38require
'../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_proposal/modules_supplier_proposal.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/supplier_proposal.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
48if (isModEnabled(
'project')) {
49 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
50 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
54$langs->loadLangs(array(
'companies',
'supplier_proposal',
'compta',
'bills',
'propal',
'orders',
'products',
'deliveries',
'sendings'));
55if (isModEnabled(
'margin')) {
56 $langs->load(
'margins');
63$socid =
GETPOST(
'socid',
'int');
64$action =
GETPOST(
'action',
'aZ09');
65$cancel =
GETPOST(
'cancel',
'alpha');
66$backtopage =
GETPOST(
'backtopage',
'alpha');
67$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
69$origin =
GETPOST(
'origin',
'alpha');
70$originid =
GETPOST(
'originid',
'int');
71$confirm =
GETPOST(
'confirm',
'alpha');
72$lineid =
GETPOST(
'lineid',
'int');
73$contactid =
GETPOST(
'contactid',
'int');
74$projectid =
GETPOST(
'projectid',
'int');
78$hidedetails = (
GETPOST(
'hidedetails',
'int') ?
GETPOST(
'hidedetails',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
79$hidedesc = (
GETPOST(
'hidedesc',
'int') ?
GETPOST(
'hidedesc',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
80$hideref = (
GETPOST(
'hideref',
'int') ?
GETPOST(
'hideref',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
86$hookmanager->initHooks(array(
'supplier_proposalcard',
'globalcard'));
92$extrafields->fetch_name_optionals_label($object->table_element);
95if ($id > 0 || !empty($ref)) {
96 $ret = $object->fetch($id, $ref);
98 $ret = $object->fetch_thirdparty();
107$usercanread = $user->rights->supplier_proposal->lire;
108$usercancreate = $user->rights->supplier_proposal->creer;
109$usercandelete = $user->rights->supplier_proposal->supprimer;
112$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->validate_advance)));
113$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->supplier_proposal->send_advance);
116$usercanclose = $user->rights->supplier_proposal->cloturer;
117$usercancreateorder = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer);
120$permissionnote = $usercancreate;
121$permissiondellink = $usercancreate;
122$permissiontoedit = $usercancreate;
123$permissiontoadd = $usercancreate;
126if (!empty($user->socid)) {
127 $socid = $user->socid;
136$parameters = array(
'socid' => $socid);
137$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
142if (empty($reshook)) {
143 $backurlforlist = DOL_URL_ROOT.
'/supplier_proposal/list.php';
145 if (empty($backtopage) || ($cancel && empty($id))) {
146 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
147 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
148 $backtopage = $backurlforlist;
150 $backtopage = DOL_URL_ROOT.
'/supplier_proposal/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
156 if (!empty($backtopageforcancel)) {
157 header(
"Location: ".$backtopageforcancel);
159 } elseif (!empty($backtopage)) {
160 header(
"Location: ".$backtopage);
166 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
168 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
170 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
173 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
174 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
177 if ($object->id > 0) {
178 $result = $object->createFromClone($user, $socid);
180 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
188 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
190 $result = $object->delete($user);
192 header(
'Location: '.DOL_URL_ROOT.
'/supplier_proposal/list.php');
195 $langs->load(
"errors");
198 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
200 $result = $object->deleteline($lineid);
203 $object->line_order(
true);
205 $langs->load(
"errors");
209 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
211 $outputlangs = $langs;
214 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') : $object->thirdparty->default_lang);
215 $outputlangs->setDefaultLang($newlang);
217 $ret = $object->fetch($id);
219 $object->fetch_thirdparty();
221 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
224 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
226 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
228 $result = $object->valid($user);
230 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
231 $outputlangs = $langs;
234 $newlang =
GETPOST(
'lang_id',
'aZ09');
237 $newlang = $object->thirdparty->default_lang;
239 if (!empty($newlang)) {
241 $outputlangs->setDefaultLang($newlang);
243 $model = $object->model_pdf;
244 $ret = $object->fetch($id);
246 $object->fetch_thirdparty();
249 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
252 $langs->load(
"errors");
253 if (count($object->errors) > 0) {
259 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
264 } elseif ($action ==
'add' && $usercancreate) {
266 $object->socid = $socid;
267 $object->fetch_thirdparty();
272 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Supplier")),
null,
'errors');
281 if (
GETPOST(
'createmode') ==
'copy' &&
GETPOST(
'copie_supplier_proposal')) {
282 if ($object->fetch(
GETPOST(
'copie_supplier_proposal')) > 0) {
284 $object->date_livraison = $date_delivery;
285 $object->delivery_date = $date_delivery;
286 $object->shipping_method_id =
GETPOST(
'shipping_method_id',
'int');
287 $object->cond_reglement_id =
GETPOST(
'cond_reglement_id');
288 $object->mode_reglement_id =
GETPOST(
'mode_reglement_id');
289 $object->fk_account =
GETPOST(
'fk_account',
'int');
292 $object->socid =
GETPOST(
'socid');
293 $object->fk_project =
GETPOST(
'projectid',
'int');
294 $object->model_pdf =
GETPOST(
'model');
295 $object->author = $user->id;
296 $object->note =
GETPOST(
'note',
'restricthtml');
297 $object->note_private =
GETPOST(
'note',
'restricthtml');
300 setEventMessages($langs->trans(
"ErrorFailedToCopyProposal",
GETPOST(
'copie_supplier_proposal')),
null,
'errors');
304 $object->date_livraison = $date_delivery;
305 $object->delivery_date = $date_delivery;
306 $object->demand_reason_id =
GETPOST(
'demand_reason_id');
307 $object->shipping_method_id =
GETPOST(
'shipping_method_id',
'int');
308 $object->cond_reglement_id =
GETPOST(
'cond_reglement_id');
309 $object->mode_reglement_id =
GETPOST(
'mode_reglement_id');
310 $object->fk_account =
GETPOST(
'fk_account',
'int');
311 $object->fk_project =
GETPOST(
'projectid',
'int');
312 $object->model_pdf =
GETPOST(
'model');
313 $object->author = $user->id;
314 $object->note =
GETPOST(
'note',
'restricthtml');
315 $object->note_private =
GETPOST(
'note',
'restricthtml');
317 $object->origin =
GETPOST(
'origin');
318 $object->origin_id =
GETPOST(
'originid');
321 if (isModEnabled(
"multicurrency")) {
322 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
326 $ret = $extrafields->setOptionalsFromPost(
null, $object);
334 if ($origin && $originid) {
336 $element = $subelement = $origin;
337 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
339 $subelement = $regs[2];
343 if ($element ==
'order') {
344 $element = $subelement =
'commande';
346 if ($element ==
'propal') {
347 $element =
'comm/propal';
348 $subelement =
'propal';
350 if ($element ==
'contract') {
351 $element = $subelement =
'contrat';
353 if ($element ==
'inter') {
354 $element = $subelement =
'ficheinter';
356 if ($element ==
'shipping') {
357 $element = $subelement =
'expedition';
360 $object->origin = $origin;
361 $object->origin_id = $originid;
364 $object->linked_objects [$object->origin] = $object->origin_id;
365 if (is_array($_POST[
'other_linked_objects']) && !empty($_POST[
'other_linked_objects'])) {
366 $object->linked_objects = array_merge($object->linked_objects, $_POST[
'other_linked_objects']);
369 $id = $object->create($user);
373 $classname = ucfirst($subelement);
374 $srcobject =
new $classname($db);
376 dol_syslog(
"Try to find source object origin=".$object->origin.
" originid=".$object->origin_id.
" to add lines");
377 $result = $srcobject->fetch($object->origin_id);
380 $lines = $srcobject->lines;
381 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
382 $srcobject->fetch_lines();
383 $lines = $srcobject->lines;
387 $num = count($lines);
388 for ($i = 0; $i < $num; $i++) {
389 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
390 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->libelle);
393 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
396 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
401 if (method_exists($lines[$i],
'fetch_optionals')) {
402 $lines[$i]->fetch_optionals();
403 $array_options = $lines[$i]->array_options;
406 $result = $object->addline(
408 $lines[$i]->subprice,
411 $lines[$i]->localtax1_tx,
412 $lines[$i]->localtax2_tx,
413 $lines[$i]->fk_product,
414 $lines[$i]->remise_percent,
417 $lines[$i]->info_bits,
420 $lines[$i]->special_code,
422 $lines[$i]->fk_fournprice,
426 $lines[$i]->ref_supplier,
439 if ($result > 0 && $lines[$i]->product_type == 9) {
440 $fk_parent_line = $result;
445 $parameters = array(
'objFrom' => $srcobject);
446 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $object, $action);
462 $id = $object->create($user);
470 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
471 $outputlangs = $langs;
474 $newlang =
GETPOST(
'lang_id',
'aZ09');
477 $newlang = $object->thirdparty->default_lang;
479 if (!empty($newlang)) {
481 $outputlangs->setDefaultLang($newlang);
483 $model = $object->model_pdf;
485 $ret = $object->fetch($id);
486 $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
492 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
505 } elseif ($action ==
'confirm_reopen' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
511 } elseif ($action ==
'close' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
517 } elseif ($action ==
'setstatut' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
520 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"CloseAs")),
null,
'errors');
525 $object->cloture($user,
GETPOST(
'statut'),
GETPOST(
'note',
'restricthtml'));
531 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
534 $triggersendname =
'PROPOSAL_SUPPLIER_SENTBYMAIL';
535 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
536 $trackid =
'spro'.$object->id;
537 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
540 $upload_dir = $conf->supplier_proposal->dir_output;
541 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
545 if ($action ==
'modif' && $usercancreate) {
546 $object->setDraft($user);
548 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
550 $outputlangs = $langs;
553 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') : $object->thirdparty->default_lang);
554 $outputlangs->setDefaultLang($newlang);
556 $ret = $object->fetch($id);
558 $object->fetch_thirdparty();
560 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
562 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
563 if (
GETPOST(
"remise_id",
'int')) {
564 if ($object->id > 0) {
565 $result = $object->insert_discount(
GETPOST(
"remise_id",
'int'));
574 if ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') && $usercancreate) {
576 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
577 $vat_rate = str_replace(
'*',
'', $vat_rate);
578 $localtax1_rate =
get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
579 $localtax2_rate =
get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
580 foreach ($object->lines as $line) {
581 $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->fk_unit, $line->multicurrency_subprice);
583 } elseif ($action ==
'addline' && $usercancreate) {
584 $langs->load(
'errors');
589 $product_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
593 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
595 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
596 if ($prod_entry_mode ==
'free') {
599 $idprod =
GETPOST(
'idprod',
'int');
611 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef,
'alpha'),
'', 2) : 0);
612 if (empty($remise_percent)) {
617 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
618 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
620 if (is_array($extralabelsline)) {
622 foreach ($extralabelsline as $key => $value) {
623 unset($_POST[
"options_".$key]);
627 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
628 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
631 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
632 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
636 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' &&
GETPOST(
'multicurrency_price_ht') ===
'') {
637 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPrice")),
null,
'errors');
640 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
641 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Description")),
null,
'errors');
644 if (!$error && ($qty >= 0)) {
648 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
652 if ($prod_entry_mode !=
'free' && empty($error)) {
656 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
661 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
663 $res = $productsupplier->fetch($idprod);
666 if (!empty($conf->global->SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER)) {
668 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
669 if ($productsupplier->fourn_socid != $socid) {
670 $productsupplier->ref_supplier =
'';
673 $fksoctosearch = $object->thirdparty->id;
674 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
676 } elseif (
GETPOST(
'idprodfournprice',
'alpha') > 0) {
679 $idprod = $productsupplier->get_buyprice(
GETPOST(
'idprodfournprice',
'alpha'), $qtytosearch);
680 $res = $productsupplier->fetch($idprod);
684 $label = $productsupplier->label;
687 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
688 $outputlangs = $langs;
690 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
691 $newlang =
GETPOST(
'lang_id',
'aZ09');
693 if (empty($newlang)) {
694 $newlang = $object->thirdparty->default_lang;
696 if (!empty($newlang)) {
698 $outputlangs->setDefaultLang($newlang);
700 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->
description;
702 $desc = $productsupplier->description;
705 if (!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) {
706 $desc = $productsupplier->desc_supplier;
710 if (trim($product_desc) == trim($desc) && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) {
714 if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) {
715 $desc = $product_desc;
717 if (!empty($product_desc) && trim($product_desc) != trim($desc)) {
718 $desc =
dol_concatdesc($desc, $product_desc,
'', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
721 $ref_supplier = $productsupplier->ref_supplier;
725 if (!GETPOSTISSET(
'tva_tx')) {
726 $tva_tx =
get_default_tva($object->thirdparty, $mysoc, $productsupplier->id,
GETPOST(
'idprodfournprice',
'alpha'));
727 $tva_npr =
get_default_npr($object->thirdparty, $mysoc, $productsupplier->id,
GETPOST(
'idprodfournprice',
'alpha'));
729 if (empty($tva_tx)) {
732 $localtax1_tx =
get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr);
733 $localtax2_tx =
get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr);
735 $type = $productsupplier->type;
736 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
737 $price_base_type =
'HT';
739 $pu_devise =
price2num($price_ht_devise,
'CU');
740 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
741 $price_base_type =
'TTC';
743 $pu_devise =
price2num($price_ttc_devise,
'CU');
745 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
746 if (empty($object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code != $object->multicurrency_code)) {
747 $pu = $productsupplier->fourn_pu;
750 $pu = $productsupplier->fourn_pu;
751 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
760 $fournprice = (is_numeric(
GETPOST(
'idprodfournprice',
'alpha')) ?
GETPOST(
'idprodfournprice',
'alpha') : -1);
763 $result = $object->addline(
765 ($price_base_type ==
'HT' ? $pu : 0),
770 $productsupplier->id,
773 ($price_base_type ==
'TTC' ? $pu : 0),
776 min($rank, count($object->lines) + 1),
784 $productsupplier->fk_unit,
800 if ($idprod == -99 || $idprod == 0) {
803 $langs->load(
"errors");
804 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")).
' '.$langs->trans(
"or").
' '.$langs->trans(
"NoPriceDefinedForThisSupplier"),
null,
'errors');
809 $langs->load(
"errors");
810 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
812 } elseif ((
GETPOST(
'price_ht') !==
'' ||
GETPOST(
'price_ttc') !==
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') && empty($error)) {
816 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
817 $tva_tx = str_replace(
'*',
'', $tva_tx);
818 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
819 $desc = $product_desc;
822 $fk_unit =
GETPOST(
'units',
'alpha');
824 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
829 $localtax1_tx =
get_localtax($tva_tx, 1, $mysoc, $object->thirdparty);
830 $localtax2_tx =
get_localtax($tva_tx, 2, $mysoc, $object->thirdparty);
832 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
836 $pu_ht =
price2num($pu_ttc / (1 + ($tva_tx / 100)),
'MU');
838 $price_base_type =
'HT';
839 $pu_ht_devise =
price2num($price_ht_devise,
'CU');
842 $result = $object->addline(
871 if (!$error && $result > 0) {
874 $ret = $object->fetch($object->id);
877 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
878 $outputlangs = $langs;
881 $newlang =
GETPOST(
'lang_id',
'aZ09');
884 $newlang = $object->thirdparty->default_lang;
886 if (!empty($newlang)) {
888 $outputlangs->setDefaultLang($newlang);
890 $model = $object->model_pdf;
891 $ret = $object->fetch($id);
893 $object->fetch_thirdparty();
896 $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
902 unset($_POST[
'prod_entry_mode']);
904 unset($_POST[
'qty']);
905 unset($_POST[
'type']);
906 unset($_POST[
'remise_percent']);
908 unset($_POST[
'price_ht']);
909 unset($_POST[
'multicurrency_price_ht']);
910 unset($_POST[
'price_ttc']);
911 unset($_POST[
'fourn_ref']);
912 unset($_POST[
'tva_tx']);
913 unset($_POST[
'label']);
914 unset($_POST[
'product_ref']);
915 unset($_POST[
'product_label']);
916 unset($_POST[
'product_desc']);
917 unset($_POST[
'fournprice']);
918 unset($_POST[
'buying_price']);
919 unset($localtax1_tx);
920 unset($localtax2_tx);
921 unset($_POST[
'np_marginRate']);
922 unset($_POST[
'np_markRate']);
923 unset($_POST[
'dp_desc']);
924 unset($_POST[
'idprodfournprice']);
925 unset($_POST[
'units']);
927 unset($_POST[
'idprod']);
929 unset($_POST[
'date_starthour']);
930 unset($_POST[
'date_startmin']);
931 unset($_POST[
'date_startsec']);
932 unset($_POST[
'date_startday']);
933 unset($_POST[
'date_startmonth']);
934 unset($_POST[
'date_startyear']);
935 unset($_POST[
'date_endhour']);
936 unset($_POST[
'date_endmin']);
937 unset($_POST[
'date_endsec']);
938 unset($_POST[
'date_endday']);
939 unset($_POST[
'date_endmonth']);
940 unset($_POST[
'date_endyear']);
947 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save') == $langs->trans(
"Save")) {
953 if (preg_match(
'/\*/', $vat_rate)) {
961 $vat_rate = str_replace(
'*',
'', $vat_rate);
962 $localtax1_rate =
get_localtax($vat_rate, 1, $mysoc, $object->thirdparty);
963 $localtax2_rate =
get_localtax($vat_rate, 2, $mysoc, $object->thirdparty);
965 if (
GETPOST(
'price_ht') !=
'') {
966 $price_base_type =
'HT';
970 $vatratecleaned = $vat_rate;
971 if (preg_match(
'/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) {
972 $vatratecleaned = trim($reg[1]);
973 $vatratecode = $reg[2];
977 $ht = (float) $ttc / (1 + ((
float) $vatratecleaned / 100));
978 $price_base_type =
'HT';
984 $fournprice = (
GETPOST(
'fournprice') ?
GETPOST(
'fournprice') :
'');
985 $buyingprice = (
GETPOST(
'buying_price') !=
'' ?
GETPOST(
'buying_price') :
'');
988 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
989 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
991 if (is_array($extralabelsline)) {
992 foreach ($extralabelsline as $key => $value) {
993 unset($_POST[
"options_".$key]);
998 $special_code =
GETPOST(
'special_code');
1004 $productid =
GETPOST(
'productid',
'int');
1005 if (!empty($productid)) {
1007 if (!empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) {
1008 if ($productid > 0 && $productsupplier->get_buyprice(0,
price2num(
GETPOST(
'qty')), $productid,
'none',
GETPOST(
'socid',
'int')) < 0) {
1009 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1014 $res = $product->fetch($productid);
1016 $type = $product->type;
1018 $price_min = $product->price_min;
1019 if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) {
1020 $price_min = $product->multiprices_min [$object->thirdparty->price_level];
1026 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1030 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1038 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1041 $result = $object->updateline(
1053 GETPOST(
'fk_parent_line',
'int'),
1068 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1070 $outputlangs = $langs;
1072 $outputlangs =
new Translate(
"", $conf);
1073 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') : $object->thirdparty->default_lang);
1074 $outputlangs->setDefaultLang($newlang);
1076 $ret = $object->fetch($id);
1077 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1080 unset($_POST[
'qty']);
1081 unset($_POST[
'type']);
1082 unset($_POST[
'productid']);
1083 unset($_POST[
'remise_percent']);
1084 unset($_POST[
'price_ht']);
1085 unset($_POST[
'multicurrency_price_ht']);
1086 unset($_POST[
'price_ttc']);
1087 unset($_POST[
'tva_tx']);
1088 unset($_POST[
'product_ref']);
1089 unset($_POST[
'product_label']);
1090 unset($_POST[
'product_desc']);
1091 unset($_POST[
'fournprice']);
1092 unset($_POST[
'buying_price']);
1094 unset($_POST[
'date_starthour']);
1095 unset($_POST[
'date_startmin']);
1096 unset($_POST[
'date_startsec']);
1097 unset($_POST[
'date_startday']);
1098 unset($_POST[
'date_startmonth']);
1099 unset($_POST[
'date_startyear']);
1100 unset($_POST[
'date_endhour']);
1101 unset($_POST[
'date_endmin']);
1102 unset($_POST[
'date_endsec']);
1103 unset($_POST[
'date_endday']);
1104 unset($_POST[
'date_endmonth']);
1105 unset($_POST[
'date_endyear']);
1112 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha') == $langs->trans(
"Cancel")) {
1113 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
1115 } elseif ($action ==
'classin' && $usercancreate) {
1117 $object->setProject(
GETPOST(
'projectid'),
'int');
1118 } elseif ($action ==
'setavailability' && $usercancreate) {
1120 $result = $object->availability(
GETPOST(
'availability_id'));
1121 } elseif ($action ==
'setconditions' && $usercancreate) {
1123 $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_id',
'int'));
1124 } elseif ($action ==
'setremisepercent' && $usercancreate) {
1125 $result = $object->set_remise_percent($user,
price2num(
GETPOST(
'remise_percent'),
'', 2));
1126 } elseif ($action ==
'setremiseabsolue' && $usercancreate) {
1127 $result = $object->set_remise_absolue($user,
price2num(
GETPOST(
'remise_absolue'),
'MU', 2));
1128 } elseif ($action ==
'setmode' && $usercancreate) {
1130 $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_id',
'int'));
1131 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
1133 $result = $object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
1134 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
1136 $result = $object->setMulticurrencyRate(
price2num(
GETPOST(
'multicurrency_tx')),
GETPOST(
'calculation_mode',
'int'));
1137 } elseif ($action ==
'update_extras') {
1141 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
1147 $result = $object->insertExtraFields(
'PROPOSAL_SUPPLIER_MODIFY');
1155 $action =
'edit_extras';
1165$title = $object->ref.
" - ".$langs->trans(
'Card');
1166if ($action ==
'create') {
1167 $title = $langs->trans(
"SupplierProposalNew");
1169$help_url =
'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur';
1173$form =
new Form($db);
1177$companystatic =
new Societe($db);
1178if (isModEnabled(
'project')) {
1185if ($action ==
'create') {
1186 $currency_code = $conf->currency;
1188 print
load_fiche_titre($langs->trans(
"SupplierProposalNew"),
'',
'supplier_proposal');
1192 $res = $soc->fetch($socid);
1196 if (!empty($origin) && !empty($originid)) {
1197 $element = $subelement =
GETPOST(
'origin');
1198 if (preg_match(
'/^([^_]+)_([^_]+)/i',
GETPOST(
'origin'), $regs)) {
1199 $element = $regs[1];
1200 $subelement = $regs[2];
1204 if ($element ==
'order' || $element ==
'commande') {
1205 $element = $subelement =
'commande';
1207 if ($element ==
'propal') {
1208 $element =
'comm/propal';
1209 $subelement =
'propal';
1214 $classname = ucfirst($subelement);
1215 $objectsrc =
new $classname($db);
1216 $objectsrc->fetch($originid);
1217 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1218 $objectsrc->fetch_lines();
1220 $objectsrc->fetch_thirdparty();
1222 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
1223 $soc = $objectsrc->thirdparty;
1225 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1226 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1227 $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_supplier_percent) ? $soc->remise_supplier_percent : 0));
1228 $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0));
1231 $objectsrc->fetch_optionals();
1232 $object->array_options = $objectsrc->array_options;
1234 if (isModEnabled(
"multicurrency")) {
1235 if (!empty($objectsrc->multicurrency_code)) {
1236 $currency_code = $objectsrc->multicurrency_code;
1238 if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) {
1239 $currency_tx = $objectsrc->multicurrency_tx;
1243 $cond_reglement_id = $soc->cond_reglement_supplier_id;
1244 $mode_reglement_id = $soc->mode_reglement_supplier_id;
1245 if (isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
1246 $currency_code = $soc->multicurrency_code;
1252 print
'<form name="addprop" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1253 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1254 print
'<input type="hidden" name="action" value="add">';
1255 if ($origin !=
'project' && $originid) {
1256 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1257 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1259 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1263 print
'<table class="border centpercent">';
1266 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td colspan="2">'.$langs->trans(
"Draft").
'</td></tr>';
1270 print
'<td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
1272 print
'<td colspan="2">';
1273 print $soc->getNomUrl(1,
'supplier');
1274 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1277 print
'<td colspan="2">';
1278 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
1279 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company((empty($socid) ?
'' : $socid),
'socid', $filter,
'SelectThirdParty', 1, 0, null, 0,
'minwidth175 maxwidth500 widthcentpercentminusxx');
1281 if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) {
1283 $(document).ready(function() {
1284 $("#socid").change(function() {
1285 console.log("We have changed the company - Reload page");
1287 $("input[name=action]").val("create");
1288 $("form[name=add]").submit();
1293 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>';
1300 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
1302 $absolute_discount = $soc->getAvailableDiscounts(
'',
'', 0, 1);
1306 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
1307 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1313 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td colspan="2">';
1314 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
1315 print $form->getSelectConditionsPaiements(
GETPOST(
'cond_reglement_id') > 0 ?
GETPOST(
'cond_reglement_id') : $cond_reglement_id,
'cond_reglement_id', -1, 1);
1319 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td colspan="2">';
1320 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1321 $form->select_types_paiements(
GETPOST(
'mode_reglement_id') > 0 ?
GETPOST(
'mode_reglement_id') : $mode_reglement_id,
'mode_reglement_id');
1325 if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && isModEnabled(
"banque")) {
1326 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td colspan="2">';
1327 $form->select_comptes(
GETPOST(
'fk_account') > 0 ?
GETPOST(
'fk_account',
'int') : $fk_account,
'fk_account', 0,
'', 1);
1332 if (isModEnabled(
"expedition")) {
1333 print
'<tr><td>'.$langs->trans(
'SendingMethod').
'</td><td colspan="2">';
1334 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1335 $form->selectShippingMethod(
GETPOST(
'shipping_method_id') > 0 ?
GETPOST(
'shipping_method_id',
'int') :
"",
'shipping_method_id',
'', 1);
1340 print
'<tr><td>'.$langs->trans(
"DeliveryDate").
'</td>';
1341 print
'<td colspan="2">';
1342 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1344 if (!empty($conf->global->DATE_LIVRAISON_WEEK_DELAY)) {
1345 $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60);
1346 $syear = date(
"Y", $tmpdte);
1347 $smonth = date(
"m", $tmpdte);
1348 $sday = date(
"d", $tmpdte);
1349 print $form->selectDate($syear.
"-".$smonth.
"-".$sday,
'liv_',
'',
'',
'',
"addask");
1351 print $form->selectDate($datedelivery ? $datedelivery : -1,
'liv_',
'',
'',
'',
"addask", 1, 1);
1358 print
'<td>'.$langs->trans(
"DefaultModel").
'</td>';
1359 print
'<td colspan="2">';
1360 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1362 $preselected = (!empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT) ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT : $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF);
1363 print $form->selectarray(
'model', $list, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1367 if (isModEnabled(
'project')) {
1368 $langs->load(
"projects");
1372 if ($origin ==
'project') {
1373 $projectid = ($originid ? $originid : 0);
1377 print
'<td>'.$langs->trans(
"Project").
'</td><td colspan="2">';
1378 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');
1379 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>';
1386 if (isModEnabled(
"multicurrency")) {
1388 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
1389 print
'<td colspan="3" class="maxwidthonsmartphone">';
1390 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
1391 print $form->selectMultiCurrency($currency_code,
'multicurrency_code');
1396 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' => 3);
1397 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1398 print $hookmanager->resPrint;
1399 if (empty($reshook)) {
1400 print $object->showOptionals($extrafields,
'create', $parameters);
1405 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1407 if ($origin ==
'contrat') {
1409 $objectsrc->remise_absolue = $remise_absolue;
1410 $objectsrc->remise_percent = $remise_percent;
1411 $objectsrc->update_price(1,
'auto', 1);
1414 print
"\n<!-- ".$classname.
" info -->";
1416 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
1417 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
1418 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
1419 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
1420 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
1422 print
'<tr><td>'.$langs->trans(
'CommRequest').
'</td><td colspan="2">'.$objectsrc->getNomUrl(1).
'</td></tr>';
1423 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td colspan="2">'.
price($objectsrc->total_ht).
'</td></tr>';
1424 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td colspan="2">'.
price($objectsrc->total_tva).
"</td></tr>";
1425 if ($mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
1426 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax1).
"</td></tr>";
1429 if ($mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
1430 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td colspan="2">'.
price($objectsrc->total_localtax2).
"</td></tr>";
1432 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td colspan="2">'.
price($objectsrc->total_ttc).
"</td></tr>";
1434 if (isModEnabled(
"multicurrency")) {
1435 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
1436 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
1437 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td colspan="2">'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
1448 if (empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) {
1449 print
'<input type="hidden" name="createmode" value="empty">';
1452 if (!empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) {
1453 print
'<br><table>';
1457 print
'<td><input type="radio" name="createmode" value="copy"></td>';
1458 print
'<td>'.$langs->trans(
"CopyAskFrom").
' </td>';
1460 $liste_ask = array();
1461 $liste_ask [0] =
'';
1463 $sql =
"SELECT p.rowid as id, p.ref, s.nom";
1464 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal p";
1465 $sql .=
", ".MAIN_DB_PREFIX.
"societe s";
1466 $sql .=
" WHERE s.rowid = p.fk_soc";
1467 $sql .=
" AND p.entityy IN (".getEntity(
'supplier_proposal').
")";
1468 $sql .=
" AND p.fk_statut <> ".SupplierProposal::STATUS_DRAFT;
1469 $sql .=
" ORDER BY Id";
1471 $resql = $db->query($sql);
1473 $num = $db->num_rows($resql);
1476 $row = $db->fetch_row($resql);
1477 $askPriceSupplierRefAndSocName = $row[1].
" - ".$row[2];
1478 $liste_ask[$row[0]] = $askPriceSupplierRefAndSocName;
1481 print $form->selectarray(
"copie_supplier_proposal", $liste_ask, 0);
1487 print
'<tr><td class="tdtop"><input type="radio" name="createmode" value="empty" checked></td>';
1488 print
'<td valign="top" colspan="2">'.$langs->trans(
"CreateEmptyAsk").
'</td></tr>';
1491 if (!empty($conf->global->SUPPLIER_PROPOSAL_CLONE_ON_CREATE_PAGE)) {
1497 print $form->buttonsSaveCancel(
"CreateDraft");
1503 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1506 $title = $langs->trans(
'ProductsAndServices');
1509 print
'<div class="div-table-responsive-no-min">';
1510 print
'<table class="noborder centpercent">';
1512 $objectsrc->printOriginLinesList();
1523 $soc->fetch($object->socid);
1525 $head = supplier_proposal_prepare_head($object);
1526 print
dol_get_fiche_head($head,
'comm', $langs->trans(
'CommRequest'), -1,
'supplier_proposal');
1531 if ($action ==
'clone') {
1532 $filter =
'(s.fournisseur:=:1)';
1534 $formquestion = array(
1542 'label' => $langs->trans(
"SelectThirdParty"),
1543 'value' => $form->select_company(
GETPOST(
'socid',
'int'),
'socid', $filter))
1546 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
1547 } elseif ($action ==
'delete') {
1549 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteAsk'), $langs->trans(
'ConfirmDeleteAsk', $object->ref),
'confirm_delete',
'', 0, 1);
1550 } elseif ($action ==
'reopen') {
1552 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ReOpen'), $langs->trans(
'ConfirmReOpenAsk', $object->ref),
'confirm_reopen',
'', 0, 1);
1553 } elseif ($action ==
'ask_deleteline') {
1555 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
1556 } elseif ($action ==
'validate') {
1561 $ref = substr($object->ref, 1, 4);
1562 if ($ref ==
'PROV') {
1563 $numref = $object->getNextNumRef($soc);
1564 if (empty($numref)) {
1569 $numref = $object->ref;
1572 $text = $langs->trans(
'ConfirmValidateAsk', $numref);
1573 if (isModEnabled(
'notification')) {
1574 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
1575 $notify =
new Notify($db);
1577 $text .= $notify->confirmMessage(
'PROPOSAL_SUPPLIER_VALIDATE', $object->socid, $object);
1581 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ValidateAsk'), $text,
'confirm_validate',
'', 0, 1);
1586 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
1587 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1588 if (empty($reshook)) {
1589 $formconfirm .= $hookmanager->resPrint;
1590 } elseif ($reshook > 0) {
1591 $formconfirm = $hookmanager->resPrint;
1599 $linkback =
'<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1602 $morehtmlref =
'<div class="refidno">';
1607 $morehtmlref .= $object->thirdparty->getNomUrl(1,
'supplier');
1608 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
1609 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?socid='.$object->thirdparty->id.
'&search_societe='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherProposals").
'</a>)';
1612 if (isModEnabled(
'project')) {
1613 $langs->load(
"projects");
1614 $morehtmlref .=
'<br>';
1615 if ($usercancreate) {
1616 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
1617 if ($action !=
'classify') {
1618 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
1620 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
1622 if (!empty($object->fk_project)) {
1624 $proj->fetch($object->fk_project);
1625 $morehtmlref .= $proj->getNomUrl(1);
1627 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
1632 $morehtmlref .=
'</div>';
1635 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
1638 print
'<div class="fichecenter">';
1639 print
'<div class="fichehalfleft">';
1640 print
'<div class="underbanner clearboth"></div>';
1642 print
'<table class="border tableforfield centpercent">';
1645 if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
1646 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
1647 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
1649 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
1650 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
1653 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td>';
1655 $absolute_discount = $soc->getAvailableDiscounts(
'', $filterabsolutediscount, 0, 1);
1656 $absolute_creditnote = $soc->getAvailableDiscounts(
'', $filtercreditnote, 0, 1);
1657 $absolute_discount =
price2num($absolute_discount,
'MT');
1658 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
1662 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?id='.$object->id);
1663 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1668 print
'<tr><td class="titlefield">';
1669 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1670 print $langs->trans(
'PaymentConditionsShort');
1673 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>';
1675 print
'</tr></table>';
1676 print
'</td><td class="valuefield">';
1677 if ($action ==
'editconditions') {
1678 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'cond_reglement_id', 1);
1680 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'none', 1);
1686 $langs->load(
'deliveries');
1688 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1689 print $langs->trans(
'DeliveryDate');
1692 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>';
1694 print
'</tr></table>';
1695 print
'</td><td class="valuefield">';
1696 if ($action ==
'editdate_livraison') {
1697 print
'<form name="editdate_livraison" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post" class="formconsumeproduce">';
1698 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1699 print
'<input type="hidden" name="action" value="setdate_livraison">';
1700 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1701 print $form->selectDate($object->delivery_date,
'liv_',
'',
'',
'',
"editdate_livraison");
1702 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
1713 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1714 print $langs->trans(
'PaymentMode');
1717 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>';
1719 print
'</tr></table>';
1720 print
'</td><td class="valuefield">';
1721 if ($action ==
'editmode') {
1722 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
1724 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'none');
1729 if (isModEnabled(
"multicurrency")) {
1733 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1734 print $form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0);
1736 if ($action !=
'editmulticurrencycode' && $object->statut == $object::STATUS_VALIDATED) {
1737 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>';
1739 print
'</tr></table>';
1740 print
'</td><td class="valuefield">';
1741 if ($action ==
'editmulticurrencycode') {
1742 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_code,
'multicurrency_code');
1744 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_code,
'none');
1749 if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) {
1752 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1753 print $form->editfieldkey(
'CurrencyRate',
'multicurrency_tx',
'', $object, 0);
1755 if ($action !=
'editmulticurrencyrate' && $object->statut == $object::STATUS_VALIDATED && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
1756 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>';
1758 print
'</tr></table>';
1759 print
'</td><td class="valuefield">';
1760 if ($action ==
'editmulticurrencyrate' || $action ==
'actualizemulticurrencyrate') {
1761 if ($action ==
'actualizemulticurrencyrate') {
1764 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx,
'multicurrency_tx', $object->multicurrency_code);
1766 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx,
'none', $object->multicurrency_code);
1767 if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
1768 print
'<div class="inline-block"> ';
1769 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=actualizemulticurrencyrate">'.$langs->trans(
"ActualizeCurrency").
'</a>';
1790 if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && isModEnabled(
"banque")) {
1793 print
'<table width="100%" class="nobordernopadding"><tr><td>';
1794 print $langs->trans(
'BankAccount');
1796 if ($action !=
'editbankaccount' && $usercancreate) {
1797 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>';
1799 print
'</tr></table>';
1800 print
'</td><td class="valuefield">';
1801 if ($action ==
'editbankaccount') {
1802 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'fk_account', 1);
1804 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'none');
1811 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1816 print
'<div class="fichehalfright">';
1817 print
'<div class="underbanner clearboth"></div>';
1819 print
'<table class="border tableforfield centpercent">';
1823 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
1824 print
'<td class="nowrap amountcard right">' .
price($object->total_ht,
'', $langs, 0, -1, -1, $conf->currency) .
'</td>';
1825 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
1827 print
'<td class="nowrap amountcard right">' .
price($object->multicurrency_total_ht,
'', $langs, 0, -1, -1, $object->multicurrency_code) .
'</td>';
1833 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
1834 print
'<td class="nowrap amountcard right">' .
price($object->total_tva,
'', $langs, 0, -1, -1, $conf->currency) .
'</td>';
1835 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
1837 print
'<td class="nowrap amountcard right">' .
price($object->multicurrency_total_tva,
'', $langs, 0, -1, -1, $object->multicurrency_code) .
'</td>';
1842 if ($mysoc->localtax1_assuj ==
"1" || $object->total_localtax1 != 0) {
1844 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
1845 print
'<td class="nowrap amountcard right">' .
price($object->total_localtax1,
'', $langs, 0, -1, -1, $conf->currency) .
'</td>';
1846 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
1847 print
'<td class="nowrap amountcard right">' .
price($object->total_localtax1,
'', $langs, 0, -1, -1, $object->multicurrency_code) .
'</td>';
1851 if ($mysoc->localtax2_assuj ==
"1" || $object->total_localtax2 != 0) {
1853 print
'<td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
1854 print
'<td class="nowrap amountcard right">' .
price($object->total_localtax2,
'', $langs, 0, -1, -1, $conf->currency) .
'</td>';
1855 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
1856 print
'<td class="nowrap amountcard right">' .
price($object->total_localtax2,
'', $langs, 0, -1, -1, $object->multicurrency_code) .
'</td>';
1864 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
1865 print
'<td class="nowrap amountcard right">' .
price($object->total_ttc,
'', $langs, 0, -1, -1, $conf->currency) .
'</td>';
1866 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
1868 print
'<td class="nowrap amountcard right">' .
price($object->multicurrency_total_ttc,
'', $langs, 0, -1, -1, $object->multicurrency_code) .
'</td>';
1882 print
'<div class="clearboth"></div><br>';
1884 if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
1885 $blocname =
'contacts';
1886 $title = $langs->trans(
'ContactsAddresses');
1887 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
1890 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
1891 $blocname =
'notes';
1892 $title = $langs->trans(
'Notes');
1893 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
1901 $result = $object->getLinesArray();
1903 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action !=
'editline') ?
'#add' :
'').
'" method="POST">
1904 <input type="hidden" name="token" value="' . newToken().
'">
1905 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
1906 <input type="hidden" name="mode" value="">
1907 <input type="hidden" name="id" value="' . $object->id.
'">
1908 <input type="hidden" name="backtopage" value="'.$backtopage.
'">
1912 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
1915 print
'<div class="div-table-responsive-no-min">';
1916 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
1919 global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax;
1920 $forceall = 1; $dateSelector = 0; $inputalsopricewithtax = 1;
1921 $senderissupplier = 2;
1922 if (!empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) {
1923 $senderissupplier = 1;
1926 if (!empty($object->lines)) {
1927 $object->printObjectLines($action, $soc, $mysoc, $lineid, $dateSelector);
1932 if ($action !=
'editline') {
1935 $parameters = array();
1936 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
1937 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1938 if (empty($reshook))
1939 $object->formAddObjectLine($dateSelector, $soc, $mysoc);
1949 if ($action ==
'statut') {
1951 $form_close =
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST" id="formacceptrefuse" class="formconsumeproduce paddingbottom paddingleft paddingright">';
1952 $form_close .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1953 $form_close .=
'<input type="hidden" name="action" value="setstatut">';
1955 if (!empty($conf->global->SUPPLIER_PROPOSAL_UPDATE_PRICE_ON_SUPPlIER_PROPOSAL)) {
1956 $form_close .=
'<p class="notice">'.$langs->trans(
'SupplierProposalRefFournNotice').
'</p>';
1958 $form_close .=
'<table class="border centpercent marginleftonly marginrightonly">';
1959 $form_close .=
'<tr><td>'.$langs->trans(
"CloseAs").
'</td><td class="left">';
1960 $form_close .=
'<select id="statut" name="statut" class="flat">';
1961 $form_close .=
'<option value="0"> </option>';
1962 $form_close .=
'<option value="2">'.$langs->trans(
'SupplierProposalStatusSigned').
'</option>';
1963 $form_close .=
'<option value="3">'.$langs->trans(
'SupplierProposalStatusNotSigned').
'</option>';
1964 $form_close .=
'</select>';
1965 $form_close .=
'</td></tr>';
1966 $form_close .=
'<tr><td class="left">'.$langs->trans(
'Note').
'</td><td class="left"><textarea cols="70" rows="'.ROWS_3.
'" wrap="soft" name="note">';
1967 $form_close .= $object->note_private;
1968 $form_close .=
'</textarea></td></tr>';
1969 $form_close .=
'</table>';
1970 $form_close .= $form->buttonsSaveCancel();
1971 $form_close .=
'<a id="acceptedrefused"> </a>';
1972 $form_close .=
'</form>';
1980 if ($action !=
'presend') {
1981 print
'<div class="tabsAction">';
1983 $parameters = array();
1984 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1986 if (empty($reshook)) {
1987 if ($action !=
'statut' && $action !=
'editline') {
1990 if (count($object->lines) > 0) {
1991 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=validate">'.$langs->trans(
'Validate').
'</a></div>';
1998 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>';
2003 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').
'"';
2004 print
'>'.$langs->trans(
'ReOpen').
'</a></div>';
2008 if (empty($user->socid)) {
2011 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>';
2013 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
'SendMail').
'</a></div>';
2020 if ($usercancreateorder) {
2021 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>';
2027 print
'<div class="inline-block divButAction"><a class="butAction reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&token='.newToken().
'&action=statut'.(empty($conf->global->MAIN_JUMP_TAG) ?
'' :
'#acceptedrefused').
'"';
2028 print
'>'.$langs->trans(
'SetAcceptedRefused').
'</a></div>';
2033 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&token='.newToken().
'&action=close'.(empty($conf->global->MAIN_JUMP_TAG) ?
'' :
'#close').
'"';
2034 print
'>'.$langs->trans(
'Close').
'</a></div>';
2038 if ($usercancreate) {
2039 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 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.newToken(),
'delete', (($object->statut ==
SupplierProposal::STATUS_DRAFT && $usercancreate) || $usercandelete));
2050 if ($action !=
'presend') {
2051 print
'<div class="fichecenter"><div class="fichehalfleft">';
2058 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2059 $genallowed = $usercanread;
2060 $delallowed = $usercancreate;
2062 print $formfile->showdocuments(
'supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'', 0,
'', $soc->default_lang);
2066 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'supplier_proposal'));
2067 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
2070 print
'</div><div class="fichehalfright">';
2073 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2075 $somethingshown =
$formactions->showactions($object,
'supplier_proposal', $socid, 1);
2077 print
'</div></div>';
2081 if (
GETPOST(
'modelselected')) {
2082 $action =
'presend';
2086 $modelmail =
'supplier_proposal_send';
2087 $defaulttopic =
'SendAskRef';
2088 $diroutput = $conf->supplier_proposal->dir_output;
2089 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO';
2090 $trackid =
'spro'.$object->id;
2092 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
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(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static getIdAndTxFromCode($dbs, $code, $date_document='')
Get id and rate of currency from code.
Class to manage 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_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.
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...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier 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...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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.