--- /tmp/dsg/dolibarr/htdocs/supplier_proposal/github_19.0.3_card.php +++ /tmp/dsg/dolibarr/htdocs/supplier_proposal/client_card.php @@ -15 +14,0 @@ - * Copyright (C) 2022 Gauthier VERDOL @@ -37 +35,0 @@ -// Load Dolibarr environment @@ -48 +46 @@ -if (isModEnabled('project')) { +if (!empty($conf->projet->enabled)) { @@ -55 +53 @@ -if (isModEnabled('margin')) { +if (!empty($conf->margin->enabled)) @@ -57 +54,0 @@ -} @@ -64,5 +61 @@ -$action = GETPOST('action', 'aZ09'); -$cancel = GETPOST('cancel', 'alpha'); -$backtopage = GETPOST('backtopage', 'alpha'); -$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); - +$action = GETPOST('action', 'alpha'); @@ -71,0 +65 @@ +$projectid = GETPOST('projectid', 'int'); @@ -74,2 +67,0 @@ -$projectid = GETPOST('projectid', 'int'); -$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1; @@ -78,3 +70,3 @@ -$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)); +$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)); @@ -83,0 +76,4 @@ + +// Security check +if (!empty($user->socid)) $socid = $user->socid; +$result = restrictedArea($user, 'supplier_proposal', $id); @@ -97 +93 @@ - if ($ret > 0) { + if ($ret > 0) @@ -99,5 +95,2 @@ - } - if ($ret <= 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } + if ($ret < 0) + dol_print_error('', $object->error); @@ -106,24 +99,3 @@ -// Common permissions -$usercanread = $user->rights->supplier_proposal->lire; -$usercancreate = $user->rights->supplier_proposal->creer; -$usercandelete = $user->rights->supplier_proposal->supprimer; - -// Advanced permissions -$usercanvalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->supplier_proposal->validate_advance))); -$usercansend = (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || $user->rights->supplier_proposal->send_advance); - -// Additional area permissions -$usercanclose = $user->rights->supplier_proposal->cloturer; -$usercancreateorder = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->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; - -// Security check -if (!empty($user->socid)) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'supplier_proposal', $object->id); +$permissionnote = $user->rights->supplier_proposal->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->supplier_proposal->creer; // Used by the include of actions_dellink.inc.php +$permissiontoedit = $user->rights->supplier_proposal->creer; // Used by the include of actions_lineupdown.inc.php @@ -138,22 +110,8 @@ -if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -} - -if (empty($reshook)) { - $backurlforlist = DOL_URL_ROOT.'/supplier_proposal/list.php'; - - 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.'/supplier_proposal/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)) + { @@ -173,2 +131,4 @@ - if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) { - if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { + if ($action == 'confirm_clone' && $confirm == 'yes') + { + if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) + { @@ -176 +136,3 @@ - } else { + } + else + { @@ -182 +144,3 @@ - } else { + } + else + { @@ -188,2 +152,5 @@ - } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete) { - // Delete askprice + } + + // Delete askprice + elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->supplier_proposal->supprimer) + { @@ -198,2 +165,5 @@ - } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { - // Remove line + } + + // Remove line + elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->supplier_proposal->creer) + { @@ -202 +172 @@ - if ($result > 0) { + if ($result) @@ -204,6 +174,2 @@ - } else { - $langs->load("errors"); - setEventMessages($object->error, $object->errors, 'errors'); - } - - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -212 +178 @@ - if (getDolGlobalInt('MAIN_MULTILANGS')) { + if (!empty($conf->global->MAIN_MULTILANGS)) { @@ -218,4 +184 @@ - if ($ret > 0) { - $object->fetch_thirdparty(); - } - $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -226,2 +189,8 @@ - } elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate) { - // Validation + } + + // Validation + elseif ($action == 'confirm_validate' && $confirm == 'yes' && + ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->creer)) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->validate_advance))) + ) + { @@ -229,21 +198,20 @@ - if ($result >= 0) { - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { - $outputlangs = $langs; - $newlang = ''; - 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 (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } - $model = $object->model_pdf; - $ret = $object->fetch($id); // Reload to get new records - if ($ret > 0) { - $object->fetch_thirdparty(); - } - - $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result >= 0) + { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + $outputlangs = $langs; + $newlang = ''; + 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; + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model = $object->modelpdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } @@ -253,9 +221,9 @@ - if (count($object->errors) > 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } else { - setEventMessages($langs->trans($object->error), null, 'errors'); - } - } - } elseif ($action == 'setdate_livraison' && $usercancreate) { - $result = $object->setDeliveryDate($user, dol_mktime(12, 0, 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int'))); - if ($result < 0) { + if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors'); + else setEventMessages($langs->trans($object->error), null, 'errors'); + } + } + + elseif ($action == 'setdate_livraison' && $user->rights->supplier_proposal->creer) + { + $result = $object->set_date_livraison($user, dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year'])); + if ($result < 0) @@ -263,3 +231,5 @@ - } - } elseif ($action == 'add' && $usercancreate) { - // Create supplier proposal + } + + // Create supplier proposal + elseif ($action == 'add' && $user->rights->supplier_proposal->creer) + { @@ -277 +247,2 @@ - if (!$error) { + if (!$error) + { @@ -281 +252,2 @@ - if (GETPOST('createmode') == 'copy' && GETPOST('copie_supplier_proposal')) { + if (GETPOST('createmode') == 'copy' && GETPOST('copie_supplier_proposal')) + { @@ -284 +256 @@ - $object->delivery_date = $date_delivery; + $object->date_livraison = $date_delivery; @@ -288,0 +261,2 @@ + $object->remise_percent = GETPOST('remise_percent'); + $object->remise_absolue = GETPOST('remise_absolue'); @@ -291 +265 @@ - $object->model_pdf = GETPOST('model'); + $object->modelpdf = GETPOST('model'); @@ -293,2 +267 @@ - $object->note = GETPOST('note', 'restricthtml'); - $object->note_private = GETPOST('note', 'restricthtml'); + $object->note = GETPOST('note', 'none'); @@ -295,0 +269,2 @@ + + $id = $object->create_from($user); @@ -301 +276 @@ - $object->delivery_date = $date_delivery; + $object->date_livraison = $date_delivery; @@ -308 +283 @@ - $object->model_pdf = GETPOST('model'); + $object->modelpdf = GETPOST('model'); @@ -310,2 +285 @@ - $object->note = GETPOST('note', 'restricthtml'); - $object->note_private = GETPOST('note', 'restricthtml'); + $object->note = GETPOST('note', 'none'); @@ -317 +291,2 @@ - if (isModEnabled("multicurrency")) { + if (!empty($conf->multicurrency->enabled)) + { @@ -329,26 +304,6 @@ - if (!$error) { - if ($origin && $originid) { - // Parse element/subelement (ex: project_task) - $element = $subelement = $origin; - if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { - $element = $regs[1]; - $subelement = $regs[2]; - } - - // For compatibility - if ($element == 'order') { - $element = $subelement = 'commande'; - } - if ($element == 'propal') { - $element = 'comm/propal'; - $subelement = 'propal'; - } - if ($element == 'contract') { - $element = $subelement = 'contrat'; - } - if ($element == 'inter') { - $element = $subelement = 'ficheinter'; - } - if ($element == 'shipping') { - $element = $subelement = 'expedition'; - } + if (!$error) + { + if ($origin && $originid) + { + $element = 'supplier_proposal'; + $subelement = 'supplier_proposal'; @@ -366 +321,2 @@ - if ($id > 0) { + if ($id > 0) + { @@ -375 +331,2 @@ - if ($result > 0) { + if ($result > 0) + { @@ -377 +334,2 @@ - if (empty($lines) && method_exists($srcobject, 'fetch_lines')) { + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) + { @@ -384 +342,2 @@ - for ($i = 0; $i < $num; $i++) { + for ($i = 0; $i < $num; $i++) + { @@ -419,2 +378 @@ - $lines[$i]->pa_ht, - $label, + $lines[$i]->pa_ht, $label, @@ -443 +401 @@ - // modified by hook + // modified by hook @@ -445 +402,0 @@ - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -456,2 +413,3 @@ - } else { - // Standard creation + } // Standard creation + else + { @@ -461,2 +419,4 @@ - if ($id > 0) { - if (!$error) { + if ($id > 0) + { + if (!$error) + { @@ -466 +426,2 @@ - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { @@ -469,6 +430,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; @@ -479 +436 @@ - $model = $object->model_pdf; + $model = $object->modelpdf; @@ -483,3 +440 @@ - if ($result < 0) { - dol_print_error($db, $result); - } + if ($result < 0) dol_print_error($db, $result); @@ -490 +445,3 @@ - } else { + } + else + { @@ -494 +451,3 @@ - } else { + } + else + { @@ -501,2 +460,4 @@ - } elseif ($action == 'confirm_reopen' && $usercanclose && !GETPOST('cancel', 'alpha')) { - // Reopen proposal + } + + // Reopen proposal + elseif ($action == 'confirm_reopen' && $user->rights->supplier_proposal->cloturer && !GETPOST('cancel', 'alpha')) { @@ -507,2 +468,4 @@ - } elseif ($action == 'close' && $usercanclose && !GETPOST('cancel', 'alpha')) { - // Close proposal + } + + // Close proposal + elseif ($action == 'close' && $user->rights->supplier_proposal->cloturer && !GETPOST('cancel', 'alpha')) { @@ -513,2 +476,4 @@ - } elseif ($action == 'setstatut' && $usercanclose && !GETPOST('cancel', 'alpha')) { - // Set accepted/refused + } + + // Set accepted/refused + elseif ($action == 'setstatut' && $user->rights->supplier_proposal->cloturer && !GETPOST('cancel', 'alpha')) { @@ -521 +486 @@ - $object->cloture($user, GETPOST('statut'), GETPOST('note', 'restricthtml')); + $object->cloture($user, GETPOST('statut'), GETPOST('note', 'none')); @@ -532 +497 @@ - $trackid = 'spro'.$object->id; + $trackid = 'spr'.$object->id; @@ -536,0 +502 @@ + $permissiontoadd = $user->rights->supplier_proposal->creer; @@ -541 +507,2 @@ - if ($action == 'modif' && $usercancreate) { + if ($action == 'modif' && $user->rights->supplier_proposal->creer) + { @@ -544 +511,2 @@ - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { @@ -547 +515 @@ - if (getDolGlobalInt('MAIN_MULTILANGS')) { + if (!empty($conf->global->MAIN_MULTILANGS)) { @@ -553,7 +521,6 @@ - if ($ret > 0) { - $object->fetch_thirdparty(); - } - $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } elseif ($action == "setabsolutediscount" && $usercancreate) { - if (GETPOST("remise_id", 'int')) { + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + + elseif ($action == "setabsolutediscount" && $user->rights->supplier_proposal->creer) { + if ($_POST["remise_id"]) { @@ -561 +528 @@ - $result = $object->insert_discount(GETPOST("remise_id", 'int')); + $result = $object->insert_discount($_POST["remise_id"]); @@ -570,10 +537,2 @@ - if ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha') && $usercancreate) { - // Define vat_rate - $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->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); - } - } elseif ($action == 'addline' && $usercancreate) { + if ($action == 'addline' && $user->rights->supplier_proposal->creer) + { @@ -585 +544 @@ - $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); + $product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : ''); @@ -588 +546,0 @@ - @@ -590,3 +548,3 @@ - - $prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09'); - if ($prod_entry_mode == 'free') { + $prod_entry_mode = GETPOST('prod_entry_mode'); + if ($prod_entry_mode == 'free') + { @@ -594 +552,5 @@ - } else { + $price_ht = GETPOST('price_ht'); + $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); + } + else + { @@ -596,15 +558,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', 2); - - $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0); - if (empty($remise_percent)) { - $remise_percent = 0; - } + $price_ht = ''; + $tva_tx = ''; + } + + $qty = GETPOST('qty'.$predef); + $remise_percent = GETPOST('remise_percent'.$predef); + $price_ht_devise = GETPOST('multicurrency_price_ht'); @@ -623,5 +577 @@ - if ($prod_entry_mode == 'free' && GETPOST('price_ht') < 0 && $qty < 0) { - setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); - $error++; - } - if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && GETPOST('type') < 0) { + if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('type') < 0) { @@ -632 +582,2 @@ - if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && GETPOST('multicurrency_price_ht') === '') { // Unit price can be 0 but not ''. Also price can be negative for proposal. + if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && $price_ht_devise === '') // Unit price can be 0 but not ''. Also price can be negative for proposal. + { @@ -636 +587 @@ - if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) { + if ($prod_entry_mode == 'free' && empty($idprod) && empty($product_desc)) { @@ -641,2 +592,2 @@ - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $pu_ht = 0; + $pu_ttc = 0; @@ -648 +599,5 @@ - if ($prod_entry_mode != 'free' && empty($error)) { // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' + // Ecrase $pu par celui du produit + // Ecrase $desc par celui du produit + // Ecrase $txtva par celui du produit + if (($prod_entry_mode != 'free') && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' + { @@ -652,3 +607 @@ - 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, ...) @@ -657 +610,2 @@ - if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) { + if (preg_match('/^idprod_([0-9]+)$/', GETPOST('idprodfournprice', 'alpha'), $reg)) + { @@ -659 +613 @@ - $res = $productsupplier->fetch($idprod); // Load product from its id + $res = $productsupplier->fetch($idprod); // Load product from its ID @@ -662 +616,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)) + { @@ -665 +620,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 + { @@ -668 +624,3 @@ - } else { + } + else + { @@ -672 +630,3 @@ - } elseif (GETPOST('idprodfournprice', 'alpha') > 0) { + } + elseif (GETPOST('idprodfournprice', 'alpha') > 0) + { @@ -679 +639,2 @@ - if ($idprod > 0) { + if ($idprod > 0) + { @@ -682,18 +642,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; - } @@ -701,15 +644,8 @@ - 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')); - } + 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)); + + $type = $productsupplier->type; + $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); @@ -719,9 +655,3 @@ - // 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; - } + $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; @@ -731,23 +661,2 @@ - $type = $productsupplier->type; - if (GETPOST('price_ht') != '' || GETPOST('multicurrency_price_ht') != '') { - $price_base_type = 'HT'; - $pu = price2num($price_ht, 'MU'); - $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'); - } else { - $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type : 'HT'); - if (empty($object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code != $object->multicurrency_code)) { // If object is in a different currency and price not in this currency - $pu = $productsupplier->fourn_pu; - $pu_devise = 0; - } else { - $pu = $productsupplier->fourn_pu; - $pu_devise = $productsupplier->fourn_multicurrency_unitprice; - } - } - - if (empty($pu)) { - $pu = 0; // If pu is '' or null, we force to have a numeric value - } + $pu_ht = $productsupplier->fourn_pu; + if (empty($pu_ht)) $pu_ht = 0; // If pu is '' or null, we force to have a numeric value @@ -761 +670 @@ - ($price_base_type == 'HT' ? $pu : 0), + $pu_ht, @@ -769 +678 @@ - ($price_base_type == 'TTC' ? $pu : 0), + $pu_ttc, @@ -772 +681 @@ - min($rank, count($object->lines) + 1), + -1, @@ -783 +692 @@ - $pu_devise, + $productsupplier->fourn_multicurrency_unitprice, @@ -786,6 +695,5 @@ - ); - - //var_dump($tva_tx); - //var_dump($productsupplier->fourn_pu); - //var_dump($price_base_type);exit; - if ($result < 0) { + ); + + //var_dump($tva_tx);var_dump($productsupplier->fourn_pu);var_dump($price_base_type);exit; + if ($result < 0) + { @@ -796 +704,2 @@ - if ($idprod == -99 || $idprod == 0) { + if ($idprod == -99 || $idprod == 0) + { @@ -802 +711,2 @@ - if ($idprod == -1) { + if ($idprod == -1) + { @@ -808 +718,3 @@ - } elseif ((GETPOST('price_ht') !== '' || GETPOST('price_ttc') !== '' || GETPOST('multicurrency_price_ht') != '') && empty($error)) { // Free product. // $price_ht is already set + } + elseif ((GETPOST('price_ht') !== '' || GETPOST('price_ttc') !== '' || GETPOST('multicurrency_price_ht') != '') && empty($error)) // Free product. // $price_ht is already set + { @@ -811 +722,0 @@ - @@ -820,3 +731 @@ - 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 @@ -828 +737,2 @@ - if (GETPOST('price_ht') != '' || GETPOST('multicurrency_price_ht') != '') { + if ($price_ht !== '') + { @@ -830 +740,3 @@ - } else { + } + else + { @@ -835,2 +747 @@ - $pu_ht_devise = price2num($price_ht_devise, 'CU'); - $info_bits = 0; + $pu_ht_devise = price2num($price_ht_devise, 'MU'); @@ -862,6 +773,6 @@ - $pu_ht_devise - ); - } - - - if (!$error && $result > 0) { + $pu_ht_devise); + } + + + if (!$error && $result > 0) + { @@ -873 +784,2 @@ - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { @@ -876,6 +788,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; @@ -886 +794 @@ - $model = $object->model_pdf; + $model = $object->modelpdf; @@ -888,3 +795,0 @@ - if ($ret > 0) { - $object->fetch_thirdparty(); - } @@ -893,3 +798 @@ - if ($result < 0) { - dol_print_error($db, $result); - } + if ($result < 0) dol_print_error($db, $result); @@ -907 +809,0 @@ - unset($_POST['fourn_ref']); @@ -921,2 +822,0 @@ - unset($_POST['units']); - @@ -923,0 +824,171 @@ + + unset($_POST['date_starthour']); + unset($_POST['date_startmin']); + unset($_POST['date_startsec']); + unset($_POST['date_startday']); + unset($_POST['date_startmonth']); + unset($_POST['date_startyear']); + unset($_POST['date_endhour']); + unset($_POST['date_endmin']); + unset($_POST['date_endsec']); + unset($_POST['date_endday']); + unset($_POST['date_endmonth']); + unset($_POST['date_endyear']); + } + else + { + $db->rollback(); + + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + // Mise a jour d'une ligne dans la demande de prix + elseif ($action == 'updateline' && $user->rights->supplier_proposal->creer && GETPOST('save') == $langs->trans("Save")) { + $vat_rate = (GETPOST('tva_tx') ?GETPOST('tva_tx') : 0); + + // Define info_bits + $info_bits = 0; + if (preg_match('/\*/', $vat_rate)) + $info_bits |= 0x01; + + // Clean parameters + $description = dol_htmlcleanlastbr(GETPOST('product_desc', 'none')); + + // Define vat_rate + $vat_rate = str_replace('*', '', $vat_rate); + $localtax1_rate = get_localtax($vat_rate, 1, $mysoc, $object->thirdparty); + $localtax2_rate = get_localtax($vat_rate, 2, $mysoc, $object->thirdparty); + + if (GETPOST('price_ht') != '') + { + $ht = price2num(GETPOST('price_ht')); + } + + if (GETPOST('price_ttc') != '') + { + $reg = array(); + $vatratecleaned = $vat_rate; + if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) // If vat is "xx (yy)" + { + $vatratecleaned = trim($reg[1]); + $vatratecode = $reg[2]; + } + + $ttc = price2num(GETPOST('price_ttc')); + $ht = $ttc / (1 + ($vatratecleaned / 100)); + } + + $price_base_type = 'HT'; + $pu_ht_devise = GETPOST('multicurrency_subprice'); + + // Add buying price + $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : ''); + $buyingprice = (GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value + + // Extrafields Lines + $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); + $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); + // Unset extrafield POST Data + if (is_array($extralabelsline)) { + foreach ($extralabelsline as $key => $value) { + unset($_POST["options_".$key]); + } + } + + // Define special_code for special lines + $special_code = GETPOST('special_code'); + if (!GETPOST('qty')) $special_code = 3; + + // Check minimum price + $productid = GETPOST('productid', 'int'); + if (!empty($productid)) { + $productsupplier = new ProductFournisseur($db); + if (!empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) + { + if ($productid > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), $productid, 'none', GETPOST('socid', 'int')) < 0) + { + setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); + } + } + + $product = new Product($db); + $res = $product->fetch($productid); + + $type = $product->type; + + $price_min = $product->price_min; + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) + $price_min = $product->multiprices_min [$object->thirdparty->price_level]; + + $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); + } else { + $type = GETPOST('type'); + $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); + + // Check parameters + if (GETPOST('type') < 0) { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); + $error++; + } + } + + if (!$error) { + $db->begin(); + + $ref_supplier = GETPOST('fourn_ref', 'alpha'); + $fk_unit = GETPOST('units'); + + $result = $object->updateline( + GETPOST('lineid'), + $ht, + GETPOST('qty'), + GETPOST('remise_percent'), + $vat_rate, + $localtax1_rate, + $localtax2_rate, + $description, + $price_base_type, + $info_bits, + $special_code, + GETPOST('fk_parent_line'), + 0, + $fournprice, + $buyingprice, + $label, + $type, + $array_options, + $ref_supplier, + $fk_unit, + $pu_ht_devise + ); + + if ($result >= 0) { + $db->commit(); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + // Define output language + $outputlangs = $langs; + if (!empty($conf->global->MAIN_MULTILANGS)) { + $outputlangs = new Translate("", $conf); + $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret = $object->fetch($id); // Reload to get new records + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['productid']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['multicurrency_price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); @@ -943,166 +1014,3 @@ - } elseif ($action == 'updateline' && $usercancreate && GETPOST('save') == $langs->trans("Save")) { - // Update a line within proposal - $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); - - // Define info_bits - $info_bits = 0; - if (preg_match('/\*/', $vat_rate)) { - $info_bits |= 0x01; - } - - // Clean parameters - $description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml')); - - // Define vat_rate - $vat_rate = str_replace('*', '', $vat_rate); - $localtax1_rate = get_localtax($vat_rate, 1, $mysoc, $object->thirdparty); - $localtax2_rate = get_localtax($vat_rate, 2, $mysoc, $object->thirdparty); - - if (GETPOST('price_ht') != '') { - $price_base_type = 'HT'; - $ht = price2num(GETPOST('price_ht'), '', 2); - } else { - $reg = array(); - $vatratecleaned = $vat_rate; - if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) { // If vat is "xx (yy)" - $vatratecleaned = trim($reg[1]); - $vatratecode = $reg[2]; - } - - $ttc = price2num(GETPOST('price_ttc'), '', 2); - $ht = (float) $ttc / (1 + ((float) $vatratecleaned / 100)); - $price_base_type = 'HT'; - } - - $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), 'CU', 2); - - // Add buying price - $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : ''); - $buyingprice = (GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value - - // Extrafields Lines - $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); - // Unset extrafield POST Data - if (is_array($extralabelsline)) { - foreach ($extralabelsline as $key => $value) { - unset($_POST["options_".$key]); - } - } - - // Define special_code for special lines - $special_code = GETPOST('special_code'); - if (!GETPOST('qty')) { - $special_code = 3; - } - - // Check minimum price - $productid = GETPOST('productid', 'int'); - if (!empty($productid)) { - $productsupplier = new ProductFournisseur($db); - if (getDolGlobalString('SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY')) { - if ($productid > 0 && $productsupplier->get_buyprice(0, price2num(GETPOST('qty')), $productid, 'none', GETPOST('socid', 'int')) < 0) { - setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); - } - } - - $product = new Product($db); - $res = $product->fetch($productid); - - $type = $product->type; - - $price_min = $product->price_min; - if (getDolGlobalString('PRODUIT_MULTIPRICES') && !empty($object->thirdparty->price_level)) { - $price_min = $product->multiprices_min [$object->thirdparty->price_level]; - } - - $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); - } else { - $type = GETPOST('type'); - $label = (GETPOST('product_label') ? GETPOST('product_label') : ''); - - // Check parameters - if (GETPOST('type') < 0) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); - $error++; - } - } - - if (!$error) { - $db->begin(); - - $ref_supplier = GETPOST('fourn_ref', 'alpha'); - $fk_unit = GETPOST('units'); - - $result = $object->updateline( - GETPOST('lineid', 'int'), - $ht, - price2num(GETPOST('qty'), 'MS', 2), - price2num(GETPOST('remise_percent'), '', 2), - $vat_rate, - $localtax1_rate, - $localtax2_rate, - $description, - $price_base_type, - $info_bits, - $special_code, - GETPOST('fk_parent_line', 'int'), - 0, - $fournprice, - $buyingprice, - $label, - $type, - $array_options, - $ref_supplier, - $fk_unit, - $pu_ht_devise - ); - - if ($result >= 0) { - $db->commit(); - - if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { - // Define output language - $outputlangs = $langs; - if (getDolGlobalInt('MAIN_MULTILANGS')) { - $outputlangs = new Translate("", $conf); - $newlang = (GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $object->thirdparty->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret = $object->fetch($id); // Reload to get new records - $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['productid']); - unset($_POST['remise_percent']); - unset($_POST['price_ht']); - unset($_POST['multicurrency_price_ht']); - unset($_POST['price_ttc']); - unset($_POST['tva_tx']); - unset($_POST['product_ref']); - unset($_POST['product_label']); - unset($_POST['product_desc']); - unset($_POST['fournprice']); - unset($_POST['buying_price']); - - unset($_POST['date_starthour']); - unset($_POST['date_startmin']); - unset($_POST['date_startsec']); - unset($_POST['date_startday']); - unset($_POST['date_startmonth']); - unset($_POST['date_startyear']); - unset($_POST['date_endhour']); - unset($_POST['date_endmin']); - unset($_POST['date_endsec']); - unset($_POST['date_endday']); - unset($_POST['date_endmonth']); - unset($_POST['date_endyear']); - } else { - $db->rollback(); - - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } elseif ($action == 'updateline' && $usercancreate && GETPOST('cancel', 'alpha') == $langs->trans("Cancel")) { + } + + elseif ($action == 'updateline' && $user->rights->supplier_proposal->creer && GETPOST('cancel', 'alpha') == $langs->trans('Cancel')) { @@ -1111,2 +1019,4 @@ - } elseif ($action == 'classin' && $usercancreate) { - // Set project + } + + // Set project + elseif ($action == 'classin' && $user->rights->supplier_proposal->creer) { @@ -1114,5 +1024,9 @@ - } elseif ($action == 'setavailability' && $usercancreate) { - // Delivery delay - $result = $object->availability(GETPOST('availability_id')); - } elseif ($action == 'setconditions' && $usercancreate) { - // Terms of payments + } + + // Delivery delay + elseif ($action == 'setavailability' && $user->rights->supplier_proposal->creer) { + $result = $object->availability($_POST['availability_id']); + } + + // Terms of payments + elseif ($action == 'setconditions' && $user->rights->supplier_proposal->creer) { @@ -1120,6 +1034,12 @@ - //} elseif ($action == 'setremisepercent' && $usercancreate) { - // $result = $object->set_remise_percent($user, price2num(GETPOST('remise_percent'), '', 2)); - //} elseif ($action == 'setremiseabsolue' && $usercancreate) { - // $result = $object->set_remise_absolue($user, price2num(GETPOST('remise_absolue'), 'MU', 2)); - } elseif ($action == 'setmode' && $usercancreate) { - // Payment mode + } + + elseif ($action == 'setremisepercent' && $user->rights->supplier_proposal->creer) { + $result = $object->set_remise_percent($user, $_POST['remise_percent']); + } + + elseif ($action == 'setremiseabsolue' && $user->rights->supplier_proposal->creer) { + $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); + } + + // Payment mode + elseif ($action == 'setmode' && $user->rights->supplier_proposal->creer) { @@ -1127,2 +1047,4 @@ - } elseif ($action == 'setmulticurrencycode' && $usercancreate) { - // Multicurrency Code + } + + // Multicurrency Code + elseif ($action == 'setmulticurrencycode' && $user->rights->supplier_proposal->creer) { @@ -1130,5 +1052,9 @@ - } elseif ($action == 'setmulticurrencyrate' && $usercancreate) { - // Multicurrency rate - $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int')); - } elseif ($action == 'update_extras') { - $object->oldcopy = dol_clone($object, 2); + } + + // Multicurrency rate + elseif ($action == 'setmulticurrencyrate' && $user->rights->supplier_proposal->creer) { + $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx'))); + } + + elseif ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); @@ -1137,6 +1063,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) + { @@ -1144 +1069,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -1150,3 +1076 @@ - if ($error) { - $action = 'edit_extras'; - } + if ($error) $action = 'edit_extras'; @@ -1161,7 +1085 @@ -$title = $object->ref." - ".$langs->trans('Card'); -if ($action == 'create') { - $title = $langs->trans("SupplierProposalNew"); -} -$help_url = 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur'; - -llxHeader('', $title, $help_url); +llxHeader('', $langs->trans('CommRequests'), 'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur'); @@ -1174,3 +1092 @@ -if (isModEnabled('project')) { - $formproject = new FormProjets($db); -} +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } @@ -1181 +1097,2 @@ -if ($action == 'create') { +if ($action == 'create') +{ @@ -1184 +1101 @@ - print load_fiche_titre($langs->trans("SupplierProposalNew"), '', 'supplier_proposal'); + print load_fiche_titre($langs->trans("NewAskPrice"), '', 'supplier_proposal'); @@ -1187 +1104 @@ - if ($socid > 0) { + if ($socid > 0) @@ -1189 +1105,0 @@ - } @@ -1192,15 +1108,4 @@ - if (!empty($origin) && !empty($originid)) { - $element = $subelement = GETPOST('origin'); - if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin'), $regs)) { - $element = $regs[1]; - $subelement = $regs[2]; - } - - // For compatibility - if ($element == 'order' || $element == 'commande') { - $element = $subelement = 'commande'; - } - if ($element == 'propal') { - $element = 'comm/propal'; - $subelement = 'propal'; - } + if (!empty($origin) && !empty($originid)) + { + $element = 'supplier_proposal'; + $subelement = 'supplier_proposal'; @@ -1213 +1118,2 @@ - if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) { + if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) + { @@ -1222,0 +1129,2 @@ + $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)); @@ -1228,9 +1136,8 @@ - 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; - } - } - } else { + 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; + } + } + else + { @@ -1239,3 +1146 @@ - if (isModEnabled("multicurrency") && !empty($soc->multicurrency_code)) { - $currency_code = $soc->multicurrency_code; - } + if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; @@ -1253,8 +1158,119 @@ - print ''; - - print dol_get_fiche_head(); - - // Call Hook tabContentCreateSupplierProposal - $parameters = array(); - // Note that $action and $object may be modified by hook - $reshook = $hookmanager->executeHooks('tabContentCreateSupplierProposal', $parameters, $object, $action); + + dol_fiche_head(); + + print ''; + + // Reference + print ''; + + // Third party + print ''; + print ''; + if ($socid > 0) { + print ''; + } else { + print ''; + } + print ''."\n"; + + if ($soc->id > 0) + { + // Discounts for third party + print ''; + } + + // Terms of payment + print ''; + + // Mode of payment + print ''; + + // Bank Account + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) { + print ''; + } + + // Shipping Method + if (!empty($conf->expedition->enabled)) { + print ''; + } + + // Delivery date (or manufacturing) + print ''; + print ''; + + + // Model + print ''; + print ''; + print '"; + + // Project + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + + $formproject = new FormProjets($db); + + if ($origin == 'project') $projectid = ($originid ? $originid : 0); + + print ''; + print ''; + print ''; + } + + // Multicurrency + if (!empty($conf->multicurrency->enabled)) { + print ''; + print ''; + print ''; + } + + // Other attributes + $parameters = array('colspan' => ' colspan="3"', 'cols' => 3); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; @@ -1262,6 +1278,59 @@ - print '
'.$langs->trans('Ref').''.$langs->trans("Draft").'
'.$langs->trans('Supplier').''; + print $soc->getNomUrl(1); + print ''; + print ''; + print $form->select_company('', 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); + print ' '; + print '
'.$langs->trans('Discounts').''; + + $absolute_discount = $soc->getAvailableDiscounts('', '', 0, 1); + + $thirdparty = $soc; + $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('PaymentConditionsShort').''; + $form->select_conditions_paiements(GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $cond_reglement_id, 'cond_reglement_id', -1, 1); + print '
'.$langs->trans('PaymentMode').''; + $form->select_types_paiements(GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $mode_reglement_id, 'mode_reglement_id'); + print '
'.$langs->trans('BankAccount').''; + $form->select_comptes(GETPOST('fk_account') > 0 ? GETPOST('fk_account', 'int') : $fk_account, 'fk_account', 0, '', 1); + print '
'.$langs->trans('SendingMethod').''; + print $form->selectShippingMethod(GETPOST('shipping_method_id') > 0 ? GETPOST('shipping_method_id', 'int') : $shipping_method_id, 'shipping_method_id', '', 1); + print '
'.$langs->trans("DeliveryDate").''; + $datedelivery = dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); + if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") { + $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); + $syear = date("Y", $tmpdte); + $smonth = date("m", $tmpdte); + $sday = date("d", $tmpdte); + print $form->selectDate($syear."-".$smonth."-".$sday, 'liv_', '', '', '', "addask"); + } else { + print $form->selectDate($datedelivery ? $datedelivery : -1, 'liv_', '', '', '', "addask", 1, 1); + } + print '
'.$langs->trans("DefaultModel").''; + $liste = ModelePDFSupplierProposal::liste_modeles($db); + print $form->selectarray('model', $liste, ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT : $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF)); + print "
'.$langs->trans("Project").''; + + $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500'); + print '   id).'">'; + + print '
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; + print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); + print '
'; - - // Reference - print ''; - - // Third party + print $object->showOptionals($extrafields, 'edit', $parameters); + } + + + // Lines from source + if (!empty($origin) && !empty($originid) && is_object($objectsrc)) + { + // TODO for compatibility + if ($origin == 'contrat') { + // Calcul contrat->price (HT), contrat->total (TTC), contrat->tva + $objectsrc->remise_absolue = $remise_absolue; + $objectsrc->remise_percent = $remise_percent; + $objectsrc->update_price(1, - 1, 1); + } + + print "\n"; + print "\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''; + print ''; + + print ''; + print ''; + print '"; + if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 + { + print '"; + } + + if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 + { + print '"; + } + print '"; + + if (!empty($conf->multicurrency->enabled)) + { + print ''; + print '"; + print '"; + } + } + + print "
'.$langs->trans('Ref').''.$langs->trans("Draft").'
'.$langs->trans('CommRequest').''.$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)."
\n"; + + + /* + * Combobox pour la fonction de copie + */ + + if (empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) print ''; + + if (!empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) + { + print '
'; + + // For backward compatibility @@ -1269,6 +1338,25 @@ - print ''; - if ($socid > 0) { - print ''; + print ''; + print ''; + print ''; - } - print ''."\n"; - - if ($soc->id > 0) { - // Discounts for third party - print ''; - } - - // Terms of payment - print ''; - - // Bank Account - if (getDolGlobalString('BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') && isModEnabled("banque")) { - print ''; - } - - // Shipping Method - if (isModEnabled("expedition")) { - print ''; - } - - // Delivery date (or manufacturing) - print ''; - print ''; - - - // Model - print ''; - print ''; - print '"; - - // Project - if (isModEnabled('project')) { - $langs->load("projects"); - - $formproject = new FormProjets($db); - - if ($origin == 'project') { - $projectid = ($originid ? $originid : 0); - } - - print ''; - print ''; - print ''; - } - - // Multicurrency - if (isModEnabled("multicurrency")) { - print ''; - print ''; - print ''; - } - - // Other attributes - $parameters = array('colspan' => ' colspan="3"', 'cols' => 3); - $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', $parameters); - } - - - // Lines from source - if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { - // TODO for compatibility - if ($origin == 'contrat') { - // Calcul contrat->price (HT), contrat->total (TTC), contrat->tva - //$objectsrc->remise_absolue = $remise_absolue; - //$objectsrc->remise_percent = $remise_percent; - $objectsrc->update_price(1, 'auto', 1); - } - - print "\n"; - print "\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''; - print ''; - - print ''; - print ''; - print '"; - if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) { // Localtax1 - print '"; - } - - if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) { // Localtax2 - print '"; - } - print '"; - - if (isModEnabled("multicurrency")) { - print ''; - print '"; - print '"; - } - } - - print "
'.$langs->trans('Supplier').''; - print $soc->getNomUrl(1, 'supplier'); - print ''; - print ''.$langs->trans("CopyAskFrom").' '; + $liste_ask = array(); + $liste_ask [0] = ''; + + $sql = "SELECT p.rowid as id, p.ref, s.nom"; + $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal p"; + $sql .= ", ".MAIN_DB_PREFIX."societe s"; + $sql .= " WHERE s.rowid = p.fk_soc"; + $sql .= " AND p.entity = ".$conf->entity; + $sql .= " AND p.fk_statut <> ".SupplierProposal::STATUS_DRAFT; + $sql .= " ORDER BY Id"; + + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $row = $db->fetch_row($resql); + $askPriceSupplierRefAndSocName = $row [1]." - ".$row [2]; + $liste_ask [$row [0]] = $askPriceSupplierRefAndSocName; + $i++; + } + print $form->selectarray("copie_supplier_proposal", $liste_ask, 0); @@ -1276,39 +1364,2 @@ - print ''; - $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')) { - print ''; - } - print ' '; - print '
'.$langs->trans('Discounts').''; - - $absolute_discount = $soc->getAvailableDiscounts('', '', 0, 1); - - $thirdparty = $soc; - $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('PaymentConditionsShort').''; - print img_picto('', 'payment', 'class="pictofixedwidth"'); - print $form->getSelectConditionsPaiements(GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $cond_reglement_id, 'cond_reglement_id', -1, 1); + dol_print_error($db); + } @@ -1317,181 +1368,13 @@ - // Mode of payment - print '
'.$langs->trans('PaymentMode').''; - print img_picto('', 'bank', 'class="pictofixedwidth"'); - $form->select_types_paiements(GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $mode_reglement_id, 'mode_reglement_id'); - print '
'.$langs->trans('BankAccount').''; - $form->select_comptes(GETPOST('fk_account') > 0 ? GETPOST('fk_account', 'int') : $fk_account, 'fk_account', 0, '', 1); - print '
'.$langs->trans('SendingMethod').''; - print img_picto('', 'dolly', 'class="pictofixedwidth"'); - $form->selectShippingMethod(GETPOST('shipping_method_id') > 0 ? GETPOST('shipping_method_id', 'int') : "", 'shipping_method_id', '', 1); - print '
'.$langs->trans("DeliveryDate").''; - print img_picto('', 'action', 'class="pictofixedwidth"'); - $datedelivery = dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); - if (is_numeric(getDolGlobalString('DATE_LIVRAISON_WEEK_DELAY'))) { // If value set to 0 or a num, not empty - $tmpdte = time() + (7 * getDolGlobalInt('DATE_LIVRAISON_WEEK_DELAY') * 24 * 60 * 60); - $syear = date("Y", $tmpdte); - $smonth = date("m", $tmpdte); - $sday = date("d", $tmpdte); - print $form->selectDate($syear."-".$smonth."-".$sday, 'liv_', '', '', '', "addask"); - } else { - print $form->selectDate($datedelivery ? $datedelivery : -1, 'liv_', '', '', '', "addask", 1, 1); - } - print '
'.$langs->trans("DefaultModel").''; - print img_picto('', 'pdf', 'class="pictofixedwidth"'); - $list = ModelePDFSupplierProposal::liste_modeles($db); - $preselected = (getDolGlobalString('SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT') ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT : $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF); - print $form->selectarray('model', $list, $preselected, 0, 0, 0, '', 0, 0, 0, '', '', 1); - print "
'.$langs->trans("Project").''; - print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); - print '   id).'">'; - - print '
'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; - print img_picto('', 'currency', 'class="pictofixedwidth"'); - print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); - print '
'.$langs->trans('CommRequest').''.$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)."
\n"; - - - /* - * Combobox for copy function - */ - - if (!getDolGlobalString('SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE')) { - print ''; - } - - if (getDolGlobalString('SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE')) { - print '
'; - - // For backward compatibility - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - } - - if (getDolGlobalString('SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE')) { - print '
'.$langs->trans("CopyAskFrom").' '; - $liste_ask = array(); - $liste_ask [0] = ''; - - $sql = "SELECT p.rowid as id, p.ref, s.nom"; - $sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal p"; - $sql .= ", ".MAIN_DB_PREFIX."societe s"; - $sql .= " WHERE s.rowid = p.fk_soc"; - $sql .= " AND p.entityy IN (".getEntity('supplier_proposal').")"; - $sql .= " AND p.fk_statut <> ".SupplierProposal::STATUS_DRAFT; - $sql .= " ORDER BY Id"; - - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) { - $row = $db->fetch_row($resql); - $askPriceSupplierRefAndSocName = $row[1]." - ".$row[2]; - $liste_ask[$row[0]] = $askPriceSupplierRefAndSocName; - $i++; - } - print $form->selectarray("copie_supplier_proposal", $liste_ask, 0); - } else { - dol_print_error($db); - } - print '
'.$langs->trans("CreateEmptyAsk").'
'; - } - } - - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel("CreateDraft"); + print ''; + print ''.$langs->trans("CreateEmptyAsk").''; + } + + if (!empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) print ''; + + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; @@ -1509 +1391,0 @@ - print '
'; @@ -1515 +1396,0 @@ - print '
'; @@ -1526 +1407 @@ - print dol_get_fiche_head($head, 'comm', $langs->trans('CommRequest'), -1, 'supplier_proposal'); + dol_fiche_head($head, 'comm', $langs->trans('CommRequest'), -1, 'supplier_proposal'); @@ -1532 +1412,0 @@ - $filter = '(s.fournisseur:=:1)'; @@ -1535,10 +1415,5 @@ - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => - // 1), - array( - 'type' => 'other', - 'name' => 'socid', - 'label' => $langs->trans("SelectThirdParty"), - 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', $filter)) - ); + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => + // 1), + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', 's.fournisseur=1'))); @@ -1547,2 +1422,4 @@ - } elseif ($action == 'delete') { - // Confirm delete + } + + // Confirm delete + elseif ($action == 'delete') { @@ -1550,2 +1427,4 @@ - } elseif ($action == 'reopen') { - // Confirm reopen + } + + // Confirm reopen + elseif ($action == 'reopen') { @@ -1553,2 +1432,4 @@ - } elseif ($action == 'ask_deleteline') { - // Confirmation delete product/service line + } + + // Confirmation delete product/service line + elseif ($action == 'ask_deleteline') { @@ -1556,2 +1437,4 @@ - } elseif ($action == 'validate') { - // Confirm validate askprice + } + + // Confirm validate askprice + elseif ($action == 'validate') { @@ -1573 +1456 @@ - if (isModEnabled('notification')) { + if (!empty($conf->notification->enabled)) { @@ -1580 +1463 @@ - if (!$error) { + if (!$error) @@ -1582 +1464,0 @@ - } @@ -1588,5 +1470,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; @@ -1604,2 +1483,2 @@ - //$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreateorder, 'string', '', 0, 1); - //$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreateorder, 'string', '', 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); @@ -1607,4 +1486,2 @@ - $morehtmlref .= $object->thirdparty->getNomUrl(1, 'supplier'); - if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherProposals").')'; - } + $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' ('.$langs->trans("OtherProposals").')'; @@ -1612 +1489,2 @@ - if (isModEnabled('project')) { + if (!empty($conf->projet->enabled)) + { @@ -1614,3 +1492,3 @@ - $morehtmlref .= '
'; - if ($usercancreate) { - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->supplier_proposal->creer) + { @@ -1618,3 +1496,13 @@ - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + $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); + } @@ -1625,4 +1513,5 @@ - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; @@ -1637,78 +1526,91 @@ - // Call Hook tabContentViewSupplierProposal - $parameters = array(); - // Note that $action and $object may be modified by hook - $reshook = $hookmanager->executeHooks('tabContentViewSupplierProposal', $parameters, $object, $action); - if (empty($reshook)) { - print '
'; - 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)%')"; - } - - print ''; - - // Payment term - print ''; - print ''; - - // Delivery date - $langs->load('deliveries'); - print ''; - print ''; - - // Payment mode + + print '
'; + print '
'; + print '
'; + + print '
'.$langs->trans('Discounts').''; - - $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount, 0, 1); - $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote, 0, 1); - $absolute_discount = price2num($absolute_discount, 'MT'); - $absolute_creditnote = price2num($absolute_creditnote, 'MT'); - - $thirdparty = $soc; - $discount_type = 1; - $backtopage = urlencode($_SERVER["PHP_SELF"].'?id='.$object->id); - include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; - - print '
'; - print ''; - if ($action != 'editconditions' && $object->statut != SupplierProposal::STATUS_NOTSIGNED) { - print ''; - } - print '
'; - print $langs->trans('PaymentConditionsShort'); - print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'), 1).'
'; - print '
'; - if ($action == 'editconditions') { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1); - } else { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none', 1); - } - print '
'; - print ''; - if ($action != 'editdate_livraison' && $object->statut == SupplierProposal::STATUS_VALIDATED) { - print ''; - } - print '
'; - print $langs->trans('DeliveryDate'); - print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryDate'), 1).'
'; - print '
'; - if ($action == 'editdate_livraison') { - print '
'; - print ''; - print ''; - print ''; - print $form->selectDate($object->delivery_date, 'liv_', '', '', '', "editdate_livraison"); - print ''; - print '
'; - } else { - print dol_print_date($object->delivery_date, 'daytext'); - } - 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)%')"; + } + + print ''; + + // Payment term + print ''; + print ''; + + // Delivery date + $langs->load('deliveries'); + print ''; + print ''; + + // Payment mode + print ''; + print ''; + + // Multicurrency + if (!empty($conf->multicurrency->enabled)) + { + // Multicurrency code @@ -1718 +1620 @@ - print $langs->trans('PaymentMode'); + print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); @@ -1720,3 +1622,2 @@ - if ($action != 'editmode' && $object->statut != SupplierProposal::STATUS_NOTSIGNED) { - print ''; - } + if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_VALIDATED) + print ''; @@ -1724,3 +1625,3 @@ - print ''; - } + if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_VALIDATED && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) + print ''; @@ -1744,3 +1644,6 @@ - print ''; - print ''; - } - } - - /* Not for supplier proposals - if ($soc->outstanding_limit) { - // Outstanding Bill - print ''; - print ''; - }*/ - - if (getDolGlobalString('BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') && isModEnabled("banque")) { - // Bank Account - print ''; - print ''; - } - - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - print '
'.$langs->trans('Discounts').''; + + $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount, 0, 1); + $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote, 0, 1); + $absolute_discount = price2num($absolute_discount, 'MT'); + $absolute_creditnote = price2num($absolute_creditnote, 'MT'); + + $thirdparty = $soc; + $discount_type = 1; + $backtopage = urlencode($_SERVER["PHP_SELF"].'?id='.$object->id); + include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; + + print '
'; + print ''; + if ($action != 'editconditions' && $object->statut != SupplierProposal::STATUS_NOTSIGNED) + print ''; + print '
'; + print $langs->trans('PaymentConditionsShort'); + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'), 1).'
'; + print '
'; + if ($action == 'editconditions') { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1); + } else { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none', 1); + } + print '
'; + print ''; + if ($action != 'editdate_livraison' && $object->statut == SupplierProposal::STATUS_VALIDATED) + print ''; + print '
'; + print $langs->trans('DeliveryDate'); + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryDate'), 1).'
'; + print '
'; + if ($action == 'editdate_livraison') { + print '
'; + print ''; + print ''; + print $form->selectDate($object->date_livraison, 'liv_', '', '', '', "editdate_livraison"); + print ''; + print '
'; + } else { + print dol_print_date($object->date_livraison, 'daytext'); + } + print '
'; + print ''; + if ($action != 'editmode' && $object->statut != SupplierProposal::STATUS_NOTSIGNED) + print ''; + print '
'; + print $langs->trans('PaymentMode'); + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('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 '
id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'), 1).'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).''; - if ($action == 'editmode') { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'DBIT', 1, 1); + print ''; + if ($action == 'editmulticurrencycode') { + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); @@ -1728 +1629 @@ - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); + $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'none'); @@ -1732,3 +1633,3 @@ - // Multicurrency - if (isModEnabled("multicurrency")) { - // Multicurrency code + // Multicurrency rate + if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) + { @@ -1738 +1639 @@ - print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); + print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); @@ -1740,3 +1641,2 @@ - if ($action != 'editmulticurrencycode' && $object->statut == $object::STATUS_VALIDATED) { - print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).''; - if ($action == 'editmulticurrencycode') { - $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code'); + 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); @@ -1748 +1651,6 @@ - $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'none'); + $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 '
'; + } @@ -1751,82 +1659,14 @@ - - // Multicurrency rate - if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) { - print '
'; - print ''; - if ($action != 'editmulticurrencyrate' && $object->statut == $object::STATUS_VALIDATED && $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 $langs->trans('OutstandingBill'); - print ''; - $arrayoutstandingbills = $soc->getOutstandingBills('supplier'); - $outstandingBills = $arrayoutstandingbills['opened']; - print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency); - print '
'; - print ''; - if ($action != 'editbankaccount' && $usercancreate) { - print ''; - } - print '
'; - print $langs->trans('BankAccount'); - 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 '
'; - - print '
'; - print '
'; - print '
'; - - print ''; - - print ''; - // Amount HT - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - // Multicurrency Amount HT - print ''; - } + } + } + + /* Not for supplier proposals + if ($soc->outstanding_limit) + { + // Outstanding Bill + print ''; @@ -1834,9 +1674,19 @@ - - print ''; - // Amount VAT - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - // Multicurrency Amount VAT - print ''; - } + }*/ + + if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) + { + // Bank Account + print ''; @@ -1844,30 +1694,20 @@ - - // 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 ''; - } - } - - print ''; - // Amount TTC - print ''; - print ''; - if (isModEnabled("multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) { - // Multicurrency Amount TTC - print ''; - } + } + + // Other attributes + $cols = 2; + 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 $langs->trans('OutstandingBill'); + print ''; + $arrayoutstandingbills = $soc->getOutstandingBills('supplier'); + $outstandingBills = $arrayoutstandingbills['opened']; + print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency); + print '
' . $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) . '
'; + print ''; + if ($action != 'editbankaccount' && $user->rights->supplier_proposal->creer) + print ''; + print '
'; + print $langs->trans('BankAccount'); + 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->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) . '' . price($object->multicurrency_total_ttc, '', $langs, 0, -1, -1, $object->multicurrency_code) . '
'; + + print '
'; + print '
'; + print '
'; + print '
'; + + print ''; + + if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) + { + // Multicurrency Amount HT + print ''; + print ''; @@ -1876,84 +1716,116 @@ - 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)).'
'; - - // 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 - */ - - // Show object lines - $result = $object->getLinesArray(); - - print '
- - - - - - '; - - if (!empty($conf->use_javascript_ajax) && $object->statut == SupplierProposal::STATUS_DRAFT) { - 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. - if (getDolGlobalString('SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY')) { - $senderissupplier = 1; - } - - if (!empty($object->lines)) { - $object->printObjectLines($action, $soc, $mysoc, $lineid, $dateSelector); - } - - // Form to add new line - if ($object->statut == SupplierProposal::STATUS_DRAFT && $usercancreate) { - if ($action != 'editline') { - // Add products/services form - - $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($dateSelector, $soc, $mysoc); - } - } - } - - print '
'; - print '
'; - print "
\n"; - } - - print dol_get_fiche_end(); - - if ($action == 'statut') { + // Multicurrency Amount VAT + print ''.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).''; + print ''.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; + print ''; + + // Multicurrency Amount TTC + print ''.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).''; + print ''.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).''; + print ''; + } + + // Amount HT + print ''.$langs->trans('AmountHT').''; + print ''.price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency).''; + print ''; + + // Amount VAT + print ''.$langs->trans('AmountVAT').''; + print ''.price($object->total_tva, '', $langs, 0, - 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, 0, - 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, 0, - 1, - 1, $conf->currency).''; + print ''; + } + + // Amount TTC + print ''.$langs->trans('AmountTTC').''; + print ''.price($object->total_ttc, '', $langs, 0, - 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 + */ + + // Show object lines + $result = $object->getLinesArray(); + + print '
+ + + + + '; + + if (!empty($conf->use_javascript_ajax) && $object->statut == SupplierProposal::STATUS_DRAFT) { + 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. + if (!empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier = 1; + + if (!empty($object->lines)) + $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, $dateSelector); + + // Form to add new line + if ($object->statut == SupplierProposal::STATUS_DRAFT && $user->rights->supplier_proposal->creer) + { + if ($action != 'editline') + { + // Add products/services form + $object->formAddObjectLine($dateSelector, $soc, $mysoc); + + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + } + } + + print '
'; + print '
'; + print "
\n"; + + dol_fiche_end(); + + if ($action == 'statut') + { @@ -1961 +1833 @@ - $form_close = '
'; + $form_close = ''; @@ -1965,5 +1837,3 @@ - if (getDolGlobalString('SUPPLIER_PROPOSAL_UPDATE_PRICE_ON_SUPPlIER_PROPOSAL')) { - $form_close .= '

'.$langs->trans('SupplierProposalRefFournNotice').'

'; // TODO Suggest a permanent checkbox instead of option - } - $form_close .= ''; - $form_close .= '
'.$langs->trans("CloseAs").''; + if (!empty($conf->global->SUPPLIER_PROPOSAL_UPDATE_PRICE_ON_SUPPlIER_PROPOSAL)) $form_close .= '

'.$langs->trans('SupplierProposalRefFournNotice').'

'; // TODO Suggest a permanent checkbox instead of option + $form_close .= ''; + $form_close .= '
'.$langs->trans("CloseAs").''; @@ -1976,2 +1846,2 @@ - $form_close .= '
'.$langs->trans('Note').'