18 |
- voir script_lang.js : bible ... |
- voir script_lang.js : bible ... |
19 |
*/ |
*/ |
20 |
require_once ("../gen/obj/instruction.class.php"); |
require_once ("../gen/obj/instruction.class.php"); |
21 |
|
require_once("../services/outgoing/messageenqueuer.php"); |
22 |
|
|
23 |
class instruction extends instruction_gen { |
class instruction extends instruction_gen { |
24 |
|
|
30 |
$this->constructeur($id,$db,$debug); |
$this->constructeur($id,$db,$debug); |
31 |
}// fin constructeur |
}// fin constructeur |
32 |
|
|
33 |
|
// {{{ Gestion de la confidentialité des données spécifiques |
34 |
|
|
35 |
|
/** |
36 |
|
* Surcharge pour gérer les actions disponibles dans le portlet |
37 |
|
*/ |
38 |
|
function checkAccessibility() { |
39 |
|
// |
40 |
|
parent::checkAccessibility(); |
41 |
|
// Si l'utilisateur est un intructeur qui en correspond pas à la |
42 |
|
// division du dossier |
43 |
|
if ($this->f->isUserInstructeur() |
44 |
|
&& isset($this->f->om_utilisateur["division"]) |
45 |
|
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()) { |
46 |
|
// |
47 |
|
$this->actions_sup = array(); |
48 |
|
$this->setParameter("actions", array()); |
49 |
|
} |
50 |
|
// Si une action 'lu' est présente et que le champ lu est à true |
51 |
|
// on supprime l'action |
52 |
|
if (isset($this->actions_sup["lu"]) |
53 |
|
&& isset($this->val[array_search("lu", $this->champs)]) |
54 |
|
&& $this->val[array_search("lu", $this->champs)]== "t") { |
55 |
|
unset($this->actions_sup["lu"]); |
56 |
|
} |
57 |
|
} |
58 |
|
|
59 |
|
/** |
60 |
|
* Cette methode est à surcharger elle permet de tester dans chaque classe |
61 |
|
* des droits des droits spécifiques en fonction des données |
62 |
|
*/ |
63 |
|
function canAccess() { |
64 |
|
// Si l'utilisateur est un intructeur qui ne correspond pas à la |
65 |
|
// division du dossier |
66 |
|
if ($this->f->isUserInstructeur() |
67 |
|
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier() |
68 |
|
&& $this->getParameter("maj") != 3) { |
69 |
|
// |
70 |
|
return false; |
71 |
|
} |
72 |
|
// |
73 |
|
return true; |
74 |
|
} |
75 |
|
|
76 |
|
/** |
77 |
|
* Cette méthode permet de récupérer la division d'un dossier |
78 |
|
*/ |
79 |
|
function getDivisionFromDossier() { |
80 |
|
// |
81 |
|
if (!isset($this->val[array_search("dossier", $this->champs)])) { |
82 |
|
return NULL; |
83 |
|
} |
84 |
|
// |
85 |
|
$sql = "select division from ".DB_PREFIXE."dossier "; |
86 |
|
$sql .= " where dossier='".$this->val[array_search("dossier", $this->champs)]."'"; |
87 |
|
// |
88 |
|
$division = $this->db->getOne($sql); |
89 |
|
$this->addToLog("getDivisionFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
90 |
|
database::isError($division); |
91 |
|
// |
92 |
|
return $division; |
93 |
|
} |
94 |
|
|
95 |
|
// }}} |
96 |
|
|
97 |
function cleSecondaire($id,&$db,$val,$DEBUG) { |
function cleSecondaire($id,&$db,$val,$DEBUG) { |
98 |
parent::cleSecondaire($id,$db,$val,$DEBUG); |
parent::cleSecondaire($id,$db,$val,$DEBUG); |
99 |
// controle suppression cle secondaire [secondary key delete control] |
// controle suppression cle secondaire [secondary key delete control] |
114 |
} |
} |
115 |
} |
} |
116 |
|
|
117 |
|
/*Met des valeurs par défaut dans certains des sous-formulaire*/ |
118 |
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){ |
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){ |
119 |
if ($validation==0 and $maj<2) { |
if ($validation==0 and $maj<2) { |
120 |
if ($maj == 0){ |
if ($maj == 0){ |
130 |
$this->idxformulaire=$idxformulaire; |
$this->idxformulaire=$idxformulaire; |
131 |
} |
} |
132 |
|
|
133 |
|
/*Affecte un type à certains champs*/ |
134 |
function setType(&$form,$maj) { |
function setType(&$form,$maj) { |
135 |
parent::setType($form,$maj); |
parent::setType($form,$maj); |
136 |
if ($maj < 2) { //ajouter et modifier |
if ($maj < 2) { //ajouter et modifier |
195 |
$form->setType('accord_tacite', 'hidden'); |
$form->setType('accord_tacite', 'hidden'); |
196 |
$form->setType('action', 'hidden'); |
$form->setType('action', 'hidden'); |
197 |
$form->setType('delai_notification', 'hidden'); |
$form->setType('delai_notification', 'hidden'); |
198 |
$form->setType('avis', 'hidden'); |
$form->setType('avis_decision', 'hidden'); |
199 |
$form->setType('archive_delai', 'hidden'); |
$form->setType('archive_delai', 'hidden'); |
200 |
$form->setType('archive_etat', 'hidden'); |
$form->setType('archive_etat', 'hidden'); |
201 |
$form->setType('archive_accord_tacite', 'hidden'); |
$form->setType('archive_accord_tacite', 'hidden'); |
211 |
$form->setType('archive_date_chantier', 'hidden'); |
$form->setType('archive_date_chantier', 'hidden'); |
212 |
} |
} |
213 |
|
|
214 |
|
/*Met des valeurs choisies dans certains select du formulaire*/ |
215 |
function setSelect(&$form, $maj,&$db,$DEBUG) { |
function setSelect(&$form, $maj,&$db,$DEBUG) { |
216 |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
217 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
228 |
$nature_dossier."' or (nature ='T' and nature !='CU')) order by evenement.action"; |
$nature_dossier."' or (nature ='T' and nature !='CU')) order by evenement.action"; |
229 |
|
|
230 |
// *** attention en dur le CU |
// *** attention en dur le CU |
231 |
|
$this->addToLog("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE); |
232 |
|
|
233 |
$res = $db->query($sql); |
$res = $db->query($sql); |
234 |
if (database::isError($res)) |
if (database::isError($res)) |
282 |
$form->setRegroupe('bible2','F',''); |
$form->setRegroupe('bible2','F',''); |
283 |
} |
} |
284 |
|
|
285 |
|
/*Change le libellé de certains champs*/ |
286 |
function setLib(&$form,$maj) { |
function setLib(&$form,$maj) { |
287 |
parent :: setLib($form,$maj); |
parent :: setLib($form,$maj); |
288 |
$form->setLib('libelle',' '); |
$form->setLib('libelle',' '); |
294 |
} |
} |
295 |
|
|
296 |
// ================================================================== |
// ================================================================== |
297 |
// trigger avant modification données [trigger before modify data] |
// trigger avant modification des données [trigger before modify data] |
298 |
// ================================================================== |
// ================================================================== |
299 |
function triggerajouter($id,&$db,$val,$DEBUG) { |
function triggerajouter($id,&$db,$val,$DEBUG) { |
300 |
// mise a jour instruction avec evenement |
// mise a jour instruction avec evenement |
318 |
} |
} |
319 |
$this->valF['accord_tacite']=$row['accord_tacite']; |
$this->valF['accord_tacite']=$row['accord_tacite']; |
320 |
$this->valF['delai_notification']=$row['delai_notification']; |
$this->valF['delai_notification']=$row['delai_notification']; |
321 |
if(isset($row['avis']) and !empty($row['avis'])) { |
if(isset($row['avis_decision']) and !empty($row['avis_decision'])) { |
322 |
$this->valF['avis']=$row['avis']; |
$this->valF['avis_decision']=$row['avis_decision']; |
323 |
} else { |
} else { |
324 |
$this->valF['avis']=NULL; |
$this->valF['avis_decision']=NULL; |
325 |
} |
} |
326 |
if($row['lettretype']!="") |
if($row['lettretype']!="") |
327 |
$this->valF['lettretype']=$row['lettretype']; |
$this->valF['lettretype']=$row['lettretype']; |
341 |
$this->valF['archive_delai']=$row['delai']; |
$this->valF['archive_delai']=$row['delai']; |
342 |
$this->valF['archive_accord_tacite']=$row['accord_tacite']; |
$this->valF['archive_accord_tacite']=$row['accord_tacite']; |
343 |
$this->valF['archive_etat']=$row['etat']; |
$this->valF['archive_etat']=$row['etat']; |
344 |
$this->valF['archive_avis']=$row['avis']; |
$this->valF['archive_avis']=$row['avis_decision']; |
345 |
// compatibilite pgsql |
// compatibilite pgsql |
346 |
if($row['date_complet']!='') |
if($row['date_complet']!='') |
347 |
$this->valF['archive_date_complet']=$row['date_complet']; |
$this->valF['archive_date_complet']=$row['date_complet']; |
428 |
$valF['accord_tacite']= $this->regle($row['regle_accord_tacite']); |
$valF['accord_tacite']= $this->regle($row['regle_accord_tacite']); |
429 |
} |
} |
430 |
if($row['regle_avis']!=''){ |
if($row['regle_avis']!=''){ |
431 |
$valF['avis']= $this->regle($row['regle_avis']); |
$valF['avis_decision']= $this->regle($row['regle_avis']); |
432 |
} |
} |
433 |
if($row['regle_date_limite']!=''){ |
if($row['regle_date_limite']!=''){ |
434 |
$valF['date_limite']= $this->regle($row['regle_date_limite']); |
$valF['date_limite']= $this->regle($row['regle_date_limite']); |
521 |
case "acceptation" : |
case "acceptation" : |
522 |
$valF['etat']= $this->valF['etat']; |
$valF['etat']= $this->valF['etat']; |
523 |
$valF['date_decision']= $this->valF['datecourrier']; |
$valF['date_decision']= $this->valF['datecourrier']; |
524 |
$valF['avis']= $this->valF['avis']; |
$valF['avis_decision']= $this->valF['avis_decision']; |
525 |
// date de validite = date de l evenement + delai |
// date de validite = date de l evenement + delai |
526 |
$valF['date_validite'] = $this->moisdate($this->valF['datecourrier'],$this->valF['delai']); |
$valF['date_validite'] = $this->moisdate($this->valF['datecourrier'],$this->valF['delai']); |
527 |
break; |
break; |
528 |
case "refus" : |
case "refus" : |
529 |
$valF['etat']= $this->valF['etat']; |
$valF['etat']= $this->valF['etat']; |
530 |
$valF['date_decision']= $this->valF['datecourrier']; |
$valF['date_decision']= $this->valF['datecourrier']; |
531 |
$valF['avis']= $this->valF['avis']; |
$valF['avis_decision']= $this->valF['avis_decision']; |
532 |
break; |
break; |
533 |
case "prolongation" : |
case "prolongation" : |
534 |
$valF['date_validite'] = $this->moisdate($this->valF['archive_date_validite'],$this->valF['delai']); |
$valF['date_validite'] = $this->moisdate($this->valF['archive_date_validite'],$this->valF['delai']); |
537 |
$valF['date_limite'] = $this->moisdate($this->valF['datecourrier'],$this->valF['delai']); |
$valF['date_limite'] = $this->moisdate($this->valF['datecourrier'],$this->valF['delai']); |
538 |
$valF['etat']= $this->valF['etat']; |
$valF['etat']= $this->valF['etat']; |
539 |
$valF['accord_tacite']= $this->valF['accord_tacite']; |
$valF['accord_tacite']= $this->valF['accord_tacite']; |
540 |
$valF['avis']= $this->valF['avis']; |
$valF['avis_decision']= $this->valF['avis_decision']; |
541 |
$valF['date_decision']= $this->valF['datecourrier']; |
$valF['date_decision']= $this->valF['datecourrier']; |
542 |
$temp = $valF['date_limite']; |
$temp = $valF['date_limite']; |
543 |
$valF['date_validite']= $this->moisdate($temp,2); |
$valF['date_validite']= $this->moisdate($temp,2); |
573 |
$db->affectedRows()." "._('enregistrement'). |
$db->affectedRows()." "._('enregistrement'). |
574 |
" "._('mis_a_jour')."]" ; |
" "._('mis_a_jour')."]" ; |
575 |
} |
} |
576 |
|
// verification si envoi vers ERP est active |
577 |
|
if ($this->f->getParameter('option_erp') != "") { |
578 |
|
// la nature du dossier |
579 |
|
$nature_dossier = substr($this->idxformulaire,0,2); |
580 |
|
$dossier_erp = $this->getFromDB("SELECT erp FROM ".DB_PREFIXE."dossier WHERE dossier = '" . |
581 |
|
$this->valF['dossier'] . "'"); |
582 |
|
$evenement_libelle = $this->getFromDB( |
583 |
|
"SELECT libelle FROM ".DB_PREFIXE."evenement WHERE evenement = '" . |
584 |
|
$this->valF['evenement'] . "'"); |
585 |
|
if ($dossier_erp == 't') { |
586 |
|
// envoi du message en cas d'un PC qui est ERP et sur lequel un evenement |
587 |
|
// d'acceptation etait fait |
588 |
|
if ($nature_dossier == |
589 |
|
$this->f->getParameter('erp_evenement_accepter_dossier_PC') |
590 |
|
&& $this->valF['evenement'] == |
591 |
|
$this->f->getParameter('erp_evenement_accepter_sans_reserve')) { |
592 |
|
$msgenque = new MessageEnqueuer(); |
593 |
|
$msgenque->setDossierInstructionIdentifier($this->valF['dossier']); |
594 |
|
$msgenque->setDecision($evenement_libelle); |
595 |
|
$msgenque->enqueueMessage($msgenque::$ERP_ARRETE_PC_EFFECTUE); |
596 |
|
} |
597 |
|
if ($this->valF['evenement'] == |
598 |
|
$this->f->getParameter('erp_evenement_refuser_dossier')) { |
599 |
|
$msgenque = new MessageEnqueuer(); |
600 |
|
$msgenque->setDossierInstructionIdentifier($this->valF['dossier']); |
601 |
|
$msgenque->enqueueMessage($msgenque::$ERP_DECISION_CONFORMITE_EFFECTUE); |
602 |
|
} |
603 |
|
} |
604 |
|
} // fin de if ($this->f->getParameter('option_erp') != "") |
605 |
} |
} |
606 |
|
|
607 |
|
|
608 |
|
/** |
609 |
|
* Fait une requette sql pour extraire la valeur d'un champ, et retourne |
610 |
|
* cette valeur |
611 |
|
* @param string $sql La requete sql a executer |
612 |
|
* @return La valeur du champs cherche, sinon NULL. En cas d'erreur de la BD |
613 |
|
* l'execution s'arrete. |
614 |
|
*/ |
615 |
|
function getFromDB($sql) { |
616 |
|
//$sql = "SELECT libelle FROM ".DB_PREFIXE."dossier WHERE dossier = '" . $dossier . "'"; |
617 |
|
$res = $this->db->limitquery($sql, 0, 1); |
618 |
|
$this->addToLog("getDossierERPSpecification(): db->limitquery(\"". |
619 |
|
str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE); |
620 |
|
// Si une erreur survient on die |
621 |
|
if (database::isError($res, true)) { |
622 |
|
// Appel de la methode de recuperation des erreurs |
623 |
|
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'instruction'); |
624 |
|
} |
625 |
|
// retourne la nature du dossier |
626 |
|
while ($row =& $res->fetchRow()) { |
627 |
|
return $row[0]; |
628 |
|
} |
629 |
|
// la nature n'etait pas trouve, ce qui ne devrait pas se passer |
630 |
|
return NULL; |
631 |
|
|
632 |
|
} |
633 |
|
|
634 |
|
|
635 |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
636 |
/* |
/* |
637 |
* cette fonction apour objet de permettre de modifier la date courrier |
* cette fonction a pour objet de permettre de modifier la date courrier |
638 |
*/ |
*/ |
639 |
$valF=array(); |
$valF=array(); |
640 |
$sql= "select action from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement']; |
$sql= "select action from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement']; |
696 |
$valF['accord_tacite']=$val['archive_accord_tacite']; |
$valF['accord_tacite']=$val['archive_accord_tacite']; |
697 |
$valF['etat']=$val['archive_etat']; |
$valF['etat']=$val['archive_etat']; |
698 |
if($val['archive_avis']=='') |
if($val['archive_avis']=='') |
699 |
$valF['avis']= null; |
$valF['avis_decision']= null; |
700 |
else |
else |
701 |
$valF['avis']=$val['archive_avis']; |
$valF['avis_decision']=$val['archive_avis']; |
702 |
// if= compatibilite pgsql |
// if= compatibilite pgsql |
703 |
if($val['archive_date_complet']!='') |
if($val['archive_date_complet']!='') |
704 |
$valF['date_complet']=$val['archive_date_complet']; |
$valF['date_complet']=$val['archive_date_complet']; |