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 && !empty($lines[$i]->extraparams)) {
483 $newline->id = $result;
484 $newline->extraparams = $lines[$i]->extraparams;
485 $newline->setExtraParameters();
489 if ($result > 0 && $lines[$i]->product_type == 9) {
490 $fk_parent_line = $result;
495 $parameters = array(
'objFrom' => $srcobject);
496 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $object, $action);
499 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
503 if (is_object($srcobject) && !empty($srcobject->error)) {
504 setEventMessages($srcobject->error, $srcobject->errors,
'errors');
506 $langs->load(
"errors");
507 setEventMessages($langs->trans(
"ErrorRecordNotFound"),
null,
'errors');
522 $categories =
GETPOST(
'categories',
'array');
523 $object->setCategories($categories);
530 $outputlangs = $langs;
533 $newlang =
GETPOST(
'lang_id',
'aZ09');
536 $newlang =
$object->thirdparty->default_lang;
538 if (!empty($newlang)) {
540 $outputlangs->setDefaultLang($newlang);
544 if (!empty($model)) {
546 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
553 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
566 } elseif ($action ==
'confirm_reopen' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
572 } elseif ($action ==
'close' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
578 } elseif ($action ==
'setstatut' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
582 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"CloseAs")),
null,
'errors');
590 } elseif ($action ==
'addline' &&
GETPOST(
'updateallvatlinesblock',
'alpha') &&
GETPOST(
'vatforblocklines',
'alpha') !==
'' && $usercancreate) {
591 $tx_tva =
GETPOST(
'vatforblocklines') ?
GETPOST(
'vatforblocklines') : 0;
592 $object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'tva', $tx_tva);
593 } elseif ($action ==
'addline' &&
GETPOST(
'updatealldiscountlinesblock',
'alpha') &&
GETPOST(
'discountforblocklines',
'alpha') !==
'' && $usercancreate) {
594 $discount =
GETPOST(
'discountforblocklines') ?
GETPOST(
'discountforblocklines') : 0;
595 $object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'discount', $discount);
596 } elseif ($action ==
'settags' &&
isModEnabled(
'category') && $usercancreate) {
601 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
604 $triggersendname =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
605 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
606 $trackid =
'spro'.$object->id;
607 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
610 $upload_dir =
$conf->supplier_proposal->dir_output;
611 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
614 if ($action ==
'modif' && $usercancreate) {
619 $outputlangs = $langs;
622 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
623 $outputlangs->setDefaultLang($newlang);
629 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
631 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
643 if ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') && $usercancreate) {
645 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
646 $vat_rate = str_replace(
'*',
'', $vat_rate);
649 foreach (
$object->lines as $line) {
650 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
654 $line_price_base_type = $line->getPriceBaseType();
655 $line_pu = ($line_price_base_type ===
'TTC') ? (
float) $line->subprice_ttc : (float) $line->subprice;
658 $line_pu_devise = ($line_price_base_type ===
'TTC') ? 0 : (float) $line->multicurrency_subprice;
659 $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);
661 } elseif ($action ==
'confirm_addtextline' && $usercancreate) {
664 $langs->load(
'subtotals');
666 $desc =
GETPOST(
'subtotaltextcontent',
'restricthtml');
669 $result =
$object->addSubtotalLine($langs, $desc, 0, array());
680 $outputlangs = $langs;
681 $newlang =
GETPOST(
'lang_id',
'alpha');
683 $newlang =
$object->thirdparty->default_lang;
685 if (!empty($newlang)) {
687 $outputlangs->setDefaultLang($newlang);
690 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
695 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
697 } elseif ($action ==
'confirm_addtitleline' && $usercancreate) {
700 $langs->load(
'subtotals');
702 $desc =
GETPOST(
'subtotallinedesc',
'alphanohtml');
703 $depth =
GETPOSTINT(
'subtotallinelevel') ?? 1;
705 $subtotal_options = array();
707 foreach (SupplierProposal::$TITLE_OPTIONS as $option) {
708 $value =
GETPOST($option,
'alphanohtml');
710 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
715 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
726 $outputlangs = $langs;
727 $newlang =
GETPOST(
'lang_id',
'alpha');
729 $newlang =
$object->thirdparty->default_lang;
731 if (!empty($newlang)) {
733 $outputlangs->setDefaultLang($newlang);
736 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
741 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
743 } elseif ($action ==
'confirm_addsubtotalline' && $usercancreate) {
746 $langs->load(
'subtotals');
748 $choosen_line =
GETPOST(
'subtotaltitleline',
'alphanohtml');
749 foreach (
$object->lines as $line) {
750 if ($line->desc == $choosen_line && $line->special_code == SUBTOTALS_SPECIAL_CODE) {
752 $depth = -$line->qty;
756 $subtotal_options = array();
758 foreach (SupplierProposal::$SUBTOTAL_OPTIONS as $option) {
759 $value =
GETPOST($option,
'alphanohtml');
761 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
766 if (isset($desc) && isset($depth)) {
767 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
770 $object->errors[] = $langs->trans(
"CorrespondingTitleNotFound");
779 $outputlangs = $langs;
780 $newlang =
GETPOST(
'lang_id',
'alpha');
782 $newlang =
$object->thirdparty->default_lang;
784 if (!empty($newlang)) {
786 $outputlangs->setDefaultLang($newlang);
789 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
794 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
796 } elseif ($action ==
'addline' && $usercancreate) {
797 $langs->load(
'errors');
806 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
808 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
809 if ($prod_entry_mode ==
'free') {
825 if (empty($remise_percent)) {
830 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
831 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
833 if (is_array($extralabelsline)) {
835 foreach ($extralabelsline as $key => $value) {
836 unset($_POST[
"options_".$key]);
840 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
841 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
844 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
845 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
849 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' &&
GETPOST(
'multicurrency_price_ht') ===
'') {
850 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPrice")),
null,
'errors');
853 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($line_desc)) {
854 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Description")),
null,
'errors');
857 if (!$error && ($qty >= 0)) {
861 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
865 if ($prod_entry_mode !=
'free' && empty($error)) {
869 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
874 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
875 $idprod = (int) $reg[1];
876 $res = $productsupplier->fetch($idprod);
879 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
881 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
882 if ($productsupplier->fourn_socid != $socid) {
883 $productsupplier->ref_supplier =
'';
886 $fksoctosearch =
$object->thirdparty->id;
887 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
889 } elseif (
GETPOSTINT(
'idprodfournprice') > 0) {
892 $idprod = $productsupplier->get_buyprice(
GETPOSTINT(
'idprodfournprice'), $qtytosearch);
893 $res = $productsupplier->fetch($idprod);
897 $label = $productsupplier->label;
901 $outputlangs = $langs;
903 if (
GETPOST(
'lang_id',
'aZ09')) {
904 $newlang =
GETPOST(
'lang_id',
'aZ09');
906 if (empty($newlang)) {
907 $newlang =
$object->thirdparty->default_lang;
909 if (!empty($newlang)) {
911 $outputlangs->setDefaultLang($newlang);
913 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->
description;
915 $desc = $productsupplier->description;
918 if (!empty($productsupplier->desc_supplier) &&
getDolGlobalString(
'PRODUIT_FOURN_TEXTS')) {
919 $desc = $productsupplier->desc_supplier;
930 $ref_supplier = $productsupplier->ref_supplier;
935 $tmpidprodfournprice =
GETPOST(
'idprodfournprice',
'alpha');
936 if (is_numeric($tmpidprodfournprice) && (
int) $tmpidprodfournprice > 0) {
937 $tmpidprodfournprice = (int) $tmpidprodfournprice;
939 $tmpidprodfournprice = 0;
945 if (empty($tva_tx)) {
951 $type = $productsupplier->type;
952 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
953 $price_base_type =
'HT';
955 $pu_devise =
price2num($price_ht_devise,
'CU');
956 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
957 $price_base_type =
'TTC';
959 $pu_devise =
price2num($price_ttc_devise,
'CU');
961 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
962 if (empty(
$object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code !=
$object->multicurrency_code)) {
963 $pu = $productsupplier->fourn_pu;
966 $pu = $productsupplier->fourn_pu;
967 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
976 $fournprice = (is_numeric(
GETPOST(
'idprodfournprice',
'alpha')) ?
GETPOST(
'idprodfournprice',
'alpha') : -1);
981 ($price_base_type ==
'HT' ? $pu : 0),
986 $productsupplier->id,
989 ($price_base_type ==
'TTC' ? $pu : 0),
992 min($rank, count(
$object->lines) + 1),
1000 $productsupplier->fk_unit,
1016 if ($idprod == -99 || $idprod == 0) {
1019 $langs->load(
"errors");
1020 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")).
' '.$langs->trans(
"or").
' '.$langs->trans(
"NoPriceDefinedForThisSupplier"),
null,
'errors');
1022 if ($idprod == -1) {
1025 $langs->load(
"errors");
1026 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
1028 } elseif ((
GETPOST(
'price_ht') !==
'' ||
GETPOST(
'price_ttc') !==
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') && empty($error)) {
1032 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1033 $tva_tx = str_replace(
'*',
'', $tva_tx);
1034 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1040 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
1049 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1050 $price_base_type =
'HT';
1053 $pu_ht_devise =
price2num($price_ht_devise,
'CU');
1055 $price_base_type =
'TTC';
1058 $pu_ht_devise =
price2num($price_ttc_devise,
'CU');
1086 (
float) $pu_ht_devise
1091 if (!$error && $result > 0) {
1098 $outputlangs = $langs;
1101 $newlang =
GETPOST(
'lang_id',
'aZ09');
1104 $newlang =
$object->thirdparty->default_lang;
1106 if (!empty($newlang)) {
1108 $outputlangs->setDefaultLang($newlang);
1116 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1122 unset($_POST[
'prod_entry_mode']);
1124 unset($_POST[
'qty']);
1125 unset($_POST[
'type']);
1126 unset($_POST[
'remise_percent']);
1127 unset($_POST[
'pu']);
1128 unset($_POST[
'price_ht']);
1129 unset($_POST[
'multicurrency_price_ht']);
1130 unset($_POST[
'price_ttc']);
1131 unset($_POST[
'fourn_ref']);
1132 unset($_POST[
'tva_tx']);
1133 unset($_POST[
'label']);
1134 unset($_POST[
'product_ref']);
1135 unset($_POST[
'product_label']);
1136 unset($_POST[
'product_desc']);
1137 unset($_POST[
'fournprice']);
1138 unset($_POST[
'buying_price']);
1139 unset($localtax1_tx);
1140 unset($localtax2_tx);
1141 unset($_POST[
'np_marginRate']);
1142 unset($_POST[
'np_markRate']);
1143 unset($_POST[
'dp_desc']);
1144 unset($_POST[
'idprodfournprice']);
1145 unset($_POST[
'units']);
1147 unset($_POST[
'idprod']);
1149 unset($_POST[
'date_starthour']);
1150 unset($_POST[
'date_startmin']);
1151 unset($_POST[
'date_startsec']);
1152 unset($_POST[
'date_startday']);
1153 unset($_POST[
'date_startmonth']);
1154 unset($_POST[
'date_startyear']);
1155 unset($_POST[
'date_endhour']);
1156 unset($_POST[
'date_endmin']);
1157 unset($_POST[
'date_endsec']);
1158 unset($_POST[
'date_endday']);
1159 unset($_POST[
'date_endmonth']);
1160 unset($_POST[
'date_endyear']);
1167 } elseif ($action ==
'updatetitleline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1170 $langs->load(
'subtotals');
1172 $desc =
GETPOST(
'line_desc',
'alphanohtml') ?? $langs->trans(
"Title");
1175 $subtotal_options = array();
1177 foreach (SupplierProposal::$TITLE_OPTIONS as $option) {
1178 $value =
GETPOST($option,
'alphanohtml');
1180 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1185 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1196 $outputlangs = $langs;
1197 $newlang =
GETPOST(
'lang_id',
'alpha');
1199 $newlang =
$object->thirdparty->default_lang;
1201 if (!empty($newlang)) {
1203 $outputlangs->setDefaultLang($newlang);
1206 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1211 } elseif ($action ==
'updatetextline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1214 $langs->load(
'subtotals');
1216 $desc =
GETPOST(
'line_desc',
'restricthtml');
1219 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, 0, array());
1230 $outputlangs = $langs;
1231 $newlang =
GETPOST(
'lang_id',
'alpha');
1233 $newlang =
$object->thirdparty->default_lang;
1235 if (!empty($newlang)) {
1237 $outputlangs->setDefaultLang($newlang);
1240 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1245 } elseif ($action ==
'updatesubtotalline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1248 $langs->load(
'subtotals');
1250 $desc =
GETPOST(
'line_desc',
'alphanohtml');
1253 $subtotal_options = array();
1255 foreach (SupplierProposal::$SUBTOTAL_OPTIONS as $option) {
1256 $value =
GETPOST($option,
'alphanohtml');
1258 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1263 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1271 $outputlangs = $langs;
1272 $newlang =
GETPOST(
'lang_id',
'alpha');
1274 $newlang =
$object->thirdparty->default_lang;
1276 if (!empty($newlang)) {
1278 $outputlangs->setDefaultLang($newlang);
1281 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1286 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save') == $langs->trans(
"Save")) {
1294 if (preg_match(
'/\*/', $vat_rate)) {
1302 $vat_rate = str_replace(
'*',
'', $vat_rate);
1313 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1314 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1316 if (is_array($extralabelsline)) {
1317 foreach ($extralabelsline as $key => $value) {
1318 unset($_POST[
"options_".$key]);
1323 $special_code =
GETPOST(
'special_code');
1332 $price_base_type =
'HT';
1333 if (empty($pu_ht) && !empty($pu_ttc)) {
1335 $price_base_type =
'TTC';
1336 } elseif (!empty($pu_ht) && !empty($pu_ttc)) {
1337 foreach (
$object->lines as $line_obj) {
1340 if ($line_obj->wasEnteredIncludingTax()) {
1342 $price_base_type =
'TTC';
1351 if (!empty($productid)) {
1353 if (
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY') == 1) {
1354 if ($productid > 0 && $productsupplier->get_buyprice(0, (
float)
price2num(
GETPOST(
'qty')), $productid,
'none',
GETPOSTINT(
'socid')) < 0) {
1355 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1360 $res = $product->fetch($productid);
1362 $type = $product->type;
1364 $price_min = $product->price_min;
1366 $price_min = $product->multiprices_min [
$object->thirdparty->price_level];
1372 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1376 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1384 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1389 if ($price_base_type ===
'TTC') {
1395 if (
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' &&
GETPOST(
'multicurrency_subprice') ===
'' &&
GETPOST(
'multicurrency_price_ttc') !==
'') {
1397 $price_base_type =
'TTC';
1401 $result =
$object->updateline(
1422 (
float) $pu_ht_devise
1430 $outputlangs = $langs;
1433 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
1434 $outputlangs->setDefaultLang($newlang);
1437 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1440 unset($_POST[
'qty']);
1441 unset($_POST[
'type']);
1442 unset($_POST[
'productid']);
1443 unset($_POST[
'remise_percent']);
1444 unset($_POST[
'price_ht']);
1445 unset($_POST[
'multicurrency_price_ht']);
1446 unset($_POST[
'price_ttc']);
1447 unset($_POST[
'tva_tx']);
1448 unset($_POST[
'product_ref']);
1449 unset($_POST[
'product_label']);
1450 unset($_POST[
'product_desc']);
1451 unset($_POST[
'fournprice']);
1452 unset($_POST[
'buying_price']);
1454 unset($_POST[
'date_starthour']);
1455 unset($_POST[
'date_startmin']);
1456 unset($_POST[
'date_startsec']);
1457 unset($_POST[
'date_startday']);
1458 unset($_POST[
'date_startmonth']);
1459 unset($_POST[
'date_startyear']);
1460 unset($_POST[
'date_endhour']);
1461 unset($_POST[
'date_endmin']);
1462 unset($_POST[
'date_endsec']);
1463 unset($_POST[
'date_endday']);
1464 unset($_POST[
'date_endmonth']);
1465 unset($_POST[
'date_endyear']);
1472 } elseif ($action ==
'updateline' && $usercancreate && $cancel) {
1473 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
1475 } elseif ($action ==
'classin' && $usercancreate) {
1478 } elseif ($action ==
'setavailability' && $usercancreate) {
1481 } elseif ($action ==
'setconditions' && $usercancreate) {
1483 $sql =
"SELECT code ";
1484 $sql .=
"FROM " . $db->prefix() .
"c_payment_term";
1485 $sql .=
" WHERE rowid = " .
GETPOSTINT(
'cond_reglement_id');
1486 $result = $db->query($sql);
1488 $obj = $db->fetch_object($result);
1489 if ($obj->code ==
'DEP30PCTDEL') {
1496 } elseif ($action ==
'setmode' && $usercancreate) {
1499 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
1501 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
1502 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
1504 if (!in_array(
GETPOSTINT(
'calculation_mode'), array(1, 2))) {
1505 $langs->load(
"compta");
1506 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CalculationMode")),
null,
'errors');
1507 $action =
'editmulticurrencyrate';
1511 } elseif ($action ==
'update_extras' && $permissiontoeditextra) {
1514 $attribute_name =
GETPOST(
'attribute',
'aZ09');
1517 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
1523 $result =
$object->updateExtraField($attribute_name,
'PROPOSAL_SUPPLIER_MODIFY');
1531 $action =
'edit_extras';
1541$title =
$object->ref.
" - ".$langs->trans(
'Card');
1542if ($action ==
'create') {
1543 $title = $langs->trans(
"SupplierProposalNew");
1545$help_url =
'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur';
1547llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-supplierproposal page-card');
1549$form =
new Form($db);
1553$companystatic =
new Societe($db);
1561if ($action ==
'create') {
1562 $currency_code =
$conf->currency;
1564 print
load_fiche_titre($langs->trans(
"SupplierProposalNew"),
'',
'supplier_proposal');
1568 $res = $soc->fetch($socid);
1572 if (!empty($origin) && !empty($originid)) {
1574 $objectsrc = fetchObjectByElement($originid, $origin);
1576 if (is_object($objectsrc)) {
1577 '@phan-var-force Commande|Propal|CommandeFournisseur|SupplierProposal $objectsrc';
1579 $classname = get_class($objectsrc);
1581 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1582 $objectsrc->fetch_lines();
1584 $objectsrc->fetch_thirdparty();
1586 $projectid = (int) $objectsrc->fk_project;
1587 $soc = $objectsrc->thirdparty;
1589 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1590 $deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent : 0));
1591 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1592 $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
1595 $objectsrc->fetch_optionals();
1596 $object->array_options = $objectsrc->array_options;
1599 if (!empty($objectsrc->multicurrency_code)) {
1600 $currency_code = $objectsrc->multicurrency_code;
1602 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
1603 $currency_tx = $objectsrc->multicurrency_tx;
1608 $cond_reglement_id = (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0);
1609 $deposit_percent = (!empty($soc->deposit_percent) ? $soc->deposit_percent : 0);
1610 $mode_reglement_id = (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0);
1611 $fk_account = (!empty($soc->fk_account) ? $soc->fk_account : 0);
1614 $cond_reglement_id = $soc->cond_reglement_supplier_id;
1615 $deposit_percent = !empty($soc->deposit_percent) ? $soc->deposit_percent : 0;
1616 $mode_reglement_id = $soc->mode_reglement_supplier_id;
1617 $fk_account = !empty($soc->fk_account) ? $soc->fk_account : 0;
1618 if (
isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
1619 $currency_code = $soc->multicurrency_code;
1622 if (
GETPOSTISSET(
'cond_reglement_id_deposit_percent')) {
1623 $deposit_percent =
GETPOSTFLOAT(
'cond_reglement_id_deposit_percent');
1628 print
'<form name="addprop" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1629 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1630 print
'<input type="hidden" name="action" value="add">';
1631 if ($origin !=
'project' && $originid) {
1632 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1633 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1635 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1636 if ($backtopageforcancel) {
1637 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
1643 $parameters = array();
1645 $reshook = $hookmanager->executeHooks(
'tabContentCreateSupplierProposal', $parameters, $object, $action);
1646 if (empty($reshook)) {
1647 print
'<table class="border centpercent">';
1650 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td colspan="2">'.$langs->trans(
"Draft").
'</td></tr>';
1654 print
'<td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
1656 print
'<td colspan="2">';
1657 print $soc->getNomUrl(1,
'supplier');
1658 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1661 print
'<td colspan="2">';
1662 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
1663 print img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company((empty($socid) ?
'' : $socid),
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1667 $(document).ready(function() {
1668 $("#socid").change(function() {
1669 console.log("We have changed the company - Reload page");
1671 $("input[name=action]").val("create");
1672 $("form[name=addprop]").submit();
1677 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>';
1684 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
1686 $absolute_discount = $soc->getAvailableDiscounts(
null,
'', 0, 1);
1690 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
1691 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1697 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td colspan="2">';
1698 print img_picto(
'',
'payment',
'class="pictofixedwidth"');
1699 print $form->getSelectConditionsPaiements(
GETPOSTISSET(
'cond_reglement_id') ?
GETPOSTINT(
'cond_reglement_id') : $cond_reglement_id,
'cond_reglement_id', -1, 1, 0,
'', $deposit_percent);
1703 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td colspan="2">';
1704 print img_picto(
'',
'bank',
'class="pictofixedwidth"');
1705 $form->select_types_paiements(
GETPOST(
'mode_reglement_id') > 0 ?
GETPOST(
'mode_reglement_id') : $mode_reglement_id,
'mode_reglement_id');
1710 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td colspan="2">';
1711 print img_picto(
'',
'bank',
'class="pictofixedwidth"');
1712 $form->select_comptes(
GETPOST(
'fk_account') > 0 ?
GETPOSTINT(
'fk_account') : $fk_account,
'fk_account', 0,
'', 1);
1718 print
'<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td colspan="2">';
1719 print img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1720 $form->selectShippingMethod(
GETPOST(
'shipping_method_id') > 0 ?
GETPOSTINT(
'shipping_method_id') :
"",
'shipping_method_id',
'', 1);
1725 print
'<tr><td>'.$langs->trans(
"DeliveryDate").
'</td>';
1726 print
'<td colspan="2">';
1727 print img_picto(
'',
'action',
'class="pictofixedwidth"');
1734 print $form->selectDate($syear.
"-".$smonth.
"-".$sday,
'liv_', 0, 0, 0,
"addask");
1736 print $form->selectDate($datedelivery ? $datedelivery : -1,
'liv_', 0, 0, 0,
"addask", 1, 1);
1743 if (count($list) > 0) {
1745 print
'<td>'.$langs->trans(
"DefaultModel").
'</td>';
1746 print
'<td colspan="2">';
1747 print img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1749 print $form->selectarray(
'model', $list, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1755 $langs->load(
"projects");
1759 if ($origin ==
'project') {
1760 $projectid = ($originid ? $originid : 0);
1764 print
'<td>'.$langs->trans(
"Project").
'</td><td colspan="2">';
1765 if (!empty($user->socid)) {
1766 $projSocFilter = $user->socid;
1767 } elseif (
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') || $socid == 0) {
1770 $projSocFilter = -1;
1772 $projSocFilter = $socid;
1774 print img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects($projSocFilter, $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
1775 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>';
1783 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
1784 print
'<td colspan="3" class="maxwidthonsmartphone">';
1785 print img_picto(
'',
'currency',
'class="pictofixedwidth"');
1786 print $form->selectMultiCurrency($currency_code,
'multicurrency_code');
1791 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
1792 print $form->selectCategories(Categorie::TYPE_SUPPLIER_PROPOSAL,
'categories', $object);
1797 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' => 3);
1798 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1799 print $hookmanager->resPrint;
1800 if (empty($reshook)) {
1801 print
$object->showOptionals($extrafields,
'create', $parameters);
1806 if (!empty($origin) && !empty($originid) && is_object($objectsrc) && $classname !==
null) {
1808 if ($origin ==
'contrat') {
1810 $objectsrc->update_price(1,
'auto', 1);
1813 print
"\n<!-- ".$classname.
" info -->";
1815 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
1816 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
1817 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
1818 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
1819 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
1821 print
'<tr><td>'.$langs->trans(
'CommRequest').
'</td><td colspan="2">'.$objectsrc->getNomUrl(1).
'</td></tr>';
1822 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td colspan="2">'.
price($objectsrc->total_ht).
'</td></tr>';
1823 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td colspan="2">'.
price($objectsrc->total_tva).
"</td></tr>";
1824 if (
$mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
1825 print
'<tr><td>'.$langs->transcountry(
"AmountLT1",
$mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax1).
"</td></tr>";
1828 if (
$mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
1829 print
'<tr><td>'.$langs->transcountry(
"AmountLT2",
$mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax2).
"</td></tr>";
1831 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td colspan="2">'.
price($objectsrc->total_ttc).
"</td></tr>";
1834 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>';
1835 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>";
1836 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>";
1848 print
'<input type="hidden" name="createmode" value="empty">';
1852 print
'<br><table>';
1856 print
'<td><input type="radio" name="createmode" value="copy"></td>';
1857 print
'<td>'.$langs->trans(
"CopyAskFrom").
' </td>';
1859 $liste_ask = array();
1860 $liste_ask [0] =
'';
1862 $sql =
"SELECT p.rowid as id, p.ref, s.nom";
1863 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal p";
1864 $sql .=
", ".MAIN_DB_PREFIX.
"societe s";
1865 $sql .=
" WHERE s.rowid = p.fk_soc";
1866 $sql .=
" AND p.entityy IN (".getEntity(
'supplier_proposal').
")";
1867 $sql .=
" AND p.fk_statut <> ".SupplierProposal::STATUS_DRAFT;
1868 $sql .=
" ORDER BY Id";
1870 $resql = $db->query($sql);
1872 $num = $db->num_rows($resql);
1875 $row = $db->fetch_row($resql);
1876 $askPriceSupplierRefAndSocName = $row[1].
" - ".$row[2];
1877 $liste_ask[$row[0]] = $askPriceSupplierRefAndSocName;
1880 print $form->selectarray(
"copie_supplier_proposal", $liste_ask, 0);
1882 dol_print_error($db);
1886 print
'<tr><td class="tdtop"><input type="radio" name="createmode" value="empty" checked></td>';
1887 print
'<td valign="top" colspan="2">'.$langs->trans(
"CreateEmptyAsk").
'</td></tr>';
1897 print $form->buttonsSaveCancel(
"CreateDraft");
1903 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1906 $title = $langs->trans(
'ProductsAndServices');
1909 print
'<div class="div-table-responsive-no-min">';
1910 print
'<table class="noborder centpercent">';
1912 $objectsrc->printOriginLinesList();
1926 print
dol_get_fiche_head($head,
'comm', $langs->trans(
'CommRequest'), -1,
'supplier_proposal', 0,
'',
'', 0,
'', 1);
1931 if ($action ==
'clone') {
1932 $filter =
'(s.fournisseur:=:1)';
1934 $formquestion = array(
1942 'label' => $langs->trans(
"SelectThirdParty"),
1943 'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter))
1946 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
1947 } elseif ($action ==
'delete') {
1949 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteAsk'), $langs->trans(
'ConfirmDeleteAsk',
$object->ref),
'confirm_delete',
'', 0, 1);
1950 } elseif ($action ==
'reopen') {
1952 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ReOpen'), $langs->trans(
'ConfirmReOpenAsk',
$object->ref),
'confirm_reopen',
'', 0, 1);
1953 } elseif ($action ==
'ask_deleteline') {
1955 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
1956 } elseif ($action ==
'ask_subtotal_deleteline') {
1958 $langs->load(
"subtotals");
1959 $title =
"DeleteSubtotalLine";
1960 $question =
"ConfirmDeleteSubtotalLine";
1961 if (
GETPOST(
'type') ==
'title') {
1964 'type' =>
'checkbox',
1965 'name' =>
'deletecorrespondingsubtotalline',
1966 'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
1970 $title =
"DeleteTitleLine";
1971 $question =
"ConfirmDeleteTitleLine";
1973 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
1974 } elseif ($action ==
'validate') {
1979 $ref = substr(
$object->ref, 1, 4);
1980 if ($ref ==
'PROV') {
1981 $numref =
$object->getNextNumRef($soc);
1982 if (empty($numref)) {
1987 $numref = (string)
$object->ref;
1990 $text = $langs->trans(
'ConfirmValidateAsk', $numref);
1992 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
1993 $notify =
new Notify($db);
1995 $text .= $notify->confirmMessage(
'PROPOSAL_SUPPLIER_VALIDATE',
$object->socid, $object);
1999 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateAsk'), $text,
'confirm_validate',
'', 0, 1);
2003 if ($action ==
'add_title_line') {
2004 $langs->load(
'subtotals');
2006 $depth_array =
$object->getPossibleLevels($langs);
2008 } elseif ($action ==
'add_subtotal_line') {
2009 $langs->load(
'subtotals');
2011 $titles =
$object->getPossibleTitles();
2013 } elseif ($action ==
'add_text_line') {
2014 $langs->load(
'subtotals');
2020 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
2021 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2022 if (empty($reshook)) {
2023 $formconfirm .= $hookmanager->resPrint;
2024 } elseif ($reshook > 0) {
2025 $formconfirm = $hookmanager->resPrint;
2033 $linkback =
'<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
2036 $morehtmlref =
'<div class="refidno">';
2041 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'supplier');
2043 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.
$object->thirdparty->id.
'">'.$langs->trans(
"OtherProposals").
'</a>)';
2047 $langs->load(
"projects");
2048 $morehtmlref .=
'<br>';
2049 if ($usercancreate) {
2050 $morehtmlref .= img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2051 if ($action !=
'classify') {
2052 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2055 $canLinkAll = ($canLinkAll ===
'' || $canLinkAll ===
false) ? 0 : $canLinkAll;
2057 $projectSocId = ((int) $canLinkAll == 1) ? -1 : $currentSocId;
2058 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $projectSocId,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2060 if (!empty(
$object->fk_project)) {
2062 $proj->fetch(
$object->fk_project);
2063 $morehtmlref .= $proj->getNomUrl(1);
2065 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2070 $morehtmlref .=
'</div>';
2073 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2076 $parameters = array();
2078 $reshook = $hookmanager->executeHooks(
'tabContentViewSupplierProposal', $parameters, $object, $action);
2079 if (empty($reshook)) {
2080 print
'<div class="fichecenter">';
2081 print
'<div class="fichehalfleft">';
2082 print
'<div class="underbanner clearboth"></div>';
2084 print
'<table class="border tableforfield centpercent">';
2088 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
2089 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
2091 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
2092 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
2095 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td>';
2097 $absolute_discount = $soc->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
2098 $absolute_creditnote = $soc->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
2099 $absolute_discount =
price2num($absolute_discount,
'MT');
2100 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
2104 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
2105 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2110 print
'<tr><td class="titlefield">';
2111 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2112 print $langs->trans(
'PaymentConditionsShort');
2115 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>';
2117 print
'</tr></table>';
2118 print
'</td><td class="valuefield">';
2119 if ($action ==
'editconditions') {
2120 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
2122 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'none', 1,
'', 1,
$object->deposit_percent);
2129 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2130 print $langs->trans(
'DeliveryDate');
2133 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>';
2135 print
'</tr></table>';
2136 print
'</td><td class="valuefield">';
2137 if ($action ==
'editdate_livraison') {
2138 print
'<form name="editdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
2139 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2140 print
'<input type="hidden" name="action" value="setdate_livraison">';
2141 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2142 print $form->selectDate(
$object->delivery_date,
'liv_', 0, 0, 0,
"editdate_livraison");
2143 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2154 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2155 print $langs->trans(
'PaymentMode');
2158 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>';
2160 print
'</tr></table>';
2161 print
'</td><td class="valuefield">';
2162 if ($action ==
'editmode') {
2163 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
2165 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
2185 print
'<table width="100%" class="nobordernopadding"><tr><td>';
2186 print $langs->trans(
'BankAccount');
2188 if ($action !=
'editbankaccount' && $usercancreate) {
2189 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>';
2191 print
'</tr></table>';
2192 print
'</td><td class="valuefield">';
2193 if ($action ==
'editbankaccount') {
2194 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
2196 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'none');
2204 print
'<table class="nobordernopadding centpercent"><tr><td>';
2205 print $langs->trans(
"Categories");
2206 print
'<td><td class="right">';
2207 if ($usercancreate) {
2208 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/supplier_proposal/card.php?id='.
$object->id.
'&action=edittags&token='.
newToken().
'">'.img_edit().
'</a>';
2212 print
'</td></tr></table>';
2215 if ($action ==
'edittags') {
2216 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
2217 print
'<input type="hidden" name="action" value="settags">';
2218 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2219 print $form->selectCategories(Categorie::TYPE_SUPPLIER_PROPOSAL,
'categories', $object);
2220 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
2223 print $form->showCategories(
$object->id, Categorie::TYPE_SUPPLIER_PROPOSAL, 1);
2228 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2233 print
'<div class="fichehalfright">';
2234 print
'<div class="underbanner clearboth"></div>';
2236 print
'<table class="border tableforfield centpercent">';
2238 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
2242 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
2243 print
'<td class="nowrap amountcard right" data-dol-field="total_ht">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2246 print
'<td class="nowrap amountcard right" data-dol-field="multicurrency_total_ht">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2252 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
2253 print
'<td class="nowrap amountcard right" data-dol-field="total_tva">' .
price(
$object->total_tva, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2256 print
'<td class="nowrap amountcard right" data-dol-field="multicurrency_total_tva">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2261 if (
$mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
2263 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1",
$mysoc->country_code) .
'</td>';
2264 print
'<td class="nowrap amountcard right" data-dol-field="total_localtax1">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2266 print
'<td class="nowrap amountcard right" data-dol-field="multicurrency_total_localtax1">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2270 if (
$mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
2272 print
'<td>' . $langs->transcountry(
"AmountLT2",
$mysoc->country_code) .
'</td>';
2273 print
'<td class="nowrap amountcard right" data-dol-field="total_localtax2">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2275 print
'<td class="nowrap amountcard right" data-dol-field="multicurrency_total_localtax2">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2283 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
2284 print
'<td class="nowrap amountcard right" data-dol-field="total_ttc">' .
price(
$object->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2287 print
'<td class="nowrap amountcard right" data-dol-field="multicurrency_total_ttc">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2301 print
'<div class="clearboth"></div><br>';
2304 $blocname =
'contacts';
2305 $title = $langs->trans(
'ContactsAddresses');
2306 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2310 $blocname =
'notes';
2311 $title = $langs->trans(
'Notes');
2312 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2320 $result =
$object->getLinesArray();
2322 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'#add' :
'').
'" method="POST">
2323 <input type="hidden" name="token" value="' .
newToken().
'">
2324 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
2325 <input type="hidden" name="mode" value="">
2326 <input type="hidden" name="id" value="' .
$object->id.
'">
2332 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_ajaxrow.tpl.php';
2334 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
2338 print
'<div class="div-table-responsive-no-min">';
2339 print
'<table id="tablelines" class="noborder noshadow centpercent">';
2342 global $forceall, $senderissupplier, $inputalsopricewithtax;
2345 $inputalsopricewithtax = 1;
2346 $senderissupplier = 2;
2347 if (
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY')) {
2348 $senderissupplier =
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY');
2352 $object->printObjectLines($action, $soc,
$mysoc, $lineid, $dateSelector);
2357 if ($action !=
'editline') {
2360 $parameters = array(
'dateSelector' => $dateSelector);
2361 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
2363 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
2365 if (empty($reshook)) {
2378 if ($action ==
'statut') {
2380 $form_close =
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST" id="formacceptrefuse" class="formconsumeproduce paddingbottom paddingleft paddingright">';
2381 $form_close .=
'<input type="hidden" name="token" value="'.newToken().
'">';
2382 $form_close .=
'<input type="hidden" name="action" value="setstatut">';
2385 $form_close .=
'<p class="notice">'.$langs->trans(
'SupplierProposalRefFournNotice').
'</p>';
2387 $form_close .=
'<table class="border centpercent marginleftonly marginrightonly">';
2388 $form_close .=
'<tr><td>'.$langs->trans(
"CloseAs").
'</td><td class="left">';
2389 $form_close .=
'<select id="statut" name="statut" class="flat">';
2390 $form_close .=
'<option value="0"> </option>';
2391 $form_close .=
'<option value="2">'.$langs->trans(
'SupplierProposalStatusSigned').
'</option>';
2392 $form_close .=
'<option value="3">'.$langs->trans(
'SupplierProposalStatusNotSigned').
'</option>';
2393 $form_close .=
'</select>';
2394 $form_close .=
'</td></tr>';
2395 $form_close .=
'<tr><td class="left">'.$langs->trans(
'Note').
'</td><td class="left"><textarea cols="70" rows="'.ROWS_3.
'" wrap="soft" name="note">';
2396 $form_close .=
$object->note_private;
2397 $form_close .=
'</textarea></td></tr>';
2398 $form_close .=
'</table>';
2399 $form_close .= $form->buttonsSaveCancel();
2400 $form_close .=
'<a id="acceptedrefused"> </a>';
2401 $form_close .=
'</form>';
2409 if ($action !=
'presend') {
2410 print
'<div class="tabsAction">';
2412 $parameters = array();
2413 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2415 if (empty($reshook)) {
2416 if ($action !=
'statut' && $action !=
'editline') {
2420 $langs->load(
'subtotals');
2422 $url_button = array();
2424 $url_button[] = array(
2425 'lang' =>
'subtotals',
2427 'perm' => (
bool) $usercancreate,
2428 'label' => $langs->trans(
'AddTitleLine'),
2429 'url' =>
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'add_title_line'],
true)
2432 $url_button[] = array(
2433 'lang' =>
'subtotals',
2435 'perm' => (
bool) $usercancreate,
2436 'label' => $langs->trans(
'AddSubtotalLine'),
2437 'url' =>
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'add_subtotal_line'],
true)
2440 $url_button[] = array(
2441 'lang' =>
'subtotals',
2443 'perm' => (
bool) $usercancreate,
2444 'label' => $langs->trans(
'AddTextLine'),
2445 'url' =>
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'add_text_line'],
true)
2448 print dolGetButtonAction(
'', $langs->trans(
'SubTotal'),
'default', $url_button,
'',
true);
2452 if (count(
$object->lines) > 0) {
2453 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>';
2460 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>';
2465 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').
'"';
2466 print
'>'.$langs->trans(
'ReOpen').
'</a></div>';
2470 if (empty($user->socid)) {
2473 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'presend',
'mode' =>
'init'],
true).
'#formmailbeforetitle',
'');
2475 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
'#',
'',
false);
2482 if ($usercancreateorder) {
2483 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>';
2489 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').
'"';
2490 print
'>'.$langs->trans(
'SetAcceptedRefused').
'</a></div>';
2495 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').
'"';
2496 print
'>'.$langs->trans(
'Close').
'</a></div>';
2500 if ($usercancreate) {
2501 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>';
2505 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";
2512 if ($action !=
'presend') {
2513 print
'<div class="fichecenter"><div class="fichehalfleft">';
2520 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
2521 $genallowed = $usercanread;
2522 $delallowed = $usercancreate;
2524 print $formfile->showdocuments(
'supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
2528 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'supplier_proposal'), 1);
2529 $linktoelem = $tmparray[
'linktoelem'];
2530 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
2531 print $htmltoenteralink;
2533 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
2537 print
'</div><div class="fichehalfright">';
2540 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2542 $somethingshown = $formactions->showactions($object,
'supplier_proposal', $socid, 1,
'', $MAXEVENT);
2544 print
'</div></div>';
2548 if (
GETPOST(
'modelselected')) {
2549 $action =
'presend';
2553 $modelmail =
'supplier_proposal_send';
2554 $defaulttopic =
'SendAskRef';
2555 $diroutput =
$conf->supplier_proposal->dir_output;
2556 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
2557 $trackid =
'spro'.$object->id;
2559 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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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 supplier_proposal lines.
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, $currencycode='')
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.