--- /tmp/dsg/dolibarr/htdocs/fourn/commande/github_19.0.3_card.php +++ /tmp/dsg/dolibarr/htdocs/fourn/commande/client_card.php @@ -7 +7 @@ - * Copyright (C) 2011-2022 Philippe Grand + * Copyright (C) 2011-2018 Philippe Grand @@ -11,5 +11 @@ - * Copyright (C) 2018-2019 Frédéric France - * Copyright (C) 2022 Gauthier VERDOL - * Copyright (C) 2022 Charlene Benke - * Copyright (C) 2023 Joachim Kueter - * Copyright (C) 2024 Nick Fragoulis + * Copyright (C) 2018-2019 Frédéric France @@ -33,3 +29,3 @@ - * \file htdocs/fourn/commande/card.php - * \ingroup supplier, order - * \brief Card supplier order + * \file htdocs/fourn/commande/card.php + * \ingroup supplier, order + * \brief Card supplier order @@ -38,2 +33,0 @@ - -// Load Dolibarr environment @@ -41 +34,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -44,3 +36,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -50,2 +40,5 @@ - -if (isModEnabled('supplier_proposal')) { +require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; +if (!empty($conf->supplier_proposal->enabled)) @@ -53,2 +46 @@ -} -if (isModEnabled("product")) { +if (!empty($conf->product->enabled)) @@ -56,2 +48 @@ -} -if (isModEnabled('project')) { +if (!empty($conf->projet->enabled)) { @@ -63 +54 @@ -if (isModEnabled('variants')) { +if (!empty($conf->variants->enabled)) { @@ -67,2 +57,0 @@ - -// Load translation files required by the page @@ -70,6 +59,2 @@ -if (isModEnabled('incoterm')) { - $langs->load('incoterm'); -} - - -// Get Parameters +if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); + @@ -78,7 +63,3 @@ -$action = GETPOST('action', 'alpha'); -$confirm = GETPOST('confirm', 'alpha'); -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'purchaseordercard'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); -$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); - -$socid = GETPOST('socid', 'int'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); +$socid = GETPOST('socid', 'int'); @@ -86,10 +67,11 @@ -$cancel = GETPOST('cancel', 'alpha'); -$lineid = GETPOST('lineid', 'int'); -$origin = GETPOST('origin', 'alpha'); -$originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility -$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; - -// PDF -$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0)); -$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0)); -$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0)); +$cancel = GETPOST('cancel', 'alpha'); +$lineid = GETPOST('lineid', 'int'); + +$lineid = GETPOST('lineid', 'int'); +$origin = GETPOST('origin', 'alpha'); +$originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility + +//PDF +$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); @@ -101,3 +83,2 @@ -if (!empty($user->socid)) { - $socid = $user->socid; -} +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); @@ -114,2 +95,7 @@ -if ($user->socid) { - $socid = $user->socid; +// Load object +if ($id > 0 || !empty($ref)) +{ + $ret = $object->fetch($id, $ref); + if ($ret < 0) dol_print_error($db, $object->error); + $ret = $object->fetch_thirdparty(); + if ($ret < 0) dol_print_error($db, $object->error); @@ -117,7 +103,6 @@ - -// Load object -if ($id > 0 || !empty($ref)) { - $ret = $object->fetch($id, $ref); - if ($ret < 0) { - dol_print_error($db, $object->error); - } +elseif (!empty($socid) && $socid > 0) +{ + $fourn = new Fournisseur($db); + $ret = $fourn->fetch($socid); + if ($ret < 0) dol_print_error($db, $object->error); + $object->socid = $fourn->id; @@ -125,9 +110 @@ - if ($ret < 0) { - dol_print_error($db, $object->error); - } -} elseif (!empty($socid) && $socid > 0) { - $object->socid = $socid; - $ret = $object->fetch_thirdparty(); - if ($ret < 0) { - dol_print_error($db, $object->error); - } + if ($ret < 0) dol_print_error($db, $object->error); @@ -136,35 +113,4 @@ -// Security check -$isdraft = (isset($object->statut) && ($object->statut == $object::STATUS_DRAFT) ? 1 : 0); -$result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande', 'fk_soc', 'rowid', $isdraft); - -// Common permissions -$usercanread = ($user->hasRight("fournisseur", "commande", "lire") || $user->hasRight("supplier_order", "lire")); -$usercancreate = ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer")); -$usercandelete = (($user->hasRight("fournisseur", "commande", "supprimer") || $user->hasRight("supplier_order", "supprimer")) || ($usercancreate && isset($object->statut) && $object->statut == $object::STATUS_DRAFT)); - -// Advanced permissions -$usercanvalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight("fournisseur", "supplier_order_advance", "validate"))); - -// Additional area permissions -$usercanapprove = $user->hasRight("fournisseur", "commande", "approuver"); -$usercanapprovesecond = $user->hasRight("fournisseur", "commande", "approve2"); -$usercanorder = $user->hasRight("fournisseur", "commande", "commander"); -if (!isModEnabled('reception')) { - $usercanreceive = $user->hasRight("fournisseur", "commande", "receptionner"); -} else { - $usercanreceive = $user->hasRight("reception", "creer"); -} - -// Permissions for includes -$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php -$permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php -$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php - -// Project permission -$caneditproject = false; -if (isModEnabled('project')) { - $caneditproject = !getDolGlobalString('SUPPLIER_ORDER_FORBID_EDIT_PROJECT') || ($object->statut == CommandeFournisseur::STATUS_DRAFT && preg_match('/^[\(]?PROV/i', $object->ref)); -} - -$error = 0; +$permissionnote = $user->rights->fournisseur->commande->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->fournisseur->commande->creer; // Used by the include of actions_dellink.inc.php +$permissiontoedit = $user->rights->fournisseur->commande->creer; // Used by the include of actions_lineupdown.inc.php +$permissiontoadd = $user->rights->fournisseur->commande->creer; // Used by the include of actions_addupdatedelete.inc.php @@ -179,22 +125,8 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - $backurlforlist = DOL_URL_ROOT.'/fourn/commande/list.php'.($socid > 0 ? '?socid='.((int) $socid) : ''); - - if (empty($backtopage) || ($cancel && empty($id))) { - if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { - if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { - $backtopage = $backurlforlist; - } else { - $backtopage = DOL_URL_ROOT.'/fourn/commande/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__'); - } - } - } - - if ($cancel) { - if (!empty($backtopageforcancel)) { - header("Location: ".$backtopageforcancel); - exit; - } elseif (!empty($backtopage)) { +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + if ($cancel) + { + if (!empty($backtopage)) + { @@ -213 +145,2 @@ - if ($action == 'setref_supplier' && $usercancreate) { + if ($action == 'setref_supplier' && $user->rights->fournisseur->commande->creer) + { @@ -215,3 +148 @@ - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); @@ -221 +152,2 @@ - if ($action == 'set_incoterms' && $usercancreate) { + if ($action == 'set_incoterms' && $user->rights->fournisseur->commande->creer) + { @@ -223,3 +155 @@ - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); @@ -229 +159,2 @@ - if ($action == 'setconditions' && $usercancreate) { + if ($action == 'setconditions' && $user->rights->fournisseur->commande->creer) + { @@ -231,3 +162 @@ - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); @@ -237 +166,2 @@ - if ($action == 'setmode' && $usercancreate) { + if ($action == 'setmode' && $user->rights->fournisseur->commande->creer) + { @@ -239,5 +169,5 @@ - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } elseif ($action == 'setmulticurrencycode' && $usercancreate) { - // Multicurrency Code + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + } + + // Multicurrency Code + elseif ($action == 'setmulticurrencycode' && $user->rights->fournisseur->commande->creer) { @@ -245,3 +175,5 @@ - } elseif ($action == 'setmulticurrencyrate' && $usercancreate) { - // Multicurrency rate - $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int')); + } + + // Multicurrency rate + elseif ($action == 'setmulticurrencyrate' && $user->rights->fournisseur->commande->creer) { + $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx'))); @@ -251 +183,2 @@ - if ($action == 'setbankaccount' && $usercancreate) { + if ($action == 'setbankaccount' && $user->rights->fournisseur->commande->creer) + { @@ -253,3 +186 @@ - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); @@ -259,5 +190,4 @@ - if ($action == 'setdate_livraison' && $usercancreate) { - $result = $object->setDeliveryDate($user, $datelivraison); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } + if ($action == 'setdate_livraison' && $user->rights->fournisseur->commande->creer) + { + $result = $object->set_date_livraison($user, $datelivraison); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); @@ -267 +197,2 @@ - if ($action == 'classin' && $usercancreate && $caneditproject) { + if ($action == 'classin' && $user->rights->fournisseur->commande->creer) + { @@ -269,84 +200,82 @@ - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - - // Edit Thirdparty - if (getDolGlobalString('MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER') && $action == 'set_thirdparty' && $usercancreate && $object->statut == CommandeFournisseur::STATUS_DRAFT) { - $new_socid = GETPOST('new_socid', 'int'); - if (!empty($new_socid) && $new_socid != $object->thirdparty->id) { - $db->begin(); - - // Update supplier - $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur'; - $sql .= ' SET fk_soc = '.((int) $new_socid); - $sql .= ' WHERE fk_soc = '.((int) $object->thirdparty->id); - $sql .= ' AND rowid = '.((int) $object->id); - - $res = $db->query($sql); - - if (!$res) { - $db->rollback(); - } else { - $db->commit(); - - // Replace prices for each lines by new supplier prices - foreach ($object->lines as $l) { - $sql = 'SELECT price, unitprice, tva_tx, ref_fourn'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price'; - $sql .= ' WHERE fk_product = '.((int) $l->fk_product); - $sql .= ' AND fk_soc = '.((int) $new_socid); - $sql .= ' ORDER BY unitprice ASC'; - - $resql = $db->query($sql); - if ($resql) { - $num_row = $db->num_rows($resql); - if (empty($num_row)) { - // No product price for this supplier ! - $l->subprice = 0; - $l->total_ht = 0; - $l->total_tva = 0; - $l->total_ttc = 0; - $l->ref_supplier = ''; - $l->update(); - } else { - // No need for loop to keep best supplier price - $obj = $db->fetch_object($resql); - $l->subprice = $obj->unitprice; - $l->total_ht = $obj->price; - $l->tva_tx = $obj->tva_tx; - $l->total_tva = $l->total_ht * ($obj->tva_tx / 100); - $l->total_ttc = $l->total_ht + $l->total_tva; - $l->ref_supplier = $obj->ref_fourn; - $l->update(); - } - } else { - dol_print_error($db); - } - $db->free($resql); - } - $object->update_price(); - } - } - header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); - exit; - } - - if ($action == 'setremisepercent' && $usercancreate) { - $result = $object->set_remise($user, price2num(GETPOST('remise_percent'))); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - - if ($action == 'reopen') { // no test on permission here, permission to use will depends on status - if (in_array($object->statut, array(1, 2, 3, 4, 5, 6, 7, 9))) { - if ($object->statut == 1) { - $newstatus = 0; // Validated->Draft - } elseif ($object->statut == 2) { - $newstatus = 0; // Approved->Draft - } elseif ($object->statut == 3) { - $newstatus = 2; // Ordered->Approved - } elseif ($object->statut == 4) { - $newstatus = 3; - } elseif ($object->statut == 5) { + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + } + + // Edit Thirdparty + if (!empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && $action == 'set_thirdparty' && $user->rights->fournisseur->commande->creer && $object->statut == CommandeFournisseur::STATUS_DRAFT) + { + $new_socid = GETPOST('new_socid', 'int'); + if (!empty($new_socid) && $new_socid != $object->thirdparty->id) { + $db->begin(); + + // Update supplier + $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur'; + $sql .= ' SET fk_soc='.$new_socid; + $sql .= ' WHERE fk_soc='.$object->thirdparty->id; + $sql .= ' AND rowid='.$object->id; + + $res = $db->query($sql); + + if (!$res) $db->rollback(); + else { + $db->commit(); + + // Replace prices for each lines by new supplier prices + foreach ($object->lines as $l) { + $sql = 'SELECT price, unitprice, tva_tx, ref_fourn'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price'; + $sql .= ' WHERE fk_product='.$l->fk_product; + $sql .= ' AND fk_soc='.$new_socid; + $sql .= ' ORDER BY unitprice ASC'; + + $resql = $db->query($sql); + if ($resql) { + $num_row = $db->num_rows($resql); + if (empty($num_row)) { + // No product price for this supplier ! + $l->subprice = 0; + $l->total_ht = 0; + $l->total_tva = 0; + $l->total_ttc = 0; + $l->ref_supplier = ''; + $l->update(); + } + else { + // No need for loop to keep best supplier price + $obj = $db->fetch_object($resql); + $l->subprice = $obj->unitprice; + $l->total_ht = $obj->price; + $l->tva_tx = $obj->tva_tx; + $l->total_tva = $l->total_ht * ($obj->tva_tx / 100); + $l->total_ttc = $l->total_ht + $l->total_tva; + $l->ref_supplier = $obj->ref_fourn; + $l->update(); + } + } + else { + dol_print_error($db); + } + $db->free($resql); + } + $object->update_price(); + } + } + header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); + exit; + } + + if ($action == 'setremisepercent' && $user->rights->fournisseur->commande->creer) + { + $result = $object->set_remise($user, $_POST['remise_percent']); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); + } + + if ($action == 'reopen') // no test on permission here, permission to use will depends on status + { + if (in_array($object->statut, array(1, 2, 3, 4, 5, 6, 7, 9))) + { + if ($object->statut == 1) $newstatus = 0; // Validated->Draft + elseif ($object->statut == 2) $newstatus = 0; // Approved->Draft + elseif ($object->statut == 3) $newstatus = 2; // Ordered->Approved + elseif ($object->statut == 4) $newstatus = 3; + elseif ($object->statut == 5) + { @@ -358,9 +287,5 @@ - } elseif ($object->statut == 6) { - $newstatus = 2; // Canceled->Approved - } elseif ($object->statut == 7) { - $newstatus = 3; // Canceled->Process running - } elseif ($object->statut == 9) { - $newstatus = 1; // Refused->Validated - } else { - $newstatus = 2; - } + } + elseif ($object->statut == 6) $newstatus = 2; // Canceled->Approved + elseif ($object->statut == 7) $newstatus = 3; // Canceled->Process running + elseif ($object->statut == 9) $newstatus = 1; // Refused->Validated + else $newstatus = 2; @@ -372 +297,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -376 +302 @@ - $sql .= ' WHERE rowid = '.((int) $object->id); + $sql .= ' WHERE rowid = '.$object->id; @@ -380 +306,2 @@ - if ($newstatus == 0) { + if ($newstatus == 0) + { @@ -383 +310 @@ - $sql .= ' WHERE rowid = '.((int) $object->id); + $sql .= ' WHERE rowid = '.$object->id; @@ -392 +319,3 @@ - } else { + } + else + { @@ -403 +332,2 @@ - if ($action == 'classifybilled' && $usercancreate) { + if ($action == 'classifybilled' && $user->rights->fournisseur->commande->creer) + { @@ -411,10 +341,2 @@ - if ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha') !== '' && $usercancreate) { - // Define new vat_rate for all lines - $vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0); - $vat_rate = str_replace('*', '', $vat_rate); - $localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc); - $localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc); - foreach ($object->lines as $line) { - $result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->product_type, 0, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice, $line->ref_supplier); - } - } elseif ($action == 'addline' && $usercancreate) { + if ($action == 'addline' && $user->rights->fournisseur->commande->creer) + { @@ -428 +350 @@ - $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); + $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); @@ -431 +352,0 @@ - @@ -433 +354,2 @@ - if ($prod_entry_mode == 'free') { + if ($prod_entry_mode == 'free') + { @@ -435 +357,5 @@ - } else { + $price_ht = GETPOST('price_ht'); + $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + } + else + { @@ -437,14 +363,7 @@ - } - - $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); // Can be '1.2' or '1.2 (CODE)' - - $price_ht = price2num(GETPOST('price_ht'), 'MU', 2); - $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2); - $price_ttc = price2num(GETPOST('price_ttc'), 'MU', 2); - $price_ttc_devise = price2num(GETPOST('multicurrency_price_ttc'), 'CU', 2); - $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); - - $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0); - if (empty($remise_percent)) { - $remise_percent = 0; - } + $price_ht = GETPOST('price_ht'); + $tva_tx = ''; + } + + $qty = GETPOST('qty'.$predef); + $remise_percent = GETPOST('remise_percent'.$predef); + $price_ht_devise = GETPOST('multicurrency_price_ht'); @@ -463 +382,2 @@ - if ($prod_entry_mode == 'free' && GETPOST('price_ht') < 0 && $qty < 0) { + if ($prod_entry_mode == 'free' && GETPOST('price_ht') < 0 && $qty < 0) + { @@ -467 +387,2 @@ - if ($prod_entry_mode == 'free' && !GETPOST('idprodfournprice') && GETPOST('type') < 0) { + if ($prod_entry_mode == 'free' && !GETPOST('idprodfournprice') && GETPOST('type') < 0) + { @@ -471 +392,2 @@ - if ($prod_entry_mode == 'free' && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && $price_ht_devise === '') { // Unit price can be 0 but not '' + if ($prod_entry_mode == 'free' && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && $price_ht_devise === '') // Unit price can be 0 but not '' + { @@ -475 +397,2 @@ - if ($prod_entry_mode == 'free' && !GETPOST('dp_desc')) { + if ($prod_entry_mode == 'free' && !GETPOST('dp_desc')) + { @@ -479 +402,2 @@ - if (GETPOST('qty', 'alpha') == '') { // 0 is allowed for order + if (!GETPOST('qty')) + { @@ -484 +408 @@ - if (!$error && isModEnabled('variants') && $prod_entry_mode != 'free') { + if (!$error && !empty($conf->variants->enabled) && $prod_entry_mode != 'free') { @@ -498 +422,2 @@ - if ($prod_entry_mode != 'free' && empty($error)) { // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' + if ($prod_entry_mode != 'free' && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' + { @@ -502,3 +427 @@ - if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') { - $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) - } + if (GETPOST('idprodfournprice', 'alpha') == -1 || GETPOST('idprodfournprice', 'alpha') == '') $idprod = -99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) @@ -507 +430,2 @@ - if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) { + if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) + { @@ -512 +436,2 @@ - if (getDolGlobalString('SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) { + if (!empty($conf->global->SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER)) + { @@ -515 +440,2 @@ - if ($productsupplier->fourn_socid != $socid) { // The price we found is for another supplier, so we clear supplier price + if ($productsupplier->fourn_socid != $socid) // The price we found is for another supplier, so we clear supplier price + { @@ -518 +444,3 @@ - } else { + } + else + { @@ -522 +450,3 @@ - } elseif (GETPOST('idprodfournprice', 'alpha') > 0) { + } + elseif (GETPOST('idprodfournprice', 'alpha') > 0) + { @@ -524 +454 @@ - //$qtytosearch = -1; // We force qty to -1 to be sure to find if a supplier price exist + //$qtytosearch=-1; // We force qty to -1 to be sure to find if a supplier price exist @@ -529 +459,2 @@ - if ($idprod > 0) { + if ($idprod > 0) + { @@ -532,18 +462,0 @@ - // Define output language - if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) { - $outputlangs = $langs; - $newlang = ''; - if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - if (empty($newlang)) { - $newlang = $object->thirdparty->default_lang; - } - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang]["description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang]["description"] : $productsupplier->description; - } else { - $desc = $productsupplier->description; - } @@ -551,30 +464,5 @@ - if (!empty($productsupplier->desc_supplier) && getDolGlobalString('PRODUIT_FOURN_TEXTS')) { - $desc = $productsupplier->desc_supplier; - } - - //If text set in desc is the same as product descpription (as now it's preloaded) whe add it only one time - if (trim($product_desc) == trim($desc) && getDolGlobalString('PRODUIT_AUTOFILL_DESC')) { - $product_desc=''; - } - - if (!empty($product_desc) && getDolGlobalString('MAIN_NO_CONCAT_DESCRIPTION')) { - $desc = $product_desc; - } - if (!empty($product_desc) && trim($product_desc) != trim($desc)) { - $desc = dol_concatdesc($desc, $product_desc, '', getDolGlobalString('MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION')); - } - - $ref_supplier = $productsupplier->ref_supplier; - - // Get vat rate - $tva_npr = 0; - if (!GETPOSTISSET('tva_tx')) { // If vat rate not provided from the form (the form has the priority) - $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); - $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); - if (empty($tva_tx)) { - $tva_npr = 0; - } - } - - $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); - $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); + if (!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) { + $desc = $productsupplier->desc_supplier; + } else $desc = $productsupplier->description; + + if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); @@ -583 +471 @@ - if (GETPOST('price_ht') != '' || GETPOST('multicurrency_price_ht') != '') { + if ($price_ht != '' || $price_ht_devise != '') { @@ -586,5 +474 @@ - $pu_devise = price2num($price_ht_devise, 'CU'); - } elseif (GETPOST('price_ttc') != '' || GETPOST('multicurrency_price_ttc') != '') { - $price_base_type = 'TTC'; - $pu = price2num($price_ttc, 'MU'); - $pu_devise = price2num($price_ttc_devise, 'CU'); + $pu_ht_devise = price2num($price_ht_devise, 'MU'); @@ -595 +479 @@ - $pu_devise = 0; + $pu_ht_devise = 0; @@ -598 +482,3 @@ - $pu_devise = $productsupplier->fourn_multicurrency_unitprice; + $pu_ht_devise = $productsupplier->fourn_multicurrency_unitprice; + /*var_dump($pu); + var_dump($pu_ht_devise);exit;*/ @@ -602,3 +488,9 @@ - if (empty($pu)) { - $pu = 0; // If pu is '' or null, we force to have a numeric value - } + $ref_supplier = $productsupplier->ref_supplier; + + $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); + $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice', 'alpha')); + if (empty($tva_tx)) $tva_npr = 0; + $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); + $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); + + if (empty($pu)) $pu = 0; // If pu is '' or null, we force to have a numeric value @@ -608 +500 @@ - ($price_base_type == 'HT' ? $pu : 0), + $pu, @@ -614 +506 @@ - $productsupplier->product_fourn_price_id, + 0, // We already have the $idprod always defined @@ -618 +510 @@ - ($price_base_type == 'TTC' ? $pu : 0), + $pu_ttc, @@ -626 +518 @@ - $pu_devise, + $pu_ht_devise, @@ -628,2 +520 @@ - 0, - min($rank, count($object->lines) + 1) + 0 @@ -632 +523,2 @@ - if ($idprod == -99 || $idprod == 0) { + if ($idprod == -99 || $idprod == 0) + { @@ -638 +530,2 @@ - if ($idprod == -1) { + if ($idprod == -1) + { @@ -644 +537,3 @@ - } elseif (empty($error)) { // $price_ht is already set + } + elseif (empty($error)) // $price_ht is already set + { @@ -654,3 +549 @@ - if (!preg_match('/\((.*)\)/', $tva_tx)) { - $tva_tx = price2num($tva_tx); // $txtva can have format '5,1' or '5.1' or '5.1(XXX)', we must clean only if '5,1' - } + $tva_tx = price2num($tva_tx); // When vat is text input field @@ -662 +555,2 @@ - if (GETPOST('price_ht') != '' || GETPOST('multicurrency_price_ht') != '') { + if ($price_ht !== '') + { @@ -664 +558,3 @@ - } else { + } + else + { @@ -669 +565 @@ - $pu_ht_devise = price2num($price_ht_devise, 'CU'); + $pu_ht_devise = price2num($price_ht_devise, 'MU'); @@ -675 +571,2 @@ - if (!$error && $result > 0) { + if (!$error && $result > 0) + { @@ -681 +578,2 @@ - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { @@ -684,6 +582,2 @@ - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { - $newlang = $object->thirdparty->default_lang; - if (GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; @@ -694 +588 @@ - $model = $object->model_pdf; + $model = $object->modelpdf; @@ -698,3 +592 @@ - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } + if ($result < 0) dol_print_error($db, $result); @@ -721 +612,0 @@ - unset($_POST['units']); @@ -735 +626,3 @@ - } else { + } + else + { @@ -746,6 +639,6 @@ - if ($action == 'updateline' && $usercancreate && !GETPOST('cancel', 'alpha')) { - $db->begin(); - - $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - - if ($lineid) { + if ($action == 'updateline' && $user->rights->fournisseur->commande->creer && !GETPOST('cancel', 'alpha')) + { + $vat_rate = (GETPOST('tva_tx') ?GETPOST('tva_tx') : 0); + + if ($lineid) + { @@ -754,3 +647 @@ - if (!$res) { - dol_print_error($db); - } + if (!$res) dol_print_error($db); @@ -760,2 +651,4 @@ - if (getDolGlobalString('SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY')) { - if ($line->fk_product > 0 && $productsupplier->get_buyprice(0, price2num(GETPOST('qty', 'int')), $line->fk_product, 'none', GETPOST('socid', 'int')) < 0) { + if (!empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY)) + { + if ($line->fk_product > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), $line->fk_product, 'none', GETPOST('socid', 'int')) < 0) + { @@ -775 +668 @@ - // Define vat_rate + // Define vat_rate @@ -780 +673,2 @@ - if (GETPOST('price_ht') != '') { + if (GETPOST('price_ht') != '') + { @@ -782,3 +676,4 @@ - $ht = price2num(GETPOST('price_ht'), '', 2); - } else { - $reg = array(); + $ht = price2num(GETPOST('price_ht')); + } + else + { @@ -786 +681,2 @@ - if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) { // If vat is "xx (yy)" + if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) // If vat is "xx (yy)" + { @@ -791,2 +687,2 @@ - $ttc = price2num(GETPOST('price_ttc'), '', 2); - $ht = (float) $ttc / (1 + ($vatratecleaned / 100)); + $ttc = price2num(GETPOST('price_ttc')); + $ht = $ttc / (1 + ($vatratecleaned / 100)); @@ -796 +692 @@ - $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), 'CU', 2); + $pu_ht_devise = GETPOST('multicurrency_subprice'); @@ -810 +706 @@ - GETPOST('product_desc', 'restricthtml'), + $_POST['product_desc'], @@ -812,2 +708,2 @@ - price2num(GETPOST('qty'), 'MS'), - price2num(GETPOST('remise_percent'), '', 2), + $_POST['qty'], + $_POST['remise_percent'], @@ -819 +715 @@ - GETPOSTISSET("type") ? GETPOST("type") : $line->product_type, + isset($_POST["type"]) ? $_POST["type"] : $line->product_type, @@ -824 +720 @@ - GETPOST('units'), + $_POST['units'], @@ -856 +752,2 @@ - if ($result >= 0) { + if ($result >= 0) + { @@ -858 +755,2 @@ - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { @@ -861,6 +759,2 @@ - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { - $newlang = $object->thirdparty->default_lang; - } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; @@ -871 +765 @@ - $model = $object->model_pdf; + $model = $object->modelpdf; @@ -875,10 +769,7 @@ - if ($result < 0) { - dol_print_error($db, $result); - } - } - - $db->commit(); - } else { - $db->rollback(); - - setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) dol_print_error($db, $result); + } + } + else + { + dol_print_error($db, $object->error); + exit; @@ -889,3 +780,2 @@ - if ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { - $db->begin(); - + if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->fournisseur->commande->creer) + { @@ -893,3 +783,2 @@ - if ($result > 0) { - // reorder lines - $object->line_order(true); + if ($result > 0) + { @@ -899 +788 @@ - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) @@ -901,2 +790 @@ - } - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) @@ -904 +791,0 @@ - } @@ -909 +796 @@ - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -911,22 +798,3 @@ - $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } else { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - // Reset action to avoid asking again confirmation on failure - $action = ''; - } - - if (!$error) { - // reopen order if necessary - if ($object->status == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) { - if ($object->setStatus($user, CommandeFournisseur::STATUS_RECEIVED_PARTIALLY) < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $error++; - $action = ''; - } - } - } - - if (!$error) { - $db->commit(); + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + @@ -935,2 +803,6 @@ - } else { - $db->rollback(); + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + /* Fix bug 1485 : Reset action to avoid asking again confirmation on failure */ + $action = ''; @@ -941,3 +813,5 @@ - if ($action == 'confirm_valid' && $confirm == 'yes' && $usercanvalidate) { - $db->begin(); - + if ($action == 'confirm_valid' && $confirm == 'yes' && + ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->commande->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_order_advance->validate))) + ) + { @@ -946 +820,2 @@ - if ($result >= 0) { + if ($result >= 0) + { @@ -948 +823,2 @@ - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { @@ -951,6 +827,2 @@ - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { - $newlang = $object->thirdparty->default_lang; - } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; @@ -961 +833 @@ - $model = $object->model_pdf; + $model = $object->modelpdf; @@ -965,7 +837,5 @@ - if ($result < 0) { - $error++; - dol_print_error($db, $result); - } - } - } else { - $error++; + if ($result < 0) dol_print_error($db, $result); + } + } + else + { @@ -976 +846,2 @@ - if (!$error && !getDolGlobalString('SUPPLIER_ORDER_NO_DIRECT_APPROVE') && $usercanapprove && !(getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') && $object->hasProductsOrServices(1))) { + if (empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE) && $user->rights->fournisseur->commande->approuver && !(!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $object->hasProductsOrServices(1))) + { @@ -979,11 +850,4 @@ - - if (!$error) { - $db->commit(); - } else { - $db->rollback(); - } - } - - if (($action == 'confirm_approve' || $action == 'confirm_approve2') && $confirm == 'yes' && $usercanapprove) { - $db->begin(); - + } + + if (($action == 'confirm_approve' || $action == 'confirm_approve2') && $confirm == 'yes' && $user->rights->fournisseur->commande->approuver) + { @@ -993,4 +857,7 @@ - if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { - $qualified_for_stock_change = $object->hasProductsOrServices(2); - } else { - $qualified_for_stock_change = $object->hasProductsOrServices(1); + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + $qualified_for_stock_change = $object->hasProductsOrServices(2); + } + else + { + $qualified_for_stock_change = $object->hasProductsOrServices(1); @@ -1000,2 +867,4 @@ - if (isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') && $qualified_for_stock_change) { // warning name of option should be STOCK_CALCULATE_ON_SUPPLIER_APPROVE_ORDER - if (!$idwarehouse || $idwarehouse == -1) { + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $qualified_for_stock_change) // warning name of option should be STOCK_CALCULATE_ON_SUPPLIER_APPROVE_ORDER + { + if (!$idwarehouse || $idwarehouse == -1) + { @@ -1008 +877,2 @@ - if (!$error) { + if (!$error) + { @@ -1010,2 +880,3 @@ - if ($result > 0) { - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { + if ($result > 0) + { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -1014,6 +885,2 @@ - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { - $newlang = $object->thirdparty->default_lang; - } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; @@ -1024,4 +891,7 @@ - $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } else { - $error++; + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); + exit; + } + else + { @@ -1031,4 +901,7 @@ - - if (!$error) { - $db->commit(); - + } + + if ($action == 'confirm_refuse' && $confirm == 'yes' && $user->rights->fournisseur->commande->approuver) + { + $result = $object->refuse($user); + if ($result > 0) + { @@ -1037,14 +910,3 @@ - } else { - $db->rollback(); - } - } - - if ($action == 'confirm_refuse' && $confirm == 'yes' && $usercanapprove) { - if (GETPOST('refuse_note')) { - $object->refuse_note = GETPOST('refuse_note'); - } - $result = $object->refuse($user); - if ($result > 0) { - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); - exit; - } else { + } + else + { @@ -1056,14 +918,11 @@ - if ($action == 'commande') { - $methodecommande = GETPOST('methodecommande', 'int'); - - if ($cancel) { - $action = ''; - } elseif ($methodecommande <= 0) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("OrderMode")), null, 'errors'); - $action = 'createorder'; - } - } - - if ($action == 'confirm_commande' && $confirm == 'yes' && $usercanorder) { - $db->begin(); - + if ($action == 'commande') { + $methodecommande = GETPOST('methodecommande', 'int'); + + if ($methodecommande <= 0) { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("OrderMode")), null, 'errors'); + $action = 'makeorder'; + } + } + + if ($action == 'confirm_commande' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander) + { @@ -1071,2 +930,4 @@ - if ($result > 0) { - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { + if ($result > 0) + { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { @@ -1075,6 +936,2 @@ - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { - $newlang = $object->thirdparty->default_lang; - } + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; @@ -1085 +942 @@ - $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1088,8 +944,0 @@ - } else { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - } - - if (!$error) { - $db->commit(); - @@ -1098,7 +947,10 @@ - } else { - $db->rollback(); - } - } - - - if ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete) { + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + + + if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisseur->commande->supprimer) + { @@ -1106 +958,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -1109 +962,3 @@ - } else { + } + else + { @@ -1115,2 +970,4 @@ - if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) { - if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { + if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->fournisseur->commande->creer) + { + if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) + { @@ -1118,2 +975,5 @@ - } else { - if ($object->id > 0) { + } + else + { + if ($object->id > 0) + { @@ -1123 +983,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -1126 +987,3 @@ - } else { + } + else + { @@ -1136,38 +999,30 @@ - if ($action == 'livraison' && $usercanreceive) { - if ($cancel) { - $action = ''; - } else { - $db->begin(); - - if (GETPOST("type") != '') { - $date_liv = dol_mktime(GETPOST('rehour'), GETPOST('remin'), GETPOST('resec'), GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear")); - - $result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment")); // GETPOST("type") is 'tot', 'par', 'nev', 'can' - if ($result > 0) { - $langs->load("deliveries"); - setEventMessages($langs->trans("DeliveryStateSaved"), null); - $action = ''; - } elseif ($result == -3) { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - } else { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - } - } else { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Delivery")), null, 'errors'); - } - - if (!$error) { - $db->commit(); - } else { - $db->rollback(); - } - } - } - - if ($action == 'confirm_cancel' && $confirm == 'yes' && $usercanorder) { - if (GETPOST('cancel_note')) { - $object->cancel_note = GETPOST('cancel_note'); - } + if ($action == 'livraison' && $user->rights->fournisseur->commande->receptionner) + { + if (GETPOST("type") != '') + { + $date_liv = dol_mktime(GETPOST('rehour'), GETPOST('remin'), GETPOST('resec'), GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear")); + + $result = $object->Livraison($user, $date_liv, GETPOST("type"), GETPOST("comment")); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($result > 0) + { + $langs->load("deliveries"); + setEventMessages($langs->trans("DeliveryStateSaved"), null); + $action = ''; + } + elseif ($result == -3) + { + setEventMessages($object->error, $object->errors, 'errors'); + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + else + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Delivery")), null, 'errors'); + } + } + + if ($action == 'confirm_cancel' && $confirm == 'yes' && $user->rights->fournisseur->commande->commander) + { @@ -1175 +1030,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -1178 +1034,3 @@ - } else { + } + else + { @@ -1189 +1047 @@ - $trackid = 'sord'.$object->id; + $trackid = 'sor'.$object->id; @@ -1194 +1052 @@ - $permissiontoadd = $usercancreate; + $permissiontoadd = $user->rights->fournisseur->commande->creer; @@ -1198,2 +1056,3 @@ - if ($action == 'update_extras') { - $object->oldcopy = dol_clone($object, 2); + if ($action == 'update_extras') + { + $object->oldcopy = dol_clone($object); @@ -1202,6 +1061,5 @@ - $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) { - $error++; - } - - if (!$error) { + $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); + if ($ret < 0) $error++; + + if (!$error) + { @@ -1209 +1067,2 @@ - if (!$error) { + if (!$error) + { @@ -1211 +1070,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -1218 +1078 @@ - if ($error) { + if ($error) @@ -1220 +1079,0 @@ - } @@ -1226,4 +1085,6 @@ - if ($action == 'add' && $usercancreate) { - $error = 0; - $selectedLines = GETPOST('toselect', 'array'); - if ($socid < 1) { + if ($action == 'add' && $user->rights->fournisseur->commande->creer) + { + $error = 0; + $selectedLines = GETPOST('toselect', 'array'); + if ($socid < 1) + { @@ -1235 +1096,2 @@ - if (!$error) { + if (!$error) + { @@ -1241,2 +1103,2 @@ - $object->cond_reglement_id = GETPOST('cond_reglement_id', 'int'); - $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int'); + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); @@ -1244,3 +1106,3 @@ - $object->note_private = GETPOST('note_private', 'restricthtml'); - $object->note_public = GETPOST('note_public', 'restricthtml'); - $object->delivery_date = $datelivraison; + $object->note_private = GETPOST('note_private', 'none'); + $object->note_public = GETPOST('note_public', 'none'); + $object->date_livraison = $datelivraison; @@ -1250,2 +1112,2 @@ - $object->multicurrency_tx = price2num(GETPOST('originmulticurrency_tx', 'alpha')); - $object->fk_project = GETPOST('projectid', 'int'); + $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); + $object->fk_project = GETPOST('projectid'); @@ -1254 +1116,2 @@ - if (!$error) { + if (!$error) + { @@ -1256,13 +1119,10 @@ - if ($ret < 0) { - $error++; - } - } - - if (!$error) { - // If creation from another object of another module (Example: origin=propal, originid=1) - if (!empty($origin) && !empty($originid)) { - $element = $subelement = $origin; - $classname = ucfirst($subelement); - if ($origin == 'propal' || $origin == 'proposal') { - $element = 'comm/propal'; - $subelement = 'propal'; + if ($ret < 0) $error++; + } + + if (!$error) + { + // If creation from another object of another module (Example: origin=propal, originid=1) + if (!empty($origin) && !empty($originid)) + { + if ($origin == 'propal' || $origin == 'proposal') + { @@ -1269,0 +1130 @@ + $element = 'comm/propal'; $subelement = 'propal'; @@ -1271 +1132,3 @@ - if ($origin == 'order' || $origin == 'commande') { + elseif ($origin == 'order' || $origin == 'commande') + { + $classname = 'Commande'; @@ -1273 +1135,0 @@ - $classname = 'Commande'; @@ -1275 +1137,2 @@ - if ($origin == 'supplier_proposal') { + else + { @@ -1292 +1155,2 @@ - if ($id > 0) { + if ($id > 0) + { @@ -1299,3 +1163,3 @@ - if ($result > 0) { - $tmpdate = $srcobject->delivery_date; - $object->setDeliveryDate($user, $tmpdate); + if ($result > 0) + { + $object->set_date_livraison($user, $srcobject->date_livraison); @@ -1305 +1169,2 @@ - if (empty($lines) && method_exists($srcobject, 'fetch_lines')) { + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) + { @@ -1313,2 +1178,3 @@ - for ($i = 0; $i < $num; $i++) { - if (empty($lines[$i]->subprice) || $lines[$i]->qty <= 0 || !in_array($lines[$i]->id, $selectedLines)) { + for ($i = 0; $i < $num; $i++) + { + if (empty($lines[$i]->subprice) || $lines[$i]->qty <= 0 || !in_array($lines[$i]->id, $selectedLines)) @@ -1316 +1181,0 @@ - } @@ -1328 +1193,2 @@ - if (method_exists($lines[$i], 'fetch_optionals')) { // For avoid conflicts if + if (method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if + { @@ -1335 +1201,2 @@ - if ($origin == "commande") { + if ($origin == "commande") + { @@ -1337,3 +1204,3 @@ - $result = $productsupplier->find_min_price_product_fournisseur($lines[$i]->fk_product, $lines[$i]->qty, $object->socid); - $lines[$i]->subprice = 0; - if ($result > 0) { + $result = $productsupplier->find_min_price_product_fournisseur($lines[$i]->fk_product, $lines[$i]->qty, $srcobject->socid); + if ($result > 0) + { @@ -1342,24 +1208,0 @@ - // we need supplier subprice - foreach ($srcobject->lines as $li) { - $sql = 'SELECT price, unitprice, tva_tx, remise_percent, entity, ref_fourn'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'product_fournisseur_price'; - $sql .= ' WHERE fk_product = '.((int) $li->fk_product); - $sql .= ' AND entity IN ('.getEntity('product_fournisseur_price').')'; - $sql .= ' AND fk_soc = '.((int) $object->socid); - $sql .= ' ORDER BY unitprice ASC'; - - $resql = $db->query($sql); - if ($resql) { - $num_row = $db->num_rows($resql); - if (empty($num_row)) { - $li->remise_percent = 0; - } else { - $obj = $db->fetch_object($resql); - $li->subprice = $obj->unitprice; - $li->remise_percent = $obj->remise_percent; - } - } else { - dol_print_error($db); - } - $db->free($resql); - } @@ -1367 +1210,3 @@ - } else { + } + else + { @@ -1374,2 +1219,3 @@ - if ($origin == "commande") { - $soc = new Societe($db); + if ($origin == "commande") + { + $soc = new societe($db); @@ -1398 +1244 @@ - $array_option, + $array_option, @@ -1402,3 +1248 @@ - !empty($lines[$i]->id) ? $lines[$i]->id : $lines[$i]->rowid, - -1, - $lines[$i]->special_code + !empty($lines[$i]->id) ? $lines[$i]->id : $lines[$i]->rowid @@ -1408 +1251,0 @@ - setEventMessages($object->error, $object->errors, 'errors'); @@ -1426,2 +1269 @@ - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) @@ -1429 +1270,0 @@ - } @@ -1438,3 +1279,6 @@ - } else { - $id = $object->create($user); - if ($id < 0) { + } + else + { + $id = $object->create($user); + if ($id < 0) + { @@ -1447 +1291,2 @@ - if ($error) { + if ($error) + { @@ -1452 +1297,3 @@ - } else { + } + else + { @@ -1454 +1301 @@ - header("Location: ".$_SERVER['PHP_SELF']."?id=".urlencode($id)); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); @@ -1460 +1307,2 @@ - if ($action == 'webservice' && GETPOST('mode', 'alpha') == "send" && !GETPOST('cancel', 'alpha')) { + if ($action == 'webservice' && GETPOST('mode', 'alpha') == "send" && !GETPOST('cancel', 'alpha')) + { @@ -1498 +1346,2 @@ - foreach ($object->lines as $line) { + foreach ($object->lines as $line) + { @@ -1502 +1351,2 @@ - if ($result_product["result"]["result_code"] == "OK") { + if ($result_product["result"]["result_code"] == "OK") + { @@ -1533 +1383,2 @@ - if (empty($result_order["result"]["result_code"])) { //No result, check error str + if (empty($result_order["result"]["result_code"])) //No result, check error str + { @@ -1535 +1386,3 @@ - } elseif ($result_order["result"]["result_code"] != "OK") { //Something went wrong + } + elseif ($result_order["result"]["result_code"] != "OK") //Something went wrong + { @@ -1537 +1390,3 @@ - } else { + } + else + { @@ -1543,3 +1398,6 @@ - if (getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB') && $usercancreate) { - if ($action == 'addcontact') { - if ($object->id > 0) { + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->fournisseur->commande->creer) + { + if ($action == 'addcontact') + { + if ($object->id > 0) + { @@ -1547,5 +1405,5 @@ - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); - } - - if ($result >= 0) { + $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) + { @@ -1554,2 +1412,5 @@ - } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { @@ -1558 +1419,3 @@ - } else { + } + else + { @@ -1562,8 +1425,15 @@ - } elseif ($action == 'swapstatut' && $object->id > 0) { - // bascule du statut d'un contact - $result = $object->swapContactStatus(GETPOST('ligne', 'int')); - } elseif ($action == 'deletecontact' && $object->id > 0) { - // Efface un contact - $result = $object->delete_contact(GETPOST("lineid", 'int')); - - if ($result >= 0) { + } + + // bascule du statut d'un contact + elseif ($action == 'swapstatut' && $object->id > 0) + { + $result = $object->swapContactStatus(GETPOST('ligne')); + } + + // Efface un contact + elseif ($action == 'deletecontact' && $object->id > 0) + { + $result = $object->delete_contact($_GET["lineid"]); + + if ($result >= 0) + { @@ -1572 +1442,2 @@ - } else { + } + else { @@ -1588,8 +1459,2 @@ -if (isModEnabled('project')) { - $formproject = new FormProjets($db); -} - -$title = $object->ref." - ".$langs->trans('Card'); -if ($action == 'create') { - $title = $langs->trans("NewOrderSupplier"); -} +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } + @@ -1597 +1462,2 @@ -llxHeader('', $title, $help_url); +llxHeader('', $langs->trans("Order"), $help_url); + @@ -1600,2 +1466,2 @@ - -if ($action == 'create') { +if ($action == 'create') +{ @@ -1609 +1475,2 @@ - if ($socid > 0) { + if ($socid > 0) + { @@ -1614 +1481,2 @@ - if (!empty($origin) && !empty($originid)) { + if (!empty($origin) && !empty($originid)) + { @@ -1617 +1484,0 @@ - $classname = ucfirst($subelement); @@ -1624 +1491,2 @@ - if ($origin == 'propal' || $origin == 'proposal') { + if ($origin == 'propal' || $origin == 'proposal') + { @@ -1626,4 +1494,4 @@ - $element = 'comm/propal'; - $subelement = 'propal'; - } - if ($origin == 'order' || $origin == 'commande') { + $element = 'comm/propal'; $subelement = 'propal'; + } + elseif ($origin == 'order' || $origin == 'commande') + { @@ -1633 +1501,2 @@ - if ($origin == 'supplier_proposal') { + else + { @@ -1639 +1507,0 @@ - @@ -1644 +1512 @@ - if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) { + if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) @@ -1646 +1513,0 @@ - } @@ -1655,53 +1522,32 @@ - if ($origin == "commande") { - $cond_reglement_id = 0; - $mode_reglement_id = 0; - $delivery_date = ''; - $objectsrc->note_private = ''; - $objectsrc->note_public = ''; - if ($societe = $object->thirdparty) { - $cond_reglement_id = $societe->cond_reglement_supplier_id; - $mode_reglement_id = $societe->mode_reglement_supplier_id; - if (isModEnabled("multicurrency")) { - $currency_code = $societe->multicurrency_code; - if (getDolGlobalString('MULTICURRENCY_USE_ORIGIN_TX')) { - $currency_tx = $societe->multicurrency_tx; - } - } - } - } else { - $soc = $objectsrc->thirdparty; - - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); - $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); - $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); - $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : (!empty($soc->availability_id) ? $soc->availability_id : 0)); - $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0)); - $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0)); - //$remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_supplier_percent) ? $soc->remise_supplier_percent : 0)); - //$remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); - $dateinvoice = !getDolGlobalString('MAIN_AUTOFILL_DATE') ? -1 : ''; - - $datedelivery = (!empty($objectsrc->delivery_date) ? $objectsrc->delivery_date : ''); - - if (isModEnabled("multicurrency")) { - if (!empty($objectsrc->multicurrency_code)) { - $currency_code = $objectsrc->multicurrency_code; - } - if (getDolGlobalString('MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) { - $currency_tx = $objectsrc->multicurrency_tx; - } - } - - $note_private = $object->getDefaultCreateValueFor('note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null)); - $note_public = $object->getDefaultCreateValueFor('note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null)); - - // Object source contacts list - $srccontactslist = $objectsrc->liste_contact(-1, 'external', 1); - } - } else { - $cond_reglement_id = !empty($societe->cond_reglement_supplier_id) ? $societe->cond_reglement_supplier_id : 0; - $mode_reglement_id = !empty($societe->mode_reglement_supplier_id) ? $societe->mode_reglement_supplier_id : 0; - - if (isModEnabled("multicurrency") && !empty($societe->multicurrency_code)) { - $currency_code = $societe->multicurrency_code; - } + + $soc = $objectsrc->client; + $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0)); + $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0)); + $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); + $availability_id = (!empty($objectsrc->availability_id) ? $objectsrc->availability_id : (!empty($soc->availability_id) ? $soc->availability_id : 0)); + $shipping_method_id = (!empty($objectsrc->shipping_method_id) ? $objectsrc->shipping_method_id : (!empty($soc->shipping_method_id) ? $soc->shipping_method_id : 0)); + $demand_reason_id = (!empty($objectsrc->demand_reason_id) ? $objectsrc->demand_reason_id : (!empty($soc->demand_reason_id) ? $soc->demand_reason_id : 0)); + $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_supplier_percent) ? $soc->remise_supplier_percent : 0)); + $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : ''; + + $datedelivery = (!empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : ''); + + if (!empty($conf->multicurrency->enabled)) + { + if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; + if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx; + } + + $note_private = $object->getDefaultCreateValueFor('note_private', (!empty($objectsrc->note_private) ? $objectsrc->note_private : null)); + $note_public = $object->getDefaultCreateValueFor('note_public', (!empty($objectsrc->note_public) ? $objectsrc->note_public : null)); + + // Object source contacts list + $srccontactslist = $objectsrc->liste_contact(-1, 'external', 1); + } + else + { + $cond_reglement_id = $societe->cond_reglement_supplier_id; + $mode_reglement_id = $societe->mode_reglement_supplier_id; + + if (!empty($conf->multicurrency->enabled) && !empty($societe->multicurrency_code)) $currency_code = $societe->multicurrency_code; @@ -1714,6 +1560,2 @@ - if (empty($cond_reglement_id) && getDolGlobalString('SUPPLIER_ORDER_DEFAULT_PAYMENT_TERM_ID')) { - $cond_reglement_id = $conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_TERM_ID; - } - if (empty($mode_reglement_id) && getDolGlobalString('SUPPLIER_ORDER_DEFAULT_PAYMENT_MODE_ID')) { - $mode_reglement_id = $conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_MODE_ID; - } + if (empty($cond_reglement_id) && !empty($conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_TERM_ID)) $cond_reglement_id = $conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_TERM_ID; + if (empty($mode_reglement_id) && !empty($conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_MODE_ID)) $mode_reglement_id = $conf->global->SUPPLIER_ORDER_DEFAULT_PAYMENT_MODE_ID; @@ -1724 +1566,2 @@ - print ''; + print ''."\n"; + print ''; @@ -1727,14 +1570,168 @@ - if ($backtopage) { - print ''; - } - if ($backtopageforcancel) { - print ''; - } - - if (!empty($currency_tx)) { - print ''; - } - - print dol_get_fiche_head(''); - - // Call Hook tabContentCreateSupplierOrder + if (!empty($currency_tx)) print ''; + + dol_fiche_head(''); + + print ''; + + // Ref + print ''; + + // Third party + print ''; + print ''; + + if ($societe->id > 0) + { + // Discounts for third party + print ''; + } + + // Ref supplier + print ''; + print ''; + + // Payment term + print ''; + + // Payment mode + print ''; + + // Planned delivery date + print ''; + print ''; + + // Bank Account + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && !empty($conf->banque->enabled)) + { + $langs->load("bank"); + print ''; + } + + // Project + if (!empty($conf->projet->enabled)) + { + $formproject = new FormProjets($db); + + $langs->load('projects'); + print ''; + } + + // Incoterms + if (!empty($conf->incoterm->enabled)) + { + print ''; + print ''; + print ''; + } + + // Multicurrency + if (!empty($conf->multicurrency->enabled)) + { + print ''; + print ''; + print ''; + } + + print ''; + print ''; + //print ''; + print ''; + + print ''; + print ''; + //print ''; + print ''; + + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { + print "\n"; + print "\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''; + print ''; + + $newclassname = $classname; + print ''; + print ''; + print '"; + if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE + { + print '"; + } + + if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF + { + print '"; + } + + print '"; + + if (!empty($conf->multicurrency->enabled)) + { + print ''; + print ''; + print ''; + } + } + + // Other options @@ -1742,181 +1739,20 @@ - // Note that $action and $object may be modified by hook - $reshook = $hookmanager->executeHooks('tabContentCreateSupplierOrder', $parameters, $object, $action); - if (empty($reshook)) { - print '
'.$langs->trans('Ref').''.$langs->trans('Draft').'
'.$langs->trans('Supplier').''; + + if ($socid > 0) + { + print $societe->getNomUrl(1); + print ''; + } + else + { + print $form->select_company((empty($socid) ? '' : $socid), 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); + // reload page to retrieve customer informations + if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) + { + print ''; + } + print ' '; + } + print '
'.$langs->trans('Discounts').''; + + $absolute_discount = $societe->getAvailableDiscounts('', '', 0, 1); + + $thirdparty = $societe; + $discount_type = 1; + $backtopage = urlencode($_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid')); + include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; + + print '
'.$langs->trans('RefSupplier').'
'.$langs->trans('PaymentConditionsShort').''; + $form->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id'); + print '
'.$langs->trans('PaymentMode').''; + $form->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id'); + print '
'; + print $langs->trans('DateDeliveryPlanned'); + print ''; + $usehourmin = 0; + if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin = 1; + print $form->selectDate($datelivraison ? $datelivraison : -1, 'liv_', $usehourmin, $usehourmin, '', "set"); + print '
'.$langs->trans('BankAccount').''; + $form->select_comptes($fk_account, 'fk_account', 0, '', 1); + print '
'.$langs->trans('Project').''; + $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500'); + print '   id).'">'; + print '
'; + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); + print '
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; + print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); + print '
'.$langs->trans('NotePublic').''; + $doleditor = new DolEditor('note_public', isset($note_public) ? $note_public : GETPOST('note_public', 'none'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + print $doleditor->Create(1); + print '
'.$langs->trans('NotePrivate').''; + $doleditor = new DolEditor('note_private', isset($note_private) ? $note_private : GETPOST('note_private', 'none'), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + print $doleditor->Create(1); + print '
'.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1).'
'.$langs->trans('AmountHT').''.price($objectsrc->total_ht).'
'.$langs->trans('AmountVAT').''.price($objectsrc->total_tva)."
'.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($objectsrc->total_localtax1)."
'.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($objectsrc->total_localtax2)."
'.$langs->trans('AmountTTC').''.price($objectsrc->total_ttc)."
'.$langs->trans('MulticurrencyAmountHT').''.price($objectsrc->multicurrency_total_ht).'
'.$langs->trans('MulticurrencyAmountVAT').''.price($objectsrc->multicurrency_total_tva).'
'.$langs->trans('MulticurrencyAmountTTC').''.price($objectsrc->multicurrency_total_ttc).'
'; - - // Ref - print ''; - - // Third party - print ''; - print ''; - - if (!empty($societe->id) && $societe->id > 0) { - // Discounts for third party - print ''; - } - - // Ref supplier - print ''; - print ''; - - // Payment term - print ''; - - // Payment mode - print ''; - - // Planned delivery date - print ''; - print ''; - - // Bank Account - if (getDolGlobalString('BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER') && isModEnabled("banque")) { - $langs->load("bank"); - print ''; - } - - // Project - if (isModEnabled('project')) { - $formproject = new FormProjets($db); - - $langs->load('projects'); - print ''; - } - - // Incoterms - if (isModEnabled('incoterm')) { - $fkincoterms = (!empty($object->fk_incoterms) ? $object->fk_incoterms : ($socid > 0 ? $societe->fk_incoterms : '')); - $locincoterms = (!empty($object->location_incoterms) ? $object->location_incoterms : ($socid > 0 ? $societe->location_incoterms : '')); - print ''; - print ''; - print ''; - } - - // Multicurrency - if (isModEnabled("multicurrency")) { - print ''; - print ''; - print ''; - } - - print ''; - print ''; - //print ''; - print ''; - - print ''; - print ''; - //print ''; - print ''; - - if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { - print "\n"; - print "\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''; - print ''; - - $newclassname = $classname; - print ''; - print ''; - print '"; - if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) { // Localtax1 RE - print '"; - } - - if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) { // Localtax2 IRPF - print '"; - } - - print '"; - - if (isModEnabled("multicurrency")) { - print ''; - print ''; - print ''; - } - } - - // Other options - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - if (empty($reshook)) { - print $object->showOptionals($extrafields, 'create'); - } - - // Bouton "Create Draft" - print "
'.$langs->trans('Ref').''.$langs->trans('Draft').'
'.$langs->trans('Supplier').''; - - if (!empty($societe->id) && $societe->id > 0) { - print $societe->getNomUrl(1, 'supplier'); - print ''; - } else { - $filter = '((s.fournisseur:=:1) AND (s.status:=:1))'; - print img_picto('', 'company', 'class="pictofixedwidth"').$form->select_company((empty($socid) ? '' : $socid), 'socid', $filter, 'SelectThirdParty', 1, 0, null, 0, 'minwidth175 maxwidth500 widthcentpercentminusxx'); - // reload page to retrieve customer informations - if (!getDolGlobalString('RELOAD_PAGE_ON_SUPPLIER_CHANGE_DISABLED')) { - print ''; - } - print ' '; - } - print '
'.$langs->trans('Discounts').''; - - $absolute_discount = $societe->getAvailableDiscounts('', '', 0, 1); - - $thirdparty = $societe; - $discount_type = 1; - $backtopage = urlencode($_SERVER["PHP_SELF"].'?socid='.$thirdparty->id.'&action='.$action.'&origin='.GETPOST('origin').'&originid='.GETPOST('originid')); - include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; - - print '
'.$langs->trans('RefSupplier').'
'.$langs->trans('PaymentConditionsShort').''; - print img_picto('', 'payment', 'class="pictofixedwidth"'); - print $form->getSelectConditionsPaiements((GETPOSTISSET('cond_reglement_id') && GETPOST('cond_reglement_id') != 0) ? GETPOST('cond_reglement_id') : $cond_reglement_id, 'cond_reglement_id', -1, 1); - print '
'.$langs->trans('PaymentMode').''; - print img_picto('', 'bank', 'class="pictofixedwidth"'); - $form->select_types_paiements((GETPOSTISSET('mode_reglement_id') && GETPOST('mode_reglement_id') != 0) ? GETPOST('mode_reglement_id') : $mode_reglement_id, 'mode_reglement_id'); - print '
'; - print $langs->trans('DateDeliveryPlanned'); - print ''; - $usehourmin = 0; - if (getDolGlobalString('SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE')) { - $usehourmin = 1; - } - print img_picto('', 'action', 'class="pictofixedwidth"'); - print $form->selectDate($datelivraison ? $datelivraison : -1, 'liv_', $usehourmin, $usehourmin, '', "set"); - print '
'.$langs->trans('BankAccount').''; - print img_picto('', 'bank_account', 'class="pictofixedwidth"'); - $form->select_comptes($fk_account, 'fk_account', 0, '', 1); - print '
'.$langs->trans('Project').''; - print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects((!getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); - print '   id) ? '&socid='.$societe->id : "")).'">'; - print '
'; - print img_picto('', 'incoterm', 'class="pictofixedwidth"'); - print $form->select_incoterms($fkincoterms, $locincoterms); - print '
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; - print img_picto('', 'currency', 'class="pictofixedwidth"'); - print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); - print '
'.$langs->trans('NotePublic').''; - $doleditor = new DolEditor('note_public', isset($note_public) ? $note_public : GETPOST('note_public', 'restricthtml'), '', 80, 'dolibarr_notes', 'In', 0, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3, '90%'); - print $doleditor->Create(1); - print '
'.$langs->trans('NotePrivate').''; - $doleditor = new DolEditor('note_private', isset($note_private) ? $note_private : GETPOST('note_private', 'restricthtml'), '', 80, 'dolibarr_notes', 'In', 0, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3, '90%'); - print $doleditor->Create(1); - print '
'.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1, 'supplier').'
'.$langs->trans('AmountHT').''.price($objectsrc->total_ht).'
'.$langs->trans('AmountVAT').''.price($objectsrc->total_tva)."
'.$langs->transcountry("AmountLT1", $mysoc->country_code).''.price($objectsrc->total_localtax1)."
'.$langs->transcountry("AmountLT2", $mysoc->country_code).''.price($objectsrc->total_localtax2)."
'.$langs->trans('AmountTTC').''.price($objectsrc->total_ttc)."
'.$langs->trans('MulticurrencyAmountHT').''.price($objectsrc->multicurrency_total_ht).'
'.$langs->trans('MulticurrencyAmountVAT').''.price($objectsrc->multicurrency_total_tva).'
'.$langs->trans('MulticurrencyAmountTTC').''.price($objectsrc->multicurrency_total_ttc).'
\n"; - } - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel("CreateDraft"); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + if (empty($reshook)) + { + print $object->showOptionals($extrafields, 'edit'); + } + + // Bouton "Create Draft" + print "\n"; + + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + @@ -1925 +1761,2 @@ - if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) + { @@ -1929 +1765,0 @@ - print '
'; @@ -1932,2 +1767,0 @@ - $selectedLines = array(); - @@ -1937,5 +1771,5 @@ - print '
'; - } - print "\n"; -} elseif (!empty($object->id)) { - // view + } + print "\n"; +} +elseif (!empty($object->id)) +{ @@ -1943,3 +1777,4 @@ - $object->fetch_thirdparty(); - - $societe = $object->thirdparty; + + $societe = new Fournisseur($db); + $result = $societe->fetch($object->socid); + if ($result < 0) dol_print_error($db); @@ -1949,0 +1785,3 @@ + $res = $object->fetch_optionals(); + + @@ -1953 +1791 @@ - print dol_get_fiche_head($head, 'card', $title, -1, 'order'); + dol_fiche_head($head, 'card', $title, -1, 'order'); @@ -1959 +1797,2 @@ - if ($action == 'delete') { + if ($action == 'delete') + { @@ -1964,2 +1803,2 @@ - if ($action == 'clone') { - $filter = '(s.fournisseur:=:1)'; + if ($action == 'clone') + { @@ -1968 +1807 @@ - array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', $filter)) + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.fournisseur=1)')) @@ -1975 +1814,2 @@ - if ($action == 'valid') { + if ($action == 'valid') + { @@ -1979 +1819,2 @@ - if (preg_match('/^[\(]?PROV/i', $object->ref) || empty($object->ref)) { // empty should not happened, but when it occurs, the test save life + if (preg_match('/^[\(]?PROV/i', $object->ref) || empty($object->ref)) // empty should not happened, but when it occurs, the test save life + { @@ -1981,5 +1822,5 @@ - } else { - $newref = $object->ref; - } - - if ($newref < 0) { + } + else $newref = $object->ref; + + if ($newref < 0) + { @@ -1988 +1829,3 @@ - } else { + } + else + { @@ -1990 +1833,2 @@ - if (isModEnabled('notification')) { + if (!empty($conf->notification->enabled)) + { @@ -2002 +1846,2 @@ - if ($action == 'approve' || $action == 'approve2') { + if ($action == 'approve' || $action == 'approve2') + { @@ -2004 +1849,2 @@ - if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { @@ -2006 +1852,3 @@ - } else { + } + else + { @@ -2011 +1859,2 @@ - if (isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') && $qualified_for_stock_change) { + if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) && $qualified_for_stock_change) + { @@ -2016,3 +1865 @@ - if ($conf->browser->name == 'ie') { - $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - } + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy @@ -2027 +1874,2 @@ - if (isModEnabled('notification')) { + if (!empty($conf->notification->enabled)) + { @@ -2037,26 +1885,10 @@ - // Confirmation of disapproval - if ($action == 'refuse') { - $formquestion = array( - array( - 'type' => 'text', - 'name' => 'refuse_note', - 'label' => $langs->trans("Reason"), - 'value' => '', - 'morecss' => 'minwidth300' - ) - ); - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("DenyingThisOrder"), $langs->trans("ConfirmDenyingThisOrder", $object->ref), "confirm_refuse", $formquestion, 0, 1); - } - - // Confirmation of cancellation - if ($action == 'cancel') { - $formquestion = array( - array( - 'type' => 'text', - 'name' => 'cancel_note', - 'label' => $langs->trans("Reason"), - 'value' => '', - 'morecss' => 'minwidth300' - ) - ); - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("Cancel"), $langs->trans("ConfirmCancelThisOrder", $object->ref), "confirm_cancel", $formquestion, 0, 1); + // Confirmation de la desapprobation + if ($action == 'refuse') + { + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("DenyingThisOrder"), $langs->trans("ConfirmDenyingThisOrder", $object->ref), "confirm_refuse", '', 0, 1); + } + + // Confirmation de l'annulation + if ($action == 'cancel') + { + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("Cancel"), $langs->trans("ConfirmCancelThisOrder", $object->ref), "confirm_cancel", '', 0, 1); @@ -2066 +1898,2 @@ - if ($action == 'commande') { + if ($action == 'commande') + { @@ -2068,7 +1901 @@ - if (!empty($conf->notification->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; - $notify = new Notify($db); - $text .= '
'; - $text .= $notify->confirmMessage('ORDER_SUPPLIER_SUBMIT', $object->socid, $object); - } - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id."&datecommande=".$date_com."&methode=".GETPOST("methodecommande")."&comment=".urlencode(GETPOST("comment")), $langs->trans("MakeOrder"), $langs->trans("ConfirmMakeOrder", dol_print_date($date_com, 'day')), "confirm_commande", '', 0, 2); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id."&datecommande=".$date_com."&methode=".$_POST["methodecommande"]."&comment=".urlencode($_POST["comment"]), $langs->trans("MakeOrder"), $langs->trans("ConfirmMakeOrder", dol_print_date($date_com, 'day')), "confirm_commande", '', 0, 2); @@ -2078,2 +1905,3 @@ - if ($action == 'ask_deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); + if ($action == 'ask_deleteline') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); @@ -2084,5 +1912,2 @@ - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } + if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; @@ -2100,2 +1925,2 @@ - $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreate, 'string', '', 0, 1); - $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreate, 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':' . getDolGlobalString('THIRDPARTY_REF_INPUT_SIZE') : ''), '', null, null, '', 1); + $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1); @@ -2103,19 +1928,17 @@ - $morehtmlref .= '
'; - if (getDolGlobalString('MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER') && !empty($usercancreate) && $action == 'edit_thirdparty') { - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $filter = '(s.fournisseur:=:1)'; - $morehtmlref .= $form->select_company($object->thirdparty->id, 'new_socid', $filter, '', 0, 0, array(), 0, 'minwidth300'); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } - if (!getDolGlobalString('MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER') || $action != 'edit_thirdparty') { - if (getDolGlobalString('MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER') && $object->statut == CommandeFournisseur::STATUS_DRAFT) { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetThirdParty')).''; - } - $morehtmlref .= $object->thirdparty->getNomUrl(1, 'supplier'); - if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; - } - } + $morehtmlref .= '
'.$langs->trans('ThirdParty'); + if (!empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && !empty($user->rights->fournisseur->commande->creer) && $action == 'edit_thirdparty') { + $morehtmlref .= ' : '; + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $form->select_company($object->thirdparty->id, 'new_socid', 's.fournisseur=1', '', 0, 0, array(), 0, 'minwidth300'); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } + if (empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) || $action != 'edit_thirdparty') { + if (!empty($conf->global->MAIN_CAN_EDIT_SUPPLIER_ON_SUPPLIER_ORDER) && $object->statut == CommandeFournisseur::STATUS_DRAFT) { + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetThirdParty')).''; + } + $morehtmlref .= ' : '.$object->thirdparty->getNomUrl(1); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherOrders").')'; + } @@ -2124,9 +1947,142 @@ - if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref .= '
'; - if ($permissiontoadd) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify' && $caneditproject) { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (!getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 1, 0, 0, 1, '', 'maxwidth300'); + if (!empty($conf->projet->enabled)) { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->fournisseur->commande->creer) { + if ($action != 'classify') + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } + else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } + else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } + else { + $morehtmlref .= ''; + } + } + } + $morehtmlref .= ''; + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + + print '
'; + print '
'; + print '
'; + + print ''; + + // Date + if ($object->methode_commande_id > 0) + { + print '"; + + if ($object->methode_commande) + { + print ''; + } + } + + // Author + print ''; + print ''; + print ''; + + // Relative and absolute discounts + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice + $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice + } else { + $filterabsolutediscount = "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')"; + $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')"; + } + + $absolute_discount = $societe->getAvailableDiscounts('', $filterabsolutediscount, 0, 1); + $absolute_creditnote = $societe->getAvailableDiscounts('', $filtercreditnote, 0, 1); + $absolute_discount = price2num($absolute_discount, 'MT'); + $absolute_creditnote = price2num($absolute_creditnote, 'MT'); + + print ''; + + // Default terms of the settlement + $langs->load('bills'); + print '"; + print ''; + + // Mode of payment + $langs->load('bills'); + print ''; + + // Multicurrency + if (!empty($conf->multicurrency->enabled)) + { + // Multicurrency code + print ''; + print ''; - } - print '
'.$langs->trans("Date").''; + if ($object->date_commande) + { + print dol_print_date($object->date_commande, "dayhour")."\n"; + } + print "
'.$langs->trans("Method").''.$object->getInputMethod().'
'.$langs->trans("AuthorRequest").''.$author->getNomUrl(1, '', 0, 0, 0).'
'.$langs->trans('Discounts').''; + + $thirdparty = $societe; + $discount_type = 1; + $backtopage = urlencode($_SERVER["PHP_SELF"].'?id='.$object->id); + include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; + + print '
'; + print ''; + print '
'; + print $langs->trans('PaymentConditions'); + print ''; + if ($action != 'editconditions') print 'id.'">'.img_edit($langs->trans('SetConditions'), 1).'
'; + print '
'; + if ($action == 'editconditions') + { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); + } + else + { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none'); + } + print "
'; + print ''; + if ($action != 'editmode') print ''; + print '
'; + print $langs->trans('PaymentMode'); + print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; + print '
'; + if ($action == 'editmode') + { + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'DBIT', 1, 1); + } + else + { + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); + } + print '
'; + print ''; + if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_DRAFT) + print ''; + print '
'; + print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; + print '
'; + if ($action == 'editmulticurrencycode') { + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); @@ -2134,70 +2090,2 @@ - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } - } - } - } - $morehtmlref .= ''; - - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - // Call Hook tabContentViewSupplierOrder - $parameters = array(); - // Note that $action and $object may be modified by hook - $reshook = $hookmanager->executeHooks('tabContentViewSupplierOrder', $parameters, $object, $action); - if (empty($reshook)) { - print '
'; - print '
'; - print '
'; - - print ''; - - // Date - if ($object->methode_commande_id > 0) { - $usehourmin = 0; - if (getDolGlobalString('SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE')) { - $usehourmin = 1; - } - print '"; - - if ($object->methode_commande) { - print ''; - } - } - - // Author - print ''; - print ''; - print ''; - - // Relative and absolute discounts - if (getDolGlobalString('FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS')) { - $filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice - $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice - } else { - $filterabsolutediscount = "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')"; - $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')"; - } - - $absolute_discount = $societe->getAvailableDiscounts('', $filterabsolutediscount, 0, 1); - $absolute_creditnote = $societe->getAvailableDiscounts('', $filtercreditnote, 0, 1); - $absolute_discount = price2num($absolute_discount, 'MT'); - $absolute_creditnote = price2num($absolute_creditnote, 'MT'); - - print ''; + print ''; + } + } + + // Bank Account + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER) && !empty($conf->banque->enabled)) + { @@ -2210 +2129 @@ - print $langs->trans('PaymentConditions'); + print $langs->trans('BankAccount'); @@ -2212,3 +2131,2 @@ - if ($action != 'editconditions') { - print ''; - } + if ($action != 'editbankaccount' && $user->rights->fournisseur->commande->creer) + print ''; @@ -2217,2 +2135,2 @@ - if ($action == 'editconditions') { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); + if ($action == 'editbankaccount') { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); @@ -2220,3 +2138,3 @@ - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none'); - } - print ""; + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); + } + print ''; @@ -2224,96 +2142,41 @@ - - // Mode of payment - $langs->load('bills'); - print ''; - - // Multicurrency - if (isModEnabled("multicurrency")) { - // Multicurrency code - print ''; - print ''; - - // Multicurrency rate - if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { - print ''; - print ''; - } - } - - // Bank Account - if (getDolGlobalString('BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER') && isModEnabled("banque")) { - print ''; - print ''; - } - - // Delivery delay (in days) - print ''; - print ''; - print ''; - print ''; - - // Delivery date planed + } + + // Delivery date planed + print ''; + + // Delivery delay (in days) + print ''; + print ''; + print ''; + print ''; + + // Incoterms + if (!empty($conf->incoterm->enabled)) + { @@ -2322 +2185,5 @@ - print $langs->trans('DateDeliveryPlanned'); + print $langs->trans('IncotermLabel'); + print '
'.$langs->trans("Date").''; - print $object->date_commande ? dol_print_date($object->date_commande, $usehourmin ? 'dayhour' : 'day') : ''; - if ($object->hasDelay() && !empty($object->delivery_date) && !empty($object->date_commande)) { - print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); - } - print "
'.$langs->trans("Method").''.$object->getInputMethod().'
'.$langs->trans("AuthorRequest").''.$author->getNomUrl(-1, '', 0, 0, 0).'
'.$langs->trans('Discounts').''; - - $thirdparty = $societe; - $discount_type = 1; - $backtopage = urlencode($_SERVER["PHP_SELF"].'?id='.$object->id); - include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; - + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'none'); + } @@ -2206,2 +2094,33 @@ - // Default terms of the settlement - $langs->load('bills'); + // Multicurrency rate + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) + { + print '
'; + print ''; + print ''; + if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) + print ''; + print '
'; + print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; + print '
'; + if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { + if ($action == 'actualizemulticurrencyrate') { + list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); + } + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); + } else { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { + print '
        '; + print ''.$langs->trans("ActualizeCurrency").''; + print '
