38require
'../../main.inc.php';
48require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
52 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/lib/invoice.lib.php';
59$langs->loadLangs(array(
'bills',
'companies',
'compta',
'admin',
'other',
'products',
'banks'));
61$action =
GETPOST(
'action',
'aZ09');
62$massaction =
GETPOST(
'massaction',
'alpha');
64$confirm =
GETPOST(
'confirm',
'alpha');
65$cancel =
GETPOST(
'cancel',
'alpha');
66$toselect =
GETPOST(
'toselect',
'array:int');
67$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'invoicetemplatelist';
68$backtopage =
GETPOST(
'backtopage',
'alpha');
69$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
77 $socid = $user->socid;
79$objecttype =
'facture_rec';
80if ($action ==
"create" || $action ==
"add") {
85$year_date_when =
GETPOST(
'year_date_when');
86$month_date_when =
GETPOST(
'month_date_when');
87$selectedLines =
GETPOST(
'toselect',
'array:int');
90$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
91$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
93if (empty($page) || $page == -1) {
96$offset = $limit * $page;
101 $sortfield =
'f.titre';
103$pageprev = $page - 1;
104$pagenext = $page + 1;
107if (($id > 0 || $ref) && $action !=
'create' && $action !=
'add') {
108 $ret =
$object->fetch($id, $ref);
112 setEventMessages($langs->trans(
"ErrorRecordNotFound"),
null,
'errors');
117$hookmanager->initHooks(array(
'invoicereccard',
'globalcard'));
120$extrafields->fetch_name_optionals_label(
$object->table_element);
122$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
124$permissiontoadd = $user->hasRight(
'facture',
'creer');
125$permissionnote = $user->hasRight(
'facture',
'creer');
126$permissiondellink = $user->hasRight(
'facture',
'creer');
127$permissiontoedit = $user->hasRight(
'facture',
'creer');
128$permissiontoeditextra = $permissiontoadd;
129if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
131 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
134$usercanread = $user->hasRight(
'facture',
'lire');
135$usercancreate = $user->hasRight(
'facture',
'creer');
136$usercanissuepayment = $user->hasRight(
'facture',
'paiement');
137$usercandelete = $user->hasRight(
'facture',
'supprimer');
140$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'facture',
'invoice_advance',
'validate')));
141$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'facture',
'invoice_advance',
'send'));
142$usercanreopen = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
'facture',
'invoice_advance',
'reopen'));
143$usercanunvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'facture',
'invoice_advance',
'unvalidate')));
144$usermustrespectpricemin = ((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'produit',
'ignore_price_min_advance')) || !
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS'));
147$usercanproductignorepricemin = ((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'produit',
'ignore_price_min_advance')) || !
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS'));
148$usercancreatemargin = $user->hasRight(
"margins",
"creer");
149$usercanreadallmargin = $user->hasRight(
"margins",
"liretous");
150$usercancreatewithdrarequest = $user->hasRight(
"prelevement",
"bons",
"creer");
164if (
GETPOST(
'cancel',
'alpha')) {
165 if ($action !=
'updateline' && $action !=
'setdate_when') {
173if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
177$parameters = array(
'socid' => $socid);
178$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
180 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
183if (empty($reshook)) {
184 $backurlforlist = DOL_URL_ROOT.
'/compta/facture/invoicetemplate_list.php';
186 if (empty($backtopage) || ($cancel && empty($id))) {
187 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
188 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
189 $backtopage = $backurlforlist;
191 $backtopage = DOL_URL_ROOT.
'/compta/facture/invoicetemplate_list.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
199 if (!empty($backtopageforcancel)) {
200 header(
"Location: ".$backtopageforcancel);
202 } elseif (!empty($backtopage)) {
203 header(
"Location: ".$backtopage);
210 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
213 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
215 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
217 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
226 if ($action ==
'add' && $usercancreate) {
227 if (!
GETPOST(
'title',
'alphanohtml')) {
228 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Title")),
null,
'errors');
243 if (empty($reyear) || empty($remonth) || empty($reday)) {
244 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Date")),
null,
'errors');
267 $object->rule_for_lines_dates =
GETPOST(
'rule_for_lines_dates',
'alpha');
269 $object->frequency = $frequency;
271 $object->nb_gen_max = $nb_gen_max;
275 $object->fk_project = $projectid;
277 $date_next_execution =
dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
278 $object->date_when = $date_next_execution;
280 $ret = $extrafields->setOptionalsFromPost(
null, $object);
282 setEventMessages($extrafields->error, $extrafields->errors,
'errors');
291 $srcObject->fetchObjectLinked();
293 if (!empty($srcObject->linkedObjectsIds[
'contrat'])) {
294 $contractidid = reset($srcObject->linkedObjectsIds[
'contrat']);
296 $object->origin_type =
'contrat';
297 $object->origin_id = $contractidid;
299 } elseif (!empty($srcObject->linkedObjectsIds[
'commande'])) {
300 $orderid = reset($srcObject->linkedObjectsIds[
'commande']);
302 $object->linked_objects[
'commande'] = $orderid;
303 } elseif (!empty($srcObject->linkedObjectsIds[
'propal'])) {
304 $proposalid = reset($srcObject->linkedObjectsIds[
'propal']);
305 $object->linked_objects[
'propal'] = $proposalid;
311 $oldinvoice =
new Facture($db);
314 $onlylines =
GETPOST(
'toselect',
'array:int');
316 $result =
$object->create($user, $oldinvoice->id, 0, $onlylines);
318 $result = $oldinvoice->delete($user, 1);
321 setEventMessages($oldinvoice->error, $oldinvoice->errors,
'errors');
333 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?facid='.
$object->id);
344 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'facture',
'supprimer')) {
346 $result =
$object->delete($user);
348 header(
"Location: ".DOL_URL_ROOT.
'/compta/facture/invoicetemplate_list.php');
357 if ($action ==
'setconditions' && $usercancreate) {
359 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModified", $langs->transnoentitiesnoconv(
"PaymentTerm"));
361 } elseif ($action ==
'setmode' && $usercancreate) {
363 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModified", $langs->transnoentitiesnoconv(
"PaymentMode"));
365 $object->setValueFrom(
'fk_societe_rib', 0);
368 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?facid='.
$object->id);
370 } elseif ($action ==
'classin' && $usercancreate) {
372 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModified", $langs->transnoentitiesnoconv(
"Project"));
374 } elseif ($action ==
'setref' && $usercancreate) {
376 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModifiedFromYToZ", $langs->transnoentitiesnoconv(
"Title"),
$object->title, $ref);
377 $result =
$object->setValueFrom(
'titre', $ref,
'',
null,
'text',
'', $user,
'BILLREC_MODIFY');
383 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
384 $langs->load(
"errors");
385 setEventMessages($langs->trans(
'ErrorRefAlreadyExists', $ref),
null,
'errors');
390 } elseif ($action ==
'setbankaccount' && $usercancreate) {
392 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModified", $langs->transnoentitiesnoconv(
"Bank"));
394 } elseif ($action ==
'setbankaccountcustomer' && $usercancreate) {
396 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModified", $langs->transnoentitiesnoconv(
"DebitBankAccount"));
397 $fk_societe_rib = (
GETPOSTINT(
'accountcustomerid') !=
"-1") ?
GETPOSTINT(
'accountcustomerid') : 0;
398 $result =
$object->setValueFrom(
'fk_societe_rib', $fk_societe_rib);
399 } elseif ($action ==
'setfrequency' && $usercancreate) {
401 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModified", $langs->transnoentitiesnoconv(
"Frequency"));
403 } elseif ($action ==
'setdate_when' && $usercancreate) {
409 } elseif ($action ==
'setnb_gen_max' && $usercancreate) {
412 } elseif ($action ==
'setauto_validate' && $usercancreate) {
415 } elseif ($action ==
'setEmailTemplate' && $usercancreate) {
418 } elseif ($action ==
'setgenerate_pdf' && $usercancreate) {
421 } elseif ($action ==
'setmodelpdf' && $usercancreate) {
424 } elseif ($action ==
'disable' && $usercancreate) {
428 $object->context[
'actionmsg'] = $langs->trans(
"RecordDisabled");
430 $res =
$object->setValueFrom(
'suspended', 1,
'',
null,
'text',
'', $user,
'BILLREC_MODIFY');
441 } elseif ($action ==
'enable' && $usercancreate) {
445 $object->context[
'actionmsg'] = $langs->trans(
"RecordEnabled");
447 $res =
$object->setValueFrom(
'suspended', 0,
'',
null,
'text',
'', $user,
'BILLREC_MODIFY');
458 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
460 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
462 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
464 if (!in_array(
GETPOSTINT(
'calculation_mode'), array(1, 2))) {
465 $langs->load(
"compta");
466 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CalculationMode")),
null,
'errors');
467 $action =
'editmulticurrencyrate';
472 } elseif ($action ==
'setruleforlinesdates' && $usercancreate) {
473 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModified", $langs->transnoentitiesnoconv(
"RuleForLinesDates"));
474 $ruleForLinesDates =
GETPOSTISSET(
'rule_for_lines_dates') ?
GETPOST(
'rule_for_lines_dates',
'alpha') :
'prepaid';
475 $object->setValueFrom(
'rule_for_lines_dates', $ruleForLinesDates);
479 if ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
490 if ($line->delete($user) > 0) {
491 $result =
$object->update_price(1);
498 setEventMessages($db->lasterror(),
null,
'errors');
502 setEventMessages($line->error, $line->errors,
'errors');
504 } elseif ($action ==
'confirm_delete_subtotalline' && $confirm ==
'yes' && $usercancreate) {
509 $result =
$object->deleteSubtotalLine($langs,
GETPOSTINT(
'lineid'), (
bool)
GETPOST(
'deletecorrespondingsubtotalline'), $user);
511 $result =
$object->update_price(1);
516 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
520 setEventMessages($db->lasterror(),
null,
'errors');
526 } elseif ($action ==
'update_extras' && $permissiontoeditextra) {
529 $attribute_name =
GETPOST(
'attribute',
'aZ09');
532 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
538 $result =
$object->updateExtraField($attribute_name,
'BILLREC_MODIFY');
546 $action =
'edit_extras';
551 if ($action ==
'addline' && $usercancreate) {
552 $langs->load(
'errors');
560 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'alpha');
561 if ($prod_entry_mode ==
'free') {
567 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
572 $tva_tx = (
GETPOST(
'tva_tx',
'alpha') ?
GETPOST(
'tva_tx',
'alpha') : 0);
576 if (empty($remise_percent)) {
581 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
582 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
584 if (is_array($extralabelsline)) {
586 foreach ($extralabelsline as $key => $value) {
587 unset($_POST[
"options_".$key.$predef]);
591 if ((empty($idprod) || $idprod < 0) && ($price_ht < 0) && ((
float) $qty < 0)) {
592 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPriceHT'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
595 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
596 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
599 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && (!($price_ht >= 0) || $price_ht ==
'')) {
600 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")),
null,
'errors');
604 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
607 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
608 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
612 $langs->load(
"errors");
613 setEventMessages($langs->trans(
'ErrorQtyForCustomerInvoiceCantBeNegative'),
null,
'errors');
617 if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) {
620 dol_print_error($db,
$object->error);
623 $ret =
$object->fetch_thirdparty();
628 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
639 if (!empty($idprod) && $idprod > 0) {
641 $prod->fetch($idprod);
643 $label = ((
GETPOST(
'product_label') &&
GETPOST(
'product_label') != $prod->label) ?
GETPOST(
'product_label') :
'');
655 $datapriceofproduct = $prod->getSellPrice(
$mysoc,
$object->thirdparty, $pqp);
657 $pu_ht = $datapriceofproduct[
'pu_ht'];
658 $pu_ttc = $datapriceofproduct[
'pu_ttc'];
659 $price_min = $datapriceofproduct[
'price_min'];
660 $price_base_type = empty($datapriceofproduct[
'price_base_type']) ?
'HT' : $datapriceofproduct[
'price_base_type'];
664 $tmpvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
665 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string) $prod->tva_tx));
668 if (!empty($price_ht)) {
670 $pu_ttc =
price2num((
float) $pu_ht * (1 + ($tmpvat / 100)),
'MU');
671 } elseif ($tmpvat != $tmpprodvat) {
674 if ($price_base_type !=
'HT') {
675 $pu_ht =
price2num((
float) $pu_ttc / (1 + ($tmpvat / 100)),
'MU');
677 $pu_ttc =
price2num((
float) $pu_ht * (1 + ($tmpvat / 100)),
'MU');
681 $outputlangs = $langs;
687 if (
GETPOST(
'lang_id',
'aZ09')) {
688 $newlang =
GETPOST(
'lang_id',
'aZ09');
690 if (empty($newlang)) {
691 $newlang =
$object->thirdparty->default_lang;
693 if (!empty($newlang)) {
695 $outputlangs->setDefaultLang($newlang);
696 $outputlangs->load(
'products');
699 $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] [
"description"])) ? $prod->multilangs [$outputlangs->defaultlang] [
"description"] : $prod->
description;
701 $desc = $prod->description;
705 if (!
getDolGlobalString(
'MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE') && (!empty($prod->customcode) || !empty($prod->country_code))) {
709 if (!empty($prod->customcode)) {
710 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomsCode").
': '.$prod->customcode;
712 if (!empty($prod->customcode) && !empty($prod->country_code)) {
715 if (!empty($prod->country_code)) {
716 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code,
'', $db, $outputlangs, 0);
719 if (!empty($prod->customcode)) {
720 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomsCode").
': '.$prod->customcode;
722 if (!empty($prod->customcode) && !empty($prod->country_code)) {
725 if (!empty($prod->country_code)) {
726 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code,
'', $db, $langs, 0);
734 $fk_unit = $prod->fk_unit;
738 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
739 $tva_tx = str_replace(
'*',
'', $tva_tx);
740 if (empty($tva_tx)) {
743 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
744 $desc = $product_desc;
749 $date_start_fill =
GETPOSTINT(
'date_start_fill');
753 $fournprice = (int) (
GETPOST(
'fournprice'.$predef) ?
GETPOST(
'fournprice'.$predef) :
'');
765 $fk_parent_line =
GETPOSTINT(
'fk_parent_line');
767 if ($usercanproductignorepricemin && (!empty($price_min) && ((
float)
price2num($pu_ht) * (1 - (
float)
price2num($remise_percent) / 100) < (
float)
price2num($price_min)))) {
768 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
769 setEventMessages($mesg,
null,
'errors');
772 $result =
$object->addline($desc, $pu_ht, (
float) $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, 0, $pu_ttc, $type, -1, $special_code, $label, (
int) $fk_unit, 0, $date_start_fill, $date_end_fill, (
int) $fournprice, (
float) $buyingprice, $fk_parent_line);
777 if ($objectline->fetch($result)) {
778 $objectline->array_options = $array_options;
779 $result = $objectline->insertExtraFields();
781 setEventMessages($langs->trans(
'Error').$result,
null,
'errors');
805 unset($_POST[
'prod_entry_mode']);
807 unset($_POST[
'qty']);
808 unset($_POST[
'type']);
809 unset($_POST[
'remise_percent']);
810 unset($_POST[
'price_ht']);
811 unset($_POST[
'multicurrency_price_ht']);
812 unset($_POST[
'price_ttc']);
813 unset($_POST[
'tva_tx']);
814 unset($_POST[
'product_ref']);
815 unset($_POST[
'product_label']);
816 unset($_POST[
'product_desc']);
817 unset($_POST[
'fournprice']);
818 unset($_POST[
'buying_price']);
819 unset($_POST[
'np_marginRate']);
820 unset($_POST[
'np_markRate']);
821 unset($_POST[
'dp_desc']);
822 unset($_POST[
'idprod']);
823 unset($_POST[
'units']);
825 unset($_POST[
'date_starthour']);
826 unset($_POST[
'date_startmin']);
827 unset($_POST[
'date_startsec']);
828 unset($_POST[
'date_startday']);
829 unset($_POST[
'date_startmonth']);
830 unset($_POST[
'date_startyear']);
831 unset($_POST[
'date_endhour']);
832 unset($_POST[
'date_endmin']);
833 unset($_POST[
'date_endsec']);
834 unset($_POST[
'date_endday']);
835 unset($_POST[
'date_endmonth']);
836 unset($_POST[
'date_endyear']);
838 unset($_POST[
'date_start_fill']);
839 unset($_POST[
'date_end_fill']);
841 unset($_POST[
'situations']);
842 unset($_POST[
'progress']);
850 } elseif ($action ==
'confirm_addtextline' && $usercancreate) {
853 $langs->load(
'subtotals');
855 $desc =
GETPOST(
'subtotaltextcontent',
'restricthtml');
858 $result =
$object->addSubtotalLine($langs, $desc, 0, array());
869 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
871 } elseif ($action ==
'confirm_addtitleline' && $usercancreate) {
874 $langs->load(
'subtotals');
876 $desc =
GETPOST(
'subtotallinedesc',
'alphanohtml');
877 $depth =
GETPOSTINT(
'subtotallinelevel') ?? 1;
879 $subtotal_options = array();
881 foreach (FactureRec::$TITLE_OPTIONS as $option) {
882 $value =
GETPOST($option,
'alphanohtml');
884 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
889 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
900 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
902 } elseif ($action ==
'confirm_addsubtotalline' && $usercancreate) {
905 $langs->load(
'subtotals');
907 $choosen_line =
GETPOST(
'subtotaltitleline',
'alphanohtml');
908 foreach (
$object->lines as $line) {
909 if ($line->desc == $choosen_line && $line->special_code == SUBTOTALS_SPECIAL_CODE) {
911 $depth = -$line->qty;
915 $subtotal_options = array();
917 foreach (FactureRec::$SUBTOTAL_OPTIONS as $option) {
918 $value =
GETPOST($option,
'alphanohtml');
920 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
925 if (isset($desc) && isset($depth)) {
926 $result =
$object->addSubtotalLine($langs, $desc, (
int) $depth, $subtotal_options);
929 $object->errors[] = $langs->trans(
"CorrespondingTitleNotFound");
938 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
940 } elseif ($action ==
'updateline' && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
941 if (!
$object->fetch($id) > 0) {
942 dol_print_error($db);
964 if (preg_match(
'/\*/', $vat_rate)) {
969 $vat_rate = str_replace(
'*',
'', $vat_rate);
974 $fournprice = (int) (
GETPOST(
'fournprice') ?
GETPOST(
'fournprice') :
'');
978 $pu_equivalent = $pu_ht;
979 $pu_equivalent_ttc = $pu_ttc;
981 $currency_tx =
$object->multicurrency_tx;
985 if ($pu_ht ==
'' && $pu_ht_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
986 $pu_equivalent = (float) $pu_ht_devise / (
float) $currency_tx;
988 if ($pu_ttc ==
'' && $pu_ttc_devise !=
'' && $currency_tx !=
'' && !empty((
float) $currency_tx)) {
989 $pu_equivalent_ttc = (float) $pu_ttc_devise / (
float) $currency_tx;
1004 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1005 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1008 if ($objectline->fetch(
GETPOSTINT(
'lineid'))) {
1009 $objectline->array_options = $array_options;
1010 $result = $objectline->insertExtraFields();
1012 setEventMessages($langs->trans(
'Error').$result,
null,
'errors');
1015 $position = ($objectline->rang >= 0 ? $objectline->rang : 0);
1018 if (is_array($extralabelsline)) {
1020 foreach ($extralabelsline as $key => $value) {
1021 unset($_POST[
"options_".$key]);
1027 if ($special_code == 3) {
1040 if (empty($remise_percent)) {
1041 $remise_percent = 0;
1044 $price_base_type =
'HT';
1046 if (empty($pu) && !empty($pu_ttc)) {
1048 $price_base_type =
'TTC';
1053 if (
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' &&
GETPOST(
'multicurrency_subprice') ===
'' &&
GETPOST(
'multicurrency_price_ttc') !==
'') {
1055 $price_base_type =
'TTC';
1056 $pu_ht_devise = $pu_ttc_devise;
1061 if (!empty($productid)) {
1063 $product->fetch($productid);
1065 $type = $product->type;
1067 $price_min = $product->price_min;
1069 $price_min = $product->multiprices_min[
$object->thirdparty->price_level];
1071 $price_min_ttc = $product->price_min_ttc;
1073 $price_min_ttc = $product->multiprices_min_ttc[
$object->thirdparty->price_level];
1082 if ($pu_equivalent && $price_min && (((
float)
price2num($pu_equivalent) * (1 - (
float) $remise_percent / 100)) < (float)
price2num($price_min)) && $price_base_type ==
'HT') {
1083 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1084 setEventMessages($mesg,
null,
'errors');
1086 $action =
'editline';
1087 } elseif ($pu_equivalent_ttc && $price_min_ttc && (((
float)
price2num($pu_equivalent_ttc) * (1 - (
float) $remise_percent / 100)) < (
float)
price2num($price_min_ttc)) && $price_base_type ==
'TTC') {
1088 $mesg = $langs->trans(
"CantBeLessThanMinPriceInclTax",
price(
price2num($price_min_ttc,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
1089 setEventMessages($mesg,
null,
'errors');
1091 $action =
'editline';
1096 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1100 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1105 $langs->load(
"errors");
1106 setEventMessages($langs->trans(
'ErrorQtyForCustomerInvoiceCantBeNegative'),
null,
'errors');
1110 $date_start_fill =
GETPOSTINT(
'date_start_fill');
1111 $date_end_fill =
GETPOSTINT(
'date_end_fill');
1112 $fk_parent_line =
GETPOST(
'fk_parent_line',
'int');
1116 $result =
$object->updateline(
1135 (
float) $pu_ht_devise,
1140 (
float) $buyingprice,
1141 (
int) $fk_parent_line
1165 unset($_POST[
'qty']);
1166 unset($_POST[
'type']);
1167 unset($_POST[
'productid']);
1168 unset($_POST[
'remise_percent']);
1169 unset($_POST[
'price_ht']);
1170 unset($_POST[
'multicurrency_price_ht']);
1171 unset($_POST[
'price_ttc']);
1172 unset($_POST[
'tva_tx']);
1173 unset($_POST[
'product_ref']);
1174 unset($_POST[
'product_label']);
1175 unset($_POST[
'product_desc']);
1176 unset($_POST[
'fournprice']);
1177 unset($_POST[
'buying_price']);
1178 unset($_POST[
'np_marginRate']);
1179 unset($_POST[
'np_markRate']);
1181 unset($_POST[
'dp_desc']);
1182 unset($_POST[
'idprod']);
1183 unset($_POST[
'units']);
1185 unset($_POST[
'date_starthour']);
1186 unset($_POST[
'date_startmin']);
1187 unset($_POST[
'date_startsec']);
1188 unset($_POST[
'date_startday']);
1189 unset($_POST[
'date_startmonth']);
1190 unset($_POST[
'date_startyear']);
1191 unset($_POST[
'date_endhour']);
1192 unset($_POST[
'date_endmin']);
1193 unset($_POST[
'date_endsec']);
1194 unset($_POST[
'date_endday']);
1195 unset($_POST[
'date_endmonth']);
1196 unset($_POST[
'date_endyear']);
1198 unset($_POST[
'situations']);
1199 unset($_POST[
'progress']);
1204 } elseif ($action ==
'updatetitleline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1207 $langs->load(
'subtotals');
1209 $desc =
GETPOST(
'line_desc',
'alphanohtml') ?? $langs->trans(
"Title");
1212 $subtotal_options = array();
1214 foreach (Facture::$TITLE_OPTIONS as $option) {
1215 $value =
GETPOST($option,
'alphanohtml');
1217 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1222 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1233 } elseif ($action ==
'updatetextline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1236 $langs->load(
'subtotals');
1238 $desc =
GETPOST(
'line_desc',
'restricthtml');
1241 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, 0, array());
1252 } elseif ($action ==
'updatesubtotalline' &&
GETPOSTISSET(
"save") && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
1255 $langs->load(
'subtotals');
1257 $desc =
GETPOST(
'line_desc',
'alphanohtml');
1260 $subtotal_options = array();
1262 foreach (Facture::$SUBTOTAL_OPTIONS as $option) {
1263 $value =
GETPOST($option,
'alphanohtml');
1265 $subtotal_options[$option] = $value ==
'on' ? 1 : $value;
1270 $result =
$object->updateSubtotalLine($langs,
GETPOSTINT(
'lineid'), $desc, $depth, $subtotal_options);
1286$title =
$object->ref.
" - ".$langs->trans(
'Card');
1291$form =
new Form($db);
1296 $formproject =
null;
1298$companystatic =
new Societe($db);
1306if ($action ==
'create') {
1307 print
load_fiche_titre($langs->trans(
"CreateRepeatableInvoice"),
'',
'bill');
1309 $sourceInvoice =
new Facture($db);
1311 $product_static =
new Product($db);
1313 if ($sourceInvoice->fetch($id, $ref) > 0) {
1314 $result = $sourceInvoice->getLinesArray();
1316 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1317 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1318 print
'<input type="hidden" name="action" value="add">';
1319 print
'<input type="hidden" name="facid" value="'.$sourceInvoice->id.
'">';
1328 if ($sourceInvoice->fk_account > 0) {
1332 print
'<table class="border centpercent">';
1334 $sourceInvoice->fetch_thirdparty();
1337 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Title").
'</td><td>';
1338 print
'<input class="flat quatrevingtpercent" type="text" name="title" value="'.dol_escape_htmltag(
GETPOST(
"title",
'alphanohtml')).
'" autofocus>';
1342 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Customer").
'</td><td>'.$sourceInvoice->thirdparty->getNomUrl(1,
'customer').
'</td>';
1347 print
"<tr><td>".$langs->trans(
"InvoiceSubtype").
"</td><td>";
1348 print $form->getSelectInvoiceSubtype(
GETPOSTISSET(
'subtype') ?
GETPOSTINT(
'subtype') : $sourceInvoice->subtype,
'subtype', 0, 0,
'');
1352 $note_public =
GETPOSTISSET(
'note_public') ?
GETPOST(
'note_public',
'restricthtml') : $sourceInvoice->note_public;
1353 $note_private =
GETPOSTISSET(
'note_private') ?
GETPOST(
'note_private',
'restricthtml') : $sourceInvoice->note_private;
1356 $substitutionarray = getCommonSubstitutionArray($langs, 2,
null, $sourceInvoice);
1358 $substitutionarray[
'__INVOICE_PREVIOUS_MONTH__'] = $langs->trans(
"PreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($sourceInvoice->date, -1,
'm'),
'%m').
')';
1359 $substitutionarray[
'__INVOICE_MONTH__'] = $langs->trans(
"MonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($sourceInvoice->date,
'%m').
')';
1360 $substitutionarray[
'__INVOICE_NEXT_MONTH__'] = $langs->trans(
"NextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($sourceInvoice->date, 1,
'm'),
'%m').
')';
1361 $substitutionarray[
'__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans(
"TextPreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($sourceInvoice->date, -1,
'm'),
'%B').
')';
1362 $substitutionarray[
'__INVOICE_MONTH_TEXT__'] = $langs->trans(
"TextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($sourceInvoice->date,
'%B').
')';
1363 $substitutionarray[
'__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans(
"TextNextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($sourceInvoice->date, 1,
'm'),
'%B').
')';
1364 $substitutionarray[
'__INVOICE_PREVIOUS_YEAR__'] = $langs->trans(
"PreviousYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($sourceInvoice->date, -1,
'y'),
'%Y').
')';
1365 $substitutionarray[
'__INVOICE_YEAR__'] = $langs->trans(
"YearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($sourceInvoice->date,
'%Y').
')';
1366 $substitutionarray[
'__INVOICE_NEXT_YEAR__'] = $langs->trans(
"NextYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($sourceInvoice->date, 1,
'y'),
'%Y').
')';
1368 $substitutionarray[
'__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans(
"DateNextInvoiceBeforeGen").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($sourceInvoice->date, 1,
'm'),
'dayhour').
')';
1369 $substitutionarray[
'__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans(
"DateNextInvoiceAfterGen").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($sourceInvoice->date, 2,
'm'),
'dayhour').
')';
1370 $substitutionarray[
'__INVOICE_COUNTER_CURRENT__'] = $langs->trans(
"Count");
1371 $substitutionarray[
'__INVOICE_COUNTER_MAX__'] = $langs->trans(
"MaxPeriodNumber");
1373 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
1374 foreach ($substitutionarray as $key => $val) {
1375 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
1377 $htmltext .=
'</i>';
1380 print
"<tr><td>".$langs->trans(
"Author").
"</td><td>".$user->getFullName($langs).
"</td></tr>";
1383 print
"<tr><td>".$langs->trans(
"PaymentConditions").
"</td><td>";
1384 print $form->getSelectConditionsPaiements(
GETPOSTISSET(
'cond_reglement_id') ?
GETPOSTINT(
'cond_reglement_id') : $sourceInvoice->cond_reglement_id,
'cond_reglement_id', -1, 0, 0,
'');
1389 print
"<tr><td>".$langs->trans(
"PaymentMode").
"</td><td>";
1390 print img_picto(
'',
'payment',
'class="pictofixedwidth"');
1391 print $form->select_types_paiements((
string) (
GETPOSTISSET(
'mode_reglement_id') ?
GETPOSTINT(
'mode_reglement_id') : $sourceInvoice->mode_reglement_id),
'mode_reglement_id',
'', 0, 1, 0, 0, 1,
'', 1);
1396 print
"<tr><td>".$langs->trans(
'DebitBankAccount').
"</td><td>";
1397 $defaultRibId = $sourceInvoice->thirdparty->getDefaultRib();
1398 $form->selectRib(
GETPOSTISSET(
'accountcustomerid') ?
GETPOSTINT(
'accountcustomerid') : $defaultRibId,
'accountcustomerid',
'(fk_soc:=:'.$sourceInvoice->socid.
")", 1,
'', 1);
1402 $(document).ready(function() {
1403 if($("#selectmode_reglement_id option:selected").data("code") != "' . $factureRec::PAYMENTCODETOEDITSOCIETERIB .
'") {
1404 hideselectfksocieterib();
1406 $("#selectmode_reglement_id").change(function() {
1407 if($("#selectmode_reglement_id option:selected").data("code") != "'. $factureRec::PAYMENTCODETOEDITSOCIETERIB .
'") {
1408 hideselectfksocieterib(1);
1410 showselectfksocieterib();
1415 function hideselectfksocieterib(empty = 0){
1416 $("#selectaccountcustomerid").closest("tr").hide();
1418 $("#selectaccountcustomerid").val("-1").change();
1422 function showselectfksocieterib(){
1423 $("#selectaccountcustomerid").closest("tr").show();
1428 if ($sourceInvoice->fk_account > 0) {
1429 print
"<tr><td>".$langs->trans(
'BankAccount').
"</td><td>";
1430 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.$sourceInvoice->id, (
string) $sourceInvoice->fk_account,
'none');
1436 print
"<tr><td>".$langs->trans(
"RuleForLinesDates").
"</td><td>";
1437 print $form->getSelectRuleForLinesDates(
GETPOSTISSET(
'rule_for_lines_dates') ?
GETPOST(
'rule_for_lines_dates',
'alpha') : $factureRec->rule_for_lines_dates);
1445 $extralabels = $extrafields->fetch_name_optionals_label($draft->table_element);
1446 if ($draft->fetch_optionals() > 0) {
1447 $sourceInvoice->array_options = array_merge($sourceInvoice->array_options, $draft->array_options);
1450 print $sourceInvoice->showOptionals($extrafields,
'create', $parameters);
1453 if (
isModEnabled(
'project') && is_object($sourceInvoice->thirdparty) && $sourceInvoice->thirdparty->id > 0 && is_object($formproject)) {
1454 $projectid =
GETPOST(
'projectid') ?
GETPOST(
'projectid') : $sourceInvoice->fk_project;
1455 $langs->load(
'projects');
1456 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td>';
1457 print img_picto(
'',
'project',
'class="pictofixedwidth"');
1458 $numprojet = $formproject->select_projects($sourceInvoice->thirdparty->id, $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 0, 0,
'');
1459 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.$sourceInvoice->thirdparty->id.
'&action=create&status=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create&socid='.$sourceInvoice->thirdparty->id.(!empty($id) ?
'&id='.$id :
'')).
'">'.img_object($langs->trans(
"AddProject"),
'add').
'</a>';
1464 print
"<tr><td>".$langs->trans(
'Model').
"</td><td>";
1465 include_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
1467 print img_picto(
'',
'generic',
'class="pictofixedwidth"');
1469 print $form->selectarray(
'modelpdf', $list,
$conf->global->FACTURE_ADDON_PDF);
1474 print
'<td class="tdtop">';
1475 print $form->textwithpicto($langs->trans(
'NotePublic'), $htmltext, 1,
'help',
'', 0, 2,
'notepublic');
1478 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1479 print $doleditor->Create(1);
1482 if (empty($user->socid)) {
1484 print
'<td class="tdtop">';
1485 print $form->textwithpicto($langs->trans(
'NotePrivate'), $htmltext, 1,
'help',
'', 0, 2,
'noteprivate');
1488 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1489 print $doleditor->Create(1);
1499 $title = $langs->trans(
"Recurrence");
1500 print
load_fiche_titre(img_picto(
'',
'recurring',
'class="pictofixedwidth"').$title,
'',
'');
1502 print
'<span class="opacitymedium">'.$langs->trans(
"ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv(
'Module2300Name')).
'</span><br><br>';
1506 print
'<table class="border centpercent">';
1509 print
'<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans(
"Frequency"), $langs->transnoentitiesnoconv(
'toolTipFrequency')).
"</td><td>";
1510 print
'<input type="text" class="width50" name="frequency" value="'.GETPOST(
'frequency',
'int').
'"> ';
1511 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'));
1515 print
"<tr><td>".$form->textwithpicto($langs->trans(
'NextDateToExecution'), $langs->trans(
"NextDateToExecutionHelp")).
"</td><td>";
1517 print $form->selectDate($date_next_execution,
'', 1, 1, 0,
"add", 1, 1);
1521 print
"<tr><td>".$langs->trans(
"MaxPeriodNumber").
"</td><td>";
1522 print
'<input type="text" class="width50" name="nb_gen_max" value="'.GETPOSTINT(
'nb_gen_max').
'">';
1526 print
"<tr><td>".$langs->trans(
"StatusOfAutoGeneratedInvoices").
"</td><td>";
1527 $select = array(
'0' => $langs->trans(
'BillStatusDraft'),
'1' => $langs->trans(
'BillStatusValidated'),
'2' => $langs->trans(
'BillStatusValidatedWithSendind'));
1528 print $form->selectarray(
'auto_validate', $select,
GETPOSTINT(
'auto_validate'));
1532 print
"<tr id='col_auto_send_model_mail' class='".(GETPOSTINT(
'auto_validate') != 2 ?
'hidden' :
'').
"'><td>" . $langs->trans(
"EmailTemplateForAutoSend") .
"</td><td>";
1533 print $form->selectModelMail(
"auto_send_",
"facture_send", 1, 0,
GETPOSTINT(
'auto_send_model_mail'));
1536 $(document).ready(function() {
1537 $('#auto_validate').on('change', function () {
1538 if(+$(this).val() === 2) {
1539 $('#col_auto_send_model_mail').show();
1541 $('#col_auto_send_model_mail').hide();
1542 $('#select_auto_send_model_mail').val(0);
1550 print
"<tr><td>".$langs->trans(
"StatusOfGeneratedDocuments").
"</td><td>";
1551 $select = array(
'0' => $langs->trans(
'DoNotGenerateDoc'),
'1' => $langs->trans(
'AutoGenerateDoc'));
1552 print $form->selectarray(
'generate_pdf', $select,
GETPOSTINT(
'generate_pdf'));
1555 print
'<input type="hidden" name="generate_pdf" value="1">';
1563 $title = $langs->trans(
"ProductsAndServices");
1565 $title = $langs->trans(
"Products");
1567 $title = $langs->trans(
"Services");
1575 print
'<div class="div-table-responsive-no-min">';
1576 print
'<table id="tablelines" class="noborder noshadow centpercent nomarginbottom">';
1579 if (!empty($sourceInvoice->lines)) {
1580 $sourceInvoice->printOriginLinesList(
'', $selectedLines);
1589 if (!empty($flag_price_may_change)) {
1590 print
'<tr><td colspan="3" class="left">';
1591 print
'<select name="usenewprice" class="flat">';
1592 print
'<option value="0">'.$langs->trans(
"AlwaysUseFixedPrice").
'</option>';
1593 print
'<option value="1" disabled>'.$langs->trans(
"AlwaysUseNewPrice").
'</option>';
1601 print $form->buttonsSaveCancel(
"Create");
1605 dol_print_error(
null,
"Error, no invoice ".$sourceInvoice->id);
1614 if ($action ==
'ask_deleteline') {
1615 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'',
'no', 1);
1618 if ($action ==
'delete') {
1619 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteRepeatableInvoice'), $langs->trans(
'ConfirmDeleteRepeatableInvoice'),
'confirm_delete',
'',
'no', 1);
1622 if ($action ==
'ask_subtotal_deleteline') {
1623 $langs->load(
"subtotals");
1624 $title =
"DeleteSubtotalLine";
1625 $question =
"ConfirmDeleteSubtotalLine";
1626 if (
GETPOST(
'type') ==
'title') {
1627 $formconfirm = array(array(
'type' =>
'checkbox',
'name' =>
'deletecorrespondingsubtotalline',
'label' => $langs->trans(
"DeleteCorrespondingSubtotalLine"),
'value' => 0));
1628 $title =
"DeleteTitleLine";
1629 $question =
"ConfirmDeleteTitleLine";
1631 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans($title), $langs->trans($question),
'confirm_delete_subtotalline', $formconfirm,
'no', 1);
1635 if ($action ==
'add_title_line') {
1636 $langs->load(
'subtotals');
1638 $depth_array =
$object->getPossibleLevels($langs);
1640 } elseif ($action ==
'add_subtotal_line') {
1641 $langs->load(
'subtotals');
1643 $titles =
$object->getPossibleTitles();
1645 } elseif ($action ==
'add_text_line') {
1646 $langs->load(
'subtotals');
1652 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
1653 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1654 if (empty($reshook)) {
1655 $formconfirm .= $hookmanager->resPrint;
1656 } elseif ($reshook > 0) {
1657 $formconfirm = $hookmanager->resPrint;
1662 $author =
new User($db);
1663 $author->fetch(
$object->user_creation_id);
1671 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/facture/invoicetemplate_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1674 if ($action !=
'editref') {
1675 $morehtmlref .= $form->editfieldkey(
$object->ref,
'ref',
$object->ref, $object, $user->hasRight(
'facture',
'creer'),
'',
'', 0, 2);
1677 $morehtmlref .= $form->editfieldval(
'',
'ref',
$object->ref, $object, $user->hasRight(
'facture',
'creer'),
'string');
1680 $morehtmlref .=
'<div class="refidno">';
1685 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'customer');
1688 $langs->load(
"projects");
1689 $morehtmlref .=
'<br>';
1690 if ($user->hasRight(
'facture',
'creer')) {
1691 $morehtmlref .= img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
1692 if ($action !=
'classify') {
1693 $morehtmlref .=
'<a class="editfielda" href="'.dolBuildUrl($_SERVER[
'PHP_SELF'], [
'action' =>
'classify',
'id' =>
$object->id],
true).
'">'.img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
1695 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid, (
string)
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
1697 if (!empty(
$object->fk_project)) {
1699 $proj->fetch(
$object->fk_project);
1700 $morehtmlref .=
' : '.$proj->getNomUrl(1);
1702 $morehtmlref .=
' - '.$proj->title;
1709 $morehtmlref .=
'</div>';
1711 $morehtmlstatus =
'';
1713 dol_banner_tab($object,
'ref', $linkback, 1,
'title',
'none', $morehtmlref,
'', 0,
'', $morehtmlstatus);
1715 print
'<div class="fichecenter">';
1716 print
'<div class="fichehalfleft">';
1717 print
'<div class="underbanner clearboth"></div>';
1719 print
'<table class="border centpercent tableforfield">';
1723 print
"<tr><td>".$langs->trans(
"InvoiceSubtype").
"</td><td>";
1725 print
$object->getSubtypeLabel(
'facture_rec');
1731 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"Author").
'</td><td>';
1732 print $author->getNomUrl(-1);
1737 print
'<table class="nobordernopadding centpercent"><tr><td>';
1738 print $langs->trans(
'PaymentConditionsShort');
1740 if ($action !=
'editconditions' && $user->hasRight(
'facture',
'creer')) {
1741 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>';
1743 print
'</tr></table>';
1745 if ($action ==
'editconditions') {
1746 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id');
1748 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id, (
string)
$object->cond_reglement_id,
'none');
1754 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1755 print $langs->trans(
'PaymentMode');
1757 if ($action !=
'editmode' && $user->hasRight(
'facture',
'creer')) {
1758 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>';
1760 print
'</tr></table>';
1762 if ($action ==
'editmode') {
1763 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
1765 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
1771 if (
$object->mode_reglement_code == $object::PAYMENTCODETOEDITSOCIETERIB) {
1772 print
'<tr><td class="nowrap">';
1773 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1774 print $langs->trans(
'DebitBankAccount');
1778 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>';
1780 print
'</tr></table>';
1783 if ($action ==
'editbankaccountcustomer') {
1784 $form->formRib($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_societe_rib,
'accountcustomerid',
'fk_soc='.$object->socid, 1, 1);
1786 $form->formRib($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_societe_rib,
'none',
'', 0, 1);
1793 print
'<tr><td class="nowrap">';
1794 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1795 print $langs->trans(
'BankAccount');
1798 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>';
1800 print
'</tr></table>';
1802 if ($action ==
'editbankaccount') {
1803 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
1805 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'none');
1813 print
'<table class="nobordernopadding centpercent"><tr><td>';
1814 print $langs->trans(
'RuleForLinesDates');
1816 if ($action !=
'editruleforlinesdates' && $user->hasRight(
'facture',
'creer')) {
1817 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editruleforlinesdates&token='.
newToken().
'&facid='.
$object->id.
'">'.img_edit($langs->trans(
'SetRuleForLinesDates'), 1).
'</a></td>';
1819 print
'</tr></table>';
1821 if ($action ==
'editruleforlinesdates') {
1822 $form->form_rule_for_lines_dates($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id,
$object->rule_for_lines_dates,
'rule_for_lines_dates');
1824 $form->form_rule_for_lines_dates($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id,
$object->rule_for_lines_dates,
'none');
1830 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1833 print
'<tr><td class="nowrap">';
1834 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
1835 print $langs->trans(
'Model');
1838 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>';
1840 print
'</tr></table>';
1842 if ($action ==
'editmodelpdf') {
1843 include_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
1846 foreach ($models as $k => $model) {
1847 $list[] = str_replace(
':',
'|', $k).
':'.$model;
1849 $select =
'select;'.implode(
',', $list);
1850 print $form->editfieldval($langs->trans(
"Model"),
'modelpdf',
$object->model_pdf, $object, $user->hasRight(
'facture',
'creer'), $select);
1864 print
'<div class="fichehalfright">';
1866 print
'<!-- amounts -->'.
"\n";
1867 print
'<div class="underbanner clearboth"></div>'.
"\n";
1870 $title = $langs->trans(
"Recurrence");
1872 print
'<table class="border tableforfield centpercent">';
1874 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
1882 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"AmountHT").
'</td>';
1883 print
'<td class="nowraponall amountcard right">'.price($sign *
$object->total_ht, 0, $langs, 1, -1, -1,
$conf->currency).
'</td>';
1886 print
'<td class="nowraponall amountcard right">' .
price($sign *
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1891 print
'<tr><td>'.$langs->trans(
"AmountVAT").
'</td>';
1892 print
'<td class="nowrap amountcard right">'.price($sign *
$object->total_tva, 0, $langs, 1, -1, -1,
$conf->currency).
'</td>';
1895 print
'<td class="nowraponall amountcard right">' .
price($sign *
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1900 if ((
$mysoc->localtax1_assuj ==
"1" &&
$mysoc->useLocalTax(1)) ||
$object->total_localtax1 != 0) {
1902 print
'<td class="titlefieldmiddle">'.$langs->transcountry(
"AmountLT1",
$mysoc->country_code).
'</td>';
1903 print
'<td class="nowraponall amountcard right">'.price($sign *
$object->total_localtax1, 1,
'', 1, - 1, - 1,
$conf->currency).
'</td></tr>';
1907 print
'<td class="nowraponall amountcard right">' .
price($sign *
$object->multicurrency_total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1912 if ((
$mysoc->localtax2_assuj ==
"1" &&
$mysoc->useLocalTax(2)) ||
$object->total_localtax2 != 0) {
1914 print
'<td>'.$langs->transcountry(
"AmountLT2",
$mysoc->country_code).
'</td>';
1915 print
'<td class=nowraponall amountcard right">'.price($sign *
$object->total_localtax2, 1,
'', 1, - 1, - 1,
$conf->currency).
'</td></tr>';
1919 print
'<td class="nowraponall amountcard right">' .
price($sign *
$object->multicurrency_total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1980 print
'<tr><td>'.$langs->trans(
"AmountTTC").
'</td><td class="nowraponall amountcard right">'.
price($sign *
$object->total_ttc, 0, $langs, 1, -1, -1,
$conf->currency).
'</td>';
1983 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
1988 print
'<tr class="liste_titre"><td class="liste_titre">'.img_picto(
'',
'recurring',
'class="pictofixedwidth"').$title.
'</td>';
1996 print
'<tr><td style="width: 50%">';
1997 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1998 print $langs->trans(
'Frequency');
2000 if ($action !=
'editfrequency' && $user->hasRight(
'facture',
'creer')) {
2001 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>';
2003 print
'</tr></table>';
2005 if ($action ==
'editfrequency') {
2006 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'">';
2007 print
'<input type="hidden" name="action" value="setfrequency">';
2008 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2009 print
'<table class="nobordernopadding">';
2011 print
'<input type="text" name="frequency" class="width50 marginrightonly right" value="'.$object->frequency.
'">';
2012 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'));
2014 print
'<td class="left"><input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
"Modify").
'"></td>';
2015 print
'</tr></table></form>';
2018 print $langs->trans(
'FrequencyPer_'.
$object->unit_frequency,
$object->frequency);
2020 print
'<span class="opacitymedium">'.$langs->trans(
"NotARecurringInvoiceTemplate").
'</span>';
2032 if ($action ==
'date_when' ||
$object->frequency > 0) {
2033 print $form->editfieldkey($form->textwithpicto($langs->trans(
"NextDateToExecution"), $langs->trans(
"NextDateToExecutionHelp")),
'date_when',
$object->date_when, $object, $user->hasRight(
'facture',
'creer'),
'day');
2035 print $form->textwithpicto($langs->trans(
"NextDateToExecution"), $langs->trans(
"NextDateToExecutionHelp"));
2037 print
'</td><td'.(isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency) ?
' colspan="2"' :
'').
'>';
2038 if ($action ==
'date_when' ||
$object->frequency > 0) {
2039 print $form->editfieldval($langs->trans(
"NextDateToExecution"),
'date_when',
$object->date_when, $object, $user->hasRight(
'facture',
'creer'),
'day',
$object->date_when,
null,
'',
'', 0,
'strikeIfMaxNbGenReached');
2042 if (!
$object->isMaxNbGenReached()) {
2044 print img_warning($langs->trans(
"Late"));
2047 print img_info($langs->trans(
"MaxNumberOfGenerationReached"));
2054 if ($action ==
'nb_gen_max' ||
$object->frequency > 0) {
2055 print $form->editfieldkey($langs->trans(
"MaxPeriodNumber"),
'nb_gen_max', (
string)
$object->nb_gen_max, $object, $user->hasRight(
'facture',
'creer'));
2057 print $langs->trans(
"MaxPeriodNumber");
2060 if ($action ==
'nb_gen_max' ||
$object->frequency > 0) {
2061 print $form->editfieldval($langs->trans(
"MaxPeriodNumber"),
'nb_gen_max',
$object->nb_gen_max ?
$object->nb_gen_max :
'',
$object, $user->hasRight(
'facture',
'creer'));
2073 if ($action ==
'auto_validate' ||
$object->frequency > 0) {
2074 print $form->editfieldkey($langs->trans(
"StatusOfAutoGeneratedInvoices"),
'auto_validate', (
string)
$object->auto_validate, $object, $user->hasRight(
'facture',
'creer'));
2076 print $langs->trans(
"StatusOfAutoGeneratedInvoices");
2079 $select =
'select;0:' . $langs->trans(
'BillStatusDraft') .
',1:' . $langs->trans(
'BillStatusValidated') .
',2:' . $langs->trans(
'BillStatusValidatedWithSendind');
2080 if ($action ==
'auto_validate' ||
$object->frequency > 0) {
2081 print $form->editfieldval($langs->trans(
"StatusOfAutoGeneratedInvoices"),
'auto_validate',
$object->auto_validate, $object, $user->hasRight(
'facture',
'creer'), $select);
2091 print
'<tr><td style="width: 50%">';
2092 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2093 print $langs->trans(
"EmailTemplateForAutoSend");
2095 if ($action !=
'editEmailTemplate' && $user->hasRight(
'facture',
'creer')) {
2096 print
'<td class="right"><a class="editfielda" href="' . $_SERVER[
"PHP_SELF"] .
'?action=editEmailTemplate&token=' .
newToken() .
'&facid=' .
$object->id .
'">' . img_edit($langs->trans(
'Edit'), 1) .
'</a></td>';
2098 print
'</tr></table>';
2101 if ($action ==
'editEmailTemplate') {
2103 print
'<form method="POST" action="' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'">';
2104 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
2105 print
'<input type="hidden" name="action" value="setEmailTemplate">';
2106 print $form->selectModelMail(
"auto_send_",
"facture_send", 1, 0,
$object->fk_email_template);
2107 print
'<input type="submit" class="button valignmiddle smallpaddingimp" name="modify" value="' . $langs->trans(
"Modify") .
'">';
2108 print
'<input type="submit" class="button button-cancel valignmiddle smallpaddingimp" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
2112 if (!empty(
$object->fk_email_template)) {
2113 $sql =
"SELECT label
2114 FROM ".$db->prefix().
"c_email_templates
2115 WHERE rowid = ".((int)
$object->fk_email_template);
2116 $result = $db->query($sql);
2118 if ($obj = $db->fetch_object($result)) {
2123 print $langs->trans(
'DefaultMailModel');
2135 if ($action ==
'generate_pdf' ||
$object->frequency > 0) {
2136 print $form->editfieldkey($langs->trans(
"StatusOfGeneratedDocuments"),
'generate_pdf', (string)
$object->generate_pdf, $object, $user->hasRight(
'facture',
'creer'));
2138 print $langs->trans(
"StatusOfGeneratedDocuments");
2142 $select =
'select;0:'.$langs->trans(
'DoNotGenerateDoc').
',1:'.$langs->trans(
'AutogenerateDoc');
2143 if ($action ==
'generate_pdf' ||
$object->frequency > 0) {
2144 print $form->editfieldval($langs->trans(
"StatusOfGeneratedDocuments"),
'generate_pdf',
$object->generate_pdf,
$object, $user->hasRight(
'facture',
'creer'), $select);
2152 print
'<input type="hidden" name="generate_pdf" value="1">';
2163 print
info_admin($langs->trans(
"EnableAndSetupModuleCron", $langs->transnoentitiesnoconv(
"Module2300Name")));
2166 print
'<div class="underbanner clearboth"></div>';
2167 print
'<table class="border centpercent tableforfield">';
2170 print
'<tr><td style="width: 50%">'.$langs->trans(
"NbOfGenerationDone").
'</td>';
2178 print $langs->trans(
"DateLastGeneration");
2192 print
'<div class="clearboth"></div><br>';
2196 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'#add' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">';
2197 print
'<input type="hidden" name="token" value="' .
newToken().
'">';
2198 print
'<input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">';
2199 print
'<input type="hidden" name="mode" value="">';
2200 print
'<input type="hidden" name="id" value="' .
$object->id.
'">';
2201 print
'<input type="hidden" name="page_y" value="">';
2203 if (!empty(
$conf->use_javascript_ajax) &&
$object->status == 0) {
2205 include DOL_DOCUMENT_ROOT.
'/core/tpl/subtotal_ajaxrow.tpl.php';
2207 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
2211 print
'<div class="div-table-responsive-no-min">';
2212 print
'<table id="tablelines" class="noborder noshadow centpercent nomarginbottom">';
2215 $canchangeproduct = 1;
2220 if (
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer') && $action !=
'valid' && $action !=
'editline') {
2221 if ($action !=
'editline') {
2224 $parameters = array();
2225 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
2227 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
2229 if (empty($reshook)) {
2246 print
'<div class="tabsAction">';
2248 $parameters = array();
2249 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2250 if (empty($reshook)) {
2253 'class' =>
'classfortooltip',
2260 $langs->load(
"subtotals");
2262 $url_button = array();
2264 $url_button[] = array(
2265 'lang' =>
'subtotals',
2267 'perm' => (
bool) $usercancreate,
2268 'label' => $langs->trans(
'AddTitleLine'),
2269 'url' =>
'/compta/facture/card-rec.php?id='.$object->id.
'&action=add_title_line&token='.
newToken()
2272 $url_button[] = array(
2273 'lang' =>
'subtotals',
2275 'perm' => (
bool) $usercancreate,
2276 'label' => $langs->trans(
'AddSubtotalLine'),
2277 'url' =>
'/compta/facture/card-rec.php?id='.$object->id.
'&action=add_subtotal_line&token='.
newToken()
2280 $url_button[] = array(
2281 'lang' =>
'subtotals',
2283 'perm' => (
bool) $usercancreate,
2284 'label' => $langs->trans(
'AddTextLine'),
2285 'url' =>
'/compta/facture/card-rec.php?id='.$object->id.
'&action=add_text_line&token='.
newToken()
2287 print dolGetButtonAction(
'', $langs->trans(
'SubTotal'),
'default', $url_button,
'',
true);
2290 if (empty(
$object->suspended)) {
2291 if ($user->hasRight(
'facture',
'creer')) {
2293 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' .
dol_escape_htmltag($langs->trans(
"MaxGenerationReached")) .
'">' . $langs->trans(
"CreateBill") .
'</a></div>';
2295 if (empty(
$object->frequency) ||
$object->date_when <= $nowlasthour) {
2296 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>';
2298 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' .
dol_escape_htmltag($langs->trans(
"DateIsNotEnough")) .
'">' . $langs->trans(
"CreateBill") .
'</a></div>';
2302 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">' . $langs->trans(
"CreateBill") .
'</a></div>';
2306 if ($user->hasRight(
'facture',
'creer')) {
2307 if (empty(
$object->suspended)) {
2308 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>';
2310 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>';
2315 print dolGetButtonAction($langs->trans(
"Delete"), $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=delete&token=' .
newToken(),
'delete', $user->hasRight(
'facture',
'supprimer'), array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
2321 print
'<div class="fichecenter"><div class="fichehalfleft">';
2322 print
'<a name="builddoc"></a>';
2326 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'invoice'), 1);
2327 $linktoelem = $tmparray[
'linktoelem'];
2328 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
2329 print $htmltoenteralink;
2331 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
2335 print
'<div class="fichehalfright">';
2339 $morehtmlcenter =
'<div class="nowraponall">';
2341 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullList'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/compta/facture/agenda-rec.php?id='.
$object->id);
2342 $morehtmlcenter .=
'</div>';
2345 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2347 $somethingshown = $formactions->showactions($object,
$object->element, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
2352 print $langs->trans(
"NoRecordFound");
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
const STATUS_DRAFT
Draft status.
Class to manage a WYSIWYG editor.
Class to manage invoices.
const TYPE_REPLACEMENT
Replacement invoice.
const STATUS_DRAFT
Draft status.
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, $tz='')
Add a delay to a date.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
$date_start
Variables from include:
dol_now($mode='gmt')
Return date for now.
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
price2num($amount, $rounding='', $option=0, $currencycode='')
Function that return a number with universal decimal format (decimal separator is '.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
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...
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular VAT rate, when selling a product with vat $vatrate,...
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
invoice_rec_prepare_head($object)
Return array head with list of tabs to view object information.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.