@@ -112,7 +112,9 @@ discard block |
||
112 | 112 | if ($this->id > 0) { |
113 | 113 | // Call trigger |
114 | 114 | $result=$this->call_trigger('LINK_CREATE',$user); |
115 | - if ($result < 0) $error++; |
|
115 | + if ($result < 0) { |
|
116 | + $error++; |
|
117 | + } |
|
116 | 118 | // End call triggers |
117 | 119 | } else { |
118 | 120 | $error++; |
@@ -123,23 +125,20 @@ discard block |
||
123 | 125 | dol_syslog(get_class($this)."::Create success id=" . $this->id); |
124 | 126 | $this->db->commit(); |
125 | 127 | return $this->id; |
126 | - } |
|
127 | - else |
|
128 | + } else |
|
128 | 129 | { |
129 | 130 | dol_syslog(get_class($this)."::Create echec update " . $this->error, LOG_ERR); |
130 | 131 | $this->db->rollback(); |
131 | 132 | return -3; |
132 | 133 | } |
133 | - } |
|
134 | - else |
|
134 | + } else |
|
135 | 135 | { |
136 | 136 | if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') |
137 | 137 | { |
138 | 138 | |
139 | 139 | $this->error=$langs->trans("ErrorCompanyNameAlreadyExists",$this->name); |
140 | 140 | $result=-1; |
141 | - } |
|
142 | - else |
|
141 | + } else |
|
143 | 142 | { |
144 | 143 | $this->error=$this->db->lasterror(); |
145 | 144 | $result=-2; |
@@ -175,7 +174,9 @@ discard block |
||
175 | 174 | |
176 | 175 | // Clean parameters |
177 | 176 | $this->url = clean_url($this->url,1); |
178 | - if (empty($this->label)) $this->label = basename($this->url); |
|
177 | + if (empty($this->label)) { |
|
178 | + $this->label = basename($this->url); |
|
179 | + } |
|
179 | 180 | $this->label = trim($this->label); |
180 | 181 | |
181 | 182 | |
@@ -198,7 +199,9 @@ discard block |
||
198 | 199 | { |
199 | 200 | // Call trigger |
200 | 201 | $result=$this->call_trigger('LINK_MODIFY',$user); |
201 | - if ($result < 0) $error++; |
|
202 | + if ($result < 0) { |
|
203 | + $error++; |
|
204 | + } |
|
202 | 205 | // End call triggers |
203 | 206 | } |
204 | 207 | |
@@ -212,16 +215,14 @@ discard block |
||
212 | 215 | $this->db->rollback(); |
213 | 216 | return -1; |
214 | 217 | } |
215 | - } |
|
216 | - else |
|
218 | + } else |
|
217 | 219 | { |
218 | 220 | if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') |
219 | 221 | { |
220 | 222 | // Doublon |
221 | 223 | $this->error = $langs->trans("ErrorDuplicateField"); |
222 | 224 | $result = -1; |
223 | - } |
|
224 | - else |
|
225 | + } else |
|
225 | 226 | { |
226 | 227 | $this->error = $langs->trans("Error sql = " . $sql); |
227 | 228 | $result = -2; |
@@ -247,7 +248,9 @@ discard block |
||
247 | 248 | |
248 | 249 | $sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM " . MAIN_DB_PREFIX . "links"; |
249 | 250 | $sql .= " WHERE objecttype = '" . $objecttype . "' AND objectid = " . $objectid; |
250 | - if ($conf->entity != 0) $sql .= " AND entity = " . $conf->entity; |
|
251 | + if ($conf->entity != 0) { |
|
252 | + $sql .= " AND entity = " . $conf->entity; |
|
253 | + } |
|
251 | 254 | if ($sortfield) { |
252 | 255 | if (empty($sortorder)) { |
253 | 256 | $sortorder = "ASC"; |
@@ -298,13 +301,17 @@ discard block |
||
298 | 301 | |
299 | 302 | $sql = "SELECT COUNT(rowid) as nb FROM " . MAIN_DB_PREFIX . "links"; |
300 | 303 | $sql .= " WHERE objecttype = '" . $objecttype . "' AND objectid = " . $objectid; |
301 | - if ($conf->entity != 0) $sql .= " AND entity = " . $conf->entity; |
|
304 | + if ($conf->entity != 0) { |
|
305 | + $sql .= " AND entity = " . $conf->entity; |
|
306 | + } |
|
302 | 307 | |
303 | 308 | $resql = $db->query($sql); |
304 | 309 | if ($resql) |
305 | 310 | { |
306 | 311 | $obj = $db->fetch_object($resql); |
307 | - if ($obj) return $obj->nb; |
|
312 | + if ($obj) { |
|
313 | + return $obj->nb; |
|
314 | + } |
|
308 | 315 | } |
309 | 316 | return -1; |
310 | 317 | } |
@@ -325,7 +332,9 @@ discard block |
||
325 | 332 | |
326 | 333 | $sql = "SELECT rowid, entity, datea, url, label, objecttype, objectid FROM " . MAIN_DB_PREFIX . "links"; |
327 | 334 | $sql .= " WHERE rowid = " . $rowid; |
328 | - if($conf->entity != 0) $sql .= " AND entity = " . $conf->entity; |
|
335 | + if($conf->entity != 0) { |
|
336 | + $sql .= " AND entity = " . $conf->entity; |
|
337 | + } |
|
329 | 338 | |
330 | 339 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
331 | 340 | $resql = $this->db->query($sql); |
@@ -341,8 +350,7 @@ discard block |
||
341 | 350 | $this->objecttype = $obj->objecttype; |
342 | 351 | $this->objectid = $obj->objectid; |
343 | 352 | return 1; |
344 | - } |
|
345 | - else |
|
353 | + } else |
|
346 | 354 | { |
347 | 355 | return 0; |
348 | 356 | } |
@@ -366,7 +374,9 @@ discard block |
||
366 | 374 | |
367 | 375 | // Call trigger |
368 | 376 | $result=$this->call_trigger('LINK_DELETE',$user); |
369 | - if ($result < 0) return -1; |
|
377 | + if ($result < 0) { |
|
378 | + return -1; |
|
379 | + } |
|
370 | 380 | // End call triggers |
371 | 381 | |
372 | 382 | $this->db->begin(); |
@@ -63,7 +63,9 @@ discard block |
||
63 | 63 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
64 | 64 | |
65 | 65 | $filesarray=array(); |
66 | - if (empty($choice)) $choice='tempfilesold'; |
|
66 | + if (empty($choice)) { |
|
67 | + $choice='tempfilesold'; |
|
68 | + } |
|
67 | 69 | |
68 | 70 | if ($choice=='tempfiles' || $choice=='tempfilesold') |
69 | 71 | { |
@@ -76,7 +78,10 @@ discard block |
||
76 | 78 | $now = dol_now(); |
77 | 79 | foreach($filesarray as $key => $val) |
78 | 80 | { |
79 | - if ($val['date'] > ($now - (24 * 3600))) unset($filesarray[$key]); // Discard files not older than 24h |
|
81 | + if ($val['date'] > ($now - (24 * 3600))) { |
|
82 | + unset($filesarray[$key]); |
|
83 | + } |
|
84 | + // Discard files not older than 24h |
|
80 | 85 | } |
81 | 86 | } |
82 | 87 | } |
@@ -110,7 +115,9 @@ discard block |
||
110 | 115 | { |
111 | 116 | if ($tmpcursor['fullname'] == $filelog) { $alreadyincluded=true; } |
112 | 117 | } |
113 | - if (! $alreadyincluded) $filesarray[]=array('fullname'=>$filelog,'type'=>'file'); |
|
118 | + if (! $alreadyincluded) { |
|
119 | + $filesarray[]=array('fullname'=>$filelog,'type'=>'file'); |
|
120 | + } |
|
114 | 121 | } |
115 | 122 | } |
116 | 123 | |
@@ -129,8 +136,7 @@ discard block |
||
129 | 136 | $result=dol_delete_dir_recursive($filesarray[$key]['fullname'], $startcount, 1, 0, $tmpcountdeleted); |
130 | 137 | $count+=$result; |
131 | 138 | $countdeleted+=$tmpcountdeleted; |
132 | - } |
|
133 | - elseif ($filesarray[$key]['type'] == 'file') |
|
139 | + } elseif ($filesarray[$key]['type'] == 'file') |
|
134 | 140 | { |
135 | 141 | // If (file that is not logfile) or (if mode is logfile) |
136 | 142 | if ($filesarray[$key]['fullname'] != $filelog || $choice=='logfile') |
@@ -140,8 +146,7 @@ discard block |
||
140 | 146 | { |
141 | 147 | $count++; |
142 | 148 | $countdeleted++; |
143 | - } |
|
144 | - else |
|
149 | + } else |
|
145 | 150 | { |
146 | 151 | $counterror++; |
147 | 152 | } |
@@ -161,9 +166,12 @@ discard block |
||
161 | 166 | if ($count > 0) |
162 | 167 | { |
163 | 168 | $this->output=$langs->trans("PurgeNDirectoriesDeleted", $countdeleted); |
164 | - if ($count > $countdeleted) $this->output.='<br>'.$langs->trans("PurgeNDirectoriesFailed", ($count - $countdeleted)); |
|
169 | + if ($count > $countdeleted) { |
|
170 | + $this->output.='<br>'.$langs->trans("PurgeNDirectoriesFailed", ($count - $countdeleted)); |
|
171 | + } |
|
172 | + } else { |
|
173 | + $this->output=$langs->trans("PurgeNothingToDelete").($choice == 'tempfilesold' ? ' (older than 24h)':''); |
|
165 | 174 | } |
166 | - else $this->output=$langs->trans("PurgeNothingToDelete").($choice == 'tempfilesold' ? ' (older than 24h)':''); |
|
167 | 175 | |
168 | 176 | //return $count; |
169 | 177 | return 0; // This function can be called by cron so must return 0 if OK |
@@ -201,7 +209,9 @@ discard block |
||
201 | 209 | } |
202 | 210 | |
203 | 211 | // Check type parameter |
204 | - if ($type == 'auto') $type = $db->type; |
|
212 | + if ($type == 'auto') { |
|
213 | + $type = $db->type; |
|
214 | + } |
|
205 | 215 | if (! in_array($type, array('postgresql', 'pgsql', 'mysql', 'mysqli', 'mysqlnobin'))) |
206 | 216 | { |
207 | 217 | $langs->load("errors"); |
@@ -233,44 +243,75 @@ discard block |
||
233 | 243 | $outputfile = $outputdir.'/'.$file; |
234 | 244 | // for compression format, we add extension |
235 | 245 | $compression=$compression ? $compression : 'none'; |
236 | - if ($compression == 'gz') $outputfile.='.gz'; |
|
237 | - if ($compression == 'bz') $outputfile.='.bz2'; |
|
246 | + if ($compression == 'gz') { |
|
247 | + $outputfile.='.gz'; |
|
248 | + } |
|
249 | + if ($compression == 'bz') { |
|
250 | + $outputfile.='.bz2'; |
|
251 | + } |
|
238 | 252 | $outputerror = $outputfile.'.err'; |
239 | 253 | dol_mkdir($conf->admin->dir_output.'/backup'); |
240 | 254 | |
241 | 255 | // Parameteres execution |
242 | 256 | $command=$cmddump; |
243 | - if (preg_match("/\s/",$command)) $command=escapeshellarg($command); // Use quotes on command |
|
257 | + if (preg_match("/\s/",$command)) { |
|
258 | + $command=escapeshellarg($command); |
|
259 | + } |
|
260 | + // Use quotes on command |
|
244 | 261 | |
245 | 262 | //$param=escapeshellarg($dolibarr_main_db_name)." -h ".escapeshellarg($dolibarr_main_db_host)." -u ".escapeshellarg($dolibarr_main_db_user)." -p".escapeshellarg($dolibarr_main_db_pass); |
246 | 263 | $param=$dolibarr_main_db_name." -h ".$dolibarr_main_db_host; |
247 | 264 | $param.=" -u ".$dolibarr_main_db_user; |
248 | - if (! empty($dolibarr_main_db_port)) $param.=" -P ".$dolibarr_main_db_port; |
|
249 | - if (! GETPOST("use_transaction")) $param.=" -l --single-transaction"; |
|
250 | - if (GETPOST("disable_fk") || $usedefault) $param.=" -K"; |
|
251 | - if (GETPOST("sql_compat") && GETPOST("sql_compat") != 'NONE') $param.=" --compatible=".escapeshellarg(GETPOST("sql_compat","alpha")); |
|
252 | - if (GETPOST("drop_database")) $param.=" --add-drop-database"; |
|
265 | + if (! empty($dolibarr_main_db_port)) { |
|
266 | + $param.=" -P ".$dolibarr_main_db_port; |
|
267 | + } |
|
268 | + if (! GETPOST("use_transaction")) { |
|
269 | + $param.=" -l --single-transaction"; |
|
270 | + } |
|
271 | + if (GETPOST("disable_fk") || $usedefault) { |
|
272 | + $param.=" -K"; |
|
273 | + } |
|
274 | + if (GETPOST("sql_compat") && GETPOST("sql_compat") != 'NONE') { |
|
275 | + $param.=" --compatible=".escapeshellarg(GETPOST("sql_compat","alpha")); |
|
276 | + } |
|
277 | + if (GETPOST("drop_database")) { |
|
278 | + $param.=" --add-drop-database"; |
|
279 | + } |
|
253 | 280 | if (GETPOST("sql_structure") || $usedefault) |
254 | 281 | { |
255 | - if (GETPOST("drop") || $usedefault) $param.=" --add-drop-table=TRUE"; |
|
256 | - else $param.=" --add-drop-table=FALSE"; |
|
257 | - } |
|
258 | - else |
|
282 | + if (GETPOST("drop") || $usedefault) { |
|
283 | + $param.=" --add-drop-table=TRUE"; |
|
284 | + } else { |
|
285 | + $param.=" --add-drop-table=FALSE"; |
|
286 | + } |
|
287 | + } else |
|
259 | 288 | { |
260 | 289 | $param.=" -t"; |
261 | 290 | } |
262 | - if (GETPOST("disable-add-locks")) $param.=" --add-locks=FALSE"; |
|
291 | + if (GETPOST("disable-add-locks")) { |
|
292 | + $param.=" --add-locks=FALSE"; |
|
293 | + } |
|
263 | 294 | if (GETPOST("sql_data") || $usedefault) |
264 | 295 | { |
265 | 296 | $param.=" --tables"; |
266 | - if (GETPOST("showcolumns") || $usedefault) $param.=" -c"; |
|
267 | - if (GETPOST("extended_ins") || $usedefault) $param.=" -e"; |
|
268 | - else $param.=" --skip-extended-insert"; |
|
269 | - if (GETPOST("delayed")) $param.=" --delayed-insert"; |
|
270 | - if (GETPOST("sql_ignore")) $param.=" --insert-ignore"; |
|
271 | - if (GETPOST("hexforbinary") || $usedefault) $param.=" --hex-blob"; |
|
272 | - } |
|
273 | - else |
|
297 | + if (GETPOST("showcolumns") || $usedefault) { |
|
298 | + $param.=" -c"; |
|
299 | + } |
|
300 | + if (GETPOST("extended_ins") || $usedefault) { |
|
301 | + $param.=" -e"; |
|
302 | + } else { |
|
303 | + $param.=" --skip-extended-insert"; |
|
304 | + } |
|
305 | + if (GETPOST("delayed")) { |
|
306 | + $param.=" --delayed-insert"; |
|
307 | + } |
|
308 | + if (GETPOST("sql_ignore")) { |
|
309 | + $param.=" --insert-ignore"; |
|
310 | + } |
|
311 | + if (GETPOST("hexforbinary") || $usedefault) { |
|
312 | + $param.=" --hex-blob"; |
|
313 | + } |
|
314 | + } else |
|
274 | 315 | { |
275 | 316 | $param.=" -d"; // No row information (no data) |
276 | 317 | } |
@@ -289,14 +330,24 @@ discard block |
||
289 | 330 | // Start call method to execute dump |
290 | 331 | $fullcommandcrypted=$command." ".$paramcrypted." 2>&1"; |
291 | 332 | $fullcommandclear=$command." ".$paramclear." 2>&1"; |
292 | - if ($compression == 'none') $handle = fopen($outputfile, 'w'); |
|
293 | - if ($compression == 'gz') $handle = gzopen($outputfile, 'w'); |
|
294 | - if ($compression == 'bz') $handle = bzopen($outputfile, 'w'); |
|
333 | + if ($compression == 'none') { |
|
334 | + $handle = fopen($outputfile, 'w'); |
|
335 | + } |
|
336 | + if ($compression == 'gz') { |
|
337 | + $handle = gzopen($outputfile, 'w'); |
|
338 | + } |
|
339 | + if ($compression == 'bz') { |
|
340 | + $handle = bzopen($outputfile, 'w'); |
|
341 | + } |
|
295 | 342 | |
296 | 343 | if ($handle) |
297 | 344 | { |
298 | - if (! empty($conf->global->MAIN_EXEC_USE_POPEN)) $execmethod=$conf->global->MAIN_EXEC_USE_POPEN; |
|
299 | - if (empty($execmethod)) $execmethod=1; |
|
345 | + if (! empty($conf->global->MAIN_EXEC_USE_POPEN)) { |
|
346 | + $execmethod=$conf->global->MAIN_EXEC_USE_POPEN; |
|
347 | + } |
|
348 | + if (empty($execmethod)) { |
|
349 | + $execmethod=1; |
|
350 | + } |
|
300 | 351 | |
301 | 352 | $ok=0; |
302 | 353 | dol_syslog("Utils::dumpDatabase execmethod=".$execmethod." command:".$fullcommandcrypted, LOG_DEBUG); |
@@ -313,47 +364,66 @@ discard block |
||
313 | 364 | dol_syslog("Datadump retval after exec=".$retval, LOG_ERR); |
314 | 365 | $error = 'Error '.$retval; |
315 | 366 | $ok=0; |
316 | - } |
|
317 | - else |
|
367 | + } else |
|
318 | 368 | { |
319 | 369 | $i=0; |
320 | - if (!empty($readt)) |
|
321 | - foreach($readt as $key=>$read) |
|
370 | + if (!empty($readt)) { |
|
371 | + foreach($readt as $key=>$read) |
|
322 | 372 | { |
323 | - $i++; // output line number |
|
324 | - if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) continue; |
|
373 | + $i++; |
|
374 | + } |
|
375 | + // output line number |
|
376 | + if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) { |
|
377 | + continue; |
|
378 | + } |
|
325 | 379 | fwrite($handle, $read.($execmethod == 2 ? '' : "\n")); |
326 | - if (preg_match('/'.preg_quote('-- Dump completed').'/i',$read)) $ok=1; |
|
327 | - elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i',$read)) $ok=1; |
|
380 | + if (preg_match('/'.preg_quote('-- Dump completed').'/i',$read)) { |
|
381 | + $ok=1; |
|
382 | + } elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i',$read)) { |
|
383 | + $ok=1; |
|
384 | + } |
|
328 | 385 | } |
329 | 386 | } |
330 | 387 | } |
331 | - if ($execmethod == 2) // With this method, there is no way to get the return code, only output |
|
388 | + if ($execmethod == 2) { |
|
389 | + // With this method, there is no way to get the return code, only output |
|
332 | 390 | { |
333 | 391 | $handlein = popen($fullcommandclear, 'r'); |
392 | + } |
|
334 | 393 | $i=0; |
335 | 394 | while (!feof($handlein)) |
336 | 395 | { |
337 | 396 | $i++; // output line number |
338 | 397 | $read = fgets($handlein); |
339 | 398 | // Exclude warning line we don't want |
340 | - if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) continue; |
|
399 | + if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) { |
|
400 | + continue; |
|
401 | + } |
|
341 | 402 | fwrite($handle,$read); |
342 | - if (preg_match('/'.preg_quote('-- Dump completed').'/i',$read)) $ok=1; |
|
343 | - elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i',$read)) $ok=1; |
|
403 | + if (preg_match('/'.preg_quote('-- Dump completed').'/i',$read)) { |
|
404 | + $ok=1; |
|
405 | + } elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i',$read)) { |
|
406 | + $ok=1; |
|
407 | + } |
|
344 | 408 | } |
345 | 409 | pclose($handlein); |
346 | 410 | } |
347 | 411 | |
348 | 412 | |
349 | - if ($compression == 'none') fclose($handle); |
|
350 | - if ($compression == 'gz') gzclose($handle); |
|
351 | - if ($compression == 'bz') bzclose($handle); |
|
413 | + if ($compression == 'none') { |
|
414 | + fclose($handle); |
|
415 | + } |
|
416 | + if ($compression == 'gz') { |
|
417 | + gzclose($handle); |
|
418 | + } |
|
419 | + if ($compression == 'bz') { |
|
420 | + bzclose($handle); |
|
421 | + } |
|
352 | 422 | |
353 | - if (! empty($conf->global->MAIN_UMASK)) |
|
354 | - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
355 | - } |
|
356 | - else |
|
423 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
424 | + @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
425 | + } |
|
426 | + } else |
|
357 | 427 | { |
358 | 428 | $langs->load("errors"); |
359 | 429 | dol_syslog("Failed to open file ".$outputfile,LOG_ERR); |
@@ -361,18 +431,33 @@ discard block |
||
361 | 431 | } |
362 | 432 | |
363 | 433 | // Get errorstring |
364 | - if ($compression == 'none') $handle = fopen($outputfile, 'r'); |
|
365 | - if ($compression == 'gz') $handle = gzopen($outputfile, 'r'); |
|
366 | - if ($compression == 'bz') $handle = bzopen($outputfile, 'r'); |
|
434 | + if ($compression == 'none') { |
|
435 | + $handle = fopen($outputfile, 'r'); |
|
436 | + } |
|
437 | + if ($compression == 'gz') { |
|
438 | + $handle = gzopen($outputfile, 'r'); |
|
439 | + } |
|
440 | + if ($compression == 'bz') { |
|
441 | + $handle = bzopen($outputfile, 'r'); |
|
442 | + } |
|
367 | 443 | if ($handle) |
368 | 444 | { |
369 | 445 | // Get 2048 first chars of error message. |
370 | 446 | $errormsg = fgets($handle,2048); |
371 | 447 | // Close file |
372 | - if ($compression == 'none') fclose($handle); |
|
373 | - if ($compression == 'gz') gzclose($handle); |
|
374 | - if ($compression == 'bz') bzclose($handle); |
|
375 | - if ($ok && preg_match('/^-- MySql/i',$errormsg)) $errormsg=''; // Pas erreur |
|
448 | + if ($compression == 'none') { |
|
449 | + fclose($handle); |
|
450 | + } |
|
451 | + if ($compression == 'gz') { |
|
452 | + gzclose($handle); |
|
453 | + } |
|
454 | + if ($compression == 'bz') { |
|
455 | + bzclose($handle); |
|
456 | + } |
|
457 | + if ($ok && preg_match('/^-- MySql/i',$errormsg)) { |
|
458 | + $errormsg=''; |
|
459 | + } |
|
460 | + // Pas erreur |
|
376 | 461 | else |
377 | 462 | { |
378 | 463 | // Renommer fichier sortie en fichier erreur |
@@ -402,8 +487,12 @@ discard block |
||
402 | 487 | $outputfiletemp = $outputfile.'-TMP.sql'; |
403 | 488 | // for compression format, we add extension |
404 | 489 | $compression=$compression ? $compression : 'none'; |
405 | - if ($compression == 'gz') $outputfile.='.gz'; |
|
406 | - if ($compression == 'bz') $outputfile.='.bz2'; |
|
490 | + if ($compression == 'gz') { |
|
491 | + $outputfile.='.gz'; |
|
492 | + } |
|
493 | + if ($compression == 'bz') { |
|
494 | + $outputfile.='.bz2'; |
|
495 | + } |
|
407 | 496 | $outputerror = $outputfile.'.err'; |
408 | 497 | dol_mkdir($conf->admin->dir_output.'/backup'); |
409 | 498 | |
@@ -412,8 +501,7 @@ discard block |
||
412 | 501 | $this->backupTables($outputfiletemp); |
413 | 502 | dol_compress_file($outputfiletemp, $outputfile, $compression); |
414 | 503 | unlink($outputfiletemp); |
415 | - } |
|
416 | - else |
|
504 | + } else |
|
417 | 505 | { |
418 | 506 | $this->backupTables($outputfile); |
419 | 507 | } |
@@ -430,36 +518,59 @@ discard block |
||
430 | 518 | $outputfile = $outputdir.'/'.$file; |
431 | 519 | // for compression format, we add extension |
432 | 520 | $compression=$compression ? $compression : 'none'; |
433 | - if ($compression == 'gz') $outputfile.='.gz'; |
|
434 | - if ($compression == 'bz') $outputfile.='.bz2'; |
|
521 | + if ($compression == 'gz') { |
|
522 | + $outputfile.='.gz'; |
|
523 | + } |
|
524 | + if ($compression == 'bz') { |
|
525 | + $outputfile.='.bz2'; |
|
526 | + } |
|
435 | 527 | $outputerror = $outputfile.'.err'; |
436 | 528 | dol_mkdir($conf->admin->dir_output.'/backup'); |
437 | 529 | |
438 | 530 | // Parameteres execution |
439 | 531 | $command=$cmddump; |
440 | - if (preg_match("/\s/",$command)) $command=escapeshellarg($command); // Use quotes on command |
|
532 | + if (preg_match("/\s/",$command)) { |
|
533 | + $command=escapeshellarg($command); |
|
534 | + } |
|
535 | + // Use quotes on command |
|
441 | 536 | |
442 | 537 | //$param=escapeshellarg($dolibarr_main_db_name)." -h ".escapeshellarg($dolibarr_main_db_host)." -u ".escapeshellarg($dolibarr_main_db_user)." -p".escapeshellarg($dolibarr_main_db_pass); |
443 | 538 | //$param="-F c"; |
444 | 539 | $param="-F p"; |
445 | 540 | $param.=" --no-tablespaces --inserts -h ".$dolibarr_main_db_host; |
446 | 541 | $param.=" -U ".$dolibarr_main_db_user; |
447 | - if (! empty($dolibarr_main_db_port)) $param.=" -p ".$dolibarr_main_db_port; |
|
448 | - if (GETPOST("sql_compat") && GETPOST("sql_compat") == 'ANSI') $param.=" --disable-dollar-quoting"; |
|
449 | - if (GETPOST("drop_database")) $param.=" -c -C"; |
|
542 | + if (! empty($dolibarr_main_db_port)) { |
|
543 | + $param.=" -p ".$dolibarr_main_db_port; |
|
544 | + } |
|
545 | + if (GETPOST("sql_compat") && GETPOST("sql_compat") == 'ANSI') { |
|
546 | + $param.=" --disable-dollar-quoting"; |
|
547 | + } |
|
548 | + if (GETPOST("drop_database")) { |
|
549 | + $param.=" -c -C"; |
|
550 | + } |
|
450 | 551 | if (GETPOST("sql_structure")) |
451 | 552 | { |
452 | - if (GETPOST("drop")) $param.=" --add-drop-table"; |
|
453 | - if (! GETPOST("sql_data")) $param.=" -s"; |
|
553 | + if (GETPOST("drop")) { |
|
554 | + $param.=" --add-drop-table"; |
|
555 | + } |
|
556 | + if (! GETPOST("sql_data")) { |
|
557 | + $param.=" -s"; |
|
558 | + } |
|
454 | 559 | } |
455 | 560 | if (GETPOST("sql_data")) |
456 | 561 | { |
457 | - if (! GETPOST("sql_structure")) $param.=" -a"; |
|
458 | - if (GETPOST("showcolumns")) $param.=" -c"; |
|
562 | + if (! GETPOST("sql_structure")) { |
|
563 | + $param.=" -a"; |
|
564 | + } |
|
565 | + if (GETPOST("showcolumns")) { |
|
566 | + $param.=" -c"; |
|
567 | + } |
|
459 | 568 | } |
460 | 569 | $param.=' -f "'.$outputfile.'"'; |
461 | 570 | //if ($compression == 'none') |
462 | - if ($compression == 'gz') $param.=' -Z 9'; |
|
571 | + if ($compression == 'gz') { |
|
572 | + $param.=' -Z 9'; |
|
573 | + } |
|
463 | 574 | //if ($compression == 'bz') |
464 | 575 | $paramcrypted=$param; |
465 | 576 | $paramclear=$param; |
@@ -483,7 +594,9 @@ discard block |
||
483 | 594 | foreach($tmpfiles as $key => $val) |
484 | 595 | { |
485 | 596 | $i++; |
486 | - if ($i <= $keeplastnfiles) continue; |
|
597 | + if ($i <= $keeplastnfiles) { |
|
598 | + continue; |
|
599 | + } |
|
487 | 600 | dol_delete_file($val['fullname'], 0, 0, 0, null, false, 0); |
488 | 601 | } |
489 | 602 | } |
@@ -512,8 +625,12 @@ discard block |
||
512 | 625 | $command=escapeshellcmd($command); |
513 | 626 | $command.=" 2>&1"; |
514 | 627 | |
515 | - if (! empty($conf->global->MAIN_EXEC_USE_POPEN)) $execmethod=$conf->global->MAIN_EXEC_USE_POPEN; |
|
516 | - if (empty($execmethod)) $execmethod=1; |
|
628 | + if (! empty($conf->global->MAIN_EXEC_USE_POPEN)) { |
|
629 | + $execmethod=$conf->global->MAIN_EXEC_USE_POPEN; |
|
630 | + } |
|
631 | + if (empty($execmethod)) { |
|
632 | + $execmethod=1; |
|
633 | + } |
|
517 | 634 | //$execmethod=1; |
518 | 635 | |
519 | 636 | dol_syslog("Utils::executeCLI execmethod=".$execmethod." system:".$command, LOG_DEBUG); |
@@ -530,9 +647,11 @@ discard block |
||
530 | 647 | $error = 'Error '.$retval; |
531 | 648 | } |
532 | 649 | } |
533 | - if ($execmethod == 2) // With this method, there is no way to get the return code, only output |
|
650 | + if ($execmethod == 2) { |
|
651 | + // With this method, there is no way to get the return code, only output |
|
534 | 652 | { |
535 | 653 | $ok=0; |
654 | + } |
|
536 | 655 | $handle = fopen($outputfile, 'w+b'); |
537 | 656 | if ($handle) |
538 | 657 | { |
@@ -547,7 +666,9 @@ discard block |
||
547 | 666 | pclose($handlein); |
548 | 667 | fclose($handle); |
549 | 668 | } |
550 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
669 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
670 | + @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
671 | + } |
|
551 | 672 | } |
552 | 673 | |
553 | 674 | // Update with result |
@@ -592,14 +713,12 @@ discard block |
||
592 | 713 | { |
593 | 714 | try { |
594 | 715 | $moduleobj = new $class($this->db); |
595 | - } |
|
596 | - catch(Exception $e) |
|
716 | + } catch(Exception $e) |
|
597 | 717 | { |
598 | 718 | $error++; |
599 | 719 | dol_print_error($e->getMessage()); |
600 | 720 | } |
601 | - } |
|
602 | - else |
|
721 | + } else |
|
603 | 722 | { |
604 | 723 | $error++; |
605 | 724 | $langs->load("errors"); |
@@ -618,8 +737,12 @@ discard block |
||
618 | 737 | $outputfiledoc = $dirofmodule.'/'.$FILENAMEDOC; |
619 | 738 | if ($dirofmodule) |
620 | 739 | { |
621 | - if (! dol_is_dir($dirofmodule)) dol_mkdir($dirofmodule); |
|
622 | - if (! dol_is_dir($dirofmoduletmp)) dol_mkdir($dirofmoduletmp); |
|
740 | + if (! dol_is_dir($dirofmodule)) { |
|
741 | + dol_mkdir($dirofmodule); |
|
742 | + } |
|
743 | + if (! dol_is_dir($dirofmoduletmp)) { |
|
744 | + dol_mkdir($dirofmoduletmp); |
|
745 | + } |
|
623 | 746 | if (! is_writable($dirofmoduletmp)) |
624 | 747 | { |
625 | 748 | $this->error = 'Dir '.$dirofmoduletmp.' does not exists or is not writable'; |
@@ -636,19 +759,26 @@ discard block |
||
636 | 759 | $i = 0; |
637 | 760 | foreach ($specs as $spec) |
638 | 761 | { |
639 | - if (preg_match('/notindoc/', $spec['relativename'])) continue; // Discard file |
|
640 | - if (preg_match('/disabled/', $spec['relativename'])) continue; // Discard file |
|
762 | + if (preg_match('/notindoc/', $spec['relativename'])) { |
|
763 | + continue; |
|
764 | + } |
|
765 | + // Discard file |
|
766 | + if (preg_match('/disabled/', $spec['relativename'])) { |
|
767 | + continue; |
|
768 | + } |
|
769 | + // Discard file |
|
641 | 770 | |
642 | 771 | $pathtofile = strtolower($module).'/doc/'.$spec['relativename']; |
643 | 772 | $format='asciidoc'; |
644 | - if (preg_match('/\.md$/i', $spec['name'])) $format='markdown'; |
|
773 | + if (preg_match('/\.md$/i', $spec['name'])) { |
|
774 | + $format='markdown'; |
|
775 | + } |
|
645 | 776 | |
646 | 777 | $filecursor = @file_get_contents($spec['fullname']); |
647 | 778 | if ($filecursor) |
648 | 779 | { |
649 | 780 | fwrite($fhandle, ($i ? "\n<<<\n\n" : "").$filecursor."\n"); |
650 | - } |
|
651 | - else |
|
781 | + } else |
|
652 | 782 | { |
653 | 783 | $this->error = 'Failed to concat content of file '.$spec['fullname']; |
654 | 784 | return -1; |
@@ -683,8 +813,7 @@ discard block |
||
683 | 813 | $this->error = $resarray['error'].' '.$resarray['output']; |
684 | 814 | } |
685 | 815 | $result = ($resarray['result'] == 0) ? 1 : 0; |
686 | - } |
|
687 | - else |
|
816 | + } else |
|
688 | 817 | { |
689 | 818 | $result = 0; |
690 | 819 | } |
@@ -692,15 +821,13 @@ discard block |
||
692 | 821 | if ($result > 0) |
693 | 822 | { |
694 | 823 | return 1; |
695 | - } |
|
696 | - else |
|
824 | + } else |
|
697 | 825 | { |
698 | 826 | $error++; |
699 | 827 | $langs->load("errors"); |
700 | 828 | $this->error = $langs->trans("ErrorFailToGenerateFile", $outputfiledoc); |
701 | 829 | } |
702 | - } |
|
703 | - else |
|
830 | + } else |
|
704 | 831 | { |
705 | 832 | $error++; |
706 | 833 | $langs->load("errors"); |
@@ -751,11 +878,13 @@ discard block |
||
751 | 878 | $logname = $file['name']; |
752 | 879 | $logpath = $file['path']; |
753 | 880 | |
754 | - if (dol_is_file($logpath.'/'.$logname) && dol_filesize($logpath.'/'.$logname) > 0) // If log file exists and is not empty |
|
881 | + if (dol_is_file($logpath.'/'.$logname) && dol_filesize($logpath.'/'.$logname) > 0) { |
|
882 | + // If log file exists and is not empty |
|
755 | 883 | { |
756 | 884 | // Handle already compressed files to rename them and add +1 |
757 | 885 | |
758 | 886 | $filter = '^'.preg_quote($logname, '/').'\.([0-9]+)\.gz$'; |
887 | + } |
|
759 | 888 | |
760 | 889 | $gzfilestmp = dol_dir_list($logpath, 'files', 0, $filter); |
761 | 890 | $gzfiles = array(); |
@@ -859,8 +988,7 @@ discard block |
||
859 | 988 | { |
860 | 989 | $tables[] = $row[0]; |
861 | 990 | } |
862 | - } |
|
863 | - else |
|
991 | + } else |
|
864 | 992 | { |
865 | 993 | $tables = is_array($tables) ? $tables : explode(',',$tables); |
866 | 994 | } |
@@ -896,16 +1024,24 @@ discard block |
||
896 | 1024 | |
897 | 1025 | "; |
898 | 1026 | |
899 | - if (GETPOST("nobin_disable_fk")) $sqlhead .= "SET FOREIGN_KEY_CHECKS=0;\n"; |
|
1027 | + if (GETPOST("nobin_disable_fk")) { |
|
1028 | + $sqlhead .= "SET FOREIGN_KEY_CHECKS=0;\n"; |
|
1029 | + } |
|
900 | 1030 | //$sqlhead .= "SET SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\";\n"; |
901 | - if (GETPOST("nobin_use_transaction")) $sqlhead .= "SET AUTOCOMMIT=0;\nSTART TRANSACTION;\n"; |
|
1031 | + if (GETPOST("nobin_use_transaction")) { |
|
1032 | + $sqlhead .= "SET AUTOCOMMIT=0;\nSTART TRANSACTION;\n"; |
|
1033 | + } |
|
902 | 1034 | |
903 | 1035 | fwrite($handle, $sqlhead); |
904 | 1036 | |
905 | 1037 | $ignore = ''; |
906 | - if (GETPOST("nobin_sql_ignore")) $ignore = 'IGNORE '; |
|
1038 | + if (GETPOST("nobin_sql_ignore")) { |
|
1039 | + $ignore = 'IGNORE '; |
|
1040 | + } |
|
907 | 1041 | $delayed = ''; |
908 | - if (GETPOST("nobin_delayed")) $delayed = 'DELAYED '; |
|
1042 | + if (GETPOST("nobin_delayed")) { |
|
1043 | + $delayed = 'DELAYED '; |
|
1044 | + } |
|
909 | 1045 | |
910 | 1046 | // Process each table and print their definition + their datas |
911 | 1047 | foreach($tables as $table) |
@@ -913,7 +1049,10 @@ discard block |
||
913 | 1049 | // Saving the table structure |
914 | 1050 | fwrite($handle, "\n--\n-- Table structure for table `".$table."`\n--\n"); |
915 | 1051 | |
916 | - if (GETPOST("nobin_drop")) fwrite($handle,"DROP TABLE IF EXISTS `".$table."`;\n"); // Dropping table if exists prior to re create it |
|
1052 | + if (GETPOST("nobin_drop")) { |
|
1053 | + fwrite($handle,"DROP TABLE IF EXISTS `".$table."`;\n"); |
|
1054 | + } |
|
1055 | + // Dropping table if exists prior to re create it |
|
917 | 1056 | fwrite($handle,"/*!40101 SET @saved_cs_client = @@character_set_client */;\n"); |
918 | 1057 | fwrite($handle,"/*!40101 SET character_set_client = utf8 */;\n"); |
919 | 1058 | $resqldrop=$db->query('SHOW CREATE TABLE '.$table); |
@@ -921,17 +1060,22 @@ discard block |
||
921 | 1060 | if (empty($row2[1])) |
922 | 1061 | { |
923 | 1062 | fwrite($handle, "\n-- WARNING: Show create table ".$table." return empy string when it should not.\n"); |
924 | - } |
|
925 | - else |
|
1063 | + } else |
|
926 | 1064 | { |
927 | 1065 | fwrite($handle,$row2[1].";\n"); |
928 | 1066 | //fwrite($handle,"/*!40101 SET character_set_client = @saved_cs_client */;\n\n"); |
929 | 1067 | |
930 | 1068 | // Dumping the data (locking the table and disabling the keys check while doing the process) |
931 | 1069 | fwrite($handle, "\n--\n-- Dumping data for table `".$table."`\n--\n"); |
932 | - if (!GETPOST("nobin_nolocks")) fwrite($handle, "LOCK TABLES `".$table."` WRITE;\n"); // Lock the table before inserting data (when the data will be imported back) |
|
933 | - if (GETPOST("nobin_disable_fk")) fwrite($handle, "ALTER TABLE `".$table."` DISABLE KEYS;\n"); |
|
934 | - else fwrite($handle, "/*!40000 ALTER TABLE `".$table."` DISABLE KEYS */;\n"); |
|
1070 | + if (!GETPOST("nobin_nolocks")) { |
|
1071 | + fwrite($handle, "LOCK TABLES `".$table."` WRITE;\n"); |
|
1072 | + } |
|
1073 | + // Lock the table before inserting data (when the data will be imported back) |
|
1074 | + if (GETPOST("nobin_disable_fk")) { |
|
1075 | + fwrite($handle, "ALTER TABLE `".$table."` DISABLE KEYS;\n"); |
|
1076 | + } else { |
|
1077 | + fwrite($handle, "/*!40000 ALTER TABLE `".$table."` DISABLE KEYS */;\n"); |
|
1078 | + } |
|
935 | 1079 | |
936 | 1080 | $sql='SELECT * FROM '.$table; |
937 | 1081 | $result = $db->query($sql); |
@@ -959,8 +1103,14 @@ discard block |
||
959 | 1103 | } |
960 | 1104 | fwrite($handle,implode(',', $row).");\n"); |
961 | 1105 | } |
962 | - if (GETPOST("nobin_disable_fk")) fwrite($handle, "ALTER TABLE `".$table."` ENABLE KEYS;\n"); // Enabling back the keys/index checking |
|
963 | - if (!GETPOST("nobin_nolocks")) fwrite($handle, "UNLOCK TABLES;\n"); // Unlocking the table |
|
1106 | + if (GETPOST("nobin_disable_fk")) { |
|
1107 | + fwrite($handle, "ALTER TABLE `".$table."` ENABLE KEYS;\n"); |
|
1108 | + } |
|
1109 | + // Enabling back the keys/index checking |
|
1110 | + if (!GETPOST("nobin_nolocks")) { |
|
1111 | + fwrite($handle, "UNLOCK TABLES;\n"); |
|
1112 | + } |
|
1113 | + // Unlocking the table |
|
964 | 1114 | fwrite($handle,"\n\n\n"); |
965 | 1115 | } |
966 | 1116 | } |
@@ -986,8 +1136,12 @@ discard block |
||
986 | 1136 | |
987 | 1137 | // Write the footer (restore the previous database settings) |
988 | 1138 | $sqlfooter="\n\n"; |
989 | - if (GETPOST("nobin_use_transaction")) $sqlfooter .= "COMMIT;\n"; |
|
990 | - if (GETPOST("nobin_disable_fk")) $sqlfooter .= "SET FOREIGN_KEY_CHECKS=1;\n"; |
|
1139 | + if (GETPOST("nobin_use_transaction")) { |
|
1140 | + $sqlfooter .= "COMMIT;\n"; |
|
1141 | + } |
|
1142 | + if (GETPOST("nobin_disable_fk")) { |
|
1143 | + $sqlfooter .= "SET FOREIGN_KEY_CHECKS=1;\n"; |
|
1144 | + } |
|
991 | 1145 | $sqlfooter.="\n\n-- Dump completed on ".date('Y-m-d G-i-s'); |
992 | 1146 | fwrite($handle, $sqlfooter); |
993 | 1147 |
@@ -66,7 +66,9 @@ discard block |
||
66 | 66 | global $db,$user,$conf,$langs; |
67 | 67 | |
68 | 68 | $hideunselectables = false; |
69 | - if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) $hideunselectables = true; |
|
69 | + if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) { |
|
70 | + $hideunselectables = true; |
|
71 | + } |
|
70 | 72 | |
71 | 73 | // Search all contacts |
72 | 74 | $sql = 'SELECT c.rowid, c.ref, c.fk_soc, c.statut'; |
@@ -76,15 +78,17 @@ discard block |
||
76 | 78 | if ($socid > 0) |
77 | 79 | { |
78 | 80 | // CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma. |
79 | - if (empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) |
|
80 | - $sql.= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)"; |
|
81 | - else if ($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') |
|
81 | + if (empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) { |
|
82 | + $sql.= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)"; |
|
83 | + } else if ($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') |
|
82 | 84 | { |
83 | 85 | $sql.= " AND (c.fk_soc IN (".$socid.", ".$conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") "; |
84 | 86 | $sql.= " OR c.fk_soc IS NULL)"; |
85 | 87 | } |
86 | 88 | } |
87 | - if ($socid == 0) $sql.= " AND (c.fk_soc = 0 OR c.fk_soc IS NULL)"; |
|
89 | + if ($socid == 0) { |
|
90 | + $sql.= " AND (c.fk_soc = 0 OR c.fk_soc IS NULL)"; |
|
91 | + } |
|
88 | 92 | $sql.= " ORDER BY c.ref "; |
89 | 93 | |
90 | 94 | dol_syslog(get_class($this)."::select_contract", LOG_DEBUG); |
@@ -92,7 +96,9 @@ discard block |
||
92 | 96 | if ($resql) |
93 | 97 | { |
94 | 98 | print '<select class="flat" name="'.$htmlname.'">'; |
95 | - if ($showempty) print '<option value="0"> </option>'; |
|
99 | + if ($showempty) { |
|
100 | + print '<option value="0"> </option>'; |
|
101 | + } |
|
96 | 102 | $num = $db->num_rows($resql); |
97 | 103 | $i = 0; |
98 | 104 | if ($num) |
@@ -104,8 +110,7 @@ discard block |
||
104 | 110 | if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && ! $user->rights->societe->lire) |
105 | 111 | { |
106 | 112 | // Do nothing |
107 | - } |
|
108 | - else |
|
113 | + } else |
|
109 | 114 | { |
110 | 115 | $labeltoshow=dol_trunc($obj->ref,18); |
111 | 116 | //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; |
@@ -113,8 +118,7 @@ discard block |
||
113 | 118 | if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0) |
114 | 119 | { |
115 | 120 | print '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
116 | - } |
|
117 | - else |
|
121 | + } else |
|
118 | 122 | { |
119 | 123 | $disabled=0; |
120 | 124 | if ( $obj->statut == 0) |
@@ -131,11 +135,12 @@ discard block |
||
131 | 135 | if ($hideunselectables && $disabled) |
132 | 136 | { |
133 | 137 | $resultat=''; |
134 | - } |
|
135 | - else |
|
138 | + } else |
|
136 | 139 | { |
137 | 140 | $resultat='<option value="'.$obj->rowid.'"'; |
138 | - if ($disabled) $resultat.=' disabled'; |
|
141 | + if ($disabled) { |
|
142 | + $resultat.=' disabled'; |
|
143 | + } |
|
139 | 144 | //if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')'; |
140 | 145 | //else $labeltoshow.=' ('.$langs->trans("Private").')'; |
141 | 146 | $resultat.='>'.$labeltoshow; |
@@ -158,8 +163,7 @@ discard block |
||
158 | 163 | } |
159 | 164 | |
160 | 165 | return $num; |
161 | - } |
|
162 | - else |
|
166 | + } else |
|
163 | 167 | { |
164 | 168 | dol_print_error($db); |
165 | 169 | return -1; |
@@ -88,8 +88,9 @@ discard block |
||
88 | 88 | { |
89 | 89 | require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; |
90 | 90 | $product = new ProductFournisseur($db); |
91 | - if ($product->fetch_product_fournisseur_price($line->fk_fournprice)) |
|
92 | - $line->pa_ht = $product->fourn_unitprice * (1 - $product->fourn_remise_percent / 100); |
|
91 | + if ($product->fetch_product_fournisseur_price($line->fk_fournprice)) { |
|
92 | + $line->pa_ht = $product->fourn_unitprice * (1 - $product->fourn_remise_percent / 100); |
|
93 | + } |
|
93 | 94 | } |
94 | 95 | // si prix d'achat non renseigné et devrait l'être, alors prix achat = prix vente |
95 | 96 | if ((!isset($line->pa_ht) || $line->pa_ht == 0) && $line->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) { |
@@ -114,8 +115,7 @@ discard block |
||
114 | 115 | //} |
115 | 116 | //else |
116 | 117 | $marginInfos['margin_on_products'] += $pv - $pa; |
117 | - } |
|
118 | - elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '2') { // remise globale considérée comme service |
|
118 | + } elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '2') { // remise globale considérée comme service |
|
119 | 119 | $marginInfos['pa_services'] += $pa; |
120 | 120 | $marginInfos['pv_services'] += $pv; |
121 | 121 | $marginInfos['pa_total'] += $pa; |
@@ -125,13 +125,11 @@ discard block |
||
125 | 125 | // $marginInfos['margin_on_services'] += -1 * (abs($pv) - $pa); |
126 | 126 | //else |
127 | 127 | $marginInfos['margin_on_services'] += $pv - $pa; |
128 | - } |
|
129 | - elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '3') { // remise globale prise en compte uniqt sur total |
|
128 | + } elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '3') { // remise globale prise en compte uniqt sur total |
|
130 | 129 | $marginInfos['pa_total'] += $pa; |
131 | 130 | $marginInfos['pv_total'] += $pv; |
132 | 131 | } |
133 | - } |
|
134 | - else { |
|
132 | + } else { |
|
135 | 133 | $type=$line->product_type?$line->product_type:$line->fk_product_type; |
136 | 134 | if ($type == 0) { // product |
137 | 135 | $marginInfos['pa_products'] += $pa; |
@@ -147,8 +145,7 @@ discard block |
||
147 | 145 | //{ |
148 | 146 | $marginInfos['margin_on_products'] += $pv - $pa; |
149 | 147 | //} |
150 | - } |
|
151 | - elseif ($type == 1) { // service |
|
148 | + } elseif ($type == 1) { // service |
|
152 | 149 | $marginInfos['pa_services'] += $pa; |
153 | 150 | $marginInfos['pv_services'] += $pv; |
154 | 151 | $marginInfos['pa_total'] += $pa; |
@@ -161,25 +158,31 @@ discard block |
||
161 | 158 | } |
162 | 159 | } |
163 | 160 | } |
164 | - if ($marginInfos['pa_products'] > 0) |
|
165 | - $marginInfos['margin_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pa_products']; |
|
166 | - if ($marginInfos['pv_products'] > 0) |
|
167 | - $marginInfos['mark_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pv_products']; |
|
161 | + if ($marginInfos['pa_products'] > 0) { |
|
162 | + $marginInfos['margin_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pa_products']; |
|
163 | + } |
|
164 | + if ($marginInfos['pv_products'] > 0) { |
|
165 | + $marginInfos['mark_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pv_products']; |
|
166 | + } |
|
168 | 167 | |
169 | - if ($marginInfos['pa_services'] > 0) |
|
170 | - $marginInfos['margin_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pa_services']; |
|
171 | - if ($marginInfos['pv_services'] > 0) |
|
172 | - $marginInfos['mark_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pv_services']; |
|
168 | + if ($marginInfos['pa_services'] > 0) { |
|
169 | + $marginInfos['margin_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pa_services']; |
|
170 | + } |
|
171 | + if ($marginInfos['pv_services'] > 0) { |
|
172 | + $marginInfos['mark_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pv_services']; |
|
173 | + } |
|
173 | 174 | |
174 | 175 | // if credit note, margin = -1 * (abs(selling_price) - buying_price) |
175 | 176 | //if ($marginInfos['pv_total'] < 0) |
176 | 177 | // $marginInfos['total_margin'] = -1 * (abs($marginInfos['pv_total']) - $marginInfos['pa_total']); |
177 | 178 | //else |
178 | 179 | $marginInfos['total_margin'] = $marginInfos['pv_total'] - $marginInfos['pa_total']; |
179 | - if ($marginInfos['pa_total'] > 0) |
|
180 | - $marginInfos['total_margin_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pa_total']; |
|
181 | - if ($marginInfos['pv_total'] > 0) |
|
182 | - $marginInfos['total_mark_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pv_total']; |
|
180 | + if ($marginInfos['pa_total'] > 0) { |
|
181 | + $marginInfos['total_margin_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pa_total']; |
|
182 | + } |
|
183 | + if ($marginInfos['pv_total'] > 0) { |
|
184 | + $marginInfos['total_mark_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pv_total']; |
|
185 | + } |
|
183 | 186 | |
184 | 187 | return $marginInfos; |
185 | 188 | } |
@@ -195,17 +198,23 @@ discard block |
||
195 | 198 | { |
196 | 199 | global $langs, $conf, $user; |
197 | 200 | |
198 | - if (! empty($user->societe_id)) return; |
|
201 | + if (! empty($user->societe_id)) { |
|
202 | + return; |
|
203 | + } |
|
199 | 204 | |
200 | - if (! $user->rights->margins->liretous) return; |
|
205 | + if (! $user->rights->margins->liretous) { |
|
206 | + return; |
|
207 | + } |
|
201 | 208 | |
202 | 209 | $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); |
203 | 210 | |
204 | 211 | $marginInfo = $this->getMarginInfosArray($object, $force_price); |
205 | 212 | |
206 | - if (! empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON)) // TODO Warning this feature rely on an external js file that may be removed. Using native js function document.cookie should be better |
|
213 | + if (! empty($conf->global->MARGIN_ADD_SHOWHIDE_BUTTON)) { |
|
214 | + // TODO Warning this feature rely on an external js file that may be removed. Using native js function document.cookie should be better |
|
207 | 215 | { |
208 | 216 | print $langs->trans('ShowMarginInfos').' : '; |
217 | + } |
|
209 | 218 | $hidemargininfos = $_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']; |
210 | 219 | print '<span id="showMarginInfos" class="linkobject '.(!empty($hidemargininfos)?'':'hideobject').'">'.img_picto($langs->trans("Disabled"),'switch_off').'</span>'; |
211 | 220 | print '<span id="hideMarginInfos" class="linkobject '.(!empty($hidemargininfos)?'hideobject':'').'">'.img_picto($langs->trans("Enabled"),'switch_on').'</span>'; |
@@ -214,7 +223,9 @@ discard block |
||
214 | 223 | $("span#showMarginInfos").click(function() { $.getScript( "'.dol_buildpath('/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js', 1).'", function( data, textStatus, jqxhr ) { $.cookie("DOLUSER_MARGININFO_HIDE_SHOW", 0); $(".margininfos").show(); $("span#showMarginInfos").addClass("hideobject"); $("span#hideMarginInfos").removeClass("hideobject");})}); |
215 | 224 | $("span#hideMarginInfos").click(function() { $.getScript( "'.dol_buildpath('/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js', 1).'", function( data, textStatus, jqxhr ) { $.cookie("DOLUSER_MARGININFO_HIDE_SHOW", 1); $(".margininfos").hide(); $("span#hideMarginInfos").addClass("hideobject"); $("span#showMarginInfos").removeClass("hideobject");})}); |
216 | 225 | });</script>'; |
217 | - if (!empty($hidemargininfos)) print '<script>$(document).ready(function() {$(".margininfos").hide();});</script>'; |
|
226 | + if (!empty($hidemargininfos)) { |
|
227 | + print '<script>$(document).ready(function() {$(".margininfos").hide();});</script>'; |
|
228 | + } |
|
218 | 229 | } |
219 | 230 | |
220 | 231 | print '<div class="div-table-responsive-no-min">'; |
@@ -224,15 +235,18 @@ discard block |
||
224 | 235 | print '<tr class="liste_titre">'; |
225 | 236 | print '<td class="liste_titre">'.$langs->trans('Margins').'</td>'; |
226 | 237 | print '<td class="liste_titre" align="right">'.$langs->trans('SellingPrice').'</td>'; |
227 | - if ($conf->global->MARGIN_TYPE == "1") |
|
228 | - print '<td class="liste_titre" align="right">'.$langs->trans('BuyingPrice').'</td>'; |
|
229 | - else |
|
230 | - print '<td class="liste_titre" align="right">'.$langs->trans('CostPrice').'</td>'; |
|
238 | + if ($conf->global->MARGIN_TYPE == "1") { |
|
239 | + print '<td class="liste_titre" align="right">'.$langs->trans('BuyingPrice').'</td>'; |
|
240 | + } else { |
|
241 | + print '<td class="liste_titre" align="right">'.$langs->trans('CostPrice').'</td>'; |
|
242 | + } |
|
231 | 243 | print '<td class="liste_titre" align="right">'.$langs->trans('Margin').'</td>'; |
232 | - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) |
|
233 | - print '<td class="liste_titre" align="right">'.$langs->trans('MarginRate').'</td>'; |
|
234 | - if (! empty($conf->global->DISPLAY_MARK_RATES)) |
|
235 | - print '<td class="liste_titre" align="right">'.$langs->trans('MarkRate').'</td>'; |
|
244 | + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { |
|
245 | + print '<td class="liste_titre" align="right">'.$langs->trans('MarginRate').'</td>'; |
|
246 | + } |
|
247 | + if (! empty($conf->global->DISPLAY_MARK_RATES)) { |
|
248 | + print '<td class="liste_titre" align="right">'.$langs->trans('MarkRate').'</td>'; |
|
249 | + } |
|
236 | 250 | print '</tr>'; |
237 | 251 | |
238 | 252 | if (! empty($conf->product->enabled)) |
@@ -243,10 +257,12 @@ discard block |
||
243 | 257 | print '<td align="right">'.price($marginInfo['pv_products'], null, null, null, null, $rounding).'</td>'; |
244 | 258 | print '<td align="right">'.price($marginInfo['pa_products'], null, null, null, null, $rounding).'</td>'; |
245 | 259 | print '<td align="right">'.price($marginInfo['margin_on_products'], null, null, null, null, $rounding).'</td>'; |
246 | - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) |
|
247 | - print '<td align="right">'.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, $rounding).'%').'</td>'; |
|
248 | - if (! empty($conf->global->DISPLAY_MARK_RATES)) |
|
249 | - print '<td align="right">'.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, $rounding).'%').'</td>'; |
|
260 | + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { |
|
261 | + print '<td align="right">'.(($marginInfo['margin_rate_products'] == '')?'':price($marginInfo['margin_rate_products'], null, null, null, null, $rounding).'%').'</td>'; |
|
262 | + } |
|
263 | + if (! empty($conf->global->DISPLAY_MARK_RATES)) { |
|
264 | + print '<td align="right">'.(($marginInfo['mark_rate_products'] == '')?'':price($marginInfo['mark_rate_products'], null, null, null, null, $rounding).'%').'</td>'; |
|
265 | + } |
|
250 | 266 | print '</tr>'; |
251 | 267 | } |
252 | 268 | |
@@ -257,10 +273,12 @@ discard block |
||
257 | 273 | print '<td align="right">'.price($marginInfo['pv_services'], null, null, null, null, $rounding).'</td>'; |
258 | 274 | print '<td align="right">'.price($marginInfo['pa_services'], null, null, null, null, $rounding).'</td>'; |
259 | 275 | print '<td align="right">'.price($marginInfo['margin_on_services'], null, null, null, null, $rounding).'</td>'; |
260 | - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) |
|
261 | - print '<td align="right">'.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, $rounding).'%').'</td>'; |
|
262 | - if (! empty($conf->global->DISPLAY_MARK_RATES)) |
|
263 | - print '<td align="right">'.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, $rounding).'%').'</td>'; |
|
276 | + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { |
|
277 | + print '<td align="right">'.(($marginInfo['margin_rate_services'] == '')?'':price($marginInfo['margin_rate_services'], null, null, null, null, $rounding).'%').'</td>'; |
|
278 | + } |
|
279 | + if (! empty($conf->global->DISPLAY_MARK_RATES)) { |
|
280 | + print '<td align="right">'.(($marginInfo['mark_rate_services'] == '')?'':price($marginInfo['mark_rate_services'], null, null, null, null, $rounding).'%').'</td>'; |
|
281 | + } |
|
264 | 282 | print '</tr>'; |
265 | 283 | } |
266 | 284 | |
@@ -271,10 +289,12 @@ discard block |
||
271 | 289 | print '<td align="right">'.price($marginInfo['pv_total'], null, null, null, null, $rounding).'</td>'; |
272 | 290 | print '<td align="right">'.price($marginInfo['pa_total'], null, null, null, null, $rounding).'</td>'; |
273 | 291 | print '<td align="right">'.price($marginInfo['total_margin'], null, null, null, null, $rounding).'</td>'; |
274 | - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) |
|
275 | - print '<td align="right">'.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, $rounding).'%').'</td>'; |
|
276 | - if (! empty($conf->global->DISPLAY_MARK_RATES)) |
|
277 | - print '<td align="right">'.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, $rounding).'%').'</td>'; |
|
292 | + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { |
|
293 | + print '<td align="right">'.(($marginInfo['total_margin_rate'] == '')?'':price($marginInfo['total_margin_rate'], null, null, null, null, $rounding).'%').'</td>'; |
|
294 | + } |
|
295 | + if (! empty($conf->global->DISPLAY_MARK_RATES)) { |
|
296 | + print '<td align="right">'.(($marginInfo['total_mark_rate'] == '')?'':price($marginInfo['total_mark_rate'], null, null, null, null, $rounding).'%').'</td>'; |
|
297 | + } |
|
278 | 298 | print '</tr>'; |
279 | 299 | } |
280 | 300 | print '</table>'; |
@@ -78,8 +78,7 @@ discard block |
||
78 | 78 | 3=>array('id'=>3, 'code'=>'PR_NOTSIGNED'), |
79 | 79 | 4=>array('id'=>4, 'code'=>'PR_CLOSED') |
80 | 80 | ); |
81 | - } |
|
82 | - else |
|
81 | + } else |
|
83 | 82 | { |
84 | 83 | $prefix="PropalStatus"; |
85 | 84 | |
@@ -100,15 +99,16 @@ discard block |
||
100 | 99 | $i++; |
101 | 100 | } |
102 | 101 | } |
103 | - } |
|
104 | - else |
|
102 | + } else |
|
105 | 103 | { |
106 | 104 | dol_print_error($this->db); |
107 | 105 | } |
108 | 106 | } |
109 | 107 | |
110 | 108 | print '<select class="flat" name="'.$htmlname.'">'; |
111 | - if ($showempty) print '<option value="-1"> </option>'; |
|
109 | + if ($showempty) { |
|
110 | + print '<option value="-1"> </option>'; |
|
111 | + } |
|
112 | 112 | |
113 | 113 | foreach($listofstatus as $key => $obj) |
114 | 114 | { |
@@ -123,8 +123,7 @@ discard block |
||
123 | 123 | if ($selected != '' && $selected == $obj['id']) |
124 | 124 | { |
125 | 125 | print '<option value="'.$obj['id'].'" selected>'; |
126 | - } |
|
127 | - else |
|
126 | + } else |
|
128 | 127 | { |
129 | 128 | print '<option value="'.$obj['id'].'">'; |
130 | 129 | } |
@@ -132,11 +131,12 @@ discard block |
||
132 | 131 | if ($langs->trans($prefix.$key.($short?'Short':'')) != $prefix.$key.($short?'Short':'')) |
133 | 132 | { |
134 | 133 | print $langs->trans($prefix.$key.($short?'Short':'')); |
135 | - } |
|
136 | - else |
|
134 | + } else |
|
137 | 135 | { |
138 | 136 | $conv_to_new_code=array('PR_DRAFT'=>'Draft','PR_OPEN'=>'Validated','PR_CLOSED'=>'Closed','PR_SIGNED'=>'Signed','PR_NOTSIGNED'=>'NotSigned','PR_FAC'=>'Billed'); |
139 | - if (! empty($conv_to_new_code[$obj['code']])) $key=$conv_to_new_code[$obj['code']]; |
|
137 | + if (! empty($conv_to_new_code[$obj['code']])) { |
|
138 | + $key=$conv_to_new_code[$obj['code']]; |
|
139 | + } |
|
140 | 140 | |
141 | 141 | print ($langs->trans($prefix.$key.($short?'Short':''))!=$prefix.$key.($short?'Short':''))?$langs->trans($prefix.$key.($short?'Short':'')):($obj['label']?$obj['label']:$obj['code']); |
142 | 142 | } |
@@ -131,9 +131,15 @@ discard block |
||
131 | 131 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON sr.fk_facture_source = f.rowid"; |
132 | 132 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fsup ON sr.fk_invoice_supplier_source = fsup.rowid"; |
133 | 133 | $sql.= " WHERE sr.entity = " . $conf->entity; |
134 | - if ($rowid) $sql.= " AND sr.rowid=".$rowid; |
|
135 | - if ($fk_facture_source) $sql.= " AND sr.fk_facture_source=".$fk_facture_source; |
|
136 | - if ($fk_invoice_supplier_source) $sql.= " AND sr.fk_invoice_supplier_source=".$fk_invoice_supplier_source; |
|
134 | + if ($rowid) { |
|
135 | + $sql.= " AND sr.rowid=".$rowid; |
|
136 | + } |
|
137 | + if ($fk_facture_source) { |
|
138 | + $sql.= " AND sr.fk_facture_source=".$fk_facture_source; |
|
139 | + } |
|
140 | + if ($fk_invoice_supplier_source) { |
|
141 | + $sql.= " AND sr.fk_invoice_supplier_source=".$fk_invoice_supplier_source; |
|
142 | + } |
|
137 | 143 | |
138 | 144 | dol_syslog(get_class($this)."::fetch", LOG_DEBUG); |
139 | 145 | $resql = $this->db->query($sql); |
@@ -170,14 +176,12 @@ discard block |
||
170 | 176 | |
171 | 177 | $this->db->free($resql); |
172 | 178 | return 1; |
173 | - } |
|
174 | - else |
|
179 | + } else |
|
175 | 180 | { |
176 | 181 | $this->db->free($resql); |
177 | 182 | return 0; |
178 | 183 | } |
179 | - } |
|
180 | - else |
|
184 | + } else |
|
181 | 185 | { |
182 | 186 | $this->error=$this->db->error(); |
183 | 187 | return -1; |
@@ -206,9 +210,15 @@ discard block |
||
206 | 210 | $this->multicurrency_amount_tva=price2num($this->multicurrency_amount_tva); |
207 | 211 | $this->multicurrency_amount_ttc=price2num($this->multicurrency_amount_ttc); |
208 | 212 | |
209 | - if (empty($this->multicurrency_amount_ht)) $this->multicurrency_amount_ht=0; |
|
210 | - if (empty($this->multicurrency_amount_tva)) $this->multicurrency_amount_tva=0; |
|
211 | - if (empty($this->multicurrency_amount_ttc)) $this->multicurrency_amount_ttc=0; |
|
213 | + if (empty($this->multicurrency_amount_ht)) { |
|
214 | + $this->multicurrency_amount_ht=0; |
|
215 | + } |
|
216 | + if (empty($this->multicurrency_amount_tva)) { |
|
217 | + $this->multicurrency_amount_tva=0; |
|
218 | + } |
|
219 | + if (empty($this->multicurrency_amount_ttc)) { |
|
220 | + $this->multicurrency_amount_ttc=0; |
|
221 | + } |
|
212 | 222 | |
213 | 223 | // Check parameters |
214 | 224 | if (empty($this->description)) |
@@ -238,8 +248,7 @@ discard block |
||
238 | 248 | { |
239 | 249 | $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."societe_remise_except"); |
240 | 250 | return $this->id; |
241 | - } |
|
242 | - else |
|
251 | + } else |
|
243 | 252 | { |
244 | 253 | $this->error=$this->db->lasterror().' - sql='.$sql; |
245 | 254 | return -1; |
@@ -277,8 +286,7 @@ discard block |
||
277 | 286 | $this->error='ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved'; |
278 | 287 | return -2; |
279 | 288 | } |
280 | - } |
|
281 | - else |
|
289 | + } else |
|
282 | 290 | { |
283 | 291 | dol_print_error($this->db); |
284 | 292 | return -1; |
@@ -305,8 +313,7 @@ discard block |
||
305 | 313 | $this->error='ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved'; |
306 | 314 | return -2; |
307 | 315 | } |
308 | - } |
|
309 | - else |
|
316 | + } else |
|
310 | 317 | { |
311 | 318 | dol_print_error($this->db); |
312 | 319 | return -1; |
@@ -317,9 +324,18 @@ discard block |
||
317 | 324 | |
318 | 325 | // Delete but only if not used |
319 | 326 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except "; |
320 | - if ($this->fk_facture_source) $sql.= " WHERE fk_facture_source = ".$this->fk_facture_source; // Delete all lines of same serie |
|
321 | - elseif ($this->fk_invoice_supplier_source) $sql.= " WHERE fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; // Delete all lines of same serie |
|
322 | - else $sql.= " WHERE rowid = ".$this->id; // Delete only line |
|
327 | + if ($this->fk_facture_source) { |
|
328 | + $sql.= " WHERE fk_facture_source = ".$this->fk_facture_source; |
|
329 | + } |
|
330 | + // Delete all lines of same serie |
|
331 | + elseif ($this->fk_invoice_supplier_source) { |
|
332 | + $sql.= " WHERE fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; |
|
333 | + } |
|
334 | + // Delete all lines of same serie |
|
335 | + else { |
|
336 | + $sql.= " WHERE rowid = ".$this->id; |
|
337 | + } |
|
338 | + // Delete only line |
|
323 | 339 | $sql.= " AND (fk_facture_line IS NULL"; // Not used as absolute simple discount |
324 | 340 | $sql.= " AND fk_facture IS NULL)"; // Not used as credit note and not used as deposit |
325 | 341 | $sql.= " AND (fk_invoice_supplier_line IS NULL"; // Not used as absolute simple discount |
@@ -342,15 +358,13 @@ discard block |
||
342 | 358 | { |
343 | 359 | $this->db->commit(); |
344 | 360 | return 1; |
345 | - } |
|
346 | - else |
|
361 | + } else |
|
347 | 362 | { |
348 | 363 | $this->error=$this->db->lasterror(); |
349 | 364 | $this->db->rollback(); |
350 | 365 | return -1; |
351 | 366 | } |
352 | - } |
|
353 | - elseif($this->fk_invoice_supplier_source) { |
|
367 | + } elseif($this->fk_invoice_supplier_source) { |
|
354 | 368 | |
355 | 369 | $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn"; |
356 | 370 | $sql.=" set paye=0, fk_statut=1"; |
@@ -362,21 +376,18 @@ discard block |
||
362 | 376 | { |
363 | 377 | $this->db->commit(); |
364 | 378 | return 1; |
365 | - } |
|
366 | - else |
|
379 | + } else |
|
367 | 380 | { |
368 | 381 | $this->error=$this->db->lasterror(); |
369 | 382 | $this->db->rollback(); |
370 | 383 | return -1; |
371 | 384 | } |
372 | - } |
|
373 | - else |
|
385 | + } else |
|
374 | 386 | { |
375 | 387 | $this->db->commit(); |
376 | 388 | return 1; |
377 | 389 | } |
378 | - } |
|
379 | - else |
|
390 | + } else |
|
380 | 391 | { |
381 | 392 | $this->error=$this->db->lasterror(); |
382 | 393 | $this->db->rollback(); |
@@ -413,11 +424,19 @@ discard block |
||
413 | 424 | |
414 | 425 | $sql ="UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; |
415 | 426 | if(! empty($this->discount_type)) { |
416 | - if ($rowidline) $sql.=" SET fk_invoice_supplier_line = ".$rowidline; |
|
417 | - if ($rowidinvoice) $sql.=" SET fk_invoice_supplier = ".$rowidinvoice; |
|
427 | + if ($rowidline) { |
|
428 | + $sql.=" SET fk_invoice_supplier_line = ".$rowidline; |
|
429 | + } |
|
430 | + if ($rowidinvoice) { |
|
431 | + $sql.=" SET fk_invoice_supplier = ".$rowidinvoice; |
|
432 | + } |
|
418 | 433 | } else { |
419 | - if ($rowidline) $sql.=" SET fk_facture_line = ".$rowidline; |
|
420 | - if ($rowidinvoice) $sql.=" SET fk_facture = ".$rowidinvoice; |
|
434 | + if ($rowidline) { |
|
435 | + $sql.=" SET fk_facture_line = ".$rowidline; |
|
436 | + } |
|
437 | + if ($rowidinvoice) { |
|
438 | + $sql.=" SET fk_facture = ".$rowidinvoice; |
|
439 | + } |
|
421 | 440 | } |
422 | 441 | $sql.=" WHERE rowid = ".$this->id; |
423 | 442 | |
@@ -433,8 +452,7 @@ discard block |
||
433 | 452 | $this->fk_facture=$rowidinvoice; |
434 | 453 | } |
435 | 454 | return 1; |
436 | - } |
|
437 | - else |
|
455 | + } else |
|
438 | 456 | { |
439 | 457 | $this->error=$this->db->error(); |
440 | 458 | return -3; |
@@ -465,8 +483,7 @@ discard block |
||
465 | 483 | if ($resql) |
466 | 484 | { |
467 | 485 | return 1; |
468 | - } |
|
469 | - else |
|
486 | + } else |
|
470 | 487 | { |
471 | 488 | $this->error=$this->db->error(); |
472 | 489 | return -3; |
@@ -498,10 +515,18 @@ discard block |
||
498 | 515 | } else { |
499 | 516 | $sql.= " AND (rc.fk_facture IS NULL AND rc.fk_facture_line IS NULL)"; // Available to customer |
500 | 517 | } |
501 | - if (is_object($company)) $sql.= " AND rc.fk_soc = ".$company->id; |
|
502 | - if (is_object($user)) $sql.= " AND rc.fk_user = ".$user->id; |
|
503 | - if ($filter) $sql.=' AND ('.$filter.')'; |
|
504 | - if ($maxvalue) $sql.=' AND rc.amount_ttc <= '.price2num($maxvalue); |
|
518 | + if (is_object($company)) { |
|
519 | + $sql.= " AND rc.fk_soc = ".$company->id; |
|
520 | + } |
|
521 | + if (is_object($user)) { |
|
522 | + $sql.= " AND rc.fk_user = ".$user->id; |
|
523 | + } |
|
524 | + if ($filter) { |
|
525 | + $sql.=' AND ('.$filter.')'; |
|
526 | + } |
|
527 | + if ($maxvalue) { |
|
528 | + $sql.=' AND rc.amount_ttc <= '.price2num($maxvalue); |
|
529 | + } |
|
505 | 530 | |
506 | 531 | dol_syslog(get_class($this)."::getAvailableDiscounts", LOG_DEBUG); |
507 | 532 | $resql=$this->db->query($sql); |
@@ -537,15 +562,13 @@ discard block |
||
537 | 562 | $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; |
538 | 563 | $sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; |
539 | 564 | $sql.= ' AND f.type = 3'; |
540 | - } |
|
541 | - else if ($invoice->element == 'invoice_supplier') |
|
565 | + } else if ($invoice->element == 'invoice_supplier') |
|
542 | 566 | { |
543 | 567 | $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; |
544 | 568 | $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; |
545 | 569 | $sql.= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; |
546 | 570 | $sql.= ' AND f.type = 3'; |
547 | - } |
|
548 | - else |
|
571 | + } else |
|
549 | 572 | { |
550 | 573 | $this->error=get_class($this)."::getSumDepositsUsed was called with a bad object as a first parameter"; |
551 | 574 | dol_print_error($this->error); |
@@ -556,10 +579,12 @@ discard block |
||
556 | 579 | if ($resql) |
557 | 580 | { |
558 | 581 | $obj = $this->db->fetch_object($resql); |
559 | - if ($multicurrency) return $obj->multicurrency_amount; |
|
560 | - else return $obj->amount; |
|
561 | - } |
|
562 | - else |
|
582 | + if ($multicurrency) { |
|
583 | + return $obj->multicurrency_amount; |
|
584 | + } else { |
|
585 | + return $obj->amount; |
|
586 | + } |
|
587 | + } else |
|
563 | 588 | { |
564 | 589 | $this->error = $this->db->lasterror(); |
565 | 590 | return -1; |
@@ -583,15 +608,13 @@ discard block |
||
583 | 608 | $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; |
584 | 609 | $sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; |
585 | 610 | $sql.= ' AND (f.type = 2 OR f.type = 0)'; // Find discount coming from credit note or excess received |
586 | - } |
|
587 | - else if ($invoice->element == 'invoice_supplier') |
|
611 | + } else if ($invoice->element == 'invoice_supplier') |
|
588 | 612 | { |
589 | 613 | $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; |
590 | 614 | $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; |
591 | 615 | $sql.= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; |
592 | 616 | $sql.= ' AND (f.type = 2 OR f.type = 0)'; // Find discount coming from credit note or excess paid |
593 | - } |
|
594 | - else |
|
617 | + } else |
|
595 | 618 | { |
596 | 619 | $this->error=get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter"; |
597 | 620 | dol_print_error($this->error); |
@@ -602,10 +625,12 @@ discard block |
||
602 | 625 | if ($resql) |
603 | 626 | { |
604 | 627 | $obj = $this->db->fetch_object($resql); |
605 | - if ($multicurrency) return $obj->multicurrency_amount; |
|
606 | - else return $obj->amount; |
|
607 | - } |
|
608 | - else |
|
628 | + if ($multicurrency) { |
|
629 | + return $obj->multicurrency_amount; |
|
630 | + } else { |
|
631 | + return $obj->amount; |
|
632 | + } |
|
633 | + } else |
|
609 | 634 | { |
610 | 635 | $this->error = $this->db->lasterror(); |
611 | 636 | return -1; |
@@ -643,8 +668,12 @@ discard block |
||
643 | 668 | } |
644 | 669 | |
645 | 670 | |
646 | - if ($withpicto) $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); |
|
647 | - if ($withpicto && $withpicto != 2) $result.=' '; |
|
671 | + if ($withpicto) { |
|
672 | + $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend); |
|
673 | + } |
|
674 | + if ($withpicto && $withpicto != 2) { |
|
675 | + $result.=' '; |
|
676 | + } |
|
648 | 677 | $result.=$link.$ref.$linkend; |
649 | 678 | return $result; |
650 | 679 | } |
@@ -218,8 +218,7 @@ discard block |
||
218 | 218 | if (count($this->error) > 0) |
219 | 219 | { |
220 | 220 | return true; |
221 | - } |
|
222 | - else |
|
221 | + } else |
|
223 | 222 | { |
224 | 223 | return false; |
225 | 224 | } |
@@ -255,8 +254,9 @@ discard block |
||
255 | 254 | function OpenID_Standarize($openid_identity = null) |
256 | 255 | { |
257 | 256 | // phpcs:enable |
258 | - if ($openid_identity === null) |
|
259 | - $openid_identity = $this->openid_url_identity; |
|
257 | + if ($openid_identity === null) { |
|
258 | + $openid_identity = $this->openid_url_identity; |
|
259 | + } |
|
260 | 260 | |
261 | 261 | $u = parse_url(strtolower(trim($openid_identity))); |
262 | 262 | |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | } |
269 | 269 | if (isset($u['query'])){ // If there is a query string, then use identity as is |
270 | 270 | return $u['host'] . $u['path'] . '?' . $u['query']; |
271 | - }else{ |
|
271 | + } else{ |
|
272 | 272 | return $u['host'] . $u['path']; |
273 | 273 | } |
274 | 274 | } |
@@ -339,7 +339,9 @@ discard block |
||
339 | 339 | { |
340 | 340 | // phpcs:enable |
341 | 341 | // Remember, SSL MUST BE SUPPORTED |
342 | - if (is_array($params)) $params = $this->array2url($params); |
|
342 | + if (is_array($params)) { |
|
343 | + $params = $this->array2url($params); |
|
344 | + } |
|
343 | 345 | |
344 | 346 | $curl = curl_init($url . ($method == "GET" && $params != "" ? "?" . $params : "")); |
345 | 347 | @curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); |
@@ -347,13 +349,15 @@ discard block |
||
347 | 349 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); |
348 | 350 | curl_setopt($curl, CURLOPT_HTTPGET, ($method == "GET")); |
349 | 351 | curl_setopt($curl, CURLOPT_POST, ($method == "POST")); |
350 | - if ($method == "POST") curl_setopt($curl, CURLOPT_POSTFIELDS, $params); |
|
352 | + if ($method == "POST") { |
|
353 | + curl_setopt($curl, CURLOPT_POSTFIELDS, $params); |
|
354 | + } |
|
351 | 355 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
352 | 356 | $response = curl_exec($curl); |
353 | 357 | |
354 | 358 | if (curl_errno($curl) == 0){ |
355 | 359 | $response; |
356 | - }else{ |
|
360 | + } else{ |
|
357 | 361 | $this->ErrorStore('OPENID_CURL', curl_error($curl)); |
358 | 362 | } |
359 | 363 | return $response; |
@@ -400,7 +404,9 @@ discard block |
||
400 | 404 | global $conf; |
401 | 405 | |
402 | 406 | include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; |
403 | - if (empty($url)) $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; |
|
407 | + if (empty($url)) { |
|
408 | + $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; |
|
409 | + } |
|
404 | 410 | |
405 | 411 | $response = getURLContent($url); |
406 | 412 | |
@@ -458,8 +464,7 @@ discard block |
||
458 | 464 | echo '<script language="JavaScript" type="text/javascript">window.location=\''; |
459 | 465 | echo $redirect_to; |
460 | 466 | echo '\';</script>'; |
461 | - } |
|
462 | - else |
|
467 | + } else |
|
463 | 468 | { // Default Header Redirect |
464 | 469 | header('Location: ' . $redirect_to); |
465 | 470 | } |
@@ -502,8 +507,7 @@ discard block |
||
502 | 507 | if ($data['is_valid'] == "true") |
503 | 508 | { |
504 | 509 | return true; |
505 | - } |
|
506 | - else |
|
510 | + } else |
|
507 | 511 | { |
508 | 512 | return false; |
509 | 513 | } |
@@ -523,7 +527,9 @@ discard block |
||
523 | 527 | global $conf; |
524 | 528 | |
525 | 529 | include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; |
526 | - if (empty($url)) $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; |
|
530 | + if (empty($url)) { |
|
531 | + $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; |
|
532 | + } |
|
527 | 533 | |
528 | 534 | dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS get XRDS'); |
529 | 535 | |
@@ -554,8 +560,7 @@ discard block |
||
554 | 560 | { |
555 | 561 | $this->ErrorStore('OPENID_NOSERVERSFOUND'); |
556 | 562 | return false; |
557 | - } |
|
558 | - else |
|
563 | + } else |
|
559 | 564 | { |
560 | 565 | dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS found endpoint = '.$server); |
561 | 566 | $this->SetOpenIDServer($server); |
@@ -152,8 +152,12 @@ discard block |
||
152 | 152 | |
153 | 153 | $this->db = $db; |
154 | 154 | |
155 | - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0; |
|
156 | - if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled']=0; |
|
155 | + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { |
|
156 | + $this->fields['rowid']['visible']=0; |
|
157 | + } |
|
158 | + if (empty($conf->multicompany->enabled)) { |
|
159 | + $this->fields['entity']['enabled']=0; |
|
160 | + } |
|
157 | 161 | } |
158 | 162 | |
159 | 163 | /** |
@@ -227,7 +231,9 @@ discard block |
||
227 | 231 | public function fetch($id, $ref = null) |
228 | 232 | { |
229 | 233 | $result = $this->fetchCommon($id, $ref); |
230 | - if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); |
|
234 | + if ($result > 0 && ! empty($this->table_element_line)) { |
|
235 | + $this->fetchLines(); |
|
236 | + } |
|
231 | 237 | return $result; |
232 | 238 | } |
233 | 239 | |
@@ -295,7 +301,9 @@ discard block |
||
295 | 301 | if ($withpicto) |
296 | 302 | { |
297 | 303 | $result.=($linkstart.img_object($label, 'label', 'class="classfortooltip"').$linkend); |
298 | - if ($withpicto != 2) $result.=' '; |
|
304 | + if ($withpicto != 2) { |
|
305 | + $result.=' '; |
|
306 | + } |
|
299 | 307 | } |
300 | 308 | $result.= $linkstart . $this->label . $linkend; |
301 | 309 | return $result; |
@@ -337,33 +345,52 @@ discard block |
||
337 | 345 | |
338 | 346 | if ($mode == 0 || $mode == 1) |
339 | 347 | { |
340 | - if ($status == 1) return $langs->trans('Enabled'); |
|
341 | - if ($status == 0) return $langs->trans('Disabled'); |
|
342 | - } |
|
343 | - elseif ($mode == 2) |
|
348 | + if ($status == 1) { |
|
349 | + return $langs->trans('Enabled'); |
|
350 | + } |
|
351 | + if ($status == 0) { |
|
352 | + return $langs->trans('Disabled'); |
|
353 | + } |
|
354 | + } elseif ($mode == 2) |
|
344 | 355 | { |
345 | - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); |
|
346 | - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); |
|
347 | - } |
|
348 | - elseif ($mode == 3) |
|
356 | + if ($status == 1) { |
|
357 | + return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); |
|
358 | + } |
|
359 | + if ($status == 0) { |
|
360 | + return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); |
|
361 | + } |
|
362 | + } elseif ($mode == 3) |
|
349 | 363 | { |
350 | - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); |
|
351 | - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); |
|
352 | - } |
|
353 | - elseif ($mode == 4) |
|
364 | + if ($status == 1) { |
|
365 | + return img_picto($langs->trans('Enabled'),'statut4'); |
|
366 | + } |
|
367 | + if ($status == 0) { |
|
368 | + return img_picto($langs->trans('Disabled'),'statut5'); |
|
369 | + } |
|
370 | + } elseif ($mode == 4) |
|
354 | 371 | { |
355 | - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); |
|
356 | - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); |
|
357 | - } |
|
358 | - elseif ($mode == 5) |
|
372 | + if ($status == 1) { |
|
373 | + return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); |
|
374 | + } |
|
375 | + if ($status == 0) { |
|
376 | + return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); |
|
377 | + } |
|
378 | + } elseif ($mode == 5) |
|
359 | 379 | { |
360 | - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); |
|
361 | - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); |
|
362 | - } |
|
363 | - elseif ($mode == 6) |
|
380 | + if ($status == 1) { |
|
381 | + return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); |
|
382 | + } |
|
383 | + if ($status == 0) { |
|
384 | + return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); |
|
385 | + } |
|
386 | + } elseif ($mode == 6) |
|
364 | 387 | { |
365 | - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); |
|
366 | - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); |
|
388 | + if ($status == 1) { |
|
389 | + return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); |
|
390 | + } |
|
391 | + if ($status == 0) { |
|
392 | + return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); |
|
393 | + } |
|
367 | 394 | } |
368 | 395 | } |
369 | 396 | |
@@ -413,8 +440,7 @@ discard block |
||
413 | 440 | } |
414 | 441 | |
415 | 442 | $this->db->free($result); |
416 | - } |
|
417 | - else |
|
443 | + } else |
|
418 | 444 | { |
419 | 445 | dol_print_error($this->db); |
420 | 446 | } |
@@ -79,8 +79,7 @@ discard block |
||
79 | 79 | if ($selected == $obj->rowid) |
80 | 80 | { |
81 | 81 | $out.='<option value="'.$obj->rowid.'" selected>'; |
82 | - } |
|
83 | - else |
|
82 | + } else |
|
84 | 83 | { |
85 | 84 | $out.='<option value="'.$obj->rowid.'">'; |
86 | 85 | } |
@@ -89,8 +88,7 @@ discard block |
||
89 | 88 | $i++; |
90 | 89 | } |
91 | 90 | $out.="</select>"; |
92 | - } |
|
93 | - else { |
|
91 | + } else { |
|
94 | 92 | dol_print_error($this->db); |
95 | 93 | } |
96 | 94 | |
@@ -138,8 +136,7 @@ discard block |
||
138 | 136 | if ($selected == $obj->rowid || $selected == $obj->code) |
139 | 137 | { |
140 | 138 | print '<option value="'.$obj->code.'" selected>'; |
141 | - } |
|
142 | - else |
|
139 | + } else |
|
143 | 140 | { |
144 | 141 | print '<option value="'.$obj->code.'">'; |
145 | 142 | } |
@@ -148,14 +145,14 @@ discard block |
||
148 | 145 | $i++; |
149 | 146 | } |
150 | 147 | print "</select>"; |
151 | - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
152 | - } |
|
153 | - else |
|
148 | + if ($user->admin) { |
|
149 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
150 | + } |
|
151 | + } else |
|
154 | 152 | { |
155 | 153 | print $langs->trans("NoTypeOfPagePleaseEditDictionary"); |
156 | 154 | } |
157 | - } |
|
158 | - else { |
|
155 | + } else { |
|
159 | 156 | dol_print_error($this->db); |
160 | 157 | } |
161 | 158 | } |
@@ -191,8 +188,7 @@ discard block |
||
191 | 188 | if ($selected == $key) |
192 | 189 | { |
193 | 190 | $out .= '<option value="'.$key.'" selected>'; |
194 | - } |
|
195 | - else |
|
191 | + } else |
|
196 | 192 | { |
197 | 193 | $out .= '<option value="'.$key.'">'; |
198 | 194 | } |