1 | <?php |
---|
2 | // +-------------------------------------------------+ |
---|
3 | // © 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net) |
---|
4 | // +-------------------------------------------------+ |
---|
5 | // $Id: bul_expl_update.inc.php,v 1.27.2.2 2014-09-12 12:54:39 ngantier Exp $ |
---|
6 | |
---|
7 | if (stristr($_SERVER['REQUEST_URI'], ".inc.php")) die("no access"); |
---|
8 | |
---|
9 | // mise a jour de l'entete de page |
---|
10 | if(!$expl_id) { |
---|
11 | // pas d'id, c'est une creation |
---|
12 | echo str_replace('!!page_title!!', $msg[4000].$msg[1003].$msg[4007], $serial_header); |
---|
13 | } else { |
---|
14 | echo str_replace('!!page_title!!', $msg[4000].$msg[1003].$msg[4008], $serial_header); |
---|
15 | } |
---|
16 | |
---|
17 | |
---|
18 | //verification des droits de modification notice |
---|
19 | $acces_m=1; |
---|
20 | if ($gestion_acces_active==1 && $gestion_acces_user_notice==1) { |
---|
21 | require_once("$class_path/acces.class.php"); |
---|
22 | $ac= new acces(); |
---|
23 | $dom_1= $ac->setDomain(1); |
---|
24 | $acces_j = $dom_1->getJoin($PMBuserid,8,'bulletin_notice'); |
---|
25 | $q = "select count(1) from bulletins $acces_j where bulletin_id=".$expl_bulletin; |
---|
26 | $r = mysql_query($q, $dbh); |
---|
27 | if(mysql_result($r,0,0)==0) { |
---|
28 | $acces_m=0; |
---|
29 | } |
---|
30 | } |
---|
31 | |
---|
32 | if ($acces_m==0) { |
---|
33 | |
---|
34 | if (!$expl_id) { |
---|
35 | error_message('', htmlentities($dom_1->getComment('mod_bull_error'), ENT_QUOTES, $charset), 1, ''); |
---|
36 | } else { |
---|
37 | error_message('', htmlentities($dom_1->getComment('mod_expl_error'), ENT_QUOTES, $charset), 1, ''); |
---|
38 | } |
---|
39 | |
---|
40 | } else { |
---|
41 | |
---|
42 | |
---|
43 | // le form d'exemplaire renvoit : |
---|
44 | // Je nettoie ce qui me parait devoir etre nettoye |
---|
45 | |
---|
46 | // $bul_id |
---|
47 | // $id_form |
---|
48 | // $org_cb |
---|
49 | // $expl_id |
---|
50 | // $expl_bulletin |
---|
51 | // $expl_typdoc |
---|
52 | $expl_cote = clean_string($expl_cote); |
---|
53 | // $expl_section |
---|
54 | // $expl_statut |
---|
55 | // $expl_location |
---|
56 | // $expl_codestat |
---|
57 | $expl_note = clean_string($expl_note); |
---|
58 | $expl_comment = clean_string($f_ex_comment); |
---|
59 | $expl_prix = clean_string($expl_prix); |
---|
60 | // $expl_owner |
---|
61 | |
---|
62 | //Verification des champs personalises |
---|
63 | $p_perso=new parametres_perso("expl"); |
---|
64 | $nberrors=$p_perso->check_submited_fields(); |
---|
65 | if ($nberrors) { |
---|
66 | error_message_history($msg["notice_champs_perso"],$p_perso->error_message,1); |
---|
67 | exit(); |
---|
68 | } |
---|
69 | // controle sur le nouveau code barre si applicable : |
---|
70 | if($org_cb != $f_ex_cb) { |
---|
71 | // si le nouveau code-barre est deja utilise, on reste sur l'ancien |
---|
72 | $requete = "SELECT expl_id FROM exemplaires WHERE expl_cb='$f_ex_cb'"; |
---|
73 | |
---|
74 | $myQuery = mysql_query($requete, $dbh); |
---|
75 | if(!($result=mysql_result($myQuery, 0, 0))) { |
---|
76 | $expl_cb = $f_ex_cb; |
---|
77 | } else { |
---|
78 | // Verif si expl_id est celui poste |
---|
79 | if($expl_id == $result[0]) { |
---|
80 | $expl_cb = $org_cb; |
---|
81 | } else { |
---|
82 | //Erreur: code barre deja existant |
---|
83 | error_message_history($msg[301],$msg[303],1); |
---|
84 | exit(); |
---|
85 | } |
---|
86 | } |
---|
87 | } else { |
---|
88 | $expl_cb = $f_ex_cb; |
---|
89 | } |
---|
90 | |
---|
91 | // on prepare la date de creation ou modification |
---|
92 | $expl_date = today(); |
---|
93 | |
---|
94 | // on recupere les valeurs |
---|
95 | $formlocid="f_ex_section".$expl_location ; |
---|
96 | $expl_section=$$formlocid ; |
---|
97 | |
---|
98 | if(!is_numeric($f_ex_nbparts) || !$f_ex_nbparts) $f_ex_nbparts=1; |
---|
99 | |
---|
100 | $transfert_origine=""; |
---|
101 | if($expl_id){ |
---|
102 | $rqt = "SELECT id_transfert FROM transferts, transferts_demande WHERE num_transfert=id_transfert and etat_transfert=0 AND num_expl='".$expl_id."' " ; |
---|
103 | $res = mysql_query ( $rqt ); |
---|
104 | if (!mysql_num_rows($res)){ |
---|
105 | // pas de transfert en cours, on met à jour transfert_location_origine |
---|
106 | $transfert_origine= ", transfert_location_origine='$expl_location', transfert_statut_origine='$expl_statut' "; |
---|
107 | } |
---|
108 | }else{ |
---|
109 | // en création |
---|
110 | $transfert_origine= ", transfert_location_origine='$expl_location', transfert_statut_origine='$expl_statut' "; |
---|
111 | } |
---|
112 | |
---|
113 | // preparation de la requete |
---|
114 | if($expl_id) { |
---|
115 | |
---|
116 | $audit=new audit(); |
---|
117 | $audit->get_old_infos("SELECT expl_statut, expl_location, transfert_location_origine, transfert_statut_origine, expl_owner FROM exemplaires WHERE expl_cb='$expl_cb' "); |
---|
118 | |
---|
119 | // update de l'exemplaire |
---|
120 | // on prepare la requete |
---|
121 | $values = "expl_cb='$expl_cb'"; |
---|
122 | $values .= ", expl_typdoc='$expl_typdoc'"; |
---|
123 | $values .= ", expl_cote='$expl_cote'"; |
---|
124 | $values .= ", expl_section='$expl_section'"; |
---|
125 | $values .= ", expl_statut='$expl_statut'"; |
---|
126 | $values .= ", expl_location='$expl_location' $transfert_origine "; |
---|
127 | $values .= ", expl_codestat='$expl_codestat'"; |
---|
128 | $values .= ", expl_note='$expl_note'"; |
---|
129 | $values .= ", expl_comment='$expl_comment'"; |
---|
130 | $values .= ", expl_prix='$expl_prix'"; |
---|
131 | $values .= ", expl_owner='$expl_owner'"; |
---|
132 | $values .= ", type_antivol='$type_antivol'"; |
---|
133 | $values .= ", expl_nbparts='$f_ex_nbparts'"; |
---|
134 | $requete = "UPDATE exemplaires SET $values WHERE expl_id=$expl_id AND expl_notice=0 LIMIT 1"; |
---|
135 | $myQuery = mysql_query($requete, $dbh); |
---|
136 | $audit->get_new_infos("SELECT expl_statut, expl_location, transfert_location_origine, transfert_statut_origine, expl_owner FROM exemplaires WHERE expl_cb='$expl_cb' "); |
---|
137 | $audit->save_info_modif(AUDIT_EXPL, $expl_id,"bul_expl_update.inc.php"); |
---|
138 | |
---|
139 | } else { |
---|
140 | // insertion d'un nouvel exemplaire |
---|
141 | $values = "expl_cb='$expl_cb'"; |
---|
142 | $values .= ", expl_notice='0'"; |
---|
143 | $values .= ", expl_bulletin='$expl_bulletin'"; |
---|
144 | $values .= ", expl_typdoc='$expl_typdoc'"; |
---|
145 | $values .= ", expl_cote='$expl_cote'"; |
---|
146 | $values .= ", expl_section='$expl_section'"; |
---|
147 | $values .= ", expl_statut='$expl_statut'"; |
---|
148 | $values .= ", expl_location='$expl_location' $transfert_origine "; |
---|
149 | $values .= ", expl_codestat='$expl_codestat'"; |
---|
150 | $values .= ", expl_note='$expl_note'"; |
---|
151 | $values .= ", expl_comment='$expl_comment'"; |
---|
152 | $values .= ", expl_prix='$expl_prix'"; |
---|
153 | $values .= ", expl_owner='$expl_owner'"; |
---|
154 | $values .= ", type_antivol='$type_antivol'"; |
---|
155 | $values .= ", expl_nbparts='$f_ex_nbparts'"; |
---|
156 | $requete = "INSERT INTO exemplaires set $values , create_date=sysdate() "; |
---|
157 | $myQuery = mysql_query($requete, $dbh); |
---|
158 | $expl_id=mysql_insert_id(); |
---|
159 | audit::insert_creation(AUDIT_EXPL, $expl_id) ; |
---|
160 | } |
---|
161 | |
---|
162 | //Insertion des champs personalises |
---|
163 | $p_perso->rec_fields_perso($expl_id); |
---|
164 | |
---|
165 | // Mise a jour de la table notices_mots_global_index pour toutes les notices en relation avec l'exemplaire |
---|
166 | $req_maj="SELECT bulletin_notice,num_notice, analysis_notice FROM bulletins LEFT JOIN analysis ON analysis_bulletin=bulletin_id WHERE bulletin_id='".$expl_bulletin."'"; |
---|
167 | $res_maj=mysql_query($req_maj); |
---|
168 | if($res_maj && mysql_num_rows($res_maj)){ |
---|
169 | $first=true;//Pour la premiere ligne de résultat on doit indexer aussi la notice de périodique et de bulletin au besoin |
---|
170 | while ( $ligne=mysql_fetch_object($res_maj) ) { |
---|
171 | if($first){ |
---|
172 | if($ligne->bulletin_notice){ |
---|
173 | notice::majNoticesMotsGlobalIndex($ligne->bulletin_notice,'expl'); |
---|
174 | } |
---|
175 | if($ligne->num_notice){ |
---|
176 | notice::majNoticesMotsGlobalIndex($ligne->num_notice,'expl'); |
---|
177 | } |
---|
178 | } |
---|
179 | if($ligne->analysis_notice){ |
---|
180 | notice::majNoticesMotsGlobalIndex($ligne->analysis_notice,'expl'); |
---|
181 | } |
---|
182 | $first=false; |
---|
183 | } |
---|
184 | } |
---|
185 | |
---|
186 | $id_form = md5(microtime()); |
---|
187 | print "<div class='row'><div class='msg-perio'>".$msg[maj_encours]."</div></div>"; |
---|
188 | $retour = "./catalog.php?categ=serials&sub=view&sub=bulletinage&action=view&bul_id=$expl_bulletin"; |
---|
189 | |
---|
190 | if ($pointage) { |
---|
191 | $templates="<script type='text/javascript'> |
---|
192 | |
---|
193 | function Fermer(obj,type_doc) { |
---|
194 | var obj_1=obj+\"_1\"; |
---|
195 | var obj_2=obj+\"_2\"; |
---|
196 | var obj_3=obj+\"_3\"; |
---|
197 | parent.document.getElementById(obj_1).disabled = true; |
---|
198 | parent.document.getElementById(obj_2).disabled = true; |
---|
199 | parent.document.getElementById(obj_3).disabled = true; |
---|
200 | parent.kill_frame_periodique(); |
---|
201 | } |
---|
202 | |
---|
203 | </script> |
---|
204 | <script type='text/javascript'>Fermer('$id_bull','$type_doc');</script> |
---|
205 | "; |
---|
206 | } else { |
---|
207 | print "<form class='form-$current_module' name=\"dummy\" method=\"post\" action=\"$retour\" style=\"display:none\"> |
---|
208 | <input type=\"hidden\" name=\"id_form\" value=\"$id_form\"> |
---|
209 | </form> |
---|
210 | <script type=\"text/javascript\">document.dummy.submit();</script>"; |
---|
211 | } |
---|
212 | } |
---|
213 | ?> |
---|