1 |
<?php |
2 |
/** |
3 |
* Ce script permet de mettre à jour les dates d'envoi de lettres avec AR |
4 |
* des instructions |
5 |
* |
6 |
* @package openfoncier |
7 |
* @version SVN : $Id$ |
8 |
*/ |
9 |
|
10 |
// |
11 |
require_once "../obj/utils.class.php"; |
12 |
|
13 |
|
14 |
$f = new utils("nohtml", "envoi_lettre_rar"); |
15 |
|
16 |
if(isset($_POST['date'])) { |
17 |
$date = $_POST['date']; |
18 |
} else { |
19 |
$date = ""; |
20 |
} |
21 |
if(isset($_POST['liste_instruction'])) { |
22 |
$liste_instruction = $_POST['liste_instruction']; |
23 |
} else { |
24 |
$liste_instruction = ""; |
25 |
} |
26 |
|
27 |
// Booléen permettant de définir si un enregistrement à eu lieu |
28 |
$correct = false; |
29 |
|
30 |
// Nombre de lettres à envoyées |
31 |
$nbLettres = 0; |
32 |
|
33 |
$error = ""; |
34 |
// Si le formulaire a été validé |
35 |
if (isset($_POST['validation'])) { |
36 |
|
37 |
// Compteur du nombre de page générées |
38 |
$nbLettres = 0; |
39 |
// Liste d'id des instructions |
40 |
$id4Gen = array(); |
41 |
|
42 |
if(!empty($date) and !empty($liste_instruction)) { |
43 |
// Création d'un tableau d'instruction |
44 |
$liste = explode("\n", $_POST['liste_instruction']); |
45 |
foreach($liste as $instruction) { |
46 |
//Vérification de l'existance de l'instruction |
47 |
if($instruction != "") { |
48 |
$sql = "SELECT count(*) FROM ".DB_PREFIXE."instruction WHERE instruction=".$instruction; |
49 |
$nbInstr = $f->db->getOne($sql); |
50 |
$f->isDatabaseError(); |
51 |
$f->addToLog("app/envoi_lettre_RAR.php : ".$sql); |
52 |
if($nbInstr == "1") { |
53 |
|
54 |
// Récupération de la date d'envoi de l'instruction bippé |
55 |
$sql = "SELECT to_char(date_envoi_rar,'DD/MM/YYYY') as date_envoi_rar FROM ".DB_PREFIXE."instruction WHERE instruction=".$instruction; |
56 |
$date_envoi_rar = $f->db->getOne($sql); |
57 |
$f->isDatabaseError(); |
58 |
$f->addToLog("app/envoi_lettre_RAR.php : ".$sql); |
59 |
|
60 |
// Si pas de date ou correspond à la date du formulaire on |
61 |
// effectue le traitement |
62 |
if($date_envoi_rar == "" or $date_envoi_rar == $date) { |
63 |
|
64 |
// Mise à jour de la date d'envoi de lettre RAR |
65 |
$valF = array(); |
66 |
$valF['date_envoi_rar'] = $date; |
67 |
$f->db->autoExecute(DB_PREFIXE."instruction", $valF, DB_AUTOQUERY_UPDATE,"instruction = ".$instruction); |
68 |
$f->isDatabaseError(); |
69 |
|
70 |
$id4Gen[] = $instruction; |
71 |
$nbLettres ++; |
72 |
|
73 |
} else { |
74 |
if($error != "") { |
75 |
$error .= "<br/>"; |
76 |
} |
77 |
$error .= _("Une lettre correspondante a l'instruction no")." ".$instruction." "._("a deja ete envoyee, le bordereau ne sera pas genere"); |
78 |
} |
79 |
} else { |
80 |
if($error != "") { |
81 |
$error .= "<br/>"; |
82 |
} |
83 |
$error .= _("Le numero")." ".$instruction." "._("ne correspond a aucune instruction."); |
84 |
} |
85 |
} |
86 |
} |
87 |
} else { |
88 |
$error = _("Tous les champs doivent etre remplis."); |
89 |
} |
90 |
} |
91 |
|
92 |
// |
93 |
$f->setTitle(_("Suivi")." -> "._("Envoi lettre RAR")); |
94 |
$f->setFlag(NULL); |
95 |
$f->display(); |
96 |
|
97 |
|
98 |
/** |
99 |
* Affichage du formulaire |
100 |
*/ |
101 |
|
102 |
// Layout |
103 |
echo "<div id=\"formulaire\" class=\"ui-tabs ui-widget ui-widget-content ui-corner-all\">"; |
104 |
echo "<ul class=\"ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all\">"; |
105 |
echo "<li class=\"ui-state-default ui-corner-top ui-tabs-selected ui-state-active\"><a href=\"#tabs-1\" id=\"main\">"; |
106 |
echo _("Creation des feuillets pour RAR"); |
107 |
echo "</a></li>"; |
108 |
echo "</ul>"; |
109 |
echo "<div id=\"tabs-1\" class=\"ui-tabs-panel ui-widget-content ui-corner-bottom\">"; |
110 |
echo '<div class="formulaire">'; |
111 |
|
112 |
// Ouverture du formulaire |
113 |
echo "\t<form method=\"post\" id=\"maj_dates_form\" action=\"../app/envoi_lettre_rar.php\" class=\"formEntete ui-corner-all\">\n"; |
114 |
|
115 |
// Affichage du message d'erreur |
116 |
if(!empty($error)) { |
117 |
$f->displayMessage("error", $error); |
118 |
} |
119 |
|
120 |
// Affichage du message de validation de la saisie |
121 |
if($nbLettres > 0) { |
122 |
$f->displayMessage("ok", $nbLettres." "._("feuillets generes :")."<br/> |
123 |
<span class=\"om-prev-icon om-icon-16 pdf-16\" |
124 |
title=\""._("Ouvrir le fichier genere")."\"> |
125 |
<a class =\"bold\" href=\"../app/pdf_lettre_rar.php?liste=".implode(",",$id4Gen)."\">"._("Telecharger les feuillets pour RAR")."</a> |
126 |
</span>"); |
127 |
} |
128 |
|
129 |
// Paramétrage et affichage des champs du formulaire |
130 |
$validation = 0; |
131 |
$maj = 0; |
132 |
$champs = array("date", "liste_instruction"); |
133 |
// |
134 |
require_once '../obj/om_formulaire.class.php'; |
135 |
$form = new formulaire(NULL, $validation, $maj, $champs); |
136 |
// |
137 |
if($date == "") { |
138 |
$date = date("d/m/Y"); |
139 |
} |
140 |
$form->setLib("date", _("Date")."* :"); |
141 |
$form->setType("date", "date"); |
142 |
$form->setVal("date", $date); |
143 |
$form->setTaille("date", 10); |
144 |
$form->setMax("date", 10); |
145 |
|
146 |
$form->setLib("liste_instruction", _("Liste des instructions scannees")."* :"); |
147 |
$form->setType("liste_instruction", "textarea"); |
148 |
$form->setVal("liste_instruction", $liste_instruction); |
149 |
$form->setTaille("liste_instruction", 20); |
150 |
$form->setMax("liste_instruction", 20); |
151 |
// |
152 |
$form->entete(); |
153 |
$form->afficher($champs, $validation, false, false); |
154 |
$form->enpied(); |
155 |
|
156 |
// Affichage du bouton de submit |
157 |
echo "\t<div class=\"formControls\">\n"; |
158 |
echo "\t\t<input type=\"submit\" value=\""._("Valider")."\""; |
159 |
echo " name=\"validation\""; |
160 |
echo " />\n"; |
161 |
echo "\t</div>\n"; |
162 |
|
163 |
// Fermeture du formulaire |
164 |
echo "\t</form>\n"; |
165 |
|
166 |
// Layout |
167 |
echo "</div>"; |
168 |
echo "</div>"; |
169 |
echo "</div>"; |
170 |
|
171 |
?> |