41require
'../main.inc.php';
42require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_proposal/modules_supplier_proposal.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/supplier_proposal.lib.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
53 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
67$langs->loadLangs(array(
'companies',
'supplier_proposal',
'compta',
'bills',
'propal',
'orders',
'products',
'sendings'));
69 $langs->load(
'margins');
77$action =
GETPOST(
'action',
'aZ09');
78$cancel =
GETPOST(
'cancel',
'alpha');
79$backtopage =
GETPOST(
'backtopage',
'alpha');
80$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
82$origin =
GETPOST(
'origin',
'alpha');
84$confirm =
GETPOST(
'confirm',
'alpha');
99$hookmanager->initHooks(array(
'supplier_proposalcard',
'globalcard'));
108$extrafields->fetch_name_optionals_label(
$object->table_element);
111if ($id > 0 || !empty($ref)) {
112 $ret =
$object->fetch($id, $ref);
114 $ret =
$object->fetch_thirdparty();
123$usercanread = $user->hasRight(
'supplier_proposal',
'lire');
124$usercancreate = $user->hasRight(
'supplier_proposal',
'creer');
125$usercandelete = $user->hasRight(
'supplier_proposal',
'supprimer');
128$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'supplier_proposal',
'validate_advance')));
129$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'supplier_proposal',
'send_advance'));
132$usercanclose = $user->hasRight(
'supplier_proposal',
'cloturer');
133$usercancreateorder = ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'));
136$permissionnote = $usercancreate;
137$permissiondellink = $usercancreate;
138$permissiontoedit = $usercancreate;
139$permissiontoadd = $usercancreate;
140$permissiontoeditextra = $permissiontoadd;
141if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
143 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
147if (!empty($user->socid)) {
148 $socid = $user->socid;
157$parameters = array(
'socid' => $socid);
158$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
160 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
166if (empty($reshook)) {
167 $backurlforlist = DOL_URL_ROOT.
'/supplier_proposal/list.php';
169 if (empty($backtopage) || ($cancel && empty($id))) {
170 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
171 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
172 $backtopage = $backurlforlist;
174 $backtopage = DOL_URL_ROOT.
'/supplier_proposal/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
179 if ($cancel && !($action ==
'updateline' && $usercancreate)) {
180 if (!empty($backtopageforcancel)) {
181 header(
"Location: ".$backtopageforcancel);
183 } elseif (!empty($backtopage)) {
184 header(
"Location: ".$backtopage);
190 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
192 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
194 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
197 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
198 if (
false && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
199 setEventMessages($langs->trans(
"NoCloneOptionsSpecified"),
null,
'errors');
202 $result =
$object->createFromClone($user, $socid);
204 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
212 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
215 $result =
$object->delete($user);
217 header(
'Location: '.DOL_URL_ROOT.
'/supplier_proposal/list.php');
220 $langs->load(
"errors");
221 setEventMessages($langs->trans(
$object->error),
null,
'errors');
223 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
225 $result =
$object->deleteLine($lineid);
230 $langs->load(
"errors");
236 $outputlangs = $langs;
239 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
240 $outputlangs->setDefaultLang($newlang);
246 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
249 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
251 } elseif ($action ==
'confirm_delete_subtotalline' && $confirm ==
'yes' && $usercancreate) {
256 $result =
$object->deleteSubtotalLine($langs,
GETPOSTINT(
'lineid'), (
bool)
GETPOST(
'deletecorrespondingsubtotalline'));
261 $outputlangs = $langs;
267 $newlang =
$object->thirdparty->default_lang;
269 if (!empty($newlang)) {
271 $outputlangs->setDefaultLang($newlang);
272 $outputlangs->load(
'products');
276 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
279 header(
'Location: '.
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' => $id]));
286 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
288 $result =
$object->valid($user);
291 $outputlangs = $langs;
294 $newlang =
GETPOST(
'lang_id',
'aZ09');
297 $newlang =
$object->thirdparty->default_lang;
299 if (!empty($newlang)) {
301 $outputlangs->setDefaultLang($newlang);
309 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
312 $langs->load(
"errors");
313 if (count(
$object->errors) > 0) {
316 setEventMessages($langs->trans(
$object->error),
null,
'errors');
319 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
322 dol_print_error($db,
$object->error);
324 } elseif ($action ==
'add' && $usercancreate) {
332 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Supplier")),
null,
'errors');
343 if (
GETPOST(
'createmode') ==
'copy' &&
GETPOSTINT(
'copie_supplier_proposal') > 0) {
346 $object->delivery_date = $date_delivery;
354 $object->model_pdf = $model_pdf;
356 $object->user_creation_id = $user->id;
362 setEventMessages($langs->trans(
"ErrorFailedToCopyProposal",
GETPOST(
'copie_supplier_proposal')),
null,
'errors');
366 $object->delivery_date = $date_delivery;
374 $object->model_pdf = $model_pdf;
376 $object->user_creation_id = $user->id;
385 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
389 $ret = $extrafields->setOptionalsFromPost(
null, $object);
397 if ($origin && $originid) {
399 $object->origin_type = $origin;
400 $object->origin_id = $originid;
405 $object->linked_objects = array_merge(
$object->linked_objects,
GETPOST(
'other_linked_objects',
'array:int'));
410 dol_syslog(
"Try to find source object origin=".
$object->origin_type.
" originid=".
$object->origin_id.
" to add lines");
413 $srcobject = fetchObjectByElement(
$object->origin_id, $origin);
415 if (is_object($srcobject) && $srcobject->id > 0) {
416 '@phan-var-force Commande|Propal|Contrat|Fichinter|Expedition $srcobject';
417 $lines = $srcobject->lines;
418 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
419 $srcobject->fetch_lines();
420 $lines = $srcobject->lines;
424 $num = count($lines);
425 for ($i = 0; $i < $num; $i++) {
426 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
427 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc :
'');
430 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
433 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
438 if (method_exists($lines[$i],
'fetch_optionals')) {
439 $lines[$i]->fetch_optionals();
440 $array_options = $lines[$i]->array_options;
442 $array_options = array();
447 $line_price_base_type = $lines[$i]->getPriceBaseType();
450 $lines[$i]->subprice,
453 $lines[$i]->localtax1_tx,
454 $lines[$i]->localtax2_tx,
455 $lines[$i]->fk_product,
456 $lines[$i]->remise_percent,
457 $line_price_base_type,
458 (
float) $lines[$i]->subprice_ttc,
459 $lines[$i]->info_bits,
462 $lines[$i]->special_code,
464 $lines[$i]->fk_fournprice,
468 $lines[$i]->ref_supplier,
481 if ($result > 0 && $lines[$i]->product_type == 9) {
482 $fk_parent_line = $result;
487 $parameters = array(
'objFrom' => $srcobject);
488 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $object, $action);
491 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
495 if (is_object($srcobject) && !empty($srcobject->error)) {
496 setEventMessages($srcobject->error, $srcobject->errors,
'errors');
498 $langs->load(
"errors");
499 setEventMessages($langs->trans(
"ErrorRecordNotFound"),
null,
'errors');
514 $categories =
GETPOST(
'categories',
'array');
515 $object->setCategories($categories);
522 $outputlangs = $langs;
525 $newlang =
GETPOST(
'lang_id',
'aZ09');
528 $newlang =
$object->thirdparty->default_lang;
530 if (!empty($newlang)) {
532 $outputlangs->setDefaultLang($newlang);
536 if (!empty($model)) {
538 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
545 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
558 } elseif ($action ==
'confirm_reopen' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
564 } elseif ($action ==
'close' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
570 } elseif ($action ==
'setstatut' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
573 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"CloseAs")),
null,
'errors');
581 } elseif ($action ==
'addline' &&
GETPOST(
'updateallvatlinesblock',
'alpha') &&
GETPOST(
'vatforblocklines',
'alpha') !==
'' && $usercancreate) {
582 $tx_tva =
GETPOST(
'vatforblocklines') ?
GETPOST(
'vatforblocklines') : 0;
583 $object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'tva', $tx_tva);
584 } elseif ($action ==
'addline' &&
GETPOST(
'updatealldiscountlinesblock',
'alpha') &&
GETPOST(
'discountforblocklines',
'alpha') !==
'' && $usercancreate) {
585 $discount =
GETPOST(
'discountforblocklines') ?
GETPOST(
'discountforblocklines') : 0;
586 $object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'discount', $discount);
587 } elseif ($action ==
'settags' &&
isModEnabled(
'category') && $usercancreate) {
592 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
595 $triggersendname =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
596 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
597 $trackid =
'spro'.$object->id;
598 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
601 $upload_dir =
$conf->supplier_proposal->dir_output;
602 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
605 if ($action ==
'modif' && $usercancreate) {
610 $outputlangs = $langs;
613 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
614 $outputlangs->setDefaultLang($newlang);
620 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
622 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
634 if ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') && $usercancreate) {
636 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
637 $vat_rate = str_replace(
'*',
'', $vat_rate);
640 foreach (
$object->lines as $line) {
641 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
645 $line_price_base_type = $line->getPriceBaseType();
646 $line_pu = ($line_price_base_type ===
'TTC') ? (
float) $line->subprice_ttc : (float) $line->subprice;
649 $line_pu_devise = ($line_price_base_type ===
'TTC') ? 0 : (float) $line->multicurrency_subprice;
650 $result =
$object->updateline($line->id, $line_pu, $line->qty, (
float) $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, $line_price_base_type, $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->ref_fourn, $line->fk_unit, $line_pu_devise);
652 } elseif ($action ==
'confirm_addtextline' && $usercancreate) {
655 $langs->load(
'subtotals');
657 $desc =
GETPOST(
'subtotaltextcontent',
'restricthtml');
660 $result =
$object->addSubtotalLine($langs, $desc, 0, array());
671 $outputlangs = $langs;
672 $newlang =
GETPOST(
'lang_id',
'alpha');
674 $newlang =
$object->thirdparty->default_lang;
676 if (!empty($newlang)) {
678 $outputlangs->setDefaultLang($newlang);
681 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
686 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
688 } elseif ($action ==
'confirm_addtitleline' && $usercancreate) {
691 $langs->load(
'subtotals');
693 $desc =
GETPOST(
'subtotallinedesc',
'alphanohtml');
694 $depth =
GETPOSTINT(
'subtotallinelevel') ?? 1;
696 $subtotal_options = array();
698 foreach (SupplierProposal::$TITLE_OPTIONS as $option) {
699 $value =
GETPOST($option,
'alphanohtml');
701 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
706 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
717 $outputlangs = $langs;
718 $newlang =
GETPOST(
'lang_id',
'alpha');
720 $newlang =
$object->thirdparty->default_lang;
722 if (!empty($newlang)) {
724 $outputlangs->setDefaultLang($newlang);
727 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
732 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
734 } elseif ($action ==
'confirm_addsubtotalline' && $usercancreate) {
737 $langs->load(
'subtotals');
739 $choosen_line =
GETPOST(
'subtotaltitleline',
'alphanohtml');
740 foreach (
$object->lines as $line) {
741 if ($line->desc == $choosen_line && $line->special_code == SUBTOTALS_SPECIAL_CODE) {
743 $depth = -$line->qty;
747 $subtotal_options = array();
749 foreach (SupplierProposal::$SUBTOTAL_OPTIONS as $option) {
750 $value =
GETPOST($option,
'alphanohtml');
752 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
757 if (isset($desc) && isset($depth)) {
758 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
761 $object->errors[] = $langs->trans(
"CorrespondingTitleNotFound");
770 $outputlangs = $langs;
771 $newlang =
GETPOST(
'lang_id',
'alpha');
773 $newlang =
$object->thirdparty->default_lang;
775 if (!empty($newlang)) {
777 $outputlangs->setDefaultLang($newlang);
780 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
785 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
787 } elseif ($action ==
'addline' && $usercancreate) {
788 $langs->load(
'errors');
797 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
799 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
800 if ($prod_entry_mode ==
'free') {
816 if (empty($remise_percent)) {
821 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
822 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
824 if (is_array($extralabelsline)) {
826 foreach ($extralabelsline as $key => $value) {
827 unset($_POST[
"options_".$key]);
831 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
832 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
835 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
836 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
840 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' &&
GETPOST(
'multicurrency_price_ht') ===
'') {
841 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPrice")),
null,
'errors');
844 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($line_desc)) {
845 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Description")),
null,
'errors');
848 if (!$error && ($qty >= 0)) {
852 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
856 if ($prod_entry_mode !=
'free' && empty($error)) {
860 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
865 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
866 $idprod = (int) $reg[1];
867 $res = $productsupplier->fetch($idprod);
870 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
872 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
873 if ($productsupplier->fourn_socid != $socid) {
874 $productsupplier->ref_supplier =
'';
877 $fksoctosearch =
$object->thirdparty->id;
878 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
880 } elseif (
GETPOSTINT(
'idprodfournprice') > 0) {
883 $idprod = $productsupplier->get_buyprice(
GETPOSTINT(
'idprodfournprice'), $qtytosearch);
884 $res = $productsupplier->fetch($idprod);
888 $label = $productsupplier->label;
892 $outputlangs = $langs;
894 if (
GETPOST(
'lang_id',
'aZ09')) {
895 $newlang =
GETPOST(
'lang_id',
'aZ09');
897 if (empty($newlang)) {
898 $newlang =
$object->thirdparty->default_lang;
900 if (!empty($newlang)) {
902 $outputlangs->setDefaultLang($newlang);
904 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->
description;
906 $desc = $productsupplier->description;
909 if (!empty($productsupplier->desc_supplier) &&
getDolGlobalString(
'PRODUIT_FOURN_TEXTS')) {
910 $desc = $productsupplier->desc_supplier;
921 $ref_supplier = $productsupplier->ref_supplier;
926 $tmpidprodfournprice =
GETPOST(
'idprodfournprice',
'alpha');
927 if (is_numeric($tmpidprodfournprice) && (
int) $tmpidprodfournprice > 0) {
928 $tmpidprodfournprice = (int) $tmpidprodfournprice;
930 $tmpidprodfournprice = 0;
936 if (empty($tva_tx)) {
942 $type = $productsupplier->type;
943 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
944 $price_base_type =
'HT';
946 $pu_devise =
price2num($price_ht_devise,
'CU');
947 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
948 $price_base_type =
'TTC';
950 $pu_devise =
price2num($price_ttc_devise,
'CU');
952 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
953 if (empty(
$object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code !=
$object->multicurrency_code)) {
954 $pu = $productsupplier->fourn_pu;
957 $pu = $productsupplier->fourn_pu;
958 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
967 $fournprice = (is_numeric(
GETPOST(
'idprodfournprice',
'alpha')) ?
GETPOST(
'idprodfournprice',
'alpha') : -1);
972 ($price_base_type ==
'HT' ? $pu : 0),
977 $productsupplier->id,
980 ($price_base_type ==
'TTC' ? $pu : 0),
983 min($rank, count(
$object->lines) + 1),
991 $productsupplier->fk_unit,
1007 if ($idprod == -99 || $idprod == 0) {
1010 $langs->load(
"errors");
1011 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")).
' '.$langs->trans(
"or").
' '.$langs->trans(
"NoPriceDefinedForThisSupplier"),
null,
'errors');
1013 if ($idprod == -1) {
1016 $langs->load(
"errors");
1017 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
1019 } elseif ((
GETPOST(
'price_ht') !==
'' ||
GETPOST(
'price_ttc') !==
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') && empty($error)) {
1023 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1024 $tva_tx = str_replace(
'*',
'', $tva_tx);
1025 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1031 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
1040 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1041 $price_base_type =
'HT';
1044 $pu_ht_devise =
price2num($price_ht_devise,
'CU');
1046 $price_base_type =
'TTC';
1049 $pu_ht_devise =
price2num($price_ttc_devise,
'CU');
1077 (
float) $pu_ht_devise
1082 if (!$error && $result > 0) {
1089 $outputlangs = $langs;
1092 $newlang =
GETPOST(
'lang_id',
'aZ09');
1095 $newlang =
$object->thirdparty->default_lang;
1097 if (!empty($newlang)) {
1099 $outputlangs->setDefaultLang($newlang);
1107 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1113 unset($_POST[
'prod_entry_mode']);
1115 unset($_POST[
'qty']);
1116 unset($_POST[
'type']);
1117 unset($_POST[
'remise_percent']);
1118 unset($_POST[
'pu']);
1119 unset($_POST[
'price_ht']);
1120 unset($_POST[
'multicurrency_price_ht']);
1121 unset($_POST[
'price_ttc']);
1122 unset($_POST[
'fourn_ref']);
1123 unset($_POST[
'tva_tx']);
1124 unset($_POST[
'label']);
1125 unset($_POST[
'product_ref']);
1126 unset($_POST[
'product_label']);
1127 unset($_POST[
'product_desc']);
1128 unset($_POST[
'fournprice']);
1129 unset($_POST[
'buying_price']);
1130 unset($localtax1_tx);
1131 unset($localtax2_tx);
1132 unset($_POST[
'np_marginRate']);
1133 unset($_POST[
'np_markRate']);
1134 unset($_POST[
'dp_desc']);
1135 unset($_POST[
'idprodfournprice']);
1136 unset($_POST[
'units']);
1138 unset($_POST[
'idprod']);
1140 unset($_POST[
'date_starthour']);
1141 unset($_POST[
'date_startmin']);
1142 unset($_POST[
'date_startsec']);
1143 unset($_POST[
'date_startday']);
1144 unset($_POST[
'date_startmonth']);
1145 unset($_POST[
'date_startyear']);
1146 unset($_POST[
'date_endhour']);
1147 unset($_POST[
'date_endmin']);
1148 unset($_POST[
'date_endsec']);
1149 unset($_POST[
'date_endday']);
1150 unset($_POST[
'date_endmonth']);
1151 unset($_POST[
'date_endyear']);
1158 } elseif ($action ==
'updatetitleline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1161 $langs->load(
'subtotals');
1163 $desc =
GETPOST(
'line_desc',
'alphanohtml') ?? $langs->trans(
"Title");
1166 $subtotal_options = array();
1168 foreach (SupplierProposal::$TITLE_OPTIONS as $option) {
1169 $value =
GETPOST($option,
'alphanohtml');
1171 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1176 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1187 $outputlangs = $langs;
1188 $newlang =
GETPOST(
'lang_id',
'alpha');
1190 $newlang =
$object->thirdparty->default_lang;
1192 if (!empty($newlang)) {
1194 $outputlangs->setDefaultLang($newlang);
1197 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1202 } elseif ($action ==
'updatetextline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1205 $langs->load(
'subtotals');
1207 $desc =
GETPOST(
'line_desc',
'restricthtml');
1210 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, 0, array());
1221 $outputlangs = $langs;
1222 $newlang =
GETPOST(
'lang_id',
'alpha');
1224 $newlang =
$object->thirdparty->default_lang;
1226 if (!empty($newlang)) {
1228 $outputlangs->setDefaultLang($newlang);
1231 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1236 } elseif ($action ==
'updatesubtotalline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1239 $langs->load(
'subtotals');
1241 $desc =
GETPOST(
'line_desc',
'alphanohtml');
1244 $subtotal_options = array();
1246 foreach (SupplierProposal::$SUBTOTAL_OPTIONS as $option) {
1247 $value =
GETPOST($option,
'alphanohtml');
1249 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1254 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1262 $outputlangs = $langs;
1263 $newlang =
GETPOST(
'lang_id',
'alpha');
1265 $newlang =
$object->thirdparty->default_lang;
1267 if (!empty($newlang)) {
1269 $outputlangs->setDefaultLang($newlang);
1272 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1277 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save') == $langs->trans(
"Save")) {
1285 if (preg_match(
'/\*/', $vat_rate)) {
1293 $vat_rate = str_replace(
'*',
'', $vat_rate);
1304 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1305 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1307 if (is_array($extralabelsline)) {
1308 foreach ($extralabelsline as $key => $value) {
1309 unset($_POST[
"options_".$key]);
1314 $special_code =
GETPOST(
'special_code');
1323 $price_base_type =
'HT';
1324 if (empty($pu_ht) && !empty($pu_ttc)) {
1326 $price_base_type =
'TTC';
1327 } elseif (!empty($pu_ht) && !empty($pu_ttc)) {
1328 foreach (
$object->lines as $line_obj) {
1331 if ($line_obj->wasEnteredIncludingTax()) {
1333 $price_base_type =
'TTC';
1342 if (!empty($productid)) {
1344 if (
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY') == 1) {
1345 if ($productid > 0 && $productsupplier->get_buyprice(0, (
float)
price2num(
GETPOST(
'qty')), $productid,
'none',
GETPOSTINT(
'socid')) < 0) {
1346 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1351 $res = $product->fetch($productid);
1353 $type = $product->type;
1355 $price_min = $product->price_min;
1357 $price_min = $product->multiprices_min [
$object->thirdparty->price_level];
1363 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1367 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1375 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1380 if ($price_base_type ===
'TTC') {
1384 $result =
$object->updateline(
1405 (
float) $pu_ht_devise
1413 $outputlangs = $langs;
1416 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
1417 $outputlangs->setDefaultLang($newlang);
1420 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1423 unset($_POST[
'qty']);
1424 unset($_POST[
'type']);
1425 unset($_POST[
'productid']);
1426 unset($_POST[
'remise_percent']);
1427 unset($_POST[
'price_ht']);
1428 unset($_POST[
'multicurrency_price_ht']);
1429 unset($_POST[
'price_ttc']);
1430 unset($_POST[
'tva_tx']);
1431 unset($_POST[
'product_ref']);
1432 unset($_POST[
'product_label']);
1433 unset($_POST[
'product_desc']);
1434 unset($_POST[
'fournprice']);
1435 unset($_POST[
'buying_price']);
1437 unset($_POST[
'date_starthour']);
1438 unset($_POST[
'date_startmin']);
1439 unset($_POST[
'date_startsec']);
1440 unset($_POST[
'date_startday']);
1441 unset($_POST[
'date_startmonth']);
1442 unset($_POST[
'date_startyear']);
1443 unset($_POST[
'date_endhour']);
1444 unset($_POST[
'date_endmin']);
1445 unset($_POST[
'date_endsec']);
1446 unset($_POST[
'date_endday']);
1447 unset($_POST[
'date_endmonth']);
1448 unset($_POST[
'date_endyear']);
1455 } elseif ($action ==
'updateline' && $usercancreate && $cancel) {
1456 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
1458 } elseif ($action ==
'classin' && $usercancreate) {
1461 } elseif ($action ==
'setavailability' && $usercancreate) {
1464 } elseif ($action ==
'setconditions' && $usercancreate) {
1466 $sql =
"SELECT code ";
1467 $sql .=
"FROM " . $db->prefix() .
"c_payment_term";
1468 $sql .=
" WHERE rowid = " .
GETPOSTINT(
'cond_reglement_id');
1469 $result = $db->query($sql);
1471 $obj = $db->fetch_object($result);
1472 if ($obj->code ==
'DEP30PCTDEL') {
1479 } elseif ($action ==
'setmode' && $usercancreate) {
1482 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
1484 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
1485 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
1488 } elseif ($action ==
'update_extras' && $permissiontoeditextra) {
1491 $attribute_name =
GETPOST(
'attribute',
'aZ09');
1494 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
1500 $result =
$object->updateExtraField($attribute_name,
'PROPOSAL_SUPPLIER_MODIFY');
1508 $action =
'edit_extras';
1518$title =
$object->ref.
" - ".$langs->trans(
'Card');
1519if ($action ==
'create') {
1520 $title = $langs->trans(
"SupplierProposalNew");
1522$help_url =
'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur';
1524llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-supplierproposal page-card');
1526$form =
new Form($db);
1530$companystatic =
new Societe($db);
1538if ($action ==
'create') {
1539 $currency_code =
$conf->currency;
1541 print
load_fiche_titre($langs->trans(
"SupplierProposalNew"),
'',
'supplier_proposal');
1545 $res = $soc->fetch($socid);
1549 if (!empty($origin) && !empty($originid)) {
1551 $objectsrc = fetchObjectByElement($originid, $origin);
1553 if (is_object($objectsrc)) {
1554 '@phan-var-force Commande|Propal|CommandeFournisseur|SupplierProposal $objectsrc';
1556 $classname = get_class($objectsrc);
1558 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1559 $objectsrc->fetch_lines();
1561 $objectsrc->fetch_thirdparty();
1563 $projectid = (int) $objectsrc->fk_project;
1564 $soc = $objectsrc->thirdparty;
1566 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1567 $deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent : 0));
1568 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1569 $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
1572 $objectsrc->fetch_optionals();
1573 $object->array_options = $objectsrc->array_options;
1576 if (!empty($objectsrc->multicurrency_code)) {
1577 $currency_code = $objectsrc->multicurrency_code;
1579 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
1580 $currency_tx = $objectsrc->multicurrency_tx;
1585 $cond_reglement_id = (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0);
1586 $deposit_percent = (!empty($soc->deposit_percent) ? $soc->deposit_percent : 0);
1587 $mode_reglement_id = (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0);
1588 $fk_account = (!empty($soc->fk_account) ? $soc->fk_account : 0);
1591 $cond_reglement_id = $soc->cond_reglement_supplier_id;
1592 $deposit_percent = !empty($soc->deposit_percent) ? $soc->deposit_percent : 0;
1593 $mode_reglement_id = $soc->mode_reglement_supplier_id;
1594 $fk_account = !empty($soc->fk_account) ? $soc->fk_account : 0;
1595 if (
isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
1596 $currency_code = $soc->multicurrency_code;
1599 if (
GETPOSTISSET(
'cond_reglement_id_deposit_percent')) {
1600 $deposit_percent =
GETPOSTFLOAT(
'cond_reglement_id_deposit_percent');
1605 print
'<form name="addprop" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1606 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1607 print
'<input type="hidden" name="action" value="add">';
1608 if ($origin !=
'project' && $originid) {
1609 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1610 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1612 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1617 $parameters = array();
1619 $reshook = $hookmanager->executeHooks(
'tabContentCreateSupplierProposal', $parameters, $object, $action);
1620 if (empty($reshook)) {
1621 print
'<table class="border centpercent">';
1624 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td colspan="2">'.$langs->trans(
"Draft").
'</td></tr>';
1628 print
'<td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
1630 print
'<td colspan="2">';
1631 print $soc->getNomUrl(1,
'supplier');
1632 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1635 print
'<td colspan="2">';
1636 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
1637 print img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company((empty($socid) ?
'' : $socid),
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1641 $(document).ready(function() {
1642 $("#socid").change(function() {
1643 console.log("We have changed the company - Reload page");
1645 $("input[name=action]").val("create");
1646 $("form[name=addprop]").submit();
1651 print
' <a href="'.DOL_URL_ROOT.
'/societe/card.php?action=create&client=0&fournisseur=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddThirdParty").
'"></span></a>';
1658 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
1660 $absolute_discount = $soc->getAvailableDiscounts(
null,
'', 0, 1);
1664 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
1665 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1671 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td colspan="2">';
1672 print img_picto(
'',
'payment',
'class="pictofixedwidth"');
1673 print $form->getSelectConditionsPaiements(
GETPOSTISSET(
'cond_reglement_id') ?
GETPOSTINT(
'cond_reglement_id') : $cond_reglement_id,
'cond_reglement_id', -1, 1, 0,
'', $deposit_percent);
1677 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td colspan="2">';
1678 print img_picto(
'',
'bank',
'class="pictofixedwidth"');
1679 $form->select_types_paiements(
GETPOST(
'mode_reglement_id') > 0 ?
GETPOST(
'mode_reglement_id') : $mode_reglement_id,
'mode_reglement_id');
1684 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td colspan="2">';
1685 print img_picto(
'',
'bank',
'class="pictofixedwidth"');
1686 $form->select_comptes(
GETPOST(
'fk_account') > 0 ?
GETPOSTINT(
'fk_account') : $fk_account,
'fk_account', 0,
'', 1);
1692 print
'<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td colspan="2">';
1693 print img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1694 $form->selectShippingMethod(
GETPOST(
'shipping_method_id') > 0 ?
GETPOSTINT(
'shipping_method_id') :
"",
'shipping_method_id',
'', 1);
1699 print
'<tr><td>'.$langs->trans(
"DeliveryDate").
'</td>';
1700 print
'<td colspan="2">';
1701 print img_picto(
'',
'action',
'class="pictofixedwidth"');
1708 print $form->selectDate($syear.
"-".$smonth.
"-".$sday,
'liv_', 0, 0, 0,
"addask");
1710 print $form->selectDate($datedelivery ? $datedelivery : -1,
'liv_', 0, 0, 0,
"addask", 1, 1);
1717 if (count($list) > 0) {
1719 print
'<td>'.$langs->trans(
"DefaultModel").
'</td>';
1720 print
'<td colspan="2">';
1721 print img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1723 print $form->selectarray(
'model', $list, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1729 $langs->load(
"projects");
1733 if ($origin ==
'project') {
1734 $projectid = ($originid ? $originid : 0);
1738 print
'<td>'.$langs->trans(
"Project").
'</td><td colspan="2">';
1739 if (!empty($user->socid)) {
1740 $projSocFilter = $user->socid;
1741 } elseif (
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') || $socid == 0) {
1744 $projSocFilter = -1;
1746 $projSocFilter = $socid;
1748 print img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects($projSocFilter, $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
1749 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.((int) $soc->id).
'&action=create&status=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create&socid='.$soc->id).
'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1757 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
1758 print
'<td colspan="3" class="maxwidthonsmartphone">';
1759 print img_picto(
'',
'currency',
'class="pictofixedwidth"');
1760 print $form->selectMultiCurrency($currency_code,
'multicurrency_code');
1765 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
1766 print $form->selectCategories(Categorie::TYPE_SUPPLIER_PROPOSAL,
'categories', $object);
1771 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' => 3);
1772 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1773 print $hookmanager->resPrint;
1774 if (empty($reshook)) {
1775 print
$object->showOptionals($extrafields,
'create', $parameters);
1780 if (!empty($origin) && !empty($originid) && is_object($objectsrc) && $classname !==
null) {
1782 if ($origin ==
'contrat') {
1784 $objectsrc->update_price(1,
'auto', 1);
1787 print
"\n<!-- ".$classname.
" info -->";
1789 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
1790 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
1791 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
1792 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
1793 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
1795 print
'<tr><td>'.$langs->trans(
'CommRequest').
'</td><td colspan="2">'.$objectsrc->getNomUrl(1).
'</td></tr>';
1796 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td colspan="2">'.
price($objectsrc->total_ht).
'</td></tr>';
1797 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td colspan="2">'.
price($objectsrc->total_tva).
"</td></tr>";
1798 if (
$mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
1799 print
'<tr><td>'.$langs->transcountry(
"AmountLT1",
$mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax1).
"</td></tr>";
1802 if (
$mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
1803 print
'<tr><td>'.$langs->transcountry(
"AmountLT2",
$mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax2).
"</td></tr>";
1805 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td colspan="2">'.
price($objectsrc->total_ttc).
"</td></tr>";
1808 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_ht, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
'</td></tr>';
1809 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_tva, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
"</td></tr>";
1810 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_ttc, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
"</td></tr>";
1822 print
'<input type="hidden" name="createmode" value="empty">';
1826 print
'<br><table>';
1830 print
'<td><input type="radio" name="createmode" value="copy"></td>';
1831 print
'<td>'.$langs->trans(
"CopyAskFrom").
' </td>';
1833 $liste_ask = array();
1834 $liste_ask [0] =
'';
1836 $sql =
"SELECT p.rowid as id, p.ref, s.nom";
1837 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal p";
1838 $sql .=
", ".MAIN_DB_PREFIX.
"societe s";
1839 $sql .=
" WHERE s.rowid = p.fk_soc";
1840 $sql .=
" AND p.entityy IN (".getEntity(
'supplier_proposal').
")";
1841 $sql .=
" AND p.fk_statut <> ".SupplierProposal::STATUS_DRAFT;
1842 $sql .=
" ORDER BY Id";
1844 $resql = $db->query($sql);
1846 $num = $db->num_rows($resql);
1849 $row = $db->fetch_row($resql);
1850 $askPriceSupplierRefAndSocName = $row[1].
" - ".$row[2];
1851 $liste_ask[$row[0]] = $askPriceSupplierRefAndSocName;
1854 print $form->selectarray(
"copie_supplier_proposal", $liste_ask, 0);
1856 dol_print_error($db);
1860 print
'<tr><td class="tdtop"><input type="radio" name="createmode" value="empty" checked></td>';
1861 print
'<td valign="top" colspan="2">'.$langs->trans(
"CreateEmptyAsk").
'</td></tr>';
1871 print $form->buttonsSaveCancel(
"CreateDraft");
1877 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1880 $title = $langs->trans(
'ProductsAndServices');
1883 print
'<div class="div-table-responsive-no-min">';
1884 print
'<table class="noborder centpercent">';
1886 $objectsrc->printOriginLinesList();
1900 print
dol_get_fiche_head($head,
'comm', $langs->trans(
'CommRequest'), -1,
'supplier_proposal', 0,
'',
'', 0,
'', 1);
1905 if ($action ==
'clone') {
1906 $filter =
'(s.fournisseur:=:1)';
1908 $formquestion = array(
1916 'label' => $langs->trans(
"SelectThirdParty"),
1917 'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter))
1920 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
1921 } elseif ($action ==
'delete') {
1923 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteAsk'), $langs->trans(
'ConfirmDeleteAsk',
$object->ref),
'confirm_delete',
'', 0, 1);
1924 } elseif ($action ==
'reopen') {
1926 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ReOpen'), $langs->trans(
'ConfirmReOpenAsk',
$object->ref),
'confirm_reopen',
'', 0, 1);
1927 } elseif ($action ==
'ask_deleteline') {
1929 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
1930 } elseif ($action ==
'ask_subtotal_deleteline') {
1932 $langs->load(
"subtotals");
1933 $title =
"DeleteSubtotalLine";
1934 $question =
"ConfirmDeleteSubtotalLine";
1935 if (
GETPOST(
'type') ==
'title') {
1938 'type' =>
'checkbox',
1939 'name' =>
'deletecorrespondingsubtotalline',
1940 'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
1944 $title =
"DeleteTitleLine";
1945 $question =
"ConfirmDeleteTitleLine";
1947 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
1948 } elseif ($action ==
'validate') {
1953 $ref = substr(
$object->ref, 1, 4);
1954 if ($ref ==
'PROV') {
1955 $numref =
$object->getNextNumRef($soc);
1956 if (empty($numref)) {
1961 $numref = (string)
$object->ref;
1964 $text = $langs->trans(
'ConfirmValidateAsk', $numref);
1966 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
1967 $notify =
new Notify($db);
1969 $text .= $notify->confirmMessage(
'PROPOSAL_SUPPLIER_VALIDATE',
$object->socid, $object);
1973 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateAsk'), $text,
'confirm_validate',
'', 0, 1);
1977 if ($action ==
'add_title_line') {
1978 $langs->load(
'subtotals');
1980 $depth_array =
$object->getPossibleLevels($langs);
1982 } elseif ($action ==
'add_subtotal_line') {
1983 $langs->load(
'subtotals');
1985 $titles =
$object->getPossibleTitles();
1987 } elseif ($action ==
'add_text_line') {
1988 $langs->load(
'subtotals');
1994 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
1995 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1996 if (empty($reshook)) {
1997 $formconfirm .= $hookmanager->resPrint;
1998 } elseif ($reshook > 0) {
1999 $formconfirm = $hookmanager->resPrint;
2007 $linkback =
'<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
2010 $morehtmlref =
'<div class="refidno">';
2015 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'supplier');
2017 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.
$object->thirdparty->id.
'">'.$langs->trans(
"OtherProposals").
'</a>)';
2021 $langs->load(
"projects");
2022 $morehtmlref .=
'<br>';
2023 if ($usercancreate) {
2024 $morehtmlref .= img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2025 if ($action !=
'classify') {
2026 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2029 $canLinkAll = ($canLinkAll ===
'' || $canLinkAll ===
false) ? 0 : $canLinkAll;
2031 $projectSocId = ((int) $canLinkAll == 1) ? -1 : $currentSocId;
2032 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $projectSocId,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2034 if (!empty(
$object->fk_project)) {
2036 $proj->fetch(
$object->fk_project);
2037 $morehtmlref .= $proj->getNomUrl(1);
2039 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2044 $morehtmlref .=
'</div>';
2047 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2050 $parameters = array();
2052 $reshook = $hookmanager->executeHooks(
'tabContentViewSupplierProposal', $parameters, $object, $action);
2053 if (empty($reshook)) {
2054 print
'<div class="fichecenter">';
2055 print
'<div class="fichehalfleft">';
2056 print
'<div class="underbanner clearboth"></div>';
2058 print
'<table class="border tableforfield centpercent">';
2062 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
2063 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
2065 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
2066 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
2069 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td>';
2071 $absolute_discount = $soc->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
2072 $absolute_creditnote = $soc->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
2073 $absolute_discount =
price2num($absolute_discount,
'MT');
2074 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
2078 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
2079 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2084 print
'<tr><td class="titlefield">';
2085 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2086 print $langs->trans(
'PaymentConditionsShort');
2089 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editconditions&token='.
newToken().
'&id='.
$object->id.
'">'.img_edit($langs->transnoentitiesnoconv(
'SetConditions'), 1).
'</a></td>';
2091 print
'</tr></table>';
2092 print
'</td><td class="valuefield">';
2093 if ($action ==
'editconditions') {
2094 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
2096 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'none', 1,
'', 1,
$object->deposit_percent);
2103 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2104 print $langs->trans(
'DeliveryDate');
2107 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editdate_livraison&token='.
newToken().
'&id='.
$object->id.
'">'.img_edit($langs->transnoentitiesnoconv(
'SetDeliveryDate'), 1).
'</a></td>';
2109 print
'</tr></table>';
2110 print
'</td><td class="valuefield">';
2111 if ($action ==
'editdate_livraison') {
2112 print
'<form name="editdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post" class="formconsumeproduce">';
2113 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2114 print
'<input type="hidden" name="action" value="setdate_livraison">';
2115 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2116 print $form->selectDate(
$object->delivery_date,
'liv_', 0, 0, 0,
"editdate_livraison");
2117 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2128 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2129 print $langs->trans(
'PaymentMode');
2132 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmode&token='.
newToken().
'&id='.
$object->id.
'">'.img_edit($langs->transnoentitiesnoconv(
'SetMode'), 1).
'</a></td>';
2134 print
'</tr></table>';
2135 print
'</td><td class="valuefield">';
2136 if ($action ==
'editmode') {
2137 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
2139 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
2159 print
'<table width="100%" class="nobordernopadding"><tr><td>';
2160 print $langs->trans(
'BankAccount');
2162 if ($action !=
'editbankaccount' && $usercancreate) {
2163 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editbankaccount&token='.
newToken().
'&id='.
$object->id.
'">'.img_edit($langs->trans(
'SetBankAccount'), 1).
'</a></td>';
2165 print
'</tr></table>';
2166 print
'</td><td class="valuefield">';
2167 if ($action ==
'editbankaccount') {
2168 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
2170 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'none');
2178 print
'<table class="nobordernopadding centpercent"><tr><td>';
2179 print $langs->trans(
"Categories");
2180 print
'<td><td class="right">';
2181 if ($usercancreate) {
2182 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/supplier_proposal/card.php?id='.
$object->id.
'&action=edittags&token='.
newToken().
'">'.img_edit().
'</a>';
2186 print
'</td></tr></table>';
2189 if ($action ==
'edittags') {
2190 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
2191 print
'<input type="hidden" name="action" value="settags">';
2192 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2193 print $form->selectCategories(Categorie::TYPE_SUPPLIER_PROPOSAL,
'categories', $object);
2194 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
2197 print $form->showCategories(
$object->id, Categorie::TYPE_SUPPLIER_PROPOSAL, 1);
2202 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2207 print
'<div class="fichehalfright">';
2208 print
'<div class="underbanner clearboth"></div>';
2210 print
'<table class="border tableforfield centpercent">';
2212 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
2216 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
2217 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2220 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2226 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
2227 print
'<td class="nowrap amountcard right">' .
price(
$object->total_tva, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2230 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2235 if (
$mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
2237 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1",
$mysoc->country_code) .
'</td>';
2238 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2240 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2244 if (
$mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
2246 print
'<td>' . $langs->transcountry(
"AmountLT2",
$mysoc->country_code) .
'</td>';
2247 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2249 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2257 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
2258 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2261 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2275 print
'<div class="clearboth"></div><br>';
2278 $blocname =
'contacts';
2279 $title = $langs->trans(
'ContactsAddresses');
2280 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2284 $blocname =
'notes';
2285 $title = $langs->trans(
'Notes');
2286 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2294 $result =
$object->getLinesArray();
2296 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'#add' :
'').
'" method="POST">
2297 <input type="hidden" name="token" value="' .
newToken().
'">
2298 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
2299 <input type="hidden" name="mode" value="">
2300 <input type="hidden" name="id" value="' .
$object->id.
'">
2306 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_ajaxrow.tpl.php';
2308 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
2312 print
'<div class="div-table-responsive-no-min">';
2313 print
'<table id="tablelines" class="noborder noshadow centpercent">';
2316 global $forceall, $senderissupplier, $inputalsopricewithtax;
2319 $inputalsopricewithtax = 1;
2320 $senderissupplier = 2;
2321 if (
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY')) {
2322 $senderissupplier =
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY');
2326 $object->printObjectLines($action, $soc,
$mysoc, $lineid, $dateSelector);
2331 if ($action !=
'editline') {
2334 $parameters = array(
'dateSelector' => $dateSelector);
2335 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
2337 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
2339 if (empty($reshook)) {
2352 if ($action ==
'statut') {
2354 $form_close =
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST" id="formacceptrefuse" class="formconsumeproduce paddingbottom paddingleft paddingright">';
2355 $form_close .=
'<input type="hidden" name="token" value="'.newToken().
'">';
2356 $form_close .=
'<input type="hidden" name="action" value="setstatut">';
2359 $form_close .=
'<p class="notice">'.$langs->trans(
'SupplierProposalRefFournNotice').
'</p>';
2361 $form_close .=
'<table class="border centpercent marginleftonly marginrightonly">';
2362 $form_close .=
'<tr><td>'.$langs->trans(
"CloseAs").
'</td><td class="left">';
2363 $form_close .=
'<select id="statut" name="statut" class="flat">';
2364 $form_close .=
'<option value="0"> </option>';
2365 $form_close .=
'<option value="2">'.$langs->trans(
'SupplierProposalStatusSigned').
'</option>';
2366 $form_close .=
'<option value="3">'.$langs->trans(
'SupplierProposalStatusNotSigned').
'</option>';
2367 $form_close .=
'</select>';
2368 $form_close .=
'</td></tr>';
2369 $form_close .=
'<tr><td class="left">'.$langs->trans(
'Note').
'</td><td class="left"><textarea cols="70" rows="'.ROWS_3.
'" wrap="soft" name="note">';
2370 $form_close .=
$object->note_private;
2371 $form_close .=
'</textarea></td></tr>';
2372 $form_close .=
'</table>';
2373 $form_close .= $form->buttonsSaveCancel();
2374 $form_close .=
'<a id="acceptedrefused"> </a>';
2375 $form_close .=
'</form>';
2383 if ($action !=
'presend') {
2384 print
'<div class="tabsAction">';
2386 $parameters = array();
2387 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2389 if (empty($reshook)) {
2390 if ($action !=
'statut' && $action !=
'editline') {
2394 $langs->load(
'subtotals');
2396 $url_button = array();
2398 $url_button[] = array(
2399 'lang' =>
'subtotals',
2401 'perm' => (
bool) $usercancreate,
2402 'label' => $langs->trans(
'AddTitleLine'),
2403 'url' =>
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'add_title_line'],
true)
2406 $url_button[] = array(
2407 'lang' =>
'subtotals',
2409 'perm' => (
bool) $usercancreate,
2410 'label' => $langs->trans(
'AddSubtotalLine'),
2411 'url' =>
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'add_subtotal_line'],
true)
2414 $url_button[] = array(
2415 'lang' =>
'subtotals',
2417 'perm' => (
bool) $usercancreate,
2418 'label' => $langs->trans(
'AddTextLine'),
2419 'url' =>
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'add_text_line'],
true)
2422 print dolGetButtonAction(
'', $langs->trans(
'SubTotal'),
'default', $url_button,
'',
true);
2426 if (count(
$object->lines) > 0) {
2427 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=validate&token='.
newToken().
'">'.$langs->trans(
'Validate').
'</a></div>';
2434 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=modif&token='.
newToken().
'">'.$langs->trans(
'Modify').
'</a></div>';
2439 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=reopen&token='.
newToken().(!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#reopen').
'"';
2440 print
'>'.$langs->trans(
'ReOpen').
'</a></div>';
2444 if (empty($user->socid)) {
2447 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'presend',
'mode' =>
'init'],
true).
'#formmailbeforetitle',
'');
2449 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
'#',
'',
false);
2456 if ($usercancreateorder) {
2457 print
'<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&origin='.
$object->element.
'&originid='.
$object->id.
'&socid='.
$object->socid.
'&token='.
newToken().
'">'.$langs->trans(
"AddSupplierOrderShort").
'</a></div>';
2463 print
'<div class="inline-block divButAction"><a class="butAction reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&token='.
newToken().
'&action=statut'.(!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#acceptedrefused').
'"';
2464 print
'>'.$langs->trans(
'SetAcceptedRefused').
'</a></div>';
2469 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&token='.
newToken().
'&action=close'.(!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#close').
'"';
2470 print
'>'.$langs->trans(
'Close').
'</a></div>';
2474 if ($usercancreate) {
2475 print
'<div class="inline-block divButAction">'.dolGetButtonAction($langs->trans(
"ToClone"), $langs->trans(
"ToClone"),
'clone', $_SERVER[
'PHP_SELF'].
'?id='.((
int)
$object->id).
'&socid='.((
int)
$object->socid).
'&action=clone&object='.urlencode(
$object->element).
'&token='.
newToken(),
'',
true, array(
'attr' => array(
'class' =>
'reposition'))).
'</div>';
2479 print dolGetButtonAction($langs->trans(
"Delete"), $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'delete', ((
$object->status ==
SupplierProposal::STATUS_DRAFT && $usercancreate) || $usercandelete), array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
2486 if ($action !=
'presend') {
2487 print
'<div class="fichecenter"><div class="fichehalfleft">';
2494 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
2495 $genallowed = $usercanread;
2496 $delallowed = $usercancreate;
2498 print $formfile->showdocuments(
'supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
2502 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'supplier_proposal'), 1);
2503 $linktoelem = $tmparray[
'linktoelem'];
2504 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
2505 print $htmltoenteralink;
2507 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
2511 print
'</div><div class="fichehalfright">';
2514 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2516 $somethingshown = $formactions->showactions($object,
'supplier_proposal', $socid, 1,
'', $MAXEVENT);
2518 print
'</div></div>';
2522 if (
GETPOST(
'modelselected')) {
2523 $action =
'presend';
2527 $modelmail =
'supplier_proposal_send';
2528 $defaulttopic =
'SendAskRef';
2529 $diroutput =
$conf->supplier_proposal->dir_output;
2530 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
2531 $trackid =
'spro'.$object->id;
2533 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage the table of subscription to notifications.
Class to manage predefined suppliers products.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage price ask supplier.
const STATUS_NOTSIGNED
Not signed quote, canceled.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
const STATUS_SIGNED
Signed quote.
const STATUS_CLOSE
Billed or closed/processed quote.
Class to manage translations.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
$date_start
Variables from include:
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that returns whether VAT must be recoverable collected VAT (e.g.: VAT NPR in France)
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular VAT rate, when selling a product with vat $vatrate,...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.
supplier_proposal_prepare_head($object)
Prepare array with list of tabs.