'; + } + } + print '
id.'">'.img_edit($langs->trans('SetConditions'), 1).'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; - print ''; - if ($action != 'editmode') { - print ''; - } - print '
'; - print $langs->trans('PaymentMode'); - print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; - print '
'; - if ($action == 'editmode') { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'DBIT', 1, 1); - } else { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); - } - print '
'; - print ''; - if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_DRAFT) { - print ''; - } - print '
'; - print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); - print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; - print '
'; - if ($action == 'editmulticurrencycode') { - $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); - } else { - $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'none'); - } - print '
'; - print ''; - print ''; - if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { - print ''; - } - print '
'; - print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); - print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; - print '
'; - if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { - if ($action == 'actualizemulticurrencyrate') { - list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); - } - $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); - } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); - if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { - print '
        '; - print ''.$langs->trans("ActualizeCurrency").''; - print '
'; - } - } - print '
'; - print ''; - } - print '
'; - print $langs->trans('BankAccount'); - print ''; - if ($action != 'editbankaccount' && $usercancreate) { - print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; - print '
'; - if ($action == 'editbankaccount') { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); - } else { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); - } - print '
'.$langs->trans('NbDaysToDelivery').' '.img_picto($langs->trans('DescNbDaysToDelivery'), 'info', 'style="cursor:help"').''.$object->getMaxDeliveryTimeDay($langs).'
'; + print ''; + if ($action != 'editdate_livraison') print ''; + print '
'; + print $langs->trans('DateDeliveryPlanned'); + print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).'
'; + print '
'; + if ($action == 'editdate_livraison') + { + print '
'; + print ''; + print ''; + $usehourmin = 0; + if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin = 1; + print $form->selectDate($object->date_livraison ? $object->date_livraison : -1, 'liv_', $usehourmin, $usehourmin, '', "setdate_livraison"); + print ''; + print '
'; + } + else + { + $usehourmin = 'day'; + if (!empty($conf->global->SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE)) $usehourmin = 'dayhour'; + print $object->date_livraison ? dol_print_date($object->date_livraison, $usehourmin) : ' '; + if ($object->hasDelay() && !empty($object->date_livraison)) { + print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); + } + } + print '
'.$langs->trans('NbDaysToDelivery').' '.img_picto($langs->trans('DescNbDaysToDelivery'), 'info', 'style="cursor:help"').''.$object->getMaxDeliveryTimeDay($langs).'
'; + if ($user->rights->fournisseur->commande->creer) print ''.img_edit().''; + else print ' '; + print '
'; @@ -2324,25 +2191,8 @@ - if ($action != 'editdate_livraison') { - print '
id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).'
'; - print ''; - if ($action == 'editdate_livraison') { - print '
'; - print ''; - print ''; - $usehourmin = 0; - if (getDolGlobalString('SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE')) { - $usehourmin = 1; - } - print $form->selectDate($object->delivery_date ? $object->delivery_date : -1, 'liv_', $usehourmin, $usehourmin, '', "setdate_livraison"); - print ''; - print '
'; - } else { - $usehourmin = 'day'; - if (getDolGlobalString('SUPPLIER_ORDER_USE_HOUR_FOR_DELIVERY_DATE')) { - $usehourmin = 'dayhour'; - } - print $object->delivery_date ? dol_print_date($object->delivery_date, $usehourmin) : ' '; - if ($object->hasDelay() && !empty($object->delivery_date) && ($object->statut == $object::STATUS_ORDERSENT || $object->statut == $object::STATUS_RECEIVED_PARTIALLY)) { - print ' '.img_picto($langs->trans("Late").' : '.$object->showDelay(), "warning"); - } + print ''; + if ($action != 'editincoterm') + { + print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); + } + else + { + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); @@ -2351,42 +2201,19 @@ - - // Incoterms - if (isModEnabled('incoterm')) { - print ''; - print '
'; - print $langs->trans('IncotermLabel'); - print ''; - if ($usercancreate) { - print ''.img_edit().''; - } else { - print ' '; - } - print '
'; - print ''; - print ''; - if ($action != 'editincoterm') { - print $form->textwithpicto(dol_escape_htmltag($object->display_incoterms()), $object->label_incoterms, 1); - } else { - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); - } - print ''; - } - - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - print ''; - - print '
'; - print '
'; - print '
'; - - print ''; - - print ''; - // Amount HT - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - // Multicurrency Amount HT - print ''; - } + } + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print '
' . $langs->trans('AmountHT') . '' . price($object->total_ht, '', $langs, 0, -1, -1, $conf->currency) . '' . price($object->multicurrency_total_ht, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'; + + print '
'; + print '
'; + print '
'; + print '
'; + + print ''; + + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) + { + // Multicurrency Amount HT + print ''; + print ''; @@ -2395,8 +2222,3 @@ - print ''; - // Amount VAT - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - // Multicurrency Amount VAT - print ''; - } + // Multicurrency Amount VAT + print ''; + print ''; @@ -2405,34 +2227,3 @@ - // Amount Local Taxes - if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { - print ''; - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print ''; - } - print ''; - - if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { - print ''; - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - print ''; - } - print ''; - } - } - - $alert = ''; - if (getDolGlobalString('ORDER_MANAGE_MIN_AMOUNT') && $object->total_ht < $object->thirdparty->supplier_order_min_amount) { - $alert = ' ' . img_warning($langs->trans('OrderMinAmount') . ': ' . price($object->thirdparty->supplier_order_min_amount)); - } - - print ''; - // Amount TTC - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - // Multicurrency Amount TTC - print ''; - } + // Multicurrency Amount TTC + print ''; + print ''; @@ -2440,86 +2231,112 @@ - - print '
'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).''.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
' . $langs->trans('AmountVAT') . '' . price($object->total_tva, '', $langs, 0, -1, -1, $conf->currency) . '' . price($object->multicurrency_total_tva, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($object->total_localtax1, '', $langs, 0, -1, -1, $conf->currency) . '' . price($object->total_localtax1, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $conf->currency) . '' . price($object->total_localtax2, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, '', $langs, 0, -1, -1, $conf->currency) . $alert . '' . price($object->multicurrency_total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'
'; - - // Margin Infos - /*if (isModEnabled('margin')) { - $formmargin->displayMarginInfos($object); - }*/ - - - print '
'; - print '
'; - - print '

