40require
'../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_proposal/modules_supplier_proposal.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/supplier_proposal.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
50if (isModEnabled(
'project')) {
51 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
52 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
65$langs->loadLangs(array(
'companies',
'supplier_proposal',
'compta',
'bills',
'propal',
'orders',
'products',
'deliveries',
'sendings'));
66if (isModEnabled(
'margin')) {
67 $langs->load(
'margins');
75$action =
GETPOST(
'action',
'aZ09');
76$cancel =
GETPOST(
'cancel',
'alpha');
77$backtopage =
GETPOST(
'backtopage',
'alpha');
78$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
80$origin =
GETPOST(
'origin',
'alpha');
82$confirm =
GETPOST(
'confirm',
'alpha');
97$hookmanager->initHooks(array(
'supplier_proposalcard',
'globalcard'));
105$extrafields->fetch_name_optionals_label(
$object->table_element);
108if ($id > 0 || !empty($ref)) {
109 $ret =
$object->fetch($id, $ref);
111 $ret =
$object->fetch_thirdparty();
120$usercanread = $user->hasRight(
'supplier_proposal',
'lire');
121$usercancreate = $user->hasRight(
'supplier_proposal',
'creer');
122$usercandelete = $user->hasRight(
'supplier_proposal',
'supprimer');
125$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'supplier_proposal',
'validate_advance')));
126$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'supplier_proposal',
'send_advance'));
129$usercanclose = $user->hasRight(
'supplier_proposal',
'cloturer');
130$usercancreateorder = ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'));
133$permissionnote = $usercancreate;
134$permissiondellink = $usercancreate;
135$permissiontoedit = $usercancreate;
136$permissiontoadd = $usercancreate;
139if (!empty($user->socid)) {
140 $socid = $user->socid;
149$parameters = array(
'socid' => $socid);
150$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
155if (empty($reshook)) {
156 $backurlforlist = DOL_URL_ROOT.
'/supplier_proposal/list.php';
158 if (empty($backtopage) || ($cancel && empty($id))) {
159 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
160 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
161 $backtopage = $backurlforlist;
163 $backtopage = DOL_URL_ROOT.
'/supplier_proposal/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
169 if (!empty($backtopageforcancel)) {
170 header(
"Location: ".$backtopageforcancel);
172 } elseif (!empty($backtopage)) {
173 header(
"Location: ".$backtopage);
179 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
181 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
183 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
186 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
187 if (
false && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
191 $result =
$object->createFromClone($user, $socid);
193 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
201 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
203 $result =
$object->delete($user);
205 header(
'Location: '.DOL_URL_ROOT.
'/supplier_proposal/list.php');
208 $langs->load(
"errors");
211 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
213 $result =
$object->deleteLine($lineid);
218 $langs->load(
"errors");
224 $outputlangs = $langs;
227 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
228 $outputlangs->setDefaultLang($newlang);
234 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
237 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
239 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
241 $result =
$object->valid($user);
244 $outputlangs = $langs;
247 $newlang =
GETPOST(
'lang_id',
'aZ09');
250 $newlang =
$object->thirdparty->default_lang;
252 if (!empty($newlang)) {
254 $outputlangs->setDefaultLang($newlang);
262 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
265 $langs->load(
"errors");
266 if (count(
$object->errors) > 0) {
272 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
277 } elseif ($action ==
'add' && $usercancreate) {
285 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Supplier")),
null,
'errors');
294 if (
GETPOST(
'createmode') ==
'copy' &&
GETPOST(
'copie_supplier_proposal')) {
297 $object->delivery_date = $date_delivery;
306 $object->user_creation_id = $user->id;
312 setEventMessages($langs->trans(
"ErrorFailedToCopyProposal",
GETPOST(
'copie_supplier_proposal')),
null,
'errors');
316 $object->delivery_date = $date_delivery;
325 $object->user_creation_id = $user->id;
333 if (isModEnabled(
"multicurrency")) {
334 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
338 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
346 if ($origin && $originid) {
348 $element = $subelement = $origin;
349 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
351 $subelement = $regs[2];
355 if ($element ==
'order') {
356 $element = $subelement =
'commande';
358 if ($element ==
'propal') {
359 $element =
'comm/propal';
360 $subelement =
'propal';
362 if ($element ==
'contract') {
363 $element = $subelement =
'contrat';
365 if ($element ==
'inter') {
366 $element = $subelement =
'fichinter';
368 if ($element ==
'shipping') {
369 $element = $subelement =
'expedition';
373 $object->origin_id = $originid;
378 $object->linked_objects = array_merge(
$object->linked_objects,
GETPOST(
'other_linked_objects',
'array:int'));
385 $classname = ucfirst($subelement);
386 $srcobject =
new $classname($db);
387 '@phan-var-force Commande|Propal|Contrat|Fichinter|Expedition $srcobject';
390 $result = $srcobject->fetch(
$object->origin_id);
393 $lines = $srcobject->lines;
394 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
395 $srcobject->fetch_lines();
396 $lines = $srcobject->lines;
400 $num = count($lines);
401 for ($i = 0; $i < $num; $i++) {
402 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
403 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc :
'');
406 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
409 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
414 if (method_exists($lines[$i],
'fetch_optionals')) {
415 $lines[$i]->fetch_optionals();
416 $array_options = $lines[$i]->array_options;
418 $array_options = array();
423 $lines[$i]->subprice,
426 $lines[$i]->localtax1_tx,
427 $lines[$i]->localtax2_tx,
428 $lines[$i]->fk_product,
429 $lines[$i]->remise_percent,
432 $lines[$i]->info_bits,
435 $lines[$i]->special_code,
437 $lines[$i]->fk_fournprice,
441 $lines[$i]->ref_supplier,
454 if ($result > 0 && $lines[$i]->product_type == 9) {
455 $fk_parent_line = $result;
460 $parameters = array(
'objFrom' => $srcobject);
461 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters,
$object, $action);
486 $outputlangs = $langs;
489 $newlang =
GETPOST(
'lang_id',
'aZ09');
492 $newlang =
$object->thirdparty->default_lang;
494 if (!empty($newlang)) {
496 $outputlangs->setDefaultLang($newlang);
501 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
507 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
520 } elseif ($action ==
'confirm_reopen' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
526 } elseif ($action ==
'close' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
532 } elseif ($action ==
'setstatut' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
535 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"CloseAs")),
null,
'errors');
546 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
549 $triggersendname =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
550 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
551 $trackid =
'spro'.$object->id;
552 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
555 $upload_dir =
$conf->supplier_proposal->dir_output;
556 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
560 if ($action ==
'modif' && $usercancreate) {
565 $outputlangs = $langs;
568 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
569 $outputlangs->setDefaultLang($newlang);
575 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
577 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
589 if ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') && $usercancreate) {
591 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
592 $vat_rate = str_replace(
'*',
'', $vat_rate);
595 foreach (
$object->lines as $line) {
596 $result =
$object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc,
'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->array_options, $line->ref_fourn, $line->fk_unit, $line->multicurrency_subprice);
598 } elseif ($action ==
'addline' && $usercancreate) {
599 $langs->load(
'errors');
604 $product_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
608 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
610 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
611 if ($prod_entry_mode ==
'free') {
626 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef,
'alpha'),
'', 2) : 0);
627 if (empty($remise_percent)) {
632 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
633 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
635 if (is_array($extralabelsline)) {
637 foreach ($extralabelsline as $key => $value) {
638 unset($_POST[
"options_".$key]);
642 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
643 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
646 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
647 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
651 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' &&
GETPOST(
'multicurrency_price_ht') ===
'') {
652 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPrice")),
null,
'errors');
655 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
656 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Description")),
null,
'errors');
659 if (!$error && ($qty >= 0)) {
663 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
667 if ($prod_entry_mode !=
'free' && empty($error)) {
671 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
676 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
678 $res = $productsupplier->fetch($idprod);
681 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
683 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
684 if ($productsupplier->fourn_socid != $socid) {
685 $productsupplier->ref_supplier =
'';
688 $fksoctosearch =
$object->thirdparty->id;
689 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
691 } elseif (
GETPOST(
'idprodfournprice',
'alpha') > 0) {
694 $idprod = $productsupplier->get_buyprice(
GETPOST(
'idprodfournprice',
'alpha'), $qtytosearch);
695 $res = $productsupplier->fetch($idprod);
699 $label = $productsupplier->label;
703 $outputlangs = $langs;
705 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
706 $newlang =
GETPOST(
'lang_id',
'aZ09');
708 if (empty($newlang)) {
709 $newlang =
$object->thirdparty->default_lang;
711 if (!empty($newlang)) {
713 $outputlangs->setDefaultLang($newlang);
715 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->
description;
717 $desc = $productsupplier->description;
720 if (!empty($productsupplier->desc_supplier) &&
getDolGlobalString(
'PRODUIT_FOURN_TEXTS')) {
721 $desc = $productsupplier->desc_supplier;
725 if (trim($product_desc) == trim($desc) &&
getDolGlobalString(
'PRODUIT_AUTOFILL_DESC')) {
730 $desc = $product_desc;
732 if (!empty($product_desc) && trim($product_desc) != trim($desc)) {
736 $ref_supplier = $productsupplier->ref_supplier;
740 if (!GETPOSTISSET(
'tva_tx')) {
741 $tmpidprodfournprice =
GETPOST(
'idprodfournprice',
'alpha');
742 if (is_numeric($tmpidprodfournprice) && (
int) $tmpidprodfournprice > 0) {
743 $tmpidprodfournprice = (int) $tmpidprodfournprice;
745 $tmpidprodfournprice = 0;
751 if (empty($tva_tx)) {
757 $type = $productsupplier->type;
758 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
759 $price_base_type =
'HT';
761 $pu_devise =
price2num($price_ht_devise,
'CU');
762 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
763 $price_base_type =
'TTC';
765 $pu_devise =
price2num($price_ttc_devise,
'CU');
767 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
768 if (empty(
$object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code !=
$object->multicurrency_code)) {
769 $pu = $productsupplier->fourn_pu;
772 $pu = $productsupplier->fourn_pu;
773 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
782 $fournprice = (is_numeric(
GETPOST(
'idprodfournprice',
'alpha')) ?
GETPOST(
'idprodfournprice',
'alpha') : -1);
787 ($price_base_type ==
'HT' ? $pu : 0),
792 $productsupplier->id,
795 ($price_base_type ==
'TTC' ? $pu : 0),
798 min($rank, count(
$object->lines) + 1),
806 $productsupplier->fk_unit,
822 if ($idprod == -99 || $idprod == 0) {
825 $langs->load(
"errors");
826 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")).
' '.$langs->trans(
"or").
' '.$langs->trans(
"NoPriceDefinedForThisSupplier"),
null,
'errors');
831 $langs->load(
"errors");
832 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
834 } elseif ((
GETPOST(
'price_ht') !==
'' ||
GETPOST(
'price_ttc') !==
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') && empty($error)) {
838 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
839 $tva_tx = str_replace(
'*',
'', $tva_tx);
840 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
841 $desc = $product_desc;
844 $fk_unit =
GETPOST(
'units',
'alpha');
846 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
854 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
858 $pu_ht =
price2num((
float) $pu_ttc / (1 + ((
float) $tva_tx / 100)),
'MU');
860 $price_base_type =
'HT';
861 $pu_ht_devise =
price2num($price_ht_devise,
'CU');
893 if (!$error && $result > 0) {
900 $outputlangs = $langs;
903 $newlang =
GETPOST(
'lang_id',
'aZ09');
906 $newlang =
$object->thirdparty->default_lang;
908 if (!empty($newlang)) {
910 $outputlangs->setDefaultLang($newlang);
918 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
924 unset($_POST[
'prod_entry_mode']);
926 unset($_POST[
'qty']);
927 unset($_POST[
'type']);
928 unset($_POST[
'remise_percent']);
930 unset($_POST[
'price_ht']);
931 unset($_POST[
'multicurrency_price_ht']);
932 unset($_POST[
'price_ttc']);
933 unset($_POST[
'fourn_ref']);
934 unset($_POST[
'tva_tx']);
935 unset($_POST[
'label']);
936 unset($_POST[
'product_ref']);
937 unset($_POST[
'product_label']);
938 unset($_POST[
'product_desc']);
939 unset($_POST[
'fournprice']);
940 unset($_POST[
'buying_price']);
941 unset($localtax1_tx);
942 unset($localtax2_tx);
943 unset($_POST[
'np_marginRate']);
944 unset($_POST[
'np_markRate']);
945 unset($_POST[
'dp_desc']);
946 unset($_POST[
'idprodfournprice']);
947 unset($_POST[
'units']);
949 unset($_POST[
'idprod']);
951 unset($_POST[
'date_starthour']);
952 unset($_POST[
'date_startmin']);
953 unset($_POST[
'date_startsec']);
954 unset($_POST[
'date_startday']);
955 unset($_POST[
'date_startmonth']);
956 unset($_POST[
'date_startyear']);
957 unset($_POST[
'date_endhour']);
958 unset($_POST[
'date_endmin']);
959 unset($_POST[
'date_endsec']);
960 unset($_POST[
'date_endday']);
961 unset($_POST[
'date_endmonth']);
962 unset($_POST[
'date_endyear']);
969 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save') == $langs->trans(
"Save")) {
975 if (preg_match(
'/\*/', $vat_rate)) {
983 $vat_rate = str_replace(
'*',
'', $vat_rate);
987 if (
GETPOST(
'price_ht') !=
'') {
988 $price_base_type =
'HT';
992 $vatratecleaned = $vat_rate;
993 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) {
994 $vatratecleaned = trim($reg[1]);
995 $vatratecode = $reg[2];
999 $ht = (float) $ttc / (1 + ((
float) $vatratecleaned / 100));
1000 $price_base_type =
'HT';
1006 $fournprice = (
GETPOST(
'fournprice') ?
GETPOST(
'fournprice') :
'');
1007 $buyingprice = (
GETPOST(
'buying_price') !=
'' ?
GETPOST(
'buying_price') :
'');
1010 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1011 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1013 if (is_array($extralabelsline)) {
1014 foreach ($extralabelsline as $key => $value) {
1015 unset($_POST[
"options_".$key]);
1020 $special_code =
GETPOST(
'special_code');
1027 if (!empty($productid)) {
1029 if (
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY') == 1) {
1030 if ($productid > 0 && $productsupplier->get_buyprice(0,
price2num(
GETPOST(
'qty')), $productid,
'none',
GETPOSTINT(
'socid')) < 0) {
1031 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1036 $res = $product->fetch($productid);
1038 $type = $product->type;
1040 $price_min = $product->price_min;
1042 $price_min = $product->multiprices_min [
$object->thirdparty->price_level];
1048 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1052 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1060 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1063 $result =
$object->updateline(
1092 $outputlangs = $langs;
1095 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
1096 $outputlangs->setDefaultLang($newlang);
1099 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1102 unset($_POST[
'qty']);
1103 unset($_POST[
'type']);
1104 unset($_POST[
'productid']);
1105 unset($_POST[
'remise_percent']);
1106 unset($_POST[
'price_ht']);
1107 unset($_POST[
'multicurrency_price_ht']);
1108 unset($_POST[
'price_ttc']);
1109 unset($_POST[
'tva_tx']);
1110 unset($_POST[
'product_ref']);
1111 unset($_POST[
'product_label']);
1112 unset($_POST[
'product_desc']);
1113 unset($_POST[
'fournprice']);
1114 unset($_POST[
'buying_price']);
1116 unset($_POST[
'date_starthour']);
1117 unset($_POST[
'date_startmin']);
1118 unset($_POST[
'date_startsec']);
1119 unset($_POST[
'date_startday']);
1120 unset($_POST[
'date_startmonth']);
1121 unset($_POST[
'date_startyear']);
1122 unset($_POST[
'date_endhour']);
1123 unset($_POST[
'date_endmin']);
1124 unset($_POST[
'date_endsec']);
1125 unset($_POST[
'date_endday']);
1126 unset($_POST[
'date_endmonth']);
1127 unset($_POST[
'date_endyear']);
1134 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha') == $langs->trans(
"Cancel")) {
1135 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
1137 } elseif ($action ==
'classin' && $usercancreate) {
1140 } elseif ($action ==
'setavailability' && $usercancreate) {
1143 } elseif ($action ==
'setconditions' && $usercancreate) {
1150 } elseif ($action ==
'setmode' && $usercancreate) {
1153 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
1155 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
1156 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
1159 } elseif ($action ==
'update_extras' && $usercancreate) {
1161 $attribute_name =
GETPOST(
'attribute',
'restricthtml');
1164 $ret = $extrafields->setOptionalsFromPost(
null,
$object, $attribute_name);
1170 $result =
$object->updateExtraField($attribute_name,
'PROPOSAL_SUPPLIER_MODIFY');
1178 $action =
'edit_extras';
1188$title =
$object->ref.
" - ".$langs->trans(
'Card');
1189if ($action ==
'create') {
1190 $title = $langs->trans(
"SupplierProposalNew");
1192$help_url =
'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur';
1194llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-supplierproposal page-card');
1196$form =
new Form($db);
1200$companystatic =
new Societe($db);
1201if (isModEnabled(
'project')) {
1208if ($action ==
'create') {
1209 $currency_code =
$conf->currency;
1211 print
load_fiche_titre($langs->trans(
"SupplierProposalNew"),
'',
'supplier_proposal');
1215 $res = $soc->fetch($socid);
1219 if (!empty($origin) && !empty($originid)) {
1220 $element = $subelement =
GETPOST(
'origin');
1222 if (preg_match(
'/^([^_]+)_([^_]+)/i',
GETPOST(
'origin'), $regs)) {
1223 $element = $regs[1];
1224 $subelement = $regs[2];
1228 if ($element ==
'order' || $element ==
'commande') {
1229 $element = $subelement =
'commande';
1231 if ($element ==
'propal') {
1232 $element =
'comm/propal';
1233 $subelement =
'propal';
1238 $classname = ucfirst($subelement);
1239 $objectsrc =
new $classname($db);
1240 '@phan-var-force Commande|Propal|CommandeFournisseur|SupplierProposal $objectsrc';
1241 $objectsrc->fetch($originid);
1242 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1243 $objectsrc->fetch_lines();
1245 $objectsrc->fetch_thirdparty();
1247 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
1248 $soc = $objectsrc->thirdparty;
1250 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1251 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1254 $objectsrc->fetch_optionals();
1255 $object->array_options = $objectsrc->array_options;
1257 if (isModEnabled(
"multicurrency")) {
1258 if (!empty($objectsrc->multicurrency_code)) {
1259 $currency_code = $objectsrc->multicurrency_code;
1261 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
1262 $currency_tx = $objectsrc->multicurrency_tx;
1266 $cond_reglement_id = $soc->cond_reglement_supplier_id;
1267 $mode_reglement_id = $soc->mode_reglement_supplier_id;
1268 if (isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
1269 $currency_code = $soc->multicurrency_code;
1275 print
'<form name="addprop" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1276 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1277 print
'<input type="hidden" name="action" value="add">';
1278 if ($origin !=
'project' && $originid) {
1279 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1280 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1282 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1287 $parameters = array();
1289 $reshook = $hookmanager->executeHooks(
'tabContentCreateSupplierProposal', $parameters,
$object, $action);
1290 if (empty($reshook)) {
1291 print
'<table class="border centpercent">';
1294 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td colspan="2">'.$langs->trans(
"Draft").
'</td></tr>';
1298 print
'<td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
1300 print
'<td colspan="2">';
1301 print $soc->getNomUrl(1,
'supplier');
1302 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1305 print
'<td colspan="2">';
1306 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
1307 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company((empty($socid) ?
'' : $socid),
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1311 $(document).ready(function() {
1312 $("#socid").change(function() {
1313 console.log("We have changed the company - Reload page");
1315 $("input[name=action]").val("create");
1316 $("form[name=addprop]").submit();
1321 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>';
1328 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
1330 $absolute_discount = $soc->getAvailableDiscounts(
null,
'', 0, 1);
1334 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
1335 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1341 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td colspan="2">';
1342 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
1343 print $form->getSelectConditionsPaiements(
GETPOST(
'cond_reglement_id') > 0 ?
GETPOST(
'cond_reglement_id') : $cond_reglement_id,
'cond_reglement_id', -1, 1);
1347 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td colspan="2">';
1348 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1349 $form->select_types_paiements(
GETPOST(
'mode_reglement_id') > 0 ?
GETPOST(
'mode_reglement_id') : $mode_reglement_id,
'mode_reglement_id');
1353 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') && isModEnabled(
"bank")) {
1354 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td colspan="2">';
1355 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1356 $form->select_comptes(
GETPOST(
'fk_account') > 0 ?
GETPOSTINT(
'fk_account') : $fk_account,
'fk_account', 0,
'', 1);
1361 if (isModEnabled(
"shipping")) {
1362 print
'<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td colspan="2">';
1363 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1364 $form->selectShippingMethod(
GETPOST(
'shipping_method_id') > 0 ?
GETPOSTINT(
'shipping_method_id') :
"",
'shipping_method_id',
'', 1);
1369 print
'<tr><td>'.$langs->trans(
"DeliveryDate").
'</td>';
1370 print
'<td colspan="2">';
1371 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1374 $tmpdte = time() + (7 *
getDolGlobalInt(
'DATE_LIVRAISON_WEEK_DELAY') * 24 * 60 * 60);
1375 $syear = date(
"Y", $tmpdte);
1376 $smonth = date(
"m", $tmpdte);
1377 $sday = date(
"d", $tmpdte);
1378 print $form->selectDate($syear.
"-".$smonth.
"-".$sday,
'liv_', 0, 0, 0,
"addask");
1380 print $form->selectDate($datedelivery ? $datedelivery : -1,
'liv_', 0, 0, 0,
"addask", 1, 1);
1387 print
'<td>'.$langs->trans(
"DefaultModel").
'</td>';
1388 print
'<td colspan="2">';
1389 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1391 $preselected = (
getDolGlobalString(
'SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT') ?
$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT :
$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF);
1392 print $form->selectarray(
'model', $list, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1396 if (isModEnabled(
'project')) {
1397 $langs->load(
"projects");
1401 if ($origin ==
'project') {
1402 $projectid = ($originid ? $originid : 0);
1406 print
'<td>'.$langs->trans(
"Project").
'</td><td colspan="2">';
1407 print
img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
1408 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.$soc->id.
'&action=create&status=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create&socid='.$soc->id).
'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1415 if (isModEnabled(
"multicurrency")) {
1417 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'',
$object, 0).
'</td>';
1418 print
'<td colspan="3" class="maxwidthonsmartphone">';
1419 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
1420 print $form->selectMultiCurrency($currency_code,
'multicurrency_code');
1425 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' => 3);
1426 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1427 print $hookmanager->resPrint;
1428 if (empty($reshook)) {
1429 print
$object->showOptionals($extrafields,
'create', $parameters);
1434 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1436 if ($origin ==
'contrat') {
1440 $objectsrc->update_price(1,
'auto', 1);
1443 print
"\n<!-- ".$classname.
" info -->";
1445 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
1446 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
1447 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
1448 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
1449 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
1451 print
'<tr><td>'.$langs->trans(
'CommRequest').
'</td><td colspan="2">'.$objectsrc->getNomUrl(1).
'</td></tr>';
1452 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td colspan="2">'.
price($objectsrc->total_ht).
'</td></tr>';
1453 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td colspan="2">'.
price($objectsrc->total_tva).
"</td></tr>";
1454 if ($mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
1455 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax1).
"</td></tr>";
1458 if ($mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
1459 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax2).
"</td></tr>";
1461 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td colspan="2">'.
price($objectsrc->total_ttc).
"</td></tr>";
1463 if (isModEnabled(
"multicurrency")) {
1464 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
1465 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
1466 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
1478 print
'<input type="hidden" name="createmode" value="empty">';
1482 print
'<br><table>';
1486 print
'<td><input type="radio" name="createmode" value="copy"></td>';
1487 print
'<td>'.$langs->trans(
"CopyAskFrom").
' </td>';
1489 $liste_ask = array();
1490 $liste_ask [0] =
'';
1492 $sql =
"SELECT p.rowid as id, p.ref, s.nom";
1493 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal p";
1494 $sql .=
", ".MAIN_DB_PREFIX.
"societe s";
1495 $sql .=
" WHERE s.rowid = p.fk_soc";
1496 $sql .=
" AND p.entityy IN (".getEntity(
'supplier_proposal').
")";
1497 $sql .=
" AND p.fk_statut <> ".SupplierProposal::STATUS_DRAFT;
1498 $sql .=
" ORDER BY Id";
1500 $resql = $db->query($sql);
1502 $num = $db->num_rows($resql);
1505 $row = $db->fetch_row($resql);
1506 $askPriceSupplierRefAndSocName = $row[1].
" - ".$row[2];
1507 $liste_ask[$row[0]] = $askPriceSupplierRefAndSocName;
1510 print $form->selectarray(
"copie_supplier_proposal", $liste_ask, 0);
1516 print
'<tr><td class="tdtop"><input type="radio" name="createmode" value="empty" checked></td>';
1517 print
'<td valign="top" colspan="2">'.$langs->trans(
"CreateEmptyAsk").
'</td></tr>';
1527 print $form->buttonsSaveCancel(
"CreateDraft");
1533 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1536 $title = $langs->trans(
'ProductsAndServices');
1539 print
'<div class="div-table-responsive-no-min">';
1540 print
'<table class="noborder centpercent">';
1542 $objectsrc->printOriginLinesList();
1556 print
dol_get_fiche_head($head,
'comm', $langs->trans(
'CommRequest'), -1,
'supplier_proposal');
1561 if ($action ==
'clone') {
1562 $filter =
'(s.fournisseur:=:1)';
1564 $formquestion = array(
1572 'label' => $langs->trans(
"SelectThirdParty"),
1573 'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter))
1576 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
1577 } elseif ($action ==
'delete') {
1579 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteAsk'), $langs->trans(
'ConfirmDeleteAsk',
$object->ref),
'confirm_delete',
'', 0, 1);
1580 } elseif ($action ==
'reopen') {
1582 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ReOpen'), $langs->trans(
'ConfirmReOpenAsk',
$object->ref),
'confirm_reopen',
'', 0, 1);
1583 } elseif ($action ==
'ask_deleteline') {
1585 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
1586 } elseif ($action ==
'validate') {
1591 $ref = substr(
$object->ref, 1, 4);
1592 if ($ref ==
'PROV') {
1593 $numref =
$object->getNextNumRef($soc);
1594 if (empty($numref)) {
1602 $text = $langs->trans(
'ConfirmValidateAsk', $numref);
1603 if (isModEnabled(
'notification')) {
1604 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
1605 $notify =
new Notify($db);
1607 $text .= $notify->confirmMessage(
'PROPOSAL_SUPPLIER_VALIDATE',
$object->socid,
$object);
1611 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateAsk'), $text,
'confirm_validate',
'', 0, 1);
1616 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
1617 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
1618 if (empty($reshook)) {
1619 $formconfirm .= $hookmanager->resPrint;
1620 } elseif ($reshook > 0) {
1621 $formconfirm = $hookmanager->resPrint;
1629 $linkback =
'<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1632 $morehtmlref =
'<div class="refidno">';
1637 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'supplier');
1639 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.
$object->thirdparty->id.
'&search_societe='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherProposals").
'</a>)';
1642 if (isModEnabled(
'project')) {
1643 $langs->load(
"projects");
1644 $morehtmlref .=
'<br>';
1645 if ($usercancreate) {
1646 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
1647 if ($action !=
'classify') {
1648 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
1650 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
1652 if (!empty(
$object->fk_project)) {
1654 $proj->fetch(
$object->fk_project);
1655 $morehtmlref .= $proj->getNomUrl(1);
1657 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
1662 $morehtmlref .=
'</div>';
1665 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1668 $parameters = array();
1670 $reshook = $hookmanager->executeHooks(
'tabContentViewSupplierProposal', $parameters,
$object, $action);
1671 if (empty($reshook)) {
1672 print
'<div class="fichecenter">';
1673 print
'<div class="fichehalfleft">';
1674 print
'<div class="underbanner clearboth"></div>';
1676 print
'<table class="border tableforfield centpercent">';
1680 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
1681 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
1683 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
1684 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
1687 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td>';
1689 $absolute_discount = $soc->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
1690 $absolute_creditnote = $soc->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
1691 $absolute_discount =
price2num($absolute_discount,
'MT');
1692 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
1696 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
1697 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1702 print
'<tr><td class="titlefield">';
1703 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1704 print $langs->trans(
'PaymentConditionsShort');
1707 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>';
1709 print
'</tr></table>';
1710 print
'</td><td class="valuefield">';
1711 if ($action ==
'editconditions') {
1712 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'cond_reglement_id', 1);
1714 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'none', 1);
1720 $langs->load(
'deliveries');
1722 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1723 print $langs->trans(
'DeliveryDate');
1726 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>';
1728 print
'</tr></table>';
1729 print
'</td><td class="valuefield">';
1730 if ($action ==
'editdate_livraison') {
1731 print
'<form name="editdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="post" class="formconsumeproduce">';
1732 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1733 print
'<input type="hidden" name="action" value="setdate_livraison">';
1734 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1735 print $form->selectDate(
$object->delivery_date,
'liv_', 0, 0, 0,
"editdate_livraison");
1736 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
1747 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1748 print $langs->trans(
'PaymentMode');
1751 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>';
1753 print
'</tr></table>';
1754 print
'</td><td class="valuefield">';
1755 if ($action ==
'editmode') {
1756 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
1758 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'none');
1775 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') && isModEnabled(
"bank")) {
1778 print
'<table width="100%" class="nobordernopadding"><tr><td>';
1779 print $langs->trans(
'BankAccount');
1781 if ($action !=
'editbankaccount' && $usercancreate) {
1782 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>';
1784 print
'</tr></table>';
1785 print
'</td><td class="valuefield">';
1786 if ($action ==
'editbankaccount') {
1787 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'fk_account', 1);
1789 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
1796 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1801 print
'<div class="fichehalfright">';
1802 print
'<div class="underbanner clearboth"></div>';
1804 print
'<table class="border tableforfield centpercent">';
1806 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
1810 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
1811 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
1812 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
1814 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1820 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
1821 print
'<td class="nowrap amountcard right">' .
price(
$object->total_tva, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
1822 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
1824 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1829 if ($mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
1831 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
1832 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
1833 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
1834 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1838 if ($mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
1840 print
'<td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
1841 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
1842 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
1843 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1851 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
1852 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
1853 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
1855 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1869 print
'<div class="clearboth"></div><br>';
1872 $blocname =
'contacts';
1873 $title = $langs->trans(
'ContactsAddresses');
1874 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
1878 $blocname =
'notes';
1879 $title = $langs->trans(
'Notes');
1880 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
1888 $result =
$object->getLinesArray();
1890 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'#add' :
'').
'" method="POST">
1891 <input type="hidden" name="token" value="' .
newToken().
'">
1892 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
1893 <input type="hidden" name="mode" value="">
1894 <input type="hidden" name="id" value="' .
$object->id.
'">
1895 <input type="hidden" name="backtopage" value="'.$backtopage.
'">
1899 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
1902 print
'<div class="div-table-responsive-no-min">';
1903 print
'<table id="tablelines" class="noborder noshadow centpercent">';
1906 global $forceall, $senderissupplier, $inputalsopricewithtax;
1909 $inputalsopricewithtax = 1;
1910 $senderissupplier = 2;
1911 if (
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY')) {
1912 $senderissupplier =
getDolGlobalInt(
'SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY');
1916 $object->printObjectLines($action, $soc, $mysoc, $lineid, $dateSelector);
1921 if ($action !=
'editline') {
1924 $parameters = array(
'dateSelector' => $dateSelector);
1925 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters,
$object, $action);
1929 if (empty($reshook)) {
1930 $object->formAddObjectLine($dateSelector, $soc, $mysoc);
1942 if ($action ==
'statut') {
1944 $form_close =
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST" id="formacceptrefuse" class="formconsumeproduce paddingbottom paddingleft paddingright">';
1945 $form_close .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1946 $form_close .=
'<input type="hidden" name="action" value="setstatut">';
1949 $form_close .=
'<p class="notice">'.$langs->trans(
'SupplierProposalRefFournNotice').
'</p>';
1951 $form_close .=
'<table class="border centpercent marginleftonly marginrightonly">';
1952 $form_close .=
'<tr><td>'.$langs->trans(
"CloseAs").
'</td><td class="left">';
1953 $form_close .=
'<select id="statut" name="statut" class="flat">';
1954 $form_close .=
'<option value="0"> </option>';
1955 $form_close .=
'<option value="2">'.$langs->trans(
'SupplierProposalStatusSigned').
'</option>';
1956 $form_close .=
'<option value="3">'.$langs->trans(
'SupplierProposalStatusNotSigned').
'</option>';
1957 $form_close .=
'</select>';
1958 $form_close .=
'</td></tr>';
1959 $form_close .=
'<tr><td class="left">'.$langs->trans(
'Note').
'</td><td class="left"><textarea cols="70" rows="'.ROWS_3.
'" wrap="soft" name="note">';
1960 $form_close .=
$object->note_private;
1961 $form_close .=
'</textarea></td></tr>';
1962 $form_close .=
'</table>';
1963 $form_close .= $form->buttonsSaveCancel();
1964 $form_close .=
'<a id="acceptedrefused"> </a>';
1965 $form_close .=
'</form>';
1973 if ($action !=
'presend') {
1974 print
'<div class="tabsAction">';
1976 $parameters = array();
1977 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
1979 if (empty($reshook)) {
1980 if ($action !=
'statut' && $action !=
'editline') {
1983 if (count(
$object->lines) > 0) {
1984 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>';
1991 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>';
1996 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').
'"';
1997 print
'>'.$langs->trans(
'ReOpen').
'</a></div>';
2001 if (empty($user->socid)) {
2004 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.
newToken().
'&mode=init#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a></div>';
2006 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
'SendMail').
'</a></div>';
2013 if ($usercancreateorder) {
2014 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>';
2020 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').
'"';
2021 print
'>'.$langs->trans(
'SetAcceptedRefused').
'</a></div>';
2026 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').
'"';
2027 print
'>'.$langs->trans(
'Close').
'</a></div>';
2031 if ($usercancreate) {
2032 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&socid='.
$object->socid.
'&action=clone&object='.
$object->element.
'&token='.
newToken().
'">'.$langs->trans(
"ToClone").
'</a></div>';
2043 if ($action !=
'presend') {
2044 print
'<div class="fichecenter"><div class="fichehalfleft">';
2051 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
2052 $genallowed = $usercanread;
2053 $delallowed = $usercancreate;
2055 print $formfile->showdocuments(
'supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'', 0,
'', $soc->default_lang);
2059 $tmparray = $form->showLinkToObjectBlock(
$object, array(), array(
'supplier_proposal'), 1);
2060 $linktoelem = $tmparray[
'linktoelem'];
2061 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
2062 print $htmltoenteralink;
2064 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
2068 print
'</div><div class="fichehalfright">';
2071 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2073 $somethingshown = $formactions->showactions(
$object,
'supplier_proposal', $socid, 1,
'', $MAXEVENT);
2075 print
'</div></div>';
2079 if (
GETPOST(
'modelselected')) {
2080 $action =
'presend';
2084 $modelmail =
'supplier_proposal_send';
2085 $defaulttopic =
'SendAskRef';
2086 $diroutput =
$conf->supplier_proposal->dir_output;
2087 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
2088 $trackid =
'spro'.$object->id;
2090 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage the table of subscription to notifications.
Class to manage predefined suppliers products.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage price ask supplier.
const STATUS_NOTSIGNED
Not signed quote, canceled.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
const STATUS_SIGNED
Signed quote.
const STATUS_CLOSE
Billed or closed/processed quote.
Class to manage translations.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that returns whether VAT must be recoverable collected VAT (e.g.: VAT NPR in France)
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.