@@ -110,16 +110,18 @@ discard block |
||
| 110 | 110 | if ($id > 0 || !empty($ref)) {
|
| 111 | 111 | $result = $object->fetch($id, $ref); |
| 112 | 112 | |
| 113 | - if (!empty($conf->product->enabled)) |
|
| 114 | - $upload_dir = $conf->product->multidir_output[$object->entity] . '/' . get_exdir(0, 0, 0, 0, $object, 'product') . dol_sanitizeFileName($object->ref); |
|
| 115 | - elseif (!empty($conf->service->enabled)) |
|
| 116 | - $upload_dir = $conf->service->multidir_output[$object->entity] . '/' . get_exdir(0, 0, 0, 0, $object, 'product') . dol_sanitizeFileName($object->ref); |
|
| 113 | + if (!empty($conf->product->enabled)) { |
|
| 114 | + $upload_dir = $conf->product->multidir_output[$object->entity] . '/' . get_exdir(0, 0, 0, 0, $object, 'product') . dol_sanitizeFileName($object->ref); |
|
| 115 | + } elseif (!empty($conf->service->enabled)) { |
|
| 116 | + $upload_dir = $conf->service->multidir_output[$object->entity] . '/' . get_exdir(0, 0, 0, 0, $object, 'product') . dol_sanitizeFileName($object->ref); |
|
| 117 | + } |
|
| 117 | 118 | |
| 118 | 119 | if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { // For backward compatiblity, we scan also old dirs
|
| 119 | - if (!empty($conf->product->enabled)) |
|
| 120 | - $upload_dirold = $conf->product->multidir_output[$object->entity] . '/' . substr(substr("000" . $object->id, -2), 1, 1) . '/' . substr(substr("000" . $object->id, -2), 0, 1) . '/' . $object->id . "/photos";
|
|
| 121 | - else |
|
| 122 | - $upload_dirold = $conf->service->multidir_output[$object->entity] . '/' . substr(substr("000" . $object->id, -2), 1, 1) . '/' . substr(substr("000" . $object->id, -2), 0, 1) . '/' . $object->id . "/photos";
|
|
| 120 | + if (!empty($conf->product->enabled)) { |
|
| 121 | + $upload_dirold = $conf->product->multidir_output[$object->entity] . '/' . substr(substr("000" . $object->id, -2), 1, 1) . '/' . substr(substr("000" . $object->id, -2), 0, 1) . '/' . $object->id . "/photos"; |
|
| 122 | + } else { |
|
| 123 | + $upload_dirold = $conf->service->multidir_output[$object->entity] . '/' . substr(substr("000" . $object->id, -2), 1, 1) . '/' . substr(substr("000" . $object->id, -2), 0, 1) . '/' . $object->id . "/photos"; |
|
| 124 | + } |
|
| 123 | 125 | } |
| 124 | 126 | } |
| 125 | 127 | |
@@ -148,20 +150,23 @@ discard block |
||
| 148 | 150 | * Actions |
| 149 | 151 | */ |
| 150 | 152 | |
| 151 | -if ($cancel) |
|
| 152 | - $action = ''; |
|
| 153 | +if ($cancel) { |
|
| 154 | + $action = ''; |
|
| 155 | +} |
|
| 153 | 156 | |
| 154 | 157 | $usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire)); |
| 155 | 158 | $usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); |
| 156 | 159 | $usercandelete = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)); |
| 157 | 160 | $createbarcode = empty($conf->barcode->enabled) ? 0 : 1; |
| 158 | -if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->creer_advance)) |
|
| 159 | - $createbarcode = 0; |
|
| 161 | +if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->creer_advance)) { |
|
| 162 | + $createbarcode = 0; |
|
| 163 | +} |
|
| 160 | 164 | |
| 161 | 165 | $parameters = array('id' => $id, 'ref' => $ref, 'objcanvas' => $objcanvas);
|
| 162 | 166 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
| 163 | -if ($reshook < 0) |
|
| 164 | - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 167 | +if ($reshook < 0) { |
|
| 168 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 169 | +} |
|
| 165 | 170 | |
| 166 | 171 | if (empty($reshook)) {
|
| 167 | 172 | // Type |
@@ -195,14 +200,15 @@ discard block |
||
| 195 | 200 | exit; |
| 196 | 201 | } else {
|
| 197 | 202 | $langs->load("errors");
|
| 198 | - if ($result == -1) |
|
| 199 | - $errors[] = 'ErrorBadBarCodeSyntax'; |
|
| 200 | - else if ($result == -2) |
|
| 201 | - $errors[] = 'ErrorBarCodeRequired'; |
|
| 202 | - else if ($result == -3) |
|
| 203 | - $errors[] = 'ErrorBarCodeAlreadyUsed'; |
|
| 204 | - else |
|
| 205 | - $errors[] = 'FailedToValidateBarCode'; |
|
| 203 | + if ($result == -1) { |
|
| 204 | + $errors[] = 'ErrorBadBarCodeSyntax'; |
|
| 205 | + } else if ($result == -2) { |
|
| 206 | + $errors[] = 'ErrorBarCodeRequired'; |
|
| 207 | + } else if ($result == -3) { |
|
| 208 | + $errors[] = 'ErrorBarCodeAlreadyUsed'; |
|
| 209 | + } else { |
|
| 210 | + $errors[] = 'FailedToValidateBarCode'; |
|
| 211 | + } |
|
| 206 | 212 | |
| 207 | 213 | $error++; |
| 208 | 214 | setEventMessages($errors, null, 'errors'); |
@@ -236,14 +242,16 @@ discard block |
||
| 236 | 242 | $object->label = GETPOST('label');
|
| 237 | 243 | $object->price_base_type = GETPOST('price_base_type');
|
| 238 | 244 | |
| 239 | - if ($object->price_base_type == 'TTC') |
|
| 240 | - $object->price_ttc = GETPOST('price');
|
|
| 241 | - else |
|
| 242 | - $object->price = GETPOST('price');
|
|
| 243 | - if ($object->price_base_type == 'TTC') |
|
| 244 | - $object->price_min_ttc = GETPOST('price_min');
|
|
| 245 | - else |
|
| 246 | - $object->price_min = GETPOST('price_min');
|
|
| 245 | + if ($object->price_base_type == 'TTC') { |
|
| 246 | + $object->price_ttc = GETPOST('price'); |
|
| 247 | + } else { |
|
| 248 | + $object->price = GETPOST('price'); |
|
| 249 | + } |
|
| 250 | + if ($object->price_base_type == 'TTC') { |
|
| 251 | + $object->price_min_ttc = GETPOST('price_min'); |
|
| 252 | + } else { |
|
| 253 | + $object->price_min = GETPOST('price_min'); |
|
| 254 | + } |
|
| 247 | 255 | |
| 248 | 256 | $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)'
|
| 249 | 257 | // We must define tva_tx, npr and local taxes |
@@ -369,8 +377,9 @@ discard block |
||
| 369 | 377 | |
| 370 | 378 | // Fill array 'array_options' with data from add form |
| 371 | 379 | $ret = $extrafields->setOptionalsFromPost($extralabels, $object); |
| 372 | - if ($ret < 0) |
|
| 373 | - $error++; |
|
| 380 | + if ($ret < 0) { |
|
| 381 | + $error++; |
|
| 382 | + } |
|
| 374 | 383 | |
| 375 | 384 | if (!$error) {
|
| 376 | 385 | $id = $object->create($user); |
@@ -384,10 +393,11 @@ discard block |
||
| 384 | 393 | header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id);
|
| 385 | 394 | exit; |
| 386 | 395 | } else {
|
| 387 | - if (count($object->errors)) |
|
| 388 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
| 389 | - else |
|
| 390 | - setEventMessages($langs->trans($object->error), null, 'errors'); |
|
| 396 | + if (count($object->errors)) { |
|
| 397 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 398 | + } else { |
|
| 399 | + setEventMessages($langs->trans($object->error), null, 'errors'); |
|
| 400 | + } |
|
| 391 | 401 | $action = "create"; |
| 392 | 402 | } |
| 393 | 403 | } |
@@ -489,8 +499,9 @@ discard block |
||
| 489 | 499 | |
| 490 | 500 | // Fill array 'array_options' with data from add form |
| 491 | 501 | $ret = $extrafields->setOptionalsFromPost($extralabels, $object); |
| 492 | - if ($ret < 0) |
|
| 493 | - $error++; |
|
| 502 | + if ($ret < 0) { |
|
| 503 | + $error++; |
|
| 504 | + } |
|
| 494 | 505 | |
| 495 | 506 | if (!$error && $object->check()) {
|
| 496 | 507 | if ($object->update($object->id, $user) > 0) {
|
@@ -500,18 +511,19 @@ discard block |
||
| 500 | 511 | |
| 501 | 512 | $action = 'view'; |
| 502 | 513 | } else {
|
| 503 | - if (count($object->errors)) |
|
| 504 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
| 505 | - else |
|
| 506 | - setEventMessages($langs->trans($object->error), null, 'errors'); |
|
| 514 | + if (count($object->errors)) { |
|
| 515 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 516 | + } else { |
|
| 517 | + setEventMessages($langs->trans($object->error), null, 'errors'); |
|
| 518 | + } |
|
| 507 | 519 | $action = 'edit'; |
| 508 | 520 | } |
| 509 | - } |
|
| 510 | - else {
|
|
| 511 | - if (count($object->errors)) |
|
| 512 | - setEventMessages($object->error, $object->errors, 'errors'); |
|
| 513 | - else |
|
| 514 | - setEventMessages($langs->trans("ErrorProductBadRefOrLabel"), null, 'errors');
|
|
| 521 | + } else {
|
|
| 522 | + if (count($object->errors)) { |
|
| 523 | + setEventMessages($object->error, $object->errors, 'errors'); |
|
| 524 | + } else { |
|
| 525 | + setEventMessages($langs->trans("ErrorProductBadRefOrLabel"), null, 'errors'); |
|
| 526 | + } |
|
| 515 | 527 | $action = 'edit'; |
| 516 | 528 | } |
| 517 | 529 | } |
@@ -648,8 +660,9 @@ discard block |
||
| 648 | 660 | |
| 649 | 661 | $tva_tx = get_default_tva($mysoc, $soc, $object->id); |
| 650 | 662 | $tva_npr = get_default_npr($mysoc, $soc, $object->id); |
| 651 | - if (empty($tva_tx)) |
|
| 652 | - $tva_npr = 0; |
|
| 663 | + if (empty($tva_tx)) { |
|
| 664 | + $tva_npr = 0; |
|
| 665 | + } |
|
| 653 | 666 | $localtax1_tx = get_localtax($tva_tx, 1, $soc, $mysoc, $tva_npr); |
| 654 | 667 | $localtax2_tx = get_localtax($tva_tx, 2, $soc, $mysoc, $tva_npr); |
| 655 | 668 | |
@@ -783,8 +796,9 @@ discard block |
||
| 783 | 796 | $form = new Form($db); |
| 784 | 797 | $formfile = new FormFile($db); |
| 785 | 798 | $formproduct = new FormProduct($db); |
| 786 | -if (!empty($conf->accounting->enabled)) |
|
| 787 | - $formaccounting = new FormAccounting($db); |
|
| 799 | +if (!empty($conf->accounting->enabled)) { |
|
| 800 | + $formaccounting = new FormAccounting($db); |
|
| 801 | +} |
|
| 788 | 802 | |
| 789 | 803 | // Load object modBarCodeProduct |
| 790 | 804 | $res = 0; |
@@ -793,8 +807,9 @@ discard block |
||
| 793 | 807 | $dirbarcode = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']);
|
| 794 | 808 | foreach ($dirbarcode as $dirroot) {
|
| 795 | 809 | $res = dol_include_once($dirroot . $module . '.php'); |
| 796 | - if ($res) |
|
| 797 | - break; |
|
| 810 | + if ($res) { |
|
| 811 | + break; |
|
| 812 | + } |
|
| 798 | 813 | } |
| 799 | 814 | if ($res > 0) {
|
| 800 | 815 | $modBarCodeProduct = new $module(); |
@@ -809,13 +824,13 @@ discard block |
||
| 809 | 824 | if (empty($object->error) && $id) {
|
| 810 | 825 | $object = new Product($db); |
| 811 | 826 | $result = $object->fetch($id); |
| 812 | - if ($result <= 0) |
|
| 813 | - dol_print_error('', $object->error);
|
|
| 827 | + if ($result <= 0) { |
|
| 828 | + dol_print_error('', $object->error); |
|
| 829 | + } |
|
| 814 | 830 | } |
| 815 | 831 | $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates |
| 816 | 832 | $objcanvas->display_canvas($action); // Show template |
| 817 | -} |
|
| 818 | -else {
|
|
| 833 | +} else {
|
|
| 819 | 834 | // ----------------------------------------- |
| 820 | 835 | // When used in standard mode |
| 821 | 836 | // ----------------------------------------- |
@@ -865,8 +880,9 @@ discard block |
||
| 865 | 880 | |
| 866 | 881 | print '<tr>'; |
| 867 | 882 | $tmpcode = ''; |
| 868 | - if (!empty($modCodeProduct->code_auto)) |
|
| 869 | - $tmpcode = $modCodeProduct->getNextValue($object, $type); |
|
| 883 | + if (!empty($modCodeProduct->code_auto)) { |
|
| 884 | + $tmpcode = $modCodeProduct->getNextValue($object, $type); |
|
| 885 | + } |
|
| 870 | 886 | print '<td class="titlefieldcreate fieldrequired">' . $langs->trans("Ref") . '</td><td colspan="3"><input id="ref" name="ref" class="maxwidth200" maxlength="128" value="' . dol_escape_htmltag(GETPOST('ref') ? GETPOST('ref') : $tmpcode) . '">';
|
| 871 | 887 | if ($refalreadyexists) {
|
| 872 | 888 | print $langs->trans("RefAlreadyExists");
|
@@ -897,24 +913,27 @@ discard block |
||
| 897 | 913 | } |
| 898 | 914 | |
| 899 | 915 | $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; |
| 900 | - if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) |
|
| 901 | - $showbarcode = 0; |
|
| 916 | + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { |
|
| 917 | + $showbarcode = 0; |
|
| 918 | + } |
|
| 902 | 919 | |
| 903 | 920 | if ($showbarcode) {
|
| 904 | 921 | print '<tr><td>' . $langs->trans('BarcodeType') . '</td><td>';
|
| 905 | 922 | if (isset($_POST['fk_barcode_type'])) {
|
| 906 | 923 | $fk_barcode_type = GETPOST('fk_barcode_type');
|
| 907 | 924 | } else {
|
| 908 | - if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) |
|
| 909 | - $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
|
| 925 | + if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) { |
|
| 926 | + $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
|
| 927 | + } |
|
| 910 | 928 | } |
| 911 | 929 | require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbarcode.class.php'; |
| 912 | 930 | $formbarcode = new FormBarCode($db); |
| 913 | 931 | print $formbarcode->selectBarcodeType($fk_barcode_type, 'fk_barcode_type', 1); |
| 914 | 932 | print '</td><td>' . $langs->trans("BarcodeValue") . '</td><td>';
|
| 915 | 933 | $tmpcode = isset($_POST['barcode']) ? GETPOST('barcode') : $object->barcode;
|
| 916 | - if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) |
|
| 917 | - $tmpcode = $modBarCodeProduct->getNextValue($object, $type); |
|
| 934 | + if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) { |
|
| 935 | + $tmpcode = $modBarCodeProduct->getNextValue($object, $type); |
|
| 936 | + } |
|
| 918 | 937 | print '<input class="maxwidth100" type="text" name="barcode" value="' . dol_escape_htmltag($tmpcode) . '">'; |
| 919 | 938 | print '</td></tr>'; |
| 920 | 939 | } |
@@ -1016,8 +1035,9 @@ discard block |
||
| 1016 | 1035 | // Origin country |
| 1017 | 1036 | print '<td>' . $langs->trans("CountryOrigin") . '</td><td>';
|
| 1018 | 1037 | print $form->select_country(GETPOST('country_id', 'int'), 'country_id');
|
| 1019 | - if ($user->admin) |
|
| 1020 | - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
|
| 1038 | + if ($user->admin) { |
|
| 1039 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 1040 | + } |
|
| 1021 | 1041 | print '</td></tr>'; |
| 1022 | 1042 | } |
| 1023 | 1043 | |
@@ -1167,8 +1187,9 @@ discard block |
||
| 1167 | 1187 | require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; |
| 1168 | 1188 | |
| 1169 | 1189 | $type = $langs->trans('Product');
|
| 1170 | - if ($object->isService()) |
|
| 1171 | - $type = $langs->trans('Service');
|
|
| 1190 | + if ($object->isService()) { |
|
| 1191 | + $type = $langs->trans('Service'); |
|
| 1192 | + } |
|
| 1172 | 1193 | //print load_fiche_titre($langs->trans('Modify').' '.$type.' : '.(is_object($object->oldcopy)?$object->oldcopy->ref:$object->ref), "");
|
| 1173 | 1194 | // Main official, simple, and not duplicated code |
| 1174 | 1195 | // print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST">'."\n"; |
@@ -1229,8 +1250,9 @@ discard block |
||
| 1229 | 1250 | |
| 1230 | 1251 | // Barcode |
| 1231 | 1252 | $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; |
| 1232 | - if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) |
|
| 1233 | - $showbarcode = 0; |
|
| 1253 | + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { |
|
| 1254 | + $showbarcode = 0; |
|
| 1255 | + } |
|
| 1234 | 1256 | |
| 1235 | 1257 | if ($showbarcode) {
|
| 1236 | 1258 | print '<tr><td>' . $langs->trans('BarcodeType') . '</td><td>';
|
@@ -1238,16 +1260,18 @@ discard block |
||
| 1238 | 1260 | $fk_barcode_type = GETPOST('fk_barcode_type');
|
| 1239 | 1261 | } else {
|
| 1240 | 1262 | $fk_barcode_type = $object->barcode_type; |
| 1241 | - if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) |
|
| 1242 | - $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
|
| 1263 | + if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) { |
|
| 1264 | + $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; |
|
| 1265 | + } |
|
| 1243 | 1266 | } |
| 1244 | 1267 | require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbarcode.class.php'; |
| 1245 | 1268 | $formbarcode = new FormBarCode($db); |
| 1246 | 1269 | print $formbarcode->selectBarcodeType($fk_barcode_type, 'fk_barcode_type', 1); |
| 1247 | 1270 | print '</td><td>' . $langs->trans("BarcodeValue") . '</td><td>';
|
| 1248 | 1271 | $tmpcode = isset($_POST['barcode']) ? GETPOST('barcode') : $object->barcode;
|
| 1249 | - if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) |
|
| 1250 | - $tmpcode = $modBarCodeProduct->getNextValue($object, $type); |
|
| 1272 | + if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) { |
|
| 1273 | + $tmpcode = $modBarCodeProduct->getNextValue($object, $type); |
|
| 1274 | + } |
|
| 1251 | 1275 | print '<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="' . dol_escape_htmltag($tmpcode) . '">'; |
| 1252 | 1276 | print '</td></tr>'; |
| 1253 | 1277 | } |
@@ -1359,8 +1383,9 @@ discard block |
||
| 1359 | 1383 | // Origin country |
| 1360 | 1384 | print '<td>' . $langs->trans("CountryOrigin") . '</td><td>';
|
| 1361 | 1385 | print $form->select_country($object->country_id, 'country_id', '', 0, 'minwidth100 maxwidthonsmartphone'); |
| 1362 | - if ($user->admin) |
|
| 1363 | - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
|
| 1386 | + if ($user->admin) { |
|
| 1387 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 1388 | + } |
|
| 1364 | 1389 | print '</td></tr>'; |
| 1365 | 1390 | } |
| 1366 | 1391 | |
@@ -1470,8 +1495,9 @@ discard block |
||
| 1470 | 1495 | // Fiche en mode visu |
| 1471 | 1496 | else {
|
| 1472 | 1497 | $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; |
| 1473 | - if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) |
|
| 1474 | - $showbarcode = 0; |
|
| 1498 | + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { |
|
| 1499 | + $showbarcode = 0; |
|
| 1500 | + } |
|
| 1475 | 1501 | |
| 1476 | 1502 | $head = product_prepare_head($object); |
| 1477 | 1503 | $titre = $langs->trans("CardProduct" . $object->type);
|
@@ -1483,8 +1509,9 @@ discard block |
||
| 1483 | 1509 | $object->next_prev_filter = " fk_product_type = " . $object->type; |
| 1484 | 1510 | |
| 1485 | 1511 | $shownav = 1; |
| 1486 | - if ($user->societe_id && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL)))
|
|
| 1487 | - $shownav = 0; |
|
| 1512 | + if ($user->societe_id && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) { |
|
| 1513 | + $shownav = 0; |
|
| 1514 | + } |
|
| 1488 | 1515 | |
| 1489 | 1516 | dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); |
| 1490 | 1517 | |
@@ -1510,8 +1537,9 @@ discard block |
||
| 1510 | 1537 | print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
| 1511 | 1538 | print $langs->trans("BarcodeType");
|
| 1512 | 1539 | print '</td>'; |
| 1513 | - if (($action != 'editbarcodetype') && $usercancreate && $createbarcode) |
|
| 1514 | - print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editbarcodetype&id=' . $object->id . '">' . img_edit($langs->trans('Edit'), 1) . '</a></td>';
|
|
| 1540 | + if (($action != 'editbarcodetype') && $usercancreate && $createbarcode) { |
|
| 1541 | + print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editbarcodetype&id=' . $object->id . '">' . img_edit($langs->trans('Edit'), 1) . '</a></td>'; |
|
| 1542 | + } |
|
| 1515 | 1543 | print '</tr></table>'; |
| 1516 | 1544 | print '</td><td colspan="2">'; |
| 1517 | 1545 | if ($action == 'editbarcodetype' || $action == 'editbarcode') {
|
@@ -1531,14 +1559,16 @@ discard block |
||
| 1531 | 1559 | print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; |
| 1532 | 1560 | print $langs->trans("BarcodeValue");
|
| 1533 | 1561 | print '</td>'; |
| 1534 | - if (($action != 'editbarcode') && $usercancreate && $createbarcode) |
|
| 1535 | - print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editbarcode&id=' . $object->id . '">' . img_edit($langs->trans('Edit'), 1) . '</a></td>';
|
|
| 1562 | + if (($action != 'editbarcode') && $usercancreate && $createbarcode) { |
|
| 1563 | + print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editbarcode&id=' . $object->id . '">' . img_edit($langs->trans('Edit'), 1) . '</a></td>'; |
|
| 1564 | + } |
|
| 1536 | 1565 | print '</tr></table>'; |
| 1537 | 1566 | print '</td><td colspan="2">'; |
| 1538 | 1567 | if ($action == 'editbarcode') {
|
| 1539 | 1568 | $tmpcode = isset($_POST['barcode']) ? GETPOST('barcode') : $object->barcode;
|
| 1540 | - if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) |
|
| 1541 | - $tmpcode = $modBarCodeProduct->getNextValue($object, $type); |
|
| 1569 | + if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) { |
|
| 1570 | + $tmpcode = $modBarCodeProduct->getNextValue($object, $type); |
|
| 1571 | + } |
|
| 1542 | 1572 | |
| 1543 | 1573 | // print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">'; |
| 1544 | 1574 | print '<form method="POST" href="' . BASE_URI . '?controller=product&method=card&id=' . $object->id . '">'; |
@@ -1548,8 +1578,7 @@ discard block |
||
| 1548 | 1578 | print '<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="' . $tmpcode . '">'; |
| 1549 | 1579 | print ' <input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
|
| 1550 | 1580 | print '</form>'; |
| 1551 | - } |
|
| 1552 | - else {
|
|
| 1581 | + } else {
|
|
| 1553 | 1582 | print $object->barcode; |
| 1554 | 1583 | } |
| 1555 | 1584 | print '</td></tr>' . "\n"; |
@@ -1709,13 +1738,14 @@ discard block |
||
| 1709 | 1738 | print '<tr><td>' . $langs->trans("Length") . ' x ' . $langs->trans("Width") . ' x ' . $langs->trans("Height") . '</td><td colspan="2">';
|
| 1710 | 1739 | if ($object->length != '' || $object->width != '' || $object->height != '') {
|
| 1711 | 1740 | print $object->length; |
| 1712 | - if ($object->width) |
|
| 1713 | - print " x " . $object->width; |
|
| 1714 | - if ($object->height) |
|
| 1715 | - print " x " . $object->height; |
|
| 1741 | + if ($object->width) { |
|
| 1742 | + print " x " . $object->width; |
|
| 1743 | + } |
|
| 1744 | + if ($object->height) { |
|
| 1745 | + print " x " . $object->height; |
|
| 1746 | + } |
|
| 1716 | 1747 | print ' ' . measuring_units_string($object->length_units, "size"); |
| 1717 | - } |
|
| 1718 | - else {
|
|
| 1748 | + } else {
|
|
| 1719 | 1749 | print ' '; |
| 1720 | 1750 | } |
| 1721 | 1751 | print "</td></tr>\n"; |
@@ -1803,8 +1833,9 @@ discard block |
||
| 1803 | 1833 | } |
| 1804 | 1834 | |
| 1805 | 1835 | $tmpcode = ''; |
| 1806 | -if (!empty($modCodeProduct->code_auto)) |
|
| 1807 | - $tmpcode = $modCodeProduct->getNextValue($object, $object->type); |
|
| 1836 | +if (!empty($modCodeProduct->code_auto)) { |
|
| 1837 | + $tmpcode = $modCodeProduct->getNextValue($object, $object->type); |
|
| 1838 | +} |
|
| 1808 | 1839 | |
| 1809 | 1840 | // Define confirmation messages |
| 1810 | 1841 | $formquestionclone = array( |
@@ -1842,8 +1873,9 @@ discard block |
||
| 1842 | 1873 | $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
| 1843 | 1874 | if (empty($reshook)) {
|
| 1844 | 1875 | if ($usercancreate) {
|
| 1845 | - if (!isset($object->no_button_edit) || $object->no_button_edit <> 1) |
|
| 1846 | - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&id=' . $object->id . '">' . $langs->trans("Modify") . '</a></div>';
|
|
| 1876 | + if (!isset($object->no_button_edit) || $object->no_button_edit <> 1) { |
|
| 1877 | + print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&id=' . $object->id . '">' . $langs->trans("Modify") . '</a></div>'; |
|
| 1878 | + } |
|
| 1847 | 1879 | |
| 1848 | 1880 | if (!isset($object->no_button_copy) || $object->no_button_copy <> 1) {
|
| 1849 | 1881 | if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) {
|
@@ -4149,25 +4149,29 @@ discard block |
||
| 4149 | 4149 | |
| 4150 | 4150 | if (!empty($conf->commande->enabled)) {
|
| 4151 | 4151 | $result = $this->load_stats_commande(0, '1,2', 1); |
| 4152 | - if ($result < 0) |
|
| 4153 | - dol_print_error($this->db, $this->error); |
|
| 4152 | + if ($result < 0) { |
|
| 4153 | + dol_print_error($this->db, $this->error); |
|
| 4154 | + } |
|
| 4154 | 4155 | $stock_commande_client = $this->stats_commande['qty']; |
| 4155 | 4156 | } |
| 4156 | 4157 | if (!empty($conf->expedition->enabled)) {
|
| 4157 | 4158 | $result = $this->load_stats_sending(0, '1,2', 1); |
| 4158 | - if ($result < 0) |
|
| 4159 | - dol_print_error($this->db, $this->error); |
|
| 4159 | + if ($result < 0) { |
|
| 4160 | + dol_print_error($this->db, $this->error); |
|
| 4161 | + } |
|
| 4160 | 4162 | $stock_sending_client = $this->stats_expedition['qty']; |
| 4161 | 4163 | } |
| 4162 | 4164 | if (!empty($conf->fournisseur->enabled)) {
|
| 4163 | 4165 | $result = $this->load_stats_commande_fournisseur(0, '1,2,3,4', 1); |
| 4164 | - if ($result < 0) |
|
| 4165 | - dol_print_error($this->db, $this->error); |
|
| 4166 | + if ($result < 0) { |
|
| 4167 | + dol_print_error($this->db, $this->error); |
|
| 4168 | + } |
|
| 4166 | 4169 | $stock_commande_fournisseur = $this->stats_commande_fournisseur['qty']; |
| 4167 | 4170 | |
| 4168 | 4171 | $result = $this->load_stats_reception(0, '4', 1); |
| 4169 | - if ($result < 0) |
|
| 4170 | - dol_print_error($this->db, $this->error); |
|
| 4172 | + if ($result < 0) { |
|
| 4173 | + dol_print_error($this->db, $this->error); |
|
| 4174 | + } |
|
| 4171 | 4175 | $stock_reception_fournisseur = $this->stats_reception['qty']; |
| 4172 | 4176 | } |
| 4173 | 4177 | |
@@ -4203,8 +4207,9 @@ discard block |
||
| 4203 | 4207 | $parameters = array('id' => $this->id);
|
| 4204 | 4208 | // Note that $action and $object may have been modified by some hooks |
| 4205 | 4209 | $reshook = $hookmanager->executeHooks('loadvirtualstock', $parameters, $this, $action);
|
| 4206 | - if ($reshook > 0) |
|
| 4207 | - $this->stock_theorique = $hookmanager->resArray['stock_theorique']; |
|
| 4210 | + if ($reshook > 0) { |
|
| 4211 | + $this->stock_theorique = $hookmanager->resArray['stock_theorique']; |
|
| 4212 | + } |
|
| 4208 | 4213 | |
| 4209 | 4214 | return 1; |
| 4210 | 4215 | } |
@@ -340,34 +340,48 @@ discard block |
||
| 340 | 340 | $sql .= " AND pac.rowid IS NULL"; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | -if ($search_ref) |
|
| 344 | - $sql .= natural_search('p.ref', $search_ref);
|
|
| 345 | -if ($search_label) |
|
| 346 | - $sql .= natural_search('p.label', $search_label);
|
|
| 347 | -if ($search_barcode) |
|
| 348 | - $sql .= natural_search('p.barcode', $search_barcode);
|
|
| 349 | -if (isset($search_tosell) && dol_strlen($search_tosell) > 0 && $search_tosell != -1) |
|
| 350 | - $sql .= " AND p.tosell = " . $db->escape($search_tosell); |
|
| 351 | -if (isset($search_tobuy) && dol_strlen($search_tobuy) > 0 && $search_tobuy != -1) |
|
| 352 | - $sql .= " AND p.tobuy = " . $db->escape($search_tobuy); |
|
| 353 | -if (dol_strlen($canvas) > 0) |
|
| 354 | - $sql .= " AND p.canvas = '" . $db->escape($canvas) . "'"; |
|
| 355 | -if ($catid > 0) |
|
| 356 | - $sql .= " AND cp.fk_categorie = " . $catid; |
|
| 357 | -if ($catid == -2) |
|
| 358 | - $sql .= " AND cp.fk_categorie IS NULL"; |
|
| 359 | -if ($search_categ > 0) |
|
| 360 | - $sql .= " AND cp.fk_categorie = " . $db->escape($search_categ); |
|
| 361 | -if ($search_categ == -2) |
|
| 362 | - $sql .= " AND cp.fk_categorie IS NULL"; |
|
| 363 | -if ($fourn_id > 0) |
|
| 364 | - $sql .= " AND pfp.fk_soc = " . $fourn_id; |
|
| 365 | -if ($search_tobatch != '' && $search_tobatch >= 0) |
|
| 366 | - $sql .= " AND p.tobatch = " . $db->escape($search_tobatch); |
|
| 367 | -if ($search_accountancy_code_sell) |
|
| 368 | - $sql .= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell);
|
|
| 369 | -if ($search_accountancy_code_buy) |
|
| 370 | - $sql .= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy);
|
|
| 343 | +if ($search_ref) { |
|
| 344 | + $sql .= natural_search('p.ref', $search_ref); |
|
| 345 | +} |
|
| 346 | +if ($search_label) { |
|
| 347 | + $sql .= natural_search('p.label', $search_label); |
|
| 348 | +} |
|
| 349 | +if ($search_barcode) { |
|
| 350 | + $sql .= natural_search('p.barcode', $search_barcode); |
|
| 351 | +} |
|
| 352 | +if (isset($search_tosell) && dol_strlen($search_tosell) > 0 && $search_tosell != -1) { |
|
| 353 | + $sql .= " AND p.tosell = " . $db->escape($search_tosell); |
|
| 354 | +} |
|
| 355 | +if (isset($search_tobuy) && dol_strlen($search_tobuy) > 0 && $search_tobuy != -1) { |
|
| 356 | + $sql .= " AND p.tobuy = " . $db->escape($search_tobuy); |
|
| 357 | +} |
|
| 358 | +if (dol_strlen($canvas) > 0) { |
|
| 359 | + $sql .= " AND p.canvas = '" . $db->escape($canvas) . "'"; |
|
| 360 | +} |
|
| 361 | +if ($catid > 0) { |
|
| 362 | + $sql .= " AND cp.fk_categorie = " . $catid; |
|
| 363 | +} |
|
| 364 | +if ($catid == -2) { |
|
| 365 | + $sql .= " AND cp.fk_categorie IS NULL"; |
|
| 366 | +} |
|
| 367 | +if ($search_categ > 0) { |
|
| 368 | + $sql .= " AND cp.fk_categorie = " . $db->escape($search_categ); |
|
| 369 | +} |
|
| 370 | +if ($search_categ == -2) { |
|
| 371 | + $sql .= " AND cp.fk_categorie IS NULL"; |
|
| 372 | +} |
|
| 373 | +if ($fourn_id > 0) { |
|
| 374 | + $sql .= " AND pfp.fk_soc = " . $fourn_id; |
|
| 375 | +} |
|
| 376 | +if ($search_tobatch != '' && $search_tobatch >= 0) { |
|
| 377 | + $sql .= " AND p.tobatch = " . $db->escape($search_tobatch); |
|
| 378 | +} |
|
| 379 | +if ($search_accountancy_code_sell) { |
|
| 380 | + $sql .= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell); |
|
| 381 | +} |
|
| 382 | +if ($search_accountancy_code_buy) { |
|
| 383 | + $sql .= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); |
|
| 384 | +} |
|
| 371 | 385 | |
| 372 | 386 | // Add where from extra fields |
| 373 | 387 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php'; |
@@ -384,9 +398,10 @@ discard block |
||
| 384 | 398 | } |
| 385 | 399 | // Add fields from extrafields |
| 386 | 400 | if (!empty($extrafields->attributes[$object->table_element]['label'])) {
|
| 387 | - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) |
|
| 388 | - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef." . $key : ''); |
|
| 389 | -} |
|
| 401 | + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { |
|
| 402 | + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef." . $key : ''); |
|
| 403 | + } |
|
| 404 | + } |
|
| 390 | 405 | // Add fields from hooks |
| 391 | 406 | $parameters = array(); |
| 392 | 407 | $reshook = $hookmanager->executeHooks('printFieldSelect', $parameters); // Note that $action and $object may have been modified by hook
|
@@ -504,10 +519,12 @@ discard block |
||
| 504 | 519 | //'presend'=>$langs->trans("SendByMail"),
|
| 505 | 520 | //'builddoc'=>$langs->trans("PDFMerge"),
|
| 506 | 521 | ); |
| 507 | - if ($user->rights->produit->supprimer) |
|
| 508 | - $arrayofmassactions['predelete'] = $langs->trans("Delete");
|
|
| 509 | - if (in_array($massaction, array('presend', 'predelete')))
|
|
| 510 | - $arrayofmassactions = array(); |
|
| 522 | + if ($user->rights->produit->supprimer) { |
|
| 523 | + $arrayofmassactions['predelete'] = $langs->trans("Delete"); |
|
| 524 | + } |
|
| 525 | + if (in_array($massaction, array('presend', 'predelete'))) { |
|
| 526 | + $arrayofmassactions = array(); |
|
| 527 | + } |
|
| 511 | 528 | $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
| 512 | 529 | |
| 513 | 530 | $newcardbutton = ''; |
@@ -527,8 +544,9 @@ discard block |
||
| 527 | 544 | } |
| 528 | 545 | |
| 529 | 546 | print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formulaire">'; |
| 530 | - if ($optioncss != '') |
|
| 531 | - print '<input type="hidden" name="optioncss" value="' . $optioncss . '">'; |
|
| 547 | + if ($optioncss != '') { |
|
| 548 | + print '<input type="hidden" name="optioncss" value="' . $optioncss . '">'; |
|
| 549 | + } |
|
| 532 | 550 | print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; |
| 533 | 551 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; |
| 534 | 552 | print '<input type="hidden" name="action" value="list">'; |
@@ -536,8 +554,9 @@ discard block |
||
| 536 | 554 | print '<input type="hidden" name="sortorder" value="' . $sortorder . '">'; |
| 537 | 555 | print '<input type="hidden" name="page" value="' . $page . '">'; |
| 538 | 556 | print '<input type="hidden" name="type" value="' . $type . '">'; |
| 539 | - if (empty($arrayfields['p.fk_product_type']['checked'])) |
|
| 540 | - print '<input type="hidden" name="search_type" value="' . dol_escape_htmltag($search_type) . '">'; |
|
| 557 | + if (empty($arrayfields['p.fk_product_type']['checked'])) { |
|
| 558 | + print '<input type="hidden" name="search_type" value="' . dol_escape_htmltag($search_type) . '">'; |
|
| 559 | + } |
|
| 541 | 560 | |
| 542 | 561 | print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_products.png', 0, $newcardbutton, '', $limit); |
| 543 | 562 | |
@@ -556,8 +575,9 @@ discard block |
||
| 556 | 575 | } |
| 557 | 576 | |
| 558 | 577 | if ($sall) {
|
| 559 | - foreach ($fieldstosearchall as $key => $val) |
|
| 560 | - $fieldstosearchall[$key] = $langs->trans($val); |
|
| 578 | + foreach ($fieldstosearchall as $key => $val) { |
|
| 579 | + $fieldstosearchall[$key] = $langs->trans($val); |
|
| 580 | + } |
|
| 561 | 581 | print '<div class="divsearchfieldfilter">' . $langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall) . '</div>';
|
| 562 | 582 | } |
| 563 | 583 | |
@@ -580,10 +600,11 @@ discard block |
||
| 580 | 600 | |
| 581 | 601 | $parameters = array(); |
| 582 | 602 | $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
| 583 | - if (empty($reshook)) |
|
| 584 | - $moreforfilter .= $hookmanager->resPrint; |
|
| 585 | - else |
|
| 586 | - $moreforfilter = $hookmanager->resPrint; |
|
| 603 | + if (empty($reshook)) { |
|
| 604 | + $moreforfilter .= $hookmanager->resPrint; |
|
| 605 | + } else { |
|
| 606 | + $moreforfilter = $hookmanager->resPrint; |
|
| 607 | + } |
|
| 587 | 608 | |
| 588 | 609 | if ($moreforfilter) {
|
| 589 | 610 | print '<div class="liste_titre liste_titre_bydiv centpercent">'; |
@@ -593,8 +614,9 @@ discard block |
||
| 593 | 614 | |
| 594 | 615 | $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; |
| 595 | 616 | $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
| 596 | - if ($massactionbutton) |
|
| 597 | - $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
|
|
| 617 | + if ($massactionbutton) { |
|
| 618 | + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); |
|
| 619 | + } |
|
| 598 | 620 | |
| 599 | 621 | print '<div class="div-table-responsive">'; |
| 600 | 622 | print '<table class="tagtable liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n"; |
@@ -821,8 +843,9 @@ discard block |
||
| 821 | 843 | $result = $db->query($sql); |
| 822 | 844 | if ($result) {
|
| 823 | 845 | $objtp = $db->fetch_object($result); |
| 824 | - if (!empty($objtp->label)) |
|
| 825 | - $obj->label = $objtp->label; |
|
| 846 | + if (!empty($objtp->label)) { |
|
| 847 | + $obj->label = $objtp->label; |
|
| 848 | + } |
|
| 826 | 849 | } |
| 827 | 850 | } |
| 828 | 851 | |
@@ -855,36 +878,41 @@ discard block |
||
| 855 | 878 | print '<td class="tdoverflowmax200">'; |
| 856 | 879 | print $product_static->getNomUrl(1); |
| 857 | 880 | print "</td>\n"; |
| 858 | - if (!$i) |
|
| 859 | - $totalarray['nbfield'] ++; |
|
| 881 | + if (!$i) { |
|
| 882 | + $totalarray['nbfield'] ++; |
|
| 883 | + } |
|
| 860 | 884 | } |
| 861 | 885 | // Ref supplier |
| 862 | 886 | if (!empty($arrayfields['pfp.ref_fourn']['checked'])) {
|
| 863 | 887 | print '<td class="tdoverflowmax200">'; |
| 864 | 888 | print $product_static->getNomUrl(1); |
| 865 | 889 | print "</td>\n"; |
| 866 | - if (!$i) |
|
| 867 | - $totalarray['nbfield'] ++; |
|
| 890 | + if (!$i) { |
|
| 891 | + $totalarray['nbfield'] ++; |
|
| 892 | + } |
|
| 868 | 893 | } |
| 869 | 894 | // Label |
| 870 | 895 | if (!empty($arrayfields['p.label']['checked'])) {
|
| 871 | 896 | print '<td class="tdoverflowmax200">' . dol_trunc($obj->label, 40) . '</td>'; |
| 872 | - if (!$i) |
|
| 873 | - $totalarray['nbfield'] ++; |
|
| 897 | + if (!$i) { |
|
| 898 | + $totalarray['nbfield'] ++; |
|
| 899 | + } |
|
| 874 | 900 | } |
| 875 | 901 | |
| 876 | 902 | // Type |
| 877 | 903 | if (!empty($arrayfields['p.fk_product_type']['checked'])) {
|
| 878 | 904 | print '<td>' . $obj->fk_product_type . '</td>'; |
| 879 | - if (!$i) |
|
| 880 | - $totalarray['nbfield'] ++; |
|
| 905 | + if (!$i) { |
|
| 906 | + $totalarray['nbfield'] ++; |
|
| 907 | + } |
|
| 881 | 908 | } |
| 882 | 909 | |
| 883 | 910 | // Barcode |
| 884 | 911 | if (!empty($arrayfields['p.barcode']['checked'])) {
|
| 885 | 912 | print '<td>' . $obj->barcode . '</td>'; |
| 886 | - if (!$i) |
|
| 887 | - $totalarray['nbfield'] ++; |
|
| 913 | + if (!$i) { |
|
| 914 | + $totalarray['nbfield'] ++; |
|
| 915 | + } |
|
| 888 | 916 | } |
| 889 | 917 | |
| 890 | 918 | // Duration |
@@ -906,22 +934,25 @@ discard block |
||
| 906 | 934 | print $obj->duration; |
| 907 | 935 | } |
| 908 | 936 | print '</td>'; |
| 909 | - if (!$i) |
|
| 910 | - $totalarray['nbfield'] ++; |
|
| 937 | + if (!$i) { |
|
| 938 | + $totalarray['nbfield'] ++; |
|
| 939 | + } |
|
| 911 | 940 | } |
| 912 | 941 | |
| 913 | 942 | // Sell price |
| 914 | 943 | if (!empty($arrayfields['p.sellprice']['checked'])) {
|
| 915 | 944 | print '<td class="right nowraponall">'; |
| 916 | 945 | if ($obj->tosell) {
|
| 917 | - if ($obj->price_base_type == 'TTC') |
|
| 918 | - print price($obj->price_ttc) . ' ' . $langs->trans("TTC");
|
|
| 919 | - else |
|
| 920 | - print price($obj->price) . ' ' . $langs->trans("HT");
|
|
| 946 | + if ($obj->price_base_type == 'TTC') { |
|
| 947 | + print price($obj->price_ttc) . ' ' . $langs->trans("TTC"); |
|
| 948 | + } else { |
|
| 949 | + print price($obj->price) . ' ' . $langs->trans("HT"); |
|
| 950 | + } |
|
| 921 | 951 | } |
| 922 | 952 | print '</td>'; |
| 923 | - if (!$i) |
|
| 924 | - $totalarray['nbfield'] ++; |
|
| 953 | + if (!$i) { |
|
| 954 | + $totalarray['nbfield'] ++; |
|
| 955 | + } |
|
| 925 | 956 | } |
| 926 | 957 | |
| 927 | 958 | // Better buy price |
@@ -934,14 +965,16 @@ discard block |
||
| 934 | 965 | if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) {
|
| 935 | 966 | $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1); |
| 936 | 967 | print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent / 100) - $product_fourn->fourn_remise) . ' ' . $langs->trans("HT"), $htmltext);
|
| 937 | - } else |
|
| 938 | - print price($product_fourn->fourn_unitprice) . ' ' . $langs->trans("HT");
|
|
| 968 | + } else { |
|
| 969 | + print price($product_fourn->fourn_unitprice) . ' ' . $langs->trans("HT"); |
|
| 970 | + } |
|
| 939 | 971 | } |
| 940 | 972 | } |
| 941 | 973 | } |
| 942 | 974 | print '</td>'; |
| 943 | - if (!$i) |
|
| 944 | - $totalarray['nbfield'] ++; |
|
| 975 | + if (!$i) { |
|
| 976 | + $totalarray['nbfield'] ++; |
|
| 977 | + } |
|
| 945 | 978 | } |
| 946 | 979 | |
| 947 | 980 | // Number of buy prices |
@@ -970,8 +1003,9 @@ discard block |
||
| 970 | 1003 | print $obj->seuil_stock_alerte; |
| 971 | 1004 | } |
| 972 | 1005 | print '</td>'; |
| 973 | - if (!$i) |
|
| 974 | - $totalarray['nbfield'] ++; |
|
| 1006 | + if (!$i) { |
|
| 1007 | + $totalarray['nbfield'] ++; |
|
| 1008 | + } |
|
| 975 | 1009 | } |
| 976 | 1010 | // Desired stock |
| 977 | 1011 | if (!empty($arrayfields['p.desiredstock']['checked'])) {
|
@@ -980,52 +1014,60 @@ discard block |
||
| 980 | 1014 | print $obj->desiredstock; |
| 981 | 1015 | } |
| 982 | 1016 | print '</td>'; |
| 983 | - if (!$i) |
|
| 984 | - $totalarray['nbfield'] ++; |
|
| 1017 | + if (!$i) { |
|
| 1018 | + $totalarray['nbfield'] ++; |
|
| 1019 | + } |
|
| 985 | 1020 | } |
| 986 | 1021 | // Stock real |
| 987 | 1022 | if (!empty($arrayfields['p.stock']['checked'])) {
|
| 988 | 1023 | print '<td align="right">'; |
| 989 | 1024 | if ($obj->fk_product_type != 1) {
|
| 990 | - if ($obj->seuil_stock_alerte != '' && $product_static->stock_reel < (float) $obj->seuil_stock_alerte) |
|
| 991 | - print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)) . ' ';
|
|
| 1025 | + if ($obj->seuil_stock_alerte != '' && $product_static->stock_reel < (float) $obj->seuil_stock_alerte) { |
|
| 1026 | + print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)) . ' '; |
|
| 1027 | + } |
|
| 992 | 1028 | print $product_static->stock_reel; |
| 993 | 1029 | } |
| 994 | 1030 | print '</td>'; |
| 995 | - if (!$i) |
|
| 996 | - $totalarray['nbfield'] ++; |
|
| 1031 | + if (!$i) { |
|
| 1032 | + $totalarray['nbfield'] ++; |
|
| 1033 | + } |
|
| 997 | 1034 | } |
| 998 | 1035 | // Stock virtual |
| 999 | 1036 | if (!empty($arrayfields['stock_virtual']['checked'])) {
|
| 1000 | 1037 | print '<td align="right">'; |
| 1001 | 1038 | if ($obj->fk_product_type != 1) {
|
| 1002 | - if ($obj->seuil_stock_alerte != '' && $product_static->stock_theorique < (float) $obj->seuil_stock_alerte) |
|
| 1003 | - print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)) . ' ';
|
|
| 1039 | + if ($obj->seuil_stock_alerte != '' && $product_static->stock_theorique < (float) $obj->seuil_stock_alerte) { |
|
| 1040 | + print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)) . ' '; |
|
| 1041 | + } |
|
| 1004 | 1042 | print $product_static->stock_theorique; |
| 1005 | 1043 | } |
| 1006 | 1044 | print '</td>'; |
| 1007 | - if (!$i) |
|
| 1008 | - $totalarray['nbfield'] ++; |
|
| 1045 | + if (!$i) { |
|
| 1046 | + $totalarray['nbfield'] ++; |
|
| 1047 | + } |
|
| 1009 | 1048 | } |
| 1010 | 1049 | // Lot/Serial |
| 1011 | 1050 | if (!empty($arrayfields['p.tobatch']['checked'])) {
|
| 1012 | 1051 | print '<td align="center">'; |
| 1013 | 1052 | print yn($obj->tobatch); |
| 1014 | 1053 | print '</td>'; |
| 1015 | - if (!$i) |
|
| 1016 | - $totalarray['nbfield'] ++; |
|
| 1054 | + if (!$i) { |
|
| 1055 | + $totalarray['nbfield'] ++; |
|
| 1056 | + } |
|
| 1017 | 1057 | } |
| 1018 | 1058 | // Accountancy code sell |
| 1019 | 1059 | if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) {
|
| 1020 | 1060 | print '<td>' . $obj->accountancy_code_sell . '</td>'; |
| 1021 | - if (!$i) |
|
| 1022 | - $totalarray['nbfield'] ++; |
|
| 1061 | + if (!$i) { |
|
| 1062 | + $totalarray['nbfield'] ++; |
|
| 1063 | + } |
|
| 1023 | 1064 | } |
| 1024 | 1065 | // Accountancy code sell |
| 1025 | 1066 | if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) {
|
| 1026 | 1067 | print '<td>' . $obj->accountancy_code_buy . '</td>'; |
| 1027 | - if (!$i) |
|
| 1028 | - $totalarray['nbfield'] ++; |
|
| 1068 | + if (!$i) { |
|
| 1069 | + $totalarray['nbfield'] ++; |
|
| 1070 | + } |
|
| 1029 | 1071 | } |
| 1030 | 1072 | // Extra fields |
| 1031 | 1073 | include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php'; |
@@ -1038,16 +1080,18 @@ discard block |
||
| 1038 | 1080 | print '<td align="center">'; |
| 1039 | 1081 | print dol_print_date($obj->date_creation, 'dayhour', 'tzuser'); |
| 1040 | 1082 | print '</td>'; |
| 1041 | - if (!$i) |
|
| 1042 | - $totalarray['nbfield'] ++; |
|
| 1083 | + if (!$i) { |
|
| 1084 | + $totalarray['nbfield'] ++; |
|
| 1085 | + } |
|
| 1043 | 1086 | } |
| 1044 | 1087 | // Date modification |
| 1045 | 1088 | if (!empty($arrayfields['p.tms']['checked'])) {
|
| 1046 | 1089 | print '<td align="center">'; |
| 1047 | 1090 | print dol_print_date($obj->date_update, 'dayhour', 'tzuser'); |
| 1048 | 1091 | print '</td>'; |
| 1049 | - if (!$i) |
|
| 1050 | - $totalarray['nbfield'] ++; |
|
| 1092 | + if (!$i) { |
|
| 1093 | + $totalarray['nbfield'] ++; |
|
| 1094 | + } |
|
| 1051 | 1095 | } |
| 1052 | 1096 | |
| 1053 | 1097 | // Status (to sell) |
@@ -1059,8 +1103,9 @@ discard block |
||
| 1059 | 1103 | print $product_static->LibStatut($obj->tosell, 5, 0); |
| 1060 | 1104 | } |
| 1061 | 1105 | print '</td>'; |
| 1062 | - if (!$i) |
|
| 1063 | - $totalarray['nbfield'] ++; |
|
| 1106 | + if (!$i) { |
|
| 1107 | + $totalarray['nbfield'] ++; |
|
| 1108 | + } |
|
| 1064 | 1109 | } |
| 1065 | 1110 | // Status (to buy) |
| 1066 | 1111 | if (!empty($arrayfields['p.tobuy']['checked'])) {
|
@@ -1071,20 +1116,23 @@ discard block |
||
| 1071 | 1116 | print $product_static->LibStatut($obj->tobuy, 5, 1); |
| 1072 | 1117 | } |
| 1073 | 1118 | print '</td>'; |
| 1074 | - if (!$i) |
|
| 1075 | - $totalarray['nbfield'] ++; |
|
| 1119 | + if (!$i) { |
|
| 1120 | + $totalarray['nbfield'] ++; |
|
| 1121 | + } |
|
| 1076 | 1122 | } |
| 1077 | 1123 | // Action |
| 1078 | 1124 | print '<td class="nowrap" align="center">'; |
| 1079 | 1125 | if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
| 1080 | 1126 | $selected = 0; |
| 1081 | - if (in_array($obj->rowid, $arrayofselected)) |
|
| 1082 | - $selected = 1; |
|
| 1127 | + if (in_array($obj->rowid, $arrayofselected)) { |
|
| 1128 | + $selected = 1; |
|
| 1129 | + } |
|
| 1083 | 1130 | print '<input id="cb' . $obj->rowid . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj->rowid . '"' . ($selected ? ' checked="checked"' : '') . '>'; |
| 1084 | 1131 | } |
| 1085 | 1132 | print '</td>'; |
| 1086 | - if (!$i) |
|
| 1087 | - $totalarray['nbfield'] ++; |
|
| 1133 | + if (!$i) { |
|
| 1134 | + $totalarray['nbfield'] ++; |
|
| 1135 | + } |
|
| 1088 | 1136 | |
| 1089 | 1137 | print "</tr>\n"; |
| 1090 | 1138 | $i++; |
@@ -1095,8 +1143,7 @@ discard block |
||
| 1095 | 1143 | print "</table>"; |
| 1096 | 1144 | print "</div>"; |
| 1097 | 1145 | print '</form>'; |
| 1098 | -} |
|
| 1099 | -else {
|
|
| 1146 | +} else {
|
|
| 1100 | 1147 | dol_print_error($db); |
| 1101 | 1148 | } |
| 1102 | 1149 | |
@@ -74,8 +74,9 @@ discard block |
||
| 74 | 74 | if ($found) return $result; |
| 75 | 75 | } */ |
| 76 | 76 | |
| 77 | - if (isset($class::$member)) |
|
| 78 | - return $class::$member; |
|
| 77 | + if (isset($class::$member)) { |
|
| 78 | + return $class::$member; |
|
| 79 | + } |
|
| 79 | 80 | dol_print_error('', 'Try to get a static member "' . $member . '" in class "' . $class . '" that does not exists or is not static.');
|
| 80 | 81 | return null; |
| 81 | 82 | } |
@@ -126,8 +127,9 @@ discard block |
||
| 126 | 127 | } else {
|
| 127 | 128 | $out = ''; |
| 128 | 129 | $addzero = array('user', 'usergroup', 'c_email_templates', 'email_template', 'default_values');
|
| 129 | - if (in_array($element, $addzero)) |
|
| 130 | - $out .= '0,'; |
|
| 130 | + if (in_array($element, $addzero)) { |
|
| 131 | + $out .= '0,'; |
|
| 132 | + } |
|
| 131 | 133 | $out .= $conf->entity; |
| 132 | 134 | return $out; |
| 133 | 135 | } |
@@ -306,32 +308,35 @@ discard block |
||
| 306 | 308 | {
|
| 307 | 309 | global $mysoc, $user, $conf; |
| 308 | 310 | |
| 309 | - if (empty($paramname)) |
|
| 310 | - return 'BadFirstParameterForGETPOST'; |
|
| 311 | + if (empty($paramname)) { |
|
| 312 | + return 'BadFirstParameterForGETPOST'; |
|
| 313 | + } |
|
| 311 | 314 | if (empty($check)) {
|
| 312 | 315 | dol_syslog("Deprecated use of GETPOST, called with 1st param = " . $paramname . " and 2nd param is '', when calling page " . $_SERVER["PHP_SELF"], LOG_WARNING);
|
| 313 | 316 | // Enable this line to know who call the GETPOST with '' $check parameter. |
| 314 | 317 | //var_dump(debug_backtrace()[0]); |
| 315 | 318 | } |
| 316 | 319 | |
| 317 | - if (empty($method)) |
|
| 318 | - $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] : ''); |
|
| 319 | - elseif ($method == 1) |
|
| 320 | - $out = isset($_GET[$paramname]) ? $_GET[$paramname] : ''; |
|
| 321 | - elseif ($method == 2) |
|
| 322 | - $out = isset($_POST[$paramname]) ? $_POST[$paramname] : ''; |
|
| 323 | - elseif ($method == 3) |
|
| 324 | - $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : ''); |
|
| 325 | - elseif ($method == 4) |
|
| 326 | - $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_COOKIE[$paramname]) ? $_COOKIE[$paramname] : '')); |
|
| 327 | - else |
|
| 328 | - return 'BadThirdParameterForGETPOST'; |
|
| 320 | + if (empty($method)) { |
|
| 321 | + $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] : ''); |
|
| 322 | + } elseif ($method == 1) { |
|
| 323 | + $out = isset($_GET[$paramname]) ? $_GET[$paramname] : ''; |
|
| 324 | + } elseif ($method == 2) { |
|
| 325 | + $out = isset($_POST[$paramname]) ? $_POST[$paramname] : ''; |
|
| 326 | + } elseif ($method == 3) { |
|
| 327 | + $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : ''); |
|
| 328 | + } elseif ($method == 4) { |
|
| 329 | + $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_COOKIE[$paramname]) ? $_COOKIE[$paramname] : '')); |
|
| 330 | + } else { |
|
| 331 | + return 'BadThirdParameterForGETPOST'; |
|
| 332 | + } |
|
| 329 | 333 | |
| 330 | 334 | if (empty($method) || $method == 3 || $method == 4) {
|
| 331 | 335 | $relativepathstring = $_SERVER["PHP_SELF"]; |
| 332 | 336 | // Clean $relativepathstring |
| 333 | - if (constant('DOL_URL_ROOT'))
|
|
| 334 | - $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_URL_ROOT'), '/') . '/', '', $relativepathstring);
|
|
| 337 | + if (constant('DOL_URL_ROOT')) { |
|
| 338 | + $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_URL_ROOT'), '/') . '/', '', $relativepathstring); |
|
| 339 | + } |
|
| 335 | 340 | $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
|
| 336 | 341 | $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
|
| 337 | 342 | //var_dump($relativepathstring); |
@@ -380,14 +385,17 @@ discard block |
||
| 380 | 385 | $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
|
| 381 | 386 | $foundintru = 0; |
| 382 | 387 | foreach ($tmpqueryarraytohave as $tmpquerytohave) {
|
| 383 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
| 384 | - $foundintru = 1; |
|
| 388 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
| 389 | + $foundintru = 1; |
|
| 390 | + } |
|
| 385 | 391 | } |
| 386 | - if (!$foundintru) |
|
| 387 | - $qualified = 1; |
|
| 392 | + if (!$foundintru) { |
|
| 393 | + $qualified = 1; |
|
| 394 | + } |
|
| 388 | 395 | //var_dump($defkey.'-'.$qualified); |
| 389 | - } else |
|
| 390 | - $qualified = 1; |
|
| 396 | + } else { |
|
| 397 | + $qualified = 1; |
|
| 398 | + } |
|
| 391 | 399 | |
| 392 | 400 | if ($qualified) {
|
| 393 | 401 | //var_dump($user->default_values[$relativepathstring][$defkey]['createform']); |
@@ -414,20 +422,24 @@ discard block |
||
| 414 | 422 | $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
|
| 415 | 423 | $foundintru = 0; |
| 416 | 424 | foreach ($tmpqueryarraytohave as $tmpquerytohave) {
|
| 417 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
| 418 | - $foundintru = 1; |
|
| 425 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
| 426 | + $foundintru = 1; |
|
| 427 | + } |
|
| 419 | 428 | } |
| 420 | - if (!$foundintru) |
|
| 421 | - $qualified = 1; |
|
| 429 | + if (!$foundintru) { |
|
| 430 | + $qualified = 1; |
|
| 431 | + } |
|
| 422 | 432 | //var_dump($defkey.'-'.$qualified); |
| 423 | - } else |
|
| 424 | - $qualified = 1; |
|
| 433 | + } else { |
|
| 434 | + $qualified = 1; |
|
| 435 | + } |
|
| 425 | 436 | |
| 426 | 437 | if ($qualified) {
|
| 427 | 438 | $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and ,
|
| 428 | 439 | foreach ($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) {
|
| 429 | - if ($out) |
|
| 430 | - $out .= ', '; |
|
| 440 | + if ($out) { |
|
| 441 | + $out .= ', '; |
|
| 442 | + } |
|
| 431 | 443 | if ($paramname == 'sortfield') {
|
| 432 | 444 | $out .= dol_string_nospecial($key, '', $forbidden_chars_to_replace); |
| 433 | 445 | } |
@@ -447,14 +459,17 @@ discard block |
||
| 447 | 459 | $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
|
| 448 | 460 | $foundintru = 0; |
| 449 | 461 | foreach ($tmpqueryarraytohave as $tmpquerytohave) {
|
| 450 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
| 451 | - $foundintru = 1; |
|
| 462 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
| 463 | + $foundintru = 1; |
|
| 464 | + } |
|
| 452 | 465 | } |
| 453 | - if (!$foundintru) |
|
| 454 | - $qualified = 1; |
|
| 466 | + if (!$foundintru) { |
|
| 467 | + $qualified = 1; |
|
| 468 | + } |
|
| 455 | 469 | //var_dump($defkey.'-'.$qualified); |
| 456 | - } else |
|
| 457 | - $qualified = 1; |
|
| 470 | + } else { |
|
| 471 | + $qualified = 1; |
|
| 472 | + } |
|
| 458 | 473 | |
| 459 | 474 | if ($qualified) {
|
| 460 | 475 | if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all'])) {
|
@@ -526,8 +541,10 @@ discard block |
||
| 526 | 541 | $newout = $user->fk_user; |
| 527 | 542 | } elseif ($reg[1] == 'ENTITY_ID' || $reg[1] == 'ENTITYID') {
|
| 528 | 543 | $newout = $conf->entity; |
| 529 | - } else |
|
| 530 | - $newout = ''; // Key not found, we replace with empty string |
|
| 544 | + } else { |
|
| 545 | + $newout = ''; |
|
| 546 | + } |
|
| 547 | + // Key not found, we replace with empty string |
|
| 531 | 548 | |
| 532 | 549 | |
| 533 | 550 | |
@@ -556,18 +573,20 @@ discard block |
||
| 556 | 573 | } |
| 557 | 574 | break; |
| 558 | 575 | case 'intcomma': |
| 559 | - if (preg_match('/[^0-9,-]+/i', $out))
|
|
| 560 | - $out = ''; |
|
| 576 | + if (preg_match('/[^0-9,-]+/i', $out)) { |
|
| 577 | + $out = ''; |
|
| 578 | + } |
|
| 561 | 579 | break; |
| 562 | 580 | case 'alpha': |
| 563 | 581 | if (!is_array($out)) {
|
| 564 | 582 | $out = trim($out); |
| 565 | 583 | // '"' is dangerous because param in url can close the href= or src= and add javascript functions. |
| 566 | 584 | // '../' is dangerous because it allows dir transversals |
| 567 | - if (preg_match('/"/', $out))
|
|
| 568 | - $out = ''; |
|
| 569 | - else if (preg_match('/\.\.\//', $out))
|
|
| 570 | - $out = ''; |
|
| 585 | + if (preg_match('/"/', $out)) { |
|
| 586 | + $out = ''; |
|
| 587 | + } else if (preg_match('/\.\.\//', $out)) { |
|
| 588 | + $out = ''; |
|
| 589 | + } |
|
| 571 | 590 | } |
| 572 | 591 | break; |
| 573 | 592 | case 'san_alpha': |
@@ -576,27 +595,31 @@ discard block |
||
| 576 | 595 | case 'aZ': |
| 577 | 596 | if (!is_array($out)) {
|
| 578 | 597 | $out = trim($out); |
| 579 | - if (preg_match('/[^a-z]+/i', $out))
|
|
| 580 | - $out = ''; |
|
| 598 | + if (preg_match('/[^a-z]+/i', $out)) { |
|
| 599 | + $out = ''; |
|
| 600 | + } |
|
| 581 | 601 | } |
| 582 | 602 | break; |
| 583 | 603 | case 'aZ09': |
| 584 | 604 | if (!is_array($out)) {
|
| 585 | 605 | $out = trim($out); |
| 586 | - if (preg_match('/[^a-z0-9_\-\.]+/i', $out))
|
|
| 587 | - $out = ''; |
|
| 606 | + if (preg_match('/[^a-z0-9_\-\.]+/i', $out)) { |
|
| 607 | + $out = ''; |
|
| 608 | + } |
|
| 588 | 609 | } |
| 589 | 610 | break; |
| 590 | 611 | case 'aZ09comma': // great to sanitize sortfield or sortorder params that can be t.abc,t.def_gh |
| 591 | 612 | if (!is_array($out)) {
|
| 592 | 613 | $out = trim($out); |
| 593 | - if (preg_match('/[^a-z0-9_\-\.,]+/i', $out))
|
|
| 594 | - $out = ''; |
|
| 614 | + if (preg_match('/[^a-z0-9_\-\.,]+/i', $out)) { |
|
| 615 | + $out = ''; |
|
| 616 | + } |
|
| 595 | 617 | } |
| 596 | 618 | break; |
| 597 | 619 | case 'array': |
| 598 | - if (!is_array($out) || empty($out)) |
|
| 599 | - $out = array(); |
|
| 620 | + if (!is_array($out) || empty($out)) { |
|
| 621 | + $out = array(); |
|
| 622 | + } |
|
| 600 | 623 | break; |
| 601 | 624 | case 'nohtml': // Recommended for most scalar parameters |
| 602 | 625 | $out = dol_string_nohtmltag($out, 0); |
@@ -606,16 +629,18 @@ discard block |
||
| 606 | 629 | $out = trim($out); |
| 607 | 630 | // '"' is dangerous because param in url can close the href= or src= and add javascript functions. |
| 608 | 631 | // '../' is dangerous because it allows dir transversals |
| 609 | - if (preg_match('/"/', $out))
|
|
| 610 | - $out = ''; |
|
| 611 | - else if (preg_match('/\.\.\//', $out))
|
|
| 612 | - $out = ''; |
|
| 632 | + if (preg_match('/"/', $out)) { |
|
| 633 | + $out = ''; |
|
| 634 | + } else if (preg_match('/\.\.\//', $out)) { |
|
| 635 | + $out = ''; |
|
| 636 | + } |
|
| 613 | 637 | $out = dol_string_nohtmltag($out); |
| 614 | 638 | } |
| 615 | 639 | break; |
| 616 | 640 | case 'custom': |
| 617 | - if (empty($filter)) |
|
| 618 | - return 'BadFourthParameterForGETPOST'; |
|
| 641 | + if (empty($filter)) { |
|
| 642 | + return 'BadFourthParameterForGETPOST'; |
|
| 643 | + } |
|
| 619 | 644 | $out = filter_var($out, $filter, $options); |
| 620 | 645 | break; |
| 621 | 646 | } |
@@ -655,10 +680,11 @@ discard block |
||
| 655 | 680 | // If prefix is for email |
| 656 | 681 | if ($mode == 'email') {
|
| 657 | 682 | if (!empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) { // If MAIL_PREFIX_FOR_EMAIL_ID is set (a value initialized with a random value is recommended)
|
| 658 | - if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') |
|
| 659 | - return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID; |
|
| 660 | - else if (isset($_SERVER["SERVER_NAME"])) |
|
| 661 | - return $_SERVER["SERVER_NAME"]; |
|
| 683 | + if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') { |
|
| 684 | + return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID; |
|
| 685 | + } else if (isset($_SERVER["SERVER_NAME"])) { |
|
| 686 | + return $_SERVER["SERVER_NAME"]; |
|
| 687 | + } |
|
| 662 | 688 | } |
| 663 | 689 | return dol_hash(DOL_DOCUMENT_ROOT . DOL_URL_ROOT); |
| 664 | 690 | } |
@@ -729,22 +755,27 @@ discard block |
||
| 729 | 755 | } |
| 730 | 756 | } |
| 731 | 757 | if ($returnemptyifnotfound) { // Not found into alternate dir
|
| 732 | - if ($returnemptyifnotfound == 1 || !file_exists($res)) |
|
| 733 | - return ''; |
|
| 758 | + if ($returnemptyifnotfound == 1 || !file_exists($res)) { |
|
| 759 | + return ''; |
|
| 760 | + } |
|
| 734 | 761 | } |
| 735 | - } |
|
| 736 | - else { // For an url path
|
|
| 762 | + } else { // For an url path
|
|
| 737 | 763 | // We try to get local path of file on filesystem from url |
| 738 | 764 | // Note that trying to know if a file on disk exist by forging path on disk from url |
| 739 | 765 | // works only for some web server and some setup. This is bugged when |
| 740 | 766 | // using proxy, rewriting, virtual path, etc... |
| 741 | 767 | $res = ''; |
| 742 | - if ($type == 1) |
|
| 743 | - $res = /* DOL_URL_ROOT */ DOL_BASE_URI . '/' . $path; // Standard value |
|
| 744 | - if ($type == 2) |
|
| 745 | - $res = /* DOL_MAIN_URL_ROOT */ DOL_BASE_PATH . '/' . $path; // Standard value |
|
| 746 | - if ($type == 3) |
|
| 747 | - $res = DOL_URL_ROOT . '/' . $path; |
|
| 768 | + if ($type == 1) { |
|
| 769 | + $res = /* DOL_URL_ROOT */ DOL_BASE_URI . '/' . $path; |
|
| 770 | + } |
|
| 771 | + // Standard value |
|
| 772 | + if ($type == 2) { |
|
| 773 | + $res = /* DOL_MAIN_URL_ROOT */ DOL_BASE_PATH . '/' . $path; |
|
| 774 | + } |
|
| 775 | + // Standard value |
|
| 776 | + if ($type == 3) { |
|
| 777 | + $res = DOL_URL_ROOT . '/' . $path; |
|
| 778 | + } |
|
| 748 | 779 | |
| 749 | 780 | foreach ($conf->file->dol_document_root as $key => $dirroot) { // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...)
|
| 750 | 781 | if ($key == 'main') {
|
@@ -824,13 +855,15 @@ discard block |
||
| 824 | 855 | function dol_size($size, $type = '') |
| 825 | 856 | {
|
| 826 | 857 | global $conf; |
| 827 | - if (empty($conf->dol_optimize_smallscreen)) |
|
| 828 | - return $size; |
|
| 829 | - if ($type == 'width' && $size > 250) |
|
| 830 | - return 250; |
|
| 831 | - else |
|
| 832 | - return 10; |
|
| 833 | -} |
|
| 858 | + if (empty($conf->dol_optimize_smallscreen)) { |
|
| 859 | + return $size; |
|
| 860 | + } |
|
| 861 | + if ($type == 'width' && $size > 250) { |
|
| 862 | + return 250; |
|
| 863 | + } else { |
|
| 864 | + return 10; |
|
| 865 | + } |
|
| 866 | + } |
|
| 834 | 867 | |
| 835 | 868 | /** |
| 836 | 869 | * Clean a string to use it as a file name |
@@ -929,8 +962,9 @@ discard block |
||
| 929 | 962 | {
|
| 930 | 963 | $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ",", ";", "=", '°'); // more complete than dol_sanitizeFileName
|
| 931 | 964 | $forbidden_chars_to_remove = array(); |
| 932 | - if (is_array($badcharstoreplace)) |
|
| 933 | - $forbidden_chars_to_replace = $badcharstoreplace; |
|
| 965 | + if (is_array($badcharstoreplace)) { |
|
| 966 | + $forbidden_chars_to_replace = $badcharstoreplace; |
|
| 967 | + } |
|
| 934 | 968 | //$forbidden_chars_to_remove=array("(",")");
|
| 935 | 969 | |
| 936 | 970 | return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove, "", $str)); |
@@ -967,9 +1001,9 @@ discard block |
||
| 967 | 1001 | if (empty($mode)) {
|
| 968 | 1002 | $substitjs["'"] = "\\'"; |
| 969 | 1003 | $substitjs['"'] = "\\'"; |
| 970 | - } else if ($mode == 1) |
|
| 971 | - $substitjs["'"] = "\\'"; |
|
| 972 | - else if ($mode == 2) {
|
|
| 1004 | + } else if ($mode == 1) { |
|
| 1005 | + $substitjs["'"] = "\\'"; |
|
| 1006 | + } else if ($mode == 2) {
|
|
| 973 | 1007 | $substitjs['"'] = '\\"'; |
| 974 | 1008 | } else if ($mode == 3) {
|
| 975 | 1009 | $substitjs["'"] = "\\'"; |
@@ -991,10 +1025,12 @@ discard block |
||
| 991 | 1025 | {
|
| 992 | 1026 | // escape quotes and backslashes, newlines, etc. |
| 993 | 1027 | $tmp = html_entity_decode($stringtoescape, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars_decode instead, that make only required change for html tags |
| 994 | - if (!$keepb) |
|
| 995 | - $tmp = strtr($tmp, array("<b>" => '', '</b>' => ''));
|
|
| 996 | - if (!$keepn) |
|
| 997 | - $tmp = strtr($tmp, array("\r" => '\\r', "\n" => '\\n'));
|
|
| 1028 | + if (!$keepb) { |
|
| 1029 | + $tmp = strtr($tmp, array("<b>" => '', '</b>' => '')); |
|
| 1030 | + } |
|
| 1031 | + if (!$keepn) { |
|
| 1032 | + $tmp = strtr($tmp, array("\r" => '\\r', "\n" => '\\n')); |
|
| 1033 | + } |
|
| 998 | 1034 | return htmlentities($tmp, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars instead, that make only required change for html tags |
| 999 | 1035 | } |
| 1000 | 1036 | |
@@ -1045,8 +1081,9 @@ discard block |
||
| 1045 | 1081 | global $conf, $user; |
| 1046 | 1082 | |
| 1047 | 1083 | // If syslog module enabled |
| 1048 | - if (empty($conf->syslog->enabled)) |
|
| 1049 | - return; |
|
| 1084 | + if (empty($conf->syslog->enabled)) { |
|
| 1085 | + return; |
|
| 1086 | + } |
|
| 1050 | 1087 | |
| 1051 | 1088 | if ($ident < 0) {
|
| 1052 | 1089 | foreach ($conf->loghandlers as $loghandlerinstance) {
|
@@ -1060,8 +1097,9 @@ discard block |
||
| 1060 | 1097 | if (!in_array($level, $logLevels, true)) {
|
| 1061 | 1098 | throw new Exception('Incorrect log level');
|
| 1062 | 1099 | } |
| 1063 | - if ($level > $conf->global->SYSLOG_LEVEL) |
|
| 1064 | - return; |
|
| 1100 | + if ($level > $conf->global->SYSLOG_LEVEL) { |
|
| 1101 | + return; |
|
| 1102 | + } |
|
| 1065 | 1103 | |
| 1066 | 1104 | $message = preg_replace('/password=\'[^\']*\'/', 'password=\'hidden\'', $message); // protection to avoid to have value of password in log
|
| 1067 | 1105 | // If adding log inside HTML page is required |
@@ -1086,24 +1124,30 @@ discard block |
||
| 1086 | 1124 | ); |
| 1087 | 1125 | |
| 1088 | 1126 | // This is when server run behind a reverse proxy |
| 1089 | - if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) |
|
| 1090 | - $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'] . (empty($_SERVER["REMOTE_ADDR"]) ? '' : '->' . $_SERVER['REMOTE_ADDR']); |
|
| 1127 | + if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 1128 | + $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'] . (empty($_SERVER["REMOTE_ADDR"]) ? '' : '->' . $_SERVER['REMOTE_ADDR']); |
|
| 1129 | + } |
|
| 1091 | 1130 | // This is when server run normally on a server |
| 1092 | - else if (!empty($_SERVER["REMOTE_ADDR"])) |
|
| 1093 | - $data['ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 1131 | + else if (!empty($_SERVER["REMOTE_ADDR"])) { |
|
| 1132 | + $data['ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 1133 | + } |
|
| 1094 | 1134 | // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache) |
| 1095 | - else if (!empty($_SERVER['SERVER_ADDR'])) |
|
| 1096 | - $data['ip'] = $_SERVER['SERVER_ADDR']; |
|
| 1135 | + else if (!empty($_SERVER['SERVER_ADDR'])) { |
|
| 1136 | + $data['ip'] = $_SERVER['SERVER_ADDR']; |
|
| 1137 | + } |
|
| 1097 | 1138 | // This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but useful if OS defined it). |
| 1098 | - else if (!empty($_SERVER['COMPUTERNAME'])) |
|
| 1099 | - $data['ip'] = $_SERVER['COMPUTERNAME'] . (empty($_SERVER['USERNAME']) ? '' : '@' . $_SERVER['USERNAME']); |
|
| 1139 | + else if (!empty($_SERVER['COMPUTERNAME'])) { |
|
| 1140 | + $data['ip'] = $_SERVER['COMPUTERNAME'] . (empty($_SERVER['USERNAME']) ? '' : '@' . $_SERVER['USERNAME']); |
|
| 1141 | + } |
|
| 1100 | 1142 | // This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it). |
| 1101 | - else if (!empty($_SERVER['LOGNAME'])) |
|
| 1102 | - $data['ip'] = '???@' . $_SERVER['LOGNAME']; |
|
| 1143 | + else if (!empty($_SERVER['LOGNAME'])) { |
|
| 1144 | + $data['ip'] = '???@' . $_SERVER['LOGNAME']; |
|
| 1145 | + } |
|
| 1103 | 1146 | // Loop on each log handler and send output |
| 1104 | 1147 | foreach ($conf->loghandlers as $loghandlerinstance) {
|
| 1105 | - if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) |
|
| 1106 | - continue; |
|
| 1148 | + if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) { |
|
| 1149 | + continue; |
|
| 1150 | + } |
|
| 1107 | 1151 | $loghandlerinstance->export($data, $suffixinfilename); |
| 1108 | 1152 | } |
| 1109 | 1153 | unset($data); |
@@ -1159,13 +1203,15 @@ discard block |
||
| 1159 | 1203 | |
| 1160 | 1204 | // Show title |
| 1161 | 1205 | $showtitle = 1; |
| 1162 | - if (!empty($conf->dol_optimize_smallscreen)) |
|
| 1163 | - $showtitle = 0; |
|
| 1206 | + if (!empty($conf->dol_optimize_smallscreen)) { |
|
| 1207 | + $showtitle = 0; |
|
| 1208 | + } |
|
| 1164 | 1209 | if (!empty($title) && $showtitle) {
|
| 1165 | 1210 | $limittitle = 30; |
| 1166 | 1211 | $out .= '<a class="tabTitle">'; |
| 1167 | - if ($picto) |
|
| 1168 | - $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_') . $picto, '', $pictoisfullpath) . ' '; |
|
| 1212 | + if ($picto) { |
|
| 1213 | + $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_') . $picto, '', $pictoisfullpath) . ' '; |
|
| 1214 | + } |
|
| 1169 | 1215 | $out .= '<span class="tabTitleText">' . dol_trunc($title, $limittitle) . '</span>'; |
| 1170 | 1216 | $out .= '</a>'; |
| 1171 | 1217 | } |
@@ -1174,12 +1220,14 @@ discard block |
||
| 1174 | 1220 | $maxkey = -1; |
| 1175 | 1221 | if (is_array($links) && !empty($links)) {
|
| 1176 | 1222 | $keys = array_keys($links); |
| 1177 | - if (count($keys)) |
|
| 1178 | - $maxkey = max($keys); |
|
| 1223 | + if (count($keys)) { |
|
| 1224 | + $maxkey = max($keys); |
|
| 1225 | + } |
|
| 1179 | 1226 | } |
| 1180 | 1227 | |
| 1181 | - if (!empty($conf->dol_optimize_smallscreen)) |
|
| 1182 | - $conf->global->MAIN_MAXTABS_IN_CARD = 2; |
|
| 1228 | + if (!empty($conf->dol_optimize_smallscreen)) { |
|
| 1229 | + $conf->global->MAIN_MAXTABS_IN_CARD = 2; |
|
| 1230 | + } |
|
| 1183 | 1231 | |
| 1184 | 1232 | // Show tabs |
| 1185 | 1233 | $bactive = false; |
@@ -1192,8 +1240,9 @@ discard block |
||
| 1192 | 1240 | for ($i = 0; $i <= $maxkey; $i++) {
|
| 1193 | 1241 | if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
|
| 1194 | 1242 | // If active tab is already present |
| 1195 | - if ($i >= $limittoshow) |
|
| 1196 | - $limittoshow--; |
|
| 1243 | + if ($i >= $limittoshow) { |
|
| 1244 | + $limittoshow--; |
|
| 1245 | + } |
|
| 1197 | 1246 | } |
| 1198 | 1247 | } |
| 1199 | 1248 | |
@@ -1234,12 +1283,12 @@ discard block |
||
| 1234 | 1283 | } |
| 1235 | 1284 | $outmore .= '<div class="popuptab wordwrap" style="display:inherit;">'; |
| 1236 | 1285 | if (isset($links[$i][2]) && $links[$i][2] == 'image') {
|
| 1237 | - if (!empty($links[$i][0])) |
|
| 1238 | - $outmore .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n"; |
|
| 1239 | - else |
|
| 1240 | - $outmore .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n"; |
|
| 1241 | - } |
|
| 1242 | - else if (!empty($links[$i][1])) {
|
|
| 1286 | + if (!empty($links[$i][0])) { |
|
| 1287 | + $outmore .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n"; |
|
| 1288 | + } else { |
|
| 1289 | + $outmore .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n"; |
|
| 1290 | + } |
|
| 1291 | + } else if (!empty($links[$i][1])) {
|
|
| 1243 | 1292 | $outmore .= '<a' . (!empty($links[$i][2]) ? ' id="' . $links[$i][2] . '"' : '') . ' class="wordwrap inline-block' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">'; |
| 1244 | 1293 | $outmore .= preg_replace('/([a-z])\/([a-z])/i', '\\1 / \\2', $links[$i][1]); // Replace x/y with x / y to allow wrap on long composed texts.
|
| 1245 | 1294 | $outmore .= '</a>' . "\n"; |
@@ -1250,8 +1299,9 @@ discard block |
||
| 1250 | 1299 | } |
| 1251 | 1300 | $displaytab = $i; |
| 1252 | 1301 | } |
| 1253 | - if ($popuptab) |
|
| 1254 | - $outmore .= '</div>'; |
|
| 1302 | + if ($popuptab) { |
|
| 1303 | + $outmore .= '</div>'; |
|
| 1304 | + } |
|
| 1255 | 1305 | |
| 1256 | 1306 | if ($displaytab > $limittoshow) {
|
| 1257 | 1307 | $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
|
@@ -1274,8 +1324,9 @@ discard block |
||
| 1274 | 1324 | |
| 1275 | 1325 | $out .= "</div>\n"; |
| 1276 | 1326 | |
| 1277 | - if (!$notab || $notab == -1) |
|
| 1278 | - $out .= "\n" . '<div class="tabBar' . ($notab == -1 ? '' : ' tabBarWithBottom') . '">' . "\n"; |
|
| 1327 | + if (!$notab || $notab == -1) { |
|
| 1328 | + $out .= "\n" . '<div class="tabBar' . ($notab == -1 ? '' : ' tabBarWithBottom') . '">' . "\n"; |
|
| 1329 | + } |
|
| 1279 | 1330 | |
| 1280 | 1331 | $parameters = array('tabname' => $active, 'out' => $out);
|
| 1281 | 1332 | $reshook = $hookmanager->executeHooks('printTabsHead', $parameters); // This hook usage is called just before output the head of tabs. Take also a look at "completeTabsHead"
|
@@ -1305,11 +1356,12 @@ discard block |
||
| 1305 | 1356 | */ |
| 1306 | 1357 | function dol_get_fiche_end($notab = 0) |
| 1307 | 1358 | {
|
| 1308 | - if (!$notab || $notab == -1) |
|
| 1309 | - return "\n</div>\n"; |
|
| 1310 | - else |
|
| 1311 | - return ''; |
|
| 1312 | -} |
|
| 1359 | + if (!$notab || $notab == -1) { |
|
| 1360 | + return "\n</div>\n"; |
|
| 1361 | + } else { |
|
| 1362 | + return ''; |
|
| 1363 | + } |
|
| 1364 | + } |
|
| 1313 | 1365 | |
| 1314 | 1366 | /** |
| 1315 | 1367 | * Show tab footer of a card. |
@@ -1340,40 +1392,55 @@ discard block |
||
| 1340 | 1392 | $showimage = 1; |
| 1341 | 1393 | $entity = (empty($object->entity) ? $conf->entity : $object->entity); |
| 1342 | 1394 | $showbarcode = empty($conf->barcode->enabled) ? 0 : ($object->barcode ? 1 : 0); |
| 1343 | - if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) |
|
| 1344 | - $showbarcode = 0; |
|
| 1395 | + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { |
|
| 1396 | + $showbarcode = 0; |
|
| 1397 | + } |
|
| 1345 | 1398 | $modulepart = 'unknown'; |
| 1346 | 1399 | |
| 1347 | - if ($object->element == 'societe') |
|
| 1348 | - $modulepart = 'societe'; |
|
| 1349 | - if ($object->element == 'contact') |
|
| 1350 | - $modulepart = 'contact'; |
|
| 1351 | - if ($object->element == 'member') |
|
| 1352 | - $modulepart = 'memberphoto'; |
|
| 1353 | - if ($object->element == 'user') |
|
| 1354 | - $modulepart = 'userphoto'; |
|
| 1355 | - if ($object->element == 'product') |
|
| 1356 | - $modulepart = 'product'; |
|
| 1400 | + if ($object->element == 'societe') { |
|
| 1401 | + $modulepart = 'societe'; |
|
| 1402 | + } |
|
| 1403 | + if ($object->element == 'contact') { |
|
| 1404 | + $modulepart = 'contact'; |
|
| 1405 | + } |
|
| 1406 | + if ($object->element == 'member') { |
|
| 1407 | + $modulepart = 'memberphoto'; |
|
| 1408 | + } |
|
| 1409 | + if ($object->element == 'user') { |
|
| 1410 | + $modulepart = 'userphoto'; |
|
| 1411 | + } |
|
| 1412 | + if ($object->element == 'product') { |
|
| 1413 | + $modulepart = 'product'; |
|
| 1414 | + } |
|
| 1357 | 1415 | |
| 1358 | 1416 | if (class_exists("Imagick")) {
|
| 1359 | - if ($object->element == 'propal') |
|
| 1360 | - $modulepart = 'propal'; |
|
| 1361 | - if ($object->element == 'commande') |
|
| 1362 | - $modulepart = 'commande'; |
|
| 1363 | - if ($object->element == 'facture') |
|
| 1364 | - $modulepart = 'facture'; |
|
| 1365 | - if ($object->element == 'fichinter') |
|
| 1366 | - $modulepart = 'ficheinter'; |
|
| 1367 | - if ($object->element == 'contrat') |
|
| 1368 | - $modulepart = 'contract'; |
|
| 1369 | - if ($object->element == 'supplier_proposal') |
|
| 1370 | - $modulepart = 'supplier_proposal'; |
|
| 1371 | - if ($object->element == 'order_supplier') |
|
| 1372 | - $modulepart = 'supplier_order'; |
|
| 1373 | - if ($object->element == 'invoice_supplier') |
|
| 1374 | - $modulepart = 'supplier_invoice'; |
|
| 1375 | - if ($object->element == 'expensereport') |
|
| 1376 | - $modulepart = 'expensereport'; |
|
| 1417 | + if ($object->element == 'propal') { |
|
| 1418 | + $modulepart = 'propal'; |
|
| 1419 | + } |
|
| 1420 | + if ($object->element == 'commande') { |
|
| 1421 | + $modulepart = 'commande'; |
|
| 1422 | + } |
|
| 1423 | + if ($object->element == 'facture') { |
|
| 1424 | + $modulepart = 'facture'; |
|
| 1425 | + } |
|
| 1426 | + if ($object->element == 'fichinter') { |
|
| 1427 | + $modulepart = 'ficheinter'; |
|
| 1428 | + } |
|
| 1429 | + if ($object->element == 'contrat') { |
|
| 1430 | + $modulepart = 'contract'; |
|
| 1431 | + } |
|
| 1432 | + if ($object->element == 'supplier_proposal') { |
|
| 1433 | + $modulepart = 'supplier_proposal'; |
|
| 1434 | + } |
|
| 1435 | + if ($object->element == 'order_supplier') { |
|
| 1436 | + $modulepart = 'supplier_order'; |
|
| 1437 | + } |
|
| 1438 | + if ($object->element == 'invoice_supplier') { |
|
| 1439 | + $modulepart = 'supplier_invoice'; |
|
| 1440 | + } |
|
| 1441 | + if ($object->element == 'expensereport') { |
|
| 1442 | + $modulepart = 'expensereport'; |
|
| 1443 | + } |
|
| 1377 | 1444 | } |
| 1378 | 1445 | |
| 1379 | 1446 | if ($object->element == 'product') {
|
@@ -1381,11 +1448,12 @@ discard block |
||
| 1381 | 1448 | $cssclass = 'photoref'; |
| 1382 | 1449 | $showimage = $object->is_photo_available($conf->product->multidir_output[$entity]); |
| 1383 | 1450 | $maxvisiblephotos = (isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO) ? $conf->global->PRODUCT_MAX_VISIBLE_PHOTO : 5); |
| 1384 | - if ($conf->browser->layout == 'phone') |
|
| 1385 | - $maxvisiblephotos = 1; |
|
| 1386 | - if ($showimage) |
|
| 1387 | - $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('product', $conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>';
|
|
| 1388 | - else {
|
|
| 1451 | + if ($conf->browser->layout == 'phone') { |
|
| 1452 | + $maxvisiblephotos = 1; |
|
| 1453 | + } |
|
| 1454 | + if ($showimage) { |
|
| 1455 | + $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('product', $conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>'; |
|
| 1456 | + } else {
|
|
| 1389 | 1457 | if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) {
|
| 1390 | 1458 | $nophoto = ''; |
| 1391 | 1459 | $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"></div>'; |
@@ -1401,11 +1469,12 @@ discard block |
||
| 1401 | 1469 | $cssclass = 'photoref'; |
| 1402 | 1470 | $showimage = $object->is_photo_available($conf->ticket->multidir_output[$entity] . '/' . $object->track_id); |
| 1403 | 1471 | $maxvisiblephotos = (isset($conf->global->TICKETSUP_MAX_VISIBLE_PHOTO) ? $conf->global->TICKETSUP_MAX_VISIBLE_PHOTO : 2); |
| 1404 | - if ($conf->browser->layout == 'phone') |
|
| 1405 | - $maxvisiblephotos = 1; |
|
| 1406 | - if ($showimage) |
|
| 1407 | - $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('ticket', $conf->ticket->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>';
|
|
| 1408 | - else {
|
|
| 1472 | + if ($conf->browser->layout == 'phone') { |
|
| 1473 | + $maxvisiblephotos = 1; |
|
| 1474 | + } |
|
| 1475 | + if ($showimage) { |
|
| 1476 | + $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('ticket', $conf->ticket->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>'; |
|
| 1477 | + } else {
|
|
| 1409 | 1478 | if (!empty($conf->global->TICKETSUP_NODISPLAYIFNOPHOTO)) {
|
| 1410 | 1479 | $nophoto = ''; |
| 1411 | 1480 | $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"></div>'; |
@@ -1430,8 +1499,10 @@ discard block |
||
| 1430 | 1499 | } else {
|
| 1431 | 1500 | $subdir = get_exdir($object->id, 0, 0, 1, $object, $modulepart); |
| 1432 | 1501 | } |
| 1433 | - if (empty($subdir)) |
|
| 1434 | - $subdir = 'errorgettingsubdirofobject'; // Protection to avoid to return empty path |
|
| 1502 | + if (empty($subdir)) { |
|
| 1503 | + $subdir = 'errorgettingsubdirofobject'; |
|
| 1504 | + } |
|
| 1505 | + // Protection to avoid to return empty path |
|
| 1435 | 1506 | |
| 1436 | 1507 | $filepath = $dir_output . $subdir . "/"; |
| 1437 | 1508 | |
@@ -1452,14 +1523,16 @@ discard block |
||
| 1452 | 1523 | if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) { // If you experienc trouble with pdf thumb generation and imagick, you can disable here.
|
| 1453 | 1524 | include_once DOL_BASE_PATH . '/core/lib/files.lib.php'; |
| 1454 | 1525 | $ret = dol_convert_file($file, 'png', $fileimage); |
| 1455 | - if ($ret < 0) |
|
| 1456 | - $error++; |
|
| 1526 | + if ($ret < 0) { |
|
| 1527 | + $error++; |
|
| 1528 | + } |
|
| 1457 | 1529 | } |
| 1458 | 1530 | } |
| 1459 | 1531 | |
| 1460 | 1532 | $heightforphotref = 70; |
| 1461 | - if (!empty($conf->dol_optimize_smallscreen)) |
|
| 1462 | - $heightforphotref = 60; |
|
| 1533 | + if (!empty($conf->dol_optimize_smallscreen)) { |
|
| 1534 | + $heightforphotref = 60; |
|
| 1535 | + } |
|
| 1463 | 1536 | // Si fichier png PDF d'1 page trouve |
| 1464 | 1537 | if (file_exists($fileimage)) {
|
| 1465 | 1538 | $phototoshow = '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">'; |
@@ -1495,8 +1568,10 @@ discard block |
||
| 1495 | 1568 | $width = 14; |
| 1496 | 1569 | $cssclass = 'photorefcenter'; |
| 1497 | 1570 | $picto = $object->picto; |
| 1498 | - if ($object->element == 'project' && !$object->public) |
|
| 1499 | - $picto = 'project'; // instead of projectpub |
|
| 1571 | + if ($object->element == 'project' && !$object->public) { |
|
| 1572 | + $picto = 'project'; |
|
| 1573 | + } |
|
| 1574 | + // instead of projectpub |
|
| 1500 | 1575 | $nophoto = img_picto('', 'object_' . $picto, '', false, 1);
|
| 1501 | 1576 | } |
| 1502 | 1577 | $morehtmlleft .= '<!-- No photo to show -->'; |
@@ -1507,8 +1582,9 @@ discard block |
||
| 1507 | 1582 | } |
| 1508 | 1583 | } |
| 1509 | 1584 | |
| 1510 | - if ($showbarcode) |
|
| 1511 | - $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $form->showbarcode($object) . '</div>'; |
|
| 1585 | + if ($showbarcode) { |
|
| 1586 | + $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $form->showbarcode($object) . '</div>'; |
|
| 1587 | + } |
|
| 1512 | 1588 | |
| 1513 | 1589 | if ($object->element == 'societe') {
|
| 1514 | 1590 | if (!empty($conf->use_javascript_ajax) && $user->rights->societe->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
|
@@ -1532,35 +1608,37 @@ discard block |
||
| 1532 | 1608 | } |
| 1533 | 1609 | } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) {
|
| 1534 | 1610 | $tmptxt = $object->getLibStatut(6, $object->totalpaye); |
| 1535 | - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout == 'phone') |
|
| 1536 | - $tmptxt = $object->getLibStatut(5, $object->totalpaye); |
|
| 1611 | + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout == 'phone') { |
|
| 1612 | + $tmptxt = $object->getLibStatut(5, $object->totalpaye); |
|
| 1613 | + } |
|
| 1537 | 1614 | $morehtmlstatus .= $tmptxt; |
| 1538 | - } |
|
| 1539 | - elseif ($object->element == 'contrat' || $object->element == 'contract') {
|
|
| 1540 | - if ($object->statut == 0) |
|
| 1541 | - $morehtmlstatus .= $object->getLibStatut(5); |
|
| 1542 | - else |
|
| 1543 | - $morehtmlstatus .= $object->getLibStatut(4); |
|
| 1544 | - } |
|
| 1545 | - elseif ($object->element == 'facturerec') {
|
|
| 1546 | - if ($object->frequency == 0) |
|
| 1547 | - $morehtmlstatus .= $object->getLibStatut(2); |
|
| 1548 | - else |
|
| 1549 | - $morehtmlstatus .= $object->getLibStatut(5); |
|
| 1550 | - } |
|
| 1551 | - elseif ($object->element == 'project_task') {
|
|
| 1615 | + } elseif ($object->element == 'contrat' || $object->element == 'contract') {
|
|
| 1616 | + if ($object->statut == 0) { |
|
| 1617 | + $morehtmlstatus .= $object->getLibStatut(5); |
|
| 1618 | + } else { |
|
| 1619 | + $morehtmlstatus .= $object->getLibStatut(4); |
|
| 1620 | + } |
|
| 1621 | + } elseif ($object->element == 'facturerec') {
|
|
| 1622 | + if ($object->frequency == 0) { |
|
| 1623 | + $morehtmlstatus .= $object->getLibStatut(2); |
|
| 1624 | + } else { |
|
| 1625 | + $morehtmlstatus .= $object->getLibStatut(5); |
|
| 1626 | + } |
|
| 1627 | + } elseif ($object->element == 'project_task') {
|
|
| 1552 | 1628 | $object->fk_statut = 1; |
| 1553 | - if ($object->progress > 0) |
|
| 1554 | - $object->fk_statut = 2; |
|
| 1555 | - if ($object->progress >= 100) |
|
| 1556 | - $object->fk_statut = 3; |
|
| 1629 | + if ($object->progress > 0) { |
|
| 1630 | + $object->fk_statut = 2; |
|
| 1631 | + } |
|
| 1632 | + if ($object->progress >= 100) { |
|
| 1633 | + $object->fk_statut = 3; |
|
| 1634 | + } |
|
| 1557 | 1635 | $tmptxt = $object->getLibStatut(5); |
| 1558 | 1636 | $morehtmlstatus .= $tmptxt; // No status on task |
| 1559 | - } |
|
| 1560 | - else { // Generic case
|
|
| 1637 | + } else { // Generic case
|
|
| 1561 | 1638 | $tmptxt = $object->getLibStatut(6); |
| 1562 | - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout == 'phone') |
|
| 1563 | - $tmptxt = $object->getLibStatut(5); |
|
| 1639 | + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout == 'phone') { |
|
| 1640 | + $tmptxt = $object->getLibStatut(5); |
|
| 1641 | + } |
|
| 1564 | 1642 | $morehtmlstatus .= $tmptxt; |
| 1565 | 1643 | } |
| 1566 | 1644 | |
@@ -1574,13 +1652,15 @@ discard block |
||
| 1574 | 1652 | } |
| 1575 | 1653 | |
| 1576 | 1654 | // Add alias for thirdparty |
| 1577 | - if (!empty($object->name_alias)) |
|
| 1578 | - $morehtmlref .= '<div class="refidno">' . $object->name_alias . '</div>'; |
|
| 1655 | + if (!empty($object->name_alias)) { |
|
| 1656 | + $morehtmlref .= '<div class="refidno">' . $object->name_alias . '</div>'; |
|
| 1657 | + } |
|
| 1579 | 1658 | |
| 1580 | 1659 | // Add label |
| 1581 | 1660 | if ($object->element == 'product' || $object->element == 'bank_account' || $object->element == 'project_task') {
|
| 1582 | - if (!empty($object->label)) |
|
| 1583 | - $morehtmlref .= '<div class="refidno">' . $object->label . '</div>'; |
|
| 1661 | + if (!empty($object->label)) { |
|
| 1662 | + $morehtmlref .= '<div class="refidno">' . $object->label . '</div>'; |
|
| 1663 | + } |
|
| 1584 | 1664 | } |
| 1585 | 1665 | |
| 1586 | 1666 | if (method_exists($object, 'getBannerAddress') && $object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories' && $object->element != 'ecm_files') {
|
@@ -1613,15 +1693,19 @@ discard block |
||
| 1613 | 1693 | {
|
| 1614 | 1694 | global $conf, $langs; |
| 1615 | 1695 | $ret = ''; |
| 1616 | - if ($fieldrequired) |
|
| 1617 | - $ret .= '<span class="fieldrequired">'; |
|
| 1618 | - if (($conf->dol_use_jmobile != 4)) |
|
| 1619 | - $ret .= '<label for="' . $fieldkey . '">'; |
|
| 1696 | + if ($fieldrequired) { |
|
| 1697 | + $ret .= '<span class="fieldrequired">'; |
|
| 1698 | + } |
|
| 1699 | + if (($conf->dol_use_jmobile != 4)) { |
|
| 1700 | + $ret .= '<label for="' . $fieldkey . '">'; |
|
| 1701 | + } |
|
| 1620 | 1702 | $ret .= $langs->trans($langkey); |
| 1621 | - if (($conf->dol_use_jmobile != 4)) |
|
| 1622 | - $ret .= '</label>'; |
|
| 1623 | - if ($fieldrequired) |
|
| 1624 | - $ret .= '</span>'; |
|
| 1703 | + if (($conf->dol_use_jmobile != 4)) { |
|
| 1704 | + $ret .= '</label>'; |
|
| 1705 | + } |
|
| 1706 | + if ($fieldrequired) { |
|
| 1707 | + $ret .= '</span>'; |
|
| 1708 | + } |
|
| 1625 | 1709 | return $ret; |
| 1626 | 1710 | } |
| 1627 | 1711 | |
@@ -1636,8 +1720,9 @@ discard block |
||
| 1636 | 1720 | {
|
| 1637 | 1721 | global $bc; |
| 1638 | 1722 | $ret = ' ' . $bc[$var]; |
| 1639 | - if ($moreclass) |
|
| 1640 | - $ret = preg_replace('/class=\"/', 'class="' . $moreclass . ' ', $ret);
|
|
| 1723 | + if ($moreclass) { |
|
| 1724 | + $ret = preg_replace('/class=\"/', 'class="' . $moreclass . ' ', $ret); |
|
| 1725 | + } |
|
| 1641 | 1726 | return $ret; |
| 1642 | 1727 | } |
| 1643 | 1728 | |
@@ -1668,18 +1753,18 @@ discard block |
||
| 1668 | 1753 | if ($object->state) {
|
| 1669 | 1754 | $ret .= ($ret ? ", " : '') . $object->state; |
| 1670 | 1755 | } |
| 1671 | - if ($object->zip) |
|
| 1672 | - $ret .= ($ret ? ", " : '') . $object->zip; |
|
| 1673 | - } |
|
| 1674 | - else if (in_array($object->country_code, array('GB', 'UK'))) { // UK: title firstname name \n address lines \n town state \n zip \n country
|
|
| 1756 | + if ($object->zip) { |
|
| 1757 | + $ret .= ($ret ? ", " : '') . $object->zip; |
|
| 1758 | + } |
|
| 1759 | + } else if (in_array($object->country_code, array('GB', 'UK'))) { // UK: title firstname name \n address lines \n town state \n zip \n country
|
|
| 1675 | 1760 | $ret .= ($ret ? $sep : '' ) . $object->town; |
| 1676 | 1761 | if ($object->state) {
|
| 1677 | 1762 | $ret .= ($ret ? ", " : '') . $object->state; |
| 1678 | 1763 | } |
| 1679 | - if ($object->zip) |
|
| 1680 | - $ret .= ($ret ? $sep : '' ) . $object->zip; |
|
| 1681 | - } |
|
| 1682 | - else if (in_array($object->country_code, array('ES', 'TR'))) { // ES: title firstname name \n address lines \n zip town \n state \n country
|
|
| 1764 | + if ($object->zip) { |
|
| 1765 | + $ret .= ($ret ? $sep : '' ) . $object->zip; |
|
| 1766 | + } |
|
| 1767 | + } else if (in_array($object->country_code, array('ES', 'TR'))) { // ES: title firstname name \n address lines \n zip town \n state \n country
|
|
| 1683 | 1768 | $ret .= ($ret ? $sep : '' ) . $object->zip; |
| 1684 | 1769 | $ret .= ($object->town ? (($object->zip ? ' ' : '') . $object->town) : ''); |
| 1685 | 1770 | if ($object->state) {
|
@@ -1696,8 +1781,9 @@ discard block |
||
| 1696 | 1781 | $ret .= ($ret ? ", " : '') . $object->state; |
| 1697 | 1782 | } |
| 1698 | 1783 | } |
| 1699 | - if (!is_object($outputlangs)) |
|
| 1700 | - $outputlangs = $langs; |
|
| 1784 | + if (!is_object($outputlangs)) { |
|
| 1785 | + $outputlangs = $langs; |
|
| 1786 | + } |
|
| 1701 | 1787 | if ($withcountry) {
|
| 1702 | 1788 | $langs->load("dict");
|
| 1703 | 1789 | $ret .= ($object->country_code ? ($ret ? $sep : '') . $outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country" . $object->country_code)) : '');
|
@@ -1718,9 +1804,10 @@ discard block |
||
| 1718 | 1804 | {
|
| 1719 | 1805 | if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
|
| 1720 | 1806 | return ($is_gmt) ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts); |
| 1721 | - } else |
|
| 1722 | - return 'Error date into a not supported range'; |
|
| 1723 | -} |
|
| 1807 | + } else { |
|
| 1808 | + return 'Error date into a not supported range'; |
|
| 1809 | + } |
|
| 1810 | + } |
|
| 1724 | 1811 | |
| 1725 | 1812 | /** |
| 1726 | 1813 | * Output date in a string format according to outputlangs (or langs if not defined). |
@@ -1766,10 +1853,12 @@ discard block |
||
| 1766 | 1853 | } |
| 1767 | 1854 | } |
| 1768 | 1855 | } |
| 1769 | - if (!is_object($outputlangs)) |
|
| 1770 | - $outputlangs = $langs; |
|
| 1771 | - if (!$format) |
|
| 1772 | - $format = 'daytextshort'; |
|
| 1856 | + if (!is_object($outputlangs)) { |
|
| 1857 | + $outputlangs = $langs; |
|
| 1858 | + } |
|
| 1859 | + if (!$format) { |
|
| 1860 | + $format = 'daytextshort'; |
|
| 1861 | + } |
|
| 1773 | 1862 | $reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array('day', 'dayhour'))) ? 1 : 0;
|
| 1774 | 1863 | $formatwithoutreduce = preg_replace('/reduceformat/', '', $format);
|
| 1775 | 1864 | if ($formatwithoutreduce != $format) {
|
@@ -1778,40 +1867,46 @@ discard block |
||
| 1778 | 1867 | } // so format 'dayreduceformat' is processed like day |
| 1779 | 1868 | // Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default. |
| 1780 | 1869 | // TODO Add format daysmallyear and dayhoursmallyear |
| 1781 | - if ($format == 'day') |
|
| 1782 | - $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : $conf->format_date_short);
|
|
| 1783 | - else if ($format == 'hour') |
|
| 1784 | - $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : $conf->format_hour_short);
|
|
| 1785 | - else if ($format == 'hourduration') |
|
| 1786 | - $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : $conf->format_hour_short_duration);
|
|
| 1787 | - else if ($format == 'daytext') |
|
| 1788 | - $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : $conf->format_date_text);
|
|
| 1789 | - else if ($format == 'daytextshort') |
|
| 1790 | - // Notice: Undefined property: stdClass::$format_date_text_short in \alixar\dolibarr\htdocs\core\lib\functions.lib.php on line 1781 |
|
| 1791 | - $format = ($outputlangs->trans("FormatDateTextShort") != "FormatDateTextShort" ? $outputlangs->trans("FormatDateTextShort") : $conf->format_date_text_short);
|
|
| 1792 | - else if ($format == 'dayhour') |
|
| 1793 | - $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : $conf->format_date_hour_short);
|
|
| 1794 | - else if ($format == 'dayhoursec') |
|
| 1795 | - $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : $conf->format_date_hour_sec_short);
|
|
| 1796 | - else if ($format == 'dayhourtext') |
|
| 1797 | - $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : $conf->format_date_hour_text);
|
|
| 1798 | - else if ($format == 'dayhourtextshort') |
|
| 1799 | - $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : $conf->format_date_hour_text_short);
|
|
| 1870 | + if ($format == 'day') { |
|
| 1871 | + $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : $conf->format_date_short); |
|
| 1872 | + } else if ($format == 'hour') { |
|
| 1873 | + $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : $conf->format_hour_short); |
|
| 1874 | + } else if ($format == 'hourduration') { |
|
| 1875 | + $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : $conf->format_hour_short_duration); |
|
| 1876 | + } else if ($format == 'daytext') { |
|
| 1877 | + $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : $conf->format_date_text); |
|
| 1878 | + } else if ($format == 'daytextshort') { |
|
| 1879 | + // Notice: Undefined property: stdClass::$format_date_text_short in \alixar\dolibarr\htdocs\core\lib\functions.lib.php on line 1781 |
|
| 1880 | + $format = ($outputlangs->trans("FormatDateTextShort") != "FormatDateTextShort" ? $outputlangs->trans("FormatDateTextShort") : $conf->format_date_text_short); |
|
| 1881 | + } else if ($format == 'dayhour') { |
|
| 1882 | + $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : $conf->format_date_hour_short); |
|
| 1883 | + } else if ($format == 'dayhoursec') { |
|
| 1884 | + $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : $conf->format_date_hour_sec_short); |
|
| 1885 | + } else if ($format == 'dayhourtext') { |
|
| 1886 | + $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : $conf->format_date_hour_text); |
|
| 1887 | + } else if ($format == 'dayhourtextshort') { |
|
| 1888 | + $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : $conf->format_date_hour_text_short); |
|
| 1889 | + } |
|
| 1800 | 1890 | // Format not sensitive to language |
| 1801 | - else if ($format == 'dayhourlog') |
|
| 1802 | - $format = '%Y%m%d%H%M%S'; |
|
| 1803 | - else if ($format == 'dayhourldap') |
|
| 1804 | - $format = '%Y%m%d%H%M%SZ'; |
|
| 1805 | - else if ($format == 'dayhourxcard') |
|
| 1806 | - $format = '%Y%m%dT%H%M%SZ'; |
|
| 1807 | - else if ($format == 'dayxcard') |
|
| 1808 | - $format = '%Y%m%d'; |
|
| 1809 | - else if ($format == 'dayrfc') |
|
| 1810 | - $format = '%Y-%m-%d'; // DATE_RFC3339 |
|
| 1811 | - else if ($format == 'dayhourrfc') |
|
| 1812 | - $format = '%Y-%m-%dT%H:%M:%SZ'; // DATETIME RFC3339 |
|
| 1813 | - else if ($format == 'standard') |
|
| 1814 | - $format = '%Y-%m-%d %H:%M:%S'; |
|
| 1891 | + else if ($format == 'dayhourlog') { |
|
| 1892 | + $format = '%Y%m%d%H%M%S'; |
|
| 1893 | + } else if ($format == 'dayhourldap') { |
|
| 1894 | + $format = '%Y%m%d%H%M%SZ'; |
|
| 1895 | + } else if ($format == 'dayhourxcard') { |
|
| 1896 | + $format = '%Y%m%dT%H%M%SZ'; |
|
| 1897 | + } else if ($format == 'dayxcard') { |
|
| 1898 | + $format = '%Y%m%d'; |
|
| 1899 | + } else if ($format == 'dayrfc') { |
|
| 1900 | + $format = '%Y-%m-%d'; |
|
| 1901 | + } |
|
| 1902 | + // DATE_RFC3339 |
|
| 1903 | + else if ($format == 'dayhourrfc') { |
|
| 1904 | + $format = '%Y-%m-%dT%H:%M:%SZ'; |
|
| 1905 | + } |
|
| 1906 | + // DATETIME RFC3339 |
|
| 1907 | + else if ($format == 'standard') { |
|
| 1908 | + $format = '%Y-%m-%d %H:%M:%S'; |
|
| 1909 | + } |
|
| 1815 | 1910 | |
| 1816 | 1911 | if ($reduceformat) {
|
| 1817 | 1912 | $format = str_replace('%Y', '%y', $format);
|
@@ -1819,8 +1914,10 @@ discard block |
||
| 1819 | 1914 | } |
| 1820 | 1915 | |
| 1821 | 1916 | // If date undefined or "", we return "" |
| 1822 | - if (dol_strlen($time) == 0) |
|
| 1823 | - return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) |
|
| 1917 | + if (dol_strlen($time) == 0) { |
|
| 1918 | + return ''; |
|
| 1919 | + } |
|
| 1920 | + // $time=0 allowed (it means 01/01/1970 00:00:00) |
|
| 1824 | 1921 | |
| 1825 | 1922 | |
| 1826 | 1923 | |
@@ -1868,8 +1965,9 @@ discard block |
||
| 1868 | 1965 | $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. |
| 1869 | 1966 | |
| 1870 | 1967 | $ret = adodb_strftime($format, $timetouse, $to_gmt); |
| 1871 | - } else |
|
| 1872 | - $ret = 'Bad value ' . $time . ' for date'; |
|
| 1968 | + } else { |
|
| 1969 | + $ret = 'Bad value ' . $time . ' for date'; |
|
| 1970 | + } |
|
| 1873 | 1971 | } |
| 1874 | 1972 | |
| 1875 | 1973 | if (preg_match('/__b__/i', $format)) {
|
@@ -1940,10 +2038,14 @@ discard block |
||
| 1940 | 2038 | global $conf; |
| 1941 | 2039 | |
| 1942 | 2040 | $usealternatemethod = false; |
| 1943 | - if ($timestamp <= 0) |
|
| 1944 | - $usealternatemethod = true; // <= 1970 |
|
| 1945 | - if ($timestamp >= 2145913200) |
|
| 1946 | - $usealternatemethod = true; // >= 2038 |
|
| 2041 | + if ($timestamp <= 0) { |
|
| 2042 | + $usealternatemethod = true; |
|
| 2043 | + } |
|
| 2044 | + // <= 1970 |
|
| 2045 | + if ($timestamp >= 2145913200) { |
|
| 2046 | + $usealternatemethod = true; |
|
| 2047 | + } |
|
| 2048 | + // >= 2038 |
|
| 1947 | 2049 | |
| 1948 | 2050 | if ($usealternatemethod) {
|
| 1949 | 2051 | $arrayinfo = adodb_getdate($timestamp, $fast); |
@@ -1978,27 +2080,36 @@ discard block |
||
| 1978 | 2080 | global $conf; |
| 1979 | 2081 | //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -"; |
| 1980 | 2082 | // Clean parameters |
| 1981 | - if ($hour == -1 || empty($hour)) |
|
| 1982 | - $hour = 0; |
|
| 1983 | - if ($minute == -1 || empty($minute)) |
|
| 1984 | - $minute = 0; |
|
| 1985 | - if ($second == -1 || empty($second)) |
|
| 1986 | - $second = 0; |
|
| 2083 | + if ($hour == -1 || empty($hour)) { |
|
| 2084 | + $hour = 0; |
|
| 2085 | + } |
|
| 2086 | + if ($minute == -1 || empty($minute)) { |
|
| 2087 | + $minute = 0; |
|
| 2088 | + } |
|
| 2089 | + if ($second == -1 || empty($second)) { |
|
| 2090 | + $second = 0; |
|
| 2091 | + } |
|
| 1987 | 2092 | |
| 1988 | 2093 | // Check parameters |
| 1989 | 2094 | if ($check) {
|
| 1990 | - if (!$month || !$day) |
|
| 1991 | - return ''; |
|
| 1992 | - if ($day > 31) |
|
| 1993 | - return ''; |
|
| 1994 | - if ($month > 12) |
|
| 1995 | - return ''; |
|
| 1996 | - if ($hour < 0 || $hour > 24) |
|
| 1997 | - return ''; |
|
| 1998 | - if ($minute < 0 || $minute > 60) |
|
| 1999 | - return ''; |
|
| 2000 | - if ($second < 0 || $second > 60) |
|
| 2001 | - return ''; |
|
| 2095 | + if (!$month || !$day) { |
|
| 2096 | + return ''; |
|
| 2097 | + } |
|
| 2098 | + if ($day > 31) { |
|
| 2099 | + return ''; |
|
| 2100 | + } |
|
| 2101 | + if ($month > 12) { |
|
| 2102 | + return ''; |
|
| 2103 | + } |
|
| 2104 | + if ($hour < 0 || $hour > 24) { |
|
| 2105 | + return ''; |
|
| 2106 | + } |
|
| 2107 | + if ($minute < 0 || $minute > 60) { |
|
| 2108 | + return ''; |
|
| 2109 | + } |
|
| 2110 | + if ($second < 0 || $second > 60) { |
|
| 2111 | + return ''; |
|
| 2112 | + } |
|
| 2002 | 2113 | } |
| 2003 | 2114 | |
| 2004 | 2115 | if (method_exists('DateTime', 'getTimestamp')) {
|
@@ -2055,8 +2166,10 @@ discard block |
||
| 2055 | 2166 | |
| 2056 | 2167 | // Note that gmmktime and mktime return same value (GMT) when used without parameters |
| 2057 | 2168 | //if ($mode == 'gmt') $ret=gmmktime(); // Strict Standards: gmmktime(): You should be using the time() function instead |
| 2058 | - if ($mode == 'gmt') |
|
| 2059 | - $ret = time(); // Time for now at greenwich. |
|
| 2169 | + if ($mode == 'gmt') { |
|
| 2170 | + $ret = time(); |
|
| 2171 | + } |
|
| 2172 | + // Time for now at greenwich. |
|
| 2060 | 2173 | else if ($mode == 'tzserver') { // Time for now with PHP server timezone added
|
| 2061 | 2174 | require_once DOL_BASE_PATH . '/core/lib/date.lib.php'; |
| 2062 | 2175 | $tzsecond = getServerTimeZoneInt('now'); // Contains tz+dayling saving time
|
@@ -2090,8 +2203,9 @@ discard block |
||
| 2090 | 2203 | global $conf, $langs; |
| 2091 | 2204 | $level = 1024; |
| 2092 | 2205 | |
| 2093 | - if (!empty($conf->dol_optimize_smallscreen)) |
|
| 2094 | - $shortunit = 1; |
|
| 2206 | + if (!empty($conf->dol_optimize_smallscreen)) { |
|
| 2207 | + $shortunit = 1; |
|
| 2208 | + } |
|
| 2095 | 2209 | |
| 2096 | 2210 | // Set value text |
| 2097 | 2211 | if (empty($shortvalue) || $size < ($level * 10)) {
|
@@ -2126,19 +2240,23 @@ discard block |
||
| 2126 | 2240 | {
|
| 2127 | 2241 | global $langs; |
| 2128 | 2242 | |
| 2129 | - if (empty($url)) |
|
| 2130 | - return ''; |
|
| 2243 | + if (empty($url)) { |
|
| 2244 | + return ''; |
|
| 2245 | + } |
|
| 2131 | 2246 | |
| 2132 | 2247 | $link = '<a href="'; |
| 2133 | - if (!preg_match('/^http/i', $url))
|
|
| 2134 | - $link .= 'http://'; |
|
| 2248 | + if (!preg_match('/^http/i', $url)) { |
|
| 2249 | + $link .= 'http://'; |
|
| 2250 | + } |
|
| 2135 | 2251 | $link .= $url; |
| 2136 | 2252 | $link .= '"'; |
| 2137 | - if ($target) |
|
| 2138 | - $link .= ' target="' . $target . '"'; |
|
| 2253 | + if ($target) { |
|
| 2254 | + $link .= ' target="' . $target . '"'; |
|
| 2255 | + } |
|
| 2139 | 2256 | $link .= '>'; |
| 2140 | - if (!preg_match('/^http/i', $url))
|
|
| 2141 | - $link .= 'http://'; |
|
| 2257 | + if (!preg_match('/^http/i', $url)) { |
|
| 2258 | + $link .= 'http://'; |
|
| 2259 | + } |
|
| 2142 | 2260 | $link .= dol_trunc($url, $max); |
| 2143 | 2261 | $link .= '</a>'; |
| 2144 | 2262 | return '<div class="nospan float" style="margin-right: 10px">' . ($withpicto ? img_picto($langs->trans("Url"), 'object_globe.png') . ' ' : '') . $link . '</div>';
|
@@ -2162,13 +2280,15 @@ discard block |
||
| 2162 | 2280 | |
| 2163 | 2281 | $newemail = $email; |
| 2164 | 2282 | |
| 2165 | - if (empty($email)) |
|
| 2166 | - return ' '; |
|
| 2283 | + if (empty($email)) { |
|
| 2284 | + return ' '; |
|
| 2285 | + } |
|
| 2167 | 2286 | |
| 2168 | 2287 | if (!empty($addlink)) {
|
| 2169 | 2288 | $newemail = '<a style="text-overflow: ellipsis;" href="'; |
| 2170 | - if (!preg_match('/^mailto:/i', $email))
|
|
| 2171 | - $newemail .= 'mailto:'; |
|
| 2289 | + if (!preg_match('/^mailto:/i', $email)) { |
|
| 2290 | + $newemail .= 'mailto:'; |
|
| 2291 | + } |
|
| 2172 | 2292 | $newemail .= $email; |
| 2173 | 2293 | $newemail .= '">'; |
| 2174 | 2294 | $newemail .= dol_trunc($email, $max); |
@@ -2181,13 +2301,14 @@ discard block |
||
| 2181 | 2301 | if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
|
| 2182 | 2302 | $type = 'AC_EMAIL'; |
| 2183 | 2303 | $link = ''; |
| 2184 | - if (!empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) |
|
| 2185 | - $link = '<a href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&backtopage=1&actioncode=' . $type . '&contactid=' . $cid . '&socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
|
|
| 2186 | - if ($link) |
|
| 2187 | - $newemail = '<div>' . $newemail . ' ' . $link . '</div>'; |
|
| 2304 | + if (!empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) { |
|
| 2305 | + $link = '<a href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&backtopage=1&actioncode=' . $type . '&contactid=' . $cid . '&socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>'; |
|
| 2306 | + } |
|
| 2307 | + if ($link) { |
|
| 2308 | + $newemail = '<div>' . $newemail . ' ' . $link . '</div>'; |
|
| 2309 | + } |
|
| 2188 | 2310 | } |
| 2189 | - } |
|
| 2190 | - else {
|
|
| 2311 | + } else {
|
|
| 2191 | 2312 | if ($showinvalid && !isValidEmail($email)) {
|
| 2192 | 2313 | $langs->load("errors");
|
| 2193 | 2314 | $newemail .= img_warning($langs->trans("ErrorBadEMail", $email));
|
@@ -2219,8 +2340,9 @@ discard block |
||
| 2219 | 2340 | |
| 2220 | 2341 | $newskype = $value; |
| 2221 | 2342 | |
| 2222 | - if (empty($value)) |
|
| 2223 | - return ' '; |
|
| 2343 | + if (empty($value)) { |
|
| 2344 | + return ' '; |
|
| 2345 | + } |
|
| 2224 | 2346 | |
| 2225 | 2347 | if (!empty($type)) {
|
| 2226 | 2348 | $newskype = '<div class="divsocialnetwork inline-block valignmiddle">'; |
@@ -2241,13 +2363,13 @@ discard block |
||
| 2241 | 2363 | if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create && $type == 'skype') {
|
| 2242 | 2364 | $addlink = 'AC_SKYPE'; |
| 2243 | 2365 | $link = ''; |
| 2244 | - if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) |
|
| 2245 | - $link = '<a href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&backtopage=1&actioncode=' . $addlink . '&contactid=' . $cid . '&socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
|
|
| 2366 | + if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) { |
|
| 2367 | + $link = '<a href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&backtopage=1&actioncode=' . $addlink . '&contactid=' . $cid . '&socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>'; |
|
| 2368 | + } |
|
| 2246 | 2369 | $newskype .= ($link ? ' ' . $link : ''); |
| 2247 | 2370 | } |
| 2248 | 2371 | $newskype .= '</div>'; |
| 2249 | - } |
|
| 2250 | - else {
|
|
| 2372 | + } else {
|
|
| 2251 | 2373 | $langs->load("errors");
|
| 2252 | 2374 | $newskype .= img_warning($langs->trans("ErrorBadSocialNetworkValue", $value));
|
| 2253 | 2375 | } |
@@ -2277,12 +2399,14 @@ discard block |
||
| 2277 | 2399 | if (empty($phone)) {
|
| 2278 | 2400 | return ''; |
| 2279 | 2401 | } |
| 2280 | - if (empty($countrycode)) |
|
| 2281 | - $countrycode = $mysoc->country_code; |
|
| 2402 | + if (empty($countrycode)) { |
|
| 2403 | + $countrycode = $mysoc->country_code; |
|
| 2404 | + } |
|
| 2282 | 2405 | |
| 2283 | 2406 | // Short format for small screens |
| 2284 | - if ($conf->dol_optimize_smallscreen) |
|
| 2285 | - $separ = ''; |
|
| 2407 | + if ($conf->dol_optimize_smallscreen) { |
|
| 2408 | + $separ = ''; |
|
| 2409 | + } |
|
| 2286 | 2410 | |
| 2287 | 2411 | $newphone = $phone; |
| 2288 | 2412 | if (strtoupper($countrycode) == "FR") {
|
@@ -2448,15 +2572,18 @@ discard block |
||
| 2448 | 2572 | $newphone = '<a href="tel:' . $phone . '"'; |
| 2449 | 2573 | $newphone .= '>' . $phone . '</a>'; |
| 2450 | 2574 | } else if (!empty($conf->clicktodial->enabled) && $addlink == 'AC_TEL') { // If click to dial, we use click to dial url
|
| 2451 | - if (empty($user->clicktodial_loaded)) |
|
| 2452 | - $user->fetch_clicktodial(); |
|
| 2575 | + if (empty($user->clicktodial_loaded)) { |
|
| 2576 | + $user->fetch_clicktodial(); |
|
| 2577 | + } |
|
| 2453 | 2578 | |
| 2454 | 2579 | // Define urlmask |
| 2455 | 2580 | $urlmask = 'ErrorClickToDialModuleNotConfigured'; |
| 2456 | - if (!empty($conf->global->CLICKTODIAL_URL)) |
|
| 2457 | - $urlmask = $conf->global->CLICKTODIAL_URL; |
|
| 2458 | - if (!empty($user->clicktodial_url)) |
|
| 2459 | - $urlmask = $user->clicktodial_url; |
|
| 2581 | + if (!empty($conf->global->CLICKTODIAL_URL)) { |
|
| 2582 | + $urlmask = $conf->global->CLICKTODIAL_URL; |
|
| 2583 | + } |
|
| 2584 | + if (!empty($user->clicktodial_url)) { |
|
| 2585 | + $urlmask = $user->clicktodial_url; |
|
| 2586 | + } |
|
| 2460 | 2587 | |
| 2461 | 2588 | $clicktodial_poste = (!empty($user->clicktodial_poste) ? urlencode($user->clicktodial_poste) : ''); |
| 2462 | 2589 | $clicktodial_login = (!empty($user->clicktodial_login) ? urlencode($user->clicktodial_login) : ''); |
@@ -2471,8 +2598,9 @@ discard block |
||
| 2471 | 2598 | $url = make_substitutions($url, $substitarray); |
| 2472 | 2599 | $newphonesav = $newphone; |
| 2473 | 2600 | $newphone = '<a href="' . $url . '"'; |
| 2474 | - if (!empty($conf->global->CLICKTODIAL_FORCENEWTARGET)) |
|
| 2475 | - $newphone .= ' target="_blank"'; |
|
| 2601 | + if (!empty($conf->global->CLICKTODIAL_FORCENEWTARGET)) { |
|
| 2602 | + $newphone .= ' target="_blank"'; |
|
| 2603 | + } |
|
| 2476 | 2604 | $newphone .= '>' . $newphonesav . '</a>'; |
| 2477 | 2605 | } |
| 2478 | 2606 | |
@@ -2480,12 +2608,15 @@ discard block |
||
| 2480 | 2608 | if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
|
| 2481 | 2609 | $type = 'AC_TEL'; |
| 2482 | 2610 | $link = ''; |
| 2483 | - if ($addlink == 'AC_FAX') |
|
| 2484 | - $type = 'AC_FAX'; |
|
| 2485 | - if (!empty($conf->global->AGENDA_ADDACTIONFORPHONE)) |
|
| 2486 | - $link = '<a href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&backtopage=1&actioncode=' . $type . ($cid ? '&contactid=' . $cid : '') . ($socid ? '&socid=' . $socid : '') . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
|
|
| 2487 | - if ($link) |
|
| 2488 | - $newphone = '<div>' . $newphone . ' ' . $link . '</div>'; |
|
| 2611 | + if ($addlink == 'AC_FAX') { |
|
| 2612 | + $type = 'AC_FAX'; |
|
| 2613 | + } |
|
| 2614 | + if (!empty($conf->global->AGENDA_ADDACTIONFORPHONE)) { |
|
| 2615 | + $link = '<a href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&backtopage=1&actioncode=' . $type . ($cid ? '&contactid=' . $cid : '') . ($socid ? '&socid=' . $socid : '') . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>'; |
|
| 2616 | + } |
|
| 2617 | + if ($link) { |
|
| 2618 | + $newphone = '<div>' . $newphone . ' ' . $link . '</div>'; |
|
| 2619 | + } |
|
| 2489 | 2620 | } |
| 2490 | 2621 | } |
| 2491 | 2622 | |
@@ -2512,15 +2643,17 @@ discard block |
||
| 2512 | 2643 | $picto = ''; |
| 2513 | 2644 | } |
| 2514 | 2645 | } |
| 2515 | - if ($adddivfloat) |
|
| 2516 | - $rep .= '<div class="nospan float" style="margin-right: 10px">'; |
|
| 2517 | - else |
|
| 2518 | - $rep .= '<span style="margin-right: 10px;">'; |
|
| 2646 | + if ($adddivfloat) { |
|
| 2647 | + $rep .= '<div class="nospan float" style="margin-right: 10px">'; |
|
| 2648 | + } else { |
|
| 2649 | + $rep .= '<span style="margin-right: 10px;">'; |
|
| 2650 | + } |
|
| 2519 | 2651 | $rep .= ($withpicto ? img_picto($titlealt, 'object_' . $picto . '.png') . ' ' : '') . $newphone; |
| 2520 | - if ($adddivfloat) |
|
| 2521 | - $rep .= '</div>'; |
|
| 2522 | - else |
|
| 2523 | - $rep .= '</span>'; |
|
| 2652 | + if ($adddivfloat) { |
|
| 2653 | + $rep .= '</div>'; |
|
| 2654 | + } else { |
|
| 2655 | + $rep .= '</span>'; |
|
| 2656 | + } |
|
| 2524 | 2657 | } |
| 2525 | 2658 | |
| 2526 | 2659 | return $rep; |
@@ -2539,16 +2672,18 @@ discard block |
||
| 2539 | 2672 | |
| 2540 | 2673 | $ret = ''; |
| 2541 | 2674 | |
| 2542 | - if (empty($mode)) |
|
| 2543 | - $ret .= $ip; |
|
| 2675 | + if (empty($mode)) { |
|
| 2676 | + $ret .= $ip; |
|
| 2677 | + } |
|
| 2544 | 2678 | |
| 2545 | 2679 | if ($mode != 2) {
|
| 2546 | 2680 | $countrycode = dolGetCountryCodeFromIp($ip); |
| 2547 | 2681 | if ($countrycode) { // If success, countrycode is us, fr, ...
|
| 2548 | 2682 | if (file_exists(DOL_BASE_PATH . 'theme/common/flags/' . $countrycode . '.png')) {
|
| 2549 | 2683 | $ret .= ' ' . img_picto($countrycode . ' ' . $langs->trans("AccordingToGeoIPDatabase"), /* DOL_URL_ROOT */ DOL_BASE_URI . '/theme/common/flags/' . $countrycode . '.png', '', 1);
|
| 2550 | - } else |
|
| 2551 | - $ret .= ' (' . $countrycode . ')';
|
|
| 2684 | + } else { |
|
| 2685 | + $ret .= ' (' . $countrycode . ')'; |
|
| 2686 | + } |
|
| 2552 | 2687 | } |
| 2553 | 2688 | } |
| 2554 | 2689 | |
@@ -2646,26 +2781,33 @@ discard block |
||
| 2646 | 2781 | $out .= $hookmanager->resPrint; |
| 2647 | 2782 | } |
| 2648 | 2783 | if (empty($reshook)) {
|
| 2649 | - if (empty($charfornl)) |
|
| 2650 | - $out .= nl2br($address); |
|
| 2651 | - else |
|
| 2652 | - $out .= preg_replace('/[\r\n]+/', $charfornl, $address);
|
|
| 2784 | + if (empty($charfornl)) { |
|
| 2785 | + $out .= nl2br($address); |
|
| 2786 | + } else { |
|
| 2787 | + $out .= preg_replace('/[\r\n]+/', $charfornl, $address); |
|
| 2788 | + } |
|
| 2653 | 2789 | |
| 2654 | 2790 | $showgmap = $showomap = 0; |
| 2655 | 2791 | |
| 2656 | 2792 | // TODO Add a hook here |
| 2657 | - if (($mode == 'thirdparty' || $mode == 'societe') && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS)) |
|
| 2658 | - $showgmap = 1; |
|
| 2659 | - if ($mode == 'contact' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) |
|
| 2660 | - $showgmap = 1; |
|
| 2661 | - if ($mode == 'member' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) |
|
| 2662 | - $showgmap = 1; |
|
| 2663 | - if (($mode == 'thirdparty' || $mode == 'societe') && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) |
|
| 2664 | - $showomap = 1; |
|
| 2665 | - if ($mode == 'contact' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) |
|
| 2666 | - $showomap = 1; |
|
| 2667 | - if ($mode == 'member' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) |
|
| 2668 | - $showomap = 1; |
|
| 2793 | + if (($mode == 'thirdparty' || $mode == 'societe') && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS)) { |
|
| 2794 | + $showgmap = 1; |
|
| 2795 | + } |
|
| 2796 | + if ($mode == 'contact' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) { |
|
| 2797 | + $showgmap = 1; |
|
| 2798 | + } |
|
| 2799 | + if ($mode == 'member' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) { |
|
| 2800 | + $showgmap = 1; |
|
| 2801 | + } |
|
| 2802 | + if (($mode == 'thirdparty' || $mode == 'societe') && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) { |
|
| 2803 | + $showomap = 1; |
|
| 2804 | + } |
|
| 2805 | + if ($mode == 'contact' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) { |
|
| 2806 | + $showomap = 1; |
|
| 2807 | + } |
|
| 2808 | + if ($mode == 'member' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) { |
|
| 2809 | + $showomap = 1; |
|
| 2810 | + } |
|
| 2669 | 2811 | |
| 2670 | 2812 | if ($showgmap) {
|
| 2671 | 2813 | $url = dol_buildpath('/google/gmaps.php?mode=' . $mode . '&id=' . $id, 1);
|
@@ -2677,11 +2819,12 @@ discard block |
||
| 2677 | 2819 | } |
| 2678 | 2820 | } |
| 2679 | 2821 | } |
| 2680 | - if ($noprint) |
|
| 2681 | - return $out; |
|
| 2682 | - else |
|
| 2683 | - print $out; |
|
| 2684 | -} |
|
| 2822 | + if ($noprint) { |
|
| 2823 | + return $out; |
|
| 2824 | + } else { |
|
| 2825 | + print $out; |
|
| 2826 | + } |
|
| 2827 | + } |
|
| 2685 | 2828 | |
| 2686 | 2829 | /** |
| 2687 | 2830 | * Return true if email syntax is ok |
@@ -2692,10 +2835,12 @@ discard block |
||
| 2692 | 2835 | */ |
| 2693 | 2836 | function isValidEmail($address, $acceptsupervisorkey = 0) |
| 2694 | 2837 | {
|
| 2695 | - if ($acceptsupervisorkey && $address == '__SUPERVISOREMAIL__') |
|
| 2696 | - return true; |
|
| 2697 | - if (filter_var($address, FILTER_VALIDATE_EMAIL)) |
|
| 2698 | - return true; |
|
| 2838 | + if ($acceptsupervisorkey && $address == '__SUPERVISOREMAIL__') { |
|
| 2839 | + return true; |
|
| 2840 | + } |
|
| 2841 | + if (filter_var($address, FILTER_VALIDATE_EMAIL)) { |
|
| 2842 | + return true; |
|
| 2843 | + } |
|
| 2699 | 2844 | |
| 2700 | 2845 | return false; |
| 2701 | 2846 | } |
@@ -2717,10 +2862,12 @@ discard block |
||
| 2717 | 2862 | $mxhosts = array(); |
| 2718 | 2863 | $weight = array(); |
| 2719 | 2864 | getmxrr(idn_to_ascii($domain), $mxhosts, $weight); |
| 2720 | - if (count($mxhosts) > 1) |
|
| 2721 | - return 1; |
|
| 2722 | - if (count($mxhosts) == 1 && !empty($mxhosts[0])) |
|
| 2723 | - return 1; |
|
| 2865 | + if (count($mxhosts) > 1) { |
|
| 2866 | + return 1; |
|
| 2867 | + } |
|
| 2868 | + if (count($mxhosts) == 1 && !empty($mxhosts[0])) { |
|
| 2869 | + return 1; |
|
| 2870 | + } |
|
| 2724 | 2871 | |
| 2725 | 2872 | return 0; |
| 2726 | 2873 | } |
@@ -2749,11 +2896,12 @@ discard block |
||
| 2749 | 2896 | */ |
| 2750 | 2897 | function dol_strlen($string, $stringencoding = 'UTF-8') |
| 2751 | 2898 | {
|
| 2752 | - if (function_exists('mb_strlen'))
|
|
| 2753 | - return mb_strlen($string, $stringencoding); |
|
| 2754 | - else |
|
| 2755 | - return strlen($string); |
|
| 2756 | -} |
|
| 2899 | + if (function_exists('mb_strlen')) { |
|
| 2900 | + return mb_strlen($string, $stringencoding); |
|
| 2901 | + } else { |
|
| 2902 | + return strlen($string); |
|
| 2903 | + } |
|
| 2904 | + } |
|
| 2757 | 2905 | |
| 2758 | 2906 | /** |
| 2759 | 2907 | * Make a substring. Works even if mbstring module is not enabled for better compatibility. |
@@ -2769,8 +2917,9 @@ discard block |
||
| 2769 | 2917 | {
|
| 2770 | 2918 | global $langs; |
| 2771 | 2919 | |
| 2772 | - if (empty($stringencoding)) |
|
| 2773 | - $stringencoding = $langs->charset_output; |
|
| 2920 | + if (empty($stringencoding)) { |
|
| 2921 | + $stringencoding = $langs->charset_output; |
|
| 2922 | + } |
|
| 2774 | 2923 | |
| 2775 | 2924 | $ret = ''; |
| 2776 | 2925 | if (empty($trunconbytes)) {
|
@@ -2806,49 +2955,56 @@ discard block |
||
| 2806 | 2955 | {
|
| 2807 | 2956 | global $conf; |
| 2808 | 2957 | |
| 2809 | - if ($size == 0 || !empty($conf->global->MAIN_DISABLE_TRUNC)) |
|
| 2810 | - return $string; |
|
| 2958 | + if ($size == 0 || !empty($conf->global->MAIN_DISABLE_TRUNC)) { |
|
| 2959 | + return $string; |
|
| 2960 | + } |
|
| 2811 | 2961 | |
| 2812 | - if (empty($stringencoding)) |
|
| 2813 | - $stringencoding = 'UTF-8'; |
|
| 2962 | + if (empty($stringencoding)) { |
|
| 2963 | + $stringencoding = 'UTF-8'; |
|
| 2964 | + } |
|
| 2814 | 2965 | // reduce for small screen |
| 2815 | - if ($conf->dol_optimize_smallscreen == 1 && $display == 1) |
|
| 2816 | - $size = round($size / 3); |
|
| 2966 | + if ($conf->dol_optimize_smallscreen == 1 && $display == 1) { |
|
| 2967 | + $size = round($size / 3); |
|
| 2968 | + } |
|
| 2817 | 2969 | |
| 2818 | 2970 | // We go always here |
| 2819 | 2971 | if ($trunc == 'right') {
|
| 2820 | 2972 | $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; |
| 2821 | - if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... |
|
| 2822 | - return dol_substr($newstring, 0, $size, $stringencoding) . ($nodot ? '' : '...'); |
|
| 2823 | - else |
|
| 2824 | - //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string; |
|
| 2825 | - return $string; |
|
| 2826 | - } |
|
| 2827 | - elseif ($trunc == 'middle') {
|
|
| 2973 | + if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) { |
|
| 2974 | + // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... |
|
| 2975 | + return dol_substr($newstring, 0, $size, $stringencoding) . ($nodot ? '' : '...'); |
|
| 2976 | + } else { |
|
| 2977 | + //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string; |
|
| 2978 | + return $string; |
|
| 2979 | + } |
|
| 2980 | + } elseif ($trunc == 'middle') {
|
|
| 2828 | 2981 | $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; |
| 2829 | 2982 | if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > ($size + 1)) {
|
| 2830 | 2983 | $size1 = round($size / 2); |
| 2831 | 2984 | $size2 = round($size / 2); |
| 2832 | 2985 | return dol_substr($newstring, 0, $size1, $stringencoding) . '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding); |
| 2833 | - } else |
|
| 2834 | - return $string; |
|
| 2835 | - } |
|
| 2836 | - elseif ($trunc == 'left') {
|
|
| 2986 | + } else { |
|
| 2987 | + return $string; |
|
| 2988 | + } |
|
| 2989 | + } elseif ($trunc == 'left') {
|
|
| 2837 | 2990 | $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; |
| 2838 | - if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... |
|
| 2839 | - return '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding); |
|
| 2840 | - else |
|
| 2841 | - return $string; |
|
| 2842 | - } |
|
| 2843 | - elseif ($trunc == 'wrap') {
|
|
| 2991 | + if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) { |
|
| 2992 | + // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... |
|
| 2993 | + return '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding); |
|
| 2994 | + } else { |
|
| 2995 | + return $string; |
|
| 2996 | + } |
|
| 2997 | + } elseif ($trunc == 'wrap') {
|
|
| 2844 | 2998 | $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; |
| 2845 | - if (dol_strlen($newstring, $stringencoding) > ($size + 1)) |
|
| 2846 | - return dol_substr($newstring, 0, $size, $stringencoding) . "\n" . dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc); |
|
| 2847 | - else |
|
| 2848 | - return $string; |
|
| 2849 | - } else |
|
| 2850 | - return 'BadParam3CallingDolTrunc'; |
|
| 2851 | -} |
|
| 2999 | + if (dol_strlen($newstring, $stringencoding) > ($size + 1)) { |
|
| 3000 | + return dol_substr($newstring, 0, $size, $stringencoding) . "\n" . dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc); |
|
| 3001 | + } else { |
|
| 3002 | + return $string; |
|
| 3003 | + } |
|
| 3004 | + } else { |
|
| 3005 | + return 'BadParam3CallingDolTrunc'; |
|
| 3006 | + } |
|
| 3007 | + } |
|
| 2852 | 3008 | |
| 2853 | 3009 | /** |
| 2854 | 3010 | * Show picto whatever it's its name (generic function) |
@@ -3057,8 +3213,9 @@ discard block |
||
| 3057 | 3213 | {
|
| 3058 | 3214 | global $conf; |
| 3059 | 3215 | |
| 3060 | - if (!preg_match('/(\.png|\.gif)$/i', $picto))
|
|
| 3061 | - $picto .= '.png'; |
|
| 3216 | + if (!preg_match('/(\.png|\.gif)$/i', $picto)) { |
|
| 3217 | + $picto .= '.png'; |
|
| 3218 | + } |
|
| 3062 | 3219 | |
| 3063 | 3220 | //$path = DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/weather/' . $picto; |
| 3064 | 3221 | $path = DOL_BASE_URI . '/theme/' . $conf->theme . '/img/weather/' . $picto; |
@@ -3080,19 +3237,21 @@ discard block |
||
| 3080 | 3237 | {
|
| 3081 | 3238 | global $conf; |
| 3082 | 3239 | |
| 3083 | - if (!preg_match('/(\.png|\.gif)$/i', $picto))
|
|
| 3084 | - $picto .= '.png'; |
|
| 3240 | + if (!preg_match('/(\.png|\.gif)$/i', $picto)) { |
|
| 3241 | + $picto .= '.png'; |
|
| 3242 | + } |
|
| 3085 | 3243 | |
| 3086 | - if ($pictoisfullpath) |
|
| 3087 | - $path = $picto; |
|
| 3088 | - else {
|
|
| 3244 | + if ($pictoisfullpath) { |
|
| 3245 | + $path = $picto; |
|
| 3246 | + } else {
|
|
| 3089 | 3247 | $path = DOL_URL_ROOT . '/theme/common/' . $picto; |
| 3090 | 3248 | |
| 3091 | 3249 | if (!empty($conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS)) {
|
| 3092 | 3250 | $themepath = DOL_BASE_PATH . 'theme/' . $conf->theme . '/img/' . $picto; |
| 3093 | 3251 | |
| 3094 | - if (file_exists($themepath)) |
|
| 3095 | - $path = $themepath; |
|
| 3252 | + if (file_exists($themepath)) { |
|
| 3253 | + $path = $themepath; |
|
| 3254 | + } |
|
| 3096 | 3255 | } |
| 3097 | 3256 | } |
| 3098 | 3257 | |
@@ -3131,8 +3290,9 @@ discard block |
||
| 3131 | 3290 | $numaction = 0; |
| 3132 | 3291 | } |
| 3133 | 3292 | } |
| 3134 | - if (!is_numeric($numaction)) |
|
| 3135 | - $numaction = 0; |
|
| 3293 | + if (!is_numeric($numaction)) { |
|
| 3294 | + $numaction = 0; |
|
| 3295 | + } |
|
| 3136 | 3296 | |
| 3137 | 3297 | return img_picto($titlealt, 'stcomm' . $numaction . '.png'); |
| 3138 | 3298 | } |
@@ -3148,8 +3308,9 @@ discard block |
||
| 3148 | 3308 | {
|
| 3149 | 3309 | global $conf, $langs; |
| 3150 | 3310 | |
| 3151 | - if ($titlealt == 'default') |
|
| 3152 | - $titlealt = $langs->trans('Show');
|
|
| 3311 | + if ($titlealt == 'default') { |
|
| 3312 | + $titlealt = $langs->trans('Show'); |
|
| 3313 | + } |
|
| 3153 | 3314 | |
| 3154 | 3315 | return img_picto($titlealt, 'pdf' . $size . '.png'); |
| 3155 | 3316 | } |
@@ -3165,8 +3326,9 @@ discard block |
||
| 3165 | 3326 | {
|
| 3166 | 3327 | global $conf, $langs; |
| 3167 | 3328 | |
| 3168 | - if ($titlealt == 'default') |
|
| 3169 | - $titlealt = $langs->trans('Add');
|
|
| 3329 | + if ($titlealt == 'default') { |
|
| 3330 | + $titlealt = $langs->trans('Add'); |
|
| 3331 | + } |
|
| 3170 | 3332 | |
| 3171 | 3333 | return img_picto($titlealt, 'edit_add.png', $other); |
| 3172 | 3334 | } |
@@ -3182,8 +3344,9 @@ discard block |
||
| 3182 | 3344 | {
|
| 3183 | 3345 | global $conf, $langs; |
| 3184 | 3346 | |
| 3185 | - if ($titlealt == 'default') |
|
| 3186 | - $titlealt = $langs->trans('Remove');
|
|
| 3347 | + if ($titlealt == 'default') { |
|
| 3348 | + $titlealt = $langs->trans('Remove'); |
|
| 3349 | + } |
|
| 3187 | 3350 | |
| 3188 | 3351 | return img_picto($titlealt, 'edit_remove.png', $other); |
| 3189 | 3352 | } |
@@ -3200,8 +3363,9 @@ discard block |
||
| 3200 | 3363 | {
|
| 3201 | 3364 | global $conf, $langs; |
| 3202 | 3365 | |
| 3203 | - if ($titlealt == 'default') |
|
| 3204 | - $titlealt = $langs->trans('Modify');
|
|
| 3366 | + if ($titlealt == 'default') { |
|
| 3367 | + $titlealt = $langs->trans('Modify'); |
|
| 3368 | + } |
|
| 3205 | 3369 | |
| 3206 | 3370 | return img_picto($titlealt, 'edit.png', ($float ? 'style="float: ' . ($langs->tab_translate["DIRECTION"] == 'rtl' ? 'left' : 'right') . '"' : "") . ($other ? ' ' . $other : '')); |
| 3207 | 3371 | } |
@@ -3218,8 +3382,9 @@ discard block |
||
| 3218 | 3382 | {
|
| 3219 | 3383 | global $conf, $langs; |
| 3220 | 3384 | |
| 3221 | - if ($titlealt == 'default') |
|
| 3222 | - $titlealt = $langs->trans('View');
|
|
| 3385 | + if ($titlealt == 'default') { |
|
| 3386 | + $titlealt = $langs->trans('View'); |
|
| 3387 | + } |
|
| 3223 | 3388 | |
| 3224 | 3389 | $moreatt = ($float ? 'style="float: right" ' : '') . $other; |
| 3225 | 3390 | |
@@ -3237,8 +3402,9 @@ discard block |
||
| 3237 | 3402 | {
|
| 3238 | 3403 | global $conf, $langs; |
| 3239 | 3404 | |
| 3240 | - if ($titlealt == 'default') |
|
| 3241 | - $titlealt = $langs->trans('Delete');
|
|
| 3405 | + if ($titlealt == 'default') { |
|
| 3406 | + $titlealt = $langs->trans('Delete'); |
|
| 3407 | + } |
|
| 3242 | 3408 | |
| 3243 | 3409 | return img_picto($titlealt, 'delete.png', $other); |
| 3244 | 3410 | //return '<span class="fa fa-trash fa-2x fa-fw" style="font-size: 1.7em;" title="'.$titlealt.'"></span>'; |
@@ -3254,8 +3420,9 @@ discard block |
||
| 3254 | 3420 | function img_printer($titlealt = "default", $other = '') |
| 3255 | 3421 | {
|
| 3256 | 3422 | global $conf, $langs; |
| 3257 | - if ($titlealt == "default") |
|
| 3258 | - $titlealt = $langs->trans("Print");
|
|
| 3423 | + if ($titlealt == "default") { |
|
| 3424 | + $titlealt = $langs->trans("Print"); |
|
| 3425 | + } |
|
| 3259 | 3426 | return img_picto($titlealt, 'printer.png', $other); |
| 3260 | 3427 | } |
| 3261 | 3428 | |
@@ -3270,8 +3437,9 @@ discard block |
||
| 3270 | 3437 | {
|
| 3271 | 3438 | global $conf, $langs; |
| 3272 | 3439 | |
| 3273 | - if ($titlealt == 'default') |
|
| 3274 | - $titlealt = $langs->trans('Split');
|
|
| 3440 | + if ($titlealt == 'default') { |
|
| 3441 | + $titlealt = $langs->trans('Split'); |
|
| 3442 | + } |
|
| 3275 | 3443 | |
| 3276 | 3444 | return img_picto($titlealt, 'split.png', $other); |
| 3277 | 3445 | } |
@@ -3288,10 +3456,11 @@ discard block |
||
| 3288 | 3456 | global $conf, $langs; |
| 3289 | 3457 | |
| 3290 | 3458 | if ($usealttitle) {
|
| 3291 | - if (is_string($usealttitle)) |
|
| 3292 | - $usealttitle = dol_escape_htmltag($usealttitle); |
|
| 3293 | - else |
|
| 3294 | - $usealttitle = $langs->trans('Info');
|
|
| 3459 | + if (is_string($usealttitle)) { |
|
| 3460 | + $usealttitle = dol_escape_htmltag($usealttitle); |
|
| 3461 | + } else { |
|
| 3462 | + $usealttitle = $langs->trans('Info'); |
|
| 3463 | + } |
|
| 3295 | 3464 | } |
| 3296 | 3465 | |
| 3297 | 3466 | return img_picto($usealttitle, 'info.png', 'style="vertical-align: middle;' . ($usehelpcursor == 1 ? ' cursor: help' : ($usehelpcursor == 2 ? ' cursor: pointer' : '')) . '"'); |
@@ -3307,8 +3476,9 @@ discard block |
||
| 3307 | 3476 | {
|
| 3308 | 3477 | global $conf, $langs; |
| 3309 | 3478 | |
| 3310 | - if ($titlealt == 'default') |
|
| 3311 | - $titlealt = $langs->trans('Informations');
|
|
| 3479 | + if ($titlealt == 'default') { |
|
| 3480 | + $titlealt = $langs->trans('Informations'); |
|
| 3481 | + } |
|
| 3312 | 3482 | |
| 3313 | 3483 | return img_picto($titlealt, 'info.png', 'style="vertical-align: middle;"'); |
| 3314 | 3484 | } |
@@ -3324,8 +3494,9 @@ discard block |
||
| 3324 | 3494 | {
|
| 3325 | 3495 | global $conf, $langs; |
| 3326 | 3496 | |
| 3327 | - if ($titlealt == 'default') |
|
| 3328 | - $titlealt = $langs->trans('Warning');
|
|
| 3497 | + if ($titlealt == 'default') { |
|
| 3498 | + $titlealt = $langs->trans('Warning'); |
|
| 3499 | + } |
|
| 3329 | 3500 | |
| 3330 | 3501 | //return '<div class="imglatecoin">'.img_picto($titlealt, 'warning_white.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')).'</div>'; |
| 3331 | 3502 | return img_picto($titlealt, 'warning.png', 'class="pictowarning valignmiddle"' . ($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' ' . $moreatt) : '')); |
@@ -3341,8 +3512,9 @@ discard block |
||
| 3341 | 3512 | {
|
| 3342 | 3513 | global $conf, $langs; |
| 3343 | 3514 | |
| 3344 | - if ($titlealt == 'default') |
|
| 3345 | - $titlealt = $langs->trans('Error');
|
|
| 3515 | + if ($titlealt == 'default') { |
|
| 3516 | + $titlealt = $langs->trans('Error'); |
|
| 3517 | + } |
|
| 3346 | 3518 | |
| 3347 | 3519 | return img_picto($titlealt, 'error.png', 'class="valigntextbottom"'); |
| 3348 | 3520 | } |
@@ -3358,8 +3530,9 @@ discard block |
||
| 3358 | 3530 | {
|
| 3359 | 3531 | global $conf, $langs; |
| 3360 | 3532 | |
| 3361 | - if ($titlealt == 'default') |
|
| 3362 | - $titlealt = $langs->trans('Next');
|
|
| 3533 | + if ($titlealt == 'default') { |
|
| 3534 | + $titlealt = $langs->trans('Next'); |
|
| 3535 | + } |
|
| 3363 | 3536 | |
| 3364 | 3537 | //return img_picto($titlealt, 'next.png', $moreatt); |
| 3365 | 3538 | return '<span class="fa fa-chevron-right paddingright paddingleft" title="' . dol_escape_htmltag($titlealt) . '"></span>'; |
@@ -3376,8 +3549,9 @@ discard block |
||
| 3376 | 3549 | {
|
| 3377 | 3550 | global $conf, $langs; |
| 3378 | 3551 | |
| 3379 | - if ($titlealt == 'default') |
|
| 3380 | - $titlealt = $langs->trans('Previous');
|
|
| 3552 | + if ($titlealt == 'default') { |
|
| 3553 | + $titlealt = $langs->trans('Previous'); |
|
| 3554 | + } |
|
| 3381 | 3555 | |
| 3382 | 3556 | //return img_picto($titlealt, 'previous.png', $moreatt); |
| 3383 | 3557 | return '<span class="fa fa-chevron-left paddingright paddingleft" title="' . dol_escape_htmltag($titlealt) . '"></span>'; |
@@ -3395,8 +3569,9 @@ discard block |
||
| 3395 | 3569 | {
|
| 3396 | 3570 | global $conf, $langs; |
| 3397 | 3571 | |
| 3398 | - if ($titlealt == 'default') |
|
| 3399 | - $titlealt = $langs->trans('Down');
|
|
| 3572 | + if ($titlealt == 'default') { |
|
| 3573 | + $titlealt = $langs->trans('Down'); |
|
| 3574 | + } |
|
| 3400 | 3575 | |
| 3401 | 3576 | return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown' . ($moreclass ? " " . $moreclass : "") . '"'); |
| 3402 | 3577 | } |
@@ -3413,8 +3588,9 @@ discard block |
||
| 3413 | 3588 | {
|
| 3414 | 3589 | global $conf, $langs; |
| 3415 | 3590 | |
| 3416 | - if ($titlealt == 'default') |
|
| 3417 | - $titlealt = $langs->trans('Up');
|
|
| 3591 | + if ($titlealt == 'default') { |
|
| 3592 | + $titlealt = $langs->trans('Up'); |
|
| 3593 | + } |
|
| 3418 | 3594 | |
| 3419 | 3595 | return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup' . ($moreclass ? " " . $moreclass : "") . '"'); |
| 3420 | 3596 | } |
@@ -3431,8 +3607,9 @@ discard block |
||
| 3431 | 3607 | {
|
| 3432 | 3608 | global $conf, $langs; |
| 3433 | 3609 | |
| 3434 | - if ($titlealt == 'default') |
|
| 3435 | - $titlealt = $langs->trans('Left');
|
|
| 3610 | + if ($titlealt == 'default') { |
|
| 3611 | + $titlealt = $langs->trans('Left'); |
|
| 3612 | + } |
|
| 3436 | 3613 | |
| 3437 | 3614 | return img_picto($titlealt, ($selected ? '1leftarrow_selected.png' : '1leftarrow.png'), $moreatt); |
| 3438 | 3615 | } |
@@ -3449,8 +3626,9 @@ discard block |
||
| 3449 | 3626 | {
|
| 3450 | 3627 | global $conf, $langs; |
| 3451 | 3628 | |
| 3452 | - if ($titlealt == 'default') |
|
| 3453 | - $titlealt = $langs->trans('Right');
|
|
| 3629 | + if ($titlealt == 'default') { |
|
| 3630 | + $titlealt = $langs->trans('Right'); |
|
| 3631 | + } |
|
| 3454 | 3632 | |
| 3455 | 3633 | return img_picto($titlealt, ($selected ? '1rightarrow_selected.png' : '1rightarrow.png'), $moreatt); |
| 3456 | 3634 | } |
@@ -3466,11 +3644,13 @@ discard block |
||
| 3466 | 3644 | {
|
| 3467 | 3645 | global $conf, $langs; |
| 3468 | 3646 | |
| 3469 | - if ($titlealt == 'default') |
|
| 3470 | - $titlealt = $langs->trans('Active');
|
|
| 3647 | + if ($titlealt == 'default') { |
|
| 3648 | + $titlealt = $langs->trans('Active'); |
|
| 3649 | + } |
|
| 3471 | 3650 | |
| 3472 | - if ($allow == 1) |
|
| 3473 | - return img_picto($titlealt, 'tick.png'); |
|
| 3651 | + if ($allow == 1) { |
|
| 3652 | + return img_picto($titlealt, 'tick.png'); |
|
| 3653 | + } |
|
| 3474 | 3654 | |
| 3475 | 3655 | return '-'; |
| 3476 | 3656 | } |
@@ -3518,8 +3698,9 @@ discard block |
||
| 3518 | 3698 | $mimeimg = dol_mimetype($file, '', 2); |
| 3519 | 3699 | $mimefa = dol_mimetype($file, '', 4); |
| 3520 | 3700 | |
| 3521 | - if (empty($titlealt)) |
|
| 3522 | - $titlealt = 'Mime type: ' . $mimetype; |
|
| 3701 | + if (empty($titlealt)) { |
|
| 3702 | + $titlealt = 'Mime type: ' . $mimetype; |
|
| 3703 | + } |
|
| 3523 | 3704 | |
| 3524 | 3705 | //return img_picto_common($titlealt, 'mime/'.$mimeimg, 'class="'.$morecss.'"'); |
| 3525 | 3706 | return '<i class="fa fa-' . $mimefa . ' paddingright"></i>'; |
@@ -3541,13 +3722,15 @@ discard block |
||
| 3541 | 3722 | |
| 3542 | 3723 | global $conf, $langs; |
| 3543 | 3724 | |
| 3544 | - if ($titlealt == 'default') |
|
| 3545 | - $titlealt = $langs->trans('Call');
|
|
| 3725 | + if ($titlealt == 'default') { |
|
| 3726 | + $titlealt = $langs->trans('Call'); |
|
| 3727 | + } |
|
| 3546 | 3728 | |
| 3547 | - if ($option == 1) |
|
| 3548 | - $img = 'call'; |
|
| 3549 | - else |
|
| 3550 | - $img = 'call_out'; |
|
| 3729 | + if ($option == 1) { |
|
| 3730 | + $img = 'call'; |
|
| 3731 | + } else { |
|
| 3732 | + $img = 'call_out'; |
|
| 3733 | + } |
|
| 3551 | 3734 | |
| 3552 | 3735 | return img_picto($titlealt, $img); |
| 3553 | 3736 | } |
@@ -3563,8 +3746,9 @@ discard block |
||
| 3563 | 3746 | {
|
| 3564 | 3747 | global $conf, $langs; |
| 3565 | 3748 | |
| 3566 | - if ($titlealt == 'default') |
|
| 3567 | - $titlealt = $langs->trans('Search');
|
|
| 3749 | + if ($titlealt == 'default') { |
|
| 3750 | + $titlealt = $langs->trans('Search'); |
|
| 3751 | + } |
|
| 3568 | 3752 | |
| 3569 | 3753 | $img = img_picto($titlealt, 'search.png', $other, false, 1); |
| 3570 | 3754 | |
@@ -3585,8 +3769,9 @@ discard block |
||
| 3585 | 3769 | {
|
| 3586 | 3770 | global $conf, $langs; |
| 3587 | 3771 | |
| 3588 | - if ($titlealt == 'default') |
|
| 3589 | - $titlealt = $langs->trans('Search');
|
|
| 3772 | + if ($titlealt == 'default') { |
|
| 3773 | + $titlealt = $langs->trans('Search'); |
|
| 3774 | + } |
|
| 3590 | 3775 | |
| 3591 | 3776 | $img = img_picto($titlealt, 'searchclear.png', $other, false, 1); |
| 3592 | 3777 | |
@@ -3648,14 +3833,16 @@ discard block |
||
| 3648 | 3833 | |
| 3649 | 3834 | if ($_SERVER['DOCUMENT_ROOT']) { // Mode web
|
| 3650 | 3835 | $out .= $langs->trans("DolibarrHasDetectedError") . ".<br>\n";
|
| 3651 | - if (!empty($conf->global->MAIN_FEATURES_LEVEL)) |
|
| 3652 | - $out .= "You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.<br>\n"; |
|
| 3836 | + if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { |
|
| 3837 | + $out .= "You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.<br>\n"; |
|
| 3838 | + } |
|
| 3653 | 3839 | $out .= $langs->trans("InformationToHelpDiagnose") . ":<br>\n";
|
| 3654 | 3840 | |
| 3655 | 3841 | $out .= "<b>" . $langs->trans("Date") . ":</b> " . dol_print_date(time(), 'dayhourlog') . "<br>\n";
|
| 3656 | 3842 | $out .= "<b>" . $langs->trans("Dolibarr") . ":</b> " . DOL_VERSION . "<br>\n";
|
| 3657 | - if (isset($conf->global->MAIN_FEATURES_LEVEL)) |
|
| 3658 | - $out .= "<b>" . $langs->trans("LevelOfFeature") . ":</b> " . $conf->global->MAIN_FEATURES_LEVEL . "<br>\n";
|
|
| 3843 | + if (isset($conf->global->MAIN_FEATURES_LEVEL)) { |
|
| 3844 | + $out .= "<b>" . $langs->trans("LevelOfFeature") . ":</b> " . $conf->global->MAIN_FEATURES_LEVEL . "<br>\n"; |
|
| 3845 | + } |
|
| 3659 | 3846 | if (function_exists("phpversion")) {
|
| 3660 | 3847 | $out .= "<b>" . $langs->trans("PHP") . ":</b> " . phpversion() . "<br>\n";
|
| 3661 | 3848 | } |
@@ -3698,18 +3885,20 @@ discard block |
||
| 3698 | 3885 | $langs->load("errors");
|
| 3699 | 3886 | |
| 3700 | 3887 | // Merge all into $errors array |
| 3701 | - if (is_array($error) && is_array($errors)) |
|
| 3702 | - $errors = array_merge($error, $errors); |
|
| 3703 | - elseif (is_array($error)) |
|
| 3704 | - $errors = $error; |
|
| 3705 | - elseif (is_array($errors)) |
|
| 3706 | - $errors = array_merge(array($error), $errors); |
|
| 3707 | - else |
|
| 3708 | - $errors = array_merge(array($error)); |
|
| 3888 | + if (is_array($error) && is_array($errors)) { |
|
| 3889 | + $errors = array_merge($error, $errors); |
|
| 3890 | + } elseif (is_array($error)) { |
|
| 3891 | + $errors = $error; |
|
| 3892 | + } elseif (is_array($errors)) { |
|
| 3893 | + $errors = array_merge(array($error), $errors); |
|
| 3894 | + } else { |
|
| 3895 | + $errors = array_merge(array($error)); |
|
| 3896 | + } |
|
| 3709 | 3897 | |
| 3710 | 3898 | foreach ($errors as $msg) {
|
| 3711 | - if (empty($msg)) |
|
| 3712 | - continue; |
|
| 3899 | + if (empty($msg)) { |
|
| 3900 | + continue; |
|
| 3901 | + } |
|
| 3713 | 3902 | if ($_SERVER['DOCUMENT_ROOT']) { // Mode web
|
| 3714 | 3903 | $out .= "<b>" . $langs->trans("Message") . ":</b> " . dol_escape_htmltag($msg) . "<br>\n";
|
| 3715 | 3904 | } else { // Mode CLI
|
@@ -3727,9 +3916,9 @@ discard block |
||
| 3727 | 3916 | $out .= "<br>\n"; |
| 3728 | 3917 | } |
| 3729 | 3918 | |
| 3730 | - if (empty($dolibarr_main_prod)) |
|
| 3731 | - print $out; |
|
| 3732 | - else {
|
|
| 3919 | + if (empty($dolibarr_main_prod)) { |
|
| 3920 | + print $out; |
|
| 3921 | + } else {
|
|
| 3733 | 3922 | print $langs->trans("DolibarrHasDetectedError") . '. ';
|
| 3734 | 3923 | print $langs->trans("YouCanSetOptionDolibarrMainProdToZero");
|
| 3735 | 3924 | define("MAIN_CORE_ERROR", 1);
|
@@ -3752,16 +3941,18 @@ discard block |
||
| 3752 | 3941 | {
|
| 3753 | 3942 | global $langs, $conf; |
| 3754 | 3943 | |
| 3755 | - if (empty($email)) |
|
| 3756 | - $email = $conf->global->MAIN_INFO_SOCIETE_MAIL; |
|
| 3944 | + if (empty($email)) { |
|
| 3945 | + $email = $conf->global->MAIN_INFO_SOCIETE_MAIL; |
|
| 3946 | + } |
|
| 3757 | 3947 | |
| 3758 | 3948 | $langs->load("errors");
|
| 3759 | 3949 | $now = dol_now(); |
| 3760 | 3950 | |
| 3761 | 3951 | print '<br><div class="center login_main_message"><div class="' . $morecss . '">'; |
| 3762 | 3952 | print $langs->trans("ErrorContactEMail", $email, $prefixcode . dol_print_date($now, '%Y%m%d'));
|
| 3763 | - if ($errormessage) |
|
| 3764 | - print '<br><br>' . $errormessage; |
|
| 3953 | + if ($errormessage) { |
|
| 3954 | + print '<br><br>' . $errormessage; |
|
| 3955 | + } |
|
| 3765 | 3956 | if (is_array($errormessages) && count($errormessages)) {
|
| 3766 | 3957 | foreach ($errormessages as $mesgtoshow) {
|
| 3767 | 3958 | print '<br><br>' . $mesgtoshow; |
@@ -4004,12 +4195,15 @@ discard block |
||
| 4004 | 4195 | $savtotalnboflines = $totalnboflines; |
| 4005 | 4196 | $totalnboflines = abs($totalnboflines); |
| 4006 | 4197 | |
| 4007 | - if ($picto == 'setup') |
|
| 4008 | - $picto = 'title_setup.png'; |
|
| 4009 | - if (($conf->browser->name == 'ie') && $picto == 'title_generic.png') |
|
| 4010 | - $picto = 'title.gif'; |
|
| 4011 | - if ($limit < 0) |
|
| 4012 | - $limit = $conf->liste_limit; |
|
| 4198 | + if ($picto == 'setup') { |
|
| 4199 | + $picto = 'title_setup.png'; |
|
| 4200 | + } |
|
| 4201 | + if (($conf->browser->name == 'ie') && $picto == 'title_generic.png') { |
|
| 4202 | + $picto = 'title.gif'; |
|
| 4203 | + } |
|
| 4204 | + if ($limit < 0) { |
|
| 4205 | + $limit = $conf->liste_limit; |
|
| 4206 | + } |
|
| 4013 | 4207 | if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) {
|
| 4014 | 4208 | $nextpage = 1; |
| 4015 | 4209 | } else {
|
@@ -4023,11 +4217,13 @@ discard block |
||
| 4023 | 4217 | // Left |
| 4024 | 4218 | //if ($picto && $titre) print '<td class="nobordernopadding hideonsmartphone" width="40" align="left" valign="middle">'.img_picto('', $picto, 'id="pictotitle"', $pictoisfullpath).'</td>';
|
| 4025 | 4219 | print '<td class="nobordernopadding valignmiddle">'; |
| 4026 | - if ($picto && $titre) |
|
| 4027 | - print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh pictotitle widthpictotitle"', $pictoisfullpath);
|
|
| 4220 | + if ($picto && $titre) { |
|
| 4221 | + print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh pictotitle widthpictotitle"', $pictoisfullpath); |
|
| 4222 | + } |
|
| 4028 | 4223 | print '<div class="titre inline-block">' . $titre; |
| 4029 | - if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') |
|
| 4030 | - print ' (' . $totalnboflines . ')';
|
|
| 4224 | + if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') { |
|
| 4225 | + print ' (' . $totalnboflines . ')'; |
|
| 4226 | + } |
|
| 4031 | 4227 | print '</div></td>'; |
| 4032 | 4228 | |
| 4033 | 4229 | // Center |
@@ -4037,10 +4233,12 @@ discard block |
||
| 4037 | 4233 | |
| 4038 | 4234 | // Right |
| 4039 | 4235 | print '<td class="nobordernopadding valignmiddle" align="right">'; |
| 4040 | - if ($sortfield) |
|
| 4041 | - $options .= "&sortfield=" . urlencode($sortfield); |
|
| 4042 | - if ($sortorder) |
|
| 4043 | - $options .= "&sortorder=" . urlencode($sortorder); |
|
| 4236 | + if ($sortfield) { |
|
| 4237 | + $options .= "&sortfield=" . urlencode($sortfield); |
|
| 4238 | + } |
|
| 4239 | + if ($sortorder) { |
|
| 4240 | + $options .= "&sortorder=" . urlencode($sortorder); |
|
| 4241 | + } |
|
| 4044 | 4242 | // Show navigation bar |
| 4045 | 4243 | $pagelist = ''; |
| 4046 | 4244 | if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
|
@@ -4048,10 +4246,11 @@ discard block |
||
| 4048 | 4246 | // Define nb of extra page links before and after selected page + ... + first or last |
| 4049 | 4247 | $maxnbofpage = (empty($conf->dol_optimize_smallscreen) ? 4 : 1); |
| 4050 | 4248 | |
| 4051 | - if ($limit > 0) |
|
| 4052 | - $nbpages = ceil($totalnboflines / $limit); |
|
| 4053 | - else |
|
| 4054 | - $nbpages = 1; |
|
| 4249 | + if ($limit > 0) { |
|
| 4250 | + $nbpages = ceil($totalnboflines / $limit); |
|
| 4251 | + } else { |
|
| 4252 | + $nbpages = 1; |
|
| 4253 | + } |
|
| 4055 | 4254 | $cpt = ($page - $maxnbofpage); |
| 4056 | 4255 | if ($cpt < 0) {
|
| 4057 | 4256 | $cpt = 0; |
@@ -4059,10 +4258,11 @@ discard block |
||
| 4059 | 4258 | |
| 4060 | 4259 | if ($cpt >= 1) {
|
| 4061 | 4260 | $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=0' . $options . '">1</a></li>'; |
| 4062 | - if ($cpt > 2) |
|
| 4063 | - $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>'; |
|
| 4064 | - else if ($cpt == 2) |
|
| 4065 | - $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=1' . $options . '">2</a></li>'; |
|
| 4261 | + if ($cpt > 2) { |
|
| 4262 | + $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>'; |
|
| 4263 | + } else if ($cpt == 2) { |
|
| 4264 | + $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=1' . $options . '">2</a></li>'; |
|
| 4265 | + } |
|
| 4066 | 4266 | } |
| 4067 | 4267 | |
| 4068 | 4268 | do {
|
@@ -4075,14 +4275,14 @@ discard block |
||
| 4075 | 4275 | } while ($cpt < $nbpages && $cpt <= $page + $maxnbofpage); |
| 4076 | 4276 | |
| 4077 | 4277 | if ($cpt < $nbpages) {
|
| 4078 | - if ($cpt < $nbpages - 2) |
|
| 4079 | - $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>'; |
|
| 4080 | - else if ($cpt == $nbpages - 2) |
|
| 4081 | - $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 2) . $options . '">' . ($nbpages - 1) . '</a></li>'; |
|
| 4278 | + if ($cpt < $nbpages - 2) { |
|
| 4279 | + $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>'; |
|
| 4280 | + } else if ($cpt == $nbpages - 2) { |
|
| 4281 | + $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 2) . $options . '">' . ($nbpages - 1) . '</a></li>'; |
|
| 4282 | + } |
|
| 4082 | 4283 | $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 1) . $options . '">' . $nbpages . '</a></li>'; |
| 4083 | 4284 | } |
| 4084 | - } |
|
| 4085 | - else {
|
|
| 4285 | + } else {
|
|
| 4086 | 4286 | $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="active"' : '') . '>' . ($page + 1) . "</li>"; |
| 4087 | 4287 | } |
| 4088 | 4288 | } |
@@ -4118,18 +4318,21 @@ discard block |
||
| 4118 | 4318 | $pagesizechoices = '10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000,5000:5000'; |
| 4119 | 4319 | //$pagesizechoices.=',0:'.$langs->trans("All"); // Not yet supported
|
| 4120 | 4320 | //$pagesizechoices.=',2:2'; |
| 4121 | - if (!empty($conf->global->MAIN_PAGESIZE_CHOICES)) |
|
| 4122 | - $pagesizechoices = $conf->global->MAIN_PAGESIZE_CHOICES; |
|
| 4321 | + if (!empty($conf->global->MAIN_PAGESIZE_CHOICES)) { |
|
| 4322 | + $pagesizechoices = $conf->global->MAIN_PAGESIZE_CHOICES; |
|
| 4323 | + } |
|
| 4123 | 4324 | |
| 4124 | 4325 | print '<li class="pagination">'; |
| 4125 | 4326 | print '<select class="flat selectlimit" name="limit" title="' . dol_escape_htmltag($langs->trans("MaxNbOfRecordPerPage")) . '">';
|
| 4126 | 4327 | $tmpchoice = explode(',', $pagesizechoices);
|
| 4127 | 4328 | $tmpkey = $limit . ':' . $limit; |
| 4128 | - if (!in_array($tmpkey, $tmpchoice)) |
|
| 4129 | - $tmpchoice[] = $tmpkey; |
|
| 4329 | + if (!in_array($tmpkey, $tmpchoice)) { |
|
| 4330 | + $tmpchoice[] = $tmpkey; |
|
| 4331 | + } |
|
| 4130 | 4332 | $tmpkey = $conf->liste_limit . ':' . $conf->liste_limit; |
| 4131 | - if (!in_array($tmpkey, $tmpchoice)) |
|
| 4132 | - $tmpchoice[] = $tmpkey; |
|
| 4333 | + if (!in_array($tmpkey, $tmpchoice)) { |
|
| 4334 | + $tmpchoice[] = $tmpkey; |
|
| 4335 | + } |
|
| 4133 | 4336 | asort($tmpchoice, SORT_NUMERIC); |
| 4134 | 4337 | $found = false; |
| 4135 | 4338 | foreach ($tmpchoice as $val) {
|
@@ -4205,14 +4408,15 @@ discard block |
||
| 4205 | 4408 | } |
| 4206 | 4409 | |
| 4207 | 4410 | // If rate is '9/9/9' we don't change it. If rate is '9.000' we apply price() |
| 4208 | - if (!preg_match('/\//', $rate))
|
|
| 4209 | - $ret = price($rate, 0, '', 0, 0) . ($addpercent ? '%' : ''); |
|
| 4210 | - else {
|
|
| 4411 | + if (!preg_match('/\//', $rate)) { |
|
| 4412 | + $ret = price($rate, 0, '', 0, 0) . ($addpercent ? '%' : ''); |
|
| 4413 | + } else {
|
|
| 4211 | 4414 | // TODO Split on / and output with a price2num to have clean numbers without ton of 000. |
| 4212 | 4415 | $ret = $rate . ($addpercent ? '%' : ''); |
| 4213 | 4416 | } |
| 4214 | - if (($info_bits & 1) && $usestarfornpr >= 0) |
|
| 4215 | - $ret .= ' *'; |
|
| 4417 | + if (($info_bits & 1) && $usestarfornpr >= 0) { |
|
| 4418 | + $ret .= ' *'; |
|
| 4419 | + } |
|
| 4216 | 4420 | $ret .= $morelabel; |
| 4217 | 4421 | return $ret; |
| 4218 | 4422 | } |
@@ -4237,11 +4441,14 @@ discard block |
||
| 4237 | 4441 | global $langs, $conf; |
| 4238 | 4442 | |
| 4239 | 4443 | // Clean parameters |
| 4240 | - if (empty($amount)) |
|
| 4241 | - $amount = 0; // To have a numeric value if amount not defined or = '' |
|
| 4444 | + if (empty($amount)) { |
|
| 4445 | + $amount = 0; |
|
| 4446 | + } |
|
| 4447 | + // To have a numeric value if amount not defined or = '' |
|
| 4242 | 4448 | $amount = (is_numeric($amount) ? $amount : 0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number) |
| 4243 | - if ($rounding < 0) |
|
| 4244 | - $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); |
|
| 4449 | + if ($rounding < 0) { |
|
| 4450 | + $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); |
|
| 4451 | + } |
|
| 4245 | 4452 | $nbdecimal = $rounding; |
| 4246 | 4453 | |
| 4247 | 4454 | // Output separators by default (french) |
@@ -4249,17 +4456,21 @@ discard block |
||
| 4249 | 4456 | $thousand = ' '; |
| 4250 | 4457 | |
| 4251 | 4458 | // If $outlangs not forced, we use use language |
| 4252 | - if (!is_object($outlangs)) |
|
| 4253 | - $outlangs = $langs; |
|
| 4254 | - |
|
| 4255 | - if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal")
|
|
| 4256 | - $dec = $outlangs->transnoentitiesnoconv("SeparatorDecimal");
|
|
| 4257 | - if ($outlangs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand")
|
|
| 4258 | - $thousand = $outlangs->transnoentitiesnoconv("SeparatorThousand");
|
|
| 4259 | - if ($thousand == 'None') |
|
| 4260 | - $thousand = ''; |
|
| 4261 | - else if ($thousand == 'Space') |
|
| 4262 | - $thousand = ' '; |
|
| 4459 | + if (!is_object($outlangs)) { |
|
| 4460 | + $outlangs = $langs; |
|
| 4461 | + } |
|
| 4462 | + |
|
| 4463 | + if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") { |
|
| 4464 | + $dec = $outlangs->transnoentitiesnoconv("SeparatorDecimal"); |
|
| 4465 | + } |
|
| 4466 | + if ($outlangs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") { |
|
| 4467 | + $thousand = $outlangs->transnoentitiesnoconv("SeparatorThousand"); |
|
| 4468 | + } |
|
| 4469 | + if ($thousand == 'None') { |
|
| 4470 | + $thousand = ''; |
|
| 4471 | + } else if ($thousand == 'Space') { |
|
| 4472 | + $thousand = ' '; |
|
| 4473 | + } |
|
| 4263 | 4474 | //print "outlangs=".$outlangs->defaultlang." amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>"; |
| 4264 | 4475 | //print "amount=".$amount."-"; |
| 4265 | 4476 | $amount = str_replace(',', '.', $amount); // should be useless
|
@@ -4271,8 +4482,9 @@ discard block |
||
| 4271 | 4482 | $end = ''; |
| 4272 | 4483 | |
| 4273 | 4484 | // We increase nbdecimal if there is more decimal than asked (to not loose information) |
| 4274 | - if (dol_strlen($decpart) > $nbdecimal) |
|
| 4275 | - $nbdecimal = dol_strlen($decpart); |
|
| 4485 | + if (dol_strlen($decpart) > $nbdecimal) { |
|
| 4486 | + $nbdecimal = dol_strlen($decpart); |
|
| 4487 | + } |
|
| 4276 | 4488 | // Si on depasse max |
| 4277 | 4489 | if ($trunc && $nbdecimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN) {
|
| 4278 | 4490 | $nbdecimal = $conf->global->MAIN_MAX_DECIMALS_SHOWN; |
@@ -4283,8 +4495,9 @@ discard block |
||
| 4283 | 4495 | } |
| 4284 | 4496 | |
| 4285 | 4497 | // If force rounding |
| 4286 | - if ($forcerounding >= 0) |
|
| 4287 | - $nbdecimal = $forcerounding; |
|
| 4498 | + if ($forcerounding >= 0) { |
|
| 4499 | + $nbdecimal = $forcerounding; |
|
| 4500 | + } |
|
| 4288 | 4501 | |
| 4289 | 4502 | // Format number |
| 4290 | 4503 | $output = number_format($amount, $nbdecimal, $dec, $thousand); |
@@ -4295,13 +4508,14 @@ discard block |
||
| 4295 | 4508 | // Add symbol of currency if requested |
| 4296 | 4509 | $cursymbolbefore = $cursymbolafter = ''; |
| 4297 | 4510 | if ($currency_code) {
|
| 4298 | - if ($currency_code == 'auto') |
|
| 4299 | - $currency_code = $conf->currency; |
|
| 4511 | + if ($currency_code == 'auto') { |
|
| 4512 | + $currency_code = $conf->currency; |
|
| 4513 | + } |
|
| 4300 | 4514 | |
| 4301 | 4515 | $listofcurrenciesbefore = array('USD', 'GBP', 'AUD', 'MXN', 'PEN', 'CNY');
|
| 4302 | - if (in_array($currency_code, $listofcurrenciesbefore)) |
|
| 4303 | - $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code); |
|
| 4304 | - else {
|
|
| 4516 | + if (in_array($currency_code, $listofcurrenciesbefore)) { |
|
| 4517 | + $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code); |
|
| 4518 | + } else {
|
|
| 4305 | 4519 | $tmpcur = $outlangs->getCurrencySymbol($currency_code); |
| 4306 | 4520 | $cursymbolafter .= ($tmpcur == $currency_code ? ' ' . $tmpcur : $tmpcur); |
| 4307 | 4521 | } |
@@ -4335,14 +4549,17 @@ discard block |
||
| 4335 | 4549 | // Decimal delimiter for PHP and database SQL requests must be '.' |
| 4336 | 4550 | $dec = ','; |
| 4337 | 4551 | $thousand = ' '; |
| 4338 | - if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal")
|
|
| 4339 | - $dec = $langs->transnoentitiesnoconv("SeparatorDecimal");
|
|
| 4340 | - if ($langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand")
|
|
| 4341 | - $thousand = $langs->transnoentitiesnoconv("SeparatorThousand");
|
|
| 4342 | - if ($thousand == 'None') |
|
| 4343 | - $thousand = ''; |
|
| 4344 | - elseif ($thousand == 'Space') |
|
| 4345 | - $thousand = ' '; |
|
| 4552 | + if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") { |
|
| 4553 | + $dec = $langs->transnoentitiesnoconv("SeparatorDecimal"); |
|
| 4554 | + } |
|
| 4555 | + if ($langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") { |
|
| 4556 | + $thousand = $langs->transnoentitiesnoconv("SeparatorThousand"); |
|
| 4557 | + } |
|
| 4558 | + if ($thousand == 'None') { |
|
| 4559 | + $thousand = ''; |
|
| 4560 | + } elseif ($thousand == 'Space') { |
|
| 4561 | + $thousand = ' '; |
|
| 4562 | + } |
|
| 4346 | 4563 | //print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>"; |
| 4347 | 4564 | // Convert value to universal number format (no thousand separator, '.' as decimal separator) |
| 4348 | 4565 | if ($alreadysqlnb != 1) { // If not a PHP number or unknown, we change format
|
@@ -4358,8 +4575,10 @@ discard block |
||
| 4358 | 4575 | } |
| 4359 | 4576 | //print "QQ".$amount.'<br>'; |
| 4360 | 4577 | // Now make replace (the main goal of function) |
| 4361 | - if ($thousand != ',' && $thousand != '.') |
|
| 4362 | - $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
|
|
| 4578 | + if ($thousand != ',' && $thousand != '.') { |
|
| 4579 | + $amount = str_replace(',', '.', $amount); |
|
| 4580 | + } |
|
| 4581 | + // To accept 2 notations for french users |
|
| 4363 | 4582 | $amount = str_replace(' ', '', $amount); // To avoid spaces
|
| 4364 | 4583 | $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . |
| 4365 | 4584 | $amount = str_replace($dec, '.', $amount); |
@@ -4368,19 +4587,23 @@ discard block |
||
| 4368 | 4587 | // Now, make a rounding if required |
| 4369 | 4588 | if ($rounding) {
|
| 4370 | 4589 | $nbofdectoround = ''; |
| 4371 | - if ($rounding == 'MU') |
|
| 4372 | - $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT; |
|
| 4373 | - elseif ($rounding == 'MT') |
|
| 4374 | - $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT; |
|
| 4375 | - elseif ($rounding == 'MS') |
|
| 4376 | - $nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK; |
|
| 4377 | - elseif (is_numeric($rounding)) |
|
| 4378 | - $nbofdectoround = $rounding; |
|
| 4590 | + if ($rounding == 'MU') { |
|
| 4591 | + $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT; |
|
| 4592 | + } elseif ($rounding == 'MT') { |
|
| 4593 | + $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT; |
|
| 4594 | + } elseif ($rounding == 'MS') { |
|
| 4595 | + $nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK; |
|
| 4596 | + } elseif (is_numeric($rounding)) { |
|
| 4597 | + $nbofdectoround = $rounding; |
|
| 4598 | + } |
|
| 4379 | 4599 | //print "RR".$amount.' - '.$nbofdectoround.'<br>'; |
| 4380 | - if (dol_strlen($nbofdectoround)) |
|
| 4381 | - $amount = round($amount, $nbofdectoround); // $nbofdectoround can be 0. |
|
| 4382 | - else |
|
| 4383 | - return 'ErrorBadParameterProvidedToFunction'; |
|
| 4600 | + if (dol_strlen($nbofdectoround)) { |
|
| 4601 | + $amount = round($amount, $nbofdectoround); |
|
| 4602 | + } |
|
| 4603 | + // $nbofdectoround can be 0. |
|
| 4604 | + else { |
|
| 4605 | + return 'ErrorBadParameterProvidedToFunction'; |
|
| 4606 | + } |
|
| 4384 | 4607 | //print 'SS'.$amount.' - '.$nbofdec.' - '.$dec.' - '.$thousand.' - '.$nbofdectoround.'<br>'; |
| 4385 | 4608 | // Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number |
| 4386 | 4609 | // to format defined by LC_NUMERIC after a calculation and we want source format to be defined by Dolibarr setup. |
@@ -4394,8 +4617,10 @@ discard block |
||
| 4394 | 4617 | //print "TT".$amount.'<br>'; |
| 4395 | 4618 | // Always make replace because each math function (like round) replace |
| 4396 | 4619 | // with local values and we want a number that has a SQL string format x.y |
| 4397 | - if ($thousand != ',' && $thousand != '.') |
|
| 4398 | - $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
|
|
| 4620 | + if ($thousand != ',' && $thousand != '.') { |
|
| 4621 | + $amount = str_replace(',', '.', $amount); |
|
| 4622 | + } |
|
| 4623 | + // To accept 2 notations for french users |
|
| 4399 | 4624 | $amount = str_replace(' ', '', $amount); // To avoid spaces
|
| 4400 | 4625 | $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . |
| 4401 | 4626 | $amount = str_replace($dec, '.', $amount); |
@@ -4454,8 +4679,9 @@ discard block |
||
| 4454 | 4679 | {
|
| 4455 | 4680 | global $db, $conf, $mysoc; |
| 4456 | 4681 | |
| 4457 | - if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) |
|
| 4458 | - $thirdparty_seller = $mysoc; |
|
| 4682 | + if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) { |
|
| 4683 | + $thirdparty_seller = $mysoc; |
|
| 4684 | + } |
|
| 4459 | 4685 | |
| 4460 | 4686 | dol_syslog("get_localtax tva=" . $vatrate . " local=" . $local . " thirdparty_buyer id=" . (is_object($thirdparty_buyer) ? $thirdparty_buyer->id : '') . "/country_code=" . (is_object($thirdparty_buyer) ? $thirdparty_buyer->country_code : '') . " thirdparty_seller id=" . $thirdparty_seller->id . "/country_code=" . $thirdparty_seller->country_code . " thirdparty_seller localtax1_assuj=" . $thirdparty_seller->localtax1_assuj . " thirdparty_seller localtax2_assuj=" . $thirdparty_seller->localtax2_assuj);
|
| 4461 | 4687 | |
@@ -4473,37 +4699,43 @@ discard block |
||
| 4473 | 4699 | // Some test to guess with no need to make database access |
| 4474 | 4700 | if ($mysoc->country_code == 'ES') { // For spain localtaxes 1 and 2, tax is qualified if buyer use local tax
|
| 4475 | 4701 | if ($local == 1) {
|
| 4476 | - if (!$mysoc->localtax1_assuj || (string) $vatratecleaned == "0") |
|
| 4477 | - return 0; |
|
| 4702 | + if (!$mysoc->localtax1_assuj || (string) $vatratecleaned == "0") { |
|
| 4703 | + return 0; |
|
| 4704 | + } |
|
| 4478 | 4705 | if ($thirdparty_seller->id == $mysoc->id) {
|
| 4479 | - if (!$thirdparty_buyer->localtax1_assuj) |
|
| 4480 | - return 0; |
|
| 4481 | - } |
|
| 4482 | - else {
|
|
| 4483 | - if (!$thirdparty_seller->localtax1_assuj) |
|
| 4484 | - return 0; |
|
| 4706 | + if (!$thirdparty_buyer->localtax1_assuj) { |
|
| 4707 | + return 0; |
|
| 4708 | + } |
|
| 4709 | + } else {
|
|
| 4710 | + if (!$thirdparty_seller->localtax1_assuj) { |
|
| 4711 | + return 0; |
|
| 4712 | + } |
|
| 4485 | 4713 | } |
| 4486 | 4714 | } |
| 4487 | 4715 | |
| 4488 | 4716 | if ($local == 2) {
|
| 4489 | 4717 | //if (! $mysoc->localtax2_assuj || (string) $vatratecleaned == "0") return 0; |
| 4490 | - if (!$mysoc->localtax2_assuj) |
|
| 4491 | - return 0; // If main vat is 0, IRPF may be different than 0. |
|
| 4718 | + if (!$mysoc->localtax2_assuj) { |
|
| 4719 | + return 0; |
|
| 4720 | + } |
|
| 4721 | + // If main vat is 0, IRPF may be different than 0. |
|
| 4492 | 4722 | if ($thirdparty_seller->id == $mysoc->id) {
|
| 4493 | - if (!$thirdparty_buyer->localtax2_assuj) |
|
| 4494 | - return 0; |
|
| 4495 | - } |
|
| 4496 | - else {
|
|
| 4497 | - if (!$thirdparty_seller->localtax2_assuj) |
|
| 4498 | - return 0; |
|
| 4723 | + if (!$thirdparty_buyer->localtax2_assuj) { |
|
| 4724 | + return 0; |
|
| 4725 | + } |
|
| 4726 | + } else {
|
|
| 4727 | + if (!$thirdparty_seller->localtax2_assuj) { |
|
| 4728 | + return 0; |
|
| 4729 | + } |
|
| 4499 | 4730 | } |
| 4500 | 4731 | } |
| 4501 | - } |
|
| 4502 | - else {
|
|
| 4503 | - if ($local == 1 && !$thirdparty_seller->localtax1_assuj) |
|
| 4504 | - return 0; |
|
| 4505 | - if ($local == 2 && !$thirdparty_seller->localtax2_assuj) |
|
| 4506 | - return 0; |
|
| 4732 | + } else {
|
|
| 4733 | + if ($local == 1 && !$thirdparty_seller->localtax1_assuj) { |
|
| 4734 | + return 0; |
|
| 4735 | + } |
|
| 4736 | + if ($local == 2 && !$thirdparty_seller->localtax2_assuj) { |
|
| 4737 | + return 0; |
|
| 4738 | + } |
|
| 4507 | 4739 | } |
| 4508 | 4740 | |
| 4509 | 4741 | // For some country MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY is forced to on. |
@@ -4545,19 +4777,23 @@ discard block |
||
| 4545 | 4777 | $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c"; |
| 4546 | 4778 | $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $thirdparty_seller->country_code . "'"; |
| 4547 | 4779 | $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1"; |
| 4548 | - if ($vatratecode) |
|
| 4549 | - $sql .= " AND t.code ='" . $vatratecode . "'"; // If we have the code, we use it in priority |
|
| 4550 | - else |
|
| 4551 | - $sql .= " AND t.recuperableonly ='" . $vatnpr . "'"; |
|
| 4780 | + if ($vatratecode) { |
|
| 4781 | + $sql .= " AND t.code ='" . $vatratecode . "'"; |
|
| 4782 | + } |
|
| 4783 | + // If we have the code, we use it in priority |
|
| 4784 | + else { |
|
| 4785 | + $sql .= " AND t.recuperableonly ='" . $vatnpr . "'"; |
|
| 4786 | + } |
|
| 4552 | 4787 | dol_syslog("get_localtax", LOG_DEBUG);
|
| 4553 | 4788 | $resql = $db->query($sql); |
| 4554 | 4789 | |
| 4555 | 4790 | if ($resql) {
|
| 4556 | 4791 | $obj = $db->fetch_object($resql); |
| 4557 | - if ($local == 1) |
|
| 4558 | - return $obj->localtax1; |
|
| 4559 | - elseif ($local == 2) |
|
| 4560 | - return $obj->localtax2; |
|
| 4792 | + if ($local == 1) { |
|
| 4793 | + return $obj->localtax1; |
|
| 4794 | + } elseif ($local == 2) { |
|
| 4795 | + return $obj->localtax2; |
|
| 4796 | + } |
|
| 4561 | 4797 | } |
| 4562 | 4798 | |
| 4563 | 4799 | return 0; |
@@ -4603,10 +4839,11 @@ discard block |
||
| 4603 | 4839 | $resql = $db->query($sql); |
| 4604 | 4840 | if ($resql) {
|
| 4605 | 4841 | $obj = $db->fetch_object($resql); |
| 4606 | - if ($local == 1) |
|
| 4607 | - return $obj->localtax1; |
|
| 4608 | - elseif ($local == 2) |
|
| 4609 | - return $obj->localtax2; |
|
| 4842 | + if ($local == 1) { |
|
| 4843 | + return $obj->localtax1; |
|
| 4844 | + } elseif ($local == 2) { |
|
| 4845 | + return $obj->localtax2; |
|
| 4846 | + } |
|
| 4610 | 4847 | } |
| 4611 | 4848 | |
| 4612 | 4849 | return 0; |
@@ -4632,9 +4869,9 @@ discard block |
||
| 4632 | 4869 | // Search local taxes |
| 4633 | 4870 | $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy"; |
| 4634 | 4871 | $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t"; |
| 4635 | - if ($firstparamisid) |
|
| 4636 | - $sql .= " WHERE t.rowid = " . (int) $vatrate; |
|
| 4637 | - else {
|
|
| 4872 | + if ($firstparamisid) { |
|
| 4873 | + $sql .= " WHERE t.rowid = " . (int) $vatrate; |
|
| 4874 | + } else {
|
|
| 4638 | 4875 | $vatratecleaned = $vatrate; |
| 4639 | 4876 | $vatratecode = ''; |
| 4640 | 4877 | if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) { // If vat is "xx (yy)"
|
@@ -4647,19 +4884,22 @@ discard block |
||
| 4647 | 4884 | else $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; */ |
| 4648 | 4885 | $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'"; |
| 4649 | 4886 | $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1"; |
| 4650 | - if ($vatratecode) |
|
| 4651 | - $sql .= " AND t.code = '" . $vatratecode . "'"; |
|
| 4887 | + if ($vatratecode) { |
|
| 4888 | + $sql .= " AND t.code = '" . $vatratecode . "'"; |
|
| 4889 | + } |
|
| 4652 | 4890 | } |
| 4653 | 4891 | |
| 4654 | 4892 | $resql = $db->query($sql); |
| 4655 | 4893 | if ($resql) {
|
| 4656 | 4894 | $obj = $db->fetch_object($resql); |
| 4657 | - if ($obj) |
|
| 4658 | - return array('rowid' => $obj->rowid, 'code' => $obj->code, 'rate' => $obj->rate, 'npr' => $obj->npr, 'accountancy_code_sell' => $obj->accountancy_code_sell, 'accountancy_code_buy' => $obj->accountancy_code_buy);
|
|
| 4659 | - else |
|
| 4660 | - return array(); |
|
| 4661 | - } else |
|
| 4662 | - dol_print_error($db); |
|
| 4895 | + if ($obj) { |
|
| 4896 | + return array('rowid' => $obj->rowid, 'code' => $obj->code, 'rate' => $obj->rate, 'npr' => $obj->npr, 'accountancy_code_sell' => $obj->accountancy_code_sell, 'accountancy_code_buy' => $obj->accountancy_code_buy); |
|
| 4897 | + } else { |
|
| 4898 | + return array(); |
|
| 4899 | + } |
|
| 4900 | + } else { |
|
| 4901 | + dol_print_error($db); |
|
| 4902 | + } |
|
| 4663 | 4903 | |
| 4664 | 4904 | return array(); |
| 4665 | 4905 | } |
@@ -4689,9 +4929,9 @@ discard block |
||
| 4689 | 4929 | // Search local taxes |
| 4690 | 4930 | $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy"; |
| 4691 | 4931 | $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t"; |
| 4692 | - if ($firstparamisid) |
|
| 4693 | - $sql .= " WHERE t.rowid = " . (int) $vatrate; |
|
| 4694 | - else {
|
|
| 4932 | + if ($firstparamisid) { |
|
| 4933 | + $sql .= " WHERE t.rowid = " . (int) $vatrate; |
|
| 4934 | + } else {
|
|
| 4695 | 4935 | $vatratecleaned = $vatrate; |
| 4696 | 4936 | $vatratecode = ''; |
| 4697 | 4937 | if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) { // If vat is "x.x (yy)"
|
@@ -4700,13 +4940,17 @@ discard block |
||
| 4700 | 4940 | } |
| 4701 | 4941 | |
| 4702 | 4942 | $sql .= ", " . MAIN_DB_PREFIX . "c_country as c"; |
| 4703 | - if ($mysoc->country_code == 'ES') |
|
| 4704 | - $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'"; // local tax in spain use the buyer country ?? |
|
| 4705 | - else |
|
| 4706 | - $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'"; |
|
| 4943 | + if ($mysoc->country_code == 'ES') { |
|
| 4944 | + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'"; |
|
| 4945 | + } |
|
| 4946 | + // local tax in spain use the buyer country ?? |
|
| 4947 | + else { |
|
| 4948 | + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'"; |
|
| 4949 | + } |
|
| 4707 | 4950 | $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1"; |
| 4708 | - if ($vatratecode) |
|
| 4709 | - $sql .= " AND t.code = '" . $vatratecode . "'"; |
|
| 4951 | + if ($vatratecode) { |
|
| 4952 | + $sql .= " AND t.code = '" . $vatratecode . "'"; |
|
| 4953 | + } |
|
| 4710 | 4954 | } |
| 4711 | 4955 | |
| 4712 | 4956 | $resql = $db->query($sql); |
@@ -4752,17 +4996,17 @@ discard block |
||
| 4752 | 4996 | if ($idprodfournprice > 0) { // We want vat for product for a "supplier" object
|
| 4753 | 4997 | $product->get_buyprice($idprodfournprice, 0, 0, 0); |
| 4754 | 4998 | $ret = $product->vatrate_supplier; |
| 4755 | - if ($product->default_vat_code) |
|
| 4756 | - $ret .= ' (' . $product->default_vat_code . ')';
|
|
| 4757 | - } |
|
| 4758 | - else {
|
|
| 4999 | + if ($product->default_vat_code) { |
|
| 5000 | + $ret .= ' (' . $product->default_vat_code . ')'; |
|
| 5001 | + } |
|
| 5002 | + } else {
|
|
| 4759 | 5003 | $ret = $product->tva_tx; // Default vat of product we defined |
| 4760 | - if ($product->default_vat_code) |
|
| 4761 | - $ret .= ' (' . $product->default_vat_code . ')';
|
|
| 5004 | + if ($product->default_vat_code) { |
|
| 5005 | + $ret .= ' (' . $product->default_vat_code . ')'; |
|
| 5006 | + } |
|
| 4762 | 5007 | } |
| 4763 | 5008 | $found = 1; |
| 4764 | - } |
|
| 4765 | - else {
|
|
| 5009 | + } else {
|
|
| 4766 | 5010 | // TODO Read default product vat according to countrycode and product. Vat for couple countrycode/product is a feature not implemeted yet. |
| 4767 | 5011 | // May be usefull/required if hidden option SERVICE_ARE_ECOMMERCE_200238EC is on |
| 4768 | 5012 | } |
@@ -4782,14 +5026,18 @@ discard block |
||
| 4782 | 5026 | $obj = $db->fetch_object($resql); |
| 4783 | 5027 | if ($obj) {
|
| 4784 | 5028 | $ret = $obj->vat_rate; |
| 4785 | - if ($obj->default_vat_code) |
|
| 4786 | - $ret .= ' (' . $obj->default_vat_code . ')';
|
|
| 5029 | + if ($obj->default_vat_code) { |
|
| 5030 | + $ret .= ' (' . $obj->default_vat_code . ')'; |
|
| 5031 | + } |
|
| 4787 | 5032 | } |
| 4788 | 5033 | $db->free($sql); |
| 4789 | - } else |
|
| 4790 | - dol_print_error($db); |
|
| 4791 | - } else |
|
| 4792 | - $ret = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS; // Forced value if autodetect fails |
|
| 5034 | + } else { |
|
| 5035 | + dol_print_error($db); |
|
| 5036 | + } |
|
| 5037 | + } else { |
|
| 5038 | + $ret = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS; |
|
| 5039 | + } |
|
| 5040 | + // Forced value if autodetect fails |
|
| 4793 | 5041 | } |
| 4794 | 5042 | |
| 4795 | 5043 | dol_syslog("get_product_vat_for_country: ret=" . $ret);
|
@@ -4844,13 +5092,15 @@ discard block |
||
| 4844 | 5092 | if ($resql) {
|
| 4845 | 5093 | $obj = $db->fetch_object($resql); |
| 4846 | 5094 | if ($obj) {
|
| 4847 | - if ($local == 1) |
|
| 4848 | - $ret = $obj->localtax1; |
|
| 4849 | - elseif ($local == 2) |
|
| 4850 | - $ret = $obj->localtax2; |
|
| 5095 | + if ($local == 1) { |
|
| 5096 | + $ret = $obj->localtax1; |
|
| 5097 | + } elseif ($local == 2) { |
|
| 5098 | + $ret = $obj->localtax2; |
|
| 5099 | + } |
|
| 4851 | 5100 | } |
| 4852 | - } else |
|
| 4853 | - dol_print_error($db); |
|
| 5101 | + } else { |
|
| 5102 | + dol_print_error($db); |
|
| 5103 | + } |
|
| 4854 | 5104 | } |
| 4855 | 5105 | |
| 4856 | 5106 | dol_syslog("get_product_localtax_for_country: ret=" . $ret);
|
@@ -4953,15 +5203,16 @@ discard block |
||
| 4953 | 5203 | global $db; |
| 4954 | 5204 | |
| 4955 | 5205 | if ($idprodfournprice > 0) {
|
| 4956 | - if (!class_exists('ProductFournisseur'))
|
|
| 4957 | - require_once DOL_BASE_PATH . '/fourn/class/fournisseur.product.class.php'; |
|
| 5206 | + if (!class_exists('ProductFournisseur')) { |
|
| 5207 | + require_once DOL_BASE_PATH . '/fourn/class/fournisseur.product.class.php'; |
|
| 5208 | + } |
|
| 4958 | 5209 | $prodprice = new ProductFournisseur($db); |
| 4959 | 5210 | $prodprice->fetch_product_fournisseur_price($idprodfournprice); |
| 4960 | 5211 | return $prodprice->fourn_tva_npr; |
| 4961 | - } |
|
| 4962 | - elseif ($idprod > 0) {
|
|
| 4963 | - if (!class_exists('Product'))
|
|
| 4964 | - require_once DOL_BASE_PATH . 'product/class/product.class.php'; |
|
| 5212 | + } elseif ($idprod > 0) {
|
|
| 5213 | + if (!class_exists('Product')) { |
|
| 5214 | + require_once DOL_BASE_PATH . 'product/class/product.class.php'; |
|
| 5215 | + } |
|
| 4965 | 5216 | $prod = new Product($db); |
| 4966 | 5217 | $prod->fetch($idprod); |
| 4967 | 5218 | return $prod->tva_npr; |
@@ -4987,30 +5238,35 @@ discard block |
||
| 4987 | 5238 | {
|
| 4988 | 5239 | global $mysoc; |
| 4989 | 5240 | |
| 4990 | - if (!is_object($thirdparty_seller)) |
|
| 4991 | - return -1; |
|
| 4992 | - if (!is_object($thirdparty_buyer)) |
|
| 4993 | - return -1; |
|
| 5241 | + if (!is_object($thirdparty_seller)) { |
|
| 5242 | + return -1; |
|
| 5243 | + } |
|
| 5244 | + if (!is_object($thirdparty_buyer)) { |
|
| 5245 | + return -1; |
|
| 5246 | + } |
|
| 4994 | 5247 | |
| 4995 | 5248 | if ($local == 1) { // Localtax 1
|
| 4996 | 5249 | if ($mysoc->country_code == 'ES') {
|
| 4997 | - if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) |
|
| 4998 | - return 0; |
|
| 4999 | - } |
|
| 5000 | - else {
|
|
| 5250 | + if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) { |
|
| 5251 | + return 0; |
|
| 5252 | + } |
|
| 5253 | + } else {
|
|
| 5001 | 5254 | // Si vendeur non assujeti a Localtax1, localtax1 par default=0 |
| 5002 | - if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) |
|
| 5003 | - return 0; |
|
| 5004 | - if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj == 'localtax1off') |
|
| 5005 | - return 0; |
|
| 5006 | - } |
|
| 5007 | - } |
|
| 5008 | - elseif ($local == 2) { //I Localtax 2
|
|
| 5255 | + if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) { |
|
| 5256 | + return 0; |
|
| 5257 | + } |
|
| 5258 | + if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj == 'localtax1off') { |
|
| 5259 | + return 0; |
|
| 5260 | + } |
|
| 5261 | + } |
|
| 5262 | + } elseif ($local == 2) { //I Localtax 2
|
|
| 5009 | 5263 | // Si vendeur non assujeti a Localtax2, localtax2 par default=0 |
| 5010 | - if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) |
|
| 5011 | - return 0; |
|
| 5012 | - if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj == 'localtax2off') |
|
| 5013 | - return 0; |
|
| 5264 | + if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) { |
|
| 5265 | + return 0; |
|
| 5266 | + } |
|
| 5267 | + if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj == 'localtax2off') { |
|
| 5268 | + return 0; |
|
| 5269 | + } |
|
| 5014 | 5270 | } |
| 5015 | 5271 | |
| 5016 | 5272 | if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code) {
|
@@ -5035,31 +5291,38 @@ discard block |
||
| 5035 | 5291 | $classname = ''; |
| 5036 | 5292 | if ($yesno == 1 || strtolower($yesno) == 'yes' || strtolower($yesno) == 'true') { // A mettre avant test sur no a cause du == 0
|
| 5037 | 5293 | $result = $langs->trans('yes');
|
| 5038 | - if ($case == 1 || $case == 3) |
|
| 5039 | - $result = $langs->trans("Yes");
|
|
| 5040 | - if ($case == 2) |
|
| 5041 | - $result = '<input type="checkbox" value="1" checked disabled>'; |
|
| 5042 | - if ($case == 3) |
|
| 5043 | - $result = '<input type="checkbox" value="1" checked disabled> ' . $result; |
|
| 5294 | + if ($case == 1 || $case == 3) { |
|
| 5295 | + $result = $langs->trans("Yes"); |
|
| 5296 | + } |
|
| 5297 | + if ($case == 2) { |
|
| 5298 | + $result = '<input type="checkbox" value="1" checked disabled>'; |
|
| 5299 | + } |
|
| 5300 | + if ($case == 3) { |
|
| 5301 | + $result = '<input type="checkbox" value="1" checked disabled> ' . $result; |
|
| 5302 | + } |
|
| 5044 | 5303 | |
| 5045 | 5304 | $classname = 'ok'; |
| 5046 | - } |
|
| 5047 | - elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') {
|
|
| 5305 | + } elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') {
|
|
| 5048 | 5306 | $result = $langs->trans("no");
|
| 5049 | - if ($case == 1 || $case == 3) |
|
| 5050 | - $result = $langs->trans("No");
|
|
| 5051 | - if ($case == 2) |
|
| 5052 | - $result = '<input type="checkbox" value="0" disabled>'; |
|
| 5053 | - if ($case == 3) |
|
| 5054 | - $result = '<input type="checkbox" value="0" disabled> ' . $result; |
|
| 5055 | - |
|
| 5056 | - if ($color == 2) |
|
| 5057 | - $classname = 'ok'; |
|
| 5058 | - else |
|
| 5059 | - $classname = 'error'; |
|
| 5060 | - } |
|
| 5061 | - if ($color) |
|
| 5062 | - return '<font class="' . $classname . '">' . $result . '</font>'; |
|
| 5307 | + if ($case == 1 || $case == 3) { |
|
| 5308 | + $result = $langs->trans("No"); |
|
| 5309 | + } |
|
| 5310 | + if ($case == 2) { |
|
| 5311 | + $result = '<input type="checkbox" value="0" disabled>'; |
|
| 5312 | + } |
|
| 5313 | + if ($case == 3) { |
|
| 5314 | + $result = '<input type="checkbox" value="0" disabled> ' . $result; |
|
| 5315 | + } |
|
| 5316 | + |
|
| 5317 | + if ($color == 2) { |
|
| 5318 | + $classname = 'ok'; |
|
| 5319 | + } else { |
|
| 5320 | + $classname = 'error'; |
|
| 5321 | + } |
|
| 5322 | + } |
|
| 5323 | + if ($color) { |
|
| 5324 | + return '<font class="' . $classname . '">' . $result . '</font>'; |
|
| 5325 | + } |
|
| 5063 | 5326 | return $result; |
| 5064 | 5327 | } |
| 5065 | 5328 | |
@@ -5085,23 +5348,27 @@ discard block |
||
| 5085 | 5348 | $path = ''; |
| 5086 | 5349 | |
| 5087 | 5350 | $arrayforoldpath = array('cheque', 'user', 'category', 'holiday', 'supplier_invoice', 'invoice_supplier', 'mailing', 'supplier_payment');
|
| 5088 | - if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) |
|
| 5089 | - $arrayforoldpath[] = 'product'; |
|
| 5351 | + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { |
|
| 5352 | + $arrayforoldpath[] = 'product'; |
|
| 5353 | + } |
|
| 5090 | 5354 | if (!empty($level) && in_array($modulepart, $arrayforoldpath)) {
|
| 5091 | 5355 | // This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided. |
| 5092 | - if (empty($alpha)) |
|
| 5093 | - $num = preg_replace('/([^0-9])/i', '', $num);
|
|
| 5094 | - else |
|
| 5095 | - $num = preg_replace('/^.*\-/i', '', $num);
|
|
| 5356 | + if (empty($alpha)) { |
|
| 5357 | + $num = preg_replace('/([^0-9])/i', '', $num); |
|
| 5358 | + } else { |
|
| 5359 | + $num = preg_replace('/^.*\-/i', '', $num); |
|
| 5360 | + } |
|
| 5096 | 5361 | $num = substr("000" . $num, -$level);
|
| 5097 | - if ($level == 1) |
|
| 5098 | - $path = substr($num, 0, 1); |
|
| 5099 | - if ($level == 2) |
|
| 5100 | - $path = substr($num, 1, 1) . '/' . substr($num, 0, 1); |
|
| 5101 | - if ($level == 3) |
|
| 5102 | - $path = substr($num, 2, 1) . '/' . substr($num, 1, 1) . '/' . substr($num, 0, 1); |
|
| 5103 | - } |
|
| 5104 | - else {
|
|
| 5362 | + if ($level == 1) { |
|
| 5363 | + $path = substr($num, 0, 1); |
|
| 5364 | + } |
|
| 5365 | + if ($level == 2) { |
|
| 5366 | + $path = substr($num, 1, 1) . '/' . substr($num, 0, 1); |
|
| 5367 | + } |
|
| 5368 | + if ($level == 3) { |
|
| 5369 | + $path = substr($num, 2, 1) . '/' . substr($num, 1, 1) . '/' . substr($num, 0, 1); |
|
| 5370 | + } |
|
| 5371 | + } else {
|
|
| 5105 | 5372 | // TODO |
| 5106 | 5373 | // We will enhance here a common way of forging path for document storage |
| 5107 | 5374 | // Here, object->id, object->ref and modulepart are required. |
@@ -5112,8 +5379,9 @@ discard block |
||
| 5112 | 5379 | } |
| 5113 | 5380 | } |
| 5114 | 5381 | |
| 5115 | - if (empty($withoutslash) && !empty($path)) |
|
| 5116 | - $path .= '/'; |
|
| 5382 | + if (empty($withoutslash) && !empty($path)) { |
|
| 5383 | + $path .= '/'; |
|
| 5384 | + } |
|
| 5117 | 5385 | |
| 5118 | 5386 | return $path; |
| 5119 | 5387 | } |
@@ -5133,8 +5401,9 @@ discard block |
||
| 5133 | 5401 | dol_syslog("functions.lib::dol_mkdir: dir=" . $dir, LOG_INFO);
|
| 5134 | 5402 | |
| 5135 | 5403 | $dir_osencoded = dol_osencode($dir); |
| 5136 | - if (@is_dir($dir_osencoded)) |
|
| 5137 | - return 0; |
|
| 5404 | + if (@is_dir($dir_osencoded)) { |
|
| 5405 | + return 0; |
|
| 5406 | + } |
|
| 5138 | 5407 | |
| 5139 | 5408 | $nberr = 0; |
| 5140 | 5409 | $nbcreated = 0; |
@@ -5149,12 +5418,15 @@ discard block |
||
| 5149 | 5418 | $cdir = explode("/", $dir);
|
| 5150 | 5419 | $num = count($cdir); |
| 5151 | 5420 | for ($i = 0; $i < $num; $i++) {
|
| 5152 | - if ($i > 0) |
|
| 5153 | - $ccdir .= '/' . $cdir[$i]; |
|
| 5154 | - else |
|
| 5155 | - $ccdir .= $cdir[$i]; |
|
| 5156 | - if (preg_match("/^.:$/", $ccdir, $regs))
|
|
| 5157 | - continue; // Si chemin Windows incomplet, on poursuit par rep suivant |
|
| 5421 | + if ($i > 0) { |
|
| 5422 | + $ccdir .= '/' . $cdir[$i]; |
|
| 5423 | + } else { |
|
| 5424 | + $ccdir .= $cdir[$i]; |
|
| 5425 | + } |
|
| 5426 | + if (preg_match("/^.:$/", $ccdir, $regs)) { |
|
| 5427 | + continue; |
|
| 5428 | + } |
|
| 5429 | + // Si chemin Windows incomplet, on poursuit par rep suivant |
|
| 5158 | 5430 | |
| 5159 | 5431 | |
| 5160 | 5432 | |
@@ -5226,8 +5498,9 @@ discard block |
||
| 5226 | 5498 | */ |
| 5227 | 5499 | function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto = 'UTF-8', $strip_tags = 0) |
| 5228 | 5500 | {
|
| 5229 | - if ($removelinefeed == 2) |
|
| 5230 | - $stringtoclean = preg_replace('/<br[^>]*>\n+/ims', '<br>', $stringtoclean);
|
|
| 5501 | + if ($removelinefeed == 2) { |
|
| 5502 | + $stringtoclean = preg_replace('/<br[^>]*>\n+/ims', '<br>', $stringtoclean); |
|
| 5503 | + } |
|
| 5231 | 5504 | $temp = preg_replace('/<br[^>]*>/i', "\n", $stringtoclean);
|
| 5232 | 5505 | |
| 5233 | 5506 | if ($strip_tags) {
|
@@ -5244,8 +5517,9 @@ discard block |
||
| 5244 | 5517 | $temp = dol_html_entity_decode($temp, ENT_COMPAT, $pagecodeto); |
| 5245 | 5518 | |
| 5246 | 5519 | // Supprime aussi les retours |
| 5247 | - if ($removelinefeed == 1) |
|
| 5248 | - $temp = str_replace(array("\r\n", "\r", "\n"), " ", $temp);
|
|
| 5520 | + if ($removelinefeed == 1) { |
|
| 5521 | + $temp = str_replace(array("\r\n", "\r", "\n"), " ", $temp); |
|
| 5522 | + } |
|
| 5249 | 5523 | |
| 5250 | 5524 | // et les espaces doubles |
| 5251 | 5525 | while (strpos($temp, " ")) {
|
@@ -5331,18 +5605,21 @@ discard block |
||
| 5331 | 5605 | if ($charset == 'UTF-8') {
|
| 5332 | 5606 | $pattern = '/(<br[^>]*>)/Uu'; |
| 5333 | 5607 | } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support |
| 5334 | - else |
|
| 5335 | - $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. |
|
| 5608 | + else { |
|
| 5609 | + $pattern = '/(<br[^>]*>)/U'; |
|
| 5610 | + } |
|
| 5611 | + // /U is to have UNGREEDY regex to limit to one html tag. |
|
| 5336 | 5612 | $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
| 5337 | 5613 | |
| 5338 | 5614 | $firstline = ''; |
| 5339 | 5615 | $i = 0; |
| 5340 | 5616 | $nba = count($a); // 2x nb of lines in $a because $a contains also a line for each new line separator |
| 5341 | 5617 | while (($i < $nba) && ($i < ($nboflines * 2))) {
|
| 5342 | - if ($i % 2 == 0) |
|
| 5343 | - $firstline .= $a[$i]; |
|
| 5344 | - elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) |
|
| 5345 | - $firstline .= ($ishtml ? "<br>\n" : "\n"); |
|
| 5618 | + if ($i % 2 == 0) { |
|
| 5619 | + $firstline .= $a[$i]; |
|
| 5620 | + } elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) { |
|
| 5621 | + $firstline .= ($ishtml ? "<br>\n" : "\n"); |
|
| 5622 | + } |
|
| 5346 | 5623 | $i++; |
| 5347 | 5624 | } |
| 5348 | 5625 | unset($a); |
@@ -5391,15 +5668,18 @@ discard block |
||
| 5391 | 5668 | $newstring = $stringtoencode; |
| 5392 | 5669 | if (dol_textishtml($stringtoencode)) { // Check if text is already HTML or not
|
| 5393 | 5670 | $newstring = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', '<br>', $newstring); // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF.
|
| 5394 | - if ($removelasteolbr) |
|
| 5395 | - $newstring = preg_replace('/<br>$/i', '', $newstring); // Remove last <br> (remove only last one)
|
|
| 5671 | + if ($removelasteolbr) { |
|
| 5672 | + $newstring = preg_replace('/<br>$/i', '', $newstring); |
|
| 5673 | + } |
|
| 5674 | + // Remove last <br> (remove only last one) |
|
| 5396 | 5675 | $newstring = strtr($newstring, array('&' => '__and__', '<' => '__lt__', '>' => '__gt__', '"' => '__dquot__'));
|
| 5397 | 5676 | $newstring = dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom); // Make entity encoding |
| 5398 | 5677 | $newstring = strtr($newstring, array('__and__' => '&', '__lt__' => '<', '__gt__' => '>', '__dquot__' => '"'));
|
| 5399 | - } |
|
| 5400 | - else {
|
|
| 5401 | - if ($removelasteolbr) |
|
| 5402 | - $newstring = preg_replace('/(\r\n|\r|\n)$/i', '', $newstring); // Remove last \n (may remove several)
|
|
| 5678 | + } else {
|
|
| 5679 | + if ($removelasteolbr) { |
|
| 5680 | + $newstring = preg_replace('/(\r\n|\r|\n)$/i', '', $newstring); |
|
| 5681 | + } |
|
| 5682 | + // Remove last \n (may remove several) |
|
| 5403 | 5683 | $newstring = dol_nl2br(dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom), $nl2brmode); |
| 5404 | 5684 | } |
| 5405 | 5685 | // Other substitutions that htmlentities does not do |
@@ -5501,8 +5781,9 @@ discard block |
||
| 5501 | 5781 | */ |
| 5502 | 5782 | function dol_nboflines($s, $maxchar = 0) |
| 5503 | 5783 | {
|
| 5504 | - if ($s == '') |
|
| 5505 | - return 0; |
|
| 5784 | + if ($s == '') { |
|
| 5785 | + return 0; |
|
| 5786 | + } |
|
| 5506 | 5787 | $arraystring = explode("\n", $s);
|
| 5507 | 5788 | $nb = count($arraystring); |
| 5508 | 5789 | |
@@ -5521,15 +5802,18 @@ discard block |
||
| 5521 | 5802 | function dol_nboflines_bis($text, $maxlinesize = 0, $charset = 'UTF-8') |
| 5522 | 5803 | {
|
| 5523 | 5804 | $repTable = array("\t" => " ", "\n" => "<br>", "\r" => " ", "\0" => " ", "\x0B" => " ");
|
| 5524 | - if (dol_textishtml($text)) |
|
| 5525 | - $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " ");
|
|
| 5805 | + if (dol_textishtml($text)) { |
|
| 5806 | + $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " "); |
|
| 5807 | + } |
|
| 5526 | 5808 | |
| 5527 | 5809 | $text = strtr($text, $repTable); |
| 5528 | 5810 | if ($charset == 'UTF-8') {
|
| 5529 | 5811 | $pattern = '/(<br[^>]*>)/Uu'; |
| 5530 | 5812 | } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support |
| 5531 | - else |
|
| 5532 | - $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. |
|
| 5813 | + else { |
|
| 5814 | + $pattern = '/(<br[^>]*>)/U'; |
|
| 5815 | + } |
|
| 5816 | + // /U is to have UNGREEDY regex to limit to one html tag. |
|
| 5533 | 5817 | $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
| 5534 | 5818 | |
| 5535 | 5819 | $nblines = (int) floor((count($a) + 1) / 2); |
@@ -5576,39 +5860,47 @@ discard block |
||
| 5576 | 5860 | function dol_textishtml($msg, $option = 0) |
| 5577 | 5861 | {
|
| 5578 | 5862 | if ($option == 1) {
|
| 5579 | - if (preg_match('/<html/i', $msg))
|
|
| 5580 | - return true; |
|
| 5581 | - elseif (preg_match('/<body/i', $msg))
|
|
| 5582 | - return true; |
|
| 5583 | - elseif (preg_match('/<br/i', $msg))
|
|
| 5584 | - return true; |
|
| 5863 | + if (preg_match('/<html/i', $msg)) { |
|
| 5864 | + return true; |
|
| 5865 | + } elseif (preg_match('/<body/i', $msg)) { |
|
| 5866 | + return true; |
|
| 5867 | + } elseif (preg_match('/<br/i', $msg)) { |
|
| 5868 | + return true; |
|
| 5869 | + } |
|
| 5585 | 5870 | return false; |
| 5586 | - } |
|
| 5587 | - else {
|
|
| 5588 | - if (preg_match('/<html/i', $msg))
|
|
| 5589 | - return true; |
|
| 5590 | - elseif (preg_match('/<body/i', $msg))
|
|
| 5591 | - return true; |
|
| 5592 | - elseif (preg_match('/<(b|em|i|u)>/i', $msg))
|
|
| 5593 | - return true; |
|
| 5594 | - elseif (preg_match('/<br\/>/i', $msg))
|
|
| 5595 | - return true; |
|
| 5596 | - elseif (preg_match('/<(br|div|font|li|p|span|strong|table)>/i', $msg))
|
|
| 5597 | - return true; |
|
| 5598 | - elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i', $msg))
|
|
| 5599 | - return true; |
|
| 5600 | - elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i', $msg))
|
|
| 5601 | - return true; |
|
| 5602 | - elseif (preg_match('/<img\s+[^<>]*src[^<>]*>/i', $msg))
|
|
| 5603 | - return true; // must accept <img src="http://example.com/aaa.png" /> |
|
| 5604 | - elseif (preg_match('/<a\s+[^<>]*href[^<>]*>/i', $msg))
|
|
| 5605 | - return true; // must accept <a href="http://example.com/aaa.png" /> |
|
| 5606 | - elseif (preg_match('/<h[0-9]>/i', $msg))
|
|
| 5607 | - return true; |
|
| 5608 | - elseif (preg_match('/&[A-Z0-9]{1,6};/i', $msg))
|
|
| 5609 | - return true; // Html entities names (http://www.w3schools.com/tags/ref_entities.asp) |
|
| 5610 | - elseif (preg_match('/&#[0-9]{2,3};/i', $msg))
|
|
| 5611 | - return true; // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp) |
|
| 5871 | + } else {
|
|
| 5872 | + if (preg_match('/<html/i', $msg)) { |
|
| 5873 | + return true; |
|
| 5874 | + } elseif (preg_match('/<body/i', $msg)) { |
|
| 5875 | + return true; |
|
| 5876 | + } elseif (preg_match('/<(b|em|i|u)>/i', $msg)) { |
|
| 5877 | + return true; |
|
| 5878 | + } elseif (preg_match('/<br\/>/i', $msg)) { |
|
| 5879 | + return true; |
|
| 5880 | + } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)>/i', $msg)) { |
|
| 5881 | + return true; |
|
| 5882 | + } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i', $msg)) { |
|
| 5883 | + return true; |
|
| 5884 | + } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i', $msg)) { |
|
| 5885 | + return true; |
|
| 5886 | + } elseif (preg_match('/<img\s+[^<>]*src[^<>]*>/i', $msg)) { |
|
| 5887 | + return true; |
|
| 5888 | + } |
|
| 5889 | + // must accept <img src="http://example.com/aaa.png" /> |
|
| 5890 | + elseif (preg_match('/<a\s+[^<>]*href[^<>]*>/i', $msg)) { |
|
| 5891 | + return true; |
|
| 5892 | + } |
|
| 5893 | + // must accept <a href="http://example.com/aaa.png" /> |
|
| 5894 | + elseif (preg_match('/<h[0-9]>/i', $msg)) { |
|
| 5895 | + return true; |
|
| 5896 | + } elseif (preg_match('/&[A-Z0-9]{1,6};/i', $msg)) { |
|
| 5897 | + return true; |
|
| 5898 | + } |
|
| 5899 | + // Html entities names (http://www.w3schools.com/tags/ref_entities.asp) |
|
| 5900 | + elseif (preg_match('/&#[0-9]{2,3};/i', $msg)) { |
|
| 5901 | + return true; |
|
| 5902 | + } |
|
| 5903 | + // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp) |
|
| 5612 | 5904 | |
| 5613 | 5905 | return false; |
| 5614 | 5906 | } |
@@ -5760,12 +6052,14 @@ discard block |
||
| 5760 | 6052 | $birthday = dol_print_date($object->birth, 'day'); |
| 5761 | 6053 | |
| 5762 | 6054 | $substitutionarray['__MEMBER_ID__'] = $object->id; |
| 5763 | - if (method_exists($object, 'getCivilityLabel')) |
|
| 5764 | - $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel(); |
|
| 6055 | + if (method_exists($object, 'getCivilityLabel')) { |
|
| 6056 | + $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel(); |
|
| 6057 | + } |
|
| 5765 | 6058 | $substitutionarray['__MEMBER_FIRSTNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->firstname) : $object->firstname; |
| 5766 | 6059 | $substitutionarray['__MEMBER_LASTNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->lastname) : $object->lastname; |
| 5767 | - if (method_exists($object, 'getFullName')) |
|
| 5768 | - $substitutionarray['__MEMBER_FULLNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->getFullName($outputlangs)) : $object->getFullName($outputlangs); |
|
| 6060 | + if (method_exists($object, 'getFullName')) { |
|
| 6061 | + $substitutionarray['__MEMBER_FULLNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->getFullName($outputlangs)) : $object->getFullName($outputlangs); |
|
| 6062 | + } |
|
| 5769 | 6063 | $substitutionarray['__MEMBER_COMPANY__'] = $msgishtml ? dol_htmlentitiesbr($object->societe) : $object->societe; |
| 5770 | 6064 | $substitutionarray['__MEMBER_ADDRESS__'] = $msgishtml ? dol_htmlentitiesbr($object->address) : $object->address; |
| 5771 | 6065 | $substitutionarray['__MEMBER_ZIP__'] = $msgishtml ? dol_htmlentitiesbr($object->zip) : $object->zip; |
@@ -5813,10 +6107,12 @@ discard block |
||
| 5813 | 6107 | $dateplannedstart = ''; |
| 5814 | 6108 | $datenextexpiration = ''; |
| 5815 | 6109 | foreach ($object->lines as $line) {
|
| 5816 | - if ($line->date_ouverture_prevue > $dateplannedstart) |
|
| 5817 | - $dateplannedstart = $line->date_ouverture_prevue; |
|
| 5818 | - if ($line->statut == 4 && $line->date_fin_prevue && (!$datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) |
|
| 5819 | - $datenextexpiration = $line->date_fin_prevue; |
|
| 6110 | + if ($line->date_ouverture_prevue > $dateplannedstart) { |
|
| 6111 | + $dateplannedstart = $line->date_ouverture_prevue; |
|
| 6112 | + } |
|
| 6113 | + if ($line->statut == 4 && $line->date_fin_prevue && (!$datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) { |
|
| 6114 | + $datenextexpiration = $line->date_fin_prevue; |
|
| 6115 | + } |
|
| 5820 | 6116 | } |
| 5821 | 6117 | $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = dol_print_date($dateplannedstart, 'dayrfc'); |
| 5822 | 6118 | $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = dol_print_date($dateplannedstart, 'standard'); |
@@ -5826,8 +6122,9 @@ discard block |
||
| 5826 | 6122 | |
| 5827 | 6123 | // Create dynamic tags for __EXTRAFIELD_FIELD__ |
| 5828 | 6124 | if ($object->table_element && $object->id > 0) {
|
| 5829 | - if (!is_object($extrafields)) |
|
| 5830 | - $extrafields = new ExtraFields($db); |
|
| 6125 | + if (!is_object($extrafields)) { |
|
| 6126 | + $extrafields = new ExtraFields($db); |
|
| 6127 | + } |
|
| 5831 | 6128 | $extrafields->fetch_name_optionals_label($object->table_element, true); |
| 5832 | 6129 | |
| 5833 | 6130 | if ($object->fetch_optionals() > 0) {
|
@@ -5848,12 +6145,15 @@ discard block |
||
| 5848 | 6145 | require_once DOL_BASE_PATH . '/core/lib/payments.lib.php'; |
| 5849 | 6146 | $outputlangs->loadLangs(array('paypal', 'other'));
|
| 5850 | 6147 | $typeforonlinepayment = 'free'; |
| 5851 | - if (is_object($object) && $object->element == 'commande') |
|
| 5852 | - $typeforonlinepayment = 'order'; |
|
| 5853 | - if (is_object($object) && $object->element == 'facture') |
|
| 5854 | - $typeforonlinepayment = 'invoice'; |
|
| 5855 | - if (is_object($object) && $object->element == 'member') |
|
| 5856 | - $typeforonlinepayment = 'member'; |
|
| 6148 | + if (is_object($object) && $object->element == 'commande') { |
|
| 6149 | + $typeforonlinepayment = 'order'; |
|
| 6150 | + } |
|
| 6151 | + if (is_object($object) && $object->element == 'facture') { |
|
| 6152 | + $typeforonlinepayment = 'invoice'; |
|
| 6153 | + } |
|
| 6154 | + if (is_object($object) && $object->element == 'member') { |
|
| 6155 | + $typeforonlinepayment = 'member'; |
|
| 6156 | + } |
|
| 5857 | 6157 | $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray['__REF__']); |
| 5858 | 6158 | $paymenturl = $url; |
| 5859 | 6159 | } |
@@ -5863,16 +6163,19 @@ discard block |
||
| 5863 | 6163 | |
| 5864 | 6164 | if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'propal') {
|
| 5865 | 6165 | $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element); |
| 5866 | - } else |
|
| 5867 | - $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = ''; |
|
| 6166 | + } else { |
|
| 6167 | + $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = ''; |
|
| 6168 | + } |
|
| 5868 | 6169 | if (!empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'commande') {
|
| 5869 | 6170 | $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = $object->getLastMainDocLink($object->element); |
| 5870 | - } else |
|
| 5871 | - $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = ''; |
|
| 6171 | + } else { |
|
| 6172 | + $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = ''; |
|
| 6173 | + } |
|
| 5872 | 6174 | if (!empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'facture') {
|
| 5873 | 6175 | $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = $object->getLastMainDocLink($object->element); |
| 5874 | - } else |
|
| 5875 | - $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = ''; |
|
| 6176 | + } else { |
|
| 6177 | + $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = ''; |
|
| 6178 | + } |
|
| 5876 | 6179 | } |
| 5877 | 6180 | } |
| 5878 | 6181 | if (empty($exclude) || !in_array('objectamount', $exclude)) {
|
@@ -5882,18 +6185,22 @@ discard block |
||
| 5882 | 6185 | $substitutionarray['__AMOUNT__'] = is_object($object) ? $object->total_ttc : ''; |
| 5883 | 6186 | $substitutionarray['__AMOUNT_EXCL_TAX__'] = is_object($object) ? $object->total_ht : ''; |
| 5884 | 6187 | $substitutionarray['__AMOUNT_VAT__'] = is_object($object) ? ($object->total_vat ? $object->total_vat : $object->total_tva) : ''; |
| 5885 | - if ($onlykey != 2 || $mysoc->useLocalTax(1)) |
|
| 5886 | - $substitutionarray['__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 : ''; |
|
| 5887 | - if ($onlykey != 2 || $mysoc->useLocalTax(2)) |
|
| 5888 | - $substitutionarray['__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 : ''; |
|
| 6188 | + if ($onlykey != 2 || $mysoc->useLocalTax(1)) { |
|
| 6189 | + $substitutionarray['__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 : ''; |
|
| 6190 | + } |
|
| 6191 | + if ($onlykey != 2 || $mysoc->useLocalTax(2)) { |
|
| 6192 | + $substitutionarray['__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 : ''; |
|
| 6193 | + } |
|
| 5889 | 6194 | |
| 5890 | 6195 | $substitutionarray['__AMOUNT_FORMATED__'] = is_object($object) ? price($object->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency) : ''; |
| 5891 | 6196 | $substitutionarray['__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object) ? price($object->total_ht, 0, $outputlangs, 0, 0, -1, $conf->currency) : ''; |
| 5892 | 6197 | $substitutionarray['__AMOUNT_VAT_FORMATED__'] = is_object($object) ? ($object->total_vat ? price($object->total_vat, 0, $outputlangs, 0, 0, -1, $conf->currency) : price($object->total_tva, 0, $outputlangs, 0, 0, -1, $conf->currency)) : ''; |
| 5893 | - if ($onlykey != 2 || $mysoc->useLocalTax(1)) |
|
| 5894 | - $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, $conf->currency) : ''; |
|
| 5895 | - if ($onlykey != 2 || $mysoc->useLocalTax(2)) |
|
| 5896 | - $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, $conf->currency) : ''; |
|
| 6198 | + if ($onlykey != 2 || $mysoc->useLocalTax(1)) { |
|
| 6199 | + $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, $conf->currency) : ''; |
|
| 6200 | + } |
|
| 6201 | + if ($onlykey != 2 || $mysoc->useLocalTax(2)) { |
|
| 6202 | + $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, $conf->currency) : ''; |
|
| 6203 | + } |
|
| 5897 | 6204 | |
| 5898 | 6205 | // TODO Add keys for foreign multicurrency |
| 5899 | 6206 | // For backward compatibility |
@@ -5963,23 +6270,27 @@ discard block |
||
| 5963 | 6270 | {
|
| 5964 | 6271 | global $conf, $langs; |
| 5965 | 6272 | |
| 5966 | - if (!is_array($substitutionarray)) |
|
| 5967 | - return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions'; |
|
| 6273 | + if (!is_array($substitutionarray)) { |
|
| 6274 | + return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions'; |
|
| 6275 | + } |
|
| 5968 | 6276 | |
| 5969 | - if (empty($outputlangs)) |
|
| 5970 | - $outputlangs = $langs; |
|
| 6277 | + if (empty($outputlangs)) { |
|
| 6278 | + $outputlangs = $langs; |
|
| 6279 | + } |
|
| 5971 | 6280 | |
| 5972 | 6281 | // Make substitution for language keys |
| 5973 | 6282 | if (is_object($outputlangs)) {
|
| 5974 | 6283 | while (preg_match('/__\(([^\)]+)\)__/', $text, $reg)) {
|
| 5975 | 6284 | $msgishtml = 0; |
| 5976 | - if (dol_textishtml($text, 1)) |
|
| 5977 | - $msgishtml = 1; |
|
| 6285 | + if (dol_textishtml($text, 1)) { |
|
| 6286 | + $msgishtml = 1; |
|
| 6287 | + } |
|
| 5978 | 6288 | |
| 5979 | 6289 | // If key is __(TranslationKey|langfile)__, then force load of langfile.lang |
| 5980 | 6290 | $tmp = explode('|', $reg[1]);
|
| 5981 | - if (!empty($tmp[1])) |
|
| 5982 | - $outputlangs->load($tmp[1]); |
|
| 6291 | + if (!empty($tmp[1])) { |
|
| 6292 | + $outputlangs->load($tmp[1]); |
|
| 6293 | + } |
|
| 5983 | 6294 | |
| 5984 | 6295 | $text = preg_replace('/__\(' . preg_quote($reg[1], '/') . '\)__/', $msgishtml ? dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])) : $outputlangs->transnoentitiesnoconv($reg[1]), $text);
|
| 5985 | 6296 | } |
@@ -5989,23 +6300,29 @@ discard block |
||
| 5989 | 6300 | // it is also converted. |
| 5990 | 6301 | while (preg_match('/__\[([^\]]+)\]__/', $text, $reg)) {
|
| 5991 | 6302 | $msgishtml = 0; |
| 5992 | - if (dol_textishtml($text, 1)) |
|
| 5993 | - $msgishtml = 1; |
|
| 6303 | + if (dol_textishtml($text, 1)) { |
|
| 6304 | + $msgishtml = 1; |
|
| 6305 | + } |
|
| 5994 | 6306 | |
| 5995 | 6307 | $keyfound = $reg[1]; |
| 5996 | - if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound))
|
|
| 5997 | - $newval = '*****forbidden*****'; |
|
| 5998 | - else |
|
| 5999 | - $newval = empty($conf->global->$keyfound) ? '' : $conf->global->$keyfound; |
|
| 6308 | + if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) { |
|
| 6309 | + $newval = '*****forbidden*****'; |
|
| 6310 | + } else { |
|
| 6311 | + $newval = empty($conf->global->$keyfound) ? '' : $conf->global->$keyfound; |
|
| 6312 | + } |
|
| 6000 | 6313 | $text = preg_replace('/__\[' . preg_quote($keyfound, '/') . '\]__/', $msgishtml ? dol_htmlentitiesbr($newval) : $newval, $text);
|
| 6001 | 6314 | } |
| 6002 | 6315 | |
| 6003 | 6316 | // Make substitition for array $substitutionarray |
| 6004 | 6317 | foreach ($substitutionarray as $key => $value) {
|
| 6005 | - if ($key == '__SIGNATURE__' && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) |
|
| 6006 | - $value = ''; // Protection |
|
| 6007 | - if ($key == '__USER_SIGNATURE__' && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) |
|
| 6008 | - $value = ''; // Protection |
|
| 6318 | + if ($key == '__SIGNATURE__' && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) { |
|
| 6319 | + $value = ''; |
|
| 6320 | + } |
|
| 6321 | + // Protection |
|
| 6322 | + if ($key == '__USER_SIGNATURE__' && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) { |
|
| 6323 | + $value = ''; |
|
| 6324 | + } |
|
| 6325 | + // Protection |
|
| 6009 | 6326 | |
| 6010 | 6327 | $text = str_replace("$key", "$value", $text); // We must keep the " to work when value is 123.5 for example
|
| 6011 | 6328 | } |
@@ -6051,8 +6368,9 @@ discard block |
||
| 6051 | 6368 | $dir = dol_buildpath($reldir, 0); |
| 6052 | 6369 | |
| 6053 | 6370 | // Check if directory exists |
| 6054 | - if (!dol_is_dir($dir)) |
|
| 6055 | - continue; |
|
| 6371 | + if (!dol_is_dir($dir)) { |
|
| 6372 | + continue; |
|
| 6373 | + } |
|
| 6056 | 6374 | |
| 6057 | 6375 | $substitfiles = dol_dir_list($dir, 'files', 0, 'functions_'); |
| 6058 | 6376 | foreach ($substitfiles as $substitfile) {
|
@@ -6064,8 +6382,9 @@ discard block |
||
| 6064 | 6382 | require_once $dir . $substitfile['name']; |
| 6065 | 6383 | // Call the user's function, and only if it is defined |
| 6066 | 6384 | $function_name = $module . "_" . $callfunc; |
| 6067 | - if (function_exists($function_name)) |
|
| 6068 | - $function_name($substitutionarray, $outputlangs, $object, $parameters); |
|
| 6385 | + if (function_exists($function_name)) { |
|
| 6386 | + $function_name($substitutionarray, $outputlangs, $object, $parameters); |
|
| 6387 | + } |
|
| 6069 | 6388 | } |
| 6070 | 6389 | } |
| 6071 | 6390 | } |
@@ -6101,8 +6420,9 @@ discard block |
||
| 6101 | 6420 | |
| 6102 | 6421 | $out = ''; |
| 6103 | 6422 | |
| 6104 | - if (!is_object($outputlangs)) |
|
| 6105 | - $outputlangs = $langs; |
|
| 6423 | + if (!is_object($outputlangs)) { |
|
| 6424 | + $outputlangs = $langs; |
|
| 6425 | + } |
|
| 6106 | 6426 | |
| 6107 | 6427 | if ($date_start && $date_end) {
|
| 6108 | 6428 | $out .= ($withparenthesis ? ' (' : '') . $outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($date_start, $format, false, $outputlangs), dol_print_date($date_end, $format, false, $outputlangs)) . ($withparenthesis ? ')' : '');
|
@@ -6131,20 +6451,22 @@ discard block |
||
| 6131 | 6451 | |
| 6132 | 6452 | $ret = ''; |
| 6133 | 6453 | // If order not defined, we use the setup |
| 6134 | - if ($nameorder < 0) |
|
| 6135 | - $nameorder = (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0); |
|
| 6454 | + if ($nameorder < 0) { |
|
| 6455 | + $nameorder = (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0); |
|
| 6456 | + } |
|
| 6136 | 6457 | if ($nameorder && ((string) $nameorder != '2')) {
|
| 6137 | 6458 | $ret .= $firstname; |
| 6138 | - if ($firstname && $lastname) |
|
| 6139 | - $ret .= ' '; |
|
| 6459 | + if ($firstname && $lastname) { |
|
| 6460 | + $ret .= ' '; |
|
| 6461 | + } |
|
| 6140 | 6462 | $ret .= $lastname; |
| 6141 | - } |
|
| 6142 | - else if ($nameorder == 2) {
|
|
| 6463 | + } else if ($nameorder == 2) {
|
|
| 6143 | 6464 | $ret .= $firstname; |
| 6144 | 6465 | } else {
|
| 6145 | 6466 | $ret .= $lastname; |
| 6146 | - if ($firstname && $lastname) |
|
| 6147 | - $ret .= ' '; |
|
| 6467 | + if ($firstname && $lastname) { |
|
| 6468 | + $ret .= ' '; |
|
| 6469 | + } |
|
| 6148 | 6470 | $ret .= $firstname; |
| 6149 | 6471 | } |
| 6150 | 6472 | return $ret; |
@@ -6164,13 +6486,14 @@ discard block |
||
| 6164 | 6486 | {
|
| 6165 | 6487 | //dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); This is not deprecated, it is used by setEventMessages function |
| 6166 | 6488 | if (!is_array($mesgs)) { // If mesgs is a string
|
| 6167 | - if ($mesgs) |
|
| 6168 | - $_SESSION['dol_events'][$style][] = $mesgs; |
|
| 6169 | - } |
|
| 6170 | - else { // If mesgs is an array
|
|
| 6489 | + if ($mesgs) { |
|
| 6490 | + $_SESSION['dol_events'][$style][] = $mesgs; |
|
| 6491 | + } |
|
| 6492 | + } else { // If mesgs is an array
|
|
| 6171 | 6493 | foreach ($mesgs as $mesg) {
|
| 6172 | - if ($mesg) |
|
| 6173 | - $_SESSION['dol_events'][$style][] = $mesg; |
|
| 6494 | + if ($mesg) { |
|
| 6495 | + $_SESSION['dol_events'][$style][] = $mesg; |
|
| 6496 | + } |
|
| 6174 | 6497 | } |
| 6175 | 6498 | } |
| 6176 | 6499 | } |
@@ -6190,13 +6513,16 @@ discard block |
||
| 6190 | 6513 | if (empty($mesg) && empty($mesgs)) {
|
| 6191 | 6514 | dol_syslog("Try to add a message in stack with empty message", LOG_WARNING);
|
| 6192 | 6515 | } else {
|
| 6193 | - if (!in_array((string) $style, array('mesgs', 'warnings', 'errors')))
|
|
| 6194 | - dol_print_error('', 'Bad parameter style=' . $style . ' for setEventMessages');
|
|
| 6195 | - if (empty($mesgs)) |
|
| 6196 | - setEventMessage($mesg, $style); |
|
| 6197 | - else {
|
|
| 6198 | - if (!empty($mesg) && !in_array($mesg, $mesgs)) |
|
| 6199 | - setEventMessage($mesg, $style); // Add message string if not already into array |
|
| 6516 | + if (!in_array((string) $style, array('mesgs', 'warnings', 'errors'))) { |
|
| 6517 | + dol_print_error('', 'Bad parameter style=' . $style . ' for setEventMessages'); |
|
| 6518 | + } |
|
| 6519 | + if (empty($mesgs)) { |
|
| 6520 | + setEventMessage($mesg, $style); |
|
| 6521 | + } else {
|
|
| 6522 | + if (!empty($mesg) && !in_array($mesg, $mesgs)) { |
|
| 6523 | + setEventMessage($mesg, $style); |
|
| 6524 | + } |
|
| 6525 | + // Add message string if not already into array |
|
| 6200 | 6526 | setEventMessage($mesgs, $style); |
| 6201 | 6527 | } |
| 6202 | 6528 | } |
@@ -6215,22 +6541,25 @@ discard block |
||
| 6215 | 6541 | {
|
| 6216 | 6542 | // Show mesgs |
| 6217 | 6543 | if (isset($_SESSION['dol_events']['mesgs'])) {
|
| 6218 | - if (empty($disabledoutputofmessages)) |
|
| 6219 | - dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']);
|
|
| 6544 | + if (empty($disabledoutputofmessages)) { |
|
| 6545 | + dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']); |
|
| 6546 | + } |
|
| 6220 | 6547 | unset($_SESSION['dol_events']['mesgs']); |
| 6221 | 6548 | } |
| 6222 | 6549 | |
| 6223 | 6550 | // Show errors |
| 6224 | 6551 | if (isset($_SESSION['dol_events']['errors'])) {
|
| 6225 | - if (empty($disabledoutputofmessages)) |
|
| 6226 | - dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error');
|
|
| 6552 | + if (empty($disabledoutputofmessages)) { |
|
| 6553 | + dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error'); |
|
| 6554 | + } |
|
| 6227 | 6555 | unset($_SESSION['dol_events']['errors']); |
| 6228 | 6556 | } |
| 6229 | 6557 | |
| 6230 | 6558 | // Show warnings |
| 6231 | 6559 | if (isset($_SESSION['dol_events']['warnings'])) {
|
| 6232 | - if (empty($disabledoutputofmessages)) |
|
| 6233 | - dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning');
|
|
| 6560 | + if (empty($disabledoutputofmessages)) { |
|
| 6561 | + dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning'); |
|
| 6562 | + } |
|
| 6234 | 6563 | unset($_SESSION['dol_events']['warnings']); |
| 6235 | 6564 | } |
| 6236 | 6565 | } |
@@ -6271,8 +6600,9 @@ discard block |
||
| 6271 | 6600 | foreach ($mesgarray as $message) {
|
| 6272 | 6601 | $ret++; |
| 6273 | 6602 | $out .= $langs->trans($message); |
| 6274 | - if ($ret < count($mesgarray)) |
|
| 6275 | - $out .= "<br>\n"; |
|
| 6603 | + if ($ret < count($mesgarray)) { |
|
| 6604 | + $out .= "<br>\n"; |
|
| 6605 | + } |
|
| 6276 | 6606 | } |
| 6277 | 6607 | } |
| 6278 | 6608 | if ($mesgstring) {
|
@@ -6338,8 +6668,9 @@ discard block |
||
| 6338 | 6668 | */ |
| 6339 | 6669 | function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'ok', $keepembedded = 0) |
| 6340 | 6670 | {
|
| 6341 | - if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) |
|
| 6342 | - return; |
|
| 6671 | + if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) { |
|
| 6672 | + return; |
|
| 6673 | + } |
|
| 6343 | 6674 | |
| 6344 | 6675 | $iserror = 0; |
| 6345 | 6676 | $iswarning = 0; |
@@ -6354,14 +6685,17 @@ discard block |
||
| 6354 | 6685 | break; |
| 6355 | 6686 | } |
| 6356 | 6687 | } |
| 6357 | - } else if ($mesgstring && preg_match('/class="error"/i', $mesgstring))
|
|
| 6358 | - $iserror++; |
|
| 6359 | - else if ($mesgstring && preg_match('/class="warning"/i', $mesgstring))
|
|
| 6360 | - $iswarning++; |
|
| 6361 | - if ($style == 'error') |
|
| 6362 | - $iserror++; |
|
| 6363 | - if ($style == 'warning') |
|
| 6364 | - $iswarning++; |
|
| 6688 | + } else if ($mesgstring && preg_match('/class="error"/i', $mesgstring)) { |
|
| 6689 | + $iserror++; |
|
| 6690 | + } else if ($mesgstring && preg_match('/class="warning"/i', $mesgstring)) { |
|
| 6691 | + $iswarning++; |
|
| 6692 | + } |
|
| 6693 | + if ($style == 'error') { |
|
| 6694 | + $iserror++; |
|
| 6695 | + } |
|
| 6696 | + if ($style == 'warning') { |
|
| 6697 | + $iswarning++; |
|
| 6698 | + } |
|
| 6365 | 6699 | |
| 6366 | 6700 | if ($iserror || $iswarning) {
|
| 6367 | 6701 | // Remove div from texts |
@@ -6380,9 +6714,10 @@ discard block |
||
| 6380 | 6714 | $mesgarray = $newmesgarray; |
| 6381 | 6715 | } |
| 6382 | 6716 | print get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror ? 'error' : 'warning'), $keepembedded); |
| 6383 | - } else |
|
| 6384 | - print get_htmloutput_mesg($mesgstring, $mesgarray, 'ok', $keepembedded); |
|
| 6385 | -} |
|
| 6717 | + } else { |
|
| 6718 | + print get_htmloutput_mesg($mesgstring, $mesgarray, 'ok', $keepembedded); |
|
| 6719 | + } |
|
| 6720 | + } |
|
| 6386 | 6721 | |
| 6387 | 6722 | /** |
| 6388 | 6723 | * Print formated error messages to output (Used to show messages on html output). |
@@ -6422,15 +6757,17 @@ discard block |
||
| 6422 | 6757 | $sizearray = count($array); |
| 6423 | 6758 | if ($sizearray > 0) {
|
| 6424 | 6759 | $temp = array(); |
| 6425 | - foreach (array_keys($array) as $key) |
|
| 6426 | - $temp[$key] = $array[$key][$index]; |
|
| 6760 | + foreach (array_keys($array) as $key) { |
|
| 6761 | + $temp[$key] = $array[$key][$index]; |
|
| 6762 | + } |
|
| 6427 | 6763 | |
| 6428 | - if (!$natsort) |
|
| 6429 | - ($order == 'asc') ? asort($temp) : arsort($temp); |
|
| 6430 | - else {
|
|
| 6764 | + if (!$natsort) { |
|
| 6765 | + ($order == 'asc') ? asort($temp) : arsort($temp); |
|
| 6766 | + } else {
|
|
| 6431 | 6767 | ($case_sensitive) ? natsort($temp) : natcasesort($temp); |
| 6432 | - if ($order != 'asc') |
|
| 6433 | - $temp = array_reverse($temp, true); |
|
| 6768 | + if ($order != 'asc') { |
|
| 6769 | + $temp = array_reverse($temp, true); |
|
| 6770 | + } |
|
| 6434 | 6771 | } |
| 6435 | 6772 | |
| 6436 | 6773 | $sorted = array(); |
@@ -6456,23 +6793,38 @@ discard block |
||
| 6456 | 6793 | // We must use here a binary strlen function (so not dol_strlen) |
| 6457 | 6794 | $strLength = dol_strlen($str); |
| 6458 | 6795 | for ($i = 0; $i < $strLength; $i++) {
|
| 6459 | - if (ord($str[$i]) < 0x80) |
|
| 6460 | - continue; // 0bbbbbbb |
|
| 6461 | - elseif ((ord($str[$i]) & 0xE0) == 0xC0) |
|
| 6462 | - $n = 1; // 110bbbbb |
|
| 6463 | - elseif ((ord($str[$i]) & 0xF0) == 0xE0) |
|
| 6464 | - $n = 2; // 1110bbbb |
|
| 6465 | - elseif ((ord($str[$i]) & 0xF8) == 0xF0) |
|
| 6466 | - $n = 3; // 11110bbb |
|
| 6467 | - elseif ((ord($str[$i]) & 0xFC) == 0xF8) |
|
| 6468 | - $n = 4; // 111110bb |
|
| 6469 | - elseif ((ord($str[$i]) & 0xFE) == 0xFC) |
|
| 6470 | - $n = 5; // 1111110b |
|
| 6471 | - else |
|
| 6472 | - return false; // Does not match any model |
|
| 6796 | + if (ord($str[$i]) < 0x80) { |
|
| 6797 | + continue; |
|
| 6798 | + } |
|
| 6799 | + // 0bbbbbbb |
|
| 6800 | + elseif ((ord($str[$i]) & 0xE0) == 0xC0) { |
|
| 6801 | + $n = 1; |
|
| 6802 | + } |
|
| 6803 | + // 110bbbbb |
|
| 6804 | + elseif ((ord($str[$i]) & 0xF0) == 0xE0) { |
|
| 6805 | + $n = 2; |
|
| 6806 | + } |
|
| 6807 | + // 1110bbbb |
|
| 6808 | + elseif ((ord($str[$i]) & 0xF8) == 0xF0) { |
|
| 6809 | + $n = 3; |
|
| 6810 | + } |
|
| 6811 | + // 11110bbb |
|
| 6812 | + elseif ((ord($str[$i]) & 0xFC) == 0xF8) { |
|
| 6813 | + $n = 4; |
|
| 6814 | + } |
|
| 6815 | + // 111110bb |
|
| 6816 | + elseif ((ord($str[$i]) & 0xFE) == 0xFC) { |
|
| 6817 | + $n = 5; |
|
| 6818 | + } |
|
| 6819 | + // 1111110b |
|
| 6820 | + else { |
|
| 6821 | + return false; |
|
| 6822 | + } |
|
| 6823 | + // Does not match any model |
|
| 6473 | 6824 | for ($j = 0; $j < $n; $j++) { // n bytes matching 10bbbbbb follow ?
|
| 6474 | - if (( ++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) |
|
| 6475 | - return false; |
|
| 6825 | + if (( ++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) { |
|
| 6826 | + return false; |
|
| 6827 | + } |
|
| 6476 | 6828 | } |
| 6477 | 6829 | } |
| 6478 | 6830 | return true; |
@@ -6490,15 +6842,21 @@ discard block |
||
| 6490 | 6842 | global $conf; |
| 6491 | 6843 | |
| 6492 | 6844 | $tmp = ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0
|
| 6493 | - if (empty($tmp) && !empty($_SERVER["WINDIR"])) |
|
| 6494 | - $tmp = 'iso-8859-1'; // By default for windows |
|
| 6495 | - if (empty($tmp)) |
|
| 6496 | - $tmp = 'utf-8'; // By default for other |
|
| 6497 | - if (!empty($conf->global->MAIN_FILESYSTEM_ENCODING)) |
|
| 6498 | - $tmp = $conf->global->MAIN_FILESYSTEM_ENCODING; |
|
| 6499 | - |
|
| 6500 | - if ($tmp == 'iso-8859-1') |
|
| 6501 | - return utf8_decode($str); |
|
| 6845 | + if (empty($tmp) && !empty($_SERVER["WINDIR"])) { |
|
| 6846 | + $tmp = 'iso-8859-1'; |
|
| 6847 | + } |
|
| 6848 | + // By default for windows |
|
| 6849 | + if (empty($tmp)) { |
|
| 6850 | + $tmp = 'utf-8'; |
|
| 6851 | + } |
|
| 6852 | + // By default for other |
|
| 6853 | + if (!empty($conf->global->MAIN_FILESYSTEM_ENCODING)) { |
|
| 6854 | + $tmp = $conf->global->MAIN_FILESYSTEM_ENCODING; |
|
| 6855 | + } |
|
| 6856 | + |
|
| 6857 | + if ($tmp == 'iso-8859-1') { |
|
| 6858 | + return utf8_decode($str); |
|
| 6859 | + } |
|
| 6502 | 6860 | return $str; |
| 6503 | 6861 | } |
| 6504 | 6862 | |
@@ -6520,8 +6878,9 @@ discard block |
||
| 6520 | 6878 | global $cache_codes; |
| 6521 | 6879 | |
| 6522 | 6880 | // If key empty |
| 6523 | - if ($key == '') |
|
| 6524 | - return ''; |
|
| 6881 | + if ($key == '') { |
|
| 6882 | + return ''; |
|
| 6883 | + } |
|
| 6525 | 6884 | |
| 6526 | 6885 | // Check in cache |
| 6527 | 6886 | if (isset($cache_codes[$tablename][$key][$fieldid])) { // Can be defined to 0 or ''
|
@@ -6533,20 +6892,21 @@ discard block |
||
| 6533 | 6892 | $sql = "SELECT " . $fieldid . " as valuetoget"; |
| 6534 | 6893 | $sql .= " FROM " . MAIN_DB_PREFIX . $tablename; |
| 6535 | 6894 | $sql .= " WHERE " . $fieldkey . " = '" . $db->escape($key) . "'"; |
| 6536 | - if (!empty($entityfilter)) |
|
| 6537 | - $sql .= " AND entity IN (" . getEntity($tablename) . ")";
|
|
| 6895 | + if (!empty($entityfilter)) { |
|
| 6896 | + $sql .= " AND entity IN (" . getEntity($tablename) . ")"; |
|
| 6897 | + } |
|
| 6538 | 6898 | |
| 6539 | 6899 | $resql = $db->query($sql); |
| 6540 | 6900 | if ($resql) {
|
| 6541 | 6901 | $obj = $db->fetch_object($resql); |
| 6542 | - if ($obj) |
|
| 6543 | - $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget; |
|
| 6544 | - else |
|
| 6545 | - $cache_codes[$tablename][$key][$fieldid] = ''; |
|
| 6902 | + if ($obj) { |
|
| 6903 | + $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget; |
|
| 6904 | + } else { |
|
| 6905 | + $cache_codes[$tablename][$key][$fieldid] = ''; |
|
| 6906 | + } |
|
| 6546 | 6907 | $db->free($resql); |
| 6547 | 6908 | return $cache_codes[$tablename][$key][$fieldid]; |
| 6548 | - } |
|
| 6549 | - else {
|
|
| 6909 | + } else {
|
|
| 6550 | 6910 | return -1; |
| 6551 | 6911 | } |
| 6552 | 6912 | } |
@@ -6593,16 +6953,17 @@ discard block |
||
| 6593 | 6953 | global $soc; // For backward compatibility |
| 6594 | 6954 | //print $s."<br>\n"; |
| 6595 | 6955 | if ($returnvalue) {
|
| 6596 | - if ($hideerrors) |
|
| 6597 | - return @eval('return ' . $s . ';');
|
|
| 6598 | - else |
|
| 6599 | - return eval('return ' . $s . ';');
|
|
| 6600 | - } |
|
| 6601 | - else {
|
|
| 6602 | - if ($hideerrors) |
|
| 6603 | - @eval($s); |
|
| 6604 | - else |
|
| 6605 | - eval($s); |
|
| 6956 | + if ($hideerrors) { |
|
| 6957 | + return @eval('return ' . $s . ';'); |
|
| 6958 | + } else { |
|
| 6959 | + return eval('return ' . $s . ';'); |
|
| 6960 | + } |
|
| 6961 | + } else {
|
|
| 6962 | + if ($hideerrors) { |
|
| 6963 | + @eval($s); |
|
| 6964 | + } else { |
|
| 6965 | + eval($s); |
|
| 6966 | + } |
|
| 6606 | 6967 | } |
| 6607 | 6968 | } |
| 6608 | 6969 | |
@@ -6628,8 +6989,9 @@ discard block |
||
| 6628 | 6989 | {
|
| 6629 | 6990 | global $langs; |
| 6630 | 6991 | |
| 6631 | - if (empty($codelang)) |
|
| 6632 | - return ''; |
|
| 6992 | + if (empty($codelang)) { |
|
| 6993 | + return ''; |
|
| 6994 | + } |
|
| 6633 | 6995 | |
| 6634 | 6996 | if ($codelang == 'auto') {
|
| 6635 | 6997 | return '<span class="fa fa-globe"></span>'; |
@@ -6643,9 +7005,9 @@ discard block |
||
| 6643 | 7005 | 'sv_SV' => 'se' |
| 6644 | 7006 | ); |
| 6645 | 7007 | |
| 6646 | - if (isset($langtocountryflag[$codelang])) |
|
| 6647 | - $flagImage = $langtocountryflag[$codelang]; |
|
| 6648 | - else {
|
|
| 7008 | + if (isset($langtocountryflag[$codelang])) { |
|
| 7009 | + $flagImage = $langtocountryflag[$codelang]; |
|
| 7010 | + } else {
|
|
| 6649 | 7011 | $tmparray = explode('_', $codelang);
|
| 6650 | 7012 | $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1]; |
| 6651 | 7013 | } |
@@ -6663,15 +7025,20 @@ discard block |
||
| 6663 | 7025 | {
|
| 6664 | 7026 | global $mysoc; |
| 6665 | 7027 | |
| 6666 | - if (strtoupper($countrycode) == 'MQ') |
|
| 6667 | - return 'fr_CA'; |
|
| 6668 | - if (strtoupper($countrycode) == 'SE') |
|
| 6669 | - return 'sv_SE'; // se_SE is Sami/Sweden, and we want in priority sv_SE for SE country |
|
| 7028 | + if (strtoupper($countrycode) == 'MQ') { |
|
| 7029 | + return 'fr_CA'; |
|
| 7030 | + } |
|
| 7031 | + if (strtoupper($countrycode) == 'SE') { |
|
| 7032 | + return 'sv_SE'; |
|
| 7033 | + } |
|
| 7034 | + // se_SE is Sami/Sweden, and we want in priority sv_SE for SE country |
|
| 6670 | 7035 | if (strtoupper($countrycode) == 'CH') {
|
| 6671 | - if ($mysoc->country_code == 'FR') |
|
| 6672 | - return 'fr_CH'; |
|
| 6673 | - if ($mysoc->country_code == 'DE') |
|
| 6674 | - return 'de_CH'; |
|
| 7036 | + if ($mysoc->country_code == 'FR') { |
|
| 7037 | + return 'fr_CH'; |
|
| 7038 | + } |
|
| 7039 | + if ($mysoc->country_code == 'DE') { |
|
| 7040 | + return 'de_CH'; |
|
| 7041 | + } |
|
| 6675 | 7042 | } |
| 6676 | 7043 | |
| 6677 | 7044 | // Locale list taken from: |
@@ -6849,8 +7216,9 @@ discard block |
||
| 6849 | 7216 | ); |
| 6850 | 7217 | |
| 6851 | 7218 | $buildprimarykeytotest = strtolower($countrycode) . '-' . strtoupper($countrycode); |
| 6852 | - if (in_array($buildprimarykeytotest, $locales)) |
|
| 6853 | - return strtolower($countrycode) . '_' . strtoupper($countrycode); |
|
| 7219 | + if (in_array($buildprimarykeytotest, $locales)) { |
|
| 7220 | + return strtolower($countrycode) . '_' . strtoupper($countrycode); |
|
| 7221 | + } |
|
| 6854 | 7222 | |
| 6855 | 7223 | foreach ($locales as $locale) {
|
| 6856 | 7224 | $locale_language = locale_get_primary_language($locale); |
@@ -6904,18 +7272,21 @@ discard block |
||
| 6904 | 7272 | |
| 6905 | 7273 | if ($mode == 'add' && !preg_match('/^\-/', $values[1])) {
|
| 6906 | 7274 | if (count($values) == 6) { // new declaration with permissions: $value='objecttype:+tabname1:Title1:langfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__'
|
| 6907 | - if ($values[0] != $type) |
|
| 6908 | - continue; |
|
| 7275 | + if ($values[0] != $type) { |
|
| 7276 | + continue; |
|
| 7277 | + } |
|
| 6909 | 7278 | |
| 6910 | 7279 | if (verifCond($values[4])) {
|
| 6911 | - if ($values[3]) |
|
| 6912 | - $langs->load($values[3]); |
|
| 7280 | + if ($values[3]) { |
|
| 7281 | + $langs->load($values[3]); |
|
| 7282 | + } |
|
| 6913 | 7283 | if (preg_match('/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
|
| 6914 | 7284 | $substitutionarray = array(); |
| 6915 | 7285 | complete_substitutions_array($substitutionarray, $langs, $object, array('needforkey' => $values[2]));
|
| 6916 | 7286 | $label = make_substitutions($reg[1], $substitutionarray); |
| 6917 | - } else |
|
| 6918 | - $label = $langs->trans($values[2]); |
|
| 7287 | + } else { |
|
| 7288 | + $label = $langs->trans($values[2]); |
|
| 7289 | + } |
|
| 6919 | 7290 | |
| 6920 | 7291 | //$head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]), 1);
|
| 6921 | 7292 | $head[$h][0] = BASE_URI . preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]);
|
@@ -6923,30 +7294,32 @@ discard block |
||
| 6923 | 7294 | $head[$h][2] = str_replace('+', '', $values[1]);
|
| 6924 | 7295 | $h++; |
| 6925 | 7296 | } |
| 6926 | - } |
|
| 6927 | - else if (count($values) == 5) { // deprecated
|
|
| 7297 | + } else if (count($values) == 5) { // deprecated
|
|
| 6928 | 7298 | dol_syslog('Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING);
|
| 6929 | 7299 | |
| 6930 | - if ($values[0] != $type) |
|
| 6931 | - continue; |
|
| 6932 | - if ($values[3]) |
|
| 6933 | - $langs->load($values[3]); |
|
| 7300 | + if ($values[0] != $type) { |
|
| 7301 | + continue; |
|
| 7302 | + } |
|
| 7303 | + if ($values[3]) { |
|
| 7304 | + $langs->load($values[3]); |
|
| 7305 | + } |
|
| 6934 | 7306 | if (preg_match('/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
|
| 6935 | 7307 | $substitutionarray = array(); |
| 6936 | 7308 | complete_substitutions_array($substitutionarray, $langs, $object, array('needforkey' => $values[2]));
|
| 6937 | 7309 | $label = make_substitutions($reg[1], $substitutionarray); |
| 6938 | - } else |
|
| 6939 | - $label = $langs->trans($values[2]); |
|
| 7310 | + } else { |
|
| 7311 | + $label = $langs->trans($values[2]); |
|
| 7312 | + } |
|
| 6940 | 7313 | |
| 6941 | 7314 | $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[4]), 1);
|
| 6942 | 7315 | $head[$h][1] = $label; |
| 6943 | 7316 | $head[$h][2] = str_replace('+', '', $values[1]);
|
| 6944 | 7317 | $h++; |
| 6945 | 7318 | } |
| 6946 | - } |
|
| 6947 | - else if ($mode == 'remove' && preg_match('/^\-/', $values[1])) {
|
|
| 6948 | - if ($values[0] != $type) |
|
| 6949 | - continue; |
|
| 7319 | + } else if ($mode == 'remove' && preg_match('/^\-/', $values[1])) {
|
|
| 7320 | + if ($values[0] != $type) { |
|
| 7321 | + continue; |
|
| 7322 | + } |
|
| 6950 | 7323 | $tabname = str_replace('-', '', $values[1]);
|
| 6951 | 7324 | foreach ($head as $key => $val) {
|
| 6952 | 7325 | $condition = (!empty($values[3]) ? verifCond($values[3]) : 1); |
@@ -6988,10 +7361,11 @@ discard block |
||
| 6988 | 7361 | global $action; |
| 6989 | 7362 | global $micro_start_time; |
| 6990 | 7363 | |
| 6991 | - if ($zone == 'private') |
|
| 6992 | - print "\n" . '<!-- Common footer for private page -->' . "\n"; |
|
| 6993 | - else |
|
| 6994 | - print "\n" . '<!-- Common footer for public page -->' . "\n"; |
|
| 7364 | + if ($zone == 'private') { |
|
| 7365 | + print "\n" . '<!-- Common footer for private page -->' . "\n"; |
|
| 7366 | + } else { |
|
| 7367 | + print "\n" . '<!-- Common footer for public page -->' . "\n"; |
|
| 7368 | + } |
|
| 6995 | 7369 | |
| 6996 | 7370 | // A div to store page_y POST parameter so we can read it using javascript |
| 6997 | 7371 | print "\n<!-- A div to store page_y POST paramater -->\n"; |
@@ -7000,8 +7374,9 @@ discard block |
||
| 7000 | 7374 | $parameters = array(); |
| 7001 | 7375 | $reshook = $hookmanager->executeHooks('printCommonFooter', $parameters); // Note that $action and $object may have been modified by some hooks
|
| 7002 | 7376 | if (empty($reshook)) {
|
| 7003 | - if (!empty($conf->global->MAIN_HTML_FOOTER)) |
|
| 7004 | - print $conf->global->MAIN_HTML_FOOTER . "\n"; |
|
| 7377 | + if (!empty($conf->global->MAIN_HTML_FOOTER)) { |
|
| 7378 | + print $conf->global->MAIN_HTML_FOOTER . "\n"; |
|
| 7379 | + } |
|
| 7005 | 7380 | |
| 7006 | 7381 | print "\n"; |
| 7007 | 7382 | if (!empty($conf->use_javascript_ajax)) {
|
@@ -7024,8 +7399,9 @@ discard block |
||
| 7024 | 7399 | print '/* JS CODE TO ENABLE to manage focus and mandatory form fields */' . "\n"; |
| 7025 | 7400 | $relativepathstring = $_SERVER["PHP_SELF"]; |
| 7026 | 7401 | // Clean $relativepathstring |
| 7027 | - if (constant('DOL_URL_ROOT'))
|
|
| 7028 | - $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_URL_ROOT'), '/') . '/', '', $relativepathstring);
|
|
| 7402 | + if (constant('DOL_URL_ROOT')) { |
|
| 7403 | + $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_URL_ROOT'), '/') . '/', '', $relativepathstring); |
|
| 7404 | + } |
|
| 7029 | 7405 | $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
|
| 7030 | 7406 | $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
|
| 7031 | 7407 | $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
|
@@ -7036,14 +7412,17 @@ discard block |
||
| 7036 | 7412 | $tmpqueryarraytohave = explode('&', $defkey);
|
| 7037 | 7413 | $foundintru = 0; |
| 7038 | 7414 | foreach ($tmpqueryarraytohave as $tmpquerytohave) {
|
| 7039 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
| 7040 | - $foundintru = 1; |
|
| 7415 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
| 7416 | + $foundintru = 1; |
|
| 7417 | + } |
|
| 7041 | 7418 | } |
| 7042 | - if (!$foundintru) |
|
| 7043 | - $qualified = 1; |
|
| 7419 | + if (!$foundintru) { |
|
| 7420 | + $qualified = 1; |
|
| 7421 | + } |
|
| 7044 | 7422 | //var_dump($defkey.'-'.$qualified); |
| 7045 | - } else |
|
| 7046 | - $qualified = 1; |
|
| 7423 | + } else { |
|
| 7424 | + $qualified = 1; |
|
| 7425 | + } |
|
| 7047 | 7426 | |
| 7048 | 7427 | if ($qualified) {
|
| 7049 | 7428 | foreach ($defval as $paramkey => $paramval) {
|
@@ -7062,14 +7441,17 @@ discard block |
||
| 7062 | 7441 | $tmpqueryarraytohave = explode('&', $defkey);
|
| 7063 | 7442 | $foundintru = 0; |
| 7064 | 7443 | foreach ($tmpqueryarraytohave as $tmpquerytohave) {
|
| 7065 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
| 7066 | - $foundintru = 1; |
|
| 7444 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
| 7445 | + $foundintru = 1; |
|
| 7446 | + } |
|
| 7067 | 7447 | } |
| 7068 | - if (!$foundintru) |
|
| 7069 | - $qualified = 1; |
|
| 7448 | + if (!$foundintru) { |
|
| 7449 | + $qualified = 1; |
|
| 7450 | + } |
|
| 7070 | 7451 | //var_dump($defkey.'-'.$qualified); |
| 7071 | - } else |
|
| 7072 | - $qualified = 1; |
|
| 7452 | + } else { |
|
| 7453 | + $qualified = 1; |
|
| 7454 | + } |
|
| 7073 | 7455 | |
| 7074 | 7456 | if ($qualified) {
|
| 7075 | 7457 | foreach ($defval as $paramkey => $paramval) {
|
@@ -7108,8 +7490,9 @@ discard block |
||
| 7108 | 7490 | print "\n"; |
| 7109 | 7491 | print "/* JS CODE TO ENABLE to add memory info */\n"; |
| 7110 | 7492 | print 'window.console && console.log("';
|
| 7111 | - if (!empty($conf->global->MEMCACHED_SERVER)) |
|
| 7112 | - print 'MEMCACHED_SERVER=' . $conf->global->MEMCACHED_SERVER . ' - '; |
|
| 7493 | + if (!empty($conf->global->MEMCACHED_SERVER)) { |
|
| 7494 | + print 'MEMCACHED_SERVER=' . $conf->global->MEMCACHED_SERVER . ' - '; |
|
| 7495 | + } |
|
| 7113 | 7496 | print 'MAIN_OPTIMIZE_SPEED=' . (isset($conf->global->MAIN_OPTIMIZE_SPEED) ? $conf->global->MAIN_OPTIMIZE_SPEED : 'off'); |
| 7114 | 7497 | if (!empty($micro_start_time)) { // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in global variable.
|
| 7115 | 7498 | $micro_end_time = microtime(true); |
@@ -7239,8 +7622,9 @@ discard block |
||
| 7239 | 7622 | |
| 7240 | 7623 | $crits = explode(' ', $value);
|
| 7241 | 7624 | $res = ''; |
| 7242 | - if (!is_array($fields)) |
|
| 7243 | - $fields = array($fields); |
|
| 7625 | + if (!is_array($fields)) { |
|
| 7626 | + $fields = array($fields); |
|
| 7627 | + } |
|
| 7244 | 7628 | |
| 7245 | 7629 | $nboffields = count($fields); |
| 7246 | 7630 | $end2 = count($crits); |
@@ -7303,8 +7687,9 @@ discard block |
||
| 7303 | 7687 | $tmpcrits = explode('|', $crit);
|
| 7304 | 7688 | $i3 = 0; |
| 7305 | 7689 | foreach ($tmpcrits as $tmpcrit) {
|
| 7306 | - if (empty($tmpcrit)) |
|
| 7307 | - continue; |
|
| 7690 | + if (empty($tmpcrit)) { |
|
| 7691 | + continue; |
|
| 7692 | + } |
|
| 7308 | 7693 | |
| 7309 | 7694 | $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : ''); |
| 7310 | 7695 | |
@@ -7340,8 +7725,9 @@ discard block |
||
| 7340 | 7725 | } |
| 7341 | 7726 | $i++; |
| 7342 | 7727 | } |
| 7343 | - if ($newres) |
|
| 7344 | - $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') . $newres . ($i2 > 1 ? ')' : '');
|
|
| 7728 | + if ($newres) { |
|
| 7729 | + $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') . $newres . ($i2 > 1 ? ')' : ''); |
|
| 7730 | + } |
|
| 7345 | 7731 | $j++; |
| 7346 | 7732 | } |
| 7347 | 7733 | $res = ($nofirstand ? "" : " AND ") . "(" . $res . ")";
|
@@ -7381,29 +7767,37 @@ discard block |
||
| 7381 | 7767 | function getImageFileNameForSize($file, $extName, $extImgTarget = '') |
| 7382 | 7768 | {
|
| 7383 | 7769 | $dirName = dirname($file); |
| 7384 | - if ($dirName == '.') |
|
| 7385 | - $dirName = ''; |
|
| 7770 | + if ($dirName == '.') { |
|
| 7771 | + $dirName = ''; |
|
| 7772 | + } |
|
| 7386 | 7773 | |
| 7387 | 7774 | $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i', '', $file); // We remove extension, whatever is its case
|
| 7388 | 7775 | $fileName = basename($fileName); |
| 7389 | 7776 | |
| 7390 | - if (empty($extImgTarget)) |
|
| 7391 | - $extImgTarget = (preg_match('/\.jpg$/i', $file) ? '.jpg' : '');
|
|
| 7392 | - if (empty($extImgTarget)) |
|
| 7393 | - $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '');
|
|
| 7394 | - if (empty($extImgTarget)) |
|
| 7395 | - $extImgTarget = (preg_match('/\.gif$/i', $file) ? '.gif' : '');
|
|
| 7396 | - if (empty($extImgTarget)) |
|
| 7397 | - $extImgTarget = (preg_match('/\.png$/i', $file) ? '.png' : '');
|
|
| 7398 | - if (empty($extImgTarget)) |
|
| 7399 | - $extImgTarget = (preg_match('/\.bmp$/i', $file) ? '.bmp' : '');
|
|
| 7400 | - |
|
| 7401 | - if (!$extImgTarget) |
|
| 7402 | - return $file; |
|
| 7777 | + if (empty($extImgTarget)) { |
|
| 7778 | + $extImgTarget = (preg_match('/\.jpg$/i', $file) ? '.jpg' : ''); |
|
| 7779 | + } |
|
| 7780 | + if (empty($extImgTarget)) { |
|
| 7781 | + $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : ''); |
|
| 7782 | + } |
|
| 7783 | + if (empty($extImgTarget)) { |
|
| 7784 | + $extImgTarget = (preg_match('/\.gif$/i', $file) ? '.gif' : ''); |
|
| 7785 | + } |
|
| 7786 | + if (empty($extImgTarget)) { |
|
| 7787 | + $extImgTarget = (preg_match('/\.png$/i', $file) ? '.png' : ''); |
|
| 7788 | + } |
|
| 7789 | + if (empty($extImgTarget)) { |
|
| 7790 | + $extImgTarget = (preg_match('/\.bmp$/i', $file) ? '.bmp' : ''); |
|
| 7791 | + } |
|
| 7792 | + |
|
| 7793 | + if (!$extImgTarget) { |
|
| 7794 | + return $file; |
|
| 7795 | + } |
|
| 7403 | 7796 | |
| 7404 | 7797 | $subdir = ''; |
| 7405 | - if ($extName) |
|
| 7406 | - $subdir = 'thumbs/'; |
|
| 7798 | + if ($extName) { |
|
| 7799 | + $subdir = 'thumbs/'; |
|
| 7800 | + } |
|
| 7407 | 7801 | |
| 7408 | 7802 | return ($dirName ? $dirName . '/' : '') . $subdir . $fileName . $extName . $extImgTarget; // New filename for thumb |
| 7409 | 7803 | } |
@@ -7421,8 +7815,9 @@ discard block |
||
| 7421 | 7815 | {
|
| 7422 | 7816 | global $conf, $langs; |
| 7423 | 7817 | |
| 7424 | - if (empty($conf->use_javascript_ajax)) |
|
| 7425 | - return ''; |
|
| 7818 | + if (empty($conf->use_javascript_ajax)) { |
|
| 7819 | + return ''; |
|
| 7820 | + } |
|
| 7426 | 7821 | |
| 7427 | 7822 | $mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css', 'svg+xml');
|
| 7428 | 7823 | //$mime_preview[]='vnd.oasis.opendocument.presentation'; |
@@ -7430,18 +7825,20 @@ discard block |
||
| 7430 | 7825 | $num_mime = array_search(dol_mimetype($relativepath, '', 1), $mime_preview); |
| 7431 | 7826 | |
| 7432 | 7827 | if ($alldata == 1) {
|
| 7433 | - if ($num_mime !== false) |
|
| 7434 | - return array('target' => '_blank', 'css' => 'documentpreview', 'url' => DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : ''), 'mime' => dol_mimetype($relativepath),);
|
|
| 7435 | - else |
|
| 7436 | - return array(); |
|
| 7828 | + if ($num_mime !== false) { |
|
| 7829 | + return array('target' => '_blank', 'css' => 'documentpreview', 'url' => DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : ''), 'mime' => dol_mimetype($relativepath),); |
|
| 7830 | + } else { |
|
| 7831 | + return array(); |
|
| 7832 | + } |
|
| 7437 | 7833 | } |
| 7438 | 7834 | |
| 7439 | 7835 | // old behavior |
| 7440 | - if ($num_mime !== false) |
|
| 7441 | - return 'javascript:document_preview(\'' . dol_escape_js(DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : '')) . '\', \'' . dol_mimetype($relativepath) . '\', \'' . dol_escape_js($langs->trans('Preview')) . '\')';
|
|
| 7442 | - else |
|
| 7443 | - return ''; |
|
| 7444 | -} |
|
| 7836 | + if ($num_mime !== false) { |
|
| 7837 | + return 'javascript:document_preview(\'' . dol_escape_js(DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : '')) . '\', \'' . dol_mimetype($relativepath) . '\', \'' . dol_escape_js($langs->trans('Preview')) . '\')'; |
|
| 7838 | + } else { |
|
| 7839 | + return ''; |
|
| 7840 | + } |
|
| 7841 | + } |
|
| 7445 | 7842 | |
| 7446 | 7843 | /** |
| 7447 | 7844 | * Make content of an input box selected when we click into input field. |
@@ -7458,8 +7855,9 @@ discard block |
||
| 7458 | 7855 | jQuery("#' . $htmlname . '").click(function() { jQuery(this).select(); } );
|
| 7459 | 7856 | }); |
| 7460 | 7857 | </script>'; |
| 7461 | - if ($addlink) |
|
| 7462 | - $out .= ' <a href="' . $addlink . '" target="_blank">' . $langs->trans("Link") . '</a>';
|
|
| 7858 | + if ($addlink) { |
|
| 7859 | + $out .= ' <a href="' . $addlink . '" target="_blank">' . $langs->trans("Link") . '</a>'; |
|
| 7860 | + } |
|
| 7463 | 7861 | return $out; |
| 7464 | 7862 | } |
| 7465 | 7863 | |
@@ -7841,8 +8239,9 @@ discard block |
||
| 7841 | 8239 | if (!isset($dictvalues[$tablename])) {
|
| 7842 | 8240 | $dictvalues[$tablename] = array(); |
| 7843 | 8241 | $sql = 'SELECT * FROM ' . $tablename . ' WHERE 1'; |
| 7844 | - if ($checkentity) |
|
| 7845 | - $sql .= ' AND entity IN (0,' . getEntity($tablename) . ')'; |
|
| 8242 | + if ($checkentity) { |
|
| 8243 | + $sql .= ' AND entity IN (0,' . getEntity($tablename) . ')'; |
|
| 8244 | + } |
|
| 7846 | 8245 | |
| 7847 | 8246 | $resql = $db->query($sql); |
| 7848 | 8247 | if ($resql) {
|
@@ -7854,11 +8253,14 @@ discard block |
||
| 7854 | 8253 | } |
| 7855 | 8254 | } |
| 7856 | 8255 | |
| 7857 | - if (!empty($dictvalues[$tablename][$id])) |
|
| 7858 | - return $dictvalues[$tablename][$id]->{$field}; // Found
|
|
| 8256 | + if (!empty($dictvalues[$tablename][$id])) { |
|
| 8257 | + return $dictvalues[$tablename][$id]->{$field}; |
|
| 8258 | + } |
|
| 8259 | + // Found |
|
| 7859 | 8260 | else { // Not found
|
| 7860 | - if ($id > 0) |
|
| 7861 | - return $id; |
|
| 8261 | + if ($id > 0) { |
|
| 8262 | + return $id; |
|
| 8263 | + } |
|
| 7862 | 8264 | return ''; |
| 7863 | 8265 | } |
| 7864 | 8266 | } |
@@ -7888,8 +8290,9 @@ discard block |
||
| 7888 | 8290 | $b = hexdec($hexb); |
| 7889 | 8291 | } |
| 7890 | 8292 | $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm |
| 7891 | - if ($bright > 0.6) |
|
| 7892 | - $res = 1; |
|
| 8293 | + if ($bright > 0.6) { |
|
| 8294 | + $res = 1; |
|
| 8295 | + } |
|
| 7893 | 8296 | } |
| 7894 | 8297 | return $res; |
| 7895 | 8298 | } |
@@ -7908,8 +8311,10 @@ discard block |
||
| 7908 | 8311 | |
| 7909 | 8312 | //print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms']; |
| 7910 | 8313 | //print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal); |
| 7911 | - if (empty($menuentry['enabled'])) |
|
| 7912 | - return 0; // Entry disabled by condition |
|
| 8314 | + if (empty($menuentry['enabled'])) { |
|
| 8315 | + return 0; |
|
| 8316 | + } |
|
| 8317 | + // Entry disabled by condition |
|
| 7913 | 8318 | if ($type_user && $menuentry['module']) {
|
| 7914 | 8319 | $tmploops = explode('|', $menuentry['module']);
|
| 7915 | 8320 | $found = 0; |
@@ -7919,15 +8324,23 @@ discard block |
||
| 7919 | 8324 | break; |
| 7920 | 8325 | } |
| 7921 | 8326 | } |
| 7922 | - if (!$found) |
|
| 7923 | - return 0; // Entry is for menus all excluded to external users |
|
| 7924 | - } |
|
| 7925 | - if (!$menuentry['perms'] && $type_user) |
|
| 7926 | - return 0; // No permissions and user is external |
|
| 7927 | - if (!$menuentry['perms'] && !empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) |
|
| 7928 | - return 0; // No permissions and option to hide when not allowed, even for internal user, is on |
|
| 7929 | - if (!$menuentry['perms']) |
|
| 7930 | - return 2; // No permissions and user is external |
|
| 8327 | + if (!$found) { |
|
| 8328 | + return 0; |
|
| 8329 | + } |
|
| 8330 | + // Entry is for menus all excluded to external users |
|
| 8331 | + } |
|
| 8332 | + if (!$menuentry['perms'] && $type_user) { |
|
| 8333 | + return 0; |
|
| 8334 | + } |
|
| 8335 | + // No permissions and user is external |
|
| 8336 | + if (!$menuentry['perms'] && !empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) { |
|
| 8337 | + return 0; |
|
| 8338 | + } |
|
| 8339 | + // No permissions and option to hide when not allowed, even for internal user, is on |
|
| 8340 | + if (!$menuentry['perms']) { |
|
| 8341 | + return 2; |
|
| 8342 | + } |
|
| 8343 | + // No permissions and user is external |
|
| 7931 | 8344 | return 1; |
| 7932 | 8345 | } |
| 7933 | 8346 | |
@@ -51,8 +51,9 @@ discard block |
||
| 51 | 51 | $id = 'mainmenu'; |
| 52 | 52 | $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
|
| 53 | 53 | |
| 54 | - if (empty($noout)) |
|
| 55 | - print_start_menu_array(); |
|
| 54 | + if (empty($noout)) { |
|
| 55 | + print_start_menu_array(); |
|
| 56 | + } |
|
| 56 | 57 | |
| 57 | 58 | $usemenuhider = (GETPOST('testmenuhider', 'int') || !empty($conf->global->MAIN_TESTMENUHIDER));
|
| 58 | 59 | |
@@ -71,14 +72,16 @@ discard block |
||
| 71 | 72 | if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home") {
|
| 72 | 73 | $classname = 'class="tmenusel"'; |
| 73 | 74 | $_SESSION['idmenu'] = ''; |
| 74 | - } else |
|
| 75 | - $classname = 'class="tmenu"'; |
|
| 75 | + } else { |
|
| 76 | + $classname = 'class="tmenu"'; |
|
| 77 | + } |
|
| 76 | 78 | $idsel = 'home'; |
| 77 | 79 | |
| 78 | 80 | $titlehome = $langs->trans("Home");
|
| 79 | - if (!empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) |
|
| 80 | - $titlehome = ' <span class="fa fa-home"></span> '; |
|
| 81 | -//$menu->add('/index.php?mainmenu=home&leftmenu=home', $titlehome, 0, $showmode, $atarget, "home", '', 10, $id, $idsel, $classname);
|
|
| 81 | + if (!empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) { |
|
| 82 | + $titlehome = ' <span class="fa fa-home"></span> '; |
|
| 83 | + } |
|
| 84 | + //$menu->add('/index.php?mainmenu=home&leftmenu=home', $titlehome, 0, $showmode, $atarget, "home", '', 10, $id, $idsel, $classname);
|
|
| 82 | 85 | $menu->add('?mainmenu=home&leftmenu=home', $titlehome, 0, $showmode, $atarget, "home", '', 10, $id, $idsel, $classname);
|
| 83 | 86 | |
| 84 | 87 | // Members |
@@ -93,8 +96,9 @@ discard block |
||
| 93 | 96 | if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "members") {
|
| 94 | 97 | $classname = 'class="tmenusel"'; |
| 95 | 98 | $_SESSION['idmenu'] = ''; |
| 96 | - } else |
|
| 97 | - $classname = 'class="tmenu"'; |
|
| 99 | + } else { |
|
| 100 | + $classname = 'class="tmenu"'; |
|
| 101 | + } |
|
| 98 | 102 | $idsel = 'members'; |
| 99 | 103 | |
| 100 | 104 | //$menu->add('/adherents/index.php?mainmenu=members&leftmenu=', $langs->trans("MenuMembers"), 0, $showmode, $atarget, "members", '', 18, $id, $idsel, $classname);
|
@@ -116,8 +120,9 @@ discard block |
||
| 116 | 120 | if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "companies") {
|
| 117 | 121 | $classname = 'class="tmenusel"'; |
| 118 | 122 | $_SESSION['idmenu'] = ''; |
| 119 | - } else |
|
| 120 | - $classname = 'class="tmenu"'; |
|
| 123 | + } else { |
|
| 124 | + $classname = 'class="tmenu"'; |
|
| 125 | + } |
|
| 121 | 126 | $idsel = 'companies'; |
| 122 | 127 | |
| 123 | 128 | //$menu->add('/societe/index.php?mainmenu=companies&leftmenu=', $langs->trans("ThirdParties"), 0, $showmode, $atarget, "companies", '', 20, $id, $idsel, $classname);
|
@@ -138,8 +143,9 @@ discard block |
||
| 138 | 143 | if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "products") {
|
| 139 | 144 | $classname = 'class="tmenusel"'; |
| 140 | 145 | $_SESSION['idmenu'] = ''; |
| 141 | - } else |
|
| 142 | - $classname = 'class="tmenu"'; |
|
| 146 | + } else { |
|
| 147 | + $classname = 'class="tmenu"'; |
|
| 148 | + } |
|
| 143 | 149 | $idsel = 'products'; |
| 144 | 150 | |
| 145 | 151 | $chaine = ""; |
@@ -169,8 +175,9 @@ discard block |
||
| 169 | 175 | if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "project") {
|
| 170 | 176 | $classname = 'class="tmenusel"'; |
| 171 | 177 | $_SESSION['idmenu'] = ''; |
| 172 | - } else |
|
| 173 | - $classname = 'class="tmenu"'; |
|
| 178 | + } else { |
|
| 179 | + $classname = 'class="tmenu"'; |
|
| 180 | + } |
|
| 174 | 181 | $idsel = 'project'; |
| 175 | 182 | |
| 176 | 183 | $title = $langs->trans("LeadsOrProjects"); // Leads and opportunities by default
|
@@ -192,18 +199,24 @@ discard block |
||
| 192 | 199 | |
| 193 | 200 | // Commercial |
| 194 | 201 | $menuqualified = 0; |
| 195 | - if (!empty($conf->propal->enabled)) |
|
| 196 | - $menuqualified++; |
|
| 197 | - if (!empty($conf->commande->enabled)) |
|
| 198 | - $menuqualified++; |
|
| 199 | - if (!empty($conf->supplier_order->enabled)) |
|
| 200 | - $menuqualified++; |
|
| 201 | - if (!empty($conf->supplier_proposal->enabled)) |
|
| 202 | - $menuqualified++; |
|
| 203 | - if (!empty($conf->contrat->enabled)) |
|
| 204 | - $menuqualified++; |
|
| 205 | - if (!empty($conf->ficheinter->enabled)) |
|
| 206 | - $menuqualified++; |
|
| 202 | + if (!empty($conf->propal->enabled)) { |
|
| 203 | + $menuqualified++; |
|
| 204 | + } |
|
| 205 | + if (!empty($conf->commande->enabled)) { |
|
| 206 | + $menuqualified++; |
|
| 207 | + } |
|
| 208 | + if (!empty($conf->supplier_order->enabled)) { |
|
| 209 | + $menuqualified++; |
|
| 210 | + } |
|
| 211 | + if (!empty($conf->supplier_proposal->enabled)) { |
|
| 212 | + $menuqualified++; |
|
| 213 | + } |
|
| 214 | + if (!empty($conf->contrat->enabled)) { |
|
| 215 | + $menuqualified++; |
|
| 216 | + } |
|
| 217 | + if (!empty($conf->ficheinter->enabled)) { |
|
| 218 | + $menuqualified++; |
|
| 219 | + } |
|
| 207 | 220 | $tmpentry = array( |
| 208 | 221 | 'enabled' => $menuqualified, |
| 209 | 222 | 'perms' => (!empty($user->rights->societe->lire) || !empty($user->rights->societe->contact->lire)), |
@@ -217,8 +230,9 @@ discard block |
||
| 217 | 230 | if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "commercial") {
|
| 218 | 231 | $classname = 'class="tmenusel"'; |
| 219 | 232 | $_SESSION['idmenu'] = ''; |
| 220 | - } else |
|
| 221 | - $classname = 'class="tmenu"'; |
|
| 233 | + } else { |
|
| 234 | + $classname = 'class="tmenu"'; |
|
| 235 | + } |
|
| 222 | 236 | $idsel = 'commercial'; |
| 223 | 237 | |
| 224 | 238 | //$menu->add('/comm/index.php?mainmenu=commercial&leftmenu=', $langs->trans("Commercial"), 0, $showmode, $atarget, "commercial", "", 40, $id, $idsel, $classname);
|
@@ -227,18 +241,24 @@ discard block |
||
| 227 | 241 | |
| 228 | 242 | // Billing - Financial |
| 229 | 243 | $menuqualified = 0; |
| 230 | - if (!empty($conf->facture->enabled)) |
|
| 231 | - $menuqualified++; |
|
| 232 | - if (!empty($conf->don->enabled)) |
|
| 233 | - $menuqualified++; |
|
| 234 | - if (!empty($conf->tax->enabled)) |
|
| 235 | - $menuqualified++; |
|
| 236 | - if (!empty($conf->salaries->enabled)) |
|
| 237 | - $menuqualified++; |
|
| 238 | - if (!empty($conf->supplier_invoice->enabled)) |
|
| 239 | - $menuqualified++; |
|
| 240 | - if (!empty($conf->loan->enabled)) |
|
| 241 | - $menuqualified++; |
|
| 244 | + if (!empty($conf->facture->enabled)) { |
|
| 245 | + $menuqualified++; |
|
| 246 | + } |
|
| 247 | + if (!empty($conf->don->enabled)) { |
|
| 248 | + $menuqualified++; |
|
| 249 | + } |
|
| 250 | + if (!empty($conf->tax->enabled)) { |
|
| 251 | + $menuqualified++; |
|
| 252 | + } |
|
| 253 | + if (!empty($conf->salaries->enabled)) { |
|
| 254 | + $menuqualified++; |
|
| 255 | + } |
|
| 256 | + if (!empty($conf->supplier_invoice->enabled)) { |
|
| 257 | + $menuqualified++; |
|
| 258 | + } |
|
| 259 | + if (!empty($conf->loan->enabled)) { |
|
| 260 | + $menuqualified++; |
|
| 261 | + } |
|
| 242 | 262 | $tmpentry = array( |
| 243 | 263 | 'enabled' => $menuqualified, |
| 244 | 264 | 'perms' => (!empty($user->rights->facture->lire) || !empty($user->rights->don->lire) || !empty($user->rights->tax->charges->lire) || !empty($user->rights->salaries->read) || !empty($user->rights->fournisseur->facture->lire) || !empty($user->rights->loan->read)), |
@@ -252,8 +272,9 @@ discard block |
||
| 252 | 272 | if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "billing") {
|
| 253 | 273 | $classname = 'class="tmenusel"'; |
| 254 | 274 | $_SESSION['idmenu'] = ''; |
| 255 | - } else |
|
| 256 | - $classname = 'class="tmenu"'; |
|
| 275 | + } else { |
|
| 276 | + $classname = 'class="tmenu"'; |
|
| 277 | + } |
|
| 257 | 278 | $idsel = 'billing'; |
| 258 | 279 | |
| 259 | 280 | //$menu->add('/compta/index.php?mainmenu=billing&leftmenu=', $langs->trans("MenuFinancial"), 0, $showmode, $atarget, "billing", '', 50, $id, $idsel, $classname);
|
@@ -275,8 +296,9 @@ discard block |
||
| 275 | 296 | if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "bank") {
|
| 276 | 297 | $classname = 'class="tmenusel"'; |
| 277 | 298 | $_SESSION['idmenu'] = ''; |
| 278 | - } else |
|
| 279 | - $classname = 'class="tmenu"'; |
|
| 299 | + } else { |
|
| 300 | + $classname = 'class="tmenu"'; |
|
| 301 | + } |
|
| 280 | 302 | $idsel = 'bank'; |
| 281 | 303 | |
| 282 | 304 | //$menu->add('/compta/bank/list.php?mainmenu=bank&leftmenu=', $langs->trans("MenuBankCash"), 0, $showmode, $atarget, "bank", '', 52, $id, $idsel, $classname);
|
@@ -285,12 +307,15 @@ discard block |
||
| 285 | 307 | |
| 286 | 308 | // Accounting |
| 287 | 309 | $menuqualified = 0; |
| 288 | - if (!empty($conf->comptabilite->enabled)) |
|
| 289 | - $menuqualified++; |
|
| 290 | - if (!empty($conf->accounting->enabled)) |
|
| 291 | - $menuqualified++; |
|
| 292 | - if (!empty($conf->asset->enabled)) |
|
| 293 | - $menuqualified++; |
|
| 310 | + if (!empty($conf->comptabilite->enabled)) { |
|
| 311 | + $menuqualified++; |
|
| 312 | + } |
|
| 313 | + if (!empty($conf->accounting->enabled)) { |
|
| 314 | + $menuqualified++; |
|
| 315 | + } |
|
| 316 | + if (!empty($conf->asset->enabled)) { |
|
| 317 | + $menuqualified++; |
|
| 318 | + } |
|
| 294 | 319 | $tmpentry = array( |
| 295 | 320 | 'enabled' => $menuqualified, |
| 296 | 321 | 'perms' => (!empty($user->rights->compta->resultat->lire) || !empty($user->rights->accounting->mouvements->lire) || !empty($user->rights->asset->read)), |
@@ -304,8 +329,9 @@ discard block |
||
| 304 | 329 | if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "accountancy") {
|
| 305 | 330 | $classname = 'class="tmenusel"'; |
| 306 | 331 | $_SESSION['idmenu'] = ''; |
| 307 | - } else |
|
| 308 | - $classname = 'class="tmenu"'; |
|
| 332 | + } else { |
|
| 333 | + $classname = 'class="tmenu"'; |
|
| 334 | + } |
|
| 309 | 335 | $idsel = 'accountancy'; |
| 310 | 336 | |
| 311 | 337 | //$menu->add('/accountancy/index.php?mainmenu=accountancy&leftmenu=', $langs->trans("MenuAccountancy"), 0, $showmode, $atarget, "accountancy", '', 54, $id, $idsel, $classname);
|
@@ -326,8 +352,9 @@ discard block |
||
| 326 | 352 | if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "hrm") {
|
| 327 | 353 | $classname = 'class="tmenusel"'; |
| 328 | 354 | $_SESSION['idmenu'] = ''; |
| 329 | - } else |
|
| 330 | - $classname = 'class="tmenu"'; |
|
| 355 | + } else { |
|
| 356 | + $classname = 'class="tmenu"'; |
|
| 357 | + } |
|
| 331 | 358 | $idsel = 'hrm'; |
| 332 | 359 | |
| 333 | 360 | //$menu->add('/hrm/index.php?mainmenu=hrm&leftmenu=', $langs->trans("HRM"), 0, $showmode, $atarget, "hrm", '', 80, $id, $idsel, $classname);
|
@@ -348,8 +375,9 @@ discard block |
||
| 348 | 375 | if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "tools") {
|
| 349 | 376 | $classname = 'class="tmenusel"'; |
| 350 | 377 | $_SESSION['idmenu'] = ''; |
| 351 | - } else |
|
| 352 | - $classname = 'class="tmenu"'; |
|
| 378 | + } else { |
|
| 379 | + $classname = 'class="tmenu"'; |
|
| 380 | + } |
|
| 353 | 381 | $idsel = 'tools'; |
| 354 | 382 | |
| 355 | 383 | //$menu->add('/core/tools.php?mainmenu=tools&leftmenu=', $langs->trans("Tools"), 0, $showmode, $atarget, "tools", '', 90, $id, $idsel, $classname);
|
@@ -377,26 +405,29 @@ discard block |
||
| 377 | 405 | $url = $shorturl = $tmp[0]; |
| 378 | 406 | $param = (isset($tmp[1]) ? $tmp[1] : ''); |
| 379 | 407 | |
| 380 | - if (!preg_match('/mainmenu/i', $param) || !preg_match('/leftmenu/i', $param))
|
|
| 381 | - $param .= ($param ? '&' : '') . 'mainmenu=' . $newTabMenu[$i]['mainmenu'] . '&leftmenu='; |
|
| 382 | -//$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad |
|
| 408 | + if (!preg_match('/mainmenu/i', $param) || !preg_match('/leftmenu/i', $param)) { |
|
| 409 | + $param .= ($param ? '&' : '') . 'mainmenu=' . $newTabMenu[$i]['mainmenu'] . '&leftmenu='; |
|
| 410 | + } |
|
| 411 | + //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad |
|
| 383 | 412 | $url = dol_buildpath($url, 1) . ($param ? '?' . $param : ''); |
| 384 | 413 | //$shorturl = $shorturl.($param?'?'.$param:''); |
| 385 | 414 | $shorturl = $url; |
| 386 | - if (DOL_URL_ROOT) |
|
| 387 | - $shorturl = preg_replace('/^' . preg_quote(DOL_URL_ROOT, '/') . '/', '', $shorturl);
|
|
| 415 | + if (DOL_URL_ROOT) { |
|
| 416 | + $shorturl = preg_replace('/^' . preg_quote(DOL_URL_ROOT, '/') . '/', '', $shorturl); |
|
| 417 | + } |
|
| 388 | 418 | } |
| 389 | 419 | |
| 390 | 420 | // Define the class (top menu selected or not) |
| 391 | - if (!empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) |
|
| 392 | - $classname = 'class="tmenusel"'; |
|
| 393 | - else if (!empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) |
|
| 394 | - $classname = 'class="tmenusel"'; |
|
| 395 | - else |
|
| 396 | - $classname = 'class="tmenu"'; |
|
| 397 | - } |
|
| 398 | - else if ($showmode == 2) |
|
| 399 | - $classname = 'class="tmenu"'; |
|
| 421 | + if (!empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) { |
|
| 422 | + $classname = 'class="tmenusel"'; |
|
| 423 | + } else if (!empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) { |
|
| 424 | + $classname = 'class="tmenusel"'; |
|
| 425 | + } else { |
|
| 426 | + $classname = 'class="tmenu"'; |
|
| 427 | + } |
|
| 428 | + } else if ($showmode == 2) { |
|
| 429 | + $classname = 'class="tmenu"'; |
|
| 430 | + } |
|
| 400 | 431 | |
| 401 | 432 | $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target'] ? $newTabMenu[$i]['target'] : $atarget), ($newTabMenu[$i]['mainmenu'] ? $newTabMenu[$i]['mainmenu'] : $newTabMenu[$i]['rowid']), ($newTabMenu[$i]['leftmenu'] ? $newTabMenu[$i]['leftmenu'] : ''), $newTabMenu[$i]['position'], $id, $idsel, $classname); |
| 402 | 433 | } |
@@ -693,9 +724,10 @@ discard block |
||
| 693 | 724 | $newmenu->add(BASE_URI . '?controller=admin/system&method=phpinfo&mainmenu=home&leftmenu=admintools', $langs->trans('InfoPHP'), 1);
|
| 694 | 725 | //if (function_exists('xdebug_is_enabled')) $newmenu->add('/admin/system/xdebug.php', $langs->trans('XDebug'),1);
|
| 695 | 726 | $newmenu->add(BASE_URI . '?controller=admin/system&method=database&mainmenu=home&leftmenu=admintools', $langs->trans('InfoDatabase'), 1);
|
| 696 | - if (function_exists('eaccelerator_info'))
|
|
| 697 | - $newmenu->add(BASE_URI . "?controller=admin/tools&method=eaccelerator&mainmenu=home&leftmenu=admintools", $langs->trans("EAccelerator"), 1);
|
|
| 698 | -//$newmenu->add("/admin/system/perf.php?mainmenu=home&leftmenu=admintools", $langs->trans("InfoPerf"),1);
|
|
| 727 | + if (function_exists('eaccelerator_info')) { |
|
| 728 | + $newmenu->add(BASE_URI . "?controller=admin/tools&method=eaccelerator&mainmenu=home&leftmenu=admintools", $langs->trans("EAccelerator"), 1); |
|
| 729 | + } |
|
| 730 | + //$newmenu->add("/admin/system/perf.php?mainmenu=home&leftmenu=admintools", $langs->trans("InfoPerf"),1);
|
|
| 699 | 731 | $newmenu->add(BASE_URI . "?controller=admin/tools&method=dolibarr_export&mainmenu=home&leftmenu=admintools", $langs->trans("Backup"), 1);
|
| 700 | 732 | $newmenu->add(BASE_URI . "?controller=admin/tools&method=dolibarr_import&mainmenu=home&leftmenu=admintools", $langs->trans("Restore"), 1);
|
| 701 | 733 | $newmenu->add(BASE_URI . "?controller=admin/tools&method=update&mainmenu=home&leftmenu=admintools", $langs->trans("MenuUpgrade"), 1);
|
@@ -808,11 +840,13 @@ discard block |
||
| 808 | 840 | if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
|
| 809 | 841 | // Categories prospects/customers |
| 810 | 842 | $menutoshow = $langs->trans("CustomersProspectsCategoriesShort");
|
| 811 | - if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) |
|
| 812 | - $menutoshow = $langs->trans("CustomersCategoriesShort");
|
|
| 813 | - if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) |
|
| 814 | - $menutoshow = $langs->trans("ProspectsCategoriesShort");
|
|
| 815 | -//$newmenu->add("/categories/index.php?leftmenu=cat&type=2", $menutoshow, 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
|
|
| 843 | + if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { |
|
| 844 | + $menutoshow = $langs->trans("CustomersCategoriesShort"); |
|
| 845 | + } |
|
| 846 | + if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) { |
|
| 847 | + $menutoshow = $langs->trans("ProspectsCategoriesShort"); |
|
| 848 | + } |
|
| 849 | + //$newmenu->add("/categories/index.php?leftmenu=cat&type=2", $menutoshow, 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
|
|
| 816 | 850 | $newmenu->add(BASE_URI . "?controller=categories&method=index&leftmenu=cat&type=2", $menutoshow, 1, $user->rights->categorie->lire, '', $mainmenu, 'cat'); |
| 817 | 851 | } |
| 818 | 852 | // Categories suppliers |
@@ -1344,25 +1378,33 @@ discard block |
||
| 1344 | 1378 | $nature = ''; |
| 1345 | 1379 | |
| 1346 | 1380 | // Must match array $sourceList defined into journals_list.php |
| 1347 | - if ($objp->nature == 2 && !empty($conf->facture->enabled)) |
|
| 1348 | - $nature = "sells"; |
|
| 1349 | - if ($objp->nature == 3 && !empty($conf->fournisseur->enabled)) |
|
| 1350 | - $nature = "purchases"; |
|
| 1351 | - if ($objp->nature == 4 && !empty($conf->banque->enabled)) |
|
| 1352 | - $nature = "bank"; |
|
| 1353 | - if ($objp->nature == 5 && !empty($conf->expensereport->enabled)) |
|
| 1354 | - $nature = "expensereports"; |
|
| 1355 | - if ($objp->nature == 1) |
|
| 1356 | - $nature = "various"; |
|
| 1357 | - if ($objp->nature == 8) |
|
| 1358 | - $nature = "inventory"; |
|
| 1359 | - if ($objp->nature == 9) |
|
| 1360 | - $nature = "hasnew"; |
|
| 1381 | + if ($objp->nature == 2 && !empty($conf->facture->enabled)) { |
|
| 1382 | + $nature = "sells"; |
|
| 1383 | + } |
|
| 1384 | + if ($objp->nature == 3 && !empty($conf->fournisseur->enabled)) { |
|
| 1385 | + $nature = "purchases"; |
|
| 1386 | + } |
|
| 1387 | + if ($objp->nature == 4 && !empty($conf->banque->enabled)) { |
|
| 1388 | + $nature = "bank"; |
|
| 1389 | + } |
|
| 1390 | + if ($objp->nature == 5 && !empty($conf->expensereport->enabled)) { |
|
| 1391 | + $nature = "expensereports"; |
|
| 1392 | + } |
|
| 1393 | + if ($objp->nature == 1) { |
|
| 1394 | + $nature = "various"; |
|
| 1395 | + } |
|
| 1396 | + if ($objp->nature == 8) { |
|
| 1397 | + $nature = "inventory"; |
|
| 1398 | + } |
|
| 1399 | + if ($objp->nature == 9) { |
|
| 1400 | + $nature = "hasnew"; |
|
| 1401 | + } |
|
| 1361 | 1402 | |
| 1362 | 1403 | // To enable when page exists |
| 1363 | 1404 | if (empty($conf->global->ACCOUNTANCY_SHOW_DEVELOP_JOURNAL)) {
|
| 1364 | - if ($nature == 'various' || $nature == 'hasnew' || $nature == 'inventory') |
|
| 1365 | - $nature = ''; |
|
| 1405 | + if ($nature == 'various' || $nature == 'hasnew' || $nature == 'inventory') { |
|
| 1406 | + $nature = ''; |
|
| 1407 | + } |
|
| 1366 | 1408 | } |
| 1367 | 1409 | |
| 1368 | 1410 | if ($nature) {
|
@@ -1377,8 +1419,9 @@ discard block |
||
| 1377 | 1419 | // Should not happend. Entries are added |
| 1378 | 1420 | $newmenu->add('', $langs->trans("NoJournalDefined"), 2, $user->rights->accounting->comptarapport->lire);
|
| 1379 | 1421 | } |
| 1380 | - } else |
|
| 1381 | - dol_print_error($db); |
|
| 1422 | + } else { |
|
| 1423 | + dol_print_error($db); |
|
| 1424 | + } |
|
| 1382 | 1425 | $db->free($resql); |
| 1383 | 1426 | } |
| 1384 | 1427 | |
@@ -1412,8 +1455,10 @@ discard block |
||
| 1412 | 1455 | } |
| 1413 | 1456 | |
| 1414 | 1457 | $modecompta = 'CREANCES-DETTES'; |
| 1415 | - if (!empty($conf->accounting->enabled) && !empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') |
|
| 1416 | - $modecompta = 'BOOKKEEPING'; // Not yet implemented. Should be BOOKKEEPINGCOLLECTED |
|
| 1458 | + if (!empty($conf->accounting->enabled) && !empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') { |
|
| 1459 | + $modecompta = 'BOOKKEEPING'; |
|
| 1460 | + } |
|
| 1461 | + // Not yet implemented. Should be BOOKKEEPINGCOLLECTED |
|
| 1417 | 1462 | if ($modecompta) {
|
| 1418 | 1463 | if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
|
| 1419 | 1464 | /* |
@@ -2079,8 +2124,9 @@ discard block |
||
| 2079 | 2124 | } |
| 2080 | 2125 | $i++; |
| 2081 | 2126 | } |
| 2082 | - } else |
|
| 2083 | - dol_print_error($db); |
|
| 2127 | + } else { |
|
| 2128 | + dol_print_error($db); |
|
| 2129 | + } |
|
| 2084 | 2130 | $db->free($resql); |
| 2085 | 2131 | } |
| 2086 | 2132 | |
@@ -2107,13 +2153,16 @@ discard block |
||
| 2107 | 2153 | //var_dump($menu_array_before);exit; |
| 2108 | 2154 | //var_dump($menu_array_after);exit; |
| 2109 | 2155 | $menu_array = $newmenu->liste; |
| 2110 | - if (is_array($menu_array_before)) |
|
| 2111 | - $menu_array = array_merge($menu_array_before, $menu_array); |
|
| 2112 | - if (is_array($menu_array_after)) |
|
| 2113 | - $menu_array = array_merge($menu_array, $menu_array_after); |
|
| 2156 | + if (is_array($menu_array_before)) { |
|
| 2157 | + $menu_array = array_merge($menu_array_before, $menu_array); |
|
| 2158 | + } |
|
| 2159 | + if (is_array($menu_array_after)) { |
|
| 2160 | + $menu_array = array_merge($menu_array, $menu_array_after); |
|
| 2161 | + } |
|
| 2114 | 2162 | //var_dump($menu_array);exit; |
| 2115 | - if (!is_array($menu_array)) |
|
| 2116 | - return 0; |
|
| 2163 | + if (!is_array($menu_array)) { |
|
| 2164 | + return 0; |
|
| 2165 | + } |
|
| 2117 | 2166 | |
| 2118 | 2167 | // TODO Use the position property in menu_array to reorder the $menu_array |
| 2119 | 2168 | //var_dump($menu_array); |
@@ -2135,8 +2184,9 @@ discard block |
||
| 2135 | 2184 | $num = count($menu_array); |
| 2136 | 2185 | for ($i = 0; $i < $num; $i++) { // Loop on each menu entry
|
| 2137 | 2186 | $showmenu = true; |
| 2138 | - if (!empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($menu_array[$i]['enabled'])) |
|
| 2139 | - $showmenu = false; |
|
| 2187 | + if (!empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($menu_array[$i]['enabled'])) { |
|
| 2188 | + $showmenu = false; |
|
| 2189 | + } |
|
| 2140 | 2190 | |
| 2141 | 2191 | // Begin of new left menu block |
| 2142 | 2192 | if (empty($menu_array[$i]['level']) && $showmenu) {
|
@@ -2144,8 +2194,9 @@ discard block |
||
| 2144 | 2194 | $blockvmenuopened = true; |
| 2145 | 2195 | $lastopened = true; |
| 2146 | 2196 | for ($j = ($i + 1); $j < $num; $j++) {
|
| 2147 | - if (empty($menu_array[$j]['level'])) |
|
| 2148 | - $lastopened = false; |
|
| 2197 | + if (empty($menu_array[$j]['level'])) { |
|
| 2198 | + $lastopened = false; |
|
| 2199 | + } |
|
| 2149 | 2200 | } |
| 2150 | 2201 | if ($altok % 2 == 0) {
|
| 2151 | 2202 | print '<div class="blockvmenu blockvmenuimpair' . $invert . ($lastopened ? ' blockvmenulast' : '') . ($altok == 1 ? ' blockvmenufirst' : '') . '">' . "\n"; |
@@ -2193,19 +2244,20 @@ discard block |
||
| 2193 | 2244 | if ($menu_array[$i]['level'] == 0) {
|
| 2194 | 2245 | if ($menu_array[$i]['enabled']) { // Enabled so visible
|
| 2195 | 2246 | print '<div class="menu_titre">' . $tabstring; |
| 2196 | - if ($shorturlwithoutparam) |
|
| 2197 | - print '<a class="vmenu" href="' . $url . '"' . ($menu_array[$i]['target'] ? ' target="' . $menu_array[$i]['target'] . '"' : '') . '>'; |
|
| 2198 | - else |
|
| 2199 | - print '<span class="vmenu">'; |
|
| 2247 | + if ($shorturlwithoutparam) { |
|
| 2248 | + print '<a class="vmenu" href="' . $url . '"' . ($menu_array[$i]['target'] ? ' target="' . $menu_array[$i]['target'] . '"' : '') . '>'; |
|
| 2249 | + } else { |
|
| 2250 | + print '<span class="vmenu">'; |
|
| 2251 | + } |
|
| 2200 | 2252 | print ($menu_array[$i]['prefix'] ? $menu_array[$i]['prefix'] : '') . $menu_array[$i]['titre']; |
| 2201 | - if ($shorturlwithoutparam) |
|
| 2202 | - print '</a>'; |
|
| 2203 | - else |
|
| 2204 | - print '</span>'; |
|
| 2253 | + if ($shorturlwithoutparam) { |
|
| 2254 | + print '</a>'; |
|
| 2255 | + } else { |
|
| 2256 | + print '</span>'; |
|
| 2257 | + } |
|
| 2205 | 2258 | print '</div>' . "\n"; |
| 2206 | 2259 | $lastlevel0 = 'enabled'; |
| 2207 | - } |
|
| 2208 | - else if ($showmenu) { // Not enabled but visible (so greyed)
|
|
| 2260 | + } else if ($showmenu) { // Not enabled but visible (so greyed)
|
|
| 2209 | 2261 | print '<div class="menu_titre">' . $tabstring . '<font class="vmenudisabled">' . $menu_array[$i]['titre'] . '</font></div>' . "\n"; |
| 2210 | 2262 | $lastlevel0 = 'greyed'; |
| 2211 | 2263 | } else {
|
@@ -2219,34 +2271,38 @@ discard block |
||
| 2219 | 2271 | // Menu level > 0 |
| 2220 | 2272 | if ($menu_array[$i]['level'] > 0) {
|
| 2221 | 2273 | $cssmenu = ''; |
| 2222 | - if ($menu_array[$i]['url']) |
|
| 2223 | - $cssmenu = ' menu_contenu' . dol_string_nospecial(preg_replace('/\.php.*$/', '', $menu_array[$i]['url']));
|
|
| 2274 | + if ($menu_array[$i]['url']) { |
|
| 2275 | + $cssmenu = ' menu_contenu' . dol_string_nospecial(preg_replace('/\.php.*$/', '', $menu_array[$i]['url'])); |
|
| 2276 | + } |
|
| 2224 | 2277 | |
| 2225 | 2278 | if ($menu_array[$i]['enabled'] && $lastlevel0 == 'enabled') { // Enabled so visible, except if parent was not enabled.
|
| 2226 | 2279 | print '<div class="menu_contenu' . $cssmenu . '">' . $tabstring; |
| 2227 | - if ($shorturlwithoutparam) |
|
| 2228 | - print '<a class="vsmenu" href="' . $url . '"' . ($menu_array[$i]['target'] ? ' target="' . $menu_array[$i]['target'] . '"' : '') . '>'; |
|
| 2229 | - else |
|
| 2230 | - print '<span class="vsmenu">'; |
|
| 2280 | + if ($shorturlwithoutparam) { |
|
| 2281 | + print '<a class="vsmenu" href="' . $url . '"' . ($menu_array[$i]['target'] ? ' target="' . $menu_array[$i]['target'] . '"' : '') . '>'; |
|
| 2282 | + } else { |
|
| 2283 | + print '<span class="vsmenu">'; |
|
| 2284 | + } |
|
| 2231 | 2285 | print $menu_array[$i]['titre']; |
| 2232 | - if ($shorturlwithoutparam) |
|
| 2233 | - print '</a>'; |
|
| 2234 | - else |
|
| 2235 | - print '</span>'; |
|
| 2286 | + if ($shorturlwithoutparam) { |
|
| 2287 | + print '</a>'; |
|
| 2288 | + } else { |
|
| 2289 | + print '</span>'; |
|
| 2290 | + } |
|
| 2236 | 2291 | // If title is not pure text and contains a table, no carriage return added |
| 2237 | - if (!strstr($menu_array[$i]['titre'], '<table')) |
|
| 2238 | - print '<br>'; |
|
| 2292 | + if (!strstr($menu_array[$i]['titre'], '<table')) { |
|
| 2293 | + print '<br>'; |
|
| 2294 | + } |
|
| 2239 | 2295 | print '</div>' . "\n"; |
| 2240 | - } |
|
| 2241 | - else if ($showmenu && $lastlevel0 == 'enabled') { // Not enabled but visible (so greyed), except if parent was not enabled.
|
|
| 2296 | + } else if ($showmenu && $lastlevel0 == 'enabled') { // Not enabled but visible (so greyed), except if parent was not enabled.
|
|
| 2242 | 2297 | print '<div class="menu_contenu' . $cssmenu . '">' . $tabstring . '<font class="vsmenudisabled vsmenudisabledmargin">' . $menu_array[$i]['titre'] . '</font><br></div>' . "\n"; |
| 2243 | 2298 | } |
| 2244 | 2299 | } |
| 2245 | 2300 | |
| 2246 | 2301 | // If next is a new block or if there is nothing after |
| 2247 | 2302 | if (empty($menu_array[$i + 1]['level'])) { // End menu block
|
| 2248 | - if ($showmenu) |
|
| 2249 | - print '<div class="menu_end"></div>' . "\n"; |
|
| 2303 | + if ($showmenu) { |
|
| 2304 | + print '<div class="menu_end"></div>' . "\n"; |
|
| 2305 | + } |
|
| 2250 | 2306 | if ($blockvmenuopened) {
|
| 2251 | 2307 | print '</div>' . "\n"; |
| 2252 | 2308 | $blockvmenuopened = false; |
@@ -2254,8 +2310,10 @@ discard block |
||
| 2254 | 2310 | } |
| 2255 | 2311 | } |
| 2256 | 2312 | |
| 2257 | - if ($altok) |
|
| 2258 | - print '<div class="blockvmenuend"></div>'; // End menu block |
|
| 2313 | + if ($altok) { |
|
| 2314 | + print '<div class="blockvmenuend"></div>'; |
|
| 2315 | + } |
|
| 2316 | + // End menu block |
|
| 2259 | 2317 | } |
| 2260 | 2318 | |
| 2261 | 2319 | return count($menu_array); |
@@ -111,45 +111,58 @@ discard block |
||
| 111 | 111 | if (!empty($perm)) {
|
| 112 | 112 | $tmp = explode(':', $typeofdata);
|
| 113 | 113 | $ret .= '<div class="editkey_' . $tmp[0] . (!empty($tmp[1]) ? ' ' . $tmp[1] : '') . '" id="' . $htmlname . '">'; |
| 114 | - if ($fieldrequired) |
|
| 115 | - $ret .= '<span class="fieldrequired">'; |
|
| 114 | + if ($fieldrequired) { |
|
| 115 | + $ret .= '<span class="fieldrequired">'; |
|
| 116 | + } |
|
| 116 | 117 | $ret .= $langs->trans($text); |
| 117 | - if ($fieldrequired) |
|
| 118 | - $ret .= '</span>'; |
|
| 118 | + if ($fieldrequired) { |
|
| 119 | + $ret .= '</span>'; |
|
| 120 | + } |
|
| 119 | 121 | $ret .= '</div>' . "\n"; |
| 120 | - } |
|
| 121 | - else {
|
|
| 122 | - if ($fieldrequired) |
|
| 123 | - $ret .= '<span class="fieldrequired">'; |
|
| 122 | + } else {
|
|
| 123 | + if ($fieldrequired) { |
|
| 124 | + $ret .= '<span class="fieldrequired">'; |
|
| 125 | + } |
|
| 124 | 126 | $ret .= $langs->trans($text); |
| 125 | - if ($fieldrequired) |
|
| 126 | - $ret .= '</span>'; |
|
| 127 | + if ($fieldrequired) { |
|
| 128 | + $ret .= '</span>'; |
|
| 129 | + } |
|
| 127 | 130 | } |
| 128 | - } |
|
| 129 | - else {
|
|
| 130 | - if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm)
|
|
| 131 | - $ret .= '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">'; |
|
| 132 | - if ($fieldrequired) |
|
| 133 | - $ret .= '<span class="fieldrequired">'; |
|
| 131 | + } else {
|
|
| 132 | + if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm) { |
|
| 133 | + $ret .= '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">'; |
|
| 134 | + } |
|
| 135 | + if ($fieldrequired) { |
|
| 136 | + $ret .= '<span class="fieldrequired">'; |
|
| 137 | + } |
|
| 134 | 138 | $ret .= $langs->trans($text); |
| 135 | - if ($fieldrequired) |
|
| 136 | - $ret .= '</span>'; |
|
| 137 | - if (!empty($notabletag)) |
|
| 138 | - $ret .= ' '; |
|
| 139 | - if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm)
|
|
| 140 | - $ret .= '</td>'; |
|
| 141 | - if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm)
|
|
| 142 | - $ret .= '<td align="right">'; |
|
| 143 | - if ($htmlname && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm)
|
|
| 144 | - $ret .= '<a href="' . $_SERVER["PHP_SELF"] . '?action=edit' . $htmlname . '&' . $paramid . '=' . $object->id . $moreparam . '">' . img_edit($langs->trans('Edit'), ($notabletag ? 0 : 1)) . '</a>';
|
|
| 145 | - if (!empty($notabletag) && $notabletag == 1) |
|
| 146 | - $ret .= ' : '; |
|
| 147 | - if (!empty($notabletag) && $notabletag == 3) |
|
| 148 | - $ret .= ' '; |
|
| 149 | - if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm)
|
|
| 150 | - $ret .= '</td>'; |
|
| 151 | - if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm)
|
|
| 152 | - $ret .= '</tr></table>'; |
|
| 139 | + if ($fieldrequired) { |
|
| 140 | + $ret .= '</span>'; |
|
| 141 | + } |
|
| 142 | + if (!empty($notabletag)) { |
|
| 143 | + $ret .= ' '; |
|
| 144 | + } |
|
| 145 | + if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm) { |
|
| 146 | + $ret .= '</td>'; |
|
| 147 | + } |
|
| 148 | + if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm) { |
|
| 149 | + $ret .= '<td align="right">'; |
|
| 150 | + } |
|
| 151 | + if ($htmlname && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm) { |
|
| 152 | + $ret .= '<a href="' . $_SERVER["PHP_SELF"] . '?action=edit' . $htmlname . '&' . $paramid . '=' . $object->id . $moreparam . '">' . img_edit($langs->trans('Edit'), ($notabletag ? 0 : 1)) . '</a>'; |
|
| 153 | + } |
|
| 154 | + if (!empty($notabletag) && $notabletag == 1) { |
|
| 155 | + $ret .= ' : '; |
|
| 156 | + } |
|
| 157 | + if (!empty($notabletag) && $notabletag == 3) { |
|
| 158 | + $ret .= ' '; |
|
| 159 | + } |
|
| 160 | + if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm) { |
|
| 161 | + $ret .= '</td>'; |
|
| 162 | + } |
|
| 163 | + if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm) { |
|
| 164 | + $ret .= '</tr></table>'; |
|
| 165 | + } |
|
| 153 | 166 | } |
| 154 | 167 | |
| 155 | 168 | return $ret; |
@@ -180,8 +193,9 @@ discard block |
||
| 180 | 193 | $ret = ''; |
| 181 | 194 | |
| 182 | 195 | // Check parameters |
| 183 | - if (empty($typeofdata)) |
|
| 184 | - return 'ErrorBadParameter'; |
|
| 196 | + if (empty($typeofdata)) { |
|
| 197 | + return 'ErrorBadParameter'; |
|
| 198 | + } |
|
| 185 | 199 | |
| 186 | 200 | // When option to edit inline is activated |
| 187 | 201 | if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match('/^select;|datehourpicker/', $typeofdata)) { // TODO add jquery timepicker
|
@@ -193,10 +207,12 @@ discard block |
||
| 193 | 207 | $ret .= '<input type="hidden" name="action" value="set' . $htmlname . '">'; |
| 194 | 208 | $ret .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; |
| 195 | 209 | $ret .= '<input type="hidden" name="' . $paramid . '" value="' . $object->id . '">'; |
| 196 | - if (empty($notabletag)) |
|
| 197 | - $ret .= '<table class="nobordernopadding centpercent" cellpadding="0" cellspacing="0">'; |
|
| 198 | - if (empty($notabletag)) |
|
| 199 | - $ret .= '<tr><td>'; |
|
| 210 | + if (empty($notabletag)) { |
|
| 211 | + $ret .= '<table class="nobordernopadding centpercent" cellpadding="0" cellspacing="0">'; |
|
| 212 | + } |
|
| 213 | + if (empty($notabletag)) { |
|
| 214 | + $ret .= '<tr><td>'; |
|
| 215 | + } |
|
| 200 | 216 | if (preg_match('/^(string|email)/', $typeofdata)) {
|
| 201 | 217 | $tmp = explode(':', $typeofdata);
|
| 202 | 218 | $ret .= '<input type="text" id="' . $htmlname . '" name="' . $htmlname . '" value="' . ($editvalue ? $editvalue : $value) . '"' . ($tmp[1] ? ' size="' . $tmp[1] . '"' : '') . '>'; |
@@ -235,35 +251,39 @@ discard block |
||
| 235 | 251 | $doleditor = new DolEditor($htmlname, ($editvalue ? $editvalue : $value), ($tmp[2] ? $tmp[2] : ''), ($tmp[3] ? $tmp[3] : '100'), ($tmp[1] ? $tmp[1] : 'dolibarr_notes'), 'In', ($tmp[5] ? $tmp[5] : 0), true, true, ($tmp[6] ? $tmp[6] : '20'), ($tmp[7] ? $tmp[7] : '100')); |
| 236 | 252 | $ret .= $doleditor->Create(1); |
| 237 | 253 | } |
| 238 | - if (empty($notabletag)) |
|
| 239 | - $ret .= '</td>'; |
|
| 254 | + if (empty($notabletag)) { |
|
| 255 | + $ret .= '</td>'; |
|
| 256 | + } |
|
| 240 | 257 | |
| 241 | - if (empty($notabletag)) |
|
| 242 | - $ret .= '<td align="left">'; |
|
| 258 | + if (empty($notabletag)) { |
|
| 259 | + $ret .= '<td align="left">'; |
|
| 260 | + } |
|
| 243 | 261 | //else $ret.='<div class="clearboth"></div>'; |
| 244 | 262 | $ret .= '<input type="submit" class="button' . (empty($notabletag) ? '' : ' ') . '" name="modify" value="' . $langs->trans("Modify") . '">';
|
| 245 | - if (preg_match('/ckeditor|textarea/', $typeofdata) && empty($notabletag))
|
|
| 246 | - $ret .= '<br>' . "\n"; |
|
| 263 | + if (preg_match('/ckeditor|textarea/', $typeofdata) && empty($notabletag)) { |
|
| 264 | + $ret .= '<br>' . "\n"; |
|
| 265 | + } |
|
| 247 | 266 | $ret .= '<input type="submit" class="button' . (empty($notabletag) ? '' : ' ') . '" name="cancel" value="' . $langs->trans("Cancel") . '">';
|
| 248 | - if (empty($notabletag)) |
|
| 249 | - $ret .= '</td>'; |
|
| 267 | + if (empty($notabletag)) { |
|
| 268 | + $ret .= '</td>'; |
|
| 269 | + } |
|
| 250 | 270 | |
| 251 | - if (empty($notabletag)) |
|
| 252 | - $ret .= '</tr></table>' . "\n"; |
|
| 271 | + if (empty($notabletag)) { |
|
| 272 | + $ret .= '</tr></table>' . "\n"; |
|
| 273 | + } |
|
| 253 | 274 | $ret .= '</form>' . "\n"; |
| 254 | - } |
|
| 255 | - else {
|
|
| 256 | - if (preg_match('/^(email)/', $typeofdata))
|
|
| 257 | - $ret .= dol_print_email($value, 0, 0, 0, 0, 1); |
|
| 258 | - elseif (preg_match('/^(amount|numeric)/', $typeofdata))
|
|
| 259 | - $ret .= ($value != '' ? price($value, '', $langs, 0, -1, -1, $conf->currency) : ''); |
|
| 260 | - elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata))
|
|
| 261 | - $ret .= dol_htmlentitiesbr($value); |
|
| 262 | - elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') |
|
| 263 | - $ret .= dol_print_date($value, 'day'); |
|
| 264 | - elseif ($typeofdata == 'dayhour' || $typeofdata == 'datehourpicker') |
|
| 265 | - $ret .= dol_print_date($value, 'dayhour'); |
|
| 266 | - else if (preg_match('/^select;/', $typeofdata)) {
|
|
| 275 | + } else {
|
|
| 276 | + if (preg_match('/^(email)/', $typeofdata)) { |
|
| 277 | + $ret .= dol_print_email($value, 0, 0, 0, 0, 1); |
|
| 278 | + } elseif (preg_match('/^(amount|numeric)/', $typeofdata)) { |
|
| 279 | + $ret .= ($value != '' ? price($value, '', $langs, 0, -1, -1, $conf->currency) : ''); |
|
| 280 | + } elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) { |
|
| 281 | + $ret .= dol_htmlentitiesbr($value); |
|
| 282 | + } elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') { |
|
| 283 | + $ret .= dol_print_date($value, 'day'); |
|
| 284 | + } elseif ($typeofdata == 'dayhour' || $typeofdata == 'datehourpicker') { |
|
| 285 | + $ret .= dol_print_date($value, 'dayhour'); |
|
| 286 | + } else if (preg_match('/^select;/', $typeofdata)) {
|
|
| 267 | 287 | $arraydata = explode(',', preg_replace('/^select;/', '', $typeofdata));
|
| 268 | 288 | foreach ($arraydata as $val) {
|
| 269 | 289 | $tmp = explode(':', $val);
|
@@ -278,8 +298,9 @@ discard block |
||
| 278 | 298 | $tmpcontent = $firstline . ((strlen($firstline) != strlen($tmpcontent)) ? '...' : ''); |
| 279 | 299 | } |
| 280 | 300 | $ret .= $tmpcontent; |
| 281 | - } else |
|
| 282 | - $ret .= $value; |
|
| 301 | + } else { |
|
| 302 | + $ret .= $value; |
|
| 303 | + } |
|
| 283 | 304 | |
| 284 | 305 | if ($formatfunc && method_exists($object, $formatfunc)) {
|
| 285 | 306 | $ret = $object->$formatfunc($ret); |
@@ -309,12 +330,13 @@ discard block |
||
| 309 | 330 | $out = ''; |
| 310 | 331 | |
| 311 | 332 | // Check parameters |
| 312 | - if (preg_match('/^text/', $inputType))
|
|
| 313 | - $value = dol_nl2br($value); |
|
| 314 | - else if (preg_match('/^numeric/', $inputType))
|
|
| 315 | - $value = price($value); |
|
| 316 | - else if ($inputType == 'day' || $inputType == 'datepicker') |
|
| 317 | - $value = dol_print_date($value, 'day'); |
|
| 333 | + if (preg_match('/^text/', $inputType)) { |
|
| 334 | + $value = dol_nl2br($value); |
|
| 335 | + } else if (preg_match('/^numeric/', $inputType)) { |
|
| 336 | + $value = price($value); |
|
| 337 | + } else if ($inputType == 'day' || $inputType == 'datepicker') { |
|
| 338 | + $value = dol_print_date($value, 'day'); |
|
| 339 | + } |
|
| 318 | 340 | |
| 319 | 341 | if ($condition) {
|
| 320 | 342 | $element = false; |
@@ -339,32 +361,35 @@ discard block |
||
| 339 | 361 | if (preg_match('/^(string|email|numeric)/', $inputType)) {
|
| 340 | 362 | $tmp = explode(':', $inputType);
|
| 341 | 363 | $inputType = $tmp[0]; |
| 342 | - if (!empty($tmp[1])) |
|
| 343 | - $inputOption = $tmp[1]; |
|
| 344 | - if (!empty($tmp[2])) |
|
| 345 | - $savemethod = $tmp[2]; |
|
| 364 | + if (!empty($tmp[1])) { |
|
| 365 | + $inputOption = $tmp[1]; |
|
| 366 | + } |
|
| 367 | + if (!empty($tmp[2])) { |
|
| 368 | + $savemethod = $tmp[2]; |
|
| 369 | + } |
|
| 346 | 370 | $out .= '<input id="width_' . $htmlname . '" value="' . $inputOption . '" type="hidden"/>' . "\n"; |
| 347 | - } |
|
| 348 | - else if ((preg_match('/^day$/', $inputType)) || (preg_match('/^datepicker/', $inputType)) || (preg_match('/^datehourpicker/', $inputType))) {
|
|
| 371 | + } else if ((preg_match('/^day$/', $inputType)) || (preg_match('/^datepicker/', $inputType)) || (preg_match('/^datehourpicker/', $inputType))) {
|
|
| 349 | 372 | $tmp = explode(':', $inputType);
|
| 350 | 373 | $inputType = $tmp[0]; |
| 351 | - if (!empty($tmp[1])) |
|
| 352 | - $inputOption = $tmp[1]; |
|
| 353 | - if (!empty($tmp[2])) |
|
| 354 | - $savemethod = $tmp[2]; |
|
| 374 | + if (!empty($tmp[1])) { |
|
| 375 | + $inputOption = $tmp[1]; |
|
| 376 | + } |
|
| 377 | + if (!empty($tmp[2])) { |
|
| 378 | + $savemethod = $tmp[2]; |
|
| 379 | + } |
|
| 355 | 380 | |
| 356 | 381 | $out .= '<input id="timestamp" type="hidden"/>' . "\n"; // Use for timestamp format |
| 357 | - } |
|
| 358 | - else if (preg_match('/^(select|autocomplete)/', $inputType)) {
|
|
| 382 | + } else if (preg_match('/^(select|autocomplete)/', $inputType)) {
|
|
| 359 | 383 | $tmp = explode(':', $inputType);
|
| 360 | 384 | $inputType = $tmp[0]; |
| 361 | 385 | $loadmethod = $tmp[1]; |
| 362 | - if (!empty($tmp[2])) |
|
| 363 | - $savemethod = $tmp[2]; |
|
| 364 | - if (!empty($tmp[3])) |
|
| 365 | - $button_only = true; |
|
| 366 | - } |
|
| 367 | - else if (preg_match('/^textarea/', $inputType)) {
|
|
| 386 | + if (!empty($tmp[2])) { |
|
| 387 | + $savemethod = $tmp[2]; |
|
| 388 | + } |
|
| 389 | + if (!empty($tmp[3])) { |
|
| 390 | + $button_only = true; |
|
| 391 | + } |
|
| 392 | + } else if (preg_match('/^textarea/', $inputType)) {
|
|
| 368 | 393 | $tmp = explode(':', $inputType);
|
| 369 | 394 | $inputType = $tmp[0]; |
| 370 | 395 | $rows = (empty($tmp[1]) ? '8' : $tmp[1]); |
@@ -373,12 +398,15 @@ discard block |
||
| 373 | 398 | $tmp = explode(':', $inputType);
|
| 374 | 399 | $inputType = $tmp[0]; |
| 375 | 400 | $toolbar = $tmp[1]; |
| 376 | - if (!empty($tmp[2])) |
|
| 377 | - $width = $tmp[2]; |
|
| 378 | - if (!empty($tmp[3])) |
|
| 379 | - $heigth = $tmp[3]; |
|
| 380 | - if (!empty($tmp[4])) |
|
| 381 | - $savemethod = $tmp[4]; |
|
| 401 | + if (!empty($tmp[2])) { |
|
| 402 | + $width = $tmp[2]; |
|
| 403 | + } |
|
| 404 | + if (!empty($tmp[3])) { |
|
| 405 | + $heigth = $tmp[3]; |
|
| 406 | + } |
|
| 407 | + if (!empty($tmp[4])) { |
|
| 408 | + $savemethod = $tmp[4]; |
|
| 409 | + } |
|
| 382 | 410 | |
| 383 | 411 | if (!empty($conf->fckeditor->enabled)) {
|
| 384 | 412 | $out .= '<input id="ckeditor_toolbar" value="' . $toolbar . '" type="hidden"/>' . "\n"; |
@@ -391,18 +419,23 @@ discard block |
||
| 391 | 419 | $out .= '<input id="table_element_' . $htmlname . '" value="' . $table_element . '" type="hidden"/>' . "\n"; |
| 392 | 420 | $out .= '<input id="fk_element_' . $htmlname . '" value="' . $fk_element . '" type="hidden"/>' . "\n"; |
| 393 | 421 | $out .= '<input id="loadmethod_' . $htmlname . '" value="' . $loadmethod . '" type="hidden"/>' . "\n"; |
| 394 | - if (!empty($savemethod)) |
|
| 395 | - $out .= '<input id="savemethod_' . $htmlname . '" value="' . $savemethod . '" type="hidden"/>' . "\n"; |
|
| 396 | - if (!empty($ext_element)) |
|
| 397 | - $out .= '<input id="ext_element_' . $htmlname . '" value="' . $ext_element . '" type="hidden"/>' . "\n"; |
|
| 422 | + if (!empty($savemethod)) { |
|
| 423 | + $out .= '<input id="savemethod_' . $htmlname . '" value="' . $savemethod . '" type="hidden"/>' . "\n"; |
|
| 424 | + } |
|
| 425 | + if (!empty($ext_element)) { |
|
| 426 | + $out .= '<input id="ext_element_' . $htmlname . '" value="' . $ext_element . '" type="hidden"/>' . "\n"; |
|
| 427 | + } |
|
| 398 | 428 | if (!empty($custommsg)) {
|
| 399 | 429 | if (is_array($custommsg)) {
|
| 400 | - if (!empty($custommsg['success'])) |
|
| 401 | - $out .= '<input id="successmsg_' . $htmlname . '" value="' . $custommsg['success'] . '" type="hidden"/>' . "\n"; |
|
| 402 | - if (!empty($custommsg['error'])) |
|
| 403 | - $out .= '<input id="errormsg_' . $htmlname . '" value="' . $custommsg['error'] . '" type="hidden"/>' . "\n"; |
|
| 404 | - } else |
|
| 405 | - $out .= '<input id="successmsg_' . $htmlname . '" value="' . $custommsg . '" type="hidden"/>' . "\n"; |
|
| 430 | + if (!empty($custommsg['success'])) { |
|
| 431 | + $out .= '<input id="successmsg_' . $htmlname . '" value="' . $custommsg['success'] . '" type="hidden"/>' . "\n"; |
|
| 432 | + } |
|
| 433 | + if (!empty($custommsg['error'])) { |
|
| 434 | + $out .= '<input id="errormsg_' . $htmlname . '" value="' . $custommsg['error'] . '" type="hidden"/>' . "\n"; |
|
| 435 | + } |
|
| 436 | + } else { |
|
| 437 | + $out .= '<input id="successmsg_' . $htmlname . '" value="' . $custommsg . '" type="hidden"/>' . "\n"; |
|
| 438 | + } |
|
| 406 | 439 | } |
| 407 | 440 | if ($inputType == 'textarea') {
|
| 408 | 441 | $out .= '<input id="textarea_' . $htmlname . '_rows" value="' . $rows . '" type="hidden"/>' . "\n"; |
@@ -440,16 +473,20 @@ discard block |
||
| 440 | 473 | {
|
| 441 | 474 | global $conf; |
| 442 | 475 | |
| 443 | - if ($incbefore) |
|
| 444 | - $text = $incbefore . $text; |
|
| 445 | - if (!$htmltext) |
|
| 446 | - return $text; |
|
| 476 | + if ($incbefore) { |
|
| 477 | + $text = $incbefore . $text; |
|
| 478 | + } |
|
| 479 | + if (!$htmltext) { |
|
| 480 | + return $text; |
|
| 481 | + } |
|
| 447 | 482 | |
| 448 | 483 | $tag = 'td'; |
| 449 | - if ($notabs == 2) |
|
| 450 | - $tag = 'div'; |
|
| 451 | - if ($notabs == 3) |
|
| 452 | - $tag = 'span'; |
|
| 484 | + if ($notabs == 2) { |
|
| 485 | + $tag = 'div'; |
|
| 486 | + } |
|
| 487 | + if ($notabs == 3) { |
|
| 488 | + $tag = 'span'; |
|
| 489 | + } |
|
| 453 | 490 | // Sanitize tooltip |
| 454 | 491 | $htmltext = str_replace("\\", "\\\\", $htmltext);
|
| 455 | 492 | $htmltext = str_replace("\r", "", $htmltext);
|
@@ -478,24 +515,35 @@ discard block |
||
| 478 | 515 | } |
| 479 | 516 | if ($tooltipon == 2 || $tooltipon == 3) {
|
| 480 | 517 | $paramfortooltipimg = ' class="' . $classfortooltip . ' inline-block' . ($extracss ? ' ' . $extracss : '') . '" style="padding: 0px;' . ($extrastyle ? ' ' . $extrastyle : '') . '"'; |
| 481 | - if ($tooltiptrigger == '') |
|
| 482 | - $paramfortooltipimg .= ' title="' . ($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)) . '"'; // Attribut to put on img tag to store tooltip |
|
| 483 | - else |
|
| 484 | - $paramfortooltipimg .= ' dolid="' . $tooltiptrigger . '"'; |
|
| 485 | - } else |
|
| 486 | - $paramfortooltipimg = ($extracss ? ' class="' . $extracss . '"' : '') . ($extrastyle ? ' style="' . $extrastyle . '"' : ''); // Attribut to put on td text tag |
|
| 518 | + if ($tooltiptrigger == '') { |
|
| 519 | + $paramfortooltipimg .= ' title="' . ($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)) . '"'; |
|
| 520 | + } |
|
| 521 | + // Attribut to put on img tag to store tooltip |
|
| 522 | + else { |
|
| 523 | + $paramfortooltipimg .= ' dolid="' . $tooltiptrigger . '"'; |
|
| 524 | + } |
|
| 525 | + } else { |
|
| 526 | + $paramfortooltipimg = ($extracss ? ' class="' . $extracss . '"' : '') . ($extrastyle ? ' style="' . $extrastyle . '"' : ''); |
|
| 527 | + } |
|
| 528 | + // Attribut to put on td text tag |
|
| 487 | 529 | if ($tooltipon == 1 || $tooltipon == 3) {
|
| 488 | 530 | $paramfortooltiptd = ' class="' . ($tooltipon == 3 ? 'cursorpointer ' : '') . $classfortooltip . ' inline-block' . ($extracss ? ' ' . $extracss : '') . '" style="padding: 0px;' . ($extrastyle ? ' ' . $extrastyle : '') . '" '; |
| 489 | - if ($tooltiptrigger == '') |
|
| 490 | - $paramfortooltiptd .= ' title="' . ($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)) . '"'; // Attribut to put on td tag to store tooltip |
|
| 491 | - else |
|
| 492 | - $paramfortooltiptd .= ' dolid="' . $tooltiptrigger . '"'; |
|
| 493 | - } else |
|
| 494 | - $paramfortooltiptd = ($extracss ? ' class="' . $extracss . '"' : '') . ($extrastyle ? ' style="' . $extrastyle . '"' : ''); // Attribut to put on td text tag |
|
| 495 | - if (empty($notabs)) |
|
| 496 | - $s .= '<table class="nobordernopadding" summary=""><tr style="height: auto;">'; |
|
| 497 | - elseif ($notabs == 2) |
|
| 498 | - $s .= '<div class="inline-block' . ($forcenowrap ? ' nowrap' : '') . '">'; |
|
| 531 | + if ($tooltiptrigger == '') { |
|
| 532 | + $paramfortooltiptd .= ' title="' . ($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)) . '"'; |
|
| 533 | + } |
|
| 534 | + // Attribut to put on td tag to store tooltip |
|
| 535 | + else { |
|
| 536 | + $paramfortooltiptd .= ' dolid="' . $tooltiptrigger . '"'; |
|
| 537 | + } |
|
| 538 | + } else { |
|
| 539 | + $paramfortooltiptd = ($extracss ? ' class="' . $extracss . '"' : '') . ($extrastyle ? ' style="' . $extrastyle . '"' : ''); |
|
| 540 | + } |
|
| 541 | + // Attribut to put on td text tag |
|
| 542 | + if (empty($notabs)) { |
|
| 543 | + $s .= '<table class="nobordernopadding" summary=""><tr style="height: auto;">'; |
|
| 544 | + } elseif ($notabs == 2) { |
|
| 545 | + $s .= '<div class="inline-block' . ($forcenowrap ? ' nowrap' : '') . '">'; |
|
| 546 | + } |
|
| 499 | 547 | // Define value if value is before |
| 500 | 548 | if ($direction < 0) {
|
| 501 | 549 | $s .= '<' . $tag . $paramfortooltipimg; |
@@ -506,19 +554,22 @@ discard block |
||
| 506 | 554 | } |
| 507 | 555 | // Use another method to help avoid having a space in value in order to use this value with jquery |
| 508 | 556 | // Define label |
| 509 | - if ((string) $text != '') |
|
| 510 | - $s .= '<' . $tag . $paramfortooltiptd . '>' . $text . '</' . $tag . '>'; |
|
| 557 | + if ((string) $text != '') { |
|
| 558 | + $s .= '<' . $tag . $paramfortooltiptd . '>' . $text . '</' . $tag . '>'; |
|
| 559 | + } |
|
| 511 | 560 | // Define value if value is after |
| 512 | 561 | if ($direction > 0) {
|
| 513 | 562 | $s .= '<' . $tag . $paramfortooltipimg; |
| 514 | - if ($tag == 'td') |
|
| 515 | - $s .= ' valign="middle" width="14"'; |
|
| 563 | + if ($tag == 'td') { |
|
| 564 | + $s .= ' valign="middle" width="14"'; |
|
| 565 | + } |
|
| 516 | 566 | $s .= '>' . $textfordialog . $img . '</' . $tag . '>'; |
| 517 | 567 | } |
| 518 | - if (empty($notabs)) |
|
| 519 | - $s .= '</tr></table>'; |
|
| 520 | - elseif ($notabs == 2) |
|
| 521 | - $s .= '</div>'; |
|
| 568 | + if (empty($notabs)) { |
|
| 569 | + $s .= '</tr></table>'; |
|
| 570 | + } elseif ($notabs == 2) { |
|
| 571 | + $s .= '</div>'; |
|
| 572 | + } |
|
| 522 | 573 | |
| 523 | 574 | return $s; |
| 524 | 575 | } |
@@ -542,20 +593,22 @@ discard block |
||
| 542 | 593 | global $conf, $langs; |
| 543 | 594 | |
| 544 | 595 | $alt = ''; |
| 545 | - if ($tooltiptrigger) |
|
| 546 | - $alt = $langs->transnoentitiesnoconv("ClickToShowHelp");
|
|
| 596 | + if ($tooltiptrigger) { |
|
| 597 | + $alt = $langs->transnoentitiesnoconv("ClickToShowHelp"); |
|
| 598 | + } |
|
| 547 | 599 | |
| 548 | 600 | //For backwards compatibility |
| 549 | - if ($type == '0') |
|
| 550 | - $type = 'info'; |
|
| 551 | - elseif ($type == '1') |
|
| 552 | - $type = 'help'; |
|
| 601 | + if ($type == '0') { |
|
| 602 | + $type = 'info'; |
|
| 603 | + } elseif ($type == '1') { |
|
| 604 | + $type = 'help'; |
|
| 605 | + } |
|
| 553 | 606 | |
| 554 | 607 | // If info or help with no javascript, show only text |
| 555 | 608 | if (empty($conf->use_javascript_ajax)) {
|
| 556 | - if ($type == 'info' || $type == 'help') |
|
| 557 | - return $text; |
|
| 558 | - else {
|
|
| 609 | + if ($type == 'info' || $type == 'help') { |
|
| 610 | + return $text; |
|
| 611 | + } else {
|
|
| 559 | 612 | $alt = $htmltext; |
| 560 | 613 | $htmltext = ''; |
| 561 | 614 | } |
@@ -563,27 +616,30 @@ discard block |
||
| 563 | 616 | |
| 564 | 617 | // If info or help with smartphone, show only text (tooltip hover can't works) |
| 565 | 618 | if (!empty($conf->dol_no_mouse_hover) && empty($tooltiptrigger)) {
|
| 566 | - if ($type == 'info' || $type == 'help') |
|
| 567 | - return $text; |
|
| 619 | + if ($type == 'info' || $type == 'help') { |
|
| 620 | + return $text; |
|
| 621 | + } |
|
| 568 | 622 | } |
| 569 | 623 | // If info or help with smartphone, show only text (tooltip on lick does not works with dialog on smaprtphone) |
| 570 | 624 | if (!empty($conf->dol_no_mouse_hover) && !empty($tooltiptrigger)) {
|
| 571 | - if ($type == 'info' || $type == 'help') |
|
| 572 | - return $text; |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - if ($type == 'info') |
|
| 576 | - $img = img_help(0, $alt); |
|
| 577 | - elseif ($type == 'help') |
|
| 578 | - $img = img_help(($tooltiptrigger != '' ? 2 : 1), $alt); |
|
| 579 | - elseif ($type == 'superadmin') |
|
| 580 | - $img = img_picto($alt, 'redstar'); |
|
| 581 | - elseif ($type == 'admin') |
|
| 582 | - $img = img_picto($alt, 'star'); |
|
| 583 | - elseif ($type == 'warning') |
|
| 584 | - $img = img_warning($alt); |
|
| 585 | - else |
|
| 586 | - $img = img_picto($alt, $type); |
|
| 625 | + if ($type == 'info' || $type == 'help') { |
|
| 626 | + return $text; |
|
| 627 | + } |
|
| 628 | + } |
|
| 629 | + |
|
| 630 | + if ($type == 'info') { |
|
| 631 | + $img = img_help(0, $alt); |
|
| 632 | + } elseif ($type == 'help') { |
|
| 633 | + $img = img_help(($tooltiptrigger != '' ? 2 : 1), $alt); |
|
| 634 | + } elseif ($type == 'superadmin') { |
|
| 635 | + $img = img_picto($alt, 'redstar'); |
|
| 636 | + } elseif ($type == 'admin') { |
|
| 637 | + $img = img_picto($alt, 'star'); |
|
| 638 | + } elseif ($type == 'warning') { |
|
| 639 | + $img = img_warning($alt); |
|
| 640 | + } else { |
|
| 641 | + $img = img_picto($alt, $type); |
|
| 642 | + } |
|
| 587 | 643 | |
| 588 | 644 | return $this->textwithtooltip($text, $htmltext, (($tooltiptrigger && !$img) ? 3 : 2), $direction, $img, $extracss, $notabs, '', $noencodehtmltext, $tooltiptrigger, $forcenowrap); |
| 589 | 645 | } |
@@ -600,8 +656,9 @@ discard block |
||
| 600 | 656 | {
|
| 601 | 657 | global $conf, $langs, $hookmanager; |
| 602 | 658 | |
| 603 | - if (count($arrayofaction) == 0) |
|
| 604 | - return; |
|
| 659 | + if (count($arrayofaction) == 0) { |
|
| 660 | + return; |
|
| 661 | + } |
|
| 605 | 662 | |
| 606 | 663 | $disabled = 0; |
| 607 | 664 | $ret = '<div class="centpercent center">'; |
@@ -733,10 +790,11 @@ discard block |
||
| 733 | 790 | $i++; |
| 734 | 791 | } |
| 735 | 792 | |
| 736 | - if (empty($disablefavorites)) |
|
| 737 | - array_multisort($favorite, SORT_DESC, $label, SORT_ASC, $countryArray); |
|
| 738 | - else |
|
| 739 | - $countryArray = dol_sort_array($countryArray, 'label'); |
|
| 793 | + if (empty($disablefavorites)) { |
|
| 794 | + array_multisort($favorite, SORT_DESC, $label, SORT_ASC, $countryArray); |
|
| 795 | + } else { |
|
| 796 | + $countryArray = dol_sort_array($countryArray, 'label'); |
|
| 797 | + } |
|
| 740 | 798 | |
| 741 | 799 | if ($showempty) {
|
| 742 | 800 | $out .= '<option value=""> </option>' . "\n"; |
@@ -746,19 +804,22 @@ discard block |
||
| 746 | 804 | //if ($showempty) $out.= '<option value="" disabled class="selectoptiondisabledwhite">--------------</option>'; |
| 747 | 805 | $out .= '<option value="special_allnotme"' . ($selected == 'special_allnotme' ? ' selected' : '') . '>' . $langs->trans("CountriesExceptMe", $langs->transnoentitiesnoconv("Country" . $mysoc->country_code)) . '</option>';
|
| 748 | 806 | $out .= '<option value="special_eec"' . ($selected == 'special_eec' ? ' selected' : '') . '>' . $langs->trans("CountriesInEEC") . '</option>';
|
| 749 | - if ($mysoc->isInEEC()) |
|
| 750 | - $out .= '<option value="special_eecnotme"' . ($selected == 'special_eecnotme' ? ' selected' : '') . '>' . $langs->trans("CountriesInEECExceptMe", $langs->transnoentitiesnoconv("Country" . $mysoc->country_code)) . '</option>';
|
|
| 807 | + if ($mysoc->isInEEC()) { |
|
| 808 | + $out .= '<option value="special_eecnotme"' . ($selected == 'special_eecnotme' ? ' selected' : '') . '>' . $langs->trans("CountriesInEECExceptMe", $langs->transnoentitiesnoconv("Country" . $mysoc->country_code)) . '</option>'; |
|
| 809 | + } |
|
| 751 | 810 | $out .= '<option value="special_noteec"' . ($selected == 'special_noteec' ? ' selected' : '') . '>' . $langs->trans("CountriesNotInEEC") . '</option>';
|
| 752 | 811 | $out .= '<option value="" disabled class="selectoptiondisabledwhite">--------------</option>'; |
| 753 | 812 | } |
| 754 | 813 | |
| 755 | 814 | foreach ($countryArray as $row) {
|
| 756 | 815 | //if (empty($showempty) && empty($row['rowid'])) continue; |
| 757 | - if (empty($row['rowid'])) |
|
| 758 | - continue; |
|
| 816 | + if (empty($row['rowid'])) { |
|
| 817 | + continue; |
|
| 818 | + } |
|
| 759 | 819 | |
| 760 | - if (empty($disablefavorites) && $row['favorite'] && $row['code_iso']) |
|
| 761 | - $atleastonefavorite++; |
|
| 820 | + if (empty($disablefavorites) && $row['favorite'] && $row['code_iso']) { |
|
| 821 | + $atleastonefavorite++; |
|
| 822 | + } |
|
| 762 | 823 | if (empty($row['favorite']) && $atleastonefavorite) {
|
| 763 | 824 | $atleastonefavorite = 0; |
| 764 | 825 | $out .= '<option value="" disabled class="selectoptiondisabledwhite">--------------</option>'; |
@@ -769,18 +830,19 @@ discard block |
||
| 769 | 830 | } else {
|
| 770 | 831 | $out .= '<option value="' . ($usecodeaskey ? ($usecodeaskey == 'code2' ? $row['code_iso'] : $row['code_iso3']) : $row['rowid']) . '">'; |
| 771 | 832 | } |
| 772 | - if ($row['label']) |
|
| 773 | - $out .= dol_trunc($row['label'], $maxlength, 'middle'); |
|
| 774 | - else |
|
| 775 | - $out .= ' '; |
|
| 776 | - if ($row['code_iso']) |
|
| 777 | - $out .= ' (' . $row['code_iso'] . ')';
|
|
| 833 | + if ($row['label']) { |
|
| 834 | + $out .= dol_trunc($row['label'], $maxlength, 'middle'); |
|
| 835 | + } else { |
|
| 836 | + $out .= ' '; |
|
| 837 | + } |
|
| 838 | + if ($row['code_iso']) { |
|
| 839 | + $out .= ' (' . $row['code_iso'] . ')'; |
|
| 840 | + } |
|
| 778 | 841 | $out .= '</option>'; |
| 779 | 842 | } |
| 780 | 843 | } |
| 781 | 844 | $out .= '</select>'; |
| 782 | - } |
|
| 783 | - else {
|
|
| 845 | + } else {
|
|
| 784 | 846 | dol_print_error($this->db); |
| 785 | 847 | } |
| 786 | 848 | |
@@ -854,8 +916,9 @@ discard block |
||
| 854 | 916 | $out .= '<option value="' . $row['rowid'] . '">'; |
| 855 | 917 | } |
| 856 | 918 | |
| 857 | - if ($row['code']) |
|
| 858 | - $out .= $row['code']; |
|
| 919 | + if ($row['code']) { |
|
| 920 | + $out .= $row['code']; |
|
| 921 | + } |
|
| 859 | 922 | |
| 860 | 923 | $out .= '</option>'; |
| 861 | 924 | } |
@@ -893,24 +956,28 @@ discard block |
||
| 893 | 956 | |
| 894 | 957 | // If product & services are enabled or both disabled. |
| 895 | 958 | if ($forceall == 1 || (empty($forceall) && !empty($conf->product->enabled) && !empty($conf->service->enabled)) || (empty($forceall) && empty($conf->product->enabled) && empty($conf->service->enabled))) {
|
| 896 | - if (empty($hidetext)) |
|
| 897 | - print $langs->trans("Type") . ': ';
|
|
| 959 | + if (empty($hidetext)) { |
|
| 960 | + print $langs->trans("Type") . ': '; |
|
| 961 | + } |
|
| 898 | 962 | print '<select class="flat" id="select_' . $htmlname . '" name="' . $htmlname . '">'; |
| 899 | 963 | if ($showempty) {
|
| 900 | 964 | print '<option value="-1"'; |
| 901 | - if ($selected == -1) |
|
| 902 | - print ' selected'; |
|
| 965 | + if ($selected == -1) { |
|
| 966 | + print ' selected'; |
|
| 967 | + } |
|
| 903 | 968 | print '> </option>'; |
| 904 | 969 | } |
| 905 | 970 | |
| 906 | 971 | print '<option value="0"'; |
| 907 | - if (0 == $selected) |
|
| 908 | - print ' selected'; |
|
| 972 | + if (0 == $selected) { |
|
| 973 | + print ' selected'; |
|
| 974 | + } |
|
| 909 | 975 | print '>' . $langs->trans("Product");
|
| 910 | 976 | |
| 911 | 977 | print '<option value="1"'; |
| 912 | - if (1 == $selected) |
|
| 913 | - print ' selected'; |
|
| 978 | + if (1 == $selected) { |
|
| 979 | + print ' selected'; |
|
| 980 | + } |
|
| 914 | 981 | print '>' . $langs->trans("Service");
|
| 915 | 982 | |
| 916 | 983 | print '</select>'; |
@@ -941,8 +1008,10 @@ discard block |
||
| 941 | 1008 | global $langs; |
| 942 | 1009 | |
| 943 | 1010 | $num = count($this->cache_types_fees); |
| 944 | - if ($num > 0) |
|
| 945 | - return 0; // Cache already loaded |
|
| 1011 | + if ($num > 0) { |
|
| 1012 | + return 0; |
|
| 1013 | + } |
|
| 1014 | + // Cache already loaded |
|
| 946 | 1015 | |
| 947 | 1016 | dol_syslog(__METHOD__, LOG_DEBUG); |
| 948 | 1017 | |
@@ -996,23 +1065,26 @@ discard block |
||
| 996 | 1065 | print '<select id="select_' . $htmlname . '" class="flat" name="' . $htmlname . '">'; |
| 997 | 1066 | if ($showempty) {
|
| 998 | 1067 | print '<option value="-1"'; |
| 999 | - if ($selected == -1) |
|
| 1000 | - print ' selected'; |
|
| 1068 | + if ($selected == -1) { |
|
| 1069 | + print ' selected'; |
|
| 1070 | + } |
|
| 1001 | 1071 | print '> </option>'; |
| 1002 | 1072 | } |
| 1003 | 1073 | |
| 1004 | 1074 | foreach ($this->cache_types_fees as $key => $value) {
|
| 1005 | 1075 | print '<option value="' . $key . '"'; |
| 1006 | - if ($key == $selected) |
|
| 1007 | - print ' selected'; |
|
| 1076 | + if ($key == $selected) { |
|
| 1077 | + print ' selected'; |
|
| 1078 | + } |
|
| 1008 | 1079 | print '>'; |
| 1009 | 1080 | print $value; |
| 1010 | 1081 | print '</option>'; |
| 1011 | 1082 | } |
| 1012 | 1083 | |
| 1013 | 1084 | print '</select>'; |
| 1014 | - if ($user->admin) |
|
| 1015 | - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
|
| 1085 | + if ($user->admin) { |
|
| 1086 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 1087 | + } |
|
| 1016 | 1088 | } |
| 1017 | 1089 | |
| 1018 | 1090 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -1075,9 +1147,9 @@ discard block |
||
| 1075 | 1147 | $urloption = 'htmlname=' . $htmlname . '&outjson=1&filter=' . $filter . ($showtype ? '&showtype=' . $showtype : ''); |
| 1076 | 1148 | $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); |
| 1077 | 1149 | $out .= '<style type="text/css">.ui-autocomplete { z-index: 250; }</style>';
|
| 1078 | - if (empty($hidelabel)) |
|
| 1079 | - print $langs->trans("RefOrLabel") . ' : ';
|
|
| 1080 | - else if ($hidelabel > 1) {
|
|
| 1150 | + if (empty($hidelabel)) { |
|
| 1151 | + print $langs->trans("RefOrLabel") . ' : '; |
|
| 1152 | + } else if ($hidelabel > 1) {
|
|
| 1081 | 1153 | $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
|
| 1082 | 1154 | if ($hidelabel == 2) {
|
| 1083 | 1155 | $out .= img_picto($langs->trans("Search"), 'search');
|
@@ -1124,10 +1196,11 @@ discard block |
||
| 1124 | 1196 | $num = 0; |
| 1125 | 1197 | $outarray = array(); |
| 1126 | 1198 | |
| 1127 | - if ($selected === '') |
|
| 1128 | - $selected = array(); |
|
| 1129 | - else if (!is_array($selected)) |
|
| 1130 | - $selected = array($selected); |
|
| 1199 | + if ($selected === '') { |
|
| 1200 | + $selected = array(); |
|
| 1201 | + } else if (!is_array($selected)) { |
|
| 1202 | + $selected = array($selected); |
|
| 1203 | + } |
|
| 1131 | 1204 | |
| 1132 | 1205 | // Clean $filter that may contains sql conditions so sql code |
| 1133 | 1206 | if (function_exists('testSqlAndScriptInject')) {
|
@@ -1145,21 +1218,26 @@ discard block |
||
| 1145 | 1218 | } |
| 1146 | 1219 | |
| 1147 | 1220 | $sql .= " FROM (" . MAIN_DB_PREFIX . "societe as s";
|
| 1148 | - if (!$user->rights->societe->client->voir && !$user->socid) |
|
| 1149 | - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; |
|
| 1221 | + if (!$user->rights->societe->client->voir && !$user->socid) { |
|
| 1222 | + $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; |
|
| 1223 | + } |
|
| 1150 | 1224 | $sql .= " )"; |
| 1151 | 1225 | if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) {
|
| 1152 | 1226 | $sql .= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "c_country as dictp ON dictp.rowid=s.fk_pays"; |
| 1153 | 1227 | } |
| 1154 | 1228 | $sql .= " WHERE s.entity IN (" . getEntity('societe') . ")";
|
| 1155 | - if (!empty($user->socid)) |
|
| 1156 | - $sql .= " AND s.rowid = " . $user->socid; |
|
| 1157 | - if ($filter) |
|
| 1158 | - $sql .= " AND (" . $filter . ")";
|
|
| 1159 | - if (!$user->rights->societe->client->voir && !$user->socid) |
|
| 1160 | - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; |
|
| 1161 | - if (!empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) |
|
| 1162 | - $sql .= " AND s.status <> 0"; |
|
| 1229 | + if (!empty($user->socid)) { |
|
| 1230 | + $sql .= " AND s.rowid = " . $user->socid; |
|
| 1231 | + } |
|
| 1232 | + if ($filter) { |
|
| 1233 | + $sql .= " AND (" . $filter . ")"; |
|
| 1234 | + } |
|
| 1235 | + if (!$user->rights->societe->client->voir && !$user->socid) { |
|
| 1236 | + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; |
|
| 1237 | + } |
|
| 1238 | + if (!empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) { |
|
| 1239 | + $sql .= " AND s.status <> 0"; |
|
| 1240 | + } |
|
| 1163 | 1241 | // Add criteria |
| 1164 | 1242 | if ($filterkey && $filterkey != '') {
|
| 1165 | 1243 | $sql .= " AND (";
|
@@ -1167,16 +1245,19 @@ discard block |
||
| 1167 | 1245 | // For natural search |
| 1168 | 1246 | $scrit = explode(' ', $filterkey);
|
| 1169 | 1247 | $i = 0; |
| 1170 | - if (count($scrit) > 1) |
|
| 1171 | - $sql .= "(";
|
|
| 1248 | + if (count($scrit) > 1) { |
|
| 1249 | + $sql .= "("; |
|
| 1250 | + } |
|
| 1172 | 1251 | foreach ($scrit as $crit) {
|
| 1173 | - if ($i > 0) |
|
| 1174 | - $sql .= " AND "; |
|
| 1252 | + if ($i > 0) { |
|
| 1253 | + $sql .= " AND "; |
|
| 1254 | + } |
|
| 1175 | 1255 | $sql .= "(s.nom LIKE '" . $this->db->escape($prefix . $crit) . "%')"; |
| 1176 | 1256 | $i++; |
| 1177 | 1257 | } |
| 1178 | - if (count($scrit) > 1) |
|
| 1179 | - $sql .= ")"; |
|
| 1258 | + if (count($scrit) > 1) { |
|
| 1259 | + $sql .= ")"; |
|
| 1260 | + } |
|
| 1180 | 1261 | if (!empty($conf->barcode->enabled)) {
|
| 1181 | 1262 | $sql .= " OR s.barcode LIKE '" . $this->db->escape($prefix . $filterkey) . "%'"; |
| 1182 | 1263 | } |
@@ -1202,13 +1283,15 @@ discard block |
||
| 1202 | 1283 | // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. |
| 1203 | 1284 | //if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty=''; |
| 1204 | 1285 | if (!empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) {
|
| 1205 | - if ($showempty && !is_numeric($showempty)) |
|
| 1206 | - $textifempty = $langs->trans($showempty); |
|
| 1207 | - else |
|
| 1208 | - $textifempty .= $langs->trans("All");
|
|
| 1286 | + if ($showempty && !is_numeric($showempty)) { |
|
| 1287 | + $textifempty = $langs->trans($showempty); |
|
| 1288 | + } else { |
|
| 1289 | + $textifempty .= $langs->trans("All"); |
|
| 1290 | + } |
|
| 1209 | 1291 | } |
| 1210 | - if ($showempty) |
|
| 1211 | - $out .= '<option value="-1">' . $textifempty . '</option>' . "\n"; |
|
| 1292 | + if ($showempty) { |
|
| 1293 | + $out .= '<option value="-1">' . $textifempty . '</option>' . "\n"; |
|
| 1294 | + } |
|
| 1212 | 1295 | |
| 1213 | 1296 | $num = $this->db->num_rows($resql); |
| 1214 | 1297 | $i = 0; |
@@ -1233,16 +1316,21 @@ discard block |
||
| 1233 | 1316 | } |
| 1234 | 1317 | |
| 1235 | 1318 | if ($showtype) {
|
| 1236 | - if ($obj->client || $obj->fournisseur) |
|
| 1237 | - $label .= ' (';
|
|
| 1238 | - if ($obj->client == 1 || $obj->client == 3) |
|
| 1239 | - $label .= $langs->trans("Customer");
|
|
| 1240 | - if ($obj->client == 2 || $obj->client == 3) |
|
| 1241 | - $label .= ($obj->client == 3 ? ', ' : '') . $langs->trans("Prospect");
|
|
| 1242 | - if ($obj->fournisseur) |
|
| 1243 | - $label .= ($obj->client ? ', ' : '') . $langs->trans("Supplier");
|
|
| 1244 | - if ($obj->client || $obj->fournisseur) |
|
| 1245 | - $label .= ')'; |
|
| 1319 | + if ($obj->client || $obj->fournisseur) { |
|
| 1320 | + $label .= ' ('; |
|
| 1321 | + } |
|
| 1322 | + if ($obj->client == 1 || $obj->client == 3) { |
|
| 1323 | + $label .= $langs->trans("Customer"); |
|
| 1324 | + } |
|
| 1325 | + if ($obj->client == 2 || $obj->client == 3) { |
|
| 1326 | + $label .= ($obj->client == 3 ? ', ' : '') . $langs->trans("Prospect"); |
|
| 1327 | + } |
|
| 1328 | + if ($obj->fournisseur) { |
|
| 1329 | + $label .= ($obj->client ? ', ' : '') . $langs->trans("Supplier"); |
|
| 1330 | + } |
|
| 1331 | + if ($obj->client || $obj->fournisseur) { |
|
| 1332 | + $label .= ')'; |
|
| 1333 | + } |
|
| 1246 | 1334 | } |
| 1247 | 1335 | |
| 1248 | 1336 | if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) {
|
@@ -1263,20 +1351,21 @@ discard block |
||
| 1263 | 1351 | } |
| 1264 | 1352 | |
| 1265 | 1353 | $i++; |
| 1266 | - if (($i % 10) == 0) |
|
| 1267 | - $out .= "\n"; |
|
| 1354 | + if (($i % 10) == 0) { |
|
| 1355 | + $out .= "\n"; |
|
| 1356 | + } |
|
| 1268 | 1357 | } |
| 1269 | 1358 | } |
| 1270 | 1359 | $out .= '</select>' . "\n"; |
| 1271 | - } |
|
| 1272 | - else {
|
|
| 1360 | + } else {
|
|
| 1273 | 1361 | dol_print_error($this->db); |
| 1274 | 1362 | } |
| 1275 | 1363 | |
| 1276 | 1364 | $this->result = array('nbofthirdparties' => $num);
|
| 1277 | 1365 | |
| 1278 | - if ($outputmode) |
|
| 1279 | - return $outarray; |
|
| 1366 | + if ($outputmode) { |
|
| 1367 | + return $outarray; |
|
| 1368 | + } |
|
| 1280 | 1369 | return $out; |
| 1281 | 1370 | } |
| 1282 | 1371 | |
@@ -1302,8 +1391,9 @@ discard block |
||
| 1302 | 1391 | $sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re"; |
| 1303 | 1392 | $sql .= " WHERE re.fk_soc = " . (int) $socid; |
| 1304 | 1393 | $sql .= " AND re.entity = " . $conf->entity; |
| 1305 | - if ($filter) |
|
| 1306 | - $sql .= " AND " . $filter; |
|
| 1394 | + if ($filter) { |
|
| 1395 | + $sql .= " AND " . $filter; |
|
| 1396 | + } |
|
| 1307 | 1397 | $sql .= " ORDER BY re.description ASC"; |
| 1308 | 1398 | |
| 1309 | 1399 | dol_syslog(get_class($this) . "::select_remises", LOG_DEBUG); |
@@ -1320,18 +1410,23 @@ discard block |
||
| 1320 | 1410 | while ($i < $num) {
|
| 1321 | 1411 | $obj = $this->db->fetch_object($resql); |
| 1322 | 1412 | $desc = dol_trunc($obj->description, 40); |
| 1323 | - if (preg_match('/\(CREDIT_NOTE\)/', $desc))
|
|
| 1324 | - $desc = preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $desc);
|
|
| 1325 | - if (preg_match('/\(DEPOSIT\)/', $desc))
|
|
| 1326 | - $desc = preg_replace('/\(DEPOSIT\)/', $langs->trans("Deposit"), $desc);
|
|
| 1327 | - if (preg_match('/\(EXCESS RECEIVED\)/', $desc))
|
|
| 1328 | - $desc = preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("ExcessReceived"), $desc);
|
|
| 1329 | - if (preg_match('/\(EXCESS PAID\)/', $desc))
|
|
| 1330 | - $desc = preg_replace('/\(EXCESS PAID\)/', $langs->trans("ExcessPaid"), $desc);
|
|
| 1413 | + if (preg_match('/\(CREDIT_NOTE\)/', $desc)) { |
|
| 1414 | + $desc = preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $desc); |
|
| 1415 | + } |
|
| 1416 | + if (preg_match('/\(DEPOSIT\)/', $desc)) { |
|
| 1417 | + $desc = preg_replace('/\(DEPOSIT\)/', $langs->trans("Deposit"), $desc); |
|
| 1418 | + } |
|
| 1419 | + if (preg_match('/\(EXCESS RECEIVED\)/', $desc)) { |
|
| 1420 | + $desc = preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("ExcessReceived"), $desc); |
|
| 1421 | + } |
|
| 1422 | + if (preg_match('/\(EXCESS PAID\)/', $desc)) { |
|
| 1423 | + $desc = preg_replace('/\(EXCESS PAID\)/', $langs->trans("ExcessPaid"), $desc); |
|
| 1424 | + } |
|
| 1331 | 1425 | |
| 1332 | 1426 | $selectstring = ''; |
| 1333 | - if ($selected > 0 && $selected == $obj->rowid) |
|
| 1334 | - $selectstring = ' selected'; |
|
| 1427 | + if ($selected > 0 && $selected == $obj->rowid) { |
|
| 1428 | + $selectstring = ' selected'; |
|
| 1429 | + } |
|
| 1335 | 1430 | |
| 1336 | 1431 | $disabled = ''; |
| 1337 | 1432 | if ($maxvalue > 0 && $obj->amount_ttc > $maxvalue) {
|
@@ -1341,8 +1436,9 @@ discard block |
||
| 1341 | 1436 | |
| 1342 | 1437 | if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST) && !empty($obj->fk_facture_source)) {
|
| 1343 | 1438 | $tmpfac = new Facture($this->db); |
| 1344 | - if ($tmpfac->fetch($obj->fk_facture_source) > 0) |
|
| 1345 | - $desc = $desc . ' - ' . $tmpfac->ref; |
|
| 1439 | + if ($tmpfac->fetch($obj->fk_facture_source) > 0) { |
|
| 1440 | + $desc = $desc . ' - ' . $tmpfac->ref; |
|
| 1441 | + } |
|
| 1346 | 1442 | } |
| 1347 | 1443 | |
| 1348 | 1444 | print '<option value="' . $obj->rowid . '"' . $selectstring . $disabled . '>' . $desc . ' (' . price($obj->amount_ht) . ' ' . $langs->trans("HT") . ' - ' . price($obj->amount_ttc) . ' ' . $langs->trans("TTC") . ')</option>';
|
@@ -1351,8 +1447,7 @@ discard block |
||
| 1351 | 1447 | } |
| 1352 | 1448 | print '</select>'; |
| 1353 | 1449 | return $qualifiedlines; |
| 1354 | - } |
|
| 1355 | - else {
|
|
| 1450 | + } else {
|
|
| 1356 | 1451 | dol_print_error($this->db); |
| 1357 | 1452 | return -1; |
| 1358 | 1453 | } |
@@ -1415,13 +1510,15 @@ discard block |
||
| 1415 | 1510 | |
| 1416 | 1511 | $langs->load('companies');
|
| 1417 | 1512 | |
| 1418 | - if (empty($htmlid)) |
|
| 1419 | - $htmlid = $htmlname; |
|
| 1513 | + if (empty($htmlid)) { |
|
| 1514 | + $htmlid = $htmlname; |
|
| 1515 | + } |
|
| 1420 | 1516 | |
| 1421 | - if ($selected === '') |
|
| 1422 | - $selected = array(); |
|
| 1423 | - else if (!is_array($selected)) |
|
| 1424 | - $selected = array($selected); |
|
| 1517 | + if ($selected === '') { |
|
| 1518 | + $selected = array(); |
|
| 1519 | + } else if (!is_array($selected)) { |
|
| 1520 | + $selected = array($selected); |
|
| 1521 | + } |
|
| 1425 | 1522 | $out = ''; |
| 1426 | 1523 | |
| 1427 | 1524 | if (!is_object($hookmanager)) {
|
@@ -1431,16 +1528,20 @@ discard block |
||
| 1431 | 1528 | |
| 1432 | 1529 | // We search third parties |
| 1433 | 1530 | $sql = "SELECT sp.rowid, sp.lastname, sp.statut, sp.firstname, sp.poste"; |
| 1434 | - if ($showsoc > 0) |
|
| 1435 | - $sql .= " , s.nom as company"; |
|
| 1531 | + if ($showsoc > 0) { |
|
| 1532 | + $sql .= " , s.nom as company"; |
|
| 1533 | + } |
|
| 1436 | 1534 | $sql .= " FROM " . MAIN_DB_PREFIX . "socpeople as sp"; |
| 1437 | - if ($showsoc > 0) |
|
| 1438 | - $sql .= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid=sp.fk_soc"; |
|
| 1535 | + if ($showsoc > 0) { |
|
| 1536 | + $sql .= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid=sp.fk_soc"; |
|
| 1537 | + } |
|
| 1439 | 1538 | $sql .= " WHERE sp.entity IN (" . getEntity('socpeople') . ")";
|
| 1440 | - if ($socid > 0 || $socid == -1) |
|
| 1441 | - $sql .= " AND sp.fk_soc=" . $socid; |
|
| 1442 | - if (!empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) |
|
| 1443 | - $sql .= " AND sp.statut <> 0"; |
|
| 1539 | + if ($socid > 0 || $socid == -1) { |
|
| 1540 | + $sql .= " AND sp.fk_soc=" . $socid; |
|
| 1541 | + } |
|
| 1542 | + if (!empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) { |
|
| 1543 | + $sql .= " AND sp.statut <> 0"; |
|
| 1544 | + } |
|
| 1444 | 1545 | $sql .= " ORDER BY sp.lastname ASC"; |
| 1445 | 1546 | |
| 1446 | 1547 | dol_syslog(get_class($this) . "::select_contacts", LOG_DEBUG); |
@@ -1453,12 +1554,15 @@ discard block |
||
| 1453 | 1554 | $out .= ajax_combobox($htmlid, $events, $conf->global->CONTACT_USE_SEARCH_TO_SELECT); |
| 1454 | 1555 | } |
| 1455 | 1556 | |
| 1456 | - if ($htmlname != 'none' || $options_only) |
|
| 1457 | - $out .= '<select class="flat' . ($moreclass ? ' ' . $moreclass : '') . '" id="' . $htmlid . '" name="' . $htmlname . ($multiple ? '[]' : '') . '" ' . ($multiple ? 'multiple' : '') . ' ' . (!empty($moreparam) ? $moreparam : '') . '>'; |
|
| 1458 | - if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple) |
|
| 1459 | - $out .= '<option value="0"' . (in_array(0, $selected) ? ' selected' : '') . '> </option>'; |
|
| 1460 | - if ($showempty == 2) |
|
| 1461 | - $out .= '<option value="0"' . (in_array(0, $selected) ? ' selected' : '') . '>' . $langs->trans("Internal") . '</option>';
|
|
| 1557 | + if ($htmlname != 'none' || $options_only) { |
|
| 1558 | + $out .= '<select class="flat' . ($moreclass ? ' ' . $moreclass : '') . '" id="' . $htmlid . '" name="' . $htmlname . ($multiple ? '[]' : '') . '" ' . ($multiple ? 'multiple' : '') . ' ' . (!empty($moreparam) ? $moreparam : '') . '>'; |
|
| 1559 | + } |
|
| 1560 | + if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple) { |
|
| 1561 | + $out .= '<option value="0"' . (in_array(0, $selected) ? ' selected' : '') . '> </option>'; |
|
| 1562 | + } |
|
| 1563 | + if ($showempty == 2) { |
|
| 1564 | + $out .= '<option value="0"' . (in_array(0, $selected) ? ' selected' : '') . '>' . $langs->trans("Internal") . '</option>'; |
|
| 1565 | + } |
|
| 1462 | 1566 | $num = $this->db->num_rows($resql); |
| 1463 | 1567 | $i = 0; |
| 1464 | 1568 | if ($num) {
|
@@ -1474,49 +1578,56 @@ discard block |
||
| 1474 | 1578 | if ($obj->statut == 1) {
|
| 1475 | 1579 | if ($htmlname != 'none') {
|
| 1476 | 1580 | $disabled = 0; |
| 1477 | - if (is_array($exclude) && count($exclude) && in_array($obj->rowid, $exclude)) |
|
| 1478 | - $disabled = 1; |
|
| 1479 | - if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) |
|
| 1480 | - $disabled = 1; |
|
| 1581 | + if (is_array($exclude) && count($exclude) && in_array($obj->rowid, $exclude)) { |
|
| 1582 | + $disabled = 1; |
|
| 1583 | + } |
|
| 1584 | + if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) { |
|
| 1585 | + $disabled = 1; |
|
| 1586 | + } |
|
| 1481 | 1587 | if (!empty($selected) && in_array($obj->rowid, $selected)) {
|
| 1482 | 1588 | $out .= '<option value="' . $obj->rowid . '"'; |
| 1483 | - if ($disabled) |
|
| 1484 | - $out .= ' disabled'; |
|
| 1589 | + if ($disabled) { |
|
| 1590 | + $out .= ' disabled'; |
|
| 1591 | + } |
|
| 1485 | 1592 | $out .= ' selected>'; |
| 1486 | 1593 | $out .= $contactstatic->getFullName($langs); |
| 1487 | - if ($showfunction && $obj->poste) |
|
| 1488 | - $out .= ' (' . $obj->poste . ')';
|
|
| 1489 | - if (($showsoc > 0) && $obj->company) |
|
| 1490 | - $out .= ' - (' . $obj->company . ')';
|
|
| 1594 | + if ($showfunction && $obj->poste) { |
|
| 1595 | + $out .= ' (' . $obj->poste . ')'; |
|
| 1596 | + } |
|
| 1597 | + if (($showsoc > 0) && $obj->company) { |
|
| 1598 | + $out .= ' - (' . $obj->company . ')'; |
|
| 1599 | + } |
|
| 1491 | 1600 | $out .= '</option>'; |
| 1492 | - } |
|
| 1493 | - else {
|
|
| 1601 | + } else {
|
|
| 1494 | 1602 | $out .= '<option value="' . $obj->rowid . '"'; |
| 1495 | - if ($disabled) |
|
| 1496 | - $out .= ' disabled'; |
|
| 1603 | + if ($disabled) { |
|
| 1604 | + $out .= ' disabled'; |
|
| 1605 | + } |
|
| 1497 | 1606 | $out .= '>'; |
| 1498 | 1607 | $out .= $contactstatic->getFullName($langs); |
| 1499 | - if ($showfunction && $obj->poste) |
|
| 1500 | - $out .= ' (' . $obj->poste . ')';
|
|
| 1501 | - if (($showsoc > 0) && $obj->company) |
|
| 1502 | - $out .= ' - (' . $obj->company . ')';
|
|
| 1608 | + if ($showfunction && $obj->poste) { |
|
| 1609 | + $out .= ' (' . $obj->poste . ')'; |
|
| 1610 | + } |
|
| 1611 | + if (($showsoc > 0) && $obj->company) { |
|
| 1612 | + $out .= ' - (' . $obj->company . ')'; |
|
| 1613 | + } |
|
| 1503 | 1614 | $out .= '</option>'; |
| 1504 | 1615 | } |
| 1505 | - } |
|
| 1506 | - else {
|
|
| 1616 | + } else {
|
|
| 1507 | 1617 | if (in_array($obj->rowid, $selected)) {
|
| 1508 | 1618 | $out .= $contactstatic->getFullName($langs); |
| 1509 | - if ($showfunction && $obj->poste) |
|
| 1510 | - $out .= ' (' . $obj->poste . ')';
|
|
| 1511 | - if (($showsoc > 0) && $obj->company) |
|
| 1512 | - $out .= ' - (' . $obj->company . ')';
|
|
| 1619 | + if ($showfunction && $obj->poste) { |
|
| 1620 | + $out .= ' (' . $obj->poste . ')'; |
|
| 1621 | + } |
|
| 1622 | + if (($showsoc > 0) && $obj->company) { |
|
| 1623 | + $out .= ' - (' . $obj->company . ')'; |
|
| 1624 | + } |
|
| 1513 | 1625 | } |
| 1514 | 1626 | } |
| 1515 | 1627 | } |
| 1516 | 1628 | $i++; |
| 1517 | 1629 | } |
| 1518 | - } |
|
| 1519 | - else {
|
|
| 1630 | + } else {
|
|
| 1520 | 1631 | $out .= '<option value="-1"' . (($showempty == 2 || $multiple) ? '' : ' selected') . ' disabled>'; |
| 1521 | 1632 | $out .= ($socid != -1) ? ($langs->trans($socid ? "NoContactDefinedForThirdParty" : "NoContactDefined")) : $langs->trans('SelectAThirdPartyFirst');
|
| 1522 | 1633 | $out .= '</option>'; |
@@ -1597,24 +1708,27 @@ discard block |
||
| 1597 | 1708 | global $conf, $user, $langs; |
| 1598 | 1709 | |
| 1599 | 1710 | // If no preselected user defined, we take current user |
| 1600 | - if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) |
|
| 1601 | - $selected = $user->id; |
|
| 1711 | + if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) { |
|
| 1712 | + $selected = $user->id; |
|
| 1713 | + } |
|
| 1602 | 1714 | |
| 1603 | - if ($selected === '') |
|
| 1604 | - $selected = array(); |
|
| 1605 | - else if (!is_array($selected)) |
|
| 1606 | - $selected = array($selected); |
|
| 1715 | + if ($selected === '') { |
|
| 1716 | + $selected = array(); |
|
| 1717 | + } else if (!is_array($selected)) { |
|
| 1718 | + $selected = array($selected); |
|
| 1719 | + } |
|
| 1607 | 1720 | |
| 1608 | 1721 | $excludeUsers = null; |
| 1609 | 1722 | $includeUsers = null; |
| 1610 | 1723 | |
| 1611 | 1724 | // Permettre l'exclusion d'utilisateurs |
| 1612 | - if (is_array($exclude)) |
|
| 1613 | - $excludeUsers = implode(",", $exclude);
|
|
| 1725 | + if (is_array($exclude)) { |
|
| 1726 | + $excludeUsers = implode(",", $exclude); |
|
| 1727 | + } |
|
| 1614 | 1728 | // Permettre l'inclusion d'utilisateurs |
| 1615 | - if (is_array($include)) |
|
| 1616 | - $includeUsers = implode(",", $include);
|
|
| 1617 | - else if ($include == 'hierarchy') {
|
|
| 1729 | + if (is_array($include)) { |
|
| 1730 | + $includeUsers = implode(",", $include); |
|
| 1731 | + } else if ($include == 'hierarchy') {
|
|
| 1618 | 1732 | // Build list includeUsers to have only hierarchy |
| 1619 | 1733 | $includeUsers = implode(",", $user->getAllChildIds(0));
|
| 1620 | 1734 | } else if ($include == 'hierarchyme') {
|
@@ -1633,12 +1747,12 @@ discard block |
||
| 1633 | 1747 | $sql .= " FROM " . MAIN_DB_PREFIX . "user as u"; |
| 1634 | 1748 | if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
|
| 1635 | 1749 | $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "entity as e ON e.rowid=u.entity"; |
| 1636 | - if ($force_entity) |
|
| 1637 | - $sql .= " WHERE u.entity IN (0," . $force_entity . ")"; |
|
| 1638 | - else |
|
| 1639 | - $sql .= " WHERE u.entity IS NOT NULL"; |
|
| 1640 | - } |
|
| 1641 | - else {
|
|
| 1750 | + if ($force_entity) { |
|
| 1751 | + $sql .= " WHERE u.entity IN (0," . $force_entity . ")"; |
|
| 1752 | + } else { |
|
| 1753 | + $sql .= " WHERE u.entity IS NOT NULL"; |
|
| 1754 | + } |
|
| 1755 | + } else {
|
|
| 1642 | 1756 | if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
|
| 1643 | 1757 | $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "usergroup_user as ug"; |
| 1644 | 1758 | $sql .= " ON ug.fk_user = u.rowid"; |
@@ -1647,16 +1761,21 @@ discard block |
||
| 1647 | 1761 | $sql .= " WHERE u.entity IN (0," . $conf->entity . ")"; |
| 1648 | 1762 | } |
| 1649 | 1763 | } |
| 1650 | - if (!empty($user->societe_id)) |
|
| 1651 | - $sql .= " AND u.fk_soc = " . $user->societe_id; |
|
| 1652 | - if (is_array($exclude) && $excludeUsers) |
|
| 1653 | - $sql .= " AND u.rowid NOT IN (" . $excludeUsers . ")";
|
|
| 1654 | - if ($includeUsers) |
|
| 1655 | - $sql .= " AND u.rowid IN (" . $includeUsers . ")";
|
|
| 1656 | - if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) |
|
| 1657 | - $sql .= " AND u.statut <> 0"; |
|
| 1658 | - if (!empty($morefilter)) |
|
| 1659 | - $sql .= " " . $morefilter; |
|
| 1764 | + if (!empty($user->societe_id)) { |
|
| 1765 | + $sql .= " AND u.fk_soc = " . $user->societe_id; |
|
| 1766 | + } |
|
| 1767 | + if (is_array($exclude) && $excludeUsers) { |
|
| 1768 | + $sql .= " AND u.rowid NOT IN (" . $excludeUsers . ")"; |
|
| 1769 | + } |
|
| 1770 | + if ($includeUsers) { |
|
| 1771 | + $sql .= " AND u.rowid IN (" . $includeUsers . ")"; |
|
| 1772 | + } |
|
| 1773 | + if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) { |
|
| 1774 | + $sql .= " AND u.statut <> 0"; |
|
| 1775 | + } |
|
| 1776 | + if (!empty($morefilter)) { |
|
| 1777 | + $sql .= " " . $morefilter; |
|
| 1778 | + } |
|
| 1660 | 1779 | |
| 1661 | 1780 | if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname
|
| 1662 | 1781 | $sql .= " ORDER BY u.firstname ASC"; |
@@ -1676,10 +1795,12 @@ discard block |
||
| 1676 | 1795 | |
| 1677 | 1796 | // do not use maxwidthonsmartphone by default. Set it by caller so auto size to 100% will work when not defined |
| 1678 | 1797 | $out .= '<select class="flat' . ($morecss ? ' minwidth100 ' . $morecss : ' minwidth200') . '" id="' . $htmlname . '" name="' . $htmlname . ($multiple ? '[]' : '') . '" ' . ($multiple ? 'multiple' : '') . ' ' . ($disabled ? ' disabled' : '') . '>'; |
| 1679 | - if ($show_empty && !$multiple) |
|
| 1680 | - $out .= '<option value="-1"' . ((empty($selected) || in_array(-1, $selected)) ? ' selected' : '') . '> </option>' . "\n"; |
|
| 1681 | - if ($show_every) |
|
| 1682 | - $out .= '<option value="-2"' . ((in_array(-2, $selected)) ? ' selected' : '') . '>-- ' . $langs->trans("Everybody") . ' --</option>' . "\n";
|
|
| 1798 | + if ($show_empty && !$multiple) { |
|
| 1799 | + $out .= '<option value="-1"' . ((empty($selected) || in_array(-1, $selected)) ? ' selected' : '') . '> </option>' . "\n"; |
|
| 1800 | + } |
|
| 1801 | + if ($show_every) { |
|
| 1802 | + $out .= '<option value="-2"' . ((in_array(-2, $selected)) ? ' selected' : '') . '>-- ' . $langs->trans("Everybody") . ' --</option>' . "\n"; |
|
| 1803 | + } |
|
| 1683 | 1804 | |
| 1684 | 1805 | $userstatic = new User($this->db); |
| 1685 | 1806 | |
@@ -1691,19 +1812,21 @@ discard block |
||
| 1691 | 1812 | $userstatic->firstname = $obj->firstname; |
| 1692 | 1813 | |
| 1693 | 1814 | $disableline = ''; |
| 1694 | - if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) |
|
| 1695 | - $disableline = ($enableonlytext ? $enableonlytext : '1'); |
|
| 1815 | + if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) { |
|
| 1816 | + $disableline = ($enableonlytext ? $enableonlytext : '1'); |
|
| 1817 | + } |
|
| 1696 | 1818 | |
| 1697 | 1819 | if ((is_object($selected) && $selected->id == $obj->rowid) || (!is_object($selected) && in_array($obj->rowid, $selected) )) {
|
| 1698 | 1820 | $out .= '<option value="' . $obj->rowid . '"'; |
| 1699 | - if ($disableline) |
|
| 1700 | - $out .= ' disabled'; |
|
| 1821 | + if ($disableline) { |
|
| 1822 | + $out .= ' disabled'; |
|
| 1823 | + } |
|
| 1701 | 1824 | $out .= ' selected>'; |
| 1702 | - } |
|
| 1703 | - else {
|
|
| 1825 | + } else {
|
|
| 1704 | 1826 | $out .= '<option value="' . $obj->rowid . '"'; |
| 1705 | - if ($disableline) |
|
| 1706 | - $out .= ' disabled'; |
|
| 1827 | + if ($disableline) { |
|
| 1828 | + $out .= ' disabled'; |
|
| 1829 | + } |
|
| 1707 | 1830 | $out .= '>'; |
| 1708 | 1831 | } |
| 1709 | 1832 | |
@@ -1757,8 +1880,9 @@ discard block |
||
| 1757 | 1880 | dol_print_error($this->db); |
| 1758 | 1881 | } |
| 1759 | 1882 | |
| 1760 | - if ($outputmode) |
|
| 1761 | - return $outarray; |
|
| 1883 | + if ($outputmode) { |
|
| 1884 | + return $outarray; |
|
| 1885 | + } |
|
| 1762 | 1886 | return $out; |
| 1763 | 1887 | } |
| 1764 | 1888 | |
@@ -1810,15 +1934,18 @@ discard block |
||
| 1810 | 1934 | } |
| 1811 | 1935 | $nbassignetouser = count($assignedtouser); |
| 1812 | 1936 | |
| 1813 | - if ($nbassignetouser && $action != 'view') |
|
| 1814 | - $out .= '<br>'; |
|
| 1815 | - if ($nbassignetouser) |
|
| 1816 | - $out .= '<ul class="attendees">'; |
|
| 1937 | + if ($nbassignetouser && $action != 'view') { |
|
| 1938 | + $out .= '<br>'; |
|
| 1939 | + } |
|
| 1940 | + if ($nbassignetouser) { |
|
| 1941 | + $out .= '<ul class="attendees">'; |
|
| 1942 | + } |
|
| 1817 | 1943 | $i = 0; |
| 1818 | 1944 | $ownerid = 0; |
| 1819 | 1945 | foreach ($assignedtouser as $key => $value) {
|
| 1820 | - if ($value['id'] == $ownerid) |
|
| 1821 | - continue; |
|
| 1946 | + if ($value['id'] == $ownerid) { |
|
| 1947 | + continue; |
|
| 1948 | + } |
|
| 1822 | 1949 | |
| 1823 | 1950 | $out .= '<li>'; |
| 1824 | 1951 | $userstatic->fetch($value['id']); |
@@ -1844,8 +1971,9 @@ discard block |
||
| 1844 | 1971 | $out .= '</li>'; |
| 1845 | 1972 | $i++; |
| 1846 | 1973 | } |
| 1847 | - if ($nbassignetouser) |
|
| 1848 | - $out .= '</ul>'; |
|
| 1974 | + if ($nbassignetouser) { |
|
| 1975 | + $out .= '</ul>'; |
|
| 1976 | + } |
|
| 1849 | 1977 | |
| 1850 | 1978 | //$out.='</form>'; |
| 1851 | 1979 | return $out; |
@@ -1976,9 +2104,9 @@ discard block |
||
| 1976 | 2104 | </script> |
| 1977 | 2105 | <?php |
| 1978 | 2106 | } |
| 1979 | - if (empty($hidelabel)) |
|
| 1980 | - print $langs->trans("RefOrLabel") . ' : ';
|
|
| 1981 | - else if ($hidelabel > 1) {
|
|
| 2107 | + if (empty($hidelabel)) { |
|
| 2108 | + print $langs->trans("RefOrLabel") . ' : '; |
|
| 2109 | + } else if ($hidelabel > 1) {
|
|
| 1982 | 2110 | $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
|
| 1983 | 2111 | if ($hidelabel == 2) {
|
| 1984 | 2112 | print img_picto($langs->trans("Search"), 'search');
|
@@ -2069,13 +2197,15 @@ discard block |
||
| 2069 | 2197 | // Price by quantity |
| 2070 | 2198 | if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
|
| 2071 | 2199 | $sql .= ", (SELECT pp.rowid FROM " . MAIN_DB_PREFIX . "product_price as pp WHERE pp.fk_product = p.rowid"; |
| 2072 | - if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) |
|
| 2073 | - $sql .= " AND price_level=" . $price_level; |
|
| 2200 | + if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { |
|
| 2201 | + $sql .= " AND price_level=" . $price_level; |
|
| 2202 | + } |
|
| 2074 | 2203 | $sql .= " ORDER BY date_price"; |
| 2075 | 2204 | $sql .= " DESC LIMIT 1) as price_rowid"; |
| 2076 | 2205 | $sql .= ", (SELECT pp.price_by_qty FROM " . MAIN_DB_PREFIX . "product_price as pp WHERE pp.fk_product = p.rowid"; // price_by_qty is 1 if some prices by qty exists in subtable |
| 2077 | - if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) |
|
| 2078 | - $sql .= " AND price_level=" . $price_level; |
|
| 2206 | + if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { |
|
| 2207 | + $sql .= " AND price_level=" . $price_level; |
|
| 2208 | + } |
|
| 2079 | 2209 | $sql .= " ORDER BY date_price"; |
| 2080 | 2210 | $sql .= " DESC LIMIT 1) as price_by_qty"; |
| 2081 | 2211 | $selectFields .= ", price_rowid, price_by_qty"; |
@@ -2117,14 +2247,15 @@ discard block |
||
| 2117 | 2247 | $sql .= " AND p.finished = " . $finished; |
| 2118 | 2248 | } elseif ($finished == 1) {
|
| 2119 | 2249 | $sql .= " AND p.finished = " . $finished; |
| 2120 | - if ($status >= 0) |
|
| 2121 | - $sql .= " AND p.tosell = " . $status; |
|
| 2122 | - } |
|
| 2123 | - elseif ($status >= 0) {
|
|
| 2250 | + if ($status >= 0) { |
|
| 2251 | + $sql .= " AND p.tosell = " . $status; |
|
| 2252 | + } |
|
| 2253 | + } elseif ($status >= 0) {
|
|
| 2124 | 2254 | $sql .= " AND p.tosell = " . $status; |
| 2125 | 2255 | } |
| 2126 | - if (strval($filtertype) != '') |
|
| 2127 | - $sql .= " AND p.fk_product_type=" . $filtertype; |
|
| 2256 | + if (strval($filtertype) != '') { |
|
| 2257 | + $sql .= " AND p.fk_product_type=" . $filtertype; |
|
| 2258 | + } |
|
| 2128 | 2259 | // Add criteria on ref/label |
| 2129 | 2260 | if ($filterkey != '') {
|
| 2130 | 2261 | $sql .= ' AND (';
|
@@ -2132,28 +2263,35 @@ discard block |
||
| 2132 | 2263 | // For natural search |
| 2133 | 2264 | $scrit = explode(' ', $filterkey);
|
| 2134 | 2265 | $i = 0; |
| 2135 | - if (count($scrit) > 1) |
|
| 2136 | - $sql .= "(";
|
|
| 2266 | + if (count($scrit) > 1) { |
|
| 2267 | + $sql .= "("; |
|
| 2268 | + } |
|
| 2137 | 2269 | foreach ($scrit as $crit) {
|
| 2138 | - if ($i > 0) |
|
| 2139 | - $sql .= " AND "; |
|
| 2270 | + if ($i > 0) { |
|
| 2271 | + $sql .= " AND "; |
|
| 2272 | + } |
|
| 2140 | 2273 | $sql .= "(p.ref LIKE '" . $db->escape($prefix . $crit) . "%' OR p.label LIKE '" . $db->escape($prefix . $crit) . "%'"; |
| 2141 | - if (!empty($conf->global->MAIN_MULTILANGS)) |
|
| 2142 | - $sql .= " OR pl.label LIKE '" . $db->escape($prefix . $crit) . "%'"; |
|
| 2274 | + if (!empty($conf->global->MAIN_MULTILANGS)) { |
|
| 2275 | + $sql .= " OR pl.label LIKE '" . $db->escape($prefix . $crit) . "%'"; |
|
| 2276 | + } |
|
| 2143 | 2277 | if (!empty($conf->global->PRODUCT_AJAX_SEARCH_ON_DESCRIPTION)) {
|
| 2144 | 2278 | $sql .= " OR p.description LIKE '" . $db->escape($prefix . $crit) . "%'"; |
| 2145 | - if (!empty($conf->global->MAIN_MULTILANGS)) |
|
| 2146 | - $sql .= " OR pl.description LIKE '" . $db->escape($prefix . $crit) . "%'"; |
|
| 2279 | + if (!empty($conf->global->MAIN_MULTILANGS)) { |
|
| 2280 | + $sql .= " OR pl.description LIKE '" . $db->escape($prefix . $crit) . "%'"; |
|
| 2281 | + } |
|
| 2147 | 2282 | } |
| 2148 | - if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) |
|
| 2149 | - $sql .= " OR pfp.ref_fourn LIKE '" . $db->escape($prefix . $crit) . "%'"; |
|
| 2283 | + if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) { |
|
| 2284 | + $sql .= " OR pfp.ref_fourn LIKE '" . $db->escape($prefix . $crit) . "%'"; |
|
| 2285 | + } |
|
| 2150 | 2286 | $sql .= ")"; |
| 2151 | 2287 | $i++; |
| 2152 | 2288 | } |
| 2153 | - if (count($scrit) > 1) |
|
| 2154 | - $sql .= ")"; |
|
| 2155 | - if (!empty($conf->barcode->enabled)) |
|
| 2156 | - $sql .= " OR p.barcode LIKE '" . $db->escape($prefix . $filterkey) . "%'"; |
|
| 2289 | + if (count($scrit) > 1) { |
|
| 2290 | + $sql .= ")"; |
|
| 2291 | + } |
|
| 2292 | + if (!empty($conf->barcode->enabled)) { |
|
| 2293 | + $sql .= " OR p.barcode LIKE '" . $db->escape($prefix . $filterkey) . "%'"; |
|
| 2294 | + } |
|
| 2157 | 2295 | $sql .= ')'; |
| 2158 | 2296 | } |
| 2159 | 2297 | if (count($warehouseStatusArray)) {
|
@@ -2192,13 +2330,15 @@ discard block |
||
| 2192 | 2330 | // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. |
| 2193 | 2331 | //if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty=''; |
| 2194 | 2332 | if (!empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) {
|
| 2195 | - if ($showempty && !is_numeric($showempty)) |
|
| 2196 | - $textifempty = $langs->trans($showempty); |
|
| 2197 | - else |
|
| 2198 | - $textifempty .= $langs->trans("All");
|
|
| 2333 | + if ($showempty && !is_numeric($showempty)) { |
|
| 2334 | + $textifempty = $langs->trans($showempty); |
|
| 2335 | + } else { |
|
| 2336 | + $textifempty .= $langs->trans("All"); |
|
| 2337 | + } |
|
| 2199 | 2338 | } |
| 2200 | - if ($showempty) |
|
| 2201 | - $out .= '<option value="0" selected>' . $textifempty . '</option>'; |
|
| 2339 | + if ($showempty) { |
|
| 2340 | + $out .= '<option value="0" selected>' . $textifempty . '</option>'; |
|
| 2341 | + } |
|
| 2202 | 2342 | |
| 2203 | 2343 | $i = 0; |
| 2204 | 2344 | while ($num && $i < $num) {
|
@@ -2272,11 +2412,11 @@ discard block |
||
| 2272 | 2412 | |
| 2273 | 2413 | $this->db->free($result); |
| 2274 | 2414 | |
| 2275 | - if (empty($outputmode)) |
|
| 2276 | - return $out; |
|
| 2415 | + if (empty($outputmode)) { |
|
| 2416 | + return $out; |
|
| 2417 | + } |
|
| 2277 | 2418 | return $outarray; |
| 2278 | - } |
|
| 2279 | - else {
|
|
| 2419 | + } else {
|
|
| 2280 | 2420 | dol_print_error($db); |
| 2281 | 2421 | } |
| 2282 | 2422 | } |
@@ -2313,10 +2453,12 @@ discard block |
||
| 2313 | 2453 | $maxlengtharticle = (empty($conf->global->PRODUCT_MAX_LENGTH_COMBO) ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO); |
| 2314 | 2454 | |
| 2315 | 2455 | $label = $objp->label; |
| 2316 | - if (!empty($objp->label_translated)) |
|
| 2317 | - $label = $objp->label_translated; |
|
| 2318 | - if (!empty($filterkey) && $filterkey != '') |
|
| 2319 | - $label = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $label, 1);
|
|
| 2456 | + if (!empty($objp->label_translated)) { |
|
| 2457 | + $label = $objp->label_translated; |
|
| 2458 | + } |
|
| 2459 | + if (!empty($filterkey) && $filterkey != '') { |
|
| 2460 | + $label = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $label, 1); |
|
| 2461 | + } |
|
| 2320 | 2462 | |
| 2321 | 2463 | $outkey = $objp->rowid; |
| 2322 | 2464 | $outref = $objp->ref; |
@@ -2334,23 +2476,27 @@ discard block |
||
| 2334 | 2476 | $opt .= ' pbq="' . $objp->price_by_qty_rowid . '" data-pbq="' . $objp->price_by_qty_rowid . '" data-pbqqty="' . $objp->price_by_qty_quantity . '" data-pbqpercent="' . $objp->price_by_qty_remise_percent . '"'; |
| 2335 | 2477 | } |
| 2336 | 2478 | if (!empty($conf->stock->enabled) && $objp->fk_product_type == 0 && isset($objp->stock)) {
|
| 2337 | - if ($objp->stock > 0) |
|
| 2338 | - $opt .= ' class="product_line_stock_ok"'; |
|
| 2339 | - else if ($objp->stock <= 0) |
|
| 2340 | - $opt .= ' class="product_line_stock_too_low"'; |
|
| 2479 | + if ($objp->stock > 0) { |
|
| 2480 | + $opt .= ' class="product_line_stock_ok"'; |
|
| 2481 | + } else if ($objp->stock <= 0) { |
|
| 2482 | + $opt .= ' class="product_line_stock_too_low"'; |
|
| 2483 | + } |
|
| 2341 | 2484 | } |
| 2342 | 2485 | $opt .= '>'; |
| 2343 | 2486 | $opt .= $objp->ref; |
| 2344 | - if ($outbarcode) |
|
| 2345 | - $opt .= ' (' . $outbarcode . ')';
|
|
| 2487 | + if ($outbarcode) { |
|
| 2488 | + $opt .= ' (' . $outbarcode . ')'; |
|
| 2489 | + } |
|
| 2346 | 2490 | $opt .= ' - ' . dol_trunc($label, $maxlengtharticle); |
| 2347 | 2491 | |
| 2348 | 2492 | $objRef = $objp->ref; |
| 2349 | - if (!empty($filterkey) && $filterkey != '') |
|
| 2350 | - $objRef = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $objRef, 1);
|
|
| 2493 | + if (!empty($filterkey) && $filterkey != '') { |
|
| 2494 | + $objRef = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $objRef, 1); |
|
| 2495 | + } |
|
| 2351 | 2496 | $outval .= $objRef; |
| 2352 | - if ($outbarcode) |
|
| 2353 | - $outval .= ' (' . $outbarcode . ')';
|
|
| 2497 | + if ($outbarcode) { |
|
| 2498 | + $outval .= ' (' . $outbarcode . ')'; |
|
| 2499 | + } |
|
| 2354 | 2500 | $outval .= ' - ' . dol_trunc($label, $maxlengtharticle); |
| 2355 | 2501 | |
| 2356 | 2502 | $found = 0; |
@@ -2549,15 +2695,18 @@ discard block |
||
| 2549 | 2695 | $sql .= " pfp.supplier_reputation"; |
| 2550 | 2696 | $sql .= " FROM " . MAIN_DB_PREFIX . "product as p"; |
| 2551 | 2697 | $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; |
| 2552 | - if ($socid) |
|
| 2553 | - $sql .= " AND pfp.fk_soc = " . $socid; |
|
| 2698 | + if ($socid) { |
|
| 2699 | + $sql .= " AND pfp.fk_soc = " . $socid; |
|
| 2700 | + } |
|
| 2554 | 2701 | $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON pfp.fk_soc = s.rowid"; |
| 2555 | 2702 | $sql .= " WHERE p.entity IN (" . getEntity('product') . ")";
|
| 2556 | 2703 | $sql .= " AND p.tobuy = 1"; |
| 2557 | - if (strval($filtertype) != '') |
|
| 2558 | - $sql .= " AND p.fk_product_type=" . $this->db->escape($filtertype); |
|
| 2559 | - if (!empty($filtre)) |
|
| 2560 | - $sql .= " " . $filtre; |
|
| 2704 | + if (strval($filtertype) != '') { |
|
| 2705 | + $sql .= " AND p.fk_product_type=" . $this->db->escape($filtertype); |
|
| 2706 | + } |
|
| 2707 | + if (!empty($filtre)) { |
|
| 2708 | + $sql .= " " . $filtre; |
|
| 2709 | + } |
|
| 2561 | 2710 | // Add criteria on ref/label |
| 2562 | 2711 | if ($filterkey != '') {
|
| 2563 | 2712 | $sql .= ' AND (';
|
@@ -2565,18 +2714,22 @@ discard block |
||
| 2565 | 2714 | // For natural search |
| 2566 | 2715 | $scrit = explode(' ', $filterkey);
|
| 2567 | 2716 | $i = 0; |
| 2568 | - if (count($scrit) > 1) |
|
| 2569 | - $sql .= "(";
|
|
| 2717 | + if (count($scrit) > 1) { |
|
| 2718 | + $sql .= "("; |
|
| 2719 | + } |
|
| 2570 | 2720 | foreach ($scrit as $crit) {
|
| 2571 | - if ($i > 0) |
|
| 2572 | - $sql .= " AND "; |
|
| 2721 | + if ($i > 0) { |
|
| 2722 | + $sql .= " AND "; |
|
| 2723 | + } |
|
| 2573 | 2724 | $sql .= "(pfp.ref_fourn LIKE '" . $this->db->escape($prefix . $crit) . "%' OR p.ref LIKE '" . $this->db->escape($prefix . $crit) . "%' OR p.label LIKE '" . $this->db->escape($prefix . $crit) . "%')"; |
| 2574 | 2725 | $i++; |
| 2575 | 2726 | } |
| 2576 | - if (count($scrit) > 1) |
|
| 2577 | - $sql .= ")"; |
|
| 2578 | - if (!empty($conf->barcode->enabled)) |
|
| 2579 | - $sql .= " OR p.barcode LIKE '" . $this->db->escape($prefix . $filterkey) . "%'"; |
|
| 2727 | + if (count($scrit) > 1) { |
|
| 2728 | + $sql .= ")"; |
|
| 2729 | + } |
|
| 2730 | + if (!empty($conf->barcode->enabled)) { |
|
| 2731 | + $sql .= " OR p.barcode LIKE '" . $this->db->escape($prefix . $filterkey) . "%'"; |
|
| 2732 | + } |
|
| 2580 | 2733 | $sql .= ')'; |
| 2581 | 2734 | } |
| 2582 | 2735 | $sql .= " ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC"; |
@@ -2593,18 +2746,21 @@ discard block |
||
| 2593 | 2746 | |
| 2594 | 2747 | //$out.='<select class="flat" id="select'.$htmlname.'" name="'.$htmlname.'">'; // remove select to have id same with combo and ajax |
| 2595 | 2748 | $out .= '<select class="flat maxwidthonsmartphone" id="' . $htmlname . '" name="' . $htmlname . '">'; |
| 2596 | - if (!$selected) |
|
| 2597 | - $out .= '<option value="0" selected> </option>'; |
|
| 2598 | - else |
|
| 2599 | - $out .= '<option value="0"> </option>'; |
|
| 2749 | + if (!$selected) { |
|
| 2750 | + $out .= '<option value="0" selected> </option>'; |
|
| 2751 | + } else { |
|
| 2752 | + $out .= '<option value="0"> </option>'; |
|
| 2753 | + } |
|
| 2600 | 2754 | |
| 2601 | 2755 | $i = 0; |
| 2602 | 2756 | while ($i < $num) {
|
| 2603 | 2757 | $objp = $this->db->fetch_object($result); |
| 2604 | 2758 | |
| 2605 | 2759 | $outkey = $objp->idprodfournprice; // id in table of price |
| 2606 | - if (!$outkey && $alsoproductwithnosupplierprice) |
|
| 2607 | - $outkey = 'idprod_' . $objp->rowid; // id of product |
|
| 2760 | + if (!$outkey && $alsoproductwithnosupplierprice) { |
|
| 2761 | + $outkey = 'idprod_' . $objp->rowid; |
|
| 2762 | + } |
|
| 2763 | + // id of product |
|
| 2608 | 2764 | |
| 2609 | 2765 | $outref = $objp->ref; |
| 2610 | 2766 | $outval = ''; |
@@ -2615,32 +2771,39 @@ discard block |
||
| 2615 | 2771 | $outdurationunit = $outtype == Product::TYPE_SERVICE ? substr($objp->duration, -1) : ''; |
| 2616 | 2772 | |
| 2617 | 2773 | $opt = '<option value="' . $outkey . '"'; |
| 2618 | - if ($selected && $selected == $objp->idprodfournprice) |
|
| 2619 | - $opt .= ' selected'; |
|
| 2620 | - if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) |
|
| 2621 | - $opt .= ' disabled'; |
|
| 2774 | + if ($selected && $selected == $objp->idprodfournprice) { |
|
| 2775 | + $opt .= ' selected'; |
|
| 2776 | + } |
|
| 2777 | + if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) { |
|
| 2778 | + $opt .= ' disabled'; |
|
| 2779 | + } |
|
| 2622 | 2780 | if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0) {
|
| 2623 | 2781 | $opt .= ' pbq="' . $objp->idprodfournprice . '" data-pbq="' . $objp->idprodfournprice . '" data-pbqqty="' . $objp->quantity . '" data-pbqpercent="' . $objp->remise_percent . '"'; |
| 2624 | 2782 | } |
| 2625 | 2783 | $opt .= '>'; |
| 2626 | 2784 | |
| 2627 | 2785 | $objRef = $objp->ref; |
| 2628 | - if ($filterkey && $filterkey != '') |
|
| 2629 | - $objRef = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $objRef, 1);
|
|
| 2786 | + if ($filterkey && $filterkey != '') { |
|
| 2787 | + $objRef = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $objRef, 1); |
|
| 2788 | + } |
|
| 2630 | 2789 | $objRefFourn = $objp->ref_fourn; |
| 2631 | - if ($filterkey && $filterkey != '') |
|
| 2632 | - $objRefFourn = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $objRefFourn, 1);
|
|
| 2790 | + if ($filterkey && $filterkey != '') { |
|
| 2791 | + $objRefFourn = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $objRefFourn, 1); |
|
| 2792 | + } |
|
| 2633 | 2793 | $label = $objp->label; |
| 2634 | - if ($filterkey && $filterkey != '') |
|
| 2635 | - $label = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $label, 1);
|
|
| 2794 | + if ($filterkey && $filterkey != '') { |
|
| 2795 | + $label = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $label, 1); |
|
| 2796 | + } |
|
| 2636 | 2797 | |
| 2637 | 2798 | $opt .= $objp->ref; |
| 2638 | - if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) |
|
| 2639 | - $opt .= ' (' . $objp->ref_fourn . ')';
|
|
| 2799 | + if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) { |
|
| 2800 | + $opt .= ' (' . $objp->ref_fourn . ')'; |
|
| 2801 | + } |
|
| 2640 | 2802 | $opt .= ' - '; |
| 2641 | 2803 | $outval .= $objRef; |
| 2642 | - if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) |
|
| 2643 | - $outval .= ' (' . $objRefFourn . ')';
|
|
| 2804 | + if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) { |
|
| 2805 | + $outval .= ' (' . $objRefFourn . ')'; |
|
| 2806 | + } |
|
| 2644 | 2807 | $outval .= ' - '; |
| 2645 | 2808 | $opt .= dol_trunc($label, 72) . ' - '; |
| 2646 | 2809 | $outval .= dol_trunc($label, 72) . ' - '; |
@@ -2734,11 +2897,11 @@ discard block |
||
| 2734 | 2897 | include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
| 2735 | 2898 | $out .= ajax_combobox($htmlname); |
| 2736 | 2899 | |
| 2737 | - if (empty($outputmode)) |
|
| 2738 | - return $out; |
|
| 2900 | + if (empty($outputmode)) { |
|
| 2901 | + return $out; |
|
| 2902 | + } |
|
| 2739 | 2903 | return $outarray; |
| 2740 | - } |
|
| 2741 | - else {
|
|
| 2904 | + } else {
|
|
| 2742 | 2905 | dol_print_error($this->db); |
| 2743 | 2906 | } |
| 2744 | 2907 | } |
@@ -2827,8 +2990,9 @@ discard block |
||
| 2827 | 2990 | $opt .= " - "; |
| 2828 | 2991 | $opt .= price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency) . "/" . $langs->trans("Unit");
|
| 2829 | 2992 | } |
| 2830 | - if ($objp->duration) |
|
| 2831 | - $opt .= " - " . $objp->duration; |
|
| 2993 | + if ($objp->duration) { |
|
| 2994 | + $opt .= " - " . $objp->duration; |
|
| 2995 | + } |
|
| 2832 | 2996 | $opt .= "</option>\n"; |
| 2833 | 2997 | |
| 2834 | 2998 | $form .= $opt; |
@@ -2839,8 +3003,7 @@ discard block |
||
| 2839 | 3003 | $form .= '</select>'; |
| 2840 | 3004 | $this->db->free($result); |
| 2841 | 3005 | return $form; |
| 2842 | - } |
|
| 2843 | - else {
|
|
| 3006 | + } else {
|
|
| 2844 | 3007 | dol_print_error($this->db); |
| 2845 | 3008 | } |
| 2846 | 3009 | } |
@@ -2868,8 +3031,9 @@ discard block |
||
| 2868 | 3031 | $resql = $this->db->query($sql); |
| 2869 | 3032 | if ($resql) {
|
| 2870 | 3033 | print '<select class="flat" id="select_' . $htmlname . '" name="' . $htmlname . '">'; |
| 2871 | - if ($showempty) |
|
| 2872 | - print '<option value="0"> </option>'; |
|
| 3034 | + if ($showempty) { |
|
| 3035 | + print '<option value="0"> </option>'; |
|
| 3036 | + } |
|
| 2873 | 3037 | $num = $this->db->num_rows($resql); |
| 2874 | 3038 | $i = 0; |
| 2875 | 3039 | if ($num) {
|
@@ -2903,8 +3067,10 @@ discard block |
||
| 2903 | 3067 | global $langs; |
| 2904 | 3068 | |
| 2905 | 3069 | $num = count($this->cache_conditions_paiements); |
| 2906 | - if ($num > 0) |
|
| 2907 | - return 0; // Cache already loaded |
|
| 3070 | + if ($num > 0) { |
|
| 3071 | + return 0; |
|
| 3072 | + } |
|
| 3073 | + // Cache already loaded |
|
| 2908 | 3074 | |
| 2909 | 3075 | dol_syslog(__METHOD__, LOG_DEBUG); |
| 2910 | 3076 | |
@@ -2949,8 +3115,10 @@ discard block |
||
| 2949 | 3115 | global $langs; |
| 2950 | 3116 | |
| 2951 | 3117 | $num = count($this->cache_availability); |
| 2952 | - if ($num > 0) |
|
| 2953 | - return 0; // Cache already loaded |
|
| 3118 | + if ($num > 0) { |
|
| 3119 | + return 0; |
|
| 3120 | + } |
|
| 3121 | + // Cache already loaded |
|
| 2954 | 3122 | |
| 2955 | 3123 | dol_syslog(__METHOD__, LOG_DEBUG); |
| 2956 | 3124 | |
@@ -3001,8 +3169,9 @@ discard block |
||
| 3001 | 3169 | dol_syslog(__METHOD__ . " selected=" . $selected . ", htmlname=" . $htmlname, LOG_DEBUG); |
| 3002 | 3170 | |
| 3003 | 3171 | print '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">'; |
| 3004 | - if ($addempty) |
|
| 3005 | - print '<option value="0"> </option>'; |
|
| 3172 | + if ($addempty) { |
|
| 3173 | + print '<option value="0"> </option>'; |
|
| 3174 | + } |
|
| 3006 | 3175 | foreach ($this->cache_availability as $id => $arrayavailability) {
|
| 3007 | 3176 | if ($selected == $id) {
|
| 3008 | 3177 | print '<option value="' . $id . '" selected>'; |
@@ -3013,8 +3182,9 @@ discard block |
||
| 3013 | 3182 | print '</option>'; |
| 3014 | 3183 | } |
| 3015 | 3184 | print '</select>'; |
| 3016 | - if ($user->admin) |
|
| 3017 | - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
|
| 3185 | + if ($user->admin) { |
|
| 3186 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 3187 | + } |
|
| 3018 | 3188 | } |
| 3019 | 3189 | |
| 3020 | 3190 | /** |
@@ -3027,8 +3197,10 @@ discard block |
||
| 3027 | 3197 | global $langs; |
| 3028 | 3198 | |
| 3029 | 3199 | $num = count($this->cache_demand_reason); |
| 3030 | - if ($num > 0) |
|
| 3031 | - return 0; // Cache already loaded |
|
| 3200 | + if ($num > 0) { |
|
| 3201 | + return 0; |
|
| 3202 | + } |
|
| 3203 | + // Cache already loaded |
|
| 3032 | 3204 | |
| 3033 | 3205 | $sql = "SELECT rowid, code, label"; |
| 3034 | 3206 | $sql .= " FROM " . MAIN_DB_PREFIX . 'c_input_reason'; |
@@ -3044,10 +3216,14 @@ discard block |
||
| 3044 | 3216 | |
| 3045 | 3217 | // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut |
| 3046 | 3218 | $label = ($obj->label != '-' ? $obj->label : ''); |
| 3047 | - if ($langs->trans("DemandReasonType" . $obj->code) != ("DemandReasonType" . $obj->code))
|
|
| 3048 | - $label = $langs->trans("DemandReasonType" . $obj->code); // So translation key DemandReasonTypeSRC_XXX will work
|
|
| 3049 | - if ($langs->trans($obj->code) != $obj->code) |
|
| 3050 | - $label = $langs->trans($obj->code); // So translation key SRC_XXX will work |
|
| 3219 | + if ($langs->trans("DemandReasonType" . $obj->code) != ("DemandReasonType" . $obj->code)) { |
|
| 3220 | + $label = $langs->trans("DemandReasonType" . $obj->code); |
|
| 3221 | + } |
|
| 3222 | + // So translation key DemandReasonTypeSRC_XXX will work |
|
| 3223 | + if ($langs->trans($obj->code) != $obj->code) { |
|
| 3224 | + $label = $langs->trans($obj->code); |
|
| 3225 | + } |
|
| 3226 | + // So translation key SRC_XXX will work |
|
| 3051 | 3227 | |
| 3052 | 3228 | $tmparray[$obj->rowid]['id'] = $obj->rowid; |
| 3053 | 3229 | $tmparray[$obj->rowid]['code'] = $obj->code; |
@@ -3059,8 +3235,7 @@ discard block |
||
| 3059 | 3235 | |
| 3060 | 3236 | unset($tmparray); |
| 3061 | 3237 | return $num; |
| 3062 | - } |
|
| 3063 | - else {
|
|
| 3238 | + } else {
|
|
| 3064 | 3239 | dol_print_error($this->db); |
| 3065 | 3240 | return -1; |
| 3066 | 3241 | } |
@@ -3083,11 +3258,13 @@ discard block |
||
| 3083 | 3258 | $this->loadCacheInputReason(); |
| 3084 | 3259 | |
| 3085 | 3260 | print '<select class="flat" id="select_' . $htmlname . '" name="' . $htmlname . '">'; |
| 3086 | - if ($addempty) |
|
| 3087 | - print '<option value="0"' . (empty($selected) ? ' selected' : '') . '> </option>'; |
|
| 3261 | + if ($addempty) { |
|
| 3262 | + print '<option value="0"' . (empty($selected) ? ' selected' : '') . '> </option>'; |
|
| 3263 | + } |
|
| 3088 | 3264 | foreach ($this->cache_demand_reason as $id => $arraydemandreason) {
|
| 3089 | - if ($arraydemandreason['code'] == $exclude) |
|
| 3090 | - continue; |
|
| 3265 | + if ($arraydemandreason['code'] == $exclude) { |
|
| 3266 | + continue; |
|
| 3267 | + } |
|
| 3091 | 3268 | |
| 3092 | 3269 | if ($selected && ($selected == $arraydemandreason['id'] || $selected == $arraydemandreason['code'])) {
|
| 3093 | 3270 | print '<option value="' . $arraydemandreason['id'] . '" selected>'; |
@@ -3099,8 +3276,9 @@ discard block |
||
| 3099 | 3276 | print '</option>'; |
| 3100 | 3277 | } |
| 3101 | 3278 | print '</select>'; |
| 3102 | - if ($user->admin) |
|
| 3103 | - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
|
| 3279 | + if ($user->admin) { |
|
| 3280 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 3281 | + } |
|
| 3104 | 3282 | } |
| 3105 | 3283 | |
| 3106 | 3284 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -3115,8 +3293,10 @@ discard block |
||
| 3115 | 3293 | global $langs; |
| 3116 | 3294 | |
| 3117 | 3295 | $num = count($this->cache_types_paiements); |
| 3118 | - if ($num > 0) |
|
| 3119 | - return $num; // Cache already loaded |
|
| 3296 | + if ($num > 0) { |
|
| 3297 | + return $num; |
|
| 3298 | + } |
|
| 3299 | + // Cache already loaded |
|
| 3120 | 3300 | |
| 3121 | 3301 | dol_syslog(__METHOD__, LOG_DEBUG); |
| 3122 | 3302 | |
@@ -3177,12 +3357,14 @@ discard block |
||
| 3177 | 3357 | $this->load_cache_conditions_paiements(); |
| 3178 | 3358 | |
| 3179 | 3359 | // Set default value if not already set by caller |
| 3180 | - if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID)) |
|
| 3181 | - $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID; |
|
| 3360 | + if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID)) { |
|
| 3361 | + $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID; |
|
| 3362 | + } |
|
| 3182 | 3363 | |
| 3183 | 3364 | print '<select id="' . $htmlname . '" class="flat selectpaymentterms' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '">'; |
| 3184 | - if ($addempty) |
|
| 3185 | - print '<option value="0"> </option>'; |
|
| 3365 | + if ($addempty) { |
|
| 3366 | + print '<option value="0"> </option>'; |
|
| 3367 | + } |
|
| 3186 | 3368 | foreach ($this->cache_conditions_paiements as $id => $arrayconditions) {
|
| 3187 | 3369 | if ($selected == $id) {
|
| 3188 | 3370 | print '<option value="' . $id . '" selected>'; |
@@ -3193,8 +3375,9 @@ discard block |
||
| 3193 | 3375 | print '</option>'; |
| 3194 | 3376 | } |
| 3195 | 3377 | print '</select>'; |
| 3196 | - if ($user->admin && empty($noinfoadmin)) |
|
| 3197 | - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
|
| 3378 | + if ($user->admin && empty($noinfoadmin)) { |
|
| 3379 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 3380 | + } |
|
| 3198 | 3381 | } |
| 3199 | 3382 | |
| 3200 | 3383 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -3220,59 +3403,68 @@ discard block |
||
| 3220 | 3403 | dol_syslog(__METHOD__ . " " . $selected . ", " . $htmlname . ", " . $filtertype . ", " . $format, LOG_DEBUG); |
| 3221 | 3404 | |
| 3222 | 3405 | $filterarray = array(); |
| 3223 | - if ($filtertype == 'CRDT') |
|
| 3224 | - $filterarray = array(0, 2, 3); |
|
| 3225 | - elseif ($filtertype == 'DBIT') |
|
| 3226 | - $filterarray = array(1, 2, 3); |
|
| 3227 | - elseif ($filtertype != '' && $filtertype != '-1') |
|
| 3228 | - $filterarray = explode(',', $filtertype);
|
|
| 3406 | + if ($filtertype == 'CRDT') { |
|
| 3407 | + $filterarray = array(0, 2, 3); |
|
| 3408 | + } elseif ($filtertype == 'DBIT') { |
|
| 3409 | + $filterarray = array(1, 2, 3); |
|
| 3410 | + } elseif ($filtertype != '' && $filtertype != '-1') { |
|
| 3411 | + $filterarray = explode(',', $filtertype); |
|
| 3412 | + } |
|
| 3229 | 3413 | |
| 3230 | 3414 | $this->load_cache_types_paiements(); |
| 3231 | 3415 | |
| 3232 | 3416 | print '<select id="select' . $htmlname . '" class="flat selectpaymenttypes' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '">'; |
| 3233 | - if ($empty) |
|
| 3234 | - print '<option value=""> </option>'; |
|
| 3417 | + if ($empty) { |
|
| 3418 | + print '<option value=""> </option>'; |
|
| 3419 | + } |
|
| 3235 | 3420 | foreach ($this->cache_types_paiements as $id => $arraytypes) {
|
| 3236 | 3421 | // If not good status |
| 3237 | - if ($active >= 0 && $arraytypes['active'] != $active) |
|
| 3238 | - continue; |
|
| 3422 | + if ($active >= 0 && $arraytypes['active'] != $active) { |
|
| 3423 | + continue; |
|
| 3424 | + } |
|
| 3239 | 3425 | |
| 3240 | 3426 | // On passe si on a demande de filtrer sur des modes de paiments particuliers |
| 3241 | - if (count($filterarray) && !in_array($arraytypes['type'], $filterarray)) |
|
| 3242 | - continue; |
|
| 3427 | + if (count($filterarray) && !in_array($arraytypes['type'], $filterarray)) { |
|
| 3428 | + continue; |
|
| 3429 | + } |
|
| 3243 | 3430 | |
| 3244 | 3431 | // We discard empty line if showempty is on because an empty line has already been output. |
| 3245 | - if ($empty && empty($arraytypes['code'])) |
|
| 3246 | - continue; |
|
| 3247 | - |
|
| 3248 | - if ($format == 0) |
|
| 3249 | - print '<option value="' . $id . '"'; |
|
| 3250 | - elseif ($format == 1) |
|
| 3251 | - print '<option value="' . $arraytypes['code'] . '"'; |
|
| 3252 | - elseif ($format == 2) |
|
| 3253 | - print '<option value="' . $arraytypes['code'] . '"'; |
|
| 3254 | - elseif ($format == 3) |
|
| 3255 | - print '<option value="' . $id . '"'; |
|
| 3432 | + if ($empty && empty($arraytypes['code'])) { |
|
| 3433 | + continue; |
|
| 3434 | + } |
|
| 3435 | + |
|
| 3436 | + if ($format == 0) { |
|
| 3437 | + print '<option value="' . $id . '"'; |
|
| 3438 | + } elseif ($format == 1) { |
|
| 3439 | + print '<option value="' . $arraytypes['code'] . '"'; |
|
| 3440 | + } elseif ($format == 2) { |
|
| 3441 | + print '<option value="' . $arraytypes['code'] . '"'; |
|
| 3442 | + } elseif ($format == 3) { |
|
| 3443 | + print '<option value="' . $id . '"'; |
|
| 3444 | + } |
|
| 3256 | 3445 | // Si selected est text, on compare avec code, sinon avec id |
| 3257 | - if (preg_match('/[a-z]/i', $selected) && $selected == $arraytypes['code'])
|
|
| 3258 | - print ' selected'; |
|
| 3259 | - elseif ($selected == $id) |
|
| 3260 | - print ' selected'; |
|
| 3446 | + if (preg_match('/[a-z]/i', $selected) && $selected == $arraytypes['code']) { |
|
| 3447 | + print ' selected'; |
|
| 3448 | + } elseif ($selected == $id) { |
|
| 3449 | + print ' selected'; |
|
| 3450 | + } |
|
| 3261 | 3451 | print '>'; |
| 3262 | - if ($format == 0) |
|
| 3263 | - $value = ($maxlength ? dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']); |
|
| 3264 | - elseif ($format == 1) |
|
| 3265 | - $value = $arraytypes['code']; |
|
| 3266 | - elseif ($format == 2) |
|
| 3267 | - $value = ($maxlength ? dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']); |
|
| 3268 | - elseif ($format == 3) |
|
| 3269 | - $value = $arraytypes['code']; |
|
| 3452 | + if ($format == 0) { |
|
| 3453 | + $value = ($maxlength ? dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']); |
|
| 3454 | + } elseif ($format == 1) { |
|
| 3455 | + $value = $arraytypes['code']; |
|
| 3456 | + } elseif ($format == 2) { |
|
| 3457 | + $value = ($maxlength ? dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']); |
|
| 3458 | + } elseif ($format == 3) { |
|
| 3459 | + $value = $arraytypes['code']; |
|
| 3460 | + } |
|
| 3270 | 3461 | print $value ? $value : ' '; |
| 3271 | 3462 | print '</option>'; |
| 3272 | 3463 | } |
| 3273 | 3464 | print '</select>'; |
| 3274 | - if ($user->admin && !$noadmininfo) |
|
| 3275 | - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
|
| 3465 | + if ($user->admin && !$noadmininfo) { |
|
| 3466 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 3467 | + } |
|
| 3276 | 3468 | } |
| 3277 | 3469 | |
| 3278 | 3470 | /** |
@@ -3326,8 +3518,9 @@ discard block |
||
| 3326 | 3518 | $sql = "SELECT rowid, code, libelle as label"; |
| 3327 | 3519 | $sql .= " FROM " . MAIN_DB_PREFIX . "c_shipment_mode"; |
| 3328 | 3520 | $sql .= " WHERE active > 0"; |
| 3329 | - if ($filtre) |
|
| 3330 | - $sql .= " AND " . $filtre; |
|
| 3521 | + if ($filtre) { |
|
| 3522 | + $sql .= " AND " . $filtre; |
|
| 3523 | + } |
|
| 3331 | 3524 | $sql .= " ORDER BY libelle ASC"; |
| 3332 | 3525 | |
| 3333 | 3526 | dol_syslog(get_class($this) . "::selectShippingMode", LOG_DEBUG); |
@@ -3352,8 +3545,9 @@ discard block |
||
| 3352 | 3545 | $i++; |
| 3353 | 3546 | } |
| 3354 | 3547 | print "</select>"; |
| 3355 | - if ($user->admin) |
|
| 3356 | - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
|
| 3548 | + if ($user->admin) { |
|
| 3549 | + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 3550 | + } |
|
| 3357 | 3551 | } else {
|
| 3358 | 3552 | print $langs->trans("NoShippingMethodDefined");
|
| 3359 | 3553 | } |
@@ -3466,8 +3660,9 @@ discard block |
||
| 3466 | 3660 | |
| 3467 | 3661 | $resql = $this->db->query($sql); |
| 3468 | 3662 | if ($resql && $this->db->num_rows($resql) > 0) {
|
| 3469 | - if ($showempty) |
|
| 3470 | - $return .= '<option value="none"></option>'; |
|
| 3663 | + if ($showempty) { |
|
| 3664 | + $return .= '<option value="none"></option>'; |
|
| 3665 | + } |
|
| 3471 | 3666 | |
| 3472 | 3667 | while ($res = $this->db->fetch_object($resql)) {
|
| 3473 | 3668 | $unitLabel = $res->label; |
@@ -3510,10 +3705,12 @@ discard block |
||
| 3510 | 3705 | $sql = "SELECT rowid, label, bank, clos as status, currency_code"; |
| 3511 | 3706 | $sql .= " FROM " . MAIN_DB_PREFIX . "bank_account"; |
| 3512 | 3707 | $sql .= " WHERE entity IN (" . getEntity('bank_account') . ")";
|
| 3513 | - if ($statut != 2) |
|
| 3514 | - $sql .= " AND clos = '" . $statut . "'"; |
|
| 3515 | - if ($filtre) |
|
| 3516 | - $sql .= " AND " . $filtre; |
|
| 3708 | + if ($statut != 2) { |
|
| 3709 | + $sql .= " AND clos = '" . $statut . "'"; |
|
| 3710 | + } |
|
| 3711 | + if ($filtre) { |
|
| 3712 | + $sql .= " AND " . $filtre; |
|
| 3713 | + } |
|
| 3517 | 3714 | $sql .= " ORDER BY label"; |
| 3518 | 3715 | |
| 3519 | 3716 | dol_syslog(get_class($this) . "::select_comptes", LOG_DEBUG); |
@@ -3535,23 +3732,24 @@ discard block |
||
| 3535 | 3732 | print '<option value="' . $obj->rowid . '">'; |
| 3536 | 3733 | } |
| 3537 | 3734 | print trim($obj->label); |
| 3538 | - if ($showcurrency) |
|
| 3539 | - print ' (' . $obj->currency_code . ')';
|
|
| 3540 | - if ($statut == 2 && $obj->status == 1) |
|
| 3541 | - print ' (' . $langs->trans("Closed") . ')';
|
|
| 3735 | + if ($showcurrency) { |
|
| 3736 | + print ' (' . $obj->currency_code . ')'; |
|
| 3737 | + } |
|
| 3738 | + if ($statut == 2 && $obj->status == 1) { |
|
| 3739 | + print ' (' . $langs->trans("Closed") . ')'; |
|
| 3740 | + } |
|
| 3542 | 3741 | print '</option>'; |
| 3543 | 3742 | $i++; |
| 3544 | 3743 | } |
| 3545 | 3744 | print "</select>"; |
| 3745 | + } else {
|
|
| 3746 | + if ($statut == 0) { |
|
| 3747 | + print '<span class="opacitymedium">' . $langs->trans("NoActiveBankAccountDefined") . '</span>'; |
|
| 3748 | + } else { |
|
| 3749 | + print '<span class="opacitymedium">' . $langs->trans("NoBankAccountFound") . '</span>'; |
|
| 3750 | + } |
|
| 3546 | 3751 | } |
| 3547 | - else {
|
|
| 3548 | - if ($statut == 0) |
|
| 3549 | - print '<span class="opacitymedium">' . $langs->trans("NoActiveBankAccountDefined") . '</span>';
|
|
| 3550 | - else |
|
| 3551 | - print '<span class="opacitymedium">' . $langs->trans("NoBankAccountFound") . '</span>';
|
|
| 3552 | - } |
|
| 3553 | - } |
|
| 3554 | - else {
|
|
| 3752 | + } else {
|
|
| 3555 | 3753 | dol_print_error($this->db); |
| 3556 | 3754 | } |
| 3557 | 3755 | |
@@ -3575,8 +3773,9 @@ discard block |
||
| 3575 | 3773 | print '<input type="hidden" name="action" value="setbankaccount">'; |
| 3576 | 3774 | print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; |
| 3577 | 3775 | $nbaccountfound = $this->select_comptes($selected, $htmlname, 0, '', $addempty); |
| 3578 | - if ($nbaccountfound > 0) |
|
| 3579 | - print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
|
|
| 3776 | + if ($nbaccountfound > 0) { |
|
| 3777 | + print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">'; |
|
| 3778 | + } |
|
| 3580 | 3779 | print '</form>'; |
| 3581 | 3780 | } else {
|
| 3582 | 3781 | |
@@ -3586,8 +3785,9 @@ discard block |
||
| 3586 | 3785 | require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; |
| 3587 | 3786 | $bankstatic = new Account($this->db); |
| 3588 | 3787 | $result = $bankstatic->fetch($selected); |
| 3589 | - if ($result) |
|
| 3590 | - print $bankstatic->getNomUrl(1); |
|
| 3788 | + if ($result) { |
|
| 3789 | + print $bankstatic->getNomUrl(1); |
|
| 3790 | + } |
|
| 3591 | 3791 | } else {
|
| 3592 | 3792 | print " "; |
| 3593 | 3793 | } |
@@ -3633,15 +3833,16 @@ discard block |
||
| 3633 | 3833 | $i = 0; |
| 3634 | 3834 | while ($i < $num) {
|
| 3635 | 3835 | $objp = $this->db->fetch_object($result); |
| 3636 | - if ($objp) |
|
| 3637 | - $cate_arbo[$objp->rowid] = array('id' => $objp->rowid, 'fulllabel' => $objp->label);
|
|
| 3836 | + if ($objp) { |
|
| 3837 | + $cate_arbo[$objp->rowid] = array('id' => $objp->rowid, 'fulllabel' => $objp->label); |
|
| 3838 | + } |
|
| 3638 | 3839 | $i++; |
| 3639 | 3840 | } |
| 3640 | 3841 | $this->db->free($result); |
| 3641 | - } else |
|
| 3642 | - dol_print_error($this->db); |
|
| 3643 | - } |
|
| 3644 | - else {
|
|
| 3842 | + } else { |
|
| 3843 | + dol_print_error($this->db); |
|
| 3844 | + } |
|
| 3845 | + } else {
|
|
| 3645 | 3846 | $cat = new Categorie($this->db); |
| 3646 | 3847 | $cate_arbo = $cat->get_full_arbo($type, $excludeafterid); |
| 3647 | 3848 | } |
@@ -3649,9 +3850,9 @@ discard block |
||
| 3649 | 3850 | $output = '<select class="flat" name="' . $htmlname . '" id="' . $htmlname . '">'; |
| 3650 | 3851 | $outarray = array(); |
| 3651 | 3852 | if (is_array($cate_arbo)) {
|
| 3652 | - if (!count($cate_arbo)) |
|
| 3653 | - $output .= '<option value="-1" disabled>' . $langs->trans("NoCategoriesDefined") . '</option>';
|
|
| 3654 | - else {
|
|
| 3853 | + if (!count($cate_arbo)) { |
|
| 3854 | + $output .= '<option value="-1" disabled>' . $langs->trans("NoCategoriesDefined") . '</option>'; |
|
| 3855 | + } else {
|
|
| 3655 | 3856 | $output .= '<option value="-1"> </option>'; |
| 3656 | 3857 | foreach ($cate_arbo as $key => $value) {
|
| 3657 | 3858 | if ($cate_arbo[$key]['id'] == $selected || ($selected == 'auto' && count($cate_arbo) == 1)) {
|
@@ -3668,8 +3869,9 @@ discard block |
||
| 3668 | 3869 | $output .= '</select>'; |
| 3669 | 3870 | $output .= "\n"; |
| 3670 | 3871 | |
| 3671 | - if ($outputmode) |
|
| 3672 | - return $outarray; |
|
| 3872 | + if ($outputmode) { |
|
| 3873 | + return $outarray; |
|
| 3874 | + } |
|
| 3673 | 3875 | return $output; |
| 3674 | 3876 | } |
| 3675 | 3877 | |
@@ -3733,8 +3935,9 @@ discard block |
||
| 3733 | 3935 | |
| 3734 | 3936 | // Clean parameters |
| 3735 | 3937 | $newselectedchoice = empty($selectedchoice) ? "no" : $selectedchoice; |
| 3736 | - if ($conf->browser->layout == 'phone') |
|
| 3737 | - $width = '95%'; |
|
| 3938 | + if ($conf->browser->layout == 'phone') { |
|
| 3939 | + $width = '95%'; |
|
| 3940 | + } |
|
| 3738 | 3941 | |
| 3739 | 3942 | if (is_array($formquestion) && !empty($formquestion)) {
|
| 3740 | 3943 | // First add hidden fields and value |
@@ -3748,8 +3951,9 @@ discard block |
||
| 3748 | 3951 | |
| 3749 | 3952 | // Now add questions |
| 3750 | 3953 | $more .= '<table class="paddingtopbottomonly" width="100%">' . "\n"; |
| 3751 | - if (!empty($formquestion['text'])) |
|
| 3752 | - $more .= '<tr><td colspan="2">' . $formquestion['text'] . '</td></tr>' . "\n"; |
|
| 3954 | + if (!empty($formquestion['text'])) { |
|
| 3955 | + $more .= '<tr><td colspan="2">' . $formquestion['text'] . '</td></tr>' . "\n"; |
|
| 3956 | + } |
|
| 3753 | 3957 | foreach ($formquestion as $key => $input) {
|
| 3754 | 3958 | if (is_array($input) && !empty($input)) {
|
| 3755 | 3959 | $size = (!empty($input['size']) ? ' size="' . $input['size'] . '"' : ''); |
@@ -3762,42 +3966,45 @@ discard block |
||
| 3762 | 3966 | $more .= '<tr><td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '>' . $input['label'] . '</td><td align="left"><input type="password" class="flat' . $morecss . '" id="' . $input['name'] . '" name="' . $input['name'] . '"' . $size . ' value="' . $input['value'] . '"' . $moreattr . ' /></td></tr>' . "\n";
|
| 3763 | 3967 | } elseif ($input['type'] == 'select') {
|
| 3764 | 3968 | $more .= '<tr><td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '>';
|
| 3765 | - if (!empty($input['label'])) |
|
| 3766 | - $more .= $input['label'] . '</td><td class="tdtop" align="left">'; |
|
| 3969 | + if (!empty($input['label'])) { |
|
| 3970 | + $more .= $input['label'] . '</td><td class="tdtop" align="left">'; |
|
| 3971 | + } |
|
| 3767 | 3972 | $more .= $this->selectarray($input['name'], $input['values'], $input['default'], 1, 0, 0, $moreattr, 0, 0, 0, '', $morecss); |
| 3768 | 3973 | $more .= '</td></tr>' . "\n"; |
| 3769 | - } |
|
| 3770 | - elseif ($input['type'] == 'checkbox') {
|
|
| 3974 | + } elseif ($input['type'] == 'checkbox') {
|
|
| 3771 | 3975 | $more .= '<tr>'; |
| 3772 | 3976 | $more .= '<td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '>' . $input['label'] . ' </td><td align="left">';
|
| 3773 | 3977 | $more .= '<input type="checkbox" class="flat' . $morecss . '" id="' . $input['name'] . '" name="' . $input['name'] . '"' . $moreattr; |
| 3774 | - if (!is_bool($input['value']) && $input['value'] != 'false' && $input['value'] != '0') |
|
| 3775 | - $more .= ' checked'; |
|
| 3776 | - if (is_bool($input['value']) && $input['value']) |
|
| 3777 | - $more .= ' checked'; |
|
| 3778 | - if (isset($input['disabled'])) |
|
| 3779 | - $more .= ' disabled'; |
|
| 3978 | + if (!is_bool($input['value']) && $input['value'] != 'false' && $input['value'] != '0') { |
|
| 3979 | + $more .= ' checked'; |
|
| 3980 | + } |
|
| 3981 | + if (is_bool($input['value']) && $input['value']) { |
|
| 3982 | + $more .= ' checked'; |
|
| 3983 | + } |
|
| 3984 | + if (isset($input['disabled'])) { |
|
| 3985 | + $more .= ' disabled'; |
|
| 3986 | + } |
|
| 3780 | 3987 | $more .= ' /></td>'; |
| 3781 | 3988 | $more .= '</tr>' . "\n"; |
| 3782 | - } |
|
| 3783 | - elseif ($input['type'] == 'radio') {
|
|
| 3989 | + } elseif ($input['type'] == 'radio') {
|
|
| 3784 | 3990 | $i = 0; |
| 3785 | 3991 | foreach ($input['values'] as $selkey => $selval) {
|
| 3786 | 3992 | $more .= '<tr>'; |
| 3787 | - if ($i == 0) |
|
| 3788 | - $more .= '<td' . (empty($input['tdclass']) ? ' class="tdtop"' : (' class="tdtop ' . $input['tdclass'] . '"')) . '>' . $input['label'] . '</td>';
|
|
| 3789 | - else |
|
| 3790 | - $more .= '<td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '> </td>';
|
|
| 3993 | + if ($i == 0) { |
|
| 3994 | + $more .= '<td' . (empty($input['tdclass']) ? ' class="tdtop"' : (' class="tdtop ' . $input['tdclass'] . '"')) . '>' . $input['label'] . '</td>'; |
|
| 3995 | + } else { |
|
| 3996 | + $more .= '<td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '> </td>'; |
|
| 3997 | + } |
|
| 3791 | 3998 | $more .= '<td><input type="radio" class="flat' . $morecss . '" id="' . $input['name'] . '" name="' . $input['name'] . '" value="' . $selkey . '"' . $moreattr; |
| 3792 | - if ($input['disabled']) |
|
| 3793 | - $more .= ' disabled'; |
|
| 3999 | + if ($input['disabled']) { |
|
| 4000 | + $more .= ' disabled'; |
|
| 4001 | + } |
|
| 3794 | 4002 | $more .= ' /> '; |
| 3795 | 4003 | $more .= $selval; |
| 3796 | 4004 | $more .= '</td></tr>' . "\n"; |
| 3797 | 4005 | $i++; |
| 3798 | 4006 | } |
| 3799 | - } |
|
| 3800 | - elseif ($input['type'] == 'date') {
|
|
| 4007 | + } elseif ($input['type'] == 'date') {
|
|
| 3801 | 4008 | $more .= '<tr><td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '>' . $input['label'] . '</td>';
|
| 3802 | 4009 | $more .= '<td align="left">'; |
| 3803 | 4010 | $more .= $this->selectDate($input['value'], $input['name'], 0, 0, 0, '', 1, 0); |
@@ -3809,13 +4016,12 @@ discard block |
||
| 3809 | 4016 | $formquestion[] = array('name' => $input['name'] . 'min');
|
| 3810 | 4017 | } elseif ($input['type'] == 'other') {
|
| 3811 | 4018 | $more .= '<tr><td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '>';
|
| 3812 | - if (!empty($input['label'])) |
|
| 3813 | - $more .= $input['label'] . '</td><td align="left">'; |
|
| 4019 | + if (!empty($input['label'])) { |
|
| 4020 | + $more .= $input['label'] . '</td><td align="left">'; |
|
| 4021 | + } |
|
| 3814 | 4022 | $more .= $input['value']; |
| 3815 | 4023 | $more .= '</td></tr>' . "\n"; |
| 3816 | - } |
|
| 3817 | - |
|
| 3818 | - elseif ($input['type'] == 'onecolumn') {
|
|
| 4024 | + } elseif ($input['type'] == 'onecolumn') {
|
|
| 3819 | 4025 | $more .= '<tr><td colspan="2" align="left">'; |
| 3820 | 4026 | $more .= $input['value']; |
| 3821 | 4027 | $more .= '</td></tr>' . "\n"; |
@@ -3828,10 +4034,12 @@ discard block |
||
| 3828 | 4034 | // JQUI method dialog is broken with jmobile, we use standard HTML. |
| 3829 | 4035 | // Note: When using dol_use_jmobile or no js, you must also check code for button use a GET url with action=xxx and check that you also output the confirm code when action=xxx |
| 3830 | 4036 | // See page product/card.php for example |
| 3831 | - if (!empty($conf->dol_use_jmobile)) |
|
| 3832 | - $useajax = 0; |
|
| 3833 | - if (empty($conf->use_javascript_ajax)) |
|
| 3834 | - $useajax = 0; |
|
| 4037 | + if (!empty($conf->dol_use_jmobile)) { |
|
| 4038 | + $useajax = 0; |
|
| 4039 | + } |
|
| 4040 | + if (empty($conf->use_javascript_ajax)) { |
|
| 4041 | + $useajax = 0; |
|
| 4042 | + } |
|
| 3835 | 4043 | |
| 3836 | 4044 | if ($useajax) {
|
| 3837 | 4045 | $autoOpen = true; |
@@ -3849,10 +4057,12 @@ discard block |
||
| 3849 | 4057 | if (is_array($formquestion)) {
|
| 3850 | 4058 | foreach ($formquestion as $key => $input) {
|
| 3851 | 4059 | //print "xx ".$key." rr ".is_array($input)."<br>\n"; |
| 3852 | - if (is_array($input) && isset($input['name'])) |
|
| 3853 | - array_push($inputok, $input['name']); |
|
| 3854 | - if (isset($input['inputko']) && $input['inputko'] == 1) |
|
| 3855 | - array_push($inputko, $input['name']); |
|
| 4060 | + if (is_array($input) && isset($input['name'])) { |
|
| 4061 | + array_push($inputok, $input['name']); |
|
| 4062 | + } |
|
| 4063 | + if (isset($input['inputko']) && $input['inputko'] == 1) { |
|
| 4064 | + array_push($inputko, $input['name']); |
|
| 4065 | + } |
|
| 3856 | 4066 | } |
| 3857 | 4067 | } |
| 3858 | 4068 | // Show JQuery confirm box. Note that global var $useglobalvars is used inside this template |
@@ -3937,12 +4147,14 @@ discard block |
||
| 3937 | 4147 | } else {
|
| 3938 | 4148 | $formconfirm .= "\n<!-- begin formconfirm page=" . $page . " -->\n"; |
| 3939 | 4149 | |
| 3940 | - if (empty($disableformtag)) |
|
| 3941 | - $formconfirm .= '<form method="POST" action="' . $page . '" class="notoptoleftroright">' . "\n"; |
|
| 4150 | + if (empty($disableformtag)) { |
|
| 4151 | + $formconfirm .= '<form method="POST" action="' . $page . '" class="notoptoleftroright">' . "\n"; |
|
| 4152 | + } |
|
| 3942 | 4153 | |
| 3943 | 4154 | $formconfirm .= '<input type="hidden" name="action" value="' . $action . '">' . "\n"; |
| 3944 | - if (empty($disableformtag)) |
|
| 3945 | - $formconfirm .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">' . "\n"; |
|
| 4155 | + if (empty($disableformtag)) { |
|
| 4156 | + $formconfirm .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">' . "\n"; |
|
| 4157 | + } |
|
| 3946 | 4158 | |
| 3947 | 4159 | $formconfirm .= '<table width="100%" class="valid">' . "\n"; |
| 3948 | 4160 | |
@@ -3967,8 +4179,9 @@ discard block |
||
| 3967 | 4179 | |
| 3968 | 4180 | $formconfirm .= '</table>' . "\n"; |
| 3969 | 4181 | |
| 3970 | - if (empty($disableformtag)) |
|
| 3971 | - $formconfirm .= "</form>\n"; |
|
| 4182 | + if (empty($disableformtag)) { |
|
| 4183 | + $formconfirm .= "</form>\n"; |
|
| 4184 | + } |
|
| 3972 | 4185 | $formconfirm .= '<br>'; |
| 3973 | 4186 | |
| 3974 | 4187 | $formconfirm .= "<!-- end formconfirm -->\n"; |
@@ -4158,14 +4371,16 @@ discard block |
||
| 4158 | 4371 | $ret .= '<td align="left"><input type="submit" class="button" value="' . $langs->trans("Modify") . '"></td>';
|
| 4159 | 4372 | $ret .= '</tr></table></form>'; |
| 4160 | 4373 | } else {
|
| 4161 | - if ($displayhour) |
|
| 4162 | - $ret .= dol_print_date($selected, 'dayhour'); |
|
| 4163 | - else |
|
| 4164 | - $ret .= dol_print_date($selected, 'day'); |
|
| 4374 | + if ($displayhour) { |
|
| 4375 | + $ret .= dol_print_date($selected, 'dayhour'); |
|
| 4376 | + } else { |
|
| 4377 | + $ret .= dol_print_date($selected, 'day'); |
|
| 4378 | + } |
|
| 4165 | 4379 | } |
| 4166 | 4380 | |
| 4167 | - if (empty($nooutput)) |
|
| 4168 | - print $ret; |
|
| 4381 | + if (empty($nooutput)) { |
|
| 4382 | + print $ret; |
|
| 4383 | + } |
|
| 4169 | 4384 | return $ret; |
| 4170 | 4385 | } |
| 4171 | 4386 | |
@@ -4291,10 +4506,10 @@ discard block |
||
| 4291 | 4506 | } else {
|
| 4292 | 4507 | if (!empty($rate)) {
|
| 4293 | 4508 | print price($rate, 1, $langs, 1, 0); |
| 4294 | - if ($currency && $rate != 1) |
|
| 4295 | - print ' (' . price($rate, 1, $langs, 1, 0) . ' ' . $currency . ' = 1 ' . $conf->currency . ')';
|
|
| 4296 | - } |
|
| 4297 | - else {
|
|
| 4509 | + if ($currency && $rate != 1) { |
|
| 4510 | + print ' (' . price($rate, 1, $langs, 1, 0) . ' ' . $currency . ' = 1 ' . $conf->currency . ')'; |
|
| 4511 | + } |
|
| 4512 | + } else {
|
|
| 4298 | 4513 | print 1; |
| 4299 | 4514 | } |
| 4300 | 4515 | } |
@@ -4327,34 +4542,41 @@ discard block |
||
| 4327 | 4542 | print '<div class="inline-block">'; |
| 4328 | 4543 | if (!empty($discount_type)) {
|
| 4329 | 4544 | if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
| 4330 | - if (!$filter || $filter == "fk_invoice_supplier_source IS NULL") |
|
| 4331 | - $translationKey = 'HasAbsoluteDiscountFromSupplier'; // If we want deposit to be substracted to payments only and not to total of final invoice |
|
| 4332 | - else |
|
| 4333 | - $translationKey = 'HasCreditNoteFromSupplier'; |
|
| 4334 | - } |
|
| 4335 | - else {
|
|
| 4336 | - if (!$filter || $filter == "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") |
|
| 4337 | - $translationKey = 'HasAbsoluteDiscountFromSupplier'; |
|
| 4338 | - else |
|
| 4339 | - $translationKey = 'HasCreditNoteFromSupplier'; |
|
| 4545 | + if (!$filter || $filter == "fk_invoice_supplier_source IS NULL") { |
|
| 4546 | + $translationKey = 'HasAbsoluteDiscountFromSupplier'; |
|
| 4547 | + } |
|
| 4548 | + // If we want deposit to be substracted to payments only and not to total of final invoice |
|
| 4549 | + else { |
|
| 4550 | + $translationKey = 'HasCreditNoteFromSupplier'; |
|
| 4551 | + } |
|
| 4552 | + } else {
|
|
| 4553 | + if (!$filter || $filter == "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") { |
|
| 4554 | + $translationKey = 'HasAbsoluteDiscountFromSupplier'; |
|
| 4555 | + } else { |
|
| 4556 | + $translationKey = 'HasCreditNoteFromSupplier'; |
|
| 4557 | + } |
|
| 4340 | 4558 | } |
| 4341 | 4559 | } else {
|
| 4342 | 4560 | if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
| 4343 | - if (!$filter || $filter == "fk_facture_source IS NULL") |
|
| 4344 | - $translationKey = 'CompanyHasAbsoluteDiscount'; // If we want deposit to be substracted to payments only and not to total of final invoice |
|
| 4345 | - else |
|
| 4346 | - $translationKey = 'CompanyHasCreditNote'; |
|
| 4347 | - } |
|
| 4348 | - else {
|
|
| 4349 | - if (!$filter || $filter == "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") |
|
| 4350 | - $translationKey = 'CompanyHasAbsoluteDiscount'; |
|
| 4351 | - else |
|
| 4352 | - $translationKey = 'CompanyHasCreditNote'; |
|
| 4561 | + if (!$filter || $filter == "fk_facture_source IS NULL") { |
|
| 4562 | + $translationKey = 'CompanyHasAbsoluteDiscount'; |
|
| 4563 | + } |
|
| 4564 | + // If we want deposit to be substracted to payments only and not to total of final invoice |
|
| 4565 | + else { |
|
| 4566 | + $translationKey = 'CompanyHasCreditNote'; |
|
| 4567 | + } |
|
| 4568 | + } else {
|
|
| 4569 | + if (!$filter || $filter == "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") { |
|
| 4570 | + $translationKey = 'CompanyHasAbsoluteDiscount'; |
|
| 4571 | + } else { |
|
| 4572 | + $translationKey = 'CompanyHasCreditNote'; |
|
| 4573 | + } |
|
| 4353 | 4574 | } |
| 4354 | 4575 | } |
| 4355 | 4576 | print $langs->trans($translationKey, price($amount, 0, $langs, 0, 0, -1, $conf->currency)); |
| 4356 | - if (empty($hidelist)) |
|
| 4357 | - print ': '; |
|
| 4577 | + if (empty($hidelist)) { |
|
| 4578 | + print ': '; |
|
| 4579 | + } |
|
| 4358 | 4580 | print '</div>'; |
| 4359 | 4581 | if (empty($hidelist)) {
|
| 4360 | 4582 | print '<div class="inline-block" style="padding-right: 10px">'; |
@@ -4364,15 +4586,18 @@ discard block |
||
| 4364 | 4586 | } else {
|
| 4365 | 4587 | $newfilter .= ' AND fk_facture IS NULL AND fk_facture_line IS NULL'; // Customer discounts available |
| 4366 | 4588 | } |
| 4367 | - if ($filter) |
|
| 4368 | - $newfilter .= ' AND (' . $filter . ')';
|
|
| 4589 | + if ($filter) { |
|
| 4590 | + $newfilter .= ' AND (' . $filter . ')'; |
|
| 4591 | + } |
|
| 4369 | 4592 | $nbqualifiedlines = $this->select_remises($selected, $htmlname, $newfilter, $socid, $maxvalue); |
| 4370 | 4593 | if ($nbqualifiedlines > 0) {
|
| 4371 | 4594 | print ' <input type="submit" class="button" value="' . dol_escape_htmltag($langs->trans("UseLine")) . '"';
|
| 4372 | - if (!empty($discount_type) && $filter && $filter != "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") |
|
| 4373 | - print ' title="' . $langs->trans("UseCreditNoteInInvoicePayment") . '"';
|
|
| 4374 | - if (empty($discount_type) && $filter && $filter != "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") |
|
| 4375 | - print ' title="' . $langs->trans("UseCreditNoteInInvoicePayment") . '"';
|
|
| 4595 | + if (!empty($discount_type) && $filter && $filter != "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") { |
|
| 4596 | + print ' title="' . $langs->trans("UseCreditNoteInInvoicePayment") . '"'; |
|
| 4597 | + } |
|
| 4598 | + if (empty($discount_type) && $filter && $filter != "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") { |
|
| 4599 | + print ' title="' . $langs->trans("UseCreditNoteInInvoicePayment") . '"'; |
|
| 4600 | + } |
|
| 4376 | 4601 | |
| 4377 | 4602 | print '>'; |
| 4378 | 4603 | } |
@@ -4473,10 +4698,11 @@ discard block |
||
| 4473 | 4698 | } |
| 4474 | 4699 | } |
| 4475 | 4700 | |
| 4476 | - if ($nooutput) |
|
| 4477 | - return $out; |
|
| 4478 | - else |
|
| 4479 | - print $out; |
|
| 4701 | + if ($nooutput) { |
|
| 4702 | + return $out; |
|
| 4703 | + } else { |
|
| 4704 | + print $out; |
|
| 4705 | + } |
|
| 4480 | 4706 | } |
| 4481 | 4707 | |
| 4482 | 4708 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -4509,8 +4735,10 @@ discard block |
||
| 4509 | 4735 | |
| 4510 | 4736 | $out = ''; |
| 4511 | 4737 | |
| 4512 | - if ($selected == 'euro' || $selected == 'euros') |
|
| 4513 | - $selected = 'EUR'; // Pour compatibilite |
|
| 4738 | + if ($selected == 'euro' || $selected == 'euros') { |
|
| 4739 | + $selected = 'EUR'; |
|
| 4740 | + } |
|
| 4741 | + // Pour compatibilite |
|
| 4514 | 4742 | |
| 4515 | 4743 | $out .= '<select class="flat maxwidth200onsmartphone minwidth300" name="' . $htmlname . '" id="' . $htmlname . '">'; |
| 4516 | 4744 | foreach ($langs->cache_currencies as $code_iso => $currency) {
|
@@ -4524,8 +4752,9 @@ discard block |
||
| 4524 | 4752 | $out .= '</option>'; |
| 4525 | 4753 | } |
| 4526 | 4754 | $out .= '</select>'; |
| 4527 | - if ($user->admin) |
|
| 4528 | - $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
|
| 4755 | + if ($user->admin) { |
|
| 4756 | + $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 4757 | + } |
|
| 4529 | 4758 | |
| 4530 | 4759 | // Make select dynamic |
| 4531 | 4760 | include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
@@ -4554,14 +4783,16 @@ discard block |
||
| 4554 | 4783 | $sql .= " WHERE entity IN ('" . getEntity('mutlicurrency') . "')";
|
| 4555 | 4784 | $resql = $db->query($sql); |
| 4556 | 4785 | if ($resql) {
|
| 4557 | - while ($obj = $db->fetch_object($resql)) |
|
| 4558 | - $TCurrency[$obj->code] = $obj->code; |
|
| 4786 | + while ($obj = $db->fetch_object($resql)) { |
|
| 4787 | + $TCurrency[$obj->code] = $obj->code; |
|
| 4788 | + } |
|
| 4559 | 4789 | } |
| 4560 | 4790 | |
| 4561 | 4791 | $out = ''; |
| 4562 | 4792 | $out .= '<select class="flat" name="' . $htmlname . '" id="' . $htmlname . '">'; |
| 4563 | - if ($useempty) |
|
| 4564 | - $out .= '<option value=""></option>'; |
|
| 4793 | + if ($useempty) { |
|
| 4794 | + $out .= '<option value=""></option>'; |
|
| 4795 | + } |
|
| 4565 | 4796 | // If company current currency not in table, we add it into list. Should always be available. |
| 4566 | 4797 | if (!in_array($conf->currency, $TCurrency)) {
|
| 4567 | 4798 | $TCurrency[$conf->currency] = $conf->currency; |
@@ -4569,10 +4800,11 @@ discard block |
||
| 4569 | 4800 | if (count($TCurrency) > 0) {
|
| 4570 | 4801 | foreach ($langs->cache_currencies as $code_iso => $currency) {
|
| 4571 | 4802 | if (isset($TCurrency[$code_iso])) {
|
| 4572 | - if (!empty($selected) && $selected == $code_iso) |
|
| 4573 | - $out .= '<option value="' . $code_iso . '" selected="selected">'; |
|
| 4574 | - else |
|
| 4575 | - $out .= '<option value="' . $code_iso . '">'; |
|
| 4803 | + if (!empty($selected) && $selected == $code_iso) { |
|
| 4804 | + $out .= '<option value="' . $code_iso . '" selected="selected">'; |
|
| 4805 | + } else { |
|
| 4806 | + $out .= '<option value="' . $code_iso . '">'; |
|
| 4807 | + } |
|
| 4576 | 4808 | |
| 4577 | 4809 | $out .= $currency['label']; |
| 4578 | 4810 | $out .= ' (' . $langs->getCurrencySymbol($code_iso) . ')';
|
@@ -4602,8 +4834,10 @@ discard block |
||
| 4602 | 4834 | global $langs; |
| 4603 | 4835 | |
| 4604 | 4836 | $num = count($this->cache_vatrates); |
| 4605 | - if ($num > 0) |
|
| 4606 | - return $num; // Cache already loaded |
|
| 4837 | + if ($num > 0) { |
|
| 4838 | + return $num; |
|
| 4839 | + } |
|
| 4840 | + // Cache already loaded |
|
| 4607 | 4841 | |
| 4608 | 4842 | dol_syslog(__METHOD__, LOG_DEBUG); |
| 4609 | 4843 | |
@@ -4632,20 +4866,23 @@ discard block |
||
| 4632 | 4866 | $this->cache_vatrates[$i]['label'] = $obj->taux . '%' . ($obj->code ? ' (' . $obj->code . ')' : ''); // Label must contains only 0-9 , . % or *
|
| 4633 | 4867 | $this->cache_vatrates[$i]['labelallrates'] = $obj->taux . '/' . ($obj->localtax1 ? $obj->localtax1 : '0') . '/' . ($obj->localtax2 ? $obj->localtax2 : '0') . ($obj->code ? ' (' . $obj->code . ')' : ''); // Must never be used as key, only label
|
| 4634 | 4868 | $positiverates = ''; |
| 4635 | - if ($obj->taux) |
|
| 4636 | - $positiverates .= ($positiverates ? '/' : '') . $obj->taux; |
|
| 4637 | - if ($obj->localtax1) |
|
| 4638 | - $positiverates .= ($positiverates ? '/' : '') . $obj->localtax1; |
|
| 4639 | - if ($obj->localtax2) |
|
| 4640 | - $positiverates .= ($positiverates ? '/' : '') . $obj->localtax2; |
|
| 4641 | - if (empty($positiverates)) |
|
| 4642 | - $positiverates = '0'; |
|
| 4869 | + if ($obj->taux) { |
|
| 4870 | + $positiverates .= ($positiverates ? '/' : '') . $obj->taux; |
|
| 4871 | + } |
|
| 4872 | + if ($obj->localtax1) { |
|
| 4873 | + $positiverates .= ($positiverates ? '/' : '') . $obj->localtax1; |
|
| 4874 | + } |
|
| 4875 | + if ($obj->localtax2) { |
|
| 4876 | + $positiverates .= ($positiverates ? '/' : '') . $obj->localtax2; |
|
| 4877 | + } |
|
| 4878 | + if (empty($positiverates)) { |
|
| 4879 | + $positiverates = '0'; |
|
| 4880 | + } |
|
| 4643 | 4881 | $this->cache_vatrates[$i]['labelpositiverates'] = $positiverates . ($obj->code ? ' (' . $obj->code . ')' : ''); // Must never be used as key, only label
|
| 4644 | 4882 | } |
| 4645 | 4883 | |
| 4646 | 4884 | return $num; |
| 4647 | - } |
|
| 4648 | - else {
|
|
| 4885 | + } else {
|
|
| 4649 | 4886 | $this->error = '<font class="error">' . $langs->trans("ErrorNoVATRateDefinedForSellerCountry", $country_code) . '</font>';
|
| 4650 | 4887 | return -1; |
| 4651 | 4888 | } |
@@ -4749,17 +4986,19 @@ discard block |
||
| 4749 | 4986 | $defaultcode = $reg[1]; |
| 4750 | 4987 | $defaulttx = preg_replace('/\s*\(.*\)/', '', $defaulttx);
|
| 4751 | 4988 | } |
| 4752 | - if (empty($defaulttx)) |
|
| 4753 | - $defaultnpr = 0; |
|
| 4989 | + if (empty($defaulttx)) { |
|
| 4990 | + $defaultnpr = 0; |
|
| 4991 | + } |
|
| 4754 | 4992 | } |
| 4755 | 4993 | |
| 4756 | 4994 | // Si taux par defaut n'a pu etre determine, on prend dernier de la liste. |
| 4757 | 4995 | // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant |
| 4758 | 4996 | if ($defaulttx < 0 || dol_strlen($defaulttx) == 0) {
|
| 4759 | - if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) |
|
| 4760 | - $defaulttx = $this->cache_vatrates[$num - 1]['txtva']; |
|
| 4761 | - else |
|
| 4762 | - $defaulttx = ($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS == 'none' ? '' : $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS); |
|
| 4997 | + if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) { |
|
| 4998 | + $defaulttx = $this->cache_vatrates[$num - 1]['txtva']; |
|
| 4999 | + } else { |
|
| 5000 | + $defaulttx = ($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS == 'none' ? '' : $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS); |
|
| 5001 | + } |
|
| 4763 | 5002 | } |
| 4764 | 5003 | |
| 4765 | 5004 | // Disabled if seller is not subject to VAT |
@@ -4773,22 +5012,26 @@ discard block |
||
| 4773 | 5012 | } |
| 4774 | 5013 | } |
| 4775 | 5014 | |
| 4776 | - if (!$options_only) |
|
| 4777 | - $return .= '<select class="flat minwidth75imp" id="' . $htmlname . '" name="' . $htmlname . '"' . ($disabled ? ' disabled' : '') . $title . '>'; |
|
| 5015 | + if (!$options_only) { |
|
| 5016 | + $return .= '<select class="flat minwidth75imp" id="' . $htmlname . '" name="' . $htmlname . '"' . ($disabled ? ' disabled' : '') . $title . '>'; |
|
| 5017 | + } |
|
| 4778 | 5018 | |
| 4779 | 5019 | $selectedfound = false; |
| 4780 | 5020 | foreach ($this->cache_vatrates as $rate) {
|
| 4781 | 5021 | // Keep only 0 if seller is not subject to VAT |
| 4782 | - if ($disabled && $rate['txtva'] != 0) |
|
| 4783 | - continue; |
|
| 5022 | + if ($disabled && $rate['txtva'] != 0) { |
|
| 5023 | + continue; |
|
| 5024 | + } |
|
| 4784 | 5025 | |
| 4785 | 5026 | // Define key to use into select list |
| 4786 | 5027 | $key = $rate['txtva']; |
| 4787 | 5028 | $key .= $rate['nprtva'] ? '*' : ''; |
| 4788 | - if ($mode > 0 && $rate['code']) |
|
| 4789 | - $key .= ' (' . $rate['code'] . ')';
|
|
| 4790 | - if ($mode < 0) |
|
| 4791 | - $key = $rate['rowid']; |
|
| 5029 | + if ($mode > 0 && $rate['code']) { |
|
| 5030 | + $key .= ' (' . $rate['code'] . ')'; |
|
| 5031 | + } |
|
| 5032 | + if ($mode < 0) { |
|
| 5033 | + $key = $rate['rowid']; |
|
| 5034 | + } |
|
| 4792 | 5035 | |
| 4793 | 5036 | $return .= '<option value="' . $key . '"'; |
| 4794 | 5037 | if (!$selectedfound) {
|
@@ -4815,10 +5058,10 @@ discard block |
||
| 4815 | 5058 | $return .= '</option>'; |
| 4816 | 5059 | } |
| 4817 | 5060 | |
| 4818 | - if (!$options_only) |
|
| 4819 | - $return .= '</select>'; |
|
| 4820 | - } |
|
| 4821 | - else {
|
|
| 5061 | + if (!$options_only) { |
|
| 5062 | + $return .= '</select>'; |
|
| 5063 | + } |
|
| 5064 | + } else {
|
|
| 4822 | 5065 | $return .= $this->error; |
| 4823 | 5066 | } |
| 4824 | 5067 | |
@@ -4890,12 +5133,15 @@ discard block |
||
| 4890 | 5133 | |
| 4891 | 5134 | $retstring = ''; |
| 4892 | 5135 | |
| 4893 | - if ($prefix == '') |
|
| 4894 | - $prefix = 're'; |
|
| 4895 | - if ($h == '') |
|
| 4896 | - $h = 0; |
|
| 4897 | - if ($m == '') |
|
| 4898 | - $m = 0; |
|
| 5136 | + if ($prefix == '') { |
|
| 5137 | + $prefix = 're'; |
|
| 5138 | + } |
|
| 5139 | + if ($h == '') { |
|
| 5140 | + $h = 0; |
|
| 5141 | + } |
|
| 5142 | + if ($m == '') { |
|
| 5143 | + $m = 0; |
|
| 5144 | + } |
|
| 4899 | 5145 | $emptydate = 0; |
| 4900 | 5146 | $emptyhours = 0; |
| 4901 | 5147 | if ($empty == 1) {
|
@@ -4944,10 +5190,12 @@ discard block |
||
| 4944 | 5190 | $smin = !isset($conf->global->MAIN_DEFAULT_DATE_MIN) ? ($h == -1 ? '59' : '') : $conf->global->MAIN_DEFAULT_DATE_MIN; |
| 4945 | 5191 | $ssec = !isset($conf->global->MAIN_DEFAULT_DATE_SEC) ? ($h == -1 ? '59' : '') : $conf->global->MAIN_DEFAULT_DATE_SEC; |
| 4946 | 5192 | } |
| 4947 | - if ($h == 3) |
|
| 4948 | - $shour = ''; |
|
| 4949 | - if ($m == 3) |
|
| 4950 | - $smin = ''; |
|
| 5193 | + if ($h == 3) { |
|
| 5194 | + $shour = ''; |
|
| 5195 | + } |
|
| 5196 | + if ($m == 3) { |
|
| 5197 | + $smin = ''; |
|
| 5198 | + } |
|
| 4951 | 5199 | |
| 4952 | 5200 | // You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery' |
| 4953 | 5201 | $usecalendar = 'combo'; |
@@ -4979,14 +5227,14 @@ discard block |
||
| 4979 | 5227 | $base = DOL_URL_ROOT . '/core/'; |
| 4980 | 5228 | $retstring .= ' onClick="showDP(\'' . $base . '\',\'' . $prefix . '\',\'' . $langs->trans("FormatDateShortJavaInput") . '\',\'' . $langs->defaultlang . '\');"';
|
| 4981 | 5229 | $retstring .= '>' . img_object($langs->trans("SelectDate"), 'calendarday', 'class="datecallink"') . '</button>';
|
| 4982 | - } else |
|
| 4983 | - $retstring .= '<button id="' . $prefix . 'Button" type="button" class="dpInvisibleButtons">' . img_object($langs->trans("Disabled"), 'calendarday', 'class="datecallink"') . '</button>';
|
|
| 5230 | + } else { |
|
| 5231 | + $retstring .= '<button id="' . $prefix . 'Button" type="button" class="dpInvisibleButtons">' . img_object($langs->trans("Disabled"), 'calendarday', 'class="datecallink"') . '</button>'; |
|
| 5232 | + } |
|
| 4984 | 5233 | |
| 4985 | 5234 | $retstring .= '<input type="hidden" id="' . $prefix . 'day" name="' . $prefix . 'day" value="' . $sday . '">' . "\n"; |
| 4986 | 5235 | $retstring .= '<input type="hidden" id="' . $prefix . 'month" name="' . $prefix . 'month" value="' . $smonth . '">' . "\n"; |
| 4987 | 5236 | $retstring .= '<input type="hidden" id="' . $prefix . 'year" name="' . $prefix . 'year" value="' . $syear . '">' . "\n"; |
| 4988 | - } |
|
| 4989 | - elseif ($usecalendar == 'jquery') {
|
|
| 5237 | + } elseif ($usecalendar == 'jquery') {
|
|
| 4990 | 5238 | if (!$disabled) {
|
| 4991 | 5239 | // Output javascript for datepicker |
| 4992 | 5240 | $retstring .= "<script type='text/javascript'>"; |
@@ -5096,32 +5344,38 @@ discard block |
||
| 5096 | 5344 | } |
| 5097 | 5345 | } |
| 5098 | 5346 | |
| 5099 | - if ($d && $h) |
|
| 5100 | - $retstring .= ($h == 2 ? '<br>' : ' '); |
|
| 5347 | + if ($d && $h) { |
|
| 5348 | + $retstring .= ($h == 2 ? '<br>' : ' '); |
|
| 5349 | + } |
|
| 5101 | 5350 | |
| 5102 | 5351 | if ($h) {
|
| 5103 | 5352 | // Show hour |
| 5104 | 5353 | $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50 ' . ($fullday ? $fullday . 'hour' : '') . '" id="' . $prefix . 'hour" name="' . $prefix . 'hour">'; |
| 5105 | - if ($emptyhours) |
|
| 5106 | - $retstring .= '<option value="-1"> </option>'; |
|
| 5354 | + if ($emptyhours) { |
|
| 5355 | + $retstring .= '<option value="-1"> </option>'; |
|
| 5356 | + } |
|
| 5107 | 5357 | for ($hour = 0; $hour < 24; $hour++) {
|
| 5108 | - if (strlen($hour) < 2) |
|
| 5109 | - $hour = "0" . $hour; |
|
| 5358 | + if (strlen($hour) < 2) { |
|
| 5359 | + $hour = "0" . $hour; |
|
| 5360 | + } |
|
| 5110 | 5361 | $retstring .= '<option value="' . $hour . '"' . (($hour == $shour) ? ' selected' : '') . '>' . $hour . (empty($conf->dol_optimize_smallscreen) ? '' : 'H') . '</option>'; |
| 5111 | 5362 | } |
| 5112 | 5363 | $retstring .= '</select>'; |
| 5113 | - if ($m && empty($conf->dol_optimize_smallscreen)) |
|
| 5114 | - $retstring .= ":"; |
|
| 5364 | + if ($m && empty($conf->dol_optimize_smallscreen)) { |
|
| 5365 | + $retstring .= ":"; |
|
| 5366 | + } |
|
| 5115 | 5367 | } |
| 5116 | 5368 | |
| 5117 | 5369 | if ($m) {
|
| 5118 | 5370 | // Show minutes |
| 5119 | 5371 | $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50 ' . ($fullday ? $fullday . 'min' : '') . '" id="' . $prefix . 'min" name="' . $prefix . 'min">'; |
| 5120 | - if ($emptyhours) |
|
| 5121 | - $retstring .= '<option value="-1"> </option>'; |
|
| 5372 | + if ($emptyhours) { |
|
| 5373 | + $retstring .= '<option value="-1"> </option>'; |
|
| 5374 | + } |
|
| 5122 | 5375 | for ($min = 0; $min < 60; $min++) {
|
| 5123 | - if (strlen($min) < 2) |
|
| 5124 | - $min = "0" . $min; |
|
| 5376 | + if (strlen($min) < 2) { |
|
| 5377 | + $min = "0" . $min; |
|
| 5378 | + } |
|
| 5125 | 5379 | $retstring .= '<option value="' . $min . '"' . (($min == $smin) ? ' selected' : '') . '>' . $min . (empty($conf->dol_optimize_smallscreen) ? '' : '') . '</option>'; |
| 5126 | 5380 | } |
| 5127 | 5381 | $retstring .= '</select>'; |
@@ -5152,21 +5406,25 @@ discard block |
||
| 5152 | 5406 | } */ |
| 5153 | 5407 | // Update the hour part |
| 5154 | 5408 | if ($h) {
|
| 5155 | - if ($fullday) |
|
| 5156 | - $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
|
|
| 5409 | + if ($fullday) { |
|
| 5410 | + $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; |
|
| 5411 | + } |
|
| 5157 | 5412 | //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); '; |
| 5158 | 5413 | $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(\'' . dol_print_date(dol_now(), '%H') . '\');'; |
| 5159 | - if ($fullday) |
|
| 5160 | - $reset_scripts .= ' } '; |
|
| 5414 | + if ($fullday) { |
|
| 5415 | + $reset_scripts .= ' } '; |
|
| 5416 | + } |
|
| 5161 | 5417 | } |
| 5162 | 5418 | // Update the minute part |
| 5163 | 5419 | if ($m) {
|
| 5164 | - if ($fullday) |
|
| 5165 | - $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
|
|
| 5420 | + if ($fullday) { |
|
| 5421 | + $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; |
|
| 5422 | + } |
|
| 5166 | 5423 | //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); '; |
| 5167 | 5424 | $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(\'' . dol_print_date(dol_now(), '%M') . '\');'; |
| 5168 | - if ($fullday) |
|
| 5169 | - $reset_scripts .= ' } '; |
|
| 5425 | + if ($fullday) { |
|
| 5426 | + $reset_scripts .= ' } '; |
|
| 5427 | + } |
|
| 5170 | 5428 | } |
| 5171 | 5429 | // If reset_scripts is not empty, print the link with the reset_scripts in the onClick |
| 5172 | 5430 | if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) {
|
@@ -5188,19 +5446,23 @@ discard block |
||
| 5188 | 5446 | $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date(dol_now(), '%Y') . '\');'; |
| 5189 | 5447 | // Update the hour part |
| 5190 | 5448 | if ($h) {
|
| 5191 | - if ($fullday) |
|
| 5192 | - $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
|
|
| 5449 | + if ($fullday) { |
|
| 5450 | + $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; |
|
| 5451 | + } |
|
| 5193 | 5452 | $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(\'' . dol_print_date(dol_now(), '%H') . '\');'; |
| 5194 | - if ($fullday) |
|
| 5195 | - $reset_scripts .= ' } '; |
|
| 5453 | + if ($fullday) { |
|
| 5454 | + $reset_scripts .= ' } '; |
|
| 5455 | + } |
|
| 5196 | 5456 | } |
| 5197 | 5457 | // Update the minute part |
| 5198 | 5458 | if ($m) {
|
| 5199 | - if ($fullday) |
|
| 5200 | - $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
|
|
| 5459 | + if ($fullday) { |
|
| 5460 | + $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {"; |
|
| 5461 | + } |
|
| 5201 | 5462 | $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(\'' . dol_print_date(dol_now(), '%M') . '\');'; |
| 5202 | - if ($fullday) |
|
| 5203 | - $reset_scripts .= ' } '; |
|
| 5463 | + if ($fullday) { |
|
| 5464 | + $reset_scripts .= ' } '; |
|
| 5465 | + } |
|
| 5204 | 5466 | } |
| 5205 | 5467 | // If reset_scripts is not empty, print the link with the reset_scripts in the onClick |
| 5206 | 5468 | if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) {
|
@@ -5263,41 +5525,46 @@ discard block |
||
| 5263 | 5525 | $retstring .= "</select>"; |
| 5264 | 5526 | } elseif ($typehour == 'text' || $typehour == 'textselect') {
|
| 5265 | 5527 | $retstring .= '<input placeholder="' . $langs->trans('HourShort') . '" type="number" min="0" size="1" name="' . $prefix . 'hour"' . ($disabled ? ' disabled' : '') . ' class="flat maxwidth50 inputhour" value="' . (($hourSelected != '') ? ((int) $hourSelected) : '') . '">';
|
| 5266 | - } else |
|
| 5267 | - return 'BadValueForParameterTypeHour'; |
|
| 5528 | + } else { |
|
| 5529 | + return 'BadValueForParameterTypeHour'; |
|
| 5530 | + } |
|
| 5268 | 5531 | |
| 5269 | - if ($typehour != 'text') |
|
| 5270 | - $retstring .= ' ' . $langs->trans('HourShort');
|
|
| 5271 | - else |
|
| 5272 | - $retstring .= '<span class="hideonsmartphone">:</span>'; |
|
| 5532 | + if ($typehour != 'text') { |
|
| 5533 | + $retstring .= ' ' . $langs->trans('HourShort'); |
|
| 5534 | + } else { |
|
| 5535 | + $retstring .= '<span class="hideonsmartphone">:</span>'; |
|
| 5536 | + } |
|
| 5273 | 5537 | |
| 5274 | 5538 | // Minutes |
| 5275 | - if ($minunderhours) |
|
| 5276 | - $retstring .= '<br>'; |
|
| 5277 | - else |
|
| 5278 | - $retstring .= '<span class="hideonsmartphone"> </span>'; |
|
| 5539 | + if ($minunderhours) { |
|
| 5540 | + $retstring .= '<br>'; |
|
| 5541 | + } else { |
|
| 5542 | + $retstring .= '<span class="hideonsmartphone"> </span>'; |
|
| 5543 | + } |
|
| 5279 | 5544 | |
| 5280 | 5545 | if ($typehour == 'select' || $typehour == 'textselect') {
|
| 5281 | 5546 | $retstring .= '<select class="flat" id="select_' . $prefix . 'min" name="' . $prefix . 'min"' . ($disabled ? ' disabled' : '') . '>'; |
| 5282 | 5547 | for ($min = 0; $min <= 55; $min = $min + 5) {
|
| 5283 | 5548 | $retstring .= '<option value="' . $min . '"'; |
| 5284 | - if ($minSelected == $min) |
|
| 5285 | - $retstring .= ' selected'; |
|
| 5549 | + if ($minSelected == $min) { |
|
| 5550 | + $retstring .= ' selected'; |
|
| 5551 | + } |
|
| 5286 | 5552 | $retstring .= '>' . $min . '</option>'; |
| 5287 | 5553 | } |
| 5288 | 5554 | $retstring .= "</select>"; |
| 5289 | - } |
|
| 5290 | - elseif ($typehour == 'text') {
|
|
| 5555 | + } elseif ($typehour == 'text') {
|
|
| 5291 | 5556 | $retstring .= '<input placeholder="' . $langs->trans('MinuteShort') . '" type="number" min="0" size="1" name="' . $prefix . 'min"' . ($disabled ? ' disabled' : '') . ' class="flat maxwidth50 inputminute" value="' . (($minSelected != '') ? ((int) $minSelected) : '') . '">';
|
| 5292 | 5557 | } |
| 5293 | 5558 | |
| 5294 | - if ($typehour != 'text') |
|
| 5295 | - $retstring .= ' ' . $langs->trans('MinuteShort');
|
|
| 5559 | + if ($typehour != 'text') { |
|
| 5560 | + $retstring .= ' ' . $langs->trans('MinuteShort'); |
|
| 5561 | + } |
|
| 5296 | 5562 | |
| 5297 | 5563 | //$retstring.=" "; |
| 5298 | 5564 | |
| 5299 | - if (!empty($nooutput)) |
|
| 5300 | - return $retstring; |
|
| 5565 | + if (!empty($nooutput)) { |
|
| 5566 | + return $retstring; |
|
| 5567 | + } |
|
| 5301 | 5568 | |
| 5302 | 5569 | print $retstring; |
| 5303 | 5570 | return; |
@@ -5340,8 +5607,9 @@ discard block |
||
| 5340 | 5607 | } |
| 5341 | 5608 | |
| 5342 | 5609 | $prefixforautocompletemode = $objecttmp->element; |
| 5343 | - if ($prefixforautocompletemode == 'societe') |
|
| 5344 | - $prefixforautocompletemode = 'company'; |
|
| 5610 | + if ($prefixforautocompletemode == 'societe') { |
|
| 5611 | + $prefixforautocompletemode = 'company'; |
|
| 5612 | + } |
|
| 5345 | 5613 | $confkeyforautocompletemode = strtoupper($prefixforautocompletemode) . '_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT |
| 5346 | 5614 | |
| 5347 | 5615 | dol_syslog(get_class($this) . "::selectForForms", LOG_DEBUG); |
@@ -5356,11 +5624,11 @@ discard block |
||
| 5356 | 5624 | // Activate the auto complete using ajax call. |
| 5357 | 5625 | $out .= ajax_autocompleter($preselectedvalue, $htmlname, $urlforajaxcall, $urloption, $conf->global->$confkeyforautocompletemode, 0, array()); |
| 5358 | 5626 | $out .= '<style type="text/css">.ui-autocomplete { z-index: 250; }</style>';
|
| 5359 | - if ($placeholder) |
|
| 5360 | - $placeholder = ' placeholder="' . $placeholder . '"'; |
|
| 5627 | + if ($placeholder) { |
|
| 5628 | + $placeholder = ' placeholder="' . $placeholder . '"'; |
|
| 5629 | + } |
|
| 5361 | 5630 | $out .= '<input type="text" class="' . $morecss . '" name="search_' . $htmlname . '" id="search_' . $htmlname . '" value="' . $preselectedvalue . '"' . $placeholder . ' />'; |
| 5362 | - } |
|
| 5363 | - else {
|
|
| 5631 | + } else {
|
|
| 5364 | 5632 | // Immediate load of all database |
| 5365 | 5633 | $out .= $this->selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo); |
| 5366 | 5634 | } |
@@ -5390,19 +5658,22 @@ discard block |
||
| 5390 | 5658 | global $conf, $langs, $user; |
| 5391 | 5659 | |
| 5392 | 5660 | $prefixforautocompletemode = $objecttmp->element; |
| 5393 | - if ($prefixforautocompletemode == 'societe') |
|
| 5394 | - $prefixforautocompletemode = 'company'; |
|
| 5661 | + if ($prefixforautocompletemode == 'societe') { |
|
| 5662 | + $prefixforautocompletemode = 'company'; |
|
| 5663 | + } |
|
| 5395 | 5664 | $confkeyforautocompletemode = strtoupper($prefixforautocompletemode) . '_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT |
| 5396 | 5665 | |
| 5397 | 5666 | $fieldstoshow = 't.ref'; |
| 5398 | 5667 | if (!empty($objecttmp->fields)) { // For object that declare it, it is better to use declared fields ( like societe, contact, ...)
|
| 5399 | 5668 | $tmpfieldstoshow = ''; |
| 5400 | 5669 | foreach ($objecttmp->fields as $key => $val) {
|
| 5401 | - if ($val['showoncombobox']) |
|
| 5402 | - $tmpfieldstoshow .= ($tmpfieldstoshow ? ',' : '') . 't.' . $key; |
|
| 5670 | + if ($val['showoncombobox']) { |
|
| 5671 | + $tmpfieldstoshow .= ($tmpfieldstoshow ? ',' : '') . 't.' . $key; |
|
| 5672 | + } |
|
| 5403 | 5673 | } |
| 5404 | - if ($tmpfieldstoshow) |
|
| 5405 | - $fieldstoshow = $tmpfieldstoshow; |
|
| 5674 | + if ($tmpfieldstoshow) { |
|
| 5675 | + $fieldstoshow = $tmpfieldstoshow; |
|
| 5676 | + } |
|
| 5406 | 5677 | } |
| 5407 | 5678 | |
| 5408 | 5679 | $out = ''; |
@@ -5412,23 +5683,28 @@ discard block |
||
| 5412 | 5683 | |
| 5413 | 5684 | // Search data |
| 5414 | 5685 | $sql = "SELECT t.rowid, " . $fieldstoshow . " FROM " . MAIN_DB_PREFIX . $objecttmp->table_element . " as t"; |
| 5415 | - if ($objecttmp->ismultientitymanaged == 2) |
|
| 5416 | - if (!$user->rights->societe->client->voir && !$user->societe_id) |
|
| 5417 | - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; |
|
| 5686 | + if ($objecttmp->ismultientitymanaged == 2) { |
|
| 5687 | + if (!$user->rights->societe->client->voir && !$user->societe_id) |
|
| 5688 | + $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; |
|
| 5689 | + } |
|
| 5418 | 5690 | $sql .= " WHERE 1=1"; |
| 5419 | - if (!empty($objecttmp->ismultientitymanaged)) |
|
| 5420 | - $sql .= " AND t.entity IN (" . getEntity($objecttmp->table_element) . ")";
|
|
| 5691 | + if (!empty($objecttmp->ismultientitymanaged)) { |
|
| 5692 | + $sql .= " AND t.entity IN (" . getEntity($objecttmp->table_element) . ")"; |
|
| 5693 | + } |
|
| 5421 | 5694 | if ($objecttmp->ismultientitymanaged == 1 && !empty($user->societe_id)) {
|
| 5422 | - if ($objecttmp->element == 'societe') |
|
| 5423 | - $sql .= " AND t.rowid = " . $user->societe_id; |
|
| 5424 | - else |
|
| 5425 | - $sql .= " AND t.fk_soc = " . $user->societe_id; |
|
| 5426 | - } |
|
| 5427 | - if ($searchkey != '') |
|
| 5428 | - $sql .= natural_search(explode(',', $fieldstoshow), $searchkey);
|
|
| 5429 | - if ($objecttmp->ismultientitymanaged == 2) |
|
| 5430 | - if (!$user->rights->societe->client->voir && !$user->societe_id) |
|
| 5431 | - $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; |
|
| 5695 | + if ($objecttmp->element == 'societe') { |
|
| 5696 | + $sql .= " AND t.rowid = " . $user->societe_id; |
|
| 5697 | + } else { |
|
| 5698 | + $sql .= " AND t.fk_soc = " . $user->societe_id; |
|
| 5699 | + } |
|
| 5700 | + } |
|
| 5701 | + if ($searchkey != '') { |
|
| 5702 | + $sql .= natural_search(explode(',', $fieldstoshow), $searchkey); |
|
| 5703 | + } |
|
| 5704 | + if ($objecttmp->ismultientitymanaged == 2) { |
|
| 5705 | + if (!$user->rights->societe->client->voir && !$user->societe_id) |
|
| 5706 | + $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; |
|
| 5707 | + } |
|
| 5432 | 5708 | $sql .= $this->db->order($fieldstoshow, "ASC"); |
| 5433 | 5709 | //$sql.=$this->db->plimit($limit, 0); |
| 5434 | 5710 | // Build output string |
@@ -5447,13 +5723,15 @@ discard block |
||
| 5447 | 5723 | |
| 5448 | 5724 | //if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty=''; |
| 5449 | 5725 | if (!empty($conf->global->$confkeyforautocompletemode)) {
|
| 5450 | - if ($showempty && !is_numeric($showempty)) |
|
| 5451 | - $textifempty = $langs->trans($showempty); |
|
| 5452 | - else |
|
| 5453 | - $textifempty .= $langs->trans("All");
|
|
| 5726 | + if ($showempty && !is_numeric($showempty)) { |
|
| 5727 | + $textifempty = $langs->trans($showempty); |
|
| 5728 | + } else { |
|
| 5729 | + $textifempty .= $langs->trans("All"); |
|
| 5730 | + } |
|
| 5454 | 5731 | } |
| 5455 | - if ($showempty) |
|
| 5456 | - $out .= '<option value="-1">' . $textifempty . '</option>' . "\n"; |
|
| 5732 | + if ($showempty) { |
|
| 5733 | + $out .= '<option value="-1">' . $textifempty . '</option>' . "\n"; |
|
| 5734 | + } |
|
| 5457 | 5735 | |
| 5458 | 5736 | $num = $this->db->num_rows($resql); |
| 5459 | 5737 | $i = 0; |
@@ -5477,21 +5755,22 @@ discard block |
||
| 5477 | 5755 | } |
| 5478 | 5756 | |
| 5479 | 5757 | $i++; |
| 5480 | - if (($i % 10) == 0) |
|
| 5481 | - $out .= "\n"; |
|
| 5758 | + if (($i % 10) == 0) { |
|
| 5759 | + $out .= "\n"; |
|
| 5760 | + } |
|
| 5482 | 5761 | } |
| 5483 | 5762 | } |
| 5484 | 5763 | |
| 5485 | 5764 | $out .= '</select>' . "\n"; |
| 5486 | - } |
|
| 5487 | - else {
|
|
| 5765 | + } else {
|
|
| 5488 | 5766 | dol_print_error($this->db); |
| 5489 | 5767 | } |
| 5490 | 5768 | |
| 5491 | 5769 | $this->result = array('nbofelement' => $num);
|
| 5492 | 5770 | |
| 5493 | - if ($outputmode) |
|
| 5494 | - return $outarray; |
|
| 5771 | + if ($outputmode) { |
|
| 5772 | + return $outarray; |
|
| 5773 | + } |
|
| 5495 | 5774 | return $out; |
| 5496 | 5775 | } |
| 5497 | 5776 | |
@@ -5527,8 +5806,9 @@ discard block |
||
| 5527 | 5806 | //if (preg_match('/^multi/',$htmlname)) $jsbeautify = 1;
|
| 5528 | 5807 | $jsbeautify = 1; |
| 5529 | 5808 | |
| 5530 | - if ($value_as_key) |
|
| 5531 | - $array = array_combine($array, $array); |
|
| 5809 | + if ($value_as_key) { |
|
| 5810 | + $array = array_combine($array, $array); |
|
| 5811 | + } |
|
| 5532 | 5812 | |
| 5533 | 5813 | $out = ''; |
| 5534 | 5814 | |
@@ -5548,10 +5828,13 @@ discard block |
||
| 5548 | 5828 | |
| 5549 | 5829 | if ($show_empty) {
|
| 5550 | 5830 | $textforempty = ' '; |
| 5551 | - if (!empty($conf->use_javascript_ajax)) |
|
| 5552 | - $textforempty = ' '; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small. |
|
| 5553 | - if (!is_numeric($show_empty)) |
|
| 5554 | - $textforempty = $show_empty; |
|
| 5831 | + if (!empty($conf->use_javascript_ajax)) { |
|
| 5832 | + $textforempty = ' '; |
|
| 5833 | + } |
|
| 5834 | + // If we use ajaxcombo, we need here to avoid to have an empty element that is too small. |
|
| 5835 | + if (!is_numeric($show_empty)) { |
|
| 5836 | + $textforempty = $show_empty; |
|
| 5837 | + } |
|
| 5555 | 5838 | $out .= '<option class="optiongrey" ' . ($moreparamonempty ? $moreparamonempty . ' ' : '') . 'value="' . ($show_empty < 0 ? $show_empty : -1) . '"' . ($id == $show_empty ? ' selected' : '') . '>' . $textforempty . '</option>' . "\n"; |
| 5556 | 5839 | } |
| 5557 | 5840 | |
@@ -5564,10 +5847,11 @@ discard block |
||
| 5564 | 5847 | } |
| 5565 | 5848 | |
| 5566 | 5849 | // Sort |
| 5567 | - if ($sort == 'ASC') |
|
| 5568 | - asort($array); |
|
| 5569 | - elseif ($sort == 'DESC') |
|
| 5570 | - arsort($array); |
|
| 5850 | + if ($sort == 'ASC') { |
|
| 5851 | + asort($array); |
|
| 5852 | + } elseif ($sort == 'DESC') { |
|
| 5853 | + arsort($array); |
|
| 5854 | + } |
|
| 5571 | 5855 | |
| 5572 | 5856 | foreach ($array as $key => $value) {
|
| 5573 | 5857 | $disabled = ''; |
@@ -5581,26 +5865,31 @@ discard block |
||
| 5581 | 5865 | } |
| 5582 | 5866 | |
| 5583 | 5867 | if ($key_in_label) {
|
| 5584 | - if (empty($nohtmlescape)) |
|
| 5585 | - $selectOptionValue = dol_escape_htmltag($key . ' - ' . ($maxlen ? dol_trunc($value, $maxlen) : $value)); |
|
| 5586 | - else |
|
| 5587 | - $selectOptionValue = $key . ' - ' . ($maxlen ? dol_trunc($value, $maxlen) : $value); |
|
| 5588 | - } |
|
| 5589 | - else {
|
|
| 5590 | - if (empty($nohtmlescape)) |
|
| 5591 | - $selectOptionValue = dol_escape_htmltag($maxlen ? dol_trunc($value, $maxlen) : $value); |
|
| 5592 | - else |
|
| 5593 | - $selectOptionValue = $maxlen ? dol_trunc($value, $maxlen) : $value; |
|
| 5594 | - if ($value == '' || $value == '-') |
|
| 5595 | - $selectOptionValue = ' '; |
|
| 5868 | + if (empty($nohtmlescape)) { |
|
| 5869 | + $selectOptionValue = dol_escape_htmltag($key . ' - ' . ($maxlen ? dol_trunc($value, $maxlen) : $value)); |
|
| 5870 | + } else { |
|
| 5871 | + $selectOptionValue = $key . ' - ' . ($maxlen ? dol_trunc($value, $maxlen) : $value); |
|
| 5872 | + } |
|
| 5873 | + } else {
|
|
| 5874 | + if (empty($nohtmlescape)) { |
|
| 5875 | + $selectOptionValue = dol_escape_htmltag($maxlen ? dol_trunc($value, $maxlen) : $value); |
|
| 5876 | + } else { |
|
| 5877 | + $selectOptionValue = $maxlen ? dol_trunc($value, $maxlen) : $value; |
|
| 5878 | + } |
|
| 5879 | + if ($value == '' || $value == '-') { |
|
| 5880 | + $selectOptionValue = ' '; |
|
| 5881 | + } |
|
| 5596 | 5882 | } |
| 5597 | 5883 | |
| 5598 | 5884 | $out .= '<option value="' . $key . '"'; |
| 5599 | 5885 | $out .= $style . $disabled; |
| 5600 | - if ($id != '' && $id == $key && !$disabled) |
|
| 5601 | - $out .= ' selected'; // To preselect a value |
|
| 5602 | - if ($nohtmlescape) |
|
| 5603 | - $out .= ' data-html="' . dol_escape_htmltag($selectOptionValue) . '"'; |
|
| 5886 | + if ($id != '' && $id == $key && !$disabled) { |
|
| 5887 | + $out .= ' selected'; |
|
| 5888 | + } |
|
| 5889 | + // To preselect a value |
|
| 5890 | + if ($nohtmlescape) { |
|
| 5891 | + $out .= ' data-html="' . dol_escape_htmltag($selectOptionValue) . '"'; |
|
| 5892 | + } |
|
| 5604 | 5893 | $out .= '>'; |
| 5605 | 5894 | //var_dump($selectOptionValue); |
| 5606 | 5895 | $out .= $selectOptionValue; |
@@ -5636,8 +5925,9 @@ discard block |
||
| 5636 | 5925 | global $delayedhtmlcontent; |
| 5637 | 5926 | |
| 5638 | 5927 | // TODO Use an internal dolibarr component instead of select2 |
| 5639 | - if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT'))
|
|
| 5640 | - return ''; |
|
| 5928 | + if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) { |
|
| 5929 | + return ''; |
|
| 5930 | + } |
|
| 5641 | 5931 | |
| 5642 | 5932 | $out = '<select type="text" class="' . $htmlname . ($morecss ? ' ' . $morecss : '') . '" ' . ($moreparam ? $moreparam . ' ' : '') . 'name="' . $htmlname . '"></select>'; |
| 5643 | 5933 | |
@@ -5736,8 +6026,9 @@ discard block |
||
| 5736 | 6026 | global $delayedhtmlcontent; |
| 5737 | 6027 | |
| 5738 | 6028 | // TODO Use an internal dolibarr component instead of select2 |
| 5739 | - if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT'))
|
|
| 5740 | - return ''; |
|
| 6029 | + if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) { |
|
| 6030 | + return ''; |
|
| 6031 | + } |
|
| 5741 | 6032 | |
| 5742 | 6033 | $out = '<select type="text" class="' . $htmlname . ($morecss ? ' ' . $morecss : '') . '" ' . ($moreparam ? $moreparam . ' ' : '') . 'name="' . $htmlname . '"><option></option></select>'; |
| 5743 | 6034 | |
@@ -5907,8 +6198,9 @@ discard block |
||
| 5907 | 6198 | |
| 5908 | 6199 | $out .= '<select id="' . $htmlname . '" class="multiselect' . ($morecss ? ' ' . $morecss : '') . '" multiple name="' . $htmlname . '[]"' . ($moreattrib ? ' ' . $moreattrib : '') . ($width ? ' style="width: ' . (preg_match('/%/', $width) ? $width : $width . 'px') . '"' : '') . '>' . "\n";
|
| 5909 | 6200 | if (is_array($array) && !empty($array)) {
|
| 5910 | - if ($value_as_key) |
|
| 5911 | - $array = array_combine($array, $array); |
|
| 6201 | + if ($value_as_key) { |
|
| 6202 | + $array = array_combine($array, $array); |
|
| 6203 | + } |
|
| 5912 | 6204 | |
| 5913 | 6205 | if (!empty($array)) {
|
| 5914 | 6206 | foreach ($array as $key => $value) {
|
@@ -5943,8 +6235,9 @@ discard block |
||
| 5943 | 6235 | {
|
| 5944 | 6236 | global $conf, $langs, $user; |
| 5945 | 6237 | |
| 5946 | - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 5947 | - return ''; |
|
| 6238 | + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { |
|
| 6239 | + return ''; |
|
| 6240 | + } |
|
| 5948 | 6241 | |
| 5949 | 6242 | $tmpvar = "MAIN_SELECTEDFIELDS_" . $varpage; |
| 5950 | 6243 | if (!empty($user->conf->$tmpvar)) {
|
@@ -5952,10 +6245,11 @@ discard block |
||
| 5952 | 6245 | foreach ($array as $key => $val) {
|
| 5953 | 6246 | //var_dump($key); |
| 5954 | 6247 | //var_dump($tmparray); |
| 5955 | - if (in_array($key, $tmparray)) |
|
| 5956 | - $array[$key]['checked'] = 1; |
|
| 5957 | - else |
|
| 5958 | - $array[$key]['checked'] = 0; |
|
| 6248 | + if (in_array($key, $tmparray)) { |
|
| 6249 | + $array[$key]['checked'] = 1; |
|
| 6250 | + } else { |
|
| 6251 | + $array[$key]['checked'] = 0; |
|
| 6252 | + } |
|
| 5959 | 6253 | } |
| 5960 | 6254 | } |
| 5961 | 6255 | //var_dump($array); |
@@ -6121,40 +6415,47 @@ discard block |
||
| 6121 | 6415 | // To work with non standard path |
| 6122 | 6416 | if ($objecttype == 'facture') {
|
| 6123 | 6417 | $tplpath = 'compta/' . $element; |
| 6124 | - if (empty($conf->facture->enabled)) |
|
| 6125 | - continue; // Do not show if module disabled |
|
| 6126 | - } |
|
| 6127 | - else if ($objecttype == 'facturerec') {
|
|
| 6418 | + if (empty($conf->facture->enabled)) { |
|
| 6419 | + continue; |
|
| 6420 | + } |
|
| 6421 | + // Do not show if module disabled |
|
| 6422 | + } else if ($objecttype == 'facturerec') {
|
|
| 6128 | 6423 | $tplpath = 'compta/facture'; |
| 6129 | 6424 | $tplname = 'linkedobjectblockForRec'; |
| 6130 | - if (empty($conf->facture->enabled)) |
|
| 6131 | - continue; // Do not show if module disabled |
|
| 6132 | - } |
|
| 6133 | - else if ($objecttype == 'propal') {
|
|
| 6425 | + if (empty($conf->facture->enabled)) { |
|
| 6426 | + continue; |
|
| 6427 | + } |
|
| 6428 | + // Do not show if module disabled |
|
| 6429 | + } else if ($objecttype == 'propal') {
|
|
| 6134 | 6430 | $tplpath = 'comm/' . $element; |
| 6135 | - if (empty($conf->propal->enabled)) |
|
| 6136 | - continue; // Do not show if module disabled |
|
| 6137 | - } |
|
| 6138 | - else if ($objecttype == 'supplier_proposal') {
|
|
| 6139 | - if (empty($conf->supplier_proposal->enabled)) |
|
| 6140 | - continue; // Do not show if module disabled |
|
| 6141 | - } |
|
| 6142 | - else if ($objecttype == 'shipping' || $objecttype == 'shipment') {
|
|
| 6431 | + if (empty($conf->propal->enabled)) { |
|
| 6432 | + continue; |
|
| 6433 | + } |
|
| 6434 | + // Do not show if module disabled |
|
| 6435 | + } else if ($objecttype == 'supplier_proposal') {
|
|
| 6436 | + if (empty($conf->supplier_proposal->enabled)) { |
|
| 6437 | + continue; |
|
| 6438 | + } |
|
| 6439 | + // Do not show if module disabled |
|
| 6440 | + } else if ($objecttype == 'shipping' || $objecttype == 'shipment') {
|
|
| 6143 | 6441 | $tplpath = 'expedition'; |
| 6144 | - if (empty($conf->expedition->enabled)) |
|
| 6145 | - continue; // Do not show if module disabled |
|
| 6146 | - } |
|
| 6147 | - else if ($objecttype == 'reception') {
|
|
| 6442 | + if (empty($conf->expedition->enabled)) { |
|
| 6443 | + continue; |
|
| 6444 | + } |
|
| 6445 | + // Do not show if module disabled |
|
| 6446 | + } else if ($objecttype == 'reception') {
|
|
| 6148 | 6447 | $tplpath = 'reception'; |
| 6149 | - if (empty($conf->reception->enabled)) |
|
| 6150 | - continue; // Do not show if module disabled |
|
| 6151 | - } |
|
| 6152 | - else if ($objecttype == 'delivery') {
|
|
| 6448 | + if (empty($conf->reception->enabled)) { |
|
| 6449 | + continue; |
|
| 6450 | + } |
|
| 6451 | + // Do not show if module disabled |
|
| 6452 | + } else if ($objecttype == 'delivery') {
|
|
| 6153 | 6453 | $tplpath = 'livraison'; |
| 6154 | - if (empty($conf->expedition->enabled)) |
|
| 6155 | - continue; // Do not show if module disabled |
|
| 6156 | - } |
|
| 6157 | - else if ($objecttype == 'invoice_supplier') {
|
|
| 6454 | + if (empty($conf->expedition->enabled)) { |
|
| 6455 | + continue; |
|
| 6456 | + } |
|
| 6457 | + // Do not show if module disabled |
|
| 6458 | + } else if ($objecttype == 'invoice_supplier') {
|
|
| 6158 | 6459 | $tplpath = 'fourn/facture'; |
| 6159 | 6460 | } else if ($objecttype == 'order_supplier') {
|
| 6160 | 6461 | $tplpath = 'fourn/commande'; |
@@ -6218,20 +6519,23 @@ discard block |
||
| 6218 | 6519 | $linktoelemlist = ''; |
| 6219 | 6520 | $listofidcompanytoscan = ''; |
| 6220 | 6521 | |
| 6221 | - if (!is_object($object->thirdparty)) |
|
| 6222 | - $object->fetch_thirdparty(); |
|
| 6522 | + if (!is_object($object->thirdparty)) { |
|
| 6523 | + $object->fetch_thirdparty(); |
|
| 6524 | + } |
|
| 6223 | 6525 | |
| 6224 | 6526 | $possiblelinks = array(); |
| 6225 | 6527 | if (is_object($object->thirdparty) && !empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
|
| 6226 | 6528 | $listofidcompanytoscan = $object->thirdparty->id; |
| 6227 | - if (($object->thirdparty->parent > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) |
|
| 6228 | - $listofidcompanytoscan .= ',' . $object->thirdparty->parent; |
|
| 6529 | + if (($object->thirdparty->parent > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) { |
|
| 6530 | + $listofidcompanytoscan .= ',' . $object->thirdparty->parent; |
|
| 6531 | + } |
|
| 6229 | 6532 | if (($object->fk_project > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PROJECT_THIRDPARY_IN_LINKTO)) {
|
| 6230 | 6533 | include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; |
| 6231 | 6534 | $tmpproject = new Project($this->db); |
| 6232 | 6535 | $tmpproject->fetch($object->fk_project); |
| 6233 | - if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) |
|
| 6234 | - $listofidcompanytoscan .= ',' . $tmpproject->socid; |
|
| 6536 | + if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) { |
|
| 6537 | + $listofidcompanytoscan .= ',' . $tmpproject->socid; |
|
| 6538 | + } |
|
| 6235 | 6539 | unset($tmpproject); |
| 6236 | 6540 | } |
| 6237 | 6541 | |
@@ -6267,8 +6571,9 @@ discard block |
||
| 6267 | 6571 | foreach ($possiblelinks as $key => $possiblelink) {
|
| 6268 | 6572 | $num = 0; |
| 6269 | 6573 | |
| 6270 | - if (empty($possiblelink['enabled'])) |
|
| 6271 | - continue; |
|
| 6574 | + if (empty($possiblelink['enabled'])) { |
|
| 6575 | + continue; |
|
| 6576 | + } |
|
| 6272 | 6577 | |
| 6273 | 6578 | if (!empty($possiblelink['perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || !in_array($key, $excludelinksto))) {
|
| 6274 | 6579 | print '<div id="' . $key . 'list"' . (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ' style="display:none"' : '') . '>'; |
@@ -6319,11 +6624,13 @@ discard block |
||
| 6319 | 6624 | } |
| 6320 | 6625 | |
| 6321 | 6626 | //$linktoelem.=($linktoelem?' ':''); |
| 6322 | - if ($num > 0) |
|
| 6323 | - $linktoelemlist .= '<li><a href="#linkto' . $key . '" class="linkto dropdowncloseonclick" rel="' . $key . '">' . $langs->trans($possiblelink['label']) . ' (' . $num . ')</a></li>';
|
|
| 6627 | + if ($num > 0) { |
|
| 6628 | + $linktoelemlist .= '<li><a href="#linkto' . $key . '" class="linkto dropdowncloseonclick" rel="' . $key . '">' . $langs->trans($possiblelink['label']) . ' (' . $num . ')</a></li>'; |
|
| 6629 | + } |
|
| 6324 | 6630 | //else $linktoelem.=$langs->trans($possiblelink['label']); |
| 6325 | - else |
|
| 6326 | - $linktoelemlist .= '<li><span class="linktodisabled">' . $langs->trans($possiblelink['label']) . ' (0)</span></li>'; |
|
| 6631 | + else { |
|
| 6632 | + $linktoelemlist .= '<li><span class="linktodisabled">' . $langs->trans($possiblelink['label']) . ' (0)</span></li>'; |
|
| 6633 | + } |
|
| 6327 | 6634 | } |
| 6328 | 6635 | } |
| 6329 | 6636 | |
@@ -6381,8 +6688,9 @@ discard block |
||
| 6381 | 6688 | $disabled = ($disabled ? ' disabled' : ''); |
| 6382 | 6689 | |
| 6383 | 6690 | $resultyesno = '<select class="flat width75" id="' . $htmlname . '" name="' . $htmlname . '"' . $disabled . '>' . "\n"; |
| 6384 | - if ($useempty) |
|
| 6385 | - $resultyesno .= '<option value="-1"' . (($value < 0) ? ' selected' : '') . '> </option>' . "\n"; |
|
| 6691 | + if ($useempty) { |
|
| 6692 | + $resultyesno .= '<option value="-1"' . (($value < 0) ? ' selected' : '') . '> </option>' . "\n"; |
|
| 6693 | + } |
|
| 6386 | 6694 | if (("$value" == 'yes') || ($value == 1)) {
|
| 6387 | 6695 | $resultyesno .= '<option value="' . $yes . '" selected>' . $langs->trans("Yes") . '</option>' . "\n";
|
| 6388 | 6696 | $resultyesno .= '<option value="' . $no . '">' . $langs->trans("No") . '</option>' . "\n";
|
@@ -6461,10 +6769,12 @@ discard block |
||
| 6461 | 6769 | global $langs, $conf, $hookmanager; |
| 6462 | 6770 | |
| 6463 | 6771 | $ret = ''; |
| 6464 | - if (empty($fieldid)) |
|
| 6465 | - $fieldid = 'rowid'; |
|
| 6466 | - if (empty($fieldref)) |
|
| 6467 | - $fieldref = 'ref'; |
|
| 6772 | + if (empty($fieldid)) { |
|
| 6773 | + $fieldid = 'rowid'; |
|
| 6774 | + } |
|
| 6775 | + if (empty($fieldref)) { |
|
| 6776 | + $fieldref = 'ref'; |
|
| 6777 | + } |
|
| 6468 | 6778 | |
| 6469 | 6779 | // Add where from hooks |
| 6470 | 6780 | if (is_object($hookmanager)) {
|
@@ -6503,8 +6813,9 @@ discard block |
||
| 6503 | 6813 | $ret .= '<!-- Start banner content --><div style="vertical-align: middle">'; |
| 6504 | 6814 | |
| 6505 | 6815 | // Right part of banner |
| 6506 | - if ($morehtmlright) |
|
| 6507 | - $ret .= '<div class="inline-block floatleft">' . $morehtmlright . '</div>'; |
|
| 6816 | + if ($morehtmlright) { |
|
| 6817 | + $ret .= '<div class="inline-block floatleft">' . $morehtmlright . '</div>'; |
|
| 6818 | + } |
|
| 6508 | 6819 | |
| 6509 | 6820 | if ($previous_ref || $next_ref || $morehtml) {
|
| 6510 | 6821 | $ret .= '<div class="pagination paginationref"><ul class="right">'; |
@@ -6522,26 +6833,32 @@ discard block |
||
| 6522 | 6833 | |
| 6523 | 6834 | $parameters = array(); |
| 6524 | 6835 | $reshook = $hookmanager->executeHooks('moreHtmlStatus', $parameters, $object); // Note that $action and $object may have been modified by hook
|
| 6525 | - if (empty($reshook)) |
|
| 6526 | - $morehtmlstatus .= $hookmanager->resPrint; |
|
| 6527 | - else |
|
| 6528 | - $morehtmlstatus = $hookmanager->resPrint; |
|
| 6529 | - if ($morehtmlstatus) |
|
| 6530 | - $ret .= '<div class="statusref">' . $morehtmlstatus . '</div>'; |
|
| 6836 | + if (empty($reshook)) { |
|
| 6837 | + $morehtmlstatus .= $hookmanager->resPrint; |
|
| 6838 | + } else { |
|
| 6839 | + $morehtmlstatus = $hookmanager->resPrint; |
|
| 6840 | + } |
|
| 6841 | + if ($morehtmlstatus) { |
|
| 6842 | + $ret .= '<div class="statusref">' . $morehtmlstatus . '</div>'; |
|
| 6843 | + } |
|
| 6531 | 6844 | |
| 6532 | 6845 | $parameters = array(); |
| 6533 | 6846 | $reshook = $hookmanager->executeHooks('moreHtmlRef', $parameters, $object); // Note that $action and $object may have been modified by hook
|
| 6534 | - if (empty($reshook)) |
|
| 6535 | - $morehtmlref .= $hookmanager->resPrint; |
|
| 6536 | - elseif ($reshook > 0) |
|
| 6537 | - $morehtmlref = $hookmanager->resPrint; |
|
| 6847 | + if (empty($reshook)) { |
|
| 6848 | + $morehtmlref .= $hookmanager->resPrint; |
|
| 6849 | + } elseif ($reshook > 0) { |
|
| 6850 | + $morehtmlref = $hookmanager->resPrint; |
|
| 6851 | + } |
|
| 6538 | 6852 | |
| 6539 | 6853 | // Left part of banner |
| 6540 | 6854 | if ($morehtmlleft) {
|
| 6541 | - if ($conf->browser->layout == 'phone') |
|
| 6542 | - $ret .= '<div class="floatleft">' . $morehtmlleft . '</div>'; // class="center" to have photo in middle |
|
| 6543 | - else |
|
| 6544 | - $ret .= '<div class="inline-block floatleft">' . $morehtmlleft . '</div>'; |
|
| 6855 | + if ($conf->browser->layout == 'phone') { |
|
| 6856 | + $ret .= '<div class="floatleft">' . $morehtmlleft . '</div>'; |
|
| 6857 | + } |
|
| 6858 | + // class="center" to have photo in middle |
|
| 6859 | + else { |
|
| 6860 | + $ret .= '<div class="inline-block floatleft">' . $morehtmlleft . '</div>'; |
|
| 6861 | + } |
|
| 6545 | 6862 | } |
| 6546 | 6863 | |
| 6547 | 6864 | //if ($conf->browser->layout == 'phone') $ret.='<div class="clearboth"></div>'; |
@@ -6566,8 +6883,9 @@ discard block |
||
| 6566 | 6883 | $ret .= $object->label; |
| 6567 | 6884 | } else if ($object->element == 'ecm_directories') {
|
| 6568 | 6885 | $ret .= ''; |
| 6569 | - } else if ($fieldref != 'none') |
|
| 6570 | - $ret .= dol_htmlentities($object->$fieldref); |
|
| 6886 | + } else if ($fieldref != 'none') { |
|
| 6887 | + $ret .= dol_htmlentities($object->$fieldref); |
|
| 6888 | + } |
|
| 6571 | 6889 | |
| 6572 | 6890 | |
| 6573 | 6891 | if ($morehtmlref) {
|
@@ -6592,15 +6910,17 @@ discard block |
||
| 6592 | 6910 | global $conf; |
| 6593 | 6911 | |
| 6594 | 6912 | //Check if barcode is filled in the card |
| 6595 | - if (empty($object->barcode)) |
|
| 6596 | - return ''; |
|
| 6913 | + if (empty($object->barcode)) { |
|
| 6914 | + return ''; |
|
| 6915 | + } |
|
| 6597 | 6916 | |
| 6598 | 6917 | // Complete object if not complete |
| 6599 | 6918 | if (empty($object->barcode_type_code) || empty($object->barcode_type_coder)) {
|
| 6600 | 6919 | $result = $object->fetch_barcode(); |
| 6601 | 6920 | //Check if fetch_barcode() failed |
| 6602 | - if ($result < 1) |
|
| 6603 | - return '<!-- ErrorFetchBarcode -->'; |
|
| 6921 | + if ($result < 1) { |
|
| 6922 | + return '<!-- ErrorFetchBarcode -->'; |
|
| 6923 | + } |
|
| 6604 | 6924 | } |
| 6605 | 6925 | |
| 6606 | 6926 | // Barcode image |
@@ -6642,108 +6962,120 @@ discard block |
||
| 6642 | 6962 | if ($modulepart == 'societe') {
|
| 6643 | 6963 | $dir = $conf->societe->multidir_output[$entity]; |
| 6644 | 6964 | if (!empty($object->logo)) {
|
| 6645 | - if ((string) $imagesize == 'mini') |
|
| 6646 | - $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty') . '/logos/' . getImageFileNameForSize($object->logo, '_mini'); // getImageFileNameForSize include the thumbs |
|
| 6647 | - else if ((string) $imagesize == 'small') |
|
| 6648 | - $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty') . '/logos/' . getImageFileNameForSize($object->logo, '_small'); |
|
| 6649 | - else |
|
| 6650 | - $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty') . '/logos/' . $object->logo; |
|
| 6965 | + if ((string) $imagesize == 'mini') { |
|
| 6966 | + $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty') . '/logos/' . getImageFileNameForSize($object->logo, '_mini'); |
|
| 6967 | + } |
|
| 6968 | + // getImageFileNameForSize include the thumbs |
|
| 6969 | + else if ((string) $imagesize == 'small') { |
|
| 6970 | + $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty') . '/logos/' . getImageFileNameForSize($object->logo, '_small'); |
|
| 6971 | + } else { |
|
| 6972 | + $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty') . '/logos/' . $object->logo; |
|
| 6973 | + } |
|
| 6651 | 6974 | $originalfile = get_exdir(0, 0, 0, 0, $object, 'thirdparty') . '/logos/' . $object->logo; |
| 6652 | 6975 | } |
| 6653 | 6976 | $email = $object->email; |
| 6654 | - } |
|
| 6655 | - else if ($modulepart == 'contact') {
|
|
| 6977 | + } else if ($modulepart == 'contact') {
|
|
| 6656 | 6978 | $dir = $conf->societe->multidir_output[$entity] . '/contact'; |
| 6657 | 6979 | if (!empty($object->photo)) {
|
| 6658 | - if ((string) $imagesize == 'mini') |
|
| 6659 | - $file = get_exdir(0, 0, 0, 0, $object, 'contact') . '/photos/' . getImageFileNameForSize($object->photo, '_mini'); |
|
| 6660 | - else if ((string) $imagesize == 'small') |
|
| 6661 | - $file = get_exdir(0, 0, 0, 0, $object, 'contact') . '/photos/' . getImageFileNameForSize($object->photo, '_small'); |
|
| 6662 | - else |
|
| 6663 | - $file = get_exdir(0, 0, 0, 0, $object, 'contact') . '/photos/' . $object->photo; |
|
| 6980 | + if ((string) $imagesize == 'mini') { |
|
| 6981 | + $file = get_exdir(0, 0, 0, 0, $object, 'contact') . '/photos/' . getImageFileNameForSize($object->photo, '_mini'); |
|
| 6982 | + } else if ((string) $imagesize == 'small') { |
|
| 6983 | + $file = get_exdir(0, 0, 0, 0, $object, 'contact') . '/photos/' . getImageFileNameForSize($object->photo, '_small'); |
|
| 6984 | + } else { |
|
| 6985 | + $file = get_exdir(0, 0, 0, 0, $object, 'contact') . '/photos/' . $object->photo; |
|
| 6986 | + } |
|
| 6664 | 6987 | $originalfile = get_exdir(0, 0, 0, 0, $object, 'contact') . '/photos/' . $object->photo; |
| 6665 | 6988 | } |
| 6666 | 6989 | $email = $object->email; |
| 6667 | 6990 | $capture = 'user'; |
| 6668 | - } |
|
| 6669 | - else if ($modulepart == 'userphoto') {
|
|
| 6991 | + } else if ($modulepart == 'userphoto') {
|
|
| 6670 | 6992 | $dir = $conf->user->dir_output; |
| 6671 | 6993 | if (!empty($object->photo)) {
|
| 6672 | - if ((string) $imagesize == 'mini') |
|
| 6673 | - $file = get_exdir(0, 0, 0, 0, $object, 'user') . $object->id . '/' . getImageFileNameForSize($object->photo, '_mini'); |
|
| 6674 | - else if ((string) $imagesize == 'small') |
|
| 6675 | - $file = get_exdir(0, 0, 0, 0, $object, 'user') . $object->id . '/' . getImageFileNameForSize($object->photo, '_small'); |
|
| 6676 | - else |
|
| 6677 | - $file = get_exdir(0, 0, 0, 0, $object, 'user') . '/' . $object->id . '/' . $object->photo; |
|
| 6994 | + if ((string) $imagesize == 'mini') { |
|
| 6995 | + $file = get_exdir(0, 0, 0, 0, $object, 'user') . $object->id . '/' . getImageFileNameForSize($object->photo, '_mini'); |
|
| 6996 | + } else if ((string) $imagesize == 'small') { |
|
| 6997 | + $file = get_exdir(0, 0, 0, 0, $object, 'user') . $object->id . '/' . getImageFileNameForSize($object->photo, '_small'); |
|
| 6998 | + } else { |
|
| 6999 | + $file = get_exdir(0, 0, 0, 0, $object, 'user') . '/' . $object->id . '/' . $object->photo; |
|
| 7000 | + } |
|
| 6678 | 7001 | $originalfile = get_exdir(0, 0, 0, 0, $object, 'user') . '/' . $object->id . '/' . $object->photo; |
| 6679 | 7002 | } |
| 6680 | - if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) |
|
| 6681 | - $altfile = $object->id . ".jpg"; // For backward compatibility |
|
| 7003 | + if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) { |
|
| 7004 | + $altfile = $object->id . ".jpg"; |
|
| 7005 | + } |
|
| 7006 | + // For backward compatibility |
|
| 6682 | 7007 | $email = $object->email; |
| 6683 | 7008 | $capture = 'user'; |
| 6684 | - } |
|
| 6685 | - else if ($modulepart == 'memberphoto') {
|
|
| 7009 | + } else if ($modulepart == 'memberphoto') {
|
|
| 6686 | 7010 | $dir = $conf->adherent->dir_output; |
| 6687 | 7011 | if (!empty($object->photo)) {
|
| 6688 | - if ((string) $imagesize == 'mini') |
|
| 6689 | - $file = get_exdir(0, 0, 0, 0, $object, 'member') . 'photos/' . getImageFileNameForSize($object->photo, '_mini'); |
|
| 6690 | - else if ((string) $imagesize == 'small') |
|
| 6691 | - $file = get_exdir(0, 0, 0, 0, $object, 'member') . 'photos/' . getImageFileNameForSize($object->photo, '_small'); |
|
| 6692 | - else |
|
| 6693 | - $file = get_exdir(0, 0, 0, 0, $object, 'member') . 'photos/' . $object->photo; |
|
| 7012 | + if ((string) $imagesize == 'mini') { |
|
| 7013 | + $file = get_exdir(0, 0, 0, 0, $object, 'member') . 'photos/' . getImageFileNameForSize($object->photo, '_mini'); |
|
| 7014 | + } else if ((string) $imagesize == 'small') { |
|
| 7015 | + $file = get_exdir(0, 0, 0, 0, $object, 'member') . 'photos/' . getImageFileNameForSize($object->photo, '_small'); |
|
| 7016 | + } else { |
|
| 7017 | + $file = get_exdir(0, 0, 0, 0, $object, 'member') . 'photos/' . $object->photo; |
|
| 7018 | + } |
|
| 6694 | 7019 | $originalfile = get_exdir(0, 0, 0, 0, $object, 'member') . 'photos/' . $object->photo; |
| 6695 | 7020 | } |
| 6696 | - if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) |
|
| 6697 | - $altfile = $object->id . ".jpg"; // For backward compatibility |
|
| 7021 | + if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) { |
|
| 7022 | + $altfile = $object->id . ".jpg"; |
|
| 7023 | + } |
|
| 7024 | + // For backward compatibility |
|
| 6698 | 7025 | $email = $object->email; |
| 6699 | 7026 | $capture = 'user'; |
| 6700 | - } |
|
| 6701 | - else {
|
|
| 7027 | + } else {
|
|
| 6702 | 7028 | // Generic case to show photos |
| 6703 | 7029 | $dir = $conf->$modulepart->dir_output; |
| 6704 | 7030 | if (!empty($object->photo)) {
|
| 6705 | - if ((string) $imagesize == 'mini') |
|
| 6706 | - $file = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . getImageFileNameForSize($object->photo, '_mini'); |
|
| 6707 | - else if ((string) $imagesize == 'small') |
|
| 6708 | - $file = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . getImageFileNameForSize($object->photo, '_small'); |
|
| 6709 | - else |
|
| 6710 | - $file = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . $object->photo; |
|
| 7031 | + if ((string) $imagesize == 'mini') { |
|
| 7032 | + $file = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . getImageFileNameForSize($object->photo, '_mini'); |
|
| 7033 | + } else if ((string) $imagesize == 'small') { |
|
| 7034 | + $file = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . getImageFileNameForSize($object->photo, '_small'); |
|
| 7035 | + } else { |
|
| 7036 | + $file = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . $object->photo; |
|
| 7037 | + } |
|
| 6711 | 7038 | $originalfile = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . $object->photo; |
| 6712 | 7039 | } |
| 6713 | - if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) |
|
| 6714 | - $altfile = $object->id . ".jpg"; // For backward compatibility |
|
| 7040 | + if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) { |
|
| 7041 | + $altfile = $object->id . ".jpg"; |
|
| 7042 | + } |
|
| 7043 | + // For backward compatibility |
|
| 6715 | 7044 | $email = $object->email; |
| 6716 | 7045 | } |
| 6717 | 7046 | |
| 6718 | - if ($forcecapture) |
|
| 6719 | - $capture = $forcecapture; |
|
| 7047 | + if ($forcecapture) { |
|
| 7048 | + $capture = $forcecapture; |
|
| 7049 | + } |
|
| 6720 | 7050 | |
| 6721 | 7051 | if ($dir) {
|
| 6722 | 7052 | if ($file && file_exists($dir . "/" . $file)) {
|
| 6723 | 7053 | if ($addlinktofullsize) {
|
| 6724 | 7054 | $urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 0, '&entity=' . $entity); |
| 6725 | - if ($urladvanced) |
|
| 6726 | - $ret .= '<a href="' . $urladvanced . '">'; |
|
| 6727 | - else |
|
| 6728 | - $ret .= '<a href="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($originalfile) . '&cache=' . $cache . '">'; |
|
| 7055 | + if ($urladvanced) { |
|
| 7056 | + $ret .= '<a href="' . $urladvanced . '">'; |
|
| 7057 | + } else { |
|
| 7058 | + $ret .= '<a href="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($originalfile) . '&cache=' . $cache . '">'; |
|
| 7059 | + } |
|
| 6729 | 7060 | } |
| 6730 | 7061 | $ret .= '<img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="Photo" id="photologo' . (preg_replace('/[^a-z]/i', '_', $file)) . '" ' . ($width ? ' width="' . $width . '"' : '') . ($height ? ' height="' . $height . '"' : '') . ' src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($file) . '&cache=' . $cache . '">';
|
| 6731 | - if ($addlinktofullsize) |
|
| 6732 | - $ret .= '</a>'; |
|
| 6733 | - } |
|
| 6734 | - else if ($altfile && file_exists($dir . "/" . $altfile)) {
|
|
| 7062 | + if ($addlinktofullsize) { |
|
| 7063 | + $ret .= '</a>'; |
|
| 7064 | + } |
|
| 7065 | + } else if ($altfile && file_exists($dir . "/" . $altfile)) {
|
|
| 6735 | 7066 | if ($addlinktofullsize) {
|
| 6736 | 7067 | $urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 0, '&entity=' . $entity); |
| 6737 | - if ($urladvanced) |
|
| 6738 | - $ret .= '<a href="' . $urladvanced . '">'; |
|
| 6739 | - else |
|
| 6740 | - $ret .= '<a href="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($originalfile) . '&cache=' . $cache . '">'; |
|
| 7068 | + if ($urladvanced) { |
|
| 7069 | + $ret .= '<a href="' . $urladvanced . '">'; |
|
| 7070 | + } else { |
|
| 7071 | + $ret .= '<a href="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($originalfile) . '&cache=' . $cache . '">'; |
|
| 7072 | + } |
|
| 6741 | 7073 | } |
| 6742 | 7074 | $ret .= '<img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="Photo alt" id="photologo' . (preg_replace('/[^a-z]/i', '_', $file)) . '" class="' . $cssclass . '" ' . ($width ? ' width="' . $width . '"' : '') . ($height ? ' height="' . $height . '"' : '') . ' src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($altfile) . '&cache=' . $cache . '">';
|
| 6743 | - if ($addlinktofullsize) |
|
| 6744 | - $ret .= '</a>'; |
|
| 6745 | - } |
|
| 6746 | - else {
|
|
| 7075 | + if ($addlinktofullsize) { |
|
| 7076 | + $ret .= '</a>'; |
|
| 7077 | + } |
|
| 7078 | + } else {
|
|
| 6747 | 7079 | $nophoto = '/public/theme/common/nophoto.png'; |
| 6748 | 7080 | if (in_array($modulepart, array('userphoto', 'contact'))) { // For module that are "physical" users
|
| 6749 | 7081 | $nophoto = '/public/theme/common/user_anonymous.png'; |
@@ -6781,8 +7113,9 @@ discard block |
||
| 6781 | 7113 | $ret .= '<tr><td class="tdoverflow"><input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput"' . ($capture ? ' capture="' . $capture . '"' : '') . '></td></tr>'; |
| 6782 | 7114 | $ret .= '</table>'; |
| 6783 | 7115 | } |
| 6784 | - } else |
|
| 6785 | - dol_print_error('', 'Call of showphoto with wrong parameters modulepart=' . $modulepart);
|
|
| 7116 | + } else { |
|
| 7117 | + dol_print_error('', 'Call of showphoto with wrong parameters modulepart=' . $modulepart); |
|
| 7118 | + } |
|
| 6786 | 7119 | |
| 6787 | 7120 | return $ret; |
| 6788 | 7121 | } |
@@ -6809,14 +7142,17 @@ discard block |
||
| 6809 | 7142 | global $conf, $user, $langs; |
| 6810 | 7143 | |
| 6811 | 7144 | // Permettre l'exclusion de groupes |
| 6812 | - if (is_array($exclude)) |
|
| 6813 | - $excludeGroups = implode("','", $exclude);
|
|
| 7145 | + if (is_array($exclude)) { |
|
| 7146 | + $excludeGroups = implode("','", $exclude); |
|
| 7147 | + } |
|
| 6814 | 7148 | // Permettre l'inclusion de groupes |
| 6815 | - if (is_array($include)) |
|
| 6816 | - $includeGroups = implode("','", $include);
|
|
| 7149 | + if (is_array($include)) { |
|
| 7150 | + $includeGroups = implode("','", $include); |
|
| 7151 | + } |
|
| 6817 | 7152 | |
| 6818 | - if (!is_array($selected)) |
|
| 6819 | - $selected = array($selected); |
|
| 7153 | + if (!is_array($selected)) { |
|
| 7154 | + $selected = array($selected); |
|
| 7155 | + } |
|
| 6820 | 7156 | |
| 6821 | 7157 | $out = ''; |
| 6822 | 7158 | |
@@ -6828,18 +7164,20 @@ discard block |
||
| 6828 | 7164 | $sql .= " FROM " . MAIN_DB_PREFIX . "usergroup as ug "; |
| 6829 | 7165 | if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
|
| 6830 | 7166 | $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "entity as e ON e.rowid=ug.entity"; |
| 6831 | - if ($force_entity) |
|
| 6832 | - $sql .= " WHERE ug.entity IN (0," . $force_entity . ")"; |
|
| 6833 | - else |
|
| 6834 | - $sql .= " WHERE ug.entity IS NOT NULL"; |
|
| 6835 | - } |
|
| 6836 | - else {
|
|
| 7167 | + if ($force_entity) { |
|
| 7168 | + $sql .= " WHERE ug.entity IN (0," . $force_entity . ")"; |
|
| 7169 | + } else { |
|
| 7170 | + $sql .= " WHERE ug.entity IS NOT NULL"; |
|
| 7171 | + } |
|
| 7172 | + } else {
|
|
| 6837 | 7173 | $sql .= " WHERE ug.entity IN (0," . $conf->entity . ")"; |
| 6838 | 7174 | } |
| 6839 | - if (is_array($exclude) && $excludeGroups) |
|
| 6840 | - $sql .= " AND ug.rowid NOT IN ('" . $excludeGroups . "')";
|
|
| 6841 | - if (is_array($include) && $includeGroups) |
|
| 6842 | - $sql .= " AND ug.rowid IN ('" . $includeGroups . "')";
|
|
| 7175 | + if (is_array($exclude) && $excludeGroups) { |
|
| 7176 | + $sql .= " AND ug.rowid NOT IN ('" . $excludeGroups . "')"; |
|
| 7177 | + } |
|
| 7178 | + if (is_array($include) && $includeGroups) { |
|
| 7179 | + $sql .= " AND ug.rowid IN ('" . $includeGroups . "')"; |
|
| 7180 | + } |
|
| 6843 | 7181 | $sql .= " ORDER BY ug.nom ASC"; |
| 6844 | 7182 | |
| 6845 | 7183 | dol_syslog(get_class($this) . "::select_dolgroups", LOG_DEBUG); |
@@ -6854,18 +7192,21 @@ discard block |
||
| 6854 | 7192 | $num = $this->db->num_rows($resql); |
| 6855 | 7193 | $i = 0; |
| 6856 | 7194 | if ($num) {
|
| 6857 | - if ($show_empty && !$multiple) |
|
| 6858 | - $out .= '<option value="-1"' . (in_array(-1, $selected) ? ' selected' : '') . '> </option>' . "\n"; |
|
| 7195 | + if ($show_empty && !$multiple) { |
|
| 7196 | + $out .= '<option value="-1"' . (in_array(-1, $selected) ? ' selected' : '') . '> </option>' . "\n"; |
|
| 7197 | + } |
|
| 6859 | 7198 | |
| 6860 | 7199 | while ($i < $num) {
|
| 6861 | 7200 | $obj = $this->db->fetch_object($resql); |
| 6862 | 7201 | $disableline = 0; |
| 6863 | - if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) |
|
| 6864 | - $disableline = 1; |
|
| 7202 | + if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) { |
|
| 7203 | + $disableline = 1; |
|
| 7204 | + } |
|
| 6865 | 7205 | |
| 6866 | 7206 | $out .= '<option value="' . $obj->rowid . '"'; |
| 6867 | - if ($disableline) |
|
| 6868 | - $out .= ' disabled'; |
|
| 7207 | + if ($disableline) { |
|
| 7208 | + $out .= ' disabled'; |
|
| 7209 | + } |
|
| 6869 | 7210 | if ((is_object($selected[0]) && $selected[0]->id == $obj->rowid) || (!is_object($selected[0]) && in_array($obj->rowid, $selected) )) {
|
| 6870 | 7211 | $out .= ' selected'; |
| 6871 | 7212 | } |
@@ -6880,13 +7221,13 @@ discard block |
||
| 6880 | 7221 | $i++; |
| 6881 | 7222 | } |
| 6882 | 7223 | } else {
|
| 6883 | - if ($show_empty) |
|
| 6884 | - $out .= '<option value="-1"' . (in_array(-1, $selected) ? ' selected' : '') . '></option>' . "\n"; |
|
| 7224 | + if ($show_empty) { |
|
| 7225 | + $out .= '<option value="-1"' . (in_array(-1, $selected) ? ' selected' : '') . '></option>' . "\n"; |
|
| 7226 | + } |
|
| 6885 | 7227 | $out .= '<option value="" disabled>' . $langs->trans("NoUserGroupDefined") . '</option>';
|
| 6886 | 7228 | } |
| 6887 | 7229 | $out .= '</select>'; |
| 6888 | - } |
|
| 6889 | - else {
|
|
| 7230 | + } else {
|
|
| 6890 | 7231 | dol_print_error($this->db); |
| 6891 | 7232 | } |
| 6892 | 7233 | |
@@ -6922,8 +7263,9 @@ discard block |
||
| 6922 | 7263 | global $conf, $langs; |
| 6923 | 7264 | |
| 6924 | 7265 | $out = ''; |
| 6925 | - if (!empty($conf->use_javascript_ajax)) |
|
| 6926 | - $out .= '<div class="inline-block checkallactions"><input type="checkbox" id="checkallactions" name="checkallactions" class="checkallactions"></div>'; |
|
| 7266 | + if (!empty($conf->use_javascript_ajax)) { |
|
| 7267 | + $out .= '<div class="inline-block checkallactions"><input type="checkbox" id="checkallactions" name="checkallactions" class="checkallactions"></div>'; |
|
| 7268 | + } |
|
| 6927 | 7269 | $out .= '<script type="text/javascript"> |
| 6928 | 7270 | $(document).ready(function() {
|
| 6929 | 7271 | $("#checkallactions").click(function() {
|
@@ -6936,8 +7278,9 @@ discard block |
||
| 6936 | 7278 | console.log("We uncheck all");
|
| 6937 | 7279 | $(".' . $cssclass . '").prop(\'checked\', false).trigger(\'change\');
|
| 6938 | 7280 | }' . "\n"; |
| 6939 | - if ($calljsfunction) |
|
| 6940 | - $out .= 'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }';
|
|
| 7281 | + if ($calljsfunction) { |
|
| 7282 | + $out .= 'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }'; |
|
| 7283 | + } |
|
| 6941 | 7284 | $out .= ' }); |
| 6942 | 7285 | |
| 6943 | 7286 | $(".checkforselect").change(function() {
|
@@ -6985,22 +7328,25 @@ discard block |
||
| 6985 | 7328 | |
| 6986 | 7329 | $sql = 'SELECT rowid, label FROM ' . MAIN_DB_PREFIX . 'c_exp_tax_cat WHERE active = 1'; |
| 6987 | 7330 | $sql .= ' AND entity IN (0,' . getEntity('exp_tax_cat') . ')';
|
| 6988 | - if (!empty($excludeid)) |
|
| 6989 | - $sql .= ' AND rowid NOT IN (' . implode(',', $excludeid) . ')';
|
|
| 7331 | + if (!empty($excludeid)) { |
|
| 7332 | + $sql .= ' AND rowid NOT IN (' . implode(',', $excludeid) . ')'; |
|
| 7333 | + } |
|
| 6990 | 7334 | $sql .= ' ORDER BY label'; |
| 6991 | 7335 | |
| 6992 | 7336 | $resql = $db->query($sql); |
| 6993 | 7337 | if ($resql) {
|
| 6994 | 7338 | $out = '<select id="select_' . $htmlname . '" name="' . $htmlname . '" class="' . $htmlname . ' flat minwidth75imp">'; |
| 6995 | - if ($useempty) |
|
| 6996 | - $out .= '<option value="0"> </option>'; |
|
| 7339 | + if ($useempty) { |
|
| 7340 | + $out .= '<option value="0"> </option>'; |
|
| 7341 | + } |
|
| 6997 | 7342 | |
| 6998 | 7343 | while ($obj = $db->fetch_object($resql)) {
|
| 6999 | 7344 | $out .= '<option ' . ($selected == $obj->rowid ? 'selected="selected"' : '') . ' value="' . $obj->rowid . '">' . $langs->trans($obj->label) . '</option>'; |
| 7000 | 7345 | } |
| 7001 | 7346 | $out .= '</select>'; |
| 7002 | - if (!empty($htmlname) && $user->admin) |
|
| 7003 | - $out .= ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
|
| 7347 | + if (!empty($htmlname) && $user->admin) { |
|
| 7348 | + $out .= ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); |
|
| 7349 | + } |
|
| 7004 | 7350 | |
| 7005 | 7351 | if (!empty($target)) {
|
| 7006 | 7352 | $sql = "SELECT c.id FROM " . MAIN_DB_PREFIX . "c_type_fees as c WHERE c.code = 'EX_KME' AND c.active = 1"; |
@@ -7013,8 +7359,9 @@ discard block |
||
| 7013 | 7359 | $("select[name=' . $target . ']").on("change", function() {
|
| 7014 | 7360 | var current_val = $(this).val(); |
| 7015 | 7361 | if (current_val == ' . $obj->id . ') {';
|
| 7016 | - if (!empty($default_selected) || !empty($selected)) |
|
| 7017 | - $out .= '$("select[name=' . $htmlname . ']").val("' . ($default_selected > 0 ? $default_selected : $selected) . '");';
|
|
| 7362 | + if (!empty($default_selected) || !empty($selected)) { |
|
| 7363 | + $out .= '$("select[name=' . $htmlname . ']").val("' . ($default_selected > 0 ? $default_selected : $selected) . '");'; |
|
| 7364 | + } |
|
| 7018 | 7365 | |
| 7019 | 7366 | $out .= ' |
| 7020 | 7367 | $("select[name=' . $htmlname . ']").change();
|
@@ -7050,8 +7397,7 @@ discard block |
||
| 7050 | 7397 | } |
| 7051 | 7398 | } |
| 7052 | 7399 | } |
| 7053 | - } |
|
| 7054 | - else {
|
|
| 7400 | + } else {
|
|
| 7055 | 7401 | dol_print_error($db); |
| 7056 | 7402 | } |
| 7057 | 7403 | |
@@ -7076,8 +7422,9 @@ discard block |
||
| 7076 | 7422 | $resql = $db->query($sql); |
| 7077 | 7423 | if ($resql) {
|
| 7078 | 7424 | $out = '<select id="select_' . $htmlname . '" name="' . $htmlname . '" class="' . $htmlname . ' flat minwidth75imp">'; |
| 7079 | - if ($useempty) |
|
| 7080 | - $out .= '<option value="0"></option>'; |
|
| 7425 | + if ($useempty) { |
|
| 7426 | + $out .= '<option value="0"></option>'; |
|
| 7427 | + } |
|
| 7081 | 7428 | |
| 7082 | 7429 | while ($obj = $db->fetch_object($resql)) {
|
| 7083 | 7430 | $out .= '<option ' . ($selected == $obj->rowid ? 'selected="selected"' : '') . ' value="' . $obj->rowid . '">' . price($obj->range_ik, 0, $langs, 1, 0) . '</option>'; |
@@ -7110,14 +7457,17 @@ discard block |
||
| 7110 | 7457 | $resql = $db->query($sql); |
| 7111 | 7458 | if ($resql) {
|
| 7112 | 7459 | $out = '<select id="select_' . $htmlname . '" name="' . $htmlname . '" class="' . $htmlname . ' flat minwidth75imp">'; |
| 7113 | - if ($useempty) |
|
| 7114 | - $out .= '<option value="0"></option>'; |
|
| 7115 | - if ($allchoice) |
|
| 7116 | - $out .= '<option value="-1">' . $langs->trans('AllExpenseReport') . '</option>';
|
|
| 7460 | + if ($useempty) { |
|
| 7461 | + $out .= '<option value="0"></option>'; |
|
| 7462 | + } |
|
| 7463 | + if ($allchoice) { |
|
| 7464 | + $out .= '<option value="-1">' . $langs->trans('AllExpenseReport') . '</option>'; |
|
| 7465 | + } |
|
| 7117 | 7466 | |
| 7118 | 7467 | $field = 'code'; |
| 7119 | - if ($useid) |
|
| 7120 | - $field = 'id'; |
|
| 7468 | + if ($useid) { |
|
| 7469 | + $field = 'id'; |
|
| 7470 | + } |
|
| 7121 | 7471 | |
| 7122 | 7472 | while ($obj = $db->fetch_object($resql)) {
|
| 7123 | 7473 | $key = $langs->trans($obj->code); |
@@ -115,8 +115,9 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | // Fill array 'array_options' with data from add form |
| 117 | 117 | $ret = $extrafields->setOptionalsFromPost($extralabels, $object); |
| 118 | - if ($ret < 0) |
|
| 119 | - $error++; |
|
| 118 | + if ($ret < 0) { |
|
| 119 | + $error++; |
|
| 120 | + } |
|
| 120 | 121 | |
| 121 | 122 | if (empty($object->label)) {
|
| 122 | 123 | $error++; |
@@ -161,8 +162,9 @@ discard block |
||
| 161 | 162 | |
| 162 | 163 | // Fill array 'array_options' with data from add form |
| 163 | 164 | $ret = $extrafields->setOptionalsFromPost($extralabels, $object); |
| 164 | - if ($ret < 0) |
|
| 165 | - $error++; |
|
| 165 | + if ($ret < 0) { |
|
| 166 | + $error++; |
|
| 167 | + } |
|
| 166 | 168 | |
| 167 | 169 | $ret = $object->update($user); |
| 168 | 170 | |
@@ -271,8 +273,9 @@ discard block |
||
| 271 | 273 | print '<td align="center">' . yn($objp->vote) . '</td>'; |
| 272 | 274 | if ($user->rights->adherent->configurer) {
|
| 273 | 275 | print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=edit&rowid=' . $objp->rowid . '">' . img_edit() . '</a></td>'; |
| 274 | - } else |
|
| 275 | - print '<td align="right"> </td>'; |
|
| 276 | + } else { |
|
| 277 | + print '<td align="right"> </td>'; |
|
| 278 | + } |
|
| 276 | 279 | print "</tr>"; |
| 277 | 280 | $i++; |
| 278 | 281 | } |
@@ -280,8 +283,7 @@ discard block |
||
| 280 | 283 | print '</div>'; |
| 281 | 284 | |
| 282 | 285 | print '</form>'; |
| 283 | - } |
|
| 284 | - else {
|
|
| 286 | + } else {
|
|
| 285 | 287 | dol_print_error($db); |
| 286 | 288 | } |
| 287 | 289 | } |
@@ -470,10 +472,11 @@ discard block |
||
| 470 | 472 | $nbtotalofrecords = ''; |
| 471 | 473 | if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
| 472 | 474 | $resql = $db->query($sql); |
| 473 | - if ($resql) |
|
| 474 | - $nbtotalofrecords = $db->num_rows($result); |
|
| 475 | - else |
|
| 476 | - dol_print_error($db); |
|
| 475 | + if ($resql) { |
|
| 476 | + $nbtotalofrecords = $db->num_rows($result); |
|
| 477 | + } else { |
|
| 478 | + dol_print_error($db); |
|
| 479 | + } |
|
| 477 | 480 | if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
| 478 | 481 | $page = 0; |
| 479 | 482 | $offset = 0; |
@@ -513,18 +516,24 @@ discard block |
||
| 513 | 516 | } |
| 514 | 517 | |
| 515 | 518 | $param = "&rowid=" . $object->id; |
| 516 | - if (!empty($status)) |
|
| 517 | - $param .= "&status=" . $status; |
|
| 518 | - if (!empty($search_lastname)) |
|
| 519 | - $param .= "&search_lastname=" . $search_lastname; |
|
| 520 | - if (!empty($search_firstname)) |
|
| 521 | - $param .= "&search_firstname=" . $search_firstname; |
|
| 522 | - if (!empty($search_login)) |
|
| 523 | - $param .= "&search_login=" . $search_login; |
|
| 524 | - if (!empty($search_email)) |
|
| 525 | - $param .= "&search_email=" . $search_email; |
|
| 526 | - if (!empty($filter)) |
|
| 527 | - $param .= "&filter=" . $filter; |
|
| 519 | + if (!empty($status)) { |
|
| 520 | + $param .= "&status=" . $status; |
|
| 521 | + } |
|
| 522 | + if (!empty($search_lastname)) { |
|
| 523 | + $param .= "&search_lastname=" . $search_lastname; |
|
| 524 | + } |
|
| 525 | + if (!empty($search_firstname)) { |
|
| 526 | + $param .= "&search_firstname=" . $search_firstname; |
|
| 527 | + } |
|
| 528 | + if (!empty($search_login)) { |
|
| 529 | + $param .= "&search_login=" . $search_login; |
|
| 530 | + } |
|
| 531 | + if (!empty($search_email)) { |
|
| 532 | + $param .= "&search_email=" . $search_email; |
|
| 533 | + } |
|
| 534 | + if (!empty($filter)) { |
|
| 535 | + $param .= "&filter=" . $filter; |
|
| 536 | + } |
|
| 528 | 537 | |
| 529 | 538 | if ($sall) {
|
| 530 | 539 | print $langs->trans("Filter") . " (" . $langs->trans("Lastname") . ", " . $langs->trans("Firstname") . ", " . $langs->trans("EMail") . ", " . $langs->trans("Address") . " " . $langs->trans("or") . " " . $langs->trans("Town") . "): " . $sall;
|
@@ -630,10 +639,10 @@ discard block |
||
| 630 | 639 | print '<td align="left" class="nowrap">'; |
| 631 | 640 | if ($objp->subscription == 'yes') {
|
| 632 | 641 | print $langs->trans("SubscriptionNotReceived");
|
| 633 | - if ($objp->statut > 0) |
|
| 634 | - print " " . img_warning(); |
|
| 635 | - } |
|
| 636 | - else {
|
|
| 642 | + if ($objp->statut > 0) { |
|
| 643 | + print " " . img_warning(); |
|
| 644 | + } |
|
| 645 | + } else {
|
|
| 637 | 646 | print ' '; |
| 638 | 647 | } |
| 639 | 648 | print '</td>'; |
@@ -28,40 +28,80 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
|
| 30 | 30 | //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
|
| 31 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
|
| 32 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
|
| 33 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
|
|
| 34 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
|
|
| 35 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
|
| 36 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
|
| 37 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
|
| 31 | +if (! defined('NOREQUIRESOC')) { |
|
| 32 | + define('NOREQUIRESOC','1'); |
|
| 33 | +} |
|
| 34 | +if (! defined('NOREQUIRETRAN')) { |
|
| 35 | + define('NOREQUIRETRAN','1'); |
|
| 36 | +} |
|
| 37 | +if (! defined('NOCSRFCHECK')) { |
|
| 38 | + define('NOCSRFCHECK','1'); |
|
| 39 | +} |
|
| 40 | +if (! defined('NOTOKENRENEWAL')) { |
|
| 41 | + define('NOTOKENRENEWAL','1'); |
|
| 42 | +} |
|
| 43 | +if (! defined('NOREQUIREMENU')) { |
|
| 44 | + define('NOREQUIREMENU','1'); |
|
| 45 | +} |
|
| 46 | +if (! defined('NOREQUIREHTML')) { |
|
| 47 | + define('NOREQUIREHTML','1'); |
|
| 48 | +} |
|
| 49 | +if (! defined('NOREQUIREAJAX')) { |
|
| 50 | + define('NOREQUIREAJAX','1'); |
|
| 51 | +} |
|
| 38 | 52 | |
| 39 | 53 | // Some value of modulepart can be used to get resources that are public so no login are required. |
| 40 | 54 | // Note that only directory logo is free to access without login. |
| 41 | 55 | if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'mycompany' && preg_match('/^\/?logos\//', $_GET['file']))
|
| 42 | 56 | {
|
| 43 | - if (! defined("NOLOGIN")) define("NOLOGIN",1);
|
|
| 44 | - if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
|
|
| 45 | - if (! defined("NOIPCHECK")) define("NOIPCHECK",1); // Do not check IP defined into conf $dolibarr_main_restrict_ip
|
|
| 57 | + if (! defined("NOLOGIN")) { |
|
| 58 | + define("NOLOGIN",1); |
|
| 59 | + } |
|
| 60 | + if (! defined("NOCSRFCHECK")) { |
|
| 61 | + define("NOCSRFCHECK",1); |
|
| 62 | + } |
|
| 63 | + // We accept to go on this page from external web site. |
|
| 64 | + if (! defined("NOIPCHECK")) { |
|
| 65 | + define("NOIPCHECK",1); |
|
| 66 | + } |
|
| 67 | + // Do not check IP defined into conf $dolibarr_main_restrict_ip |
|
| 46 | 68 | } |
| 47 | 69 | // For direct external download link, we don't need to load/check we are into a login session |
| 48 | 70 | if (isset($_GET["hashp"]) && ! defined("NOLOGIN"))
|
| 49 | 71 | {
|
| 50 | - if (! defined("NOLOGIN")) define("NOLOGIN",1);
|
|
| 51 | - if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
|
|
| 52 | - if (! defined("NOIPCHECK")) define("NOIPCHECK",1); // Do not check IP defined into conf $dolibarr_main_restrict_ip
|
|
| 72 | + if (! defined("NOLOGIN")) { |
|
| 73 | + define("NOLOGIN",1); |
|
| 74 | + } |
|
| 75 | + if (! defined("NOCSRFCHECK")) { |
|
| 76 | + define("NOCSRFCHECK",1); |
|
| 77 | + } |
|
| 78 | + // We accept to go on this page from external web site. |
|
| 79 | + if (! defined("NOIPCHECK")) { |
|
| 80 | + define("NOIPCHECK",1); |
|
| 81 | + } |
|
| 82 | + // Do not check IP defined into conf $dolibarr_main_restrict_ip |
|
| 53 | 83 | } |
| 54 | 84 | // Some value of modulepart can be used to get resources that are public so no login are required. |
| 55 | 85 | if ((isset($_GET["modulepart"]) && $_GET["modulepart"] == 'medias')) |
| 56 | 86 | {
|
| 57 | - if (! defined("NOLOGIN")) define("NOLOGIN",1);
|
|
| 58 | - if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
|
|
| 59 | - if (! defined("NOIPCHECK")) define("NOIPCHECK",1); // Do not check IP defined into conf $dolibarr_main_restrict_ip
|
|
| 87 | + if (! defined("NOLOGIN")) { |
|
| 88 | + define("NOLOGIN",1); |
|
| 89 | + } |
|
| 90 | + if (! defined("NOCSRFCHECK")) { |
|
| 91 | + define("NOCSRFCHECK",1); |
|
| 92 | + } |
|
| 93 | + // We accept to go on this page from external web site. |
|
| 94 | + if (! defined("NOIPCHECK")) { |
|
| 95 | + define("NOIPCHECK",1); |
|
| 96 | + } |
|
| 97 | + // Do not check IP defined into conf $dolibarr_main_restrict_ip |
|
| 60 | 98 | } |
| 61 | 99 | |
| 62 | 100 | // For multicompany |
| 63 | 101 | $entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); |
| 64 | -if (is_numeric($entity)) define("DOLENTITY", $entity);
|
|
| 102 | +if (is_numeric($entity)) { |
|
| 103 | + define("DOLENTITY", $entity); |
|
| 104 | +} |
|
| 65 | 105 | |
| 66 | 106 | /** |
| 67 | 107 | * Header empty |
@@ -91,9 +131,16 @@ discard block |
||
| 91 | 131 | $entity=GETPOST('entity','int')?GETPOST('entity','int'):$conf->entity;
|
| 92 | 132 | |
| 93 | 133 | // Security check |
| 94 | -if (empty($modulepart) && empty($hashp)) accessforbidden('Bad link. Bad value for parameter modulepart',0,0,1);
|
|
| 95 | -if (empty($original_file) && empty($hashp) && $modulepart != 'barcode') accessforbidden('Bad link. Missing identification to find file (original_file or hashp)',0,0,1);
|
|
| 96 | -if ($modulepart == 'fckeditor') $modulepart='medias'; // For backward compatibility |
|
| 134 | +if (empty($modulepart) && empty($hashp)) { |
|
| 135 | + accessforbidden('Bad link. Bad value for parameter modulepart',0,0,1); |
|
| 136 | +} |
|
| 137 | +if (empty($original_file) && empty($hashp) && $modulepart != 'barcode') { |
|
| 138 | + accessforbidden('Bad link. Missing identification to find file (original_file or hashp)',0,0,1); |
|
| 139 | +} |
|
| 140 | +if ($modulepart == 'fckeditor') { |
|
| 141 | + $modulepart='medias'; |
|
| 142 | +} |
|
| 143 | +// For backward compatibility |
|
| 97 | 144 | |
| 98 | 145 | |
| 99 | 146 | |
@@ -117,8 +164,9 @@ discard block |
||
| 117 | 164 | {
|
| 118 | 165 | header('Cache-Control: max-age=3600, public, must-revalidate');
|
| 119 | 166 | header('Pragma: cache'); // This is to avoid having Pragma: no-cache
|
| 120 | - } |
|
| 121 | - else header('Cache-Control: no-cache');
|
|
| 167 | + } else { |
|
| 168 | + header('Cache-Control: no-cache'); |
|
| 169 | + } |
|
| 122 | 170 | //print $dolibarr_nocache; exit; |
| 123 | 171 | } |
| 124 | 172 | |
@@ -132,32 +180,34 @@ discard block |
||
| 132 | 180 | {
|
| 133 | 181 | $tmp = explode('/', $ecmfile->filepath, 2); // $ecmfile->filepath is relative to document directory
|
| 134 | 182 | // filepath can be 'users/X' or 'X/propale/PR11111' |
| 135 | - if (is_numeric($tmp[0])) // If first tmp is numeric, it is subdir of company for multicompany, we take next part. |
|
| 183 | + if (is_numeric($tmp[0])) { |
|
| 184 | + // If first tmp is numeric, it is subdir of company for multicompany, we take next part. |
|
| 136 | 185 | {
|
| 137 | - $tmp = explode('/', $tmp[1], 2);
|
|
| 186 | + $tmp = explode('/', $tmp[1], 2); |
|
| 187 | + } |
|
| 138 | 188 | } |
| 139 | 189 | $moduleparttocheck = $tmp[0]; // moduleparttocheck is first part of path |
| 140 | 190 | |
| 141 | - if ($modulepart) // Not required, so often not defined, for link using public hashp parameter. |
|
| 191 | + if ($modulepart) { |
|
| 192 | + // Not required, so often not defined, for link using public hashp parameter. |
|
| 142 | 193 | {
|
| 143 | 194 | if ($moduleparttocheck == $modulepart) |
| 144 | 195 | {
|
| 145 | 196 | // We remove first level of directory |
| 146 | - $original_file = (($tmp[1]?$tmp[1].'/':'').$ecmfile->filename); // this is relative to module dir |
|
| 197 | + $original_file = (($tmp[1]?$tmp[1].'/':'').$ecmfile->filename); |
|
| 198 | + } |
|
| 199 | + // this is relative to module dir |
|
| 147 | 200 | //var_dump($original_file); exit; |
| 148 | - } |
|
| 149 | - else |
|
| 201 | + } else |
|
| 150 | 202 | {
|
| 151 | 203 | accessforbidden('Bad link. File is from another module part.',0,0,1);
|
| 152 | 204 | } |
| 153 | - } |
|
| 154 | - else |
|
| 205 | + } else |
|
| 155 | 206 | {
|
| 156 | 207 | $modulepart = $moduleparttocheck; |
| 157 | 208 | $original_file = (($tmp[1]?$tmp[1].'/':'').$ecmfile->filename); // this is relative to module dir |
| 158 | 209 | } |
| 159 | - } |
|
| 160 | - else |
|
| 210 | + } else |
|
| 161 | 211 | {
|
| 162 | 212 | $langs->load("errors");
|
| 163 | 213 | accessforbidden($langs->trans("ErrorFileNotFoundWithSharedLink"),0,0,1);
|
@@ -166,8 +216,11 @@ discard block |
||
| 166 | 216 | |
| 167 | 217 | // Define mime type |
| 168 | 218 | $type = 'application/octet-stream'; |
| 169 | -if (GETPOST('type','alpha')) $type=GETPOST('type','alpha');
|
|
| 170 | -else $type=dol_mimetype($original_file); |
|
| 219 | +if (GETPOST('type','alpha')) { |
|
| 220 | + $type=GETPOST('type','alpha'); |
|
| 221 | +} else { |
|
| 222 | + $type=dol_mimetype($original_file); |
|
| 223 | +} |
|
| 171 | 224 | |
| 172 | 225 | // Security: Delete string ../ into $original_file |
| 173 | 226 | $original_file = str_replace("../","/", $original_file);
|
@@ -176,7 +229,9 @@ discard block |
||
| 176 | 229 | $refname=basename(dirname($original_file)."/"); |
| 177 | 230 | |
| 178 | 231 | // Security check |
| 179 | -if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart');
|
|
| 232 | +if (empty($modulepart)) { |
|
| 233 | + accessforbidden('Bad value for parameter modulepart'); |
|
| 234 | +} |
|
| 180 | 235 | |
| 181 | 236 | $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); |
| 182 | 237 | $accessallowed = $check_access['accessallowed']; |
@@ -187,8 +242,7 @@ discard block |
||
| 187 | 242 | {
|
| 188 | 243 | $accessallowed = 1; // When using hashp, link is public so we force $accessallowed |
| 189 | 244 | $sqlprotectagainstexternals = ''; |
| 190 | -} |
|
| 191 | -else |
|
| 245 | +} else |
|
| 192 | 246 | {
|
| 193 | 247 | // Basic protection (against external users only) |
| 194 | 248 | if ($user->societe_id > 0) |
@@ -256,10 +310,14 @@ discard block |
||
| 256 | 310 | $newdir=dol_osencode($dir); |
| 257 | 311 | |
| 258 | 312 | // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) |
| 259 | - if (! is_dir($newdir)) continue; |
|
| 313 | + if (! is_dir($newdir)) { |
|
| 314 | + continue; |
|
| 315 | + } |
|
| 260 | 316 | |
| 261 | 317 | $result=@include_once $newdir.$generator.'.modules.php'; |
| 262 | - if ($result) break; |
|
| 318 | + if ($result) { |
|
| 319 | + break; |
|
| 320 | + } |
|
| 263 | 321 | } |
| 264 | 322 | |
| 265 | 323 | // Load barcode class |
@@ -269,8 +327,7 @@ discard block |
||
| 269 | 327 | {
|
| 270 | 328 | $result=$module->buildBarCode($code,$encoding,$readable); |
| 271 | 329 | } |
| 272 | -} |
|
| 273 | -else // Open and return file |
|
| 330 | +} else // Open and return file |
|
| 274 | 331 | {
|
| 275 | 332 | clearstatcache(); |
| 276 | 333 | |
@@ -294,8 +351,7 @@ discard block |
||
| 294 | 351 | {
|
| 295 | 352 | top_httphead($type); |
| 296 | 353 | header('Content-Disposition: inline; filename="'.basename($fullpath_original_file).'"');
|
| 297 | - } |
|
| 298 | - else |
|
| 354 | + } else |
|
| 299 | 355 | {
|
| 300 | 356 | top_httphead('image/png');
|
| 301 | 357 | header('Content-Disposition: inline; filename="'.basename($fullpath_original_file).'"');
|
@@ -307,4 +363,6 @@ discard block |
||
| 307 | 363 | } |
| 308 | 364 | |
| 309 | 365 | |
| 310 | -if (is_object($db)) $db->close(); |
|
| 366 | +if (is_object($db)) { |
|
| 367 | + $db->close(); |
|
| 368 | +} |
|