40require
"../main.inc.php";
51require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/lib/contract.lib.php';
54require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/modules/contract/modules_contract.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
57require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
58require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
59require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
60require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
62 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
65 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
66 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
70$langs->loadLangs(array(
"contracts",
"orders",
"companies",
"bills",
"products",
'compta',
'propal'));
72$action =
GETPOST(
'action',
'aZ09');
73$confirm =
GETPOST(
'confirm',
'alpha');
74$cancel =
GETPOST(
'cancel',
'alpha');
75$backtopage =
GETPOST(
'backtopage',
'alpha');
76$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
81$origin =
GETPOST(
'origin',
'alpha');
84$attribute =
GETPOST(
'attribute',
'aZ09');
100 $socid = $user->socid;
104$hookmanager->initHooks(array(
'contractcard',
'globalcard'));
113if ($id > 0 || !empty($ref) && $action !=
'add') {
114 $ret =
$object->fetch($id, $ref);
116 $ret =
$object->fetch_thirdparty();
119 dol_print_error(
null,
$object->error);
124$extrafields->fetch_name_optionals_label(
$object->table_element);
127$extralabelslines = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
129$permissionnote = $user->hasRight(
'contrat',
'creer');
130$permissiondellink = $user->hasRight(
'contrat',
'creer');
131$permissiontodelete = ($user->hasRight(
'contrat',
'creer') &&
$object->status == $object::STATUS_DRAFT) || $user->hasRight(
'contrat',
'supprimer');
132$permissiontoadd = $user->hasRight(
'contrat',
'creer');
133$permissiontoedit = $permissiontoadd;
134$permissiontoactivate = $user->hasRight(
'contrat',
'activer');
135$permissiontodisable = $user->hasRight(
'contrat',
'desactiver');
136$permissiontoeditextra = $permissiontoadd;
137if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
139 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
147if (!(
$object->id > 0) && ($action ==
'view' || $action ==
'')) {
156$parameters = array(
'socid' => $socid);
157$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
159 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
161if (empty($reshook)) {
162 $backurlforlist =
dolBuildUrl(DOL_URL_ROOT .
'/contrat/list.php');
164 if (empty($backtopage) || ($cancel && empty($id))) {
165 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
166 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
167 $backtopage = $backurlforlist;
169 $backtopage =
dolBuildUrl(DOL_URL_ROOT .
'/contrat/card.php', [
'id'=> ((!empty($id) && $id > 0) ? $id :
'__ID__')]);
175 if (!empty($backtopageforcancel)) {
176 header(
"Location: ".$backtopageforcancel);
178 } elseif (!empty($backtopage)) {
179 header(
"Location: ".$backtopage);
185 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
187 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
189 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
191 if ($action ==
'confirm_active' && $confirm ==
'yes' && $permissiontoactivate) {
204 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
209 } elseif ($action ==
'confirm_sign' && $confirm ==
'yes' && $user->hasRight(
'contract',
'creer')) {
210 $result =
$object->setSignedStatus($user,
GETPOSTINT(
'signed_status'), 0,
'CONTRACT_MODIFY');
212 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
217 } elseif ($action ==
'confirm_unsign' && $confirm ==
'yes' && $user->hasRight(
'contract',
'creer')) {
218 $result =
$object->setSignedStatus($user, Contrat::$SIGNED_STATUSES[
'STATUS_NO_SIGNATURE'], 0,
'CONTRACT_MODIFY');
220 header(
'Location: ' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id);
225 } elseif ($action ==
'confirm_closeline' && $confirm ==
'yes' && $permissiontodisable) {
232 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
237 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
245 if (
GETPOST(
'mode') ==
'predefined') {
257 $date_start_update =
'';
258 $date_end_update =
'';
259 $date_start_real_update =
'';
260 $date_end_real_update =
'';
261 if (
GETPOST(
'date_start_updatemonth') &&
GETPOST(
'date_start_updateday') &&
GETPOST(
'date_start_updateyear')) {
264 if (
GETPOST(
'date_end_updatemonth') &&
GETPOST(
'date_end_updateday') &&
GETPOST(
'date_end_updateyear')) {
267 if (
GETPOST(
'date_start_real_updatemonth') &&
GETPOST(
'date_start_real_updateday') &&
GETPOST(
'date_start_real_updateyear')) {
270 if (
GETPOST(
'date_end_real_updatemonth') &&
GETPOST(
'date_end_real_updateday') &&
GETPOST(
'date_end_real_updateyear')) {
278 if ($action ==
'add' && $user->hasRight(
'contrat',
'creer')) {
280 if (empty($datecontrat)) {
282 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
287 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")),
null,
'errors');
293 $ret = $extrafields->setOptionalsFromPost(
null, $object);
301 $object->date_contrat = $datecontrat;
315 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
319 if (!empty($origin) && !empty($originid)) {
321 $object->origin_id = $originid;
326 $object->linked_objects = array_merge(
$object->linked_objects,
GETPOST(
'other_linked_objects',
'array:int'));
334 $srcobject = fetchObjectByElement(
$object->origin_id, $origin);
336 if (is_object($srcobject) && $srcobject->id > 0) {
337 '@phan-var-force Commande|Propal|Facture $srcobject';
338 $srcobject->fetch_thirdparty();
339 $lines = $srcobject->lines;
340 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
341 $srcobject->fetch_lines();
342 $lines = $srcobject->lines;
346 $num = count($lines);
349 for ($i = 0; $i < $num; $i++) {
350 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
352 if ($product_type == 1 || (
getDolGlobalString(
'CONTRACT_SUPPORT_PRODUCTS') && in_array($product_type, array(0, 1)))) {
354 if ($lines[$i]->fk_product > 0) {
358 $prod->id = $lines[$i]->fk_product;
359 $prod->getMultiLangs();
361 $outputlangs = $langs;
363 if (
GETPOST(
'lang_id',
'aZ09')) {
364 $newlang =
GETPOST(
'lang_id',
'aZ09');
366 if (empty($newlang)) {
367 $newlang = $srcobject->thirdparty->default_lang;
369 if (!empty($newlang)) {
371 $outputlangs->setDefaultLang($newlang);
374 $label = (!empty($prod->multilangs[$outputlangs->defaultlang][
"libelle"])) ? $prod->multilangs[$outputlangs->defaultlang][
"libelle"] : $lines[$i]->product_label;
376 $label = $lines[$i]->product_label;
378 $desc = ($lines[$i]->desc && $lines[$i]->desc != $lines[$i]->label) ?
dol_htmlentitiesbr($lines[$i]->desc) :
'';
384 $array_options = array();
386 if (method_exists($lines[$i],
'fetch_optionals')) {
387 $lines[$i]->fetch_optionals();
388 $array_options = $lines[$i]->array_options;
391 $txtva = $lines[$i]->vat_src_code ? $lines[$i]->tva_tx.
' ('.$lines[$i]->vat_src_code.
')' : $lines[$i]->tva_tx;
399 $line_price_base_type = $lines[$i]->getPriceBaseType();
402 $lines[$i]->subprice,
407 $lines[$i]->fk_product,
408 $lines[$i]->remise_percent,
409 $lines[$i]->date_start,
410 $lines[$i]->date_end,
411 $line_price_base_type,
412 (
float) $lines[$i]->subprice_ttc,
413 $lines[$i]->info_bits,
414 $lines[$i]->fk_fournprice,
417 (
int) $lines[$i]->fk_unit,
428 if (is_object($srcobject) && !empty($srcobject->error)) {
429 $srcobjecterror = $srcobject->error;
431 $langs->load(
"errors");
432 $srcobjecterror = $langs->trans(
"ErrorRecordNotFound");
434 setEventMessages($srcobjecterror, (is_object($srcobject) ? $srcobject->errors : null),
'errors');
439 $parameters = array(
'objFrom' => (is_object($srcobject) ? $srcobject : null));
440 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $object, $action);
443 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
454 $result =
$object->create($user);
456 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
464 } elseif ($action ==
'classin' && $user->hasRight(
'contrat',
'creer')) {
466 } elseif ($action ==
'addline' && $user->hasRight(
'contrat',
'creer')) {
473 $price_ht_devise =
'';
475 $price_ttc_devise =
'';
477 $rang = count(
$object->lines) + 1;
479 if (
GETPOST(
'price_ht') !==
'') {
482 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
485 if (
GETPOST(
'price_ttc') !==
'') {
488 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
492 if (
GETPOST(
'prod_entry_mode',
'alpha') ==
'free') {
498 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
503 $tva_tx =
GETPOST(
'tva_tx',
'alpha');
507 if (empty($remise_percent)) {
512 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Qty")),
null,
'errors');
515 if (
GETPOST(
'prod_entry_mode',
'alpha') ==
'free' && (empty($idprod) || $idprod < 0) && empty($line_desc)) {
516 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Description")),
null,
'errors');
523 setEventMessages($langs->trans(
"Error").
': '.$langs->trans(
"DateStartPlanned").
' > '.$langs->trans(
"DateEndPlanned"),
null,
'errors');
528 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
529 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
531 if (is_array($extralabelsline)) {
533 foreach ($extralabelsline as $key => $value) {
534 unset($_POST[
"options_".$key]);
543 $price_base_type =
'';
550 $prod->fetch($idprod);
559 $price_min = $prod->price_min;
560 $price_min_ttc = $prod->price_min_ttc;
564 $price_min = $prod->multiprices_min[
$object->thirdparty->price_level];
565 $price_min_ttc = $prod->multiprices_min_ttc[
$object->thirdparty->price_level];
568 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
572 $filter = array(
't.fk_product' => (
string) $prod->id,
't.fk_soc' => (
string)
$object->thirdparty->id);
574 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
576 if (count($prodcustprice->lines) > 0) {
577 $date_now = (int) floor(
dol_now() / 86400) * 86400;
578 foreach ($prodcustprice->lines as $k => $custprice_line) {
579 if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
580 $price_min =
price($custprice_line->price_min);
581 $price_min_ttc =
price($custprice_line->price_min_ttc);
597 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
598 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string) $prod->tva_tx));
601 if (!empty($price_ht) || $price_ht ===
'0') {
603 $pu_ttc =
price2num((
float) $pu_ht * (1 + ((
float) $tmpvat / 100)),
'MU');
604 $price_base_type =
'HT';
605 } elseif (!empty($price_ttc) || $price_ttc ===
'0') {
607 $pu_ht =
price2num((
float) $pu_ttc / (1 + ((
float) $tmpvat / 100)),
'MU');
608 $price_base_type =
'TTC';
611 $desc = $prod->description;
621 $fk_unit = $prod->fk_unit;
625 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
626 if (empty($tva_tx)) {
629 $tva_tx = str_replace(
'*',
'', $tva_tx);
632 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
633 $pu_ttc_devise =
price2num($price_ttc_devise,
'MU');
635 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
638 if (!empty($price_ht) || $price_ht ===
'0') {
640 $pu_ttc =
price2num((
float) $pu_ht * (1 + ((
float) $tmpvat / 100)),
'MU');
641 $price_base_type =
'HT';
642 } elseif (!empty($price_ttc) || $price_ttc ===
'0') {
644 $pu_ht =
price2num((
float) $pu_ttc / (1 + ((
float) $tmpvat / 100)),
'MU');
645 $price_base_type =
'TTC';
653 $fk_fournprice =
GETPOST(
'fournprice');
655 $pa_ht =
GETPOST(
'buying_price');
665 if (((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'produit',
'ignore_price_min_advance'))
667 $object->error = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
685 (
int) $fk_fournprice,
690 (
float) $pu_ht_devise
697 $outputlangs = $langs;
700 $newlang =
GETPOST(
'lang_id',
'aZ09');
703 $newlang =
$object->thirdparty->default_lang;
705 if (!empty($newlang)) {
707 $outputlangs->setDefaultLang($newlang);
712 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
715 unset($_POST[
'prod_entry_mode']);
717 unset($_POST[
'qty']);
718 unset($_POST[
'type']);
719 unset($_POST[
'remise_percent']);
720 unset($_POST[
'price_ht']);
721 unset($_POST[
'multicurrency_price_ht']);
722 unset($_POST[
'price_ttc']);
723 unset($_POST[
'tva_tx']);
724 unset($_POST[
'product_ref']);
725 unset($_POST[
'product_label']);
726 unset($_POST[
'product_desc']);
727 unset($_POST[
'fournprice']);
728 unset($_POST[
'buying_price']);
729 unset($_POST[
'np_marginRate']);
730 unset($_POST[
'np_markRate']);
731 unset($_POST[
'dp_desc']);
732 unset($_POST[
'idprod']);
734 unset($_POST[
'date_starthour']);
735 unset($_POST[
'date_startmin']);
736 unset($_POST[
'date_startsec']);
737 unset($_POST[
'date_startday']);
738 unset($_POST[
'date_startmonth']);
739 unset($_POST[
'date_startyear']);
740 unset($_POST[
'date_endhour']);
741 unset($_POST[
'date_endmin']);
742 unset($_POST[
'date_endsec']);
743 unset($_POST[
'date_endday']);
744 unset($_POST[
'date_endmonth']);
745 unset($_POST[
'date_endyear']);
750 } elseif ($action ==
'updateline' && $user->hasRight(
'contrat',
'creer') && !
GETPOST(
'cancel',
'alpha')) {
754 if (!empty($date_start_update) && !empty($date_end_update) && $date_start_update > $date_end_update) {
755 setEventMessages($langs->trans(
"Error").
': '.$langs->trans(
"DateStartPlanned").
' > '.$langs->trans(
"DateEndPlanned"),
null,
'errors');
756 $action =
'editline';
762 if ($objectline->fetch($idline) < 0) {
763 setEventMessages($objectline->error, $objectline->errors,
'errors');
766 $objectline->fetch_optionals();
768 $objectline->oldcopy =
dol_clone($objectline, 2);
776 if ($date_start_real_update ==
'') {
777 $date_start_real_update = $objectline->date_start_real;
779 if ($date_end_real_update ==
'') {
780 $date_end_real_update = $objectline->date_end_real;
783 $vat_rate =
GETPOST(
'eltva_tx',
'alpha');
786 if (preg_match(
'/\*/', $vat_rate)) {
791 $vat_rate = str_replace(
'*',
'', $vat_rate);
800 if (preg_match(
'/\((.*)\)/', $txtva, $reg)) {
801 $vat_src_code = $reg[1];
802 $txtva = preg_replace(
'/\s*\(.*\)/',
'', $txtva);
818 $objectline->fk_product =
GETPOSTINT(
'idprod');
819 $objectline->description =
GETPOST(
'product_desc',
'restricthtml');
823 if (isset($objectline->oldcopy) && (float) $objectline->subprice != (
float) $objectline->oldcopy->subprice) {
824 $objectline->subprice_ttc = 0;
827 $objectline->remise_percent = $remise_percent;
828 $objectline->tva_tx = ($txtva ? $txtva : 0);
829 $objectline->vat_src_code = $vat_src_code;
830 $objectline->localtax1_tx = is_numeric($localtax1_tx) ? $localtax1_tx : 0;
831 $objectline->localtax2_tx = is_numeric($localtax2_tx) ? $localtax2_tx : 0;
832 $objectline->date_start = $date_start_update;
833 $objectline->date_start_real = $date_start_real_update;
834 $objectline->date_end = $date_end_update;
835 $objectline->date_end_real = $date_end_real_update;
836 $objectline->user_closing_id = $user->id;
838 $objectline->pa_ht = $pa_ht;
844 $objectline->fk_unit =
null;
848 $extralabelsline = $extrafields->fetch_name_optionals_label($objectline->table_element);
849 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
851 if (is_array($array_options) && count($array_options) > 0) {
853 foreach ($array_options as $key => $value) {
854 $objectline->array_options[$key] = $array_options[$key];
860 $result = $objectline->update($user);
863 $action =
'editline';
864 $_GET[
'rowid'] =
GETPOST(
'elrowid');
865 setEventMessages($objectline->error, $objectline->errors,
'errors');
874 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $user->hasRight(
'contrat',
'creer')) {
878 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
883 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' && $user->hasRight(
'contrat',
'creer')) {
884 $result =
$object->validate($user);
889 $outputlangs = $langs;
892 $newlang =
GETPOST(
'lang_id',
'aZ09');
895 $newlang =
$object->thirdparty->default_lang;
897 if (!empty($newlang)) {
899 $outputlangs->setDefaultLang($newlang);
904 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
909 } elseif ($action ==
'reopen' && $user->hasRight(
'contrat',
'creer')) {
910 $result =
$object->reopen($user);
914 } elseif ($action ==
'confirm_close' && $confirm ==
'yes' && $permissiontodisable) {
916 $result =
$object->closeAll($user);
920 } elseif ($action ==
'confirm_activate' && $confirm ==
'yes' && $permissiontoactivate) {
923 $comment =
GETPOST(
'comment',
'alpha');
928 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontodelete) {
930 $result =
$object->delete($user);
932 header(
"Location: list.php?restore_lastsearch_values=1");
937 } elseif ($action ==
'confirm_move' && $confirm ==
'yes' && $permissiontoedit) {
940 $result = $contractline->fetch(
GETPOSTINT(
'lineid'));
941 $contractline->fk_contrat =
GETPOSTINT(
'newcid');
942 $result = $contractline->update($user, 1);
944 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
950 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"RefNewContract")),
null,
'errors');
952 } elseif ($action ==
'update_extras' && $permissiontoeditextra) {
955 $attribute =
GETPOST(
'attribute',
'aZ09');
958 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute);
960 setEventMessages($extrafields->error,
$object->errors,
'errors');
965 $result =
$object->updateExtraField($attribute,
'CONTRACT_MODIFY');
973 $action =
'edit_extras';
975 } elseif ($action ==
'setref_supplier' && $permissiontoadd) {
979 $result =
$object->setValueFrom(
'ref_supplier',
GETPOST(
'ref_supplier',
'alpha'),
'',
null,
'text',
'', $user,
'CONTRACT_MODIFY');
982 $action =
'editref_supplier';
984 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
988 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
991 } elseif ($action ==
'setref_customer' && $permissiontoadd) {
995 $result =
$object->setValueFrom(
'ref_customer',
GETPOST(
'ref_customer',
'alpha'),
'',
null,
'text',
'', $user,
'CONTRACT_MODIFY');
998 $action =
'editref_customer';
1000 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
1004 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
1007 } elseif ($action ==
'setref' && $permissiontoadd) {
1009 $result =
$object->fetch($id);
1016 $result =
$object->setValueFrom(
'ref',
GETPOST(
'ref',
'alpha'),
'',
null,
'text',
'', $user,
'CONTRACT_MODIFY');
1019 $action =
'editref';
1021 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1028 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
1032 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
1035 } elseif ($action ==
'setdate_contrat' && $permissiontoadd) {
1037 $result =
$object->fetch($id);
1042 $result =
$object->setValueFrom(
'date_contrat', $datacontrat,
'',
null,
'date',
'', $user,
'CONTRACT_MODIFY');
1045 $action =
'editdate_contrat';
1047 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
1051 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
1057 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1061 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1064 $triggersendname =
'CONTRACT_SENTBYMAIL';
1066 $mode =
'emailfromcontract';
1067 $trackid =
'con'.$object->id;
1068 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1072 if ($action ==
'addcontact' && $user->hasRight(
'contrat',
'creer')) {
1075 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
1078 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
1081 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1082 $langs->load(
"errors");
1083 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
1088 } elseif ($action ==
'swapstatut' && $user->hasRight(
'contrat',
'creer')) {
1091 } elseif ($action ==
'deletecontact' && $user->hasRight(
'contrat',
'creer')) {
1096 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
1105 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $user->hasRight(
'contrat',
'creer')) {
1107 setEventMessages($langs->trans(
"NoCloneOptionsSpecified"),
null,
'errors');
1110 $result =
$object->createFromClone($user, $socid);
1112 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
1115 if (count(
$object->errors) > 0) {
1130$title =
$object->ref.
" - ".$langs->trans(
'Contract');
1131if ($action ==
'create') {
1132 $title = $langs->trans(
"NewContract");
1134$help_url =
'EN:Module_Contracts|FR:Module_Contrat|ES:Contratos_de_servicio';
1136llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-contrat page-card');
1138$form =
new Form($db);
1147if (substr(
$module, 0, 13) ==
'mod_contract_' && substr(
$module, -3) ==
'php') {
1151$modCodeContract =
null;
1153 $modCodeContract =
new $module();
1155 '@phan-var-force ModelNumRefContracts $modCodeContract';
1159if ($action ==
'create') {
1166 $soc->fetch($socid);
1173 if (preg_match(
'/^([^_]+)_([^_]+)/i',
GETPOST(
'origin'), $regs)) {
1174 $element = $regs[1];
1177 if ($element ==
'project') {
1181 $objectsrc = fetchObjectByElement($originid, $origin);
1183 if (is_object($objectsrc) && $objectsrc->id > 0) {
1184 '@phan-var-force Commande|Propal|Facture $objectsrc';
1185 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1186 $objectsrc->fetch_lines();
1188 $objectsrc->fetch_thirdparty();
1191 $objectsrc->fetch_optionals();
1192 $object->array_options = $objectsrc->array_options;
1194 $projectid = (int) $objectsrc->fk_project;
1196 $soc = $objectsrc->thirdparty;
1198 $note_private = (!empty($objectsrc->note_private) ? $objectsrc->note_private :
'');
1199 $note_public = (!empty($objectsrc->note_public) ? $objectsrc->note_public :
'');
1202 $srccontactslist = $objectsrc->liste_contact(-1,
'external', 1);
1209 $note_private =
GETPOST(
"note_private",
"alpha");
1210 $note_public =
GETPOST(
"note_public",
"alpha");
1215 print
'<form name="form_contract" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1216 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1217 print
'<input type="hidden" name="action" value="add">';
1218 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">'.
"\n";
1219 print
'<input type="hidden" name="remise_percent" value="0">';
1220 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1221 if ($backtopageforcancel) {
1222 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
1224 print
'<input type="hidden" name="contract_type" value="'.GETPOSTINT(
'contract_type').
'">';
1228 print
'<table class="border centpercent">';
1231 if (empty($modCodeContract->code_auto)) {
1232 print
'<tr><td class="titlefield fieldrequired">'.$langs->trans(
'Ref').
'</td><td>';
1236 $tmpcode =
'<input name="ref" class="maxwidth100" maxlength="128" value="'.dol_escape_htmltag(
GETPOST(
'ref',
'alpha')).
'">';
1244 print
'<tr><td>'.$langs->trans(
'RefCustomer').
'</td>';
1245 print
'<td><input type="text" class="maxwidth150" name="ref_customer" id="ref_customer" value="'.dol_escape_htmltag(
GETPOST(
'ref_customer',
'alpha')).
'"></td></tr>';
1249 print
'<tr><td>'.$langs->trans(
'RefSupplier').
'</td>';
1250 print
'<td><input type="text" class="maxwidth150" name="ref_supplier" id="ref_supplier" value="'.dol_escape_htmltag(
GETPOST(
'ref_supplier',
'alpha')).
'"></td></tr>';
1255 print
'<td class="fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
1258 print $soc->getNomUrl(1);
1259 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1263 print img_picto(
'',
'company',
'class="pictofixedwidth"');
1264 print $form->select_company(
'',
'socid',
'',
'SelectThirdParty', 1, 0, array(), 0,
'minwidth150 widthcentpercentminusxx maxwidth500');
1265 print
' <a href="'.dolBuildUrl(DOL_URL_ROOT .
'/societe/card.php', [
'action' =>
'create',
'customer' => 3,
'backtopage' =>
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'create'])]).
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddThirdParty").
'"></span></a>';
1272 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
1273 if ($soc->remise_percent) {
1274 print $langs->trans(
"CompanyHasRelativeDiscount", $soc->remise_percent).
' ';
1276 print
'<span class="hideonsmartphone">'.$langs->trans(
"CompanyHasNoRelativeDiscount").
'. </span>';
1278 $absolute_discount = $soc->getAvailableDiscounts();
1279 if ($absolute_discount) {
1280 print $langs->trans(
"CompanyHasAbsoluteDiscount",
price($absolute_discount), $langs->trans(
"Currency".$conf->currency)).
'.';
1282 print
'<span class="hideonsmartphone">'.$langs->trans(
"CompanyHasNoAbsoluteDiscount").
'.</span>';
1288 print
'<tr><td class="nowrap"><span class="fieldrequired">'.$langs->trans(
"TypeContact_contrat_internal_SALESREPFOLL").
'</span></td><td>';
1289 print img_picto(
'',
'user',
'class="pictofixedwidth"');
1290 print $form->select_dolusers(
GETPOST(
"commercial_suivi_id") ?
GETPOST(
"commercial_suivi_id") : $user->id,
'commercial_suivi_id', 1, null);
1294 print
'<tr><td class="nowrap"><span class="fieldrequired">'.$langs->trans(
"TypeContact_contrat_internal_SALESREPSIGN").
'</span></td><td>';
1295 print img_picto(
'',
'user',
'class="pictofixedwidth"');
1296 print $form->select_dolusers(
GETPOST(
"commercial_signature_id") ?
GETPOST(
"commercial_signature_id") : $user->id,
'commercial_signature_id', 1, null);
1299 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td><td>';
1300 print img_picto(
'',
'action',
'class="pictofixedwidth"');
1301 print $form->selectDate($datecontrat,
'', 0, 0, 0,
"contrat");
1306 $currency_code = (is_object($objectsrc) && !empty($objectsrc->multicurrency_code)) ? $objectsrc->multicurrency_code : ($soc->multicurrency_code ? $soc->multicurrency_code :
$conf->currency);
1308 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
1310 print img_picto(
'',
'currency',
'class="pictofixedwidth"');
1311 print $form->selectMultiCurrency((
GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code',
'alpha') : $currency_code),
'multicurrency_code');
1317 $langs->load(
'projects');
1321 print
'<tr><td>'.$langs->trans(
"Project").
'</td><td>';
1322 print img_picto(
'',
'project',
'class="pictofixedwidth"');
1323 $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid,
"projectid", 0, 0, 1, 1, 0, 0, 0,
'', 0, 0,
'minwidth150 maxwidth300 widthcentpercentminusxx');
1324 print
' <a href="' .
dolBuildUrl(DOL_URL_ROOT .
'/projet/card.php', [
'socid' => $soc->id,
'action' =>
'create',
'status' => 1,
'backtopage' =>
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'create',
'socid' => $soc->id])]) .
'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1329 print
'<tr><td>'.$langs->trans(
"NotePublic").
'</td><td class="tdtop">';
1330 $doleditor =
new DolEditor(
'note_public', (
string) $note_public,
'', 100,
'dolibarr_notes',
'In',
true,
true, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1331 print $doleditor->Create(1);
1335 if (empty($user->socid)) {
1336 print
'<tr><td>'.$langs->trans(
"NotePrivate").
'</td><td class="tdtop">';
1337 $doleditor =
new DolEditor(
'note_private', (
string) $note_private,
'', 100,
'dolibarr_notes',
'In',
true,
true, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1338 print $doleditor->Create(1);
1343 $parameters = array(
'objectsrc' => $objectsrc,
'colspan' =>
' colspan="3"',
'cols' =>
'3');
1344 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1345 print $hookmanager->resPrint;
1348 if (empty($reshook)) {
1349 print
$object->showOptionals($extrafields,
'create', $parameters);
1356 print $form->buttonsSaveCancel(
"CreateDraft");
1358 if (is_object($objectsrc)) {
1359 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
1360 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
1363 print
'<br>'.$langs->trans(
"Note").
': '.$langs->trans(
"OnlyLinesWithTypeServiceAreUsed");
1377 $result =
$object->fetch_lines();
1379 dol_print_error($db,
$object->error);
1382 $nbofservices = count(
$object->lines);
1384 $author =
new User($db);
1385 $author->fetch(
$object->user_author_id);
1387 $commercial_signature =
new User($db);
1388 $commercial_signature->fetch(
$object->commercial_signature_id);
1390 $commercial_suivi =
new User($db);
1391 $commercial_suivi->fetch(
$object->commercial_suivi_id);
1398 print
dol_get_fiche_head($head, $hselected, $langs->trans(
"Contract"), -1,
'contract', 0,
'',
'', 0,
'', 1);
1401 if ($action ==
'delete') {
1403 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id, $langs->trans(
"DeleteAContract"), $langs->trans(
"ConfirmDeleteAContract"),
"confirm_delete",
'', 0, 1);
1404 } elseif ($action ==
'valid') {
1406 $ref = substr(
$object->ref, 1, 4);
1407 if ($ref ==
'PROV' && !empty($modCodeContract->code_auto)) {
1410 $numref = (string)
$object->ref;
1412 $text = $langs->trans(
'ConfirmValidateContract', $numref);
1413 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id, $langs->trans(
"ValidateAContract"), $text,
"confirm_valid",
'', 0, 1);
1414 } elseif ($action ==
'close') {
1416 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id, $langs->trans(
"CloseAContract"), $langs->trans(
"ConfirmCloseContract"),
"confirm_close",
'', 0, 1);
1417 } elseif ($action ==
'activate') {
1418 $formquestion = array(
1419 array(
'type' =>
'date',
'name' =>
'd_start',
'label' => $langs->trans(
"DateServiceActivate"),
'value' =>
dol_now()),
1420 array(
'type' =>
'date',
'name' =>
'd_end',
'label' => $langs->trans(
"DateEndPlanned"), 0 =>
'', 1 =>
''),
1421 array(
'type' =>
'text',
'name' =>
'comment',
'label' => $langs->trans(
"Comment"),
'value' =>
'', 0 =>
'', 1 =>
'',
'class' =>
'minwidth300',
'moreattr' =>
'autofocus')
1423 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id, $langs->trans(
"ActivateAllOnContract"), $langs->trans(
"ConfirmActivateAllOnContract"),
"confirm_activate", $formquestion,
'yes', 1, 300);
1424 } elseif ($action ==
'clone') {
1425 $filter =
'(s.client:IN:1,2,3) OR (s.fournisseur:=:1)';
1427 $formquestion = array(array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter)));
1428 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneContract',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
1429 } elseif ($action ==
'sign') {
1430 $text = $langs->trans(
'ConfirmSignContract');
1432 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
1433 $notify =
new Notify($db);
1435 $text .= $notify->confirmMessage(
'CONTRACT_MODIFY',
$object->socid, $object);
1440 'name' =>
'signed_status',
1441 'label' =>
'<span class="fieldrequired">'.$langs->trans(
'SignStatus').
'</span>',
1442 'values' =>
$object->getSignedStatusLocalisedArray()
1444 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'SignContract'), $text,
'confirm_sign', $formquestion, 0, 1);
1445 } elseif ($action ==
'unsign') {
1446 $text = $langs->trans(
'ConfirmUnsignContract');
1448 require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
1449 $notify =
new Notify($db);
1451 $text .= $notify->confirmMessage(
'CONTRACT_MODIFY',
$object->socid, $object);
1453 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'UnsignContract'), $text,
'confirm_unsign',
'', 0, 1);
1458 $parameters = array(
1459 'formConfirm' => $formconfirm,
1464 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1465 if (empty($reshook)) {
1466 $formconfirm .= $hookmanager->resPrint;
1467 } elseif ($reshook > 0) {
1468 $formconfirm = $hookmanager->resPrint;
1476 if (
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'contrat',
'creer')) {
1477 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'" method="POST">';
1478 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1479 print
'<input type="hidden" name="action" value="setremise">';
1480 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1485 $linkback =
'<a href="'.DOL_URL_ROOT.
'/contrat/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1489 if (!empty($modCodeContract->code_auto)) {
1492 $morehtmlref .= $form->editfieldkey(
"",
'ref',
$object->ref, $object, $user->hasRight(
'contrat',
'creer'),
'string',
'', 0, 3);
1493 $morehtmlref .= $form->editfieldval(
"",
'ref',
$object->ref, $object, $user->hasRight(
'contrat',
'creer'),
'string',
'',
null,
'2');
1496 $morehtmlref .=
'<div class="refidno">';
1498 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_customer',
$object->ref_customer, $object, $user->hasRight(
'contrat',
'creer'),
'string',
'', 0, 1);
1499 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'ref_customer',
$object->ref_customer, $object, $user->hasRight(
'contrat',
'creer'),
'string'.(isset(
$conf->global->THIRDPARTY_REF_INPUT_SIZE) ?
':' .
getDolGlobalString(
'THIRDPARTY_REF_INPUT_SIZE') :
''),
'', null, null,
'', 1,
'getFormatedCustomerRef');
1501 $morehtmlref .=
'<br>';
1502 $morehtmlref .= $form->editfieldkey(
"RefSupplier",
'ref_supplier',
$object->ref_supplier, $object, $user->hasRight(
'contrat',
'creer'),
'string',
'', 0, 1);
1503 $morehtmlref .= $form->editfieldval(
"RefSupplier",
'ref_supplier',
$object->ref_supplier, $object, $user->hasRight(
'contrat',
'creer'),
'string',
'',
null,
null,
'', 1,
'getFormatedSupplierRef');
1505 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
1507 $morehtmlref .=
' <span class="otherlink valignmiddle">(<a href="'.DOL_URL_ROOT.
'/contrat/list.php?socid='.((int)
$object->thirdparty->id).
'">'.$langs->trans(
"OtherContracts").
'</a>)</span>';
1511 $langs->load(
"projects");
1512 $morehtmlref .=
'<br>';
1513 if ($permissiontoadd) {
1514 $morehtmlref .= img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
1515 if ($action !=
'classify') {
1516 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' => ((
int)
$object->id)],
true).
'">'.img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
1518 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid, (
string)
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
1520 if (!empty(
$object->fk_project)) {
1522 $proj->fetch(
$object->fk_project);
1523 $morehtmlref .= $proj->getNomUrl(1);
1525 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
1530 $morehtmlref .=
'</div>';
1533 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'none', $morehtmlref);
1536 print
'<div class="fichecenter">';
1537 print
'<div class="fichehalfleft">';
1538 print
'<div class="underbanner clearboth"></div>';
1540 print
'<table class="border centpercent tableforfield">';
1543 print
'<tr><td class="titlefield">'.$langs->trans(
'Discount').
'</td><td colspan="3">';
1544 if (
$object->thirdparty->remise_percent) {
1545 print $langs->trans(
"CompanyHasRelativeDiscount",
$object->thirdparty->remise_percent).
'. ';
1547 print
'<span class="hideonsmartphone opacitymedium">'.$langs->trans(
"CompanyHasNoRelativeDiscount").
'. </span>';
1549 $absolute_discount =
$object->thirdparty->getAvailableDiscounts();
1550 if ($absolute_discount) {
1551 print $langs->trans(
"CompanyHasAbsoluteDiscount",
price($absolute_discount), $langs->trans(
"Currency".$conf->currency)).
'.';
1553 print
'<span class="hideonsmartphone opacitymedium">'.$langs->trans(
"CompanyHasNoAbsoluteDiscount").
'.</span>';
1559 print
'<td class="titlefield">';
1560 print $form->editfieldkey(
"Date",
'date_contrat',
$object->date_contrat, $object, $user->hasRight(
'contrat',
'creer'));
1562 print $form->editfieldval(
"Date",
'date_contrat',
$object->date_contrat, $object, $user->hasRight(
'contrat',
'creer'),
'datehourpicker');
1567 $contractTypeLabels = array(0 => $langs->trans(
'CustomerContract'), 1 => $langs->trans(
'SupplierContract'));
1568 print
'<tr><td class="titlefield">'.$langs->trans(
'ContractType').
'</td>';
1569 print
'<td>'.dol_escape_htmltag($contractTypeLabels[(
int)
$object->fk_contract_type] ?? $contractTypeLabels[0]).
'</td>';
1573 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1578 print
'<div class="fichehalfright">';
1580 print
'<!-- amounts -->'.
"\n";
1581 print
'<div class="underbanner clearboth"></div>';
1584 print
'<div class="div-table-responsive-no-min">';
1585 print
'<table class="border tableforfield centpercent">';
1588 print
'<tr><td class="titlefield">'.
"".
'</td>';
1589 print
'<td class=right>'.$langs->trans(
'Total').
'</td>';
1590 print
'<td class=right>'.$staticcontractline->LibStatut(0, 5, 0).
'</td>';
1591 print
'<td class=right>'.$staticcontractline->LibStatut(4, 5, 0).
'</td>';
1592 print
'<td class=right>'.$staticcontractline->LibStatut(4, 5, 1).
'</td>';
1593 print
'<td class=right>'.$staticcontractline->LibStatut(5, 5, 0).
'</td>';
1596 $all=
$object->getTotalizedLines(-1, 0);
1597 $draft=
$object->getTotalizedLines(0, 0);
1598 $enabled=
$object->getTotalizedLines(4, 0);
1599 $expired=
$object->getTotalizedLines(4, 1);
1600 $close=
$object->getTotalizedLines(5, 0);
1603 print
'<tr><td class="titlefield">'.$langs->trans(
"Quantity").
'</td>';
1604 print
'<td class="right nowrap">'.($all[
'total_qty'] ?
price2num($all[
'total_qty']) :
'<span class="opacitymedium">0</span>').
'</td>';
1605 print
'<td class="right">'.($draft[
'total_qty'] ?
price2num($draft[
'total_qty']) :
'<span class="opacitymedium">0</span>').
'</td>';
1606 print
'<td class="right">'.($enabled[
'total_qty'] ?
price2num($enabled[
'total_qty']) :
'<span class="opacitymedium">0</span>').
'</td>';
1607 print
'<td class="right">'.($expired[
'total_qty'] ?
price2num($expired[
'total_qty']) :
'<span class="opacitymedium">0</span>').
'</td>';
1608 print
'<td class="right">'.($close[
'total_qty'] ?
price2num($close[
'total_qty']) :
'<span class="opacitymedium">0</span>').
'</td>';
1611 print
'<tr><td class="titlefield">'.$langs->trans(
"TotalHT").
'</td>';
1612 print
'<td class="nowraponall amountcard right">'.($all[
'total_ht'] ?
price($all[
'total_ht']) :
'<span class="opacitymedium">0</span>').
'</td>';
1613 print
'<td class="nowraponall amountcard right">'.($draft[
'total_ht'] ?
price($draft[
'total_ht']) :
'<span class="opacitymedium">0</span>').
'</td>';
1614 print
'<td class="nowraponall amountcard right">'.($enabled[
'total_ht'] ?
price($enabled[
'total_ht']) :
'<span class="opacitymedium">0</span>').
'</td>';
1615 print
'<td class="nowraponall amountcard right">'.($expired[
'total_ht'] ?
price($expired[
'total_ht']) :
'<span class="opacitymedium">0</span>').
'</td>';
1616 print
'<td class="nowraponall amountcard right">'.($close[
'total_ht'] ?
price($close[
'total_ht']) :
'<span class="opacitymedium">0</span>').
'</td>';
1619 print
'<tr><td class="titlefield">'.$langs->trans(
"TotalVAT").
'</td>';
1620 print
'<td class="nowraponall amountcard right nowrap">'.($all[
'total_tva'] ?
price($all[
'total_tva']) :
'<span class="opacitymedium">0</span>').
'</td>';
1621 print
'<td class="nowraponall amountcard right">'.($draft[
'total_tva'] ?
price($draft[
'total_tva']) :
'<span class="opacitymedium">0</span>').
'</td>';
1622 print
'<td class="nowraponall amountcard right">'.($enabled[
'total_tva'] ?
price($enabled[
'total_tva']) :
'<span class="opacitymedium">0</span>').
'</td>';
1623 print
'<td class="nowraponall amountcard right">'.($expired[
'total_tva'] ?
price($expired[
'total_tva']) :
'<span class="opacitymedium">0</span>').
'</td>';
1624 print
'<td class="nowraponall amountcard right">'.($close[
'total_tva'] ?
price($close[
'total_tva']) :
'<span class="opacitymedium">0</span>').
'</td>';
1627 if (
$mysoc->localtax1_assuj ==
"1" || $all[
'total_localtax1'] != 0) {
1628 print
'<tr><td class="titlefield">' . $langs->trans(
"TotalLT1") .
'</td>';
1629 print
'<td class="nowraponall amountcard right nowrap">' . ($all[
'total_localtax1'] ?
price($all[
'total_localtax1']) :
'<span class="opacitymedium">0</span>') .
'</td>';
1630 print
'<td class="nowraponall amountcard right">' . ($draft[
'total_localtax1'] ?
price($draft[
'total_localtax1']) :
'<span class="opacitymedium">0</span>') .
'</td>';
1631 print
'<td class="nowraponall amountcard right">' . ($enabled[
'total_localtax1'] ?
price($enabled[
'total_localtax1']) :
'<span class="opacitymedium">0</span>') .
'</td>';
1632 print
'<td class="nowraponall amountcard right">' . ($expired[
'total_localtax1'] ?
price($expired[
'total_localtax1']) :
'<span class="opacitymedium">0</span>') .
'</td>';
1633 print
'<td class="nowraponall amountcard right">' . ($close[
'total_localtax1'] ?
price($close[
'total_localtax1']) :
'<span class="opacitymedium">0</span>') .
'</td>';
1637 if (
$mysoc->localtax2_assuj ==
"1" || $all[
'total_localtax2'] != 0) {
1638 print
'<tr><td class="titlefield">' . $langs->trans(
"TotalLT2") .
'</td>';
1639 print
'<td class="nowraponall amountcard right nowrap">' . ($all[
'total_localtax2'] ?
price($all[
'total_localtax2']) :
'<span class="opacitymedium">0</span>') .
'</td>';
1640 print
'<td class="nowraponall amountcard right">' . ($draft[
'total_localtax2'] ?
price($draft[
'total_localtax2']) :
'<span class="opacitymedium">0</span>') .
'</td>';
1641 print
'<td class="nowraponall amountcard right">' . ($enabled[
'total_localtax2'] ?
price($enabled[
'total_localtax2']) :
'<span class="opacitymedium">0</span>') .
'</td>';
1642 print
'<td class="nowraponall amountcard right">' . ($expired[
'total_localtax2'] ?
price($expired[
'total_localtax2']) :
'<span class="opacitymedium">0</span>') .
'</td>';
1643 print
'<td class="nowraponall amountcard right">' . ($close[
'total_localtax2'] ?
price($close[
'total_localtax2']) :
'<span class="opacitymedium">0</span>') .
'</td>';
1647 print
'<tr><td class="titlefield">'.$langs->trans(
"TotalTTC").
'</td>';
1648 print
'<td class="nowraponall amountcard right nowrap">'.($all[
'total_ttc'] ?
price($all[
'total_ttc']):
'<span class="opacitymedium">0</span>').
'</td>';
1649 print
'<td class="nowraponall amountcard right">'.($draft[
'total_ttc'] ?
price($draft[
'total_ttc']) :
'<span class="opacitymedium">0</span>').
'</td>';
1650 print
'<td class="nowraponall amountcard right">'.($enabled[
'total_ttc'] ?
price($enabled[
'total_ttc']) :
'<span class="opacitymedium">0</span>').
'</td>';
1651 print
'<td class="nowraponall amountcard right">'.($expired[
'total_ttc'] ?
price($expired[
'total_ttc']) :
'<span class="opacitymedium">0</span>').
'</td>';
1652 print
'<td class="nowraponall amountcard right">'.($close[
'total_ttc'] ?
price($close[
'total_ttc']) :
'<span class="opacitymedium">0</span>').
'</td>';
1662 print
'<div class="clearboth"></div><br>';
1664 if (
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'contrat',
'creer')) {
1671 $blocname =
'contacts';
1672 $title = $langs->trans(
'ContactsAddresses');
1673 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
1677 $blocname =
'notes';
1678 $title = $langs->trans(
'Notes');
1679 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
1683 $arrayothercontracts =
$object->getListOfContracts(
'others');
1691 global $inputalsopricewithtax;
1692 $inputalsopricewithtax = 1;
1694 $productstatic =
new Product($db);
1697 if (
isModEnabled(
'margin') && !empty(
$object->element) && in_array(
$object->element, array(
'facture',
'propal',
'commande'))) {
1701 $parameters = array(
'nbOfLines' => &$nbofservices);
1702 $reshook = $hookmanager->executeHooks(
'printObjectLinesBlock', $parameters, $object, $action);
1703 if (empty($reshook)) {
1707 print
'<div id="contrat-lines-container" id="contractlines" data-contractid="'.$object->id.
'" data-element="'.
$object->element.
'" >';
1708 while ($cursorline <= $nbofservices) {
1709 print
'<div id="contrat-line-container'.$object->lines[$cursorline - 1]->id.
'" data-contratlineid = "'.
$object->lines[$cursorline - 1]->id.
'" data-element="'.
$object->lines[$cursorline - 1]->element.
'" >';
1710 print
'<form name="update" id="addproduct" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'" method="post">';
1711 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1712 print
'<input type="hidden" name="action" value="updateline">';
1713 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1714 print
'<input type="hidden" name="elrowid" value="'.$object->lines[$cursorline - 1]->id.
'">';
1715 print
'<input type="hidden" name="fournprice" value="'.(!empty(
$object->lines[$cursorline - 1]->fk_fournprice) ?
$object->lines[$cursorline - 1]->fk_fournprice : 0).
'">';
1718 print
'<div class="div-table-responsive-no-min">';
1719 print
'<table class="notopnoleftnoright allwidth tableforservicepart1 centpercent">';
1721 $sql =
"SELECT cd.rowid, cd.statut, cd.label as label_det, cd.fk_product, cd.product_type, cd.description, cd.qty,";
1722 $sql .=
" cd.tva_tx, cd.vat_src_code, cd.remise_percent, cd.info_bits, cd.subprice, cd.multicurrency_subprice,";
1723 $sql .=
" cd.date_ouverture_prevue as date_start, cd.date_ouverture as date_start_real,";
1724 $sql .=
" cd.date_fin_validite as date_end, cd.date_cloture as date_end_real,";
1725 $sql .=
" cd.commentaire as comment, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht,";
1726 $sql .=
" cd.fk_unit,";
1727 $sql .=
" p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity, p.tosell, p.tobuy, p.tobatch";
1728 $sql .=
" ,cd.rang";
1729 $sql .=
" FROM ".MAIN_DB_PREFIX.
"contratdet as cd";
1730 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
1731 $sql .=
" WHERE cd.rowid = ".((int)
$object->lines[$cursorline - 1]->id);
1733 $result = $db->query($sql);
1738 $objp = $db->fetch_object($result);
1741 print
'<tr class="liste_titre'.($cursorline ?
' liste_titre_add' :
'').
'">';
1742 print
'<td>'.$langs->trans(
"ServiceNb", $cursorline).
'</td>';
1743 print
'<td width="80" class="center">'.$langs->trans(
"VAT").
'</td>';
1744 print
'<td width="80" class="right">'.$langs->trans(
"PriceUHT").
'</td>';
1746 print
'<td width="80" class="right">'.$langs->trans(
"PriceUHT").
' <span class="opacitymedium">('.$langs->getCurrencySymbol(
$object->multicurrency_code).
')</span></td>';
1748 print
'<td width="30" class="center">'.$langs->trans(
"Qty").
'</td>';
1750 print
'<td width="30" class="left">'.$langs->trans(
"Unit").
'</td>';
1752 print
'<td width="50" class="right">'.$langs->trans(
"ReductionShort").
'</td>';
1754 print
'<td width="50" class="right">'.$langs->trans(
"BuyingPrice").
'</td>';
1758 if ($nbofservices > 1 &&
$conf->browser->layout !=
'phone' && $user->hasRight(
'contrat',
'creer')) {
1759 print
'<td width="30" class="linecolmove tdlineupdown center">';
1760 if ($cursorline > 1) {
1761 print
'<a class="lineupdown reposition paddingrightonly paddingleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=up&token='.
newToken().
'&rowid='.$objp->rowid.
'">';
1762 echo
img_up(
'default', 0,
'imgupforline');
1765 if ($cursorline < $nbofservices) {
1766 print
'<a class="lineupdown reposition paddingrightonly paddingleftonly" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=down&token='.
newToken().
'&rowid='.$objp->rowid.
'">';
1767 echo
img_down(
'default', 0,
'imgdownforline');
1772 print
'<td width="30"> </td>';
1780 if ($action !=
'editline' || $idline != $objp->rowid) {
1782 if (
getDolGlobalString(
'CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT') && $objp->statut == ContratLigne::STATUS_CLOSED && $action !=
'showclosedlines') {
1783 $moreparam =
'style="display: none;"';
1787 $line->id = $objp->rowid;
1791 print
'<tr class="tdtop oddeven" '.$moreparam.
'>';
1794 print
'<td class="linecoldescription minwidth300imp">';
1796 print
'<div id="line_'.$line->rowid.
'"></div>';
1797 if ($objp->fk_product > 0) {
1798 $productstatic->id = $objp->fk_product;
1799 $productstatic->type = $objp->ptype;
1800 $productstatic->ref = $objp->pref;
1801 $productstatic->entity = $objp->pentity;
1802 $productstatic->label = $objp->plabel;
1803 $productstatic->status = $objp->tosell;
1804 $productstatic->status_buy = $objp->tobuy;
1805 $productstatic->status_batch = $objp->tobatch;
1807 $text = $productstatic->getNomUrl(1,
'', 32);
1808 if ($objp->plabel) {
1810 $text .= $objp->plabel;
1812 $description = $objp->description;
1815 print (!empty($line->fk_parent_line) ? img_picto(
'',
'rightarrow.png') :
'') . $text;
1817 print $form->textwithpicto(
'', $description);
1820 print $form->textwithtooltip($text, $description, 3, 0,
'',
'', 0, (!empty($line->fk_parent_line) ? img_picto(
'',
'rightarrow.png') :
''));
1824 if ($line->fk_product > 0 &&
getDolGlobalInt(
'PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE')) {
1825 print (!empty($line->description) && $line->description != $line->plabel) ? (($line->date_start || $line->date_end) ?
'' :
'<br>').
'<br>'.
dol_htmlentitiesbr($line->
description) :
'';
1828 print img_object($langs->trans(
"ShowProductOrService"), ($objp->product_type ?
'service' :
'product')).
' '.
dol_htmlentitiesbr($objp->
description).
"\n";
1833 print
'<td class="center">';
1834 print
vatrate($objp->tva_tx.($objp->vat_src_code ? (
' ('.$objp->vat_src_code.
')') :
''), true, $objp->info_bits);
1837 print
'<td class="right">'.($objp->subprice !=
'' ?
price($objp->subprice) :
'').
"</td>\n";
1840 print
'<td class="linecoluht_currency nowrap right">'.price($objp->multicurrency_subprice).
'</td>';
1843 print
'<td class="center">'.$objp->qty.
'</td>';
1846 print
'<td class="left">'.$object->lines[$cursorline - 1]->getLabelOfUnit(
'long', $langs).
'</td>';
1849 if ($objp->remise_percent > 0) {
1850 print
'<td class="right">'.$objp->remise_percent.
"%</td>\n";
1852 print
'<td> </td>';
1857 print
'<td class="right nowraponall">'.price($objp->pa_ht).
'</td>';
1861 print
'<td class="nowraponall right">';
1862 if ($user->hasRight(
'contrat',
'creer') && is_array($arrayothercontracts) && count($arrayothercontracts) && (
$object->status >= 0)) {
1863 print
'<!-- link to move service line into another contract -->';
1864 print
'<a class="reposition marginrightonly" style="padding-left: 5px;" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=move&token='.
newToken().
'&elrowid='.$objp->rowid.
'">';
1865 print img_picto($langs->trans(
"MoveToAnotherContract"),
'uparrow');
1868 if ($user->hasRight(
'contrat',
'creer') && (
$object->statut >= 0)) {
1869 print
'<a class="reposition marginrightonly editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=editline&token='.
newToken().
'&elrowid='.$objp->rowid.
'">';
1873 if ($user->hasRight(
'contrat',
'creer') && (
$object->statut >= 0)) {
1874 print
'<a class="reposition marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=deleteline&token='.
newToken().
'&elrowid='.$objp->rowid.
'">';
1891 if ($objp->subprice >= 0) {
1892 print
'<tr class="oddeven" '.$moreparam.
'>';
1893 print
'<td colspan="'.$colspan.
'">';
1896 print $langs->trans(
"DateStartPlanned").
': ';
1897 if ($objp->date_start) {
1900 if ($objp->statut == 0 && $db->jdate($objp->date_start) < ($now -
$conf->contrat->services->inactifs->warning_delay)) {
1901 $warning_delay =
$conf->contrat->services->inactifs->warning_delay / 3600 / 24;
1902 $textlate = $langs->trans(
"Late").
' = '.$langs->trans(
"DateReference").
' > '.$langs->trans(
"DateToday").
' '.(ceil($warning_delay) >= 0 ?
'+' :
'').ceil($warning_delay).
' '.$langs->trans(
"days");
1903 print
" ".img_warning($textlate);
1906 print $langs->trans(
"Unknown");
1908 print
' - ';
1909 print $langs->trans(
"DateEndPlanned").
': ';
1910 if ($objp->date_end) {
1912 if ($objp->statut == 4 && $db->jdate($objp->date_end) < ($now -
$conf->contrat->services->expires->warning_delay)) {
1913 $warning_delay =
$conf->contrat->services->expires->warning_delay / 3600 / 24;
1914 $textlate = $langs->trans(
"Late").
' = '.$langs->trans(
"DateReference").
' > '.$langs->trans(
"DateToday").
' '.(ceil($warning_delay) >= 0 ?
'+' :
'').ceil($warning_delay).
' '.$langs->trans(
"days");
1915 print
" ".img_warning($textlate);
1918 print $langs->trans(
"Unknown");
1925 $parameters = [
'line' =>
$object->lines[$cursorline - 1],
'i' => $cursorline - 1,
'coldisplay' => &$coldisplay,
'colspan' => $colspan,
'moreparam' => $moreparam];
1926 $reshook = $hookmanager->executeHooks(
'objectLineView_BeforeProductExtrafield', $parameters, $object, $action);
1927 print $hookmanager->resPrint;
1930 if (empty($reshook) && is_array($extralabelslines) && count($extralabelslines) > 0) {
1932 $line->id = $objp->rowid;
1933 $line->fetch_optionals();
1934 print $line->showOptionals($extrafields,
'view', array(
'class' =>
'oddeven',
'style' => $moreparam,
'colspan' => $colspan,
'tdclass' =>
'notitlefieldcreate'),
'',
'',
'1');
1939 print
'<tr class="oddeven">';
1941 $currentLineProductId =
GETPOSTISSET(
'idprod') ?
GETPOST(
'idprod') : (!empty(
$object->lines[$cursorline - 1]->fk_product) ?
$object->lines[$cursorline - 1]->fk_product : 0);
1942 if ($objp->fk_product > 0) {
1943 $canchangeproduct = 1;
1946 if (empty($canchangeproduct)) {
1947 $productstatic->id = $objp->fk_product;
1948 $productstatic->type = $objp->ptype;
1949 $productstatic->ref = $objp->pref;
1950 $productstatic->entity = $objp->pentity;
1951 print $productstatic->getNomUrl(1,
'', 32);
1952 print $objp->label ?
' - '.dol_trunc($objp->label, 32) :
'';
1953 print
'<input type="hidden" name="idprod" value="'.$currentLineProductId.
'">';
1955 $senderissupplier = 0;
1956 if (empty($senderissupplier)) {
1962 print $form->select_produits($currentLineProductId,
'idprod', $filtertype, 0, 0, 1, 2,
'', 0, array(), 0, 1, 0,
'minwidth250onall maxwidth500 widthcentpercentminusx');
1964 $form->select_produits_fournisseurs($currentLineProductId,
'idprod');
1969 print $objp->label ? $objp->label.
'<br>' :
'';
1970 print
'<input type="hidden" name="idprod" value="'.$currentLineProductId.
'">';
1974 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1979 $doleditor =
new DolEditor(
'product_desc', (
GETPOSTISSET(
'product_desc') ?
GETPOST(
'product_desc') : $objp->
description),
'', 92,
'dolibarr_details',
'', false, true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), $nbrows,
'90%');
1980 $doleditor->Create();
1985 print
'<td class="right">';
1986 print $form->load_tva(
"eltva_tx", $objp->tva_tx.($objp->vat_src_code ? (
' ('.$objp->vat_src_code.
')') :
''),
$mysoc,
$object->thirdparty, $currentLineProductId, $objp->info_bits, $objp->product_type, false, 1);
1990 print
'<td class="right"><input class="width50" type="text" name="elprice" value="'.(GETPOSTISSET(
'elprice') ?
GETPOST(
'elprice') :
price($objp->subprice)).
'"></td>';
1994 print
'<td class="linecoluht_currency nowrap right">'.price($objp->multicurrency_subprice).
'</td>';
1998 print
'<td class="center"><input size="2" type="text" name="elqty" value="'.(GETPOSTISSET(
'elqty') ?
GETPOST(
'elqty') : $objp->qty).
'"></td>';
2002 print
'<td class="left">';
2008 print
'<td class="nowraponall right"><input size="1" type="text" name="elremise_percent" value="'.(GETPOSTISSET(
'elremise_percent') ?
GETPOST(
'elremise_percent') : $objp->remise_percent).
'">%</td>';
2010 if (!empty($usemargins)) {
2011 print
'<td class="right">';
2012 if ($objp->fk_product) {
2013 print
'<select id="fournprice" name="fournprice"></select>';
2015 print
'<input id="buying_price" type="text" class="width50" name="buying_price" value="'.price((
GETPOSTISSET(
'buying_price') ?
GETPOST(
'buying_price') : $objp->pa_ht), 0,
'', 0).
'"></td>';
2017 print
'<td class="center">';
2018 print
'<input type="submit" class="button margintoponly marginbottomonly" name="save" value="'.$langs->trans(
"Modify").
'">';
2019 print
'<br><input type="submit" class="button margintoponly marginbottomonly button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2032 print
'<tr class="oddeven">';
2033 print
'<td colspan="'.$colspan.
'">';
2034 print $langs->trans(
"DateStartPlanned").
' ';
2035 print $form->selectDate($db->jdate($objp->date_start),
"date_start_update", $usehm, $usehm, ($db->jdate($objp->date_start) > 0 ? 0 : 1),
"update");
2036 print
' '.$langs->trans(
"DateEndPlanned").
' ';
2037 print $form->selectDate($db->jdate($objp->date_end),
"date_end_update", $usehm, $usehm, ($db->jdate($objp->date_end) > 0 ? 0 : 1),
"update");
2041 if (is_array($extralabelslines) && count($extralabelslines) > 0) {
2043 $line->id = $objp->rowid;
2044 $line->fetch_optionals();
2046 print $line->showOptionals($extrafields,
'edit', array(
'style' =>
'class="oddeven"',
'colspan' => $colspan,
'tdclass' =>
'notitlefieldcreate'),
'',
'',
'1');
2052 dol_print_error($db);
2057 if (
getDolGlobalString(
'CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT') &&
$object->lines[$cursorline - 1]->statut == ContratLigne::STATUS_CLOSED && $action !=
'showclosedlines') {
2058 $moreparam =
'style="display: none;"';
2069 print
'<tr class="oddeven" '.$moreparam.
'>';
2070 print
'<td class="tdhrthin" colspan="'.$colspan.
'"><hr class="opacitymedium tdhrthin"></td>';
2083 if ($action ==
'deleteline' && !$cancel && $user->hasRight(
'contrat',
'creer') &&
$object->lines[$cursorline - 1]->id == $idline) {
2084 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".((
int)
$object->id).
"&lineid=".((
int) $idline), $langs->trans(
"DeleteContractLine"), $langs->trans(
"ConfirmDeleteContractLine"),
"confirm_deleteline",
'', 0, 1);
2085 if ($ret ==
'html') {
2086 print
'<table class="notopnoleftnoright centpercent"><tr class="oddeven" height="6"><td></td></tr></table>';
2093 if ($action ==
'move' && !$cancel && $user->hasRight(
'contrat',
'creer') &&
$object->lines[$cursorline - 1]->id == $idline) {
2094 $arraycontractid = array();
2095 foreach ($arrayothercontracts as $contractcursor) {
2096 $arraycontractid[$contractcursor->id] = $contractcursor->ref;
2100 $formquestion = array(
2101 'text' => $langs->trans(
"ConfirmMoveToAnotherContractQuestion"),
2102 0 => array(
'type' =>
'select',
'name' =>
'newcid',
'values' => $arraycontractid));
2104 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".((
int)
$object->id).
"&lineid=".((
int) $idline), $langs->trans(
"MoveToAnotherContract"), $langs->trans(
"ConfirmMoveToAnotherContract"),
"confirm_move", $formquestion,
'yes');
2105 print
'<table class="notopnoleftnoright centpercent"><tr class="oddeven" height="6"><td></td></tr></table>';
2110 print
'<table class="notopnoleftnoright tableforservicepart2'.($cursorline < $nbofservices ?
' boxtablenobottom' :
'').
' centpercent">';
2112 print
'<tr class="oddeven" '.$moreparam.
'>';
2113 print
'<td><span class="valignmiddle hideonsmartphone">'.$langs->trans(
"ServiceStatus").
':</span> '.
$object->lines[$cursorline - 1]->getLibStatut(4).
'</td>';
2114 print
'<td width="30" class="right">';
2115 if ($user->socid == 0) {
2116 if (
$object->status > 0 && $action !=
'activateline' && $action !=
'unactivateline' && is_object($objp)) {
2117 $tmpaction =
'activateline';
2118 $tmpactionpicto =
'play';
2119 $tmpactiontext = $langs->trans(
"Activate");
2120 if ($objp->statut == 4) {
2121 $tmpaction =
'unactivateline';
2122 $tmpactionpicto =
'playstop.png';
2123 $tmpactiontext = $langs->trans(
"Disable");
2125 if (($tmpaction ==
'activateline' && $user->hasRight(
'contrat',
'activer')) || ($tmpaction ==
'unactivateline' && $user->hasRight(
'contrat',
'desactiver'))) {
2126 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&ligne='.
$object->lines[$cursorline - 1]->id.
'&action='.$tmpaction.
'&token='.
newToken().
'">';
2127 print img_picto($tmpactiontext, $tmpactionpicto);
2135 print
'<tr class="oddeven" '.$moreparam.
'>';
2139 if (!$objp->date_start_real) {
2140 print $langs->trans(
"DateStartReal").
': ';
2141 if ($objp->date_start_real) {
2144 print $langs->trans(
"ContractStatusNotRunning");
2148 if ($objp->date_start_real && !$objp->date_end_real) {
2149 print $langs->trans(
"DateStartReal").
': ';
2153 if ($objp->date_start_real && $objp->date_end_real) {
2154 print $langs->trans(
"DateStartReal").
': ';
2156 print
' - ';
2157 print $langs->trans(
"DateEndReal").
': ';
2160 if (!empty($objp->comment)) {
2161 print
" - ".$objp->comment;
2165 print
'<td class="center"> </td>';
2172 if ($permissiontoactivate && $action ==
'activateline' &&
$object->lines[$cursorline - 1]->id ==
GETPOSTINT(
'ligne') && is_object($objp)) {
2173 print
'<form name="active" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2174 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2175 print
'<input type="hidden" name="action" value="confirm_active">';
2176 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2177 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2178 print
'<input type="hidden" name="ligne" value="'.GETPOSTINT(
'ligne').
'">';
2179 print
'<input type="hidden" name="confirm" value="yes">';
2181 print
'<table class="noborder tableforservicepart2'.($cursorline < $nbofservices ?
' boxtablenobottom' :
'').
' centpercent">';
2184 $dateactstart = $objp->date_start;
2187 } elseif (!$dateactstart) {
2191 $dateactend = $objp->date_end;
2194 } elseif (!$dateactend) {
2195 if ($objp->fk_product > 0) {
2197 $product->fetch($objp->fk_product);
2198 if (!empty($product->duration_value) && !empty($product->duration_unit)) {
2204 print
'<tr class="oddeven">';
2205 print
'<td class="nohover">'.$langs->trans(
"DateServiceActivate").
'</td><td class="nohover">';
2206 print $form->selectDate($dateactstart,
'start', $usehm, $usehm, 0,
"active", 1, 0);
2208 print
'<td class="nohover">'.$langs->trans(
"DateEndPlanned").
'</td><td class="nohover">';
2209 print $form->selectDate($dateactend,
"end", $usehm, $usehm, 0,
"active", 1, 0);
2211 print
'<td class="center nohover">';
2216 print
'<tr class="oddeven">';
2217 print
'<td class="nohover">'.$langs->trans(
"Comment").
'</td><td colspan="3" class="nohover" colspan="'.(
isModEnabled(
'margin') ? 4 : 3).
'"><input type="text" class="minwidth300" name="comment" value="'.
dol_escape_htmltag(
GETPOST(
"comment",
'alphanohtml')).
'"></td>';
2218 print
'<td class="nohover right">';
2219 print
'<input type="submit" class="button" name="activate" value="'.$langs->trans(
"Activate").
'"> ';
2220 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2230 if ($permissiontodisable && $action ==
'unactivateline' &&
$object->lines[$cursorline - 1]->id ==
GETPOSTINT(
'ligne') && is_object($objp)) {
2231 print
'<!-- Form to disabled a line -->'.
"\n";
2232 print
'<form name="confirm_closeline" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&ligne='.
$object->lines[$cursorline - 1]->id.
'" method="post">';
2233 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2234 print
'<input type="hidden" name="confirm" value="yes">';
2235 print
'<input type="hidden" name="action" value="confirm_closeline">';
2236 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2238 print
'<table class="noborder tableforservicepart2'.($cursorline < $nbofservices ?
' boxtablenobottom' :
'').
' centpercent">';
2241 $dateactstart = $objp->date_start_real;
2244 } elseif (!$dateactstart) {
2248 $dateactend = $objp->date_end_real;
2251 } elseif (!$dateactend) {
2252 if ($objp->fk_product > 0) {
2254 $product->fetch($objp->fk_product);
2259 if ($dateactend > $now) {
2263 print
'<tr class="oddeven"><td colspan="2" class="nohover">';
2264 if ($objp->statut >= 4) {
2265 if ($objp->statut == 4) {
2266 print $langs->trans(
"DateEndReal").
' ';
2267 print $form->selectDate($dateactend,
"end", $usehm, $usehm, ($objp->date_end_real > 0 ? 0 : 1),
"closeline", 1, 1);
2271 print
'<td class="center nohover">';
2274 print
'<tr class="oddeven">';
2275 print
'<td class="nohover">'.$langs->trans(
"Comment").
'</td><td class="nohover"><input class="quatrevingtpercent" type="text" class="flat" name="comment" value="'.
dol_escape_htmltag(
GETPOST(
'comment',
'alpha')).
'"></td>';
2276 print
'<td class="nohover right">';
2277 print
'<input type="submit" class="button" name="close" value="'.$langs->trans(
"Disable").
'"> ';
2278 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2293 if ($user->hasRight(
'contrat',
'creer') && (
$object->status == 0)) {
2297 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
2298 <input type="hidden" name="token" value="'.
newToken().
'">
2299 <input type="hidden" name="action" value="'.(($action !=
'editline') ?
'addline' :
'updateline').
'">
2300 <input type="hidden" name="mode" value="">
2301 <input type="hidden" name="id" value="'.
$object->id.
'">
2302 <input type="hidden" name="page_y" value="">
2303 <input type="hidden" name="backtopage" value="'.$backtopage.
'">
2306 print
'<div class="div-table-responsive-no-min">';
2307 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
2310 if ($action !=
'editline') {
2311 $forcetoshowtitlelines = 1;
2312 if (empty(
$object->multicurrency_code)) {
2319 $parameters = array();
2320 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
2322 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
2324 if (empty($reshook)) {
2337 if (
GETPOST(
'modelselected')) {
2338 $action =
'presend';
2344 if ($user->socid == 0 && $action !=
'presend' && $action !=
'editline') {
2345 print
'<div class="tabsAction">';
2347 $parameters = array();
2348 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2350 if (empty($reshook)) {
2354 'class' =>
'classfortooltip'
2359 if (empty($user->socid)) {
2360 if (
$object->status == $object::STATUS_VALIDATED) {
2361 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'contrat',
'creer'))) {
2362 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.
newToken().
'&mode=init#formmailbeforetitle',
'',
true, $params);
2364 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
'#',
'',
false, $params);
2369 if (
$object->status == $object::STATUS_DRAFT && $nbofservices) {
2370 if ($user->hasRight(
'contrat',
'creer')) {
2371 unset($params[
'attr'][
'title']);
2372 print dolGetButtonAction($langs->trans(
'Validate'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=valid&token='.
newToken(),
'',
true, $params);
2374 $params[
'attr'][
'title'] = $langs->trans(
"NotEnoughPermissions");
2375 print dolGetButtonAction($langs->trans(
'Validate'),
'',
'default',
'#',
'',
false, $params);
2378 if (
$object->status == $object::STATUS_VALIDATED) {
2379 if ($user->hasRight(
'contrat',
'creer')) {
2380 unset($params[
'attr'][
'title']);
2381 print dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=reopen&token='.
newToken(),
'',
true, $params);
2383 $params[
'attr'][
'title'] = $langs->trans(
"NotEnoughPermissions");
2384 print dolGetButtonAction($langs->trans(
'Modify'),
'',
'default',
'#',
'',
false, $params);
2389 $arrayofcreatebutton = array();
2391 $arrayofcreatebutton[] = array(
2392 'url' =>
'/comm/propal/card.php?action=create&origin='.
$object->element.
'&originid='.
$object->id.
'&socid='.
$object->thirdparty->id.
'&renewal=true',
2393 'label' => $langs->trans(
'AddProp'),
2395 'perm' => $user->hasRight(
'propale',
'creer') ?
true : false,
2401 $arrayofcreatebutton[] = array(
2402 'url' =>
'/commande/card.php?action=create&token='.
newToken().
'&origin='.
$object->element.
'&originid='.
$object->id.
'&socid='.
$object->thirdparty->id,
2403 'label' => $langs->trans(
'AddOrder'),
2405 'perm' => $user->hasRight(
'commande',
'creer') ?
true : false,
2410 $arrayofcreatebutton[] = array(
2411 'url' =>
'/compta/facture/card.php?action=create&origin='.
$object->element.
'&originid='.
$object->id.
'&socid='.
$object->thirdparty->id,
2412 'label' => $langs->trans(
'CreateBill'),
2414 'perm' => $user->hasRight(
'facture',
'creer') ?
true : false,
2419 $langs->load(
"suppliers");
2420 $arrayofcreatebutton[] = array(
2421 'url' =>
'/fourn/facture/card.php?action=create&origin='.
$object->element.
'&originid='.
$object->id.
'&socid='.
$object->thirdparty->id,
2422 'label' => $langs->trans(
'AddSupplierInvoice'),
2424 'perm' => $user->hasRight(
'fournisseur',
'facture',
'creer') ?
true : false,
2429 $langs->load(
"interventions");
2430 $arrayofcreatebutton[] = array(
2431 'url' =>
'/fichinter/card.php?action=create&origin='.
$object->element.
'&originid='.
$object->id.
'&socid='.
$object->thirdparty->id,
2432 'label' => $langs->trans(
'AddIntervention'),
2433 'lang' =>
'interventions',
2434 'perm' => $user->hasRight(
'ficheinter',
'creer') ?
true : false,
2438 if (count($arrayofcreatebutton)) {
2439 unset($params[
'attr'][
'title']);
2440 print dolGetButtonAction(
'', $langs->trans(
"Create"),
'default', $arrayofcreatebutton,
'',
true, $params);
2443 $arrayforbutaction = array();
2444 $arrayforbutaction[] = array(
2445 'url' =>
'/contrat/card.php?id='.
$object->id.
'&action=activate&token='.
newToken(),
2446 'label' => $langs->trans(
'ActivateAllContracts'),
2448 'perm' => (
$object->nbofservicesclosed > 0 ||
$object->nbofserviceswait > 0) ? $permissiontoactivate : -1,
2451 $arrayforbutaction[] = array(
2452 'url' =>
'/contrat/card.php?id='.
$object->id.
'&action=close&token='.
newToken(),
2453 'label' => $langs->trans(
'CloseAllContracts'),
2455 'perm' => (
$object->nbofservicesclosed < $nbofservices) ? $permissiontodisable : -1,
2459 if (count($arrayforbutaction)) {
2460 unset($params[
'attr'][
'title']);
2461 print dolGetButtonAction(
'', $langs->trans(
"Enable").
" / ".$langs->trans(
"Close"),
'default', $arrayforbutaction,
'',
true, $params);
2465 if ($action ==
'showclosedlines') {
2466 print
'<div class="inline-block divButAction"><a class="butAction" id="btnhideclosedlines" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=hideclosedlines&token='.
newToken().
'">'.$langs->trans(
"HideClosedServices").
'</a></div>';
2468 print
'<div class="inline-block divButAction"><a class="butAction" id="btnshowclosedlines" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=showclosedlines&token='.
newToken().
'">'.$langs->trans(
"ShowClosedServices").
'</a></div>';
2473 if (
getDolGlobalString(
'CONTRACT_SHOW_SIGNATURE_STATUS_WITH_SERVICE_STATUS') &&
$object->status > Contrat::STATUS_DRAFT) {
2474 if (
$object->signed_status != Contrat::$SIGNED_STATUSES[
'STATUS_SIGNED_ALL']) {
2475 print
'<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=sign&token=' .
newToken() .
'">' . $langs->trans(
"ContractSign") .
'</a></div>';
2477 print
'<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=unsign&token=' .
newToken() .
'">' . $langs->trans(
"ContractUnsign") .
'</a></div>';
2482 if ($user->hasRight(
'contrat',
'creer')) {
2483 unset($params[
'attr'][
'title']);
2484 print dolGetButtonAction($langs->trans(
'ToClone'), $langs->trans(
'ToClone'),
'clone', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&socid='.
$object->socid.
'&action=clone&token='.
newToken(),
'',
true, array(
'attr' => array(
'class' =>
'reposition')));
2488 unset($params[
'attr'][
'title']);
2489 print dolGetButtonAction($langs->trans(
'Delete'), $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'', $permissiontodelete, array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
2495 if ($action !=
'presend') {
2496 print
'<div class="fichecenter"><div class="fichehalfleft">';
2503 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
2504 $genallowed = $user->hasRight(
'contrat',
'lire');
2505 $delallowed = $user->hasRight(
'contrat',
'creer');
2506 $tooltipAfterComboOfModels =
'';
2508 $tooltipAfterComboOfModels = $langs->trans(
"AccordingToYourSetupTheFileWillBeConcatenated",
getDolGlobalString(
'MAIN_INFO_CONTRACT_TERMSOFSALE'));
2511 print $formfile->showdocuments(
'contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, (
$object->model_pdf ?
$object->model_pdf :
getDolGlobalString(
'CONTRACT_ADDON_PDF')), 1, 0, 0, 28, 0,
'',
'0',
'', $soc->default_lang,
'',
$object, 0,
'remove_file', $tooltipAfterComboOfModels);
2515 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'contrat'), 1);
2516 $linktoelem = $tmparray[
'linktoelem'];
2517 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
2518 print $htmltoenteralink;
2520 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
2524 print
'<br><!-- Link to sign -->';
2525 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
2527 print showOnlineSignatureUrl(
'contract',
$object->ref, $object).
'<br>';
2530 print
'</div><div class="fichehalfright">';
2534 $morehtmlcenter =
'<div class="nowraponall">';
2535 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT.
'/contrat/messaging.php?id='.
$object->id);
2536 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/contrat/agenda.php?id='.
$object->id);
2537 $morehtmlcenter .=
'</div>';
2541 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2543 $somethingshown = $formactions->showactions($object,
'contract', $socid, 1,
'listactions', $MAXEVENT,
'', $morehtmlcenter);
2545 print
'</div></div>';
2549 $modelmail =
'contract';
2550 $defaulttopic =
'SendContractRef';
2551 $diroutput =
$conf->contract->multidir_output[
$object->entity ??
$conf->entity];
2552 $trackid =
'con'.$object->id;
2554 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
2566 print
"\n".
'<script type="text/javascript">'.
"\n";
2568 $(document).ready(
function() {
2569 var idprod = $(
"input[name='idprod']").val();
2570 var fournprice = $(
"input[name='fournprice']").val();
2571 var token =
'<?php echo currentToken(); ?>';
2573 $.post(
'<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {
2577 if (data.length > 0) {
2580 $(data).each(
function() {
2581 options +=
'<option value="'+this.
id+
'" price="'+this.price+
'"';
2582 if (fournprice > 0) {
2583 if (this.
id == fournprice) {
2584 options +=
' selected';
2585 $(
"#buying_price").val(pricejs(this.price,
'MU'));
2589 options +=
'>'+this.label+
'</option>';
2591 options +=
'<option value=null'+(trouve?
'':
' selected')+
'><?php echo $langs->trans("InputPrice"); ?></option>';
2592 $(
"#fournprice").html(options);
2594 $(
"#buying_price").hide();
2595 $(
"#fournprice").show();
2598 $(
"#buying_price").show();
2600 $(
"#fournprice").change(
function() {
2601 var selval = $(
this).find(
'option:selected').attr(
"price");
2603 $(
"#buying_price").val(pricejs(selval,
'MU')).hide();
2605 $(
'#buying_price').show();
2609 $(
"#fournprice").hide();
2610 $(
'#buying_price').show();
2616 $(
"#fournprice").hide();
2617 $(
'#buying_price').show();
2621 print
'</script>'.
"\n";
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage lines of contracts.
Class to manage a WYSIWYG editor.
Class to manage the table of subscription to notifications.
File of class to manage predefined price products or services by customer.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
Class to manage Dolibarr users.
if(! $sortfield) if(! $sortorder) $module
contract_prepare_head(Contrat $object)
Prepare array with list of tabs.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0, $tz='')
Add a delay to a date.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_move_dir($srcdir, $destdir, $overwriteifexists=1, $indexdatabase=1, $renamedircontent=1)
Move a directory into another name.
$date_start
Variables from include:
dol_now($mode='gmt')
Return date for now.
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
price2num($amount, $rounding='', $option=0, $currencycode='')
Function that return a number with universal decimal format (decimal separator is '.
dol_strlen($string, $stringencoding='UTF-8', $binarycount=0)
Make a strlen call.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
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...
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular VAT rate, when selling a product with vat $vatrate,...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.