40require
'../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_proposal/modules_supplier_proposal.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/supplier_proposal.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
50if (isModEnabled(
'project')) {
51 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
52 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
65$langs->loadLangs(array(
'companies',
'supplier_proposal',
'compta',
'bills',
'propal',
'orders',
'products',
'deliveries',
'sendings'));
66if (isModEnabled(
'margin')) {
67 $langs->load(
'margins');
75$action =
GETPOST(
'action',
'aZ09');
76$cancel =
GETPOST(
'cancel',
'alpha');
77$backtopage =
GETPOST(
'backtopage',
'alpha');
78$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
80$origin =
GETPOST(
'origin',
'alpha');
82$confirm =
GETPOST(
'confirm',
'alpha');
97$hookmanager->initHooks(array(
'supplier_proposalcard',
'globalcard'));
105$extrafields->fetch_name_optionals_label(
$object->table_element);
108if ($id > 0 || !empty($ref)) {
109 $ret =
$object->fetch($id, $ref);
111 $ret =
$object->fetch_thirdparty();
120$usercanread = $user->hasRight(
'supplier_proposal',
'lire');
121$usercancreate = $user->hasRight(
'supplier_proposal',
'creer');
122$usercandelete = $user->hasRight(
'supplier_proposal',
'supprimer');
125$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'supplier_proposal',
'validate_advance')));
126$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'supplier_proposal',
'send_advance'));
129$usercanclose = $user->hasRight(
'supplier_proposal',
'cloturer');
130$usercancreateorder = ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'));
133$permissionnote = $usercancreate;
134$permissiondellink = $usercancreate;
135$permissiontoedit = $usercancreate;
136$permissiontoadd = $usercancreate;
137$permissiontoeditextra = $permissiontoadd;
138if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
140 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
144if (!empty($user->socid)) {
145 $socid = $user->socid;
154$parameters = array(
'socid' => $socid);
155$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
160if (empty($reshook)) {
161 $backurlforlist = DOL_URL_ROOT.
'/supplier_proposal/list.php';
163 if (empty($backtopage) || ($cancel && empty($id))) {
164 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
165 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
166 $backtopage = $backurlforlist;
168 $backtopage = DOL_URL_ROOT.
'/supplier_proposal/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
174 if (!empty($backtopageforcancel)) {
175 header(
"Location: ".$backtopageforcancel);
177 } elseif (!empty($backtopage)) {
178 header(
"Location: ".$backtopage);
184 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
186 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
188 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
191 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
192 if (
false && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
196 $result =
$object->createFromClone($user, $socid);
198 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
206 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
208 $result =
$object->delete($user);
210 header(
'Location: '.DOL_URL_ROOT.
'/supplier_proposal/list.php');
213 $langs->load(
"errors");
216 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
218 $result =
$object->deleteLine($lineid);
223 $langs->load(
"errors");
229 $outputlangs = $langs;
232 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
233 $outputlangs->setDefaultLang($newlang);
239 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
242 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
244 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
246 $result =
$object->valid($user);
249 $outputlangs = $langs;
252 $newlang =
GETPOST(
'lang_id',
'aZ09');
255 $newlang =
$object->thirdparty->default_lang;
257 if (!empty($newlang)) {
259 $outputlangs->setDefaultLang($newlang);
267 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
270 $langs->load(
"errors");
271 if (count(
$object->errors) > 0) {
277 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
282 } elseif ($action ==
'add' && $usercancreate) {
290 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Supplier")),
null,
'errors');
301 if (
GETPOST(
'createmode') ==
'copy' &&
GETPOSTINT(
'copie_supplier_proposal') > 0) {
304 $object->delivery_date = $date_delivery;
311 $object->model_pdf = $model_pdf;
313 $object->user_creation_id = $user->id;
319 setEventMessages($langs->trans(
"ErrorFailedToCopyProposal",
GETPOST(
'copie_supplier_proposal')),
null,
'errors');
323 $object->delivery_date = $date_delivery;
330 $object->model_pdf = $model_pdf;
332 $object->user_creation_id = $user->id;
340 if (isModEnabled(
"multicurrency")) {
341 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
345 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
353 if ($origin && $originid) {
355 $element = $subelement = $origin;
357 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
359 $subelement = $regs[2];
363 if ($element ==
'order') {
364 $element = $subelement =
'commande';
366 if ($element ==
'propal') {
367 $element =
'comm/propal';
368 $subelement =
'propal';
370 if ($element ==
'contract') {
371 $element = $subelement =
'contrat';
373 if ($element ==
'inter') {
374 $element = $subelement =
'fichinter';
376 if ($element ==
'shipping') {
377 $element = $subelement =
'expedition';
381 $object->origin_type = $origin;
382 $object->origin_id = $originid;
387 $object->linked_objects = array_merge(
$object->linked_objects,
GETPOST(
'other_linked_objects',
'array:int'));
394 $classname = ucfirst($subelement);
395 $srcobject =
new $classname($db);
396 '@phan-var-force Commande|Propal|Contrat|Fichinter|Expedition $srcobject';
398 dol_syslog(
"Try to find source object origin=".
$object->origin_type.
" originid=".
$object->origin_id.
" to add lines");
399 $result = $srcobject->fetch(
$object->origin_id);
402 $lines = $srcobject->lines;
403 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
404 $srcobject->fetch_lines();
405 $lines = $srcobject->lines;
409 $num = count($lines);
410 for ($i = 0; $i < $num; $i++) {
411 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
412 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc :
'');
415 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
418 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
423 if (method_exists($lines[$i],
'fetch_optionals')) {
424 $lines[$i]->fetch_optionals();
425 $array_options = $lines[$i]->array_options;
427 $array_options = array();
432 $lines[$i]->subprice,
435 $lines[$i]->localtax1_tx,
436 $lines[$i]->localtax2_tx,
437 $lines[$i]->fk_product,
438 $lines[$i]->remise_percent,
441 $lines[$i]->info_bits,
444 $lines[$i]->special_code,
446 $lines[$i]->fk_fournprice,
450 $lines[$i]->ref_supplier,
463 if ($result > 0 && $lines[$i]->product_type == 9) {
464 $fk_parent_line = $result;
469 $parameters = array(
'objFrom' => $srcobject);
470 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters,
$object, $action);
495 $outputlangs = $langs;
498 $newlang =
GETPOST(
'lang_id',
'aZ09');
501 $newlang =
$object->thirdparty->default_lang;
503 if (!empty($newlang)) {
505 $outputlangs->setDefaultLang($newlang);
509 if (!empty($model)) {
511 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
518 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
531 } elseif ($action ==
'confirm_reopen' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
537 } elseif ($action ==
'close' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
543 } elseif ($action ==
'setstatut' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
546 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"CloseAs")),
null,
'errors');
557 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
560 $triggersendname =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
561 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
562 $trackid =
'spro'.$object->id;
563 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
566 $upload_dir =
$conf->supplier_proposal->dir_output;
567 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
571 if ($action ==
'modif' && $usercancreate) {
576 $outputlangs = $langs;
579 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
580 $outputlangs->setDefaultLang($newlang);
586 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
588 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
600 if ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') && $usercancreate) {
602 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
603 $vat_rate = str_replace(
'*',
'', $vat_rate);
606 foreach (
$object->lines as $line) {
607 $result =
$object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, (
float) $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc,
'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->array_options, $line->ref_fourn, $line->fk_unit, $line->multicurrency_subprice);
609 } elseif ($action ==
'addline' && $usercancreate) {
610 $langs->load(
'errors');
615 $line_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
619 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
621 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
622 if ($prod_entry_mode ==
'free') {
637 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef,
'alpha'),
'', 2) : 0);
638 if (empty($remise_percent)) {
643 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
644 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
646 if (is_array($extralabelsline)) {
648 foreach ($extralabelsline as $key => $value) {
649 unset($_POST[
"options_".$key]);
653 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
654 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
657 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
658 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
662 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' &&
GETPOST(
'multicurrency_price_ht') ===
'') {
663 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPrice")),
null,
'errors');
666 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($line_desc)) {
667 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Description")),
null,
'errors');
670 if (!$error && ($qty >= 0)) {
674 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
678 if ($prod_entry_mode !=
'free' && empty($error)) {
682 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
687 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
688 $idprod = (int) $reg[1];
689 $res = $productsupplier->fetch($idprod);
692 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
694 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
695 if ($productsupplier->fourn_socid != $socid) {
696 $productsupplier->ref_supplier =
'';
699 $fksoctosearch =
$object->thirdparty->id;
700 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
702 } elseif (
GETPOSTINT(
'idprodfournprice') > 0) {
705 $idprod = $productsupplier->get_buyprice(
GETPOSTINT(
'idprodfournprice'), $qtytosearch);
706 $res = $productsupplier->fetch($idprod);
710 $label = $productsupplier->label;
714 $outputlangs = $langs;
716 if (
GETPOST(
'lang_id',
'aZ09')) {
717 $newlang =
GETPOST(
'lang_id',
'aZ09');
719 if (empty($newlang)) {
720 $newlang =
$object->thirdparty->default_lang;
722 if (!empty($newlang)) {
724 $outputlangs->setDefaultLang($newlang);
726 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->
description;
728 $desc = $productsupplier->description;
731 if (!empty($productsupplier->desc_supplier) &&
getDolGlobalString(
'PRODUIT_FOURN_TEXTS')) {
732 $desc = $productsupplier->desc_supplier;
743 $ref_supplier = $productsupplier->ref_supplier;
747 if (!GETPOSTISSET(
'tva_tx')) {
748 $tmpidprodfournprice =
GETPOST(
'idprodfournprice',
'alpha');
749 if (is_numeric($tmpidprodfournprice) && (
int) $tmpidprodfournprice > 0) {
750 $tmpidprodfournprice = (int) $tmpidprodfournprice;
752 $tmpidprodfournprice = 0;
758 if (empty($tva_tx)) {
764 $type = $productsupplier->type;
765 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
766 $price_base_type =
'HT';
768 $pu_devise =
price2num($price_ht_devise,
'CU');
769 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
770 $price_base_type =
'TTC';
772 $pu_devise =
price2num($price_ttc_devise,
'CU');
774 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
775 if (empty(
$object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code !=
$object->multicurrency_code)) {
776 $pu = $productsupplier->fourn_pu;
779 $pu = $productsupplier->fourn_pu;
780 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
789 $fournprice = (is_numeric(
GETPOST(
'idprodfournprice',
'alpha')) ?
GETPOST(
'idprodfournprice',
'alpha') : -1);
794 ($price_base_type ==
'HT' ? $pu : 0),
799 $productsupplier->id,
802 ($price_base_type ==
'TTC' ? $pu : 0),
805 min($rank, count(
$object->lines) + 1),
813 $productsupplier->fk_unit,
829 if ($idprod == -99 || $idprod == 0) {
832 $langs->load(
"errors");
833 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")).
' '.$langs->trans(
"or").
' '.$langs->trans(
"NoPriceDefinedForThisSupplier"),
null,
'errors');
838 $langs->load(
"errors");
839 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
841 } elseif ((
GETPOST(
'price_ht') !==
'' ||
GETPOST(
'price_ttc') !==
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') && empty($error)) {
845 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
846 $tva_tx = str_replace(
'*',
'', $tva_tx);
847 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
853 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
861 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
865 $pu_ht =
price2num((
float) $pu_ttc / (1 + ((
float) $tva_tx / 100)),
'MU');
867 $price_base_type =
'HT';
868 $pu_ht_devise =
price2num($price_ht_devise,
'CU');
895 (
float) $pu_ht_devise
900 if (!$error && $result > 0) {
907 $outputlangs = $langs;
910 $newlang =
GETPOST(
'lang_id',
'aZ09');
913 $newlang =
$object->thirdparty->default_lang;
915 if (!empty($newlang)) {
917 $outputlangs->setDefaultLang($newlang);
925 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
931 unset($_POST[
'prod_entry_mode']);
933 unset($_POST[
'qty']);
934 unset($_POST[
'type']);
935 unset($_POST[
'remise_percent']);
937 unset($_POST[
'price_ht']);
938 unset($_POST[
'multicurrency_price_ht']);
939 unset($_POST[
'price_ttc']);
940 unset($_POST[
'fourn_ref']);
941 unset($_POST[
'tva_tx']);
942 unset($_POST[
'label']);
943 unset($_POST[
'product_ref']);
944 unset($_POST[
'product_label']);
945 unset($_POST[
'product_desc']);
946 unset($_POST[
'fournprice']);
947 unset($_POST[
'buying_price']);
948 unset($localtax1_tx);
949 unset($localtax2_tx);
950 unset($_POST[
'np_marginRate']);
951 unset($_POST[
'np_markRate']);
952 unset($_POST[
'dp_desc']);
953 unset($_POST[
'idprodfournprice']);
954 unset($_POST[
'units']);
956 unset($_POST[
'idprod']);
958 unset($_POST[
'date_starthour']);
959 unset($_POST[
'date_startmin']);
960 unset($_POST[
'date_startsec']);
961 unset($_POST[
'date_startday']);
962 unset($_POST[
'date_startmonth']);
963 unset($_POST[
'date_startyear']);
964 unset($_POST[
'date_endhour']);
965 unset($_POST[
'date_endmin']);
966 unset($_POST[
'date_endsec']);
967 unset($_POST[
'date_endday']);
968 unset($_POST[
'date_endmonth']);
969 unset($_POST[
'date_endyear']);
976 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save') == $langs->trans(
"Save")) {
982 if (preg_match(
'/\*/', $vat_rate)) {
990 $vat_rate = str_replace(
'*',
'', $vat_rate);
994 if (
GETPOST(
'price_ht') !=
'') {
995 $price_base_type =
'HT';
999 $vatratecleaned = $vat_rate;
1000 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) {
1001 $vatratecleaned = trim($reg[1]);
1002 $vatratecode = $reg[2];
1006 $ht = (float) $ttc / (1 + ((
float) $vatratecleaned / 100));
1007 $price_base_type =
'HT';
1017 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1018 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1020 if (is_array($extralabelsline)) {
1021 foreach ($extralabelsline as $key => $value) {
1022 unset($_POST[
"options_".$key]);
1027 $special_code =
GETPOST(
'special_code');
1034 if (!empty($productid)) {
1036 if (
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY') == 1) {
1037 if ($productid > 0 && $productsupplier->get_buyprice(0, (
float)
price2num(
GETPOST(
'qty')), $productid,
'none',
GETPOSTINT(
'socid')) < 0) {
1038 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1043 $res = $product->fetch($productid);
1045 $type = $product->type;
1047 $price_min = $product->price_min;
1049 $price_min = $product->multiprices_min [
$object->thirdparty->price_level];
1055 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1059 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1067 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1070 $result =
$object->updateline(
1091 (
float) $pu_ht_devise
1099 $outputlangs = $langs;
1102 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
1103 $outputlangs->setDefaultLang($newlang);
1106 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1109 unset($_POST[
'qty']);
1110 unset($_POST[
'type']);
1111 unset($_POST[
'productid']);
1112 unset($_POST[
'remise_percent']);
1113 unset($_POST[
'price_ht']);
1114 unset($_POST[
'multicurrency_price_ht']);
1115 unset($_POST[
'price_ttc']);
1116 unset($_POST[
'tva_tx']);
1117 unset($_POST[
'product_ref']);
1118 unset($_POST[
'product_label']);
1119 unset($_POST[
'product_desc']);
1120 unset($_POST[
'fournprice']);
1121 unset($_POST[
'buying_price']);
1123 unset($_POST[
'date_starthour']);
1124 unset($_POST[
'date_startmin']);
1125 unset($_POST[
'date_startsec']);
1126 unset($_POST[
'date_startday']);
1127 unset($_POST[
'date_startmonth']);
1128 unset($_POST[
'date_startyear']);
1129 unset($_POST[
'date_endhour']);
1130 unset($_POST[
'date_endmin']);
1131 unset($_POST[
'date_endsec']);
1132 unset($_POST[
'date_endday']);
1133 unset($_POST[
'date_endmonth']);
1134 unset($_POST[
'date_endyear']);
1141 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha') == $langs->trans(
"Cancel")) {
1142 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
1144 } elseif ($action ==
'classin' && $usercancreate) {
1147 } elseif ($action ==
'setavailability' && $usercancreate) {
1150 } elseif ($action ==
'setconditions' && $usercancreate) {
1157 } elseif ($action ==
'setmode' && $usercancreate) {
1160 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
1162 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
1163 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
1166 } elseif ($action ==
'update_extras' && $permissiontoeditextra) {
1169 $attribute_name =
GETPOST(
'attribute',
'aZ09');
1172 $ret = $extrafields->setOptionalsFromPost(
null,
$object, $attribute_name);
1178 $result =
$object->updateExtraField($attribute_name,
'PROPOSAL_SUPPLIER_MODIFY');
1186 $action =
'edit_extras';
1196$title =
$object->ref.
" - ".$langs->trans(
'Card');
1197if ($action ==
'create') {
1198 $title = $langs->trans(
"SupplierProposalNew");
1200$help_url =
'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur';
1202llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-supplierproposal page-card');
1204$form =
new Form($db);
1208$companystatic =
new Societe($db);
1209if (isModEnabled(
'project')) {
1216if ($action ==
'create') {
1217 $currency_code =
$conf->currency;
1219 print
load_fiche_titre($langs->trans(
"SupplierProposalNew"),
'',
'supplier_proposal');
1223 $res = $soc->fetch($socid);
1227 if (!empty($origin) && !empty($originid)) {
1228 $element = $subelement =
GETPOST(
'origin');
1230 if (preg_match(
'/^([^_]+)_([^_]+)/i',
GETPOST(
'origin'), $regs)) {
1231 $element = $regs[1];
1232 $subelement = $regs[2];
1236 if ($element ==
'order' || $element ==
'commande') {
1237 $element = $subelement =
'commande';
1239 if ($element ==
'propal') {
1240 $element =
'comm/propal';
1241 $subelement =
'propal';
1246 $classname = ucfirst($subelement);
1247 $objectsrc =
new $classname($db);
1248 '@phan-var-force Commande|Propal|CommandeFournisseur|SupplierProposal $objectsrc';
1249 $objectsrc->fetch($originid);
1250 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1251 $objectsrc->fetch_lines();
1253 $objectsrc->fetch_thirdparty();
1255 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
1256 $soc = $objectsrc->thirdparty;
1258 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1259 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1262 $objectsrc->fetch_optionals();
1263 $object->array_options = $objectsrc->array_options;
1265 if (isModEnabled(
"multicurrency")) {
1266 if (!empty($objectsrc->multicurrency_code)) {
1267 $currency_code = $objectsrc->multicurrency_code;
1269 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
1270 $currency_tx = $objectsrc->multicurrency_tx;
1274 $cond_reglement_id = $soc->cond_reglement_supplier_id;
1275 $mode_reglement_id = $soc->mode_reglement_supplier_id;
1276 if (isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
1277 $currency_code = $soc->multicurrency_code;
1283 print
'<form name="addprop" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1284 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1285 print
'<input type="hidden" name="action" value="add">';
1286 if ($origin !=
'project' && $originid) {
1287 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1288 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1290 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1295 $parameters = array();
1297 $reshook = $hookmanager->executeHooks(
'tabContentCreateSupplierProposal', $parameters,
$object, $action);
1298 if (empty($reshook)) {
1299 print
'<table class="border centpercent">';
1302 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td colspan="2">'.$langs->trans(
"Draft").
'</td></tr>';
1306 print
'<td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
1308 print
'<td colspan="2">';
1309 print $soc->getNomUrl(1,
'supplier');
1310 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1313 print
'<td colspan="2">';
1314 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
1315 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company((empty($socid) ?
'' : $socid),
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1319 $(document).ready(function() {
1320 $("#socid").change(function() {
1321 console.log("We have changed the company - Reload page");
1323 $("input[name=action]").val("create");
1324 $("form[name=addprop]").submit();
1329 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>';
1336 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
1338 $absolute_discount = $soc->getAvailableDiscounts(
null,
'', 0, 1);
1342 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
1343 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1349 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td colspan="2">';
1350 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
1351 print $form->getSelectConditionsPaiements(
GETPOST(
'cond_reglement_id') > 0 ?
GETPOSTINT(
'cond_reglement_id') : $cond_reglement_id,
'cond_reglement_id', -1, 1);
1355 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td colspan="2">';
1356 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1357 $form->select_types_paiements(
GETPOST(
'mode_reglement_id') > 0 ?
GETPOST(
'mode_reglement_id') : $mode_reglement_id,
'mode_reglement_id');
1361 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') && isModEnabled(
"bank")) {
1362 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td colspan="2">';
1363 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1364 $form->select_comptes(
GETPOST(
'fk_account') > 0 ?
GETPOSTINT(
'fk_account') : $fk_account,
'fk_account', 0,
'', 1);
1369 if (isModEnabled(
"shipping")) {
1370 print
'<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td colspan="2">';
1371 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1372 $form->selectShippingMethod(
GETPOST(
'shipping_method_id') > 0 ?
GETPOSTINT(
'shipping_method_id') :
"",
'shipping_method_id',
'', 1);
1377 print
'<tr><td>'.$langs->trans(
"DeliveryDate").
'</td>';
1378 print
'<td colspan="2">';
1379 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1382 $tmpdte = time() + (7 *
getDolGlobalInt(
'DATE_LIVRAISON_WEEK_DELAY') * 24 * 60 * 60);
1383 $syear = date(
"Y", $tmpdte);
1384 $smonth = date(
"m", $tmpdte);
1385 $sday = date(
"d", $tmpdte);
1386 print $form->selectDate($syear.
"-".$smonth.
"-".$sday,
'liv_', 0, 0, 0,
"addask");
1388 print $form->selectDate($datedelivery ? $datedelivery : -1,
'liv_', 0, 0, 0,
"addask", 1, 1);
1395 print
'<td>'.$langs->trans(
"DefaultModel").
'</td>';
1396 print
'<td colspan="2">';
1397 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1400 print $form->selectarray(
'model', $list, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1404 if (isModEnabled(
'project')) {
1405 $langs->load(
"projects");
1409 if ($origin ==
'project') {
1410 $projectid = ($originid ? $originid : 0);
1414 print
'<td>'.$langs->trans(
"Project").
'</td><td colspan="2">';
1416 $canLinkAll = ($canLinkAll ===
'' || $canLinkAll ===
false) ? 0 : $canLinkAll;
1418 $projectSocId = ((int) $canLinkAll == 1) ? -1 : $currentSocId;
1419 print
img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects($projectSocId, $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
1420 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.$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>';
1427 if (isModEnabled(
"multicurrency")) {
1429 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'',
$object, 0).
'</td>';
1430 print
'<td colspan="3" class="maxwidthonsmartphone">';
1431 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
1432 print $form->selectMultiCurrency($currency_code,
'multicurrency_code');
1437 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' => 3);
1438 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1439 print $hookmanager->resPrint;
1440 if (empty($reshook)) {
1441 print
$object->showOptionals($extrafields,
'create', $parameters);
1446 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1448 if ($origin ==
'contrat') {
1452 $objectsrc->update_price(1,
'auto', 1);
1455 print
"\n<!-- ".$classname.
" info -->";
1457 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
1458 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
1459 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
1460 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
1461 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
1463 print
'<tr><td>'.$langs->trans(
'CommRequest').
'</td><td colspan="2">'.$objectsrc->getNomUrl(1).
'</td></tr>';
1464 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td colspan="2">'.
price($objectsrc->total_ht).
'</td></tr>';
1465 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td colspan="2">'.
price($objectsrc->total_tva).
"</td></tr>";
1466 if ($mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
1467 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax1).
"</td></tr>";
1470 if ($mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
1471 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax2).
"</td></tr>";
1473 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td colspan="2">'.
price($objectsrc->total_ttc).
"</td></tr>";
1475 if (isModEnabled(
"multicurrency")) {
1476 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
1477 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
1478 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
1490 print
'<input type="hidden" name="createmode" value="empty">';
1494 print
'<br><table>';
1498 print
'<td><input type="radio" name="createmode" value="copy"></td>';
1499 print
'<td>'.$langs->trans(
"CopyAskFrom").
' </td>';
1501 $liste_ask = array();
1502 $liste_ask [0] =
'';
1504 $sql =
"SELECT p.rowid as id, p.ref, s.nom";
1505 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal p";
1506 $sql .=
", ".MAIN_DB_PREFIX.
"societe s";
1507 $sql .=
" WHERE s.rowid = p.fk_soc";
1508 $sql .=
" AND p.entityy IN (".getEntity(
'supplier_proposal').
")";
1509 $sql .=
" AND p.fk_statut <> ".SupplierProposal::STATUS_DRAFT;
1510 $sql .=
" ORDER BY Id";
1512 $resql = $db->query($sql);
1514 $num = $db->num_rows($resql);
1517 $row = $db->fetch_row($resql);
1518 $askPriceSupplierRefAndSocName = $row[1].
" - ".$row[2];
1519 $liste_ask[$row[0]] = $askPriceSupplierRefAndSocName;
1522 print $form->selectarray(
"copie_supplier_proposal", $liste_ask, 0);
1528 print
'<tr><td class="tdtop"><input type="radio" name="createmode" value="empty" checked></td>';
1529 print
'<td valign="top" colspan="2">'.$langs->trans(
"CreateEmptyAsk").
'</td></tr>';
1539 print $form->buttonsSaveCancel(
"CreateDraft");
1545 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1548 $title = $langs->trans(
'ProductsAndServices');
1551 print
'<div class="div-table-responsive-no-min">';
1552 print
'<table class="noborder centpercent">';
1554 $objectsrc->printOriginLinesList();
1568 print
dol_get_fiche_head($head,
'comm', $langs->trans(
'CommRequest'), -1,
'supplier_proposal', 0,
'',
'', 0,
'', 1);
1573 if ($action ==
'clone') {
1574 $filter =
'(s.fournisseur:=:1)';
1576 $formquestion = array(
1584 'label' => $langs->trans(
"SelectThirdParty"),
1585 'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter))
1588 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
1589 } elseif ($action ==
'delete') {
1591 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteAsk'), $langs->trans(
'ConfirmDeleteAsk',
$object->ref),
'confirm_delete',
'', 0, 1);
1592 } elseif ($action ==
'reopen') {
1594 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ReOpen'), $langs->trans(
'ConfirmReOpenAsk',
$object->ref),
'confirm_reopen',
'', 0, 1);
1595 } elseif ($action ==
'ask_deleteline') {
1597 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
1598 } elseif ($action ==
'validate') {
1603 $ref = substr(
$object->ref, 1, 4);
1604 if ($ref ==
'PROV') {
1605 $numref =
$object->getNextNumRef($soc);
1606 if (empty($numref)) {
1614 $text = $langs->trans(
'ConfirmValidateAsk', $numref);
1615 if (isModEnabled(
'notification')) {
1616 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
1617 $notify =
new Notify($db);
1619 $text .= $notify->confirmMessage(
'PROPOSAL_SUPPLIER_VALIDATE',
$object->socid,
$object);
1623 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateAsk'), $text,
'confirm_validate',
'', 0, 1);
1628 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
1629 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
1630 if (empty($reshook)) {
1631 $formconfirm .= $hookmanager->resPrint;
1632 } elseif ($reshook > 0) {
1633 $formconfirm = $hookmanager->resPrint;
1641 $linkback =
'<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1644 $morehtmlref =
'<div class="refidno">';
1649 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'supplier');
1651 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.
$object->thirdparty->id.
'&search_societe='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherProposals").
'</a>)';
1654 if (isModEnabled(
'project')) {
1655 $langs->load(
"projects");
1656 $morehtmlref .=
'<br>';
1657 if ($usercancreate) {
1658 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
1659 if ($action !=
'classify') {
1660 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
1663 $canLinkAll = ($canLinkAll ===
'' || $canLinkAll ===
false) ? 0 : $canLinkAll;
1665 $projectSocId = ((int) $canLinkAll == 1) ? -1 : $currentSocId;
1666 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $projectSocId,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
1668 if (!empty(
$object->fk_project)) {
1670 $proj->fetch(
$object->fk_project);
1671 $morehtmlref .= $proj->getNomUrl(1);
1673 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
1678 $morehtmlref .=
'</div>';
1681 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1684 $parameters = array();
1686 $reshook = $hookmanager->executeHooks(
'tabContentViewSupplierProposal', $parameters,
$object, $action);
1687 if (empty($reshook)) {
1688 print
'<div class="fichecenter">';
1689 print
'<div class="fichehalfleft">';
1690 print
'<div class="underbanner clearboth"></div>';
1692 print
'<table class="border tableforfield centpercent">';
1696 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
1697 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
1699 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
1700 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
1703 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td>';
1705 $absolute_discount = $soc->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
1706 $absolute_creditnote = $soc->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
1707 $absolute_discount =
price2num($absolute_discount,
'MT');
1708 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
1712 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
1713 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1718 print
'<tr><td class="titlefield">';
1719 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1720 print $langs->trans(
'PaymentConditionsShort');
1723 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>';
1725 print
'</tr></table>';
1726 print
'</td><td class="valuefield">';
1727 if ($action ==
'editconditions') {
1728 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 1);
1730 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'none', 1);
1736 $langs->load(
'deliveries');
1738 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1739 print $langs->trans(
'DeliveryDate');
1742 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>';
1744 print
'</tr></table>';
1745 print
'</td><td class="valuefield">';
1746 if ($action ==
'editdate_livraison') {
1747 print
'<form name="editdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post" class="formconsumeproduce">';
1748 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1749 print
'<input type="hidden" name="action" value="setdate_livraison">';
1750 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1751 print $form->selectDate(
$object->delivery_date,
'liv_', 0, 0, 0,
"editdate_livraison");
1752 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
1763 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1764 print $langs->trans(
'PaymentMode');
1767 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>';
1769 print
'</tr></table>';
1770 print
'</td><td class="valuefield">';
1771 if ($action ==
'editmode') {
1772 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
1774 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
1791 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') && isModEnabled(
"bank")) {
1794 print
'<table width="100%" class="nobordernopadding"><tr><td>';
1795 print $langs->trans(
'BankAccount');
1797 if ($action !=
'editbankaccount' && $usercancreate) {
1798 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>';
1800 print
'</tr></table>';
1801 print
'</td><td class="valuefield">';
1802 if ($action ==
'editbankaccount') {
1803 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
1805 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'none');
1812 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1817 print
'<div class="fichehalfright">';
1818 print
'<div class="underbanner clearboth"></div>';
1820 print
'<table class="border tableforfield centpercent">';
1822 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
1826 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
1827 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
1828 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
1830 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1836 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
1837 print
'<td class="nowrap amountcard right">' .
price(
$object->total_tva, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
1838 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
1840 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1845 if ($mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
1847 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
1848 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
1849 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
1850 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1854 if ($mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
1856 print
'<td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
1857 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
1858 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
1859 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1867 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
1868 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
1869 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
1871 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1885 print
'<div class="clearboth"></div><br>';
1888 $blocname =
'contacts';
1889 $title = $langs->trans(
'ContactsAddresses');
1890 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
1894 $blocname =
'notes';
1895 $title = $langs->trans(
'Notes');
1896 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
1904 $result =
$object->getLinesArray();
1906 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'#add' :
'').
'" method="POST">
1907 <input type="hidden" name="token" value="' .
newToken().
'">
1908 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
1909 <input type="hidden" name="mode" value="">
1910 <input type="hidden" name="id" value="' .
$object->id.
'">
1911 <input type="hidden" name="backtopage" value="'.$backtopage.
'">
1915 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
1918 print
'<div class="div-table-responsive-no-min">';
1919 print
'<table id="tablelines" class="noborder noshadow centpercent">';
1922 global $forceall, $senderissupplier, $inputalsopricewithtax;
1925 $inputalsopricewithtax = 1;
1926 $senderissupplier = 2;
1927 if (
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY')) {
1928 $senderissupplier =
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY');
1932 $object->printObjectLines($action, $soc, $mysoc, $lineid, $dateSelector);
1937 if ($action !=
'editline') {
1940 $parameters = array(
'dateSelector' => $dateSelector);
1941 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters,
$object, $action);
1945 if (empty($reshook)) {
1946 $object->formAddObjectLine($dateSelector, $soc, $mysoc);
1958 if ($action ==
'statut') {
1960 $form_close =
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST" id="formacceptrefuse" class="formconsumeproduce paddingbottom paddingleft paddingright">';
1961 $form_close .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1962 $form_close .=
'<input type="hidden" name="action" value="setstatut">';
1965 $form_close .=
'<p class="notice">'.$langs->trans(
'SupplierProposalRefFournNotice').
'</p>';
1967 $form_close .=
'<table class="border centpercent marginleftonly marginrightonly">';
1968 $form_close .=
'<tr><td>'.$langs->trans(
"CloseAs").
'</td><td class="left">';
1969 $form_close .=
'<select id="statut" name="statut" class="flat">';
1970 $form_close .=
'<option value="0"> </option>';
1971 $form_close .=
'<option value="2">'.$langs->trans(
'SupplierProposalStatusSigned').
'</option>';
1972 $form_close .=
'<option value="3">'.$langs->trans(
'SupplierProposalStatusNotSigned').
'</option>';
1973 $form_close .=
'</select>';
1974 $form_close .=
'</td></tr>';
1975 $form_close .=
'<tr><td class="left">'.$langs->trans(
'Note').
'</td><td class="left"><textarea cols="70" rows="'.ROWS_3.
'" wrap="soft" name="note">';
1976 $form_close .=
$object->note_private;
1977 $form_close .=
'</textarea></td></tr>';
1978 $form_close .=
'</table>';
1979 $form_close .= $form->buttonsSaveCancel();
1980 $form_close .=
'<a id="acceptedrefused"> </a>';
1981 $form_close .=
'</form>';
1989 if ($action !=
'presend') {
1990 print
'<div class="tabsAction">';
1992 $parameters = array();
1993 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
1995 if (empty($reshook)) {
1996 if ($action !=
'statut' && $action !=
'editline') {
1999 if (count(
$object->lines) > 0) {
2000 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>';
2007 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>';
2012 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').
'"';
2013 print
'>'.$langs->trans(
'ReOpen').
'</a></div>';
2017 if (empty($user->socid)) {
2020 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.
newToken().
'&mode=init#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a></div>';
2022 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
'SendMail').
'</a></div>';
2029 if ($usercancreateorder) {
2030 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>';
2036 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').
'"';
2037 print
'>'.$langs->trans(
'SetAcceptedRefused').
'</a></div>';
2042 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').
'"';
2043 print
'>'.$langs->trans(
'Close').
'</a></div>';
2047 if ($usercancreate) {
2048 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&socid='.
$object->socid.
'&action=clone&object='.
$object->element.
'&token='.
newToken().
'">'.$langs->trans(
"ToClone").
'</a></div>';
2059 if ($action !=
'presend') {
2060 print
'<div class="fichecenter"><div class="fichehalfleft">';
2067 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
2068 $genallowed = $usercanread;
2069 $delallowed = $usercancreate;
2071 print $formfile->showdocuments(
'supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
2075 $tmparray = $form->showLinkToObjectBlock(
$object, array(), array(
'supplier_proposal'), 1);
2076 $linktoelem = $tmparray[
'linktoelem'];
2077 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
2078 print $htmltoenteralink;
2080 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
2084 print
'</div><div class="fichehalfright">';
2087 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2089 $somethingshown = $formactions->showactions(
$object,
'supplier_proposal', $socid, 1,
'', $MAXEVENT);
2091 print
'</div></div>';
2095 if (
GETPOST(
'modelselected')) {
2096 $action =
'presend';
2100 $modelmail =
'supplier_proposal_send';
2101 $defaulttopic =
'SendAskRef';
2102 $diroutput =
$conf->supplier_proposal->dir_output;
2103 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
2104 $trackid =
'spro'.$object->id;
2106 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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.
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
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, when selling a product with vat $vatrate,...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
supplier_proposal_prepare_head($object)
Prepare array with list of tabs.