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');
1769 if (!empty($origin) && !empty($originid)) {
1771 $element = $subelement = $origin;
1773 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
1774 $element = $regs[1];
1775 $subelement = $regs[2];
1778 if ($element ==
'project') {
1779 $projectid = $originid;
1782 if ($element ==
'order' || $element ==
'commande') {
1783 $element = $subelement =
'commande';
1785 if ($element ==
'propal') {
1786 $element =
'comm/propal';
1787 $subelement =
'propal';
1789 if ($element ==
'contract') {
1790 $element = $subelement =
'contrat';
1792 if ($element ==
'shipping') {
1793 $element = $subelement =
'expedition';
1798 $classname = ucfirst($subelement);
1799 $objectsrc =
new $classname($db);
1800 $objectsrc->fetch($originid);
1801 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1802 $objectsrc->fetch_lines();
1804 $objectsrc->fetch_thirdparty();
1806 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : 0);
1807 $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client :
'');
1809 $soc = $objectsrc->thirdparty;
1811 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1812 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1813 $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
1816 $objectsrc->fetch_optionals();
1817 $object->array_options = $objectsrc->array_options;
1819 if (isModEnabled(
"multicurrency")) {
1820 if (!empty($objectsrc->multicurrency_code)) {
1821 $currency_code = $objectsrc->multicurrency_code;
1823 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
1824 $currency_tx = $objectsrc->multicurrency_tx;
1829 $cond_reglement_id = empty($soc->cond_reglement_id) ? $cond_reglement_id : $soc->cond_reglement_id;
1830 $deposit_percent = empty($soc->deposit_percent) ? $deposit_percent : $soc->deposit_percent;
1831 $mode_reglement_id = empty($soc->mode_reglement_id) ? $mode_reglement_id : $soc->mode_reglement_id;
1832 $fk_account = empty($soc->fk_account) ? $fk_account : $soc->fk_account;
1833 $shipping_method_id = $soc->shipping_method_id;
1834 $warehouse_id = $soc->fk_warehouse;
1835 $remise_percent = $soc->remise_percent;
1837 if (isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
1838 $currency_code = $soc->multicurrency_code;
1843 if (!
GETPOST(
'changecompany')) {
1844 if (GETPOSTISSET(
'cond_reglement_id')) {
1845 $cond_reglement_id =
GETPOST(
'cond_reglement_id',
'int');
1847 if (GETPOSTISSET(
'deposit_percent')) {
1850 if (GETPOSTISSET(
'mode_reglement_id')) {
1851 $mode_reglement_id =
GETPOST(
'mode_reglement_id',
'int');
1853 if (GETPOSTISSET(
'cond_reglement_id')) {
1854 $fk_account =
GETPOST(
'fk_account',
'int');
1859 if ($soc->fk_warehouse > 0) {
1860 $warehouse_id = $soc->fk_warehouse;
1862 if (isModEnabled(
'stock') && empty($warehouse_id) &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')) {
1864 $warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE;
1866 if (empty($object->warehouse_id) &&
getDolGlobalString(
'MAIN_DEFAULT_WAREHOUSE_USER')) {
1867 $warehouse_id = $user->fk_warehouse;
1871 print
'<form name="addprop" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1872 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1873 print
'<input type="hidden" name="action" value="add">';
1874 print
'<input type="hidden" name="changecompany" value="0">';
1875 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1876 if ($origin !=
'project' && $originid) {
1877 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1878 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1879 } elseif ($origin ==
'project' && !empty($projectid)) {
1880 print
'<input type="hidden" name="projectid" value="'.$projectid.
'">';
1886 $parameters = array();
1888 $reshook = $hookmanager->executeHooks(
'tabContentCreateProposal', $parameters, $object, $action);
1889 if (empty($reshook)) {
1890 print
'<table class="border centpercent">';
1893 print
'<tr class="field_ref"><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td class="valuefieldcreate">'.$langs->trans(
"Draft").
'</td></tr>';
1896 print
'<tr class="field_ref_client"><td class="titlefieldcreate">'.$langs->trans(
'RefCustomer').
'</td><td class="valuefieldcreate">';
1897 print
'<input type="text" name="ref_client" value="'.(!empty($ref_client) ? $ref_client :
GETPOST(
'ref_client')).
'"></td>';
1901 print
'<tr class="field_socid">';
1902 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Customer').
'</td>';
1903 $shipping_method_id = 0;
1905 print
'<td class="valuefieldcreate">';
1906 print $soc->getNomUrl(1,
'customer');
1907 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1909 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($soc->shipping_method_id)) {
1910 $shipping_method_id = $soc->shipping_method_id;
1914 print
'<td class="valuefieldcreate">';
1915 $filter =
'((s.client:IN:1,2,3) AND (s.status:=:1))';
1916 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid', $filter,
'SelectThirdParty', 1, 0,
null, 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
1920 $(document).ready(function() {
1921 $("#socid").change(function() {
1922 console.log("We have changed the company - Reload page");
1923 var socid = $(this).val();
1925 $("input[name=action]").val("create");
1926 $("input[name=changecompany]").val("1");
1927 $("form[name=addprop]").submit();
1932 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>';
1939 print
'<tr class="field_contactid"><td class="titlefieldcreate">'.$langs->trans(
"DefaultContact").
'</td><td class="valuefieldcreate">';
1940 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
1941 print $form->selectcontacts($soc->id, $contactid,
'contactid', 1,
'',
'', 0,
'minwidth300');
1945 print
'<tr class="field_discount_info"><td class="titlefieldcreate">'.$langs->trans(
'Discounts').
'</td><td class="valuefieldcreate">';
1947 $absolute_discount = $soc->getAvailableDiscounts();
1951 $backtopage = $_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.urlencode(
GETPOST(
'origin')).
'&originid='.urlencode(
GETPOSTINT(
'originid'));
1952 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1957 print
'<tr class="field_addprop"><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'DatePropal').
'</td><td class="valuefieldcreate">';
1958 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1959 print $form->selectDate(
'',
'',
'',
'',
'',
"addprop", 1, 1);
1963 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>';
1966 print
'<tr class="field_cond_reglement_id"><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
1967 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
1969 print $form->getSelectConditionsPaiements($cond_reglement_id,
'cond_reglement_id', 1, 1, 0,
'', $deposit_percent);
1973 print
'<tr class="field_mode_reglement_id"><td class="titlefieldcreate">'.$langs->trans(
'PaymentMode').
'</td><td class="valuefieldcreate">';
1974 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1975 print $form->select_types_paiements($mode_reglement_id,
'mode_reglement_id',
'CRDT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx', 1);
1979 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') && isModEnabled(
"banque")) {
1980 print
'<tr class="field_fk_account"><td class="titlefieldcreate">'.$langs->trans(
'BankAccount').
'</td><td class="valuefieldcreate">';
1981 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes($fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
1986 print
'<tr class="field_demand_reason_id"><td class="titlefieldcreate">'.$langs->trans(
'Source').
'</td><td class="valuefieldcreate">';
1987 print
img_picto(
'',
'question',
'class="pictofixedwidth"');
1988 $form->selectInputReason((GETPOSTISSET(
'demand_reason_id') ?
GETPOST(
'demand_reason_id',
'int') :
''),
'demand_reason_id',
"SRC_PROP", 1,
'maxwidth200 widthcentpercentminusx');
1992 if (isModEnabled(
"expedition")) {
1993 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($soc->shipping_method_id)) {
1994 $shipping_method_id = $soc->shipping_method_id;
1996 print
'<tr class="field_shipping_method_id"><td class="titlefieldcreate">'.$langs->trans(
'SendingMethod').
'</td><td class="valuefieldcreate">';
1997 print
img_picto(
'',
'dolly',
'class="pictofixedwidth"');
1998 $form->selectShippingMethod((GETPOSTISSET(
'shipping_method_id') ?
GETPOST(
'shipping_method_id',
'int') : $shipping_method_id),
'shipping_method_id',
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx');
2003 if (isModEnabled(
'stock') &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL')) {
2004 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2006 print
'<tr class="field_warehouse_id"><td class="titlefieldcreate">'.$langs->trans(
'Warehouse').
'</td><td class="valuefieldcreate">';
2007 print
img_picto(
'',
'stock',
'class="pictofixedwidth"').$formproduct->selectWarehouses($warehouse_id,
'warehouse_id',
'', 1, 0, 0,
'', 0, 0, array(),
'maxwidth500 widthcentpercentminusxx');
2012 print
'<tr class="field_availability_id"><td class="titlefieldcreate">'.$langs->trans(
'AvailabilityPeriod');
2013 if (isModEnabled(
'commande')) {
2014 print
' ('.$langs->trans(
'AfterOrder').
')';
2016 print
'</td><td class="valuefieldcreate">';
2017 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
2018 $form->selectAvailabilityDelay((GETPOSTISSET(
'availability_id') ?
GETPOST(
'availability_id',
'int') :
''),
'availability_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
2022 print
'<tr class="field_date_livraison"><td class="titlefieldcreate">'.$langs->trans(
"DeliveryDate").
'</td>';
2023 print
'<td class="valuefieldcreate">';
2024 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2026 $tmpdte = time() + (7 *
getDolGlobalInt(
'DATE_LIVRAISON_WEEK_DELAY') * 24 * 60 * 60);
2027 $syear = date(
"Y", $tmpdte);
2028 $smonth = date(
"m", $tmpdte);
2029 $sday = date(
"d", $tmpdte);
2030 print $form->selectDate($syear.
"-".$smonth.
"-".$sday,
'date_livraison',
'',
'',
'',
"addprop");
2032 print $form->selectDate(-1,
'date_livraison',
'',
'',
'',
"addprop", 1, 1);
2037 if (isModEnabled(
'project')) {
2038 $langs->load(
"projects");
2039 print
'<tr class="field_projectid">';
2040 print
'<td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td class="valuefieldcreate">';
2041 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');
2042 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>';
2048 if (isModEnabled(
'incoterm')) {
2049 print
'<tr class="field_incoterm_id">';
2050 print
'<td class="titlefieldcreate"><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), $soc->label_incoterms, 1).
'</label></td>';
2051 print
'<td class="valuefieldcreate maxwidthonsmartphone">';
2052 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2053 print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms :
''), (!empty($soc->location_incoterms) ? $soc->location_incoterms :
''));
2058 print
'<tr class="field_model">';
2059 print
'<td class="titlefieldcreate">'.$langs->trans(
"DefaultModel").
'</td>';
2060 print
'<td class="valuefieldcreate">';
2061 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
2064 print $form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
2068 if (isModEnabled(
"multicurrency")) {
2069 print
'<tr class="field_currency">';
2070 print
'<td class="titlefieldcreate">'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
2071 print
'<td class="valuefieldcreate maxwidthonsmartphone">';
2072 print
img_picto(
'',
'currency',
'class="pictofixedwidth"').$form->selectMultiCurrency(((GETPOSTISSET(
'multicurrency_code') && !
GETPOST(
'changecompany')) ?
GETPOST(
'multicurrency_code') : $currency_code),
'multicurrency_code', 0);
2077 print
'<tr class="field_note_public">';
2078 print
'<td class="titlefieldcreate tdtop">'.$langs->trans(
'NotePublic').
'</td>';
2079 print
'<td class="valuefieldcreate">';
2080 $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');
2081 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In', 0,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
2082 print $doleditor->Create(1);
2085 if (empty($user->socid)) {
2086 print
'<tr class="field_note_private">';
2087 print
'<td class="titlefieldcreate tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
2088 print
'<td class="valuefieldcreate">';
2089 $note_private = $object->getDefaultCreateValueFor(
'note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc)) ? $objectsrc->note_private : null));
2090 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In', 0,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
2091 print $doleditor->Create(1);
2097 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
2100 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2102 if ($origin ==
'contrat') {
2106 $objectsrc->update_price(1,
'auto', 1);
2109 print
"\n<!-- ".$classname.
" info -->";
2111 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2112 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2113 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2114 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2115 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2117 $newclassname = $classname;
2118 if ($newclassname ==
'Propal') {
2119 $newclassname =
'CommercialProposal';
2120 } elseif ($newclassname ==
'Commande') {
2121 $newclassname =
'Order';
2122 } elseif ($newclassname ==
'Expedition') {
2123 $newclassname =
'Sending';
2124 } elseif ($newclassname ==
'Fichinter') {
2125 $newclassname =
'Intervention';
2128 print
'<tr><td>'.$langs->trans($newclassname).
'</td><td>'.$objectsrc->getNomUrl(1).
'</td></tr>';
2129 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht, 0, $langs, 1, -1, -1, $conf->currency).
'</td></tr>';
2130 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva, 0, $langs, 1, -1, -1, $conf->currency).
"</td></tr>";
2131 if ($mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
2132 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1, 0, $langs, 1, -1, -1, $conf->currency).
"</td></tr>";
2135 if ($mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
2136 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2, 0, $langs, 1, -1, -1, $conf->currency).
"</td></tr>";
2138 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc, 0, $langs, 1, -1, -1, $conf->currency).
"</td></tr>";
2140 if (isModEnabled(
"multicurrency")) {
2141 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
2142 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
2143 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2155 print
'<input type="hidden" name="createmode" value="empty">';
2159 print
'<br><table>';
2163 print
'<td><input type="radio" name="createmode" value="copy"></td>';
2164 print
'<td>'.$langs->trans(
"CopyPropalFrom").
' </td>';
2166 $liste_propal = array();
2167 $liste_propal [0] =
'';
2169 $sql =
"SELECT p.rowid as id, p.ref, s.nom";
2170 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal p";
2171 $sql .=
", ".MAIN_DB_PREFIX.
"societe s";
2172 $sql .=
" WHERE s.rowid = p.fk_soc";
2173 $sql .=
" AND p.entity IN (".getEntity(
'propal').
")";
2174 $sql .=
" AND p.fk_statut <> 0";
2175 $sql .=
" ORDER BY Id";
2177 $resql = $db->query($sql);
2179 $num = $db->num_rows($resql);
2182 $row = $db->fetch_row($resql);
2183 $propalRefAndSocName = $row[1].
" - ".$row[2];
2184 $liste_propal[$row[0]] = $propalRefAndSocName;
2187 print $form->selectarray(
"copie_propal", $liste_propal, 0);
2193 print
'<tr><td class="tdtop"><input type="radio" name="createmode" value="empty" checked></td>';
2194 print
'<td valign="top" colspan="2">'.$langs->trans(
"CreateEmptyPropal").
'</td></tr>';
2201 $langs->load(
"bills");
2203 print $form->buttonsSaveCancel(
"CreateDraft");
2209 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2212 $title = $langs->trans(
'ProductsAndServices');
2215 print
'<div class="div-table-responsive-no-min">';
2216 print
'<table class="noborder centpercent">';
2218 $objectsrc->printOriginLinesList();
2223} elseif ($object->id > 0) {
2227 $object->fetch_thirdparty();
2228 if ($object->thirdparty) {
2229 $soc = $object->thirdparty;
2240 if ($action ==
'clone') {
2242 $filter =
'(s.client:IN:1,2,3)';
2243 $formquestion = array(
2246 array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' => $form->select_company(
GETPOST(
'socid',
'int'),
'socid', $filter,
'', 0, 0,
null, 0,
'maxwidth300')),
2247 array(
'type' =>
'checkbox',
'name' =>
'update_prices',
'label' => $langs->trans(
'PuttingPricesUpToDate'),
'value' => 0),
2248 array(
'type' =>
'checkbox',
'name' =>
'update_desc',
'label' => $langs->trans(
'PuttingDescUpToDate'),
'value' => 0),
2250 if (
getDolGlobalString(
'PROPAL_CLONE_DATE_DELIVERY') && !empty($object->delivery_date)) {
2251 $formquestion[] = array(
'type' =>
'date',
'name' =>
'date_delivery',
'label' => $langs->trans(
"DeliveryDate"),
'value' => $object->delivery_date);
2254 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmClonePropal', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
2257 if ($action ==
'closeas') {
2259 $formquestion = array();
2261 $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)));
2263 $formquestion[] = array(
'type' =>
'text',
'name' =>
'note_private',
'label' => $langs->trans(
"Note"),
'value' =>
'');
2265 if (
getDolGlobalInt(
'PROPOSAL_SUGGEST_DOWN_PAYMENT_INVOICE_CREATION')) {
2270 $deposit_percent_from_payment_terms =
getDictionaryValue(
'c_payment_term',
'deposit_percent', $object->cond_reglement_id);
2272 if (!empty($deposit_percent_from_payment_terms) && isModEnabled(
'facture') && $user->hasRight(
'facture',
'creer')) {
2273 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
2275 $object->fetchObjectLinked();
2277 $eligibleForDepositGeneration =
true;
2279 if (array_key_exists(
'facture', $object->linkedObjects)) {
2280 foreach ($object->linkedObjects[
'facture'] as $invoice) {
2282 $eligibleForDepositGeneration =
false;
2288 if ($eligibleForDepositGeneration && array_key_exists(
'commande', $object->linkedObjects)) {
2289 foreach ($object->linkedObjects[
'commande'] as $order) {
2290 $order->fetchObjectLinked();
2292 if (array_key_exists(
'facture', $order->linkedObjects)) {
2293 foreach ($order->linkedObjects[
'facture'] as $invoice) {
2295 $eligibleForDepositGeneration =
false;
2304 if ($eligibleForDepositGeneration) {
2305 $formquestion[] = array(
2306 'type' =>
'checkbox',
2307 'tdclass' =>
'showonlyifsigned',
2308 'name' =>
'generate_deposit',
2309 'morecss' =>
'margintoponly marginbottomonly',
2310 'label' => $form->textwithpicto($langs->trans(
'GenerateDeposit', $object->deposit_percent), $langs->trans(
'DepositGenerationPermittedByThePaymentTermsSelected'))
2313 $formquestion[] = array(
2315 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2317 'label' => $langs->trans(
'DateInvoice'),
2323 $formquestion[] = array(
2325 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2326 'name' =>
'date_pointoftax',
2327 'label' => $langs->trans(
'DatePointOfTax'),
2333 $paymentTermsSelect = $form->getSelectConditionsPaiements(0,
'cond_reglement_id', -1, 0, 1,
'minwidth200');
2335 $formquestion[] = array(
2337 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2338 'name' =>
'cond_reglement_id',
2339 'label' => $langs->trans(
'PaymentTerm'),
2340 'value' => $paymentTermsSelect
2343 $formquestion[] = array(
2344 'type' =>
'checkbox',
2345 'tdclass' =>
'showonlyifgeneratedeposit',
2346 'name' =>
'validate_generated_deposit',
2347 'morecss' =>
'margintoponly marginbottomonly',
2348 'label' => $langs->trans(
'ValidateGeneratedDeposit')
2351 $formquestion[] = array(
2352 'type' =>
'onecolumn',
2355 let signedValue = ' . $object::STATUS_SIGNED .
';
2357 $(document).ready(function() {
2358 $("[name=generate_deposit]").change(function () {
2359 let $self = $(this);
2360 let $target = $(".showonlyifgeneratedeposit").parent(".tagtr");
2362 if (! $self.parents(".tagtr").is(":hidden") && $self.is(":checked")) {
2371 $("#statut").change(function() {
2372 let $target = $(".showonlyifsigned").parent(".tagtr");
2374 if ($(this).val() == signedValue) {
2380 $("[name=generate_deposit]").trigger("change");
2385 $("#statut").trigger("change");
2394 if (isModEnabled(
'notification')) {
2395 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
2396 $notify =
new Notify($db);
2397 $formquestion = array_merge($formquestion, array(
2398 array(
'type' =>
'onecolumn',
'value' => $notify->confirmMessage(
'PROPAL_CLOSE_SIGNED', $object->socid, $object)),
2403 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'SetAcceptedRefused'),
'',
'confirm_closeas', $formquestion,
'', 1, 250);
2405 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?statut=3&id=' . $object->id, $langs->trans(
'Close'),
'',
'confirm_closeas', $formquestion,
'', 1, 250);
2407 } elseif ($action ==
'delete') {
2409 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteProp'), $langs->trans(
'ConfirmDeleteProp', $object->ref),
'confirm_delete',
'', 0, 1);
2410 } elseif ($action ==
'reopen') {
2412 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ReOpen'), $langs->trans(
'ConfirmReOpenProp', $object->ref),
'confirm_reopen',
'', 0, 1);
2413 } elseif ($action ==
'ask_deleteline') {
2415 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
2416 } elseif ($action ==
'validate') {
2421 $ref = substr($object->ref, 1, 4);
2422 if ($ref ==
'PROV' || $ref ==
'') {
2423 $numref = $object->getNextNumRef($soc);
2424 if (empty($numref)) {
2429 $numref = $object->ref;
2432 $text = $langs->trans(
'ConfirmValidateProp', $numref);
2433 if (isModEnabled(
'notification')) {
2434 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
2435 $notify =
new Notify($db);
2437 $text .= $notify->confirmMessage(
'PROPAL_VALIDATE', $object->socid, $object);
2442 foreach ($object->lines as $line) {
2443 $res = $line->fetch_product();
2445 if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end))) {
2451 if ($nbMandated > 0) {
2452 $text .=
'<div><span class="clearboth nowraponall warning">'.$langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate").
'</span></div>';
2456 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ValidateProp'), $text,
'confirm_validate',
'', 0, 1);
2461 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
2462 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2463 if (empty($reshook)) {
2464 $formconfirm .= $hookmanager->resPrint;
2465 } elseif ($reshook > 0) {
2466 $formconfirm = $hookmanager->resPrint;
2475 $linkback =
'<a href="'.DOL_URL_ROOT.
'/comm/propal/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
2477 $morehtmlref =
'<div class="refidno">';
2479 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client', $object->ref_client, $object, $usercancreate,
'string',
'', 0, 1);
2480 $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);
2482 $morehtmlref .=
'<br><span class="hideonsmartphone">'.$langs->trans(
'ThirdParty').
' : </span>'.$soc->getNomUrl(1,
'customer');
2484 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/comm/propal/list.php?socid='.$soc->id.
'&search_societe='.urlencode($soc->name).
'">'.$langs->trans(
"OtherProposals").
'</a>)';
2487 if (isModEnabled(
'project')) {
2488 $langs->load(
"projects");
2489 $morehtmlref .=
'<br>';
2490 if ($usercancreate) {
2491 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2492 if ($action !=
'classify') {
2493 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2495 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2497 if (!empty($object->fk_project)) {
2499 $proj->fetch($object->fk_project);
2500 $morehtmlref .= $proj->getNomUrl(1);
2502 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2507 $morehtmlref .=
'</div>';
2510 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2513 $parameters = array();
2515 $reshook = $hookmanager->executeHooks(
'tabContentViewProposal', $parameters, $object, $action);
2516 if (empty($reshook)) {
2517 print
'<div class="fichecenter">';
2518 print
'<div class="fichehalfleft">';
2519 print
'<div class="underbanner clearboth"></div>';
2521 print
'<table class="border tableforfield centpercent">';
2525 $filterabsolutediscount =
"fk_facture_source IS NULL";
2526 $filtercreditnote =
"fk_facture_source IS NOT NULL";
2528 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
2529 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
2532 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td>';
2534 $absolute_discount = $soc->getAvailableDiscounts(
'', $filterabsolutediscount);
2535 $absolute_creditnote = $soc->getAvailableDiscounts(
'', $filtercreditnote);
2536 $absolute_discount =
price2num($absolute_discount,
'MT');
2537 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
2543 $backtopage = $_SERVER[
"PHP_SELF"].
'?id='.$object->id;
2544 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2560 print $form->editfieldkey(
"DatePropal",
'date',
'', $object, $editenable);
2561 print
'</td><td class="valuefield">';
2562 if ($action ==
'editdate' && $usercancreate && $caneditfield) {
2563 print
'<form name="editdate" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
2564 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2565 print
'<input type="hidden" name="action" value="setdate">';
2566 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2567 print $form->selectDate($object->date,
're',
'',
'', 0,
"editdate");
2568 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2571 if ($object->date) {
2582 print
'<table class="nobordernopadding centpercent"><tr><td>';
2583 print $langs->trans(
'DateEndPropal');
2585 if ($action !=
'editecheance' && $usercancreate && $caneditfield) {
2586 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>';
2588 print
'</tr></table>';
2589 print
'</td><td class="valuefield">';
2590 if ($action ==
'editecheance' && $usercancreate && $caneditfield) {
2591 print
'<form name="editecheance" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
2592 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2593 print
'<input type="hidden" name="action" value="setecheance">';
2594 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2595 print $form->selectDate($object->fin_validite,
'ech',
'',
'',
'',
"editecheance");
2596 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2599 if (!empty($object->fin_validite)) {
2601 if ($object->statut ==
Propal::STATUS_VALIDATED && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) {
2613 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2614 print $langs->trans(
'PaymentConditionsShort');
2616 if ($action !=
'editconditions' && $usercancreate && $caneditfield) {
2617 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>';
2619 print
'</tr></table>';
2620 print
'</td><td class="valuefield">';
2621 if ($action ==
'editconditions' && $usercancreate && $caneditfield) {
2622 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'cond_reglement_id', 0,
'', 1, $object->deposit_percent);
2624 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'none', 0,
'', 1, $object->deposit_percent);
2630 print
'<tr class="field_mode_reglement_id">';
2631 print
'<td class="titlefieldcreate">';
2632 print
'<table class="nobordernopadding centpercent"><tr><td>';
2633 print $langs->trans(
'PaymentMode');
2635 if ($action !=
'editmode' && $usercancreate && $caneditfield) {
2636 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>';
2638 print
'</tr></table>';
2639 print
'</td><td class="valuefieldcreate">';
2640 if ($action ==
'editmode' && $usercancreate && $caneditfield) {
2641 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
2643 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'none');
2648 $langs->load(
'deliveries');
2650 print $form->editfieldkey($langs->trans(
'DeliveryDate'),
'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield,
'datepicker');
2651 print
'</td><td class="valuefieldedit">';
2652 print $form->editfieldval($langs->trans(
'DeliveryDate'),
'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield,
'datepicker');
2657 print
'<tr class="fielddeliverydelay"><td>';
2658 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2659 if (isModEnabled(
'commande')) {
2660 print $form->textwithpicto($langs->trans(
'AvailabilityPeriod'), $langs->trans(
'AvailabilityPeriod').
' ('.$langs->trans(
'AfterOrder').
')');
2662 print $langs->trans(
'AvailabilityPeriod');
2665 if ($action !=
'editavailability' && $usercancreate && $caneditfield) {
2666 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>';
2668 print
'</tr></table>';
2669 print
'</td><td class="valuefield">';
2670 if ($action ==
'editavailability' && $usercancreate && $caneditfield) {
2671 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->availability_id,
'availability_id', 1);
2673 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->availability_id,
'none', 1);
2680 if (isModEnabled(
"expedition")) {
2682 print
'<table class="nobordernopadding centpercent"><tr><td>';
2683 print $langs->trans(
'SendingMethod');
2685 if ($action !=
'editshippingmethod' && $usercancreate && $caneditfield) {
2686 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>';
2688 print
'</tr></table>';
2689 print
'</td><td class="valuefield">';
2690 if ($action ==
'editshippingmethod' && $usercancreate && $caneditfield) {
2691 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->shipping_method_id,
'shipping_method_id', 1);
2693 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->shipping_method_id,
'none');
2700 if (isModEnabled(
'stock') &&
getDolGlobalString(
'WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL')) {
2701 $langs->load(
'stocks');
2702 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2704 print
'<tr class="field_warehouse_id"><td class="titlefieldcreate">';
2705 $editenable = $usercancreate;
2706 print $form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, $editenable);
2707 print
'</td><td class="valuefieldcreate">';
2708 if ($action ==
'editwarehouse') {
2709 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->warehouse_id,
'warehouse_id', 1);
2711 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->warehouse_id,
'none');
2719 print
'<table class="nobordernopadding centpercent"><tr><td>';
2720 print $langs->trans(
'Source');
2722 if ($action !=
'editdemandreason' && $usercancreate) {
2723 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>';
2725 print
'</tr></table>';
2726 print
'</td><td class="valuefield">';
2727 if ($action ==
'editdemandreason' && $usercancreate) {
2728 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->demand_reason_id,
'demand_reason_id', 1);
2730 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->demand_reason_id,
'none');
2736 if (isModEnabled(
"multicurrency")) {
2740 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2741 print $form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0);
2743 if ($action !=
'editmulticurrencycode' && $object->statut == $object::STATUS_DRAFT && $usercancreate) {
2744 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>';
2746 print
'</tr></table>';
2747 print
'</td><td class="valuefield">';
2748 if ($object->statut == $object::STATUS_DRAFT && $action ==
'editmulticurrencycode' && $usercancreate) {
2749 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_code,
'multicurrency_code');
2751 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_code,
'none');
2756 if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) {
2759 print
'<table class="nobordernopadding" width="100%"><tr>';
2761 print $form->editfieldkey(
'CurrencyRate',
'multicurrency_tx',
'', $object, 0);
2763 if ($action !=
'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $usercancreate) {
2764 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>';
2766 print
'</tr></table>';
2767 print
'</td><td class="valuefield">';
2768 if ($object->statut == $object::STATUS_DRAFT && ($action ==
'editmulticurrencyrate' || $action ==
'actualizemulticurrencyrate') && $usercancreate) {
2769 if ($action ==
'actualizemulticurrencyrate') {
2772 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx,
'multicurrency_tx', $object->multicurrency_code);
2774 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx,
'none', $object->multicurrency_code);
2775 if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
2776 print
'<div class="inline-block"> ';
2777 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=actualizemulticurrencyrate">'.$langs->trans(
"ActualizeCurrency").
'</a>';
2785 if ($soc->outstanding_limit) {
2788 print $langs->trans(
'OutstandingBill');
2789 print
'</td><td class="valuefield">';
2790 $arrayoutstandingbills = $soc->getOutstandingBills();
2791 print($arrayoutstandingbills[
'opened'] > $soc->outstanding_limit ?
img_warning() :
'');
2792 print
price($arrayoutstandingbills[
'opened']).
' / ';
2793 print
price($soc->outstanding_limit, 0, $langs, 1, - 1, - 1, $conf->currency);
2798 if (
getDolGlobalString(
'BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL') && isModEnabled(
"banque")) {
2801 print
'<table width="100%" class="nobordernopadding"><tr><td>';
2802 print $langs->trans(
'BankAccount');
2804 if ($action !=
'editbankaccount' && $usercancreate) {
2805 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>';
2807 print
'</tr></table>';
2808 print
'</td><td class="valuefield">';
2809 if ($action ==
'editbankaccount') {
2810 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'fk_account', 1);
2812 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'none');
2818 $tmparray = $object->getTotalWeightVolume();
2819 $totalWeight = $tmparray[
'weight'];
2820 $totalVolume = $tmparray[
'volume'];
2822 print
'<tr><td>'.$langs->trans(
"CalculatedWeight").
'</td>';
2823 print
'<td class="valuefield">';
2824 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);
2828 print
'<tr><td>'.$langs->trans(
"CalculatedVolume").
'</td>';
2829 print
'<td class="valuefield">';
2830 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);
2835 if (isModEnabled(
'incoterm')) {
2837 print
'<table width="100%" class="nobordernopadding"><tr><td>';
2838 print $langs->trans(
'IncotermLabel');
2839 print
'<td><td class="right">';
2840 if ($action !=
'editincoterm' && $usercancreate && $caneditfield) {
2841 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/propal/card.php?id='.$object->id.
'&action=editincoterm&token='.newToken().
'">'.
img_edit().
'</a>';
2845 print
'</td></tr></table>';
2847 print
'<td class="valuefield">';
2848 if ($action ==
'editincoterm' && $usercancreate && $caneditfield) {
2849 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.$object->id);
2851 print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
2857 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2862 print
'<div class="fichehalfright">';
2863 print
'<div class="underbanner clearboth"></div>';
2865 print
'<table class="border tableforfield centpercent">';
2868 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
2869 print
'<td class="nowrap amountcard right">' .
price($object->total_ht,
'', $langs, 1, -1, -1, $conf->currency) .
'</td>';
2870 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2871 print
'<td class="nowrap amountcard right">' .
price($object->multicurrency_total_ht,
'', $langs, 1, -1, -1, $object->multicurrency_code) .
'</td>';
2876 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountVAT') .
'</td>';
2877 print
'<td class="nowrap amountcard right">' .
price($object->total_tva,
'', $langs, 1, -1, -1, $conf->currency) .
'</td>';
2878 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2879 print
'<td class="nowrap amountcard right">' .
price($object->multicurrency_total_tva,
'', $langs, 1, -1, -1, $object->multicurrency_code) .
'</td>';
2883 if ($mysoc->localtax1_assuj ==
"1" || $object->total_localtax1 != 0) {
2885 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
2886 print
'<td class="nowrap amountcard right">' .
price($object->total_localtax1,
'', $langs, 1, -1, -1, $conf->currency) .
'</td>';
2887 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2888 $object->multicurrency_total_localtax1 =
price2num($object->total_localtax1 * $object->multicurrency_tx,
'MT');
2890 print
'<td class="nowrap amountcard right">' .
price($object->multicurrency_total_localtax1,
'', $langs, 1, -1, -1, $object->multicurrency_code) .
'</td>';
2895 if ($mysoc->localtax2_assuj ==
"1" || $object->total_localtax2 != 0) {
2897 print
'<td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
2898 print
'<td class="nowrap amountcard right">' .
price($object->total_localtax2,
'', $langs, 1, -1, -1, $conf->currency) .
'</td>';
2899 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2900 $object->multicurrency_total_localtax2 =
price2num($object->total_localtax2 * $object->multicurrency_tx,
'MT');
2902 print
'<td class="nowrap amountcard right">' .
price($object->multicurrency_total_localtax2,
'', $langs, 1, -1, -1, $object->multicurrency_code) .
'</td>';
2908 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
2909 print
'<td class="nowrap amountcard right">' .
price($object->total_ttc,
'', $langs, 1, -1, -1, $conf->currency) .
'</td>';
2910 if (isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2911 print
'<td class="nowrap amountcard right">' .
price($object->multicurrency_total_ttc,
'', $langs, 1, -1, -1, $object->multicurrency_code) .
'</td>';
2918 if (isModEnabled(
'margin')) {
2919 $formmargin->displayMarginInfos($object);
2925 print
'<div class="clearboth"></div><br>';
2928 $blocname =
'contacts';
2929 $title = $langs->trans(
'ContactsAddresses');
2930 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2934 $blocname =
'notes';
2935 $title = $langs->trans(
'Notes');
2936 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2944 $result = $object->getLinesArray();
2948 global $inputalsopricewithtax;
2949 $inputalsopricewithtax = 1;
2951 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">
2952 <input type="hidden" name="token" value="' . newToken().
'">
2953 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
2954 <input type="hidden" name="mode" value="">
2955 <input type="hidden" name="page_y" value="">
2956 <input type="hidden" name="backtopage" value="'.$backtopage.
'">
2957 <input type="hidden" name="id" value="' . $object->id.
'">
2961 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
2964 print
'<div class="div-table-responsive-no-min">';
2965 if (!empty($object->lines) || ($object->statut ==
Propal::STATUS_DRAFT && $usercancreate && $action !=
'selectlines' && $action !=
'editline')) {
2966 print
'<table id="tablelines" class="noborder noshadow centpercent">';
2969 if (!empty($object->lines)) {
2970 $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 1);
2975 if ($action !=
'editline') {
2976 $parameters = array();
2977 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
2981 if (empty($reshook)) {
2982 $object->formAddObjectLine(1, $mysoc, $soc);
2985 $parameters = array();
2986 $reshook = $hookmanager->executeHooks(
'formEditObjectLine', $parameters, $object, $action);
2990 if (!empty($object->lines) || ($object->statut ==
Propal::STATUS_DRAFT && $usercancreate && $action !=
'selectlines' && $action !=
'editline')) {
3005 if ($action !=
'presend') {
3006 print
'<div class="tabsAction">';
3008 $parameters = array();
3009 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3011 if (empty($reshook)) {
3012 if ($action !=
'editline') {
3014 if (($object->statut ==
Propal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0)
3016 if ($usercanvalidate) {
3017 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>';
3019 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
'Validate').
'</a>';
3029 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=modif&token='.newToken().
'">'.$langs->trans(
'Modify').
'</a>';
3034 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=reopen&token='.newToken().(!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#reopen').
'"';
3035 print
'>'.$langs->trans(
'ReOpen').
'</a>';
3039 if (empty($user->socid)) {
3041 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.newToken().
'&id='.$object->id.
'&mode=init#formmailbeforetitle',
'', $usercansend);
3047 if ($usercancreateorder) {
3048 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>';
3055 if ($usercancreatepurchaseorder) {
3056 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>';
3062 if (isModEnabled(
"service") && isModEnabled(
'ficheinter') && $object->statut ==
Propal::STATUS_SIGNED) {
3063 if ($usercancreateintervention) {
3064 $langs->load(
"interventions");
3065 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>';
3071 $langs->load(
"contracts");
3073 if ($usercancreatecontract) {
3074 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>';
3080 if (isModEnabled(
'facture') && $usercancreateinvoice) {
3081 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>';
3084 $arrayofinvoiceforpropal = $object->getInvoiceArrayList();
3085 if ((is_array($arrayofinvoiceforpropal) && count($arrayofinvoiceforpropal) > 0) || !
getDolGlobalString(
'WORKFLOW_PROPAL_NEED_INVOICE_TO_BE_CLASSIFIED_BILLED')) {
3086 if ($usercanclose) {
3087 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=classifybilled&token='.newToken().
'&socid='.$object->socid.
'">'.$langs->trans(
"ClassifyBilled").
'</a>';
3089 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
"ClassifyBilled").
'</a>';
3097 if ($usercanclose) {
3098 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=closeas&token='.newToken().(!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#close').
'"';
3099 print
'>'.$langs->trans(
'SetAcceptedRefused').
'</a>';
3101 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'"';
3102 print
'>'.$langs->trans(
'SetAcceptedRefused').
'</a>';
3108 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' . $object->id .
'&token='.newToken().
'&action=closeas&token='.newToken() . (!
getDolGlobalString(
'MAIN_JUMP_TAG') ?
'' :
'#close') .
'"';
3109 print
'>' . $langs->trans(
'SetRefusedAndClose') .
'</a>';
3114 if ($usercancreate) {
3115 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>';
3119 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.newToken(),
'delete', $usercandelete);
3127 if (
GETPOST(
'modelselected')) {
3128 $action =
'presend';
3131 if ($action !=
'presend') {
3132 print
'<div class="fichecenter"><div class="fichehalfleft">';
3133 print
'<a name="builddoc"></a>';
3138 $filedir = $conf->propal->multidir_output[$object->entity].
"/".
dol_sanitizeFileName($object->ref);
3139 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
3140 $genallowed = $usercanread;
3141 $delallowed = $usercancreate;
3143 print $formfile->showdocuments(
'propal', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'', 0,
'', $soc->default_lang,
'', $object);
3146 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'propal'));
3148 $compatibleImportElementsList =
false;
3150 $compatibleImportElementsList = array(
'commande',
'propal',
'facture');
3152 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList);
3158 print
'<br><!-- Link to sign -->';
3159 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
3160 print showOnlineSignatureUrl(
'proposal', $object->ref).
'<br>';
3163 print
'</div><div class="fichehalfright">';
3167 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/comm/propal/agenda.php?id='.$object->id);
3170 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3172 $somethingshown =
$formactions->showactions($object,
'propal', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3174 print
'</div></div>';
3178 $modelmail =
'propal_send';
3179 $defaulttopic =
'SendPropalRef';
3180 $diroutput = $conf->propal->multidir_output[$object->entity];
3181 $trackid =
'pro'.$object->id;
3183 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.