41require
'../main.inc.php';
42require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_proposal/modules_supplier_proposal.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/supplier_proposal.lib.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
53 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
67$langs->loadLangs(array(
'companies',
'supplier_proposal',
'compta',
'bills',
'propal',
'orders',
'products',
'sendings'));
69 $langs->load(
'margins');
77$action =
GETPOST(
'action',
'aZ09');
78$cancel =
GETPOST(
'cancel',
'alpha');
79$backtopage =
GETPOST(
'backtopage',
'alpha');
80$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
82$origin =
GETPOST(
'origin',
'alpha');
84$confirm =
GETPOST(
'confirm',
'alpha');
99$hookmanager->initHooks(array(
'supplier_proposalcard',
'globalcard'));
108$extrafields->fetch_name_optionals_label(
$object->table_element);
111if ($id > 0 || !empty($ref)) {
112 $ret =
$object->fetch($id, $ref);
114 $ret =
$object->fetch_thirdparty();
123$usercanread = $user->hasRight(
'supplier_proposal',
'lire');
124$usercancreate = $user->hasRight(
'supplier_proposal',
'creer');
125$usercandelete = $user->hasRight(
'supplier_proposal',
'supprimer');
128$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'supplier_proposal',
'validate_advance')));
129$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'supplier_proposal',
'send_advance'));
132$usercanclose = $user->hasRight(
'supplier_proposal',
'cloturer');
133$usercancreateorder = ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'));
136$permissionnote = $usercancreate;
137$permissiondellink = $usercancreate;
138$permissiontoedit = $usercancreate;
139$permissiontoadd = $usercancreate;
140$permissiontoeditextra = $permissiontoadd;
141if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
143 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
147if (!empty($user->socid)) {
148 $socid = $user->socid;
157$parameters = array(
'socid' => $socid);
158$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
166if (empty($reshook)) {
167 $backurlforlist = DOL_URL_ROOT.
'/supplier_proposal/list.php';
169 if (empty($backtopage) || ($cancel && empty($id))) {
170 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
171 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
172 $backtopage = $backurlforlist;
174 $backtopage = DOL_URL_ROOT.
'/supplier_proposal/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
179 if ($cancel && !($action ==
'updateline' && $usercancreate)) {
180 if (!empty($backtopageforcancel)) {
181 header(
"Location: ".$backtopageforcancel);
183 } elseif (!empty($backtopage)) {
184 header(
"Location: ".$backtopage);
190 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
192 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
194 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
197 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
198 if (
false && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
202 $result =
$object->createFromClone($user, $socid);
204 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
212 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
214 $result =
$object->delete($user);
216 header(
'Location: '.DOL_URL_ROOT.
'/supplier_proposal/list.php');
219 $langs->load(
"errors");
222 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
224 $result =
$object->deleteLine($lineid);
229 $langs->load(
"errors");
235 $outputlangs = $langs;
238 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
239 $outputlangs->setDefaultLang($newlang);
245 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
248 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
250 } elseif ($action ==
'confirm_delete_subtotalline' && $confirm ==
'yes' && $usercancreate) {
255 $result =
$object->deleteSubtotalLine($langs,
GETPOSTINT(
'lineid'), (
bool)
GETPOST(
'deletecorrespondingsubtotalline'));
260 $outputlangs = $langs;
266 $newlang =
$object->thirdparty->default_lang;
268 if (!empty($newlang)) {
270 $outputlangs->setDefaultLang($newlang);
271 $outputlangs->load(
'products');
275 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
278 header(
'Location: '.
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' => $id]));
285 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
287 $result =
$object->valid($user);
290 $outputlangs = $langs;
293 $newlang =
GETPOST(
'lang_id',
'aZ09');
296 $newlang =
$object->thirdparty->default_lang;
298 if (!empty($newlang)) {
300 $outputlangs->setDefaultLang($newlang);
308 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
311 $langs->load(
"errors");
312 if (count(
$object->errors) > 0) {
318 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
323 } elseif ($action ==
'add' && $usercancreate) {
331 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Supplier")),
null,
'errors');
342 if (
GETPOST(
'createmode') ==
'copy' &&
GETPOSTINT(
'copie_supplier_proposal') > 0) {
345 $object->delivery_date = $date_delivery;
353 $object->model_pdf = $model_pdf;
355 $object->user_creation_id = $user->id;
361 setEventMessages($langs->trans(
"ErrorFailedToCopyProposal",
GETPOST(
'copie_supplier_proposal')),
null,
'errors');
365 $object->delivery_date = $date_delivery;
373 $object->model_pdf = $model_pdf;
375 $object->user_creation_id = $user->id;
384 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
388 $ret = $extrafields->setOptionalsFromPost(
null, $object);
396 if ($origin && $originid) {
398 $element = $subelement = $origin;
400 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
402 $subelement = $regs[2];
406 if ($element ==
'order') {
407 $element = $subelement =
'commande';
409 if ($element ==
'propal') {
410 $element =
'comm/propal';
411 $subelement =
'propal';
413 if ($element ==
'contract') {
414 $element = $subelement =
'contrat';
416 if ($element ==
'inter') {
417 $element = $subelement =
'fichinter';
419 if ($element ==
'shipping') {
420 $element = $subelement =
'expedition';
424 $object->origin_type = $origin;
425 $object->origin_id = $originid;
430 $object->linked_objects = array_merge(
$object->linked_objects,
GETPOST(
'other_linked_objects',
'array:int'));
438 $classname = ucfirst($subelement);
439 $srcobject =
new $classname(
$db);
440 '@phan-var-force Commande|Propal|Contrat|Fichinter|Expedition $srcobject';
442 dol_syslog(
"Try to find source object origin=".
$object->origin_type.
" originid=".
$object->origin_id.
" to add lines");
443 $result = $srcobject->fetch(
$object->origin_id);
446 $lines = $srcobject->lines;
447 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
448 $srcobject->fetch_lines();
449 $lines = $srcobject->lines;
453 $num = count($lines);
454 for ($i = 0; $i < $num; $i++) {
455 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
456 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc :
'');
459 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
462 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
467 if (method_exists($lines[$i],
'fetch_optionals')) {
468 $lines[$i]->fetch_optionals();
469 $array_options = $lines[$i]->array_options;
471 $array_options = array();
476 $line_price_base_type = $lines[$i]->getPriceBaseType();
479 $lines[$i]->subprice,
482 $lines[$i]->localtax1_tx,
483 $lines[$i]->localtax2_tx,
484 $lines[$i]->fk_product,
485 $lines[$i]->remise_percent,
486 $line_price_base_type,
487 (
float) $lines[$i]->subprice_ttc,
488 $lines[$i]->info_bits,
491 $lines[$i]->special_code,
493 $lines[$i]->fk_fournprice,
497 $lines[$i]->ref_supplier,
510 if ($result > 0 && $lines[$i]->product_type == 9) {
511 $fk_parent_line = $result;
516 $parameters = array(
'objFrom' => $srcobject);
517 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $object, $action);
538 $categories =
GETPOST(
'categories',
'array');
539 $object->setCategories($categories);
546 $outputlangs = $langs;
549 $newlang =
GETPOST(
'lang_id',
'aZ09');
552 $newlang =
$object->thirdparty->default_lang;
554 if (!empty($newlang)) {
556 $outputlangs->setDefaultLang($newlang);
560 if (!empty($model)) {
562 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
569 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
582 } elseif ($action ==
'confirm_reopen' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
588 } elseif ($action ==
'close' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
594 } elseif ($action ==
'setstatut' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
597 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"CloseAs")),
null,
'errors');
605 } elseif ($action ==
'addline' &&
GETPOST(
'updateallvatlinesblock',
'alpha') &&
GETPOST(
'vatforblocklines',
'alpha') !==
'' && $usercancreate) {
606 $tx_tva =
GETPOST(
'vatforblocklines') ?
GETPOST(
'vatforblocklines') : 0;
607 $object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'tva', $tx_tva);
608 } elseif ($action ==
'addline' &&
GETPOST(
'updatealldiscountlinesblock',
'alpha') &&
GETPOST(
'discountforblocklines',
'alpha') !==
'' && $usercancreate) {
609 $discount =
GETPOST(
'discountforblocklines') ?
GETPOST(
'discountforblocklines') : 0;
610 $object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'discount', $discount);
611 } elseif ($action ==
'settags' &&
isModEnabled(
'category') && $usercancreate) {
616 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
619 $triggersendname =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
620 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
621 $trackid =
'spro'.$object->id;
622 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
625 $upload_dir =
$conf->supplier_proposal->dir_output;
626 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
629 if ($action ==
'modif' && $usercancreate) {
634 $outputlangs = $langs;
637 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
638 $outputlangs->setDefaultLang($newlang);
644 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
646 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
658 if ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') && $usercancreate) {
660 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
661 $vat_rate = str_replace(
'*',
'', $vat_rate);
664 foreach (
$object->lines as $line) {
665 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
669 $line_price_base_type = $line->getPriceBaseType();
670 $line_pu = ($line_price_base_type ===
'TTC') ? (
float) $line->subprice_ttc : (float) $line->subprice;
673 $line_pu_devise = ($line_price_base_type ===
'TTC') ? 0 : (float) $line->multicurrency_subprice;
674 $result =
$object->updateline($line->id, $line_pu, $line->qty, (
float) $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, $line_price_base_type, $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_pu_devise);
676 } elseif ($action ==
'confirm_addtextline' && $usercancreate) {
679 $langs->load(
'subtotals');
681 $desc =
GETPOST(
'subtotaltextcontent',
'restricthtml');
684 $result =
$object->addSubtotalLine($langs, $desc, 0, array());
695 $outputlangs = $langs;
696 $newlang =
GETPOST(
'lang_id',
'alpha');
698 $newlang =
$object->thirdparty->default_lang;
700 if (!empty($newlang)) {
702 $outputlangs->setDefaultLang($newlang);
705 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
710 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
712 } elseif ($action ==
'confirm_addtitleline' && $usercancreate) {
715 $langs->load(
'subtotals');
717 $desc =
GETPOST(
'subtotallinedesc',
'alphanohtml');
718 $depth =
GETPOSTINT(
'subtotallinelevel') ?? 1;
720 $subtotal_options = array();
722 foreach (SupplierProposal::$TITLE_OPTIONS as $option) {
723 $value =
GETPOST($option,
'alphanohtml');
725 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
730 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
741 $outputlangs = $langs;
742 $newlang =
GETPOST(
'lang_id',
'alpha');
744 $newlang =
$object->thirdparty->default_lang;
746 if (!empty($newlang)) {
748 $outputlangs->setDefaultLang($newlang);
751 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
756 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
758 } elseif ($action ==
'confirm_addsubtotalline' && $usercancreate) {
761 $langs->load(
'subtotals');
763 $choosen_line =
GETPOST(
'subtotaltitleline',
'alphanohtml');
764 foreach (
$object->lines as $line) {
765 if ($line->desc == $choosen_line && $line->special_code == SUBTOTALS_SPECIAL_CODE) {
767 $depth = -$line->qty;
771 $subtotal_options = array();
773 foreach (SupplierProposal::$SUBTOTAL_OPTIONS as $option) {
774 $value =
GETPOST($option,
'alphanohtml');
776 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
781 if (isset($desc) && isset($depth)) {
782 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
785 $object->errors[] = $langs->trans(
"CorrespondingTitleNotFound");
794 $outputlangs = $langs;
795 $newlang =
GETPOST(
'lang_id',
'alpha');
797 $newlang =
$object->thirdparty->default_lang;
799 if (!empty($newlang)) {
801 $outputlangs->setDefaultLang($newlang);
804 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
809 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
811 } elseif ($action ==
'addline' && $usercancreate) {
812 $langs->load(
'errors');
817 $line_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
821 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
823 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
824 if ($prod_entry_mode ==
'free') {
839 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef,
'alpha'),
'', 2) : 0);
840 if (empty($remise_percent)) {
845 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
846 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
848 if (is_array($extralabelsline)) {
850 foreach ($extralabelsline as $key => $value) {
851 unset($_POST[
"options_".$key]);
855 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
856 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
859 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
860 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
864 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' &&
GETPOST(
'multicurrency_price_ht') ===
'') {
865 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPrice")),
null,
'errors');
868 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($line_desc)) {
869 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Description")),
null,
'errors');
872 if (!$error && ($qty >= 0)) {
876 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
880 if ($prod_entry_mode !=
'free' && empty($error)) {
884 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
889 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
890 $idprod = (int) $reg[1];
891 $res = $productsupplier->fetch($idprod);
894 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
896 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
897 if ($productsupplier->fourn_socid != $socid) {
898 $productsupplier->ref_supplier =
'';
901 $fksoctosearch =
$object->thirdparty->id;
902 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
904 } elseif (
GETPOSTINT(
'idprodfournprice') > 0) {
907 $idprod = $productsupplier->get_buyprice(
GETPOSTINT(
'idprodfournprice'), $qtytosearch);
908 $res = $productsupplier->fetch($idprod);
912 $label = $productsupplier->label;
916 $outputlangs = $langs;
918 if (
GETPOST(
'lang_id',
'aZ09')) {
919 $newlang =
GETPOST(
'lang_id',
'aZ09');
921 if (empty($newlang)) {
922 $newlang =
$object->thirdparty->default_lang;
924 if (!empty($newlang)) {
926 $outputlangs->setDefaultLang($newlang);
928 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->
description;
930 $desc = $productsupplier->description;
933 if (!empty($productsupplier->desc_supplier) &&
getDolGlobalString(
'PRODUIT_FOURN_TEXTS')) {
934 $desc = $productsupplier->desc_supplier;
945 $ref_supplier = $productsupplier->ref_supplier;
949 if (!GETPOSTISSET(
'tva_tx')) {
950 $tmpidprodfournprice =
GETPOST(
'idprodfournprice',
'alpha');
951 if (is_numeric($tmpidprodfournprice) && (
int) $tmpidprodfournprice > 0) {
952 $tmpidprodfournprice = (int) $tmpidprodfournprice;
954 $tmpidprodfournprice = 0;
960 if (empty($tva_tx)) {
966 $type = $productsupplier->type;
967 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
968 $price_base_type =
'HT';
970 $pu_devise =
price2num($price_ht_devise,
'CU');
971 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
972 $price_base_type =
'TTC';
974 $pu_devise =
price2num($price_ttc_devise,
'CU');
976 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
977 if (empty(
$object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code !=
$object->multicurrency_code)) {
978 $pu = $productsupplier->fourn_pu;
981 $pu = $productsupplier->fourn_pu;
982 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
991 $fournprice = (is_numeric(
GETPOST(
'idprodfournprice',
'alpha')) ?
GETPOST(
'idprodfournprice',
'alpha') : -1);
996 ($price_base_type ==
'HT' ? $pu : 0),
1001 $productsupplier->id,
1004 ($price_base_type ==
'TTC' ? $pu : 0),
1007 min($rank, count(
$object->lines) + 1),
1015 $productsupplier->fk_unit,
1031 if ($idprod == -99 || $idprod == 0) {
1034 $langs->load(
"errors");
1035 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")).
' '.$langs->trans(
"or").
' '.$langs->trans(
"NoPriceDefinedForThisSupplier"),
null,
'errors');
1037 if ($idprod == -1) {
1040 $langs->load(
"errors");
1041 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
1043 } elseif ((
GETPOST(
'price_ht') !==
'' ||
GETPOST(
'price_ttc') !==
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') && empty($error)) {
1047 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1048 $tva_tx = str_replace(
'*',
'', $tva_tx);
1049 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1055 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
1064 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1065 $price_base_type =
'HT';
1068 $pu_ht_devise =
price2num($price_ht_devise,
'CU');
1070 $price_base_type =
'TTC';
1073 $pu_ht_devise =
price2num($price_ttc_devise,
'CU');
1101 (
float) $pu_ht_devise
1106 if (!$error && $result > 0) {
1113 $outputlangs = $langs;
1116 $newlang =
GETPOST(
'lang_id',
'aZ09');
1119 $newlang =
$object->thirdparty->default_lang;
1121 if (!empty($newlang)) {
1123 $outputlangs->setDefaultLang($newlang);
1131 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1137 unset($_POST[
'prod_entry_mode']);
1139 unset($_POST[
'qty']);
1140 unset($_POST[
'type']);
1141 unset($_POST[
'remise_percent']);
1142 unset($_POST[
'pu']);
1143 unset($_POST[
'price_ht']);
1144 unset($_POST[
'multicurrency_price_ht']);
1145 unset($_POST[
'price_ttc']);
1146 unset($_POST[
'fourn_ref']);
1147 unset($_POST[
'tva_tx']);
1148 unset($_POST[
'label']);
1149 unset($_POST[
'product_ref']);
1150 unset($_POST[
'product_label']);
1151 unset($_POST[
'product_desc']);
1152 unset($_POST[
'fournprice']);
1153 unset($_POST[
'buying_price']);
1154 unset($localtax1_tx);
1155 unset($localtax2_tx);
1156 unset($_POST[
'np_marginRate']);
1157 unset($_POST[
'np_markRate']);
1158 unset($_POST[
'dp_desc']);
1159 unset($_POST[
'idprodfournprice']);
1160 unset($_POST[
'units']);
1162 unset($_POST[
'idprod']);
1164 unset($_POST[
'date_starthour']);
1165 unset($_POST[
'date_startmin']);
1166 unset($_POST[
'date_startsec']);
1167 unset($_POST[
'date_startday']);
1168 unset($_POST[
'date_startmonth']);
1169 unset($_POST[
'date_startyear']);
1170 unset($_POST[
'date_endhour']);
1171 unset($_POST[
'date_endmin']);
1172 unset($_POST[
'date_endsec']);
1173 unset($_POST[
'date_endday']);
1174 unset($_POST[
'date_endmonth']);
1175 unset($_POST[
'date_endyear']);
1182 } elseif ($action ==
'updatetitleline' && GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1185 $langs->load(
'subtotals');
1187 $desc =
GETPOST(
'line_desc',
'alphanohtml') ?? $langs->trans(
"Title");
1190 $subtotal_options = array();
1192 foreach (SupplierProposal::$TITLE_OPTIONS as $option) {
1193 $value =
GETPOST($option,
'alphanohtml');
1195 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1200 $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 ==
'updatetextline' && GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1229 $langs->load(
'subtotals');
1231 $desc =
GETPOST(
'line_desc',
'restricthtml');
1234 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, 0, array());
1245 $outputlangs = $langs;
1246 $newlang =
GETPOST(
'lang_id',
'alpha');
1248 $newlang =
$object->thirdparty->default_lang;
1250 if (!empty($newlang)) {
1252 $outputlangs->setDefaultLang($newlang);
1255 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1260 } elseif ($action ==
'updatesubtotalline' && GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1263 $langs->load(
'subtotals');
1265 $desc =
GETPOST(
'line_desc',
'alphanohtml');
1268 $subtotal_options = array();
1270 foreach (SupplierProposal::$SUBTOTAL_OPTIONS as $option) {
1271 $value =
GETPOST($option,
'alphanohtml');
1273 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1278 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1286 $outputlangs = $langs;
1287 $newlang =
GETPOST(
'lang_id',
'alpha');
1289 $newlang =
$object->thirdparty->default_lang;
1291 if (!empty($newlang)) {
1293 $outputlangs->setDefaultLang($newlang);
1296 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1301 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save') == $langs->trans(
"Save")) {
1309 if (preg_match(
'/\*/', $vat_rate)) {
1317 $vat_rate = str_replace(
'*',
'', $vat_rate);
1328 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1329 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1331 if (is_array($extralabelsline)) {
1332 foreach ($extralabelsline as $key => $value) {
1333 unset($_POST[
"options_".$key]);
1338 $special_code =
GETPOST(
'special_code');
1347 $price_base_type =
'HT';
1348 if (empty($pu_ht) && !empty($pu_ttc)) {
1350 $price_base_type =
'TTC';
1351 } elseif (!empty($pu_ht) && !empty($pu_ttc)) {
1352 foreach (
$object->lines as $line_obj) {
1355 if ($line_obj->wasEnteredIncludingTax()) {
1357 $price_base_type =
'TTC';
1366 if (!empty($productid)) {
1368 if (
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY') == 1) {
1369 if ($productid > 0 && $productsupplier->get_buyprice(0, (
float)
price2num(
GETPOST(
'qty')), $productid,
'none',
GETPOSTINT(
'socid')) < 0) {
1370 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1375 $res = $product->fetch($productid);
1377 $type = $product->type;
1379 $price_min = $product->price_min;
1381 $price_min = $product->multiprices_min [
$object->thirdparty->price_level];
1387 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1391 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1399 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1404 if ($price_base_type ===
'TTC') {
1408 $result =
$object->updateline(
1429 (
float) $pu_ht_devise
1437 $outputlangs = $langs;
1440 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
1441 $outputlangs->setDefaultLang($newlang);
1444 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1447 unset($_POST[
'qty']);
1448 unset($_POST[
'type']);
1449 unset($_POST[
'productid']);
1450 unset($_POST[
'remise_percent']);
1451 unset($_POST[
'price_ht']);
1452 unset($_POST[
'multicurrency_price_ht']);
1453 unset($_POST[
'price_ttc']);
1454 unset($_POST[
'tva_tx']);
1455 unset($_POST[
'product_ref']);
1456 unset($_POST[
'product_label']);
1457 unset($_POST[
'product_desc']);
1458 unset($_POST[
'fournprice']);
1459 unset($_POST[
'buying_price']);
1461 unset($_POST[
'date_starthour']);
1462 unset($_POST[
'date_startmin']);
1463 unset($_POST[
'date_startsec']);
1464 unset($_POST[
'date_startday']);
1465 unset($_POST[
'date_startmonth']);
1466 unset($_POST[
'date_startyear']);
1467 unset($_POST[
'date_endhour']);
1468 unset($_POST[
'date_endmin']);
1469 unset($_POST[
'date_endsec']);
1470 unset($_POST[
'date_endday']);
1471 unset($_POST[
'date_endmonth']);
1472 unset($_POST[
'date_endyear']);
1479 } elseif ($action ==
'updateline' && $usercancreate && $cancel) {
1480 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
1482 } elseif ($action ==
'classin' && $usercancreate) {
1485 } elseif ($action ==
'setavailability' && $usercancreate) {
1488 } elseif ($action ==
'setconditions' && $usercancreate) {
1490 $sql =
"SELECT code ";
1491 $sql .=
"FROM " .
$db->prefix() .
"c_payment_term";
1492 $sql .=
" WHERE rowid = " .
GETPOSTINT(
'cond_reglement_id');
1493 $result =
$db->query($sql);
1495 $obj =
$db->fetch_object($result);
1496 if ($obj->code ==
'DEP30PCTDEL') {
1503 } elseif ($action ==
'setmode' && $usercancreate) {
1506 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
1508 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
1509 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
1512 } elseif ($action ==
'update_extras' && $permissiontoeditextra) {
1515 $attribute_name =
GETPOST(
'attribute',
'aZ09');
1518 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
1524 $result =
$object->updateExtraField($attribute_name,
'PROPOSAL_SUPPLIER_MODIFY');
1532 $action =
'edit_extras';
1542$title =
$object->ref.
" - ".$langs->trans(
'Card');
1543if ($action ==
'create') {
1544 $title = $langs->trans(
"SupplierProposalNew");
1546$help_url =
'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur';
1548llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-supplierproposal page-card');
1562if ($action ==
'create') {
1563 $currency_code =
$conf->currency;
1565 print
load_fiche_titre($langs->trans(
"SupplierProposalNew"),
'',
'supplier_proposal');
1569 $res = $soc->fetch($socid);
1573 if (!empty($origin) && !empty($originid)) {
1574 $element = $subelement =
GETPOST(
'origin');
1576 if (preg_match(
'/^([^_]+)_([^_]+)/i',
GETPOST(
'origin'), $regs)) {
1577 $element = $regs[1];
1578 $subelement = $regs[2];
1582 if ($element ==
'order' || $element ==
'commande') {
1583 $element = $subelement =
'commande';
1585 if ($element ==
'propal') {
1586 $element =
'comm/propal';
1587 $subelement =
'propal';
1592 $classname = ucfirst($subelement);
1593 $objectsrc =
new $classname(
$db);
1594 '@phan-var-force Commande|Propal|CommandeFournisseur|SupplierProposal $objectsrc';
1596 $objectsrc->fetch($originid);
1597 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1598 $objectsrc->fetch_lines();
1600 $objectsrc->fetch_thirdparty();
1602 $projectid = (int) $objectsrc->fk_project;
1603 $soc = $objectsrc->thirdparty;
1605 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1606 $deposit_percent = (!empty($objectsrc->deposit_percent) ? $objectsrc->deposit_percent : (!empty($soc->deposit_percent) ? $soc->deposit_percent : 0));
1607 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1610 $objectsrc->fetch_optionals();
1611 $object->array_options = $objectsrc->array_options;
1614 if (!empty($objectsrc->multicurrency_code)) {
1615 $currency_code = $objectsrc->multicurrency_code;
1617 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
1618 $currency_tx = $objectsrc->multicurrency_tx;
1622 $cond_reglement_id = $soc->cond_reglement_supplier_id;
1623 $deposit_percent = !empty($soc->deposit_percent) ? $soc->deposit_percent : 0;
1624 $mode_reglement_id = $soc->mode_reglement_supplier_id;
1625 if (
isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
1626 $currency_code = $soc->multicurrency_code;
1629 if (GETPOSTISSET(
'cond_reglement_id_deposit_percent')) {
1630 $deposit_percent =
GETPOSTFLOAT(
'cond_reglement_id_deposit_percent');
1635 print
'<form name="addprop" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1636 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1637 print
'<input type="hidden" name="action" value="add">';
1638 if ($origin !=
'project' && $originid) {
1639 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1640 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1642 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1647 $parameters = array();
1649 $reshook = $hookmanager->executeHooks(
'tabContentCreateSupplierProposal', $parameters, $object, $action);
1650 if (empty($reshook)) {
1651 print
'<table class="border centpercent">';
1654 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td colspan="2">'.$langs->trans(
"Draft").
'</td></tr>';
1658 print
'<td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
1660 print
'<td colspan="2">';
1661 print $soc->getNomUrl(1,
'supplier');
1662 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1665 print
'<td colspan="2">';
1666 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
1667 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company((empty($socid) ?
'' : $socid),
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1671 $(document).ready(function() {
1672 $("#socid").change(function() {
1673 console.log("We have changed the company - Reload page");
1675 $("input[name=action]").val("create");
1676 $("form[name=addprop]").submit();
1681 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>';
1688 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
1690 $absolute_discount = $soc->getAvailableDiscounts(
null,
'', 0, 1);
1694 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
1695 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1701 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td colspan="2">';
1702 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
1703 print $form->getSelectConditionsPaiements(GETPOSTISSET(
'cond_reglement_id') ?
GETPOSTINT(
'cond_reglement_id') : $cond_reglement_id,
'cond_reglement_id', -1, 1, 0,
'', $deposit_percent);
1707 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td colspan="2">';
1708 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1709 $form->select_types_paiements(
GETPOST(
'mode_reglement_id') > 0 ?
GETPOST(
'mode_reglement_id') : $mode_reglement_id,
'mode_reglement_id');
1714 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td colspan="2">';
1715 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1716 $form->select_comptes(
GETPOST(
'fk_account') > 0 ?
GETPOSTINT(
'fk_account') : $fk_account,
'fk_account', 0,
'', 1);
1722 print
'<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td colspan="2">';
1723 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1724 $form->selectShippingMethod(
GETPOST(
'shipping_method_id') > 0 ?
GETPOSTINT(
'shipping_method_id') :
"",
'shipping_method_id',
'', 1);
1729 print
'<tr><td>'.$langs->trans(
"DeliveryDate").
'</td>';
1730 print
'<td colspan="2">';
1731 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1734 $tmpdte = time() + (7 *
getDolGlobalInt(
'DATE_LIVRAISON_WEEK_DELAY') * 24 * 60 * 60);
1735 $syear =
date(
"Y", $tmpdte);
1736 $smonth =
date(
"m", $tmpdte);
1737 $sday =
date(
"d", $tmpdte);
1738 print $form->selectDate($syear.
"-".$smonth.
"-".$sday,
'liv_', 0, 0, 0,
"addask");
1740 print $form->selectDate($datedelivery ? $datedelivery : -1,
'liv_', 0, 0, 0,
"addask", 1, 1);
1747 if (count($list) > 0) {
1749 print
'<td>'.$langs->trans(
"DefaultModel").
'</td>';
1750 print
'<td colspan="2">';
1751 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1753 print $form->selectarray(
'model', $list, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1759 $langs->load(
"projects");
1763 if ($origin ==
'project') {
1764 $projectid = ($originid ? $originid : 0);
1768 print
'<td>'.$langs->trans(
"Project").
'</td><td colspan="2">';
1769 if (!empty($user->socid)) {
1770 $projSocFilter = $user->socid;
1771 } elseif (
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') || $socid == 0) {
1774 $projSocFilter = -1;
1776 $projSocFilter = $socid;
1778 print
img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects($projSocFilter, $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
1779 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>';
1787 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
1788 print
'<td colspan="3" class="maxwidthonsmartphone">';
1789 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
1790 print $form->selectMultiCurrency($currency_code,
'multicurrency_code');
1795 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
1796 print $form->selectCategories(Categorie::TYPE_SUPPLIER_PROPOSAL,
'categories', $object);
1801 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' => 3);
1802 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1803 print $hookmanager->resPrint;
1804 if (empty($reshook)) {
1805 print
$object->showOptionals($extrafields,
'create', $parameters);
1810 if (!empty($origin) && !empty($originid) && is_object($objectsrc) && $classname !==
null) {
1812 if ($origin ==
'contrat') {
1814 $objectsrc->update_price(1,
'auto', 1);
1817 print
"\n<!-- ".$classname.
" info -->";
1819 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
1820 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
1821 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
1822 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
1823 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
1825 print
'<tr><td>'.$langs->trans(
'CommRequest').
'</td><td colspan="2">'.$objectsrc->getNomUrl(1).
'</td></tr>';
1826 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td colspan="2">'.
price($objectsrc->total_ht).
'</td></tr>';
1827 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td colspan="2">'.
price($objectsrc->total_tva).
"</td></tr>";
1828 if (
$mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
1829 print
'<tr><td>'.$langs->transcountry(
"AmountLT1",
$mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax1).
"</td></tr>";
1832 if (
$mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
1833 print
'<tr><td>'.$langs->transcountry(
"AmountLT2",
$mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax2).
"</td></tr>";
1835 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td colspan="2">'.
price($objectsrc->total_ttc).
"</td></tr>";
1838 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
1839 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
1840 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
1852 print
'<input type="hidden" name="createmode" value="empty">';
1856 print
'<br><table>';
1860 print
'<td><input type="radio" name="createmode" value="copy"></td>';
1861 print
'<td>'.$langs->trans(
"CopyAskFrom").
' </td>';
1863 $liste_ask = array();
1864 $liste_ask [0] =
'';
1866 $sql =
"SELECT p.rowid as id, p.ref, s.nom";
1867 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal p";
1868 $sql .=
", ".MAIN_DB_PREFIX.
"societe s";
1869 $sql .=
" WHERE s.rowid = p.fk_soc";
1870 $sql .=
" AND p.entityy IN (".getEntity(
'supplier_proposal').
")";
1871 $sql .=
" AND p.fk_statut <> ".SupplierProposal::STATUS_DRAFT;
1872 $sql .=
" ORDER BY Id";
1874 $resql =
$db->query($sql);
1876 $num =
$db->num_rows($resql);
1879 $row =
$db->fetch_row($resql);
1880 $askPriceSupplierRefAndSocName = $row[1].
" - ".$row[2];
1881 $liste_ask[$row[0]] = $askPriceSupplierRefAndSocName;
1884 print $form->selectarray(
"copie_supplier_proposal", $liste_ask, 0);
1890 print
'<tr><td class="tdtop"><input type="radio" name="createmode" value="empty" checked></td>';
1891 print
'<td valign="top" colspan="2">'.$langs->trans(
"CreateEmptyAsk").
'</td></tr>';
1901 print $form->buttonsSaveCancel(
"CreateDraft");
1907 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1910 $title = $langs->trans(
'ProductsAndServices');
1913 print
'<div class="div-table-responsive-no-min">';
1914 print
'<table class="noborder centpercent">';
1916 $objectsrc->printOriginLinesList();
1930 print
dol_get_fiche_head($head,
'comm', $langs->trans(
'CommRequest'), -1,
'supplier_proposal', 0,
'',
'', 0,
'', 1);
1935 if ($action ==
'clone') {
1936 $filter =
'(s.fournisseur:=:1)';
1938 $formquestion = array(
1946 'label' => $langs->trans(
"SelectThirdParty"),
1947 'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter))
1950 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
1951 } elseif ($action ==
'delete') {
1953 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteAsk'), $langs->trans(
'ConfirmDeleteAsk',
$object->ref),
'confirm_delete',
'', 0, 1);
1954 } elseif ($action ==
'reopen') {
1956 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ReOpen'), $langs->trans(
'ConfirmReOpenAsk',
$object->ref),
'confirm_reopen',
'', 0, 1);
1957 } elseif ($action ==
'ask_deleteline') {
1959 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
1960 } elseif ($action ==
'ask_subtotal_deleteline') {
1962 $langs->load(
"subtotals");
1963 $title =
"DeleteSubtotalLine";
1964 $question =
"ConfirmDeleteSubtotalLine";
1965 if (
GETPOST(
'type') ==
'title') {
1968 'type' =>
'checkbox',
1969 'name' =>
'deletecorrespondingsubtotalline',
1970 'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
1974 $title =
"DeleteTitleLine";
1975 $question =
"ConfirmDeleteTitleLine";
1977 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
1978 } elseif ($action ==
'validate') {
1983 $ref = substr(
$object->ref, 1, 4);
1984 if ($ref ==
'PROV') {
1985 $numref =
$object->getNextNumRef($soc);
1986 if (empty($numref)) {
1994 $text = $langs->trans(
'ConfirmValidateAsk', $numref);
1996 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
1999 $text .= $notify->confirmMessage(
'PROPOSAL_SUPPLIER_VALIDATE',
$object->socid, $object);
2003 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateAsk'), $text,
'confirm_validate',
'', 0, 1);
2007 if ($action ==
'add_title_line') {
2008 $langs->load(
'subtotals');
2010 $depth_array =
$object->getPossibleLevels($langs);
2012 } elseif ($action ==
'add_subtotal_line') {
2013 $langs->load(
'subtotals');
2015 $titles =
$object->getPossibleTitles();
2017 } elseif ($action ==
'add_text_line') {
2018 $langs->load(
'subtotals');
2024 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
2025 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2026 if (empty($reshook)) {
2027 $formconfirm .= $hookmanager->resPrint;
2028 } elseif ($reshook > 0) {
2029 $formconfirm = $hookmanager->resPrint;
2037 $linkback =
'<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
2040 $morehtmlref =
'<div class="refidno">';
2045 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'supplier');
2047 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.
$object->thirdparty->id.
'">'.$langs->trans(
"OtherProposals").
'</a>)';
2051 $langs->load(
"projects");
2052 $morehtmlref .=
'<br>';
2053 if ($usercancreate) {
2054 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2055 if ($action !=
'classify') {
2056 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2059 $canLinkAll = ($canLinkAll ===
'' || $canLinkAll ===
false) ? 0 : $canLinkAll;
2061 $projectSocId = ((int) $canLinkAll == 1) ? -1 : $currentSocId;
2062 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $projectSocId,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2064 if (!empty(
$object->fk_project)) {
2066 $proj->fetch(
$object->fk_project);
2067 $morehtmlref .= $proj->getNomUrl(1);
2069 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2074 $morehtmlref .=
'</div>';
2077 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2080 $parameters = array();
2082 $reshook = $hookmanager->executeHooks(
'tabContentViewSupplierProposal', $parameters, $object, $action);
2083 if (empty($reshook)) {
2084 print
'<div class="fichecenter">';
2085 print
'<div class="fichehalfleft">';
2086 print
'<div class="underbanner clearboth"></div>';
2088 print
'<table class="border tableforfield centpercent">';
2092 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
2093 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
2095 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
2096 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
2099 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td>';
2101 $absolute_discount = $soc->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
2102 $absolute_creditnote = $soc->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
2103 $absolute_discount =
price2num($absolute_discount,
'MT');
2104 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
2108 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
2109 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2114 print
'<tr><td class="titlefield">';
2115 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2116 print $langs->trans(
'PaymentConditionsShort');
2119 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>';
2121 print
'</tr></table>';
2122 print
'</td><td class="valuefield">';
2123 if ($action ==
'editconditions') {
2124 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 1,
'', 1,
$object->deposit_percent);
2126 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'none', 1,
'', 1,
$object->deposit_percent);
2133 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2134 print $langs->trans(
'DeliveryDate');
2137 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>';
2139 print
'</tr></table>';
2140 print
'</td><td class="valuefield">';
2141 if ($action ==
'editdate_livraison') {
2142 print
'<form name="editdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post" class="formconsumeproduce">';
2143 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2144 print
'<input type="hidden" name="action" value="setdate_livraison">';
2145 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2146 print $form->selectDate(
$object->delivery_date,
'liv_', 0, 0, 0,
"editdate_livraison");
2147 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2158 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2159 print $langs->trans(
'PaymentMode');
2162 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>';
2164 print
'</tr></table>';
2165 print
'</td><td class="valuefield">';
2166 if ($action ==
'editmode') {
2167 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
2169 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
2189 print
'<table width="100%" class="nobordernopadding"><tr><td>';
2190 print $langs->trans(
'BankAccount');
2192 if ($action !=
'editbankaccount' && $usercancreate) {
2193 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>';
2195 print
'</tr></table>';
2196 print
'</td><td class="valuefield">';
2197 if ($action ==
'editbankaccount') {
2198 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
2200 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'none');
2208 print
'<table class="nobordernopadding centpercent"><tr><td>';
2209 print $langs->trans(
"Categories");
2210 print
'<td><td class="right">';
2211 if ($usercancreate) {
2212 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/supplier_proposal/card.php?id='.
$object->id.
'&action=edittags&token='.
newToken().
'">'.
img_edit().
'</a>';
2216 print
'</td></tr></table>';
2219 if ($action ==
'edittags') {
2220 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
2221 print
'<input type="hidden" name="action" value="settags">';
2222 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2223 print $form->selectCategories(Categorie::TYPE_SUPPLIER_PROPOSAL,
'categories', $object);
2224 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
2227 print $form->showCategories(
$object->id, Categorie::TYPE_SUPPLIER_PROPOSAL, 1);
2232 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2237 print
'<div class="fichehalfright">';
2238 print
'<div class="underbanner clearboth"></div>';
2240 print
'<table class="border tableforfield centpercent">';
2242 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
2246 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
2247 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2250 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2256 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
2257 print
'<td class="nowrap amountcard right">' .
price(
$object->total_tva, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2260 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2265 if (
$mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
2267 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1",
$mysoc->country_code) .
'</td>';
2268 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2270 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2274 if (
$mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
2276 print
'<td>' . $langs->transcountry(
"AmountLT2",
$mysoc->country_code) .
'</td>';
2277 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2279 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2287 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
2288 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
2291 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
2305 print
'<div class="clearboth"></div><br>';
2308 $blocname =
'contacts';
2309 $title = $langs->trans(
'ContactsAddresses');
2310 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2314 $blocname =
'notes';
2315 $title = $langs->trans(
'Notes');
2316 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2324 $result =
$object->getLinesArray();
2326 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'#add' :
'').
'" method="POST">
2327 <input type="hidden" name="token" value="' .
newToken().
'">
2328 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
2329 <input type="hidden" name="mode" value="">
2330 <input type="hidden" name="id" value="' .
$object->id.
'">
2336 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_ajaxrow.tpl.php';
2338 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
2342 print
'<div class="div-table-responsive-no-min">';
2343 print
'<table id="tablelines" class="noborder noshadow centpercent">';
2346 global $forceall, $senderissupplier, $inputalsopricewithtax;
2349 $inputalsopricewithtax = 1;
2350 $senderissupplier = 2;
2351 if (
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY')) {
2352 $senderissupplier =
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY');
2356 $object->printObjectLines($action, $soc,
$mysoc, $lineid, $dateSelector);
2361 if ($action !=
'editline') {
2364 $parameters = array(
'dateSelector' => $dateSelector);
2365 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
2369 if (empty($reshook)) {
2382 if ($action ==
'statut') {
2384 $form_close =
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST" id="formacceptrefuse" class="formconsumeproduce paddingbottom paddingleft paddingright">';
2385 $form_close .=
'<input type="hidden" name="token" value="'.newToken().
'">';
2386 $form_close .=
'<input type="hidden" name="action" value="setstatut">';
2389 $form_close .=
'<p class="notice">'.$langs->trans(
'SupplierProposalRefFournNotice').
'</p>';
2391 $form_close .=
'<table class="border centpercent marginleftonly marginrightonly">';
2392 $form_close .=
'<tr><td>'.$langs->trans(
"CloseAs").
'</td><td class="left">';
2393 $form_close .=
'<select id="statut" name="statut" class="flat">';
2394 $form_close .=
'<option value="0"> </option>';
2395 $form_close .=
'<option value="2">'.$langs->trans(
'SupplierProposalStatusSigned').
'</option>';
2396 $form_close .=
'<option value="3">'.$langs->trans(
'SupplierProposalStatusNotSigned').
'</option>';
2397 $form_close .=
'</select>';
2398 $form_close .=
'</td></tr>';
2399 $form_close .=
'<tr><td class="left">'.$langs->trans(
'Note').
'</td><td class="left"><textarea cols="70" rows="'.ROWS_3.
'" wrap="soft" name="note">';
2400 $form_close .=
$object->note_private;
2401 $form_close .=
'</textarea></td></tr>';
2402 $form_close .=
'</table>';
2403 $form_close .= $form->buttonsSaveCancel();
2404 $form_close .=
'<a id="acceptedrefused"> </a>';
2405 $form_close .=
'</form>';
2413 if ($action !=
'presend') {
2414 print
'<div class="tabsAction">';
2416 $parameters = array();
2417 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2419 if (empty($reshook)) {
2420 if ($action !=
'statut' && $action !=
'editline') {
2424 $langs->load(
'subtotals');
2426 $url_button = array();
2428 $url_button[] = array(
2429 'lang' =>
'subtotals',
2431 'perm' => (
bool) $usercancreate,
2432 'label' => $langs->trans(
'AddTitleLine'),
2433 'url' =>
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'add_title_line'],
true)
2436 $url_button[] = array(
2437 'lang' =>
'subtotals',
2439 'perm' => (
bool) $usercancreate,
2440 'label' => $langs->trans(
'AddSubtotalLine'),
2441 'url' =>
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'add_subtotal_line'],
true)
2444 $url_button[] = array(
2445 'lang' =>
'subtotals',
2447 'perm' => (
bool) $usercancreate,
2448 'label' => $langs->trans(
'AddTextLine'),
2449 'url' =>
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'add_text_line'],
true)
2452 print
dolGetButtonAction(
'', $langs->trans(
'SubTotal'),
'default', $url_button,
'',
true);
2456 if (count(
$object->lines) > 0) {
2457 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>';
2464 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>';
2469 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').
'"';
2470 print
'>'.$langs->trans(
'ReOpen').
'</a></div>';
2474 if (empty($user->socid)) {
2477 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'presend',
'mode' =>
'init'],
true).
'#formmailbeforetitle',
'');
2486 if ($usercancreateorder) {
2487 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>';
2493 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').
'"';
2494 print
'>'.$langs->trans(
'SetAcceptedRefused').
'</a></div>';
2499 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').
'"';
2500 print
'>'.$langs->trans(
'Close').
'</a></div>';
2504 if ($usercancreate) {
2505 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>';
2516 if ($action !=
'presend') {
2517 print
'<div class="fichecenter"><div class="fichehalfleft">';
2524 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
2525 $genallowed = $usercanread;
2526 $delallowed = $usercancreate;
2528 print $formfile->showdocuments(
'supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $soc->default_lang);
2532 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'supplier_proposal'), 1);
2533 $linktoelem = $tmparray[
'linktoelem'];
2534 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
2535 print $htmltoenteralink;
2537 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
2541 print
'</div><div class="fichehalfright">';
2544 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2546 $somethingshown = $formactions->showactions($object,
'supplier_proposal', $socid, 1,
'', $MAXEVENT);
2548 print
'</div></div>';
2552 if (
GETPOST(
'modelselected')) {
2553 $action =
'presend';
2557 $modelmail =
'supplier_proposal_send';
2558 $defaulttopic =
'SendAskRef';
2559 $diroutput =
$conf->supplier_proposal->dir_output;
2560 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
2561 $trackid =
'spro'.$object->id;
2563 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 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...
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_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.
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).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
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.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
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
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, $mode=0)
Check permissions of a user to show a page and an object.
supplier_proposal_prepare_head($object)
Prepare array with list of tabs.