'; - - if (getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) { - $blocname = 'contacts'; - $title = $langs->trans('ContactsAddresses'); - include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; - } - - if (getDolGlobalString('MAIN_DISABLE_NOTES_TAB')) { - $blocname = 'notes'; - $title = $langs->trans('Notes'); - include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; - } - - /* - * Lines - */ - //$result = $object->getLinesArray(); - - - print '
- - - - - - - '; - - if (!empty($conf->use_javascript_ajax) && $object->statut == 0) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } - - print '
'; - print ''; - - // Add free products/services form - global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax; - $forceall = 1; - $dateSelector = 0; - $inputalsopricewithtax = 1; - $senderissupplier = 2; // $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum. - if (getDolGlobalString('SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY')) { - $senderissupplier = 1; - } - - // Show object lines - if (!empty($object->lines)) { - $object->printObjectLines($action, $object->thirdparty, $mysoc, $lineid, 1); - } - - $num = count($object->lines); - - // Form to add new line - if ($object->statut == CommandeFournisseur::STATUS_DRAFT && $usercancreate) { - if ($action != 'editline') { - // Add free products/services - - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - if (empty($reshook)) { - $object->formAddObjectLine(1, $societe, $mysoc); - } - } - } - print '
'; - print '
'; - print '
'; - } - - print dol_get_fiche_end(); + } + + // Total + $alert = ''; + if (!empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->supplier_order_min_amount) { + $alert = ' '.img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->supplier_order_min_amount)); + } + print ''.$langs->trans("AmountHT").''; + print ''.price($object->total_ht, '', $langs, 1, -1, -1, $conf->currency).$alert.''; + print ''; + + // Total VAT + print ''.$langs->trans("AmountVAT").''.price($object->total_tva, '', $langs, 1, -1, -1, $conf->currency).''; + print ''; + + // Amount Local Taxes + if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) //Localtax1 + { + print ''.$langs->transcountry("AmountLT1", $mysoc->country_code).''; + print ''.price($object->total_localtax1, '', $langs, 1, -1, -1, $conf->currency).''; + print ''; + } + if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) //Localtax2 + { + print ''.$langs->transcountry("AmountLT2", $mysoc->country_code).''; + print ''.price($object->total_localtax2, '', $langs, 1, -1, -1, $conf->currency).''; + print ''; + } + + // Total TTC + print ''.$langs->trans("AmountTTC").''.price($object->total_ttc, '', $langs, 1, -1, -1, $conf->currency).''; + print ''; + + print ''; + + // Margin Infos + /*if (! empty($conf->margin->enabled)) { + $formmargin->displayMarginInfos($object); + }*/ + + + print '
'; + print ''; + print ''; + + print '

