37require
"../main.inc.php";
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/contract.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/modules/contract/modules_contract.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
48if (isModEnabled(
"propal")) {
49 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
51if (isModEnabled(
'project')) {
52 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
53 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
58$langs->loadLangs(array(
"contracts",
"orders",
"companies",
"bills",
"products",
'compta'));
60$action =
GETPOST(
'action',
'aZ09');
61$confirm =
GETPOST(
'confirm',
'alpha');
62$cancel =
GETPOST(
'cancel',
'alpha');
63$backtopage =
GETPOST(
'backtopage',
'alpha');
68$origin =
GETPOST(
'origin',
'alpha');
78$usehm = (
getDolGlobalString(
'MAIN_USE_HOURMIN_IN_DATE_RANGE') ? $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE : 0);
82 $socid = $user->socid;
86$hookmanager->initHooks(array(
'contractcard',
'globalcard'));
92if ($id > 0 || !empty($ref) && $action !=
'add') {
93 $ret =
$object->fetch($id, $ref);
95 $ret =
$object->fetch_thirdparty();
103$extrafields->fetch_name_optionals_label(
$object->table_element);
106$extralabelslines = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
108$permissionnote = $user->hasRight(
'contrat',
'creer');
109$permissiondellink = $user->hasRight(
'contrat',
'creer');
110$permissiontodelete = ($user->hasRight(
'contrat',
'creer') &&
$object->statut == $object::STATUS_DRAFT) || $user->hasRight(
'contrat',
'supprimer');
111$permissiontoadd = $user->hasRight(
'contrat',
'creer');
112$permissiontoedit = $permissiontoadd;
113$permissiontoactivate = $user->hasRight(
'contrat',
'activer');
123$parameters = array(
'socid' => $socid);
124$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
128if (empty($reshook)) {
129 $backurlforlist = DOL_URL_ROOT.
'/contrat/list.php';
131 if (empty($backtopage) || ($cancel && empty($id))) {
132 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
133 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
134 $backtopage = $backurlforlist;
136 $backtopage = DOL_URL_ROOT.
'/contrat/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
142 if (!empty($backtopageforcancel)) {
143 header(
"Location: ".$backtopageforcancel);
145 } elseif (!empty($backtopage)) {
146 header(
"Location: ".$backtopage);
152 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
154 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
156 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
158 if ($action ==
'confirm_active' && $confirm ==
'yes' && $permissiontoactivate) {
171 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
176 } elseif ($action ==
'confirm_closeline' && $confirm ==
'yes' && $permissiontoactivate) {
183 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
188 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
196 if (
GETPOST(
'mode') ==
'predefined') {
208 $date_start_update =
'';
209 $date_end_update =
'';
210 $date_start_real_update =
'';
211 $date_end_real_update =
'';
212 if (
GETPOST(
'date_start_updatemonth') &&
GETPOST(
'date_start_updateday') &&
GETPOST(
'date_start_updateyear')) {
215 if (
GETPOST(
'date_end_updatemonth') &&
GETPOST(
'date_end_updateday') &&
GETPOST(
'date_end_updateyear')) {
218 if (
GETPOST(
'date_start_real_updatemonth') &&
GETPOST(
'date_start_real_updateday') &&
GETPOST(
'date_start_real_updateyear')) {
219 $date_start_real_update =
dol_mktime(
GETPOST(
'date_start_real_updatehour'),
GETPOST(
'date_start_real_updatemin'), 0,
GETPOST(
'date_start_real_updatemonth'),
GETPOST(
'date_start_real_updateday'),
GETPOST(
'date_start_real_updateyear'));
221 if (
GETPOST(
'date_end_real_updatemonth') &&
GETPOST(
'date_end_real_updateday') &&
GETPOST(
'date_end_real_updateyear')) {
222 $date_end_real_update =
dol_mktime(
GETPOST(
'date_end_real_updatehour'),
GETPOST(
'date_end_real_updatemin'), 0,
GETPOST(
'date_end_real_updatemonth'),
GETPOST(
'date_end_real_updateday'),
GETPOST(
'date_end_real_updateyear'));
229 if ($action ==
'add' && $user->hasRight(
'contrat',
'creer')) {
231 if (empty($datecontrat)) {
233 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
238 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdParty")),
null,
'errors');
244 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
252 $object->date_contrat = $datecontrat;
266 if (!empty($origin) && !empty($originid)) {
268 $element = $subelement = $origin;
269 if (preg_match(
'/^([^_]+)_([^_]+)/i', $origin, $regs)) {
271 $subelement = $regs[2];
275 if ($element ==
'order') {
276 $element = $subelement =
'commande';
278 if ($element ==
'propal') {
279 $element =
'comm/propal';
280 $subelement =
'propal';
282 if ($element ==
'invoice' || $element ==
'facture') {
283 $element =
'compta/facture';
284 $subelement =
'facture';
288 $object->origin_id = $originid;
293 $object->linked_objects = array_merge(
$object->linked_objects,
GETPOST(
'other_linked_objects',
'array:int'));
300 $classname = ucfirst($subelement);
301 $srcobject =
new $classname($db);
304 $result = $srcobject->fetch(
$object->origin_id);
306 $srcobject->fetch_thirdparty();
307 $lines = $srcobject->lines;
308 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
309 $srcobject->fetch_lines();
310 $lines = $srcobject->lines;
314 $num = count($lines);
316 for ($i = 0; $i < $num; $i++) {
317 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
319 if ($product_type == 1 || (
getDolGlobalString(
'CONTRACT_SUPPORT_PRODUCTS') && in_array($product_type, array(0, 1)))) {
321 if ($lines[$i]->fk_product > 0) {
322 $product_static =
new Product($db);
327 $prod->id = $lines[$i]->fk_product;
328 $prod->getMultiLangs();
330 $outputlangs = $langs;
332 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
333 $newlang =
GETPOST(
'lang_id',
'aZ09');
335 if (empty($newlang)) {
336 $newlang = $srcobject->thirdparty->default_lang;
338 if (!empty($newlang)) {
340 $outputlangs->setDefaultLang($newlang);
343 $label = (!empty($prod->multilangs[$outputlangs->defaultlang][
"libelle"])) ? $prod->multilangs[$outputlangs->defaultlang][
"libelle"] : $lines[$i]->product_label;
345 $label = $lines[$i]->product_label;
347 $desc = ($lines[$i]->desc && $lines[$i]->desc != $lines[$i]->label) ?
dol_htmlentitiesbr($lines[$i]->desc) :
'';
353 $array_options = array();
355 if (method_exists($lines[$i],
'fetch_optionals')) {
356 $lines[$i]->fetch_optionals();
357 $array_options = $lines[$i]->array_options;
360 $txtva = $lines[$i]->vat_src_code ? $lines[$i]->tva_tx.
' ('.$lines[$i]->vat_src_code.
')' : $lines[$i]->tva_tx;
368 $lines[$i]->subprice,
373 $lines[$i]->fk_product,
374 $lines[$i]->remise_percent,
375 $lines[$i]->date_start,
376 $lines[$i]->date_end,
379 $lines[$i]->info_bits,
380 $lines[$i]->fk_fournprice,
399 $parameters = array(
'objFrom' => $srcobject);
400 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters,
$object, $action);
414 $result =
$object->create($user);
416 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
424 } elseif ($action ==
'classin' && $user->hasRight(
'contrat',
'creer')) {
426 } elseif ($action ==
'addline' && $user->hasRight(
'contrat',
'creer')) {
430 $product_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
433 $price_ht_devise =
'';
435 $price_ttc_devise =
'';
437 $rang = count(
$object->lines) + 1;
439 if (
GETPOST(
'price_ht') !==
'') {
442 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
445 if (
GETPOST(
'price_ttc') !==
'') {
448 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
452 if (
GETPOST(
'prod_entry_mode',
'alpha') ==
'free') {
458 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
463 $tva_tx =
GETPOST(
'tva_tx',
'alpha');
466 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef),
'', 2) : 0);
467 if (empty($remise_percent)) {
472 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Qty")),
null,
'errors');
475 if (
GETPOST(
'prod_entry_mode',
'alpha') ==
'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
476 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Description")),
null,
'errors');
482 if (!empty($date_start) && !empty($date_end) && $date_start > $date_end) {
483 setEventMessages($langs->trans(
"Error").
': '.$langs->trans(
"DateStartPlanned").
' > '.$langs->trans(
"DateEndPlanned"),
null,
'errors');
488 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
489 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
491 if (is_array($extralabelsline)) {
493 foreach ($extralabelsline as $key => $value) {
494 unset($_POST[
"options_".$key]);
507 $prod->fetch($idprod);
516 $price_min = $prod->price_min;
517 $price_min_ttc = $prod->price_min_ttc;
521 $price_min = $prod->multiprices_min[
$object->thirdparty->price_level];
522 $price_min_ttc = $prod->multiprices_min_ttc[
$object->thirdparty->price_level];
525 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
529 $filter = array(
't.fk_product' => $prod->id,
't.fk_soc' =>
$object->thirdparty->id);
531 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
533 if (count($prodcustprice->lines) > 0) {
534 $price_min =
price($prodcustprice->lines[0]->price_min);
535 $price_min_ttc =
price($prodcustprice->lines[0]->price_min_ttc);
548 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
549 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string) $prod->tva_tx));
552 if (!empty($price_ht) || $price_ht ===
'0') {
554 $pu_ttc =
price2num((
float) $pu_ht * (1 + ((
float) $tmpvat / 100)),
'MU');
555 $price_base_type =
'HT';
556 } elseif (!empty($price_ttc) || $price_ttc ===
'0') {
558 $pu_ht =
price2num((
float) $pu_ttc / (1 + ((
float) $tmpvat / 100)),
'MU');
559 $price_base_type =
'TTC';
562 $desc = $prod->description;
570 $desc = $product_desc;
575 $fk_unit = $prod->fk_unit;
579 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
580 if (empty($tva_tx)) {
583 $tva_tx = str_replace(
'*',
'', $tva_tx);
584 $desc = $product_desc;
585 $fk_unit =
GETPOST(
'units',
'alpha');
586 $pu_ht_devise =
price2num($price_ht_devise,
'MU');
587 $pu_ttc_devise =
price2num($price_ttc_devise,
'MU');
589 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
592 if (!empty($price_ht) || $price_ht ===
'0') {
594 $pu_ttc =
price2num((
float) $pu_ht * (1 + ((
float) $tmpvat / 100)),
'MU');
595 $price_base_type =
'HT';
596 } elseif (!empty($price_ttc) || $price_ttc ===
'0') {
598 $pu_ht =
price2num((
float) $pu_ttc / (1 + ((
float) $tmpvat / 100)),
'MU');
599 $price_base_type =
'TTC';
607 $fk_fournprice =
GETPOST(
'fournprice');
609 $pa_ht =
GETPOST(
'buying_price');
619 if (((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'produit',
'ignore_price_min_advance'))
621 $object->error = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1, $conf->currency));
650 $outputlangs = $langs;
653 $newlang =
GETPOST(
'lang_id',
'aZ09');
656 $newlang =
$object->thirdparty->default_lang;
658 if (!empty($newlang)) {
660 $outputlangs->setDefaultLang($newlang);
665 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
668 unset($_POST[
'prod_entry_mode']);
670 unset($_POST[
'qty']);
671 unset($_POST[
'type']);
672 unset($_POST[
'remise_percent']);
673 unset($_POST[
'price_ht']);
674 unset($_POST[
'multicurrency_price_ht']);
675 unset($_POST[
'price_ttc']);
676 unset($_POST[
'tva_tx']);
677 unset($_POST[
'product_ref']);
678 unset($_POST[
'product_label']);
679 unset($_POST[
'product_desc']);
680 unset($_POST[
'fournprice']);
681 unset($_POST[
'buying_price']);
682 unset($_POST[
'np_marginRate']);
683 unset($_POST[
'np_markRate']);
684 unset($_POST[
'dp_desc']);
685 unset($_POST[
'idprod']);
687 unset($_POST[
'date_starthour']);
688 unset($_POST[
'date_startmin']);
689 unset($_POST[
'date_startsec']);
690 unset($_POST[
'date_startday']);
691 unset($_POST[
'date_startmonth']);
692 unset($_POST[
'date_startyear']);
693 unset($_POST[
'date_endhour']);
694 unset($_POST[
'date_endmin']);
695 unset($_POST[
'date_endsec']);
696 unset($_POST[
'date_endday']);
697 unset($_POST[
'date_endmonth']);
698 unset($_POST[
'date_endyear']);
703 } elseif ($action ==
'updateline' && $user->hasRight(
'contrat',
'creer') && !
GETPOST(
'cancel',
'alpha')) {
707 if (!empty($date_start_update) && !empty($date_end_update) && $date_start_update > $date_end_update) {
708 setEventMessages($langs->trans(
"Error").
': '.$langs->trans(
"DateStartPlanned").
' > '.$langs->trans(
"DateEndPlanned"),
null,
'errors');
709 $action =
'editline';
715 if ($objectline->fetch(
GETPOSTINT(
'elrowid')) < 0) {
719 $objectline->fetch_optionals();
721 $objectline->oldcopy =
dol_clone($objectline, 2);
727 if ($date_start_real_update ==
'') {
728 $date_start_real_update = $objectline->date_start_real;
730 if ($date_end_real_update ==
'') {
731 $date_end_real_update = $objectline->date_end_real;
734 $vat_rate =
GETPOST(
'eltva_tx',
'alpha');
737 if (preg_match(
'/\*/', $vat_rate)) {
742 $vat_rate = str_replace(
'*',
'', $vat_rate);
751 if (preg_match(
'/\((.*)\)/', $txtva, $reg)) {
752 $vat_src_code = $reg[1];
753 $txtva = preg_replace(
'/\s*\(.*\)/',
'', $txtva);
763 $fk_unit =
GETPOST(
'unit',
'alpha');
770 if ($remise_percent > 0) {
771 $remise = round(((
float) $price_ht * (
float) $remise_percent / 100), 2);
774 $objectline->fk_product =
GETPOSTINT(
'idprod');
775 $objectline->description =
GETPOST(
'product_desc',
'restricthtml');
776 $objectline->price_ht = $price_ht;
779 $objectline->remise_percent = $remise_percent;
780 $objectline->tva_tx = ($txtva ? $txtva : 0);
781 $objectline->vat_src_code = $vat_src_code;
782 $objectline->localtax1_tx = is_numeric($localtax1_tx) ? $localtax1_tx : 0;
783 $objectline->localtax2_tx = is_numeric($localtax2_tx) ? $localtax2_tx : 0;
784 $objectline->date_start = $date_start_update;
785 $objectline->date_start_real = $date_start_real_update;
786 $objectline->date_end = $date_end_update;
787 $objectline->date_end_real = $date_end_real_update;
788 $objectline->user_closing_id = $user->id;
790 $objectline->pa_ht = $pa_ht;
794 $objectline->fk_unit =
GETPOST(
'unit');
796 $objectline->fk_unit =
null;
800 $extralabelsline = $extrafields->fetch_name_optionals_label($objectline->table_element);
801 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
803 if (is_array($array_options) && count($array_options) > 0) {
805 foreach ($array_options as $key => $value) {
806 $objectline->array_options[$key] = $array_options[$key];
812 $result = $objectline->update($user);
815 $action =
'editline';
816 $_GET[
'rowid'] =
GETPOST(
'elrowid');
826 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $user->hasRight(
'contrat',
'creer')) {
830 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
835 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' && $user->hasRight(
'contrat',
'creer')) {
836 $result =
$object->validate($user);
841 $outputlangs = $langs;
844 $newlang =
GETPOST(
'lang_id',
'aZ09');
847 $newlang =
$object->thirdparty->default_lang;
849 if (!empty($newlang)) {
851 $outputlangs->setDefaultLang($newlang);
856 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
861 } elseif ($action ==
'reopen' && $user->hasRight(
'contrat',
'creer')) {
862 $result =
$object->reopen($user);
866 } elseif ($action ==
'confirm_close' && $confirm ==
'yes' && $user->hasRight(
'contrat',
'creer')) {
868 $result =
$object->closeAll($user);
872 } elseif ($action ==
'confirm_activate' && $confirm ==
'yes' && $user->hasRight(
'contrat',
'creer')) {
875 $comment =
GETPOST(
'comment',
'alpha');
876 $result =
$object->activateAll($user, $date_start, 0, $comment, $date_end);
880 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'contrat',
'supprimer')) {
881 $result =
$object->delete($user);
883 header(
"Location: list.php?restore_lastsearch_values=1");
888 } elseif ($action ==
'confirm_move' && $confirm ==
'yes' && $user->hasRight(
'contrat',
'creer')) {
891 $result = $contractline->fetch(
GETPOSTINT(
'lineid'));
892 $contractline->fk_contrat =
GETPOSTINT(
'newcid');
893 $result = $contractline->update($user, 1);
895 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
901 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"RefNewContract")),
null,
'errors');
903 } elseif ($action ==
'update_extras' && $permissiontoadd) {
906 $attribute =
GETPOST(
'attribute',
'alphanohtml');
909 $ret = $extrafields->setOptionalsFromPost(
null,
$object, $attribute);
916 $result =
$object->updateExtraField($attribute,
'CONTRACT_MODIFY');
924 $action =
'edit_extras';
926 } elseif ($action ==
'setref_supplier' && $permissiontoadd) {
930 $result =
$object->setValueFrom(
'ref_supplier',
GETPOST(
'ref_supplier',
'alpha'),
'',
null,
'text',
'', $user,
'CONTRACT_MODIFY');
933 $action =
'editref_supplier';
935 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
939 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
942 } elseif ($action ==
'setref_customer' && $permissiontoadd) {
946 $result =
$object->setValueFrom(
'ref_customer',
GETPOST(
'ref_customer',
'alpha'),
'',
null,
'text',
'', $user,
'CONTRACT_MODIFY');
949 $action =
'editref_customer';
951 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
955 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
958 } elseif ($action ==
'setref' && $permissiontoadd) {
967 $result =
$object->setValueFrom(
'ref',
GETPOST(
'ref',
'alpha'),
'',
null,
'text',
'', $user,
'CONTRACT_MODIFY');
972 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
979 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
983 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
986 } elseif ($action ==
'setdate_contrat' && $permissiontoadd) {
993 $result =
$object->setValueFrom(
'date_contrat', $datacontrat,
'',
null,
'date',
'', $user,
'CONTRACT_MODIFY');
996 $action =
'editdate_contrat';
998 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
1002 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
1008 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1011 $upload_dir = $conf->contrat->multidir_output[!empty(
$object->entity) ?
$object->entity : $conf->entity];
1012 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1015 $triggersendname =
'CONTRACT_SENTBYMAIL';
1017 $mode =
'emailfromcontract';
1018 $trackid =
'con'.$object->id;
1019 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1022 if (
getDolGlobalString(
'MAIN_DISABLE_CONTACTS_TAB') && $user->hasRight(
'contrat',
'creer')) {
1023 if ($action ==
'addcontact') {
1026 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
1029 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
1032 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1033 $langs->load(
"errors");
1034 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
1039 } elseif ($action ==
'swapstatut') {
1042 } elseif ($action ==
'deletecontact') {
1047 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
1056 if ($action ==
'confirm_clone' && $confirm ==
'yes') {
1058 setEventMessages($langs->trans(
"NoCloneOptionsSpecified"),
null,
'errors');
1061 $result =
$object->createFromClone($user, $socid);
1063 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
1066 if (count(
$object->errors) > 0) {
1081$help_url =
'EN:Module_Contracts|FR:Module_Contrat';
1083$title =
$object->ref.
" - ".$langs->trans(
'Contract');
1084if ($action ==
'create') {
1085 $title = $langs->trans(
"NewContract");
1090$form =
new Form($db);
1092if (isModEnabled(
'project')) {
1097$module = (
getDolGlobalString(
'CONTRACT_ADDON') ? $conf->global->CONTRACT_ADDON :
'mod_contract_serpis');
1098if (substr($module, 0, 13) ==
'mod_contract_' && substr($module, -3) ==
'php') {
1099 $module = substr($module, 0,
dol_strlen($module) - 4);
1103 $modCodeContract =
new $module();
1107if ($action ==
'create') {
1113 $soc->fetch($socid);
1119 $element = $subelement =
GETPOST(
'origin');
1120 if (preg_match(
'/^([^_]+)_([^_]+)/i',
GETPOST(
'origin'), $regs)) {
1121 $element = $regs[1];
1122 $subelement = $regs[2];
1125 if ($element ==
'project') {
1129 if ($element ==
'order' || $element ==
'commande') {
1130 $element = $subelement =
'commande';
1132 if ($element ==
'propal') {
1133 $element =
'comm/propal';
1134 $subelement =
'propal';
1136 if ($element ==
'invoice' || $element ==
'facture') {
1137 $element =
'compta/facture';
1138 $subelement =
'facture';
1143 $classname = ucfirst($subelement);
1144 $objectsrc =
new $classname($db);
1145 $objectsrc->fetch($originid);
1146 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
1147 $objectsrc->fetch_lines();
1149 $objectsrc->fetch_thirdparty();
1152 $objectsrc->fetch_optionals();
1153 $object->array_options = $objectsrc->array_options;
1155 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
1157 $soc = $objectsrc->thirdparty;
1159 $note_private = (!empty($objectsrc->note_private) ? $objectsrc->note_private :
'');
1160 $note_public = (!empty($objectsrc->note_public) ? $objectsrc->note_public :
'');
1163 $srccontactslist = $objectsrc->liste_contact(-1,
'external', 1);
1167 $note_private =
GETPOST(
"note_private");
1168 $note_public =
GETPOST(
"note_public");
1173 print
'<form name="form_contract" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1174 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1175 print
'<input type="hidden" name="action" value="add">';
1176 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">'.
"\n";
1177 print
'<input type="hidden" name="remise_percent" value="0">';
1178 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1182 print
'<table class="border centpercent">';
1185 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Ref').
'</td><td>';
1186 if (!empty($modCodeContract->code_auto)) {
1187 $tmpcode = $langs->trans(
"Draft");
1189 $tmpcode =
'<input name="ref" class="maxwidth100" maxlength="128" value="'.dol_escape_htmltag(
GETPOST(
'ref') ?
GETPOST(
'ref') : $tmpcode).
'">';
1195 print
'<tr><td>'.$langs->trans(
'RefCustomer').
'</td>';
1196 print
'<td><input type="text" class="maxwidth150" name="ref_customer" id="ref_customer" value="'.dol_escape_htmltag(
GETPOST(
'ref_customer',
'alpha')).
'"></td></tr>';
1199 print
'<tr><td>'.$langs->trans(
'RefSupplier').
'</td>';
1200 print
'<td><input type="text" class="maxwidth150" name="ref_supplier" id="ref_supplier" value="'.dol_escape_htmltag(
GETPOST(
'ref_supplier',
'alpha')).
'"></td></tr>';
1204 print
'<td class="fieldrequired">'.$langs->trans(
'ThirdParty').
'</td>';
1207 print $soc->getNomUrl(1);
1208 print
'<input type="hidden" name="socid" value="'.$soc->id.
'">';
1212 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
1213 print $form->select_company(
'',
'socid',
'',
'SelectThirdParty', 1, 0,
null, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1214 print
' <a href="'.DOL_URL_ROOT.
'/societe/card.php?action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddThirdParty").
'"></span></a>';
1221 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
1222 if ($soc->remise_percent) {
1223 print $langs->trans(
"CompanyHasRelativeDiscount", $soc->remise_percent).
' ';
1225 print
'<span class="hideonsmartphone">'.$langs->trans(
"CompanyHasNoRelativeDiscount").
'. </span>';
1227 $absolute_discount = $soc->getAvailableDiscounts();
1228 if ($absolute_discount) {
1229 print $langs->trans(
"CompanyHasAbsoluteDiscount",
price($absolute_discount), $langs->trans(
"Currency".$conf->currency)).
'.';
1231 print
'<span class="hideonsmartphone">'.$langs->trans(
"CompanyHasNoAbsoluteDiscount").
'.</span>';
1237 print
'<tr><td class="nowrap"><span class="fieldrequired">'.$langs->trans(
"TypeContact_contrat_internal_SALESREPFOLL").
'</span></td><td>';
1238 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
1239 print $form->select_dolusers(
GETPOST(
"commercial_suivi_id") ?
GETPOST(
"commercial_suivi_id") : $user->id,
'commercial_suivi_id', 1,
'');
1243 print
'<tr><td class="nowrap"><span class="fieldrequired">'.$langs->trans(
"TypeContact_contrat_internal_SALESREPSIGN").
'</span></td><td>';
1244 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
1245 print $form->select_dolusers(
GETPOST(
"commercial_signature_id") ?
GETPOST(
"commercial_signature_id") : $user->id,
'commercial_signature_id', 1,
'');
1248 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td><td>';
1249 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
1250 print $form->selectDate($datecontrat,
'', 0, 0, 0,
"contrat");
1254 if (isModEnabled(
'project')) {
1255 $langs->load(
'projects');
1259 print
'<tr><td>'.$langs->trans(
"Project").
'</td><td>';
1260 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1261 $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid,
"projectid", 0, 0, 1, 1);
1262 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" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1266 print
'<tr><td>'.$langs->trans(
"NotePublic").
'</td><td class="tdtop">';
1267 $doleditor =
new DolEditor(
'note_public', $note_public,
'',
'100',
'dolibarr_notes',
'In', 1,
true, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1268 print $doleditor->Create(1);
1271 if (empty($user->socid)) {
1272 print
'<tr><td>'.$langs->trans(
"NotePrivate").
'</td><td class="tdtop">';
1273 $doleditor =
new DolEditor(
'note_private', $note_private,
'',
'100',
'dolibarr_notes',
'In', 1,
true, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1274 print $doleditor->Create(1);
1279 $parameters = array(
'objectsrc' => $objectsrc,
'colspan' =>
' colspan="3"',
'cols' =>
'3');
1280 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1281 print $hookmanager->resPrint;
1284 if (empty($reshook)) {
1285 print
$object->showOptionals($extrafields,
'create', $parameters);
1292 print $form->buttonsSaveCancel(
"Create");
1294 if (is_object($objectsrc)) {
1295 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
1296 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
1299 print
'<br>'.$langs->trans(
"Note").
': '.$langs->trans(
"OnlyLinesWithTypeServiceAreUsed");
1313 $result =
$object->fetch_lines();
1318 $nbofservices = count(
$object->lines);
1320 $author =
new User($db);
1321 $author->fetch(
$object->user_author_id);
1323 $commercial_signature =
new User($db);
1324 $commercial_signature->fetch(
$object->commercial_signature_id);
1326 $commercial_suivi =
new User($db);
1327 $commercial_suivi->fetch(
$object->commercial_suivi_id);
1334 print
dol_get_fiche_head($head, $hselected, $langs->trans(
"Contract"), -1,
'contract');
1337 if ($action ==
'delete') {
1339 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id, $langs->trans(
"DeleteAContract"), $langs->trans(
"ConfirmDeleteAContract"),
"confirm_delete",
'', 0, 1);
1340 } elseif ($action ==
'valid') {
1342 $ref = substr(
$object->ref, 1, 4);
1343 if ($ref ==
'PROV' && !empty($modCodeContract->code_auto)) {
1348 $text = $langs->trans(
'ConfirmValidateContract', $numref);
1349 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id, $langs->trans(
"ValidateAContract"), $text,
"confirm_valid",
'', 0, 1);
1350 } elseif ($action ==
'close') {
1352 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id, $langs->trans(
"CloseAContract"), $langs->trans(
"ConfirmCloseContract"),
"confirm_close",
'', 0, 1);
1353 } elseif ($action ==
'activate') {
1354 $formquestion = array(
1355 array(
'type' =>
'date',
'name' =>
'd_start',
'label' => $langs->trans(
"DateServiceActivate"),
'value' =>
dol_now()),
1356 array(
'type' =>
'date',
'name' =>
'd_end',
'label' => $langs->trans(
"DateEndPlanned"), 0 =>
'', 1 =>
''),
1357 array(
'type' =>
'text',
'name' =>
'comment',
'label' => $langs->trans(
"Comment"),
'value' =>
'', 0 =>
'', 1 =>
'',
'class' =>
'minwidth300',
'moreattr' =>
'autofocus')
1359 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
"?id=".
$object->id, $langs->trans(
"ActivateAllOnContract"), $langs->trans(
"ConfirmActivateAllOnContract"),
"confirm_activate", $formquestion,
'yes', 1, 280);
1360 } elseif ($action ==
'clone') {
1361 $filter =
'(s.client:IN:1,2,3)';
1363 $formquestion = array(array(
'type' =>
'other',
'name' =>
'socid',
'label' => $langs->trans(
"SelectThirdParty"),
'value' => $form->select_company(
GETPOSTINT(
'socid'),
'socid', $filter)));
1364 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneContract',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
1369 $parameters = array(
1370 'formConfirm' => $formconfirm,
1375 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
1376 if (empty($reshook)) {
1377 $formconfirm .= $hookmanager->resPrint;
1378 } elseif ($reshook > 0) {
1379 $formconfirm = $hookmanager->resPrint;
1387 if (
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'contrat',
'creer')) {
1388 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'" method="POST">';
1389 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1390 print
'<input type="hidden" name="action" value="setremise">';
1391 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1396 $linkback =
'<a href="'.DOL_URL_ROOT.
'/contrat/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1400 if (!empty($modCodeContract->code_auto)) {
1403 $morehtmlref .= $form->editfieldkey(
"",
'ref',
$object->ref,
$object, $user->hasRight(
'contrat',
'creer'),
'string',
'', 0, 3);
1404 $morehtmlref .= $form->editfieldval(
"",
'ref',
$object->ref,
$object, $user->hasRight(
'contrat',
'creer'),
'string',
'', 0, 2);
1407 $morehtmlref .=
'<div class="refidno">';
1409 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_customer',
$object->ref_customer,
$object, $user->hasRight(
'contrat',
'creer'),
'string',
'', 0, 1);
1410 $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');
1412 $morehtmlref .=
'<br>';
1413 $morehtmlref .= $form->editfieldkey(
"RefSupplier",
'ref_supplier',
$object->ref_supplier,
$object, $user->hasRight(
'contrat',
'creer'),
'string',
'', 0, 1);
1414 $morehtmlref .= $form->editfieldval(
"RefSupplier",
'ref_supplier',
$object->ref_supplier,
$object, $user->hasRight(
'contrat',
'creer'),
'string',
'',
null,
null,
'', 1,
'getFormatedSupplierRef');
1416 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
1418 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/contrat/list.php?socid='.
$object->thirdparty->id.
'&search_name='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherContracts").
'</a>)';
1421 if (isModEnabled(
'project')) {
1422 $langs->load(
"projects");
1423 $morehtmlref .=
'<br>';
1424 if ($permissiontoadd) {
1425 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
1426 if ($action !=
'classify') {
1427 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
1429 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
1431 if (!empty(
$object->fk_project)) {
1433 $proj->fetch(
$object->fk_project);
1434 $morehtmlref .= $proj->getNomUrl(1);
1436 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
1441 $morehtmlref .=
'</div>';
1444 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'none', $morehtmlref);
1447 print
'<div class="fichecenter">';
1448 print
'<div class="underbanner clearboth"></div>';
1451 print
'<table class="border tableforfield" width="100%">';
1454 print
'<tr><td class="titlefield">'.$langs->trans(
'Discount').
'</td><td colspan="3">';
1455 if (
$object->thirdparty->remise_percent) {
1456 print $langs->trans(
"CompanyHasRelativeDiscount",
$object->thirdparty->remise_percent).
'. ';
1458 print
'<span class="hideonsmartphone">'.$langs->trans(
"CompanyHasNoRelativeDiscount").
'. </span>';
1460 $absolute_discount =
$object->thirdparty->getAvailableDiscounts();
1461 if ($absolute_discount) {
1462 print $langs->trans(
"CompanyHasAbsoluteDiscount",
price($absolute_discount), $langs->trans(
"Currency".$conf->currency)).
'.';
1464 print
'<span class="hideonsmartphone">'.$langs->trans(
"CompanyHasNoAbsoluteDiscount").
'.</span>';
1470 print
'<td class="titlefield">';
1471 print $form->editfieldkey(
"Date",
'date_contrat',
$object->date_contrat,
$object, $user->hasRight(
'contrat',
'creer'));
1473 print $form->editfieldval(
"Date",
'date_contrat',
$object->date_contrat,
$object, $user->hasRight(
'contrat',
'creer'),
'datehourpicker');
1479 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1485 if (
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'contrat',
'creer')) {
1492 $blocname =
'contacts';
1493 $title = $langs->trans(
'ContactsAddresses');
1494 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
1498 $blocname =
'notes';
1499 $title = $langs->trans(
'Notes');
1500 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
1504 $arrayothercontracts =
$object->getListOfContracts(
'others');
1512 global $inputalsopricewithtax;
1513 $inputalsopricewithtax = 1;
1515 $productstatic =
new Product($db);
1518 if (isModEnabled(
'margin') && !empty(
$object->element) && in_array(
$object->element, array(
'facture',
'propal',
'commande'))) {
1526 print
'<div id="contrat-lines-container" id="contractlines" data-contractid="'.$object->id.
'" data-element="'.
$object->element.
'" >';
1527 while ($cursorline <= $nbofservices) {
1528 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.
'" >';
1529 print
'<form name="update" id="addproduct" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'" method="post">';
1530 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1531 print
'<input type="hidden" name="action" value="updateline">';
1532 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1533 print
'<input type="hidden" name="elrowid" value="'.$object->lines[$cursorline - 1]->id.
'">';
1534 print
'<input type="hidden" name="fournprice" value="'.(!empty(
$object->lines[$cursorline - 1]->fk_fournprice) ?
$object->lines[$cursorline - 1]->fk_fournprice : 0).
'">';
1537 print
'<div class="div-table-responsive-no-min">';
1538 print
'<table class="notopnoleftnoright allwidth tableforservicepart1 centpercent">';
1540 $sql =
"SELECT cd.rowid, cd.statut, cd.label as label_det, cd.fk_product, cd.product_type, cd.description, cd.price_ht, cd.qty,";
1541 $sql .=
" cd.tva_tx, cd.vat_src_code, cd.remise_percent, cd.info_bits, cd.subprice, cd.multicurrency_subprice,";
1542 $sql .=
" cd.date_ouverture_prevue as date_start, cd.date_ouverture as date_start_real,";
1543 $sql .=
" cd.date_fin_validite as date_end, cd.date_cloture as date_end_real,";
1544 $sql .=
" cd.commentaire as comment, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht,";
1545 $sql .=
" cd.fk_unit,";
1546 $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";
1547 $sql .=
" ,cd.rang";
1548 $sql .=
" FROM ".MAIN_DB_PREFIX.
"contratdet as cd";
1549 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
1550 $sql .=
" WHERE cd.rowid = ".((int)
$object->lines[$cursorline - 1]->id);
1552 $result = $db->query($sql);
1556 $objp = $db->fetch_object($result);
1559 print
'<tr class="liste_titre'.($cursorline ?
' liste_titre_add' :
'').
'">';
1560 print
'<td>'.$langs->trans(
"ServiceNb", $cursorline).
'</td>';
1561 print
'<td width="80" class="center">'.$langs->trans(
"VAT").
'</td>';
1562 print
'<td width="80" class="right">'.$langs->trans(
"PriceUHT").
'</td>';
1566 print
'<td width="30" class="center">'.$langs->trans(
"Qty").
'</td>';
1568 print
'<td width="30" class="left">'.$langs->trans(
"Unit").
'</td>';
1570 print
'<td width="50" class="right">'.$langs->trans(
"ReductionShort").
'</td>';
1572 print
'<td width="50" class="right">'.$langs->trans(
"BuyingPrice").
'</td>';
1576 if ($nbofservices > 1 && $conf->browser->layout !=
'phone' && $user->hasRight(
'contrat',
'creer')) {
1577 print
'<td width="30" class="linecolmove tdlineupdown center">';
1578 if ($cursorline > 1) {
1579 print
'<a class="lineupdown reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=up&token='.
newToken().
'&rowid='.$objp->rowid.
'">';
1580 echo
img_up(
'default', 0,
'imgupforline');
1583 if ($cursorline < $nbofservices) {
1584 print
'<a class="lineupdown reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=down&token='.
newToken().
'&rowid='.$objp->rowid.
'">';
1585 echo
img_down(
'default', 0,
'imgdownforline');
1590 print
'<td width="30"> </td>';
1598 if ($action !=
'editline' ||
GETPOST(
'elrowid') != $objp->rowid) {
1600 if (
getDolGlobalString(
'CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT') && $objp->statut == ContratLigne::STATUS_CLOSED && $action !=
'showclosedlines') {
1601 $moreparam =
'style="display: none;"';
1604 print
'<tr class="tdtop oddeven" '.$moreparam.
'>';
1607 if ($objp->fk_product > 0) {
1608 $productstatic->id = $objp->fk_product;
1609 $productstatic->type = $objp->ptype;
1610 $productstatic->ref = $objp->pref;
1611 $productstatic->entity = $objp->pentity;
1612 $productstatic->label = $objp->plabel;
1613 $productstatic->status = $objp->tosell;
1614 $productstatic->status_buy = $objp->tobuy;
1615 $productstatic->status_batch = $objp->tobatch;
1618 $text = $productstatic->getNomUrl(1,
'', 32);
1619 if ($objp->plabel) {
1621 $text .= $objp->plabel;
1623 $description = $objp->description;
1627 $text .= (!empty($objp->description) && $objp->description != $objp->plabel) ?
'<br>'.
dol_htmlentitiesbr($objp->description) :
'';
1631 print $form->textwithtooltip($text, $description, 3,
'',
'', $cursorline, 3, (!empty($line->fk_parent_line) ?
img_picto(
'',
'rightarrow') :
''));
1635 print
'<td>'.img_object($langs->trans(
"ShowProductOrService"), ($objp->product_type ?
'service' :
'product')).
' '.
dol_htmlentitiesbr($objp->
description).
"</td>\n";
1638 print
'<td class="center">';
1639 print
vatrate($objp->tva_tx.($objp->vat_src_code ? (
' ('.$objp->vat_src_code.
')') :
''),
'%', $objp->info_bits);
1642 print
'<td class="right">'.($objp->subprice !=
'' ?
price($objp->subprice) :
'').
"</td>\n";
1648 print
'<td class="center">'.$objp->qty.
'</td>';
1651 print
'<td class="left">'.$langs->trans(
$object->lines[$cursorline - 1]->getLabelOfUnit()).
'</td>';
1654 if ($objp->remise_percent > 0) {
1655 print
'<td class="right">'.$objp->remise_percent.
"%</td>\n";
1657 print
'<td> </td>';
1662 print
'<td class="right nowraponall">'.price($objp->pa_ht).
'</td>';
1666 print
'<td class="nowraponall right">';
1667 if ($user->hasRight(
'contrat',
'creer') && is_array($arrayothercontracts) && count($arrayothercontracts) && (
$object->statut >= 0)) {
1668 print
'<!-- link to move service line into another contract -->';
1669 print
'<a class="reposition marginrightonly" style="padding-left: 5px;" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=move&token='.
newToken().
'&elrowid='.$objp->rowid.
'">';
1670 print
img_picto($langs->trans(
"MoveToAnotherContract"),
'uparrow');
1673 if ($user->hasRight(
'contrat',
'creer') && (
$object->statut >= 0)) {
1674 print
'<a class="reposition marginrightonly editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=editline&token='.
newToken().
'&elrowid='.$objp->rowid.
'">';
1678 if ($user->hasRight(
'contrat',
'creer') && (
$object->statut >= 0)) {
1679 print
'<a class="reposition marginrightonly" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=deleteline&token='.
newToken().
'&elrowid='.$objp->rowid.
'">';
1696 if ($objp->subprice >= 0) {
1697 print
'<tr class="oddeven" '.$moreparam.
'>';
1698 print
'<td colspan="'.$colspan.
'">';
1701 print $langs->trans(
"DateStartPlanned").
': ';
1702 if ($objp->date_start) {
1705 if ($objp->statut == 0 && $db->jdate($objp->date_start) < ($now - $conf->contrat->services->inactifs->warning_delay)) {
1706 $warning_delay = $conf->contrat->services->inactifs->warning_delay / 3600 / 24;
1707 $textlate = $langs->trans(
"Late").
' = '.$langs->trans(
"DateReference").
' > '.$langs->trans(
"DateToday").
' '.(ceil($warning_delay) >= 0 ?
'+' :
'').ceil($warning_delay).
' '.$langs->trans(
"days");
1708 print
" ".img_warning($textlate);
1711 print $langs->trans(
"Unknown");
1713 print
' - ';
1714 print $langs->trans(
"DateEndPlanned").
': ';
1715 if ($objp->date_end) {
1717 if ($objp->statut == 4 && $db->jdate($objp->date_end) < ($now - $conf->contrat->services->expires->warning_delay)) {
1718 $warning_delay = $conf->contrat->services->expires->warning_delay / 3600 / 24;
1719 $textlate = $langs->trans(
"Late").
' = '.$langs->trans(
"DateReference").
' > '.$langs->trans(
"DateToday").
' '.(ceil($warning_delay) >= 0 ?
'+' :
'').ceil($warning_delay).
' '.$langs->trans(
"days");
1720 print
" ".img_warning($textlate);
1723 print $langs->trans(
"Unknown");
1731 if (is_array($extralabelslines) && count($extralabelslines) > 0) {
1733 $line->id = $objp->rowid;
1734 $line->fetch_optionals();
1735 print $line->showOptionals($extrafields,
'view', array(
'class' =>
'oddeven',
'style' => $moreparam,
'colspan' => $colspan),
'',
'', 1);
1740 print
'<tr class="oddeven">';
1742 $currentLineProductId=GETPOSTISSET(
'idprod')?
GETPOST(
'idprod'):(!empty(
$object->lines[$cursorline - 1]->fk_product) ?
$object->lines[$cursorline - 1]->fk_product : 0);
1743 if ($objp->fk_product > 0) {
1744 $canchangeproduct = 1;
1747 if (empty($canchangeproduct)) {
1748 $productstatic->id = $objp->fk_product;
1749 $productstatic->type = $objp->ptype;
1750 $productstatic->ref = $objp->pref;
1751 $productstatic->entity = $objp->pentity;
1752 print $productstatic->getNomUrl(1,
'', 32);
1753 print $objp->label ?
' - '.dol_trunc($objp->label, 32) :
'';
1754 print
'<input type="hidden" name="idprod" value="'.$currentLineProductId.
'">';
1756 $senderissupplier = 0;
1757 if (empty($senderissupplier)) {
1758 print $form->select_produits($currentLineProductId,
'idprod',
'', 0, 0, 1, 2,
'', 0, array(), 0, 1, 0,
'minwidth250onall maxwidth500 widthcentpercentminusx');
1760 $form->select_produits_fournisseurs($currentLineProductId,
'idprod');
1765 print $objp->label ? $objp->label.
'<br>' :
'';
1766 print
'<input type="hidden" name="idprod" value="'.$currentLineProductId.
'">';
1770 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1775 $doleditor =
new DolEditor(
'product_desc', (GETPOSTISSET(
'product_desc')?
GETPOST(
'product_desc'):$objp->
description),
'', 92,
'dolibarr_details',
'', false, true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), $nbrows,
'90%');
1776 $doleditor->Create();
1781 print
'<td class="right">';
1782 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, 0, 1);
1786 print
'<td class="right"><input class="width50" type="text" name="elprice" value="'.(GETPOSTISSET(
'elprice')?
GETPOST(
'elprice'):
price($objp->subprice)).
'"></td>';
1794 print
'<td class="center"><input size="2" type="text" name="elqty" value="'.(GETPOSTISSET(
'elqty')?
GETPOST(
'elqty'):$objp->qty).
'"></td>';
1798 print
'<td class="left">';
1799 print $form->selectUnits((GETPOSTISSET(
'unit')?
GETPOST(
'unit'):$objp->fk_unit),
"unit");
1804 print
'<td class="nowraponall right"><input size="1" type="text" name="elremise_percent" value="'.(GETPOSTISSET(
'elremise_percent')?
GETPOST(
'elremise_percent'):$objp->remise_percent).
'">%</td>';
1806 if (!empty($usemargins)) {
1807 print
'<td class="right">';
1808 if ($objp->fk_product) {
1809 print
'<select id="fournprice" name="fournprice"></select>';
1811 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>';
1813 print
'<td class="center">';
1814 print
'<input type="submit" class="button margintoponly marginbottomonly" name="save" value="'.$langs->trans(
"Modify").
'">';
1815 print
'<br><input type="submit" class="button margintoponly marginbottomonly button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1828 print
'<tr class="oddeven">';
1829 print
'<td colspan="'.$colspan.
'">';
1830 print $langs->trans(
"DateStartPlanned").
' ';
1831 print $form->selectDate($db->jdate($objp->date_start),
"date_start_update", $usehm, $usehm, ($db->jdate($objp->date_start) > 0 ? 0 : 1),
"update");
1832 print
' '.$langs->trans(
"DateEndPlanned").
' ';
1833 print $form->selectDate($db->jdate($objp->date_end),
"date_end_update", $usehm, $usehm, ($db->jdate($objp->date_end) > 0 ? 0 : 1),
"update");
1837 if (is_array($extralabelslines) && count($extralabelslines) > 0) {
1839 $line->id = $objp->rowid;
1840 $line->fetch_optionals();
1841 print $line->showOptionals($extrafields,
'edit', array(
'style' =>
'class="oddeven"',
'colspan' => $colspan),
'',
'', 1);
1852 if (
getDolGlobalString(
'CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT') &&
$object->lines[$cursorline - 1]->statut == ContratLigne::STATUS_CLOSED && $action !=
'showclosedlines') {
1853 $moreparam =
'style="display: none;"';
1864 print
'<tr class="oddeven" '.$moreparam.
'>';
1865 print
'<td class="tdhrthin" colspan="'.$colspan.
'"><hr class="opacitymedium tdhrthin"></td>';
1878 if ($action ==
'deleteline' && !$_REQUEST[
"cancel"] && $user->hasRight(
'contrat',
'creer') &&
$object->lines[$cursorline - 1]->id ==
GETPOST(
'elrowid')) {
1879 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id.
"&lineid=".
GETPOST(
'elrowid'), $langs->trans(
"DeleteContractLine"), $langs->trans(
"ConfirmDeleteContractLine"),
"confirm_deleteline",
'', 0, 1);
1880 if ($ret ==
'html') {
1881 print
'<table class="notopnoleftnoright" width="100%"><tr class="oddeven" height="6"><td></td></tr></table>';
1888 if ($action ==
'move' && !$_REQUEST[
"cancel"] && $user->hasRight(
'contrat',
'creer') &&
$object->lines[$cursorline - 1]->id ==
GETPOST(
'elrowid')) {
1889 $arraycontractid = array();
1890 foreach ($arrayothercontracts as $contractcursor) {
1891 $arraycontractid[$contractcursor->id] = $contractcursor->ref;
1895 $formquestion = array(
1896 'text' => $langs->trans(
"ConfirmMoveToAnotherContractQuestion"),
1897 0 => array(
'type' =>
'select',
'name' =>
'newcid',
'values' => $arraycontractid));
1899 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id.
"&lineid=".
GETPOSTINT(
'elrowid'), $langs->trans(
"MoveToAnotherContract"), $langs->trans(
"ConfirmMoveToAnotherContract"),
"confirm_move", $formquestion);
1900 print
'<table class="notopnoleftnoright" width="100%"><tr class="oddeven" height="6"><td></td></tr></table>';
1905 print
'<table class="notopnoleftnoright tableforservicepart2'.($cursorline < $nbofservices ?
' boxtablenobottom' :
'').
' centpercent">';
1907 print
'<tr class="oddeven" '.$moreparam.
'>';
1908 print
'<td><span class="valignmiddle hideonsmartphone">'.$langs->trans(
"ServiceStatus").
':</span> '.
$object->lines[$cursorline - 1]->getLibStatut(4).
'</td>';
1909 print
'<td width="30" class="right">';
1910 if ($user->socid == 0) {
1911 if (
$object->statut > 0 && $action !=
'activateline' && $action !=
'unactivateline') {
1912 $tmpaction =
'activateline';
1913 $tmpactionpicto =
'play';
1914 $tmpactiontext = $langs->trans(
"Activate");
1915 if ($objp->statut == 4) {
1916 $tmpaction =
'unactivateline';
1917 $tmpactionpicto =
'playstop';
1918 $tmpactiontext = $langs->trans(
"Disable");
1920 if (($tmpaction ==
'activateline' && $user->hasRight(
'contrat',
'activer')) || ($tmpaction ==
'unactivateline' && $user->hasRight(
'contrat',
'desactiver'))) {
1921 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&ligne='.
$object->lines[$cursorline - 1]->id.
'&action='.$tmpaction.
'">';
1922 print
img_picto($tmpactiontext, $tmpactionpicto);
1930 print
'<tr class="oddeven" '.$moreparam.
'>';
1934 if (!$objp->date_start_real) {
1935 print $langs->trans(
"DateStartReal").
': ';
1936 if ($objp->date_start_real) {
1939 print $langs->trans(
"ContractStatusNotRunning");
1943 if ($objp->date_start_real && !$objp->date_end_real) {
1944 print $langs->trans(
"DateStartReal").
': ';
1948 if ($objp->date_start_real && $objp->date_end_real) {
1949 print $langs->trans(
"DateStartReal").
': ';
1951 print
' - ';
1952 print $langs->trans(
"DateEndReal").
': ';
1955 if (!empty($objp->comment)) {
1956 print
" - ".$objp->comment;
1960 print
'<td class="center"> </td>';
1967 if ($user->hasRight(
'contrat',
'activer') && $action ==
'activateline' &&
$object->lines[$cursorline - 1]->id ==
GETPOSTINT(
'ligne')) {
1968 print
'<form name="active" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1969 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1970 print
'<input type="hidden" name="action" value="confirm_active">';
1971 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1972 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1973 print
'<input type="hidden" name="ligne" value="'.GETPOSTINT(
'ligne').
'">';
1974 print
'<input type="hidden" name="confirm" value="yes">';
1976 print
'<table class="noborder tableforservicepart2'.($cursorline < $nbofservices ?
' boxtablenobottom' :
'').
' centpercent">';
1979 $dateactstart = $objp->date_start;
1982 } elseif (!$dateactstart) {
1983 $dateactstart = time();
1986 $dateactend = $objp->date_end;
1989 } elseif (!$dateactend) {
1990 if ($objp->fk_product > 0) {
1992 $product->fetch($objp->fk_product);
1993 $dateactend =
dol_time_plus_duree(time(), $product->duration_value, $product->duration_unit);
1997 print
'<tr class="oddeven">';
1998 print
'<td class="nohover">'.$langs->trans(
"DateServiceActivate").
'</td><td class="nohover">';
1999 print $form->selectDate($dateactstart,
'start', $usehm, $usehm, 0,
"active", 1, 0);
2001 print
'<td class="nohover">'.$langs->trans(
"DateEndPlanned").
'</td><td class="nohover">';
2002 print $form->selectDate($dateactend,
"end", $usehm, $usehm, 0,
"active", 1, 0);
2004 print
'<td class="center nohover">';
2009 print
'<tr class="oddeven">';
2010 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>';
2011 print
'<td class="nohover right">';
2012 print
'<input type="submit" class="button" name="activate" value="'.$langs->trans(
"Activate").
'"> ';
2013 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2022 if ($user->hasRight(
'contrat',
'activer') && $action ==
'unactivateline' &&
$object->lines[$cursorline - 1]->id ==
GETPOSTINT(
'ligne')) {
2026 print
'<!-- Form to disabled a line -->'.
"\n";
2027 print
'<form name="confirm_closeline" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&ligne='.
$object->lines[$cursorline - 1]->id.
'" method="post">';
2028 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2029 print
'<input type="hidden" name="confirm" value="yes">';
2030 print
'<input type="hidden" name="action" value="confirm_closeline">';
2031 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2033 print
'<table class="noborder tableforservicepart2'.($cursorline < $nbofservices ?
' boxtablenobottom' :
'').
' centpercent">';
2036 $dateactstart = $objp->date_start_real;
2039 } elseif (!$dateactstart) {
2040 $dateactstart = time();
2043 $dateactend = $objp->date_end_real;
2046 } elseif (!$dateactend) {
2047 if ($objp->fk_product > 0) {
2049 $product->fetch($objp->fk_product);
2050 $dateactend =
dol_time_plus_duree(time(), $product->duration_value, $product->duration_unit);
2054 if ($dateactend > $now) {
2058 print
'<tr class="oddeven"><td colspan="2" class="nohover">';
2059 if ($objp->statut >= 4) {
2060 if ($objp->statut == 4) {
2061 print $langs->trans(
"DateEndReal").
' ';
2062 print $form->selectDate($dateactend,
"end", $usehm, $usehm, ($objp->date_end_real > 0 ? 0 : 1),
"closeline", 1, 1);
2066 print
'<td class="center nohover">';
2069 print
'<tr class="oddeven">';
2070 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>';
2071 print
'<td class="nohover right">';
2072 print
'<input type="submit" class="button" name="close" value="'.$langs->trans(
"Disable").
'"> ';
2073 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2087 if ($user->hasRight(
'contrat',
'creer') && (
$object->statut == 0)) {
2091 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
2092 <input type="hidden" name="token" value="'.
newToken().
'">
2093 <input type="hidden" name="action" value="'.(($action !=
'editline') ?
'addline' :
'updateline').
'">
2094 <input type="hidden" name="mode" value="">
2095 <input type="hidden" name="id" value="'.
$object->id.
'">
2096 <input type="hidden" name="page_y" value="">
2097 <input type="hidden" name="backtopage" value="'.$backtopage.
'">
2100 print
'<div class="div-table-responsive-no-min">';
2101 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
2104 if ($action !=
'editline') {
2105 $forcetoshowtitlelines = 1;
2106 if (empty(
$object->multicurrency_code)) {
2107 $object->multicurrency_code = $conf->currency;
2112 $parameters = array();
2113 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters,
$object, $action);
2117 if (empty($reshook)) {
2118 $object->formAddObjectLine(1, $mysoc, $soc);
2130 if (
GETPOST(
'modelselected')) {
2131 $action =
'presend';
2137 if ($user->socid == 0 && $action !=
'presend' && $action !=
'editline') {
2138 print
'<div class="tabsAction">';
2140 $parameters = array();
2141 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
2143 if (empty($reshook)) {
2147 'class' =>
'classfortooltip'
2152 if (empty($user->socid)) {
2153 if (
$object->status == $object::STATUS_VALIDATED) {
2154 if ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'contrat',
'creer'))) {
2155 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.
newToken().
'&mode=init#formmailbeforetitle',
'',
true, $params);
2157 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default',
'#',
'',
false, $params);
2162 if (
$object->status == $object::STATUS_DRAFT && $nbofservices) {
2163 if ($user->hasRight(
'contrat',
'creer')) {
2164 unset($params[
'attr'][
'title']);
2165 print
dolGetButtonAction($langs->trans(
'Validate'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=valid&token='.
newToken(),
'',
true, $params);
2167 $params[
'attr'][
'title'] = $langs->trans(
"NotEnoughPermissions");
2168 print
dolGetButtonAction($langs->trans(
'Validate'),
'',
'default',
'#',
'',
false, $params);
2171 if (
$object->status == $object::STATUS_VALIDATED) {
2172 if ($user->hasRight(
'contrat',
'creer')) {
2173 unset($params[
'attr'][
'title']);
2174 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=reopen&token='.
newToken(),
'',
true, $params);
2176 $params[
'attr'][
'title'] = $langs->trans(
"NotEnoughPermissions");
2177 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default',
'#',
'',
false, $params);
2182 $arrayofcreatebutton = array();
2183 if (isModEnabled(
'order') &&
$object->status > 0 &&
$object->nbofservicesclosed < $nbofservices) {
2184 $arrayofcreatebutton[] = array(
2185 'url' =>
'/commande/card.php?action=create&token='.
newToken().
'&origin='.
$object->element.
'&originid='.
$object->id.
'&socid='.
$object->thirdparty->id,
2186 'label' => $langs->trans(
'AddOrder'),
2188 'perm' => $user->hasRight(
'commande',
'creer')
2191 if (isModEnabled(
'invoice') &&
$object->status > 0 && $soc->client > 0) {
2192 $arrayofcreatebutton[] = array(
2193 'url' =>
'/compta/facture/card.php?action=create&origin='.
$object->element.
'&originid='.
$object->id.
'&socid='.
$object->thirdparty->id,
2194 'label' => $langs->trans(
'CreateBill'),
2196 'perm' => $user->hasRight(
'facture',
'creer')
2199 if (isModEnabled(
'supplier_invoice') &&
$object->status > 0 && $soc->fournisseur == 1) {
2200 $langs->load(
"suppliers");
2201 $arrayofcreatebutton[] = array(
2202 'url' =>
'/fourn/facture/card.php?action=create&origin='.
$object->element.
'&originid='.
$object->id.
'&socid='.
$object->thirdparty->id,
2203 'label' => $langs->trans(
'AddSupplierInvoice'),
2205 'perm' => $user->hasRight(
'fournisseur',
'facture',
'creer')
2208 if (count($arrayofcreatebutton)) {
2209 unset($params[
'attr'][
'title']);
2210 print
dolGetButtonAction(
'', $langs->trans(
"Create"),
'default', $arrayofcreatebutton,
'',
true, $params);
2213 if (
$object->nbofservicesclosed > 0 ||
$object->nbofserviceswait > 0) {
2214 if ($user->hasRight(
'contrat',
'activer')) {
2215 unset($params[
'attr'][
'title']);
2216 print
dolGetButtonAction($langs->trans(
'ActivateAllContracts'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=activate&token='.
newToken(),
'',
true, $params);
2218 unset($params[
'attr'][
'title']);
2219 print
dolGetButtonAction($langs->trans(
'ActivateAllContracts'),
'',
'default',
'#',
'',
false, $params);
2222 if (
$object->nbofservicesclosed < $nbofservices) {
2223 if ($user->hasRight(
'contrat',
'desactiver')) {
2224 unset($params[
'attr'][
'title']);
2225 print
dolGetButtonAction($langs->trans(
'CloseAllContracts'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=close&token='.
newToken(),
'',
true, $params);
2227 unset($params[
'attr'][
'title']);
2228 print
dolGetButtonAction($langs->trans(
'CloseAllContracts'),
'',
'default',
'#',
'',
false, $params);
2241 if ($action ==
'showclosedlines') {
2242 print
'<div class="inline-block divButAction"><a class="butAction" id="btnhideclosedlines" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=hideclosedlines">'.$langs->trans(
"HideClosedServices").
'</a></div>';
2244 print
'<div class="inline-block divButAction"><a class="butAction" id="btnshowclosedlines" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=showclosedlines">'.$langs->trans(
"ShowClosedServices").
'</a></div>';
2249 if ($user->hasRight(
'contrat',
'creer')) {
2250 unset($params[
'attr'][
'title']);
2255 unset($params[
'attr'][
'title']);
2256 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'', $permissiontodelete, $params);
2262 if ($action !=
'presend') {
2263 print
'<div class="fichecenter"><div class="fichehalfleft">';
2270 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
2271 $genallowed = $user->hasRight(
'contrat',
'lire');
2272 $delallowed = $user->hasRight(
'contrat',
'creer');
2275 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);
2279 $linktoelem = $form->showLinkToObjectBlock(
$object,
null, array(
'contrat'));
2280 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
2284 print
'<br><!-- Link to sign -->';
2285 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
2287 print showOnlineSignatureUrl(
'contract',
$object->ref).
'<br>';
2290 print
'</div><div class="fichehalfright">';
2294 $morehtmlcenter =
'<div class="nowraponall">';
2295 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT.
'/contrat/messaging.php?id='.
$object->id);
2296 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/contrat/agenda.php?id='.
$object->id);
2297 $morehtmlcenter .=
'</div>';
2301 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2303 $somethingshown = $formactions->showactions(
$object,
'contract', $socid, 1,
'listactions', $MAXEVENT,
'', $morehtmlcenter);
2305 print
'</div></div>';
2309 $modelmail =
'contract';
2310 $defaulttopic =
'SendContractRef';
2311 $diroutput = $conf->contrat->multidir_output[
$object->entity];
2312 $trackid =
'con'.$object->id;
2314 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
2325if (isModEnabled(
'margin') && $action ==
'editline') {
2327<script
type=
"text/javascript">
2328$(document).ready(
function() {
2329 var idprod = $(
"input[name='idprod']").val();
2330 var fournprice = $(
"input[name='fournprice']").val();
2331 var token =
'<?php echo currentToken(); ?>';
2333 $.post(
'<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {
2337 if (data.length > 0) {
2340 $(data).each(
function() {
2341 options +=
'<option value="'+this.
id+
'" price="'+this.
price+
'"';
2342 if (fournprice > 0) {
2343 if (this.
id == fournprice) {
2344 options +=
' selected';
2345 $(
"#buying_price").val(this.price);
2349 options +=
'>'+this.label+
'</option>';
2351 options +=
'<option value=null'+(trouve?
'':
' selected')+
'><?php echo $langs->trans("InputPrice"); ?></option>';
2352 $(
"#fournprice").html(options);
2354 $(
"#buying_price").hide();
2355 $(
"#fournprice").show();
2358 $(
"#buying_price").show();
2360 $(
"#fournprice").change(
function() {
2361 var selval = $(
this).find(
'option:selected').attr(
"price");
2363 $(
"#buying_price").val(selval).hide();
2365 $(
'#buying_price').show();
2369 $(
"#fournprice").hide();
2370 $(
'#buying_price').show();
2376 $(
"#fournprice").hide();
2377 $(
'#buying_price').show();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage contracts.
Class to manage lines of contracts.
Class to manage a WYSIWYG editor.
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.
contract_prepare_head(Contrat $object)
Prepare array with list of tabs.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
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.
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
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.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $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.
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_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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 dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular vat, 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_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
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.