39require
'../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_proposal/modules_supplier_proposal.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/supplier_proposal.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
49if (isModEnabled(
'project')) {
50 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
55$langs->loadLangs(array(
'companies',
'supplier_proposal',
'compta',
'bills',
'propal',
'orders',
'products',
'deliveries',
'sendings'));
56if (isModEnabled(
'margin')) {
57 $langs->load(
'margins');
65$action =
GETPOST(
'action',
'aZ09');
66$cancel =
GETPOST(
'cancel',
'alpha');
67$backtopage =
GETPOST(
'backtopage',
'alpha');
68$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
70$origin =
GETPOST(
'origin',
'alpha');
72$confirm =
GETPOST(
'confirm',
'alpha');
87$hookmanager->initHooks(array(
'supplier_proposalcard',
'globalcard'));
93$extrafields->fetch_name_optionals_label(
$object->table_element);
96if ($id > 0 || !empty($ref)) {
97 $ret =
$object->fetch($id, $ref);
99 $ret =
$object->fetch_thirdparty();
108$usercanread = $user->hasRight(
'supplier_proposal',
'lire');
109$usercancreate = $user->hasRight(
'supplier_proposal',
'creer');
110$usercandelete = $user->hasRight(
'supplier_proposal',
'supprimer');
113$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'supplier_proposal',
'validate_advance')));
114$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'supplier_proposal',
'send_advance'));
117$usercanclose = $user->hasRight(
'supplier_proposal',
'cloturer');
118$usercancreateorder = ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'));
121$permissionnote = $usercancreate;
122$permissiondellink = $usercancreate;
123$permissiontoedit = $usercancreate;
124$permissiontoadd = $usercancreate;
127if (!empty($user->socid)) {
128 $socid = $user->socid;
137$parameters = array(
'socid' => $socid);
138$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
143if (empty($reshook)) {
144 $backurlforlist = DOL_URL_ROOT.
'/supplier_proposal/list.php';
146 if (empty($backtopage) || ($cancel && empty($id))) {
147 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
148 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
149 $backtopage = $backurlforlist;
151 $backtopage = DOL_URL_ROOT.
'/supplier_proposal/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
157 if (!empty($backtopageforcancel)) {
158 header(
"Location: ".$backtopageforcancel);
160 } elseif (!empty($backtopage)) {
161 header(
"Location: ".$backtopage);
167 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
169 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
171 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
174 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
175 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
179 $result =
$object->createFromClone($user, $socid);
181 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
189 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
191 $result =
$object->delete($user);
193 header(
'Location: '.DOL_URL_ROOT.
'/supplier_proposal/list.php');
196 $langs->load(
"errors");
199 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
201 $result =
$object->deleteLine($lineid);
206 $langs->load(
"errors");
212 $outputlangs = $langs;
215 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
216 $outputlangs->setDefaultLang($newlang);
222 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
225 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
227 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
229 $result =
$object->valid($user);
232 $outputlangs = $langs;
235 $newlang =
GETPOST(
'lang_id',
'aZ09');
238 $newlang =
$object->thirdparty->default_lang;
240 if (!empty($newlang)) {
242 $outputlangs->setDefaultLang($newlang);
250 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
253 $langs->load(
"errors");
254 if (count(
$object->errors) > 0) {
260 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
265 } elseif ($action ==
'add' && $usercancreate) {
273 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Supplier")),
null,
'errors');
282 if (
GETPOST(
'createmode') ==
'copy' &&
GETPOST(
'copie_supplier_proposal')) {
285 $object->delivery_date = $date_delivery;
298 setEventMessages($langs->trans(
"ErrorFailedToCopyProposal",
GETPOST(
'copie_supplier_proposal')),
null,
'errors');
302 $object->delivery_date = $date_delivery;
318 if (isModEnabled(
"multicurrency")) {
319 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
323 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
331 if ($origin && $originid) {
333 $element = $subelement = $origin;
334 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
336 $subelement = $regs[2];
340 if ($element ==
'order') {
341 $element = $subelement =
'commande';
343 if ($element ==
'propal') {
344 $element =
'comm/propal';
345 $subelement =
'propal';
347 if ($element ==
'contract') {
348 $element = $subelement =
'contrat';
350 if ($element ==
'inter') {
351 $element = $subelement =
'ficheinter';
353 if ($element ==
'shipping') {
354 $element = $subelement =
'expedition';
358 $object->origin_id = $originid;
363 $object->linked_objects = array_merge(
$object->linked_objects,
GETPOST(
'other_linked_objects',
'array:int'));
370 $classname = ucfirst($subelement);
371 $srcobject =
new $classname($db);
374 $result = $srcobject->fetch(
$object->origin_id);
377 $lines = $srcobject->lines;
378 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
379 $srcobject->fetch_lines();
380 $lines = $srcobject->lines;
384 $num = count($lines);
385 for ($i = 0; $i < $num; $i++) {
386 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
387 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc :
'');
390 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
393 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
398 if (method_exists($lines[$i],
'fetch_optionals')) {
399 $lines[$i]->fetch_optionals();
400 $array_options = $lines[$i]->array_options;
405 $lines[$i]->subprice,
408 $lines[$i]->localtax1_tx,
409 $lines[$i]->localtax2_tx,
410 $lines[$i]->fk_product,
411 $lines[$i]->remise_percent,
414 $lines[$i]->info_bits,
417 $lines[$i]->special_code,
419 $lines[$i]->fk_fournprice,
423 $lines[$i]->ref_supplier,
436 if ($result > 0 && $lines[$i]->product_type == 9) {
437 $fk_parent_line = $result;
442 $parameters = array(
'objFrom' => $srcobject);
443 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters,
$object, $action);
468 $outputlangs = $langs;
471 $newlang =
GETPOST(
'lang_id',
'aZ09');
474 $newlang =
$object->thirdparty->default_lang;
476 if (!empty($newlang)) {
478 $outputlangs->setDefaultLang($newlang);
483 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
489 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
502 } elseif ($action ==
'confirm_reopen' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
508 } elseif ($action ==
'close' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
514 } elseif ($action ==
'setstatut' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
517 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"CloseAs")),
null,
'errors');
528 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
531 $triggersendname =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
532 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
533 $trackid =
'spro'.$object->id;
534 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
537 $upload_dir = $conf->supplier_proposal->dir_output;
538 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
542 if ($action ==
'modif' && $usercancreate) {
547 $outputlangs = $langs;
550 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
551 $outputlangs->setDefaultLang($newlang);
557 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
559 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
571 if ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') && $usercancreate) {
573 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
574 $vat_rate = str_replace(
'*',
'', $vat_rate);
577 foreach (
$object->lines as $line) {
578 $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);
580 } elseif ($action ==
'addline' && $usercancreate) {
581 $langs->load(
'errors');
586 $product_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
590 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
592 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
593 if ($prod_entry_mode ==
'free') {
608 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef,
'alpha'),
'', 2) : 0);
609 if (empty($remise_percent)) {
614 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
615 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
617 if (is_array($extralabelsline)) {
619 foreach ($extralabelsline as $key => $value) {
620 unset($_POST[
"options_".$key]);
624 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
625 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
628 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
629 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
633 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' &&
GETPOST(
'multicurrency_price_ht') ===
'') {
634 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPrice")),
null,
'errors');
637 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
638 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Description")),
null,
'errors');
641 if (!$error && ($qty >= 0)) {
645 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
649 if ($prod_entry_mode !=
'free' && empty($error)) {
653 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
658 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
660 $res = $productsupplier->fetch($idprod);
663 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
665 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
666 if ($productsupplier->fourn_socid != $socid) {
667 $productsupplier->ref_supplier =
'';
670 $fksoctosearch =
$object->thirdparty->id;
671 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
673 } elseif (
GETPOST(
'idprodfournprice',
'alpha') > 0) {
676 $idprod = $productsupplier->get_buyprice(
GETPOST(
'idprodfournprice',
'alpha'), $qtytosearch);
677 $res = $productsupplier->fetch($idprod);
681 $label = $productsupplier->label;
685 $outputlangs = $langs;
687 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
688 $newlang =
GETPOST(
'lang_id',
'aZ09');
690 if (empty($newlang)) {
691 $newlang =
$object->thirdparty->default_lang;
693 if (!empty($newlang)) {
695 $outputlangs->setDefaultLang($newlang);
697 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->
description;
699 $desc = $productsupplier->description;
702 if (!empty($productsupplier->desc_supplier) &&
getDolGlobalString(
'PRODUIT_FOURN_TEXTS')) {
703 $desc = $productsupplier->desc_supplier;
707 if (trim($product_desc) == trim($desc) &&
getDolGlobalString(
'PRODUIT_AUTOFILL_DESC')) {
712 $desc = $product_desc;
714 if (!empty($product_desc) && trim($product_desc) != trim($desc)) {
718 $ref_supplier = $productsupplier->ref_supplier;
722 if (!GETPOSTISSET(
'tva_tx')) {
726 if (empty($tva_tx)) {
732 $type = $productsupplier->type;
733 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
734 $price_base_type =
'HT';
736 $pu_devise =
price2num($price_ht_devise,
'CU');
737 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
738 $price_base_type =
'TTC';
740 $pu_devise =
price2num($price_ttc_devise,
'CU');
742 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
743 if (empty(
$object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code !=
$object->multicurrency_code)) {
744 $pu = $productsupplier->fourn_pu;
747 $pu = $productsupplier->fourn_pu;
748 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
757 $fournprice = (is_numeric(
GETPOST(
'idprodfournprice',
'alpha')) ?
GETPOST(
'idprodfournprice',
'alpha') : -1);
762 ($price_base_type ==
'HT' ? $pu : 0),
767 $productsupplier->id,
770 ($price_base_type ==
'TTC' ? $pu : 0),
773 min($rank, count(
$object->lines) + 1),
781 $productsupplier->fk_unit,
797 if ($idprod == -99 || $idprod == 0) {
800 $langs->load(
"errors");
801 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")).
' '.$langs->trans(
"or").
' '.$langs->trans(
"NoPriceDefinedForThisSupplier"),
null,
'errors');
806 $langs->load(
"errors");
807 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
809 } elseif ((
GETPOST(
'price_ht') !==
'' ||
GETPOST(
'price_ttc') !==
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') && empty($error)) {
813 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
814 $tva_tx = str_replace(
'*',
'', $tva_tx);
815 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
816 $desc = $product_desc;
819 $fk_unit =
GETPOST(
'units',
'alpha');
821 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
829 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
833 $pu_ht =
price2num($pu_ttc / (1 + ($tva_tx / 100)),
'MU');
835 $price_base_type =
'HT';
836 $pu_ht_devise =
price2num($price_ht_devise,
'CU');
868 if (!$error && $result > 0) {
875 $outputlangs = $langs;
878 $newlang =
GETPOST(
'lang_id',
'aZ09');
881 $newlang =
$object->thirdparty->default_lang;
883 if (!empty($newlang)) {
885 $outputlangs->setDefaultLang($newlang);
893 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
899 unset($_POST[
'prod_entry_mode']);
901 unset($_POST[
'qty']);
902 unset($_POST[
'type']);
903 unset($_POST[
'remise_percent']);
905 unset($_POST[
'price_ht']);
906 unset($_POST[
'multicurrency_price_ht']);
907 unset($_POST[
'price_ttc']);
908 unset($_POST[
'fourn_ref']);
909 unset($_POST[
'tva_tx']);
910 unset($_POST[
'label']);
911 unset($_POST[
'product_ref']);
912 unset($_POST[
'product_label']);
913 unset($_POST[
'product_desc']);
914 unset($_POST[
'fournprice']);
915 unset($_POST[
'buying_price']);
916 unset($localtax1_tx);
917 unset($localtax2_tx);
918 unset($_POST[
'np_marginRate']);
919 unset($_POST[
'np_markRate']);
920 unset($_POST[
'dp_desc']);
921 unset($_POST[
'idprodfournprice']);
922 unset($_POST[
'units']);
924 unset($_POST[
'idprod']);
926 unset($_POST[
'date_starthour']);
927 unset($_POST[
'date_startmin']);
928 unset($_POST[
'date_startsec']);
929 unset($_POST[
'date_startday']);
930 unset($_POST[
'date_startmonth']);
931 unset($_POST[
'date_startyear']);
932 unset($_POST[
'date_endhour']);
933 unset($_POST[
'date_endmin']);
934 unset($_POST[
'date_endsec']);
935 unset($_POST[
'date_endday']);
936 unset($_POST[
'date_endmonth']);
937 unset($_POST[
'date_endyear']);
944 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save') == $langs->trans(
"Save")) {
950 if (preg_match(
'/\*/', $vat_rate)) {
958 $vat_rate = str_replace(
'*',
'', $vat_rate);
962 if (
GETPOST(
'price_ht') !=
'') {
963 $price_base_type =
'HT';
967 $vatratecleaned = $vat_rate;
968 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) {
969 $vatratecleaned = trim($reg[1]);
970 $vatratecode = $reg[2];
974 $ht = (float) $ttc / (1 + ((
float) $vatratecleaned / 100));
975 $price_base_type =
'HT';
981 $fournprice = (
GETPOST(
'fournprice') ?
GETPOST(
'fournprice') :
'');
982 $buyingprice = (
GETPOST(
'buying_price') !=
'' ?
GETPOST(
'buying_price') :
'');
985 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
986 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
988 if (is_array($extralabelsline)) {
989 foreach ($extralabelsline as $key => $value) {
990 unset($_POST[
"options_".$key]);
995 $special_code =
GETPOST(
'special_code');
1002 if (!empty($productid)) {
1005 if ($productid > 0 && $productsupplier->get_buyprice(0,
price2num(
GETPOST(
'qty')), $productid,
'none',
GETPOSTINT(
'socid')) < 0) {
1006 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1011 $res = $product->fetch($productid);
1013 $type = $product->type;
1015 $price_min = $product->price_min;
1017 $price_min = $product->multiprices_min [
$object->thirdparty->price_level];
1023 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1027 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1035 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1038 $result =
$object->updateline(
1067 $outputlangs = $langs;
1069 $outputlangs =
new Translate(
"", $conf);
1070 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
1071 $outputlangs->setDefaultLang($newlang);
1074 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1077 unset($_POST[
'qty']);
1078 unset($_POST[
'type']);
1079 unset($_POST[
'productid']);
1080 unset($_POST[
'remise_percent']);
1081 unset($_POST[
'price_ht']);
1082 unset($_POST[
'multicurrency_price_ht']);
1083 unset($_POST[
'price_ttc']);
1084 unset($_POST[
'tva_tx']);
1085 unset($_POST[
'product_ref']);
1086 unset($_POST[
'product_label']);
1087 unset($_POST[
'product_desc']);
1088 unset($_POST[
'fournprice']);
1089 unset($_POST[
'buying_price']);
1091 unset($_POST[
'date_starthour']);
1092 unset($_POST[
'date_startmin']);
1093 unset($_POST[
'date_startsec']);
1094 unset($_POST[
'date_startday']);
1095 unset($_POST[
'date_startmonth']);
1096 unset($_POST[
'date_startyear']);
1097 unset($_POST[
'date_endhour']);
1098 unset($_POST[
'date_endmin']);
1099 unset($_POST[
'date_endsec']);
1100 unset($_POST[
'date_endday']);
1101 unset($_POST[
'date_endmonth']);
1102 unset($_POST[
'date_endyear']);
1109 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha') == $langs->trans(
"Cancel")) {
1110 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
1112 } elseif ($action ==
'classin' && $usercancreate) {
1115 } elseif ($action ==
'setavailability' && $usercancreate) {
1118 } elseif ($action ==
'setconditions' && $usercancreate) {
1125 } elseif ($action ==
'setmode' && $usercancreate) {
1128 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
1130 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
1131 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
1134 } elseif ($action ==
'update_extras' && $usercancreate) {
1138 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
1144 $result =
$object->insertExtraFields(
'PROPOSAL_SUPPLIER_MODIFY');
1152 $action =
'edit_extras';
1162$title =
$object->ref.
" - ".$langs->trans(
'Card');
1163if ($action ==
'create') {
1164 $title = $langs->trans(
"SupplierProposalNew");
1166$help_url =
'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur';
1170$form =
new Form($db);
1174$companystatic =
new Societe($db);
1175if (isModEnabled(
'project')) {
1182if ($action ==
'create') {
1183 $currency_code = $conf->currency;
1185 print
load_fiche_titre($langs->trans(
"SupplierProposalNew"),
'',
'supplier_proposal');
1189 $res = $soc->fetch($socid);
1193 if (!empty($origin) && !empty($originid)) {
1194 $element = $subelement =
GETPOST(
'origin');
1195 if (preg_match(
'/^([^_]+)_([^_]+)/i',
GETPOST(
'origin'), $regs)) {
1196 $element = $regs[1];
1197 $subelement = $regs[2];
1201 if ($element ==
'order' || $element ==
'commande') {
1202 $element = $subelement =
'commande';
1204 if ($element ==
'propal') {
1205 $element =
'comm/propal';
1206 $subelement =
'propal';
1211 $classname = ucfirst($subelement);
1212 $objectsrc =
new $classname($db);
1213 $objectsrc->fetch($originid);
1214 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1215 $objectsrc->fetch_lines();
1217 $objectsrc->fetch_thirdparty();
1219 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
1220 $soc = $objectsrc->thirdparty;
1222 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1223 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1226 $objectsrc->fetch_optionals();
1227 $object->array_options = $objectsrc->array_options;
1229 if (isModEnabled(
"multicurrency")) {
1230 if (!empty($objectsrc->multicurrency_code)) {
1231 $currency_code = $objectsrc->multicurrency_code;
1233 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
1234 $currency_tx = $objectsrc->multicurrency_tx;
1238 $cond_reglement_id = $soc->cond_reglement_supplier_id;
1239 $mode_reglement_id = $soc->mode_reglement_supplier_id;
1240 if (isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
1241 $currency_code = $soc->multicurrency_code;
1247 print
'<form name="addprop" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1248 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1249 print
'<input type="hidden" name="action" value="add">';
1250 if ($origin !=
'project' && $originid) {
1251 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1252 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1254 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1259 $parameters = array();
1261 $reshook = $hookmanager->executeHooks(
'tabContentCreateSupplierProposal', $parameters,
$object, $action);
1262 if (empty($reshook)) {
1263 print
'<table class="border centpercent">';
1266 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td colspan="2">'.$langs->trans(
"Draft").
'</td></tr>';
1270 print
'<td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
1272 print
'<td colspan="2">';
1273 print $soc->getNomUrl(1,
'supplier');
1274 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1277 print
'<td colspan="2">';
1278 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
1279 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company((empty($socid) ?
'' : $socid),
'socid', $filter,
'SelectThirdParty', 1, 0, null, 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1283 $(document).ready(function() {
1284 $("#socid").change(function() {
1285 console.log("We have changed the company - Reload page");
1287 $("input[name=action]").val("create");
1288 $("form[name=addprop]").submit();
1293 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>';
1300 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
1302 $absolute_discount = $soc->getAvailableDiscounts(
'',
'', 0, 1);
1306 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
1307 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1313 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td colspan="2">';
1314 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
1315 print $form->getSelectConditionsPaiements(
GETPOST(
'cond_reglement_id') > 0 ?
GETPOST(
'cond_reglement_id') : $cond_reglement_id,
'cond_reglement_id', -1, 1);
1319 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td colspan="2">';
1320 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1321 $form->select_types_paiements(
GETPOST(
'mode_reglement_id') > 0 ?
GETPOST(
'mode_reglement_id') : $mode_reglement_id,
'mode_reglement_id');
1325 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') && isModEnabled(
"bank")) {
1326 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td colspan="2">';
1327 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1328 $form->select_comptes(
GETPOST(
'fk_account') > 0 ?
GETPOSTINT(
'fk_account') : $fk_account,
'fk_account', 0,
'', 1);
1333 if (isModEnabled(
"shipping")) {
1334 print
'<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td colspan="2">';
1335 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1336 $form->selectShippingMethod(
GETPOST(
'shipping_method_id') > 0 ?
GETPOSTINT(
'shipping_method_id') :
"",
'shipping_method_id',
'', 1);
1341 print
'<tr><td>'.$langs->trans(
"DeliveryDate").
'</td>';
1342 print
'<td colspan="2">';
1343 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1346 $tmpdte = time() + (7 *
getDolGlobalInt(
'DATE_LIVRAISON_WEEK_DELAY') * 24 * 60 * 60);
1347 $syear = date(
"Y", $tmpdte);
1348 $smonth = date(
"m", $tmpdte);
1349 $sday = date(
"d", $tmpdte);
1350 print $form->selectDate($syear.
"-".$smonth.
"-".$sday,
'liv_', 0, 0, 0,
"addask");
1352 print $form->selectDate($datedelivery ? $datedelivery : -1,
'liv_', 0, 0, 0,
"addask", 1, 1);
1359 print
'<td>'.$langs->trans(
"DefaultModel").
'</td>';
1360 print
'<td colspan="2">';
1361 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1363 $preselected = (
getDolGlobalString(
'SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT') ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT : $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF);
1364 print $form->selectarray(
'model', $list, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1368 if (isModEnabled(
'project')) {
1369 $langs->load(
"projects");
1373 if ($origin ==
'project') {
1374 $projectid = ($originid ? $originid : 0);
1378 print
'<td>'.$langs->trans(
"Project").
'</td><td colspan="2">';
1379 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');
1380 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>';
1387 if (isModEnabled(
"multicurrency")) {
1389 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'',
$object, 0).
'</td>';
1390 print
'<td colspan="3" class="maxwidthonsmartphone">';
1391 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
1392 print $form->selectMultiCurrency($currency_code,
'multicurrency_code');
1397 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' => 3);
1398 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1399 print $hookmanager->resPrint;
1400 if (empty($reshook)) {
1401 print
$object->showOptionals($extrafields,
'create', $parameters);
1406 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1408 if ($origin ==
'contrat') {
1412 $objectsrc->update_price(1,
'auto', 1);
1415 print
"\n<!-- ".$classname.
" info -->";
1417 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
1418 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
1419 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
1420 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
1421 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
1423 print
'<tr><td>'.$langs->trans(
'CommRequest').
'</td><td colspan="2">'.$objectsrc->getNomUrl(1).
'</td></tr>';
1424 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td colspan="2">'.
price($objectsrc->total_ht).
'</td></tr>';
1425 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td colspan="2">'.
price($objectsrc->total_tva).
"</td></tr>";
1426 if ($mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
1427 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax1).
"</td></tr>";
1430 if ($mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
1431 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax2).
"</td></tr>";
1433 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td colspan="2">'.
price($objectsrc->total_ttc).
"</td></tr>";
1435 if (isModEnabled(
"multicurrency")) {
1436 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
1437 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
1438 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
1450 print
'<input type="hidden" name="createmode" value="empty">';
1454 print
'<br><table>';
1458 print
'<td><input type="radio" name="createmode" value="copy"></td>';
1459 print
'<td>'.$langs->trans(
"CopyAskFrom").
' </td>';
1461 $liste_ask = array();
1462 $liste_ask [0] =
'';
1464 $sql =
"SELECT p.rowid as id, p.ref, s.nom";
1465 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal p";
1466 $sql .=
", ".MAIN_DB_PREFIX.
"societe s";
1467 $sql .=
" WHERE s.rowid = p.fk_soc";
1468 $sql .=
" AND p.entityy IN (".getEntity(
'supplier_proposal').
")";
1469 $sql .=
" AND p.fk_statut <> ".SupplierProposal::STATUS_DRAFT;
1470 $sql .=
" ORDER BY Id";
1472 $resql = $db->query($sql);
1474 $num = $db->num_rows($resql);
1477 $row = $db->fetch_row($resql);
1478 $askPriceSupplierRefAndSocName = $row[1].
" - ".$row[2];
1479 $liste_ask[$row[0]] = $askPriceSupplierRefAndSocName;
1482 print $form->selectarray(
"copie_supplier_proposal", $liste_ask, 0);
1488 print
'<tr><td class="tdtop"><input type="radio" name="createmode" value="empty" checked></td>';
1489 print
'<td valign="top" colspan="2">'.$langs->trans(
"CreateEmptyAsk").
'</td></tr>';
1499 print $form->buttonsSaveCancel(
"CreateDraft");
1505 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1508 $title = $langs->trans(
'ProductsAndServices');
1511 print
'<div class="div-table-responsive-no-min">';
1512 print
'<table class="noborder centpercent">';
1514 $objectsrc->printOriginLinesList();
1527 $head = supplier_proposal_prepare_head(
$object);
1528 print
dol_get_fiche_head($head,
'comm', $langs->trans(
'CommRequest'), -1,
'supplier_proposal');
1533 if ($action ==
'clone') {
1534 $filter =
'(s.fournisseur:=:1)';
1536 $formquestion = array(
1544 'label' => $langs->trans(
"SelectThirdParty"),
1545 'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter))
1548 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
1549 } elseif ($action ==
'delete') {
1551 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteAsk'), $langs->trans(
'ConfirmDeleteAsk',
$object->ref),
'confirm_delete',
'', 0, 1);
1552 } elseif ($action ==
'reopen') {
1554 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ReOpen'), $langs->trans(
'ConfirmReOpenAsk',
$object->ref),
'confirm_reopen',
'', 0, 1);
1555 } elseif ($action ==
'ask_deleteline') {
1557 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
1558 } elseif ($action ==
'validate') {
1563 $ref = substr(
$object->ref, 1, 4);
1564 if ($ref ==
'PROV') {
1565 $numref =
$object->getNextNumRef($soc);
1566 if (empty($numref)) {
1574 $text = $langs->trans(
'ConfirmValidateAsk', $numref);
1575 if (isModEnabled(
'notification')) {
1576 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
1577 $notify =
new Notify($db);
1579 $text .= $notify->confirmMessage(
'PROPOSAL_SUPPLIER_VALIDATE',
$object->socid,
$object);
1583 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateAsk'), $text,
'confirm_validate',
'', 0, 1);
1588 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
1589 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
1590 if (empty($reshook)) {
1591 $formconfirm .= $hookmanager->resPrint;
1592 } elseif ($reshook > 0) {
1593 $formconfirm = $hookmanager->resPrint;
1601 $linkback =
'<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1604 $morehtmlref =
'<div class="refidno">';
1609 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'supplier');
1611 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.
$object->thirdparty->id.
'&search_societe='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherProposals").
'</a>)';
1614 if (isModEnabled(
'project')) {
1615 $langs->load(
"projects");
1616 $morehtmlref .=
'<br>';
1617 if ($usercancreate) {
1618 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
1619 if ($action !=
'classify') {
1620 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
1622 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
1624 if (!empty(
$object->fk_project)) {
1626 $proj->fetch(
$object->fk_project);
1627 $morehtmlref .= $proj->getNomUrl(1);
1629 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
1634 $morehtmlref .=
'</div>';
1637 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1640 $parameters = array();
1642 $reshook = $hookmanager->executeHooks(
'tabContentViewSupplierProposal', $parameters,
$object, $action);
1643 if (empty($reshook)) {
1644 print
'<div class="fichecenter">';
1645 print
'<div class="fichehalfleft">';
1646 print
'<div class="underbanner clearboth"></div>';
1648 print
'<table class="border tableforfield centpercent">';
1652 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
1653 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
1655 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
1656 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
1659 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td>';
1661 $absolute_discount = $soc->getAvailableDiscounts(
'', $filterabsolutediscount, 0, 1);
1662 $absolute_creditnote = $soc->getAvailableDiscounts(
'', $filtercreditnote, 0, 1);
1663 $absolute_discount =
price2num($absolute_discount,
'MT');
1664 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
1668 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
1669 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1674 print
'<tr><td class="titlefield">';
1675 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1676 print $langs->trans(
'PaymentConditionsShort');
1679 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>';
1681 print
'</tr></table>';
1682 print
'</td><td class="valuefield">';
1683 if ($action ==
'editconditions') {
1684 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'cond_reglement_id', 1);
1686 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'none', 1);
1692 $langs->load(
'deliveries');
1694 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1695 print $langs->trans(
'DeliveryDate');
1698 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>';
1700 print
'</tr></table>';
1701 print
'</td><td class="valuefield">';
1702 if ($action ==
'editdate_livraison') {
1703 print
'<form name="editdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post" class="formconsumeproduce">';
1704 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1705 print
'<input type="hidden" name="action" value="setdate_livraison">';
1706 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1707 print $form->selectDate(
$object->delivery_date,
'liv_', 0, 0, 0,
"editdate_livraison");
1708 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
1719 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1720 print $langs->trans(
'PaymentMode');
1723 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>';
1725 print
'</tr></table>';
1726 print
'</td><td class="valuefield">';
1727 if ($action ==
'editmode') {
1728 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
1730 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'none');
1735 if (isModEnabled(
"multicurrency")) {
1739 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1740 print $form->editfieldkey(
'Currency',
'multicurrency_code',
'',
$object, 0);
1742 if ($action !=
'editmulticurrencycode' &&
$object->statut == $object::STATUS_VALIDATED) {
1743 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmulticurrencycode&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetMultiCurrencyCode'), 1).
'</a></td>';
1745 print
'</tr></table>';
1746 print
'</td><td class="valuefield">';
1747 if ($action ==
'editmulticurrencycode') {
1748 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_code,
'multicurrency_code');
1750 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_code,
'none');
1755 if (
$object->multicurrency_code != $conf->currency ||
$object->multicurrency_tx != 1) {
1758 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1759 print $form->editfieldkey(
'CurrencyRate',
'multicurrency_tx',
'',
$object, 0);
1761 if ($action !=
'editmulticurrencyrate' &&
$object->statut == $object::STATUS_VALIDATED &&
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency) {
1762 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmulticurrencyrate&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetMultiCurrencyCode'), 1).
'</a></td>';
1764 print
'</tr></table>';
1765 print
'</td><td class="valuefield">';
1766 if ($action ==
'editmulticurrencyrate' || $action ==
'actualizemulticurrencyrate') {
1767 if ($action ==
'actualizemulticurrencyrate') {
1770 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_tx,
'multicurrency_tx',
$object->multicurrency_code);
1772 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_tx,
'none',
$object->multicurrency_code);
1773 if (
$object->statut == $object::STATUS_DRAFT &&
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency) {
1774 print
'<div class="inline-block"> ';
1775 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=actualizemulticurrencyrate">'.$langs->trans(
"ActualizeCurrency").
'</a>';
1796 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') && isModEnabled(
"bank")) {
1799 print
'<table width="100%" class="nobordernopadding"><tr><td>';
1800 print $langs->trans(
'BankAccount');
1802 if ($action !=
'editbankaccount' && $usercancreate) {
1803 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>';
1805 print
'</tr></table>';
1806 print
'</td><td class="valuefield">';
1807 if ($action ==
'editbankaccount') {
1808 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'fk_account', 1);
1810 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
1817 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1822 print
'<div class="fichehalfright">';
1823 print
'<div class="underbanner clearboth"></div>';
1825 print
'<table class="border tableforfield centpercent">';
1829 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
1830 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
1831 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
1833 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1839 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
1840 print
'<td class="nowrap amountcard right">' .
price(
$object->total_tva, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
1841 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
1843 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1848 if ($mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
1850 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
1851 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
1852 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
1853 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1857 if ($mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
1859 print
'<td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
1860 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
1861 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
1862 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1870 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
1871 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ttc, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
1872 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
1874 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1888 print
'<div class="clearboth"></div><br>';
1891 $blocname =
'contacts';
1892 $title = $langs->trans(
'ContactsAddresses');
1893 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
1897 $blocname =
'notes';
1898 $title = $langs->trans(
'Notes');
1899 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
1907 $result =
$object->getLinesArray();
1909 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'#add' :
'').
'" method="POST">
1910 <input type="hidden" name="token" value="' .
newToken().
'">
1911 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
1912 <input type="hidden" name="mode" value="">
1913 <input type="hidden" name="id" value="' .
$object->id.
'">
1914 <input type="hidden" name="backtopage" value="'.$backtopage.
'">
1918 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
1921 print
'<div class="div-table-responsive-no-min">';
1922 print
'<table id="tablelines" class="noborder noshadow centpercent">';
1925 global $forceall, $senderissupplier, $inputalsopricewithtax;
1928 $inputalsopricewithtax = 1;
1929 $senderissupplier = 2;
1931 $senderissupplier = 1;
1935 $object->printObjectLines($action, $soc, $mysoc, $lineid, $dateSelector);
1940 if ($action !=
'editline') {
1943 $parameters = array(
'dateSelector' => $dateSelector);
1944 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters,
$object, $action);
1948 if (empty($reshook)) {
1949 $object->formAddObjectLine($dateSelector, $soc, $mysoc);
1961 if ($action ==
'statut') {
1963 $form_close =
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST" id="formacceptrefuse" class="formconsumeproduce paddingbottom paddingleft paddingright">';
1964 $form_close .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1965 $form_close .=
'<input type="hidden" name="action" value="setstatut">';
1968 $form_close .=
'<p class="notice">'.$langs->trans(
'SupplierProposalRefFournNotice').
'</p>';
1970 $form_close .=
'<table class="border centpercent marginleftonly marginrightonly">';
1971 $form_close .=
'<tr><td>'.$langs->trans(
"CloseAs").
'</td><td class="left">';
1972 $form_close .=
'<select id="statut" name="statut" class="flat">';
1973 $form_close .=
'<option value="0"> </option>';
1974 $form_close .=
'<option value="2">'.$langs->trans(
'SupplierProposalStatusSigned').
'</option>';
1975 $form_close .=
'<option value="3">'.$langs->trans(
'SupplierProposalStatusNotSigned').
'</option>';
1976 $form_close .=
'</select>';
1977 $form_close .=
'</td></tr>';
1978 $form_close .=
'<tr><td class="left">'.$langs->trans(
'Note').
'</td><td class="left"><textarea cols="70" rows="'.ROWS_3.
'" wrap="soft" name="note">';
1979 $form_close .=
$object->note_private;
1980 $form_close .=
'</textarea></td></tr>';
1981 $form_close .=
'</table>';
1982 $form_close .= $form->buttonsSaveCancel();
1983 $form_close .=
'<a id="acceptedrefused"> </a>';
1984 $form_close .=
'</form>';
1992 if ($action !=
'presend') {
1993 print
'<div class="tabsAction">';
1995 $parameters = array();
1996 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
1998 if (empty($reshook)) {
1999 if ($action !=
'statut' && $action !=
'editline') {
2002 if (count(
$object->lines) > 0) {
2003 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>';
2010 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>';
2015 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').
'"';
2016 print
'>'.$langs->trans(
'ReOpen').
'</a></div>';
2020 if (empty($user->socid)) {
2023 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>';
2025 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
'SendMail').
'</a></div>';
2032 if ($usercancreateorder) {
2033 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>';
2039 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').
'"';
2040 print
'>'.$langs->trans(
'SetAcceptedRefused').
'</a></div>';
2045 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').
'"';
2046 print
'>'.$langs->trans(
'Close').
'</a></div>';
2050 if ($usercancreate) {
2051 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>';
2062 if ($action !=
'presend') {
2063 print
'<div class="fichecenter"><div class="fichehalfleft">';
2070 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
2071 $genallowed = $usercanread;
2072 $delallowed = $usercancreate;
2074 print $formfile->showdocuments(
'supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'', 0,
'', $soc->default_lang);
2078 $linktoelem = $form->showLinkToObjectBlock(
$object,
null, array(
'supplier_proposal'));
2079 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
2082 print
'</div><div class="fichehalfright">';
2085 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2087 $somethingshown = $formactions->showactions(
$object,
'supplier_proposal', $socid, 1,
'', $MAXEVENT);
2089 print
'</div></div>';
2093 if (
GETPOST(
'modelselected')) {
2094 $action =
'presend';
2098 $modelmail =
'supplier_proposal_send';
2099 $defaulttopic =
'SendAskRef';
2100 $diroutput = $conf->supplier_proposal->dir_output;
2101 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
2102 $trackid =
'spro'.$object->id;
2104 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()
Empty header.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static getIdAndTxFromCode($dbs, $code, $date_document='')
Get id and rate of currency from code.
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.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 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.