40require
'../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_proposal/modules_supplier_proposal.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/supplier_proposal.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
52 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
53 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
66$langs->loadLangs(array(
'companies',
'supplier_proposal',
'compta',
'bills',
'propal',
'orders',
'products',
'sendings'));
68 $langs->load(
'margins');
76$action =
GETPOST(
'action',
'aZ09');
77$cancel =
GETPOST(
'cancel',
'alpha');
78$backtopage =
GETPOST(
'backtopage',
'alpha');
79$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
81$origin =
GETPOST(
'origin',
'alpha');
83$confirm =
GETPOST(
'confirm',
'alpha');
98$hookmanager->initHooks(array(
'supplier_proposalcard',
'globalcard'));
107$extrafields->fetch_name_optionals_label(
$object->table_element);
110if ($id > 0 || !empty($ref)) {
111 $ret =
$object->fetch($id, $ref);
113 $ret =
$object->fetch_thirdparty();
122$usercanread = $user->hasRight(
'supplier_proposal',
'lire');
123$usercancreate = $user->hasRight(
'supplier_proposal',
'creer');
124$usercandelete = $user->hasRight(
'supplier_proposal',
'supprimer');
127$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'supplier_proposal',
'validate_advance')));
128$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'supplier_proposal',
'send_advance'));
131$usercanclose = $user->hasRight(
'supplier_proposal',
'cloturer');
132$usercancreateorder = ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'));
135$permissionnote = $usercancreate;
136$permissiondellink = $usercancreate;
137$permissiontoedit = $usercancreate;
138$permissiontoadd = $usercancreate;
139$permissiontoeditextra = $permissiontoadd;
140if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
142 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
146if (!empty($user->socid)) {
147 $socid = $user->socid;
156$parameters = array(
'socid' => $socid);
157$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
165if (empty($reshook)) {
166 $backurlforlist = DOL_URL_ROOT.
'/supplier_proposal/list.php';
168 if (empty($backtopage) || ($cancel && empty($id))) {
169 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
170 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
171 $backtopage = $backurlforlist;
173 $backtopage = DOL_URL_ROOT.
'/supplier_proposal/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
178 if ($cancel && !($action ==
'updateline' && $usercancreate)) {
179 if (!empty($backtopageforcancel)) {
180 header(
"Location: ".$backtopageforcancel);
182 } elseif (!empty($backtopage)) {
183 header(
"Location: ".$backtopage);
189 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
191 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
193 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
196 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
197 if (
false && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
201 $result =
$object->createFromClone($user, $socid);
203 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
211 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
213 $result =
$object->delete($user);
215 header(
'Location: '.DOL_URL_ROOT.
'/supplier_proposal/list.php');
218 $langs->load(
"errors");
221 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
223 $result =
$object->deleteLine($lineid);
228 $langs->load(
"errors");
234 $outputlangs = $langs;
237 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
238 $outputlangs->setDefaultLang($newlang);
244 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
247 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
249 } elseif ($action ==
'confirm_delete_subtotalline' && $confirm ==
'yes' && $usercancreate) {
254 $result =
$object->deleteSubtotalLine($langs,
GETPOSTINT(
'lineid'), (
bool)
GETPOST(
'deletecorrespondingsubtotalline'));
259 $outputlangs = $langs;
265 $newlang =
$object->thirdparty->default_lang;
267 if (!empty($newlang)) {
269 $outputlangs->setDefaultLang($newlang);
270 $outputlangs->load(
'products');
274 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
277 header(
'Location: '.
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' => $id]));
284 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
286 $result =
$object->valid($user);
289 $outputlangs = $langs;
292 $newlang =
GETPOST(
'lang_id',
'aZ09');
295 $newlang =
$object->thirdparty->default_lang;
297 if (!empty($newlang)) {
299 $outputlangs->setDefaultLang($newlang);
307 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
310 $langs->load(
"errors");
311 if (count(
$object->errors) > 0) {
317 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
322 } elseif ($action ==
'add' && $usercancreate) {
330 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Supplier")),
null,
'errors');
341 if (
GETPOST(
'createmode') ==
'copy' &&
GETPOSTINT(
'copie_supplier_proposal') > 0) {
344 $object->delivery_date = $date_delivery;
352 $object->model_pdf = $model_pdf;
354 $object->user_creation_id = $user->id;
360 setEventMessages($langs->trans(
"ErrorFailedToCopyProposal",
GETPOST(
'copie_supplier_proposal')),
null,
'errors');
364 $object->delivery_date = $date_delivery;
372 $object->model_pdf = $model_pdf;
374 $object->user_creation_id = $user->id;
383 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
387 $ret = $extrafields->setOptionalsFromPost(
null, $object);
395 if ($origin && $originid) {
397 $element = $subelement = $origin;
399 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
401 $subelement = $regs[2];
405 if ($element ==
'order') {
406 $element = $subelement =
'commande';
408 if ($element ==
'propal') {
409 $element =
'comm/propal';
410 $subelement =
'propal';
412 if ($element ==
'contract') {
413 $element = $subelement =
'contrat';
415 if ($element ==
'inter') {
416 $element = $subelement =
'fichinter';
418 if ($element ==
'shipping') {
419 $element = $subelement =
'expedition';
423 $object->origin_type = $origin;
424 $object->origin_id = $originid;
429 $object->linked_objects = array_merge(
$object->linked_objects,
GETPOST(
'other_linked_objects',
'array:int'));
437 $classname = ucfirst($subelement);
438 $srcobject =
new $classname(
$db);
439 '@phan-var-force Commande|Propal|Contrat|Fichinter|Expedition $srcobject';
441 dol_syslog(
"Try to find source object origin=".
$object->origin_type.
" originid=".
$object->origin_id.
" to add lines");
442 $result = $srcobject->fetch(
$object->origin_id);
445 $lines = $srcobject->lines;
446 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
447 $srcobject->fetch_lines();
448 $lines = $srcobject->lines;
452 $num = count($lines);
453 for ($i = 0; $i < $num; $i++) {
454 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
455 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc :
'');
458 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
461 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
466 if (method_exists($lines[$i],
'fetch_optionals')) {
467 $lines[$i]->fetch_optionals();
468 $array_options = $lines[$i]->array_options;
470 $array_options = array();
475 $lines[$i]->subprice,
478 $lines[$i]->localtax1_tx,
479 $lines[$i]->localtax2_tx,
480 $lines[$i]->fk_product,
481 $lines[$i]->remise_percent,
484 $lines[$i]->info_bits,
487 $lines[$i]->special_code,
489 $lines[$i]->fk_fournprice,
493 $lines[$i]->ref_supplier,
506 if ($result > 0 && !empty($lines[$i]->extraparams)) {
508 $newline->id = $result;
509 $newline->extraparams = $lines[$i]->extraparams;
510 $newline->setExtraParameters();
514 if ($result > 0 && $lines[$i]->product_type == 9) {
515 $fk_parent_line = $result;
520 $parameters = array(
'objFrom' => $srcobject);
521 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $object, $action);
542 $categories =
GETPOST(
'categories',
'array');
543 $object->setCategories($categories);
550 $outputlangs = $langs;
553 $newlang =
GETPOST(
'lang_id',
'aZ09');
556 $newlang =
$object->thirdparty->default_lang;
558 if (!empty($newlang)) {
560 $outputlangs->setDefaultLang($newlang);
564 if (!empty($model)) {
566 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
573 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
586 } elseif ($action ==
'confirm_reopen' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
592 } elseif ($action ==
'close' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
598 } elseif ($action ==
'setstatut' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
601 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"CloseAs")),
null,
'errors');
609 } elseif ($action ==
'addline' &&
GETPOST(
'updateallvatlinesblock',
'alpha') &&
GETPOST(
'vatforblocklines',
'alpha') !==
'' && $usercancreate) {
610 $tx_tva =
GETPOST(
'vatforblocklines') ?
GETPOST(
'vatforblocklines') : 0;
611 $object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'tva', $tx_tva);
612 } elseif ($action ==
'addline' &&
GETPOST(
'updatealldiscountlinesblock',
'alpha') &&
GETPOST(
'discountforblocklines',
'alpha') !==
'' && $usercancreate) {
613 $discount =
GETPOST(
'discountforblocklines') ?
GETPOST(
'discountforblocklines') : 0;
614 $object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'discount', $discount);
615 } elseif ($action ==
'settags' &&
isModEnabled(
'category') && $usercancreate) {
620 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
623 $triggersendname =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
624 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
625 $trackid =
'spro'.$object->id;
626 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
629 $upload_dir =
$conf->supplier_proposal->dir_output;
630 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
633 if ($action ==
'modif' && $usercancreate) {
638 $outputlangs = $langs;
641 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
642 $outputlangs->setDefaultLang($newlang);
648 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
650 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
662 if ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') && $usercancreate) {
664 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
665 $vat_rate = str_replace(
'*',
'', $vat_rate);
668 foreach (
$object->lines as $line) {
669 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
672 $result =
$object->updateline($line->id, $line->subprice, $line->qty, (
float) $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);
674 } elseif ($action ==
'confirm_addtitleline' && $usercancreate) {
677 $langs->load(
'subtotals');
679 $desc =
GETPOST(
'subtotallinedesc',
'alphanohtml');
680 $depth =
GETPOSTINT(
'subtotallinelevel') ?? 1;
682 $subtotal_options = array();
684 foreach (SupplierProposal::$TITLE_OPTIONS as $option) {
685 $value =
GETPOST($option,
'alphanohtml');
687 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
692 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
703 $outputlangs = $langs;
704 $newlang =
GETPOST(
'lang_id',
'alpha');
706 $newlang =
$object->thirdparty->default_lang;
708 if (!empty($newlang)) {
710 $outputlangs->setDefaultLang($newlang);
713 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
718 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
720 } elseif ($action ==
'confirm_addsubtotalline' && $usercancreate) {
723 $langs->load(
'subtotals');
725 $choosen_line =
GETPOST(
'subtotaltitleline',
'alphanohtml');
726 foreach (
$object->lines as $line) {
727 if ($line->desc == $choosen_line && $line->special_code == SUBTOTALS_SPECIAL_CODE) {
729 $depth = -$line->qty;
733 $subtotal_options = array();
735 foreach (SupplierProposal::$SUBTOTAL_OPTIONS as $option) {
736 $value =
GETPOST($option,
'alphanohtml');
738 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
743 if (isset($desc) && isset($depth)) {
744 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
747 $object->errors[] = $langs->trans(
"CorrespondingTitleNotFound");
756 $outputlangs = $langs;
757 $newlang =
GETPOST(
'lang_id',
'alpha');
759 $newlang =
$object->thirdparty->default_lang;
761 if (!empty($newlang)) {
763 $outputlangs->setDefaultLang($newlang);
766 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
771 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
773 } elseif ($action ==
'addline' && $usercancreate) {
774 $langs->load(
'errors');
783 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
785 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
786 if ($prod_entry_mode ==
'free') {
802 if (empty($remise_percent)) {
807 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
808 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
810 if (is_array($extralabelsline)) {
812 foreach ($extralabelsline as $key => $value) {
813 unset($_POST[
"options_".$key]);
817 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
818 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
821 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
822 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
826 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' &&
GETPOST(
'multicurrency_price_ht') ===
'') {
827 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPrice")),
null,
'errors');
830 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($line_desc)) {
831 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Description")),
null,
'errors');
834 if (!$error && ($qty >= 0)) {
838 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
842 if ($prod_entry_mode !=
'free' && empty($error)) {
846 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
851 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
852 $idprod = (int) $reg[1];
853 $res = $productsupplier->fetch($idprod);
856 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
858 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
859 if ($productsupplier->fourn_socid != $socid) {
860 $productsupplier->ref_supplier =
'';
863 $fksoctosearch =
$object->thirdparty->id;
864 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
866 } elseif (
GETPOSTINT(
'idprodfournprice') > 0) {
869 $idprod = $productsupplier->get_buyprice(
GETPOSTINT(
'idprodfournprice'), $qtytosearch);
870 $res = $productsupplier->fetch($idprod);
874 $label = $productsupplier->label;
878 $outputlangs = $langs;
880 if (
GETPOST(
'lang_id',
'aZ09')) {
881 $newlang =
GETPOST(
'lang_id',
'aZ09');
883 if (empty($newlang)) {
884 $newlang =
$object->thirdparty->default_lang;
886 if (!empty($newlang)) {
888 $outputlangs->setDefaultLang($newlang);
890 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->
description;
892 $desc = $productsupplier->description;
895 if (!empty($productsupplier->desc_supplier) &&
getDolGlobalString(
'PRODUIT_FOURN_TEXTS')) {
896 $desc = $productsupplier->desc_supplier;
907 $ref_supplier = $productsupplier->ref_supplier;
912 $tmpidprodfournprice =
GETPOST(
'idprodfournprice',
'alpha');
913 if (is_numeric($tmpidprodfournprice) && (
int) $tmpidprodfournprice > 0) {
914 $tmpidprodfournprice = (int) $tmpidprodfournprice;
916 $tmpidprodfournprice = 0;
922 if (empty($tva_tx)) {
928 $type = $productsupplier->type;
929 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
930 $price_base_type =
'HT';
932 $pu_devise =
price2num($price_ht_devise,
'CU');
933 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
934 $price_base_type =
'TTC';
936 $pu_devise =
price2num($price_ttc_devise,
'CU');
938 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
939 if (empty(
$object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code !=
$object->multicurrency_code)) {
940 $pu = $productsupplier->fourn_pu;
943 $pu = $productsupplier->fourn_pu;
944 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
953 $fournprice = (is_numeric(
GETPOST(
'idprodfournprice',
'alpha')) ?
GETPOST(
'idprodfournprice',
'alpha') : -1);
958 ($price_base_type ==
'HT' ? $pu : 0),
963 $productsupplier->id,
966 ($price_base_type ==
'TTC' ? $pu : 0),
969 min($rank, count(
$object->lines) + 1),
977 $productsupplier->fk_unit,
993 if ($idprod == -99 || $idprod == 0) {
996 $langs->load(
"errors");
997 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")).
' '.$langs->trans(
"or").
' '.$langs->trans(
"NoPriceDefinedForThisSupplier"),
null,
'errors');
1002 $langs->load(
"errors");
1003 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
1005 } elseif ((
GETPOST(
'price_ht') !==
'' ||
GETPOST(
'price_ttc') !==
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') && empty($error)) {
1009 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1010 $tva_tx = str_replace(
'*',
'', $tva_tx);
1011 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1017 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
1025 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1029 $pu_ht =
price2num((
float) $pu_ttc / (1 + ((
float) $tva_tx / 100)),
'MU');
1031 $price_base_type =
'HT';
1032 $pu_ht_devise =
price2num($price_ht_devise,
'CU');
1059 (
float) $pu_ht_devise
1064 if (!$error && $result > 0) {
1071 $outputlangs = $langs;
1074 $newlang =
GETPOST(
'lang_id',
'aZ09');
1077 $newlang =
$object->thirdparty->default_lang;
1079 if (!empty($newlang)) {
1081 $outputlangs->setDefaultLang($newlang);
1089 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1095 unset($_POST[
'prod_entry_mode']);
1097 unset($_POST[
'qty']);
1098 unset($_POST[
'type']);
1099 unset($_POST[
'remise_percent']);
1100 unset($_POST[
'pu']);
1101 unset($_POST[
'price_ht']);
1102 unset($_POST[
'multicurrency_price_ht']);
1103 unset($_POST[
'price_ttc']);
1104 unset($_POST[
'fourn_ref']);
1105 unset($_POST[
'tva_tx']);
1106 unset($_POST[
'label']);
1107 unset($_POST[
'product_ref']);
1108 unset($_POST[
'product_label']);
1109 unset($_POST[
'product_desc']);
1110 unset($_POST[
'fournprice']);
1111 unset($_POST[
'buying_price']);
1112 unset($localtax1_tx);
1113 unset($localtax2_tx);
1114 unset($_POST[
'np_marginRate']);
1115 unset($_POST[
'np_markRate']);
1116 unset($_POST[
'dp_desc']);
1117 unset($_POST[
'idprodfournprice']);
1118 unset($_POST[
'units']);
1120 unset($_POST[
'idprod']);
1122 unset($_POST[
'date_starthour']);
1123 unset($_POST[
'date_startmin']);
1124 unset($_POST[
'date_startsec']);
1125 unset($_POST[
'date_startday']);
1126 unset($_POST[
'date_startmonth']);
1127 unset($_POST[
'date_startyear']);
1128 unset($_POST[
'date_endhour']);
1129 unset($_POST[
'date_endmin']);
1130 unset($_POST[
'date_endsec']);
1131 unset($_POST[
'date_endday']);
1132 unset($_POST[
'date_endmonth']);
1133 unset($_POST[
'date_endyear']);
1140 } elseif ($action ==
'updatetitleline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1143 $langs->load(
'subtotals');
1145 $desc =
GETPOST(
'line_desc',
'alphanohtml') ?? $langs->trans(
"Title");
1148 $subtotal_options = array();
1150 foreach (SupplierProposal::$TITLE_OPTIONS as $option) {
1151 $value =
GETPOST($option,
'alphanohtml');
1153 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1158 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1169 $outputlangs = $langs;
1170 $newlang =
GETPOST(
'lang_id',
'alpha');
1172 $newlang =
$object->thirdparty->default_lang;
1174 if (!empty($newlang)) {
1176 $outputlangs->setDefaultLang($newlang);
1179 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1184 } elseif ($action ==
'updatesubtotalline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1187 $langs->load(
'subtotals');
1189 $desc =
GETPOST(
'line_desc',
'alphanohtml');
1192 $subtotal_options = array();
1194 foreach (SupplierProposal::$SUBTOTAL_OPTIONS as $option) {
1195 $value =
GETPOST($option,
'alphanohtml');
1197 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1202 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1210 $outputlangs = $langs;
1211 $newlang =
GETPOST(
'lang_id',
'alpha');
1213 $newlang =
$object->thirdparty->default_lang;
1215 if (!empty($newlang)) {
1217 $outputlangs->setDefaultLang($newlang);
1220 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1225 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save') == $langs->trans(
"Save")) {
1231 if (preg_match(
'/\*/', $vat_rate)) {
1239 $vat_rate = str_replace(
'*',
'', $vat_rate);
1243 if (
GETPOST(
'price_ht') !=
'') {
1244 $price_base_type =
'HT';
1248 $vatratecleaned = $vat_rate;
1249 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) {
1250 $vatratecleaned = trim($reg[1]);
1251 $vatratecode = $reg[2];
1255 $ht = (float) $ttc / (1 + ((
float) $vatratecleaned / 100));
1256 $price_base_type =
'HT';
1266 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1267 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1269 if (is_array($extralabelsline)) {
1270 foreach ($extralabelsline as $key => $value) {
1271 unset($_POST[
"options_".$key]);
1276 $special_code =
GETPOST(
'special_code');
1283 if (!empty($productid)) {
1285 if (
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY') == 1) {
1286 if ($productid > 0 && $productsupplier->get_buyprice(0, (
float)
price2num(
GETPOST(
'qty')), $productid,
'none',
GETPOSTINT(
'socid')) < 0) {
1287 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1292 $res = $product->fetch($productid);
1294 $type = $product->type;
1296 $price_min = $product->price_min;
1298 $price_min = $product->multiprices_min [
$object->thirdparty->price_level];
1304 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1308 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1316 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1319 $result =
$object->updateline(
1340 (
float) $pu_ht_devise
1348 $outputlangs = $langs;
1351 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
1352 $outputlangs->setDefaultLang($newlang);
1355 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1358 unset($_POST[
'qty']);
1359 unset($_POST[
'type']);
1360 unset($_POST[
'productid']);
1361 unset($_POST[
'remise_percent']);
1362 unset($_POST[
'price_ht']);
1363 unset($_POST[
'multicurrency_price_ht']);
1364 unset($_POST[
'price_ttc']);
1365 unset($_POST[
'tva_tx']);
1366 unset($_POST[
'product_ref']);
1367 unset($_POST[
'product_label']);
1368 unset($_POST[
'product_desc']);
1369 unset($_POST[
'fournprice']);
1370 unset($_POST[
'buying_price']);
1372 unset($_POST[
'date_starthour']);
1373 unset($_POST[
'date_startmin']);
1374 unset($_POST[
'date_startsec']);
1375 unset($_POST[
'date_startday']);
1376 unset($_POST[
'date_startmonth']);
1377 unset($_POST[
'date_startyear']);
1378 unset($_POST[
'date_endhour']);
1379 unset($_POST[
'date_endmin']);
1380 unset($_POST[
'date_endsec']);
1381 unset($_POST[
'date_endday']);
1382 unset($_POST[
'date_endmonth']);
1383 unset($_POST[
'date_endyear']);
1390 } elseif ($action ==
'updateline' && $usercancreate && $cancel) {
1391 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
1393 } elseif ($action ==
'classin' && $usercancreate) {
1396 } elseif ($action ==
'setavailability' && $usercancreate) {
1399 } elseif ($action ==
'setconditions' && $usercancreate) {
1401 $sql =
"SELECT code ";
1402 $sql .=
"FROM " .
$db->prefix() .
"c_payment_term";
1403 $sql .=
" WHERE rowid = " .
GETPOSTINT(
'cond_reglement_id');
1404 $result =
$db->query($sql);
1406 $obj =
$db->fetch_object($result);
1407 if ($obj->code ==
'DEP30PCTDEL') {
1414 } elseif ($action ==
'setmode' && $usercancreate) {
1417 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
1419 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
1420 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
1423 } elseif ($action ==
'update_extras' && $permissiontoeditextra) {
1426 $attribute_name =
GETPOST(
'attribute',
'aZ09');
1429 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
1435 $result =
$object->updateExtraField($attribute_name,
'PROPOSAL_SUPPLIER_MODIFY');
1443 $action =
'edit_extras';
1453$title =
$object->ref.
" - ".$langs->trans(
'Card');
1454if ($action ==
'create') {
1455 $title = $langs->trans(
"SupplierProposalNew");
1457$help_url =
'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur';
1459llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-supplierproposal page-card');
1473if ($action ==
'create') {
1474 $currency_code =
$conf->currency;
1476 print
load_fiche_titre($langs->trans(
"SupplierProposalNew"),
'',
'supplier_proposal');
1480 $res = $soc->fetch($socid);
1484 if (!empty($origin) && !empty($originid)) {
1485 $element = $subelement =
GETPOST(
'origin');
1487 if (preg_match(
'/^([^_]+)_([^_]+)/i',
GETPOST(
'origin'), $regs)) {
1488 $element = $regs[1];
1489 $subelement = $regs[2];
1493 if ($element ==
'order' || $element ==
'commande') {
1494 $element = $subelement =
'commande';
1496 if ($element ==
'propal') {
1497 $element =
'comm/propal';
1498 $subelement =
'propal';
1503 $classname = ucfirst($subelement);
1504 $objectsrc =
new $classname(
$db);
1505 '@phan-var-force Commande|Propal|CommandeFournisseur|SupplierProposal $objectsrc';
1507 $objectsrc->fetch($originid);
1508 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1509 $objectsrc->fetch_lines();
1511 $objectsrc->fetch_thirdparty();
1513 $projectid = (int) $objectsrc->fk_project;
1514 $soc = $objectsrc->thirdparty;
1516 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1517 $deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent : 0));
1518 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1519 $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
1522 $objectsrc->fetch_optionals();
1523 $object->array_options = $objectsrc->array_options;
1526 if (!empty($objectsrc->multicurrency_code)) {
1527 $currency_code = $objectsrc->multicurrency_code;
1529 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
1530 $currency_tx = $objectsrc->multicurrency_tx;
1534 $cond_reglement_id = $soc->cond_reglement_supplier_id;
1535 $deposit_percent = !empty($soc->deposit_percent) ? $soc->deposit_percent : 0;
1536 $mode_reglement_id = $soc->mode_reglement_supplier_id;
1537 $fk_account = !empty($soc->fk_account) ? $soc->fk_account : 0;
1538 if (
isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
1539 $currency_code = $soc->multicurrency_code;
1542 if (
GETPOSTISSET(
'cond_reglement_id_deposit_percent')) {
1543 $deposit_percent =
GETPOSTFLOAT(
'cond_reglement_id_deposit_percent');
1548 print
'<form name="addprop" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1549 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1550 print
'<input type="hidden" name="action" value="add">';
1551 if ($origin !=
'project' && $originid) {
1552 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1553 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1555 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1560 $parameters = array();
1562 $reshook = $hookmanager->executeHooks(
'tabContentCreateSupplierProposal', $parameters, $object, $action);
1563 if (empty($reshook)) {
1564 print
'<table class="border centpercent">';
1567 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td colspan="2">'.$langs->trans(
"Draft").
'</td></tr>';
1571 print
'<td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
1573 print
'<td colspan="2">';
1574 print $soc->getNomUrl(1,
'supplier');
1575 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1578 print
'<td colspan="2">';
1579 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
1580 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company((empty($socid) ?
'' : $socid),
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1584 $(document).ready(function() {
1585 $("#socid").change(function() {
1586 console.log("We have changed the company - Reload page");
1588 $("input[name=action]").val("create");
1589 $("form[name=addprop]").submit();
1594 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>';
1601 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
1603 $absolute_discount = $soc->getAvailableDiscounts(
null,
'', 0, 1);
1607 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
1608 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1614 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td colspan="2">';
1615 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
1616 print $form->getSelectConditionsPaiements(
GETPOSTISSET(
'cond_reglement_id') ?
GETPOSTINT(
'cond_reglement_id') : $cond_reglement_id,
'cond_reglement_id', -1, 1, 0,
'', $deposit_percent);
1620 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td colspan="2">';
1621 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1622 $form->select_types_paiements(
GETPOST(
'mode_reglement_id') > 0 ?
GETPOST(
'mode_reglement_id') : $mode_reglement_id,
'mode_reglement_id');
1627 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td colspan="2">';
1628 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1629 $form->select_comptes(
GETPOST(
'fk_account') > 0 ?
GETPOSTINT(
'fk_account') : $fk_account,
'fk_account', 0,
'', 1);
1635 print
'<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td colspan="2">';
1636 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1637 $form->selectShippingMethod(
GETPOST(
'shipping_method_id') > 0 ?
GETPOSTINT(
'shipping_method_id') :
"",
'shipping_method_id',
'', 1);
1642 print
'<tr><td>'.$langs->trans(
"DeliveryDate").
'</td>';
1643 print
'<td colspan="2">';
1644 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1647 $tmpdte = time() + (7 *
getDolGlobalInt(
'DATE_LIVRAISON_WEEK_DELAY') * 24 * 60 * 60);
1648 $syear =
date(
"Y", $tmpdte);
1649 $smonth =
date(
"m", $tmpdte);
1650 $sday =
date(
"d", $tmpdte);
1651 print $form->selectDate($syear.
"-".$smonth.
"-".$sday,
'liv_', 0, 0, 0,
"addask");
1653 print $form->selectDate($datedelivery ? $datedelivery : -1,
'liv_', 0, 0, 0,
"addask", 1, 1);
1660 if (count($list) > 0) {
1662 print
'<td>'.$langs->trans(
"DefaultModel").
'</td>';
1663 print
'<td colspan="2">';
1664 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1666 print $form->selectarray(
'model', $list, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1672 $langs->load(
"projects");
1676 if ($origin ==
'project') {
1677 $projectid = ($originid ? $originid : 0);
1681 print
'<td>'.$langs->trans(
"Project").
'</td><td colspan="2">';
1682 if (!empty($user->socid)) {
1683 $projSocFilter = $user->socid;
1684 } elseif (
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') || $socid == 0) {
1687 $projSocFilter = -1;
1689 $projSocFilter = $socid;
1691 print
img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects($projSocFilter, $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
1692 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.((int) $soc->id).
'&action=create&status=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create&socid='.$soc->id).
'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1700 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
1701 print
'<td colspan="3" class="maxwidthonsmartphone">';
1702 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
1703 print $form->selectMultiCurrency($currency_code,
'multicurrency_code');
1708 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
1709 print $form->selectCategories(Categorie::TYPE_SUPPLIER_PROPOSAL,
'categories', $object);
1714 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' => 3);
1715 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1716 print $hookmanager->resPrint;
1717 if (empty($reshook)) {
1718 print
$object->showOptionals($extrafields,
'create', $parameters);
1723 if (!empty($origin) && !empty($originid) && is_object($objectsrc) && $classname !==
null) {
1725 if ($origin ==
'contrat') {
1727 $objectsrc->update_price(1,
'auto', 1);
1730 print
"\n<!-- ".$classname.
" info -->";
1732 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
1733 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
1734 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
1735 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
1736 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
1738 print
'<tr><td>'.$langs->trans(
'CommRequest').
'</td><td colspan="2">'.$objectsrc->getNomUrl(1).
'</td></tr>';
1739 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td colspan="2">'.
price($objectsrc->total_ht).
'</td></tr>';
1740 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td colspan="2">'.
price($objectsrc->total_tva).
"</td></tr>";
1741 if (
$mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
1742 print
'<tr><td>'.$langs->transcountry(
"AmountLT1",
$mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax1).
"</td></tr>";
1745 if (
$mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
1746 print
'<tr><td>'.$langs->transcountry(
"AmountLT2",
$mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax2).
"</td></tr>";
1748 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td colspan="2">'.
price($objectsrc->total_ttc).
"</td></tr>";
1751 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_ht, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
'</td></tr>';
1752 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_tva, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
"</td></tr>";
1753 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_ttc, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
"</td></tr>";
1765 print
'<input type="hidden" name="createmode" value="empty">';
1769 print
'<br><table>';
1773 print
'<td><input type="radio" name="createmode" value="copy"></td>';
1774 print
'<td>'.$langs->trans(
"CopyAskFrom").
' </td>';
1776 $liste_ask = array();
1777 $liste_ask [0] =
'';
1779 $sql =
"SELECT p.rowid as id, p.ref, s.nom";
1780 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal p";
1781 $sql .=
", ".MAIN_DB_PREFIX.
"societe s";
1782 $sql .=
" WHERE s.rowid = p.fk_soc";
1783 $sql .=
" AND p.entityy IN (".getEntity(
'supplier_proposal').
")";
1784 $sql .=
" AND p.fk_statut <> ".SupplierProposal::STATUS_DRAFT;
1785 $sql .=
" ORDER BY Id";
1787 $resql =
$db->query($sql);
1789 $num =
$db->num_rows($resql);
1792 $row =
$db->fetch_row($resql);
1793 $askPriceSupplierRefAndSocName = $row[1].
" - ".$row[2];
1794 $liste_ask[$row[0]] = $askPriceSupplierRefAndSocName;
1797 print $form->selectarray(
"copie_supplier_proposal", $liste_ask, 0);
1803 print
'<tr><td class="tdtop"><input type="radio" name="createmode" value="empty" checked></td>';
1804 print
'<td valign="top" colspan="2">'.$langs->trans(
"CreateEmptyAsk").
'</td></tr>';
1814 print $form->buttonsSaveCancel(
"CreateDraft");
1820 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1823 $title = $langs->trans(
'ProductsAndServices');
1826 print
'<div class="div-table-responsive-no-min">';
1827 print
'<table class="noborder centpercent">';
1829 $objectsrc->printOriginLinesList();
1843 print
dol_get_fiche_head($head,
'comm', $langs->trans(
'CommRequest'), -1,
'supplier_proposal', 0,
'',
'', 0,
'', 1);
1848 if ($action ==
'clone') {
1849 $filter =
'(s.fournisseur:=:1)';
1851 $formquestion = array(
1859 'label' => $langs->trans(
"SelectThirdParty"),
1860 'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter))
1863 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
1864 } elseif ($action ==
'delete') {
1866 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteAsk'), $langs->trans(
'ConfirmDeleteAsk',
$object->ref),
'confirm_delete',
'', 0, 1);
1867 } elseif ($action ==
'reopen') {
1869 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ReOpen'), $langs->trans(
'ConfirmReOpenAsk',
$object->ref),
'confirm_reopen',
'', 0, 1);
1870 } elseif ($action ==
'ask_deleteline') {
1872 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
1873 } elseif ($action ==
'ask_subtotal_deleteline') {
1875 $langs->load(
"subtotals");
1876 $title =
"DeleteSubtotalLine";
1877 $question =
"ConfirmDeleteSubtotalLine";
1878 if (
GETPOST(
'type') ==
'title') {
1881 'type' =>
'checkbox',
1882 'name' =>
'deletecorrespondingsubtotalline',
1883 'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
1887 $title =
"DeleteTitleLine";
1888 $question =
"ConfirmDeleteTitleLine";
1890 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
1891 } elseif ($action ==
'validate') {
1896 $ref = substr(
$object->ref, 1, 4);
1897 if ($ref ==
'PROV') {
1898 $numref =
$object->getNextNumRef($soc);
1899 if (empty($numref)) {
1907 $text = $langs->trans(
'ConfirmValidateAsk', $numref);
1909 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
1912 $text .= $notify->confirmMessage(
'PROPOSAL_SUPPLIER_VALIDATE',
$object->socid, $object);
1916 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateAsk'), $text,
'confirm_validate',
'', 0, 1);
1920 if ($action ==
'add_title_line') {
1921 $langs->load(
'subtotals');
1923 $depth_array =
$object->getPossibleLevels($langs);
1925 } elseif ($action ==
'add_subtotal_line') {
1926 $langs->load(
'subtotals');
1928 $titles =
$object->getPossibleTitles();
1933 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
1934 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1935 if (empty($reshook)) {
1936 $formconfirm .= $hookmanager->resPrint;
1937 } elseif ($reshook > 0) {
1938 $formconfirm = $hookmanager->resPrint;
1946 $linkback =
'<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1949 $morehtmlref =
'<div class="refidno">';
1954 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'supplier');
1956 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.
$object->thirdparty->id.
'">'.$langs->trans(
"OtherProposals").
'</a>)';
1960 $langs->load(
"projects");
1961 $morehtmlref .=
'<br>';
1962 if ($usercancreate) {
1963 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
1964 if ($action !=
'classify') {
1965 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
1968 $canLinkAll = ($canLinkAll ===
'' || $canLinkAll ===
false) ? 0 : $canLinkAll;
1970 $projectSocId = ((int) $canLinkAll == 1) ? -1 : $currentSocId;
1971 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $projectSocId,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
1973 if (!empty(
$object->fk_project)) {
1975 $proj->fetch(
$object->fk_project);
1976 $morehtmlref .= $proj->getNomUrl(1);
1978 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
1983 $morehtmlref .=
'</div>';
1986 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1989 $parameters = array();
1991 $reshook = $hookmanager->executeHooks(
'tabContentViewSupplierProposal', $parameters, $object, $action);
1992 if (empty($reshook)) {
1993 print
'<div class="fichecenter">';
1994 print
'<div class="fichehalfleft">';
1995 print
'<div class="underbanner clearboth"></div>';
1997 print
'<table class="border tableforfield centpercent">';
2001 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
2002 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
2004 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
2005 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
2008 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td>';
2010 $absolute_discount = $soc->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
2011 $absolute_creditnote = $soc->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
2012 $absolute_discount =
price2num($absolute_discount,
'MT');
2013 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
2017 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
2018 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2023 print
'<tr><td class="titlefield">';
2024 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2025 print $langs->trans(
'PaymentConditionsShort');
2028 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>';
2030 print
'</tr></table>';
2031 print
'</td><td class="valuefield">';
2032 if ($action ==
'editconditions') {
2033 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
2035 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'none', 1,
'', 1,
$object->deposit_percent);
2042 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2043 print $langs->trans(
'DeliveryDate');
2046 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>';
2048 print
'</tr></table>';
2049 print
'</td><td class="valuefield">';
2050 if ($action ==
'editdate_livraison') {
2051 print
'<form name="editdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post" class="formconsumeproduce">';
2052 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2053 print
'<input type="hidden" name="action" value="setdate_livraison">';
2054 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2055 print $form->selectDate(
$object->delivery_date,
'liv_', 0, 0, 0,
"editdate_livraison");
2056 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2067 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2068 print $langs->trans(
'PaymentMode');
2071 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>';
2073 print
'</tr></table>';
2074 print
'</td><td class="valuefield">';
2075 if ($action ==
'editmode') {
2076 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
2078 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
2098 print
'<table width="100%" class="nobordernopadding"><tr><td>';
2099 print $langs->trans(
'BankAccount');
2101 if ($action !=
'editbankaccount' && $usercancreate) {
2102 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>';
2104 print
'</tr></table>';
2105 print
'</td><td class="valuefield">';
2106 if ($action ==
'editbankaccount') {
2107 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
2109 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'none');
2117 print
'<table class="nobordernopadding centpercent"><tr><td>';
2118 print $langs->trans(
"Categories");
2119 print
'<td><td class="right">';
2120 if ($usercancreate) {
2121 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/supplier_proposal/card.php?id='.
$object->id.
'&action=edittags&token='.
newToken().
'">'.
img_edit().
'</a>';
2125 print
'</td></tr></table>';
2128 if ($action ==
'edittags') {
2129 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
2130 print
'<input type="hidden" name="action" value="settags">';
2131 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2132 print $form->selectCategories(Categorie::TYPE_SUPPLIER_PROPOSAL,
'categories', $object);
2133 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
2136 print $form->showCategories(
$object->id, Categorie::TYPE_SUPPLIER_PROPOSAL, 1);
2141 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2146 print
'<div class="fichehalfright">';
2147 print
'<div class="underbanner clearboth"></div>';
2149 print
'<table class="border tableforfield centpercent">';
2151 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
2155 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
2156 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2159 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2165 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
2166 print
'<td class="nowrap amountcard right">' .
price(
$object->total_tva, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2169 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2174 if (
$mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
2176 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1",
$mysoc->country_code) .
'</td>';
2177 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2179 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2183 if (
$mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
2185 print
'<td>' . $langs->transcountry(
"AmountLT2",
$mysoc->country_code) .
'</td>';
2186 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2188 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2196 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
2197 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2200 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2214 print
'<div class="clearboth"></div><br>';
2217 $blocname =
'contacts';
2218 $title = $langs->trans(
'ContactsAddresses');
2219 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2223 $blocname =
'notes';
2224 $title = $langs->trans(
'Notes');
2225 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2233 $result =
$object->getLinesArray();
2235 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'#add' :
'').
'" method="POST">
2236 <input type="hidden" name="token" value="' .
newToken().
'">
2237 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
2238 <input type="hidden" name="mode" value="">
2239 <input type="hidden" name="id" value="' .
$object->id.
'">
2245 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_ajaxrow.tpl.php';
2247 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
2251 print
'<div class="div-table-responsive-no-min">';
2252 print
'<table id="tablelines" class="noborder noshadow centpercent">';
2255 global $forceall, $senderissupplier, $inputalsopricewithtax;
2258 $inputalsopricewithtax = 1;
2259 $senderissupplier = 2;
2260 if (
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY')) {
2261 $senderissupplier =
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY');
2265 $object->printObjectLines($action, $soc,
$mysoc, $lineid, $dateSelector);
2270 if ($action !=
'editline') {
2273 $parameters = array(
'dateSelector' => $dateSelector);
2274 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
2278 if (empty($reshook)) {
2291 if ($action ==
'statut') {
2293 $form_close =
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST" id="formacceptrefuse" class="formconsumeproduce paddingbottom paddingleft paddingright">';
2294 $form_close .=
'<input type="hidden" name="token" value="'.newToken().
'">';
2295 $form_close .=
'<input type="hidden" name="action" value="setstatut">';
2298 $form_close .=
'<p class="notice">'.$langs->trans(
'SupplierProposalRefFournNotice').
'</p>';
2300 $form_close .=
'<table class="border centpercent marginleftonly marginrightonly">';
2301 $form_close .=
'<tr><td>'.$langs->trans(
"CloseAs").
'</td><td class="left">';
2302 $form_close .=
'<select id="statut" name="statut" class="flat">';
2303 $form_close .=
'<option value="0"> </option>';
2304 $form_close .=
'<option value="2">'.$langs->trans(
'SupplierProposalStatusSigned').
'</option>';
2305 $form_close .=
'<option value="3">'.$langs->trans(
'SupplierProposalStatusNotSigned').
'</option>';
2306 $form_close .=
'</select>';
2307 $form_close .=
'</td></tr>';
2308 $form_close .=
'<tr><td class="left">'.$langs->trans(
'Note').
'</td><td class="left"><textarea cols="70" rows="'.ROWS_3.
'" wrap="soft" name="note">';
2309 $form_close .=
$object->note_private;
2310 $form_close .=
'</textarea></td></tr>';
2311 $form_close .=
'</table>';
2312 $form_close .= $form->buttonsSaveCancel();
2313 $form_close .=
'<a id="acceptedrefused"> </a>';
2314 $form_close .=
'</form>';
2322 if ($action !=
'presend') {
2323 print
'<div class="tabsAction">';
2325 $parameters = array();
2326 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2328 if (empty($reshook)) {
2329 if ($action !=
'statut' && $action !=
'editline') {
2332 $langs->load(
'subtotals');
2334 $url_button = array();
2336 $url_button[] = array(
2337 'lang' =>
'subtotals',
2339 'perm' => (
bool) $usercancreate,
2340 'label' => $langs->trans(
'AddTitleLine'),
2341 'url' =>
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'add_title_line'],
true)
2344 $url_button[] = array(
2345 'lang' =>
'subtotals',
2347 'perm' => (
bool) $usercancreate,
2348 'label' => $langs->trans(
'AddSubtotalLine'),
2349 'url' =>
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'add_subtotal_line'],
true)
2352 print
dolGetButtonAction(
'', $langs->trans(
'SubTotal'),
'default', $url_button,
'',
true);
2356 if (count(
$object->lines) > 0) {
2357 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>';
2364 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>';
2369 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').
'"';
2370 print
'>'.$langs->trans(
'ReOpen').
'</a></div>';
2374 if (empty($user->socid)) {
2377 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'presend',
'mode' =>
'init'],
true).
'#formmailbeforetitle',
'');
2386 if ($usercancreateorder) {
2387 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>';
2393 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').
'"';
2394 print
'>'.$langs->trans(
'SetAcceptedRefused').
'</a></div>';
2399 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').
'"';
2400 print
'>'.$langs->trans(
'Close').
'</a></div>';
2404 if ($usercancreate) {
2405 print
'<div class="inline-block divButAction"><a class="butAction butActionClone" href="'.$_SERVER[
'PHP_SELF'].
'?id='.((int)
$object->id).
'&socid='.((int)
$object->socid).
'&action=clone&object='.urlencode(
$object->element).
'&token='.
newToken().
'">'.$langs->trans(
"ToClone").
'</a></div>';
2416 if ($action !=
'presend') {
2417 print
'<div class="fichecenter"><div class="fichehalfleft">';
2424 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
2425 $genallowed = $usercanread;
2426 $delallowed = $usercancreate;
2428 print $formfile->showdocuments(
'supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
2432 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'supplier_proposal'), 1);
2433 $linktoelem = $tmparray[
'linktoelem'];
2434 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
2435 print $htmltoenteralink;
2437 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
2441 print
'</div><div class="fichehalfright">';
2444 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2446 $somethingshown = $formactions->showactions($object,
'supplier_proposal', $socid, 1,
'', $MAXEVENT);
2448 print
'</div></div>';
2452 if (
GETPOST(
'modelselected')) {
2453 $action =
'presend';
2457 $modelmail =
'supplier_proposal_send';
2458 $defaulttopic =
'SendAskRef';
2459 $diroutput =
$conf->supplier_proposal->dir_output;
2460 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
2461 $trackid =
'spro'.$object->id;
2463 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage the table of subscription to notifications.
Class to manage predefined suppliers products.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage price ask supplier.
const STATUS_NOTSIGNED
Not signed quote, canceled.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
const STATUS_SIGNED
Signed quote.
const STATUS_CLOSE
Billed or closed/processed quote.
Class to manage supplier_proposal lines.
Class to manage translations.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
$date_start
Variables from include:
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
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...
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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 rate, when selling a product with vat $vatrate,...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.
supplier_proposal_prepare_head($object)
Prepare array with list of tabs.