41 require
'../../main.inc.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formpropal.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/core/modules/propale/modules_propale.php';
49 require_once DOL_DOCUMENT_ROOT.
'/core/lib/propal.lib.php';
50 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
51 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
52 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
55 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
59 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
63 $langs->loadLangs(array(
'companies',
'propal',
'compta',
'bills',
'orders',
'products',
'deliveries',
'sendings',
'other'));
65 $langs->load(
'incoterm');
68 $langs->load(
'margins');
75 $socid =
GETPOST(
'socid',
'int');
76 $action =
GETPOST(
'action',
'aZ09');
77 $cancel =
GETPOST(
'cancel',
'alpha');
78 $origin =
GETPOST(
'origin',
'alpha');
79 $originid =
GETPOST(
'originid',
'int');
80 $confirm =
GETPOST(
'confirm',
'alpha');
81 $lineid =
GETPOST(
'lineid',
'int');
82 $contactid =
GETPOST(
'contactid',
'int');
83 $projectid =
GETPOST(
'projectid',
'int');
84 $rank = (
GETPOST(
'rank',
'int') > 0) ?
GETPOST(
'rank',
'int') : -1;
87 $hidedetails = (
GETPOST(
'hidedetails',
'int') ?
GETPOST(
'hidedetails',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
88 $hidedesc = (
GETPOST(
'hidedesc',
'int') ?
GETPOST(
'hidedesc',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
89 $hideref = (
GETPOST(
'hideref',
'int') ?
GETPOST(
'hideref',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
95 $extrafields->fetch_name_optionals_label($object->table_element);
98 if ($id > 0 || !empty($ref)) {
99 $ret = $object->fetch($id, $ref);
101 $ret = $object->fetch_thirdparty();
110 $hookmanager->initHooks(array(
'propalcard',
'globalcard'));
112 $usercanread = $user->hasRight(
"propal",
"lire");
113 $usercancreate = $user->hasRight(
"propal",
"creer");
114 $usercandelete = $user->hasRight(
"propal",
"supprimer");
116 $usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->close)));
117 $usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->validate)));
118 $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->propal->propal_advance->send)));
120 $usermustrespectpricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
121 $usercancreateorder = $user->hasRight(
'commande',
'creer');
122 $usercancreateinvoice = $user->hasRight(
'facture',
'creer');
123 $usercancreatecontract = $user->hasRight(
'contrat',
'creer');
124 $usercancreateintervention = $user->hasRight(
'ficheinter',
'creer');
125 $usercancreatepurchaseorder = ($user->hasRight(
'fournisseur',
'commande',
'creer') || $user->hasRight(
'supplier_order',
'creer'));
127 $permissionnote = $usercancreate;
128 $permissiondellink = $usercancreate;
129 $permissiontoedit = $usercancreate;
132 if (!empty($user->socid)) {
133 $socid = $user->socid;
143 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
148 if (empty($reshook)) {
149 $backurlforlist = DOL_URL_ROOT.
'/comm/propal/list.php';
151 if (empty($backtopage) || ($cancel && empty($id))) {
152 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
153 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
154 $backtopage = $backurlforlist;
156 $backtopage = DOL_URL_ROOT.
'/comm/propal/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
162 if (!empty($backtopageforcancel)) {
163 header(
"Location: ".$backtopageforcancel);
165 } elseif (!empty($backtopage)) {
166 header(
"Location: ".$backtopage);
172 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
174 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
176 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
179 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
183 if ($object->id > 0) {
184 if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY)) {
190 GETPOST(
'date_deliverymonth',
'int'),
191 GETPOST(
'date_deliveryday',
'int'),
192 GETPOST(
'date_deliveryyear',
'int')
194 $date_delivery_old = (empty($object->delivery_date) ? $object->date_livraison : $object->delivery_date);
195 if (!empty($date_delivery_old) && !empty($date_delivery)) {
206 $difference = $date_delivery - $old_date_delivery;
207 if ($difference != 0) {
208 $object->date_livraison = $date_delivery;
209 $object->delivery_date = $date_delivery;
210 foreach ($object->lines as $line) {
211 if (isset($line->date_start)) {
212 $line->date_start = $line->date_start + $difference;
214 if (isset($line->date_end)) {
215 $line->date_end = $line->date_end + $difference;
222 $result = $object->createFromClone($user, $socid, (
GETPOSTISSET(
'entity') ?
GETPOST(
'entity',
'int') :
null), (
GETPOST(
'update_prices',
'aZ') ?
true :
false));
224 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
227 if (count($object->errors) > 0) {
234 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
236 $result = $object->delete($user);
238 header(
'Location: '.DOL_URL_ROOT.
'/comm/propal/list.php?restore_lastsearch_values=1');
241 $langs->load(
"errors");
244 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
246 $result = $object->deleteline($lineid);
249 $object->line_order(
true);
251 $langs->load(
"errors");
255 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
257 $outputlangs = $langs;
260 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') : $object->thirdparty->default_lang);
261 $outputlangs->setDefaultLang($newlang);
263 $ret = $object->fetch($id);
265 $object->fetch_thirdparty();
267 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
270 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
272 } elseif ($action ==
'confirm_validate' && $confirm ==
'yes' && $usercanvalidate) {
274 $idwarehouse =
GETPOST(
'idwarehouse',
'int');
275 $result = $object->valid($user);
276 if ( $result > 0 && ! empty($conf->global->PROPAL_SKIP_ACCEPT_REFUSE) ) {
277 $result = $object->closeProposal($user, $object::STATUS_SIGNED);
280 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
281 $outputlangs = $langs;
284 $newlang =
GETPOST(
'lang_id',
'aZ09');
287 $newlang = $object->thirdparty->default_lang;
289 if (!empty($newlang)) {
291 $outputlangs->setDefaultLang($newlang);
293 $model = $object->model_pdf;
294 $ret = $object->fetch($id);
296 $object->fetch_thirdparty();
299 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
302 $langs->load(
"errors");
303 if (count($object->errors) > 0) {
309 } elseif ($action ==
'setdate' && $usercancreate) {
314 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
318 $result = $object->set_date($user, $datep);
319 if ($result > 0 && !empty($object->duree_validite) && !empty($object->fin_validite)) {
320 $datev = $datep + ($object->duree_validite * 24 * 3600);
321 $result = $object->set_echeance($user, $datev, 1);
325 } elseif (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
326 $outputlangs = $langs;
329 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang)) $newlang = $object->thirdparty->default_lang;
330 if (!empty($newlang)) {
332 $outputlangs->setDefaultLang($newlang);
334 $model = $object->model_pdf;
335 $ret = $object->fetch($id);
337 $object->fetch_thirdparty();
340 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
343 } elseif ($action ==
'setecheance' && $usercancreate) {
346 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
347 $outputlangs = $langs;
350 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang)) $newlang = $object->thirdparty->default_lang;
351 if (!empty($newlang)) {
353 $outputlangs->setDefaultLang($newlang);
355 $model = $object->model_pdf;
356 $ret = $object->fetch($id);
358 $object->fetch_thirdparty();
361 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
366 } elseif ($action ==
'setdate_livraison' && $usercancreate) {
367 $result = $object->setDeliveryDate($user,
dol_mktime(12, 0, 0,
GETPOST(
'date_livraisonmonth',
'int'),
GETPOST(
'date_livraisonday',
'int'),
GETPOST(
'date_livraisonyear',
'int')));
371 } elseif ($action ==
'setref_client' && $usercancreate) {
373 $result = $object->set_ref_client($user,
GETPOST(
'ref_client'));
377 } elseif ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm') && $usercancreate) {
379 $result = $object->setIncoterms(
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
380 } elseif ($action ==
'add' && $usercancreate) {
382 $object->socid = $socid;
383 $object->fetch_thirdparty();
387 $duration =
GETPOST(
'duree_validite',
'int');
390 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DatePropal")),
null,
'errors');
394 if (empty($duration)) {
395 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ValidityDuration")),
null,
'errors');
401 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Customer")),
null,
'errors');
412 if ($object->fetch(
GETPOST(
'copie_propal',
'int')) > 0) {
414 $object->datep = $datep;
415 $object->date = $datep;
416 $object->date_livraison = $date_delivery;
417 $object->delivery_date = $date_delivery;
418 $object->availability_id =
GETPOST(
'availability_id');
419 $object->demand_reason_id =
GETPOST(
'demand_reason_id');
420 $object->fk_delivery_address =
GETPOST(
'fk_address',
'int');
421 $object->shipping_method_id =
GETPOST(
'shipping_method_id',
'int');
422 $object->warehouse_id =
GETPOST(
'warehouse_id',
'int');
423 $object->duree_validite = $duration;
424 $object->cond_reglement_id =
GETPOST(
'cond_reglement_id');
425 $object->deposit_percent =
GETPOST(
'cond_reglement_id_deposit_percent',
'alpha');
426 $object->mode_reglement_id =
GETPOST(
'mode_reglement_id');
427 $object->fk_account =
GETPOST(
'fk_account',
'int');
430 $object->socid =
GETPOST(
'socid',
'int');
431 $object->contact_id =
GETPOST(
'contactid',
'int');
432 $object->fk_project =
GETPOST(
'projectid',
'int');
433 $object->model_pdf =
GETPOST(
'model',
'alphanohtml');
434 $object->author = $user->id;
435 $object->user_author_id = $user->id;
436 $object->note_private =
GETPOST(
'note_private',
'restricthtml');
437 $object->note_public =
GETPOST(
'note_public',
'restricthtml');
439 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
440 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
446 $object->ref_client =
GETPOST(
'ref_client');
447 $object->datep = $datep;
448 $object->date = $datep;
449 $object->date_livraison = $date_delivery;
450 $object->delivery_date = $date_delivery;
451 $object->availability_id =
GETPOST(
'availability_id',
'int');
452 $object->demand_reason_id =
GETPOST(
'demand_reason_id',
'int');
453 $object->fk_delivery_address =
GETPOST(
'fk_address',
'int');
454 $object->shipping_method_id =
GETPOST(
'shipping_method_id',
'int');
455 $object->warehouse_id =
GETPOST(
'warehouse_id',
'int');
457 $object->cond_reglement_id =
GETPOST(
'cond_reglement_id',
'int');
458 $object->deposit_percent =
GETPOST(
'cond_reglement_id_deposit_percent',
'alpha');
459 $object->mode_reglement_id =
GETPOST(
'mode_reglement_id',
'int');
460 $object->fk_account =
GETPOST(
'fk_account',
'int');
461 $object->contact_id =
GETPOST(
'contactid',
'int');
462 $object->fk_project =
GETPOST(
'projectid',
'int');
463 $object->model_pdf =
GETPOST(
'model');
464 $object->author = $user->id;
465 $object->note_private =
GETPOST(
'note_private',
'restricthtml');
466 $object->note_public =
GETPOST(
'note_public',
'restricthtml');
467 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
468 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
470 $object->origin =
GETPOST(
'origin');
471 $object->origin_id =
GETPOST(
'originid');
475 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
479 $ret = $extrafields->setOptionalsFromPost(
null, $object);
487 if ($origin && $originid) {
489 $element = $subelement = $origin;
490 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
491 $element = $regs [1];
492 $subelement = $regs [2];
496 if ($element ==
'order') {
497 $element = $subelement =
'commande';
499 if ($element ==
'propal') {
500 $element =
'comm/propal';
501 $subelement =
'propal';
503 if ($element ==
'contract') {
504 $element = $subelement =
'contrat';
506 if ($element ==
'inter') {
507 $element = $subelement =
'ficheinter';
509 if ($element ==
'shipping') {
510 $element = $subelement =
'expedition';
513 $object->origin = $origin;
514 $object->origin_id = $originid;
517 $object->linked_objects [$object->origin] = $object->origin_id;
518 if (is_array($_POST[
'other_linked_objects']) && !empty($_POST[
'other_linked_objects'])) {
519 $object->linked_objects = array_merge($object->linked_objects, $_POST[
'other_linked_objects']);
522 $id = $object->create($user);
526 $classname = ucfirst($subelement);
527 $srcobject =
new $classname($db);
529 dol_syslog(
"Try to find source object origin=".$object->origin.
" originid=".$object->origin_id.
" to add lines");
530 $result = $srcobject->fetch($object->origin_id);
533 $lines = $srcobject->lines;
534 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
535 $srcobject->fetch_lines();
536 $lines = $srcobject->lines;
540 $num = count($lines);
541 for ($i = 0; $i < $num; $i++) {
542 $label = (!empty($lines[$i]->label) ? $lines[$i]->label :
'');
543 $desc = (!empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->libelle);
546 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
550 if ($lines[$i]->date_debut_prevue) {
551 $date_start = $lines[$i]->date_debut_prevue;
553 if ($lines[$i]->date_debut_reel) {
554 $date_start = $lines[$i]->date_debut_reel;
556 if ($lines[$i]->date_start) {
557 $date_start = $lines[$i]->date_start;
562 if ($lines[$i]->date_fin_prevue) {
563 $date_end = $lines[$i]->date_fin_prevue;
565 if ($lines[$i]->date_fin_reel) {
566 $date_end = $lines[$i]->date_fin_reel;
568 if ($lines[$i]->date_end) {
569 $date_end = $lines[$i]->date_end;
573 if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
578 if (method_exists($lines[$i],
'fetch_optionals')) {
579 $lines[$i]->fetch_optionals();
580 $array_options = $lines[$i]->array_options;
583 $tva_tx = $lines[$i]->tva_tx;
584 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', $tva_tx)) {
585 $tva_tx .=
' ('.$lines[$i]->vat_src_code.
')';
588 $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);
599 if ($result > 0 && $lines[$i]->product_type == 9) {
600 $fk_parent_line = $result;
606 $reshook = $hookmanager->executeHooks(
'createFrom',
$parameters, $object, $action);
621 $id = $object->create($user);
626 if (
GETPOST(
'contactid') > 0) {
627 $result = $object->add_contact(
GETPOST(
'contactid'),
'CUSTOMER',
'external');
634 if (!empty($conf->global->PROPOSAL_AUTO_ADD_AUTHOR_AS_CONTACT)) {
635 $result = $object->add_contact($user->id,
'SALESREPFOLL',
'internal');
638 setEventMessages($langs->trans(
"ErrorFailedToAddUserAsContact"),
null,
'errors');
646 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
647 $outputlangs = $langs;
650 $newlang =
GETPOST(
'lang_id',
'aZ09');
653 $newlang = $object->thirdparty->default_lang;
655 if (!empty($newlang)) {
657 $outputlangs->setDefaultLang($newlang);
659 $model = $object->model_pdf;
661 $ret = $object->fetch($id);
662 $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
668 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
681 } elseif ($action ==
'classifybilled' && $usercanclose) {
685 $result = $object->classifyBilled($user, 0,
'');
696 } elseif ($action ==
'confirm_closeas' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
698 if (!(
GETPOST(
'statut',
'int') > 0)) {
699 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CloseAs")),
null,
'errors');
701 } elseif (
GETPOST(
'statut',
'int') == $object::STATUS_SIGNED ||
GETPOST(
'statut',
'int') == $object::STATUS_NOTSIGNED) {
703 if ($object->statut == $object::STATUS_VALIDATED || ( ! empty($conf->global->PROPAL_SKIP_ACCEPT_REFUSE) && $object->statut == $object::STATUS_DRAFT)) {
706 $result = $object->closeProposal($user,
GETPOST(
'statut',
'int'),
GETPOST(
'note_private',
'restricthtml'));
713 $locationTarget =
'';
715 $deposit_percent_from_payment_terms =
getDictionaryValue(
'c_payment_term',
'deposit_percent', $object->cond_reglement_id);
718 !$error &&
GETPOST(
'statut',
'int') == $object::STATUS_SIGNED &&
GETPOST(
'generate_deposit',
'alpha') ==
'on'
719 && !empty($deposit_percent_from_payment_terms) &&
isModEnabled(
'facture') && !empty($user->rights->facture->creer)
721 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
724 $forceFields = array();
727 $forceFields[
'date_pointoftax'] =
dol_mktime(0, 0, 0,
GETPOST(
'date_pointoftaxmonth',
'int'),
GETPOST(
'date_pointoftaxday',
'int'),
GETPOST(
'date_pointoftaxyear',
'int'));
734 $locationTarget = DOL_URL_ROOT .
'/compta/facture/card.php?id=' . $deposit->id;
744 if ($deposit && empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
745 $ret = $deposit->fetch($deposit->id);
746 $outputlangs = $langs;
750 $outputlangs->setDefaultLang($deposit->thirdparty->default_lang);
751 $outputlangs->load(
'products');
754 $result = $deposit->generateDocument($deposit->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
761 if ($locationTarget) {
762 header(
'Location: ' . $locationTarget);
771 } elseif ($action ==
'confirm_reopen' && $usercanclose && !
GETPOST(
'cancel',
'alpha')) {
777 $result = $object->reopen($user, empty($conf->global->PROPAL_SKIP_ACCEPT_REFUSE));
789 } elseif ($action ==
'import_lines_from_object'
790 && $user->rights->propal->creer
794 $fromElement =
GETPOST(
'fromelement');
795 $fromElementid =
GETPOST(
'fromelementid');
796 $importLines =
GETPOST(
'line_checkbox');
798 if (!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid)) {
799 if ($fromElement ==
'commande') {
801 $lineClassName =
'OrderLine';
802 } elseif ($fromElement ==
'propal') {
803 dol_include_once(
'/comm/'.$fromElement.
'/class/'.$fromElement.
'.class.php');
804 $lineClassName =
'PropaleLigne';
806 $nextRang = count($object->lines) + 1;
809 foreach ($importLines as $lineId) {
810 $lineId = intval($lineId);
811 $originLine =
new $lineClassName($db);
812 if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) {
813 $originLine->fetch_optionals();
814 $desc = $originLine->desc;
815 $pu_ht = $originLine->subprice;
816 $qty = $originLine->qty;
817 $txtva = $originLine->tva_tx;
818 $txlocaltax1 = $originLine->localtax1_tx;
819 $txlocaltax2 = $originLine->localtax2_tx;
820 $fk_product = $originLine->fk_product;
821 $remise_percent = $originLine->remise_percent;
822 $date_start = $originLine->date_start;
823 $date_end = $originLine->date_end;
825 $info_bits = $originLine->info_bits;
826 $fk_remise_except = $originLine->fk_remise_except;
827 $price_base_type =
'HT';
829 $type = $originLine->product_type;
831 $special_code = $originLine->special_code;
832 $origin = $originLine->element;
833 $origin_id = $originLine->id;
835 $fk_fournprice = $originLine->fk_fournprice;
836 $pa_ht = $originLine->pa_ht;
837 $label = $originLine->label;
838 $array_options = $originLine->array_options;
839 $situation_percent = 100;
841 $fk_unit = $originLine->fk_unit;
842 $pu_ht_devise = $originLine->multicurrency_subprice;
844 $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);
862 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
865 $actiontypecode =
'AC_OTH_AUTO';
866 $triggersendname =
'PROPAL_SENTBYMAIL';
867 $autocopy =
'MAIN_MAIL_AUTOCOPY_PROPOSAL_TO';
868 $trackid =
'pro'.$object->id;
869 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
873 if ($action ==
'modif' && $usercancreate) {
874 $object->setDraft($user);
876 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
878 $outputlangs = $langs;
881 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') : $object->thirdparty->default_lang);
882 $outputlangs->setDefaultLang($newlang);
884 $ret = $object->fetch($id);
886 $object->fetch_thirdparty();
888 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
890 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
891 if (
GETPOST(
"remise_id",
"int")) {
892 if ($object->id > 0) {
893 $result = $object->insert_discount(
GETPOST(
"remise_id",
"int"));
899 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'vatforalllines',
'alpha') !==
'' && $usercancreate) {
901 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
902 $vat_rate = str_replace(
'*',
'', $vat_rate);
903 $localtax1_rate =
get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
904 $localtax2_rate =
get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
905 foreach ($object->lines as $line) {
906 $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);
908 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'remiseforalllines',
'alpha') !==
'' && $usercancreate) {
910 $remise_percent = (
GETPOST(
'remiseforalllines') ?
GETPOST(
'remiseforalllines') : 0);
911 $remise_percent = str_replace(
'*',
'', $remise_percent);
912 foreach ($object->lines as $line) {
913 $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);
915 } elseif ($action ==
'addline' && $usercancreate) {
921 $price_ht_devise =
'';
923 $price_ttc_devise =
'';
925 if (
GETPOST(
'price_ht') !==
'') {
928 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
931 if (
GETPOST(
'price_ttc') !==
'') {
934 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
938 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'aZ09');
939 if ($prod_entry_mode ==
'free') {
941 $tva_tx = (
GETPOST(
'tva_tx',
'alpha') ?
price2num(preg_replace(
'/\s*\(.*\)/',
'',
GETPOST(
'tva_tx',
'alpha'))) : 0);
943 $idprod =
GETPOST(
'idprod',
'int');
949 if (empty($remise_percent)) {
954 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
955 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
957 if (is_array($extralabelsline)) {
959 foreach ($extralabelsline as $key => $value) {
960 unset($_POST[
"options_".$key]);
964 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
965 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
969 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && $price_ht ===
'' && $price_ht_devise ===
'' && $price_ttc ===
'' && $price_ttc_devise ===
'') {
970 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")),
null,
'errors');
973 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
974 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Description")),
null,
'errors');
978 if (!$error &&
isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
979 if ($combinations =
GETPOST(
'combinations',
'array')) {
983 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
984 $idprod = $res->fk_product_child;
986 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
992 if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) {
997 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
1007 if (!empty($idprod) && $idprod > 0) {
1009 $prod->fetch($idprod);
1011 $label = ((
GETPOST(
'product_label') &&
GETPOST(
'product_label') != $prod->label) ?
GETPOST(
'product_label') :
'');
1016 if (empty($tva_tx)) {
1021 $pu_ht = $prod->price;
1022 $pu_ttc = $prod->price_ttc;
1023 $price_min = $prod->price_min;
1024 $price_min_ttc = $prod->price_min_ttc;
1025 $price_base_type = $prod->price_base_type;
1028 if (!empty($conf->global->PRODUIT_MULTIPRICES) && $object->thirdparty->price_level) {
1029 $pu_ht = $prod->multiprices[$object->thirdparty->price_level];
1030 $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
1031 $price_min = $prod->multiprices_min[$object->thirdparty->price_level];
1032 $price_min_ttc = $prod->multiprices_min_ttc[$object->thirdparty->price_level];
1033 $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
1034 if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) {
1035 if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) {
1036 $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level];
1038 if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) {
1039 $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level];
1042 } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
1044 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
1048 $filter = array(
't.fk_product' => $prod->id,
't.fk_soc' => $object->thirdparty->id);
1050 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1053 if (count($prodcustprice->lines) > 0) {
1054 $pu_ht =
price($prodcustprice->lines[0]->price);
1055 $pu_ttc =
price($prodcustprice->lines[0]->price_ttc);
1056 $price_min =
price($prodcustprice->lines[0]->price_min);
1057 $price_min_ttc =
price($prodcustprice->lines[0]->price_min_ttc);
1058 $price_base_type = $prodcustprice->lines[0]->price_base_type;
1059 $tva_tx = ($prodcustprice->lines[0]->default_vat_code ? $prodcustprice->lines[0]->tva_tx.
' ('.$prodcustprice->lines[0]->default_vat_code.
' )' : $prodcustprice->lines[0]->tva_tx);
1060 if ($prodcustprice->lines[0]->default_vat_code && !preg_match(
'/\(.*\)/', $tva_tx)) {
1061 $tva_tx .=
' ('.$prodcustprice->lines[0]->default_vat_code.
')';
1063 $tva_npr = $prodcustprice->lines[0]->recuperableonly;
1064 if (empty($tva_tx)) {
1069 } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) {
1071 if ($prod->prices_by_qty[0]) {
1076 foreach ($prod->prices_by_qty_list[0] as $priceforthequantityarray) {
1077 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1081 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1082 $pu_ht = $priceforthequantityarray[
'unitprice'];
1084 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1090 } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
1092 if ($prod->prices_by_qty[$object->thirdparty->price_level]) {
1097 foreach ($prod->prices_by_qty_list[$object->thirdparty->price_level] as $priceforthequantityarray) {
1098 if ($priceforthequantityarray[
'rowid'] != $pqp) {
1102 if ($priceforthequantityarray[
'price_base_type'] ==
'HT') {
1103 $pu_ht = $priceforthequantityarray[
'unitprice'];
1105 $pu_ttc = $priceforthequantityarray[
'unitprice'];
1113 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
1114 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $prod->tva_tx));
1117 if (!empty($price_ht) || $price_ht ===
'0') {
1119 $pu_ttc =
price2num($pu_ht * (1 + ($tmpvat / 100)),
'MU');
1120 } elseif (!empty($price_ttc) || $price_ttc ===
'0') {
1122 $pu_ht =
price2num($pu_ttc / (1 + ($tmpvat / 100)),
'MU');
1123 } elseif ($tmpvat != $tmpprodvat) {
1125 if ($price_base_type !=
'HT') {
1126 $pu_ht =
price2num($pu_ttc / (1 + ($tmpvat / 100)),
'MU');
1128 $pu_ttc =
price2num($pu_ht * (1 + ($tmpvat / 100)),
'MU');
1135 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
1136 $outputlangs = $langs;
1138 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
1139 $newlang =
GETPOST(
'lang_id',
'aZ09');
1141 if (empty($newlang)) {
1142 $newlang = $object->thirdparty->default_lang;
1144 if (!empty($newlang)) {
1145 $outputlangs =
new Translate(
"", $conf);
1146 $outputlangs->setDefaultLang($newlang);
1149 $desc = (!empty($prod->multilangs[$outputlangs->defaultlang][
"description"])) ? $prod->multilangs[$outputlangs->defaultlang][
"description"] : $prod->description;
1151 $desc = $prod->description;
1155 if ($product_desc==$desc && !empty($conf->global->PRODUIT_AUTOFILL_DESC)) {
1159 if (!empty($product_desc) && !empty($conf->global->MAIN_NO_CONCAT_DESCRIPTION)) {
1160 $desc = $product_desc;
1162 $desc =
dol_concatdesc($desc, $product_desc,
'', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
1166 if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) {
1169 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
1170 $outputlangs = $langs;
1172 if (empty($newlang) &&
GETPOST(
'lang_id',
'alpha')) {
1173 $newlang =
GETPOST(
'lang_id',
'alpha');
1175 if (empty($newlang)) {
1176 $newlang = $object->thirdparty->default_lang;
1178 if (!empty($newlang)) {
1179 $outputlangs =
new Translate(
"", $conf);
1180 $outputlangs->setDefaultLang($newlang);
1181 $outputlangs->load(
'products');
1183 if (!empty($prod->customcode)) {
1184 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
1186 if (!empty($prod->customcode) && !empty($prod->country_code)) {
1189 if (!empty($prod->country_code)) {
1190 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code, 0, $db, $outputlangs, 0);
1193 if (!empty($prod->customcode)) {
1194 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
1196 if (!empty($prod->customcode) && !empty($prod->country_code)) {
1199 if (!empty($prod->country_code)) {
1200 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code, 0, $db, $langs, 0);
1207 $type = $prod->type;
1208 $fk_unit = $prod->fk_unit;
1212 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1213 if (empty($tva_tx)) {
1216 $tva_tx = str_replace(
'*',
'', $tva_tx);
1217 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1218 $desc = $product_desc;
1220 $fk_unit =
GETPOST(
'units',
'alpha');
1221 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
1222 $pu_ttc_devise =
price2num($price_ttc_devise,
'MU');
1224 if ($pu_ttc && !$pu_ht) {
1225 $price_base_type =
'TTC';
1237 $pu_equivalent = $pu_ht;
1238 $pu_equivalent_ttc = $pu_ttc;
1239 $currency_tx = $object->multicurrency_tx;
1243 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'') {
1244 $pu_equivalent = $pu_ht_devise * $currency_tx;
1246 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'') {
1247 $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx;
1251 $localtax1_tx =
get_localtax($tva_tx, 1, $object->thirdparty, $tva_npr);
1252 $localtax2_tx =
get_localtax($tva_tx, 2, $object->thirdparty, $tva_npr);
1262 if ($usermustrespectpricemin) {
1263 if ($pu_equivalent && $price_min && ((
price2num($pu_equivalent) * (1 - $remise_percent / 100)) <
price2num($price_min))) {
1264 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1267 } elseif ($pu_equivalent_ttc && $price_min_ttc && ((
price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) <
price2num($price_min_ttc))) {
1268 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1276 $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);
1281 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1283 $outputlangs = $langs;
1285 $outputlangs =
new Translate(
"", $conf);
1286 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') : $object->thirdparty->default_lang);
1287 $outputlangs->setDefaultLang($newlang);
1289 $ret = $object->fetch($id);
1291 $object->fetch_thirdparty();
1293 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1296 unset($_POST[
'prod_entry_mode']);
1298 unset($_POST[
'qty']);
1299 unset($_POST[
'type']);
1300 unset($_POST[
'remise_percent']);
1301 unset($_POST[
'price_ht']);
1302 unset($_POST[
'multicurrency_price_ht']);
1303 unset($_POST[
'price_ttc']);
1304 unset($_POST[
'tva_tx']);
1305 unset($_POST[
'product_ref']);
1306 unset($_POST[
'product_label']);
1307 unset($_POST[
'product_desc']);
1308 unset($_POST[
'fournprice']);
1309 unset($_POST[
'buying_price']);
1310 unset($_POST[
'np_marginRate']);
1311 unset($_POST[
'np_markRate']);
1312 unset($_POST[
'dp_desc']);
1313 unset($_POST[
'idprod']);
1314 unset($_POST[
'units']);
1316 unset($_POST[
'date_starthour']);
1317 unset($_POST[
'date_startmin']);
1318 unset($_POST[
'date_startsec']);
1319 unset($_POST[
'date_startday']);
1320 unset($_POST[
'date_startmonth']);
1321 unset($_POST[
'date_startyear']);
1322 unset($_POST[
'date_endhour']);
1323 unset($_POST[
'date_endmin']);
1324 unset($_POST[
'date_endsec']);
1325 unset($_POST[
'date_endday']);
1326 unset($_POST[
'date_endmonth']);
1327 unset($_POST[
'date_endyear']);
1335 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'save')) {
1339 if (preg_match(
'/\*/',
GETPOST(
'tva_tx'))) {
1348 $vat_rate = str_replace(
'*',
'', $vat_rate);
1349 $localtax1_rate =
get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
1350 $localtax2_rate =
get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
1367 $pu_equivalent = $pu_ht;
1368 $pu_equivalent_ttc = $pu_ttc;
1369 $currency_tx = $object->multicurrency_tx;
1373 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'') {
1374 $pu_equivalent = $pu_ht_devise * $currency_tx;
1376 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'') {
1377 $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx;
1381 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
1382 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
1384 if (is_array($extralabelsline)) {
1386 foreach ($extralabelsline as $key => $value) {
1387 unset($_POST[
"options_".$key]);
1392 $special_code =
GETPOST(
'special_code',
'int');
1398 $productid =
GETPOST(
'productid',
'int');
1399 if (!empty($productid)) {
1401 $res = $product->fetch($productid);
1403 $type = $product->type;
1406 $price_min = $product->price_min;
1407 if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) {
1408 $price_min = $product->multiprices_min[$object->thirdparty->price_level];
1410 $price_min_ttc = $product->price_min_ttc;
1411 if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) {
1412 $price_min_ttc = $product->multiprices_min_ttc[$object->thirdparty->price_level];
1418 if ($usermustrespectpricemin) {
1419 if ($pu_equivalent && $price_min && ((
price2num($pu_equivalent) * (1 - $remise_percent / 100)) <
price2num($price_min))) {
1420 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1423 $action =
'editline';
1424 } elseif ($pu_equivalent_ttc && $price_min_ttc && ((
price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) <
price2num($price_min_ttc))) {
1425 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
1428 $action =
'editline';
1433 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1437 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1445 if (empty($user->rights->margins->creer)) {
1446 foreach ($object->lines as &$line) {
1447 if ($line->id ==
GETPOST(
'lineid',
'int')) {
1448 $fournprice = $line->fk_fournprice;
1449 $buyingprice = $line->pa_ht;
1458 $price_base_type =
'HT';
1459 if (empty($pu) && !empty($pu_ttc)) {
1461 $price_base_type =
'TTC';
1464 $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);
1469 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1471 $outputlangs = $langs;
1473 $outputlangs =
new Translate(
"", $conf);
1474 $newlang = (
GETPOST(
'lang_id',
'aZ09') ?
GETPOST(
'lang_id',
'aZ09') : $object->thirdparty->default_lang);
1475 $outputlangs->setDefaultLang($newlang);
1477 $ret = $object->fetch($id);
1479 $object->fetch_thirdparty();
1481 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1484 unset($_POST[
'qty']);
1485 unset($_POST[
'type']);
1486 unset($_POST[
'productid']);
1487 unset($_POST[
'remise_percent']);
1488 unset($_POST[
'price_ht']);
1489 unset($_POST[
'multicurrency_price_ht']);
1490 unset($_POST[
'price_ttc']);
1491 unset($_POST[
'tva_tx']);
1492 unset($_POST[
'product_ref']);
1493 unset($_POST[
'product_label']);
1494 unset($_POST[
'product_desc']);
1495 unset($_POST[
'fournprice']);
1496 unset($_POST[
'buying_price']);
1498 unset($_POST[
'date_starthour']);
1499 unset($_POST[
'date_startmin']);
1500 unset($_POST[
'date_startsec']);
1501 unset($_POST[
'date_startday']);
1502 unset($_POST[
'date_startmonth']);
1503 unset($_POST[
'date_startyear']);
1504 unset($_POST[
'date_endhour']);
1505 unset($_POST[
'date_endmin']);
1506 unset($_POST[
'date_endsec']);
1507 unset($_POST[
'date_endday']);
1508 unset($_POST[
'date_endmonth']);
1509 unset($_POST[
'date_endyear']);
1516 } elseif ($action ==
'updateline' && $usercancreate &&
GETPOST(
'cancel',
'alpha')) {
1517 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
1519 } elseif ($action ==
'classin' && $usercancreate) {
1521 $object->setProject(
GETPOST(
'projectid',
'int'));
1522 } elseif ($action ==
'setavailability' && $usercancreate) {
1524 $result = $object->set_availability($user,
GETPOST(
'availability_id',
'int'));
1525 } elseif ($action ==
'setdemandreason' && $usercancreate) {
1527 $result = $object->set_demand_reason($user,
GETPOST(
'demand_reason_id',
'int'));
1528 } elseif ($action ==
'setconditions' && $usercancreate) {
1530 $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_id',
'int'),
GETPOST(
'cond_reglement_id_deposit_percent',
'alpha'));
1531 } elseif ($action ==
'setremisepercent' && $usercancreate) {
1532 $result = $object->set_remise_percent($user,
price2num(
GETPOST(
'remise_percent'),
'', 2));
1533 } elseif ($action ==
'setremiseabsolue' && $usercancreate) {
1534 $result = $object->set_remise_absolue($user,
price2num(
GETPOST(
'remise_absolue'),
'MU', 2));
1535 } elseif ($action ==
'setmode' && $usercancreate) {
1537 $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_id',
'int'));
1538 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
1540 $result = $object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
1541 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
1543 $result = $object->setMulticurrencyRate(
price2num(
GETPOST(
'multicurrency_tx')),
GETPOST(
'calculation_mode',
'int'));
1544 } elseif ($action ==
'setbankaccount' && $usercancreate) {
1546 $result = $object->setBankAccount(
GETPOST(
'fk_account',
'int'));
1547 } elseif ($action ==
'setshippingmethod' && $usercancreate) {
1549 $result = $object->setShippingMethod(
GETPOST(
'shipping_method_id',
'int'));
1550 } elseif ($action ==
'setwarehouse' && $usercancreate) {
1552 $result = $object->setWarehouse(
GETPOST(
'warehouse_id',
'int'));
1553 } elseif ($action ==
'update_extras') {
1557 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
1562 $result = $object->updateExtraField(
GETPOST(
'attribute',
'restricthtml'),
'PROPAL_MODIFY', $user);
1569 $action =
'edit_extras';
1573 if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) {
1574 if ($action ==
'addcontact') {
1575 if ($object->id > 0) {
1578 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
1582 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
1585 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1586 $langs->load(
"errors");
1587 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
1592 } elseif ($action ==
'swapstatut') {
1594 if ($object->fetch($id) > 0) {
1595 $result = $object->swapContactStatus(
GETPOST(
'ligne',
'int'));
1599 } elseif ($action ==
'deletecontact') {
1601 $object->fetch($id);
1602 $result = $object->delete_contact($lineid);
1605 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
1614 $upload_dir = !empty($conf->propal->multidir_output[$object->entity])?$conf->propal->multidir_output[$object->entity]:$conf->propal->dir_output;
1615 $permissiontoadd = $usercancreate;
1616 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1632 $title = $object->ref.
" - ".$langs->trans(
'Card');
1633 if ($action ==
'create') {
1634 $title = $langs->trans(
"NewPropal");
1636 $help_url =
'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos|DE:Modul_Angebote';
1643 if ($action ==
'create') {
1644 $currency_code = $conf->currency;
1650 $res = $soc->fetch($socid);
1654 if (!empty($origin) && !empty($originid)) {
1656 $element = $subelement = $origin;
1658 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
1659 $element = $regs[1];
1660 $subelement = $regs[2];
1663 if ($element ==
'project') {
1664 $projectid = $originid;
1667 if ($element ==
'order' || $element ==
'commande') {
1668 $element = $subelement =
'commande';
1670 if ($element ==
'propal') {
1671 $element =
'comm/propal';
1672 $subelement =
'propal';
1674 if ($element ==
'contract') {
1675 $element = $subelement =
'contrat';
1677 if ($element ==
'shipping') {
1678 $element = $subelement =
'expedition';
1683 $classname = ucfirst($subelement);
1684 $objectsrc =
new $classname($db);
1685 $objectsrc->fetch($originid);
1686 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1687 $objectsrc->fetch_lines();
1689 $objectsrc->fetch_thirdparty();
1691 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : 0);
1692 $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client :
'');
1694 $soc = $objectsrc->thirdparty;
1696 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_id) ? $soc->cond_reglement_id : 0));
1697 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_id) ? $soc->mode_reglement_id : 0));
1698 $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0));
1699 $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0));
1700 $warehouse_id = (!empty($objectsrc->warehouse_id) ? $objectsrc->warehouse_id : (!empty($soc->warehouse_id) ? $soc->warehouse_id : 0));
1701 $dateinvoice = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 :
'') : $dateinvoice);
1704 $objectsrc->fetch_optionals();
1705 $object->array_options = $objectsrc->array_options;
1708 if (!empty($objectsrc->multicurrency_code)) {
1709 $currency_code = $objectsrc->multicurrency_code;
1711 if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) {
1712 $currency_tx = $objectsrc->multicurrency_tx;
1717 if (
isModEnabled(
"multicurrency") && !empty($soc->multicurrency_code)) {
1718 $currency_code = $soc->multicurrency_code;
1723 if ($soc->fk_warehouse > 0) {
1724 $warehouse_id = $soc->fk_warehouse;
1726 if (
isModEnabled(
'stock') && empty($warehouse_id) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) {
1727 if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) {
1728 $warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE;
1730 if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) {
1731 $warehouse_id = $user->fk_warehouse;
1735 print
'<form name="addprop" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1736 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1737 print
'<input type="hidden" name="action" value="add">';
1738 if ($origin !=
'project' && $originid) {
1739 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1740 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1741 } elseif ($origin ==
'project' && !empty($projectid)) {
1742 print
'<input type="hidden" name="projectid" value="'.$projectid.
'">';
1747 print
'<table class="border centpercent">';
1750 print
'<tr class="field_ref"><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td class="valuefieldcreate">'.$langs->trans(
"Draft").
'</td></tr>';
1753 print
'<tr class="field_ref_client"><td class="titlefieldcreate">'.$langs->trans(
'RefCustomer').
'</td><td class="valuefieldcreate">';
1754 print
'<input type="text" name="ref_client" value="'.(!empty($ref_client)?$ref_client:
GETPOST(
'ref_client')).
'"></td>';
1758 print
'<tr class="field_socid">';
1759 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Customer').
'</td>';
1760 $shipping_method_id = 0;
1762 print
'<td class="valuefieldcreate">';
1763 print $soc->getNomUrl(1,
'customer');
1764 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1766 if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && !empty($soc->shipping_method_id)) {
1767 $shipping_method_id = $soc->shipping_method_id;
1771 print
'<td class="valuefieldcreate">';
1772 print
img_picto(
'',
'company').$form->select_company(
'',
'socid',
'((s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1)',
'SelectThirdParty', 1, 0,
null, 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
1774 if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) {
1775 print
'<script type="text/javascript">
1776 $(document).ready(function() {
1777 $("#socid").change(function() {
1778 console.log("We have changed the company - Reload page");
1779 var socid = $(this).val();
1781 $("input[name=action]").val("create");
1782 $("form[name=addprop]").submit();
1787 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>';
1794 print
'<tr class="field_contactid"><td class="titlefieldcreate">'.$langs->trans(
"DefaultContact").
'</td><td class="valuefieldcreate">';
1796 print
$form->selectcontacts($soc->id, $contactid,
'contactid', 1,
'',
'', 0,
'minwidth300');
1800 print
'<tr class="field_discount_info"><td class="titlefieldcreate">'.$langs->trans(
'Discounts').
'</td><td class="valuefieldcreate">';
1802 $absolute_discount = $soc->getAvailableDiscounts();
1806 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$thirdparty->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
1807 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
1812 print
'<tr class="field_addprop"><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'DatePropal').
'</td><td class="valuefieldcreate">';
1813 print
$form->selectDate(
'',
'',
'',
'',
'',
"addprop", 1, 1);
1817 print
'<tr class="field_duree_validitee"><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"ValidityDuration").
'</td><td class="valuefieldcreate">'.
img_picto(
'',
'clock',
'class="paddingright"').
'<input name="duree_validite" class="width50" value="'.(
GETPOSTISSET(
'duree_validite') ?
GETPOST(
'duree_validite',
'alphanohtml') : $conf->global->PROPALE_VALIDITY_DURATION).
'"> '.$langs->trans(
"days").
'</td></tr>';
1820 print
'<tr class="field_cond_reglement_id"><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
1822 print
$form->getSelectConditionsPaiements((
GETPOSTISSET(
'cond_reglement_id') &&
GETPOST(
'cond_reglement_id',
'int') != 0) ?
GETPOST(
'cond_reglement_id',
'int') : $soc->cond_reglement_id,
'cond_reglement_id', 1, 1, 0,
'', (
GETPOSTISSET(
'cond_reglement_id_deposit_percent') ?
GETPOST(
'cond_reglement_id_deposit_percent',
'alpha') : $soc->deposit_percent));
1826 print
'<tr class="field_mode_reglement_id"><td class="titlefieldcreate">'.$langs->trans(
'PaymentMode').
'</td><td class="valuefieldcreate">';
1827 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
1828 print
$form->select_types_paiements((
GETPOSTISSET(
'mode_reglement_id') &&
GETPOST(
'mode_reglement_id',
'int') != 0) ?
GETPOST(
'mode_reglement_id',
'int') : $soc->mode_reglement_id,
'mode_reglement_id',
'CRDT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx', 1);
1832 if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) &&
isModEnabled(
"banque")) {
1833 print
'<tr class="field_fk_account"><td class="titlefieldcreate">'.$langs->trans(
'BankAccount').
'</td><td class="valuefieldcreate">';
1834 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes($soc->fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
1839 print
'<tr class="field_demand_reason_id"><td class="titlefieldcreate">'.$langs->trans(
'Source').
'</td><td class="valuefieldcreate">';
1840 print
img_picto(
'',
'question',
'class="pictofixedwidth"');
1841 $form->selectInputReason(
'',
'demand_reason_id',
"SRC_PROP", 1,
'maxwidth200 widthcentpercentminusx');
1845 print
'<tr class="field_availability_id"><td class="titlefieldcreate">'.$langs->trans(
'AvailabilityPeriod');
1847 print
' ('.$langs->trans(
'AfterOrder').
')';
1849 print
'</td><td class="valuefieldcreate">';
1850 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
1851 $form->selectAvailabilityDelay(
'',
'availability_id',
'', 1,
'maxwidth200 widthcentpercentminusx');
1856 if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && !empty($soc->shipping_method_id)) {
1857 $shipping_method_id = $soc->shipping_method_id;
1859 print
'<tr class="field_shipping_method_id"><td class="titlefieldcreate">'.$langs->trans(
'SendingMethod').
'</td><td class="valuefieldcreate">';
1860 print
img_picto(
'',
'object_dollyrevert',
'class="pictofixedwidth"');
1861 $form->selectShippingMethod($shipping_method_id,
'shipping_method_id',
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx');
1866 if (
isModEnabled(
'stock') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL)) {
1867 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
1869 print
'<tr class="field_warehouse_id"><td class="titlefieldcreate">'.$langs->trans(
'Warehouse').
'</td><td class="valuefieldcreate">';
1870 print
img_picto(
'',
'stock',
'class="pictofixedwidth"').$formproduct->selectWarehouses($warehouse_id,
'warehouse_id',
'', 1, 0, 0,
'', 0, 0, array(),
'maxwidth500 widthcentpercentminusxx');
1875 print
'<tr class="field_date_livraison"><td class="titlefieldcreate">'.$langs->trans(
"DeliveryDate").
'</td>';
1876 print
'<td class="valuefieldcreate">';
1877 if (isset($conf->global->DATE_LIVRAISON_WEEK_DELAY) && is_numeric($conf->global->DATE_LIVRAISON_WEEK_DELAY)) {
1878 $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60);
1879 $syear = date(
"Y", $tmpdte);
1880 $smonth = date(
"m", $tmpdte);
1881 $sday = date(
"d", $tmpdte);
1882 print
$form->selectDate($syear.
"-".$smonth.
"-".$sday,
'date_livraison',
'',
'',
'',
"addprop");
1884 print
$form->selectDate(-1,
'date_livraison',
'',
'',
'',
"addprop", 1, 1);
1890 $langs->load(
"projects");
1891 print
'<tr class="field_projectid">';
1892 print
'<td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td class="valuefieldcreate">';
1893 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');
1894 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>';
1901 print
'<tr class="field_incoterm_id">';
1902 print
'<td class="titlefieldcreate"><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), $soc->label_incoterms, 1).
'</label></td>';
1903 print
'<td class="valuefieldcreate maxwidthonsmartphone">';
1904 print
$form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms :
''), (!empty($soc->location_incoterms) ? $soc->location_incoterms :
''));
1909 print
'<tr class="field_model">';
1910 print
'<td class="titlefieldcreate">'.$langs->trans(
"DefaultModel").
'</td>';
1911 print
'<td class="valuefieldcreate">';
1912 print
img_picto(
'',
'pdf',
'class="pictofixedwidth"');
1914 $preselected = (!empty($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT) ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT :
getDolGlobalString(
"PROPALE_ADDON_PDF"));
1915 print
$form->selectarray(
'model', $liste, $preselected, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth200 widthcentpercentminusx', 1);
1920 print
'<tr class="field_currency">';
1921 print
'<td class="titlefieldcreate">'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
1922 print
'<td class="valuefieldcreate maxwidthonsmartphone">';
1923 print
img_picto(
'',
'currency',
'class="pictofixedwidth"').$form->selectMultiCurrency($currency_code,
'multicurrency_code', 0);
1928 print
'<tr class="field_note_public">';
1929 print
'<td class="titlefieldcreate tdtop">'.$langs->trans(
'NotePublic').
'</td>';
1930 print
'<td class="valuefieldcreate">';
1931 $note_public = $object->getDefaultCreateValueFor(
'note_public', (!empty($objectsrc) ? $objectsrc->note_public :
null));
1932 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In', 0,
false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3,
'90%');
1933 print $doleditor->Create(1);
1936 if (empty($user->socid)) {
1937 print
'<tr class="field_note_private">';
1938 print
'<td class="titlefieldcreate tdtop">'.$langs->trans(
'NotePrivate').
'</td>';
1939 print
'<td class="valuefieldcreate">';
1940 $note_private = $object->getDefaultCreateValueFor(
'note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc)) ? $objectsrc->note_private :
null));
1941 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In', 0,
false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3,
'90%');
1942 print $doleditor->Create(1);
1948 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1951 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1953 if ($origin ==
'contrat') {
1955 $objectsrc->remise_absolue = $remise_absolue;
1956 $objectsrc->remise_percent = $remise_percent;
1957 $objectsrc->update_price(1,
'auto', 1);
1960 print
"\n<!-- ".$classname.
" info -->";
1962 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
1963 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
1964 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
1965 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
1966 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
1968 $newclassname = $classname;
1969 if ($newclassname ==
'Propal') {
1970 $newclassname =
'CommercialProposal';
1971 } elseif ($newclassname ==
'Commande') {
1972 $newclassname =
'Order';
1973 } elseif ($newclassname ==
'Expedition') {
1974 $newclassname =
'Sending';
1975 } elseif ($newclassname ==
'Fichinter') {
1976 $newclassname =
'Intervention';
1979 print
'<tr><td>'.$langs->trans($newclassname).
'</td><td>'.$objectsrc->getNomUrl(1).
'</td></tr>';
1980 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht, 0, $langs, 1, -1, -1, $conf->currency).
'</td></tr>';
1981 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva, 0, $langs, 1, -1, -1, $conf->currency).
"</td></tr>";
1982 if ($mysoc->localtax1_assuj ==
"1" || $objectsrc->total_localtax1 != 0) {
1983 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1, 0, $langs, 1, -1, -1, $conf->currency).
"</td></tr>";
1986 if ($mysoc->localtax2_assuj ==
"1" || $objectsrc->total_localtax2 != 0) {
1987 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2, 0, $langs, 1, -1, -1, $conf->currency).
"</td></tr>";
1989 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc, 0, $langs, 1, -1, -1, $conf->currency).
"</td></tr>";
1992 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
1993 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
1994 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2005 if (empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) {
2006 print
'<input type="hidden" name="createmode" value="empty">';
2009 if (!empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) {
2010 print
'<br><table>';
2014 print
'<td><input type="radio" name="createmode" value="copy"></td>';
2015 print
'<td>'.$langs->trans(
"CopyPropalFrom").
' </td>';
2017 $liste_propal = array();
2018 $liste_propal [0] =
'';
2020 $sql =
"SELECT p.rowid as id, p.ref, s.nom";
2021 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal p";
2022 $sql .=
", ".MAIN_DB_PREFIX.
"societe s";
2023 $sql .=
" WHERE s.rowid = p.fk_soc";
2024 $sql .=
" AND p.entity IN (".getEntity(
'propal').
")";
2025 $sql .=
" AND p.fk_statut <> 0";
2026 $sql .=
" ORDER BY Id";
2028 $resql = $db->query($sql);
2030 $num = $db->num_rows(
$resql);
2033 $row = $db->fetch_row(
$resql);
2034 $propalRefAndSocName = $row[1].
" - ".$row[2];
2035 $liste_propal[$row[0]] = $propalRefAndSocName;
2038 print
$form->selectarray(
"copie_propal", $liste_propal, 0);
2044 print
'<tr><td class="tdtop"><input type="radio" name="createmode" value="empty" checked></td>';
2045 print
'<td valign="top" colspan="2">'.$langs->trans(
"CreateEmptyPropal").
'</td></tr>';
2051 $langs->load(
"bills");
2053 print
$form->buttonsSaveCancel(
"CreateDraft");
2059 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
2062 $title = $langs->trans(
'ProductsAndServices');
2065 print
'<div class="div-table-responsive-no-min">';
2066 print
'<table class="noborder centpercent">';
2068 $objectsrc->printOriginLinesList();
2073 } elseif ($object->id > 0) {
2079 $soc->fetch($object->socid);
2087 if ($action ==
'clone') {
2089 $formquestion = array(
2092 array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' =>
$form->select_company(
GETPOST(
'socid',
'int'),
'socid',
'(s.client=1 OR s.client=2 OR s.client=3)',
'', 0, 0,
null, 0,
'maxwidth300')),
2093 array(
'type' =>
'checkbox',
'name' =>
'update_prices',
'label' => $langs->trans(
'PuttingPricesUpToDate'),
'value' => (!empty($conf->global->PROPOSAL_CLONE_UPDATE_PRICES) ? 1 : 0)),
2095 if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY) && !empty($object->delivery_date)) {
2096 $formquestion[] = array(
'type' =>
'date',
'name' =>
'date_delivery',
'label' => $langs->trans(
"DeliveryDate"),
'value' => $object->delivery_date);
2099 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmClonePropal', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
2102 if ($action ==
'closeas') {
2104 $formquestion = array();
2105 if (empty($conf->global->PROPAL_SKIP_ACCEPT_REFUSE)) {
2106 $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)));
2108 $formquestion[] = array(
'type' =>
'text',
'name' =>
'note_private',
'label' => $langs->trans(
"Note"),
'value' =>
'');
2110 if (
getDolGlobalInt(
'PROPOSAL_SUGGEST_DOWN_PAYMENT_INVOICE_CREATION')) {
2115 $deposit_percent_from_payment_terms =
getDictionaryValue(
'c_payment_term',
'deposit_percent', $object->cond_reglement_id);
2117 if (!empty($deposit_percent_from_payment_terms) &&
isModEnabled(
'facture') && !empty($user->rights->facture->creer)) {
2118 require_once DOL_DOCUMENT_ROOT .
'/compta/facture/class/facture.class.php';
2120 $object->fetchObjectLinked();
2122 $eligibleForDepositGeneration =
true;
2124 if (array_key_exists(
'facture', $object->linkedObjects)) {
2125 foreach ($object->linkedObjects[
'facture'] as $invoice) {
2127 $eligibleForDepositGeneration =
false;
2133 if ($eligibleForDepositGeneration && array_key_exists(
'commande', $object->linkedObjects)) {
2134 foreach ($object->linkedObjects[
'commande'] as $order) {
2135 $order->fetchObjectLinked();
2137 if (array_key_exists(
'facture', $order->linkedObjects)) {
2138 foreach ($order->linkedObjects[
'facture'] as $invoice) {
2140 $eligibleForDepositGeneration =
false;
2149 if ($eligibleForDepositGeneration) {
2150 $formquestion[] = array(
2151 'type' =>
'checkbox',
2152 'tdclass' =>
'showonlyifsigned',
2153 'name' =>
'generate_deposit',
2154 'morecss' =>
'margintoponly marginbottomonly',
2155 'label' =>
$form->textwithpicto($langs->trans(
'GenerateDeposit', $object->deposit_percent), $langs->trans(
'DepositGenerationPermittedByThePaymentTermsSelected'))
2158 $formquestion[] = array(
2160 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2162 'label' => $langs->trans(
'DateInvoice'),
2167 if (!empty($conf->global->INVOICE_POINTOFTAX_DATE)) {
2168 $formquestion[] = array(
2170 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2171 'name' =>
'date_pointoftax',
2172 'label' => $langs->trans(
'DatePointOfTax'),
2178 $paymentTermsSelect =
$form->getSelectConditionsPaiements(0,
'cond_reglement_id', -1, 0, 1,
'minwidth200');
2180 $formquestion[] = array(
2182 'tdclass' =>
'fieldrequired showonlyifgeneratedeposit',
2183 'name' =>
'cond_reglement_id',
2184 'label' => $langs->trans(
'PaymentTerm'),
2185 'value' => $paymentTermsSelect
2188 $formquestion[] = array(
2189 'type' =>
'checkbox',
2190 'tdclass' =>
'showonlyifgeneratedeposit',
2191 'name' =>
'validate_generated_deposit',
2192 'morecss' =>
'margintoponly marginbottomonly',
2193 'label' => $langs->trans(
'ValidateGeneratedDeposit')
2196 $formquestion[] = array(
2197 'type' =>
'onecolumn',
2200 let signedValue = ' . $object::STATUS_SIGNED .
';
2202 $(document).ready(function() {
2203 $("[name=generate_deposit]").change(function () {
2204 let $self = $(this);
2205 let $target = $(".showonlyifgeneratedeposit").parent(".tagtr");
2207 if (! $self.parents(".tagtr").is(":hidden") && $self.is(":checked")) {
2216 $("#statut").change(function() {
2217 let $target = $(".showonlyifsigned").parent(".tagtr");
2219 if ($(this).val() == signedValue) {
2225 $("[name=generate_deposit]").trigger("change");
2230 $("#statut").trigger("change");
2240 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
2241 $notify =
new Notify($db);
2242 $formquestion = array_merge($formquestion, array(
2243 array(
'type' =>
'onecolumn',
'value' => $notify->confirmMessage(
'PROPAL_CLOSE_SIGNED', $object->socid, $object)),
2247 if (empty($conf->global->PROPAL_SKIP_ACCEPT_REFUSE)) {
2248 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'SetAcceptedRefused'), $text,
'confirm_closeas', $formquestion,
'', 1, 250);
2250 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"] .
'?statut=3&id=' . $object->id, $langs->trans(
'Close'), $text,
'confirm_closeas', $formquestion,
'', 1, 250);
2252 } elseif ($action ==
'delete') {
2254 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteProp'), $langs->trans(
'ConfirmDeleteProp', $object->ref),
'confirm_delete',
'', 0, 1);
2255 } elseif ($action ==
'reopen') {
2257 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ReOpen'), $langs->trans(
'ConfirmReOpenProp', $object->ref),
'confirm_reopen',
'', 0, 1);
2258 } elseif ($action ==
'ask_deleteline') {
2260 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
2261 } elseif ($action ==
'validate') {
2266 $ref = substr($object->ref, 1, 4);
2267 if ($ref ==
'PROV' || $ref ==
'') {
2268 $numref = $object->getNextNumRef($soc);
2269 if (empty($numref)) {
2274 $numref = $object->ref;
2277 $text = $langs->trans(
'ConfirmValidateProp', $numref);
2279 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
2280 $notify =
new Notify($db);
2282 $text .= $notify->confirmMessage(
'PROPAL_VALIDATE', $object->socid, $object);
2287 foreach ($object->lines as $line) {
2288 $res = $line->fetch_product();
2290 if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end) )) {
2296 if ($nbMandated > 0) {
2297 $text .=
'<div><span class="clearboth nowraponall warning">'.$langs->trans(
"mandatoryPeriodNeedTobeSetMsgValidate").
'</span></div>';
2301 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ValidateProp'), $text,
'confirm_validate',
'', 0, 1);
2307 $reshook = $hookmanager->executeHooks(
'formConfirm',
$parameters, $object, $action);
2308 if (empty($reshook)) {
2310 } elseif ($reshook > 0) {
2320 $linkback =
'<a href="'.DOL_URL_ROOT.
'/comm/propal/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
2322 $morehtmlref =
'<div class="refidno">';
2324 $morehtmlref .=
$form->editfieldkey(
"RefCustomer",
'ref_client', $object->ref_client, $object, $usercancreate,
'string',
'', 0, 1);
2325 $morehtmlref .=
$form->editfieldval(
"RefCustomer",
'ref_client', $object->ref_client, $object, $usercancreate,
'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ?
':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE :
''),
'',
null,
null,
'', 1);
2327 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1,
'customer');
2328 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
2329 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/comm/propal/list.php?socid='.$object->thirdparty->id.
'&search_societe='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherProposals").
'</a>)';
2333 $langs->load(
"projects");
2334 $morehtmlref .=
'<br>';
2335 if ($usercancreate) {
2336 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2337 if ($action !=
'classify') {
2338 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2340 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, ($action ==
'classify' ? 1 : 0), 0, 1,
'');
2342 if (!empty($object->fk_project)) {
2344 $proj->fetch($object->fk_project);
2345 $morehtmlref .= $proj->getNomUrl(1);
2347 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2352 $morehtmlref .=
'</div>';
2355 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2358 print
'<div class="fichecenter">';
2359 print
'<div class="fichehalfleft">';
2360 print
'<div class="underbanner clearboth"></div>';
2362 print
'<table class="border tableforfield centpercent">';
2365 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
2366 $filterabsolutediscount =
"fk_facture_source IS NULL";
2367 $filtercreditnote =
"fk_facture_source IS NOT NULL";
2369 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
2370 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
2373 print
'<tr><td class="titlefield">'.$langs->trans(
'Discounts').
'</td><td>';
2375 $absolute_discount = $soc->getAvailableDiscounts(
'', $filterabsolutediscount);
2376 $absolute_creditnote = $soc->getAvailableDiscounts(
'', $filtercreditnote);
2377 $absolute_discount =
price2num($absolute_discount,
'MT');
2378 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
2384 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?id='.$object->id);
2385 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2401 print
$form->editfieldkey(
"DatePropal",
'date',
'', $object, $editenable);
2402 print
'</td><td class="valuefield">';
2403 if ($action ==
'editdate' && $usercancreate && $caneditfield) {
2404 print
'<form name="editdate" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
2405 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2406 print
'<input type="hidden" name="action" value="setdate">';
2407 print
$form->selectDate($object->date,
're',
'',
'', 0,
"editdate");
2408 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2411 if ($object->date) {
2422 print
'<table class="nobordernopadding centpercent"><tr><td>';
2423 print $langs->trans(
'DateEndPropal');
2425 if ($action !=
'editecheance' && $usercancreate && $caneditfield) {
2426 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>';
2428 print
'</tr></table>';
2429 print
'</td><td class="valuefield">';
2430 if ($action ==
'editecheance' && $usercancreate && $caneditfield) {
2431 print
'<form name="editecheance" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="post">';
2432 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2433 print
'<input type="hidden" name="action" value="setecheance">';
2434 print
$form->selectDate($object->fin_validite,
'ech',
'',
'',
'',
"editecheance");
2435 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
'Modify').
'">';
2438 if (!empty($object->fin_validite)) {
2440 if ($object->statut ==
Propal::STATUS_VALIDATED && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) {
2452 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2453 print $langs->trans(
'PaymentConditionsShort');
2455 if ($action !=
'editconditions' && $usercancreate && $caneditfield) {
2456 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>';
2458 print
'</tr></table>';
2459 print
'</td><td class="valuefield">';
2460 if ($action ==
'editconditions' && $usercancreate && $caneditfield) {
2461 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'cond_reglement_id', 0,
'', 1, $object->deposit_percent);
2463 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'none', 0,
'', 1, $object->deposit_percent);
2469 print
'<tr class="field_mode_reglement_id">';
2470 print
'<td class="titlefieldcreate">';
2471 print
'<table class="nobordernopadding centpercent"><tr><td>';
2472 print $langs->trans(
'PaymentMode');
2474 if ($action !=
'editmode' && $usercancreate && $caneditfield) {
2475 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>';
2477 print
'</tr></table>';
2478 print
'</td><td class="valuefieldcreate">';
2479 if ($action ==
'editmode' && $usercancreate && $caneditfield) {
2480 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
2482 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'none');
2487 $langs->load(
'deliveries');
2489 print
$form->editfieldkey($langs->trans(
'DeliveryDate'),
'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield,
'datepicker');
2490 print
'</td><td class="valuefieldedit">';
2491 print
$form->editfieldval($langs->trans(
'DeliveryDate'),
'date_livraison', $object->delivery_date, $object, $usercancreate && $caneditfield,
'datepicker');
2496 print
'<tr class="fielddeliverydelay"><td>';
2497 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2499 print
$form->textwithpicto($langs->trans(
'AvailabilityPeriod'), $langs->trans(
'AvailabilityPeriod').
' ('.$langs->trans(
'AfterOrder').
')');
2501 print $langs->trans(
'AvailabilityPeriod');
2504 if ($action !=
'editavailability' && $usercancreate && $caneditfield) {
2505 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>';
2507 print
'</tr></table>';
2508 print
'</td><td class="valuefield">';
2509 if ($action ==
'editavailability' && $usercancreate && $caneditfield) {
2510 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->availability_id,
'availability_id', 1);
2512 $form->form_availability($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->availability_id,
'none', 1);
2521 print
'<table class="nobordernopadding centpercent"><tr><td>';
2522 print $langs->trans(
'SendingMethod');
2524 if ($action !=
'editshippingmethod' && $usercancreate && $caneditfield) {
2525 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>';
2527 print
'</tr></table>';
2528 print
'</td><td class="valuefield">';
2529 if ($action ==
'editshippingmethod' && $usercancreate && $caneditfield) {
2530 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->shipping_method_id,
'shipping_method_id', 1);
2532 $form->formSelectShippingMethod($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->shipping_method_id,
'none');
2539 if (
isModEnabled(
'stock') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROPAL)) {
2540 $langs->load(
'stocks');
2541 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2543 print
'<tr class="field_warehouse_id"><td class="titlefieldcreate">';
2544 $editenable = $usercancreate;
2545 print
$form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, $editenable);
2546 print
'</td><td class="valuefieldcreate">';
2547 if ($action ==
'editwarehouse') {
2548 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->warehouse_id,
'warehouse_id', 1);
2550 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->warehouse_id,
'none');
2558 print
'<table class="nobordernopadding centpercent"><tr><td>';
2559 print $langs->trans(
'Source');
2561 if ($action !=
'editdemandreason' && $usercancreate) {
2562 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>';
2564 print
'</tr></table>';
2565 print
'</td><td class="valuefield">';
2566 if ($action ==
'editdemandreason' && $usercancreate) {
2567 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->demand_reason_id,
'demand_reason_id', 1);
2569 $form->formInputReason($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->demand_reason_id,
'none');
2579 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2580 print
$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0);
2582 if ($action !=
'editmulticurrencycode' && $object->statut == $object::STATUS_DRAFT && $usercancreate) {
2583 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>';
2585 print
'</tr></table>';
2586 print
'</td><td class="valuefield">';
2587 if ($object->statut == $object::STATUS_DRAFT && $action ==
'editmulticurrencycode' && $usercancreate) {
2588 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_code,
'multicurrency_code');
2590 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_code,
'none');
2595 if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) {
2598 print
'<table class="nobordernopadding" width="100%"><tr>';
2600 print
$form->editfieldkey(
'CurrencyRate',
'multicurrency_tx',
'', $object, 0);
2602 if ($action !=
'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $usercancreate) {
2603 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>';
2605 print
'</tr></table>';
2606 print
'</td><td class="valuefield">';
2607 if ($object->statut == $object::STATUS_DRAFT && ($action ==
'editmulticurrencyrate' || $action ==
'actualizemulticurrencyrate') && $usercancreate) {
2608 if ($action ==
'actualizemulticurrencyrate') {
2611 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx,
'multicurrency_tx', $object->multicurrency_code);
2613 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx,
'none', $object->multicurrency_code);
2614 if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
2615 print
'<div class="inline-block"> ';
2616 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=actualizemulticurrencyrate">'.$langs->trans(
"ActualizeCurrency").
'</a>';
2624 if ($soc->outstanding_limit) {
2627 print $langs->trans(
'OutstandingBill');
2628 print
'</td><td class="valuefield">';
2629 $arrayoutstandingbills = $soc->getOutstandingBills();
2630 print ($arrayoutstandingbills[
'opened'] > $soc->outstanding_limit ?
img_warning() :
'');
2631 print
price($arrayoutstandingbills[
'opened']).
' / ';
2632 print
price($soc->outstanding_limit, 0, $langs, 1, - 1, - 1, $conf->currency);
2637 if (!empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) &&
isModEnabled(
"banque")) {
2640 print
'<table width="100%" class="nobordernopadding"><tr><td>';
2641 print $langs->trans(
'BankAccount');
2643 if ($action !=
'editbankaccount' && $usercancreate) {
2644 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>';
2646 print
'</tr></table>';
2647 print
'</td><td class="valuefield">';
2648 if ($action ==
'editbankaccount') {
2649 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'fk_account', 1);
2651 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'none');
2657 $tmparray = $object->getTotalWeightVolume();
2658 $totalWeight = $tmparray[
'weight'];
2659 $totalVolume = $tmparray[
'volume'];
2661 print
'<tr><td>'.$langs->trans(
"CalculatedWeight").
'</td>';
2662 print
'<td class="valuefield">';
2663 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);
2667 print
'<tr><td>'.$langs->trans(
"CalculatedVolume").
'</td>';
2668 print
'<td class="valuefield">';
2669 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);
2676 print
'<table width="100%" class="nobordernopadding"><tr><td>';
2677 print $langs->trans(
'IncotermLabel');
2678 print
'<td><td class="right">';
2679 if ($action !=
'editincoterm' && $usercancreate && $caneditfield) {
2680 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/comm/propal/card.php?id='.$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit().
'</a>';
2684 print
'</td></tr></table>';
2686 print
'<td class="valuefield">';
2687 if ($action ==
'editincoterm' && $usercancreate && $caneditfield) {
2688 print
$form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.$object->id);
2690 print
$form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
2696 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2701 print
'<div class="fichehalfright">';
2702 print
'<div class="underbanner clearboth"></div>';
2704 print
'<table class="border tableforfield centpercent">';
2706 if (
isModEnabled(
"multicurrency") && ($object->multicurrency_code && $object->multicurrency_code != $conf->currency)) {
2708 print
'<tr><td class="titlefieldmiddle">'.$form->editfieldkey(
'MulticurrencyAmountHT',
'multicurrency_total_ht',
'', $object, 0).
'</td>';
2709 print
'<td class="nowrap right amountcard">'.price($object->multicurrency_total_ht,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
2713 print
'<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountVAT',
'multicurrency_total_tva',
'', $object, 0).
'</td>';
2714 print
'<td class="nowrap right amountcard">'.price($object->multicurrency_total_tva,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
2718 print
'<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountTTC',
'multicurrency_total_ttc',
'', $object, 0).
'</td>';
2719 print
'<td class="nowrap right amountcard">'.price($object->multicurrency_total_ttc,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
2724 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
'AmountHT').
'</td>';
2725 print
'<td class="nowrap right amountcard">'.price($object->total_ht,
'', $langs, 0, - 1, - 1, $conf->currency).
'</td>';
2729 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td>';
2730 print
'<td class="nowrap right amountcard">'.price($object->total_tva,
'', $langs, 0, - 1, - 1, $conf->currency).
'</td>';
2734 if ($mysoc->localtax1_assuj ==
"1" || $object->total_localtax1 != 0) {
2735 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
2736 print
'<td class="nowrap right amountcard">'.price($object->total_localtax1,
'', $langs, 0, - 1, - 1, $conf->currency).
'</td>';
2739 if ($mysoc->localtax2_assuj ==
"1" || $object->total_localtax2 != 0) {
2740 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
2741 print
'<td class="nowrap right amountcard">'.price($object->total_localtax2,
'', $langs, 0, - 1, - 1, $conf->currency).
'</td>';
2746 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td>';
2747 print
'<td class="nowrap right amountcard">'.price($object->total_ttc,
'', $langs, 0, - 1, - 1, $conf->currency).
'</td>';
2757 $formmargin->displayMarginInfos($object);
2763 print
'<div class="clearboth"></div><br>';
2765 if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
2766 $blocname =
'contacts';
2767 $title = $langs->trans(
'ContactsAddresses');
2768 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2771 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
2772 $blocname =
'notes';
2773 $title = $langs->trans(
'Notes');
2774 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
2782 $result = $object->getLinesArray();
2786 global $inputalsopricewithtax;
2787 $inputalsopricewithtax = 1;
2789 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'" method="POST">
2790 <input type="hidden" name="token" value="' .
newToken().
'">
2791 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
2792 <input type="hidden" name="mode" value="">
2793 <input type="hidden" name="page_y" value="">
2794 <input type="hidden" name="id" value="' . $object->id.
'">
2798 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
2801 print
'<div class="div-table-responsive-no-min">';
2802 if (!empty($object->lines) || ($object->statut ==
Propal::STATUS_DRAFT && $usercancreate && $action !=
'selectlines' && $action !=
'editline')) {
2803 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
2806 if (!empty($object->lines)) {
2807 $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 1);
2812 if ($action !=
'editline') {
2814 $reshook = $hookmanager->executeHooks(
'formAddObjectLine',
$parameters, $object, $action);
2815 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
2816 if (empty($reshook))
2817 $object->formAddObjectLine(1, $mysoc, $soc);
2820 $reshook = $hookmanager->executeHooks(
'formEditObjectLine',
$parameters, $object, $action);
2824 if (!empty($object->lines) || ($object->statut ==
Propal::STATUS_DRAFT && $usercancreate && $action !=
'selectlines' && $action !=
'editline')) {
2838 if ($action !=
'presend') {
2839 print
'<div class="tabsAction">';
2842 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
2844 if (empty($reshook)) {
2845 if ($action !=
'editline') {
2847 if (($object->statut ==
Propal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0)
2848 || ($object->statut ==
Propal::STATUS_DRAFT && !empty($conf->global->PROPAL_ENABLE_NEGATIVE) && count($object->lines) > 0)) {
2849 if ($usercanvalidate) {
2850 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=validate&token='.
newToken().
'">'.(empty($conf->global->PROPAL_SKIP_ACCEPT_REFUSE) ? $langs->trans(
'Validate') : $langs->trans(
'ValidateAndSign')).
'</a>';
2852 print
'<a class="butActionRefused classfortooltip" href="#">'.$langs->trans(
'Validate').
'</a>';
2862 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=modif&token='.
newToken().
'">'.$langs->trans(
'Modify').
'</a>';
2867 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=reopen&token='.
newToken().(empty($conf->global->MAIN_JUMP_TAG) ?
'' :
'#reopen').
'"';
2868 print
'>'.$langs->trans(
'ReOpen').
'</a>';
2872 if (empty($user->socid)) {
2874 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?action=presend&token='.
newToken().
'&id='.$object->id.
'&mode=init#formmailbeforetitle',
'', $usercansend);
2880 if ($usercancreateorder) {
2881 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>';
2886 if (!empty($conf->global->WORKFLOW_CAN_CREATE_PURCHASE_ORDER_FROM_PROPOSAL)) {
2888 if ($usercancreatepurchaseorder) {
2889 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>';
2896 if ($usercancreateintervention) {
2897 $langs->load(
"interventions");
2898 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>';
2904 $langs->load(
"contracts");
2906 if ($usercancreatecontract) {
2907 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>';
2913 if (
isModEnabled(
'facture') && $usercancreateinvoice) {
2914 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>';
2917 $arrayofinvoiceforpropal = $object->getInvoiceArrayList();
2918 if ((is_array($arrayofinvoiceforpropal) && count($arrayofinvoiceforpropal) > 0) || empty($conf->global->WORKFLOW_PROPAL_NEED_INVOICE_TO_BE_CLASSIFIED_BILLED)) {
2919 if ($usercanclose) {
2920 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=classifybilled&token='.
newToken().
'&socid='.$object->socid.
'">'.$langs->trans(
"ClassifyBilled").
'</a>';
2922 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
"ClassifyBilled").
'</a>';
2927 if (empty($conf->global->PROPAL_SKIP_ACCEPT_REFUSE)) {
2930 if ($usercanclose) {
2931 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=closeas&token='.
newToken().(empty($conf->global->MAIN_JUMP_TAG) ?
'' :
'#close').
'"';
2932 print
'>'.$langs->trans(
'SetAcceptedRefused').
'</a>';
2934 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'"';
2935 print
'>'.$langs->trans(
'SetAcceptedRefused').
'</a>';
2941 print
'<a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' . $object->id .
'&token='.newToken().
'&action=closeas&token='.
newToken() . (empty($conf->global->MAIN_JUMP_TAG) ?
'' :
'#close') .
'"';
2942 print
'>' . $langs->trans(
'SetRefusedAndClose') .
'</a>';
2947 if ($usercancreate) {
2948 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>';
2952 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.
newToken(),
'delete', $usercandelete);
2960 if (
GETPOST(
'modelselected')) {
2961 $action =
'presend';
2964 if ($action !=
'presend') {
2965 print
'<div class="fichecenter"><div class="fichehalfleft">';
2966 print
'<a name="builddoc"></a>';
2971 $filedir = $conf->propal->multidir_output[$object->entity].
"/".
dol_sanitizeFileName($object->ref);
2972 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2973 $genallowed = $usercanread;
2974 $delallowed = $usercancreate;
2976 print $formfile->showdocuments(
'propal', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'', 0,
'', $soc->default_lang,
'', $object);
2979 $linktoelem =
$form->showLinkToObjectBlock($object,
null, array(
'propal'));
2981 $compatibleImportElementsList =
false;
2983 $compatibleImportElementsList = array(
'commande',
'propal');
2985 $somethingshown =
$form->showLinkedObjectBlock($object, $linktoelem, $compatibleImportElementsList);
2988 $useonlinesignature = 1;
2991 print
'<br><!-- Link to sign -->';
2992 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
2993 print showOnlineSignatureUrl(
'proposal', $object->ref).
'<br>';
2996 print
'</div><div class="fichehalfright">';
2999 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3001 $somethingshown =
$formactions->showactions($object,
'propal', $socid, 1);
3003 print
'</div></div>';
3007 $modelmail =
'propal_send';
3008 $defaulttopic =
'SendPropalRef';
3009 $diroutput = $conf->propal->multidir_output[$object->entity];
3010 $trackid =
'pro'.$object->id;
3012 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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.
Class to manage products or services.
File of class to manage predefined price products or services by customer.
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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages 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).
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Fonction qui renvoie si tva doit etre tva percue recuperable.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessage($mesgs, $style='mesgs')
Set event message 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,...
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
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.
$formconfirm
if ($action == 'delbookkeepingyear') {
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.