37 require
'../main.inc.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_proposal/modules_supplier_proposal.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/lib/supplier_proposal.lib.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
47 if (!empty($conf->project->enabled)) {
48 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
53 $langs->loadLangs(array(
'companies',
'supplier_proposal',
'compta',
'bills',
'propal',
'orders',
'products',
'deliveries',
'sendings'));
54 if (!empty($conf->margin->enabled)) {
55 $langs->load(
'margins');
62 $socid =
GETPOST(
'socid',
'int');
63 $action =
GETPOST(
'action',
'aZ09');
65 $origin =
GETPOST(
'origin',
'alpha');
66 $originid =
GETPOST(
'originid',
'int');
67 $confirm =
GETPOST(
'confirm',
'alpha');
68 $projectid =
GETPOST(
'projectid',
'int');
69 $lineid =
GETPOST(
'lineid',
'int');
70 $contactid =
GETPOST(
'contactid',
'int');
71 $rank = (
GETPOST(
'rank',
'int') > 0) ?
GETPOST(
'rank',
'int') : -1;
74 $hidedetails = (
GETPOST(
'hidedetails',
'int') ?
GETPOST(
'hidedetails',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
75 $hidedesc = (
GETPOST(
'hidedesc',
'int') ?
GETPOST(
'hidedesc',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
76 $hideref = (
GETPOST(
'hideref',
'int') ?
GETPOST(
'hideref',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
82 if (!empty($user->socid)) {
83 $socid = $user->socid;
88 $hookmanager->initHooks(array(
'supplier_proposalcard',
'globalcard'));
94 $extrafields->fetch_name_optionals_label($object->table_element);
97 if ($id > 0 || !empty($ref)) {
98 $ret = $object->fetch($id, $ref);
100 $ret = $object->fetch_thirdparty();
108 $usercanread = $user->rights->supplier_proposal->lire;
109 $usercancreate = $user->rights->supplier_proposal->creer;
110 $usercandelete = $user->rights->supplier_proposal->supprimer;
113 $usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->validate_advance)));
114 $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->supplier_proposal->send_advance);
117 $usercanclose = $user->rights->supplier_proposal->cloturer;
118 $usercancreateorder = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer);
121 $permissionnote = $usercancreate;
122 $permissiondellink = $usercancreate;
123 $permissiontoedit = $usercancreate;
124 $permissiontoadd = $usercancreate;
131 $parameters = array(
'socid' => $socid);
132 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
137 if (empty($reshook)) {
138 $backurlforlist = DOL_URL_ROOT.
'/supplier_proposal/list.php';
140 if (empty($backtopage) || ($cancel && empty($id))) {
141 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
142 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
143 $backtopage = $backurlforlist;
145 $backtopage = DOL_URL_ROOT.
'/supplier_proposal/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
151 if (!empty($backtopageforcancel)) {
152 header(
"Location: ".$backtopageforcancel);
154 } elseif (!empty($backtopage)) {
155 header(
"Location: ".$backtopage);
161 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
163 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
165 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
168 if ($action ==
'confirm_clone' && $confirm ==
'yes') {
169 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
172 if ($object->id > 0) {
173 $result = $object->createFromClone($user, $socid);
175 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
183 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
185 $result = $object->delete($user);
187 header(
'Location: '.DOL_URL_ROOT.
'/supplier_proposal/list.php');
190 $langs->load(
"errors");
193 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
195 $result = $object->deleteline($lineid);
198 $object->line_order(
true);
201 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
203 $outputlangs = $langs;
204 if (!empty($conf->global->MAIN_MULTILANGS)) {
206 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') : $object->thirdparty->default_lang);
207 $outputlangs->setDefaultLang($newlang);
209 $ret = $object->fetch($id);
210 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
213 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
215 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
217 $result = $object->valid($user);
219 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
221 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
222 $outputlangs = $langs;
224 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
225 $newlang =
GETPOST(
'lang_id',
'aZ09');
227 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
228 $newlang = $object->thirdparty->default_lang;
230 if (!empty($newlang)) {
232 $outputlangs->setDefaultLang($newlang);
234 $model = $object->model_pdf;
235 $ret = $object->fetch($id);
237 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
241 $langs->load(
"errors");
242 if (count($object->errors) > 0) {
248 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
253 } elseif ($action ==
'add' && $usercancreate) {
255 $object->socid = $socid;
256 $object->fetch_thirdparty();
261 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Supplier")), null,
'errors');
270 if (
GETPOST(
'createmode') ==
'copy' &&
GETPOST(
'copie_supplier_proposal')) {
271 if ($object->fetch(
GETPOST(
'copie_supplier_proposal')) > 0) {
273 $object->date_livraison = $date_delivery;
274 $object->delivery_date = $date_delivery;
275 $object->shipping_method_id =
GETPOST(
'shipping_method_id',
'int');
276 $object->cond_reglement_id =
GETPOST(
'cond_reglement_id');
277 $object->mode_reglement_id =
GETPOST(
'mode_reglement_id');
278 $object->fk_account =
GETPOST(
'fk_account',
'int');
281 $object->socid =
GETPOST(
'socid');
282 $object->fk_project =
GETPOST(
'projectid',
'int');
283 $object->model_pdf =
GETPOST(
'model');
284 $object->author = $user->id;
285 $object->note =
GETPOST(
'note',
'restricthtml');
286 $object->note_private =
GETPOST(
'note',
'restricthtml');
289 setEventMessages($langs->trans(
"ErrorFailedToCopyProposal",
GETPOST(
'copie_supplier_proposal')), null,
'errors');
293 $object->date_livraison = $date_delivery;
294 $object->delivery_date = $date_delivery;
295 $object->demand_reason_id =
GETPOST(
'demand_reason_id');
296 $object->shipping_method_id =
GETPOST(
'shipping_method_id',
'int');
297 $object->cond_reglement_id =
GETPOST(
'cond_reglement_id');
298 $object->mode_reglement_id =
GETPOST(
'mode_reglement_id');
299 $object->fk_account =
GETPOST(
'fk_account',
'int');
300 $object->fk_project =
GETPOST(
'projectid',
'int');
301 $object->model_pdf =
GETPOST(
'model');
302 $object->author = $user->id;
303 $object->note =
GETPOST(
'note',
'restricthtml');
304 $object->note_private =
GETPOST(
'note',
'restricthtml');
306 $object->origin =
GETPOST(
'origin');
307 $object->origin_id =
GETPOST(
'originid');
310 if (!empty($conf->multicurrency->enabled)) {
311 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
315 $ret = $extrafields->setOptionalsFromPost(null, $object);
323 if ($origin && $originid) {
324 $element = $subelement = $origin;
325 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
327 $subelement = $regs[2];
331 if ($element ==
'order') {
332 $element = $subelement =
'commande';
334 if ($element ==
'propal') {
335 $element =
'comm/propal';
336 $subelement =
'propal';
339 $object->origin = $origin;
340 $object->origin_id = $originid;
343 $object->linked_objects [$object->origin] = $object->origin_id;
344 if (is_array($_POST[
'other_linked_objects']) && !empty($_POST[
'other_linked_objects'])) {
345 $object->linked_objects = array_merge($object->linked_objects, $_POST[
'other_linked_objects']);
348 $id = $object->create($user);
352 $classname = ucfirst($subelement);
353 $srcobject =
new $classname($db);
355 dol_syslog(
"Try to find source object origin=".$object->origin.
" originid=".$object->origin_id.
" to add lines");
356 $result = $srcobject->fetch($object->origin_id);
359 $lines = $srcobject->lines;
360 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
361 $srcobject->fetch_lines();
362 $lines = $srcobject->lines;
366 $num = count($lines);
367 for ($i = 0; $i < $num; $i++) {
368 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
369 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->libelle);
372 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
375 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
380 if (method_exists($lines[$i],
'fetch_optionals')) {
381 $lines[$i]->fetch_optionals();
382 $array_options = $lines[$i]->array_options;
385 $result = $object->addline(
387 $lines[$i]->subprice,
390 $lines[$i]->localtax1_tx,
391 $lines[$i]->localtax2_tx,
392 $lines[$i]->fk_product,
393 $lines[$i]->remise_percent,
396 $lines[$i]->info_bits,
399 $lines[$i]->special_code,
401 $lines[$i]->fk_fournprice,
405 $lines[$i]->ref_supplier,
418 if ($result > 0 && $lines[$i]->product_type == 9) {
419 $fk_parent_line = $result;
424 $parameters = array(
'objFrom' => $srcobject);
425 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $object, $action);
440 $id = $object->create($user);
448 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
449 $outputlangs = $langs;
451 if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
452 $newlang =
GETPOST(
'lang_id',
'aZ09');
454 if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
455 $newlang = $object->thirdparty->default_lang;
457 if (!empty($newlang)) {
459 $outputlangs->setDefaultLang($newlang);
461 $model = $object->model_pdf;
463 $ret = $object->fetch($id);
464 $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
470 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
483 } elseif ($action ==
'confirm_reopen' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
489 } elseif ($action ==
'close' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
495 } elseif ($action ==
'setstatut' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
498 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"CloseAs")), null,
'errors');
503 $object->cloture($user,
GETPOST(
'statut'),
GETPOST(
'note',
'restricthtml'));
509 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
512 $triggersendname =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
513 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
514 $trackid =
'spro'.$object->id;
515 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
518 $upload_dir = $conf->supplier_proposal->dir_output;
519 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
523 if ($action ==
'modif' && $usercancreate) {
524 $object->setDraft($user);
526 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
528 $outputlangs = $langs;
529 if (!empty($conf->global->MAIN_MULTILANGS)) {
531 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') : $object->thirdparty->default_lang);
532 $outputlangs->setDefaultLang($newlang);
534 $ret = $object->fetch($id);
535 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
537 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
538 if (
GETPOST(
"remise_id",
'int')) {
539 if ($object->id > 0) {
540 $result = $object->insert_discount(
GETPOST(
"remise_id",
'int'));
549 if ($action ==
'addline' && $usercancreate) {
550 $langs->load(
'errors');
559 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
561 $prod_entry_mode =
GETPOST(
'prod_entry_mode');
562 if ($prod_entry_mode ==
'free') {
565 $idprod =
GETPOST(
'idprod',
'int');
577 if (empty($remise_percent)) {
582 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
583 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
585 if (is_array($extralabelsline)) {
587 foreach ($extralabelsline as $key => $value) {
588 unset($_POST[
"options_".$key]);
592 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
593 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')), null,
'errors');
596 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
597 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")), null,
'errors');
601 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' && $price_ht_devise ===
'') {
602 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPrice")), null,
'errors');
605 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
606 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Description")), null,
'errors');
609 if (!$error && ($qty >= 0)) {
613 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
617 if ($prod_entry_mode !=
'free' && empty($error)) {
621 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
626 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
628 $res = $productsupplier->fetch($idprod);
631 if (!empty($conf->global->SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER)) {
633 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
634 if ($productsupplier->fourn_socid != $socid) {
635 $productsupplier->ref_supplier =
'';
638 $fksoctosearch = $object->thirdparty->id;
639 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
641 } elseif (
GETPOST(
'idprodfournprice',
'alpha') > 0) {
644 $idprod = $productsupplier->get_buyprice(
GETPOST(
'idprodfournprice',
'alpha'), $qtytosearch);
645 $res = $productsupplier->fetch($idprod);
649 $label = $productsupplier->label;
652 if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
653 $outputlangs = $langs;
655 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
656 $newlang =
GETPOST(
'lang_id',
'aZ09');
658 if (empty($newlang)) {
659 $newlang = $object->thirdparty->default_lang;
661 if (!empty($newlang)) {
663 $outputlangs->setDefaultLang($newlang);
665 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->description;
667 $desc = $productsupplier->description;
670 if (!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) {
671 $desc = $productsupplier->desc_supplier;
675 if (trim($product_desc) == trim($desc) && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) {
679 if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) {
680 $desc = $product_desc;
682 if (!empty($product_desc) && trim($product_desc) != trim($desc)) {
683 $desc =
dol_concatdesc($desc, $product_desc,
'', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
686 $ref_supplier = $productsupplier->ref_supplier;
691 $tva_tx =
get_default_tva($object->thirdparty, $mysoc, $productsupplier->id,
GETPOST(
'idprodfournprice',
'alpha'));
692 $tva_npr =
get_default_npr($object->thirdparty, $mysoc, $productsupplier->id,
GETPOST(
'idprodfournprice',
'alpha'));
694 if (empty($tva_tx)) {
697 $localtax1_tx =
get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr);
698 $localtax2_tx =
get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr);
700 $type = $productsupplier->type;
701 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'price_ht_devise') !=
'') {
702 $price_base_type =
'HT';
704 $pu_devise =
price2num($price_ht_devise,
'CU');
705 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'price_ttc_devise') !=
'') {
706 $price_base_type =
'TTC';
708 $pu_devise =
price2num($price_ttc_devise,
'CU');
710 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
711 if (empty($object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code != $object->multicurrency_code)) {
712 $pu = $productsupplier->fourn_pu;
715 $pu = $productsupplier->fourn_pu;
716 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
725 $fournprice = (is_numeric(
GETPOST(
'idprodfournprice',
'alpha')) ?
GETPOST(
'idprodfournprice',
'alpha') : -1);
728 $result = $object->addline(
730 ($price_base_type ==
'HT' ? $pu : 0),
735 $productsupplier->id,
738 ($price_base_type ==
'TTC' ? $pu : 0),
741 min($rank, count($object->lines) + 1),
749 $productsupplier->fk_unit,
765 if ($idprod == -99 || $idprod == 0) {
768 $langs->load(
"errors");
769 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")).
' '.$langs->trans(
"or").
' '.$langs->trans(
"NoPriceDefinedForThisSupplier"), null,
'errors');
774 $langs->load(
"errors");
775 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"), null,
'errors');
777 } elseif ((
GETPOST(
'price_ht') !==
'' ||
GETPOST(
'price_ttc') !==
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') && empty($error)) {
781 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
782 $tva_tx = str_replace(
'*',
'', $tva_tx);
783 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
784 $desc = $product_desc;
787 $fk_unit =
GETPOST(
'units',
'alpha');
789 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
794 $localtax1_tx =
get_localtax($tva_tx, 1, $mysoc, $object->thirdparty);
795 $localtax2_tx =
get_localtax($tva_tx, 2, $mysoc, $object->thirdparty);
797 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'price_ht_devise') !=
'') {
801 $pu_ht =
price2num($pu_ttc / (1 + ($tva_tx / 100)),
'MU');
803 $price_base_type =
'HT';
804 $pu_ht_devise =
price2num($price_ht_devise,
'CU');
807 $result = $object->addline(
836 if (!$error && $result > 0) {
839 $ret = $object->fetch($object->id);
842 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
843 $outputlangs = $langs;
845 if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
846 $newlang =
GETPOST(
'lang_id',
'aZ09');
848 if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
849 $newlang = $object->thirdparty->default_lang;
851 if (!empty($newlang)) {
853 $outputlangs->setDefaultLang($newlang);
855 $model = $object->model_pdf;
856 $ret = $object->fetch($id);
858 $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
864 unset($_POST[
'prod_entry_mode']);
866 unset($_POST[
'qty']);
867 unset($_POST[
'type']);
868 unset($_POST[
'remise_percent']);
870 unset($_POST[
'price_ht']);
871 unset($_POST[
'multicurrency_price_ht']);
872 unset($_POST[
'price_ttc']);
873 unset($_POST[
'fourn_ref']);
874 unset($_POST[
'tva_tx']);
875 unset($_POST[
'label']);
876 unset($_POST[
'product_ref']);
877 unset($_POST[
'product_label']);
878 unset($_POST[
'product_desc']);
879 unset($_POST[
'fournprice']);
880 unset($_POST[
'buying_price']);
881 unset($localtax1_tx);
882 unset($localtax2_tx);
883 unset($_POST[
'np_marginRate']);
884 unset($_POST[
'np_markRate']);
885 unset($_POST[
'dp_desc']);
886 unset($_POST[
'idprodfournprice']);
887 unset($_POST[
'units']);
889 unset($_POST[
'idprod']);
891 unset($_POST[
'date_starthour']);
892 unset($_POST[
'date_startmin']);
893 unset($_POST[
'date_startsec']);
894 unset($_POST[
'date_startday']);
895 unset($_POST[
'date_startmonth']);
896 unset($_POST[
'date_startyear']);
897 unset($_POST[
'date_endhour']);
898 unset($_POST[
'date_endmin']);
899 unset($_POST[
'date_endsec']);
900 unset($_POST[
'date_endday']);
901 unset($_POST[
'date_endmonth']);
902 unset($_POST[
'date_endyear']);
909 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save') == $langs->trans(
"Save")) {
915 if (preg_match(
'/\*/', $vat_rate)) {
923 $vat_rate = str_replace(
'*',
'', $vat_rate);
924 $localtax1_rate =
get_localtax($vat_rate, 1, $mysoc, $object->thirdparty);
925 $localtax2_rate =
get_localtax($vat_rate, 2, $mysoc, $object->thirdparty);
927 if (
GETPOST(
'price_ht') !=
'') {
928 $price_base_type =
'HT';
932 $vatratecleaned = $vat_rate;
933 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) {
934 $vatratecleaned = trim($reg[1]);
935 $vatratecode = $reg[2];
939 $ht = $ttc / (1 + ($vatratecleaned / 100));
940 $price_base_type =
'HT';
946 $fournprice = (
GETPOST(
'fournprice') ?
GETPOST(
'fournprice') :
'');
947 $buyingprice = (
GETPOST(
'buying_price') !=
'' ?
GETPOST(
'buying_price') :
'');
950 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
951 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
953 if (is_array($extralabelsline)) {
954 foreach ($extralabelsline as $key => $value) {
955 unset($_POST[
"options_".$key]);
960 $special_code =
GETPOST(
'special_code');
966 $productid =
GETPOST(
'productid',
'int');
967 if (!empty($productid)) {
969 if (!empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) {
970 if ($productid > 0 && $productsupplier->get_buyprice(0,
price2num(
GETPOST(
'qty')), $productid,
'none',
GETPOST(
'socid',
'int')) < 0) {
971 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"), null,
'warnings');
976 $res = $product->fetch($productid);
978 $type = $product->type;
980 $price_min = $product->price_min;
981 if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) {
982 $price_min = $product->multiprices_min [$object->thirdparty->price_level];
988 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
992 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")), null,
'errors');
1000 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1003 $result = $object->updateline(
1015 GETPOST(
'fk_parent_line',
'int'),
1030 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1032 $outputlangs = $langs;
1033 if (!empty($conf->global->MAIN_MULTILANGS)) {
1034 $outputlangs =
new Translate(
"", $conf);
1035 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') : $object->thirdparty->default_lang);
1036 $outputlangs->setDefaultLang($newlang);
1038 $ret = $object->fetch($id);
1039 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1042 unset($_POST[
'qty']);
1043 unset($_POST[
'type']);
1044 unset($_POST[
'productid']);
1045 unset($_POST[
'remise_percent']);
1046 unset($_POST[
'price_ht']);
1047 unset($_POST[
'multicurrency_price_ht']);
1048 unset($_POST[
'price_ttc']);
1049 unset($_POST[
'tva_tx']);
1050 unset($_POST[
'product_ref']);
1051 unset($_POST[
'product_label']);
1052 unset($_POST[
'product_desc']);
1053 unset($_POST[
'fournprice']);
1054 unset($_POST[
'buying_price']);
1056 unset($_POST[
'date_starthour']);
1057 unset($_POST[
'date_startmin']);
1058 unset($_POST[
'date_startsec']);
1059 unset($_POST[
'date_startday']);
1060 unset($_POST[
'date_startmonth']);
1061 unset($_POST[
'date_startyear']);
1062 unset($_POST[
'date_endhour']);
1063 unset($_POST[
'date_endmin']);
1064 unset($_POST[
'date_endsec']);
1065 unset($_POST[
'date_endday']);
1066 unset($_POST[
'date_endmonth']);
1067 unset($_POST[
'date_endyear']);
1074 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha') == $langs->trans(
"Cancel")) {
1075 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
1077 } elseif ($action ==
'classin' && $usercancreate) {
1079 $object->setProject(
GETPOST(
'projectid'),
'int');
1080 } elseif ($action ==
'setavailability' && $usercancreate) {
1082 $result = $object->availability(
GETPOST(
'availability_id'));
1083 } elseif ($action ==
'setconditions' && $usercancreate) {
1085 $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_id',
'int'));
1086 } elseif ($action ==
'setremisepercent' && $usercancreate) {
1087 $result = $object->set_remise_percent($user,
price2num(
GETPOST(
'remise_percent'),
'', 2));
1088 } elseif ($action ==
'setremiseabsolue' && $usercancreate) {
1089 $result = $object->set_remise_absolue($user,
price2num(
GETPOST(
'remise_absolue'),
'MU', 2));
1090 } elseif ($action ==
'setmode' && $usercancreate) {
1092 $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_id',
'int'));
1093 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
1095 $result = $object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
1096 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
1098 $result = $object->setMulticurrencyRate(
price2num(
GETPOST(
'multicurrency_tx')),
GETPOST(
'calculation_mode',
'int'));
1099 } elseif ($action ==
'update_extras') {
1103 $ret = $extrafields->setOptionalsFromPost(null, $object,
GETPOST(
'attribute',
'restricthtml'));
1109 $result = $object->insertExtraFields(
'PROPOSAL_SUPPLIER_MODIFY');
1117 $action =
'edit_extras';
1126 $title = $langs->trans(
'CommRequest').
" - ".$langs->trans(
'Card');
1127 $help_url =
'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur';
1134 $companystatic =
new Societe($db);
1135 if (!empty($conf->project->enabled)) {
1142 if ($action ==
'create') {
1143 $currency_code = $conf->currency;
1145 print
load_fiche_titre($langs->trans(
"NewAskPrice"),
'',
'supplier_proposal');
1149 $res = $soc->fetch($socid);
1153 if (!empty($origin) && !empty($originid)) {
1154 $element = $subelement =
GETPOST(
'origin');
1155 if (preg_match(
'/^([^_]+)_([^_]+)/i',
GETPOST(
'origin'), $regs)) {
1156 $element = $regs[1];
1157 $subelement = $regs[2];
1161 if ($element ==
'order' || $element ==
'commande') {
1162 $element = $subelement =
'commande';
1164 if ($element ==
'propal') {
1165 $element =
'comm/propal';
1166 $subelement =
'propal';
1171 $classname = ucfirst($subelement);
1172 $objectsrc =
new $classname($db);
1173 $objectsrc->fetch($originid);
1174 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1175 $objectsrc->fetch_lines();
1177 $objectsrc->fetch_thirdparty();
1179 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
1180 $soc = $objectsrc->thirdparty;
1182 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1183 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1184 $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_supplier_percent) ? $soc->remise_supplier_percent : 0));
1185 $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0));
1188 $objectsrc->fetch_optionals();
1189 $object->array_options = $objectsrc->array_options;
1191 if (!empty($conf->multicurrency->enabled)) {
1192 if (!empty($objectsrc->multicurrency_code)) {
1193 $currency_code = $objectsrc->multicurrency_code;
1195 if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) {
1196 $currency_tx = $objectsrc->multicurrency_tx;
1200 $cond_reglement_id = $soc->cond_reglement_supplier_id;
1201 $mode_reglement_id = $soc->mode_reglement_supplier_id;
1202 if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) {
1203 $currency_code = $soc->multicurrency_code;
1209 print
'<form name="addprop" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1210 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1211 print
'<input type="hidden" name="action" value="add">';
1212 if ($origin !=
'project' && $originid) {
1213 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1214 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1219 print
'<table class="border centpercent">';
1222 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td colspan="2">'.$langs->trans(
"Draft").
'</td></tr>';
1226 print
'<td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
1228 print
'<td colspan="2">';
1229 print $soc->getNomUrl(1,
'supplier');
1230 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1233 print
'<td colspan="2">';
1234 print
img_picto(
'',
'company').$form->select_company(
'',
'socid',
's.fournisseur=1',
'SelectThirdParty', 0, 0, null, 0,
'minwidth300');
1236 if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) {
1238 $(document).ready(function() {
1239 $("#socid").change(function() {
1240 var socid = $(this).val();
1242 window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?action=create&socid="+socid;
1247 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>';
1254 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
1256 $absolute_discount = $soc->getAvailableDiscounts(
'',
'', 0, 1);
1260 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
1261 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1267 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td colspan="2">';
1268 $form->select_conditions_paiements(
GETPOST(
'cond_reglement_id') > 0 ?
GETPOST(
'cond_reglement_id') : $cond_reglement_id,
'cond_reglement_id', -1, 1);
1272 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td colspan="2">';
1273 $form->select_types_paiements(
GETPOST(
'mode_reglement_id') > 0 ?
GETPOST(
'mode_reglement_id') : $mode_reglement_id,
'mode_reglement_id');
1277 if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) {
1278 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td colspan="2">';
1279 $form->select_comptes(
GETPOST(
'fk_account') > 0 ?
GETPOST(
'fk_account',
'int') : $fk_account,
'fk_account', 0,
'', 1);
1284 if (!empty($conf->expedition->enabled)) {
1285 print
'<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td colspan="2">';
1286 print
$form->selectShippingMethod(
GETPOST(
'shipping_method_id') > 0 ?
GETPOST(
'shipping_method_id',
'int') :
"",
'shipping_method_id',
'', 1);
1291 print
'<tr><td>'.$langs->trans(
"DeliveryDate").
'</td>';
1292 print
'<td colspan="2">';
1294 if (!empty($conf->global->DATE_LIVRAISON_WEEK_DELAY)) {
1295 $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60);
1296 $syear = date(
"Y", $tmpdte);
1297 $smonth = date(
"m", $tmpdte);
1298 $sday = date(
"d", $tmpdte);
1299 print
$form->selectDate($syear.
"-".$smonth.
"-".$sday,
'liv_',
'',
'',
'',
"addask");
1301 print
$form->selectDate($datedelivery ? $datedelivery : -1,
'liv_',
'',
'',
'',
"addask", 1, 1);
1308 print
'<td>'.$langs->trans(
"DefaultModel").
'</td>';
1309 print
'<td colspan="2">';
1311 $preselected = (!empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT) ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT : $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF);
1312 print
$form->selectarray(
'model', $list, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1316 if (!empty($conf->project->enabled)) {
1317 $langs->load(
"projects");
1321 if ($origin ==
'project') {
1322 $projectid = ($originid ? $originid : 0);
1326 print
'<td>'.$langs->trans(
"Project").
'</td><td colspan="2">';
1327 print
img_picto(
'',
'project').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
1328 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>';
1335 if (!empty($conf->multicurrency->enabled)) {
1337 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
1338 print
'<td colspan="3" class="maxwidthonsmartphone">';
1339 print
$form->selectMultiCurrency($currency_code,
'multicurrency_code');
1344 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' => 3);
1345 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1346 print $hookmanager->resPrint;
1347 if (empty($reshook)) {
1348 print $object->showOptionals($extrafields,
'create', $parameters);
1353 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1355 if ($origin ==
'contrat') {
1357 $objectsrc->remise_absolue = $remise_absolue;
1358 $objectsrc->remise_percent = $remise_percent;
1359 $objectsrc->update_price(1, - 1, 1);
1362 print
"\n<!-- ".$classname.
" info -->";
1364 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
1365 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
1366 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
1367 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
1368 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
1370 print
'<tr><td>'.$langs->trans(
'CommRequest').
'</td><td colspan="2">'.$objectsrc->getNomUrl(1).
'</td></tr>';
1371 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td colspan="2">'.
price($objectsrc->total_ht).
'</td></tr>';
1372 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td colspan="2">'.
price($objectsrc->total_tva).
"</td></tr>";
1373 if ($mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
1374 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax1).
"</td></tr>";
1377 if ($mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
1378 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax2).
"</td></tr>";
1380 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td colspan="2">'.
price($objectsrc->total_ttc).
"</td></tr>";
1382 if (!empty($conf->multicurrency->enabled)) {
1383 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
1384 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
1385 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
1396 if (empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) {
1397 print
'<input type="hidden" name="createmode" value="empty">';
1400 if (!empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) {
1401 print
'<br><table>';
1405 print
'<td><input type="radio" name="createmode" value="copy"></td>';
1406 print
'<td>'.$langs->trans(
"CopyAskFrom").
' </td>';
1408 $liste_ask = array();
1409 $liste_ask [0] =
'';
1411 $sql =
"SELECT p.rowid as id, p.ref, s.nom";
1412 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal p";
1413 $sql .=
", ".MAIN_DB_PREFIX.
"societe s";
1414 $sql .=
" WHERE s.rowid = p.fk_soc";
1415 $sql .=
" AND p.entity = ".$conf->entity;
1416 $sql .=
" AND p.fk_statut <> ".SupplierProposal::STATUS_DRAFT;
1417 $sql .=
" ORDER BY Id";
1419 $resql = $db->query($sql);
1421 $num = $db->num_rows(
$resql);
1424 $row = $db->fetch_row(
$resql);
1425 $askPriceSupplierRefAndSocName = $row [1].
" - ".$row [2];
1426 $liste_ask [$row [0]] = $askPriceSupplierRefAndSocName;
1429 print
$form->selectarray(
"copie_supplier_proposal", $liste_ask, 0);
1435 print
'<tr><td class="tdtop"><input type="radio" name="createmode" value="empty" checked></td>';
1436 print
'<td valign="top" colspan="2">'.$langs->trans(
"CreateEmptyAsk").
'</td></tr>';
1439 if (!empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) {
1445 print
$form->buttonsSaveCancel(
"CreateDraft");
1451 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1454 $title = $langs->trans(
'ProductsAndServices');
1457 print
'<div class="div-table-responsive-no-min">';
1458 print
'<table class="noborder centpercent">';
1460 $objectsrc->printOriginLinesList();
1471 $soc->fetch($object->socid);
1473 $head = supplier_proposal_prepare_head($object);
1474 print
dol_get_fiche_head($head,
'comm', $langs->trans(
'CommRequest'), -1,
'supplier_proposal');
1479 if ($action ==
'clone') {
1481 $formquestion = array(
1489 'label' => $langs->trans(
"SelectThirdParty"),
1490 'value' =>
$form->select_company(
GETPOST(
'socid',
'int'),
'socid',
's.fournisseur=1'))
1493 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
1494 } elseif ($action ==
'delete') {
1496 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteAsk'), $langs->trans(
'ConfirmDeleteAsk', $object->ref),
'confirm_delete',
'', 0, 1);
1497 } elseif ($action ==
'reopen') {
1499 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ReOpen'), $langs->trans(
'ConfirmReOpenAsk', $object->ref),
'confirm_reopen',
'', 0, 1);
1500 } elseif ($action ==
'ask_deleteline') {
1502 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
1503 } elseif ($action ==
'validate') {
1508 $ref = substr($object->ref, 1, 4);
1509 if ($ref ==
'PROV') {
1510 $numref = $object->getNextNumRef($soc);
1511 if (empty($numref)) {
1516 $numref = $object->ref;
1519 $text = $langs->trans(
'ConfirmValidateAsk', $numref);
1520 if (!empty($conf->notification->enabled)) {
1521 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
1522 $notify =
new Notify($db);
1524 $text .= $notify->confirmMessage(
'PROPOSAL_SUPPLIER_VALIDATE', $object->socid, $object);
1528 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ValidateAsk'), $text,
'confirm_validate',
'', 0, 1);
1533 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
1534 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1535 if (empty($reshook)) {
1536 $formconfirm .= $hookmanager->resPrint;
1537 } elseif ($reshook > 0) {
1538 $formconfirm = $hookmanager->resPrint;
1546 $linkback =
'<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1549 $morehtmlref =
'<div class="refidno">';
1554 $morehtmlref .= $langs->trans(
'ThirdParty').
' : '.$object->thirdparty->getNomUrl(1,
'supplier');
1555 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
1556 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.$object->thirdparty->id.
'&search_societe='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherProposals").
'</a>)';
1559 if (!empty($conf->project->enabled)) {
1560 $langs->load(
"projects");
1561 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
1562 if ($usercancreate) {
1563 if ($action !=
'classify') {
1564 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
1566 if ($action ==
'classify') {
1568 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
1569 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
1570 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1571 $morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
1572 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
1573 $morehtmlref .=
'</form>';
1575 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
1578 if (!empty($object->fk_project)) {
1580 $proj->fetch($object->fk_project);
1581 $morehtmlref .=
' : '.$proj->getNomUrl(1);
1583 $morehtmlref .=
' - '.$proj->title;
1590 $morehtmlref .=
'</div>';
1593 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1596 print
'<div class="fichecenter">';
1597 print
'<div class="fichehalfleft">';
1598 print
'<div class="underbanner clearboth"></div>';
1600 print
'<table class="border tableforfield" width="100%">';
1603 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
1604 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
1605 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
1607 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
1608 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
1611 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td>';
1613 $absolute_discount = $soc->getAvailableDiscounts(
'', $filterabsolutediscount, 0, 1);
1614 $absolute_creditnote = $soc->getAvailableDiscounts(
'', $filtercreditnote, 0, 1);
1615 $absolute_discount =
price2num($absolute_discount,
'MT');
1616 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
1620 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?id='.$object->id);
1621 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1626 print
'<tr><td class="titlefield">';
1627 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1628 print $langs->trans(
'PaymentConditionsShort');
1631 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>';
1633 print
'</tr></table>';
1634 print
'</td><td class="valuefield">';
1635 if ($action ==
'editconditions') {
1636 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'cond_reglement_id', 1);
1638 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'none', 1);
1644 $langs->load(
'deliveries');
1646 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1647 print $langs->trans(
'DeliveryDate');
1650 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>';
1652 print
'</tr></table>';
1653 print
'</td><td class="valuefield">';
1654 if ($action ==
'editdate_livraison') {
1655 print
'<form name="editdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post" class="formconsumeproduce">';
1656 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1657 print
'<input type="hidden" name="action" value="setdate_livraison">';
1658 print
$form->selectDate($object->delivery_date,
'liv_',
'',
'',
'',
"editdate_livraison");
1659 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
1670 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1671 print $langs->trans(
'PaymentMode');
1674 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>';
1676 print
'</tr></table>';
1677 print
'</td><td class="valuefield">';
1678 if ($action ==
'editmode') {
1679 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
1681 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'none');
1686 if (!empty($conf->multicurrency->enabled)) {
1690 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1691 print
$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0);
1693 if ($action !=
'editmulticurrencycode' && $object->statut == $object::STATUS_VALIDATED) {
1694 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmulticurrencycode&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetMultiCurrencyCode'), 1).
'</a></td>';
1696 print
'</tr></table>';
1697 print
'</td><td class="valuefield">';
1698 if ($action ==
'editmulticurrencycode') {
1699 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_code,
'multicurrency_code');
1701 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_code,
'none');
1706 if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) {
1709 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1710 print
$form->editfieldkey(
'CurrencyRate',
'multicurrency_tx',
'', $object, 0);
1712 if ($action !=
'editmulticurrencyrate' && $object->statut == $object::STATUS_VALIDATED && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
1713 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmulticurrencyrate&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetMultiCurrencyCode'), 1).
'</a></td>';
1715 print
'</tr></table>';
1716 print
'</td><td class="valuefield">';
1717 if ($action ==
'editmulticurrencyrate' || $action ==
'actualizemulticurrencyrate') {
1718 if ($action ==
'actualizemulticurrencyrate') {
1721 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx,
'multicurrency_tx', $object->multicurrency_code);
1723 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx,
'none', $object->multicurrency_code);
1724 if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
1725 print
'<div class="inline-block"> ';
1726 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=actualizemulticurrencyrate">'.$langs->trans(
"ActualizeCurrency").
'</a>';
1748 if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && !empty($conf->banque->enabled)) {
1751 print
'<table width="100%" class="nobordernopadding"><tr><td>';
1752 print $langs->trans(
'BankAccount');
1754 if ($action !=
'editbankaccount' && $usercancreate) {
1755 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>';
1757 print
'</tr></table>';
1758 print
'</td><td class="valuefield">';
1759 if ($action ==
'editbankaccount') {
1760 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'fk_account', 1);
1762 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'none');
1769 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1774 print
'<div class="fichehalfright">';
1775 print
'<div class="underbanner clearboth"></div>';
1777 print
'<table class="border tableforfield centpercent">';
1779 if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) {
1781 print
'<tr><td class="titlefieldmiddle">'.$form->editfieldkey(
'MulticurrencyAmountHT',
'multicurrency_total_ht',
'', $object, 0).
'</td>';
1782 print
'<td class="valuefield nowrap right amountcard">'.price($object->multicurrency_total_ht,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
1786 print
'<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountVAT',
'multicurrency_total_tva',
'', $object, 0).
'</td>';
1787 print
'<td class="valuefield nowrap right amountcard">'.price($object->multicurrency_total_tva,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
1791 print
'<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountTTC',
'multicurrency_total_ttc',
'', $object, 0).
'</td>';
1792 print
'<td class="valuefield nowrap right amountcard">'.price($object->multicurrency_total_ttc,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
1797 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
'AmountHT').
'</td>';
1798 print
'<td class="valuefield nowrap right amountcard">'.price($object->total_ht,
'', $langs, 0, - 1, - 1, $conf->currency).
'</td>';
1802 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td>';
1803 print
'<td class="valuefield nowrap right amountcard">'.price($object->total_tva,
'', $langs, 0, - 1, - 1, $conf->currency).
'</td>';
1807 if ($mysoc->localtax1_assuj ==
"1" || $object->total_localtax1 != 0) {
1808 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
1809 print
'<td class="valuefield nowrap right amountcard">'.price($object->total_localtax1,
'', $langs, 0, - 1, - 1, $conf->currency).
'</td>';
1812 if ($mysoc->localtax2_assuj ==
"1" || $object->total_localtax2 != 0) {
1813 print
'<tr><td height="10">'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
1814 print
'<td class="valuefield nowrap right amountcard">'.price($object->total_localtax2,
'', $langs, 0, - 1, - 1, $conf->currency).
'</td>';
1819 print
'<tr><td height="10">'.$langs->trans(
'AmountTTC').
'</td>';
1820 print
'<td class="valuefield nowrap right amountcard">'.price($object->total_ttc,
'', $langs, 0, - 1, - 1, $conf->currency).
'</td>';
1833 print
'<div class="clearboth"></div><br>';
1835 if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
1836 $blocname =
'contacts';
1837 $title = $langs->trans(
'ContactsAddresses');
1838 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
1841 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
1842 $blocname =
'notes';
1843 $title = $langs->trans(
'Notes');
1844 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
1852 $result = $object->getLinesArray();
1854 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action !=
'editline') ?
'#add' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
1855 <input type="hidden" name="token" value="' .
newToken().
'">
1856 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
1857 <input type="hidden" name="mode" value="">
1858 <input type="hidden" name="id" value="' . $object->id.
'">
1862 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
1865 print
'<div class="div-table-responsive-no-min">';
1866 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
1869 global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax;
1870 $forceall = 1; $dateSelector = 0; $inputalsopricewithtax = 1;
1871 $senderissupplier = 2;
1872 if (!empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) {
1873 $senderissupplier = 1;
1876 if (!empty($object->lines)) {
1877 $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, $dateSelector);
1882 if ($action !=
'editline') {
1885 $parameters = array();
1886 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
1887 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1888 if (empty($reshook))
1889 $object->formAddObjectLine($dateSelector, $soc, $mysoc);
1899 if ($action ==
'statut') {
1901 $form_close =
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST" id="formacceptrefuse" class="formconsumeproduce paddingbottom paddingleft paddingright">';
1902 $form_close .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1903 $form_close .=
'<input type="hidden" name="action" value="setstatut">';
1905 if (!empty($conf->global->SUPPLIER_PROPOSAL_UPDATE_PRICE_ON_SUPPlIER_PROPOSAL)) {
1906 $form_close .=
'<p class="notice">'.$langs->trans(
'SupplierProposalRefFournNotice').
'</p>';
1908 $form_close .=
'<table class="border centpercent marginleftonly marginrightonly">';
1909 $form_close .=
'<tr><td>'.$langs->trans(
"CloseAs").
'</td><td class="left">';
1910 $form_close .=
'<select id="statut" name="statut" class="flat">';
1911 $form_close .=
'<option value="0"> </option>';
1912 $form_close .=
'<option value="2">'.$langs->trans(
'SupplierProposalStatusSigned').
'</option>';
1913 $form_close .=
'<option value="3">'.$langs->trans(
'SupplierProposalStatusNotSigned').
'</option>';
1914 $form_close .=
'</select>';
1915 $form_close .=
'</td></tr>';
1916 $form_close .=
'<tr><td class="left">'.$langs->trans(
'Note').
'</td><td class="left"><textarea cols="70" rows="'.ROWS_3.
'" wrap="soft" name="note">';
1917 $form_close .= $object->note_private;
1918 $form_close .=
'</textarea></td></tr>';
1919 $form_close .=
'</table>';
1920 $form_close .=
$form->buttonsSaveCancel();
1921 $form_close .=
'<a id="acceptedrefused"> </a>';
1922 $form_close .=
'</form>';
1930 if ($action !=
'presend') {
1931 print
'<div class="tabsAction">';
1933 $parameters = array();
1934 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1936 if (empty($reshook)) {
1937 if ($action !=
'statut' && $action !=
'editline') {
1940 if (count($object->lines) > 0) {
1941 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=validate">'.$langs->trans(
'Validate').
'</a></div>';
1948 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>';
1953 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=reopen&token='.
newToken().(empty($conf->global->MAIN_JUMP_TAG) ?
'' :
'#reopen').
'"';
1954 print
'>'.$langs->trans(
'ReOpen').
'</a></div>';
1958 if (empty($user->socid)) {
1961 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>';
1963 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
'SendMail').
'</a></div>';
1969 if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) && $object->statut ==
SupplierProposal::STATUS_SIGNED) {
1970 if ($usercancreateorder) {
1971 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.
'">'.$langs->trans(
"AddSupplierOrderShort").
'</a></div>';
1977 print
'<div class="inline-block divButAction"><a class="butAction reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=statut'.(empty($conf->global->MAIN_JUMP_TAG) ?
'' :
'#acceptedrefused').
'"';
1978 print
'>'.$langs->trans(
'SetAcceptedRefused').
'</a></div>';
1983 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=close'.(empty($conf->global->MAIN_JUMP_TAG) ?
'' :
'#close').
'"';
1984 print
'>'.$langs->trans(
'Close').
'</a></div>';
1988 if ($usercancreate) {
1989 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&socid='.$object->socid.
'&action=clone&object='.$object->element.
'">'.$langs->trans(
"ToClone").
'</a></div>';
1994 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.
newToken().
'"';
1995 print
'>'.$langs->trans(
'Delete').
'</a></div>';
2003 if ($action !=
'presend') {
2004 print
'<div class="fichecenter"><div class="fichehalfleft">';
2011 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2012 $genallowed = $usercanread;
2013 $delallowed = $usercancreate;
2015 print $formfile->showdocuments(
'supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'', 0,
'', $soc->default_lang);
2019 $linktoelem =
$form->showLinkToObjectBlock($object, null, array(
'supplier_proposal'));
2020 $somethingshown =
$form->showLinkedObjectBlock($object, $linktoelem);
2023 print
'</div><div class="fichehalfright">';
2026 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2028 $somethingshown =
$formactions->showactions($object,
'supplier_proposal', $socid, 1);
2030 print
'</div></div>';
2034 if (
GETPOST(
'modelselected')) {
2035 $action =
'presend';
2039 $modelmail =
'supplier_proposal_send';
2040 $defaulttopic =
'SendAskRef';
2041 $diroutput = $conf->supplier_proposal->dir_output;
2042 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
2043 $trackid =
'spro'.$object->id;
2045 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage notifications.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action== 'set') elseif($action== 'specimen') elseif($action== 'setmodel') elseif($action== 'del') elseif($action== 'setdoc') $formactions
View.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
const STATUS_NOTSIGNED
Not signed quote, canceled.
Class to manage products or services.
dol_now($mode= 'auto')
Return date for now.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for properties) With native = 0: P...
const STATUS_CLOSE
Billed or closed/processed quote.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Fonction qui renvoie si tva doit etre tva percue recuperable.
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...
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate, from a $thirdparty_buyer to a $thirdparty_seller Note: This function applies same rules than get_default_tva.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $help_url
View.
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...
static getIdAndTxFromCode($dbs, $code, $date_document= '')
Get id and rate of currency from code.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
const STATUS_SIGNED
Signed quote.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage projects.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
const STATUS_VALIDATED
Validated status.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Class to manage translations.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
restrictedArea($user, $features, $objectid=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.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
const STATUS_DRAFT
Draft status.
Class to manage price ask supplier.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
$formconfirm
if ($action == 'delbookkeepingyear') {
Class to manage predefined suppliers products.