'; + + if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; + } + + if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; + } + + /* + * Lines + */ + //$result = $object->getLinesArray(); + + + print '
+ + + + + + '; + + if (!empty($conf->use_javascript_ajax) && $object->statut == 0) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; + } + + print '
'; + print ''; + + // Add free products/services form + global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax; + $forceall = 1; $dateSelector = 0; $inputalsopricewithtax = 1; + $senderissupplier = 2; // $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum. + //if (! empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED)) $senderissupplier=2; + if (!empty($conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier = 1; + + // Show object lines + if (!empty($object->lines)) + $ret = $object->printObjectLines($action, $societe, $mysoc, $lineid, 1); + + $num = count($object->lines); + + // Form to add new line + if ($object->statut == CommandeFournisseur::STATUS_DRAFT && $user->rights->fournisseur->commande->creer) + { + if ($action != 'editline') + { + // Add free products/services + $object->formAddObjectLine(1, $societe, $mysoc); + + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + } + } + print '
'; + print '
'; + print '
'; + + dol_fiche_end(); @@ -2528 +2345 @@ - * Buttons for actions + * Boutons actions @@ -2531,16 +2348,70 @@ - if ($user->socid == 0 && $action != 'delete') { - if ($action != 'createorder' && $action != 'presend' && $action != 'editline') { - print '
'; - - $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been - // modified by hook - if (empty($reshook)) { - $object->fetchObjectLinked(); // Links are used to show or not button, so we load them now. - - // Validate - if ($object->statut == 0 && $num > 0) { - if ($usercanvalidate) { - $tmpbuttonlabel = $langs->trans('Validate'); - if ($usercanapprove && !getDolGlobalString('SUPPLIER_ORDER_NO_DIRECT_APPROVE')) { - $tmpbuttonlabel = $langs->trans("ValidateAndApprove"); + if ($user->socid == 0 && $action != 'editline' && $action != 'delete') + { + print '
'; + + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if (empty($reshook)) + { + $object->fetchObjectLinked(); // Links are used to show or not button, so we load them now. + + // Validate + if ($object->statut == 0 && $num > 0) + { + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->commande->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_order_advance->validate))) + { + $tmpbuttonlabel = $langs->trans('Validate'); + if ($user->rights->fournisseur->commande->approuver && empty($conf->global->SUPPLIER_ORDER_NO_DIRECT_APPROVE)) $tmpbuttonlabel = $langs->trans("ValidateAndApprove"); + + print ''; + print $tmpbuttonlabel; + print ''; + } + } + // Create event + /*if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. + { + print ''; + }*/ + + // Modify + if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) + { + if ($user->rights->fournisseur->commande->commander) + { + print ''.$langs->trans("Modify").''; + } + } + + // Approve + if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) + { + if ($user->rights->fournisseur->commande->approuver) + { + if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED && !empty($object->user_approve_id)) + { + print ''.$langs->trans("ApproveOrder").''; + } + else + { + print ''.$langs->trans("ApproveOrder").''; + } + } + else + { + print ''.$langs->trans("ApproveOrder").''; + } + } + + // Second approval (if option SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED is set) + if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) + { + if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) + { + if ($user->rights->fournisseur->commande->approve2) + { + if (!empty($object->user_approve_id2)) + { + print ''.$langs->trans("Approve2Order").''; @@ -2548,43 +2419,3 @@ - - print ''; - print $tmpbuttonlabel; - print ''; - } - } - // Create event - /*if (isModEnabled('agenda') && !empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a "workflow" action so should appears somewhere else on page. - { - print ''; - }*/ - - // Modify - if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { - if ($usercanorder) { - print ''.$langs->trans("Modify").''; - } - } - - // Approve - if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { - if ($usercanapprove) { - if (getDolGlobalString('SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED') && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED && !empty($object->user_approve_id)) { - print ''.$langs->trans("ApproveOrder").''; - } else { - print ''.$langs->trans("ApproveOrder").''; - } - } else { - print ''.$langs->trans("ApproveOrder").''; - } - } - - // Second approval (if option SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED is set) - if (getDolGlobalString('SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED') && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) { - if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { - if ($usercanapprovesecond) { - if (!empty($object->user_approve_id2)) { - print ''.$langs->trans("Approve2Order").''; - } else { - print ''.$langs->trans("Approve2Order").''; - } - } else { - print ''.$langs->trans("Approve2Order").''; + else + { + print ''.$langs->trans("Approve2Order").''; @@ -2593,6 +2424,71 @@ - } - - // Refuse - if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { - if ($usercanapprove || $usercanapprovesecond) { - print ''.$langs->trans("RefuseOrder").''; + else + { + print ''.$langs->trans("Approve2Order").''; + } + } + } + + // Refuse + if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) + { + if ($user->rights->fournisseur->commande->approuver || $user->rights->fournisseur->commande->approve2) + { + print ''.$langs->trans("RefuseOrder").''; + } + else + { + print ''.$langs->trans("RefuseOrder").''; + } + } + + // Send + if (empty($user->socid)) { + if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED, 3, 4, 5)) || !empty($conf->global->SUPPLIER_ORDER_SENDBYEMAIL_FOR_ALL_STATUS)) + { + if ($user->rights->fournisseur->commande->commander) + { + print ''.$langs->trans('SendMail').''; + } + } + } + + // Reopen + if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED))) + { + $buttonshown = 0; + if (!$buttonshown && $user->rights->fournisseur->commande->approuver) + { + if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) + || (!empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) && $user->id == $object->user_approve_id)) + { + print ''.$langs->trans("Disapprove").''; + $buttonshown++; + } + } + if (!$buttonshown && $user->rights->fournisseur->commande->approve2 && !empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) + { + if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) + || (!empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) && $user->id == $object->user_approve_id2)) + { + print ''.$langs->trans("Disapprove").''; + } + } + } + if (in_array($object->statut, array(3, 4, 5, 6, 7, 9))) + { + if ($user->rights->fournisseur->commande->commander) + { + print ''.$langs->trans("ReOpen").''; + } + } + + // Ship + + if (!empty($conf->stock->enabled) && (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) + { + $labelofbutton = $langs->trans('ReceiveProducts'); + if ($conf->reception->enabled) $labelofbutton = $langs->trans("CreateReception"); + + if (in_array($object->statut, array(3, 4, 5))) { + if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->receptionner) { + print ''; @@ -2600 +2496 @@ - print ''.$langs->trans("RefuseOrder").''; + print ''; @@ -2603,6 +2499,49 @@ - - // Send - if (empty($user->socid)) { - if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED, 3, 4, 5)) || getDolGlobalString('SUPPLIER_ORDER_SENDBYEMAIL_FOR_ALL_STATUS')) { - if ($usercanorder) { - print ''.$langs->trans('SendMail').''; + } + + if ($object->statut == CommandeFournisseur::STATUS_ACCEPTED) + { + if ($user->rights->fournisseur->commande->commander) + { + print ''; + } + else + { + print ''; + } + } + + // Classify received (this does not record reception) + if ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY) + { + if ($user->rights->fournisseur->commande->receptionner) + { + print ''; + } + } + + // Create bill + //if (! empty($conf->facture->enabled)) + //{ + if (!empty($conf->fournisseur->enabled) && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) // statut 2 means approved, 7 means canceled + { + if ($user->rights->fournisseur->facture->creer) + { + print ''.$langs->trans("CreateBill").''; + } + } + //} + + // Classify billed manually (need one invoice if module invoice is on, no condition on invoice if not) + if ($user->rights->fournisseur->commande->creer && $object->statut >= 2 && $object->statut != 7 && $object->billed != 1) // statut 2 means approved + { + if (empty($conf->facture->enabled)) + { + print ''.$langs->trans("ClassifyBilled").''; + } + else + { + if (!empty($object->linkedObjectsIds['invoice_supplier'])) + { + if ($user->rights->fournisseur->facture->creer) + { + print ''.$langs->trans("ClassifyBilled").''; @@ -2611,11 +2550,3 @@ - } - - // Reopen - if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED))) { - $buttonshown = 0; - if (!$buttonshown && $usercanapprove) { - if (!getDolGlobalString('SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY') - || (getDolGlobalString('SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY') && $user->id == $object->user_approve_id)) { - print ''.$langs->trans("Disapprove").''; - $buttonshown++; - } + else + { + print ''.$langs->trans("ClassifyBilled").''; @@ -2623,109 +2554,37 @@ - if (!$buttonshown && $usercanapprovesecond && getDolGlobalString('SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED')) { - if (!getDolGlobalString('SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY') - || (getDolGlobalString('SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY') && $user->id == $object->user_approve_id2)) { - print ''.$langs->trans("Disapprove").''; - } - } - } - if (in_array($object->statut, array(3, 4, 5, 6, 7, 9))) { - if ($usercanorder) { - print ''.$langs->trans("ReOpen").''; - } - } - - // Ship - $hasreception = 0; - if (isModEnabled('stock') && (getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') || getDolGlobalString('STOCK_CALCULATE_ON_RECEPTION') || getDolGlobalString('STOCK_CALCULATE_ON_RECEPTION_CLOSE'))) { - $labelofbutton = $langs->trans('ReceiveProducts'); - if (isModEnabled('reception')) { - $labelofbutton = $langs->trans("CreateReception"); - if (!empty($object->linkedObjects['reception'])) { - foreach ($object->linkedObjects['reception'] as $element) { - if ($element->statut >= 0) { - $hasreception = 1; - break; - } - } - } - } - - if (in_array($object->statut, array(3, 4, 5))) { - if (isModEnabled("supplier_order") && $usercanreceive) { - print ''; - } else { - print ''; - } - } - } - - if ($object->statut == CommandeFournisseur::STATUS_ACCEPTED) { - if ($usercanorder) { - print ''; - } else { - print ''; - } - } - - // Classify received (this does not record reception) - if ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY) { - if ($usercanreceive) { - print ''; - } - } - - // Create bill - //if (isModEnabled('facture')) - //{ - if (isModEnabled("supplier_invoice") && ($object->statut >= 2 && $object->statut != 7 && $object->billed != 1)) { // statut 2 means approved, 7 means canceled - if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight("supplier_invoice", "creer")) { - print ''.$langs->trans("SupplierOrderCreateBill").''; - } - } - //} - - // Classify billed manually (need one invoice if module invoice is on, no condition on invoice if not) - if ($usercancreate && $object->statut >= 2 && $object->statut != 7 && $object->billed != 1) { // statut 2 means approved - if (!isModEnabled('facture')) { - print ''.$langs->trans("ClassifyBilled").''; - } else { - if (!empty($object->linkedObjectsIds['invoice_supplier'])) { - if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight("supplier_invoice", "creer")) { - print ''.$langs->trans("ClassifyBilled").''; - } - } else { - print ''.$langs->trans("ClassifyBilled").''; - } - } - } - - // Create a remote order using WebService only if module is activated - if (!empty($conf->syncsupplierwebservices->enabled) && $object->statut >= 2) { // 2 means accepted - print ''.$langs->trans('CreateRemoteOrder').''; - } - - // Clone - if ($usercancreate) { - print ''.$langs->trans("ToClone").''; - } - - // Cancel - if ($object->statut == CommandeFournisseur::STATUS_ACCEPTED) { - if ($usercanorder) { - print ''.$langs->trans("CancelOrder").''; - } - } - - // Delete - if (!empty($usercandelete)) { - if ($hasreception) { - print ''.$langs->trans("Delete").''; - } else { - print ''.$langs->trans("Delete").''; - } - } - } - - print "
"; - } - - if ($usercanorder && $object->statut == CommandeFournisseur::STATUS_ACCEPTED && $action == 'createorder') { + } + } + + // Create a remote order using WebService only if module is activated + if (!empty($conf->syncsupplierwebservices->enabled) && $object->statut >= 2) // 2 means accepted + { + print ''.$langs->trans('CreateRemoteOrder').''; + } + + // Clone + if ($user->rights->fournisseur->commande->creer) + { + print ''.$langs->trans("ToClone").''; + } + + // Cancel + if ($object->statut == 2) + { + if ($user->rights->fournisseur->commande->commander) + { + print ''.$langs->trans("CancelOrder").''; + } + } + + // Delete + if (!empty($user->rights->fournisseur->commande->supprimer) || ($object->statut == CommandeFournisseur::STATUS_DRAFT && !empty($user->rights->fournisseur->commande->creer))) + { + print ''.$langs->trans("Delete").''; + } + } + + print "
"; + + + + if ($user->rights->fournisseur->commande->commander && $object->statut == CommandeFournisseur::STATUS_ACCEPTED && $action == 'makeorder') + { @@ -2743 +2602,2 @@ - print $form->selectDate($date_com ?: '', '', 0, 0, '', "commande", 1, 1); + if (empty($date_com)) $date_com = dol_now(); + print $form->selectDate($date_com, '', 1, 1, '', "commande", 1, 1); @@ -2746,2 +2606,2 @@ - // Force mandatory order method - print ''.$langs->trans("OrderMode").''; + // Force mandatory order method + print ''.$langs->trans("OrderMode").''; @@ -2751,2 +2611 @@ - print ''.$langs->trans("Comment").''; - + print ''.$langs->trans("Comment").''; @@ -2756 +2615 @@ - print ''; + print ''; @@ -2764,6 +2623,2 @@ - // Select mail models is same action as presend - if (GETPOST('modelselected')) { - $action = 'presend'; - } - - if ($action != 'createorder' && $action != 'presend') { + if ($action != 'makeorder') + { @@ -2778,5 +2633,4 @@ - $genallowed = $usercanread; - $delallowed = $usercancreate; - $modelpdf = (!empty($object->model_pdf) ? $object->model_pdf : (!getDolGlobalString('COMMANDE_SUPPLIER_ADDON_PDF') ? '' : $conf->global->COMMANDE_SUPPLIER_ADDON_PDF)); - - print $formfile->showdocuments('commande_fournisseur', $objref, $filedir, $urlsource, $genallowed, $delallowed, $modelpdf, 1, 0, 0, 0, 0, '', '', '', $object->thirdparty->default_lang, '', $object); + $genallowed = $user->rights->fournisseur->commande->lire; + $delallowed = $user->rights->fournisseur->commande->creer; + + print $formfile->showdocuments('commande_fournisseur', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 0, 0, '', '', '', $object->thirdparty->default_lang); @@ -2789,4 +2643,6 @@ - print '
'; - - if ($action == 'classifyreception') { - if ($usercanreceive && ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY)) { + print '
'; + + if ($action == 'classifyreception') + { + if ($user->rights->fournisseur->commande->receptionner && ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY)) + { @@ -2818,6 +2674,2 @@ - print ''.$langs->trans("Comment").''; - print ''; - print ''; - print '     '; - print ''; - print ''; + print ''.$langs->trans("Comment").''; + print ''; @@ -2835 +2687 @@ - print '
'; + print ''; @@ -2841 +2693,2 @@ - if ($action == 'webservice' && GETPOST('mode', 'alpha') != "send" && !GETPOST('cancel', 'alpha')) { + if ($action == 'webservice' && GETPOST('mode', 'alpha') != "send" && !GETPOST('cancel', 'alpha')) + { @@ -2870 +2723,2 @@ - if ($mode == "init") { + if ($mode == "init") + { @@ -2878 +2732,2 @@ - if ($error_occurred) { + if ($error_occurred) + { @@ -2880,2 +2735,5 @@ - print ''; - } else { + print ''; + } + else + { + $textinput_size = "50"; @@ -2885 +2743 @@ - print ''.$langs->trans("User").''; + print ''.$langs->trans("User").''; @@ -2887 +2745 @@ - print ''.$langs->trans("Password").''; + print ''.$langs->trans("Password").''; @@ -2890 +2748 @@ - print ''; + print ''; @@ -2893 +2751 @@ - print ''; + print ''; @@ -2900 +2758,3 @@ - } elseif ($mode == "check") { + } + elseif ($mode == "check") + { @@ -2915 +2775,2 @@ - if ($user_status_code == "OK") { + if ($user_status_code == "OK") + { @@ -2920 +2781,2 @@ - if (empty($ws_thirdparty)) { + if (empty($ws_thirdparty)) + { @@ -2923 +2785,3 @@ - } else { + } + else + { @@ -2940 +2804,2 @@ - if (!$result_product) { + if (!$result_product) + { @@ -2948 +2813,2 @@ - if (empty($status_code)) { //No result, check error str + if (empty($status_code)) //No result, check error str + { @@ -2950,2 +2816,5 @@ - } elseif ($status_code != "OK") { //Something went wrong - if ($status_code == "NOT_FOUND") { + } + elseif ($status_code != "OK") //Something went wrong + { + if ($status_code == "NOT_FOUND") + { @@ -2953 +2822,3 @@ - } else { + } + else + { @@ -2967,2 +2838,4 @@ - if (count($product_fourn_list) > 0) { - foreach ($product_fourn_list as $product_fourn_line) { + if (count($product_fourn_list) > 0) + { + foreach ($product_fourn_list as $product_fourn_line) + { @@ -2986 +2859,3 @@ - } elseif ($user_status_code == "PERMISSION_DENIED") { + } + elseif ($user_status_code == "PERMISSION_DENIED") + { @@ -2989 +2864,3 @@ - } elseif ($user_status_code == "BAD_CREDENTIALS") { + } + elseif ($user_status_code == "BAD_CREDENTIALS") + { @@ -2992 +2869,3 @@ - } else { + } + else + { @@ -3006 +2885,2 @@ - if ($error_occurred) { + if ($error_occurred) + { @@ -3008,2 +2888,4 @@ - } else { - print ''; + } + else + { + print ''; @@ -3012 +2894 @@ - print ''; + print ''; @@ -3014,0 +2897,5 @@ + } + + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; @@ -3022 +2909 @@ - $trackid = 'sord'.$object->id; + $trackid = 'sor'.$object->id; --- /tmp/dsg/dolibarr/htdocs/fourn/commande/github_19.0.3_contact.php +++ /tmp/dsg/dolibarr/htdocs/fourn/commande/client_contact.php @@ -6 +5,0 @@ - * Copyright (C) 2023 Christian Foellmann @@ -28 +26,0 @@ -// Load Dolibarr environment @@ -34 +32 @@ -if (isModEnabled('project')) { +if (!empty($conf->projet->enabled)) { @@ -43 +41 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -46,3 +44 @@ -if ($user->socid) { - $socid = $user->socid; -} +if ($user->socid) $socid = $user->socid; @@ -50 +45,0 @@ -$hookmanager->initHooks(array('ordersuppliercardcontact', 'ordersuppliercontactcard', 'globalcard')); @@ -54,12 +48,0 @@ -$usercancreate = ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer")); -$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php - -/* - * Actions - */ - -$parameters = array('id'=>$id); -$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} @@ -71,8 +54,21 @@ -if (empty($reshook)) { - if ($action == 'addcontact' && ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer"))) { - $result = $object->fetch($id); - - if ($result > 0 && $id > 0) { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); +if ($action == 'addcontact' && $user->rights->fournisseur->commande->creer) +{ + $result = $object->fetch($id); + + if ($result > 0 && $id > 0) + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); @@ -80,17 +76,2 @@ - - if ($result >= 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } elseif ($action == 'swapstatut' && ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer"))) { - // Toggle the status of a contact - if ($object->fetch($id)) { - $result = $object->swapContactStatus(GETPOST('ligne', 'int')); - } else { + else + { @@ -99,13 +80,32 @@ - } elseif ($action == 'deletecontact' && ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer"))) { - // Deleting a contact - $object->fetch($id); - $result = $object->delete_contact(GETPOST("lineid", 'int')); - - if ($result >= 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } -} + } +} + +// Toggle the status of a contact +elseif ($action == 'swapstatut' && $user->rights->fournisseur->commande->creer) +{ + if ($object->fetch($id)) + { + $result = $object->swapContactStatus(GETPOST('ligne')); + } + else + { + dol_print_error($db); + } +} + +// Deleting a contact +elseif ($action == 'deletecontact' && $user->rights->fournisseur->commande->creer) +{ + $object->fetch($id); + $result = $object->delete_contact($_GET["lineid"]); + + if ($result >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { + dol_print_error($db); + } +} + @@ -116,0 +117,2 @@ +$help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; +llxHeader('', $langs->trans("Order"), $help_url); @@ -130 +132,2 @@ -if ($id > 0 || !empty($ref)) { +if ($id > 0 || !empty($ref)) +{ @@ -133 +136,2 @@ - if ($object->fetch($id, $ref) > 0) { + if ($object->fetch($id, $ref) > 0) + { @@ -136,4 +139,0 @@ - $title = $object->ref." - ".$langs->trans('ContactsAddresses'); - $help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; - llxHeader('', $title, $help_url); - @@ -141 +141 @@ - print dol_get_fiche_head($head, 'contact', $langs->trans("SupplierOrder"), -1, 'order'); + dol_fiche_head($head, 'contact', $langs->trans("SupplierOrder"), -1, 'order'); @@ -152 +152 @@ - $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); @@ -154,19 +154,32 @@ - if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref .= '
'; - if (0) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify' && $caneditproject) { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (!getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } - } - } + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->fournisseur->commande->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } @@ -179 +192 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -183 +196,3 @@ - } else { + } + else + { --- /tmp/dsg/dolibarr/htdocs/fourn/commande/github_19.0.3_dispatch.php +++ /tmp/dsg/dolibarr/htdocs/fourn/commande/client_dispatch.php @@ -3 +3 @@ - * Copyright (C) 2004-2023 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur @@ -6 +6 @@ - * Copyright (C) 2010-2021 Juanjo Menent + * Copyright (C) 2010-2019 Juanjo Menent @@ -9,3 +9,3 @@ - * Copyright (C) 2017-2022 Ferran Marcet - * Copyright (C) 2018-2022 Frédéric France - * Copyright (C) 2019-2020 Christophe Battarel + * Copyright (C) 2017 Ferran Marcet + * Copyright (C) 2018 Frédéric France + * Copyright (C) 2019 Christophe Battarel @@ -13,3 +13,3 @@ - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or @@ -18 +18 @@ - * This program is distributed in the hope that it will be useful, + * This program is distributed in the hope that it will be useful, @@ -20 +20 @@ - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -24,0 +25 @@ + * or see https://www.gnu.org/ @@ -33 +33,0 @@ -// Load Dolibarr environment @@ -41,4 +41 @@ -require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; - -if (isModEnabled('project')) { +if (!empty($conf->projet->enabled)) @@ -46 +42,0 @@ -} @@ -51 +47 @@ -if (isModEnabled('productbatch')) { +if (!empty($conf->productbatch->enabled)) @@ -53,3 +49,2 @@ -} - -// Security check + + // Security check @@ -61,4 +56,2 @@ -$cancel = GETPOST('cancel', 'alpha'); -$confirm = GETPOST('confirm', 'alpha'); - -if ($user->socid) { + +if ($user->socid) @@ -65,0 +59,4 @@ +$result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); + +if (empty($conf->stock->enabled)) { + accessforbidden(); @@ -72 +69 @@ -if (GETPOSTISSET("projectid")) { +if ($_GET["projectid"]) @@ -74 +70,0 @@ -} @@ -89,18 +84,0 @@ -if (empty($conf->reception->enabled)) { - $permissiontoreceive = $user->hasRight("fournisseur", "commande", "receptionner"); - $permissiontocontrol = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight("fournisseur", "commande", "receptionner")) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight("fournisseur", "commande_advance", "check"))); -} else { - $permissiontoreceive = $user->hasRight("reception", "creer"); - $permissiontocontrol = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight("reception", "creer")) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight("reception", "reception_advance", "validate"))); -} - -// $id is id of a purchase order. -$result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande'); - -if (!isModEnabled('stock')) { - accessforbidden(); -} - -$usercancreate = ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer")); -$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php - @@ -114,5 +92,4 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if ($action == 'checkdispatchline' && $permissiontocontrol) { +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if ($action == 'checkdispatchline' && !((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))) +{ @@ -125 +102,2 @@ - if (!$result) { + if (!$result) + { @@ -131 +109,2 @@ - if (!$error) { + if (!$error) + { @@ -140 +119,2 @@ - if (!$error) { + if (!$error) + { @@ -148 +128,2 @@ - if (!$error) { + if (!$error) + { @@ -150 +131,3 @@ - } else { + } + else + { @@ -155 +138,2 @@ -if ($action == 'uncheckdispatchline' && $permissiontocontrol) { +if ($action == 'uncheckdispatchline' && !((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))) +{ @@ -162 +146,2 @@ - if (!$result) { + if (!$result) + { @@ -168 +153,2 @@ - if (!$error) { + if (!$error) + { @@ -176 +162,2 @@ - if (!$error) { + if (!$error) + { @@ -184 +171,2 @@ - if (!$error) { + if (!$error) + { @@ -186 +174,3 @@ - } else { + } + else + { @@ -191 +181,2 @@ -if ($action == 'denydispatchline' && $permissiontocontrol) { +if ($action == 'denydispatchline' && !((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))) +{ @@ -198 +189,2 @@ - if (!$result) { + if (!$result) + { @@ -204 +196,2 @@ - if (!$error) { + if (!$error) + { @@ -212 +205,2 @@ - if (!$error) { + if (!$error) + { @@ -220 +214,2 @@ - if (!$error) { + if (!$error) + { @@ -222 +217,3 @@ - } else { + } + else + { @@ -227 +224 @@ -if ($action == 'dispatch' && $permissiontoreceive) { +if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) { @@ -229 +225,0 @@ - $notrigger = 0; @@ -234 +230,2 @@ - foreach ($_POST as $key => $value) { + foreach ($_POST as $key => $value) + { @@ -236,2 +233,2 @@ - $reg = array(); - if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) { + if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) + { @@ -245,3 +242 @@ - if (empty(GETPOST($ent))) { - $ent = $fk_default_warehouse; - } + if (empty(GETPOST($ent))) $ent = $fk_default_warehouse; @@ -251,3 +246,3 @@ - if (getDolGlobalString('SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) { - if (!isModEnabled("multicurrency") && empty($conf->dynamicprices->enabled)) { - $dto = GETPOST("dto_".$reg[1].'_'.$reg[2], 'int'); + if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) { + if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { + $dto = GETPOST("dto_".$reg[1].'_'.$reg[2]); @@ -262,3 +257 @@ - $qtytomove = (float) price2num(GETPOST($qty, 'alphanohtml')); - $puformove = (float) price2num(GETPOST($pu, 'alphanohtml')); - if ($qtytomove != 0) { + if (GETPOST($qty) != 0) { @@ -273 +266 @@ - $result = $object->dispatchProduct($user, GETPOSTINT($prod), $qtytomove, GETPOSTINT($ent), $puformove, GETPOST('comment'), '', '', '', GETPOST($fk_commandefourndet, 'int'), $notrigger); + $result = $object->dispatchProduct($user, GETPOST($prod, 'int'), GETPOST($qty), GETPOST($ent, 'int'), GETPOST($pu), GETPOST('comment'), '', '', '', GETPOST($fk_commandefourndet, 'int'), $notrigger); @@ -279,7 +272,3 @@ - if (!$error && getDolGlobalString('SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) { - if (!isModEnabled("multicurrency") && empty($conf->dynamicprices->enabled)) { - $dto = price2num(GETPOST("dto_".$reg[1].'_'.$reg[2], 'int'), ''); - if (empty($dto)) { - $dto = 0; - } - + if (!$error && !empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) { + if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { + $dto = GETPOST("dto_".$reg[1].'_'.$reg[2]); @@ -290,5 +279,5 @@ - $sql .= " SET unitprice='".price2num(GETPOST($pu), 'MU')."'"; - $sql .= ", price=".price2num(GETPOST($pu), 'MU')."*quantity"; - $sql .= ", remise_percent = ".((float) $dto); - $sql .= " WHERE fk_soc=".((int) $object->socid); - $sql .= " AND fk_product=".((int) GETPOST($prod, 'int')); + $sql .= " SET unitprice='".GETPOST($pu)."'"; + $sql .= ", price=".GETPOST($pu)."*quantity"; + $sql .= ", remise_percent='".$dto."'"; + $sql .= " WHERE fk_soc=".$object->socid; + $sql .= " AND fk_product=".GETPOST($prod, 'int'); @@ -304 +293,2 @@ - if (preg_match('/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) { + if (preg_match('/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) + { @@ -316,2 +306,2 @@ - $dDLUO = dol_mktime(12, 0, 0, GETPOST('dluo_'.$reg[1].'_'.$reg[2].'month', 'int'), GETPOST('dluo_'.$reg[1].'_'.$reg[2].'day', 'int'), GETPOST('dluo_'.$reg[1].'_'.$reg[2].'year', 'int')); - $dDLC = dol_mktime(12, 0, 0, GETPOST('dlc_'.$reg[1].'_'.$reg[2].'month', 'int'), GETPOST('dlc_'.$reg[1].'_'.$reg[2].'day', 'int'), GETPOST('dlc_'.$reg[1].'_'.$reg[2].'year', 'int')); + $dDLUO = dol_mktime(12, 0, 0, $_POST['dluo_'.$reg[1].'_'.$reg[2].'month'], $_POST['dluo_'.$reg[1].'_'.$reg[2].'day'], $_POST['dluo_'.$reg[1].'_'.$reg[2].'year']); + $dDLC = dol_mktime(12, 0, 0, $_POST['dlc_'.$reg[1].'_'.$reg[2].'month'], $_POST['dlc_'.$reg[1].'_'.$reg[2].'day'], $_POST['dlc_'.$reg[1].'_'.$reg[2].'year']); @@ -321,10 +310,0 @@ - if (getDolGlobalString('SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) { - if (!isModEnabled("multicurrency") && empty($conf->dynamicprices->enabled)) { - $dto = GETPOST("dto_".$reg[1].'_'.$reg[2], 'int'); - if (!empty($dto)) { - $unit_price = price2num(GETPOST("pu_".$reg[1]) * (100 - $dto) / 100, 'MU'); - } - $saveprice = "saveprice_".$reg[1].'_'.$reg[2]; - } - } - @@ -332,5 +312 @@ - $qtytomove = (float) price2num(GETPOST($qty, 'alphanohtml')); - $puformove = (float) price2num(GETPOST($pu, 'alphanohtml')); - if ($qtytomove > 0) { - $productId = GETPOSTINT($prod); - + if (GETPOST($qty) > 0) { @@ -352 +328 @@ - $result = $object->dispatchProduct($user, $productId, $qtytomove, GETPOSTINT($ent), $puformove, GETPOST('comment'), $dDLUO, $dDLC, GETPOST($lot, 'alpha'), GETPOST($fk_commandefourndet, 'int'), $notrigger); + $result = $object->dispatchProduct($user, GETPOST($prod, 'int'), GETPOST($qty), GETPOST($ent, 'int'), GETPOST($pu), GETPOST('comment'), $dDLC, $dDLUO, GETPOST($lot, 'alpha'), GETPOST($fk_commandefourndet, 'int'), $notrigger); @@ -356,18 +331,0 @@ - } - - if (!$error && getDolGlobalString('SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) { - if (!isModEnabled("multicurrency") && empty($conf->dynamicprices->enabled)) { - $dto = GETPOST("dto_".$reg[1].'_'.$reg[2], 'int'); - //update supplier price - if (GETPOSTISSET($saveprice)) { - // TODO Use class - $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql .= " SET unitprice = ".price2num(GETPOST($pu), 'MU', 2); - $sql .= ", price = ".price2num(GETPOST($pu), 'MU', 2)." * quantity"; - $sql .= ", remise_percent = ".price2num((empty($dto) ? 0 : $dto), 3, 2)."'"; - $sql .= " WHERE fk_soc = ".((int) $object->socid); - $sql .= " AND fk_product=".((int) $productId); - - $resql = $db->query($sql); - } - } @@ -387,0 +346,13 @@ + if (!$notrigger && !$error) { + global $conf, $langs, $user; + // Call trigger + + $result = $object->call_trigger('ORDER_SUPPLIER_DISPATCH', $user); + // End call triggers + + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + } + @@ -390,2 +360,0 @@ - - setEventMessages($langs->trans("ReceptionsRecorded"), null, 'mesgs'); @@ -400,98 +368,0 @@ -// Remove a dispatched line -if ($action == 'confirm_deleteline' && $confirm == 'yes' && $permissiontoreceive) { - $db->begin(); - - $supplierorderdispatch = new CommandeFournisseurDispatch($db); - $result = $supplierorderdispatch->fetch($lineid); - if ($result > 0) { - $qty = $supplierorderdispatch->qty; - $entrepot = $supplierorderdispatch->fk_entrepot; - $product = $supplierorderdispatch->fk_product; - $price = price2num(GETPOST('price', 'alpha'), 'MU'); - $comment = $supplierorderdispatch->comment; - $eatby = $supplierorderdispatch->eatby; - $sellby = $supplierorderdispatch->sellby; - $batch = $supplierorderdispatch->batch; - - $result = $supplierorderdispatch->delete($user); - } - if ($result < 0) { - $errors = $object->errors; - $error++; - } else { - // If module stock is enabled and the stock increase is done on purchase order dispatching - if ($entrepot > 0 && isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER') && empty($supplierorderdispatch->fk_reception)) { - $mouv = new MouvementStock($db); - if ($product > 0) { - $mouv->origin = &$object; - $mouv->setOrigin($object->element, $object->id); - $result = $mouv->livraison($user, $product, $entrepot, $qty, $price, $comment, '', $eatby, $sellby, $batch); - if ($result < 0) { - $errors = $mouv->errors; - $error++; - } - } - } - } - if ($error > 0) { - $db->rollback(); - setEventMessages($error, $errors, 'errors'); - } else { - $db->commit(); - } -} - -// Update a dispatched line -if ($action == 'updateline' && $permissiontoreceive) { - $db->begin(); - $error = 0; - - $supplierorderdispatch = new CommandeFournisseurDispatch($db); - $result = $supplierorderdispatch->fetch($lineid); - if ($result > 0) { - $qty = $supplierorderdispatch->qty; - $entrepot = $supplierorderdispatch->fk_entrepot; - $product = $supplierorderdispatch->fk_product; - $price = price2num(GETPOST('price'), '', 2); - $comment = $supplierorderdispatch->comment; - $eatby = $supplierorderdispatch->eatby; - $sellby = $supplierorderdispatch->sellby; - $batch = $supplierorderdispatch->batch; - - $supplierorderdispatch->qty = price2num(GETPOST('qty', 'alpha'), 'MS', 2); - $supplierorderdispatch->fk_entrepot = GETPOST('fk_entrepot'); - $result = $supplierorderdispatch->update($user); - } - if ($result < 0) { - $error++; - $errors = $supplierorderdispatch->errors; - } else { - // If module stock is enabled and the stock increase is done on purchase order dispatching - if ($entrepot > 0 && isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER')) { - $mouv = new MouvementStock($db); - if ($product > 0) { - $mouv->origin = &$object; - $mouv->setOrigin($object->element, $object->id); - $result = $mouv->livraison($user, $product, $entrepot, $qty, $price, $comment, '', $eatby, $sellby, $batch); - if ($result < 0) { - $errors = $mouv->errors; - $error++; - } else { - $mouv->origin = &$object; - $result = $mouv->reception($user, $product, $supplierorderdispatch->fk_entrepot, $supplierorderdispatch->qty, $price, $comment, $eatby, $sellby, $batch); - if ($result < 0) { - $errors = $mouv->errors; - $error++; - } - } - } - } - } - if ($error > 0) { - $db->rollback(); - setEventMessages($error, $errors, 'errors'); - } else { - $db->commit(); - } -} - @@ -510 +380,0 @@ -$title = $object->ref." - ".$langs->trans('OrderDispatch'); @@ -512,3 +382 @@ -$morejs = array('/fourn/js/lib_dispatch.js.php'); - -llxHeader('', $title, $help_url, '', 0, 0, $morejs); +llxHeader('', $langs->trans("Order"), $help_url, '', 0, 0, array('/fourn/js/lib_dispatch.js.php')); @@ -526,21 +394,2 @@ - print dol_get_fiche_head($head, 'dispatch', $title, -1, 'order'); - - $formconfirm = ''; - - // Confirmation to delete line - if ($action == 'ask_deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); - } - - // Call Hook formConfirm - $parameters = array('lineid' => $lineid); - // Note that $action and $object may be modified by hook - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } - - // Print form confirm - print $formconfirm; + dol_fiche_head($head, 'dispatch', $title, -1, 'order'); + @@ -557 +406 @@ - $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); @@ -559,19 +408,32 @@ - if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref .= '
'; - if (0) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify' && $caneditproject) { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (!getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } - } - } + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->fournisseur->commande->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } @@ -608,2 +470,2 @@ - $parameters = array(); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -618,2 +480,2 @@ - /*$disabled = 1; - if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { + $disabled = 1; + if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) @@ -621,2 +482,0 @@ - }*/ - $disabled = 0; // This is used to disable or not the bulk selection of target warehouse. No reason to have it disabled so forced to 0. @@ -629,4 +488,0 @@ - - print '
'; - - @@ -635 +491,2 @@ - || $object->statut == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) { + || $object->statut == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) + { @@ -639,9 +496,3 @@ - $entrepot = new Entrepot($db); - $listwarehouses = $entrepot->list_array(1); - - - if (empty($conf->reception->enabled)) { - print '
'; - } else { - print ''; - } + + if (empty($conf->reception->enabled))print ''; + else print ''; @@ -650,5 +501,2 @@ - if (empty($conf->reception->enabled)) { - print ''; - } else { - print ''; - } + if (empty($conf->reception->enabled))print ''; + else print ''; @@ -664 +512 @@ - $sql .= " WHERE cfd.fk_commande = ".((int) $object->id); + $sql .= " WHERE cfd.fk_commande = ".$object->id; @@ -675 +523 @@ - $products_dispatched[$objd->rowid] = price2num($objd->qty, 'MS'); + $products_dispatched[$objd->rowid] = price2num($objd->qty, 5); @@ -682,2 +530 @@ - //$sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, SUM(l.qty) as qty,"; - $sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, l.qty as qty,"; + $sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, SUM(l.qty) as qty,"; @@ -686,12 +533,10 @@ - // Enable hooks to alter the SQL query (SELECT) - $parameters = array(); - $reshook = $hookmanager->executeHooks( - 'printFieldListSelect', - $parameters, - $object, - $action - ); - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - $sql .= $hookmanager->resPrint; + // Enable hooks to alter the SQL query (SELECT) + $parameters = array(); + $reshook = $hookmanager->executeHooks( + 'printFieldListSelect', + $parameters, + $object, + $action + ); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + $sql .= $hookmanager->resPrint; @@ -701,2 +546,2 @@ - $sql .= " WHERE l.fk_commande = ".((int) $object->id); - if (!getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { + $sql .= " WHERE l.fk_commande = ".$object->id; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) @@ -704,17 +549,14 @@ - } - - // Enable hooks to alter the SQL query (WHERE) - $parameters = array(); - $reshook = $hookmanager->executeHooks( - 'printFieldListWhere', - $parameters, - $object, - $action - ); - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - $sql .= $hookmanager->resPrint; - - //$sql .= " GROUP BY p.ref, p.label, p.tobatch, p.fk_default_warehouse, l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product - $sql .= " ORDER BY l.rang, p.ref, p.label"; + + // Enable hooks to alter the SQL query (WHERE) + $parameters = array(); + $reshook = $hookmanager->executeHooks( + 'printFieldListWhere', + $parameters, + $object, + $action + ); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + $sql .= $hookmanager->resPrint; + + $sql .= " GROUP BY p.ref, p.label, p.tobatch, l.rowid, l.fk_product, l.subprice, l.remise_percent, p.fk_default_warehouse"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product + $sql .= " ORDER BY p.ref, p.label"; @@ -727,0 +570,3 @@ + $entrepot = new Entrepot($db); + $listwarehouses = $entrepot->list_array(1); + @@ -731 +576,2 @@ - if (isModEnabled('productbatch')) { + if (!empty($conf->productbatch->enabled)) + { @@ -733,7 +579,5 @@ - if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { - print ''.$langs->trans("SellByDate").''; - } - if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { - print ''.$langs->trans("EatByDate").''; - } - } else { + print ''.$langs->trans("EatByDate").''; + print ''.$langs->trans("SellByDate").''; + } + else + { @@ -747,2 +591 @@ - print ' '.$langs->trans("QtyToDispatchShort"); - print '
'.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').$langs->trans("Reset").''; + print ''.$langs->trans("QtyToDispatchShort").''; @@ -751,2 +594,2 @@ - if (getDolGlobalString('SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) { - if (!isModEnabled("multicurrency") && empty($conf->dynamicprices->enabled)) { + if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) { + if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { @@ -762,4 +605,7 @@ - if (count($listwarehouses) > 1) { - print '
'.$form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, $langs->trans("ForceTo"), 0, 0, '', 0, 0, $disabled, '', 'minwidth100 maxwidth300', 1); - } elseif (count($listwarehouses) == 1) { - print '
'.$form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0, '', 0, 0, $disabled, '', 'minwidth100 maxwidth300', 1); + if (count($listwarehouses) > 1) + { + print '
'.$langs->trans("ForceTo").' '.$form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 1, 0, 0, '', 0, 0, $disabled); + } + elseif (count($listwarehouses) == 1) + { + print '
'.$langs->trans("ForceTo").' '.$form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0, '', 0, 0, $disabled); @@ -770,12 +616,10 @@ - // Enable hooks to append additional columns - $parameters = array(); - $reshook = $hookmanager->executeHooks( - 'printFieldListTitle', - $parameters, - $object, - $action - ); - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - print $hookmanager->resPrint; + // Enable hooks to append additional columns + $parameters = array(); + $reshook = $hookmanager->executeHooks( + 'printFieldListTitle', + $parameters, + $object, + $action + ); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print $hookmanager->resPrint; @@ -790,3 +633,0 @@ - $conf->cache['product'] = array(); - - // Loop on each source order line (may be more or less than current number of lines in llx_commande_fournisseurdet) @@ -800,3 +641,2 @@ - $alreadydispatched = isset($products_dispatched[$objp->rowid]) ? $products_dispatched[$objp->rowid] : 0; - $remaintodispatch = price2num($objp->qty - ((float) $alreadydispatched), 5); // Calculation of dispatched - if ($remaintodispatch < 0 && !getDolGlobalString('SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN')) { + $remaintodispatch = price2num($objp->qty - ((float) $products_dispatched[$objp->rowid]), 5); // Calculation of dispatched + if ($remaintodispatch < 0) @@ -804,3 +644,2 @@ - } - - if ($remaintodispatch || !getDolGlobalString('SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED')) { + + if ($remaintodispatch || empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) { @@ -818 +657 @@ - print ''; + print ''; @@ -821,9 +660 @@ - if (empty($conf->cache['product'][$objp->fk_product])) { - $tmpproduct = new Product($db); - $tmpproduct->fetch($objp->fk_product); - $conf->cache['product'][$objp->fk_product] = $tmpproduct; - } else { - $tmpproduct = $conf->cache['product'][$objp->fk_product]; - } - - $linktoprod = $tmpproduct->getNomUrl(1); + $linktoprod = ''.img_object($langs->trans("ShowProduct"), 'product').' '.$objp->ref.''; @@ -832 +663 @@ - if (isModEnabled('productbatch')) { + if (!empty($conf->productbatch->enabled)) { @@ -834 +664,0 @@ - // Product @@ -839,6 +669,2 @@ - if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { - print ''; - } - if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { - print ''; - } + print ''; + print ''; @@ -846 +671,0 @@ - // Product @@ -851 +676 @@ - print ''.$langs->trans("ProductDoesNotUseBatchSerial").''; + print $langs->trans("ProductDoesNotUseBatchSerial"); @@ -853,6 +678,2 @@ - if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { - print ''; - } - if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { - print ''; - } + print ''; + print ''; @@ -868 +689 @@ - if (!empty($objp->remise_percent) && !getDolGlobalString('STOCK_EXCLUDE_DISCOUNT_FOR_PMP')) { + if (!empty($objp->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) @@ -870 +690,0 @@ - } @@ -879,3 +699,3 @@ - print ''.$alreadydispatched.''; - - if (isModEnabled('productbatch') && $objp->tobatch > 0) { + print ''.$products_dispatched[$objp->rowid].''; + + if (!empty($conf->productbatch->enabled) && $objp->tobatch == 1) { @@ -886 +706 @@ - //print img_picto($langs->trans('AddDispatchBatchLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"'); + //print img_picto($langs->trans('AddDispatchBatchLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"'); @@ -890,18 +710,15 @@ - // Enable hooks to append additional columns - $parameters = array( - // allows hook to distinguish between the rows with information and the rows with dispatch form input - 'is_information_row' => true, - 'i' => $i, - 'suffix' => $suffix, - 'objp' => $objp, - ); - $reshook = $hookmanager->executeHooks( - 'printFieldListValue', - $parameters, - $object, - $action - ); - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - print $hookmanager->resPrint; + // Enable hooks to append additional columns + $parameters = array( + 'is_information_row' => true, // allows hook to distinguish between the + // rows with information and the rows with + // dispatch form input + 'objp' => $objp + ); + $reshook = $hookmanager->executeHooks( + 'printFieldListValue', + $parameters, + $object, + $action + ); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print $hookmanager->resPrint; @@ -917,4 +734,7 @@ - if (getDolGlobalString('SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT')) { // Not tested ! - print $langs->trans("BuyingPrice").': '; - } else { - print ''; + if (!empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) // Not tested ! + { + print $langs->trans("BuyingPrice").': '; + } + else + { + print ''; @@ -928,13 +748,9 @@ - if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { - print ''; - $dlcdatesuffix = dol_mktime(0, 0, 0, GETPOST('dlc'.$suffix.'month'), GETPOST('dlc'.$suffix.'day'), GETPOST('dlc'.$suffix.'year')); - print $form->selectDate($dlcdatesuffix, 'dlc'.$suffix, '', '', 1, ''); - print ''; - } - if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { - print ''; - $dluodatesuffix = dol_mktime(0, 0, 0, GETPOST('dluo'.$suffix.'month'), GETPOST('dluo'.$suffix.'day'), GETPOST('dluo'.$suffix.'year')); - print $form->selectDate($dluodatesuffix, 'dluo'.$suffix, '', '', 1, ''); - print ''; - } - print ' '; // Supplier ref + Qty ordered + qty already dispatched + print ''; + $dlcdatesuffix = dol_mktime(0, 0, 0, GETPOST('dlc'.$suffix.'month'), GETPOST('dlc'.$suffix.'day'), GETPOST('dlc'.$suffix.'year')); + print $form->selectDate($dlcdatesuffix, 'dlc'.$suffix, '', '', 1, ''); + print ''; + print ''; + $dluodatesuffix = dol_mktime(0, 0, 0, GETPOST('dluo'.$suffix.'month'), GETPOST('dluo'.$suffix.'day'), GETPOST('dluo'.$suffix.'year')); + print $form->selectDate($dluodatesuffix, 'dluo'.$suffix, '', '', 1, ''); + print ''; + print ' '; // Supplier ref + Qty ordered + qty already dispatched @@ -943,3 +758,0 @@ - $colspan = 7; - $colspan = (getDolGlobalString('PRODUCT_DISABLE_SELLBY')) ? --$colspan : $colspan; - $colspan = (getDolGlobalString('PRODUCT_DISABLE_EATBY')) ? --$colspan : $colspan; @@ -949 +762 @@ - //print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"'); + //print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"'); @@ -953,18 +766,15 @@ - // Enable hooks to append additional columns - $parameters = array( - // allows hook to distinguish between the rows with information and the rows with dispatch form input - 'is_information_row' => true, - 'i' => $i, - 'suffix' => $suffix, - 'objp' => $objp, - ); - $reshook = $hookmanager->executeHooks( - 'printFieldListValue', - $parameters, - $object, - $action - ); - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - print $hookmanager->resPrint; + // Enable hooks to append additional columns + $parameters = array( + 'is_information_row' => true, // allows hook to distinguish between the + // rows with information and the rows with + // dispatch form input + 'objp' => $objp + ); + $reshook = $hookmanager->executeHooks( + 'printFieldListValue', + $parameters, + $object, + $action + ); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print $hookmanager->resPrint; @@ -975 +785 @@ - print ''; + print ''; @@ -980,4 +790,7 @@ - if (getDolGlobalString('SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT')) { // Not tested ! - print $langs->trans("BuyingPrice").': '; - } else { - print ''; + if (!empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) // Not tested ! + { + print $langs->trans("BuyingPrice").': '; + } + else + { + print ''; @@ -991,2 +804 @@ - print ''.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').''; - print ''; + print ''; @@ -996,6 +808,8 @@ - if (isModEnabled('productbatch') && $objp->tobatch > 0) { - $type = 'batch'; - print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine('.$i.', \''.$type.'\')"'); - } else { - $type = 'dispatch'; - print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine('.$i.', \''.$type.'\')"'); + if (!empty($conf->productbatch->enabled) && $objp->tobatch == 1) { + $type = 'batch'; + print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine('.$i.', \''.$type.'\')"'); + } + else + { + $type = 'dispatch'; + print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine('.$i.', \''.$type.'\')"'); @@ -1005,2 +819,2 @@ - if (getDolGlobalString('SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT')) { - if (!isModEnabled("multicurrency") && empty($conf->dynamicprices->enabled)) { + if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) { + if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { @@ -1009 +823 @@ - print ''; + print ''; @@ -1014 +828 @@ - print ''; + print ''; @@ -1027 +841 @@ - print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); + print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ?GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); @@ -1029 +843 @@ - print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); + print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ?GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); @@ -1036,17 +850,12 @@ - // Enable hooks to append additional columns - $parameters = array( - 'is_information_row' => false, // this is a dispatch form row - 'i' => $i, - 'suffix' => $suffix, - 'objp' => $objp, - ); - $reshook = $hookmanager->executeHooks( - 'printFieldListValue', - $parameters, - $object, - $action - ); - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - } - print $hookmanager->resPrint; + // Enable hooks to append additional columns + $parameters = array( + 'is_information_row' => false // this is a dispatch form row + ); + $reshook = $hookmanager->executeHooks( + 'printFieldListValue', + $parameters, + $object, + $action + ); + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print $hookmanager->resPrint; @@ -1067 +876,2 @@ - if ($nbproduct) { + if ($nbproduct) + { @@ -1074,24 +884,16 @@ - if (empty($reshook)) { - if (empty($conf->reception->enabled)) { - print $langs->trans("Comment").' : '; - print 'trans("DispatchSupplierOrder", $object->ref); - // print ' / '.$object->ref_supplier; // Not yet available - print '" class="flat">
'; - - print ' '.$checkboxlabel; - } - - $dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive") : $langs->trans("CreateReception"); - - print '
'; - print ''; - print 'reception->enabled)) { + print $langs->trans("Comment").' : '; + print 'trans("DispatchSupplierOrder", $object->ref); + // print ' / '.$object->ref_supplier; // Not yet available + print '" class="flat">
'; + + print ' '.$checkboxlabel; + } + + $dispatchBt = empty($conf->reception->enabled) ? $langs->trans("Receive") : $langs->trans("CreateReception"); + + print '
\n"; - if (!getDolGlobalString('SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED')) { + print "
\n"; + if (empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) @@ -1111 +911 @@ - } else { + else @@ -1113 +912,0 @@ - } @@ -1119 +918 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -1127,25 +925,0 @@ - }); - - $("#autoreset").click(function() { - $(".qtydispatchinput").each(function(){ - id = $(this).attr("id"); - idtab = id.split("_"); - if(idtab[1] == 0){ - console.log(idtab); - $(this).val(""); - $("#qty_dispatched_0_"+idtab[2]).val("0"); - } else { - obj = $(this).parent().parent(); - nameobj = obj.attr("name"); - nametab = nameobj.split("_"); - obj.remove(); - $("tr[name^=\'"+nametab[0]+"_\'][name$=\'_"+nametab[2]+"\']:last .splitbutton").show(); - } - }); - }); - - $(".resetline").click(function(){ - id = $(this).attr("id"); - id = id.split("reset_"); - console.log("Reset trigger for id = qty_"+id[1]); - $("#qty_"+id[1]).val(""); @@ -1160,4 +934 @@ - $sql .= " ,cd.rowid, cd.subprice"; - if ($conf->reception->enabled) { - $sql .= " ,cfd.fk_reception, r.date_delivery"; - } + if ($conf->reception->enabled)$sql .= " ,cfd.fk_reception, r.date_delivery"; @@ -1166 +936,0 @@ - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseurdet as cd ON cd.rowid = cfd.fk_commandefourndet"; @@ -1168,4 +938,2 @@ - if ($conf->reception->enabled) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."reception as r ON cfd.fk_reception = r.rowid"; - } - $sql .= " WHERE cfd.fk_commande = ".((int) $object->id); + if ($conf->reception->enabled)$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."reception as r ON cfd.fk_reception = r.rowid"; + $sql .= " WHERE cfd.fk_commande = ".$object->id; @@ -1189,5 +957,2 @@ - // Reception ref - if ($conf->reception->enabled) { - print ''.$langs->trans("Reception").''; - } - // Product + if ($conf->reception->enabled)print ''.$langs->trans("Reception").''; + @@ -1195,3 +960,3 @@ - print ''.$langs->trans("DateCreation").''; - print ''.$langs->trans("DateDeliveryPlanned").''; - if (isModEnabled('productbatch')) { + print ''.$langs->trans("DateCreation").''; + print ''.$langs->trans("DateDeliveryPlanned").''; + if (!empty($conf->productbatch->enabled)) { @@ -1199,6 +964,2 @@ - if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { - print ''.$langs->trans("SellByDate").''; - } - if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { - print ''.$langs->trans("EatByDate").''; - } + print ''.$langs->trans("EatByDate").''; + print ''.$langs->trans("SellByDate").''; @@ -1206,0 +968 @@ + print ''; @@ -1211 +973 @@ - if (getDolGlobalString('SUPPLIER_ORDER_USE_DISPATCH_STATUS') && empty($reception->rowid)) { + if (!empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS) && empty($reception->rowid)) { @@ -1213 +975,2 @@ - } elseif (isModEnabled("reception")) { + } + elseif (!empty($conf->reception->enabled)) { @@ -1217 +980 @@ - print ''; + print ''; @@ -1220 +982,0 @@ - @@ -1225,13 +987,4 @@ - if ($action == 'editline' && $lineid == $objp->dispatchlineid) { - print ' - - - - '; - } - - print ''; - - // Reception ref - if (isModEnabled("reception")) { - print ''; + print ""; + + if (!empty($conf->reception->enabled)) { + print ''; @@ -1247,10 +1000,2 @@ - // Product - print ''; - if (empty($conf->cache['product'][$objp->fk_product])) { - $tmpproduct = new Product($db); - $tmpproduct->fetch($objp->fk_product); - $conf->cache['product'][$objp->fk_product] = $tmpproduct; - } else { - $tmpproduct = $conf->cache['product'][$objp->fk_product]; - } - print $tmpproduct->getNomUrl(1); + print ''; + print ''.img_object($langs->trans("ShowProduct"), 'product').' '.$objp->ref.''; @@ -1259,9 +1004,4 @@ - - // Date creation - print ''.dol_print_date($db->jdate($objp->datec), 'day').''; - - // Date delivery - print ''.dol_print_date($db->jdate($objp->date_delivery), 'day').''; - - // Batch / Eat by / Sell by - if (isModEnabled('productbatch')) { + print ''.dol_print_date($db->jdate($objp->datec), 'day').''; + print ''.dol_print_date($db->jdate($objp->date_delivery), 'day').''; + + if (!empty($conf->productbatch->enabled)) { @@ -1270 +1010 @@ - $lot = new Productlot($db); + $lot=new Productlot($db); @@ -1273,6 +1013,2 @@ - if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { - print ''.dol_print_date($lot->sellby, 'day').''; - } - if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { - print ''.dol_print_date($lot->eatby, 'day').''; - } + print ''.dol_print_date($lot->eatby, 'day').''; + print ''.dol_print_date($lot->sellby, 'day').''; @@ -1281,6 +1017,2 @@ - if (!getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { - print ''; - } - if (!getDolGlobalString('PRODUCT_DISABLE_EATBY')) { - print ''; - } + print ''; + print ''; @@ -1291,8 +1023,2 @@ - print ''; - if ($action == 'editline' && $lineid == $objp->dispatchlineid) { - print ''; - } else { - print $objp->qty; - } - print ''; - print ''; + print ''.$objp->qty.''; + print ' '; @@ -1301,15 +1027,4 @@ - print ''; - if ($action == 'editline' && $lineid == $objp->dispatchlineid) { - if (count($listwarehouses) > 1) { - print $formproduct->selectWarehouses(GETPOST("fk_entrepot") ? GETPOST("fk_entrepot") : ($objp->warehouse_id ? $objp->warehouse_id : ''), "fk_entrepot", '', 1, 0, $objp->fk_product, '', 1, 1, null, 'csswarehouse'); - } elseif (count($listwarehouses) == 1) { - print $formproduct->selectWarehouses(GETPOST("fk_entrepot") ? GETPOST("fk_entrepot") : ($objp->warehouse_id ? $objp->warehouse_id : ''), "fk_entrepot", '', 0, 0, $objp->fk_product, '', 1, 1, null, 'csswarehouse'); - } else { - $langs->load("errors"); - print $langs->trans("ErrorNoWarehouseDefined"); - } - } else { - $warehouse_static->id = $objp->warehouse_id; - $warehouse_static->label = $objp->entrepot; - print $warehouse_static->getNomUrl(1); - } + print ''; + $warehouse_static->id = $objp->warehouse_id; + $warehouse_static->libelle = $objp->entrepot; + print $warehouse_static->getNomUrl(1); @@ -1322 +1037 @@ - if (getDolGlobalString('SUPPLIER_ORDER_USE_DISPATCH_STATUS') && empty($reception->rowid)) { + if (!empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS) && empty($reception->rowid)) { @@ -1331 +1046,2 @@ - if (!$permissiontocontrol) { + if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check))) + { @@ -1341 +1057 @@ - if ($object->statut == 5) { + if ($object->statut == 5) @@ -1343 +1058,0 @@ - } @@ -1358 +1073 @@ - } elseif (isModEnabled("reception")) { + } elseif (!empty($conf->reception->enabled)) { @@ -1366,26 +1081 @@ - // Action - if ($action != 'editline' || $lineid != $objp->dispatchlineid) { - if (empty($reception->id) || ($reception->statut == Reception::STATUS_DRAFT)) { // only allow edit on draft reception - print ''; - print 'dispatchlineid.'#line_'.$objp->dispatchlineid.'">'; - print img_edit(); - print ''; - print ''; - - print ''; - print 'dispatchlineid.'#dispatch_received_products">'; - print img_delete(); - print ''; - print ''; - } else { - print ''; - } - } else { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - + print ''; @@ -1394,3 +1083,0 @@ - if ($action == 'editline' && $lineid == $objp->dispatchlineid) { - print ''; - } --- /tmp/dsg/dolibarr/htdocs/fourn/commande/github_19.0.3_document.php +++ /tmp/dsg/dolibarr/htdocs/fourn/commande/client_document.php @@ -30 +29,0 @@ -// Load Dolibarr environment @@ -38 +37 @@ -if (isModEnabled('project')) { +if (!empty($conf->projet->enabled)) { @@ -47 +46 @@ -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'alpha'); @@ -48,0 +48,4 @@ + +// Security check +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); @@ -52,2 +55,2 @@ -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -55,3 +58 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -61,6 +62,2 @@ -if (!$sortorder) { - $sortorder = "ASC"; -} -if (!$sortfield) { - $sortfield = "name"; -} +if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "name"; @@ -68 +64,0 @@ -$hookmanager->initHooks(array('ordersuppliercarddocument')); @@ -71 +67,2 @@ -if ($object->fetch($id, $ref) < 0) { +if ($object->fetch($id, $ref) < 0) +{ @@ -79,9 +75,0 @@ -// Security check -$socid = 0; -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); - -$permissiontoadd = ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer")); // Used by the include of actions_setnotes.inc.php - @@ -93 +81 @@ -include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; +include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; @@ -102,3 +90,4 @@ -$title = $object->ref." - ".$langs->trans('Documents'); -$help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; -llxHeader('', $title, $help_url); +if ($object->id > 0) +{ + $help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; + llxHeader('', $langs->trans("Order"), $help_url); @@ -106 +94,0 @@ -if ($object->id > 0) { @@ -114 +102 @@ - print dol_get_fiche_head($head, 'documents', $langs->trans('SupplierOrder'), -1, 'order'); + dol_fiche_head($head, 'documents', $langs->trans('SupplierOrder'), -1, 'order'); @@ -118 +106 @@ - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); @@ -120 +108,2 @@ - foreach ($filearray as $key => $file) { + foreach ($filearray as $key => $file) + { @@ -133 +122 @@ - $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); @@ -135,19 +124,32 @@ - if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref .= '
'; - if (0) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify' && $caneditproject) { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (!getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } - } - } + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->fournisseur->commande->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } @@ -170 +172 @@ - print dol_get_fiche_end(); + dol_fiche_end(); @@ -174,2 +176,2 @@ - $permissiontoadd = ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer")); - $permtoedit = ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer")); + $permission = $user->rights->fournisseur->commande->creer; + $permtoedit = $user->rights->fournisseur->commande->creer; @@ -177,2 +179,4 @@ - include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} else { + include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; +} +else +{ --- /tmp/dsg/dolibarr/htdocs/fourn/commande/github_19.0.3_index.php +++ /tmp/dsg/dolibarr/htdocs/fourn/commande/client_index.php @@ -6 +6 @@ - * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2019 Nicolas ZABOURI @@ -23,7 +23,5 @@ - * \file htdocs/fourn/commande/index.php - * \ingroup commande fournisseur - * \brief Home page of supplier's orders area - */ - - -// Load Dolibarr environment + * \file htdocs/fourn/commande/index.php + * \ingroup commande fournisseur + * \brief Home page of supplier's orders area + */ + @@ -31,0 +30 @@ +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; @@ -33,2 +32,10 @@ -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - + +// Security check +$orderid = GETPOST('orderid'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande'); + +$hookmanager = new HookManager($db); + +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('orderssuppliersindex')); @@ -38,14 +44,0 @@ - - -// Security check -$orderid = GETPOST('orderid'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande'); - -$hookmanager = new HookManager($db); - -// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array -$hookmanager->initHooks(array('orderssuppliersindex')); - @@ -67,0 +61,14 @@ + +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo +{ + print '
'; + print ''; + print '
'; + print ''; + print ''; + print ''; + print "
'.$langs->trans("Search").'
'; + print $langs->trans("SupplierOrder").':

\n"; +} + + @@ -75,3 +82 @@ -if (!$user->hasRight("societe", "client", "voir") && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -} +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -80,6 +85,2 @@ -if ($user->socid) { - $sql .= ' AND cf.fk_soc = '.((int) $user->socid); -} -if (!$user->hasRight("societe", "client", "voir") && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); -} +if ($user->socid) $sql .= ' AND cf.fk_soc = '.$user->socid; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; @@ -89 +90,2 @@ -if ($resql) { +if ($resql) +{ @@ -99 +101,2 @@ - while ($i < $num) { + while ($i < $num) + { @@ -101 +104,2 @@ - if ($obj) { + if ($obj) + { @@ -110 +114 @@ - include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; @@ -117 +121,2 @@ - foreach ($listofstatus as $status) { + foreach ($listofstatus as $status) + { @@ -119,26 +124,11 @@ - if ($status == CommandeFournisseur::STATUS_DRAFT) { - $colorseries[$status] = '-'.$badgeStatus0; - } - if ($status == CommandeFournisseur::STATUS_VALIDATED) { - $colorseries[$status] = '-'.$badgeStatus1; - } - if ($status == CommandeFournisseur::STATUS_ACCEPTED) { - $colorseries[$status] = $badgeStatus1; - } - if ($status == CommandeFournisseur::STATUS_REFUSED) { - $colorseries[$status] = $badgeStatus9; - } - if ($status == CommandeFournisseur::STATUS_ORDERSENT) { - $colorseries[$status] = $badgeStatus4; - } - if ($status == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY) { - $colorseries[$status] = '-'.$badgeStatus4; - } - if ($status == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) { - $colorseries[$status] = $badgeStatus6; - } - if ($status == CommandeFournisseur::STATUS_CANCELED || $status == CommandeFournisseur::STATUS_CANCELED_AFTER_ORDER) { - $colorseries[$status] = $badgeStatus9; - } - - if (!$conf->use_javascript_ajax) { + if ($status == CommandeFournisseur::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; + if ($status == CommandeFournisseur::STATUS_VALIDATED) $colorseries[$status] = '-'.$badgeStatus1; + if ($status == CommandeFournisseur::STATUS_ACCEPTED) $colorseries[$status] = $badgeStatus1; + if ($status == CommandeFournisseur::STATUS_REFUSED) $colorseries[$status] = $badgeStatus9; + if ($status == CommandeFournisseur::STATUS_ORDERSENT) $colorseries[$status] = $badgeStatus4; + if ($status == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY) $colorseries[$status] = '-'.$badgeStatus4; + if ($status == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) $colorseries[$status] = $badgeStatus6; + if ($status == CommandeFournisseur::STATUS_CANCELED || $status == CommandeFournisseur::STATUS_CANCELED_AFTER_ORDER) $colorseries[$status] = $badgeStatus9; + + if (!$conf->use_javascript_ajax) + { @@ -151 +141,2 @@ - if ($conf->use_javascript_ajax) { + if ($conf->use_javascript_ajax) + { @@ -172 +163,3 @@ -} else { +} +else +{ @@ -180 +173,2 @@ -if (isModEnabled("supplier_order")) { +if (!empty($conf->fournisseur->enabled)) +{ @@ -184,3 +178 @@ - if (!$user->hasRight("societe", "client", "voir") && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -190,6 +182,2 @@ - if (!empty($socid)) { - $sql .= " AND c.fk_soc = ".((int) $socid); - } - if (!$user->hasRight("societe", "client", "voir") && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } + if (!empty($socid)) $sql .= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; @@ -198 +186,2 @@ - if ($resql) { + if ($resql) + { @@ -205 +194,2 @@ - if ($num) { + if ($num) + { @@ -207 +197,2 @@ - while ($i < $num) { + while ($i < $num) + { @@ -227 +218 @@ -if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) { +if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { @@ -232 +223,2 @@ -if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) { +if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) +{ @@ -237 +229,3 @@ -} else { +} +else +{ @@ -243 +237,2 @@ -if ($resql) { +if ($resql) +{ @@ -252 +247,2 @@ - while ($i < $num) { + while ($i < $num) + { @@ -259 +255,2 @@ - if ($userstatic->hasRight('fournisseur', 'commande', 'approuver')) { + if (!empty($userstatic->rights->fournisseur->commande->approuver)) + { @@ -275 +272,3 @@ -} else { +} +else +{ @@ -280 +279 @@ -print '
'; +print '
'; @@ -291,3 +290 @@ -if (!$user->hasRight("societe", "client", "voir") && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -} +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -295 +292 @@ -$sql .= " AND c.entity IN (".getEntity('supplier_order').")"; +$sql .= " AND c.entity = ".$conf->entity; @@ -297,6 +294,2 @@ -if (!empty($socid)) { - $sql .= " AND c.fk_soc = ".((int) $socid); -} -if (!$user->hasRight("societe", "client", "voir") && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); -} +if (!empty($socid)) $sql .= " AND c.fk_soc = ".$socid; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; @@ -307 +300,2 @@ -if ($resql) { +if ($resql) +{ @@ -314 +308,2 @@ - if ($num) { + if ($num) + { @@ -316 +311,2 @@ - while ($i < $num) { + while ($i < $num) + { @@ -351,3 +347,2 @@ -} else { - dol_print_error($db); -} +} +else dol_print_error($db); @@ -358 +353 @@ - */ +*/ @@ -363 +358 @@ -if (!$user->hasRight("societe", "client", "voir") && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -365 +360 @@ -$sql.= " AND c.entity IN (".getEntity("supplier_order").")"; +$sql.= " AND c.entity = ".$conf->entity; @@ -367,2 +362,2 @@ -if ($socid) $sql.= " AND c.fk_soc = ".((int) $socid); -if (!$user->hasRight("societe", "client", "voir") && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .((int) $user->id); +if ($socid) $sql.= " AND c.fk_soc = ".$socid; +if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -425 +420 @@ -print '
'; +print ''; --- /tmp/dsg/dolibarr/htdocs/fourn/commande/github_19.0.3_info.php +++ /tmp/dsg/dolibarr/htdocs/fourn/commande/client_info.php @@ -22,7 +22,5 @@ - * \file htdocs/fourn/commande/info.php - * \ingroup commande - * \brief Info page for Purchase Order / Supplier Order - */ - - -// Load Dolibarr environment + * \file htdocs/fourn/commande/info.php + * \ingroup commande + * \brief Fiche commande + */ + @@ -30 +27,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -34 +31,2 @@ -if (isModEnabled('project')) { +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +if (!empty($conf->projet->enabled)) { @@ -41,8 +39,7 @@ -// Get Paramters -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); - -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'alpha'); + +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -50,3 +47 @@ -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -56,16 +51,12 @@ -if (!$sortfield) { - $sortfield = 'a.datep,a.id'; -} -if (!$sortorder) { - $sortorder = 'DESC,DESC'; -} - -if (GETPOST('actioncode', 'array')) { - $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) { - $actioncode = '0'; - } -} else { - $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (!getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECTS') ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECTS)); -} -$search_rowid = GETPOST('search_rowid'); +if (!$sortfield) $sortfield = 'a.datep,a.id'; +if (!$sortorder) $sortorder = 'DESC,DESC'; + +if (GETPOST('actioncode', 'array')) +{ + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; +} +else +{ + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECTS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECTS)); +} @@ -76,3 +67 @@ -if ($user->socid) { - $socid = $user->socid; -} +if ($user->socid) $socid = $user->socid; @@ -81,9 +70,3 @@ -if (!$user->hasRight("fournisseur", "commande", "lire")) { - accessforbidden(); -} - -// Init Hooks -$hookmanager->initHooks(array('ordersuppliercardinfo')); - -$usercancreate = ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer")); -$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php +if (!$user->rights->fournisseur->commande->lire) accessforbidden(); + + @@ -98,3 +81 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -103,3 +84,4 @@ -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers - $actioncode = ''; - $search_agenda_label = ''; +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers +{ + $actioncode = ''; + $search_agenda_label = ''; @@ -117,10 +99,9 @@ -if ($id > 0 || !empty($ref)) { - $object->fetch($id, $ref); - $object->fetch_thirdparty(); - $object->info($object->id); -} - -$title = $object->ref.' - '.$langs->trans('Info').' - '.$object->ref.' '.$object->name; -if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { - $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info"); -} +if ($id > 0 || !empty($ref)) +{ + $object->fetch($id, $ref); + $object->fetch_thirdparty(); + $object->info($object->id); +} + +$title = $langs->trans("SupplierOrder").' - '.$object->ref.' '.$object->name; +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info"); @@ -135 +116 @@ -print dol_get_fiche_head($head, 'info', $langs->trans("SupplierOrder"), -1, 'order'); +dol_fiche_head($head, 'info', $langs->trans("SupplierOrder"), -1, 'order'); @@ -147 +128 @@ -$morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); +$morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); @@ -149,19 +130,32 @@ -if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref .= '
'; - if (0) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify' && $caneditproject) { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (!getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } - } - } +if (!empty($conf->projet->enabled)) +{ + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->fournisseur->commande->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } @@ -183 +177 @@ -print dol_get_fiche_end(); +dol_fiche_end(); @@ -191,3 +185,4 @@ -$permok = $user->hasRight('agenda', 'myactions', 'create'); -if ($permok) { - $out .= '&originid='.$object->id.'&origin=order_supplier'; +$permok = $user->rights->agenda->myactions->create; +if ($permok) +{ + $out .= '&originid='.$object->id.'&origin=order_supplier'; @@ -199,6 +194,10 @@ -if (isModEnabled('agenda')) { - if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { - print ''.$langs->trans("AddAction").''; - } else { - print ''.$langs->trans("AddAction").''; - } +if (!empty($conf->agenda->enabled)) +{ + if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) + { + print ''.$langs->trans("AddAction").''; + } + else + { + print ''.$langs->trans("AddAction").''; + } @@ -210,28 +209,23 @@ -if (!empty($object->id)) { - $param = '&id='.$object->id; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.$contextpage; - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.$limit; - } - - print load_fiche_titre($langs->trans("ActionsOnOrder"), '', ''); - - // List of actions on element - /*include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions=new FormActions($db); - $somethingshown = $formactions->showactions($object,'project',0);*/ - - // List of todo actions - //show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode); - - // List of done actions - //show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters, $sortfield, $sortorder); - - // List of all actions - $filters = array(); - $filters['search_agenda_label'] = $search_agenda_label; - $filters['search_rowid'] = $search_rowid; - - show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); +if (!empty($object->id)) +{ + $param = '&id='.$object->id; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + + print load_fiche_titre($langs->trans("ActionsOnOrder"), '', ''); + + // List of actions on element + /*include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions=new FormActions($db); + $somethingshown = $formactions->showactions($object,'project',0);*/ + + // List of todo actions + //show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode); + + // List of done actions + //show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters, $sortfield, $sortorder); + + // List of all actions + $filters = array(); + $filters['search_agenda_label'] = $search_agenda_label; + show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); --- /tmp/dsg/dolibarr/htdocs/fourn/commande/github_19.0.3_list.php +++ /tmp/dsg/dolibarr/htdocs/fourn/commande/client_list.php @@ -2,11 +2,10 @@ -/* Copyright (C) 2001-2006 Rodolphe Quiedeville - * Copyright (C) 2004-2016 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2013 Cédric Salvador - * Copyright (C) 2014 Marcos García - * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2016 Ferran Marcet - * Copyright (C) 2018-2021 Frédéric France - * Copyright (C) 2018-2022 Charlene Benke - * Copyright (C) 2019 Nicolas Zabouri - * Copyright (C) 2021-2023 Alexandre Spangaro +/* Copyright (C) 2001-2006 Rodolphe Quiedeville + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2014 Marcos García + * Copyright (C) 2014 Juanjo Menent + * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018 Charlene Benke + * Copyright (C) 2019 Nicolas ZABOURI @@ -29,3 +28,3 @@ - * \file htdocs/fourn/commande/list.php - * \ingroup fournisseur - * \brief List of purchase orders + * \file htdocs/fourn/commande/list.php + * \ingroup fournisseur + * \brief List of purchase orders @@ -34,2 +32,0 @@ - -// Load Dolibarr environment @@ -36,0 +34,4 @@ +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; @@ -41,5 +41,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; @@ -49,4 +45,2 @@ -// Load translation files required by the page -$langs->loadLangs(array("orders", "sendings", 'deliveries', 'companies', 'compta', 'bills', 'projects', 'suppliers', 'products')); - -// Get Parameters +$langs->loadLangs(array("orders", "sendings", 'deliveries', 'companies', 'compta', 'bills', 'projects', 'suppliers')); + @@ -58,41 +52,10 @@ -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'supplierorderlist'; -$mode = GETPOST('mode', 'alpha'); - -// Search Criteria -$search_date_order_startday = GETPOST('search_date_order_startday', 'int'); -$search_date_order_startmonth = GETPOST('search_date_order_startmonth', 'int'); -$search_date_order_startyear = GETPOST('search_date_order_startyear', 'int'); -$search_date_order_endday = GETPOST('search_date_order_endday', 'int'); -$search_date_order_endmonth = GETPOST('search_date_order_endmonth', 'int'); -$search_date_order_endyear = GETPOST('search_date_order_endyear', 'int'); -$search_date_order_start = dol_mktime(0, 0, 0, $search_date_order_startmonth, $search_date_order_startday, $search_date_order_startyear); // Use tzserver -$search_date_order_end = dol_mktime(23, 59, 59, $search_date_order_endmonth, $search_date_order_endday, $search_date_order_endyear); - -$search_date_delivery_startday = GETPOST('search_date_delivery_startday', 'int'); -$search_date_delivery_startmonth = GETPOST('search_date_delivery_startmonth', 'int'); -$search_date_delivery_startyear = GETPOST('search_date_delivery_startyear', 'int'); -$search_date_delivery_endday = GETPOST('search_date_delivery_endday', 'int'); -$search_date_delivery_endmonth = GETPOST('search_date_delivery_endmonth', 'int'); -$search_date_delivery_endyear = GETPOST('search_date_delivery_endyear', 'int'); -$search_date_delivery_start = dol_mktime(0, 0, 0, $search_date_delivery_startmonth, $search_date_delivery_startday, $search_date_delivery_startyear); // Use tzserver -$search_date_delivery_end = dol_mktime(23, 59, 59, $search_date_delivery_endmonth, $search_date_delivery_endday, $search_date_delivery_endyear); - -$search_date_valid_startday = GETPOST('search_date_valid_startday', 'int'); -$search_date_valid_startmonth = GETPOST('search_date_valid_startmonth', 'int'); -$search_date_valid_startyear = GETPOST('search_date_valid_startyear', 'int'); -$search_date_valid_endday = GETPOST('search_date_valid_endday', 'int'); -$search_date_valid_endmonth = GETPOST('search_date_valid_endmonth', 'int'); -$search_date_valid_endyear = GETPOST('search_date_valid_endyear', 'int'); -$search_date_valid_start = dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear); // Use tzserver -$search_date_valid_end = dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear); - -$search_date_approve_startday = GETPOST('search_date_approve_startday', 'int'); -$search_date_approve_startmonth = GETPOST('search_date_approve_startmonth', 'int'); -$search_date_approve_startyear = GETPOST('search_date_approve_startyear', 'int'); -$search_date_approve_endday = GETPOST('search_date_approve_endday', 'int'); -$search_date_approve_endmonth = GETPOST('search_date_approve_endmonth', 'int'); -$search_date_approve_endyear = GETPOST('search_date_approve_endyear', 'int'); -$search_date_approve_start = dol_mktime(0, 0, 0, $search_date_approve_startmonth, $search_date_approve_startday, $search_date_approve_startyear); // Use tzserver -$search_date_approve_end = dol_mktime(23, 59, 59, $search_date_approve_endmonth, $search_date_approve_endday, $search_date_approve_endyear); - -$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'supplierorderlist'; + +$search_orderyear = GETPOST("search_orderyear", "int"); +$search_ordermonth = GETPOST("search_ordermonth", "int"); +$search_orderday = GETPOST("search_orderday", "int"); +$search_deliveryyear = GETPOST("search_deliveryyear", "int"); +$search_deliverymonth = GETPOST("search_deliverymonth", "int"); +$search_deliveryday = GETPOST("search_deliveryday", "int"); + +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); @@ -104 +66,0 @@ -$search_company_alias = GETPOST('search_company_alias', 'alpha'); @@ -107 +69 @@ -$search_state = GETPOST("search_state", 'alpha'); +$search_state = trim(GETPOST("search_state", 'alpha')); @@ -113,0 +76 @@ +$search_status = (GETPOST('search_status', 'alpha') != '' ?GETPOST('search_status', 'alpha') : GETPOST('statut', 'alpha')); // alpha and not intbecause it can be '6,7' @@ -118 +81 @@ -$search_total_tva = GETPOST('search_total_tva', 'alpha'); +$search_total_vat = GETPOST('search_total_vat', 'alpha'); @@ -123 +86 @@ -$search_multicurrency_montant_tva = GETPOST('search_multicurrency_montant_tva', 'alpha'); +$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha'); @@ -131,5 +94,7 @@ -if (GETPOSTISARRAY('search_status')) { - $search_status = join(',', GETPOST('search_status', 'array:intcomma')); -} else { - $search_status = (GETPOST('search_status', 'intcomma') != '' ? GETPOST('search_status', 'intcomma') : GETPOST('statut', 'intcomma')); -} +$status = GETPOST('statut', 'alpha'); +$search_status = GETPOST('search_status'); + +// Security check +$orderid = GETPOST('orderid', 'int'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande'); @@ -139,3 +104,3 @@ -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); @@ -143,3 +108 @@ -if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { - $page = 0; -} // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 @@ -149,6 +112,4 @@ -if (!$sortfield) { - $sortfield = 'cf.ref'; -} -if (!$sortorder) { - $sortorder = 'DESC'; -} +if (!$sortfield) $sortfield = 'cf.ref'; +if (!$sortorder) $sortorder = 'DESC'; + +if ($search_status == '') $search_status = -1; @@ -162 +123 @@ -$extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label('commande_fournisseur'); @@ -167,4 +128,43 @@ -$fieldstosearchall = array(); -foreach ($object->fields as $key => $val) { - if (!empty($val['searchall'])) { - $fieldstosearchall['cf.'.$key] = $val['label']; +$fieldstosearchall = array( + 'cf.ref'=>'Ref', + 'cf.ref_supplier'=>'RefSupplierOrder', + 'pd.description'=>'Description', + 's.nom'=>"ThirdParty", + 'cf.note_public'=>'NotePublic', +); +if (empty($user->socid)) $fieldstosearchall["cf.note_private"] = "NotePrivate"; + +$checkedtypetiers = 0; +$arrayfields = array( + 'cf.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'cf.ref_supplier'=>array('label'=>$langs->trans("RefOrderSupplierShort"), 'checked'=>1, 'enabled'=>1), + 'p.project_ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>0, 'enabled'=>1), + 'u.login'=>array('label'=>$langs->trans("AuthorRequest"), 'checked'=>1), + 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), + 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1), + 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1), + 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0), + 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0), + 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers), + 'cf.date_commande'=>array('label'=>$langs->trans("OrderDateShort"), 'checked'=>1), + 'cf.date_delivery'=>array('label'=>$langs->trans("DateDeliveryPlanned"), 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE)), + 'cf.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), + 'cf.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0), + 'cf.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0), + 'cf.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'cf.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'cf.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'cf.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'cf.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'cf.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 'cf.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + 'cf.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), + 'cf.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>1) +); +// Extra fields +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $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])); @@ -173,41 +172,0 @@ -$fieldstosearchall['pd.description'] = 'Description'; -$fieldstosearchall['s.nom'] = "ThirdParty"; -$fieldstosearchall['s.name_alias'] = "AliasNameShort"; -$fieldstosearchall['s.zip'] = "Zip"; -$fieldstosearchall['s.town'] = "Town"; -if (empty($user->socid)) { - $fieldstosearchall["cf.note_private"] = "NotePrivate"; -} - -$checkedtypetiers = 0; - -// Definition of array of fields for columns -$arrayfields = array( - 'u.login'=>array('label'=>"AuthorRequest", 'enabled'=>1, 'position'=>41), - 's.name_alias'=>array('label'=>"AliasNameShort", 'position'=>51, 'checked'=>0), - 's.town'=>array('label'=>"Town", 'enabled'=>1, 'position'=>55, 'checked'=>1), - 's.zip'=>array('label'=>"Zip", 'enabled'=>1, 'position'=>56, 'checked'=>1), - 'state.nom'=>array('label'=>"StateShort", 'enabled'=>1, 'position'=>57), - 'country.code_iso'=>array('label'=>"Country", 'enabled'=>1, 'position'=>58), - 'typent.code'=>array('label'=>"ThirdPartyType", 'enabled'=>$checkedtypetiers, 'position'=>59), - 'cf.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax1_assuj == "1"), 'position'=>140), - 'cf.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax2_assuj == "1"), 'position'=>145), - 'cf.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PUBLIC_NOTES')), 'position'=>750), - 'cf.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES')), 'position'=>760), -); -foreach ($object->fields as $key => $val) { - // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) { - $visible = (int) dol_eval($val['visible'], 1); - $arrayfields['cf.'.$key] = array( - 'label'=>$val['label'], - 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)), - 'position'=>$val['position'], - 'help'=> isset($val['help']) ? $val['help'] : '' - ); - } -} -// Extra fields -include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; - @@ -217,18 +175,0 @@ -$error = 0; - -if (!$user->hasRight('societe', 'client', 'voir')) { - $search_sale = $user->id; -} - -// Security check -$orderid = GETPOST('orderid', 'int'); -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande'); - -$permissiontoread = ($user->hasRight("fournisseur", "commande", "lire") || $user->hasRight("supplier_order", "lire")); -$permissiontoadd = ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer")); -$permissiontodelete = ($user->hasRight("fournisseur", "commande", "supprimer") || $user->hasRight("supplier_order", "supprimer")); -$permissiontovalidate = $permissiontoadd; -$permissiontoapprove = ($user->hasRight("fournisseur", "commande", "approuver") || $user->hasRight("supplier_order", "approuver")); @@ -241,9 +182,4 @@ -if (GETPOST('cancel', 'alpha')) { - $action = 'list'; - $massaction = ''; -} -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createsupplierbills') { - $massaction = ''; -} - -$parameters = array('socid'=>$socid, 'arrayfields'=>&$arrayfields); +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } + +$parameters = array('socid'=>$socid); @@ -251,5 +187,4 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ @@ -260 +195,2 @@ - 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 + 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 + { @@ -268 +203,0 @@ - $search_company_alias = ''; @@ -277 +212 @@ - $search_total_tva = ''; + $search_total_vat = ''; @@ -282 +217 @@ - $search_multicurrency_montant_tva = ''; + $search_multicurrency_montant_vat = ''; @@ -285,33 +220,7 @@ - $search_status = ''; - $search_date_order_startday = ''; - $search_date_order_startmonth = ''; - $search_date_order_startyear = ''; - $search_date_order_endday = ''; - $search_date_order_endmonth = ''; - $search_date_order_endyear = ''; - $search_date_order_start = ''; - $search_date_order_end = ''; - $search_date_delivery_startday = ''; - $search_date_delivery_startmonth = ''; - $search_date_delivery_startyear = ''; - $search_date_delivery_endday = ''; - $search_date_delivery_endmonth = ''; - $search_date_delivery_endyear = ''; - $search_date_delivery_start = ''; - $search_date_delivery_end = ''; - $search_date_valid_startday = ''; - $search_date_valid_startmonth = ''; - $search_date_valid_startyear = ''; - $search_date_valid_endday = ''; - $search_date_valid_endmonth = ''; - $search_date_valid_endyear = ''; - $search_date_valid_start = ''; - $search_date_valid_end = ''; - $search_date_approve_startday = ''; - $search_date_approve_startmonth = ''; - $search_date_approve_startyear = ''; - $search_date_approve_endday = ''; - $search_date_approve_endmonth = ''; - $search_date_approve_endyear = ''; - $search_date_approve_start = ''; - $search_date_approve_end = ''; + $search_status = -1; + $search_orderyear = ''; + $search_ordermonth = ''; + $search_orderday = ''; + $search_deliveryday = ''; + $search_deliverymonth = ''; + $search_deliveryyear = ''; @@ -320 +229 @@ - $toselect = array(); + $toselect = ''; @@ -324 +233,2 @@ - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) + { @@ -330,0 +241,2 @@ + $permissiontoread = $user->rights->fournisseur->commande->lire; + $permissiontodelete = $user->rights->fournisseur->commande->supprimer; @@ -334,37 +246,3 @@ - if ($action == 'validate' && $permissiontovalidate) { - if (GETPOST('confirm') == 'yes') { - $objecttmp = new CommandeFournisseur($db); - $db->begin(); - $error = 0; - - foreach ($toselect as $checked) { - if ($objecttmp->fetch($checked)) { - if ($objecttmp->statut == 0) { - $objecttmp->date_commande = dol_now(); - $result = $objecttmp->valid($user); - if ($result >= 0) { - // If we have permission, and if we don't need to provide the idwarehouse, we go directly on approved step - if (!getDolGlobalString('SUPPLIER_ORDER_NO_DIRECT_APPROVE') && $permissiontoapprove && !(getDolGlobalString('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER') && $objecttmp->hasProductsOrServices(1))) { - $result = $objecttmp->approve($user); - setEventMessages($langs->trans("SupplierOrderValidatedAndApproved"), array($objecttmp->ref)); - } else { - setEventMessages($langs->trans("SupplierOrderValidated"), array($objecttmp->ref)); - } - } else { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - } - } - } - } - - if (!$error) { - $db->commit(); - } else { - $db->rollback(); - } - } - } - - // Mass action to generate vendor bills - if ($massaction == 'confirm_createsupplierbills') { + // TODO Move this into mass action include + if ($massaction == 'confirm_createbills') + { @@ -376 +253,0 @@ - /** @var FactureFournisseur[] $TFactThird */ @@ -380,2 +256,0 @@ - $lastid = 0; - $lastref = ''; @@ -385,2 +259,0 @@ - $default_ref_supplier=dol_print_date(dol_now(), '%Y%m%d%H%M%S'); - @@ -388,3 +261,25 @@ - $cmd = new CommandeFournisseur($db); - if ($cmd->fetch($id_order) <= 0) { - continue; + $cmd = new Commande($db); + if ($cmd->fetch($id_order) <= 0) continue; + + $object = new Facture($db); + if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order. + else { + $object->socid = $cmd->socid; + $object->type = Facture::TYPE_STANDARD; + $object->cond_reglement_id = $cmd->cond_reglement_id; + $object->mode_reglement_id = $cmd->mode_reglement_id; + $object->fk_project = $cmd->fk_project; + + $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + if (empty($datefacture)) + { + $datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y")); + } + + $object->date = $datefacture; + $object->origin = 'commande'; + $object->origin_id = $id_order; + + $res = $object->create($user); + + if ($res > 0) $nb_bills_created++; @@ -393,38 +288,2 @@ - $objecttmp = new FactureFournisseur($db); - if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) { - $objecttmp = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created supplier invoice. - } else { - // Search if the VAT reverse-charge is activated by default in supplier card to resume the information - if (!empty($cmd->socid) > 0) { - $societe = new Societe($db); - $societe->fetch($cmd->socid); - $objecttmp->vat_reverse_charge = $societe->vat_reverse_charge; - } - $objecttmp->socid = $cmd->socid; - $objecttmp->type = $objecttmp::TYPE_STANDARD; - $objecttmp->cond_reglement_id = $cmd->cond_reglement_id; - $objecttmp->mode_reglement_id = $cmd->mode_reglement_id; - $objecttmp->fk_project = $cmd->fk_project; - $objecttmp->multicurrency_code = $cmd->multicurrency_code; - $objecttmp->ref_supplier = !empty($cmd->ref_supplier) ? $cmd->ref_supplier : $default_ref_supplier; - $default_ref_supplier+=1; - - $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - if (empty($datefacture)) { - $datefacture = dol_now(); - } - - $objecttmp->date = $datefacture; - $objecttmp->origin = 'order_supplier'; - $objecttmp->origin_id = $id_order; - - $res = $objecttmp->create($user); - - if ($res > 0) { - $nb_bills_created++; - $lastref = $objecttmp->ref; - $lastid = $objecttmp->id; - } - } - - if ($objecttmp->id > 0) { + if ($object->id > 0) + { @@ -438,3 +297,3 @@ - $sql .= ", '".$db->escape($objecttmp->origin)."'"; - $sql .= ", ".((int) $objecttmp->id); - $sql .= ", '".$db->escape($objecttmp->element)."'"; + $sql .= ", '".$object->origin."'"; + $sql .= ", ".$object->id; + $sql .= ", '".$object->element."'"; @@ -443 +302,2 @@ - if (!$db->query($sql)) { + if (!$db->query($sql)) + { @@ -447 +307,2 @@ - if (!$error) { + if (!$error) + { @@ -449 +310,2 @@ - if (empty($lines) && method_exists($cmd, 'fetch_lines')) { + if (empty($lines) && method_exists($cmd, 'fetch_lines')) + { @@ -457 +319,2 @@ - for ($i = 0; $i < $num; $i++) { + for ($i = 0; $i < $num; $i++) + { @@ -459 +322,2 @@ - if ($lines[$i]->subprice < 0) { + if ($lines[$i]->subprice < 0) + { @@ -462 +326 @@ - $discount->fk_soc = $objecttmp->socid; + $discount->fk_soc = $object->socid; @@ -470,2 +334,3 @@ - if ($discountid > 0) { - $result = $objecttmp->insert_discount($discountid); + if ($discountid > 0) + { + $result = $object->insert_discount($discountid); @@ -473 +338,3 @@ - } else { + } + else + { @@ -478 +345,3 @@ - } else { + } + else + { @@ -483,9 +352,3 @@ - if ($lines[$i]->date_debut_prevue) { - $date_start = $lines[$i]->date_debut_prevue; - } - if ($lines[$i]->date_debut_reel) { - $date_start = $lines[$i]->date_debut_reel; - } - if ($lines[$i]->date_start) { - $date_start = $lines[$i]->date_start; - } + if ($lines[$i]->date_debut_prevue) $date_start = $lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start; @@ -494,9 +357,3 @@ - if ($lines[$i]->date_fin_prevue) { - $date_end = $lines[$i]->date_fin_prevue; - } - if ($lines[$i]->date_fin_reel) { - $date_end = $lines[$i]->date_fin_reel; - } - if ($lines[$i]->date_end) { - $date_end = $lines[$i]->date_end; - } + if ($lines[$i]->date_fin_prevue) $date_end = $lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end; @@ -504 +361,2 @@ - if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { + if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) + { @@ -507 +365 @@ - $result = $objecttmp->addline( + $result = $object->addline( @@ -509,0 +368 @@ + $lines[$i]->qty, @@ -513 +371,0 @@ - $lines[$i]->qty, @@ -519,0 +378 @@ + $lines[$i]->fk_remise_except, @@ -520,0 +380 @@ + 0, @@ -522,7 +382,6 @@ - // we dont use the rank from orderline because we may have lines from several orders - -1, - false, - $lines[$i]->array_options, - $lines[$i]->fk_unit, - // we use the id of each order, not the id of the first one stored in $objecttmp->origin_id - $lines[$i]->fk_commande, + $ii, + $lines[$i]->special_code, + $object->origin, + $lines[$i]->rowid, + $fk_parent_line, + $lines[$i]->fk_fournprice, @@ -530,5 +389,4 @@ - $lines[$i]->ref_supplier, - $lines[$i]->special_code, - $fk_parent_line - ); - if ($result > 0) { + $lines[$i]->label + ); + if ($result > 0) + { @@ -536 +394,3 @@ - } else { + } + else + { @@ -542 +402,2 @@ - if ($result > 0 && $lines[$i]->product_type == 9) { + if ($result > 0 && $lines[$i]->product_type == 9) + { @@ -550,7 +411,4 @@ - $cmd->classifyBilled($user); // TODO Move this in workflow like done for sales orders - - if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) { - $TFactThird[$cmd->socid] = $objecttmp; - } else { - $TFact[$objecttmp->id] = $objecttmp; - } + $cmd->classifyBilled($user); // TODO Move this in workflow like done for customer orders + + if (!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object; + else $TFact[$object->id] = $object; @@ -566,3 +424,5 @@ - foreach ($TAllFact as &$objecttmp) { - $objecttmp->validate($user); - if ($result <= 0) { + foreach ($TAllFact as &$object) + { + $object->validate($user); + if ($result <= 0) + { @@ -570 +430 @@ - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); @@ -574 +434 @@ - $id = $objecttmp->id; // For builddoc action + $id = $object->id; // For builddoc action @@ -578,3 +438,3 @@ - $upload_dir = $conf->fournisseur->facture->dir_output; - $permissiontoadd = ($user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "creer")); - //include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + $upload_dir = $conf->facture->dir_output; + $permissiontoadd = $user->rights->facture->creer; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; @@ -583,4 +443,5 @@ - $massaction = $action = 'confirm_createsupplierbills'; - } - - if (!$error) { + $massaction = $action = 'confirm_createbills'; + } + + if (!$error) + { @@ -588,142 +449,4 @@ - - if ($nb_bills_created == 1) { - $texttoshow = $langs->trans('BillXCreated', '{s1}'); - $texttoshow = str_replace('{s1}', ''.$lastref.'', $texttoshow); - setEventMessages($texttoshow, null, 'mesgs'); - } else { - setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs'); - } - - // Make a redirect to avoid to bill twice if we make a refresh or back - $param = ''; - if (!empty($mode)) { - $param .= '&mode='.urlencode($mode); - } - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); - } - if ($sall) { - $param .= '&sall='.urlencode($sall); - } - if ($socid > 0) { - $param .= '&socid='.urlencode($socid); - } - if ($search_status != '') { - $param .= '&search_status='.urlencode($search_status); - } - if ($search_date_order_startday) { - $param .= '&search_date_order_startday='.urlencode($search_date_order_startday); - } - if ($search_date_order_startmonth) { - $param .= '&search_date_order_startmonth='.urlencode($search_date_order_startmonth); - } - if ($search_date_order_startyear) { - $param .= '&search_date_order_startyear='.urlencode($search_date_order_startyear); - } - if ($search_date_order_endday) { - $param .= '&search_date_order_endday='.urlencode($search_date_order_endday); - } - if ($search_date_order_endmonth) { - $param .= '&search_date_order_endmonth='.urlencode($search_date_order_endmonth); - } - if ($search_date_order_endyear) { - $param .= '&search_date_order_endyear='.urlencode($search_date_order_endyear); - } - if ($search_date_delivery_startday) { - $param .= '&search_date_delivery_startday='.urlencode($search_date_delivery_startday); - } - if ($search_date_delivery_startmonth) { - $param .= '&search_date_delivery_startmonth='.urlencode($search_date_delivery_startmonth); - } - if ($search_date_delivery_startyear) { - $param .= '&search_date_delivery_startyear='.urlencode($search_date_delivery_startyear); - } - if ($search_date_delivery_endday) { - $param .= '&search_date_delivery_endday='.urlencode($search_date_delivery_endday); - } - if ($search_date_delivery_endmonth) { - $param .= '&search_date_delivery_endmonth='.urlencode($search_date_delivery_endmonth); - } - if ($search_date_delivery_endyear) { - $param .= '&search_date_delivery_endyear='.urlencode($search_date_delivery_endyear); - } - if ($search_date_valid_startday) { - $param .= '&search_date_valid_startday='.urlencode($search_date_valid_startday); - } - if ($search_date_valid_startmonth) { - $param .= '&search_date_valid_startmonth='.urlencode($search_date_valid_startmonth); - } - if ($search_date_valid_startyear) { - $param .= '&search_date_valid_startyear='.urlencode($search_date_valid_startyear); - } - if ($search_date_valid_endday) { - $param .= '&search_date_valid_endday='.urlencode($search_date_valid_endday); - } - if ($search_date_valid_endmonth) { - $param .= '&search_date_valid_endmonth='.urlencode($search_date_valid_endmonth); - } - if ($search_date_valid_endyear) { - $param .= '&search_date_valid_endyear='.urlencode($search_date_valid_endyear); - } - if ($search_date_approve_startday) { - $param .= '&search_date_approve_startday='.urlencode($search_date_approve_startday); - } - if ($search_date_approve_startmonth) { - $param .= '&search_date_approve_startmonth='.urlencode($search_date_approve_startmonth); - } - if ($search_date_approve_startyear) { - $param .= '&search_date_approve_startyear='.urlencode($search_date_approve_startyear); - } - if ($search_date_approve_endday) { - $param .= '&search_date_approve_endday='.urlencode($search_date_approve_endday); - } - if ($search_date_approve_endmonth) { - $param .= '&search_date_approve_endmonth='.urlencode($search_date_approve_endmonth); - } - if ($search_date_approve_endyear) { - $param .= '&search_date_approve_endyear='.urlencode($search_date_approve_endyear); - } - if ($search_ref) { - $param .= '&search_ref='.urlencode($search_ref); - } - if ($search_company) { - $param .= '&search_company='.urlencode($search_company); - } - if ($search_company_alias) { - $param .= '&search_company_alias='.urlencode($search_company_alias); - } - //if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer); - if ($search_user > 0) { - $param .= '&search_user='.urlencode($search_user); - } - if ($search_sale > 0) { - $param .= '&search_sale='.urlencode($search_sale); - } - if ($search_total_ht != '') { - $param .= '&search_total_ht='.urlencode($search_total_ht); - } - if ($search_total_tva != '') { - $param .= '&search_total_tva='.urlencode($search_total_tva); - } - if ($search_total_ttc != '') { - $param .= '&search_total_ttc='.urlencode($search_total_ttc); - } - if ($search_project_ref >= 0) { - $param .= "&search_project_ref=".urlencode($search_project_ref); - } - if ($show_files) { - $param .= '&show_files='.urlencode($show_files); - } - if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); - } - if ($billed != '') { - $param .= '&billed='.urlencode($billed); - } - - header("Location: ".$_SERVER['PHP_SELF'].'?'.$param); - exit; - } else { + setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs'); + } + else + { @@ -734 +457 @@ - setEventMessages("Error", null, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); @@ -756 +479,2 @@ -if ($socid > 0) { +if ($socid > 0) +{ @@ -761,2 +485 @@ - -/*if ($search_status) +if ($status) @@ -764,8 +487,3 @@ - if ($search_status == '1,2') $title .= ' - '.$langs->trans("SuppliersOrdersToProcess"); - elseif ($search_status == '3,4') $title .= ' - '.$langs->trans("SuppliersOrdersAwaitingReception"); - elseif ($search_status == '1,2,3') $title .= ' - '.$langs->trans("StatusOrderToProcessShort"); - elseif ($search_status == '6,7') $title .= ' - '.$langs->trans("StatusOrderCanceled"); - elseif (is_numeric($search_status) && $search_status >= 0) $title .= ' - '.$commandestatic->LibStatut($search_status); -}*/ -if ($search_billed > 0) { - $title .= ' - '.$langs->trans("Billed"); + if ($status == '1,2,3') $title .= ' - '.$langs->trans("StatusOrderToProcessShort"); + if ($status == '6,7') $title .= ' - '.$langs->trans("StatusOrderCanceled"); + else $title .= ' - '.$commandestatic->LibStatut($status); @@ -772,0 +491 @@ +if ($search_billed > 0) $title .= ' - '.$langs->trans("Billed"); @@ -776,3 +495 @@ - -$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +// llxHeader('',$title,$help_url); @@ -781,4 +498,2 @@ -if ($sall) { - $sql = 'SELECT DISTINCT'; -} -$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.email,'; +if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; +$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.email,'; @@ -787,3 +502,2 @@ -$sql .= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as delivery_date, cf.date_valid, cf.date_approve,"; -$sql .= ' cf.localtax1 as total_localtax1, cf.localtax2 as total_localtax2,'; -$sql .= ' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva, cf.multicurrency_total_ttc,'; +$sql .= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.tva as total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_delivery,"; +$sql .= ' cf.fk_multicurrency, cf.multicurrency_code, cf.multicurrency_tx, cf.multicurrency_total_ht, cf.multicurrency_total_tva as multicurrency_total_vat, cf.multicurrency_total_ttc,'; @@ -793 +507 @@ -$sql .= " u.firstname, u.lastname, u.photo, u.login, u.email as user_email, u.statut as user_status"; +$sql .= " u.firstname, u.lastname, u.photo, u.login, u.email as user_email"; @@ -796,3 +510 @@ - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); - } + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); @@ -802 +514 @@ -$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook @@ -804,3 +515,0 @@ - -$sqlfields = $sql; // $sql fields to remove for count total - @@ -812,6 +521,3 @@ -if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cf.rowid = ef.fk_object)"; -} -if ($sall) { - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande'; -} +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cf.rowid = ef.fk_object)"; +if ($sall || $search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseurdet as pd ON cf.rowid=pd.fk_commande'; +if ($search_product_category > 0) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; @@ -820,3 +526,7 @@ -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; +// We'll need this table joined to the select in order to filter by sale +if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +if ($search_user > 0) +{ + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; +} @@ -825,28 +535,9 @@ -if ($socid > 0) { - $sql .= " AND s.rowid = ".((int) $socid); -} -if ($search_ref) { - $sql .= natural_search('cf.ref', $search_ref); -} -if ($search_refsupp) { - $sql .= natural_search("cf.ref_supplier", $search_refsupp); -} -if ($sall) { - $sql .= natural_search(array_keys($fieldstosearchall), $sall); -} -if (empty($arrayfields['s.name_alias']['checked']) && $search_company) { - $sql .= natural_search(array("s.nom", "s.name_alias"), $search_company); -} else { - if ($search_company) { - $sql .= natural_search('s.nom', $search_company); - } - if ($search_company_alias) { - $sql .= natural_search('s.name_alias', $search_company_alias); - } -} -if ($search_request_author) { - $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_request_author); -} -if ($search_billed != '' && $search_billed >= 0) { - $sql .= " AND cf.billed = ".((int) $search_billed); -} +if ($socid > 0) $sql .= " AND s.rowid = ".$socid; +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($search_ref) $sql .= natural_search('cf.ref', $search_ref); +if ($search_refsupp) $sql .= natural_search("cf.ref_supplier", $search_refsupp); +if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); +if ($search_company) $sql .= natural_search('s.nom', $search_company); +if ($search_request_author) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_request_author); +if ($search_billed != '' && $search_billed >= 0) $sql .= " AND cf.billed = ".$db->escape($search_billed); +if ($search_product_category > 0) $sql .= " AND cp.fk_categorie = ".$search_product_category; @@ -854,122 +545,23 @@ -if (GETPOST('statut', 'intcomma') !== '') { - $sql .= " AND cf.fk_statut IN (".$db->sanitize($db->escape($db->escape(GETPOST('statut', 'intcomma')))).")"; -} -if ($search_status != '' && $search_status != '-1') { - $sql .= " AND cf.fk_statut IN (".$db->sanitize($db->escape($search_status)).")"; -} -if ($search_date_order_start) { - $sql .= " AND cf.date_commande >= '".$db->idate($search_date_order_start)."'"; -} -if ($search_date_order_end) { - $sql .= " AND cf.date_commande <= '".$db->idate($search_date_order_end)."'"; -} -if ($search_date_delivery_start) { - $sql .= " AND cf.date_livraison >= '".$db->idate($search_date_delivery_start)."'"; -} -if ($search_date_delivery_end) { - $sql .= " AND cf.date_livraison <= '".$db->idate($search_date_delivery_end)."'"; -} -if ($search_date_valid_start) { - $sql .= " AND cf.date_valid >= '".$db->idate($search_date_valid_start)."'"; -} -if ($search_date_valid_end) { - $sql .= " AND cf.date_valid <= '".$db->idate($search_date_valid_end)."'"; -} -if ($search_date_approve_start) { - $sql .= " AND cf.date_livraison >= '".$db->idate($search_date_approve_start)."'"; -} -if ($search_date_approve_end) { - $sql .= " AND cf.date_livraison <= '".$db->idate($search_date_approve_end)."'"; -} -if ($search_town) { - $sql .= natural_search('s.town', $search_town); -} -if ($search_zip) { - $sql .= natural_search("s.zip", $search_zip); -} -if ($search_state) { - $sql .= natural_search("state.nom", $search_state); -} -if ($search_country) { - $sql .= " AND s.fk_pays IN (".$db->sanitize($db->escape($search_country)).')'; -} -if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) { - $sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')'; -} -/*if ($search_sale > 0) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale); -}*/ -if ($search_user > 0) { - $sql .= " AND EXISTS ("; - $sql .= " SELECT ec.rowid "; - $sql .= " FROM " . MAIN_DB_PREFIX . "element_contact as ec"; - $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "c_type_contact as tc ON tc.rowid = ec.fk_c_type_contact"; - $sql .= " WHERE ec.element_id = cf.rowid AND ec.fk_socpeople = " . ((int) $search_user); - $sql .= " AND tc.element = 'order_supplier' AND tc.source = 'internal'"; - $sql .= ")"; -} -if ($search_total_ht != '') { - $sql .= natural_search('cf.total_ht', $search_total_ht, 1); -} -if ($search_total_tva != '') { - $sql .= natural_search('cf.total_tva', $search_total_tva, 1); -} -if ($search_total_ttc != '') { - $sql .= natural_search('cf.total_ttc', $search_total_ttc, 1); -} -if ($search_multicurrency_code != '') { - $sql .= " AND cf.multicurrency_code = '".$db->escape($search_multicurrency_code)."'"; -} -if ($search_multicurrency_tx != '') { - $sql .= natural_search('cf.multicurrency_tx', $search_multicurrency_tx, 1); -} -if ($search_multicurrency_montant_ht != '') { - $sql .= natural_search('cf.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); -} -if ($search_multicurrency_montant_tva != '') { - $sql .= natural_search('cf.multicurrency_total_tva', $search_multicurrency_montant_tva, 1); -} -if ($search_multicurrency_montant_ttc != '') { - $sql .= natural_search('cf.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); -} -if ($search_project_ref != '') { - $sql .= natural_search("p.ref", $search_project_ref); -} -// Search on sale representative -if ($search_sale && $search_sale != '-1') { - if ($search_sale == -2) { - $sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = cf.fk_soc)"; - } elseif ($search_sale > 0) { - $sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = cf.fk_soc AND sc.fk_user = ".((int) $search_sale).")"; - } -} -// Search for tag/category ($searchCategoryProductList is an array of ID) -$searchCategoryProductOperator = -1; -$searchCategoryProductList = array($search_product_category); -if (!empty($searchCategoryProductList)) { - $searchCategoryProductSqlList = array(); - $listofcategoryid = ''; - foreach ($searchCategoryProductList as $searchCategoryProduct) { - if (intval($searchCategoryProduct) == -2) { - $searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."commande_fournisseurdet as cd WHERE cd.fk_commande = cf.rowid AND cd.fk_product = ck.fk_product)"; - } elseif (intval($searchCategoryProduct) > 0) { - if ($searchCategoryProductOperator == 0) { - $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."commande_fournisseurdet as cd WHERE cd.fk_commande = cf.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")"; - } else { - $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct); - } - } - } - if ($listofcategoryid) { - $searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."commande_fournisseurdet as cd WHERE cd.fk_commande = cf.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; - } - if ($searchCategoryProductOperator == 1) { - if (!empty($searchCategoryProductSqlList)) { - $sql .= " AND (".implode(' OR ', $searchCategoryProductSqlList).")"; - } - } else { - if (!empty($searchCategoryProductSqlList)) { - $sql .= " AND (".implode(' AND ', $searchCategoryProductSqlList).")"; - } - } -} +if (GETPOST('statut', 'intcomma') !== '') + $sql .= " AND cf.fk_statut IN (".$db->escape($db->escape(GETPOST('statut', 'intcomma'))).")"; +if ($search_status != '' && $search_status >= 0) + $sql .= " AND cf.fk_statut IN (".$db->escape($search_status).")"; +$sql .= dolSqlDateFilter("cf.date_commande", $search_orderday, $search_ordermonth, $search_orderyear); +$sql .= dolSqlDateFilter("cf.date_livraison", $search_deliveryday, $search_deliverymonth, $search_deliveryyear); +if ($search_town) $sql .= natural_search('s.town', $search_town); +if ($search_zip) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); +if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')'; +if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')'; +if ($search_company) $sql .= natural_search('s.nom', $search_company); +if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$db->escape($search_sale); +if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='supplier_order' AND tc.source='internal' AND ec.element_id = cf.rowid AND ec.fk_socpeople = ".$db->escape($search_user); +if ($search_total_ht != '') $sql .= natural_search('cf.total_ht', $search_total_ht, 1); +if ($search_total_vat != '') $sql .= natural_search('cf.tva', $search_total_vat, 1); +if ($search_total_ttc != '') $sql .= natural_search('cf.total_ttc', $search_total_ttc, 1); +if ($search_multicurrency_code != '') $sql .= ' AND cf.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"'; +if ($search_multicurrency_tx != '') $sql .= natural_search('cf.multicurrency_tx', $search_multicurrency_tx, 1); +if ($search_multicurrency_montant_ht != '') $sql .= natural_search('cf.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); +if ($search_multicurrency_montant_vat != '') $sql .= natural_search('cf.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); +if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('cf.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); +if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_ref); @@ -980 +572 @@ -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook @@ -983 +575,2 @@ -// Count total nb of records +$sql .= $db->order($sortfield, $sortorder); + @@ -985,13 +578,6 @@ -if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { - /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); - $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); - $resql = $db->query($sqlforcount); - if ($resql) { - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; - } else { - dol_print_error($db); - } - - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +{ + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { @@ -1001 +586,0 @@ - $db->free($resql); @@ -1004,5 +589 @@ -$sql .= $db->order($sortfield, $sortorder); -if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); -} -//print $sql; +$sql .= $db->plimit($limit + 1, $offset); @@ -1011 +592,13 @@ -if ($resql) { +if ($resql) +{ + if ($socid > 0) + { + $soc = new Societe($db); + $soc->fetch($socid); + $title = $langs->trans('ListOfSupplierOrders').' - '.$soc->name; + } + else + { + $title = $langs->trans('ListOfSupplierOrders'); + } + @@ -1016 +609,2 @@ - if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $sall) { + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) + { @@ -1026,151 +620,28 @@ - if (!empty($mode)) { - $param .= '&mode='.urlencode($mode); - } - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); - } - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.((int) $limit); - } - if ($sall) { - $param .= '&sall='.urlencode($sall); - } - if ($socid > 0) { - $param .= '&socid='.urlencode($socid); - } - if ($sall) { - $param .= "&search_all=".urlencode($sall); - } - if ($search_date_order_startday) { - $param .= '&search_date_order_startday='.urlencode($search_date_order_startday); - } - if ($search_date_order_startmonth) { - $param .= '&search_date_order_startmonth='.urlencode($search_date_order_startmonth); - } - if ($search_date_order_startyear) { - $param .= '&search_date_order_startyear='.urlencode($search_date_order_startyear); - } - if ($search_date_order_endday) { - $param .= '&search_date_order_endday='.urlencode($search_date_order_endday); - } - if ($search_date_order_endmonth) { - $param .= '&search_date_order_endmonth='.urlencode($search_date_order_endmonth); - } - if ($search_date_order_endyear) { - $param .= '&search_date_order_endyear='.urlencode($search_date_order_endyear); - } - if ($search_date_delivery_startday) { - $param .= '&search_date_delivery_startday='.urlencode($search_date_delivery_startday); - } - if ($search_date_delivery_startmonth) { - $param .= '&search_date_delivery_startmonth='.urlencode($search_date_delivery_startmonth); - } - if ($search_date_delivery_startyear) { - $param .= '&search_date_delivery_startyear='.urlencode($search_date_delivery_startyear); - } - if ($search_date_delivery_endday) { - $param .= '&search_date_delivery_endday='.urlencode($search_date_delivery_endday); - } - if ($search_date_delivery_endmonth) { - $param .= '&search_date_delivery_endmonth='.urlencode($search_date_delivery_endmonth); - } - if ($search_date_delivery_endyear) { - $param .= '&search_date_delivery_endyear='.urlencode($search_date_delivery_endyear); - } - if ($search_date_valid_startday) { - $param .= '&search_date_valid_startday='.urlencode($search_date_valid_startday); - } - if ($search_date_valid_startmonth) { - $param .= '&search_date_valid_startmonth='.urlencode($search_date_valid_startmonth); - } - if ($search_date_valid_startyear) { - $param .= '&search_date_valid_startyear='.urlencode($search_date_valid_startyear); - } - if ($search_date_valid_endday) { - $param .= '&search_date_valid_endday='.urlencode($search_date_valid_endday); - } - if ($search_date_valid_endmonth) { - $param .= '&search_date_valid_endmonth='.urlencode($search_date_valid_endmonth); - } - if ($search_date_valid_endyear) { - $param .= '&search_date_valid_endyear='.urlencode($search_date_valid_endyear); - } - if ($search_date_approve_startday) { - $param .= '&search_date_approve_startday='.urlencode($search_date_approve_startday); - } - if ($search_date_approve_startmonth) { - $param .= '&search_date_approve_startmonth='.urlencode($search_date_approve_startmonth); - } - if ($search_date_approve_startyear) { - $param .= '&search_date_approve_startyear='.urlencode($search_date_approve_startyear); - } - if ($search_date_approve_endday) { - $param .= '&search_date_approve_endday='.urlencode($search_date_approve_endday); - } - if ($search_date_approve_endmonth) { - $param .= '&search_date_approve_endmonth='.urlencode($search_date_approve_endmonth); - } - if ($search_date_approve_endyear) { - $param .= '&search_date_approve_endyear='.urlencode($search_date_approve_endyear); - } - if ($search_ref) { - $param .= '&search_ref='.urlencode($search_ref); - } - if ($search_company) { - $param .= '&search_company='.urlencode($search_company); - } - if ($search_company_alias) { - $param .= '&search_company_alias='.urlencode($search_company_alias); - } - if ($search_user > 0) { - $param .= '&search_user='.urlencode($search_user); - } - if ($search_request_author) { - $param .= '&search_request_author='.urlencode($search_request_author); - } - if ($search_sale > 0) { - $param .= '&search_sale='.urlencode($search_sale); - } - if ($search_total_ht != '') { - $param .= '&search_total_ht='.urlencode($search_total_ht); - } - if ($search_total_ttc != '') { - $param .= "&search_total_ttc=".urlencode($search_total_ttc); - } - if ($search_multicurrency_code != '') { - $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code); - } - if ($search_multicurrency_tx != '') { - $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx); - } - if ($search_multicurrency_montant_ht != '') { - $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht); - } - if ($search_multicurrency_montant_tva != '') { - $param .= '&search_multicurrency_montant_tva='.urlencode($search_multicurrency_montant_tva); - } - if ($search_multicurrency_montant_ttc != '') { - $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc); - } - if ($search_refsupp) { - $param .= "&search_refsupp=".urlencode($search_refsupp); - } - if ($search_status != '' && $search_status != '-1') { - $param .= "&search_status=".urlencode($search_status); - } - if ($search_project_ref >= 0) { - $param .= "&search_project_ref=".urlencode($search_project_ref); - } - if ($search_billed != '') { - $param .= "&search_billed=".urlencode($search_billed); - } - if ($show_files) { - $param .= '&show_files='.urlencode($show_files); - } - if ($optioncss != '') { - $param .= '&optioncss='.urlencode($optioncss); - } - if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) { - $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); - } - + if ($socid > 0) $param .= '&socid='.$socid; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; + if ($sall) $param .= "&search_all=".$sall; + if ($search_orderday) $param .= '&search_orderday='.$search_orderday; + if ($search_ordermonth) $param .= '&search_ordermonth='.$search_ordermonth; + if ($search_orderyear) $param .= '&search_orderyear='.$search_orderyear; + if ($search_deliveryday) $param .= '&search_deliveryday='.$search_deliveryday; + if ($search_deliverymonth) $param .= '&search_deliverymonth='.$search_deliverymonth; + if ($search_deliveryyear) $param .= '&search_deliveryyear='.$search_deliveryyear; + if ($search_ref) $param .= '&search_ref='.$search_ref; + if ($search_company) $param .= '&search_company='.$search_company; + if ($search_user > 0) $param .= '&search_user='.$search_user; + if ($search_request_author) $param .= '&search_request_author='.$search_request_author; + if ($search_sale > 0) $param .= '&search_sale='.$search_sale; + if ($search_total_ht != '') $param .= '&search_total_ht='.$search_total_ht; + if ($search_total_ttc != '') $param .= "&search_total_ttc=".$search_total_ttc; + if ($search_multicurrency_code != '') $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code); + if ($search_multicurrency_tx != '') $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx); + if ($search_multicurrency_montant_ht != '') $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht); + if ($search_multicurrency_montant_vat != '') $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat); + if ($search_multicurrency_montant_ttc != '') $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc); + if ($search_refsupp) $param .= "&search_refsupp=".urlencode($search_refsupp); + if ($search_status >= 0) $param .= "&search_status=".urlencode($search_status); + if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); + if ($search_billed != '') $param .= "&search_billed=".urlencode($search_billed); + if ($show_files) $param .= '&show_files='.urlencode($show_files); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); @@ -1180,4 +650,0 @@ - $parameters = array('param' => &$param); - $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook - $param .= $hookmanager->resPrint; - @@ -1186,3 +653,3 @@ - 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), - 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), - 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), + 'generate_doc'=>$langs->trans("ReGeneratePDF"), + 'builddoc'=>$langs->trans("PDFMerge"), + 'presend'=>$langs->trans("SendByMail"), @@ -1190,18 +657,3 @@ - - if ($permissiontovalidate) { - if ($permissiontoapprove && !getDolGlobalString('SUPPLIER_ORDER_NO_DIRECT_APPROVE')) { - $arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ValidateAndApprove"); - } else { - $arrayofmassactions['prevalidate'] = img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"); - } - } - - if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight("supplier_invoice", "creer")) { - $arrayofmassactions['createbills'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("CreateInvoiceForThisSupplier"); - } - if ($permissiontodelete) { - $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); - } - if (in_array($massaction, array('presend', 'predelete', 'createbills'))) { - $arrayofmassactions = array(); - } + //if($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); + if ($user->rights->fournisseur->commande->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); + if (in_array($massaction, array('presend', 'predelete', 'createbills'))) $arrayofmassactions = array(); @@ -1210,5 +661,0 @@ - $url = DOL_URL_ROOT.'/fourn/commande/card.php?action=create'; - if ($socid > 0) { - $url .= '&socid='.((int) $socid); - $url .= '&backtopage='.urlencode(DOL_URL_ROOT.'/fourn/commande/list.php?socid='.((int) $socid)); - } @@ -1216,10 +663,8 @@ - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); - $newcardbutton .= dolGetButtonTitleSeparator(); - $newcardbutton .= dolGetButtonTitle($langs->trans('NewSupplierOrderShort'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd); - - // Lines of title fields - print '
'; - if ($optioncss != '') { - print ''; - } + if ($user->rights->fournisseur->commande->creer) + { + $newcardbutton .= dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/fourn/commande/card.php?action=create'); + } + + // Fields title search + print ''; + if ($optioncss != '') print ''; @@ -1228,0 +674 @@ + print ''; @@ -1231,3 +676,0 @@ - print ''; - print ''; - print ''; @@ -1239 +682 @@ - $objecttmp = new CommandeFournisseur($db); // in case $object is not the good object + $objecttmp = new CommandeFournisseur($db); @@ -1243,5 +686,2 @@ - if ($massaction == 'prevalidate') { - print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1); - } - - if ($massaction == 'createbills') { + if ($massaction == 'createbills') + { @@ -1249,3 +689,3 @@ - print ''; - - print ''; + print ''; + + print '
'; @@ -1253 +693 @@ - print '
'; + print ''; @@ -1277,0 +718 @@ + print '
'; @@ -1280 +721 @@ - print ''; + print ''; @@ -1283,7 +724,5 @@ - print '
'; - } - - if ($sall) { - foreach ($fieldstosearchall as $key => $val) { - $fieldstosearchall[$key] = $langs->trans($val); - } + } + + if ($sall) + { + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); @@ -1296 +735,2 @@ - if ($user->hasRight("user", "user", "lire")) { + if ($user->rights->societe->client->voir || $socid) + { @@ -1299,2 +739,2 @@ - $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); - $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx'); + $moreforfilter .= $langs->trans('ThirdPartiesOfSaleRepresentative').': '; + $moreforfilter .= $formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth200'); @@ -1304 +744,2 @@ - if ($user->hasRight("user", "user", "lire")) { + if ($user->rights->user->user->lire) + { @@ -1306,2 +747,2 @@ - $tmptitle = $langs->trans('LinkedToSpecificUsers'); - $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx'); + $moreforfilter .= $langs->trans('LinkedToSpecificUsers').': '; + $moreforfilter .= $form->select_dolusers($search_user, 'search_user', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200'); @@ -1311 +752,2 @@ - if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire') && ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire'))) { + if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire)) + { @@ -1314 +756 @@ - $tmptitle = $langs->trans('IncludingProductWithTag'); + $moreforfilter .= $langs->trans('IncludingProductWithTag').': '; @@ -1316 +758 @@ - $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300 widthcentpercentminusx', 1); + $moreforfilter .= $form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); @@ -1321,7 +763,5 @@ - if (empty($reshook)) { - $moreforfilter .= $hookmanager->resPrint; - } else { - $moreforfilter = $hookmanager->resPrint; - } - - if (!empty($moreforfilter)) { + if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; + else $moreforfilter = $hookmanager->resPrint; + + if (!empty($moreforfilter)) + { @@ -1334,12 +774,2 @@ - $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields - $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); - - if (GETPOST('autoselectall', 'int')) { - $selectedfields .= ''; - } + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); @@ -1348 +778 @@ - print ''."\n"; + print '
'."\n"; @@ -1351,7 +780,0 @@ - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } @@ -1359,2 +782,3 @@ - if (!empty($arrayfields['cf.ref']['checked'])) { - print ''; + if (!empty($arrayfields['cf.ref']['checked'])) + { + print ''; @@ -1363,2 +787,3 @@ - if (!empty($arrayfields['cf.ref_supplier']['checked'])) { - print ''; + if (!empty($arrayfields['cf.ref_supplier']['checked'])) + { + print ''; @@ -1367,2 +792,3 @@ - if (!empty($arrayfields['cf.fk_projet']['checked'])) { - print ''; + if (!empty($arrayfields['p.project_ref']['checked'])) + { + print ''; @@ -1371 +797,2 @@ - if (!empty($arrayfields['u.login']['checked'])) { + if (!empty($arrayfields['u.login']['checked'])) + { @@ -1377 +804,2 @@ - if (!empty($arrayfields['cf.fk_soc']['checked'])) { + if (!empty($arrayfields['s.nom']['checked'])) + { @@ -1380,4 +807,0 @@ - // Alias - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - } @@ -1385,3 +809 @@ - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - } + if (!empty($arrayfields['s.town']['checked'])) print ''; @@ -1389,3 +811 @@ - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - } + if (!empty($arrayfields['s.zip']['checked'])) print ''; @@ -1393 +813,2 @@ - if (!empty($arrayfields['state.nom']['checked'])) { + if (!empty($arrayfields['state.nom']['checked'])) + { @@ -1399 +820,2 @@ - if (!empty($arrayfields['country.code_iso']['checked'])) { + if (!empty($arrayfields['country.code_iso']['checked'])) + { @@ -1405 +827,2 @@ - if (!empty($arrayfields['typent.code']['checked'])) { + if (!empty($arrayfields['typent.code']['checked'])) + { @@ -1407 +830 @@ - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (!getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1); + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT)); @@ -1411,8 +834,6 @@ - if (!empty($arrayfields['cf.date_commande']['checked'])) { - print ''; - } - if (!empty($arrayfields['cf.total_ht']['checked'])) { + if (!empty($arrayfields['cf.date_delivery']['checked'])) + { + print ''; + } + if (!empty($arrayfields['cf.total_ht']['checked'])) + { @@ -1438 +858,2 @@ - if (!empty($arrayfields['cf.total_tva']['checked'])) { + if (!empty($arrayfields['cf.total_vat']['checked'])) + { @@ -1441,4 +862,5 @@ - print ''; - print ''; - } - if (!empty($arrayfields['cf.total_ttc']['checked'])) { + print ''; + print ''; + } + if (!empty($arrayfields['cf.total_ttc']['checked'])) + { @@ -1450 +872,2 @@ - if (!empty($arrayfields['cf.multicurrency_code']['checked'])) { + if (!empty($arrayfields['cf.multicurrency_code']['checked'])) + { @@ -1456 +879,2 @@ - if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) { + if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) + { @@ -1462 +886,2 @@ - if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) { + if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) + { @@ -1468 +893,2 @@ - if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) { + if (!empty($arrayfields['cf.multicurrency_total_vat']['checked'])) + { @@ -1471,4 +897,5 @@ - print ''; - print ''; - } - if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) { + print ''; + print ''; + } + if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) + { @@ -1488 +915,2 @@ - if (!empty($arrayfields['cf.date_creation']['checked'])) { + if (!empty($arrayfields['cf.datec']['checked'])) + { @@ -1493 +921,2 @@ - if (!empty($arrayfields['cf.tms']['checked'])) { + if (!empty($arrayfields['cf.tms']['checked'])) + { @@ -1497,6 +925,0 @@ - // Billed - if (!empty($arrayfields['cf.billed']['checked'])) { - print ''; - } @@ -1504,7 +927,9 @@ - if (!empty($arrayfields['cf.fk_statut']['checked'])) { - print ''; - } - // Date valid - if (!empty($arrayfields['cf.date_valid']['checked'])) { + if (!empty($arrayfields['cf.fk_statut']['checked'])) + { + print ''; + } + // Status billed + if (!empty($arrayfields['cf.billed']['checked'])) + { @@ -1512,27 +937 @@ - print '
'; - print $form->selectDate($search_date_valid_start ? $search_date_valid_start : -1, 'search_date_valid_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_date_valid_end ? $search_date_valid_end : -1, 'search_date_valid_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; - print ''; - } - // Date approve - if (!empty($arrayfields['cf.date_approve']['checked'])) { - print ''; - } - // Note public - if (!empty($arrayfields['cf.note_public']['checked'])) { - print ''; - } - // Note private - if (!empty($arrayfields['cf.note_private']['checked'])) { - print ''; - } + print ''; @@ -1551,4 +947,0 @@ - $totalarray = array(); - $totalarray['nbfield'] = 0; - - // Fields title @@ -1556,92 +949,21 @@ - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.ref']['checked'])) { - print_liste_field_titre($arrayfields['cf.ref']['label'], $_SERVER["PHP_SELF"], "cf.ref", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.ref_supplier']['checked'])) { - print_liste_field_titre($arrayfields['cf.ref_supplier']['label'], $_SERVER["PHP_SELF"], "cf.ref_supplier", "", $param, '', $sortfield, $sortorder, 'tdoverflowmax100imp '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.fk_projet']['checked'])) { - print_liste_field_titre($arrayfields['cf.fk_projet']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['u.login']['checked'])) { - print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], "u.login", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.fk_soc']['checked'])) { - print_liste_field_titre($arrayfields['cf.fk_soc']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['s.name_alias']['checked'])) { - print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['s.town']['checked'])) { - print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['s.zip']['checked'])) { - print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['state.nom']['checked'])) { - print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['country.code_iso']['checked'])) { - print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['typent.code']['checked'])) { - print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.fk_author']['checked'])) { - print_liste_field_titre($arrayfields['cf.fk_author']['label'], $_SERVER["PHP_SELF"], "cf.fk_author", "", $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.date_commande']['checked'])) { - print_liste_field_titre($arrayfields['cf.date_commande']['label'], $_SERVER["PHP_SELF"], "cf.date_commande", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.date_livraison']['checked'])) { - print_liste_field_titre($arrayfields['cf.date_livraison']['label'], $_SERVER["PHP_SELF"], 'cf.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.total_ht']['checked'])) { - print_liste_field_titre($arrayfields['cf.total_ht']['label'], $_SERVER["PHP_SELF"], "cf.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.total_tva']['checked'])) { - print_liste_field_titre($arrayfields['cf.total_tva']['label'], $_SERVER["PHP_SELF"], "cf.total_tva", "", $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.total_ttc']['checked'])) { - print_liste_field_titre($arrayfields['cf.total_ttc']['label'], $_SERVER["PHP_SELF"], "cf.total_ttc", "", $param, '', $sortfield, $sortorder, 'right '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.multicurrency_code']['checked'])) { - print_liste_field_titre($arrayfields['cf.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_code', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) { - print_liste_field_titre($arrayfields['cf.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_tx', '', $param, '', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) { - print_liste_field_titre($arrayfields['cf.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) { - print_liste_field_titre($arrayfields['cf.multicurrency_total_tva']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) { - print_liste_field_titre($arrayfields['cf.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); - $totalarray['nbfield']++; - } + if (!empty($arrayfields['cf.ref']['checked'])) print_liste_field_titre($arrayfields['cf.ref']['label'], $_SERVER["PHP_SELF"], "cf.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['cf.ref_supplier']['checked'])) print_liste_field_titre($arrayfields['cf.ref_supplier']['label'], $_SERVER["PHP_SELF"], "cf.ref_supplier", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.project_ref']['checked'])) print_liste_field_titre($arrayfields['p.project_ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], "u.login", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cf.fk_author']['checked'])) print_liste_field_titre($arrayfields['cf.fk_author']['label'], $_SERVER["PHP_SELF"], "cf.fk_author", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['cf.date_commande']['checked'])) print_liste_field_titre($arrayfields['cf.date_commande']['label'], $_SERVER["PHP_SELF"], "cf.date_commande", "", $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cf.date_delivery']['checked'])) print_liste_field_titre($arrayfields['cf.date_delivery']['label'], $_SERVER["PHP_SELF"], 'cf.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['cf.total_ht']['checked'])) print_liste_field_titre($arrayfields['cf.total_ht']['label'], $_SERVER["PHP_SELF"], "cf.total_ht", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['cf.total_vat']['checked'])) print_liste_field_titre($arrayfields['cf.total_vat']['label'], $_SERVER["PHP_SELF"], "cf.tva", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['cf.total_ttc']['checked'])) print_liste_field_titre($arrayfields['cf.total_ttc']['label'], $_SERVER["PHP_SELF"], "cf.total_ttc", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['cf.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_code', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_tx', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['cf.multicurrency_total_vat']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) print_liste_field_titre($arrayfields['cf.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'cf.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); @@ -1654,36 +976,5 @@ - if (!empty($arrayfields['cf.date_creation']['checked'])) { - print_liste_field_titre($arrayfields['cf.date_creation']['label'], $_SERVER["PHP_SELF"], "cf.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowraponall '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.tms']['checked'])) { - print_liste_field_titre($arrayfields['cf.tms']['label'], $_SERVER["PHP_SELF"], "cf.tms", "", $param, '', $sortfield, $sortorder, 'center nowraponall '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.billed']['checked'])) { - print_liste_field_titre($arrayfields['cf.billed']['label'], $_SERVER["PHP_SELF"], 'cf.billed', '', $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.fk_statut']['checked'])) { - print_liste_field_titre($arrayfields['cf.fk_statut']['label'], $_SERVER["PHP_SELF"], "cf.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.date_valid']['checked'])) { - print_liste_field_titre($arrayfields['cf.date_valid']['label'], $_SERVER["PHP_SELF"], "cf.date_valid", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.date_approve']['checked'])) { - print_liste_field_titre($arrayfields['cf.date_approve']['label'], $_SERVER["PHP_SELF"], 'cf.date_approve', '', $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.note_public']['checked'])) { - print_liste_field_titre($arrayfields['cf.note_public']['label'], $_SERVER["PHP_SELF"], "cf.note_public", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; - } - if (!empty($arrayfields['cf.note_private']['checked'])) { - print_liste_field_titre($arrayfields['cf.note_private']['label'], $_SERVER["PHP_SELF"], "cf.note_private", "", $param, '', $sortfield, $sortorder, 'center '); - $totalarray['nbfield']++; - } - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); - $totalarray['nbfield']++; - } + if (!empty($arrayfields['cf.datec']['checked'])) print_liste_field_titre($arrayfields['cf.datec']['label'], $_SERVER["PHP_SELF"], "cf.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['cf.tms']['checked'])) print_liste_field_titre($arrayfields['cf.tms']['label'], $_SERVER["PHP_SELF"], "cf.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + if (!empty($arrayfields['cf.fk_statut']['checked'])) print_liste_field_titre($arrayfields['cf.fk_statut']['label'], $_SERVER["PHP_SELF"], "cf.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['cf.billed']['checked'])) print_liste_field_titre($arrayfields['cf.billed']['label'], $_SERVER["PHP_SELF"], 'cf.billed', '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); @@ -1690,0 +982 @@ + @@ -1701,8 +993,3 @@ - $savnbfield = $totalarray['nbfield']; - $totalarray = array('nbfield' => 0, 'val' => array(), 'pos' => array()); - $totalarray['val']['cf.total_ht'] = 0; - $totalarray['val']['cf.total_ttc'] = 0; - $totalarray['val']['cf.total_tva'] = 0; - - $imaxinloop = ($limit ? min($num, $limit) : $num); - while ($i < $imaxinloop) { + $totalarray = array(); + while ($i < min($num, $limit)) + { @@ -1710,6 +996,0 @@ - - $notshippable = 0; - $warning = 0; - $text_info = ''; - $text_warning = ''; - $nbprod = 0; @@ -1720 +1000,0 @@ - $objectstatic->socid = $obj->socid; @@ -1724,2 +1004 @@ - $objectstatic->date_commande = $db->jdate($obj->date_commande); - $objectstatic->delivery_date = $db->jdate($obj->delivery_date); + $objectstatic->date_delivery = $db->jdate($obj->date_delivery); @@ -1730,6 +1009,52 @@ - if ($mode == 'kanban') { - if ($i == 0) { - print ''; + + // Ref + if (!empty($arrayfields['cf.ref']['checked'])) + { + print ''."\n"; + if (!$i) $totalarray['nbfield']++; + } + // Ref Supplier + if (!empty($arrayfields['cf.ref_supplier']['checked'])) + { + print ''."\n"; + if (!$i) $totalarray['nbfield']++; + } + // Project + if (!empty($arrayfields['p.project_ref']['checked'])) + { + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_title; + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Author + $userstatic->id = $obj->fk_user_author; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->login = $obj->login; + $userstatic->photo = $obj->photo; + $userstatic->email = $obj->user_email; + if (!empty($arrayfields['u.login']['checked'])) + { + print '"; + if (!$i) $totalarray['nbfield']++; + } + // Thirdparty + if (!empty($arrayfields['s.nom']['checked'])) + { + print ''; + print $thirdpartytmp->getNomUrl(1, 'supplier'); + print ''."\n"; + if (!$i) $totalarray['nbfield']++; + } + // Town + if (!empty($arrayfields['s.town']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // State + if (!empty($arrayfields['state.nom']['checked'])) + { + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Order date + if (!empty($arrayfields['cf.date_commande']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Plannned date of delivery + if (!empty($arrayfields['cf.date_delivery']['checked'])) + { + print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - // Ref - if (!empty($arrayfields['cf.ref']['checked'])) { - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Ref Supplier - if (!empty($arrayfields['cf.ref_supplier']['checked'])) { - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Project - if (!empty($arrayfields['cf.fk_projet']['checked'])) { - $projectstatic->id = $obj->project_id; - $projectstatic->ref = $obj->project_ref; - $projectstatic->title = $obj->project_title; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Author - $userstatic->id = $obj->fk_user_author; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - $userstatic->login = $obj->login; - $userstatic->photo = $obj->photo; - $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_status; - if (!empty($arrayfields['u.login']['checked'])) { - print '"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Thirdparty - if (!empty($arrayfields['cf.fk_soc']['checked'])) { - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Alias - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Order date - if (!empty($arrayfields['cf.date_commande']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Plannned date of delivery - if (!empty($arrayfields['cf.date_livraison']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount HT - if (!empty($arrayfields['cf.total_ht']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ht'; - } - $totalarray['val']['cf.total_ht'] += $obj->total_ht; - } - // Amount VAT - if (!empty($arrayfields['cf.total_tva']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_tva'; - } - $totalarray['val']['cf.total_tva'] += $obj->total_tva; - } - // Amount TTC - if (!empty($arrayfields['cf.total_ttc']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ttc'; - } - $totalarray['val']['cf.total_ttc'] += $obj->total_ttc; - } - - // Currency - if (!empty($arrayfields['cf.multicurrency_code']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Currency rate - if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount HT - if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount VAT - if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount TTC - if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['cf.date_creation']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['cf.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Billed - if (!empty($arrayfields['cf.billed']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['cf.fk_statut']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // valid date - if (!empty($arrayfields['cf.date_valid']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // approve date - if (!empty($arrayfields['cf.date_approve']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Note public - if (!empty($arrayfields['cf.note_public']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Note private - if (!empty($arrayfields['cf.note_private']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - - print "\n"; - - $total += $obj->total_ht; - $subtotal += $obj->total_ht; - } + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Amount HT + if (!empty($arrayfields['cf.total_ht']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ht'; + $totalarray['val']['cf.total_ht'] += $obj->total_ht; + } + // Amount VAT + if (!empty($arrayfields['cf.total_vat']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_vat'; + $totalarray['val']['cf.total_vat'] += $obj->total_tva; + } + // Amount TTC + if (!empty($arrayfields['cf.total_ttc']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ttc'; + $totalarray['val']['cf.total_ttc'] += $obj->total_ttc; + } + + // Currency + if (!empty($arrayfields['cf.multicurrency_code']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + + // Currency rate + if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount HT + if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount VAT + if (!empty($arrayfields['cf.multicurrency_total_vat']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount TTC + if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['cf.datec']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Date modification + if (!empty($arrayfields['cf.tms']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Status + if (!empty($arrayfields['cf.fk_statut']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Billed + if (!empty($arrayfields['cf.billed']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Action column + print ''; + if (!$i) $totalarray['nbfield']++; + + print "\n"; @@ -2094,10 +1241,8 @@ - // If no record found - if ($num == 0) { - $colspan = 1; - foreach ($arrayfields as $key => $val) { - if (!empty($val['checked'])) { - $colspan++; - } - } - print ''; - } + + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + print "
'; - $searchpicto = $form->showFilterButtons('left'); - print $searchpicto; - print ''; - print '
'; - print $form->selectDate($search_date_order_start ? $search_date_order_start : -1, 'search_date_order_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_date_order_end ? $search_date_order_end : -1, 'search_date_order_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; + if (!empty($arrayfields['cf.date_commande']['checked'])) + { + print '
'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_orderyear ? $search_orderyear : -1, 'search_orderyear', 1, 20, 5); @@ -1422,11 +843,10 @@ - if (!empty($arrayfields['cf.date_livraison']['checked'])) { - print ''; - print '
'; - print $form->selectDate($search_date_delivery_start ? $search_date_delivery_start : -1, 'search_date_delivery_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_date_delivery_end ? $search_date_delivery_end : -1, 'search_date_delivery_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; - print '
'; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_deliveryyear ? $search_deliveryyear : -1, 'search_deliveryyear', 1, 20, 5); + print ''; - print $form->selectyesno('search_billed', $search_billed, 1, false, 1, 1, 'search_status width100 onrightofpage'); - print ''; - $formorder->selectSupplierOrderStatus($search_status, 1, 'search_status', 'search_status width100 onrightofpage'); - print ''; + $formorder->selectSupplierOrderStatus((strstr($search_status, ',') ?-1 : $search_status), 1, 'search_status'); + print ''; - print '
'; - print $form->selectDate($search_date_approve_start ? $search_date_approve_start : -1, 'search_date_approve_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_date_approve_end ? $search_date_approve_end : -1, 'search_date_approve_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; - print '
'; - print ''; + print $form->selectyesno('search_billed', $search_billed, 1, 0, 1); @@ -1542,6 +941,4 @@ - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - $searchpicto = $form->showFilterButtons(); - print $searchpicto; - print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; - print '
'; - } - + print '
'; + + // Picto + Ref + print $objectstatic->getNomUrl(1, '', 0, -1, 1); + // Other picto tool + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->fournisseur->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref); + print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + + print ''.$obj->ref_supplier.''; + if ($obj->project_id > 0) print $projectstatic->getNomUrl(1); + print ''; + if ($userstatic->id) print $userstatic->getNomUrl(1); + print "'; @@ -1739,8 +1064,61 @@ - $thirdpartytmp->name_alias = $obj->alias; - $thirdpartytmp->client = $obj->client; - $thirdpartytmp->fournisseur = $obj->fournisseur; - // Output Kanban - print $objectstatic->getKanbanView('', array('thirdparty'=>$thirdpartytmp->getNomUrl('supplier', 0, 0, -1), 'selected' => in_array($objectstatic->id, $arrayofselected))); - if ($i == ($imaxinloop - 1)) { - print ''; - print '
'; + print $obj->town; + print ''; + print $obj->zip; + print '".$obj->state_name."'; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; + print ''; + if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1); + print $typenArray[$obj->typent_code]; + print ''; + if ($obj->date_commande) print dol_print_date($db->jdate($obj->date_commande), 'day'); + else print ''; + print ''; + print dol_print_date($db->jdate($obj->date_delivery), 'day'); + if ($objectstatic->hasDelay() && !empty($objectstatic->date_delivery)) { + print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning"); @@ -1748,340 +1126,109 @@ - } else { - print '
'; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print ''; - - // Picto + Ref - print $objectstatic->getNomUrl(1, '', 0, -1, 1); - // Other picto tool - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->fournisseur->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref); - print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - - print ''.dol_escape_htmltag($obj->ref_supplier).''; - if ($obj->project_id > 0) { - print $projectstatic->getNomUrl(1); - } - print ''; - if ($userstatic->id) { - print $userstatic->getNomUrl(1); - } - print "'; - $thirdpartytmp->id = $obj->socid; - $thirdpartytmp->name = $obj->name; - $thirdpartytmp->email = $obj->email; - $thirdpartytmp->name_alias = $obj->alias; - $thirdpartytmp->client = $obj->client; - $thirdpartytmp->fournisseur = $obj->fournisseur; - print $thirdpartytmp->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); - print ''; - print $obj->alias; - print ''; - print $obj->town; - print ''; - print $obj->zip; - print '".$obj->state_name."'; - $tmparray = getCountry($obj->fk_pays, 'all'); - print $tmparray['label']; - print ''; - if (empty($typenArray)) { - $typenArray = $formcompany->typent_array(1); - } - print $typenArray[$obj->typent_code]; - print ''; - print dol_print_date($db->jdate($obj->date_commande), 'day'); - if ($objectstatic->statut != $objectstatic::STATUS_ORDERSENT && $objectstatic->statut != $objectstatic::STATUS_RECEIVED_PARTIALLY) { - if ($objectstatic->hasDelay()) { - print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning"); - } - } - print ''; - print dol_print_date($db->jdate($obj->delivery_date), 'day'); - if ($objectstatic->statut == $objectstatic::STATUS_ORDERSENT || $objectstatic->statut == $objectstatic::STATUS_RECEIVED_PARTIALLY) { - if ($objectstatic->hasDelay()) { - print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning"); - } - } - print ''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."'; - $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); - print "'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_tva)."'.price($obj->multicurrency_total_ttc)."'; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''.yn($obj->billed).''.$objectstatic->LibStatut($obj->fk_statut, 5, $obj->billed).''; - print dol_print_date($db->jdate($obj->date_valid), 'day'); - print ''; - print dol_print_date($db->jdate($obj->date_approve), 'day'); - print ''; - print dol_string_nohtmltag($obj->note_public); - print ''; - print dol_string_nohtmltag($obj->note_private); - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print '
'.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."'; + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + print "'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_ttc)."'; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''.$objectstatic->LibStatut($obj->fk_statut, 5, $obj->billed).''.yn($obj->billed).''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; + } + print '
'.$langs->trans("NoRecordFound").'
\n"; + print ''; + print "\n"; @@ -2107,9 +1251,0 @@ - $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); - $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - print '
'."\n"; - print ''; - - print ''."\n"; - @@ -2117,3 +1253 @@ - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { - $hidegeneratedfilelistifempty = 0; - } + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; @@ -2126,2 +1260,2 @@ - $genallowed = $permissiontoread; - $delallowed = $permissiontoadd; + $genallowed = $user->rights->fournisseur->commande->lire; + $delallowed = $user->rights->fournisseur->commande->creer; @@ -2130 +1264,3 @@ -} else { +} +else +{ --- /tmp/dsg/dolibarr/htdocs/fourn/commande/github_19.0.3_note.php +++ /tmp/dsg/dolibarr/htdocs/fourn/commande/client_note.php @@ -23,3 +23,3 @@ - * \file htdocs/fourn/commande/note.php - * \ingroup commande - * \brief page for notes on supplier orders + * \file htdocs/fourn/commande/note.php + * \ingroup commande + * \brief Fiche note commande @@ -28,2 +27,0 @@ - -// Load Dolibarr environment @@ -33 +31 @@ -if (isModEnabled('project')) { +if (!empty($conf->projet->enabled)) { @@ -40,2 +38 @@ -// Get Parameters -$id = GETPOST('facid', 'int') ? GETPOST('facid', 'int') : GETPOST('id', 'int'); +$id = GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int'); @@ -46,6 +43 @@ -if ($user->socid) { - $socid = $user->socid; -} - -// Init Objects -$hookmanager->initHooks(array('ordersuppliercardnote')); +if ($user->socid) $socid = $user->socid; @@ -57,4 +49 @@ -// Permissions -$permissionnote = ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer")); // Used by the include of actions_setnotes.inc.php -$usercancreate = ($user->hasRight("fournisseur", "commande", "creer") || $user->hasRight("supplier_order", "creer")); -$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php +$permissionnote = $user->rights->fournisseur->commande->creer; // Used by the include of actions_setnotes.inc.php @@ -67,7 +56 @@ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} -if (empty($reshook)) { - include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once -} +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once @@ -79,2 +61,0 @@ - -$title = $object->ref." - ".$langs->trans('Notes'); @@ -82 +63 @@ -llxHeader('', $title, $help_url); +llxHeader('', $langs->trans("Order"), $help_url); @@ -94,3 +75,5 @@ -if ($id > 0 || !empty($ref)) { - if ($result >= 0) { - $object->fetch_thirdparty(); +if ($id > 0 || !empty($ref)) +{ + if ($result >= 0) + { + $object->fetch_thirdparty(); @@ -98,2 +81,2 @@ - $author = new User($db); - $author->fetch($object->user_author_id); + $author = new User($db); + $author->fetch($object->user_author_id); @@ -101 +84 @@ - $head = ordersupplier_prepare_head($object); + $head = ordersupplier_prepare_head($object); @@ -103,2 +86,2 @@ - $title = $langs->trans("SupplierOrder"); - print dol_get_fiche_head($head, 'note', $title, -1, 'order'); + $title = $langs->trans("SupplierOrder"); + dol_fiche_head($head, 'note', $title, -1, 'order'); @@ -115 +98 @@ - $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); @@ -117,19 +100,32 @@ - if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref .= '
'; - if (0) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify' && $caneditproject) { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (!getDolGlobalString('PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } - } - } + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->fournisseur->commande->creer) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ' : '; + } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } @@ -147 +143 @@ - include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; @@ -149 +145 @@ - print ''; + print ''; @@ -151,6 +147,8 @@ - print dol_get_fiche_end(); - } else { - /* Order not found */ - $langs->load("errors"); - print $langs->trans("ErrorRecordNotFound"); - } + dol_fiche_end(); + } + else + { + /* Order not found */ + $langs->load("errors"); + print $langs->trans("ErrorRecordNotFound"); + }