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';
56$langs->loadLangs(array(
'companies',
'supplier_proposal',
'compta',
'bills',
'propal',
'orders',
'products',
'deliveries',
'sendings'));
57if (isModEnabled(
'margin')) {
58 $langs->load(
'margins');
66$action =
GETPOST(
'action',
'aZ09');
67$cancel =
GETPOST(
'cancel',
'alpha');
68$backtopage =
GETPOST(
'backtopage',
'alpha');
69$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
71$origin =
GETPOST(
'origin',
'alpha');
73$confirm =
GETPOST(
'confirm',
'alpha');
88$hookmanager->initHooks(array(
'supplier_proposalcard',
'globalcard'));
96$extrafields->fetch_name_optionals_label(
$object->table_element);
99if ($id > 0 || !empty($ref)) {
100 $ret =
$object->fetch($id, $ref);
102 $ret =
$object->fetch_thirdparty();
111$usercanread = $user->hasRight(
'supplier_proposal',
'lire');
112$usercancreate = $user->hasRight(
'supplier_proposal',
'creer');
113$usercandelete = $user->hasRight(
'supplier_proposal',
'supprimer');
116$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'supplier_proposal',
'validate_advance')));
117$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'supplier_proposal',
'send_advance'));
120$usercanclose = $user->hasRight(
'supplier_proposal',
'cloturer');
121$usercancreateorder = ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'));
124$permissionnote = $usercancreate;
125$permissiondellink = $usercancreate;
126$permissiontoedit = $usercancreate;
127$permissiontoadd = $usercancreate;
130if (!empty($user->socid)) {
131 $socid = $user->socid;
140$parameters = array(
'socid' => $socid);
141$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
146if (empty($reshook)) {
147 $backurlforlist = DOL_URL_ROOT.
'/supplier_proposal/list.php';
149 if (empty($backtopage) || ($cancel && empty($id))) {
150 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
151 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
152 $backtopage = $backurlforlist;
154 $backtopage = DOL_URL_ROOT.
'/supplier_proposal/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
160 if (!empty($backtopageforcancel)) {
161 header(
"Location: ".$backtopageforcancel);
163 } elseif (!empty($backtopage)) {
164 header(
"Location: ".$backtopage);
170 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
172 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
174 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
177 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
178 if (
false && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
182 $result =
$object->createFromClone($user, $socid);
184 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
192 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
194 $result =
$object->delete($user);
196 header(
'Location: '.DOL_URL_ROOT.
'/supplier_proposal/list.php');
199 $langs->load(
"errors");
202 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
204 $result =
$object->deleteLine($lineid);
209 $langs->load(
"errors");
215 $outputlangs = $langs;
218 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
219 $outputlangs->setDefaultLang($newlang);
225 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
228 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
230 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
232 $result =
$object->valid($user);
235 $outputlangs = $langs;
238 $newlang =
GETPOST(
'lang_id',
'aZ09');
241 $newlang =
$object->thirdparty->default_lang;
243 if (!empty($newlang)) {
245 $outputlangs->setDefaultLang($newlang);
253 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
256 $langs->load(
"errors");
257 if (count(
$object->errors) > 0) {
263 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
268 } elseif ($action ==
'add' && $usercancreate) {
276 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Supplier")),
null,
'errors');
285 if (
GETPOST(
'createmode') ==
'copy' &&
GETPOST(
'copie_supplier_proposal')) {
288 $object->delivery_date = $date_delivery;
301 setEventMessages($langs->trans(
"ErrorFailedToCopyProposal",
GETPOST(
'copie_supplier_proposal')),
null,
'errors');
305 $object->delivery_date = $date_delivery;
321 if (isModEnabled(
"multicurrency")) {
322 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
326 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
334 if ($origin && $originid) {
336 $element = $subelement = $origin;
337 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
339 $subelement = $regs[2];
343 if ($element ==
'order') {
344 $element = $subelement =
'commande';
346 if ($element ==
'propal') {
347 $element =
'comm/propal';
348 $subelement =
'propal';
350 if ($element ==
'contract') {
351 $element = $subelement =
'contrat';
353 if ($element ==
'inter') {
354 $element = $subelement =
'fichinter';
356 if ($element ==
'shipping') {
357 $element = $subelement =
'expedition';
361 $object->origin_id = $originid;
366 $object->linked_objects = array_merge(
$object->linked_objects,
GETPOST(
'other_linked_objects',
'array:int'));
373 $classname = ucfirst($subelement);
374 $srcobject =
new $classname($db);
375 '@phan-var-force Commande|Propal|Contrat|Fichinter|Expedition $srcobject';
378 $result = $srcobject->fetch(
$object->origin_id);
381 $lines = $srcobject->lines;
382 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
383 $srcobject->fetch_lines();
384 $lines = $srcobject->lines;
388 $num = count($lines);
389 for ($i = 0; $i < $num; $i++) {
390 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
391 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc :
'');
394 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
397 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
402 if (method_exists($lines[$i],
'fetch_optionals')) {
403 $lines[$i]->fetch_optionals();
404 $array_options = $lines[$i]->array_options;
406 $array_options = array();
411 $lines[$i]->subprice,
414 $lines[$i]->localtax1_tx,
415 $lines[$i]->localtax2_tx,
416 $lines[$i]->fk_product,
417 $lines[$i]->remise_percent,
420 $lines[$i]->info_bits,
423 $lines[$i]->special_code,
425 $lines[$i]->fk_fournprice,
429 $lines[$i]->ref_supplier,
442 if ($result > 0 && $lines[$i]->product_type == 9) {
443 $fk_parent_line = $result;
448 $parameters = array(
'objFrom' => $srcobject);
449 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters,
$object, $action);
474 $outputlangs = $langs;
477 $newlang =
GETPOST(
'lang_id',
'aZ09');
480 $newlang =
$object->thirdparty->default_lang;
482 if (!empty($newlang)) {
484 $outputlangs->setDefaultLang($newlang);
489 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
495 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
508 } elseif ($action ==
'confirm_reopen' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
514 } elseif ($action ==
'close' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
520 } elseif ($action ==
'setstatut' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
523 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"CloseAs")),
null,
'errors');
534 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
537 $triggersendname =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
538 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
539 $trackid =
'spro'.$object->id;
540 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
543 $upload_dir = $conf->supplier_proposal->dir_output;
544 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
548 if ($action ==
'modif' && $usercancreate) {
553 $outputlangs = $langs;
556 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
557 $outputlangs->setDefaultLang($newlang);
563 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
565 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
577 if ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') && $usercancreate) {
579 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
580 $vat_rate = str_replace(
'*',
'', $vat_rate);
583 foreach (
$object->lines as $line) {
584 $result =
$object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc,
'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->array_options, $line->ref_fourn, $line->fk_unit, $line->multicurrency_subprice);
586 } elseif ($action ==
'addline' && $usercancreate) {
587 $langs->load(
'errors');
592 $product_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
596 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
598 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
599 if ($prod_entry_mode ==
'free') {
614 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef,
'alpha'),
'', 2) : 0);
615 if (empty($remise_percent)) {
620 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
621 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
623 if (is_array($extralabelsline)) {
625 foreach ($extralabelsline as $key => $value) {
626 unset($_POST[
"options_".$key]);
630 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
631 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
634 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
635 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
639 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' &&
GETPOST(
'multicurrency_price_ht') ===
'') {
640 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPrice")),
null,
'errors');
643 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
644 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Description")),
null,
'errors');
647 if (!$error && ($qty >= 0)) {
651 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
655 if ($prod_entry_mode !=
'free' && empty($error)) {
659 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
664 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
666 $res = $productsupplier->fetch($idprod);
669 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
671 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
672 if ($productsupplier->fourn_socid != $socid) {
673 $productsupplier->ref_supplier =
'';
676 $fksoctosearch =
$object->thirdparty->id;
677 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
679 } elseif (
GETPOST(
'idprodfournprice',
'alpha') > 0) {
682 $idprod = $productsupplier->get_buyprice(
GETPOST(
'idprodfournprice',
'alpha'), $qtytosearch);
683 $res = $productsupplier->fetch($idprod);
687 $label = $productsupplier->label;
691 $outputlangs = $langs;
693 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
694 $newlang =
GETPOST(
'lang_id',
'aZ09');
696 if (empty($newlang)) {
697 $newlang =
$object->thirdparty->default_lang;
699 if (!empty($newlang)) {
701 $outputlangs->setDefaultLang($newlang);
703 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->
description;
705 $desc = $productsupplier->description;
708 if (!empty($productsupplier->desc_supplier) &&
getDolGlobalString(
'PRODUIT_FOURN_TEXTS')) {
709 $desc = $productsupplier->desc_supplier;
713 if (trim($product_desc) == trim($desc) &&
getDolGlobalString(
'PRODUIT_AUTOFILL_DESC')) {
718 $desc = $product_desc;
720 if (!empty($product_desc) && trim($product_desc) != trim($desc)) {
724 $ref_supplier = $productsupplier->ref_supplier;
728 if (!GETPOSTISSET(
'tva_tx')) {
729 $tmpidprodfournprice =
GETPOST(
'idprodfournprice',
'alpha');
730 if (is_numeric($tmpidprodfournprice) && (
int) $tmpidprodfournprice > 0) {
731 $tmpidprodfournprice = (int) $tmpidprodfournprice;
733 $tmpidprodfournprice = 0;
739 if (empty($tva_tx)) {
745 $type = $productsupplier->type;
746 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
747 $price_base_type =
'HT';
749 $pu_devise =
price2num($price_ht_devise,
'CU');
750 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
751 $price_base_type =
'TTC';
753 $pu_devise =
price2num($price_ttc_devise,
'CU');
755 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
756 if (empty(
$object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code !=
$object->multicurrency_code)) {
757 $pu = $productsupplier->fourn_pu;
760 $pu = $productsupplier->fourn_pu;
761 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
770 $fournprice = (is_numeric(
GETPOST(
'idprodfournprice',
'alpha')) ?
GETPOST(
'idprodfournprice',
'alpha') : -1);
775 ($price_base_type ==
'HT' ? $pu : 0),
780 $productsupplier->id,
783 ($price_base_type ==
'TTC' ? $pu : 0),
786 min($rank, count(
$object->lines) + 1),
794 $productsupplier->fk_unit,
810 if ($idprod == -99 || $idprod == 0) {
813 $langs->load(
"errors");
814 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")).
' '.$langs->trans(
"or").
' '.$langs->trans(
"NoPriceDefinedForThisSupplier"),
null,
'errors');
819 $langs->load(
"errors");
820 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
822 } elseif ((
GETPOST(
'price_ht') !==
'' ||
GETPOST(
'price_ttc') !==
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') && empty($error)) {
826 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
827 $tva_tx = str_replace(
'*',
'', $tva_tx);
828 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
829 $desc = $product_desc;
832 $fk_unit =
GETPOST(
'units',
'alpha');
834 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
842 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
846 $pu_ht =
price2num((
float) $pu_ttc / (1 + ((
float) $tva_tx / 100)),
'MU');
848 $price_base_type =
'HT';
849 $pu_ht_devise =
price2num($price_ht_devise,
'CU');
881 if (!$error && $result > 0) {
888 $outputlangs = $langs;
891 $newlang =
GETPOST(
'lang_id',
'aZ09');
894 $newlang =
$object->thirdparty->default_lang;
896 if (!empty($newlang)) {
898 $outputlangs->setDefaultLang($newlang);
906 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
912 unset($_POST[
'prod_entry_mode']);
914 unset($_POST[
'qty']);
915 unset($_POST[
'type']);
916 unset($_POST[
'remise_percent']);
918 unset($_POST[
'price_ht']);
919 unset($_POST[
'multicurrency_price_ht']);
920 unset($_POST[
'price_ttc']);
921 unset($_POST[
'fourn_ref']);
922 unset($_POST[
'tva_tx']);
923 unset($_POST[
'label']);
924 unset($_POST[
'product_ref']);
925 unset($_POST[
'product_label']);
926 unset($_POST[
'product_desc']);
927 unset($_POST[
'fournprice']);
928 unset($_POST[
'buying_price']);
929 unset($localtax1_tx);
930 unset($localtax2_tx);
931 unset($_POST[
'np_marginRate']);
932 unset($_POST[
'np_markRate']);
933 unset($_POST[
'dp_desc']);
934 unset($_POST[
'idprodfournprice']);
935 unset($_POST[
'units']);
937 unset($_POST[
'idprod']);
939 unset($_POST[
'date_starthour']);
940 unset($_POST[
'date_startmin']);
941 unset($_POST[
'date_startsec']);
942 unset($_POST[
'date_startday']);
943 unset($_POST[
'date_startmonth']);
944 unset($_POST[
'date_startyear']);
945 unset($_POST[
'date_endhour']);
946 unset($_POST[
'date_endmin']);
947 unset($_POST[
'date_endsec']);
948 unset($_POST[
'date_endday']);
949 unset($_POST[
'date_endmonth']);
950 unset($_POST[
'date_endyear']);
957 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save') == $langs->trans(
"Save")) {
963 if (preg_match(
'/\*/', $vat_rate)) {
971 $vat_rate = str_replace(
'*',
'', $vat_rate);
975 if (
GETPOST(
'price_ht') !=
'') {
976 $price_base_type =
'HT';
980 $vatratecleaned = $vat_rate;
981 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) {
982 $vatratecleaned = trim($reg[1]);
983 $vatratecode = $reg[2];
987 $ht = (float) $ttc / (1 + ((
float) $vatratecleaned / 100));
988 $price_base_type =
'HT';
994 $fournprice = (
GETPOST(
'fournprice') ?
GETPOST(
'fournprice') :
'');
995 $buyingprice = (
GETPOST(
'buying_price') !=
'' ?
GETPOST(
'buying_price') :
'');
998 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
999 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1001 if (is_array($extralabelsline)) {
1002 foreach ($extralabelsline as $key => $value) {
1003 unset($_POST[
"options_".$key]);
1008 $special_code =
GETPOST(
'special_code');
1015 if (!empty($productid)) {
1018 if ($productid > 0 && $productsupplier->get_buyprice(0,
price2num(
GETPOST(
'qty')), $productid,
'none',
GETPOSTINT(
'socid')) < 0) {
1019 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1024 $res = $product->fetch($productid);
1026 $type = $product->type;
1028 $price_min = $product->price_min;
1030 $price_min = $product->multiprices_min [
$object->thirdparty->price_level];
1036 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1040 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1048 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1051 $result =
$object->updateline(
1080 $outputlangs = $langs;
1082 $outputlangs =
new Translate(
"", $conf);
1083 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
1084 $outputlangs->setDefaultLang($newlang);
1087 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1090 unset($_POST[
'qty']);
1091 unset($_POST[
'type']);
1092 unset($_POST[
'productid']);
1093 unset($_POST[
'remise_percent']);
1094 unset($_POST[
'price_ht']);
1095 unset($_POST[
'multicurrency_price_ht']);
1096 unset($_POST[
'price_ttc']);
1097 unset($_POST[
'tva_tx']);
1098 unset($_POST[
'product_ref']);
1099 unset($_POST[
'product_label']);
1100 unset($_POST[
'product_desc']);
1101 unset($_POST[
'fournprice']);
1102 unset($_POST[
'buying_price']);
1104 unset($_POST[
'date_starthour']);
1105 unset($_POST[
'date_startmin']);
1106 unset($_POST[
'date_startsec']);
1107 unset($_POST[
'date_startday']);
1108 unset($_POST[
'date_startmonth']);
1109 unset($_POST[
'date_startyear']);
1110 unset($_POST[
'date_endhour']);
1111 unset($_POST[
'date_endmin']);
1112 unset($_POST[
'date_endsec']);
1113 unset($_POST[
'date_endday']);
1114 unset($_POST[
'date_endmonth']);
1115 unset($_POST[
'date_endyear']);
1122 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha') == $langs->trans(
"Cancel")) {
1123 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
1125 } elseif ($action ==
'classin' && $usercancreate) {
1128 } elseif ($action ==
'setavailability' && $usercancreate) {
1131 } elseif ($action ==
'setconditions' && $usercancreate) {
1138 } elseif ($action ==
'setmode' && $usercancreate) {
1141 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
1143 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
1144 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
1147 } elseif ($action ==
'update_extras' && $usercancreate) {
1149 $attribute_name =
GETPOST(
'attribute',
'restricthtml');
1152 $ret = $extrafields->setOptionalsFromPost(
null,
$object, $attribute_name);
1158 $result =
$object->updateExtraField($attribute_name,
'PROPOSAL_SUPPLIER_MODIFY');
1166 $action =
'edit_extras';
1176$title =
$object->ref.
" - ".$langs->trans(
'Card');
1177if ($action ==
'create') {
1178 $title = $langs->trans(
"SupplierProposalNew");
1180$help_url =
'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur';
1182llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-supplierproposal page-card');
1184$form =
new Form($db);
1188$companystatic =
new Societe($db);
1189if (isModEnabled(
'project')) {
1196if ($action ==
'create') {
1197 $currency_code = $conf->currency;
1199 print
load_fiche_titre($langs->trans(
"SupplierProposalNew"),
'',
'supplier_proposal');
1203 $res = $soc->fetch($socid);
1207 if (!empty($origin) && !empty($originid)) {
1208 $element = $subelement =
GETPOST(
'origin');
1209 if (preg_match(
'/^([^_]+)_([^_]+)/i',
GETPOST(
'origin'), $regs)) {
1210 $element = $regs[1];
1211 $subelement = $regs[2];
1215 if ($element ==
'order' || $element ==
'commande') {
1216 $element = $subelement =
'commande';
1218 if ($element ==
'propal') {
1219 $element =
'comm/propal';
1220 $subelement =
'propal';
1225 $classname = ucfirst($subelement);
1226 $objectsrc =
new $classname($db);
1227 '@phan-var-force Commande|Propal|CommandeFournisseur|SupplierProposal $objectsrc';
1228 $objectsrc->fetch($originid);
1229 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1230 $objectsrc->fetch_lines();
1232 $objectsrc->fetch_thirdparty();
1234 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
1235 $soc = $objectsrc->thirdparty;
1237 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1238 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1241 $objectsrc->fetch_optionals();
1242 $object->array_options = $objectsrc->array_options;
1244 if (isModEnabled(
"multicurrency")) {
1245 if (!empty($objectsrc->multicurrency_code)) {
1246 $currency_code = $objectsrc->multicurrency_code;
1248 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
1249 $currency_tx = $objectsrc->multicurrency_tx;
1253 $cond_reglement_id = $soc->cond_reglement_supplier_id;
1254 $mode_reglement_id = $soc->mode_reglement_supplier_id;
1255 if (isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
1256 $currency_code = $soc->multicurrency_code;
1262 print
'<form name="addprop" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1263 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1264 print
'<input type="hidden" name="action" value="add">';
1265 if ($origin !=
'project' && $originid) {
1266 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1267 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1269 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1274 $parameters = array();
1276 $reshook = $hookmanager->executeHooks(
'tabContentCreateSupplierProposal', $parameters,
$object, $action);
1277 if (empty($reshook)) {
1278 print
'<table class="border centpercent">';
1281 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td colspan="2">'.$langs->trans(
"Draft").
'</td></tr>';
1285 print
'<td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
1287 print
'<td colspan="2">';
1288 print $soc->getNomUrl(1,
'supplier');
1289 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1292 print
'<td colspan="2">';
1293 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
1294 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company((empty($socid) ?
'' : $socid),
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1298 $(document).ready(function() {
1299 $("#socid").change(function() {
1300 console.log("We have changed the company - Reload page");
1302 $("input[name=action]").val("create");
1303 $("form[name=addprop]").submit();
1308 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>';
1315 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
1317 $absolute_discount = $soc->getAvailableDiscounts(
null,
'', 0, 1);
1321 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
1322 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1328 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td colspan="2">';
1329 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
1330 print $form->getSelectConditionsPaiements(
GETPOST(
'cond_reglement_id') > 0 ?
GETPOST(
'cond_reglement_id') : $cond_reglement_id,
'cond_reglement_id', -1, 1);
1334 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td colspan="2">';
1335 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1336 $form->select_types_paiements(
GETPOST(
'mode_reglement_id') > 0 ?
GETPOST(
'mode_reglement_id') : $mode_reglement_id,
'mode_reglement_id');
1340 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') && isModEnabled(
"bank")) {
1341 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td colspan="2">';
1342 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1343 $form->select_comptes(
GETPOST(
'fk_account') > 0 ?
GETPOSTINT(
'fk_account') : $fk_account,
'fk_account', 0,
'', 1);
1348 if (isModEnabled(
"shipping")) {
1349 print
'<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td colspan="2">';
1350 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1351 $form->selectShippingMethod(
GETPOST(
'shipping_method_id') > 0 ?
GETPOSTINT(
'shipping_method_id') :
"",
'shipping_method_id',
'', 1);
1356 print
'<tr><td>'.$langs->trans(
"DeliveryDate").
'</td>';
1357 print
'<td colspan="2">';
1358 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1361 $tmpdte = time() + (7 *
getDolGlobalInt(
'DATE_LIVRAISON_WEEK_DELAY') * 24 * 60 * 60);
1362 $syear = date(
"Y", $tmpdte);
1363 $smonth = date(
"m", $tmpdte);
1364 $sday = date(
"d", $tmpdte);
1365 print $form->selectDate($syear.
"-".$smonth.
"-".$sday,
'liv_', 0, 0, 0,
"addask");
1367 print $form->selectDate($datedelivery ? $datedelivery : -1,
'liv_', 0, 0, 0,
"addask", 1, 1);
1374 print
'<td>'.$langs->trans(
"DefaultModel").
'</td>';
1375 print
'<td colspan="2">';
1376 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1378 $preselected = (
getDolGlobalString(
'SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT') ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT : $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF);
1379 print $form->selectarray(
'model', $list, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1383 if (isModEnabled(
'project')) {
1384 $langs->load(
"projects");
1388 if ($origin ==
'project') {
1389 $projectid = ($originid ? $originid : 0);
1393 print
'<td>'.$langs->trans(
"Project").
'</td><td colspan="2">';
1394 print
img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
1395 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>';
1402 if (isModEnabled(
"multicurrency")) {
1404 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'',
$object, 0).
'</td>';
1405 print
'<td colspan="3" class="maxwidthonsmartphone">';
1406 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
1407 print $form->selectMultiCurrency($currency_code,
'multicurrency_code');
1412 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' => 3);
1413 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1414 print $hookmanager->resPrint;
1415 if (empty($reshook)) {
1416 print
$object->showOptionals($extrafields,
'create', $parameters);
1421 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1423 if ($origin ==
'contrat') {
1427 $objectsrc->update_price(1,
'auto', 1);
1430 print
"\n<!-- ".$classname.
" info -->";
1432 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
1433 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
1434 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
1435 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
1436 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
1438 print
'<tr><td>'.$langs->trans(
'CommRequest').
'</td><td colspan="2">'.$objectsrc->getNomUrl(1).
'</td></tr>';
1439 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td colspan="2">'.
price($objectsrc->total_ht).
'</td></tr>';
1440 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td colspan="2">'.
price($objectsrc->total_tva).
"</td></tr>";
1441 if ($mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
1442 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax1).
"</td></tr>";
1445 if ($mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
1446 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax2).
"</td></tr>";
1448 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td colspan="2">'.
price($objectsrc->total_ttc).
"</td></tr>";
1450 if (isModEnabled(
"multicurrency")) {
1451 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
1452 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
1453 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
1465 print
'<input type="hidden" name="createmode" value="empty">';
1469 print
'<br><table>';
1473 print
'<td><input type="radio" name="createmode" value="copy"></td>';
1474 print
'<td>'.$langs->trans(
"CopyAskFrom").
' </td>';
1476 $liste_ask = array();
1477 $liste_ask [0] =
'';
1479 $sql =
"SELECT p.rowid as id, p.ref, s.nom";
1480 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal p";
1481 $sql .=
", ".MAIN_DB_PREFIX.
"societe s";
1482 $sql .=
" WHERE s.rowid = p.fk_soc";
1483 $sql .=
" AND p.entityy IN (".getEntity(
'supplier_proposal').
")";
1484 $sql .=
" AND p.fk_statut <> ".SupplierProposal::STATUS_DRAFT;
1485 $sql .=
" ORDER BY Id";
1487 $resql = $db->query($sql);
1489 $num = $db->num_rows($resql);
1492 $row = $db->fetch_row($resql);
1493 $askPriceSupplierRefAndSocName = $row[1].
" - ".$row[2];
1494 $liste_ask[$row[0]] = $askPriceSupplierRefAndSocName;
1497 print $form->selectarray(
"copie_supplier_proposal", $liste_ask, 0);
1503 print
'<tr><td class="tdtop"><input type="radio" name="createmode" value="empty" checked></td>';
1504 print
'<td valign="top" colspan="2">'.$langs->trans(
"CreateEmptyAsk").
'</td></tr>';
1514 print $form->buttonsSaveCancel(
"CreateDraft");
1520 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1523 $title = $langs->trans(
'ProductsAndServices');
1526 print
'<div class="div-table-responsive-no-min">';
1527 print
'<table class="noborder centpercent">';
1529 $objectsrc->printOriginLinesList();
1542 $head = supplier_proposal_prepare_head(
$object);
1543 print
dol_get_fiche_head($head,
'comm', $langs->trans(
'CommRequest'), -1,
'supplier_proposal');
1548 if ($action ==
'clone') {
1549 $filter =
'(s.fournisseur:=:1)';
1551 $formquestion = array(
1559 'label' => $langs->trans(
"SelectThirdParty"),
1560 'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter))
1563 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
1564 } elseif ($action ==
'delete') {
1566 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteAsk'), $langs->trans(
'ConfirmDeleteAsk',
$object->ref),
'confirm_delete',
'', 0, 1);
1567 } elseif ($action ==
'reopen') {
1569 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ReOpen'), $langs->trans(
'ConfirmReOpenAsk',
$object->ref),
'confirm_reopen',
'', 0, 1);
1570 } elseif ($action ==
'ask_deleteline') {
1572 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
1573 } elseif ($action ==
'validate') {
1578 $ref = substr(
$object->ref, 1, 4);
1579 if ($ref ==
'PROV') {
1580 $numref =
$object->getNextNumRef($soc);
1581 if (empty($numref)) {
1589 $text = $langs->trans(
'ConfirmValidateAsk', $numref);
1590 if (isModEnabled(
'notification')) {
1591 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
1592 $notify =
new Notify($db);
1594 $text .= $notify->confirmMessage(
'PROPOSAL_SUPPLIER_VALIDATE',
$object->socid,
$object);
1598 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateAsk'), $text,
'confirm_validate',
'', 0, 1);
1603 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
1604 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
1605 if (empty($reshook)) {
1606 $formconfirm .= $hookmanager->resPrint;
1607 } elseif ($reshook > 0) {
1608 $formconfirm = $hookmanager->resPrint;
1616 $linkback =
'<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1619 $morehtmlref =
'<div class="refidno">';
1624 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'supplier');
1626 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.
$object->thirdparty->id.
'&search_societe='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherProposals").
'</a>)';
1629 if (isModEnabled(
'project')) {
1630 $langs->load(
"projects");
1631 $morehtmlref .=
'<br>';
1632 if ($usercancreate) {
1633 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
1634 if ($action !=
'classify') {
1635 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
1637 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
1639 if (!empty(
$object->fk_project)) {
1641 $proj->fetch(
$object->fk_project);
1642 $morehtmlref .= $proj->getNomUrl(1);
1644 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
1649 $morehtmlref .=
'</div>';
1652 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1655 $parameters = array();
1657 $reshook = $hookmanager->executeHooks(
'tabContentViewSupplierProposal', $parameters,
$object, $action);
1658 if (empty($reshook)) {
1659 print
'<div class="fichecenter">';
1660 print
'<div class="fichehalfleft">';
1661 print
'<div class="underbanner clearboth"></div>';
1663 print
'<table class="border tableforfield centpercent">';
1667 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
1668 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
1670 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
1671 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
1674 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td>';
1676 $absolute_discount = $soc->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
1677 $absolute_creditnote = $soc->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
1678 $absolute_discount =
price2num($absolute_discount,
'MT');
1679 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
1683 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
1684 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1689 print
'<tr><td class="titlefield">';
1690 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1691 print $langs->trans(
'PaymentConditionsShort');
1694 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>';
1696 print
'</tr></table>';
1697 print
'</td><td class="valuefield">';
1698 if ($action ==
'editconditions') {
1699 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'cond_reglement_id', 1);
1701 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'none', 1);
1707 $langs->load(
'deliveries');
1709 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1710 print $langs->trans(
'DeliveryDate');
1713 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>';
1715 print
'</tr></table>';
1716 print
'</td><td class="valuefield">';
1717 if ($action ==
'editdate_livraison') {
1718 print
'<form name="editdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post" class="formconsumeproduce">';
1719 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1720 print
'<input type="hidden" name="action" value="setdate_livraison">';
1721 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1722 print $form->selectDate(
$object->delivery_date,
'liv_', 0, 0, 0,
"editdate_livraison");
1723 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
1734 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1735 print $langs->trans(
'PaymentMode');
1738 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>';
1740 print
'</tr></table>';
1741 print
'</td><td class="valuefield">';
1742 if ($action ==
'editmode') {
1743 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
1745 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'none');
1762 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') && isModEnabled(
"bank")) {
1765 print
'<table width="100%" class="nobordernopadding"><tr><td>';
1766 print $langs->trans(
'BankAccount');
1768 if ($action !=
'editbankaccount' && $usercancreate) {
1769 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>';
1771 print
'</tr></table>';
1772 print
'</td><td class="valuefield">';
1773 if ($action ==
'editbankaccount') {
1774 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'fk_account', 1);
1776 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
1783 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1788 print
'<div class="fichehalfright">';
1789 print
'<div class="underbanner clearboth"></div>';
1791 print
'<table class="border tableforfield centpercent">';
1793 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
1797 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
1798 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
1799 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
1801 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1807 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
1808 print
'<td class="nowrap amountcard right">' .
price(
$object->total_tva, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
1809 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
1811 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1816 if ($mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
1818 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
1819 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
1820 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
1821 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1825 if ($mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
1827 print
'<td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
1828 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
1829 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
1830 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1838 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
1839 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ttc, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
1840 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
1842 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1856 print
'<div class="clearboth"></div><br>';
1859 $blocname =
'contacts';
1860 $title = $langs->trans(
'ContactsAddresses');
1861 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
1865 $blocname =
'notes';
1866 $title = $langs->trans(
'Notes');
1867 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
1875 $result =
$object->getLinesArray();
1877 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'#add' :
'').
'" method="POST">
1878 <input type="hidden" name="token" value="' .
newToken().
'">
1879 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
1880 <input type="hidden" name="mode" value="">
1881 <input type="hidden" name="id" value="' .
$object->id.
'">
1882 <input type="hidden" name="backtopage" value="'.$backtopage.
'">
1886 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
1889 print
'<div class="div-table-responsive-no-min">';
1890 print
'<table id="tablelines" class="noborder noshadow centpercent">';
1893 global $forceall, $senderissupplier, $inputalsopricewithtax;
1896 $inputalsopricewithtax = 1;
1897 $senderissupplier = 2;
1899 $senderissupplier = 1;
1903 $object->printObjectLines($action, $soc, $mysoc, $lineid, $dateSelector);
1908 if ($action !=
'editline') {
1911 $parameters = array(
'dateSelector' => $dateSelector);
1912 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters,
$object, $action);
1916 if (empty($reshook)) {
1917 $object->formAddObjectLine($dateSelector, $soc, $mysoc);
1929 if ($action ==
'statut') {
1931 $form_close =
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST" id="formacceptrefuse" class="formconsumeproduce paddingbottom paddingleft paddingright">';
1932 $form_close .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1933 $form_close .=
'<input type="hidden" name="action" value="setstatut">';
1936 $form_close .=
'<p class="notice">'.$langs->trans(
'SupplierProposalRefFournNotice').
'</p>';
1938 $form_close .=
'<table class="border centpercent marginleftonly marginrightonly">';
1939 $form_close .=
'<tr><td>'.$langs->trans(
"CloseAs").
'</td><td class="left">';
1940 $form_close .=
'<select id="statut" name="statut" class="flat">';
1941 $form_close .=
'<option value="0"> </option>';
1942 $form_close .=
'<option value="2">'.$langs->trans(
'SupplierProposalStatusSigned').
'</option>';
1943 $form_close .=
'<option value="3">'.$langs->trans(
'SupplierProposalStatusNotSigned').
'</option>';
1944 $form_close .=
'</select>';
1945 $form_close .=
'</td></tr>';
1946 $form_close .=
'<tr><td class="left">'.$langs->trans(
'Note').
'</td><td class="left"><textarea cols="70" rows="'.ROWS_3.
'" wrap="soft" name="note">';
1947 $form_close .=
$object->note_private;
1948 $form_close .=
'</textarea></td></tr>';
1949 $form_close .=
'</table>';
1950 $form_close .= $form->buttonsSaveCancel();
1951 $form_close .=
'<a id="acceptedrefused"> </a>';
1952 $form_close .=
'</form>';
1960 if ($action !=
'presend') {
1961 print
'<div class="tabsAction">';
1963 $parameters = array();
1964 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
1966 if (empty($reshook)) {
1967 if ($action !=
'statut' && $action !=
'editline') {
1970 if (count(
$object->lines) > 0) {
1971 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>';
1978 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>';
1983 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').
'"';
1984 print
'>'.$langs->trans(
'ReOpen').
'</a></div>';
1988 if (empty($user->socid)) {
1991 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>';
1993 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
'SendMail').
'</a></div>';
2000 if ($usercancreateorder) {
2001 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>';
2007 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').
'"';
2008 print
'>'.$langs->trans(
'SetAcceptedRefused').
'</a></div>';
2013 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').
'"';
2014 print
'>'.$langs->trans(
'Close').
'</a></div>';
2018 if ($usercancreate) {
2019 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>';
2030 if ($action !=
'presend') {
2031 print
'<div class="fichecenter"><div class="fichehalfleft">';
2038 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
2039 $genallowed = $usercanread;
2040 $delallowed = $usercancreate;
2042 print $formfile->showdocuments(
'supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'', 0,
'', $soc->default_lang);
2046 $linktoelem = $form->showLinkToObjectBlock(
$object, array(), array(
'supplier_proposal'));
2047 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
2050 print
'</div><div class="fichehalfright">';
2053 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2055 $somethingshown = $formactions->showactions(
$object,
'supplier_proposal', $socid, 1,
'', $MAXEVENT);
2057 print
'</div></div>';
2061 if (
GETPOST(
'modelselected')) {
2062 $action =
'presend';
2066 $modelmail =
'supplier_proposal_send';
2067 $defaulttopic =
'SendAskRef';
2068 $diroutput = $conf->supplier_proposal->dir_output;
2069 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
2070 $trackid =
'spro'.$object->id;
2072 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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)
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)
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.
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'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
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.