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')) {
602 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"CloseAs")),
null,
'errors');
610 } elseif ($action ==
'addline' &&
GETPOST(
'updateallvatlinesblock',
'alpha') &&
GETPOST(
'vatforblocklines',
'alpha') !==
'' && $usercancreate) {
611 $tx_tva =
GETPOST(
'vatforblocklines') ?
GETPOST(
'vatforblocklines') : 0;
612 $object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'tva', $tx_tva);
613 } elseif ($action ==
'addline' &&
GETPOST(
'updatealldiscountlinesblock',
'alpha') &&
GETPOST(
'discountforblocklines',
'alpha') !==
'' && $usercancreate) {
614 $discount =
GETPOST(
'discountforblocklines') ?
GETPOST(
'discountforblocklines') : 0;
615 $object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'discount', $discount);
616 } elseif ($action ==
'settags' &&
isModEnabled(
'category') && $usercancreate) {
621 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
624 $triggersendname =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
625 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
626 $trackid =
'spro'.$object->id;
627 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
630 $upload_dir =
$conf->supplier_proposal->dir_output;
631 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
634 if ($action ==
'modif' && $usercancreate) {
639 $outputlangs = $langs;
642 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
643 $outputlangs->setDefaultLang($newlang);
649 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
651 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
663 if ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') && $usercancreate) {
665 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
666 $vat_rate = str_replace(
'*',
'', $vat_rate);
669 foreach (
$object->lines as $line) {
670 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
673 $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);
675 } elseif ($action ==
'confirm_addtitleline' && $usercancreate) {
678 $langs->load(
'subtotals');
680 $desc =
GETPOST(
'subtotallinedesc',
'alphanohtml');
681 $depth =
GETPOSTINT(
'subtotallinelevel') ?? 1;
683 $subtotal_options = array();
685 foreach (SupplierProposal::$TITLE_OPTIONS as $option) {
686 $value =
GETPOST($option,
'alphanohtml');
688 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
693 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
704 $outputlangs = $langs;
705 $newlang =
GETPOST(
'lang_id',
'alpha');
707 $newlang =
$object->thirdparty->default_lang;
709 if (!empty($newlang)) {
711 $outputlangs->setDefaultLang($newlang);
714 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
719 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
721 } elseif ($action ==
'confirm_addsubtotalline' && $usercancreate) {
724 $langs->load(
'subtotals');
726 $choosen_line =
GETPOST(
'subtotaltitleline',
'alphanohtml');
727 foreach (
$object->lines as $line) {
728 if ($line->desc == $choosen_line && $line->special_code == SUBTOTALS_SPECIAL_CODE) {
730 $depth = -$line->qty;
734 $subtotal_options = array();
736 foreach (SupplierProposal::$SUBTOTAL_OPTIONS as $option) {
737 $value =
GETPOST($option,
'alphanohtml');
739 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
744 if (isset($desc) && isset($depth)) {
745 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
748 $object->errors[] = $langs->trans(
"CorrespondingTitleNotFound");
757 $outputlangs = $langs;
758 $newlang =
GETPOST(
'lang_id',
'alpha');
760 $newlang =
$object->thirdparty->default_lang;
762 if (!empty($newlang)) {
764 $outputlangs->setDefaultLang($newlang);
767 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
772 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
774 } elseif ($action ==
'addline' && $usercancreate) {
775 $langs->load(
'errors');
784 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
786 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
787 if ($prod_entry_mode ==
'free') {
803 if (empty($remise_percent)) {
808 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
809 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
811 if (is_array($extralabelsline)) {
813 foreach ($extralabelsline as $key => $value) {
814 unset($_POST[
"options_".$key]);
818 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
819 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
822 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
823 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
827 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' &&
GETPOST(
'multicurrency_price_ht') ===
'') {
828 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPrice")),
null,
'errors');
831 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($line_desc)) {
832 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Description")),
null,
'errors');
835 if (!$error && ($qty >= 0)) {
839 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
843 if ($prod_entry_mode !=
'free' && empty($error)) {
847 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
852 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
853 $idprod = (int) $reg[1];
854 $res = $productsupplier->fetch($idprod);
857 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
859 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
860 if ($productsupplier->fourn_socid != $socid) {
861 $productsupplier->ref_supplier =
'';
864 $fksoctosearch =
$object->thirdparty->id;
865 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
867 } elseif (
GETPOSTINT(
'idprodfournprice') > 0) {
870 $idprod = $productsupplier->get_buyprice(
GETPOSTINT(
'idprodfournprice'), $qtytosearch);
871 $res = $productsupplier->fetch($idprod);
875 $label = $productsupplier->label;
879 $outputlangs = $langs;
881 if (
GETPOST(
'lang_id',
'aZ09')) {
882 $newlang =
GETPOST(
'lang_id',
'aZ09');
884 if (empty($newlang)) {
885 $newlang =
$object->thirdparty->default_lang;
887 if (!empty($newlang)) {
889 $outputlangs->setDefaultLang($newlang);
891 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->
description;
893 $desc = $productsupplier->description;
896 if (!empty($productsupplier->desc_supplier) &&
getDolGlobalString(
'PRODUIT_FOURN_TEXTS')) {
897 $desc = $productsupplier->desc_supplier;
908 $ref_supplier = $productsupplier->ref_supplier;
913 $tmpidprodfournprice =
GETPOST(
'idprodfournprice',
'alpha');
914 if (is_numeric($tmpidprodfournprice) && (
int) $tmpidprodfournprice > 0) {
915 $tmpidprodfournprice = (int) $tmpidprodfournprice;
917 $tmpidprodfournprice = 0;
923 if (empty($tva_tx)) {
929 $type = $productsupplier->type;
930 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
931 $price_base_type =
'HT';
933 $pu_devise =
price2num($price_ht_devise,
'CU');
934 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
935 $price_base_type =
'TTC';
937 $pu_devise =
price2num($price_ttc_devise,
'CU');
939 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
940 if (empty(
$object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code !=
$object->multicurrency_code)) {
941 $pu = $productsupplier->fourn_pu;
944 $pu = $productsupplier->fourn_pu;
945 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
954 $fournprice = (is_numeric(
GETPOST(
'idprodfournprice',
'alpha')) ?
GETPOST(
'idprodfournprice',
'alpha') : -1);
959 ($price_base_type ==
'HT' ? $pu : 0),
964 $productsupplier->id,
967 ($price_base_type ==
'TTC' ? $pu : 0),
970 min($rank, count(
$object->lines) + 1),
978 $productsupplier->fk_unit,
994 if ($idprod == -99 || $idprod == 0) {
997 $langs->load(
"errors");
998 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")).
' '.$langs->trans(
"or").
' '.$langs->trans(
"NoPriceDefinedForThisSupplier"),
null,
'errors');
1000 if ($idprod == -1) {
1003 $langs->load(
"errors");
1004 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
1006 } elseif ((
GETPOST(
'price_ht') !==
'' ||
GETPOST(
'price_ttc') !==
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') && empty($error)) {
1010 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1011 $tva_tx = str_replace(
'*',
'', $tva_tx);
1012 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1018 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
1026 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1030 $pu_ht =
price2num((
float) $pu_ttc / (1 + ((
float) $tva_tx / 100)),
'MU');
1032 $price_base_type =
'HT';
1033 $pu_ht_devise =
price2num($price_ht_devise,
'CU');
1060 (
float) $pu_ht_devise
1065 if (!$error && $result > 0) {
1072 $outputlangs = $langs;
1075 $newlang =
GETPOST(
'lang_id',
'aZ09');
1078 $newlang =
$object->thirdparty->default_lang;
1080 if (!empty($newlang)) {
1082 $outputlangs->setDefaultLang($newlang);
1090 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1096 unset($_POST[
'prod_entry_mode']);
1098 unset($_POST[
'qty']);
1099 unset($_POST[
'type']);
1100 unset($_POST[
'remise_percent']);
1101 unset($_POST[
'pu']);
1102 unset($_POST[
'price_ht']);
1103 unset($_POST[
'multicurrency_price_ht']);
1104 unset($_POST[
'price_ttc']);
1105 unset($_POST[
'fourn_ref']);
1106 unset($_POST[
'tva_tx']);
1107 unset($_POST[
'label']);
1108 unset($_POST[
'product_ref']);
1109 unset($_POST[
'product_label']);
1110 unset($_POST[
'product_desc']);
1111 unset($_POST[
'fournprice']);
1112 unset($_POST[
'buying_price']);
1113 unset($localtax1_tx);
1114 unset($localtax2_tx);
1115 unset($_POST[
'np_marginRate']);
1116 unset($_POST[
'np_markRate']);
1117 unset($_POST[
'dp_desc']);
1118 unset($_POST[
'idprodfournprice']);
1119 unset($_POST[
'units']);
1121 unset($_POST[
'idprod']);
1123 unset($_POST[
'date_starthour']);
1124 unset($_POST[
'date_startmin']);
1125 unset($_POST[
'date_startsec']);
1126 unset($_POST[
'date_startday']);
1127 unset($_POST[
'date_startmonth']);
1128 unset($_POST[
'date_startyear']);
1129 unset($_POST[
'date_endhour']);
1130 unset($_POST[
'date_endmin']);
1131 unset($_POST[
'date_endsec']);
1132 unset($_POST[
'date_endday']);
1133 unset($_POST[
'date_endmonth']);
1134 unset($_POST[
'date_endyear']);
1141 } elseif ($action ==
'updatetitleline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1144 $langs->load(
'subtotals');
1146 $desc =
GETPOST(
'line_desc',
'alphanohtml') ?? $langs->trans(
"Title");
1149 $subtotal_options = array();
1151 foreach (SupplierProposal::$TITLE_OPTIONS as $option) {
1152 $value =
GETPOST($option,
'alphanohtml');
1154 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1159 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1170 $outputlangs = $langs;
1171 $newlang =
GETPOST(
'lang_id',
'alpha');
1173 $newlang =
$object->thirdparty->default_lang;
1175 if (!empty($newlang)) {
1177 $outputlangs->setDefaultLang($newlang);
1180 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1185 } elseif ($action ==
'updatesubtotalline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1188 $langs->load(
'subtotals');
1190 $desc =
GETPOST(
'line_desc',
'alphanohtml');
1193 $subtotal_options = array();
1195 foreach (SupplierProposal::$SUBTOTAL_OPTIONS as $option) {
1196 $value =
GETPOST($option,
'alphanohtml');
1198 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1203 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1211 $outputlangs = $langs;
1212 $newlang =
GETPOST(
'lang_id',
'alpha');
1214 $newlang =
$object->thirdparty->default_lang;
1216 if (!empty($newlang)) {
1218 $outputlangs->setDefaultLang($newlang);
1221 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1226 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save') == $langs->trans(
"Save")) {
1232 if (preg_match(
'/\*/', $vat_rate)) {
1240 $vat_rate = str_replace(
'*',
'', $vat_rate);
1244 if (
GETPOST(
'price_ht') !=
'') {
1245 $price_base_type =
'HT';
1249 $vatratecleaned = $vat_rate;
1250 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) {
1251 $vatratecleaned = trim($reg[1]);
1252 $vatratecode = $reg[2];
1256 $ht = (float) $ttc / (1 + ((
float) $vatratecleaned / 100));
1257 $price_base_type =
'HT';
1267 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1268 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1270 if (is_array($extralabelsline)) {
1271 foreach ($extralabelsline as $key => $value) {
1272 unset($_POST[
"options_".$key]);
1277 $special_code =
GETPOST(
'special_code');
1284 if (!empty($productid)) {
1286 if (
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY') == 1) {
1287 if ($productid > 0 && $productsupplier->get_buyprice(0, (
float)
price2num(
GETPOST(
'qty')), $productid,
'none',
GETPOSTINT(
'socid')) < 0) {
1288 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1293 $res = $product->fetch($productid);
1295 $type = $product->type;
1297 $price_min = $product->price_min;
1299 $price_min = $product->multiprices_min [
$object->thirdparty->price_level];
1305 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1309 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1317 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1320 $result =
$object->updateline(
1341 (
float) $pu_ht_devise
1349 $outputlangs = $langs;
1352 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
1353 $outputlangs->setDefaultLang($newlang);
1356 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1359 unset($_POST[
'qty']);
1360 unset($_POST[
'type']);
1361 unset($_POST[
'productid']);
1362 unset($_POST[
'remise_percent']);
1363 unset($_POST[
'price_ht']);
1364 unset($_POST[
'multicurrency_price_ht']);
1365 unset($_POST[
'price_ttc']);
1366 unset($_POST[
'tva_tx']);
1367 unset($_POST[
'product_ref']);
1368 unset($_POST[
'product_label']);
1369 unset($_POST[
'product_desc']);
1370 unset($_POST[
'fournprice']);
1371 unset($_POST[
'buying_price']);
1373 unset($_POST[
'date_starthour']);
1374 unset($_POST[
'date_startmin']);
1375 unset($_POST[
'date_startsec']);
1376 unset($_POST[
'date_startday']);
1377 unset($_POST[
'date_startmonth']);
1378 unset($_POST[
'date_startyear']);
1379 unset($_POST[
'date_endhour']);
1380 unset($_POST[
'date_endmin']);
1381 unset($_POST[
'date_endsec']);
1382 unset($_POST[
'date_endday']);
1383 unset($_POST[
'date_endmonth']);
1384 unset($_POST[
'date_endyear']);
1391 } elseif ($action ==
'updateline' && $usercancreate && $cancel) {
1392 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
1394 } elseif ($action ==
'classin' && $usercancreate) {
1397 } elseif ($action ==
'setavailability' && $usercancreate) {
1400 } elseif ($action ==
'setconditions' && $usercancreate) {
1402 $sql =
"SELECT code ";
1403 $sql .=
"FROM " .
$db->prefix() .
"c_payment_term";
1404 $sql .=
" WHERE rowid = " .
GETPOSTINT(
'cond_reglement_id');
1405 $result =
$db->query($sql);
1407 $obj =
$db->fetch_object($result);
1408 if ($obj->code ==
'DEP30PCTDEL') {
1415 } elseif ($action ==
'setmode' && $usercancreate) {
1418 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
1420 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
1421 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
1424 } elseif ($action ==
'update_extras' && $permissiontoeditextra) {
1427 $attribute_name =
GETPOST(
'attribute',
'aZ09');
1430 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
1436 $result =
$object->updateExtraField($attribute_name,
'PROPOSAL_SUPPLIER_MODIFY');
1444 $action =
'edit_extras';
1454$title =
$object->ref.
" - ".$langs->trans(
'Card');
1455if ($action ==
'create') {
1456 $title = $langs->trans(
"SupplierProposalNew");
1458$help_url =
'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur';
1460llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-supplierproposal page-card');
1474if ($action ==
'create') {
1475 $currency_code =
$conf->currency;
1477 print
load_fiche_titre($langs->trans(
"SupplierProposalNew"),
'',
'supplier_proposal');
1481 $res = $soc->fetch($socid);
1485 if (!empty($origin) && !empty($originid)) {
1486 $element = $subelement =
GETPOST(
'origin');
1488 if (preg_match(
'/^([^_]+)_([^_]+)/i',
GETPOST(
'origin'), $regs)) {
1489 $element = $regs[1];
1490 $subelement = $regs[2];
1494 if ($element ==
'order' || $element ==
'commande') {
1495 $element = $subelement =
'commande';
1497 if ($element ==
'propal') {
1498 $element =
'comm/propal';
1499 $subelement =
'propal';
1504 $classname = ucfirst($subelement);
1505 $objectsrc =
new $classname(
$db);
1506 '@phan-var-force Commande|Propal|CommandeFournisseur|SupplierProposal $objectsrc';
1508 $objectsrc->fetch($originid);
1509 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1510 $objectsrc->fetch_lines();
1512 $objectsrc->fetch_thirdparty();
1514 $projectid = (int) $objectsrc->fk_project;
1515 $soc = $objectsrc->thirdparty;
1517 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1518 $deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent : 0));
1519 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1520 $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
1523 $objectsrc->fetch_optionals();
1524 $object->array_options = $objectsrc->array_options;
1527 if (!empty($objectsrc->multicurrency_code)) {
1528 $currency_code = $objectsrc->multicurrency_code;
1530 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
1531 $currency_tx = $objectsrc->multicurrency_tx;
1535 $cond_reglement_id = $soc->cond_reglement_supplier_id;
1536 $deposit_percent = !empty($soc->deposit_percent) ? $soc->deposit_percent : 0;
1537 $mode_reglement_id = $soc->mode_reglement_supplier_id;
1538 $fk_account = !empty($soc->fk_account) ? $soc->fk_account : 0;
1539 if (
isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
1540 $currency_code = $soc->multicurrency_code;
1543 if (
GETPOSTISSET(
'cond_reglement_id_deposit_percent')) {
1544 $deposit_percent =
GETPOSTFLOAT(
'cond_reglement_id_deposit_percent');
1549 print
'<form name="addprop" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1550 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1551 print
'<input type="hidden" name="action" value="add">';
1552 if ($origin !=
'project' && $originid) {
1553 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1554 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1556 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1561 $parameters = array();
1563 $reshook = $hookmanager->executeHooks(
'tabContentCreateSupplierProposal', $parameters, $object, $action);
1564 if (empty($reshook)) {
1565 print
'<table class="border centpercent">';
1568 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td colspan="2">'.$langs->trans(
"Draft").
'</td></tr>';
1572 print
'<td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
1574 print
'<td colspan="2">';
1575 print $soc->getNomUrl(1,
'supplier');
1576 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1579 print
'<td colspan="2">';
1580 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
1581 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company((empty($socid) ?
'' : $socid),
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1585 $(document).ready(function() {
1586 $("#socid").change(function() {
1587 console.log("We have changed the company - Reload page");
1589 $("input[name=action]").val("create");
1590 $("form[name=addprop]").submit();
1595 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>';
1602 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
1604 $absolute_discount = $soc->getAvailableDiscounts(
null,
'', 0, 1);
1608 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
1609 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1615 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td colspan="2">';
1616 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
1617 print $form->getSelectConditionsPaiements(
GETPOSTISSET(
'cond_reglement_id') ?
GETPOSTINT(
'cond_reglement_id') : $cond_reglement_id,
'cond_reglement_id', -1, 1, 0,
'', $deposit_percent);
1621 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td colspan="2">';
1622 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1623 $form->select_types_paiements(
GETPOST(
'mode_reglement_id') > 0 ?
GETPOST(
'mode_reglement_id') : $mode_reglement_id,
'mode_reglement_id');
1628 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td colspan="2">';
1629 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1630 $form->select_comptes(
GETPOST(
'fk_account') > 0 ?
GETPOSTINT(
'fk_account') : $fk_account,
'fk_account', 0,
'', 1);
1636 print
'<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td colspan="2">';
1637 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1638 $form->selectShippingMethod(
GETPOST(
'shipping_method_id') > 0 ?
GETPOSTINT(
'shipping_method_id') :
"",
'shipping_method_id',
'', 1);
1643 print
'<tr><td>'.$langs->trans(
"DeliveryDate").
'</td>';
1644 print
'<td colspan="2">';
1645 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1648 $tmpdte = time() + (7 *
getDolGlobalInt(
'DATE_LIVRAISON_WEEK_DELAY') * 24 * 60 * 60);
1649 $syear =
date(
"Y", $tmpdte);
1650 $smonth =
date(
"m", $tmpdte);
1651 $sday =
date(
"d", $tmpdte);
1652 print $form->selectDate($syear.
"-".$smonth.
"-".$sday,
'liv_', 0, 0, 0,
"addask");
1654 print $form->selectDate($datedelivery ? $datedelivery : -1,
'liv_', 0, 0, 0,
"addask", 1, 1);
1661 if (count($list) > 0) {
1663 print
'<td>'.$langs->trans(
"DefaultModel").
'</td>';
1664 print
'<td colspan="2">';
1665 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1667 print $form->selectarray(
'model', $list, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1673 $langs->load(
"projects");
1677 if ($origin ==
'project') {
1678 $projectid = ($originid ? $originid : 0);
1682 print
'<td>'.$langs->trans(
"Project").
'</td><td colspan="2">';
1683 if (!empty($user->socid)) {
1684 $projSocFilter = $user->socid;
1685 } elseif (
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') || $socid == 0) {
1688 $projSocFilter = -1;
1690 $projSocFilter = $socid;
1692 print
img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects($projSocFilter, $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
1693 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>';
1701 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
1702 print
'<td colspan="3" class="maxwidthonsmartphone">';
1703 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
1704 print $form->selectMultiCurrency($currency_code,
'multicurrency_code');
1709 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
1710 print $form->selectCategories(Categorie::TYPE_SUPPLIER_PROPOSAL,
'categories', $object);
1715 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' => 3);
1716 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1717 print $hookmanager->resPrint;
1718 if (empty($reshook)) {
1719 print
$object->showOptionals($extrafields,
'create', $parameters);
1724 if (!empty($origin) && !empty($originid) && is_object($objectsrc) && $classname !==
null) {
1726 if ($origin ==
'contrat') {
1728 $objectsrc->update_price(1,
'auto', 1);
1731 print
"\n<!-- ".$classname.
" info -->";
1733 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
1734 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
1735 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
1736 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
1737 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
1739 print
'<tr><td>'.$langs->trans(
'CommRequest').
'</td><td colspan="2">'.$objectsrc->getNomUrl(1).
'</td></tr>';
1740 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td colspan="2">'.
price($objectsrc->total_ht).
'</td></tr>';
1741 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td colspan="2">'.
price($objectsrc->total_tva).
"</td></tr>";
1742 if (
$mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
1743 print
'<tr><td>'.$langs->transcountry(
"AmountLT1",
$mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax1).
"</td></tr>";
1746 if (
$mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
1747 print
'<tr><td>'.$langs->transcountry(
"AmountLT2",
$mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax2).
"</td></tr>";
1749 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td colspan="2">'.
price($objectsrc->total_ttc).
"</td></tr>";
1752 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>';
1753 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>";
1754 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>";
1766 print
'<input type="hidden" name="createmode" value="empty">';
1770 print
'<br><table>';
1774 print
'<td><input type="radio" name="createmode" value="copy"></td>';
1775 print
'<td>'.$langs->trans(
"CopyAskFrom").
' </td>';
1777 $liste_ask = array();
1778 $liste_ask [0] =
'';
1780 $sql =
"SELECT p.rowid as id, p.ref, s.nom";
1781 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal p";
1782 $sql .=
", ".MAIN_DB_PREFIX.
"societe s";
1783 $sql .=
" WHERE s.rowid = p.fk_soc";
1784 $sql .=
" AND p.entityy IN (".getEntity(
'supplier_proposal').
")";
1785 $sql .=
" AND p.fk_statut <> ".SupplierProposal::STATUS_DRAFT;
1786 $sql .=
" ORDER BY Id";
1788 $resql =
$db->query($sql);
1790 $num =
$db->num_rows($resql);
1793 $row =
$db->fetch_row($resql);
1794 $askPriceSupplierRefAndSocName = $row[1].
" - ".$row[2];
1795 $liste_ask[$row[0]] = $askPriceSupplierRefAndSocName;
1798 print $form->selectarray(
"copie_supplier_proposal", $liste_ask, 0);
1804 print
'<tr><td class="tdtop"><input type="radio" name="createmode" value="empty" checked></td>';
1805 print
'<td valign="top" colspan="2">'.$langs->trans(
"CreateEmptyAsk").
'</td></tr>';
1815 print $form->buttonsSaveCancel(
"CreateDraft");
1821 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1824 $title = $langs->trans(
'ProductsAndServices');
1827 print
'<div class="div-table-responsive-no-min">';
1828 print
'<table class="noborder centpercent">';
1830 $objectsrc->printOriginLinesList();
1844 print
dol_get_fiche_head($head,
'comm', $langs->trans(
'CommRequest'), -1,
'supplier_proposal', 0,
'',
'', 0,
'', 1);
1849 if ($action ==
'clone') {
1850 $filter =
'(s.fournisseur:=:1)';
1852 $formquestion = array(
1860 'label' => $langs->trans(
"SelectThirdParty"),
1861 'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter))
1864 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
1865 } elseif ($action ==
'delete') {
1867 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteAsk'), $langs->trans(
'ConfirmDeleteAsk',
$object->ref),
'confirm_delete',
'', 0, 1);
1868 } elseif ($action ==
'reopen') {
1870 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ReOpen'), $langs->trans(
'ConfirmReOpenAsk',
$object->ref),
'confirm_reopen',
'', 0, 1);
1871 } elseif ($action ==
'ask_deleteline') {
1873 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
1874 } elseif ($action ==
'ask_subtotal_deleteline') {
1876 $langs->load(
"subtotals");
1877 $title =
"DeleteSubtotalLine";
1878 $question =
"ConfirmDeleteSubtotalLine";
1879 if (
GETPOST(
'type') ==
'title') {
1882 'type' =>
'checkbox',
1883 'name' =>
'deletecorrespondingsubtotalline',
1884 'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
1888 $title =
"DeleteTitleLine";
1889 $question =
"ConfirmDeleteTitleLine";
1891 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
1892 } elseif ($action ==
'validate') {
1897 $ref = substr(
$object->ref, 1, 4);
1898 if ($ref ==
'PROV') {
1899 $numref =
$object->getNextNumRef($soc);
1900 if (empty($numref)) {
1908 $text = $langs->trans(
'ConfirmValidateAsk', $numref);
1910 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
1913 $text .= $notify->confirmMessage(
'PROPOSAL_SUPPLIER_VALIDATE',
$object->socid, $object);
1917 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateAsk'), $text,
'confirm_validate',
'', 0, 1);
1921 if ($action ==
'add_title_line') {
1922 $langs->load(
'subtotals');
1924 $depth_array =
$object->getPossibleLevels($langs);
1926 } elseif ($action ==
'add_subtotal_line') {
1927 $langs->load(
'subtotals');
1929 $titles =
$object->getPossibleTitles();
1934 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
1935 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1936 if (empty($reshook)) {
1937 $formconfirm .= $hookmanager->resPrint;
1938 } elseif ($reshook > 0) {
1939 $formconfirm = $hookmanager->resPrint;
1947 $linkback =
'<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1950 $morehtmlref =
'<div class="refidno">';
1955 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'supplier');
1957 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.
$object->thirdparty->id.
'">'.$langs->trans(
"OtherProposals").
'</a>)';
1961 $langs->load(
"projects");
1962 $morehtmlref .=
'<br>';
1963 if ($usercancreate) {
1964 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
1965 if ($action !=
'classify') {
1966 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
1969 $canLinkAll = ($canLinkAll ===
'' || $canLinkAll ===
false) ? 0 : $canLinkAll;
1971 $projectSocId = ((int) $canLinkAll == 1) ? -1 : $currentSocId;
1972 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $projectSocId,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
1974 if (!empty(
$object->fk_project)) {
1976 $proj->fetch(
$object->fk_project);
1977 $morehtmlref .= $proj->getNomUrl(1);
1979 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
1984 $morehtmlref .=
'</div>';
1987 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1990 $parameters = array();
1992 $reshook = $hookmanager->executeHooks(
'tabContentViewSupplierProposal', $parameters, $object, $action);
1993 if (empty($reshook)) {
1994 print
'<div class="fichecenter">';
1995 print
'<div class="fichehalfleft">';
1996 print
'<div class="underbanner clearboth"></div>';
1998 print
'<table class="border tableforfield centpercent">';
2002 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
2003 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
2005 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
2006 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
2009 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td>';
2011 $absolute_discount = $soc->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
2012 $absolute_creditnote = $soc->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
2013 $absolute_discount =
price2num($absolute_discount,
'MT');
2014 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
2018 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
2019 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2024 print
'<tr><td class="titlefield">';
2025 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2026 print $langs->trans(
'PaymentConditionsShort');
2029 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>';
2031 print
'</tr></table>';
2032 print
'</td><td class="valuefield">';
2033 if ($action ==
'editconditions') {
2034 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
2036 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'none', 1,
'', 1,
$object->deposit_percent);
2043 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2044 print $langs->trans(
'DeliveryDate');
2047 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>';
2049 print
'</tr></table>';
2050 print
'</td><td class="valuefield">';
2051 if ($action ==
'editdate_livraison') {
2052 print
'<form name="editdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post">';
2053 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2054 print
'<input type="hidden" name="action" value="setdate_livraison">';
2055 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2056 print $form->selectDate(
$object->delivery_date,
'liv_', 0, 0, 0,
"editdate_livraison");
2057 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2068 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2069 print $langs->trans(
'PaymentMode');
2072 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>';
2074 print
'</tr></table>';
2075 print
'</td><td class="valuefield">';
2076 if ($action ==
'editmode') {
2077 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
2079 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
2099 print
'<table width="100%" class="nobordernopadding"><tr><td>';
2100 print $langs->trans(
'BankAccount');
2102 if ($action !=
'editbankaccount' && $usercancreate) {
2103 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>';
2105 print
'</tr></table>';
2106 print
'</td><td class="valuefield">';
2107 if ($action ==
'editbankaccount') {
2108 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
2110 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'none');
2118 print
'<table class="nobordernopadding centpercent"><tr><td>';
2119 print $langs->trans(
"Categories");
2120 print
'<td><td class="right">';
2121 if ($usercancreate) {
2122 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/supplier_proposal/card.php?id='.
$object->id.
'&action=edittags&token='.
newToken().
'">'.
img_edit().
'</a>';
2126 print
'</td></tr></table>';
2129 if ($action ==
'edittags') {
2130 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
2131 print
'<input type="hidden" name="action" value="settags">';
2132 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2133 print $form->selectCategories(Categorie::TYPE_SUPPLIER_PROPOSAL,
'categories', $object);
2134 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
2137 print $form->showCategories(
$object->id, Categorie::TYPE_SUPPLIER_PROPOSAL, 1);
2142 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2147 print
'<div class="fichehalfright">';
2148 print
'<div class="underbanner clearboth"></div>';
2150 print
'<table class="border tableforfield centpercent">';
2152 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
2156 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
2157 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2160 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2166 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
2167 print
'<td class="nowrap amountcard right">' .
price(
$object->total_tva, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2170 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2175 if (
$mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
2177 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1",
$mysoc->country_code) .
'</td>';
2178 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2180 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2184 if (
$mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
2186 print
'<td>' . $langs->transcountry(
"AmountLT2",
$mysoc->country_code) .
'</td>';
2187 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2189 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2197 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
2198 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2201 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2215 print
'<div class="clearboth"></div><br>';
2218 $blocname =
'contacts';
2219 $title = $langs->trans(
'ContactsAddresses');
2220 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2224 $blocname =
'notes';
2225 $title = $langs->trans(
'Notes');
2226 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2234 $result =
$object->getLinesArray();
2236 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'#add' :
'').
'" method="POST">
2237 <input type="hidden" name="token" value="' .
newToken().
'">
2238 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
2239 <input type="hidden" name="mode" value="">
2240 <input type="hidden" name="id" value="' .
$object->id.
'">
2246 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_ajaxrow.tpl.php';
2248 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
2252 print
'<div class="div-table-responsive-no-min">';
2253 print
'<table id="tablelines" class="noborder noshadow centpercent">';
2256 global $forceall, $senderissupplier, $inputalsopricewithtax;
2259 $inputalsopricewithtax = 1;
2260 $senderissupplier = 2;
2261 if (
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY')) {
2262 $senderissupplier =
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY');
2266 $object->printObjectLines($action, $soc,
$mysoc, $lineid, $dateSelector);
2271 if ($action !=
'editline') {
2274 $parameters = array(
'dateSelector' => $dateSelector);
2275 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
2279 if (empty($reshook)) {
2292 if ($action ==
'statut') {
2294 $form_close =
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST" id="formacceptrefuse" class="formconsumeproduce paddingbottom paddingleft paddingright">';
2295 $form_close .=
'<input type="hidden" name="token" value="'.newToken().
'">';
2296 $form_close .=
'<input type="hidden" name="action" value="setstatut">';
2299 $form_close .=
'<p class="notice">'.$langs->trans(
'SupplierProposalRefFournNotice').
'</p>';
2301 $form_close .=
'<table class="border centpercent marginleftonly marginrightonly">';
2302 $form_close .=
'<tr><td>'.$langs->trans(
"CloseAs").
'</td><td class="left">';
2303 $form_close .=
'<select id="statut" name="statut" class="flat">';
2304 $form_close .=
'<option value="0"> </option>';
2305 $form_close .=
'<option value="2">'.$langs->trans(
'SupplierProposalStatusSigned').
'</option>';
2306 $form_close .=
'<option value="3">'.$langs->trans(
'SupplierProposalStatusNotSigned').
'</option>';
2307 $form_close .=
'</select>';
2308 $form_close .=
'</td></tr>';
2309 $form_close .=
'<tr><td class="left">'.$langs->trans(
'Note').
'</td><td class="left"><textarea cols="70" rows="'.ROWS_3.
'" wrap="soft" name="note">';
2310 $form_close .=
$object->note_private;
2311 $form_close .=
'</textarea></td></tr>';
2312 $form_close .=
'</table>';
2313 $form_close .= $form->buttonsSaveCancel();
2314 $form_close .=
'<a id="acceptedrefused"> </a>';
2315 $form_close .=
'</form>';
2323 if ($action !=
'presend') {
2324 print
'<div class="tabsAction">';
2326 $parameters = array();
2327 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2329 if (empty($reshook)) {
2330 if ($action !=
'statut' && $action !=
'editline') {
2333 $langs->load(
'subtotals');
2335 $url_button = array();
2337 $url_button[] = array(
2338 'lang' =>
'subtotals',
2340 'perm' => (
bool) $usercancreate,
2341 'label' => $langs->trans(
'AddTitleLine'),
2342 'url' =>
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'add_title_line'],
true)
2345 $url_button[] = array(
2346 'lang' =>
'subtotals',
2348 'perm' => (
bool) $usercancreate,
2349 'label' => $langs->trans(
'AddSubtotalLine'),
2350 'url' =>
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'add_subtotal_line'],
true)
2353 print
dolGetButtonAction(
'', $langs->trans(
'SubTotal'),
'default', $url_button,
'',
true);
2357 if (count(
$object->lines) > 0) {
2358 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>';
2365 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>';
2370 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').
'"';
2371 print
'>'.$langs->trans(
'ReOpen').
'</a></div>';
2375 if (empty($user->socid)) {
2378 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'presend',
'mode' =>
'init'],
true).
'#formmailbeforetitle',
'');
2387 if ($usercancreateorder) {
2388 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>';
2394 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').
'"';
2395 print
'>'.$langs->trans(
'SetAcceptedRefused').
'</a></div>';
2400 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').
'"';
2401 print
'>'.$langs->trans(
'Close').
'</a></div>';
2405 if ($usercancreate) {
2406 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>';
2417 if ($action !=
'presend') {
2418 print
'<div class="fichecenter"><div class="fichehalfleft">';
2425 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
2426 $genallowed = $usercanread;
2427 $delallowed = $usercancreate;
2429 print $formfile->showdocuments(
'supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
2433 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'supplier_proposal'), 1);
2434 $linktoelem = $tmparray[
'linktoelem'];
2435 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
2436 print $htmltoenteralink;
2438 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
2442 print
'</div><div class="fichehalfright">';
2445 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2447 $somethingshown = $formactions->showactions($object,
'supplier_proposal', $socid, 1,
'', $MAXEVENT);
2449 print
'</div></div>';
2453 if (
GETPOST(
'modelselected')) {
2454 $action =
'presend';
2458 $modelmail =
'supplier_proposal_send';
2459 $defaulttopic =
'SendAskRef';
2460 $diroutput =
$conf->supplier_proposal->dir_output;
2461 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
2462 $trackid =
'spro'.$object->id;
2464 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.