| Line 171... |
Line 171... |
| 171 |
// Insertion dans la base
|
171 |
// Insertion dans la base
|
| 172 |
$obs_a_taguer_ids = array();
|
172 |
$obs_a_taguer_ids = array();
|
| 173 |
$img_a_taguer_ids_noms = array();
|
173 |
$img_a_taguer_ids_noms = array();
|
| 174 |
$champsEtendusObs = array();
|
174 |
$champsEtendusObs = array();
|
| 175 |
foreach ($observations as $obs) {
|
175 |
foreach ($observations as $obs) {
|
| 176 |
$obs_etendue = $obs['obs_etendue'];
|
176 |
$fullObs = $obs;
|
| 177 |
if (isset($obs['image_nom'])) { $obs_images['image_nom'] = $obs['image_nom'];}
|
- |
|
| 178 |
if (isset($obs['image_b64'])) {$obs_images['image_b64'] = $obs['image_b64'];}
|
- |
|
| 179 |
unset($obs['obs_etendue']);
|
177 |
unset($obs['obs_etendue']);
|
| 180 |
unset($obs['image_nom']);
|
178 |
unset($obs['image_nom']);
|
| 181 |
unset($obs['image_b64']);
|
179 |
unset($obs['image_b64']);
|
| Line 182... |
Line 180... |
| 182 |
|
180 |
|
| Line 190... |
Line 188... |
| 190 |
}
|
188 |
}
|
| Line 191... |
Line 189... |
| 191 |
|
189 |
|
| 192 |
// récupérer l'id de l'obs nouvellement insérée
|
190 |
// récupérer l'id de l'obs nouvellement insérée
|
| 193 |
$idNouvelleObs = Cel::db()->obtenirDernierId();
|
191 |
$idNouvelleObs = Cel::db()->obtenirDernierId();
|
| 194 |
$obs_a_taguer_ids[] = $idNouvelleObs;
|
192 |
$obs_a_taguer_ids[] = $idNouvelleObs;
|
| Line 195... |
Line 193... |
| 195 |
$champsEtendusObs[$idNouvelleObs] = $obs_etendue;
|
193 |
$champsEtendusObs[$idNouvelleObs] = $fullObs['obs_etendue'];
|
| 196 |
|
194 |
|
| 197 |
$imgAAjouter = null;
|
195 |
$imgAAjouter = null;
|
| 198 |
if (!empty($obs_images)) {
|
196 |
if (isset($fullObs['image_nom'])) {
|
| 199 |
$imgAAjouter = $this->traiterImagesALierAObs($idNouvelleObs, $obs_images);
|
197 |
$imgAAjouter = $this->traiterImagesALierAObs($idNouvelleObs, $fullObs);
|
| 200 |
if ($imgAAjouter != null) {
|
198 |
if ($imgAAjouter != null) {
|
| 201 |
foreach ($imgAAjouter as $uneImgAAjouter) {
|
199 |
foreach ($imgAAjouter as $uneImgAAjouter) {
|
| 202 |
$nomsOriginauxImagesTemp[] = $uneImgAAjouter['nom'];
|
200 |
$nomsOriginauxImagesTemp[] = $uneImgAAjouter['nom'];
|
| Line 488... |
Line 486... |
| 488 |
if(! $champs_etendus_obs) return TRUE;
|
486 |
if(! $champs_etendus_obs) return TRUE;
|
| Line 489... |
Line 487... |
| 489 |
|
487 |
|
| 490 |
return $gestionChampsEtendus->ajouterParLots($champs_etendus_obs, $this->projet);
|
488 |
return $gestionChampsEtendus->ajouterParLots($champs_etendus_obs, $this->projet);
|
| Line 491... |
Line 489... |
| 491 |
}
|
489 |
}
|
| 492 |
|
490 |
|
| 493 |
private function traiterImagesALierAObs($idObs, $obsImages) {
|
491 |
private function traiterImagesALierAObs($idObs, $obs) {
|
| 494 |
$imgAAjouter = null;
|
492 |
$imgAAjouter = null;
|
| 495 |
if (is_array($obsImages['image_nom'])) {
|
493 |
if (is_array($obs['image_nom'])) {
|
| 496 |
$imgAAjouter = array();
|
494 |
$imgAAjouter = array();
|
| 497 |
foreach ($obsImages['image_nom'] as $index => $nom_image) {
|
495 |
foreach ($obs['image_nom'] as $index => $nom_image) {
|
| 498 |
$image = array();
|
496 |
$image = array();
|
| 499 |
$image['id_utilisateur'] = $this->userId;
|
497 |
$image['id_utilisateur'] = $this->userId;
|
| 500 |
$image['id_obs'] = $idObs;
|
498 |
$image['id_obs'] = $idObs;
|
| 501 |
$image['nom'] = $nom_image;
|
499 |
$image['nom'] = $nom_image;
|
| 502 |
// on suppose que les b64 des images sont envoyés dans le même ordre que leurs noms
|
500 |
// on suppose que les b64 des images sont envoyés dans le même ordre que leurs noms
|
| 503 |
// TODO: indexer le tableau avec le nom des images
|
501 |
// TODO: indexer le tableau avec le nom des images
|
| 504 |
$image['b64'] = isset($obsImages['image_b64'][$index]) ? $obsImages['image_b64'][$index] : '';
|
502 |
$image['b64'] = isset($obs['image_b64'][$index]) ? $obs['image_b64'][$index] : '';
|
| 505 |
$this->debug[] = 'Contient B64 : '.(empty($obsImages['image_b64']) ? 'non' : 'oui');
|
503 |
$this->debug[] = 'Contient B64 : '.(empty($obs['image_b64']) ? 'non' : 'oui');
|
| 506 |
$imgAAjouter[] = $image;
|
504 |
$imgAAjouter[] = $image;
|
| 507 |
}
|
- |
|
| 508 |
} else {
|
505 |
}
|
| 509 |
if (!empty($obsImages['image_nom'])) {
|
506 |
} else {
|
| 510 |
$imgAAjouter = array();
|
507 |
$imgAAjouter = array();
|
| 511 |
$imgAAjouter['id_utilisateur'] = $this->userId;
|
508 |
$imgAAjouter['id_utilisateur'] = $this->userId;
|
| 512 |
$imgAAjouter['id_obs'] = $idObs;
|
509 |
$imgAAjouter['id_obs'] = $idObs;
|
| 513 |
$imgAAjouter['nom'] = $obsImages['image_nom'];
|
510 |
$imgAAjouter['nom'] = $obs['image_nom'];
|
| 514 |
$imgAAjouter['b64'] = isset($obsImages['image_b64']) ? $obsImages['image_b64'] : array();
|
- |
|
| 515 |
$this->debug[] = 'Contient B64 : '.(empty($obsImages['image_b64']) ? 'non' : 'oui');
|
511 |
$imgAAjouter['b64'] = isset($obs['image_b64']) ? $obs['image_b64'] : array();
|
| Line 516... |
Line 512... |
| 516 |
}
|
512 |
$this->debug[] = 'Contient B64 : '.(empty($obs['image_b64']) ? 'non' : 'oui');
|
| 517 |
}
|
513 |
}
|