244 |
function majDossierAutorisation() { |
function majDossierAutorisation() { |
245 |
|
|
246 |
/* |
/* |
247 |
* Récupération des données du dernier dossier soumis à arrété ou P0 |
* Mise à jour des données (terrain, ref. cadastrales, demandeurs, lots) |
248 |
*/ |
*/ |
249 |
// Initialisation des requêtes |
// Initialisation des requêtes |
250 |
$sql_terrain = "SELECT dossier.terrain_references_cadastrales, |
$sql_terrain = "SELECT dossier.terrain_references_cadastrales, |
290 |
AND date_decision IS NOT NULL AND avis_decision.typeavis='F' AND instruction.date_retour_signature IS NOT NULL"; |
AND date_decision IS NOT NULL AND avis_decision.typeavis='F' AND instruction.date_retour_signature IS NOT NULL"; |
291 |
} |
} |
292 |
|
|
|
/* |
|
|
* Mise à jour des données (terrain, ref. cadastrales, demandeurs, lots) |
|
|
*/ |
|
293 |
//terrain |
//terrain |
294 |
$res_terrain = $this->db->query($sql_terrain.$sql_where); |
$res_terrain = $this->db->query($sql_terrain.$sql_where); |
295 |
$this->addToLog("majDossierAutorisation(): db->query(\"".$sql_terrain.$sql_where."\")", VERBOSE_MODE); |
$this->addToLog("majDossierAutorisation(): db->query(\"".$sql_terrain.$sql_where."\")", VERBOSE_MODE); |
359 |
$ldad->ajouter($valDemandeurUpdate, $this->db, DEBUG); |
$ldad->ajouter($valDemandeurUpdate, $this->db, DEBUG); |
360 |
} |
} |
361 |
} |
} |
|
} |
|
362 |
|
|
363 |
|
|
364 |
|
/** |
365 |
|
* Mise à jour des dates |
366 |
|
*/ |
367 |
|
// Requêtes permettant de les recupérer |
368 |
|
$sql_date_depot_decision_validite = "SELECT MIN(dossier.date_depot) as date_depot, MIN(dossier.date_decision) as date_decision, MAX(dossier.date_validite) as date_validite FROM ".DB_PREFIXE."dossier |
369 |
|
WHERE dossier.dossier_autorisation='".$this->getVal("dossier_autorisation")."'"; |
370 |
|
|
371 |
|
$sql_date_doc_daact = "SELECT MAX(dossier.date_chantier) as date_chantier, MAX(dossier.date_achevement) as date_achevement FROM ".DB_PREFIXE."dossier |
372 |
|
LEFT OUTER JOIN ".DB_PREFIXE."instruction ON |
373 |
|
dossier.dossier=instruction.dossier |
374 |
|
LEFT OUTER JOIN ".DB_PREFIXE."avis_decision ON |
375 |
|
dossier.avis_decision = avis_decision.avis_decision |
376 |
|
WHERE dossier.dossier_autorisation = '".$this->getVal("dossier_autorisation")."' |
377 |
|
AND date_decision IS NOT NULL AND avis_decision.typeavis='F' AND instruction.date_retour_signature IS NOT NULL"; |
378 |
|
// Récupération des infos avec la 1ere requête |
379 |
|
$res_date_depot_decision_validite = $this->db->query($sql_date_depot_decision_validite); |
380 |
|
$this->addToLog("majDossierAutorisation(): db->query(\"".$sql_date_depot_decision_validite."\")", VERBOSE_MODE); |
381 |
|
database::isError($res_date_depot_decision_validite); |
382 |
|
$row_date_depot_decision_validite = $res_date_depot_decision_validite->fetchRow(DB_FETCHMODE_ASSOC); |
383 |
|
// Récupération des infos avec la 2nd requête |
384 |
|
$res_date_doc_daact = $this->db->query($sql_date_doc_daact); |
385 |
|
$this->addToLog("majDossierAutorisation(): db->query(\"".$sql_date_doc_daact."\")", VERBOSE_MODE); |
386 |
|
database::isError($res_date_doc_daact); |
387 |
|
$row_date_doc_daact = $res_date_doc_daact->fetchRow(DB_FETCHMODE_ASSOC); |
388 |
|
// Fusion des 2 résultats |
389 |
|
$row_date = array_merge($row_date_depot_decision_validite, $row_date_doc_daact); |
390 |
|
// Si pas de date on remplace "" par NULL pour éviter les erreurs de base de données |
391 |
|
foreach($row_date as $key => $date) { |
392 |
|
if($date == "") { |
393 |
|
$row_date[$key] = NULL; |
394 |
|
} |
395 |
|
} |
396 |
|
// Mise à jour du DA avec ces nouvelles dates |
397 |
|
$res_update_date = $this->db->autoExecute(DB_PREFIXE."dossier_autorisation", |
398 |
|
$row_date, |
399 |
|
DB_AUTOQUERY_UPDATE, |
400 |
|
"dossier_autorisation = '".$this->getVal("dossier_autorisation")."'"); |
401 |
|
database::isError($res_update_date); |
402 |
|
|
403 |
|
} |
404 |
}// fin classe |
}// fin classe |
405 |
?> |
?> |