Line 436... |
Line 436... |
436 |
$elements = $this->executerRequeteHistorique($requete);
|
436 |
$elements = $this->executerRequeteHistorique($requete);
|
437 |
return $elements;
|
437 |
return $elements;
|
438 |
}
|
438 |
}
|
Line 439... |
Line 439... |
439 |
|
439 |
|
- |
|
440 |
private function executerRequete($requete) {
|
440 |
private function executerRequete($requete) {
|
441 |
$infos = null;
|
441 |
try {
|
442 |
try {
|
442 |
$infos = $this->bdd->query($requete)->fetchAll(PDO::FETCH_ASSOC);
|
443 |
$infos = $this->bdd->query($requete)->fetchAll(PDO::FETCH_ASSOC);
|
443 |
if ($infos === false) {
|
444 |
if ($infos === false) {
|
444 |
$this->messages[] = "La requête a retourné aucun résultat.";
|
445 |
$this->messages[] = "La requête a retourné aucun résultat.";
|
Line 484... |
Line 485... |
484 |
$infos_elements_1er = $this->executerRequete($requete_elements_1er);
|
485 |
$infos_elements_1er = $this->executerRequete($requete_elements_1er);
|
Line 485... |
Line 486... |
485 |
|
486 |
|
486 |
// Construction de la requête pour récupérer les second éléments
|
487 |
// Construction de la requête pour récupérer les second éléments
|
487 |
$elements_1er_cle_ligne = array();
|
488 |
$elements_1er_cle_ligne = array();
|
488 |
foreach ($infos_elements_1er as $info) {
|
489 |
foreach ($infos_elements_1er as $info) {
|
489 |
$elements_1er_cle_ligne[] = $info['cmhl_cle_ligne'];
|
490 |
$elements_1er_cle_ligne[] = '"'.$info['cmhl_cle_ligne'].'"';
|
490 |
}
|
491 |
}
|
491 |
$chaine_1er_elements = 'AND h1.cmhl_cle_ligne IN ('.str_replace(',,',',',implode(',', $elements_1er_cle_ligne)).') ';
|
492 |
$chaine_1er_elements = 'AND h1.cmhl_cle_ligne IN ('.str_replace(',,',',',implode(',', $elements_1er_cle_ligne)).') ';
|
Line 492... |
Line 493... |
492 |
$requete_elements_2nd = sprintf($requete, $chaine_1er_elements, '2');
|
493 |
$requete_elements_2nd = sprintf($requete, $chaine_1er_elements, '2');
|
Line 607... |
Line 608... |
607 |
}
|
608 |
}
|
Line 608... |
Line 609... |
608 |
|
609 |
|
609 |
private function getXmlHisto($info) {
|
610 |
private function getXmlHisto($info) {
|
610 |
$xml = '';
|
611 |
$xml = '';
|
611 |
if ($info['cmhl_ce_etat'] == '3') {
|
612 |
if ($info['cmhl_ce_etat'] == '3') {
|
612 |
$xml = $info['enrg_prec'];
|
613 |
$xml = @$info['enrg_prec'];
|
613 |
} else {
|
614 |
} else {
|
614 |
$xml = $info['cmhl_enregistrement'];
|
615 |
$xml = $info['cmhl_enregistrement'];
|
615 |
}
|
616 |
}
|
616 |
return $xml;
|
617 |
return $xml;
|
Line 623... |
Line 624... |
623 |
foreach ($nouveau as $cle => $valeur) {
|
624 |
foreach ($nouveau as $cle => $valeur) {
|
624 |
$diff[$cle] = array('type' => 'A', 'type_txt' => 'Ajout', 'nouveau' => $valeur, 'ancien' => ' ');
|
625 |
$diff[$cle] = array('type' => 'A', 'type_txt' => 'Ajout', 'nouveau' => $valeur, 'ancien' => ' ');
|
625 |
}
|
626 |
}
|
626 |
} else if ($info['cmhl_ce_etat'] == '2') {
|
627 |
} else if ($info['cmhl_ce_etat'] == '2') {
|
627 |
$nouveau = $this->getTableauDepuisXmlHisto($info['cmhl_enregistrement']);
|
628 |
$nouveau = $this->getTableauDepuisXmlHisto($info['cmhl_enregistrement']);
|
628 |
$ancien = $this->getTableauDepuisXmlHisto($info['enrg_prec']);
|
629 |
$ancien = @$this->getTableauDepuisXmlHisto($info['enrg_prec']);
|
629 |
foreach ($nouveau as $cle => $valeur) {
|
630 |
foreach ($nouveau as $cle => $valeur) {
|
630 |
if (!isset($ancien[$cle])) {
|
631 |
if (!isset($ancien[$cle])) {
|
631 |
$diff[$cle] = array('type' => 'A', 'type_txt' => 'Ajout', 'nouveau' => $valeur, 'ancien' => ' ');
|
632 |
$diff[$cle] = array('type' => 'A', 'type_txt' => 'Ajout', 'nouveau' => $valeur, 'ancien' => ' ');
|
632 |
} else if (isset($ancien[$cle]) && $ancien[$cle] != $valeur) {
|
633 |
} else if (isset($ancien[$cle]) && $ancien[$cle] != $valeur) {
|
633 |
$diff[$cle] = array('type' => 'M', 'type_txt' => 'Modification', 'nouveau' => $valeur, 'ancien' => $ancien[$cle]);
|
634 |
$diff[$cle] = array('type' => 'M', 'type_txt' => 'Modification', 'nouveau' => $valeur, 'ancien' => $ancien[$cle]);
|
Line 649... |
Line 650... |
649 |
$diff['date_nouvelle'] = strftime($format, strtotime($info['cmhl_date_modification']));
|
650 |
$diff['date_nouvelle'] = strftime($format, strtotime($info['cmhl_date_modification']));
|
650 |
$diff['date_ancienne'] = '';
|
651 |
$diff['date_ancienne'] = '';
|
651 |
$diff['etat'] = 'A';
|
652 |
$diff['etat'] = 'A';
|
652 |
} else if ($info['cmhl_ce_etat'] == '2') {
|
653 |
} else if ($info['cmhl_ce_etat'] == '2') {
|
653 |
$diff['date_nouvelle'] = strftime($format, strtotime($info['cmhl_date_modification']));
|
654 |
$diff['date_nouvelle'] = strftime($format, strtotime($info['cmhl_date_modification']));
|
654 |
$diff['date_ancienne'] = strftime($format, strtotime($info['date_prec']));
|
655 |
$diff['date_ancienne'] = @strftime($format, strtotime($info['date_prec']));
|
655 |
$diff['etat'] = 'M';
|
656 |
$diff['etat'] = 'M';
|
656 |
} else if ($info['cmhl_ce_etat'] == '3') {
|
657 |
} else if ($info['cmhl_ce_etat'] == '3') {
|
657 |
$diff['etat'] = 'S';
|
658 |
$diff['etat'] = 'S';
|
658 |
}
|
659 |
}
|
659 |
return $diff;
|
660 |
return $diff;
|