47require
'../../main.inc.php';
57require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
58require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formother.class.php';
59require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formfile.class.php';
60require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formpropal.class.php';
61require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmargin.class.php';
62require_once DOL_DOCUMENT_ROOT .
'/comm/propal/class/propal.class.php';
63require_once DOL_DOCUMENT_ROOT .
'/comm/action/class/actioncomm.class.php';
64require_once DOL_DOCUMENT_ROOT .
'/core/modules/propale/modules_propale.php';
65require_once DOL_DOCUMENT_ROOT .
'/core/lib/propal.lib.php';
66require_once DOL_DOCUMENT_ROOT .
'/core/lib/functions2.lib.php';
67require_once DOL_DOCUMENT_ROOT .
'/core/class/extrafields.class.php';
68require_once DOL_DOCUMENT_ROOT .
'/core/class/doleditor.class.php';
70 require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
71 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
75 require_once DOL_DOCUMENT_ROOT .
'/variants/class/ProductCombination.class.php';
80$langs->loadLangs(array(
'companies',
'propal',
'compta',
'bills',
'orders',
'products',
'sendings',
'other'));
82 $langs->load(
'incoterm');
85 $langs->load(
'margins');
90$array_options = array();
95$action =
GETPOST(
'action',
'aZ09');
96$cancel =
GETPOST(
'cancel',
'alpha');
97$origin =
GETPOST(
'origin',
'alpha');
100$confirm =
GETPOST(
'confirm',
'alpha');
101$backtopage =
GETPOST(
'backtopage',
'alpha');
102$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
116$extrafields->fetch_name_optionals_label(
$object->table_element);
119if ($id > 0 || !empty($ref)) {
120 $ret =
$object->fetch($id, $ref);
122 $ret =
$object->fetch_thirdparty();
123 if ($ret > 0 && isset(
$object->fk_project)) {
124 $ret =
$object->fetchProject();
134$hookmanager->initHooks(array(
'propalcard',
'globalcard'));
136$usercanread = $user->hasRight(
"propal",
"lire");
137$usercancreate = $user->hasRight(
"propal",
"creer");
138$usercandelete = $user->hasRight(
"propal",
"supprimer");
140$usercanclose = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'propal',
'propal_advance',
'close')));
141$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'propal',
'propal_advance',
'validate')));
144$usermustrespectpricemin = ((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'produit',
'ignore_price_min_advance')) || !
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS'));
145$usercancreateorder = ($user->hasRight(
'commande',
'creer') == 1);
146$usercancreateinvoice = ($user->hasRight(
'facture',
'creer') == 1);
147$usercancreatecontract = ($user->hasRight(
'contrat',
'creer') == 1);
148$usercancreateintervention = ($user->hasRight(
'ficheinter',
'creer') == 1);
149$usercancreatepurchaseorder = ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'));
150$usercanreopen = ((!
getDolGlobalBool(
'MAIN_USE_ADVANCED_PERMS') && $usercanclose) || (
getDolGlobalBool(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'propal',
'propal_advance',
'reopen')));
152 $usercanreopen =
false;
155$permissiontoadd = $usercancreate;
156$permissionnote = $usercancreate;
157$permissiondellink = $usercancreate;
158$permissiontoedit = $usercancreate;
159$permissiontoeditextra = $permissiontoadd;
160if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
162 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
165$price_base_type =
null;
166$shipping_method_id =
null;
170if (!empty($user->socid)) {
171 $socid = $user->socid;
180$parameters = array(
'socid' => $socid);
181$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
183 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
185if (empty($reshook)) {
186 $backurlforlist =
dolBuildUrl(DOL_URL_ROOT .
'/comm/propal/list.php');
188 if (empty($backtopage) || ($cancel && empty($id))) {
189 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
190 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
191 $backtopage = $backurlforlist;
193 $backtopage =
dolBuildUrl(DOL_URL_ROOT .
'/comm/propal/card.php', [
'id' => ((!empty($id) && $id > 0) ? $id :
'__ID__')]);
199 if (!empty($backtopageforcancel)) {
200 header(
"Location: " . $backtopageforcancel);
202 } elseif (!empty($backtopage)) {
203 header(
"Location: " . $backtopage);
209 include DOL_DOCUMENT_ROOT .
'/core/actions_setnotes.inc.php';
211 include DOL_DOCUMENT_ROOT .
'/core/actions_dellink.inc.php';
213 include DOL_DOCUMENT_ROOT .
'/core/actions_lineupdown.inc.php';
216 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
218 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'IdThirdParty')),
null,
'errors');
223 '@phan-var-force Propal $objectutil';
235 $date_delivery_old = $objectutil->delivery_date;
236 if (!empty($date_delivery_old) && !empty($date_delivery)) {
247 $difference = $date_delivery - $old_date_delivery;
248 if ($difference != 0) {
249 $objectutil->delivery_date = $date_delivery;
250 foreach ($objectutil->lines as $line) {
251 if (isset($line->date_start)) {
252 $line->date_start += $difference;
254 if (isset($line->date_end)) {
255 $line->date_end += $difference;
262 $result = $objectutil->createFromClone($user, $socid, (
GETPOSTISSET(
'entity') ?
GETPOSTINT(
'entity') : null), (
GETPOST(
'update_prices') ==
'on'), (
GETPOST(
'update_desc') ==
'on'));
264 $warningMsgLineList = array();
266 foreach ($objectutil->lines as $line) {
267 if (!is_object($line->product)) {
268 $line->fetch_product();
270 if (is_object($line->product) && $line->product->id > 0) {
271 if (empty($line->product->status)) {
272 $warningMsgLineList[$line->id] = $langs->trans(
'WarningLineProductNotToSell', $line->product->ref);
276 if (!empty($warningMsgLineList)) {
277 setEventMessages(
'', $warningMsgLineList,
'warnings');
280 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
'?id=' . $result);
283 if (count($objectutil->errors) > 0) {
284 setEventMessages($objectutil->error, $objectutil->errors,
'errors');
290 } elseif ($action ==
'confirm_cancel' && $confirm ==
'yes' && $usercanclose) {
292 $result =
$object->setCancel($user);
297 $langs->load(
"errors");
300 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
303 $result =
$object->delete($user);
305 header(
'Location: ' .
dolBuildUrl(DOL_URL_ROOT .
'/comm/propal/list.php', [
'restore_lastsearch_values' => 1]));
308 $langs->load(
"errors");
311 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
313 $result =
$object->deleteLine($lineid);
318 $langs->load(
"errors");
329 $outputlangs = $langs;
332 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
333 $outputlangs->setDefaultLang($newlang);
335 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
337 } elseif ($action ==
'confirm_delete_subtotalline' && $confirm ==
'yes' && $usercancreate) {
342 $result =
$object->deleteSubtotalLine($langs,
GETPOSTINT(
'lineid'), (
bool)
GETPOST(
'deletecorrespondingsubtotalline'));
347 $outputlangs = $langs;
353 $newlang =
$object->thirdparty->default_lang;
355 if (!empty($newlang)) {
357 $outputlangs->setDefaultLang($newlang);
358 $outputlangs->load(
'products');
362 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
365 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' . $id);
372 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
375 $result =
$object->valid($user);
377 $result =
$object->closeProposal($user, $object::STATUS_SIGNED);
388 $outputlangs = $langs;
391 $newlang =
GETPOST(
'lang_id',
'aZ09');
394 $newlang =
$object->thirdparty->default_lang;
396 if (!empty($newlang)) {
398 $outputlangs->setDefaultLang($newlang);
402 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
404 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
407 $langs->load(
"errors");
408 if (count(
$object->errors) > 0) {
411 setEventMessages($langs->trans(
$object->error),
null,
'errors');
414 } elseif ($action ==
'setdate' && $usercancreate) {
419 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
423 $result =
$object->set_date($user, $datep);
424 if ($result > 0 && !empty(
$object->duree_validite) && !empty(
$object->fin_validite)) {
425 $datev = $datep + (
$object->duree_validite * 24 * 3600);
426 $result =
$object->set_echeance($user, $datev, 1);
429 dol_print_error($db,
$object->error);
431 $outputlangs = $langs;
434 $newlang =
GETPOST(
'lang_id',
'aZ09');
437 $newlang =
$object->thirdparty->default_lang;
439 if (!empty($newlang)) {
441 $outputlangs->setDefaultLang($newlang);
449 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
452 } elseif ($action ==
'setecheance' && $usercancreate) {
456 $outputlangs = $langs;
459 $newlang =
GETPOST(
'lang_id',
'aZ09');
462 $newlang =
$object->thirdparty->default_lang;
464 if (!empty($newlang)) {
466 $outputlangs->setDefaultLang($newlang);
474 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
479 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
484 } elseif ($action ==
'setref_client' && $usercancreate) {
490 } elseif ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm') && $usercancreate) {
496 } elseif ($action ==
'settags' &&
isModEnabled(
'category') && $usercancreate) {
501 } elseif ($action ==
'add' && $usercancreate) {
511 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DatePropal")),
null,
'errors');
515 if (empty($duration)) {
516 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ValidityDuration")),
null,
'errors');
522 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Customer")),
null,
'errors');
537 $object->delivery_date = $date_delivery;
543 $object->duree_validite = $duration;
553 $object->user_author_id = $user->id;
559 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
561 setEventMessages($langs->trans(
"ErrorFailedToCopyProposal",
GETPOST(
'copie_propal')),
null,
'errors');
569 $object->delivery_date = $date_delivery;
584 $object->user_author_id = $user->id;
588 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
595 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
599 $ret = $extrafields->setOptionalsFromPost(
null, $object);
607 if ($origin && $originid) {
609 $element = $subelement = $origin;
611 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
613 $subelement = $regs[2];
617 if ($element ==
'order') {
618 $element = $subelement =
'commande';
620 if ($element ==
'propal') {
621 $element =
'comm/propal';
622 $subelement =
'propal';
624 if ($element ==
'contract') {
625 $element = $subelement =
'contrat';
627 if ($element ==
'inter') {
628 $element = $subelement =
'fichinter';
630 if ($element ==
'shipping') {
631 $element = $subelement =
'expedition';
635 if (($origin !=
'contrat' || $renewal !=
'true') && !
getDolGlobalInt(
'CONTRACT_NEW_CONTRACT_ON_RENEWAL')) {
637 $object->origin_id = $originid;
643 $object->linked_objects = array_merge(
$object->linked_objects,
GETPOST(
'other_linked_objects',
'array:int'));
650 $classname = ucfirst($subelement);
651 $srcobject =
new $classname($db);
652 '@phan-var-force Commande|Propal|Contrat|Fichinter|Expedition $srcobject';
655 dol_syslog(
"Try to find source object origin=" .
$object->origin .
" originid=" .
$object->origin_id .
" to add lines");
656 $result = $srcobject->fetch(
$object->origin_id);
659 $lines = $srcobject->lines;
660 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
661 $srcobject->fetch_lines();
662 $lines = $srcobject->lines;
666 $num = count($lines);
667 for ($i = 0; $i < $num; $i++) {
668 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
669 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc :
'');
672 $product_type = ($lines[$i]->product_type ? (int) $lines[$i]->product_type : 0);
676 if ($lines[$i]->date_debut_prevue) {
679 if ($lines[$i]->date_debut_reel) {
682 if ($lines[$i]->date_start) {
688 if ($lines[$i]->date_fin_prevue) {
689 $date_end = $lines[$i]->date_fin_prevue;
691 if ($lines[$i]->date_fin_reel) {
692 $date_end = $lines[$i]->date_fin_reel;
694 if ($lines[$i]->date_end) {
695 $date_end = $lines[$i]->date_end;
699 if ($origin ==
'contrat' && $renewal ==
'true') {
700 if ($lines[$i]->date_start && $lines[$i]->date_end) {
701 $duration = $lines[$i]->date_end - $lines[$i]->date_start;
708 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
713 if (method_exists($lines[$i],
'fetch_optionals')) {
714 $lines[$i]->fetch_optionals();
715 $array_options = $lines[$i]->array_options;
718 $tva_tx = $lines[$i]->tva_tx;
719 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', $tva_tx)) {
720 $tva_tx .=
' (' . $lines[$i]->vat_src_code .
')';
725 $line_price_base_type = $lines[$i]->getPriceBaseType();
726 $result =
$object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $line_price_base_type, (
float) $lines[$i]->subprice_ttc, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label,
$date_start, $date_end, $array_options, $lines[$i]->fk_unit);
737 if ($result > 0 && !empty($lines[$i]->extraparams)) {
739 $newline->id = $result;
740 $newline->extraparams = $lines[$i]->extraparams;
741 $newline->setExtraParameters();
745 if ($result > 0 && $lines[$i]->product_type == 9) {
746 $fk_parent_line = $result;
751 $parameters = array(
'objFrom' => $srcobject);
752 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $object, $action);
755 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
759 setEventMessages($srcobject->error, $srcobject->errors,
'errors');
773 if (
GETPOST(
'contactid') > 0) {
777 setEventMessages($langs->trans(
"ErrorFailedToAddContact"),
null,
'errors');
782 $result =
$object->add_contact($user->id,
'SALESREPFOLL',
'internal');
785 setEventMessages($langs->trans(
"ErrorFailedToAddUserAsContact"),
null,
'errors');
789 $categories =
GETPOST(
'categories',
'array');
790 if (method_exists($object,
'setCategories')) {
791 $object->setCategories($categories);
800 $outputlangs = $langs;
803 $newlang =
GETPOST(
'lang_id',
'aZ09');
806 $newlang =
$object->thirdparty->default_lang;
808 if (!empty($newlang)) {
810 $outputlangs->setDefaultLang($newlang);
815 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
821 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' . $id);
834 } elseif ($action ==
'classifybilled' && $usercanclose) {
838 $result =
$object->classifyBilled($user, 0,
'');
849 } elseif ($action ==
'confirm_closeas' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
852 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CloseAs")),
null,
'errors');
854 } elseif (
GETPOSTINT(
'statut') == $object::STATUS_SIGNED ||
GETPOSTINT(
'statut') == $object::STATUS_NOTSIGNED) {
855 $locationTarget =
'';
869 $locationTarget = DOL_URL_ROOT .
'/comm/propal/card.php?id=' .
$object->id;
874 $deposit_percent_from_payment_terms =
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
877 !$error &&
GETPOSTINT(
'statut') == $object::STATUS_SIGNED &&
GETPOST(
'generate_deposit') ==
'on'
878 && !empty($deposit_percent_from_payment_terms) &&
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')
880 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
883 $forceFields = array();
892 setEventMessage(
'DepositGenerated');
893 $locationTarget = DOL_URL_ROOT .
'/compta/facture/card.php?id=' . $deposit->id;
896 setEventMessages(
"Failed to create down payment - " .
$object->error,
$object->errors,
'errors');
904 $ret = $deposit->fetch($deposit->id);
905 $outputlangs = $langs;
909 $outputlangs->setDefaultLang($deposit->thirdparty->default_lang);
910 $outputlangs->load(
'products');
913 $result = $deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
916 setEventMessages($deposit->error, $deposit->errors,
'errors');
920 if ($locationTarget) {
921 header(
'Location: ' . $locationTarget);
933 } elseif ($action ==
'confirm_reopen' && $usercanreopen && !
GETPOST(
'cancel',
'alpha')) {
940 $result =
$object->reopen($user, $newstatus);
957 $fromElement =
GETPOST(
'fromelement');
958 $fromElementid =
GETPOST(
'fromelementid');
959 $importLines =
GETPOST(
'line_checkbox');
961 if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && preg_match(
'/^[a-zA-Z]+$/', $fromElement) && !empty($fromElementid)) {
962 if ($fromElement ==
'commande') {
963 dol_include_once(
'/' . $fromElement .
'/class/' . $fromElement .
'.class.php');
964 $lineClassName =
'OrderLine';
965 } elseif ($fromElement ==
'propal') {
966 dol_include_once(
'/comm/' . $fromElement .
'/class/' . $fromElement .
'.class.php');
967 $lineClassName =
'PropaleLigne';
968 } elseif ($fromElement ==
'facture') {
969 dol_include_once(
'/compta/' . $fromElement .
'/class/' . $fromElement .
'.class.php');
970 $lineClassName =
'FactureLigne';
972 $lineClassName =
null;
974 $nextRang = count(
$object->lines) + 1;
977 foreach ($importLines as $lineId) {
978 $lineId = intval($lineId);
979 $originLine =
new $lineClassName($db);
980 if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) {
981 $originLine->fetch_optionals();
982 $desc = $originLine->desc;
983 $pu_ht = $originLine->subprice;
984 $qty = $originLine->qty;
985 $txtva = $originLine->tva_tx;
986 $txlocaltax1 = $originLine->localtax1_tx;
987 $txlocaltax2 = $originLine->localtax2_tx;
988 $fk_product = $originLine->fk_product;
989 $remise_percent = $originLine->remise_percent;
991 $date_end = $originLine->date_end;
992 $fk_code_ventilation = 0;
993 $info_bits = $originLine->info_bits;
994 $fk_remise_except = $originLine->fk_remise_except;
995 $price_base_type =
'HT';
997 $type = $originLine->product_type;
999 $special_code = $originLine->special_code;
1000 $origin = $originLine->element;
1001 $origin_id = $originLine->id;
1002 $fk_parent_line = 0;
1003 $fk_fournprice = $originLine->fk_fournprice;
1004 $pa_ht = $originLine->pa_ht;
1005 $label = $originLine->label;
1006 $array_options = $originLine->array_options;
1007 $situation_percent = 100;
1009 $fk_unit = $originLine->fk_unit;
1010 $pu_ht_devise = $originLine->multicurrency_subprice;
1012 $res =
$object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, $rang, $special_code, $fk_parent_line, $fk_fournprice, $pa_ht, $label,
$date_start, $date_end, $array_options, $fk_unit, $origin, $origin_id, $pu_ht_devise, $fk_remise_except);
1025 setEventMessages($langs->trans(
'ErrorsOnXLines', $error),
null,
'errors');
1028 } elseif ($action ==
'addline' &&
GETPOST(
'updateallvatlinesblock',
'alpha') &&
GETPOST(
'vatforblocklines',
'alpha') !==
'' && $usercancreate) {
1029 $tx_tva =
GETPOST(
'vatforblocklines') ?
GETPOST(
'vatforblocklines') : 0;
1030 $result =
$object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'tva', $tx_tva);
1034 } elseif ($action ==
'addline' &&
GETPOST(
'updatealldiscountlinesblock',
'alpha') &&
GETPOST(
'discountforblocklines',
'alpha') !==
'' && $usercancreate) {
1035 $discount =
GETPOST(
'discountforblocklines') ?
GETPOST(
'discountforblocklines') : 0;
1036 $result =
$object->updateSubtotalLineBlockLines($langs,
$object->getRangOfLine($lineid),
'discount', $discount);
1042 include DOL_DOCUMENT_ROOT .
'/core/actions_printing.inc.php';
1045 $actiontypecode =
'AC_EMAIL';
1046 $triggersendname =
'PROPAL_SENTBYMAIL';
1047 $autocopy =
'MAIN_MAIL_AUTOCOPY_PROPOSAL_TO';
1048 $trackid =
'pro' .
$object->id;
1050 include DOL_DOCUMENT_ROOT .
'/core/actions_sendmails.inc.php';
1055 if ($action ==
'modif' && $usercancreate) {
1056 $result =
$object->setDraft($user);
1063 $outputlangs = $langs;
1066 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
1067 $outputlangs->setDefaultLang($newlang);
1073 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1075 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
1084 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') && (
GETPOST(
'alldate_start',
'alpha') ||
GETPOST(
'alldate_end',
'alpha')) && $usercancreate) {
1088 foreach (
$object->lines as $key => $line) {
1089 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
1092 if ($line->product_type == 1) {
1094 $line_price_base_type = $line->getPriceBaseType();
1095 $line_pu = ($line_price_base_type ===
'TTC') ? (
float) $line->subprice_ttc : (float) $line->subprice;
1096 $result =
$object->updateline($line->id, $line_pu, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, $line_price_base_type, $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $alldate_start, $alldate_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
1100 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'vatforalllines',
'alpha') !==
'' && $usercancreate) {
1102 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
1103 $vat_rate = str_replace(
'*',
'', $vat_rate);
1106 foreach (
$object->lines as $key => $line) {
1107 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
1111 $line_price_base_type = $line->getPriceBaseType();
1112 $line_pu = ($line_price_base_type ===
'TTC') ? (
float) $line->subprice_ttc : (float) $line->subprice;
1113 $result =
$object->updateline($line->id, $line_pu, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, $line_price_base_type, $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
1116 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'remiseforalllines',
'alpha') !==
'' && $usercancreate) {
1118 $remise_percent = (
GETPOST(
'remiseforalllines') ?
GETPOST(
'remiseforalllines') : 0);
1119 $remise_percent = str_replace(
'*',
'', $remise_percent);
1120 foreach (
$object->lines as $key => $line) {
1121 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
1124 $tvatx = $line->tva_tx;
1125 if (!empty($line->vat_src_code)) {
1126 $tvatx .=
' (' . $line->vat_src_code .
')';
1129 $line_price_base_type = $line->getPriceBaseType();
1130 $line_pu = ($line_price_base_type ===
'TTC') ? (
float) $line->subprice_ttc : (float) $line->subprice;
1131 $result =
$object->updateline($line->id, $line_pu, $line->qty, (
float) $remise_percent, $tvatx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, $line_price_base_type, $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
1134 } elseif ($action ==
'addline' &&
GETPOST(
'submitforallmargins',
'alpha') &&
GETPOST(
'marginforalllines',
'alpha') !==
'' && $usercancreate) {
1136 $margin_rate = (
GETPOST(
'marginforalllines',
'alpha') ?
GETPOST(
'marginforalllines',
'alpha') : 0);
1137 foreach (
$object->lines as $key => $line) {
1138 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
1141 $subprice =
price2num($line->pa_ht * (1 + $margin_rate / 100),
'MU');
1143 $prod->fetch($line->fk_product);
1144 if ($prod->price_min > $subprice) {
1145 $price_subprice =
price($subprice, 0, $outlangs, 1, -1, -1,
'auto');
1146 $price_price_min =
price($prod->price_min, 0, $outlangs, 1, -1, -1,
'auto');
1147 setEventMessages($prod->ref .
' - ' . $prod->label .
' (' . $price_subprice .
' < ' . $price_price_min .
' ' . strtolower($langs->trans(
"MinPrice")) .
')' .
"\n",
null,
'warnings');
1150 if ($line->subprice <> 0) {
1151 $multicurrency_subprice = (float) $subprice * $line->multicurrency_subprice / $line->subprice;
1153 $multicurrency_subprice = 0;
1156 $result =
$object->updateline($line->id, (
float) $subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $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->date_start, $line->date_end, $line->array_options, $line->fk_unit, $multicurrency_subprice);
1173 } elseif ($action ==
'confirm_addtextline' && $usercancreate) {
1176 $langs->load(
'subtotals');
1178 $desc =
GETPOST(
'subtotaltextcontent',
'restricthtml');
1181 $result =
$object->addSubtotalLine($langs, $desc, 0, array());
1192 $outputlangs = $langs;
1193 $newlang =
GETPOST(
'lang_id',
'alpha');
1195 $newlang =
$object->thirdparty->default_lang;
1197 if (!empty($newlang)) {
1199 $outputlangs->setDefaultLang($newlang);
1202 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1207 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' . $id);
1209 } elseif ($action ==
'confirm_addtitleline' && $usercancreate) {
1212 $langs->load(
'subtotals');
1214 $desc =
GETPOST(
'subtotallinedesc',
'alphanohtml');
1215 $depth =
GETPOSTINT(
'subtotallinelevel') ?? 1;
1217 $subtotal_options = array();
1219 foreach (Propal::$TITLE_OPTIONS as $option) {
1220 $value =
GETPOST($option,
'alphanohtml');
1222 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1227 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
1238 $outputlangs = $langs;
1239 $newlang =
GETPOST(
'lang_id',
'alpha');
1241 $newlang =
$object->thirdparty->default_lang;
1243 if (!empty($newlang)) {
1245 $outputlangs->setDefaultLang($newlang);
1248 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1253 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' . $id);
1255 } elseif ($action ==
'confirm_addsubtotalline' && $usercancreate) {
1258 $langs->load(
'subtotals');
1260 $choosen_line =
GETPOST(
'subtotaltitleline',
'alphanohtml');
1261 foreach (
$object->lines as $line) {
1262 if ($line->desc == $choosen_line && $line->special_code == SUBTOTALS_SPECIAL_CODE) {
1263 $desc = $line->desc;
1264 $depth = -$line->qty;
1268 $subtotal_options = array();
1270 foreach (Propal::$SUBTOTAL_OPTIONS as $option) {
1271 $value =
GETPOST($option,
'alphanohtml');
1273 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1278 if (isset($desc) && isset($depth)) {
1279 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
1282 $object->errors[] = $langs->trans(
"CorrespondingTitleNotFound");
1291 $outputlangs = $langs;
1292 $newlang =
GETPOST(
'lang_id',
'alpha');
1294 $newlang =
$object->thirdparty->default_lang;
1296 if (!empty($newlang)) {
1298 $outputlangs->setDefaultLang($newlang);
1301 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1306 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' . $id);
1308 } elseif ($action ==
'addline' && !
GETPOST(
'submitforalllines',
'alpha') && !
GETPOST(
'submitforallmargins',
'alpha') && !
GETPOST(
'markforalllines',
'alpha') && $usercancreate) {
1315 $price_ht_devise =
'';
1317 $price_ttc_devise =
'';
1321 if (
GETPOST(
'price_ht') !==
'') {
1324 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
1327 if (
GETPOST(
'price_ttc') !==
'') {
1330 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
1331 $price_ttc_devise =
price2num(
GETPOST(
'multicurrency_price_ttc'),
'CU', 2);
1334 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
1335 if ($prod_entry_mode ==
'free') {
1341 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
1346 $tva_tx =
GETPOST(
'tva_tx',
'alpha');
1350 if (empty($remise_percent)) {
1351 $remise_percent = 0;
1355 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1356 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1358 if (is_array($extralabelsline)) {
1360 foreach ($extralabelsline as $key => $value) {
1361 unset($_POST[
"options_" . $key]);
1365 $price_to_test_sign = ($price_ht ? $price_ht : $price_ttc);
1367 if ((empty($idprod) || $idprod < 0) && ($price_to_test_sign < 0) && ($qty < 0)) {
1368 $langs->load(
"errors");
1369 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPriceHT'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1372 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
1373 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1377 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && $price_ht ===
'' && $price_ht_devise ===
'' && $price_ttc ===
'' && $price_ttc_devise ===
'') {
1378 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")),
null,
'errors');
1382 setEventMessages($langs->trans(
'FieldCannotBeNegative', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1385 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($line_desc)) {
1386 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Description")),
null,
'errors');
1390 if (!$error &&
isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1391 if ($combinations =
GETPOST(
'combinations',
'array:alphanohtml')) {
1395 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1396 $idprod = $res->fk_product_child;
1398 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1404 if (!$error && (!empty($line_desc) || (!empty($idprod) && $idprod > 0))) {
1412 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
1421 if (!empty($idprod) && $idprod > 0) {
1423 $prod->fetch($idprod);
1425 $label = ((
GETPOST(
'product_label') &&
GETPOST(
'product_label') != $prod->label) ?
GETPOST(
'product_label') :
'');
1435 $pu_ht = $prod->price;
1436 $pu_ttc = $prod->price_ttc;
1437 $price_min = $prod->price_min;
1438 $price_min_ttc = $prod->price_min_ttc;
1439 $price_base_type = $prod->price_base_type;
1443 require_once DOL_DOCUMENT_ROOT .
'/product/class/productcustomerprice.class.php';
1445 $filter = array(
't.fk_product' => (
string) $prod->id,
't.fk_soc' => (
string)
$object->thirdparty->id);
1448 $pricebycustomerexist =
false;
1449 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1452 if (count($prodcustprice->lines) > 0) {
1453 $date_now = (int) floor(
dol_now() / 86400) * 86400;
1454 foreach ($prodcustprice->lines as $k => $custprice_line) {
1455 if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
1456 $pricebycustomerexist =
true;
1457 $pu_ht =
price($custprice_line->price);
1458 $pu_ttc =
price($custprice_line->price_ttc);
1459 $price_min =
price($custprice_line->price_min);
1460 $price_min_ttc =
price($custprice_line->price_min_ttc);
1461 $price_base_type = $custprice_line->price_base_type;
1475 setEventMessages($prodcustprice->error, $prodcustprice->errors,
'errors');
1478 if (!$pricebycustomerexist && !empty(
$object->thirdparty->price_level)) {
1479 $pu_ht = $prod->multiprices[
$object->thirdparty->price_level];
1480 $pu_ttc = $prod->multiprices_ttc[
$object->thirdparty->price_level];
1481 $price_min = $prod->multiprices_min[
$object->thirdparty->price_level];
1482 $price_min_ttc = $prod->multiprices_min_ttc[
$object->thirdparty->price_level];
1483 $price_base_type = $prod->multiprices_base_type[
$object->thirdparty->price_level];
1485 if (isset($prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
1486 $tva_tx = $prod->multiprices_tva_tx[
$object->thirdparty->price_level];
1488 if (isset($prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
1489 $tva_npr = $prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
1494 $pu_ht = $prod->multiprices[
$object->thirdparty->price_level];
1495 $pu_ttc = $prod->multiprices_ttc[
$object->thirdparty->price_level];
1496 $price_min = $prod->multiprices_min[
$object->thirdparty->price_level];
1497 $price_min_ttc = $prod->multiprices_min_ttc[
$object->thirdparty->price_level];
1498 $price_base_type = $prod->multiprices_base_type[
$object->thirdparty->price_level];
1500 if (isset($prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
1501 $tva_tx = $prod->multiprices_tva_tx[
$object->thirdparty->price_level];
1503 if (isset($prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
1504 $tva_npr = $prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
1509 require_once DOL_DOCUMENT_ROOT .
'/product/class/productcustomerprice.class.php';
1513 $filter = array(
't.fk_product' => (
string) $prod->id,
't.fk_soc' => (
string)
$object->thirdparty->id);
1515 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1518 if (count($prodcustprice->lines) > 0) {
1519 $date_now = (int) floor(
dol_now() / 86400) * 86400;
1520 foreach ($prodcustprice->lines as $k => $custprice_line) {
1521 if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
1522 $pu_ht =
price($custprice_line->price);
1523 $pu_ttc =
price($custprice_line->price_ttc);
1524 $price_min =
price($custprice_line->price_min);
1525 $price_min_ttc =
price($custprice_line->price_min_ttc);
1526 $price_base_type = $custprice_line->price_base_type;
1540 setEventMessages($prodcustprice->error, $prodcustprice->errors,
'errors');
1544 if ($prod->prices_by_qty[0]) {
1549 foreach ($prod->prices_by_qty_list[0] as $priceforthequantityarray) {
1550 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1554 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1555 $pu_ht = $priceforthequantityarray[
'unitprice'];
1557 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1565 if (!empty(
$object->thirdparty->price_level)) {
1567 $pu_ht = $prod->multiprices[
$object->thirdparty->price_level];
1568 $pu_ttc = $prod->multiprices_ttc[
$object->thirdparty->price_level];
1569 $price_min = $prod->multiprices_min[
$object->thirdparty->price_level];
1570 $price_min_ttc = $prod->multiprices_min_ttc[
$object->thirdparty->price_level];
1571 $price_base_type = (empty($prod->multiprices_base_type[
$object->thirdparty->price_level]) ?
'HT' : $prod->multiprices_base_type[
$object->thirdparty->price_level]);
1573 if (isset($prod->multiprices_tva_tx[
$object->thirdparty->price_level])) {
1574 $tva_tx = $prod->multiprices_tva_tx[
$object->thirdparty->price_level];
1576 if (isset($prod->multiprices_recuperableonly[
$object->thirdparty->price_level])) {
1577 $tva_npr = $prod->multiprices_recuperableonly[
$object->thirdparty->price_level];
1581 if (!empty(
$object->thirdparty->price_level) && !empty($prod->prices_by_qty[
$object->thirdparty->price_level])) {
1586 foreach ($prod->prices_by_qty_list[
$object->thirdparty->price_level] as $priceforthequantityarray) {
1587 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1591 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1592 $pu_ht = $priceforthequantityarray[
'unitprice'];
1594 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1602 $tmpvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
1603 $tmpprodvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string) $prod->tva_tx));
1608 if (!empty($price_ht) || (string) $price_ht ===
'0') {
1609 $pu_ht = (float)
price2num($price_ht,
'MU');
1610 $pu_ttc = (float)
price2num((
float) $pu_ht * (1 + ((float) $tmpvat / 100)),
'MU');
1611 $price_base_type =
'HT';
1612 } elseif (!empty($price_ht_devise) || (
string) $price_ht_devise ===
'0') {
1613 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1614 $pu_ttc_devise = (float)
price2num((
float) $pu_ht_devise * (1 + ((float) $tmpvat / 100)),
'MU');
1617 $price_base_type =
'HT';
1618 } elseif (!empty($price_ttc) || (
string) $price_ttc ===
'0') {
1619 $pu_ttc = (float)
price2num($price_ttc,
'MU');
1620 $pu_ht = (float)
price2num((
float) $pu_ttc / (1 + ((float) $tmpvat / 100)),
'MU');
1621 $price_base_type =
'TTC';
1622 } elseif (!empty($price_ttc_devise) || (
string) $price_ttc_devise ===
'0') {
1623 $pu_ttc_devise = (float)
price2num($price_ttc_devise,
'MU');
1624 $pu_ht_devise = (float)
price2num((
float) $pu_ttc_devise / (1 + ((float) $tmpvat / 100)),
'MU');
1627 $price_base_type =
'TTC';
1628 } elseif ($tmpvat != $tmpprodvat) {
1630 if ($price_base_type !=
'HT') {
1631 $pu_ht = (float)
price2num((
float) $pu_ttc / (1 + ((float) $tmpvat / 100)),
'MU');
1633 $pu_ttc = (float)
price2num((
float) $pu_ht * (1 + ((float) $tmpvat / 100)),
'MU');
1641 $outputlangs = $langs;
1643 if (
GETPOST(
'lang_id',
'aZ09')) {
1644 $newlang =
GETPOST(
'lang_id',
'aZ09');
1646 if (empty($newlang)) {
1647 $newlang =
$object->thirdparty->default_lang;
1649 if (!empty($newlang)) {
1651 $outputlangs->setDefaultLang($newlang);
1654 $desc = (!empty($prod->multilangs[$outputlangs->defaultlang][
"description"])) ? $prod->multilangs[$outputlangs->defaultlang][
"description"] : $prod->
description;
1656 $desc = $prod->description;
1668 if (!
getDolGlobalString(
'MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE') && (!empty($prod->customcode) || !empty($prod->country_code))) {
1672 $outputlangs = $langs;
1674 if (
GETPOST(
'lang_id',
'alpha')) {
1675 $newlang =
GETPOST(
'lang_id',
'alpha');
1677 if (empty($newlang)) {
1678 $newlang =
$object->thirdparty->default_lang;
1680 if (!empty($newlang)) {
1682 $outputlangs->setDefaultLang($newlang);
1683 $outputlangs->load(
'products');
1685 if (!empty($prod->customcode)) {
1686 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomsCode") .
': ' . $prod->customcode;
1688 if (!empty($prod->customcode) && !empty($prod->country_code)) {
1691 if (!empty($prod->country_code)) {
1692 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin") .
': ' .
getCountry($prod->country_code,
'', $db, $outputlangs, 0);
1695 if (!empty($prod->customcode)) {
1696 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomsCode") .
': ' . $prod->customcode;
1698 if (!empty($prod->customcode) && !empty($prod->country_code)) {
1701 if (!empty($prod->country_code)) {
1702 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin") .
': ' .
getCountry($prod->country_code,
'', $db, $langs, 0);
1709 $type = $prod->type;
1710 $fk_unit = $prod->fk_unit;
1714 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1715 $tva_tx = str_replace(
'*',
'', $tva_tx);
1716 if (empty($tva_tx)) {
1719 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1722 $fk_unit =
GETPOST(
'units',
'alpha');
1723 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1724 $pu_ttc_devise =
price2num($price_ttc_devise,
'MU');
1726 if ($pu_ttc && !$pu_ht) {
1727 $price_base_type =
'TTC';
1741 $fournprice = (int) (
GETPOST(
'fournprice' . $predef) ?
GETPOST(
'fournprice' . $predef) :
'');
1742 $buyingprice =
price2num((
GETPOST(
'buying_price' . $predef) !=
'' ?
GETPOST(
'buying_price' . $predef) :
''),
'', 2);
1748 $pu_equivalent = $pu_ht;
1749 $pu_equivalent_ttc = $pu_ttc;
1750 $currency_tx =
$object->multicurrency_tx;
1754 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1755 $pu_equivalent = (float) $pu_ht_devise / (
float) $currency_tx;
1757 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
1758 $pu_equivalent_ttc = (float) $pu_ttc_devise / (
float) $currency_tx;
1778 if ($usermustrespectpricemin) {
1779 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - $remise_percent / 100)) < (float)
price2num($price_min)) && $price_base_type ==
'HT') {
1780 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1781 setEventMessages($mesg,
null,
'errors');
1783 } elseif ($pu_equivalent_ttc && $price_min_ttc && (((
float)
price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < (
float)
price2num($price_min_ttc)) && $price_base_type ==
'TTC') {
1784 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1785 setEventMessages($mesg,
null,
'errors');
1792 if ($price_ht ===
'' && $price_ttc ===
'' && $price_ht_devise ===
'' && $price_ttc_devise !==
'') {
1795 $price_base_type =
'TTC';
1796 $pu_ht_devise =
price2num($price_ttc_devise,
'MU');
1801 $result =
$object->addline($desc, $pu_ht, (
float) $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, min($rank, count(
$object->lines) + 1), 0,
GETPOSTINT(
'fk_parent_line'), (
int) $fournprice, $buyingprice, $label,
$date_start, $date_end, $array_options, $fk_unit,
'', 0, (
float) $pu_ht_devise);
1813 $outputlangs = $langs;
1814 $newlang =
GETPOST(
'lang_id',
'alpha');
1816 $newlang =
$object->thirdparty->default_lang;
1818 if (!empty($newlang)) {
1820 $outputlangs->setDefaultLang($newlang);
1822 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1825 unset($_POST[
'prod_entry_mode']);
1827 unset($_POST[
'qty']);
1828 unset($_POST[
'type']);
1829 unset($_POST[
'remise_percent']);
1830 unset($_POST[
'price_ht']);
1831 unset($_POST[
'multicurrency_price_ht']);
1832 unset($_POST[
'price_ttc']);
1833 unset($_POST[
'tva_tx']);
1834 unset($_POST[
'product_ref']);
1835 unset($_POST[
'product_label']);
1836 unset($_POST[
'product_desc']);
1837 unset($_POST[
'fournprice']);
1838 unset($_POST[
'buying_price']);
1839 unset($_POST[
'np_marginRate']);
1840 unset($_POST[
'np_markRate']);
1841 unset($_POST[
'dp_desc']);
1842 unset($_POST[
'idprod']);
1843 unset($_POST[
'units']);
1845 unset($_POST[
'date_starthour']);
1846 unset($_POST[
'date_startmin']);
1847 unset($_POST[
'date_startsec']);
1848 unset($_POST[
'date_startday']);
1849 unset($_POST[
'date_startmonth']);
1850 unset($_POST[
'date_startyear']);
1851 unset($_POST[
'date_endhour']);
1852 unset($_POST[
'date_endmin']);
1853 unset($_POST[
'date_endsec']);
1854 unset($_POST[
'date_endday']);
1855 unset($_POST[
'date_endmonth']);
1856 unset($_POST[
'date_endyear']);
1858 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
1867 } elseif ($action ==
'addline' && $usercancreate && (
1868 (
GETPOST(
'submitforallmargins',
'alpha') &&
GETPOST(
'marginforalllines',
'alpha') !==
'') ||
1869 (
GETPOST(
'submitforallmark',
'alpha') &&
GETPOST(
'markforalllines',
'alpha') !==
'')
1873 $margin_rate =
GETPOSTISSET(
'marginforalllines') ?
GETPOST(
'marginforalllines',
'int') :
'';
1875 foreach (
$object->lines as &$line) {
1876 if ($line->subprice > 0) {
1877 if ($line->special_code == SUBTOTALS_SPECIAL_CODE) {
1880 $subprice_multicurrency = $line->subprice;
1881 if (is_numeric($margin_rate) && $margin_rate > 0) {
1882 $line->subprice = (float)
price2num((
float) $line->pa_ht * (1 + (float) $margin_rate / 100),
'MU');
1883 } elseif (is_numeric($mark_rate) && $mark_rate > 0) {
1884 $line->subprice = (float) ($line->pa_ht / (1 - ((
float) $mark_rate / 100)));
1886 $line->subprice = (float) $line->pa_ht;
1889 if ($line->fk_product > 0) {
1891 $res = $prod->fetch($line->fk_product);
1893 if ($prod->price_min > $line->subprice) {
1894 $price_subprice =
price($line->subprice, 0, $outlangs, 1, -1, -1,
'auto');
1895 $price_price_min =
price($prod->price_min, 0, $outlangs, 1, -1, -1,
'auto');
1896 setEventMessages($prod->ref .
' - ' . $prod->label .
' (' . $price_subprice .
' < ' . $price_price_min .
' ' . strtolower($langs->trans(
"MinPrice")) .
')' .
"\n",
null,
'warnings');
1898 setEventMessages($prod->error, $prod->errors,
'errors');
1901 setEventMessages($prod->error, $prod->errors,
'errors');
1906 $multicurrency_subprice = (float) $line->subprice * $line->multicurrency_subprice / $subprice_multicurrency;
1908 $result =
$object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $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->date_start, $line->date_end, $line->array_options, $line->fk_unit, $multicurrency_subprice);
1911 if (is_numeric($margin_rate) && empty($mark_rate)) {
1912 $line->marge_tx = $margin_rate;
1913 } elseif (is_numeric($mark_rate) && empty($margin_rate)) {
1914 $line->marque_tx = $mark_rate;
1916 $line->total_ht = $line->qty * (float) $line->subprice;
1917 $line->total_tva = $line->tva_tx * $line->qty * (float) $line->subprice;
1918 $line->total_ttc = (1 + $line->tva_tx) * $line->qty * (
float) $line->subprice;
1920 $line->multicurrency_total_ht = $line->qty * (float) $subprice_multicurrency * $line->multicurrency_subprice / $line->subprice;
1921 $line->multicurrency_total_tva = $line->tva_tx * $line->qty * (float) $subprice_multicurrency * $line->multicurrency_subprice / $line->subprice;
1922 $line->multicurrency_total_ttc = (1 + $line->tva_tx) * $line->qty * (
float) $subprice_multicurrency * $line->multicurrency_subprice / $line->subprice;
1924 $line->multicurrency_subprice = $multicurrency_subprice;
1930 } elseif ($action ==
'updatetitleline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1933 $langs->load(
'subtotals');
1935 $desc =
GETPOST(
'line_desc',
'alphanohtml') ?? $langs->trans(
"Title");
1938 $subtotal_options = array();
1940 foreach (Propal::$TITLE_OPTIONS as $option) {
1941 $value =
GETPOST($option,
'alphanohtml');
1943 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1948 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1959 $outputlangs = $langs;
1960 $newlang =
GETPOST(
'lang_id',
'alpha');
1962 $newlang =
$object->thirdparty->default_lang;
1964 if (!empty($newlang)) {
1966 $outputlangs->setDefaultLang($newlang);
1969 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1974 } elseif ($action ==
'updatetextline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1977 $langs->load(
'subtotals');
1979 $desc =
GETPOST(
'line_desc',
'restricthtml');
1982 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, 0, array());
1993 $outputlangs = $langs;
1994 $newlang =
GETPOST(
'lang_id',
'alpha');
1996 $newlang =
$object->thirdparty->default_lang;
1998 if (!empty($newlang)) {
2000 $outputlangs->setDefaultLang($newlang);
2003 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
2008 } elseif ($action ==
'updatesubtotalline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
2011 $langs->load(
'subtotals');
2013 $desc =
GETPOST(
'line_desc',
'alphanohtml');
2016 $subtotal_options = array();
2018 foreach (Propal::$SUBTOTAL_OPTIONS as $option) {
2019 $value =
GETPOST($option,
'alphanohtml');
2021 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
2026 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
2034 $outputlangs = $langs;
2035 $newlang =
GETPOST(
'lang_id',
'alpha');
2037 $newlang =
$object->thirdparty->default_lang;
2039 if (!empty($newlang)) {
2041 $outputlangs->setDefaultLang($newlang);
2044 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
2049 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save')) {
2057 if (preg_match(
'/\*/',
GETPOST(
'tva_tx'))) {
2062 $vat_rate = (
GETPOST(
'tva_tx') ?
GETPOST(
'tva_tx',
'alpha') : 0);
2063 $vat_rate = str_replace(
'*',
'', $vat_rate);
2070 $fournprice = (int) (
GETPOST(
'fournprice') ?
GETPOST(
'fournprice') :
'');
2080 if (empty($remise_percent)) {
2081 $remise_percent = 0;
2085 $pu_equivalent = $pu_ht;
2086 $pu_equivalent_ttc = $pu_ttc;
2088 $currency_tx =
$object->multicurrency_tx;
2092 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
2093 $pu_equivalent = (float) $pu_ht_devise / (
float) $currency_tx;
2095 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
2096 $pu_equivalent_ttc = (float) $pu_ttc_devise / (
float) $currency_tx;
2111 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
2112 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
2114 if (is_array($extralabelsline)) {
2116 foreach ($extralabelsline as $key => $value) {
2117 unset($_POST[
"options_" . $key]);
2131 $price_base_type =
'HT';
2132 if (empty($pu_ht) && !empty($pu_ttc)) {
2134 $price_base_type =
'TTC';
2135 } elseif (!empty($pu_ht) && !empty($pu_ttc)) {
2136 foreach (
$object->lines as $line_obj) {
2138 if ($line_obj->wasEnteredIncludingTax()) {
2140 $price_base_type =
'TTC';
2149 if (
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' &&
GETPOST(
'multicurrency_subprice') ===
'' &&
GETPOST(
'multicurrency_price_ttc') !==
'') {
2151 $price_base_type =
'TTC';
2152 $pu_ht_devise = $pu_ttc_devise;
2157 if (!empty($productid)) {
2159 $res = $product->fetch($productid);
2161 $type = $product->type;
2165 $price_min = $product->price_min;
2167 $price_min = $product->multiprices_min[
$object->thirdparty->price_level];
2169 $price_min_ttc = $product->price_min_ttc;
2171 $price_min_ttc = $product->multiprices_min_ttc[
$object->thirdparty->price_level];
2178 if ($usermustrespectpricemin) {
2179 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - (
float) $remise_percent / 100)) < (float)
price2num($price_min)) && $price_base_type ==
'HT') {
2180 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
2181 setEventMessages($mesg,
null,
'errors');
2183 $action =
'editline';
2184 } elseif ($pu_equivalent_ttc && $price_min_ttc && (((
float)
price2num($pu_equivalent_ttc) * (1 - (
float) $remise_percent / 100)) < (
float)
price2num($price_min_ttc)) && $price_base_type ==
'TTC') {
2185 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
2186 setEventMessages($mesg,
null,
'errors');
2188 $action =
'editline';
2193 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
2197 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
2205 $oldbuyingprice = array_column(
$object->lines,
'pa_ht',
'id')[$lineid] ??
null;
2207 if (!$user->hasRight(
'margins',
'creer')) {
2208 foreach (
$object->lines as &$line) {
2210 $fournprice = $line->fk_fournprice;
2211 $buyingprice = (string) $line->pa_ht;
2219 $result =
$object->updateline(
GETPOSTINT(
'lineid'), (
float) $pu, (
float) $qty, (
float) $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $description, $price_base_type, $info_bits, $special_code,
GETPOSTINT(
'fk_parent_line'), 0, (
int) $fournprice, $buyingprice, $label, $type,
$date_start, $date_end, $array_options,
GETPOSTINT(
"units"), (
float) $pu_ht_devise);
2226 $outputlangs = $langs;
2229 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') :
$object->thirdparty->default_lang);
2230 $outputlangs->setDefaultLang($newlang);
2236 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
2239 unset($_POST[
'qty']);
2240 unset($_POST[
'type']);
2241 unset($_POST[
'productid']);
2242 unset($_POST[
'remise_percent']);
2243 unset($_POST[
'price_ht']);
2244 unset($_POST[
'multicurrency_price_ht']);
2245 unset($_POST[
'price_ttc']);
2246 unset($_POST[
'tva_tx']);
2247 unset($_POST[
'product_ref']);
2248 unset($_POST[
'product_label']);
2249 unset($_POST[
'product_desc']);
2250 unset($_POST[
'fournprice']);
2251 unset($_POST[
'buying_price']);
2253 unset($_POST[
'date_starthour']);
2254 unset($_POST[
'date_startmin']);
2255 unset($_POST[
'date_startsec']);
2256 unset($_POST[
'date_startday']);
2257 unset($_POST[
'date_startmonth']);
2258 unset($_POST[
'date_startyear']);
2259 unset($_POST[
'date_endhour']);
2260 unset($_POST[
'date_endmin']);
2261 unset($_POST[
'date_endsec']);
2262 unset($_POST[
'date_endday']);
2263 unset($_POST[
'date_endmonth']);
2264 unset($_POST[
'date_endyear']);
2266 if (
$object->getLinkedBuyPriceDocuments($user, $lineid, $oldbuyingprice)) {
2267 $action =
'ask_updatelinkedbuyingprice';
2275 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha')) {
2276 header(
'Location: ' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
2278 } elseif ($action ==
'confirm_updatelinkedbuyingprice' && $confirm ==
'yes' && $usercancreate) {
2279 $result =
$object->updateLinkedBuyPrice($user, $lineid, array(
'propal' =>
GETPOST(
'updatelinked_propal'),
'commande' =>
GETPOST(
'updatelinked_commande'),
'facture' =>
GETPOST(
'updatelinked_facture')));
2280 setEventMessages(($result < 0 ? $object->error : $langs->trans(
'RecordsModified', $result)), null, ($result < 0 ?
'errors' :
'mesgs'));
2281 } elseif ($action ==
'classin' && $usercancreate) {
2284 } elseif ($action ==
'setavailability' && $usercancreate) {
2287 } elseif ($action ==
'setdemandreason' && $usercancreate) {
2290 } elseif ($action ==
'setconditions' && $usercancreate) {
2293 } elseif ($action ==
'setmode' && $usercancreate) {
2296 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
2298 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
2299 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
2301 if (!in_array(
GETPOSTINT(
'calculation_mode'), array(1, 2))) {
2302 $langs->load(
"compta");
2303 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CalculationMode")),
null,
'errors');
2304 $action =
'editmulticurrencyrate';
2308 } elseif ($action ==
'setbankaccount' && $usercancreate) {
2311 } elseif ($action ==
'setshippingmethod' && $usercancreate) {
2314 } elseif ($action ==
'setwarehouse' && $usercancreate) {
2317 } elseif ($action ==
'update_extras' && $permissiontoeditextra) {
2320 $attribute_name =
GETPOST(
'attribute',
'aZ09');
2323 $result = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
2329 $result =
$object->updateExtraField($attribute_name,
'PROPAL_MODIFY');
2336 $action =
'edit_extras';
2341 if ($action ==
'addcontact' && $usercancreate) {
2346 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
2350 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
2353 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2354 $langs->load(
"errors");
2355 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
2360 } elseif ($action ==
'swapstatut' && $usercancreate) {
2362 if (
$object->fetch($id) > 0) {
2365 dol_print_error($db);
2367 } elseif ($action ==
'deletecontact' && $usercancreate) {
2370 $result =
$object->delete_contact($lineid);
2373 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
"?id=" .
$object->id);
2376 dol_print_error($db);
2383 $permissiontoadd = $usercancreate;
2384 include DOL_DOCUMENT_ROOT .
'/core/actions_builddoc.inc.php';
2392$form =
new Form($db);
2401$title =
$object->ref .
" - " . $langs->trans(
'Card');
2402if ($action ==
'create') {
2403 $title = $langs->trans(
"NewPropal");
2405$help_url =
'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos|DE:Modul_Angebote';
2412if ($action ==
'create') {
2419 $res = $soc->fetch($socid);
2422 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2423 $deposit_percent =
GETPOSTFLOAT(
'cond_reglement_id_deposit_percent');
2424 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2430 if (!empty($origin) && !empty($originid)) {
2432 $element = $subelement = $origin;
2434 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
2435 $element = $regs[1];
2436 $subelement = $regs[2];
2439 if ($element ==
'project') {
2440 $projectid = $originid;
2444 $project->fetch($projectid);
2445 if ($project->socid > 0) {
2447 $soc->fetch($project->socid);
2451 if ($element ==
'order' || $element ==
'commande') {
2452 $element = $subelement =
'commande';
2454 if ($element ==
'propal') {
2455 $element =
'comm/propal';
2456 $subelement =
'propal';
2458 if ($element ==
'contract') {
2459 $element = $subelement =
'contrat';
2461 if ($element ==
'shipping') {
2462 $element = $subelement =
'expedition';
2467 $classname = ucfirst($subelement);
2468 $objectsrc =
new $classname($db);
2469 '@phan-var-force Commande|Propal|Contrat|Expedition $objectsrc';
2471 $objectsrc->fetch($originid);
2472 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
2473 $objectsrc->fetch_lines();
2475 $objectsrc->fetch_thirdparty();
2477 $projectid = (int) $objectsrc->fk_project;
2478 $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client :
'');
2480 $soc = $objectsrc->thirdparty;
2482 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
2483 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
2484 $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : -1));
2487 $objectsrc->fetch_optionals();
2488 $object->array_options = $objectsrc->array_options;
2491 if (!empty($objectsrc->multicurrency_code)) {
2492 $currency_code = $objectsrc->multicurrency_code;
2494 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
2495 $currency_tx = $objectsrc->multicurrency_tx;
2503 $cond_reglement_id = empty($soc->cond_reglement_id) ? $cond_reglement_id : $soc->cond_reglement_id;
2504 $deposit_percent = empty($soc->deposit_percent) ? $deposit_percent : $soc->deposit_percent;
2505 $mode_reglement_id = empty($soc->mode_reglement_id) ? $mode_reglement_id : $soc->mode_reglement_id;
2506 $fk_account = empty($soc->fk_account) ? $fk_account : $soc->fk_account;
2507 $shipping_method_id = $soc->shipping_method_id;
2508 $warehouse_id = !empty($soc->fk_warehouse) ? $soc->fk_warehouse : $warehouse_id;
2509 $remise_percent = $soc->remise_percent;
2511 if (
isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
2512 $currency_code = $soc->multicurrency_code;
2517 if (!
GETPOST(
'changecompany')) {
2519 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2525 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2531 $shipping_method_id =
GETPOSTINT(
'shipping_method_id');
2535 if ($soc->fk_warehouse > 0) {
2536 $warehouse_id = $soc->fk_warehouse;
2543 $warehouse_id = $user->fk_warehouse;
2547 print
'<form name="addprop" action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST">';
2548 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2549 print
'<input type="hidden" name="action" value="add">';
2550 print
'<input type="hidden" name="changecompany" value="0">';
2551 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
2552 if ($backtopageforcancel) {
2553 print
'<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel .
'">';
2555 if ($origin !=
'project' && $originid) {
2556 print
'<input type="hidden" name="origin" value="' . $origin .
'">';
2557 print
'<input type="hidden" name="originid" value="' . $originid .
'">';
2558 if ($origin ==
'contrat' && !empty($renewal)) {
2559 print
'<input type="hidden" name="renewal" value="' . $renewal .
'">';
2561 } elseif ($origin ==
'project' && !empty($projectid)) {
2562 print
'<input type="hidden" name="projectid" value="' . $projectid .
'">';
2568 $parameters = array();
2570 $reshook = $hookmanager->executeHooks(
'tabContentCreateProposal', $parameters, $object, $action);
2571 if (empty($reshook)) {
2572 print
'<table class="border centpercent">';
2578 print
'<tr class="field_socid">';
2580 print
'<td class="titlefieldcreate fieldrequired">' . $langs->trans(
'Customer') .
'</td>';
2581 $shipping_method_id = 0;
2584 print
'<td class="valuefieldcreate">';
2585 print $soc->getNomUrl(1,
'customer');
2586 print
'<input type="hidden" name="socid" value="' . $soc->id .
'">';
2588 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($soc->shipping_method_id)) {
2589 $shipping_method_id = $soc->shipping_method_id;
2592 print
'<td class="valuefieldcreate">';
2593 $filter =
'((s.client:IN:1,2,3) AND (s.status:=:1))';
2594 print img_picto(
'',
'company',
'class="pictofixedwidth"');
2595 print $form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
2599 $(document).ready(function() {
2600 $("#socid").change(function() {
2601 console.log("We have changed the company - Reload page");
2602 var socid = $(this).val();
2604 $("input[name=action]").val("create");
2605 $("input[name=changecompany]").val("1");
2606 $("form[name=addprop]").submit();
2611 print
' <a href="' . DOL_URL_ROOT .
'/societe/card.php?action=create&prospect=3&fournisseur=0&backtopage=' . urlencode($_SERVER[
"PHP_SELF"] .
'?action=create') .
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="' . $langs->trans(
"AddThirdParty") .
'"></span></a>';
2614 print
'</tr>' .
"\n";
2618 print
'<tr class="field_ref_client"><td class="titlefieldcreate">';
2619 print $form->textwithpicto($langs->trans(
'RefCustomer'), $langs->trans(
'RefOfOnCustomerSide', $langs->transnoentitiesnoconv(
"Proposal")));
2620 print
'</td><td class="valuefieldcreate">';
2621 print
'<input type="text" name="ref_client" value="' . (!empty($ref_client) ? $ref_client :
GETPOST(
'ref_client')) .
'"></td>';
2627 print
'<tr class="field_contactid"><td class="titlefieldcreate">' . $langs->trans(
"DefaultContact") .
'</td><td class="valuefieldcreate">';
2628 print img_picto(
'',
'contact',
'class="pictofixedwidth"');
2630 print $form->select_contact($soc->id, $contactid,
'contactid', 1,
'',
'', 1,
'maxwidth300 widthcentpercentminusx',
true);
2634 print
'<tr class="field_discount_info"><td class="titlefieldcreate">' . $langs->trans(
'Discounts') .
'</td><td class="valuefieldcreate">';
2636 $absolute_discount = $soc->getAvailableDiscounts();
2640 $backtopage = $_SERVER[
"PHP_SELF"] .
'?socid=' . $thirdparty->id .
'&action=' . $action .
'&origin=' . urlencode((
string) (
GETPOST(
'origin'))) .
'&originid=' . urlencode((
string) (
GETPOSTINT(
'originid')));
2641 include DOL_DOCUMENT_ROOT .
'/core/tpl/object_discounts.tpl.php';
2647 print
'<tr class="field_addprop"><td class="titlefieldcreate fieldrequired">' . $langs->trans(
'Date') .
'</td><td class="valuefieldcreate">';
2648 print img_picto(
'',
'action',
'class="pictofixedwidth"');
2649 print $form->selectDate($newdatepropal ? $newdatepropal : $datepropal,
'', 0, 0, 0,
"addprop", 1, 1);
2653 print
'<tr class="field_duree_validitee"><td class="titlefieldcreate fieldrequired">' . $langs->trans(
"ValidityDuration") .
'</td><td class="valuefieldcreate">' . img_picto(
'',
'clock',
'class="pictofixedwidth"') .
'<input name="duree_validite" class="width50" value="' . (
GETPOSTISSET(
'duree_validite') ?
GETPOST(
'duree_validite',
'alphanohtml') :
getDolGlobalString(
'PROPALE_VALIDITY_DURATION')) .
'"> ' . $langs->trans(
"days") .
'</td></tr>';
2656 print
'<tr class="field_cond_reglement_id"><td class="nowrap">' . $langs->trans(
'PaymentConditionsShort') .
'</td><td>';
2657 print img_picto(
'',
'payment',
'class="pictofixedwidth"');
2659 print $form->getSelectConditionsPaiements((
int) $cond_reglement_id,
'cond_reglement_id', 1, 1, 0,
'', $deposit_percent);
2663 print
'<tr class="field_mode_reglement_id"><td class="titlefieldcreate">' . $langs->trans(
'PaymentMode') .
'</td><td class="valuefieldcreate">';
2664 print img_picto(
'',
'bank',
'class="pictofixedwidth"');
2665 print $form->select_types_paiements((
string) $mode_reglement_id,
'mode_reglement_id',
'CRDT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx', 1);
2670 print
'<tr class="field_fk_account"><td class="titlefieldcreate">' . $langs->trans(
'BankAccount') .
'</td><td class="valuefieldcreate">';
2671 print img_picto(
'',
'bank_account',
'class="pictofixedwidth"') . $form->select_comptes((
int) $fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
2676 print
'<tr class="field_demand_reason_id"><td class="titlefieldcreate">' . $langs->trans(
'Source') .
'</td><td class="valuefieldcreate">';
2677 print img_picto(
'',
'question',
'class="pictofixedwidth"');
2678 $form->selectInputReason((
GETPOSTISSET(
'demand_reason_id') ?
GETPOSTINT(
'demand_reason_id') :
''),
'demand_reason_id',
"SRC_PROP", 1,
'maxwidth200 widthcentpercentminusx');
2683 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($soc->shipping_method_id)) {
2684 $shipping_method_id = $soc->shipping_method_id;
2686 print
'<tr class="field_shipping_method_id"><td class="titlefieldcreate">' . $langs->trans(
'SendingMethod') .
'</td><td class="valuefieldcreate">';
2687 print img_picto(
'',
'dolly',
'class="pictofixedwidth"');
2688 $form->selectShippingMethod((
string) $shipping_method_id,
'shipping_method_id',
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx');
2692 $formproduct =
null;
2695 require_once DOL_DOCUMENT_ROOT .
'/product/class/html.formproduct.class.php';
2697 print
'<tr class="field_warehouse_id"><td class="titlefieldcreate">' . $langs->trans(
'Warehouse') .
'</td><td class="valuefieldcreate">';
2698 print img_picto(
'',
'stock',
'class="pictofixedwidth"') . $formproduct->selectWarehouses((
int) $warehouse_id,
'warehouse_id',
'', 1, 0, 0,
'', 0, 0, array(),
'maxwidth500 widthcentpercentminusxx');
2703 print
'<tr class="field_availability_id"><td class="titlefieldcreate">' . $langs->trans(
'AvailabilityPeriod');
2705 print
' (' . $langs->trans(
'AfterOrder') .
')';
2707 print
'</td><td class="valuefieldcreate">';
2708 print img_picto(
'',
'clock',
'class="pictofixedwidth"');
2709 print $form->selectAvailabilityDelay((
GETPOSTISSET(
'availability_id') ?
GETPOSTINT(
'availability_id') :
''),
'availability_id',
'', 1,
'maxwidth200 widthcentpercentminusx', 1);
2713 print
'<tr class="field_date_livraison"><td class="titlefieldcreate">' . $langs->trans(
"DeliveryDate") .
'</td>';
2714 print
'<td class="valuefieldcreate">';
2715 print img_picto(
'',
'action',
'class="pictofixedwidth"');
2718 $syear =
date(
"Y", $tmpdte);
2719 $smonth =
date(
"m", $tmpdte);
2720 $sday =
date(
"d", $tmpdte);
2721 print $form->selectDate($syear .
"-" . $smonth .
"-" . $sday,
'date_livraison', 0, 0, 0,
"addprop");
2723 $tmp_date_delivery =
GETPOST(
'date_delivery') ?: -1;
2724 print $form->selectDate($tmp_date_delivery,
'date_livraison', 0, 0, 0,
"addprop", 1, 1);
2729 if (
isModEnabled(
'project') && is_object($formproject)) {
2730 $langs->load(
"projects");
2731 print
'<tr class="field_projectid">';
2732 print
'<td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td class="valuefieldcreate">';
2733 print img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects((($soc->id > 0 && !
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_CUSTOMERS')) ? $soc->id : -1), (string) $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx');
2734 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 paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
2741 print
'<tr class="field_incoterm_id">';
2742 print
'<td class="titlefieldcreate"><label for="incoterm_id">' . $form->textwithpicto($langs->trans(
"IncotermLabel"), $soc->label_incoterms, 1) .
'</label></td>';
2743 print
'<td class="valuefieldcreate maxwidthonsmartphone">';
2744 print img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2745 print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms :
''), (!empty($soc->location_incoterms) ? $soc->location_incoterms :
''));
2750 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
2751 print $form->selectCategories(Categorie::TYPE_PROPOSAL,
'categories', $object);
2755 include_once DOL_DOCUMENT_ROOT .
'/core/modules/propale/modules_propale.php';
2757 if (is_array($list) && count($list) > 0) {
2758 print
'<tr class="field_model">';
2759 print
'<td class="titlefieldcreate">' . $langs->trans(
"DefaultModel") .
'</td>';
2760 print
'<td class="valuefieldcreate">';
2761 print img_picto(
'',
'pdf',
'class="pictofixedwidth"');
2763 print $form->selectarray(
'model', $list, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
2769 print
'<tr class="field_currency">';
2770 print
'<td class="titlefieldcreate">' . $form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0) .
'</td>';
2771 print
'<td class="valuefieldcreate maxwidthonsmartphone">';
2772 print img_picto(
'',
'currency',
'class="pictofixedwidth"') . $form->selectMultiCurrency(((
GETPOSTISSET(
'multicurrency_code') && !
GETPOST(
'changecompany')) ?
GETPOST(
'multicurrency_code') : $currency_code),
'multicurrency_code', 0,
'', false,
'maxwidth200 widthcentpercentminusx');
2777 print
'<tr class="field_note_public">';
2778 print
'<td class="titlefieldcreate tdtop">' . $langs->trans(
'NotePublic') .
'</td>';
2779 print
'<td class="valuefieldcreate">';
2780 $note_public =
GETPOST(
'note_public',
'restricthtml');
2781 if (!
GETPOSTISSET(
'note_public') && empty($note_public) && !empty($objectsrc)) {
2782 $note_public = $objectsrc->note_public;
2784 $doleditor =
new DolEditor(
'note_public', (
string) $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
2785 print $doleditor->Create(1);
2788 if (empty($user->socid)) {
2789 print
'<tr class="field_note_private">';
2790 print
'<td class="titlefieldcreate tdtop">' . $langs->trans(
'NotePrivate') .
'</td>';
2791 print
'<td class="valuefieldcreate">';
2792 $note_private =
GETPOST(
'note_private',
'restricthtml');
2793 if (!
GETPOSTISSET(
'note_private') && empty($note_private) && !empty($objectsrc)) {
2794 $note_private = $objectsrc->note_private;
2796 $doleditor =
new DolEditor(
'note_private', (
string) $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
2797 print $doleditor->Create(1);
2803 if (
getDolGlobalInt(
'THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_PROPAL') && $socid > 0) {
2804 $thirdpartytopropagateextrafieldsfrom = $soc;
2806 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_add.tpl.php';
2809 if (!empty($origin) && !empty($originid) && is_object($objectsrc) && !empty($classname)) {
2811 if ($origin ==
'contrat') {
2813 $objectsrc->update_price(1,
'auto', 1);
2816 print
"\n<!-- " . $classname .
" info -->";
2818 print
'<input type="hidden" name="amount" value="' . $objectsrc->total_ht .
'">' .
"\n";
2819 print
'<input type="hidden" name="total" value="' . $objectsrc->total_ttc .
'">' .
"\n";
2820 print
'<input type="hidden" name="tva" value="' . $objectsrc->total_tva .
'">' .
"\n";
2821 print
'<input type="hidden" name="origin" value="' . $objectsrc->element .
'">';
2822 print
'<input type="hidden" name="originid" value="' . $objectsrc->id .
'">';
2824 $newclassname = $classname;
2825 if ($newclassname ==
'Propal') {
2826 $newclassname =
'CommercialProposal';
2827 } elseif ($newclassname ==
'Commande') {
2828 $newclassname =
'Order';
2829 } elseif ($newclassname ==
'Expedition') {
2830 $newclassname =
'Sending';
2831 } elseif ($newclassname ==
'Fichinter') {
2832 $newclassname =
'Intervention';
2835 print
'<tr><td>' . $langs->trans($newclassname) .
'</td><td>' . $objectsrc->getNomUrl(1) .
'</td></tr>';
2836 print
'<tr><td>' . $langs->trans(
'AmountHT') .
'</td><td>' .
price($objectsrc->total_ht, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td></tr>';
2837 print
'<tr><td>' . $langs->trans(
'AmountVAT') .
'</td><td>' .
price($objectsrc->total_tva, 0, $langs, 1, -1, -1,
$conf->currency) .
"</td></tr>";
2838 if (
$mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
2839 print
'<tr><td>' . $langs->transcountry(
"AmountLT1",
$mysoc->country_code) .
'</td><td>' .
price($objectsrc->total_localtax1, 0, $langs, 1, -1, -1,
$conf->currency) .
"</td></tr>";
2842 if (
$mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
2843 print
'<tr><td>' . $langs->transcountry(
"AmountLT2",
$mysoc->country_code) .
'</td><td>' .
price($objectsrc->total_localtax2, 0, $langs, 1, -1, -1,
$conf->currency) .
"</td></tr>";
2845 print
'<tr><td>' . $langs->trans(
'AmountTTC') .
'</td><td>' .
price($objectsrc->total_ttc, 0, $langs, 1, -1, -1,
$conf->currency) .
"</td></tr>";
2848 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
'</td></tr>';
2849 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
"</td></tr>";
2850 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
"</td></tr>";
2862 print
'<input type="hidden" name="createmode" value="empty">';
2866 print
'<br><table>';
2870 print
'<td><input type="radio" name="createmode" value="copy"></td>';
2871 print
'<td>' . $langs->trans(
"CopyPropalFrom") .
' </td>';
2873 $liste_propal = array();
2874 $liste_propal[0] =
'';
2876 $sql =
"SELECT p.rowid as id, p.ref, s.nom";
2877 $sql .=
" FROM " . MAIN_DB_PREFIX .
"propal p";
2878 $sql .=
", " . MAIN_DB_PREFIX .
"societe s";
2879 $sql .=
" WHERE s.rowid = p.fk_soc";
2880 $sql .=
" AND p.entity IN (" .
getEntity(
'propal') .
")";
2881 $sql .=
" AND p.fk_statut <> 0";
2882 $sql .=
" ORDER BY Id";
2884 $resql = $db->query($sql);
2886 $num = $db->num_rows($resql);
2889 $row = $db->fetch_row($resql);
2890 $propalRefAndSocName = $row[1] .
" - " . $row[2];
2891 $liste_propal[$row[0]] = $propalRefAndSocName;
2894 print $form->selectarray(
"copie_propal", $liste_propal, 0);
2896 dol_print_error($db);
2900 print
'<tr><td class="tdtop"><input type="radio" name="createmode" value="empty" checked></td>';
2901 print
'<td valign="top" colspan="2">' . $langs->trans(
"CreateEmptyPropal") .
'</td></tr>';
2908 $langs->load(
"bills");
2910 print $form->buttonsSaveCancel(
"CreateDraft");
2916 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2919 $title = $langs->trans(
'ProductsAndServices');
2922 print
'<div class="div-table-responsive-no-min">';
2923 print
'<table class="noborder centpercent">';
2925 $objectsrc->printOriginLinesList();
2942 print
dol_get_fiche_head($head,
'comm', $langs->trans(
'Proposal'), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
2947 if ($action ==
'clone') {
2949 $filter =
'(s.client:IN:1,2,3)';
2950 $formquestion = array(
2953 array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter,
'', 0, 0, array(), 0,
'maxwidth300')),
2954 array(
'type' =>
'checkbox',
'name' =>
'update_prices',
'label' => $langs->trans(
'PuttingPricesUpToDate'),
'value' => 0),
2955 array(
'type' =>
'checkbox',
'name' =>
'update_desc',
'label' => $langs->trans(
'PuttingDescUpToDate'),
'value' => 0),
2958 $formquestion[] = array(
'type' =>
'date',
'name' =>
'date_delivery',
'label' => $langs->trans(
"DeliveryDate"),
'value' =>
$object->delivery_date);
2961 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmClonePropal',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1, 0, 600);
2965 if ($action ==
'add_title_line') {
2966 $langs->load(
'subtotals');
2968 $depth_array =
$object->getPossibleLevels($langs);
2970 } elseif ($action ==
'add_subtotal_line') {
2971 $langs->load(
'subtotals');
2973 $titles =
$object->getPossibleTitles();
2975 } elseif ($action ==
'add_text_line') {
2976 $langs->load(
'subtotals');
2981 if ($action ==
'closeas') {
2983 $formquestion = array();
2985 $formquestion[] = array(
'type' =>
'select',
'name' =>
'statut',
'label' =>
'<span class="fieldrequired">' . $langs->trans(
"CloseAs") .
'</span>',
'values' => array($object::STATUS_SIGNED =>
$object->LibStatut($object::STATUS_SIGNED), $object::STATUS_NOTSIGNED =>
$object->LibStatut($object::STATUS_NOTSIGNED)));
2987 $formquestion[] = array(
'type' =>
'text',
'name' =>
'note_private',
'label' => $langs->trans(
"Note"),
'value' =>
'');
2989 if (
getDolGlobalInt(
'PROPOSAL_SUGGEST_DOWN_PAYMENT_INVOICE_CREATION')) {
2994 $deposit_percent_from_payment_terms =
getDictionaryValue(
'c_payment_term',
'deposit_percent',
$object->cond_reglement_id);
2996 if (!empty($deposit_percent_from_payment_terms) &&
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')) {
2997 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
3001 $eligibleForDepositGeneration =
true;
3003 if (array_key_exists(
'facture',
$object->linkedObjects)) {
3004 foreach (
$object->linkedObjects[
'facture'] as $invoice) {
3005 '@phan-var-force Facture $invoice';
3008 $eligibleForDepositGeneration =
false;
3014 if ($eligibleForDepositGeneration && array_key_exists(
'commande',
$object->linkedObjects)) {
3015 foreach (
$object->linkedObjects[
'commande'] as $order) {
3016 $order->fetchObjectLinked();
3018 if (array_key_exists(
'facture', $order->linkedObjects)) {
3019 foreach ($order->linkedObjects[
'facture'] as $invoice) {
3020 '@phan-var-force Facture $invoice';
3023 $eligibleForDepositGeneration =
false;
3032 if ($eligibleForDepositGeneration) {
3033 $formquestion[] = array(
3034 'type' =>
'checkbox',
3035 'tdclass' =>
'showonlyifsigned',
3036 'name' =>
'generate_deposit',
3037 'morecss' =>
'margintoponly marginbottomonly',
3038 'label' => $form->textwithpicto($langs->trans(
'GenerateDeposit',
$object->deposit_percent), $langs->trans(
'DepositGenerationPermittedByThePaymentTermsSelected'))
3041 $formquestion[] = array(
3043 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
3045 'label' => $langs->trans(
'DateInvoice'),
3051 $formquestion[] = array(
3053 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
3054 'name' =>
'date_pointoftax',
3055 'label' => $langs->trans(
'DatePointOfTax'),
3061 $paymentTermsSelect = $form->getSelectConditionsPaiements(0,
'cond_reglement_id', -1, 0, 1,
'minwidth200');
3063 $formquestion[] = array(
3065 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
3066 'name' =>
'cond_reglement_id',
3067 'label' => $langs->trans(
'PaymentTerm'),
3068 'value' => $paymentTermsSelect
3071 $formquestion[] = array(
3072 'type' =>
'checkbox',
3073 'tdclass' =>
'showonlyifgeneratedeposit',
3074 'name' =>
'validate_generated_deposit',
3075 'morecss' =>
'margintoponly marginbottomonly',
3076 'label' => $langs->trans(
'ValidateGeneratedDeposit')
3079 $formquestion[] = array(
3080 'type' =>
'onecolumn',
3083 let signedValue = ' . $object::STATUS_SIGNED .
';
3085 $(document).ready(function() {
3086 $("[name=generate_deposit]").change(function () {
3087 let $self = $(this);
3088 let $target = $(".showonlyifgeneratedeposit").parent(".tagtr");
3090 if (! $self.parents(".tagtr").is(":hidden") && $self.is(":checked")) {
3099 $("#statut").change(function() {
3100 let $target = $(".showonlyifsigned").parent(".tagtr");
3102 if ($(this).val() == signedValue) {
3108 $("[name=generate_deposit]").trigger("change");
3113 $("#statut").trigger("change");
3123 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
3124 $notify =
new Notify($db);
3125 $formquestion = array_merge($formquestion, array(
3126 array(
'type' =>
'onecolumn',
'value' => $notify->confirmMessage(
'PROPAL_CLOSE_SIGNED',
$object->socid, $object)),
3131 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'SetAcceptedRefused'),
'',
'confirm_closeas', $formquestion,
'', 1, 250);
3133 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?statut=3&id=' .
$object->id, $langs->trans(
'Close'),
'',
'confirm_closeas', $formquestion,
'', 1, 250);
3135 } elseif ($action ==
'cancel') {
3137 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
"CancelPropal"), $langs->trans(
'ConfirmCancelPropal',
$object->ref),
'confirm_cancel',
'', 0, 1);
3138 } elseif ($action ==
'delete') {
3140 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'DeleteProp'), $langs->trans(
'ConfirmDeleteProp',
$object->ref),
'confirm_delete',
'', 0, 1);
3141 } elseif ($action ==
'reopen') {
3143 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'ReOpen'), $langs->trans(
'ConfirmReOpenProp',
$object->ref),
'confirm_reopen',
'', 0, 1);
3144 } elseif ($action ==
'ask_deleteline') {
3146 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
3147 } elseif ($action ==
'ask_updatelinkedbuyingprice') {
3149 $labels = array(
'propal' =>
'Proposal',
'commande' =>
'Order',
'facture' =>
'Invoice');
3150 $formquestion = array(array(
'type' =>
'hidden',
'name' =>
'lineid',
'value' => $lineid));
3151 foreach (
$object->getLinkedBuyPriceDocuments($user, $lineid) as $element => $document) {
3152 $formquestion[] = array(
'type' =>
'checkbox',
'name' =>
'updatelinked_' . $element,
'label' => $langs->trans($labels[$element]) .
' ' .
dol_escape_htmltag(implode(
', ', $document[
'refs'])),
'value' => ($element !=
'facture'));
3154 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id, $langs->trans(
'UpdateLinkedBuyingPrice'), $langs->trans(
'UpdateLinkedBuyingPriceQuestion'),
'confirm_updatelinkedbuyingprice', $formquestion,
'yes', 1);
3155 } elseif ($action ==
'ask_subtotal_deleteline') {
3157 $langs->load(
"subtotals");
3158 $title =
"DeleteSubtotalLine";
3159 $question =
"ConfirmDeleteSubtotalLine";
3160 if (
GETPOST(
'type') ==
'title') {
3161 $formconfirm = array(array(
'type' =>
'checkbox',
'name' =>
'deletecorrespondingsubtotalline',
'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
'value' => 0));
3162 $title =
"DeleteTitleLine";
3163 $question =
"ConfirmDeleteTitleLine";
3165 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
3166 } elseif ($action ==
'validate') {
3171 $ref = substr(
$object->ref, 1, 4);
3172 if ($ref ==
'PROV' || $ref ==
'') {
3173 $numref =
$object->getNextNumRef($soc);
3174 if (empty($numref)) {
3179 $numref = (string)
$object->ref;
3182 $text = $langs->trans(
'ConfirmValidateProp', $numref);
3184 require_once DOL_DOCUMENT_ROOT .
'/core/class/notify.class.php';
3185 $notify =
new Notify($db);
3187 $text .= $notify->confirmMessage(
'PROPAL_VALIDATE',
$object->socid, $object);
3192 foreach (
$object->lines as $line) {
3193 $res = $line->fetch_product();
3195 if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end))) {
3201 if ($nbMandated > 0) {
3203 setEventMessages($langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate"),
null,
'errors');
3206 $text .=
'<div><span class="clearboth nowraponall warning">' . img_warning() . $langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate") .
'</span></div>';
3211 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'ValidateProp'), $text,
'confirm_validate',
'', 0, 1, 240);
3216 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
3217 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
3218 if (empty($reshook)) {
3219 $formconfirm .= $hookmanager->resPrint;
3220 } elseif ($reshook > 0) {
3221 $formconfirm = $hookmanager->resPrint;
3230 $linkback =
'<a href="' . DOL_URL_ROOT .
'/comm/propal/list.php?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
"BackToList") .
'</a>';
3232 $morehtmlref =
'<div class="refidno">';
3234 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client',
$object->ref_client, $object, $usercancreate,
'string',
'', 0, 1);
3235 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'ref_client',
$object->ref_client, $object, $usercancreate,
'string' . (isset(
$conf->global->THIRDPARTY_REF_INPUT_SIZE) ?
':' .
getDolGlobalString(
'THIRDPARTY_REF_INPUT_SIZE') :
''),
'', null, null,
'', 1);
3237 $morehtmlref .=
'<br>' . $soc->getNomUrl(1,
'customer');
3239 $morehtmlref .=
' (<a href="' . DOL_URL_ROOT .
'/comm/propal/list.php?socid=' . ((int) $soc->id) .
'">' . $langs->trans(
"OtherProposals") .
'</a>)';
3243 $langs->load(
"projects");
3244 $morehtmlref .=
'<br>';
3245 if ($usercancreate) {
3246 $morehtmlref .= img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
3247 if ($action !=
'classify') {
3248 $morehtmlref .=
'<a class="editfielda" href="' . $_SERVER[
'PHP_SELF'] .
'?action=classify&token=' .
newToken() .
'&id=' .
$object->id .
'">' . img_edit($langs->transnoentitiesnoconv(
'SetProject')) .
'</a> ';
3250 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->socid, (
string)
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
3252 if (!empty(
$object->fk_project)) {
3254 $proj->fetch(
$object->fk_project);
3255 $morehtmlref .= $proj->getNomUrl(1);
3257 $morehtmlref .=
'<span class="opacitymedium"> - ' .
dol_escape_htmltag($proj->title) .
'</span>';
3262 $morehtmlref .=
'</div>';
3265 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
3268 $parameters = array();
3270 $reshook = $hookmanager->executeHooks(
'tabContentViewProposal', $parameters, $object, $action);
3271 if (empty($reshook)) {
3272 print
'<div class="fichecenter">';
3273 print
'<div class="fichehalfleft">';
3274 print
'<div class="underbanner clearboth"></div>';
3276 print
'<table class="border tableforfield centpercent">';
3280 $filterabsolutediscount =
"fk_facture_source IS NULL";
3281 $filtercreditnote =
"fk_facture_source IS NOT NULL";
3283 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
3284 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
3287 print
'<tr><td class="titlefieldmax45">' . $langs->trans(
'Discounts') .
'</td><td>';
3289 $absolute_discount = $soc->getAvailableDiscounts(
null, $filterabsolutediscount);
3290 $absolute_creditnote = $soc->getAvailableDiscounts(
null, $filtercreditnote);
3291 $absolute_discount =
price2num($absolute_discount,
'MT');
3292 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
3298 $backtopage = $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id;
3299 include DOL_DOCUMENT_ROOT .
'/core/tpl/object_discounts.tpl.php';
3315 print $form->editfieldkey(
"DatePropal",
'date',
'', $object, (
int) $editenable);
3316 print
'</td><td class="valuefield">';
3317 if ($action ==
'editdate' && $usercancreate && $caneditfield) {
3318 print
'<form name="editdate" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
3319 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3320 print
'<input type="hidden" name="action" value="setdate">';
3321 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
3322 print $form->selectDate(
$object->date,
're', 0, 0, 0,
"editdate");
3323 print
'<input type="submit" class="button button-edit" value="' . $langs->trans(
'Modify') .
'">';
3337 print
'<table class="nobordernopadding centpercent"><tr><td>';
3338 print $langs->trans(
'DateEndPropal');
3340 if ($action !=
'editecheance' && $usercancreate && $caneditfield) {
3341 print
'<td class="right"><a class="editfielda" href="' . $_SERVER[
"PHP_SELF"] .
'?action=editecheance&token=' .
newToken() .
'&id=' .
$object->id .
'">' . img_edit($langs->trans(
'SetConditions'), 1) .
'</a></td>';
3343 print
'</tr></table>';
3344 print
'</td><td class="valuefield">';
3345 if ($action ==
'editecheance' && $usercancreate && $caneditfield) {
3346 print
'<form name="editecheance" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="post">';
3347 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
3348 print
'<input type="hidden" name="action" value="setecheance">';
3349 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
3350 print $form->selectDate(
$object->fin_validite,
'ech', 0, 0, 0,
"editecheance");
3351 print
'<input type="submit" class="button button-edit" value="' . $langs->trans(
'Modify') .
'">';
3354 if (!empty(
$object->fin_validite)) {
3357 print img_warning($langs->trans(
"Late"));
3368 print
'<table class="nobordernopadding centpercent"><tr><td>';
3369 print $langs->trans(
'PaymentConditionsShort');
3371 if ($action !=
'editconditions' && $usercancreate && $caneditfield) {
3372 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>';
3374 print
'</tr></table>';
3375 print
'</td><td class="valuefield">';
3376 if ($action ==
'editconditions' && $usercancreate && $caneditfield) {
3377 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 0,
'', 1,
$object->deposit_percent);
3379 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->cond_reglement_id,
'none', 0,
'', 1,
$object->deposit_percent);
3385 print
'<tr class="field_mode_reglement_id">';
3387 print
'<table class="nobordernopadding centpercent"><tr><td>';
3388 print $langs->trans(
'PaymentMode');
3390 if ($action !=
'editmode' && $usercancreate && $caneditfield) {
3391 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>';
3393 print
'</tr></table>';
3394 print
'</td><td class="valuefieldcreate">';
3395 if ($action ==
'editmode' && $usercancreate && $caneditfield) {
3396 $form->form_modes_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
3398 $form->form_modes_reglement($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->mode_reglement_id,
'none');
3403 print
'<tr class="fielddeliverydelay"><td>';
3404 print
'<table class="nobordernopadding centpercent"><tr><td>';
3406 print $form->textwithpicto($langs->trans(
'AvailabilityPeriod'), $langs->trans(
'AvailabilityPeriod') .
' (' . $langs->trans(
'AfterOrder') .
')');
3408 print $langs->trans(
'AvailabilityPeriod');
3411 if ($action !=
'editavailability' && $usercancreate && $caneditfield) {
3412 print
'<td class="right"><a class="editfielda" href="' . $_SERVER[
"PHP_SELF"] .
'?action=editavailability&token=' .
newToken() .
'&id=' .
$object->id .
'">' . img_edit($langs->transnoentitiesnoconv(
'SetAvailability'), 1) .
'</a></td>';
3414 print
'</tr></table>';
3415 print
'</td><td class="valuefield">';
3416 if ($action ==
'editavailability' && $usercancreate && $caneditfield) {
3417 $form->form_availability($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->availability_id,
'availability_id', $langs->trans(
"Delay"));
3419 $form->form_availability($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->availability_id,
'none', 1);
3427 print $form->editfieldkey($langs->trans(
'DeliveryDate'),
'date_livraison',
$object->delivery_date, $object, (
int) ($usercancreate && $caneditfield),
'datepicker');
3428 print
'</td><td class="valuefieldedit">';
3429 print $form->editfieldval($langs->trans(
'DeliveryDate'),
'date_livraison',
$object->delivery_date, $object, $usercancreate && $caneditfield,
'datepicker');
3436 print
'<table class="nobordernopadding centpercent"><tr><td>';
3437 print $langs->trans(
'SendingMethod');
3439 if ($action !=
'editshippingmethod' && $usercancreate && $caneditfield) {
3440 print
'<td class="right"><a class="editfielda" href="' . $_SERVER[
"PHP_SELF"] .
'?action=editshippingmethod&token=' .
newToken() .
'&id=' .
$object->id .
'">' . img_edit($langs->trans(
'SetShippingMode'), 1) .
'</a></td>';
3442 print
'</tr></table>';
3443 print
'</td><td class="valuefield">';
3444 if ($action ==
'editshippingmethod' && $usercancreate && $caneditfield) {
3445 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->shipping_method_id,
'shipping_method_id', 1);
3447 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->shipping_method_id,
'none');
3455 $langs->load(
'stocks');
3456 require_once DOL_DOCUMENT_ROOT .
'/product/class/html.formproduct.class.php';
3458 print
'<tr class="field_warehouse_id"><td>';
3459 $editenable = $usercancreate;
3460 print $form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, $editenable);
3461 print
'</td><td class="valuefieldcreate">';
3462 if ($action ==
'editwarehouse') {
3463 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->warehouse_id,
'warehouse_id', 1);
3465 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->warehouse_id,
'none');
3473 print
'<table class="nobordernopadding centpercent"><tr><td>';
3474 print $langs->trans(
'Source');
3476 if ($action !=
'editdemandreason' && $usercancreate) {
3477 print
'<td class="right"><a class="editfielda" href="' . $_SERVER[
"PHP_SELF"] .
'?action=editdemandreason&token=' .
newToken() .
'&id=' .
$object->id .
'">' . img_edit($langs->transnoentitiesnoconv(
'SetDemandReason'), 1) .
'</a></td>';
3479 print
'</tr></table>';
3480 print
'</td><td class="valuefield">';
3481 if ($action ==
'editdemandreason' && $usercancreate) {
3482 $form->formInputReason($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->demand_reason_id,
'demand_reason_id', 1);
3484 $form->formInputReason($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->demand_reason_id,
'none');
3489 if ($soc->outstanding_limit) {
3492 print $langs->trans(
'OutstandingBill');
3493 print
'</td><td class="valuefield">';
3494 $arrayoutstandingbills = $soc->getOutstandingBills();
3495 print($arrayoutstandingbills[
'opened'] > $soc->outstanding_limit ? img_warning() :
'');
3496 print
price($arrayoutstandingbills[
'opened']) .
' / ';
3497 print
price($soc->outstanding_limit, 0, $langs, 1, -1, -1,
$conf->currency);
3505 print
'<table width="100%" class="nobordernopadding"><tr><td>';
3506 print $langs->trans(
'BankAccount');
3508 if ($action !=
'editbankaccount' && $usercancreate) {
3509 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>';
3511 print
'</tr></table>';
3512 print
'</td><td class="valuefield">';
3513 if ($action ==
'editbankaccount') {
3514 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
3516 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_account,
'none');
3523 $tmparray =
$object->getTotalWeightVolume();
3524 $totalWeight = isset($tmparray[
'weight']) ? $tmparray[
'weight'] : 0;
3525 $totalVolume = isset($tmparray[
'volume']) ? $tmparray[
'volume'] : 0;
3527 print
'<tr><td>' . $langs->trans(
"CalculatedWeight") .
'</td>';
3528 print
'<td class="valuefield">';
3533 print
'<tr><td>' . $langs->trans(
"CalculatedVolume") .
'</td>';
3534 print
'<td class="valuefield">';
3543 print
'<table width="100%" class="nobordernopadding"><tr><td>';
3544 print $langs->trans(
'IncotermLabel');
3545 print
'<td><td class="right">';
3546 if ($action !=
'editincoterm' && $usercancreate && $caneditfield) {
3547 print
'<a class="editfielda" href="' . DOL_URL_ROOT .
'/comm/propal/card.php?id=' .
$object->id .
'&action=editincoterm&token=' .
newToken() .
'">' . img_edit() .
'</a>';
3551 print
'</td></tr></table>';
3553 print
'<td class="valuefield">';
3554 if ($action ==
'editincoterm' && $usercancreate && $caneditfield) {
3555 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id);
3557 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3565 print
'<table class="nobordernopadding centpercent"><tr><td>';
3566 print $langs->trans(
"Categories");
3567 print
'<td><td class="right">';
3568 if ($usercancreate) {
3569 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/propal/card.php?id='.
$object->id.
'&action=edittags&token='.
newToken().
'">'.img_edit().
'</a>';
3573 print
'</td></tr></table>';
3576 if ($action ==
'edittags') {
3577 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
3578 print
'<input type="hidden" name="action" value="settags">';
3579 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3580 print $form->selectCategories(Categorie::TYPE_PROPOSAL,
'categories', $object);
3581 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
3584 print $form->showCategories(
$object->id, Categorie::TYPE_PROPOSAL, 1);
3590 include DOL_DOCUMENT_ROOT .
'/core/tpl/extrafields_view.tpl.php';
3595 print
'<div class="fichehalfright">';
3596 print
'<div class="underbanner clearboth"></div>';
3598 print
'<table class="border tableforfield centpercent">';
3600 include DOL_DOCUMENT_ROOT .
'/core/tpl/object_currency_amount.tpl.php';
3603 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
3604 print
'<td class="nowrap amountcard right" data-dol-field="total_ht">' .
price(
$object->total_ht, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
3606 print
'<td class="nowrap amountcard right" data-dol-field="multicurrency_total_ht">' .
price(
$object->multicurrency_total_ht, 0, $langs, 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3611 print
'<td>' . $langs->trans(
'AmountVAT') .
'</td>';
3612 print
'<td class="nowrap amountcard right" data-dol-field="total_tva">' .
price(
$object->total_tva, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
3614 print
'<td class="nowrap amountcard right" data-dol-field="multicurrency_total_tva">' .
price(
$object->multicurrency_total_tva, 0, $langs, 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3618 if (
$mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
3620 print
'<td>' . $langs->transcountry(
"AmountLT1",
$mysoc->country_code) .
'</td>';
3621 print
'<td class="nowrap amountcard right" data-dol-field="total_localtax1">' .
price(
$object->total_localtax1, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
3625 print
'<td class="nowrap amountcard right" data-dol-field="multicurrency_total_localtax1">' .
price(
$object->multicurrency_total_localtax1, 0, $langs, 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3630 if (
$mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
3632 print
'<td>' . $langs->transcountry(
"AmountLT2",
$mysoc->country_code) .
'</td>';
3633 print
'<td class="nowrap amountcard right" data-dol-field="total_localtax2">' .
price(
$object->total_localtax2, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
3637 print
'<td class="nowrap amountcard right" data-dol-field="multicurrency_total_localtax2">' .
price(
$object->multicurrency_total_localtax2, 0, $langs, 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3643 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
3644 print
'<td class="nowrap amountcard right" data-dol-field="total_ttc">' .
price(
$object->total_ttc, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
3646 print
'<td class="nowrap amountcard right" data-dol-field="multicurrency_total_ttc">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 1, -1, -1,
$object->multicurrency_code) .
'</td>';
3654 $formmargin->displayMarginInfos($object);
3660 print
'<div class="clearboth"></div><br>';
3663 $blocname =
'contacts';
3664 $title = $langs->trans(
'ContactsAddresses');
3665 include DOL_DOCUMENT_ROOT .
'/core/tpl/bloc_showhide.tpl.php';
3669 $blocname =
'notes';
3670 $title = $langs->trans(
'Notes');
3671 include DOL_DOCUMENT_ROOT .
'/core/tpl/bloc_showhide.tpl.php';
3679 $result =
$object->getLinesArray();
3683 global $inputalsopricewithtax;
3684 $inputalsopricewithtax = 1;
3686 print
' <form name="addproduct" id="addproduct" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'" method="POST">
3687 <input type="hidden" name="token" value="' .
newToken() .
'">
3688 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline') .
'">
3689 <input type="hidden" name="mode" value="">
3690 <input type="hidden" name="page_y" value="">
3691 <input type="hidden" name="backtopage" value="' . $backtopage .
'">
3692 <input type="hidden" name="id" value="' .
$object->id .
'">
3697 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_ajaxrow.tpl.php';
3699 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
3703 print
'<div class="div-table-responsive-no-min">';
3705 print
'<table id="tablelines" class="noborder noshadow centpercent">';
3714 if ($action !=
'editline') {
3715 $parameters = array();
3716 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
3718 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
3720 if (empty($reshook)) {
3724 $parameters = array();
3725 $reshook = $hookmanager->executeHooks(
'formEditObjectLine', $parameters, $object, $action);
3744 if ($action !=
'presend') {
3745 $numlines = count(
$object->lines);
3746 print
'<div class="tabsAction">';
3748 $parameters = array();
3749 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3751 if (empty($reshook)) {
3752 if ($action !=
'editline') {
3756 $langs->load(
'subtotals');
3758 $url_button = array();
3760 $url_button[] = array(
3761 'lang' =>
'subtotals',
3763 'perm' => (
bool) $usercancreate,
3764 'label' => $langs->trans(
'AddTitleLine'),
3765 'url' =>
'/comm/propal/card.php?id=' .
$object->id .
'&action=add_title_line&token=' .
newToken()
3768 $url_button[] = array(
3769 'lang' =>
'subtotals',
3771 'perm' => (
bool) $usercancreate,
3772 'label' => $langs->trans(
'AddSubtotalLine'),
3773 'url' =>
'/comm/propal/card.php?id=' .
$object->id .
'&action=add_subtotal_line&token=' .
newToken()
3776 $url_button[] = array(
3777 'lang' =>
'subtotals',
3779 'perm' => (
bool) $usercancreate,
3780 'label' => $langs->trans(
'AddTextLine'),
3781 'url' =>
'/comm/propal/card.php?id=' .
$object->id .
'&action=add_text_line&token=' .
newToken()
3784 print dolGetButtonAction(
'', $langs->trans(
'SubTotal'),
'default', $url_button,
'',
true);
3791 if ($usercanvalidate) {
3792 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=validate&token=' .
newToken() .
'">' . (!
getDolGlobalString(
'PROPAL_SKIP_ACCEPT_REFUSE') ? $langs->trans(
'Validate') : $langs->trans(
'ValidateAndSign')) .
'</a>';
3794 print
'<a class="butActionRefused classfortooltip" href="#">' . $langs->trans(
'Validate') .
'</a>';
3804 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=modif&token=' .
newToken() .
'">' . $langs->trans(
'Modify') .
'</a>';
3809 if ($usercanreopen) {
3810 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=reopen&token=' .
newToken() . (!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#reopen') .
'"';
3811 print
'>' . $langs->trans(
'ReOpen') .
'</a>';
3813 print
'<a class="butActionRefused classfortooltip" href="#" title="' . $langs->trans(
"NotEnoughPermissions") .
'">' . $langs->trans(
"ReOpen") .
'</a>';
3818 if (empty($user->socid)) {
3820 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"] .
'?action=presend&token=' .
newToken() .
'&id=' .
$object->id .
'&mode=init#formmailbeforetitle',
'', $usercansend);
3824 $arrayforbutaction = array();
3827 $arrayforbutaction[] = array(
3830 'perm' => $usercancreateorder,
3831 'label' =>
'AddOrder',
3832 'url' =>
'/commande/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id) .
'&socid=' . ((
int)
$object->socid)
3842 $arrayforbutaction[] = array(
3845 'perm' => $usercancreatepurchaseorder,
3846 'label' =>
'AddPurchaseOrder',
3847 'url' =>
'/fourn/commande/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id)
3857 $arrayforbutaction[] = array(
3858 'lang' =>
'interventions',
3860 'perm' => $usercancreateintervention,
3861 'label' =>
'AddIntervention',
3862 'url' =>
'/fichinter/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id) .
'&socid=' . ((
int)
$object->socid)
3872 $arrayforbutaction[] = array(
3873 'lang' =>
'contracts',
3875 'perm' => $usercancreatecontract,
3876 'label' =>
'AddContract',
3877 'url' =>
'/contrat/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((
int)
$object->id) .
'&socid=' . ((
int)
$object->socid)
3889 $arrayforbutaction[] = [
3890 'lang' =>
'invoice',
3892 'perm' => $usercancreateinvoice,
3893 'label' =>
'CreateBill',
3894 'url' =>
'/compta/facture/card.php?action=create&origin=' . urlencode(
$object->element) .
'&originid=' . ((int)
$object->id) .
'&socid=' . ((int)
$object->socid),
3901 $actionButtonsParameters = [
3902 "areDropdownButtons" => !
getDolGlobalInt(
"MAIN_REMOVE_DROPDOWN_CREATE_BUTTONS_ON_ORDER"),
3903 "backtopage" => $_SERVER[
"PHP_SELF"] .
"?id=" . ((int) $id)
3906 if ($numlines > 0) {
3907 print dolGetButtonAction(
'', $langs->trans(
"Create"),
'default', $arrayforbutaction, (
string)
$object->id, 1, $actionButtonsParameters);
3909 print dolGetButtonAction($langs->trans(
"ErrorObjectMustHaveLinesToBeValidated",
$object->ref), $langs->trans(
"Create"),
'default', $arrayforbutaction, (
string)
$object->id, 0, $actionButtonsParameters);
3913 $arrayofinvoiceforpropal =
$object->getInvoiceArrayList();
3914 if ((is_array($arrayofinvoiceforpropal) && count($arrayofinvoiceforpropal) > 0) || !
getDolGlobalString(
'WORKFLOW_PROPAL_NEED_INVOICE_TO_BE_CLASSIFIED_BILLED')) {
3915 if ($usercanclose) {
3916 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=classifybilled&token=' .
newToken() .
'&socid=' .
$object->socid .
'">' . $langs->trans(
"ClassifyBilled") .
'</a>';
3918 print
'<a class="butActionRefused classfortooltip" href="#" title="' . $langs->trans(
"NotEnoughPermissions") .
'">' . $langs->trans(
"ClassifyBilled") .
'</a>';
3926 if ($usercanclose) {
3927 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=closeas&token=' .
newToken() . (!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#close') .
'"';
3928 print
'>' . $langs->trans(
'SetAcceptedRefused') .
'</a>';
3930 print
'<a class="butActionRefused classfortooltip" href="#" title="' . $langs->trans(
"NotEnoughPermissions") .
'"';
3931 print
'>' . $langs->trans(
'SetAcceptedRefused') .
'</a>';
3937 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&token=' .
newToken() .
'&action=closeas&token=' .
newToken() . (!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#close') .
'"';
3938 print
'>' . $langs->trans(
'SetRefusedAndClose') .
'</a>';
3944 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=cancel&token=' .
newToken() .
'">' . $langs->trans(
"CancelPropal") .
'</a>';
3948 if ($usercancreate) {
3949 print dolGetButtonAction($langs->trans(
"ToClone"), $langs->trans(
"ToClone"),
'clone', $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'&socid=' .
$object->socid .
'&action=clone&token=' .
newToken() .
'&object=' .
$object->element,
'',
true, array(
'attr' => array(
'class' =>
'reposition')));
3953 print dolGetButtonAction($langs->trans(
"Delete"), $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=delete&token=' .
newToken(),
'delete', $usercandelete, array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
3961 if (
GETPOST(
'modelselected')) {
3962 $action =
'presend';
3965 if ($action !=
'presend') {
3966 print
'<div class="fichecenter"><div class="fichehalfleft">';
3967 print
'<a name="builddoc"></a>';
3973 $urlsource = $_SERVER[
"PHP_SELF"] .
"?id=" .
$object->id;
3974 $genallowed = $usercanread;
3975 $delallowed = $usercancreate;
3976 $tooltipAfterComboOfModels =
'';
3978 $tooltipAfterComboOfModels = $langs->trans(
"AccordingToYourSetupTheFileWillBeConcatenated",
getDolGlobalString(
'MAIN_INFO_PROPAL_TERMSOFSALE'));
3981 print $formfile->showdocuments(
'propal', $objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'0',
'', $soc->default_lang,
'', $object, 0,
'remove_file', $tooltipAfterComboOfModels);
3984 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'propal'), 1);
3985 $linktoelem = $tmparray[
'linktoelem'];
3986 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
3987 print $htmltoenteralink;
3989 $compatibleImportElementsList =
false;
3991 $compatibleImportElementsList = array(
'commande',
'propal',
'facture',
'subscription');
3993 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList);
3999 print
'<br><!-- Link to sign -->';
4000 require_once DOL_DOCUMENT_ROOT .
'/core/lib/signature.lib.php';
4001 print showOnlineSignatureUrl(
'proposal',
$object->ref, $object) .
'<br>';
4004 print
'</div><div class="fichehalfright">';
4008 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT .
'/comm/propal/messaging.php?id=' .
$object->id);
4009 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT .
'/comm/propal/agenda.php?id=' .
$object->id);
4012 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formactions.class.php';
4014 $somethingshown = $formactions->showactions($object,
'propal', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
4016 print
'</div></div>';
4020 $modelmail =
'propal_send';
4021 $defaulttopic =
'SendPropalRef';
4023 $trackid =
'pro' .
$object->id;
4025 include DOL_DOCUMENT_ROOT .
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage a WYSIWYG editor.
static createDepositFromOrigin(CommonObject $origin, $date, $payment_terms_id, User $user, $notrigger=0, $autoValidateDeposit=false, $overrideFields=array())
Creates a deposit from a proposal or an order by grouping lines by VAT rates.
const TYPE_DEPOSIT
Deposit invoice.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage the table of subscription to notifications.
Class ProductCombination Used to represent the relation between a product and one of its variants.
File of class to manage predefined price products or services by customer.
Class to manage products or services.
Class to manage projects.
Class to manage proposals.
const STATUS_DRAFT
Draft status.
const STATUS_SIGNED
Signed quote.
const STATUS_NOTSIGNED
Not signed quote.
const STATUS_BILLED
Billed or processed quote.
const STATUS_CANCELED
Canceled status.
const STATUS_VALIDATED
Validated status.
Class to manage commercial proposal lines.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
$date_start
Variables from include:
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
price2num($amount, $rounding='', $option=0, $currencycode='')
Function that return a number with universal decimal format (decimal separator is '.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
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...
getDolCurrency()
Return the main currency ('EUR', 'USD', ...)
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalBool($key, $default=false)
Return a Dolibarr global constant boolean value.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
getWarningDelay($module, $parmlevel1, $parmlevel2='')
Return a warning delay You can use it like this: if (getWarningDelay('module', 'paramlevel1')) It rep...
getDictionaryValue($tablename, $field, $id, $checkentity=false, $rowidfield='rowid')
Return the value of a filed into a dictionary for the record $id.
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular VAT rate, when selling a product with vat $vatrate,...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
propal_prepare_head($object)
Prepare array with list of tabs.
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.