42require
'../../main.inc.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formpropal.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/modules/propale/modules_propale.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/lib/propal.lib.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
54if (isModEnabled(
'project')) {
55 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
56 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
59if (isModEnabled(
'variants')) {
60 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
64$langs->loadLangs(array(
'companies',
'propal',
'compta',
'bills',
'orders',
'products',
'deliveries',
'sendings',
'other'));
65if (isModEnabled(
'incoterm')) {
66 $langs->load(
'incoterm');
68if (isModEnabled(
'margin')) {
69 $langs->load(
'margins');
76$socid =
GETPOST(
'socid',
'int');
77$action =
GETPOST(
'action',
'aZ09');
78$cancel =
GETPOST(
'cancel',
'alpha');
79$origin =
GETPOST(
'origin',
'alpha');
80$originid =
GETPOST(
'originid',
'int');
81$confirm =
GETPOST(
'confirm',
'alpha');
82$backtopage =
GETPOST(
'backtopage',
'alpha');
83$lineid =
GETPOST(
'lineid',
'int');
84$contactid =
GETPOST(
'contactid',
'int');
85$projectid =
GETPOST(
'projectid',
'int');
97$extrafields->fetch_name_optionals_label($object->table_element);
100if ($id > 0 || !empty($ref)) {
101 $ret = $object->fetch($id, $ref);
103 $ret = $object->fetch_thirdparty();
104 if ($ret > 0 && isset($object->fk_project)) {
105 $ret = $object->fetch_project();
115$hookmanager->initHooks(array(
'propalcard',
'globalcard'));
117$usercanread = $user->hasRight(
"propal",
"lire");
118$usercancreate = $user->hasRight(
"propal",
"creer");
119$usercandelete = $user->hasRight(
"propal",
"supprimer");
121$usercanclose = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->propal->propal_advance->close)));
122$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->propal->propal_advance->validate)));
125$usermustrespectpricemin = ((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && empty($user->rights->produit->ignore_price_min_advance)) || !
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS'));
126$usercancreateorder = $user->hasRight(
'commande',
'creer');
127$usercancreateinvoice = $user->hasRight(
'facture',
'creer');
128$usercancreatecontract = $user->hasRight(
'contrat',
'creer');
129$usercancreateintervention = $user->hasRight(
'ficheinter',
'creer');
130$usercancreatepurchaseorder = ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'));
132$permissionnote = $usercancreate;
133$permissiondellink = $usercancreate;
134$permissiontoedit = $usercancreate;
137if (!empty($user->socid)) {
138 $socid = $user->socid;
147$parameters = array(
'socid' => $socid);
148$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
152if (empty($reshook)) {
153 $backurlforlist = DOL_URL_ROOT.
'/comm/propal/list.php';
155 if (empty($backtopage) || ($cancel && empty($id))) {
156 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
157 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
158 $backtopage = $backurlforlist;
160 $backtopage = DOL_URL_ROOT.
'/comm/propal/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
166 if (!empty($backtopageforcancel)) {
167 header(
"Location: ".$backtopageforcancel);
169 } elseif (!empty($backtopage)) {
170 header(
"Location: ".$backtopage);
176 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
178 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
180 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
183 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
185 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'IdThirdParty')),
null,
'errors');
187 if ($object->id > 0) {
194 GETPOST(
'date_deliverymonth',
'int'),
195 GETPOST(
'date_deliveryday',
'int'),
196 GETPOST(
'date_deliveryyear',
'int')
198 $date_delivery_old = $object->delivery_date;
199 if (!empty($date_delivery_old) && !empty($date_delivery)) {
210 $difference = $date_delivery - $old_date_delivery;
211 if ($difference != 0) {
212 $object->delivery_date = $date_delivery;
213 foreach ($object->lines as $line) {
214 if (isset($line->date_start)) {
215 $line->date_start = $line->date_start + $difference;
217 if (isset($line->date_end)) {
218 $line->date_end = $line->date_end + $difference;
225 $result = $object->createFromClone($user, $socid, (GETPOSTISSET(
'entity') ?
GETPOST(
'entity',
'int') : null), (
GETPOST(
'update_prices',
'aZ') ? true : false), (
GETPOST(
'update_desc',
'aZ') ? true : false));
227 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
230 if (count($object->errors) > 0) {
237 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
239 $result = $object->delete($user);
241 header(
'Location: '.DOL_URL_ROOT.
'/comm/propal/list.php?restore_lastsearch_values=1');
244 $langs->load(
"errors");
247 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
249 $result = $object->deleteline($lineid);
252 $object->line_order(
true);
254 $langs->load(
"errors");
260 $outputlangs = $langs;
263 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') : $object->thirdparty->default_lang);
264 $outputlangs->setDefaultLang($newlang);
266 $ret = $object->fetch($id);
268 $object->fetch_thirdparty();
270 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
273 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
275 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
277 $idwarehouse =
GETPOST(
'idwarehouse',
'int');
278 $result = $object->valid($user);
280 $result = $object->closeProposal($user, $object::STATUS_SIGNED);
284 $outputlangs = $langs;
287 $newlang =
GETPOST(
'lang_id',
'aZ09');
290 $newlang = $object->thirdparty->default_lang;
292 if (!empty($newlang)) {
294 $outputlangs->setDefaultLang($newlang);
296 $model = $object->model_pdf;
297 $ret = $object->fetch($id);
299 $object->fetch_thirdparty();
302 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
305 $langs->load(
"errors");
306 if (count($object->errors) > 0) {
312 } elseif ($action ==
'setdate' && $usercancreate) {
317 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
321 $result = $object->set_date($user, $datep);
322 if ($result > 0 && !empty($object->duree_validite) && !empty($object->fin_validite)) {
323 $datev = $datep + ($object->duree_validite * 24 * 3600);
324 $result = $object->set_echeance($user, $datev, 1);
329 $outputlangs = $langs;
332 $newlang =
GETPOST(
'lang_id',
'aZ09');
335 $newlang = $object->thirdparty->default_lang;
337 if (!empty($newlang)) {
339 $outputlangs->setDefaultLang($newlang);
341 $model = $object->model_pdf;
342 $ret = $object->fetch($id);
344 $object->fetch_thirdparty();
347 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
350 } elseif ($action ==
'setecheance' && $usercancreate) {
354 $outputlangs = $langs;
357 $newlang =
GETPOST(
'lang_id',
'aZ09');
360 $newlang = $object->thirdparty->default_lang;
362 if (!empty($newlang)) {
364 $outputlangs->setDefaultLang($newlang);
366 $model = $object->model_pdf;
367 $ret = $object->fetch($id);
369 $object->fetch_thirdparty();
372 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
377 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
378 $result = $object->setDeliveryDate($user,
dol_mktime(12, 0, 0,
GETPOST(
'date_livraisonmonth',
'int'),
GETPOST(
'date_livraisonday',
'int'),
GETPOST(
'date_livraisonyear',
'int')));
382 } elseif ($action ==
'setref_client' && $usercancreate) {
384 $result = $object->set_ref_client($user,
GETPOST(
'ref_client'));
388 } elseif ($action ==
'set_incoterms' && isModEnabled(
'incoterm') && $usercancreate) {
390 $result = $object->setIncoterms(
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
391 } elseif ($action ==
'add' && $usercancreate) {
393 $object->socid = $socid;
394 $object->fetch_thirdparty();
398 $duration =
GETPOST(
'duree_validite',
'int');
401 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DatePropal")),
null,
'errors');
405 if (empty($duration)) {
406 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ValidityDuration")),
null,
'errors');
412 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Customer")),
null,
'errors');
423 if ($object->fetch(
GETPOST(
'copie_propal',
'int')) > 0) {
425 $object->datep = $datep;
426 $object->date = $datep;
427 $object->delivery_date = $date_delivery;
428 $object->availability_id =
GETPOST(
'availability_id');
429 $object->demand_reason_id =
GETPOST(
'demand_reason_id');
430 $object->fk_delivery_address =
GETPOST(
'fk_address',
'int');
431 $object->shipping_method_id =
GETPOST(
'shipping_method_id',
'int');
432 $object->warehouse_id =
GETPOST(
'warehouse_id',
'int');
433 $object->duree_validite = $duration;
434 $object->cond_reglement_id =
GETPOST(
'cond_reglement_id');
435 $object->deposit_percent =
GETPOST(
'cond_reglement_id_deposit_percent',
'alpha');
436 $object->mode_reglement_id =
GETPOST(
'mode_reglement_id',
'int');
437 $object->fk_account =
GETPOST(
'fk_account',
'int');
438 $object->socid =
GETPOST(
'socid',
'int');
439 $object->contact_id =
GETPOST(
'contactid',
'int');
440 $object->fk_project =
GETPOST(
'projectid',
'int');
441 $object->model_pdf =
GETPOST(
'model',
'alphanohtml');
442 $object->author = $user->id;
443 $object->user_author_id = $user->id;
444 $object->note_private =
GETPOST(
'note_private',
'restricthtml');
445 $object->note_public =
GETPOST(
'note_public',
'restricthtml');
448 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
449 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
455 $object->ref_client =
GETPOST(
'ref_client');
456 $object->datep = $datep;
457 $object->date = $datep;
458 $object->delivery_date = $date_delivery;
459 $object->availability_id =
GETPOST(
'availability_id',
'int');
460 $object->demand_reason_id =
GETPOST(
'demand_reason_id',
'int');
461 $object->fk_delivery_address =
GETPOST(
'fk_address',
'int');
462 $object->shipping_method_id =
GETPOST(
'shipping_method_id',
'int');
463 $object->warehouse_id =
GETPOST(
'warehouse_id',
'int');
465 $object->cond_reglement_id =
GETPOST(
'cond_reglement_id',
'int');
466 $object->deposit_percent =
GETPOST(
'cond_reglement_id_deposit_percent',
'alpha');
467 $object->mode_reglement_id =
GETPOST(
'mode_reglement_id',
'int');
468 $object->fk_account =
GETPOST(
'fk_account',
'int');
469 $object->contact_id =
GETPOST(
'contactid',
'int');
470 $object->fk_project =
GETPOST(
'projectid',
'int');
471 $object->model_pdf =
GETPOST(
'model');
472 $object->author = $user->id;
473 $object->note_private =
GETPOST(
'note_private',
'restricthtml');
474 $object->note_public =
GETPOST(
'note_public',
'restricthtml');
475 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
476 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
478 $object->origin =
GETPOST(
'origin');
479 $object->origin_id =
GETPOST(
'originid');
482 if (isModEnabled(
"multicurrency")) {
483 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
487 $ret = $extrafields->setOptionalsFromPost(
null, $object);
495 if ($origin && $originid) {
497 $element = $subelement = $origin;
499 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
501 $subelement = $regs[2];
505 if ($element ==
'order') {
506 $element = $subelement =
'commande';
508 if ($element ==
'propal') {
509 $element =
'comm/propal';
510 $subelement =
'propal';
512 if ($element ==
'contract') {
513 $element = $subelement =
'contrat';
515 if ($element ==
'inter') {
516 $element = $subelement =
'ficheinter';
518 if ($element ==
'shipping') {
519 $element = $subelement =
'expedition';
522 $object->origin = $origin;
523 $object->origin_id = $originid;
526 $object->linked_objects [$object->origin] = $object->origin_id;
527 if (is_array($_POST[
'other_linked_objects']) && !empty($_POST[
'other_linked_objects'])) {
528 $object->linked_objects = array_merge($object->linked_objects, $_POST[
'other_linked_objects']);
531 $id = $object->create($user);
535 $classname = ucfirst($subelement);
536 $srcobject =
new $classname($db);
538 dol_syslog(
"Try to find source object origin=".$object->origin.
" originid=".$object->origin_id.
" to add lines");
539 $result = $srcobject->fetch($object->origin_id);
542 $lines = $srcobject->lines;
543 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
544 $srcobject->fetch_lines();
545 $lines = $srcobject->lines;
549 $num = count($lines);
550 for ($i = 0; $i < $num; $i++) {
551 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
552 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->label);
555 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
559 if ($lines[$i]->date_debut_prevue) {
560 $date_start = $lines[$i]->date_debut_prevue;
562 if ($lines[$i]->date_debut_reel) {
563 $date_start = $lines[$i]->date_debut_reel;
565 if ($lines[$i]->date_start) {
566 $date_start = $lines[$i]->date_start;
571 if ($lines[$i]->date_fin_prevue) {
572 $date_end = $lines[$i]->date_fin_prevue;
574 if ($lines[$i]->date_fin_reel) {
575 $date_end = $lines[$i]->date_fin_reel;
577 if ($lines[$i]->date_end) {
578 $date_end = $lines[$i]->date_end;
582 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
587 if (method_exists($lines[$i],
'fetch_optionals')) {
588 $lines[$i]->fetch_optionals();
589 $array_options = $lines[$i]->array_options;
592 $tva_tx = $lines[$i]->tva_tx;
593 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', $tva_tx)) {
594 $tva_tx .=
' ('.$lines[$i]->vat_src_code.
')';
597 $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,
'HT', 0, $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);
608 if ($result > 0 && $lines[$i]->product_type == 9) {
609 $fk_parent_line = $result;
614 $parameters = array(
'objFrom' => $srcobject);
615 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $object, $action);
631 $id = $object->create($user);
636 if (
GETPOST(
'contactid') > 0) {
637 $result = $object->add_contact(
GETPOST(
'contactid'),
'CUSTOMER',
'external');
645 $result = $object->add_contact($user->id,
'SALESREPFOLL',
'internal');
648 setEventMessages($langs->trans(
"ErrorFailedToAddUserAsContact"),
null,
'errors');
657 $outputlangs = $langs;
660 $newlang =
GETPOST(
'lang_id',
'aZ09');
663 $newlang = $object->thirdparty->default_lang;
665 if (!empty($newlang)) {
667 $outputlangs->setDefaultLang($newlang);
669 $model = $object->model_pdf;
671 $ret = $object->fetch($id);
672 $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
678 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
691 } elseif ($action ==
'classifybilled' && $usercanclose) {
695 $result = $object->classifyBilled($user, 0,
'');
706 } elseif ($action ==
'confirm_closeas' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
708 if (!(
GETPOST(
'statut',
'int') > 0)) {
709 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CloseAs")),
null,
'errors');
711 } elseif (
GETPOST(
'statut',
'int') == $object::STATUS_SIGNED ||
GETPOST(
'statut',
'int') == $object::STATUS_NOTSIGNED) {
712 $locationTarget =
'';
714 if ($object->statut == $object::STATUS_VALIDATED || (
getDolGlobalString(
'PROPAL_SKIP_ACCEPT_REFUSE') && $object->statut == $object::STATUS_DRAFT)) {
717 $result = $object->closeProposal($user,
GETPOST(
'statut',
'int'),
GETPOST(
'note_private',
'restricthtml'));
723 $locationTarget = DOL_URL_ROOT .
'/comm/propal/card.php?id=' . $object->id;
728 $deposit_percent_from_payment_terms =
getDictionaryValue(
'c_payment_term',
'deposit_percent', $object->cond_reglement_id);
731 !$error &&
GETPOST(
'statut',
'int') == $object::STATUS_SIGNED &&
GETPOST(
'generate_deposit',
'alpha') ==
'on'
732 && !empty($deposit_percent_from_payment_terms) && isModEnabled(
'facture') && $user->hasRight(
'facture',
'creer')
734 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
737 $forceFields = array();
739 if (GETPOSTISSET(
'date_pointoftax')) {
740 $forceFields[
'date_pointoftax'] =
dol_mktime(0, 0, 0,
GETPOST(
'date_pointoftaxmonth',
'int'),
GETPOST(
'date_pointoftaxday',
'int'),
GETPOST(
'date_pointoftaxyear',
'int'));
747 $locationTarget = DOL_URL_ROOT .
'/compta/facture/card.php?id=' . $deposit->id;
758 $ret = $deposit->fetch($deposit->id);
759 $outputlangs = $langs;
763 $outputlangs->setDefaultLang($deposit->thirdparty->default_lang);
764 $outputlangs->load(
'products');
767 $result = $deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
774 if ($locationTarget) {
775 header(
'Location: ' . $locationTarget);
784 } elseif ($action ==
'confirm_reopen' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
791 $result = $object->reopen($user, $newstatus);
796 $object->statut = $newstatus;
797 $object->status = $newstatus;
806 } elseif ($action ==
'import_lines_from_object'
807 && $user->hasRight(
'propal',
'creer')
811 $fromElement =
GETPOST(
'fromelement');
812 $fromElementid =
GETPOST(
'fromelementid');
813 $importLines =
GETPOST(
'line_checkbox');
815 if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) {
816 if ($fromElement ==
'commande') {
818 $lineClassName =
'OrderLine';
819 } elseif ($fromElement ==
'propal') {
820 dol_include_once(
'/comm/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
821 $lineClassName =
'PropaleLigne';
822 } elseif ($fromElement ==
'facture') {
823 dol_include_once(
'/compta/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
824 $lineClassName =
'FactureLigne';
826 $nextRang = count($object->lines) + 1;
829 foreach ($importLines as $lineId) {
830 $lineId = intval($lineId);
831 $originLine =
new $lineClassName($db);
832 if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) {
833 $originLine->fetch_optionals();
834 $desc = $originLine->desc;
835 $pu_ht = $originLine->subprice;
836 $qty = $originLine->qty;
837 $txtva = $originLine->tva_tx;
838 $txlocaltax1 = $originLine->localtax1_tx;
839 $txlocaltax2 = $originLine->localtax2_tx;
840 $fk_product = $originLine->fk_product;
841 $remise_percent = $originLine->remise_percent;
842 $date_start = $originLine->date_start;
843 $date_end = $originLine->date_end;
845 $info_bits = $originLine->info_bits;
846 $fk_remise_except = $originLine->fk_remise_except;
847 $price_base_type =
'HT';
849 $type = $originLine->product_type;
851 $special_code = $originLine->special_code;
852 $origin = $originLine->element;
853 $origin_id = $originLine->id;
855 $fk_fournprice = $originLine->fk_fournprice;
856 $pa_ht = $originLine->pa_ht;
857 $label = $originLine->label;
858 $array_options = $originLine->array_options;
859 $situation_percent = 100;
861 $fk_unit = $originLine->fk_unit;
862 $pu_ht_devise = $originLine->multicurrency_subprice;
864 $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);
882 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
885 $actiontypecode =
'AC_OTH_AUTO';
886 $triggersendname =
'PROPAL_SENTBYMAIL';
887 $autocopy =
'MAIN_MAIL_AUTOCOPY_PROPOSAL_TO';
888 $trackid =
'pro'.$object->id;
889 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
893 if ($action ==
'modif' && $usercancreate) {
894 $object->setDraft($user);
898 $outputlangs = $langs;
901 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') : $object->thirdparty->default_lang);
902 $outputlangs->setDefaultLang($newlang);
904 $ret = $object->fetch($id);
906 $object->fetch_thirdparty();
908 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
910 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
911 if (
GETPOST(
"remise_id",
"int")) {
912 if ($object->id > 0) {
913 $result = $object->insert_discount(
GETPOST(
"remise_id",
"int"));
919 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'vatforalllines',
'alpha') !==
'' && $usercancreate) {
921 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
922 $vat_rate = str_replace(
'*',
'', $vat_rate);
923 $localtax1_rate =
get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
924 $localtax2_rate =
get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
925 foreach ($object->lines as $line) {
926 $result = $object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc,
'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
928 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'remiseforalllines',
'alpha') !==
'' && $usercancreate) {
930 $remise_percent = (
GETPOST(
'remiseforalllines') ?
GETPOST(
'remiseforalllines') : 0);
931 $remise_percent = str_replace(
'*',
'', $remise_percent);
932 foreach ($object->lines as $line) {
933 $result = $object->updateline($line->id, $line->subprice, $line->qty, $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, $line->multicurrency_subprice);
935 } elseif ($action ==
'addline' &&
GETPOST(
'submitforallmargins',
'alpha') &&
GETPOST(
'marginforalllines') !==
'' && $usercancreate) {
937 $margin_rate = (
GETPOST(
'marginforalllines') ?
GETPOST(
'marginforalllines') : 0);
938 foreach ($object->lines as &$line) {
939 $subprice =
price2num($line->pa_ht * (1 + $margin_rate/100),
'MU');
941 $prod->fetch($line->fk_product);
942 if ($prod->price_min > $subprice) {
943 $price_subprice =
price($subprice, 0, $outlangs, 1, -1, -1,
'auto');
944 $price_price_min =
price($prod->price_min, 0, $outlangs, 1, -1, -1,
'auto');
945 setEventMessages($prod->ref.
' - '.$prod->label.
' ('.$price_subprice.
' < '.$price_price_min.
' '.strtolower($langs->trans(
"MinPrice")).
')'.
"\n",
null,
'warnings');
948 $multicurrency_subprice = $subprice * $line->multicurrency_subprice / $line->subprice;
950 $result = $object->updateline($line->id, $subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_rate, $line->localtax2_rate, $line->desc,
'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $multicurrency_subprice);
952 $line->price = $subprice;
953 $line->marge_tx = $margin_rate;
954 $line->marque_tx = $margin_rate * $line->pa_ht / $subprice;
955 $line->total_ht = $line->qty * $subprice;
956 $line->total_tva = $line->tva_tx * $line->qty * $subprice;
957 $line->total_ttc = (1 + $line->tva_tx) * $line->qty * $subprice;
959 $line->multicurrency_total_ht = $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice;
960 $line->multicurrency_total_tva = $line->tva_tx * $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice;
961 $line->multicurrency_total_ttc = (1 + $line->tva_tx) * $line->qty * $subprice * $line->multicurrency_subprice / $line->subprice;
963 $line->subprice = $subprice;
964 $line->multicurrency_subprice = $multicurrency_subprice;
966 } elseif ($action ==
'addline' && $usercancreate) {
969 $product_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
972 $price_ht_devise =
'';
974 $price_ttc_devise =
'';
978 if (
GETPOST(
'price_ht') !==
'') {
981 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
984 if (
GETPOST(
'price_ttc') !==
'') {
987 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
991 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
992 if ($prod_entry_mode ==
'free') {
995 $idprod =
GETPOST(
'idprod',
'int');
998 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
1003 $tva_tx =
GETPOST(
'tva_tx',
'alpha');
1006 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef,
'alpha'),
'', 2) : 0);
1007 if (empty($remise_percent)) {
1008 $remise_percent = 0;
1012 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
1013 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
1015 if (is_array($extralabelsline)) {
1017 foreach ($extralabelsline as $key => $value) {
1018 unset($_POST[
"options_".$key]);
1022 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
1023 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1027 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && $price_ht ===
'' && $price_ht_devise ===
'' && $price_ttc ===
'' && $price_ttc_devise ===
'') {
1028 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")),
null,
'errors');
1031 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
1032 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Description")),
null,
'errors');
1036 if (!$error && isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1037 if ($combinations =
GETPOST(
'combinations',
'array')) {
1041 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1042 $idprod = $res->fk_product_child;
1044 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1050 $propal_qty_requirement = (
getDolGlobalString(
'PROPAL_ENABLE_NEGATIVE_QTY') ? ($qty >= 0 || $qty <= 0) : $qty >= 0);
1051 if (!$error && $propal_qty_requirement && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) {
1059 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
1068 if (!empty($idprod) && $idprod > 0) {
1070 $prod->fetch($idprod);
1072 $label = ((
GETPOST(
'product_label') &&
GETPOST(
'product_label') != $prod->label) ?
GETPOST(
'product_label') :
'');
1082 $pu_ht = $prod->price;
1083 $pu_ttc = $prod->price_ttc;
1084 $price_min = $prod->price_min;
1085 $price_min_ttc = $prod->price_min_ttc;
1086 $price_base_type = $prod->price_base_type;
1090 $pu_ht = $prod->multiprices[$object->thirdparty->price_level];
1091 $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
1092 $price_min = $prod->multiprices_min[$object->thirdparty->price_level];
1093 $price_min_ttc = $prod->multiprices_min_ttc[$object->thirdparty->price_level];
1094 $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
1096 if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) {
1097 $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level];
1099 if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) {
1100 $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level];
1105 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
1109 $filter = array(
't.fk_product' => $prod->id,
't.fk_soc' => $object->thirdparty->id);
1111 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1114 if (count($prodcustprice->lines) > 0) {
1115 $pu_ht =
price($prodcustprice->lines[0]->price);
1116 $pu_ttc =
price($prodcustprice->lines[0]->price_ttc);
1117 $price_min =
price($prodcustprice->lines[0]->price_min);
1118 $price_min_ttc =
price($prodcustprice->lines[0]->price_min_ttc);
1119 $price_base_type = $prodcustprice->lines[0]->price_base_type;
1132 if ($prod->prices_by_qty[0]) {
1137 foreach ($prod->prices_by_qty_list[0] as $priceforthequantityarray) {
1138 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1142 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1143 $pu_ht = $priceforthequantityarray[
'unitprice'];
1145 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1153 if ($prod->prices_by_qty[$object->thirdparty->price_level]) {
1158 foreach ($prod->prices_by_qty_list[$object->thirdparty->price_level] as $priceforthequantityarray) {
1159 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1163 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1164 $pu_ht = $priceforthequantityarray[
'unitprice'];
1166 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1174 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
1175 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $prod->tva_tx));
1178 if (!empty($price_ht) || (
string) $price_ht ===
'0') {
1180 $pu_ttc =
price2num($pu_ht * (1 + ((
float) $tmpvat / 100)),
'MU');
1181 } elseif (!empty($price_ht_devise) || (
string) $price_ht_devise ===
'0') {
1182 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1185 } elseif (!empty($price_ttc) || (
string) $price_ttc ===
'0') {
1187 $pu_ht =
price2num($pu_ttc / (1 + ((
float) $tmpvat / 100)),
'MU');
1188 } elseif ($tmpvat != $tmpprodvat) {
1190 if ($price_base_type !=
'HT') {
1191 $pu_ht =
price2num($pu_ttc / (1 + ($tmpvat / 100)),
'MU');
1193 $pu_ttc =
price2num($pu_ht * (1 + ($tmpvat / 100)),
'MU');
1201 $outputlangs = $langs;
1203 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
1204 $newlang =
GETPOST(
'lang_id',
'aZ09');
1206 if (empty($newlang)) {
1207 $newlang = $object->thirdparty->default_lang;
1209 if (!empty($newlang)) {
1210 $outputlangs =
new Translate(
"", $conf);
1211 $outputlangs->setDefaultLang($newlang);
1214 $desc = (!empty($prod->multilangs[$outputlangs->defaultlang][
"description"])) ? $prod->multilangs[$outputlangs->defaultlang][
"description"] : $prod->
description;
1216 $desc = $prod->description;
1225 $desc = $product_desc;
1231 if (!
getDolGlobalString(
'MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE') && (!empty($prod->customcode) || !empty($prod->country_code))) {
1235 $outputlangs = $langs;
1237 if (empty($newlang) &&
GETPOST(
'lang_id',
'alpha')) {
1238 $newlang =
GETPOST(
'lang_id',
'alpha');
1240 if (empty($newlang)) {
1241 $newlang = $object->thirdparty->default_lang;
1243 if (!empty($newlang)) {
1244 $outputlangs =
new Translate(
"", $conf);
1245 $outputlangs->setDefaultLang($newlang);
1246 $outputlangs->load(
'products');
1248 if (!empty($prod->customcode)) {
1249 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
1251 if (!empty($prod->customcode) && !empty($prod->country_code)) {
1254 if (!empty($prod->country_code)) {
1255 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code, 0, $db, $outputlangs, 0);
1258 if (!empty($prod->customcode)) {
1259 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
1261 if (!empty($prod->customcode) && !empty($prod->country_code)) {
1264 if (!empty($prod->country_code)) {
1265 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code, 0, $db, $langs, 0);
1272 $type = $prod->type;
1273 $fk_unit = $prod->fk_unit;
1277 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1278 if (empty($tva_tx)) {
1281 $tva_tx = str_replace(
'*',
'', $tva_tx);
1282 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1283 $desc = $product_desc;
1285 $fk_unit =
GETPOST(
'units',
'alpha');
1286 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1287 $pu_ttc_devise =
price2num($price_ttc_devise,
'MU');
1289 if ($pu_ttc && !$pu_ht) {
1290 $price_base_type =
'TTC';
1300 $localtax1_tx =
get_localtax($tva_tx, 1, $object->thirdparty, $tva_npr);
1301 $localtax2_tx =
get_localtax($tva_tx, 2, $object->thirdparty, $tva_npr);
1311 $pu_equivalent = $pu_ht;
1312 $pu_equivalent_ttc = $pu_ttc;
1313 $currency_tx = $object->multicurrency_tx;
1317 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'') {
1318 $pu_equivalent = $pu_ht_devise * $currency_tx;
1320 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'') {
1321 $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx;
1339 if ($usermustrespectpricemin) {
1340 if ($pu_equivalent && $price_min && ((
price2num($pu_equivalent) * (1 - $remise_percent / 100)) <
price2num($price_min)) && $price_base_type ==
'HT') {
1341 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1344 } elseif ($pu_equivalent_ttc && $price_min_ttc && ((
price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) <
price2num($price_min_ttc)) && $price_base_type ==
'TTC') {
1345 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1353 $result = $object->addline($desc, $pu_ht, $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,
GETPOST(
'fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit,
'', 0, $pu_ht_devise);
1360 $outputlangs = $langs;
1362 $outputlangs =
new Translate(
"", $conf);
1363 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') : $object->thirdparty->default_lang);
1364 $outputlangs->setDefaultLang($newlang);
1366 $ret = $object->fetch($id);
1368 $object->fetch_thirdparty();
1370 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1373 unset($_POST[
'prod_entry_mode']);
1375 unset($_POST[
'qty']);
1376 unset($_POST[
'type']);
1377 unset($_POST[
'remise_percent']);
1378 unset($_POST[
'price_ht']);
1379 unset($_POST[
'multicurrency_price_ht']);
1380 unset($_POST[
'price_ttc']);
1381 unset($_POST[
'tva_tx']);
1382 unset($_POST[
'product_ref']);
1383 unset($_POST[
'product_label']);
1384 unset($_POST[
'product_desc']);
1385 unset($_POST[
'fournprice']);
1386 unset($_POST[
'buying_price']);
1387 unset($_POST[
'np_marginRate']);
1388 unset($_POST[
'np_markRate']);
1389 unset($_POST[
'dp_desc']);
1390 unset($_POST[
'idprod']);
1391 unset($_POST[
'units']);
1393 unset($_POST[
'date_starthour']);
1394 unset($_POST[
'date_startmin']);
1395 unset($_POST[
'date_startsec']);
1396 unset($_POST[
'date_startday']);
1397 unset($_POST[
'date_startmonth']);
1398 unset($_POST[
'date_startyear']);
1399 unset($_POST[
'date_endhour']);
1400 unset($_POST[
'date_endmin']);
1401 unset($_POST[
'date_endsec']);
1402 unset($_POST[
'date_endday']);
1403 unset($_POST[
'date_endmonth']);
1404 unset($_POST[
'date_endyear']);
1412 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save')) {
1420 if (preg_match(
'/\*/',
GETPOST(
'tva_tx'))) {
1426 $vat_rate = str_replace(
'*',
'', $vat_rate);
1427 $localtax1_rate =
get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
1428 $localtax2_rate =
get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
1443 if (empty($remise_percent)) {
1444 $remise_percent = 0;
1448 $pu_equivalent = $pu_ht;
1449 $pu_equivalent_ttc = $pu_ttc;
1451 $currency_tx = $object->multicurrency_tx;
1455 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'') {
1456 $pu_equivalent = $pu_ht_devise * $currency_tx;
1458 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'') {
1459 $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx;
1474 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
1475 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
1477 if (is_array($extralabelsline)) {
1479 foreach ($extralabelsline as $key => $value) {
1480 unset($_POST[
"options_".$key]);
1485 $special_code =
GETPOST(
'special_code',
'int');
1491 $productid =
GETPOST(
'productid',
'int');
1492 if (!empty($productid)) {
1494 $res = $product->fetch($productid);
1496 $type = $product->type;
1499 $price_min = $product->price_min;
1500 if (
getDolGlobalString(
'PRODUIT_MULTIPRICES') && !empty($object->thirdparty->price_level)) {
1501 $price_min = $product->multiprices_min[$object->thirdparty->price_level];
1503 $price_min_ttc = $product->price_min_ttc;
1504 if (
getDolGlobalString(
'PRODUIT_MULTIPRICES') && !empty($object->thirdparty->price_level)) {
1505 $price_min_ttc = $product->multiprices_min_ttc[$object->thirdparty->price_level];
1512 if ($usermustrespectpricemin) {
1513 if ($pu_equivalent && $price_min && ((
price2num($pu_equivalent) * (1 - (
float) $remise_percent / 100)) <
price2num($price_min)) && $price_base_type ==
'HT') {
1514 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1517 $action =
'editline';
1518 } elseif ($pu_equivalent_ttc && $price_min_ttc && ((
price2num($pu_equivalent_ttc) * (1 - (
float) $remise_percent / 100)) <
price2num($price_min_ttc)) && $price_base_type ==
'TTC') {
1519 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1522 $action =
'editline';
1527 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1531 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1539 if (!$user->hasRight(
'margins',
'creer')) {
1540 foreach ($object->lines as &$line) {
1541 if ($line->id ==
GETPOST(
'lineid',
'int')) {
1542 $fournprice = $line->fk_fournprice;
1543 $buyingprice = $line->pa_ht;
1552 $price_base_type =
'HT';
1553 if (empty($pu) && !empty($pu_ttc)) {
1555 $price_base_type =
'TTC';
1558 $result = $object->updateline(
GETPOST(
'lineid',
'int'), $pu, $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $description, $price_base_type, $info_bits, $special_code,
GETPOST(
'fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options,
GETPOST(
"units"), $pu_ht_devise);
1565 $outputlangs = $langs;
1567 $outputlangs =
new Translate(
"", $conf);
1568 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') : $object->thirdparty->default_lang);
1569 $outputlangs->setDefaultLang($newlang);
1571 $ret = $object->fetch($id);
1573 $object->fetch_thirdparty();
1575 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1578 unset($_POST[
'qty']);
1579 unset($_POST[
'type']);
1580 unset($_POST[
'productid']);
1581 unset($_POST[
'remise_percent']);
1582 unset($_POST[
'price_ht']);
1583 unset($_POST[
'multicurrency_price_ht']);
1584 unset($_POST[
'price_ttc']);
1585 unset($_POST[
'tva_tx']);
1586 unset($_POST[
'product_ref']);
1587 unset($_POST[
'product_label']);
1588 unset($_POST[
'product_desc']);
1589 unset($_POST[
'fournprice']);
1590 unset($_POST[
'buying_price']);
1592 unset($_POST[
'date_starthour']);
1593 unset($_POST[
'date_startmin']);
1594 unset($_POST[
'date_startsec']);
1595 unset($_POST[
'date_startday']);
1596 unset($_POST[
'date_startmonth']);
1597 unset($_POST[
'date_startyear']);
1598 unset($_POST[
'date_endhour']);
1599 unset($_POST[
'date_endmin']);
1600 unset($_POST[
'date_endsec']);
1601 unset($_POST[
'date_endday']);
1602 unset($_POST[
'date_endmonth']);
1603 unset($_POST[
'date_endyear']);
1610 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha')) {
1611 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
1613 } elseif ($action ==
'classin' && $usercancreate) {
1615 $object->setProject(
GETPOST(
'projectid',
'int'));
1616 } elseif ($action ==
'setavailability' && $usercancreate) {
1618 $result = $object->set_availability($user,
GETPOST(
'availability_id',
'int'));
1619 } elseif ($action ==
'setdemandreason' && $usercancreate) {
1621 $result = $object->set_demand_reason($user,
GETPOST(
'demand_reason_id',
'int'));
1622 } elseif ($action ==
'setconditions' && $usercancreate) {
1624 $sql =
"SELECT code ";
1625 $sql .=
"FROM " . $db->prefix() .
"c_payment_term";
1626 $sql .=
" WHERE rowid = " . ((int)
GETPOST(
'cond_reglement_id',
'int'));
1627 $result = $db->query($sql);
1629 $obj = $db->fetch_object($result);
1630 if ($obj->code ==
'DEP30PCTDEL') {
1631 $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_id',
'int'),
GETPOST(
'cond_reglement_id_deposit_percent',
'alpha'));
1633 $object->deposit_percent = 0;
1634 $object->update($user);
1635 $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_id',
'int'), $object->deposit_percent);
1642 } elseif ($action ==
'setmode' && $usercancreate) {
1644 $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_id',
'int'));
1645 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
1647 $result = $object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
1648 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
1650 $result = $object->setMulticurrencyRate(
price2num(
GETPOST(
'multicurrency_tx')),
GETPOST(
'calculation_mode',
'int'));
1651 } elseif ($action ==
'setbankaccount' && $usercancreate) {
1653 $result = $object->setBankAccount(
GETPOST(
'fk_account',
'int'));
1654 } elseif ($action ==
'setshippingmethod' && $usercancreate) {
1656 $result = $object->setShippingMethod(
GETPOST(
'shipping_method_id',
'int'));
1657 } elseif ($action ==
'setwarehouse' && $usercancreate) {
1659 $result = $object->setWarehouse(
GETPOST(
'warehouse_id',
'int'));
1660 } elseif ($action ==
'update_extras') {
1661 $object->oldcopy =
dol_clone($object, 2);
1662 $attribute_name =
GETPOST(
'attribute',
'restricthtml');
1665 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
1670 $result = $object->updateExtraField($attribute_name,
'PROPAL_MODIFY');
1677 $action =
'edit_extras';
1682 if ($action ==
'addcontact') {
1683 if ($object->id > 0) {
1686 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
1690 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
1693 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1694 $langs->load(
"errors");
1695 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
1700 } elseif ($action ==
'swapstatut') {
1702 if ($object->fetch($id) > 0) {
1703 $result = $object->swapContactStatus(
GETPOST(
'ligne',
'int'));
1707 } elseif ($action ==
'deletecontact') {
1709 $object->fetch($id);
1710 $result = $object->delete_contact($lineid);
1713 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
1722 $upload_dir = !empty($conf->propal->multidir_output[$object->entity]) ? $conf->propal->multidir_output[$object->entity] : $conf->propal->dir_output;
1723 $permissiontoadd = $usercancreate;
1724 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1732$form =
new Form($db);
1736if (isModEnabled(
'project')) {
1740$title = $object->ref.
" - ".$langs->trans(
'Card');
1741if ($action ==
'create') {
1742 $title = $langs->trans(
"NewPropal");
1744$help_url =
'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos|DE:Modul_Angebote';
1751if ($action ==
'create') {
1752 $currency_code = $conf->currency;
1758 $res = $soc->fetch($socid);
1761 $currency_code = $conf->currency;
1763 $cond_reglement_id =
GETPOST(
'cond_reglement_id',
'int');
1764 $deposit_percent =
GETPOST(
'cond_reglement_id_deposit_percent',
'alpha');
1765 $mode_reglement_id =
GETPOST(
'mode_reglement_id',
'int');
1766 $fk_account =
GETPOST(
'fk_account',
'int');
1770 if (!empty($origin) && !empty($originid)) {
1772 $element = $subelement = $origin;
1774 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
1775 $element = $regs[1];
1776 $subelement = $regs[2];
1779 if ($element ==
'project') {
1780 $projectid = $originid;
1784 $project->fetch($projectid);
1785 if ($project->socid > 0) {
1787 $soc->fetch($project->socid);
1791 if ($element ==
'order' || $element ==
'commande') {
1792 $element = $subelement =
'commande';
1794 if ($element ==
'propal') {
1795 $element =
'comm/propal';
1796 $subelement =
'propal';
1798 if ($element ==
'contract') {
1799 $element = $subelement =
'contrat';
1801 if ($element ==
'shipping') {
1802 $element = $subelement =
'expedition';
1807 $classname = ucfirst($subelement);
1808 $objectsrc =
new $classname($db);
1809 $objectsrc->fetch($originid);
1810 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1811 $objectsrc->fetch_lines();
1813 $objectsrc->fetch_thirdparty();
1815 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : 0);
1816 $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client :
'');
1818 $soc = $objectsrc->thirdparty;
1820 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1821 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1822 $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
1825 $objectsrc->fetch_optionals();
1826 $object->array_options = $objectsrc->array_options;
1828 if (isModEnabled(
"multicurrency")) {
1829 if (!empty($objectsrc->multicurrency_code)) {
1830 $currency_code = $objectsrc->multicurrency_code;
1832 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
1833 $currency_tx = $objectsrc->multicurrency_tx;
1841 $cond_reglement_id = empty($soc->cond_reglement_id) ? $cond_reglement_id : $soc->cond_reglement_id;
1842 $deposit_percent = empty($soc->deposit_percent) ? $deposit_percent : $soc->deposit_percent;
1843 $mode_reglement_id = empty($soc->mode_reglement_id) ? $mode_reglement_id : $soc->mode_reglement_id;
1844 $fk_account = empty($soc->fk_account) ? $fk_account : $soc->fk_account;
1845 $shipping_method_id = $soc->shipping_method_id;
1846 $warehouse_id = $soc->fk_warehouse;
1847 $remise_percent = $soc->remise_percent;
1849 if (isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
1850 $currency_code = $soc->multicurrency_code;
1855 if (!
GETPOST(
'changecompany')) {
1856 if (GETPOSTISSET(
'cond_reglement_id')) {
1857 $cond_reglement_id =
GETPOST(
'cond_reglement_id',
'int');
1859 if (GETPOSTISSET(
'deposit_percent')) {
1862 if (GETPOSTISSET(
'mode_reglement_id')) {
1863 $mode_reglement_id =
GETPOST(
'mode_reglement_id',
'int');
1865 if (GETPOSTISSET(
'cond_reglement_id')) {
1866 $fk_account =
GETPOST(
'fk_account',
'int');
1871 if ($soc->fk_warehouse > 0) {
1872 $warehouse_id = $soc->fk_warehouse;
1874 if (isModEnabled(
'stock') && empty($warehouse_id) &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
1876 $warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE;
1878 if (empty($object->warehouse_id) &&
getDolGlobalString(
'MAIN_DEFAULT_WAREHOUSE_USER')) {
1879 $warehouse_id = $user->fk_warehouse;
1883 print
'<form name="addprop" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1884 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1885 print
'<input type="hidden" name="action" value="add">';
1886 print
'<input type="hidden" name="changecompany" value="0">';
1887 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1888 if ($origin !=
'project' && $originid) {
1889 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1890 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1891 } elseif ($origin ==
'project' && !empty($projectid)) {
1892 print
'<input type="hidden" name="projectid" value="'.$projectid.
'">';
1898 $parameters = array();
1900 $reshook = $hookmanager->executeHooks(
'tabContentCreateProposal', $parameters, $object, $action);
1901 if (empty($reshook)) {
1902 print
'<table class="border centpercent">';
1905 print
'<tr class="field_ref"><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td class="valuefieldcreate">'.$langs->trans(
"Draft").
'</td></tr>';
1908 print
'<tr class="field_ref_client"><td class="titlefieldcreate">'.$langs->trans(
'RefCustomer').
'</td><td class="valuefieldcreate">';
1909 print
'<input type="text" name="ref_client" value="'.(!empty($ref_client) ? $ref_client :
GETPOST(
'ref_client')).
'"></td>';
1913 print
'<tr class="field_socid">';
1914 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Customer').
'</td>';
1915 $shipping_method_id = 0;
1917 print
'<td class="valuefieldcreate">';
1918 print $soc->getNomUrl(1,
'customer');
1919 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1921 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($soc->shipping_method_id)) {
1922 $shipping_method_id = $soc->shipping_method_id;
1926 print
'<td class="valuefieldcreate">';
1927 $filter =
'((s.client:IN:1,2,3) AND (s.status:=:1))';
1928 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 1, 0,
null, 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
1932 $(document).ready(function() {
1933 $("#socid").change(function() {
1934 console.log("We have changed the company - Reload page");
1935 var socid = $(this).val();
1937 $("input[name=action]").val("create");
1938 $("input[name=changecompany]").val("1");
1939 $("form[name=addprop]").submit();
1944 print
' <a href="'.DOL_URL_ROOT.
'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddThirdParty").
'"></span></a>';
1951 print
'<tr class="field_contactid"><td class="titlefieldcreate">'.$langs->trans(
"DefaultContact").
'</td><td class="valuefieldcreate">';
1952 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
1953 print $form->selectcontacts($soc->id, $contactid,
'contactid', 1,
'',
'', 0,
'minwidth300');
1957 print
'<tr class="field_discount_info"><td class="titlefieldcreate">'.$langs->trans(
'Discounts').
'</td><td class="valuefieldcreate">';
1959 $absolute_discount = $soc->getAvailableDiscounts();
1963 $backtopage = $_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.urlencode(
GETPOST(
'origin')).
'&originid='.urlencode(
GETPOSTINT(
'originid'));
1964 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1969 print
'<tr class="field_addprop"><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'DatePropal').
'</td><td class="valuefieldcreate">';
1970 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1971 print $form->selectDate(
'',
'',
'',
'',
'',
"addprop", 1, 1);
1975 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') : $conf->global->PROPALE_VALIDITY_DURATION).
'"> '.$langs->trans(
"days").
'</td></tr>';
1978 print
'<tr class="field_cond_reglement_id"><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
1979 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
1981 print $form->getSelectConditionsPaiements($cond_reglement_id,
'cond_reglement_id', 1, 1, 0,
'', $deposit_percent);
1985 print
'<tr class="field_mode_reglement_id"><td class="titlefieldcreate">'.$langs->trans(
'PaymentMode').
'</td><td class="valuefieldcreate">';
1986 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1987 print $form->select_types_paiements($mode_reglement_id,
'mode_reglement_id',
'CRDT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx', 1);
1991 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') && isModEnabled(
"banque")) {
1992 print
'<tr class="field_fk_account"><td class="titlefieldcreate">'.$langs->trans(
'BankAccount').
'</td><td class="valuefieldcreate">';
1993 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes($fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
1998 print
'<tr class="field_demand_reason_id"><td class="titlefieldcreate">'.$langs->trans(
'Source').
'</td><td class="valuefieldcreate">';
1999 print
img_picto(
'',
'question',
'class="pictofixedwidth"');
2000 $form->selectInputReason((GETPOSTISSET(
'demand_reason_id') ?
GETPOST(
'demand_reason_id',
'int') :
''),
'demand_reason_id',
"SRC_PROP", 1,
'maxwidth200 widthcentpercentminusx');
2004 if (isModEnabled(
"expedition")) {
2005 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($soc->shipping_method_id)) {
2006 $shipping_method_id = $soc->shipping_method_id;
2008 print
'<tr class="field_shipping_method_id"><td class="titlefieldcreate">'.$langs->trans(
'SendingMethod').
'</td><td class="valuefieldcreate">';
2009 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
2010 $form->selectShippingMethod((GETPOSTISSET(
'shipping_method_id') ?
GETPOST(
'shipping_method_id',
'int') : $shipping_method_id),
'shipping_method_id',
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx');
2015 if (isModEnabled(
'stock') &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL')) {
2016 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2018 print
'<tr class="field_warehouse_id"><td class="titlefieldcreate">'.$langs->trans(
'Warehouse').
'</td><td class="valuefieldcreate">';
2019 print
img_picto(
'',
'stock',
'class="pictofixedwidth"').$formproduct->selectWarehouses($warehouse_id,
'warehouse_id',
'', 1, 0, 0,
'', 0, 0, array(),
'maxwidth500 widthcentpercentminusxx');
2024 print
'<tr class="field_availability_id"><td class="titlefieldcreate">'.$langs->trans(
'AvailabilityPeriod');
2025 if (isModEnabled(
'commande')) {
2026 print
' ('.$langs->trans(
'AfterOrder').
')';
2028 print
'</td><td class="valuefieldcreate">';
2029 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
2030 $form->selectAvailabilityDelay((GETPOSTISSET(
'availability_id') ?
GETPOST(
'availability_id',
'int') :
''),
'availability_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
2034 print
'<tr class="field_date_livraison"><td class="titlefieldcreate">'.$langs->trans(
"DeliveryDate").
'</td>';
2035 print
'<td class="valuefieldcreate">';
2036 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2038 $tmpdte = time() + (7 *
getDolGlobalInt(
'DATE_LIVRAISON_WEEK_DELAY') * 24 * 60 * 60);
2039 $syear = date(
"Y", $tmpdte);
2040 $smonth = date(
"m", $tmpdte);
2041 $sday = date(
"d", $tmpdte);
2042 print $form->selectDate($syear.
"-".$smonth.
"-".$sday,
'date_livraison',
'',
'',
'',
"addprop");
2044 print $form->selectDate(-1,
'date_livraison',
'',
'',
'',
"addprop", 1, 1);
2049 if (isModEnabled(
'project')) {
2050 $langs->load(
"projects");
2051 print
'<tr class="field_projectid">';
2052 print
'<td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td class="valuefieldcreate">';
2053 print
img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx');
2054 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>';
2060 if (isModEnabled(
'incoterm')) {
2061 print
'<tr class="field_incoterm_id">';
2062 print
'<td class="titlefieldcreate"><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), $soc->label_incoterms, 1).
'</label></td>';
2063 print
'<td class="valuefieldcreate maxwidthonsmartphone">';
2064 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2065 print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms :
''), (!empty($soc->location_incoterms) ? $soc->location_incoterms :
''));
2070 print
'<tr class="field_model">';
2071 print
'<td class="titlefieldcreate">'.$langs->trans(
"DefaultModel").
'</td>';
2072 print
'<td class="valuefieldcreate">';
2073 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
2076 print $form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
2080 if (isModEnabled(
"multicurrency")) {
2081 print
'<tr class="field_currency">';
2082 print
'<td class="titlefieldcreate">'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
2083 print
'<td class="valuefieldcreate maxwidthonsmartphone">';
2084 print
img_picto(
'',
'currency',
'class="pictofixedwidth"').$form->selectMultiCurrency(((GETPOSTISSET(
'multicurrency_code') && !
GETPOST(
'changecompany')) ?
GETPOST(
'multicurrency_code') : $currency_code),
'multicurrency_code', 0);
2089 print
'<tr class="field_note_public">';
2090 print
'<td class="titlefieldcreate tdtop">'.$langs->trans(
'NotePublic').
'</td>';
2091 print
'<td class="valuefieldcreate">';
2092 $note_public = $object->getDefaultCreateValueFor(
'note_public', (!empty($objectsrc) ? $objectsrc->note_public : (
getDolGlobalString(
'PROPALE_ADDON_NOTE_PUBLIC_DEFAULT') ? $conf->global->PROPALE_ADDON_NOTE_PUBLIC_DEFAULT : null)),
'restricthtml');
2093 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In', 0,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
2094 print $doleditor->Create(1);
2097 if (empty($user->socid)) {
2098 print
'<tr class="field_note_private">';
2099 print
'<td class="titlefieldcreate tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
2100 print
'<td class="valuefieldcreate">';
2101 $note_private = $object->getDefaultCreateValueFor(
'note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc)) ? $objectsrc->note_private : null));
2102 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In', 0,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
2103 print $doleditor->Create(1);
2109 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
2112 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2114 if ($origin ==
'contrat') {
2118 $objectsrc->update_price(1,
'auto', 1);
2121 print
"\n<!-- ".$classname.
" info -->";
2123 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2124 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2125 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2126 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2127 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2129 $newclassname = $classname;
2130 if ($newclassname ==
'Propal') {
2131 $newclassname =
'CommercialProposal';
2132 } elseif ($newclassname ==
'Commande') {
2133 $newclassname =
'Order';
2134 } elseif ($newclassname ==
'Expedition') {
2135 $newclassname =
'Sending';
2136 } elseif ($newclassname ==
'Fichinter') {
2137 $newclassname =
'Intervention';
2140 print
'<tr><td>'.$langs->trans($newclassname).
'</td><td>'.$objectsrc->getNomUrl(1).
'</td></tr>';
2141 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht, 0, $langs, 1, -1, -1, $conf->currency).
'</td></tr>';
2142 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva, 0, $langs, 1, -1, -1, $conf->currency).
"</td></tr>";
2143 if ($mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
2144 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1, 0, $langs, 1, -1, -1, $conf->currency).
"</td></tr>";
2147 if ($mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
2148 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2, 0, $langs, 1, -1, -1, $conf->currency).
"</td></tr>";
2150 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc, 0, $langs, 1, -1, -1, $conf->currency).
"</td></tr>";
2152 if (isModEnabled(
"multicurrency")) {
2153 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
2154 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
2155 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2167 print
'<input type="hidden" name="createmode" value="empty">';
2171 print
'<br><table>';
2175 print
'<td><input type="radio" name="createmode" value="copy"></td>';
2176 print
'<td>'.$langs->trans(
"CopyPropalFrom").
' </td>';
2178 $liste_propal = array();
2179 $liste_propal [0] =
'';
2181 $sql =
"SELECT p.rowid as id, p.ref, s.nom";
2182 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal p";
2183 $sql .=
", ".MAIN_DB_PREFIX.
"societe s";
2184 $sql .=
" WHERE s.rowid = p.fk_soc";
2185 $sql .=
" AND p.entity IN (".getEntity(
'propal').
")";
2186 $sql .=
" AND p.fk_statut <> 0";
2187 $sql .=
" ORDER BY Id";
2189 $resql = $db->query($sql);
2191 $num = $db->num_rows($resql);
2194 $row = $db->fetch_row($resql);
2195 $propalRefAndSocName = $row[1].
" - ".$row[2];
2196 $liste_propal[$row[0]] = $propalRefAndSocName;
2199 print $form->selectarray(
"copie_propal", $liste_propal, 0);
2205 print
'<tr><td class="tdtop"><input type="radio" name="createmode" value="empty" checked></td>';
2206 print
'<td valign="top" colspan="2">'.$langs->trans(
"CreateEmptyPropal").
'</td></tr>';
2213 $langs->load(
"bills");
2215 print $form->buttonsSaveCancel(
"CreateDraft");
2221 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2224 $title = $langs->trans(
'ProductsAndServices');
2227 print
'<div class="div-table-responsive-no-min">';
2228 print
'<table class="noborder centpercent">';
2230 $objectsrc->printOriginLinesList();
2235} elseif ($object->id > 0) {
2239 $object->fetch_thirdparty();
2240 if ($object->thirdparty) {
2241 $soc = $object->thirdparty;
2252 if ($action ==
'clone') {
2254 $filter =
'(s.client:IN:1,2,3)';
2255 $formquestion = array(
2258 array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' => $form->select_company(
GETPOST(
'socid',
'int'),
'socid', $filter,
'', 0, 0,
null, 0,
'maxwidth300')),
2259 array(
'type' =>
'checkbox',
'name' =>
'update_prices',
'label' => $langs->trans(
'PuttingPricesUpToDate'),
'value' => 0),
2260 array(
'type' =>
'checkbox',
'name' =>
'update_desc',
'label' => $langs->trans(
'PuttingDescUpToDate'),
'value' => 0),
2262 if (
getDolGlobalString(
'PROPAL_CLONE_DATE_DELIVERY') && !empty($object->delivery_date)) {
2263 $formquestion[] = array(
'type' =>
'date',
'name' =>
'date_delivery',
'label' => $langs->trans(
"DeliveryDate"),
'value' => $object->delivery_date);
2266 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmClonePropal', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
2269 if ($action ==
'closeas') {
2271 $formquestion = array();
2273 $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)));
2275 $formquestion[] = array(
'type' =>
'text',
'name' =>
'note_private',
'label' => $langs->trans(
"Note"),
'value' =>
'');
2277 if (
getDolGlobalInt(
'PROPOSAL_SUGGEST_DOWN_PAYMENT_INVOICE_CREATION')) {
2282 $deposit_percent_from_payment_terms =
getDictionaryValue(
'c_payment_term',
'deposit_percent', $object->cond_reglement_id);
2284 if (!empty($deposit_percent_from_payment_terms) && isModEnabled(
'facture') && $user->hasRight(
'facture',
'creer')) {
2285 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
2287 $object->fetchObjectLinked();
2289 $eligibleForDepositGeneration =
true;
2291 if (array_key_exists(
'facture', $object->linkedObjects)) {
2292 foreach ($object->linkedObjects[
'facture'] as $invoice) {
2294 $eligibleForDepositGeneration =
false;
2300 if ($eligibleForDepositGeneration && array_key_exists(
'commande', $object->linkedObjects)) {
2301 foreach ($object->linkedObjects[
'commande'] as $order) {
2302 $order->fetchObjectLinked();
2304 if (array_key_exists(
'facture', $order->linkedObjects)) {
2305 foreach ($order->linkedObjects[
'facture'] as $invoice) {
2307 $eligibleForDepositGeneration =
false;
2316 if ($eligibleForDepositGeneration) {
2317 $formquestion[] = array(
2318 'type' =>
'checkbox',
2319 'tdclass' =>
'showonlyifsigned',
2320 'name' =>
'generate_deposit',
2321 'morecss' =>
'margintoponly marginbottomonly',
2322 'label' => $form->textwithpicto($langs->trans(
'GenerateDeposit', $object->deposit_percent), $langs->trans(
'DepositGenerationPermittedByThePaymentTermsSelected'))
2325 $formquestion[] = array(
2327 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2329 'label' => $langs->trans(
'DateInvoice'),
2335 $formquestion[] = array(
2337 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2338 'name' =>
'date_pointoftax',
2339 'label' => $langs->trans(
'DatePointOfTax'),
2345 $paymentTermsSelect = $form->getSelectConditionsPaiements(0,
'cond_reglement_id', -1, 0, 1,
'minwidth200');
2347 $formquestion[] = array(
2349 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2350 'name' =>
'cond_reglement_id',
2351 'label' => $langs->trans(
'PaymentTerm'),
2352 'value' => $paymentTermsSelect
2355 $formquestion[] = array(
2356 'type' =>
'checkbox',
2357 'tdclass' =>
'showonlyifgeneratedeposit',
2358 'name' =>
'validate_generated_deposit',
2359 'morecss' =>
'margintoponly marginbottomonly',
2360 'label' => $langs->trans(
'ValidateGeneratedDeposit')
2363 $formquestion[] = array(
2364 'type' =>
'onecolumn',
2367 let signedValue = ' . $object::STATUS_SIGNED .
';
2369 $(document).ready(function() {
2370 $("[name=generate_deposit]").change(function () {
2371 let $self = $(this);
2372 let $target = $(".showonlyifgeneratedeposit").parent(".tagtr");
2374 if (! $self.parents(".tagtr").is(":hidden") && $self.is(":checked")) {
2383 $("#statut").change(function() {
2384 let $target = $(".showonlyifsigned").parent(".tagtr");
2386 if ($(this).val() == signedValue) {
2392 $("[name=generate_deposit]").trigger("change");
2397 $("#statut").trigger("change");
2406 if (isModEnabled(
'notification')) {
2407 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
2408 $notify =
new Notify($db);
2409 $formquestion = array_merge($formquestion, array(
2410 array(
'type' =>
'onecolumn',
'value' => $notify->confirmMessage(
'PROPAL_CLOSE_SIGNED', $object->socid, $object)),
2415 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'SetAcceptedRefused'),
'',
'confirm_closeas', $formquestion,
'', 1, 250);
2417 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?statut=3&id=' . $object->id, $langs->trans(
'Close'),
'',
'confirm_closeas', $formquestion,
'', 1, 250);
2419 } elseif ($action ==
'delete') {
2421 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteProp'), $langs->trans(
'ConfirmDeleteProp', $object->ref),
'confirm_delete',
'', 0, 1);
2422 } elseif ($action ==
'reopen') {
2424 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ReOpen'), $langs->trans(
'ConfirmReOpenProp', $object->ref),
'confirm_reopen',
'', 0, 1);
2425 } elseif ($action ==
'ask_deleteline') {
2427 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
2428 } elseif ($action ==
'validate') {
2433 $ref = substr($object->ref, 1, 4);
2434 if ($ref ==
'PROV' || $ref ==
'') {
2435 $numref = $object->getNextNumRef($soc);
2436 if (empty($numref)) {
2441 $numref = $object->ref;
2444 $text = $langs->trans(
'ConfirmValidateProp', $numref);
2445 if (isModEnabled(
'notification')) {
2446 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
2447 $notify =
new Notify($db);
2449 $text .= $notify->confirmMessage(
'PROPAL_VALIDATE', $object->socid, $object);
2454 foreach ($object->lines as $line) {
2455 $res = $line->fetch_product();
2457 if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end))) {
2463 if ($nbMandated > 0) {
2464 $text .=
'<div><span class="clearboth nowraponall warning">'.$langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate").
'</span></div>';
2468 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ValidateProp'), $text,
'confirm_validate',
'', 0, 1);
2473 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
2474 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2475 if (empty($reshook)) {
2476 $formconfirm .= $hookmanager->resPrint;
2477 } elseif ($reshook > 0) {
2478 $formconfirm = $hookmanager->resPrint;
2487 $linkback =
'<a href="'.DOL_URL_ROOT.
'/comm/propal/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
2489 $morehtmlref =
'<div class="refidno">';
2491 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client', $object->ref_client, $object, $usercancreate,
'string',
'', 0, 1);
2492 $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);
2494 $morehtmlref .=
'<br><span class="hideonsmartphone">'.$langs->trans(
'ThirdParty').
' : </span>'.$soc->getNomUrl(1,
'customer');
2496 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/comm/propal/list.php?socid='.$soc->id.
'&search_societe='.urlencode($soc->name).
'">'.$langs->trans(
"OtherProposals").
'</a>)';
2499 if (isModEnabled(
'project')) {
2500 $langs->load(
"projects");
2501 $morehtmlref .=
'<br>';
2502 if ($usercancreate) {
2503 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2504 if ($action !=
'classify') {
2505 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2507 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2509 if (!empty($object->fk_project)) {
2511 $proj->fetch($object->fk_project);
2512 $morehtmlref .= $proj->getNomUrl(1);
2514 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2519 $morehtmlref .=
'</div>';
2522 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2525 $parameters = array();
2527 $reshook = $hookmanager->executeHooks(
'tabContentViewProposal', $parameters, $object, $action);
2528 if (empty($reshook)) {
2529 print
'<div class="fichecenter">';
2530 print
'<div class="fichehalfleft">';
2531 print
'<div class="underbanner clearboth"></div>';
2533 print
'<table class="border tableforfield centpercent">';
2537 $filterabsolutediscount =
"fk_facture_source IS NULL";
2538 $filtercreditnote =
"fk_facture_source IS NOT NULL";
2540 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
2541 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
2544 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td>';
2546 $absolute_discount = $soc->getAvailableDiscounts(
'', $filterabsolutediscount);
2547 $absolute_creditnote = $soc->getAvailableDiscounts(
'', $filtercreditnote);
2548 $absolute_discount =
price2num($absolute_discount,
'MT');
2549 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
2555 $backtopage = $_SERVER[
"PHP_SELF"].
'?id='.$object->id;
2556 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2572 print $form->editfieldkey(
"DatePropal",
'date',
'', $object, $editenable);
2573 print
'</td><td class="valuefield">';
2574 if ($action ==
'editdate' && $usercancreate && $caneditfield) {
2575 print
'<form name="editdate" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
2576 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2577 print
'<input type="hidden" name="action" value="setdate">';
2578 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2579 print $form->selectDate($object->date,
're',
'',
'', 0,
"editdate");
2580 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2583 if ($object->date) {
2594 print
'<table class="nobordernopadding centpercent"><tr><td>';
2595 print $langs->trans(
'DateEndPropal');
2597 if ($action !=
'editecheance' && $usercancreate && $caneditfield) {
2598 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>';
2600 print
'</tr></table>';
2601 print
'</td><td class="valuefield">';
2602 if ($action ==
'editecheance' && $usercancreate && $caneditfield) {
2603 print
'<form name="editecheance" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
2604 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2605 print
'<input type="hidden" name="action" value="setecheance">';
2606 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2607 print $form->selectDate($object->fin_validite,
'ech',
'',
'',
'',
"editecheance");
2608 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2611 if (!empty($object->fin_validite)) {
2613 if ($object->statut ==
Propal::STATUS_VALIDATED && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) {
2625 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2626 print $langs->trans(
'PaymentConditionsShort');
2628 if ($action !=
'editconditions' && $usercancreate && $caneditfield) {
2629 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>';
2631 print
'</tr></table>';
2632 print
'</td><td class="valuefield">';
2633 if ($action ==
'editconditions' && $usercancreate && $caneditfield) {
2634 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'cond_reglement_id', 0,
'', 1, $object->deposit_percent);
2636 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'none', 0,
'', 1, $object->deposit_percent);
2642 print
'<tr class="field_mode_reglement_id">';
2643 print
'<td class="titlefieldcreate">';
2644 print
'<table class="nobordernopadding centpercent"><tr><td>';
2645 print $langs->trans(
'PaymentMode');
2647 if ($action !=
'editmode' && $usercancreate && $caneditfield) {
2648 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>';
2650 print
'</tr></table>';
2651 print
'</td><td class="valuefieldcreate">';
2652 if ($action ==
'editmode' && $usercancreate && $caneditfield) {
2653 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
2655 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'none');
2660 $langs->load(
'deliveries');
2662 print $form->editfieldkey($langs->trans(
'DeliveryDate'),
'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield,
'datepicker');
2663 print
'</td><td class="valuefieldedit">';
2664 print $form->editfieldval($langs->trans(
'DeliveryDate'),
'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield,
'datepicker');
2669 print
'<tr class="fielddeliverydelay"><td>';
2670 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2671 if (isModEnabled(
'commande')) {
2672 print $form->textwithpicto($langs->trans(
'AvailabilityPeriod'), $langs->trans(
'AvailabilityPeriod').
' ('.$langs->trans(
'AfterOrder').
')');
2674 print $langs->trans(
'AvailabilityPeriod');
2677 if ($action !=
'editavailability' && $usercancreate && $caneditfield) {
2678 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>';
2680 print
'</tr></table>';
2681 print
'</td><td class="valuefield">';
2682 if ($action ==
'editavailability' && $usercancreate && $caneditfield) {
2683 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->availability_id,
'availability_id', 1);
2685 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->availability_id,
'none', 1);
2692 if (isModEnabled(
"expedition")) {
2694 print
'<table class="nobordernopadding centpercent"><tr><td>';
2695 print $langs->trans(
'SendingMethod');
2697 if ($action !=
'editshippingmethod' && $usercancreate && $caneditfield) {
2698 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>';
2700 print
'</tr></table>';
2701 print
'</td><td class="valuefield">';
2702 if ($action ==
'editshippingmethod' && $usercancreate && $caneditfield) {
2703 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->shipping_method_id,
'shipping_method_id', 1);
2705 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->shipping_method_id,
'none');
2712 if (isModEnabled(
'stock') &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL')) {
2713 $langs->load(
'stocks');
2714 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2716 print
'<tr class="field_warehouse_id"><td class="titlefieldcreate">';
2717 $editenable = $usercancreate;
2718 print $form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, $editenable);
2719 print
'</td><td class="valuefieldcreate">';
2720 if ($action ==
'editwarehouse') {
2721 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->warehouse_id,
'warehouse_id', 1);
2723 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->warehouse_id,
'none');
2731 print
'<table class="nobordernopadding centpercent"><tr><td>';
2732 print $langs->trans(
'Source');
2734 if ($action !=
'editdemandreason' && $usercancreate) {
2735 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>';
2737 print
'</tr></table>';
2738 print
'</td><td class="valuefield">';
2739 if ($action ==
'editdemandreason' && $usercancreate) {
2740 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->demand_reason_id,
'demand_reason_id', 1);
2742 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->demand_reason_id,
'none');
2748 if (isModEnabled(
"multicurrency")) {
2752 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2753 print $form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0);
2755 if ($action !=
'editmulticurrencycode' && $object->statut == $object::STATUS_DRAFT && $usercancreate) {
2756 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmulticurrencycode&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetMultiCurrencyCode'), 1).
'</a></td>';
2758 print
'</tr></table>';
2759 print
'</td><td class="valuefield">';
2760 if ($object->statut == $object::STATUS_DRAFT && $action ==
'editmulticurrencycode' && $usercancreate) {
2761 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_code,
'multicurrency_code');
2763 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_code,
'none');
2768 if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) {
2771 print
'<table class="nobordernopadding" width="100%"><tr>';
2773 print $form->editfieldkey(
'CurrencyRate',
'multicurrency_tx',
'', $object, 0);
2775 if ($action !=
'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $usercancreate) {
2776 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmulticurrencyrate&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetMultiCurrencyCode'), 1).
'</a></td>';
2778 print
'</tr></table>';
2779 print
'</td><td class="valuefield">';
2780 if ($object->statut == $object::STATUS_DRAFT && ($action ==
'editmulticurrencyrate' || $action ==
'actualizemulticurrencyrate') && $usercancreate) {
2781 if ($action ==
'actualizemulticurrencyrate') {
2784 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx,
'multicurrency_tx', $object->multicurrency_code);
2786 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx,
'none', $object->multicurrency_code);
2787 if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
2788 print
'<div class="inline-block"> ';
2789 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=actualizemulticurrencyrate">'.$langs->trans(
"ActualizeCurrency").
'</a>';
2797 if ($soc->outstanding_limit) {
2800 print $langs->trans(
'OutstandingBill');
2801 print
'</td><td class="valuefield">';
2802 $arrayoutstandingbills = $soc->getOutstandingBills();
2803 print($arrayoutstandingbills[
'opened'] > $soc->outstanding_limit ?
img_warning() :
'');
2804 print
price($arrayoutstandingbills[
'opened']).
' / ';
2805 print
price($soc->outstanding_limit, 0, $langs, 1, - 1, - 1, $conf->currency);
2810 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') && isModEnabled(
"banque")) {
2813 print
'<table width="100%" class="nobordernopadding"><tr><td>';
2814 print $langs->trans(
'BankAccount');
2816 if ($action !=
'editbankaccount' && $usercancreate) {
2817 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>';
2819 print
'</tr></table>';
2820 print
'</td><td class="valuefield">';
2821 if ($action ==
'editbankaccount') {
2822 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'fk_account', 1);
2824 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'none');
2830 $tmparray = $object->getTotalWeightVolume();
2831 $totalWeight = $tmparray[
'weight'];
2832 $totalVolume = $tmparray[
'volume'];
2834 print
'<tr><td>'.$langs->trans(
"CalculatedWeight").
'</td>';
2835 print
'<td class="valuefield">';
2836 print
showDimensionInBestUnit($totalWeight, 0,
"weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT :
'no', 0);
2840 print
'<tr><td>'.$langs->trans(
"CalculatedVolume").
'</td>';
2841 print
'<td class="valuefield">';
2842 print
showDimensionInBestUnit($totalVolume, 0,
"volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT :
'no', 0);
2847 if (isModEnabled(
'incoterm')) {
2849 print
'<table width="100%" class="nobordernopadding"><tr><td>';
2850 print $langs->trans(
'IncotermLabel');
2851 print
'<td><td class="right">';
2852 if ($action !=
'editincoterm' && $usercancreate && $caneditfield) {
2853 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/propal/card.php?id='.$object->id.
'&action=editincoterm&token='.newToken().
'">'.
img_edit().
'</a>';
2857 print
'</td></tr></table>';
2859 print
'<td class="valuefield">';
2860 if ($action ==
'editincoterm' && $usercancreate && $caneditfield) {
2861 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.$object->id);
2863 print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
2869 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2874 print
'<div class="fichehalfright">';
2875 print
'<div class="underbanner clearboth"></div>';
2877 print
'<table class="border tableforfield centpercent">';
2880 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
2881 print
'<td class="nowrap amountcard right">' .
price($object->total_ht,
'', $langs, 1, -1, -1, $conf->currency) .
'</td>';
2882 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2883 print
'<td class="nowrap amountcard right">' .
price($object->multicurrency_total_ht,
'', $langs, 1, -1, -1, $object->multicurrency_code) .
'</td>';
2888 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
2889 print
'<td class="nowrap amountcard right">' .
price($object->total_tva,
'', $langs, 1, -1, -1, $conf->currency) .
'</td>';
2890 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2891 print
'<td class="nowrap amountcard right">' .
price($object->multicurrency_total_tva,
'', $langs, 1, -1, -1, $object->multicurrency_code) .
'</td>';
2895 if ($mysoc->localtax1_assuj ==
"1" || $object->total_localtax1 != 0) {
2897 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
2898 print
'<td class="nowrap amountcard right">' .
price($object->total_localtax1,
'', $langs, 1, -1, -1, $conf->currency) .
'</td>';
2899 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2900 $object->multicurrency_total_localtax1 =
price2num($object->total_localtax1 * $object->multicurrency_tx,
'MT');
2902 print
'<td class="nowrap amountcard right">' .
price($object->multicurrency_total_localtax1,
'', $langs, 1, -1, -1, $object->multicurrency_code) .
'</td>';
2907 if ($mysoc->localtax2_assuj ==
"1" || $object->total_localtax2 != 0) {
2909 print
'<td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
2910 print
'<td class="nowrap amountcard right">' .
price($object->total_localtax2,
'', $langs, 1, -1, -1, $conf->currency) .
'</td>';
2911 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2912 $object->multicurrency_total_localtax2 =
price2num($object->total_localtax2 * $object->multicurrency_tx,
'MT');
2914 print
'<td class="nowrap amountcard right">' .
price($object->multicurrency_total_localtax2,
'', $langs, 1, -1, -1, $object->multicurrency_code) .
'</td>';
2920 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
2921 print
'<td class="nowrap amountcard right">' .
price($object->total_ttc,
'', $langs, 1, -1, -1, $conf->currency) .
'</td>';
2922 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2923 print
'<td class="nowrap amountcard right">' .
price($object->multicurrency_total_ttc,
'', $langs, 1, -1, -1, $object->multicurrency_code) .
'</td>';
2930 if (isModEnabled(
'margin')) {
2931 $formmargin->displayMarginInfos($object);
2937 print
'<div class="clearboth"></div><br>';
2940 $blocname =
'contacts';
2941 $title = $langs->trans(
'ContactsAddresses');
2942 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2946 $blocname =
'notes';
2947 $title = $langs->trans(
'Notes');
2948 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2956 $result = $object->getLinesArray();
2960 global $inputalsopricewithtax;
2961 $inputalsopricewithtax = 1;
2963 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">
2964 <input type="hidden" name="token" value="' . newToken().
'">
2965 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
2966 <input type="hidden" name="mode" value="">
2967 <input type="hidden" name="page_y" value="">
2968 <input type="hidden" name="backtopage" value="'.$backtopage.
'">
2969 <input type="hidden" name="id" value="' . $object->id.
'">
2973 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
2976 print
'<div class="div-table-responsive-no-min">';
2977 if (!empty($object->lines) || ($object->statut ==
Propal::STATUS_DRAFT && $usercancreate && $action !=
'selectlines' && $action !=
'editline')) {
2978 print
'<table id="tablelines" class="noborder noshadow centpercent">';
2981 if (!empty($object->lines)) {
2982 $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 1);
2987 if ($action !=
'editline') {
2988 $parameters = array();
2989 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
2993 if (empty($reshook)) {
2994 $object->formAddObjectLine(1, $mysoc, $soc);
2997 $parameters = array();
2998 $reshook = $hookmanager->executeHooks(
'formEditObjectLine', $parameters, $object, $action);
3002 if (!empty($object->lines) || ($object->statut ==
Propal::STATUS_DRAFT && $usercancreate && $action !=
'selectlines' && $action !=
'editline')) {
3017 if ($action !=
'presend') {
3018 print
'<div class="tabsAction">';
3020 $parameters = array();
3021 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3023 if (empty($reshook)) {
3024 if ($action !=
'editline') {
3026 if (($object->statut ==
Propal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0)
3028 if ($usercanvalidate) {
3029 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>';
3031 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
'Validate').
'</a>';
3041 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=modif&token='.newToken().
'">'.$langs->trans(
'Modify').
'</a>';
3046 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=reopen&token='.newToken().(!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#reopen').
'"';
3047 print
'>'.$langs->trans(
'ReOpen').
'</a>';
3051 if (empty($user->socid)) {
3053 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.newToken().
'&id='.$object->id.
'&mode=init#formmailbeforetitle',
'', $usercansend);
3059 if ($usercancreateorder) {
3060 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/commande/card.php?action=create&origin='.$object->element.
'&originid='.$object->id.
'&socid='.$object->socid.
'">'.$langs->trans(
"AddOrder").
'</a>';
3067 if ($usercancreatepurchaseorder) {
3068 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/commande/card.php?action=create&origin='.$object->element.
'&originid='.$object->id.
'&socid='.$object->socid.
'">'.$langs->trans(
"AddPurchaseOrder").
'</a>';
3074 if (isModEnabled(
"service") && isModEnabled(
'ficheinter') && $object->statut ==
Propal::STATUS_SIGNED) {
3075 if ($usercancreateintervention) {
3076 $langs->load(
"interventions");
3077 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/fichinter/card.php?action=create&origin='.$object->element.
'&originid='.$object->id.
'&socid='.$object->socid.
'">'.$langs->trans(
"AddIntervention").
'</a>';
3083 $langs->load(
"contracts");
3085 if ($usercancreatecontract) {
3086 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/contrat/card.php?action=create&origin='.$object->element.
'&originid='.$object->id.
'&socid='.$object->socid.
'">'.$langs->trans(
'AddContract').
'</a>';
3092 if (isModEnabled(
'facture') && $usercancreateinvoice) {
3093 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/compta/facture/card.php?action=create&origin='.$object->element.
'&originid='.$object->id.
'&socid='.$object->socid.
'">'.$langs->trans(
"CreateBill").
'</a>';
3096 $arrayofinvoiceforpropal = $object->getInvoiceArrayList();
3097 if ((is_array($arrayofinvoiceforpropal) && count($arrayofinvoiceforpropal) > 0) || !
getDolGlobalString(
'WORKFLOW_PROPAL_NEED_INVOICE_TO_BE_CLASSIFIED_BILLED')) {
3098 if ($usercanclose) {
3099 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=classifybilled&token='.newToken().
'&socid='.$object->socid.
'">'.$langs->trans(
"ClassifyBilled").
'</a>';
3101 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
"ClassifyBilled").
'</a>';
3109 if ($usercanclose) {
3110 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=closeas&token='.newToken().(!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#close').
'"';
3111 print
'>'.$langs->trans(
'SetAcceptedRefused').
'</a>';
3113 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'"';
3114 print
'>'.$langs->trans(
'SetAcceptedRefused').
'</a>';
3120 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' . $object->id .
'&token='.newToken().
'&action=closeas&token='.newToken() . (!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#close') .
'"';
3121 print
'>' . $langs->trans(
'SetRefusedAndClose') .
'</a>';
3126 if ($usercancreate) {
3127 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&socid='.$object->socid.
'&action=clone&token='.newToken().
'&object='.$object->element.
'">'.$langs->trans(
"ToClone").
'</a>';
3131 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.newToken(),
'delete', $usercandelete);
3139 if (
GETPOST(
'modelselected')) {
3140 $action =
'presend';
3143 if ($action !=
'presend') {
3144 print
'<div class="fichecenter"><div class="fichehalfleft">';
3145 print
'<a name="builddoc"></a>';
3150 $filedir = $conf->propal->multidir_output[$object->entity].
"/".
dol_sanitizeFileName($object->ref);
3151 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
3152 $genallowed = $usercanread;
3153 $delallowed = $usercancreate;
3155 print $formfile->showdocuments(
'propal', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'', 0,
'', $soc->default_lang,
'', $object);
3158 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'propal'));
3160 $compatibleImportElementsList =
false;
3162 $compatibleImportElementsList = array(
'commande',
'propal',
'facture');
3164 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList);
3170 print
'<br><!-- Link to sign -->';
3171 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
3172 print showOnlineSignatureUrl(
'proposal', $object->ref).
'<br>';
3175 print
'</div><div class="fichehalfright">';
3179 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/comm/propal/agenda.php?id='.$object->id);
3182 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3184 $somethingshown =
$formactions->showactions($object,
'propal', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3186 print
'</div></div>';
3190 $modelmail =
'propal_send';
3191 $defaulttopic =
'SendPropalRef';
3192 $diroutput = $conf->propal->multidir_output[$object->entity];
3193 $trackid =
'pro'.$object->id;
3195 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif( $action=='specimen') elseif($action=='setmodel') elseif( $action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
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.
static getIdAndTxFromCode($dbs, $code, $date_document='')
Get id and rate of currency from code.
Class to manage notifications.
Class ProductCombination Used to represent a product combination.
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_VALIDATED
Validated status.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $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.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0)
Set event message in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
getDictionaryValue($tablename, $field, $id, $checkentity=false, $rowidfield='rowid')
Return the value of a filed into a dictionary for the record $id.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
propal_prepare_head($object)
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.