68 |
if ( isset($this->actions_sup["finalisation"]) && |
if ( isset($this->actions_sup["finalisation"]) && |
69 |
isset($this->val[array_search("om_final_instruction", $this->champs)]) |
isset($this->val[array_search("om_final_instruction", $this->champs)]) |
70 |
&& $this->val[array_search("om_final_instruction", $this->champs)]== "t" ){ |
&& $this->val[array_search("om_final_instruction", $this->champs)]== "t" ){ |
71 |
|
|
72 |
|
//On cache le lien de finalisation et on affiche le bon lien pour l'édition |
73 |
unset($this->actions_sup["finalisation"]); |
unset($this->actions_sup["finalisation"]); |
74 |
|
$this->actions_sup["pdfetat"]["lien"] = "../spg/file.php?id="; |
75 |
|
$this->actions_sup["pdfetat"]["id"] = |
76 |
|
"&obj=rapport_instruction&champ=om_fichier_rapport_instruction"; |
77 |
} |
} |
78 |
//Si le document n'est pas finalisé, on affiche uniquement le lien de |
//Si le document n'est pas finalisé, on affiche uniquement le lien de |
79 |
//finalisation |
//finalisation |
80 |
if ( isset($this->actions_sup["definalisation"]) && |
if ( isset($this->actions_sup["definalisation"]) && |
81 |
isset($this->val[array_search("om_final_instruction", $this->champs)]) |
isset($this->val[array_search("om_final_instruction", $this->champs)]) |
82 |
&& $this->val[array_search("om_final_instruction", $this->champs)]!= "t" ){ |
&& $this->val[array_search("om_final_instruction", $this->champs)]!= "t" ){ |
83 |
|
|
84 |
|
//On cache le lien de finalisation et on affiche le bon lien pour l'édition |
85 |
unset($this->actions_sup["definalisation"]); |
unset($this->actions_sup["definalisation"]); |
86 |
|
$this->actions_sup["pdfetat"]["lien"] = "../app/pdf_instruction.php?idx="; |
87 |
|
$this->actions_sup["pdfetat"]["id"] = ""; |
88 |
} |
} |
89 |
} |
} |
90 |
|
|
1364 |
} |
} |
1365 |
} |
} |
1366 |
} |
} |
1367 |
|
|
1368 |
$this->updateDate("date_envoi_signature"); |
$this->updateDate("date_envoi_signature"); |
1369 |
$this->updateDate("date_retour_signature"); |
$this->updateDate("date_retour_signature"); |
1370 |
$this->updateDate("date_envoi_rar"); |
$this->updateDate("date_envoi_rar"); |
1416 |
return false; |
return false; |
1417 |
} |
} |
1418 |
} |
} |
1419 |
|
|
1420 |
|
/** |
1421 |
|
* Finalisation des documents. |
1422 |
|
*/ |
1423 |
|
function finalisation( $champ = '', $status, $sousform){ |
1424 |
|
|
1425 |
|
//Si on finalise le document |
1426 |
|
if ( $status == 1 ){ |
1427 |
|
|
1428 |
|
//Génération du PDF |
1429 |
|
$_GET['output'] = "string"; |
1430 |
|
$f = $this->f; |
1431 |
|
include '../app/pdf_instruction.php'; |
1432 |
|
|
1433 |
|
//Métadonnées du document |
1434 |
|
$metadata = array( |
1435 |
|
'filename' => $obj.'_'.$idx.'.pdf', |
1436 |
|
'mimetype' => 'application/pdf', |
1437 |
|
'size' => strlen($pdf_output) |
1438 |
|
); |
1439 |
|
|
1440 |
|
//Si le document a déjà été finalisé |
1441 |
|
//on met à jour le document mais pas son uid |
1442 |
|
if ( $this->val[array_search("om_fichier_instruction", $this->champs)] != '' ){ |
1443 |
|
$uid = $this->f->storage->update($this->val[array_search("om_fichier_instruction", $this->champs)], $pdf_output, $metadata); |
1444 |
|
} |
1445 |
|
//Sinon, on joute le document et on récupère son uid |
1446 |
|
else { |
1447 |
|
//Stockage du PDF |
1448 |
|
$uid = $this->f->storage->create($pdf_output, $metadata); |
1449 |
|
} |
1450 |
|
} |
1451 |
|
else { |
1452 |
|
//Récupération de l'uid du document finalisé |
1453 |
|
$uid = $this->val[array_search("om_fichier_instruction", $this->champs)]; |
1454 |
|
|
1455 |
|
//On dé-finalise avant de finaliser |
1456 |
|
if ( $uid == '' ){ |
1457 |
|
return -1; |
1458 |
|
} |
1459 |
|
} |
1460 |
|
|
1461 |
|
//Mise à jour des données |
1462 |
|
if ( $uid != '' ){ |
1463 |
|
// Logger |
1464 |
|
$this->addToLog("finalisation() - begin", EXTRA_VERBOSE_MODE); |
1465 |
|
// Recuperation de la valeur de la cle primaire de l'objet |
1466 |
|
if(isset($this->val[array_search($this->clePrimaire, $this->champs)])) |
1467 |
|
$id = $this->val[array_search($this->clePrimaire, $this->champs)]; |
1468 |
|
else |
1469 |
|
$id=$this->id; |
1470 |
|
|
1471 |
|
//Tableau contenant le lien vers le PDF et lien du portlet pour la mise |
1472 |
|
//à jour de l'interface |
1473 |
|
if ( $status == 0 ){ |
1474 |
|
$lien = '../app/pdf_instruction.php?idx='.$id; |
1475 |
|
} |
1476 |
|
else { |
1477 |
|
$lien = '../spg/file.php?obj=instruction&'. |
1478 |
|
'champ=om_fichier_instruction&id='.$id; |
1479 |
|
} |
1480 |
|
|
1481 |
|
$retour = array( |
1482 |
|
"portlet"=> "<a href=\"#\" onclick=\"finalizeDocument(". |
1483 |
|
$id.", 'instruction', '".$sousform."', ".(($status==0)?1:0).")\"> |
1484 |
|
<span class=\"om-prev-icon om-icon-16 om-icon-fix delete-16 " |
1485 |
|
.(($status==1)?"de":"")."finalise\" title=\"". |
1486 |
|
(($status==1)?_("Reprendre la redaction du document"):_("Finaliser le document"))."\">". |
1487 |
|
(($status==1)?_("Reprendre la redaction du document"):_("Finaliser le document"))."</span> |
1488 |
|
</a>", |
1489 |
|
"pdf" => $lien |
1490 |
|
); |
1491 |
|
|
1492 |
|
foreach ( $this->champs as $key=>$value ) |
1493 |
|
$val[$value] = $this->val[$key]; |
1494 |
|
$val['date_evenement']=$this->dateDBToForm($val['date_evenement']); |
1495 |
|
$val['archive_date_complet']=$this->dateDBToForm($val['archive_date_complet']); |
1496 |
|
$val['archive_date_rejet']=$this->dateDBToForm($val['archive_date_rejet']); |
1497 |
|
$val['archive_date_limite']=$this->dateDBToForm($val['archive_date_limite']); |
1498 |
|
$val['archive_date_notification_delai']=$this->dateDBToForm($val['archive_date_notification_delai']); |
1499 |
|
$val['archive_date_decision']=$this->dateDBToForm($val['archive_date_decision']); |
1500 |
|
$val['archive_date_validite']=$this->dateDBToForm($val['archive_date_validite']); |
1501 |
|
$val['archive_date_achevement']=$this->dateDBToForm($val['archive_date_achevement']); |
1502 |
|
$val['archive_date_chantier']=$this->dateDBToForm($val['archive_date_chantier']); |
1503 |
|
$val['archive_date_conformite']=$this->dateDBToForm($val['archive_date_conformite']); |
1504 |
|
$val['archive_date_dernier_depot']=$this->dateDBToForm($val['archive_date_dernier_depot']); |
1505 |
|
$val['archive_date_limite_incompletude']=$this->dateDBToForm($val['archive_date_limite_incompletude']); |
1506 |
|
$val['date_finalisation_courrier']=$this->dateDBToForm($val['date_finalisation_courrier']); |
1507 |
|
$val['date_envoi_signature']=$this->dateDBToForm($val['date_envoi_signature']); |
1508 |
|
$val['date_retour_signature']=$this->dateDBToForm($val['date_retour_signature']); |
1509 |
|
$val['date_envoi_rar']=$this->dateDBToForm($val['date_envoi_rar']); |
1510 |
|
$val['date_retour_rar']=$this->dateDBToForm($val['date_retour_rar']); |
1511 |
|
$val['date_envoi_controle_legalite']=$this->dateDBToForm($val['date_envoi_controle_legalite']); |
1512 |
|
$val['date_retour_controle_legalite']=$this->dateDBToForm($val['date_retour_controle_legalite']); |
1513 |
|
|
1514 |
|
$this->setvalF($val); |
1515 |
|
|
1516 |
|
// Verification de la validite des donnees |
1517 |
|
$this->verifier($this->val, $this->db, DEBUG); |
1518 |
|
// Verification du verrou |
1519 |
|
$this->testverrou(); |
1520 |
|
// Si les verifications precedentes sont correctes, on procede a |
1521 |
|
// la modification, sinon on ne fait rien et on retourne une erreur |
1522 |
|
if ($this->correct) { |
1523 |
|
// Execution du trigger 'before' specifique au MODE 'update' |
1524 |
|
$this->triggermodifier( $id, $this->db, $this->val, DEBUG); |
1525 |
|
$valF = array( |
1526 |
|
"om_final_instruction"=> ($status==1)?TRUE:FALSE, |
1527 |
|
"om_fichier_instruction"=>$uid); |
1528 |
|
// Execution de la requête de modification des donnees de l'attribut |
1529 |
|
// valF de l'objet dans l'attribut table de l'objet |
1530 |
|
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
1531 |
|
DB_AUTOQUERY_UPDATE, $this->getCle($id)); |
1532 |
|
$this->addToLog("finalisation() : db->autoExecute(\"".DB_PREFIXE.$this->table."\", ".print_r($valF, true).", DB_AUTOQUERY_UPDATE, \"".$this->getCle($id)."\")", VERBOSE_MODE); |
1533 |
|
// Si une erreur survient |
1534 |
|
if (database::isError($res)) { |
1535 |
|
// Appel de la methode de recuperation des erreurs |
1536 |
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
1537 |
|
} else { |
1538 |
|
// Log |
1539 |
|
$this->addToLog(_("Requete executee"), VERBOSE_MODE); |
1540 |
|
// Log |
1541 |
|
$message = _("Enregistrement")." ".$id." "; |
1542 |
|
$message .= _("de la table")." \"".$this->table."\" "; |
1543 |
|
$message .= "[ ".$this->db->affectedRows()." "; |
1544 |
|
$message .= _("enregistrement(s) mis a jour")." ]"; |
1545 |
|
$this->addToLog($message, VERBOSE_MODE); |
1546 |
|
// Mise en place du verrou pour ne pas finaliser plusieurs fois |
1547 |
|
// le meme document |
1548 |
|
$this->verrouille(); |
1549 |
|
// Execution du trigger 'after' specifique au MODE 'update' |
1550 |
|
//$this->triggermodifierapres($id, $this->db, $val, DEBUG); |
1551 |
|
|
1552 |
|
return $retour; |
1553 |
|
} |
1554 |
|
} else { |
1555 |
|
// Message d'echec (saut d'une ligne supplementaire avant le |
1556 |
|
// message pour qu'il soit mis en evidence) |
1557 |
|
$this->addToLog("Finalisation non enregistree"); |
1558 |
|
return -1; |
1559 |
|
} |
1560 |
|
} |
1561 |
|
// Si le document n'a pas été stocké |
1562 |
|
else{ |
1563 |
|
return -1; |
1564 |
|
} |
1565 |
|
} |
1566 |
}// fin classe |
}// fin classe |
1567 |
?> |
?> |