36require
'../../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
40if (isModEnabled(
'project')) {
41 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/invoice.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
59$langs->loadLangs(array(
'bills',
'companies',
'compta',
'admin',
'other',
'products',
'banks'));
61$action =
GETPOST(
'action',
'alpha');
62$massaction =
GETPOST(
'massaction',
'alpha');
64$confirm =
GETPOST(
'confirm',
'alpha');
65$cancel =
GETPOST(
'cancel',
'alpha');
66$toselect =
GETPOST(
'toselect',
'array');
67$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'invoicetemplatelist';
68$backtopage =
GETPOST(
'backtopage',
'alpha');
69$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
76 $socid = $user->socid;
78$objecttype =
'facture_rec';
79if ($action ==
"create" || $action ==
"add") {
84$year_date_when =
GETPOST(
'year_date_when');
85$month_date_when =
GETPOST(
'month_date_when');
86$selectedLines =
GETPOST(
'toselect',
'array');
89$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
90$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
92if (empty($page) || $page == -1) {
95$offset = $limit * $page;
100 $sortfield =
'f.titre';
102$pageprev = $page - 1;
103$pagenext = $page + 1;
106if (($id > 0 || $ref) && $action !=
'create' && $action !=
'add') {
107 $ret =
$object->fetch($id, $ref);
117$hookmanager->initHooks(array(
'invoicereccard',
'globalcard'));
121$extrafields->fetch_name_optionals_label(
$object->table_element);
123$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
125$permissionnote = $user->hasRight(
'facture',
'creer');
126$permissiondellink = $user->hasRight(
'facture',
'creer');
127$permissiontoedit = $user->hasRight(
'facture',
'creer');
129$usercanread = $user->hasRight(
'facture',
'lire');
130$usercancreate = $user->hasRight(
'facture',
'creer');
131$usercanissuepayment = $user->hasRight(
'facture',
'paiement');
132$usercandelete = $user->hasRight(
'facture',
'supprimer');
135$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'facture',
'invoice_advance',
'validate')));
136$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->rights->facture->invoice_advance->send);
137$usercanreopen = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->rights->facture->invoice_advance->reopen);
138$usercanunvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'facture',
'invoice_advance',
'unvalidate')));
141$usercanproductignorepricemin = ((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'produit',
'ignore_price_min_advance')) || !
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS'));
142$usercancreatemargin = $user->hasRight(
"margins",
"creer");
143$usercanreadallmargin = $user->hasRight(
"margins",
"liretous");
144$usercancreatewithdrarequest = $user->hasRight(
"prelevement",
"bons",
"creer");
157if (
GETPOST(
'cancel',
'alpha')) {
158 if ($action !=
'updateline') {
166if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
170$parameters = array();
171$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
176if (empty($reshook)) {
177 $backurlforlist = DOL_URL_ROOT.
'/compta/facture/invoicetemplate_list.php';
179 if (empty($backtopage) || ($cancel && empty($id))) {
180 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
181 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
182 $backtopage = $backurlforlist;
184 $backtopage = DOL_URL_ROOT.
'/compta/facture/invoicetemplate_list.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
192 if (!empty($backtopageforcancel)) {
193 header(
"Location: ".$backtopageforcancel);
195 } elseif (!empty($backtopage)) {
196 header(
"Location: ".$backtopage);
203 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
206 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
208 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
210 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
219 if ($action ==
'add' && $usercancreate) {
220 if (!
GETPOST(
'title',
'alphanohtml')) {
221 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Title")),
null,
'errors');
236 if (empty($reyear) || empty($remonth) || empty($reday)) {
237 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Date")),
null,
'errors');
260 $object->frequency = $frequency;
262 $object->nb_gen_max = $nb_gen_max;
265 $object->fk_project = $projectid;
267 $date_next_execution =
dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
268 $object->date_when = $date_next_execution;
270 $ret = $extrafields->setOptionalsFromPost(
null, $object);
280 $srcObject->fetchObjectLinked();
282 if (!empty($srcObject->linkedObjectsIds[
'contrat'])) {
283 $contractidid = reset($srcObject->linkedObjectsIds[
'contrat']);
285 $object->origin_type =
'contrat';
286 $object->origin_id = $contractidid;
288 } elseif (!empty($srcObject->linkedObjectsIds[
'commande'])) {
289 $orderid = reset($srcObject->linkedObjectsIds[
'commande']);
291 $object->linked_objects[
'commande'] = $orderid;
292 } elseif (!empty($srcObject->linkedObjectsIds[
'propal'])) {
293 $proposalid = reset($srcObject->linkedObjectsIds[
'propal']);
295 $object->linked_objects[
'commande'] = $proposalid;
301 $oldinvoice =
new Facture($db);
304 $onlylines =
GETPOST(
'toselect',
'array');
306 $result =
$object->create($user, $oldinvoice->id, 0, $onlylines);
308 $result = $oldinvoice->delete($user, 1);
323 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?facid='.
$object->id);
334 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'facture',
'supprimer')) {
337 header(
"Location: ".DOL_URL_ROOT.
'/compta/facture/invoicetemplate_list.php');
343 if ($action ==
'setconditions' && $usercancreate) {
345 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModified", $langs->transnoentitiesnoconv(
"PaymentTerm"));
347 } elseif ($action ==
'setmode' && $usercancreate) {
349 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModified", $langs->transnoentitiesnoconv(
"PaymentMode"));
351 $object->setValueFrom(
'fk_societe_rib', 0);
354 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?facid='.
$object->id);
356 } elseif ($action ==
'classin' && $usercancreate) {
358 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModified", $langs->transnoentitiesnoconv(
"Project"));
360 } elseif ($action ==
'setref' && $usercancreate) {
362 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModifiedFromYToZ", $langs->transnoentitiesnoconv(
"Title"),
$object->title, $ref);
363 $result =
$object->setValueFrom(
'titre', $ref,
'',
null,
'text',
'', $user,
'BILLREC_MODIFY');
369 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
370 $langs->load(
"errors");
371 setEventMessages($langs->trans(
'ErrorRefAlreadyExists', $ref),
null,
'errors');
376 } elseif ($action ==
'setbankaccount' && $usercancreate) {
378 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModified", $langs->transnoentitiesnoconv(
"Bank"));
380 } elseif ($action ==
'setbankaccountcustomer' && $usercancreate) {
382 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModified", $langs->transnoentitiesnoconv(
"DebitBankAccount"));
383 $fk_societe_rib = (
GETPOSTINT(
'accountcustomerid') !=
"-1") ?
GETPOSTINT(
'accountcustomerid') : 0;
384 $result =
$object->setValueFrom(
'fk_societe_rib', $fk_societe_rib);
385 } elseif ($action ==
'setfrequency' && $usercancreate) {
387 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModified", $langs->transnoentitiesnoconv(
"Frequency"));
389 } elseif ($action ==
'setdate_when' && $usercancreate) {
395 } elseif ($action ==
'setnb_gen_max' && $usercancreate) {
398 } elseif ($action ==
'setauto_validate' && $usercancreate) {
401 } elseif ($action ==
'setgenerate_pdf' && $usercancreate) {
404 } elseif ($action ==
'setmodelpdf' && $usercancreate) {
407 } elseif ($action ==
'disable' && $usercancreate) {
411 $object->context[
'actionmsg'] = $langs->trans(
"RecordDisabled");
413 $res =
$object->setValueFrom(
'suspended', 1,
'',
null,
'text',
'', $user,
'BILLREC_MODIFY');
424 } elseif ($action ==
'enable' && $usercancreate) {
428 $object->context[
'actionmsg'] = $langs->trans(
"RecordEnabled");
430 $res =
$object->setValueFrom(
'suspended', 0,
'',
null,
'text',
'', $user,
'BILLREC_MODIFY');
441 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
443 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
444 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
450 if ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
461 if ($line->delete($user) > 0) {
462 $result =
$object->update_price(1);
475 } elseif ($action ==
'update_extras' && $usercancreate) {
479 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
485 $result =
$object->insertExtraFields(
'BILLREC_MODIFY');
494 if ($action ==
'addline' && $usercancreate) {
495 $langs->load(
'errors');
500 $product_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
503 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'alpha');
504 if ($prod_entry_mode ==
'free') {
510 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
515 $tva_tx = (
GETPOST(
'tva_tx',
'alpha') ?
GETPOST(
'tva_tx',
'alpha') : 0);
519 if (empty($remise_percent)) {
524 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
525 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
527 if (is_array($extralabelsline)) {
529 foreach ($extralabelsline as $key => $value) {
530 unset($_POST[
"options_".$key.$predef]);
534 if ((empty($idprod) || $idprod < 0) && ($price_ht < 0) && ($qty < 0)) {
535 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPriceHT'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
538 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
539 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
542 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && (!($price_ht >= 0) || $price_ht ==
'')) {
543 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")),
null,
'errors');
547 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
550 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
551 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
555 $langs->load(
"errors");
556 setEventMessages($langs->trans(
'ErrorQtyForCustomerInvoiceCantBeNegative'),
null,
'errors');
560 if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) {
566 $ret =
$object->fetch_thirdparty();
571 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
582 if (!empty($idprod) && $idprod > 0) {
584 $prod->fetch($idprod);
586 $label = ((
GETPOST(
'product_label') &&
GETPOST(
'product_label') != $prod->label) ?
GETPOST(
'product_label') :
'');
598 $datapriceofproduct = $prod->getSellPrice($mysoc,
$object->thirdparty, $pqp);
600 $pu_ht = $datapriceofproduct[
'pu_ht'];
601 $pu_ttc = $datapriceofproduct[
'pu_ttc'];
602 $price_min = $datapriceofproduct[
'price_min'];
603 $price_base_type = empty($datapriceofproduct[
'price_base_type']) ?
'HT' : $datapriceofproduct[
'price_base_type'];
607 $tmpvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
608 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string) $prod->tva_tx));
611 if (!empty($price_ht)) {
613 $pu_ttc =
price2num((
float) $pu_ht * (1 + ($tmpvat / 100)),
'MU');
614 } elseif ($tmpvat != $tmpprodvat) {
617 if ($price_base_type !=
'HT') {
618 $pu_ht =
price2num((
float) $pu_ttc / (1 + ($tmpvat / 100)),
'MU');
620 $pu_ttc =
price2num((
float) $pu_ht * (1 + ($tmpvat / 100)),
'MU');
628 $outputlangs = $langs;
630 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
631 $newlang =
GETPOST(
'lang_id',
'aZ09');
633 if (empty($newlang)) {
634 $newlang =
$object->thirdparty->default_lang;
636 if (!empty($newlang)) {
638 $outputlangs->setDefaultLang($newlang);
641 $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] [
"description"])) ? $prod->multilangs [$outputlangs->defaultlang] [
"description"] : $prod->
description;
643 $desc = $prod->description;
649 if (!
getDolGlobalString(
'MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE') && (!empty($prod->customcode) || !empty($prod->country_code))) {
653 $outputlangs = $langs;
655 if (empty($newlang) &&
GETPOST(
'lang_id',
'alpha')) {
656 $newlang =
GETPOST(
'lang_id',
'alpha');
658 if (empty($newlang)) {
659 $newlang =
$object->thirdparty->default_lang;
661 if (!empty($newlang)) {
663 $outputlangs->setDefaultLang($newlang);
664 $outputlangs->load(
'products');
666 if (!empty($prod->customcode)) {
667 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
669 if (!empty($prod->customcode) && !empty($prod->country_code)) {
672 if (!empty($prod->country_code)) {
673 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code,
'', $db, $outputlangs, 0);
676 if (!empty($prod->customcode)) {
677 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
679 if (!empty($prod->customcode) && !empty($prod->country_code)) {
682 if (!empty($prod->country_code)) {
683 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code,
'', $db, $langs, 0);
691 $fk_unit = $prod->fk_unit;
695 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
696 $tva_tx = str_replace(
'*',
'', $tva_tx);
697 if (empty($tva_tx)) {
700 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
701 $desc = $product_desc;
703 $fk_unit =
GETPOST(
'units',
'alpha');
706 $date_start_fill =
GETPOSTINT(
'date_start_fill');
722 $fk_parent_line =
GETPOST(
'fk_parent_line',
'int');
724 if ($usercanproductignorepricemin && (!empty($price_min) && ((
float)
price2num($pu_ht) * (1 - (
float)
price2num($remise_percent) / 100) < (
float)
price2num($price_min)))) {
725 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
729 $result =
$object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, 0, $pu_ttc, $type, -1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice, $fk_parent_line);
752 unset($_POST[
'prod_entry_mode']);
754 unset($_POST[
'qty']);
755 unset($_POST[
'type']);
756 unset($_POST[
'remise_percent']);
757 unset($_POST[
'price_ht']);
758 unset($_POST[
'multicurrency_price_ht']);
759 unset($_POST[
'price_ttc']);
760 unset($_POST[
'tva_tx']);
761 unset($_POST[
'product_ref']);
762 unset($_POST[
'product_label']);
763 unset($_POST[
'product_desc']);
764 unset($_POST[
'fournprice']);
765 unset($_POST[
'buying_price']);
766 unset($_POST[
'np_marginRate']);
767 unset($_POST[
'np_markRate']);
768 unset($_POST[
'dp_desc']);
769 unset($_POST[
'idprod']);
770 unset($_POST[
'units']);
772 unset($_POST[
'date_starthour']);
773 unset($_POST[
'date_startmin']);
774 unset($_POST[
'date_startsec']);
775 unset($_POST[
'date_startday']);
776 unset($_POST[
'date_startmonth']);
777 unset($_POST[
'date_startyear']);
778 unset($_POST[
'date_endhour']);
779 unset($_POST[
'date_endmin']);
780 unset($_POST[
'date_endsec']);
781 unset($_POST[
'date_endday']);
782 unset($_POST[
'date_endmonth']);
783 unset($_POST[
'date_endyear']);
785 unset($_POST[
'date_start_fill']);
786 unset($_POST[
'date_end_fill']);
788 unset($_POST[
'situations']);
789 unset($_POST[
'progress']);
797 } elseif ($action ==
'updateline' && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
798 if (!
$object->fetch($id) > 0) {
816 if (preg_match(
'/\*/', $vat_rate)) {
821 $vat_rate = str_replace(
'*',
'', $vat_rate);
830 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
831 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
834 if ($objectline->fetch(
GETPOSTINT(
'lineid'))) {
835 $objectline->array_options = $array_options;
836 $result = $objectline->insertExtraFields();
842 $position = ($objectline->rang >= 0 ? $objectline->rang : 0);
845 if (is_array($extralabelsline)) {
847 foreach ($extralabelsline as $key => $value) {
848 unset($_POST[
"options_".$key]);
854 if ($special_code == 3) {
871 if (empty($remise_percent)) {
877 if (!empty($productid)) {
879 $product->fetch($productid);
881 $type = $product->type;
883 $price_min = $product->price_min;
885 $price_min = $product->multiprices_min[
$object->thirdparty->price_level];
894 setEventMessages($langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, - 1,
$conf->currency)),
null,
'errors');
899 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
903 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
908 $langs->load(
"errors");
909 setEventMessages($langs->trans(
'ErrorQtyForCustomerInvoiceCantBeNegative'),
null,
'errors');
913 $date_start_fill =
GETPOSTINT(
'date_start_fill');
915 $fk_parent_line =
GETPOST(
'fk_parent_line',
'int');
967 unset($_POST[
'qty']);
968 unset($_POST[
'type']);
969 unset($_POST[
'productid']);
970 unset($_POST[
'remise_percent']);
971 unset($_POST[
'price_ht']);
972 unset($_POST[
'multicurrency_price_ht']);
973 unset($_POST[
'price_ttc']);
974 unset($_POST[
'tva_tx']);
975 unset($_POST[
'product_ref']);
976 unset($_POST[
'product_label']);
977 unset($_POST[
'product_desc']);
978 unset($_POST[
'fournprice']);
979 unset($_POST[
'buying_price']);
980 unset($_POST[
'np_marginRate']);
981 unset($_POST[
'np_markRate']);
983 unset($_POST[
'dp_desc']);
984 unset($_POST[
'idprod']);
985 unset($_POST[
'units']);
987 unset($_POST[
'date_starthour']);
988 unset($_POST[
'date_startmin']);
989 unset($_POST[
'date_startsec']);
990 unset($_POST[
'date_startday']);
991 unset($_POST[
'date_startmonth']);
992 unset($_POST[
'date_startyear']);
993 unset($_POST[
'date_endhour']);
994 unset($_POST[
'date_endmin']);
995 unset($_POST[
'date_endsec']);
996 unset($_POST[
'date_endday']);
997 unset($_POST[
'date_endmonth']);
998 unset($_POST[
'date_endyear']);
1000 unset($_POST[
'situations']);
1001 unset($_POST[
'progress']);
1014$title =
$object->ref.
" - ".$langs->trans(
'Card');
1019$form =
new Form($db);
1021if (isModEnabled(
'project')) {
1024 $formproject =
null;
1026$companystatic =
new Societe($db);
1034if ($action ==
'create') {
1035 print
load_fiche_titre($langs->trans(
"CreateRepeatableInvoice"),
'',
'bill');
1039 $product_static =
new Product($db);
1041 if (
$object->fetch($id, $ref) > 0) {
1042 $result =
$object->getLinesArray();
1044 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1045 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1046 print
'<input type="hidden" name="action" value="add">';
1047 print
'<input type="hidden" name="facid" value="'.$object->id.
'">';
1053 if (isModEnabled(
'project')) {
1056 if (
$object->fk_account > 0) {
1060 print
'<table class="border centpercent">';
1065 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Title").
'</td><td>';
1066 print
'<input class="flat quatrevingtpercent" type="text" name="title" value="'.dol_escape_htmltag(
GETPOST(
"title",
'alphanohtml')).
'" autofocus>';
1070 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Customer").
'</td><td>'.
$object->thirdparty->getNomUrl(1,
'customer').
'</td>';
1075 print
"<tr><td>".$langs->trans(
"InvoiceSubtype").
"</td><td>";
1076 print $form->getSelectInvoiceSubtype(GETPOSTISSET(
'subtype') ?
GETPOST(
'subtype') :
$object->subtype,
'subtype', 0, 0,
'');
1080 $note_public = GETPOSTISSET(
'note_public') ?
GETPOST(
'note_public',
'restricthtml') :
$object->note_public;
1081 $note_private = GETPOSTISSET(
'note_private') ?
GETPOST(
'note_private',
'restricthtml') :
$object->note_private;
1086 $substitutionarray[
'__INVOICE_PREVIOUS_MONTH__'] = $langs->trans(
"PreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree(
$object->date, -1,
'm'),
'%m').
')';
1087 $substitutionarray[
'__INVOICE_MONTH__'] = $langs->trans(
"MonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
$object->date,
'%m').
')';
1089 $substitutionarray[
'__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans(
"TextPreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree(
$object->date, -1,
'm'),
'%B').
')';
1090 $substitutionarray[
'__INVOICE_MONTH_TEXT__'] = $langs->trans(
"TextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
$object->date,
'%B').
')';
1091 $substitutionarray[
'__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans(
"TextNextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree(
$object->date, 1,
'm'),
'%B').
')';
1093 $substitutionarray[
'__INVOICE_YEAR__'] = $langs->trans(
"YearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
$object->date,
'%Y').
')';
1096 $substitutionarray[
'__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans(
"DateNextInvoiceBeforeGen").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree(
$object->date, 1,
'm'),
'dayhour').
')';
1097 $substitutionarray[
'__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans(
"DateNextInvoiceAfterGen").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree(
$object->date, 2,
'm'),
'dayhour').
')';
1098 $substitutionarray[
'__INVOICE_COUNTER_CURRENT__'] = $langs->trans(
"Count");
1099 $substitutionarray[
'__INVOICE_COUNTER_MAX__'] = $langs->trans(
"MaxPeriodNumber");
1101 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
1102 foreach ($substitutionarray as $key => $val) {
1103 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
1105 $htmltext .=
'</i>';
1108 print
"<tr><td>".$langs->trans(
"Author").
"</td><td>".$user->getFullName($langs).
"</td></tr>";
1111 print
"<tr><td>".$langs->trans(
"PaymentConditions").
"</td><td>";
1112 print $form->getSelectConditionsPaiements(GETPOSTISSET(
'cond_reglement_id') ?
GETPOSTINT(
'cond_reglement_id') :
$object->cond_reglement_id,
'cond_reglement_id', -1, 0, 0,
'');
1117 print
"<tr><td>".$langs->trans(
"PaymentMode").
"</td><td>";
1118 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
1119 print $form->select_types_paiements(GETPOSTISSET(
'mode_reglement_id') ?
GETPOSTINT(
'mode_reglement_id') :
$object->mode_reglement_id,
'mode_reglement_id',
'', 0, 1, 0, 0, 1,
'', 1);
1124 print
"<tr><td>".$langs->trans(
'DebitBankAccount').
"</td><td>";
1125 $defaultRibId =
$object->thirdparty->getDefaultRib();
1126 $form->selectRib(GETPOSTISSET(
'accountcustomerid') ?
GETPOSTINT(
'accountcustomerid') : $defaultRibId,
'accountcustomerid',
'fk_soc='.
$object->socid, 1,
'', 1);
1130 $(document).ready(function() {
1131 if($("#selectmode_reglement_id option:selected").data("code") != "' . $factureRec::PAYMENTCODETOEDITSOCIETERIB .
'") {
1132 hideselectfksocieterib();
1134 $("#selectmode_reglement_id").change(function() {
1135 if($("#selectmode_reglement_id option:selected").data("code") != "'. $factureRec::PAYMENTCODETOEDITSOCIETERIB .
'") {
1136 hideselectfksocieterib(1);
1138 showselectfksocieterib();
1143 function hideselectfksocieterib(empty = 0){
1144 $("#selectaccountcustomerid").closest("tr").hide();
1146 $("#selectaccountcustomerid").val("-1").change();
1150 function showselectfksocieterib(){
1151 $("#selectaccountcustomerid").closest("tr").show();
1156 if (
$object->fk_account > 0) {
1157 print
"<tr><td>".$langs->trans(
'BankAccount').
"</td><td>";
1158 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
1167 $extralabels = $extrafields->fetch_name_optionals_label($draft->table_element);
1168 if ($draft->fetch_optionals() > 0) {
1169 $object->array_options = array_merge(
$object->array_options, $draft->array_options);
1172 print
$object->showOptionals($extrafields,
'create', $parameters);
1175 if (isModEnabled(
'project') && is_object(
$object->thirdparty) &&
$object->thirdparty->id > 0 && is_object($formproject)) {
1177 $langs->load(
'projects');
1178 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td>';
1179 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1180 $numprojet = $formproject->select_projects(
$object->thirdparty->id, $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 0, 0,
'');
1181 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.
$object->thirdparty->id.
'&action=create&status=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create&socid='.
$object->thirdparty->id.(!empty($id) ?
'&id='.$id :
'')).
'">'.
img_object($langs->trans(
"AddProject"),
'add').
'</a>';
1186 print
"<tr><td>".$langs->trans(
'Model').
"</td><td>";
1187 include_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
1189 print
img_picto(
'',
'generic',
'class="pictofixedwidth"');
1191 print $form->selectarray(
'modelpdf', $list,
$conf->global->FACTURE_ADDON_PDF);
1196 print
'<td class="tdtop">';
1197 print $form->textwithpicto($langs->trans(
'NotePublic'), $htmltext, 1,
'help',
'', 0, 2,
'notepublic');
1200 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1201 print $doleditor->Create(1);
1204 if (empty($user->socid)) {
1206 print
'<td class="tdtop">';
1207 print $form->textwithpicto($langs->trans(
'NotePrivate'), $htmltext, 1,
'help',
'', 0, 2,
'noteprivate');
1210 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1211 print $doleditor->Create(1);
1221 $title = $langs->trans(
"Recurrence");
1224 print
'<span class="opacitymedium">'.$langs->trans(
"ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv(
'Module2300Name')).
'</span><br><br>';
1228 print
'<table class="border centpercent">';
1231 print
'<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans(
"Frequency"), $langs->transnoentitiesnoconv(
'toolTipFrequency')).
"</td><td>";
1232 print
'<input type="text" class="width50" name="frequency" value="'.GETPOST(
'frequency',
'int').
'"> ';
1233 print $form->selectarray(
'unit_frequency', array(
'd' => $langs->trans(
'Day'),
'm' => $langs->trans(
'Month'),
'y' => $langs->trans(
'Year')), (
GETPOST(
'unit_frequency') ?
GETPOST(
'unit_frequency') :
'm'));
1237 print
"<tr><td>".$langs->trans(
'NextDateToExecution').
"</td><td>";
1239 print $form->selectDate($date_next_execution,
'', 1, 1, 0,
"add", 1, 1);
1243 print
"<tr><td>".$langs->trans(
"MaxPeriodNumber").
"</td><td>";
1244 print
'<input type="text" class="width50" name="nb_gen_max" value="'.GETPOSTINT(
'nb_gen_max').
'">';
1248 print
"<tr><td>".$langs->trans(
"StatusOfAutoGeneratedInvoices").
"</td><td>";
1249 $select = array(
'0' => $langs->trans(
'BillStatusDraft'),
'1' => $langs->trans(
'BillStatusValidated'));
1250 print $form->selectarray(
'auto_validate', $select,
GETPOSTINT(
'auto_validate'));
1255 print
"<tr><td>".$langs->trans(
"StatusOfGeneratedDocuments").
"</td><td>";
1256 $select = array(
'0' => $langs->trans(
'DoNotGenerateDoc'),
'1' => $langs->trans(
'AutoGenerateDoc'));
1257 print $form->selectarray(
'generate_pdf', $select,
GETPOSTINT(
'generate_pdf'));
1260 print
'<input type="hidden" name="generate_pdf" value="1">';
1268 $title = $langs->trans(
"ProductsAndServices");
1269 if (!isModEnabled(
'service')) {
1270 $title = $langs->trans(
"Products");
1271 } elseif (!isModEnabled(
'product')) {
1272 $title = $langs->trans(
"Services");
1280 print
'<div class="div-table-responsive-no-min">';
1281 print
'<table id="tablelines" class="noborder noshadow centpercent">';
1285 $object->printOriginLinesList(
'', $selectedLines);
1294 if (!empty($flag_price_may_change)) {
1295 print
'<tr><td colspan="3" class="left">';
1296 print
'<select name="usenewprice" class="flat">';
1297 print
'<option value="0">'.$langs->trans(
"AlwaysUseFixedPrice").
'</option>';
1298 print
'<option value="1" disabled>'.$langs->trans(
"AlwaysUseNewPrice").
'</option>';
1306 print $form->buttonsSaveCancel(
"Create");
1319 if ($action ==
'ask_deleteline') {
1320 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'',
'no', 1);
1323 if ($action ==
'delete') {
1324 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteRepeatableInvoice'), $langs->trans(
'ConfirmDeleteRepeatableInvoice'),
'confirm_delete',
'',
'no', 1);
1328 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
1329 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1330 if (empty($reshook)) {
1331 $formconfirm .= $hookmanager->resPrint;
1332 } elseif ($reshook > 0) {
1333 $formconfirm = $hookmanager->resPrint;
1338 $author =
new User($db);
1339 $author->fetch(
$object->user_author);
1343 print
dol_get_fiche_head($head,
'card', $langs->trans(
"RepeatableInvoice"), -1,
'bill');
1347 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/facture/invoicetemplate_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1350 if ($action !=
'editref') {
1351 $morehtmlref .= $form->editfieldkey(
$object->ref,
'ref',
$object->ref, $object, $user->hasRight(
'facture',
'creer'),
'',
'', 0, 2);
1353 $morehtmlref .= $form->editfieldval(
'',
'ref',
$object->ref, $object, $user->hasRight(
'facture',
'creer'),
'string');
1356 $morehtmlref .=
'<div class="refidno">';
1361 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'customer');
1363 if (isModEnabled(
'project')) {
1364 $langs->load(
"projects");
1365 $morehtmlref .=
'<br>';
1366 if ($user->hasRight(
'facture',
'creer')) {
1367 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
1368 if ($action !=
'classify') {
1369 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
1371 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
1373 if (!empty(
$object->fk_project)) {
1375 $proj->fetch(
$object->fk_project);
1376 $morehtmlref .=
' : '.$proj->getNomUrl(1);
1378 $morehtmlref .=
' - '.$proj->title;
1385 $morehtmlref .=
'</div>';
1387 $morehtmlstatus =
'';
1389 dol_banner_tab($object,
'ref', $linkback, 1,
'title',
'none', $morehtmlref,
'', 0,
'', $morehtmlstatus);
1391 print
'<div class="fichecenter">';
1392 print
'<div class="fichehalfleft">';
1393 print
'<div class="underbanner clearboth"></div>';
1395 print
'<table class="border centpercent tableforfield">';
1399 print
"<tr><td>".$langs->trans(
"InvoiceSubtype").
"</td><td>";
1401 print
$object->getSubtypeLabel(
'facture_rec');
1407 print
'<tr><td class="titlefield">'.$langs->trans(
"Author").
'</td><td>';
1408 print $author->getNomUrl(-1);
1412 print
'<tr><td>'.$langs->trans(
"AmountHT").
'</td>';
1413 print
'<td>'.price(
$object->total_ht, 0, $langs, 1, -1, -1,
$conf->currency).
'</td>';
1417 print
'<tr><td>'.$langs->trans(
"AmountVAT").
'</td><td>'.
price(
$object->total_tva, 0, $langs, 1, -1, -1,
$conf->currency).
'</td>';
1421 if (($mysoc->localtax1_assuj ==
"1" && $mysoc->useLocalTax(1)) ||
$object->total_localtax1 != 0) {
1422 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
1423 print
'<td class="nowrap">'.price(
$object->total_localtax1, 1,
'', 1, - 1, - 1,
$conf->currency).
'</td></tr>';
1425 if (($mysoc->localtax2_assuj ==
"1" && $mysoc->useLocalTax(2)) ||
$object->total_localtax2 != 0) {
1426 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
1427 print
'<td class=nowrap">'.price(
$object->total_localtax2, 1,
'', 1, - 1, - 1,
$conf->currency).
'</td></tr>';
1430 print
'<tr><td>'.$langs->trans(
"AmountTTC").
'</td><td colspan="3">'.
price(
$object->total_ttc, 0, $langs, 1, -1, -1,
$conf->currency).
'</td>';
1436 print
'<table class="nobordernopadding centpercent"><tr><td>';
1437 print $langs->trans(
'PaymentConditionsShort');
1439 if ($action !=
'editconditions' && $user->hasRight(
'facture',
'creer')) {
1440 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editconditions&token='.
newToken().
'&facid='.
$object->id.
'">'.
img_edit($langs->trans(
'SetConditions'), 1).
'</a></td>';
1442 print
'</tr></table>';
1444 if ($action ==
'editconditions') {
1445 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id,
$object->cond_reglement_id,
'cond_reglement_id');
1447 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id,
$object->cond_reglement_id,
'none');
1453 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1454 print $langs->trans(
'PaymentMode');
1456 if ($action !=
'editmode' && $user->hasRight(
'facture',
'creer')) {
1457 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmode&token='.
newToken().
'&facid='.
$object->id.
'">'.
img_edit($langs->trans(
'SetMode'), 1).
'</a></td>';
1459 print
'</tr></table>';
1461 if ($action ==
'editmode') {
1462 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id,
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
1464 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id,
$object->mode_reglement_id,
'none');
1470 if (
$object->mode_reglement_code == $object::PAYMENTCODETOEDITSOCIETERIB) {
1471 print
'<tr><td class="nowrap">';
1472 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1473 print $langs->trans(
'DebitBankAccount');
1477 print
'<td class="right"><a class="editfielda" href="' . $_SERVER[
"PHP_SELF"] .
'?action=editbankaccountcustomer&token=' .
newToken() .
'&id=' .
$object->id .
'">' .
img_edit($langs->trans(
'SetDebitBankAccount'), 1) .
'</a></td>';
1479 print
'</tr></table>';
1482 if ($action ==
'editbankaccountcustomer') {
1483 $form->formRib($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->fk_societe_rib,
'accountcustomerid',
'fk_soc='.$object->socid, 1, 1);
1485 $form->formRib($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->fk_societe_rib,
'none',
'', 0, 1);
1492 print
'<tr><td class="nowrap">';
1493 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1494 print $langs->trans(
'BankAccount');
1497 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editbankaccount&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->trans(
'SetBankAccount'), 1).
'</a></td>';
1499 print
'</tr></table>';
1501 if ($action ==
'editbankaccount') {
1502 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'fk_account', 1);
1504 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
1510 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1516 print
'<tr><td class="nowrap">';
1517 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1518 print $langs->trans(
'Model');
1521 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmodelpdf&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->trans(
'SetModel'), 1).
'</a></td>';
1523 print
'</tr></table>';
1525 if ($action ==
'editmodelpdf') {
1526 include_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
1529 foreach ($models as $k => $model) {
1530 $list[] = str_replace(
':',
'|', $k).
':'.$model;
1532 $select =
'select;'.implode(
',', $list);
1533 print $form->editfieldval($langs->trans(
"Model"),
'modelpdf',
$object->model_pdf, $object, $user->hasRight(
'facture',
'creer'), $select);
1547 print
'<div class="fichehalfright">';
1548 print
'<div class="underbanner clearboth"></div>';
1554 $title = $langs->trans(
"Recurrence");
1556 print
'<table class="border centpercent tableforfield">';
1558 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
1560 print
'<tr><td colspan="2">'.img_picto(
'',
'recurring',
'class="pictofixedwidth"').$title.
'</td></tr>';
1563 print
'<tr><td style="width: 50%">';
1564 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1565 print $langs->trans(
'Frequency');
1567 if ($action !=
'editfrequency' && $user->hasRight(
'facture',
'creer')) {
1568 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editfrequency&token='.
newToken().
'&facid='.
$object->id.
'">'.
img_edit($langs->trans(
'Edit'), 1).
'</a></td>';
1570 print
'</tr></table>';
1572 if ($action ==
'editfrequency') {
1573 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'">';
1574 print
'<input type="hidden" name="action" value="setfrequency">';
1575 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1576 print
'<table class="nobordernopadding">';
1578 print
'<input type="text" name="frequency" class="width50 marginrightonly right" value="'.$object->frequency.
'">';
1579 print $form->selectarray(
'unit_frequency', array(
'd' => $langs->trans(
'Day'),
'm' => $langs->trans(
'Month'),
'y' => $langs->trans(
'Year')), (
$object->unit_frequency ?
$object->unit_frequency :
'm'));
1581 print
'<td class="left"><input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
"Modify").
'"></td>';
1582 print
'</tr></table></form>';
1585 print $langs->trans(
'FrequencyPer_'.
$object->unit_frequency,
$object->frequency);
1587 print
'<span class="opacitymedium">'.$langs->trans(
"NotARecurringInvoiceTemplate").
'</span>';
1594 if ($action ==
'date_when' ||
$object->frequency > 0) {
1595 print $form->editfieldkey($langs->trans(
"NextDateToExecution"),
'date_when',
$object->date_when, $object, $user->hasRight(
'facture',
'creer'),
'day');
1597 print $langs->trans(
"NextDateToExecution");
1600 if ($action ==
'date_when' ||
$object->frequency > 0) {
1601 print $form->editfieldval($langs->trans(
"NextDateToExecution"),
'date_when',
$object->date_when, $object, $user->hasRight(
'facture',
'creer'),
'day',
$object->date_when,
null,
'',
'', 0,
'strikeIfMaxNbGenReached');
1604 if (!
$object->isMaxNbGenReached()) {
1609 print
img_info($langs->trans(
"MaxNumberOfGenerationReached"));
1616 if ($action ==
'nb_gen_max' ||
$object->frequency > 0) {
1617 print $form->editfieldkey($langs->trans(
"MaxPeriodNumber"),
'nb_gen_max',
$object->nb_gen_max, $object, $user->hasRight(
'facture',
'creer'));
1619 print $langs->trans(
"MaxPeriodNumber");
1622 if ($action ==
'nb_gen_max' ||
$object->frequency > 0) {
1623 print $form->editfieldval($langs->trans(
"MaxPeriodNumber"),
'nb_gen_max',
$object->nb_gen_max ?
$object->nb_gen_max :
'',
$object, $user->hasRight(
'facture',
'creer'));
1632 if ($action ==
'auto_validate' ||
$object->frequency > 0) {
1633 print $form->editfieldkey($langs->trans(
"StatusOfAutoGeneratedInvoices"),
'auto_validate',
$object->auto_validate, $object, $user->hasRight(
'facture',
'creer'));
1635 print $langs->trans(
"StatusOfAutoGeneratedInvoices");
1638 $select =
'select;0:'.$langs->trans(
'BillStatusDraft').
',1:'.$langs->trans(
'BillStatusValidated');
1639 if ($action ==
'auto_validate' ||
$object->frequency > 0) {
1640 print $form->editfieldval($langs->trans(
"StatusOfAutoGeneratedInvoices"),
'auto_validate',
$object->auto_validate, $object, $user->hasRight(
'facture',
'creer'), $select);
1647 if ($action ==
'generate_pdf' ||
$object->frequency > 0) {
1648 print $form->editfieldkey($langs->trans(
"StatusOfGeneratedDocuments"),
'generate_pdf',
$object->generate_pdf, $object, $user->hasRight(
'facture',
'creer'));
1650 print $langs->trans(
"StatusOfGeneratedDocuments");
1654 $select =
'select;0:'.$langs->trans(
'DoNotGenerateDoc').
',1:'.$langs->trans(
'AutogenerateDoc');
1655 if ($action ==
'generate_pdf' ||
$object->frequency > 0) {
1656 print $form->editfieldval($langs->trans(
"StatusOfGeneratedDocuments"),
'generate_pdf',
$object->generate_pdf, $object, $user->hasRight(
'facture',
'creer'), $select);
1661 print
'<input type="hidden" name="generate_pdf" value="1">';
1670 if (!isModEnabled(
'cron')) {
1671 print
info_admin($langs->trans(
"EnableAndSetupModuleCron", $langs->transnoentitiesnoconv(
"Module2300Name")));
1674 print
'<div class="underbanner clearboth"></div>';
1675 print
'<table class="border centpercent tableforfield">';
1678 print
'<tr><td style="width: 50%">'.$langs->trans(
"NbOfGenerationDone").
'</td>';
1686 print $langs->trans(
"DateLastGeneration");
1700 print
'<div class="clearboth"></div><br>';
1704 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'#add' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">';
1705 print
'<input type="hidden" name="token" value="' .
newToken().
'">';
1706 print
'<input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">';
1707 print
'<input type="hidden" name="mode" value="">';
1708 print
'<input type="hidden" name="id" value="' .
$object->id.
'">';
1709 print
'<input type="hidden" name="page_y" value="">';
1711 if (!empty(
$conf->use_javascript_ajax) &&
$object->statut == 0) {
1712 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
1715 print
'<div class="div-table-responsive-no-min">';
1716 print
'<table id="tablelines" class="noborder noshadow centpercent">';
1719 $canchangeproduct = 1;
1720 $object->printObjectLines($action, $mysoc,
$object->thirdparty, $lineid, 0);
1724 if (
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer') && $action !=
'valid' && $action !=
'editline') {
1725 if ($action !=
'editline') {
1728 $parameters = array();
1729 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
1733 if (empty($reshook)) {
1750 print
'<div class="tabsAction">';
1752 $parameters = array();
1753 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1754 if (empty($reshook)) {
1757 'class' =>
'classfortooltip',
1760 if (empty(
$object->suspended)) {
1761 if ($user->hasRight(
'facture',
'creer')) {
1763 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' .
dol_escape_htmltag($langs->trans(
"MaxGenerationReached")) .
'">' . $langs->trans(
"CreateBill") .
'</a></div>';
1765 if (empty(
$object->frequency) ||
$object->date_when <= $nowlasthour) {
1766 print
'<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT .
'/compta/facture/card.php?action=create&socid=' .
$object->thirdparty->id .
'&fac_rec=' .
$object->id .
'">' . $langs->trans(
"CreateBill") .
'</a></div>';
1768 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' .
dol_escape_htmltag($langs->trans(
"DateIsNotEnough")) .
'">' . $langs->trans(
"CreateBill") .
'</a></div>';
1772 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">' . $langs->trans(
"CreateBill") .
'</a></div>';
1776 if ($user->hasRight(
'facture',
'creer')) {
1777 if (empty(
$object->suspended)) {
1778 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?action=disable&id='.
$object->id.
'&token='.
newToken().
'">'.$langs->trans(
"Disable").
'</a></div>';
1780 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=enable&id='.
$object->id.
'&token='.
newToken().
'">'.$langs->trans(
"Enable").
'</a></div>';
1785 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=delete&token=' .
newToken(),
'delete', $user->hasRight(
'facture',
'supprimer'));
1791 print
'<div class="fichecenter"><div class="fichehalfleft">';
1792 print
'<a name="builddoc"></a>';
1796 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'invoice'), 1);
1797 $linktoelem = $tmparray[
'linktoelem'];
1798 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
1799 print $htmltoenteralink;
1801 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
1805 print
'<div class="fichehalfright">';
1810 $morehtmlcenter =
'';
1813 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1815 $morehtmlcenter =
'';
1816 $somethingshown = $formactions->showactions($object,
$object->element, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
1821 print $langs->trans(
"NoRecordFound");
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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.
const STATUS_DRAFT
Draft status.
Class to manage a WYSIWYG editor.
Class to manage invoices.
const TYPE_REPLACEMENT
Replacement invoice.
const TYPE_STANDARD
Standard invoice.
Class to manage invoice lines of templates.
Class to manage invoice templates.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
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.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_get_last_hour($date, $gm='tzserver')
Return GMT time for last hour of a given GMT date (it replaces hours, min and second part to 23:59:59...
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_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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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 '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_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).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
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,...
img_info($titlealt='default')
Show info logo.
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...
invoice_rec_prepare_head($object)
Return array head with list of tabs to view object information.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.