@@ -36,13 +36,17 @@ |
||
36 | 36 | // List of supported format |
37 | 37 | $tmptype2label=ExtraFields::$type2label; |
38 | 38 | $type2label=array(''); |
39 | -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); |
|
39 | +foreach ($tmptype2label as $key => $val) { |
|
40 | + $type2label[$key]=$langs->transnoentitiesnoconv($val); |
|
41 | +} |
|
40 | 42 | |
41 | 43 | $action=GETPOST('action', 'alpha'); |
42 | 44 | $attrname=GETPOST('attrname', 'alpha'); |
43 | 45 | $elementtype='socpeople'; //Must be the $element of the class that manage extrafield |
44 | 46 | |
45 | -if (!$user->admin) accessforbidden(); |
|
47 | +if (!$user->admin) { |
|
48 | + accessforbidden(); |
|
49 | +} |
|
46 | 50 | |
47 | 51 | |
48 | 52 | /* |
@@ -51,8 +51,7 @@ discard block |
||
51 | 51 | { |
52 | 52 | print '<br>'; |
53 | 53 | print '<font class="error">'.$langs->transnoentities("ErrorFieldRequired",$langs->trans("VATIntraShort")).'</font><br>'; |
54 | -} |
|
55 | -else |
|
54 | +} else |
|
56 | 55 | { |
57 | 56 | $vatNumber = preg_replace('/\^\w/', '', $vatNumber); |
58 | 57 | $countryCode=substr($vatNumber,0,2); |
@@ -103,18 +102,15 @@ discard block |
||
103 | 102 | { |
104 | 103 | print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>'; |
105 | 104 | $messagetoshow=$soapclient->response; |
106 | - } |
|
107 | - elseif (preg_match('/TIMEOUT/i',$result['faultstring'])) |
|
105 | + } elseif (preg_match('/TIMEOUT/i',$result['faultstring'])) |
|
108 | 106 | { |
109 | 107 | print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>'; |
110 | 108 | $messagetoshow=$soapclient->response; |
111 | - } |
|
112 | - elseif (preg_match('/SERVER_BUSY/i',$result['faultstring'])) |
|
109 | + } elseif (preg_match('/SERVER_BUSY/i',$result['faultstring'])) |
|
113 | 110 | { |
114 | 111 | print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>'; |
115 | 112 | $messagetoshow=$soapclient->response; |
116 | - } |
|
117 | - elseif ($result['faultstring']) |
|
113 | + } elseif ($result['faultstring']) |
|
118 | 114 | { |
119 | 115 | print '<font class="error">'.$langs->trans("Error").'</font><br>'; |
120 | 116 | $messagetoshow=$result['faultstring']; |
@@ -123,22 +119,24 @@ discard block |
||
123 | 119 | elseif (preg_match('/INVALID_INPUT/i',$result['faultstring']) |
124 | 120 | || ($result['requestDate'] && ! $result['valid'])) |
125 | 121 | { |
126 | - if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>'; |
|
122 | + if ($result['requestDate']) { |
|
123 | + print $langs->trans("Date").': '.$result['requestDate'].'<br>'; |
|
124 | + } |
|
127 | 125 | print $langs->trans("VATIntraSyntaxIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>'; |
128 | 126 | print $langs->trans("ValueIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>'; |
129 | 127 | //$messagetoshow=$soapclient->response; |
130 | - } |
|
131 | - else |
|
128 | + } else |
|
132 | 129 | { |
133 | 130 | // Syntaxe ok |
134 | - if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>'; |
|
131 | + if ($result['requestDate']) { |
|
132 | + print $langs->trans("Date").': '.$result['requestDate'].'<br>'; |
|
133 | + } |
|
135 | 134 | print $langs->trans("VATIntraSyntaxIsValid").': <font class="ok">'.$langs->trans("Yes").'</font><br>'; |
136 | 135 | print $langs->trans("ValueIsValid").': '; |
137 | 136 | if (preg_match('/MS_UNAVAILABLE/i',$result['faultstring'])) |
138 | 137 | { |
139 | 138 | print '<font class="error">'.$langs->trans("ErrorVATCheckMS_UNAVAILABLE",$countryCode).'</font><br>'; |
140 | - } |
|
141 | - else |
|
139 | + } else |
|
142 | 140 | { |
143 | 141 | if (! empty($result['valid']) && ($result['valid']==1 || $result['valid']=='true')) |
144 | 142 | { |
@@ -146,8 +144,7 @@ discard block |
||
146 | 144 | print '<br>'; |
147 | 145 | print $langs->trans("Name").': '.$result['name'].'<br>'; |
148 | 146 | print $langs->trans("Address").': '.$result['address'].'<br>'; |
149 | - } |
|
150 | - else |
|
147 | + } else |
|
151 | 148 | { |
152 | 149 | print '<font class="error">'.$langs->trans("No").'</font>'; |
153 | 150 | print '<br>'."\n"; |
@@ -44,7 +44,9 @@ discard block |
||
44 | 44 | |
45 | 45 | // Security check |
46 | 46 | $socid = GETPOST("socid","int"); |
47 | -if ($user->societe_id) $socid=$user->societe_id; |
|
47 | +if ($user->societe_id) { |
|
48 | + $socid=$user->societe_id; |
|
49 | +} |
|
48 | 50 | $result = restrictedArea($user, 'societe','',''); |
49 | 51 | |
50 | 52 | $id=GETPOST("id","int"); |
@@ -97,7 +99,9 @@ discard block |
||
97 | 99 | |
98 | 100 | $parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas); |
99 | 101 | $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
100 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
102 | +if ($reshook < 0) { |
|
103 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
104 | +} |
|
101 | 105 | |
102 | 106 | if (empty($reshook)) |
103 | 107 | { |
@@ -116,8 +120,12 @@ discard block |
||
116 | 120 | // Modification |
117 | 121 | if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha')) |
118 | 122 | { |
119 | - if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
120 | - if (! GETPOST('bank','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); |
|
123 | + if (! GETPOST('label','alpha')) { |
|
124 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
125 | + } |
|
126 | + if (! GETPOST('bank','alpha')) { |
|
127 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); |
|
128 | + } |
|
121 | 129 | $action='edit'; |
122 | 130 | $error++; |
123 | 131 | } |
@@ -167,8 +175,7 @@ discard block |
||
167 | 175 | if (! $result) |
168 | 176 | { |
169 | 177 | setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); |
170 | - } |
|
171 | - else |
|
178 | + } else |
|
172 | 179 | { |
173 | 180 | // If this account is the default bank account, we disable others |
174 | 181 | if ($companybankaccount->default_rib) |
@@ -188,11 +195,21 @@ discard block |
||
188 | 195 | // Modification |
189 | 196 | if (! GETPOST('label','alpha') || ! GETPOST('proprio','alpha') || ! GETPOST('cardnumber','alpha') || ! GETPOST('exp_date_month','alpha') || ! GETPOST('exp_date_year','alpha') || ! GETPOST('cvn','alpha')) |
190 | 197 | { |
191 | - if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
192 | - if (! GETPOST('proprio','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); |
|
193 | - if (! GETPOST('cardnumber','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); |
|
194 | - if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); |
|
195 | - if (! GETPOST('cvn','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); |
|
198 | + if (! GETPOST('label','alpha')) { |
|
199 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
200 | + } |
|
201 | + if (! GETPOST('proprio','alpha')) { |
|
202 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); |
|
203 | + } |
|
204 | + if (! GETPOST('cardnumber','alpha')) { |
|
205 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); |
|
206 | + } |
|
207 | + if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) { |
|
208 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); |
|
209 | + } |
|
210 | + if (! GETPOST('cvn','alpha')) { |
|
211 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); |
|
212 | + } |
|
196 | 213 | $action='createcard'; |
197 | 214 | $error++; |
198 | 215 | } |
@@ -218,8 +235,7 @@ discard block |
||
218 | 235 | if (! $result) |
219 | 236 | { |
220 | 237 | setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); |
221 | - } |
|
222 | - else |
|
238 | + } else |
|
223 | 239 | { |
224 | 240 | // If this account is the default bank account, we disable others |
225 | 241 | if ($companypaymentmode->default_rib) |
@@ -240,8 +256,12 @@ discard block |
||
240 | 256 | |
241 | 257 | if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha')) |
242 | 258 | { |
243 | - if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
244 | - if (! GETPOST('bank','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); |
|
259 | + if (! GETPOST('label','alpha')) { |
|
260 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
261 | + } |
|
262 | + if (! GETPOST('bank','alpha')) { |
|
263 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); |
|
264 | + } |
|
245 | 265 | $action='create'; |
246 | 266 | $error++; |
247 | 267 | } |
@@ -325,8 +345,7 @@ discard block |
||
325 | 345 | $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; |
326 | 346 | header('Location: '.$url); |
327 | 347 | exit; |
328 | - } |
|
329 | - else |
|
348 | + } else |
|
330 | 349 | { |
331 | 350 | $db->rollback(); |
332 | 351 | } |
@@ -339,11 +358,21 @@ discard block |
||
339 | 358 | |
340 | 359 | if (! GETPOST('label','alpha') || ! GETPOST('proprio','alpha') || ! GETPOST('cardnumber','alpha') || ! GETPOST('exp_date_month','alpha') || ! GETPOST('exp_date_year','alpha') || ! GETPOST('cvn','alpha')) |
341 | 360 | { |
342 | - if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
343 | - if (! GETPOST('proprio','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); |
|
344 | - if (! GETPOST('cardnumber','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); |
|
345 | - if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); |
|
346 | - if (! GETPOST('cvn','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); |
|
361 | + if (! GETPOST('label','alpha')) { |
|
362 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
363 | + } |
|
364 | + if (! GETPOST('proprio','alpha')) { |
|
365 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); |
|
366 | + } |
|
367 | + if (! GETPOST('cardnumber','alpha')) { |
|
368 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); |
|
369 | + } |
|
370 | + if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) { |
|
371 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); |
|
372 | + } |
|
373 | + if (! GETPOST('cvn','alpha')) { |
|
374 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); |
|
375 | + } |
|
347 | 376 | $action='createcard'; |
348 | 377 | $error++; |
349 | 378 | } |
@@ -390,8 +419,7 @@ discard block |
||
390 | 419 | $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; |
391 | 420 | header('Location: '.$url); |
392 | 421 | exit; |
393 | - } |
|
394 | - else |
|
422 | + } else |
|
395 | 423 | { |
396 | 424 | $db->rollback(); |
397 | 425 | } |
@@ -407,8 +435,7 @@ discard block |
||
407 | 435 | $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
408 | 436 | header('Location: '.$url); |
409 | 437 | exit; |
410 | - } |
|
411 | - else |
|
438 | + } else |
|
412 | 439 | { |
413 | 440 | setEventMessages($db->lasterror, null, 'errors'); |
414 | 441 | } |
@@ -425,13 +452,11 @@ discard block |
||
425 | 452 | $url = $_SERVER['PHP_SELF']."?socid=".$object->id; |
426 | 453 | header('Location: '.$url); |
427 | 454 | exit; |
428 | - } |
|
429 | - else |
|
455 | + } else |
|
430 | 456 | { |
431 | 457 | setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); |
432 | 458 | } |
433 | - } |
|
434 | - else |
|
459 | + } else |
|
435 | 460 | { |
436 | 461 | setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); |
437 | 462 | } |
@@ -447,13 +472,11 @@ discard block |
||
447 | 472 | $url = $_SERVER['PHP_SELF']."?socid=".$object->id; |
448 | 473 | header('Location: '.$url); |
449 | 474 | exit; |
450 | - } |
|
451 | - else |
|
475 | + } else |
|
452 | 476 | { |
453 | 477 | setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); |
454 | 478 | } |
455 | - } |
|
456 | - else |
|
479 | + } else |
|
457 | 480 | { |
458 | 481 | setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); |
459 | 482 | } |
@@ -489,8 +512,7 @@ discard block |
||
489 | 512 | { |
490 | 513 | $error++; |
491 | 514 | setEventMessages('ThisThirdpartyIsNotACustomer', null, 'errors'); |
492 | - } |
|
493 | - else |
|
515 | + } else |
|
494 | 516 | { |
495 | 517 | // Creation of Stripe customer + update of societe_account |
496 | 518 | $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus, 1); |
@@ -498,8 +520,7 @@ discard block |
||
498 | 520 | { |
499 | 521 | $error++; |
500 | 522 | setEventMessages($stripe->error, $stripe->errors, 'errors'); |
501 | - } |
|
502 | - else |
|
523 | + } else |
|
503 | 524 | { |
504 | 525 | $stripecu = $cu->id; |
505 | 526 | } |
@@ -514,8 +535,7 @@ discard block |
||
514 | 535 | { |
515 | 536 | $error++; |
516 | 537 | setEventMessages('ThisPaymentModeIsNotACard', null, 'errors'); |
517 | - } |
|
518 | - else |
|
538 | + } else |
|
519 | 539 | { |
520 | 540 | // Get the Stripe customer |
521 | 541 | $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); |
@@ -533,8 +553,7 @@ discard block |
||
533 | 553 | { |
534 | 554 | $error++; |
535 | 555 | setEventMessages($stripe->error, $stripe->errors, 'errors'); |
536 | - } |
|
537 | - else |
|
556 | + } else |
|
538 | 557 | { |
539 | 558 | $stripecard = $card->id; |
540 | 559 | } |
@@ -580,8 +599,7 @@ discard block |
||
580 | 599 | { |
581 | 600 | $stripecu = $newcu; |
582 | 601 | $db->commit(); |
583 | - } |
|
584 | - else |
|
602 | + } else |
|
585 | 603 | { |
586 | 604 | $db->rollback(); |
587 | 605 | } |
@@ -594,14 +612,12 @@ discard block |
||
594 | 612 | $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
595 | 613 | header('Location: '.$url); |
596 | 614 | exit; |
597 | - } |
|
598 | - catch(Exception $e) |
|
615 | + } catch(Exception $e) |
|
599 | 616 | { |
600 | 617 | $error++; |
601 | 618 | setEventMessages($e->getMessage(), null, 'errors'); |
602 | 619 | } |
603 | - } |
|
604 | - elseif ($action == 'setassourcedefault') |
|
620 | + } elseif ($action == 'setassourcedefault') |
|
605 | 621 | { |
606 | 622 | try { |
607 | 623 | $cu=$stripe->customerStripe($object, $stripeacc, $servicestatus); |
@@ -611,14 +627,12 @@ discard block |
||
611 | 627 | $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
612 | 628 | header('Location: '.$url); |
613 | 629 | exit; |
614 | - } |
|
615 | - catch(Exception $e) |
|
630 | + } catch(Exception $e) |
|
616 | 631 | { |
617 | 632 | $error++; |
618 | 633 | setEventMessages($e->getMessage(), null, 'errors'); |
619 | 634 | } |
620 | - } |
|
621 | - elseif ($action == 'deletecard' && $source) |
|
635 | + } elseif ($action == 'deletecard' && $source) |
|
622 | 636 | { |
623 | 637 | try { |
624 | 638 | $cu=$stripe->customerStripe($object, $stripeacc, $servicestatus); |
@@ -626,15 +640,17 @@ discard block |
||
626 | 640 | if ($card) |
627 | 641 | { |
628 | 642 | // $card->detach(); Does not work with card_, only with src_ |
629 | - if (method_exists($card, 'detach')) $card->detach(); |
|
630 | - else $card->delete(); |
|
643 | + if (method_exists($card, 'detach')) { |
|
644 | + $card->detach(); |
|
645 | + } else { |
|
646 | + $card->delete(); |
|
647 | + } |
|
631 | 648 | } |
632 | 649 | |
633 | 650 | $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
634 | 651 | header('Location: '.$url); |
635 | 652 | exit; |
636 | - } |
|
637 | - catch(Exception $e) |
|
653 | + } catch(Exception $e) |
|
638 | 654 | { |
639 | 655 | $error++; |
640 | 656 | setEventMessages($e->getMessage(), null, 'errors'); |
@@ -672,20 +688,23 @@ discard block |
||
672 | 688 | { |
673 | 689 | $companybankaccount->fetch(0, $object->id); |
674 | 690 | $companypaymentmode->fetch(0, null, $object->id, 'card'); |
675 | -} |
|
676 | -else |
|
691 | +} else |
|
677 | 692 | { |
678 | 693 | $companybankaccount->fetch($id); |
679 | 694 | $companypaymentmode->fetch($id); |
680 | 695 | } |
681 | -if (empty($companybankaccount->socid)) $companybankaccount->socid=$object->id; |
|
696 | +if (empty($companybankaccount->socid)) { |
|
697 | + $companybankaccount->socid=$object->id; |
|
698 | +} |
|
682 | 699 | |
683 | 700 | if ($socid && ($action == 'edit' || $action == 'editcard') && $user->rights->societe->creer) |
684 | 701 | { |
685 | 702 | print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">'; |
686 | 703 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
687 | 704 | $actionforadd='update'; |
688 | - if ($action == 'editcard') $actionforadd='updatecard'; |
|
705 | + if ($action == 'editcard') { |
|
706 | + $actionforadd='updatecard'; |
|
707 | + } |
|
689 | 708 | print '<input type="hidden" name="action" value="'.$actionforadd.'">'; |
690 | 709 | print '<input type="hidden" name="id" value="'.GETPOST("id","int").'">'; |
691 | 710 | } |
@@ -694,7 +713,9 @@ discard block |
||
694 | 713 | print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">'; |
695 | 714 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
696 | 715 | $actionforadd='add'; |
697 | - if ($action == 'createcard') $actionforadd='addcard'; |
|
716 | + if ($action == 'createcard') { |
|
717 | + $actionforadd='addcard'; |
|
718 | + } |
|
698 | 719 | print '<input type="hidden" name="action" value="'.$actionforadd.'">'; |
699 | 720 | } |
700 | 721 | |
@@ -720,10 +741,12 @@ discard block |
||
720 | 741 | dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); |
721 | 742 | |
722 | 743 | |
723 | - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
744 | + if (! empty($conf->global->SOCIETE_USEPREFIX)) { |
|
745 | + // Old not used prefix field |
|
724 | 746 | { |
725 | 747 | print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; |
726 | 748 | } |
749 | + } |
|
727 | 750 | |
728 | 751 | //if ($conf->agenda->enabled && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events'); |
729 | 752 | |
@@ -737,19 +760,31 @@ discard block |
||
737 | 760 | print '<tr><td class="titlefield">'; |
738 | 761 | print $langs->trans('CustomerCode').'</td><td colspan="2">'; |
739 | 762 | print $object->code_client; |
740 | - if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; |
|
763 | + if ($object->check_codeclient() <> 0) { |
|
764 | + print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; |
|
765 | + } |
|
741 | 766 | print '</td></tr>'; |
742 | 767 | $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; |
743 | 768 | $resql=$db->query($sql); |
744 | - if (!$resql) dol_print_error($db); |
|
769 | + if (!$resql) { |
|
770 | + dol_print_error($db); |
|
771 | + } |
|
745 | 772 | |
746 | 773 | $obj = $db->fetch_object($resql); |
747 | 774 | $nbFactsClient = $obj->nb; |
748 | 775 | $thirdTypeArray['customer']=$langs->trans("customer"); |
749 | - if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal']=$langs->transnoentitiesnoconv('Proposals'); |
|
750 | - if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order']=$langs->transnoentitiesnoconv('Orders'); |
|
751 | - if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice']=$langs->transnoentitiesnoconv('Invoices'); |
|
752 | - if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract']=$langs->transnoentitiesnoconv('Contracts'); |
|
776 | + if ($conf->propal->enabled && $user->rights->propal->lire) { |
|
777 | + $elementTypeArray['propal']=$langs->transnoentitiesnoconv('Proposals'); |
|
778 | + } |
|
779 | + if ($conf->commande->enabled && $user->rights->commande->lire) { |
|
780 | + $elementTypeArray['order']=$langs->transnoentitiesnoconv('Orders'); |
|
781 | + } |
|
782 | + if ($conf->facture->enabled && $user->rights->facture->lire) { |
|
783 | + $elementTypeArray['invoice']=$langs->transnoentitiesnoconv('Invoices'); |
|
784 | + } |
|
785 | + if ($conf->contrat->enabled && $user->rights->contrat->lire) { |
|
786 | + $elementTypeArray['contract']=$langs->transnoentitiesnoconv('Contracts'); |
|
787 | + } |
|
753 | 788 | } |
754 | 789 | |
755 | 790 | if (! empty($conf->stripe->enabled)) |
@@ -764,7 +799,9 @@ discard block |
||
764 | 799 | print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); |
765 | 800 | if ($stripecu && $action != 'editkey_account') |
766 | 801 | { |
767 | - if (! empty($conf->stripe->enabled) && !empty($stripeacc)) $connect=$stripeacc.'/'; |
|
802 | + if (! empty($conf->stripe->enabled) && !empty($stripeacc)) { |
|
803 | + $connect=$stripeacc.'/'; |
|
804 | + } |
|
768 | 805 | $url='https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu; |
769 | 806 | if ($servicestatus) |
770 | 807 | { |
@@ -811,8 +848,7 @@ discard block |
||
811 | 848 | if ($customerstripe->id) { |
812 | 849 | $listofsources=$customerstripe->sources->data; |
813 | 850 | } |
814 | - } |
|
815 | - catch(Exception $e) |
|
851 | + } catch(Exception $e) |
|
816 | 852 | { |
817 | 853 | dol_syslog("Error when searching/loading Stripe customer for thirdparty id =".$object->id); |
818 | 854 | } |
@@ -888,16 +924,21 @@ discard block |
||
888 | 924 | print img_credit_card($companypaymentmodetemp->type); |
889 | 925 | print '</td>'; |
890 | 926 | print '<td>'; |
891 | - if ($companypaymentmodetemp->last_four) print '....'.$companypaymentmodetemp->last_four; |
|
892 | - if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) print ' - '.sprintf("%02d", $companypaymentmodetemp->exp_date_month).'/'.$companypaymentmodetemp->exp_date_year.''; |
|
927 | + if ($companypaymentmodetemp->last_four) { |
|
928 | + print '....'.$companypaymentmodetemp->last_four; |
|
929 | + } |
|
930 | + if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) { |
|
931 | + print ' - '.sprintf("%02d", $companypaymentmodetemp->exp_date_month).'/'.$companypaymentmodetemp->exp_date_year.''; |
|
932 | + } |
|
893 | 933 | print '</td><td>'; |
894 | 934 | if ($companypaymentmodetemp->country_code) |
895 | 935 | { |
896 | 936 | $img=picto_from_langcode($companypaymentmodetemp->country_code); |
897 | 937 | print $img?$img.' ':''; |
898 | 938 | print getCountry($companypaymentmodetemp->country_code,1); |
939 | + } else { |
|
940 | + print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
899 | 941 | } |
900 | - else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
901 | 942 | print '</td>'; |
902 | 943 | // Default |
903 | 944 | print '<td align="center">'; |
@@ -911,8 +952,11 @@ discard block |
||
911 | 952 | } |
912 | 953 | print '</td>'; |
913 | 954 | print '<td>'; |
914 | - if (empty($companypaymentmodetemp->stripe_card_ref)) print $langs->trans("Local"); |
|
915 | - else print $langs->trans("LocalAndRemote"); |
|
955 | + if (empty($companypaymentmodetemp->stripe_card_ref)) { |
|
956 | + print $langs->trans("Local"); |
|
957 | + } else { |
|
958 | + print $langs->trans("LocalAndRemote"); |
|
959 | + } |
|
916 | 960 | print '</td>'; |
917 | 961 | print '<td>'; |
918 | 962 | print dol_print_date($companypaymentmodetemp->tms, 'dayhour'); |
@@ -939,8 +983,9 @@ discard block |
||
939 | 983 | $i++; |
940 | 984 | } |
941 | 985 | } |
986 | + } else { |
|
987 | + dol_print_error($db); |
|
942 | 988 | } |
943 | - else dol_print_error($db); |
|
944 | 989 | } |
945 | 990 | |
946 | 991 | // Show remote sources (not already shown as local source) |
@@ -948,7 +993,10 @@ discard block |
||
948 | 993 | { |
949 | 994 | foreach ($listofsources as $src) |
950 | 995 | { |
951 | - if (! empty($arrayofstripecard[$src->id])) continue; // Already in previous list |
|
996 | + if (! empty($arrayofstripecard[$src->id])) { |
|
997 | + continue; |
|
998 | + } |
|
999 | + // Already in previous list |
|
952 | 1000 | |
953 | 1001 | $nbremote++; |
954 | 1002 | |
@@ -961,7 +1009,9 @@ discard block |
||
961 | 1009 | } |
962 | 1010 | // Src ID |
963 | 1011 | print '<td>'; |
964 | - if (!empty($stripeacc)) $connect=$stripeacc.'/'; |
|
1012 | + if (!empty($stripeacc)) { |
|
1013 | + $connect=$stripeacc.'/'; |
|
1014 | + } |
|
965 | 1015 | $url='https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id; |
966 | 1016 | if ($servicestatus) |
967 | 1017 | { |
@@ -974,12 +1024,10 @@ discard block |
||
974 | 1024 | if ($src->object=='card') |
975 | 1025 | { |
976 | 1026 | print img_credit_card($src->brand); |
977 | - } |
|
978 | - elseif ($src->object=='source' && $src->type=='card') |
|
1027 | + } elseif ($src->object=='source' && $src->type=='card') |
|
979 | 1028 | { |
980 | 1029 | print img_credit_card($src->card->brand); |
981 | - } |
|
982 | - elseif ($src->object=='source' && $src->type=='sepa_debit') |
|
1030 | + } elseif ($src->object=='source' && $src->type=='sepa_debit') |
|
983 | 1031 | { |
984 | 1032 | print '<span class="fa fa-university fa-2x fa-fw"></span>'; |
985 | 1033 | } |
@@ -994,10 +1042,10 @@ discard block |
||
994 | 1042 | $img=picto_from_langcode($src->country); |
995 | 1043 | print $img?$img.' ':''; |
996 | 1044 | print getCountry($src->country,1); |
1045 | + } else { |
|
1046 | + print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
997 | 1047 | } |
998 | - else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
999 | - } |
|
1000 | - elseif ($src->object=='source' && $src->type=='card') |
|
1048 | + } elseif ($src->object=='source' && $src->type=='card') |
|
1001 | 1049 | { |
1002 | 1050 | print $src->owner->name.'<br>....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.''; |
1003 | 1051 | print '</td><td>'; |
@@ -1007,10 +1055,10 @@ discard block |
||
1007 | 1055 | $img=picto_from_langcode($src->card->country); |
1008 | 1056 | print $img?$img.' ':''; |
1009 | 1057 | print getCountry($src->card->country,1); |
1058 | + } else { |
|
1059 | + print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
1010 | 1060 | } |
1011 | - else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
1012 | - } |
|
1013 | - elseif ($src->object=='source' && $src->type=='sepa_debit') |
|
1061 | + } elseif ($src->object=='source' && $src->type=='sepa_debit') |
|
1014 | 1062 | { |
1015 | 1063 | print 'info sepa'; |
1016 | 1064 | print '</td><td>'; |
@@ -1019,8 +1067,9 @@ discard block |
||
1019 | 1067 | $img=picto_from_langcode($src->sepa_debit->country); |
1020 | 1068 | print $img?$img.' ':''; |
1021 | 1069 | print getCountry($src->sepa_debit->country,1); |
1070 | + } else { |
|
1071 | + print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
1022 | 1072 | } |
1023 | - else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
1024 | 1073 | } |
1025 | 1074 | print '</td>'; |
1026 | 1075 | // Default |
@@ -1190,12 +1239,16 @@ discard block |
||
1190 | 1239 | $out.= '<input type="hidden" name="socid" value="'.$object->id.'">'; |
1191 | 1240 | $out.= '<input type="hidden" name="companybankid" value="'.$rib->id.'">'; |
1192 | 1241 | |
1193 | - if (is_array($modellist) && count($modellist) == 1) // If there is only one element |
|
1242 | + if (is_array($modellist) && count($modellist) == 1) { |
|
1243 | + // If there is only one element |
|
1194 | 1244 | { |
1195 | 1245 | $arraykeys=array_keys($modellist); |
1246 | + } |
|
1196 | 1247 | $modelselected=$arraykeys[0]; |
1197 | 1248 | } |
1198 | - if (! empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF; |
|
1249 | + if (! empty($conf->global->BANKADDON_PDF)) { |
|
1250 | + $modelselected = $conf->global->BANKADDON_PDF; |
|
1251 | + } |
|
1199 | 1252 | |
1200 | 1253 | $out.= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); |
1201 | 1254 | $out.= ajax_combobox('modelrib'.$rib->id); |
@@ -1207,21 +1260,29 @@ discard block |
||
1207 | 1260 | $formadmin=new FormAdmin($db); |
1208 | 1261 | $defaultlang=$codelang?$codelang:$langs->getDefaultLang(); |
1209 | 1262 | $morecss='maxwidth150'; |
1210 | - if ($conf->browser->layout == 'phone') $morecss='maxwidth100'; |
|
1263 | + if ($conf->browser->layout == 'phone') { |
|
1264 | + $morecss='maxwidth100'; |
|
1265 | + } |
|
1211 | 1266 | $out.= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss); |
1212 | 1267 | } |
1213 | 1268 | // Button |
1214 | 1269 | $genbutton = '<input class="button buttongen" id="'.$forname.'_generatebutton" name="'.$forname.'_generatebutton"'; |
1215 | 1270 | $genbutton.= ' type="submit" value="'.$buttonlabel.'"'; |
1216 | - if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) $genbutton.= ' disabled'; |
|
1271 | + if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) { |
|
1272 | + $genbutton.= ' disabled'; |
|
1273 | + } |
|
1217 | 1274 | $genbutton.= '>'; |
1218 | 1275 | if ($allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') |
1219 | 1276 | { |
1220 | 1277 | $langs->load("errors"); |
1221 | 1278 | $genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); |
1222 | 1279 | } |
1223 | - if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton=''; |
|
1224 | - if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') $genbutton=''; |
|
1280 | + if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') { |
|
1281 | + $genbutton=''; |
|
1282 | + } |
|
1283 | + if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') { |
|
1284 | + $genbutton=''; |
|
1285 | + } |
|
1225 | 1286 | $out.= $genbutton; |
1226 | 1287 | $out.= '</form>'; |
1227 | 1288 | } |
@@ -1250,7 +1311,9 @@ discard block |
||
1250 | 1311 | if (count($rib_list) == 0) |
1251 | 1312 | { |
1252 | 1313 | $colspan=8; |
1253 | - if (! empty($conf->prelevement->enabled)) $colspan+=2; |
|
1314 | + if (! empty($conf->prelevement->enabled)) { |
|
1315 | + $colspan+=2; |
|
1316 | + } |
|
1254 | 1317 | print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoBANRecord").'</td></tr>'; |
1255 | 1318 | } |
1256 | 1319 | |
@@ -1368,12 +1431,16 @@ discard block |
||
1368 | 1431 | $name = 'iban'; |
1369 | 1432 | $size = 30; |
1370 | 1433 | $content = $companybankaccount->iban; |
1371 | - if ($companybankaccount->needIBAN()) $require=true; |
|
1434 | + if ($companybankaccount->needIBAN()) { |
|
1435 | + $require=true; |
|
1436 | + } |
|
1372 | 1437 | } elseif ($val == 'BIC') { |
1373 | 1438 | $name = 'bic'; |
1374 | 1439 | $size = 12; |
1375 | 1440 | $content = $companybankaccount->bic; |
1376 | - if ($companybankaccount->needIBAN()) $require=true; |
|
1441 | + if ($companybankaccount->needIBAN()) { |
|
1442 | + $require=true; |
|
1443 | + } |
|
1377 | 1444 | } |
1378 | 1445 | |
1379 | 1446 | print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>'; |
@@ -1403,7 +1470,9 @@ discard block |
||
1403 | 1470 | |
1404 | 1471 | print '<table class="border" width="100%">'; |
1405 | 1472 | |
1406 | - if (empty($companybankaccount->rum)) $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); |
|
1473 | + if (empty($companybankaccount->rum)) { |
|
1474 | + $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); |
|
1475 | + } |
|
1407 | 1476 | |
1408 | 1477 | // RUM |
1409 | 1478 | print '<tr><td class="titlefield">'.$langs->trans("RUM").'</td>'; |
@@ -1515,11 +1584,15 @@ discard block |
||
1515 | 1584 | } elseif ($val == 'IBAN') { |
1516 | 1585 | $name = 'iban'; |
1517 | 1586 | $size = 30; |
1518 | - if ($companybankaccount->needIBAN()) $require=true; |
|
1587 | + if ($companybankaccount->needIBAN()) { |
|
1588 | + $require=true; |
|
1589 | + } |
|
1519 | 1590 | } elseif ($val == 'BIC') { |
1520 | 1591 | $name = 'bic'; |
1521 | 1592 | $size = 12; |
1522 | - if ($companybankaccount->needIBAN()) $require=true; |
|
1593 | + if ($companybankaccount->needIBAN()) { |
|
1594 | + $require=true; |
|
1595 | + } |
|
1523 | 1596 | } |
1524 | 1597 | |
1525 | 1598 | print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>'; |
@@ -35,11 +35,15 @@ discard block |
||
35 | 35 | |
36 | 36 | // Security check |
37 | 37 | $id = GETPOST('id')?GETPOST('id','int'):GETPOST('socid','int'); |
38 | -if ($user->societe_id) $id=$user->societe_id; |
|
38 | +if ($user->societe_id) { |
|
39 | + $id=$user->societe_id; |
|
40 | +} |
|
39 | 41 | $result = restrictedArea($user, 'societe', $id, '&societe'); |
40 | 42 | |
41 | 43 | $object = new Societe($db); |
42 | -if ($id > 0) $object->fetch($id); |
|
44 | +if ($id > 0) { |
|
45 | + $object->fetch($id); |
|
46 | +} |
|
43 | 47 | |
44 | 48 | $permissionnote=$user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php |
45 | 49 | |
@@ -61,7 +65,9 @@ discard block |
||
61 | 65 | $form = new Form($db); |
62 | 66 | |
63 | 67 | $title=$langs->trans("ThirdParty").' - '.$langs->trans("Notes"); |
64 | -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name.' - '.$langs->trans("Notes"); |
|
68 | +if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) { |
|
69 | + $title=$object->name.' - '.$langs->trans("Notes"); |
|
70 | +} |
|
65 | 71 | $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; |
66 | 72 | llxHeader('',$title,$help_url); |
67 | 73 | |
@@ -70,7 +76,9 @@ discard block |
||
70 | 76 | /* |
71 | 77 | * Affichage onglets |
72 | 78 | */ |
73 | - if (! empty($conf->notification->enabled)) $langs->load("mails"); |
|
79 | + if (! empty($conf->notification->enabled)) { |
|
80 | + $langs->load("mails"); |
|
81 | + } |
|
74 | 82 | |
75 | 83 | $head = societe_prepare_head($object); |
76 | 84 | |
@@ -89,17 +97,21 @@ discard block |
||
89 | 97 | print '<div class="underbanner clearboth"></div>'; |
90 | 98 | print '<table class="border centpercent">'; |
91 | 99 | |
92 | - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
100 | + if (! empty($conf->global->SOCIETE_USEPREFIX)) { |
|
101 | + // Old not used prefix field |
|
93 | 102 | { |
94 | 103 | print '<tr><td class="'.$cssclass.'">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; |
95 | 104 | } |
105 | + } |
|
96 | 106 | |
97 | 107 | if ($object->client) |
98 | 108 | { |
99 | 109 | print '<tr><td class="'.$cssclass.'">'; |
100 | 110 | print $langs->trans('CustomerCode').'</td><td colspan="3">'; |
101 | 111 | print $object->code_client; |
102 | - if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; |
|
112 | + if ($object->check_codeclient() <> 0) { |
|
113 | + print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; |
|
114 | + } |
|
103 | 115 | print '</td></tr>'; |
104 | 116 | } |
105 | 117 | |
@@ -108,7 +120,9 @@ discard block |
||
108 | 120 | print '<tr><td class="'.$cssclass.'">'; |
109 | 121 | print $langs->trans('SupplierCode').'</td><td colspan="3">'; |
110 | 122 | print $object->code_fournisseur; |
111 | - if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; |
|
123 | + if ($object->check_codefournisseur() <> 0) { |
|
124 | + print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; |
|
125 | + } |
|
112 | 126 | print '</td></tr>'; |
113 | 127 | } |
114 | 128 | |
@@ -122,8 +136,7 @@ discard block |
||
122 | 136 | include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; |
123 | 137 | |
124 | 138 | dol_fiche_end(); |
125 | -} |
|
126 | -else |
|
139 | +} else |
|
127 | 140 | { |
128 | 141 | $langs->load("errors"); |
129 | 142 | print $langs->trans("ErrorRecordNotFound"); |
@@ -32,7 +32,9 @@ discard block |
||
32 | 32 | $langs->load("companies"); |
33 | 33 | |
34 | 34 | $socid = GETPOST('socid','int'); |
35 | -if ($user->societe_id) $socid=$user->societe_id; |
|
35 | +if ($user->societe_id) { |
|
36 | + $socid=$user->societe_id; |
|
37 | +} |
|
36 | 38 | |
37 | 39 | // Security check |
38 | 40 | $result=restrictedArea($user,'societe',0,'','','',''); |
@@ -57,12 +59,14 @@ discard block |
||
57 | 59 | print '<div class="fichecenter"><div class="fichethirdleft">'; |
58 | 60 | |
59 | 61 | |
60 | -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo |
|
62 | +if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { |
|
63 | + // This is useless due to the global search combo |
|
61 | 64 | { |
62 | 65 | // Search thirdparty |
63 | 66 | if (! empty($conf->societe->enabled) && $user->rights->societe->lire) |
64 | 67 | { |
65 | 68 | $listofsearchfields['search_thirdparty']=array('text'=>'ThirdParty'); |
69 | +} |
|
66 | 70 | } |
67 | 71 | // Search contact/address |
68 | 72 | if (! empty($conf->societe->enabled) && $user->rights->societe->lire) |
@@ -78,10 +82,14 @@ discard block |
||
78 | 82 | $i=0; |
79 | 83 | foreach($listofsearchfields as $key => $value) |
80 | 84 | { |
81 | - if ($i == 0) print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("Search").'</th></tr>'; |
|
85 | + if ($i == 0) { |
|
86 | + print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("Search").'</th></tr>'; |
|
87 | + } |
|
82 | 88 | print '<tr '.$bc[false].'>'; |
83 | 89 | print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>'; |
84 | - if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; |
|
90 | + if ($i == 0) { |
|
91 | + print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; |
|
92 | + } |
|
85 | 93 | print '</tr>'; |
86 | 94 | $i++; |
87 | 95 | } |
@@ -106,11 +114,20 @@ discard block |
||
106 | 114 | |
107 | 115 | $sql = "SELECT s.rowid, s.client, s.fournisseur"; |
108 | 116 | $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
109 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
117 | +if (! $user->rights->societe->client->voir && ! $socid) { |
|
118 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
119 | +} |
|
110 | 120 | $sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; |
111 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
112 | -if ($socid) $sql.= " AND s.rowid = ".$socid; |
|
113 | -if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible |
|
121 | +if (! $user->rights->societe->client->voir && ! $socid) { |
|
122 | + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
123 | +} |
|
124 | +if ($socid) { |
|
125 | + $sql.= " AND s.rowid = ".$socid; |
|
126 | +} |
|
127 | +if (! $user->rights->fournisseur->lire) { |
|
128 | + $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; |
|
129 | +} |
|
130 | +// client=0, fournisseur=0 must be visible |
|
114 | 131 | //print $sql; |
115 | 132 | $result = $db->query($sql); |
116 | 133 | if ($result) |
@@ -122,10 +139,13 @@ discard block |
||
122 | 139 | if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found=1; $third['customer']++; } |
123 | 140 | if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found=1; $third['supplier']++; } |
124 | 141 | if (! empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found=1; $third['other']++; } |
125 | - if ($found) $total++; |
|
142 | + if ($found) { |
|
143 | + $total++; |
|
144 | + } |
|
126 | 145 | } |
146 | +} else { |
|
147 | + dol_print_error($db); |
|
127 | 148 | } |
128 | -else dol_print_error($db); |
|
129 | 149 | |
130 | 150 | print '<div class="div-table-responsive-no-min">'; |
131 | 151 | print '<table class="noborder nohover" width="100%">'."\n"; |
@@ -134,10 +154,18 @@ discard block |
||
134 | 154 | { |
135 | 155 | print '<tr><td align="center" colspan="2">'; |
136 | 156 | $dataseries=array(); |
137 | - if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[]=array($langs->trans("Prospects"), round($third['prospect'])); |
|
138 | - if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[]=array($langs->trans("Customers"), round($third['customer'])); |
|
139 | - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[]=array($langs->trans("Suppliers"), round($third['supplier'])); |
|
140 | - if (! empty($conf->societe->enabled)) $dataseries[]=array($langs->trans("Others"), round($third['other'])); |
|
157 | + if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) { |
|
158 | + $dataseries[]=array($langs->trans("Prospects"), round($third['prospect'])); |
|
159 | + } |
|
160 | + if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) { |
|
161 | + $dataseries[]=array($langs->trans("Customers"), round($third['customer'])); |
|
162 | + } |
|
163 | + if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) { |
|
164 | + $dataseries[]=array($langs->trans("Suppliers"), round($third['supplier'])); |
|
165 | + } |
|
166 | + if (! empty($conf->societe->enabled)) { |
|
167 | + $dataseries[]=array($langs->trans("Others"), round($third['other'])); |
|
168 | + } |
|
141 | 169 | include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; |
142 | 170 | $dolgraph = new DolGraph(); |
143 | 171 | $dolgraph->SetData($dataseries); |
@@ -148,8 +176,7 @@ discard block |
||
148 | 176 | $dolgraph->draw('idgraphthirdparties'); |
149 | 177 | print $dolgraph->show(); |
150 | 178 | print '</td></tr>'."\n"; |
151 | -} |
|
152 | -else |
|
179 | +} else |
|
153 | 180 | { |
154 | 181 | if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) |
155 | 182 | { |
@@ -193,7 +220,9 @@ discard block |
||
193 | 220 | $sql.= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs"; |
194 | 221 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid"; |
195 | 222 | $sql.= " WHERE c.type = 2"; |
196 | - if (! is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql.= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'"; |
|
223 | + if (! is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) { |
|
224 | + $sql.= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'"; |
|
225 | + } |
|
197 | 226 | $sql.= " AND c.entity IN (".getEntity('category').")"; |
198 | 227 | $sql.= " GROUP BY c.label"; |
199 | 228 | $total=0; |
@@ -214,8 +243,7 @@ discard block |
||
214 | 243 | if ($i < $nbmax) |
215 | 244 | { |
216 | 245 | $dataseries[]=array($obj->label, round($obj->nb)); |
217 | - } |
|
218 | - else |
|
246 | + } else |
|
219 | 247 | { |
220 | 248 | $rest+=$obj->nb; |
221 | 249 | } |
@@ -235,8 +263,7 @@ discard block |
||
235 | 263 | $dolgraph->setWidth('100%'); |
236 | 264 | $dolgraph->draw('idgraphcateg'); |
237 | 265 | print $dolgraph->show(); |
238 | - } |
|
239 | - else |
|
266 | + } else |
|
240 | 267 | { |
241 | 268 | while ($i < $num) |
242 | 269 | { |
@@ -270,11 +297,19 @@ discard block |
||
270 | 297 | $sql.= ", s.logo"; |
271 | 298 | $sql.= ", s.canvas, s.tms as datem, s.status as status"; |
272 | 299 | $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
273 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
300 | +if (! $user->rights->societe->client->voir && ! $socid) { |
|
301 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
302 | +} |
|
274 | 303 | $sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; |
275 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
276 | -if ($socid) $sql.= " AND s.rowid = ".$socid; |
|
277 | -if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur != 1 OR s.client != 0)"; |
|
304 | +if (! $user->rights->societe->client->voir && ! $socid) { |
|
305 | + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
306 | +} |
|
307 | +if ($socid) { |
|
308 | + $sql.= " AND s.rowid = ".$socid; |
|
309 | +} |
|
310 | +if (! $user->rights->fournisseur->lire) { |
|
311 | + $sql.=" AND (s.fournisseur != 1 OR s.client != 0)"; |
|
312 | +} |
|
278 | 313 | $sql.= $db->order("s.tms","DESC"); |
279 | 314 | $sql.= $db->plimit($max,0); |
280 | 315 | |
@@ -327,7 +362,9 @@ discard block |
||
327 | 362 | $thirdparty_static->name=$langs->trans("Customer"); |
328 | 363 | print $thirdparty_static->getNomUrl(0,'customer',0,1); |
329 | 364 | } |
330 | - if ($thirdparty_static->client == 3 && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print " / "; |
|
365 | + if ($thirdparty_static->client == 3 && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { |
|
366 | + print " / "; |
|
367 | + } |
|
331 | 368 | if (($thirdparty_static->client==2 || $thirdparty_static->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) |
332 | 369 | { |
333 | 370 | $thirdparty_static->name=$langs->trans("Prospect"); |
@@ -335,7 +372,9 @@ discard block |
||
335 | 372 | } |
336 | 373 | if (! empty($conf->fournisseur->enabled) && $thirdparty_static->fournisseur) |
337 | 374 | { |
338 | - if ($thirdparty_static->client) print " / "; |
|
375 | + if ($thirdparty_static->client) { |
|
376 | + print " / "; |
|
377 | + } |
|
339 | 378 | $thirdparty_static->name=$langs->trans("Supplier"); |
340 | 379 | print $thirdparty_static->getNomUrl(0,'supplier',0,1); |
341 | 380 | } |
@@ -357,8 +396,7 @@ discard block |
||
357 | 396 | print '</div>'; |
358 | 397 | print "<!-- End last thirdparties modified -->\n"; |
359 | 398 | } |
360 | -} |
|
361 | -else |
|
399 | +} else |
|
362 | 400 | { |
363 | 401 | dol_print_error($db); |
364 | 402 | } |
@@ -46,8 +46,9 @@ discard block |
||
46 | 46 | |
47 | 47 | // Security check |
48 | 48 | $socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int'); |
49 | -if ($user->societe_id) |
|
49 | +if ($user->societe_id) { |
|
50 | 50 | $socid = $user->societe_id; |
51 | +} |
|
51 | 52 | $result = restrictedArea($user, 'societe', $socid, '&societe'); |
52 | 53 | |
53 | 54 | $object = new Societe($db); |
@@ -63,14 +64,18 @@ discard block |
||
63 | 64 | |
64 | 65 | $parameters=array('id'=>$socid); |
65 | 66 | $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
66 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
67 | +if ($reshook < 0) { |
|
68 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
69 | +} |
|
67 | 70 | |
68 | 71 | if (empty($reshook)) |
69 | 72 | { |
70 | - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers |
|
73 | + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) { |
|
74 | + // Both test are required to be compatible with all browsers |
|
71 | 75 | { |
72 | 76 | $search_prod = ''; |
73 | 77 | } |
78 | + } |
|
74 | 79 | |
75 | 80 | if ($action == 'add_customer_price_confirm' && ! $cancel && ($user->rights->produit->creer || $user->rights->service->creer)) { |
76 | 81 | |
@@ -181,8 +186,9 @@ discard block |
||
181 | 186 | $result = $object->fetch($socid); |
182 | 187 | llxHeader("", $langs->trans("ThirdParty") . '-' . $langs->trans('PriceByCustomer')); |
183 | 188 | |
184 | -if (! empty($conf->notification->enabled)) |
|
189 | +if (! empty($conf->notification->enabled)) { |
|
185 | 190 | $langs->load("mails"); |
191 | +} |
|
186 | 192 | $head = societe_prepare_head($object); |
187 | 193 | |
188 | 194 | dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company'); |
@@ -196,17 +202,20 @@ discard block |
||
196 | 202 | print '<div class="underbanner clearboth"></div>'; |
197 | 203 | print '<table class="border centpercent">'; |
198 | 204 | |
199 | -if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
205 | +if (! empty($conf->global->SOCIETE_USEPREFIX)) { |
|
206 | + // Old not used prefix field |
|
200 | 207 | { |
201 | 208 | print '<tr><td class="titlefield">' . $langs->trans('Prefix') . '</td><td colspan="3">' . $object->prefix_comm . '</td></tr>'; |
202 | 209 | } |
210 | +} |
|
203 | 211 | |
204 | 212 | if ($object->client) { |
205 | 213 | print '<tr><td class="titlefield">'; |
206 | 214 | print $langs->trans('CustomerCode') . '</td><td colspan="3">'; |
207 | 215 | print $object->code_client; |
208 | - if ($object->check_codeclient() != 0) |
|
209 | - print ' <font class="error">(' . $langs->trans("WrongCustomerCode") . ')</font>'; |
|
216 | + if ($object->check_codeclient() != 0) { |
|
217 | + print ' <font class="error">(' . $langs->trans("WrongCustomerCode") . ')</font>'; |
|
218 | + } |
|
210 | 219 | print '</td></tr>'; |
211 | 220 | } |
212 | 221 | |
@@ -214,8 +223,9 @@ discard block |
||
214 | 223 | print '<tr><td class="titlefield">'; |
215 | 224 | print $langs->trans('SupplierCode') . '</td><td colspan="3">'; |
216 | 225 | print $object->code_fournisseur; |
217 | - if ($object->check_codefournisseur() != 0) |
|
218 | - print ' <font class="error">(' . $langs->trans("WrongSupplierCode") . ')</font>'; |
|
226 | + if ($object->check_codefournisseur() != 0) { |
|
227 | + print ' <font class="error">(' . $langs->trans("WrongSupplierCode") . ')</font>'; |
|
228 | + } |
|
219 | 229 | print '</td></tr>'; |
220 | 230 | } |
221 | 231 | |
@@ -239,10 +249,12 @@ discard block |
||
239 | 249 | $offset = $limit * $page; |
240 | 250 | $pageprev = $page - 1; |
241 | 251 | $pagenext = $page + 1; |
242 | - if (! $sortorder) |
|
243 | - $sortorder = "ASC"; |
|
244 | - if (! $sortfield) |
|
245 | - $sortfield = "soc.nom"; |
|
252 | + if (! $sortorder) { |
|
253 | + $sortorder = "ASC"; |
|
254 | + } |
|
255 | + if (! $sortfield) { |
|
256 | + $sortfield = "soc.nom"; |
|
257 | + } |
|
246 | 258 | |
247 | 259 | // Build filter to diplay only concerned lines |
248 | 260 | $filter = array ( |
@@ -474,8 +486,7 @@ discard block |
||
474 | 486 | print '</td>'; |
475 | 487 | } |
476 | 488 | print "</table>"; |
477 | - } |
|
478 | - else |
|
489 | + } else |
|
479 | 490 | { |
480 | 491 | print $langs->trans('None'); |
481 | 492 | } |
@@ -483,8 +494,7 @@ discard block |
||
483 | 494 | print "\n" . '<div class="tabsAction">' . "\n"; |
484 | 495 | print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '">' . $langs->trans("Ok") . '</a></div>'; |
485 | 496 | print "\n</div><br>\n"; |
486 | - } |
|
487 | - else |
|
497 | + } else |
|
488 | 498 | { |
489 | 499 | // View mode |
490 | 500 | |
@@ -598,11 +608,12 @@ discard block |
||
598 | 608 | |
599 | 609 | print "</tr>\n"; |
600 | 610 | } |
601 | - } |
|
602 | - else |
|
611 | + } else |
|
603 | 612 | { |
604 | 613 | $colspan=9; |
605 | - if ($user->rights->produit->supprimer || $user->rights->service->supprimer) $colspan+=1; |
|
614 | + if ($user->rights->produit->supprimer || $user->rights->service->supprimer) { |
|
615 | + $colspan+=1; |
|
616 | + } |
|
606 | 617 | print '<tr ' . $bc[false] . '><td colspan="'.$colspan.'">' . $langs->trans('None') . '</td></tr>'; |
607 | 618 | } |
608 | 619 |
@@ -42,12 +42,20 @@ discard block |
||
42 | 42 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
43 | 43 | require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; |
44 | 44 | require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
45 | -if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
|
45 | +if (! empty($conf->adherent->enabled)) { |
|
46 | + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
|
47 | +} |
|
46 | 48 | |
47 | 49 | $langs->loadLangs(array("companies","commercial","bills","banks","users")); |
48 | -if (! empty($conf->categorie->enabled)) $langs->load("categories"); |
|
49 | -if (! empty($conf->incoterm->enabled)) $langs->load("incoterm"); |
|
50 | -if (! empty($conf->notification->enabled)) $langs->load("mails"); |
|
50 | +if (! empty($conf->categorie->enabled)) { |
|
51 | + $langs->load("categories"); |
|
52 | +} |
|
53 | +if (! empty($conf->incoterm->enabled)) { |
|
54 | + $langs->load("incoterm"); |
|
55 | +} |
|
56 | +if (! empty($conf->notification->enabled)) { |
|
57 | + $langs->load("mails"); |
|
58 | +} |
|
51 | 59 | |
52 | 60 | $mesg=''; $error=0; $errors=array(); |
53 | 61 | |
@@ -56,8 +64,12 @@ discard block |
||
56 | 64 | $backtopage = GETPOST('backtopage','alpha'); |
57 | 65 | $confirm = GETPOST('confirm'); |
58 | 66 | $socid = GETPOST('socid','int')?GETPOST('socid','int'):GETPOST('id','int'); |
59 | -if ($user->societe_id) $socid=$user->societe_id; |
|
60 | -if (empty($socid) && $action == 'view') $action='create'; |
|
67 | +if ($user->societe_id) { |
|
68 | + $socid=$user->societe_id; |
|
69 | +} |
|
70 | +if (empty($socid) && $action == 'view') { |
|
71 | + $action='create'; |
|
72 | +} |
|
61 | 73 | |
62 | 74 | $object = new Societe($db); |
63 | 75 | $extrafields = new ExtraFields($db); |
@@ -98,7 +110,9 @@ discard block |
||
98 | 110 | |
99 | 111 | $parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas); |
100 | 112 | $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
101 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
113 | +if ($reshook < 0) { |
|
114 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
115 | +} |
|
102 | 116 | |
103 | 117 | if (empty($reshook)) |
104 | 118 | { |
@@ -129,18 +143,24 @@ discard block |
||
129 | 143 | if ($socid > 0 && empty($object->id)) |
130 | 144 | { |
131 | 145 | $result=$object->fetch($socid); |
132 | - if ($result <= 0) dol_print_error('',$object->error); |
|
133 | -} |
|
146 | + if ($result <= 0) { |
|
147 | + dol_print_error('',$object->error); |
|
148 | + } |
|
149 | + } |
|
134 | 150 | |
135 | 151 | $title=$langs->trans("ThirdParty"); |
136 | -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$langs->trans('Card'); |
|
152 | +if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) { |
|
153 | + $title=$object->name." - ".$langs->trans('Card'); |
|
154 | +} |
|
137 | 155 | $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; |
138 | 156 | llxHeader('',$title,$help_url); |
139 | 157 | |
140 | 158 | $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; |
141 | 159 | |
142 | 160 | |
143 | -if (!empty($object->id)) $res=$object->fetch_optionals($object->id,$extralabels); |
|
161 | +if (!empty($object->id)) { |
|
162 | + $res=$object->fetch_optionals($object->id,$extralabels); |
|
163 | +} |
|
144 | 164 | //if ($res < 0) { dol_print_error($db); exit; } |
145 | 165 | |
146 | 166 |
@@ -61,12 +61,15 @@ discard block |
||
61 | 61 | global $conf, $dolibarr_main_authentication, $dolibarr_auto_user; |
62 | 62 | |
63 | 63 | // Authentication mode |
64 | - if (empty($dolibarr_main_authentication)) |
|
65 | - $dolibarr_main_authentication = 'http,dolibarr'; |
|
64 | + if (empty($dolibarr_main_authentication)) { |
|
65 | + $dolibarr_main_authentication = 'http,dolibarr'; |
|
66 | + } |
|
66 | 67 | // Authentication mode: forceuser |
67 | 68 | if ($dolibarr_main_authentication == 'forceuser') |
68 | 69 | { |
69 | - if (empty($dolibarr_auto_user)) $dolibarr_auto_user='auto'; |
|
70 | + if (empty($dolibarr_auto_user)) { |
|
71 | + $dolibarr_auto_user='auto'; |
|
72 | + } |
|
70 | 73 | if ($dolibarr_auto_user != $login) |
71 | 74 | { |
72 | 75 | dol_syslog("Warning: your instance is set to use the automatic forced login '".$dolibarr_auto_user."' that is not the requested login. API usage is forbidden in this mode."); |
@@ -80,7 +83,9 @@ discard block |
||
80 | 83 | { |
81 | 84 | throw new RestException(403, "Bad value for entity, must be the numeric ID of company."); |
82 | 85 | } |
83 | - if ($entity == '') $entity=1; |
|
86 | + if ($entity == '') { |
|
87 | + $entity=1; |
|
88 | + } |
|
84 | 89 | |
85 | 90 | include_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php'; |
86 | 91 | $login = checkLoginPassEntity($login, $password, $entity, $authmode); |
@@ -121,8 +126,7 @@ discard block |
||
121 | 126 | { |
122 | 127 | throw new RestException(500, 'Error when updating api_key for user :'.$this->db->lasterror()); |
123 | 128 | } |
124 | - } |
|
125 | - else |
|
129 | + } else |
|
126 | 130 | { |
127 | 131 | $token = $tmpuser->api_key; |
128 | 132 | } |
@@ -50,7 +50,9 @@ discard block |
||
50 | 50 | { |
51 | 51 | global $conf, $dolibarr_main_url_root; |
52 | 52 | |
53 | - if (empty($cachedir)) $cachedir = $conf->api->dir_temp; |
|
53 | + if (empty($cachedir)) { |
|
54 | + $cachedir = $conf->api->dir_temp; |
|
55 | + } |
|
54 | 56 | Defaults::$cacheDirectory = $cachedir; |
55 | 57 | |
56 | 58 | $this->db = $db; |
@@ -229,8 +231,7 @@ discard block |
||
229 | 231 | $featuresarray = array($resource); |
230 | 232 | if (preg_match('/&/', $resource)) { |
231 | 233 | $featuresarray = explode("&", $resource); |
232 | - } |
|
233 | - else if (preg_match('/\|/', $resource)) { |
|
234 | + } else if (preg_match('/\|/', $resource)) { |
|
234 | 235 | $featuresarray = explode("|", $resource); |
235 | 236 | } |
236 | 237 | |
@@ -258,8 +259,12 @@ discard block |
||
258 | 259 | $counter=0; |
259 | 260 | while ($i < $nb) |
260 | 261 | { |
261 | - if ($tmp[$i]=='(') $counter++; |
|
262 | - if ($tmp[$i]==')') $counter--; |
|
262 | + if ($tmp[$i]=='(') { |
|
263 | + $counter++; |
|
264 | + } |
|
265 | + if ($tmp[$i]==')') { |
|
266 | + $counter--; |
|
267 | + } |
|
263 | 268 | if ($counter < 0) |
264 | 269 | { |
265 | 270 | $error="Bad sqlfilters=".$sqlfilters; |
@@ -284,16 +289,19 @@ discard block |
||
284 | 289 | global $db; |
285 | 290 | |
286 | 291 | //dol_syslog("Convert matches ".$matches[1]); |
287 | - if (empty($matches[1])) return ''; |
|
292 | + if (empty($matches[1])) { |
|
293 | + return ''; |
|
294 | + } |
|
288 | 295 | $tmp=explode(':',$matches[1]); |
289 | - if (count($tmp) < 3) return ''; |
|
296 | + if (count($tmp) < 3) { |
|
297 | + return ''; |
|
298 | + } |
|
290 | 299 | |
291 | 300 | $tmpescaped=$tmp[2]; |
292 | 301 | if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) |
293 | 302 | { |
294 | 303 | $tmpescaped = "'".$db->escape($regbis[1])."'"; |
295 | - } |
|
296 | - else |
|
304 | + } else |
|
297 | 305 | { |
298 | 306 | $tmpescaped = $db->escape($tmpescaped); |
299 | 307 | } |