| @@ -37,36 +37,36 @@ discard block | ||
| 37 | 37 | * \ingroup product | 
| 38 | 38 | * \brief Page to show product | 
| 39 | 39 | */ | 
| 40 | -require DOL_BASE_PATH . '/main.inc.php'; | |
| 41 | - | |
| 42 | -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php'; | |
| 43 | -require_once DOL_DOCUMENT_ROOT . '/core/class/canvas.class.php'; | |
| 44 | -require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; | |
| 45 | -require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; | |
| 46 | -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; | |
| 47 | -require_once DOL_DOCUMENT_ROOT . '/core/class/genericobject.class.php'; | |
| 48 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php'; | |
| 49 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; | |
| 50 | -require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; | |
| 51 | -require_once DOL_DOCUMENT_ROOT . '/core/modules/product/modules_product.class.php'; | |
| 40 | +require DOL_BASE_PATH.'/main.inc.php'; | |
| 41 | + | |
| 42 | +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; | |
| 43 | +require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; | |
| 44 | +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; | |
| 45 | +require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; | |
| 46 | +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; | |
| 47 | +require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; | |
| 48 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; | |
| 49 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; | |
| 50 | +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; | |
| 51 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/product/modules_product.class.php'; | |
| 52 | 52 | |
| 53 | 53 |  if (!empty($conf->propal->enabled)) {
 | 
| 54 | - require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; | |
| 54 | + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; | |
| 55 | 55 | } | 
| 56 | 56 |  if (!empty($conf->facture->enabled)) {
 | 
| 57 | - require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; | |
| 57 | + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; | |
| 58 | 58 | } | 
| 59 | 59 |  if (!empty($conf->commande->enabled)) {
 | 
| 60 | - require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; | |
| 60 | + require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; | |
| 61 | 61 | } | 
| 62 | 62 |  if (!empty($conf->accounting->enabled)) {
 | 
| 63 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; | |
| 63 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; | |
| 64 | 64 | } | 
| 65 | 65 |  if (!empty($conf->accounting->enabled)) {
 | 
| 66 | - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; | |
| 66 | + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; | |
| 67 | 67 | } | 
| 68 | 68 |  if (!empty($conf->accounting->enabled)) {
 | 
| 69 | - require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; | |
| 69 | + require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; | |
| 70 | 70 | } | 
| 71 | 71 | |
| 72 | 72 | // Load translation files required by the page | 
| @@ -111,15 +111,15 @@ discard block | ||
| 111 | 111 | $result = $object->fetch($id, $ref); | 
| 112 | 112 | |
| 113 | 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); | |
| 114 | + $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); | |
| 115 | 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); | |
| 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 |      if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {    // For backward compatiblity, we scan also old dirs
 | 
| 119 | 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";
 | |
| 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 | 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";
 | |
| 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";
 | |
| 123 | 123 | } | 
| 124 | 124 | } | 
| 125 | 125 | |
| @@ -129,7 +129,7 @@ discard block | ||
| 129 | 129 |  $canvas = !empty($object->canvas) ? $object->canvas : GETPOST("canvas");
 | 
| 130 | 130 | $objcanvas = null; | 
| 131 | 131 |  if (!empty($canvas)) {
 | 
| 132 | - require_once DOL_DOCUMENT_ROOT . '/core/class/canvas.class.php'; | |
| 132 | + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; | |
| 133 | 133 | $objcanvas = new Canvas($db, $action); | 
| 134 | 134 |      $objcanvas->getCanvas('product', 'card', $canvas);
 | 
| 135 | 135 | } | 
| @@ -159,7 +159,7 @@ discard block | ||
| 159 | 159 | $createbarcode = 0; | 
| 160 | 160 | |
| 161 | 161 |  $parameters = array('id' => $id, 'ref' => $ref, 'objcanvas' => $objcanvas);
 | 
| 162 | -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);    // Note that $action and $object may have been modified by some hooks
 | |
| 162 | +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 | |
| 163 | 163 | if ($reshook < 0) | 
| 164 | 164 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); | 
| 165 | 165 | |
| @@ -167,21 +167,21 @@ discard block | ||
| 167 | 167 | // Type | 
| 168 | 168 |      if ($action == 'setfk_product_type' && $usercancreate) {
 | 
| 169 | 169 |          $result = $object->setValueFrom('fk_product_type', GETPOST('fk_product_type'), '', null, 'text', '', $user, 'PRODUCT_MODIFY');
 | 
| 170 | -        header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id);
 | |
| 170 | +        header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
 | |
| 171 | 171 | exit; | 
| 172 | 172 | } | 
| 173 | 173 | |
| 174 | 174 | // Actions to build doc | 
| 175 | 175 | $upload_dir = $conf->produit->dir_output; | 
| 176 | 176 | $permissioncreate = $usercancreate; | 
| 177 | - include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php'; | |
| 177 | + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; | |
| 178 | 178 | |
| 179 | - include DOL_DOCUMENT_ROOT . '/core/actions_printing.inc.php'; | |
| 179 | + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; | |
| 180 | 180 | |
| 181 | 181 | // Barcode type | 
| 182 | 182 |      if ($action == 'setfk_barcode_type' && $createbarcode) {
 | 
| 183 | 183 |          $result = $object->setValueFrom('fk_barcode_type', GETPOST('fk_barcode_type'), '', null, 'text', '', $user, 'PRODUCT_MODIFY');
 | 
| 184 | -        header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id);
 | |
| 184 | +        header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
 | |
| 185 | 185 | exit; | 
| 186 | 186 | } | 
| 187 | 187 | |
| @@ -191,7 +191,7 @@ discard block | ||
| 191 | 191 | |
| 192 | 192 |          if ($result >= 0) {
 | 
| 193 | 193 |              $result = $object->setValueFrom('barcode', GETPOST('barcode'), '', null, 'text', '', $user, 'PRODUCT_MODIFY');
 | 
| 194 | -            header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id);
 | |
| 194 | +            header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
 | |
| 195 | 195 | exit; | 
| 196 | 196 |          } else {
 | 
| 197 | 197 |              $langs->load("errors");
 | 
| @@ -245,10 +245,10 @@ discard block | ||
| 245 | 245 | else | 
| 246 | 246 |                  $object->price_min = GETPOST('price_min');
 | 
| 247 | 247 | |
| 248 | -            $tva_tx_txt = GETPOST('tva_tx', 'alpha');           // tva_tx can be '8.5'  or  '8.5*'  or  '8.5 (XXX)' or '8.5* (XXX)'
 | |
| 248 | +            $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 | 249 | // We must define tva_tx, npr and local taxes | 
| 250 | 250 | $vatratecode = ''; | 
| 251 | -            $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt);     // keep remove all after the numbers and dot
 | |
| 251 | +            $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot
 | |
| 252 | 252 |              $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0;
 | 
| 253 | 253 | $localtax1 = 0; | 
| 254 | 254 | $localtax2 = 0; | 
| @@ -260,10 +260,10 @@ discard block | ||
| 260 | 260 | $vatratecode = $reg[1]; | 
| 261 | 261 | // Get record from code | 
| 262 | 262 | $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; | 
| 263 | - $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c"; | |
| 264 | - $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $mysoc->country_code . "'"; | |
| 265 | - $sql .= " AND t.taux = " . ((float) $tva_tx) . " AND t.active = 1"; | |
| 266 | - $sql .= " AND t.code ='" . $vatratecode . "'"; | |
| 263 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; | |
| 264 | + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'"; | |
| 265 | + $sql .= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; | |
| 266 | + $sql .= " AND t.code ='".$vatratecode."'"; | |
| 267 | 267 | $resql = $db->query($sql); | 
| 268 | 268 |                  if ($resql) {
 | 
| 269 | 269 | $obj = $db->fetch_object($resql); | 
| @@ -298,7 +298,7 @@ discard block | ||
| 298 | 298 |              if ($result < 0) {
 | 
| 299 | 299 | $error++; | 
| 300 | 300 | $mesg = 'Failed to get bar code type information '; | 
| 301 | - setEventMessages($mesg . $stdobject->error, $mesg . $stdobject->errors, 'errors'); | |
| 301 | + setEventMessages($mesg.$stdobject->error, $mesg.$stdobject->errors, 'errors'); | |
| 302 | 302 | } | 
| 303 | 303 | $object->barcode_type_code = $stdobject->barcode_type_code; | 
| 304 | 304 | $object->barcode_type_coder = $stdobject->barcode_type_coder; | 
| @@ -307,7 +307,7 @@ discard block | ||
| 307 | 307 |              $object->description = dol_htmlcleanlastbr(GETPOST('desc', 'none'));
 | 
| 308 | 308 |              $object->url = GETPOST('url');
 | 
| 309 | 309 |              $object->note_private = dol_htmlcleanlastbr(GETPOST('note_private', 'none'));
 | 
| 310 | - $object->note = $object->note_private; // deprecated | |
| 310 | + $object->note = $object->note_private; // deprecated | |
| 311 | 311 |              $object->customcode = GETPOST('customcode', 'alpha');
 | 
| 312 | 312 |              $object->country_id = GETPOST('country_id', 'int');
 | 
| 313 | 313 | $object->duration_value = $duration_value; | 
| @@ -358,9 +358,9 @@ discard block | ||
| 358 | 358 | // MultiPrix | 
| 359 | 359 |              if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
 | 
| 360 | 360 |                  for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
 | 
| 361 | -                    if (isset($_POST["price_" . $i])) {
 | |
| 362 | - $object->multiprices["$i"] = price2num($_POST["price_" . $i], 'MU'); | |
| 363 | - $object->multiprices_base_type["$i"] = $_POST["multiprices_base_type_" . $i]; | |
| 361 | +                    if (isset($_POST["price_".$i])) {
 | |
| 362 | + $object->multiprices["$i"] = price2num($_POST["price_".$i], 'MU'); | |
| 363 | + $object->multiprices_base_type["$i"] = $_POST["multiprices_base_type_".$i]; | |
| 364 | 364 |                      } else {
 | 
| 365 | 365 | $object->multiprices["$i"] = ""; | 
| 366 | 366 | } | 
| @@ -381,7 +381,7 @@ discard block | ||
| 381 | 381 |                  $categories = GETPOST('categories', 'array');
 | 
| 382 | 382 | $object->setCategories($categories); | 
| 383 | 383 | |
| 384 | -                header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id);
 | |
| 384 | +                header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
 | |
| 385 | 385 | exit; | 
| 386 | 386 |              } else {
 | 
| 387 | 387 | if (count($object->errors)) | 
| @@ -455,7 +455,7 @@ discard block | ||
| 455 | 455 |                  if ($result < 0) {
 | 
| 456 | 456 | $error++; | 
| 457 | 457 | $mesg = 'Failed to get bar code type information '; | 
| 458 | - setEventMessages($mesg . $stdobject->error, $mesg . $stdobject->errors, 'errors'); | |
| 458 | + setEventMessages($mesg.$stdobject->error, $mesg.$stdobject->errors, 'errors'); | |
| 459 | 459 | } | 
| 460 | 460 | $object->barcode_type_code = $stdobject->barcode_type_code; | 
| 461 | 461 | $object->barcode_type_coder = $stdobject->barcode_type_coder; | 
| @@ -545,7 +545,7 @@ discard block | ||
| 545 | 545 |                              if ($result < 1) {
 | 
| 546 | 546 | $db->rollback(); | 
| 547 | 547 |                                  setEventMessages($langs->trans('ErrorProductClone'), null, 'errors');
 | 
| 548 | -                                header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $originalId);
 | |
| 548 | +                                header("Location: ".$_SERVER["PHP_SELF"]."?id=".$originalId);
 | |
| 549 | 549 | exit; | 
| 550 | 550 | } | 
| 551 | 551 | } | 
| @@ -555,7 +555,7 @@ discard block | ||
| 555 | 555 | $db->commit(); | 
| 556 | 556 | $db->close(); | 
| 557 | 557 | |
| 558 | -                        header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
 | |
| 558 | +                        header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
 | |
| 559 | 559 | exit; | 
| 560 | 560 |                      } else {
 | 
| 561 | 561 | $id = $originalId; | 
| @@ -567,7 +567,7 @@ discard block | ||
| 567 | 567 | $action = ""; | 
| 568 | 568 | |
| 569 | 569 |                              $mesg = $langs->trans("ErrorProductAlreadyExists", $object->ref);
 | 
| 570 | -                            $mesg .= ' <a href="' . $_SERVER["PHP_SELF"] . '?ref=' . $object->ref . '">' . $langs->trans("ShowCardHere") . '</a>.';
 | |
| 570 | +                            $mesg .= ' <a href="'.$_SERVER["PHP_SELF"].'?ref='.$object->ref.'">'.$langs->trans("ShowCardHere").'</a>.';
 | |
| 571 | 571 | setEventMessages($mesg, null, 'errors'); | 
| 572 | 572 | $object->fetch($id); | 
| 573 | 573 |                          } else {
 | 
| @@ -597,7 +597,7 @@ discard block | ||
| 597 | 597 | $result = $object->delete($user); | 
| 598 | 598 | |
| 599 | 599 |          if ($result > 0) {
 | 
| 600 | -            header('Location: ' . DOL_URL_ROOT . '/product/list.php?type=' . $object->type . '&delprod=' . urlencode($object->ref));
 | |
| 600 | +            header('Location: '.DOL_URL_ROOT.'/product/list.php?type='.$object->type.'&delprod='.urlencode($object->ref));
 | |
| 601 | 601 | exit; | 
| 602 | 602 |          } else {
 | 
| 603 | 603 | setEventMessages($langs->trans($object->error), null, 'errors'); | 
| @@ -663,7 +663,7 @@ discard block | ||
| 663 | 663 | $pu_ttc = $object->multiprices_ttc[$soc->price_level]; | 
| 664 | 664 | $price_base_type = $object->multiprices_base_type[$soc->price_level]; | 
| 665 | 665 |              } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
 | 
| 666 | - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; | |
| 666 | + require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; | |
| 667 | 667 | |
| 668 | 668 | $prodcustprice = new Productcustomerprice($db); | 
| 669 | 669 | |
| @@ -709,11 +709,11 @@ discard block | ||
| 709 | 709 |                      $object->id, GETPOST('remise_percent'), $price_base_type, $pu_ttc, 0, 0, -1, 0, 0, 0, $buyprice, '', '', '', 0, $object->fk_unit
 | 
| 710 | 710 | ); | 
| 711 | 711 |                  if ($result > 0) {
 | 
| 712 | -                    header("Location: " . DOL_URL_ROOT . "/comm/propal/card.php?id=" . $propal->id);
 | |
| 712 | +                    header("Location: ".DOL_URL_ROOT."/comm/propal/card.php?id=".$propal->id);
 | |
| 713 | 713 | return; | 
| 714 | 714 | } | 
| 715 | 715 | |
| 716 | -                setEventMessages($langs->trans("ErrorUnknown") . ": $result", null, 'errors');
 | |
| 716 | +                setEventMessages($langs->trans("ErrorUnknown").": $result", null, 'errors');
 | |
| 717 | 717 |              } elseif (GETPOST('commandeid') > 0) {
 | 
| 718 | 718 | // Define cost price for margin calculation | 
| 719 | 719 | $buyprice = 0; | 
| @@ -731,7 +731,7 @@ discard block | ||
| 731 | 731 | ); | 
| 732 | 732 | |
| 733 | 733 |                  if ($result > 0) {
 | 
| 734 | -                    header("Location: " . DOL_URL_ROOT . "/commande/card.php?id=" . $commande->id);
 | |
| 734 | +                    header("Location: ".DOL_URL_ROOT."/commande/card.php?id=".$commande->id);
 | |
| 735 | 735 | exit; | 
| 736 | 736 | } | 
| 737 | 737 |              } elseif (GETPOST('factureid') > 0) {
 | 
| @@ -749,7 +749,7 @@ discard block | ||
| 749 | 749 | ); | 
| 750 | 750 | |
| 751 | 751 |                  if ($result > 0) {
 | 
| 752 | -                    header("Location: " . DOL_URL_ROOT . "/compta/facture/card.php?facid=" . $facture->id);
 | |
| 752 | +                    header("Location: ".DOL_URL_ROOT."/compta/facture/card.php?facid=".$facture->id);
 | |
| 753 | 753 | exit; | 
| 754 | 754 | } | 
| 755 | 755 | } | 
| @@ -770,11 +770,11 @@ discard block | ||
| 770 | 770 | $helpurl = ''; | 
| 771 | 771 | $shortlabel = dol_trunc($object->label, 16); | 
| 772 | 772 |  if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) {
 | 
| 773 | -    $title = $langs->trans('Product') . " " . $shortlabel . " - " . $langs->trans('Card');
 | |
| 773 | +    $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Card');
 | |
| 774 | 774 | $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; | 
| 775 | 775 | } | 
| 776 | 776 |  if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) {
 | 
| 777 | -    $title = $langs->trans('Service') . " " . $shortlabel . " - " . $langs->trans('Card');
 | |
| 777 | +    $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Card');
 | |
| 778 | 778 | $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; | 
| 779 | 779 | } | 
| 780 | 780 | |
| @@ -792,7 +792,7 @@ discard block | ||
| 792 | 792 | $module = strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM); | 
| 793 | 793 |      $dirbarcode = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']);
 | 
| 794 | 794 |      foreach ($dirbarcode as $dirroot) {
 | 
| 795 | - $res = dol_include_once($dirroot . $module . '.php'); | |
| 795 | + $res = dol_include_once($dirroot.$module.'.php'); | |
| 796 | 796 | if ($res) | 
| 797 | 797 | break; | 
| 798 | 798 | } | 
| @@ -813,7 +813,7 @@ discard block | ||
| 813 | 813 |              dol_print_error('', $object->error);
 | 
| 814 | 814 | } | 
| 815 | 815 | $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates | 
| 816 | - $objcanvas->display_canvas($action); // Show template | |
| 816 | + $objcanvas->display_canvas($action); // Show template | |
| 817 | 817 | } | 
| 818 | 818 |  else {
 | 
| 819 | 819 | // ----------------------------------------- | 
| @@ -821,14 +821,14 @@ discard block | ||
| 821 | 821 | // ----------------------------------------- | 
| 822 | 822 |      if ($action == 'create' && $usercancreate) {
 | 
| 823 | 823 | //WYSIWYG Editor | 
| 824 | - require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; | |
| 824 | + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; | |
| 825 | 825 | |
| 826 | 826 | // Load object modCodeProduct | 
| 827 | 827 | $module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON : 'mod_codeproduct_leopard'); | 
| 828 | 828 |          if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') {
 | 
| 829 | 829 | $module = substr($module, 0, dol_strlen($module) - 4); | 
| 830 | 830 | } | 
| 831 | -        $result = dol_include_once('/core/modules/product/' . $module . '.php');
 | |
| 831 | +        $result = dol_include_once('/core/modules/product/'.$module.'.php');
 | |
| 832 | 832 |          if ($result > 0) {
 | 
| 833 | 833 | $modCodeProduct = new $module(); | 
| 834 | 834 | } | 
| @@ -836,10 +836,10 @@ discard block | ||
| 836 | 836 |          dol_set_focus('input[name="ref"]');
 | 
| 837 | 837 | |
| 838 | 838 | //print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; | 
| 839 | - print '<form method="POST" href="' . BASE_URI . '?controller=product&method=card" method="POST">'; | |
| 840 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 839 | + print '<form method="POST" href="'.BASE_URI.'?controller=product&method=card" method="POST">'; | |
| 840 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 841 | 841 | print '<input type="hidden" name="action" value="add">'; | 
| 842 | - print '<input type="hidden" name="type" value="' . $type . '">' . "\n"; | |
| 842 | + print '<input type="hidden" name="type" value="'.$type.'">'."\n"; | |
| 843 | 843 | if (!empty($modCodeProduct->code_auto)) | 
| 844 | 844 |          {
 | 
| 845 | 845 | print '<input type="hidden" name="code_auto" value="1">'; | 
| @@ -867,30 +867,30 @@ discard block | ||
| 867 | 867 | $tmpcode = ''; | 
| 868 | 868 | if (!empty($modCodeProduct->code_auto)) | 
| 869 | 869 | $tmpcode = $modCodeProduct->getNextValue($object, $type); | 
| 870 | -        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) . '">';
 | |
| 870 | +        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 | 871 |          if ($refalreadyexists) {
 | 
| 872 | 872 |              print $langs->trans("RefAlreadyExists");
 | 
| 873 | 873 | } | 
| 874 | 874 | print '</td></tr>'; | 
| 875 | 875 | |
| 876 | 876 | // Label | 
| 877 | -        print '<tr><td class="fieldrequired">' . $langs->trans("Label") . '</td><td colspan="3"><input name="label" class="minwidth300 maxwidth400onsmartphone" maxlength="255" value="' . dol_escape_htmltag(GETPOST('label')) . '"></td></tr>';
 | |
| 877 | +        print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td colspan="3"><input name="label" class="minwidth300 maxwidth400onsmartphone" maxlength="255" value="'.dol_escape_htmltag(GETPOST('label')).'"></td></tr>';
 | |
| 878 | 878 | |
| 879 | 879 | // On sell | 
| 880 | -        print '<tr><td class="fieldrequired">' . $langs->trans("Status") . ' (' . $langs->trans("Sell") . ')</td><td colspan="3">';
 | |
| 880 | +        print '<tr><td class="fieldrequired">'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td colspan="3">';
 | |
| 881 | 881 |          $statutarray = array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell"));
 | 
| 882 | 882 |          print $form->selectarray('statut', $statutarray, GETPOST('statut'));
 | 
| 883 | 883 | print '</td></tr>'; | 
| 884 | 884 | |
| 885 | 885 | // To buy | 
| 886 | -        print '<tr><td class="fieldrequired">' . $langs->trans("Status") . ' (' . $langs->trans("Buy") . ')</td><td colspan="3">';
 | |
| 886 | +        print '<tr><td class="fieldrequired">'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td colspan="3">';
 | |
| 887 | 887 |          $statutarray = array('1' => $langs->trans("ProductStatusOnBuy"), '0' => $langs->trans("ProductStatusNotOnBuy"));
 | 
| 888 | 888 |          print $form->selectarray('statut_buy', $statutarray, GETPOST('statut_buy'));
 | 
| 889 | 889 | print '</td></tr>'; | 
| 890 | 890 | |
| 891 | 891 | // Batch number management | 
| 892 | 892 |          if (!empty($conf->productbatch->enabled)) {
 | 
| 893 | -            print '<tr><td>' . $langs->trans("ManageLotSerial") . '</td><td colspan="3">';
 | |
| 893 | +            print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td colspan="3">';
 | |
| 894 | 894 |              $statutarray = array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch"));
 | 
| 895 | 895 |              print $form->selectarray('status_batch', $statutarray, GETPOST('status_batch'));
 | 
| 896 | 896 | print '</td></tr>'; | 
| @@ -901,26 +901,26 @@ discard block | ||
| 901 | 901 | $showbarcode = 0; | 
| 902 | 902 | |
| 903 | 903 |          if ($showbarcode) {
 | 
| 904 | -            print '<tr><td>' . $langs->trans('BarcodeType') . '</td><td>';
 | |
| 904 | +            print '<tr><td>'.$langs->trans('BarcodeType').'</td><td>';
 | |
| 905 | 905 |              if (isset($_POST['fk_barcode_type'])) {
 | 
| 906 | 906 |                  $fk_barcode_type = GETPOST('fk_barcode_type');
 | 
| 907 | 907 |              } else {
 | 
| 908 | 908 | if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) | 
| 909 | 909 | $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; | 
| 910 | 910 | } | 
| 911 | - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbarcode.class.php'; | |
| 911 | + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; | |
| 912 | 912 | $formbarcode = new FormBarCode($db); | 
| 913 | 913 | print $formbarcode->selectBarcodeType($fk_barcode_type, 'fk_barcode_type', 1); | 
| 914 | -            print '</td><td>' . $langs->trans("BarcodeValue") . '</td><td>';
 | |
| 914 | +            print '</td><td>'.$langs->trans("BarcodeValue").'</td><td>';
 | |
| 915 | 915 |              $tmpcode = isset($_POST['barcode']) ? GETPOST('barcode') : $object->barcode;
 | 
| 916 | 916 | if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) | 
| 917 | 917 | $tmpcode = $modBarCodeProduct->getNextValue($object, $type); | 
| 918 | - print '<input class="maxwidth100" type="text" name="barcode" value="' . dol_escape_htmltag($tmpcode) . '">'; | |
| 918 | + print '<input class="maxwidth100" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).'">'; | |
| 919 | 919 | print '</td></tr>'; | 
| 920 | 920 | } | 
| 921 | 921 | |
| 922 | 922 | // Description (used in invoice, propal...) | 
| 923 | -        print '<tr><td class="tdtop">' . $langs->trans("Description") . '</td><td colspan="3">';
 | |
| 923 | +        print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">';
 | |
| 924 | 924 | |
| 925 | 925 |          $doleditor = new DolEditor('desc', GETPOST('desc', 'none'), '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%');
 | 
| 926 | 926 | $doleditor->Create(); | 
| @@ -928,23 +928,23 @@ discard block | ||
| 928 | 928 | print "</td></tr>"; | 
| 929 | 929 | |
| 930 | 930 | // Public URL | 
| 931 | -        print '<tr><td>' . $langs->trans("PublicUrl") . '</td><td colspan="3">';
 | |
| 932 | -        print '<input type="text" name="url" class="quatrevingtpercent" value="' . GETPOST('url') . '">';
 | |
| 931 | +        print '<tr><td>'.$langs->trans("PublicUrl").'</td><td colspan="3">';
 | |
| 932 | +        print '<input type="text" name="url" class="quatrevingtpercent" value="'.GETPOST('url').'">';
 | |
| 933 | 933 | print '</td></tr>'; | 
| 934 | 934 | |
| 935 | 935 |          if ($type != 1 && !empty($conf->stock->enabled)) {
 | 
| 936 | 936 | // Default warehouse | 
| 937 | -            print '<tr><td>' . $langs->trans("DefaultWarehouse") . '</td><td>';
 | |
| 937 | +            print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>';
 | |
| 938 | 938 |              print $formproduct->selectWarehouses(GETPOST('fk_default_warehouse'), 'fk_default_warehouse', 'warehouseopen', 1);
 | 
| 939 | -            print ' <a href="' . DOL_URL_ROOT . '/product/stock/card.php?action=create&backtopage=' . urlencode($_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=edit') . '">' . $langs->trans("AddWarehouse") . '</a>';
 | |
| 939 | +            print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit').'">'.$langs->trans("AddWarehouse").'</a>';
 | |
| 940 | 940 | print '</td>'; | 
| 941 | 941 | // Stock min level | 
| 942 | -            print '<tr><td>' . $form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1) . '</td><td>';
 | |
| 943 | -            print '<input name="seuil_stock_alerte" class="maxwidth50" value="' . GETPOST('seuil_stock_alerte') . '">';
 | |
| 942 | +            print '<tr><td>'.$form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1).'</td><td>';
 | |
| 943 | +            print '<input name="seuil_stock_alerte" class="maxwidth50" value="'.GETPOST('seuil_stock_alerte').'">';
 | |
| 944 | 944 | print '</td>'; | 
| 945 | 945 | // Stock desired level | 
| 946 | -            print '<td>' . $form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1) . '</td><td>';
 | |
| 947 | -            print '<input name="desiredstock" class="maxwidth50" value="' . GETPOST('desiredstock') . '">';
 | |
| 946 | +            print '<td>'.$form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1).'</td><td>';
 | |
| 947 | +            print '<input name="desiredstock" class="maxwidth50" value="'.GETPOST('desiredstock').'">';
 | |
| 948 | 948 | print '</td></tr>'; | 
| 949 | 949 |          } else {
 | 
| 950 | 950 | print '<input name="seuil_stock_alerte" type="hidden" value="0">'; | 
| @@ -953,7 +953,7 @@ discard block | ||
| 953 | 953 | |
| 954 | 954 | // Nature | 
| 955 | 955 |          if ($type != 1) {
 | 
| 956 | -            print '<tr><td>' . $langs->trans("Nature") . '</td><td colspan="3">';
 | |
| 956 | +            print '<tr><td>'.$langs->trans("Nature").'</td><td colspan="3">';
 | |
| 957 | 957 |              $statutarray = array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial"));
 | 
| 958 | 958 |              print $form->selectarray('finished', $statutarray, GETPOST('finished'), 1);
 | 
| 959 | 959 | print '</td></tr>'; | 
| @@ -961,42 +961,42 @@ discard block | ||
| 961 | 961 | |
| 962 | 962 | // Duration | 
| 963 | 963 |          if ($type == 1) {
 | 
| 964 | -            print '<tr><td>' . $langs->trans("Duration") . '</td><td colspan="3"><input name="duration_value" size="6" maxlength="5" value="' . $duration_value . '">  ';
 | |
| 965 | -            print '<input name="duration_unit" type="radio" value="i">' . $langs->trans("Minute") . ' ';
 | |
| 966 | -            print '<input name="duration_unit" type="radio" value="h">' . $langs->trans("Hour") . ' ';
 | |
| 967 | -            print '<input name="duration_unit" type="radio" value="d">' . $langs->trans("Day") . ' ';
 | |
| 968 | -            print '<input name="duration_unit" type="radio" value="w">' . $langs->trans("Week") . ' ';
 | |
| 969 | -            print '<input name="duration_unit" type="radio" value="m">' . $langs->trans("Month") . ' ';
 | |
| 970 | -            print '<input name="duration_unit" type="radio" value="y">' . $langs->trans("Year") . ' ';
 | |
| 964 | +            print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3"><input name="duration_value" size="6" maxlength="5" value="'.$duration_value.'">  ';
 | |
| 965 | +            print '<input name="duration_unit" type="radio" value="i">'.$langs->trans("Minute").' ';
 | |
| 966 | +            print '<input name="duration_unit" type="radio" value="h">'.$langs->trans("Hour").' ';
 | |
| 967 | +            print '<input name="duration_unit" type="radio" value="d">'.$langs->trans("Day").' ';
 | |
| 968 | +            print '<input name="duration_unit" type="radio" value="w">'.$langs->trans("Week").' ';
 | |
| 969 | +            print '<input name="duration_unit" type="radio" value="m">'.$langs->trans("Month").' ';
 | |
| 970 | +            print '<input name="duration_unit" type="radio" value="y">'.$langs->trans("Year").' ';
 | |
| 971 | 971 | print '</td></tr>'; | 
| 972 | 972 | } | 
| 973 | 973 | |
| 974 | 974 |          if ($type != 1) { // Le poids et le volume ne concerne que les produits et pas les services
 | 
| 975 | 975 | // Weight | 
| 976 | -            print '<tr><td>' . $langs->trans("Weight") . '</td><td colspan="3">';
 | |
| 977 | -            print '<input name="weight" size="4" value="' . GETPOST('weight') . '">';
 | |
| 976 | +            print '<tr><td>'.$langs->trans("Weight").'</td><td colspan="3">';
 | |
| 977 | +            print '<input name="weight" size="4" value="'.GETPOST('weight').'">';
 | |
| 978 | 978 |              print $formproduct->select_measuring_units("weight_units", "weight");
 | 
| 979 | 979 | print '</td></tr>'; | 
| 980 | 980 | // Length | 
| 981 | 981 |              if (empty($conf->global->PRODUCT_DISABLE_SIZE)) {
 | 
| 982 | -                print '<tr><td>' . $langs->trans("Length") . ' x ' . $langs->trans("Width") . ' x ' . $langs->trans("Height") . '</td><td colspan="3">';
 | |
| 983 | -                print '<input name="size" size="4" value="' . GETPOST('size') . '"> x ';
 | |
| 984 | -                print '<input name="sizewidth" size="4" value="' . GETPOST('sizewidth') . '"> x ';
 | |
| 985 | -                print '<input name="sizeheight" size="4" value="' . GETPOST('sizeheight') . '">';
 | |
| 982 | +                print '<tr><td>'.$langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").'</td><td colspan="3">';
 | |
| 983 | +                print '<input name="size" size="4" value="'.GETPOST('size').'"> x ';
 | |
| 984 | +                print '<input name="sizewidth" size="4" value="'.GETPOST('sizewidth').'"> x ';
 | |
| 985 | +                print '<input name="sizeheight" size="4" value="'.GETPOST('sizeheight').'">';
 | |
| 986 | 986 |                  print $formproduct->select_measuring_units("size_units", "size");
 | 
| 987 | 987 | print '</td></tr>'; | 
| 988 | 988 | } | 
| 989 | 989 |              if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) {
 | 
| 990 | 990 | // Surface | 
| 991 | -                print '<tr><td>' . $langs->trans("Surface") . '</td><td colspan="3">';
 | |
| 992 | -                print '<input name="surface" size="4" value="' . GETPOST('surface') . '">';
 | |
| 991 | +                print '<tr><td>'.$langs->trans("Surface").'</td><td colspan="3">';
 | |
| 992 | +                print '<input name="surface" size="4" value="'.GETPOST('surface').'">';
 | |
| 993 | 993 |                  print $formproduct->select_measuring_units("surface_units", "surface");
 | 
| 994 | 994 | print '</td></tr>'; | 
| 995 | 995 | } | 
| 996 | 996 |              if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) {
 | 
| 997 | 997 | // Volume | 
| 998 | -                print '<tr><td>' . $langs->trans("Volume") . '</td><td colspan="3">';
 | |
| 999 | -                print '<input name="volume" size="4" value="' . GETPOST('volume') . '">';
 | |
| 998 | +                print '<tr><td>'.$langs->trans("Volume").'</td><td colspan="3">';
 | |
| 999 | +                print '<input name="volume" size="4" value="'.GETPOST('volume').'">';
 | |
| 1000 | 1000 |                  print $formproduct->select_measuring_units("volume_units", "volume");
 | 
| 1001 | 1001 | print '</td></tr>'; | 
| 1002 | 1002 | } | 
| @@ -1004,7 +1004,7 @@ discard block | ||
| 1004 | 1004 | |
| 1005 | 1005 | // Units | 
| 1006 | 1006 |          if ($conf->global->PRODUCT_USE_UNITS) {
 | 
| 1007 | -            print '<tr><td>' . $langs->trans('DefaultUnitToShow') . '</td>';
 | |
| 1007 | +            print '<tr><td>'.$langs->trans('DefaultUnitToShow').'</td>';
 | |
| 1008 | 1008 | print '<td colspan="3">'; | 
| 1009 | 1009 |              print $form->selectUnits('', 'units');
 | 
| 1010 | 1010 | print '</td></tr>'; | 
| @@ -1012,9 +1012,9 @@ discard block | ||
| 1012 | 1012 | |
| 1013 | 1013 | // Custom code | 
| 1014 | 1014 |          if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO) && empty($type)) {
 | 
| 1015 | -            print '<tr><td>' . $langs->trans("CustomCode") . '</td><td><input name="customcode" class="maxwidth100onsmartphone" value="' . GETPOST('customcode') . '"></td>';
 | |
| 1015 | +            print '<tr><td>'.$langs->trans("CustomCode").'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.GETPOST('customcode').'"></td>';
 | |
| 1016 | 1016 | // Origin country | 
| 1017 | -            print '<td>' . $langs->trans("CountryOrigin") . '</td><td>';
 | |
| 1017 | +            print '<td>'.$langs->trans("CountryOrigin").'</td><td>';
 | |
| 1018 | 1018 |              print $form->select_country(GETPOST('country_id', 'int'), 'country_id');
 | 
| 1019 | 1019 | if ($user->admin) | 
| 1020 | 1020 |                  print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
 | 
| @@ -1023,7 +1023,7 @@ discard block | ||
| 1023 | 1023 | |
| 1024 | 1024 | // Other attributes | 
| 1025 | 1025 |          $parameters = array('colspan' => 3);
 | 
| 1026 | -        $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action);    // Note that $action and $object may have been modified by hook
 | |
| 1026 | +        $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
 | |
| 1027 | 1027 | print $hookmanager->resPrint; | 
| 1028 | 1028 |          if (empty($reshook)) {
 | 
| 1029 | 1029 | print $object->showOptionals($extrafields, 'edit', $parameters); | 
| @@ -1032,7 +1032,7 @@ discard block | ||
| 1032 | 1032 | // Note (private, no output on invoices, propales...) | 
| 1033 | 1033 | //if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) available in create mode | 
| 1034 | 1034 |          //{
 | 
| 1035 | -        print '<tr><td class="tdtop">' . $langs->trans("NoteNotVisibleOnBill") . '</td><td colspan="3">';
 | |
| 1035 | +        print '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="3">';
 | |
| 1036 | 1036 | |
| 1037 | 1037 | // We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF. | 
| 1038 | 1038 |          $doleditor = new DolEditor('note_private', GETPOST('note_private', 'none'), '', 140, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_8, '90%');
 | 
| @@ -1043,7 +1043,7 @@ discard block | ||
| 1043 | 1043 | |
| 1044 | 1044 |          if ($conf->categorie->enabled) {
 | 
| 1045 | 1045 | // Categories | 
| 1046 | -            print '<tr><td>' . $langs->trans("Categories") . '</td><td colspan="3">';
 | |
| 1046 | +            print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
 | |
| 1047 | 1047 | $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1); | 
| 1048 | 1048 |              print $form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, '', 0, '100%');
 | 
| 1049 | 1049 | print "</td></tr>"; | 
| @@ -1058,7 +1058,7 @@ discard block | ||
| 1058 | 1058 | // We must set them on prices tab. | 
| 1059 | 1059 | print '<table class="border" width="100%">'; | 
| 1060 | 1060 | // VAT | 
| 1061 | -            print '<tr><td class="titlefieldcreate">' . $langs->trans("VATRate") . '</td><td>';
 | |
| 1061 | +            print '<tr><td class="titlefieldcreate">'.$langs->trans("VATRate").'</td><td>';
 | |
| 1062 | 1062 | $defaultva = get_default_tva($mysoc, $mysoc); | 
| 1063 | 1063 |              print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1);
 | 
| 1064 | 1064 | print '</td></tr>'; | 
| @@ -1068,18 +1068,18 @@ discard block | ||
| 1068 | 1068 | print '<table class="border" width="100%">'; | 
| 1069 | 1069 | |
| 1070 | 1070 | // Price | 
| 1071 | -            print '<tr><td class="titlefieldcreate">' . $langs->trans("SellingPrice") . '</td>';
 | |
| 1072 | - print '<td><input name="price" class="maxwidth50" value="' . $object->price . '">'; | |
| 1071 | +            print '<tr><td class="titlefieldcreate">'.$langs->trans("SellingPrice").'</td>';
 | |
| 1072 | + print '<td><input name="price" class="maxwidth50" value="'.$object->price.'">'; | |
| 1073 | 1073 | print $form->selectPriceBaseType($object->price_base_type, "price_base_type"); | 
| 1074 | 1074 | print '</td></tr>'; | 
| 1075 | 1075 | |
| 1076 | 1076 | // Min price | 
| 1077 | -            print '<tr><td>' . $langs->trans("MinPrice") . '</td>';
 | |
| 1078 | - print '<td><input name="price_min" class="maxwidth50" value="' . $object->price_min . '">'; | |
| 1077 | +            print '<tr><td>'.$langs->trans("MinPrice").'</td>';
 | |
| 1078 | + print '<td><input name="price_min" class="maxwidth50" value="'.$object->price_min.'">'; | |
| 1079 | 1079 | print '</td></tr>'; | 
| 1080 | 1080 | |
| 1081 | 1081 | // VAT | 
| 1082 | -            print '<tr><td>' . $langs->trans("VATRate") . '</td><td>';
 | |
| 1082 | +            print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
 | |
| 1083 | 1083 | $defaultva = get_default_tva($mysoc, $mysoc); | 
| 1084 | 1084 |              print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1);
 | 
| 1085 | 1085 | print '</td></tr>'; | 
| @@ -1094,7 +1094,7 @@ discard block | ||
| 1094 | 1094 | |
| 1095 | 1095 |          if (!empty($conf->accounting->enabled)) {
 | 
| 1096 | 1096 | // Accountancy_code_sell | 
| 1097 | -            print '<tr><td class="titlefieldcreate">' . $langs->trans("ProductAccountancySellCode") . '</td>';
 | |
| 1097 | +            print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>';
 | |
| 1098 | 1098 | print '<td>'; | 
| 1099 | 1099 |              print $formaccounting->select_account(GETPOST('accountancy_code_sell'), 'accountancy_code_sell', 1, null, 1, 1, '');
 | 
| 1100 | 1100 | print '</td></tr>'; | 
| @@ -1102,47 +1102,47 @@ discard block | ||
| 1102 | 1102 |              if ($conf->global->MAIN_FEATURES_LEVEL) {
 | 
| 1103 | 1103 | // Accountancy_code_sell_intra | 
| 1104 | 1104 |                  if ($mysoc->isInEEC()) {
 | 
| 1105 | -                    print '<tr><td class="titlefieldcreate">' . $langs->trans("ProductAccountancySellIntraCode") . '</td>';
 | |
| 1105 | +                    print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellIntraCode").'</td>';
 | |
| 1106 | 1106 | print '<td>'; | 
| 1107 | 1107 |                      print $formaccounting->select_account(GETPOST('accountancy_code_sell_intra'), 'accountancy_code_sell_intra', 1, null, 1, 1, '');
 | 
| 1108 | 1108 | print '</td></tr>'; | 
| 1109 | 1109 | } | 
| 1110 | 1110 | |
| 1111 | 1111 | // Accountancy_code_sell_export | 
| 1112 | -                print '<tr><td class="titlefieldcreate">' . $langs->trans("ProductAccountancySellExportCode") . '</td>';
 | |
| 1112 | +                print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellExportCode").'</td>';
 | |
| 1113 | 1113 | print '<td>'; | 
| 1114 | 1114 |                  print $formaccounting->select_account(GETPOST('accountancy_code_sell_export'), 'accountancy_code_sell_export', 1, null, 1, 1, '');
 | 
| 1115 | 1115 | print '</td></tr>'; | 
| 1116 | 1116 | } | 
| 1117 | 1117 | |
| 1118 | 1118 | // Accountancy_code_buy | 
| 1119 | -            print '<tr><td>' . $langs->trans("ProductAccountancyBuyCode") . '</td>';
 | |
| 1119 | +            print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>';
 | |
| 1120 | 1120 | print '<td>'; | 
| 1121 | 1121 |              print $formaccounting->select_account(GETPOST('accountancy_code_buy'), 'accountancy_code_buy', 1, null, 1, 1, '');
 | 
| 1122 | 1122 | print '</td></tr>'; | 
| 1123 | 1123 |          } else { // For external software
 | 
| 1124 | 1124 | // Accountancy_code_sell | 
| 1125 | -            print '<tr><td class="titlefieldcreate">' . $langs->trans("ProductAccountancySellCode") . '</td>';
 | |
| 1126 | - print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell" value="' . $object->accountancy_code_sell . '">'; | |
| 1125 | +            print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>';
 | |
| 1126 | + print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.'">'; | |
| 1127 | 1127 | print '</td></tr>'; | 
| 1128 | 1128 | |
| 1129 | 1129 |              if ($conf->global->MAIN_FEATURES_LEVEL) {
 | 
| 1130 | 1130 | // Accountancy_code_sell_intra | 
| 1131 | 1131 |                  if ($mysoc->isInEEC()) {
 | 
| 1132 | -                    print '<tr><td class="titlefieldcreate">' . $langs->trans("ProductAccountancySellIntraCode") . '</td>';
 | |
| 1133 | - print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell_intra" value="' . $object->accountancy_code_sell_intra . '">'; | |
| 1132 | +                    print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellIntraCode").'</td>';
 | |
| 1133 | + print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell_intra" value="'.$object->accountancy_code_sell_intra.'">'; | |
| 1134 | 1134 | print '</td></tr>'; | 
| 1135 | 1135 | } | 
| 1136 | 1136 | |
| 1137 | 1137 | // Accountancy_code_sell_export | 
| 1138 | -                print '<tr><td class="titlefieldcreate">' . $langs->trans("ProductAccountancySellExportCode") . '</td>';
 | |
| 1139 | - print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell_export" value="' . $object->accountancy_code_sell_export . '">'; | |
| 1138 | +                print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellExportCode").'</td>';
 | |
| 1139 | + print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell_export" value="'.$object->accountancy_code_sell_export.'">'; | |
| 1140 | 1140 | print '</td></tr>'; | 
| 1141 | 1141 | } | 
| 1142 | 1142 | |
| 1143 | 1143 | // Accountancy_code_buy | 
| 1144 | -            print '<tr><td>' . $langs->trans("ProductAccountancyBuyCode") . '</td>';
 | |
| 1145 | - print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy" value="' . $object->accountancy_code_buy . '">'; | |
| 1144 | +            print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>';
 | |
| 1145 | + print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.'">'; | |
| 1146 | 1146 | print '</td></tr>'; | 
| 1147 | 1147 | } | 
| 1148 | 1148 | print '</table>'; | 
| @@ -1150,9 +1150,9 @@ discard block | ||
| 1150 | 1150 | dol_fiche_end(); | 
| 1151 | 1151 | |
| 1152 | 1152 | print '<div class="center">'; | 
| 1153 | -        print '<input type="submit" class="button" value="' . $langs->trans("Create") . '">';
 | |
| 1153 | +        print '<input type="submit" class="button" value="'.$langs->trans("Create").'">';
 | |
| 1154 | 1154 | print '     '; | 
| 1155 | -        print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
 | |
| 1155 | +        print '<input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">';
 | |
| 1156 | 1156 | print '</div>'; | 
| 1157 | 1157 | |
| 1158 | 1158 | print '</form>'; | 
| @@ -1164,7 +1164,7 @@ discard block | ||
| 1164 | 1164 | // Fiche en mode edition | 
| 1165 | 1165 |          if ($action == 'edit' && $usercancreate) {
 | 
| 1166 | 1166 | //WYSIWYG Editor | 
| 1167 | - require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; | |
| 1167 | + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; | |
| 1168 | 1168 | |
| 1169 | 1169 |              $type = $langs->trans('Product');
 | 
| 1170 | 1170 | if ($object->isService()) | 
| @@ -1172,47 +1172,47 @@ discard block | ||
| 1172 | 1172 |              //print load_fiche_titre($langs->trans('Modify').' '.$type.' : '.(is_object($object->oldcopy)?$object->oldcopy->ref:$object->ref), "");
 | 
| 1173 | 1173 | // Main official, simple, and not duplicated code | 
| 1174 | 1174 | // print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="POST">'."\n"; | 
| 1175 | - print '<form href="' . BASE_URI . '?controller=product&method=card&id=' . $object->id . '" method="POST">' . "\n"; | |
| 1176 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 1175 | + print '<form href="'.BASE_URI.'?controller=product&method=card&id='.$object->id.'" method="POST">'."\n"; | |
| 1176 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 1177 | 1177 | print '<input type="hidden" name="action" value="update">'; | 
| 1178 | - print '<input type="hidden" name="id" value="' . $object->id . '">'; | |
| 1179 | - print '<input type="hidden" name="canvas" value="' . $object->canvas . '">'; | |
| 1178 | + print '<input type="hidden" name="id" value="'.$object->id.'">'; | |
| 1179 | + print '<input type="hidden" name="canvas" value="'.$object->canvas.'">'; | |
| 1180 | 1180 | |
| 1181 | 1181 | $head = product_prepare_head($object); | 
| 1182 | -            $titre = $langs->trans("CardProduct" . $object->type);
 | |
| 1182 | +            $titre = $langs->trans("CardProduct".$object->type);
 | |
| 1183 | 1183 | $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); | 
| 1184 | 1184 | dol_fiche_head($head, 'card', $titre, 0, $picto); | 
| 1185 | 1185 | |
| 1186 | 1186 | print '<table class="border allwidth">'; | 
| 1187 | 1187 | |
| 1188 | 1188 | // Ref | 
| 1189 | -            print '<tr><td class="titlefield fieldrequired">' . $langs->trans("Ref") . '</td><td colspan="3"><input name="ref" class="maxwidth200" maxlength="128" value="' . dol_escape_htmltag($object->ref) . '"></td></tr>';
 | |
| 1189 | +            print '<tr><td class="titlefield fieldrequired">'.$langs->trans("Ref").'</td><td colspan="3"><input name="ref" class="maxwidth200" maxlength="128" value="'.dol_escape_htmltag($object->ref).'"></td></tr>';
 | |
| 1190 | 1190 | |
| 1191 | 1191 | // Label | 
| 1192 | -            print '<tr><td class="fieldrequired">' . $langs->trans("Label") . '</td><td colspan="3"><input name="label" class="minwidth300 maxwidth400onsmartphone" maxlength="255" value="' . dol_escape_htmltag($object->label) . '"></td></tr>';
 | |
| 1192 | +            print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td colspan="3"><input name="label" class="minwidth300 maxwidth400onsmartphone" maxlength="255" value="'.dol_escape_htmltag($object->label).'"></td></tr>';
 | |
| 1193 | 1193 | |
| 1194 | 1194 | // Status To sell | 
| 1195 | -            print '<tr><td class="fieldrequired">' . $langs->trans("Status") . ' (' . $langs->trans("Sell") . ')</td><td colspan="3">';
 | |
| 1195 | +            print '<tr><td class="fieldrequired">'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td colspan="3">';
 | |
| 1196 | 1196 | print '<select class="flat" name="statut">'; | 
| 1197 | 1197 |              if ($object->status) {
 | 
| 1198 | -                print '<option value="1" selected>' . $langs->trans("OnSell") . '</option>';
 | |
| 1199 | -                print '<option value="0">' . $langs->trans("NotOnSell") . '</option>';
 | |
| 1198 | +                print '<option value="1" selected>'.$langs->trans("OnSell").'</option>';
 | |
| 1199 | +                print '<option value="0">'.$langs->trans("NotOnSell").'</option>';
 | |
| 1200 | 1200 |              } else {
 | 
| 1201 | -                print '<option value="1">' . $langs->trans("OnSell") . '</option>';
 | |
| 1202 | -                print '<option value="0" selected>' . $langs->trans("NotOnSell") . '</option>';
 | |
| 1201 | +                print '<option value="1">'.$langs->trans("OnSell").'</option>';
 | |
| 1202 | +                print '<option value="0" selected>'.$langs->trans("NotOnSell").'</option>';
 | |
| 1203 | 1203 | } | 
| 1204 | 1204 | print '</select>'; | 
| 1205 | 1205 | print '</td></tr>'; | 
| 1206 | 1206 | |
| 1207 | 1207 | // Status To Buy | 
| 1208 | -            print '<tr><td class="fieldrequired">' . $langs->trans("Status") . ' (' . $langs->trans("Buy") . ')</td><td colspan="3">';
 | |
| 1208 | +            print '<tr><td class="fieldrequired">'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td colspan="3">';
 | |
| 1209 | 1209 | print '<select class="flat" name="statut_buy">'; | 
| 1210 | 1210 |              if ($object->status_buy) {
 | 
| 1211 | -                print '<option value="1" selected>' . $langs->trans("ProductStatusOnBuy") . '</option>';
 | |
| 1212 | -                print '<option value="0">' . $langs->trans("ProductStatusNotOnBuy") . '</option>';
 | |
| 1211 | +                print '<option value="1" selected>'.$langs->trans("ProductStatusOnBuy").'</option>';
 | |
| 1212 | +                print '<option value="0">'.$langs->trans("ProductStatusNotOnBuy").'</option>';
 | |
| 1213 | 1213 |              } else {
 | 
| 1214 | -                print '<option value="1">' . $langs->trans("ProductStatusOnBuy") . '</option>';
 | |
| 1215 | -                print '<option value="0" selected>' . $langs->trans("ProductStatusNotOnBuy") . '</option>';
 | |
| 1214 | +                print '<option value="1">'.$langs->trans("ProductStatusOnBuy").'</option>';
 | |
| 1215 | +                print '<option value="0" selected>'.$langs->trans("ProductStatusNotOnBuy").'</option>';
 | |
| 1216 | 1216 | } | 
| 1217 | 1217 | print '</select>'; | 
| 1218 | 1218 | print '</td></tr>'; | 
| @@ -1220,7 +1220,7 @@ discard block | ||
| 1220 | 1220 | // Batch number managment | 
| 1221 | 1221 |              if ($conf->productbatch->enabled) {
 | 
| 1222 | 1222 |                  if ($object->isProduct() || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
 | 
| 1223 | -                    print '<tr><td>' . $langs->trans("ManageLotSerial") . '</td><td colspan="3">';
 | |
| 1223 | +                    print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td colspan="3">';
 | |
| 1224 | 1224 |                      $statutarray = array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch"));
 | 
| 1225 | 1225 |                      print $form->selectarray('status_batch', $statutarray, $object->status_batch);
 | 
| 1226 | 1226 | print '</td></tr>'; | 
| @@ -1233,7 +1233,7 @@ discard block | ||
| 1233 | 1233 | $showbarcode = 0; | 
| 1234 | 1234 | |
| 1235 | 1235 |              if ($showbarcode) {
 | 
| 1236 | -                print '<tr><td>' . $langs->trans('BarcodeType') . '</td><td>';
 | |
| 1236 | +                print '<tr><td>'.$langs->trans('BarcodeType').'</td><td>';
 | |
| 1237 | 1237 |                  if (isset($_POST['fk_barcode_type'])) {
 | 
| 1238 | 1238 |                      $fk_barcode_type = GETPOST('fk_barcode_type');
 | 
| 1239 | 1239 |                  } else {
 | 
| @@ -1241,19 +1241,19 @@ discard block | ||
| 1241 | 1241 | if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) | 
| 1242 | 1242 | $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; | 
| 1243 | 1243 | } | 
| 1244 | - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbarcode.class.php'; | |
| 1244 | + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; | |
| 1245 | 1245 | $formbarcode = new FormBarCode($db); | 
| 1246 | 1246 | print $formbarcode->selectBarcodeType($fk_barcode_type, 'fk_barcode_type', 1); | 
| 1247 | -                print '</td><td>' . $langs->trans("BarcodeValue") . '</td><td>';
 | |
| 1247 | +                print '</td><td>'.$langs->trans("BarcodeValue").'</td><td>';
 | |
| 1248 | 1248 |                  $tmpcode = isset($_POST['barcode']) ? GETPOST('barcode') : $object->barcode;
 | 
| 1249 | 1249 | if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) | 
| 1250 | 1250 | $tmpcode = $modBarCodeProduct->getNextValue($object, $type); | 
| 1251 | - print '<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="' . dol_escape_htmltag($tmpcode) . '">'; | |
| 1251 | + print '<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).'">'; | |
| 1252 | 1252 | print '</td></tr>'; | 
| 1253 | 1253 | } | 
| 1254 | 1254 | |
| 1255 | 1255 | // Description (used in invoice, propal...) | 
| 1256 | -            print '<tr><td class="tdtop">' . $langs->trans("Description") . '</td><td colspan="3">';
 | |
| 1256 | +            print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">';
 | |
| 1257 | 1257 | |
| 1258 | 1258 | // We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF. | 
| 1259 | 1259 |              $doleditor = new DolEditor('desc', $object->description, '', 160, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%');
 | 
| @@ -1263,16 +1263,16 @@ discard block | ||
| 1263 | 1263 | print "\n"; | 
| 1264 | 1264 | |
| 1265 | 1265 | // Public Url | 
| 1266 | -            print '<tr><td>' . $langs->trans("PublicUrl") . '</td><td colspan="3">';
 | |
| 1267 | - print '<input type="text" name="url" class="quatrevingtpercent" value="' . $object->url . '">'; | |
| 1266 | +            print '<tr><td>'.$langs->trans("PublicUrl").'</td><td colspan="3">';
 | |
| 1267 | + print '<input type="text" name="url" class="quatrevingtpercent" value="'.$object->url.'">'; | |
| 1268 | 1268 | print '</td></tr>'; | 
| 1269 | 1269 | |
| 1270 | 1270 | // Stock | 
| 1271 | 1271 |              if ($object->isProduct() && !empty($conf->stock->enabled)) {
 | 
| 1272 | 1272 | // Default warehouse | 
| 1273 | -                print '<tr><td>' . $langs->trans("DefaultWarehouse") . '</td><td>';
 | |
| 1273 | +                print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>';
 | |
| 1274 | 1274 | print $formproduct->selectWarehouses($object->fk_default_warehouse, 'fk_default_warehouse', 'warehouseopen', 1); | 
| 1275 | -                print ' <a href="' . DOL_URL_ROOT . '/product/stock/card.php?action=create&backtopage=' . urlencode($_SERVER['PHP_SELF'] . '?action=create&type=' . GETPOST('type', 'int')) . '">' . $langs->trans("AddWarehouse") . '</a>';
 | |
| 1275 | +                print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].'?action=create&type='.GETPOST('type', 'int')).'">'.$langs->trans("AddWarehouse").'</a>';
 | |
| 1276 | 1276 | print '</td>'; | 
| 1277 | 1277 | /* | 
| 1278 | 1278 |                    print "<tr>".'<td>'.$langs->trans("StockLimit").'</td><td>';
 | 
| @@ -1293,7 +1293,7 @@ discard block | ||
| 1293 | 1293 | |
| 1294 | 1294 | // Nature | 
| 1295 | 1295 |              if ($object->type != Product::TYPE_SERVICE) {
 | 
| 1296 | -                print '<tr><td>' . $langs->trans("Nature") . '</td><td colspan="3">';
 | |
| 1296 | +                print '<tr><td>'.$langs->trans("Nature").'</td><td colspan="3">';
 | |
| 1297 | 1297 |                  $statutarray = array('-1' => ' ', '1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial"));
 | 
| 1298 | 1298 |                  print $form->selectarray('finished', $statutarray, $object->finished);
 | 
| 1299 | 1299 | print '</td></tr>'; | 
| @@ -1301,53 +1301,53 @@ discard block | ||
| 1301 | 1301 | |
| 1302 | 1302 |              if ($object->isService()) {
 | 
| 1303 | 1303 | // Duration | 
| 1304 | -                print '<tr><td>' . $langs->trans("Duration") . '</td><td colspan="3"><input name="duration_value" size="3" maxlength="5" value="' . $object->duration_value . '">';
 | |
| 1304 | +                print '<tr><td>'.$langs->trans("Duration").'</td><td colspan="3"><input name="duration_value" size="3" maxlength="5" value="'.$object->duration_value.'">';
 | |
| 1305 | 1305 | print '  '; | 
| 1306 | -                print '<input name="duration_unit" type="radio" value="i"' . ($object->duration_unit == 'i' ? ' checked' : '') . '>' . $langs->trans("Minute");
 | |
| 1306 | +                print '<input name="duration_unit" type="radio" value="i"'.($object->duration_unit == 'i' ? ' checked' : '').'>'.$langs->trans("Minute");
 | |
| 1307 | 1307 | print '  '; | 
| 1308 | -                print '<input name="duration_unit" type="radio" value="h"' . ($object->duration_unit == 'h' ? ' checked' : '') . '>' . $langs->trans("Hour");
 | |
| 1308 | +                print '<input name="duration_unit" type="radio" value="h"'.($object->duration_unit == 'h' ? ' checked' : '').'>'.$langs->trans("Hour");
 | |
| 1309 | 1309 | print '  '; | 
| 1310 | -                print '<input name="duration_unit" type="radio" value="d"' . ($object->duration_unit == 'd' ? ' checked' : '') . '>' . $langs->trans("Day");
 | |
| 1310 | +                print '<input name="duration_unit" type="radio" value="d"'.($object->duration_unit == 'd' ? ' checked' : '').'>'.$langs->trans("Day");
 | |
| 1311 | 1311 | print '  '; | 
| 1312 | -                print '<input name="duration_unit" type="radio" value="w"' . ($object->duration_unit == 'w' ? ' checked' : '') . '>' . $langs->trans("Week");
 | |
| 1312 | +                print '<input name="duration_unit" type="radio" value="w"'.($object->duration_unit == 'w' ? ' checked' : '').'>'.$langs->trans("Week");
 | |
| 1313 | 1313 | print '  '; | 
| 1314 | -                print '<input name="duration_unit" type="radio" value="m"' . ($object->duration_unit == 'm' ? ' checked' : '') . '>' . $langs->trans("Month");
 | |
| 1314 | +                print '<input name="duration_unit" type="radio" value="m"'.($object->duration_unit == 'm' ? ' checked' : '').'>'.$langs->trans("Month");
 | |
| 1315 | 1315 | print '  '; | 
| 1316 | -                print '<input name="duration_unit" type="radio" value="y"' . ($object->duration_unit == 'y' ? ' checked' : '') . '>' . $langs->trans("Year");
 | |
| 1316 | +                print '<input name="duration_unit" type="radio" value="y"'.($object->duration_unit == 'y' ? ' checked' : '').'>'.$langs->trans("Year");
 | |
| 1317 | 1317 | print '</td></tr>'; | 
| 1318 | 1318 |              } else {
 | 
| 1319 | 1319 | // Weight | 
| 1320 | -                print '<tr><td>' . $langs->trans("Weight") . '</td><td colspan="3">';
 | |
| 1321 | - print '<input name="weight" size="5" value="' . $object->weight . '"> '; | |
| 1320 | +                print '<tr><td>'.$langs->trans("Weight").'</td><td colspan="3">';
 | |
| 1321 | + print '<input name="weight" size="5" value="'.$object->weight.'"> '; | |
| 1322 | 1322 |                  print $formproduct->select_measuring_units("weight_units", "weight", $object->weight_units);
 | 
| 1323 | 1323 | print '</td></tr>'; | 
| 1324 | 1324 |                  if (empty($conf->global->PRODUCT_DISABLE_SIZE)) {
 | 
| 1325 | 1325 | // Length | 
| 1326 | -                    print '<tr><td>' . $langs->trans("Length") . ' x ' . $langs->trans("Width") . ' x ' . $langs->trans("Height") . '</td><td colspan="3">';
 | |
| 1327 | - print '<input name="size" size="5" value="' . $object->length . '">x'; | |
| 1328 | - print '<input name="sizewidth" size="5" value="' . $object->width . '">x'; | |
| 1329 | - print '<input name="sizeheight" size="5" value="' . $object->height . '"> '; | |
| 1326 | +                    print '<tr><td>'.$langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").'</td><td colspan="3">';
 | |
| 1327 | + print '<input name="size" size="5" value="'.$object->length.'">x'; | |
| 1328 | + print '<input name="sizewidth" size="5" value="'.$object->width.'">x'; | |
| 1329 | + print '<input name="sizeheight" size="5" value="'.$object->height.'"> '; | |
| 1330 | 1330 |                      print $formproduct->select_measuring_units("size_units", "size", $object->length_units);
 | 
| 1331 | 1331 | print '</td></tr>'; | 
| 1332 | 1332 | } | 
| 1333 | 1333 |                  if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) {
 | 
| 1334 | 1334 | // Surface | 
| 1335 | -                    print '<tr><td>' . $langs->trans("Surface") . '</td><td colspan="3">';
 | |
| 1336 | - print '<input name="surface" size="5" value="' . $object->surface . '"> '; | |
| 1335 | +                    print '<tr><td>'.$langs->trans("Surface").'</td><td colspan="3">';
 | |
| 1336 | + print '<input name="surface" size="5" value="'.$object->surface.'"> '; | |
| 1337 | 1337 |                      print $formproduct->select_measuring_units("surface_units", "surface", $object->surface_units);
 | 
| 1338 | 1338 | print '</td></tr>'; | 
| 1339 | 1339 | } | 
| 1340 | 1340 |                  if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) {
 | 
| 1341 | 1341 | // Volume | 
| 1342 | -                    print '<tr><td>' . $langs->trans("Volume") . '</td><td colspan="3">';
 | |
| 1343 | - print '<input name="volume" size="5" value="' . $object->volume . '"> '; | |
| 1342 | +                    print '<tr><td>'.$langs->trans("Volume").'</td><td colspan="3">';
 | |
| 1343 | + print '<input name="volume" size="5" value="'.$object->volume.'"> '; | |
| 1344 | 1344 |                      print $formproduct->select_measuring_units("volume_units", "volume", $object->volume_units);
 | 
| 1345 | 1345 | print '</td></tr>'; | 
| 1346 | 1346 | } | 
| 1347 | 1347 | } | 
| 1348 | 1348 | // Units | 
| 1349 | 1349 |              if ($conf->global->PRODUCT_USE_UNITS) {
 | 
| 1350 | -                print '<tr><td>' . $langs->trans('DefaultUnitToShow') . '</td>';
 | |
| 1350 | +                print '<tr><td>'.$langs->trans('DefaultUnitToShow').'</td>';
 | |
| 1351 | 1351 | print '<td colspan="3">'; | 
| 1352 | 1352 | print $form->selectUnits($object->fk_unit, 'units'); | 
| 1353 | 1353 | print '</td></tr>'; | 
| @@ -1355,9 +1355,9 @@ discard block | ||
| 1355 | 1355 | |
| 1356 | 1356 | // Custom code | 
| 1357 | 1357 |              if (!$object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) {
 | 
| 1358 | -                print '<tr><td>' . $langs->trans("CustomCode") . '</td><td><input name="customcode" class="maxwidth100onsmartphone" value="' . $object->customcode . '"></td>';
 | |
| 1358 | +                print '<tr><td>'.$langs->trans("CustomCode").'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.$object->customcode.'"></td>';
 | |
| 1359 | 1359 | // Origin country | 
| 1360 | -                print '<td>' . $langs->trans("CountryOrigin") . '</td><td>';
 | |
| 1360 | +                print '<td>'.$langs->trans("CountryOrigin").'</td><td>';
 | |
| 1361 | 1361 | print $form->select_country($object->country_id, 'country_id', '', 0, 'minwidth100 maxwidthonsmartphone'); | 
| 1362 | 1362 | if ($user->admin) | 
| 1363 | 1363 |                      print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
 | 
| @@ -1366,7 +1366,7 @@ discard block | ||
| 1366 | 1366 | |
| 1367 | 1367 | // Other attributes | 
| 1368 | 1368 |              $parameters = array('colspan' => ' colspan="3"', 'cols' => 3);
 | 
| 1369 | -            $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action);    // Note that $action and $object may have been modified by hook
 | |
| 1369 | +            $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
 | |
| 1370 | 1370 | print $hookmanager->resPrint; | 
| 1371 | 1371 |              if (empty($reshook)) {
 | 
| 1372 | 1372 | print $object->showOptionals($extrafields, 'edit'); | 
| @@ -1374,7 +1374,7 @@ discard block | ||
| 1374 | 1374 | |
| 1375 | 1375 | // Tags-Categories | 
| 1376 | 1376 |              if ($conf->categorie->enabled) {
 | 
| 1377 | -                print '<tr><td class="tdtop">' . $langs->trans("Categories") . '</td><td colspan="3">';
 | |
| 1377 | +                print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td colspan="3">';
 | |
| 1378 | 1378 | $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1); | 
| 1379 | 1379 | $c = new Categorie($db); | 
| 1380 | 1380 | $cats = $c->containing($object->id, Categorie::TYPE_PRODUCT); | 
| @@ -1388,7 +1388,7 @@ discard block | ||
| 1388 | 1388 | |
| 1389 | 1389 | // Note private | 
| 1390 | 1390 |              if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
 | 
| 1391 | -                print '<tr><td class="tdtop">' . $langs->trans("NoteNotVisibleOnBill") . '</td><td colspan="3">';
 | |
| 1391 | +                print '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="3">';
 | |
| 1392 | 1392 | |
| 1393 | 1393 |                  $doleditor = new DolEditor('note_private', $object->note_private, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%');
 | 
| 1394 | 1394 | $doleditor->Create(); | 
| @@ -1404,7 +1404,7 @@ discard block | ||
| 1404 | 1404 | |
| 1405 | 1405 |              if (!empty($conf->accounting->enabled)) {
 | 
| 1406 | 1406 | // Accountancy_code_sell | 
| 1407 | -                print '<tr><td class="titlefield">' . $langs->trans("ProductAccountancySellCode") . '</td>';
 | |
| 1407 | +                print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellCode").'</td>';
 | |
| 1408 | 1408 | print '<td>'; | 
| 1409 | 1409 | print $formaccounting->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, '', 1, 1); | 
| 1410 | 1410 | print '</td></tr>'; | 
| @@ -1412,47 +1412,47 @@ discard block | ||
| 1412 | 1412 |                  if ($conf->global->MAIN_FEATURES_LEVEL) {
 | 
| 1413 | 1413 | // Accountancy_code_sell_intra | 
| 1414 | 1414 |                      if ($mysoc->isInEEC()) {
 | 
| 1415 | -                        print '<tr><td class="titlefield">' . $langs->trans("ProductAccountancySellIntraCode") . '</td>';
 | |
| 1415 | +                        print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellIntraCode").'</td>';
 | |
| 1416 | 1416 | print '<td>'; | 
| 1417 | 1417 | print $formaccounting->select_account($object->accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, '', 1, 1); | 
| 1418 | 1418 | print '</td></tr>'; | 
| 1419 | 1419 | } | 
| 1420 | 1420 | |
| 1421 | 1421 | // Accountancy_code_sell_export | 
| 1422 | -                    print '<tr><td class="titlefield">' . $langs->trans("ProductAccountancySellExportCode") . '</td>';
 | |
| 1422 | +                    print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellExportCode").'</td>';
 | |
| 1423 | 1423 | print '<td>'; | 
| 1424 | 1424 | print $formaccounting->select_account($object->accountancy_code_sell_export, 'accountancy_code_sell_export', 1, '', 1, 1); | 
| 1425 | 1425 | print '</td></tr>'; | 
| 1426 | 1426 | } | 
| 1427 | 1427 | |
| 1428 | 1428 | // Accountancy_code_buy | 
| 1429 | -                print '<tr><td>' . $langs->trans("ProductAccountancyBuyCode") . '</td>';
 | |
| 1429 | +                print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>';
 | |
| 1430 | 1430 | print '<td>'; | 
| 1431 | 1431 | print $formaccounting->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1); | 
| 1432 | 1432 | print '</td></tr>'; | 
| 1433 | 1433 |              } else { // For external software
 | 
| 1434 | 1434 | // Accountancy_code_sell | 
| 1435 | -                print '<tr><td class="titlefield">' . $langs->trans("ProductAccountancySellCode") . '</td>';
 | |
| 1436 | - print '<td><input name="accountancy_code_sell" class="maxwidth200" value="' . $object->accountancy_code_sell . '">'; | |
| 1435 | +                print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellCode").'</td>';
 | |
| 1436 | + print '<td><input name="accountancy_code_sell" class="maxwidth200" value="'.$object->accountancy_code_sell.'">'; | |
| 1437 | 1437 | print '</td></tr>'; | 
| 1438 | 1438 | |
| 1439 | 1439 |                  if ($conf->global->MAIN_FEATURES_LEVEL) {
 | 
| 1440 | 1440 | // Accountancy_code_sell_intra | 
| 1441 | 1441 |                      if ($mysoc->isInEEC()) {
 | 
| 1442 | -                        print '<tr><td class="titlefield">' . $langs->trans("ProductAccountancySellIntraCode") . '</td>';
 | |
| 1443 | - print '<td><input name="accountancy_code_sell_intra" class="maxwidth200" value="' . $object->accountancy_code_sell_intra . '">'; | |
| 1442 | +                        print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellIntraCode").'</td>';
 | |
| 1443 | + print '<td><input name="accountancy_code_sell_intra" class="maxwidth200" value="'.$object->accountancy_code_sell_intra.'">'; | |
| 1444 | 1444 | print '</td></tr>'; | 
| 1445 | 1445 | } | 
| 1446 | 1446 | |
| 1447 | 1447 | // Accountancy_code_sell_export | 
| 1448 | -                    print '<tr><td class="titlefield">' . $langs->trans("ProductAccountancySellExportCode") . '</td>';
 | |
| 1449 | - print '<td><input name="accountancy_code_sell_export" class="maxwidth200" value="' . $object->accountancy_code_sell_export . '">'; | |
| 1448 | +                    print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellExportCode").'</td>';
 | |
| 1449 | + print '<td><input name="accountancy_code_sell_export" class="maxwidth200" value="'.$object->accountancy_code_sell_export.'">'; | |
| 1450 | 1450 | print '</td></tr>'; | 
| 1451 | 1451 | } | 
| 1452 | 1452 | |
| 1453 | 1453 | // Accountancy_code_buy | 
| 1454 | -                print '<tr><td>' . $langs->trans("ProductAccountancyBuyCode") . '</td>';
 | |
| 1455 | - print '<td><input name="accountancy_code_buy" class="maxwidth200" value="' . $object->accountancy_code_buy . '">'; | |
| 1454 | +                print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>';
 | |
| 1455 | + print '<td><input name="accountancy_code_buy" class="maxwidth200" value="'.$object->accountancy_code_buy.'">'; | |
| 1456 | 1456 | print '</td></tr>'; | 
| 1457 | 1457 | } | 
| 1458 | 1458 | print '</table>'; | 
| @@ -1460,9 +1460,9 @@ discard block | ||
| 1460 | 1460 | dol_fiche_end(); | 
| 1461 | 1461 | |
| 1462 | 1462 | print '<div class="center">'; | 
| 1463 | -            print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
 | |
| 1463 | +            print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
 | |
| 1464 | 1464 | print '     '; | 
| 1465 | -            print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
 | |
| 1465 | +            print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
 | |
| 1466 | 1466 | print '</div>'; | 
| 1467 | 1467 | |
| 1468 | 1468 | print '</form>'; | 
| @@ -1474,13 +1474,13 @@ discard block | ||
| 1474 | 1474 | $showbarcode = 0; | 
| 1475 | 1475 | |
| 1476 | 1476 | $head = product_prepare_head($object); | 
| 1477 | -            $titre = $langs->trans("CardProduct" . $object->type);
 | |
| 1477 | +            $titre = $langs->trans("CardProduct".$object->type);
 | |
| 1478 | 1478 | $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); | 
| 1479 | 1479 | |
| 1480 | 1480 | dol_fiche_head($head, 'card', $titre, -1, $picto); | 
| 1481 | 1481 | |
| 1482 | -            $linkback = '<a href="' . DOL_URL_ROOT . '/product/list.php?restore_lastsearch_values=1&type=' . $object->type . '">' . $langs->trans("BackToList") . '</a>';
 | |
| 1483 | - $object->next_prev_filter = " fk_product_type = " . $object->type; | |
| 1482 | +            $linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1&type='.$object->type.'">'.$langs->trans("BackToList").'</a>';
 | |
| 1483 | + $object->next_prev_filter = " fk_product_type = ".$object->type; | |
| 1484 | 1484 | |
| 1485 | 1485 | $shownav = 1; | 
| 1486 | 1486 |              if ($user->societe_id && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL)))
 | 
| @@ -1498,8 +1498,8 @@ discard block | ||
| 1498 | 1498 | // Type | 
| 1499 | 1499 |              if (!empty($conf->produit->enabled) && !empty($conf->service->enabled)) {
 | 
| 1500 | 1500 | // TODO change for compatibility with edit in place | 
| 1501 | -                $typeformat = 'select;0:' . $langs->trans("Product") . ',1:' . $langs->trans("Service");
 | |
| 1502 | -                print '<tr><td class="titlefield">' . $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat) . '</td><td colspan="2">';
 | |
| 1501 | +                $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service");
 | |
| 1502 | +                print '<tr><td class="titlefield">'.$form->editfieldkey("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat).'</td><td colspan="2">';
 | |
| 1503 | 1503 |                  print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat);
 | 
| 1504 | 1504 | print '</td></tr>'; | 
| 1505 | 1505 | } | 
| @@ -1511,20 +1511,20 @@ discard block | ||
| 1511 | 1511 |                  print $langs->trans("BarcodeType");
 | 
| 1512 | 1512 | print '</td>'; | 
| 1513 | 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>';
 | |
| 1514 | +                    print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcodetype&id='.$object->id.'">'.img_edit($langs->trans('Edit'), 1).'</a></td>';
 | |
| 1515 | 1515 | print '</tr></table>'; | 
| 1516 | 1516 | print '</td><td colspan="2">'; | 
| 1517 | 1517 |                  if ($action == 'editbarcodetype' || $action == 'editbarcode') {
 | 
| 1518 | - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formbarcode.class.php'; | |
| 1518 | + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; | |
| 1519 | 1519 | $formbarcode = new FormBarCode($db); | 
| 1520 | 1520 | } | 
| 1521 | 1521 |                  if ($action == 'editbarcodetype') {
 | 
| 1522 | - print $formbarcode->formBarcodeType($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->barcode_type, 'fk_barcode_type'); | |
| 1522 | + print $formbarcode->formBarcodeType($_SERVER['PHP_SELF'].'?id='.$object->id, $object->barcode_type, 'fk_barcode_type'); | |
| 1523 | 1523 |                  } else {
 | 
| 1524 | 1524 | $object->fetch_barcode(); | 
| 1525 | -                    print $object->barcode_type_label ? $object->barcode_type_label : ($object->barcode ? '<div class="warning">' . $langs->trans("SetDefaultBarcodeType") . '<div>' : '');
 | |
| 1525 | +                    print $object->barcode_type_label ? $object->barcode_type_label : ($object->barcode ? '<div class="warning">'.$langs->trans("SetDefaultBarcodeType").'<div>' : '');
 | |
| 1526 | 1526 | } | 
| 1527 | - print '</td></tr>' . "\n"; | |
| 1527 | + print '</td></tr>'."\n"; | |
| 1528 | 1528 | |
| 1529 | 1529 | // Barcode value | 
| 1530 | 1530 | print '<tr><td class="nowrap">'; | 
| @@ -1532,7 +1532,7 @@ discard block | ||
| 1532 | 1532 |                  print $langs->trans("BarcodeValue");
 | 
| 1533 | 1533 | print '</td>'; | 
| 1534 | 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>';
 | |
| 1535 | +                    print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcode&id='.$object->id.'">'.img_edit($langs->trans('Edit'), 1).'</a></td>';
 | |
| 1536 | 1536 | print '</tr></table>'; | 
| 1537 | 1537 | print '</td><td colspan="2">'; | 
| 1538 | 1538 |                  if ($action == 'editbarcode') {
 | 
| @@ -1541,18 +1541,18 @@ discard block | ||
| 1541 | 1541 | $tmpcode = $modBarCodeProduct->getNextValue($object, $type); | 
| 1542 | 1542 | |
| 1543 | 1543 | // print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">'; | 
| 1544 | - print '<form method="POST" href="' . BASE_URI . '?controller=product&method=card&id=' . $object->id . '">'; | |
| 1545 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 1544 | + print '<form method="POST" href="'.BASE_URI.'?controller=product&method=card&id='.$object->id.'">'; | |
| 1545 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 1546 | 1546 | print '<input type="hidden" name="action" value="setbarcode">'; | 
| 1547 | - print '<input type="hidden" name="barcode_type_code" value="' . $object->barcode_type_code . '">'; | |
| 1548 | - print '<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="' . $tmpcode . '">'; | |
| 1549 | -                    print ' <input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
 | |
| 1547 | + print '<input type="hidden" name="barcode_type_code" value="'.$object->barcode_type_code.'">'; | |
| 1548 | + print '<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="'.$tmpcode.'">'; | |
| 1549 | +                    print ' <input type="submit" class="button" value="'.$langs->trans("Modify").'">';
 | |
| 1550 | 1550 | print '</form>'; | 
| 1551 | 1551 | } | 
| 1552 | 1552 |                  else {
 | 
| 1553 | 1553 | print $object->barcode; | 
| 1554 | 1554 | } | 
| 1555 | - print '</td></tr>' . "\n"; | |
| 1555 | + print '</td></tr>'."\n"; | |
| 1556 | 1556 | } | 
| 1557 | 1557 | |
| 1558 | 1558 | // Accountancy sell code | 
| @@ -1626,7 +1626,7 @@ discard block | ||
| 1626 | 1626 | // Batch number management (to batch) | 
| 1627 | 1627 |              if (!empty($conf->productbatch->enabled)) {
 | 
| 1628 | 1628 |                  if ($object->isProduct() || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
 | 
| 1629 | -                    print '<tr><td>' . $langs->trans("ManageLotSerial") . '</td><td colspan="2">';
 | |
| 1629 | +                    print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td colspan="2">';
 | |
| 1630 | 1630 |                      if (!empty($conf->use_javascript_ajax) && $usercancreate && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
 | 
| 1631 | 1631 | print ajax_object_onoff($object, 'status_batch', 'tobatch', 'ProductStatusOnBatch', 'ProductStatusNotOnBatch'); | 
| 1632 | 1632 |                      } else {
 | 
| @@ -1637,10 +1637,10 @@ discard block | ||
| 1637 | 1637 | } | 
| 1638 | 1638 | |
| 1639 | 1639 | // Description | 
| 1640 | -            print '<tr><td class="tdtop">' . $langs->trans("Description") . '</td><td colspan="2">' . (dol_textishtml($object->description) ? $object->description : dol_nl2br($object->description, 1, true)) . '</td></tr>';
 | |
| 1640 | +            print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="2">'.(dol_textishtml($object->description) ? $object->description : dol_nl2br($object->description, 1, true)).'</td></tr>';
 | |
| 1641 | 1641 | |
| 1642 | 1642 | // Public URL | 
| 1643 | -            print '<tr><td>' . $langs->trans("PublicUrl") . '</td><td colspan="2">';
 | |
| 1643 | +            print '<tr><td>'.$langs->trans("PublicUrl").'</td><td colspan="2">';
 | |
| 1644 | 1644 | print dol_print_url($object->url); | 
| 1645 | 1645 | print '</td></tr>'; | 
| 1646 | 1646 | |
| @@ -1649,7 +1649,7 @@ discard block | ||
| 1649 | 1649 | $warehouse = new Entrepot($db); | 
| 1650 | 1650 | $warehouse->fetch($object->fk_default_warehouse); | 
| 1651 | 1651 | |
| 1652 | -                print '<tr><td>' . $langs->trans("DefaultWarehouse") . '</td><td>';
 | |
| 1652 | +                print '<tr><td>'.$langs->trans("DefaultWarehouse").'</td><td>';
 | |
| 1653 | 1653 | print (!empty($warehouse->id) ? $warehouse->getNomUrl(1) : ''); | 
| 1654 | 1654 | print '</td>'; | 
| 1655 | 1655 | } | 
| @@ -1664,7 +1664,7 @@ discard block | ||
| 1664 | 1664 | $prodstatic->fetch($combination->fk_product_parent); | 
| 1665 | 1665 | |
| 1666 | 1666 | // Parent product | 
| 1667 | -                    print '<tr><td>' . $langs->trans("ParentProduct") . '</td><td colspan="2">';
 | |
| 1667 | +                    print '<tr><td>'.$langs->trans("ParentProduct").'</td><td colspan="2">';
 | |
| 1668 | 1668 | print $prodstatic->getNomUrl(1); | 
| 1669 | 1669 | print '</td></tr>'; | 
| 1670 | 1670 | } | 
| @@ -1679,41 +1679,41 @@ discard block | ||
| 1679 | 1679 | |
| 1680 | 1680 | // Nature | 
| 1681 | 1681 |              if ($object->type != Product::TYPE_SERVICE) {
 | 
| 1682 | -                print '<tr><td class="titlefield">' . $langs->trans("Nature") . '</td><td colspan="2">';
 | |
| 1682 | +                print '<tr><td class="titlefield">'.$langs->trans("Nature").'</td><td colspan="2">';
 | |
| 1683 | 1683 | print $object->getLibFinished(); | 
| 1684 | 1684 | print '</td></tr>'; | 
| 1685 | 1685 | } | 
| 1686 | 1686 | |
| 1687 | 1687 |              if ($object->isService()) {
 | 
| 1688 | 1688 | // Duration | 
| 1689 | -                print '<tr><td class="titlefield">' . $langs->trans("Duration") . '</td><td colspan="2">' . $object->duration_value . ' ';
 | |
| 1689 | +                print '<tr><td class="titlefield">'.$langs->trans("Duration").'</td><td colspan="2">'.$object->duration_value.' ';
 | |
| 1690 | 1690 |                  if ($object->duration_value > 1) {
 | 
| 1691 | 1691 |                      $dur = array("i" => $langs->trans("Minute"), "h" => $langs->trans("Hours"), "d" => $langs->trans("Days"), "w" => $langs->trans("Weeks"), "m" => $langs->trans("Months"), "y" => $langs->trans("Years"));
 | 
| 1692 | 1692 |                  } else if ($object->duration_value > 0) {
 | 
| 1693 | 1693 |                      $dur = array("i" => $langs->trans("Minute"), "h" => $langs->trans("Hour"), "d" => $langs->trans("Day"), "w" => $langs->trans("Week"), "m" => $langs->trans("Month"), "y" => $langs->trans("Year"));
 | 
| 1694 | 1694 | } | 
| 1695 | - print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '') . " "; | |
| 1695 | + print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')." "; | |
| 1696 | 1696 | |
| 1697 | 1697 | print '</td></tr>'; | 
| 1698 | 1698 |              } else {
 | 
| 1699 | 1699 | // Weight | 
| 1700 | -                print '<tr><td class="titlefield">' . $langs->trans("Weight") . '</td><td colspan="2">';
 | |
| 1700 | +                print '<tr><td class="titlefield">'.$langs->trans("Weight").'</td><td colspan="2">';
 | |
| 1701 | 1701 |                  if ($object->weight != '') {
 | 
| 1702 | - print $object->weight . " " . measuring_units_string($object->weight_units, "weight"); | |
| 1702 | + print $object->weight." ".measuring_units_string($object->weight_units, "weight"); | |
| 1703 | 1703 |                  } else {
 | 
| 1704 | 1704 | print ' '; | 
| 1705 | 1705 | } | 
| 1706 | 1706 | print "</td></tr>\n"; | 
| 1707 | 1707 |                  if (empty($conf->global->PRODUCT_DISABLE_SIZE)) {
 | 
| 1708 | 1708 | // Length | 
| 1709 | -                    print '<tr><td>' . $langs->trans("Length") . ' x ' . $langs->trans("Width") . ' x ' . $langs->trans("Height") . '</td><td colspan="2">';
 | |
| 1709 | +                    print '<tr><td>'.$langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").'</td><td colspan="2">';
 | |
| 1710 | 1710 |                      if ($object->length != '' || $object->width != '' || $object->height != '') {
 | 
| 1711 | 1711 | print $object->length; | 
| 1712 | 1712 | if ($object->width) | 
| 1713 | - print " x " . $object->width; | |
| 1713 | + print " x ".$object->width; | |
| 1714 | 1714 | if ($object->height) | 
| 1715 | - print " x " . $object->height; | |
| 1716 | - print ' ' . measuring_units_string($object->length_units, "size"); | |
| 1715 | + print " x ".$object->height; | |
| 1716 | + print ' '.measuring_units_string($object->length_units, "size"); | |
| 1717 | 1717 | } | 
| 1718 | 1718 |                      else {
 | 
| 1719 | 1719 | print ' '; | 
| @@ -1722,9 +1722,9 @@ discard block | ||
| 1722 | 1722 | } | 
| 1723 | 1723 |                  if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) {
 | 
| 1724 | 1724 | // Surface | 
| 1725 | -                    print '<tr><td>' . $langs->trans("Surface") . '</td><td colspan="2">';
 | |
| 1725 | +                    print '<tr><td>'.$langs->trans("Surface").'</td><td colspan="2">';
 | |
| 1726 | 1726 |                      if ($object->surface != '') {
 | 
| 1727 | - print $object->surface . " " . measuring_units_string($object->surface_units, "surface"); | |
| 1727 | + print $object->surface." ".measuring_units_string($object->surface_units, "surface"); | |
| 1728 | 1728 |                      } else {
 | 
| 1729 | 1729 | print ' '; | 
| 1730 | 1730 | } | 
| @@ -1732,9 +1732,9 @@ discard block | ||
| 1732 | 1732 | } | 
| 1733 | 1733 |                  if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) {
 | 
| 1734 | 1734 | // Volume | 
| 1735 | -                    print '<tr><td>' . $langs->trans("Volume") . '</td><td colspan="2">';
 | |
| 1735 | +                    print '<tr><td>'.$langs->trans("Volume").'</td><td colspan="2">';
 | |
| 1736 | 1736 |                      if ($object->volume != '') {
 | 
| 1737 | - print $object->volume . " " . measuring_units_string($object->volume_units, "volume"); | |
| 1737 | + print $object->volume." ".measuring_units_string($object->volume_units, "volume"); | |
| 1738 | 1738 |                      } else {
 | 
| 1739 | 1739 | print ' '; | 
| 1740 | 1740 | } | 
| @@ -1746,7 +1746,7 @@ discard block | ||
| 1746 | 1746 |              if (!empty($conf->global->PRODUCT_USE_UNITS)) {
 | 
| 1747 | 1747 | $unit = $object->getLabelOfUnit(); | 
| 1748 | 1748 | |
| 1749 | -                print '<tr><td>' . $langs->trans('DefaultUnitToShow') . '</td><td>';
 | |
| 1749 | +                print '<tr><td>'.$langs->trans('DefaultUnitToShow').'</td><td>';
 | |
| 1750 | 1750 |                  if ($unit !== '') {
 | 
| 1751 | 1751 | print $langs->trans($unit); | 
| 1752 | 1752 | } | 
| @@ -1755,28 +1755,28 @@ discard block | ||
| 1755 | 1755 | |
| 1756 | 1756 | // Custom code | 
| 1757 | 1757 |              if (!$object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) {
 | 
| 1758 | -                print '<tr><td>' . $langs->trans("CustomCode") . '</td><td colspan="2">' . $object->customcode . '</td>';
 | |
| 1758 | +                print '<tr><td>'.$langs->trans("CustomCode").'</td><td colspan="2">'.$object->customcode.'</td>';
 | |
| 1759 | 1759 | |
| 1760 | 1760 | // Origin country code | 
| 1761 | -                print '<tr><td>' . $langs->trans("CountryOrigin") . '</td><td colspan="2">' . getCountry($object->country_id, 0, $db) . '</td>';
 | |
| 1761 | +                print '<tr><td>'.$langs->trans("CountryOrigin").'</td><td colspan="2">'.getCountry($object->country_id, 0, $db).'</td>';
 | |
| 1762 | 1762 | } | 
| 1763 | 1763 | |
| 1764 | 1764 | // Other attributes | 
| 1765 | -            $parameters = array('colspan' => ' colspan="' . (2 + (($showphoto || $showbarcode) ? 1 : 0)) . '"');
 | |
| 1766 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; | |
| 1765 | +            $parameters = array('colspan' => ' colspan="'.(2 + (($showphoto || $showbarcode) ? 1 : 0)).'"');
 | |
| 1766 | + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; | |
| 1767 | 1767 | |
| 1768 | 1768 | // Categories | 
| 1769 | 1769 |              if ($conf->categorie->enabled) {
 | 
| 1770 | -                print '<tr><td valign="middle">' . $langs->trans("Categories") . '</td><td colspan="3">';
 | |
| 1770 | +                print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td colspan="3">';
 | |
| 1771 | 1771 | print $form->showCategories($object->id, 'product', 1); | 
| 1772 | 1772 | print "</td></tr>"; | 
| 1773 | 1773 | } | 
| 1774 | 1774 | |
| 1775 | 1775 | // Note private | 
| 1776 | 1776 |              if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
 | 
| 1777 | - print '<!-- show Note --> ' . "\n"; | |
| 1778 | -                print '<tr><td class="tdtop">' . $langs->trans("NotePrivate") . '</td><td colspan="' . (2 + (($showphoto || $showbarcode) ? 1 : 0)) . '">' . (dol_textishtml($object->note_private) ? $object->note_private : dol_nl2br($object->note_private, 1, true)) . '</td></tr>' . "\n";
 | |
| 1779 | - print '<!-- End show Note --> ' . "\n"; | |
| 1777 | + print '<!-- show Note --> '."\n"; | |
| 1778 | +                print '<tr><td class="tdtop">'.$langs->trans("NotePrivate").'</td><td colspan="'.(2 + (($showphoto || $showbarcode) ? 1 : 0)).'">'.(dol_textishtml($object->note_private) ? $object->note_private : dol_nl2br($object->note_private, 1, true)).'</td></tr>'."\n";
 | |
| 1779 | + print '<!-- End show Note --> '."\n"; | |
| 1780 | 1780 | } | 
| 1781 | 1781 | |
| 1782 | 1782 | print "</table>\n"; | 
| @@ -1797,7 +1797,7 @@ discard block | ||
| 1797 | 1797 |  if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') {
 | 
| 1798 | 1798 | $module = substr($module, 0, dol_strlen($module) - 4); | 
| 1799 | 1799 | } | 
| 1800 | -$result = dol_include_once('/core/modules/product/' . $module . '.php');
 | |
| 1800 | +$result = dol_include_once('/core/modules/product/'.$module.'.php');
 | |
| 1801 | 1801 |  if ($result > 0) {
 | 
| 1802 | 1802 | $modCodeProduct = new $module(); | 
| 1803 | 1803 | } | 
| @@ -1809,9 +1809,9 @@ discard block | ||
| 1809 | 1809 | // Define confirmation messages | 
| 1810 | 1810 | $formquestionclone = array( | 
| 1811 | 1811 |      'text' => $langs->trans("ConfirmClone"),
 | 
| 1812 | -    array('type' => 'text', 'name' => 'clone_ref', 'label' => $langs->trans("NewRefForClone"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf") . ' ' . $object->ref : $tmpcode, 'size' => 24),
 | |
| 1812 | +    array('type' => 'text', 'name' => 'clone_ref', 'label' => $langs->trans("NewRefForClone"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf").' '.$object->ref : $tmpcode, 'size' => 24),
 | |
| 1813 | 1813 |      array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneContentProduct"), 'value' => 1),
 | 
| 1814 | -    array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct") . ' (' . $langs->trans("FeatureNotYetAvailable") . ')', 'value' => 0, 'disabled' => true),
 | |
| 1814 | +    array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true),
 | |
| 1815 | 1815 | ); | 
| 1816 | 1816 |  if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) {
 | 
| 1817 | 1817 |      $formquestionclone[] = array('type' => 'checkbox', 'name' => 'clone_composition', 'label' => $langs->trans('CloneCompositionProduct'), 'value' => 1);
 | 
| @@ -1820,13 +1820,13 @@ discard block | ||
| 1820 | 1820 | // Confirm delete product | 
| 1821 | 1821 | if (($action == 'delete' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js | 
| 1822 | 1822 |      || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) {       // Always output when not jmobile nor js
 | 
| 1823 | -    print $form->formconfirm("card.php?id=" . $object->id, $langs->trans("DeleteProduct"), $langs->trans("ConfirmDeleteProduct"), "confirm_delete", '', 0, "action-delete");
 | |
| 1823 | +    print $form->formconfirm("card.php?id=".$object->id, $langs->trans("DeleteProduct"), $langs->trans("ConfirmDeleteProduct"), "confirm_delete", '', 0, "action-delete");
 | |
| 1824 | 1824 | } | 
| 1825 | 1825 | |
| 1826 | 1826 | // Clone confirmation | 
| 1827 | 1827 | if (($action == 'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js | 
| 1828 | 1828 |      || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) {       // Always output when not jmobile nor js
 | 
| 1829 | -    print $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneProduct'), $langs->trans('ConfirmCloneProduct', $object->ref), 'confirm_clone', $formquestionclone, 'yes', 'action-clone', 260, 600);
 | |
| 1829 | +    print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('CloneProduct'), $langs->trans('ConfirmCloneProduct', $object->ref), 'confirm_clone', $formquestionclone, 'yes', 'action-clone', 260, 600);
 | |
| 1830 | 1830 | } | 
| 1831 | 1831 | |
| 1832 | 1832 | |
| @@ -1836,20 +1836,20 @@ discard block | ||
| 1836 | 1836 | /* */ | 
| 1837 | 1837 | /* * ************************************************************************* */ | 
| 1838 | 1838 |  if ($action != 'create' && $action != 'edit') {
 | 
| 1839 | - print "\n" . '<div class="tabsAction">' . "\n"; | |
| 1839 | + print "\n".'<div class="tabsAction">'."\n"; | |
| 1840 | 1840 | |
| 1841 | 1841 | $parameters = array(); | 
| 1842 | -    $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action);    // Note that $action and $object may have been modified by hook
 | |
| 1842 | +    $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
 | |
| 1843 | 1843 |      if (empty($reshook)) {
 | 
| 1844 | 1844 |          if ($usercancreate) {
 | 
| 1845 | 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>';
 | |
| 1846 | +                print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$object->id.'">'.$langs->trans("Modify").'</a></div>';
 | |
| 1847 | 1847 | |
| 1848 | 1848 |              if (!isset($object->no_button_copy) || $object->no_button_copy <> 1) {
 | 
| 1849 | 1849 |                  if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) {
 | 
| 1850 | -                    print '<div class="inline-block divButAction"><span id="action-clone" class="butAction">' . $langs->trans('ToClone') . '</span></div>' . "\n";
 | |
| 1850 | +                    print '<div class="inline-block divButAction"><span id="action-clone" class="butAction">'.$langs->trans('ToClone').'</span></div>'."\n";
 | |
| 1851 | 1851 |                  } else {
 | 
| 1852 | -                    print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=clone&id=' . $object->id . '">' . $langs->trans("ToClone") . '</a></div>';
 | |
| 1852 | +                    print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=clone&id='.$object->id.'">'.$langs->trans("ToClone").'</a></div>';
 | |
| 1853 | 1853 | } | 
| 1854 | 1854 | } | 
| 1855 | 1855 | } | 
| @@ -1858,15 +1858,15 @@ discard block | ||
| 1858 | 1858 |          if ($usercandelete) {
 | 
| 1859 | 1859 |              if (empty($object_is_used) && (!isset($object->no_button_delete) || $object->no_button_delete <> 1)) {
 | 
| 1860 | 1860 |                  if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) {
 | 
| 1861 | -                    print '<div class="inline-block divButAction"><span id="action-delete" class="butActionDelete">' . $langs->trans('Delete') . '</span></div>' . "\n";
 | |
| 1861 | +                    print '<div class="inline-block divButAction"><span id="action-delete" class="butActionDelete">'.$langs->trans('Delete').'</span></div>'."\n";
 | |
| 1862 | 1862 |                  } else {
 | 
| 1863 | -                    print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?action=delete&id=' . $object->id . '">' . $langs->trans("Delete") . '</a></div>';
 | |
| 1863 | +                    print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans("Delete").'</a></div>';
 | |
| 1864 | 1864 | } | 
| 1865 | 1865 |              } else {
 | 
| 1866 | -                print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . $langs->trans("ProductIsUsed") . '">' . $langs->trans("Delete") . '</a></div>';
 | |
| 1866 | +                print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ProductIsUsed").'">'.$langs->trans("Delete").'</a></div>';
 | |
| 1867 | 1867 | } | 
| 1868 | 1868 |          } else {
 | 
| 1869 | -            print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' . $langs->trans("NotEnoughPermissions") . '">' . $langs->trans("Delete") . '</a></div>';
 | |
| 1869 | +            print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("Delete").'</a></div>';
 | |
| 1870 | 1870 | } | 
| 1871 | 1871 | } | 
| 1872 | 1872 | |
| @@ -1891,12 +1891,12 @@ discard block | ||
| 1891 | 1891 | |
| 1892 | 1892 |          if (is_array($otherprop) && count($otherprop)) {
 | 
| 1893 | 1893 | $html .= '<tr><td style="width: 200px;">'; | 
| 1894 | -            $html .= $langs->trans("AddToDraftProposals") . '</td><td>';
 | |
| 1894 | +            $html .= $langs->trans("AddToDraftProposals").'</td><td>';
 | |
| 1895 | 1895 |              $html .= $form->selectarray("propalid", $otherprop, 0, 1);
 | 
| 1896 | 1896 | $html .= '</td></tr>'; | 
| 1897 | 1897 |          } else {
 | 
| 1898 | 1898 | $html .= '<tr><td style="width: 200px;">'; | 
| 1899 | -            $html .= $langs->trans("AddToDraftProposals") . '</td><td>';
 | |
| 1899 | +            $html .= $langs->trans("AddToDraftProposals").'</td><td>';
 | |
| 1900 | 1900 |              $html .= $langs->trans("NoDraftProposals");
 | 
| 1901 | 1901 | $html .= '</td></tr>'; | 
| 1902 | 1902 | } | 
| @@ -1911,12 +1911,12 @@ discard block | ||
| 1911 | 1911 | $othercom = $commande->liste_array(2, 1, null); | 
| 1912 | 1912 |          if (is_array($othercom) && count($othercom)) {
 | 
| 1913 | 1913 | $html .= '<tr><td style="width: 200px;">'; | 
| 1914 | -            $html .= $langs->trans("AddToDraftOrders") . '</td><td>';
 | |
| 1914 | +            $html .= $langs->trans("AddToDraftOrders").'</td><td>';
 | |
| 1915 | 1915 |              $html .= $form->selectarray("commandeid", $othercom, 0, 1);
 | 
| 1916 | 1916 | $html .= '</td></tr>'; | 
| 1917 | 1917 |          } else {
 | 
| 1918 | 1918 | $html .= '<tr><td style="width: 200px;">'; | 
| 1919 | -            $html .= $langs->trans("AddToDraftOrders") . '</td><td>';
 | |
| 1919 | +            $html .= $langs->trans("AddToDraftOrders").'</td><td>';
 | |
| 1920 | 1920 |              $html .= $langs->trans("NoDraftOrders");
 | 
| 1921 | 1921 | $html .= '</td></tr>'; | 
| 1922 | 1922 | } | 
| @@ -1931,12 +1931,12 @@ discard block | ||
| 1931 | 1931 | $otherinvoice = $invoice->liste_array(2, 1, null); | 
| 1932 | 1932 |          if (is_array($otherinvoice) && count($otherinvoice)) {
 | 
| 1933 | 1933 | $html .= '<tr><td style="width: 200px;">'; | 
| 1934 | -            $html .= $langs->trans("AddToDraftInvoices") . '</td><td>';
 | |
| 1934 | +            $html .= $langs->trans("AddToDraftInvoices").'</td><td>';
 | |
| 1935 | 1935 |              $html .= $form->selectarray("factureid", $otherinvoice, 0, 1);
 | 
| 1936 | 1936 | $html .= '</td></tr>'; | 
| 1937 | 1937 |          } else {
 | 
| 1938 | 1938 | $html .= '<tr><td style="width: 200px;">'; | 
| 1939 | -            $html .= $langs->trans("AddToDraftInvoices") . '</td><td>';
 | |
| 1939 | +            $html .= $langs->trans("AddToDraftInvoices").'</td><td>';
 | |
| 1940 | 1940 |              $html .= $langs->trans("NoDraftInvoices");
 | 
| 1941 | 1941 | $html .= '</td></tr>'; | 
| 1942 | 1942 | } | 
| @@ -1945,17 +1945,17 @@ discard block | ||
| 1945 | 1945 | //If any text is going to be printed, then we show the table | 
| 1946 | 1946 |      if (!empty($html)) {
 | 
| 1947 | 1947 | // print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">'; | 
| 1948 | - print '<form method="POST" href="' . BASE_URI . '?controller=product&method=card&id=' . $object->id . '">'; | |
| 1949 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 1948 | + print '<form method="POST" href="'.BASE_URI.'?controller=product&method=card&id='.$object->id.'">'; | |
| 1949 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 1950 | 1950 | print '<input type="hidden" name="action" value="addin">'; | 
| 1951 | 1951 | |
| 1952 | 1952 |          print load_fiche_titre($langs->trans("AddToDraft"), '', '');
 | 
| 1953 | 1953 | |
| 1954 | 1954 |          dol_fiche_head('');
 | 
| 1955 | 1955 | |
| 1956 | -        $html .= '<tr><td class="nowrap">' . $langs->trans("Quantity") . ' ';
 | |
| 1956 | +        $html .= '<tr><td class="nowrap">'.$langs->trans("Quantity").' ';
 | |
| 1957 | 1957 | $html .= '<input type="text" class="flat" name="qty" size="1" value="1"></td>'; | 
| 1958 | -        $html .= '<td class="nowrap">' . $langs->trans("ReductionShort") . '(%) ';
 | |
| 1958 | +        $html .= '<td class="nowrap">'.$langs->trans("ReductionShort").'(%) ';
 | |
| 1959 | 1959 | $html .= '<input type="text" class="flat" name="remise_percent" size="1" value="0">'; | 
| 1960 | 1960 | $html .= '</td></tr>'; | 
| 1961 | 1961 | |
| @@ -1964,7 +1964,7 @@ discard block | ||
| 1964 | 1964 | print '</table>'; | 
| 1965 | 1965 | |
| 1966 | 1966 | print '<div class="center">'; | 
| 1967 | -        print '<input type="submit" class="button" value="' . $langs->trans("Add") . '">';
 | |
| 1967 | +        print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
 | |
| 1968 | 1968 | print '</div>'; | 
| 1969 | 1969 | |
| 1970 | 1970 | dol_fiche_end(); | 
| @@ -1983,9 +1983,9 @@ discard block | ||
| 1983 | 1983 | print '<a name="builddoc"></a>'; // ancre | 
| 1984 | 1984 | // Documents | 
| 1985 | 1985 | $objectref = dol_sanitizeFileName($object->ref); | 
| 1986 | - $relativepath = $comref . '/' . $objectref . '.pdf'; | |
| 1987 | - $filedir = $conf->produit->dir_output . '/' . $objectref; | |
| 1988 | - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; | |
| 1986 | + $relativepath = $comref.'/'.$objectref.'.pdf'; | |
| 1987 | + $filedir = $conf->produit->dir_output.'/'.$objectref; | |
| 1988 | + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; | |
| 1989 | 1989 | $genallowed = $usercanread; | 
| 1990 | 1990 | $delallowed = $usercancreate; | 
| 1991 | 1991 | |
| @@ -1996,14 +1996,14 @@ discard block | ||
| 1996 | 1996 | |
| 1997 | 1997 | $MAXEVENT = 10; | 
| 1998 | 1998 | |
| 1999 | - $morehtmlright = '<a href="' . DOL_URL_ROOT . '/product/agenda.php?id=' . $object->id . '">'; | |
| 1999 | + $morehtmlright = '<a href="'.DOL_URL_ROOT.'/product/agenda.php?id='.$object->id.'">'; | |
| 2000 | 2000 |      $morehtmlright .= $langs->trans("SeeAll");
 | 
| 2001 | 2001 | $morehtmlright .= '</a>'; | 
| 2002 | 2002 | |
| 2003 | 2003 | // List of actions on element | 
| 2004 | - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; | |
| 2004 | + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; | |
| 2005 | 2005 | $formactions = new FormActions($db); | 
| 2006 | - $somethingshown = $formactions->showactions($object, 'product', 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product | |
| 2006 | + $somethingshown = $formactions->showactions($object, 'product', 0, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for product | |
| 2007 | 2007 | |
| 2008 | 2008 | print '</div></div></div>'; | 
| 2009 | 2009 | } | 
| @@ -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)) {
 | 
| @@ -34,9 +34,9 @@ discard block | ||
| 34 | 34 | * \ingroup produit | 
| 35 | 35 | * \brief File of class to manage predefined products or services | 
| 36 | 36 | */ | 
| 37 | -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; | |
| 38 | -require_once DOL_DOCUMENT_ROOT . '/product/class/productbatch.class.php'; | |
| 39 | -require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php'; | |
| 37 | +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; | |
| 38 | +require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; | |
| 39 | +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; | |
| 40 | 40 | |
| 41 | 41 | /** | 
| 42 | 42 | * Class to manage products or services | 
| @@ -58,7 +58,7 @@ discard block | ||
| 58 | 58 | * @var int Field with ID of parent key if this field has a parent | 
| 59 | 59 | */ | 
| 60 | 60 | public $fk_element = 'fk_product'; | 
| 61 | -    protected $childtables = array('supplier_proposaldet', 'propaldet', 'commandedet', 'facturedet', 'contratdet', 'facture_fourn_det', 'commande_fournisseurdet');    // To test if we can delete object
 | |
| 61 | +    protected $childtables = array('supplier_proposaldet', 'propaldet', 'commandedet', 'facturedet', 'contratdet', 'facture_fourn_det', 'commande_fournisseurdet'); // To test if we can delete object
 | |
| 62 | 62 | |
| 63 | 63 | /** | 
| 64 | 64 | * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe | 
| @@ -105,7 +105,7 @@ discard block | ||
| 105 | 105 | * | 
| 106 | 106 | * @var float | 
| 107 | 107 | */ | 
| 108 | - public $price; // Price net | |
| 108 | + public $price; // Price net | |
| 109 | 109 | |
| 110 | 110 | /** | 
| 111 | 111 | * Price with tax | 
| @@ -505,7 +505,7 @@ discard block | ||
| 505 | 505 |                  if (substr($module, 0, 16) == 'mod_codeproduct_' && substr($module, -3) == 'php') {
 | 
| 506 | 506 | $module = substr($module, 0, dol_strlen($module) - 4); | 
| 507 | 507 | } | 
| 508 | -                dol_include_once('/core/modules/product/' . $module . '.php');
 | |
| 508 | +                dol_include_once('/core/modules/product/'.$module.'.php');
 | |
| 509 | 509 | $modCodeProduct = new $module; | 
| 510 | 510 |                  if (!empty($modCodeProduct->code_auto)) {
 | 
| 511 | 511 | $this->ref = $modCodeProduct->getNextValue($this, $this->type); | 
| @@ -519,7 +519,7 @@ discard block | ||
| 519 | 519 | } | 
| 520 | 520 | } | 
| 521 | 521 | |
| 522 | - dol_syslog(get_class($this) . "::create ref=" . $this->ref . " price=" . $this->price . " price_ttc=" . $this->price_ttc . " tva_tx=" . $this->tva_tx . " price_base_type=" . $this->price_base_type, LOG_DEBUG); | |
| 522 | + dol_syslog(get_class($this)."::create ref=".$this->ref." price=".$this->price." price_ttc=".$this->price_ttc." tva_tx=".$this->tva_tx." price_base_type=".$this->price_base_type, LOG_DEBUG); | |
| 523 | 523 | |
| 524 | 524 | $now = dol_now(); | 
| 525 | 525 | |
| @@ -536,16 +536,16 @@ discard block | ||
| 536 | 536 | |
| 537 | 537 |          if ($result >= 0) {
 | 
| 538 | 538 | $sql = "SELECT count(*) as nb"; | 
| 539 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product"; | |
| 540 | -            $sql .= " WHERE entity IN (" . getEntity('product') . ")";
 | |
| 541 | - $sql .= " AND ref = '" . $this->db->escape($this->ref) . "'"; | |
| 539 | + $sql .= " FROM ".MAIN_DB_PREFIX."product"; | |
| 540 | +            $sql .= " WHERE entity IN (".getEntity('product').")";
 | |
| 541 | + $sql .= " AND ref = '".$this->db->escape($this->ref)."'"; | |
| 542 | 542 | |
| 543 | 543 | $result = $this->db->query($sql); | 
| 544 | 544 |              if ($result) {
 | 
| 545 | 545 | $obj = $this->db->fetch_object($result); | 
| 546 | 546 |                  if ($obj->nb == 0) {
 | 
| 547 | 547 | // Produit non deja existant | 
| 548 | -                    $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product (";
 | |
| 548 | +                    $sql = "INSERT INTO ".MAIN_DB_PREFIX."product (";
 | |
| 549 | 549 | $sql .= "datec"; | 
| 550 | 550 | $sql .= ", entity"; | 
| 551 | 551 | $sql .= ", ref"; | 
| @@ -569,34 +569,34 @@ discard block | ||
| 569 | 569 | $sql .= ", tobatch"; | 
| 570 | 570 | $sql .= ", fk_unit"; | 
| 571 | 571 |                      $sql .= ") VALUES (";
 | 
| 572 | - $sql .= "'" . $this->db->idate($now) . "'"; | |
| 573 | - $sql .= ", " . $conf->entity; | |
| 574 | - $sql .= ", '" . $this->db->escape($this->ref) . "'"; | |
| 575 | - $sql .= ", " . (!empty($this->ref_ext) ? "'" . $this->db->escape($this->ref_ext) . "'" : "null"); | |
| 576 | - $sql .= ", " . price2num($price_min_ht); | |
| 577 | - $sql .= ", " . price2num($price_min_ttc); | |
| 578 | - $sql .= ", " . (!empty($this->label) ? "'" . $this->db->escape($this->label) . "'" : "null"); | |
| 579 | - $sql .= ", " . $user->id; | |
| 580 | - $sql .= ", " . $this->type; | |
| 581 | - $sql .= ", " . price2num($price_ht); | |
| 582 | - $sql .= ", " . price2num($price_ttc); | |
| 583 | - $sql .= ", '" . $this->db->escape($this->price_base_type) . "'"; | |
| 584 | - $sql .= ", " . $this->status; | |
| 585 | - $sql .= ", " . $this->status_buy; | |
| 586 | - $sql .= ", '" . $this->db->escape($this->accountancy_code_buy) . "'"; | |
| 587 | - $sql .= ", '" . $this->db->escape($this->accountancy_code_sell) . "'"; | |
| 588 | - $sql .= ", '" . $this->db->escape($this->accountancy_code_sell_intra) . "'"; | |
| 589 | - $sql .= ", '" . $this->db->escape($this->accountancy_code_sell_export) . "'"; | |
| 590 | - $sql .= ", '" . $this->db->escape($this->canvas) . "'"; | |
| 591 | - $sql .= ", " . ((!isset($this->finished) || $this->finished < 0 || $this->finished == '') ? 'null' : (int) $this->finished); | |
| 592 | - $sql .= ", " . ((empty($this->status_batch) || $this->status_batch < 0) ? '0' : $this->status_batch); | |
| 593 | - $sql .= ", " . (!$this->fk_unit ? 'NULL' : $this->fk_unit); | |
| 572 | + $sql .= "'".$this->db->idate($now)."'"; | |
| 573 | + $sql .= ", ".$conf->entity; | |
| 574 | + $sql .= ", '".$this->db->escape($this->ref)."'"; | |
| 575 | + $sql .= ", ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null"); | |
| 576 | + $sql .= ", ".price2num($price_min_ht); | |
| 577 | + $sql .= ", ".price2num($price_min_ttc); | |
| 578 | + $sql .= ", ".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); | |
| 579 | + $sql .= ", ".$user->id; | |
| 580 | + $sql .= ", ".$this->type; | |
| 581 | + $sql .= ", ".price2num($price_ht); | |
| 582 | + $sql .= ", ".price2num($price_ttc); | |
| 583 | + $sql .= ", '".$this->db->escape($this->price_base_type)."'"; | |
| 584 | + $sql .= ", ".$this->status; | |
| 585 | + $sql .= ", ".$this->status_buy; | |
| 586 | + $sql .= ", '".$this->db->escape($this->accountancy_code_buy)."'"; | |
| 587 | + $sql .= ", '".$this->db->escape($this->accountancy_code_sell)."'"; | |
| 588 | + $sql .= ", '".$this->db->escape($this->accountancy_code_sell_intra)."'"; | |
| 589 | + $sql .= ", '".$this->db->escape($this->accountancy_code_sell_export)."'"; | |
| 590 | + $sql .= ", '".$this->db->escape($this->canvas)."'"; | |
| 591 | + $sql .= ", ".((!isset($this->finished) || $this->finished < 0 || $this->finished == '') ? 'null' : (int) $this->finished); | |
| 592 | + $sql .= ", ".((empty($this->status_batch) || $this->status_batch < 0) ? '0' : $this->status_batch); | |
| 593 | + $sql .= ", ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); | |
| 594 | 594 | $sql .= ")"; | 
| 595 | 595 | |
| 596 | - dol_syslog(get_class($this) . "::Create", LOG_DEBUG); | |
| 596 | + dol_syslog(get_class($this)."::Create", LOG_DEBUG); | |
| 597 | 597 | $result = $this->db->query($sql); | 
| 598 | 598 |                      if ($result) {
 | 
| 599 | - $id = $this->db->last_insert_id(MAIN_DB_PREFIX . "product"); | |
| 599 | + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."product"); | |
| 600 | 600 | |
| 601 | 601 |                          if ($id > 0) {
 | 
| 602 | 602 | $this->id = $id; | 
| @@ -651,7 +651,7 @@ discard block | ||
| 651 | 651 | } | 
| 652 | 652 |          } else {
 | 
| 653 | 653 | $this->db->rollback(); | 
| 654 | -            dol_syslog(get_class($this) . "::Create fails verify " . join(',', $this->errors), LOG_WARNING);
 | |
| 654 | +            dol_syslog(get_class($this)."::Create fails verify ".join(',', $this->errors), LOG_WARNING);
 | |
| 655 | 655 | return -3; | 
| 656 | 656 | } | 
| 657 | 657 | } | 
| @@ -711,7 +711,7 @@ discard block | ||
| 711 | 711 | |
| 712 | 712 |              $dirsociete = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']);
 | 
| 713 | 713 |              foreach ($dirsociete as $dirroot) {
 | 
| 714 | - $res = dol_include_once($dirroot . $module . '.php'); | |
| 714 | + $res = dol_include_once($dirroot.$module.'.php'); | |
| 715 | 715 |                  if ($res) {
 | 
| 716 | 716 | break; | 
| 717 | 717 | } | 
| @@ -719,7 +719,7 @@ discard block | ||
| 719 | 719 | |
| 720 | 720 | $mod = new $module(); | 
| 721 | 721 | |
| 722 | - dol_syslog(get_class($this) . "::check_barcode value=" . $valuetotest . " type=" . $typefortest . " module=" . $module); | |
| 722 | + dol_syslog(get_class($this)."::check_barcode value=".$valuetotest." type=".$typefortest." module=".$module); | |
| 723 | 723 | $result = $mod->verif($this->db, $valuetotest, $this, 0, $typefortest); | 
| 724 | 724 | return $result; | 
| 725 | 725 |          } else {
 | 
| @@ -763,10 +763,10 @@ discard block | ||
| 763 | 763 | $this->height_units = trim($this->height_units); | 
| 764 | 764 | // set unit not defined | 
| 765 | 765 |          if ($this->length_units) {
 | 
| 766 | - $this->width_units = $this->length_units; // Not used yet | |
| 766 | + $this->width_units = $this->length_units; // Not used yet | |
| 767 | 767 | } | 
| 768 | 768 |          if ($this->length_units) {
 | 
| 769 | - $this->height_units = $this->length_units; // Not used yet | |
| 769 | + $this->height_units = $this->length_units; // Not used yet | |
| 770 | 770 | } | 
| 771 | 771 | // Automated compute surface and volume if not filled | 
| 772 | 772 |          if (empty($this->surface) && !empty($this->length) && !empty($this->width) && $this->length_units == $this->width_units) {
 | 
| @@ -825,7 +825,7 @@ discard block | ||
| 825 | 825 | // Check name is required and codes are ok or unique. | 
| 826 | 826 | // If error, this->errors[] is filled | 
| 827 | 827 |          if ($action != 'add') {
 | 
| 828 | - $result = $this->verify(); // We don't check when update called during a create because verify was already done | |
| 828 | + $result = $this->verify(); // We don't check when update called during a create because verify was already done | |
| 829 | 829 | } | 
| 830 | 830 | |
| 831 | 831 |          if ($result >= 0) {
 | 
| @@ -841,7 +841,7 @@ discard block | ||
| 841 | 841 | //$valueforundefinedlot = 'Undefined'; // In previous version, 39 and lower | 
| 842 | 842 | $valueforundefinedlot = '000000'; | 
| 843 | 843 | |
| 844 | -                dol_syslog("Flag batch of product id=" . $this->id . " is set to ON, so we will create missing records into product_batch");
 | |
| 844 | +                dol_syslog("Flag batch of product id=".$this->id." is set to ON, so we will create missing records into product_batch");
 | |
| 845 | 845 | |
| 846 | 846 | $this->load_stock(); | 
| 847 | 847 |                  foreach ($this->stock_warehouse as $idW => $ObjW) {   // For each warehouse where we have stocks defined for this product (for each lines in product_stock)
 | 
| @@ -849,7 +849,7 @@ discard block | ||
| 849 | 849 |                      foreach ($ObjW->detail_batch as $detail) {    // Each lines of detail in product_batch of the current $ObjW = product_stock
 | 
| 850 | 850 |                          if ($detail->batch == $valueforundefinedlot || $detail->batch == 'Undefined') {
 | 
| 851 | 851 | // We discard this line, we will create it later | 
| 852 | -                            $sqlclean = "DELETE FROM " . MAIN_DB_PREFIX . "product_batch WHERE batch in('Undefined', '" . $valueforundefinedlot . "') AND fk_product_stock = " . $ObjW->id;
 | |
| 852 | +                            $sqlclean = "DELETE FROM ".MAIN_DB_PREFIX."product_batch WHERE batch in('Undefined', '".$valueforundefinedlot."') AND fk_product_stock = ".$ObjW->id;
 | |
| 853 | 853 | $result = $this->db->query($sqlclean); | 
| 854 | 854 |                              if (!$result) {
 | 
| 855 | 855 | dol_print_error($this->db); | 
| @@ -881,59 +881,59 @@ discard block | ||
| 881 | 881 | $this->barcode = $this->get_barcode($this, $this->barcode_type_code); | 
| 882 | 882 | } | 
| 883 | 883 | |
| 884 | - $sql = "UPDATE " . MAIN_DB_PREFIX . "product"; | |
| 885 | - $sql .= " SET label = '" . $this->db->escape($this->label) . "'"; | |
| 886 | - $sql .= ", ref = '" . $this->db->escape($this->ref) . "'"; | |
| 887 | - $sql .= ", ref_ext = " . (!empty($this->ref_ext) ? "'" . $this->db->escape($this->ref_ext) . "'" : "null"); | |
| 888 | - $sql .= ", default_vat_code = " . ($this->default_vat_code ? "'" . $this->db->escape($this->default_vat_code) . "'" : "null"); | |
| 889 | - $sql .= ", tva_tx = " . $this->tva_tx; | |
| 890 | - $sql .= ", recuperableonly = " . $this->tva_npr; | |
| 891 | - $sql .= ", localtax1_tx = " . $this->localtax1_tx; | |
| 892 | - $sql .= ", localtax2_tx = " . $this->localtax2_tx; | |
| 893 | - $sql .= ", localtax1_type = " . ($this->localtax1_type != '' ? "'" . $this->db->escape($this->localtax1_type) . "'" : "'0'"); | |
| 894 | - $sql .= ", localtax2_type = " . ($this->localtax2_type != '' ? "'" . $this->db->escape($this->localtax2_type) . "'" : "'0'"); | |
| 895 | - | |
| 896 | - $sql .= ", barcode = " . (empty($this->barcode) ? "null" : "'" . $this->db->escape($this->barcode) . "'"); | |
| 897 | - $sql .= ", fk_barcode_type = " . (empty($this->barcode_type) ? "null" : $this->db->escape($this->barcode_type)); | |
| 898 | - | |
| 899 | - $sql .= ", tosell = " . $this->status; | |
| 900 | - $sql .= ", tobuy = " . $this->status_buy; | |
| 901 | - $sql .= ", tobatch = " . ((empty($this->status_batch) || $this->status_batch < 0) ? '0' : $this->status_batch); | |
| 902 | - $sql .= ", finished = " . ((!isset($this->finished) || $this->finished < 0) ? "null" : (int) $this->finished); | |
| 903 | - $sql .= ", weight = " . ($this->weight != '' ? "'" . $this->db->escape($this->weight) . "'" : 'null'); | |
| 904 | - $sql .= ", weight_units = " . ($this->weight_units != '' ? "'" . $this->db->escape($this->weight_units) . "'" : 'null'); | |
| 905 | - $sql .= ", length = " . ($this->length != '' ? "'" . $this->db->escape($this->length) . "'" : 'null'); | |
| 906 | - $sql .= ", length_units = " . ($this->length_units != '' ? "'" . $this->db->escape($this->length_units) . "'" : 'null'); | |
| 907 | - $sql .= ", width= " . ($this->width != '' ? "'" . $this->db->escape($this->width) . "'" : 'null'); | |
| 908 | - $sql .= ", width_units = " . ($this->width_units != '' ? "'" . $this->db->escape($this->width_units) . "'" : 'null'); | |
| 909 | - $sql .= ", height = " . ($this->height != '' ? "'" . $this->db->escape($this->height) . "'" : 'null'); | |
| 910 | - $sql .= ", height_units = " . ($this->height_units != '' ? "'" . $this->db->escape($this->height_units) . "'" : 'null'); | |
| 911 | - $sql .= ", surface = " . ($this->surface != '' ? "'" . $this->db->escape($this->surface) . "'" : 'null'); | |
| 912 | - $sql .= ", surface_units = " . ($this->surface_units != '' ? "'" . $this->db->escape($this->surface_units) . "'" : 'null'); | |
| 913 | - $sql .= ", volume = " . ($this->volume != '' ? "'" . $this->db->escape($this->volume) . "'" : 'null'); | |
| 914 | - $sql .= ", volume_units = " . ($this->volume_units != '' ? "'" . $this->db->escape($this->volume_units) . "'" : 'null'); | |
| 915 | - $sql .= ", fk_default_warehouse = " . ($this->fk_default_warehouse > 0 ? $this->db->escape($this->fk_default_warehouse) : 'null'); | |
| 916 | - $sql .= ", seuil_stock_alerte = " . ((isset($this->seuil_stock_alerte) && $this->seuil_stock_alerte != '') ? "'" . $this->db->escape($this->seuil_stock_alerte) . "'" : "null"); | |
| 917 | - $sql .= ", description = '" . $this->db->escape($this->description) . "'"; | |
| 918 | - $sql .= ", url = " . ($this->url ? "'" . $this->db->escape($this->url) . "'" : 'null'); | |
| 919 | - $sql .= ", customcode = '" . $this->db->escape($this->customcode) . "'"; | |
| 920 | - $sql .= ", fk_country = " . ($this->country_id > 0 ? $this->country_id : 'null'); | |
| 921 | - $sql .= ", note = " . (isset($this->note) ? "'" . $this->db->escape($this->note) . "'" : 'null'); | |
| 922 | - $sql .= ", duration = '" . $this->db->escape($this->duration_value . $this->duration_unit) . "'"; | |
| 923 | - $sql .= ", accountancy_code_buy = '" . $this->db->escape($this->accountancy_code_buy) . "'"; | |
| 924 | - $sql .= ", accountancy_code_sell= '" . $this->db->escape($this->accountancy_code_sell) . "'"; | |
| 925 | - $sql .= ", accountancy_code_sell_intra= '" . $this->db->escape($this->accountancy_code_sell_intra) . "'"; | |
| 926 | - $sql .= ", accountancy_code_sell_export= '" . $this->db->escape($this->accountancy_code_sell_export) . "'"; | |
| 927 | - $sql .= ", desiredstock = " . ((isset($this->desiredstock) && $this->desiredstock != '') ? $this->desiredstock : "null"); | |
| 928 | - $sql .= ", cost_price = " . ($this->cost_price != '' ? $this->db->escape($this->cost_price) : 'null'); | |
| 929 | - $sql .= ", fk_unit= " . (!$this->fk_unit ? 'NULL' : $this->fk_unit); | |
| 930 | - $sql .= ", price_autogen = " . (!$this->price_autogen ? 0 : 1); | |
| 931 | - $sql .= ", fk_price_expression = " . ($this->fk_price_expression != 0 ? $this->fk_price_expression : 'NULL'); | |
| 932 | - $sql .= ", fk_user_modif = " . ($user->id > 0 ? $user->id : 'NULL'); | |
| 884 | + $sql = "UPDATE ".MAIN_DB_PREFIX."product"; | |
| 885 | + $sql .= " SET label = '".$this->db->escape($this->label)."'"; | |
| 886 | + $sql .= ", ref = '".$this->db->escape($this->ref)."'"; | |
| 887 | + $sql .= ", ref_ext = ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null"); | |
| 888 | + $sql .= ", default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null"); | |
| 889 | + $sql .= ", tva_tx = ".$this->tva_tx; | |
| 890 | + $sql .= ", recuperableonly = ".$this->tva_npr; | |
| 891 | + $sql .= ", localtax1_tx = ".$this->localtax1_tx; | |
| 892 | + $sql .= ", localtax2_tx = ".$this->localtax2_tx; | |
| 893 | + $sql .= ", localtax1_type = ".($this->localtax1_type != '' ? "'".$this->db->escape($this->localtax1_type)."'" : "'0'"); | |
| 894 | + $sql .= ", localtax2_type = ".($this->localtax2_type != '' ? "'".$this->db->escape($this->localtax2_type)."'" : "'0'"); | |
| 895 | + | |
| 896 | + $sql .= ", barcode = ".(empty($this->barcode) ? "null" : "'".$this->db->escape($this->barcode)."'"); | |
| 897 | + $sql .= ", fk_barcode_type = ".(empty($this->barcode_type) ? "null" : $this->db->escape($this->barcode_type)); | |
| 898 | + | |
| 899 | + $sql .= ", tosell = ".$this->status; | |
| 900 | + $sql .= ", tobuy = ".$this->status_buy; | |
| 901 | + $sql .= ", tobatch = ".((empty($this->status_batch) || $this->status_batch < 0) ? '0' : $this->status_batch); | |
| 902 | + $sql .= ", finished = ".((!isset($this->finished) || $this->finished < 0) ? "null" : (int) $this->finished); | |
| 903 | + $sql .= ", weight = ".($this->weight != '' ? "'".$this->db->escape($this->weight)."'" : 'null'); | |
| 904 | + $sql .= ", weight_units = ".($this->weight_units != '' ? "'".$this->db->escape($this->weight_units)."'" : 'null'); | |
| 905 | + $sql .= ", length = ".($this->length != '' ? "'".$this->db->escape($this->length)."'" : 'null'); | |
| 906 | + $sql .= ", length_units = ".($this->length_units != '' ? "'".$this->db->escape($this->length_units)."'" : 'null'); | |
| 907 | + $sql .= ", width= ".($this->width != '' ? "'".$this->db->escape($this->width)."'" : 'null'); | |
| 908 | + $sql .= ", width_units = ".($this->width_units != '' ? "'".$this->db->escape($this->width_units)."'" : 'null'); | |
| 909 | + $sql .= ", height = ".($this->height != '' ? "'".$this->db->escape($this->height)."'" : 'null'); | |
| 910 | + $sql .= ", height_units = ".($this->height_units != '' ? "'".$this->db->escape($this->height_units)."'" : 'null'); | |
| 911 | + $sql .= ", surface = ".($this->surface != '' ? "'".$this->db->escape($this->surface)."'" : 'null'); | |
| 912 | + $sql .= ", surface_units = ".($this->surface_units != '' ? "'".$this->db->escape($this->surface_units)."'" : 'null'); | |
| 913 | + $sql .= ", volume = ".($this->volume != '' ? "'".$this->db->escape($this->volume)."'" : 'null'); | |
| 914 | + $sql .= ", volume_units = ".($this->volume_units != '' ? "'".$this->db->escape($this->volume_units)."'" : 'null'); | |
| 915 | + $sql .= ", fk_default_warehouse = ".($this->fk_default_warehouse > 0 ? $this->db->escape($this->fk_default_warehouse) : 'null'); | |
| 916 | + $sql .= ", seuil_stock_alerte = ".((isset($this->seuil_stock_alerte) && $this->seuil_stock_alerte != '') ? "'".$this->db->escape($this->seuil_stock_alerte)."'" : "null"); | |
| 917 | + $sql .= ", description = '".$this->db->escape($this->description)."'"; | |
| 918 | + $sql .= ", url = ".($this->url ? "'".$this->db->escape($this->url)."'" : 'null'); | |
| 919 | + $sql .= ", customcode = '".$this->db->escape($this->customcode)."'"; | |
| 920 | + $sql .= ", fk_country = ".($this->country_id > 0 ? $this->country_id : 'null'); | |
| 921 | + $sql .= ", note = ".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : 'null'); | |
| 922 | + $sql .= ", duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."'"; | |
| 923 | + $sql .= ", accountancy_code_buy = '".$this->db->escape($this->accountancy_code_buy)."'"; | |
| 924 | + $sql .= ", accountancy_code_sell= '".$this->db->escape($this->accountancy_code_sell)."'"; | |
| 925 | + $sql .= ", accountancy_code_sell_intra= '".$this->db->escape($this->accountancy_code_sell_intra)."'"; | |
| 926 | + $sql .= ", accountancy_code_sell_export= '".$this->db->escape($this->accountancy_code_sell_export)."'"; | |
| 927 | + $sql .= ", desiredstock = ".((isset($this->desiredstock) && $this->desiredstock != '') ? $this->desiredstock : "null"); | |
| 928 | + $sql .= ", cost_price = ".($this->cost_price != '' ? $this->db->escape($this->cost_price) : 'null'); | |
| 929 | + $sql .= ", fk_unit= ".(!$this->fk_unit ? 'NULL' : $this->fk_unit); | |
| 930 | + $sql .= ", price_autogen = ".(!$this->price_autogen ? 0 : 1); | |
| 931 | + $sql .= ", fk_price_expression = ".($this->fk_price_expression != 0 ? $this->fk_price_expression : 'NULL'); | |
| 932 | + $sql .= ", fk_user_modif = ".($user->id > 0 ? $user->id : 'NULL'); | |
| 933 | 933 | // stock field is not here because it is a denormalized value from product_stock. | 
| 934 | - $sql .= " WHERE rowid = " . $id; | |
| 934 | + $sql .= " WHERE rowid = ".$id; | |
| 935 | 935 | |
| 936 | - dol_syslog(get_class($this) . "::update", LOG_DEBUG); | |
| 936 | + dol_syslog(get_class($this)."::update", LOG_DEBUG); | |
| 937 | 937 | |
| 938 | 938 | $resql = $this->db->query($sql); | 
| 939 | 939 |              if ($resql) {
 | 
| @@ -942,7 +942,7 @@ discard block | ||
| 942 | 942 | // Multilangs | 
| 943 | 943 |                  if (!empty($conf->global->MAIN_MULTILANGS)) {
 | 
| 944 | 944 |                      if ($this->setMultiLangs($user) < 0) {
 | 
| 945 | -                        $this->error = $langs->trans("Error") . " : " . $this->db->error() . " - " . $sql;
 | |
| 945 | +                        $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql;
 | |
| 946 | 946 | return -2; | 
| 947 | 947 | } | 
| 948 | 948 | } | 
| @@ -969,8 +969,8 @@ discard block | ||
| 969 | 969 |                  if (!$error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) {
 | 
| 970 | 970 | // We remove directory | 
| 971 | 971 |                      if ($conf->product->dir_output) {
 | 
| 972 | - $olddir = $conf->product->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref); | |
| 973 | - $newdir = $conf->product->dir_output . "/" . dol_sanitizeFileName($this->ref); | |
| 972 | + $olddir = $conf->product->dir_output."/".dol_sanitizeFileName($this->oldcopy->ref); | |
| 973 | + $newdir = $conf->product->dir_output."/".dol_sanitizeFileName($this->ref); | |
| 974 | 974 |                          if (file_exists($olddir)) {
 | 
| 975 | 975 | //include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; | 
| 976 | 976 | //$res = dol_move($olddir, $newdir); | 
| @@ -988,7 +988,7 @@ discard block | ||
| 988 | 988 |                  if (!$error) {
 | 
| 989 | 989 |                      if ($conf->variants->enabled) {
 | 
| 990 | 990 | |
| 991 | - include_once DOL_DOCUMENT_ROOT . '/variants/class/ProductCombination.class.php'; | |
| 991 | + include_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; | |
| 992 | 992 | |
| 993 | 993 | $comb = new ProductCombination($this->db); | 
| 994 | 994 | |
| @@ -1007,15 +1007,15 @@ discard block | ||
| 1007 | 1007 |                  if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
 | 
| 1008 | 1008 |                      $langs->load("errors");
 | 
| 1009 | 1009 |                      if (empty($conf->barcode->enabled) || empty($this->barcode)) {
 | 
| 1010 | -                        $this->error = $langs->trans("Error") . " : " . $langs->trans("ErrorProductAlreadyExists", $this->ref);
 | |
| 1010 | +                        $this->error = $langs->trans("Error")." : ".$langs->trans("ErrorProductAlreadyExists", $this->ref);
 | |
| 1011 | 1011 |                      } else {
 | 
| 1012 | -                        $this->error = $langs->trans("Error") . " : " . $langs->trans("ErrorProductBarCodeAlreadyExists", $this->barcode);
 | |
| 1012 | +                        $this->error = $langs->trans("Error")." : ".$langs->trans("ErrorProductBarCodeAlreadyExists", $this->barcode);
 | |
| 1013 | 1013 | } | 
| 1014 | 1014 | $this->errors[] = $this->error; | 
| 1015 | 1015 | $this->db->rollback(); | 
| 1016 | 1016 | return -1; | 
| 1017 | 1017 |                  } else {
 | 
| 1018 | -                    $this->error = $langs->trans("Error") . " : " . $this->db->error() . " - " . $sql;
 | |
| 1018 | +                    $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql;
 | |
| 1019 | 1019 | $this->errors[] = $this->error; | 
| 1020 | 1020 | $this->db->rollback(); | 
| 1021 | 1021 | return -2; | 
| @@ -1023,7 +1023,7 @@ discard block | ||
| 1023 | 1023 | } | 
| 1024 | 1024 |          } else {
 | 
| 1025 | 1025 | $this->db->rollback(); | 
| 1026 | -            dol_syslog(get_class($this) . "::Update fails verify " . join(',', $this->errors), LOG_WARNING);
 | |
| 1026 | +            dol_syslog(get_class($this)."::Update fails verify ".join(',', $this->errors), LOG_WARNING);
 | |
| 1027 | 1027 | return -3; | 
| 1028 | 1028 | } | 
| 1029 | 1029 | } | 
| @@ -1039,11 +1039,11 @@ discard block | ||
| 1039 | 1039 |      {
 | 
| 1040 | 1040 | // Deprecation warning | 
| 1041 | 1041 |          if ($id > 0) {
 | 
| 1042 | - dol_syslog(__METHOD__ . " with parameter is deprecated", LOG_WARNING); | |
| 1042 | + dol_syslog(__METHOD__." with parameter is deprecated", LOG_WARNING); | |
| 1043 | 1043 | } | 
| 1044 | 1044 | |
| 1045 | 1045 | global $conf, $langs; | 
| 1046 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; | |
| 1046 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; | |
| 1047 | 1047 | |
| 1048 | 1048 | $error = 0; | 
| 1049 | 1049 | |
| @@ -1079,10 +1079,10 @@ discard block | ||
| 1079 | 1079 | |
| 1080 | 1080 | // Delete from product_batch on product delete | 
| 1081 | 1081 |              if (!$error) {
 | 
| 1082 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . 'product_batch'; | |
| 1082 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX.'product_batch'; | |
| 1083 | 1083 |                  $sql .= " WHERE fk_product_stock IN (";
 | 
| 1084 | - $sql .= "SELECT rowid FROM " . MAIN_DB_PREFIX . 'product_stock'; | |
| 1085 | - $sql .= " WHERE fk_product = " . $id . ")"; | |
| 1084 | + $sql .= "SELECT rowid FROM ".MAIN_DB_PREFIX.'product_stock'; | |
| 1085 | + $sql .= " WHERE fk_product = ".$id.")"; | |
| 1086 | 1086 | |
| 1087 | 1087 | $result = $this->db->query($sql); | 
| 1088 | 1088 |                  if (!$result) {
 | 
| @@ -1093,11 +1093,11 @@ discard block | ||
| 1093 | 1093 | |
| 1094 | 1094 | // Delete all child tables | 
| 1095 | 1095 |              if (!$error) {
 | 
| 1096 | -                $elements = array('product_fournisseur_price', 'product_price', 'product_lang', 'categorie_product', 'product_stock', 'product_customer_price', 'product_lot');  // product_batch is done before
 | |
| 1096 | +                $elements = array('product_fournisseur_price', 'product_price', 'product_lang', 'categorie_product', 'product_stock', 'product_customer_price', 'product_lot'); // product_batch is done before
 | |
| 1097 | 1097 |                  foreach ($elements as $table) {
 | 
| 1098 | 1098 |                      if (!$error) {
 | 
| 1099 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . $table; | |
| 1100 | - $sql .= " WHERE fk_product = " . $id; | |
| 1099 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; | |
| 1100 | + $sql .= " WHERE fk_product = ".$id; | |
| 1101 | 1101 | |
| 1102 | 1102 | $result = $this->db->query($sql); | 
| 1103 | 1103 |                          if (!$result) {
 | 
| @@ -1110,8 +1110,8 @@ discard block | ||
| 1110 | 1110 | |
| 1111 | 1111 |              if (!$error) {
 | 
| 1112 | 1112 | |
| 1113 | - include_once DOL_DOCUMENT_ROOT . '/variants/class/ProductCombination.class.php'; | |
| 1114 | - include_once DOL_DOCUMENT_ROOT . '/variants/class/ProductCombination2ValuePair.class.php'; | |
| 1113 | + include_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; | |
| 1114 | + include_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination2ValuePair.class.php'; | |
| 1115 | 1115 | |
| 1116 | 1116 | //If it is a parent product, then we remove the association with child products | 
| 1117 | 1117 | $prodcomb = new ProductCombination($this->db); | 
| @@ -1130,8 +1130,8 @@ discard block | ||
| 1130 | 1130 | |
| 1131 | 1131 | // Delete from product_association | 
| 1132 | 1132 |              if (!$error) {
 | 
| 1133 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_association"; | |
| 1134 | - $sql .= " WHERE fk_product_pere = " . $id . " OR fk_product_fils = " . $id; | |
| 1133 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_association"; | |
| 1134 | + $sql .= " WHERE fk_product_pere = ".$id." OR fk_product_fils = ".$id; | |
| 1135 | 1135 | |
| 1136 | 1136 | $result = $this->db->query($sql); | 
| 1137 | 1137 |                  if (!$result) {
 | 
| @@ -1142,8 +1142,8 @@ discard block | ||
| 1142 | 1142 | |
| 1143 | 1143 | // Delete product | 
| 1144 | 1144 |              if (!$error) {
 | 
| 1145 | - $sqlz = "DELETE FROM " . MAIN_DB_PREFIX . "product"; | |
| 1146 | - $sqlz .= " WHERE rowid = " . $id; | |
| 1145 | + $sqlz = "DELETE FROM ".MAIN_DB_PREFIX."product"; | |
| 1146 | + $sqlz .= " WHERE rowid = ".$id; | |
| 1147 | 1147 | |
| 1148 | 1148 | $resultz = $this->db->query($sqlz); | 
| 1149 | 1149 |                  if (!$resultz) {
 | 
| @@ -1156,7 +1156,7 @@ discard block | ||
| 1156 | 1156 | // We remove directory | 
| 1157 | 1157 | $ref = dol_sanitizeFileName($this->ref); | 
| 1158 | 1158 |                  if ($conf->product->dir_output) {
 | 
| 1159 | - $dir = $conf->product->dir_output . "/" . $ref; | |
| 1159 | + $dir = $conf->product->dir_output."/".$ref; | |
| 1160 | 1160 |                      if (file_exists($dir)) {
 | 
| 1161 | 1161 | $res = @dol_delete_dir_recursive($dir); | 
| 1162 | 1162 |                          if (!$res) {
 | 
| @@ -1172,7 +1172,7 @@ discard block | ||
| 1172 | 1172 | $result = $this->deleteExtraFields(); | 
| 1173 | 1173 |                  if ($result < 0) {
 | 
| 1174 | 1174 | $error++; | 
| 1175 | - dol_syslog(get_class($this) . "::delete error -4 " . $this->error, LOG_ERR); | |
| 1175 | + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); | |
| 1176 | 1176 | } | 
| 1177 | 1177 | } | 
| 1178 | 1178 | |
| @@ -1181,8 +1181,8 @@ discard block | ||
| 1181 | 1181 | return 1; | 
| 1182 | 1182 |              } else {
 | 
| 1183 | 1183 |                  foreach ($this->errors as $errmsg) {
 | 
| 1184 | - dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR); | |
| 1185 | - $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); | |
| 1184 | + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); | |
| 1185 | + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); | |
| 1186 | 1186 | } | 
| 1187 | 1187 | $this->db->rollback(); | 
| 1188 | 1188 | return -$error; | 
| @@ -1209,66 +1209,66 @@ discard block | ||
| 1209 | 1209 |          foreach ($langs_available as $key => $value) {
 | 
| 1210 | 1210 |              if ($key == $current_lang) {
 | 
| 1211 | 1211 | $sql = "SELECT rowid"; | 
| 1212 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_lang"; | |
| 1213 | - $sql .= " WHERE fk_product=" . $this->id; | |
| 1214 | - $sql .= " AND lang='" . $key . "'"; | |
| 1212 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; | |
| 1213 | + $sql .= " WHERE fk_product=".$this->id; | |
| 1214 | + $sql .= " AND lang='".$key."'"; | |
| 1215 | 1215 | |
| 1216 | 1216 | $result = $this->db->query($sql); | 
| 1217 | 1217 | |
| 1218 | 1218 |                  if ($this->db->num_rows($result)) { // if there is already a description line for this language
 | 
| 1219 | - $sql2 = "UPDATE " . MAIN_DB_PREFIX . "product_lang"; | |
| 1219 | + $sql2 = "UPDATE ".MAIN_DB_PREFIX."product_lang"; | |
| 1220 | 1220 | $sql2 .= " SET "; | 
| 1221 | - $sql2 .= " label='" . $this->db->escape($this->label) . "',"; | |
| 1222 | - $sql2 .= " description='" . $this->db->escape($this->description) . "'"; | |
| 1221 | + $sql2 .= " label='".$this->db->escape($this->label)."',"; | |
| 1222 | + $sql2 .= " description='".$this->db->escape($this->description)."'"; | |
| 1223 | 1223 |                      if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) {
 | 
| 1224 | - $sql2 .= ", note='" . $this->db->escape($this->other) . "'"; | |
| 1224 | + $sql2 .= ", note='".$this->db->escape($this->other)."'"; | |
| 1225 | 1225 | } | 
| 1226 | - $sql2 .= " WHERE fk_product=" . $this->id . " AND lang='" . $this->db->escape($key) . "'"; | |
| 1226 | + $sql2 .= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($key)."'"; | |
| 1227 | 1227 |                  } else {
 | 
| 1228 | - $sql2 = "INSERT INTO " . MAIN_DB_PREFIX . "product_lang (fk_product, lang, label, description"; | |
| 1228 | + $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description"; | |
| 1229 | 1229 |                      if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) {
 | 
| 1230 | 1230 | $sql2 .= ", note"; | 
| 1231 | 1231 | } | 
| 1232 | 1232 | $sql2 .= ")"; | 
| 1233 | -                    $sql2 .= " VALUES(" . $this->id . ",'" . $this->db->escape($key) . "','" . $this->db->escape($this->label) . "',";
 | |
| 1234 | - $sql2 .= " '" . $this->db->escape($this->description) . "'"; | |
| 1233 | +                    $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',";
 | |
| 1234 | + $sql2 .= " '".$this->db->escape($this->description)."'"; | |
| 1235 | 1235 |                      if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) {
 | 
| 1236 | - $sql2 .= ", '" . $this->db->escape($this->other) . "'"; | |
| 1236 | + $sql2 .= ", '".$this->db->escape($this->other)."'"; | |
| 1237 | 1237 | } | 
| 1238 | 1238 | $sql2 .= ")"; | 
| 1239 | 1239 | } | 
| 1240 | - dol_syslog(get_class($this) . '::setMultiLangs key = current_lang = ' . $key); | |
| 1240 | + dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key); | |
| 1241 | 1241 |                  if (!$this->db->query($sql2)) {
 | 
| 1242 | 1242 | $this->error = $this->db->lasterror(); | 
| 1243 | 1243 | return -1; | 
| 1244 | 1244 | } | 
| 1245 | 1245 |              } else if (isset($this->multilangs[$key])) {
 | 
| 1246 | 1246 | $sql = "SELECT rowid"; | 
| 1247 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_lang"; | |
| 1248 | - $sql .= " WHERE fk_product=" . $this->id; | |
| 1249 | - $sql .= " AND lang='" . $key . "'"; | |
| 1247 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; | |
| 1248 | + $sql .= " WHERE fk_product=".$this->id; | |
| 1249 | + $sql .= " AND lang='".$key."'"; | |
| 1250 | 1250 | |
| 1251 | 1251 | $result = $this->db->query($sql); | 
| 1252 | 1252 | |
| 1253 | 1253 |                  if ($this->db->num_rows($result)) { // if there is already a description line for this language
 | 
| 1254 | - $sql2 = "UPDATE " . MAIN_DB_PREFIX . "product_lang"; | |
| 1254 | + $sql2 = "UPDATE ".MAIN_DB_PREFIX."product_lang"; | |
| 1255 | 1255 | $sql2 .= " SET "; | 
| 1256 | - $sql2 .= " label='" . $this->db->escape($this->multilangs["$key"]["label"]) . "',"; | |
| 1257 | - $sql2 .= " description='" . $this->db->escape($this->multilangs["$key"]["description"]) . "'"; | |
| 1256 | + $sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; | |
| 1257 | + $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; | |
| 1258 | 1258 |                      if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) {
 | 
| 1259 | - $sql2 .= ", note='" . $this->db->escape($this->multilangs["$key"]["other"]) . "'"; | |
| 1259 | + $sql2 .= ", note='".$this->db->escape($this->multilangs["$key"]["other"])."'"; | |
| 1260 | 1260 | } | 
| 1261 | - $sql2 .= " WHERE fk_product=" . $this->id . " AND lang='" . $this->db->escape($key) . "'"; | |
| 1261 | + $sql2 .= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($key)."'"; | |
| 1262 | 1262 |                  } else {
 | 
| 1263 | - $sql2 = "INSERT INTO " . MAIN_DB_PREFIX . "product_lang (fk_product, lang, label, description"; | |
| 1263 | + $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."product_lang (fk_product, lang, label, description"; | |
| 1264 | 1264 |                      if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) {
 | 
| 1265 | 1265 | $sql2 .= ", note"; | 
| 1266 | 1266 | } | 
| 1267 | 1267 | $sql2 .= ")"; | 
| 1268 | -                    $sql2 .= " VALUES(" . $this->id . ",'" . $this->db->escape($key) . "','" . $this->db->escape($this->multilangs["$key"]["label"]) . "',";
 | |
| 1269 | - $sql2 .= " '" . $this->db->escape($this->multilangs["$key"]["description"]) . "'"; | |
| 1268 | +                    $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',";
 | |
| 1269 | + $sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'"; | |
| 1270 | 1270 |                      if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) {
 | 
| 1271 | - $sql2 .= ", '" . $this->db->escape($this->multilangs["$key"]["other"]) . "'"; | |
| 1271 | + $sql2 .= ", '".$this->db->escape($this->multilangs["$key"]["other"])."'"; | |
| 1272 | 1272 | } | 
| 1273 | 1273 | $sql2 .= ")"; | 
| 1274 | 1274 | } | 
| @@ -1306,24 +1306,24 @@ discard block | ||
| 1306 | 1306 | */ | 
| 1307 | 1307 | function delMultiLangs($langtodelete, $user) | 
| 1308 | 1308 |      {
 | 
| 1309 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_lang"; | |
| 1310 | - $sql .= " WHERE fk_product=" . $this->id . " AND lang='" . $this->db->escape($langtodelete) . "'"; | |
| 1309 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_lang"; | |
| 1310 | + $sql .= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($langtodelete)."'"; | |
| 1311 | 1311 | |
| 1312 | - dol_syslog(get_class($this) . '::delMultiLangs', LOG_DEBUG); | |
| 1312 | + dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG); | |
| 1313 | 1313 | $result = $this->db->query($sql); | 
| 1314 | 1314 |          if ($result) {
 | 
| 1315 | 1315 | // Call trigger | 
| 1316 | 1316 |              $result = $this->call_trigger('PRODUCT_DEL_MULTILANGS', $user);
 | 
| 1317 | 1317 |              if ($result < 0) {
 | 
| 1318 | 1318 | $this->error = $this->db->lasterror(); | 
| 1319 | - dol_syslog(get_class($this) . '::delMultiLangs error=' . $this->error, LOG_ERR); | |
| 1319 | + dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); | |
| 1320 | 1320 | return -1; | 
| 1321 | 1321 | } | 
| 1322 | 1322 | // End call triggers | 
| 1323 | 1323 | return 1; | 
| 1324 | 1324 |          } else {
 | 
| 1325 | 1325 | $this->error = $this->db->lasterror(); | 
| 1326 | - dol_syslog(get_class($this) . '::delMultiLangs error=' . $this->error, LOG_ERR); | |
| 1326 | + dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR); | |
| 1327 | 1327 | return -1; | 
| 1328 | 1328 | } | 
| 1329 | 1329 | } | 
| @@ -1354,16 +1354,16 @@ discard block | ||
| 1354 | 1354 | return -1; | 
| 1355 | 1355 | } | 
| 1356 | 1356 | |
| 1357 | - $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . " SET "; | |
| 1358 | - $sql .= "$field = '" . $this->db->escape($value) . "'"; | |
| 1359 | - $sql .= " WHERE rowid = " . $this->id; | |
| 1357 | + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET "; | |
| 1358 | + $sql .= "$field = '".$this->db->escape($value)."'"; | |
| 1359 | + $sql .= " WHERE rowid = ".$this->id; | |
| 1360 | 1360 | |
| 1361 | - dol_syslog(get_class($this) . "::" . __FUNCTION__ . " sql=" . $sql, LOG_DEBUG); | |
| 1361 | + dol_syslog(get_class($this)."::".__FUNCTION__." sql=".$sql, LOG_DEBUG); | |
| 1362 | 1362 | $resql = $this->db->query($sql); | 
| 1363 | 1363 | |
| 1364 | 1364 |          if ($resql) {
 | 
| 1365 | 1365 | // Call triggers | 
| 1366 | - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; | |
| 1366 | + include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; | |
| 1367 | 1367 | $interface = new Interfaces($this->db); | 
| 1368 | 1368 |              $result = $interface->run_triggers('PRODUCT_MODIFY', $this, $user, $langs, $conf);
 | 
| 1369 | 1369 |              if ($result < 0) {
 | 
| @@ -1396,8 +1396,8 @@ discard block | ||
| 1396 | 1396 | $current_lang = $langs->getDefaultLang(); | 
| 1397 | 1397 | |
| 1398 | 1398 | $sql = "SELECT lang, label, description, note as other"; | 
| 1399 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_lang"; | |
| 1400 | - $sql .= " WHERE fk_product=" . $this->id; | |
| 1399 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; | |
| 1400 | + $sql .= " WHERE fk_product=".$this->id; | |
| 1401 | 1401 | |
| 1402 | 1402 | $result = $this->db->query($sql); | 
| 1403 | 1403 |          if ($result) {
 | 
| @@ -1414,7 +1414,7 @@ discard block | ||
| 1414 | 1414 | } | 
| 1415 | 1415 | return 1; | 
| 1416 | 1416 |          } else {
 | 
| 1417 | - $this->error = "Error: " . $this->db->lasterror() . " - " . $sql; | |
| 1417 | + $this->error = "Error: ".$this->db->lasterror()." - ".$sql; | |
| 1418 | 1418 | return -1; | 
| 1419 | 1419 | } | 
| 1420 | 1420 | } | 
| @@ -1440,13 +1440,13 @@ discard block | ||
| 1440 | 1440 | } | 
| 1441 | 1441 | |
| 1442 | 1442 | // Add new price | 
| 1443 | - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_price(price_level,date_price, fk_product, fk_user_author, price, price_ttc, price_base_type,tosell, tva_tx, default_vat_code, recuperableonly,"; | |
| 1443 | + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(price_level,date_price, fk_product, fk_user_author, price, price_ttc, price_base_type,tosell, tva_tx, default_vat_code, recuperableonly,"; | |
| 1444 | 1444 | $sql .= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, price_min,price_min_ttc,price_by_qty,entity,fk_price_expression) "; | 
| 1445 | -        $sql .= " VALUES(" . ($level ? $level : 1) . ", '" . $this->db->idate($now) . "'," . $this->id . "," . $user->id . "," . $this->price . "," . $this->price_ttc . ",'" . $this->db->escape($this->price_base_type) . "'," . $this->status . "," . $this->tva_tx . ", " . ($this->default_vat_code ? ("'" . $this->db->escape($this->default_vat_code) . "'") : "null") . "," . $this->tva_npr . ",";
 | |
| 1446 | - $sql .= " " . $this->localtax1_tx . ", " . $this->localtax2_tx . ", '" . $this->db->escape($this->localtax1_type) . "', '" . $this->db->escape($this->localtax2_type) . "', " . $this->price_min . "," . $this->price_min_ttc . "," . $this->price_by_qty . "," . $conf->entity . "," . ($this->fk_price_expression > 0 ? $this->fk_price_expression : 'null'); | |
| 1445 | +        $sql .= " VALUES(".($level ? $level : 1).", '".$this->db->idate($now)."',".$this->id.",".$user->id.",".$this->price.",".$this->price_ttc.",'".$this->db->escape($this->price_base_type)."',".$this->status.",".$this->tva_tx.", ".($this->default_vat_code ? ("'".$this->db->escape($this->default_vat_code)."'") : "null").",".$this->tva_npr.",";
 | |
| 1446 | + $sql .= " ".$this->localtax1_tx.", ".$this->localtax2_tx.", '".$this->db->escape($this->localtax1_type)."', '".$this->db->escape($this->localtax2_type)."', ".$this->price_min.",".$this->price_min_ttc.",".$this->price_by_qty.",".$conf->entity.",".($this->fk_price_expression > 0 ? $this->fk_price_expression : 'null'); | |
| 1447 | 1447 | $sql .= ")"; | 
| 1448 | 1448 | |
| 1449 | - dol_syslog(get_class($this) . "::_log_price", LOG_DEBUG); | |
| 1449 | + dol_syslog(get_class($this)."::_log_price", LOG_DEBUG); | |
| 1450 | 1450 | $resql = $this->db->query($sql); | 
| 1451 | 1451 |          if (!$resql) {
 | 
| 1452 | 1452 | $this->error = $this->db->lasterror(); | 
| @@ -1468,12 +1468,12 @@ discard block | ||
| 1468 | 1468 | function log_price_delete($user, $rowid) | 
| 1469 | 1469 |      {
 | 
| 1470 | 1470 | // phpcs:enable | 
| 1471 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_price_by_qty"; | |
| 1472 | - $sql .= " WHERE fk_product_price=" . $rowid; | |
| 1471 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price_by_qty"; | |
| 1472 | + $sql .= " WHERE fk_product_price=".$rowid; | |
| 1473 | 1473 | $resql = $this->db->query($sql); | 
| 1474 | 1474 | |
| 1475 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_price"; | |
| 1476 | - $sql .= " WHERE rowid=" . $rowid; | |
| 1475 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price"; | |
| 1476 | + $sql .= " WHERE rowid=".$rowid; | |
| 1477 | 1477 | $resql = $this->db->query($sql); | 
| 1478 | 1478 |          if ($resql) {
 | 
| 1479 | 1479 | return 1; | 
| @@ -1507,20 +1507,20 @@ discard block | ||
| 1507 | 1507 | $sql .= " pfp.fk_product, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_soc, pfp.tva_tx, pfp.fk_supplier_price_expression"; | 
| 1508 | 1508 | $sql .= " ,pfp.default_vat_code"; | 
| 1509 | 1509 | $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; | 
| 1510 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_fournisseur_price as pfp"; | |
| 1511 | - $sql .= " WHERE pfp.rowid = " . $prodfournprice; | |
| 1510 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; | |
| 1511 | + $sql .= " WHERE pfp.rowid = ".$prodfournprice; | |
| 1512 | 1512 |          if ($qty > 0) {
 | 
| 1513 | - $sql .= " AND pfp.quantity <= " . $qty; | |
| 1513 | + $sql .= " AND pfp.quantity <= ".$qty; | |
| 1514 | 1514 | } | 
| 1515 | 1515 | $sql .= " ORDER BY pfp.quantity DESC"; | 
| 1516 | 1516 | |
| 1517 | - dol_syslog(get_class($this) . "::get_buyprice first search by prodfournprice/qty", LOG_DEBUG); | |
| 1517 | + dol_syslog(get_class($this)."::get_buyprice first search by prodfournprice/qty", LOG_DEBUG); | |
| 1518 | 1518 | $resql = $this->db->query($sql); | 
| 1519 | 1519 |          if ($resql) {
 | 
| 1520 | 1520 | $obj = $this->db->fetch_object($resql); | 
| 1521 | 1521 |              if ($obj && $obj->quantity > 0) {        // If we found a supplier prices from the id of supplier price
 | 
| 1522 | 1522 |                  if (!empty($conf->dynamicprices->enabled) && !empty($obj->fk_supplier_price_expression)) {
 | 
| 1523 | - include_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_parser.class.php'; | |
| 1523 | + include_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; | |
| 1524 | 1524 | $prod_supplier = new ProductFournisseur($this->db); | 
| 1525 | 1525 | $prod_supplier->product_fourn_price_id = $obj->rowid; | 
| 1526 | 1526 | $prod_supplier->id = $obj->fk_product; | 
| @@ -1534,16 +1534,16 @@ discard block | ||
| 1534 | 1534 | } | 
| 1535 | 1535 | } | 
| 1536 | 1536 | $this->product_fourn_price_id = $obj->rowid; | 
| 1537 | - $this->buyprice = $obj->price; // deprecated | |
| 1538 | - $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product of supplier | |
| 1539 | - $this->fourn_price_base_type = 'HT'; // Price base type | |
| 1540 | - $this->fourn_socid = $obj->fk_soc; // Company that offer this price | |
| 1541 | - $this->ref_fourn = $obj->ref_fourn; // deprecated | |
| 1542 | - $this->ref_supplier = $obj->ref_fourn; // Ref supplier | |
| 1543 | - $this->desc_supplier = $obj->desc_fourn; // desc supplier | |
| 1544 | - $this->remise_percent = $obj->remise_percent; // remise percent if present and not typed | |
| 1545 | - $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier | |
| 1546 | - $this->default_vat_code = $obj->default_vat_code; // Vat code supplier | |
| 1537 | + $this->buyprice = $obj->price; // deprecated | |
| 1538 | + $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product of supplier | |
| 1539 | + $this->fourn_price_base_type = 'HT'; // Price base type | |
| 1540 | + $this->fourn_socid = $obj->fk_soc; // Company that offer this price | |
| 1541 | + $this->ref_fourn = $obj->ref_fourn; // deprecated | |
| 1542 | + $this->ref_supplier = $obj->ref_fourn; // Ref supplier | |
| 1543 | + $this->desc_supplier = $obj->desc_fourn; // desc supplier | |
| 1544 | + $this->remise_percent = $obj->remise_percent; // remise percent if present and not typed | |
| 1545 | + $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier | |
| 1546 | + $this->default_vat_code = $obj->default_vat_code; // Vat code supplier | |
| 1547 | 1547 | $this->fourn_multicurrency_price = $obj->multicurrency_price; | 
| 1548 | 1548 | $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; | 
| 1549 | 1549 | $this->fourn_multicurrency_tx = $obj->multicurrency_tx; | 
| @@ -1557,27 +1557,27 @@ discard block | ||
| 1557 | 1557 | $sql .= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.desc_fourn as desc_supplier, pfp.tva_tx, pfp.fk_supplier_price_expression"; | 
| 1558 | 1558 | $sql .= " ,pfp.default_vat_code"; | 
| 1559 | 1559 | $sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; | 
| 1560 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_fournisseur_price as pfp"; | |
| 1561 | - $sql .= " WHERE pfp.fk_product = " . $product_id; | |
| 1560 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; | |
| 1561 | + $sql .= " WHERE pfp.fk_product = ".$product_id; | |
| 1562 | 1562 |                  if ($fourn_ref != 'none') {
 | 
| 1563 | - $sql .= " AND pfp.ref_fourn = '" . $fourn_ref . "'"; | |
| 1563 | + $sql .= " AND pfp.ref_fourn = '".$fourn_ref."'"; | |
| 1564 | 1564 | } | 
| 1565 | 1565 |                  if ($fk_soc > 0) {
 | 
| 1566 | - $sql .= " AND pfp.fk_soc = " . $fk_soc; | |
| 1566 | + $sql .= " AND pfp.fk_soc = ".$fk_soc; | |
| 1567 | 1567 | } | 
| 1568 | 1568 |                  if ($qty > 0) {
 | 
| 1569 | - $sql .= " AND pfp.quantity <= " . $qty; | |
| 1569 | + $sql .= " AND pfp.quantity <= ".$qty; | |
| 1570 | 1570 | } | 
| 1571 | 1571 | $sql .= " ORDER BY pfp.quantity DESC"; | 
| 1572 | 1572 | $sql .= " LIMIT 1"; | 
| 1573 | 1573 | |
| 1574 | - dol_syslog(get_class($this) . "::get_buyprice second search from qty/ref/product_id", LOG_DEBUG); | |
| 1574 | + dol_syslog(get_class($this)."::get_buyprice second search from qty/ref/product_id", LOG_DEBUG); | |
| 1575 | 1575 | $resql = $this->db->query($sql); | 
| 1576 | 1576 |                  if ($resql) {
 | 
| 1577 | 1577 | $obj = $this->db->fetch_object($resql); | 
| 1578 | 1578 |                      if ($obj && $obj->quantity > 0) {        // If found
 | 
| 1579 | 1579 |                          if (!empty($conf->dynamicprices->enabled) && !empty($obj->fk_supplier_price_expression)) {
 | 
| 1580 | - include_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_parser.class.php'; | |
| 1580 | + include_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; | |
| 1581 | 1581 | $prod_supplier = new ProductFournisseur($this->db); | 
| 1582 | 1582 | $prod_supplier->product_fourn_price_id = $obj->rowid; | 
| 1583 | 1583 | $prod_supplier->id = $obj->fk_product; | 
| @@ -1591,17 +1591,17 @@ discard block | ||
| 1591 | 1591 | } | 
| 1592 | 1592 | } | 
| 1593 | 1593 | $this->product_fourn_price_id = $obj->rowid; | 
| 1594 | - $this->buyprice = $obj->price; // deprecated | |
| 1595 | - $this->fourn_qty = $obj->quantity; // min quantity for price for a virtual supplier | |
| 1596 | - $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product for a virtual supplier | |
| 1597 | - $this->fourn_price_base_type = 'HT'; // Price base type for a virtual supplier | |
| 1598 | - $this->fourn_socid = $obj->fk_soc; // Company that offer this price | |
| 1599 | - $this->ref_fourn = $obj->ref_supplier; // deprecated | |
| 1600 | - $this->ref_supplier = $obj->ref_supplier; // Ref supplier | |
| 1601 | - $this->desc_supplier = $obj->desc_supplier; // desc supplier | |
| 1602 | - $this->remise_percent = $obj->remise_percent; // remise percent if present and not typed | |
| 1603 | - $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier | |
| 1604 | - $this->default_vat_code = $obj->default_vat_code; // Vat code supplier | |
| 1594 | + $this->buyprice = $obj->price; // deprecated | |
| 1595 | + $this->fourn_qty = $obj->quantity; // min quantity for price for a virtual supplier | |
| 1596 | + $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product for a virtual supplier | |
| 1597 | + $this->fourn_price_base_type = 'HT'; // Price base type for a virtual supplier | |
| 1598 | + $this->fourn_socid = $obj->fk_soc; // Company that offer this price | |
| 1599 | + $this->ref_fourn = $obj->ref_supplier; // deprecated | |
| 1600 | + $this->ref_supplier = $obj->ref_supplier; // Ref supplier | |
| 1601 | + $this->desc_supplier = $obj->desc_supplier; // desc supplier | |
| 1602 | + $this->remise_percent = $obj->remise_percent; // remise percent if present and not typed | |
| 1603 | + $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier | |
| 1604 | + $this->default_vat_code = $obj->default_vat_code; // Vat code supplier | |
| 1605 | 1605 | $this->fourn_multicurrency_price = $obj->multicurrency_price; | 
| 1606 | 1606 | $this->fourn_multicurrency_unitprice = $obj->multicurrency_unitprice; | 
| 1607 | 1607 | $this->fourn_multicurrency_tx = $obj->multicurrency_tx; | 
| @@ -1610,7 +1610,7 @@ discard block | ||
| 1610 | 1610 | $result = $obj->fk_product; | 
| 1611 | 1611 | return $result; | 
| 1612 | 1612 |                      } else {
 | 
| 1613 | - return -1; // Ce produit n'existe pas avec cet id tarif fournisseur ou existe mais qte insuffisante, ni pour le couple produit/ref fournisseur dans la quantité. | |
| 1613 | + return -1; // Ce produit n'existe pas avec cet id tarif fournisseur ou existe mais qte insuffisante, ni pour le couple produit/ref fournisseur dans la quantité. | |
| 1614 | 1614 | } | 
| 1615 | 1615 |                  } else {
 | 
| 1616 | 1616 | $this->error = $this->db->lasterror(); | 
| @@ -1645,7 +1645,7 @@ discard block | ||
| 1645 | 1645 | |
| 1646 | 1646 | $id = $this->id; | 
| 1647 | 1647 | |
| 1648 | - dol_syslog(get_class($this) . "::update_price id=" . $id . " newprice=" . $newprice . " newpricebase=" . $newpricebase . " newminprice=" . $newminprice . " level=" . $level . " npr=" . $newnpr . " newdefaultvatcode=" . $newdefaultvatcode); | |
| 1648 | + dol_syslog(get_class($this)."::update_price id=".$id." newprice=".$newprice." newpricebase=".$newpricebase." newminprice=".$newminprice." level=".$level." npr=".$newnpr." newdefaultvatcode=".$newdefaultvatcode); | |
| 1649 | 1649 | |
| 1650 | 1650 | // Clean parameters | 
| 1651 | 1651 |          if (empty($this->tva_tx)) {
 | 
| @@ -1687,7 +1687,7 @@ discard block | ||
| 1687 | 1687 | } | 
| 1688 | 1688 |              } else {
 | 
| 1689 | 1689 | $price = price2num($newprice, 'MU'); | 
| 1690 | - $price_ttc = ( $newnpr != 1 ) ? price2num($newprice) * (1 + ($newvat / 100)) : $price; | |
| 1690 | + $price_ttc = ($newnpr != 1) ? price2num($newprice) * (1 + ($newvat / 100)) : $price; | |
| 1691 | 1691 | $price_ttc = price2num($price_ttc, 'MU'); | 
| 1692 | 1692 | |
| 1693 | 1693 |                  if ($newminprice !== '' || $newminprice === 0) {
 | 
| @@ -1714,32 +1714,32 @@ discard block | ||
| 1714 | 1714 | $localtax2 = get_localtax($newvat, 2); | 
| 1715 | 1715 | } | 
| 1716 | 1716 |              if (empty($localtax1)) {
 | 
| 1717 | - $localtax1 = 0; // If = '' then = 0 | |
| 1717 | + $localtax1 = 0; // If = '' then = 0 | |
| 1718 | 1718 | } | 
| 1719 | 1719 |              if (empty($localtax2)) {
 | 
| 1720 | - $localtax2 = 0; // If = '' then = 0 | |
| 1720 | + $localtax2 = 0; // If = '' then = 0 | |
| 1721 | 1721 | } | 
| 1722 | 1722 | |
| 1723 | 1723 | $this->db->begin(); | 
| 1724 | 1724 | |
| 1725 | 1725 | // Ne pas mettre de quote sur les numeriques decimaux. | 
| 1726 | 1726 | // Ceci provoque des stockages avec arrondis en base au lieu des valeurs exactes. | 
| 1727 | - $sql = "UPDATE " . MAIN_DB_PREFIX . "product SET"; | |
| 1728 | - $sql .= " price_base_type='" . $newpricebase . "',"; | |
| 1729 | - $sql .= " price=" . $price . ","; | |
| 1730 | - $sql .= " price_ttc=" . $price_ttc . ","; | |
| 1731 | - $sql .= " price_min=" . $price_min . ","; | |
| 1732 | - $sql .= " price_min_ttc=" . $price_min_ttc . ","; | |
| 1733 | - $sql .= " localtax1_tx=" . ($localtax1 >= 0 ? $localtax1 : 'NULL') . ","; | |
| 1734 | - $sql .= " localtax2_tx=" . ($localtax2 >= 0 ? $localtax2 : 'NULL') . ","; | |
| 1735 | - $sql .= " localtax1_type=" . ($localtaxtype1 != '' ? "'" . $localtaxtype1 . "'" : "'0'") . ","; | |
| 1736 | - $sql .= " localtax2_type=" . ($localtaxtype2 != '' ? "'" . $localtaxtype2 . "'" : "'0'") . ","; | |
| 1737 | - $sql .= " default_vat_code=" . ($newdefaultvatcode ? "'" . $this->db->escape($newdefaultvatcode) . "'" : "null") . ","; | |
| 1738 | - $sql .= " tva_tx='" . price2num($newvat) . "',"; | |
| 1739 | - $sql .= " recuperableonly='" . $newnpr . "'"; | |
| 1740 | - $sql .= " WHERE rowid = " . $id; | |
| 1741 | - | |
| 1742 | - dol_syslog(get_class($this) . "::update_price", LOG_DEBUG); | |
| 1727 | + $sql = "UPDATE ".MAIN_DB_PREFIX."product SET"; | |
| 1728 | + $sql .= " price_base_type='".$newpricebase."',"; | |
| 1729 | + $sql .= " price=".$price.","; | |
| 1730 | + $sql .= " price_ttc=".$price_ttc.","; | |
| 1731 | + $sql .= " price_min=".$price_min.","; | |
| 1732 | + $sql .= " price_min_ttc=".$price_min_ttc.","; | |
| 1733 | + $sql .= " localtax1_tx=".($localtax1 >= 0 ? $localtax1 : 'NULL').","; | |
| 1734 | + $sql .= " localtax2_tx=".($localtax2 >= 0 ? $localtax2 : 'NULL').","; | |
| 1735 | + $sql .= " localtax1_type=".($localtaxtype1 != '' ? "'".$localtaxtype1."'" : "'0'").","; | |
| 1736 | + $sql .= " localtax2_type=".($localtaxtype2 != '' ? "'".$localtaxtype2."'" : "'0'").","; | |
| 1737 | + $sql .= " default_vat_code=".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").","; | |
| 1738 | + $sql .= " tva_tx='".price2num($newvat)."',"; | |
| 1739 | + $sql .= " recuperableonly='".$newnpr."'"; | |
| 1740 | + $sql .= " WHERE rowid = ".$id; | |
| 1741 | + | |
| 1742 | + dol_syslog(get_class($this)."::update_price", LOG_DEBUG); | |
| 1743 | 1743 | $resql = $this->db->query($sql); | 
| 1744 | 1744 |              if ($resql) {
 | 
| 1745 | 1745 | $this->multiprices[$level] = $price; | 
| @@ -1768,9 +1768,9 @@ discard block | ||
| 1768 | 1768 | // Price by quantity | 
| 1769 | 1769 | $this->price_by_qty = $newpbq; | 
| 1770 | 1770 | |
| 1771 | - $this->_log_price($user, $level); // Save price for level into table product_price | |
| 1771 | + $this->_log_price($user, $level); // Save price for level into table product_price | |
| 1772 | 1772 | |
| 1773 | - $this->level = $level; // Store level of price edited for trigger | |
| 1773 | + $this->level = $level; // Store level of price edited for trigger | |
| 1774 | 1774 | // Call trigger | 
| 1775 | 1775 |                  $result = $this->call_trigger('PRODUCT_PRICE_MODIFY', $user);
 | 
| 1776 | 1776 |                  if ($result < 0) {
 | 
| @@ -1817,16 +1817,16 @@ discard block | ||
| 1817 | 1817 | */ | 
| 1818 | 1818 | function fetch($id = '', $ref = '', $ref_ext = '', $barcode = '', $ignore_expression = 0) | 
| 1819 | 1819 |      {
 | 
| 1820 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; | |
| 1820 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; | |
| 1821 | 1821 | |
| 1822 | 1822 | global $langs, $conf; | 
| 1823 | 1823 | |
| 1824 | - dol_syslog(get_class($this) . "::fetch id=" . $id . " ref=" . $ref . " ref_ext=" . $ref_ext); | |
| 1824 | + dol_syslog(get_class($this)."::fetch id=".$id." ref=".$ref." ref_ext=".$ref_ext); | |
| 1825 | 1825 | |
| 1826 | 1826 | // Check parameters | 
| 1827 | 1827 |          if (!$id && !$ref && !$ref_ext && !$barcode) {
 | 
| 1828 | 1828 | $this->error = 'ErrorWrongParameters'; | 
| 1829 | - dol_syslog(get_class($this) . "::fetch " . $this->error); | |
| 1829 | + dol_syslog(get_class($this)."::fetch ".$this->error); | |
| 1830 | 1830 | return -1; | 
| 1831 | 1831 | } | 
| 1832 | 1832 | |
| @@ -1838,17 +1838,17 @@ discard block | ||
| 1838 | 1838 | $sql .= " accountancy_code_buy, accountancy_code_sell, accountancy_code_sell_intra, accountancy_code_sell_export, stock, pmp,"; | 
| 1839 | 1839 | $sql .= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit,"; | 
| 1840 | 1840 | $sql .= " fk_price_expression, price_autogen"; | 
| 1841 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product"; | |
| 1841 | + $sql .= " FROM ".MAIN_DB_PREFIX."product"; | |
| 1842 | 1842 |          if ($id) {
 | 
| 1843 | - $sql .= " WHERE rowid = " . $this->db->escape($id); | |
| 1843 | + $sql .= " WHERE rowid = ".$this->db->escape($id); | |
| 1844 | 1844 |          } else {
 | 
| 1845 | -            $sql .= " WHERE entity IN (" . getEntity($this->element) . ")";
 | |
| 1845 | +            $sql .= " WHERE entity IN (".getEntity($this->element).")";
 | |
| 1846 | 1846 |              if ($ref) {
 | 
| 1847 | - $sql .= " AND ref = '" . $this->db->escape($ref) . "'"; | |
| 1847 | + $sql .= " AND ref = '".$this->db->escape($ref)."'"; | |
| 1848 | 1848 |              } else if ($ref_ext) {
 | 
| 1849 | - $sql .= " AND ref_ext = '" . $this->db->escape($ref_ext) . "'"; | |
| 1849 | + $sql .= " AND ref_ext = '".$this->db->escape($ref_ext)."'"; | |
| 1850 | 1850 |              } else if ($barcode) {
 | 
| 1851 | - $sql .= " AND barcode = '" . $this->db->escape($barcode) . "'"; | |
| 1851 | + $sql .= " AND barcode = '".$this->db->escape($barcode)."'"; | |
| 1852 | 1852 | } | 
| 1853 | 1853 | } | 
| 1854 | 1854 | |
| @@ -1864,7 +1864,7 @@ discard block | ||
| 1864 | 1864 | $this->description = $obj->description; | 
| 1865 | 1865 | $this->url = $obj->url; | 
| 1866 | 1866 | $this->note_private = $obj->note_private; | 
| 1867 | - $this->note = $obj->note_private; // deprecated | |
| 1867 | + $this->note = $obj->note_private; // deprecated | |
| 1868 | 1868 | |
| 1869 | 1869 | $this->type = $obj->fk_product_type; | 
| 1870 | 1870 | $this->status = $obj->tosell; | 
| @@ -1884,7 +1884,7 @@ discard block | ||
| 1884 | 1884 | $this->tva_tx = $obj->tva_tx; | 
| 1885 | 1885 | //! French VAT NPR | 
| 1886 | 1886 | $this->tva_npr = $obj->tva_npr; | 
| 1887 | - $this->recuperableonly = $obj->tva_npr; // For backward compatibility | |
| 1887 | + $this->recuperableonly = $obj->tva_npr; // For backward compatibility | |
| 1888 | 1888 | //! Local taxes | 
| 1889 | 1889 | $this->localtax1_tx = $obj->localtax1_tx; | 
| 1890 | 1890 | $this->localtax2_tx = $obj->localtax2_tx; | 
| @@ -1949,10 +1949,10 @@ discard block | ||
| 1949 | 1949 |                      for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
 | 
| 1950 | 1950 | $sql = "SELECT price, price_ttc, price_min, price_min_ttc,"; | 
| 1951 | 1951 | $sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid, recuperableonly"; | 
| 1952 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_price"; | |
| 1953 | -                        $sql .= " WHERE entity IN (" . getEntity('productprice') . ")";
 | |
| 1954 | - $sql .= " AND price_level=" . $i; | |
| 1955 | - $sql .= " AND fk_product = " . $this->id; | |
| 1952 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_price"; | |
| 1953 | +                        $sql .= " WHERE entity IN (".getEntity('productprice').")";
 | |
| 1954 | + $sql .= " AND price_level=".$i; | |
| 1955 | + $sql .= " AND fk_product = ".$this->id; | |
| 1956 | 1956 | $sql .= " ORDER BY date_price DESC, rowid DESC"; | 
| 1957 | 1957 | $sql .= " LIMIT 1"; | 
| 1958 | 1958 | $resql = $this->db->query($sql); | 
| @@ -1965,7 +1965,7 @@ discard block | ||
| 1965 | 1965 | $this->multiprices_min_ttc[$i] = $result["price_min_ttc"]; | 
| 1966 | 1966 | $this->multiprices_base_type[$i] = $result["price_base_type"]; | 
| 1967 | 1967 | // Next two fields are used only if PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL is on | 
| 1968 | -                            $this->multiprices_tva_tx[$i] = $result["tva_tx"];     // TODO Add ' ('.$result['default_vat_code'].')'
 | |
| 1968 | +                            $this->multiprices_tva_tx[$i] = $result["tva_tx"]; // TODO Add ' ('.$result['default_vat_code'].')'
 | |
| 1969 | 1969 | $this->multiprices_recuperableonly[$i] = $result["recuperableonly"]; | 
| 1970 | 1970 | |
| 1971 | 1971 | // Price by quantity | 
| @@ -2013,8 +2013,8 @@ discard block | ||
| 2013 | 2013 |                  } else if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) {    // prices per quantity
 | 
| 2014 | 2014 | $sql = "SELECT price, price_ttc, price_min, price_min_ttc,"; | 
| 2015 | 2015 | $sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid"; | 
| 2016 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_price"; | |
| 2017 | - $sql .= " WHERE fk_product = " . $this->id; | |
| 2016 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_price"; | |
| 2017 | + $sql .= " WHERE fk_product = ".$this->id; | |
| 2018 | 2018 | $sql .= " ORDER BY date_price DESC, rowid DESC"; | 
| 2019 | 2019 | $sql .= " LIMIT 1"; | 
| 2020 | 2020 | $resql = $this->db->query($sql); | 
| @@ -2027,8 +2027,8 @@ discard block | ||
| 2027 | 2027 | // Récuperation de la liste des prix selon qty si flag positionné | 
| 2028 | 2028 |                          if ($this->prices_by_qty[0] == 1) {
 | 
| 2029 | 2029 | $sql = "SELECT rowid,price, unitprice, quantity, remise_percent, remise, remise, price_base_type"; | 
| 2030 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_price_by_qty"; | |
| 2031 | - $sql .= " WHERE fk_product_price = " . $this->prices_by_qty_id[0]; | |
| 2030 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; | |
| 2031 | + $sql .= " WHERE fk_product_price = ".$this->prices_by_qty_id[0]; | |
| 2032 | 2032 | $sql .= " ORDER BY quantity ASC"; | 
| 2033 | 2033 | $resultat = array(); | 
| 2034 | 2034 | $resql = $this->db->query($sql); | 
| @@ -2059,10 +2059,10 @@ discard block | ||
| 2059 | 2059 |                      for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
 | 
| 2060 | 2060 | $sql = "SELECT price, price_ttc, price_min, price_min_ttc,"; | 
| 2061 | 2061 | $sql .= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid, recuperableonly"; | 
| 2062 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_price"; | |
| 2063 | -                        $sql .= " WHERE entity IN (" . getEntity('productprice') . ")";
 | |
| 2064 | - $sql .= " AND price_level=" . $i; | |
| 2065 | - $sql .= " AND fk_product = " . $this->id; | |
| 2062 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_price"; | |
| 2063 | +                        $sql .= " WHERE entity IN (".getEntity('productprice').")";
 | |
| 2064 | + $sql .= " AND price_level=".$i; | |
| 2065 | + $sql .= " AND fk_product = ".$this->id; | |
| 2066 | 2066 | $sql .= " ORDER BY date_price DESC, rowid DESC"; | 
| 2067 | 2067 | $sql .= " LIMIT 1"; | 
| 2068 | 2068 | $resql = $this->db->query($sql); | 
| @@ -2075,7 +2075,7 @@ discard block | ||
| 2075 | 2075 | $this->multiprices_min_ttc[$i] = $result["price_min_ttc"]; | 
| 2076 | 2076 | $this->multiprices_base_type[$i] = $result["price_base_type"]; | 
| 2077 | 2077 | // Next two fields are used only if PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL is on | 
| 2078 | -                            $this->multiprices_tva_tx[$i] = $result["tva_tx"];     // TODO Add ' ('.$result['default_vat_code'].')'
 | |
| 2078 | +                            $this->multiprices_tva_tx[$i] = $result["tva_tx"]; // TODO Add ' ('.$result['default_vat_code'].')'
 | |
| 2079 | 2079 | $this->multiprices_recuperableonly[$i] = $result["recuperableonly"]; | 
| 2080 | 2080 | |
| 2081 | 2081 | // Price by quantity | 
| @@ -2084,8 +2084,8 @@ discard block | ||
| 2084 | 2084 | // Récuperation de la liste des prix selon qty si flag positionné | 
| 2085 | 2085 |                              if ($this->prices_by_qty[$i] == 1) {
 | 
| 2086 | 2086 | $sql = "SELECT rowid, price, unitprice, quantity, remise_percent, remise, price_base_type"; | 
| 2087 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_price_by_qty"; | |
| 2088 | - $sql .= " WHERE fk_product_price = " . $this->prices_by_qty_id[$i]; | |
| 2087 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; | |
| 2088 | + $sql .= " WHERE fk_product_price = ".$this->prices_by_qty_id[$i]; | |
| 2089 | 2089 | $sql .= " ORDER BY quantity ASC"; | 
| 2090 | 2090 | $resultat = array(); | 
| 2091 | 2091 | $resql = $this->db->query($sql); | 
| @@ -2098,7 +2098,7 @@ discard block | ||
| 2098 | 2098 | $resultat[$ii]["unitprice"] = $result["unitprice"]; | 
| 2099 | 2099 | $resultat[$ii]["quantity"] = $result["quantity"]; | 
| 2100 | 2100 | $resultat[$ii]["remise_percent"] = $result["remise_percent"]; | 
| 2101 | - $resultat[$ii]["remise"] = $result["remise"]; // deprecated | |
| 2101 | + $resultat[$ii]["remise"] = $result["remise"]; // deprecated | |
| 2102 | 2102 | $resultat[$ii]["price_base_type"] = $result["price_base_type"]; | 
| 2103 | 2103 | $ii++; | 
| 2104 | 2104 | } | 
| @@ -2116,7 +2116,7 @@ discard block | ||
| 2116 | 2116 | } | 
| 2117 | 2117 | |
| 2118 | 2118 |                  if (!empty($conf->dynamicprices->enabled) && !empty($this->fk_price_expression) && empty($ignore_expression)) {
 | 
| 2119 | - include_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_parser.class.php'; | |
| 2119 | + include_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; | |
| 2120 | 2120 | $priceparser = new PriceParser($this->db); | 
| 2121 | 2121 | $price_result = $priceparser->parseProduct($this); | 
| 2122 | 2122 |                      if ($price_result >= 0) {
 | 
| @@ -2156,22 +2156,22 @@ discard block | ||
| 2156 | 2156 | |
| 2157 | 2157 | $sql = "SELECT COUNT(DISTINCT p.fk_soc) as nb_customers, COUNT(DISTINCT p.rowid) as nb,"; | 
| 2158 | 2158 | $sql .= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty"; | 
| 2159 | - $sql .= " FROM " . MAIN_DB_PREFIX . "propaldet as pd"; | |
| 2160 | - $sql .= ", " . MAIN_DB_PREFIX . "propal as p"; | |
| 2161 | - $sql .= ", " . MAIN_DB_PREFIX . "societe as s"; | |
| 2159 | + $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pd"; | |
| 2160 | + $sql .= ", ".MAIN_DB_PREFIX."propal as p"; | |
| 2161 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; | |
| 2162 | 2162 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2163 | - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; | |
| 2163 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; | |
| 2164 | 2164 | } | 
| 2165 | 2165 | $sql .= " WHERE p.rowid = pd.fk_propal"; | 
| 2166 | 2166 | $sql .= " AND p.fk_soc = s.rowid"; | 
| 2167 | -        $sql .= " AND p.entity IN (" . getEntity('propal') . ")";
 | |
| 2168 | - $sql .= " AND pd.fk_product = " . $this->id; | |
| 2167 | +        $sql .= " AND p.entity IN (".getEntity('propal').")";
 | |
| 2168 | + $sql .= " AND pd.fk_product = ".$this->id; | |
| 2169 | 2169 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2170 | - $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id; | |
| 2170 | + $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; | |
| 2171 | 2171 | } | 
| 2172 | 2172 | //$sql.= " AND pr.fk_statut != 0"; | 
| 2173 | 2173 |          if ($socid > 0) {
 | 
| 2174 | - $sql .= " AND p.fk_soc = " . $socid; | |
| 2174 | + $sql .= " AND p.fk_soc = ".$socid; | |
| 2175 | 2175 | } | 
| 2176 | 2176 | |
| 2177 | 2177 | $result = $this->db->query($sql); | 
| @@ -2203,22 +2203,22 @@ discard block | ||
| 2203 | 2203 | |
| 2204 | 2204 | $sql = "SELECT COUNT(DISTINCT p.fk_soc) as nb_suppliers, COUNT(DISTINCT p.rowid) as nb,"; | 
| 2205 | 2205 | $sql .= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty"; | 
| 2206 | - $sql .= " FROM " . MAIN_DB_PREFIX . "supplier_proposaldet as pd"; | |
| 2207 | - $sql .= ", " . MAIN_DB_PREFIX . "supplier_proposal as p"; | |
| 2208 | - $sql .= ", " . MAIN_DB_PREFIX . "societe as s"; | |
| 2206 | + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as pd"; | |
| 2207 | + $sql .= ", ".MAIN_DB_PREFIX."supplier_proposal as p"; | |
| 2208 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; | |
| 2209 | 2209 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2210 | - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; | |
| 2210 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; | |
| 2211 | 2211 | } | 
| 2212 | 2212 | $sql .= " WHERE p.rowid = pd.fk_supplier_proposal"; | 
| 2213 | 2213 | $sql .= " AND p.fk_soc = s.rowid"; | 
| 2214 | -        $sql .= " AND p.entity IN (" . getEntity('supplier_proposal') . ")";
 | |
| 2215 | - $sql .= " AND pd.fk_product = " . $this->id; | |
| 2214 | +        $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")";
 | |
| 2215 | + $sql .= " AND pd.fk_product = ".$this->id; | |
| 2216 | 2216 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2217 | - $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id; | |
| 2217 | + $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; | |
| 2218 | 2218 | } | 
| 2219 | 2219 | //$sql.= " AND pr.fk_statut != 0"; | 
| 2220 | 2220 |          if ($socid > 0) {
 | 
| 2221 | - $sql .= " AND p.fk_soc = " . $socid; | |
| 2221 | + $sql .= " AND p.fk_soc = ".$socid; | |
| 2222 | 2222 | } | 
| 2223 | 2223 | |
| 2224 | 2224 | $result = $this->db->query($sql); | 
| @@ -2251,24 +2251,24 @@ discard block | ||
| 2251 | 2251 | |
| 2252 | 2252 | $sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,"; | 
| 2253 | 2253 | $sql .= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; | 
| 2254 | - $sql .= " FROM " . MAIN_DB_PREFIX . "commandedet as cd"; | |
| 2255 | - $sql .= ", " . MAIN_DB_PREFIX . "commande as c"; | |
| 2256 | - $sql .= ", " . MAIN_DB_PREFIX . "societe as s"; | |
| 2254 | + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; | |
| 2255 | + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; | |
| 2256 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; | |
| 2257 | 2257 |          if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) {
 | 
| 2258 | - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; | |
| 2258 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; | |
| 2259 | 2259 | } | 
| 2260 | 2260 | $sql .= " WHERE c.rowid = cd.fk_commande"; | 
| 2261 | 2261 | $sql .= " AND c.fk_soc = s.rowid"; | 
| 2262 | -        $sql .= " AND c.entity IN (" . getEntity('commande') . ")";
 | |
| 2263 | - $sql .= " AND cd.fk_product = " . $this->id; | |
| 2262 | +        $sql .= " AND c.entity IN (".getEntity('commande').")";
 | |
| 2263 | + $sql .= " AND cd.fk_product = ".$this->id; | |
| 2264 | 2264 |          if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) {
 | 
| 2265 | - $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id; | |
| 2265 | + $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; | |
| 2266 | 2266 | } | 
| 2267 | 2267 |          if ($socid > 0) {
 | 
| 2268 | - $sql .= " AND c.fk_soc = " . $socid; | |
| 2268 | + $sql .= " AND c.fk_soc = ".$socid; | |
| 2269 | 2269 | } | 
| 2270 | 2270 |          if ($filtrestatut <> '') {
 | 
| 2271 | -            $sql .= " AND c.fk_statut in (" . $filtrestatut . ")";
 | |
| 2271 | +            $sql .= " AND c.fk_statut in (".$filtrestatut.")";
 | |
| 2272 | 2272 | } | 
| 2273 | 2273 | |
| 2274 | 2274 | $result = $this->db->query($sql); | 
| @@ -2306,12 +2306,12 @@ discard block | ||
| 2306 | 2306 |              if (!empty($conf->global->STOCK_CALCULATE_ON_BILL)) {
 | 
| 2307 | 2307 |                  if (!empty($conf->global->DECREASE_ONLY_UNINVOICEDPRODUCTS)) {
 | 
| 2308 | 2308 | $adeduire = 0; | 
| 2309 | - $sql = "SELECT sum(fd.qty) as count FROM " . MAIN_DB_PREFIX . "facturedet fd "; | |
| 2310 | - $sql .= " JOIN " . MAIN_DB_PREFIX . "facture f ON fd.fk_facture = f.rowid "; | |
| 2311 | - $sql .= " JOIN " . MAIN_DB_PREFIX . "element_element el ON el.fk_target = f.rowid and el.targettype = 'facture' and sourcetype = 'commande'"; | |
| 2312 | - $sql .= " JOIN " . MAIN_DB_PREFIX . "commande c ON el.fk_source = c.rowid "; | |
| 2313 | -                    $sql .= " WHERE c.fk_statut IN (" . $filtrestatut . ") AND c.facture = 0 AND fd.fk_product = " . $this->id;
 | |
| 2314 | - dol_syslog(__METHOD__ . ":: sql $sql", LOG_NOTICE); | |
| 2309 | + $sql = "SELECT sum(fd.qty) as count FROM ".MAIN_DB_PREFIX."facturedet fd "; | |
| 2310 | + $sql .= " JOIN ".MAIN_DB_PREFIX."facture f ON fd.fk_facture = f.rowid "; | |
| 2311 | + $sql .= " JOIN ".MAIN_DB_PREFIX."element_element el ON el.fk_target = f.rowid and el.targettype = 'facture' and sourcetype = 'commande'"; | |
| 2312 | + $sql .= " JOIN ".MAIN_DB_PREFIX."commande c ON el.fk_source = c.rowid "; | |
| 2313 | +                    $sql .= " WHERE c.fk_statut IN (".$filtrestatut.") AND c.facture = 0 AND fd.fk_product = ".$this->id;
 | |
| 2314 | + dol_syslog(__METHOD__.":: sql $sql", LOG_NOTICE); | |
| 2315 | 2315 | |
| 2316 | 2316 | $resql = $this->db->query($sql); | 
| 2317 | 2317 |                      if ($resql) {
 | 
| @@ -2348,24 +2348,24 @@ discard block | ||
| 2348 | 2348 | |
| 2349 | 2349 | $sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_suppliers, COUNT(DISTINCT c.rowid) as nb,"; | 
| 2350 | 2350 | $sql .= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; | 
| 2351 | - $sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet as cd"; | |
| 2352 | - $sql .= ", " . MAIN_DB_PREFIX . "commande_fournisseur as c"; | |
| 2353 | - $sql .= ", " . MAIN_DB_PREFIX . "societe as s"; | |
| 2351 | + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd"; | |
| 2352 | + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c"; | |
| 2353 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; | |
| 2354 | 2354 |          if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) {
 | 
| 2355 | - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; | |
| 2355 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; | |
| 2356 | 2356 | } | 
| 2357 | 2357 | $sql .= " WHERE c.rowid = cd.fk_commande"; | 
| 2358 | 2358 | $sql .= " AND c.fk_soc = s.rowid"; | 
| 2359 | -        $sql .= " AND c.entity IN (" . getEntity('supplier_order') . ")";
 | |
| 2360 | - $sql .= " AND cd.fk_product = " . $this->id; | |
| 2359 | +        $sql .= " AND c.entity IN (".getEntity('supplier_order').")";
 | |
| 2360 | + $sql .= " AND cd.fk_product = ".$this->id; | |
| 2361 | 2361 |          if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) {
 | 
| 2362 | - $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id; | |
| 2362 | + $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; | |
| 2363 | 2363 | } | 
| 2364 | 2364 |          if ($socid > 0) {
 | 
| 2365 | - $sql .= " AND c.fk_soc = " . $socid; | |
| 2365 | + $sql .= " AND c.fk_soc = ".$socid; | |
| 2366 | 2366 | } | 
| 2367 | 2367 |          if ($filtrestatut != '') {
 | 
| 2368 | -            $sql .= " AND c.fk_statut in (" . $filtrestatut . ")"; // Peut valoir 0
 | |
| 2368 | +            $sql .= " AND c.fk_statut in (".$filtrestatut.")"; // Peut valoir 0
 | |
| 2369 | 2369 | } | 
| 2370 | 2370 | |
| 2371 | 2371 | $result = $this->db->query($sql); | 
| @@ -2377,7 +2377,7 @@ discard block | ||
| 2377 | 2377 | $this->stats_commande_fournisseur['qty'] = $obj->qty ? $obj->qty : 0; | 
| 2378 | 2378 | return 1; | 
| 2379 | 2379 |          } else {
 | 
| 2380 | - $this->error = $this->db->error() . ' sql=' . $sql; | |
| 2380 | + $this->error = $this->db->error().' sql='.$sql; | |
| 2381 | 2381 | return -1; | 
| 2382 | 2382 | } | 
| 2383 | 2383 | } | 
| @@ -2398,28 +2398,28 @@ discard block | ||
| 2398 | 2398 | |
| 2399 | 2399 | $sql = "SELECT COUNT(DISTINCT e.fk_soc) as nb_customers, COUNT(DISTINCT e.rowid) as nb,"; | 
| 2400 | 2400 | $sql .= " COUNT(ed.rowid) as nb_rows, SUM(ed.qty) as qty"; | 
| 2401 | - $sql .= " FROM " . MAIN_DB_PREFIX . "expeditiondet as ed"; | |
| 2402 | - $sql .= ", " . MAIN_DB_PREFIX . "commandedet as cd"; | |
| 2403 | - $sql .= ", " . MAIN_DB_PREFIX . "commande as c"; | |
| 2404 | - $sql .= ", " . MAIN_DB_PREFIX . "expedition as e"; | |
| 2405 | - $sql .= ", " . MAIN_DB_PREFIX . "societe as s"; | |
| 2401 | + $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; | |
| 2402 | + $sql .= ", ".MAIN_DB_PREFIX."commandedet as cd"; | |
| 2403 | + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; | |
| 2404 | + $sql .= ", ".MAIN_DB_PREFIX."expedition as e"; | |
| 2405 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; | |
| 2406 | 2406 |          if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) {
 | 
| 2407 | - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; | |
| 2407 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; | |
| 2408 | 2408 | } | 
| 2409 | 2409 | $sql .= " WHERE e.rowid = ed.fk_expedition"; | 
| 2410 | 2410 | $sql .= " AND c.rowid = cd.fk_commande"; | 
| 2411 | 2411 | $sql .= " AND e.fk_soc = s.rowid"; | 
| 2412 | -        $sql .= " AND e.entity IN (" . getEntity('expedition') . ")";
 | |
| 2412 | +        $sql .= " AND e.entity IN (".getEntity('expedition').")";
 | |
| 2413 | 2413 | $sql .= " AND ed.fk_origin_line = cd.rowid"; | 
| 2414 | - $sql .= " AND cd.fk_product = " . $this->id; | |
| 2414 | + $sql .= " AND cd.fk_product = ".$this->id; | |
| 2415 | 2415 |          if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) {
 | 
| 2416 | - $sql .= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id; | |
| 2416 | + $sql .= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; | |
| 2417 | 2417 | } | 
| 2418 | 2418 |          if ($socid > 0) {
 | 
| 2419 | - $sql .= " AND e.fk_soc = " . $socid; | |
| 2419 | + $sql .= " AND e.fk_soc = ".$socid; | |
| 2420 | 2420 | } | 
| 2421 | 2421 |          if ($filtrestatut <> '') {
 | 
| 2422 | -            $sql .= " AND c.fk_statut in (" . $filtrestatut . ")";
 | |
| 2422 | +            $sql .= " AND c.fk_statut in (".$filtrestatut.")";
 | |
| 2423 | 2423 | } | 
| 2424 | 2424 | |
| 2425 | 2425 | $result = $this->db->query($sql); | 
| @@ -2452,24 +2452,24 @@ discard block | ||
| 2452 | 2452 | |
| 2453 | 2453 | $sql = "SELECT COUNT(DISTINCT cf.fk_soc) as nb_customers, COUNT(DISTINCT cf.rowid) as nb,"; | 
| 2454 | 2454 | $sql .= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty"; | 
| 2455 | - $sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseur_dispatch as fd"; | |
| 2456 | - $sql .= ", " . MAIN_DB_PREFIX . "commande_fournisseur as cf"; | |
| 2457 | - $sql .= ", " . MAIN_DB_PREFIX . "societe as s"; | |
| 2455 | + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as fd"; | |
| 2456 | + $sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf"; | |
| 2457 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; | |
| 2458 | 2458 |          if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) {
 | 
| 2459 | - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; | |
| 2459 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; | |
| 2460 | 2460 | } | 
| 2461 | 2461 | $sql .= " WHERE cf.rowid = fd.fk_commande"; | 
| 2462 | 2462 | $sql .= " AND cf.fk_soc = s.rowid"; | 
| 2463 | -        $sql .= " AND cf.entity IN (" . getEntity('supplier_order') . ")";
 | |
| 2464 | - $sql .= " AND fd.fk_product = " . $this->id; | |
| 2463 | +        $sql .= " AND cf.entity IN (".getEntity('supplier_order').")";
 | |
| 2464 | + $sql .= " AND fd.fk_product = ".$this->id; | |
| 2465 | 2465 |          if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) {
 | 
| 2466 | - $sql .= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id; | |
| 2466 | + $sql .= " AND cf.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; | |
| 2467 | 2467 | } | 
| 2468 | 2468 |          if ($socid > 0) {
 | 
| 2469 | - $sql .= " AND cf.fk_soc = " . $socid; | |
| 2469 | + $sql .= " AND cf.fk_soc = ".$socid; | |
| 2470 | 2470 | } | 
| 2471 | 2471 |          if ($filtrestatut <> '') {
 | 
| 2472 | -            $sql .= " AND cf.fk_statut in (" . $filtrestatut . ")";
 | |
| 2472 | +            $sql .= " AND cf.fk_statut in (".$filtrestatut.")";
 | |
| 2473 | 2473 | } | 
| 2474 | 2474 | |
| 2475 | 2475 | $result = $this->db->query($sql); | 
| @@ -2501,22 +2501,22 @@ discard block | ||
| 2501 | 2501 | |
| 2502 | 2502 | $sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,"; | 
| 2503 | 2503 | $sql .= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; | 
| 2504 | - $sql .= " FROM " . MAIN_DB_PREFIX . "contratdet as cd"; | |
| 2505 | - $sql .= ", " . MAIN_DB_PREFIX . "contrat as c"; | |
| 2506 | - $sql .= ", " . MAIN_DB_PREFIX . "societe as s"; | |
| 2504 | + $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; | |
| 2505 | + $sql .= ", ".MAIN_DB_PREFIX."contrat as c"; | |
| 2506 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; | |
| 2507 | 2507 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2508 | - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; | |
| 2508 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; | |
| 2509 | 2509 | } | 
| 2510 | 2510 | $sql .= " WHERE c.rowid = cd.fk_contrat"; | 
| 2511 | 2511 | $sql .= " AND c.fk_soc = s.rowid"; | 
| 2512 | -        $sql .= " AND c.entity IN (" . getEntity('contract') . ")";
 | |
| 2513 | - $sql .= " AND cd.fk_product = " . $this->id; | |
| 2512 | +        $sql .= " AND c.entity IN (".getEntity('contract').")";
 | |
| 2513 | + $sql .= " AND cd.fk_product = ".$this->id; | |
| 2514 | 2514 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2515 | - $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id; | |
| 2515 | + $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; | |
| 2516 | 2516 | } | 
| 2517 | 2517 | //$sql.= " AND c.statut != 0"; | 
| 2518 | 2518 |          if ($socid > 0) {
 | 
| 2519 | - $sql .= " AND c.fk_soc = " . $socid; | |
| 2519 | + $sql .= " AND c.fk_soc = ".$socid; | |
| 2520 | 2520 | } | 
| 2521 | 2521 | |
| 2522 | 2522 | $result = $this->db->query($sql); | 
| @@ -2528,7 +2528,7 @@ discard block | ||
| 2528 | 2528 | $this->stats_contrat['qty'] = $obj->qty ? $obj->qty : 0; | 
| 2529 | 2529 | return 1; | 
| 2530 | 2530 |          } else {
 | 
| 2531 | - $this->error = $this->db->error() . ' sql=' . $sql; | |
| 2531 | + $this->error = $this->db->error().' sql='.$sql; | |
| 2532 | 2532 | return -1; | 
| 2533 | 2533 | } | 
| 2534 | 2534 | } | 
| @@ -2548,22 +2548,22 @@ discard block | ||
| 2548 | 2548 | |
| 2549 | 2549 | $sql = "SELECT COUNT(DISTINCT f.fk_soc) as nb_customers, COUNT(DISTINCT f.rowid) as nb,"; | 
| 2550 | 2550 | $sql .= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty"; | 
| 2551 | - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; | |
| 2552 | - $sql .= ", " . MAIN_DB_PREFIX . "facture as f"; | |
| 2553 | - $sql .= ", " . MAIN_DB_PREFIX . "societe as s"; | |
| 2551 | + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; | |
| 2552 | + $sql .= ", ".MAIN_DB_PREFIX."facture as f"; | |
| 2553 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; | |
| 2554 | 2554 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2555 | - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; | |
| 2555 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; | |
| 2556 | 2556 | } | 
| 2557 | 2557 | $sql .= " WHERE f.rowid = fd.fk_facture"; | 
| 2558 | 2558 | $sql .= " AND f.fk_soc = s.rowid"; | 
| 2559 | -        $sql .= " AND f.entity IN (" . getEntity('invoice') . ")";
 | |
| 2560 | - $sql .= " AND fd.fk_product = " . $this->id; | |
| 2559 | +        $sql .= " AND f.entity IN (".getEntity('invoice').")";
 | |
| 2560 | + $sql .= " AND fd.fk_product = ".$this->id; | |
| 2561 | 2561 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2562 | - $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id; | |
| 2562 | + $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; | |
| 2563 | 2563 | } | 
| 2564 | 2564 | //$sql.= " AND f.fk_statut != 0"; | 
| 2565 | 2565 |          if ($socid > 0) {
 | 
| 2566 | - $sql .= " AND f.fk_soc = " . $socid; | |
| 2566 | + $sql .= " AND f.fk_soc = ".$socid; | |
| 2567 | 2567 | } | 
| 2568 | 2568 | |
| 2569 | 2569 | $result = $this->db->query($sql); | 
| @@ -2595,22 +2595,22 @@ discard block | ||
| 2595 | 2595 | |
| 2596 | 2596 | $sql = "SELECT COUNT(DISTINCT f.fk_soc) as nb_suppliers, COUNT(DISTINCT f.rowid) as nb,"; | 
| 2597 | 2597 | $sql .= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty"; | 
| 2598 | - $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd"; | |
| 2599 | - $sql .= ", " . MAIN_DB_PREFIX . "facture_fourn as f"; | |
| 2600 | - $sql .= ", " . MAIN_DB_PREFIX . "societe as s"; | |
| 2598 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd"; | |
| 2599 | + $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f"; | |
| 2600 | + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; | |
| 2601 | 2601 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2602 | - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; | |
| 2602 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; | |
| 2603 | 2603 | } | 
| 2604 | 2604 | $sql .= " WHERE f.rowid = fd.fk_facture_fourn"; | 
| 2605 | 2605 | $sql .= " AND f.fk_soc = s.rowid"; | 
| 2606 | -        $sql .= " AND f.entity IN (" . getEntity('facture_fourn') . ")";
 | |
| 2607 | - $sql .= " AND fd.fk_product = " . $this->id; | |
| 2606 | +        $sql .= " AND f.entity IN (".getEntity('facture_fourn').")";
 | |
| 2607 | + $sql .= " AND fd.fk_product = ".$this->id; | |
| 2608 | 2608 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2609 | - $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id; | |
| 2609 | + $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; | |
| 2610 | 2610 | } | 
| 2611 | 2611 | //$sql.= " AND f.fk_statut != 0"; | 
| 2612 | 2612 |          if ($socid > 0) {
 | 
| 2613 | - $sql .= " AND f.fk_soc = " . $socid; | |
| 2613 | + $sql .= " AND f.fk_soc = ".$socid; | |
| 2614 | 2614 | } | 
| 2615 | 2615 | |
| 2616 | 2616 | $result = $this->db->query($sql); | 
| @@ -2646,15 +2646,15 @@ discard block | ||
| 2646 | 2646 |              while ($i < $num) {
 | 
| 2647 | 2647 | $arr = $this->db->fetch_array($resql); | 
| 2648 | 2648 |                  if ($mode == 'byunit') {
 | 
| 2649 | - $tab[$arr[1]] = $arr[0]; // 1st field | |
| 2649 | + $tab[$arr[1]] = $arr[0]; // 1st field | |
| 2650 | 2650 | } | 
| 2651 | 2651 |                  if ($mode == 'bynumber') {
 | 
| 2652 | - $tab[$arr[1]] = $arr[2]; // 3rd field | |
| 2652 | + $tab[$arr[1]] = $arr[2]; // 3rd field | |
| 2653 | 2653 | } | 
| 2654 | 2654 | $i++; | 
| 2655 | 2655 | } | 
| 2656 | 2656 |          } else {
 | 
| 2657 | - $this->error = $this->db->error() . ' sql=' . $sql; | |
| 2657 | + $this->error = $this->db->error().' sql='.$sql; | |
| 2658 | 2658 | return -1; | 
| 2659 | 2659 | } | 
| 2660 | 2660 | |
| @@ -2662,7 +2662,7 @@ discard block | ||
| 2662 | 2662 |              $year = strftime('%Y', time());
 | 
| 2663 | 2663 |              $month = strftime('%m', time());
 | 
| 2664 | 2664 |          } else {
 | 
| 2665 | - $month = 12; // We imagine we are at end of year, so we get last 12 month before, so all correct year. | |
| 2665 | + $month = 12; // We imagine we are at end of year, so we get last 12 month before, so all correct year. | |
| 2666 | 2666 | } | 
| 2667 | 2667 | $result = array(); | 
| 2668 | 2668 | |
| @@ -2670,10 +2670,10 @@ discard block | ||
| 2670 | 2670 | $idx = ucfirst(dol_trunc(dol_print_date(dol_mktime(12, 0, 0, $month, 1, $year), "%b"), 3, 'right', 'UTF-8', 1)); | 
| 2671 | 2671 |              $monthnum = sprintf("%02s", $month);
 | 
| 2672 | 2672 | |
| 2673 | - $result[$j] = array($idx, isset($tab[$year . $month]) ? $tab[$year . $month] : 0); | |
| 2673 | + $result[$j] = array($idx, isset($tab[$year.$month]) ? $tab[$year.$month] : 0); | |
| 2674 | 2674 | // $result[$j] = array($monthnum,isset($tab[$year.$month])?$tab[$year.$month]:0); | 
| 2675 | 2675 | |
| 2676 | - $month = "0" . ($month - 1); | |
| 2676 | + $month = "0".($month - 1); | |
| 2677 | 2677 |              if (dol_strlen($month) == 3) {
 | 
| 2678 | 2678 | $month = substr($month, 1); | 
| 2679 | 2679 | } | 
| @@ -2707,26 +2707,26 @@ discard block | ||
| 2707 | 2707 |          if ($mode == 'bynumber') {
 | 
| 2708 | 2708 | $sql .= ", count(DISTINCT f.rowid)"; | 
| 2709 | 2709 | } | 
| 2710 | - $sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as d, " . MAIN_DB_PREFIX . "facture as f, " . MAIN_DB_PREFIX . "societe as s"; | |
| 2710 | + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as d, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; | |
| 2711 | 2711 |          if ($filteronproducttype >= 0) {
 | 
| 2712 | - $sql .= ", " . MAIN_DB_PREFIX . "product as p"; | |
| 2712 | + $sql .= ", ".MAIN_DB_PREFIX."product as p"; | |
| 2713 | 2713 | } | 
| 2714 | 2714 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2715 | - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; | |
| 2715 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; | |
| 2716 | 2716 | } | 
| 2717 | 2717 | $sql .= " WHERE f.rowid = d.fk_facture"; | 
| 2718 | 2718 |          if ($this->id > 0) {
 | 
| 2719 | - $sql .= " AND d.fk_product =" . $this->id; | |
| 2719 | + $sql .= " AND d.fk_product =".$this->id; | |
| 2720 | 2720 |          } else {
 | 
| 2721 | 2721 | $sql .= " AND d.fk_product > 0"; | 
| 2722 | 2722 | } | 
| 2723 | 2723 |          if ($filteronproducttype >= 0) {
 | 
| 2724 | - $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =" . $filteronproducttype; | |
| 2724 | + $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; | |
| 2725 | 2725 | } | 
| 2726 | 2726 | $sql .= " AND f.fk_soc = s.rowid"; | 
| 2727 | -        $sql .= " AND f.entity IN (" . getEntity('invoice') . ")";
 | |
| 2727 | +        $sql .= " AND f.entity IN (".getEntity('invoice').")";
 | |
| 2728 | 2728 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2729 | - $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id; | |
| 2729 | + $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; | |
| 2730 | 2730 | } | 
| 2731 | 2731 |          if ($socid > 0) {
 | 
| 2732 | 2732 | $sql .= " AND f.fk_soc = $socid"; | 
| @@ -2759,26 +2759,26 @@ discard block | ||
| 2759 | 2759 |          if ($mode == 'bynumber') {
 | 
| 2760 | 2760 | $sql .= ", count(DISTINCT f.rowid)"; | 
| 2761 | 2761 | } | 
| 2762 | - $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as d, " . MAIN_DB_PREFIX . "facture_fourn as f, " . MAIN_DB_PREFIX . "societe as s"; | |
| 2762 | + $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as d, ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s"; | |
| 2763 | 2763 |          if ($filteronproducttype >= 0) {
 | 
| 2764 | - $sql .= ", " . MAIN_DB_PREFIX . "product as p"; | |
| 2764 | + $sql .= ", ".MAIN_DB_PREFIX."product as p"; | |
| 2765 | 2765 | } | 
| 2766 | 2766 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2767 | - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; | |
| 2767 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; | |
| 2768 | 2768 | } | 
| 2769 | 2769 | $sql .= " WHERE f.rowid = d.fk_facture_fourn"; | 
| 2770 | 2770 |          if ($this->id > 0) {
 | 
| 2771 | - $sql .= " AND d.fk_product =" . $this->id; | |
| 2771 | + $sql .= " AND d.fk_product =".$this->id; | |
| 2772 | 2772 |          } else {
 | 
| 2773 | 2773 | $sql .= " AND d.fk_product > 0"; | 
| 2774 | 2774 | } | 
| 2775 | 2775 |          if ($filteronproducttype >= 0) {
 | 
| 2776 | - $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =" . $filteronproducttype; | |
| 2776 | + $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; | |
| 2777 | 2777 | } | 
| 2778 | 2778 | $sql .= " AND f.fk_soc = s.rowid"; | 
| 2779 | -        $sql .= " AND f.entity IN (" . getEntity('facture_fourn') . ")";
 | |
| 2779 | +        $sql .= " AND f.entity IN (".getEntity('facture_fourn').")";
 | |
| 2780 | 2780 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2781 | - $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id; | |
| 2781 | + $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; | |
| 2782 | 2782 | } | 
| 2783 | 2783 |          if ($socid > 0) {
 | 
| 2784 | 2784 | $sql .= " AND f.fk_soc = $socid"; | 
| @@ -2811,29 +2811,29 @@ discard block | ||
| 2811 | 2811 |          if ($mode == 'bynumber') {
 | 
| 2812 | 2812 | $sql .= ", count(DISTINCT p.rowid)"; | 
| 2813 | 2813 | } | 
| 2814 | - $sql .= " FROM " . MAIN_DB_PREFIX . "propaldet as d, " . MAIN_DB_PREFIX . "propal as p, " . MAIN_DB_PREFIX . "societe as s"; | |
| 2814 | + $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as d, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s"; | |
| 2815 | 2815 |          if ($filteronproducttype >= 0) {
 | 
| 2816 | - $sql .= ", " . MAIN_DB_PREFIX . "product as prod"; | |
| 2816 | + $sql .= ", ".MAIN_DB_PREFIX."product as prod"; | |
| 2817 | 2817 | } | 
| 2818 | 2818 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2819 | - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; | |
| 2819 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; | |
| 2820 | 2820 | } | 
| 2821 | 2821 | $sql .= " WHERE p.rowid = d.fk_propal"; | 
| 2822 | 2822 |          if ($this->id > 0) {
 | 
| 2823 | - $sql .= " AND d.fk_product =" . $this->id; | |
| 2823 | + $sql .= " AND d.fk_product =".$this->id; | |
| 2824 | 2824 |          } else {
 | 
| 2825 | 2825 | $sql .= " AND d.fk_product > 0"; | 
| 2826 | 2826 | } | 
| 2827 | 2827 |          if ($filteronproducttype >= 0) {
 | 
| 2828 | - $sql .= " AND prod.rowid = d.fk_product AND prod.fk_product_type =" . $filteronproducttype; | |
| 2828 | + $sql .= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype; | |
| 2829 | 2829 | } | 
| 2830 | 2830 | $sql .= " AND p.fk_soc = s.rowid"; | 
| 2831 | -        $sql .= " AND p.entity IN (" . getEntity('propal') . ")";
 | |
| 2831 | +        $sql .= " AND p.entity IN (".getEntity('propal').")";
 | |
| 2832 | 2832 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2833 | - $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id; | |
| 2833 | + $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; | |
| 2834 | 2834 | } | 
| 2835 | 2835 |          if ($socid > 0) {
 | 
| 2836 | - $sql .= " AND p.fk_soc = " . $socid; | |
| 2836 | + $sql .= " AND p.fk_soc = ".$socid; | |
| 2837 | 2837 | } | 
| 2838 | 2838 | $sql .= $morefilter; | 
| 2839 | 2839 | $sql .= " GROUP BY date_format(p.datep,'%Y%m')"; | 
| @@ -2863,29 +2863,29 @@ discard block | ||
| 2863 | 2863 |          if ($mode == 'bynumber') {
 | 
| 2864 | 2864 | $sql .= ", count(DISTINCT p.rowid)"; | 
| 2865 | 2865 | } | 
| 2866 | - $sql .= " FROM " . MAIN_DB_PREFIX . "supplier_proposaldet as d, " . MAIN_DB_PREFIX . "supplier_proposal as p, " . MAIN_DB_PREFIX . "societe as s"; | |
| 2866 | + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as d, ".MAIN_DB_PREFIX."supplier_proposal as p, ".MAIN_DB_PREFIX."societe as s"; | |
| 2867 | 2867 |          if ($filteronproducttype >= 0) {
 | 
| 2868 | - $sql .= ", " . MAIN_DB_PREFIX . "product as prod"; | |
| 2868 | + $sql .= ", ".MAIN_DB_PREFIX."product as prod"; | |
| 2869 | 2869 | } | 
| 2870 | 2870 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2871 | - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; | |
| 2871 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; | |
| 2872 | 2872 | } | 
| 2873 | 2873 | $sql .= " WHERE p.rowid = d.fk_supplier_proposal"; | 
| 2874 | 2874 |          if ($this->id > 0) {
 | 
| 2875 | - $sql .= " AND d.fk_product =" . $this->id; | |
| 2875 | + $sql .= " AND d.fk_product =".$this->id; | |
| 2876 | 2876 |          } else {
 | 
| 2877 | 2877 | $sql .= " AND d.fk_product > 0"; | 
| 2878 | 2878 | } | 
| 2879 | 2879 |          if ($filteronproducttype >= 0) {
 | 
| 2880 | - $sql .= " AND prod.rowid = d.fk_product AND prod.fk_product_type =" . $filteronproducttype; | |
| 2880 | + $sql .= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype; | |
| 2881 | 2881 | } | 
| 2882 | 2882 | $sql .= " AND p.fk_soc = s.rowid"; | 
| 2883 | -        $sql .= " AND p.entity IN (" . getEntity('supplier_proposal') . ")";
 | |
| 2883 | +        $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")";
 | |
| 2884 | 2884 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2885 | - $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id; | |
| 2885 | + $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; | |
| 2886 | 2886 | } | 
| 2887 | 2887 |          if ($socid > 0) {
 | 
| 2888 | - $sql .= " AND p.fk_soc = " . $socid; | |
| 2888 | + $sql .= " AND p.fk_soc = ".$socid; | |
| 2889 | 2889 | } | 
| 2890 | 2890 | $sql .= $morefilter; | 
| 2891 | 2891 | $sql .= " GROUP BY date_format(p.date_valid,'%Y%m')"; | 
| @@ -2914,29 +2914,29 @@ discard block | ||
| 2914 | 2914 |          if ($mode == 'bynumber') {
 | 
| 2915 | 2915 | $sql .= ", count(DISTINCT c.rowid)"; | 
| 2916 | 2916 | } | 
| 2917 | - $sql .= " FROM " . MAIN_DB_PREFIX . "commandedet as d, " . MAIN_DB_PREFIX . "commande as c, " . MAIN_DB_PREFIX . "societe as s"; | |
| 2917 | + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as d, ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s"; | |
| 2918 | 2918 |          if ($filteronproducttype >= 0) {
 | 
| 2919 | - $sql .= ", " . MAIN_DB_PREFIX . "product as p"; | |
| 2919 | + $sql .= ", ".MAIN_DB_PREFIX."product as p"; | |
| 2920 | 2920 | } | 
| 2921 | 2921 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2922 | - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; | |
| 2922 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; | |
| 2923 | 2923 | } | 
| 2924 | 2924 | $sql .= " WHERE c.rowid = d.fk_commande"; | 
| 2925 | 2925 |          if ($this->id > 0) {
 | 
| 2926 | - $sql .= " AND d.fk_product =" . $this->id; | |
| 2926 | + $sql .= " AND d.fk_product =".$this->id; | |
| 2927 | 2927 |          } else {
 | 
| 2928 | 2928 | $sql .= " AND d.fk_product > 0"; | 
| 2929 | 2929 | } | 
| 2930 | 2930 |          if ($filteronproducttype >= 0) {
 | 
| 2931 | - $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =" . $filteronproducttype; | |
| 2931 | + $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; | |
| 2932 | 2932 | } | 
| 2933 | 2933 | $sql .= " AND c.fk_soc = s.rowid"; | 
| 2934 | -        $sql .= " AND c.entity IN (" . getEntity('commande') . ")";
 | |
| 2934 | +        $sql .= " AND c.entity IN (".getEntity('commande').")";
 | |
| 2935 | 2935 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2936 | - $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id; | |
| 2936 | + $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; | |
| 2937 | 2937 | } | 
| 2938 | 2938 |          if ($socid > 0) {
 | 
| 2939 | - $sql .= " AND c.fk_soc = " . $socid; | |
| 2939 | + $sql .= " AND c.fk_soc = ".$socid; | |
| 2940 | 2940 | } | 
| 2941 | 2941 | $sql .= $morefilter; | 
| 2942 | 2942 | $sql .= " GROUP BY date_format(c.date_commande,'%Y%m')"; | 
| @@ -2965,29 +2965,29 @@ discard block | ||
| 2965 | 2965 |          if ($mode == 'bynumber') {
 | 
| 2966 | 2966 | $sql .= ", count(DISTINCT c.rowid)"; | 
| 2967 | 2967 | } | 
| 2968 | - $sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet as d, " . MAIN_DB_PREFIX . "commande_fournisseur as c, " . MAIN_DB_PREFIX . "societe as s"; | |
| 2968 | + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as d, ".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."societe as s"; | |
| 2969 | 2969 |          if ($filteronproducttype >= 0) {
 | 
| 2970 | - $sql .= ", " . MAIN_DB_PREFIX . "product as p"; | |
| 2970 | + $sql .= ", ".MAIN_DB_PREFIX."product as p"; | |
| 2971 | 2971 | } | 
| 2972 | 2972 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2973 | - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; | |
| 2973 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; | |
| 2974 | 2974 | } | 
| 2975 | 2975 | $sql .= " WHERE c.rowid = d.fk_commande"; | 
| 2976 | 2976 |          if ($this->id > 0) {
 | 
| 2977 | - $sql .= " AND d.fk_product =" . $this->id; | |
| 2977 | + $sql .= " AND d.fk_product =".$this->id; | |
| 2978 | 2978 |          } else {
 | 
| 2979 | 2979 | $sql .= " AND d.fk_product > 0"; | 
| 2980 | 2980 | } | 
| 2981 | 2981 |          if ($filteronproducttype >= 0) {
 | 
| 2982 | - $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =" . $filteronproducttype; | |
| 2982 | + $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; | |
| 2983 | 2983 | } | 
| 2984 | 2984 | $sql .= " AND c.fk_soc = s.rowid"; | 
| 2985 | -        $sql .= " AND c.entity IN (" . getEntity('supplier_order') . ")";
 | |
| 2985 | +        $sql .= " AND c.entity IN (".getEntity('supplier_order').")";
 | |
| 2986 | 2986 |          if (!$user->rights->societe->client->voir && !$socid) {
 | 
| 2987 | - $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " . $user->id; | |
| 2987 | + $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; | |
| 2988 | 2988 | } | 
| 2989 | 2989 |          if ($socid > 0) {
 | 
| 2990 | - $sql .= " AND c.fk_soc = " . $socid; | |
| 2990 | + $sql .= " AND c.fk_soc = ".$socid; | |
| 2991 | 2991 | } | 
| 2992 | 2992 | $sql .= $morefilter; | 
| 2993 | 2993 | $sql .= " GROUP BY date_format(c.date_commande,'%Y%m')"; | 
| @@ -3026,8 +3026,8 @@ discard block | ||
| 3026 | 3026 | } | 
| 3027 | 3027 | |
| 3028 | 3028 | // Check not already father of id_pere (to avoid father -> child -> father links) | 
| 3029 | - $sql = 'SELECT fk_product_pere from ' . MAIN_DB_PREFIX . 'product_association'; | |
| 3030 | - $sql .= ' WHERE fk_product_pere = ' . $id_fils . ' AND fk_product_fils = ' . $id_pere; | |
| 3029 | + $sql = 'SELECT fk_product_pere from '.MAIN_DB_PREFIX.'product_association'; | |
| 3030 | + $sql .= ' WHERE fk_product_pere = '.$id_fils.' AND fk_product_fils = '.$id_pere; | |
| 3031 | 3031 |          if (!$this->db->query($sql)) {
 | 
| 3032 | 3032 | dol_print_error($this->db); | 
| 3033 | 3033 | return -1; | 
| @@ -3039,8 +3039,8 @@ discard block | ||
| 3039 | 3039 | $this->error = "isFatherOfThis"; | 
| 3040 | 3040 | return -1; | 
| 3041 | 3041 |                  } else {
 | 
| 3042 | - $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'product_association(fk_product_pere,fk_product_fils,qty,incdec)'; | |
| 3043 | -                    $sql .= ' VALUES (' . $id_pere . ', ' . $id_fils . ', ' . $qty . ', ' . $incdec . ')';
 | |
| 3042 | + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association(fk_product_pere,fk_product_fils,qty,incdec)'; | |
| 3043 | +                    $sql .= ' VALUES ('.$id_pere.', '.$id_fils.', '.$qty.', '.$incdec.')';
 | |
| 3044 | 3044 |                      if (!$this->db->query($sql)) {
 | 
| 3045 | 3045 | dol_print_error($this->db); | 
| 3046 | 3046 | return -1; | 
| @@ -3079,10 +3079,10 @@ discard block | ||
| 3079 | 3079 | $qty = 1; | 
| 3080 | 3080 | } | 
| 3081 | 3081 | |
| 3082 | - $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'product_association SET '; | |
| 3083 | - $sql .= 'qty=' . $qty; | |
| 3084 | - $sql .= ',incdec=' . $incdec; | |
| 3085 | - $sql .= ' WHERE fk_product_pere=' . $id_pere . ' AND fk_product_fils=' . $id_fils; | |
| 3082 | + $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_association SET '; | |
| 3083 | + $sql .= 'qty='.$qty; | |
| 3084 | + $sql .= ',incdec='.$incdec; | |
| 3085 | + $sql .= ' WHERE fk_product_pere='.$id_pere.' AND fk_product_fils='.$id_fils; | |
| 3086 | 3086 | |
| 3087 | 3087 |          if (!$this->db->query($sql)) {
 | 
| 3088 | 3088 | dol_print_error($this->db); | 
| @@ -3110,11 +3110,11 @@ discard block | ||
| 3110 | 3110 | $fk_child = 0; | 
| 3111 | 3111 | } | 
| 3112 | 3112 | |
| 3113 | - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "product_association"; | |
| 3114 | - $sql .= " WHERE fk_product_pere = " . $fk_parent; | |
| 3115 | - $sql .= " AND fk_product_fils = " . $fk_child; | |
| 3113 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_association"; | |
| 3114 | + $sql .= " WHERE fk_product_pere = ".$fk_parent; | |
| 3115 | + $sql .= " AND fk_product_fils = ".$fk_child; | |
| 3116 | 3116 | |
| 3117 | - dol_syslog(get_class($this) . '::del_sousproduit', LOG_DEBUG); | |
| 3117 | + dol_syslog(get_class($this).'::del_sousproduit', LOG_DEBUG); | |
| 3118 | 3118 |          if (!$this->db->query($sql)) {
 | 
| 3119 | 3119 | dol_print_error($this->db); | 
| 3120 | 3120 | return -1; | 
| @@ -3135,9 +3135,9 @@ discard block | ||
| 3135 | 3135 |      {
 | 
| 3136 | 3136 | // phpcs:enable | 
| 3137 | 3137 | $sql = "SELECT fk_product_pere, qty, incdec"; | 
| 3138 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_association"; | |
| 3139 | - $sql .= " WHERE fk_product_pere = '" . $fk_parent . "'"; | |
| 3140 | - $sql .= " AND fk_product_fils = '" . $fk_child . "'"; | |
| 3138 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_association"; | |
| 3139 | + $sql .= " WHERE fk_product_pere = '".$fk_parent."'"; | |
| 3140 | + $sql .= " AND fk_product_fils = '".$fk_child."'"; | |
| 3141 | 3141 | |
| 3142 | 3142 | $result = $this->db->query($sql); | 
| 3143 | 3143 |          if ($result) {
 | 
| @@ -3176,15 +3176,15 @@ discard block | ||
| 3176 | 3176 | |
| 3177 | 3177 | $now = dol_now(); | 
| 3178 | 3178 | |
| 3179 | - dol_syslog(get_class($this) . "::add_fournisseur id_fourn = " . $id_fourn . " ref_fourn=" . $ref_fourn . " quantity=" . $quantity, LOG_DEBUG); | |
| 3179 | + dol_syslog(get_class($this)."::add_fournisseur id_fourn = ".$id_fourn." ref_fourn=".$ref_fourn." quantity=".$quantity, LOG_DEBUG); | |
| 3180 | 3180 | |
| 3181 | 3181 |          if ($ref_fourn) {
 | 
| 3182 | 3182 | $sql = "SELECT rowid, fk_product"; | 
| 3183 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_fournisseur_price"; | |
| 3184 | - $sql .= " WHERE fk_soc = " . $id_fourn; | |
| 3185 | - $sql .= " AND ref_fourn = '" . $this->db->escape($ref_fourn) . "'"; | |
| 3186 | - $sql .= " AND fk_product != " . $this->id; | |
| 3187 | -            $sql .= " AND entity IN (" . getEntity('productsupplierprice') . ")";
 | |
| 3183 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; | |
| 3184 | + $sql .= " WHERE fk_soc = ".$id_fourn; | |
| 3185 | + $sql .= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; | |
| 3186 | + $sql .= " AND fk_product != ".$this->id; | |
| 3187 | +            $sql .= " AND entity IN (".getEntity('productsupplierprice').")";
 | |
| 3188 | 3188 | |
| 3189 | 3189 | $resql = $this->db->query($sql); | 
| 3190 | 3190 |              if ($resql) {
 | 
| @@ -3199,16 +3199,16 @@ discard block | ||
| 3199 | 3199 | } | 
| 3200 | 3200 | |
| 3201 | 3201 | $sql = "SELECT rowid"; | 
| 3202 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_fournisseur_price"; | |
| 3203 | - $sql .= " WHERE fk_soc = " . $id_fourn; | |
| 3202 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; | |
| 3203 | + $sql .= " WHERE fk_soc = ".$id_fourn; | |
| 3204 | 3204 |          if ($ref_fourn) {
 | 
| 3205 | - $sql .= " AND ref_fourn = '" . $this->db->escape($ref_fourn) . "'"; | |
| 3205 | + $sql .= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; | |
| 3206 | 3206 |          } else {
 | 
| 3207 | 3207 | $sql .= " AND (ref_fourn = '' OR ref_fourn IS NULL)"; | 
| 3208 | 3208 | } | 
| 3209 | - $sql .= " AND quantity = '" . $quantity . "'"; | |
| 3210 | - $sql .= " AND fk_product = " . $this->id; | |
| 3211 | -        $sql .= " AND entity IN (" . getEntity('productsupplierprice') . ")";
 | |
| 3209 | + $sql .= " AND quantity = '".$quantity."'"; | |
| 3210 | + $sql .= " AND fk_product = ".$this->id; | |
| 3211 | +        $sql .= " AND entity IN (".getEntity('productsupplierprice').")";
 | |
| 3212 | 3212 | |
| 3213 | 3213 | $resql = $this->db->query($sql); | 
| 3214 | 3214 |          if ($resql) {
 | 
| @@ -3216,7 +3216,7 @@ discard block | ||
| 3216 | 3216 | |
| 3217 | 3217 | // The reference supplier does not exist, we create it for this product. | 
| 3218 | 3218 |              if (!$obj) {
 | 
| 3219 | -                $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price(";
 | |
| 3219 | +                $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price(";
 | |
| 3220 | 3220 | $sql .= "datec"; | 
| 3221 | 3221 | $sql .= ", entity"; | 
| 3222 | 3222 | $sql .= ", fk_product"; | 
| @@ -3226,18 +3226,18 @@ discard block | ||
| 3226 | 3226 | $sql .= ", fk_user"; | 
| 3227 | 3227 | $sql .= ", tva_tx"; | 
| 3228 | 3228 |                  $sql .= ") VALUES (";
 | 
| 3229 | - $sql .= "'" . $this->db->idate($now) . "'"; | |
| 3230 | - $sql .= ", " . $conf->entity; | |
| 3231 | - $sql .= ", " . $this->id; | |
| 3232 | - $sql .= ", " . $id_fourn; | |
| 3233 | - $sql .= ", '" . $this->db->escape($ref_fourn) . "'"; | |
| 3234 | - $sql .= ", " . $quantity; | |
| 3235 | - $sql .= ", " . $user->id; | |
| 3229 | + $sql .= "'".$this->db->idate($now)."'"; | |
| 3230 | + $sql .= ", ".$conf->entity; | |
| 3231 | + $sql .= ", ".$this->id; | |
| 3232 | + $sql .= ", ".$id_fourn; | |
| 3233 | + $sql .= ", '".$this->db->escape($ref_fourn)."'"; | |
| 3234 | + $sql .= ", ".$quantity; | |
| 3235 | + $sql .= ", ".$user->id; | |
| 3236 | 3236 | $sql .= ", 0"; | 
| 3237 | 3237 | $sql .= ")"; | 
| 3238 | 3238 | |
| 3239 | 3239 |                  if ($this->db->query($sql)) {
 | 
| 3240 | - $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX . "product_fournisseur_price"); | |
| 3240 | + $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price"); | |
| 3241 | 3241 | return 1; | 
| 3242 | 3242 |                  } else {
 | 
| 3243 | 3243 | $this->error = $this->db->lasterror(); | 
| @@ -3269,9 +3269,9 @@ discard block | ||
| 3269 | 3269 | $list = array(); | 
| 3270 | 3270 | |
| 3271 | 3271 | $sql = "SELECT DISTINCT p.fk_soc"; | 
| 3272 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_fournisseur_price as p"; | |
| 3273 | - $sql .= " WHERE p.fk_product = " . $this->id; | |
| 3274 | - $sql .= " AND p.entity = " . $conf->entity; | |
| 3272 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as p"; | |
| 3273 | + $sql .= " WHERE p.fk_product = ".$this->id; | |
| 3274 | + $sql .= " AND p.entity = ".$conf->entity; | |
| 3275 | 3275 | |
| 3276 | 3276 | $result = $this->db->query($sql); | 
| 3277 | 3277 |          if ($result) {
 | 
| @@ -3301,13 +3301,13 @@ discard block | ||
| 3301 | 3301 | $this->db->begin(); | 
| 3302 | 3302 | |
| 3303 | 3303 | // les prix | 
| 3304 | -        $sql = "INSERT " . MAIN_DB_PREFIX . "product_price (";
 | |
| 3304 | +        $sql = "INSERT ".MAIN_DB_PREFIX."product_price (";
 | |
| 3305 | 3305 | $sql .= " fk_product, date_price, price, tva_tx, localtax1_tx, localtax2_tx, fk_user_author, tosell)"; | 
| 3306 | - $sql .= " SELECT " . $toId . ", date_price, price, tva_tx, localtax1_tx, localtax2_tx, fk_user_author, tosell"; | |
| 3307 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_price "; | |
| 3308 | - $sql .= " WHERE fk_product = " . $fromId; | |
| 3306 | + $sql .= " SELECT ".$toId.", date_price, price, tva_tx, localtax1_tx, localtax2_tx, fk_user_author, tosell"; | |
| 3307 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_price "; | |
| 3308 | + $sql .= " WHERE fk_product = ".$fromId; | |
| 3309 | 3309 | |
| 3310 | - dol_syslog(get_class($this) . '::clone_price', LOG_DEBUG); | |
| 3310 | + dol_syslog(get_class($this).'::clone_price', LOG_DEBUG); | |
| 3311 | 3311 |          if (!$this->db->query($sql)) {
 | 
| 3312 | 3312 | $this->db->rollback(); | 
| 3313 | 3313 | return -1; | 
| @@ -3329,11 +3329,11 @@ discard block | ||
| 3329 | 3329 | // phpcs:enable | 
| 3330 | 3330 | $this->db->begin(); | 
| 3331 | 3331 | |
| 3332 | - $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'product_association (fk_product_pere, fk_product_fils, qty)'; | |
| 3333 | - $sql .= " SELECT " . $toId . ", fk_product_fils, qty FROM " . MAIN_DB_PREFIX . "product_association"; | |
| 3334 | - $sql .= " WHERE fk_product_pere = " . $fromId; | |
| 3332 | + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association (fk_product_pere, fk_product_fils, qty)'; | |
| 3333 | + $sql .= " SELECT ".$toId.", fk_product_fils, qty FROM ".MAIN_DB_PREFIX."product_association"; | |
| 3334 | + $sql .= " WHERE fk_product_pere = ".$fromId; | |
| 3335 | 3335 | |
| 3336 | - dol_syslog(get_class($this) . '::clone_association', LOG_DEBUG); | |
| 3336 | + dol_syslog(get_class($this).'::clone_association', LOG_DEBUG); | |
| 3337 | 3337 |          if (!$this->db->query($sql)) {
 | 
| 3338 | 3338 | $this->db->rollback(); | 
| 3339 | 3339 | return -1; | 
| @@ -3372,13 +3372,13 @@ discard block | ||
| 3372 | 3372 | } */ | 
| 3373 | 3373 | |
| 3374 | 3374 | // les prix de fournisseurs. | 
| 3375 | -        $sql = "INSERT " . MAIN_DB_PREFIX . "product_fournisseur_price (";
 | |
| 3375 | +        $sql = "INSERT ".MAIN_DB_PREFIX."product_fournisseur_price (";
 | |
| 3376 | 3376 | $sql .= " datec, fk_product, fk_soc, price, quantity, fk_user)"; | 
| 3377 | - $sql .= " SELECT '" . $this->db->idate($now) . "', " . $toId . ", fk_soc, price, quantity, fk_user"; | |
| 3378 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_fournisseur_price"; | |
| 3379 | - $sql .= " WHERE fk_product = " . $fromId; | |
| 3377 | + $sql .= " SELECT '".$this->db->idate($now)."', ".$toId.", fk_soc, price, quantity, fk_user"; | |
| 3378 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; | |
| 3379 | + $sql .= " WHERE fk_product = ".$fromId; | |
| 3380 | 3380 | |
| 3381 | - dol_syslog(get_class($this) . '::clone_fournisseurs', LOG_DEBUG); | |
| 3381 | + dol_syslog(get_class($this).'::clone_fournisseurs', LOG_DEBUG); | |
| 3382 | 3382 | $resql = $this->db->query($sql); | 
| 3383 | 3383 |          if (!$resql) {
 | 
| 3384 | 3384 | $this->db->rollback(); | 
| @@ -3421,8 +3421,8 @@ discard block | ||
| 3421 | 3421 | } | 
| 3422 | 3422 | |
| 3423 | 3423 | //print "XXX We add id=".$id." - label=".$label." - nb=".$nb." - multiply=".$multiply." fullpath=".$compl_path.$label."\n"; | 
| 3424 | - $this->fetch($id); // Load product | |
| 3425 | -                $this->load_stock('nobatch,novirtual');    // Load stock to get true this->stock_reel
 | |
| 3424 | + $this->fetch($id); // Load product | |
| 3425 | +                $this->load_stock('nobatch,novirtual'); // Load stock to get true this->stock_reel
 | |
| 3426 | 3426 | $this->res[] = array( | 
| 3427 | 3427 | 'id' => $id, // Id product | 
| 3428 | 3428 | 'id_parent' => $id_parent, | 
| @@ -3432,7 +3432,7 @@ discard block | ||
| 3432 | 3432 | 'stock' => $this->stock_reel, // Stock | 
| 3433 | 3433 | 'stock_alert' => $this->seuil_stock_alerte, // Stock alert | 
| 3434 | 3434 | 'label' => $label, | 
| 3435 | - 'fullpath' => $compl_path . $label, // Label | |
| 3435 | + 'fullpath' => $compl_path.$label, // Label | |
| 3436 | 3436 | 'type' => $type, // Nb of units that compose parent product | 
| 3437 | 3437 | 'desiredstock' => $this->desiredstock, | 
| 3438 | 3438 | 'level' => $level, | 
| @@ -3443,7 +3443,7 @@ discard block | ||
| 3443 | 3443 | // Recursive call if there is childs to child | 
| 3444 | 3444 |                  if (is_array($desc_pere['childs'])) {
 | 
| 3445 | 3445 | //print 'YYY We go down for '.$desc_pere[3]." -> \n"; | 
| 3446 | - $this->fetch_prod_arbo($desc_pere['childs'], $compl_path . $desc_pere[3] . " -> ", $desc_pere[1] * $multiply, $level + 1, $id); | |
| 3446 | + $this->fetch_prod_arbo($desc_pere['childs'], $compl_path.$desc_pere[3]." -> ", $desc_pere[1] * $multiply, $level + 1, $id); | |
| 3447 | 3447 | } | 
| 3448 | 3448 | } | 
| 3449 | 3449 | } | 
| @@ -3482,8 +3482,8 @@ discard block | ||
| 3482 | 3482 | $nb = 0; | 
| 3483 | 3483 | |
| 3484 | 3484 | $sql = "SELECT COUNT(pa.rowid) as nb"; | 
| 3485 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_association as pa"; | |
| 3486 | - $sql .= " WHERE pa.fk_product_fils = " . $this->id . " OR pa.fk_product_pere = " . $this->id; | |
| 3485 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_association as pa"; | |
| 3486 | + $sql .= " WHERE pa.fk_product_fils = ".$this->id." OR pa.fk_product_pere = ".$this->id; | |
| 3487 | 3487 | $resql = $this->db->query($sql); | 
| 3488 | 3488 |          if ($resql) {
 | 
| 3489 | 3489 | $obj = $this->db->fetch_object($resql); | 
| @@ -3505,8 +3505,8 @@ discard block | ||
| 3505 | 3505 | public function hasVariants() | 
| 3506 | 3506 |      {
 | 
| 3507 | 3507 | $nb = 0; | 
| 3508 | - $sql = "SELECT count(rowid) as nb FROM " . MAIN_DB_PREFIX . "product_attribute_combination WHERE fk_product_parent = " . $this->id; | |
| 3509 | -        $sql .= " AND entity IN (" . getEntity('product') . ")";
 | |
| 3508 | + $sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_parent = ".$this->id; | |
| 3509 | +        $sql .= " AND entity IN (".getEntity('product').")";
 | |
| 3510 | 3510 | |
| 3511 | 3511 | $resql = $this->db->query($sql); | 
| 3512 | 3512 |          if ($resql) {
 | 
| @@ -3528,7 +3528,7 @@ discard block | ||
| 3528 | 3528 |      {
 | 
| 3529 | 3529 | global $conf; | 
| 3530 | 3530 |          if (!empty($conf->variants->enabled)) {
 | 
| 3531 | -            $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "product_attribute_combination WHERE fk_product_child = " . $this->id . " AND entity IN (" . getEntity('product') . ")";
 | |
| 3531 | +            $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_child = ".$this->id." AND entity IN (".getEntity('product').")";
 | |
| 3532 | 3532 | |
| 3533 | 3533 | $query = $this->db->query($sql); | 
| 3534 | 3534 | |
| @@ -3554,10 +3554,10 @@ discard block | ||
| 3554 | 3554 | public function getFather() | 
| 3555 | 3555 |      {
 | 
| 3556 | 3556 | $sql = "SELECT p.rowid, p.label as label, p.ref as ref, pa.fk_product_pere as id, p.fk_product_type, pa.qty, pa.incdec, p.entity"; | 
| 3557 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_association as pa,"; | |
| 3558 | - $sql .= " " . MAIN_DB_PREFIX . "product as p"; | |
| 3557 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_association as pa,"; | |
| 3558 | + $sql .= " ".MAIN_DB_PREFIX."product as p"; | |
| 3559 | 3559 | $sql .= " WHERE p.rowid = pa.fk_product_pere"; | 
| 3560 | - $sql .= " AND pa.fk_product_fils = " . $this->id; | |
| 3560 | + $sql .= " AND pa.fk_product_fils = ".$this->id; | |
| 3561 | 3561 | |
| 3562 | 3562 | $res = $this->db->query($sql); | 
| 3563 | 3563 |          if ($res) {
 | 
| @@ -3592,16 +3592,16 @@ discard block | ||
| 3592 | 3592 | global $alreadyfound; | 
| 3593 | 3593 | |
| 3594 | 3594 | $sql = "SELECT p.rowid, p.label as label, pa.qty as qty, pa.fk_product_fils as id, p.fk_product_type, pa.incdec"; | 
| 3595 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product as p"; | |
| 3596 | - $sql .= ", " . MAIN_DB_PREFIX . "product_association as pa"; | |
| 3595 | + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; | |
| 3596 | + $sql .= ", ".MAIN_DB_PREFIX."product_association as pa"; | |
| 3597 | 3597 | $sql .= " WHERE p.rowid = pa.fk_product_fils"; | 
| 3598 | - $sql .= " AND pa.fk_product_pere = " . $id; | |
| 3599 | - $sql .= " AND pa.fk_product_fils != " . $id; // This should not happens, it is to avoid infinite loop if it happens | |
| 3598 | + $sql .= " AND pa.fk_product_pere = ".$id; | |
| 3599 | + $sql .= " AND pa.fk_product_fils != ".$id; // This should not happens, it is to avoid infinite loop if it happens | |
| 3600 | 3600 | |
| 3601 | - dol_syslog(get_class($this) . '::getChildsArbo id=' . $id . ' level=' . $level, LOG_DEBUG); | |
| 3601 | + dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level, LOG_DEBUG); | |
| 3602 | 3602 | |
| 3603 | 3603 |          if ($level == 1) {
 | 
| 3604 | - $alreadyfound = array($id => 1); // We init array of found object to start of tree, so if we found it later (should not happened), we stop immediatly | |
| 3604 | + $alreadyfound = array($id => 1); // We init array of found object to start of tree, so if we found it later (should not happened), we stop immediatly | |
| 3605 | 3605 | } | 
| 3606 | 3606 | // Protection against infinite loop | 
| 3607 | 3607 |          if ($level > 30) {
 | 
| @@ -3613,7 +3613,7 @@ discard block | ||
| 3613 | 3613 | $prods = array(); | 
| 3614 | 3614 |              while ($rec = $this->db->fetch_array($res)) {
 | 
| 3615 | 3615 |                  if (!empty($alreadyfound[$rec['rowid']])) {
 | 
| 3616 | - dol_syslog(get_class($this) . '::getChildsArbo the product id=' . $rec['rowid'] . ' was already found at a higher level in tree. We discard to avoid infinite loop', LOG_WARNING); | |
| 3616 | + dol_syslog(get_class($this).'::getChildsArbo the product id='.$rec['rowid'].' was already found at a higher level in tree. We discard to avoid infinite loop', LOG_WARNING); | |
| 3617 | 3617 | continue; | 
| 3618 | 3618 | } | 
| 3619 | 3619 | $alreadyfound[$rec['rowid']] = 1; | 
| @@ -3676,7 +3676,7 @@ discard block | ||
| 3676 | 3676 | global $conf, $langs, $hookmanager; | 
| 3677 | 3677 | |
| 3678 | 3678 | // include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; | 
| 3679 | - include_once DOL_BASE_PATH . '/core/lib/product.lib.php'; | |
| 3679 | + include_once DOL_BASE_PATH.'/core/lib/product.lib.php'; | |
| 3680 | 3680 | |
| 3681 | 3681 | $result = ''; | 
| 3682 | 3682 | $newref = $this->ref; | 
| @@ -3685,37 +3685,37 @@ discard block | ||
| 3685 | 3685 | } | 
| 3686 | 3686 | |
| 3687 | 3687 |          if ($this->type == Product::TYPE_PRODUCT) {
 | 
| 3688 | -            $label = '<u>' . $langs->trans("ShowProduct") . '</u>';
 | |
| 3688 | +            $label = '<u>'.$langs->trans("ShowProduct").'</u>';
 | |
| 3689 | 3689 | } | 
| 3690 | 3690 |          if ($this->type == Product::TYPE_SERVICE) {
 | 
| 3691 | -            $label = '<u>' . $langs->trans("ShowService") . '</u>';
 | |
| 3691 | +            $label = '<u>'.$langs->trans("ShowService").'</u>';
 | |
| 3692 | 3692 | } | 
| 3693 | 3693 |          if (!empty($this->ref)) {
 | 
| 3694 | -            $label .= '<br><b>' . $langs->trans('ProductRef') . ':</b> ' . $this->ref;
 | |
| 3694 | +            $label .= '<br><b>'.$langs->trans('ProductRef').':</b> '.$this->ref;
 | |
| 3695 | 3695 | } | 
| 3696 | 3696 |          if (!empty($this->label)) {
 | 
| 3697 | -            $label .= '<br><b>' . $langs->trans('ProductLabel') . ':</b> ' . $this->label;
 | |
| 3697 | +            $label .= '<br><b>'.$langs->trans('ProductLabel').':</b> '.$this->label;
 | |
| 3698 | 3698 | } | 
| 3699 | 3699 | |
| 3700 | 3700 |          if ($this->type == Product::TYPE_PRODUCT) {
 | 
| 3701 | 3701 |              if ($this->weight) {
 | 
| 3702 | -                $label .= "<br><b>" . $langs->trans("Weight") . '</b>: ' . $this->weight . ' ' . measuring_units_string($this->weight_units, "weight");
 | |
| 3702 | +                $label .= "<br><b>".$langs->trans("Weight").'</b>: '.$this->weight.' '.measuring_units_string($this->weight_units, "weight");
 | |
| 3703 | 3703 | } | 
| 3704 | 3704 |              if ($this->length) {
 | 
| 3705 | -                $label .= "<br><b>" . $langs->trans("Length") . '</b>: ' . $this->length . ' ' . measuring_units_string($this->length_units, 'length');
 | |
| 3705 | +                $label .= "<br><b>".$langs->trans("Length").'</b>: '.$this->length.' '.measuring_units_string($this->length_units, 'length');
 | |
| 3706 | 3706 | } | 
| 3707 | 3707 |              if ($this->surface) {
 | 
| 3708 | -                $label .= "<br><b>" . $langs->trans("Surface") . '</b>: ' . $this->surface . ' ' . measuring_units_string($this->surface_units, 'surface');
 | |
| 3708 | +                $label .= "<br><b>".$langs->trans("Surface").'</b>: '.$this->surface.' '.measuring_units_string($this->surface_units, 'surface');
 | |
| 3709 | 3709 | } | 
| 3710 | 3710 |              if ($this->volume) {
 | 
| 3711 | -                $label .= "<br><b>" . $langs->trans("Volume") . '</b>: ' . $this->volume . ' ' . measuring_units_string($this->volume_units, 'volume');
 | |
| 3711 | +                $label .= "<br><b>".$langs->trans("Volume").'</b>: '.$this->volume.' '.measuring_units_string($this->volume_units, 'volume');
 | |
| 3712 | 3712 | } | 
| 3713 | 3713 | } | 
| 3714 | 3714 | |
| 3715 | 3715 |          if ($this->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
 | 
| 3716 | 3716 |              if (!empty($conf->productbatch->enabled)) {
 | 
| 3717 | 3717 |                  $langs->load("productbatch");
 | 
| 3718 | -                $label .= "<br><b>" . $langs->trans("ManageLotSerial") . '</b>: ' . $this->getLibStatut(0, 2);
 | |
| 3718 | +                $label .= "<br><b>".$langs->trans("ManageLotSerial").'</b>: '.$this->getLibStatut(0, 2);
 | |
| 3719 | 3719 | } | 
| 3720 | 3720 | } | 
| 3721 | 3721 | //if ($this->type == Product::TYPE_SERVICE) | 
| @@ -3723,19 +3723,19 @@ discard block | ||
| 3723 | 3723 | // | 
| 3724 | 3724 | //} | 
| 3725 | 3725 |          if (!empty($conf->accounting->enabled) && $this->status) {
 | 
| 3726 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; | |
| 3727 | -            $label .= '<br><b>' . $langs->trans('ProductAccountancySellCode') . ':</b> ' . length_accountg($this->accountancy_code_sell);
 | |
| 3728 | -            $label .= '<br><b>' . $langs->trans('ProductAccountancySellIntraCode') . ':</b> ' . length_accountg($this->accountancy_code_sell_export);
 | |
| 3729 | -            $label .= '<br><b>' . $langs->trans('ProductAccountancySellExportCode') . ':</b> ' . length_accountg($this->accountancy_code_sell_intra);
 | |
| 3726 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; | |
| 3727 | +            $label .= '<br><b>'.$langs->trans('ProductAccountancySellCode').':</b> '.length_accountg($this->accountancy_code_sell);
 | |
| 3728 | +            $label .= '<br><b>'.$langs->trans('ProductAccountancySellIntraCode').':</b> '.length_accountg($this->accountancy_code_sell_export);
 | |
| 3729 | +            $label .= '<br><b>'.$langs->trans('ProductAccountancySellExportCode').':</b> '.length_accountg($this->accountancy_code_sell_intra);
 | |
| 3730 | 3730 | } | 
| 3731 | 3731 |          if (!empty($conf->accounting->enabled) && $this->status_buy) {
 | 
| 3732 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; | |
| 3733 | -            $label .= '<br><b>' . $langs->trans('ProductAccountancyBuyCode') . ':</b> ' . length_accountg($this->accountancy_code_buy);
 | |
| 3732 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; | |
| 3733 | +            $label .= '<br><b>'.$langs->trans('ProductAccountancyBuyCode').':</b> '.length_accountg($this->accountancy_code_buy);
 | |
| 3734 | 3734 | } | 
| 3735 | 3735 |          if (!empty($this->entity)) {
 | 
| 3736 | 3736 |              $tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80);
 | 
| 3737 | 3737 |              if ($this->nbphoto > 0) {
 | 
| 3738 | - $label .= '<br>' . $tmpphoto; | |
| 3738 | + $label .= '<br>'.$tmpphoto; | |
| 3739 | 3739 | } | 
| 3740 | 3740 | } | 
| 3741 | 3741 | |
| @@ -3743,10 +3743,10 @@ discard block | ||
| 3743 | 3743 |          if (empty($notooltip)) {
 | 
| 3744 | 3744 |              if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
 | 
| 3745 | 3745 |                  $label = $langs->trans("ShowProduct");
 | 
| 3746 | - $linkclose .= ' alt="' . dol_escape_htmltag($label, 1) . '"'; | |
| 3746 | + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; | |
| 3747 | 3747 | } | 
| 3748 | 3748 | |
| 3749 | - $linkclose .= ' title="' . dol_escape_htmltag($label, 1, 1) . '"'; | |
| 3749 | + $linkclose .= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; | |
| 3750 | 3750 | $linkclose .= ' class="classfortooltip"'; | 
| 3751 | 3751 | |
| 3752 | 3752 | /* | 
| @@ -3759,16 +3759,16 @@ discard block | ||
| 3759 | 3759 | |
| 3760 | 3760 |          if ($option == 'supplier' || $option == 'category') {
 | 
| 3761 | 3761 | // $url = DOL_URL_ROOT . '/product/fournisseurs.php?id=' . $this->id; | 
| 3762 | - $url = BASE_URI . '?controller=product&method=fournisseurs&id=' . $this->id; | |
| 3762 | + $url = BASE_URI.'?controller=product&method=fournisseurs&id='.$this->id; | |
| 3763 | 3763 |          } else if ($option == 'stock') {
 | 
| 3764 | 3764 | // $url = DOL_URL_ROOT . '/product/stock/product.php?id=' . $this->id; | 
| 3765 | - $url = BASE_URI . '?controller/stock=product&method=product&id=' . $this->id; | |
| 3765 | + $url = BASE_URI.'?controller/stock=product&method=product&id='.$this->id; | |
| 3766 | 3766 |          } else if ($option == 'composition') {
 | 
| 3767 | 3767 | // $url = DOL_URL_ROOT . '/product/composition/card.php?id=' . $this->id; | 
| 3768 | - $url = BASE_URI . '?controller=product/composition&method=card&id=' . $this->id; | |
| 3768 | + $url = BASE_URI.'?controller=product/composition&method=card&id='.$this->id; | |
| 3769 | 3769 |          } else {
 | 
| 3770 | 3770 | // $url = DOL_URL_ROOT . '/product/card.php?id=' . $this->id; | 
| 3771 | - $url = BASE_URI . '?controller=product&method=card&id=' . $this->id; | |
| 3771 | + $url = BASE_URI.'?controller=product&method=card&id='.$this->id; | |
| 3772 | 3772 | } | 
| 3773 | 3773 | |
| 3774 | 3774 |          if ($option !== 'nolink') {
 | 
| @@ -3782,8 +3782,8 @@ discard block | ||
| 3782 | 3782 | } | 
| 3783 | 3783 | } | 
| 3784 | 3784 | |
| 3785 | - $linkstart = '<a href="' . $url . '"'; | |
| 3786 | - $linkstart .= $linkclose . '>'; | |
| 3785 | + $linkstart = '<a href="'.$url.'"'; | |
| 3786 | + $linkstart .= $linkclose.'>'; | |
| 3787 | 3787 | $linkend = '</a>'; | 
| 3788 | 3788 | |
| 3789 | 3789 | $result .= $linkstart; | 
| @@ -3801,7 +3801,7 @@ discard block | ||
| 3801 | 3801 | global $action; | 
| 3802 | 3802 |          $hookmanager->initHooks(array('productdao'));
 | 
| 3803 | 3803 |          $parameters = array('id' => $this->id, 'getnomurl' => $result);
 | 
| 3804 | -        $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
 | |
| 3804 | +        $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 | |
| 3805 | 3805 |          if ($reshook > 0) {
 | 
| 3806 | 3806 | $result = $hookmanager->resPrint; | 
| 3807 | 3807 |          } else {
 | 
| @@ -3889,16 +3889,16 @@ discard block | ||
| 3889 | 3889 | case 1: | 
| 3890 | 3890 |                      return ($status == 0 ? $langs->trans('ProductStatusNotOnBatchShort') : $langs->trans('ProductStatusOnBatchShort'));
 | 
| 3891 | 3891 | case 2: | 
| 3892 | - return $this->LibStatut($status, 3, 2) . ' ' . $this->LibStatut($status, 1, 2); | |
| 3892 | + return $this->LibStatut($status, 3, 2).' '.$this->LibStatut($status, 1, 2); | |
| 3893 | 3893 | case 3: | 
| 3894 | 3894 |                      if ($status == 0) {
 | 
| 3895 | 3895 |                          return img_picto($langs->trans('ProductStatusNotOnBatch'), 'statut5');
 | 
| 3896 | 3896 | } | 
| 3897 | 3897 |                      return img_picto($langs->trans('ProductStatusOnBatch'), 'statut4');
 | 
| 3898 | 3898 | case 4: | 
| 3899 | - return $this->LibStatut($status, 3, 2) . ' ' . $this->LibStatut($status, 0, 2); | |
| 3899 | + return $this->LibStatut($status, 3, 2).' '.$this->LibStatut($status, 0, 2); | |
| 3900 | 3900 | case 5: | 
| 3901 | - return $this->LibStatut($status, 1, 2) . ' ' . $this->LibStatut($status, 3, 2); | |
| 3901 | + return $this->LibStatut($status, 1, 2).' '.$this->LibStatut($status, 3, 2); | |
| 3902 | 3902 | default: | 
| 3903 | 3903 |                      return $langs->trans('Unknown');
 | 
| 3904 | 3904 | } | 
| @@ -3917,9 +3917,9 @@ discard block | ||
| 3917 | 3917 | } | 
| 3918 | 3918 |          } elseif ($mode == 2) {
 | 
| 3919 | 3919 |              if ($status == 0) {
 | 
| 3920 | -                return img_picto($langs->trans('ProductStatusNotOnSell'), 'statut5', 'class="pictostatus"') . ' ' . ($type == 0 ? $langs->trans('ProductStatusNotOnSellShort') : $langs->trans('ProductStatusNotOnBuyShort'));
 | |
| 3920 | +                return img_picto($langs->trans('ProductStatusNotOnSell'), 'statut5', 'class="pictostatus"').' '.($type == 0 ? $langs->trans('ProductStatusNotOnSellShort') : $langs->trans('ProductStatusNotOnBuyShort'));
 | |
| 3921 | 3921 |              } elseif ($status == 1) {
 | 
| 3922 | -                return img_picto($langs->trans('ProductStatusOnSell'), 'statut4', 'class="pictostatus"') . ' ' . ($type == 0 ? $langs->trans('ProductStatusOnSellShort') : $langs->trans('ProductStatusOnBuyShort'));
 | |
| 3922 | +                return img_picto($langs->trans('ProductStatusOnSell'), 'statut4', 'class="pictostatus"').' '.($type == 0 ? $langs->trans('ProductStatusOnSellShort') : $langs->trans('ProductStatusOnBuyShort'));
 | |
| 3923 | 3923 | } | 
| 3924 | 3924 |          } elseif ($mode == 3) {
 | 
| 3925 | 3925 |              if ($status == 0) {
 | 
| @@ -3929,21 +3929,21 @@ discard block | ||
| 3929 | 3929 | } | 
| 3930 | 3930 |          } elseif ($mode == 4) {
 | 
| 3931 | 3931 |              if ($status == 0) {
 | 
| 3932 | -                return img_picto($langs->trans('ProductStatusNotOnSell'), 'statut5', 'class="pictostatus"') . ' ' . ($type == 0 ? $langs->trans('ProductStatusNotOnSell') : $langs->trans('ProductStatusNotOnBuy'));
 | |
| 3932 | +                return img_picto($langs->trans('ProductStatusNotOnSell'), 'statut5', 'class="pictostatus"').' '.($type == 0 ? $langs->trans('ProductStatusNotOnSell') : $langs->trans('ProductStatusNotOnBuy'));
 | |
| 3933 | 3933 |              } elseif ($status == 1) {
 | 
| 3934 | -                return img_picto($langs->trans('ProductStatusOnSell'), 'statut4', 'class="pictostatus"') . ' ' . ($type == 0 ? $langs->trans('ProductStatusOnSell') : $langs->trans('ProductStatusOnBuy'));
 | |
| 3934 | +                return img_picto($langs->trans('ProductStatusOnSell'), 'statut4', 'class="pictostatus"').' '.($type == 0 ? $langs->trans('ProductStatusOnSell') : $langs->trans('ProductStatusOnBuy'));
 | |
| 3935 | 3935 | } | 
| 3936 | 3936 |          } elseif ($mode == 5) {
 | 
| 3937 | 3937 |              if ($status == 0) {
 | 
| 3938 | -                return ($type == 0 ? $langs->trans('ProductStatusNotOnSellShort') : $langs->trans('ProductStatusNotOnBuyShort')) . ' ' . img_picto(($type == 0 ? $langs->trans('ProductStatusNotOnSell') : $langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"');
 | |
| 3938 | +                return ($type == 0 ? $langs->trans('ProductStatusNotOnSellShort') : $langs->trans('ProductStatusNotOnBuyShort')).' '.img_picto(($type == 0 ? $langs->trans('ProductStatusNotOnSell') : $langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"');
 | |
| 3939 | 3939 |              } elseif ($status == 1) {
 | 
| 3940 | -                return ($type == 0 ? $langs->trans('ProductStatusOnSellShort') : $langs->trans('ProductStatusOnBuyShort')) . ' ' . img_picto(($type == 0 ? $langs->trans('ProductStatusOnSell') : $langs->trans('ProductStatusOnBuy')), 'statut4', 'class="pictostatus"');
 | |
| 3940 | +                return ($type == 0 ? $langs->trans('ProductStatusOnSellShort') : $langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type == 0 ? $langs->trans('ProductStatusOnSell') : $langs->trans('ProductStatusOnBuy')), 'statut4', 'class="pictostatus"');
 | |
| 3941 | 3941 | } | 
| 3942 | 3942 |          } elseif ($mode == 6) {
 | 
| 3943 | 3943 |              if ($status == 0) {
 | 
| 3944 | -                return ($type == 0 ? $langs->trans('ProductStatusNotOnSellShort') : $langs->trans('ProductStatusNotOnBuyShort')) . ' ' . img_picto(($type == 0 ? $langs->trans('ProductStatusNotOnSell') : $langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"');
 | |
| 3944 | +                return ($type == 0 ? $langs->trans('ProductStatusNotOnSellShort') : $langs->trans('ProductStatusNotOnBuyShort')).' '.img_picto(($type == 0 ? $langs->trans('ProductStatusNotOnSell') : $langs->trans('ProductStatusNotOnBuy')), 'statut5', 'class="pictostatus"');
 | |
| 3945 | 3945 |              } elseif ($status == 1) {
 | 
| 3946 | -                return ($type == 0 ? $langs->trans('ProductStatusOnSellShort') : $langs->trans('ProductStatusOnBuyShort')) . ' ' . img_picto(($type == 0 ? $langs->trans('ProductStatusOnSell') : $langs->trans('ProductStatusOnBuy')), 'statut4', 'class="pictostatus"');
 | |
| 3946 | +                return ($type == 0 ? $langs->trans('ProductStatusOnSellShort') : $langs->trans('ProductStatusOnBuyShort')).' '.img_picto(($type == 0 ? $langs->trans('ProductStatusOnSell') : $langs->trans('ProductStatusOnBuy')), 'statut4', 'class="pictostatus"');
 | |
| 3947 | 3947 | } | 
| 3948 | 3948 | } | 
| 3949 | 3949 |          return $langs->trans('Unknown');
 | 
| @@ -3989,10 +3989,10 @@ discard block | ||
| 3989 | 3989 |          if ($id_entrepot) {
 | 
| 3990 | 3990 | $this->db->begin(); | 
| 3991 | 3991 | |
| 3992 | - include_once DOL_DOCUMENT_ROOT . '/product/stock/class/mouvementstock.class.php'; | |
| 3992 | + include_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; | |
| 3993 | 3993 | |
| 3994 | - $op[0] = "+" . trim($nbpiece); | |
| 3995 | - $op[1] = "-" . trim($nbpiece); | |
| 3994 | + $op[0] = "+".trim($nbpiece); | |
| 3995 | + $op[1] = "-".trim($nbpiece); | |
| 3996 | 3996 | |
| 3997 | 3997 | $movementstock = new MouvementStock($this->db); | 
| 3998 | 3998 | $movementstock->setOrigin($origin_element, $origin_id); | 
| @@ -4035,10 +4035,10 @@ discard block | ||
| 4035 | 4035 |          if ($id_entrepot) {
 | 
| 4036 | 4036 | $this->db->begin(); | 
| 4037 | 4037 | |
| 4038 | - include_once DOL_DOCUMENT_ROOT . '/product/stock/class/mouvementstock.class.php'; | |
| 4038 | + include_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; | |
| 4039 | 4039 | |
| 4040 | - $op[0] = "+" . trim($nbpiece); | |
| 4041 | - $op[1] = "-" . trim($nbpiece); | |
| 4040 | + $op[0] = "+".trim($nbpiece); | |
| 4041 | + $op[1] = "-".trim($nbpiece); | |
| 4042 | 4042 | |
| 4043 | 4043 | $movementstock = new MouvementStock($this->db); | 
| 4044 | 4044 | $movementstock->setOrigin($origin_element, $origin_id); | 
| @@ -4089,16 +4089,16 @@ discard block | ||
| 4089 | 4089 | } | 
| 4090 | 4090 | |
| 4091 | 4091 | $sql = "SELECT ps.rowid, ps.reel, ps.fk_entrepot"; | 
| 4092 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_stock as ps"; | |
| 4093 | - $sql .= ", " . MAIN_DB_PREFIX . "entrepot as w"; | |
| 4094 | -        $sql .= " WHERE w.entity IN (" . getEntity('stock') . ")";
 | |
| 4092 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps"; | |
| 4093 | + $sql .= ", ".MAIN_DB_PREFIX."entrepot as w"; | |
| 4094 | +        $sql .= " WHERE w.entity IN (".getEntity('stock').")";
 | |
| 4095 | 4095 | $sql .= " AND w.rowid = ps.fk_entrepot"; | 
| 4096 | - $sql .= " AND ps.fk_product = " . $this->id; | |
| 4096 | + $sql .= " AND ps.fk_product = ".$this->id; | |
| 4097 | 4097 |          if ($conf->global->ENTREPOT_EXTRA_STATUS && count($warehouseStatus)) {
 | 
| 4098 | -            $sql .= " AND w.statut IN (" . $this->db->escape(implode(',', $warehouseStatus)) . ")";
 | |
| 4098 | +            $sql .= " AND w.statut IN (".$this->db->escape(implode(',', $warehouseStatus)).")";
 | |
| 4099 | 4099 | } | 
| 4100 | 4100 | |
| 4101 | - dol_syslog(get_class($this) . "::load_stock", LOG_DEBUG); | |
| 4101 | + dol_syslog(get_class($this)."::load_stock", LOG_DEBUG); | |
| 4102 | 4102 | $result = $this->db->query($sql); | 
| 4103 | 4103 |          if ($result) {
 | 
| 4104 | 4104 | $num = $this->db->num_rows($result); | 
| @@ -4119,7 +4119,7 @@ discard block | ||
| 4119 | 4119 | $this->db->free($result); | 
| 4120 | 4120 | |
| 4121 | 4121 |              if (!preg_match('/novirtual/', $option)) {
 | 
| 4122 | - $this->load_virtual_stock(); // This also load stats_commande_fournisseur, ... | |
| 4122 | + $this->load_virtual_stock(); // This also load stats_commande_fournisseur, ... | |
| 4123 | 4123 | } | 
| 4124 | 4124 | |
| 4125 | 4125 | return 1; | 
| @@ -4196,7 +4196,7 @@ discard block | ||
| 4196 | 4196 | } | 
| 4197 | 4197 | |
| 4198 | 4198 |          if (!is_object($hookmanager)) {
 | 
| 4199 | - include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; | |
| 4199 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; | |
| 4200 | 4200 | $hookmanager = new HookManager($this->db); | 
| 4201 | 4201 | } | 
| 4202 | 4202 |          $hookmanager->initHooks(array('productdao'));
 | 
| @@ -4220,10 +4220,10 @@ discard block | ||
| 4220 | 4220 |      {
 | 
| 4221 | 4221 | $result = array(); | 
| 4222 | 4222 | |
| 4223 | - $sql = "SELECT pb.batch, pb.eatby, pb.sellby, SUM(pb.qty) FROM " . MAIN_DB_PREFIX . "product_batch as pb, " . MAIN_DB_PREFIX . "product_stock as ps"; | |
| 4224 | - $sql .= " WHERE pb.fk_product_stock = ps.rowid AND ps.fk_product = " . $this->id . " AND pb.batch = '" . $this->db->escape($batch) . "'"; | |
| 4223 | + $sql = "SELECT pb.batch, pb.eatby, pb.sellby, SUM(pb.qty) FROM ".MAIN_DB_PREFIX."product_batch as pb, ".MAIN_DB_PREFIX."product_stock as ps"; | |
| 4224 | + $sql .= " WHERE pb.fk_product_stock = ps.rowid AND ps.fk_product = ".$this->id." AND pb.batch = '".$this->db->escape($batch)."'"; | |
| 4225 | 4225 | $sql .= " GROUP BY pb.batch, pb.eatby, pb.sellby"; | 
| 4226 | - dol_syslog(get_class($this) . "::loadBatchInfo load first entry found for lot/serial = " . $batch, LOG_DEBUG); | |
| 4226 | + dol_syslog(get_class($this)."::loadBatchInfo load first entry found for lot/serial = ".$batch, LOG_DEBUG); | |
| 4227 | 4227 | $resql = $this->db->query($sql); | 
| 4228 | 4228 |          if ($resql) {
 | 
| 4229 | 4229 | $num = $this->db->num_rows($resql); | 
| @@ -4254,15 +4254,15 @@ discard block | ||
| 4254 | 4254 | // phpcs:enable | 
| 4255 | 4255 | global $conf; | 
| 4256 | 4256 | |
| 4257 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; | |
| 4257 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; | |
| 4258 | 4258 | |
| 4259 | 4259 | $result = 0; | 
| 4260 | 4260 | |
| 4261 | 4261 | $dir = $sdir; | 
| 4262 | 4262 |          if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
 | 
| 4263 | - $dir .= '/' . get_exdir($this->id, 2, 0, 0, $this, 'product') . $this->id . "/photos"; | |
| 4263 | + $dir .= '/'.get_exdir($this->id, 2, 0, 0, $this, 'product').$this->id."/photos"; | |
| 4264 | 4264 |          } else {
 | 
| 4265 | - $dir .= '/' . get_exdir(0, 0, 0, 0, $this, 'product') . dol_sanitizeFileName($this->ref); | |
| 4265 | + $dir .= '/'.get_exdir(0, 0, 0, 0, $this, 'product').dol_sanitizeFileName($this->ref); | |
| 4266 | 4266 | } | 
| 4267 | 4267 | |
| 4268 | 4268 | dol_mkdir($dir); | 
| @@ -4270,7 +4270,7 @@ discard block | ||
| 4270 | 4270 | $dir_osencoded = $dir; | 
| 4271 | 4271 | |
| 4272 | 4272 |          if (is_dir($dir_osencoded)) {
 | 
| 4273 | - $originImage = $dir . '/' . $file['name']; | |
| 4273 | + $originImage = $dir.'/'.$file['name']; | |
| 4274 | 4274 | |
| 4275 | 4275 | // Cree fichier en taille origine | 
| 4276 | 4276 | $result = dol_move_uploaded_file($file['tmp_name'], $originImage, 1); | 
| @@ -4298,16 +4298,16 @@ discard block | ||
| 4298 | 4298 | function is_photo_available($sdir) | 
| 4299 | 4299 |      {
 | 
| 4300 | 4300 | // phpcs:enable | 
| 4301 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; | |
| 4302 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; | |
| 4301 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; | |
| 4302 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; | |
| 4303 | 4303 | |
| 4304 | 4304 | global $conf; | 
| 4305 | 4305 | |
| 4306 | 4306 | $dir = $sdir; | 
| 4307 | 4307 |          if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
 | 
| 4308 | - $dir .= '/' . get_exdir($this->id, 2, 0, 0, $this, 'product') . $this->id . "/photos/"; | |
| 4308 | + $dir .= '/'.get_exdir($this->id, 2, 0, 0, $this, 'product').$this->id."/photos/"; | |
| 4309 | 4309 |          } else {
 | 
| 4310 | - $dir .= '/' . get_exdir(0, 0, 0, 0, $this, 'product') . dol_sanitizeFileName($this->ref) . '/'; | |
| 4310 | + $dir .= '/'.get_exdir(0, 0, 0, 0, $this, 'product').dol_sanitizeFileName($this->ref).'/'; | |
| 4311 | 4311 | } | 
| 4312 | 4312 | |
| 4313 | 4313 | $nbphoto = 0; | 
| @@ -4318,9 +4318,9 @@ discard block | ||
| 4318 | 4318 |              if (is_resource($handle)) {
 | 
| 4319 | 4319 |                  while (($file = readdir($handle)) !== false) {
 | 
| 4320 | 4320 |                      if (!utf8_check($file)) {
 | 
| 4321 | - $file = utf8_encode($file); // To be sure data is stored in UTF8 in memory | |
| 4321 | + $file = utf8_encode($file); // To be sure data is stored in UTF8 in memory | |
| 4322 | 4322 | } | 
| 4323 | -                    if (dol_is_file($dir . $file) && image_format_supported($file) > 0) {
 | |
| 4323 | +                    if (dol_is_file($dir.$file) && image_format_supported($file) > 0) {
 | |
| 4324 | 4324 | return true; | 
| 4325 | 4325 | } | 
| 4326 | 4326 | } | 
| @@ -4340,8 +4340,8 @@ discard block | ||
| 4340 | 4340 | function liste_photos($dir, $nbmax = 0) | 
| 4341 | 4341 |      {
 | 
| 4342 | 4342 | // phpcs:enable | 
| 4343 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; | |
| 4344 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; | |
| 4343 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; | |
| 4344 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; | |
| 4345 | 4345 | |
| 4346 | 4346 | $nbphoto = 0; | 
| 4347 | 4347 | $tabobj = array(); | 
| @@ -4351,25 +4351,25 @@ discard block | ||
| 4351 | 4351 |          if (is_resource($handle)) {
 | 
| 4352 | 4352 |              while (($file = readdir($handle)) !== false) {
 | 
| 4353 | 4353 |                  if (!utf8_check($file)) {
 | 
| 4354 | - $file = utf8_encode($file); // readdir returns ISO | |
| 4354 | + $file = utf8_encode($file); // readdir returns ISO | |
| 4355 | 4355 | } | 
| 4356 | -                if (dol_is_file($dir . $file) && image_format_supported($file) >= 0) {
 | |
| 4356 | +                if (dol_is_file($dir.$file) && image_format_supported($file) >= 0) {
 | |
| 4357 | 4357 | $nbphoto++; | 
| 4358 | 4358 | |
| 4359 | 4359 | // On determine nom du fichier vignette | 
| 4360 | 4360 | $photo = $file; | 
| 4361 | 4361 | $photo_vignette = ''; | 
| 4362 | -                    if (preg_match('/(' . $this->regeximgext . ')$/i', $photo, $regs)) {
 | |
| 4363 | -                        $photo_vignette = preg_replace('/' . $regs[0] . '/i', '', $photo) . '_small' . $regs[0];
 | |
| 4362 | +                    if (preg_match('/('.$this->regeximgext.')$/i', $photo, $regs)) {
 | |
| 4363 | +                        $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $photo).'_small'.$regs[0];
 | |
| 4364 | 4364 | } | 
| 4365 | 4365 | |
| 4366 | - $dirthumb = $dir . 'thumbs/'; | |
| 4366 | + $dirthumb = $dir.'thumbs/'; | |
| 4367 | 4367 | |
| 4368 | 4368 | // Objet | 
| 4369 | 4369 | $obj = array(); | 
| 4370 | 4370 | $obj['photo'] = $photo; | 
| 4371 | -                    if ($photo_vignette && dol_is_file($dirthumb . $photo_vignette)) {
 | |
| 4372 | - $obj['photo_vignette'] = 'thumbs/' . $photo_vignette; | |
| 4371 | +                    if ($photo_vignette && dol_is_file($dirthumb.$photo_vignette)) {
 | |
| 4372 | + $obj['photo_vignette'] = 'thumbs/'.$photo_vignette; | |
| 4373 | 4373 |                      } else {
 | 
| 4374 | 4374 | $obj['photo_vignette'] = ""; | 
| 4375 | 4375 | } | 
| @@ -4399,24 +4399,24 @@ discard block | ||
| 4399 | 4399 | function delete_photo($file) | 
| 4400 | 4400 |      {
 | 
| 4401 | 4401 | // phpcs:enable | 
| 4402 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; | |
| 4403 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; | |
| 4402 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; | |
| 4403 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; | |
| 4404 | 4404 | |
| 4405 | - $dir = dirname($file) . '/'; // Chemin du dossier contenant l'image d'origine | |
| 4406 | - $dirthumb = $dir . '/thumbs/'; // Chemin du dossier contenant la vignette | |
| 4407 | -        $filename = preg_replace('/' . preg_quote($dir, '/') . '/i', '', $file); // Nom du fichier
 | |
| 4405 | + $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine | |
| 4406 | + $dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette | |
| 4407 | +        $filename = preg_replace('/'.preg_quote($dir, '/').'/i', '', $file); // Nom du fichier
 | |
| 4408 | 4408 | // On efface l'image d'origine | 
| 4409 | 4409 | dol_delete_file($file, 0, 0, 0, $this); // For triggers | 
| 4410 | 4410 | // Si elle existe, on efface la vignette | 
| 4411 | -        if (preg_match('/(' . $this->regeximgext . ')$/i', $filename, $regs)) {
 | |
| 4412 | -            $photo_vignette = preg_replace('/' . $regs[0] . '/i', '', $filename) . '_small' . $regs[0];
 | |
| 4413 | -            if (file_exists(dol_osencode($dirthumb . $photo_vignette))) {
 | |
| 4414 | - dol_delete_file($dirthumb . $photo_vignette); | |
| 4411 | +        if (preg_match('/('.$this->regeximgext.')$/i', $filename, $regs)) {
 | |
| 4412 | +            $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $filename).'_small'.$regs[0];
 | |
| 4413 | +            if (file_exists(dol_osencode($dirthumb.$photo_vignette))) {
 | |
| 4414 | + dol_delete_file($dirthumb.$photo_vignette); | |
| 4415 | 4415 | } | 
| 4416 | 4416 | |
| 4417 | -            $photo_vignette = preg_replace('/' . $regs[0] . '/i', '', $filename) . '_mini' . $regs[0];
 | |
| 4418 | -            if (file_exists(dol_osencode($dirthumb . $photo_vignette))) {
 | |
| 4419 | - dol_delete_file($dirthumb . $photo_vignette); | |
| 4417 | +            $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $filename).'_mini'.$regs[0];
 | |
| 4418 | +            if (file_exists(dol_osencode($dirthumb.$photo_vignette))) {
 | |
| 4419 | + dol_delete_file($dirthumb.$photo_vignette); | |
| 4420 | 4420 | } | 
| 4421 | 4421 | } | 
| 4422 | 4422 | } | 
| @@ -4451,12 +4451,12 @@ discard block | ||
| 4451 | 4451 | $this->nb = array(); | 
| 4452 | 4452 | |
| 4453 | 4453 | $sql = "SELECT count(p.rowid) as nb, fk_product_type"; | 
| 4454 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product as p"; | |
| 4455 | -        $sql .= ' WHERE p.entity IN (' . getEntity($this->element, 1) . ')';
 | |
| 4454 | + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; | |
| 4455 | +        $sql .= ' WHERE p.entity IN ('.getEntity($this->element, 1).')';
 | |
| 4456 | 4456 | // Add where from hooks | 
| 4457 | 4457 |          if (is_object($hookmanager)) {
 | 
| 4458 | 4458 | $parameters = array(); | 
| 4459 | -            $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters);    // Note that $action and $object may have been modified by hook
 | |
| 4459 | +            $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
 | |
| 4460 | 4460 | $sql .= $hookmanager->resPrint; | 
| 4461 | 4461 | } | 
| 4462 | 4462 | $sql .= ' GROUP BY fk_product_type'; | 
| @@ -4517,7 +4517,7 @@ discard block | ||
| 4517 | 4517 |          if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) {
 | 
| 4518 | 4518 |              $dirsociete = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']);
 | 
| 4519 | 4519 |              foreach ($dirsociete as $dirroot) {
 | 
| 4520 | - $res = dol_include_once($dirroot . $conf->global->BARCODE_PRODUCT_ADDON_NUM . '.php'); | |
| 4520 | + $res = dol_include_once($dirroot.$conf->global->BARCODE_PRODUCT_ADDON_NUM.'.php'); | |
| 4521 | 4521 |                  if ($res) {
 | 
| 4522 | 4522 | break; | 
| 4523 | 4523 | } | 
| @@ -4527,7 +4527,7 @@ discard block | ||
| 4527 | 4527 | |
| 4528 | 4528 | $result = $mod->getNextValue($object, $type); | 
| 4529 | 4529 | |
| 4530 | - dol_syslog(get_class($this) . "::get_barcode barcode=" . $result . " module=" . $var); | |
| 4530 | + dol_syslog(get_class($this)."::get_barcode barcode=".$result." module=".$var); | |
| 4531 | 4531 | } | 
| 4532 | 4532 | return $result; | 
| 4533 | 4533 | } | 
| @@ -4550,7 +4550,7 @@ discard block | ||
| 4550 | 4550 | $this->id = 0; | 
| 4551 | 4551 | $this->ref = 'PRODUCT_SPEC'; | 
| 4552 | 4552 | $this->label = 'PRODUCT SPECIMEN'; | 
| 4553 | - $this->description = 'This is description of this product specimen that was created the ' . dol_print_date($now, 'dayhourlog') . '.'; | |
| 4553 | + $this->description = 'This is description of this product specimen that was created the '.dol_print_date($now, 'dayhourlog').'.'; | |
| 4554 | 4554 | $this->specimen = 1; | 
| 4555 | 4555 | $this->country_id = 1; | 
| 4556 | 4556 | $this->tosell = 1; | 
| @@ -4575,7 +4575,7 @@ discard block | ||
| 4575 | 4575 | $this->volume = 300; | 
| 4576 | 4576 | $this->volume_unit = 0; | 
| 4577 | 4577 | |
| 4578 | - $this->barcode = -1; // Create barcode automatically | |
| 4578 | + $this->barcode = -1; // Create barcode automatically | |
| 4579 | 4579 | } | 
| 4580 | 4580 | |
| 4581 | 4581 | /** | 
| @@ -4600,7 +4600,7 @@ discard block | ||
| 4600 | 4600 | $label_type = 'short_label'; | 
| 4601 | 4601 | } | 
| 4602 | 4602 | |
| 4603 | - $sql = 'select ' . $label_type . ' from ' . MAIN_DB_PREFIX . 'c_units where rowid=' . $this->fk_unit; | |
| 4603 | + $sql = 'select '.$label_type.' from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit; | |
| 4604 | 4604 | $resql = $this->db->query($sql); | 
| 4605 | 4605 |          if ($resql && $this->db->num_rows($resql) > 0) {
 | 
| 4606 | 4606 | $res = $this->db->fetch_array($resql); | 
| @@ -4608,8 +4608,8 @@ discard block | ||
| 4608 | 4608 | $this->db->free($resql); | 
| 4609 | 4609 | return $label; | 
| 4610 | 4610 |          } else {
 | 
| 4611 | - $this->error = $this->db->error() . ' sql=' . $sql; | |
| 4612 | - dol_syslog(get_class($this) . "::getLabelOfUnit Error " . $this->error, LOG_ERR); | |
| 4611 | + $this->error = $this->db->error().' sql='.$sql; | |
| 4612 | + dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR); | |
| 4613 | 4613 | return -1; | 
| 4614 | 4614 | } | 
| 4615 | 4615 | } | 
| @@ -4638,7 +4638,7 @@ discard block | ||
| 4638 | 4638 | $maxpricesupplier = 0; | 
| 4639 | 4639 | |
| 4640 | 4640 |          if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) {
 | 
| 4641 | - include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; | |
| 4641 | + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; | |
| 4642 | 4642 | $product_fourn = new ProductFournisseur($this->db); | 
| 4643 | 4643 | $product_fourn_list = $product_fourn->list_product_fournisseur_price($this->id, '', ''); | 
| 4644 | 4644 | |
| @@ -4674,7 +4674,7 @@ discard block | ||
| 4674 | 4674 | } | 
| 4675 | 4675 | |
| 4676 | 4676 | // Get current categories | 
| 4677 | - include_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; | |
| 4677 | + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; | |
| 4678 | 4678 | $c = new Categorie($this->db); | 
| 4679 | 4679 | $existing = $c->containing($this->id, Categorie::TYPE_PRODUCT, 'id'); | 
| 4680 | 4680 | |
| @@ -4735,7 +4735,7 @@ discard block | ||
| 4735 | 4735 |      {
 | 
| 4736 | 4736 | global $conf, $db; | 
| 4737 | 4737 | |
| 4738 | - $sql = "SELECT rowid, level, fk_level, var_percent, var_min_percent FROM " . MAIN_DB_PREFIX . "product_pricerules"; | |
| 4738 | + $sql = "SELECT rowid, level, fk_level, var_percent, var_min_percent FROM ".MAIN_DB_PREFIX."product_pricerules"; | |
| 4739 | 4739 | $query = $db->query($sql); | 
| 4740 | 4740 | |
| 4741 | 4741 | $rules = array(); | 
| @@ -4809,8 +4809,8 @@ discard block | ||
| 4809 | 4809 |      {
 | 
| 4810 | 4810 | $sql = "SELECT p.rowid, p.ref, p.datec as date_creation, p.tms as date_modification,"; | 
| 4811 | 4811 | $sql .= " p.fk_user_author, p.fk_user_modif"; | 
| 4812 | - $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element . " as p"; | |
| 4813 | - $sql .= " WHERE p.rowid = " . $id; | |
| 4812 | + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p"; | |
| 4813 | + $sql .= " WHERE p.rowid = ".$id; | |
| 4814 | 4814 | |
| 4815 | 4815 | $result = $this->db->query($sql); | 
| 4816 | 4816 |          if ($result) {
 | 
| @@ -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 | } | 
| @@ -34,14 +34,14 @@ discard block | ||
| 34 | 34 | */ | 
| 35 | 35 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> | 
| 36 | 36 |  defined('BASE_PATH') or die('Single entry point through the index.php of the main folder');
 | 
| 37 | -require DOL_BASE_PATH . '/main.inc.php'; | |
| 37 | +require DOL_BASE_PATH.'/main.inc.php'; | |
| 38 | 38 | |
| 39 | -require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; | |
| 40 | -require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.product.class.php'; | |
| 41 | -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; | |
| 39 | +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; | |
| 40 | +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; | |
| 41 | +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; | |
| 42 | 42 | |
| 43 | 43 |  if (!empty($conf->categorie->enabled)) {
 | 
| 44 | - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; | |
| 44 | + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; | |
| 45 | 45 | } | 
| 46 | 46 | |
| 47 | 47 | // Load translation files required by the page | 
| @@ -80,7 +80,7 @@ discard block | ||
| 80 | 80 | $show_childproducts = ''; | 
| 81 | 81 | } | 
| 82 | 82 | |
| 83 | -$diroutputmassaction = $conf->product->dir_output . '/temp/massgeneration/' . $user->id; | |
| 83 | +$diroutputmassaction = $conf->product->dir_output.'/temp/massgeneration/'.$user->id; | |
| 84 | 84 | |
| 85 | 85 |  $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
 | 
| 86 | 86 |  $sortfield = GETPOST("sortfield", 'alpha');
 | 
| @@ -132,7 +132,7 @@ discard block | ||
| 132 | 132 |  $canvas = GETPOST("canvas");
 | 
| 133 | 133 | $objcanvas = null; | 
| 134 | 134 |  if (!empty($canvas)) {
 | 
| 135 | - require_once DOL_DOCUMENT_ROOT . '/core/class/canvas.class.php'; | |
| 135 | + require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; | |
| 136 | 136 | $objcanvas = new Canvas($db, $action); | 
| 137 | 137 |      $objcanvas->getCanvas('product', 'list', $canvas);
 | 
| 138 | 138 | } | 
| @@ -149,7 +149,7 @@ discard block | ||
| 149 | 149 | // Define virtualdiffersfromphysical | 
| 150 | 150 | $virtualdiffersfromphysical = 0; | 
| 151 | 151 |  if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION)) {
 | 
| 152 | - $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. | |
| 152 | + $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs. | |
| 153 | 153 | } | 
| 154 | 154 | |
| 155 | 155 | // List of fields to search into when doing a "search in all" | 
| @@ -198,14 +198,14 @@ discard block | ||
| 198 | 198 |      'p.accountancy_code_buy' => array('label' => $langs->trans("ProductAccountancyBuyCode"), 'checked' => 0),
 | 
| 199 | 199 |      'p.datec' => array('label' => $langs->trans("DateCreation"), 'checked' => 0, 'position' => 500),
 | 
| 200 | 200 |      'p.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => 0, 'position' => 500),
 | 
| 201 | -    'p.tosell' => array('label' => $langs->trans("Status") . ' (' . $langs->trans("Sell") . ')', 'checked' => 1, 'position' => 1000),
 | |
| 202 | -    'p.tobuy' => array('label' => $langs->trans("Status") . ' (' . $langs->trans("Buy") . ')', 'checked' => 1, 'position' => 1000)
 | |
| 201 | +    'p.tosell' => array('label' => $langs->trans("Status").' ('.$langs->trans("Sell").')', 'checked' => 1, 'position' => 1000),
 | |
| 202 | +    'p.tobuy' => array('label' => $langs->trans("Status").' ('.$langs->trans("Buy").')', 'checked' => 1, 'position' => 1000)
 | |
| 203 | 203 | ); | 
| 204 | 204 | // Extra fields | 
| 205 | 205 |  if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
 | 
| 206 | 206 |      foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
 | 
| 207 | 207 |          if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) {
 | 
| 208 | -            $arrayfields["ef." . $key] = array('label' => $extrafields->attributes[$object->table_element]['label'][$key], 'checked' => (($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position' => $extrafields->attributes[$object->table_element]['pos'][$key], 'enabled' => (abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
 | |
| 208 | +            $arrayfields["ef.".$key] = array('label' => $extrafields->attributes[$object->table_element]['label'][$key], 'checked' => (($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position' => $extrafields->attributes[$object->table_element]['pos'][$key], 'enabled' => (abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
 | |
| 209 | 209 | } | 
| 210 | 210 | } | 
| 211 | 211 | } | 
| @@ -226,14 +226,14 @@ discard block | ||
| 226 | 226 | } | 
| 227 | 227 | |
| 228 | 228 | $parameters = array(); | 
| 229 | -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);    // Note that $action and $object may have been modified by some hooks
 | |
| 229 | +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 | |
| 230 | 230 |  if ($reshook < 0) {
 | 
| 231 | 231 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); | 
| 232 | 232 | } | 
| 233 | 233 | |
| 234 | 234 |  if (empty($reshook)) {
 | 
| 235 | 235 | // Selection of new fields | 
| 236 | - include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; | |
| 236 | + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; | |
| 237 | 237 | |
| 238 | 238 | // Purge search criteria | 
| 239 | 239 |      if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
 | 
| @@ -265,7 +265,7 @@ discard block | ||
| 265 | 265 | $permtoread = $user->rights->produit->lire; | 
| 266 | 266 | $permtodelete = $user->rights->produit->supprimer; | 
| 267 | 267 | $uploaddir = $conf->product->dir_output; | 
| 268 | - include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php'; | |
| 268 | + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; | |
| 269 | 269 | } | 
| 270 | 270 | |
| 271 | 271 | |
| @@ -292,38 +292,38 @@ discard block | ||
| 292 | 292 | $sql .= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy,'; | 
| 293 | 293 | $sql .= ' p.datec as date_creation, p.tms as date_update, p.pmp,'; | 
| 294 | 294 | $sql .= ' MIN(pfp.unitprice) as minsellprice'; | 
| 295 | -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts )) {
 | |
| 295 | +if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) {
 | |
| 296 | 296 | $sql .= ', pac.rowid prod_comb_id'; | 
| 297 | 297 | } | 
| 298 | 298 | // Add fields from extrafields | 
| 299 | 299 |  if (!empty($extrafields->attributes[$object->table_element]['label'])) {
 | 
| 300 | 300 |      foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
 | 
| 301 | - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef." . $key . ' as options_' . $key : ''); | |
| 301 | + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); | |
| 302 | 302 | } | 
| 303 | 303 | } | 
| 304 | 304 | // Add fields from hooks | 
| 305 | 305 | $parameters = array(); | 
| 306 | -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters);    // Note that $action and $object may have been modified by hook
 | |
| 306 | +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
 | |
| 307 | 307 | $sql .= $hookmanager->resPrint; | 
| 308 | -$sql .= ' FROM ' . MAIN_DB_PREFIX . 'product as p'; | |
| 308 | +$sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; | |
| 309 | 309 |  if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
 | 
| 310 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_extrafields as ef on (p.rowid = ef.fk_object)"; | |
| 310 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_extrafields as ef on (p.rowid = ef.fk_object)"; | |
| 311 | 311 | } | 
| 312 | 312 |  if (!empty($search_categ) || !empty($catid)) {
 | 
| 313 | - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . "categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ | |
| 313 | + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; // We'll need this table joined to the select in order to filter by categ | |
| 314 | 314 | } | 
| 315 | -$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; | |
| 315 | +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; | |
| 316 | 316 | // multilang | 
| 317 | 317 |  if (!empty($conf->global->MAIN_MULTILANGS)) {
 | 
| 318 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '" . $langs->getDefaultLang() . "'"; | |
| 318 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '".$langs->getDefaultLang()."'"; | |
| 319 | 319 | } | 
| 320 | 320 | |
| 321 | -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts )) {
 | |
| 322 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_attribute_combination pac ON pac.fk_product_child = p.rowid"; | |
| 321 | +if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) {
 | |
| 322 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid"; | |
| 323 | 323 | } | 
| 324 | 324 | |
| 325 | 325 | |
| 326 | -$sql .= ' WHERE p.entity IN (' . getEntity('product') . ')';
 | |
| 326 | +$sql .= ' WHERE p.entity IN ('.getEntity('product').')';
 | |
| 327 | 327 |  if ($sall) {
 | 
| 328 | 328 | $sql .= natural_search(array_keys($fieldstosearchall), $sall); | 
| 329 | 329 | } | 
| @@ -336,7 +336,7 @@ discard block | ||
| 336 | 336 | } | 
| 337 | 337 | } | 
| 338 | 338 | |
| 339 | -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts )) {
 | |
| 339 | +if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) {
 | |
| 340 | 340 | $sql .= " AND pac.rowid IS NULL"; | 
| 341 | 341 | } | 
| 342 | 342 | |
| @@ -347,49 +347,49 @@ discard block | ||
| 347 | 347 | if ($search_barcode) | 
| 348 | 348 |      $sql .= natural_search('p.barcode', $search_barcode);
 | 
| 349 | 349 | if (isset($search_tosell) && dol_strlen($search_tosell) > 0 && $search_tosell != -1) | 
| 350 | - $sql .= " AND p.tosell = " . $db->escape($search_tosell); | |
| 350 | + $sql .= " AND p.tosell = ".$db->escape($search_tosell); | |
| 351 | 351 | if (isset($search_tobuy) && dol_strlen($search_tobuy) > 0 && $search_tobuy != -1) | 
| 352 | - $sql .= " AND p.tobuy = " . $db->escape($search_tobuy); | |
| 352 | + $sql .= " AND p.tobuy = ".$db->escape($search_tobuy); | |
| 353 | 353 | if (dol_strlen($canvas) > 0) | 
| 354 | - $sql .= " AND p.canvas = '" . $db->escape($canvas) . "'"; | |
| 354 | + $sql .= " AND p.canvas = '".$db->escape($canvas)."'"; | |
| 355 | 355 | if ($catid > 0) | 
| 356 | - $sql .= " AND cp.fk_categorie = " . $catid; | |
| 356 | + $sql .= " AND cp.fk_categorie = ".$catid; | |
| 357 | 357 | if ($catid == -2) | 
| 358 | 358 | $sql .= " AND cp.fk_categorie IS NULL"; | 
| 359 | 359 | if ($search_categ > 0) | 
| 360 | - $sql .= " AND cp.fk_categorie = " . $db->escape($search_categ); | |
| 360 | + $sql .= " AND cp.fk_categorie = ".$db->escape($search_categ); | |
| 361 | 361 | if ($search_categ == -2) | 
| 362 | 362 | $sql .= " AND cp.fk_categorie IS NULL"; | 
| 363 | 363 | if ($fourn_id > 0) | 
| 364 | - $sql .= " AND pfp.fk_soc = " . $fourn_id; | |
| 364 | + $sql .= " AND pfp.fk_soc = ".$fourn_id; | |
| 365 | 365 | if ($search_tobatch != '' && $search_tobatch >= 0) | 
| 366 | - $sql .= " AND p.tobatch = " . $db->escape($search_tobatch); | |
| 366 | + $sql .= " AND p.tobatch = ".$db->escape($search_tobatch); | |
| 367 | 367 | if ($search_accountancy_code_sell) | 
| 368 | 368 |      $sql .= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell);
 | 
| 369 | 369 | if ($search_accountancy_code_buy) | 
| 370 | 370 |      $sql .= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy);
 | 
| 371 | 371 | |
| 372 | 372 | // Add where from extra fields | 
| 373 | -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php'; | |
| 373 | +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; | |
| 374 | 374 | // Add where from hooks | 
| 375 | 375 | $parameters = array(); | 
| 376 | -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters);    // Note that $action and $object may have been modified by hook
 | |
| 376 | +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
 | |
| 377 | 377 | $sql .= $hookmanager->resPrint; | 
| 378 | 378 | $sql .= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,"; | 
| 379 | 379 | $sql .= " p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,"; | 
| 380 | 380 | $sql .= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.pmp'; | 
| 381 | 381 | |
| 382 | -if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts )) {
 | |
| 382 | +if (!empty($conf->variants->enabled) && (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD) && !$show_childproducts)) {
 | |
| 383 | 383 | $sql .= ', pac.rowid'; | 
| 384 | 384 | } | 
| 385 | 385 | // Add fields from extrafields | 
| 386 | 386 |  if (!empty($extrafields->attributes[$object->table_element]['label'])) {
 | 
| 387 | 387 | foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) | 
| 388 | - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef." . $key : ''); | |
| 388 | + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); | |
| 389 | 389 | } | 
| 390 | 390 | // Add fields from hooks | 
| 391 | 391 | $parameters = array(); | 
| 392 | -$reshook = $hookmanager->executeHooks('printFieldSelect', $parameters);    // Note that $action and $object may have been modified by hook
 | |
| 392 | +$reshook = $hookmanager->executeHooks('printFieldSelect', $parameters); // Note that $action and $object may have been modified by hook
 | |
| 393 | 393 | $sql .= $hookmanager->resPrint; | 
| 394 | 394 |  //if (GETPOST("toolowstock")) $sql.= " HAVING SUM(s.reel) < p.seuil_stock_alerte";    // Not used yet
 | 
| 395 | 395 | $sql .= $db->order($sortfield, $sortorder); | 
| @@ -417,7 +417,7 @@ discard block | ||
| 417 | 417 | $obj = $db->fetch_object($resql); | 
| 418 | 418 | $id = $obj->rowid; | 
| 419 | 419 |          //header("Location: ".DOL_URL_ROOT.'/product/card.php?id='.$id);
 | 
| 420 | -        header("Location: " . BASE_URI . '?controller=product&method=card&id=' . $id);
 | |
| 420 | +        header("Location: ".BASE_URI.'?controller=product&method=card&id='.$id);
 | |
| 421 | 421 | exit; | 
| 422 | 422 | } | 
| 423 | 423 | |
| @@ -439,64 +439,64 @@ discard block | ||
| 439 | 439 | |
| 440 | 440 | $param = ''; | 
| 441 | 441 |      if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
 | 
| 442 | - $param .= '&contextpage=' . urlencode($contextpage); | |
| 442 | + $param .= '&contextpage='.urlencode($contextpage); | |
| 443 | 443 | } | 
| 444 | 444 |      if ($limit > 0 && $limit != $conf->liste_limit) {
 | 
| 445 | - $param .= '&limit=' . urlencode($limit); | |
| 445 | + $param .= '&limit='.urlencode($limit); | |
| 446 | 446 | } | 
| 447 | 447 |      if ($sall) {
 | 
| 448 | - $param .= "&sall=" . urlencode($sall); | |
| 448 | + $param .= "&sall=".urlencode($sall); | |
| 449 | 449 | } | 
| 450 | 450 |      if ($search_categ > 0) {
 | 
| 451 | - $param .= "&search_categ=" . urlencode($search_categ); | |
| 451 | + $param .= "&search_categ=".urlencode($search_categ); | |
| 452 | 452 | } | 
| 453 | 453 |      if ($search_ref) {
 | 
| 454 | - $param = "&search_ref=" . urlencode($search_ref); | |
| 454 | + $param = "&search_ref=".urlencode($search_ref); | |
| 455 | 455 | } | 
| 456 | 456 |      if ($search_ref_supplier) {
 | 
| 457 | - $param = "&search_ref_supplier=" . urlencode($search_ref_supplier); | |
| 457 | + $param = "&search_ref_supplier=".urlencode($search_ref_supplier); | |
| 458 | 458 | } | 
| 459 | 459 |      if ($search_barcode) {
 | 
| 460 | - $param .= ($search_barcode ? "&search_barcode=" . urlencode($search_barcode) : ""); | |
| 460 | + $param .= ($search_barcode ? "&search_barcode=".urlencode($search_barcode) : ""); | |
| 461 | 461 | } | 
| 462 | 462 |      if ($search_label) {
 | 
| 463 | - $param .= "&search_label=" . urlencode($search_label); | |
| 463 | + $param .= "&search_label=".urlencode($search_label); | |
| 464 | 464 | } | 
| 465 | 465 |      if ($search_tosell != '') {
 | 
| 466 | - $param .= "&search_tosell=" . urlencode($search_tosell); | |
| 466 | + $param .= "&search_tosell=".urlencode($search_tosell); | |
| 467 | 467 | } | 
| 468 | 468 |      if ($search_tobuy != '') {
 | 
| 469 | - $param .= "&search_tobuy=" . urlencode($search_tobuy); | |
| 469 | + $param .= "&search_tobuy=".urlencode($search_tobuy); | |
| 470 | 470 | } | 
| 471 | 471 |      if ($fourn_id > 0) {
 | 
| 472 | - $param .= ($fourn_id ? "&fourn_id=" . $fourn_id : ""); | |
| 472 | + $param .= ($fourn_id ? "&fourn_id=".$fourn_id : ""); | |
| 473 | 473 | } | 
| 474 | 474 |      if ($seach_categ) {
 | 
| 475 | - $param .= ($search_categ ? "&search_categ=" . urlencode($search_categ) : ""); | |
| 475 | + $param .= ($search_categ ? "&search_categ=".urlencode($search_categ) : ""); | |
| 476 | 476 | } | 
| 477 | 477 |      if ($show_childproducts) {
 | 
| 478 | - $param .= ($show_childproducts ? "&search_show_childproducts=" . urlencode($show_childproducts) : ""); | |
| 478 | + $param .= ($show_childproducts ? "&search_show_childproducts=".urlencode($show_childproducts) : ""); | |
| 479 | 479 | } | 
| 480 | 480 |      if ($type != '') {
 | 
| 481 | - $param .= '&type=' . urlencode($type); | |
| 481 | + $param .= '&type='.urlencode($type); | |
| 482 | 482 | } | 
| 483 | 483 |      if ($search_type != '') {
 | 
| 484 | - $param .= '&search_type=' . urlencode($search_type); | |
| 484 | + $param .= '&search_type='.urlencode($search_type); | |
| 485 | 485 | } | 
| 486 | 486 |      if ($optioncss != '') {
 | 
| 487 | - $param .= '&optioncss=' . urlencode($optioncss); | |
| 487 | + $param .= '&optioncss='.urlencode($optioncss); | |
| 488 | 488 | } | 
| 489 | 489 |      if ($search_tobatch) {
 | 
| 490 | - $param = "&search_ref_supplier=" . urlencode($search_ref_supplier); | |
| 490 | + $param = "&search_ref_supplier=".urlencode($search_ref_supplier); | |
| 491 | 491 | } | 
| 492 | 492 |      if ($search_accountancy_code_sell) {
 | 
| 493 | - $param = "&search_accountancy_code_sell=" . urlencode($search_accountancy_code_sell); | |
| 493 | + $param = "&search_accountancy_code_sell=".urlencode($search_accountancy_code_sell); | |
| 494 | 494 | } | 
| 495 | 495 |      if ($search_accountancy_code_buy) {
 | 
| 496 | - $param = "&search_accountancy_code_buy=" . urlencode($search_accountancy_code_buy); | |
| 496 | + $param = "&search_accountancy_code_buy=".urlencode($search_accountancy_code_buy); | |
| 497 | 497 | } | 
| 498 | 498 | // Add $param from extra fields | 
| 499 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php'; | |
| 499 | + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; | |
| 500 | 500 | |
| 501 | 501 | // List of mass actions available | 
| 502 | 502 | $arrayofmassactions = array( | 
| @@ -521,51 +521,51 @@ discard block | ||
| 521 | 521 | $label = 'NewService'; | 
| 522 | 522 | } | 
| 523 | 523 | //$newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/product/card.php?action=create&type='.$type.'"><span class="valignmiddle">'.$langs->trans($label).'</span>'; | 
| 524 | - $newcardbutton = '<a class="butActionNew" href="' . BASE_URI . '?controller=product&method=card&action=create&type=' . $type . '"><span class="valignmiddle">' . $langs->trans($label) . '</span>'; | |
| 524 | + $newcardbutton = '<a class="butActionNew" href="'.BASE_URI.'?controller=product&method=card&action=create&type='.$type.'"><span class="valignmiddle">'.$langs->trans($label).'</span>'; | |
| 525 | 525 | $newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>'; | 
| 526 | 526 | $newcardbutton .= '</a>'; | 
| 527 | 527 | } | 
| 528 | 528 | |
| 529 | - print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formulaire">'; | |
| 529 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formulaire">'; | |
| 530 | 530 | if ($optioncss != '') | 
| 531 | - print '<input type="hidden" name="optioncss" value="' . $optioncss . '">'; | |
| 532 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 531 | + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; | |
| 532 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 533 | 533 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; | 
| 534 | 534 | print '<input type="hidden" name="action" value="list">'; | 
| 535 | - print '<input type="hidden" name="sortfield" value="' . $sortfield . '">'; | |
| 536 | - print '<input type="hidden" name="sortorder" value="' . $sortorder . '">'; | |
| 537 | - print '<input type="hidden" name="page" value="' . $page . '">'; | |
| 538 | - print '<input type="hidden" name="type" value="' . $type . '">'; | |
| 535 | + print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; | |
| 536 | + print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; | |
| 537 | + print '<input type="hidden" name="page" value="'.$page.'">'; | |
| 538 | + print '<input type="hidden" name="type" value="'.$type.'">'; | |
| 539 | 539 | if (empty($arrayfields['p.fk_product_type']['checked'])) | 
| 540 | - print '<input type="hidden" name="search_type" value="' . dol_escape_htmltag($search_type) . '">'; | |
| 540 | + print '<input type="hidden" name="search_type" value="'.dol_escape_htmltag($search_type).'">'; | |
| 541 | 541 | |
| 542 | 542 | print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_products.png', 0, $newcardbutton, '', $limit); | 
| 543 | 543 | |
| 544 | 544 | $topicmail = "Information"; | 
| 545 | 545 | $modelmail = "product"; | 
| 546 | 546 | $objecttmp = new Product($db); | 
| 547 | - $trackid = 'prod' . $object->id; | |
| 548 | - include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php'; | |
| 547 | + $trackid = 'prod'.$object->id; | |
| 548 | + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; | |
| 549 | 549 | |
| 550 | 550 |      if (!empty($catid)) {
 | 
| 551 | 551 | print "<div id='ways'>"; | 
| 552 | 552 | $c = new Categorie($db); | 
| 553 | 553 |          $ways = $c->print_all_ways(' > ', 'product/list.php');
 | 
| 554 | - print " > " . $ways[0] . "<br>\n"; | |
| 554 | + print " > ".$ways[0]."<br>\n"; | |
| 555 | 555 | print "</div><br>"; | 
| 556 | 556 | } | 
| 557 | 557 | |
| 558 | 558 |      if ($sall) {
 | 
| 559 | 559 | foreach ($fieldstosearchall as $key => $val) | 
| 560 | 560 | $fieldstosearchall[$key] = $langs->trans($val); | 
| 561 | -        print '<div class="divsearchfieldfilter">' . $langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall) . '</div>';
 | |
| 561 | +        print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
 | |
| 562 | 562 | } | 
| 563 | 563 | |
| 564 | 564 | // Filter on categories | 
| 565 | 565 | $moreforfilter = ''; | 
| 566 | 566 |      if (!empty($conf->categorie->enabled)) {
 | 
| 567 | 567 | $moreforfilter .= '<div class="divsearchfield">'; | 
| 568 | -        $moreforfilter .= $langs->trans('Categories') . ': ';
 | |
| 568 | +        $moreforfilter .= $langs->trans('Categories').': ';
 | |
| 569 | 569 | $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1); | 
| 570 | 570 | $moreforfilter .= '</div>'; | 
| 571 | 571 | } | 
| @@ -573,13 +573,13 @@ discard block | ||
| 573 | 573 | //Show/hide child products. Hidden by default | 
| 574 | 574 |      if (!empty($conf->variants->enabled) && !empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
 | 
| 575 | 575 | $moreforfilter .= '<div class="divsearchfield">'; | 
| 576 | - $moreforfilter .= '<input type="checkbox" id="search_show_childproducts" name="search_show_childproducts"' . ($show_childproducts ? 'checked="checked"' : '') . '>'; | |
| 577 | -        $moreforfilter .= ' <label for="search_show_childproducts">' . $langs->trans('ShowChildProducts') . '</label>';
 | |
| 576 | + $moreforfilter .= '<input type="checkbox" id="search_show_childproducts" name="search_show_childproducts"'.($show_childproducts ? 'checked="checked"' : '').'>'; | |
| 577 | +        $moreforfilter .= ' <label for="search_show_childproducts">'.$langs->trans('ShowChildProducts').'</label>';
 | |
| 578 | 578 | $moreforfilter .= '</div>'; | 
| 579 | 579 | } | 
| 580 | 580 | |
| 581 | 581 | $parameters = array(); | 
| 582 | -    $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters);    // Note that $action and $object may have been modified by hook
 | |
| 582 | +    $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
 | |
| 583 | 583 | if (empty($reshook)) | 
| 584 | 584 | $moreforfilter .= $hookmanager->resPrint; | 
| 585 | 585 | else | 
| @@ -597,23 +597,23 @@ discard block | ||
| 597 | 597 |          $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
 | 
| 598 | 598 | |
| 599 | 599 | print '<div class="div-table-responsive">'; | 
| 600 | - print '<table class="tagtable liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n"; | |
| 600 | + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; | |
| 601 | 601 | |
| 602 | 602 | // Lines with input filters | 
| 603 | 603 | print '<tr class="liste_titre_filter">'; | 
| 604 | 604 |      if (!empty($arrayfields['p.ref']['checked'])) {
 | 
| 605 | 605 | print '<td class="liste_titre" align="left">'; | 
| 606 | - print '<input class="flat" type="text" name="search_ref" size="8" value="' . dol_escape_htmltag($search_ref) . '">'; | |
| 606 | + print '<input class="flat" type="text" name="search_ref" size="8" value="'.dol_escape_htmltag($search_ref).'">'; | |
| 607 | 607 | print '</td>'; | 
| 608 | 608 | } | 
| 609 | 609 |      if (!empty($arrayfields['pfp.ref_fourn']['checked'])) {
 | 
| 610 | 610 | print '<td class="liste_titre" align="left">'; | 
| 611 | - print '<input class="flat" type="text" name="search_ref_supplier" size="8" value="' . dol_escape_htmltag($search_ref_supplier) . '">'; | |
| 611 | + print '<input class="flat" type="text" name="search_ref_supplier" size="8" value="'.dol_escape_htmltag($search_ref_supplier).'">'; | |
| 612 | 612 | print '</td>'; | 
| 613 | 613 | } | 
| 614 | 614 |      if (!empty($arrayfields['p.label']['checked'])) {
 | 
| 615 | 615 | print '<td class="liste_titre" align="left">'; | 
| 616 | - print '<input class="flat" type="text" name="search_label" size="12" value="' . dol_escape_htmltag($search_label) . '">'; | |
| 616 | + print '<input class="flat" type="text" name="search_label" size="12" value="'.dol_escape_htmltag($search_label).'">'; | |
| 617 | 617 | print '</td>'; | 
| 618 | 618 | } | 
| 619 | 619 | // Type | 
| @@ -626,7 +626,7 @@ discard block | ||
| 626 | 626 | // Barcode | 
| 627 | 627 |      if (!empty($arrayfields['p.barcode']['checked'])) {
 | 
| 628 | 628 | print '<td class="liste_titre">'; | 
| 629 | - print '<input class="flat" type="text" name="search_barcode" size="6" value="' . dol_escape_htmltag($search_barcode) . '">'; | |
| 629 | + print '<input class="flat" type="text" name="search_barcode" size="6" value="'.dol_escape_htmltag($search_barcode).'">'; | |
| 630 | 630 | print '</td>'; | 
| 631 | 631 | } | 
| 632 | 632 | // Duration | 
| @@ -680,21 +680,21 @@ discard block | ||
| 680 | 680 | } | 
| 681 | 681 | // To batch | 
| 682 | 682 |      if (!empty($arrayfields['p.tobatch']['checked'])) {
 | 
| 683 | - print '<td class="liste_titre center">' . $form->selectyesno($search_tobatch, '', '', '', 1) . '</td>'; | |
| 683 | + print '<td class="liste_titre center">'.$form->selectyesno($search_tobatch, '', '', '', 1).'</td>'; | |
| 684 | 684 | } | 
| 685 | 685 | // Accountancy code sell | 
| 686 | 686 |      if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) {
 | 
| 687 | - print '<td class="liste_titre"><input class="flat" type="text" name="search_accountancy_code_sell" size="6" value="' . dol_escape_htmltag($search_accountancy_code_sell) . '"></td>'; | |
| 687 | + print '<td class="liste_titre"><input class="flat" type="text" name="search_accountancy_code_sell" size="6" value="'.dol_escape_htmltag($search_accountancy_code_sell).'"></td>'; | |
| 688 | 688 | } | 
| 689 | 689 | // Accountancy code sell | 
| 690 | 690 |      if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) {
 | 
| 691 | - print '<td class="liste_titre"><input class="flat" type="text" name="search_accountancy_code_buy" size="6" value="' . dol_escape_htmltag($search_accountancy_code_buy) . '"></td>'; | |
| 691 | + print '<td class="liste_titre"><input class="flat" type="text" name="search_accountancy_code_buy" size="6" value="'.dol_escape_htmltag($search_accountancy_code_buy).'"></td>'; | |
| 692 | 692 | } | 
| 693 | 693 | // Extra fields | 
| 694 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php'; | |
| 694 | + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; | |
| 695 | 695 | // Fields from hook | 
| 696 | 696 |      $parameters = array('arrayfields' => $arrayfields);
 | 
| 697 | -    $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters);    // Note that $action and $object may have been modified by hook
 | |
| 697 | +    $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
 | |
| 698 | 698 | print $hookmanager->resPrint; | 
| 699 | 699 | // Date creation | 
| 700 | 700 |      if (!empty($arrayfields['p.datec']['checked'])) {
 | 
| @@ -777,10 +777,10 @@ discard block | ||
| 777 | 777 | print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_buy", "", $param, '', $sortfield, $sortorder); | 
| 778 | 778 | } | 
| 779 | 779 | // Extra fields | 
| 780 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php'; | |
| 780 | + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; | |
| 781 | 781 | // Hook fields | 
| 782 | 782 |      $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
 | 
| 783 | -    $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters);    // Note that $action and $object may have been modified by hook
 | |
| 783 | +    $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
 | |
| 784 | 784 | print $hookmanager->resPrint; | 
| 785 | 785 | if (!empty($arrayfields['p.datec']['checked'])) | 
| 786 | 786 |      {
 | 
| @@ -813,9 +813,9 @@ discard block | ||
| 813 | 813 | // Multilangs | 
| 814 | 814 |          if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active
 | 
| 815 | 815 | $sql = "SELECT label"; | 
| 816 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_lang"; | |
| 817 | - $sql .= " WHERE fk_product=" . $obj->rowid; | |
| 818 | - $sql .= " AND lang='" . $db->escape($langs->getDefaultLang()) . "'"; | |
| 816 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; | |
| 817 | + $sql .= " WHERE fk_product=".$obj->rowid; | |
| 818 | + $sql .= " AND lang='".$db->escape($langs->getDefaultLang())."'"; | |
| 819 | 819 | $sql .= " LIMIT 1"; | 
| 820 | 820 | |
| 821 | 821 | $result = $db->query($sql); | 
| @@ -843,7 +843,7 @@ discard block | ||
| 843 | 843 | |
| 844 | 844 |          if ((!empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || !empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) { // To optimize call of load_stock
 | 
| 845 | 845 |              if ($obj->fk_product_type != 1 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {    // Not a service
 | 
| 846 | -                $product_static->load_stock('nobatch');             // Load stock_reel + stock_warehouse. This also call load_virtual_stock()
 | |
| 846 | +                $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock()
 | |
| 847 | 847 | } | 
| 848 | 848 | } | 
| 849 | 849 | |
| @@ -856,7 +856,7 @@ discard block | ||
| 856 | 856 | print $product_static->getNomUrl(1); | 
| 857 | 857 | print "</td>\n"; | 
| 858 | 858 | if (!$i) | 
| 859 | - $totalarray['nbfield'] ++; | |
| 859 | + $totalarray['nbfield']++; | |
| 860 | 860 | } | 
| 861 | 861 | // Ref supplier | 
| 862 | 862 |          if (!empty($arrayfields['pfp.ref_fourn']['checked'])) {
 | 
| @@ -864,27 +864,27 @@ discard block | ||
| 864 | 864 | print $product_static->getNomUrl(1); | 
| 865 | 865 | print "</td>\n"; | 
| 866 | 866 | if (!$i) | 
| 867 | - $totalarray['nbfield'] ++; | |
| 867 | + $totalarray['nbfield']++; | |
| 868 | 868 | } | 
| 869 | 869 | // Label | 
| 870 | 870 |          if (!empty($arrayfields['p.label']['checked'])) {
 | 
| 871 | - print '<td class="tdoverflowmax200">' . dol_trunc($obj->label, 40) . '</td>'; | |
| 871 | + print '<td class="tdoverflowmax200">'.dol_trunc($obj->label, 40).'</td>'; | |
| 872 | 872 | if (!$i) | 
| 873 | - $totalarray['nbfield'] ++; | |
| 873 | + $totalarray['nbfield']++; | |
| 874 | 874 | } | 
| 875 | 875 | |
| 876 | 876 | // Type | 
| 877 | 877 |          if (!empty($arrayfields['p.fk_product_type']['checked'])) {
 | 
| 878 | - print '<td>' . $obj->fk_product_type . '</td>'; | |
| 878 | + print '<td>'.$obj->fk_product_type.'</td>'; | |
| 879 | 879 | if (!$i) | 
| 880 | - $totalarray['nbfield'] ++; | |
| 880 | + $totalarray['nbfield']++; | |
| 881 | 881 | } | 
| 882 | 882 | |
| 883 | 883 | // Barcode | 
| 884 | 884 |          if (!empty($arrayfields['p.barcode']['checked'])) {
 | 
| 885 | - print '<td>' . $obj->barcode . '</td>'; | |
| 885 | + print '<td>'.$obj->barcode.'</td>'; | |
| 886 | 886 | if (!$i) | 
| 887 | - $totalarray['nbfield'] ++; | |
| 887 | + $totalarray['nbfield']++; | |
| 888 | 888 | } | 
| 889 | 889 | |
| 890 | 890 | // Duration | 
| @@ -901,13 +901,13 @@ discard block | ||
| 901 | 901 |                      $dur = array("i" => $langs->trans("Minute"), "h" => $langs->trans("Hour"), "d" => $langs->trans("Day"), "w" => $langs->trans("Week"), "m" => $langs->trans("Month"), "y" => $langs->trans("Year"));
 | 
| 902 | 902 | } | 
| 903 | 903 | print $duration_value; | 
| 904 | - print (!empty($duration_unit) && isset($dur[$duration_unit]) ? ' ' . $langs->trans($dur[$duration_unit]) : ''); | |
| 904 | + print (!empty($duration_unit) && isset($dur[$duration_unit]) ? ' '.$langs->trans($dur[$duration_unit]) : ''); | |
| 905 | 905 |              } else {
 | 
| 906 | 906 | print $obj->duration; | 
| 907 | 907 | } | 
| 908 | 908 | print '</td>'; | 
| 909 | 909 | if (!$i) | 
| 910 | - $totalarray['nbfield'] ++; | |
| 910 | + $totalarray['nbfield']++; | |
| 911 | 911 | } | 
| 912 | 912 | |
| 913 | 913 | // Sell price | 
| @@ -915,13 +915,13 @@ discard block | ||
| 915 | 915 | print '<td class="right nowraponall">'; | 
| 916 | 916 |              if ($obj->tosell) {
 | 
| 917 | 917 | if ($obj->price_base_type == 'TTC') | 
| 918 | -                    print price($obj->price_ttc) . ' ' . $langs->trans("TTC");
 | |
| 918 | +                    print price($obj->price_ttc).' '.$langs->trans("TTC");
 | |
| 919 | 919 | else | 
| 920 | -                    print price($obj->price) . ' ' . $langs->trans("HT");
 | |
| 920 | +                    print price($obj->price).' '.$langs->trans("HT");
 | |
| 921 | 921 | } | 
| 922 | 922 | print '</td>'; | 
| 923 | 923 | if (!$i) | 
| 924 | - $totalarray['nbfield'] ++; | |
| 924 | + $totalarray['nbfield']++; | |
| 925 | 925 | } | 
| 926 | 926 | |
| 927 | 927 | // Better buy price | 
| @@ -933,15 +933,15 @@ discard block | ||
| 933 | 933 |                      if ($product_fourn->product_fourn_price_id > 0) {
 | 
| 934 | 934 |                          if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) {
 | 
| 935 | 935 | $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1); | 
| 936 | -                            print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent / 100) - $product_fourn->fourn_remise) . ' ' . $langs->trans("HT"), $htmltext);
 | |
| 936 | +                            print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent / 100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"), $htmltext);
 | |
| 937 | 937 | } else | 
| 938 | -                            print price($product_fourn->fourn_unitprice) . ' ' . $langs->trans("HT");
 | |
| 938 | +                            print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT");
 | |
| 939 | 939 | } | 
| 940 | 940 | } | 
| 941 | 941 | } | 
| 942 | 942 | print '</td>'; | 
| 943 | 943 | if (!$i) | 
| 944 | - $totalarray['nbfield'] ++; | |
| 944 | + $totalarray['nbfield']++; | |
| 945 | 945 | } | 
| 946 | 946 | |
| 947 | 947 | // Number of buy prices | 
| @@ -971,7 +971,7 @@ discard block | ||
| 971 | 971 | } | 
| 972 | 972 | print '</td>'; | 
| 973 | 973 | if (!$i) | 
| 974 | - $totalarray['nbfield'] ++; | |
| 974 | + $totalarray['nbfield']++; | |
| 975 | 975 | } | 
| 976 | 976 | // Desired stock | 
| 977 | 977 |          if (!empty($arrayfields['p.desiredstock']['checked'])) {
 | 
| @@ -981,31 +981,31 @@ discard block | ||
| 981 | 981 | } | 
| 982 | 982 | print '</td>'; | 
| 983 | 983 | if (!$i) | 
| 984 | - $totalarray['nbfield'] ++; | |
| 984 | + $totalarray['nbfield']++; | |
| 985 | 985 | } | 
| 986 | 986 | // Stock real | 
| 987 | 987 |          if (!empty($arrayfields['p.stock']['checked'])) {
 | 
| 988 | 988 | print '<td align="right">'; | 
| 989 | 989 |              if ($obj->fk_product_type != 1) {
 | 
| 990 | 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)) . ' ';
 | |
| 991 | +                    print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' ';
 | |
| 992 | 992 | print $product_static->stock_reel; | 
| 993 | 993 | } | 
| 994 | 994 | print '</td>'; | 
| 995 | 995 | if (!$i) | 
| 996 | - $totalarray['nbfield'] ++; | |
| 996 | + $totalarray['nbfield']++; | |
| 997 | 997 | } | 
| 998 | 998 | // Stock virtual | 
| 999 | 999 |          if (!empty($arrayfields['stock_virtual']['checked'])) {
 | 
| 1000 | 1000 | print '<td align="right">'; | 
| 1001 | 1001 |              if ($obj->fk_product_type != 1) {
 | 
| 1002 | 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)) . ' ';
 | |
| 1003 | +                    print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' ';
 | |
| 1004 | 1004 | print $product_static->stock_theorique; | 
| 1005 | 1005 | } | 
| 1006 | 1006 | print '</td>'; | 
| 1007 | 1007 | if (!$i) | 
| 1008 | - $totalarray['nbfield'] ++; | |
| 1008 | + $totalarray['nbfield']++; | |
| 1009 | 1009 | } | 
| 1010 | 1010 | // Lot/Serial | 
| 1011 | 1011 |          if (!empty($arrayfields['p.tobatch']['checked'])) {
 | 
| @@ -1013,25 +1013,25 @@ discard block | ||
| 1013 | 1013 | print yn($obj->tobatch); | 
| 1014 | 1014 | print '</td>'; | 
| 1015 | 1015 | if (!$i) | 
| 1016 | - $totalarray['nbfield'] ++; | |
| 1016 | + $totalarray['nbfield']++; | |
| 1017 | 1017 | } | 
| 1018 | 1018 | // Accountancy code sell | 
| 1019 | 1019 |          if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) {
 | 
| 1020 | - print '<td>' . $obj->accountancy_code_sell . '</td>'; | |
| 1020 | + print '<td>'.$obj->accountancy_code_sell.'</td>'; | |
| 1021 | 1021 | if (!$i) | 
| 1022 | - $totalarray['nbfield'] ++; | |
| 1022 | + $totalarray['nbfield']++; | |
| 1023 | 1023 | } | 
| 1024 | 1024 | // Accountancy code sell | 
| 1025 | 1025 |          if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) {
 | 
| 1026 | - print '<td>' . $obj->accountancy_code_buy . '</td>'; | |
| 1026 | + print '<td>'.$obj->accountancy_code_buy.'</td>'; | |
| 1027 | 1027 | if (!$i) | 
| 1028 | - $totalarray['nbfield'] ++; | |
| 1028 | + $totalarray['nbfield']++; | |
| 1029 | 1029 | } | 
| 1030 | 1030 | // Extra fields | 
| 1031 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php'; | |
| 1031 | + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; | |
| 1032 | 1032 | // Fields from hook | 
| 1033 | 1033 |          $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj);
 | 
| 1034 | -        $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters);    // Note that $action and $object may have been modified by hook
 | |
| 1034 | +        $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
 | |
| 1035 | 1035 | print $hookmanager->resPrint; | 
| 1036 | 1036 | // Date creation | 
| 1037 | 1037 |          if (!empty($arrayfields['p.datec']['checked'])) {
 | 
| @@ -1039,7 +1039,7 @@ discard block | ||
| 1039 | 1039 | print dol_print_date($obj->date_creation, 'dayhour', 'tzuser'); | 
| 1040 | 1040 | print '</td>'; | 
| 1041 | 1041 | if (!$i) | 
| 1042 | - $totalarray['nbfield'] ++; | |
| 1042 | + $totalarray['nbfield']++; | |
| 1043 | 1043 | } | 
| 1044 | 1044 | // Date modification | 
| 1045 | 1045 |          if (!empty($arrayfields['p.tms']['checked'])) {
 | 
| @@ -1047,7 +1047,7 @@ discard block | ||
| 1047 | 1047 | print dol_print_date($obj->date_update, 'dayhour', 'tzuser'); | 
| 1048 | 1048 | print '</td>'; | 
| 1049 | 1049 | if (!$i) | 
| 1050 | - $totalarray['nbfield'] ++; | |
| 1050 | + $totalarray['nbfield']++; | |
| 1051 | 1051 | } | 
| 1052 | 1052 | |
| 1053 | 1053 | // Status (to sell) | 
| @@ -1060,7 +1060,7 @@ discard block | ||
| 1060 | 1060 | } | 
| 1061 | 1061 | print '</td>'; | 
| 1062 | 1062 | if (!$i) | 
| 1063 | - $totalarray['nbfield'] ++; | |
| 1063 | + $totalarray['nbfield']++; | |
| 1064 | 1064 | } | 
| 1065 | 1065 | // Status (to buy) | 
| 1066 | 1066 |          if (!empty($arrayfields['p.tobuy']['checked'])) {
 | 
| @@ -1072,7 +1072,7 @@ discard block | ||
| 1072 | 1072 | } | 
| 1073 | 1073 | print '</td>'; | 
| 1074 | 1074 | if (!$i) | 
| 1075 | - $totalarray['nbfield'] ++; | |
| 1075 | + $totalarray['nbfield']++; | |
| 1076 | 1076 | } | 
| 1077 | 1077 | // Action | 
| 1078 | 1078 | print '<td class="nowrap" align="center">'; | 
| @@ -1080,11 +1080,11 @@ discard block | ||
| 1080 | 1080 | $selected = 0; | 
| 1081 | 1081 | if (in_array($obj->rowid, $arrayofselected)) | 
| 1082 | 1082 | $selected = 1; | 
| 1083 | - print '<input id="cb' . $obj->rowid . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj->rowid . '"' . ($selected ? ' checked="checked"' : '') . '>'; | |
| 1083 | + print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; | |
| 1084 | 1084 | } | 
| 1085 | 1085 | print '</td>'; | 
| 1086 | 1086 | if (!$i) | 
| 1087 | - $totalarray['nbfield'] ++; | |
| 1087 | + $totalarray['nbfield']++; | |
| 1088 | 1088 | |
| 1089 | 1089 | print "</tr>\n"; | 
| 1090 | 1090 | $i++; | 
| @@ -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 | |
| @@ -36,7 +36,7 @@ discard block | ||
| 36 | 36 | * \brief A set of functions for Dolibarr | 
| 37 | 37 | * This file contains all frequently used functions. | 
| 38 | 38 | */ | 
| 39 | -include_once DOL_BASE_PATH . '/core/lib/json.lib.php'; | |
| 39 | +include_once DOL_BASE_PATH.'/core/lib/json.lib.php'; | |
| 40 | 40 | |
| 41 | 41 | /** | 
| 42 | 42 | * Function to return value of a static property when class | 
| @@ -51,7 +51,7 @@ discard block | ||
| 51 | 51 | */ | 
| 52 | 52 | function getStaticMember($class, $member) | 
| 53 | 53 |  {
 | 
| 54 | - dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); | |
| 54 | + dol_syslog(__FUNCTION__." is deprecated", LOG_WARNING); | |
| 55 | 55 | |
| 56 | 56 | // This part is deprecated. Uncomment if for php 5.2.*, and comment next isset class::member | 
| 57 | 57 | /* if (version_compare(phpversion(), '5.3.0', '<')) | 
| @@ -76,7 +76,7 @@ discard block | ||
| 76 | 76 | |
| 77 | 77 | if (isset($class::$member)) | 
| 78 | 78 | return $class::$member; | 
| 79 | -    dol_print_error('', 'Try to get a static member "' . $member . '" in class "' . $class . '" that does not exists or is not static.');
 | |
| 79 | +    dol_print_error('', 'Try to get a static member "'.$member.'" in class "'.$class.'" that does not exists or is not static.');
 | |
| 80 | 80 | return null; | 
| 81 | 81 | } | 
| 82 | 82 | |
| @@ -93,9 +93,9 @@ discard block | ||
| 93 | 93 | */ | 
| 94 | 94 | function getDoliDBInstance($type, $host, $user, $pass, $name, $port) | 
| 95 | 95 |  {
 | 
| 96 | - require_once DOL_BASE_PATH . "/core/db/" . $type . '.class.php'; | |
| 96 | + require_once DOL_BASE_PATH."/core/db/".$type.'.class.php'; | |
| 97 | 97 | |
| 98 | - $class = 'DoliDB' . ucfirst($type); | |
| 98 | + $class = 'DoliDB'.ucfirst($type); | |
| 99 | 99 | $dolidb = new $class($type, $host, $user, $pass, $name, $port); | 
| 100 | 100 | return $dolidb; | 
| 101 | 101 | } | 
| @@ -151,7 +151,7 @@ discard block | ||
| 151 | 151 | */ | 
| 152 | 152 | function getBrowserInfo($user_agent) | 
| 153 | 153 |  {
 | 
| 154 | - include_once DOL_BASE_PATH . '/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php'; | |
| 154 | + include_once DOL_BASE_PATH.'/includes/mobiledetect/mobiledetectlib/Mobile_Detect.php'; | |
| 155 | 155 | |
| 156 | 156 | $name = 'unknown'; | 
| 157 | 157 | $version = ''; | 
| @@ -264,7 +264,7 @@ discard block | ||
| 264 | 264 | $depth = $db->transaction_opened; | 
| 265 | 265 | $disconnectdone = $db->close(); | 
| 266 | 266 | } | 
| 267 | -    dol_syslog("--- End access to " . $_SERVER["PHP_SELF"] . (($disconnectdone && $depth) ? ' (Warn: db disconnection forced, transaction depth was ' . $depth . ')' : ''), (($disconnectdone && $depth) ? LOG_WARNING : LOG_INFO));
 | |
| 267 | +    dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].(($disconnectdone && $depth) ? ' (Warn: db disconnection forced, transaction depth was '.$depth.')' : ''), (($disconnectdone && $depth) ? LOG_WARNING : LOG_INFO));
 | |
| 268 | 268 | } | 
| 269 | 269 | |
| 270 | 270 | /** | 
| @@ -309,7 +309,7 @@ discard block | ||
| 309 | 309 | if (empty($paramname)) | 
| 310 | 310 | return 'BadFirstParameterForGETPOST'; | 
| 311 | 311 |      if (empty($check)) {
 | 
| 312 | -        dol_syslog("Deprecated use of GETPOST, called with 1st param = " . $paramname . " and 2nd param is '', when calling page " . $_SERVER["PHP_SELF"], LOG_WARNING);
 | |
| 312 | +        dol_syslog("Deprecated use of GETPOST, called with 1st param = ".$paramname." and 2nd param is '', when calling page ".$_SERVER["PHP_SELF"], LOG_WARNING);
 | |
| 313 | 313 | // Enable this line to know who call the GETPOST with '' $check parameter. | 
| 314 | 314 | //var_dump(debug_backtrace()[0]); | 
| 315 | 315 | } | 
| @@ -331,7 +331,7 @@ discard block | ||
| 331 | 331 | $relativepathstring = $_SERVER["PHP_SELF"]; | 
| 332 | 332 | // Clean $relativepathstring | 
| 333 | 333 |          if (constant('DOL_URL_ROOT'))
 | 
| 334 | -            $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_URL_ROOT'), '/') . '/', '', $relativepathstring);
 | |
| 334 | +            $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'), '/').'/', '', $relativepathstring);
 | |
| 335 | 335 |          $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
 | 
| 336 | 336 |          $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
 | 
| 337 | 337 | //var_dump($relativepathstring); | 
| @@ -339,8 +339,8 @@ discard block | ||
| 339 | 339 | // Code for search criteria persistence. | 
| 340 | 340 | // Retrieve values if restore_lastsearch_values | 
| 341 | 341 |          if (!empty($_GET['restore_lastsearch_values'])) {        // Use $_GET here and not GETPOST
 | 
| 342 | -            if (!empty($_SESSION['lastsearch_values_' . $relativepathstring])) { // If there is saved values
 | |
| 343 | - $tmp = json_decode($_SESSION['lastsearch_values_' . $relativepathstring], true); | |
| 342 | +            if (!empty($_SESSION['lastsearch_values_'.$relativepathstring])) { // If there is saved values
 | |
| 343 | + $tmp = json_decode($_SESSION['lastsearch_values_'.$relativepathstring], true); | |
| 344 | 344 |                  if (is_array($tmp)) {
 | 
| 345 | 345 |                      foreach ($tmp as $key => $val) {
 | 
| 346 | 346 |                          if ($key == $paramname) { // We are on the requested parameter
 | 
| @@ -351,12 +351,12 @@ discard block | ||
| 351 | 351 | } | 
| 352 | 352 | } | 
| 353 | 353 | // If there is saved contextpage, page or limit | 
| 354 | -            if ($paramname == 'contextpage' && !empty($_SESSION['lastsearch_contextpage_' . $relativepathstring])) {
 | |
| 355 | - $out = $_SESSION['lastsearch_contextpage_' . $relativepathstring]; | |
| 356 | -            } elseif ($paramname == 'page' && !empty($_SESSION['lastsearch_page_' . $relativepathstring])) {
 | |
| 357 | - $out = $_SESSION['lastsearch_page_' . $relativepathstring]; | |
| 358 | -            } elseif ($paramname == 'limit' && !empty($_SESSION['lastsearch_limit_' . $relativepathstring])) {
 | |
| 359 | - $out = $_SESSION['lastsearch_limit_' . $relativepathstring]; | |
| 354 | +            if ($paramname == 'contextpage' && !empty($_SESSION['lastsearch_contextpage_'.$relativepathstring])) {
 | |
| 355 | + $out = $_SESSION['lastsearch_contextpage_'.$relativepathstring]; | |
| 356 | +            } elseif ($paramname == 'page' && !empty($_SESSION['lastsearch_page_'.$relativepathstring])) {
 | |
| 357 | + $out = $_SESSION['lastsearch_page_'.$relativepathstring]; | |
| 358 | +            } elseif ($paramname == 'limit' && !empty($_SESSION['lastsearch_limit_'.$relativepathstring])) {
 | |
| 359 | + $out = $_SESSION['lastsearch_limit_'.$relativepathstring]; | |
| 360 | 360 | } | 
| 361 | 361 | } | 
| 362 | 362 | // Else, retreive default values if we are not doing a sort | 
| @@ -424,7 +424,7 @@ discard block | ||
| 424 | 424 | $qualified = 1; | 
| 425 | 425 | |
| 426 | 426 |                                      if ($qualified) {
 | 
| 427 | -                                        $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "=");  // we accept _, -, . and ,
 | |
| 427 | +                                        $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and ,
 | |
| 428 | 428 |                                          foreach ($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) {
 | 
| 429 | 429 | if ($out) | 
| 430 | 430 | $out .= ', '; | 
| @@ -460,11 +460,11 @@ discard block | ||
| 460 | 460 |                                      if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all'])) {
 | 
| 461 | 461 | // We made a search from quick search menu, do we still use default filter ? | 
| 462 | 462 |                                          if (empty($conf->global->MAIN_DISABLE_DEFAULT_FILTER_FOR_QUICK_SEARCH)) {
 | 
| 463 | -                                            $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "=");  // we accept _, -, . and ,
 | |
| 463 | +                                            $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and ,
 | |
| 464 | 464 | $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace); | 
| 465 | 465 | } | 
| 466 | 466 |                                      } else {
 | 
| 467 | -                                        $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "=");  // we accept _, -, . and ,
 | |
| 467 | +                                        $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and ,
 | |
| 468 | 468 | $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace); | 
| 469 | 469 | } | 
| 470 | 470 | break; | 
| @@ -482,7 +482,7 @@ discard block | ||
| 482 | 482 | // We do this only if var is a GET. If it is a POST, may be we want to post the text with vars as the setup text. | 
| 483 | 483 |      if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) {
 | 
| 484 | 484 | $maxloop = 20; | 
| 485 | - $loopnb = 0; // Protection against infinite loop | |
| 485 | + $loopnb = 0; // Protection against infinite loop | |
| 486 | 486 |          while (preg_match('/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) {    // Detect '__ABCDEF__' as key 'ABCDEF' and '__ABC_DEF__' as key 'ABC_DEF'. Detection is also correct when 2 vars are side by side.
 | 
| 487 | 487 | $loopnb++; | 
| 488 | 488 | $newout = ''; | 
| @@ -527,7 +527,7 @@ discard block | ||
| 527 | 527 |              } elseif ($reg[1] == 'ENTITY_ID' || $reg[1] == 'ENTITYID') {
 | 
| 528 | 528 | $newout = $conf->entity; | 
| 529 | 529 | } else | 
| 530 | - $newout = ''; // Key not found, we replace with empty string | |
| 530 | + $newout = ''; // Key not found, we replace with empty string | |
| 531 | 531 | |
| 532 | 532 | |
| 533 | 533 | |
| @@ -542,7 +542,7 @@ discard block | ||
| 542 | 542 | |
| 543 | 543 | |
| 544 | 544 |  //var_dump('__'.$reg[1].'__ -> '.$newout);
 | 
| 545 | -            $out = preg_replace('/__' . preg_quote($reg[1], '/') . '__/', $newout, $out);
 | |
| 545 | +            $out = preg_replace('/__'.preg_quote($reg[1], '/').'__/', $newout, $out);
 | |
| 546 | 546 | } | 
| 547 | 547 | } | 
| 548 | 548 | |
| @@ -660,15 +660,15 @@ discard block | ||
| 660 | 660 | else if (isset($_SERVER["SERVER_NAME"])) | 
| 661 | 661 | return $_SERVER["SERVER_NAME"]; | 
| 662 | 662 | } | 
| 663 | - return dol_hash(DOL_DOCUMENT_ROOT . DOL_URL_ROOT); | |
| 663 | + return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT); | |
| 664 | 664 | } | 
| 665 | 665 | |
| 666 | 666 |          if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["DOCUMENT_ROOT"])) {
 | 
| 667 | - return dol_hash($_SERVER["SERVER_NAME"] . $_SERVER["DOCUMENT_ROOT"] . DOL_DOCUMENT_ROOT . DOL_URL_ROOT); | |
| 667 | + return dol_hash($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT); | |
| 668 | 668 | // Use this for a "readable" cookie name | 
| 669 | 669 | //return dol_sanitizeFileName($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT); | 
| 670 | 670 | } | 
| 671 | - return dol_hash(DOL_DOCUMENT_ROOT . DOL_URL_ROOT); | |
| 671 | + return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT); | |
| 672 | 672 | } | 
| 673 | 673 | } | 
| 674 | 674 | |
| @@ -684,12 +684,12 @@ discard block | ||
| 684 | 684 | */ | 
| 685 | 685 | function dol_include_once($relpath, $classname = '') | 
| 686 | 686 |  {
 | 
| 687 | - global $conf, $langs, $user, $mysoc; // Do not remove this. They must be defined for files we include. Other globals var must be retreived with $GLOBALS['var'] | |
| 687 | + global $conf, $langs, $user, $mysoc; // Do not remove this. They must be defined for files we include. Other globals var must be retreived with $GLOBALS['var'] | |
| 688 | 688 | |
| 689 | 689 | $fullpath = dol_buildpath($relpath); | 
| 690 | 690 | |
| 691 | 691 |      if (!file_exists($fullpath)) {
 | 
| 692 | -        dol_syslog('functions::dol_include_once Tried to load unexisting file: ' . $relpath, LOG_ERR);
 | |
| 692 | +        dol_syslog('functions::dol_include_once Tried to load unexisting file: '.$relpath, LOG_ERR);
 | |
| 693 | 693 | return false; | 
| 694 | 694 | } | 
| 695 | 695 | |
| @@ -718,13 +718,13 @@ discard block | ||
| 718 | 718 | |
| 719 | 719 |      if ($type == 0 /* empty($type) */) { // For a filesystem path
 | 
| 720 | 720 | //$res = DOL_BASE_PATH . '' . $path; // Standard default path | 
| 721 | - $res = DOL_BASE_PATH . '/' . $path; // Standard default path | |
| 721 | + $res = DOL_BASE_PATH.'/'.$path; // Standard default path | |
| 722 | 722 |          foreach ($conf->file->dol_document_root as $key => $dirroot) { // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...)
 | 
| 723 | 723 |              if ($key == 'main') {
 | 
| 724 | 724 | continue; | 
| 725 | 725 | } | 
| 726 | -            if (file_exists($dirroot . '/' . $path)) {
 | |
| 727 | - $res = $dirroot . '/' . $path; | |
| 726 | +            if (file_exists($dirroot.'/'.$path)) {
 | |
| 727 | + $res = $dirroot.'/'.$path; | |
| 728 | 728 | return $res; | 
| 729 | 729 | } | 
| 730 | 730 | } | 
| @@ -740,11 +740,11 @@ discard block | ||
| 740 | 740 | // using proxy, rewriting, virtual path, etc... | 
| 741 | 741 | $res = ''; | 
| 742 | 742 | if ($type == 1) | 
| 743 | - $res = /* DOL_URL_ROOT */ DOL_BASE_URI . '/' . $path; // Standard value | |
| 743 | + $res = /* DOL_URL_ROOT */ DOL_BASE_URI.'/'.$path; // Standard value | |
| 744 | 744 | if ($type == 2) | 
| 745 | - $res = /* DOL_MAIN_URL_ROOT */ DOL_BASE_PATH . '/' . $path; // Standard value | |
| 745 | + $res = /* DOL_MAIN_URL_ROOT */ DOL_BASE_PATH.'/'.$path; // Standard value | |
| 746 | 746 | if ($type == 3) | 
| 747 | - $res = DOL_URL_ROOT . '/' . $path; | |
| 747 | + $res = DOL_URL_ROOT.'/'.$path; | |
| 748 | 748 | |
| 749 | 749 |          foreach ($conf->file->dol_document_root as $key => $dirroot) { // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...)
 | 
| 750 | 750 |              if ($key == 'main') {
 | 
| @@ -752,33 +752,33 @@ discard block | ||
| 752 | 752 | global $dolibarr_main_url_root; | 
| 753 | 753 | |
| 754 | 754 | // Define $urlwithroot | 
| 755 | -                    $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', trim($dolibarr_main_url_root));
 | |
| 756 | - $urlwithroot = $urlwithouturlroot . DOL_URL_ROOT; // This is to use external domain name found into config file | |
| 755 | +                    $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
 | |
| 756 | + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file | |
| 757 | 757 | //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current | 
| 758 | 758 | |
| 759 | -                    $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : $urlwithroot) . '/' . $path;     // Test on start with http is for old conf syntax
 | |
| 759 | +                    $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : $urlwithroot).'/'.$path; // Test on start with http is for old conf syntax
 | |
| 760 | 760 | } | 
| 761 | 761 | continue; | 
| 762 | 762 | } | 
| 763 | -            preg_match('/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs);    // Take part before '?'
 | |
| 763 | +            preg_match('/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs); // Take part before '?'
 | |
| 764 | 764 |              if (!empty($regs[1])) {
 | 
| 765 | 765 | //print $key.'-'.$dirroot.'/'.$path.'-'.$conf->file->dol_url_root[$type].'<br>'."\n"; | 
| 766 | -                if (file_exists($dirroot . '/' . $regs[1])) {
 | |
| 766 | +                if (file_exists($dirroot.'/'.$regs[1])) {
 | |
| 767 | 767 |                      if ($type == 1) {
 | 
| 768 | -                        $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : DOL_URL_ROOT) . $conf->file->dol_url_root[$key] . '/' . $path;
 | |
| 768 | +                        $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : DOL_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path;
 | |
| 769 | 769 | } | 
| 770 | 770 |                      if ($type == 2) {
 | 
| 771 | -                        $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : DOL_MAIN_URL_ROOT) . $conf->file->dol_url_root[$key] . '/' . $path;
 | |
| 771 | +                        $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path;
 | |
| 772 | 772 | } | 
| 773 | 773 |                      if ($type == 3) {
 | 
| 774 | 774 | global $dolibarr_main_url_root; | 
| 775 | 775 | |
| 776 | 776 | // Define $urlwithroot | 
| 777 | -                        $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', trim($dolibarr_main_url_root));
 | |
| 778 | - $urlwithroot = $urlwithouturlroot . DOL_URL_ROOT; // This is to use external domain name found into config file | |
| 777 | +                        $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
 | |
| 778 | + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file | |
| 779 | 779 | //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current | 
| 780 | 780 | |
| 781 | -                        $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : $urlwithroot) . $conf->file->dol_url_root[$key] . '/' . $path;     // Test on start with http is for old conf syntax
 | |
| 781 | +                        $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : $urlwithroot).$conf->file->dol_url_root[$key].'/'.$path; // Test on start with http is for old conf syntax
 | |
| 782 | 782 | } | 
| 783 | 783 | break; | 
| 784 | 784 | } | 
| @@ -806,7 +806,7 @@ discard block | ||
| 806 | 806 |      if (empty($native)) {
 | 
| 807 | 807 | $myclone = unserialize(serialize($object)); | 
| 808 | 808 |      } else {
 | 
| 809 | - $myclone = clone $object; // PHP clone is a shallow copy only, not a real clone, so properties of references will keep references (refer to the same target/variable) | |
| 809 | + $myclone = clone $object; // PHP clone is a shallow copy only, not a real clone, so properties of references will keep references (refer to the same target/variable) | |
| 810 | 810 | } | 
| 811 | 811 | |
| 812 | 812 | return $myclone; | 
| @@ -927,7 +927,7 @@ discard block | ||
| 927 | 927 | */ | 
| 928 | 928 | function dol_string_nospecial($str, $newstr = '_', $badcharstoreplace = '') | 
| 929 | 929 |  {
 | 
| 930 | -    $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ",", ";", "=", '°');  // more complete than dol_sanitizeFileName
 | |
| 930 | +    $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ",", ";", "=", '°'); // more complete than dol_sanitizeFileName
 | |
| 931 | 931 | $forbidden_chars_to_remove = array(); | 
| 932 | 932 | if (is_array($badcharstoreplace)) | 
| 933 | 933 | $forbidden_chars_to_replace = $badcharstoreplace; | 
| @@ -990,12 +990,12 @@ discard block | ||
| 990 | 990 | function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0) | 
| 991 | 991 |  {
 | 
| 992 | 992 | // escape quotes and backslashes, newlines, etc. | 
| 993 | - $tmp = html_entity_decode($stringtoescape, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars_decode instead, that make only required change for html tags | |
| 993 | + $tmp = html_entity_decode($stringtoescape, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars_decode instead, that make only required change for html tags | |
| 994 | 994 | if (!$keepb) | 
| 995 | 995 |          $tmp = strtr($tmp, array("<b>" => '', '</b>' => ''));
 | 
| 996 | 996 | if (!$keepn) | 
| 997 | 997 |          $tmp = strtr($tmp, array("\r" => '\\r', "\n" => '\\n'));
 | 
| 998 | - return htmlentities($tmp, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars instead, that make only required change for html tags | |
| 998 | + return htmlentities($tmp, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars instead, that make only required change for html tags | |
| 999 | 999 | } | 
| 1000 | 1000 | |
| 1001 | 1001 | /** | 
| @@ -1066,14 +1066,14 @@ discard block | ||
| 1066 | 1066 |          $message = preg_replace('/password=\'[^\']*\'/', 'password=\'hidden\'', $message); // protection to avoid to have value of password in log
 | 
| 1067 | 1067 | // If adding log inside HTML page is required | 
| 1068 | 1068 |          if (!empty($_REQUEST['logtohtml']) && (!empty($conf->global->MAIN_ENABLE_LOG_TO_HTML) || !empty($conf->global->MAIN_LOGTOHTML))) {   // MAIN_LOGTOHTML kept for backward compatibility
 | 
| 1069 | - $conf->logbuffer[] = dol_print_date(time(), "%Y-%m-%d %H:%M:%S") . " " . $message; | |
| 1069 | + $conf->logbuffer[] = dol_print_date(time(), "%Y-%m-%d %H:%M:%S")." ".$message; | |
| 1070 | 1070 | } | 
| 1071 | 1071 | |
| 1072 | 1072 | //TODO: Remove this. MAIN_ENABLE_LOG_INLINE_HTML should be deprecated and use a log handler dedicated to HTML output | 
| 1073 | 1073 | // If html log tag enabled and url parameter log defined, we show output log on HTML comments | 
| 1074 | 1074 |          if (!empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && !empty($_GET["log"])) {
 | 
| 1075 | 1075 | print "\n\n<!-- Log start\n"; | 
| 1076 | - print $message . "\n"; | |
| 1076 | + print $message."\n"; | |
| 1077 | 1077 | print "Log end -->\n"; | 
| 1078 | 1078 | } | 
| 1079 | 1079 | |
| @@ -1087,7 +1087,7 @@ discard block | ||
| 1087 | 1087 | |
| 1088 | 1088 | // This is when server run behind a reverse proxy | 
| 1089 | 1089 | if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) | 
| 1090 | - $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'] . (empty($_SERVER["REMOTE_ADDR"]) ? '' : '->' . $_SERVER['REMOTE_ADDR']); | |
| 1090 | + $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'].(empty($_SERVER["REMOTE_ADDR"]) ? '' : '->'.$_SERVER['REMOTE_ADDR']); | |
| 1091 | 1091 | // This is when server run normally on a server | 
| 1092 | 1092 | else if (!empty($_SERVER["REMOTE_ADDR"])) | 
| 1093 | 1093 | $data['ip'] = $_SERVER['REMOTE_ADDR']; | 
| @@ -1096,10 +1096,10 @@ discard block | ||
| 1096 | 1096 | $data['ip'] = $_SERVER['SERVER_ADDR']; | 
| 1097 | 1097 | // 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 | 1098 | else if (!empty($_SERVER['COMPUTERNAME'])) | 
| 1099 | - $data['ip'] = $_SERVER['COMPUTERNAME'] . (empty($_SERVER['USERNAME']) ? '' : '@' . $_SERVER['USERNAME']); | |
| 1099 | + $data['ip'] = $_SERVER['COMPUTERNAME'].(empty($_SERVER['USERNAME']) ? '' : '@'.$_SERVER['USERNAME']); | |
| 1100 | 1100 | // 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 | 1101 | else if (!empty($_SERVER['LOGNAME'])) | 
| 1102 | - $data['ip'] = '???@' . $_SERVER['LOGNAME']; | |
| 1102 | + $data['ip'] = '???@'.$_SERVER['LOGNAME']; | |
| 1103 | 1103 | // Loop on each log handler and send output | 
| 1104 | 1104 |          foreach ($conf->loghandlers as $loghandlerinstance) {
 | 
| 1105 | 1105 | if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) | 
| @@ -1151,10 +1151,10 @@ discard block | ||
| 1151 | 1151 |  {
 | 
| 1152 | 1152 | global $conf, $langs, $hookmanager; | 
| 1153 | 1153 | |
| 1154 | - $out = "\n" . '<div class="tabs" data-role="controlgroup" data-type="horizontal">' . "\n"; | |
| 1154 | + $out = "\n".'<div class="tabs" data-role="controlgroup" data-type="horizontal">'."\n"; | |
| 1155 | 1155 | |
| 1156 | 1156 |      if ($morehtmlright) {
 | 
| 1157 | - $out .= '<div class="inline-block floatright tabsElem">' . $morehtmlright . '</div>'; // Output right area first so when space is missing, text is in front of tabs and not under. | |
| 1157 | + $out .= '<div class="inline-block floatright tabsElem">'.$morehtmlright.'</div>'; // Output right area first so when space is missing, text is in front of tabs and not under. | |
| 1158 | 1158 | } | 
| 1159 | 1159 | |
| 1160 | 1160 | // Show title | 
| @@ -1165,8 +1165,8 @@ discard block | ||
| 1165 | 1165 | $limittitle = 30; | 
| 1166 | 1166 | $out .= '<a class="tabTitle">'; | 
| 1167 | 1167 | if ($picto) | 
| 1168 | - $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_') . $picto, '', $pictoisfullpath) . ' '; | |
| 1169 | - $out .= '<span class="tabTitleText">' . dol_trunc($title, $limittitle) . '</span>'; | |
| 1168 | + $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_').$picto, '', $pictoisfullpath).' '; | |
| 1169 | + $out .= '<span class="tabTitleText">'.dol_trunc($title, $limittitle).'</span>'; | |
| 1170 | 1170 | $out .= '</a>'; | 
| 1171 | 1171 | } | 
| 1172 | 1172 | |
| @@ -1206,23 +1206,23 @@ discard block | ||
| 1206 | 1206 | } | 
| 1207 | 1207 | |
| 1208 | 1208 |          if ($i < $limittoshow || $isactive) {
 | 
| 1209 | - $out .= '<div class="inline-block tabsElem' . ($isactive ? ' tabsElemActive' : '') . ((!$isactive && !empty($conf->global->MAIN_HIDE_INACTIVETAB_ON_PRINT)) ? ' hideonprint' : '') . '"><!-- id tab = ' . (empty($links[$i][2]) ? '' : $links[$i][2]) . ' -->'; | |
| 1209 | + $out .= '<div class="inline-block tabsElem'.($isactive ? ' tabsElemActive' : '').((!$isactive && !empty($conf->global->MAIN_HIDE_INACTIVETAB_ON_PRINT)) ? ' hideonprint' : '').'"><!-- id tab = '.(empty($links[$i][2]) ? '' : $links[$i][2]).' -->'; | |
| 1210 | 1210 |              if (isset($links[$i][2]) && $links[$i][2] == 'image') {
 | 
| 1211 | 1211 |                  if (!empty($links[$i][0])) {
 | 
| 1212 | - $out .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n"; | |
| 1212 | + $out .= '<a class="tabimage'.($morecss ? ' '.$morecss : '').'" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n"; | |
| 1213 | 1213 |                  } else {
 | 
| 1214 | - $out .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n"; | |
| 1214 | + $out .= '<span class="tabspan">'.$links[$i][1].'</span>'."\n"; | |
| 1215 | 1215 | } | 
| 1216 | 1216 |              } else if (!empty($links[$i][1])) {
 | 
| 1217 | 1217 | //print "x $i $active ".$links[$i][2]." z"; | 
| 1218 | 1218 |                  if ($isactive) {
 | 
| 1219 | - $out .= '<a' . (!empty($links[$i][2]) ? ' id="' . $links[$i][2] . '"' : '') . ' class="tabactive tab inline-block' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">'; | |
| 1219 | + $out .= '<a'.(!empty($links[$i][2]) ? ' id="'.$links[$i][2].'"' : '').' class="tabactive tab inline-block'.($morecss ? ' '.$morecss : '').'" href="'.$links[$i][0].'">'; | |
| 1220 | 1220 | $out .= $links[$i][1]; | 
| 1221 | - $out .= '</a>' . "\n"; | |
| 1221 | + $out .= '</a>'."\n"; | |
| 1222 | 1222 |                  } else {
 | 
| 1223 | - $out .= '<a' . (!empty($links[$i][2]) ? ' id="' . $links[$i][2] . '"' : '') . ' class="tabunactive tab inline-block' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">'; | |
| 1223 | + $out .= '<a'.(!empty($links[$i][2]) ? ' id="'.$links[$i][2].'"' : '').' class="tabunactive tab inline-block'.($morecss ? ' '.$morecss : '').'" href="'.$links[$i][0].'">'; | |
| 1224 | 1224 | $out .= $links[$i][1]; | 
| 1225 | - $out .= '</a>' . "\n"; | |
| 1225 | + $out .= '</a>'."\n"; | |
| 1226 | 1226 | } | 
| 1227 | 1227 | } | 
| 1228 | 1228 | $out .= '</div>'; | 
| @@ -1235,14 +1235,14 @@ discard block | ||
| 1235 | 1235 | $outmore .= '<div class="popuptab wordwrap" style="display:inherit;">'; | 
| 1236 | 1236 |              if (isset($links[$i][2]) && $links[$i][2] == 'image') {
 | 
| 1237 | 1237 | if (!empty($links[$i][0])) | 
| 1238 | - $outmore .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n"; | |
| 1238 | + $outmore .= '<a class="tabimage'.($morecss ? ' '.$morecss : '').'" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n"; | |
| 1239 | 1239 | else | 
| 1240 | - $outmore .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n"; | |
| 1240 | + $outmore .= '<span class="tabspan">'.$links[$i][1].'</span>'."\n"; | |
| 1241 | 1241 | } | 
| 1242 | 1242 |              else if (!empty($links[$i][1])) {
 | 
| 1243 | - $outmore .= '<a' . (!empty($links[$i][2]) ? ' id="' . $links[$i][2] . '"' : '') . ' class="wordwrap inline-block' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">'; | |
| 1243 | + $outmore .= '<a'.(!empty($links[$i][2]) ? ' id="'.$links[$i][2].'"' : '').' class="wordwrap inline-block'.($morecss ? ' '.$morecss : '').'" href="'.$links[$i][0].'">'; | |
| 1244 | 1244 |                  $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 | - $outmore .= '</a>' . "\n"; | |
| 1245 | + $outmore .= '</a>'."\n"; | |
| 1246 | 1246 | } | 
| 1247 | 1247 | $outmore .= '</div>'; | 
| 1248 | 1248 | |
| @@ -1258,24 +1258,24 @@ discard block | ||
| 1258 | 1258 |          $right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right');
 | 
| 1259 | 1259 | |
| 1260 | 1260 |          $tabsname = str_replace("@", "", $picto);
 | 
| 1261 | - $out .= '<div id="moretabs' . $tabsname . '" class="inline-block tabsElem">'; | |
| 1262 | -        $out .= '<a href="#" class="tab moretab inline-block tabunactive reposition">' . $langs->trans("More") . '... (' . $nbintab . ')</a>';
 | |
| 1263 | - $out .= '<div id="moretabsList' . $tabsname . '" style="position: absolute; ' . $left . ': -999em; text-align: ' . $left . '; margin:0px; padding:2px">'; | |
| 1261 | + $out .= '<div id="moretabs'.$tabsname.'" class="inline-block tabsElem">'; | |
| 1262 | +        $out .= '<a href="#" class="tab moretab inline-block tabunactive reposition">'.$langs->trans("More").'... ('.$nbintab.')</a>';
 | |
| 1263 | + $out .= '<div id="moretabsList'.$tabsname.'" style="position: absolute; '.$left.': -999em; text-align: '.$left.'; margin:0px; padding:2px">'; | |
| 1264 | 1264 | $out .= $outmore; | 
| 1265 | 1265 | $out .= '</div>'; | 
| 1266 | 1266 | $out .= '<div></div>'; | 
| 1267 | 1267 | $out .= "</div>\n"; | 
| 1268 | 1268 | |
| 1269 | 1269 | $out .= "<script>"; | 
| 1270 | -        $out .= "$('#moretabs" . $tabsname . "').mouseenter( function() { console.log('mouseenter " . $left . "'); $('#moretabsList" . $tabsname . "').css('" . $left . "','auto');});";
 | |
| 1271 | -        $out .= "$('#moretabs" . $tabsname . "').mouseleave( function() { console.log('mouseleave " . $left . "'); $('#moretabsList" . $tabsname . "').css('" . $left . "','-999em');});";
 | |
| 1270 | +        $out .= "$('#moretabs".$tabsname."').mouseenter( function() { console.log('mouseenter ".$left."'); $('#moretabsList".$tabsname."').css('".$left."','auto');});";
 | |
| 1271 | +        $out .= "$('#moretabs".$tabsname."').mouseleave( function() { console.log('mouseleave ".$left."'); $('#moretabsList".$tabsname."').css('".$left."','-999em');});";
 | |
| 1272 | 1272 | $out .= "</script>"; | 
| 1273 | 1273 | } | 
| 1274 | 1274 | |
| 1275 | 1275 | $out .= "</div>\n"; | 
| 1276 | 1276 | |
| 1277 | 1277 | if (!$notab || $notab == -1) | 
| 1278 | - $out .= "\n" . '<div class="tabBar' . ($notab == -1 ? '' : ' tabBarWithBottom') . '">' . "\n"; | |
| 1278 | + $out .= "\n".'<div class="tabBar'.($notab == -1 ? '' : ' tabBarWithBottom').'">'."\n"; | |
| 1279 | 1279 | |
| 1280 | 1280 |      $parameters = array('tabname' => $active, 'out' => $out);
 | 
| 1281 | 1281 |      $reshook = $hookmanager->executeHooks('printTabsHead', $parameters); // This hook usage is called just before output the head of tabs. Take also a look at "completeTabsHead"
 | 
| @@ -1384,7 +1384,7 @@ discard block | ||
| 1384 | 1384 | if ($conf->browser->layout == 'phone') | 
| 1385 | 1385 | $maxvisiblephotos = 1; | 
| 1386 | 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>';
 | |
| 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 | 1388 |          else {
 | 
| 1389 | 1389 |              if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) {
 | 
| 1390 | 1390 | $nophoto = ''; | 
| @@ -1393,18 +1393,18 @@ discard block | ||
| 1393 | 1393 |              //elseif ($conf->browser->layout != 'phone') {    // Show no photo link
 | 
| 1394 | 1394 | $nophoto = '/public/theme/common/nophoto.png'; | 
| 1395 | 1395 | // $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" border="0"' . ($width ? ' width="' . $width . '"' : '') . ' src="' . DOL_URL_ROOT . $nophoto . '"></div>'; | 
| 1396 | - $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" border="0"' . ($width ? ' width="' . $width . '"' : '') . ' src="' . DOL_BASE_URI . $nophoto . '"></div>'; | |
| 1396 | + $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').'" alt="No photo" border="0"'.($width ? ' width="'.$width.'"' : '').' src="'.DOL_BASE_URI.$nophoto.'"></div>'; | |
| 1397 | 1397 | //} | 
| 1398 | 1398 | } | 
| 1399 | 1399 |      } elseif ($object->element == 'ticket') {
 | 
| 1400 | 1400 | $width = 80; | 
| 1401 | 1401 | $cssclass = 'photoref'; | 
| 1402 | - $showimage = $object->is_photo_available($conf->ticket->multidir_output[$entity] . '/' . $object->track_id); | |
| 1402 | + $showimage = $object->is_photo_available($conf->ticket->multidir_output[$entity].'/'.$object->track_id); | |
| 1403 | 1403 | $maxvisiblephotos = (isset($conf->global->TICKETSUP_MAX_VISIBLE_PHOTO) ? $conf->global->TICKETSUP_MAX_VISIBLE_PHOTO : 2); | 
| 1404 | 1404 | if ($conf->browser->layout == 'phone') | 
| 1405 | 1405 | $maxvisiblephotos = 1; | 
| 1406 | 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>';
 | |
| 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 | 1408 |          else {
 | 
| 1409 | 1409 |              if (!empty($conf->global->TICKETSUP_NODISPLAYIFNOPHOTO)) {
 | 
| 1410 | 1410 | $nophoto = ''; | 
| @@ -1413,7 +1413,7 @@ discard block | ||
| 1413 | 1413 |              //elseif ($conf->browser->layout != 'phone') {    // Show no photo link
 | 
| 1414 | 1414 | $nophoto = '/public/theme/common/nophoto.png'; | 
| 1415 | 1415 | //$morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" border="0"' . ($width ? ' width="' . $width . '"' : '') . ' src="' . DOL_URL_ROOT . $nophoto . '"></div>'; | 
| 1416 | - $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" border="0"' . ($width ? ' width="' . $width . '"' : '') . ' src="' . DOL_BASE_URI . $nophoto . '"></div>'; | |
| 1416 | + $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').'" alt="No photo" border="0"'.($width ? ' width="'.$width.'"' : '').' src="'.DOL_BASE_URI.$nophoto.'"></div>'; | |
| 1417 | 1417 | //} | 
| 1418 | 1418 | } | 
| 1419 | 1419 |      } else {
 | 
| @@ -1423,25 +1423,25 @@ discard block | ||
| 1423 | 1423 | // Check if a preview file is available | 
| 1424 | 1424 |                  if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter', 'contract', 'supplier_order', 'supplier_proposal', 'supplier_invoice', 'expensereport')) && class_exists("Imagick")) {
 | 
| 1425 | 1425 | $objectref = dol_sanitizeFileName($object->ref); | 
| 1426 | - $dir_output = (empty($conf->$modulepart->multidir_output[$entity]) ? $conf->$modulepart->dir_output : $conf->$modulepart->multidir_output[$entity]) . "/"; | |
| 1426 | + $dir_output = (empty($conf->$modulepart->multidir_output[$entity]) ? $conf->$modulepart->dir_output : $conf->$modulepart->multidir_output[$entity])."/"; | |
| 1427 | 1427 |                      if (in_array($modulepart, array('invoice_supplier', 'supplier_invoice'))) {
 | 
| 1428 | 1428 | $subdir = get_exdir($object->id, 2, 0, 1, $object, $modulepart); | 
| 1429 | -                        $subdir .= ((!empty($subdir) && !preg_match('/\/$/', $subdir)) ? '/' : '') . $objectref;  // the objectref dir is not included into get_exdir when used with level=2, so we add it at end
 | |
| 1429 | +                        $subdir .= ((!empty($subdir) && !preg_match('/\/$/', $subdir)) ? '/' : '').$objectref; // the objectref dir is not included into get_exdir when used with level=2, so we add it at end
 | |
| 1430 | 1430 |                      } else {
 | 
| 1431 | 1431 | $subdir = get_exdir($object->id, 0, 0, 1, $object, $modulepart); | 
| 1432 | 1432 | } | 
| 1433 | 1433 | if (empty($subdir)) | 
| 1434 | 1434 | $subdir = 'errorgettingsubdirofobject'; // Protection to avoid to return empty path | 
| 1435 | 1435 | |
| 1436 | - $filepath = $dir_output . $subdir . "/"; | |
| 1436 | + $filepath = $dir_output.$subdir."/"; | |
| 1437 | 1437 | |
| 1438 | - $file = $filepath . $objectref . ".pdf"; | |
| 1439 | - $relativepath = $subdir . '/' . $objectref . '.pdf'; | |
| 1438 | + $file = $filepath.$objectref.".pdf"; | |
| 1439 | + $relativepath = $subdir.'/'.$objectref.'.pdf'; | |
| 1440 | 1440 | |
| 1441 | 1441 | // Define path to preview pdf file (preview precompiled "file.ext" are "file.ext_preview.png") | 
| 1442 | - $fileimage = $file . '_preview.png'; // If PDF has 1 page | |
| 1443 | - $fileimagebis = $file . '_preview-0.png'; // If PDF has more than one page | |
| 1444 | - $relativepathimage = $relativepath . '_preview.png'; | |
| 1442 | + $fileimage = $file.'_preview.png'; // If PDF has 1 page | |
| 1443 | + $fileimagebis = $file.'_preview-0.png'; // If PDF has more than one page | |
| 1444 | + $relativepathimage = $relativepath.'_preview.png'; | |
| 1445 | 1445 | |
| 1446 | 1446 | // Si fichier PDF existe | 
| 1447 | 1447 |                      if (file_exists($file)) {
 | 
| @@ -1450,7 +1450,7 @@ discard block | ||
| 1450 | 1450 | if ((!file_exists($fileimage) || (filemtime($fileimage) < filemtime($file))) && (!file_exists($fileimagebis) || (filemtime($fileimagebis) < filemtime($file))) | 
| 1451 | 1451 |                          ) {
 | 
| 1452 | 1452 |                              if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) {  // If you experienc trouble with pdf thumb generation and imagick, you can disable here.
 | 
| 1453 | - include_once DOL_BASE_PATH . '/core/lib/files.lib.php'; | |
| 1453 | + include_once DOL_BASE_PATH.'/core/lib/files.lib.php'; | |
| 1454 | 1454 | $ret = dol_convert_file($file, 'png', $fileimage); | 
| 1455 | 1455 | if ($ret < 0) | 
| 1456 | 1456 | $error++; | 
| @@ -1463,14 +1463,14 @@ discard block | ||
| 1463 | 1463 | // Si fichier png PDF d'1 page trouve | 
| 1464 | 1464 |                          if (file_exists($fileimage)) {
 | 
| 1465 | 1465 | $phototoshow = '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">'; | 
| 1466 | - $phototoshow .= '<img height="' . $heightforphotref . '" class="photo photowithmargin photowithborder" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=apercu' . $modulepart . '&file=' . urlencode($relativepathimage) . '">'; | |
| 1466 | + $phototoshow .= '<img height="'.$heightforphotref.'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=apercu'.$modulepart.'&file='.urlencode($relativepathimage).'">'; | |
| 1467 | 1467 | $phototoshow .= '</div></div>'; | 
| 1468 | 1468 | } | 
| 1469 | 1469 | // Si fichier png PDF de plus d'1 page trouve | 
| 1470 | 1470 |                          elseif (file_exists($fileimagebis)) {
 | 
| 1471 | -                            $preview = preg_replace('/\.png/', '', $relativepathimage) . "-0.png";
 | |
| 1471 | +                            $preview = preg_replace('/\.png/', '', $relativepathimage)."-0.png";
 | |
| 1472 | 1472 | $phototoshow = '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">'; | 
| 1473 | - $phototoshow .= '<img height="' . $heightforphotref . '" class="photo photowithmargin photowithborder" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=apercu' . $modulepart . '&file=' . urlencode($preview) . '"><p>'; | |
| 1473 | + $phototoshow .= '<img height="'.$heightforphotref.'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=apercu'.$modulepart.'&file='.urlencode($preview).'"><p>'; | |
| 1474 | 1474 | $phototoshow .= '</div></div>'; | 
| 1475 | 1475 | } | 
| 1476 | 1476 | } | 
| @@ -1497,10 +1497,10 @@ discard block | ||
| 1497 | 1497 | $picto = $object->picto; | 
| 1498 | 1498 | if ($object->element == 'project' && !$object->public) | 
| 1499 | 1499 | $picto = 'project'; // instead of projectpub | 
| 1500 | -                    $nophoto = img_picto('', 'object_' . $picto, '', false, 1);
 | |
| 1500 | +                    $nophoto = img_picto('', 'object_'.$picto, '', false, 1);
 | |
| 1501 | 1501 | } | 
| 1502 | 1502 | $morehtmlleft .= '<!-- No photo to show -->'; | 
| 1503 | - $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" border="0"' . ($width ? ' width="' . $width . '"' : '') . ' src="' . $nophoto . '"></div></div>'; | |
| 1503 | + $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').'" alt="No photo" border="0"'.($width ? ' width="'.$width.'"' : '').' src="'.$nophoto.'"></div></div>'; | |
| 1504 | 1504 | |
| 1505 | 1505 | $morehtmlleft .= '</div>'; | 
| 1506 | 1506 | } | 
| @@ -1508,7 +1508,7 @@ discard block | ||
| 1508 | 1508 | } | 
| 1509 | 1509 | |
| 1510 | 1510 | if ($showbarcode) | 
| 1511 | - $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $form->showbarcode($object) . '</div>'; | |
| 1511 | + $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode($object).'</div>'; | |
| 1512 | 1512 | |
| 1513 | 1513 |      if ($object->element == 'societe') {
 | 
| 1514 | 1514 |          if (!empty($conf->use_javascript_ajax) && $user->rights->societe->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
 | 
| @@ -1521,14 +1521,14 @@ discard block | ||
| 1521 | 1521 |          if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
 | 
| 1522 | 1522 | $morehtmlstatus .= ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); | 
| 1523 | 1523 |          } else {
 | 
| 1524 | - $morehtmlstatus .= '<span class="statusrefsell">' . $object->getLibStatut(5, 0) . '</span>'; | |
| 1524 | + $morehtmlstatus .= '<span class="statusrefsell">'.$object->getLibStatut(5, 0).'</span>'; | |
| 1525 | 1525 | } | 
| 1526 | 1526 | $morehtmlstatus .= '   '; | 
| 1527 | 1527 |          //$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Buy").') ';
 | 
| 1528 | 1528 |          if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
 | 
| 1529 | 1529 | $morehtmlstatus .= ajax_object_onoff($object, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); | 
| 1530 | 1530 |          } else {
 | 
| 1531 | - $morehtmlstatus .= '<span class="statusrefbuy">' . $object->getLibStatut(5, 1) . '</span>'; | |
| 1531 | + $morehtmlstatus .= '<span class="statusrefbuy">'.$object->getLibStatut(5, 1).'</span>'; | |
| 1532 | 1532 | } | 
| 1533 | 1533 |      } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) {
 | 
| 1534 | 1534 | $tmptxt = $object->getLibStatut(6, $object->totalpaye); | 
| @@ -1555,7 +1555,7 @@ discard block | ||
| 1555 | 1555 | if ($object->progress >= 100) | 
| 1556 | 1556 | $object->fk_statut = 3; | 
| 1557 | 1557 | $tmptxt = $object->getLibStatut(5); | 
| 1558 | - $morehtmlstatus .= $tmptxt; // No status on task | |
| 1558 | + $morehtmlstatus .= $tmptxt; // No status on task | |
| 1559 | 1559 | } | 
| 1560 | 1560 |      else { // Generic case
 | 
| 1561 | 1561 | $tmptxt = $object->getLibStatut(6); | 
| @@ -1569,18 +1569,18 @@ discard block | ||
| 1569 | 1569 |          if (method_exists($object, 'getVentilExportCompta')) {
 | 
| 1570 | 1570 | $accounted = $object->getVentilExportCompta(); | 
| 1571 | 1571 |              $langs->load("accountancy");
 | 
| 1572 | -            $morehtmlstatus .= '</div><div class="statusref statusrefbis">' . ($accounted > 0 ? $langs->trans("Accounted") : $langs->trans("NotYetAccounted"));
 | |
| 1572 | +            $morehtmlstatus .= '</div><div class="statusref statusrefbis">'.($accounted > 0 ? $langs->trans("Accounted") : $langs->trans("NotYetAccounted"));
 | |
| 1573 | 1573 | } | 
| 1574 | 1574 | } | 
| 1575 | 1575 | |
| 1576 | 1576 | // Add alias for thirdparty | 
| 1577 | 1577 | if (!empty($object->name_alias)) | 
| 1578 | - $morehtmlref .= '<div class="refidno">' . $object->name_alias . '</div>'; | |
| 1578 | + $morehtmlref .= '<div class="refidno">'.$object->name_alias.'</div>'; | |
| 1579 | 1579 | |
| 1580 | 1580 | // Add label | 
| 1581 | 1581 |      if ($object->element == 'product' || $object->element == 'bank_account' || $object->element == 'project_task') {
 | 
| 1582 | 1582 | if (!empty($object->label)) | 
| 1583 | - $morehtmlref .= '<div class="refidno">' . $object->label . '</div>'; | |
| 1583 | + $morehtmlref .= '<div class="refidno">'.$object->label.'</div>'; | |
| 1584 | 1584 | } | 
| 1585 | 1585 | |
| 1586 | 1586 |      if (method_exists($object, 'getBannerAddress') && $object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories' && $object->element != 'ecm_files') {
 | 
| @@ -1590,11 +1590,11 @@ discard block | ||
| 1590 | 1590 | } | 
| 1591 | 1591 |      if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && in_array($object->element, array('societe', 'contact', 'member', 'product'))) {
 | 
| 1592 | 1592 | $morehtmlref .= '<div style="clear: both;"></div><div class="refidno">'; | 
| 1593 | -        $morehtmlref .= $langs->trans("TechnicalID") . ': ' . $object->id;
 | |
| 1593 | +        $morehtmlref .= $langs->trans("TechnicalID").': '.$object->id;
 | |
| 1594 | 1594 | $morehtmlref .= '</div>'; | 
| 1595 | 1595 | } | 
| 1596 | 1596 | |
| 1597 | - print '<div class="' . ($onlybanner ? 'arearefnobottom ' : 'arearef ') . 'heightref valignmiddle" width="100%">'; | |
| 1597 | + print '<div class="'.($onlybanner ? 'arearefnobottom ' : 'arearef ').'heightref valignmiddle" width="100%">'; | |
| 1598 | 1598 | print $form->showrefnav($object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright); | 
| 1599 | 1599 | print '</div>'; | 
| 1600 | 1600 | print '<div class="underrefbanner clearboth"></div>'; | 
| @@ -1616,7 +1616,7 @@ discard block | ||
| 1616 | 1616 | if ($fieldrequired) | 
| 1617 | 1617 | $ret .= '<span class="fieldrequired">'; | 
| 1618 | 1618 | if (($conf->dol_use_jmobile != 4)) | 
| 1619 | - $ret .= '<label for="' . $fieldkey . '">'; | |
| 1619 | + $ret .= '<label for="'.$fieldkey.'">'; | |
| 1620 | 1620 | $ret .= $langs->trans($langkey); | 
| 1621 | 1621 | if (($conf->dol_use_jmobile != 4)) | 
| 1622 | 1622 | $ret .= '</label>'; | 
| @@ -1635,9 +1635,9 @@ discard block | ||
| 1635 | 1635 | function dol_bc($var, $moreclass = '') | 
| 1636 | 1636 |  {
 | 
| 1637 | 1637 | global $bc; | 
| 1638 | - $ret = ' ' . $bc[$var]; | |
| 1638 | + $ret = ' '.$bc[$var]; | |
| 1639 | 1639 | if ($moreclass) | 
| 1640 | -        $ret = preg_replace('/class=\"/', 'class="' . $moreclass . ' ', $ret);
 | |
| 1640 | +        $ret = preg_replace('/class=\"/', 'class="'.$moreclass.' ', $ret);
 | |
| 1641 | 1641 | return $ret; | 
| 1642 | 1642 | } | 
| 1643 | 1643 | |
| @@ -1657,50 +1657,50 @@ discard block | ||
| 1657 | 1657 | global $conf, $langs; | 
| 1658 | 1658 | |
| 1659 | 1659 | $ret = ''; | 
| 1660 | -    $countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR');    // See also MAIN_FORCE_STATE_INTO_ADDRESS
 | |
| 1660 | +    $countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR'); // See also MAIN_FORCE_STATE_INTO_ADDRESS
 | |
| 1661 | 1661 | // Address | 
| 1662 | 1662 |      if (empty($mode)) {
 | 
| 1663 | 1663 | $ret .= $object->address; | 
| 1664 | 1664 | } | 
| 1665 | 1665 | // Zip/Town/State | 
| 1666 | 1666 |      if (in_array($object->country_code, array('AU', 'CA', 'US')) || !empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) {    // US: title firstname name \n address lines \n town, state, zip \n country
 | 
| 1667 | - $ret .= ($ret ? $sep : '' ) . $object->town; | |
| 1667 | + $ret .= ($ret ? $sep : '').$object->town; | |
| 1668 | 1668 |          if ($object->state) {
 | 
| 1669 | - $ret .= ($ret ? ", " : '') . $object->state; | |
| 1669 | + $ret .= ($ret ? ", " : '').$object->state; | |
| 1670 | 1670 | } | 
| 1671 | 1671 | if ($object->zip) | 
| 1672 | - $ret .= ($ret ? ", " : '') . $object->zip; | |
| 1672 | + $ret .= ($ret ? ", " : '').$object->zip; | |
| 1673 | 1673 | } | 
| 1674 | 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
 | 
| 1675 | - $ret .= ($ret ? $sep : '' ) . $object->town; | |
| 1675 | + $ret .= ($ret ? $sep : '').$object->town; | |
| 1676 | 1676 |          if ($object->state) {
 | 
| 1677 | - $ret .= ($ret ? ", " : '') . $object->state; | |
| 1677 | + $ret .= ($ret ? ", " : '').$object->state; | |
| 1678 | 1678 | } | 
| 1679 | 1679 | if ($object->zip) | 
| 1680 | - $ret .= ($ret ? $sep : '' ) . $object->zip; | |
| 1680 | + $ret .= ($ret ? $sep : '').$object->zip; | |
| 1681 | 1681 | } | 
| 1682 | 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
 | 
| 1683 | - $ret .= ($ret ? $sep : '' ) . $object->zip; | |
| 1684 | - $ret .= ($object->town ? (($object->zip ? ' ' : '') . $object->town) : ''); | |
| 1683 | + $ret .= ($ret ? $sep : '').$object->zip; | |
| 1684 | + $ret .= ($object->town ? (($object->zip ? ' ' : '').$object->town) : ''); | |
| 1685 | 1685 |          if ($object->state) {
 | 
| 1686 | - $ret .= "\n" . $object->state; | |
| 1686 | + $ret .= "\n".$object->state; | |
| 1687 | 1687 | } | 
| 1688 | 1688 |      } else if (in_array($object->country_code, array('IT'))) { // IT: tile firstname name\n address lines \n zip (Code Departement) \n country
 | 
| 1689 | - $ret .= ($ret ? $sep : '' ) . $object->zip; | |
| 1690 | - $ret .= ($object->town ? (($object->zip ? ' ' : '') . $object->town) : ''); | |
| 1691 | -        $ret .= ($object->departement_id ? (' (' . ($object->departement_id) . ')') : '');
 | |
| 1689 | + $ret .= ($ret ? $sep : '').$object->zip; | |
| 1690 | + $ret .= ($object->town ? (($object->zip ? ' ' : '').$object->town) : ''); | |
| 1691 | +        $ret .= ($object->departement_id ? (' ('.($object->departement_id).')') : '');
 | |
| 1692 | 1692 |      } else {                                          // Other: title firstname name \n address lines \n zip town \n country
 | 
| 1693 | - $ret .= $object->zip ? (($ret ? $sep : '' ) . $object->zip) : ''; | |
| 1694 | - $ret .= ($object->town ? (($object->zip ? ' ' : ($ret ? $sep : '' )) . $object->town) : ''); | |
| 1693 | + $ret .= $object->zip ? (($ret ? $sep : '').$object->zip) : ''; | |
| 1694 | + $ret .= ($object->town ? (($object->zip ? ' ' : ($ret ? $sep : '')).$object->town) : ''); | |
| 1695 | 1695 |          if ($object->state && in_array($object->country_code, $countriesusingstate)) {
 | 
| 1696 | - $ret .= ($ret ? ", " : '') . $object->state; | |
| 1696 | + $ret .= ($ret ? ", " : '').$object->state; | |
| 1697 | 1697 | } | 
| 1698 | 1698 | } | 
| 1699 | 1699 | if (!is_object($outputlangs)) | 
| 1700 | 1700 | $outputlangs = $langs; | 
| 1701 | 1701 |      if ($withcountry) {
 | 
| 1702 | 1702 |          $langs->load("dict");
 | 
| 1703 | -        $ret .= ($object->country_code ? ($ret ? $sep : '') . $outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country" . $object->country_code)) : '');
 | |
| 1703 | +        $ret .= ($object->country_code ? ($ret ? $sep : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code)) : '');
 | |
| 1704 | 1704 | } | 
| 1705 | 1705 | |
| 1706 | 1706 | return $ret; | 
| @@ -1755,13 +1755,13 @@ discard block | ||
| 1755 | 1755 |          if (is_string($tzoutput)) {
 | 
| 1756 | 1756 |              if ($tzoutput == 'tzserver') {
 | 
| 1757 | 1757 | $to_gmt = false; | 
| 1758 | - $offsettzstring = @date_default_timezone_get(); // Example 'Europe/Berlin' or 'Indian/Reunion' | |
| 1758 | + $offsettzstring = @date_default_timezone_get(); // Example 'Europe/Berlin' or 'Indian/Reunion' | |
| 1759 | 1759 | $offsettz = 0; | 
| 1760 | 1760 | $offsetdst = 0; | 
| 1761 | 1761 |              } elseif ($tzoutput == 'tzuser' || $tzoutput == 'tzuserrel') {
 | 
| 1762 | 1762 | $to_gmt = true; | 
| 1763 | 1763 | $offsettzstring = (empty($_SESSION['dol_tz_string']) ? 'UTC' : $_SESSION['dol_tz_string']); // Example 'Europe/Berlin' or 'Indian/Reunion' | 
| 1764 | - $offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60; // Will not be used anymore | |
| 1764 | + $offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60; // Will not be used anymore | |
| 1765 | 1765 | $offsetdst = (empty($_SESSION['dol_dst']) ? 0 : $_SESSION['dol_dst']) * 60 * 60; // Will not be used anymore | 
| 1766 | 1766 | } | 
| 1767 | 1767 | } | 
| @@ -1807,9 +1807,9 @@ discard block | ||
| 1807 | 1807 | else if ($format == 'dayxcard') | 
| 1808 | 1808 | $format = '%Y%m%d'; | 
| 1809 | 1809 | else if ($format == 'dayrfc') | 
| 1810 | - $format = '%Y-%m-%d'; // DATE_RFC3339 | |
| 1810 | + $format = '%Y-%m-%d'; // DATE_RFC3339 | |
| 1811 | 1811 | else if ($format == 'dayhourrfc') | 
| 1812 | - $format = '%Y-%m-%dT%H:%M:%SZ'; // DATETIME RFC3339 | |
| 1812 | + $format = '%Y-%m-%dT%H:%M:%SZ'; // DATETIME RFC3339 | |
| 1813 | 1813 | else if ($format == 'standard') | 
| 1814 | 1814 | $format = '%Y-%m-%d %H:%M:%S'; | 
| 1815 | 1815 | |
| @@ -1820,7 +1820,7 @@ discard block | ||
| 1820 | 1820 | |
| 1821 | 1821 | // If date undefined or "", we return "" | 
| 1822 | 1822 | if (dol_strlen($time) == 0) | 
| 1823 | - return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) | |
| 1823 | + return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) | |
| 1824 | 1824 | |
| 1825 | 1825 | |
| 1826 | 1826 | |
| @@ -1851,7 +1851,7 @@ discard block | ||
| 1851 | 1851 |      if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg) || preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i', $time, $reg)) { // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000
 | 
| 1852 | 1852 | // TODO Remove this. | 
| 1853 | 1853 | // This part of code should not be used. | 
| 1854 | -        dol_syslog("Functions.lib::dol_print_date function call with deprecated value of time in page " . $_SERVER["PHP_SELF"], LOG_ERR);
 | |
| 1854 | +        dol_syslog("Functions.lib::dol_print_date function call with deprecated value of time in page ".$_SERVER["PHP_SELF"], LOG_ERR);
 | |
| 1855 | 1855 | // Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' or 'YYYYMMDDHHMMSS' | 
| 1856 | 1856 | $syear = (!empty($reg[1]) ? $reg[1] : ''); | 
| 1857 | 1857 | $smonth = (!empty($reg[2]) ? $reg[2] : ''); | 
| @@ -1869,7 +1869,7 @@ discard block | ||
| 1869 | 1869 | |
| 1870 | 1870 | $ret = adodb_strftime($format, $timetouse, $to_gmt); | 
| 1871 | 1871 | } else | 
| 1872 | - $ret = 'Bad value ' . $time . ' for date'; | |
| 1872 | + $ret = 'Bad value '.$time.' for date'; | |
| 1873 | 1873 | } | 
| 1874 | 1874 | |
| 1875 | 1875 |      if (preg_match('/__b__/i', $format)) {
 | 
| @@ -1878,11 +1878,11 @@ discard block | ||
| 1878 | 1878 |          $month = adodb_strftime('%m', $timetouse);
 | 
| 1879 | 1879 |          $month = sprintf("%02d", $month); // $month may be return with format '06' on some installation and '6' on other, so we force it to '06'.
 | 
| 1880 | 1880 |          if ($encodetooutput) {
 | 
| 1881 | -            $monthtext = $outputlangs->transnoentities('Month' . $month);
 | |
| 1882 | -            $monthtextshort = $outputlangs->transnoentities('MonthShort' . $month);
 | |
| 1881 | +            $monthtext = $outputlangs->transnoentities('Month'.$month);
 | |
| 1882 | +            $monthtextshort = $outputlangs->transnoentities('MonthShort'.$month);
 | |
| 1883 | 1883 |          } else {
 | 
| 1884 | -            $monthtext = $outputlangs->transnoentitiesnoconv('Month' . $month);
 | |
| 1885 | -            $monthtextshort = $outputlangs->transnoentitiesnoconv('MonthShort' . $month);
 | |
| 1884 | +            $monthtext = $outputlangs->transnoentitiesnoconv('Month'.$month);
 | |
| 1885 | +            $monthtextshort = $outputlangs->transnoentitiesnoconv('MonthShort'.$month);
 | |
| 1886 | 1886 | } | 
| 1887 | 1887 | //print 'monthtext='.$monthtext.' monthtextshort='.$monthtextshort; | 
| 1888 | 1888 |          $ret = str_replace('__b__', $monthtextshort, $ret);
 | 
| @@ -1893,8 +1893,8 @@ discard block | ||
| 1893 | 1893 |      if (preg_match('/__a__/i', $format)) {
 | 
| 1894 | 1894 | $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. | 
| 1895 | 1895 | |
| 1896 | -        $w = adodb_strftime('%w', $timetouse);      // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring.
 | |
| 1897 | -        $dayweek = $outputlangs->transnoentitiesnoconv('Day' . $w);
 | |
| 1896 | +        $w = adodb_strftime('%w', $timetouse); // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring.
 | |
| 1897 | +        $dayweek = $outputlangs->transnoentitiesnoconv('Day'.$w);
 | |
| 1898 | 1898 |          $ret = str_replace('__A__', $dayweek, $ret);
 | 
| 1899 | 1899 |          $ret = str_replace('__a__', dol_substr($dayweek, 0, 3), $ret);
 | 
| 1900 | 1900 | } | 
| @@ -1941,9 +1941,9 @@ discard block | ||
| 1941 | 1941 | |
| 1942 | 1942 | $usealternatemethod = false; | 
| 1943 | 1943 | if ($timestamp <= 0) | 
| 1944 | - $usealternatemethod = true; // <= 1970 | |
| 1944 | + $usealternatemethod = true; // <= 1970 | |
| 1945 | 1945 | if ($timestamp >= 2145913200) | 
| 1946 | - $usealternatemethod = true; // >= 2038 | |
| 1946 | + $usealternatemethod = true; // >= 2038 | |
| 1947 | 1947 | |
| 1948 | 1948 |      if ($usealternatemethod) {
 | 
| 1949 | 1949 | $arrayinfo = adodb_getdate($timestamp, $fast); | 
| @@ -2003,23 +2003,23 @@ discard block | ||
| 2003 | 2003 | |
| 2004 | 2004 |      if (method_exists('DateTime', 'getTimestamp')) {
 | 
| 2005 | 2005 |          if (empty($gm) || $gm === 'server') {
 | 
| 2006 | - $default_timezone = @date_default_timezone_get(); // Example 'Europe/Berlin' | |
| 2006 | + $default_timezone = @date_default_timezone_get(); // Example 'Europe/Berlin' | |
| 2007 | 2007 | $localtz = new DateTimeZone($default_timezone); | 
| 2008 | 2008 |          } else if ($gm === 'user') {
 | 
| 2009 | 2009 | // We use dol_tz_string first because it is more reliable. | 
| 2010 | - $default_timezone = (empty($_SESSION["dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION["dol_tz_string"]); // Example 'Europe/Berlin' | |
| 2010 | + $default_timezone = (empty($_SESSION["dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION["dol_tz_string"]); // Example 'Europe/Berlin' | |
| 2011 | 2011 |              try {
 | 
| 2012 | 2012 | $localtz = new DateTimeZone($default_timezone); | 
| 2013 | 2013 |              } catch (Exception $e) {
 | 
| 2014 | -                dol_syslog("Warning dol_tz_string contains an invalid value " . $_SESSION["dol_tz_string"], LOG_WARNING);
 | |
| 2014 | +                dol_syslog("Warning dol_tz_string contains an invalid value ".$_SESSION["dol_tz_string"], LOG_WARNING);
 | |
| 2015 | 2015 | $default_timezone = @date_default_timezone_get(); | 
| 2016 | 2016 | } | 
| 2017 | 2017 |          } else if (strrpos($gm, "tz,") !== false) {
 | 
| 2018 | -            $timezone = str_replace("tz,", "", $gm);  // Example 'tz,Europe/Berlin'
 | |
| 2018 | +            $timezone = str_replace("tz,", "", $gm); // Example 'tz,Europe/Berlin'
 | |
| 2019 | 2019 |              try {
 | 
| 2020 | 2020 | $localtz = new DateTimeZone($timezone); | 
| 2021 | 2021 |              } catch (Exception $e) {
 | 
| 2022 | -                dol_syslog("Warning passed timezone contains an invalid value " . $timezone, LOG_WARNING);
 | |
| 2022 | +                dol_syslog("Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING);
 | |
| 2023 | 2023 | } | 
| 2024 | 2024 | } | 
| 2025 | 2025 | |
| @@ -2058,8 +2058,8 @@ discard block | ||
| 2058 | 2058 | if ($mode == 'gmt') | 
| 2059 | 2059 | $ret = time(); // Time for now at greenwich. | 
| 2060 | 2060 |      else if ($mode == 'tzserver') {  // Time for now with PHP server timezone added
 | 
| 2061 | - require_once DOL_BASE_PATH . '/core/lib/date.lib.php'; | |
| 2062 | -        $tzsecond = getServerTimeZoneInt('now');    // Contains tz+dayling saving time
 | |
| 2061 | + require_once DOL_BASE_PATH.'/core/lib/date.lib.php'; | |
| 2062 | +        $tzsecond = getServerTimeZoneInt('now'); // Contains tz+dayling saving time
 | |
| 2063 | 2063 |          $ret = (int) (dol_now('gmt') + ($tzsecond * 3600));
 | 
| 2064 | 2064 | } | 
| 2065 | 2065 | /* else if ($mode == 'tzref') // Time for now with parent company timezone is added | 
| @@ -2105,9 +2105,9 @@ discard block | ||
| 2105 | 2105 | } | 
| 2106 | 2106 | // Use long or short text unit | 
| 2107 | 2107 |      if (empty($shortunit)) {
 | 
| 2108 | - $ret .= ' ' . $textunitlong; | |
| 2108 | + $ret .= ' '.$textunitlong; | |
| 2109 | 2109 |      } else {
 | 
| 2110 | - $ret .= ' ' . $textunitshort; | |
| 2110 | + $ret .= ' '.$textunitshort; | |
| 2111 | 2111 | } | 
| 2112 | 2112 | |
| 2113 | 2113 | return $ret; | 
| @@ -2135,13 +2135,13 @@ discard block | ||
| 2135 | 2135 | $link .= $url; | 
| 2136 | 2136 | $link .= '"'; | 
| 2137 | 2137 | if ($target) | 
| 2138 | - $link .= ' target="' . $target . '"'; | |
| 2138 | + $link .= ' target="'.$target.'"'; | |
| 2139 | 2139 | $link .= '>'; | 
| 2140 | 2140 |      if (!preg_match('/^http/i', $url))
 | 
| 2141 | 2141 | $link .= 'http://'; | 
| 2142 | 2142 | $link .= dol_trunc($url, $max); | 
| 2143 | 2143 | $link .= '</a>'; | 
| 2144 | -    return '<div class="nospan float" style="margin-right: 10px">' . ($withpicto ? img_picto($langs->trans("Url"), 'object_globe.png') . ' ' : '') . $link . '</div>';
 | |
| 2144 | +    return '<div class="nospan float" style="margin-right: 10px">'.($withpicto ? img_picto($langs->trans("Url"), 'object_globe.png').' ' : '').$link.'</div>';
 | |
| 2145 | 2145 | } | 
| 2146 | 2146 | |
| 2147 | 2147 | /** | 
| @@ -2182,9 +2182,9 @@ discard block | ||
| 2182 | 2182 | $type = 'AC_EMAIL'; | 
| 2183 | 2183 | $link = ''; | 
| 2184 | 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>';
 | |
| 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 | 2186 | if ($link) | 
| 2187 | - $newemail = '<div>' . $newemail . ' ' . $link . '</div>'; | |
| 2187 | + $newemail = '<div>'.$newemail.' '.$link.'</div>'; | |
| 2188 | 2188 | } | 
| 2189 | 2189 | } | 
| 2190 | 2190 |      else {
 | 
| @@ -2194,7 +2194,7 @@ discard block | ||
| 2194 | 2194 | } | 
| 2195 | 2195 | } | 
| 2196 | 2196 | |
| 2197 | -    $rep = '<div class="nospan float" style="margin-right: 10px">' . ($withpicto ? img_picto($langs->trans("EMail"), 'object_email.png') . ' ' : '') . $newemail . '</div>';
 | |
| 2197 | +    $rep = '<div class="nospan float" style="margin-right: 10px">'.($withpicto ? img_picto($langs->trans("EMail"), 'object_email.png').' ' : '').$newemail.'</div>';
 | |
| 2198 | 2198 |      if ($hookmanager) {
 | 
| 2199 | 2199 |          $parameters = array('cid' => $cid, 'socid' => $socid, 'addlink' => $addlink, 'picto' => $withpicto);
 | 
| 2200 | 2200 |          $reshook = $hookmanager->executeHooks('printEmail', $parameters, $email);
 | 
| @@ -2224,26 +2224,26 @@ discard block | ||
| 2224 | 2224 | |
| 2225 | 2225 |      if (!empty($type)) {
 | 
| 2226 | 2226 | $newskype = '<div class="divsocialnetwork inline-block valignmiddle">'; | 
| 2227 | - $newskype .= img_picto($langs->trans(strtoupper($type)), $type . '.png', '', false, 0, 0, '', 'paddingright'); | |
| 2227 | + $newskype .= img_picto($langs->trans(strtoupper($type)), $type.'.png', '', false, 0, 0, '', 'paddingright'); | |
| 2228 | 2228 | $newskype .= $value; | 
| 2229 | 2229 |          if ($type == 'skype') {
 | 
| 2230 | 2230 | $newskype .= ' '; | 
| 2231 | 2231 | $newskype .= '<a href="skype:'; | 
| 2232 | 2232 | $newskype .= $value; | 
| 2233 | -            $newskype .= '?call" alt="' . $langs->trans("Call") . ' ' . $value . '" title="' . $langs->trans("Call") . ' ' . $value . '">';
 | |
| 2234 | - $newskype .= '<img src="' . DOL_URL_ROOT . '/theme/common/skype_callbutton.png" border="0">'; | |
| 2233 | +            $newskype .= '?call" alt="'.$langs->trans("Call").' '.$value.'" title="'.$langs->trans("Call").' '.$value.'">';
 | |
| 2234 | + $newskype .= '<img src="'.DOL_URL_ROOT.'/theme/common/skype_callbutton.png" border="0">'; | |
| 2235 | 2235 | $newskype .= '</a><a href="skype:'; | 
| 2236 | 2236 | $newskype .= $value; | 
| 2237 | -            $newskype .= '?chat" alt="' . $langs->trans("Chat") . ' ' . $value . '" title="' . $langs->trans("Chat") . ' ' . $value . '">';
 | |
| 2238 | - $newskype .= '<img class="paddingleft" src="' . DOL_URL_ROOT . '/theme/common/skype_chatbutton.png" border="0">'; | |
| 2237 | +            $newskype .= '?chat" alt="'.$langs->trans("Chat").' '.$value.'" title="'.$langs->trans("Chat").' '.$value.'">';
 | |
| 2238 | + $newskype .= '<img class="paddingleft" src="'.DOL_URL_ROOT.'/theme/common/skype_chatbutton.png" border="0">'; | |
| 2239 | 2239 | $newskype .= '</a>'; | 
| 2240 | 2240 | } | 
| 2241 | 2241 |          if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create && $type == 'skype') {
 | 
| 2242 | 2242 | $addlink = 'AC_SKYPE'; | 
| 2243 | 2243 | $link = ''; | 
| 2244 | 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>';
 | |
| 2246 | - $newskype .= ($link ? ' ' . $link : ''); | |
| 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>';
 | |
| 2246 | + $newskype .= ($link ? ' '.$link : ''); | |
| 2247 | 2247 | } | 
| 2248 | 2248 | $newskype .= '</div>'; | 
| 2249 | 2249 | } | 
| @@ -2288,165 +2288,165 @@ discard block | ||
| 2288 | 2288 |      if (strtoupper($countrycode) == "FR") {
 | 
| 2289 | 2289 | // France | 
| 2290 | 2290 |          if (dol_strlen($phone) == 10) {
 | 
| 2291 | - $newphone = substr($newphone, 0, 2) . $separ . substr($newphone, 2, 2) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2); | |
| 2291 | + $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 2).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2); | |
| 2292 | 2292 |          } elseif (dol_strlen($phone) == 7) {
 | 
| 2293 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 2); | |
| 2293 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2); | |
| 2294 | 2294 |          } elseif (dol_strlen($phone) == 9) {
 | 
| 2295 | - $newphone = substr($newphone, 0, 2) . $separ . substr($newphone, 2, 3) . $separ . substr($newphone, 5, 2) . $separ . substr($newphone, 7, 2); | |
| 2295 | + $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2); | |
| 2296 | 2296 |          } elseif (dol_strlen($phone) == 11) {
 | 
| 2297 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 2) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2); | |
| 2297 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2); | |
| 2298 | 2298 |          } elseif (dol_strlen($phone) == 12) {
 | 
| 2299 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2); | |
| 2299 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); | |
| 2300 | 2300 | } | 
| 2301 | 2301 |      } elseif (strtoupper($countrycode) == "CA") {
 | 
| 2302 | 2302 |          if (dol_strlen($phone) == 10) {
 | 
| 2303 | -            $newphone = ($separ != '' ? '(' : '') . substr($newphone, 0, 3) . ($separ != '' ? ')' : '') . $separ . substr($newphone, 3, 3) . ($separ != '' ? '-' : '') . substr($newphone, 6, 4);
 | |
| 2303 | +            $newphone = ($separ != '' ? '(' : '').substr($newphone, 0, 3).($separ != '' ? ')' : '').$separ.substr($newphone, 3, 3).($separ != '' ? '-' : '').substr($newphone, 6, 4);
 | |
| 2304 | 2304 | } | 
| 2305 | 2305 |      } elseif (strtoupper($countrycode) == "PT") {//Portugal
 | 
| 2306 | 2306 |          if (dol_strlen($phone) == 13) {//ex: +351_ABC_DEF_GHI
 | 
| 2307 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 3); | |
| 2307 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3); | |
| 2308 | 2308 | } | 
| 2309 | 2309 |      } elseif (strtoupper($countrycode) == "SR") {//Suriname
 | 
| 2310 | 2310 |          if (dol_strlen($phone) == 10) {//ex: +597_ABC_DEF
 | 
| 2311 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 3); | |
| 2311 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3); | |
| 2312 | 2312 |          } elseif (dol_strlen($phone) == 11) {//ex: +597_ABC_DEFG
 | 
| 2313 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 4); | |
| 2313 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4); | |
| 2314 | 2314 | } | 
| 2315 | 2315 |      } elseif (strtoupper($countrycode) == "DE") {//Allemagne
 | 
| 2316 | 2316 |          if (dol_strlen($phone) == 14) {//ex:  +49_ABCD_EFGH_IJK
 | 
| 2317 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 4) . $separ . substr($newphone, 7, 4) . $separ . substr($newphone, 11, 3); | |
| 2317 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3); | |
| 2318 | 2318 |          } elseif (dol_strlen($phone) == 13) {//ex: +49_ABC_DEFG_HIJ
 | 
| 2319 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 4) . $separ . substr($newphone, 10, 3); | |
| 2319 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3); | |
| 2320 | 2320 | } | 
| 2321 | 2321 |      } elseif (strtoupper($countrycode) == "ES") {//Espagne
 | 
| 2322 | 2322 |          if (dol_strlen($phone) == 12) {//ex:  +34_ABC_DEF_GHI
 | 
| 2323 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 3); | |
| 2323 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3); | |
| 2324 | 2324 | } | 
| 2325 | 2325 |      } elseif (strtoupper($countrycode) == "BF") {// Burkina Faso
 | 
| 2326 | 2326 |          if (dol_strlen($phone) == 12) {//ex :  +22 A BC_DE_FG_HI
 | 
| 2327 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 1) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2); | |
| 2327 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); | |
| 2328 | 2328 | } | 
| 2329 | 2329 |      } elseif (strtoupper($countrycode) == "RO") {// Roumanie
 | 
| 2330 | 2330 |          if (dol_strlen($phone) == 12) {//ex :  +40 AB_CDE_FG_HI
 | 
| 2331 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 3) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2); | |
| 2331 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); | |
| 2332 | 2332 | } | 
| 2333 | 2333 |      } elseif (strtoupper($countrycode) == "TR") {//Turquie
 | 
| 2334 | 2334 |          if (dol_strlen($phone) == 13) {//ex :  +90 ABC_DEF_GHIJ
 | 
| 2335 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 4); | |
| 2335 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4); | |
| 2336 | 2336 | } | 
| 2337 | 2337 |      } elseif (strtoupper($countrycode) == "US") {//Etat-Unis
 | 
| 2338 | 2338 |          if (dol_strlen($phone) == 12) {//ex: +1 ABC_DEF_GHIJ
 | 
| 2339 | - $newphone = substr($newphone, 0, 2) . $separ . substr($newphone, 2, 3) . $separ . substr($newphone, 5, 3) . $separ . substr($newphone, 8, 4); | |
| 2339 | + $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4); | |
| 2340 | 2340 | } | 
| 2341 | 2341 |      } elseif (strtoupper($countrycode) == "MX") {//Mexique
 | 
| 2342 | 2342 |          if (dol_strlen($phone) == 12) {//ex: +52 ABCD_EFG_HI
 | 
| 2343 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 4) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 2); | |
| 2343 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2); | |
| 2344 | 2344 |          } elseif (dol_strlen($phone) == 11) {//ex: +52 AB_CD_EF_GH
 | 
| 2345 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 2) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2); | |
| 2345 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2); | |
| 2346 | 2346 |          } elseif (dol_strlen($phone) == 13) {//ex: +52 ABC_DEF_GHIJ
 | 
| 2347 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 4); | |
| 2347 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4); | |
| 2348 | 2348 | } | 
| 2349 | 2349 |      } elseif (strtoupper($countrycode) == "ML") {//Mali
 | 
| 2350 | 2350 |          if (dol_strlen($phone) == 12) {//ex: +223 AB_CD_EF_GH
 | 
| 2351 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2); | |
| 2351 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); | |
| 2352 | 2352 | } | 
| 2353 | 2353 |      } elseif (strtoupper($countrycode) == "TH") {//Thaïlande
 | 
| 2354 | 2354 |          if (dol_strlen($phone) == 11) {//ex: +66_ABC_DE_FGH
 | 
| 2355 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 3); | |
| 2355 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3); | |
| 2356 | 2356 |          } elseif (dol_strlen($phone) == 12) {//ex: +66_A_BCD_EF_GHI
 | 
| 2357 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 1) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 3); | |
| 2357 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 3); | |
| 2358 | 2358 | } | 
| 2359 | 2359 |      } elseif (strtoupper($countrycode) == "MU") {//Maurice
 | 
| 2360 | 2360 |          if (dol_strlen($phone) == 11) {//ex: +230_ABC_DE_FG
 | 
| 2361 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2); | |
| 2361 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2); | |
| 2362 | 2362 |          } elseif (dol_strlen($phone) == 12) {//ex: +230_ABCD_EF_GH
 | 
| 2363 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 4) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2); | |
| 2363 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); | |
| 2364 | 2364 | } | 
| 2365 | 2365 |      } elseif (strtoupper($countrycode) == "ZA") {//Afrique du sud
 | 
| 2366 | 2366 |          if (dol_strlen($phone) == 12) {//ex: +27_AB_CDE_FG_HI
 | 
| 2367 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 3) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2); | |
| 2367 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); | |
| 2368 | 2368 | } | 
| 2369 | 2369 |      } elseif (strtoupper($countrycode) == "SY") {//Syrie
 | 
| 2370 | 2370 |          if (dol_strlen($phone) == 12) {//ex: +963_AB_CD_EF_GH
 | 
| 2371 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2); | |
| 2371 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); | |
| 2372 | 2372 |          } elseif (dol_strlen($phone) == 13) {//ex: +963_AB_CD_EF_GHI
 | 
| 2373 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 3); | |
| 2373 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 3); | |
| 2374 | 2374 | } | 
| 2375 | 2375 |      } elseif (strtoupper($countrycode) == "AE") {//Emirats Arabes Unis
 | 
| 2376 | 2376 |          if (dol_strlen($phone) == 12) {//ex: +971_ABC_DEF_GH
 | 
| 2377 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 2); | |
| 2377 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2); | |
| 2378 | 2378 |          } elseif (dol_strlen($phone) == 13) {//ex: +971_ABC_DEF_GHI
 | 
| 2379 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 3); | |
| 2379 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3); | |
| 2380 | 2380 |          } elseif (dol_strlen($phone) == 14) {//ex: +971_ABC_DEF_GHIK
 | 
| 2381 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 4); | |
| 2381 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 4); | |
| 2382 | 2382 | } | 
| 2383 | 2383 |      } elseif (strtoupper($countrycode) == "DZ") {//Algérie
 | 
| 2384 | 2384 |          if (dol_strlen($phone) == 13) {//ex: +213_ABC_DEF_GHI
 | 
| 2385 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 3); | |
| 2385 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3); | |
| 2386 | 2386 | } | 
| 2387 | 2387 |      } elseif (strtoupper($countrycode) == "BE") {//Belgique
 | 
| 2388 | 2388 |          if (dol_strlen($phone) == 11) {//ex: +32_ABC_DE_FGH
 | 
| 2389 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 3); | |
| 2389 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3); | |
| 2390 | 2390 |          } elseif (dol_strlen($phone) == 12) {//ex: +32_ABC_DEF_GHI
 | 
| 2391 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 3); | |
| 2391 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3); | |
| 2392 | 2392 | } | 
| 2393 | 2393 |      } elseif (strtoupper($countrycode) == "PF") {//Polynésie française
 | 
| 2394 | 2394 |          if (dol_strlen($phone) == 12) {//ex: +689_AB_CD_EF_GH
 | 
| 2395 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2); | |
| 2395 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); | |
| 2396 | 2396 | } | 
| 2397 | 2397 |      } elseif (strtoupper($countrycode) == "CO") {//Colombie
 | 
| 2398 | 2398 |          if (dol_strlen($phone) == 13) {//ex: +57_ABC_DEF_GH_IJ
 | 
| 2399 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 2) . $separ . substr($newphone, 11, 2); | |
| 2399 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2); | |
| 2400 | 2400 | } | 
| 2401 | 2401 |      } elseif (strtoupper($countrycode) == "JO") {//Jordanie
 | 
| 2402 | 2402 |          if (dol_strlen($phone) == 12) {//ex: +962_A_BCD_EF_GH
 | 
| 2403 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 1) . $separ . substr($newphone, 5, 3) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2); | |
| 2403 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 1).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2); | |
| 2404 | 2404 | } | 
| 2405 | 2405 |      } elseif (strtoupper($countrycode) == "MG") {//Madagascar
 | 
| 2406 | 2406 |          if (dol_strlen($phone) == 13) {//ex: +261_AB_CD_EF_GHI
 | 
| 2407 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 3); | |
| 2407 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 3); | |
| 2408 | 2408 | } | 
| 2409 | 2409 |      } elseif (strtoupper($countrycode) == "GB") {//Royaume uni
 | 
| 2410 | 2410 |          if (dol_strlen($phone) == 13) {//ex: +44_ABCD_EFG_HIJ
 | 
| 2411 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 4) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 3); | |
| 2411 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3); | |
| 2412 | 2412 | } | 
| 2413 | 2413 |      } elseif (strtoupper($countrycode) == "CH") {//Suisse
 | 
| 2414 | 2414 |          if (dol_strlen($phone) == 12) {//ex: +41_AB_CDE_FG_HI
 | 
| 2415 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 3) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2); | |
| 2415 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2); | |
| 2416 | 2416 |          } elseif (dol_strlen($phone) == 15) {// +41_AB_CDE_FGH_IJKL
 | 
| 2417 | - $newphone = $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 3) . $separ . substr($newphone, 8, 3) . $separ . substr($newphone, 11, 4); | |
| 2417 | + $newphone = $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 3).$separ.substr($newphone, 11, 4); | |
| 2418 | 2418 | } | 
| 2419 | 2419 |      } elseif (strtoupper($countrycode) == "TN") {//Tunisie
 | 
| 2420 | 2420 |          if (dol_strlen($phone) == 12) {//ex: +216_AB_CDE_FGH
 | 
| 2421 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 3); | |
| 2421 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3); | |
| 2422 | 2422 | } | 
| 2423 | 2423 |      } elseif (strtoupper($countrycode) == "GF") {//Guyane francaise
 | 
| 2424 | 2424 |          if (dol_strlen($phone) == 13) {//ex: +594_ABC_DE_FG_HI  (ABC=594 de nouveau)
 | 
| 2425 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2) . $separ . substr($newphone, 11, 2); | |
| 2425 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2); | |
| 2426 | 2426 | } | 
| 2427 | 2427 |      } elseif (strtoupper($countrycode) == "GP") {//Guadeloupe
 | 
| 2428 | 2428 |          if (dol_strlen($phone) == 13) {//ex: +590_ABC_DE_FG_HI  (ABC=590 de nouveau)
 | 
| 2429 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2) . $separ . substr($newphone, 11, 2); | |
| 2429 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2); | |
| 2430 | 2430 | } | 
| 2431 | 2431 |      } elseif (strtoupper($countrycode) == "MQ") {//Martinique
 | 
| 2432 | 2432 |          if (dol_strlen($phone) == 13) {//ex: +596_ABC_DE_FG_HI  (ABC=596 de nouveau)
 | 
| 2433 | - $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2) . $separ . substr($newphone, 11, 2); | |
| 2433 | + $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2); | |
| 2434 | 2434 | } | 
| 2435 | 2435 |      } elseif (strtoupper($countrycode) == "IT") {//Italie
 | 
| 2436 | 2436 |          if (dol_strlen($phone) == 12) {//ex: +39_ABC_DEF_GHI
 | 
| 2437 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 3); | |
| 2437 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3); | |
| 2438 | 2438 |          } elseif (dol_strlen($phone) == 13) {//ex: +39_ABC_DEF_GH_IJ
 | 
| 2439 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 2) . $separ . substr($newphone, 11, 2); | |
| 2439 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2); | |
| 2440 | 2440 | } | 
| 2441 | 2441 |      } elseif (strtoupper($countrycode) == "AU") {//Australie
 | 
| 2442 | 2442 |          if (dol_strlen($phone) == 12) {//ex: +61_A_BCDE_FGHI
 | 
| 2443 | - $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 1) . $separ . substr($newphone, 4, 4) . $separ . substr($newphone, 8, 4); | |
| 2443 | + $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4); | |
| 2444 | 2444 | } | 
| 2445 | 2445 | } | 
| 2446 | 2446 |      if (!empty($addlink)) { // Link on phone number (+ link to add action if conf->global->AGENDA_ADDACTIONFORPHONE set)
 | 
| 2447 | 2447 |          if ($conf->browser->layout == 'phone' || (!empty($conf->clicktodial->enabled) && !empty($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS))) { // If phone or option for, we use link of phone
 | 
| 2448 | - $newphone = '<a href="tel:' . $phone . '"'; | |
| 2449 | - $newphone .= '>' . $phone . '</a>'; | |
| 2448 | + $newphone = '<a href="tel:'.$phone.'"'; | |
| 2449 | + $newphone .= '>'.$phone.'</a>'; | |
| 2450 | 2450 |          } else if (!empty($conf->clicktodial->enabled) && $addlink == 'AC_TEL') {  // If click to dial, we use click to dial url
 | 
| 2451 | 2451 | if (empty($user->clicktodial_loaded)) | 
| 2452 | 2452 | $user->fetch_clicktodial(); | 
| @@ -2470,10 +2470,10 @@ discard block | ||
| 2470 | 2470 | '__PASS__' => $clicktodial_password); | 
| 2471 | 2471 | $url = make_substitutions($url, $substitarray); | 
| 2472 | 2472 | $newphonesav = $newphone; | 
| 2473 | - $newphone = '<a href="' . $url . '"'; | |
| 2473 | + $newphone = '<a href="'.$url.'"'; | |
| 2474 | 2474 | if (!empty($conf->global->CLICKTODIAL_FORCENEWTARGET)) | 
| 2475 | 2475 | $newphone .= ' target="_blank"'; | 
| 2476 | - $newphone .= '>' . $newphonesav . '</a>'; | |
| 2476 | + $newphone .= '>'.$newphonesav.'</a>'; | |
| 2477 | 2477 | } | 
| 2478 | 2478 | |
| 2479 | 2479 | //if (($cid || $socid) && ! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) | 
| @@ -2483,9 +2483,9 @@ discard block | ||
| 2483 | 2483 | if ($addlink == 'AC_FAX') | 
| 2484 | 2484 | $type = 'AC_FAX'; | 
| 2485 | 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>';
 | |
| 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 | 2487 | if ($link) | 
| 2488 | - $newphone = '<div>' . $newphone . ' ' . $link . '</div>'; | |
| 2488 | + $newphone = '<div>'.$newphone.' '.$link.'</div>'; | |
| 2489 | 2489 | } | 
| 2490 | 2490 | } | 
| 2491 | 2491 | |
| @@ -2516,7 +2516,7 @@ discard block | ||
| 2516 | 2516 | $rep .= '<div class="nospan float" style="margin-right: 10px">'; | 
| 2517 | 2517 | else | 
| 2518 | 2518 | $rep .= '<span style="margin-right: 10px;">'; | 
| 2519 | - $rep .= ($withpicto ? img_picto($titlealt, 'object_' . $picto . '.png') . ' ' : '') . $newphone; | |
| 2519 | + $rep .= ($withpicto ? img_picto($titlealt, 'object_'.$picto.'.png').' ' : '').$newphone; | |
| 2520 | 2520 | if ($adddivfloat) | 
| 2521 | 2521 | $rep .= '</div>'; | 
| 2522 | 2522 | else | 
| @@ -2545,10 +2545,10 @@ discard block | ||
| 2545 | 2545 |      if ($mode != 2) {
 | 
| 2546 | 2546 | $countrycode = dolGetCountryCodeFromIp($ip); | 
| 2547 | 2547 |          if ($countrycode) { // If success, countrycode is us, fr, ...
 | 
| 2548 | -            if (file_exists(DOL_BASE_PATH . 'theme/common/flags/' . $countrycode . '.png')) {
 | |
| 2549 | -                $ret .= ' ' . img_picto($countrycode . ' ' . $langs->trans("AccordingToGeoIPDatabase"), /* DOL_URL_ROOT */ DOL_BASE_URI . '/theme/common/flags/' . $countrycode . '.png', '', 1);
 | |
| 2548 | +            if (file_exists(DOL_BASE_PATH.'theme/common/flags/'.$countrycode.'.png')) {
 | |
| 2549 | +                $ret .= ' '.img_picto($countrycode.' '.$langs->trans("AccordingToGeoIPDatabase"), /* DOL_URL_ROOT */ DOL_BASE_URI.'/theme/common/flags/'.$countrycode.'.png', '', 1);
 | |
| 2550 | 2550 | } else | 
| 2551 | -                $ret .= ' (' . $countrycode . ')';
 | |
| 2551 | +                $ret .= ' ('.$countrycode.')';
 | |
| 2552 | 2552 | } | 
| 2553 | 2553 | } | 
| 2554 | 2554 | |
| @@ -2586,7 +2586,7 @@ discard block | ||
| 2586 | 2586 | //$ip='24.24.24.24'; | 
| 2587 | 2587 | //$datafile='E:\Mes Sites\Web\Admin1\awstats\maxmind\GeoIP.dat'; Note that this must be downloaded datafile (not same than datafile provided with ubuntu packages) | 
| 2588 | 2588 | |
| 2589 | - include_once DOL_BASE_PATH . '/core/class/dolgeoip.class.php'; | |
| 2589 | + include_once DOL_BASE_PATH.'/core/class/dolgeoip.class.php'; | |
| 2590 | 2590 |          $geoip = new DolGeoIP('country', $datafile);
 | 
| 2591 | 2591 | //print 'ip='.$ip.' databaseType='.$geoip->gi->databaseType." GEOIP_CITY_EDITION_REV1=".GEOIP_CITY_EDITION_REV1."\n"; | 
| 2592 | 2592 | //print "geoip_country_id_by_addr=".geoip_country_id_by_addr($geoip->gi,$ip)."\n"; | 
| @@ -2613,7 +2613,7 @@ discard block | ||
| 2613 | 2613 | $datafile = $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE; | 
| 2614 | 2614 | //$ip='24.24.24.24'; | 
| 2615 | 2615 | //$datafile='E:\Mes Sites\Web\Admin1\awstats\maxmind\GeoIP.dat'; | 
| 2616 | - include_once DOL_BASE_PATH . '/core/class/dolgeoip.class.php'; | |
| 2616 | + include_once DOL_BASE_PATH.'/core/class/dolgeoip.class.php'; | |
| 2617 | 2617 |          $geoip = new DolGeoIP('country', $datafile);
 | 
| 2618 | 2618 | $countrycode = $geoip->getCountryCodeFromIP($ip); | 
| 2619 | 2619 | $ret = $countrycode; | 
| @@ -2668,12 +2668,12 @@ discard block | ||
| 2668 | 2668 | $showomap = 1; | 
| 2669 | 2669 | |
| 2670 | 2670 |              if ($showgmap) {
 | 
| 2671 | -                $url = dol_buildpath('/google/gmaps.php?mode=' . $mode . '&id=' . $id, 1);
 | |
| 2672 | - $out .= ' <a href="' . $url . '" target="_gmaps"><img id="' . $htmlid . '" class="valigntextbottom" src="' . DOL_URL_ROOT . '/theme/common/gmap.png"></a>'; | |
| 2671 | +                $url = dol_buildpath('/google/gmaps.php?mode='.$mode.'&id='.$id, 1);
 | |
| 2672 | + $out .= ' <a href="'.$url.'" target="_gmaps"><img id="'.$htmlid.'" class="valigntextbottom" src="'.DOL_URL_ROOT.'/theme/common/gmap.png"></a>'; | |
| 2673 | 2673 | } | 
| 2674 | 2674 |              if ($showomap) {
 | 
| 2675 | -                $url = dol_buildpath('/openstreetmap/maps.php?mode=' . $mode . '&id=' . $id, 1);
 | |
| 2676 | - $out .= ' <a href="' . $url . '" target="_gmaps"><img id="' . $htmlid . '_openstreetmap" class="valigntextbottom" src="' . DOL_URL_ROOT . '/theme/common/gmap.png"></a>'; | |
| 2675 | +                $url = dol_buildpath('/openstreetmap/maps.php?mode='.$mode.'&id='.$id, 1);
 | |
| 2676 | + $out .= ' <a href="'.$url.'" target="_gmaps"><img id="'.$htmlid.'_openstreetmap" class="valigntextbottom" src="'.DOL_URL_ROOT.'/theme/common/gmap.png"></a>'; | |
| 2677 | 2677 | } | 
| 2678 | 2678 | } | 
| 2679 | 2679 | } | 
| @@ -2819,7 +2819,7 @@ discard block | ||
| 2819 | 2819 |      if ($trunc == 'right') {
 | 
| 2820 | 2820 | $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; | 
| 2821 | 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 ? '' : '...'); | |
| 2822 | + return dol_substr($newstring, 0, $size, $stringencoding).($nodot ? '' : '...'); | |
| 2823 | 2823 | else | 
| 2824 | 2824 | //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string; | 
| 2825 | 2825 | return $string; | 
| @@ -2829,21 +2829,21 @@ discard block | ||
| 2829 | 2829 |          if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > ($size + 1)) {
 | 
| 2830 | 2830 | $size1 = round($size / 2); | 
| 2831 | 2831 | $size2 = round($size / 2); | 
| 2832 | - return dol_substr($newstring, 0, $size1, $stringencoding) . '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding); | |
| 2832 | + return dol_substr($newstring, 0, $size1, $stringencoding).'...'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding); | |
| 2833 | 2833 | } else | 
| 2834 | 2834 | return $string; | 
| 2835 | 2835 | } | 
| 2836 | 2836 |      elseif ($trunc == 'left') {
 | 
| 2837 | 2837 | $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; | 
| 2838 | 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); | |
| 2839 | + return '...'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding); | |
| 2840 | 2840 | else | 
| 2841 | 2841 | return $string; | 
| 2842 | 2842 | } | 
| 2843 | 2843 |      elseif ($trunc == 'wrap') {
 | 
| 2844 | 2844 | $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; | 
| 2845 | 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); | |
| 2846 | + return dol_substr($newstring, 0, $size, $stringencoding)."\n".dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc); | |
| 2847 | 2847 | else | 
| 2848 | 2848 | return $string; | 
| 2849 | 2849 | } else | 
| @@ -2877,7 +2877,7 @@ discard block | ||
| 2877 | 2877 | $url = DOL_BASE_URI; | 
| 2878 | 2878 | |
| 2879 | 2879 | $theme = $conf->theme; | 
| 2880 | - $path = 'theme/' . $theme; | |
| 2880 | + $path = 'theme/'.$theme; | |
| 2881 | 2881 | |
| 2882 | 2882 | // Define fullpathpicto to use into src | 
| 2883 | 2883 |      if ($pictoisfullpath) {
 | 
| @@ -2926,7 +2926,7 @@ discard block | ||
| 2926 | 2926 | $fakey = 'fa-pencil'; | 
| 2927 | 2927 | $facolor = '#444'; | 
| 2928 | 2928 |              } elseif ($pictowithoutext == 'filter') {
 | 
| 2929 | - $fakey = 'fa-' . $pictowithoutext; | |
| 2929 | + $fakey = 'fa-'.$pictowithoutext; | |
| 2930 | 2930 |              } elseif ($pictowithoutext == 'grip_title' || $pictowithoutext == 'grip') {
 | 
| 2931 | 2931 | $fakey = 'fa-arrows'; | 
| 2932 | 2932 |              } elseif ($pictowithoutext == 'listlight') {
 | 
| @@ -2965,15 +2965,15 @@ discard block | ||
| 2965 | 2965 |              } elseif ($pictowithoutext == 'jabber') {
 | 
| 2966 | 2966 | $fakey = 'fa-comment-o'; | 
| 2967 | 2967 |              } else {
 | 
| 2968 | - $fakey = 'fa-' . $pictowithoutext; | |
| 2968 | + $fakey = 'fa-'.$pictowithoutext; | |
| 2969 | 2969 | $facolor = '#444'; | 
| 2970 | 2970 | $marginleftonlyshort = 0; | 
| 2971 | 2971 | } | 
| 2972 | 2972 | |
| 2973 | 2973 |              if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) {
 | 
| 2974 | - $morecss .= ($morecss ? ' ' : '') . $reg[1]; | |
| 2974 | + $morecss .= ($morecss ? ' ' : '').$reg[1]; | |
| 2975 | 2975 | } | 
| 2976 | -            $enabledisablehtml = '<span class="fa ' . $fakey . ' ' . ($marginleftonlyshort ? ($marginleftonlyshort == 1 ? 'marginleftonlyshort' : 'marginleftonly') : '') . ' valignmiddle' . ($morecss ? ' ' . $morecss : '') . '" style="' . ($fasize ? ('font-size: ' . $fasize . ';') : '') . ($facolor ? (' color: ' . $facolor . ';') : '') . '" alt="' . dol_escape_htmltag($titlealt) . '"' . (($notitle || empty($title)) ? '' : ' title="' . dol_escape_htmltag($title) . '"') . ($moreatt ? ' ' . $moreatt : '') . '>';
 | |
| 2976 | +            $enabledisablehtml = '<span class="fa '.$fakey.' '.($marginleftonlyshort ? ($marginleftonlyshort == 1 ? 'marginleftonlyshort' : 'marginleftonly') : '').' valignmiddle'.($morecss ? ' '.$morecss : '').'" style="'.($fasize ? ('font-size: '.$fasize.';') : '').($facolor ? (' color: '.$facolor.';') : '').'" alt="'.dol_escape_htmltag($titlealt).'"'.(($notitle || empty($title)) ? '' : ' title="'.dol_escape_htmltag($title).'"').($moreatt ? ' '.$moreatt : '').'>';
 | |
| 2977 | 2977 |              if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
 | 
| 2978 | 2978 | $enabledisablehtml .= $titlealt; | 
| 2979 | 2979 | } | 
| @@ -2983,11 +2983,11 @@ discard block | ||
| 2983 | 2983 | } | 
| 2984 | 2984 | |
| 2985 | 2985 |          if (!empty($conf->global->MAIN_OVERWRITE_THEME_PATH)) {
 | 
| 2986 | - $path = $conf->global->MAIN_OVERWRITE_THEME_PATH . '/theme/' . $theme; // If the theme does not have the same name as the module | |
| 2986 | + $path = $conf->global->MAIN_OVERWRITE_THEME_PATH.'/theme/'.$theme; // If the theme does not have the same name as the module | |
| 2987 | 2987 |          } else if (!empty($conf->global->MAIN_OVERWRITE_THEME_RES)) {
 | 
| 2988 | - $path = $conf->global->MAIN_OVERWRITE_THEME_RES . '/theme/' . $conf->global->MAIN_OVERWRITE_THEME_RES; // To allow an external module to overwrite image resources whatever is activated theme | |
| 2988 | + $path = $conf->global->MAIN_OVERWRITE_THEME_RES.'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES; // To allow an external module to overwrite image resources whatever is activated theme | |
| 2989 | 2989 |          } else if (!empty($conf->modules_parts['theme']) && array_key_exists($theme, $conf->modules_parts['theme'])) {
 | 
| 2990 | - $path = $theme . '/theme/' . $theme; // If the theme have the same name as the module | |
| 2990 | + $path = $theme.'/theme/'.$theme; // If the theme have the same name as the module | |
| 2991 | 2991 | } | 
| 2992 | 2992 | |
| 2993 | 2993 | // If we ask an image into $url/$mymodule/img (instead of default path) | 
| @@ -3007,22 +3007,22 @@ discard block | ||
| 3007 | 3007 | continue; | 
| 3008 | 3008 | } | 
| 3009 | 3009 | // This need a lot of time, that's why enabling alternative dir like "custom" dir is not recommanded | 
| 3010 | -            if (file_exists($dirroot . '/' . $path . '/img/' . $picto)) {
 | |
| 3010 | +            if (file_exists($dirroot.'/'.$path.'/img/'.$picto)) {
 | |
| 3011 | 3011 | //$url = DOL_URL_ROOT . $conf->file->dol_url_root[$type]; | 
| 3012 | - $url = DOL_BASE_URI . $conf->file->dol_url_root[$type]; | |
| 3012 | + $url = DOL_BASE_URI.$conf->file->dol_url_root[$type]; | |
| 3013 | 3013 | break; | 
| 3014 | 3014 | } | 
| 3015 | 3015 | } | 
| 3016 | 3016 | |
| 3017 | 3017 | // $url is '' or '/custom', $path is current theme or | 
| 3018 | - $fullpathpicto = $url . '/' . $path . '/img/' . $picto; | |
| 3018 | + $fullpathpicto = $url.'/'.$path.'/img/'.$picto; | |
| 3019 | 3019 | } | 
| 3020 | 3020 | |
| 3021 | 3021 |      if ($srconly) {
 | 
| 3022 | 3022 | return $fullpathpicto; | 
| 3023 | 3023 | } | 
| 3024 | 3024 | // tag title is used for tooltip on <a>, tag alt can be used with very simple text on image for bind people | 
| 3025 | - return '<img src="' . $fullpathpicto . '" alt="' . dol_escape_htmltag($alt) . '"' . (($notitle || empty($titlealt)) ? '' : ' title="' . dol_escape_htmltag($titlealt) . '"') . ($moreatt ? ' ' . $moreatt : ' class="inline-block' . ($morecss ? ' ' . $morecss : '') . '"') . '>'; // Alt is used for accessibility, title for popup | |
| 3025 | + return '<img src="'.$fullpathpicto.'" alt="'.dol_escape_htmltag($alt).'"'.(($notitle || empty($titlealt)) ? '' : ' title="'.dol_escape_htmltag($titlealt).'"').($moreatt ? ' '.$moreatt : ' class="inline-block'.($morecss ? ' '.$morecss : '').'"').'>'; // Alt is used for accessibility, title for popup | |
| 3026 | 3026 | } | 
| 3027 | 3027 | |
| 3028 | 3028 | /** | 
| @@ -3040,7 +3040,7 @@ discard block | ||
| 3040 | 3040 | */ | 
| 3041 | 3041 | function img_object($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $srconly = 0, $notitle = 0) | 
| 3042 | 3042 |  {
 | 
| 3043 | - return img_picto($titlealt, 'object_' . $picto, $moreatt, $pictoisfullpath, $srconly, $notitle); | |
| 3043 | + return img_picto($titlealt, 'object_'.$picto, $moreatt, $pictoisfullpath, $srconly, $notitle); | |
| 3044 | 3044 | } | 
| 3045 | 3045 | |
| 3046 | 3046 | /** | 
| @@ -3061,7 +3061,7 @@ discard block | ||
| 3061 | 3061 | $picto .= '.png'; | 
| 3062 | 3062 | |
| 3063 | 3063 | //$path = DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/weather/' . $picto; | 
| 3064 | - $path = DOL_BASE_URI . '/theme/' . $conf->theme . '/img/weather/' . $picto; | |
| 3064 | + $path = DOL_BASE_URI.'/theme/'.$conf->theme.'/img/weather/'.$picto; | |
| 3065 | 3065 | |
| 3066 | 3066 | return img_picto($titlealt, $path, $moreatt, 1); | 
| 3067 | 3067 | } | 
| @@ -3086,10 +3086,10 @@ discard block | ||
| 3086 | 3086 | if ($pictoisfullpath) | 
| 3087 | 3087 | $path = $picto; | 
| 3088 | 3088 |      else {
 | 
| 3089 | - $path = DOL_URL_ROOT . '/theme/common/' . $picto; | |
| 3089 | + $path = DOL_URL_ROOT.'/theme/common/'.$picto; | |
| 3090 | 3090 | |
| 3091 | 3091 |          if (!empty($conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS)) {
 | 
| 3092 | - $themepath = DOL_BASE_PATH . 'theme/' . $conf->theme . '/img/' . $picto; | |
| 3092 | + $themepath = DOL_BASE_PATH.'theme/'.$conf->theme.'/img/'.$picto; | |
| 3093 | 3093 | |
| 3094 | 3094 | if (file_exists($themepath)) | 
| 3095 | 3095 | $path = $themepath; | 
| @@ -3127,14 +3127,14 @@ discard block | ||
| 3127 | 3127 | $numaction = 3; | 
| 3128 | 3128 |              $titlealt = $langs->transnoentitiesnoconv('ChangeContactDone');
 | 
| 3129 | 3129 |          } else {
 | 
| 3130 | -            $titlealt = $langs->transnoentitiesnoconv('ChangeStatus ' . $numaction);
 | |
| 3130 | +            $titlealt = $langs->transnoentitiesnoconv('ChangeStatus '.$numaction);
 | |
| 3131 | 3131 | $numaction = 0; | 
| 3132 | 3132 | } | 
| 3133 | 3133 | } | 
| 3134 | 3134 | if (!is_numeric($numaction)) | 
| 3135 | 3135 | $numaction = 0; | 
| 3136 | 3136 | |
| 3137 | - return img_picto($titlealt, 'stcomm' . $numaction . '.png'); | |
| 3137 | + return img_picto($titlealt, 'stcomm'.$numaction.'.png'); | |
| 3138 | 3138 | } | 
| 3139 | 3139 | |
| 3140 | 3140 | /** | 
| @@ -3151,7 +3151,7 @@ discard block | ||
| 3151 | 3151 | if ($titlealt == 'default') | 
| 3152 | 3152 |          $titlealt = $langs->trans('Show');
 | 
| 3153 | 3153 | |
| 3154 | - return img_picto($titlealt, 'pdf' . $size . '.png'); | |
| 3154 | + return img_picto($titlealt, 'pdf'.$size.'.png'); | |
| 3155 | 3155 | } | 
| 3156 | 3156 | |
| 3157 | 3157 | /** | 
| @@ -3203,7 +3203,7 @@ discard block | ||
| 3203 | 3203 | if ($titlealt == 'default') | 
| 3204 | 3204 |          $titlealt = $langs->trans('Modify');
 | 
| 3205 | 3205 | |
| 3206 | - return img_picto($titlealt, 'edit.png', ($float ? 'style="float: ' . ($langs->tab_translate["DIRECTION"] == 'rtl' ? 'left' : 'right') . '"' : "") . ($other ? ' ' . $other : '')); | |
| 3206 | + return img_picto($titlealt, 'edit.png', ($float ? 'style="float: '.($langs->tab_translate["DIRECTION"] == 'rtl' ? 'left' : 'right').'"' : "").($other ? ' '.$other : '')); | |
| 3207 | 3207 | } | 
| 3208 | 3208 | |
| 3209 | 3209 | /** | 
| @@ -3221,7 +3221,7 @@ discard block | ||
| 3221 | 3221 | if ($titlealt == 'default') | 
| 3222 | 3222 |          $titlealt = $langs->trans('View');
 | 
| 3223 | 3223 | |
| 3224 | - $moreatt = ($float ? 'style="float: right" ' : '') . $other; | |
| 3224 | + $moreatt = ($float ? 'style="float: right" ' : '').$other; | |
| 3225 | 3225 | |
| 3226 | 3226 | return img_picto($titlealt, 'view.png', $moreatt); | 
| 3227 | 3227 | } | 
| @@ -3294,7 +3294,7 @@ discard block | ||
| 3294 | 3294 |              $usealttitle = $langs->trans('Info');
 | 
| 3295 | 3295 | } | 
| 3296 | 3296 | |
| 3297 | - return img_picto($usealttitle, 'info.png', 'style="vertical-align: middle;' . ($usehelpcursor == 1 ? ' cursor: help' : ($usehelpcursor == 2 ? ' cursor: pointer' : '')) . '"'); | |
| 3297 | + return img_picto($usealttitle, 'info.png', 'style="vertical-align: middle;'.($usehelpcursor == 1 ? ' cursor: help' : ($usehelpcursor == 2 ? ' cursor: pointer' : '')).'"'); | |
| 3298 | 3298 | } | 
| 3299 | 3299 | |
| 3300 | 3300 | /** | 
| @@ -3328,7 +3328,7 @@ discard block | ||
| 3328 | 3328 |          $titlealt = $langs->trans('Warning');
 | 
| 3329 | 3329 | |
| 3330 | 3330 | //return '<div class="imglatecoin">'.img_picto($titlealt, 'warning_white.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')).'</div>'; | 
| 3331 | - return img_picto($titlealt, 'warning.png', 'class="pictowarning valignmiddle"' . ($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' ' . $moreatt) : '')); | |
| 3331 | + return img_picto($titlealt, 'warning.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt) : '')); | |
| 3332 | 3332 | } | 
| 3333 | 3333 | |
| 3334 | 3334 | /** | 
| @@ -3362,7 +3362,7 @@ discard block | ||
| 3362 | 3362 |          $titlealt = $langs->trans('Next');
 | 
| 3363 | 3363 | |
| 3364 | 3364 | //return img_picto($titlealt, 'next.png', $moreatt); | 
| 3365 | - return '<span class="fa fa-chevron-right paddingright paddingleft" title="' . dol_escape_htmltag($titlealt) . '"></span>'; | |
| 3365 | + return '<span class="fa fa-chevron-right paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).'"></span>'; | |
| 3366 | 3366 | } | 
| 3367 | 3367 | |
| 3368 | 3368 | /** | 
| @@ -3380,7 +3380,7 @@ discard block | ||
| 3380 | 3380 |          $titlealt = $langs->trans('Previous');
 | 
| 3381 | 3381 | |
| 3382 | 3382 | //return img_picto($titlealt, 'previous.png', $moreatt); | 
| 3383 | - return '<span class="fa fa-chevron-left paddingright paddingleft" title="' . dol_escape_htmltag($titlealt) . '"></span>'; | |
| 3383 | + return '<span class="fa fa-chevron-left paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).'"></span>'; | |
| 3384 | 3384 | } | 
| 3385 | 3385 | |
| 3386 | 3386 | /** | 
| @@ -3398,7 +3398,7 @@ discard block | ||
| 3398 | 3398 | if ($titlealt == 'default') | 
| 3399 | 3399 |          $titlealt = $langs->trans('Down');
 | 
| 3400 | 3400 | |
| 3401 | - return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown' . ($moreclass ? " " . $moreclass : "") . '"'); | |
| 3401 | + return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown'.($moreclass ? " ".$moreclass : "").'"'); | |
| 3402 | 3402 | } | 
| 3403 | 3403 | |
| 3404 | 3404 | /** | 
| @@ -3416,7 +3416,7 @@ discard block | ||
| 3416 | 3416 | if ($titlealt == 'default') | 
| 3417 | 3417 |          $titlealt = $langs->trans('Up');
 | 
| 3418 | 3418 | |
| 3419 | - return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup' . ($moreclass ? " " . $moreclass : "") . '"'); | |
| 3419 | + return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup'.($moreclass ? " ".$moreclass : "").'"'); | |
| 3420 | 3420 | } | 
| 3421 | 3421 | |
| 3422 | 3422 | /** | 
| @@ -3499,7 +3499,7 @@ discard block | ||
| 3499 | 3499 | $brand = 'credit-card'; | 
| 3500 | 3500 | } | 
| 3501 | 3501 | |
| 3502 | - return '<span class="fa fa-' . $brand . ' fa-2x fa-fw"></span>'; | |
| 3502 | + return '<span class="fa fa-'.$brand.' fa-2x fa-fw"></span>'; | |
| 3503 | 3503 | } | 
| 3504 | 3504 | |
| 3505 | 3505 | /** | 
| @@ -3512,17 +3512,17 @@ discard block | ||
| 3512 | 3512 | */ | 
| 3513 | 3513 | function img_mime($file, $titlealt = '', $morecss = '') | 
| 3514 | 3514 |  {
 | 
| 3515 | - require_once DOL_BASE_PATH . '/core/lib/files.lib.php'; | |
| 3515 | + require_once DOL_BASE_PATH.'/core/lib/files.lib.php'; | |
| 3516 | 3516 | |
| 3517 | 3517 | $mimetype = dol_mimetype($file, '', 1); | 
| 3518 | 3518 | $mimeimg = dol_mimetype($file, '', 2); | 
| 3519 | 3519 | $mimefa = dol_mimetype($file, '', 4); | 
| 3520 | 3520 | |
| 3521 | 3521 | if (empty($titlealt)) | 
| 3522 | - $titlealt = 'Mime type: ' . $mimetype; | |
| 3522 | + $titlealt = 'Mime type: '.$mimetype; | |
| 3523 | 3523 | |
| 3524 | 3524 | //return img_picto_common($titlealt, 'mime/'.$mimeimg, 'class="'.$morecss.'"'); | 
| 3525 | - return '<i class="fa fa-' . $mimefa . ' paddingright"></i>'; | |
| 3525 | + return '<i class="fa fa-'.$mimefa.' paddingright"></i>'; | |
| 3526 | 3526 | } | 
| 3527 | 3527 | |
| 3528 | 3528 | /** | 
| @@ -3537,7 +3537,7 @@ discard block | ||
| 3537 | 3537 | */ | 
| 3538 | 3538 | function img_phone($titlealt = 'default', $option = 0) | 
| 3539 | 3539 |  {
 | 
| 3540 | - dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); | |
| 3540 | + dol_syslog(__FUNCTION__." is deprecated", LOG_WARNING); | |
| 3541 | 3541 | |
| 3542 | 3542 | global $conf, $langs; | 
| 3543 | 3543 | |
| @@ -3568,8 +3568,8 @@ discard block | ||
| 3568 | 3568 | |
| 3569 | 3569 | $img = img_picto($titlealt, 'search.png', $other, false, 1); | 
| 3570 | 3570 | |
| 3571 | - $input = '<input type="image" class="liste_titre" name="button_search" src="' . $img . '" '; | |
| 3572 | - $input .= 'value="' . dol_escape_htmltag($titlealt) . '" title="' . dol_escape_htmltag($titlealt) . '" >'; | |
| 3571 | + $input = '<input type="image" class="liste_titre" name="button_search" src="'.$img.'" '; | |
| 3572 | + $input .= 'value="'.dol_escape_htmltag($titlealt).'" title="'.dol_escape_htmltag($titlealt).'" >'; | |
| 3573 | 3573 | |
| 3574 | 3574 | return $input; | 
| 3575 | 3575 | } | 
| @@ -3590,8 +3590,8 @@ discard block | ||
| 3590 | 3590 | |
| 3591 | 3591 | $img = img_picto($titlealt, 'searchclear.png', $other, false, 1); | 
| 3592 | 3592 | |
| 3593 | - $input = '<input type="image" class="liste_titre" name="button_removefilter" src="' . $img . '" '; | |
| 3594 | - $input .= 'value="' . dol_escape_htmltag($titlealt) . '" title="' . dol_escape_htmltag($titlealt) . '" >'; | |
| 3593 | + $input = '<input type="image" class="liste_titre" name="button_removefilter" src="'.$img.'" '; | |
| 3594 | + $input .= 'value="'.dol_escape_htmltag($titlealt).'" title="'.dol_escape_htmltag($titlealt).'" >'; | |
| 3595 | 3595 | |
| 3596 | 3596 | return $input; | 
| 3597 | 3597 | } | 
| @@ -3611,10 +3611,10 @@ discard block | ||
| 3611 | 3611 | global $conf, $langs; | 
| 3612 | 3612 | |
| 3613 | 3613 |      if ($infoonimgalt) {
 | 
| 3614 | - return img_picto($text, 'info', 'class="hideonsmartphone' . ($morecss ? ' ' . $morecss : '') . '"'); | |
| 3614 | + return img_picto($text, 'info', 'class="hideonsmartphone'.($morecss ? ' '.$morecss : '').'"'); | |
| 3615 | 3615 | } | 
| 3616 | 3616 | |
| 3617 | -    return ($nodiv ? '' : '<div class="' . (empty($admin) ? '' : ($admin == '1' ? 'info' : $admin)) . ' hideonsmartphone' . ($morecss ? ' ' . $morecss : '') . '">') . '<span class="fa fa-info-circle" title="' . dol_escape_htmltag($admin ? $langs->trans('InfoAdmin') : $langs->trans('Note')) . '"></span> ' . $text . ($nodiv ? '' : '</div>');
 | |
| 3617 | +    return ($nodiv ? '' : '<div class="'.(empty($admin) ? '' : ($admin == '1' ? 'info' : $admin)).' hideonsmartphone'.($morecss ? ' '.$morecss : '').'">').'<span class="fa fa-info-circle" title="'.dol_escape_htmltag($admin ? $langs->trans('InfoAdmin') : $langs->trans('Note')).'"></span> '.$text.($nodiv ? '' : '</div>');
 | |
| 3618 | 3618 | } | 
| 3619 | 3619 | |
| 3620 | 3620 | /** | 
| @@ -3639,7 +3639,7 @@ discard block | ||
| 3639 | 3639 | |
| 3640 | 3640 | // Si erreur intervenue avant chargement langue | 
| 3641 | 3641 |      if (!$langs) {
 | 
| 3642 | - require_once DOL_BASE_PATH . '/core/class/translate.class.php'; | |
| 3642 | + require_once DOL_BASE_PATH.'/core/class/translate.class.php'; | |
| 3643 | 3643 |          $langs = new Translate('', $conf);
 | 
| 3644 | 3644 |          $langs->load("main");
 | 
| 3645 | 3645 | } | 
| @@ -3647,51 +3647,51 @@ discard block | ||
| 3647 | 3647 |      $langs->loadLangs(array('main', 'errors'));
 | 
| 3648 | 3648 | |
| 3649 | 3649 |      if ($_SERVER['DOCUMENT_ROOT']) {    // Mode web
 | 
| 3650 | -        $out .= $langs->trans("DolibarrHasDetectedError") . ".<br>\n";
 | |
| 3650 | +        $out .= $langs->trans("DolibarrHasDetectedError").".<br>\n";
 | |
| 3651 | 3651 | if (!empty($conf->global->MAIN_FEATURES_LEVEL)) | 
| 3652 | 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"; | 
| 3653 | -        $out .= $langs->trans("InformationToHelpDiagnose") . ":<br>\n";
 | |
| 3653 | +        $out .= $langs->trans("InformationToHelpDiagnose").":<br>\n";
 | |
| 3654 | 3654 | |
| 3655 | -        $out .= "<b>" . $langs->trans("Date") . ":</b> " . dol_print_date(time(), 'dayhourlog') . "<br>\n";
 | |
| 3656 | -        $out .= "<b>" . $langs->trans("Dolibarr") . ":</b> " . DOL_VERSION . "<br>\n";
 | |
| 3655 | +        $out .= "<b>".$langs->trans("Date").":</b> ".dol_print_date(time(), 'dayhourlog')."<br>\n";
 | |
| 3656 | +        $out .= "<b>".$langs->trans("Dolibarr").":</b> ".DOL_VERSION."<br>\n";
 | |
| 3657 | 3657 | if (isset($conf->global->MAIN_FEATURES_LEVEL)) | 
| 3658 | -            $out .= "<b>" . $langs->trans("LevelOfFeature") . ":</b> " . $conf->global->MAIN_FEATURES_LEVEL . "<br>\n";
 | |
| 3658 | +            $out .= "<b>".$langs->trans("LevelOfFeature").":</b> ".$conf->global->MAIN_FEATURES_LEVEL."<br>\n";
 | |
| 3659 | 3659 |          if (function_exists("phpversion")) {
 | 
| 3660 | -            $out .= "<b>" . $langs->trans("PHP") . ":</b> " . phpversion() . "<br>\n";
 | |
| 3660 | +            $out .= "<b>".$langs->trans("PHP").":</b> ".phpversion()."<br>\n";
 | |
| 3661 | 3661 | } | 
| 3662 | -        $out .= "<b>" . $langs->trans("Server") . ":</b> " . $_SERVER["SERVER_SOFTWARE"] . "<br>\n";
 | |
| 3662 | +        $out .= "<b>".$langs->trans("Server").":</b> ".$_SERVER["SERVER_SOFTWARE"]."<br>\n";
 | |
| 3663 | 3663 |          if (function_exists("php_uname")) {
 | 
| 3664 | -            $out .= "<b>" . $langs->trans("OS") . ":</b> " . php_uname() . "<br>\n";
 | |
| 3664 | +            $out .= "<b>".$langs->trans("OS").":</b> ".php_uname()."<br>\n";
 | |
| 3665 | 3665 | } | 
| 3666 | -        $out .= "<b>" . $langs->trans("UserAgent") . ":</b> " . $_SERVER["HTTP_USER_AGENT"] . "<br>\n";
 | |
| 3666 | +        $out .= "<b>".$langs->trans("UserAgent").":</b> ".$_SERVER["HTTP_USER_AGENT"]."<br>\n";
 | |
| 3667 | 3667 | $out .= "<br>\n"; | 
| 3668 | -        $out .= "<b>" . $langs->trans("RequestedUrl") . ":</b> " . dol_htmlentities($_SERVER["REQUEST_URI"], ENT_COMPAT, 'UTF-8') . "<br>\n";
 | |
| 3669 | -        $out .= "<b>" . $langs->trans("Referer") . ":</b> " . (isset($_SERVER["HTTP_REFERER"]) ? dol_htmlentities($_SERVER["HTTP_REFERER"], ENT_COMPAT, 'UTF-8') : '') . "<br>\n";
 | |
| 3670 | -        $out .= "<b>" . $langs->trans("MenuManager") . ":</b> " . (isset($conf->standard_menu) ? $conf->standard_menu : '') . "<br>\n";
 | |
| 3668 | +        $out .= "<b>".$langs->trans("RequestedUrl").":</b> ".dol_htmlentities($_SERVER["REQUEST_URI"], ENT_COMPAT, 'UTF-8')."<br>\n";
 | |
| 3669 | +        $out .= "<b>".$langs->trans("Referer").":</b> ".(isset($_SERVER["HTTP_REFERER"]) ? dol_htmlentities($_SERVER["HTTP_REFERER"], ENT_COMPAT, 'UTF-8') : '')."<br>\n";
 | |
| 3670 | +        $out .= "<b>".$langs->trans("MenuManager").":</b> ".(isset($conf->standard_menu) ? $conf->standard_menu : '')."<br>\n";
 | |
| 3671 | 3671 | $out .= "<br>\n"; | 
| 3672 | - $syslog .= "url=" . dol_escape_htmltag($_SERVER["REQUEST_URI"]); | |
| 3673 | - $syslog .= ", query_string=" . dol_escape_htmltag($_SERVER["QUERY_STRING"]); | |
| 3672 | + $syslog .= "url=".dol_escape_htmltag($_SERVER["REQUEST_URI"]); | |
| 3673 | + $syslog .= ", query_string=".dol_escape_htmltag($_SERVER["QUERY_STRING"]); | |
| 3674 | 3674 |      } else {                              // Mode CLI
 | 
| 3675 | -        $out .= '> ' . $langs->transnoentities("ErrorInternalErrorDetected") . ":\n" . $argv[0] . "\n";
 | |
| 3676 | - $syslog .= "pid=" . dol_getmypid(); | |
| 3675 | +        $out .= '> '.$langs->transnoentities("ErrorInternalErrorDetected").":\n".$argv[0]."\n";
 | |
| 3676 | + $syslog .= "pid=".dol_getmypid(); | |
| 3677 | 3677 | } | 
| 3678 | 3678 | |
| 3679 | 3679 |      if (is_object($db)) {
 | 
| 3680 | 3680 |          if ($_SERVER['DOCUMENT_ROOT']) {  // Mode web
 | 
| 3681 | -            $out .= "<b>" . $langs->trans("DatabaseTypeManager") . ":</b> " . $db->type . "<br>\n";
 | |
| 3682 | -            $out .= "<b>" . $langs->trans("RequestLastAccessInError") . ":</b> " . ($db->lastqueryerror() ? dol_escape_htmltag($db->lastqueryerror()) : $langs->trans("ErrorNoRequestInError")) . "<br>\n";
 | |
| 3683 | -            $out .= "<b>" . $langs->trans("ReturnCodeLastAccessInError") . ":</b> " . ($db->lasterrno() ? dol_escape_htmltag($db->lasterrno()) : $langs->trans("ErrorNoRequestInError")) . "<br>\n";
 | |
| 3684 | -            $out .= "<b>" . $langs->trans("InformationLastAccessInError") . ":</b> " . ($db->lasterror() ? dol_escape_htmltag($db->lasterror()) : $langs->trans("ErrorNoRequestInError")) . "<br>\n";
 | |
| 3681 | +            $out .= "<b>".$langs->trans("DatabaseTypeManager").":</b> ".$db->type."<br>\n";
 | |
| 3682 | +            $out .= "<b>".$langs->trans("RequestLastAccessInError").":</b> ".($db->lastqueryerror() ? dol_escape_htmltag($db->lastqueryerror()) : $langs->trans("ErrorNoRequestInError"))."<br>\n";
 | |
| 3683 | +            $out .= "<b>".$langs->trans("ReturnCodeLastAccessInError").":</b> ".($db->lasterrno() ? dol_escape_htmltag($db->lasterrno()) : $langs->trans("ErrorNoRequestInError"))."<br>\n";
 | |
| 3684 | +            $out .= "<b>".$langs->trans("InformationLastAccessInError").":</b> ".($db->lasterror() ? dol_escape_htmltag($db->lasterror()) : $langs->trans("ErrorNoRequestInError"))."<br>\n";
 | |
| 3685 | 3685 | $out .= "<br>\n"; | 
| 3686 | 3686 |          } else {                            // Mode CLI
 | 
| 3687 | 3687 | // No dol_escape_htmltag for output, we are in CLI mode | 
| 3688 | -            $out .= '> ' . $langs->transnoentities("DatabaseTypeManager") . ":\n" . $db->type . "\n";
 | |
| 3689 | -            $out .= '> ' . $langs->transnoentities("RequestLastAccessInError") . ":\n" . ($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities("ErrorNoRequestInError")) . "\n";
 | |
| 3690 | -            $out .= '> ' . $langs->transnoentities("ReturnCodeLastAccessInError") . ":\n" . ($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities("ErrorNoRequestInError")) . "\n";
 | |
| 3691 | -            $out .= '> ' . $langs->transnoentities("InformationLastAccessInError") . ":\n" . ($db->lasterror() ? $db->lasterror() : $langs->transnoentities("ErrorNoRequestInError")) . "\n";
 | |
| 3688 | +            $out .= '> '.$langs->transnoentities("DatabaseTypeManager").":\n".$db->type."\n";
 | |
| 3689 | +            $out .= '> '.$langs->transnoentities("RequestLastAccessInError").":\n".($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities("ErrorNoRequestInError"))."\n";
 | |
| 3690 | +            $out .= '> '.$langs->transnoentities("ReturnCodeLastAccessInError").":\n".($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities("ErrorNoRequestInError"))."\n";
 | |
| 3691 | +            $out .= '> '.$langs->transnoentities("InformationLastAccessInError").":\n".($db->lasterror() ? $db->lasterror() : $langs->transnoentities("ErrorNoRequestInError"))."\n";
 | |
| 3692 | 3692 | } | 
| 3693 | - $syslog .= ", sql=" . $db->lastquery(); | |
| 3694 | - $syslog .= ", db_error=" . $db->lasterror(); | |
| 3693 | + $syslog .= ", sql=".$db->lastquery(); | |
| 3694 | + $syslog .= ", db_error=".$db->lasterror(); | |
| 3695 | 3695 | } | 
| 3696 | 3696 | |
| 3697 | 3697 |      if ($error || $errors) {
 | 
| @@ -3711,31 +3711,31 @@ discard block | ||
| 3711 | 3711 | if (empty($msg)) | 
| 3712 | 3712 | continue; | 
| 3713 | 3713 |              if ($_SERVER['DOCUMENT_ROOT']) {  // Mode web
 | 
| 3714 | -                $out .= "<b>" . $langs->trans("Message") . ":</b> " . dol_escape_htmltag($msg) . "<br>\n";
 | |
| 3714 | +                $out .= "<b>".$langs->trans("Message").":</b> ".dol_escape_htmltag($msg)."<br>\n";
 | |
| 3715 | 3715 |              } else {                        // Mode CLI
 | 
| 3716 | -                $out .= '> ' . $langs->transnoentities("Message") . ":\n" . $msg . "\n";
 | |
| 3716 | +                $out .= '> '.$langs->transnoentities("Message").":\n".$msg."\n";
 | |
| 3717 | 3717 | } | 
| 3718 | - $syslog .= ", msg=" . $msg; | |
| 3718 | + $syslog .= ", msg=".$msg; | |
| 3719 | 3719 | } | 
| 3720 | 3720 | } | 
| 3721 | 3721 |      if (empty($dolibarr_main_prod) && $_SERVER['DOCUMENT_ROOT'] && function_exists('xdebug_print_function_stack') && function_exists('xdebug_call_file')) {
 | 
| 3722 | 3722 | xdebug_print_function_stack(); | 
| 3723 | - $out .= '<b>XDebug informations:</b>' . "<br>\n"; | |
| 3724 | - $out .= 'File: ' . xdebug_call_file() . "<br>\n"; | |
| 3725 | - $out .= 'Line: ' . xdebug_call_line() . "<br>\n"; | |
| 3726 | - $out .= 'Function: ' . xdebug_call_function() . "<br>\n"; | |
| 3723 | + $out .= '<b>XDebug informations:</b>'."<br>\n"; | |
| 3724 | + $out .= 'File: '.xdebug_call_file()."<br>\n"; | |
| 3725 | + $out .= 'Line: '.xdebug_call_line()."<br>\n"; | |
| 3726 | + $out .= 'Function: '.xdebug_call_function()."<br>\n"; | |
| 3727 | 3727 | $out .= "<br>\n"; | 
| 3728 | 3728 | } | 
| 3729 | 3729 | |
| 3730 | 3730 | if (empty($dolibarr_main_prod)) | 
| 3731 | 3731 | print $out; | 
| 3732 | 3732 |      else {
 | 
| 3733 | -        print $langs->trans("DolibarrHasDetectedError") . '. ';
 | |
| 3733 | +        print $langs->trans("DolibarrHasDetectedError").'. ';
 | |
| 3734 | 3734 |          print $langs->trans("YouCanSetOptionDolibarrMainProdToZero");
 | 
| 3735 | 3735 |          define("MAIN_CORE_ERROR", 1);
 | 
| 3736 | 3736 | } | 
| 3737 | 3737 | //else print 'Sorry, an error occured but the parameter $dolibarr_main_prod is defined in conf file so no message is reported to your browser. Please read the log file for error message.'; | 
| 3738 | -    dol_syslog("Error " . $syslog, LOG_ERR);
 | |
| 3738 | +    dol_syslog("Error ".$syslog, LOG_ERR);
 | |
| 3739 | 3739 | } | 
| 3740 | 3740 | |
| 3741 | 3741 | /** | 
| @@ -3758,13 +3758,13 @@ discard block | ||
| 3758 | 3758 |      $langs->load("errors");
 | 
| 3759 | 3759 | $now = dol_now(); | 
| 3760 | 3760 | |
| 3761 | - print '<br><div class="center login_main_message"><div class="' . $morecss . '">'; | |
| 3762 | -    print $langs->trans("ErrorContactEMail", $email, $prefixcode . dol_print_date($now, '%Y%m%d'));
 | |
| 3761 | + print '<br><div class="center login_main_message"><div class="'.$morecss.'">'; | |
| 3762 | +    print $langs->trans("ErrorContactEMail", $email, $prefixcode.dol_print_date($now, '%Y%m%d'));
 | |
| 3763 | 3763 | if ($errormessage) | 
| 3764 | - print '<br><br>' . $errormessage; | |
| 3764 | + print '<br><br>'.$errormessage; | |
| 3765 | 3765 |      if (is_array($errormessages) && count($errormessages)) {
 | 
| 3766 | 3766 |          foreach ($errormessages as $mesgtoshow) {
 | 
| 3767 | - print '<br><br>' . $mesgtoshow; | |
| 3767 | + print '<br><br>'.$mesgtoshow; | |
| 3768 | 3768 | } | 
| 3769 | 3769 | } | 
| 3770 | 3770 | print '</div></div>'; | 
| @@ -3822,16 +3822,16 @@ discard block | ||
| 3822 | 3822 | } | 
| 3823 | 3823 | |
| 3824 | 3824 |      $tmpsortfield = explode(',', $sortfield);
 | 
| 3825 | - $sortfield1 = trim($tmpsortfield[0]); // If $sortfield is 'd.datep,d.id', it becomes 'd.datep' | |
| 3825 | + $sortfield1 = trim($tmpsortfield[0]); // If $sortfield is 'd.datep,d.id', it becomes 'd.datep' | |
| 3826 | 3826 |      $tmpfield = explode(',', $field);
 | 
| 3827 | - $field1 = trim($tmpfield[0]); // If $field is 'd.datep,d.id', it becomes 'd.datep' | |
| 3827 | + $field1 = trim($tmpfield[0]); // If $field is 'd.datep,d.id', it becomes 'd.datep' | |
| 3828 | 3828 |      //var_dump('field='.$field.' field1='.$field1.' sortfield='.$sortfield.' sortfield1='.$sortfield1);
 | 
| 3829 | 3829 | // If field is used as sort criteria we use a specific css class liste_titre_sel | 
| 3830 | 3830 |      // Example if (sortfield,field)=("nom","xxx.nom") or (sortfield,field)=("nom","nom")
 | 
| 3831 | 3831 |      if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace("/^[^\.]+\./", "", $field1))) {
 | 
| 3832 | - $out .= '<' . $tag . ' class="' . $prefix . 'liste_titre_sel" ' . $moreattrib . '>'; | |
| 3832 | + $out .= '<'.$tag.' class="'.$prefix.'liste_titre_sel" '.$moreattrib.'>'; | |
| 3833 | 3833 |      } else {
 | 
| 3834 | - $out .= '<' . $tag . ' class="' . $prefix . 'liste_titre" ' . $moreattrib . '>'; | |
| 3834 | + $out .= '<'.$tag.' class="'.$prefix.'liste_titre" '.$moreattrib.'>'; | |
| 3835 | 3835 | } | 
| 3836 | 3836 | |
| 3837 | 3837 |      if (empty($thead) && $field && empty($disablesortlink)) {    // If this is a sort field
 | 
| @@ -3839,7 +3839,7 @@ discard block | ||
| 3839 | 3839 |          $options = preg_replace('/sortorder=([a-zA-Z0-9,\s\.]+)/i', '', $options);
 | 
| 3840 | 3840 |          $options = preg_replace('/&+/i', '&', $options);
 | 
| 3841 | 3841 |          if (!preg_match('/^&/', $options)) {
 | 
| 3842 | - $options = '&' . $options; | |
| 3842 | + $options = '&'.$options; | |
| 3843 | 3843 | } | 
| 3844 | 3844 | |
| 3845 | 3845 | $sortordertouseinlink = ''; | 
| @@ -3857,7 +3857,7 @@ discard block | ||
| 3857 | 3857 | } | 
| 3858 | 3858 | } | 
| 3859 | 3859 |          $sortordertouseinlink = preg_replace('/,$/', '', $sortordertouseinlink);
 | 
| 3860 | - $out .= '<a class="reposition" href="' . $file . '?sortfield=' . $field . '&sortorder=' . $sortordertouseinlink . '&begin=' . $begin . $options . '">'; | |
| 3860 | + $out .= '<a class="reposition" href="'.$file.'?sortfield='.$field.'&sortorder='.$sortordertouseinlink.'&begin='.$begin.$options.'">'; | |
| 3861 | 3861 | } | 
| 3862 | 3862 | |
| 3863 | 3863 |      if ($tooltip) {
 | 
| @@ -3875,7 +3875,7 @@ discard block | ||
| 3875 | 3875 |          $options = preg_replace('/sortorder=([a-zA-Z0-9,\s\.]+)/i', '', $options);
 | 
| 3876 | 3876 |          $options = preg_replace('/&+/i', '&', $options);
 | 
| 3877 | 3877 |          if (!preg_match('/^&/', $options)) {
 | 
| 3878 | - $options = '&' . $options; | |
| 3878 | + $options = '&'.$options; | |
| 3879 | 3879 | } | 
| 3880 | 3880 | |
| 3881 | 3881 |          if (!$sortorder || $field1 != $sortfield1) {
 | 
| @@ -3885,19 +3885,19 @@ discard block | ||
| 3885 | 3885 |              if (preg_match('/^DESC/', $sortorder)) {
 | 
| 3886 | 3886 |                  //$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>';
 | 
| 3887 | 3887 |                  //$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",1).'</a>';
 | 
| 3888 | -                $sortimg .= '<span class="nowrap">' . img_up("Z-A", 0) . '</span>';
 | |
| 3888 | +                $sortimg .= '<span class="nowrap">'.img_up("Z-A", 0).'</span>';
 | |
| 3889 | 3889 | } | 
| 3890 | 3890 |              if (preg_match('/^ASC/', $sortorder)) {
 | 
| 3891 | 3891 |                  //$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",1).'</a>';
 | 
| 3892 | 3892 |                  //$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>';
 | 
| 3893 | -                $sortimg .= '<span class="nowrap">' . img_down("A-Z", 0) . '</span>';
 | |
| 3893 | +                $sortimg .= '<span class="nowrap">'.img_down("A-Z", 0).'</span>';
 | |
| 3894 | 3894 | } | 
| 3895 | 3895 | } | 
| 3896 | 3896 | } | 
| 3897 | 3897 | |
| 3898 | 3898 | $out .= $sortimg; | 
| 3899 | 3899 | |
| 3900 | - $out .= '</' . $tag . '>'; | |
| 3900 | + $out .= '</'.$tag.'>'; | |
| 3901 | 3901 | |
| 3902 | 3902 | return $out; | 
| 3903 | 3903 | } | 
| @@ -3912,9 +3912,9 @@ discard block | ||
| 3912 | 3912 | */ | 
| 3913 | 3913 | function print_titre($title) | 
| 3914 | 3914 |  {
 | 
| 3915 | - dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); | |
| 3915 | + dol_syslog(__FUNCTION__." is deprecated", LOG_WARNING); | |
| 3916 | 3916 | |
| 3917 | - print '<div class="titre">' . $title . '</div>'; | |
| 3917 | + print '<div class="titre">'.$title.'</div>'; | |
| 3918 | 3918 | } | 
| 3919 | 3919 | |
| 3920 | 3920 | /** | 
| @@ -3957,20 +3957,20 @@ discard block | ||
| 3957 | 3957 | } | 
| 3958 | 3958 | |
| 3959 | 3959 | $return .= "\n"; | 
| 3960 | - $return .= '<table ' . ($id ? 'id="' . $id . '" ' : '') . 'summary="" class="centpercent notopnoleftnoright' . ($morecssontable ? ' ' . $morecssontable : '') . '" style="margin-bottom: 6px;"><tr>'; // maring bottom must be same than into print_barre_list | |
| 3960 | + $return .= '<table '.($id ? 'id="'.$id.'" ' : '').'summary="" class="centpercent notopnoleftnoright'.($morecssontable ? ' '.$morecssontable : '').'" style="margin-bottom: 6px;"><tr>'; // maring bottom must be same than into print_barre_list | |
| 3961 | 3961 |      if ($picto) {
 | 
| 3962 | -        $return .= '<td class="nobordernopadding widthpictotitle opacityhigh" valign="middle">' . img_picto('', $picto, 'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath) . '</td>';
 | |
| 3962 | +        $return .= '<td class="nobordernopadding widthpictotitle opacityhigh" valign="middle">'.img_picto('', $picto, 'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).'</td>';
 | |
| 3963 | 3963 | } | 
| 3964 | 3964 | $return .= '<td class="nobordernopadding valignmiddle">'; | 
| 3965 | - $return .= '<div class="titre inline-block">' . $titre . '</div>'; | |
| 3965 | + $return .= '<div class="titre inline-block">'.$titre.'</div>'; | |
| 3966 | 3966 | $return .= '</td>'; | 
| 3967 | 3967 |      if (dol_strlen($morehtmlcenter)) {
 | 
| 3968 | - $return .= '<td class="nobordernopadding" align="center" valign="middle">' . $morehtmlcenter . '</td>'; | |
| 3968 | + $return .= '<td class="nobordernopadding" align="center" valign="middle">'.$morehtmlcenter.'</td>'; | |
| 3969 | 3969 | } | 
| 3970 | 3970 |      if (dol_strlen($morehtmlright)) {
 | 
| 3971 | - $return .= '<td class="nobordernopadding titre_right wordbreak" align="right" valign="middle">' . $morehtmlright . '</td>'; | |
| 3971 | + $return .= '<td class="nobordernopadding titre_right wordbreak" align="right" valign="middle">'.$morehtmlright.'</td>'; | |
| 3972 | 3972 | } | 
| 3973 | - $return .= '</tr></table>' . "\n"; | |
| 3973 | + $return .= '</tr></table>'."\n"; | |
| 3974 | 3974 | |
| 3975 | 3975 | return $return; | 
| 3976 | 3976 | } | 
| @@ -4018,29 +4018,29 @@ discard block | ||
| 4018 | 4018 | //print 'totalnboflines='.$totalnboflines.'-savlimit='.$savlimit.'-limit='.$limit.'-num='.$num.'-nextpage='.$nextpage; | 
| 4019 | 4019 | |
| 4020 | 4020 | print "\n"; | 
| 4021 | - print "<!-- Begin title '" . $titre . "' -->\n"; | |
| 4022 | - print '<table border="0" class="centpercent notopnoleftnoright' . ($morecss ? ' ' . $morecss : '') . '" style="margin-bottom: 6px;"><tr>'; // maring bottom must be same than into load_fiche_tire | |
| 4021 | + print "<!-- Begin title '".$titre."' -->\n"; | |
| 4022 | + print '<table border="0" class="centpercent notopnoleftnoright'.($morecss ? ' '.$morecss : '').'" style="margin-bottom: 6px;"><tr>'; // maring bottom must be same than into load_fiche_tire | |
| 4023 | 4023 | // Left | 
| 4024 | 4024 |      //if ($picto && $titre) print '<td class="nobordernopadding hideonsmartphone" width="40" align="left" valign="middle">'.img_picto('', $picto, 'id="pictotitle"', $pictoisfullpath).'</td>';
 | 
| 4025 | 4025 | print '<td class="nobordernopadding valignmiddle">'; | 
| 4026 | 4026 | if ($picto && $titre) | 
| 4027 | 4027 |          print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh pictotitle widthpictotitle"', $pictoisfullpath);
 | 
| 4028 | - print '<div class="titre inline-block">' . $titre; | |
| 4028 | + print '<div class="titre inline-block">'.$titre; | |
| 4029 | 4029 | if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') | 
| 4030 | -        print ' (' . $totalnboflines . ')';
 | |
| 4030 | +        print ' ('.$totalnboflines.')';
 | |
| 4031 | 4031 | print '</div></td>'; | 
| 4032 | 4032 | |
| 4033 | 4033 | // Center | 
| 4034 | 4034 |      if ($morehtmlcenter) {
 | 
| 4035 | - print '<td class="nobordernopadding center valignmiddle">' . $morehtmlcenter . '</td>'; | |
| 4035 | + print '<td class="nobordernopadding center valignmiddle">'.$morehtmlcenter.'</td>'; | |
| 4036 | 4036 | } | 
| 4037 | 4037 | |
| 4038 | 4038 | // Right | 
| 4039 | 4039 | print '<td class="nobordernopadding valignmiddle" align="right">'; | 
| 4040 | 4040 | if ($sortfield) | 
| 4041 | - $options .= "&sortfield=" . urlencode($sortfield); | |
| 4041 | + $options .= "&sortfield=".urlencode($sortfield); | |
| 4042 | 4042 | if ($sortorder) | 
| 4043 | - $options .= "&sortorder=" . urlencode($sortorder); | |
| 4043 | + $options .= "&sortorder=".urlencode($sortorder); | |
| 4044 | 4044 | // Show navigation bar | 
| 4045 | 4045 | $pagelist = ''; | 
| 4046 | 4046 |      if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
 | 
| @@ -4058,40 +4058,40 @@ discard block | ||
| 4058 | 4058 | } | 
| 4059 | 4059 | |
| 4060 | 4060 |              if ($cpt >= 1) {
 | 
| 4061 | - $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=0' . $options . '">1</a></li>'; | |
| 4061 | + $pagelist .= '<li'.(($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><a href="'.$file.'?page=0'.$options.'">1</a></li>'; | |
| 4062 | 4062 | if ($cpt > 2) | 
| 4063 | - $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>'; | |
| 4063 | + $pagelist .= '<li'.(($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><span '.(($conf->dol_use_jmobile != 4) ? 'class="inactive"' : '').'>...</span></li>'; | |
| 4064 | 4064 | else if ($cpt == 2) | 
| 4065 | - $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=1' . $options . '">2</a></li>'; | |
| 4065 | + $pagelist .= '<li'.(($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><a href="'.$file.'?page=1'.$options.'">2</a></li>'; | |
| 4066 | 4066 | } | 
| 4067 | 4067 | |
| 4068 | 4068 |              do {
 | 
| 4069 | 4069 |                  if ($cpt == $page) {
 | 
| 4070 | - $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="active"' : '') . '>' . ($page + 1) . '</span></li>'; | |
| 4070 | + $pagelist .= '<li'.(($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><span '.(($conf->dol_use_jmobile != 4) ? 'class="active"' : '').'>'.($page + 1).'</span></li>'; | |
| 4071 | 4071 |                  } else {
 | 
| 4072 | - $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . $cpt . $options . '">' . ($cpt + 1) . '</a></li>'; | |
| 4072 | + $pagelist .= '<li'.(($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><a href="'.$file.'?page='.$cpt.$options.'">'.($cpt + 1).'</a></li>'; | |
| 4073 | 4073 | } | 
| 4074 | 4074 | $cpt++; | 
| 4075 | 4075 | } while ($cpt < $nbpages && $cpt <= $page + $maxnbofpage); | 
| 4076 | 4076 | |
| 4077 | 4077 |              if ($cpt < $nbpages) {
 | 
| 4078 | 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>'; | |
| 4079 | + $pagelist .= '<li'.(($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><span '.(($conf->dol_use_jmobile != 4) ? 'class="inactive"' : '').'>...</span></li>'; | |
| 4080 | 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>'; | |
| 4082 | - $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 1) . $options . '">' . $nbpages . '</a></li>'; | |
| 4081 | + $pagelist .= '<li'.(($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><a href="'.$file.'?page='.($nbpages - 2).$options.'">'.($nbpages - 1).'</a></li>'; | |
| 4082 | + $pagelist .= '<li'.(($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><a href="'.$file.'?page='.($nbpages - 1).$options.'">'.$nbpages.'</a></li>'; | |
| 4083 | 4083 | } | 
| 4084 | 4084 | } | 
| 4085 | 4085 |          else {
 | 
| 4086 | - $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="active"' : '') . '>' . ($page + 1) . "</li>"; | |
| 4086 | + $pagelist .= '<li'.(($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><span '.(($conf->dol_use_jmobile != 4) ? 'class="active"' : '').'>'.($page + 1)."</li>"; | |
| 4087 | 4087 | } | 
| 4088 | 4088 | } | 
| 4089 | 4089 | |
| 4090 | - print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit); // output the div and ul for previous/last completed with page numbers into $pagelist | |
| 4090 | + print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit); // output the div and ul for previous/last completed with page numbers into $pagelist | |
| 4091 | 4091 | |
| 4092 | 4092 | print '</td>'; | 
| 4093 | 4093 | |
| 4094 | - print '</tr></table>' . "\n"; | |
| 4094 | + print '</tr></table>'."\n"; | |
| 4095 | 4095 | print "<!-- End title -->\n\n"; | 
| 4096 | 4096 | } | 
| 4097 | 4097 | |
| @@ -4122,12 +4122,12 @@ discard block | ||
| 4122 | 4122 | $pagesizechoices = $conf->global->MAIN_PAGESIZE_CHOICES; | 
| 4123 | 4123 | |
| 4124 | 4124 | print '<li class="pagination">'; | 
| 4125 | -        print '<select class="flat selectlimit" name="limit" title="' . dol_escape_htmltag($langs->trans("MaxNbOfRecordPerPage")) . '">';
 | |
| 4125 | +        print '<select class="flat selectlimit" name="limit" title="'.dol_escape_htmltag($langs->trans("MaxNbOfRecordPerPage")).'">';
 | |
| 4126 | 4126 |          $tmpchoice = explode(',', $pagesizechoices);
 | 
| 4127 | - $tmpkey = $limit . ':' . $limit; | |
| 4127 | + $tmpkey = $limit.':'.$limit; | |
| 4128 | 4128 | if (!in_array($tmpkey, $tmpchoice)) | 
| 4129 | 4129 | $tmpchoice[] = $tmpkey; | 
| 4130 | - $tmpkey = $conf->liste_limit . ':' . $conf->liste_limit; | |
| 4130 | + $tmpkey = $conf->liste_limit.':'.$conf->liste_limit; | |
| 4131 | 4131 | if (!in_array($tmpkey, $tmpchoice)) | 
| 4132 | 4132 | $tmpchoice[] = $tmpkey; | 
| 4133 | 4133 | asort($tmpchoice, SORT_NUMERIC); | 
| @@ -4142,7 +4142,7 @@ discard block | ||
| 4142 | 4142 | $selected = ' selected="selected"'; | 
| 4143 | 4143 | $found = true; | 
| 4144 | 4144 | } | 
| 4145 | - print '<option name="' . $key . '"' . $selected . '>' . dol_escape_htmltag($val) . '</option>' . "\n"; | |
| 4145 | + print '<option name="'.$key.'"'.$selected.'>'.dol_escape_htmltag($val).'</option>'."\n"; | |
| 4146 | 4146 | } | 
| 4147 | 4147 | } | 
| 4148 | 4148 | print '</select>'; | 
| @@ -4161,20 +4161,20 @@ discard block | ||
| 4161 | 4161 | print '</li>'; | 
| 4162 | 4162 | } | 
| 4163 | 4163 |      if ($page > 0) {
 | 
| 4164 | -        print '<li class="pagination"><a class="paginationprevious" href="' . $file . '?page=' . ($page - 1) . $options . '"><i class="fa fa-chevron-left" title="' . dol_escape_htmltag($langs->trans("Previous")) . '"></i></a></li>';
 | |
| 4164 | +        print '<li class="pagination"><a class="paginationprevious" href="'.$file.'?page='.($page - 1).$options.'"><i class="fa fa-chevron-left" title="'.dol_escape_htmltag($langs->trans("Previous")).'"></i></a></li>';
 | |
| 4165 | 4165 | } | 
| 4166 | 4166 |      if ($betweenarrows) {
 | 
| 4167 | 4167 | print $betweenarrows; | 
| 4168 | 4168 | } | 
| 4169 | 4169 |      if ($nextpage > 0) {
 | 
| 4170 | -        print '<li class="pagination"><a class="paginationnext" href="' . $file . '?page=' . ($page + 1) . $options . '"><i class="fa fa-chevron-right" title="' . dol_escape_htmltag($langs->trans("Next")) . '"></i></a></li>';
 | |
| 4170 | +        print '<li class="pagination"><a class="paginationnext" href="'.$file.'?page='.($page + 1).$options.'"><i class="fa fa-chevron-right" title="'.dol_escape_htmltag($langs->trans("Next")).'"></i></a></li>';
 | |
| 4171 | 4171 | } | 
| 4172 | 4172 |      if ($afterarrows) {
 | 
| 4173 | 4173 | print '<li class="paginationafterarrows">'; | 
| 4174 | 4174 | print $afterarrows; | 
| 4175 | 4175 | print '</li>'; | 
| 4176 | 4176 | } | 
| 4177 | - print '</ul></div>' . "\n"; | |
| 4177 | + print '</ul></div>'."\n"; | |
| 4178 | 4178 | } | 
| 4179 | 4179 | |
| 4180 | 4180 | /** | 
| @@ -4196,8 +4196,8 @@ discard block | ||
| 4196 | 4196 | $addpercent = true; | 
| 4197 | 4197 | } | 
| 4198 | 4198 |      if (preg_match('/\((.*)\)/', $rate, $reg)) {
 | 
| 4199 | -        $morelabel = ' (' . $reg[1] . ')';
 | |
| 4200 | -        $rate = preg_replace('/\s*' . preg_quote($morelabel, '/') . '/', '', $rate);
 | |
| 4199 | +        $morelabel = ' ('.$reg[1].')';
 | |
| 4200 | +        $rate = preg_replace('/\s*'.preg_quote($morelabel, '/').'/', '', $rate);
 | |
| 4201 | 4201 | } | 
| 4202 | 4202 |      if (preg_match('/\*/', $rate)) {
 | 
| 4203 | 4203 |          $rate = str_replace('*', '', $rate);
 | 
| @@ -4206,10 +4206,10 @@ discard block | ||
| 4206 | 4206 | |
| 4207 | 4207 | // If rate is '9/9/9' we don't change it. If rate is '9.000' we apply price() | 
| 4208 | 4208 |      if (!preg_match('/\//', $rate))
 | 
| 4209 | - $ret = price($rate, 0, '', 0, 0) . ($addpercent ? '%' : ''); | |
| 4209 | + $ret = price($rate, 0, '', 0, 0).($addpercent ? '%' : ''); | |
| 4210 | 4210 |      else {
 | 
| 4211 | 4211 | // TODO Split on / and output with a price2num to have clean numbers without ton of 000. | 
| 4212 | - $ret = $rate . ($addpercent ? '%' : ''); | |
| 4212 | + $ret = $rate.($addpercent ? '%' : ''); | |
| 4213 | 4213 | } | 
| 4214 | 4214 | if (($info_bits & 1) && $usestarfornpr >= 0) | 
| 4215 | 4215 | $ret .= ' *'; | 
| @@ -4303,10 +4303,10 @@ discard block | ||
| 4303 | 4303 | $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code); | 
| 4304 | 4304 |          else {
 | 
| 4305 | 4305 | $tmpcur = $outlangs->getCurrencySymbol($currency_code); | 
| 4306 | - $cursymbolafter .= ($tmpcur == $currency_code ? ' ' . $tmpcur : $tmpcur); | |
| 4306 | + $cursymbolafter .= ($tmpcur == $currency_code ? ' '.$tmpcur : $tmpcur); | |
| 4307 | 4307 | } | 
| 4308 | 4308 | } | 
| 4309 | - $output = $cursymbolbefore . $output . $end . ($cursymbolafter ? ' ' : '') . $cursymbolafter; | |
| 4309 | + $output = $cursymbolbefore.$output.$end.($cursymbolafter ? ' ' : '').$cursymbolafter; | |
| 4310 | 4310 | |
| 4311 | 4311 | return $output; | 
| 4312 | 4312 | } | 
| @@ -4360,7 +4360,7 @@ discard block | ||
| 4360 | 4360 | // Now make replace (the main goal of function) | 
| 4361 | 4361 | if ($thousand != ',' && $thousand != '.') | 
| 4362 | 4362 |              $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
 | 
| 4363 | -        $amount = str_replace(' ', '', $amount);  // To avoid spaces
 | |
| 4363 | +        $amount = str_replace(' ', '', $amount); // To avoid spaces
 | |
| 4364 | 4364 | $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . | 
| 4365 | 4365 | $amount = str_replace($dec, '.', $amount); | 
| 4366 | 4366 | } | 
| @@ -4389,14 +4389,14 @@ discard block | ||
| 4389 | 4389 |              $temps = sprintf("%0.10F", $amount - intval($amount)); // temps=0.0000000000 or 0.0000200000 or 9999.1000000000
 | 
| 4390 | 4390 |              $temps = preg_replace('/([\.1-9])0+$/', '\\1', $temps); // temps=0. or 0.00002 or 9999.1
 | 
| 4391 | 4391 | $nbofdec = max(0, dol_strlen($temps) - 2); // -2 to remove "0." | 
| 4392 | - $amount = number_format($amount, min($nbofdec, $nbofdectoround), $dec, $thousand); // Convert amount to format with dolibarr dec and thousand | |
| 4392 | + $amount = number_format($amount, min($nbofdec, $nbofdectoround), $dec, $thousand); // Convert amount to format with dolibarr dec and thousand | |
| 4393 | 4393 | } | 
| 4394 | 4394 | //print "TT".$amount.'<br>'; | 
| 4395 | 4395 | // Always make replace because each math function (like round) replace | 
| 4396 | 4396 | // with local values and we want a number that has a SQL string format x.y | 
| 4397 | 4397 | if ($thousand != ',' && $thousand != '.') | 
| 4398 | 4398 |              $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
 | 
| 4399 | -        $amount = str_replace(' ', '', $amount);  // To avoid spaces
 | |
| 4399 | +        $amount = str_replace(' ', '', $amount); // To avoid spaces
 | |
| 4400 | 4400 | $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . | 
| 4401 | 4401 | $amount = str_replace($dec, '.', $amount); | 
| 4402 | 4402 | } | 
| @@ -4417,7 +4417,7 @@ discard block | ||
| 4417 | 4417 | */ | 
| 4418 | 4418 | function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round = -1, $forceunitoutput = 'no') | 
| 4419 | 4419 |  {
 | 
| 4420 | - require_once DOL_BASE_PATH . '/core/lib/product.lib.php'; | |
| 4420 | + require_once DOL_BASE_PATH.'/core/lib/product.lib.php'; | |
| 4421 | 4421 | |
| 4422 | 4422 |      if (($forceunitoutput == 'no' && $dimension < 1 / 10000) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) {
 | 
| 4423 | 4423 | $dimension = $dimension * 1000000; | 
| @@ -4433,7 +4433,7 @@ discard block | ||
| 4433 | 4433 | $unit = $unit + 3; | 
| 4434 | 4434 | } | 
| 4435 | 4435 | |
| 4436 | - $ret = price($dimension, 0, $outputlangs, 0, 0, $round) . ' ' . measuring_units_string($unit, $type); | |
| 4436 | + $ret = price($dimension, 0, $outputlangs, 0, 0, $round).' '.measuring_units_string($unit, $type); | |
| 4437 | 4437 | |
| 4438 | 4438 | return $ret; | 
| 4439 | 4439 | } | 
| @@ -4457,7 +4457,7 @@ discard block | ||
| 4457 | 4457 | if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) | 
| 4458 | 4458 | $thirdparty_seller = $mysoc; | 
| 4459 | 4459 | |
| 4460 | -    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);
 | |
| 4460 | +    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 | 4461 | |
| 4462 | 4462 | $vatratecleaned = $vatrate; | 
| 4463 | 4463 |      if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {      // If vat is "xx (yy)"
 | 
| @@ -4488,7 +4488,7 @@ discard block | ||
| 4488 | 4488 |          if ($local == 2) {
 | 
| 4489 | 4489 | //if (! $mysoc->localtax2_assuj || (string) $vatratecleaned == "0") return 0; | 
| 4490 | 4490 | if (!$mysoc->localtax2_assuj) | 
| 4491 | - return 0; // If main vat is 0, IRPF may be different than 0. | |
| 4491 | + return 0; // If main vat is 0, IRPF may be different than 0. | |
| 4492 | 4492 |              if ($thirdparty_seller->id == $mysoc->id) {
 | 
| 4493 | 4493 | if (!$thirdparty_buyer->localtax2_assuj) | 
| 4494 | 4494 | return 0; | 
| @@ -4542,13 +4542,13 @@ discard block | ||
| 4542 | 4542 | |
| 4543 | 4543 | // By default, search value of local tax on line of common tax | 
| 4544 | 4544 | $sql = "SELECT t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; | 
| 4545 | - $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c"; | |
| 4546 | - $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $thirdparty_seller->country_code . "'"; | |
| 4547 | - $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1"; | |
| 4545 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; | |
| 4546 | + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$thirdparty_seller->country_code."'"; | |
| 4547 | + $sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; | |
| 4548 | 4548 | if ($vatratecode) | 
| 4549 | - $sql .= " AND t.code ='" . $vatratecode . "'"; // If we have the code, we use it in priority | |
| 4549 | + $sql .= " AND t.code ='".$vatratecode."'"; // If we have the code, we use it in priority | |
| 4550 | 4550 | else | 
| 4551 | - $sql .= " AND t.recuperableonly ='" . $vatnpr . "'"; | |
| 4551 | + $sql .= " AND t.recuperableonly ='".$vatnpr."'"; | |
| 4552 | 4552 |      dol_syslog("get_localtax", LOG_DEBUG);
 | 
| 4553 | 4553 | $resql = $db->query($sql); | 
| 4554 | 4554 | |
| @@ -4594,10 +4594,10 @@ discard block | ||
| 4594 | 4594 |  {
 | 
| 4595 | 4595 | global $db, $mysoc; | 
| 4596 | 4596 | $sql = "SELECT t.localtax1, t.localtax2 "; | 
| 4597 | - $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t inner join " . MAIN_DB_PREFIX . "c_country as c ON c.rowid=t.fk_pays"; | |
| 4598 | -    $sql .= " WHERE c.code = '" . $mysoc->country_code . "' AND t.active = 1 AND t.taux=(";
 | |
| 4599 | - $sql .= " SELECT max(tt.taux) FROM " . MAIN_DB_PREFIX . "c_tva as tt inner join " . MAIN_DB_PREFIX . "c_country as c ON c.rowid=tt.fk_pays"; | |
| 4600 | - $sql .= " WHERE c.code = '" . $mysoc->country_code . "' AND tt.active = 1"; | |
| 4597 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t inner join ".MAIN_DB_PREFIX."c_country as c ON c.rowid=t.fk_pays"; | |
| 4598 | +    $sql .= " WHERE c.code = '".$mysoc->country_code."' AND t.active = 1 AND t.taux=(";
 | |
| 4599 | + $sql .= " SELECT max(tt.taux) FROM ".MAIN_DB_PREFIX."c_tva as tt inner join ".MAIN_DB_PREFIX."c_country as c ON c.rowid=tt.fk_pays"; | |
| 4600 | + $sql .= " WHERE c.code = '".$mysoc->country_code."' AND tt.active = 1"; | |
| 4601 | 4601 | $sql .= " )"; | 
| 4602 | 4602 | |
| 4603 | 4603 | $resql = $db->query($sql); | 
| @@ -4627,13 +4627,13 @@ discard block | ||
| 4627 | 4627 |  {
 | 
| 4628 | 4628 | global $db, $mysoc; | 
| 4629 | 4629 | |
| 4630 | -    dol_syslog("getTaxesFromId vat id or rate = " . $vatrate);
 | |
| 4630 | +    dol_syslog("getTaxesFromId vat id or rate = ".$vatrate);
 | |
| 4631 | 4631 | |
| 4632 | 4632 | // Search local taxes | 
| 4633 | 4633 | $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy"; | 
| 4634 | - $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t"; | |
| 4634 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t"; | |
| 4635 | 4635 | if ($firstparamisid) | 
| 4636 | - $sql .= " WHERE t.rowid = " . (int) $vatrate; | |
| 4636 | + $sql .= " WHERE t.rowid = ".(int) $vatrate; | |
| 4637 | 4637 |      else {
 | 
| 4638 | 4638 | $vatratecleaned = $vatrate; | 
| 4639 | 4639 | $vatratecode = ''; | 
| @@ -4642,13 +4642,13 @@ discard block | ||
| 4642 | 4642 | $vatratecode = $reg[2]; | 
| 4643 | 4643 | } | 
| 4644 | 4644 | |
| 4645 | - $sql .= ", " . MAIN_DB_PREFIX . "c_country as c"; | |
| 4645 | + $sql .= ", ".MAIN_DB_PREFIX."c_country as c"; | |
| 4646 | 4646 | /* if ($mysoc->country_code == 'ES') $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'"; // vat in spain use the buyer country ?? | 
| 4647 | 4647 | else $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; */ | 
| 4648 | - $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'"; | |
| 4649 | - $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1"; | |
| 4648 | + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; | |
| 4649 | + $sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; | |
| 4650 | 4650 | if ($vatratecode) | 
| 4651 | - $sql .= " AND t.code = '" . $vatratecode . "'"; | |
| 4651 | + $sql .= " AND t.code = '".$vatratecode."'"; | |
| 4652 | 4652 | } | 
| 4653 | 4653 | |
| 4654 | 4654 | $resql = $db->query($sql); | 
| @@ -4684,13 +4684,13 @@ discard block | ||
| 4684 | 4684 |  {
 | 
| 4685 | 4685 | global $db, $mysoc; | 
| 4686 | 4686 | |
| 4687 | -    dol_syslog("getLocalTaxesFromRate vatrate=" . $vatrate . " local=" . $local);
 | |
| 4687 | +    dol_syslog("getLocalTaxesFromRate vatrate=".$vatrate." local=".$local);
 | |
| 4688 | 4688 | |
| 4689 | 4689 | // Search local taxes | 
| 4690 | 4690 | $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy"; | 
| 4691 | - $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t"; | |
| 4691 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t"; | |
| 4692 | 4692 | if ($firstparamisid) | 
| 4693 | - $sql .= " WHERE t.rowid = " . (int) $vatrate; | |
| 4693 | + $sql .= " WHERE t.rowid = ".(int) $vatrate; | |
| 4694 | 4694 |      else {
 | 
| 4695 | 4695 | $vatratecleaned = $vatrate; | 
| 4696 | 4696 | $vatratecode = ''; | 
| @@ -4699,14 +4699,14 @@ discard block | ||
| 4699 | 4699 | $vatratecode = $reg[2]; | 
| 4700 | 4700 | } | 
| 4701 | 4701 | |
| 4702 | - $sql .= ", " . MAIN_DB_PREFIX . "c_country as c"; | |
| 4702 | + $sql .= ", ".MAIN_DB_PREFIX."c_country as c"; | |
| 4703 | 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 ?? | |
| 4704 | + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'"; // local tax in spain use the buyer country ?? | |
| 4705 | 4705 | else | 
| 4706 | - $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'"; | |
| 4707 | - $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1"; | |
| 4706 | + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; | |
| 4707 | + $sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1"; | |
| 4708 | 4708 | if ($vatratecode) | 
| 4709 | - $sql .= " AND t.code = '" . $vatratecode . "'"; | |
| 4709 | + $sql .= " AND t.code = '".$vatratecode."'"; | |
| 4710 | 4710 | } | 
| 4711 | 4711 | |
| 4712 | 4712 | $resql = $db->query($sql); | 
| @@ -4738,7 +4738,7 @@ discard block | ||
| 4738 | 4738 |  {
 | 
| 4739 | 4739 | global $db, $conf, $mysoc; | 
| 4740 | 4740 | |
| 4741 | - require_once DOL_BASE_PATH . '/product/class/product.class.php'; | |
| 4741 | + require_once DOL_BASE_PATH.'/product/class/product.class.php'; | |
| 4742 | 4742 | |
| 4743 | 4743 | $ret = 0; | 
| 4744 | 4744 | $found = 0; | 
| @@ -4753,12 +4753,12 @@ discard block | ||
| 4753 | 4753 | $product->get_buyprice($idprodfournprice, 0, 0, 0); | 
| 4754 | 4754 | $ret = $product->vatrate_supplier; | 
| 4755 | 4755 | if ($product->default_vat_code) | 
| 4756 | -                    $ret .= ' (' . $product->default_vat_code . ')';
 | |
| 4756 | +                    $ret .= ' ('.$product->default_vat_code.')';
 | |
| 4757 | 4757 | } | 
| 4758 | 4758 |              else {
 | 
| 4759 | - $ret = $product->tva_tx; // Default vat of product we defined | |
| 4759 | + $ret = $product->tva_tx; // Default vat of product we defined | |
| 4760 | 4760 | if ($product->default_vat_code) | 
| 4761 | -                    $ret .= ' (' . $product->default_vat_code . ')';
 | |
| 4761 | +                    $ret .= ' ('.$product->default_vat_code.')';
 | |
| 4762 | 4762 | } | 
| 4763 | 4763 | $found = 1; | 
| 4764 | 4764 | } | 
| @@ -4772,8 +4772,8 @@ discard block | ||
| 4772 | 4772 |          if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) {
 | 
| 4773 | 4773 | // If vat of product for the country not found or not defined, we return the first higher vat of country. | 
| 4774 | 4774 | $sql = "SELECT t.taux as vat_rate, t.code as default_vat_code"; | 
| 4775 | - $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c"; | |
| 4776 | - $sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='" . $thirdparty_seller->country_code . "'"; | |
| 4775 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; | |
| 4776 | + $sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$thirdparty_seller->country_code."'"; | |
| 4777 | 4777 | $sql .= " ORDER BY t.taux DESC, t.code ASC, t.recuperableonly ASC"; | 
| 4778 | 4778 | $sql .= $db->plimit(1); | 
| 4779 | 4779 | |
| @@ -4783,16 +4783,16 @@ discard block | ||
| 4783 | 4783 |                  if ($obj) {
 | 
| 4784 | 4784 | $ret = $obj->vat_rate; | 
| 4785 | 4785 | if ($obj->default_vat_code) | 
| 4786 | -                        $ret .= ' (' . $obj->default_vat_code . ')';
 | |
| 4786 | +                        $ret .= ' ('.$obj->default_vat_code.')';
 | |
| 4787 | 4787 | } | 
| 4788 | 4788 | $db->free($sql); | 
| 4789 | 4789 | } else | 
| 4790 | 4790 | dol_print_error($db); | 
| 4791 | 4791 | } else | 
| 4792 | - $ret = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS; // Forced value if autodetect fails | |
| 4792 | + $ret = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS; // Forced value if autodetect fails | |
| 4793 | 4793 | } | 
| 4794 | 4794 | |
| 4795 | -    dol_syslog("get_product_vat_for_country: ret=" . $ret);
 | |
| 4795 | +    dol_syslog("get_product_vat_for_country: ret=".$ret);
 | |
| 4796 | 4796 | return $ret; | 
| 4797 | 4797 | } | 
| 4798 | 4798 | |
| @@ -4810,7 +4810,7 @@ discard block | ||
| 4810 | 4810 | global $db, $mysoc; | 
| 4811 | 4811 | |
| 4812 | 4812 |      if (!class_exists('Product')) {
 | 
| 4813 | - require_once DOL_BASE_PATH . 'product/class/product.class.php'; | |
| 4813 | + require_once DOL_BASE_PATH.'product/class/product.class.php'; | |
| 4814 | 4814 | } | 
| 4815 | 4815 | |
| 4816 | 4816 | $ret = 0; | 
| @@ -4835,8 +4835,8 @@ discard block | ||
| 4835 | 4835 |      if (!$found) {
 | 
| 4836 | 4836 | // If vat of product for the country not found or not defined, we return higher vat of country. | 
| 4837 | 4837 | $sql = "SELECT taux as vat_rate, localtax1, localtax2"; | 
| 4838 | - $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c"; | |
| 4839 | - $sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='" . $thirdparty_seller->country_code . "'"; | |
| 4838 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; | |
| 4839 | + $sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$thirdparty_seller->country_code."'"; | |
| 4840 | 4840 | $sql .= " ORDER BY t.taux DESC, t.recuperableonly ASC"; | 
| 4841 | 4841 | $sql .= $db->plimit(1); | 
| 4842 | 4842 | |
| @@ -4853,7 +4853,7 @@ discard block | ||
| 4853 | 4853 | dol_print_error($db); | 
| 4854 | 4854 | } | 
| 4855 | 4855 | |
| 4856 | -    dol_syslog("get_product_localtax_for_country: ret=" . $ret);
 | |
| 4856 | +    dol_syslog("get_product_localtax_for_country: ret=".$ret);
 | |
| 4857 | 4857 | return $ret; | 
| 4858 | 4858 | } | 
| 4859 | 4859 | |
| @@ -4877,7 +4877,7 @@ discard block | ||
| 4877 | 4877 |  {
 | 
| 4878 | 4878 | global $conf; | 
| 4879 | 4879 | |
| 4880 | - require_once DOL_BASE_PATH . '/core/lib/company.lib.php'; | |
| 4880 | + require_once DOL_BASE_PATH.'/core/lib/company.lib.php'; | |
| 4881 | 4881 | |
| 4882 | 4882 | // Note: possible values for tva_assuj are 0/1 or franchise/reel | 
| 4883 | 4883 | $seller_use_vat = ((is_numeric($thirdparty_seller->tva_assuj) && !$thirdparty_seller->tva_assuj) || (!is_numeric($thirdparty_seller->tva_assuj) && $thirdparty_seller->tva_assuj == 'franchise')) ? 0 : 1; | 
| @@ -4888,7 +4888,7 @@ discard block | ||
| 4888 | 4888 | $buyer_country_code = $thirdparty_buyer->country_code; | 
| 4889 | 4889 | $buyer_in_cee = isInEEC($thirdparty_buyer); | 
| 4890 | 4890 | |
| 4891 | -    dol_syslog("get_default_tva: seller use vat=" . $seller_use_vat . ", seller country=" . $seller_country_code . ", seller in cee=" . $seller_in_cee . ", buyer vat number=" . $thirdparty_buyer->tva_intra . " buyer country=" . $buyer_country_code . ", buyer in cee=" . $buyer_in_cee . ", idprod=" . $idprod . ", idprodfournprice=" . $idprodfournprice . ", SERVICE_ARE_ECOMMERCE_200238EC=" . (!empty($conf->global->SERVICES_ARE_ECOMMERCE_200238EC) ? $conf->global->SERVICES_ARE_ECOMMERCE_200238EC : ''));
 | |
| 4891 | +    dol_syslog("get_default_tva: seller use vat=".$seller_use_vat.", seller country=".$seller_country_code.", seller in cee=".$seller_in_cee.", buyer vat number=".$thirdparty_buyer->tva_intra." buyer country=".$buyer_country_code.", buyer in cee=".$buyer_in_cee.", idprod=".$idprod.", idprodfournprice=".$idprodfournprice.", SERVICE_ARE_ECOMMERCE_200238EC=".(!empty($conf->global->SERVICES_ARE_ECOMMERCE_200238EC) ? $conf->global->SERVICES_ARE_ECOMMERCE_200238EC : ''));
 | |
| 4892 | 4892 | |
| 4893 | 4893 | // If services are eServices according to EU Council Directive 2002/38/EC (http://ec.europa.eu/taxation_customs/taxation/vat/traders/e-commerce/article_1610_en.htm) | 
| 4894 | 4894 | // we use the buyer VAT. | 
| @@ -4954,14 +4954,14 @@ discard block | ||
| 4954 | 4954 | |
| 4955 | 4955 |      if ($idprodfournprice > 0) {
 | 
| 4956 | 4956 |          if (!class_exists('ProductFournisseur'))
 | 
| 4957 | - require_once DOL_BASE_PATH . '/fourn/class/fournisseur.product.class.php'; | |
| 4957 | + require_once DOL_BASE_PATH.'/fourn/class/fournisseur.product.class.php'; | |
| 4958 | 4958 | $prodprice = new ProductFournisseur($db); | 
| 4959 | 4959 | $prodprice->fetch_product_fournisseur_price($idprodfournprice); | 
| 4960 | 4960 | return $prodprice->fourn_tva_npr; | 
| 4961 | 4961 | } | 
| 4962 | 4962 |      elseif ($idprod > 0) {
 | 
| 4963 | 4963 |          if (!class_exists('Product'))
 | 
| 4964 | - require_once DOL_BASE_PATH . 'product/class/product.class.php'; | |
| 4964 | + require_once DOL_BASE_PATH.'product/class/product.class.php'; | |
| 4965 | 4965 | $prod = new Product($db); | 
| 4966 | 4966 | $prod->fetch($idprod); | 
| 4967 | 4967 | return $prod->tva_npr; | 
| @@ -5040,7 +5040,7 @@ discard block | ||
| 5040 | 5040 | if ($case == 2) | 
| 5041 | 5041 | $result = '<input type="checkbox" value="1" checked disabled>'; | 
| 5042 | 5042 | if ($case == 3) | 
| 5043 | - $result = '<input type="checkbox" value="1" checked disabled> ' . $result; | |
| 5043 | + $result = '<input type="checkbox" value="1" checked disabled> '.$result; | |
| 5044 | 5044 | |
| 5045 | 5045 | $classname = 'ok'; | 
| 5046 | 5046 | } | 
| @@ -5051,7 +5051,7 @@ discard block | ||
| 5051 | 5051 | if ($case == 2) | 
| 5052 | 5052 | $result = '<input type="checkbox" value="0" disabled>'; | 
| 5053 | 5053 | if ($case == 3) | 
| 5054 | - $result = '<input type="checkbox" value="0" disabled> ' . $result; | |
| 5054 | + $result = '<input type="checkbox" value="0" disabled> '.$result; | |
| 5055 | 5055 | |
| 5056 | 5056 | if ($color == 2) | 
| 5057 | 5057 | $classname = 'ok'; | 
| @@ -5059,7 +5059,7 @@ discard block | ||
| 5059 | 5059 | $classname = 'error'; | 
| 5060 | 5060 | } | 
| 5061 | 5061 | if ($color) | 
| 5062 | - return '<font class="' . $classname . '">' . $result . '</font>'; | |
| 5062 | + return '<font class="'.$classname.'">'.$result.'</font>'; | |
| 5063 | 5063 | return $result; | 
| 5064 | 5064 | } | 
| 5065 | 5065 | |
| @@ -5093,13 +5093,13 @@ discard block | ||
| 5093 | 5093 |              $num = preg_replace('/([^0-9])/i', '', $num);
 | 
| 5094 | 5094 | else | 
| 5095 | 5095 |              $num = preg_replace('/^.*\-/i', '', $num);
 | 
| 5096 | -        $num = substr("000" . $num, -$level);
 | |
| 5096 | +        $num = substr("000".$num, -$level);
 | |
| 5097 | 5097 | if ($level == 1) | 
| 5098 | 5098 | $path = substr($num, 0, 1); | 
| 5099 | 5099 | if ($level == 2) | 
| 5100 | - $path = substr($num, 1, 1) . '/' . substr($num, 0, 1); | |
| 5100 | + $path = substr($num, 1, 1).'/'.substr($num, 0, 1); | |
| 5101 | 5101 | if ($level == 3) | 
| 5102 | - $path = substr($num, 2, 1) . '/' . substr($num, 1, 1) . '/' . substr($num, 0, 1); | |
| 5102 | + $path = substr($num, 2, 1).'/'.substr($num, 1, 1).'/'.substr($num, 0, 1); | |
| 5103 | 5103 | } | 
| 5104 | 5104 |      else {
 | 
| 5105 | 5105 | // TODO | 
| @@ -5130,7 +5130,7 @@ discard block | ||
| 5130 | 5130 |  {
 | 
| 5131 | 5131 | global $conf; | 
| 5132 | 5132 | |
| 5133 | -    dol_syslog("functions.lib::dol_mkdir: dir=" . $dir, LOG_INFO);
 | |
| 5133 | +    dol_syslog("functions.lib::dol_mkdir: dir=".$dir, LOG_INFO);
 | |
| 5134 | 5134 | |
| 5135 | 5135 | $dir_osencoded = dol_osencode($dir); | 
| 5136 | 5136 | if (@is_dir($dir_osencoded)) | 
| @@ -5142,15 +5142,15 @@ discard block | ||
| 5142 | 5142 | $ccdir = ''; | 
| 5143 | 5143 |      if (!empty($dataroot)) {
 | 
| 5144 | 5144 | // Remove data root from loop | 
| 5145 | - $dir = str_replace($dataroot . '/', '', $dir); | |
| 5146 | - $ccdir = $dataroot . '/'; | |
| 5145 | + $dir = str_replace($dataroot.'/', '', $dir); | |
| 5146 | + $ccdir = $dataroot.'/'; | |
| 5147 | 5147 | } | 
| 5148 | 5148 | |
| 5149 | 5149 |      $cdir = explode("/", $dir);
 | 
| 5150 | 5150 | $num = count($cdir); | 
| 5151 | 5151 |      for ($i = 0; $i < $num; $i++) {
 | 
| 5152 | 5152 | if ($i > 0) | 
| 5153 | - $ccdir .= '/' . $cdir[$i]; | |
| 5153 | + $ccdir .= '/'.$cdir[$i]; | |
| 5154 | 5154 | else | 
| 5155 | 5155 | $ccdir .= $cdir[$i]; | 
| 5156 | 5156 |          if (preg_match("/^.:$/", $ccdir, $regs))
 | 
| @@ -5174,20 +5174,20 @@ discard block | ||
| 5174 | 5174 |          if ($ccdir) {
 | 
| 5175 | 5175 | $ccdir_osencoded = dol_osencode($ccdir); | 
| 5176 | 5176 |              if (!@is_dir($ccdir_osencoded)) {
 | 
| 5177 | -                dol_syslog("functions.lib::dol_mkdir: Directory '" . $ccdir . "' does not exists or is outside open_basedir PHP setting.", LOG_DEBUG);
 | |
| 5177 | +                dol_syslog("functions.lib::dol_mkdir: Directory '".$ccdir."' does not exists or is outside open_basedir PHP setting.", LOG_DEBUG);
 | |
| 5178 | 5178 | |
| 5179 | 5179 | umask(0); | 
| 5180 | 5180 | $dirmaskdec = octdec($newmask); | 
| 5181 | 5181 |                  if (empty($newmask)) {
 | 
| 5182 | 5182 |                      $dirmaskdec = empty($conf->global->MAIN_UMASK) ? octdec('0755') : octdec($conf->global->MAIN_UMASK);
 | 
| 5183 | 5183 | } | 
| 5184 | -                $dirmaskdec |= octdec('0111');  // Set x bit required for directories
 | |
| 5184 | +                $dirmaskdec |= octdec('0111'); // Set x bit required for directories
 | |
| 5185 | 5185 |                  if (!@mkdir($ccdir_osencoded, $dirmaskdec)) {
 | 
| 5186 | 5186 | // Si le is_dir a renvoye une fausse info, alors on passe ici. | 
| 5187 | -                    dol_syslog("functions.lib::dol_mkdir: Fails to create directory '" . $ccdir . "' or directory already exists.", LOG_WARNING);
 | |
| 5187 | +                    dol_syslog("functions.lib::dol_mkdir: Fails to create directory '".$ccdir."' or directory already exists.", LOG_WARNING);
 | |
| 5188 | 5188 | $nberr++; | 
| 5189 | 5189 |                  } else {
 | 
| 5190 | -                    dol_syslog("functions.lib::dol_mkdir: Directory '" . $ccdir . "' created", LOG_DEBUG);
 | |
| 5190 | +                    dol_syslog("functions.lib::dol_mkdir: Directory '".$ccdir."' created", LOG_DEBUG);
 | |
| 5191 | 5191 | $nberr = 0; // On remet a zero car si on arrive ici, cela veut dire que les echecs precedents peuvent etre ignore | 
| 5192 | 5192 | $nbcreated++; | 
| 5193 | 5193 | } | 
| @@ -5235,9 +5235,9 @@ discard block | ||
| 5235 | 5235 |      } else {
 | 
| 5236 | 5236 | $pattern = "/<[^<>]+>/"; | 
| 5237 | 5237 | // Exemple of $temp: <a href="/myurl" title="<u>A title</u>">0000-021</a> | 
| 5238 | - $temp = preg_replace($pattern, "", $temp); // pass 1 | |
| 5238 | + $temp = preg_replace($pattern, "", $temp); // pass 1 | |
| 5239 | 5239 | // $temp after pass 1: <a href="/myurl" title="A title">0000-021 | 
| 5240 | - $temp = preg_replace($pattern, "", $temp); // pass 2 | |
| 5240 | + $temp = preg_replace($pattern, "", $temp); // pass 2 | |
| 5241 | 5241 | // $temp after pass 2: 0000-021 | 
| 5242 | 5242 | } | 
| 5243 | 5243 | |
| @@ -5293,8 +5293,8 @@ discard block | ||
| 5293 | 5293 |  {
 | 
| 5294 | 5294 | $temp = $stringtoclean; | 
| 5295 | 5295 |      foreach ($disallowed_tags as $tagtoremove) {
 | 
| 5296 | -        $temp = preg_replace('/<\/?' . $tagtoremove . '>/', '', $temp);
 | |
| 5297 | -        $temp = preg_replace('/<\/?' . $tagtoremove . '\s+[^>]*>/', '', $temp);
 | |
| 5296 | +        $temp = preg_replace('/<\/?'.$tagtoremove.'>/', '', $temp);
 | |
| 5297 | +        $temp = preg_replace('/<\/?'.$tagtoremove.'\s+[^>]*>/', '', $temp);
 | |
| 5298 | 5298 | } | 
| 5299 | 5299 | return $temp; | 
| 5300 | 5300 | } | 
| @@ -5311,12 +5311,12 @@ discard block | ||
| 5311 | 5311 |  {
 | 
| 5312 | 5312 |      if ($nboflines == 1) {
 | 
| 5313 | 5313 |          if (dol_textishtml($text)) {
 | 
| 5314 | -            $firstline = preg_replace('/<br[^>]*>.*$/s', '', $text);  // The s pattern modifier means the . can match newline characters
 | |
| 5314 | +            $firstline = preg_replace('/<br[^>]*>.*$/s', '', $text); // The s pattern modifier means the . can match newline characters
 | |
| 5315 | 5315 |              $firstline = preg_replace('/<div[^>]*>.*$/s', '', $firstline); // The s pattern modifier means the . can match newline characters
 | 
| 5316 | 5316 |          } else {
 | 
| 5317 | 5317 |              $firstline = preg_replace('/[\n\r].*/', '', $text);
 | 
| 5318 | 5318 | } | 
| 5319 | - return $firstline . ((strlen($firstline) != strlen($text)) ? '...' : ''); | |
| 5319 | + return $firstline.((strlen($firstline) != strlen($text)) ? '...' : ''); | |
| 5320 | 5320 |      } else {
 | 
| 5321 | 5321 | $ishtml = 0; | 
| 5322 | 5322 |          if (dol_textishtml($text)) {
 | 
| @@ -5332,7 +5332,7 @@ discard block | ||
| 5332 | 5332 | $pattern = '/(<br[^>]*>)/Uu'; | 
| 5333 | 5333 | } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support | 
| 5334 | 5334 | else | 
| 5335 | - $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. | |
| 5335 | + $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. | |
| 5336 | 5336 | $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); | 
| 5337 | 5337 | |
| 5338 | 5338 | $firstline = ''; | 
| @@ -5346,7 +5346,7 @@ discard block | ||
| 5346 | 5346 | $i++; | 
| 5347 | 5347 | } | 
| 5348 | 5348 | unset($a); | 
| 5349 | - return $firstline . (($i < $nba) ? '...' : ''); | |
| 5349 | + return $firstline.(($i < $nba) ? '...' : ''); | |
| 5350 | 5350 | } | 
| 5351 | 5351 | } | 
| 5352 | 5352 | |
| @@ -5417,9 +5417,9 @@ discard block | ||
| 5417 | 5417 | function dol_htmlentitiesbr_decode($stringtodecode, $pagecodeto = 'UTF-8') | 
| 5418 | 5418 |  {
 | 
| 5419 | 5419 | $ret = dol_html_entity_decode($stringtodecode, ENT_COMPAT, $pagecodeto); | 
| 5420 | -    $ret = preg_replace('/' . "\r\n" . '<br(\s[\sa-zA-Z_="]*)?\/?>/i', "<br>", $ret);
 | |
| 5421 | -    $ret = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>' . "\r\n" . '/i', "\r\n", $ret);
 | |
| 5422 | -    $ret = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>' . "\n" . '/i', "\n", $ret);
 | |
| 5420 | +    $ret = preg_replace('/'."\r\n".'<br(\s[\sa-zA-Z_="]*)?\/?>/i', "<br>", $ret);
 | |
| 5421 | +    $ret = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>'."\r\n".'/i', "\r\n", $ret);
 | |
| 5422 | +    $ret = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>'."\n".'/i', "\n", $ret);
 | |
| 5423 | 5423 |      $ret = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', "\n", $ret);
 | 
| 5424 | 5424 | return $ret; | 
| 5425 | 5425 | } | 
| @@ -5432,7 +5432,7 @@ discard block | ||
| 5432 | 5432 | */ | 
| 5433 | 5433 | function dol_htmlcleanlastbr($stringtodecode) | 
| 5434 | 5434 |  {
 | 
| 5435 | -    $ret = preg_replace('/(<br>|<br(\s[\sa-zA-Z_="]*)?\/?>|' . "\n" . '|' . "\r" . ')+$/i', "", $stringtodecode);
 | |
| 5435 | +    $ret = preg_replace('/(<br>|<br(\s[\sa-zA-Z_="]*)?\/?>|'."\n".'|'."\r".')+$/i', "", $stringtodecode);
 | |
| 5436 | 5436 | return $ret; | 
| 5437 | 5437 | } | 
| 5438 | 5438 | |
| @@ -5529,7 +5529,7 @@ discard block | ||
| 5529 | 5529 | $pattern = '/(<br[^>]*>)/Uu'; | 
| 5530 | 5530 | } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support | 
| 5531 | 5531 | else | 
| 5532 | - $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. | |
| 5532 | + $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. | |
| 5533 | 5533 | $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); | 
| 5534 | 5534 | |
| 5535 | 5535 | $nblines = (int) floor((count($a) + 1) / 2); | 
| @@ -5560,7 +5560,7 @@ discard block | ||
| 5560 | 5560 | */ | 
| 5561 | 5561 | function dol_microtime_float() | 
| 5562 | 5562 |  {
 | 
| 5563 | - dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); | |
| 5563 | + dol_syslog(__FUNCTION__." is deprecated", LOG_WARNING); | |
| 5564 | 5564 | |
| 5565 | 5565 | return microtime(true); | 
| 5566 | 5566 | } | 
| @@ -5606,9 +5606,9 @@ discard block | ||
| 5606 | 5606 |          elseif (preg_match('/<h[0-9]>/i', $msg))
 | 
| 5607 | 5607 | return true; | 
| 5608 | 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) | |
| 5609 | + return true; // Html entities names (http://www.w3schools.com/tags/ref_entities.asp) | |
| 5610 | 5610 |          elseif (preg_match('/&#[0-9]{2,3};/i', $msg))
 | 
| 5611 | - return true; // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp) | |
| 5611 | + return true; // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp) | |
| 5612 | 5612 | |
| 5613 | 5613 | return false; | 
| 5614 | 5614 | } | 
| @@ -5833,7 +5833,7 @@ discard block | ||
| 5833 | 5833 |                  if ($object->fetch_optionals() > 0) {
 | 
| 5834 | 5834 |                      if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) {
 | 
| 5835 | 5835 |                          foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) {
 | 
| 5836 | - $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key]; | |
| 5836 | + $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = $object->array_options['options_'.$key]; | |
| 5837 | 5837 | } | 
| 5838 | 5838 | } | 
| 5839 | 5839 | } | 
| @@ -5845,7 +5845,7 @@ discard block | ||
| 5845 | 5845 | $paymenturl = ''; | 
| 5846 | 5846 |              } else {
 | 
| 5847 | 5847 | // Set the online payment url link into __ONLINE_PAYMENT_URL__ key | 
| 5848 | - require_once DOL_BASE_PATH . '/core/lib/payments.lib.php'; | |
| 5848 | + require_once DOL_BASE_PATH.'/core/lib/payments.lib.php'; | |
| 5849 | 5849 |                  $outputlangs->loadLangs(array('paypal', 'other'));
 | 
| 5850 | 5850 | $typeforonlinepayment = 'free'; | 
| 5851 | 5851 | if (is_object($object) && $object->element == 'commande') | 
| @@ -5906,7 +5906,7 @@ discard block | ||
| 5906 | 5906 | |
| 5907 | 5907 | //var_dump($substitutionarray['__AMOUNT_FORMATED__']); | 
| 5908 | 5908 |      if (empty($exclude) || !in_array('date', $exclude)) {
 | 
| 5909 | - include_once DOL_BASE_PATH . '/core/lib/date.lib.php'; | |
| 5909 | + include_once DOL_BASE_PATH.'/core/lib/date.lib.php'; | |
| 5910 | 5910 | |
| 5911 | 5911 | $tmp = dol_getdate(dol_now(), true); | 
| 5912 | 5912 | $tmp2 = dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']); | 
| @@ -5916,13 +5916,13 @@ discard block | ||
| 5916 | 5916 | |
| 5917 | 5917 | $substitutionarray = array_merge($substitutionarray, array( | 
| 5918 | 5918 | '__DAY__' => (string) $tmp['mday'], | 
| 5919 | -            '__DAY_TEXT__' => $outputlangs->trans('Day' . $tmp['wday']), // Monday
 | |
| 5920 | - '__DAY_TEXT_SHORT__' => $outputlangs->trans($tmp['weekday'] . 'Min'), // Mon | |
| 5921 | -            '__DAY_TEXT_MIN__' => $outputlangs->trans('Short' . $tmp['weekday']), // M
 | |
| 5919 | +            '__DAY_TEXT__' => $outputlangs->trans('Day'.$tmp['wday']), // Monday
 | |
| 5920 | + '__DAY_TEXT_SHORT__' => $outputlangs->trans($tmp['weekday'].'Min'), // Mon | |
| 5921 | +            '__DAY_TEXT_MIN__' => $outputlangs->trans('Short'.$tmp['weekday']), // M
 | |
| 5922 | 5922 | '__MONTH__' => (string) $tmp['mon'], | 
| 5923 | -            '__MONTH_TEXT__' => $outputlangs->trans('Month' . sprintf("%02d", $tmp['mon'])),
 | |
| 5924 | -            '__MONTH_TEXT_SHORT__' => $outputlangs->trans('MonthShort' . sprintf("%02d", $tmp['mon'])),
 | |
| 5925 | -            '__MONTH_TEXT_MIN__' => $outputlangs->trans('MonthVeryShort' . sprintf("%02d", $tmp['mon'])),
 | |
| 5923 | +            '__MONTH_TEXT__' => $outputlangs->trans('Month'.sprintf("%02d", $tmp['mon'])),
 | |
| 5924 | +            '__MONTH_TEXT_SHORT__' => $outputlangs->trans('MonthShort'.sprintf("%02d", $tmp['mon'])),
 | |
| 5925 | +            '__MONTH_TEXT_MIN__' => $outputlangs->trans('MonthVeryShort'.sprintf("%02d", $tmp['mon'])),
 | |
| 5926 | 5926 | '__YEAR__' => (string) $tmp['year'], | 
| 5927 | 5927 | '__PREVIOUS_DAY__' => (string) $tmp2['day'], | 
| 5928 | 5928 | '__PREVIOUS_MONTH__' => (string) $tmp3['month'], | 
| @@ -5981,7 +5981,7 @@ discard block | ||
| 5981 | 5981 | if (!empty($tmp[1])) | 
| 5982 | 5982 | $outputlangs->load($tmp[1]); | 
| 5983 | 5983 | |
| 5984 | -            $text = preg_replace('/__\(' . preg_quote($reg[1], '/') . '\)__/', $msgishtml ? dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])) : $outputlangs->transnoentitiesnoconv($reg[1]), $text);
 | |
| 5984 | +            $text = preg_replace('/__\('.preg_quote($reg[1], '/').'\)__/', $msgishtml ? dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])) : $outputlangs->transnoentitiesnoconv($reg[1]), $text);
 | |
| 5985 | 5985 | } | 
| 5986 | 5986 | } | 
| 5987 | 5987 | |
| @@ -5997,13 +5997,13 @@ discard block | ||
| 5997 | 5997 | $newval = '*****forbidden*****'; | 
| 5998 | 5998 | else | 
| 5999 | 5999 | $newval = empty($conf->global->$keyfound) ? '' : $conf->global->$keyfound; | 
| 6000 | -        $text = preg_replace('/__\[' . preg_quote($keyfound, '/') . '\]__/', $msgishtml ? dol_htmlentitiesbr($newval) : $newval, $text);
 | |
| 6000 | +        $text = preg_replace('/__\['.preg_quote($keyfound, '/').'\]__/', $msgishtml ? dol_htmlentitiesbr($newval) : $newval, $text);
 | |
| 6001 | 6001 | } | 
| 6002 | 6002 | |
| 6003 | 6003 | // Make substitition for array $substitutionarray | 
| 6004 | 6004 |      foreach ($substitutionarray as $key => $value) {
 | 
| 6005 | 6005 | if ($key == '__SIGNATURE__' && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) | 
| 6006 | - $value = ''; // Protection | |
| 6006 | + $value = ''; // Protection | |
| 6007 | 6007 | if ($key == '__USER_SIGNATURE__' && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) | 
| 6008 | 6008 | $value = ''; // Protection | 
| 6009 | 6009 | |
| @@ -6029,7 +6029,7 @@ discard block | ||
| 6029 | 6029 |  {
 | 
| 6030 | 6030 | global $conf, $user; | 
| 6031 | 6031 | |
| 6032 | - require_once DOL_BASE_PATH . '/core/lib/files.lib.php'; | |
| 6032 | + require_once DOL_BASE_PATH.'/core/lib/files.lib.php'; | |
| 6033 | 6033 | |
| 6034 | 6034 | // Add a substitution key for each extrafields, using key __EXTRA_XXX__ | 
| 6035 | 6035 | // TODO Remove this. Already available into the getCommonSubstitutionArray used to build the substitution array. | 
| @@ -6059,11 +6059,11 @@ discard block | ||
| 6059 | 6059 |              if (preg_match('/functions_(.*)\.lib\.php/i', $substitfile['name'], $reg)) {
 | 
| 6060 | 6060 | $module = $reg[1]; | 
| 6061 | 6061 | |
| 6062 | -                dol_syslog("Library " . $substitfile['name'] . " found into " . $dir);
 | |
| 6062 | +                dol_syslog("Library ".$substitfile['name']." found into ".$dir);
 | |
| 6063 | 6063 | // Include the user's functions file | 
| 6064 | - require_once $dir . $substitfile['name']; | |
| 6064 | + require_once $dir.$substitfile['name']; | |
| 6065 | 6065 | // Call the user's function, and only if it is defined | 
| 6066 | - $function_name = $module . "_" . $callfunc; | |
| 6066 | + $function_name = $module."_".$callfunc; | |
| 6067 | 6067 | if (function_exists($function_name)) | 
| 6068 | 6068 | $function_name($substitutionarray, $outputlangs, $object, $parameters); | 
| 6069 | 6069 | } | 
| @@ -6105,13 +6105,13 @@ discard block | ||
| 6105 | 6105 | $outputlangs = $langs; | 
| 6106 | 6106 | |
| 6107 | 6107 |      if ($date_start && $date_end) {
 | 
| 6108 | -        $out .= ($withparenthesis ? ' (' : '') . $outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($date_start, $format, false, $outputlangs), dol_print_date($date_end, $format, false, $outputlangs)) . ($withparenthesis ? ')' : '');
 | |
| 6108 | +        $out .= ($withparenthesis ? ' (' : '').$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($date_start, $format, false, $outputlangs), dol_print_date($date_end, $format, false, $outputlangs)).($withparenthesis ? ')' : '');
 | |
| 6109 | 6109 | } | 
| 6110 | 6110 |      if ($date_start && !$date_end) {
 | 
| 6111 | -        $out .= ($withparenthesis ? ' (' : '') . $outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($date_start, $format, false, $outputlangs)) . ($withparenthesis ? ')' : '');
 | |
| 6111 | +        $out .= ($withparenthesis ? ' (' : '').$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($date_start, $format, false, $outputlangs)).($withparenthesis ? ')' : '');
 | |
| 6112 | 6112 | } | 
| 6113 | 6113 |      if (!$date_start && $date_end) {
 | 
| 6114 | -        $out .= ($withparenthesis ? ' (' : '') . $outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($date_end, $format, false, $outputlangs)) . ($withparenthesis ? ')' : '');
 | |
| 6114 | +        $out .= ($withparenthesis ? ' (' : '').$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($date_end, $format, false, $outputlangs)).($withparenthesis ? ')' : '');
 | |
| 6115 | 6115 | } | 
| 6116 | 6116 | |
| 6117 | 6117 | return $out; | 
| @@ -6191,7 +6191,7 @@ discard block | ||
| 6191 | 6191 |          dol_syslog("Try to add a message in stack with empty message", LOG_WARNING);
 | 
| 6192 | 6192 |      } else {
 | 
| 6193 | 6193 |          if (!in_array((string) $style, array('mesgs', 'warnings', 'errors')))
 | 
| 6194 | -            dol_print_error('', 'Bad parameter style=' . $style . ' for setEventMessages');
 | |
| 6194 | +            dol_print_error('', 'Bad parameter style='.$style.' for setEventMessages');
 | |
| 6195 | 6195 | if (empty($mesgs)) | 
| 6196 | 6196 | setEventMessage($mesg, $style); | 
| 6197 | 6197 |          else {
 | 
| @@ -6260,7 +6260,7 @@ discard block | ||
| 6260 | 6260 | |
| 6261 | 6261 | // If inline message with no format, we add it. | 
| 6262 | 6262 |      if ((empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) || $keepembedded) && !preg_match('/<div class=".*">/i', $out)) {
 | 
| 6263 | - $divstart = '<div class="' . $style . ' clearboth">'; | |
| 6263 | + $divstart = '<div class="'.$style.' clearboth">'; | |
| 6264 | 6264 | $divend = '</div>'; | 
| 6265 | 6265 | } | 
| 6266 | 6266 | |
| @@ -6287,14 +6287,14 @@ discard block | ||
| 6287 | 6287 |          if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && empty($keepembedded)) {
 | 
| 6288 | 6288 | $return = '<script type="text/javascript"> | 
| 6289 | 6289 |  					$(document).ready(function() {
 | 
| 6290 | - var block = ' . (!empty($conf->global->MAIN_USE_JQUERY_BLOCKUI) ? "true" : "false") . ' | |
| 6290 | + var block = ' . (!empty($conf->global->MAIN_USE_JQUERY_BLOCKUI) ? "true" : "false").' | |
| 6291 | 6291 |  						if (block) {
 | 
| 6292 | -							$.dolEventValid("","' . dol_escape_js($out) . '");
 | |
| 6292 | +							$.dolEventValid("","' . dol_escape_js($out).'");
 | |
| 6293 | 6293 |  						} else {
 | 
| 6294 | 6294 | /* jnotify(message, preset of message type, keepmessage) */ | 
| 6295 | -							$.jnotify("' . dol_escape_js($out) . '",
 | |
| 6296 | - "' . ($style == "ok" ? 3000 : $style) . '", | |
| 6297 | - ' . ($style == "ok" ? "false" : "true") . ', | |
| 6295 | +							$.jnotify("' . dol_escape_js($out).'",
 | |
| 6296 | + "' . ($style == "ok" ? 3000 : $style).'", | |
| 6297 | + ' . ($style == "ok" ? "false" : "true").', | |
| 6298 | 6298 |  							{ remove: function (){} } );
 | 
| 6299 | 6299 | } | 
| 6300 | 6300 | }); | 
| @@ -6489,11 +6489,11 @@ discard block | ||
| 6489 | 6489 |  {
 | 
| 6490 | 6490 | global $conf; | 
| 6491 | 6491 | |
| 6492 | -    $tmp = ini_get("unicode.filesystem_encoding");      // Disponible avec PHP 6.0
 | |
| 6492 | +    $tmp = ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0
 | |
| 6493 | 6493 | if (empty($tmp) && !empty($_SERVER["WINDIR"])) | 
| 6494 | 6494 | $tmp = 'iso-8859-1'; // By default for windows | 
| 6495 | 6495 | if (empty($tmp)) | 
| 6496 | - $tmp = 'utf-8'; // By default for other | |
| 6496 | + $tmp = 'utf-8'; // By default for other | |
| 6497 | 6497 | if (!empty($conf->global->MAIN_FILESYSTEM_ENCODING)) | 
| 6498 | 6498 | $tmp = $conf->global->MAIN_FILESYSTEM_ENCODING; | 
| 6499 | 6499 | |
| @@ -6525,16 +6525,16 @@ discard block | ||
| 6525 | 6525 | |
| 6526 | 6526 | // Check in cache | 
| 6527 | 6527 |      if (isset($cache_codes[$tablename][$key][$fieldid])) { // Can be defined to 0 or ''
 | 
| 6528 | - return $cache_codes[$tablename][$key][$fieldid]; // Found in cache | |
| 6528 | + return $cache_codes[$tablename][$key][$fieldid]; // Found in cache | |
| 6529 | 6529 | } | 
| 6530 | 6530 | |
| 6531 | 6531 |      dol_syslog('dol_getIdFromCode (value not found into cache)', LOG_DEBUG);
 | 
| 6532 | 6532 | |
| 6533 | - $sql = "SELECT " . $fieldid . " as valuetoget"; | |
| 6534 | - $sql .= " FROM " . MAIN_DB_PREFIX . $tablename; | |
| 6535 | - $sql .= " WHERE " . $fieldkey . " = '" . $db->escape($key) . "'"; | |
| 6533 | + $sql = "SELECT ".$fieldid." as valuetoget"; | |
| 6534 | + $sql .= " FROM ".MAIN_DB_PREFIX.$tablename; | |
| 6535 | + $sql .= " WHERE ".$fieldkey." = '".$db->escape($key)."'"; | |
| 6536 | 6536 | if (!empty($entityfilter)) | 
| 6537 | -        $sql .= " AND entity IN (" . getEntity($tablename) . ")";
 | |
| 6537 | +        $sql .= " AND entity IN (".getEntity($tablename).")";
 | |
| 6538 | 6538 | |
| 6539 | 6539 | $resql = $db->query($sql); | 
| 6540 | 6540 |      if ($resql) {
 | 
| @@ -6561,12 +6561,12 @@ discard block | ||
| 6561 | 6561 |  {
 | 
| 6562 | 6562 | global $user, $conf, $langs; | 
| 6563 | 6563 | global $leftmenu; | 
| 6564 | - global $rights; // To export to dol_eval function | |
| 6564 | + global $rights; // To export to dol_eval function | |
| 6565 | 6565 | //print $strRights."<br>\n"; | 
| 6566 | 6566 | $rights = true; | 
| 6567 | 6567 |      if ($strRights != '') {
 | 
| 6568 | -        $str = 'if(!(' . $strRights . ')) { $rights = false; }';
 | |
| 6569 | - dol_eval($str); // The dol_eval must contains all the global $xxx used into a condition | |
| 6568 | +        $str = 'if(!('.$strRights.')) { $rights = false; }';
 | |
| 6569 | + dol_eval($str); // The dol_eval must contains all the global $xxx used into a condition | |
| 6570 | 6570 | } | 
| 6571 | 6571 | return $rights; | 
| 6572 | 6572 | } | 
| @@ -6589,14 +6589,14 @@ discard block | ||
| 6589 | 6589 | global $object; | 
| 6590 | 6590 | global $mysoc; | 
| 6591 | 6591 | |
| 6592 | - global $obj; // To get $obj used into list when dol_eval is used for computed fields and $obj is not yet $object | |
| 6593 | - global $soc; // For backward compatibility | |
| 6592 | + global $obj; // To get $obj used into list when dol_eval is used for computed fields and $obj is not yet $object | |
| 6593 | + global $soc; // For backward compatibility | |
| 6594 | 6594 | //print $s."<br>\n"; | 
| 6595 | 6595 |      if ($returnvalue) {
 | 
| 6596 | 6596 | if ($hideerrors) | 
| 6597 | -            return @eval('return ' . $s . ';');
 | |
| 6597 | +            return @eval('return '.$s.';');
 | |
| 6598 | 6598 | else | 
| 6599 | -            return eval('return ' . $s . ';');
 | |
| 6599 | +            return eval('return '.$s.';');
 | |
| 6600 | 6600 | } | 
| 6601 | 6601 |      else {
 | 
| 6602 | 6602 | if ($hideerrors) | 
| @@ -6650,7 +6650,7 @@ discard block | ||
| 6650 | 6650 | $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1]; | 
| 6651 | 6651 | } | 
| 6652 | 6652 | |
| 6653 | - return img_picto_common($codelang, 'flags/' . strtolower($flagImage) . '.png', $moreatt); | |
| 6653 | + return img_picto_common($codelang, 'flags/'.strtolower($flagImage).'.png', $moreatt); | |
| 6654 | 6654 | } | 
| 6655 | 6655 | |
| 6656 | 6656 | /** | 
| @@ -6848,16 +6848,16 @@ discard block | ||
| 6848 | 6848 | 'zu-ZA', | 
| 6849 | 6849 | ); | 
| 6850 | 6850 | |
| 6851 | - $buildprimarykeytotest = strtolower($countrycode) . '-' . strtoupper($countrycode); | |
| 6851 | + $buildprimarykeytotest = strtolower($countrycode).'-'.strtoupper($countrycode); | |
| 6852 | 6852 | if (in_array($buildprimarykeytotest, $locales)) | 
| 6853 | - return strtolower($countrycode) . '_' . strtoupper($countrycode); | |
| 6853 | + return strtolower($countrycode).'_'.strtoupper($countrycode); | |
| 6854 | 6854 | |
| 6855 | 6855 |      foreach ($locales as $locale) {
 | 
| 6856 | 6856 | $locale_language = locale_get_primary_language($locale); | 
| 6857 | 6857 | $locale_region = locale_get_region($locale); | 
| 6858 | 6858 |          if (strtoupper($countrycode) == $locale_region) {
 | 
| 6859 | 6859 | //var_dump($locale.'-'.$locale_language.'-'.$locale_region); | 
| 6860 | - return strtolower($locale_language) . '_' . strtoupper($locale_region); | |
| 6860 | + return strtolower($locale_language).'_'.strtoupper($locale_region); | |
| 6861 | 6861 | } | 
| 6862 | 6862 | } | 
| 6863 | 6863 | |
| @@ -6918,7 +6918,7 @@ discard block | ||
| 6918 | 6918 | $label = $langs->trans($values[2]); | 
| 6919 | 6919 | |
| 6920 | 6920 |                          //$head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]), 1);
 | 
| 6921 | -                        $head[$h][0] = BASE_URI . preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]);
 | |
| 6921 | +                        $head[$h][0] = BASE_URI.preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]);
 | |
| 6922 | 6922 | $head[$h][1] = $label; | 
| 6923 | 6923 |                          $head[$h][2] = str_replace('+', '', $values[1]);
 | 
| 6924 | 6924 | $h++; | 
| @@ -6989,43 +6989,43 @@ discard block | ||
| 6989 | 6989 | global $micro_start_time; | 
| 6990 | 6990 | |
| 6991 | 6991 | if ($zone == 'private') | 
| 6992 | - print "\n" . '<!-- Common footer for private page -->' . "\n"; | |
| 6992 | + print "\n".'<!-- Common footer for private page -->'."\n"; | |
| 6993 | 6993 | else | 
| 6994 | - print "\n" . '<!-- Common footer for public page -->' . "\n"; | |
| 6994 | + print "\n".'<!-- Common footer for public page -->'."\n"; | |
| 6995 | 6995 | |
| 6996 | 6996 | // A div to store page_y POST parameter so we can read it using javascript | 
| 6997 | 6997 | print "\n<!-- A div to store page_y POST paramater -->\n"; | 
| 6998 | - print '<div id="page_y" style="display: none;">' . $_POST['page_y'] . '</div>' . "\n"; | |
| 6998 | + print '<div id="page_y" style="display: none;">'.$_POST['page_y'].'</div>'."\n"; | |
| 6999 | 6999 | |
| 7000 | 7000 | $parameters = array(); | 
| 7001 | -    $reshook = $hookmanager->executeHooks('printCommonFooter', $parameters);    // Note that $action and $object may have been modified by some hooks
 | |
| 7001 | +    $reshook = $hookmanager->executeHooks('printCommonFooter', $parameters); // Note that $action and $object may have been modified by some hooks
 | |
| 7002 | 7002 |      if (empty($reshook)) {
 | 
| 7003 | 7003 | if (!empty($conf->global->MAIN_HTML_FOOTER)) | 
| 7004 | - print $conf->global->MAIN_HTML_FOOTER . "\n"; | |
| 7004 | + print $conf->global->MAIN_HTML_FOOTER."\n"; | |
| 7005 | 7005 | |
| 7006 | 7006 | print "\n"; | 
| 7007 | 7007 |          if (!empty($conf->use_javascript_ajax)) {
 | 
| 7008 | - print '<script type="text/javascript" language="javascript">' . "\n"; | |
| 7009 | -            print 'jQuery(document).ready(function() {' . "\n";
 | |
| 7008 | + print '<script type="text/javascript" language="javascript">'."\n"; | |
| 7009 | +            print 'jQuery(document).ready(function() {'."\n";
 | |
| 7010 | 7010 | |
| 7011 | 7011 |              if ($zone == 'private' && empty($conf->dol_use_jmobile)) {
 | 
| 7012 | 7012 | print "\n"; | 
| 7013 | - print '/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */' . "\n"; | |
| 7013 | + print '/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'."\n"; | |
| 7014 | 7014 |                  print 'jQuery(".menuhider").click(function() {';
 | 
| 7015 | -                print '  console.log("We click on .menuhider");' . "\n";
 | |
| 7015 | +                print '  console.log("We click on .menuhider");'."\n";
 | |
| 7016 | 7016 |                  //print "  $('.side-nav').animate({width:'toggle'},200);\n";     // OK with eldy theme but not with md
 | 
| 7017 | 7017 |                  print "  $('.side-nav').toggle()\n";
 | 
| 7018 | 7018 |                  print "  $('.login_block').toggle()\n";
 | 
| 7019 | - print '});' . "\n"; | |
| 7019 | + print '});'."\n"; | |
| 7020 | 7020 | } | 
| 7021 | 7021 | |
| 7022 | 7022 | // Management of focus and mandatory for fields | 
| 7023 | 7023 |              if ($action == 'create' || $action == 'edit' || (empty($action) && (preg_match('/new\.php/', $_SERVER["PHP_SELF"])))) {
 | 
| 7024 | - print '/* JS CODE TO ENABLE to manage focus and mandatory form fields */' . "\n"; | |
| 7024 | + print '/* JS CODE TO ENABLE to manage focus and mandatory form fields */'."\n"; | |
| 7025 | 7025 | $relativepathstring = $_SERVER["PHP_SELF"]; | 
| 7026 | 7026 | // Clean $relativepathstring | 
| 7027 | 7027 |                  if (constant('DOL_URL_ROOT'))
 | 
| 7028 | -                    $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_URL_ROOT'), '/') . '/', '', $relativepathstring);
 | |
| 7028 | +                    $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'), '/').'/', '', $relativepathstring);
 | |
| 7029 | 7029 |                  $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
 | 
| 7030 | 7030 |                  $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
 | 
| 7031 | 7031 |                  $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
 | 
| @@ -7048,9 +7048,9 @@ discard block | ||
| 7048 | 7048 |                          if ($qualified) {
 | 
| 7049 | 7049 |                              foreach ($defval as $paramkey => $paramval) {
 | 
| 7050 | 7050 | // Set focus on field | 
| 7051 | -                                print 'jQuery("input[name=\'' . $paramkey . '\']").focus();' . "\n";
 | |
| 7052 | -                                print 'jQuery("textarea[name=\'' . $paramkey . '\']").focus();' . "\n";
 | |
| 7053 | -                                print 'jQuery("select[name=\'' . $paramkey . '\']").focus();' . "\n";  // Not really usefull, but we keep it in case of.
 | |
| 7051 | +                                print 'jQuery("input[name=\''.$paramkey.'\']").focus();'."\n";
 | |
| 7052 | +                                print 'jQuery("textarea[name=\''.$paramkey.'\']").focus();'."\n";
 | |
| 7053 | +                                print 'jQuery("select[name=\''.$paramkey.'\']").focus();'."\n"; // Not really usefull, but we keep it in case of.
 | |
| 7054 | 7054 | } | 
| 7055 | 7055 | } | 
| 7056 | 7056 | } | 
| @@ -7074,16 +7074,16 @@ discard block | ||
| 7074 | 7074 |                          if ($qualified) {
 | 
| 7075 | 7075 |                              foreach ($defval as $paramkey => $paramval) {
 | 
| 7076 | 7076 | // Add property 'required' on input | 
| 7077 | -                                print 'jQuery("input[name=\'' . $paramkey . '\']").prop(\'required\',true);' . "\n";
 | |
| 7078 | -                                print 'jQuery("textarea[name=\'' . $paramkey . '\']").prop(\'required\',true);' . "\n";
 | |
| 7079 | -                                print 'jQuery("select[name=\'' . $paramkey . '\']").prop(\'required\',true);' . "\n";  // required on a select works only if key is "", this does not happen in Dolibarr
 | |
| 7077 | +                                print 'jQuery("input[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n";
 | |
| 7078 | +                                print 'jQuery("textarea[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n";
 | |
| 7079 | +                                print 'jQuery("select[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n"; // required on a select works only if key is "", this does not happen in Dolibarr
 | |
| 7080 | 7080 | } | 
| 7081 | 7081 | } | 
| 7082 | 7082 | } | 
| 7083 | 7083 | } | 
| 7084 | 7084 | } | 
| 7085 | 7085 | |
| 7086 | - print '});' . "\n"; | |
| 7086 | + print '});'."\n"; | |
| 7087 | 7087 | |
| 7088 | 7088 | // Google Analytics | 
| 7089 | 7089 | // TODO Add a hook here | 
| @@ -7091,15 +7091,15 @@ discard block | ||
| 7091 | 7091 |                  if (($conf->dol_use_jmobile != 4)) {
 | 
| 7092 | 7092 | print "\n"; | 
| 7093 | 7093 | print "/* JS CODE TO ENABLE for google analtics tag */\n"; | 
| 7094 | - print ' var _gaq = _gaq || [];' . "\n"; | |
| 7095 | - print ' _gaq.push([\'_setAccount\', \'' . $conf->global->MAIN_GOOGLE_AN_ID . '\']);' . "\n"; | |
| 7096 | - print ' _gaq.push([\'_trackPageview\']);' . "\n"; | |
| 7097 | - print '' . "\n"; | |
| 7098 | -                    print '  (function() {' . "\n";
 | |
| 7099 | - print ' var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;' . "\n"; | |
| 7100 | - print ' ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';' . "\n"; | |
| 7101 | - print ' var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);' . "\n"; | |
| 7102 | - print ' })();' . "\n"; | |
| 7094 | + print ' var _gaq = _gaq || [];'."\n"; | |
| 7095 | + print ' _gaq.push([\'_setAccount\', \''.$conf->global->MAIN_GOOGLE_AN_ID.'\']);'."\n"; | |
| 7096 | + print ' _gaq.push([\'_trackPageview\']);'."\n"; | |
| 7097 | + print ''."\n"; | |
| 7098 | +                    print '  (function() {'."\n";
 | |
| 7099 | + print ' var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;'."\n"; | |
| 7100 | + print ' ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';'."\n"; | |
| 7101 | + print ' var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);'."\n"; | |
| 7102 | + print ' })();'."\n"; | |
| 7103 | 7103 | } | 
| 7104 | 7104 | } | 
| 7105 | 7105 | |
| @@ -7109,27 +7109,27 @@ discard block | ||
| 7109 | 7109 | print "/* JS CODE TO ENABLE to add memory info */\n"; | 
| 7110 | 7110 |                  print 'window.console && console.log("';
 | 
| 7111 | 7111 | if (!empty($conf->global->MEMCACHED_SERVER)) | 
| 7112 | - print 'MEMCACHED_SERVER=' . $conf->global->MEMCACHED_SERVER . ' - '; | |
| 7113 | - print 'MAIN_OPTIMIZE_SPEED=' . (isset($conf->global->MAIN_OPTIMIZE_SPEED) ? $conf->global->MAIN_OPTIMIZE_SPEED : 'off'); | |
| 7112 | + print 'MEMCACHED_SERVER='.$conf->global->MEMCACHED_SERVER.' - '; | |
| 7113 | + print 'MAIN_OPTIMIZE_SPEED='.(isset($conf->global->MAIN_OPTIMIZE_SPEED) ? $conf->global->MAIN_OPTIMIZE_SPEED : 'off'); | |
| 7114 | 7114 |                  if (!empty($micro_start_time)) {   // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in global variable.
 | 
| 7115 | 7115 | $micro_end_time = microtime(true); | 
| 7116 | - print ' - Build time: ' . ceil(1000 * ($micro_end_time - $micro_start_time)) . ' ms'; | |
| 7116 | + print ' - Build time: '.ceil(1000 * ($micro_end_time - $micro_start_time)).' ms'; | |
| 7117 | 7117 | } | 
| 7118 | 7118 |                  if (function_exists("memory_get_usage")) {
 | 
| 7119 | - print ' - Mem: ' . memory_get_usage(); | |
| 7119 | + print ' - Mem: '.memory_get_usage(); | |
| 7120 | 7120 | } | 
| 7121 | 7121 |                  if (function_exists("xdebug_memory_usage")) {
 | 
| 7122 | - print ' - XDebug time: ' . ceil(1000 * xdebug_time_index()) . ' ms'; | |
| 7123 | - print ' - XDebug mem: ' . xdebug_memory_usage(); | |
| 7124 | - print ' - XDebug mem peak: ' . xdebug_peak_memory_usage(); | |
| 7122 | + print ' - XDebug time: '.ceil(1000 * xdebug_time_index()).' ms'; | |
| 7123 | + print ' - XDebug mem: '.xdebug_memory_usage(); | |
| 7124 | + print ' - XDebug mem peak: '.xdebug_peak_memory_usage(); | |
| 7125 | 7125 | } | 
| 7126 | 7126 |                  if (function_exists("zend_loader_file_encoded")) {
 | 
| 7127 | - print ' - Zend encoded file: ' . (zend_loader_file_encoded() ? 'yes' : 'no'); | |
| 7127 | + print ' - Zend encoded file: '.(zend_loader_file_encoded() ? 'yes' : 'no'); | |
| 7128 | 7128 | } | 
| 7129 | - print '");' . "\n"; | |
| 7129 | + print '");'."\n"; | |
| 7130 | 7130 | } | 
| 7131 | 7131 | |
| 7132 | - print "\n" . '</script>' . "\n"; | |
| 7132 | + print "\n".'</script>'."\n"; | |
| 7133 | 7133 | } | 
| 7134 | 7134 | |
| 7135 | 7135 | // Add Xdebug coverage of code | 
| @@ -7143,7 +7143,7 @@ discard block | ||
| 7143 | 7143 | print "<!-- Start of log output\n"; | 
| 7144 | 7144 | //print '<div class="hidden">'."\n"; | 
| 7145 | 7145 |              foreach ($conf->logbuffer as $logline) {
 | 
| 7146 | - print $logline . "<br>\n"; | |
| 7146 | + print $logline."<br>\n"; | |
| 7147 | 7147 | } | 
| 7148 | 7148 | //print '</div>'."\n"; | 
| 7149 | 7149 | print "End of log output -->\n"; | 
| @@ -7186,8 +7186,8 @@ discard block | ||
| 7186 | 7186 | */ | 
| 7187 | 7187 | function dol_set_focus($selector) | 
| 7188 | 7188 |  {
 | 
| 7189 | - print "\n" . '<!-- Set focus onto a specific field -->' . "\n"; | |
| 7190 | -    print '<script type="text/javascript" language="javascript">jQuery(document).ready(function() { jQuery("' . dol_escape_js($selector) . '").focus(); });</script>' . "\n";
 | |
| 7189 | + print "\n".'<!-- Set focus onto a specific field -->'."\n"; | |
| 7190 | +    print '<script type="text/javascript" language="javascript">jQuery(document).ready(function() { jQuery("'.dol_escape_js($selector).'").focus(); });</script>'."\n";
 | |
| 7191 | 7191 | } | 
| 7192 | 7192 | |
| 7193 | 7193 | /** | 
| @@ -7232,7 +7232,7 @@ discard block | ||
| 7232 | 7232 |          $value = preg_replace('/\*/', '%', $value); // Replace * with %
 | 
| 7233 | 7233 | } | 
| 7234 | 7234 |      if ($mode == 1) {
 | 
| 7235 | -        $value = preg_replace('/([<>=]+)\s+([0-9' . preg_quote($langs->trans("DecimalSeparator"), '/') . '\-])/', '\1\2', $value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do
 | |
| 7235 | +        $value = preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"), '/').'\-])/', '\1\2', $value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do
 | |
| 7236 | 7236 | } | 
| 7237 | 7237 | |
| 7238 | 7238 |      $value = preg_replace('/\s*\|\s*/', '|', $value);
 | 
| @@ -7261,14 +7261,14 @@ discard block | ||
| 7261 | 7261 |                  if ($newcrit != '') {
 | 
| 7262 | 7262 | $numnewcrit = price2num($newcrit); | 
| 7263 | 7263 |                      if (is_numeric($numnewcrit)) {
 | 
| 7264 | - $newres .= ($i2 > 0 ? ' OR ' : '') . $field . ' ' . $operator . ' ' . $numnewcrit; | |
| 7264 | + $newres .= ($i2 > 0 ? ' OR ' : '').$field.' '.$operator.' '.$numnewcrit; | |
| 7265 | 7265 |                      } else {
 | 
| 7266 | - $newres .= ($i2 > 0 ? ' OR ' : '') . '1 = 2'; // force false | |
| 7266 | + $newres .= ($i2 > 0 ? ' OR ' : '').'1 = 2'; // force false | |
| 7267 | 7267 | } | 
| 7268 | 7268 | $i2++; // a criteria was added to string | 
| 7269 | 7269 | } | 
| 7270 | 7270 |              } else if ($mode == 2) {
 | 
| 7271 | -                $newres .= ($i2 > 0 ? ' OR ' : '') . $field . " IN (" . $db->escape(trim($crit)) . ")";
 | |
| 7271 | +                $newres .= ($i2 > 0 ? ' OR ' : '').$field." IN (".$db->escape(trim($crit)).")";
 | |
| 7272 | 7272 | $i2++; // a criteria was added to string | 
| 7273 | 7273 |              } else if ($mode == 3) {
 | 
| 7274 | 7274 |                  $tmparray = explode(',', trim($crit));
 | 
| @@ -7277,10 +7277,10 @@ discard block | ||
| 7277 | 7277 |                      foreach ($tmparray as $val) {
 | 
| 7278 | 7278 |                          if ($val) {
 | 
| 7279 | 7279 | $listofcodes .= ($listofcodes ? ',' : ''); | 
| 7280 | - $listofcodes .= "'" . $db->escape(trim($val)) . "'"; | |
| 7280 | + $listofcodes .= "'".$db->escape(trim($val))."'"; | |
| 7281 | 7281 | } | 
| 7282 | 7282 | } | 
| 7283 | -                    $newres .= ($i2 > 0 ? ' OR ' : '') . $field . " IN (" . $listofcodes . ")";
 | |
| 7283 | +                    $newres .= ($i2 > 0 ? ' OR ' : '').$field." IN (".$listofcodes.")";
 | |
| 7284 | 7284 | $i2++; // a criteria was added to string | 
| 7285 | 7285 | } | 
| 7286 | 7286 |              } else if ($mode == 4) {
 | 
| @@ -7289,10 +7289,10 @@ discard block | ||
| 7289 | 7289 | $listofcodes = ''; | 
| 7290 | 7290 |                      foreach ($tmparray as $val) {
 | 
| 7291 | 7291 |                          if ($val) {
 | 
| 7292 | -                            $newres .= ($i2 > 0 ? ' OR (' : '(') . $field . ' LIKE \'' . $db->escape(trim($val)) . ',%\'';
 | |
| 7293 | - $newres .= ' OR ' . $field . ' = \'' . $db->escape(trim($val)) . '\''; | |
| 7294 | - $newres .= ' OR ' . $field . ' LIKE \'%,' . $db->escape(trim($val)) . '\''; | |
| 7295 | - $newres .= ' OR ' . $field . ' LIKE \'%,' . $db->escape(trim($val)) . ',%\''; | |
| 7292 | +                            $newres .= ($i2 > 0 ? ' OR (' : '(').$field.' LIKE \''.$db->escape(trim($val)).',%\'';
 | |
| 7293 | + $newres .= ' OR '.$field.' = \''.$db->escape(trim($val)).'\''; | |
| 7294 | + $newres .= ' OR '.$field.' LIKE \'%,'.$db->escape(trim($val)).'\''; | |
| 7295 | + $newres .= ' OR '.$field.' LIKE \'%,'.$db->escape(trim($val)).',%\''; | |
| 7296 | 7296 | $newres .= ')'; | 
| 7297 | 7297 | $i2++; | 
| 7298 | 7298 | } | 
| @@ -7309,9 +7309,9 @@ discard block | ||
| 7309 | 7309 | $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : ''); | 
| 7310 | 7310 | |
| 7311 | 7311 |                      if (preg_match('/\.(id|rowid)$/', $field)) { // Special case for rowid that is sometimes a ref so used as a search field
 | 
| 7312 | - $newres .= $field . " = " . (is_numeric(trim($tmpcrit)) ? trim($tmpcrit) : '0'); | |
| 7312 | + $newres .= $field." = ".(is_numeric(trim($tmpcrit)) ? trim($tmpcrit) : '0'); | |
| 7313 | 7313 |                      } else {
 | 
| 7314 | - $newres .= $field . " LIKE '"; | |
| 7314 | + $newres .= $field." LIKE '"; | |
| 7315 | 7315 | |
| 7316 | 7316 | $tmpcrit = trim($tmpcrit); | 
| 7317 | 7317 | $tmpcrit2 = $tmpcrit; | 
| @@ -7330,7 +7330,7 @@ discard block | ||
| 7330 | 7330 | $newres .= $tmpafter; | 
| 7331 | 7331 | $newres .= "'"; | 
| 7332 | 7332 |                          if ($tmpcrit2 == '') {
 | 
| 7333 | - $newres .= ' OR ' . $field . " IS NULL"; | |
| 7333 | + $newres .= ' OR '.$field." IS NULL"; | |
| 7334 | 7334 | } | 
| 7335 | 7335 | } | 
| 7336 | 7336 | |
| @@ -7341,10 +7341,10 @@ discard block | ||
| 7341 | 7341 | $i++; | 
| 7342 | 7342 | } | 
| 7343 | 7343 | if ($newres) | 
| 7344 | -            $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') . $newres . ($i2 > 1 ? ')' : '');
 | |
| 7344 | +            $res = $res.($res ? ' AND ' : '').($i2 > 1 ? '(' : '').$newres.($i2 > 1 ? ')' : '');
 | |
| 7345 | 7345 | $j++; | 
| 7346 | 7346 | } | 
| 7347 | -    $res = ($nofirstand ? "" : " AND ") . "(" . $res . ")";
 | |
| 7347 | +    $res = ($nofirstand ? "" : " AND ")."(".$res.")";
 | |
| 7348 | 7348 | //print 'xx'.$res.'yy'; | 
| 7349 | 7349 | return $res; | 
| 7350 | 7350 | } | 
| @@ -7363,8 +7363,8 @@ discard block | ||
| 7363 | 7363 | $url = $object->getLastMainDocLink($object->element); | 
| 7364 | 7364 | |
| 7365 | 7365 |      if ($url) {
 | 
| 7366 | -        $out .= img_picto('', 'object_globe.png') . ' ' . $langs->trans("DirectDownloadLink") . '<br>';
 | |
| 7367 | - $out .= '<input type="text" id="directdownloadlink" class="quatrevingtpercent" value="' . $url . '">'; | |
| 7366 | +        $out .= img_picto('', 'object_globe.png').' '.$langs->trans("DirectDownloadLink").'<br>';
 | |
| 7367 | + $out .= '<input type="text" id="directdownloadlink" class="quatrevingtpercent" value="'.$url.'">'; | |
| 7368 | 7368 |          $out .= ajax_autoselect("directdownloadlink", 0);
 | 
| 7369 | 7369 | } | 
| 7370 | 7370 | return $out; | 
| @@ -7405,7 +7405,7 @@ discard block | ||
| 7405 | 7405 | if ($extName) | 
| 7406 | 7406 | $subdir = 'thumbs/'; | 
| 7407 | 7407 | |
| 7408 | - return ($dirName ? $dirName . '/' : '') . $subdir . $fileName . $extName . $extImgTarget; // New filename for thumb | |
| 7408 | + return ($dirName ? $dirName.'/' : '').$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb | |
| 7409 | 7409 | } | 
| 7410 | 7410 | |
| 7411 | 7411 | /** | 
| @@ -7431,14 +7431,14 @@ discard block | ||
| 7431 | 7431 | |
| 7432 | 7432 |      if ($alldata == 1) {
 | 
| 7433 | 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),);
 | |
| 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 | 7435 | else | 
| 7436 | 7436 | return array(); | 
| 7437 | 7437 | } | 
| 7438 | 7438 | |
| 7439 | 7439 | // old behavior | 
| 7440 | 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')) . '\')';
 | |
| 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 | 7442 | else | 
| 7443 | 7443 | return ''; | 
| 7444 | 7444 | } | 
| @@ -7455,11 +7455,11 @@ discard block | ||
| 7455 | 7455 | global $langs; | 
| 7456 | 7456 | $out = '<script type="text/javascript"> | 
| 7457 | 7457 |                 jQuery(document).ready(function () {
 | 
| 7458 | -				    jQuery("#' . $htmlname . '").click(function() { jQuery(this).select(); } );
 | |
| 7458 | +				    jQuery("#' . $htmlname.'").click(function() { jQuery(this).select(); } );
 | |
| 7459 | 7459 | }); | 
| 7460 | 7460 | </script>'; | 
| 7461 | 7461 | if ($addlink) | 
| 7462 | -        $out .= ' <a href="' . $addlink . '" target="_blank">' . $langs->trans("Link") . '</a>';
 | |
| 7462 | +        $out .= ' <a href="'.$addlink.'" target="_blank">'.$langs->trans("Link").'</a>';
 | |
| 7463 | 7463 | return $out; | 
| 7464 | 7464 | } | 
| 7465 | 7465 | |
| @@ -7840,9 +7840,9 @@ discard block | ||
| 7840 | 7840 | |
| 7841 | 7841 |      if (!isset($dictvalues[$tablename])) {
 | 
| 7842 | 7842 | $dictvalues[$tablename] = array(); | 
| 7843 | - $sql = 'SELECT * FROM ' . $tablename . ' WHERE 1'; | |
| 7843 | + $sql = 'SELECT * FROM '.$tablename.' WHERE 1'; | |
| 7844 | 7844 | if ($checkentity) | 
| 7845 | - $sql .= ' AND entity IN (0,' . getEntity($tablename) . ')'; | |
| 7845 | + $sql .= ' AND entity IN (0,'.getEntity($tablename).')'; | |
| 7846 | 7846 | |
| 7847 | 7847 | $resql = $db->query($sql); | 
| 7848 | 7848 |          if ($resql) {
 | 
| @@ -7880,14 +7880,14 @@ discard block | ||
| 7880 | 7880 | $g = $tmp[1]; | 
| 7881 | 7881 | $b = $tmp[2]; | 
| 7882 | 7882 |          } else {
 | 
| 7883 | - $hexr = $stringcolor[0] . $stringcolor[1]; | |
| 7884 | - $hexg = $stringcolor[2] . $stringcolor[3]; | |
| 7885 | - $hexb = $stringcolor[4] . $stringcolor[5]; | |
| 7883 | + $hexr = $stringcolor[0].$stringcolor[1]; | |
| 7884 | + $hexg = $stringcolor[2].$stringcolor[3]; | |
| 7885 | + $hexb = $stringcolor[4].$stringcolor[5]; | |
| 7886 | 7886 | $r = hexdec($hexr); | 
| 7887 | 7887 | $g = hexdec($hexg); | 
| 7888 | 7888 | $b = hexdec($hexb); | 
| 7889 | 7889 | } | 
| 7890 | - $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm | |
| 7890 | + $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm | |
| 7891 | 7891 | if ($bright > 0.6) | 
| 7892 | 7892 | $res = 1; | 
| 7893 | 7893 | } | 
| @@ -7923,11 +7923,11 @@ discard block | ||
| 7923 | 7923 | return 0; // Entry is for menus all excluded to external users | 
| 7924 | 7924 | } | 
| 7925 | 7925 | if (!$menuentry['perms'] && $type_user) | 
| 7926 | - return 0; // No permissions and user is external | |
| 7926 | + return 0; // No permissions and user is external | |
| 7927 | 7927 | if (!$menuentry['perms'] && !empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) | 
| 7928 | 7928 | return 0; // No permissions and option to hide when not allowed, even for internal user, is on | 
| 7929 | 7929 | if (!$menuentry['perms']) | 
| 7930 | - return 2; // No permissions and user is external | |
| 7930 | + return 2; // No permissions and user is external | |
| 7931 | 7931 | return 1; | 
| 7932 | 7932 | } | 
| 7933 | 7933 | |
| @@ -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 | |
| @@ -27,7 +27,7 @@ discard block | ||
| 27 | 27 | * \file htdocs/core/menus/standard/eldy.lib.php | 
| 28 | 28 | * \brief Library for file eldy menus | 
| 29 | 29 | */ | 
| 30 | -require_once DOL_DOCUMENT_ROOT . '/core/class/menubase.class.php'; | |
| 30 | +require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; | |
| 31 | 31 | |
| 32 | 32 | /** | 
| 33 | 33 | * Core function to output top menu eldy | 
| @@ -378,13 +378,13 @@ discard block | ||
| 378 | 378 | $param = (isset($tmp[1]) ? $tmp[1] : ''); | 
| 379 | 379 | |
| 380 | 380 |                  if (!preg_match('/mainmenu/i', $param) || !preg_match('/leftmenu/i', $param))
 | 
| 381 | - $param .= ($param ? '&' : '') . 'mainmenu=' . $newTabMenu[$i]['mainmenu'] . '&leftmenu='; | |
| 381 | + $param .= ($param ? '&' : '').'mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu='; | |
| 382 | 382 | //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad | 
| 383 | - $url = dol_buildpath($url, 1) . ($param ? '?' . $param : ''); | |
| 383 | + $url = dol_buildpath($url, 1).($param ? '?'.$param : ''); | |
| 384 | 384 | //$shorturl = $shorturl.($param?'?'.$param:''); | 
| 385 | 385 | $shorturl = $url; | 
| 386 | 386 | if (DOL_URL_ROOT) | 
| 387 | -                    $shorturl = preg_replace('/^' . preg_quote(DOL_URL_ROOT, '/') . '/', '', $shorturl);
 | |
| 387 | +                    $shorturl = preg_replace('/^'.preg_quote(DOL_URL_ROOT, '/').'/', '', $shorturl);
 | |
| 388 | 388 | } | 
| 389 | 389 | |
| 390 | 390 | // Define the class (top menu selected or not) | 
| @@ -408,7 +408,7 @@ discard block | ||
| 408 | 408 |      if (empty($noout)) {
 | 
| 409 | 409 |          foreach ($menu->liste as $menkey => $menuval) {
 | 
| 410 | 410 | print_start_menu_entry($menuval['idsel'], $menuval['classname'], $menuval['enabled']); | 
| 411 | -            print_text_menu_entry($menuval['titre'], $menuval['enabled'], (($menuval['url'] != '#' && !preg_match('/^(http:\/\/|https:\/\/)/i', $menuval['url'])) ? DOL_URL_ROOT : '') . $menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target'] ? $menuval['target'] : $atarget));
 | |
| 411 | +            print_text_menu_entry($menuval['titre'], $menuval['enabled'], (($menuval['url'] != '#' && !preg_match('/^(http:\/\/|https:\/\/)/i', $menuval['url'])) ? DOL_URL_ROOT : '').$menuval['url'], $menuval['id'], $menuval['idsel'], $menuval['classname'], ($menuval['target'] ? $menuval['target'] : $atarget));
 | |
| 412 | 412 | print_end_menu_entry($menuval['enabled']); | 
| 413 | 413 | } | 
| 414 | 414 | } | 
| @@ -433,7 +433,7 @@ discard block | ||
| 433 | 433 | global $conf; | 
| 434 | 434 | |
| 435 | 435 | print '<div class="tmenudiv">'; | 
| 436 | - print '<ul class="tmenu"' . (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' title="Top menu"') . '>'; | |
| 436 | + print '<ul class="tmenu"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' title="Top menu"').'>'; | |
| 437 | 437 | } | 
| 438 | 438 | |
| 439 | 439 | /** | 
| @@ -447,7 +447,7 @@ discard block | ||
| 447 | 447 | function print_start_menu_entry($idsel, $classname, $showmode) | 
| 448 | 448 |  {
 | 
| 449 | 449 |      if ($showmode) {
 | 
| 450 | - print '<li ' . $classname . ' id="mainmenutd_' . $idsel . '">'; | |
| 450 | + print '<li '.$classname.' id="mainmenutd_'.$idsel.'">'; | |
| 451 | 451 | //print '<div class="tmenuleft tmenusep"></div>'; | 
| 452 | 452 | print '<div class="tmenucenter">'; | 
| 453 | 453 | } | 
| @@ -470,17 +470,17 @@ discard block | ||
| 470 | 470 | global $langs; | 
| 471 | 471 | |
| 472 | 472 |      if ($showmode == 1) {
 | 
| 473 | - print '<a class="tmenuimage" tabindex="-1" href="' . $url . '"' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; | |
| 474 | - print '<div class="' . $id . ' ' . $idsel . ' topmenuimage"><span class="' . $id . ' tmenuimage" id="mainmenuspan_' . $idsel . '"></span></div>'; | |
| 473 | + print '<a class="tmenuimage" tabindex="-1" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').'>'; | |
| 474 | + print '<div class="'.$id.' '.$idsel.' topmenuimage"><span class="'.$id.' tmenuimage" id="mainmenuspan_'.$idsel.'"></span></div>'; | |
| 475 | 475 | print '</a>'; | 
| 476 | - print '<a ' . $classname . ' id="mainmenua_' . $idsel . '" href="' . $url . '"' . ($atarget ? ' target="' . $atarget . '"' : '') . '>'; | |
| 476 | + print '<a '.$classname.' id="mainmenua_'.$idsel.'" href="'.$url.'"'.($atarget ? ' target="'.$atarget.'"' : '').'>'; | |
| 477 | 477 | print '<span class="mainmenuaspan">'; | 
| 478 | 478 | print $text; | 
| 479 | 479 | print '</span>'; | 
| 480 | 480 | print '</a>'; | 
| 481 | 481 |      } elseif ($showmode == 2) {
 | 
| 482 | - print '<div class="' . $id . ' ' . $idsel . ' topmenuimage tmenudisabled"><span class="' . $id . '" id="mainmenuspan_' . $idsel . '"></span></div>'; | |
| 483 | -        print '<a class="tmenudisabled" id="mainmenua_' . $idsel . '" href="#" title="' . dol_escape_htmltag($langs->trans("NotAllowed")) . '">';
 | |
| 482 | + print '<div class="'.$id.' '.$idsel.' topmenuimage tmenudisabled"><span class="'.$id.'" id="mainmenuspan_'.$idsel.'"></span></div>'; | |
| 483 | +        print '<a class="tmenudisabled" id="mainmenua_'.$idsel.'" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">';
 | |
| 484 | 484 | print '<span class="mainmenuaspan">'; | 
| 485 | 485 | print $text; | 
| 486 | 486 | print '</span>'; | 
| @@ -545,38 +545,38 @@ discard block | ||
| 545 | 545 | // Show logo company | 
| 546 | 546 |      if (empty($conf->global->MAIN_MENU_INVERT) && empty($noout) && !empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
 | 
| 547 | 547 | $mysoc->logo_mini = $conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; | 
| 548 | -        if (!empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_mini)) {
 | |
| 549 | -            $urllogo = DOL_BASE_URI . '/viewimage.php?cache=1&modulepart=mycompany&file=' . urlencode('logos/thumbs/' . $mysoc->logo_mini);
 | |
| 548 | +        if (!empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) {
 | |
| 549 | +            $urllogo = DOL_BASE_URI.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_mini);
 | |
| 550 | 550 |          } else {
 | 
| 551 | - $urllogo = DOL_BASE_URI . '/theme/dolibarr_logo.png'; | |
| 551 | + $urllogo = DOL_BASE_URI.'/theme/dolibarr_logo.png'; | |
| 552 | 552 | } | 
| 553 | 553 |          $title = $langs->trans("GoIntoSetupToChangeLogo");
 | 
| 554 | - print "\n" . '<!-- Show logo on menu -->' . "\n"; | |
| 555 | - print '<div class="blockvmenuimpair blockvmenulogo">' . "\n"; | |
| 554 | + print "\n".'<!-- Show logo on menu -->'."\n"; | |
| 555 | + print '<div class="blockvmenuimpair blockvmenulogo">'."\n"; | |
| 556 | 556 | print '<div class="menu_titre" id="menu_titre_logo"></div>'; | 
| 557 | 557 | print '<div class="menu_top" id="menu_top_logo"></div>'; | 
| 558 | 558 | print '<div class="menu_contenu" id="menu_contenu_logo">'; | 
| 559 | - print '<div class="center"><img class="mycompany" title="' . dol_escape_htmltag($title) . '" alt="" src="' . $urllogo . '" style="max-width: 70%"></div>' . "\n"; | |
| 559 | + print '<div class="center"><img class="mycompany" title="'.dol_escape_htmltag($title).'" alt="" src="'.$urllogo.'" style="max-width: 70%"></div>'."\n"; | |
| 560 | 560 | print '</div>'; | 
| 561 | 561 | print '<div class="menu_end" id="menu_end_logo"></div>'; | 
| 562 | - print '</div>' . "\n"; | |
| 562 | + print '</div>'."\n"; | |
| 563 | 563 | } | 
| 564 | 564 | |
| 565 | 565 |      if (is_array($moredata) && !empty($moredata['searchform'])) { // searchform can contains select2 code or link to show old search form or link to switch on search page
 | 
| 566 | 566 | print "\n"; | 
| 567 | 567 | print "<!-- Begin SearchForm -->\n"; | 
| 568 | - print '<div id="blockvmenusearch" class="blockvmenusearch">' . "\n"; | |
| 568 | + print '<div id="blockvmenusearch" class="blockvmenusearch">'."\n"; | |
| 569 | 569 | print $moredata['searchform']; | 
| 570 | - print '</div>' . "\n"; | |
| 570 | + print '</div>'."\n"; | |
| 571 | 571 | print "<!-- End SearchForm -->\n"; | 
| 572 | 572 | } | 
| 573 | 573 | |
| 574 | 574 |      if (is_array($moredata) && !empty($moredata['bookmarks'])) {
 | 
| 575 | 575 | print "\n"; | 
| 576 | 576 | print "<!-- Begin Bookmarks -->\n"; | 
| 577 | - print '<div id="blockvmenubookmarks" class="blockvmenubookmarks">' . "\n"; | |
| 577 | + print '<div id="blockvmenubookmarks" class="blockvmenubookmarks">'."\n"; | |
| 578 | 578 | print $moredata['bookmarks']; | 
| 579 | - print '</div>' . "\n"; | |
| 579 | + print '</div>'."\n"; | |
| 580 | 580 | print "<!-- End Bookmarks -->\n"; | 
| 581 | 581 | } | 
| 582 | 582 | |
| @@ -593,11 +593,11 @@ discard block | ||
| 593 | 593 | |
| 594 | 594 | // Home - dashboard | 
| 595 | 595 |  //$newmenu->add("/index.php?mainmenu=home&leftmenu=home", $langs->trans("MyDashboard"), 0, 1, '', $mainmenu, 'home', 0, '', '', '', '<i class="fa fa-bar-chart fa-fw paddingright"></i>');
 | 
| 596 | -            $newmenu->add(BASE_URI . "?controller=home&method=home&mainmenu=home&leftmenu=home", $langs->trans("MyDashboard"), 0, 1, '', $mainmenu, 'home', 0, '', '', '', '<i class="fa fa-bar-chart fa-fw paddingright"></i>');
 | |
| 596 | +            $newmenu->add(BASE_URI."?controller=home&method=home&mainmenu=home&leftmenu=home", $langs->trans("MyDashboard"), 0, 1, '', $mainmenu, 'home', 0, '', '', '', '<i class="fa fa-bar-chart fa-fw paddingright"></i>');
 | |
| 597 | 597 | |
| 598 | 598 | // Setup | 
| 599 | 599 |  //$newmenu->add("/admin/index.php?mainmenu=home&leftmenu=setup", $langs->trans("Setup"), 0, $user->admin, '', $mainmenu, 'setup', 0, '', '', '', '<i class="fa fa-wrench fa-fw paddingright"></i>');
 | 
| 600 | -            $newmenu->add(BASE_URI . "?controller=admin&method=index&mainmenu=home&leftmenu=setup", $langs->trans("Setup"), 0, $user->admin, '', $mainmenu, 'setup', 0, '', '', '', '<i class="fa fa-wrench fa-fw paddingright"></i>');
 | |
| 600 | +            $newmenu->add(BASE_URI."?controller=admin&method=index&mainmenu=home&leftmenu=setup", $langs->trans("Setup"), 0, $user->admin, '', $mainmenu, 'setup', 0, '', '', '', '<i class="fa fa-wrench fa-fw paddingright"></i>');
 | |
| 601 | 601 | |
| 602 | 602 |              if ($usemenuhider || empty($leftmenu) || $leftmenu == "setup") {
 | 
| 603 | 603 | // Load translation files required by the page | 
| @@ -606,14 +606,14 @@ discard block | ||
| 606 | 606 | $warnpicto = ''; | 
| 607 | 607 |                  if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) {
 | 
| 608 | 608 |                      $langs->load("errors");
 | 
| 609 | -                    $warnpicto = ' ' . img_warning($langs->trans("WarningMandatorySetupNotComplete"));
 | |
| 609 | +                    $warnpicto = ' '.img_warning($langs->trans("WarningMandatorySetupNotComplete"));
 | |
| 610 | 610 | } | 
| 611 | 611 |  //$newmenu->add("/admin/company.php?mainmenu=home", $langs->trans("MenuCompanySetup") . $warnpicto, 1);
 | 
| 612 | -                $newmenu->add(BASE_URI . "?controller=admin&method=company&mainmenu=home", $langs->trans("MenuCompanySetup") . $warnpicto, 1);
 | |
| 612 | +                $newmenu->add(BASE_URI."?controller=admin&method=company&mainmenu=home", $langs->trans("MenuCompanySetup").$warnpicto, 1);
 | |
| 613 | 613 | $warnpicto = ''; | 
| 614 | 614 |                  if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only user module enabled
 | 
| 615 | 615 |                      $langs->load("errors");
 | 
| 616 | -                    $warnpicto = ' ' . img_warning($langs->trans("WarningMandatorySetupNotComplete"));
 | |
| 616 | +                    $warnpicto = ' '.img_warning($langs->trans("WarningMandatorySetupNotComplete"));
 | |
| 617 | 617 | } | 
| 618 | 618 | /* | 
| 619 | 619 |                    $newmenu->add("/admin/modules.php?mainmenu=home", $langs->trans("Modules") . $warnpicto, 1);
 | 
| @@ -632,42 +632,42 @@ discard block | ||
| 632 | 632 |                    $newmenu->add("/admin/dict.php?mainmenu=home", $langs->trans("Dictionary"), 1);
 | 
| 633 | 633 |                    $newmenu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"), 1);
 | 
| 634 | 634 | */ | 
| 635 | -                $newmenu->add(BASE_URI . "?controller=admin&method=modules&mainmenu=home", $langs->trans("Modules") . $warnpicto, 1);
 | |
| 636 | -                $newmenu->add(BASE_URI . "?controller=admin&method=menus&mainmenu=home", $langs->trans("Menus"), 1);
 | |
| 637 | -                $newmenu->add(BASE_URI . "?controller=admin&method=ihm&mainmenu=home", $langs->trans("GUISetup"), 1);
 | |
| 638 | - | |
| 639 | -                $newmenu->add(BASE_URI . "?controller=admin&method=translation&mainmenu=home", $langs->trans("Translation"), 1);
 | |
| 640 | -                $newmenu->add(BASE_URI . "?controller=admin&method=defaultvalues&mainmenu=home", $langs->trans("DefaultValues"), 1);
 | |
| 641 | -                $newmenu->add(BASE_URI . "?controller=admin&method=boxes&mainmenu=home", $langs->trans("Boxes"), 1);
 | |
| 642 | -                $newmenu->add(BASE_URI . "?controller=admin&method=delais&mainmenu=home", $langs->trans("MenuWarnings"), 1);
 | |
| 643 | -                $newmenu->add(BASE_URI . "?controller=admin&method=security_other&mainmenu=home", $langs->trans("Security"), 1);
 | |
| 644 | -                $newmenu->add(BASE_URI . "?controller=admin&method=limits&mainmenu=home", $langs->trans("MenuLimits"), 1);
 | |
| 645 | -                $newmenu->add(BASE_URI . "?controller=admin&method=pdf&mainmenu=home", $langs->trans("PDF"), 1);
 | |
| 646 | -                $newmenu->add(BASE_URI . "?controller=admin&method=mails&mainmenu=home", $langs->trans("Emails"), 1);
 | |
| 647 | -                $newmenu->add(BASE_URI . "?controller=admin&method=sms&mainmenu=home", $langs->trans("SMS"), 1);
 | |
| 648 | -                $newmenu->add(BASE_URI . "?controller=admin&method=dict&mainmenu=home", $langs->trans("Dictionary"), 1);
 | |
| 649 | -                $newmenu->add(BASE_URI . "?controller=admin&method=const&mainmenu=home", $langs->trans("OtherSetup"), 1);
 | |
| 635 | +                $newmenu->add(BASE_URI."?controller=admin&method=modules&mainmenu=home", $langs->trans("Modules").$warnpicto, 1);
 | |
| 636 | +                $newmenu->add(BASE_URI."?controller=admin&method=menus&mainmenu=home", $langs->trans("Menus"), 1);
 | |
| 637 | +                $newmenu->add(BASE_URI."?controller=admin&method=ihm&mainmenu=home", $langs->trans("GUISetup"), 1);
 | |
| 638 | + | |
| 639 | +                $newmenu->add(BASE_URI."?controller=admin&method=translation&mainmenu=home", $langs->trans("Translation"), 1);
 | |
| 640 | +                $newmenu->add(BASE_URI."?controller=admin&method=defaultvalues&mainmenu=home", $langs->trans("DefaultValues"), 1);
 | |
| 641 | +                $newmenu->add(BASE_URI."?controller=admin&method=boxes&mainmenu=home", $langs->trans("Boxes"), 1);
 | |
| 642 | +                $newmenu->add(BASE_URI."?controller=admin&method=delais&mainmenu=home", $langs->trans("MenuWarnings"), 1);
 | |
| 643 | +                $newmenu->add(BASE_URI."?controller=admin&method=security_other&mainmenu=home", $langs->trans("Security"), 1);
 | |
| 644 | +                $newmenu->add(BASE_URI."?controller=admin&method=limits&mainmenu=home", $langs->trans("MenuLimits"), 1);
 | |
| 645 | +                $newmenu->add(BASE_URI."?controller=admin&method=pdf&mainmenu=home", $langs->trans("PDF"), 1);
 | |
| 646 | +                $newmenu->add(BASE_URI."?controller=admin&method=mails&mainmenu=home", $langs->trans("Emails"), 1);
 | |
| 647 | +                $newmenu->add(BASE_URI."?controller=admin&method=sms&mainmenu=home", $langs->trans("SMS"), 1);
 | |
| 648 | +                $newmenu->add(BASE_URI."?controller=admin&method=dict&mainmenu=home", $langs->trans("Dictionary"), 1);
 | |
| 649 | +                $newmenu->add(BASE_URI."?controller=admin&method=const&mainmenu=home", $langs->trans("OtherSetup"), 1);
 | |
| 650 | 650 | } | 
| 651 | 651 | |
| 652 | 652 | // System tools | 
| 653 | 653 |  //$newmenu->add("/admin/tools/index.php?mainmenu=home&leftmenu=admintools", $langs->trans("AdminTools"), 0, $user->admin, '', $mainmenu, 'admintools', 0, '', '', '', '<i class="fa fa-server fa-fw paddingright"></i>');
 | 
| 654 | -            $newmenu->add(BASE_URI . "?controller=admin/tools&method=index&mainmenu=home&leftmenu=admintools", $langs->trans("AdminTools"), 0, $user->admin, '', $mainmenu, 'admintools', 0, '', '', '', '<i class="fa fa-server fa-fw paddingright"></i>');
 | |
| 654 | +            $newmenu->add(BASE_URI."?controller=admin/tools&method=index&mainmenu=home&leftmenu=admintools", $langs->trans("AdminTools"), 0, $user->admin, '', $mainmenu, 'admintools', 0, '', '', '', '<i class="fa fa-server fa-fw paddingright"></i>');
 | |
| 655 | 655 | |
| 656 | 656 |              if ($usemenuhider || empty($leftmenu) || preg_match('/^admintools/', $leftmenu)) {
 | 
| 657 | 657 | // Load translation files required by the page | 
| 658 | 658 |                  $langs->loadLangs(array('admin', 'help'));
 | 
| 659 | 659 | |
| 660 | 660 |  //$newmenu->add('/admin/system/dolibarr.php?mainmenu=home&leftmenu=admintools_info', $langs->trans('InfoDolibarr'), 1);
 | 
| 661 | -                $newmenu->add(BASE_URI . "?controller=admin/system&method=dolibarr&mainmenu=home&leftmenu=admintools_info", $langs->trans('InfoDolibarr'), 1);
 | |
| 661 | +                $newmenu->add(BASE_URI."?controller=admin/system&method=dolibarr&mainmenu=home&leftmenu=admintools_info", $langs->trans('InfoDolibarr'), 1);
 | |
| 662 | 662 |                  if ($usemenuhider || empty($leftmenu) || $leftmenu == 'admintools_info') {
 | 
| 663 | 663 | /* | 
| 664 | 664 |                        $newmenu->add('/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info', $langs->trans('Modules'), 2);
 | 
| 665 | 665 |                        $newmenu->add('/admin/triggers.php?mainmenu=home&leftmenu=admintools_info', $langs->trans('Triggers'), 2);
 | 
| 666 | 666 |                        $newmenu->add('/admin/system/filecheck.php?mainmenu=home&leftmenu=admintools_info', $langs->trans('FileCheck'), 2);
 | 
| 667 | 667 | */ | 
| 668 | -                    $newmenu->add(BASE_URI . '?controller=admin/system&method=modules&mainmenu=home&leftmenu=admintools_info', $langs->trans('Modules'), 2);
 | |
| 669 | -                    $newmenu->add(BASE_URI . '?controller=admin&method=triggers&mainmenu=home&leftmenu=admintools_info', $langs->trans('Triggers'), 2);
 | |
| 670 | -                    $newmenu->add(BASE_URI . '?controller=admin/system&method=filecheck&mainmenu=home&leftmenu=admintools_info', $langs->trans('FileCheck'), 2);
 | |
| 668 | +                    $newmenu->add(BASE_URI.'?controller=admin/system&method=modules&mainmenu=home&leftmenu=admintools_info', $langs->trans('Modules'), 2);
 | |
| 669 | +                    $newmenu->add(BASE_URI.'?controller=admin&method=triggers&mainmenu=home&leftmenu=admintools_info', $langs->trans('Triggers'), 2);
 | |
| 670 | +                    $newmenu->add(BASE_URI.'?controller=admin/system&method=filecheck&mainmenu=home&leftmenu=admintools_info', $langs->trans('FileCheck'), 2);
 | |
| 671 | 671 | } | 
| 672 | 672 | /* | 
| 673 | 673 |                    $newmenu->add('/admin/system/browser.php?mainmenu=home&leftmenu=admintools', $langs->trans('InfoBrowser'), 1);
 | 
| @@ -687,32 +687,32 @@ discard block | ||
| 687 | 687 |                    $newmenu->add("/admin/tools/listsessions.php?mainmenu=home&leftmenu=admintools", $langs->trans("Sessions"), 1);
 | 
| 688 | 688 |                    $newmenu->add('/admin/system/about.php?mainmenu=home&leftmenu=admintools', $langs->trans('ExternalResources'), 1);
 | 
| 689 | 689 | */ | 
| 690 | -                $newmenu->add(BASE_URI . '?controller=admin/system&method=browser&mainmenu=home&leftmenu=admintools', $langs->trans('InfoBrowser'), 1);
 | |
| 691 | -                $newmenu->add(BASE_URI . '?controller=admin/system&method=os&mainmenu=home&leftmenu=admintools', $langs->trans('InfoOS'), 1);
 | |
| 692 | -                $newmenu->add(BASE_URI . '?controller=admin/system&method=web&mainmenu=home&leftmenu=admintools', $langs->trans('InfoWebServer'), 1);
 | |
| 693 | -                $newmenu->add(BASE_URI . '?controller=admin/system&method=phpinfo&mainmenu=home&leftmenu=admintools', $langs->trans('InfoPHP'), 1);
 | |
| 690 | +                $newmenu->add(BASE_URI.'?controller=admin/system&method=browser&mainmenu=home&leftmenu=admintools', $langs->trans('InfoBrowser'), 1);
 | |
| 691 | +                $newmenu->add(BASE_URI.'?controller=admin/system&method=os&mainmenu=home&leftmenu=admintools', $langs->trans('InfoOS'), 1);
 | |
| 692 | +                $newmenu->add(BASE_URI.'?controller=admin/system&method=web&mainmenu=home&leftmenu=admintools', $langs->trans('InfoWebServer'), 1);
 | |
| 693 | +                $newmenu->add(BASE_URI.'?controller=admin/system&method=phpinfo&mainmenu=home&leftmenu=admintools', $langs->trans('InfoPHP'), 1);
 | |
| 694 | 694 |  //if (function_exists('xdebug_is_enabled')) $newmenu->add('/admin/system/xdebug.php', $langs->trans('XDebug'),1);
 | 
| 695 | -                $newmenu->add(BASE_URI . '?controller=admin/system&method=database&mainmenu=home&leftmenu=admintools', $langs->trans('InfoDatabase'), 1);
 | |
| 695 | +                $newmenu->add(BASE_URI.'?controller=admin/system&method=database&mainmenu=home&leftmenu=admintools', $langs->trans('InfoDatabase'), 1);
 | |
| 696 | 696 |                  if (function_exists('eaccelerator_info'))
 | 
| 697 | -                    $newmenu->add(BASE_URI . "?controller=admin/tools&method=eaccelerator&mainmenu=home&leftmenu=admintools", $langs->trans("EAccelerator"), 1);
 | |
| 697 | +                    $newmenu->add(BASE_URI."?controller=admin/tools&method=eaccelerator&mainmenu=home&leftmenu=admintools", $langs->trans("EAccelerator"), 1);
 | |
| 698 | 698 |  //$newmenu->add("/admin/system/perf.php?mainmenu=home&leftmenu=admintools", $langs->trans("InfoPerf"),1);
 | 
| 699 | -                $newmenu->add(BASE_URI . "?controller=admin/tools&method=dolibarr_export&mainmenu=home&leftmenu=admintools", $langs->trans("Backup"), 1);
 | |
| 700 | -                $newmenu->add(BASE_URI . "?controller=admin/tools&method=dolibarr_import&mainmenu=home&leftmenu=admintools", $langs->trans("Restore"), 1);
 | |
| 701 | -                $newmenu->add(BASE_URI . "?controller=admin/tools&method=update&mainmenu=home&leftmenu=admintools", $langs->trans("MenuUpgrade"), 1);
 | |
| 702 | -                $newmenu->add(BASE_URI . "?controller=admin/tools&method=purge&mainmenu=home&leftmenu=admintools", $langs->trans("Purge"), 1);
 | |
| 703 | -                $newmenu->add(BASE_URI . "?controller=admin/tools&method=listevents&mainmenu=home&leftmenu=admintools", $langs->trans("Audit"), 1);
 | |
| 704 | -                $newmenu->add(BASE_URI . "?controller=admin/tools&method=listsessions&mainmenu=home&leftmenu=admintools", $langs->trans("Sessions"), 1);
 | |
| 705 | -                $newmenu->add(BASE_URI . '?controller=admin/system&method=about&mainmenu=home&leftmenu=admintools', $langs->trans('ExternalResources'), 1);
 | |
| 699 | +                $newmenu->add(BASE_URI."?controller=admin/tools&method=dolibarr_export&mainmenu=home&leftmenu=admintools", $langs->trans("Backup"), 1);
 | |
| 700 | +                $newmenu->add(BASE_URI."?controller=admin/tools&method=dolibarr_import&mainmenu=home&leftmenu=admintools", $langs->trans("Restore"), 1);
 | |
| 701 | +                $newmenu->add(BASE_URI."?controller=admin/tools&method=update&mainmenu=home&leftmenu=admintools", $langs->trans("MenuUpgrade"), 1);
 | |
| 702 | +                $newmenu->add(BASE_URI."?controller=admin/tools&method=purge&mainmenu=home&leftmenu=admintools", $langs->trans("Purge"), 1);
 | |
| 703 | +                $newmenu->add(BASE_URI."?controller=admin/tools&method=listevents&mainmenu=home&leftmenu=admintools", $langs->trans("Audit"), 1);
 | |
| 704 | +                $newmenu->add(BASE_URI."?controller=admin/tools&method=listsessions&mainmenu=home&leftmenu=admintools", $langs->trans("Sessions"), 1);
 | |
| 705 | +                $newmenu->add(BASE_URI.'?controller=admin/system&method=about&mainmenu=home&leftmenu=admintools', $langs->trans('ExternalResources'), 1);
 | |
| 706 | 706 | |
| 707 | 707 |                  if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
 | 
| 708 | 708 |                      $langs->load("products");
 | 
| 709 | 709 |  //$newmenu->add("/product/admin/product_tools.php?mainmenu=home&leftmenu=admintools", $langs->trans("ProductVatMassChange"), 1, $user->admin);
 | 
| 710 | -                    $newmenu->add(BASE_URI . "?controller=product/admin&method=product_tools&mainmenu=home&leftmenu=admintools", $langs->trans("ProductVatMassChange"), 1, $user->admin);
 | |
| 710 | +                    $newmenu->add(BASE_URI."?controller=product/admin&method=product_tools&mainmenu=home&leftmenu=admintools", $langs->trans("ProductVatMassChange"), 1, $user->admin);
 | |
| 711 | 711 | } | 
| 712 | 712 | } | 
| 713 | 713 | |
| 714 | 714 |  //$newmenu->add("/user/home.php?leftmenu=users", $langs->trans("MenuUsersAndGroups"), 0, $user->rights->user->user->lire, '', $mainmenu, 'users', 0, '', '', '', '<i class="fa fa-users fa-fw paddingright"></i>');
 | 
| 715 | -            $newmenu->add(BASE_URI . "?controller=user&method=home&leftmenu=users", $langs->trans("MenuUsersAndGroups"), 0, $user->rights->user->user->lire, '', $mainmenu, 'users', 0, '', '', '', '<i class="fa fa-users fa-fw paddingright"></i>');
 | |
| 715 | +            $newmenu->add(BASE_URI."?controller=user&method=home&leftmenu=users", $langs->trans("MenuUsersAndGroups"), 0, $user->rights->user->user->lire, '', $mainmenu, 'users', 0, '', '', '', '<i class="fa fa-users fa-fw paddingright"></i>');
 | |
| 716 | 716 |              if ($user->rights->user->user->lire) {
 | 
| 717 | 717 |                  if ($usemenuhider || empty($leftmenu) || $leftmenu == "users") {
 | 
| 718 | 718 |                      $newmenu->add("", $langs->trans("Users"), 1, $user->rights->user->user->lire || $user->admin);
 | 
| @@ -728,16 +728,16 @@ discard block | ||
| 728 | 728 |                        $newmenu->add("/user/group/card.php?leftmenu=users&action=create", $langs->trans("NewGroup"), 2, (($conf->global->MAIN_USE_ADVANCED_PERMS ? $user->rights->user->group_advance->write : $user->rights->user->user->creer) || $user->admin) && !(!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
 | 
| 729 | 729 |                        $newmenu->add("/user/group/list.php?leftmenu=users", $langs->trans("ListOfGroups"), 2, (($conf->global->MAIN_USE_ADVANCED_PERMS ? $user->rights->user->group_advance->read : $user->rights->user->user->lire) || $user->admin) && !(!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
 | 
| 730 | 730 | */ | 
| 731 | -                    $newmenu->add(BASE_URI . "?controller=user&method=card&leftmenu=users&action=create", $langs->trans("NewUser"), 2, ($user->rights->user->user->creer || $user->admin) && !(!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE), '', 'home');
 | |
| 732 | -                    $newmenu->add(BASE_URI . "?controller=user&method=list&leftmenu=users", $langs->trans("ListOfUsers"), 2, $user->rights->user->user->lire || $user->admin);
 | |
| 733 | -                    $newmenu->add(BASE_URI . "?controller=user&method=hierarchy&leftmenu=users", $langs->trans("HierarchicView"), 2, $user->rights->user->user->lire || $user->admin);
 | |
| 731 | +                    $newmenu->add(BASE_URI."?controller=user&method=card&leftmenu=users&action=create", $langs->trans("NewUser"), 2, ($user->rights->user->user->creer || $user->admin) && !(!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE), '', 'home');
 | |
| 732 | +                    $newmenu->add(BASE_URI."?controller=user&method=list&leftmenu=users", $langs->trans("ListOfUsers"), 2, $user->rights->user->user->lire || $user->admin);
 | |
| 733 | +                    $newmenu->add(BASE_URI."?controller=user&method=hierarchy&leftmenu=users", $langs->trans("HierarchicView"), 2, $user->rights->user->user->lire || $user->admin);
 | |
| 734 | 734 |                      if (!empty($conf->categorie->enabled)) {
 | 
| 735 | 735 |                          $langs->load("categories");
 | 
| 736 | -                        $newmenu->add(BASE_URI . "?controller=categories&method=index&leftmenu=users&type=7", $langs->trans("UsersCategoriesShort"), 2, $user->rights->categorie->lire, '', $mainmenu, 'cat');
 | |
| 736 | +                        $newmenu->add(BASE_URI."?controller=categories&method=index&leftmenu=users&type=7", $langs->trans("UsersCategoriesShort"), 2, $user->rights->categorie->lire, '', $mainmenu, 'cat');
 | |
| 737 | 737 | } | 
| 738 | 738 |                      $newmenu->add("", $langs->trans("Groups"), 1, ($user->rights->user->user->lire || $user->admin) && !(!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
 | 
| 739 | -                    $newmenu->add(BASE_URI . "?controller=user/group&method=card&leftmenu=users&action=create", $langs->trans("NewGroup"), 2, (($conf->global->MAIN_USE_ADVANCED_PERMS ? $user->rights->user->group_advance->write : $user->rights->user->user->creer) || $user->admin) && !(!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
 | |
| 740 | -                    $newmenu->add(BASE_URI . "?controller=user/group&method=list&leftmenu=users", $langs->trans("ListOfGroups"), 2, (($conf->global->MAIN_USE_ADVANCED_PERMS ? $user->rights->user->group_advance->read : $user->rights->user->user->lire) || $user->admin) && !(!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
 | |
| 739 | +                    $newmenu->add(BASE_URI."?controller=user/group&method=card&leftmenu=users&action=create", $langs->trans("NewGroup"), 2, (($conf->global->MAIN_USE_ADVANCED_PERMS ? $user->rights->user->group_advance->write : $user->rights->user->user->creer) || $user->admin) && !(!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
 | |
| 740 | +                    $newmenu->add(BASE_URI."?controller=user/group&method=list&leftmenu=users", $langs->trans("ListOfGroups"), 2, (($conf->global->MAIN_USE_ADVANCED_PERMS ? $user->rights->user->group_advance->read : $user->rights->user->user->lire) || $user->admin) && !(!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE));
 | |
| 741 | 741 | } | 
| 742 | 742 | } | 
| 743 | 743 | } | 
| @@ -750,26 +750,26 @@ discard block | ||
| 750 | 750 |              if (!empty($conf->societe->enabled)) {
 | 
| 751 | 751 |                  $langs->load("companies");
 | 
| 752 | 752 |  //$newmenu->add("/societe/index.php?leftmenu=thirdparties", $langs->trans("ThirdParty"), 0, $user->rights->societe->lire, '', $mainmenu, 'thirdparties');
 | 
| 753 | -                $newmenu->add(BASE_URI . "?controller=societe&method=index&leftmenu=thirdparties", $langs->trans("ThirdParty"), 0, $user->rights->societe->lire, '', $mainmenu, 'thirdparties');
 | |
| 753 | +                $newmenu->add(BASE_URI."?controller=societe&method=index&leftmenu=thirdparties", $langs->trans("ThirdParty"), 0, $user->rights->societe->lire, '', $mainmenu, 'thirdparties');
 | |
| 754 | 754 | |
| 755 | 755 |                  if ($user->rights->societe->creer) {
 | 
| 756 | 756 |  //$newmenu->add("/societe/card.php?action=create", $langs->trans("MenuNewThirdParty"), 1);
 | 
| 757 | -                    $newmenu->add(BASE_URI . "?controller=societe&method=card&action=create", $langs->trans("MenuNewThirdParty"), 1);
 | |
| 757 | +                    $newmenu->add(BASE_URI."?controller=societe&method=card&action=create", $langs->trans("MenuNewThirdParty"), 1);
 | |
| 758 | 758 |                      if (!$conf->use_javascript_ajax) {
 | 
| 759 | 759 |  //$newmenu->add("/societe/card.php?action=create&private=1", $langs->trans("MenuNewPrivateIndividual"), 1);
 | 
| 760 | -                        $newmenu->add(BASE_URI . "?controller=societe&method=card&action=create&private=1", $langs->trans("MenuNewPrivateIndividual"), 1);
 | |
| 760 | +                        $newmenu->add(BASE_URI."?controller=societe&method=card&action=create&private=1", $langs->trans("MenuNewPrivateIndividual"), 1);
 | |
| 761 | 761 | } | 
| 762 | 762 | } | 
| 763 | 763 | } | 
| 764 | 764 | |
| 765 | 765 |  //$newmenu->add("/societe/list.php?leftmenu=thirdparties", $langs->trans("List"), 1);
 | 
| 766 | -            $newmenu->add(BASE_URI . "?controller=societe&method=list&leftmenu=thirdparties", $langs->trans("List"), 1);
 | |
| 766 | +            $newmenu->add(BASE_URI."?controller=societe&method=list&leftmenu=thirdparties", $langs->trans("List"), 1);
 | |
| 767 | 767 | |
| 768 | 768 | // Prospects | 
| 769 | 769 |              if (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
 | 
| 770 | 770 |                  $langs->load("commercial");
 | 
| 771 | 771 |  //$newmenu->add("/societe/list.php?type=p&leftmenu=prospects", $langs->trans("ListProspectsShort"), 1, $user->rights->societe->lire, '', $mainmenu, 'prospects');
 | 
| 772 | -                $newmenu->add(BASE_URI . "?controller=societe&method=list&type=p&leftmenu=prospects", $langs->trans("ListProspectsShort"), 1, $user->rights->societe->lire, '', $mainmenu, 'prospects');
 | |
| 772 | +                $newmenu->add(BASE_URI."?controller=societe&method=list&type=p&leftmenu=prospects", $langs->trans("ListProspectsShort"), 1, $user->rights->societe->lire, '', $mainmenu, 'prospects');
 | |
| 773 | 773 | /* no more required, there is a filter that can do more | 
| 774 | 774 |                    if ($usemenuhider || empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/societe/list.php?type=p&sortfield=s.datec&sortorder=desc&begin=&search_stcomm=-1", $langs->trans("LastProspectDoNotContact"), 2, $user->rights->societe->lire);
 | 
| 775 | 775 |                    if ($usemenuhider || empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/societe/list.php?type=p&sortfield=s.datec&sortorder=desc&begin=&search_stcomm=0", $langs->trans("LastProspectNeverContacted"), 2, $user->rights->societe->lire);
 | 
| @@ -778,7 +778,7 @@ discard block | ||
| 778 | 778 |                    if ($usemenuhider || empty($leftmenu) || $leftmenu=="prospects") $newmenu->add("/societe/list.php?type=p&sortfield=s.datec&sortorder=desc&begin=&search_stcomm=3", $langs->trans("LastProspectContactDone"), 2, $user->rights->societe->lire);
 | 
| 779 | 779 | */ | 
| 780 | 780 |  //$newmenu->add("/societe/card.php?leftmenu=prospects&action=create&type=p", $langs->trans("MenuNewProspect"), 2, $user->rights->societe->creer);
 | 
| 781 | -                $newmenu->add(BASE_URI . "?controller=societe&method=card&leftmenu=prospects&action=create&type=p", $langs->trans("MenuNewProspect"), 2, $user->rights->societe->creer);
 | |
| 781 | +                $newmenu->add(BASE_URI."?controller=societe&method=card&leftmenu=prospects&action=create&type=p", $langs->trans("MenuNewProspect"), 2, $user->rights->societe->creer);
 | |
| 782 | 782 |  //$newmenu->add("/contact/list.php?leftmenu=customers&type=p", $langs->trans("Contacts"), 2, $user->rights->societe->contact->lire);
 | 
| 783 | 783 | } | 
| 784 | 784 | |
| @@ -786,10 +786,10 @@ discard block | ||
| 786 | 786 |              if (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
 | 
| 787 | 787 |                  $langs->load("commercial");
 | 
| 788 | 788 |  //$newmenu->add("/societe/list.php?type=c&leftmenu=customers", $langs->trans("ListCustomersShort"), 1, $user->rights->societe->lire, '', $mainmenu, 'customers');
 | 
| 789 | -                $newmenu->add(BASE_URI . "?controller=societe&method=list&type=c&leftmenu=customers", $langs->trans("ListCustomersShort"), 1, $user->rights->societe->lire, '', $mainmenu, 'customers');
 | |
| 789 | +                $newmenu->add(BASE_URI."?controller=societe&method=list&type=c&leftmenu=customers", $langs->trans("ListCustomersShort"), 1, $user->rights->societe->lire, '', $mainmenu, 'customers');
 | |
| 790 | 790 | |
| 791 | 791 |  //$newmenu->add("/societe/card.php?leftmenu=customers&action=create&type=c", $langs->trans("MenuNewCustomer"), 2, $user->rights->societe->creer);
 | 
| 792 | -                $newmenu->add(BASE_URI . "?controller=societe&method=card&leftmenu=customers&action=create&type=c", $langs->trans("MenuNewCustomer"), 2, $user->rights->societe->creer);
 | |
| 792 | +                $newmenu->add(BASE_URI."?controller=societe&method=card&leftmenu=customers&action=create&type=c", $langs->trans("MenuNewCustomer"), 2, $user->rights->societe->creer);
 | |
| 793 | 793 |  //$newmenu->add("/contact/list.php?leftmenu=customers&type=c", $langs->trans("Contacts"), 2, $user->rights->societe->contact->lire);
 | 
| 794 | 794 | } | 
| 795 | 795 | |
| @@ -798,8 +798,8 @@ discard block | ||
| 798 | 798 |                  $langs->load("suppliers");
 | 
| 799 | 799 |  //$newmenu->add("/societe/list.php?type=f&leftmenu=suppliers", $langs->trans("ListSuppliersShort"), 1, ($user->rights->fournisseur->lire || $user->rights->supplier_proposal->lire), '', $mainmenu, 'suppliers');
 | 
| 800 | 800 |  //$newmenu->add("/societe/card.php?leftmenu=suppliers&action=create&type=f", $langs->trans("MenuNewSupplier"), 2, $user->rights->societe->creer && ($user->rights->fournisseur->lire || $user->rights->supplier_proposal->lire));
 | 
| 801 | -                $newmenu->add(BASE_URI . "?controller=societe&method=list&type=f&leftmenu=suppliers", $langs->trans("ListSuppliersShort"), 1, ($user->rights->fournisseur->lire || $user->rights->supplier_proposal->lire), '', $mainmenu, 'suppliers');
 | |
| 802 | -                $newmenu->add(BASE_URI . "?controller=societe&method=card&leftmenu=suppliers&action=create&type=f", $langs->trans("MenuNewSupplier"), 2, $user->rights->societe->creer && ($user->rights->fournisseur->lire || $user->rights->supplier_proposal->lire));
 | |
| 801 | +                $newmenu->add(BASE_URI."?controller=societe&method=list&type=f&leftmenu=suppliers", $langs->trans("ListSuppliersShort"), 1, ($user->rights->fournisseur->lire || $user->rights->supplier_proposal->lire), '', $mainmenu, 'suppliers');
 | |
| 802 | +                $newmenu->add(BASE_URI."?controller=societe&method=card&leftmenu=suppliers&action=create&type=f", $langs->trans("MenuNewSupplier"), 2, $user->rights->societe->creer && ($user->rights->fournisseur->lire || $user->rights->supplier_proposal->lire));
 | |
| 803 | 803 | } | 
| 804 | 804 | |
| 805 | 805 | // Categories | 
| @@ -813,12 +813,12 @@ discard block | ||
| 813 | 813 | if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) | 
| 814 | 814 |                          $menutoshow = $langs->trans("ProspectsCategoriesShort");
 | 
| 815 | 815 |  //$newmenu->add("/categories/index.php?leftmenu=cat&type=2", $menutoshow, 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
 | 
| 816 | - $newmenu->add(BASE_URI . "?controller=categories&method=index&leftmenu=cat&type=2", $menutoshow, 1, $user->rights->categorie->lire, '', $mainmenu, 'cat'); | |
| 816 | + $newmenu->add(BASE_URI."?controller=categories&method=index&leftmenu=cat&type=2", $menutoshow, 1, $user->rights->categorie->lire, '', $mainmenu, 'cat'); | |
| 817 | 817 | } | 
| 818 | 818 | // Categories suppliers | 
| 819 | 819 |                  if (!empty($conf->fournisseur->enabled)) {
 | 
| 820 | 820 |  //$newmenu->add("/categories/index.php?leftmenu=catfournish&type=1", $langs->trans("SuppliersCategoriesShort"), 1, $user->rights->categorie->lire);
 | 
| 821 | -                    $newmenu->add(BASE_URI . "?controller=categories&method=index&leftmenu=catfournish&type=1", $langs->trans("SuppliersCategoriesShort"), 1, $user->rights->categorie->lire);
 | |
| 821 | +                    $newmenu->add(BASE_URI."?controller=categories&method=index&leftmenu=catfournish&type=1", $langs->trans("SuppliersCategoriesShort"), 1, $user->rights->categorie->lire);
 | |
| 822 | 822 | } | 
| 823 | 823 | } | 
| 824 | 824 | |
| @@ -826,30 +826,30 @@ discard block | ||
| 826 | 826 |  //$newmenu->add("/societe/index.php?leftmenu=thirdparties", (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")), 0, $user->rights->societe->contact->lire, '', $mainmenu, 'contacts');
 | 
| 827 | 827 |  //$newmenu->add("/contact/card.php?leftmenu=contacts&action=create", (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress")), 1, $user->rights->societe->contact->creer);
 | 
| 828 | 828 |  //$newmenu->add("/contact/list.php?leftmenu=contacts", $langs->trans("List"), 1, $user->rights->societe->contact->lire);
 | 
| 829 | -            $newmenu->add(BASE_URI . "?controller=societe&method=index&leftmenu=thirdparties", (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")), 0, $user->rights->societe->contact->lire, '', $mainmenu, 'contacts');
 | |
| 830 | -            $newmenu->add(BASE_URI . "?controller=contact&method=card&leftmenu=contacts&action=create", (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress")), 1, $user->rights->societe->contact->creer);
 | |
| 831 | -            $newmenu->add(BASE_URI . "?controller=contact&method=list&leftmenu=contacts", $langs->trans("List"), 1, $user->rights->societe->contact->lire);
 | |
| 829 | +            $newmenu->add(BASE_URI."?controller=societe&method=index&leftmenu=thirdparties", (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")), 0, $user->rights->societe->contact->lire, '', $mainmenu, 'contacts');
 | |
| 830 | +            $newmenu->add(BASE_URI."?controller=contact&method=card&leftmenu=contacts&action=create", (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress")), 1, $user->rights->societe->contact->creer);
 | |
| 831 | +            $newmenu->add(BASE_URI."?controller=contact&method=list&leftmenu=contacts", $langs->trans("List"), 1, $user->rights->societe->contact->lire);
 | |
| 832 | 832 |              if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
 | 
| 833 | 833 |  //$newmenu->add("/contact/list.php?leftmenu=contacts&type=p", $langs->trans("Prospects"), 2, $user->rights->societe->contact->lire);
 | 
| 834 | -                $newmenu->add(BASE_URI . "?controller=contact&method=list&leftmenu=contacts&type=p", $langs->trans("Prospects"), 2, $user->rights->societe->contact->lire);
 | |
| 834 | +                $newmenu->add(BASE_URI."?controller=contact&method=list&leftmenu=contacts&type=p", $langs->trans("Prospects"), 2, $user->rights->societe->contact->lire);
 | |
| 835 | 835 | } | 
| 836 | 836 |              if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
 | 
| 837 | 837 |  //$newmenu->add("/contact/list.php?leftmenu=contacts&type=c", $langs->trans("Customers"), 2, $user->rights->societe->contact->lire);
 | 
| 838 | -                $newmenu->add(BASE_URI . "?controller=contact&method=list&leftmenu=contacts&type=c", $langs->trans("Customers"), 2, $user->rights->societe->contact->lire);
 | |
| 838 | +                $newmenu->add(BASE_URI."?controller=contact&method=list&leftmenu=contacts&type=c", $langs->trans("Customers"), 2, $user->rights->societe->contact->lire);
 | |
| 839 | 839 | } | 
| 840 | 840 |              if (!empty($conf->fournisseur->enabled)) {
 | 
| 841 | 841 |  //$newmenu->add("/contact/list.php?leftmenu=contacts&type=f", $langs->trans("Suppliers"), 2, $user->rights->societe->contact->lire);
 | 
| 842 | -                $newmenu->add(BASE_URI . "?controller=contact&method=list&leftmenu=contacts&type=f", $langs->trans("Suppliers"), 2, $user->rights->societe->contact->lire);
 | |
| 842 | +                $newmenu->add(BASE_URI."?controller=contact&method=list&leftmenu=contacts&type=f", $langs->trans("Suppliers"), 2, $user->rights->societe->contact->lire);
 | |
| 843 | 843 | } | 
| 844 | 844 |  //$newmenu->add("/contact/list.php?leftmenu=contacts&type=o", $langs->trans("ContactOthers"), 2, $user->rights->societe->contact->lire);
 | 
| 845 | -            $newmenu->add(BASE_URI . "?controller=contact&methos=list&leftmenu=contacts&type=o", $langs->trans("ContactOthers"), 2, $user->rights->societe->contact->lire);
 | |
| 845 | +            $newmenu->add(BASE_URI."?controller=contact&methos=list&leftmenu=contacts&type=o", $langs->trans("ContactOthers"), 2, $user->rights->societe->contact->lire);
 | |
| 846 | 846 |  //$newmenu->add("/contact/list.php?userid=$user->id", $langs->trans("MyContacts"), 1, $user->rights->societe->contact->lire);
 | 
| 847 | 847 | // Categories | 
| 848 | 848 |              if (!empty($conf->categorie->enabled)) {
 | 
| 849 | 849 |                  $langs->load("categories");
 | 
| 850 | 850 | // Categories Contact | 
| 851 | 851 |  //$newmenu->add("/categories/index.php?leftmenu=catcontact&type=4", $langs->trans("ContactCategoriesShort"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
 | 
| 852 | -                $newmenu->add(BASE_URI . "?controller=categories&method=index&leftmenu=catcontact&type=4", $langs->trans("ContactCategoriesShort"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
 | |
| 852 | +                $newmenu->add(BASE_URI."?controller=categories&method=index&leftmenu=catcontact&type=4", $langs->trans("ContactCategoriesShort"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
 | |
| 853 | 853 | } | 
| 854 | 854 | } | 
| 855 | 855 | |
| @@ -865,9 +865,9 @@ discard block | ||
| 865 | 865 |  //$newmenu->add("/comm/propal/index.php?leftmenu=propals", $langs->trans("Proposals"), 0, $user->rights->propale->lire, '', $mainmenu, 'propals', 100);
 | 
| 866 | 866 |  //$newmenu->add("/comm/propal/card.php?action=create&leftmenu=propals", $langs->trans("NewPropal"), 1, $user->rights->propale->creer);
 | 
| 867 | 867 |  //$newmenu->add("/comm/propal/list.php?leftmenu=propals", $langs->trans("List"), 1, $user->rights->propale->lire);
 | 
| 868 | -                $newmenu->add(BASE_URI . "?controller=comm/propal&method=index&leftmenu=propals", $langs->trans("Proposals"), 0, $user->rights->propale->lire, '', $mainmenu, 'propals', 100);
 | |
| 869 | -                $newmenu->add(BASE_URI . "?controller=comm/propal&method=card&action=create&leftmenu=propals", $langs->trans("NewPropal"), 1, $user->rights->propale->creer);
 | |
| 870 | -                $newmenu->add(BASE_URI . "?controller=comm/propal&method=list&leftmenu=propals", $langs->trans("List"), 1, $user->rights->propale->lire);
 | |
| 868 | +                $newmenu->add(BASE_URI."?controller=comm/propal&method=index&leftmenu=propals", $langs->trans("Proposals"), 0, $user->rights->propale->lire, '', $mainmenu, 'propals', 100);
 | |
| 869 | +                $newmenu->add(BASE_URI."?controller=comm/propal&method=card&action=create&leftmenu=propals", $langs->trans("NewPropal"), 1, $user->rights->propale->creer);
 | |
| 870 | +                $newmenu->add(BASE_URI."?controller=comm/propal&method=list&leftmenu=propals", $langs->trans("List"), 1, $user->rights->propale->lire);
 | |
| 871 | 871 |                  if ($usemenuhider || empty($leftmenu) || $leftmenu == "propals") {
 | 
| 872 | 872 | /* | 
| 873 | 873 |                        $newmenu->add("/comm/propal/list.php?leftmenu=propals&viewstatut=0", $langs->trans("PropalsDraft"), 2, $user->rights->propale->lire);
 | 
| @@ -876,15 +876,15 @@ discard block | ||
| 876 | 876 |                        $newmenu->add("/comm/propal/list.php?leftmenu=propals&viewstatut=3", $langs->trans("PropalStatusNotSigned"), 2, $user->rights->propale->lire);
 | 
| 877 | 877 |                        $newmenu->add("/comm/propal/list.php?leftmenu=propals&viewstatut=4", $langs->trans("PropalStatusBilled"), 2, $user->rights->propale->lire);
 | 
| 878 | 878 | */ | 
| 879 | -                    $newmenu->add(BASE_URI . "?controller=comm/propal&method=list&leftmenu=propals&viewstatut=0", $langs->trans("PropalsDraft"), 2, $user->rights->propale->lire);
 | |
| 880 | -                    $newmenu->add(BASE_URI . "?controller=comm/propal&method=list&leftmenu=propals&viewstatut=1", $langs->trans("PropalsOpened"), 2, $user->rights->propale->lire);
 | |
| 881 | -                    $newmenu->add(BASE_URI . "?controller=comm/propal&method=list&leftmenu=propals&viewstatut=2", $langs->trans("PropalStatusSigned"), 2, $user->rights->propale->lire);
 | |
| 882 | -                    $newmenu->add(BASE_URI . "?controller=comm/propal&method=list&leftmenu=propals&viewstatut=3", $langs->trans("PropalStatusNotSigned"), 2, $user->rights->propale->lire);
 | |
| 883 | -                    $newmenu->add(BASE_URI . "?controller=comm/propal&method=list&leftmenu=propals&viewstatut=4", $langs->trans("PropalStatusBilled"), 2, $user->rights->propale->lire);
 | |
| 879 | +                    $newmenu->add(BASE_URI."?controller=comm/propal&method=list&leftmenu=propals&viewstatut=0", $langs->trans("PropalsDraft"), 2, $user->rights->propale->lire);
 | |
| 880 | +                    $newmenu->add(BASE_URI."?controller=comm/propal&method=list&leftmenu=propals&viewstatut=1", $langs->trans("PropalsOpened"), 2, $user->rights->propale->lire);
 | |
| 881 | +                    $newmenu->add(BASE_URI."?controller=comm/propal&method=list&leftmenu=propals&viewstatut=2", $langs->trans("PropalStatusSigned"), 2, $user->rights->propale->lire);
 | |
| 882 | +                    $newmenu->add(BASE_URI."?controller=comm/propal&method=list&leftmenu=propals&viewstatut=3", $langs->trans("PropalStatusNotSigned"), 2, $user->rights->propale->lire);
 | |
| 883 | +                    $newmenu->add(BASE_URI."?controller=comm/propal&method=list&leftmenu=propals&viewstatut=4", $langs->trans("PropalStatusBilled"), 2, $user->rights->propale->lire);
 | |
| 884 | 884 |  //$newmenu->add("/comm/propal/list.php?leftmenu=propals&viewstatut=2,3,4", $langs->trans("PropalStatusClosedShort"), 2, $user->rights->propale->lire);
 | 
| 885 | 885 | } | 
| 886 | 886 |  //$newmenu->add("/comm/propal/stats/index.php?leftmenu=propals", $langs->trans("Statistics"), 1, $user->rights->propale->lire);
 | 
| 887 | -                $newmenu->add(BASE_URI . "?controller=comm/propal/stats&method=index&leftmenu=propals", $langs->trans("Statistics"), 1, $user->rights->propale->lire);
 | |
| 887 | +                $newmenu->add(BASE_URI."?controller=comm/propal/stats&method=index&leftmenu=propals", $langs->trans("Statistics"), 1, $user->rights->propale->lire);
 | |
| 888 | 888 | } | 
| 889 | 889 | |
| 890 | 890 | // Customers orders | 
| @@ -893,26 +893,26 @@ discard block | ||
| 893 | 893 |  //$newmenu->add("/commande/index.php?leftmenu=orders", $langs->trans("CustomersOrders"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders', 200);
 | 
| 894 | 894 |  //$newmenu->add("/commande/card.php?action=create&leftmenu=orders", $langs->trans("NewOrder"), 1, $user->rights->commande->creer);
 | 
| 895 | 895 |  //$newmenu->add("/commande/list.php?leftmenu=orders", $langs->trans("List"), 1, $user->rights->commande->lire);
 | 
| 896 | -                $newmenu->add(BASE_URI . "?controller=commande&method=index&leftmenu=orders", $langs->trans("CustomersOrders"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders', 200);
 | |
| 897 | -                $newmenu->add(BASE_URI . "?controller=commande&method=card&action=create&leftmenu=orders", $langs->trans("NewOrder"), 1, $user->rights->commande->creer);
 | |
| 898 | -                $newmenu->add(BASE_URI . "?controller=commande&method=list&leftmenu=orders", $langs->trans("List"), 1, $user->rights->commande->lire);
 | |
| 896 | +                $newmenu->add(BASE_URI."?controller=commande&method=index&leftmenu=orders", $langs->trans("CustomersOrders"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders', 200);
 | |
| 897 | +                $newmenu->add(BASE_URI."?controller=commande&method=card&action=create&leftmenu=orders", $langs->trans("NewOrder"), 1, $user->rights->commande->creer);
 | |
| 898 | +                $newmenu->add(BASE_URI."?controller=commande&method=list&leftmenu=orders", $langs->trans("List"), 1, $user->rights->commande->lire);
 | |
| 899 | 899 |                  if ($usemenuhider || empty($leftmenu) || $leftmenu == "orders") {
 | 
| 900 | 900 |  //$newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=0", $langs->trans("StatusOrderDraftShort"), 2, $user->rights->commande->lire);
 | 
| 901 | 901 |  //$newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=1", $langs->trans("StatusOrderValidated"), 2, $user->rights->commande->lire);
 | 
| 902 | -                    $newmenu->add(BASE_URI . "?controller=commande&method=list&leftmenu=orders&viewstatut=0", $langs->trans("StatusOrderDraftShort"), 2, $user->rights->commande->lire);
 | |
| 903 | -                    $newmenu->add(BASE_URI . "?controller=commande&method=list&leftmenu=orders&viewstatut=1", $langs->trans("StatusOrderValidated"), 2, $user->rights->commande->lire);
 | |
| 902 | +                    $newmenu->add(BASE_URI."?controller=commande&method=list&leftmenu=orders&viewstatut=0", $langs->trans("StatusOrderDraftShort"), 2, $user->rights->commande->lire);
 | |
| 903 | +                    $newmenu->add(BASE_URI."?controller=commande&method=list&leftmenu=orders&viewstatut=1", $langs->trans("StatusOrderValidated"), 2, $user->rights->commande->lire);
 | |
| 904 | 904 |                      if (!empty($conf->expedition->enabled)) {
 | 
| 905 | 905 |  //$newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=2", $langs->trans("StatusOrderSentShort"), 2, $user->rights->commande->lire);
 | 
| 906 | -                        $newmenu->add(BASE_URI . "?controller=commande&method=list&leftmenu=orders&viewstatut=2", $langs->trans("StatusOrderSentShort"), 2, $user->rights->commande->lire);
 | |
| 906 | +                        $newmenu->add(BASE_URI."?controller=commande&method=list&leftmenu=orders&viewstatut=2", $langs->trans("StatusOrderSentShort"), 2, $user->rights->commande->lire);
 | |
| 907 | 907 | } | 
| 908 | 908 |  //$newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=3", $langs->trans("StatusOrderDelivered"), 2, $user->rights->commande->lire);
 | 
| 909 | -                    $newmenu->add(BASE_URI . "?controller=commande&method=list&leftmenu=orders&viewstatut=3", $langs->trans("StatusOrderDelivered"), 2, $user->rights->commande->lire);
 | |
| 909 | +                    $newmenu->add(BASE_URI."?controller=commande&method=list&leftmenu=orders&viewstatut=3", $langs->trans("StatusOrderDelivered"), 2, $user->rights->commande->lire);
 | |
| 910 | 910 |  //$newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=4", $langs->trans("StatusOrderProcessed"), 2, $user->rights->commande->lire);
 | 
| 911 | 911 |  //$newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=-1", $langs->trans("StatusOrderCanceledShort"), 2, $user->rights->commande->lire);
 | 
| 912 | -                    $newmenu->add(BASE_URI . "?controller=commande&method=list&leftmenu=orders&viewstatut=-1", $langs->trans("StatusOrderCanceledShort"), 2, $user->rights->commande->lire);
 | |
| 912 | +                    $newmenu->add(BASE_URI."?controller=commande&method=list&leftmenu=orders&viewstatut=-1", $langs->trans("StatusOrderCanceledShort"), 2, $user->rights->commande->lire);
 | |
| 913 | 913 | } | 
| 914 | 914 |  //$newmenu->add("/commande/stats/index.php?leftmenu=orders", $langs->trans("Statistics"), 1, $user->rights->commande->lire);
 | 
| 915 | -                $newmenu->add(BASE_URI . "?controller=commande/stats&method=index&leftmenu=orders", $langs->trans("Statistics"), 1, $user->rights->commande->lire);
 | |
| 915 | +                $newmenu->add(BASE_URI."?controller=commande/stats&method=index&leftmenu=orders", $langs->trans("Statistics"), 1, $user->rights->commande->lire);
 | |
| 916 | 916 | } | 
| 917 | 917 | |
| 918 | 918 | // Suppliers orders | 
| @@ -921,16 +921,16 @@ discard block | ||
| 921 | 921 |  //$newmenu->add("/fourn/commande/index.php?leftmenu=orders_suppliers", $langs->trans("SuppliersOrders"), 0, $user->rights->fournisseur->commande->lire, '', $mainmenu, 'orders_suppliers', 400);
 | 
| 922 | 922 |  //$newmenu->add("/fourn/commande/card.php?action=create&leftmenu=orders_suppliers", $langs->trans("NewOrder"), 1, $user->rights->fournisseur->commande->creer);
 | 
| 923 | 923 |  //$newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers", $langs->trans("List"), 1, $user->rights->fournisseur->commande->lire);
 | 
| 924 | -                $newmenu->add(BASE_URI . "?controller=fourn/commande&method=index&leftmenu=orders_suppliers", $langs->trans("SuppliersOrders"), 0, $user->rights->fournisseur->commande->lire, '', $mainmenu, 'orders_suppliers', 400);
 | |
| 925 | -                $newmenu->add(BASE_URI . "?controller=fourn/commande&method=card&action=create&leftmenu=orders_suppliers", $langs->trans("NewOrder"), 1, $user->rights->fournisseur->commande->creer);
 | |
| 926 | -                $newmenu->add(BASE_URI . "?controller=fourn/commande&method=list&leftmenu=orders_suppliers", $langs->trans("List"), 1, $user->rights->fournisseur->commande->lire);
 | |
| 924 | +                $newmenu->add(BASE_URI."?controller=fourn/commande&method=index&leftmenu=orders_suppliers", $langs->trans("SuppliersOrders"), 0, $user->rights->fournisseur->commande->lire, '', $mainmenu, 'orders_suppliers', 400);
 | |
| 925 | +                $newmenu->add(BASE_URI."?controller=fourn/commande&method=card&action=create&leftmenu=orders_suppliers", $langs->trans("NewOrder"), 1, $user->rights->fournisseur->commande->creer);
 | |
| 926 | +                $newmenu->add(BASE_URI."?controller=fourn/commande&method=list&leftmenu=orders_suppliers", $langs->trans("List"), 1, $user->rights->fournisseur->commande->lire);
 | |
| 927 | 927 | |
| 928 | 928 |                  if ($usemenuhider || empty($leftmenu) || $leftmenu == "orders_suppliers") {
 | 
| 929 | 929 |  //$newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=0", $langs->trans("StatusOrderDraftShort"), 2, $user->rights->fournisseur->commande->lire);
 | 
| 930 | -                    $newmenu->add(BASE_URI . "?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=0", $langs->trans("StatusOrderDraftShort"), 2, $user->rights->fournisseur->commande->lire);
 | |
| 930 | +                    $newmenu->add(BASE_URI."?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=0", $langs->trans("StatusOrderDraftShort"), 2, $user->rights->fournisseur->commande->lire);
 | |
| 931 | 931 |                      if (empty($conf->global->SUPPLIER_ORDER_HIDE_VALIDATED)) {
 | 
| 932 | 932 |  //$newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=1", $langs->trans("StatusOrderValidated"), 2, $user->rights->fournisseur->commande->lire);
 | 
| 933 | -                        $newmenu->add(BASE_URI . "?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=1", $langs->trans("StatusOrderValidated"), 2, $user->rights->fournisseur->commande->lire);
 | |
| 933 | +                        $newmenu->add(BASE_URI."?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=1", $langs->trans("StatusOrderValidated"), 2, $user->rights->fournisseur->commande->lire);
 | |
| 934 | 934 | } | 
| 935 | 935 | /* | 
| 936 | 936 |                        $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=2", $langs->trans("StatusOrderApprovedShort"), 2, $user->rights->fournisseur->commande->lire);
 | 
| @@ -940,16 +940,16 @@ discard block | ||
| 940 | 940 |                        $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=6,7", $langs->trans("StatusOrderCanceled"), 2, $user->rights->fournisseur->commande->lire);
 | 
| 941 | 941 |                        $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=9", $langs->trans("StatusOrderRefused"), 2, $user->rights->fournisseur->commande->lire);
 | 
| 942 | 942 | */ | 
| 943 | -                    $newmenu->add(BASE_URI . "?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=2", $langs->trans("StatusOrderApprovedShort"), 2, $user->rights->fournisseur->commande->lire);
 | |
| 944 | -                    $newmenu->add(BASE_URI . "?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=3", $langs->trans("StatusOrderOnProcessShort"), 2, $user->rights->fournisseur->commande->lire);
 | |
| 945 | -                    $newmenu->add(BASE_URI . "?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=4", $langs->trans("StatusOrderReceivedPartiallyShort"), 2, $user->rights->fournisseur->commande->lire);
 | |
| 946 | -                    $newmenu->add(BASE_URI . "?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=5", $langs->trans("StatusOrderReceivedAll"), 2, $user->rights->fournisseur->commande->lire);
 | |
| 947 | -                    $newmenu->add(BASE_URI . "?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=6,7", $langs->trans("StatusOrderCanceled"), 2, $user->rights->fournisseur->commande->lire);
 | |
| 948 | -                    $newmenu->add(BASE_URI . "?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=9", $langs->trans("StatusOrderRefused"), 2, $user->rights->fournisseur->commande->lire);
 | |
| 943 | +                    $newmenu->add(BASE_URI."?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=2", $langs->trans("StatusOrderApprovedShort"), 2, $user->rights->fournisseur->commande->lire);
 | |
| 944 | +                    $newmenu->add(BASE_URI."?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=3", $langs->trans("StatusOrderOnProcessShort"), 2, $user->rights->fournisseur->commande->lire);
 | |
| 945 | +                    $newmenu->add(BASE_URI."?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=4", $langs->trans("StatusOrderReceivedPartiallyShort"), 2, $user->rights->fournisseur->commande->lire);
 | |
| 946 | +                    $newmenu->add(BASE_URI."?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=5", $langs->trans("StatusOrderReceivedAll"), 2, $user->rights->fournisseur->commande->lire);
 | |
| 947 | +                    $newmenu->add(BASE_URI."?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=6,7", $langs->trans("StatusOrderCanceled"), 2, $user->rights->fournisseur->commande->lire);
 | |
| 948 | +                    $newmenu->add(BASE_URI."?controller=fourn/commande&method=list&leftmenu=orders_suppliers&statut=9", $langs->trans("StatusOrderRefused"), 2, $user->rights->fournisseur->commande->lire);
 | |
| 949 | 949 | } | 
| 950 | 950 |  // Billed is another field. We should add instead a dedicated filter on list. if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders_suppliers") $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&billed=1", $langs->trans("StatusOrderBilled"), 2, $user->rights->fournisseur->commande->lire);
 | 
| 951 | 951 |  //$newmenu->add("/commande/stats/index.php?leftmenu=orders_suppliers&mode=supplier", $langs->trans("Statistics"), 1, $user->rights->fournisseur->commande->lire);
 | 
| 952 | -                $newmenu->add(BASE_URI . "?controller=commande/stats&method=index&leftmenu=orders_suppliers&mode=supplier", $langs->trans("Statistics"), 1, $user->rights->fournisseur->commande->lire);
 | |
| 952 | +                $newmenu->add(BASE_URI."?controller=commande/stats&method=index&leftmenu=orders_suppliers&mode=supplier", $langs->trans("Statistics"), 1, $user->rights->fournisseur->commande->lire);
 | |
| 953 | 953 | } | 
| 954 | 954 | |
| 955 | 955 | // Contrat | 
| @@ -961,10 +961,10 @@ discard block | ||
| 961 | 961 |                    $newmenu->add("/contrat/list.php?leftmenu=contracts", $langs->trans("List"), 1, $user->rights->contrat->lire);
 | 
| 962 | 962 |                    $newmenu->add("/contrat/services_list.php?leftmenu=contracts", $langs->trans("MenuServices"), 1, $user->rights->contrat->lire);
 | 
| 963 | 963 | */ | 
| 964 | -                $newmenu->add(BASE_URI . "?controller=contrat&method=index&leftmenu=contracts", $langs->trans("ContractsSubscriptions"), 0, $user->rights->contrat->lire, '', $mainmenu, 'contracts', 2000);
 | |
| 965 | -                $newmenu->add(BASE_URI . "?controller=contrat&method=card&action=create&leftmenu=contracts", $langs->trans("NewContractSubscription"), 1, $user->rights->contrat->creer);
 | |
| 966 | -                $newmenu->add(BASE_URI . "?controller=contrat&method=list&leftmenu=contracts", $langs->trans("List"), 1, $user->rights->contrat->lire);
 | |
| 967 | -                $newmenu->add(BASE_URI . "?controller=contrat&method=services_list&leftmenu=contracts", $langs->trans("MenuServices"), 1, $user->rights->contrat->lire);
 | |
| 964 | +                $newmenu->add(BASE_URI."?controller=contrat&method=index&leftmenu=contracts", $langs->trans("ContractsSubscriptions"), 0, $user->rights->contrat->lire, '', $mainmenu, 'contracts', 2000);
 | |
| 965 | +                $newmenu->add(BASE_URI."?controller=contrat&method=card&action=create&leftmenu=contracts", $langs->trans("NewContractSubscription"), 1, $user->rights->contrat->creer);
 | |
| 966 | +                $newmenu->add(BASE_URI."?controller=contrat&method=list&leftmenu=contracts", $langs->trans("List"), 1, $user->rights->contrat->lire);
 | |
| 967 | +                $newmenu->add(BASE_URI."?controller=contrat&method=services_list&leftmenu=contracts", $langs->trans("MenuServices"), 1, $user->rights->contrat->lire);
 | |
| 968 | 968 |                  if ($usemenuhider || empty($leftmenu) || $leftmenu == "contracts") {
 | 
| 969 | 969 | /* | 
| 970 | 970 |                        $newmenu->add("/contrat/services_list.php?leftmenu=contracts&mode=0", $langs->trans("MenuInactiveServices"), 2, $user->rights->contrat->lire);
 | 
| @@ -972,10 +972,10 @@ discard block | ||
| 972 | 972 |                        $newmenu->add("/contrat/services_list.php?leftmenu=contracts&mode=4&filter=expired", $langs->trans("MenuExpiredServices"), 2, $user->rights->contrat->lire);
 | 
| 973 | 973 |                        $newmenu->add("/contrat/services_list.php?leftmenu=contracts&mode=5", $langs->trans("MenuClosedServices"), 2, $user->rights->contrat->lire);
 | 
| 974 | 974 | */ | 
| 975 | -                    $newmenu->add(BASE_URI . "?controller=contrat&method=services_list&leftmenu=contracts&mode=0", $langs->trans("MenuInactiveServices"), 2, $user->rights->contrat->lire);
 | |
| 976 | -                    $newmenu->add(BASE_URI . "?controller=contrat&method=services_list&leftmenu=contracts&mode=4", $langs->trans("MenuRunningServices"), 2, $user->rights->contrat->lire);
 | |
| 977 | -                    $newmenu->add(BASE_URI . "?controller=contrat&method=services_list&leftmenu=contracts&mode=4&filter=expired", $langs->trans("MenuExpiredServices"), 2, $user->rights->contrat->lire);
 | |
| 978 | -                    $newmenu->add(BASE_URI . "?controller=contrat&method=services_list&leftmenu=contracts&mode=5", $langs->trans("MenuClosedServices"), 2, $user->rights->contrat->lire);
 | |
| 975 | +                    $newmenu->add(BASE_URI."?controller=contrat&method=services_list&leftmenu=contracts&mode=0", $langs->trans("MenuInactiveServices"), 2, $user->rights->contrat->lire);
 | |
| 976 | +                    $newmenu->add(BASE_URI."?controller=contrat&method=services_list&leftmenu=contracts&mode=4", $langs->trans("MenuRunningServices"), 2, $user->rights->contrat->lire);
 | |
| 977 | +                    $newmenu->add(BASE_URI."?controller=contrat&method=services_list&leftmenu=contracts&mode=4&filter=expired", $langs->trans("MenuExpiredServices"), 2, $user->rights->contrat->lire);
 | |
| 978 | +                    $newmenu->add(BASE_URI."?controller=contrat&method=services_list&leftmenu=contracts&mode=5", $langs->trans("MenuClosedServices"), 2, $user->rights->contrat->lire);
 | |
| 979 | 979 | } | 
| 980 | 980 | } | 
| 981 | 981 | |
| @@ -989,11 +989,11 @@ discard block | ||
| 989 | 989 |                    $newmenu->add("/fichinter/card-red.php?leftmenu=ficheinter", $langs->trans("ModelList"), 1, $user->rights->ficheinter->lire, '', '', '', 203);
 | 
| 990 | 990 |                    $newmenu->add("/fichinter/stats/index.php?leftmenu=ficheinter", $langs->trans("Statistics"), 1, $user->rights->fournisseur->commande->lire);
 | 
| 991 | 991 | */ | 
| 992 | -                $newmenu->add(BASE_URI . "?controller=fichinter&method=index&leftmenu=ficheinter", $langs->trans("Interventions"), 0, $user->rights->ficheinter->lire, '', $mainmenu, 'ficheinter', 2200);
 | |
| 993 | -                $newmenu->add(BASE_URI . "?controller=fichinter&method=card&action=create&leftmenu=ficheinter", $langs->trans("NewIntervention"), 1, $user->rights->ficheinter->creer, '', '', '', 201);
 | |
| 994 | -                $newmenu->add(BASE_URI . "?controller=fichinter&method=list&leftmenu=ficheinter", $langs->trans("List"), 1, $user->rights->ficheinter->lire, '', '', '', 202);
 | |
| 995 | -                $newmenu->add(BASE_URI . "?controller=fichinter&method=card-red&leftmenu=ficheinter", $langs->trans("ModelList"), 1, $user->rights->ficheinter->lire, '', '', '', 203);
 | |
| 996 | -                $newmenu->add(BASE_URI . "?controller=fichinter/stats&method=index&leftmenu=ficheinter", $langs->trans("Statistics"), 1, $user->rights->fournisseur->commande->lire);
 | |
| 992 | +                $newmenu->add(BASE_URI."?controller=fichinter&method=index&leftmenu=ficheinter", $langs->trans("Interventions"), 0, $user->rights->ficheinter->lire, '', $mainmenu, 'ficheinter', 2200);
 | |
| 993 | +                $newmenu->add(BASE_URI."?controller=fichinter&method=card&action=create&leftmenu=ficheinter", $langs->trans("NewIntervention"), 1, $user->rights->ficheinter->creer, '', '', '', 201);
 | |
| 994 | +                $newmenu->add(BASE_URI."?controller=fichinter&method=list&leftmenu=ficheinter", $langs->trans("List"), 1, $user->rights->ficheinter->lire, '', '', '', 202);
 | |
| 995 | +                $newmenu->add(BASE_URI."?controller=fichinter&method=card-red&leftmenu=ficheinter", $langs->trans("ModelList"), 1, $user->rights->ficheinter->lire, '', '', '', 203);
 | |
| 996 | +                $newmenu->add(BASE_URI."?controller=fichinter/stats&method=index&leftmenu=ficheinter", $langs->trans("Statistics"), 1, $user->rights->fournisseur->commande->lire);
 | |
| 997 | 997 | } | 
| 998 | 998 | } | 
| 999 | 999 | |
| @@ -1011,9 +1011,9 @@ discard block | ||
| 1011 | 1011 |                    $newmenu->add("/compta/facture/card.php?action=create", $langs->trans("NewBill"), 1, $user->rights->facture->creer);
 | 
| 1012 | 1012 |                    $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills", $langs->trans("List"), 1, $user->rights->facture->lire, '', $mainmenu, 'customers_bills_list');
 | 
| 1013 | 1013 | */ | 
| 1014 | -                $newmenu->add(BASE_URI . "?controller=compta/facture&method=list&leftmenu=customers_bills", $langs->trans("BillsCustomers"), 0, $user->rights->facture->lire, '', $mainmenu, 'customers_bills');
 | |
| 1015 | -                $newmenu->add(BASE_URI . "?controller=compta/facture&method=card&action=create", $langs->trans("NewBill"), 1, $user->rights->facture->creer);
 | |
| 1016 | -                $newmenu->add(BASE_URI . "?controller=compta/facture&method=list&leftmenu=customers_bills", $langs->trans("List"), 1, $user->rights->facture->lire, '', $mainmenu, 'customers_bills_list');
 | |
| 1014 | +                $newmenu->add(BASE_URI."?controller=compta/facture&method=list&leftmenu=customers_bills", $langs->trans("BillsCustomers"), 0, $user->rights->facture->lire, '', $mainmenu, 'customers_bills');
 | |
| 1015 | +                $newmenu->add(BASE_URI."?controller=compta/facture&method=card&action=create", $langs->trans("NewBill"), 1, $user->rights->facture->creer);
 | |
| 1016 | +                $newmenu->add(BASE_URI."?controller=compta/facture&method=list&leftmenu=customers_bills", $langs->trans("List"), 1, $user->rights->facture->lire, '', $mainmenu, 'customers_bills_list');
 | |
| 1017 | 1017 | |
| 1018 | 1018 |                  if ($usemenuhider || empty($leftmenu) || preg_match('/customers_bills(|_draft|_notpaid|_paid|_canceled)$/', $leftmenu)) {
 | 
| 1019 | 1019 | /* | 
| @@ -1022,24 +1022,24 @@ discard block | ||
| 1022 | 1022 |                        $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_paid&search_status=2", $langs->trans("BillShortStatusPaid"), 2, $user->rights->facture->lire);
 | 
| 1023 | 1023 |                        $newmenu->add("/compta/facture/list.php?leftmenu=customers_bills_canceled&search_status=3", $langs->trans("BillShortStatusCanceled"), 2, $user->rights->facture->lire);
 | 
| 1024 | 1024 | */ | 
| 1025 | -                    $newmenu->add(BASE_URI . "?controller=compta/facture&method=list&leftmenu=customers_bills_draft&search_status=0", $langs->trans("BillShortStatusDraft"), 2, $user->rights->facture->lire);
 | |
| 1026 | -                    $newmenu->add(BASE_URI . "?controller=compta/facture&method=list&leftmenu=customers_bills_notpaid&search_status=1", $langs->trans("BillShortStatusNotPaid"), 2, $user->rights->facture->lire);
 | |
| 1027 | -                    $newmenu->add(BASE_URI . "?controller=compta/facture&method=list&leftmenu=customers_bills_paid&search_status=2", $langs->trans("BillShortStatusPaid"), 2, $user->rights->facture->lire);
 | |
| 1028 | -                    $newmenu->add(BASE_URI . "?controller=compta/facture&method=list&leftmenu=customers_bills_canceled&search_status=3", $langs->trans("BillShortStatusCanceled"), 2, $user->rights->facture->lire);
 | |
| 1025 | +                    $newmenu->add(BASE_URI."?controller=compta/facture&method=list&leftmenu=customers_bills_draft&search_status=0", $langs->trans("BillShortStatusDraft"), 2, $user->rights->facture->lire);
 | |
| 1026 | +                    $newmenu->add(BASE_URI."?controller=compta/facture&method=list&leftmenu=customers_bills_notpaid&search_status=1", $langs->trans("BillShortStatusNotPaid"), 2, $user->rights->facture->lire);
 | |
| 1027 | +                    $newmenu->add(BASE_URI."?controller=compta/facture&method=list&leftmenu=customers_bills_paid&search_status=2", $langs->trans("BillShortStatusPaid"), 2, $user->rights->facture->lire);
 | |
| 1028 | +                    $newmenu->add(BASE_URI."?controller=compta/facture&method=list&leftmenu=customers_bills_canceled&search_status=3", $langs->trans("BillShortStatusCanceled"), 2, $user->rights->facture->lire);
 | |
| 1029 | 1029 | } | 
| 1030 | 1030 |  //$newmenu->add("/compta/facture/invoicetemplate_list.php?leftmenu=customers_bills_templates", $langs->trans("ListOfTemplates"), 1, $user->rights->facture->creer, '', $mainmenu, 'customers_bills_templates');    // No need to see recurring invoices, if user has no permission to create invoice.
 | 
| 1031 | 1031 |  //$newmenu->add("/compta/paiement/list.php?leftmenu=customers_bills_payment", $langs->trans("Payments"), 1, $user->rights->facture->lire, '', $mainmenu, 'customers_bills_payment');
 | 
| 1032 | -                $newmenu->add(BASE_URI . "?controller=compta/facture&method=invoicetemplate_list&leftmenu=customers_bills_templates", $langs->trans("ListOfTemplates"), 1, $user->rights->facture->creer, '', $mainmenu, 'customers_bills_templates');    // No need to see recurring invoices, if user has no permission to create invoice.
 | |
| 1033 | -                $newmenu->add(BASE_URI . "?controller=compta/paiement&method=list&leftmenu=customers_bills_payment", $langs->trans("Payments"), 1, $user->rights->facture->lire, '', $mainmenu, 'customers_bills_payment');
 | |
| 1032 | +                $newmenu->add(BASE_URI."?controller=compta/facture&method=invoicetemplate_list&leftmenu=customers_bills_templates", $langs->trans("ListOfTemplates"), 1, $user->rights->facture->creer, '', $mainmenu, 'customers_bills_templates'); // No need to see recurring invoices, if user has no permission to create invoice.
 | |
| 1033 | +                $newmenu->add(BASE_URI."?controller=compta/paiement&method=list&leftmenu=customers_bills_payment", $langs->trans("Payments"), 1, $user->rights->facture->lire, '', $mainmenu, 'customers_bills_payment');
 | |
| 1034 | 1034 | |
| 1035 | 1035 |                  if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) {
 | 
| 1036 | 1036 |  //$newmenu->add("/compta/paiement/tovalidate.php?leftmenu=customers_bills_tovalid", $langs->trans("MenuToValid"), 2, $user->rights->facture->lire, '', $mainmenu, 'customer_bills_tovalid');
 | 
| 1037 | -                    $newmenu->add(BASE_URI . "?controller=compta/paiement&method=tovalidate&leftmenu=customers_bills_tovalid", $langs->trans("MenuToValid"), 2, $user->rights->facture->lire, '', $mainmenu, 'customer_bills_tovalid');
 | |
| 1037 | +                    $newmenu->add(BASE_URI."?controller=compta/paiement&method=tovalidate&leftmenu=customers_bills_tovalid", $langs->trans("MenuToValid"), 2, $user->rights->facture->lire, '', $mainmenu, 'customer_bills_tovalid');
 | |
| 1038 | 1038 | } | 
| 1039 | 1039 |  //$newmenu->add("/compta/paiement/rapport.php?leftmenu=customers_bills_reports", $langs->trans("Reportings"), 2, $user->rights->facture->lire, '', $mainmenu, 'customers_bills_reports');
 | 
| 1040 | 1040 |  //$newmenu->add("/compta/facture/stats/index.php?leftmenu=customers_bills_stats", $langs->trans("Statistics"), 1, $user->rights->facture->lire, '', $mainmenu, 'customers_bills_stats');
 | 
| 1041 | -                $newmenu->add(BASE_URI . "?controller=compta/paiement&method=rapport&leftmenu=customers_bills_reports", $langs->trans("Reportings"), 2, $user->rights->facture->lire, '', $mainmenu, 'customers_bills_reports');
 | |
| 1042 | -                $newmenu->add(BASE_URI . "?controller=compta/facture/stats&method=index&leftmenu=customers_bills_stats", $langs->trans("Statistics"), 1, $user->rights->facture->lire, '', $mainmenu, 'customers_bills_stats');
 | |
| 1041 | +                $newmenu->add(BASE_URI."?controller=compta/paiement&method=rapport&leftmenu=customers_bills_reports", $langs->trans("Reportings"), 2, $user->rights->facture->lire, '', $mainmenu, 'customers_bills_reports');
 | |
| 1042 | +                $newmenu->add(BASE_URI."?controller=compta/facture/stats&method=index&leftmenu=customers_bills_stats", $langs->trans("Statistics"), 1, $user->rights->facture->lire, '', $mainmenu, 'customers_bills_stats');
 | |
| 1043 | 1043 | } | 
| 1044 | 1044 | |
| 1045 | 1045 | // Suppliers invoices | 
| @@ -1048,25 +1048,25 @@ discard block | ||
| 1048 | 1048 |  //$newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("BillsSuppliers"), 0, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills');
 | 
| 1049 | 1049 |  //$newmenu->add("/fourn/facture/card.php?leftmenu=suppliers_bills&action=create", $langs->trans("NewBill"), 1, $user->rights->fournisseur->facture->creer, '', $mainmenu, 'suppliers_bills_create');
 | 
| 1050 | 1050 |  //$newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("List"), 1, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_list');
 | 
| 1051 | -                $newmenu->add(BASE_URI . "?controller=fourn/facture&method=list&leftmenu=suppliers_bills", $langs->trans("BillsSuppliers"), 0, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills');
 | |
| 1052 | -                $newmenu->add(BASE_URI . "?controller=fourn/facture&method=card&leftmenu=suppliers_bills&action=create", $langs->trans("NewBill"), 1, $user->rights->fournisseur->facture->creer, '', $mainmenu, 'suppliers_bills_create');
 | |
| 1053 | -                $newmenu->add(BASE_URI . "?controller=fourn/facture&method=list&leftmenu=suppliers_bills", $langs->trans("List"), 1, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_list');
 | |
| 1051 | +                $newmenu->add(BASE_URI."?controller=fourn/facture&method=list&leftmenu=suppliers_bills", $langs->trans("BillsSuppliers"), 0, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills');
 | |
| 1052 | +                $newmenu->add(BASE_URI."?controller=fourn/facture&method=card&leftmenu=suppliers_bills&action=create", $langs->trans("NewBill"), 1, $user->rights->fournisseur->facture->creer, '', $mainmenu, 'suppliers_bills_create');
 | |
| 1053 | +                $newmenu->add(BASE_URI."?controller=fourn/facture&method=list&leftmenu=suppliers_bills", $langs->trans("List"), 1, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_list');
 | |
| 1054 | 1054 | |
| 1055 | 1055 |                  if ($usemenuhider || empty($leftmenu) || preg_match('/suppliers_bills/', $leftmenu)) {
 | 
| 1056 | 1056 |  //$newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills_draft&search_status=0", $langs->trans("BillShortStatusDraft"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_draft');
 | 
| 1057 | 1057 |  //$newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills_notpaid&search_status=1", $langs->trans("BillShortStatusNotPaid"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_notpaid');
 | 
| 1058 | 1058 |  //$newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills_paid&search_status=2", $langs->trans("BillShortStatusPaid"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_paid');
 | 
| 1059 | -                    $newmenu->add(BASE_URI . "?controller=fourn/facture&method=list&leftmenu=suppliers_bills_draft&search_status=0", $langs->trans("BillShortStatusDraft"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_draft');
 | |
| 1060 | -                    $newmenu->add(BASE_URI . "?controller=fourn/facture&method=list&leftmenu=suppliers_bills_notpaid&search_status=1", $langs->trans("BillShortStatusNotPaid"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_notpaid');
 | |
| 1061 | -                    $newmenu->add(BASE_URI . "?controller=fourn/facture&method=list&leftmenu=suppliers_bills_paid&search_status=2", $langs->trans("BillShortStatusPaid"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_paid');
 | |
| 1059 | +                    $newmenu->add(BASE_URI."?controller=fourn/facture&method=list&leftmenu=suppliers_bills_draft&search_status=0", $langs->trans("BillShortStatusDraft"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_draft');
 | |
| 1060 | +                    $newmenu->add(BASE_URI."?controller=fourn/facture&method=list&leftmenu=suppliers_bills_notpaid&search_status=1", $langs->trans("BillShortStatusNotPaid"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_notpaid');
 | |
| 1061 | +                    $newmenu->add(BASE_URI."?controller=fourn/facture&method=list&leftmenu=suppliers_bills_paid&search_status=2", $langs->trans("BillShortStatusPaid"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_paid');
 | |
| 1062 | 1062 | } | 
| 1063 | 1063 | |
| 1064 | 1064 |  //$newmenu->add("/fourn/facture/paiement.php?leftmenu=suppliers_bills_payment", $langs->trans("Payments"), 1, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_payment');
 | 
| 1065 | 1065 |  //$newmenu->add("/fourn/facture/rapport.php?leftmenu=suppliers_bills_report", $langs->trans("Reportings"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_report');
 | 
| 1066 | 1066 |  //$newmenu->add("/compta/facture/stats/index.php?mode=supplier&leftmenu=suppliers_bills_stats", $langs->trans("Statistics"), 1, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_stats');
 | 
| 1067 | -                $newmenu->add(BASE_URI . "?controller=fourn/facture&method=paiement&leftmenu=suppliers_bills_payment", $langs->trans("Payments"), 1, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_payment');
 | |
| 1068 | -                $newmenu->add(BASE_URI . "?controller=fourn/facture&method=rapport&leftmenu=suppliers_bills_report", $langs->trans("Reportings"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_report');
 | |
| 1069 | -                $newmenu->add(BASE_URI . "?controller=compta/facture/stats&method=index&mode=supplier&leftmenu=suppliers_bills_stats", $langs->trans("Statistics"), 1, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_stats');
 | |
| 1067 | +                $newmenu->add(BASE_URI."?controller=fourn/facture&method=paiement&leftmenu=suppliers_bills_payment", $langs->trans("Payments"), 1, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_payment');
 | |
| 1068 | +                $newmenu->add(BASE_URI."?controller=fourn/facture&method=rapport&leftmenu=suppliers_bills_report", $langs->trans("Reportings"), 2, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_report');
 | |
| 1069 | +                $newmenu->add(BASE_URI."?controller=compta/facture/stats&method=index&mode=supplier&leftmenu=suppliers_bills_stats", $langs->trans("Statistics"), 1, $user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_stats');
 | |
| 1070 | 1070 | } | 
| 1071 | 1071 | |
| 1072 | 1072 | // Orders | 
| @@ -1074,7 +1074,7 @@ discard block | ||
| 1074 | 1074 |                  $langs->load("orders");
 | 
| 1075 | 1075 |                  if (!empty($conf->facture->enabled)) {
 | 
| 1076 | 1076 |  //$newmenu->add("/commande/list.php?leftmenu=orders&viewstatut=-3&billed=0&contextpage=billableorders", $langs->trans("MenuOrdersToBill2"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders');
 | 
| 1077 | -                    $newmenu->add(BASE_URI . "?controller=commande&method=list&leftmenu=orders&viewstatut=-3&billed=0&contextpage=billableorders", $langs->trans("MenuOrdersToBill2"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders');
 | |
| 1077 | +                    $newmenu->add(BASE_URI."?controller=commande&method=list&leftmenu=orders&viewstatut=-3&billed=0&contextpage=billableorders", $langs->trans("MenuOrdersToBill2"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders');
 | |
| 1078 | 1078 | } | 
| 1079 | 1079 |  //                  if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->rights->commande->lire);
 | 
| 1080 | 1080 | } | 
| @@ -1084,7 +1084,7 @@ discard block | ||
| 1084 | 1084 |                  if (!empty($conf->global->SUPPLIER_MENU_ORDER_RECEIVED_INTO_INVOICE)) {
 | 
| 1085 | 1085 |                      $langs->load("supplier");
 | 
| 1086 | 1086 |  //$newmenu->add("/fourn/commande/list.php?leftmenu=orders&search_status=5&billed=0", $langs->trans("MenuOrdersSupplierToBill"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders');
 | 
| 1087 | -                    $newmenu->add(BASE_URI . "?controller=fourn/commande&method=list&leftmenu=orders&search_status=5&billed=0", $langs->trans("MenuOrdersSupplierToBill"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders');
 | |
| 1087 | +                    $newmenu->add(BASE_URI."?controller=fourn/commande&method=list&leftmenu=orders&search_status=5&billed=0", $langs->trans("MenuOrdersSupplierToBill"), 0, $user->rights->commande->lire, '', $mainmenu, 'orders');
 | |
| 1088 | 1088 |  //                  if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders") $newmenu->add("/commande/", $langs->trans("StatusOrderToBill"), 1, $user->rights->commande->lire);
 | 
| 1089 | 1089 | } | 
| 1090 | 1090 | } | 
| @@ -1094,12 +1094,12 @@ discard block | ||
| 1094 | 1094 |              if (!empty($conf->don->enabled)) {
 | 
| 1095 | 1095 |                  $langs->load("donations");
 | 
| 1096 | 1096 |  //$newmenu->add("/don/index.php?leftmenu=donations&mainmenu=billing", $langs->trans("Donations"), 0, $user->rights->don->lire, '', $mainmenu, 'donations');
 | 
| 1097 | -                $newmenu->add(BASE_URI . "?controller=don&method=index&leftmenu=donations&mainmenu=billing", $langs->trans("Donations"), 0, $user->rights->don->lire, '', $mainmenu, 'donations');
 | |
| 1097 | +                $newmenu->add(BASE_URI."?controller=don&method=index&leftmenu=donations&mainmenu=billing", $langs->trans("Donations"), 0, $user->rights->don->lire, '', $mainmenu, 'donations');
 | |
| 1098 | 1098 |                  if ($usemenuhider || empty($leftmenu) || $leftmenu == "donations") {
 | 
| 1099 | 1099 |  //$newmenu->add("/don/card.php?leftmenu=donations&action=create", $langs->trans("NewDonation"), 1, $user->rights->don->creer);
 | 
| 1100 | 1100 |  //$newmenu->add("/don/list.php?leftmenu=donations", $langs->trans("List"), 1, $user->rights->don->lire);
 | 
| 1101 | -                    $newmenu->add(BASE_URI . "?controller=don&method=card&leftmenu=donations&action=create", $langs->trans("NewDonation"), 1, $user->rights->don->creer);
 | |
| 1102 | -                    $newmenu->add(BASE_URI . "?controller=don&method=list&leftmenu=donations", $langs->trans("List"), 1, $user->rights->don->lire);
 | |
| 1101 | +                    $newmenu->add(BASE_URI."?controller=don&method=card&leftmenu=donations&action=create", $langs->trans("NewDonation"), 1, $user->rights->don->creer);
 | |
| 1102 | +                    $newmenu->add(BASE_URI."?controller=don&method=list&leftmenu=donations", $langs->trans("List"), 1, $user->rights->don->lire);
 | |
| 1103 | 1103 | } | 
| 1104 | 1104 |  // if ($leftmenu=="donations") $newmenu->add("/don/stats/index.php",$langs->trans("Statistics"), 1, $user->rights->don->lire);
 | 
| 1105 | 1105 | } | 
| @@ -1110,24 +1110,24 @@ discard block | ||
| 1110 | 1110 | |
| 1111 | 1111 | $permtoshowmenu = ((!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) || (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) || (!empty($conf->loan->enabled) && $user->rights->loan->read) || (!empty($conf->banque->enabled) && $user->rights->banque->lire)); | 
| 1112 | 1112 |  //$newmenu->add("/compta/charges/index.php?leftmenu=tax&mainmenu=billing", $langs->trans("MenuSpecialExpenses"), 0, $permtoshowmenu, '', $mainmenu, 'tax');
 | 
| 1113 | -                $newmenu->add(BASE_URI . "?controller=compta/charges&method=index&leftmenu=tax&mainmenu=billing", $langs->trans("MenuSpecialExpenses"), 0, $permtoshowmenu, '', $mainmenu, 'tax');
 | |
| 1113 | +                $newmenu->add(BASE_URI."?controller=compta/charges&method=index&leftmenu=tax&mainmenu=billing", $langs->trans("MenuSpecialExpenses"), 0, $permtoshowmenu, '', $mainmenu, 'tax');
 | |
| 1114 | 1114 | |
| 1115 | 1115 | // Social contributions | 
| 1116 | 1116 |                  if (!empty($conf->tax->enabled)) {
 | 
| 1117 | 1117 |  //$newmenu->add("/compta/sociales/list.php?leftmenu=tax_social", $langs->trans("MenuSocialContributions"), 1, $user->rights->tax->charges->lire);
 | 
| 1118 | -                    $newmenu->add(BASE_URI . "?controller=compta/sociales&method=list&leftmenu=tax_social", $langs->trans("MenuSocialContributions"), 1, $user->rights->tax->charges->lire);
 | |
| 1118 | +                    $newmenu->add(BASE_URI."?controller=compta/sociales&method=list&leftmenu=tax_social", $langs->trans("MenuSocialContributions"), 1, $user->rights->tax->charges->lire);
 | |
| 1119 | 1119 |                      if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_social/i', $leftmenu)) {
 | 
| 1120 | 1120 |  //$newmenu->add("/compta/sociales/card.php?leftmenu=tax_social&action=create", $langs->trans("MenuNewSocialContribution"), 2, $user->rights->tax->charges->creer);
 | 
| 1121 | 1121 |  //$newmenu->add("/compta/sociales/list.php?leftmenu=tax_social", $langs->trans("List"), 2, $user->rights->tax->charges->lire);
 | 
| 1122 | 1122 |  //$newmenu->add("/compta/sociales/payments.php?leftmenu=tax_social&mainmenu=billing&mode=sconly", $langs->trans("Payments"), 2, $user->rights->tax->charges->lire);
 | 
| 1123 | -                        $newmenu->add(BASE_URI . "?controller=compta/sociales&method=card&leftmenu=tax_social&action=create", $langs->trans("MenuNewSocialContribution"), 2, $user->rights->tax->charges->creer);
 | |
| 1124 | -                        $newmenu->add(BASE_URI . "?controller=compta/sociales&method=list&leftmenu=tax_social", $langs->trans("List"), 2, $user->rights->tax->charges->lire);
 | |
| 1125 | -                        $newmenu->add(BASE_URI . "?controller=compta/sociales&method=payments&leftmenu=tax_social&mainmenu=billing&mode=sconly", $langs->trans("Payments"), 2, $user->rights->tax->charges->lire);
 | |
| 1123 | +                        $newmenu->add(BASE_URI."?controller=compta/sociales&method=card&leftmenu=tax_social&action=create", $langs->trans("MenuNewSocialContribution"), 2, $user->rights->tax->charges->creer);
 | |
| 1124 | +                        $newmenu->add(BASE_URI."?controller=compta/sociales&method=list&leftmenu=tax_social", $langs->trans("List"), 2, $user->rights->tax->charges->lire);
 | |
| 1125 | +                        $newmenu->add(BASE_URI."?controller=compta/sociales&method=payments&leftmenu=tax_social&mainmenu=billing&mode=sconly", $langs->trans("Payments"), 2, $user->rights->tax->charges->lire);
 | |
| 1126 | 1126 | } | 
| 1127 | 1127 | // VAT | 
| 1128 | 1128 |                      if (empty($conf->global->TAX_DISABLE_VAT_MENUS)) {
 | 
| 1129 | 1129 |  //$newmenu->add("/compta/tva/list.php?leftmenu=tax_vat&mainmenu=billing", $langs->transcountry("VAT", $mysoc->country_code), 1, $user->rights->tax->charges->lire, '', $mainmenu, 'tax_vat');
 | 
| 1130 | -                        $newmenu->add(BASE_URI . "?controller=compta/tva&method=list&leftmenu=tax_vat&mainmenu=billing", $langs->transcountry("VAT", $mysoc->country_code), 1, $user->rights->tax->charges->lire, '', $mainmenu, 'tax_vat');
 | |
| 1130 | +                        $newmenu->add(BASE_URI."?controller=compta/tva&method=list&leftmenu=tax_vat&mainmenu=billing", $langs->transcountry("VAT", $mysoc->country_code), 1, $user->rights->tax->charges->lire, '', $mainmenu, 'tax_vat');
 | |
| 1131 | 1131 |                          if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_vat/i', $leftmenu)) {
 | 
| 1132 | 1132 | /* | 
| 1133 | 1133 |                                $newmenu->add("/compta/tva/card.php?leftmenu=tax_vat&action=create", $langs->trans("New"), 2, $user->rights->tax->charges->creer);
 | 
| @@ -1136,18 +1136,18 @@ discard block | ||
| 1136 | 1136 |                                $newmenu->add("/compta/tva/clients.php?leftmenu=tax_vat", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
 | 
| 1137 | 1137 |                                $newmenu->add("/compta/tva/quadri_detail.php?leftmenu=tax_vat", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
 | 
| 1138 | 1138 | */ | 
| 1139 | -                            $newmenu->add(BASE_URI . "?controller=compta/tva&method=card&leftmenu=tax_vat&action=create", $langs->trans("New"), 2, $user->rights->tax->charges->creer);
 | |
| 1140 | -                            $newmenu->add(BASE_URI . "?controller=compta/tva&method=list&leftmenu=tax_vat", $langs->trans("List"), 2, $user->rights->tax->charges->lire);
 | |
| 1141 | -                            $newmenu->add(BASE_URI . "?controller=compta/tva&method=index&leftmenu=tax_vat", $langs->trans("ReportByMonth"), 2, $user->rights->tax->charges->lire);
 | |
| 1142 | -                            $newmenu->add(BASE_URI . "?controller=compta/tva&method=clients&leftmenu=tax_vat", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
 | |
| 1143 | -                            $newmenu->add(BASE_URI . "?controller=compta/tva&method=quadri_detail&leftmenu=tax_vat", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
 | |
| 1139 | +                            $newmenu->add(BASE_URI."?controller=compta/tva&method=card&leftmenu=tax_vat&action=create", $langs->trans("New"), 2, $user->rights->tax->charges->creer);
 | |
| 1140 | +                            $newmenu->add(BASE_URI."?controller=compta/tva&method=list&leftmenu=tax_vat", $langs->trans("List"), 2, $user->rights->tax->charges->lire);
 | |
| 1141 | +                            $newmenu->add(BASE_URI."?controller=compta/tva&method=index&leftmenu=tax_vat", $langs->trans("ReportByMonth"), 2, $user->rights->tax->charges->lire);
 | |
| 1142 | +                            $newmenu->add(BASE_URI."?controller=compta/tva&method=clients&leftmenu=tax_vat", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
 | |
| 1143 | +                            $newmenu->add(BASE_URI."?controller=compta/tva&method=quadri_detail&leftmenu=tax_vat", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
 | |
| 1144 | 1144 | } | 
| 1145 | 1145 | global $mysoc; | 
| 1146 | 1146 | |
| 1147 | 1147 | //Local Taxes 1 | 
| 1148 | 1148 |                          if ($mysoc->useLocalTax(1) && (isset($mysoc->localtax1_assuj) && $mysoc->localtax1_assuj == "1")) {
 | 
| 1149 | 1149 |  //$newmenu->add("/compta/localtax/list.php?leftmenu=tax_1_vat&mainmenu=billing&localTaxType=1", $langs->transcountry("LT1", $mysoc->country_code), 1, $user->rights->tax->charges->lire);
 | 
| 1150 | -                            $newmenu->add(BASE_URI . "?controller=compta/localtax&method=list&leftmenu=tax_1_vat&mainmenu=billing&localTaxType=1", $langs->transcountry("LT1", $mysoc->country_code), 1, $user->rights->tax->charges->lire);
 | |
| 1150 | +                            $newmenu->add(BASE_URI."?controller=compta/localtax&method=list&leftmenu=tax_1_vat&mainmenu=billing&localTaxType=1", $langs->transcountry("LT1", $mysoc->country_code), 1, $user->rights->tax->charges->lire);
 | |
| 1151 | 1151 |                              if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_1_vat/i', $leftmenu)) {
 | 
| 1152 | 1152 | /* | 
| 1153 | 1153 |                                    $newmenu->add("/compta/localtax/card.php?leftmenu=tax_1_vat&action=create&localTaxType=1", $langs->trans("New"), 2, $user->rights->tax->charges->creer);
 | 
| @@ -1156,17 +1156,17 @@ discard block | ||
| 1156 | 1156 |                                    $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_1_vat&localTaxType=1", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
 | 
| 1157 | 1157 |                                    $newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_1_vat&localTaxType=1", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
 | 
| 1158 | 1158 | */ | 
| 1159 | -                                $newmenu->add(BASE_URI . "?controller=compta/localtax&method=card&leftmenu=tax_1_vat&action=create&localTaxType=1", $langs->trans("New"), 2, $user->rights->tax->charges->creer);
 | |
| 1160 | -                                $newmenu->add(BASE_URI . "?controller=compta/localtax&method=list&leftmenu=tax_1_vat&localTaxType=1", $langs->trans("List"), 2, $user->rights->tax->charges->lire);
 | |
| 1161 | -                                $newmenu->add(BASE_URI . "?controller=compta/localtax&method=index&leftmenu=tax_1_vat&localTaxType=1", $langs->trans("ReportByMonth"), 2, $user->rights->tax->charges->lire);
 | |
| 1162 | -                                $newmenu->add(BASE_URI . "?controller=compta/localtax&method=clients&leftmenu=tax_1_vat&localTaxType=1", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
 | |
| 1163 | -                                $newmenu->add(BASE_URI . "?controller=compta/localtax&method=quadri_detail&leftmenu=tax_1_vat&localTaxType=1", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
 | |
| 1159 | +                                $newmenu->add(BASE_URI."?controller=compta/localtax&method=card&leftmenu=tax_1_vat&action=create&localTaxType=1", $langs->trans("New"), 2, $user->rights->tax->charges->creer);
 | |
| 1160 | +                                $newmenu->add(BASE_URI."?controller=compta/localtax&method=list&leftmenu=tax_1_vat&localTaxType=1", $langs->trans("List"), 2, $user->rights->tax->charges->lire);
 | |
| 1161 | +                                $newmenu->add(BASE_URI."?controller=compta/localtax&method=index&leftmenu=tax_1_vat&localTaxType=1", $langs->trans("ReportByMonth"), 2, $user->rights->tax->charges->lire);
 | |
| 1162 | +                                $newmenu->add(BASE_URI."?controller=compta/localtax&method=clients&leftmenu=tax_1_vat&localTaxType=1", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
 | |
| 1163 | +                                $newmenu->add(BASE_URI."?controller=compta/localtax&method=quadri_detail&leftmenu=tax_1_vat&localTaxType=1", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
 | |
| 1164 | 1164 | } | 
| 1165 | 1165 | } | 
| 1166 | 1166 | //Local Taxes 2 | 
| 1167 | 1167 |                          if ($mysoc->useLocalTax(2) && (isset($mysoc->localtax2_assuj) && $mysoc->localtax2_assuj == "1")) {
 | 
| 1168 | 1168 |  //$newmenu->add("/compta/localtax/list.php?leftmenu=tax_2_vat&mainmenu=billing&localTaxType=2", $langs->transcountry("LT2", $mysoc->country_code), 1, $user->rights->tax->charges->lire);
 | 
| 1169 | -                            $newmenu->add(BASE_URI . "?controller=compta/localtax&method=list&leftmenu=tax_2_vat&mainmenu=billing&localTaxType=2", $langs->transcountry("LT2", $mysoc->country_code), 1, $user->rights->tax->charges->lire);
 | |
| 1169 | +                            $newmenu->add(BASE_URI."?controller=compta/localtax&method=list&leftmenu=tax_2_vat&mainmenu=billing&localTaxType=2", $langs->transcountry("LT2", $mysoc->country_code), 1, $user->rights->tax->charges->lire);
 | |
| 1170 | 1170 |                              if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_2_vat/i', $leftmenu)) {
 | 
| 1171 | 1171 | /* | 
| 1172 | 1172 |                                    $newmenu->add("/compta/localtax/card.php?leftmenu=tax_2_vat&action=create&localTaxType=2", $langs->trans("New"), 2, $user->rights->tax->charges->creer);
 | 
| @@ -1175,11 +1175,11 @@ discard block | ||
| 1175 | 1175 |                                    $newmenu->add("/compta/localtax/clients.php?leftmenu=tax_2_vat&localTaxType=2", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
 | 
| 1176 | 1176 |                                    $newmenu->add("/compta/localtax/quadri_detail.php?leftmenu=tax_2_vat&localTaxType=2", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
 | 
| 1177 | 1177 | */ | 
| 1178 | -                                $newmenu->add(BASE_URI . "?controller=compta/localtax&method=card&leftmenu=tax_2_vat&action=create&localTaxType=2", $langs->trans("New"), 2, $user->rights->tax->charges->creer);
 | |
| 1179 | -                                $newmenu->add(BASE_URI . "?controller=compta/localtax&method=list&leftmenu=tax_2_vat&localTaxType=2", $langs->trans("List"), 2, $user->rights->tax->charges->lire);
 | |
| 1180 | -                                $newmenu->add(BASE_URI . "?controller=compta/localtax&method=index&leftmenu=tax_2_vat&localTaxType=2", $langs->trans("ReportByMonth"), 2, $user->rights->tax->charges->lire);
 | |
| 1181 | -                                $newmenu->add(BASE_URI . "?controller=compta/localtax&method=clients&leftmenu=tax_2_vat&localTaxType=2", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
 | |
| 1182 | -                                $newmenu->add(BASE_URI . "?controller=compta/localtax&method=quadri_detail&leftmenu=tax_2_vat&localTaxType=2", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
 | |
| 1178 | +                                $newmenu->add(BASE_URI."?controller=compta/localtax&method=card&leftmenu=tax_2_vat&action=create&localTaxType=2", $langs->trans("New"), 2, $user->rights->tax->charges->creer);
 | |
| 1179 | +                                $newmenu->add(BASE_URI."?controller=compta/localtax&method=list&leftmenu=tax_2_vat&localTaxType=2", $langs->trans("List"), 2, $user->rights->tax->charges->lire);
 | |
| 1180 | +                                $newmenu->add(BASE_URI."?controller=compta/localtax&method=index&leftmenu=tax_2_vat&localTaxType=2", $langs->trans("ReportByMonth"), 2, $user->rights->tax->charges->lire);
 | |
| 1181 | +                                $newmenu->add(BASE_URI."?controller=compta/localtax&method=clients&leftmenu=tax_2_vat&localTaxType=2", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire);
 | |
| 1182 | +                                $newmenu->add(BASE_URI."?controller=compta/localtax&method=quadri_detail&leftmenu=tax_2_vat&localTaxType=2", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire);
 | |
| 1183 | 1183 | } | 
| 1184 | 1184 | } | 
| 1185 | 1185 | } | 
| @@ -1189,14 +1189,14 @@ discard block | ||
| 1189 | 1189 |                  if (!empty($conf->salaries->enabled)) {
 | 
| 1190 | 1190 |                      $langs->load("salaries");
 | 
| 1191 | 1191 |  //$newmenu->add("/compta/salaries/list.php?leftmenu=tax_salary&mainmenu=billing", $langs->trans("Salaries"), 1, $user->rights->salaries->read, '', $mainmenu, 'tax_salary');
 | 
| 1192 | -                    $newmenu->add(BASE_URI . "?controller=compta/salaries&method=list&leftmenu=tax_salary&mainmenu=billing", $langs->trans("Salaries"), 1, $user->rights->salaries->read, '', $mainmenu, 'tax_salary');
 | |
| 1192 | +                    $newmenu->add(BASE_URI."?controller=compta/salaries&method=list&leftmenu=tax_salary&mainmenu=billing", $langs->trans("Salaries"), 1, $user->rights->salaries->read, '', $mainmenu, 'tax_salary');
 | |
| 1193 | 1193 |                      if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i', $leftmenu)) {
 | 
| 1194 | 1194 |  //$newmenu->add("/compta/salaries/card.php?leftmenu=tax_salary&action=create", $langs->trans("NewPayment"), 2, $user->rights->salaries->write);
 | 
| 1195 | 1195 |  //$newmenu->add("/compta/salaries/list.php?leftmenu=tax_salary", $langs->trans("Payments"), 2, $user->rights->salaries->read);
 | 
| 1196 | 1196 |  //$newmenu->add("/compta/salaries/stats/index.php?leftmenu=tax_salary", $langs->trans("Statistics"), 2, $user->rights->salaries->read);
 | 
| 1197 | -                        $newmenu->add(BASE_URI . "?controller=compta/salaries&method=card&leftmenu=tax_salary&action=create", $langs->trans("NewPayment"), 2, $user->rights->salaries->write);
 | |
| 1198 | -                        $newmenu->add(BASE_URI . "?controller=compta/salaries&method=list&leftmenu=tax_salary", $langs->trans("Payments"), 2, $user->rights->salaries->read);
 | |
| 1199 | -                        $newmenu->add(BASE_URI . "?controller=compta/salaries/stats&method=index&leftmenu=tax_salary", $langs->trans("Statistics"), 2, $user->rights->salaries->read);
 | |
| 1197 | +                        $newmenu->add(BASE_URI."?controller=compta/salaries&method=card&leftmenu=tax_salary&action=create", $langs->trans("NewPayment"), 2, $user->rights->salaries->write);
 | |
| 1198 | +                        $newmenu->add(BASE_URI."?controller=compta/salaries&method=list&leftmenu=tax_salary", $langs->trans("Payments"), 2, $user->rights->salaries->read);
 | |
| 1199 | +                        $newmenu->add(BASE_URI."?controller=compta/salaries/stats&method=index&leftmenu=tax_salary", $langs->trans("Statistics"), 2, $user->rights->salaries->read);
 | |
| 1200 | 1200 | } | 
| 1201 | 1201 | } | 
| 1202 | 1202 | |
| @@ -1204,10 +1204,10 @@ discard block | ||
| 1204 | 1204 |                  if (!empty($conf->loan->enabled)) {
 | 
| 1205 | 1205 |                      $langs->load("loan");
 | 
| 1206 | 1206 |  //$newmenu->add("/loan/list.php?leftmenu=tax_loan&mainmenu=billing", $langs->trans("Loans"), 1, $user->rights->loan->read, '', $mainmenu, 'tax_loan');
 | 
| 1207 | -                    $newmenu->add(BASE_URI . "?controller=loan&method=list&leftmenu=tax_loan&mainmenu=billing", $langs->trans("Loans"), 1, $user->rights->loan->read, '', $mainmenu, 'tax_loan');
 | |
| 1207 | +                    $newmenu->add(BASE_URI."?controller=loan&method=list&leftmenu=tax_loan&mainmenu=billing", $langs->trans("Loans"), 1, $user->rights->loan->read, '', $mainmenu, 'tax_loan');
 | |
| 1208 | 1208 |                      if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_loan/i', $leftmenu)) {
 | 
| 1209 | 1209 |  //$newmenu->add("/loan/card.php?leftmenu=tax_loan&action=create", $langs->trans("NewLoan"), 2, $user->rights->loan->write);
 | 
| 1210 | -                        $newmenu->add(BASE_URI . "?controller=loan&method=card&leftmenu=tax_loan&action=create", $langs->trans("NewLoan"), 2, $user->rights->loan->write);
 | |
| 1210 | +                        $newmenu->add(BASE_URI."?controller=loan&method=card&leftmenu=tax_loan&action=create", $langs->trans("NewLoan"), 2, $user->rights->loan->write);
 | |
| 1211 | 1211 |  //$newmenu->add("/loan/payment/list.php?leftmenu=tax_loan",$langs->trans("Payments"),2,$user->rights->loan->read);
 | 
| 1212 | 1212 | } | 
| 1213 | 1213 | } | 
| @@ -1216,12 +1216,12 @@ discard block | ||
| 1216 | 1216 |                  if (!empty($conf->banque->enabled) && empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)) {
 | 
| 1217 | 1217 |                      $langs->load("banks");
 | 
| 1218 | 1218 |  //$newmenu->add("/compta/bank/various_payment/list.php?leftmenu=tax_various&mainmenu=billing", $langs->trans("MenuVariousPayment"), 1, $user->rights->banque->lire, '', $mainmenu, 'tax_various');
 | 
| 1219 | -                    $newmenu->add(BASE_URI . "?controller=compta/bank/various_payment&method=list&leftmenu=tax_various&mainmenu=billing", $langs->trans("MenuVariousPayment"), 1, $user->rights->banque->lire, '', $mainmenu, 'tax_various');
 | |
| 1219 | +                    $newmenu->add(BASE_URI."?controller=compta/bank/various_payment&method=list&leftmenu=tax_various&mainmenu=billing", $langs->trans("MenuVariousPayment"), 1, $user->rights->banque->lire, '', $mainmenu, 'tax_various');
 | |
| 1220 | 1220 |                      if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_various/i', $leftmenu)) {
 | 
| 1221 | 1221 |  //$newmenu->add("/compta/bank/various_payment/card.php?leftmenu=tax_various&action=create", $langs->trans("New"), 2, $user->rights->banque->modifier);
 | 
| 1222 | 1222 |  //$newmenu->add("/compta/bank/various_payment/list.php?leftmenu=tax_various", $langs->trans("List"), 2, $user->rights->banque->lire);
 | 
| 1223 | -                        $newmenu->add(BASE_URI . "?controller=compta/bank/various_payment&method=card&leftmenu=tax_various&action=create", $langs->trans("New"), 2, $user->rights->banque->modifier);
 | |
| 1224 | -                        $newmenu->add(BASE_URI . "?controller=compta/bank/various_payment&method=list&leftmenu=tax_various", $langs->trans("List"), 2, $user->rights->banque->lire);
 | |
| 1223 | +                        $newmenu->add(BASE_URI."?controller=compta/bank/various_payment&method=card&leftmenu=tax_various&action=create", $langs->trans("New"), 2, $user->rights->banque->modifier);
 | |
| 1224 | +                        $newmenu->add(BASE_URI."?controller=compta/bank/various_payment&method=list&leftmenu=tax_various", $langs->trans("List"), 2, $user->rights->banque->lire);
 | |
| 1225 | 1225 | } | 
| 1226 | 1226 | } | 
| 1227 | 1227 | } | 
| @@ -1239,11 +1239,11 @@ discard block | ||
| 1239 | 1239 | |
| 1240 | 1240 | $permtoshowmenu = (!empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire); | 
| 1241 | 1241 |  //$newmenu->add("/accountancy/index.php?leftmenu=accountancy", $langs->trans("MenuAccountancy"), 0, $permtoshowmenu, '', $mainmenu, 'accountancy');
 | 
| 1242 | -                $newmenu->add(BASE_URI . "?controller=accountancy&method=index&leftmenu=accountancy", $langs->trans("MenuAccountancy"), 0, $permtoshowmenu, '', $mainmenu, 'accountancy');
 | |
| 1242 | +                $newmenu->add(BASE_URI."?controller=accountancy&method=index&leftmenu=accountancy", $langs->trans("MenuAccountancy"), 0, $permtoshowmenu, '', $mainmenu, 'accountancy');
 | |
| 1243 | 1243 | |
| 1244 | 1244 | // Chart of account | 
| 1245 | 1245 |  //$newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1);
 | 
| 1246 | -                $newmenu->add(BASE_URI . "?controller=accountancy&method=index&leftmenu=accountancy_admin", $langs->trans("Setup"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1);
 | |
| 1246 | +                $newmenu->add(BASE_URI."?controller=accountancy&method=index&leftmenu=accountancy_admin", $langs->trans("Setup"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1);
 | |
| 1247 | 1247 |                  if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/', $leftmenu)) {
 | 
| 1248 | 1248 | /* | 
| 1249 | 1249 |                        $newmenu->add("/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("General"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_general', 10);
 | 
| @@ -1253,71 +1253,71 @@ discard block | ||
| 1253 | 1253 |                        $newmenu->add("/accountancy/admin/categories_list.php?id=32&search_country_id=" . $mysoc->country_id . "&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingCategory"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 41);
 | 
| 1254 | 1254 |                        $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 50);
 | 
| 1255 | 1255 | */ | 
| 1256 | -                    $newmenu->add(BASE_URI . "?controller=accountancy/admin&method=index&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("General"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_general', 10);
 | |
| 1257 | -                    $newmenu->add(BASE_URI . "?controller=accountancy/admin&method=journals_list&id=35&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingJournals"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_journal', 20);
 | |
| 1258 | -                    $newmenu->add(BASE_URI . "?controller=accountancy/admin&method=accountmodel&id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 30);
 | |
| 1259 | -                    $newmenu->add(BASE_URI . "?controller=accountancy/admin&method=account&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 40);
 | |
| 1260 | -                    $newmenu->add(BASE_URI . "?controller=accountancy/admin&method=categories_list&id=32&search_country_id=" . $mysoc->country_id . "&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingCategory"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 41);
 | |
| 1261 | -                    $newmenu->add(BASE_URI . "?controller=accountancy/admin&method=defaultaccounts&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 50);
 | |
| 1256 | +                    $newmenu->add(BASE_URI."?controller=accountancy/admin&method=index&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("General"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_general', 10);
 | |
| 1257 | +                    $newmenu->add(BASE_URI."?controller=accountancy/admin&method=journals_list&id=35&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingJournals"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_journal', 20);
 | |
| 1258 | +                    $newmenu->add(BASE_URI."?controller=accountancy/admin&method=accountmodel&id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 30);
 | |
| 1259 | +                    $newmenu->add(BASE_URI."?controller=accountancy/admin&method=account&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 40);
 | |
| 1260 | +                    $newmenu->add(BASE_URI."?controller=accountancy/admin&method=categories_list&id=32&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("AccountingCategory"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 41);
 | |
| 1261 | +                    $newmenu->add(BASE_URI."?controller=accountancy/admin&method=defaultaccounts&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 50);
 | |
| 1262 | 1262 |                      if (!empty($conf->banque->enabled)) {
 | 
| 1263 | 1263 |  //$newmenu->add("/compta/bank/list.php?mainmenu=accountancy&leftmenu=accountancy_admin&search_status=-1", $langs->trans("MenuBankAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_bank', 51);
 | 
| 1264 | -                        $newmenu->add(BASE_URI . "?controller=compta/bank&method=list&mainmenu=accountancy&leftmenu=accountancy_admin&search_status=-1", $langs->trans("MenuBankAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_bank', 51);
 | |
| 1264 | +                        $newmenu->add(BASE_URI."?controller=compta/bank&method=list&mainmenu=accountancy&leftmenu=accountancy_admin&search_status=-1", $langs->trans("MenuBankAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_bank', 51);
 | |
| 1265 | 1265 | } | 
| 1266 | 1266 |                      if (!empty($conf->facture->enabled) || !empty($conf->fournisseur->enabled)) {
 | 
| 1267 | 1267 |  //$newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=" . $mysoc->country_id . "&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 52);
 | 
| 1268 | -                        $newmenu->add(BASE_URI . "?controller=admin&method=dict&id=10&from=accountancy&search_country_id=" . $mysoc->country_id . "&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 52);
 | |
| 1268 | +                        $newmenu->add(BASE_URI."?controller=admin&method=dict&id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 52);
 | |
| 1269 | 1269 | } | 
| 1270 | 1270 |                      if (!empty($conf->tax->enabled)) {
 | 
| 1271 | 1271 |  //$newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=" . $mysoc->country_id . "&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 53);
 | 
| 1272 | -                        $newmenu->add(BASE_URI . "?controller=admin&method=dict&id=7&from=accountancy&search_country_id=" . $mysoc->country_id . "&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 53);
 | |
| 1272 | +                        $newmenu->add(BASE_URI."?controller=admin&method=dict&id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 53);
 | |
| 1273 | 1273 | } | 
| 1274 | 1274 |                      if (!empty($conf->expensereport->enabled)) {
 | 
| 1275 | 1275 |  //$newmenu->add("/admin/dict.php?id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuExpenseReportAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 54);
 | 
| 1276 | -                        $newmenu->add(BASE_URI . "?controller=admin&method=dict&id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuExpenseReportAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 54);
 | |
| 1276 | +                        $newmenu->add(BASE_URI."?controller=admin&method=dict&id=17&from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuExpenseReportAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 54);
 | |
| 1277 | 1277 | } | 
| 1278 | 1278 |  //$newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 55);
 | 
| 1279 | 1279 |  //$newmenu->add("/accountancy/admin/export.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ExportOptions"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_export', 60);
 | 
| 1280 | -                    $newmenu->add(BASE_URI . "?controller=accountancy/admin&method=productaccount&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 55);
 | |
| 1281 | -                    $newmenu->add(BASE_URI . "?controller=accountancy/admin&method=export&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ExportOptions"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_export', 60);
 | |
| 1280 | +                    $newmenu->add(BASE_URI."?controller=accountancy/admin&method=productaccount&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 55);
 | |
| 1281 | +                    $newmenu->add(BASE_URI."?controller=accountancy/admin&method=export&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("ExportOptions"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_export', 60);
 | |
| 1282 | 1282 | |
| 1283 | 1283 | // Fiscal year | 
| 1284 | 1284 |                      if ($conf->global->MAIN_FEATURES_LEVEL > 1) {
 | 
| 1285 | 1285 | // Not yet used. In a future will lock some periods. | 
| 1286 | 1286 |  //$newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 2, $user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear');
 | 
| 1287 | -                        $newmenu->add(BASE_URI . "?controller=accountancy/admin&method=fiscalyear&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 2, $user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear');
 | |
| 1287 | +                        $newmenu->add(BASE_URI."?controller=accountancy/admin&method=fiscalyear&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("FiscalPeriod"), 2, $user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear');
 | |
| 1288 | 1288 | } | 
| 1289 | 1289 | } | 
| 1290 | 1290 | |
| 1291 | 1291 | // Binding | 
| 1292 | 1292 |                  if (!empty($conf->facture->enabled)) {
 | 
| 1293 | 1293 |  //$newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&mainmenu=accountancy", $langs->trans("CustomersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer');
 | 
| 1294 | -                    $newmenu->add(BASE_URI . "?controller=accountancy/customer&method=index&leftmenu=accountancy_dispatch_customer&mainmenu=accountancy", $langs->trans("CustomersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer');
 | |
| 1294 | +                    $newmenu->add(BASE_URI."?controller=accountancy/customer&method=index&leftmenu=accountancy_dispatch_customer&mainmenu=accountancy", $langs->trans("CustomersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer');
 | |
| 1295 | 1295 |                      if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_customer/', $leftmenu)) {
 | 
| 1296 | 1296 |  //$newmenu->add("/accountancy/customer/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write);
 | 
| 1297 | 1297 |  //$newmenu->add("/accountancy/customer/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write);
 | 
| 1298 | -                        $newmenu->add(BASE_URI . "?controller=accountancy/customer&method=list&mainmenu=accountancy&leftmenu=accountancy_dispatch_customer", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write);
 | |
| 1299 | -                        $newmenu->add(BASE_URI . "?controller=accountancy/customer&method=lines&mainmenu=accountancy&leftmenu=accountancy_dispatch_customer", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write);
 | |
| 1298 | +                        $newmenu->add(BASE_URI."?controller=accountancy/customer&method=list&mainmenu=accountancy&leftmenu=accountancy_dispatch_customer", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write);
 | |
| 1299 | +                        $newmenu->add(BASE_URI."?controller=accountancy/customer&method=lines&mainmenu=accountancy&leftmenu=accountancy_dispatch_customer", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write);
 | |
| 1300 | 1300 | } | 
| 1301 | 1301 | } | 
| 1302 | 1302 |                  if (!empty($conf->supplier_invoice->enabled)) {
 | 
| 1303 | 1303 |  //$newmenu->add("/accountancy/supplier/index.php?leftmenu=accountancy_dispatch_supplier&mainmenu=accountancy", $langs->trans("SuppliersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_supplier');
 | 
| 1304 | -                    $newmenu->add(BASE_URI . "?controller=accountancy/supplier&method=index&leftmenu=accountancy_dispatch_supplier&mainmenu=accountancy", $langs->trans("SuppliersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_supplier');
 | |
| 1304 | +                    $newmenu->add(BASE_URI."?controller=accountancy/supplier&method=index&leftmenu=accountancy_dispatch_supplier&mainmenu=accountancy", $langs->trans("SuppliersVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_supplier');
 | |
| 1305 | 1305 |                      if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_supplier/', $leftmenu)) {
 | 
| 1306 | 1306 |  //$newmenu->add("/accountancy/supplier/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write);
 | 
| 1307 | 1307 |  //$newmenu->add("/accountancy/supplier/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write);
 | 
| 1308 | -                        $newmenu->add(BASE_URI . "?controller=accountancy/supplier&method=list&mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write);
 | |
| 1309 | -                        $newmenu->add(BASE_URI . "?controller=accountancy/supplier&method=lines&mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write);
 | |
| 1308 | +                        $newmenu->add(BASE_URI."?controller=accountancy/supplier&method=list&mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write);
 | |
| 1309 | +                        $newmenu->add(BASE_URI."?controller=accountancy/supplier&method=lines&mainmenu=accountancy&leftmenu=accountancy_dispatch_supplier", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write);
 | |
| 1310 | 1310 | } | 
| 1311 | 1311 | } | 
| 1312 | 1312 | |
| 1313 | 1313 |                  if (!empty($conf->expensereport->enabled)) {
 | 
| 1314 | 1314 |  //$newmenu->add("/accountancy/expensereport/index.php?leftmenu=accountancy_dispatch_expensereport&mainmenu=accountancy", $langs->trans("ExpenseReportsVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_expensereport');
 | 
| 1315 | -                    $newmenu->add(BASE_URI . "?controller=accountancy/expensereport&method=index&leftmenu=accountancy_dispatch_expensereport&mainmenu=accountancy", $langs->trans("ExpenseReportsVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_expensereport');
 | |
| 1315 | +                    $newmenu->add(BASE_URI."?controller=accountancy/expensereport&method=index&leftmenu=accountancy_dispatch_expensereport&mainmenu=accountancy", $langs->trans("ExpenseReportsVentilation"), 1, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_expensereport');
 | |
| 1316 | 1316 |                      if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_dispatch_expensereport/', $leftmenu)) {
 | 
| 1317 | 1317 |  //$newmenu->add("/accountancy/expensereport/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write);
 | 
| 1318 | 1318 |  //$newmenu->add("/accountancy/expensereport/lines.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write);
 | 
| 1319 | -                        $newmenu->add(BASE_URI . "?controller=accountancy/expensereport&method=list&mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write);
 | |
| 1320 | -                        $newmenu->add(BASE_URI . "?controller=accountancy/expensereport&method=lines&mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write);
 | |
| 1319 | +                        $newmenu->add(BASE_URI."?controller=accountancy/expensereport&method=list&mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport", $langs->trans("ToBind"), 2, $user->rights->accounting->bind->write);
 | |
| 1320 | +                        $newmenu->add(BASE_URI."?controller=accountancy/expensereport&method=lines&mainmenu=accountancy&leftmenu=accountancy_dispatch_expensereport", $langs->trans("Binded"), 2, $user->rights->accounting->bind->write);
 | |
| 1321 | 1321 | } | 
| 1322 | 1322 | } | 
| 1323 | 1323 | |
| @@ -1327,8 +1327,8 @@ discard block | ||
| 1327 | 1327 | |
| 1328 | 1328 | // Multi journal | 
| 1329 | 1329 | $sql = "SELECT rowid, code, label, nature"; | 
| 1330 | - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_journal"; | |
| 1331 | - $sql .= " WHERE entity = " . $conf->entity; | |
| 1330 | + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal"; | |
| 1331 | + $sql .= " WHERE entity = ".$conf->entity; | |
| 1332 | 1332 | $sql .= " AND active = 1"; | 
| 1333 | 1333 | $sql .= " ORDER BY label DESC"; | 
| 1334 | 1334 | |
| @@ -1369,7 +1369,7 @@ discard block | ||
| 1369 | 1369 |                                      $langs->load('accountancy');
 | 
| 1370 | 1370 | $journallabel = $langs->transnoentities($objp->label); // Labels in this table are set by loading llx_accounting_abc.sql. Label can be 'ACCOUNTING_SELL_JOURNAL', 'InventoryJournal', ... | 
| 1371 | 1371 |  //$newmenu->add('/accountancy/journal/' . $nature . 'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal=' . $objp->rowid, $journallabel, 2, $user->rights->accounting->comptarapport->lire);
 | 
| 1372 | - $newmenu->add(BASE_URI . '?controller=accountancy/journal&method=' . $nature . 'journal&mainmenu=accountancy&leftmenu=accountancy_journal&id_journal=' . $objp->rowid, $journallabel, 2, $user->rights->accounting->comptarapport->lire); | |
| 1372 | + $newmenu->add(BASE_URI.'?controller=accountancy/journal&method='.$nature.'journal&mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid, $journallabel, 2, $user->rights->accounting->comptarapport->lire); | |
| 1373 | 1373 | } | 
| 1374 | 1374 | $i++; | 
| 1375 | 1375 | } | 
| @@ -1384,31 +1384,31 @@ discard block | ||
| 1384 | 1384 | |
| 1385 | 1385 | // General Ledger | 
| 1386 | 1386 |  //$newmenu->add("/accountancy/bookkeeping/list.php?mainmenu=accountancy&leftmenu=accountancy_generalledger", $langs->trans("Bookkeeping"), 1, $user->rights->accounting->mouvements->lire);
 | 
| 1387 | -                $newmenu->add(BASE_URI . "?controller=accountancy/bookkeeping&method=list&mainmenu=accountancy&leftmenu=accountancy_generalledger", $langs->trans("Bookkeeping"), 1, $user->rights->accounting->mouvements->lire);
 | |
| 1387 | +                $newmenu->add(BASE_URI."?controller=accountancy/bookkeeping&method=list&mainmenu=accountancy&leftmenu=accountancy_generalledger", $langs->trans("Bookkeeping"), 1, $user->rights->accounting->mouvements->lire);
 | |
| 1388 | 1388 | |
| 1389 | 1389 | // Balance | 
| 1390 | 1390 |  //$newmenu->add("/accountancy/bookkeeping/balance.php?mainmenu=accountancy&leftmenu=accountancy_balance", $langs->trans("AccountBalance"), 1, $user->rights->accounting->mouvements->lire);
 | 
| 1391 | -                $newmenu->add(BASE_URI . "?controller=accountancy/bookkeeping&method=balance&mainmenu=accountancy&leftmenu=accountancy_balance", $langs->trans("AccountBalance"), 1, $user->rights->accounting->mouvements->lire);
 | |
| 1391 | +                $newmenu->add(BASE_URI."?controller=accountancy/bookkeeping&method=balance&mainmenu=accountancy&leftmenu=accountancy_balance", $langs->trans("AccountBalance"), 1, $user->rights->accounting->mouvements->lire);
 | |
| 1392 | 1392 | |
| 1393 | 1393 | // Files | 
| 1394 | 1394 |                  if (!empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL > 2) {
 | 
| 1395 | 1395 |  //$newmenu->add("/compta/compta-files.php?mainmenu=accountancy&leftmenu=accountancy_files", $langs->trans("AccountantFiles"), 1, $user->rights->accounting->mouvements->lire);
 | 
| 1396 | -                    $newmenu->add(BASE_URI . "?controller=compta&method=compta-files&mainmenu=accountancy&leftmenu=accountancy_files", $langs->trans("AccountantFiles"), 1, $user->rights->accounting->mouvements->lire);
 | |
| 1396 | +                    $newmenu->add(BASE_URI."?controller=compta&method=compta-files&mainmenu=accountancy&leftmenu=accountancy_files", $langs->trans("AccountantFiles"), 1, $user->rights->accounting->mouvements->lire);
 | |
| 1397 | 1397 | } | 
| 1398 | 1398 | |
| 1399 | 1399 | // Reports | 
| 1400 | 1400 |                  $langs->load("compta");
 | 
| 1401 | 1401 | |
| 1402 | 1402 |  //$newmenu->add("/compta/resultat/index.php?mainmenu=accountancy&leftmenu=accountancy_report", $langs->trans("Reportings"), 1, $user->rights->accounting->comptarapport->lire, '', $mainmenu, 'ca');
 | 
| 1403 | -                $newmenu->add(BASE_URI . "?controller=compta/resultat&method=index&mainmenu=accountancy&leftmenu=accountancy_report", $langs->trans("Reportings"), 1, $user->rights->accounting->comptarapport->lire, '', $mainmenu, 'ca');
 | |
| 1403 | +                $newmenu->add(BASE_URI."?controller=compta/resultat&method=index&mainmenu=accountancy&leftmenu=accountancy_report", $langs->trans("Reportings"), 1, $user->rights->accounting->comptarapport->lire, '', $mainmenu, 'ca');
 | |
| 1404 | 1404 | |
| 1405 | 1405 |                  if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
 | 
| 1406 | 1406 |  //$newmenu->add("/compta/resultat/index.php?leftmenu=accountancy_report", $langs->trans("MenuReportInOut"), 2, $user->rights->accounting->comptarapport->lire);
 | 
| 1407 | 1407 |  //$newmenu->add("/compta/resultat/clientfourn.php?leftmenu=accountancy_report", $langs->trans("ByPredefinedAccountGroups"), 3, $user->rights->accounting->comptarapport->lire);
 | 
| 1408 | 1408 |  //$newmenu->add("/compta/resultat/result.php?leftmenu=accountancy_report", $langs->trans("ByPersonalizedAccountGroups"), 3, $user->rights->accounting->comptarapport->lire);
 | 
| 1409 | -                    $newmenu->add(BASE_URI . "?controller=compta/resultat&method=index&leftmenu=accountancy_report", $langs->trans("MenuReportInOut"), 2, $user->rights->accounting->comptarapport->lire);
 | |
| 1410 | -                    $newmenu->add(BASE_URI . "?controller=compta/resultat&method=clientfourn&leftmenu=accountancy_report", $langs->trans("ByPredefinedAccountGroups"), 3, $user->rights->accounting->comptarapport->lire);
 | |
| 1411 | -                    $newmenu->add(BASE_URI . "?controller=compta/resultat&method=result&leftmenu=accountancy_report", $langs->trans("ByPersonalizedAccountGroups"), 3, $user->rights->accounting->comptarapport->lire);
 | |
| 1409 | +                    $newmenu->add(BASE_URI."?controller=compta/resultat&method=index&leftmenu=accountancy_report", $langs->trans("MenuReportInOut"), 2, $user->rights->accounting->comptarapport->lire);
 | |
| 1410 | +                    $newmenu->add(BASE_URI."?controller=compta/resultat&method=clientfourn&leftmenu=accountancy_report", $langs->trans("ByPredefinedAccountGroups"), 3, $user->rights->accounting->comptarapport->lire);
 | |
| 1411 | +                    $newmenu->add(BASE_URI."?controller=compta/resultat&method=result&leftmenu=accountancy_report", $langs->trans("ByPersonalizedAccountGroups"), 3, $user->rights->accounting->comptarapport->lire);
 | |
| 1412 | 1412 | } | 
| 1413 | 1413 | |
| 1414 | 1414 | $modecompta = 'CREANCES-DETTES'; | 
| @@ -1423,11 +1423,11 @@ discard block | ||
| 1423 | 1423 |                            $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=accountancy_report&modecompta = " . $modecompta, $langs->trans("ByProductsAndServices"), 3, $user->rights->accounting->comptarapport->lire);
 | 
| 1424 | 1424 |                            $newmenu->add("/compta/stats/byratecountry.php?leftmenu=accountancy_report&modecompta = " . $modecompta, $langs->trans("ByVatRate"), 3, $user->rights->accounting->comptarapport->lire);
 | 
| 1425 | 1425 | */ | 
| 1426 | -                        $newmenu->add(BASE_URI . "?controller=compta/stats&method=index&leftmenu=accountancy_report&modecompta = " . $modecompta, $langs->trans("ReportTurnover"), 2, $user->rights->accounting->comptarapport->lire);
 | |
| 1427 | -                        $newmenu->add(BASE_URI . "?controller=compta/stats&method=casoc&leftmenu=accountancy_report&modecompta = " . $modecompta, $langs->trans("ByCompanies"), 3, $user->rights->accounting->comptarapport->lire);
 | |
| 1428 | -                        $newmenu->add(BASE_URI . "?controller=compta/stats&method=cabyuser&leftmenu=accountancy_report&modecompta = " . $modecompta, $langs->trans("ByUsers"), 3, $user->rights->accounting->comptarapport->lire);
 | |
| 1429 | -                        $newmenu->add(BASE_URI . "?controller=compta/stats&method=cabyprodserv&leftmenu=accountancy_report&modecompta = " . $modecompta, $langs->trans("ByProductsAndServices"), 3, $user->rights->accounting->comptarapport->lire);
 | |
| 1430 | -                        $newmenu->add(BASE_URI . "?controller=compta/stats&method=byratecountry&leftmenu=accountancy_report&modecompta = " . $modecompta, $langs->trans("ByVatRate"), 3, $user->rights->accounting->comptarapport->lire);
 | |
| 1426 | +                        $newmenu->add(BASE_URI."?controller=compta/stats&method=index&leftmenu=accountancy_report&modecompta = ".$modecompta, $langs->trans("ReportTurnover"), 2, $user->rights->accounting->comptarapport->lire);
 | |
| 1427 | +                        $newmenu->add(BASE_URI."?controller=compta/stats&method=casoc&leftmenu=accountancy_report&modecompta = ".$modecompta, $langs->trans("ByCompanies"), 3, $user->rights->accounting->comptarapport->lire);
 | |
| 1428 | +                        $newmenu->add(BASE_URI."?controller=compta/stats&method=cabyuser&leftmenu=accountancy_report&modecompta = ".$modecompta, $langs->trans("ByUsers"), 3, $user->rights->accounting->comptarapport->lire);
 | |
| 1429 | +                        $newmenu->add(BASE_URI."?controller=compta/stats&method=cabyprodserv&leftmenu=accountancy_report&modecompta = ".$modecompta, $langs->trans("ByProductsAndServices"), 3, $user->rights->accounting->comptarapport->lire);
 | |
| 1430 | +                        $newmenu->add(BASE_URI."?controller=compta/stats&method=byratecountry&leftmenu=accountancy_report&modecompta = ".$modecompta, $langs->trans("ByVatRate"), 3, $user->rights->accounting->comptarapport->lire);
 | |
| 1431 | 1431 | } | 
| 1432 | 1432 | } | 
| 1433 | 1433 | |
| @@ -1438,9 +1438,9 @@ discard block | ||
| 1438 | 1438 |  //$newmenu->add("/compta/stats/index.php?leftmenu=accountancy_report&modecompta = " . $modecompta, $langs->trans("ReportTurnoverCollected"), 2, $user->rights->accounting->comptarapport->lire);
 | 
| 1439 | 1439 |  //$newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report&modecompta = " . $modecompta, $langs->trans("ByCompanies"), 3, $user->rights->accounting->comptarapport->lire);
 | 
| 1440 | 1440 |  //$newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report&modecompta = " . $modecompta, $langs->trans("ByUsers"), 3, $user->rights->accounting->comptarapport->lire);
 | 
| 1441 | -                        $newmenu->add(BASE_URI . "?controller=compta/stats&method=index&leftmenu=accountancy_report&modecompta = " . $modecompta, $langs->trans("ReportTurnoverCollected"), 2, $user->rights->accounting->comptarapport->lire);
 | |
| 1442 | -                        $newmenu->add(BASE_URI . "?controller=compta/stats&method=casoc&leftmenu=accountancy_report&modecompta = " . $modecompta, $langs->trans("ByCompanies"), 3, $user->rights->accounting->comptarapport->lire);
 | |
| 1443 | -                        $newmenu->add(BASE_URI . "?controller=compta/stats&method=cabyuser&leftmenu=accountancy_report&modecompta = " . $modecompta, $langs->trans("ByUsers"), 3, $user->rights->accounting->comptarapport->lire);
 | |
| 1441 | +                        $newmenu->add(BASE_URI."?controller=compta/stats&method=index&leftmenu=accountancy_report&modecompta = ".$modecompta, $langs->trans("ReportTurnoverCollected"), 2, $user->rights->accounting->comptarapport->lire);
 | |
| 1442 | +                        $newmenu->add(BASE_URI."?controller=compta/stats&method=casoc&leftmenu=accountancy_report&modecompta = ".$modecompta, $langs->trans("ByCompanies"), 3, $user->rights->accounting->comptarapport->lire);
 | |
| 1443 | +                        $newmenu->add(BASE_URI."?controller=compta/stats&method=cabyuser&leftmenu=accountancy_report&modecompta = ".$modecompta, $langs->trans("ByUsers"), 3, $user->rights->accounting->comptarapport->lire);
 | |
| 1444 | 1444 |  //$newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=accountancy_report&modecompta = ".$modecompta, $langs->trans("ByProductsAndServices"),3,$user->rights->accounting->comptarapport->lire);
 | 
| 1445 | 1445 |  //$newmenu->add("/compta/stats/byratecountry.php?leftmenu=accountancy_report&modecompta = ".$modecompta, $langs->trans("ByVatRate"),3,$user->rights->accounting->comptarapport->lire);
 | 
| 1446 | 1446 | } | 
| @@ -1453,19 +1453,19 @@ discard block | ||
| 1453 | 1453 | |
| 1454 | 1454 | // Bilan, resultats | 
| 1455 | 1455 |  //$newmenu->add("/compta/resultat/index.php?leftmenu=report&mainmenu=accountancy", $langs->trans("Reportings"), 0, $user->rights->compta->resultat->lire, '', $mainmenu, 'ca');
 | 
| 1456 | -                $newmenu->add(BASE_URI . "?controller=compta/resultat&method=index&leftmenu=report&mainmenu=accountancy", $langs->trans("Reportings"), 0, $user->rights->compta->resultat->lire, '', $mainmenu, 'ca');
 | |
| 1456 | +                $newmenu->add(BASE_URI."?controller=compta/resultat&method=index&leftmenu=report&mainmenu=accountancy", $langs->trans("Reportings"), 0, $user->rights->compta->resultat->lire, '', $mainmenu, 'ca');
 | |
| 1457 | 1457 | |
| 1458 | 1458 |                  if ($usemenuhider || empty($leftmenu) || preg_match('/report/', $leftmenu)) {
 | 
| 1459 | 1459 |  //$newmenu->add("/compta/resultat/index.php?leftmenu=report", $langs->trans("MenuReportInOut"), 1, $user->rights->compta->resultat->lire);
 | 
| 1460 | 1460 |  //$newmenu->add("/compta/resultat/clientfourn.php?leftmenu=report", $langs->trans("ByCompanies"), 2, $user->rights->compta->resultat->lire);
 | 
| 1461 | -                    $newmenu->add(BASE_URI . "?controller=compta/resultat&method=index&leftmenu=report", $langs->trans("MenuReportInOut"), 1, $user->rights->compta->resultat->lire);
 | |
| 1462 | -                    $newmenu->add(BASE_URI . "?controller=compta/resultat&method=clientfourn&leftmenu=report", $langs->trans("ByCompanies"), 2, $user->rights->compta->resultat->lire);
 | |
| 1461 | +                    $newmenu->add(BASE_URI."?controller=compta/resultat&method=index&leftmenu=report", $langs->trans("MenuReportInOut"), 1, $user->rights->compta->resultat->lire);
 | |
| 1462 | +                    $newmenu->add(BASE_URI."?controller=compta/resultat&method=clientfourn&leftmenu=report", $langs->trans("ByCompanies"), 2, $user->rights->compta->resultat->lire);
 | |
| 1463 | 1463 | /* On verra ca avec module compabilite expert | 
| 1464 | 1464 |                        $newmenu->add("/compta/resultat/compteres.php?leftmenu=report","Compte de resultat",2,$user->rights->compta->resultat->lire);
 | 
| 1465 | 1465 |                        $newmenu->add("/compta/resultat/bilan.php?leftmenu=report","Bilan",2,$user->rights->compta->resultat->lire);
 | 
| 1466 | 1466 | */ | 
| 1467 | 1467 |  //$newmenu->add("/compta/stats/index.php?leftmenu=report", $langs->trans("ReportTurnover"), 1, $user->rights->compta->resultat->lire);
 | 
| 1468 | -                    $newmenu->add(BASE_URI . "?controller=compta/stats&method=index&leftmenu=report", $langs->trans("ReportTurnover"), 1, $user->rights->compta->resultat->lire);
 | |
| 1468 | +                    $newmenu->add(BASE_URI."?controller=compta/stats&method=index&leftmenu=report", $langs->trans("ReportTurnover"), 1, $user->rights->compta->resultat->lire);
 | |
| 1469 | 1469 | |
| 1470 | 1470 | /* | 
| 1471 | 1471 |                        $newmenu->add("/compta/stats/cumul.php?leftmenu=report","Cumule",2,$user->rights->compta->resultat->lire);
 | 
| @@ -1478,16 +1478,16 @@ discard block | ||
| 1478 | 1478 |  //$newmenu->add("/compta/stats/cabyuser.php?leftmenu=report", $langs->trans("ByUsers"), 2, $user->rights->compta->resultat->lire);
 | 
| 1479 | 1479 |  //$newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=report", $langs->trans("ByProductsAndServices"), 2, $user->rights->compta->resultat->lire);
 | 
| 1480 | 1480 |  //$newmenu->add("/compta/stats/byratecountry.php?leftmenu=report", $langs->trans("ByVatRate"), 2, $user->rights->compta->resultat->lire);
 | 
| 1481 | -                    $newmenu->add(BASE_URI . "?controller=compta/stats&method=casoc&leftmenu=report", $langs->trans("ByCompanies"), 2, $user->rights->compta->resultat->lire);
 | |
| 1482 | -                    $newmenu->add(BASE_URI . "?controller=compta/stats&method=cabyuser&leftmenu=report", $langs->trans("ByUsers"), 2, $user->rights->compta->resultat->lire);
 | |
| 1483 | -                    $newmenu->add(BASE_URI . "?controller=compta/stats&method=cabyprodserv&leftmenu=report", $langs->trans("ByProductsAndServices"), 2, $user->rights->compta->resultat->lire);
 | |
| 1484 | -                    $newmenu->add(BASE_URI . "?controller=compta/stats&method=byratecountry&leftmenu=report", $langs->trans("ByVatRate"), 2, $user->rights->compta->resultat->lire);
 | |
| 1481 | +                    $newmenu->add(BASE_URI."?controller=compta/stats&method=casoc&leftmenu=report", $langs->trans("ByCompanies"), 2, $user->rights->compta->resultat->lire);
 | |
| 1482 | +                    $newmenu->add(BASE_URI."?controller=compta/stats&method=cabyuser&leftmenu=report", $langs->trans("ByUsers"), 2, $user->rights->compta->resultat->lire);
 | |
| 1483 | +                    $newmenu->add(BASE_URI."?controller=compta/stats&method=cabyprodserv&leftmenu=report", $langs->trans("ByProductsAndServices"), 2, $user->rights->compta->resultat->lire);
 | |
| 1484 | +                    $newmenu->add(BASE_URI."?controller=compta/stats&method=byratecountry&leftmenu=report", $langs->trans("ByVatRate"), 2, $user->rights->compta->resultat->lire);
 | |
| 1485 | 1485 | |
| 1486 | 1486 | // Journaux | 
| 1487 | 1487 |  //$newmenu->add("/compta/journal/sellsjournal.php?leftmenu=report", $langs->trans("SellsJournal"), 1, $user->rights->compta->resultat->lire, '', '', '', 50);
 | 
| 1488 | 1488 |  //$newmenu->add("/compta/journal/purchasesjournal.php?leftmenu=report", $langs->trans("PurchasesJournal"), 1, $user->rights->compta->resultat->lire, '', '', '', 51);
 | 
| 1489 | -                    $newmenu->add(BASE_URI . "?controller=compta/journal&method=sellsjournal&leftmenu=report", $langs->trans("SellsJournal"), 1, $user->rights->compta->resultat->lire, '', '', '', 50);
 | |
| 1490 | -                    $newmenu->add(BASE_URI . "?controller=compta/journal&method=purchasesjournal&leftmenu=report", $langs->trans("PurchasesJournal"), 1, $user->rights->compta->resultat->lire, '', '', '', 51);
 | |
| 1489 | +                    $newmenu->add(BASE_URI."?controller=compta/journal&method=sellsjournal&leftmenu=report", $langs->trans("SellsJournal"), 1, $user->rights->compta->resultat->lire, '', '', '', 50);
 | |
| 1490 | +                    $newmenu->add(BASE_URI."?controller=compta/journal&method=purchasesjournal&leftmenu=report", $langs->trans("PurchasesJournal"), 1, $user->rights->compta->resultat->lire, '', '', '', 51);
 | |
| 1491 | 1491 | } | 
| 1492 | 1492 |  //if ($leftmenu=="ca") $newmenu->add("/compta/journaux/index.php?leftmenu=ca",$langs->trans("Journaux"),1,$user->rights->compta->resultat->lire||$user->rights->accounting->comptarapport->lire);
 | 
| 1493 | 1493 | } | 
| @@ -1499,15 +1499,15 @@ discard block | ||
| 1499 | 1499 |  //$newmenu->add("/asset/card.php?action=create", $langs->trans("MenuNewAsset"), 1, $user->rights->asset->write);
 | 
| 1500 | 1500 |  //$newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuListAssets"), 1, $user->rights->asset->read);
 | 
| 1501 | 1501 |  //$newmenu->add("/asset/type.php?leftmenu=asset_type", $langs->trans("MenuTypeAssets"), 1, $user->rights->asset->read, '', $mainmenu, 'asset_type');
 | 
| 1502 | -                $newmenu->add(BASE_URI . "?controller=asset&method=list&leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuAssets"), 0, $user->rights->asset->read, '', $mainmenu, 'asset');
 | |
| 1503 | -                $newmenu->add(BASE_URI . "?controller=asset&method=card&action=create", $langs->trans("MenuNewAsset"), 1, $user->rights->asset->write);
 | |
| 1504 | -                $newmenu->add(BASE_URI . "?controller=asset&method=list&leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuListAssets"), 1, $user->rights->asset->read);
 | |
| 1505 | -                $newmenu->add(BASE_URI . "?controller=asset&method=type&leftmenu=asset_type", $langs->trans("MenuTypeAssets"), 1, $user->rights->asset->read, '', $mainmenu, 'asset_type');
 | |
| 1502 | +                $newmenu->add(BASE_URI."?controller=asset&method=list&leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuAssets"), 0, $user->rights->asset->read, '', $mainmenu, 'asset');
 | |
| 1503 | +                $newmenu->add(BASE_URI."?controller=asset&method=card&action=create", $langs->trans("MenuNewAsset"), 1, $user->rights->asset->write);
 | |
| 1504 | +                $newmenu->add(BASE_URI."?controller=asset&method=list&leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuListAssets"), 1, $user->rights->asset->read);
 | |
| 1505 | +                $newmenu->add(BASE_URI."?controller=asset&method=type&leftmenu=asset_type", $langs->trans("MenuTypeAssets"), 1, $user->rights->asset->read, '', $mainmenu, 'asset_type');
 | |
| 1506 | 1506 |                  if ($usemenuhider || empty($leftmenu) || preg_match('/asset_type/', $leftmenu)) {
 | 
| 1507 | 1507 |  //$newmenu->add("/asset/type.php?leftmenu=asset_type&action=create", $langs->trans("MenuNewTypeAssets"), 2, $user->rights->asset->write);
 | 
| 1508 | 1508 |  //$newmenu->add("/asset/type.php?leftmenu=asset_type", $langs->trans("MenuListTypeAssets"), 2, $user->rights->asset->read);
 | 
| 1509 | -                    $newmenu->add(BASE_URI . "?controller=asset&method=type&leftmenu=asset_type&action=create", $langs->trans("MenuNewTypeAssets"), 2, $user->rights->asset->write);
 | |
| 1510 | -                    $newmenu->add(BASE_URI . "?controller=asset&mtehod=type&leftmenu=asset_type", $langs->trans("MenuListTypeAssets"), 2, $user->rights->asset->read);
 | |
| 1509 | +                    $newmenu->add(BASE_URI."?controller=asset&method=type&leftmenu=asset_type&action=create", $langs->trans("MenuNewTypeAssets"), 2, $user->rights->asset->write);
 | |
| 1510 | +                    $newmenu->add(BASE_URI."?controller=asset&mtehod=type&leftmenu=asset_type", $langs->trans("MenuListTypeAssets"), 2, $user->rights->asset->read);
 | |
| 1511 | 1511 | } | 
| 1512 | 1512 | } | 
| 1513 | 1513 | } | 
| @@ -1532,28 +1532,28 @@ discard block | ||
| 1532 | 1532 | |
| 1533 | 1533 |                    $newmenu->add("/compta/bank/transfer.php", $langs->trans("MenuBankInternalTransfer"), 1, $user->rights->banque->transfer);
 | 
| 1534 | 1534 | */ | 
| 1535 | -                $newmenu->add(BASE_URI . "?controller=compta/bank&method=list&leftmenu=bank&mainmenu=bank", $langs->trans("MenuBankCash"), 0, $user->rights->banque->lire, '', $mainmenu, 'bank');
 | |
| 1535 | +                $newmenu->add(BASE_URI."?controller=compta/bank&method=list&leftmenu=bank&mainmenu=bank", $langs->trans("MenuBankCash"), 0, $user->rights->banque->lire, '', $mainmenu, 'bank');
 | |
| 1536 | 1536 | |
| 1537 | -                $newmenu->add(BASE_URI . "?controller=compta/bank&method=card&action=create", $langs->trans("MenuNewFinancialAccount"), 1, $user->rights->banque->configurer);
 | |
| 1538 | -                $newmenu->add(BASE_URI . "?controller=compta/bank&method=list&leftmenu=bank&mainmenu=bank", $langs->trans("List"), 1, $user->rights->banque->lire, '', $mainmenu, 'bank');
 | |
| 1539 | -                $newmenu->add(BASE_URI . "?controller=compta/bank&method=bankentries_list", $langs->trans("ListTransactions"), 1, $user->rights->banque->lire);
 | |
| 1540 | -                $newmenu->add(BASE_URI . "?controller=compta/bank&method=budget", $langs->trans("ListTransactionsByCategory"), 1, $user->rights->banque->lire);
 | |
| 1537 | +                $newmenu->add(BASE_URI."?controller=compta/bank&method=card&action=create", $langs->trans("MenuNewFinancialAccount"), 1, $user->rights->banque->configurer);
 | |
| 1538 | +                $newmenu->add(BASE_URI."?controller=compta/bank&method=list&leftmenu=bank&mainmenu=bank", $langs->trans("List"), 1, $user->rights->banque->lire, '', $mainmenu, 'bank');
 | |
| 1539 | +                $newmenu->add(BASE_URI."?controller=compta/bank&method=bankentries_list", $langs->trans("ListTransactions"), 1, $user->rights->banque->lire);
 | |
| 1540 | +                $newmenu->add(BASE_URI."?controller=compta/bank&method=budget", $langs->trans("ListTransactionsByCategory"), 1, $user->rights->banque->lire);
 | |
| 1541 | 1541 | |
| 1542 | -                $newmenu->add(BASE_URI . "?controller=compta/bank&method=transfer", $langs->trans("MenuBankInternalTransfer"), 1, $user->rights->banque->transfer);
 | |
| 1542 | +                $newmenu->add(BASE_URI."?controller=compta/bank&method=transfer", $langs->trans("MenuBankInternalTransfer"), 1, $user->rights->banque->transfer);
 | |
| 1543 | 1543 | } | 
| 1544 | 1544 | |
| 1545 | 1545 |              if (!empty($conf->categorie->enabled)) {
 | 
| 1546 | 1546 |                  $langs->load("categories");
 | 
| 1547 | 1547 |  //$newmenu->add("/categories/index.php?type = 5", $langs->trans("Rubriques"), 1, $user->rights->categorie->creer, '', $mainmenu, 'tags');
 | 
| 1548 | 1548 |  //$newmenu->add("/compta/bank/categ.php", $langs->trans("RubriquesTransactions"), 1, $user->rights->categorie->creer, '', $mainmenu, 'tags');
 | 
| 1549 | -                $newmenu->add(BASE_URI . "?controller=categories&method=index&type=5", $langs->trans("Rubriques"), 1, $user->rights->categorie->creer, '', $mainmenu, 'tags');
 | |
| 1550 | -                $newmenu->add(BASE_URI . "?controller=compta/bank&method=categ", $langs->trans("RubriquesTransactions"), 1, $user->rights->categorie->creer, '', $mainmenu, 'tags');
 | |
| 1549 | +                $newmenu->add(BASE_URI."?controller=categories&method=index&type=5", $langs->trans("Rubriques"), 1, $user->rights->categorie->creer, '', $mainmenu, 'tags');
 | |
| 1550 | +                $newmenu->add(BASE_URI."?controller=compta/bank&method=categ", $langs->trans("RubriquesTransactions"), 1, $user->rights->categorie->creer, '', $mainmenu, 'tags');
 | |
| 1551 | 1551 | } | 
| 1552 | 1552 | |
| 1553 | 1553 | // Prelevements | 
| 1554 | 1554 |              if (!empty($conf->prelevement->enabled)) {
 | 
| 1555 | 1555 |  //$newmenu->add("/compta/prelevement/index.php?leftmenu=withdraw&mainmenu=bank", $langs->trans("StandingOrders"), 0, $user->rights->prelevement->bons->lire, '', $mainmenu, 'withdraw');
 | 
| 1556 | -                $newmenu->add(BASE_URI . "?controller=compta/prelevement&method=index&leftmenu=withdraw&mainmenu=bank", $langs->trans("StandingOrders"), 0, $user->rights->prelevement->bons->lire, '', $mainmenu, 'withdraw');
 | |
| 1556 | +                $newmenu->add(BASE_URI."?controller=compta/prelevement&method=index&leftmenu=withdraw&mainmenu=bank", $langs->trans("StandingOrders"), 0, $user->rights->prelevement->bons->lire, '', $mainmenu, 'withdraw');
 | |
| 1557 | 1557 | |
| 1558 | 1558 |                  if ($usemenuhider || empty($leftmenu) || $leftmenu == "withdraw") {
 | 
| 1559 | 1559 |  //$newmenu->add("/compta/prelevement/demandes.php?status = 0&mainmenu=bank",$langs->trans("StandingOrderToProcess"),1,$user->rights->prelevement->bons->lire);
 | 
| @@ -1566,12 +1566,12 @@ discard block | ||
| 1566 | 1566 |                        $newmenu->add("/compta/prelevement/rejets.php?mainmenu=bank", $langs->trans("Rejects"), 1, $user->rights->prelevement->bons->lire);
 | 
| 1567 | 1567 |                        $newmenu->add("/compta/prelevement/stats.php?mainmenu=bank", $langs->trans("Statistics"), 1, $user->rights->prelevement->bons->lire);
 | 
| 1568 | 1568 | */ | 
| 1569 | -                    $newmenu->add(BASE_URI . "?controller=compta/prelevement&method=create&mainmenu=bank", $langs->trans("NewStandingOrder"), 1, $user->rights->prelevement->bons->creer);
 | |
| 1569 | +                    $newmenu->add(BASE_URI."?controller=compta/prelevement&method=create&mainmenu=bank", $langs->trans("NewStandingOrder"), 1, $user->rights->prelevement->bons->creer);
 | |
| 1570 | 1570 | |
| 1571 | -                    $newmenu->add(BASE_URI . "?controller=compta/prelevement&method=bons&mainmenu=bank", $langs->trans("WithdrawalsReceipts"), 1, $user->rights->prelevement->bons->lire);
 | |
| 1572 | -                    $newmenu->add(BASE_URI . "?controller=compta/prelevement&method=list&mainmenu=bank", $langs->trans("WithdrawalsLines"), 1, $user->rights->prelevement->bons->lire);
 | |
| 1573 | -                    $newmenu->add(BASE_URI . "?controller=compta/prelevement&method=rejets&mainmenu=bank", $langs->trans("Rejects"), 1, $user->rights->prelevement->bons->lire);
 | |
| 1574 | -                    $newmenu->add(BASE_URI . "?controller=compta/prelevement&method=stats&mainmenu=bank", $langs->trans("Statistics"), 1, $user->rights->prelevement->bons->lire);
 | |
| 1571 | +                    $newmenu->add(BASE_URI."?controller=compta/prelevement&method=bons&mainmenu=bank", $langs->trans("WithdrawalsReceipts"), 1, $user->rights->prelevement->bons->lire);
 | |
| 1572 | +                    $newmenu->add(BASE_URI."?controller=compta/prelevement&method=list&mainmenu=bank", $langs->trans("WithdrawalsLines"), 1, $user->rights->prelevement->bons->lire);
 | |
| 1573 | +                    $newmenu->add(BASE_URI."?controller=compta/prelevement&method=rejets&mainmenu=bank", $langs->trans("Rejects"), 1, $user->rights->prelevement->bons->lire);
 | |
| 1574 | +                    $newmenu->add(BASE_URI."?controller=compta/prelevement&method=stats&mainmenu=bank", $langs->trans("Statistics"), 1, $user->rights->prelevement->bons->lire);
 | |
| 1575 | 1575 | |
| 1576 | 1576 |  //$newmenu->add("/compta/prelevement/config.php",$langs->trans("Setup"),1,$user->rights->prelevement->bons->configurer);
 | 
| 1577 | 1577 | } | 
| @@ -1580,12 +1580,12 @@ discard block | ||
| 1580 | 1580 | // Gestion cheques | 
| 1581 | 1581 |              if (empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && !empty($conf->banque->enabled) && (!empty($conf->facture->enabled) || !empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))) {
 | 
| 1582 | 1582 |  //$newmenu->add("/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank", $langs->trans("MenuChequeDeposits"), 0, $user->rights->banque->cheque, '', $mainmenu, 'checks');
 | 
| 1583 | -                $newmenu->add(BASE_URI . "?controller=compta/paiement/cheque&method=index&leftmenu=checks&mainmenu=bank", $langs->trans("MenuChequeDeposits"), 0, $user->rights->banque->cheque, '', $mainmenu, 'checks');
 | |
| 1583 | +                $newmenu->add(BASE_URI."?controller=compta/paiement/cheque&method=index&leftmenu=checks&mainmenu=bank", $langs->trans("MenuChequeDeposits"), 0, $user->rights->banque->cheque, '', $mainmenu, 'checks');
 | |
| 1584 | 1584 |                  if (preg_match('/checks/', $leftmenu)) {
 | 
| 1585 | 1585 |  //$newmenu->add("/compta/paiement/cheque/card.php?leftmenu=checks_bis&action=new&mainmenu=bank", $langs->trans("NewChequeDeposit"), 1, $user->rights->banque->cheque);
 | 
| 1586 | 1586 |  //$newmenu->add("/compta/paiement/cheque/list.php?leftmenu=checks_bis&mainmenu=bank", $langs->trans("List"), 1, $user->rights->banque->cheque);
 | 
| 1587 | -                    $newmenu->add(BASE_URI . "?controller=compta/paiement/cheque&method=card&leftmenu=checks_bis&action=new&mainmenu=bank", $langs->trans("NewChequeDeposit"), 1, $user->rights->banque->cheque);
 | |
| 1588 | -                    $newmenu->add(BASE_URI . "?controller=compta/paiement/cheque&method=list&leftmenu=checks_bis&mainmenu=bank", $langs->trans("List"), 1, $user->rights->banque->cheque);
 | |
| 1587 | +                    $newmenu->add(BASE_URI."?controller=compta/paiement/cheque&method=card&leftmenu=checks_bis&action=new&mainmenu=bank", $langs->trans("NewChequeDeposit"), 1, $user->rights->banque->cheque);
 | |
| 1588 | +                    $newmenu->add(BASE_URI."?controller=compta/paiement/cheque&method=list&leftmenu=checks_bis&mainmenu=bank", $langs->trans("List"), 1, $user->rights->banque->cheque);
 | |
| 1589 | 1589 | } | 
| 1590 | 1590 | } | 
| 1591 | 1591 | |
| @@ -1595,9 +1595,9 @@ discard block | ||
| 1595 | 1595 |  //$newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("POS"), 0, $permtomakecashfence, '', $mainmenu, 'cashcontrol');
 | 
| 1596 | 1596 |  //$newmenu->add("/compta/cashcontrol/cashcontrol_card.php?action=create", $langs->trans("NewCashFence"), 1, $permtomakecashfence);
 | 
| 1597 | 1597 |  //$newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("List"), 1, $permtomakecashfence);
 | 
| 1598 | -                $newmenu->add(BASE_URI . "?controller=compta/cashcontrol&method=cashcontrol_list&action=list", $langs->trans("POS"), 0, $permtomakecashfence, '', $mainmenu, 'cashcontrol');
 | |
| 1599 | -                $newmenu->add(BASE_URI . "?controller=compta/cashcontrol&method=cashcontrol_card&action=create", $langs->trans("NewCashFence"), 1, $permtomakecashfence);
 | |
| 1600 | -                $newmenu->add(BASE_URI . "?controller=compta/cashcontrol&method=cashcontrol_list&action=list", $langs->trans("List"), 1, $permtomakecashfence);
 | |
| 1598 | +                $newmenu->add(BASE_URI."?controller=compta/cashcontrol&method=cashcontrol_list&action=list", $langs->trans("POS"), 0, $permtomakecashfence, '', $mainmenu, 'cashcontrol');
 | |
| 1599 | +                $newmenu->add(BASE_URI."?controller=compta/cashcontrol&method=cashcontrol_card&action=create", $langs->trans("NewCashFence"), 1, $permtomakecashfence);
 | |
| 1600 | +                $newmenu->add(BASE_URI."?controller=compta/cashcontrol&method=cashcontrol_list&action=list", $langs->trans("List"), 1, $permtomakecashfence);
 | |
| 1601 | 1601 | } | 
| 1602 | 1602 | } | 
| 1603 | 1603 | |
| @@ -1610,34 +1610,34 @@ discard block | ||
| 1610 | 1610 |  //$newmenu->add("/product/index.php?leftmenu=product&type=0", $langs->trans("Products"), 0, $user->rights->produit->lire, '', $mainmenu, 'product');
 | 
| 1611 | 1611 |  //$newmenu->add("/product/card.php?leftmenu=product&action=create&type=0", $langs->trans("NewProduct"), 1, $user->rights->produit->creer);
 | 
| 1612 | 1612 |  //$newmenu->add("/product/list.php?leftmenu=product&type=0", $langs->trans("List"), 1, $user->rights->produit->lire);
 | 
| 1613 | -                $newmenu->add(BASE_URI . "?controller=product&method=index&leftmenu=product&type=0", $langs->trans("Products"), 0, $user->rights->produit->lire, '', $mainmenu, 'product');
 | |
| 1614 | -                $newmenu->add(BASE_URI . "?controller=product&method=card&leftmenu=product&action=create&type=0", $langs->trans("NewProduct"), 1, $user->rights->produit->creer);
 | |
| 1615 | -                $newmenu->add(BASE_URI . "?controller=product&method=list&leftmenu=product&type=0", $langs->trans("List"), 1, $user->rights->produit->lire);
 | |
| 1613 | +                $newmenu->add(BASE_URI."?controller=product&method=index&leftmenu=product&type=0", $langs->trans("Products"), 0, $user->rights->produit->lire, '', $mainmenu, 'product');
 | |
| 1614 | +                $newmenu->add(BASE_URI."?controller=product&method=card&leftmenu=product&action=create&type=0", $langs->trans("NewProduct"), 1, $user->rights->produit->creer);
 | |
| 1615 | +                $newmenu->add(BASE_URI."?controller=product&method=list&leftmenu=product&type=0", $langs->trans("List"), 1, $user->rights->produit->lire);
 | |
| 1616 | 1616 |                  if (!empty($conf->stock->enabled)) {
 | 
| 1617 | 1617 |  //$newmenu->add("/product/reassort.php?type = 0", $langs->trans("Stocks"), 1, $user->rights->produit->lire && $user->rights->stock->lire);
 | 
| 1618 | -                    $newmenu->add(BASE_URI . "?controller=product&method=reassort&type=0", $langs->trans("Stocks"), 1, $user->rights->produit->lire && $user->rights->stock->lire);
 | |
| 1618 | +                    $newmenu->add(BASE_URI."?controller=product&method=reassort&type=0", $langs->trans("Stocks"), 1, $user->rights->produit->lire && $user->rights->stock->lire);
 | |
| 1619 | 1619 | } | 
| 1620 | 1620 |                  if (!empty($conf->productbatch->enabled)) {
 | 
| 1621 | 1621 |                      $langs->load("stocks");
 | 
| 1622 | 1622 |  //$newmenu->add("/product/reassortlot.php?type = 0", $langs->trans("StocksByLotSerial"), 1, $user->rights->produit->lire && $user->rights->stock->lire);
 | 
| 1623 | 1623 |  //$newmenu->add("/product/stock/productlot_list.php", $langs->trans("LotSerial"), 1, $user->rights->produit->lire && $user->rights->stock->lire);
 | 
| 1624 | -                    $newmenu->add(BASE_URI . "?controller=product&method=reassortlot&type=0", $langs->trans("StocksByLotSerial"), 1, $user->rights->produit->lire && $user->rights->stock->lire);
 | |
| 1625 | -                    $newmenu->add(BASE_URI . "?controller=product/stock&method=productlot_list", $langs->trans("LotSerial"), 1, $user->rights->produit->lire && $user->rights->stock->lire);
 | |
| 1624 | +                    $newmenu->add(BASE_URI."?controller=product&method=reassortlot&type=0", $langs->trans("StocksByLotSerial"), 1, $user->rights->produit->lire && $user->rights->stock->lire);
 | |
| 1625 | +                    $newmenu->add(BASE_URI."?controller=product/stock&method=productlot_list", $langs->trans("LotSerial"), 1, $user->rights->produit->lire && $user->rights->stock->lire);
 | |
| 1626 | 1626 | } | 
| 1627 | 1627 |                  if (!empty($conf->variants->enabled)) {
 | 
| 1628 | 1628 |  //$newmenu->add("/variants/list.php", $langs->trans("VariantAttributes"), 1, $user->rights->produit->lire);
 | 
| 1629 | -                    $newmenu->add(BASE_URI . "?controller=variants&method=list", $langs->trans("VariantAttributes"), 1, $user->rights->produit->lire);
 | |
| 1629 | +                    $newmenu->add(BASE_URI."?controller=variants&method=list", $langs->trans("VariantAttributes"), 1, $user->rights->produit->lire);
 | |
| 1630 | 1630 | } | 
| 1631 | 1631 |                  if (!empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->facture->enabled) || !empty($conf->fournisseur->enabled) || !empty($conf->supplier_proposal->enabled)) {
 | 
| 1632 | 1632 |  // $newmenu->add("/product/stats/card.php?id = all&leftmenu=stats&type=0", $langs->trans("Statistics"), 1, $user->rights->produit->lire && $user->rights->propale->lire);
 | 
| 1633 | -                    $newmenu->add(BASE_URI . "?controller=product/stats&method=card&id=all&leftmenu=stats&type=0", $langs->trans("Statistics"), 1, $user->rights->produit->lire && $user->rights->propale->lire);
 | |
| 1633 | +                    $newmenu->add(BASE_URI."?controller=product/stats&method=card&id=all&leftmenu=stats&type=0", $langs->trans("Statistics"), 1, $user->rights->produit->lire && $user->rights->propale->lire);
 | |
| 1634 | 1634 | } | 
| 1635 | 1635 | |
| 1636 | 1636 | // Categories | 
| 1637 | 1637 |                  if (!empty($conf->categorie->enabled)) {
 | 
| 1638 | 1638 |                      $langs->load("categories");
 | 
| 1639 | 1639 |  //$newmenu->add("/categories/index.php?leftmenu=cat&type=0", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
 | 
| 1640 | -                    $newmenu->add(BASE_URI . "?controller=categories&method=index&leftmenu=cat&type=0", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
 | |
| 1640 | +                    $newmenu->add(BASE_URI."?controller=categories&method=index&leftmenu=cat&type=0", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
 | |
| 1641 | 1641 |                      //if ($usemenuhider || empty($leftmenu) || $leftmenu=="cat") $newmenu->add("/categories/list.php", $langs->trans("List"), 1, $user->rights->categorie->lire);
 | 
| 1642 | 1642 | } | 
| 1643 | 1643 | } | 
| @@ -1647,18 +1647,18 @@ discard block | ||
| 1647 | 1647 |                  //$newmenu->add("/product/index.php?leftmenu=service&type=1", $langs->trans("Services"), 0, $user->rights->service->lire, '', $mainmenu, 'service');
 | 
| 1648 | 1648 |                  //$newmenu->add("/product/card.php?leftmenu=service&action=create&type=1", $langs->trans("NewService"), 1, $user->rights->service->creer);
 | 
| 1649 | 1649 |                  //$newmenu->add("/product/list.php?leftmenu=service&type=1", $langs->trans("List"), 1, $user->rights->service->lire);
 | 
| 1650 | -                $newmenu->add(BASE_URI . "?controller=product&method=index&leftmenu=service&type=1", $langs->trans("Services"), 0, $user->rights->service->lire, '', $mainmenu, 'service');
 | |
| 1651 | -                $newmenu->add(BASE_URI . "?controller=product&method=card&leftmenu=service&action=create&type=1", $langs->trans("NewService"), 1, $user->rights->service->creer);
 | |
| 1652 | -                $newmenu->add(BASE_URI . "?controller=product&method=list&leftmenu=service&type=1", $langs->trans("List"), 1, $user->rights->service->lire);
 | |
| 1650 | +                $newmenu->add(BASE_URI."?controller=product&method=index&leftmenu=service&type=1", $langs->trans("Services"), 0, $user->rights->service->lire, '', $mainmenu, 'service');
 | |
| 1651 | +                $newmenu->add(BASE_URI."?controller=product&method=card&leftmenu=service&action=create&type=1", $langs->trans("NewService"), 1, $user->rights->service->creer);
 | |
| 1652 | +                $newmenu->add(BASE_URI."?controller=product&method=list&leftmenu=service&type=1", $langs->trans("List"), 1, $user->rights->service->lire);
 | |
| 1653 | 1653 |                  if (!empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->facture->enabled) || !empty($conf->fournisseur->enabled) || !empty($conf->supplier_proposal->enabled)) {
 | 
| 1654 | 1654 |                      //$newmenu->add("/product/stats/card.php?id = all&leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->rights->service->lire && $user->rights->propale->lire);
 | 
| 1655 | -                    $newmenu->add(BASE_URI . "?controller=product/stats&method=card&id=all&leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->rights->service->lire && $user->rights->propale->lire);
 | |
| 1655 | +                    $newmenu->add(BASE_URI."?controller=product/stats&method=card&id=all&leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->rights->service->lire && $user->rights->propale->lire);
 | |
| 1656 | 1656 | } | 
| 1657 | 1657 | // Categories | 
| 1658 | 1658 |                  if (!empty($conf->categorie->enabled)) {
 | 
| 1659 | 1659 |                      $langs->load("categories");
 | 
| 1660 | 1660 |                      //$newmenu->add("/categories/index.php?leftmenu=cat&type=0", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
 | 
| 1661 | -                    $newmenu->add(BASE_URI . "?controller=categories&method=index&leftmenu=cat&type=0", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
 | |
| 1661 | +                    $newmenu->add(BASE_URI."?controller=categories&method=index&leftmenu=cat&type=0", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
 | |
| 1662 | 1662 |                      //if ($usemenuhider || empty($leftmenu) || $leftmenu=="cat") $newmenu->add("/categories/list.php", $langs->trans("List"), 1, $user->rights->categorie->lire);
 | 
| 1663 | 1663 | } | 
| 1664 | 1664 | } | 
| @@ -1674,15 +1674,15 @@ discard block | ||
| 1674 | 1674 | |
| 1675 | 1675 |                    $newmenu->add("/product/stock/massstockmove.php", $langs->trans("MassStockTransferShort"), 1, $user->rights->stock->mouvement->creer);
 | 
| 1676 | 1676 | */ | 
| 1677 | -                $newmenu->add(BASE_URI . "?controller=product/stock&method=index&leftmenu=stock", $langs->trans("Warehouses"), 0, $user->rights->stock->lire, '', $mainmenu, 'stock');
 | |
| 1678 | -                $newmenu->add(BASE_URI . "?controller=product/stock&method=card&action=create", $langs->trans("MenuNewWarehouse"), 1, $user->rights->stock->creer);
 | |
| 1679 | -                $newmenu->add(BASE_URI . "?controller=product/stock&method=list", $langs->trans("List"), 1, $user->rights->stock->lire);
 | |
| 1680 | -                $newmenu->add(BASE_URI . "?controller=product/stock&method=movement_list", $langs->trans("Movements"), 1, $user->rights->stock->mouvement->lire);
 | |
| 1677 | +                $newmenu->add(BASE_URI."?controller=product/stock&method=index&leftmenu=stock", $langs->trans("Warehouses"), 0, $user->rights->stock->lire, '', $mainmenu, 'stock');
 | |
| 1678 | +                $newmenu->add(BASE_URI."?controller=product/stock&method=card&action=create", $langs->trans("MenuNewWarehouse"), 1, $user->rights->stock->creer);
 | |
| 1679 | +                $newmenu->add(BASE_URI."?controller=product/stock&method=list", $langs->trans("List"), 1, $user->rights->stock->lire);
 | |
| 1680 | +                $newmenu->add(BASE_URI."?controller=product/stock&method=movement_list", $langs->trans("Movements"), 1, $user->rights->stock->mouvement->lire);
 | |
| 1681 | 1681 | |
| 1682 | -                $newmenu->add(BASE_URI . "?controller=product/stock&method=massstockmove", $langs->trans("MassStockTransferShort"), 1, $user->rights->stock->mouvement->creer);
 | |
| 1682 | +                $newmenu->add(BASE_URI."?controller=product/stock&method=massstockmove", $langs->trans("MassStockTransferShort"), 1, $user->rights->stock->mouvement->creer);
 | |
| 1683 | 1683 |                  if ($conf->supplier_order->enabled) {
 | 
| 1684 | 1684 |                      //$newmenu->add("/product/stock/replenish.php", $langs->trans("Replenishment"), 1, $user->rights->stock->mouvement->creer && $user->rights->fournisseur->lire);
 | 
| 1685 | -                    $newmenu->add(BASE_URI . "?controller=product/stock&method=replenish", $langs->trans("Replenishment"), 1, $user->rights->stock->mouvement->creer && $user->rights->fournisseur->lire);
 | |
| 1685 | +                    $newmenu->add(BASE_URI."?controller=product/stock&method=replenish", $langs->trans("Replenishment"), 1, $user->rights->stock->mouvement->creer && $user->rights->fournisseur->lire);
 | |
| 1686 | 1686 | } | 
| 1687 | 1687 | } | 
| 1688 | 1688 | |
| @@ -1694,16 +1694,16 @@ discard block | ||
| 1694 | 1694 |                          //$newmenu->add("/product/inventory/list.php?leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->lire, '', $mainmenu, 'stock');
 | 
| 1695 | 1695 |                          //$newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->creer);
 | 
| 1696 | 1696 |                          //$newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->lire);
 | 
| 1697 | -                        $newmenu->add(BASE_URI . "?controller=product/inventory&method=list&leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->lire, '', $mainmenu, 'stock');
 | |
| 1698 | -                        $newmenu->add(BASE_URI . "?controller=product/inventory&method=card&action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->creer);
 | |
| 1699 | -                        $newmenu->add(BASE_URI . "?controller=product/inventory&method=list", $langs->trans("List"), 1, $user->rights->stock->lire);
 | |
| 1697 | +                        $newmenu->add(BASE_URI."?controller=product/inventory&method=list&leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->lire, '', $mainmenu, 'stock');
 | |
| 1698 | +                        $newmenu->add(BASE_URI."?controller=product/inventory&method=card&action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->creer);
 | |
| 1699 | +                        $newmenu->add(BASE_URI."?controller=product/inventory&method=list", $langs->trans("List"), 1, $user->rights->stock->lire);
 | |
| 1700 | 1700 |                      } else {
 | 
| 1701 | 1701 |                          //$newmenu->add("/product/inventory/list.php?leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->inventory_advance->read, '', $mainmenu, 'stock');
 | 
| 1702 | 1702 |                          //$newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->inventory_advance->write);
 | 
| 1703 | 1703 |                          //$newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->inventory_advance->read);
 | 
| 1704 | -                        $newmenu->add(BASE_URI . "?controller=product/inventory&method=list&leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->inventory_advance->read, '', $mainmenu, 'stock');
 | |
| 1705 | -                        $newmenu->add(BASE_URI . "?controller=product/inventory&method=card&action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->inventory_advance->write);
 | |
| 1706 | -                        $newmenu->add(BASE_URI . "?controller=product/inventory&method=list", $langs->trans("List"), 1, $user->rights->stock->inventory_advance->read);
 | |
| 1704 | +                        $newmenu->add(BASE_URI."?controller=product/inventory&method=list&leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->inventory_advance->read, '', $mainmenu, 'stock');
 | |
| 1705 | +                        $newmenu->add(BASE_URI."?controller=product/inventory&method=card&action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->inventory_advance->write);
 | |
| 1706 | +                        $newmenu->add(BASE_URI."?controller=product/inventory&method=list", $langs->trans("List"), 1, $user->rights->stock->inventory_advance->read);
 | |
| 1707 | 1707 | } | 
| 1708 | 1708 | } | 
| 1709 | 1709 | } | 
| @@ -1714,19 +1714,19 @@ discard block | ||
| 1714 | 1714 |                  //$newmenu->add("/expedition/index.php?leftmenu=sendings", $langs->trans("Shipments"), 0, $user->rights->expedition->lire, '', $mainmenu, 'sendings');
 | 
| 1715 | 1715 |                  //$newmenu->add("/expedition/card.php?action=create2&leftmenu=sendings", $langs->trans("NewSending"), 1, $user->rights->expedition->creer);
 | 
| 1716 | 1716 |                  //$newmenu->add("/expedition/list.php?leftmenu=sendings", $langs->trans("List"), 1, $user->rights->expedition->lire);
 | 
| 1717 | -                $newmenu->add(BASE_URI . "?controller=expedition&method=index&leftmenu=sendings", $langs->trans("Shipments"), 0, $user->rights->expedition->lire, '', $mainmenu, 'sendings');
 | |
| 1718 | -                $newmenu->add(BASE_URI . "?controller=expedition&method=card&action=create2&leftmenu=sendings", $langs->trans("NewSending"), 1, $user->rights->expedition->creer);
 | |
| 1719 | -                $newmenu->add(BASE_URI . "?controller=expedition&method=list&leftmenu=sendings", $langs->trans("List"), 1, $user->rights->expedition->lire);
 | |
| 1717 | +                $newmenu->add(BASE_URI."?controller=expedition&method=index&leftmenu=sendings", $langs->trans("Shipments"), 0, $user->rights->expedition->lire, '', $mainmenu, 'sendings');
 | |
| 1718 | +                $newmenu->add(BASE_URI."?controller=expedition&method=card&action=create2&leftmenu=sendings", $langs->trans("NewSending"), 1, $user->rights->expedition->creer);
 | |
| 1719 | +                $newmenu->add(BASE_URI."?controller=expedition&method=list&leftmenu=sendings", $langs->trans("List"), 1, $user->rights->expedition->lire);
 | |
| 1720 | 1720 |                  if ($usemenuhider || empty($leftmenu) || $leftmenu == "sendings") {
 | 
| 1721 | 1721 |                      //$newmenu->add("/expedition/list.php?leftmenu=sendings&viewstatut=0", $langs->trans("StatusSendingDraftShort"), 2, $user->rights->expedition->lire);
 | 
| 1722 | 1722 |                      //$newmenu->add("/expedition/list.php?leftmenu=sendings&viewstatut=1", $langs->trans("StatusSendingValidatedShort"), 2, $user->rights->expedition->lire);
 | 
| 1723 | 1723 |                      //$newmenu->add("/expedition/list.php?leftmenu=sendings&viewstatut=2", $langs->trans("StatusSendingProcessedShort"), 2, $user->rights->expedition->lire);
 | 
| 1724 | -                    $newmenu->add(BASE_URI . "?controller=expedition&method=list&leftmenu=sendings&viewstatut=0", $langs->trans("StatusSendingDraftShort"), 2, $user->rights->expedition->lire);
 | |
| 1725 | -                    $newmenu->add(BASE_URI . "?controller=expedition&method=list&leftmenu=sendings&viewstatut=1", $langs->trans("StatusSendingValidatedShort"), 2, $user->rights->expedition->lire);
 | |
| 1726 | -                    $newmenu->add(BASE_URI . "?controller=expedition&method=list&leftmenu=sendings&viewstatut=2", $langs->trans("StatusSendingProcessedShort"), 2, $user->rights->expedition->lire);
 | |
| 1724 | +                    $newmenu->add(BASE_URI."?controller=expedition&method=list&leftmenu=sendings&viewstatut=0", $langs->trans("StatusSendingDraftShort"), 2, $user->rights->expedition->lire);
 | |
| 1725 | +                    $newmenu->add(BASE_URI."?controller=expedition&method=list&leftmenu=sendings&viewstatut=1", $langs->trans("StatusSendingValidatedShort"), 2, $user->rights->expedition->lire);
 | |
| 1726 | +                    $newmenu->add(BASE_URI."?controller=expedition&method=list&leftmenu=sendings&viewstatut=2", $langs->trans("StatusSendingProcessedShort"), 2, $user->rights->expedition->lire);
 | |
| 1727 | 1727 | } | 
| 1728 | 1728 |                  //$newmenu->add("/expedition/stats/index.php?leftmenu=sendings", $langs->trans("Statistics"), 1, $user->rights->expedition->lire);
 | 
| 1729 | -                $newmenu->add(BASE_URI . "?controller=expedition/stats&method=index&leftmenu=sendings", $langs->trans("Statistics"), 1, $user->rights->expedition->lire);
 | |
| 1729 | +                $newmenu->add(BASE_URI."?controller=expedition/stats&method=index&leftmenu=sendings", $langs->trans("Statistics"), 1, $user->rights->expedition->lire);
 | |
| 1730 | 1730 | } | 
| 1731 | 1731 | |
| 1732 | 1732 | // Receptions | 
| @@ -1735,23 +1735,23 @@ discard block | ||
| 1735 | 1735 |                  //$newmenu->add("/reception/index.php?leftmenu=receptions", $langs->trans("Receptions"), 0, $user->rights->reception->lire, '', $mainmenu, 'receptions');
 | 
| 1736 | 1736 |                  //$newmenu->add("/reception/card.php?action=create2&leftmenu=receptions", $langs->trans("NewReception"), 1, $user->rights->reception->creer);
 | 
| 1737 | 1737 |                  //$newmenu->add("/reception/list.php?leftmenu=receptions", $langs->trans("List"), 1, $user->rights->reception->lire);
 | 
| 1738 | -                $newmenu->add(BASE_URI . "?controller=reception&method=index&leftmenu=receptions", $langs->trans("Receptions"), 0, $user->rights->reception->lire, '', $mainmenu, 'receptions');
 | |
| 1739 | -                $newmenu->add(BASE_URI . "?controller=reception&method=card&action=create2&leftmenu=receptions", $langs->trans("NewReception"), 1, $user->rights->reception->creer);
 | |
| 1740 | -                $newmenu->add(BASE_URI . "?controller=reception&method=list&leftmenu=receptions", $langs->trans("List"), 1, $user->rights->reception->lire);
 | |
| 1738 | +                $newmenu->add(BASE_URI."?controller=reception&method=index&leftmenu=receptions", $langs->trans("Receptions"), 0, $user->rights->reception->lire, '', $mainmenu, 'receptions');
 | |
| 1739 | +                $newmenu->add(BASE_URI."?controller=reception&method=card&action=create2&leftmenu=receptions", $langs->trans("NewReception"), 1, $user->rights->reception->creer);
 | |
| 1740 | +                $newmenu->add(BASE_URI."?controller=reception&method=list&leftmenu=receptions", $langs->trans("List"), 1, $user->rights->reception->lire);
 | |
| 1741 | 1741 |                  if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") {
 | 
| 1742 | 1742 |                      //$newmenu->add("/reception/list.php?leftmenu=receptions&viewstatut=0", $langs->trans("StatusReceptionDraftShort"), 2, $user->rights->reception->lire);
 | 
| 1743 | -                    $newmenu->add(BASE_URI . "?controller=reception&method=list&leftmenu=receptions&viewstatut=0", $langs->trans("StatusReceptionDraftShort"), 2, $user->rights->reception->lire);
 | |
| 1743 | +                    $newmenu->add(BASE_URI."?controller=reception&method=list&leftmenu=receptions&viewstatut=0", $langs->trans("StatusReceptionDraftShort"), 2, $user->rights->reception->lire);
 | |
| 1744 | 1744 | } | 
| 1745 | 1745 |                  if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") {
 | 
| 1746 | 1746 |                      //$newmenu->add("/reception/list.php?leftmenu=receptions&viewstatut=1", $langs->trans("StatusReceptionValidatedShort"), 2, $user->rights->reception->lire);
 | 
| 1747 | -                    $newmenu->add(BASE_URI . "?controller=reception&method=list&leftmenu=receptions&viewstatut=1", $langs->trans("StatusReceptionValidatedShort"), 2, $user->rights->reception->lire);
 | |
| 1747 | +                    $newmenu->add(BASE_URI."?controller=reception&method=list&leftmenu=receptions&viewstatut=1", $langs->trans("StatusReceptionValidatedShort"), 2, $user->rights->reception->lire);
 | |
| 1748 | 1748 | } | 
| 1749 | 1749 |                  if ($usemenuhider || empty($leftmenu) || $leftmenu == "receptions") {
 | 
| 1750 | 1750 |                      //$newmenu->add("/reception/list.php?leftmenu=receptions&viewstatut=2", $langs->trans("StatusReceptionProcessedShort"), 2, $user->rights->reception->lire);
 | 
| 1751 | -                    $newmenu->add(BASE_URI . "?controller=reception&method=list&leftmenu=receptions&viewstatut=2", $langs->trans("StatusReceptionProcessedShort"), 2, $user->rights->reception->lire);
 | |
| 1751 | +                    $newmenu->add(BASE_URI."?controller=reception&method=list&leftmenu=receptions&viewstatut=2", $langs->trans("StatusReceptionProcessedShort"), 2, $user->rights->reception->lire);
 | |
| 1752 | 1752 | } | 
| 1753 | 1753 |                  //$newmenu->add("/reception/stats/index.php?leftmenu=receptions", $langs->trans("Statistics"), 1, $user->rights->reception->lire);
 | 
| 1754 | -                $newmenu->add(BASE_URI . "?controller=reception/stats&method=index&leftmenu=receptions", $langs->trans("Statistics"), 1, $user->rights->reception->lire);
 | |
| 1754 | +                $newmenu->add(BASE_URI."?controller=reception/stats&method=index&leftmenu=receptions", $langs->trans("Statistics"), 1, $user->rights->reception->lire);
 | |
| 1755 | 1755 | } | 
| 1756 | 1756 | } | 
| 1757 | 1757 | |
| @@ -1785,32 +1785,32 @@ discard block | ||
| 1785 | 1785 | // Project assigned to user | 
| 1786 | 1786 |                  //$newmenu->add("/projet/index.php?leftmenu=projects" . ($search_project_user ? '&search_project_user=' . $search_project_user : ''), $titleboth, 0, $user->rights->projet->lire, '', $mainmenu, 'projects');
 | 
| 1787 | 1787 |                  //$newmenu->add("/projet/card.php?leftmenu=projects&action=create" . ($search_project_user ? '&search_project_user=' . $search_project_user : ''), $titlenew, 1, $user->rights->projet->creer);
 | 
| 1788 | - $newmenu->add(BASE_URI . "?controller=projet&method=index&leftmenu=projects" . ($search_project_user ? '&search_project_user=' . $search_project_user : ''), $titleboth, 0, $user->rights->projet->lire, '', $mainmenu, 'projects'); | |
| 1789 | - $newmenu->add(BASE_URI . "?controller=projet&method=card&leftmenu=projects&action=create" . ($search_project_user ? '&search_project_user=' . $search_project_user : ''), $titlenew, 1, $user->rights->projet->creer); | |
| 1788 | + $newmenu->add(BASE_URI."?controller=projet&method=index&leftmenu=projects".($search_project_user ? '&search_project_user='.$search_project_user : ''), $titleboth, 0, $user->rights->projet->lire, '', $mainmenu, 'projects'); | |
| 1789 | + $newmenu->add(BASE_URI."?controller=projet&method=card&leftmenu=projects&action=create".($search_project_user ? '&search_project_user='.$search_project_user : ''), $titlenew, 1, $user->rights->projet->creer); | |
| 1790 | 1790 | |
| 1791 | 1791 |                  if ($conf->global->PROJECT_USE_OPPORTUNITIES == 0) {
 | 
| 1792 | 1792 |                      //$newmenu->add("/projet/list.php?leftmenu=projets" . ($search_project_user ? '&search_project_user=' . $search_project_user : '') . '&search_status=99', $langs->trans("List"), 1, $showmode, '', 'project', 'list');
 | 
| 1793 | -                    $newmenu->add(BASE_URI . "?controller=projet&method=list&leftmenu=projets" . ($search_project_user ? '&search_project_user=' . $search_project_user : '') . '&search_status=99', $langs->trans("List"), 1, $showmode, '', 'project', 'list');
 | |
| 1793 | +                    $newmenu->add(BASE_URI."?controller=projet&method=list&leftmenu=projets".($search_project_user ? '&search_project_user='.$search_project_user : '').'&search_status=99', $langs->trans("List"), 1, $showmode, '', 'project', 'list');
 | |
| 1794 | 1794 |                  } elseif ($conf->global->PROJECT_USE_OPPORTUNITIES == 1) {
 | 
| 1795 | 1795 |                      //$newmenu->add("/projet/list.php?leftmenu=projets" . ($search_project_user ? '&search_project_user=' . $search_project_user : ''), $langs->trans("List"), 1, $showmode, '', 'project', 'list');
 | 
| 1796 | 1796 |                      //$newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_opp_status=openedopp&search_status=99&contextpage=lead', $langs->trans("ListOpenLeads"), 2, $showmode);
 | 
| 1797 | 1797 |                      //$newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_opp_status=notopenedopp&search_status=99&contextpage=project', $langs->trans("ListOpenProjects"), 2, $showmode);
 | 
| 1798 | -                    $newmenu->add(BASE_URI . "?controller=projet&method=list&leftmenu=projets" . ($search_project_user ? '&search_project_user=' . $search_project_user : ''), $langs->trans("List"), 1, $showmode, '', 'project', 'list');
 | |
| 1799 | -                    $newmenu->add(BASE_URI . '?controller=projet&method=list&mainmenu=project&leftmenu=list&search_opp_status=openedopp&search_status=99&contextpage=lead', $langs->trans("ListOpenLeads"), 2, $showmode);
 | |
| 1800 | -                    $newmenu->add(BASE_URI . '?controller=projet&method=list&mainmenu=project&leftmenu=list&search_opp_status=notopenedopp&search_status=99&contextpage=project', $langs->trans("ListOpenProjects"), 2, $showmode);
 | |
| 1798 | +                    $newmenu->add(BASE_URI."?controller=projet&method=list&leftmenu=projets".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $showmode, '', 'project', 'list');
 | |
| 1799 | +                    $newmenu->add(BASE_URI.'?controller=projet&method=list&mainmenu=project&leftmenu=list&search_opp_status=openedopp&search_status=99&contextpage=lead', $langs->trans("ListOpenLeads"), 2, $showmode);
 | |
| 1800 | +                    $newmenu->add(BASE_URI.'?controller=projet&method=list&mainmenu=project&leftmenu=list&search_opp_status=notopenedopp&search_status=99&contextpage=project', $langs->trans("ListOpenProjects"), 2, $showmode);
 | |
| 1801 | 1801 |                  } elseif ($conf->global->PROJECT_USE_OPPORTUNITIES == 2) { // 2 = leads only
 | 
| 1802 | 1802 |                      //$newmenu->add('/projet/list.php?mainmenu=project&leftmenu=list&search_opp_status=openedopp&search_status=99', $langs->trans("List"), 2, $showmode);
 | 
| 1803 | -                    $newmenu->add(BASE_URI . '?controller=projet&method=list&mainmenu=project&leftmenu=list&search_opp_status=openedopp&search_status=99', $langs->trans("List"), 2, $showmode);
 | |
| 1803 | +                    $newmenu->add(BASE_URI.'?controller=projet&method=list&mainmenu=project&leftmenu=list&search_opp_status=openedopp&search_status=99', $langs->trans("List"), 2, $showmode);
 | |
| 1804 | 1804 | } | 
| 1805 | 1805 | |
| 1806 | 1806 |                  //$newmenu->add("/projet/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire);
 | 
| 1807 | -                $newmenu->add(BASE_URI . "?controller=projet/stats&method=index&leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire);
 | |
| 1807 | +                $newmenu->add(BASE_URI."?controller=projet/stats&method=index&leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire);
 | |
| 1808 | 1808 | |
| 1809 | 1809 | // Categories | 
| 1810 | 1810 |                  if (!empty($conf->categorie->enabled)) {
 | 
| 1811 | 1811 |                      $langs->load("categories");
 | 
| 1812 | 1812 |                      //$newmenu->add("/categories/index.php?leftmenu=cat&type=6", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
 | 
| 1813 | -                    $newmenu->add(BASE_URI . "?controller=categories&method=index&leftmenu=cat&type=6", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
 | |
| 1813 | +                    $newmenu->add(BASE_URI."?controller=categories&method=index&leftmenu=cat&type=6", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
 | |
| 1814 | 1814 | } | 
| 1815 | 1815 | |
| 1816 | 1816 |                  if (empty($conf->global->PROJECT_HIDE_TASKS)) {
 | 
| @@ -1823,12 +1823,12 @@ discard block | ||
| 1823 | 1823 | |
| 1824 | 1824 |                        $newmenu->add("/projet/activity/perweek.php?leftmenu=tasks" . ($search_project_user ? '&search_project_user=' . $search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->rights->projet->lire);
 | 
| 1825 | 1825 | */ | 
| 1826 | -                    $newmenu->add(BASE_URI . "?controller=projet/activity&method=index&leftmenu=tasks" . ($search_project_user ? '&search_project_user=' . $search_project_user : ''), $langs->trans("Activities"), 0, $user->rights->projet->lire);
 | |
| 1827 | -                    $newmenu->add(BASE_URI . "?controller=projet&method=tasks&leftmenu=tasks&action=create", $langs->trans("NewTask"), 1, $user->rights->projet->creer);
 | |
| 1828 | -                    $newmenu->add(BASE_URI . "?controller=projet/tasks&method=list&leftmenu=tasks" . ($search_project_user ? '&search_project_user=' . $search_project_user : ''), $langs->trans("List"), 1, $user->rights->projet->lire);
 | |
| 1829 | -                    $newmenu->add(BASE_URI . "?controller=projet/tasks/stats&method=index&leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire);
 | |
| 1826 | +                    $newmenu->add(BASE_URI."?controller=projet/activity&method=index&leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("Activities"), 0, $user->rights->projet->lire);
 | |
| 1827 | +                    $newmenu->add(BASE_URI."?controller=projet&method=tasks&leftmenu=tasks&action=create", $langs->trans("NewTask"), 1, $user->rights->projet->creer);
 | |
| 1828 | +                    $newmenu->add(BASE_URI."?controller=projet/tasks&method=list&leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $user->rights->projet->lire);
 | |
| 1829 | +                    $newmenu->add(BASE_URI."?controller=projet/tasks/stats&method=index&leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire);
 | |
| 1830 | 1830 | |
| 1831 | -                    $newmenu->add(BASE_URI . "?controller=projet/activity&method=perweek&leftmenu=tasks" . ($search_project_user ? '&search_project_user=' . $search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->rights->projet->lire);
 | |
| 1831 | +                    $newmenu->add(BASE_URI."?controller=projet/activity&method=perweek&leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->rights->projet->lire);
 | |
| 1832 | 1832 | } | 
| 1833 | 1833 | } | 
| 1834 | 1834 | } | 
| @@ -1844,9 +1844,9 @@ discard block | ||
| 1844 | 1844 |                  //$newmenu->add("/user/list.php?leftmenu=hrm&mode=employee", $langs->trans("Employees"), 0, $user->rights->hrm->employee->read, '', $mainmenu, 'hrm');
 | 
| 1845 | 1845 |                  //$newmenu->add("/user/card.php?action=create&employee = 1", $langs->trans("NewEmployee"), 1, $user->rights->hrm->employee->write);
 | 
| 1846 | 1846 |                  //$newmenu->add("/user/list.php?leftmenu=hrm&mode=employee&contextpage = employeelist", $langs->trans("List"), 1, $user->rights->hrm->employee->read);
 | 
| 1847 | -                $newmenu->add(BASE_URI . "?controller=user&method=list&leftmenu=hrm&mode=employee", $langs->trans("Employees"), 0, $user->rights->hrm->employee->read, '', $mainmenu, 'hrm');
 | |
| 1848 | -                $newmenu->add(BASE_URI . "?controller=user&method=card&action=create&employee = 1", $langs->trans("NewEmployee"), 1, $user->rights->hrm->employee->write);
 | |
| 1849 | -                $newmenu->add(BASE_URI . "?controller=user&method=list&leftmenu=hrm&mode=employee&contextpage = employeelist", $langs->trans("List"), 1, $user->rights->hrm->employee->read);
 | |
| 1847 | +                $newmenu->add(BASE_URI."?controller=user&method=list&leftmenu=hrm&mode=employee", $langs->trans("Employees"), 0, $user->rights->hrm->employee->read, '', $mainmenu, 'hrm');
 | |
| 1848 | +                $newmenu->add(BASE_URI."?controller=user&method=card&action=create&employee = 1", $langs->trans("NewEmployee"), 1, $user->rights->hrm->employee->write);
 | |
| 1849 | +                $newmenu->add(BASE_URI."?controller=user&method=list&leftmenu=hrm&mode=employee&contextpage = employeelist", $langs->trans("List"), 1, $user->rights->hrm->employee->read);
 | |
| 1850 | 1850 | } | 
| 1851 | 1851 | |
| 1852 | 1852 | // Leave/Holiday/Vacation module | 
| @@ -1857,9 +1857,9 @@ discard block | ||
| 1857 | 1857 |                  //$newmenu->add("/holiday/list.php?leftmenu=hrm", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->read, '', $mainmenu, 'hrm');
 | 
| 1858 | 1858 |                  //$newmenu->add("/holiday/card.php?action=request", $langs->trans("New"), 1, $user->rights->holiday->write);
 | 
| 1859 | 1859 |                  //$newmenu->add("/holiday/list.php?leftmenu=hrm", $langs->trans("List"), 1, $user->rights->holiday->read);
 | 
| 1860 | -                $newmenu->add(BASE_URI . "?controller=holiday&method=list&leftmenu=hrm", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->read, '', $mainmenu, 'hrm');
 | |
| 1861 | -                $newmenu->add(BASE_URI . "?controller=holiday&method=card&action=request", $langs->trans("New"), 1, $user->rights->holiday->write);
 | |
| 1862 | -                $newmenu->add(BASE_URI . "?controller=holiday&method=list&leftmenu=hrm", $langs->trans("List"), 1, $user->rights->holiday->read);
 | |
| 1860 | +                $newmenu->add(BASE_URI."?controller=holiday&method=list&leftmenu=hrm", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->read, '', $mainmenu, 'hrm');
 | |
| 1861 | +                $newmenu->add(BASE_URI."?controller=holiday&method=card&action=request", $langs->trans("New"), 1, $user->rights->holiday->write);
 | |
| 1862 | +                $newmenu->add(BASE_URI."?controller=holiday&method=list&leftmenu=hrm", $langs->trans("List"), 1, $user->rights->holiday->read);
 | |
| 1863 | 1863 |                  if ($usemenuhider || empty($leftmenu) || $leftmenu == "hrm") {
 | 
| 1864 | 1864 | /* | 
| 1865 | 1865 |                        $newmenu->add("/holiday/list.php?search_statut = 1&leftmenu=hrm", $langs->trans("DraftCP"), 2, $user->rights->holiday->read);
 | 
| @@ -1868,18 +1868,18 @@ discard block | ||
| 1868 | 1868 |                        $newmenu->add("/holiday/list.php?search_statut = 4&leftmenu=hrm", $langs->trans("CancelCP"), 2, $user->rights->holiday->read);
 | 
| 1869 | 1869 |                        $newmenu->add("/holiday/list.php?search_statut = 5&leftmenu=hrm", $langs->trans("RefuseCP"), 2, $user->rights->holiday->read);
 | 
| 1870 | 1870 | */ | 
| 1871 | -                    $newmenu->add(BASE_URI . "?controller=holiday&method=list&search_statut=1&leftmenu=hrm", $langs->trans("DraftCP"), 2, $user->rights->holiday->read);
 | |
| 1872 | -                    $newmenu->add(BASE_URI . "?controller=holiday&method=list&search_statut=2&leftmenu=hrm", $langs->trans("ToReviewCP"), 2, $user->rights->holiday->read);
 | |
| 1873 | -                    $newmenu->add(BASE_URI . "?controller=holiday&method=list&search_statut=3&leftmenu=hrm", $langs->trans("ApprovedCP"), 2, $user->rights->holiday->read);
 | |
| 1874 | -                    $newmenu->add(BASE_URI . "?controller=holiday&method=list&search_statut=4&leftmenu=hrm", $langs->trans("CancelCP"), 2, $user->rights->holiday->read);
 | |
| 1875 | -                    $newmenu->add(BASE_URI . "?controller=holiday&method=list&search_statut=5&leftmenu=hrm", $langs->trans("RefuseCP"), 2, $user->rights->holiday->read);
 | |
| 1871 | +                    $newmenu->add(BASE_URI."?controller=holiday&method=list&search_statut=1&leftmenu=hrm", $langs->trans("DraftCP"), 2, $user->rights->holiday->read);
 | |
| 1872 | +                    $newmenu->add(BASE_URI."?controller=holiday&method=list&search_statut=2&leftmenu=hrm", $langs->trans("ToReviewCP"), 2, $user->rights->holiday->read);
 | |
| 1873 | +                    $newmenu->add(BASE_URI."?controller=holiday&method=list&search_statut=3&leftmenu=hrm", $langs->trans("ApprovedCP"), 2, $user->rights->holiday->read);
 | |
| 1874 | +                    $newmenu->add(BASE_URI."?controller=holiday&method=list&search_statut=4&leftmenu=hrm", $langs->trans("CancelCP"), 2, $user->rights->holiday->read);
 | |
| 1875 | +                    $newmenu->add(BASE_URI."?controller=holiday&method=list&search_statut=5&leftmenu=hrm", $langs->trans("RefuseCP"), 2, $user->rights->holiday->read);
 | |
| 1876 | 1876 | } | 
| 1877 | 1877 |                  //$newmenu->add("/holiday/define_holiday.php?action=request", $langs->trans("MenuConfCP"), 1, $user->rights->holiday->read);
 | 
| 1878 | 1878 |                  //$newmenu->add("/holiday/month_report.php", $langs->trans("MenuReportMonth"), 1, $user->rights->holiday->read_all);
 | 
| 1879 | 1879 |                  //$newmenu->add("/holiday/view_log.php?action=request", $langs->trans("MenuLogCP"), 1, $user->rights->holiday->define_holiday);
 | 
| 1880 | -                $newmenu->add(BASE_URI . "?controller=holiday&method=define_holiday&action=request", $langs->trans("MenuConfCP"), 1, $user->rights->holiday->read);
 | |
| 1881 | -                $newmenu->add(BASE_URI . "?controller=holiday&method=month_report", $langs->trans("MenuReportMonth"), 1, $user->rights->holiday->read_all);
 | |
| 1882 | -                $newmenu->add(BASE_URI . "?controller=holiday&method=view_log&action=request", $langs->trans("MenuLogCP"), 1, $user->rights->holiday->define_holiday);
 | |
| 1880 | +                $newmenu->add(BASE_URI."?controller=holiday&method=define_holiday&action=request", $langs->trans("MenuConfCP"), 1, $user->rights->holiday->read);
 | |
| 1881 | +                $newmenu->add(BASE_URI."?controller=holiday&method=month_report", $langs->trans("MenuReportMonth"), 1, $user->rights->holiday->read_all);
 | |
| 1882 | +                $newmenu->add(BASE_URI."?controller=holiday&method=view_log&action=request", $langs->trans("MenuLogCP"), 1, $user->rights->holiday->define_holiday);
 | |
| 1883 | 1883 | } | 
| 1884 | 1884 | |
| 1885 | 1885 | // Trips and expenses (old module) | 
| @@ -1891,10 +1891,10 @@ discard block | ||
| 1891 | 1891 |                    $newmenu->add("/compta/deplacement/list.php?leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("List"), 1, $user->rights->deplacement->lire);
 | 
| 1892 | 1892 |                    $newmenu->add("/compta/deplacement/stats/index.php?leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("Statistics"), 1, $user->rights->deplacement->lire);
 | 
| 1893 | 1893 | */ | 
| 1894 | -                $newmenu->add(BASE_URI . "?controller=compta/deplacement&method=index&leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->deplacement->lire, '', $mainmenu, 'tripsandexpenses');
 | |
| 1895 | -                $newmenu->add(BASE_URI . "?controller=compta/deplacement&method=card&action=create&leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("New"), 1, $user->rights->deplacement->creer);
 | |
| 1896 | -                $newmenu->add(BASE_URI . "?controller=compta/deplacement&method=list&leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("List"), 1, $user->rights->deplacement->lire);
 | |
| 1897 | -                $newmenu->add(BASE_URI . "?controller=compta/deplacement/stats&method=index&leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("Statistics"), 1, $user->rights->deplacement->lire);
 | |
| 1894 | +                $newmenu->add(BASE_URI."?controller=compta/deplacement&method=index&leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->deplacement->lire, '', $mainmenu, 'tripsandexpenses');
 | |
| 1895 | +                $newmenu->add(BASE_URI."?controller=compta/deplacement&method=card&action=create&leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("New"), 1, $user->rights->deplacement->creer);
 | |
| 1896 | +                $newmenu->add(BASE_URI."?controller=compta/deplacement&method=list&leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("List"), 1, $user->rights->deplacement->lire);
 | |
| 1897 | +                $newmenu->add(BASE_URI."?controller=compta/deplacement/stats&method=index&leftmenu=tripsandexpenses&mainmenu=hrm", $langs->trans("Statistics"), 1, $user->rights->deplacement->lire);
 | |
| 1898 | 1898 | } | 
| 1899 | 1899 | |
| 1900 | 1900 | // Expense report | 
| @@ -1914,18 +1914,18 @@ discard block | ||
| 1914 | 1914 | } | 
| 1915 | 1915 |                    $newmenu->add("/expensereport/stats/index.php?leftmenu=expensereport&mainmenu=hrm", $langs->trans("Statistics"), 1, $user->rights->expensereport->lire);
 | 
| 1916 | 1916 | */ | 
| 1917 | -                $newmenu->add(BASE_URI . "?controller=expensereport&method=index&leftmenu=expensereport&mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->expensereport->lire, '', $mainmenu, 'expensereport');
 | |
| 1918 | -                $newmenu->add(BASE_URI . "?controller=expensereport&method=card&action=create&leftmenu=expensereport&mainmenu=hrm", $langs->trans("New"), 1, $user->rights->expensereport->creer);
 | |
| 1919 | -                $newmenu->add(BASE_URI . "?controller=expensereport&method=list&leftmenu=expensereport&mainmenu=hrm", $langs->trans("List"), 1, $user->rights->expensereport->lire);
 | |
| 1917 | +                $newmenu->add(BASE_URI."?controller=expensereport&method=index&leftmenu=expensereport&mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->expensereport->lire, '', $mainmenu, 'expensereport');
 | |
| 1918 | +                $newmenu->add(BASE_URI."?controller=expensereport&method=card&action=create&leftmenu=expensereport&mainmenu=hrm", $langs->trans("New"), 1, $user->rights->expensereport->creer);
 | |
| 1919 | +                $newmenu->add(BASE_URI."?controller=expensereport&method=list&leftmenu=expensereport&mainmenu=hrm", $langs->trans("List"), 1, $user->rights->expensereport->lire);
 | |
| 1920 | 1920 |                  if ($usemenuhider || empty($leftmenu) || $leftmenu == "expensereport") {
 | 
| 1921 | -                    $newmenu->add(BASE_URI . "?controller=expensereport&method=list&search_status=0&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Draft"), 2, $user->rights->expensereport->lire);
 | |
| 1922 | -                    $newmenu->add(BASE_URI . "?controller=expensereport&method=list&search_status=2&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Validated"), 2, $user->rights->expensereport->lire);
 | |
| 1923 | -                    $newmenu->add(BASE_URI . "?controller=expensereport&method=list&search_status=5&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Approved"), 2, $user->rights->expensereport->lire);
 | |
| 1924 | -                    $newmenu->add(BASE_URI . "?controller=expensereport&method=list&search_status=6&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Paid"), 2, $user->rights->expensereport->lire);
 | |
| 1925 | -                    $newmenu->add(BASE_URI . "?controller=expensereport&method=list&search_status=4&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Canceled"), 2, $user->rights->expensereport->lire);
 | |
| 1926 | -                    $newmenu->add(BASE_URI . "?controller=expensereport&method=list&search_status=99&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Refused"), 2, $user->rights->expensereport->lire);
 | |
| 1927 | - } | |
| 1928 | -                $newmenu->add(BASE_URI . "?controller=expensereport/stats&method=index&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Statistics"), 1, $user->rights->expensereport->lire);
 | |
| 1921 | +                    $newmenu->add(BASE_URI."?controller=expensereport&method=list&search_status=0&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Draft"), 2, $user->rights->expensereport->lire);
 | |
| 1922 | +                    $newmenu->add(BASE_URI."?controller=expensereport&method=list&search_status=2&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Validated"), 2, $user->rights->expensereport->lire);
 | |
| 1923 | +                    $newmenu->add(BASE_URI."?controller=expensereport&method=list&search_status=5&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Approved"), 2, $user->rights->expensereport->lire);
 | |
| 1924 | +                    $newmenu->add(BASE_URI."?controller=expensereport&method=list&search_status=6&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Paid"), 2, $user->rights->expensereport->lire);
 | |
| 1925 | +                    $newmenu->add(BASE_URI."?controller=expensereport&method=list&search_status=4&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Canceled"), 2, $user->rights->expensereport->lire);
 | |
| 1926 | +                    $newmenu->add(BASE_URI."?controller=expensereport&method=list&search_status=99&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Refused"), 2, $user->rights->expensereport->lire);
 | |
| 1927 | + } | |
| 1928 | +                $newmenu->add(BASE_URI."?controller=expensereport/stats&method=index&leftmenu=expensereport&mainmenu=hrm", $langs->trans("Statistics"), 1, $user->rights->expensereport->lire);
 | |
| 1929 | 1929 | } | 
| 1930 | 1930 | |
| 1931 | 1931 |              if (!empty($conf->projet->enabled)) {
 | 
| @@ -1935,7 +1935,7 @@ discard block | ||
| 1935 | 1935 |                      $search_project_user = GETPOST('search_project_user', 'int');
 | 
| 1936 | 1936 | |
| 1937 | 1937 |                      //$newmenu->add("/projet/activity/perweek.php?leftmenu=tasks" . ($search_project_user ? '&search_project_user=' . $search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->rights->projet->lire);
 | 
| 1938 | -                    $newmenu->add(BASE_URI . "?controller=projet/activity&method=perweek&leftmenu=tasks" . ($search_project_user ? '&search_project_user=' . $search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->rights->projet->lire);
 | |
| 1938 | +                    $newmenu->add(BASE_URI."?controller=projet/activity&method=perweek&leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->rights->projet->lire);
 | |
| 1939 | 1939 | } | 
| 1940 | 1940 | } | 
| 1941 | 1941 | } | 
| @@ -1948,24 +1948,24 @@ discard block | ||
| 1948 | 1948 |              if (empty($user->socid)) { // limit to internal users
 | 
| 1949 | 1949 |                  $langs->load("mails");
 | 
| 1950 | 1950 |                  //$newmenu->add("/admin/mails_templates.php?leftmenu=email_templates", $langs->trans("EMailTemplates"), 0, 1, '', $mainmenu, 'email_templates');
 | 
| 1951 | -                $newmenu->add(BASE_URI . "?controller=admin&method=mails_templates&leftmenu=email_templates", $langs->trans("EMailTemplates"), 0, 1, '', $mainmenu, 'email_templates');
 | |
| 1951 | +                $newmenu->add(BASE_URI."?controller=admin&method=mails_templates&leftmenu=email_templates", $langs->trans("EMailTemplates"), 0, 1, '', $mainmenu, 'email_templates');
 | |
| 1952 | 1952 | } | 
| 1953 | 1953 | |
| 1954 | 1954 |              if (!empty($conf->mailing->enabled)) {
 | 
| 1955 | 1955 |                  //$newmenu->add("/comm/mailing/index.php?leftmenu=mailing", $langs->trans("EMailings"), 0, $user->rights->mailing->lire, '', $mainmenu, 'mailing');
 | 
| 1956 | 1956 |                  //$newmenu->add("/comm/mailing/card.php?leftmenu=mailing&action=create", $langs->trans("NewMailing"), 1, $user->rights->mailing->creer);
 | 
| 1957 | 1957 |                  //$newmenu->add("/comm/mailing/list.php?leftmenu=mailing", $langs->trans("List"), 1, $user->rights->mailing->lire);
 | 
| 1958 | -                $newmenu->add(BASE_URI . "?controller=comm/mailing&method=index&leftmenu=mailing", $langs->trans("EMailings"), 0, $user->rights->mailing->lire, '', $mainmenu, 'mailing');
 | |
| 1959 | -                $newmenu->add(BASE_URI . "?controller=comm/mailing&method=card&leftmenu=mailing&action=create", $langs->trans("NewMailing"), 1, $user->rights->mailing->creer);
 | |
| 1960 | -                $newmenu->add(BASE_URI . "?controller=comm/mailing&method=list&leftmenu=mailing", $langs->trans("List"), 1, $user->rights->mailing->lire);
 | |
| 1958 | +                $newmenu->add(BASE_URI."?controller=comm/mailing&method=index&leftmenu=mailing", $langs->trans("EMailings"), 0, $user->rights->mailing->lire, '', $mainmenu, 'mailing');
 | |
| 1959 | +                $newmenu->add(BASE_URI."?controller=comm/mailing&method=card&leftmenu=mailing&action=create", $langs->trans("NewMailing"), 1, $user->rights->mailing->creer);
 | |
| 1960 | +                $newmenu->add(BASE_URI."?controller=comm/mailing&method=list&leftmenu=mailing", $langs->trans("List"), 1, $user->rights->mailing->lire);
 | |
| 1961 | 1961 | } | 
| 1962 | 1962 | |
| 1963 | 1963 |              if (!empty($conf->export->enabled)) {
 | 
| 1964 | 1964 |                  $langs->load("exports");
 | 
| 1965 | 1965 |                  //$newmenu->add("/exports/index.php?leftmenu=export", $langs->trans("FormatedExport"), 0, $user->rights->export->lire, '', $mainmenu, 'export');
 | 
| 1966 | 1966 |                  //$newmenu->add("/exports/export.php?leftmenu=export", $langs->trans("NewExport"), 1, $user->rights->export->creer);
 | 
| 1967 | -                $newmenu->add(BASE_URI . "?controller=exports&methodindex&leftmenu=export", $langs->trans("FormatedExport"), 0, $user->rights->export->lire, '', $mainmenu, 'export');
 | |
| 1968 | -                $newmenu->add(BASE_URI . "?controller=exports&method=export&leftmenu=export", $langs->trans("NewExport"), 1, $user->rights->export->creer);
 | |
| 1967 | +                $newmenu->add(BASE_URI."?controller=exports&methodindex&leftmenu=export", $langs->trans("FormatedExport"), 0, $user->rights->export->lire, '', $mainmenu, 'export');
 | |
| 1968 | +                $newmenu->add(BASE_URI."?controller=exports&method=export&leftmenu=export", $langs->trans("NewExport"), 1, $user->rights->export->creer);
 | |
| 1969 | 1969 |                  //$newmenu->add("/exports/export.php?leftmenu=export",$langs->trans("List"),1, $user->rights->export->lire);
 | 
| 1970 | 1970 | } | 
| 1971 | 1971 | |
| @@ -1973,8 +1973,8 @@ discard block | ||
| 1973 | 1973 |                  $langs->load("exports");
 | 
| 1974 | 1974 |                  //$newmenu->add("/imports/index.php?leftmenu=import", $langs->trans("FormatedImport"), 0, $user->rights->import->run, '', $mainmenu, 'import');
 | 
| 1975 | 1975 |                  //$newmenu->add("/imports/import.php?leftmenu=import", $langs->trans("NewImport"), 1, $user->rights->import->run);
 | 
| 1976 | -                $newmenu->add(BASE_URI . "?controller=imports&method=index&leftmenu=import", $langs->trans("FormatedImport"), 0, $user->rights->import->run, '', $mainmenu, 'import');
 | |
| 1977 | -                $newmenu->add(BASE_URI . "?controller=imports&method=import&leftmenu=import", $langs->trans("NewImport"), 1, $user->rights->import->run);
 | |
| 1976 | +                $newmenu->add(BASE_URI."?controller=imports&method=index&leftmenu=import", $langs->trans("FormatedImport"), 0, $user->rights->import->run, '', $mainmenu, 'import');
 | |
| 1977 | +                $newmenu->add(BASE_URI."?controller=imports&method=import&leftmenu=import", $langs->trans("NewImport"), 1, $user->rights->import->run);
 | |
| 1978 | 1978 | } | 
| 1979 | 1979 | } | 
| 1980 | 1980 | |
| @@ -2017,30 +2017,30 @@ discard block | ||
| 2017 | 2017 |                    $newmenu->add("/adherents/type.php?leftmenu=setup&mainmenu=members&action=create", $langs->trans("New"), 1, $user->rights->adherent->configurer);
 | 
| 2018 | 2018 |                    $newmenu->add("/adherents/type.php?leftmenu=setup&mainmenu=members", $langs->trans("List"), 1, $user->rights->adherent->configurer);
 | 
| 2019 | 2019 | */ | 
| 2020 | -                $newmenu->add(BASE_URI . "?controller=adherents&method=index&leftmenu=members&mainmenu=members", $langs->trans("Members"), 0, $user->rights->adherent->lire, '', $mainmenu, 'members');
 | |
| 2021 | -                $newmenu->add(BASE_URI . "?controller=adherents&method=card&leftmenu=members&action=create", $langs->trans("NewMember"), 1, $user->rights->adherent->creer);
 | |
| 2022 | -                $newmenu->add(BASE_URI . "?controller=adherents&method=list&leftmenu=members", $langs->trans("List"), 1, $user->rights->adherent->lire);
 | |
| 2023 | -                $newmenu->add(BASE_URI . "?controller=adherents&method=list&leftmenu=members&statut=-1", $langs->trans("MenuMembersToValidate"), 2, $user->rights->adherent->lire);
 | |
| 2024 | -                $newmenu->add(BASE_URI . "?controller=adherents&method=list&leftmenu=members&statut=1", $langs->trans("MenuMembersValidated"), 2, $user->rights->adherent->lire);
 | |
| 2025 | -                $newmenu->add(BASE_URI . "?controller=adherents&method=list&leftmenu=members&statut=1&filter = uptodate", $langs->trans("MenuMembersUpToDate"), 2, $user->rights->adherent->lire);
 | |
| 2026 | -                $newmenu->add(BASE_URI . "?controller=adherents&method=list&leftmenu=members&statut=1&filter = outofdate", $langs->trans("MenuMembersNotUpToDate"), 2, $user->rights->adherent->lire);
 | |
| 2027 | -                $newmenu->add(BASE_URI . "?controller=adherents&method=list&leftmenu=members&statut=0", $langs->trans("MenuMembersResiliated"), 2, $user->rights->adherent->lire);
 | |
| 2028 | -                $newmenu->add(BASE_URI . "?controller=adherents/stats&method=index&leftmenu=members", $langs->trans("MenuMembersStats"), 1, $user->rights->adherent->lire);
 | |
| 2029 | -                $newmenu->add(BASE_URI . "?controller=adherents/cartes&method=carte&leftmenu=export", $langs->trans("MembersCards"), 1, $user->rights->adherent->export);
 | |
| 2020 | +                $newmenu->add(BASE_URI."?controller=adherents&method=index&leftmenu=members&mainmenu=members", $langs->trans("Members"), 0, $user->rights->adherent->lire, '', $mainmenu, 'members');
 | |
| 2021 | +                $newmenu->add(BASE_URI."?controller=adherents&method=card&leftmenu=members&action=create", $langs->trans("NewMember"), 1, $user->rights->adherent->creer);
 | |
| 2022 | +                $newmenu->add(BASE_URI."?controller=adherents&method=list&leftmenu=members", $langs->trans("List"), 1, $user->rights->adherent->lire);
 | |
| 2023 | +                $newmenu->add(BASE_URI."?controller=adherents&method=list&leftmenu=members&statut=-1", $langs->trans("MenuMembersToValidate"), 2, $user->rights->adherent->lire);
 | |
| 2024 | +                $newmenu->add(BASE_URI."?controller=adherents&method=list&leftmenu=members&statut=1", $langs->trans("MenuMembersValidated"), 2, $user->rights->adherent->lire);
 | |
| 2025 | +                $newmenu->add(BASE_URI."?controller=adherents&method=list&leftmenu=members&statut=1&filter = uptodate", $langs->trans("MenuMembersUpToDate"), 2, $user->rights->adherent->lire);
 | |
| 2026 | +                $newmenu->add(BASE_URI."?controller=adherents&method=list&leftmenu=members&statut=1&filter = outofdate", $langs->trans("MenuMembersNotUpToDate"), 2, $user->rights->adherent->lire);
 | |
| 2027 | +                $newmenu->add(BASE_URI."?controller=adherents&method=list&leftmenu=members&statut=0", $langs->trans("MenuMembersResiliated"), 2, $user->rights->adherent->lire);
 | |
| 2028 | +                $newmenu->add(BASE_URI."?controller=adherents/stats&method=index&leftmenu=members", $langs->trans("MenuMembersStats"), 1, $user->rights->adherent->lire);
 | |
| 2029 | +                $newmenu->add(BASE_URI."?controller=adherents/cartes&method=carte&leftmenu=export", $langs->trans("MembersCards"), 1, $user->rights->adherent->export);
 | |
| 2030 | 2030 |                  if (!empty($conf->global->MEMBER_LINK_TO_HTPASSWDFILE) && ($usemenuhider || empty($leftmenu) || $leftmenu == 'none' || $leftmenu == "members" || $leftmenu == "export")) {
 | 
| 2031 | -                    $newmenu->add(BASE_URI . "?controller=adherents&method=htpasswd&leftmenu=export", $langs->trans("Filehtpasswd"), 1, $user->rights->adherent->export);
 | |
| 2031 | +                    $newmenu->add(BASE_URI."?controller=adherents&method=htpasswd&leftmenu=export", $langs->trans("Filehtpasswd"), 1, $user->rights->adherent->export);
 | |
| 2032 | 2032 | } | 
| 2033 | 2033 |                  if (!empty($conf->categorie->enabled)) {
 | 
| 2034 | 2034 |                      $langs->load("categories");
 | 
| 2035 | -                    $newmenu->add(BASE_URI . "?controller=categories&method=index&leftmenu=cat&type=3", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
 | |
| 2036 | - } | |
| 2037 | -                $newmenu->add(BASE_URI . "?controller=adherents&method=index&leftmenu=members&mainmenu=members", $langs->trans("Subscriptions"), 0, $user->rights->adherent->cotisation->lire);
 | |
| 2038 | -                $newmenu->add(BASE_URI . "?controller=adherents&methodlist&leftmenu=members&statut=-1,1&mainmenu=members", $langs->trans("NewSubscription"), 1, $user->rights->adherent->cotisation->creer);
 | |
| 2039 | -                $newmenu->add(BASE_URI . "?controller=adherents/subscription&method=list&leftmenu=members", $langs->trans("List"), 1, $user->rights->adherent->cotisation->lire);
 | |
| 2040 | -                $newmenu->add(BASE_URI . "?controller=adherents/stats&method=index&leftmenu=members", $langs->trans("MenuMembersStats"), 1, $user->rights->adherent->lire);
 | |
| 2041 | -                $newmenu->add(BASE_URI . "?controller=adherents&method=type&leftmenu=setup&mainmenu=members", $langs->trans("MembersTypes"), 0, $user->rights->adherent->configurer, '', $mainmenu, 'setup');
 | |
| 2042 | -                $newmenu->add(BASE_URI . "?controller=adherents&method=type&leftmenu=setup&mainmenu=members&action=create", $langs->trans("New"), 1, $user->rights->adherent->configurer);
 | |
| 2043 | -                $newmenu->add(BASE_URI . "?controller=adherents&method=type&leftmenu=setup&mainmenu=members", $langs->trans("List"), 1, $user->rights->adherent->configurer);
 | |
| 2035 | +                    $newmenu->add(BASE_URI."?controller=categories&method=index&leftmenu=cat&type=3", $langs->trans("Categories"), 1, $user->rights->categorie->lire, '', $mainmenu, 'cat');
 | |
| 2036 | + } | |
| 2037 | +                $newmenu->add(BASE_URI."?controller=adherents&method=index&leftmenu=members&mainmenu=members", $langs->trans("Subscriptions"), 0, $user->rights->adherent->cotisation->lire);
 | |
| 2038 | +                $newmenu->add(BASE_URI."?controller=adherents&methodlist&leftmenu=members&statut=-1,1&mainmenu=members", $langs->trans("NewSubscription"), 1, $user->rights->adherent->cotisation->creer);
 | |
| 2039 | +                $newmenu->add(BASE_URI."?controller=adherents/subscription&method=list&leftmenu=members", $langs->trans("List"), 1, $user->rights->adherent->cotisation->lire);
 | |
| 2040 | +                $newmenu->add(BASE_URI."?controller=adherents/stats&method=index&leftmenu=members", $langs->trans("MenuMembersStats"), 1, $user->rights->adherent->lire);
 | |
| 2041 | +                $newmenu->add(BASE_URI."?controller=adherents&method=type&leftmenu=setup&mainmenu=members", $langs->trans("MembersTypes"), 0, $user->rights->adherent->configurer, '', $mainmenu, 'setup');
 | |
| 2042 | +                $newmenu->add(BASE_URI."?controller=adherents&method=type&leftmenu=setup&mainmenu=members&action=create", $langs->trans("New"), 1, $user->rights->adherent->configurer);
 | |
| 2043 | +                $newmenu->add(BASE_URI."?controller=adherents&method=type&leftmenu=setup&mainmenu=members", $langs->trans("List"), 1, $user->rights->adherent->configurer);
 | |
| 2044 | 2044 | } | 
| 2045 | 2045 | } | 
| 2046 | 2046 | |
| @@ -2051,11 +2051,11 @@ discard block | ||
| 2051 | 2051 | //var_dump($newmenu->liste); // | 
| 2052 | 2052 | // We update newmenu for special dynamic menus | 
| 2053 | 2053 |          if (!empty($user->rights->banque->lire) && $mainmenu == 'bank') { // Entry for each bank account
 | 
| 2054 | - require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; | |
| 2054 | + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; | |
| 2055 | 2055 | |
| 2056 | 2056 | $sql = "SELECT rowid, label, courant, rappro"; | 
| 2057 | - $sql .= " FROM " . MAIN_DB_PREFIX . "bank_account"; | |
| 2058 | - $sql .= " WHERE entity = " . $conf->entity; | |
| 2057 | + $sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; | |
| 2058 | + $sql .= " WHERE entity = ".$conf->entity; | |
| 2059 | 2059 | $sql .= " AND clos = 0"; | 
| 2060 | 2060 | $sql .= " ORDER BY label"; | 
| 2061 | 2061 | |
| @@ -2066,16 +2066,16 @@ discard block | ||
| 2066 | 2066 | |
| 2067 | 2067 |                  if ($numr > 0) {
 | 
| 2068 | 2068 |                      //$newmenu->add('/compta/bank/list.php', $langs->trans("BankAccounts"), 0, $user->rights->banque->lire);
 | 
| 2069 | -                    $newmenu->add(BASE_URI . '?controller=compta/bank?method=list', $langs->trans("BankAccounts"), 0, $user->rights->banque->lire);
 | |
| 2069 | +                    $newmenu->add(BASE_URI.'?controller=compta/bank?method=list', $langs->trans("BankAccounts"), 0, $user->rights->banque->lire);
 | |
| 2070 | 2070 | } | 
| 2071 | 2071 | |
| 2072 | 2072 |                  while ($i < $numr) {
 | 
| 2073 | 2073 | $objp = $db->fetch_object($resql); | 
| 2074 | 2074 |                      //$newmenu->add('/compta/bank/card.php?id=' . $objp->rowid, $objp->label, 1, $user->rights->banque->lire);
 | 
| 2075 | - $newmenu->add(BASE_URI . '?controller=compta/bank&method=card&id=' . $objp->rowid, $objp->label, 1, $user->rights->banque->lire); | |
| 2075 | + $newmenu->add(BASE_URI.'?controller=compta/bank&method=card&id='.$objp->rowid, $objp->label, 1, $user->rights->banque->lire); | |
| 2076 | 2076 |                      if ($objp->rappro && $objp->courant != Account::TYPE_CASH && empty($objp->clos)) {  // If not cash account and not closed and can be reconciliate
 | 
| 2077 | 2077 |                          //$newmenu->add('/compta/bank/bankentries_list.php?action=reconcile&contextpage=banktransactionlist-' . $objp->rowid . '&account=' . $objp->rowid . '&id=' . $objp->rowid . '&search_conciliated=0', $langs->trans("Conciliate"), 2, $user->rights->banque->consolidate);
 | 
| 2078 | -                        $newmenu->add(BASE_URI . '?controller=compta/bank&method=bankentries_list&action=reconcile&contextpage=banktransactionlist-' . $objp->rowid . '&account=' . $objp->rowid . '&id=' . $objp->rowid . '&search_conciliated=0', $langs->trans("Conciliate"), 2, $user->rights->banque->consolidate);
 | |
| 2078 | +                        $newmenu->add(BASE_URI.'?controller=compta/bank&method=bankentries_list&action=reconcile&contextpage=banktransactionlist-'.$objp->rowid.'&account='.$objp->rowid.'&id='.$objp->rowid.'&search_conciliated=0', $langs->trans("Conciliate"), 2, $user->rights->banque->consolidate);
 | |
| 2079 | 2079 | } | 
| 2080 | 2080 | $i++; | 
| 2081 | 2081 | } | 
| @@ -2088,11 +2088,11 @@ discard block | ||
| 2088 | 2088 | $MAXFTP = 20; | 
| 2089 | 2089 | $i = 1; | 
| 2090 | 2090 |              while ($i <= $MAXFTP) {
 | 
| 2091 | - $paramkey = 'FTP_NAME_' . $i; | |
| 2091 | + $paramkey = 'FTP_NAME_'.$i; | |
| 2092 | 2092 | //print $paramkey; | 
| 2093 | 2093 |                  if (!empty($conf->global->$paramkey)) {
 | 
| 2094 | 2094 | //$link = "/ftp/index.php?idmenu = " . $_SESSION["idmenu"] . "&numero_ftp = " . $i; | 
| 2095 | - $link = BASE_URI . "?controller=ftp&method=index&idmenu=" . $_SESSION["idmenu"] . "&numero_ftp=" . $i; | |
| 2095 | + $link = BASE_URI."?controller=ftp&method=index&idmenu=".$_SESSION["idmenu"]."&numero_ftp=".$i; | |
| 2096 | 2096 | |
| 2097 | 2097 | $newmenu->add($link, dol_trunc($conf->global->$paramkey, 24)); | 
| 2098 | 2098 | } | 
| @@ -2148,9 +2148,9 @@ discard block | ||
| 2148 | 2148 | $lastopened = false; | 
| 2149 | 2149 | } | 
| 2150 | 2150 |                  if ($altok % 2 == 0) {
 | 
| 2151 | - print '<div class="blockvmenu blockvmenuimpair' . $invert . ($lastopened ? ' blockvmenulast' : '') . ($altok == 1 ? ' blockvmenufirst' : '') . '">' . "\n"; | |
| 2151 | + print '<div class="blockvmenu blockvmenuimpair'.$invert.($lastopened ? ' blockvmenulast' : '').($altok == 1 ? ' blockvmenufirst' : '').'">'."\n"; | |
| 2152 | 2152 |                  } else {
 | 
| 2153 | - print '<div class="blockvmenu blockvmenupair' . $invert . ($lastopened ? ' blockvmenulast' : '') . ($altok == 1 ? ' blockvmenufirst' : '') . '">' . "\n"; | |
| 2153 | + print '<div class="blockvmenu blockvmenupair'.$invert.($lastopened ? ' blockvmenulast' : '').($altok == 1 ? ' blockvmenufirst' : '').'">'."\n"; | |
| 2154 | 2154 | } | 
| 2155 | 2155 | } | 
| 2156 | 2156 | |
| @@ -2172,47 +2172,47 @@ discard block | ||
| 2172 | 2172 |              if (!preg_match("/^(http:\/\/|https:\/\/)/i", $menu_array[$i]['url'])) {
 | 
| 2173 | 2173 |                  $tmp = explode('?', $menu_array[$i]['url'], 2);
 | 
| 2174 | 2174 | $url = $shorturl = $tmp[0]; | 
| 2175 | - $param = (isset($tmp[1]) ? $tmp[1] : ''); // params in url of the menu link | |
| 2175 | + $param = (isset($tmp[1]) ? $tmp[1] : ''); // params in url of the menu link | |
| 2176 | 2176 | // Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined. | 
| 2177 | 2177 |                  if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && !empty($menu_array[$i]['mainmenu'])) {
 | 
| 2178 | - $param .= ($param ? '&' : '') . 'mainmenu=' . $menu_array[$i]['mainmenu'] . '&leftmenu='; | |
| 2178 | + $param .= ($param ? '&' : '').'mainmenu='.$menu_array[$i]['mainmenu'].'&leftmenu='; | |
| 2179 | 2179 | } | 
| 2180 | 2180 |                  if ((!preg_match('/mainmenu/i', $param)) && (!preg_match('/leftmenu/i', $param)) && empty($menu_array[$i]['mainmenu'])) {
 | 
| 2181 | - $param .= ($param ? '&' : '') . 'leftmenu='; | |
| 2181 | + $param .= ($param ? '&' : '').'leftmenu='; | |
| 2182 | 2182 | } | 
| 2183 | 2183 | //$url.="idmenu = ".$menu_array[$i]['rowid']; // Already done by menuLoad | 
| 2184 | - $url = dol_buildpath($url, 1) . ($param ? '?' . $param : ''); | |
| 2184 | + $url = dol_buildpath($url, 1).($param ? '?'.$param : ''); | |
| 2185 | 2185 | $shorturlwithoutparam = $shorturl; | 
| 2186 | - $shorturl = $shorturl . ($param ? '?' . $param : ''); | |
| 2186 | + $shorturl = $shorturl.($param ? '?'.$param : ''); | |
| 2187 | 2187 | } | 
| 2188 | 2188 | |
| 2189 | 2189 | |
| 2190 | - print '<!-- Process menu entry with mainmenu=' . $menu_array[$i]['mainmenu'] . ', leftmenu=' . $menu_array[$i]['leftmenu'] . ', level=' . $menu_array[$i]['level'] . ' enabled=' . $menu_array[$i]['enabled'] . ', position=' . $menu_array[$i]['position'] . ' -->' . "\n"; | |
| 2190 | + print '<!-- Process menu entry with mainmenu='.$menu_array[$i]['mainmenu'].', leftmenu='.$menu_array[$i]['leftmenu'].', level='.$menu_array[$i]['level'].' enabled='.$menu_array[$i]['enabled'].', position='.$menu_array[$i]['position'].' -->'."\n"; | |
| 2191 | 2191 | |
| 2192 | 2192 | // Menu level 0 | 
| 2193 | 2193 |              if ($menu_array[$i]['level'] == 0) {
 | 
| 2194 | 2194 |                  if ($menu_array[$i]['enabled']) {     // Enabled so visible
 | 
| 2195 | - print '<div class="menu_titre">' . $tabstring; | |
| 2195 | + print '<div class="menu_titre">'.$tabstring; | |
| 2196 | 2196 | if ($shorturlwithoutparam) | 
| 2197 | - print '<a class="vmenu" href="' . $url . '"' . ($menu_array[$i]['target'] ? ' target="' . $menu_array[$i]['target'] . '"' : '') . '>'; | |
| 2197 | + print '<a class="vmenu" href="'.$url.'"'.($menu_array[$i]['target'] ? ' target="'.$menu_array[$i]['target'].'"' : '').'>'; | |
| 2198 | 2198 | else | 
| 2199 | 2199 | print '<span class="vmenu">'; | 
| 2200 | - print ($menu_array[$i]['prefix'] ? $menu_array[$i]['prefix'] : '') . $menu_array[$i]['titre']; | |
| 2200 | + print ($menu_array[$i]['prefix'] ? $menu_array[$i]['prefix'] : '').$menu_array[$i]['titre']; | |
| 2201 | 2201 | if ($shorturlwithoutparam) | 
| 2202 | 2202 | print '</a>'; | 
| 2203 | 2203 | else | 
| 2204 | 2204 | print '</span>'; | 
| 2205 | - print '</div>' . "\n"; | |
| 2205 | + print '</div>'."\n"; | |
| 2206 | 2206 | $lastlevel0 = 'enabled'; | 
| 2207 | 2207 | } | 
| 2208 | 2208 |                  else if ($showmenu) {                 // Not enabled but visible (so greyed)
 | 
| 2209 | - print '<div class="menu_titre">' . $tabstring . '<font class="vmenudisabled">' . $menu_array[$i]['titre'] . '</font></div>' . "\n"; | |
| 2209 | + print '<div class="menu_titre">'.$tabstring.'<font class="vmenudisabled">'.$menu_array[$i]['titre'].'</font></div>'."\n"; | |
| 2210 | 2210 | $lastlevel0 = 'greyed'; | 
| 2211 | 2211 |                  } else {
 | 
| 2212 | 2212 | $lastlevel0 = 'hidden'; | 
| 2213 | 2213 | } | 
| 2214 | 2214 |                  if ($showmenu) {
 | 
| 2215 | - print '<div class="menu_top"></div>' . "\n"; | |
| 2215 | + print '<div class="menu_top"></div>'."\n"; | |
| 2216 | 2216 | } | 
| 2217 | 2217 | } | 
| 2218 | 2218 | |
| @@ -2220,12 +2220,12 @@ discard block | ||
| 2220 | 2220 |              if ($menu_array[$i]['level'] > 0) {
 | 
| 2221 | 2221 | $cssmenu = ''; | 
| 2222 | 2222 | if ($menu_array[$i]['url']) | 
| 2223 | -                    $cssmenu = ' menu_contenu' . dol_string_nospecial(preg_replace('/\.php.*$/', '', $menu_array[$i]['url']));
 | |
| 2223 | +                    $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/', '', $menu_array[$i]['url']));
 | |
| 2224 | 2224 | |
| 2225 | 2225 |                  if ($menu_array[$i]['enabled'] && $lastlevel0 == 'enabled') {     // Enabled so visible, except if parent was not enabled.
 | 
| 2226 | - print '<div class="menu_contenu' . $cssmenu . '">' . $tabstring; | |
| 2226 | + print '<div class="menu_contenu'.$cssmenu.'">'.$tabstring; | |
| 2227 | 2227 | if ($shorturlwithoutparam) | 
| 2228 | - print '<a class="vsmenu" href="' . $url . '"' . ($menu_array[$i]['target'] ? ' target="' . $menu_array[$i]['target'] . '"' : '') . '>'; | |
| 2228 | + print '<a class="vsmenu" href="'.$url.'"'.($menu_array[$i]['target'] ? ' target="'.$menu_array[$i]['target'].'"' : '').'>'; | |
| 2229 | 2229 | else | 
| 2230 | 2230 | print '<span class="vsmenu">'; | 
| 2231 | 2231 | print $menu_array[$i]['titre']; | 
| @@ -2236,26 +2236,26 @@ discard block | ||
| 2236 | 2236 | // If title is not pure text and contains a table, no carriage return added | 
| 2237 | 2237 | if (!strstr($menu_array[$i]['titre'], '<table')) | 
| 2238 | 2238 | print '<br>'; | 
| 2239 | - print '</div>' . "\n"; | |
| 2239 | + print '</div>'."\n"; | |
| 2240 | 2240 | } | 
| 2241 | 2241 |                  else if ($showmenu && $lastlevel0 == 'enabled') {       // Not enabled but visible (so greyed), except if parent was not enabled.
 | 
| 2242 | - print '<div class="menu_contenu' . $cssmenu . '">' . $tabstring . '<font class="vsmenudisabled vsmenudisabledmargin">' . $menu_array[$i]['titre'] . '</font><br></div>' . "\n"; | |
| 2242 | + print '<div class="menu_contenu'.$cssmenu.'">'.$tabstring.'<font class="vsmenudisabled vsmenudisabledmargin">'.$menu_array[$i]['titre'].'</font><br></div>'."\n"; | |
| 2243 | 2243 | } | 
| 2244 | 2244 | } | 
| 2245 | 2245 | |
| 2246 | 2246 | // If next is a new block or if there is nothing after | 
| 2247 | 2247 |              if (empty($menu_array[$i + 1]['level'])) {               // End menu block
 | 
| 2248 | 2248 | if ($showmenu) | 
| 2249 | - print '<div class="menu_end"></div>' . "\n"; | |
| 2249 | + print '<div class="menu_end"></div>'."\n"; | |
| 2250 | 2250 |                  if ($blockvmenuopened) {
 | 
| 2251 | - print '</div>' . "\n"; | |
| 2251 | + print '</div>'."\n"; | |
| 2252 | 2252 | $blockvmenuopened = false; | 
| 2253 | 2253 | } | 
| 2254 | 2254 | } | 
| 2255 | 2255 | } | 
| 2256 | 2256 | |
| 2257 | 2257 | if ($altok) | 
| 2258 | - print '<div class="blockvmenuend"></div>'; // End menu block | |
| 2258 | + print '<div class="blockvmenuend"></div>'; // End menu block | |
| 2259 | 2259 | } | 
| 2260 | 2260 | |
| 2261 | 2261 | return count($menu_array); | 
| @@ -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); | 
| @@ -1995,28 +1995,28 @@ | ||
| 1995 | 1995 | |
| 1996 | 1996 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps | 
| 1997 | 1997 | /** | 
| 1998 | - * Return list of products for a customer | |
| 1999 | - * | |
| 2000 | - * @param int $selected Preselected product | |
| 2001 | - * @param string $htmlname Name of select html | |
| 2002 | -     *  @param		string	$filtertype         Filter on product type (''=nofilter, 0=product, 1=service)
 | |
| 2003 | - * @param int $limit Limit on number of returned lines | |
| 2004 | - * @param int $price_level Level of price to show | |
| 2005 | - * @param string $filterkey Filter on product | |
| 2006 | - * @param int $status -1=Return all products, 0=Products not on sell, 1=Products on sell | |
| 2007 | - * @param int $finished Filter on finished field: 2=No filter | |
| 2008 | - * @param int $outputmode 0=HTML select string, 1=Array | |
| 2009 | - * @param int $socid Thirdparty Id (to get also price dedicated to this customer) | |
| 2010 | - * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. | |
| 2011 | - * @param int $forcecombo Force to use combo box | |
| 2012 | - * @param string $morecss Add more css on select | |
| 2013 | - * @param int $hidepriceinlabel 1=Hide prices in label | |
| 2014 | - * @param string $warehouseStatus warehouse status filter, following comma separated filter options can be used | |
| 2015 | - * 'warehouseopen' = select products from open warehouses, | |
| 2016 | - * 'warehouseclosed' = select products from closed warehouses, | |
| 2017 | - * 'warehouseinternal' = select products from warehouses for internal correct/transfer only | |
| 2018 | - * @return array Array of keys for json | |
| 2019 | - */ | |
| 1998 | + * Return list of products for a customer | |
| 1999 | + * | |
| 2000 | + * @param int $selected Preselected product | |
| 2001 | + * @param string $htmlname Name of select html | |
| 2002 | +                     *  @param		string	$filtertype         Filter on product type (''=nofilter, 0=product, 1=service)
 | |
| 2003 | + * @param int $limit Limit on number of returned lines | |
| 2004 | + * @param int $price_level Level of price to show | |
| 2005 | + * @param string $filterkey Filter on product | |
| 2006 | + * @param int $status -1=Return all products, 0=Products not on sell, 1=Products on sell | |
| 2007 | + * @param int $finished Filter on finished field: 2=No filter | |
| 2008 | + * @param int $outputmode 0=HTML select string, 1=Array | |
| 2009 | + * @param int $socid Thirdparty Id (to get also price dedicated to this customer) | |
| 2010 | + * @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text. | |
| 2011 | + * @param int $forcecombo Force to use combo box | |
| 2012 | + * @param string $morecss Add more css on select | |
| 2013 | + * @param int $hidepriceinlabel 1=Hide prices in label | |
| 2014 | + * @param string $warehouseStatus warehouse status filter, following comma separated filter options can be used | |
| 2015 | + * 'warehouseopen' = select products from open warehouses, | |
| 2016 | + * 'warehouseclosed' = select products from closed warehouses, | |
| 2017 | + * 'warehouseinternal' = select products from warehouses for internal correct/transfer only | |
| 2018 | + * @return array Array of keys for json | |
| 2019 | + */ | |
| 2020 | 2020 | function select_produits_list($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '') | 
| 2021 | 2021 |      {
 | 
| 2022 | 2022 | // phpcs:enable | 
| @@ -110,13 +110,13 @@ discard block | ||
| 110 | 110 |          if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match('/^select;/', $typeofdata)) {
 | 
| 111 | 111 |              if (!empty($perm)) {
 | 
| 112 | 112 |                  $tmp = explode(':', $typeofdata);
 | 
| 113 | - $ret .= '<div class="editkey_' . $tmp[0] . (!empty($tmp[1]) ? ' ' . $tmp[1] : '') . '" id="' . $htmlname . '">'; | |
| 113 | + $ret .= '<div class="editkey_'.$tmp[0].(!empty($tmp[1]) ? ' '.$tmp[1] : '').'" id="'.$htmlname.'">'; | |
| 114 | 114 | if ($fieldrequired) | 
| 115 | 115 | $ret .= '<span class="fieldrequired">'; | 
| 116 | 116 | $ret .= $langs->trans($text); | 
| 117 | 117 | if ($fieldrequired) | 
| 118 | 118 | $ret .= '</span>'; | 
| 119 | - $ret .= '</div>' . "\n"; | |
| 119 | + $ret .= '</div>'."\n"; | |
| 120 | 120 | } | 
| 121 | 121 |              else {
 | 
| 122 | 122 | if ($fieldrequired) | 
| @@ -127,7 +127,7 @@ discard block | ||
| 127 | 127 | } | 
| 128 | 128 | } | 
| 129 | 129 |          else {
 | 
| 130 | -            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm)
 | |
| 130 | +            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm)
 | |
| 131 | 131 | $ret .= '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">'; | 
| 132 | 132 | if ($fieldrequired) | 
| 133 | 133 | $ret .= '<span class="fieldrequired">'; | 
| @@ -136,19 +136,19 @@ discard block | ||
| 136 | 136 | $ret .= '</span>'; | 
| 137 | 137 | if (!empty($notabletag)) | 
| 138 | 138 | $ret .= ' '; | 
| 139 | -            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm)
 | |
| 139 | +            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm)
 | |
| 140 | 140 | $ret .= '</td>'; | 
| 141 | -            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm)
 | |
| 141 | +            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm)
 | |
| 142 | 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>';
 | |
| 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 | 145 | if (!empty($notabletag) && $notabletag == 1) | 
| 146 | 146 | $ret .= ' : '; | 
| 147 | 147 | if (!empty($notabletag) && $notabletag == 3) | 
| 148 | 148 | $ret .= ' '; | 
| 149 | -            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm)
 | |
| 149 | +            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm)
 | |
| 150 | 150 | $ret .= '</td>'; | 
| 151 | -            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm)
 | |
| 151 | +            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm)
 | |
| 152 | 152 | $ret .= '</tr></table>'; | 
| 153 | 153 | } | 
| 154 | 154 | |
| @@ -187,41 +187,41 @@ discard block | ||
| 187 | 187 |          if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match('/^select;|datehourpicker/', $typeofdata)) { // TODO add jquery timepicker
 | 
| 188 | 188 | $ret .= $this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $editvalue, $extObject, $custommsg); | 
| 189 | 189 |          } else {
 | 
| 190 | -            if (GETPOST('action', 'aZ09') == 'edit' . $htmlname) {
 | |
| 190 | +            if (GETPOST('action', 'aZ09') == 'edit'.$htmlname) {
 | |
| 191 | 191 | $ret .= "\n"; | 
| 192 | - $ret .= '<form method="post" action="' . $_SERVER["PHP_SELF"] . ($moreparam ? '?' . $moreparam : '') . '">'; | |
| 193 | - $ret .= '<input type="hidden" name="action" value="set' . $htmlname . '">'; | |
| 194 | - $ret .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 195 | - $ret .= '<input type="hidden" name="' . $paramid . '" value="' . $object->id . '">'; | |
| 192 | + $ret .= '<form method="post" action="'.$_SERVER["PHP_SELF"].($moreparam ? '?'.$moreparam : '').'">'; | |
| 193 | + $ret .= '<input type="hidden" name="action" value="set'.$htmlname.'">'; | |
| 194 | + $ret .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 195 | + $ret .= '<input type="hidden" name="'.$paramid.'" value="'.$object->id.'">'; | |
| 196 | 196 | if (empty($notabletag)) | 
| 197 | 197 | $ret .= '<table class="nobordernopadding centpercent" cellpadding="0" cellspacing="0">'; | 
| 198 | 198 | if (empty($notabletag)) | 
| 199 | 199 | $ret .= '<tr><td>'; | 
| 200 | 200 |                  if (preg_match('/^(string|email)/', $typeofdata)) {
 | 
| 201 | 201 |                      $tmp = explode(':', $typeofdata);
 | 
| 202 | - $ret .= '<input type="text" id="' . $htmlname . '" name="' . $htmlname . '" value="' . ($editvalue ? $editvalue : $value) . '"' . ($tmp[1] ? ' size="' . $tmp[1] . '"' : '') . '>'; | |
| 202 | + $ret .= '<input type="text" id="'.$htmlname.'" name="'.$htmlname.'" value="'.($editvalue ? $editvalue : $value).'"'.($tmp[1] ? ' size="'.$tmp[1].'"' : '').'>'; | |
| 203 | 203 |                  } else if (preg_match('/^(numeric|amount)/', $typeofdata)) {
 | 
| 204 | 204 |                      $tmp = explode(':', $typeofdata);
 | 
| 205 | 205 | $valuetoshow = price2num($editvalue ? $editvalue : $value); | 
| 206 | - $ret .= '<input type="text" id="' . $htmlname . '" name="' . $htmlname . '" value="' . ($valuetoshow != '' ? price($valuetoshow) : '') . '"' . ($tmp[1] ? ' size="' . $tmp[1] . '"' : '') . '>'; | |
| 206 | + $ret .= '<input type="text" id="'.$htmlname.'" name="'.$htmlname.'" value="'.($valuetoshow != '' ? price($valuetoshow) : '').'"'.($tmp[1] ? ' size="'.$tmp[1].'"' : '').'>'; | |
| 207 | 207 |                  } else if (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) {
 | 
| 208 | 208 |                      $tmp = explode(':', $typeofdata);
 | 
| 209 | 209 | $cols = $tmp[2]; | 
| 210 | 210 | $morealt = ''; | 
| 211 | 211 |                      if (preg_match('/%/', $cols)) {
 | 
| 212 | - $morealt = ' style="width: ' . $cols . '"'; | |
| 212 | + $morealt = ' style="width: '.$cols.'"'; | |
| 213 | 213 | $cols = ''; | 
| 214 | 214 | } | 
| 215 | 215 | |
| 216 | 216 | $valuetoshow = ($editvalue ? $editvalue : $value); | 
| 217 | 217 | |
| 218 | - $ret .= '<textarea id="' . $htmlname . '" name="' . $htmlname . '" wrap="soft" rows="' . ($tmp[1] ? $tmp[1] : '20') . '"' . ($cols ? ' cols="' . $cols . '"' : 'class="quatrevingtpercent"') . $morealt . '">'; | |
| 218 | + $ret .= '<textarea id="'.$htmlname.'" name="'.$htmlname.'" wrap="soft" rows="'.($tmp[1] ? $tmp[1] : '20').'"'.($cols ? ' cols="'.$cols.'"' : 'class="quatrevingtpercent"').$morealt.'">'; | |
| 219 | 219 |                      $ret .= dol_string_neverthesehtmltags($valuetoshow, array('textarea'));
 | 
| 220 | 220 | $ret .= '</textarea>'; | 
| 221 | 221 |                  } else if ($typeofdata == 'day' || $typeofdata == 'datepicker') {
 | 
| 222 | - $ret .= $this->selectDate($value, $htmlname, 0, 0, 1, 'form' . $htmlname, 1, 0); | |
| 222 | + $ret .= $this->selectDate($value, $htmlname, 0, 0, 1, 'form'.$htmlname, 1, 0); | |
| 223 | 223 |                  } else if ($typeofdata == 'dayhour' || $typeofdata == 'datehourpicker') {
 | 
| 224 | - $ret .= $this->selectDate($value, $htmlname, 1, 1, 1, 'form' . $htmlname, 1, 0); | |
| 224 | + $ret .= $this->selectDate($value, $htmlname, 1, 1, 1, 'form'.$htmlname, 1, 0); | |
| 225 | 225 |                  } else if (preg_match('/^select;/', $typeofdata)) {
 | 
| 226 | 226 |                      $arraydata = explode(',', preg_replace('/^select;/', '', $typeofdata));
 | 
| 227 | 227 |                      foreach ($arraydata as $val) {
 | 
| @@ -230,8 +230,8 @@ discard block | ||
| 230 | 230 | } | 
| 231 | 231 | $ret .= $this->selectarray($htmlname, $arraylist, $value); | 
| 232 | 232 |                  } else if (preg_match('/^ckeditor/', $typeofdata)) {
 | 
| 233 | -                    $tmp = explode(':', $typeofdata);  // Example: ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols
 | |
| 234 | - require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; | |
| 233 | +                    $tmp = explode(':', $typeofdata); // Example: ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols
 | |
| 234 | + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; | |
| 235 | 235 | $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 | 236 | $ret .= $doleditor->Create(1); | 
| 237 | 237 | } | 
| @@ -241,16 +241,16 @@ discard block | ||
| 241 | 241 | if (empty($notabletag)) | 
| 242 | 242 | $ret .= '<td align="left">'; | 
| 243 | 243 | //else $ret.='<div class="clearboth"></div>'; | 
| 244 | -                $ret .= '<input type="submit" class="button' . (empty($notabletag) ? '' : ' ') . '" name="modify" value="' . $langs->trans("Modify") . '">';
 | |
| 244 | +                $ret .= '<input type="submit" class="button'.(empty($notabletag) ? '' : ' ').'" name="modify" value="'.$langs->trans("Modify").'">';
 | |
| 245 | 245 |                  if (preg_match('/ckeditor|textarea/', $typeofdata) && empty($notabletag))
 | 
| 246 | - $ret .= '<br>' . "\n"; | |
| 247 | -                $ret .= '<input type="submit" class="button' . (empty($notabletag) ? '' : ' ') . '" name="cancel" value="' . $langs->trans("Cancel") . '">';
 | |
| 246 | + $ret .= '<br>'."\n"; | |
| 247 | +                $ret .= '<input type="submit" class="button'.(empty($notabletag) ? '' : ' ').'" name="cancel" value="'.$langs->trans("Cancel").'">';
 | |
| 248 | 248 | if (empty($notabletag)) | 
| 249 | 249 | $ret .= '</td>'; | 
| 250 | 250 | |
| 251 | 251 | if (empty($notabletag)) | 
| 252 | - $ret .= '</tr></table>' . "\n"; | |
| 253 | - $ret .= '</form>' . "\n"; | |
| 252 | + $ret .= '</tr></table>'."\n"; | |
| 253 | + $ret .= '</form>'."\n"; | |
| 254 | 254 | } | 
| 255 | 255 |              else {
 | 
| 256 | 256 |                  if (preg_match('/^(email)/', $typeofdata))
 | 
| @@ -275,7 +275,7 @@ discard block | ||
| 275 | 275 |                      if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
 | 
| 276 | 276 |                          $firstline = preg_replace('/<br>.*/', '', $tmpcontent);
 | 
| 277 | 277 |                          $firstline = preg_replace('/[\n\r].*/', '', $firstline);
 | 
| 278 | - $tmpcontent = $firstline . ((strlen($firstline) != strlen($tmpcontent)) ? '...' : ''); | |
| 278 | + $tmpcontent = $firstline.((strlen($firstline) != strlen($tmpcontent)) ? '...' : ''); | |
| 279 | 279 | } | 
| 280 | 280 | $ret .= $tmpcontent; | 
| 281 | 281 | } else | 
| @@ -343,7 +343,7 @@ discard block | ||
| 343 | 343 | $inputOption = $tmp[1]; | 
| 344 | 344 | if (!empty($tmp[2])) | 
| 345 | 345 | $savemethod = $tmp[2]; | 
| 346 | - $out .= '<input id="width_' . $htmlname . '" value="' . $inputOption . '" type="hidden"/>' . "\n"; | |
| 346 | + $out .= '<input id="width_'.$htmlname.'" value="'.$inputOption.'" type="hidden"/>'."\n"; | |
| 347 | 347 | } | 
| 348 | 348 |              else if ((preg_match('/^day$/', $inputType)) || (preg_match('/^datepicker/', $inputType)) || (preg_match('/^datehourpicker/', $inputType))) {
 | 
| 349 | 349 |                  $tmp = explode(':', $inputType);
 | 
| @@ -353,7 +353,7 @@ discard block | ||
| 353 | 353 | if (!empty($tmp[2])) | 
| 354 | 354 | $savemethod = $tmp[2]; | 
| 355 | 355 | |
| 356 | - $out .= '<input id="timestamp" type="hidden"/>' . "\n"; // Use for timestamp format | |
| 356 | + $out .= '<input id="timestamp" type="hidden"/>'."\n"; // Use for timestamp format | |
| 357 | 357 | } | 
| 358 | 358 |              else if (preg_match('/^(select|autocomplete)/', $inputType)) {
 | 
| 359 | 359 |                  $tmp = explode(':', $inputType);
 | 
| @@ -381,35 +381,35 @@ discard block | ||
| 381 | 381 | $savemethod = $tmp[4]; | 
| 382 | 382 | |
| 383 | 383 |                  if (!empty($conf->fckeditor->enabled)) {
 | 
| 384 | - $out .= '<input id="ckeditor_toolbar" value="' . $toolbar . '" type="hidden"/>' . "\n"; | |
| 384 | + $out .= '<input id="ckeditor_toolbar" value="'.$toolbar.'" type="hidden"/>'."\n"; | |
| 385 | 385 |                  } else {
 | 
| 386 | 386 | $inputType = 'textarea'; | 
| 387 | 387 | } | 
| 388 | 388 | } | 
| 389 | 389 | |
| 390 | - $out .= '<input id="element_' . $htmlname . '" value="' . $element . '" type="hidden"/>' . "\n"; | |
| 391 | - $out .= '<input id="table_element_' . $htmlname . '" value="' . $table_element . '" type="hidden"/>' . "\n"; | |
| 392 | - $out .= '<input id="fk_element_' . $htmlname . '" value="' . $fk_element . '" type="hidden"/>' . "\n"; | |
| 393 | - $out .= '<input id="loadmethod_' . $htmlname . '" value="' . $loadmethod . '" type="hidden"/>' . "\n"; | |
| 390 | + $out .= '<input id="element_'.$htmlname.'" value="'.$element.'" type="hidden"/>'."\n"; | |
| 391 | + $out .= '<input id="table_element_'.$htmlname.'" value="'.$table_element.'" type="hidden"/>'."\n"; | |
| 392 | + $out .= '<input id="fk_element_'.$htmlname.'" value="'.$fk_element.'" type="hidden"/>'."\n"; | |
| 393 | + $out .= '<input id="loadmethod_'.$htmlname.'" value="'.$loadmethod.'" type="hidden"/>'."\n"; | |
| 394 | 394 | if (!empty($savemethod)) | 
| 395 | - $out .= '<input id="savemethod_' . $htmlname . '" value="' . $savemethod . '" type="hidden"/>' . "\n"; | |
| 395 | + $out .= '<input id="savemethod_'.$htmlname.'" value="'.$savemethod.'" type="hidden"/>'."\n"; | |
| 396 | 396 | if (!empty($ext_element)) | 
| 397 | - $out .= '<input id="ext_element_' . $htmlname . '" value="' . $ext_element . '" type="hidden"/>' . "\n"; | |
| 397 | + $out .= '<input id="ext_element_'.$htmlname.'" value="'.$ext_element.'" type="hidden"/>'."\n"; | |
| 398 | 398 |              if (!empty($custommsg)) {
 | 
| 399 | 399 |                  if (is_array($custommsg)) {
 | 
| 400 | 400 | if (!empty($custommsg['success'])) | 
| 401 | - $out .= '<input id="successmsg_' . $htmlname . '" value="' . $custommsg['success'] . '" type="hidden"/>' . "\n"; | |
| 401 | + $out .= '<input id="successmsg_'.$htmlname.'" value="'.$custommsg['success'].'" type="hidden"/>'."\n"; | |
| 402 | 402 | if (!empty($custommsg['error'])) | 
| 403 | - $out .= '<input id="errormsg_' . $htmlname . '" value="' . $custommsg['error'] . '" type="hidden"/>' . "\n"; | |
| 403 | + $out .= '<input id="errormsg_'.$htmlname.'" value="'.$custommsg['error'].'" type="hidden"/>'."\n"; | |
| 404 | 404 | } else | 
| 405 | - $out .= '<input id="successmsg_' . $htmlname . '" value="' . $custommsg . '" type="hidden"/>' . "\n"; | |
| 405 | + $out .= '<input id="successmsg_'.$htmlname.'" value="'.$custommsg.'" type="hidden"/>'."\n"; | |
| 406 | 406 | } | 
| 407 | 407 |              if ($inputType == 'textarea') {
 | 
| 408 | - $out .= '<input id="textarea_' . $htmlname . '_rows" value="' . $rows . '" type="hidden"/>' . "\n"; | |
| 409 | - $out .= '<input id="textarea_' . $htmlname . '_cols" value="' . $cols . '" type="hidden"/>' . "\n"; | |
| 408 | + $out .= '<input id="textarea_'.$htmlname.'_rows" value="'.$rows.'" type="hidden"/>'."\n"; | |
| 409 | + $out .= '<input id="textarea_'.$htmlname.'_cols" value="'.$cols.'" type="hidden"/>'."\n"; | |
| 410 | 410 | } | 
| 411 | - $out .= '<span id="viewval_' . $htmlname . '" class="viewval_' . $inputType . ($button_only ? ' inactive' : ' active') . '">' . $value . '</span>' . "\n"; | |
| 412 | - $out .= '<span id="editval_' . $htmlname . '" class="editval_' . $inputType . ($button_only ? ' inactive' : ' active') . ' hideobject">' . (!empty($editvalue) ? $editvalue : $value) . '</span>' . "\n"; | |
| 411 | + $out .= '<span id="viewval_'.$htmlname.'" class="viewval_'.$inputType.($button_only ? ' inactive' : ' active').'">'.$value.'</span>'."\n"; | |
| 412 | + $out .= '<span id="editval_'.$htmlname.'" class="editval_'.$inputType.($button_only ? ' inactive' : ' active').' hideobject">'.(!empty($editvalue) ? $editvalue : $value).'</span>'."\n"; | |
| 413 | 413 |          } else {
 | 
| 414 | 414 | $out = $value; | 
| 415 | 415 | } | 
| @@ -441,7 +441,7 @@ discard block | ||
| 441 | 441 | global $conf; | 
| 442 | 442 | |
| 443 | 443 | if ($incbefore) | 
| 444 | - $text = $incbefore . $text; | |
| 444 | + $text = $incbefore.$text; | |
| 445 | 445 | if (!$htmltext) | 
| 446 | 446 | return $text; | 
| 447 | 447 | |
| @@ -457,11 +457,11 @@ discard block | ||
| 457 | 457 | |
| 458 | 458 | $extrastyle = ''; | 
| 459 | 459 |          if ($direction < 0) {
 | 
| 460 | - $extracss = ($extracss ? $extracss . ' ' : '') . 'inline-block'; | |
| 460 | + $extracss = ($extracss ? $extracss.' ' : '').'inline-block'; | |
| 461 | 461 | $extrastyle = 'padding: 0px; padding-left: 3px !important;'; | 
| 462 | 462 | } | 
| 463 | 463 |          if ($direction > 0) {
 | 
| 464 | - $extracss = ($extracss ? $extracss . ' ' : '') . 'inline-block'; | |
| 464 | + $extracss = ($extracss ? $extracss.' ' : '').'inline-block'; | |
| 465 | 465 | $extrastyle = 'padding: 0px; padding-right: 3px !important;'; | 
| 466 | 466 | } | 
| 467 | 467 | |
| @@ -474,46 +474,46 @@ discard block | ||
| 474 | 474 |              $htmltext = str_replace('"', """, $htmltext);
 | 
| 475 | 475 |          } else {
 | 
| 476 | 476 | $classfortooltip = 'classfortooltiponclick'; | 
| 477 | - $textfordialog .= '<div style="display: none;" id="idfortooltiponclick_' . $tooltiptrigger . '" class="classfortooltiponclicktext">' . $htmltext . '</div>'; | |
| 477 | + $textfordialog .= '<div style="display: none;" id="idfortooltiponclick_'.$tooltiptrigger.'" class="classfortooltiponclicktext">'.$htmltext.'</div>'; | |
| 478 | 478 | } | 
| 479 | 479 |          if ($tooltipon == 2 || $tooltipon == 3) {
 | 
| 480 | - $paramfortooltipimg = ' class="' . $classfortooltip . ' inline-block' . ($extracss ? ' ' . $extracss : '') . '" style="padding: 0px;' . ($extrastyle ? ' ' . $extrastyle : '') . '"'; | |
| 480 | + $paramfortooltipimg = ' class="'.$classfortooltip.' inline-block'.($extracss ? ' '.$extracss : '').'" style="padding: 0px;'.($extrastyle ? ' '.$extrastyle : '').'"'; | |
| 481 | 481 | if ($tooltiptrigger == '') | 
| 482 | - $paramfortooltipimg .= ' title="' . ($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)) . '"'; // Attribut to put on img tag to store tooltip | |
| 482 | + $paramfortooltipimg .= ' title="'.($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)).'"'; // Attribut to put on img tag to store tooltip | |
| 483 | 483 | else | 
| 484 | - $paramfortooltipimg .= ' dolid="' . $tooltiptrigger . '"'; | |
| 484 | + $paramfortooltipimg .= ' dolid="'.$tooltiptrigger.'"'; | |
| 485 | 485 | } else | 
| 486 | - $paramfortooltipimg = ($extracss ? ' class="' . $extracss . '"' : '') . ($extrastyle ? ' style="' . $extrastyle . '"' : ''); // Attribut to put on td text tag | |
| 486 | + $paramfortooltipimg = ($extracss ? ' class="'.$extracss.'"' : '').($extrastyle ? ' style="'.$extrastyle.'"' : ''); // Attribut to put on td text tag | |
| 487 | 487 |          if ($tooltipon == 1 || $tooltipon == 3) {
 | 
| 488 | - $paramfortooltiptd = ' class="' . ($tooltipon == 3 ? 'cursorpointer ' : '') . $classfortooltip . ' inline-block' . ($extracss ? ' ' . $extracss : '') . '" style="padding: 0px;' . ($extrastyle ? ' ' . $extrastyle : '') . '" '; | |
| 488 | + $paramfortooltiptd = ' class="'.($tooltipon == 3 ? 'cursorpointer ' : '').$classfortooltip.' inline-block'.($extracss ? ' '.$extracss : '').'" style="padding: 0px;'.($extrastyle ? ' '.$extrastyle : '').'" '; | |
| 489 | 489 | if ($tooltiptrigger == '') | 
| 490 | - $paramfortooltiptd .= ' title="' . ($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)) . '"'; // Attribut to put on td tag to store tooltip | |
| 490 | + $paramfortooltiptd .= ' title="'.($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)).'"'; // Attribut to put on td tag to store tooltip | |
| 491 | 491 | else | 
| 492 | - $paramfortooltiptd .= ' dolid="' . $tooltiptrigger . '"'; | |
| 492 | + $paramfortooltiptd .= ' dolid="'.$tooltiptrigger.'"'; | |
| 493 | 493 | } else | 
| 494 | - $paramfortooltiptd = ($extracss ? ' class="' . $extracss . '"' : '') . ($extrastyle ? ' style="' . $extrastyle . '"' : ''); // Attribut to put on td text tag | |
| 494 | + $paramfortooltiptd = ($extracss ? ' class="'.$extracss.'"' : '').($extrastyle ? ' style="'.$extrastyle.'"' : ''); // Attribut to put on td text tag | |
| 495 | 495 | if (empty($notabs)) | 
| 496 | 496 | $s .= '<table class="nobordernopadding" summary=""><tr style="height: auto;">'; | 
| 497 | 497 | elseif ($notabs == 2) | 
| 498 | - $s .= '<div class="inline-block' . ($forcenowrap ? ' nowrap' : '') . '">'; | |
| 498 | + $s .= '<div class="inline-block'.($forcenowrap ? ' nowrap' : '').'">'; | |
| 499 | 499 | // Define value if value is before | 
| 500 | 500 |          if ($direction < 0) {
 | 
| 501 | - $s .= '<' . $tag . $paramfortooltipimg; | |
| 501 | + $s .= '<'.$tag.$paramfortooltipimg; | |
| 502 | 502 |              if ($tag == 'td') {
 | 
| 503 | 503 | $s .= ' valign="top" width="14"'; | 
| 504 | 504 | } | 
| 505 | - $s .= '>' . $textfordialog . $img . '</' . $tag . '>'; | |
| 505 | + $s .= '>'.$textfordialog.$img.'</'.$tag.'>'; | |
| 506 | 506 | } | 
| 507 | 507 | // Use another method to help avoid having a space in value in order to use this value with jquery | 
| 508 | 508 | // Define label | 
| 509 | 509 | if ((string) $text != '') | 
| 510 | - $s .= '<' . $tag . $paramfortooltiptd . '>' . $text . '</' . $tag . '>'; | |
| 510 | + $s .= '<'.$tag.$paramfortooltiptd.'>'.$text.'</'.$tag.'>'; | |
| 511 | 511 | // Define value if value is after | 
| 512 | 512 |          if ($direction > 0) {
 | 
| 513 | - $s .= '<' . $tag . $paramfortooltipimg; | |
| 513 | + $s .= '<'.$tag.$paramfortooltipimg; | |
| 514 | 514 | if ($tag == 'td') | 
| 515 | 515 | $s .= ' valign="middle" width="14"'; | 
| 516 | - $s .= '>' . $textfordialog . $img . '</' . $tag . '>'; | |
| 516 | + $s .= '>'.$textfordialog.$img.'</'.$tag.'>'; | |
| 517 | 517 | } | 
| 518 | 518 | if (empty($notabs)) | 
| 519 | 519 | $s .= '</tr></table>'; | 
| @@ -605,15 +605,15 @@ discard block | ||
| 605 | 605 | |
| 606 | 606 | $disabled = 0; | 
| 607 | 607 | $ret = '<div class="centpercent center">'; | 
| 608 | - $ret .= '<select class="flat' . (empty($conf->use_javascript_ajax) ? '' : ' hideobject') . ' massaction massactionselect" name="massaction"' . ($disabled ? ' disabled="disabled"' : '') . '>'; | |
| 608 | + $ret .= '<select class="flat'.(empty($conf->use_javascript_ajax) ? '' : ' hideobject').' massaction massactionselect" name="massaction"'.($disabled ? ' disabled="disabled"' : '').'>'; | |
| 609 | 609 | |
| 610 | 610 | // Complete list with data from external modules. THe module can use $_SERVER['PHP_SELF'] to know on which page we are, or use the $parameters['currentcontext'] completed by executeHooks. | 
| 611 | 611 | $parameters = array(); | 
| 612 | -        $reshook = $hookmanager->executeHooks('addMoreMassActions', $parameters);    // Note that $action and $object may have been modified by hook
 | |
| 612 | +        $reshook = $hookmanager->executeHooks('addMoreMassActions', $parameters); // Note that $action and $object may have been modified by hook
 | |
| 613 | 613 |          if (empty($reshook)) {
 | 
| 614 | -            $ret .= '<option value="0"' . ($disabled ? ' disabled="disabled"' : '') . '>-- ' . $langs->trans("SelectAction") . ' --</option>';
 | |
| 614 | +            $ret .= '<option value="0"'.($disabled ? ' disabled="disabled"' : '').'>-- '.$langs->trans("SelectAction").' --</option>';
 | |
| 615 | 615 |              foreach ($arrayofaction as $code => $label) {
 | 
| 616 | - $ret .= '<option value="' . $code . '"' . ($disabled ? ' disabled="disabled"' : '') . '>' . $label . '</option>'; | |
| 616 | + $ret .= '<option value="'.$code.'"'.($disabled ? ' disabled="disabled"' : '').'>'.$label.'</option>'; | |
| 617 | 617 | } | 
| 618 | 618 | } | 
| 619 | 619 | $ret .= $hookmanager->resPrint; | 
| @@ -621,7 +621,7 @@ discard block | ||
| 621 | 621 | $ret .= '</select>'; | 
| 622 | 622 | // Warning: if you set submit button to disabled, post using 'Enter' will no more work if there is no another input submit. So we add a hidden button | 
| 623 | 623 | $ret .= '<input type="submit" name="confirmmassactioninvisible" style="display: none" tabindex="-1">'; // Hidden button BEFORE so it is the one used when we submit with ENTER. | 
| 624 | -        $ret .= '<input type="submit" disabled name="confirmmassaction" class="button' . (empty($conf->use_javascript_ajax) ? '' : ' hideobject') . ' massaction massactionconfirmed" value="' . dol_escape_htmltag($langs->trans("Confirm")) . '">';
 | |
| 624 | +        $ret .= '<input type="submit" disabled name="confirmmassaction" class="button'.(empty($conf->use_javascript_ajax) ? '' : ' hideobject').' massaction massactionconfirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">';
 | |
| 625 | 625 | $ret .= '</div>'; | 
| 626 | 626 | |
| 627 | 627 |          if (!empty($conf->use_javascript_ajax)) {
 | 
| @@ -635,11 +635,11 @@ discard block | ||
| 635 | 635 | if ($(this).is(\':checked\')) atleastoneselected++; | 
| 636 | 636 | }); | 
| 637 | 637 |  					console.log("initCheckForSelect mode="+mode+" atleastoneselected="+atleastoneselected);
 | 
| 638 | - if (atleastoneselected || ' . $alwaysvisible . ') | |
| 638 | + if (atleastoneselected || ' . $alwaysvisible.') | |
| 639 | 639 |      	  			{
 | 
| 640 | 640 |      	  				jQuery(".massaction").show();
 | 
| 641 | -        			    ' . ($selected ? 'if (atleastoneselected) { jQuery(".massactionselect").val("' . $selected . '"); jQuery(".massactionconfirmed").prop(\'disabled\', false); }' : '') . '
 | |
| 642 | -        			    ' . ($selected ? 'if (! atleastoneselected) { jQuery(".massactionselect").val("0"); jQuery(".massactionconfirmed").prop(\'disabled\', true); } ' : '') . '
 | |
| 641 | +        			    ' . ($selected ? 'if (atleastoneselected) { jQuery(".massactionselect").val("'.$selected.'"); jQuery(".massactionconfirmed").prop(\'disabled\', false); }' : '').'
 | |
| 642 | +        			    ' . ($selected ? 'if (! atleastoneselected) { jQuery(".massactionselect").val("0"); jQuery(".massactionconfirmed").prop(\'disabled\', true); } ' : '').'
 | |
| 643 | 643 | } | 
| 644 | 644 | else | 
| 645 | 645 |      	  			{
 | 
| @@ -708,14 +708,14 @@ discard block | ||
| 708 | 708 | $atleastonefavorite = 0; | 
| 709 | 709 | |
| 710 | 710 | $sql = "SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite"; | 
| 711 | - $sql .= " FROM " . MAIN_DB_PREFIX . "c_country"; | |
| 711 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_country"; | |
| 712 | 712 | $sql .= " WHERE active > 0"; | 
| 713 | 713 | //$sql.= " ORDER BY code ASC"; | 
| 714 | 714 | |
| 715 | - dol_syslog(get_class($this) . "::select_country", LOG_DEBUG); | |
| 715 | + dol_syslog(get_class($this)."::select_country", LOG_DEBUG); | |
| 716 | 716 | $resql = $this->db->query($sql); | 
| 717 | 717 |          if ($resql) {
 | 
| 718 | - $out .= '<select id="select' . $htmlname . '" class="flat maxwidth200onsmartphone selectcountry' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" ' . $htmloption . '>'; | |
| 718 | + $out .= '<select id="select'.$htmlname.'" class="flat maxwidth200onsmartphone selectcountry'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" '.$htmloption.'>'; | |
| 719 | 719 | $num = $this->db->num_rows($resql); | 
| 720 | 720 | $i = 0; | 
| 721 | 721 |              if ($num) {
 | 
| @@ -726,7 +726,7 @@ discard block | ||
| 726 | 726 | $countryArray[$i]['rowid'] = $obj->rowid; | 
| 727 | 727 | $countryArray[$i]['code_iso'] = $obj->code_iso; | 
| 728 | 728 | $countryArray[$i]['code_iso3'] = $obj->code_iso3; | 
| 729 | -                    $countryArray[$i]['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country" . $obj->code_iso) != "Country" . $obj->code_iso ? $langs->transnoentitiesnoconv("Country" . $obj->code_iso) : ($obj->label != '-' ? $obj->label : ''));
 | |
| 729 | +                    $countryArray[$i]['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso) != "Country".$obj->code_iso ? $langs->transnoentitiesnoconv("Country".$obj->code_iso) : ($obj->label != '-' ? $obj->label : ''));
 | |
| 730 | 730 | $countryArray[$i]['favorite'] = $obj->favorite; | 
| 731 | 731 | $favorite[$i] = $obj->favorite; | 
| 732 | 732 | $label[$i] = dol_string_unaccent($countryArray[$i]['label']); | 
| @@ -739,16 +739,16 @@ discard block | ||
| 739 | 739 | $countryArray = dol_sort_array($countryArray, 'label'); | 
| 740 | 740 | |
| 741 | 741 |                  if ($showempty) {
 | 
| 742 | - $out .= '<option value=""> </option>' . "\n"; | |
| 742 | + $out .= '<option value=""> </option>'."\n"; | |
| 743 | 743 | } | 
| 744 | 744 | |
| 745 | 745 |                  if ($addspecialentries) { // Add dedicated entries for groups of countries
 | 
| 746 | 746 | //if ($showempty) $out.= '<option value="" disabled class="selectoptiondisabledwhite">--------------</option>'; | 
| 747 | -                    $out .= '<option value="special_allnotme"' . ($selected == 'special_allnotme' ? ' selected' : '') . '>' . $langs->trans("CountriesExceptMe", $langs->transnoentitiesnoconv("Country" . $mysoc->country_code)) . '</option>';
 | |
| 748 | -                    $out .= '<option value="special_eec"' . ($selected == 'special_eec' ? ' selected' : '') . '>' . $langs->trans("CountriesInEEC") . '</option>';
 | |
| 747 | +                    $out .= '<option value="special_allnotme"'.($selected == 'special_allnotme' ? ' selected' : '').'>'.$langs->trans("CountriesExceptMe", $langs->transnoentitiesnoconv("Country".$mysoc->country_code)).'</option>';
 | |
| 748 | +                    $out .= '<option value="special_eec"'.($selected == 'special_eec' ? ' selected' : '').'>'.$langs->trans("CountriesInEEC").'</option>';
 | |
| 749 | 749 | if ($mysoc->isInEEC()) | 
| 750 | -                        $out .= '<option value="special_eecnotme"' . ($selected == 'special_eecnotme' ? ' selected' : '') . '>' . $langs->trans("CountriesInEECExceptMe", $langs->transnoentitiesnoconv("Country" . $mysoc->country_code)) . '</option>';
 | |
| 751 | -                    $out .= '<option value="special_noteec"' . ($selected == 'special_noteec' ? ' selected' : '') . '>' . $langs->trans("CountriesNotInEEC") . '</option>';
 | |
| 750 | +                        $out .= '<option value="special_eecnotme"'.($selected == 'special_eecnotme' ? ' selected' : '').'>'.$langs->trans("CountriesInEECExceptMe", $langs->transnoentitiesnoconv("Country".$mysoc->country_code)).'</option>';
 | |
| 751 | +                    $out .= '<option value="special_noteec"'.($selected == 'special_noteec' ? ' selected' : '').'>'.$langs->trans("CountriesNotInEEC").'</option>';
 | |
| 752 | 752 | $out .= '<option value="" disabled class="selectoptiondisabledwhite">--------------</option>'; | 
| 753 | 753 | } | 
| 754 | 754 | |
| @@ -765,16 +765,16 @@ discard block | ||
| 765 | 765 | } | 
| 766 | 766 |                      if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['code_iso3'] || $selected == $row['label'])) {
 | 
| 767 | 767 | $foundselected = true; | 
| 768 | - $out .= '<option value="' . ($usecodeaskey ? ($usecodeaskey == 'code2' ? $row['code_iso'] : $row['code_iso3']) : $row['rowid']) . '" selected>'; | |
| 768 | + $out .= '<option value="'.($usecodeaskey ? ($usecodeaskey == 'code2' ? $row['code_iso'] : $row['code_iso3']) : $row['rowid']).'" selected>'; | |
| 769 | 769 |                      } else {
 | 
| 770 | - $out .= '<option value="' . ($usecodeaskey ? ($usecodeaskey == 'code2' ? $row['code_iso'] : $row['code_iso3']) : $row['rowid']) . '">'; | |
| 770 | + $out .= '<option value="'.($usecodeaskey ? ($usecodeaskey == 'code2' ? $row['code_iso'] : $row['code_iso3']) : $row['rowid']).'">'; | |
| 771 | 771 | } | 
| 772 | 772 | if ($row['label']) | 
| 773 | 773 | $out .= dol_trunc($row['label'], $maxlength, 'middle'); | 
| 774 | 774 | else | 
| 775 | 775 | $out .= ' '; | 
| 776 | 776 | if ($row['code_iso']) | 
| 777 | -                        $out .= ' (' . $row['code_iso'] . ')';
 | |
| 777 | +                        $out .= ' ('.$row['code_iso'].')';
 | |
| 778 | 778 | $out .= '</option>'; | 
| 779 | 779 | } | 
| 780 | 780 | } | 
| @@ -785,8 +785,8 @@ discard block | ||
| 785 | 785 | } | 
| 786 | 786 | |
| 787 | 787 | // Make select dynamic | 
| 788 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; | |
| 789 | -        $out .= ajax_combobox('select' . $htmlname);
 | |
| 788 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; | |
| 789 | +        $out .= ajax_combobox('select'.$htmlname);
 | |
| 790 | 790 | |
| 791 | 791 | return $out; | 
| 792 | 792 | } | 
| @@ -815,25 +815,25 @@ discard block | ||
| 815 | 815 | $incotermArray = array(); | 
| 816 | 816 | |
| 817 | 817 | $sql = "SELECT rowid, code"; | 
| 818 | - $sql .= " FROM " . MAIN_DB_PREFIX . "c_incoterms"; | |
| 818 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_incoterms"; | |
| 819 | 819 | $sql .= " WHERE active > 0"; | 
| 820 | 820 | $sql .= " ORDER BY code ASC"; | 
| 821 | 821 | |
| 822 | - dol_syslog(get_class($this) . "::select_incoterm", LOG_DEBUG); | |
| 822 | + dol_syslog(get_class($this)."::select_incoterm", LOG_DEBUG); | |
| 823 | 823 | $resql = $this->db->query($sql); | 
| 824 | 824 |          if ($resql) {
 | 
| 825 | 825 |              if ($conf->use_javascript_ajax && !$forcecombo) {
 | 
| 826 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; | |
| 826 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; | |
| 827 | 827 | $out .= ajax_combobox($htmlname, $events); | 
| 828 | 828 | } | 
| 829 | 829 | |
| 830 | 830 |              if (!empty($page)) {
 | 
| 831 | - $out .= '<form method="post" action="' . $page . '">'; | |
| 831 | + $out .= '<form method="post" action="'.$page.'">'; | |
| 832 | 832 | $out .= '<input type="hidden" name="action" value="set_incoterms">'; | 
| 833 | - $out .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 833 | + $out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 834 | 834 | } | 
| 835 | 835 | |
| 836 | - $out .= '<select id="' . $htmlname . '" class="flat selectincoterm minwidth100imp noenlargeonsmartphone" name="' . $htmlname . '" ' . $htmloption . '>'; | |
| 836 | + $out .= '<select id="'.$htmlname.'" class="flat selectincoterm minwidth100imp noenlargeonsmartphone" name="'.$htmlname.'" '.$htmloption.'>'; | |
| 837 | 837 | $out .= '<option value="0"> </option>'; | 
| 838 | 838 | $num = $this->db->num_rows($resql); | 
| 839 | 839 | $i = 0; | 
| @@ -849,9 +849,9 @@ discard block | ||
| 849 | 849 | |
| 850 | 850 |                  foreach ($incotermArray as $row) {
 | 
| 851 | 851 |                      if ($selected && ($selected == $row['rowid'] || $selected == $row['code'])) {
 | 
| 852 | - $out .= '<option value="' . $row['rowid'] . '" selected>'; | |
| 852 | + $out .= '<option value="'.$row['rowid'].'" selected>'; | |
| 853 | 853 |                      } else {
 | 
| 854 | - $out .= '<option value="' . $row['rowid'] . '">'; | |
| 854 | + $out .= '<option value="'.$row['rowid'].'">'; | |
| 855 | 855 | } | 
| 856 | 856 | |
| 857 | 857 | if ($row['code']) | 
| @@ -862,10 +862,10 @@ discard block | ||
| 862 | 862 | } | 
| 863 | 863 | $out .= '</select>'; | 
| 864 | 864 | |
| 865 | - $out .= '<input id="location_incoterms" class="maxwidth100onsmartphone" name="location_incoterms" value="' . $location_incoterms . '">'; | |
| 865 | + $out .= '<input id="location_incoterms" class="maxwidth100onsmartphone" name="location_incoterms" value="'.$location_incoterms.'">'; | |
| 866 | 866 | |
| 867 | 867 |              if (!empty($page)) {
 | 
| 868 | -                $out .= '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '"></form>';
 | |
| 868 | +                $out .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'"></form>';
 | |
| 869 | 869 | } | 
| 870 | 870 |          } else {
 | 
| 871 | 871 | dol_print_error($this->db); | 
| @@ -894,8 +894,8 @@ discard block | ||
| 894 | 894 | // If product & services are enabled or both disabled. | 
| 895 | 895 |          if ($forceall == 1 || (empty($forceall) && !empty($conf->product->enabled) && !empty($conf->service->enabled)) || (empty($forceall) && empty($conf->product->enabled) && empty($conf->service->enabled))) {
 | 
| 896 | 896 | if (empty($hidetext)) | 
| 897 | -                print $langs->trans("Type") . ': ';
 | |
| 898 | - print '<select class="flat" id="select_' . $htmlname . '" name="' . $htmlname . '">'; | |
| 897 | +                print $langs->trans("Type").': ';
 | |
| 898 | + print '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">'; | |
| 899 | 899 |              if ($showempty) {
 | 
| 900 | 900 | print '<option value="-1"'; | 
| 901 | 901 | if ($selected == -1) | 
| @@ -906,26 +906,26 @@ discard block | ||
| 906 | 906 | print '<option value="0"'; | 
| 907 | 907 | if (0 == $selected) | 
| 908 | 908 | print ' selected'; | 
| 909 | -            print '>' . $langs->trans("Product");
 | |
| 909 | +            print '>'.$langs->trans("Product");
 | |
| 910 | 910 | |
| 911 | 911 | print '<option value="1"'; | 
| 912 | 912 | if (1 == $selected) | 
| 913 | 913 | print ' selected'; | 
| 914 | -            print '>' . $langs->trans("Service");
 | |
| 914 | +            print '>'.$langs->trans("Service");
 | |
| 915 | 915 | |
| 916 | 916 | print '</select>'; | 
| 917 | 917 |              //if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
 | 
| 918 | 918 | } | 
| 919 | 919 |          if ((empty($forceall) && empty($conf->product->enabled) && !empty($conf->service->enabled)) || $forceall == 3) {
 | 
| 920 | 920 |              print $langs->trans("Service");
 | 
| 921 | - print '<input type="hidden" name="' . $htmlname . '" value="1">'; | |
| 921 | + print '<input type="hidden" name="'.$htmlname.'" value="1">'; | |
| 922 | 922 | } | 
| 923 | 923 |          if ((empty($forceall) && !empty($conf->product->enabled) && empty($conf->service->enabled)) || $forceall == 2) {
 | 
| 924 | 924 |              print $langs->trans("Product");
 | 
| 925 | - print '<input type="hidden" name="' . $htmlname . '" value="0">'; | |
| 925 | + print '<input type="hidden" name="'.$htmlname.'" value="0">'; | |
| 926 | 926 | } | 
| 927 | 927 |          if ($forceall < 0) { // This should happened only for contracts when both predefined product and service are disabled.
 | 
| 928 | - print '<input type="hidden" name="' . $htmlname . '" value="1">'; // By default we set on service for contract. If CONTRACT_SUPPORT_PRODUCTS is set, forceall should be 1 not -1 | |
| 928 | + print '<input type="hidden" name="'.$htmlname.'" value="1">'; // By default we set on service for contract. If CONTRACT_SUPPORT_PRODUCTS is set, forceall should be 1 not -1 | |
| 929 | 929 | } | 
| 930 | 930 | } | 
| 931 | 931 | |
| @@ -942,14 +942,14 @@ discard block | ||
| 942 | 942 | |
| 943 | 943 | $num = count($this->cache_types_fees); | 
| 944 | 944 | if ($num > 0) | 
| 945 | - return 0; // Cache already loaded | |
| 945 | + return 0; // Cache already loaded | |
| 946 | 946 | |
| 947 | 947 | dol_syslog(__METHOD__, LOG_DEBUG); | 
| 948 | 948 | |
| 949 | 949 |          $langs->load("trips");
 | 
| 950 | 950 | |
| 951 | 951 | $sql = "SELECT c.code, c.label"; | 
| 952 | - $sql .= " FROM " . MAIN_DB_PREFIX . "c_type_fees as c"; | |
| 952 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees as c"; | |
| 953 | 953 | $sql .= " WHERE active > 0"; | 
| 954 | 954 | |
| 955 | 955 | $resql = $this->db->query($sql); | 
| @@ -989,11 +989,11 @@ discard block | ||
| 989 | 989 | // phpcs:enable | 
| 990 | 990 | global $user, $langs; | 
| 991 | 991 | |
| 992 | - dol_syslog(__METHOD__ . " selected=" . $selected . ", htmlname=" . $htmlname, LOG_DEBUG); | |
| 992 | + dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG); | |
| 993 | 993 | |
| 994 | 994 | $this->load_cache_types_fees(); | 
| 995 | 995 | |
| 996 | - print '<select id="select_' . $htmlname . '" class="flat" name="' . $htmlname . '">'; | |
| 996 | + print '<select id="select_'.$htmlname.'" class="flat" name="'.$htmlname.'">'; | |
| 997 | 997 |          if ($showempty) {
 | 
| 998 | 998 | print '<option value="-1"'; | 
| 999 | 999 | if ($selected == -1) | 
| @@ -1002,7 +1002,7 @@ discard block | ||
| 1002 | 1002 | } | 
| 1003 | 1003 | |
| 1004 | 1004 |          foreach ($this->cache_types_fees as $key => $value) {
 | 
| 1005 | - print '<option value="' . $key . '"'; | |
| 1005 | + print '<option value="'.$key.'"'; | |
| 1006 | 1006 | if ($key == $selected) | 
| 1007 | 1007 | print ' selected'; | 
| 1008 | 1008 | print '>'; | 
| @@ -1065,25 +1065,25 @@ discard block | ||
| 1065 | 1065 | // No immediate load of all database | 
| 1066 | 1066 | $placeholder = ''; | 
| 1067 | 1067 |              if ($selected && empty($selected_input_value)) {
 | 
| 1068 | - require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; | |
| 1068 | + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; | |
| 1069 | 1069 | $societetmp = new Societe($this->db); | 
| 1070 | 1070 | $societetmp->fetch($selected); | 
| 1071 | 1071 | $selected_input_value = $societetmp->name; | 
| 1072 | 1072 | unset($societetmp); | 
| 1073 | 1073 | } | 
| 1074 | 1074 | // mode 1 | 
| 1075 | - $urloption = 'htmlname=' . $htmlname . '&outjson=1&filter=' . $filter . ($showtype ? '&showtype=' . $showtype : ''); | |
| 1076 | - $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); | |
| 1075 | + $urloption = 'htmlname='.$htmlname.'&outjson=1&filter='.$filter.($showtype ? '&showtype='.$showtype : ''); | |
| 1076 | + $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); | |
| 1077 | 1077 |              $out .= '<style type="text/css">.ui-autocomplete { z-index: 250; }</style>';
 | 
| 1078 | 1078 | if (empty($hidelabel)) | 
| 1079 | -                print $langs->trans("RefOrLabel") . ' : ';
 | |
| 1079 | +                print $langs->trans("RefOrLabel").' : ';
 | |
| 1080 | 1080 |              else if ($hidelabel > 1) {
 | 
| 1081 | -                $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
 | |
| 1081 | +                $placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"';
 | |
| 1082 | 1082 |                  if ($hidelabel == 2) {
 | 
| 1083 | 1083 |                      $out .= img_picto($langs->trans("Search"), 'search');
 | 
| 1084 | 1084 | } | 
| 1085 | 1085 | } | 
| 1086 | - $out .= '<input type="text" class="' . $morecss . '" name="search_' . $htmlname . '" id="search_' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' ' . (!empty($conf->global->THIRDPARTY_SEARCH_AUTOFOCUS) ? 'autofocus' : '') . ' />'; | |
| 1086 | + $out .= '<input type="text" class="'.$morecss.'" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' '.(!empty($conf->global->THIRDPARTY_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; | |
| 1087 | 1087 |              if ($hidelabel == 3) {
 | 
| 1088 | 1088 |                  $out .= img_picto($langs->trans("Search"), 'search');
 | 
| 1089 | 1089 | } | 
| @@ -1144,20 +1144,20 @@ discard block | ||
| 1144 | 1144 | $sql .= " , dictp.code as country_code"; | 
| 1145 | 1145 | } | 
| 1146 | 1146 | |
| 1147 | -        $sql .= " FROM (" . MAIN_DB_PREFIX . "societe as s";
 | |
| 1147 | +        $sql .= " FROM (".MAIN_DB_PREFIX."societe as s";
 | |
| 1148 | 1148 | if (!$user->rights->societe->client->voir && !$user->socid) | 
| 1149 | - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; | |
| 1149 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; | |
| 1150 | 1150 | $sql .= " )"; | 
| 1151 | 1151 |          if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) {
 | 
| 1152 | - $sql .= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "c_country as dictp ON dictp.rowid=s.fk_pays"; | |
| 1152 | + $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."c_country as dictp ON dictp.rowid=s.fk_pays"; | |
| 1153 | 1153 | } | 
| 1154 | -        $sql .= " WHERE s.entity IN (" . getEntity('societe') . ")";
 | |
| 1154 | +        $sql .= " WHERE s.entity IN (".getEntity('societe').")";
 | |
| 1155 | 1155 | if (!empty($user->socid)) | 
| 1156 | - $sql .= " AND s.rowid = " . $user->socid; | |
| 1156 | + $sql .= " AND s.rowid = ".$user->socid; | |
| 1157 | 1157 | if ($filter) | 
| 1158 | -            $sql .= " AND (" . $filter . ")";
 | |
| 1158 | +            $sql .= " AND (".$filter.")";
 | |
| 1159 | 1159 | if (!$user->rights->societe->client->voir && !$user->socid) | 
| 1160 | - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; | |
| 1160 | + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; | |
| 1161 | 1161 | if (!empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) | 
| 1162 | 1162 | $sql .= " AND s.status <> 0"; | 
| 1163 | 1163 | // Add criteria | 
| @@ -1172,31 +1172,31 @@ discard block | ||
| 1172 | 1172 |              foreach ($scrit as $crit) {
 | 
| 1173 | 1173 | if ($i > 0) | 
| 1174 | 1174 | $sql .= " AND "; | 
| 1175 | - $sql .= "(s.nom LIKE '" . $this->db->escape($prefix . $crit) . "%')"; | |
| 1175 | + $sql .= "(s.nom LIKE '".$this->db->escape($prefix.$crit)."%')"; | |
| 1176 | 1176 | $i++; | 
| 1177 | 1177 | } | 
| 1178 | 1178 | if (count($scrit) > 1) | 
| 1179 | 1179 | $sql .= ")"; | 
| 1180 | 1180 |              if (!empty($conf->barcode->enabled)) {
 | 
| 1181 | - $sql .= " OR s.barcode LIKE '" . $this->db->escape($prefix . $filterkey) . "%'"; | |
| 1181 | + $sql .= " OR s.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; | |
| 1182 | 1182 | } | 
| 1183 | - $sql .= " OR s.code_client LIKE '" . $this->db->escape($prefix . $filterkey) . "%' OR s.code_fournisseur LIKE '" . $this->db->escape($prefix . $filterkey) . "%'"; | |
| 1183 | + $sql .= " OR s.code_client LIKE '".$this->db->escape($prefix.$filterkey)."%' OR s.code_fournisseur LIKE '".$this->db->escape($prefix.$filterkey)."%'"; | |
| 1184 | 1184 | $sql .= ")"; | 
| 1185 | 1185 | } | 
| 1186 | 1186 |          $sql .= $this->db->order("nom", "ASC");
 | 
| 1187 | 1187 | $sql .= $this->db->plimit($limit, 0); | 
| 1188 | 1188 | |
| 1189 | 1189 | // Build output string | 
| 1190 | - dol_syslog(get_class($this) . "::select_thirdparty_list", LOG_DEBUG); | |
| 1190 | + dol_syslog(get_class($this)."::select_thirdparty_list", LOG_DEBUG); | |
| 1191 | 1191 | $resql = $this->db->query($sql); | 
| 1192 | 1192 |          if ($resql) {
 | 
| 1193 | 1193 |              if (!$forcecombo) {
 | 
| 1194 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; | |
| 1194 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; | |
| 1195 | 1195 | $out .= ajax_combobox($htmlname, $events, $conf->global->COMPANY_USE_SEARCH_TO_SELECT); | 
| 1196 | 1196 | } | 
| 1197 | 1197 | |
| 1198 | 1198 | // Construct $out and $outarray | 
| 1199 | - $out .= '<select id="' . $htmlname . '" class="flat' . ($morecss ? ' ' . $morecss : '') . '"' . ($moreparam ? ' ' . $moreparam : '') . ' name="' . $htmlname . ($multiple ? '[]' : '') . '" ' . ($multiple ? 'multiple' : '') . '>' . "\n"; | |
| 1199 | + $out .= '<select id="'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'"'.($moreparam ? ' '.$moreparam : '').' name="'.$htmlname.($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').'>'."\n"; | |
| 1200 | 1200 | |
| 1201 | 1201 | $textifempty = ''; | 
| 1202 | 1202 | // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. | 
| @@ -1208,7 +1208,7 @@ discard block | ||
| 1208 | 1208 |                      $textifempty .= $langs->trans("All");
 | 
| 1209 | 1209 | } | 
| 1210 | 1210 | if ($showempty) | 
| 1211 | - $out .= '<option value="-1">' . $textifempty . '</option>' . "\n"; | |
| 1211 | + $out .= '<option value="-1">'.$textifempty.'</option>'."\n"; | |
| 1212 | 1212 | |
| 1213 | 1213 | $num = $this->db->num_rows($resql); | 
| 1214 | 1214 | $i = 0; | 
| @@ -1218,18 +1218,18 @@ discard block | ||
| 1218 | 1218 | $label = ''; | 
| 1219 | 1219 |                      if ($conf->global->SOCIETE_ADD_REF_IN_LIST) {
 | 
| 1220 | 1220 |                          if (($obj->client) && (!empty($obj->code_client))) {
 | 
| 1221 | - $label = $obj->code_client . ' - '; | |
| 1221 | + $label = $obj->code_client.' - '; | |
| 1222 | 1222 | } | 
| 1223 | 1223 |                          if (($obj->fournisseur) && (!empty($obj->code_fournisseur))) {
 | 
| 1224 | - $label .= $obj->code_fournisseur . ' - '; | |
| 1224 | + $label .= $obj->code_fournisseur.' - '; | |
| 1225 | 1225 | } | 
| 1226 | - $label .= ' ' . $obj->name; | |
| 1226 | + $label .= ' '.$obj->name; | |
| 1227 | 1227 |                      } else {
 | 
| 1228 | 1228 | $label = $obj->name; | 
| 1229 | 1229 | } | 
| 1230 | 1230 | |
| 1231 | 1231 |                      if (!empty($obj->name_alias)) {
 | 
| 1232 | -                        $label .= ' (' . $obj->name_alias . ')';
 | |
| 1232 | +                        $label .= ' ('.$obj->name_alias.')';
 | |
| 1233 | 1233 | } | 
| 1234 | 1234 | |
| 1235 | 1235 |                      if ($showtype) {
 | 
| @@ -1238,25 +1238,25 @@ discard block | ||
| 1238 | 1238 | if ($obj->client == 1 || $obj->client == 3) | 
| 1239 | 1239 |                              $label .= $langs->trans("Customer");
 | 
| 1240 | 1240 | if ($obj->client == 2 || $obj->client == 3) | 
| 1241 | -                            $label .= ($obj->client == 3 ? ', ' : '') . $langs->trans("Prospect");
 | |
| 1241 | +                            $label .= ($obj->client == 3 ? ', ' : '').$langs->trans("Prospect");
 | |
| 1242 | 1242 | if ($obj->fournisseur) | 
| 1243 | -                            $label .= ($obj->client ? ', ' : '') . $langs->trans("Supplier");
 | |
| 1243 | +                            $label .= ($obj->client ? ', ' : '').$langs->trans("Supplier");
 | |
| 1244 | 1244 | if ($obj->client || $obj->fournisseur) | 
| 1245 | 1245 | $label .= ')'; | 
| 1246 | 1246 | } | 
| 1247 | 1247 | |
| 1248 | 1248 |                      if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) {
 | 
| 1249 | - $label .= '-' . $obj->address . '-' . $obj->zip . ' ' . $obj->town; | |
| 1249 | + $label .= '-'.$obj->address.'-'.$obj->zip.' '.$obj->town; | |
| 1250 | 1250 |                          if (!empty($obj->country_code)) {
 | 
| 1251 | -                            $label .= ' ' . $langs->trans('Country' . $obj->country_code);
 | |
| 1251 | +                            $label .= ' '.$langs->trans('Country'.$obj->country_code);
 | |
| 1252 | 1252 | } | 
| 1253 | 1253 | } | 
| 1254 | 1254 | |
| 1255 | 1255 |                      if (empty($outputmode)) {
 | 
| 1256 | 1256 |                          if (in_array($obj->rowid, $selected)) {
 | 
| 1257 | - $out .= '<option value="' . $obj->rowid . '" selected>' . $label . '</option>'; | |
| 1257 | + $out .= '<option value="'.$obj->rowid.'" selected>'.$label.'</option>'; | |
| 1258 | 1258 |                          } else {
 | 
| 1259 | - $out .= '<option value="' . $obj->rowid . '">' . $label . '</option>'; | |
| 1259 | + $out .= '<option value="'.$obj->rowid.'">'.$label.'</option>'; | |
| 1260 | 1260 | } | 
| 1261 | 1261 |                      } else {
 | 
| 1262 | 1262 |                          array_push($outarray, array('key' => $obj->rowid, 'value' => $label, 'label' => $label));
 | 
| @@ -1267,7 +1267,7 @@ discard block | ||
| 1267 | 1267 | $out .= "\n"; | 
| 1268 | 1268 | } | 
| 1269 | 1269 | } | 
| 1270 | - $out .= '</select>' . "\n"; | |
| 1270 | + $out .= '</select>'."\n"; | |
| 1271 | 1271 | } | 
| 1272 | 1272 |          else {
 | 
| 1273 | 1273 | dol_print_error($this->db); | 
| @@ -1299,17 +1299,17 @@ discard block | ||
| 1299 | 1299 | // On recherche les remises | 
| 1300 | 1300 | $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; | 
| 1301 | 1301 | $sql .= " re.description, re.fk_facture_source"; | 
| 1302 | - $sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re"; | |
| 1303 | - $sql .= " WHERE re.fk_soc = " . (int) $socid; | |
| 1304 | - $sql .= " AND re.entity = " . $conf->entity; | |
| 1302 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re"; | |
| 1303 | + $sql .= " WHERE re.fk_soc = ".(int) $socid; | |
| 1304 | + $sql .= " AND re.entity = ".$conf->entity; | |
| 1305 | 1305 | if ($filter) | 
| 1306 | - $sql .= " AND " . $filter; | |
| 1306 | + $sql .= " AND ".$filter; | |
| 1307 | 1307 | $sql .= " ORDER BY re.description ASC"; | 
| 1308 | 1308 | |
| 1309 | - dol_syslog(get_class($this) . "::select_remises", LOG_DEBUG); | |
| 1309 | + dol_syslog(get_class($this)."::select_remises", LOG_DEBUG); | |
| 1310 | 1310 | $resql = $this->db->query($sql); | 
| 1311 | 1311 |          if ($resql) {
 | 
| 1312 | - print '<select id="select_' . $htmlname . '" class="flat maxwidthonsmartphone" name="' . $htmlname . '">'; | |
| 1312 | + print '<select id="select_'.$htmlname.'" class="flat maxwidthonsmartphone" name="'.$htmlname.'">'; | |
| 1313 | 1313 | $num = $this->db->num_rows($resql); | 
| 1314 | 1314 | |
| 1315 | 1315 | $qualifiedlines = $num; | 
| @@ -1342,10 +1342,10 @@ discard block | ||
| 1342 | 1342 |                      if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST) && !empty($obj->fk_facture_source)) {
 | 
| 1343 | 1343 | $tmpfac = new Facture($this->db); | 
| 1344 | 1344 | if ($tmpfac->fetch($obj->fk_facture_source) > 0) | 
| 1345 | - $desc = $desc . ' - ' . $tmpfac->ref; | |
| 1345 | + $desc = $desc.' - '.$tmpfac->ref; | |
| 1346 | 1346 | } | 
| 1347 | 1347 | |
| 1348 | -                    print '<option value="' . $obj->rowid . '"' . $selectstring . $disabled . '>' . $desc . ' (' . price($obj->amount_ht) . ' ' . $langs->trans("HT") . ' - ' . price($obj->amount_ttc) . ' ' . $langs->trans("TTC") . ')</option>';
 | |
| 1348 | +                    print '<option value="'.$obj->rowid.'"'.$selectstring.$disabled.'>'.$desc.' ('.price($obj->amount_ht).' '.$langs->trans("HT").' - '.price($obj->amount_ttc).' '.$langs->trans("TTC").')</option>';
 | |
| 1349 | 1349 | $i++; | 
| 1350 | 1350 | } | 
| 1351 | 1351 | } | 
| @@ -1425,7 +1425,7 @@ discard block | ||
| 1425 | 1425 | $out = ''; | 
| 1426 | 1426 | |
| 1427 | 1427 |          if (!is_object($hookmanager)) {
 | 
| 1428 | - include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; | |
| 1428 | + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; | |
| 1429 | 1429 | $hookmanager = new HookManager($this->db); | 
| 1430 | 1430 | } | 
| 1431 | 1431 | |
| @@ -1433,36 +1433,36 @@ discard block | ||
| 1433 | 1433 | $sql = "SELECT sp.rowid, sp.lastname, sp.statut, sp.firstname, sp.poste"; | 
| 1434 | 1434 | if ($showsoc > 0) | 
| 1435 | 1435 | $sql .= " , s.nom as company"; | 
| 1436 | - $sql .= " FROM " . MAIN_DB_PREFIX . "socpeople as sp"; | |
| 1436 | + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; | |
| 1437 | 1437 | if ($showsoc > 0) | 
| 1438 | - $sql .= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid=sp.fk_soc"; | |
| 1439 | -        $sql .= " WHERE sp.entity IN (" . getEntity('socpeople') . ")";
 | |
| 1438 | + $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=sp.fk_soc"; | |
| 1439 | +        $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")";
 | |
| 1440 | 1440 | if ($socid > 0 || $socid == -1) | 
| 1441 | - $sql .= " AND sp.fk_soc=" . $socid; | |
| 1441 | + $sql .= " AND sp.fk_soc=".$socid; | |
| 1442 | 1442 | if (!empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) | 
| 1443 | 1443 | $sql .= " AND sp.statut <> 0"; | 
| 1444 | 1444 | $sql .= " ORDER BY sp.lastname ASC"; | 
| 1445 | 1445 | |
| 1446 | - dol_syslog(get_class($this) . "::select_contacts", LOG_DEBUG); | |
| 1446 | + dol_syslog(get_class($this)."::select_contacts", LOG_DEBUG); | |
| 1447 | 1447 | $resql = $this->db->query($sql); | 
| 1448 | 1448 |          if ($resql) {
 | 
| 1449 | 1449 | $num = $this->db->num_rows($resql); | 
| 1450 | 1450 | |
| 1451 | 1451 |              if ($conf->use_javascript_ajax && !$forcecombo && !$options_only) {
 | 
| 1452 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; | |
| 1452 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; | |
| 1453 | 1453 | $out .= ajax_combobox($htmlid, $events, $conf->global->CONTACT_USE_SEARCH_TO_SELECT); | 
| 1454 | 1454 | } | 
| 1455 | 1455 | |
| 1456 | 1456 | if ($htmlname != 'none' || $options_only) | 
| 1457 | - $out .= '<select class="flat' . ($moreclass ? ' ' . $moreclass : '') . '" id="' . $htmlid . '" name="' . $htmlname . ($multiple ? '[]' : '') . '" ' . ($multiple ? 'multiple' : '') . ' ' . (!empty($moreparam) ? $moreparam : '') . '>'; | |
| 1457 | + $out .= '<select class="flat'.($moreclass ? ' '.$moreclass : '').'" id="'.$htmlid.'" name="'.$htmlname.($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').' '.(!empty($moreparam) ? $moreparam : '').'>'; | |
| 1458 | 1458 | if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple) | 
| 1459 | - $out .= '<option value="0"' . (in_array(0, $selected) ? ' selected' : '') . '> </option>'; | |
| 1459 | + $out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'> </option>'; | |
| 1460 | 1460 | if ($showempty == 2) | 
| 1461 | -                $out .= '<option value="0"' . (in_array(0, $selected) ? ' selected' : '') . '>' . $langs->trans("Internal") . '</option>';
 | |
| 1461 | +                $out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'>'.$langs->trans("Internal").'</option>';
 | |
| 1462 | 1462 | $num = $this->db->num_rows($resql); | 
| 1463 | 1463 | $i = 0; | 
| 1464 | 1464 |              if ($num) {
 | 
| 1465 | - include_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; | |
| 1465 | + include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; | |
| 1466 | 1466 | $contactstatic = new Contact($this->db); | 
| 1467 | 1467 | |
| 1468 | 1468 |                  while ($i < $num) {
 | 
| @@ -1479,27 +1479,27 @@ discard block | ||
| 1479 | 1479 | if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) | 
| 1480 | 1480 | $disabled = 1; | 
| 1481 | 1481 |                              if (!empty($selected) && in_array($obj->rowid, $selected)) {
 | 
| 1482 | - $out .= '<option value="' . $obj->rowid . '"'; | |
| 1482 | + $out .= '<option value="'.$obj->rowid.'"'; | |
| 1483 | 1483 | if ($disabled) | 
| 1484 | 1484 | $out .= ' disabled'; | 
| 1485 | 1485 | $out .= ' selected>'; | 
| 1486 | 1486 | $out .= $contactstatic->getFullName($langs); | 
| 1487 | 1487 | if ($showfunction && $obj->poste) | 
| 1488 | -                                    $out .= ' (' . $obj->poste . ')';
 | |
| 1488 | +                                    $out .= ' ('.$obj->poste.')';
 | |
| 1489 | 1489 | if (($showsoc > 0) && $obj->company) | 
| 1490 | -                                    $out .= ' - (' . $obj->company . ')';
 | |
| 1490 | +                                    $out .= ' - ('.$obj->company.')';
 | |
| 1491 | 1491 | $out .= '</option>'; | 
| 1492 | 1492 | } | 
| 1493 | 1493 |                              else {
 | 
| 1494 | - $out .= '<option value="' . $obj->rowid . '"'; | |
| 1494 | + $out .= '<option value="'.$obj->rowid.'"'; | |
| 1495 | 1495 | if ($disabled) | 
| 1496 | 1496 | $out .= ' disabled'; | 
| 1497 | 1497 | $out .= '>'; | 
| 1498 | 1498 | $out .= $contactstatic->getFullName($langs); | 
| 1499 | 1499 | if ($showfunction && $obj->poste) | 
| 1500 | -                                    $out .= ' (' . $obj->poste . ')';
 | |
| 1500 | +                                    $out .= ' ('.$obj->poste.')';
 | |
| 1501 | 1501 | if (($showsoc > 0) && $obj->company) | 
| 1502 | -                                    $out .= ' - (' . $obj->company . ')';
 | |
| 1502 | +                                    $out .= ' - ('.$obj->company.')';
 | |
| 1503 | 1503 | $out .= '</option>'; | 
| 1504 | 1504 | } | 
| 1505 | 1505 | } | 
| @@ -1507,9 +1507,9 @@ discard block | ||
| 1507 | 1507 |                              if (in_array($obj->rowid, $selected)) {
 | 
| 1508 | 1508 | $out .= $contactstatic->getFullName($langs); | 
| 1509 | 1509 | if ($showfunction && $obj->poste) | 
| 1510 | -                                    $out .= ' (' . $obj->poste . ')';
 | |
| 1510 | +                                    $out .= ' ('.$obj->poste.')';
 | |
| 1511 | 1511 | if (($showsoc > 0) && $obj->company) | 
| 1512 | -                                    $out .= ' - (' . $obj->company . ')';
 | |
| 1512 | +                                    $out .= ' - ('.$obj->company.')';
 | |
| 1513 | 1513 | } | 
| 1514 | 1514 | } | 
| 1515 | 1515 | } | 
| @@ -1517,7 +1517,7 @@ discard block | ||
| 1517 | 1517 | } | 
| 1518 | 1518 | } | 
| 1519 | 1519 |              else {
 | 
| 1520 | - $out .= '<option value="-1"' . (($showempty == 2 || $multiple) ? '' : ' selected') . ' disabled>'; | |
| 1520 | + $out .= '<option value="-1"'.(($showempty == 2 || $multiple) ? '' : ' selected').' disabled>'; | |
| 1521 | 1521 |                  $out .= ($socid != -1) ? ($langs->trans($socid ? "NoContactDefinedForThirdParty" : "NoContactDefined")) : $langs->trans('SelectAThirdPartyFirst');
 | 
| 1522 | 1522 | $out .= '</option>'; | 
| 1523 | 1523 | } | 
| @@ -1531,7 +1531,7 @@ discard block | ||
| 1531 | 1531 | 'showsoc' => $showsoc, | 
| 1532 | 1532 | ); | 
| 1533 | 1533 | |
| 1534 | -            $reshook = $hookmanager->executeHooks('afterSelectContactOptions', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
 | |
| 1534 | +            $reshook = $hookmanager->executeHooks('afterSelectContactOptions', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 | |
| 1535 | 1535 | |
| 1536 | 1536 |              if ($htmlname != 'none' || $options_only) {
 | 
| 1537 | 1537 | $out .= '</select>'; | 
| @@ -1630,33 +1630,33 @@ discard block | ||
| 1630 | 1630 |          if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
 | 
| 1631 | 1631 | $sql .= ", e.label"; | 
| 1632 | 1632 | } | 
| 1633 | - $sql .= " FROM " . MAIN_DB_PREFIX . "user as u"; | |
| 1633 | + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; | |
| 1634 | 1634 |          if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
 | 
| 1635 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "entity as e ON e.rowid=u.entity"; | |
| 1635 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entity as e ON e.rowid=u.entity"; | |
| 1636 | 1636 | if ($force_entity) | 
| 1637 | - $sql .= " WHERE u.entity IN (0," . $force_entity . ")"; | |
| 1637 | + $sql .= " WHERE u.entity IN (0,".$force_entity.")"; | |
| 1638 | 1638 | else | 
| 1639 | 1639 | $sql .= " WHERE u.entity IS NOT NULL"; | 
| 1640 | 1640 | } | 
| 1641 | 1641 |          else {
 | 
| 1642 | 1642 |              if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
 | 
| 1643 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "usergroup_user as ug"; | |
| 1643 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug"; | |
| 1644 | 1644 | $sql .= " ON ug.fk_user = u.rowid"; | 
| 1645 | - $sql .= " WHERE ug.entity = " . $conf->entity; | |
| 1645 | + $sql .= " WHERE ug.entity = ".$conf->entity; | |
| 1646 | 1646 |              } else {
 | 
| 1647 | - $sql .= " WHERE u.entity IN (0," . $conf->entity . ")"; | |
| 1647 | + $sql .= " WHERE u.entity IN (0,".$conf->entity.")"; | |
| 1648 | 1648 | } | 
| 1649 | 1649 | } | 
| 1650 | 1650 | if (!empty($user->societe_id)) | 
| 1651 | - $sql .= " AND u.fk_soc = " . $user->societe_id; | |
| 1651 | + $sql .= " AND u.fk_soc = ".$user->societe_id; | |
| 1652 | 1652 | if (is_array($exclude) && $excludeUsers) | 
| 1653 | -            $sql .= " AND u.rowid NOT IN (" . $excludeUsers . ")";
 | |
| 1653 | +            $sql .= " AND u.rowid NOT IN (".$excludeUsers.")";
 | |
| 1654 | 1654 | if ($includeUsers) | 
| 1655 | -            $sql .= " AND u.rowid IN (" . $includeUsers . ")";
 | |
| 1655 | +            $sql .= " AND u.rowid IN (".$includeUsers.")";
 | |
| 1656 | 1656 | if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) | 
| 1657 | 1657 | $sql .= " AND u.statut <> 0"; | 
| 1658 | 1658 | if (!empty($morefilter)) | 
| 1659 | - $sql .= " " . $morefilter; | |
| 1659 | + $sql .= " ".$morefilter; | |
| 1660 | 1660 | |
| 1661 | 1661 |          if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname
 | 
| 1662 | 1662 | $sql .= " ORDER BY u.firstname ASC"; | 
| @@ -1664,22 +1664,22 @@ discard block | ||
| 1664 | 1664 | $sql .= " ORDER BY u.lastname ASC"; | 
| 1665 | 1665 | } | 
| 1666 | 1666 | |
| 1667 | - dol_syslog(get_class($this) . "::select_dolusers", LOG_DEBUG); | |
| 1667 | + dol_syslog(get_class($this)."::select_dolusers", LOG_DEBUG); | |
| 1668 | 1668 | $resql = $this->db->query($sql); | 
| 1669 | 1669 |          if ($resql) {
 | 
| 1670 | 1670 | $num = $this->db->num_rows($resql); | 
| 1671 | 1671 | $i = 0; | 
| 1672 | 1672 |              if ($num) {
 | 
| 1673 | 1673 | // Enhance with select2 | 
| 1674 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; | |
| 1674 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; | |
| 1675 | 1675 | $out .= ajax_combobox($htmlname); | 
| 1676 | 1676 | |
| 1677 | 1677 | // do not use maxwidthonsmartphone by default. Set it by caller so auto size to 100% will work when not defined | 
| 1678 | - $out .= '<select class="flat' . ($morecss ? ' minwidth100 ' . $morecss : ' minwidth200') . '" id="' . $htmlname . '" name="' . $htmlname . ($multiple ? '[]' : '') . '" ' . ($multiple ? 'multiple' : '') . ' ' . ($disabled ? ' disabled' : '') . '>'; | |
| 1678 | + $out .= '<select class="flat'.($morecss ? ' minwidth100 '.$morecss : ' minwidth200').'" id="'.$htmlname.'" name="'.$htmlname.($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').' '.($disabled ? ' disabled' : '').'>'; | |
| 1679 | 1679 | if ($show_empty && !$multiple) | 
| 1680 | - $out .= '<option value="-1"' . ((empty($selected) || in_array(-1, $selected)) ? ' selected' : '') . '> </option>' . "\n"; | |
| 1680 | + $out .= '<option value="-1"'.((empty($selected) || in_array(-1, $selected)) ? ' selected' : '').'> </option>'."\n"; | |
| 1681 | 1681 | if ($show_every) | 
| 1682 | -                    $out .= '<option value="-2"' . ((in_array(-2, $selected)) ? ' selected' : '') . '>-- ' . $langs->trans("Everybody") . ' --</option>' . "\n";
 | |
| 1682 | +                    $out .= '<option value="-2"'.((in_array(-2, $selected)) ? ' selected' : '').'>-- '.$langs->trans("Everybody").' --</option>'."\n";
 | |
| 1683 | 1683 | |
| 1684 | 1684 | $userstatic = new User($this->db); | 
| 1685 | 1685 | |
| @@ -1694,14 +1694,14 @@ discard block | ||
| 1694 | 1694 | if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) | 
| 1695 | 1695 | $disableline = ($enableonlytext ? $enableonlytext : '1'); | 
| 1696 | 1696 | |
| 1697 | -                    if ((is_object($selected) && $selected->id == $obj->rowid) || (!is_object($selected) && in_array($obj->rowid, $selected) )) {
 | |
| 1698 | - $out .= '<option value="' . $obj->rowid . '"'; | |
| 1697 | +                    if ((is_object($selected) && $selected->id == $obj->rowid) || (!is_object($selected) && in_array($obj->rowid, $selected))) {
 | |
| 1698 | + $out .= '<option value="'.$obj->rowid.'"'; | |
| 1699 | 1699 | if ($disableline) | 
| 1700 | 1700 | $out .= ' disabled'; | 
| 1701 | 1701 | $out .= ' selected>'; | 
| 1702 | 1702 | } | 
| 1703 | 1703 |                      else {
 | 
| 1704 | - $out .= '<option value="' . $obj->rowid . '"'; | |
| 1704 | + $out .= '<option value="'.$obj->rowid.'"'; | |
| 1705 | 1705 | if ($disableline) | 
| 1706 | 1706 | $out .= ' disabled'; | 
| 1707 | 1707 | $out .= '>'; | 
| @@ -1717,31 +1717,31 @@ discard block | ||
| 1717 | 1717 | // Complete name with more info | 
| 1718 | 1718 | $moreinfo = 0; | 
| 1719 | 1719 |                      if (!empty($conf->global->MAIN_SHOW_LOGIN)) {
 | 
| 1720 | -                        $out .= ($moreinfo ? ' - ' : ' (') . $obj->login;
 | |
| 1720 | +                        $out .= ($moreinfo ? ' - ' : ' (').$obj->login;
 | |
| 1721 | 1721 | $moreinfo++; | 
| 1722 | 1722 | } | 
| 1723 | 1723 |                      if ($showstatus >= 0) {
 | 
| 1724 | 1724 |                          if ($obj->statut == 1 && $showstatus == 1) {
 | 
| 1725 | -                            $out .= ($moreinfo ? ' - ' : ' (') . $langs->trans('Enabled');
 | |
| 1725 | +                            $out .= ($moreinfo ? ' - ' : ' (').$langs->trans('Enabled');
 | |
| 1726 | 1726 | $moreinfo++; | 
| 1727 | 1727 | } | 
| 1728 | 1728 |                          if ($obj->statut == 0) {
 | 
| 1729 | -                            $out .= ($moreinfo ? ' - ' : ' (') . $langs->trans('Disabled');
 | |
| 1729 | +                            $out .= ($moreinfo ? ' - ' : ' (').$langs->trans('Disabled');
 | |
| 1730 | 1730 | $moreinfo++; | 
| 1731 | 1731 | } | 
| 1732 | 1732 | } | 
| 1733 | 1733 |                      if (!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
 | 
| 1734 | 1734 |                          if (!$obj->entity) {
 | 
| 1735 | -                            $out .= ($moreinfo ? ' - ' : ' (') . $langs->trans("AllEntities");
 | |
| 1735 | +                            $out .= ($moreinfo ? ' - ' : ' (').$langs->trans("AllEntities");
 | |
| 1736 | 1736 | $moreinfo++; | 
| 1737 | 1737 |                          } else {
 | 
| 1738 | -                            $out .= ($moreinfo ? ' - ' : ' (') . ($obj->label ? $obj->label : $langs->trans("EntityNameNotDefined"));
 | |
| 1738 | +                            $out .= ($moreinfo ? ' - ' : ' (').($obj->label ? $obj->label : $langs->trans("EntityNameNotDefined"));
 | |
| 1739 | 1739 | $moreinfo++; | 
| 1740 | 1740 | } | 
| 1741 | 1741 | } | 
| 1742 | 1742 | $out .= ($moreinfo ? ')' : ''); | 
| 1743 | 1743 |                      if ($disableline && $disableline != '1') {
 | 
| 1744 | - $out .= ' - ' . $disableline; // This is text from $enableonlytext parameter | |
| 1744 | + $out .= ' - '.$disableline; // This is text from $enableonlytext parameter | |
| 1745 | 1745 | } | 
| 1746 | 1746 | $out .= '</option>'; | 
| 1747 | 1747 | $outarray[$userstatic->id] = $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength); | 
| @@ -1749,8 +1749,8 @@ discard block | ||
| 1749 | 1749 | $i++; | 
| 1750 | 1750 | } | 
| 1751 | 1751 |              } else {
 | 
| 1752 | - $out .= '<select class="flat" id="' . $htmlname . '" name="' . $htmlname . '" disabled>'; | |
| 1753 | -                $out .= '<option value="">' . $langs->trans("None") . '</option>';
 | |
| 1752 | + $out .= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'" disabled>'; | |
| 1753 | +                $out .= '<option value="">'.$langs->trans("None").'</option>';
 | |
| 1754 | 1754 | } | 
| 1755 | 1755 | $out .= '</select>'; | 
| 1756 | 1756 |          } else {
 | 
| @@ -1801,7 +1801,7 @@ discard block | ||
| 1801 | 1801 | $out .= '<input type="hidden" class="removedassignedhidden" name="removedassigned" value="">'; | 
| 1802 | 1802 |              $out .= '<script type="text/javascript" language="javascript">jQuery(document).ready(function () {    jQuery(".removedassigned").click(function() {        jQuery(".removedassignedhidden").val(jQuery(this).val());    });})</script>';
 | 
| 1803 | 1803 |              $out .= $this->select_dolusers('', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter);
 | 
| 1804 | -            $out .= ' <input type="submit" class="button valignmiddle" name="' . $action . 'assignedtouser" value="' . dol_escape_htmltag($langs->trans("Add")) . '">';
 | |
| 1804 | +            $out .= ' <input type="submit" class="button valignmiddle" name="'.$action.'assignedtouser" value="'.dol_escape_htmltag($langs->trans("Add")).'">';
 | |
| 1805 | 1805 | $out .= '<br>'; | 
| 1806 | 1806 | } | 
| 1807 | 1807 | $assignedtouser = array(); | 
| @@ -1825,16 +1825,16 @@ discard block | ||
| 1825 | 1825 | $out .= $userstatic->getNomUrl(-1); | 
| 1826 | 1826 |              if ($i == 0) {
 | 
| 1827 | 1827 | $ownerid = $value['id']; | 
| 1828 | -                $out .= ' (' . $langs->trans("Owner") . ')';
 | |
| 1828 | +                $out .= ' ('.$langs->trans("Owner").')';
 | |
| 1829 | 1829 | } | 
| 1830 | 1830 |              if ($nbassignetouser > 1 && $action != 'view') {
 | 
| 1831 | -                $out .= ' <input type="image" style="border: 0px;" src="' . img_picto($langs->trans("Remove"), 'delete', '', 0, 1) . '" value="' . $userstatic->id . '" class="removedassigned" id="removedassigned_' . $userstatic->id . '" name="removedassigned_' . $userstatic->id . '">';
 | |
| 1831 | +                $out .= ' <input type="image" style="border: 0px;" src="'.img_picto($langs->trans("Remove"), 'delete', '', 0, 1).'" value="'.$userstatic->id.'" class="removedassigned" id="removedassigned_'.$userstatic->id.'" name="removedassigned_'.$userstatic->id.'">';
 | |
| 1832 | 1832 | } | 
| 1833 | 1833 | // Show my availability | 
| 1834 | 1834 |              if ($showproperties) {
 | 
| 1835 | 1835 |                  if ($ownerid == $value['id'] && is_array($listofuserid) && count($listofuserid) && in_array($ownerid, array_keys($listofuserid))) {
 | 
| 1836 | 1836 | $out .= '<div class="myavailability inline-block">'; | 
| 1837 | -                    $out .= ' - <span class="opacitymedium">' . $langs->trans("Availability") . ':</span>  <input id="transparency" class="marginleftonly marginrightonly" ' . ($action == 'view' ? 'disabled' : '') . ' type="checkbox" name="transparency"' . ($listofuserid[$ownerid]['transparency'] ? ' checked' : '') . '>' . $langs->trans("Busy");
 | |
| 1837 | +                    $out .= ' - <span class="opacitymedium">'.$langs->trans("Availability").':</span>  <input id="transparency" class="marginleftonly marginrightonly" '.($action == 'view' ? 'disabled' : '').' type="checkbox" name="transparency"'.($listofuserid[$ownerid]['transparency'] ? ' checked' : '').'>'.$langs->trans("Busy");
 | |
| 1838 | 1838 | $out .= '</div>'; | 
| 1839 | 1839 | } | 
| 1840 | 1840 | } | 
| @@ -1888,19 +1888,19 @@ discard block | ||
| 1888 | 1888 | $placeholder = ''; | 
| 1889 | 1889 | |
| 1890 | 1890 |              if ($selected && empty($selected_input_value)) {
 | 
| 1891 | - require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; | |
| 1891 | + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; | |
| 1892 | 1892 | $producttmpselect = new Product($this->db); | 
| 1893 | 1893 | $producttmpselect->fetch($selected); | 
| 1894 | 1894 | $selected_input_value = $producttmpselect->ref; | 
| 1895 | 1895 | unset($producttmpselect); | 
| 1896 | 1896 | } | 
| 1897 | 1897 | // mode=1 means customers products | 
| 1898 | - $urloption = 'htmlname=' . $htmlname . '&outjson=1&price_level=' . $price_level . '&type=' . $filtertype . '&mode=1&status=' . $status . '&finished=' . $finished . '&hidepriceinlabel=' . $hidepriceinlabel . '&warehousestatus=' . $warehouseStatus; | |
| 1898 | + $urloption = 'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished.'&hidepriceinlabel='.$hidepriceinlabel.'&warehousestatus='.$warehouseStatus; | |
| 1899 | 1899 | //Price by customer | 
| 1900 | 1900 |              if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
 | 
| 1901 | - $urloption .= '&socid=' . $socid; | |
| 1901 | + $urloption .= '&socid='.$socid; | |
| 1902 | 1902 | } | 
| 1903 | - print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); | |
| 1903 | + print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); | |
| 1904 | 1904 | |
| 1905 | 1905 |              if (!empty($conf->variants->enabled)) {
 | 
| 1906 | 1906 | |
| @@ -1977,14 +1977,14 @@ discard block | ||
| 1977 | 1977 | <?php | 
| 1978 | 1978 | } | 
| 1979 | 1979 | if (empty($hidelabel)) | 
| 1980 | -                                print $langs->trans("RefOrLabel") . ' : ';
 | |
| 1980 | +                                print $langs->trans("RefOrLabel").' : ';
 | |
| 1981 | 1981 |                              else if ($hidelabel > 1) {
 | 
| 1982 | -                                $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
 | |
| 1982 | +                                $placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"';
 | |
| 1983 | 1983 |                                  if ($hidelabel == 2) {
 | 
| 1984 | 1984 |                                      print img_picto($langs->trans("Search"), 'search');
 | 
| 1985 | 1985 | } | 
| 1986 | 1986 | } | 
| 1987 | - print '<input type="text" class="minwidth100" name="search_' . $htmlname . '" id="search_' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' ' . (!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '') . ' />'; | |
| 1987 | + print '<input type="text" class="minwidth100" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' '.(!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; | |
| 1988 | 1988 |                              if ($hidelabel == 3) {
 | 
| 1989 | 1989 |                                  print img_picto($langs->trans("Search"), 'search');
 | 
| 1990 | 1990 | } | 
| @@ -2027,7 +2027,7 @@ discard block | ||
| 2027 | 2027 | |
| 2028 | 2028 | $warehouseStatusArray = array(); | 
| 2029 | 2029 |          if (!empty($warehouseStatus)) {
 | 
| 2030 | - require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php'; | |
| 2030 | + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; | |
| 2031 | 2031 |              if (preg_match('/warehouseclosed/', $warehouseStatus)) {
 | 
| 2032 | 2032 | $warehouseStatusArray[] = Entrepot::STATUS_CLOSED; | 
| 2033 | 2033 | } | 
| @@ -2043,13 +2043,13 @@ discard block | ||
| 2043 | 2043 | (count($warehouseStatusArray)) ? $selectFieldsGrouped = ", sum(ps.reel) as stock" : $selectFieldsGrouped = ", p.stock"; | 
| 2044 | 2044 | |
| 2045 | 2045 | $sql = "SELECT "; | 
| 2046 | - $sql .= $selectFields . $selectFieldsGrouped; | |
| 2046 | + $sql .= $selectFields.$selectFieldsGrouped; | |
| 2047 | 2047 | |
| 2048 | 2048 |          if (!empty($conf->global->PRODUCT_SORT_BY_CATEGORY)) {
 | 
| 2049 | 2049 | //Product category | 
| 2050 | - $sql .= ", (SELECT " . MAIN_DB_PREFIX . "categorie_product.fk_categorie | |
| 2051 | - FROM " . MAIN_DB_PREFIX . "categorie_product | |
| 2052 | - WHERE " . MAIN_DB_PREFIX . "categorie_product.fk_product=p.rowid | |
| 2050 | + $sql .= ", (SELECT ".MAIN_DB_PREFIX."categorie_product.fk_categorie | |
| 2051 | + FROM " . MAIN_DB_PREFIX."categorie_product | |
| 2052 | + WHERE " . MAIN_DB_PREFIX."categorie_product.fk_product=p.rowid | |
| 2053 | 2053 | LIMIT 1 | 
| 2054 | 2054 | ) AS categorie_product_id "; | 
| 2055 | 2055 | } | 
| @@ -2068,45 +2068,45 @@ discard block | ||
| 2068 | 2068 | } | 
| 2069 | 2069 | // Price by quantity | 
| 2070 | 2070 |          if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
 | 
| 2071 | - $sql .= ", (SELECT pp.rowid FROM " . MAIN_DB_PREFIX . "product_price as pp WHERE pp.fk_product = p.rowid"; | |
| 2071 | + $sql .= ", (SELECT pp.rowid FROM ".MAIN_DB_PREFIX."product_price as pp WHERE pp.fk_product = p.rowid"; | |
| 2072 | 2072 | if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) | 
| 2073 | - $sql .= " AND price_level=" . $price_level; | |
| 2073 | + $sql .= " AND price_level=".$price_level; | |
| 2074 | 2074 | $sql .= " ORDER BY date_price"; | 
| 2075 | 2075 | $sql .= " DESC LIMIT 1) as price_rowid"; | 
| 2076 | - $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 | |
| 2076 | + $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 | 2077 | if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) | 
| 2078 | - $sql .= " AND price_level=" . $price_level; | |
| 2078 | + $sql .= " AND price_level=".$price_level; | |
| 2079 | 2079 | $sql .= " ORDER BY date_price"; | 
| 2080 | 2080 | $sql .= " DESC LIMIT 1) as price_by_qty"; | 
| 2081 | 2081 | $selectFields .= ", price_rowid, price_by_qty"; | 
| 2082 | 2082 | } | 
| 2083 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product as p"; | |
| 2083 | + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; | |
| 2084 | 2084 |          if (count($warehouseStatusArray)) {
 | 
| 2085 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_stock as ps on ps.fk_product = p.rowid"; | |
| 2086 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "entrepot as e on ps.fk_entrepot = e.rowid"; | |
| 2085 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.fk_product = p.rowid"; | |
| 2086 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e on ps.fk_entrepot = e.rowid"; | |
| 2087 | 2087 | } | 
| 2088 | 2088 | |
| 2089 | 2089 | // include search in supplier ref | 
| 2090 | 2090 |          if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) {
 | 
| 2091 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; | |
| 2091 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; | |
| 2092 | 2092 | } | 
| 2093 | 2093 | |
| 2094 | 2094 | //Price by customer | 
| 2095 | 2095 |          if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
 | 
| 2096 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_customer_price as pcp ON pcp.fk_soc=" . $socid . " AND pcp.fk_product=p.rowid"; | |
| 2096 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_customer_price as pcp ON pcp.fk_soc=".$socid." AND pcp.fk_product=p.rowid"; | |
| 2097 | 2097 | } | 
| 2098 | 2098 | // Multilang : we add translation | 
| 2099 | 2099 |          if (!empty($conf->global->MAIN_MULTILANGS)) {
 | 
| 2100 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_lang as pl ON pl.fk_product = p.rowid AND pl.lang='" . $langs->getDefaultLang() . "'"; | |
| 2100 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang='".$langs->getDefaultLang()."'"; | |
| 2101 | 2101 | } | 
| 2102 | 2102 | |
| 2103 | 2103 |          if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
 | 
| 2104 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_attribute_combination pac ON pac.fk_product_child = p.rowid"; | |
| 2104 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid"; | |
| 2105 | 2105 | } | 
| 2106 | 2106 | |
| 2107 | -        $sql .= ' WHERE p.entity IN (' . getEntity('product') . ')';
 | |
| 2107 | +        $sql .= ' WHERE p.entity IN ('.getEntity('product').')';
 | |
| 2108 | 2108 |          if (count($warehouseStatusArray)) {
 | 
| 2109 | -            $sql .= ' AND (p.fk_product_type = 1 OR e.statut IN (' . $this->db->escape(implode(',', $warehouseStatusArray)) . '))';
 | |
| 2109 | +            $sql .= ' AND (p.fk_product_type = 1 OR e.statut IN ('.$this->db->escape(implode(',', $warehouseStatusArray)).'))';
 | |
| 2110 | 2110 | } | 
| 2111 | 2111 | |
| 2112 | 2112 |          if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
 | 
| @@ -2114,17 +2114,17 @@ discard block | ||
| 2114 | 2114 | } | 
| 2115 | 2115 | |
| 2116 | 2116 |          if ($finished == 0) {
 | 
| 2117 | - $sql .= " AND p.finished = " . $finished; | |
| 2117 | + $sql .= " AND p.finished = ".$finished; | |
| 2118 | 2118 |          } elseif ($finished == 1) {
 | 
| 2119 | - $sql .= " AND p.finished = " . $finished; | |
| 2119 | + $sql .= " AND p.finished = ".$finished; | |
| 2120 | 2120 | if ($status >= 0) | 
| 2121 | - $sql .= " AND p.tosell = " . $status; | |
| 2121 | + $sql .= " AND p.tosell = ".$status; | |
| 2122 | 2122 | } | 
| 2123 | 2123 |          elseif ($status >= 0) {
 | 
| 2124 | - $sql .= " AND p.tosell = " . $status; | |
| 2124 | + $sql .= " AND p.tosell = ".$status; | |
| 2125 | 2125 | } | 
| 2126 | 2126 | if (strval($filtertype) != '') | 
| 2127 | - $sql .= " AND p.fk_product_type=" . $filtertype; | |
| 2127 | + $sql .= " AND p.fk_product_type=".$filtertype; | |
| 2128 | 2128 | // Add criteria on ref/label | 
| 2129 | 2129 |          if ($filterkey != '') {
 | 
| 2130 | 2130 |              $sql .= ' AND (';
 | 
| @@ -2137,27 +2137,27 @@ discard block | ||
| 2137 | 2137 |              foreach ($scrit as $crit) {
 | 
| 2138 | 2138 | if ($i > 0) | 
| 2139 | 2139 | $sql .= " AND "; | 
| 2140 | - $sql .= "(p.ref LIKE '" . $db->escape($prefix . $crit) . "%' OR p.label LIKE '" . $db->escape($prefix . $crit) . "%'"; | |
| 2140 | + $sql .= "(p.ref LIKE '".$db->escape($prefix.$crit)."%' OR p.label LIKE '".$db->escape($prefix.$crit)."%'"; | |
| 2141 | 2141 | if (!empty($conf->global->MAIN_MULTILANGS)) | 
| 2142 | - $sql .= " OR pl.label LIKE '" . $db->escape($prefix . $crit) . "%'"; | |
| 2142 | + $sql .= " OR pl.label LIKE '".$db->escape($prefix.$crit)."%'"; | |
| 2143 | 2143 |                  if (!empty($conf->global->PRODUCT_AJAX_SEARCH_ON_DESCRIPTION)) {
 | 
| 2144 | - $sql .= " OR p.description LIKE '" . $db->escape($prefix . $crit) . "%'"; | |
| 2144 | + $sql .= " OR p.description LIKE '".$db->escape($prefix.$crit)."%'"; | |
| 2145 | 2145 | if (!empty($conf->global->MAIN_MULTILANGS)) | 
| 2146 | - $sql .= " OR pl.description LIKE '" . $db->escape($prefix . $crit) . "%'"; | |
| 2146 | + $sql .= " OR pl.description LIKE '".$db->escape($prefix.$crit)."%'"; | |
| 2147 | 2147 | } | 
| 2148 | 2148 | if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) | 
| 2149 | - $sql .= " OR pfp.ref_fourn LIKE '" . $db->escape($prefix . $crit) . "%'"; | |
| 2149 | + $sql .= " OR pfp.ref_fourn LIKE '".$db->escape($prefix.$crit)."%'"; | |
| 2150 | 2150 | $sql .= ")"; | 
| 2151 | 2151 | $i++; | 
| 2152 | 2152 | } | 
| 2153 | 2153 | if (count($scrit) > 1) | 
| 2154 | 2154 | $sql .= ")"; | 
| 2155 | 2155 | if (!empty($conf->barcode->enabled)) | 
| 2156 | - $sql .= " OR p.barcode LIKE '" . $db->escape($prefix . $filterkey) . "%'"; | |
| 2156 | + $sql .= " OR p.barcode LIKE '".$db->escape($prefix.$filterkey)."%'"; | |
| 2157 | 2157 | $sql .= ')'; | 
| 2158 | 2158 | } | 
| 2159 | 2159 |          if (count($warehouseStatusArray)) {
 | 
| 2160 | - $sql .= ' GROUP BY' . $selectFields; | |
| 2160 | + $sql .= ' GROUP BY'.$selectFields; | |
| 2161 | 2161 | } | 
| 2162 | 2162 | |
| 2163 | 2163 | //Sort by category | 
| @@ -2172,21 +2172,21 @@ discard block | ||
| 2172 | 2172 | $sql .= $db->plimit($limit, 0); | 
| 2173 | 2173 | |
| 2174 | 2174 | // Build output string | 
| 2175 | - dol_syslog(get_class($this) . "::select_produits_list search product", LOG_DEBUG); | |
| 2175 | + dol_syslog(get_class($this)."::select_produits_list search product", LOG_DEBUG); | |
| 2176 | 2176 | $result = $this->db->query($sql); | 
| 2177 | 2177 |          if ($result) {
 | 
| 2178 | - require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; | |
| 2179 | - require_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_parser.class.php'; | |
| 2178 | + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; | |
| 2179 | + require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; | |
| 2180 | 2180 | $num = $this->db->num_rows($result); | 
| 2181 | 2181 | |
| 2182 | 2182 | $events = null; | 
| 2183 | 2183 | |
| 2184 | 2184 |              if (!$forcecombo) {
 | 
| 2185 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; | |
| 2185 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; | |
| 2186 | 2186 | $out .= ajax_combobox($htmlname, $events, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT); | 
| 2187 | 2187 | } | 
| 2188 | 2188 | |
| 2189 | - $out .= '<select class="flat' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">'; | |
| 2189 | + $out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">'; | |
| 2190 | 2190 | |
| 2191 | 2191 | $textifempty = ''; | 
| 2192 | 2192 | // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. | 
| @@ -2198,7 +2198,7 @@ discard block | ||
| 2198 | 2198 |                      $textifempty .= $langs->trans("All");
 | 
| 2199 | 2199 | } | 
| 2200 | 2200 | if ($showempty) | 
| 2201 | - $out .= '<option value="0" selected>' . $textifempty . '</option>'; | |
| 2201 | + $out .= '<option value="0" selected>'.$textifempty.'</option>'; | |
| 2202 | 2202 | |
| 2203 | 2203 | $i = 0; | 
| 2204 | 2204 |              while ($num && $i < $num) {
 | 
| @@ -2208,11 +2208,11 @@ discard block | ||
| 2208 | 2208 | |
| 2209 | 2209 |                  if ((!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($objp->price_by_qty) && $objp->price_by_qty == 1) { // Price by quantity will return many prices for the same product
 | 
| 2210 | 2210 | $sql = "SELECT rowid, quantity, price, unitprice, remise_percent, remise, price_base_type"; | 
| 2211 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_price_by_qty"; | |
| 2212 | - $sql .= " WHERE fk_product_price=" . $objp->price_rowid; | |
| 2211 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_price_by_qty"; | |
| 2212 | + $sql .= " WHERE fk_product_price=".$objp->price_rowid; | |
| 2213 | 2213 | $sql .= " ORDER BY quantity ASC"; | 
| 2214 | 2214 | |
| 2215 | - dol_syslog(get_class($this) . "::select_produits_list search price by qty", LOG_DEBUG); | |
| 2215 | + dol_syslog(get_class($this)."::select_produits_list search price by qty", LOG_DEBUG); | |
| 2216 | 2216 | $result2 = $this->db->query($sql); | 
| 2217 | 2217 |                      if ($result2) {
 | 
| 2218 | 2218 | $nb_prices = $this->db->num_rows($result2); | 
| @@ -2316,7 +2316,7 @@ discard block | ||
| 2316 | 2316 | if (!empty($objp->label_translated)) | 
| 2317 | 2317 | $label = $objp->label_translated; | 
| 2318 | 2318 | if (!empty($filterkey) && $filterkey != '') | 
| 2319 | -            $label = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $label, 1);
 | |
| 2319 | +            $label = preg_replace('/('.preg_quote($filterkey).')/i', '<strong>$1</strong>', $label, 1);
 | |
| 2320 | 2320 | |
| 2321 | 2321 | $outkey = $objp->rowid; | 
| 2322 | 2322 | $outref = $objp->ref; | 
| @@ -2328,10 +2328,10 @@ discard block | ||
| 2328 | 2328 | $outdurationvalue = $outtype == Product::TYPE_SERVICE ? substr($objp->duration, 0, dol_strlen($objp->duration) - 1) : ''; | 
| 2329 | 2329 | $outdurationunit = $outtype == Product::TYPE_SERVICE ? substr($objp->duration, -1) : ''; | 
| 2330 | 2330 | |
| 2331 | - $opt = '<option value="' . $objp->rowid . '"'; | |
| 2331 | + $opt = '<option value="'.$objp->rowid.'"'; | |
| 2332 | 2332 | $opt .= ($objp->rowid == $selected) ? ' selected' : ''; | 
| 2333 | 2333 |          if (!empty($objp->price_by_qty_rowid) && $objp->price_by_qty_rowid > 0) {
 | 
| 2334 | - $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 . '"'; | |
| 2334 | + $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 | 2335 | } | 
| 2336 | 2336 |          if (!empty($conf->stock->enabled) && $objp->fk_product_type == 0 && isset($objp->stock)) {
 | 
| 2337 | 2337 | if ($objp->stock > 0) | 
| @@ -2342,16 +2342,16 @@ discard block | ||
| 2342 | 2342 | $opt .= '>'; | 
| 2343 | 2343 | $opt .= $objp->ref; | 
| 2344 | 2344 | if ($outbarcode) | 
| 2345 | -            $opt .= ' (' . $outbarcode . ')';
 | |
| 2346 | - $opt .= ' - ' . dol_trunc($label, $maxlengtharticle); | |
| 2345 | +            $opt .= ' ('.$outbarcode.')';
 | |
| 2346 | + $opt .= ' - '.dol_trunc($label, $maxlengtharticle); | |
| 2347 | 2347 | |
| 2348 | 2348 | $objRef = $objp->ref; | 
| 2349 | 2349 | if (!empty($filterkey) && $filterkey != '') | 
| 2350 | -            $objRef = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $objRef, 1);
 | |
| 2350 | +            $objRef = preg_replace('/('.preg_quote($filterkey).')/i', '<strong>$1</strong>', $objRef, 1);
 | |
| 2351 | 2351 | $outval .= $objRef; | 
| 2352 | 2352 | if ($outbarcode) | 
| 2353 | -            $outval .= ' (' . $outbarcode . ')';
 | |
| 2354 | - $outval .= ' - ' . dol_trunc($label, $maxlengtharticle); | |
| 2353 | +            $outval .= ' ('.$outbarcode.')';
 | |
| 2354 | + $outval .= ' - '.dol_trunc($label, $maxlengtharticle); | |
| 2355 | 2355 | |
| 2356 | 2356 | $found = 0; | 
| 2357 | 2357 | |
| @@ -2359,25 +2359,25 @@ discard block | ||
| 2359 | 2359 | // If we need a particular price level (from 1 to 6) | 
| 2360 | 2360 |          if (empty($hidepriceinlabel) && $price_level >= 1 && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) {
 | 
| 2361 | 2361 | $sql = "SELECT price, price_ttc, price_base_type, tva_tx"; | 
| 2362 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product_price"; | |
| 2363 | - $sql .= " WHERE fk_product='" . $objp->rowid . "'"; | |
| 2364 | -            $sql .= " AND entity IN (" . getEntity('productprice') . ")";
 | |
| 2365 | - $sql .= " AND price_level=" . $price_level; | |
| 2362 | + $sql .= " FROM ".MAIN_DB_PREFIX."product_price"; | |
| 2363 | + $sql .= " WHERE fk_product='".$objp->rowid."'"; | |
| 2364 | +            $sql .= " AND entity IN (".getEntity('productprice').")";
 | |
| 2365 | + $sql .= " AND price_level=".$price_level; | |
| 2366 | 2366 | $sql .= " ORDER BY date_price DESC, rowid DESC"; // Warning DESC must be both on date_price and rowid. | 
| 2367 | 2367 | $sql .= " LIMIT 1"; | 
| 2368 | 2368 | |
| 2369 | - dol_syslog(get_class($this) . '::constructProductListOption search price for level ' . $price_level . '', LOG_DEBUG); | |
| 2369 | + dol_syslog(get_class($this).'::constructProductListOption search price for level '.$price_level.'', LOG_DEBUG); | |
| 2370 | 2370 | $result2 = $this->db->query($sql); | 
| 2371 | 2371 |              if ($result2) {
 | 
| 2372 | 2372 | $objp2 = $this->db->fetch_object($result2); | 
| 2373 | 2373 |                  if ($objp2) {
 | 
| 2374 | 2374 | $found = 1; | 
| 2375 | 2375 |                      if ($objp2->price_base_type == 'HT') {
 | 
| 2376 | -                        $opt .= ' - ' . price($objp2->price, 1, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->trans("HT");
 | |
| 2377 | -                        $outval .= ' - ' . price($objp2->price, 0, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->transnoentities("HT");
 | |
| 2376 | +                        $opt .= ' - '.price($objp2->price, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("HT");
 | |
| 2377 | +                        $outval .= ' - '.price($objp2->price, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("HT");
 | |
| 2378 | 2378 |                      } else {
 | 
| 2379 | -                        $opt .= ' - ' . price($objp2->price_ttc, 1, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->trans("TTC");
 | |
| 2380 | -                        $outval .= ' - ' . price($objp2->price_ttc, 0, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->transnoentities("TTC");
 | |
| 2379 | +                        $opt .= ' - '.price($objp2->price_ttc, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("TTC");
 | |
| 2380 | +                        $outval .= ' - '.price($objp2->price_ttc, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("TTC");
 | |
| 2381 | 2381 | } | 
| 2382 | 2382 | $outprice_ht = price($objp2->price); | 
| 2383 | 2383 | $outprice_ttc = price($objp2->price_ttc); | 
| @@ -2395,13 +2395,13 @@ discard block | ||
| 2395 | 2395 | $outqty = $objp->quantity; | 
| 2396 | 2396 | $outdiscount = $objp->remise_percent; | 
| 2397 | 2397 |              if ($objp->quantity == 1) {
 | 
| 2398 | - $opt .= ' - ' . price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency) . "/"; | |
| 2399 | - $outval .= ' - ' . price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency) . "/"; | |
| 2398 | + $opt .= ' - '.price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency)."/"; | |
| 2399 | + $outval .= ' - '.price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency)."/"; | |
| 2400 | 2400 |                  $opt .= $langs->trans("Unit"); // Do not use strtolower because it breaks utf8 encoding
 | 
| 2401 | 2401 |                  $outval .= $langs->transnoentities("Unit");
 | 
| 2402 | 2402 |              } else {
 | 
| 2403 | - $opt .= ' - ' . price($objp->price, 1, $langs, 0, 0, -1, $conf->currency) . "/" . $objp->quantity; | |
| 2404 | - $outval .= ' - ' . price($objp->price, 0, $langs, 0, 0, -1, $conf->currency) . "/" . $objp->quantity; | |
| 2403 | + $opt .= ' - '.price($objp->price, 1, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity; | |
| 2404 | + $outval .= ' - '.price($objp->price, 0, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity; | |
| 2405 | 2405 |                  $opt .= $langs->trans("Units"); // Do not use strtolower because it breaks utf8 encoding
 | 
| 2406 | 2406 |                  $outval .= $langs->transnoentities("Units");
 | 
| 2407 | 2407 | } | 
| @@ -2412,12 +2412,12 @@ discard block | ||
| 2412 | 2412 | $outtva_tx = $objp->tva_tx; | 
| 2413 | 2413 | } | 
| 2414 | 2414 |          if (empty($hidepriceinlabel) && !empty($objp->quantity) && $objp->quantity >= 1) {
 | 
| 2415 | -            $opt .= " (" . price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency) . "/" . $langs->trans("Unit") . ")"; // Do not use strtolower because it breaks utf8 encoding
 | |
| 2416 | -            $outval .= " (" . price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency) . "/" . $langs->transnoentities("Unit") . ")"; // Do not use strtolower because it breaks utf8 encoding
 | |
| 2415 | +            $opt .= " (".price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit").")"; // Do not use strtolower because it breaks utf8 encoding
 | |
| 2416 | +            $outval .= " (".price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->transnoentities("Unit").")"; // Do not use strtolower because it breaks utf8 encoding
 | |
| 2417 | 2417 | } | 
| 2418 | 2418 |          if (empty($hidepriceinlabel) && !empty($objp->remise_percent) && $objp->remise_percent >= 1) {
 | 
| 2419 | -            $opt .= " - " . $langs->trans("Discount") . " : " . vatrate($objp->remise_percent) . ' %';
 | |
| 2420 | -            $outval .= " - " . $langs->transnoentities("Discount") . " : " . vatrate($objp->remise_percent) . ' %';
 | |
| 2419 | +            $opt .= " - ".$langs->trans("Discount")." : ".vatrate($objp->remise_percent).' %';
 | |
| 2420 | +            $outval .= " - ".$langs->transnoentities("Discount")." : ".vatrate($objp->remise_percent).' %';
 | |
| 2421 | 2421 | } | 
| 2422 | 2422 | |
| 2423 | 2423 | // Price by customer | 
| @@ -2426,11 +2426,11 @@ discard block | ||
| 2426 | 2426 | $found = 1; | 
| 2427 | 2427 | |
| 2428 | 2428 |                  if ($objp->custprice_base_type == 'HT') {
 | 
| 2429 | -                    $opt .= ' - ' . price($objp->custprice, 1, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->trans("HT");
 | |
| 2430 | -                    $outval .= ' - ' . price($objp->custprice, 0, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->transnoentities("HT");
 | |
| 2429 | +                    $opt .= ' - '.price($objp->custprice, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("HT");
 | |
| 2430 | +                    $outval .= ' - '.price($objp->custprice, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("HT");
 | |
| 2431 | 2431 |                  } else {
 | 
| 2432 | -                    $opt .= ' - ' . price($objp->custprice_ttc, 1, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->trans("TTC");
 | |
| 2433 | -                    $outval .= ' - ' . price($objp->custprice_ttc, 0, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->transnoentities("TTC");
 | |
| 2432 | +                    $opt .= ' - '.price($objp->custprice_ttc, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("TTC");
 | |
| 2433 | +                    $outval .= ' - '.price($objp->custprice_ttc, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("TTC");
 | |
| 2434 | 2434 | } | 
| 2435 | 2435 | |
| 2436 | 2436 | $outprice_ht = price($objp->custprice); | 
| @@ -2443,11 +2443,11 @@ discard block | ||
| 2443 | 2443 | // If level no defined or multiprice not found, we used the default price | 
| 2444 | 2444 |          if (empty($hidepriceinlabel) && !$found) {
 | 
| 2445 | 2445 |              if ($objp->price_base_type == 'HT') {
 | 
| 2446 | -                $opt .= ' - ' . price($objp->price, 1, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->trans("HT");
 | |
| 2447 | -                $outval .= ' - ' . price($objp->price, 0, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->transnoentities("HT");
 | |
| 2446 | +                $opt .= ' - '.price($objp->price, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("HT");
 | |
| 2447 | +                $outval .= ' - '.price($objp->price, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("HT");
 | |
| 2448 | 2448 |              } else {
 | 
| 2449 | -                $opt .= ' - ' . price($objp->price_ttc, 1, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->trans("TTC");
 | |
| 2450 | -                $outval .= ' - ' . price($objp->price_ttc, 0, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->transnoentities("TTC");
 | |
| 2449 | +                $opt .= ' - '.price($objp->price_ttc, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("TTC");
 | |
| 2450 | +                $outval .= ' - '.price($objp->price_ttc, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("TTC");
 | |
| 2451 | 2451 | } | 
| 2452 | 2452 | $outprice_ht = price($objp->price); | 
| 2453 | 2453 | $outprice_ttc = price($objp->price_ttc); | 
| @@ -2456,21 +2456,21 @@ discard block | ||
| 2456 | 2456 | } | 
| 2457 | 2457 | |
| 2458 | 2458 |          if (!empty($conf->stock->enabled) && isset($objp->stock) && $objp->fk_product_type == 0) {
 | 
| 2459 | -            $opt .= ' - ' . $langs->trans("Stock") . ':' . $objp->stock;
 | |
| 2459 | +            $opt .= ' - '.$langs->trans("Stock").':'.$objp->stock;
 | |
| 2460 | 2460 | |
| 2461 | 2461 |              if ($objp->stock > 0) {
 | 
| 2462 | -                $outval .= ' - <span class="product_line_stock_ok">' . $langs->transnoentities("Stock") . ':' . $objp->stock . '</span>';
 | |
| 2462 | +                $outval .= ' - <span class="product_line_stock_ok">'.$langs->transnoentities("Stock").':'.$objp->stock.'</span>';
 | |
| 2463 | 2463 |              } elseif ($objp->stock <= 0) {
 | 
| 2464 | -                $outval .= ' - <span class="product_line_stock_too_low">' . $langs->transnoentities("Stock") . ':' . $objp->stock . '</span>';
 | |
| 2464 | +                $outval .= ' - <span class="product_line_stock_too_low">'.$langs->transnoentities("Stock").':'.$objp->stock.'</span>';
 | |
| 2465 | 2465 | } | 
| 2466 | 2466 | } | 
| 2467 | 2467 | |
| 2468 | 2468 |          if ($outdurationvalue && $outdurationunit) {
 | 
| 2469 | 2469 |              $da = array("h" => $langs->trans("Hour"), "d" => $langs->trans("Day"), "w" => $langs->trans("Week"), "m" => $langs->trans("Month"), "y" => $langs->trans("Year"));
 | 
| 2470 | 2470 |              if (isset($da[$outdurationunit])) {
 | 
| 2471 | - $key = $da[$outdurationunit] . ($outdurationvalue > 1 ? 's' : ''); | |
| 2472 | - $opt .= ' - ' . $outdurationvalue . ' ' . $langs->trans($key); | |
| 2473 | - $outval .= ' - ' . $outdurationvalue . ' ' . $langs->transnoentities($key); | |
| 2471 | + $key = $da[$outdurationunit].($outdurationvalue > 1 ? 's' : ''); | |
| 2472 | + $opt .= ' - '.$outdurationvalue.' '.$langs->trans($key); | |
| 2473 | + $outval .= ' - '.$outdurationvalue.' '.$langs->transnoentities($key); | |
| 2474 | 2474 | } | 
| 2475 | 2475 | } | 
| 2476 | 2476 | |
| @@ -2501,7 +2501,7 @@ discard block | ||
| 2501 | 2501 | $selected_input_value = ''; | 
| 2502 | 2502 |          if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) {
 | 
| 2503 | 2503 |              if ($selected > 0) {
 | 
| 2504 | - require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; | |
| 2504 | + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; | |
| 2505 | 2505 | $producttmpselect = new Product($this->db); | 
| 2506 | 2506 | $producttmpselect->fetch($selected); | 
| 2507 | 2507 | $selected_input_value = $producttmpselect->ref; | 
| @@ -2509,9 +2509,9 @@ discard block | ||
| 2509 | 2509 | } | 
| 2510 | 2510 | |
| 2511 | 2511 | // mode=2 means suppliers products | 
| 2512 | - $urloption = ($socid > 0 ? 'socid=' . $socid . '&' : '') . 'htmlname=' . $htmlname . '&outjson=1&price_level=' . $price_level . '&type=' . $filtertype . '&mode=2&status=' . $status . '&finished=' . $finished . '&alsoproductwithnosupplierprice=' . $alsoproductwithnosupplierprice; | |
| 2513 | - print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); | |
| 2514 | -            print ($hidelabel ? '' : $langs->trans("RefOrLabel") . ' : ') . '<input type="text" size="20" name="search_' . $htmlname . '" id="search_' . $htmlname . '" value="' . $selected_input_value . '">';
 | |
| 2512 | + $urloption = ($socid > 0 ? 'socid='.$socid.'&' : '').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished.'&alsoproductwithnosupplierprice='.$alsoproductwithnosupplierprice; | |
| 2513 | + print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); | |
| 2514 | +            print ($hidelabel ? '' : $langs->trans("RefOrLabel").' : ').'<input type="text" size="20" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'">';
 | |
| 2515 | 2515 |          } else {
 | 
| 2516 | 2516 | print $this->select_produits_fournisseurs_list($socid, $selected, $htmlname, $filtertype, $filtre, '', -1, 0, 0, $alsoproductwithnosupplierprice); | 
| 2517 | 2517 | } | 
| @@ -2547,17 +2547,17 @@ discard block | ||
| 2547 | 2547 | $sql .= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,"; | 
| 2548 | 2548 | $sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,"; | 
| 2549 | 2549 | $sql .= " pfp.supplier_reputation"; | 
| 2550 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product as p"; | |
| 2551 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; | |
| 2550 | + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; | |
| 2551 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; | |
| 2552 | 2552 | if ($socid) | 
| 2553 | - $sql .= " AND pfp.fk_soc = " . $socid; | |
| 2554 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON pfp.fk_soc = s.rowid"; | |
| 2555 | -        $sql .= " WHERE p.entity IN (" . getEntity('product') . ")";
 | |
| 2553 | + $sql .= " AND pfp.fk_soc = ".$socid; | |
| 2554 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid"; | |
| 2555 | +        $sql .= " WHERE p.entity IN (".getEntity('product').")";
 | |
| 2556 | 2556 | $sql .= " AND p.tobuy = 1"; | 
| 2557 | 2557 | if (strval($filtertype) != '') | 
| 2558 | - $sql .= " AND p.fk_product_type=" . $this->db->escape($filtertype); | |
| 2558 | + $sql .= " AND p.fk_product_type=".$this->db->escape($filtertype); | |
| 2559 | 2559 | if (!empty($filtre)) | 
| 2560 | - $sql .= " " . $filtre; | |
| 2560 | + $sql .= " ".$filtre; | |
| 2561 | 2561 | // Add criteria on ref/label | 
| 2562 | 2562 |          if ($filterkey != '') {
 | 
| 2563 | 2563 |              $sql .= ' AND (';
 | 
| @@ -2570,13 +2570,13 @@ discard block | ||
| 2570 | 2570 |              foreach ($scrit as $crit) {
 | 
| 2571 | 2571 | if ($i > 0) | 
| 2572 | 2572 | $sql .= " AND "; | 
| 2573 | - $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) . "%')"; | |
| 2573 | + $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 | 2574 | $i++; | 
| 2575 | 2575 | } | 
| 2576 | 2576 | if (count($scrit) > 1) | 
| 2577 | 2577 | $sql .= ")"; | 
| 2578 | 2578 | if (!empty($conf->barcode->enabled)) | 
| 2579 | - $sql .= " OR p.barcode LIKE '" . $this->db->escape($prefix . $filterkey) . "%'"; | |
| 2579 | + $sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'"; | |
| 2580 | 2580 | $sql .= ')'; | 
| 2581 | 2581 | } | 
| 2582 | 2582 | $sql .= " ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC"; | 
| @@ -2584,15 +2584,15 @@ discard block | ||
| 2584 | 2584 | |
| 2585 | 2585 | // Build output string | 
| 2586 | 2586 | |
| 2587 | - dol_syslog(get_class($this) . "::select_produits_fournisseurs_list", LOG_DEBUG); | |
| 2587 | + dol_syslog(get_class($this)."::select_produits_fournisseurs_list", LOG_DEBUG); | |
| 2588 | 2588 | $result = $this->db->query($sql); | 
| 2589 | 2589 |          if ($result) {
 | 
| 2590 | - require_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_parser.class.php'; | |
| 2590 | + require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; | |
| 2591 | 2591 | |
| 2592 | 2592 | $num = $this->db->num_rows($result); | 
| 2593 | 2593 | |
| 2594 | 2594 | //$out.='<select class="flat" id="select'.$htmlname.'" name="'.$htmlname.'">'; // remove select to have id same with combo and ajax | 
| 2595 | - $out .= '<select class="flat maxwidthonsmartphone" id="' . $htmlname . '" name="' . $htmlname . '">'; | |
| 2595 | + $out .= '<select class="flat maxwidthonsmartphone" id="'.$htmlname.'" name="'.$htmlname.'">'; | |
| 2596 | 2596 | if (!$selected) | 
| 2597 | 2597 | $out .= '<option value="0" selected> </option>'; | 
| 2598 | 2598 | else | 
| @@ -2602,9 +2602,9 @@ discard block | ||
| 2602 | 2602 |              while ($i < $num) {
 | 
| 2603 | 2603 | $objp = $this->db->fetch_object($result); | 
| 2604 | 2604 | |
| 2605 | - $outkey = $objp->idprodfournprice; // id in table of price | |
| 2605 | + $outkey = $objp->idprodfournprice; // id in table of price | |
| 2606 | 2606 | if (!$outkey && $alsoproductwithnosupplierprice) | 
| 2607 | - $outkey = 'idprod_' . $objp->rowid; // id of product | |
| 2607 | + $outkey = 'idprod_'.$objp->rowid; // id of product | |
| 2608 | 2608 | |
| 2609 | 2609 | $outref = $objp->ref; | 
| 2610 | 2610 | $outval = ''; | 
| @@ -2614,36 +2614,36 @@ discard block | ||
| 2614 | 2614 | $outdurationvalue = $outtype == Product::TYPE_SERVICE ? substr($objp->duration, 0, dol_strlen($objp->duration) - 1) : ''; | 
| 2615 | 2615 | $outdurationunit = $outtype == Product::TYPE_SERVICE ? substr($objp->duration, -1) : ''; | 
| 2616 | 2616 | |
| 2617 | - $opt = '<option value="' . $outkey . '"'; | |
| 2617 | + $opt = '<option value="'.$outkey.'"'; | |
| 2618 | 2618 | if ($selected && $selected == $objp->idprodfournprice) | 
| 2619 | 2619 | $opt .= ' selected'; | 
| 2620 | 2620 | if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) | 
| 2621 | 2621 | $opt .= ' disabled'; | 
| 2622 | 2622 |                  if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0) {
 | 
| 2623 | - $opt .= ' pbq="' . $objp->idprodfournprice . '" data-pbq="' . $objp->idprodfournprice . '" data-pbqqty="' . $objp->quantity . '" data-pbqpercent="' . $objp->remise_percent . '"'; | |
| 2623 | + $opt .= ' pbq="'.$objp->idprodfournprice.'" data-pbq="'.$objp->idprodfournprice.'" data-pbqqty="'.$objp->quantity.'" data-pbqpercent="'.$objp->remise_percent.'"'; | |
| 2624 | 2624 | } | 
| 2625 | 2625 | $opt .= '>'; | 
| 2626 | 2626 | |
| 2627 | 2627 | $objRef = $objp->ref; | 
| 2628 | 2628 | if ($filterkey && $filterkey != '') | 
| 2629 | -                    $objRef = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $objRef, 1);
 | |
| 2629 | +                    $objRef = preg_replace('/('.preg_quote($filterkey).')/i', '<strong>$1</strong>', $objRef, 1);
 | |
| 2630 | 2630 | $objRefFourn = $objp->ref_fourn; | 
| 2631 | 2631 | if ($filterkey && $filterkey != '') | 
| 2632 | -                    $objRefFourn = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $objRefFourn, 1);
 | |
| 2632 | +                    $objRefFourn = preg_replace('/('.preg_quote($filterkey).')/i', '<strong>$1</strong>', $objRefFourn, 1);
 | |
| 2633 | 2633 | $label = $objp->label; | 
| 2634 | 2634 | if ($filterkey && $filterkey != '') | 
| 2635 | -                    $label = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $label, 1);
 | |
| 2635 | +                    $label = preg_replace('/('.preg_quote($filterkey).')/i', '<strong>$1</strong>', $label, 1);
 | |
| 2636 | 2636 | |
| 2637 | 2637 | $opt .= $objp->ref; | 
| 2638 | 2638 | if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) | 
| 2639 | -                    $opt .= ' (' . $objp->ref_fourn . ')';
 | |
| 2639 | +                    $opt .= ' ('.$objp->ref_fourn.')';
 | |
| 2640 | 2640 | $opt .= ' - '; | 
| 2641 | 2641 | $outval .= $objRef; | 
| 2642 | 2642 | if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) | 
| 2643 | -                    $outval .= ' (' . $objRefFourn . ')';
 | |
| 2643 | +                    $outval .= ' ('.$objRefFourn.')';
 | |
| 2644 | 2644 | $outval .= ' - '; | 
| 2645 | - $opt .= dol_trunc($label, 72) . ' - '; | |
| 2646 | - $outval .= dol_trunc($label, 72) . ' - '; | |
| 2645 | + $opt .= dol_trunc($label, 72).' - '; | |
| 2646 | + $outval .= dol_trunc($label, 72).' - '; | |
| 2647 | 2647 | |
| 2648 | 2648 |                  if (!empty($objp->idprodfournprice)) {
 | 
| 2649 | 2649 | $outqty = $objp->quantity; | 
| @@ -2665,39 +2665,39 @@ discard block | ||
| 2665 | 2665 | } | 
| 2666 | 2666 | } | 
| 2667 | 2667 |                      if ($objp->quantity == 1) {
 | 
| 2668 | - $opt .= price($objp->fprice, 1, $langs, 0, 0, -1, $conf->currency) . "/"; | |
| 2669 | - $outval .= price($objp->fprice, 0, $langs, 0, 0, -1, $conf->currency) . "/"; | |
| 2668 | + $opt .= price($objp->fprice, 1, $langs, 0, 0, -1, $conf->currency)."/"; | |
| 2669 | + $outval .= price($objp->fprice, 0, $langs, 0, 0, -1, $conf->currency)."/"; | |
| 2670 | 2670 |                          $opt .= $langs->trans("Unit"); // Do not use strtolower because it breaks utf8 encoding
 | 
| 2671 | 2671 |                          $outval .= $langs->transnoentities("Unit");
 | 
| 2672 | 2672 |                      } else {
 | 
| 2673 | - $opt .= price($objp->fprice, 1, $langs, 0, 0, -1, $conf->currency) . "/" . $objp->quantity; | |
| 2674 | - $outval .= price($objp->fprice, 0, $langs, 0, 0, -1, $conf->currency) . "/" . $objp->quantity; | |
| 2675 | -                        $opt .= ' ' . $langs->trans("Units"); // Do not use strtolower because it breaks utf8 encoding
 | |
| 2676 | -                        $outval .= ' ' . $langs->transnoentities("Units");
 | |
| 2673 | + $opt .= price($objp->fprice, 1, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity; | |
| 2674 | + $outval .= price($objp->fprice, 0, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity; | |
| 2675 | +                        $opt .= ' '.$langs->trans("Units"); // Do not use strtolower because it breaks utf8 encoding
 | |
| 2676 | +                        $outval .= ' '.$langs->transnoentities("Units");
 | |
| 2677 | 2677 | } | 
| 2678 | 2678 | |
| 2679 | 2679 |                      if ($objp->quantity >= 1) {
 | 
| 2680 | -                        $opt .= " (" . price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency) . "/" . $langs->trans("Unit") . ")"; // Do not use strtolower because it breaks utf8 encoding
 | |
| 2681 | -                        $outval .= " (" . price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency) . "/" . $langs->transnoentities("Unit") . ")"; // Do not use strtolower because it breaks utf8 encoding
 | |
| 2680 | +                        $opt .= " (".price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit").")"; // Do not use strtolower because it breaks utf8 encoding
 | |
| 2681 | +                        $outval .= " (".price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->transnoentities("Unit").")"; // Do not use strtolower because it breaks utf8 encoding
 | |
| 2682 | 2682 | } | 
| 2683 | 2683 |                      if ($objp->remise_percent >= 1) {
 | 
| 2684 | -                        $opt .= " - " . $langs->trans("Discount") . " : " . vatrate($objp->remise_percent) . ' %';
 | |
| 2685 | -                        $outval .= " - " . $langs->transnoentities("Discount") . " : " . vatrate($objp->remise_percent) . ' %';
 | |
| 2684 | +                        $opt .= " - ".$langs->trans("Discount")." : ".vatrate($objp->remise_percent).' %';
 | |
| 2685 | +                        $outval .= " - ".$langs->transnoentities("Discount")." : ".vatrate($objp->remise_percent).' %';
 | |
| 2686 | 2686 | } | 
| 2687 | 2687 |                      if ($objp->duration) {
 | 
| 2688 | - $opt .= " - " . $objp->duration; | |
| 2689 | - $outval .= " - " . $objp->duration; | |
| 2688 | + $opt .= " - ".$objp->duration; | |
| 2689 | + $outval .= " - ".$objp->duration; | |
| 2690 | 2690 | } | 
| 2691 | 2691 |                      if (!$socid) {
 | 
| 2692 | - $opt .= " - " . dol_trunc($objp->name, 8); | |
| 2693 | - $outval .= " - " . dol_trunc($objp->name, 8); | |
| 2692 | + $opt .= " - ".dol_trunc($objp->name, 8); | |
| 2693 | + $outval .= " - ".dol_trunc($objp->name, 8); | |
| 2694 | 2694 | } | 
| 2695 | 2695 |                      if ($objp->supplier_reputation) {
 | 
| 2696 | 2696 | //TODO dictionary | 
| 2697 | 2697 |                          $reputations = array('' => $langs->trans('Standard'), 'FAVORITE' => $langs->trans('Favorite'), 'NOTTHGOOD' => $langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER' => $langs->trans('DoNotOrderThisProductToThisSupplier'));
 | 
| 2698 | 2698 | |
| 2699 | - $opt .= " - " . $reputations[$objp->supplier_reputation]; | |
| 2700 | - $outval .= " - " . $reputations[$objp->supplier_reputation]; | |
| 2699 | + $opt .= " - ".$reputations[$objp->supplier_reputation]; | |
| 2700 | + $outval .= " - ".$reputations[$objp->supplier_reputation]; | |
| 2701 | 2701 | } | 
| 2702 | 2702 |                  } else {
 | 
| 2703 | 2703 |                      if (empty($alsoproductwithnosupplierprice)) {     // No supplier price defined for couple product/supplier
 | 
| @@ -2731,7 +2731,7 @@ discard block | ||
| 2731 | 2731 | |
| 2732 | 2732 | $this->db->free($result); | 
| 2733 | 2733 | |
| 2734 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; | |
| 2734 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; | |
| 2735 | 2735 | $out .= ajax_combobox($htmlname); | 
| 2736 | 2736 | |
| 2737 | 2737 | if (empty($outputmode)) | 
| @@ -2762,39 +2762,39 @@ discard block | ||
| 2762 | 2762 | $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration, pfp.fk_soc,"; | 
| 2763 | 2763 | $sql .= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.unitprice,"; | 
| 2764 | 2764 | $sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, s.nom as name"; | 
| 2765 | - $sql .= " FROM " . MAIN_DB_PREFIX . "product as p"; | |
| 2766 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; | |
| 2767 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON pfp.fk_soc = s.rowid"; | |
| 2768 | -        $sql .= " WHERE pfp.entity IN (" . getEntity('productsupplierprice') . ")";
 | |
| 2765 | + $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; | |
| 2766 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; | |
| 2767 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid"; | |
| 2768 | +        $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")";
 | |
| 2769 | 2769 | $sql .= " AND p.tobuy = 1"; | 
| 2770 | 2770 | $sql .= " AND s.fournisseur = 1"; | 
| 2771 | - $sql .= " AND p.rowid = " . $productid; | |
| 2771 | + $sql .= " AND p.rowid = ".$productid; | |
| 2772 | 2772 | $sql .= " ORDER BY s.nom, pfp.ref_fourn DESC"; | 
| 2773 | 2773 | |
| 2774 | - dol_syslog(get_class($this) . "::select_product_fourn_price", LOG_DEBUG); | |
| 2774 | + dol_syslog(get_class($this)."::select_product_fourn_price", LOG_DEBUG); | |
| 2775 | 2775 | $result = $this->db->query($sql); | 
| 2776 | 2776 | |
| 2777 | 2777 |          if ($result) {
 | 
| 2778 | 2778 | $num = $this->db->num_rows($result); | 
| 2779 | 2779 | |
| 2780 | - $form = '<select class="flat" id="select_' . $htmlname . '" name="' . $htmlname . '">'; | |
| 2780 | + $form = '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">'; | |
| 2781 | 2781 | |
| 2782 | 2782 |              if (!$num) {
 | 
| 2783 | -                $form .= '<option value="0">-- ' . $langs->trans("NoSupplierPriceDefinedForThisProduct") . ' --</option>';
 | |
| 2783 | +                $form .= '<option value="0">-- '.$langs->trans("NoSupplierPriceDefinedForThisProduct").' --</option>';
 | |
| 2784 | 2784 |              } else {
 | 
| 2785 | - require_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_parser.class.php'; | |
| 2785 | + require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; | |
| 2786 | 2786 | $form .= '<option value="0"> </option>'; | 
| 2787 | 2787 | |
| 2788 | 2788 | $i = 0; | 
| 2789 | 2789 |                  while ($i < $num) {
 | 
| 2790 | 2790 | $objp = $this->db->fetch_object($result); | 
| 2791 | 2791 | |
| 2792 | - $opt = '<option value="' . $objp->idprodfournprice . '"'; | |
| 2792 | + $opt = '<option value="'.$objp->idprodfournprice.'"'; | |
| 2793 | 2793 | //if there is only one supplier, preselect it | 
| 2794 | 2794 |                      if ($num == 1 || ($selected_supplier > 0 && $objp->fk_soc == $selected_supplier)) {
 | 
| 2795 | 2795 | $opt .= ' selected'; | 
| 2796 | 2796 | } | 
| 2797 | - $opt .= '>' . $objp->name . ' - ' . $objp->ref_fourn . ' - '; | |
| 2797 | + $opt .= '>'.$objp->name.' - '.$objp->ref_fourn.' - '; | |
| 2798 | 2798 | |
| 2799 | 2799 |                      if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_supplier_price_expression)) {
 | 
| 2800 | 2800 | $prod_supplier = new ProductFournisseur($this->db); | 
| @@ -2813,10 +2813,10 @@ discard block | ||
| 2813 | 2813 | } | 
| 2814 | 2814 | } | 
| 2815 | 2815 |                      if ($objp->quantity == 1) {
 | 
| 2816 | - $opt .= price($objp->fprice, 1, $langs, 0, 0, -1, $conf->currency) . "/"; | |
| 2816 | + $opt .= price($objp->fprice, 1, $langs, 0, 0, -1, $conf->currency)."/"; | |
| 2817 | 2817 | } | 
| 2818 | 2818 | |
| 2819 | - $opt .= $objp->quantity . ' '; | |
| 2819 | + $opt .= $objp->quantity.' '; | |
| 2820 | 2820 | |
| 2821 | 2821 |                      if ($objp->quantity == 1) {
 | 
| 2822 | 2822 |                          $opt .= $langs->trans("Unit");
 | 
| @@ -2825,10 +2825,10 @@ discard block | ||
| 2825 | 2825 | } | 
| 2826 | 2826 |                      if ($objp->quantity > 1) {
 | 
| 2827 | 2827 | $opt .= " - "; | 
| 2828 | -                        $opt .= price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency) . "/" . $langs->trans("Unit");
 | |
| 2828 | +                        $opt .= price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit");
 | |
| 2829 | 2829 | } | 
| 2830 | 2830 | if ($objp->duration) | 
| 2831 | - $opt .= " - " . $objp->duration; | |
| 2831 | + $opt .= " - ".$objp->duration; | |
| 2832 | 2832 | $opt .= "</option>\n"; | 
| 2833 | 2833 | |
| 2834 | 2834 | $form .= $opt; | 
| @@ -2860,14 +2860,14 @@ discard block | ||
| 2860 | 2860 | // phpcs:enable | 
| 2861 | 2861 | // looking for users | 
| 2862 | 2862 | $sql = "SELECT a.rowid, a.label"; | 
| 2863 | - $sql .= " FROM " . MAIN_DB_PREFIX . "societe_address as a"; | |
| 2864 | - $sql .= " WHERE a.fk_soc = " . $socid; | |
| 2863 | + $sql .= " FROM ".MAIN_DB_PREFIX."societe_address as a"; | |
| 2864 | + $sql .= " WHERE a.fk_soc = ".$socid; | |
| 2865 | 2865 | $sql .= " ORDER BY a.label ASC"; | 
| 2866 | 2866 | |
| 2867 | - dol_syslog(get_class($this) . "::select_address", LOG_DEBUG); | |
| 2867 | + dol_syslog(get_class($this)."::select_address", LOG_DEBUG); | |
| 2868 | 2868 | $resql = $this->db->query($sql); | 
| 2869 | 2869 |          if ($resql) {
 | 
| 2870 | - print '<select class="flat" id="select_' . $htmlname . '" name="' . $htmlname . '">'; | |
| 2870 | + print '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">'; | |
| 2871 | 2871 | if ($showempty) | 
| 2872 | 2872 | print '<option value="0"> </option>'; | 
| 2873 | 2873 | $num = $this->db->num_rows($resql); | 
| @@ -2877,9 +2877,9 @@ discard block | ||
| 2877 | 2877 | $obj = $this->db->fetch_object($resql); | 
| 2878 | 2878 | |
| 2879 | 2879 |                      if ($selected && $selected == $obj->rowid) {
 | 
| 2880 | - print '<option value="' . $obj->rowid . '" selected>' . $obj->label . '</option>'; | |
| 2880 | + print '<option value="'.$obj->rowid.'" selected>'.$obj->label.'</option>'; | |
| 2881 | 2881 |                      } else {
 | 
| 2882 | - print '<option value="' . $obj->rowid . '">' . $obj->label . '</option>'; | |
| 2882 | + print '<option value="'.$obj->rowid.'">'.$obj->label.'</option>'; | |
| 2883 | 2883 | } | 
| 2884 | 2884 | $i++; | 
| 2885 | 2885 | } | 
| @@ -2904,13 +2904,13 @@ discard block | ||
| 2904 | 2904 | |
| 2905 | 2905 | $num = count($this->cache_conditions_paiements); | 
| 2906 | 2906 | if ($num > 0) | 
| 2907 | - return 0; // Cache already loaded | |
| 2907 | + return 0; // Cache already loaded | |
| 2908 | 2908 | |
| 2909 | 2909 | dol_syslog(__METHOD__, LOG_DEBUG); | 
| 2910 | 2910 | |
| 2911 | 2911 | $sql = "SELECT rowid, code, libelle as label"; | 
| 2912 | - $sql .= " FROM " . MAIN_DB_PREFIX . 'c_payment_term'; | |
| 2913 | -        $sql .= " WHERE entity IN (" . getEntity('c_payment_term') . ")";
 | |
| 2912 | + $sql .= " FROM ".MAIN_DB_PREFIX.'c_payment_term'; | |
| 2913 | +        $sql .= " WHERE entity IN (".getEntity('c_payment_term').")";
 | |
| 2914 | 2914 | $sql .= " AND active > 0"; | 
| 2915 | 2915 | $sql .= " ORDER BY sortorder"; | 
| 2916 | 2916 | |
| @@ -2922,7 +2922,7 @@ discard block | ||
| 2922 | 2922 | $obj = $this->db->fetch_object($resql); | 
| 2923 | 2923 | |
| 2924 | 2924 | // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut | 
| 2925 | -                $label = ($langs->trans("PaymentConditionShort" . $obj->code) != ("PaymentConditionShort" . $obj->code) ? $langs->trans("PaymentConditionShort" . $obj->code) : ($obj->label != '-' ? $obj->label : ''));
 | |
| 2925 | +                $label = ($langs->trans("PaymentConditionShort".$obj->code) != ("PaymentConditionShort".$obj->code) ? $langs->trans("PaymentConditionShort".$obj->code) : ($obj->label != '-' ? $obj->label : ''));
 | |
| 2926 | 2926 | $this->cache_conditions_paiements[$obj->rowid]['code'] = $obj->code; | 
| 2927 | 2927 | $this->cache_conditions_paiements[$obj->rowid]['label'] = $label; | 
| 2928 | 2928 | $i++; | 
| @@ -2950,14 +2950,14 @@ discard block | ||
| 2950 | 2950 | |
| 2951 | 2951 | $num = count($this->cache_availability); | 
| 2952 | 2952 | if ($num > 0) | 
| 2953 | - return 0; // Cache already loaded | |
| 2953 | + return 0; // Cache already loaded | |
| 2954 | 2954 | |
| 2955 | 2955 | dol_syslog(__METHOD__, LOG_DEBUG); | 
| 2956 | 2956 | |
| 2957 | 2957 |          $langs->load('propal');
 | 
| 2958 | 2958 | |
| 2959 | 2959 | $sql = "SELECT rowid, code, label"; | 
| 2960 | - $sql .= " FROM " . MAIN_DB_PREFIX . 'c_availability'; | |
| 2960 | + $sql .= " FROM ".MAIN_DB_PREFIX.'c_availability'; | |
| 2961 | 2961 | $sql .= " WHERE active > 0"; | 
| 2962 | 2962 | |
| 2963 | 2963 | $resql = $this->db->query($sql); | 
| @@ -2968,7 +2968,7 @@ discard block | ||
| 2968 | 2968 | $obj = $this->db->fetch_object($resql); | 
| 2969 | 2969 | |
| 2970 | 2970 | // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut | 
| 2971 | -                $label = ($langs->trans("AvailabilityType" . $obj->code) != ("AvailabilityType" . $obj->code) ? $langs->trans("AvailabilityType" . $obj->code) : ($obj->label != '-' ? $obj->label : ''));
 | |
| 2971 | +                $label = ($langs->trans("AvailabilityType".$obj->code) != ("AvailabilityType".$obj->code) ? $langs->trans("AvailabilityType".$obj->code) : ($obj->label != '-' ? $obj->label : ''));
 | |
| 2972 | 2972 | $this->cache_availability[$obj->rowid]['code'] = $obj->code; | 
| 2973 | 2973 | $this->cache_availability[$obj->rowid]['label'] = $label; | 
| 2974 | 2974 | $i++; | 
| @@ -2998,16 +2998,16 @@ discard block | ||
| 2998 | 2998 | |
| 2999 | 2999 | $this->load_cache_availability(); | 
| 3000 | 3000 | |
| 3001 | - dol_syslog(__METHOD__ . " selected=" . $selected . ", htmlname=" . $htmlname, LOG_DEBUG); | |
| 3001 | + dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG); | |
| 3002 | 3002 | |
| 3003 | - print '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">'; | |
| 3003 | + print '<select id="'.$htmlname.'" class="flat" name="'.$htmlname.'">'; | |
| 3004 | 3004 | if ($addempty) | 
| 3005 | 3005 | print '<option value="0"> </option>'; | 
| 3006 | 3006 |          foreach ($this->cache_availability as $id => $arrayavailability) {
 | 
| 3007 | 3007 |              if ($selected == $id) {
 | 
| 3008 | - print '<option value="' . $id . '" selected>'; | |
| 3008 | + print '<option value="'.$id.'" selected>'; | |
| 3009 | 3009 |              } else {
 | 
| 3010 | - print '<option value="' . $id . '">'; | |
| 3010 | + print '<option value="'.$id.'">'; | |
| 3011 | 3011 | } | 
| 3012 | 3012 | print $arrayavailability['label']; | 
| 3013 | 3013 | print '</option>'; | 
| @@ -3028,10 +3028,10 @@ discard block | ||
| 3028 | 3028 | |
| 3029 | 3029 | $num = count($this->cache_demand_reason); | 
| 3030 | 3030 | if ($num > 0) | 
| 3031 | - return 0; // Cache already loaded | |
| 3031 | + return 0; // Cache already loaded | |
| 3032 | 3032 | |
| 3033 | 3033 | $sql = "SELECT rowid, code, label"; | 
| 3034 | - $sql .= " FROM " . MAIN_DB_PREFIX . 'c_input_reason'; | |
| 3034 | + $sql .= " FROM ".MAIN_DB_PREFIX.'c_input_reason'; | |
| 3035 | 3035 | $sql .= " WHERE active > 0"; | 
| 3036 | 3036 | |
| 3037 | 3037 | $resql = $this->db->query($sql); | 
| @@ -3044,10 +3044,10 @@ discard block | ||
| 3044 | 3044 | |
| 3045 | 3045 | // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut | 
| 3046 | 3046 | $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
 | |
| 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 | 3049 | if ($langs->trans($obj->code) != $obj->code) | 
| 3050 | - $label = $langs->trans($obj->code); // So translation key SRC_XXX will work | |
| 3050 | + $label = $langs->trans($obj->code); // So translation key SRC_XXX will work | |
| 3051 | 3051 | |
| 3052 | 3052 | $tmparray[$obj->rowid]['id'] = $obj->rowid; | 
| 3053 | 3053 | $tmparray[$obj->rowid]['code'] = $obj->code; | 
| @@ -3082,17 +3082,17 @@ discard block | ||
| 3082 | 3082 | |
| 3083 | 3083 | $this->loadCacheInputReason(); | 
| 3084 | 3084 | |
| 3085 | - print '<select class="flat" id="select_' . $htmlname . '" name="' . $htmlname . '">'; | |
| 3085 | + print '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">'; | |
| 3086 | 3086 | if ($addempty) | 
| 3087 | - print '<option value="0"' . (empty($selected) ? ' selected' : '') . '> </option>'; | |
| 3087 | + print '<option value="0"'.(empty($selected) ? ' selected' : '').'> </option>'; | |
| 3088 | 3088 |          foreach ($this->cache_demand_reason as $id => $arraydemandreason) {
 | 
| 3089 | 3089 | if ($arraydemandreason['code'] == $exclude) | 
| 3090 | 3090 | continue; | 
| 3091 | 3091 | |
| 3092 | 3092 |              if ($selected && ($selected == $arraydemandreason['id'] || $selected == $arraydemandreason['code'])) {
 | 
| 3093 | - print '<option value="' . $arraydemandreason['id'] . '" selected>'; | |
| 3093 | + print '<option value="'.$arraydemandreason['id'].'" selected>'; | |
| 3094 | 3094 |              } else {
 | 
| 3095 | - print '<option value="' . $arraydemandreason['id'] . '">'; | |
| 3095 | + print '<option value="'.$arraydemandreason['id'].'">'; | |
| 3096 | 3096 | } | 
| 3097 | 3097 | $label = $arraydemandreason['label']; // Translation of label was already done into the ->loadCacheInputReason | 
| 3098 | 3098 | print $langs->trans($label); | 
| @@ -3116,15 +3116,15 @@ discard block | ||
| 3116 | 3116 | |
| 3117 | 3117 | $num = count($this->cache_types_paiements); | 
| 3118 | 3118 | if ($num > 0) | 
| 3119 | - return $num; // Cache already loaded | |
| 3119 | + return $num; // Cache already loaded | |
| 3120 | 3120 | |
| 3121 | 3121 | dol_syslog(__METHOD__, LOG_DEBUG); | 
| 3122 | 3122 | |
| 3123 | 3123 | $this->cache_types_paiements = array(); | 
| 3124 | 3124 | |
| 3125 | 3125 | $sql = "SELECT id, code, libelle as label, type, active"; | 
| 3126 | - $sql .= " FROM " . MAIN_DB_PREFIX . "c_paiement"; | |
| 3127 | -        $sql .= " WHERE entity IN (" . getEntity('c_paiement') . ")";
 | |
| 3126 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_paiement"; | |
| 3127 | +        $sql .= " WHERE entity IN (".getEntity('c_paiement').")";
 | |
| 3128 | 3128 | //if ($active >= 0) $sql.= " AND active = ".$active; | 
| 3129 | 3129 | |
| 3130 | 3130 | $resql = $this->db->query($sql); | 
| @@ -3135,7 +3135,7 @@ discard block | ||
| 3135 | 3135 | $obj = $this->db->fetch_object($resql); | 
| 3136 | 3136 | |
| 3137 | 3137 | // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut | 
| 3138 | -                $label = ($langs->transnoentitiesnoconv("PaymentTypeShort" . $obj->code) != ("PaymentTypeShort" . $obj->code) ? $langs->transnoentitiesnoconv("PaymentTypeShort" . $obj->code) : ($obj->label != '-' ? $obj->label : ''));
 | |
| 3138 | +                $label = ($langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code) != ("PaymentTypeShort".$obj->code) ? $langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code) : ($obj->label != '-' ? $obj->label : ''));
 | |
| 3139 | 3139 | $this->cache_types_paiements[$obj->id]['id'] = $obj->id; | 
| 3140 | 3140 | $this->cache_types_paiements[$obj->id]['code'] = $obj->code; | 
| 3141 | 3141 | $this->cache_types_paiements[$obj->id]['label'] = $label; | 
| @@ -3172,7 +3172,7 @@ discard block | ||
| 3172 | 3172 | // phpcs:enable | 
| 3173 | 3173 | global $langs, $user, $conf; | 
| 3174 | 3174 | |
| 3175 | - dol_syslog(__METHOD__ . " selected=" . $selected . ", htmlname=" . $htmlname, LOG_DEBUG); | |
| 3175 | + dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG); | |
| 3176 | 3176 | |
| 3177 | 3177 | $this->load_cache_conditions_paiements(); | 
| 3178 | 3178 | |
| @@ -3180,14 +3180,14 @@ discard block | ||
| 3180 | 3180 | if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID)) | 
| 3181 | 3181 | $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID; | 
| 3182 | 3182 | |
| 3183 | - print '<select id="' . $htmlname . '" class="flat selectpaymentterms' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '">'; | |
| 3183 | + print '<select id="'.$htmlname.'" class="flat selectpaymentterms'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">'; | |
| 3184 | 3184 | if ($addempty) | 
| 3185 | 3185 | print '<option value="0"> </option>'; | 
| 3186 | 3186 |          foreach ($this->cache_conditions_paiements as $id => $arrayconditions) {
 | 
| 3187 | 3187 |              if ($selected == $id) {
 | 
| 3188 | - print '<option value="' . $id . '" selected>'; | |
| 3188 | + print '<option value="'.$id.'" selected>'; | |
| 3189 | 3189 |              } else {
 | 
| 3190 | - print '<option value="' . $id . '">'; | |
| 3190 | + print '<option value="'.$id.'">'; | |
| 3191 | 3191 | } | 
| 3192 | 3192 | print $arrayconditions['label']; | 
| 3193 | 3193 | print '</option>'; | 
| @@ -3217,7 +3217,7 @@ discard block | ||
| 3217 | 3217 | // phpcs:enable | 
| 3218 | 3218 | global $langs, $user; | 
| 3219 | 3219 | |
| 3220 | - dol_syslog(__METHOD__ . " " . $selected . ", " . $htmlname . ", " . $filtertype . ", " . $format, LOG_DEBUG); | |
| 3220 | + dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); | |
| 3221 | 3221 | |
| 3222 | 3222 | $filterarray = array(); | 
| 3223 | 3223 | if ($filtertype == 'CRDT') | 
| @@ -3229,7 +3229,7 @@ discard block | ||
| 3229 | 3229 | |
| 3230 | 3230 | $this->load_cache_types_paiements(); | 
| 3231 | 3231 | |
| 3232 | - print '<select id="select' . $htmlname . '" class="flat selectpaymenttypes' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '">'; | |
| 3232 | + print '<select id="select'.$htmlname.'" class="flat selectpaymenttypes'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">'; | |
| 3233 | 3233 | if ($empty) | 
| 3234 | 3234 | print '<option value=""> </option>'; | 
| 3235 | 3235 |          foreach ($this->cache_types_paiements as $id => $arraytypes) {
 | 
| @@ -3246,13 +3246,13 @@ discard block | ||
| 3246 | 3246 | continue; | 
| 3247 | 3247 | |
| 3248 | 3248 | if ($format == 0) | 
| 3249 | - print '<option value="' . $id . '"'; | |
| 3249 | + print '<option value="'.$id.'"'; | |
| 3250 | 3250 | elseif ($format == 1) | 
| 3251 | - print '<option value="' . $arraytypes['code'] . '"'; | |
| 3251 | + print '<option value="'.$arraytypes['code'].'"'; | |
| 3252 | 3252 | elseif ($format == 2) | 
| 3253 | - print '<option value="' . $arraytypes['code'] . '"'; | |
| 3253 | + print '<option value="'.$arraytypes['code'].'"'; | |
| 3254 | 3254 | elseif ($format == 3) | 
| 3255 | - print '<option value="' . $id . '"'; | |
| 3255 | + print '<option value="'.$id.'"'; | |
| 3256 | 3256 | // Si selected est text, on compare avec code, sinon avec id | 
| 3257 | 3257 |              if (preg_match('/[a-z]/i', $selected) && $selected == $arraytypes['code'])
 | 
| 3258 | 3258 | print ' selected'; | 
| @@ -3288,16 +3288,16 @@ discard block | ||
| 3288 | 3288 | |
| 3289 | 3289 | $return = ''; | 
| 3290 | 3290 | |
| 3291 | - $return .= '<select class="flat" id="select_' . $htmlname . '" name="' . $htmlname . '">'; | |
| 3291 | + $return .= '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">'; | |
| 3292 | 3292 | $options = array( | 
| 3293 | 3293 |              'HT' => $langs->trans("HT"),
 | 
| 3294 | 3294 |              'TTC' => $langs->trans("TTC")
 | 
| 3295 | 3295 | ); | 
| 3296 | 3296 |          foreach ($options as $id => $value) {
 | 
| 3297 | 3297 |              if ($selected == $id) {
 | 
| 3298 | - $return .= '<option value="' . $id . '" selected>' . $value; | |
| 3298 | + $return .= '<option value="'.$id.'" selected>'.$value; | |
| 3299 | 3299 |              } else {
 | 
| 3300 | - $return .= '<option value="' . $id . '">' . $value; | |
| 3300 | + $return .= '<option value="'.$id.'">'.$value; | |
| 3301 | 3301 | } | 
| 3302 | 3302 | $return .= '</option>'; | 
| 3303 | 3303 | } | 
| @@ -3324,30 +3324,30 @@ discard block | ||
| 3324 | 3324 |          $langs->load("deliveries");
 | 
| 3325 | 3325 | |
| 3326 | 3326 | $sql = "SELECT rowid, code, libelle as label"; | 
| 3327 | - $sql .= " FROM " . MAIN_DB_PREFIX . "c_shipment_mode"; | |
| 3327 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode"; | |
| 3328 | 3328 | $sql .= " WHERE active > 0"; | 
| 3329 | 3329 | if ($filtre) | 
| 3330 | - $sql .= " AND " . $filtre; | |
| 3330 | + $sql .= " AND ".$filtre; | |
| 3331 | 3331 | $sql .= " ORDER BY libelle ASC"; | 
| 3332 | 3332 | |
| 3333 | - dol_syslog(get_class($this) . "::selectShippingMode", LOG_DEBUG); | |
| 3333 | + dol_syslog(get_class($this)."::selectShippingMode", LOG_DEBUG); | |
| 3334 | 3334 | $result = $this->db->query($sql); | 
| 3335 | 3335 |          if ($result) {
 | 
| 3336 | 3336 | $num = $this->db->num_rows($result); | 
| 3337 | 3337 | $i = 0; | 
| 3338 | 3338 |              if ($num) {
 | 
| 3339 | - print '<select id="select' . $htmlname . '" class="flat selectshippingmethod" name="' . $htmlname . '"' . ($moreattrib ? ' ' . $moreattrib : '') . '>'; | |
| 3339 | + print '<select id="select'.$htmlname.'" class="flat selectshippingmethod" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>'; | |
| 3340 | 3340 |                  if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
 | 
| 3341 | 3341 | print '<option value="-1"> </option>'; | 
| 3342 | 3342 | } | 
| 3343 | 3343 |                  while ($i < $num) {
 | 
| 3344 | 3344 | $obj = $this->db->fetch_object($result); | 
| 3345 | 3345 |                      if ($selected == $obj->rowid) {
 | 
| 3346 | - print '<option value="' . $obj->rowid . '" selected>'; | |
| 3346 | + print '<option value="'.$obj->rowid.'" selected>'; | |
| 3347 | 3347 |                      } else {
 | 
| 3348 | - print '<option value="' . $obj->rowid . '">'; | |
| 3348 | + print '<option value="'.$obj->rowid.'">'; | |
| 3349 | 3349 | } | 
| 3350 | -                    print ($langs->trans("SendingMethod" . strtoupper($obj->code)) != "SendingMethod" . strtoupper($obj->code)) ? $langs->trans("SendingMethod" . strtoupper($obj->code)) : $obj->label;
 | |
| 3350 | +                    print ($langs->trans("SendingMethod".strtoupper($obj->code)) != "SendingMethod".strtoupper($obj->code)) ? $langs->trans("SendingMethod".strtoupper($obj->code)) : $obj->label;
 | |
| 3351 | 3351 | print '</option>'; | 
| 3352 | 3352 | $i++; | 
| 3353 | 3353 | } | 
| @@ -3378,16 +3378,16 @@ discard block | ||
| 3378 | 3378 |          $langs->load("deliveries");
 | 
| 3379 | 3379 | |
| 3380 | 3380 |          if ($htmlname != "none") {
 | 
| 3381 | - print '<form method="POST" action="' . $page . '">'; | |
| 3381 | + print '<form method="POST" action="'.$page.'">'; | |
| 3382 | 3382 | print '<input type="hidden" name="action" value="setshippingmethod">'; | 
| 3383 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 3383 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 3384 | 3384 | $this->selectShippingMethod($selected, $htmlname, '', $addempty); | 
| 3385 | -            print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
 | |
| 3385 | +            print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
 | |
| 3386 | 3386 | print '</form>'; | 
| 3387 | 3387 |          } else {
 | 
| 3388 | 3388 |              if ($selected) {
 | 
| 3389 | 3389 | $code = $langs->getLabelFromKey($db, $selected, 'c_shipment_mode', 'rowid', 'code'); | 
| 3390 | -                print $langs->trans("SendingMethod" . strtoupper($code));
 | |
| 3390 | +                print $langs->trans("SendingMethod".strtoupper($code));
 | |
| 3391 | 3391 |              } else {
 | 
| 3392 | 3392 | print " "; | 
| 3393 | 3393 | } | 
| @@ -3409,7 +3409,7 @@ discard block | ||
| 3409 | 3409 |          $langs->load('bills');
 | 
| 3410 | 3410 | |
| 3411 | 3411 | $opt = '<option value ="" selected></option>'; | 
| 3412 | - $sql = 'SELECT rowid, ref, situation_cycle_ref, situation_counter, situation_final, fk_soc FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_counter>=1'; | |
| 3412 | + $sql = 'SELECT rowid, ref, situation_cycle_ref, situation_counter, situation_final, fk_soc FROM '.MAIN_DB_PREFIX.'facture WHERE situation_counter>=1'; | |
| 3413 | 3413 | $sql .= ' ORDER by situation_cycle_ref, situation_counter desc'; | 
| 3414 | 3414 | $resql = $this->db->query($sql); | 
| 3415 | 3415 |          if ($resql && $this->db->num_rows($resql) > 0) {
 | 
| @@ -3427,9 +3427,9 @@ discard block | ||
| 3427 | 3427 | //Not prov? | 
| 3428 | 3428 |                              if (substr($obj->ref, 1, 4) != 'PROV') {
 | 
| 3429 | 3429 |                                  if ($selected == $obj->rowid) {
 | 
| 3430 | - $opt .= '<option value="' . $obj->rowid . '" selected>' . $obj->ref . '</option>'; | |
| 3430 | + $opt .= '<option value="'.$obj->rowid.'" selected>'.$obj->ref.'</option>'; | |
| 3431 | 3431 |                                  } else {
 | 
| 3432 | - $opt .= '<option value="' . $obj->rowid . '">' . $obj->ref . '</option>'; | |
| 3432 | + $opt .= '<option value="'.$obj->rowid.'">'.$obj->ref.'</option>'; | |
| 3433 | 3433 | } | 
| 3434 | 3434 | } | 
| 3435 | 3435 | } | 
| @@ -3437,10 +3437,10 @@ discard block | ||
| 3437 | 3437 | } | 
| 3438 | 3438 | } | 
| 3439 | 3439 |          } else {
 | 
| 3440 | -            dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR);
 | |
| 3440 | +            dol_syslog("Error sql=".$sql.", error=".$this->error, LOG_ERR);
 | |
| 3441 | 3441 | } | 
| 3442 | 3442 |          if ($opt == '<option value ="" selected></option>') {
 | 
| 3443 | -            $opt = '<option value ="0" selected>' . $langs->trans('NoSituations') . '</option>';
 | |
| 3443 | +            $opt = '<option value ="0" selected>'.$langs->trans('NoSituations').'</option>';
 | |
| 3444 | 3444 | } | 
| 3445 | 3445 | return $opt; | 
| 3446 | 3446 | } | 
| @@ -3459,9 +3459,9 @@ discard block | ||
| 3459 | 3459 | |
| 3460 | 3460 |          $langs->load('products');
 | 
| 3461 | 3461 | |
| 3462 | - $return = '<select class="flat" id="' . $htmlname . '" name="' . $htmlname . '">'; | |
| 3462 | + $return = '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">'; | |
| 3463 | 3463 | |
| 3464 | - $sql = 'SELECT rowid, label, code from ' . MAIN_DB_PREFIX . 'c_units'; | |
| 3464 | + $sql = 'SELECT rowid, label, code from '.MAIN_DB_PREFIX.'c_units'; | |
| 3465 | 3465 | $sql .= ' WHERE active > 0'; | 
| 3466 | 3466 | |
| 3467 | 3467 | $resql = $this->db->query($sql); | 
| @@ -3471,14 +3471,14 @@ discard block | ||
| 3471 | 3471 | |
| 3472 | 3472 |              while ($res = $this->db->fetch_object($resql)) {
 | 
| 3473 | 3473 | $unitLabel = $res->label; | 
| 3474 | -                if (!empty($langs->tab_translate['unit' . $res->code])) { // check if Translation is available before
 | |
| 3475 | -                    $unitLabel = $langs->trans('unit' . $res->code) != $res->label ? $langs->trans('unit' . $res->code) : $res->label;
 | |
| 3474 | +                if (!empty($langs->tab_translate['unit'.$res->code])) { // check if Translation is available before
 | |
| 3475 | +                    $unitLabel = $langs->trans('unit'.$res->code) != $res->label ? $langs->trans('unit'.$res->code) : $res->label;
 | |
| 3476 | 3476 | } | 
| 3477 | 3477 | |
| 3478 | 3478 |                  if ($selected == $res->rowid) {
 | 
| 3479 | - $return .= '<option value="' . $res->rowid . '" selected>' . $unitLabel . '</option>'; | |
| 3479 | + $return .= '<option value="'.$res->rowid.'" selected>'.$unitLabel.'</option>'; | |
| 3480 | 3480 |                  } else {
 | 
| 3481 | - $return .= '<option value="' . $res->rowid . '">' . $unitLabel . '</option>'; | |
| 3481 | + $return .= '<option value="'.$res->rowid.'">'.$unitLabel.'</option>'; | |
| 3482 | 3482 | } | 
| 3483 | 3483 | } | 
| 3484 | 3484 | $return .= '</select>'; | 
| @@ -3508,21 +3508,21 @@ discard block | ||
| 3508 | 3508 | $num = 0; | 
| 3509 | 3509 | |
| 3510 | 3510 | $sql = "SELECT rowid, label, bank, clos as status, currency_code"; | 
| 3511 | - $sql .= " FROM " . MAIN_DB_PREFIX . "bank_account"; | |
| 3512 | -        $sql .= " WHERE entity IN (" . getEntity('bank_account') . ")";
 | |
| 3511 | + $sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; | |
| 3512 | +        $sql .= " WHERE entity IN (".getEntity('bank_account').")";
 | |
| 3513 | 3513 | if ($statut != 2) | 
| 3514 | - $sql .= " AND clos = '" . $statut . "'"; | |
| 3514 | + $sql .= " AND clos = '".$statut."'"; | |
| 3515 | 3515 | if ($filtre) | 
| 3516 | - $sql .= " AND " . $filtre; | |
| 3516 | + $sql .= " AND ".$filtre; | |
| 3517 | 3517 | $sql .= " ORDER BY label"; | 
| 3518 | 3518 | |
| 3519 | - dol_syslog(get_class($this) . "::select_comptes", LOG_DEBUG); | |
| 3519 | + dol_syslog(get_class($this)."::select_comptes", LOG_DEBUG); | |
| 3520 | 3520 | $result = $this->db->query($sql); | 
| 3521 | 3521 |          if ($result) {
 | 
| 3522 | 3522 | $num = $this->db->num_rows($result); | 
| 3523 | 3523 | $i = 0; | 
| 3524 | 3524 |              if ($num) {
 | 
| 3525 | - print '<select id="select' . $htmlname . '" class="flat selectbankaccount" name="' . $htmlname . '"' . ($moreattrib ? ' ' . $moreattrib : '') . '>'; | |
| 3525 | + print '<select id="select'.$htmlname.'" class="flat selectbankaccount" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>'; | |
| 3526 | 3526 |                  if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
 | 
| 3527 | 3527 | print '<option value="-1"> </option>'; | 
| 3528 | 3528 | } | 
| @@ -3530,15 +3530,15 @@ discard block | ||
| 3530 | 3530 |                  while ($i < $num) {
 | 
| 3531 | 3531 | $obj = $this->db->fetch_object($result); | 
| 3532 | 3532 |                      if ($selected == $obj->rowid) {
 | 
| 3533 | - print '<option value="' . $obj->rowid . '" selected>'; | |
| 3533 | + print '<option value="'.$obj->rowid.'" selected>'; | |
| 3534 | 3534 |                      } else {
 | 
| 3535 | - print '<option value="' . $obj->rowid . '">'; | |
| 3535 | + print '<option value="'.$obj->rowid.'">'; | |
| 3536 | 3536 | } | 
| 3537 | 3537 | print trim($obj->label); | 
| 3538 | 3538 | if ($showcurrency) | 
| 3539 | -                        print ' (' . $obj->currency_code . ')';
 | |
| 3539 | +                        print ' ('.$obj->currency_code.')';
 | |
| 3540 | 3540 | if ($statut == 2 && $obj->status == 1) | 
| 3541 | -                        print ' (' . $langs->trans("Closed") . ')';
 | |
| 3541 | +                        print ' ('.$langs->trans("Closed").')';
 | |
| 3542 | 3542 | print '</option>'; | 
| 3543 | 3543 | $i++; | 
| 3544 | 3544 | } | 
| @@ -3546,9 +3546,9 @@ discard block | ||
| 3546 | 3546 | } | 
| 3547 | 3547 |              else {
 | 
| 3548 | 3548 | if ($statut == 0) | 
| 3549 | -                    print '<span class="opacitymedium">' . $langs->trans("NoActiveBankAccountDefined") . '</span>';
 | |
| 3549 | +                    print '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>';
 | |
| 3550 | 3550 | else | 
| 3551 | -                    print '<span class="opacitymedium">' . $langs->trans("NoBankAccountFound") . '</span>';
 | |
| 3551 | +                    print '<span class="opacitymedium">'.$langs->trans("NoBankAccountFound").'</span>';
 | |
| 3552 | 3552 | } | 
| 3553 | 3553 | } | 
| 3554 | 3554 |          else {
 | 
| @@ -3571,19 +3571,19 @@ discard block | ||
| 3571 | 3571 |      {
 | 
| 3572 | 3572 | global $langs; | 
| 3573 | 3573 |          if ($htmlname != "none") {
 | 
| 3574 | - print '<form method="POST" action="' . $page . '">'; | |
| 3574 | + print '<form method="POST" action="'.$page.'">'; | |
| 3575 | 3575 | print '<input type="hidden" name="action" value="setbankaccount">'; | 
| 3576 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 3576 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 3577 | 3577 | $nbaccountfound = $this->select_comptes($selected, $htmlname, 0, '', $addempty); | 
| 3578 | 3578 | if ($nbaccountfound > 0) | 
| 3579 | -                print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
 | |
| 3579 | +                print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
 | |
| 3580 | 3580 | print '</form>'; | 
| 3581 | 3581 |          } else {
 | 
| 3582 | 3582 | |
| 3583 | 3583 |              $langs->load('banks');
 | 
| 3584 | 3584 | |
| 3585 | 3585 |              if ($selected) {
 | 
| 3586 | - require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; | |
| 3586 | + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; | |
| 3587 | 3587 | $bankstatic = new Account($this->db); | 
| 3588 | 3588 | $result = $bankstatic->fetch($selected); | 
| 3589 | 3589 | if ($result) | 
| @@ -3613,19 +3613,19 @@ discard block | ||
| 3613 | 3613 | global $conf, $langs; | 
| 3614 | 3614 |          $langs->load("categories");
 | 
| 3615 | 3615 | |
| 3616 | - include_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; | |
| 3616 | + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; | |
| 3617 | 3617 | |
| 3618 | 3618 | // For backward compatibility | 
| 3619 | 3619 |          if (is_numeric($type)) {
 | 
| 3620 | - dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING); | |
| 3620 | + dol_syslog(__METHOD__.': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING); | |
| 3621 | 3621 | } | 
| 3622 | 3622 | |
| 3623 | 3623 |          if ($type === Categorie::TYPE_BANK_LINE) {
 | 
| 3624 | 3624 | // TODO Move this into common category feature | 
| 3625 | 3625 | $categids = array(); | 
| 3626 | 3626 | $sql = "SELECT c.label, c.rowid"; | 
| 3627 | - $sql .= " FROM " . MAIN_DB_PREFIX . "bank_categ as c"; | |
| 3628 | - $sql .= " WHERE entity = " . $conf->entity; | |
| 3627 | + $sql .= " FROM ".MAIN_DB_PREFIX."bank_categ as c"; | |
| 3628 | + $sql .= " WHERE entity = ".$conf->entity; | |
| 3629 | 3629 | $sql .= " ORDER BY c.label"; | 
| 3630 | 3630 | $result = $this->db->query($sql); | 
| 3631 | 3631 |              if ($result) {
 | 
| @@ -3646,11 +3646,11 @@ discard block | ||
| 3646 | 3646 | $cate_arbo = $cat->get_full_arbo($type, $excludeafterid); | 
| 3647 | 3647 | } | 
| 3648 | 3648 | |
| 3649 | - $output = '<select class="flat" name="' . $htmlname . '" id="' . $htmlname . '">'; | |
| 3649 | + $output = '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">'; | |
| 3650 | 3650 | $outarray = array(); | 
| 3651 | 3651 |          if (is_array($cate_arbo)) {
 | 
| 3652 | 3652 | if (!count($cate_arbo)) | 
| 3653 | -                $output .= '<option value="-1" disabled>' . $langs->trans("NoCategoriesDefined") . '</option>';
 | |
| 3653 | +                $output .= '<option value="-1" disabled>'.$langs->trans("NoCategoriesDefined").'</option>';
 | |
| 3654 | 3654 |              else {
 | 
| 3655 | 3655 | $output .= '<option value="-1"> </option>'; | 
| 3656 | 3656 |                  foreach ($cate_arbo as $key => $value) {
 | 
| @@ -3659,7 +3659,7 @@ discard block | ||
| 3659 | 3659 |                      } else {
 | 
| 3660 | 3660 | $add = ''; | 
| 3661 | 3661 | } | 
| 3662 | - $output .= '<option ' . $add . 'value="' . $cate_arbo[$key]['id'] . '">' . dol_trunc($cate_arbo[$key]['fulllabel'], $maxlength, 'middle') . '</option>'; | |
| 3662 | + $output .= '<option '.$add.'value="'.$cate_arbo[$key]['id'].'">'.dol_trunc($cate_arbo[$key]['fulllabel'], $maxlength, 'middle').'</option>'; | |
| 3663 | 3663 | |
| 3664 | 3664 | $outarray[$cate_arbo[$key]['id']] = $cate_arbo[$key]['fulllabel']; | 
| 3665 | 3665 | } | 
| @@ -3693,7 +3693,7 @@ discard block | ||
| 3693 | 3693 | function form_confirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = "", $useajax = 0, $height = 170, $width = 500) | 
| 3694 | 3694 |      {
 | 
| 3695 | 3695 | // phpcs:enable | 
| 3696 | - dol_syslog(__METHOD__ . ': using form_confirm is deprecated. Use formconfim instead.', LOG_WARNING); | |
| 3696 | + dol_syslog(__METHOD__.': using form_confirm is deprecated. Use formconfim instead.', LOG_WARNING); | |
| 3697 | 3697 | print $this->formconfirm($page, $title, $question, $action, $formquestion, $selectedchoice, $useajax, $height, $width); | 
| 3698 | 3698 | } | 
| 3699 | 3699 | |
| @@ -3741,36 +3741,36 @@ discard block | ||
| 3741 | 3741 |              foreach ($formquestion as $key => $input) {
 | 
| 3742 | 3742 |                  if (is_array($input) && !empty($input)) {
 | 
| 3743 | 3743 |                      if ($input['type'] == 'hidden') {
 | 
| 3744 | - $more .= '<input type="hidden" id="' . $input['name'] . '" name="' . $input['name'] . '" value="' . dol_escape_htmltag($input['value']) . '">' . "\n"; | |
| 3744 | + $more .= '<input type="hidden" id="'.$input['name'].'" name="'.$input['name'].'" value="'.dol_escape_htmltag($input['value']).'">'."\n"; | |
| 3745 | 3745 | } | 
| 3746 | 3746 | } | 
| 3747 | 3747 | } | 
| 3748 | 3748 | |
| 3749 | 3749 | // Now add questions | 
| 3750 | - $more .= '<table class="paddingtopbottomonly" width="100%">' . "\n"; | |
| 3750 | + $more .= '<table class="paddingtopbottomonly" width="100%">'."\n"; | |
| 3751 | 3751 | if (!empty($formquestion['text'])) | 
| 3752 | - $more .= '<tr><td colspan="2">' . $formquestion['text'] . '</td></tr>' . "\n"; | |
| 3752 | + $more .= '<tr><td colspan="2">'.$formquestion['text'].'</td></tr>'."\n"; | |
| 3753 | 3753 |              foreach ($formquestion as $key => $input) {
 | 
| 3754 | 3754 |                  if (is_array($input) && !empty($input)) {
 | 
| 3755 | - $size = (!empty($input['size']) ? ' size="' . $input['size'] . '"' : ''); | |
| 3756 | - $moreattr = (!empty($input['moreattr']) ? ' ' . $input['moreattr'] : ''); | |
| 3757 | - $morecss = (!empty($input['morecss']) ? ' ' . $input['morecss'] : ''); | |
| 3755 | + $size = (!empty($input['size']) ? ' size="'.$input['size'].'"' : ''); | |
| 3756 | + $moreattr = (!empty($input['moreattr']) ? ' '.$input['moreattr'] : ''); | |
| 3757 | + $morecss = (!empty($input['morecss']) ? ' '.$input['morecss'] : ''); | |
| 3758 | 3758 | |
| 3759 | 3759 |                      if ($input['type'] == 'text') {
 | 
| 3760 | -                        $more .= '<tr><td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '>' . $input['label'] . '</td><td align="left"><input type="text" class="flat' . $morecss . '" id="' . $input['name'] . '" name="' . $input['name'] . '"' . $size . ' value="' . $input['value'] . '"' . $moreattr . ' /></td></tr>' . "\n";
 | |
| 3760 | +                        $more .= '<tr><td'.(empty($input['tdclass']) ? '' : (' class="'.$input['tdclass'].'"')).'>'.$input['label'].'</td><td align="left"><input type="text" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'"'.$moreattr.' /></td></tr>'."\n";
 | |
| 3761 | 3761 |                      } elseif ($input['type'] == 'password') {
 | 
| 3762 | -                        $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";
 | |
| 3762 | +                        $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 | 3763 |                      } elseif ($input['type'] == 'select') {
 | 
| 3764 | -                        $more .= '<tr><td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '>';
 | |
| 3764 | +                        $more .= '<tr><td'.(empty($input['tdclass']) ? '' : (' class="'.$input['tdclass'].'"')).'>';
 | |
| 3765 | 3765 | if (!empty($input['label'])) | 
| 3766 | - $more .= $input['label'] . '</td><td class="tdtop" align="left">'; | |
| 3766 | + $more .= $input['label'].'</td><td class="tdtop" align="left">'; | |
| 3767 | 3767 | $more .= $this->selectarray($input['name'], $input['values'], $input['default'], 1, 0, 0, $moreattr, 0, 0, 0, '', $morecss); | 
| 3768 | - $more .= '</td></tr>' . "\n"; | |
| 3768 | + $more .= '</td></tr>'."\n"; | |
| 3769 | 3769 | } | 
| 3770 | 3770 |                      elseif ($input['type'] == 'checkbox') {
 | 
| 3771 | 3771 | $more .= '<tr>'; | 
| 3772 | -                        $more .= '<td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '>' . $input['label'] . ' </td><td align="left">';
 | |
| 3773 | - $more .= '<input type="checkbox" class="flat' . $morecss . '" id="' . $input['name'] . '" name="' . $input['name'] . '"' . $moreattr; | |
| 3772 | +                        $more .= '<td'.(empty($input['tdclass']) ? '' : (' class="'.$input['tdclass'].'"')).'>'.$input['label'].' </td><td align="left">';
 | |
| 3773 | + $more .= '<input type="checkbox" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$moreattr; | |
| 3774 | 3774 | if (!is_bool($input['value']) && $input['value'] != 'false' && $input['value'] != '0') | 
| 3775 | 3775 | $more .= ' checked'; | 
| 3776 | 3776 | if (is_bool($input['value']) && $input['value']) | 
| @@ -3778,51 +3778,51 @@ discard block | ||
| 3778 | 3778 | if (isset($input['disabled'])) | 
| 3779 | 3779 | $more .= ' disabled'; | 
| 3780 | 3780 | $more .= ' /></td>'; | 
| 3781 | - $more .= '</tr>' . "\n"; | |
| 3781 | + $more .= '</tr>'."\n"; | |
| 3782 | 3782 | } | 
| 3783 | 3783 |                      elseif ($input['type'] == 'radio') {
 | 
| 3784 | 3784 | $i = 0; | 
| 3785 | 3785 |                          foreach ($input['values'] as $selkey => $selval) {
 | 
| 3786 | 3786 | $more .= '<tr>'; | 
| 3787 | 3787 | if ($i == 0) | 
| 3788 | -                                $more .= '<td' . (empty($input['tdclass']) ? ' class="tdtop"' : (' class="tdtop ' . $input['tdclass'] . '"')) . '>' . $input['label'] . '</td>';
 | |
| 3788 | +                                $more .= '<td'.(empty($input['tdclass']) ? ' class="tdtop"' : (' class="tdtop '.$input['tdclass'].'"')).'>'.$input['label'].'</td>';
 | |
| 3789 | 3789 | else | 
| 3790 | -                                $more .= '<td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '> </td>';
 | |
| 3791 | - $more .= '<td><input type="radio" class="flat' . $morecss . '" id="' . $input['name'] . '" name="' . $input['name'] . '" value="' . $selkey . '"' . $moreattr; | |
| 3790 | +                                $more .= '<td'.(empty($input['tdclass']) ? '' : (' class="'.$input['tdclass'].'"')).'> </td>';
 | |
| 3791 | + $more .= '<td><input type="radio" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'" value="'.$selkey.'"'.$moreattr; | |
| 3792 | 3792 | if ($input['disabled']) | 
| 3793 | 3793 | $more .= ' disabled'; | 
| 3794 | 3794 | $more .= ' /> '; | 
| 3795 | 3795 | $more .= $selval; | 
| 3796 | - $more .= '</td></tr>' . "\n"; | |
| 3796 | + $more .= '</td></tr>'."\n"; | |
| 3797 | 3797 | $i++; | 
| 3798 | 3798 | } | 
| 3799 | 3799 | } | 
| 3800 | 3800 |                      elseif ($input['type'] == 'date') {
 | 
| 3801 | -                        $more .= '<tr><td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '>' . $input['label'] . '</td>';
 | |
| 3801 | +                        $more .= '<tr><td'.(empty($input['tdclass']) ? '' : (' class="'.$input['tdclass'].'"')).'>'.$input['label'].'</td>';
 | |
| 3802 | 3802 | $more .= '<td align="left">'; | 
| 3803 | 3803 | $more .= $this->selectDate($input['value'], $input['name'], 0, 0, 0, '', 1, 0); | 
| 3804 | - $more .= '</td></tr>' . "\n"; | |
| 3805 | -                        $formquestion[] = array('name' => $input['name'] . 'day');
 | |
| 3806 | -                        $formquestion[] = array('name' => $input['name'] . 'month');
 | |
| 3807 | -                        $formquestion[] = array('name' => $input['name'] . 'year');
 | |
| 3808 | -                        $formquestion[] = array('name' => $input['name'] . 'hour');
 | |
| 3809 | -                        $formquestion[] = array('name' => $input['name'] . 'min');
 | |
| 3804 | + $more .= '</td></tr>'."\n"; | |
| 3805 | +                        $formquestion[] = array('name' => $input['name'].'day');
 | |
| 3806 | +                        $formquestion[] = array('name' => $input['name'].'month');
 | |
| 3807 | +                        $formquestion[] = array('name' => $input['name'].'year');
 | |
| 3808 | +                        $formquestion[] = array('name' => $input['name'].'hour');
 | |
| 3809 | +                        $formquestion[] = array('name' => $input['name'].'min');
 | |
| 3810 | 3810 |                      } elseif ($input['type'] == 'other') {
 | 
| 3811 | -                        $more .= '<tr><td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '>';
 | |
| 3811 | +                        $more .= '<tr><td'.(empty($input['tdclass']) ? '' : (' class="'.$input['tdclass'].'"')).'>';
 | |
| 3812 | 3812 | if (!empty($input['label'])) | 
| 3813 | - $more .= $input['label'] . '</td><td align="left">'; | |
| 3813 | + $more .= $input['label'].'</td><td align="left">'; | |
| 3814 | 3814 | $more .= $input['value']; | 
| 3815 | - $more .= '</td></tr>' . "\n"; | |
| 3815 | + $more .= '</td></tr>'."\n"; | |
| 3816 | 3816 | } | 
| 3817 | 3817 | |
| 3818 | 3818 |                      elseif ($input['type'] == 'onecolumn') {
 | 
| 3819 | 3819 | $more .= '<tr><td colspan="2" align="left">'; | 
| 3820 | 3820 | $more .= $input['value']; | 
| 3821 | - $more .= '</td></tr>' . "\n"; | |
| 3821 | + $more .= '</td></tr>'."\n"; | |
| 3822 | 3822 | } | 
| 3823 | 3823 | } | 
| 3824 | 3824 | } | 
| 3825 | - $more .= '</table>' . "\n"; | |
| 3825 | + $more .= '</table>'."\n"; | |
| 3826 | 3826 | } | 
| 3827 | 3827 | |
| 3828 | 3828 | // JQUI method dialog is broken with jmobile, we use standard HTML. | 
| @@ -3841,10 +3841,10 @@ discard block | ||
| 3841 | 3841 | $button = $useajax; | 
| 3842 | 3842 | $useajax = 1; | 
| 3843 | 3843 | $autoOpen = false; | 
| 3844 | - $dialogconfirm .= '-' . $button; | |
| 3844 | + $dialogconfirm .= '-'.$button; | |
| 3845 | 3845 | } | 
| 3846 | -            $pageyes = $page . (preg_match('/\?/', $page) ? '&' : '?') . 'action=' . $action . '&confirm=yes';
 | |
| 3847 | -            $pageno = ($useajax == 2 ? $page . (preg_match('/\?/', $page) ? '&' : '?') . 'confirm=no' : '');
 | |
| 3846 | +            $pageyes = $page.(preg_match('/\?/', $page) ? '&' : '?').'action='.$action.'&confirm=yes';
 | |
| 3847 | +            $pageno = ($useajax == 2 ? $page.(preg_match('/\?/', $page) ? '&' : '?').'confirm=no' : '');
 | |
| 3848 | 3848 | // Add input fields into list of fields to read during submit (inputok and inputko) | 
| 3849 | 3849 |              if (is_array($formquestion)) {
 | 
| 3850 | 3850 |                  foreach ($formquestion as $key => $input) {
 | 
| @@ -3856,20 +3856,20 @@ discard block | ||
| 3856 | 3856 | } | 
| 3857 | 3857 | } | 
| 3858 | 3858 | // Show JQuery confirm box. Note that global var $useglobalvars is used inside this template | 
| 3859 | - $formconfirm .= '<div id="' . $dialogconfirm . '" title="' . dol_escape_htmltag($title) . '" style="display: none;">'; | |
| 3859 | + $formconfirm .= '<div id="'.$dialogconfirm.'" title="'.dol_escape_htmltag($title).'" style="display: none;">'; | |
| 3860 | 3860 |              if (!empty($more)) {
 | 
| 3861 | - $formconfirm .= '<div class="confirmquestions">' . $more . '</div>'; | |
| 3861 | + $formconfirm .= '<div class="confirmquestions">'.$more.'</div>'; | |
| 3862 | 3862 | } | 
| 3863 | -            $formconfirm .= ($question ? '<div class="confirmmessage">' . img_help('', '') . ' ' . $question . '</div>' : '');
 | |
| 3864 | - $formconfirm .= '</div>' . "\n"; | |
| 3863 | +            $formconfirm .= ($question ? '<div class="confirmmessage">'.img_help('', '').' '.$question.'</div>' : '');
 | |
| 3864 | + $formconfirm .= '</div>'."\n"; | |
| 3865 | 3865 | |
| 3866 | - $formconfirm .= "\n<!-- begin ajax formconfirm page=" . $page . " -->\n"; | |
| 3867 | - $formconfirm .= '<script type="text/javascript">' . "\n"; | |
| 3866 | + $formconfirm .= "\n<!-- begin ajax formconfirm page=".$page." -->\n"; | |
| 3867 | + $formconfirm .= '<script type="text/javascript">'."\n"; | |
| 3868 | 3868 |              $formconfirm .= 'jQuery(document).ready(function() {
 | 
| 3869 | 3869 |              $(function() {
 | 
| 3870 | - $( "#' . $dialogconfirm . '" ).dialog( | |
| 3870 | + $( "#' . $dialogconfirm.'" ).dialog( | |
| 3871 | 3871 |              	{
 | 
| 3872 | - autoOpen: ' . ($autoOpen ? "true" : "false") . ','; | |
| 3872 | + autoOpen: ' . ($autoOpen ? "true" : "false").','; | |
| 3873 | 3873 |              if ($newselectedchoice == 'no') {
 | 
| 3874 | 3874 | $formconfirm .= ' | 
| 3875 | 3875 |  						open: function() {
 | 
| @@ -3878,15 +3878,15 @@ discard block | ||
| 3878 | 3878 | } | 
| 3879 | 3879 | $formconfirm .= ' | 
| 3880 | 3880 | resizable: false, | 
| 3881 | - height: "' . $height . '", | |
| 3882 | - width: "' . $width . '", | |
| 3881 | + height: "' . $height.'", | |
| 3882 | + width: "' . $width.'", | |
| 3883 | 3883 | modal: true, | 
| 3884 | 3884 | closeOnEscape: false, | 
| 3885 | 3885 |                      buttons: {
 | 
| 3886 | -                        "' . dol_escape_js($langs->transnoentities("Yes")) . '": function() {
 | |
| 3886 | +                        "' . dol_escape_js($langs->transnoentities("Yes")).'": function() {
 | |
| 3887 | 3887 | var options=""; | 
| 3888 | - var inputok = ' . json_encode($inputok) . '; | |
| 3889 | - var pageyes = "' . dol_escape_js(!empty($pageyes) ? $pageyes : '') . '"; | |
| 3888 | + var inputok = ' . json_encode($inputok).'; | |
| 3889 | + var pageyes = "' . dol_escape_js(!empty($pageyes) ? $pageyes : '').'"; | |
| 3890 | 3890 |                           	if (inputok.length>0) {
 | 
| 3891 | 3891 |                           		$.each(inputok, function(i, inputname) {
 | 
| 3892 | 3892 | var more = ""; | 
| @@ -3902,10 +3902,10 @@ discard block | ||
| 3902 | 3902 |              				if (pageyes.length > 0) { location.href = urljump; }
 | 
| 3903 | 3903 |                              $(this).dialog("close");
 | 
| 3904 | 3904 | }, | 
| 3905 | -                        "' . dol_escape_js($langs->transnoentities("No")) . '": function() {
 | |
| 3905 | +                        "' . dol_escape_js($langs->transnoentities("No")).'": function() {
 | |
| 3906 | 3906 | var options = ""; | 
| 3907 | - var inputko = ' . json_encode($inputko) . '; | |
| 3908 | - var pageno="' . dol_escape_js(!empty($pageno) ? $pageno : '') . '"; | |
| 3907 | + var inputko = ' . json_encode($inputko).'; | |
| 3908 | + var pageno="' . dol_escape_js(!empty($pageno) ? $pageno : '').'"; | |
| 3909 | 3909 |                           	if (inputko.length>0) {
 | 
| 3910 | 3910 |                           		$.each(inputko, function(i, inputname) {
 | 
| 3911 | 3911 | var more = ""; | 
| @@ -3924,10 +3924,10 @@ discard block | ||
| 3924 | 3924 | } | 
| 3925 | 3925 | ); | 
| 3926 | 3926 | |
| 3927 | - var button = "' . $button . '"; | |
| 3927 | + var button = "' . $button.'"; | |
| 3928 | 3928 |              	if (button.length > 0) {
 | 
| 3929 | 3929 |                  	$( "#" + button ).click(function() {
 | 
| 3930 | -                		$("#' . $dialogconfirm . '").dialog("open");
 | |
| 3930 | +                		$("#' . $dialogconfirm.'").dialog("open");
 | |
| 3931 | 3931 | }); | 
| 3932 | 3932 | } | 
| 3933 | 3933 | }); | 
| @@ -3935,37 +3935,37 @@ discard block | ||
| 3935 | 3935 | </script>'; | 
| 3936 | 3936 | $formconfirm .= "<!-- end ajax formconfirm -->\n"; | 
| 3937 | 3937 |          } else {
 | 
| 3938 | - $formconfirm .= "\n<!-- begin formconfirm page=" . $page . " -->\n"; | |
| 3938 | + $formconfirm .= "\n<!-- begin formconfirm page=".$page." -->\n"; | |
| 3939 | 3939 | |
| 3940 | 3940 | if (empty($disableformtag)) | 
| 3941 | - $formconfirm .= '<form method="POST" action="' . $page . '" class="notoptoleftroright">' . "\n"; | |
| 3941 | + $formconfirm .= '<form method="POST" action="'.$page.'" class="notoptoleftroright">'."\n"; | |
| 3942 | 3942 | |
| 3943 | - $formconfirm .= '<input type="hidden" name="action" value="' . $action . '">' . "\n"; | |
| 3943 | + $formconfirm .= '<input type="hidden" name="action" value="'.$action.'">'."\n"; | |
| 3944 | 3944 | if (empty($disableformtag)) | 
| 3945 | - $formconfirm .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">' . "\n"; | |
| 3945 | + $formconfirm .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n"; | |
| 3946 | 3946 | |
| 3947 | - $formconfirm .= '<table width="100%" class="valid">' . "\n"; | |
| 3947 | + $formconfirm .= '<table width="100%" class="valid">'."\n"; | |
| 3948 | 3948 | |
| 3949 | 3949 | // Line title | 
| 3950 | -            $formconfirm .= '<tr class="validtitre"><td class="validtitre" colspan="3">' . img_picto('', 'recent') . ' ' . $title . '</td></tr>' . "\n";
 | |
| 3950 | +            $formconfirm .= '<tr class="validtitre"><td class="validtitre" colspan="3">'.img_picto('', 'recent').' '.$title.'</td></tr>'."\n";
 | |
| 3951 | 3951 | |
| 3952 | 3952 | // Line form fields | 
| 3953 | 3953 |              if ($more) {
 | 
| 3954 | - $formconfirm .= '<tr class="valid"><td class="valid" colspan="3">' . "\n"; | |
| 3954 | + $formconfirm .= '<tr class="valid"><td class="valid" colspan="3">'."\n"; | |
| 3955 | 3955 | $formconfirm .= $more; | 
| 3956 | - $formconfirm .= '</td></tr>' . "\n"; | |
| 3956 | + $formconfirm .= '</td></tr>'."\n"; | |
| 3957 | 3957 | } | 
| 3958 | 3958 | |
| 3959 | 3959 | // Line with question | 
| 3960 | 3960 | $formconfirm .= '<tr class="valid">'; | 
| 3961 | - $formconfirm .= '<td class="valid">' . $question . '</td>'; | |
| 3961 | + $formconfirm .= '<td class="valid">'.$question.'</td>'; | |
| 3962 | 3962 | $formconfirm .= '<td class="valid">'; | 
| 3963 | 3963 |              $formconfirm .= $this->selectyesno("confirm", $newselectedchoice);
 | 
| 3964 | 3964 | $formconfirm .= '</td>'; | 
| 3965 | -            $formconfirm .= '<td class="valid" align="center"><input class="button valignmiddle" type="submit" value="' . $langs->trans("Validate") . '"></td>';
 | |
| 3966 | - $formconfirm .= '</tr>' . "\n"; | |
| 3965 | +            $formconfirm .= '<td class="valid" align="center"><input class="button valignmiddle" type="submit" value="'.$langs->trans("Validate").'"></td>';
 | |
| 3966 | + $formconfirm .= '</tr>'."\n"; | |
| 3967 | 3967 | |
| 3968 | - $formconfirm .= '</table>' . "\n"; | |
| 3968 | + $formconfirm .= '</table>'."\n"; | |
| 3969 | 3969 | |
| 3970 | 3970 | if (empty($disableformtag)) | 
| 3971 | 3971 | $formconfirm .= "</form>\n"; | 
| @@ -3996,8 +3996,8 @@ discard block | ||
| 3996 | 3996 | // phpcs:enable | 
| 3997 | 3997 | global $langs; | 
| 3998 | 3998 | |
| 3999 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php'; | |
| 4000 | - require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; | |
| 3999 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; | |
| 4000 | + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; | |
| 4001 | 4001 | |
| 4002 | 4002 | $out = ''; | 
| 4003 | 4003 | |
| @@ -4006,11 +4006,11 @@ discard block | ||
| 4006 | 4006 |          $langs->load("project");
 | 
| 4007 | 4007 |          if ($htmlname != "none") {
 | 
| 4008 | 4008 | $out .= "\n"; | 
| 4009 | - $out .= '<form method="post" action="' . $page . '">'; | |
| 4009 | + $out .= '<form method="post" action="'.$page.'">'; | |
| 4010 | 4010 | $out .= '<input type="hidden" name="action" value="classin">'; | 
| 4011 | - $out .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 4011 | + $out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 4012 | 4012 | $out .= $formproject->select_projects($socid, $selected, $htmlname, $maxlength, 0, 1, $discard_closed, $forcefocus, 0, 0, '', 1); | 
| 4013 | -            $out .= '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
 | |
| 4013 | +            $out .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
 | |
| 4014 | 4014 | $out .= '</form>'; | 
| 4015 | 4015 |          } else {
 | 
| 4016 | 4016 |              if ($selected) {
 | 
| @@ -4045,11 +4045,11 @@ discard block | ||
| 4045 | 4045 | // phpcs:enable | 
| 4046 | 4046 | global $langs; | 
| 4047 | 4047 |          if ($htmlname != "none") {
 | 
| 4048 | - print '<form method="post" action="' . $page . '">'; | |
| 4048 | + print '<form method="post" action="'.$page.'">'; | |
| 4049 | 4049 | print '<input type="hidden" name="action" value="setconditions">'; | 
| 4050 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 4050 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 4051 | 4051 | $this->select_conditions_paiements($selected, $htmlname, -1, $addempty); | 
| 4052 | -            print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
 | |
| 4052 | +            print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
 | |
| 4053 | 4053 | print '</form>'; | 
| 4054 | 4054 |          } else {
 | 
| 4055 | 4055 |              if ($selected) {
 | 
| @@ -4076,11 +4076,11 @@ discard block | ||
| 4076 | 4076 | // phpcs:enable | 
| 4077 | 4077 | global $langs; | 
| 4078 | 4078 |          if ($htmlname != "none") {
 | 
| 4079 | - print '<form method="post" action="' . $page . '">'; | |
| 4079 | + print '<form method="post" action="'.$page.'">'; | |
| 4080 | 4080 | print '<input type="hidden" name="action" value="setavailability">'; | 
| 4081 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 4081 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 4082 | 4082 | $this->selectAvailabilityDelay($selected, $htmlname, -1, $addempty); | 
| 4083 | -            print '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
 | |
| 4083 | +            print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
 | |
| 4084 | 4084 | print '</form>'; | 
| 4085 | 4085 |          } else {
 | 
| 4086 | 4086 |              if ($selected) {
 | 
| @@ -4106,11 +4106,11 @@ discard block | ||
| 4106 | 4106 |      {
 | 
| 4107 | 4107 | global $langs; | 
| 4108 | 4108 |          if ($htmlname != "none") {
 | 
| 4109 | - print '<form method="post" action="' . $page . '">'; | |
| 4109 | + print '<form method="post" action="'.$page.'">'; | |
| 4110 | 4110 | print '<input type="hidden" name="action" value="setdemandreason">'; | 
| 4111 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 4111 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 4112 | 4112 | $this->selectInputReason($selected, $htmlname, -1, $addempty); | 
| 4113 | -            print '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
 | |
| 4113 | +            print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
 | |
| 4114 | 4114 | print '</form>'; | 
| 4115 | 4115 |          } else {
 | 
| 4116 | 4116 |              if ($selected) {
 | 
| @@ -4148,14 +4148,14 @@ discard block | ||
| 4148 | 4148 | $ret = ''; | 
| 4149 | 4149 | |
| 4150 | 4150 |          if ($htmlname != "none") {
 | 
| 4151 | - $ret .= '<form method="post" action="' . $page . '" name="form' . $htmlname . '">'; | |
| 4152 | - $ret .= '<input type="hidden" name="action" value="set' . $htmlname . '">'; | |
| 4153 | - $ret .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 4151 | + $ret .= '<form method="post" action="'.$page.'" name="form'.$htmlname.'">'; | |
| 4152 | + $ret .= '<input type="hidden" name="action" value="set'.$htmlname.'">'; | |
| 4153 | + $ret .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 4154 | 4154 | $ret .= '<table class="nobordernopadding" cellpadding="0" cellspacing="0">'; | 
| 4155 | 4155 | $ret .= '<tr><td>'; | 
| 4156 | - $ret .= $this->selectDate($selected, $htmlname, $displayhour, $displaymin, 1, 'form' . $htmlname, 1, 0); | |
| 4156 | + $ret .= $this->selectDate($selected, $htmlname, $displayhour, $displaymin, 1, 'form'.$htmlname, 1, 0); | |
| 4157 | 4157 | $ret .= '</td>'; | 
| 4158 | -            $ret .= '<td align="left"><input type="submit" class="button" value="' . $langs->trans("Modify") . '"></td>';
 | |
| 4158 | +            $ret .= '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
 | |
| 4159 | 4159 | $ret .= '</tr></table></form>'; | 
| 4160 | 4160 |          } else {
 | 
| 4161 | 4161 | if ($displayhour) | 
| @@ -4186,15 +4186,15 @@ discard block | ||
| 4186 | 4186 | global $langs; | 
| 4187 | 4187 | |
| 4188 | 4188 |          if ($htmlname != "none") {
 | 
| 4189 | - print '<form method="POST" action="' . $page . '" name="form' . $htmlname . '">'; | |
| 4190 | - print '<input type="hidden" name="action" value="set' . $htmlname . '">'; | |
| 4191 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 4189 | + print '<form method="POST" action="'.$page.'" name="form'.$htmlname.'">'; | |
| 4190 | + print '<input type="hidden" name="action" value="set'.$htmlname.'">'; | |
| 4191 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 4192 | 4192 | print $this->select_dolusers($selected, $htmlname, 1, $exclude, 0, $include); | 
| 4193 | -            print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
 | |
| 4193 | +            print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
 | |
| 4194 | 4194 | print '</form>'; | 
| 4195 | 4195 |          } else {
 | 
| 4196 | 4196 |              if ($selected) {
 | 
| 4197 | - require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; | |
| 4197 | + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; | |
| 4198 | 4198 | $theuser = new User($this->db); | 
| 4199 | 4199 | $theuser->fetch($selected); | 
| 4200 | 4200 | print $theuser->getNomUrl(1); | 
| @@ -4220,11 +4220,11 @@ discard block | ||
| 4220 | 4220 | // phpcs:enable | 
| 4221 | 4221 | global $langs; | 
| 4222 | 4222 |          if ($htmlname != "none") {
 | 
| 4223 | - print '<form method="POST" action="' . $page . '">'; | |
| 4223 | + print '<form method="POST" action="'.$page.'">'; | |
| 4224 | 4224 | print '<input type="hidden" name="action" value="setmode">'; | 
| 4225 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 4225 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 4226 | 4226 | $this->select_types_paiements($selected, $htmlname, $filtertype, 0, 0, 0, 0, $active); | 
| 4227 | -            print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
 | |
| 4227 | +            print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
 | |
| 4228 | 4228 | print '</form>'; | 
| 4229 | 4229 |          } else {
 | 
| 4230 | 4230 |              if ($selected) {
 | 
| @@ -4250,11 +4250,11 @@ discard block | ||
| 4250 | 4250 | // phpcs:enable | 
| 4251 | 4251 | global $langs; | 
| 4252 | 4252 |          if ($htmlname != "none") {
 | 
| 4253 | - print '<form method="POST" action="' . $page . '">'; | |
| 4253 | + print '<form method="POST" action="'.$page.'">'; | |
| 4254 | 4254 | print '<input type="hidden" name="action" value="setmulticurrencycode">'; | 
| 4255 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 4255 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 4256 | 4256 | print $this->selectMultiCurrency($selected, $htmlname, 0); | 
| 4257 | -            print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
 | |
| 4257 | +            print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
 | |
| 4258 | 4258 | print '</form>'; | 
| 4259 | 4259 |          } else {
 | 
| 4260 | 4260 |              dol_include_once('/core/lib/company.lib.php');
 | 
| @@ -4278,21 +4278,21 @@ discard block | ||
| 4278 | 4278 | global $langs, $mysoc, $conf; | 
| 4279 | 4279 | |
| 4280 | 4280 |          if ($htmlname != "none") {
 | 
| 4281 | - print '<form method="POST" action="' . $page . '">'; | |
| 4281 | + print '<form method="POST" action="'.$page.'">'; | |
| 4282 | 4282 | print '<input type="hidden" name="action" value="setmulticurrencyrate">'; | 
| 4283 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 4284 | - print '<input type="text" name="' . $htmlname . '" value="' . (!empty($rate) ? price($rate) : 1) . '" size="10" /> '; | |
| 4283 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 4284 | + print '<input type="text" name="'.$htmlname.'" value="'.(!empty($rate) ? price($rate) : 1).'" size="10" /> '; | |
| 4285 | 4285 | print '<select name="calculation_mode">'; | 
| 4286 | - print '<option value="1">' . $currency . ' > ' . $conf->currency . '</option>'; | |
| 4287 | - print '<option value="2">' . $conf->currency . ' > ' . $currency . '</option>'; | |
| 4286 | + print '<option value="1">'.$currency.' > '.$conf->currency.'</option>'; | |
| 4287 | + print '<option value="2">'.$conf->currency.' > '.$currency.'</option>'; | |
| 4288 | 4288 | print '</select> '; | 
| 4289 | -            print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
 | |
| 4289 | +            print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
 | |
| 4290 | 4290 | print '</form>'; | 
| 4291 | 4291 |          } else {
 | 
| 4292 | 4292 |              if (!empty($rate)) {
 | 
| 4293 | 4293 | print price($rate, 1, $langs, 1, 0); | 
| 4294 | 4294 | if ($currency && $rate != 1) | 
| 4295 | -                    print '   (' . price($rate, 1, $langs, 1, 0) . ' ' . $currency . ' = 1 ' . $conf->currency . ')';
 | |
| 4295 | +                    print '   ('.price($rate, 1, $langs, 1, 0).' '.$currency.' = 1 '.$conf->currency.')';
 | |
| 4296 | 4296 | } | 
| 4297 | 4297 |              else {
 | 
| 4298 | 4298 | print 1; | 
| @@ -4321,14 +4321,14 @@ discard block | ||
| 4321 | 4321 | // phpcs:enable | 
| 4322 | 4322 | global $conf, $langs; | 
| 4323 | 4323 |          if ($htmlname != "none") {
 | 
| 4324 | - print '<form method="post" action="' . $page . '">'; | |
| 4324 | + print '<form method="post" action="'.$page.'">'; | |
| 4325 | 4325 | print '<input type="hidden" name="action" value="setabsolutediscount">'; | 
| 4326 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 4326 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 4327 | 4327 | print '<div class="inline-block">'; | 
| 4328 | 4328 |              if (!empty($discount_type)) {
 | 
| 4329 | 4329 |                  if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
 | 
| 4330 | 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 | |
| 4331 | + $translationKey = 'HasAbsoluteDiscountFromSupplier'; // If we want deposit to be substracted to payments only and not to total of final invoice | |
| 4332 | 4332 | else | 
| 4333 | 4333 | $translationKey = 'HasCreditNoteFromSupplier'; | 
| 4334 | 4334 | } | 
| @@ -4341,7 +4341,7 @@ discard block | ||
| 4341 | 4341 |              } else {
 | 
| 4342 | 4342 |                  if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
 | 
| 4343 | 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 | |
| 4344 | + $translationKey = 'CompanyHasAbsoluteDiscount'; // If we want deposit to be substracted to payments only and not to total of final invoice | |
| 4345 | 4345 | else | 
| 4346 | 4346 | $translationKey = 'CompanyHasCreditNote'; | 
| 4347 | 4347 | } | 
| @@ -4358,21 +4358,21 @@ discard block | ||
| 4358 | 4358 | print '</div>'; | 
| 4359 | 4359 |              if (empty($hidelist)) {
 | 
| 4360 | 4360 | print '<div class="inline-block" style="padding-right: 10px">'; | 
| 4361 | - $newfilter = 'discount_type=' . intval($discount_type); | |
| 4361 | + $newfilter = 'discount_type='.intval($discount_type); | |
| 4362 | 4362 |                  if (!empty($discount_type)) {
 | 
| 4363 | 4363 | $newfilter .= ' AND fk_invoice_supplier IS NULL AND fk_invoice_supplier_line IS NULL'; // Supplier discounts available | 
| 4364 | 4364 |                  } else {
 | 
| 4365 | 4365 | $newfilter .= ' AND fk_facture IS NULL AND fk_facture_line IS NULL'; // Customer discounts available | 
| 4366 | 4366 | } | 
| 4367 | 4367 | if ($filter) | 
| 4368 | -                    $newfilter .= ' AND (' . $filter . ')';
 | |
| 4368 | +                    $newfilter .= ' AND ('.$filter.')';
 | |
| 4369 | 4369 | $nbqualifiedlines = $this->select_remises($selected, $htmlname, $newfilter, $socid, $maxvalue); | 
| 4370 | 4370 |                  if ($nbqualifiedlines > 0) {
 | 
| 4371 | -                    print '   <input type="submit" class="button" value="' . dol_escape_htmltag($langs->trans("UseLine")) . '"';
 | |
| 4371 | +                    print '   <input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("UseLine")).'"';
 | |
| 4372 | 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") . '"';
 | |
| 4373 | +                        print ' title="'.$langs->trans("UseCreditNoteInInvoicePayment").'"';
 | |
| 4374 | 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") . '"';
 | |
| 4375 | +                        print ' title="'.$langs->trans("UseCreditNoteInInvoicePayment").'"';
 | |
| 4376 | 4376 | |
| 4377 | 4377 | print '>'; | 
| 4378 | 4378 | } | 
| @@ -4409,22 +4409,22 @@ discard block | ||
| 4409 | 4409 | global $langs, $conf; | 
| 4410 | 4410 | |
| 4411 | 4411 |          if ($htmlname != "none") {
 | 
| 4412 | - print '<form method="post" action="' . $page . '">'; | |
| 4412 | + print '<form method="post" action="'.$page.'">'; | |
| 4413 | 4413 | print '<input type="hidden" name="action" value="set_contact">'; | 
| 4414 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 4414 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 4415 | 4415 | print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">'; | 
| 4416 | 4416 | print '<tr><td>'; | 
| 4417 | 4417 | $num = $this->select_contacts($societe->id, $selected, $htmlname); | 
| 4418 | 4418 |              if ($num == 0) {
 | 
| 4419 | 4419 |                  $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress"));
 | 
| 4420 | - print '<a href="' . DOL_URL_ROOT . '/contact/card.php?socid=' . $societe->id . '&action=create&backtoreferer=1">' . $addcontact . '</a>'; | |
| 4420 | + print '<a href="'.DOL_URL_ROOT.'/contact/card.php?socid='.$societe->id.'&action=create&backtoreferer=1">'.$addcontact.'</a>'; | |
| 4421 | 4421 | } | 
| 4422 | 4422 | print '</td>'; | 
| 4423 | -            print '<td align="left"><input type="submit" class="button" value="' . $langs->trans("Modify") . '"></td>';
 | |
| 4423 | +            print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
 | |
| 4424 | 4424 | print '</tr></table></form>'; | 
| 4425 | 4425 |          } else {
 | 
| 4426 | 4426 |              if ($selected) {
 | 
| 4427 | - require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; | |
| 4427 | + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; | |
| 4428 | 4428 | $contact = new Contact($this->db); | 
| 4429 | 4429 | $contact->fetch($selected); | 
| 4430 | 4430 | print $contact->getFullName($langs); | 
| @@ -4456,15 +4456,15 @@ discard block | ||
| 4456 | 4456 | |
| 4457 | 4457 | $out = ''; | 
| 4458 | 4458 |          if ($htmlname != "none") {
 | 
| 4459 | - $out .= '<form method="post" action="' . $page . '">'; | |
| 4459 | + $out .= '<form method="post" action="'.$page.'">'; | |
| 4460 | 4460 | $out .= '<input type="hidden" name="action" value="set_thirdparty">'; | 
| 4461 | - $out .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 4461 | + $out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 4462 | 4462 | $out .= $this->select_company($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events); | 
| 4463 | -            $out .= '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
 | |
| 4463 | +            $out .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
 | |
| 4464 | 4464 | $out .= '</form>'; | 
| 4465 | 4465 |          } else {
 | 
| 4466 | 4466 |              if ($selected) {
 | 
| 4467 | - require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; | |
| 4467 | + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; | |
| 4468 | 4468 | $soc = new Societe($this->db); | 
| 4469 | 4469 | $soc->fetch($selected); | 
| 4470 | 4470 | $out .= $soc->getNomUrl($langs); | 
| @@ -4510,17 +4510,17 @@ discard block | ||
| 4510 | 4510 | $out = ''; | 
| 4511 | 4511 | |
| 4512 | 4512 | if ($selected == 'euro' || $selected == 'euros') | 
| 4513 | - $selected = 'EUR'; // Pour compatibilite | |
| 4513 | + $selected = 'EUR'; // Pour compatibilite | |
| 4514 | 4514 | |
| 4515 | - $out .= '<select class="flat maxwidth200onsmartphone minwidth300" name="' . $htmlname . '" id="' . $htmlname . '">'; | |
| 4515 | + $out .= '<select class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'" id="'.$htmlname.'">'; | |
| 4516 | 4516 |          foreach ($langs->cache_currencies as $code_iso => $currency) {
 | 
| 4517 | 4517 |              if ($selected && $selected == $code_iso) {
 | 
| 4518 | - $out .= '<option value="' . $code_iso . '" selected>'; | |
| 4518 | + $out .= '<option value="'.$code_iso.'" selected>'; | |
| 4519 | 4519 |              } else {
 | 
| 4520 | - $out .= '<option value="' . $code_iso . '">'; | |
| 4520 | + $out .= '<option value="'.$code_iso.'">'; | |
| 4521 | 4521 | } | 
| 4522 | 4522 | $out .= $currency['label']; | 
| 4523 | -            $out .= ' (' . $langs->getCurrencySymbol($code_iso) . ')';
 | |
| 4523 | +            $out .= ' ('.$langs->getCurrencySymbol($code_iso).')';
 | |
| 4524 | 4524 | $out .= '</option>'; | 
| 4525 | 4525 | } | 
| 4526 | 4526 | $out .= '</select>'; | 
| @@ -4528,7 +4528,7 @@ discard block | ||
| 4528 | 4528 |              $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
 | 
| 4529 | 4529 | |
| 4530 | 4530 | // Make select dynamic | 
| 4531 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; | |
| 4531 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; | |
| 4532 | 4532 | $out .= ajax_combobox($htmlname); | 
| 4533 | 4533 | |
| 4534 | 4534 | return $out; | 
| @@ -4546,12 +4546,12 @@ discard block | ||
| 4546 | 4546 |      {
 | 
| 4547 | 4547 | global $db, $conf, $langs, $user; | 
| 4548 | 4548 | |
| 4549 | -        $langs->loadCacheCurrencies('');        // Load ->cache_currencies
 | |
| 4549 | +        $langs->loadCacheCurrencies(''); // Load ->cache_currencies
 | |
| 4550 | 4550 | |
| 4551 | 4551 | $TCurrency = array(); | 
| 4552 | 4552 | |
| 4553 | - $sql = 'SELECT code FROM ' . MAIN_DB_PREFIX . 'multicurrency'; | |
| 4554 | -        $sql .= " WHERE entity IN ('" . getEntity('mutlicurrency') . "')";
 | |
| 4553 | + $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency'; | |
| 4554 | +        $sql .= " WHERE entity IN ('".getEntity('mutlicurrency')."')";
 | |
| 4555 | 4555 | $resql = $db->query($sql); | 
| 4556 | 4556 |          if ($resql) {
 | 
| 4557 | 4557 | while ($obj = $db->fetch_object($resql)) | 
| @@ -4559,7 +4559,7 @@ discard block | ||
| 4559 | 4559 | } | 
| 4560 | 4560 | |
| 4561 | 4561 | $out = ''; | 
| 4562 | - $out .= '<select class="flat" name="' . $htmlname . '" id="' . $htmlname . '">'; | |
| 4562 | + $out .= '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">'; | |
| 4563 | 4563 | if ($useempty) | 
| 4564 | 4564 | $out .= '<option value=""></option>'; | 
| 4565 | 4565 | // If company current currency not in table, we add it into list. Should always be available. | 
| @@ -4570,12 +4570,12 @@ discard block | ||
| 4570 | 4570 |              foreach ($langs->cache_currencies as $code_iso => $currency) {
 | 
| 4571 | 4571 |                  if (isset($TCurrency[$code_iso])) {
 | 
| 4572 | 4572 | if (!empty($selected) && $selected == $code_iso) | 
| 4573 | - $out .= '<option value="' . $code_iso . '" selected="selected">'; | |
| 4573 | + $out .= '<option value="'.$code_iso.'" selected="selected">'; | |
| 4574 | 4574 | else | 
| 4575 | - $out .= '<option value="' . $code_iso . '">'; | |
| 4575 | + $out .= '<option value="'.$code_iso.'">'; | |
| 4576 | 4576 | |
| 4577 | 4577 | $out .= $currency['label']; | 
| 4578 | -                    $out .= ' (' . $langs->getCurrencySymbol($code_iso) . ')';
 | |
| 4578 | +                    $out .= ' ('.$langs->getCurrencySymbol($code_iso).')';
 | |
| 4579 | 4579 | $out .= '</option>'; | 
| 4580 | 4580 | } | 
| 4581 | 4581 | } | 
| @@ -4583,7 +4583,7 @@ discard block | ||
| 4583 | 4583 | |
| 4584 | 4584 | $out .= '</select>'; | 
| 4585 | 4585 | // Make select dynamic | 
| 4586 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; | |
| 4586 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; | |
| 4587 | 4587 | $out .= ajax_combobox($htmlname); | 
| 4588 | 4588 | |
| 4589 | 4589 | return $out; | 
| @@ -4603,15 +4603,15 @@ discard block | ||
| 4603 | 4603 | |
| 4604 | 4604 | $num = count($this->cache_vatrates); | 
| 4605 | 4605 | if ($num > 0) | 
| 4606 | - return $num; // Cache already loaded | |
| 4606 | + return $num; // Cache already loaded | |
| 4607 | 4607 | |
| 4608 | 4608 | dol_syslog(__METHOD__, LOG_DEBUG); | 
| 4609 | 4609 | |
| 4610 | 4610 | $sql = "SELECT DISTINCT t.rowid, t.code, t.taux, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.recuperableonly"; | 
| 4611 | - $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c"; | |
| 4611 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; | |
| 4612 | 4612 | $sql .= " WHERE t.fk_pays = c.rowid"; | 
| 4613 | 4613 | $sql .= " AND t.active > 0"; | 
| 4614 | -        $sql .= " AND c.code IN (" . $country_code . ")";
 | |
| 4614 | +        $sql .= " AND c.code IN (".$country_code.")";
 | |
| 4615 | 4615 | $sql .= " ORDER BY t.code ASC, t.taux ASC, t.recuperableonly ASC"; | 
| 4616 | 4616 | |
| 4617 | 4617 | $resql = $this->db->query($sql); | 
| @@ -4629,28 +4629,28 @@ discard block | ||
| 4629 | 4629 | $this->cache_vatrates[$i]['localtax2'] = $obj->localtax2; | 
| 4630 | 4630 | $this->cache_vatrates[$i]['localtax2_type'] = $obj->localtax1_type; | 
| 4631 | 4631 | |
| 4632 | -                    $this->cache_vatrates[$i]['label'] = $obj->taux . '%' . ($obj->code ? ' (' . $obj->code . ')' : '');   // Label must contains only 0-9 , . % or *
 | |
| 4633 | -                    $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
 | |
| 4632 | +                    $this->cache_vatrates[$i]['label'] = $obj->taux.'%'.($obj->code ? ' ('.$obj->code.')' : ''); // Label must contains only 0-9 , . % or *
 | |
| 4633 | +                    $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 | 4634 | $positiverates = ''; | 
| 4635 | 4635 | if ($obj->taux) | 
| 4636 | - $positiverates .= ($positiverates ? '/' : '') . $obj->taux; | |
| 4636 | + $positiverates .= ($positiverates ? '/' : '').$obj->taux; | |
| 4637 | 4637 | if ($obj->localtax1) | 
| 4638 | - $positiverates .= ($positiverates ? '/' : '') . $obj->localtax1; | |
| 4638 | + $positiverates .= ($positiverates ? '/' : '').$obj->localtax1; | |
| 4639 | 4639 | if ($obj->localtax2) | 
| 4640 | - $positiverates .= ($positiverates ? '/' : '') . $obj->localtax2; | |
| 4640 | + $positiverates .= ($positiverates ? '/' : '').$obj->localtax2; | |
| 4641 | 4641 | if (empty($positiverates)) | 
| 4642 | 4642 | $positiverates = '0'; | 
| 4643 | -                    $this->cache_vatrates[$i]['labelpositiverates'] = $positiverates . ($obj->code ? ' (' . $obj->code . ')' : ''); // Must never be used as key, only label
 | |
| 4643 | +                    $this->cache_vatrates[$i]['labelpositiverates'] = $positiverates.($obj->code ? ' ('.$obj->code.')' : ''); // Must never be used as key, only label
 | |
| 4644 | 4644 | } | 
| 4645 | 4645 | |
| 4646 | 4646 | return $num; | 
| 4647 | 4647 | } | 
| 4648 | 4648 |              else {
 | 
| 4649 | -                $this->error = '<font class="error">' . $langs->trans("ErrorNoVATRateDefinedForSellerCountry", $country_code) . '</font>';
 | |
| 4649 | +                $this->error = '<font class="error">'.$langs->trans("ErrorNoVATRateDefinedForSellerCountry", $country_code).'</font>';
 | |
| 4650 | 4650 | return -1; | 
| 4651 | 4651 | } | 
| 4652 | 4652 |          } else {
 | 
| 4653 | - $this->error = '<font class="error">' . $this->db->error() . '</font>'; | |
| 4653 | + $this->error = '<font class="error">'.$this->db->error().'</font>'; | |
| 4654 | 4654 | return -2; | 
| 4655 | 4655 | } | 
| 4656 | 4656 | } | 
| @@ -4699,9 +4699,9 @@ discard block | ||
| 4699 | 4699 | // Check parameters | 
| 4700 | 4700 |          if (is_object($societe_vendeuse) && !$societe_vendeuse->country_code) {
 | 
| 4701 | 4701 |              if ($societe_vendeuse->id == $mysoc->id) {
 | 
| 4702 | -                $return .= '<font class="error">' . $langs->trans("ErrorYourCountryIsNotDefined") . '</div>';
 | |
| 4702 | +                $return .= '<font class="error">'.$langs->trans("ErrorYourCountryIsNotDefined").'</div>';
 | |
| 4703 | 4703 |              } else {
 | 
| 4704 | -                $return .= '<font class="error">' . $langs->trans("ErrorSupplierCountryIsNotDefined") . '</div>';
 | |
| 4704 | +                $return .= '<font class="error">'.$langs->trans("ErrorSupplierCountryIsNotDefined").'</div>';
 | |
| 4705 | 4705 | } | 
| 4706 | 4706 | return $return; | 
| 4707 | 4707 | } | 
| @@ -4712,32 +4712,32 @@ discard block | ||
| 4712 | 4712 | // Define list of countries to use to search VAT rates to show | 
| 4713 | 4713 | // First we defined code_country to use to find list | 
| 4714 | 4714 |          if (is_object($societe_vendeuse)) {
 | 
| 4715 | - $code_country = "'" . $societe_vendeuse->country_code . "'"; | |
| 4715 | + $code_country = "'".$societe_vendeuse->country_code."'"; | |
| 4716 | 4716 |          } else {
 | 
| 4717 | - $code_country = "'" . $mysoc->country_code . "'"; // Pour compatibilite ascendente | |
| 4717 | + $code_country = "'".$mysoc->country_code."'"; // Pour compatibilite ascendente | |
| 4718 | 4718 | } | 
| 4719 | 4719 |          if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) {    // If option to have vat for end customer for services is on
 | 
| 4720 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; | |
| 4720 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; | |
| 4721 | 4721 |              if (!isInEEC($societe_vendeuse) && (!is_object($societe_acheteuse) || (isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany()))) {
 | 
| 4722 | 4722 | // We also add the buyer | 
| 4723 | 4723 |                  if (is_numeric($type)) {
 | 
| 4724 | 4724 |                      if ($type == 1) { // We know product is a service
 | 
| 4725 | - $code_country .= ",'" . $societe_acheteuse->country_code . "'"; | |
| 4725 | + $code_country .= ",'".$societe_acheteuse->country_code."'"; | |
| 4726 | 4726 | } | 
| 4727 | 4727 |                  } else if (!$idprod) {  // We don't know type of product
 | 
| 4728 | - $code_country .= ",'" . $societe_acheteuse->country_code . "'"; | |
| 4728 | + $code_country .= ",'".$societe_acheteuse->country_code."'"; | |
| 4729 | 4729 |                  } else {
 | 
| 4730 | 4730 | $prodstatic = new Product($this->db); | 
| 4731 | 4731 | $prodstatic->fetch($idprod); | 
| 4732 | 4732 |                      if ($prodstatic->type == Product::TYPE_SERVICE) {   // We know product is a service
 | 
| 4733 | - $code_country .= ",'" . $societe_acheteuse->country_code . "'"; | |
| 4733 | + $code_country .= ",'".$societe_acheteuse->country_code."'"; | |
| 4734 | 4734 | } | 
| 4735 | 4735 | } | 
| 4736 | 4736 | } | 
| 4737 | 4737 | } | 
| 4738 | 4738 | |
| 4739 | 4739 | // Now we get list | 
| 4740 | - $num = $this->load_cache_vatrates($code_country); // If no vat defined, return -1 with message into this->error | |
| 4740 | + $num = $this->load_cache_vatrates($code_country); // If no vat defined, return -1 with message into this->error | |
| 4741 | 4741 | |
| 4742 | 4742 |          if ($num > 0) {
 | 
| 4743 | 4743 | // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '') | 
| @@ -4768,13 +4768,13 @@ discard block | ||
| 4768 | 4768 |              if (is_object($societe_vendeuse) && $societe_vendeuse->id == $mysoc->id && $societe_vendeuse->tva_assuj == "0") {
 | 
| 4769 | 4769 | // Override/enable VAT for expense report regardless of global setting - needed if expense report used for business expenses | 
| 4770 | 4770 |                  if (empty($conf->global->OVERRIDE_VAT_FOR_EXPENSE_REPORT)) {
 | 
| 4771 | -                    $title = ' title="' . $langs->trans('VATIsNotUsed') . '"';
 | |
| 4771 | +                    $title = ' title="'.$langs->trans('VATIsNotUsed').'"';
 | |
| 4772 | 4772 | $disabled = true; | 
| 4773 | 4773 | } | 
| 4774 | 4774 | } | 
| 4775 | 4775 | |
| 4776 | 4776 | if (!$options_only) | 
| 4777 | - $return .= '<select class="flat minwidth75imp" id="' . $htmlname . '" name="' . $htmlname . '"' . ($disabled ? ' disabled' : '') . $title . '>'; | |
| 4777 | + $return .= '<select class="flat minwidth75imp" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled ? ' disabled' : '').$title.'>'; | |
| 4778 | 4778 | |
| 4779 | 4779 | $selectedfound = false; | 
| 4780 | 4780 |              foreach ($this->cache_vatrates as $rate) {
 | 
| @@ -4786,11 +4786,11 @@ discard block | ||
| 4786 | 4786 | $key = $rate['txtva']; | 
| 4787 | 4787 | $key .= $rate['nprtva'] ? '*' : ''; | 
| 4788 | 4788 | if ($mode > 0 && $rate['code']) | 
| 4789 | -                    $key .= ' (' . $rate['code'] . ')';
 | |
| 4789 | +                    $key .= ' ('.$rate['code'].')';
 | |
| 4790 | 4790 | if ($mode < 0) | 
| 4791 | 4791 | $key = $rate['rowid']; | 
| 4792 | 4792 | |
| 4793 | - $return .= '<option value="' . $key . '"'; | |
| 4793 | + $return .= '<option value="'.$key.'"'; | |
| 4794 | 4794 |                  if (!$selectedfound) {
 | 
| 4795 | 4795 |                      if ($defaultcode) { // If defaultcode is defined, we used it in priority to select combo option instead of using rate+npr flag
 | 
| 4796 | 4796 |                          if ($defaultcode == $rate['code']) {
 | 
| @@ -4810,7 +4810,7 @@ discard block | ||
| 4810 | 4810 | $return .= vatrate($rate['label']); | 
| 4811 | 4811 | } | 
| 4812 | 4812 | //$return.=($rate['code']?' '.$rate['code']:''); | 
| 4813 | - $return .= (empty($rate['code']) && $rate['nprtva']) ? ' *' : ''; // We show the * (old behaviour only if new vat code is not used) | |
| 4813 | + $return .= (empty($rate['code']) && $rate['nprtva']) ? ' *' : ''; // We show the * (old behaviour only if new vat code is not used) | |
| 4814 | 4814 | |
| 4815 | 4815 | $return .= '</option>'; | 
| 4816 | 4816 | } | 
| @@ -4909,7 +4909,7 @@ discard block | ||
| 4909 | 4909 | $orig_set_time = $set_time; | 
| 4910 | 4910 | |
| 4911 | 4911 |          if ($set_time === '' && $emptydate == 0) {
 | 
| 4912 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; | |
| 4912 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; | |
| 4913 | 4913 |              $set_time = dol_now('tzuser') - (getServerTimeZoneInt('now') * 3600); // set_time must be relative to PHP server timezone
 | 
| 4914 | 4914 | } | 
| 4915 | 4915 | |
| @@ -4962,36 +4962,36 @@ discard block | ||
| 4962 | 4962 | //print "e".$set_time." t ".$conf->format_date_short; | 
| 4963 | 4963 |                  if (strval($set_time) != '' && $set_time != -1) {
 | 
| 4964 | 4964 | //$formated_date=dol_print_date($set_time,$conf->format_date_short); | 
| 4965 | -                    $formated_date = dol_print_date($set_time, $langs->trans("FormatDateShortInput"));  // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
 | |
| 4965 | +                    $formated_date = dol_print_date($set_time, $langs->trans("FormatDateShortInput")); // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
 | |
| 4966 | 4966 | } | 
| 4967 | 4967 | |
| 4968 | 4968 | // Calendrier popup version eldy | 
| 4969 | 4969 |                  if ($usecalendar == "eldy") {
 | 
| 4970 | 4970 | // Zone de saisie manuelle de la date | 
| 4971 | - $retstring .= '<input id="' . $prefix . '" name="' . $prefix . '" type="text" class="maxwidth75" maxlength="11" value="' . $formated_date . '"'; | |
| 4971 | + $retstring .= '<input id="'.$prefix.'" name="'.$prefix.'" type="text" class="maxwidth75" maxlength="11" value="'.$formated_date.'"'; | |
| 4972 | 4972 | $retstring .= ($disabled ? ' disabled' : ''); | 
| 4973 | -                    $retstring .= ' onChange="dpChangeDay(\'' . $prefix . '\',\'' . $langs->trans("FormatDateShortJavaInput") . '\'); "';  // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
 | |
| 4973 | +                    $retstring .= ' onChange="dpChangeDay(\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
 | |
| 4974 | 4974 | $retstring .= '>'; | 
| 4975 | 4975 | |
| 4976 | 4976 | // Icone calendrier | 
| 4977 | 4977 |                      if (!$disabled) {
 | 
| 4978 | - $retstring .= '<button id="' . $prefix . 'Button" type="button" class="dpInvisibleButtons"'; | |
| 4979 | - $base = DOL_URL_ROOT . '/core/'; | |
| 4980 | -                        $retstring .= ' onClick="showDP(\'' . $base . '\',\'' . $prefix . '\',\'' . $langs->trans("FormatDateShortJavaInput") . '\',\'' . $langs->defaultlang . '\');"';
 | |
| 4981 | -                        $retstring .= '>' . img_object($langs->trans("SelectDate"), 'calendarday', 'class="datecallink"') . '</button>';
 | |
| 4978 | + $retstring .= '<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons"'; | |
| 4979 | + $base = DOL_URL_ROOT.'/core/'; | |
| 4980 | +                        $retstring .= ' onClick="showDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\',\''.$langs->defaultlang.'\');"';
 | |
| 4981 | +                        $retstring .= '>'.img_object($langs->trans("SelectDate"), 'calendarday', 'class="datecallink"').'</button>';
 | |
| 4982 | 4982 | } else | 
| 4983 | -                        $retstring .= '<button id="' . $prefix . 'Button" type="button" class="dpInvisibleButtons">' . img_object($langs->trans("Disabled"), 'calendarday', 'class="datecallink"') . '</button>';
 | |
| 4983 | +                        $retstring .= '<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons">'.img_object($langs->trans("Disabled"), 'calendarday', 'class="datecallink"').'</button>';
 | |
| 4984 | 4984 | |
| 4985 | - $retstring .= '<input type="hidden" id="' . $prefix . 'day" name="' . $prefix . 'day" value="' . $sday . '">' . "\n"; | |
| 4986 | - $retstring .= '<input type="hidden" id="' . $prefix . 'month" name="' . $prefix . 'month" value="' . $smonth . '">' . "\n"; | |
| 4987 | - $retstring .= '<input type="hidden" id="' . $prefix . 'year" name="' . $prefix . 'year" value="' . $syear . '">' . "\n"; | |
| 4985 | + $retstring .= '<input type="hidden" id="'.$prefix.'day" name="'.$prefix.'day" value="'.$sday.'">'."\n"; | |
| 4986 | + $retstring .= '<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n"; | |
| 4987 | + $retstring .= '<input type="hidden" id="'.$prefix.'year" name="'.$prefix.'year" value="'.$syear.'">'."\n"; | |
| 4988 | 4988 | } | 
| 4989 | 4989 |                  elseif ($usecalendar == 'jquery') {
 | 
| 4990 | 4990 |                      if (!$disabled) {
 | 
| 4991 | 4991 | // Output javascript for datepicker | 
| 4992 | 4992 | $retstring .= "<script type='text/javascript'>"; | 
| 4993 | -                        $retstring .= "$(function(){ $('#" . $prefix . "').datepicker({
 | |
| 4994 | -							dateFormat: '" . $langs->trans("FormatDateShortJQueryInput") . "',
 | |
| 4993 | +                        $retstring .= "$(function(){ $('#".$prefix."').datepicker({
 | |
| 4994 | +							dateFormat: '" . $langs->trans("FormatDateShortJQueryInput")."',
 | |
| 4995 | 4995 | autoclose: true, | 
| 4996 | 4996 | todayHighlight: true,"; | 
| 4997 | 4997 |                          if (!empty($conf->dol_use_jmobile)) {
 | 
| @@ -5014,7 +5014,7 @@ discard block | ||
| 5014 | 5014 | */ | 
| 5015 | 5015 | $retstring .= " | 
| 5016 | 5016 | showOn: 'button', | 
| 5017 | - buttonImage: '" . DOL_BASE_URI . "/theme/" . $conf->theme . "/img/object_calendarday.png', | |
| 5017 | + buttonImage: '" . DOL_BASE_URI."/theme/".$conf->theme."/img/object_calendarday.png', | |
| 5018 | 5018 | buttonImageOnly: true"; | 
| 5019 | 5019 | } | 
| 5020 | 5020 | $retstring .= " | 
| @@ -5024,9 +5024,9 @@ discard block | ||
| 5024 | 5024 | |
| 5025 | 5025 | // Zone de saisie manuelle de la date | 
| 5026 | 5026 | $retstring .= '<div class="nowrap inline-block">'; | 
| 5027 | - $retstring .= '<input id="' . $prefix . '" name="' . $prefix . '" type="text" class="maxwidth75" maxlength="11" value="' . $formated_date . '"'; | |
| 5027 | + $retstring .= '<input id="'.$prefix.'" name="'.$prefix.'" type="text" class="maxwidth75" maxlength="11" value="'.$formated_date.'"'; | |
| 5028 | 5028 | $retstring .= ($disabled ? ' disabled' : ''); | 
| 5029 | -                    $retstring .= ' onChange="dpChangeDay(\'' . $prefix . '\',\'' . $langs->trans("FormatDateShortJavaInput") . '\'); "';  // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
 | |
| 5029 | +                    $retstring .= ' onChange="dpChangeDay(\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
 | |
| 5030 | 5030 | $retstring .= '>'; | 
| 5031 | 5031 | |
| 5032 | 5032 | // Icone calendrier | 
| @@ -5041,13 +5041,13 @@ discard block | ||
| 5041 | 5041 | $retstring.='});'; | 
| 5042 | 5042 | $retstring.="</script>"; */ | 
| 5043 | 5043 |                      } else {
 | 
| 5044 | -                        $retstring .= '<button id="' . $prefix . 'Button" type="button" class="dpInvisibleButtons">' . img_object($langs->trans("Disabled"), 'calendarday', 'class="datecallink"') . '</button>';
 | |
| 5044 | +                        $retstring .= '<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons">'.img_object($langs->trans("Disabled"), 'calendarday', 'class="datecallink"').'</button>';
 | |
| 5045 | 5045 | } | 
| 5046 | 5046 | |
| 5047 | 5047 | $retstring .= '</div>'; | 
| 5048 | - $retstring .= '<input type="hidden" id="' . $prefix . 'day" name="' . $prefix . 'day" value="' . $sday . '">' . "\n"; | |
| 5049 | - $retstring .= '<input type="hidden" id="' . $prefix . 'month" name="' . $prefix . 'month" value="' . $smonth . '">' . "\n"; | |
| 5050 | - $retstring .= '<input type="hidden" id="' . $prefix . 'year" name="' . $prefix . 'year" value="' . $syear . '">' . "\n"; | |
| 5048 | + $retstring .= '<input type="hidden" id="'.$prefix.'day" name="'.$prefix.'day" value="'.$sday.'">'."\n"; | |
| 5049 | + $retstring .= '<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n"; | |
| 5050 | + $retstring .= '<input type="hidden" id="'.$prefix.'year" name="'.$prefix.'year" value="'.$syear.'">'."\n"; | |
| 5051 | 5051 |                  } else {
 | 
| 5052 | 5052 | $retstring .= "Bad value of MAIN_POPUP_CALENDAR"; | 
| 5053 | 5053 | } | 
| @@ -5056,26 +5056,26 @@ discard block | ||
| 5056 | 5056 |              else {
 | 
| 5057 | 5057 | //$retstring.='<div class="inline-block">'; | 
| 5058 | 5058 | // Day | 
| 5059 | - $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50imp" id="' . $prefix . 'day" name="' . $prefix . 'day">'; | |
| 5059 | + $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth50imp" id="'.$prefix.'day" name="'.$prefix.'day">'; | |
| 5060 | 5060 | |
| 5061 | 5061 |                  if ($emptydate || $set_time == -1) {
 | 
| 5062 | 5062 | $retstring .= '<option value="0" selected> </option>'; | 
| 5063 | 5063 | } | 
| 5064 | 5064 | |
| 5065 | 5065 |                  for ($day = 1; $day <= 31; $day++) {
 | 
| 5066 | - $retstring .= '<option value="' . $day . '"' . ($day == $sday ? ' selected' : '') . '>' . $day . '</option>'; | |
| 5066 | + $retstring .= '<option value="'.$day.'"'.($day == $sday ? ' selected' : '').'>'.$day.'</option>'; | |
| 5067 | 5067 | } | 
| 5068 | 5068 | |
| 5069 | 5069 | $retstring .= "</select>"; | 
| 5070 | 5070 | |
| 5071 | - $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth75imp" id="' . $prefix . 'month" name="' . $prefix . 'month">'; | |
| 5071 | + $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth75imp" id="'.$prefix.'month" name="'.$prefix.'month">'; | |
| 5072 | 5072 |                  if ($emptydate || $set_time == -1) {
 | 
| 5073 | 5073 | $retstring .= '<option value="0" selected> </option>'; | 
| 5074 | 5074 | } | 
| 5075 | 5075 | |
| 5076 | 5076 | // Month | 
| 5077 | 5077 |                  for ($month = 1; $month <= 12; $month++) {
 | 
| 5078 | - $retstring .= '<option value="' . $month . '"' . ($month == $smonth ? ' selected' : '') . '>'; | |
| 5078 | + $retstring .= '<option value="'.$month.'"'.($month == $smonth ? ' selected' : '').'>'; | |
| 5079 | 5079 | $retstring .= dol_print_date(mktime(12, 0, 0, $month, 1, 2000), "%b"); | 
| 5080 | 5080 | $retstring .= "</option>"; | 
| 5081 | 5081 | } | 
| @@ -5083,12 +5083,12 @@ discard block | ||
| 5083 | 5083 | |
| 5084 | 5084 | // Year | 
| 5085 | 5085 |                  if ($emptydate || $set_time == -1) {
 | 
| 5086 | -                    $retstring .= '<input' . ($disabled ? ' disabled' : '') . ' placeholder="' . dol_escape_htmltag($langs->trans("Year")) . '" class="flat maxwidth50imp valignmiddle" type="number" min="0" max="3000" maxlength="4" id="' . $prefix . 'year" name="' . $prefix . 'year" value="' . $syear . '">';
 | |
| 5086 | +                    $retstring .= '<input'.($disabled ? ' disabled' : '').' placeholder="'.dol_escape_htmltag($langs->trans("Year")).'" class="flat maxwidth50imp valignmiddle" type="number" min="0" max="3000" maxlength="4" id="'.$prefix.'year" name="'.$prefix.'year" value="'.$syear.'">';
 | |
| 5087 | 5087 |                  } else {
 | 
| 5088 | - $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth75imp" id="' . $prefix . 'year" name="' . $prefix . 'year">'; | |
| 5088 | + $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth75imp" id="'.$prefix.'year" name="'.$prefix.'year">'; | |
| 5089 | 5089 | |
| 5090 | 5090 |                      for ($year = $syear - 10; $year < $syear + 10; $year++) {
 | 
| 5091 | - $retstring .= '<option value="' . $year . '"' . ($year == $syear ? ' selected' : '') . '>' . $year . '</option>'; | |
| 5091 | + $retstring .= '<option value="'.$year.'"'.($year == $syear ? ' selected' : '').'>'.$year.'</option>'; | |
| 5092 | 5092 | } | 
| 5093 | 5093 | $retstring .= "</select>\n"; | 
| 5094 | 5094 | } | 
| @@ -5101,13 +5101,13 @@ discard block | ||
| 5101 | 5101 | |
| 5102 | 5102 |          if ($h) {
 | 
| 5103 | 5103 | // Show hour | 
| 5104 | - $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50 ' . ($fullday ? $fullday . 'hour' : '') . '" id="' . $prefix . 'hour" name="' . $prefix . 'hour">'; | |
| 5104 | + $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth50 '.($fullday ? $fullday.'hour' : '').'" id="'.$prefix.'hour" name="'.$prefix.'hour">'; | |
| 5105 | 5105 | if ($emptyhours) | 
| 5106 | 5106 | $retstring .= '<option value="-1"> </option>'; | 
| 5107 | 5107 |              for ($hour = 0; $hour < 24; $hour++) {
 | 
| 5108 | 5108 | if (strlen($hour) < 2) | 
| 5109 | - $hour = "0" . $hour; | |
| 5110 | - $retstring .= '<option value="' . $hour . '"' . (($hour == $shour) ? ' selected' : '') . '>' . $hour . (empty($conf->dol_optimize_smallscreen) ? '' : 'H') . '</option>'; | |
| 5109 | + $hour = "0".$hour; | |
| 5110 | + $retstring .= '<option value="'.$hour.'"'.(($hour == $shour) ? ' selected' : '').'>'.$hour.(empty($conf->dol_optimize_smallscreen) ? '' : 'H').'</option>'; | |
| 5111 | 5111 | } | 
| 5112 | 5112 | $retstring .= '</select>'; | 
| 5113 | 5113 | if ($m && empty($conf->dol_optimize_smallscreen)) | 
| @@ -5116,17 +5116,17 @@ discard block | ||
| 5116 | 5116 | |
| 5117 | 5117 |          if ($m) {
 | 
| 5118 | 5118 | // Show minutes | 
| 5119 | - $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50 ' . ($fullday ? $fullday . 'min' : '') . '" id="' . $prefix . 'min" name="' . $prefix . 'min">'; | |
| 5119 | + $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth50 '.($fullday ? $fullday.'min' : '').'" id="'.$prefix.'min" name="'.$prefix.'min">'; | |
| 5120 | 5120 | if ($emptyhours) | 
| 5121 | 5121 | $retstring .= '<option value="-1"> </option>'; | 
| 5122 | 5122 |              for ($min = 0; $min < 60; $min++) {
 | 
| 5123 | 5123 | if (strlen($min) < 2) | 
| 5124 | - $min = "0" . $min; | |
| 5125 | - $retstring .= '<option value="' . $min . '"' . (($min == $smin) ? ' selected' : '') . '>' . $min . (empty($conf->dol_optimize_smallscreen) ? '' : '') . '</option>'; | |
| 5124 | + $min = "0".$min; | |
| 5125 | + $retstring .= '<option value="'.$min.'"'.(($min == $smin) ? ' selected' : '').'>'.$min.(empty($conf->dol_optimize_smallscreen) ? '' : '').'</option>'; | |
| 5126 | 5126 | } | 
| 5127 | 5127 | $retstring .= '</select>'; | 
| 5128 | 5128 | |
| 5129 | - $retstring .= '<input type="hidden" name="' . $prefix . 'sec" value="' . $ssec . '">'; | |
| 5129 | + $retstring .= '<input type="hidden" name="'.$prefix.'sec" value="'.$ssec.'">'; | |
| 5130 | 5130 | } | 
| 5131 | 5131 | |
| 5132 | 5132 | // Add a "Now" link | 
| @@ -5135,10 +5135,10 @@ discard block | ||
| 5135 | 5135 | $reset_scripts = ""; | 
| 5136 | 5136 | |
| 5137 | 5137 | // Generate the date part, depending on the use or not of the javascript calendar | 
| 5138 | - $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date(dol_now(), 'day') . '\');'; | |
| 5139 | - $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date(dol_now(), '%d') . '\');'; | |
| 5140 | - $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date(dol_now(), '%m') . '\');'; | |
| 5141 | - $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date(dol_now(), '%Y') . '\');'; | |
| 5138 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day').'\');'; | |
| 5139 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d').'\');'; | |
| 5140 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m').'\');'; | |
| 5141 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y').'\');'; | |
| 5142 | 5142 | /* if ($usecalendar == "eldy") | 
| 5143 | 5143 |                {
 | 
| 5144 | 5144 | $base=DOL_URL_ROOT.'/core/'; | 
| @@ -5155,7 +5155,7 @@ discard block | ||
| 5155 | 5155 | if ($fullday) | 
| 5156 | 5156 |                      $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
 | 
| 5157 | 5157 | //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); '; | 
| 5158 | - $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(\'' . dol_print_date(dol_now(), '%H') . '\');'; | |
| 5158 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H').'\');'; | |
| 5159 | 5159 | if ($fullday) | 
| 5160 | 5160 | $reset_scripts .= ' } '; | 
| 5161 | 5161 | } | 
| @@ -5164,13 +5164,13 @@ discard block | ||
| 5164 | 5164 | if ($fullday) | 
| 5165 | 5165 |                      $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
 | 
| 5166 | 5166 | //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); '; | 
| 5167 | - $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(\'' . dol_print_date(dol_now(), '%M') . '\');'; | |
| 5167 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M').'\');'; | |
| 5168 | 5168 | if ($fullday) | 
| 5169 | 5169 | $reset_scripts .= ' } '; | 
| 5170 | 5170 | } | 
| 5171 | 5171 | // If reset_scripts is not empty, print the link with the reset_scripts in the onClick | 
| 5172 | 5172 |              if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) {
 | 
| 5173 | - $retstring .= ' <button class="dpInvisibleButtons datenowlink" id="' . $prefix . 'ButtonNow" type="button" name="_useless" value="now" onClick="' . $reset_scripts . '">'; | |
| 5173 | + $retstring .= ' <button class="dpInvisibleButtons datenowlink" id="'.$prefix.'ButtonNow" type="button" name="_useless" value="now" onClick="'.$reset_scripts.'">'; | |
| 5174 | 5174 |                  $retstring .= $langs->trans("Now");
 | 
| 5175 | 5175 | $retstring .= '</button> '; | 
| 5176 | 5176 | } | 
| @@ -5182,15 +5182,15 @@ discard block | ||
| 5182 | 5182 | $reset_scripts = ""; | 
| 5183 | 5183 | |
| 5184 | 5184 | // Generate the date part, depending on the use or not of the javascript calendar | 
| 5185 | - $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date(dol_now(), 'day') . '\');'; | |
| 5186 | - $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date(dol_now(), '%d') . '\');'; | |
| 5187 | - $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date(dol_now(), '%m') . '\');'; | |
| 5188 | - $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date(dol_now(), '%Y') . '\');'; | |
| 5185 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day').'\');'; | |
| 5186 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d').'\');'; | |
| 5187 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m').'\');'; | |
| 5188 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y').'\');'; | |
| 5189 | 5189 | // Update the hour part | 
| 5190 | 5190 |              if ($h) {
 | 
| 5191 | 5191 | if ($fullday) | 
| 5192 | 5192 |                      $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
 | 
| 5193 | - $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(\'' . dol_print_date(dol_now(), '%H') . '\');'; | |
| 5193 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H').'\');'; | |
| 5194 | 5194 | if ($fullday) | 
| 5195 | 5195 | $reset_scripts .= ' } '; | 
| 5196 | 5196 | } | 
| @@ -5198,13 +5198,13 @@ discard block | ||
| 5198 | 5198 |              if ($m) {
 | 
| 5199 | 5199 | if ($fullday) | 
| 5200 | 5200 |                      $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
 | 
| 5201 | - $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(\'' . dol_print_date(dol_now(), '%M') . '\');'; | |
| 5201 | + $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M').'\');'; | |
| 5202 | 5202 | if ($fullday) | 
| 5203 | 5203 | $reset_scripts .= ' } '; | 
| 5204 | 5204 | } | 
| 5205 | 5205 | // If reset_scripts is not empty, print the link with the reset_scripts in the onClick | 
| 5206 | 5206 |              if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) {
 | 
| 5207 | - $retstring .= ' <button class="dpInvisibleButtons datenowlink" id="' . $prefix . 'ButtonPlusOne" type="button" name="_useless2" value="plusone" onClick="' . $reset_scripts . '">'; | |
| 5207 | + $retstring .= ' <button class="dpInvisibleButtons datenowlink" id="'.$prefix.'ButtonPlusOne" type="button" name="_useless2" value="plusone" onClick="'.$reset_scripts.'">'; | |
| 5208 | 5208 |                  $retstring .= $langs->trans("DateStartPlusOne");
 | 
| 5209 | 5209 | $retstring .= '</button> '; | 
| 5210 | 5210 | } | 
| @@ -5213,7 +5213,7 @@ discard block | ||
| 5213 | 5213 | // Add a "Plus one hour" link | 
| 5214 | 5214 |          if ($conf->use_javascript_ajax && $adddateof) {
 | 
| 5215 | 5215 | $tmparray = dol_getdate($adddateof); | 
| 5216 | -            $retstring .= ' - <button class="dpInvisibleButtons datenowlink" id="dateofinvoice" type="button" name="_dateofinvoice" value="now" onclick="jQuery(\'#re\').val(\'' . dol_print_date($adddateof, 'day') . '\');jQuery(\'#reday\').val(\'' . $tmparray['mday'] . '\');jQuery(\'#remonth\').val(\'' . $tmparray['mon'] . '\');jQuery(\'#reyear\').val(\'' . $tmparray['year'] . '\');">' . $langs->trans("DateInvoice") . '</a>';
 | |
| 5216 | +            $retstring .= ' - <button class="dpInvisibleButtons datenowlink" id="dateofinvoice" type="button" name="_dateofinvoice" value="now" onclick="jQuery(\'#re\').val(\''.dol_print_date($adddateof, 'day').'\');jQuery(\'#reday\').val(\''.$tmparray['mday'].'\');jQuery(\'#remonth\').val(\''.$tmparray['mon'].'\');jQuery(\'#reyear\').val(\''.$tmparray['year'].'\');">'.$langs->trans("DateInvoice").'</a>';
 | |
| 5217 | 5217 | } | 
| 5218 | 5218 | |
| 5219 | 5219 | return $retstring; | 
| @@ -5245,29 +5245,29 @@ discard block | ||
| 5245 | 5245 | |
| 5246 | 5246 | // Hours | 
| 5247 | 5247 |          if ($iSecond != '') {
 | 
| 5248 | - require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; | |
| 5248 | + require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; | |
| 5249 | 5249 | |
| 5250 | 5250 | $hourSelected = convertSecondToTime($iSecond, 'allhour'); | 
| 5251 | 5251 | $minSelected = convertSecondToTime($iSecond, 'min'); | 
| 5252 | 5252 | } | 
| 5253 | 5253 | |
| 5254 | 5254 |          if ($typehour == 'select') {
 | 
| 5255 | - $retstring .= '<select class="flat" id="select_' . $prefix . 'hour" name="' . $prefix . 'hour"' . ($disabled ? ' disabled' : '') . '>'; | |
| 5255 | + $retstring .= '<select class="flat" id="select_'.$prefix.'hour" name="'.$prefix.'hour"'.($disabled ? ' disabled' : '').'>'; | |
| 5256 | 5256 |              for ($hour = 0; $hour < 25; $hour++) { // For a duration, we allow 24 hours
 | 
| 5257 | - $retstring .= '<option value="' . $hour . '"'; | |
| 5257 | + $retstring .= '<option value="'.$hour.'"'; | |
| 5258 | 5258 |                  if ($hourSelected == $hour) {
 | 
| 5259 | 5259 | $retstring .= " selected"; | 
| 5260 | 5260 | } | 
| 5261 | - $retstring .= ">" . $hour . "</option>"; | |
| 5261 | + $retstring .= ">".$hour."</option>"; | |
| 5262 | 5262 | } | 
| 5263 | 5263 | $retstring .= "</select>"; | 
| 5264 | 5264 |          } elseif ($typehour == 'text' || $typehour == 'textselect') {
 | 
| 5265 | -            $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) : '') . '">';
 | |
| 5265 | +            $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 | 5266 | } else | 
| 5267 | 5267 | return 'BadValueForParameterTypeHour'; | 
| 5268 | 5268 | |
| 5269 | 5269 | if ($typehour != 'text') | 
| 5270 | -            $retstring .= ' ' . $langs->trans('HourShort');
 | |
| 5270 | +            $retstring .= ' '.$langs->trans('HourShort');
 | |
| 5271 | 5271 | else | 
| 5272 | 5272 | $retstring .= '<span class="hideonsmartphone">:</span>'; | 
| 5273 | 5273 | |
| @@ -5278,21 +5278,21 @@ discard block | ||
| 5278 | 5278 | $retstring .= '<span class="hideonsmartphone"> </span>'; | 
| 5279 | 5279 | |
| 5280 | 5280 |          if ($typehour == 'select' || $typehour == 'textselect') {
 | 
| 5281 | - $retstring .= '<select class="flat" id="select_' . $prefix . 'min" name="' . $prefix . 'min"' . ($disabled ? ' disabled' : '') . '>'; | |
| 5281 | + $retstring .= '<select class="flat" id="select_'.$prefix.'min" name="'.$prefix.'min"'.($disabled ? ' disabled' : '').'>'; | |
| 5282 | 5282 |              for ($min = 0; $min <= 55; $min = $min + 5) {
 | 
| 5283 | - $retstring .= '<option value="' . $min . '"'; | |
| 5283 | + $retstring .= '<option value="'.$min.'"'; | |
| 5284 | 5284 | if ($minSelected == $min) | 
| 5285 | 5285 | $retstring .= ' selected'; | 
| 5286 | - $retstring .= '>' . $min . '</option>'; | |
| 5286 | + $retstring .= '>'.$min.'</option>'; | |
| 5287 | 5287 | } | 
| 5288 | 5288 | $retstring .= "</select>"; | 
| 5289 | 5289 | } | 
| 5290 | 5290 |          elseif ($typehour == 'text') {
 | 
| 5291 | -            $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) : '') . '">';
 | |
| 5291 | +            $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 | 5292 | } | 
| 5293 | 5293 | |
| 5294 | 5294 | if ($typehour != 'text') | 
| 5295 | -            $retstring .= ' ' . $langs->trans('MinuteShort');
 | |
| 5295 | +            $retstring .= ' '.$langs->trans('MinuteShort');
 | |
| 5296 | 5296 | |
| 5297 | 5297 | //$retstring.=" "; | 
| 5298 | 5298 | |
| @@ -5335,30 +5335,30 @@ discard block | ||
| 5335 | 5335 | } | 
| 5336 | 5336 | } | 
| 5337 | 5337 |          if (!is_object($objecttmp)) {
 | 
| 5338 | -            dol_syslog('Error bad setup of type for field ' . $InfoFieldList, LOG_WARNING);
 | |
| 5339 | -            return 'Error bad setup of type for field ' . join(',', $InfoFieldList);
 | |
| 5338 | +            dol_syslog('Error bad setup of type for field '.$InfoFieldList, LOG_WARNING);
 | |
| 5339 | +            return 'Error bad setup of type for field '.join(',', $InfoFieldList);
 | |
| 5340 | 5340 | } | 
| 5341 | 5341 | |
| 5342 | 5342 | $prefixforautocompletemode = $objecttmp->element; | 
| 5343 | 5343 | if ($prefixforautocompletemode == 'societe') | 
| 5344 | 5344 | $prefixforautocompletemode = 'company'; | 
| 5345 | - $confkeyforautocompletemode = strtoupper($prefixforautocompletemode) . '_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT | |
| 5345 | + $confkeyforautocompletemode = strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT | |
| 5346 | 5346 | |
| 5347 | - dol_syslog(get_class($this) . "::selectForForms", LOG_DEBUG); | |
| 5347 | + dol_syslog(get_class($this)."::selectForForms", LOG_DEBUG); | |
| 5348 | 5348 | |
| 5349 | 5349 | $out = ''; | 
| 5350 | 5350 |          if (!empty($conf->use_javascript_ajax) && !empty($conf->global->$confkeyforautocompletemode) && !$forcecombo) {
 | 
| 5351 | - $objectdesc = $classname . ':' . $classpath; | |
| 5352 | - $urlforajaxcall = DOL_URL_ROOT . '/core/ajax/selectobject.php'; | |
| 5351 | + $objectdesc = $classname.':'.$classpath; | |
| 5352 | + $urlforajaxcall = DOL_URL_ROOT.'/core/ajax/selectobject.php'; | |
| 5353 | 5353 | //if ($objecttmp->element == 'societe') $urlforajaxcall = DOL_URL_ROOT.'/societe/ajax/company.php'; | 
| 5354 | 5354 | // No immediate load of all database | 
| 5355 | - $urloption = 'htmlname=' . $htmlname . '&outjson=1&objectdesc=' . $objectdesc . ($moreparams ? $moreparams : ''); | |
| 5355 | + $urloption = 'htmlname='.$htmlname.'&outjson=1&objectdesc='.$objectdesc.($moreparams ? $moreparams : ''); | |
| 5356 | 5356 | // Activate the auto complete using ajax call. | 
| 5357 | 5357 | $out .= ajax_autocompleter($preselectedvalue, $htmlname, $urlforajaxcall, $urloption, $conf->global->$confkeyforautocompletemode, 0, array()); | 
| 5358 | 5358 |              $out .= '<style type="text/css">.ui-autocomplete { z-index: 250; }</style>';
 | 
| 5359 | 5359 | if ($placeholder) | 
| 5360 | - $placeholder = ' placeholder="' . $placeholder . '"'; | |
| 5361 | - $out .= '<input type="text" class="' . $morecss . '" name="search_' . $htmlname . '" id="search_' . $htmlname . '" value="' . $preselectedvalue . '"' . $placeholder . ' />'; | |
| 5360 | + $placeholder = ' placeholder="'.$placeholder.'"'; | |
| 5361 | + $out .= '<input type="text" class="'.$morecss.'" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$preselectedvalue.'"'.$placeholder.' />'; | |
| 5362 | 5362 | } | 
| 5363 | 5363 |          else {
 | 
| 5364 | 5364 | // Immediate load of all database | 
| @@ -5392,14 +5392,14 @@ discard block | ||
| 5392 | 5392 | $prefixforautocompletemode = $objecttmp->element; | 
| 5393 | 5393 | if ($prefixforautocompletemode == 'societe') | 
| 5394 | 5394 | $prefixforautocompletemode = 'company'; | 
| 5395 | - $confkeyforautocompletemode = strtoupper($prefixforautocompletemode) . '_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT | |
| 5395 | + $confkeyforautocompletemode = strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT | |
| 5396 | 5396 | |
| 5397 | 5397 | $fieldstoshow = 't.ref'; | 
| 5398 | 5398 |          if (!empty($objecttmp->fields)) { // For object that declare it, it is better to use declared fields ( like societe, contact, ...)
 | 
| 5399 | 5399 | $tmpfieldstoshow = ''; | 
| 5400 | 5400 |              foreach ($objecttmp->fields as $key => $val) {
 | 
| 5401 | 5401 | if ($val['showoncombobox']) | 
| 5402 | - $tmpfieldstoshow .= ($tmpfieldstoshow ? ',' : '') . 't.' . $key; | |
| 5402 | + $tmpfieldstoshow .= ($tmpfieldstoshow ? ',' : '').'t.'.$key; | |
| 5403 | 5403 | } | 
| 5404 | 5404 | if ($tmpfieldstoshow) | 
| 5405 | 5405 | $fieldstoshow = $tmpfieldstoshow; | 
| @@ -5411,36 +5411,36 @@ discard block | ||
| 5411 | 5411 | $num = 0; | 
| 5412 | 5412 | |
| 5413 | 5413 | // Search data | 
| 5414 | - $sql = "SELECT t.rowid, " . $fieldstoshow . " FROM " . MAIN_DB_PREFIX . $objecttmp->table_element . " as t"; | |
| 5414 | + $sql = "SELECT t.rowid, ".$fieldstoshow." FROM ".MAIN_DB_PREFIX.$objecttmp->table_element." as t"; | |
| 5415 | 5415 | if ($objecttmp->ismultientitymanaged == 2) | 
| 5416 | 5416 | if (!$user->rights->societe->client->voir && !$user->societe_id) | 
| 5417 | - $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; | |
| 5417 | + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; | |
| 5418 | 5418 | $sql .= " WHERE 1=1"; | 
| 5419 | 5419 | if (!empty($objecttmp->ismultientitymanaged)) | 
| 5420 | -            $sql .= " AND t.entity IN (" . getEntity($objecttmp->table_element) . ")";
 | |
| 5420 | +            $sql .= " AND t.entity IN (".getEntity($objecttmp->table_element).")";
 | |
| 5421 | 5421 |          if ($objecttmp->ismultientitymanaged == 1 && !empty($user->societe_id)) {
 | 
| 5422 | 5422 | if ($objecttmp->element == 'societe') | 
| 5423 | - $sql .= " AND t.rowid = " . $user->societe_id; | |
| 5423 | + $sql .= " AND t.rowid = ".$user->societe_id; | |
| 5424 | 5424 | else | 
| 5425 | - $sql .= " AND t.fk_soc = " . $user->societe_id; | |
| 5425 | + $sql .= " AND t.fk_soc = ".$user->societe_id; | |
| 5426 | 5426 | } | 
| 5427 | 5427 | if ($searchkey != '') | 
| 5428 | 5428 |              $sql .= natural_search(explode(',', $fieldstoshow), $searchkey);
 | 
| 5429 | 5429 | if ($objecttmp->ismultientitymanaged == 2) | 
| 5430 | 5430 | if (!$user->rights->societe->client->voir && !$user->societe_id) | 
| 5431 | - $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; | |
| 5431 | + $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; | |
| 5432 | 5432 | $sql .= $this->db->order($fieldstoshow, "ASC"); | 
| 5433 | 5433 | //$sql.=$this->db->plimit($limit, 0); | 
| 5434 | 5434 | // Build output string | 
| 5435 | 5435 | $resql = $this->db->query($sql); | 
| 5436 | 5436 |          if ($resql) {
 | 
| 5437 | 5437 |              if (!$forcecombo) {
 | 
| 5438 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; | |
| 5438 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; | |
| 5439 | 5439 | $out .= ajax_combobox($htmlname, null, $conf->global->$confkeyforautocompletemode); | 
| 5440 | 5440 | } | 
| 5441 | 5441 | |
| 5442 | 5442 | // Construct $out and $outarray | 
| 5443 | - $out .= '<select id="' . $htmlname . '" class="flat' . ($morecss ? ' ' . $morecss : '') . '"' . ($moreparams ? ' ' . $moreparams : '') . ' name="' . $htmlname . '">' . "\n"; | |
| 5443 | + $out .= '<select id="'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'"'.($moreparams ? ' '.$moreparams : '').' name="'.$htmlname.'">'."\n"; | |
| 5444 | 5444 | |
| 5445 | 5445 | // Warning: Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. Seems it is no more true with selec2 v4 | 
| 5446 | 5446 | $textifempty = ' '; | 
| @@ -5453,7 +5453,7 @@ discard block | ||
| 5453 | 5453 |                      $textifempty .= $langs->trans("All");
 | 
| 5454 | 5454 | } | 
| 5455 | 5455 | if ($showempty) | 
| 5456 | - $out .= '<option value="-1">' . $textifempty . '</option>' . "\n"; | |
| 5456 | + $out .= '<option value="-1">'.$textifempty.'</option>'."\n"; | |
| 5457 | 5457 | |
| 5458 | 5458 | $num = $this->db->num_rows($resql); | 
| 5459 | 5459 | $i = 0; | 
| @@ -5464,13 +5464,13 @@ discard block | ||
| 5464 | 5464 |                      $tmparray = explode(',', $fieldstoshow);
 | 
| 5465 | 5465 |                      foreach ($tmparray as $key => $val) {
 | 
| 5466 | 5466 |                          $val = preg_replace('/t\./', '', $val);
 | 
| 5467 | - $label .= (($label && $obj->$val) ? ' - ' : '') . $obj->$val; | |
| 5467 | + $label .= (($label && $obj->$val) ? ' - ' : '').$obj->$val; | |
| 5468 | 5468 | } | 
| 5469 | 5469 |                      if (empty($outputmode)) {
 | 
| 5470 | 5470 |                          if ($preselectedvalue > 0 && $preselectedvalue == $obj->rowid) {
 | 
| 5471 | - $out .= '<option value="' . $obj->rowid . '" selected>' . $label . '</option>'; | |
| 5471 | + $out .= '<option value="'.$obj->rowid.'" selected>'.$label.'</option>'; | |
| 5472 | 5472 |                          } else {
 | 
| 5473 | - $out .= '<option value="' . $obj->rowid . '">' . $label . '</option>'; | |
| 5473 | + $out .= '<option value="'.$obj->rowid.'">'.$label.'</option>'; | |
| 5474 | 5474 | } | 
| 5475 | 5475 |                      } else {
 | 
| 5476 | 5476 |                          array_push($outarray, array('key' => $obj->rowid, 'value' => $label, 'label' => $label));
 | 
| @@ -5482,7 +5482,7 @@ discard block | ||
| 5482 | 5482 | } | 
| 5483 | 5483 | } | 
| 5484 | 5484 | |
| 5485 | - $out .= '</select>' . "\n"; | |
| 5485 | + $out .= '</select>'."\n"; | |
| 5486 | 5486 | } | 
| 5487 | 5487 |          else {
 | 
| 5488 | 5488 | dol_print_error($this->db); | 
| @@ -5538,12 +5538,12 @@ discard block | ||
| 5538 | 5538 |              $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ? (constant('REQUIRE_JQUERY_MULTISELECT') ? constant('REQUIRE_JQUERY_MULTISELECT') : 'select2') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
 | 
| 5539 | 5539 | |
| 5540 | 5540 | // Enhance with select2 | 
| 5541 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; | |
| 5541 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; | |
| 5542 | 5542 | $out .= ajax_combobox($htmlname); | 
| 5543 | 5543 | } | 
| 5544 | 5544 | |
| 5545 | -        $out .= '<select id="' . preg_replace('/^\./', '', $htmlname) . '" ' . ($disabled ? 'disabled ' : '') . 'class="flat ' . (preg_replace('/^\./', '', $htmlname)) . ($morecss ? ' ' . $morecss : '') . '"';
 | |
| 5546 | -        $out .= ' name="' . preg_replace('/^\./', '', $htmlname) . '" ' . ($moreparam ? $moreparam : '');
 | |
| 5545 | +        $out .= '<select id="'.preg_replace('/^\./', '', $htmlname).'" '.($disabled ? 'disabled ' : '').'class="flat '.(preg_replace('/^\./', '', $htmlname)).($morecss ? ' '.$morecss : '').'"';
 | |
| 5546 | +        $out .= ' name="'.preg_replace('/^\./', '', $htmlname).'" '.($moreparam ? $moreparam : '');
 | |
| 5547 | 5547 | $out .= '>'; | 
| 5548 | 5548 | |
| 5549 | 5549 |          if ($show_empty) {
 | 
| @@ -5552,7 +5552,7 @@ discard block | ||
| 5552 | 5552 | $textforempty = ' '; // If we use ajaxcombo, we need   here to avoid to have an empty element that is too small. | 
| 5553 | 5553 | if (!is_numeric($show_empty)) | 
| 5554 | 5554 | $textforempty = $show_empty; | 
| 5555 | - $out .= '<option class="optiongrey" ' . ($moreparamonempty ? $moreparamonempty . ' ' : '') . 'value="' . ($show_empty < 0 ? $show_empty : -1) . '"' . ($id == $show_empty ? ' selected' : '') . '>' . $textforempty . '</option>' . "\n"; | |
| 5555 | + $out .= '<option class="optiongrey" '.($moreparamonempty ? $moreparamonempty.' ' : '').'value="'.($show_empty < 0 ? $show_empty : -1).'"'.($id == $show_empty ? ' selected' : '').'>'.$textforempty.'</option>'."\n"; | |
| 5556 | 5556 | } | 
| 5557 | 5557 | |
| 5558 | 5558 |          if (is_array($array)) {
 | 
| @@ -5582,9 +5582,9 @@ discard block | ||
| 5582 | 5582 | |
| 5583 | 5583 |                  if ($key_in_label) {
 | 
| 5584 | 5584 | if (empty($nohtmlescape)) | 
| 5585 | - $selectOptionValue = dol_escape_htmltag($key . ' - ' . ($maxlen ? dol_trunc($value, $maxlen) : $value)); | |
| 5585 | + $selectOptionValue = dol_escape_htmltag($key.' - '.($maxlen ? dol_trunc($value, $maxlen) : $value)); | |
| 5586 | 5586 | else | 
| 5587 | - $selectOptionValue = $key . ' - ' . ($maxlen ? dol_trunc($value, $maxlen) : $value); | |
| 5587 | + $selectOptionValue = $key.' - '.($maxlen ? dol_trunc($value, $maxlen) : $value); | |
| 5588 | 5588 | } | 
| 5589 | 5589 |                  else {
 | 
| 5590 | 5590 | if (empty($nohtmlescape)) | 
| @@ -5595,12 +5595,12 @@ discard block | ||
| 5595 | 5595 | $selectOptionValue = ' '; | 
| 5596 | 5596 | } | 
| 5597 | 5597 | |
| 5598 | - $out .= '<option value="' . $key . '"'; | |
| 5599 | - $out .= $style . $disabled; | |
| 5598 | + $out .= '<option value="'.$key.'"'; | |
| 5599 | + $out .= $style.$disabled; | |
| 5600 | 5600 | if ($id != '' && $id == $key && !$disabled) | 
| 5601 | - $out .= ' selected'; // To preselect a value | |
| 5601 | + $out .= ' selected'; // To preselect a value | |
| 5602 | 5602 | if ($nohtmlescape) | 
| 5603 | - $out .= ' data-html="' . dol_escape_htmltag($selectOptionValue) . '"'; | |
| 5603 | + $out .= ' data-html="'.dol_escape_htmltag($selectOptionValue).'"'; | |
| 5604 | 5604 | $out .= '>'; | 
| 5605 | 5605 | //var_dump($selectOptionValue); | 
| 5606 | 5606 | $out .= $selectOptionValue; | 
| @@ -5639,19 +5639,19 @@ discard block | ||
| 5639 | 5639 |          if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT'))
 | 
| 5640 | 5640 | return ''; | 
| 5641 | 5641 | |
| 5642 | - $out = '<select type="text" class="' . $htmlname . ($morecss ? ' ' . $morecss : '') . '" ' . ($moreparam ? $moreparam . ' ' : '') . 'name="' . $htmlname . '"></select>'; | |
| 5642 | + $out = '<select type="text" class="'.$htmlname.($morecss ? ' '.$morecss : '').'" '.($moreparam ? $moreparam.' ' : '').'name="'.$htmlname.'"></select>'; | |
| 5643 | 5643 | |
| 5644 | 5644 | $tmpplugin = 'select2'; | 
| 5645 | - $outdelayed = "\n" . '<!-- JS CODE TO ENABLE ' . $tmpplugin . ' for id ' . $htmlname . ' --> | |
| 5645 | + $outdelayed = "\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' --> | |
| 5646 | 5646 | <script type="text/javascript"> | 
| 5647 | 5647 |  	    	$(document).ready(function () {
 | 
| 5648 | 5648 | |
| 5649 | - ' . ($callurlonselect ? 'var saveRemoteData = [];' : '') . ' | |
| 5649 | + ' . ($callurlonselect ? 'var saveRemoteData = [];' : '').' | |
| 5650 | 5650 | |
| 5651 | -                $(".' . $htmlname . '").select2({
 | |
| 5651 | +                $(".' . $htmlname.'").select2({
 | |
| 5652 | 5652 |  			    	ajax: {
 | 
| 5653 | 5653 | dir: "ltr", | 
| 5654 | - url: "' . $url . '", | |
| 5654 | + url: "' . $url.'", | |
| 5655 | 5655 | dataType: \'json\', | 
| 5656 | 5656 | delay: 250, | 
| 5657 | 5657 |  				    	data: function (params) {
 | 
| @@ -5678,9 +5678,9 @@ discard block | ||
| 5678 | 5678 | }, | 
| 5679 | 5679 | language: select2arrayoflanguage, | 
| 5680 | 5680 | containerCssClass: \':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */ | 
| 5681 | - placeholder: "' . dol_escape_js($placeholder) . '", | |
| 5681 | + placeholder: "' . dol_escape_js($placeholder).'", | |
| 5682 | 5682 |  			    	escapeMarkup: function (markup) { return markup; }, 	// let our custom formatter work
 | 
| 5683 | - minimumInputLength: ' . $minimumInputLength . ', | |
| 5683 | + minimumInputLength: ' . $minimumInputLength.', | |
| 5684 | 5684 |  			        formatResult: function(result, container, query, escapeMarkup) {
 | 
| 5685 | 5685 | return escapeMarkup(result.text); | 
| 5686 | 5686 | }, | 
| @@ -5688,10 +5688,10 @@ discard block | ||
| 5688 | 5688 | |
| 5689 | 5689 | ' . ($callurlonselect ? ' | 
| 5690 | 5690 | /* Code to execute a GET when we select a value */ | 
| 5691 | -                $(".' . $htmlname . '").change(function() {
 | |
| 5692 | -			    	var selected = $(".' . $htmlname . '").val();
 | |
| 5691 | +                $(".' . $htmlname.'").change(function() {
 | |
| 5692 | +			    	var selected = $(".' . $htmlname.'").val();
 | |
| 5693 | 5693 |                  	console.log("We select in selectArrayAjax the entry "+selected)
 | 
| 5694 | -			        $(".' . $htmlname . '").val("");  /* reset visible combo value */
 | |
| 5694 | +			        $(".' . $htmlname.'").val("");  /* reset visible combo value */
 | |
| 5695 | 5695 |      			    $.each( saveRemoteData, function( key, value ) {
 | 
| 5696 | 5696 | if (key == selected) | 
| 5697 | 5697 |      			            {
 | 
| @@ -5699,7 +5699,7 @@ discard block | ||
| 5699 | 5699 | location.assign(value.url); | 
| 5700 | 5700 | } | 
| 5701 | 5701 | }); | 
| 5702 | - });' : '' ) . ' | |
| 5702 | + });' : '').' | |
| 5703 | 5703 | |
| 5704 | 5704 | }); | 
| 5705 | 5705 | </script>'; | 
| @@ -5739,7 +5739,7 @@ discard block | ||
| 5739 | 5739 |          if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT'))
 | 
| 5740 | 5740 | return ''; | 
| 5741 | 5741 | |
| 5742 | - $out = '<select type="text" class="' . $htmlname . ($morecss ? ' ' . $morecss : '') . '" ' . ($moreparam ? $moreparam . ' ' : '') . 'name="' . $htmlname . '"><option></option></select>'; | |
| 5742 | + $out = '<select type="text" class="'.$htmlname.($morecss ? ' '.$morecss : '').'" '.($moreparam ? $moreparam.' ' : '').'name="'.$htmlname.'"><option></option></select>'; | |
| 5743 | 5743 | |
| 5744 | 5744 | $formattedarrayresult = array(); | 
| 5745 | 5745 | |
| @@ -5752,20 +5752,20 @@ discard block | ||
| 5752 | 5752 | } | 
| 5753 | 5753 | |
| 5754 | 5754 | $tmpplugin = 'select2'; | 
| 5755 | - $outdelayed = "\n" . '<!-- JS CODE TO ENABLE ' . $tmpplugin . ' for id ' . $htmlname . ' --> | |
| 5755 | + $outdelayed = "\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' --> | |
| 5756 | 5756 | <script type="text/javascript"> | 
| 5757 | 5757 |  			$(document).ready(function () {
 | 
| 5758 | - var data = ' . json_encode($formattedarrayresult) . '; | |
| 5758 | + var data = ' . json_encode($formattedarrayresult).'; | |
| 5759 | 5759 | |
| 5760 | - ' . ($callurlonselect ? 'var saveRemoteData = ' . json_encode($array) . ';' : '') . ' | |
| 5760 | + ' . ($callurlonselect ? 'var saveRemoteData = '.json_encode($array).';' : '').' | |
| 5761 | 5761 | |
| 5762 | -				$(".' . $htmlname . '").select2({
 | |
| 5762 | +				$(".' . $htmlname.'").select2({
 | |
| 5763 | 5763 | data: data, | 
| 5764 | 5764 | language: select2arrayoflanguage, | 
| 5765 | 5765 | containerCssClass: \':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */ | 
| 5766 | - placeholder: "' . dol_escape_js($placeholder) . '", | |
| 5766 | + placeholder: "' . dol_escape_js($placeholder).'", | |
| 5767 | 5767 |  					escapeMarkup: function (markup) { return markup; }, 	// let our custom formatter work
 | 
| 5768 | - minimumInputLength: ' . $minimumInputLength . ', | |
| 5768 | + minimumInputLength: ' . $minimumInputLength.', | |
| 5769 | 5769 |  					formatResult: function(result, container, query, escapeMarkup) {
 | 
| 5770 | 5770 | return escapeMarkup(result.text); | 
| 5771 | 5771 | }, | 
| @@ -5803,11 +5803,11 @@ discard block | ||
| 5803 | 5803 | |
| 5804 | 5804 | ' . ($callurlonselect ? ' | 
| 5805 | 5805 | /* Code to execute a GET when we select a value */ | 
| 5806 | -				$(".' . $htmlname . '").change(function() {
 | |
| 5807 | -					var selected = $(".' . $htmlname . '").val();
 | |
| 5806 | +				$(".' . $htmlname.'").change(function() {
 | |
| 5807 | +					var selected = $(".' . $htmlname.'").val();
 | |
| 5808 | 5808 |  					console.log("We select "+selected)
 | 
| 5809 | 5809 | |
| 5810 | -					$(".' . $htmlname . '").val("");  /* reset visible combo value */
 | |
| 5810 | +					$(".' . $htmlname.'").val("");  /* reset visible combo value */
 | |
| 5811 | 5811 |  					$.each( saveRemoteData, function( key, value ) {
 | 
| 5812 | 5812 | if (key == selected) | 
| 5813 | 5813 |  						{
 | 
| @@ -5815,7 +5815,7 @@ discard block | ||
| 5815 | 5815 | location.assign(value.url); | 
| 5816 | 5816 | } | 
| 5817 | 5817 | }); | 
| 5818 | - });' : '' ) . ' | |
| 5818 | + });' : '').' | |
| 5819 | 5819 | |
| 5820 | 5820 | }); | 
| 5821 | 5821 | </script>'; | 
| @@ -5855,28 +5855,28 @@ discard block | ||
| 5855 | 5855 | |
| 5856 | 5856 | // Add code for jquery to use multiselect | 
| 5857 | 5857 |          if (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) {
 | 
| 5858 | - $out .= "\n" . '<!-- JS CODE TO ENABLE ' . $tmpplugin . ' for id ' . $htmlname . ' --> | |
| 5858 | + $out .= "\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' --> | |
| 5859 | 5859 | <script type="text/javascript">' . "\n"; | 
| 5860 | 5860 |              if ($addjscombo == 1) {
 | 
| 5861 | 5861 |                  $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ? constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
 | 
| 5862 | -                $out .= 'function formatResult(record) {' . "\n";
 | |
| 5862 | +                $out .= 'function formatResult(record) {'."\n";
 | |
| 5863 | 5863 |                  if ($elemtype == 'category') {
 | 
| 5864 | - $out .= ' //return \'<span><img src="' . DOL_URL_ROOT . '/theme/eldy/img/object_category.png' . '"> <a href="' . DOL_URL_ROOT . '/categories/viewcat.php?type=0&id=\'+record.id+\'">\'+record.text+\'</a></span>\'; | |
| 5865 | - return \'<span><img src="' . DOL_URL_ROOT . '/theme/eldy/img/object_category.png' . '"> \'+record.text+\'</span>\';'; | |
| 5864 | + $out .= ' //return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png'.'"> <a href="'.DOL_URL_ROOT.'/categories/viewcat.php?type=0&id=\'+record.id+\'">\'+record.text+\'</a></span>\'; | |
| 5865 | + return \'<span><img src="' . DOL_URL_ROOT.'/theme/eldy/img/object_category.png'.'"> \'+record.text+\'</span>\';'; | |
| 5866 | 5866 |                  } else {
 | 
| 5867 | 5867 | $out .= 'return record.text;'; | 
| 5868 | 5868 | } | 
| 5869 | - $out .= '};' . "\n"; | |
| 5870 | -                $out .= 'function formatSelection(record) {' . "\n";
 | |
| 5869 | + $out .= '};'."\n"; | |
| 5870 | +                $out .= 'function formatSelection(record) {'."\n";
 | |
| 5871 | 5871 |                  if ($elemtype == 'category') {
 | 
| 5872 | - $out .= ' //return \'<span><img src="' . DOL_URL_ROOT . '/theme/eldy/img/object_category.png' . '"> <a href="' . DOL_URL_ROOT . '/categories/viewcat.php?type=0&id=\'+record.id+\'">\'+record.text+\'</a></span>\'; | |
| 5873 | - return \'<span><img src="' . DOL_URL_ROOT . '/theme/eldy/img/object_category.png' . '"> \'+record.text+\'</span>\';'; | |
| 5872 | + $out .= ' //return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png'.'"> <a href="'.DOL_URL_ROOT.'/categories/viewcat.php?type=0&id=\'+record.id+\'">\'+record.text+\'</a></span>\'; | |
| 5873 | + return \'<span><img src="' . DOL_URL_ROOT.'/theme/eldy/img/object_category.png'.'"> \'+record.text+\'</span>\';'; | |
| 5874 | 5874 |                  } else {
 | 
| 5875 | 5875 | $out .= 'return record.text;'; | 
| 5876 | 5876 | } | 
| 5877 | - $out .= '};' . "\n"; | |
| 5877 | + $out .= '};'."\n"; | |
| 5878 | 5878 |                  $out .= '$(document).ready(function () {
 | 
| 5879 | -							$(\'#' . $htmlname . '\').' . $tmpplugin . '({
 | |
| 5879 | +							$(\'#' . $htmlname.'\').'.$tmpplugin.'({
 | |
| 5880 | 5880 | dir: \'ltr\', | 
| 5881 | 5881 | // Specify format function for dropdown item | 
| 5882 | 5882 | formatResult: formatResult, | 
| @@ -5890,13 +5890,13 @@ discard block | ||
| 5890 | 5890 | // Add other js lib | 
| 5891 | 5891 | // ... | 
| 5892 | 5892 |                  $out .= '$(document).ready(function () {
 | 
| 5893 | -							$(\'#' . $htmlname . '\').multiSelect({
 | |
| 5893 | +							$(\'#' . $htmlname.'\').multiSelect({
 | |
| 5894 | 5894 | containerHTML: \'<div class="multi-select-container">\', | 
| 5895 | 5895 | menuHTML: \'<div class="multi-select-menu">\', | 
| 5896 | - buttonHTML: \'<span class="multi-select-button ' . $morecss . '">\', | |
| 5896 | + buttonHTML: \'<span class="multi-select-button ' . $morecss.'">\', | |
| 5897 | 5897 | menuItemHTML: \'<label class="multi-select-menuitem">\', | 
| 5898 | 5898 | activeClass: \'multi-select-container--open\', | 
| 5899 | - noneText: \'' . $placeholder . '\' | |
| 5899 | + noneText: \'' . $placeholder.'\' | |
| 5900 | 5900 | }); | 
| 5901 | 5901 | })'; | 
| 5902 | 5902 | } | 
| @@ -5905,27 +5905,27 @@ discard block | ||
| 5905 | 5905 | |
| 5906 | 5906 | // Try also magic suggest | 
| 5907 | 5907 | |
| 5908 | -        $out .= '<select id="' . $htmlname . '" class="multiselect' . ($morecss ? ' ' . $morecss : '') . '" multiple name="' . $htmlname . '[]"' . ($moreattrib ? ' ' . $moreattrib : '') . ($width ? ' style="width: ' . (preg_match('/%/', $width) ? $width : $width . 'px') . '"' : '') . '>' . "\n";
 | |
| 5908 | +        $out .= '<select id="'.$htmlname.'" class="multiselect'.($morecss ? ' '.$morecss : '').'" multiple name="'.$htmlname.'[]"'.($moreattrib ? ' '.$moreattrib : '').($width ? ' style="width: '.(preg_match('/%/', $width) ? $width : $width.'px').'"' : '').'>'."\n";
 | |
| 5909 | 5909 |          if (is_array($array) && !empty($array)) {
 | 
| 5910 | 5910 | if ($value_as_key) | 
| 5911 | 5911 | $array = array_combine($array, $array); | 
| 5912 | 5912 | |
| 5913 | 5913 |              if (!empty($array)) {
 | 
| 5914 | 5914 |                  foreach ($array as $key => $value) {
 | 
| 5915 | - $out .= '<option value="' . $key . '"'; | |
| 5915 | + $out .= '<option value="'.$key.'"'; | |
| 5916 | 5916 |                      if (is_array($selected) && !empty($selected) && in_array($key, $selected) && !empty($key)) {
 | 
| 5917 | 5917 | $out .= ' selected'; | 
| 5918 | 5918 | } | 
| 5919 | 5919 | $out .= '>'; | 
| 5920 | 5920 | |
| 5921 | 5921 | $newval = ($translate ? $langs->trans($value) : $value); | 
| 5922 | - $newval = ($key_in_label ? $key . ' - ' . $newval : $newval); | |
| 5922 | + $newval = ($key_in_label ? $key.' - '.$newval : $newval); | |
| 5923 | 5923 | $out .= dol_htmlentitiesbr($newval); | 
| 5924 | - $out .= '</option>' . "\n"; | |
| 5924 | + $out .= '</option>'."\n"; | |
| 5925 | 5925 | } | 
| 5926 | 5926 | } | 
| 5927 | 5927 | } | 
| 5928 | - $out .= '</select>' . "\n"; | |
| 5928 | + $out .= '</select>'."\n"; | |
| 5929 | 5929 | |
| 5930 | 5930 | return $out; | 
| 5931 | 5931 | } | 
| @@ -5946,7 +5946,7 @@ discard block | ||
| 5946 | 5946 | if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) | 
| 5947 | 5947 | return ''; | 
| 5948 | 5948 | |
| 5949 | - $tmpvar = "MAIN_SELECTEDFIELDS_" . $varpage; | |
| 5949 | + $tmpvar = "MAIN_SELECTEDFIELDS_".$varpage; | |
| 5950 | 5950 |          if (!empty($user->conf->$tmpvar)) {
 | 
| 5951 | 5951 |              $tmparray = explode(',', $user->conf->$tmpvar);
 | 
| 5952 | 5952 |              foreach ($array as $key => $val) {
 | 
| @@ -5968,28 +5968,28 @@ discard block | ||
| 5968 | 5968 |                var_dump(array_key_exists('enabled', $val));
 | 
| 5969 | 5969 | var_dump(!$val['enabled']); */ | 
| 5970 | 5970 |              if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled']) {
 | 
| 5971 | - unset($array[$key]); // We don't want this field | |
| 5971 | + unset($array[$key]); // We don't want this field | |
| 5972 | 5972 | continue; | 
| 5973 | 5973 | } | 
| 5974 | 5974 |              if ($val['label']) {
 | 
| 5975 | - $lis .= '<li><input type="checkbox" id="checkbox' . $key . '" value="' . $key . '"' . (empty($val['checked']) ? '' : ' checked="checked"') . '/><label for="checkbox' . $key . '">' . dol_escape_htmltag($langs->trans($val['label'])) . '</label></li>'; | |
| 5976 | - $listcheckedstring .= (empty($val['checked']) ? '' : $key . ','); | |
| 5975 | + $lis .= '<li><input type="checkbox" id="checkbox'.$key.'" value="'.$key.'"'.(empty($val['checked']) ? '' : ' checked="checked"').'/><label for="checkbox'.$key.'">'.dol_escape_htmltag($langs->trans($val['label'])).'</label></li>'; | |
| 5976 | + $listcheckedstring .= (empty($val['checked']) ? '' : $key.','); | |
| 5977 | 5977 | } | 
| 5978 | 5978 | } | 
| 5979 | 5979 | |
| 5980 | - $out = '<!-- Component multiSelectArrayWithCheckbox ' . $htmlname . ' --> | |
| 5980 | + $out = '<!-- Component multiSelectArrayWithCheckbox '.$htmlname.' --> | |
| 5981 | 5981 | |
| 5982 | 5982 | <dl class="dropdown"> | 
| 5983 | 5983 | <dt> | 
| 5984 | 5984 | <a href="#"> | 
| 5985 | -              ' . img_picto('', 'list') . '
 | |
| 5985 | +              ' . img_picto('', 'list').'
 | |
| 5986 | 5986 | </a> | 
| 5987 | - <input type="hidden" class="' . $htmlname . '" name="' . $htmlname . '" value="' . $listcheckedstring . '"> | |
| 5987 | + <input type="hidden" class="' . $htmlname.'" name="'.$htmlname.'" value="'.$listcheckedstring.'"> | |
| 5988 | 5988 | </dt> | 
| 5989 | 5989 | <dd class="dropdowndd"> | 
| 5990 | - <div class="multiselectcheckbox' . $htmlname . '"> | |
| 5991 | - <ul class="ul' . $htmlname . '"> | |
| 5992 | - ' . $lis . ' | |
| 5990 | + <div class="multiselectcheckbox' . $htmlname.'"> | |
| 5991 | + <ul class="ul' . $htmlname.'"> | |
| 5992 | + ' . $lis.' | |
| 5993 | 5993 | </ul> | 
| 5994 | 5994 | </div> | 
| 5995 | 5995 | </dd> | 
| @@ -5997,15 +5997,15 @@ discard block | ||
| 5997 | 5997 | |
| 5998 | 5998 | <script type="text/javascript"> | 
| 5999 | 5999 |            jQuery(document).ready(function () {
 | 
| 6000 | -              $(\'.multiselectcheckbox' . $htmlname . ' input[type="checkbox"]\').on(\'click\', function () {
 | |
| 6000 | +              $(\'.multiselectcheckbox' . $htmlname.' input[type="checkbox"]\').on(\'click\', function () {
 | |
| 6001 | 6001 |                    console.log("A new field was added/removed")
 | 
| 6002 | 6002 |                    $("input:hidden[name=formfilteraction]").val(\'listafterchangingselectedfields\')
 | 
| 6003 | 6003 | var title = $(this).val() + ","; | 
| 6004 | 6004 |                    if ($(this).is(\':checked\')) {
 | 
| 6005 | - $(\'.' . $htmlname . '\').val(title + $(\'.' . $htmlname . '\').val()); | |
| 6005 | + $(\'.' . $htmlname.'\').val(title + $(\'.'.$htmlname.'\').val()); | |
| 6006 | 6006 | } | 
| 6007 | 6007 |                    else {
 | 
| 6008 | - $(\'.' . $htmlname . '\').val( $(\'.' . $htmlname . '\').val().replace(title, \'\') ) | |
| 6008 | + $(\'.' . $htmlname.'\').val( $(\'.'.$htmlname.'\').val().replace(title, \'\') ) | |
| 6009 | 6009 | } | 
| 6010 | 6010 | // Now, we submit page | 
| 6011 | 6011 | $(this).parents(\'form:first\').submit(); | 
| @@ -6029,7 +6029,7 @@ discard block | ||
| 6029 | 6029 |      {
 | 
| 6030 | 6030 | global $db; | 
| 6031 | 6031 | |
| 6032 | - include_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; | |
| 6032 | + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; | |
| 6033 | 6033 | |
| 6034 | 6034 | $cat = new Categorie($db); | 
| 6035 | 6035 | $categories = $cat->containing($id, $type); | 
| @@ -6037,12 +6037,12 @@ discard block | ||
| 6037 | 6037 |          if ($rendermode == 1) {
 | 
| 6038 | 6038 | $toprint = array(); | 
| 6039 | 6039 |              foreach ($categories as $c) {
 | 
| 6040 | - $ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text | |
| 6040 | + $ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text | |
| 6041 | 6041 |                  foreach ($ways as $way) {
 | 
| 6042 | -                    $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #aaa"') . '>' . img_object('', 'category') . ' ' . $way . '</li>';
 | |
| 6042 | +                    $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"'.($c->color ? ' style="background: #'.$c->color.';"' : ' style="background: #aaa"').'>'.img_object('', 'category').' '.$way.'</li>';
 | |
| 6043 | 6043 | } | 
| 6044 | 6044 | } | 
| 6045 | -            return '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
 | |
| 6045 | +            return '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>';
 | |
| 6046 | 6046 | } | 
| 6047 | 6047 | |
| 6048 | 6048 |          if ($rendermode == 0) {
 | 
| @@ -6078,7 +6078,7 @@ discard block | ||
| 6078 | 6078 | 'morehtmlright' => $morehtmlright, | 
| 6079 | 6079 | 'compatibleImportElementsList' => & $compatibleImportElementsList, | 
| 6080 | 6080 | ); | 
| 6081 | -        $reshook = $hookmanager->executeHooks('showLinkedObjectBlock', $parameters, $object, $action);    // Note that $action and $object may have been modified by hook
 | |
| 6081 | +        $reshook = $hookmanager->executeHooks('showLinkedObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
 | |
| 6082 | 6082 | |
| 6083 | 6083 |          if (empty($reshook)) {
 | 
| 6084 | 6084 | $nbofdifferenttypes = count($object->linkedObjects); | 
| @@ -6088,15 +6088,15 @@ discard block | ||
| 6088 | 6088 | |
| 6089 | 6089 | |
| 6090 | 6090 | print '<div class="div-table-responsive-no-min">'; | 
| 6091 | - print '<table class="noborder allwidth" data-block="showLinkedObject" data-element="' . $object->element . '" data-elementid="' . $object->id . '" >'; | |
| 6091 | + print '<table class="noborder allwidth" data-block="showLinkedObject" data-element="'.$object->element.'" data-elementid="'.$object->id.'" >'; | |
| 6092 | 6092 | |
| 6093 | 6093 | print '<tr class="liste_titre">'; | 
| 6094 | -            print '<td>' . $langs->trans("Type") . '</td>';
 | |
| 6095 | -            print '<td>' . $langs->trans("Ref") . '</td>';
 | |
| 6094 | +            print '<td>'.$langs->trans("Type").'</td>';
 | |
| 6095 | +            print '<td>'.$langs->trans("Ref").'</td>';
 | |
| 6096 | 6096 | print '<td align="center"></td>'; | 
| 6097 | -            print '<td align="center">' . $langs->trans("Date") . '</td>';
 | |
| 6098 | -            print '<td align="right">' . $langs->trans("AmountHTShort") . '</td>';
 | |
| 6099 | -            print '<td align="right">' . $langs->trans("Status") . '</td>';
 | |
| 6097 | +            print '<td align="center">'.$langs->trans("Date").'</td>';
 | |
| 6098 | +            print '<td align="right">'.$langs->trans("AmountHTShort").'</td>';
 | |
| 6099 | +            print '<td align="right">'.$langs->trans("Status").'</td>';
 | |
| 6100 | 6100 | print '<td></td>'; | 
| 6101 | 6101 | print '</tr>'; | 
| 6102 | 6102 | |
| @@ -6114,13 +6114,13 @@ discard block | ||
| 6114 | 6114 |                  if ($objecttype != 'supplier_proposal' && preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs)) {
 | 
| 6115 | 6115 | $element = $regs[1]; | 
| 6116 | 6116 | $subelement = $regs[2]; | 
| 6117 | - $tplpath = $element . '/' . $subelement; | |
| 6117 | + $tplpath = $element.'/'.$subelement; | |
| 6118 | 6118 | } | 
| 6119 | 6119 | $tplname = 'linkedobjectblock'; | 
| 6120 | 6120 | |
| 6121 | 6121 | // To work with non standard path | 
| 6122 | 6122 |                  if ($objecttype == 'facture') {
 | 
| 6123 | - $tplpath = 'compta/' . $element; | |
| 6123 | + $tplpath = 'compta/'.$element; | |
| 6124 | 6124 | if (empty($conf->facture->enabled)) | 
| 6125 | 6125 | continue; // Do not show if module disabled | 
| 6126 | 6126 | } | 
| @@ -6131,7 +6131,7 @@ discard block | ||
| 6131 | 6131 | continue; // Do not show if module disabled | 
| 6132 | 6132 | } | 
| 6133 | 6133 |                  else if ($objecttype == 'propal') {
 | 
| 6134 | - $tplpath = 'comm/' . $element; | |
| 6134 | + $tplpath = 'comm/'.$element; | |
| 6135 | 6135 | if (empty($conf->propal->enabled)) | 
| 6136 | 6136 | continue; // Do not show if module disabled | 
| 6137 | 6137 | } | 
| @@ -6169,14 +6169,14 @@ discard block | ||
| 6169 | 6169 | |
| 6170 | 6170 | |
| 6171 | 6171 | // Output template part (modules that overwrite templates must declare this into descriptor) | 
| 6172 | -                $dirtpls = array_merge($conf->modules_parts['tpl'], array('/' . $tplpath . '/tpl'));
 | |
| 6172 | +                $dirtpls = array_merge($conf->modules_parts['tpl'], array('/'.$tplpath.'/tpl'));
 | |
| 6173 | 6173 |                  foreach ($dirtpls as $reldir) {
 | 
| 6174 | 6174 |                      if ($nboftypesoutput == ($nbofdifferenttypes - 1)) {    // No more type to show after
 | 
| 6175 | 6175 | global $noMoreLinkedObjectBlockAfter; | 
| 6176 | 6176 | $noMoreLinkedObjectBlockAfter = 1; | 
| 6177 | 6177 | } | 
| 6178 | 6178 | |
| 6179 | - $res = @include dol_buildpath($reldir . '/' . $tplname . '.tpl.php'); | |
| 6179 | + $res = @include dol_buildpath($reldir.'/'.$tplname.'.tpl.php'); | |
| 6180 | 6180 |                      if ($res) {
 | 
| 6181 | 6181 | $nboftypesoutput++; | 
| 6182 | 6182 | break; | 
| @@ -6185,7 +6185,7 @@ discard block | ||
| 6185 | 6185 | } | 
| 6186 | 6186 | |
| 6187 | 6187 |              if (!$nboftypesoutput) {
 | 
| 6188 | -                print '<tr><td class="impair opacitymedium" colspan="7">' . $langs->trans("None") . '</td></tr>';
 | |
| 6188 | +                print '<tr><td class="impair opacitymedium" colspan="7">'.$langs->trans("None").'</td></tr>';
 | |
| 6189 | 6189 | } | 
| 6190 | 6190 | |
| 6191 | 6191 | print '</table>'; | 
| @@ -6225,26 +6225,26 @@ discard block | ||
| 6225 | 6225 |          if (is_object($object->thirdparty) && !empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
 | 
| 6226 | 6226 | $listofidcompanytoscan = $object->thirdparty->id; | 
| 6227 | 6227 | if (($object->thirdparty->parent > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) | 
| 6228 | - $listofidcompanytoscan .= ',' . $object->thirdparty->parent; | |
| 6228 | + $listofidcompanytoscan .= ','.$object->thirdparty->parent; | |
| 6229 | 6229 |              if (($object->fk_project > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PROJECT_THIRDPARY_IN_LINKTO)) {
 | 
| 6230 | - include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; | |
| 6230 | + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; | |
| 6231 | 6231 | $tmpproject = new Project($this->db); | 
| 6232 | 6232 | $tmpproject->fetch($object->fk_project); | 
| 6233 | 6233 | if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) | 
| 6234 | - $listofidcompanytoscan .= ',' . $tmpproject->socid; | |
| 6234 | + $listofidcompanytoscan .= ','.$tmpproject->socid; | |
| 6235 | 6235 | unset($tmpproject); | 
| 6236 | 6236 | } | 
| 6237 | 6237 | |
| 6238 | 6238 | $possiblelinks = array( | 
| 6239 | -                'propal' => array('enabled' => $conf->propal->enabled, 'perms' => 1, 'label' => 'LinkToProposal', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $listofidcompanytoscan . ') AND t.entity IN (' . getEntity('propal') . ')'),
 | |
| 6240 | -                'order' => array('enabled' => $conf->commande->enabled, 'perms' => 1, 'label' => 'LinkToOrder', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $listofidcompanytoscan . ') AND t.entity IN (' . getEntity('commande') . ')'),
 | |
| 6241 | -                'invoice' => array('enabled' => $conf->facture->enabled, 'perms' => 1, 'label' => 'LinkToInvoice', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total as total_ht FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $listofidcompanytoscan . ') AND t.entity IN (' . getEntity('invoice') . ')'),
 | |
| 6242 | -                'invoice_template' => array('enabled' => $conf->facture->enabled, 'perms' => 1, 'label' => 'LinkToTemplateInvoice', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total as total_ht FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $listofidcompanytoscan . ') AND t.entity IN (' . getEntity('invoice') . ')'),
 | |
| 6243 | -                'contrat' => array('enabled' => $conf->contrat->enabled, 'perms' => 1, 'label' => 'LinkToContract', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, '' as total_ht FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "contrat as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $listofidcompanytoscan . ') AND t.entity IN (' . getEntity('contract') . ')'),
 | |
| 6244 | -                'fichinter' => array('enabled' => $conf->ficheinter->enabled, 'perms' => 1, 'label' => 'LinkToIntervention', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $listofidcompanytoscan . ') AND t.entity IN (' . getEntity('intervention') . ')'),
 | |
| 6245 | -                'supplier_proposal' => array('enabled' => $conf->supplier_proposal->enabled, 'perms' => 1, 'label' => 'LinkToSupplierProposal', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $listofidcompanytoscan . ') AND t.entity IN (' . getEntity('supplier_proposal') . ')'),
 | |
| 6246 | -                'order_supplier' => array('enabled' => $conf->supplier_order->enabled, 'perms' => 1, 'label' => 'LinkToSupplierOrder', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $listofidcompanytoscan . ') AND t.entity IN (' . getEntity('commande_fournisseur') . ')'),
 | |
| 6247 | -                'invoice_supplier' => array('enabled' => $conf->supplier_invoice->enabled, 'perms' => 1, 'label' => 'LinkToSupplierInvoice', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $listofidcompanytoscan . ') AND t.entity IN (' . getEntity('facture_fourn') . ')')
 | |
| 6239 | +                'propal' => array('enabled' => $conf->propal->enabled, 'perms' => 1, 'label' => 'LinkToProposal', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('propal').')'),
 | |
| 6240 | +                'order' => array('enabled' => $conf->commande->enabled, 'perms' => 1, 'label' => 'LinkToOrder', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande').')'),
 | |
| 6241 | +                'invoice' => array('enabled' => $conf->facture->enabled, 'perms' => 1, 'label' => 'LinkToInvoice', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'),
 | |
| 6242 | +                'invoice_template' => array('enabled' => $conf->facture->enabled, 'perms' => 1, 'label' => 'LinkToTemplateInvoice', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'),
 | |
| 6243 | +                'contrat' => array('enabled' => $conf->contrat->enabled, 'perms' => 1, 'label' => 'LinkToContract', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, '' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('contract').')'),
 | |
| 6244 | +                'fichinter' => array('enabled' => $conf->ficheinter->enabled, 'perms' => 1, 'label' => 'LinkToIntervention', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('intervention').')'),
 | |
| 6245 | +                'supplier_proposal' => array('enabled' => $conf->supplier_proposal->enabled, 'perms' => 1, 'label' => 'LinkToSupplierProposal', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('supplier_proposal').')'),
 | |
| 6246 | +                'order_supplier' => array('enabled' => $conf->supplier_order->enabled, 'perms' => 1, 'label' => 'LinkToSupplierOrder', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande_fournisseur').')'),
 | |
| 6247 | +                'invoice_supplier' => array('enabled' => $conf->supplier_invoice->enabled, 'perms' => 1, 'label' => 'LinkToSupplierInvoice', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture_fourn').')')
 | |
| 6248 | 6248 | ); | 
| 6249 | 6249 | } | 
| 6250 | 6250 | |
| @@ -6253,7 +6253,7 @@ discard block | ||
| 6253 | 6253 | // Can complete the possiblelink array | 
| 6254 | 6254 |          $hookmanager->initHooks(array('commonobject'));
 | 
| 6255 | 6255 |          $parameters = array('listofidcompanytoscan' => $listofidcompanytoscan);
 | 
| 6256 | -        $reshook = $hookmanager->executeHooks('showLinkToObjectBlock', $parameters, $object, $action);    // Note that $action and $object may have been modified by hook
 | |
| 6256 | +        $reshook = $hookmanager->executeHooks('showLinkToObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
 | |
| 6257 | 6257 |          if (empty($reshook)) {
 | 
| 6258 | 6258 |              if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
 | 
| 6259 | 6259 | $possiblelinks = array_merge($possiblelinks, $hookmanager->resArray); | 
| @@ -6271,7 +6271,7 @@ discard block | ||
| 6271 | 6271 | continue; | 
| 6272 | 6272 | |
| 6273 | 6273 |              if (!empty($possiblelink['perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || !in_array($key, $excludelinksto))) {
 | 
| 6274 | - print '<div id="' . $key . 'list"' . (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ' style="display:none"' : '') . '>'; | |
| 6274 | + print '<div id="'.$key.'list"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ' style="display:none"' : '').'>'; | |
| 6275 | 6275 | $sql = $possiblelink['sql']; | 
| 6276 | 6276 | |
| 6277 | 6277 | $resqllist = $this->db->query($sql); | 
| @@ -6279,34 +6279,34 @@ discard block | ||
| 6279 | 6279 | $num = $this->db->num_rows($resqllist); | 
| 6280 | 6280 | $i = 0; | 
| 6281 | 6281 | |
| 6282 | - print '<br><form action="' . $_SERVER["PHP_SELF"] . '" method="POST" name="formlinked' . $key . '">'; | |
| 6283 | - print '<input type="hidden" name="id" value="' . $object->id . '">'; | |
| 6282 | + print '<br><form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="formlinked'.$key.'">'; | |
| 6283 | + print '<input type="hidden" name="id" value="'.$object->id.'">'; | |
| 6284 | 6284 | print '<input type="hidden" name="action" value="addlink">'; | 
| 6285 | - print '<input type="hidden" name="addlink" value="' . $key . '">'; | |
| 6285 | + print '<input type="hidden" name="addlink" value="'.$key.'">'; | |
| 6286 | 6286 | print '<table class="noborder">'; | 
| 6287 | 6287 | print '<tr class="liste_titre">'; | 
| 6288 | 6288 | print '<td class="nowrap"></td>'; | 
| 6289 | -                    print '<td align="center">' . $langs->trans("Ref") . '</td>';
 | |
| 6290 | -                    print '<td align="left">' . $langs->trans("RefCustomer") . '</td>';
 | |
| 6291 | -                    print '<td align="right">' . $langs->trans("AmountHTShort") . '</td>';
 | |
| 6292 | -                    print '<td align="left">' . $langs->trans("Company") . '</td>';
 | |
| 6289 | +                    print '<td align="center">'.$langs->trans("Ref").'</td>';
 | |
| 6290 | +                    print '<td align="left">'.$langs->trans("RefCustomer").'</td>';
 | |
| 6291 | +                    print '<td align="right">'.$langs->trans("AmountHTShort").'</td>';
 | |
| 6292 | +                    print '<td align="left">'.$langs->trans("Company").'</td>';
 | |
| 6293 | 6293 | print '</tr>'; | 
| 6294 | 6294 |                      while ($i < $num) {
 | 
| 6295 | 6295 | $objp = $this->db->fetch_object($resqllist); | 
| 6296 | 6296 | |
| 6297 | 6297 | print '<tr class="oddeven">'; | 
| 6298 | 6298 | print '<td aling="left">'; | 
| 6299 | - print '<input type="radio" name="idtolinkto" value=' . $objp->rowid . '>'; | |
| 6299 | + print '<input type="radio" name="idtolinkto" value='.$objp->rowid.'>'; | |
| 6300 | 6300 | print '</td>'; | 
| 6301 | - print '<td align="center">' . $objp->ref . '</td>'; | |
| 6302 | - print '<td>' . $objp->ref_client . '</td>'; | |
| 6303 | - print '<td align="right">' . price($objp->total_ht) . '</td>'; | |
| 6304 | - print '<td>' . $objp->name . '</td>'; | |
| 6301 | + print '<td align="center">'.$objp->ref.'</td>'; | |
| 6302 | + print '<td>'.$objp->ref_client.'</td>'; | |
| 6303 | + print '<td align="right">'.price($objp->total_ht).'</td>'; | |
| 6304 | + print '<td>'.$objp->name.'</td>'; | |
| 6305 | 6305 | print '</tr>'; | 
| 6306 | 6306 | $i++; | 
| 6307 | 6307 | } | 
| 6308 | 6308 | print '</table>'; | 
| 6309 | -                    print '<div class="center"><input type="submit" class="button valignmiddle" value="' . $langs->trans('ToLink') . '">     <input type="submit" class="button" name="cancel" value="' . $langs->trans('Cancel') . '"></div>';
 | |
| 6309 | +                    print '<div class="center"><input type="submit" class="button valignmiddle" value="'.$langs->trans('ToLink').'">     <input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'"></div>';
 | |
| 6310 | 6310 | |
| 6311 | 6311 | print '</form>'; | 
| 6312 | 6312 | $this->db->free($resqllist); | 
| @@ -6320,20 +6320,20 @@ discard block | ||
| 6320 | 6320 | |
| 6321 | 6321 | //$linktoelem.=($linktoelem?'   ':''); | 
| 6322 | 6322 | if ($num > 0) | 
| 6323 | -                    $linktoelemlist .= '<li><a href="#linkto' . $key . '" class="linkto dropdowncloseonclick" rel="' . $key . '">' . $langs->trans($possiblelink['label']) . ' (' . $num . ')</a></li>';
 | |
| 6323 | +                    $linktoelemlist .= '<li><a href="#linkto'.$key.'" class="linkto dropdowncloseonclick" rel="'.$key.'">'.$langs->trans($possiblelink['label']).' ('.$num.')</a></li>';
 | |
| 6324 | 6324 | //else $linktoelem.=$langs->trans($possiblelink['label']); | 
| 6325 | 6325 | else | 
| 6326 | - $linktoelemlist .= '<li><span class="linktodisabled">' . $langs->trans($possiblelink['label']) . ' (0)</span></li>'; | |
| 6326 | + $linktoelemlist .= '<li><span class="linktodisabled">'.$langs->trans($possiblelink['label']).' (0)</span></li>'; | |
| 6327 | 6327 | } | 
| 6328 | 6328 | } | 
| 6329 | 6329 | |
| 6330 | 6330 |          if ($linktoelemlist) {
 | 
| 6331 | 6331 | $linktoelem = ' | 
| 6332 | 6332 | <dl class="dropdown" id="linktoobjectname"> | 
| 6333 | -    		<dt><a href="#linktoobjectname">' . $langs->trans("LinkTo") . '...</a></dt>
 | |
| 6333 | +    		<dt><a href="#linktoobjectname">' . $langs->trans("LinkTo").'...</a></dt>
 | |
| 6334 | 6334 | <dd> | 
| 6335 | 6335 | <div class="multiselectlinkto"> | 
| 6336 | - <ul class="ulselectedfields">' . $linktoelemlist . ' | |
| 6336 | + <ul class="ulselectedfields">' . $linktoelemlist.' | |
| 6337 | 6337 | </ul> | 
| 6338 | 6338 | </div> | 
| 6339 | 6339 | </dd> | 
| @@ -6380,18 +6380,18 @@ discard block | ||
| 6380 | 6380 | |
| 6381 | 6381 | $disabled = ($disabled ? ' disabled' : ''); | 
| 6382 | 6382 | |
| 6383 | - $resultyesno = '<select class="flat width75" id="' . $htmlname . '" name="' . $htmlname . '"' . $disabled . '>' . "\n"; | |
| 6383 | + $resultyesno = '<select class="flat width75" id="'.$htmlname.'" name="'.$htmlname.'"'.$disabled.'>'."\n"; | |
| 6384 | 6384 | if ($useempty) | 
| 6385 | - $resultyesno .= '<option value="-1"' . (($value < 0) ? ' selected' : '') . '> </option>' . "\n"; | |
| 6385 | + $resultyesno .= '<option value="-1"'.(($value < 0) ? ' selected' : '').'> </option>'."\n"; | |
| 6386 | 6386 |          if (("$value" == 'yes') || ($value == 1)) {
 | 
| 6387 | -            $resultyesno .= '<option value="' . $yes . '" selected>' . $langs->trans("Yes") . '</option>' . "\n";
 | |
| 6388 | -            $resultyesno .= '<option value="' . $no . '">' . $langs->trans("No") . '</option>' . "\n";
 | |
| 6387 | +            $resultyesno .= '<option value="'.$yes.'" selected>'.$langs->trans("Yes").'</option>'."\n";
 | |
| 6388 | +            $resultyesno .= '<option value="'.$no.'">'.$langs->trans("No").'</option>'."\n";
 | |
| 6389 | 6389 |          } else {
 | 
| 6390 | 6390 | $selected = (($useempty && $value != '0' && $value != 'no') ? '' : ' selected'); | 
| 6391 | -            $resultyesno .= '<option value="' . $yes . '">' . $langs->trans("Yes") . '</option>' . "\n";
 | |
| 6392 | -            $resultyesno .= '<option value="' . $no . '"' . $selected . '>' . $langs->trans("No") . '</option>' . "\n";
 | |
| 6391 | +            $resultyesno .= '<option value="'.$yes.'">'.$langs->trans("Yes").'</option>'."\n";
 | |
| 6392 | +            $resultyesno .= '<option value="'.$no.'"'.$selected.'>'.$langs->trans("No").'</option>'."\n";
 | |
| 6393 | 6393 | } | 
| 6394 | - $resultyesno .= '</select>' . "\n"; | |
| 6394 | + $resultyesno .= '</select>'."\n"; | |
| 6395 | 6395 | return $resultyesno; | 
| 6396 | 6396 | } | 
| 6397 | 6397 | |
| @@ -6409,12 +6409,12 @@ discard block | ||
| 6409 | 6409 |      {
 | 
| 6410 | 6410 | // phpcs:enable | 
| 6411 | 6411 | $sql = "SELECT rowid, label"; | 
| 6412 | - $sql .= " FROM " . MAIN_DB_PREFIX . "export_model"; | |
| 6413 | - $sql .= " WHERE type = '" . $type . "'"; | |
| 6412 | + $sql .= " FROM ".MAIN_DB_PREFIX."export_model"; | |
| 6413 | + $sql .= " WHERE type = '".$type."'"; | |
| 6414 | 6414 | $sql .= " ORDER BY rowid"; | 
| 6415 | 6415 | $result = $this->db->query($sql); | 
| 6416 | 6416 |          if ($result) {
 | 
| 6417 | - print '<select class="flat" id="select_' . $htmlname . '" name="' . $htmlname . '">'; | |
| 6417 | + print '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">'; | |
| 6418 | 6418 |              if ($useempty) {
 | 
| 6419 | 6419 | print '<option value="-1"> </option>'; | 
| 6420 | 6420 | } | 
| @@ -6424,9 +6424,9 @@ discard block | ||
| 6424 | 6424 |              while ($i < $num) {
 | 
| 6425 | 6425 | $obj = $this->db->fetch_object($result); | 
| 6426 | 6426 |                  if ($selected == $obj->rowid) {
 | 
| 6427 | - print '<option value="' . $obj->rowid . '" selected>'; | |
| 6427 | + print '<option value="'.$obj->rowid.'" selected>'; | |
| 6428 | 6428 |                  } else {
 | 
| 6429 | - print '<option value="' . $obj->rowid . '">'; | |
| 6429 | + print '<option value="'.$obj->rowid.'">'; | |
| 6430 | 6430 | } | 
| 6431 | 6431 | print $obj->label; | 
| 6432 | 6432 | print '</option>'; | 
| @@ -6469,7 +6469,7 @@ discard block | ||
| 6469 | 6469 | // Add where from hooks | 
| 6470 | 6470 |          if (is_object($hookmanager)) {
 | 
| 6471 | 6471 | $parameters = array(); | 
| 6472 | -            $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object);    // Note that $action and $object may have been modified by hook
 | |
| 6472 | +            $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
 | |
| 6473 | 6473 | $object->next_prev_filter .= $hookmanager->resPrint; | 
| 6474 | 6474 | } | 
| 6475 | 6475 | $previous_ref = $next_ref = ''; | 
| @@ -6495,8 +6495,8 @@ discard block | ||
| 6495 | 6495 | $stringforfirstkey .= ' CTL +'; | 
| 6496 | 6496 | } | 
| 6497 | 6497 | |
| 6498 | - $previous_ref = $object->ref_previous ? '<a accesskey="p" title="' . $stringforfirstkey . ' p" class="classfortooltip" href="' . $navurl . '?' . $paramid . '=' . urlencode($object->ref_previous) . $moreparam . '"><i class="fa fa-chevron-left"></i></a>' : '<span class="inactive"><i class="fa fa-chevron-left opacitymedium"></i></span>'; | |
| 6499 | - $next_ref = $object->ref_next ? '<a accesskey="n" title="' . $stringforfirstkey . ' n" class="classfortooltip" href="' . $navurl . '?' . $paramid . '=' . urlencode($object->ref_next) . $moreparam . '"><i class="fa fa-chevron-right"></i></a>' : '<span class="inactive"><i class="fa fa-chevron-right opacitymedium"></i></span>'; | |
| 6498 | + $previous_ref = $object->ref_previous ? '<a accesskey="p" title="'.$stringforfirstkey.' p" class="classfortooltip" href="'.$navurl.'?'.$paramid.'='.urlencode($object->ref_previous).$moreparam.'"><i class="fa fa-chevron-left"></i></a>' : '<span class="inactive"><i class="fa fa-chevron-left opacitymedium"></i></span>'; | |
| 6499 | + $next_ref = $object->ref_next ? '<a accesskey="n" title="'.$stringforfirstkey.' n" class="classfortooltip" href="'.$navurl.'?'.$paramid.'='.urlencode($object->ref_next).$moreparam.'"><i class="fa fa-chevron-right"></i></a>' : '<span class="inactive"><i class="fa fa-chevron-right opacitymedium"></i></span>'; | |
| 6500 | 6500 | } | 
| 6501 | 6501 | |
| 6502 | 6502 | //print "xx".$previous_ref."x".$next_ref; | 
| @@ -6504,30 +6504,30 @@ discard block | ||
| 6504 | 6504 | |
| 6505 | 6505 | // Right part of banner | 
| 6506 | 6506 | if ($morehtmlright) | 
| 6507 | - $ret .= '<div class="inline-block floatleft">' . $morehtmlright . '</div>'; | |
| 6507 | + $ret .= '<div class="inline-block floatleft">'.$morehtmlright.'</div>'; | |
| 6508 | 6508 | |
| 6509 | 6509 |          if ($previous_ref || $next_ref || $morehtml) {
 | 
| 6510 | 6510 | $ret .= '<div class="pagination paginationref"><ul class="right">'; | 
| 6511 | 6511 | } | 
| 6512 | 6512 |          if ($morehtml) {
 | 
| 6513 | - $ret .= '<li class="noborder litext">' . $morehtml . '</li>'; | |
| 6513 | + $ret .= '<li class="noborder litext">'.$morehtml.'</li>'; | |
| 6514 | 6514 | } | 
| 6515 | 6515 |          if ($shownav && ($previous_ref || $next_ref)) {
 | 
| 6516 | - $ret .= '<li class="pagination">' . $previous_ref . '</li>'; | |
| 6517 | - $ret .= '<li class="pagination">' . $next_ref . '</li>'; | |
| 6516 | + $ret .= '<li class="pagination">'.$previous_ref.'</li>'; | |
| 6517 | + $ret .= '<li class="pagination">'.$next_ref.'</li>'; | |
| 6518 | 6518 | } | 
| 6519 | 6519 |          if ($previous_ref || $next_ref || $morehtml) {
 | 
| 6520 | 6520 | $ret .= '</ul></div>'; | 
| 6521 | 6521 | } | 
| 6522 | 6522 | |
| 6523 | 6523 | $parameters = array(); | 
| 6524 | -        $reshook = $hookmanager->executeHooks('moreHtmlStatus', $parameters, $object);    // Note that $action and $object may have been modified by hook
 | |
| 6524 | +        $reshook = $hookmanager->executeHooks('moreHtmlStatus', $parameters, $object); // Note that $action and $object may have been modified by hook
 | |
| 6525 | 6525 | if (empty($reshook)) | 
| 6526 | 6526 | $morehtmlstatus .= $hookmanager->resPrint; | 
| 6527 | 6527 | else | 
| 6528 | 6528 | $morehtmlstatus = $hookmanager->resPrint; | 
| 6529 | 6529 | if ($morehtmlstatus) | 
| 6530 | - $ret .= '<div class="statusref">' . $morehtmlstatus . '</div>'; | |
| 6530 | + $ret .= '<div class="statusref">'.$morehtmlstatus.'</div>'; | |
| 6531 | 6531 | |
| 6532 | 6532 | $parameters = array(); | 
| 6533 | 6533 |          $reshook = $hookmanager->executeHooks('moreHtmlRef', $parameters, $object); // Note that $action and $object may have been modified by hook
 | 
| @@ -6539,29 +6539,29 @@ discard block | ||
| 6539 | 6539 | // Left part of banner | 
| 6540 | 6540 |          if ($morehtmlleft) {
 | 
| 6541 | 6541 | if ($conf->browser->layout == 'phone') | 
| 6542 | - $ret .= '<div class="floatleft">' . $morehtmlleft . '</div>'; // class="center" to have photo in middle | |
| 6542 | + $ret .= '<div class="floatleft">'.$morehtmlleft.'</div>'; // class="center" to have photo in middle | |
| 6543 | 6543 | else | 
| 6544 | - $ret .= '<div class="inline-block floatleft">' . $morehtmlleft . '</div>'; | |
| 6544 | + $ret .= '<div class="inline-block floatleft">'.$morehtmlleft.'</div>'; | |
| 6545 | 6545 | } | 
| 6546 | 6546 | |
| 6547 | 6547 | //if ($conf->browser->layout == 'phone') $ret.='<div class="clearboth"></div>'; | 
| 6548 | - $ret .= '<div class="inline-block floatleft valignmiddle refid' . (($shownav && ($previous_ref || $next_ref)) ? ' refidpadding' : '') . '">'; | |
| 6548 | + $ret .= '<div class="inline-block floatleft valignmiddle refid'.(($shownav && ($previous_ref || $next_ref)) ? ' refidpadding' : '').'">'; | |
| 6549 | 6549 | |
| 6550 | 6550 | // For thirdparty, contact, user, member, the ref is the id, so we show something else | 
| 6551 | 6551 |          if ($object->element == 'societe') {
 | 
| 6552 | 6552 | $ret .= dol_htmlentities($object->name); | 
| 6553 | 6553 |          } else if ($object->element == 'member') {
 | 
| 6554 | - $ret .= $object->ref . '<br>'; | |
| 6554 | + $ret .= $object->ref.'<br>'; | |
| 6555 | 6555 | $fullname = $object->getFullName($langs); | 
| 6556 | 6556 |              if ($object->morphy == 'mor' && $object->societe) {
 | 
| 6557 | -                $ret .= dol_htmlentities($object->societe) . ((!empty($fullname) && $object->societe != $fullname) ? ' (' . dol_htmlentities($fullname) . ')' : '');
 | |
| 6557 | +                $ret .= dol_htmlentities($object->societe).((!empty($fullname) && $object->societe != $fullname) ? ' ('.dol_htmlentities($fullname).')' : '');
 | |
| 6558 | 6558 |              } else {
 | 
| 6559 | -                $ret .= dol_htmlentities($fullname) . ((!empty($object->societe) && $object->societe != $fullname) ? ' (' . dol_htmlentities($object->societe) . ')' : '');
 | |
| 6559 | +                $ret .= dol_htmlentities($fullname).((!empty($object->societe) && $object->societe != $fullname) ? ' ('.dol_htmlentities($object->societe).')' : '');
 | |
| 6560 | 6560 | } | 
| 6561 | 6561 |          } else if (in_array($object->element, array('contact', 'user', 'usergroup'))) {
 | 
| 6562 | 6562 | $ret .= dol_htmlentities($object->getFullName($langs)); | 
| 6563 | 6563 |          } else if (in_array($object->element, array('action', 'agenda'))) {
 | 
| 6564 | - $ret .= $object->ref . '<br>' . $object->label; | |
| 6564 | + $ret .= $object->ref.'<br>'.$object->label; | |
| 6565 | 6565 |          } else if (in_array($object->element, array('adherent_type'))) {
 | 
| 6566 | 6566 | $ret .= $object->label; | 
| 6567 | 6567 |          } else if ($object->element == 'ecm_directories') {
 | 
| @@ -6571,7 +6571,7 @@ discard block | ||
| 6571 | 6571 | |
| 6572 | 6572 | |
| 6573 | 6573 |          if ($morehtmlref) {
 | 
| 6574 | - $ret .= ' ' . $morehtmlref; | |
| 6574 | + $ret .= ' '.$morehtmlref; | |
| 6575 | 6575 | } | 
| 6576 | 6576 | $ret .= '</div>'; | 
| 6577 | 6577 | |
| @@ -6604,9 +6604,9 @@ discard block | ||
| 6604 | 6604 | } | 
| 6605 | 6605 | |
| 6606 | 6606 | // Barcode image | 
| 6607 | - $url = DOL_URL_ROOT . '/viewimage.php?modulepart=barcode&generator=' . urlencode($object->barcode_type_coder) . '&code=' . urlencode($object->barcode) . '&encoding=' . urlencode($object->barcode_type_code); | |
| 6608 | - $out = '<!-- url barcode = ' . $url . ' -->'; | |
| 6609 | - $out .= '<img src="' . $url . '">'; | |
| 6607 | + $url = DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($object->barcode_type_coder).'&code='.urlencode($object->barcode).'&encoding='.urlencode($object->barcode_type_code); | |
| 6608 | + $out = '<!-- url barcode = '.$url.' -->'; | |
| 6609 | + $out .= '<img src="'.$url.'">'; | |
| 6610 | 6610 | return $out; | 
| 6611 | 6611 | } | 
| 6612 | 6612 | |
| @@ -6643,25 +6643,25 @@ discard block | ||
| 6643 | 6643 | $dir = $conf->societe->multidir_output[$entity]; | 
| 6644 | 6644 |              if (!empty($object->logo)) {
 | 
| 6645 | 6645 | if ((string) $imagesize == 'mini') | 
| 6646 | - $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty') . '/logos/' . getImageFileNameForSize($object->logo, '_mini'); // getImageFileNameForSize include the thumbs | |
| 6646 | + $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'/logos/'.getImageFileNameForSize($object->logo, '_mini'); // getImageFileNameForSize include the thumbs | |
| 6647 | 6647 | else if ((string) $imagesize == 'small') | 
| 6648 | - $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty') . '/logos/' . getImageFileNameForSize($object->logo, '_small'); | |
| 6648 | + $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'/logos/'.getImageFileNameForSize($object->logo, '_small'); | |
| 6649 | 6649 | else | 
| 6650 | - $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty') . '/logos/' . $object->logo; | |
| 6651 | - $originalfile = get_exdir(0, 0, 0, 0, $object, 'thirdparty') . '/logos/' . $object->logo; | |
| 6650 | + $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'/logos/'.$object->logo; | |
| 6651 | + $originalfile = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'/logos/'.$object->logo; | |
| 6652 | 6652 | } | 
| 6653 | 6653 | $email = $object->email; | 
| 6654 | 6654 | } | 
| 6655 | 6655 |          else if ($modulepart == 'contact') {
 | 
| 6656 | - $dir = $conf->societe->multidir_output[$entity] . '/contact'; | |
| 6656 | + $dir = $conf->societe->multidir_output[$entity].'/contact'; | |
| 6657 | 6657 |              if (!empty($object->photo)) {
 | 
| 6658 | 6658 | if ((string) $imagesize == 'mini') | 
| 6659 | - $file = get_exdir(0, 0, 0, 0, $object, 'contact') . '/photos/' . getImageFileNameForSize($object->photo, '_mini'); | |
| 6659 | + $file = get_exdir(0, 0, 0, 0, $object, 'contact').'/photos/'.getImageFileNameForSize($object->photo, '_mini'); | |
| 6660 | 6660 | else if ((string) $imagesize == 'small') | 
| 6661 | - $file = get_exdir(0, 0, 0, 0, $object, 'contact') . '/photos/' . getImageFileNameForSize($object->photo, '_small'); | |
| 6661 | + $file = get_exdir(0, 0, 0, 0, $object, 'contact').'/photos/'.getImageFileNameForSize($object->photo, '_small'); | |
| 6662 | 6662 | else | 
| 6663 | - $file = get_exdir(0, 0, 0, 0, $object, 'contact') . '/photos/' . $object->photo; | |
| 6664 | - $originalfile = get_exdir(0, 0, 0, 0, $object, 'contact') . '/photos/' . $object->photo; | |
| 6663 | + $file = get_exdir(0, 0, 0, 0, $object, 'contact').'/photos/'.$object->photo; | |
| 6664 | + $originalfile = get_exdir(0, 0, 0, 0, $object, 'contact').'/photos/'.$object->photo; | |
| 6665 | 6665 | } | 
| 6666 | 6666 | $email = $object->email; | 
| 6667 | 6667 | $capture = 'user'; | 
| @@ -6670,15 +6670,15 @@ discard block | ||
| 6670 | 6670 | $dir = $conf->user->dir_output; | 
| 6671 | 6671 |              if (!empty($object->photo)) {
 | 
| 6672 | 6672 | if ((string) $imagesize == 'mini') | 
| 6673 | - $file = get_exdir(0, 0, 0, 0, $object, 'user') . $object->id . '/' . getImageFileNameForSize($object->photo, '_mini'); | |
| 6673 | + $file = get_exdir(0, 0, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_mini'); | |
| 6674 | 6674 | else if ((string) $imagesize == 'small') | 
| 6675 | - $file = get_exdir(0, 0, 0, 0, $object, 'user') . $object->id . '/' . getImageFileNameForSize($object->photo, '_small'); | |
| 6675 | + $file = get_exdir(0, 0, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_small'); | |
| 6676 | 6676 | else | 
| 6677 | - $file = get_exdir(0, 0, 0, 0, $object, 'user') . '/' . $object->id . '/' . $object->photo; | |
| 6678 | - $originalfile = get_exdir(0, 0, 0, 0, $object, 'user') . '/' . $object->id . '/' . $object->photo; | |
| 6677 | + $file = get_exdir(0, 0, 0, 0, $object, 'user').'/'.$object->id.'/'.$object->photo; | |
| 6678 | + $originalfile = get_exdir(0, 0, 0, 0, $object, 'user').'/'.$object->id.'/'.$object->photo; | |
| 6679 | 6679 | } | 
| 6680 | 6680 | if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) | 
| 6681 | - $altfile = $object->id . ".jpg"; // For backward compatibility | |
| 6681 | + $altfile = $object->id.".jpg"; // For backward compatibility | |
| 6682 | 6682 | $email = $object->email; | 
| 6683 | 6683 | $capture = 'user'; | 
| 6684 | 6684 | } | 
| @@ -6686,15 +6686,15 @@ discard block | ||
| 6686 | 6686 | $dir = $conf->adherent->dir_output; | 
| 6687 | 6687 |              if (!empty($object->photo)) {
 | 
| 6688 | 6688 | if ((string) $imagesize == 'mini') | 
| 6689 | - $file = get_exdir(0, 0, 0, 0, $object, 'member') . 'photos/' . getImageFileNameForSize($object->photo, '_mini'); | |
| 6689 | + $file = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.getImageFileNameForSize($object->photo, '_mini'); | |
| 6690 | 6690 | else if ((string) $imagesize == 'small') | 
| 6691 | - $file = get_exdir(0, 0, 0, 0, $object, 'member') . 'photos/' . getImageFileNameForSize($object->photo, '_small'); | |
| 6691 | + $file = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.getImageFileNameForSize($object->photo, '_small'); | |
| 6692 | 6692 | else | 
| 6693 | - $file = get_exdir(0, 0, 0, 0, $object, 'member') . 'photos/' . $object->photo; | |
| 6694 | - $originalfile = get_exdir(0, 0, 0, 0, $object, 'member') . 'photos/' . $object->photo; | |
| 6693 | + $file = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.$object->photo; | |
| 6694 | + $originalfile = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.$object->photo; | |
| 6695 | 6695 | } | 
| 6696 | 6696 | if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) | 
| 6697 | - $altfile = $object->id . ".jpg"; // For backward compatibility | |
| 6697 | + $altfile = $object->id.".jpg"; // For backward compatibility | |
| 6698 | 6698 | $email = $object->email; | 
| 6699 | 6699 | $capture = 'user'; | 
| 6700 | 6700 | } | 
| @@ -6703,15 +6703,15 @@ discard block | ||
| 6703 | 6703 | $dir = $conf->$modulepart->dir_output; | 
| 6704 | 6704 |              if (!empty($object->photo)) {
 | 
| 6705 | 6705 | if ((string) $imagesize == 'mini') | 
| 6706 | - $file = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . getImageFileNameForSize($object->photo, '_mini'); | |
| 6706 | + $file = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.getImageFileNameForSize($object->photo, '_mini'); | |
| 6707 | 6707 | else if ((string) $imagesize == 'small') | 
| 6708 | - $file = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . getImageFileNameForSize($object->photo, '_small'); | |
| 6708 | + $file = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.getImageFileNameForSize($object->photo, '_small'); | |
| 6709 | 6709 | else | 
| 6710 | - $file = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . $object->photo; | |
| 6711 | - $originalfile = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . $object->photo; | |
| 6710 | + $file = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.$object->photo; | |
| 6711 | + $originalfile = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.$object->photo; | |
| 6712 | 6712 | } | 
| 6713 | 6713 | if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) | 
| 6714 | - $altfile = $object->id . ".jpg"; // For backward compatibility | |
| 6714 | + $altfile = $object->id.".jpg"; // For backward compatibility | |
| 6715 | 6715 | $email = $object->email; | 
| 6716 | 6716 | } | 
| 6717 | 6717 | |
| @@ -6719,27 +6719,27 @@ discard block | ||
| 6719 | 6719 | $capture = $forcecapture; | 
| 6720 | 6720 | |
| 6721 | 6721 |          if ($dir) {
 | 
| 6722 | -            if ($file && file_exists($dir . "/" . $file)) {
 | |
| 6722 | +            if ($file && file_exists($dir."/".$file)) {
 | |
| 6723 | 6723 |                  if ($addlinktofullsize) {
 | 
| 6724 | - $urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 0, '&entity=' . $entity); | |
| 6724 | + $urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 0, '&entity='.$entity); | |
| 6725 | 6725 | if ($urladvanced) | 
| 6726 | - $ret .= '<a href="' . $urladvanced . '">'; | |
| 6726 | + $ret .= '<a href="'.$urladvanced.'">'; | |
| 6727 | 6727 | else | 
| 6728 | - $ret .= '<a href="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($originalfile) . '&cache=' . $cache . '">'; | |
| 6728 | + $ret .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">'; | |
| 6729 | 6729 | } | 
| 6730 | -                $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 . '">';
 | |
| 6730 | +                $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 | 6731 | if ($addlinktofullsize) | 
| 6732 | 6732 | $ret .= '</a>'; | 
| 6733 | 6733 | } | 
| 6734 | -            else if ($altfile && file_exists($dir . "/" . $altfile)) {
 | |
| 6734 | +            else if ($altfile && file_exists($dir."/".$altfile)) {
 | |
| 6735 | 6735 |                  if ($addlinktofullsize) {
 | 
| 6736 | - $urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 0, '&entity=' . $entity); | |
| 6736 | + $urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 0, '&entity='.$entity); | |
| 6737 | 6737 | if ($urladvanced) | 
| 6738 | - $ret .= '<a href="' . $urladvanced . '">'; | |
| 6738 | + $ret .= '<a href="'.$urladvanced.'">'; | |
| 6739 | 6739 | else | 
| 6740 | - $ret .= '<a href="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($originalfile) . '&cache=' . $cache . '">'; | |
| 6740 | + $ret .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">'; | |
| 6741 | 6741 | } | 
| 6742 | -                $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 . '">';
 | |
| 6742 | +                $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 | 6743 | if ($addlinktofullsize) | 
| 6744 | 6744 | $ret .= '</a>'; | 
| 6745 | 6745 | } | 
| @@ -6763,10 +6763,10 @@ discard block | ||
| 6763 | 6763 | $ret .= '<!-- Put link to gravatar -->'; | 
| 6764 | 6764 | //$defaultimg=urlencode(dol_buildpath($nophoto,3)); | 
| 6765 | 6765 | $defaultimg = 'mm'; | 
| 6766 | - $ret .= '<img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="Gravatar avatar" title="' . $email . ' Gravatar avatar" ' . ($width ? ' width="' . $width . '"' : '') . ($height ? ' height="' . $height . '"' : '') . ' src="https://www.gravatar.com/avatar/' . dol_hash(strtolower(trim($email)), 3) . '?s=' . $width . '&d=' . $defaultimg . '">'; // gravatar need md5 hash | |
| 6766 | + $ret .= '<img class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').'" alt="Gravatar avatar" title="'.$email.' Gravatar avatar" '.($width ? ' width="'.$width.'"' : '').($height ? ' height="'.$height.'"' : '').' src="https://www.gravatar.com/avatar/'.dol_hash(strtolower(trim($email)), 3).'?s='.$width.'&d='.$defaultimg.'">'; // gravatar need md5 hash | |
| 6767 | 6767 |                  } else {
 | 
| 6768 | 6768 | //$ret .= '<img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" ' . ($width ? ' width="' . $width . '"' : '') . ($height ? ' height="' . $height . '"' : '') . ' src="' . DOL_URL_ROOT . $nophoto . '">'; | 
| 6769 | - $ret .= '<img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" ' . ($width ? ' width="' . $width . '"' : '') . ($height ? ' height="' . $height . '"' : '') . ' src="' . DOL_BASE_URI . $nophoto . '">'; | |
| 6769 | + $ret .= '<img class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').'" alt="No photo" '.($width ? ' width="'.$width.'"' : '').($height ? ' height="'.$height.'"' : '').' src="'.DOL_BASE_URI.$nophoto.'">'; | |
| 6770 | 6770 | } | 
| 6771 | 6771 | } | 
| 6772 | 6772 | |
| @@ -6776,13 +6776,13 @@ discard block | ||
| 6776 | 6776 | } | 
| 6777 | 6777 | $ret .= '<table class="nobordernopadding centpercent">'; | 
| 6778 | 6778 |                  if ($object->photo) {
 | 
| 6779 | -                    $ret .= '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> ' . $langs->trans("Delete") . '<br><br></td></tr>';
 | |
| 6779 | +                    $ret .= '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
 | |
| 6780 | 6780 | } | 
| 6781 | - $ret .= '<tr><td class="tdoverflow"><input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput"' . ($capture ? ' capture="' . $capture . '"' : '') . '></td></tr>'; | |
| 6781 | + $ret .= '<tr><td class="tdoverflow"><input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput"'.($capture ? ' capture="'.$capture.'"' : '').'></td></tr>'; | |
| 6782 | 6782 | $ret .= '</table>'; | 
| 6783 | 6783 | } | 
| 6784 | 6784 | } else | 
| 6785 | -            dol_print_error('', 'Call of showphoto with wrong parameters modulepart=' . $modulepart);
 | |
| 6785 | +            dol_print_error('', 'Call of showphoto with wrong parameters modulepart='.$modulepart);
 | |
| 6786 | 6786 | |
| 6787 | 6787 | return $ret; | 
| 6788 | 6788 | } | 
| @@ -6825,37 +6825,37 @@ discard block | ||
| 6825 | 6825 |          if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
 | 
| 6826 | 6826 | $sql .= ", e.label"; | 
| 6827 | 6827 | } | 
| 6828 | - $sql .= " FROM " . MAIN_DB_PREFIX . "usergroup as ug "; | |
| 6828 | + $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as ug "; | |
| 6829 | 6829 |          if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
 | 
| 6830 | - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "entity as e ON e.rowid=ug.entity"; | |
| 6830 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entity as e ON e.rowid=ug.entity"; | |
| 6831 | 6831 | if ($force_entity) | 
| 6832 | - $sql .= " WHERE ug.entity IN (0," . $force_entity . ")"; | |
| 6832 | + $sql .= " WHERE ug.entity IN (0,".$force_entity.")"; | |
| 6833 | 6833 | else | 
| 6834 | 6834 | $sql .= " WHERE ug.entity IS NOT NULL"; | 
| 6835 | 6835 | } | 
| 6836 | 6836 |          else {
 | 
| 6837 | - $sql .= " WHERE ug.entity IN (0," . $conf->entity . ")"; | |
| 6837 | + $sql .= " WHERE ug.entity IN (0,".$conf->entity.")"; | |
| 6838 | 6838 | } | 
| 6839 | 6839 | if (is_array($exclude) && $excludeGroups) | 
| 6840 | -            $sql .= " AND ug.rowid NOT IN ('" . $excludeGroups . "')";
 | |
| 6840 | +            $sql .= " AND ug.rowid NOT IN ('".$excludeGroups."')";
 | |
| 6841 | 6841 | if (is_array($include) && $includeGroups) | 
| 6842 | -            $sql .= " AND ug.rowid IN ('" . $includeGroups . "')";
 | |
| 6842 | +            $sql .= " AND ug.rowid IN ('".$includeGroups."')";
 | |
| 6843 | 6843 | $sql .= " ORDER BY ug.nom ASC"; | 
| 6844 | 6844 | |
| 6845 | - dol_syslog(get_class($this) . "::select_dolgroups", LOG_DEBUG); | |
| 6845 | + dol_syslog(get_class($this)."::select_dolgroups", LOG_DEBUG); | |
| 6846 | 6846 | $resql = $this->db->query($sql); | 
| 6847 | 6847 |          if ($resql) {
 | 
| 6848 | 6848 | // Enhance with select2 | 
| 6849 | - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; | |
| 6849 | + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; | |
| 6850 | 6850 | $out .= ajax_combobox($htmlname); | 
| 6851 | 6851 | |
| 6852 | - $out .= '<select class="flat minwidth200" id="' . $htmlname . '" name="' . $htmlname . ($multiple ? '[]' : '') . '" ' . ($multiple ? 'multiple' : '') . ' ' . ($disabled ? ' disabled' : '') . '>'; | |
| 6852 | + $out .= '<select class="flat minwidth200" id="'.$htmlname.'" name="'.$htmlname.($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').' '.($disabled ? ' disabled' : '').'>'; | |
| 6853 | 6853 | |
| 6854 | 6854 | $num = $this->db->num_rows($resql); | 
| 6855 | 6855 | $i = 0; | 
| 6856 | 6856 |              if ($num) {
 | 
| 6857 | 6857 | if ($show_empty && !$multiple) | 
| 6858 | - $out .= '<option value="-1"' . (in_array(-1, $selected) ? ' selected' : '') . '> </option>' . "\n"; | |
| 6858 | + $out .= '<option value="-1"'.(in_array(-1, $selected) ? ' selected' : '').'> </option>'."\n"; | |
| 6859 | 6859 | |
| 6860 | 6860 |                  while ($i < $num) {
 | 
| 6861 | 6861 | $obj = $this->db->fetch_object($resql); | 
| @@ -6863,17 +6863,17 @@ discard block | ||
| 6863 | 6863 | if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) | 
| 6864 | 6864 | $disableline = 1; | 
| 6865 | 6865 | |
| 6866 | - $out .= '<option value="' . $obj->rowid . '"'; | |
| 6866 | + $out .= '<option value="'.$obj->rowid.'"'; | |
| 6867 | 6867 | if ($disableline) | 
| 6868 | 6868 | $out .= ' disabled'; | 
| 6869 | -                    if ((is_object($selected[0]) && $selected[0]->id == $obj->rowid) || (!is_object($selected[0]) && in_array($obj->rowid, $selected) )) {
 | |
| 6869 | +                    if ((is_object($selected[0]) && $selected[0]->id == $obj->rowid) || (!is_object($selected[0]) && in_array($obj->rowid, $selected))) {
 | |
| 6870 | 6870 | $out .= ' selected'; | 
| 6871 | 6871 | } | 
| 6872 | 6872 | $out .= '>'; | 
| 6873 | 6873 | |
| 6874 | 6874 | $out .= $obj->name; | 
| 6875 | 6875 |                      if (!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) {
 | 
| 6876 | -                        $out .= " (" . $obj->label . ")";
 | |
| 6876 | +                        $out .= " (".$obj->label.")";
 | |
| 6877 | 6877 | } | 
| 6878 | 6878 | |
| 6879 | 6879 | $out .= '</option>'; | 
| @@ -6881,8 +6881,8 @@ discard block | ||
| 6881 | 6881 | } | 
| 6882 | 6882 |              } else {
 | 
| 6883 | 6883 | if ($show_empty) | 
| 6884 | - $out .= '<option value="-1"' . (in_array(-1, $selected) ? ' selected' : '') . '></option>' . "\n"; | |
| 6885 | -                $out .= '<option value="" disabled>' . $langs->trans("NoUserGroupDefined") . '</option>';
 | |
| 6884 | + $out .= '<option value="-1"'.(in_array(-1, $selected) ? ' selected' : '').'></option>'."\n"; | |
| 6885 | +                $out .= '<option value="" disabled>'.$langs->trans("NoUserGroupDefined").'</option>';
 | |
| 6886 | 6886 | } | 
| 6887 | 6887 | $out .= '</select>'; | 
| 6888 | 6888 | } | 
| @@ -6903,8 +6903,8 @@ discard block | ||
| 6903 | 6903 | global $conf, $langs; | 
| 6904 | 6904 | |
| 6905 | 6905 | $out = '<div class="nowrap">'; | 
| 6906 | -        $out .= '<input type="image" class="liste_titre" name="button_search" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
 | |
| 6907 | -        $out .= '<input type="image" class="liste_titre" name="button_removefilter" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
 | |
| 6906 | +        $out .= '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"), 'search.png', '', '', 1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
 | |
| 6907 | +        $out .= '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
 | |
| 6908 | 6908 | $out .= '</div>'; | 
| 6909 | 6909 | |
| 6910 | 6910 | return $out; | 
| @@ -6929,12 +6929,12 @@ discard block | ||
| 6929 | 6929 |              	$("#checkallactions").click(function() {
 | 
| 6930 | 6930 |                      if($(this).is(\':checked\')){
 | 
| 6931 | 6931 |                          console.log("We check all");
 | 
| 6932 | -                		$(".' . $cssclass . '").prop(\'checked\', true).trigger(\'change\');
 | |
| 6932 | +                		$(".' . $cssclass.'").prop(\'checked\', true).trigger(\'change\');
 | |
| 6933 | 6933 | } | 
| 6934 | 6934 | else | 
| 6935 | 6935 |                      {
 | 
| 6936 | 6936 |                          console.log("We uncheck all");
 | 
| 6937 | -                		$(".' . $cssclass . '").prop(\'checked\', false).trigger(\'change\');
 | |
| 6937 | +                		$(".' . $cssclass.'").prop(\'checked\', false).trigger(\'change\');
 | |
| 6938 | 6938 | }' . "\n"; | 
| 6939 | 6939 | if ($calljsfunction) | 
| 6940 | 6940 |              $out .= 'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }';
 | 
| @@ -6983,64 +6983,64 @@ discard block | ||
| 6983 | 6983 |      {
 | 
| 6984 | 6984 | global $db, $conf, $langs, $user; | 
| 6985 | 6985 | |
| 6986 | - $sql = 'SELECT rowid, label FROM ' . MAIN_DB_PREFIX . 'c_exp_tax_cat WHERE active = 1'; | |
| 6987 | -        $sql .= ' AND entity IN (0,' . getEntity('exp_tax_cat') . ')';
 | |
| 6986 | + $sql = 'SELECT rowid, label FROM '.MAIN_DB_PREFIX.'c_exp_tax_cat WHERE active = 1'; | |
| 6987 | +        $sql .= ' AND entity IN (0,'.getEntity('exp_tax_cat').')';
 | |
| 6988 | 6988 | if (!empty($excludeid)) | 
| 6989 | -            $sql .= ' AND rowid NOT IN (' . implode(',', $excludeid) . ')';
 | |
| 6989 | +            $sql .= ' AND rowid NOT IN ('.implode(',', $excludeid).')';
 | |
| 6990 | 6990 | $sql .= ' ORDER BY label'; | 
| 6991 | 6991 | |
| 6992 | 6992 | $resql = $db->query($sql); | 
| 6993 | 6993 |          if ($resql) {
 | 
| 6994 | - $out = '<select id="select_' . $htmlname . '" name="' . $htmlname . '" class="' . $htmlname . ' flat minwidth75imp">'; | |
| 6994 | + $out = '<select id="select_'.$htmlname.'" name="'.$htmlname.'" class="'.$htmlname.' flat minwidth75imp">'; | |
| 6995 | 6995 | if ($useempty) | 
| 6996 | 6996 | $out .= '<option value="0"> </option>'; | 
| 6997 | 6997 | |
| 6998 | 6998 |              while ($obj = $db->fetch_object($resql)) {
 | 
| 6999 | - $out .= '<option ' . ($selected == $obj->rowid ? 'selected="selected"' : '') . ' value="' . $obj->rowid . '">' . $langs->trans($obj->label) . '</option>'; | |
| 6999 | + $out .= '<option '.($selected == $obj->rowid ? 'selected="selected"' : '').' value="'.$obj->rowid.'">'.$langs->trans($obj->label).'</option>'; | |
| 7000 | 7000 | } | 
| 7001 | 7001 | $out .= '</select>'; | 
| 7002 | 7002 | if (!empty($htmlname) && $user->admin) | 
| 7003 | -                $out .= ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
 | |
| 7003 | +                $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
 | |
| 7004 | 7004 | |
| 7005 | 7005 |              if (!empty($target)) {
 | 
| 7006 | - $sql = "SELECT c.id FROM " . MAIN_DB_PREFIX . "c_type_fees as c WHERE c.code = 'EX_KME' AND c.active = 1"; | |
| 7006 | + $sql = "SELECT c.id FROM ".MAIN_DB_PREFIX."c_type_fees as c WHERE c.code = 'EX_KME' AND c.active = 1"; | |
| 7007 | 7007 | $resql = $db->query($sql); | 
| 7008 | 7008 |                  if ($resql) {
 | 
| 7009 | 7009 |                      if ($db->num_rows($resql) > 0) {
 | 
| 7010 | 7010 | $obj = $db->fetch_object($resql); | 
| 7011 | 7011 | $out .= '<script type="text/javascript"> | 
| 7012 | 7012 |  							$(function() {
 | 
| 7013 | -								$("select[name=' . $target . ']").on("change", function() {
 | |
| 7013 | +								$("select[name=' . $target.']").on("change", function() {
 | |
| 7014 | 7014 | var current_val = $(this).val(); | 
| 7015 | -									if (current_val == ' . $obj->id . ') {';
 | |
| 7015 | +									if (current_val == ' . $obj->id.') {';
 | |
| 7016 | 7016 | if (!empty($default_selected) || !empty($selected)) | 
| 7017 | -                            $out .= '$("select[name=' . $htmlname . ']").val("' . ($default_selected > 0 ? $default_selected : $selected) . '");';
 | |
| 7017 | +                            $out .= '$("select[name='.$htmlname.']").val("'.($default_selected > 0 ? $default_selected : $selected).'");';
 | |
| 7018 | 7018 | |
| 7019 | 7019 | $out .= ' | 
| 7020 | -										$("select[name=' . $htmlname . ']").change();
 | |
| 7020 | +										$("select[name=' . $htmlname.']").change();
 | |
| 7021 | 7021 | } | 
| 7022 | 7022 | }); | 
| 7023 | 7023 | |
| 7024 | -								$("select[name=' . $htmlname . ']").change(function() {
 | |
| 7024 | +								$("select[name=' . $htmlname.']").change(function() {
 | |
| 7025 | 7025 | |
| 7026 | -									if ($("select[name=' . $target . ']").val() == ' . $obj->id . ') {
 | |
| 7026 | +									if ($("select[name=' . $target.']").val() == '.$obj->id.') {
 | |
| 7027 | 7027 | // get price of kilometer to fill the unit price | 
| 7028 | - var data = ' . json_encode($params) . '; | |
| 7028 | + var data = ' . json_encode($params).'; | |
| 7029 | 7029 | data.fk_c_exp_tax_cat = $(this).val(); | 
| 7030 | 7030 | |
| 7031 | 7031 |  										$.ajax({
 | 
| 7032 | 7032 | method: "POST", | 
| 7033 | 7033 | dataType: "json", | 
| 7034 | 7034 | data: data, | 
| 7035 | - url: "' . (DOL_URL_ROOT . '/expensereport/ajax/ajaxik.php') . '", | |
| 7035 | + url: "' . (DOL_URL_ROOT.'/expensereport/ajax/ajaxik.php').'", | |
| 7036 | 7036 |  										}).done(function( data, textStatus, jqXHR ) {
 | 
| 7037 | 7037 | console.log(data); | 
| 7038 | 7038 |  											if (typeof data.up != "undefined") {
 | 
| 7039 | 7039 |  												$("input[name=value_unit]").val(data.up);
 | 
| 7040 | -												$("select[name=' . $htmlname . ']").attr("title", data.title);
 | |
| 7040 | +												$("select[name=' . $htmlname.']").attr("title", data.title);
 | |
| 7041 | 7041 |  											} else {
 | 
| 7042 | 7042 |  												$("input[name=value_unit]").val("");
 | 
| 7043 | -												$("select[name=' . $htmlname . ']").attr("title", "");
 | |
| 7043 | +												$("select[name=' . $htmlname.']").attr("title", "");
 | |
| 7044 | 7044 | } | 
| 7045 | 7045 | }); | 
| 7046 | 7046 | } | 
| @@ -7070,17 +7070,17 @@ discard block | ||
| 7070 | 7070 |      {
 | 
| 7071 | 7071 | global $db, $conf, $langs; | 
| 7072 | 7072 | |
| 7073 | - $sql = 'SELECT rowid, range_ik FROM ' . MAIN_DB_PREFIX . 'c_exp_tax_range'; | |
| 7074 | - $sql .= ' WHERE entity = ' . $conf->entity . ' AND active = 1'; | |
| 7073 | + $sql = 'SELECT rowid, range_ik FROM '.MAIN_DB_PREFIX.'c_exp_tax_range'; | |
| 7074 | + $sql .= ' WHERE entity = '.$conf->entity.' AND active = 1'; | |
| 7075 | 7075 | |
| 7076 | 7076 | $resql = $db->query($sql); | 
| 7077 | 7077 |          if ($resql) {
 | 
| 7078 | - $out = '<select id="select_' . $htmlname . '" name="' . $htmlname . '" class="' . $htmlname . ' flat minwidth75imp">'; | |
| 7078 | + $out = '<select id="select_'.$htmlname.'" name="'.$htmlname.'" class="'.$htmlname.' flat minwidth75imp">'; | |
| 7079 | 7079 | if ($useempty) | 
| 7080 | 7080 | $out .= '<option value="0"></option>'; | 
| 7081 | 7081 | |
| 7082 | 7082 |              while ($obj = $db->fetch_object($resql)) {
 | 
| 7083 | - $out .= '<option ' . ($selected == $obj->rowid ? 'selected="selected"' : '') . ' value="' . $obj->rowid . '">' . price($obj->range_ik, 0, $langs, 1, 0) . '</option>'; | |
| 7083 | + $out .= '<option '.($selected == $obj->rowid ? 'selected="selected"' : '').' value="'.$obj->rowid.'">'.price($obj->range_ik, 0, $langs, 1, 0).'</option>'; | |
| 7084 | 7084 | } | 
| 7085 | 7085 | $out .= '</select>'; | 
| 7086 | 7086 |          } else {
 | 
| @@ -7104,16 +7104,16 @@ discard block | ||
| 7104 | 7104 |      {
 | 
| 7105 | 7105 | global $db, $langs; | 
| 7106 | 7106 | |
| 7107 | - $sql = 'SELECT id, code, label FROM ' . MAIN_DB_PREFIX . 'c_type_fees'; | |
| 7107 | + $sql = 'SELECT id, code, label FROM '.MAIN_DB_PREFIX.'c_type_fees'; | |
| 7108 | 7108 | $sql .= ' WHERE active = 1'; | 
| 7109 | 7109 | |
| 7110 | 7110 | $resql = $db->query($sql); | 
| 7111 | 7111 |          if ($resql) {
 | 
| 7112 | - $out = '<select id="select_' . $htmlname . '" name="' . $htmlname . '" class="' . $htmlname . ' flat minwidth75imp">'; | |
| 7112 | + $out = '<select id="select_'.$htmlname.'" name="'.$htmlname.'" class="'.$htmlname.' flat minwidth75imp">'; | |
| 7113 | 7113 | if ($useempty) | 
| 7114 | 7114 | $out .= '<option value="0"></option>'; | 
| 7115 | 7115 | if ($allchoice) | 
| 7116 | -                $out .= '<option value="-1">' . $langs->trans('AllExpenseReport') . '</option>';
 | |
| 7116 | +                $out .= '<option value="-1">'.$langs->trans('AllExpenseReport').'</option>';
 | |
| 7117 | 7117 | |
| 7118 | 7118 | $field = 'code'; | 
| 7119 | 7119 | if ($useid) | 
| @@ -7121,7 +7121,7 @@ discard block | ||
| 7121 | 7121 | |
| 7122 | 7122 |              while ($obj = $db->fetch_object($resql)) {
 | 
| 7123 | 7123 | $key = $langs->trans($obj->code); | 
| 7124 | -                $out .= '<option ' . ($selected == $obj->{$field} ? 'selected="selected"' : '') . ' value="' . $obj->{$field} . '">' . ($key != $obj->code ? $key : $obj->label) . '</option>';
 | |
| 7124 | +                $out .= '<option '.($selected == $obj->{$field} ? 'selected="selected"' : '').' value="'.$obj->{$field}.'">'.($key != $obj->code ? $key : $obj->label).'</option>';
 | |
| 7125 | 7125 | } | 
| 7126 | 7126 | $out .= '</select>'; | 
| 7127 | 7127 |          } else {
 | 
| @@ -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); | 
| @@ -28,12 +28,12 @@ discard block | ||
| 28 | 28 | * \brief Member's type setup | 
| 29 | 29 | */ | 
| 30 | 30 | |
| 31 | -require DOL_BASE_PATH . '/main.inc.php'; | |
| 31 | +require DOL_BASE_PATH.'/main.inc.php'; | |
| 32 | 32 | |
| 33 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/member.lib.php'; | |
| 34 | -require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; | |
| 35 | -require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent_type.class.php'; | |
| 36 | -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; | |
| 33 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; | |
| 34 | +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; | |
| 35 | +require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; | |
| 36 | +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; | |
| 37 | 37 | |
| 38 | 38 |  $langs->load("members");
 | 
| 39 | 39 | |
| @@ -101,7 +101,7 @@ discard block | ||
| 101 | 101 | $action = ''; | 
| 102 | 102 | |
| 103 | 103 |      if (!empty($backtopage)) {
 | 
| 104 | -        header("Location: " . $backtopage);
 | |
| 104 | +        header("Location: ".$backtopage);
 | |
| 105 | 105 | exit; | 
| 106 | 106 | } | 
| 107 | 107 | } | 
| @@ -122,7 +122,7 @@ discard block | ||
| 122 | 122 | $error++; | 
| 123 | 123 |          setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
 | 
| 124 | 124 |      } else {
 | 
| 125 | - $sql = "SELECT libelle FROM " . MAIN_DB_PREFIX . "adherent_type WHERE libelle='" . $db->escape($object->label) . "'"; | |
| 125 | + $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."adherent_type WHERE libelle='".$db->escape($object->label)."'"; | |
| 126 | 126 | $result = $db->query($sql); | 
| 127 | 127 |          if ($result) {
 | 
| 128 | 128 | $num = $db->num_rows($result); | 
| @@ -137,7 +137,7 @@ discard block | ||
| 137 | 137 |      if (!$error) {
 | 
| 138 | 138 | $id = $object->create($user); | 
| 139 | 139 |          if ($id > 0) {
 | 
| 140 | -            header("Location: " . $_SERVER["PHP_SELF"]);
 | |
| 140 | +            header("Location: ".$_SERVER["PHP_SELF"]);
 | |
| 141 | 141 | exit; | 
| 142 | 142 |          } else {
 | 
| 143 | 143 | setEventMessages($object->error, $object->errors, 'errors'); | 
| @@ -173,7 +173,7 @@ discard block | ||
| 173 | 173 | } | 
| 174 | 174 | |
| 175 | 175 |      //header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$object->id);
 | 
| 176 | -    header("Location: " . $_SERVER["PHP_SELF"] . "&rowid=" . $object->id);
 | |
| 176 | +    header("Location: ".$_SERVER["PHP_SELF"]."&rowid=".$object->id);
 | |
| 177 | 177 | exit; | 
| 178 | 178 | } | 
| 179 | 179 | |
| @@ -183,7 +183,7 @@ discard block | ||
| 183 | 183 | |
| 184 | 184 |      if ($res > 0) {
 | 
| 185 | 185 |          setEventMessages($langs->trans("MemberTypeDeleted"), null, 'mesgs');
 | 
| 186 | -        header("Location: " . $_SERVER["PHP_SELF"]);
 | |
| 186 | +        header("Location: ".$_SERVER["PHP_SELF"]);
 | |
| 187 | 187 | exit; | 
| 188 | 188 |      } else {
 | 
| 189 | 189 |          setEventMessages($langs->trans("MemberTypeCanNotBeDeleted"), null, 'errors');
 | 
| @@ -206,8 +206,8 @@ discard block | ||
| 206 | 206 |      //dol_fiche_head('');
 | 
| 207 | 207 | |
| 208 | 208 | $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote"; | 
| 209 | - $sql .= " FROM " . MAIN_DB_PREFIX . "adherent_type as d"; | |
| 210 | -    $sql .= " WHERE d.entity IN (" . getEntity('member_type') . ")";
 | |
| 209 | + $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; | |
| 210 | +    $sql .= " WHERE d.entity IN (".getEntity('member_type').")";
 | |
| 211 | 211 | |
| 212 | 212 | $result = $db->query($sql); | 
| 213 | 213 |      if ($result) {
 | 
| @@ -220,35 +220,35 @@ discard block | ||
| 220 | 220 | |
| 221 | 221 | $newcardbutton = ''; | 
| 222 | 222 |          if ($user->rights->adherent->configurer) {
 | 
| 223 | -            $newcardbutton = '<a class="butActionNew" href="' . DOL_URL_ROOT . '/adherents/type.php?action=create"><span class="valignmiddle">' . $langs->trans('NewMemberType') . '</span>';
 | |
| 223 | +            $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/adherents/type.php?action=create"><span class="valignmiddle">'.$langs->trans('NewMemberType').'</span>';
 | |
| 224 | 224 | $newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>'; | 
| 225 | 225 | $newcardbutton .= '</a>'; | 
| 226 | 226 | } | 
| 227 | 227 | |
| 228 | 228 | // print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; | 
| 229 | - print '<form method="POST" href="' . $_SERVER["PHP_SELF"] . '">'; | |
| 229 | + print '<form method="POST" href="'.$_SERVER["PHP_SELF"].'">'; | |
| 230 | 230 |          if ($optioncss != '') {
 | 
| 231 | - print '<input type="hidden" name="optioncss" value="' . $optioncss . '">'; | |
| 231 | + print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; | |
| 232 | 232 | } | 
| 233 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 233 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 234 | 234 | print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; | 
| 235 | 235 | print '<input type="hidden" name="action" value="list">'; | 
| 236 | - print '<input type="hidden" name="sortfield" value="' . $sortfield . '">'; | |
| 237 | - print '<input type="hidden" name="page" value="' . $page . '">'; | |
| 238 | - print '<input type="hidden" name="sortorder" value="' . $sortorder . '">'; | |
| 236 | + print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; | |
| 237 | + print '<input type="hidden" name="page" value="'.$page.'">'; | |
| 238 | + print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; | |
| 239 | 239 | |
| 240 | 240 |          print_barre_liste($langs->trans("MembersTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, $newcardbutton, '', $limit);
 | 
| 241 | 241 | |
| 242 | 242 | $moreforfilter = ''; | 
| 243 | 243 | |
| 244 | 244 | print '<div class="div-table-responsive">'; | 
| 245 | - print '<table class="tagtable liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n"; | |
| 245 | + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; | |
| 246 | 246 | |
| 247 | 247 | print '<tr class="liste_titre">'; | 
| 248 | -        print '<th>' . $langs->trans("Ref") . '</th>';
 | |
| 249 | -        print '<th>' . $langs->trans("Label") . '</th>';
 | |
| 250 | -        print '<th align="center">' . $langs->trans("SubscriptionRequired") . '</th>';
 | |
| 251 | -        print '<th align="center">' . $langs->trans("VoteAllowed") . '</th>';
 | |
| 248 | +        print '<th>'.$langs->trans("Ref").'</th>';
 | |
| 249 | +        print '<th>'.$langs->trans("Label").'</th>';
 | |
| 250 | +        print '<th align="center">'.$langs->trans("SubscriptionRequired").'</th>';
 | |
| 251 | +        print '<th align="center">'.$langs->trans("VoteAllowed").'</th>';
 | |
| 252 | 252 | print '<th> </th>'; | 
| 253 | 253 | print "</tr>\n"; | 
| 254 | 254 | |
| @@ -266,11 +266,11 @@ discard block | ||
| 266 | 266 | print $membertype->getNomUrl(1); | 
| 267 | 267 |              //<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a>
 | 
| 268 | 268 | print '</td>'; | 
| 269 | - print '<td>' . dol_escape_htmltag($objp->label) . '</td>'; | |
| 270 | - print '<td align="center">' . yn($objp->subscription) . '</td>'; | |
| 271 | - print '<td align="center">' . yn($objp->vote) . '</td>'; | |
| 269 | + print '<td>'.dol_escape_htmltag($objp->label).'</td>'; | |
| 270 | + print '<td align="center">'.yn($objp->subscription).'</td>'; | |
| 271 | + print '<td align="center">'.yn($objp->vote).'</td>'; | |
| 272 | 272 |              if ($user->rights->adherent->configurer) {
 | 
| 273 | - print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=edit&rowid=' . $objp->rowid . '">' . img_edit() . '</a></td>'; | |
| 273 | + print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>'; | |
| 274 | 274 | } else | 
| 275 | 275 | print '<td align="right"> </td>'; | 
| 276 | 276 | print "</tr>"; | 
| @@ -298,8 +298,8 @@ discard block | ||
| 298 | 298 |      print load_fiche_titre($langs->trans("NewMemberType"));
 | 
| 299 | 299 | |
| 300 | 300 | //print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">'; | 
| 301 | - print '<form href="' . $_SERVER['PHP_SELF'] . '" method="POST">'; | |
| 302 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 301 | + print '<form href="'.$_SERVER['PHP_SELF'].'" method="POST">'; | |
| 302 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 303 | 303 | print '<input type="hidden" name="action" value="add">'; | 
| 304 | 304 | |
| 305 | 305 |      dol_fiche_head('');
 | 
| @@ -307,28 +307,28 @@ discard block | ||
| 307 | 307 | print '<table class="border" width="100%">'; | 
| 308 | 308 | print '<tbody>'; | 
| 309 | 309 | |
| 310 | -    print '<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans("Label") . '</td><td><input type="text" class="minwidth200" name="label" autofocus="autofocus"></td></tr>';
 | |
| 310 | +    print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" class="minwidth200" name="label" autofocus="autofocus"></td></tr>';
 | |
| 311 | 311 | |
| 312 | -    print '<tr><td>' . $langs->trans("SubscriptionRequired") . '</td><td>';
 | |
| 312 | +    print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
 | |
| 313 | 313 |      print $form->selectyesno("subscription", 1, 1);
 | 
| 314 | 314 | print '</td></tr>'; | 
| 315 | 315 | |
| 316 | -    print '<tr><td>' . $langs->trans("VoteAllowed") . '</td><td>';
 | |
| 316 | +    print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
 | |
| 317 | 317 |      print $form->selectyesno("vote", 0, 1);
 | 
| 318 | 318 | print '</td></tr>'; | 
| 319 | 319 | |
| 320 | -    print '<tr><td class="tdtop">' . $langs->trans("Description") . '</td><td>';
 | |
| 320 | +    print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
 | |
| 321 | 321 | print '<textarea name="comment" wrap="soft" class="centpercent" rows="3"></textarea></td></tr>'; | 
| 322 | 322 | |
| 323 | -    print '<tr><td class="tdtop">' . $langs->trans("WelcomeEMail") . '</td><td>';
 | |
| 324 | - require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; | |
| 323 | +    print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
 | |
| 324 | + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; | |
| 325 | 325 |      $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
 | 
| 326 | 326 | $doleditor->Create(); | 
| 327 | 327 | print '</td></tr>'; | 
| 328 | 328 | |
| 329 | 329 | // Other attributes | 
| 330 | 330 | $parameters = array(); | 
| 331 | -    $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action);    // Note that $action and $object may have been modified by hook
 | |
| 331 | +    $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook
 | |
| 332 | 332 | print $hookmanager->resPrint; | 
| 333 | 333 |      if (empty($reshook)) {
 | 
| 334 | 334 | print $object->showOptionals($extrafields, 'edit'); | 
| @@ -339,9 +339,9 @@ discard block | ||
| 339 | 339 | dol_fiche_end(); | 
| 340 | 340 | |
| 341 | 341 | print '<div class="center">'; | 
| 342 | -    print '<input type="submit" name="button" class="button" value="' . $langs->trans("Add") . '">';
 | |
| 342 | +    print '<input type="submit" name="button" class="button" value="'.$langs->trans("Add").'">';
 | |
| 343 | 343 | print '     '; | 
| 344 | -    print '<input type="submit" name="cancel" class="button" value="' . $langs->trans("Cancel") . '" onclick="history.go(-1)" />';
 | |
| 344 | +    print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'" onclick="history.go(-1)" />';
 | |
| 345 | 345 | print '</div>'; | 
| 346 | 346 | |
| 347 | 347 | print "</form>\n"; | 
| @@ -362,7 +362,7 @@ discard block | ||
| 362 | 362 | * Confirmation suppression | 
| 363 | 363 | */ | 
| 364 | 364 |          if ($action == 'delete') {
 | 
| 365 | -            print $form->formconfirm($_SERVER['PHP_SELF'] . "&rowid=" . $object->id, $langs->trans("DeleteAMemberType"), $langs->trans("ConfirmDeleteMemberType", $object->label), "confirm_delete", '', 0, 1);
 | |
| 365 | +            print $form->formconfirm($_SERVER['PHP_SELF']."&rowid=".$object->id, $langs->trans("DeleteAMemberType"), $langs->trans("ConfirmDeleteMemberType", $object->label), "confirm_delete", '', 0, 1);
 | |
| 366 | 366 | } | 
| 367 | 367 | |
| 368 | 368 | $head = member_type_prepare_head($object); | 
| @@ -370,7 +370,7 @@ discard block | ||
| 370 | 370 |          dol_fiche_head($head, 'card', $langs->trans("MemberType"), -1, 'group');
 | 
| 371 | 371 | |
| 372 | 372 |          //$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
 | 
| 373 | -        $linkback = '<a href="' . BASE_URI . '?controller=adherents&method=type&restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
 | |
| 373 | +        $linkback = '<a href="'.BASE_URI.'?controller=adherents&method=type&restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
 | |
| 374 | 374 | |
| 375 | 375 | dol_banner_tab($object, 'rowid', $linkback); | 
| 376 | 376 | |
| @@ -379,22 +379,22 @@ discard block | ||
| 379 | 379 | |
| 380 | 380 | print '<table class="border" width="100%">'; | 
| 381 | 381 | |
| 382 | -        print '<tr><td class="titlefield">' . $langs->trans("SubscriptionRequired") . '</td><td>';
 | |
| 382 | +        print '<tr><td class="titlefield">'.$langs->trans("SubscriptionRequired").'</td><td>';
 | |
| 383 | 383 | print yn($object->subscription); | 
| 384 | 384 | print '</tr>'; | 
| 385 | 385 | |
| 386 | -        print '<tr><td>' . $langs->trans("VoteAllowed") . '</td><td>';
 | |
| 386 | +        print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
 | |
| 387 | 387 | print yn($object->vote); | 
| 388 | 388 | print '</tr>'; | 
| 389 | 389 | |
| 390 | -        print '<tr><td class="tdtop">' . $langs->trans("Description") . '</td><td>';
 | |
| 391 | - print nl2br($object->note) . "</td></tr>"; | |
| 390 | +        print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
 | |
| 391 | + print nl2br($object->note)."</td></tr>"; | |
| 392 | 392 | |
| 393 | -        print '<tr><td class="tdtop">' . $langs->trans("WelcomeEMail") . '</td><td>';
 | |
| 394 | - print nl2br($object->mail_valid) . "</td></tr>"; | |
| 393 | +        print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
 | |
| 394 | + print nl2br($object->mail_valid)."</td></tr>"; | |
| 395 | 395 | |
| 396 | 396 | // Other attributes | 
| 397 | - include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; | |
| 397 | + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; | |
| 398 | 398 | |
| 399 | 399 | print '</table>'; | 
| 400 | 400 | print '</div>'; | 
| @@ -409,15 +409,15 @@ discard block | ||
| 409 | 409 | |
| 410 | 410 | // Edit | 
| 411 | 411 |          if ($user->rights->adherent->configurer) {
 | 
| 412 | -            print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '&action=edit&rowid=' . $object->id . '">' . $langs->trans("Modify") . '</a></div>';
 | |
| 412 | +            print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'&action=edit&rowid='.$object->id.'">'.$langs->trans("Modify").'</a></div>';
 | |
| 413 | 413 | } | 
| 414 | 414 | |
| 415 | 415 | // Add | 
| 416 | -        print '<div class="inline-block divButAction"><a class="butAction" href="card.php&action=create&typeid=' . $object->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '&rowid=' . $object->id) . '">' . $langs->trans("AddMember") . '</a></div>';
 | |
| 416 | +        print '<div class="inline-block divButAction"><a class="butAction" href="card.php&action=create&typeid='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'&rowid='.$object->id).'">'.$langs->trans("AddMember").'</a></div>';
 | |
| 417 | 417 | |
| 418 | 418 | // Delete | 
| 419 | 419 |          if ($user->rights->adherent->configurer) {
 | 
| 420 | -            print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER['PHP_SELF'] . '&action=delete&rowid=' . $object->id . '">' . $langs->trans("DeleteType") . '</a></div>';
 | |
| 420 | +            print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'&action=delete&rowid='.$object->id.'">'.$langs->trans("DeleteType").'</a></div>';
 | |
| 421 | 421 | } | 
| 422 | 422 | |
| 423 | 423 | print "</div>"; | 
| @@ -433,10 +433,10 @@ discard block | ||
| 433 | 433 | $sql .= " d.datefin,"; | 
| 434 | 434 | $sql .= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,"; | 
| 435 | 435 | $sql .= " t.libelle as type, t.subscription"; | 
| 436 | - $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as d, " . MAIN_DB_PREFIX . "adherent_type as t"; | |
| 436 | + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t"; | |
| 437 | 437 | $sql .= " WHERE d.fk_adherent_type = t.rowid "; | 
| 438 | -        $sql .= " AND d.entity IN (" . getEntity('adherent') . ")";
 | |
| 439 | - $sql .= " AND t.rowid = " . $object->id; | |
| 438 | +        $sql .= " AND d.entity IN (".getEntity('adherent').")";
 | |
| 439 | + $sql .= " AND t.rowid = ".$object->id; | |
| 440 | 440 |          if ($sall) {
 | 
| 441 | 441 |              $sql .= natural_search(array("f.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall);
 | 
| 442 | 442 | } | 
| @@ -458,13 +458,13 @@ discard block | ||
| 458 | 458 |              $sql .= natural_search("d.email", $search_email);
 | 
| 459 | 459 | } | 
| 460 | 460 |          if ($filter == 'uptodate') {
 | 
| 461 | - $sql .= " AND datefin >= '" . $db->idate($now) . "'"; | |
| 461 | + $sql .= " AND datefin >= '".$db->idate($now)."'"; | |
| 462 | 462 | } | 
| 463 | 463 |          if ($filter == 'outofdate') {
 | 
| 464 | - $sql .= " AND datefin < '" . $db->idate($now) . "'"; | |
| 464 | + $sql .= " AND datefin < '".$db->idate($now)."'"; | |
| 465 | 465 | } | 
| 466 | 466 | |
| 467 | - $sql .= " " . $db->order($sortfield, $sortorder); | |
| 467 | + $sql .= " ".$db->order($sortfield, $sortorder); | |
| 468 | 468 | |
| 469 | 469 | // Count total nb of records | 
| 470 | 470 | $nbtotalofrecords = ''; | 
| @@ -480,7 +480,7 @@ discard block | ||
| 480 | 480 | } | 
| 481 | 481 | } | 
| 482 | 482 | |
| 483 | - $sql .= " " . $db->plimit($conf->liste_limit + 1, $offset); | |
| 483 | + $sql .= " ".$db->plimit($conf->liste_limit + 1, $offset); | |
| 484 | 484 | |
| 485 | 485 | $resql = $db->query($sql); | 
| 486 | 486 |          if ($resql) {
 | 
| @@ -509,30 +509,30 @@ discard block | ||
| 509 | 509 |              if ($type > 0) {
 | 
| 510 | 510 | $membertype = new AdherentType($db); | 
| 511 | 511 | $result = $membertype->fetch($type); | 
| 512 | -                $titre .= " (" . $membertype->label . ")";
 | |
| 512 | +                $titre .= " (".$membertype->label.")";
 | |
| 513 | 513 | } | 
| 514 | 514 | |
| 515 | - $param = "&rowid=" . $object->id; | |
| 515 | + $param = "&rowid=".$object->id; | |
| 516 | 516 | if (!empty($status)) | 
| 517 | - $param .= "&status=" . $status; | |
| 517 | + $param .= "&status=".$status; | |
| 518 | 518 | if (!empty($search_lastname)) | 
| 519 | - $param .= "&search_lastname=" . $search_lastname; | |
| 519 | + $param .= "&search_lastname=".$search_lastname; | |
| 520 | 520 | if (!empty($search_firstname)) | 
| 521 | - $param .= "&search_firstname=" . $search_firstname; | |
| 521 | + $param .= "&search_firstname=".$search_firstname; | |
| 522 | 522 | if (!empty($search_login)) | 
| 523 | - $param .= "&search_login=" . $search_login; | |
| 523 | + $param .= "&search_login=".$search_login; | |
| 524 | 524 | if (!empty($search_email)) | 
| 525 | - $param .= "&search_email=" . $search_email; | |
| 525 | + $param .= "&search_email=".$search_email; | |
| 526 | 526 | if (!empty($filter)) | 
| 527 | - $param .= "&filter=" . $filter; | |
| 527 | + $param .= "&filter=".$filter; | |
| 528 | 528 | |
| 529 | 529 |              if ($sall) {
 | 
| 530 | -                print $langs->trans("Filter") . " (" . $langs->trans("Lastname") . ", " . $langs->trans("Firstname") . ", " . $langs->trans("EMail") . ", " . $langs->trans("Address") . " " . $langs->trans("or") . " " . $langs->trans("Town") . "): " . $sall;
 | |
| 530 | +                print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall;
 | |
| 531 | 531 | } | 
| 532 | 532 | |
| 533 | 533 | //print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; | 
| 534 | - print '<form method="POST" href="' . $_SERVER["PHP_SELF"] . '">'; | |
| 535 | - print '<input class="flat" type="hidden" name="rowid" value="' . $object->id . '" size="12"></td>'; | |
| 534 | + print '<form method="POST" href="'.$_SERVER["PHP_SELF"].'">'; | |
| 535 | + print '<input class="flat" type="hidden" name="rowid" value="'.$object->id.'" size="12"></td>'; | |
| 536 | 536 | |
| 537 | 537 | print '<br>'; | 
| 538 | 538 |              print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords);
 | 
| @@ -540,34 +540,34 @@ discard block | ||
| 540 | 540 | $moreforfilter = ''; | 
| 541 | 541 | |
| 542 | 542 | print '<div class="div-table-responsive">'; | 
| 543 | - print '<table class="tagtable liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n"; | |
| 543 | + print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; | |
| 544 | 544 | |
| 545 | 545 | // Lignes des champs de filtre | 
| 546 | 546 | print '<tr class="liste_titre_filter">'; | 
| 547 | 547 | |
| 548 | 548 | print '<td class="liste_titre" align="left">'; | 
| 549 | - print '<input class="flat" type="text" name="search_lastname" value="' . dol_escape_htmltag($search_lastname) . '" size="12"></td>'; | |
| 549 | + print '<input class="flat" type="text" name="search_lastname" value="'.dol_escape_htmltag($search_lastname).'" size="12"></td>'; | |
| 550 | 550 | |
| 551 | 551 | print '<td class="liste_titre" align="left">'; | 
| 552 | - print '<input class="flat" type="text" name="search_login" value="' . dol_escape_htmltag($search_login) . '" size="7"></td>'; | |
| 552 | + print '<input class="flat" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'" size="7"></td>'; | |
| 553 | 553 | |
| 554 | 554 | print '<td class="liste_titre"> </td>'; | 
| 555 | 555 | |
| 556 | 556 | print '<td class="liste_titre" align="left">'; | 
| 557 | - print '<input class="flat" type="text" name="search_email" value="' . dol_escape_htmltag($search_email) . '" size="12"></td>'; | |
| 557 | + print '<input class="flat" type="text" name="search_email" value="'.dol_escape_htmltag($search_email).'" size="12"></td>'; | |
| 558 | 558 | |
| 559 | 559 | print '<td class="liste_titre"> </td>'; | 
| 560 | 560 | |
| 561 | 561 | print '<td align="right" colspan="2" class="liste_titre">'; | 
| 562 | -            print '<input type="image" class="liste_titre" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png" name="button_search" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
 | |
| 562 | +            print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
 | |
| 563 | 563 | print '  '; | 
| 564 | -            print '<input type="image" class="liste_titre" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/searchclear.png" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
 | |
| 564 | +            print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
 | |
| 565 | 565 | print '</td>'; | 
| 566 | 566 | |
| 567 | 567 | print "</tr>\n"; | 
| 568 | 568 | |
| 569 | 569 | print '<tr class="liste_titre">'; | 
| 570 | -            print_liste_field_titre($langs->trans("Name") . " / " . $langs->trans("Company"), $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder);
 | |
| 570 | +            print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"), $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder);
 | |
| 571 | 571 |              print_liste_field_titre("Login", $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder);
 | 
| 572 | 572 |              print_liste_field_titre("Nature", $_SERVER["PHP_SELF"], "d.morphy", $param, "", "", $sortfield, $sortorder);
 | 
| 573 | 573 |              print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "d.email", $param, "", "", $sortfield, $sortorder);
 | 
| @@ -589,14 +589,14 @@ discard block | ||
| 589 | 589 | print '<tr class="oddeven">'; | 
| 590 | 590 |                  if ($objp->societe != '') {
 | 
| 591 | 591 |                      // print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,20).' / '.dol_trunc($objp->societe,12).'</a></td>'."\n";
 | 
| 592 | -                    print '<td><a href="' . BASE_URI . '?controller=adherent&method=card&rowid=' . $objp->rowid . '">' . img_object($langs->trans("ShowMember"), "user") . ' ' . $adh->getFullName($langs, 0, -1, 20) . ' / ' . dol_trunc($objp->societe, 12) . '</a></td>' . "\n";
 | |
| 592 | +                    print '<td><a href="'.BASE_URI.'?controller=adherent&method=card&rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->societe, 12).'</a></td>'."\n";
 | |
| 593 | 593 |                  } else {
 | 
| 594 | 594 |                      // print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,32).'</a></td>'."\n";
 | 
| 595 | -                    print '<td><a href="' . BASE_URI . '?adherent&method=card&rowid=' . $objp->rowid . '">' . img_object($langs->trans("ShowMember"), "user") . ' ' . $adh->getFullName($langs, 0, -1, 32) . '</a></td>' . "\n";
 | |
| 595 | +                    print '<td><a href="'.BASE_URI.'?adherent&method=card&rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 32).'</a></td>'."\n";
 | |
| 596 | 596 | } | 
| 597 | 597 | |
| 598 | 598 | // Login | 
| 599 | - print "<td>" . $objp->login . "</td>\n"; | |
| 599 | + print "<td>".$objp->login."</td>\n"; | |
| 600 | 600 | |
| 601 | 601 | // Type | 
| 602 | 602 | /* print '<td class="nowrap">'; | 
| @@ -607,10 +607,10 @@ discard block | ||
| 607 | 607 | */ | 
| 608 | 608 | |
| 609 | 609 | // Moral/Physique | 
| 610 | - print "<td>" . $adh->getmorphylib($objp->morphy) . "</td>\n"; | |
| 610 | + print "<td>".$adh->getmorphylib($objp->morphy)."</td>\n"; | |
| 611 | 611 | |
| 612 | 612 | |
| 613 | - print "<td>" . dol_print_email($objp->email, 0, 0, 1) . "</td>\n"; | |
| 613 | + print "<td>".dol_print_email($objp->email, 0, 0, 1)."</td>\n"; | |
| 614 | 614 | |
| 615 | 615 | // Statut | 
| 616 | 616 | print '<td class="nowrap">'; | 
| @@ -621,7 +621,7 @@ discard block | ||
| 621 | 621 |                  if ($datefin) {
 | 
| 622 | 622 | print '<td align="center" class="nowrap">'; | 
| 623 | 623 |                      if ($datefin < dol_now() && $objp->statut > 0) {
 | 
| 624 | -                        print dol_print_date($datefin, 'day') . " " . img_warning($langs->trans("SubscriptionLate"));
 | |
| 624 | +                        print dol_print_date($datefin, 'day')." ".img_warning($langs->trans("SubscriptionLate"));
 | |
| 625 | 625 |                      } else {
 | 
| 626 | 626 | print dol_print_date($datefin, 'day'); | 
| 627 | 627 | } | 
| @@ -631,7 +631,7 @@ discard block | ||
| 631 | 631 |                      if ($objp->subscription == 'yes') {
 | 
| 632 | 632 |                          print $langs->trans("SubscriptionNotReceived");
 | 
| 633 | 633 | if ($objp->statut > 0) | 
| 634 | - print " " . img_warning(); | |
| 634 | + print " ".img_warning(); | |
| 635 | 635 | } | 
| 636 | 636 |                      else {
 | 
| 637 | 637 | print ' '; | 
| @@ -643,12 +643,12 @@ discard block | ||
| 643 | 643 | print '<td align="center">'; | 
| 644 | 644 |                  if ($user->rights->adherent->creer) {
 | 
| 645 | 645 | // print '<a href="card.php?rowid=' . $objp->rowid . '&action=edit&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?rowid=' . $object->id) . '">' . img_edit() . '</a>'; | 
| 646 | - print '<a href="' . BASE_URI . '?controller=adherent&method=card&rowid=' . $objp->rowid . '&action=edit&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '&rowid=' . $object->id) . '">' . img_edit() . '</a>'; | |
| 646 | + print '<a href="'.BASE_URI.'?controller=adherent&method=card&rowid='.$objp->rowid.'&action=edit&backtopage='.urlencode($_SERVER["PHP_SELF"].'&rowid='.$object->id).'">'.img_edit().'</a>'; | |
| 647 | 647 | } | 
| 648 | 648 | print ' '; | 
| 649 | 649 |                  if ($user->rights->adherent->supprimer) {
 | 
| 650 | 650 |                      // print '<a href="card.php?rowid=' . $objp->rowid . '&action=resign">' . img_picto($langs->trans("Resiliate"), 'disable.png') . '</a>';
 | 
| 651 | -                    print '<a href="' . BASE_URI . '?controller=adherent&method=card&rowid=' . $objp->rowid . '&action=resign">' . img_picto($langs->trans("Resiliate"), 'disable.png') . '</a>';
 | |
| 651 | +                    print '<a href="'.BASE_URI.'?controller=adherent&method=card&rowid='.$objp->rowid.'&action=resign">'.img_picto($langs->trans("Resiliate"), 'disable.png').'</a>';
 | |
| 652 | 652 | } | 
| 653 | 653 | print "</td>"; | 
| 654 | 654 | |
| @@ -682,39 +682,39 @@ discard block | ||
| 682 | 682 | $head = member_type_prepare_head($object); | 
| 683 | 683 | |
| 684 | 684 | //print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'">'; | 
| 685 | - print '<form method="post" href="' . $_SERVER["PHP_SELF"] . '&rowid=' . $object->id . '">'; | |
| 686 | - print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; | |
| 687 | - print '<input type="hidden" name="rowid" value="' . $object->id . '">'; | |
| 685 | + print '<form method="post" href="'.$_SERVER["PHP_SELF"].'&rowid='.$object->id.'">'; | |
| 686 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; | |
| 687 | + print '<input type="hidden" name="rowid" value="'.$object->id.'">'; | |
| 688 | 688 | print '<input type="hidden" name="action" value="update">'; | 
| 689 | 689 | |
| 690 | 690 |          dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group');
 | 
| 691 | 691 | |
| 692 | 692 | print '<table class="border" width="100%">'; | 
| 693 | 693 | |
| 694 | -        print '<tr><td class="titlefield">' . $langs->trans("Ref") . '</td><td>' . $object->id . '</td></tr>';
 | |
| 694 | +        print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->id.'</td></tr>';
 | |
| 695 | 695 | |
| 696 | -        print '<tr><td class="fieldrequired">' . $langs->trans("Label") . '</td><td><input type="text" name="label" size="40" value="' . dol_escape_htmltag($object->label) . '"></td></tr>';
 | |
| 696 | +        print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>';
 | |
| 697 | 697 | |
| 698 | -        print '<tr><td>' . $langs->trans("SubscriptionRequired") . '</td><td>';
 | |
| 698 | +        print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
 | |
| 699 | 699 |          print $form->selectyesno("subscription", $object->subscription, 1);
 | 
| 700 | 700 | print '</td></tr>'; | 
| 701 | 701 | |
| 702 | -        print '<tr><td>' . $langs->trans("VoteAllowed") . '</td><td>';
 | |
| 702 | +        print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
 | |
| 703 | 703 |          print $form->selectyesno("vote", $object->vote, 1);
 | 
| 704 | 704 | print '</td></tr>'; | 
| 705 | 705 | |
| 706 | -        print '<tr><td class="tdtop">' . $langs->trans("Description") . '</td><td>';
 | |
| 707 | - print '<textarea name="comment" wrap="soft" class="centpercent" rows="3">' . $object->note . '</textarea></td></tr>'; | |
| 706 | +        print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
 | |
| 707 | + print '<textarea name="comment" wrap="soft" class="centpercent" rows="3">'.$object->note.'</textarea></td></tr>'; | |
| 708 | 708 | |
| 709 | -        print '<tr><td class="tdtop">' . $langs->trans("WelcomeEMail") . '</td><td>';
 | |
| 710 | - require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; | |
| 709 | +        print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
 | |
| 710 | + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; | |
| 711 | 711 |          $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
 | 
| 712 | 712 | $doleditor->Create(); | 
| 713 | 713 | print "</td></tr>"; | 
| 714 | 714 | |
| 715 | 715 | // Other attributes | 
| 716 | 716 | $parameters = array(); | 
| 717 | -        $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action);    // Note that $action and $object may have been modified by hook
 | |
| 717 | +        $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook
 | |
| 718 | 718 | print $hookmanager->resPrint; | 
| 719 | 719 |          if (empty($reshook)) {
 | 
| 720 | 720 | print $object->showOptionals($extrafields, 'edit'); | 
| @@ -726,17 +726,17 @@ discard block | ||
| 726 | 726 |          if (empty($reshook)) {
 | 
| 727 | 727 | print '<br><br><table class="border" width="100%">'; | 
| 728 | 728 |              foreach ($extrafields->attribute_label as $key => $label) {
 | 
| 729 | -                if (isset($_POST["options_" . $key])) {
 | |
| 730 | -                    if (is_array($_POST["options_" . $key])) {
 | |
| 729 | +                if (isset($_POST["options_".$key])) {
 | |
| 730 | +                    if (is_array($_POST["options_".$key])) {
 | |
| 731 | 731 | // $_POST["options"] is an array but following code expects a comma separated string | 
| 732 | -                        $value = implode(",", $_POST["options_" . $key]);
 | |
| 732 | +                        $value = implode(",", $_POST["options_".$key]);
 | |
| 733 | 733 |                      } else {
 | 
| 734 | - $value = $_POST["options_" . $key]; | |
| 734 | + $value = $_POST["options_".$key]; | |
| 735 | 735 | } | 
| 736 | 736 |                  } else {
 | 
| 737 | - $value = $adht->array_options["options_" . $key]; | |
| 737 | + $value = $adht->array_options["options_".$key]; | |
| 738 | 738 | } | 
| 739 | - print '<tr><td width="30%">' . $label . '</td><td>'; | |
| 739 | + print '<tr><td width="30%">'.$label.'</td><td>'; | |
| 740 | 740 | print $extrafields->showInputField($key, $value); | 
| 741 | 741 | print "</td></tr>\n"; | 
| 742 | 742 | } | 
| @@ -746,9 +746,9 @@ discard block | ||
| 746 | 746 | dol_fiche_end(); | 
| 747 | 747 | |
| 748 | 748 | print '<div class="center">'; | 
| 749 | -        print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">';
 | |
| 749 | +        print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
 | |
| 750 | 750 | print '     '; | 
| 751 | -        print '<input type="submit" name="cancel" class="button" value="' . $langs->trans("Cancel") . '">';
 | |
| 751 | +        print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
 | |
| 752 | 752 | print '</div>'; | 
| 753 | 753 | |
| 754 | 754 | print "</form>"; | 
| @@ -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>'; | 
| @@ -40,23 +40,23 @@ discard block | ||
| 40 | 40 | // Note that only directory logo is free to access without login. | 
| 41 | 41 |  if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'mycompany' && preg_match('/^\/?logos\//', $_GET['file']))
 | 
| 42 | 42 |  {
 | 
| 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
 | |
| 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
 | |
| 46 | 46 | } | 
| 47 | 47 | // For direct external download link, we don't need to load/check we are into a login session | 
| 48 | 48 |  if (isset($_GET["hashp"]) && ! defined("NOLOGIN"))
 | 
| 49 | 49 |  {
 | 
| 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
 | |
| 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
 | |
| 53 | 53 | } | 
| 54 | 54 | // Some value of modulepart can be used to get resources that are public so no login are required. | 
| 55 | 55 | if ((isset($_GET["modulepart"]) && $_GET["modulepart"] == 'medias')) | 
| 56 | 56 |  {
 | 
| 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
 | |
| 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
 | |
| 60 | 60 | } | 
| 61 | 61 | |
| 62 | 62 | // For multicompany | 
| @@ -125,43 +125,43 @@ discard block | ||
| 125 | 125 | // If we have a hash public (hashp), we guess the original_file. | 
| 126 | 126 | if (! empty($hashp)) | 
| 127 | 127 |  {
 | 
| 128 | - include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; | |
| 129 | - $ecmfile=new EcmFiles($db); | |
| 130 | - $result = $ecmfile->fetch(0, '', '', '', $hashp); | |
| 131 | - if ($result > 0) | |
| 132 | -	{
 | |
| 133 | -		$tmp = explode('/', $ecmfile->filepath, 2);		// $ecmfile->filepath is relative to document directory
 | |
| 134 | - // 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. | |
| 136 | -		{
 | |
| 137 | -			$tmp = explode('/', $tmp[1], 2);
 | |
| 138 | - } | |
| 139 | - $moduleparttocheck = $tmp[0]; // moduleparttocheck is first part of path | |
| 140 | - | |
| 141 | - if ($modulepart) // Not required, so often not defined, for link using public hashp parameter. | |
| 142 | -		{
 | |
| 143 | - if ($moduleparttocheck == $modulepart) | |
| 144 | -			{
 | |
| 145 | - // We remove first level of directory | |
| 146 | - $original_file = (($tmp[1]?$tmp[1].'/':'').$ecmfile->filename); // this is relative to module dir | |
| 147 | - //var_dump($original_file); exit; | |
| 148 | - } | |
| 149 | - else | |
| 150 | -			{
 | |
| 151 | -				accessforbidden('Bad link. File is from another module part.',0,0,1);
 | |
| 152 | - } | |
| 153 | - } | |
| 154 | - else | |
| 155 | -		{
 | |
| 156 | - $modulepart = $moduleparttocheck; | |
| 157 | - $original_file = (($tmp[1]?$tmp[1].'/':'').$ecmfile->filename); // this is relative to module dir | |
| 158 | - } | |
| 159 | - } | |
| 160 | - else | |
| 161 | -	{
 | |
| 162 | -		$langs->load("errors");
 | |
| 163 | -		accessforbidden($langs->trans("ErrorFileNotFoundWithSharedLink"),0,0,1);
 | |
| 164 | - } | |
| 128 | + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; | |
| 129 | + $ecmfile=new EcmFiles($db); | |
| 130 | + $result = $ecmfile->fetch(0, '', '', '', $hashp); | |
| 131 | + if ($result > 0) | |
| 132 | +    {
 | |
| 133 | +        $tmp = explode('/', $ecmfile->filepath, 2);		// $ecmfile->filepath is relative to document directory
 | |
| 134 | + // 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. | |
| 136 | +        {
 | |
| 137 | +            $tmp = explode('/', $tmp[1], 2);
 | |
| 138 | + } | |
| 139 | + $moduleparttocheck = $tmp[0]; // moduleparttocheck is first part of path | |
| 140 | + | |
| 141 | + if ($modulepart) // Not required, so often not defined, for link using public hashp parameter. | |
| 142 | +        {
 | |
| 143 | + if ($moduleparttocheck == $modulepart) | |
| 144 | +            {
 | |
| 145 | + // We remove first level of directory | |
| 146 | + $original_file = (($tmp[1]?$tmp[1].'/':'').$ecmfile->filename); // this is relative to module dir | |
| 147 | + //var_dump($original_file); exit; | |
| 148 | + } | |
| 149 | + else | |
| 150 | +            {
 | |
| 151 | +                accessforbidden('Bad link. File is from another module part.',0,0,1);
 | |
| 152 | + } | |
| 153 | + } | |
| 154 | + else | |
| 155 | +        {
 | |
| 156 | + $modulepart = $moduleparttocheck; | |
| 157 | + $original_file = (($tmp[1]?$tmp[1].'/':'').$ecmfile->filename); // this is relative to module dir | |
| 158 | + } | |
| 159 | + } | |
| 160 | + else | |
| 161 | +    {
 | |
| 162 | +        $langs->load("errors");
 | |
| 163 | +        accessforbidden($langs->trans("ErrorFileNotFoundWithSharedLink"),0,0,1);
 | |
| 164 | + } | |
| 165 | 165 | } | 
| 166 | 166 | |
| 167 | 167 | // Define mime type | 
| @@ -185,50 +185,50 @@ discard block | ||
| 185 | 185 | |
| 186 | 186 | if (! empty($hashp)) | 
| 187 | 187 |  {
 | 
| 188 | - $accessallowed = 1; // When using hashp, link is public so we force $accessallowed | |
| 189 | - $sqlprotectagainstexternals = ''; | |
| 188 | + $accessallowed = 1; // When using hashp, link is public so we force $accessallowed | |
| 189 | + $sqlprotectagainstexternals = ''; | |
| 190 | 190 | } | 
| 191 | 191 | else | 
| 192 | 192 |  {
 | 
| 193 | - // Basic protection (against external users only) | |
| 194 | - if ($user->societe_id > 0) | |
| 195 | -	{
 | |
| 196 | - if ($sqlprotectagainstexternals) | |
| 197 | -		{
 | |
| 198 | - $resql = $db->query($sqlprotectagainstexternals); | |
| 199 | - if ($resql) | |
| 200 | -			{
 | |
| 201 | - $num=$db->num_rows($resql); | |
| 202 | - $i=0; | |
| 203 | - while ($i < $num) | |
| 204 | -				{
 | |
| 205 | - $obj = $db->fetch_object($resql); | |
| 206 | - if ($user->societe_id != $obj->fk_soc) | |
| 207 | -					{
 | |
| 208 | - $accessallowed=0; | |
| 209 | - break; | |
| 210 | - } | |
| 211 | - $i++; | |
| 212 | - } | |
| 213 | - } | |
| 214 | - } | |
| 215 | - } | |
| 193 | + // Basic protection (against external users only) | |
| 194 | + if ($user->societe_id > 0) | |
| 195 | +    {
 | |
| 196 | + if ($sqlprotectagainstexternals) | |
| 197 | +        {
 | |
| 198 | + $resql = $db->query($sqlprotectagainstexternals); | |
| 199 | + if ($resql) | |
| 200 | +            {
 | |
| 201 | + $num=$db->num_rows($resql); | |
| 202 | + $i=0; | |
| 203 | + while ($i < $num) | |
| 204 | +                {
 | |
| 205 | + $obj = $db->fetch_object($resql); | |
| 206 | + if ($user->societe_id != $obj->fk_soc) | |
| 207 | +                    {
 | |
| 208 | + $accessallowed=0; | |
| 209 | + break; | |
| 210 | + } | |
| 211 | + $i++; | |
| 212 | + } | |
| 213 | + } | |
| 214 | + } | |
| 215 | + } | |
| 216 | 216 | } | 
| 217 | 217 | |
| 218 | 218 | // Security: | 
| 219 | 219 | // Limit access if permissions are wrong | 
| 220 | 220 | if (! $accessallowed) | 
| 221 | 221 |  {
 | 
| 222 | - accessforbidden(); | |
| 222 | + accessforbidden(); | |
| 223 | 223 | } | 
| 224 | 224 | |
| 225 | 225 | // Security: | 
| 226 | 226 | // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers. | 
| 227 | 227 |  if (preg_match('/\.\./',$fullpath_original_file) || preg_match('/[<>|]/',$fullpath_original_file))
 | 
| 228 | 228 |  {
 | 
| 229 | -	dol_syslog("Refused to deliver file ".$fullpath_original_file);
 | |
| 230 | - print "ErrorFileNameInvalid: ".$original_file; | |
| 231 | - exit; | |
| 229 | +    dol_syslog("Refused to deliver file ".$fullpath_original_file);
 | |
| 230 | + print "ErrorFileNameInvalid: ".$original_file; | |
| 231 | + exit; | |
| 232 | 232 | } | 
| 233 | 233 | |
| 234 | 234 | |
| @@ -28,39 +28,39 @@ 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'))		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');
 | |
| 38 | 38 | |
| 39 | 39 | // Some value of modulepart can be used to get resources that are public so no login are required. | 
| 40 | 40 | // Note that only directory logo is free to access without login. | 
| 41 | 41 |  if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'mycompany' && preg_match('/^\/?logos\//', $_GET['file']))
 | 
| 42 | 42 |  {
 | 
| 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
 | |
| 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
 | |
| 46 | 46 | } | 
| 47 | 47 | // For direct external download link, we don't need to load/check we are into a login session | 
| 48 | -if (isset($_GET["hashp"]) && ! defined("NOLOGIN"))
 | |
| 48 | +if (isset($_GET["hashp"]) && !defined("NOLOGIN"))
 | |
| 49 | 49 |  {
 | 
| 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
 | |
| 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
 | |
| 53 | 53 | } | 
| 54 | 54 | // Some value of modulepart can be used to get resources that are public so no login are required. | 
| 55 | 55 | if ((isset($_GET["modulepart"]) && $_GET["modulepart"] == 'medias')) | 
| 56 | 56 |  {
 | 
| 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
 | |
| 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
 | |
| 60 | 60 | } | 
| 61 | 61 | |
| 62 | 62 | // For multicompany | 
| 63 | -$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); | |
| 63 | +$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); | |
| 64 | 64 |  if (is_numeric($entity)) define("DOLENTITY", $entity);
 | 
| 65 | 65 | |
| 66 | 66 | /** | 
| @@ -80,20 +80,20 @@ discard block | ||
| 80 | 80 |  {
 | 
| 81 | 81 | } | 
| 82 | 82 | |
| 83 | -require 'main.inc.php'; // Load $user and permissions | |
| 83 | +require 'main.inc.php'; // Load $user and permissions | |
| 84 | 84 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; | 
| 85 | 85 | |
| 86 | -$action=GETPOST('action','alpha');
 | |
| 87 | -$original_file=GETPOST('file','alpha');		// Do not use urldecode here ($_GET are already decoded by PHP).
 | |
| 88 | -$hashp=GETPOST('hashp','aZ09');
 | |
| 89 | -$modulepart=GETPOST('modulepart','alpha');
 | |
| 90 | -$urlsource=GETPOST('urlsource','alpha');
 | |
| 91 | -$entity=GETPOST('entity','int')?GETPOST('entity','int'):$conf->entity;
 | |
| 86 | +$action = GETPOST('action', 'alpha');
 | |
| 87 | +$original_file = GETPOST('file', 'alpha'); // Do not use urldecode here ($_GET are already decoded by PHP).
 | |
| 88 | +$hashp = GETPOST('hashp', 'aZ09');
 | |
| 89 | +$modulepart = GETPOST('modulepart', 'alpha');
 | |
| 90 | +$urlsource = GETPOST('urlsource', 'alpha');
 | |
| 91 | +$entity = GETPOST('entity', 'int') ?GETPOST('entity', 'int') : $conf->entity;
 | |
| 92 | 92 | |
| 93 | 93 | // 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 | |
| 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 | |
| 97 | 97 | |
| 98 | 98 | |
| 99 | 99 | |
| @@ -109,71 +109,71 @@ discard block | ||
| 109 | 109 | * View | 
| 110 | 110 | */ | 
| 111 | 111 | |
| 112 | -if (GETPOST("cache",'alpha'))
 | |
| 112 | +if (GETPOST("cache", 'alpha'))
 | |
| 113 | 113 |  {
 | 
| 114 | 114 | // Important: Following code is to avoid page request by browser and PHP CPU at | 
| 115 | 115 | // each Dolibarr page access. | 
| 116 | 116 | if (empty($dolibarr_nocache)) | 
| 117 | 117 |      {
 | 
| 118 | 118 |          header('Cache-Control: max-age=3600, public, must-revalidate');
 | 
| 119 | -        header('Pragma: cache');       // This is to avoid having Pragma: no-cache
 | |
| 119 | +        header('Pragma: cache'); // This is to avoid having Pragma: no-cache
 | |
| 120 | 120 | } | 
| 121 | 121 |      else header('Cache-Control: no-cache');
 | 
| 122 | 122 | //print $dolibarr_nocache; exit; | 
| 123 | 123 | } | 
| 124 | 124 | |
| 125 | 125 | // If we have a hash public (hashp), we guess the original_file. | 
| 126 | -if (! empty($hashp)) | |
| 126 | +if (!empty($hashp)) | |
| 127 | 127 |  {
 | 
| 128 | 128 | include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; | 
| 129 | - $ecmfile=new EcmFiles($db); | |
| 129 | + $ecmfile = new EcmFiles($db); | |
| 130 | 130 | $result = $ecmfile->fetch(0, '', '', '', $hashp); | 
| 131 | 131 | if ($result > 0) | 
| 132 | 132 |  	{
 | 
| 133 | -		$tmp = explode('/', $ecmfile->filepath, 2);		// $ecmfile->filepath is relative to document directory
 | |
| 133 | +		$tmp = explode('/', $ecmfile->filepath, 2); // $ecmfile->filepath is relative to document directory
 | |
| 134 | 134 | // filepath can be 'users/X' or 'X/propale/PR11111' | 
| 135 | 135 | if (is_numeric($tmp[0])) // If first tmp is numeric, it is subdir of company for multicompany, we take next part. | 
| 136 | 136 |  		{
 | 
| 137 | 137 |  			$tmp = explode('/', $tmp[1], 2);
 | 
| 138 | 138 | } | 
| 139 | - $moduleparttocheck = $tmp[0]; // moduleparttocheck is first part of path | |
| 139 | + $moduleparttocheck = $tmp[0]; // moduleparttocheck is first part of path | |
| 140 | 140 | |
| 141 | 141 | if ($modulepart) // Not required, so often not defined, for link using public hashp parameter. | 
| 142 | 142 |  		{
 | 
| 143 | 143 | if ($moduleparttocheck == $modulepart) | 
| 144 | 144 |  			{
 | 
| 145 | 145 | // We remove first level of directory | 
| 146 | - $original_file = (($tmp[1]?$tmp[1].'/':'').$ecmfile->filename); // this is relative to module dir | |
| 146 | + $original_file = (($tmp[1] ? $tmp[1].'/' : '').$ecmfile->filename); // this is relative to module dir | |
| 147 | 147 | //var_dump($original_file); exit; | 
| 148 | 148 | } | 
| 149 | 149 | else | 
| 150 | 150 |  			{
 | 
| 151 | -				accessforbidden('Bad link. File is from another module part.',0,0,1);
 | |
| 151 | +				accessforbidden('Bad link. File is from another module part.', 0, 0, 1);
 | |
| 152 | 152 | } | 
| 153 | 153 | } | 
| 154 | 154 | else | 
| 155 | 155 |  		{
 | 
| 156 | 156 | $modulepart = $moduleparttocheck; | 
| 157 | - $original_file = (($tmp[1]?$tmp[1].'/':'').$ecmfile->filename); // this is relative to module dir | |
| 157 | + $original_file = (($tmp[1] ? $tmp[1].'/' : '').$ecmfile->filename); // this is relative to module dir | |
| 158 | 158 | } | 
| 159 | 159 | } | 
| 160 | 160 | else | 
| 161 | 161 |  	{
 | 
| 162 | 162 |  		$langs->load("errors");
 | 
| 163 | -		accessforbidden($langs->trans("ErrorFileNotFoundWithSharedLink"),0,0,1);
 | |
| 163 | +		accessforbidden($langs->trans("ErrorFileNotFoundWithSharedLink"), 0, 0, 1);
 | |
| 164 | 164 | } | 
| 165 | 165 | } | 
| 166 | 166 | |
| 167 | 167 | // Define mime type | 
| 168 | 168 | $type = 'application/octet-stream'; | 
| 169 | -if (GETPOST('type','alpha')) $type=GETPOST('type','alpha');
 | |
| 170 | -else $type=dol_mimetype($original_file); | |
| 169 | +if (GETPOST('type', 'alpha')) $type = GETPOST('type', 'alpha');
 | |
| 170 | +else $type = dol_mimetype($original_file); | |
| 171 | 171 | |
| 172 | 172 | // Security: Delete string ../ into $original_file | 
| 173 | -$original_file = str_replace("../","/", $original_file);
 | |
| 173 | +$original_file = str_replace("../", "/", $original_file);
 | |
| 174 | 174 | |
| 175 | 175 | // Find the subdirectory name as the reference | 
| 176 | -$refname=basename(dirname($original_file)."/"); | |
| 176 | +$refname = basename(dirname($original_file)."/"); | |
| 177 | 177 | |
| 178 | 178 | // Security check | 
| 179 | 179 |  if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart');
 | 
| @@ -181,11 +181,11 @@ discard block | ||
| 181 | 181 | $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); | 
| 182 | 182 | $accessallowed = $check_access['accessallowed']; | 
| 183 | 183 | $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; | 
| 184 | -$fullpath_original_file = $check_access['original_file']; // $fullpath_original_file is now a full path name | |
| 184 | +$fullpath_original_file = $check_access['original_file']; // $fullpath_original_file is now a full path name | |
| 185 | 185 | |
| 186 | -if (! empty($hashp)) | |
| 186 | +if (!empty($hashp)) | |
| 187 | 187 |  {
 | 
| 188 | - $accessallowed = 1; // When using hashp, link is public so we force $accessallowed | |
| 188 | + $accessallowed = 1; // When using hashp, link is public so we force $accessallowed | |
| 189 | 189 | $sqlprotectagainstexternals = ''; | 
| 190 | 190 | } | 
| 191 | 191 | else | 
| @@ -198,14 +198,14 @@ discard block | ||
| 198 | 198 | $resql = $db->query($sqlprotectagainstexternals); | 
| 199 | 199 | if ($resql) | 
| 200 | 200 |  			{
 | 
| 201 | - $num=$db->num_rows($resql); | |
| 202 | - $i=0; | |
| 201 | + $num = $db->num_rows($resql); | |
| 202 | + $i = 0; | |
| 203 | 203 | while ($i < $num) | 
| 204 | 204 |  				{
 | 
| 205 | 205 | $obj = $db->fetch_object($resql); | 
| 206 | 206 | if ($user->societe_id != $obj->fk_soc) | 
| 207 | 207 |  					{
 | 
| 208 | - $accessallowed=0; | |
| 208 | + $accessallowed = 0; | |
| 209 | 209 | break; | 
| 210 | 210 | } | 
| 211 | 211 | $i++; | 
| @@ -217,14 +217,14 @@ discard block | ||
| 217 | 217 | |
| 218 | 218 | // Security: | 
| 219 | 219 | // Limit access if permissions are wrong | 
| 220 | -if (! $accessallowed) | |
| 220 | +if (!$accessallowed) | |
| 221 | 221 |  {
 | 
| 222 | 222 | accessforbidden(); | 
| 223 | 223 | } | 
| 224 | 224 | |
| 225 | 225 | // Security: | 
| 226 | 226 | // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers. | 
| 227 | -if (preg_match('/\.\./',$fullpath_original_file) || preg_match('/[<>|]/',$fullpath_original_file))
 | |
| 227 | +if (preg_match('/\.\./', $fullpath_original_file) || preg_match('/[<>|]/', $fullpath_original_file))
 | |
| 228 | 228 |  {
 | 
| 229 | 229 |  	dol_syslog("Refused to deliver file ".$fullpath_original_file);
 | 
| 230 | 230 | print "ErrorFileNameInvalid: ".$original_file; | 
| @@ -235,10 +235,10 @@ discard block | ||
| 235 | 235 | |
| 236 | 236 | if ($modulepart == 'barcode') | 
| 237 | 237 |  {
 | 
| 238 | -    $generator=GETPOST("generator","alpha");
 | |
| 239 | -    $code=GETPOST("code",'none');							// This can be rich content (qrcode, datamatrix, ...)
 | |
| 240 | -    $encoding=GETPOST("encoding","alpha");
 | |
| 241 | -    $readable=GETPOST("readable",'alpha')?GETPOST("readable","alpha"):"Y";
 | |
| 238 | +    $generator = GETPOST("generator", "alpha");
 | |
| 239 | +    $code = GETPOST("code", 'none'); // This can be rich content (qrcode, datamatrix, ...)
 | |
| 240 | +    $encoding = GETPOST("encoding", "alpha");
 | |
| 241 | +    $readable = GETPOST("readable", 'alpha') ?GETPOST("readable", "alpha") : "Y";
 | |
| 242 | 242 | |
| 243 | 243 | if (empty($generator) || empty($encoding)) | 
| 244 | 244 |      {
 | 
| @@ -246,19 +246,19 @@ discard block | ||
| 246 | 246 | exit; | 
| 247 | 247 | } | 
| 248 | 248 | |
| 249 | -    $dirbarcode=array_merge(array("/core/modules/barcode/doc/"),$conf->modules_parts['barcode']);
 | |
| 249 | +    $dirbarcode = array_merge(array("/core/modules/barcode/doc/"), $conf->modules_parts['barcode']);
 | |
| 250 | 250 | |
| 251 | - $result=0; | |
| 251 | + $result = 0; | |
| 252 | 252 | |
| 253 | - foreach($dirbarcode as $reldir) | |
| 253 | + foreach ($dirbarcode as $reldir) | |
| 254 | 254 |      {
 | 
| 255 | - $dir=dol_buildpath($reldir,0); | |
| 256 | - $newdir=dol_osencode($dir); | |
| 255 | + $dir = dol_buildpath($reldir, 0); | |
| 256 | + $newdir = dol_osencode($dir); | |
| 257 | 257 | |
| 258 | 258 | // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) | 
| 259 | - if (! is_dir($newdir)) continue; | |
| 259 | + if (!is_dir($newdir)) continue; | |
| 260 | 260 | |
| 261 | - $result=@include_once $newdir.$generator.'.modules.php'; | |
| 261 | + $result = @include_once $newdir.$generator.'.modules.php'; | |
| 262 | 262 | if ($result) break; | 
| 263 | 263 | } | 
| 264 | 264 | |
| @@ -267,7 +267,7 @@ discard block | ||
| 267 | 267 | $module = new $classname($db); | 
| 268 | 268 | if ($module->encodingIsSupported($encoding)) | 
| 269 | 269 |      {
 | 
| 270 | - $result=$module->buildBarCode($code,$encoding,$readable); | |
| 270 | + $result = $module->buildBarCode($code, $encoding, $readable); | |
| 271 | 271 | } | 
| 272 | 272 | } | 
| 273 | 273 | else // Open and return file | 
| @@ -280,10 +280,10 @@ discard block | ||
| 280 | 280 |      dol_syslog("viewimage.php return file $fullpath_original_file filename=$filename content-type=$type");
 | 
| 281 | 281 | |
| 282 | 282 | // This test is to avoid error images when image is not available (for example thumbs). | 
| 283 | - if (! dol_is_file($fullpath_original_file) && empty($_GET["noalt"])) | |
| 283 | + if (!dol_is_file($fullpath_original_file) && empty($_GET["noalt"])) | |
| 284 | 284 |      {
 | 
| 285 | 285 | // $fullpath_original_file=DOL_DOCUMENT_ROOT.'/public/theme/common/nophoto.png'; | 
| 286 | - $fullpath_original_file = DOL_BASE_URI . '/public/theme/common/nophoto.png'; | |
| 286 | + $fullpath_original_file = DOL_BASE_URI.'/public/theme/common/nophoto.png'; | |
| 287 | 287 | /*$error='Error: File '.$_GET["file"].' does not exists or filesystems permissions are not allowed'; | 
| 288 | 288 | print $error; | 
| 289 | 289 | exit;*/ | 
| @@ -301,7 +301,7 @@ discard block | ||
| 301 | 301 |          header('Content-Disposition: inline; filename="'.basename($fullpath_original_file).'"');
 | 
| 302 | 302 | } | 
| 303 | 303 | |
| 304 | - $fullpath_original_file_osencoded=dol_osencode($fullpath_original_file); | |
| 304 | + $fullpath_original_file_osencoded = dol_osencode($fullpath_original_file); | |
| 305 | 305 | |
| 306 | 306 | readfile($fullpath_original_file_osencoded); | 
| 307 | 307 | } | 
| @@ -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 | +} | |