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';
50$langs->loadLangs(array(
'bills',
'companies',
'compta',
'admin',
'other',
'products',
'banks'));
52$action =
GETPOST(
'action',
'alpha');
53$massaction =
GETPOST(
'massaction',
'alpha');
55$confirm =
GETPOST(
'confirm',
'alpha');
56$cancel =
GETPOST(
'cancel',
'alpha');
57$toselect =
GETPOST(
'toselect',
'array');
58$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'invoicetemplatelist';
59$backtopage =
GETPOST(
'backtopage',
'alpha');
60$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
67 $socid = $user->socid;
69$objecttype =
'facture_rec';
70if ($action ==
"create" || $action ==
"add") {
75$year_date_when =
GETPOST(
'year_date_when');
76$month_date_when =
GETPOST(
'month_date_when');
77$selectedLines =
GETPOST(
'toselect',
'array');
80$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
81$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
83if (empty($page) || $page == -1) {
86$offset = $limit * $page;
91 $sortfield =
'f.titre';
97if (($id > 0 || $ref) && $action !=
'create' && $action !=
'add') {
98 $ret =
$object->fetch($id, $ref);
108$hookmanager->initHooks(array(
'invoicereccard',
'globalcard'));
112$extrafields->fetch_name_optionals_label(
$object->table_element);
114$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
116$permissionnote = $user->hasRight(
'facture',
'creer');
117$permissiondellink = $user->hasRight(
'facture',
'creer');
118$permissiontoedit = $user->hasRight(
'facture',
'creer');
120$usercanread = $user->hasRight(
'facture',
'lire');
121$usercancreate = $user->hasRight(
'facture',
'creer');
122$usercanissuepayment = $user->hasRight(
'facture',
'paiement');
123$usercandelete = $user->hasRight(
'facture',
'supprimer');
126$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'facture',
'invoice_advance',
'validate')));
127$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->rights->facture->invoice_advance->send);
128$usercanreopen = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->rights->facture->invoice_advance->reopen);
129$usercanunvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
'facture',
'invoice_advance',
'unvalidate')));
132$usercanproductignorepricemin = ((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'produit',
'ignore_price_min_advance')) || !
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS'));
133$usercancreatemargin = $user->hasRight(
"margins",
"creer");
134$usercanreadallmargin = $user->hasRight(
"margins",
"liretous");
135$usercancreatewithdrarequest = $user->hasRight(
"prelevement",
"bons",
"creer");
148if (
GETPOST(
'cancel',
'alpha')) {
149 if ($action !=
'updateline') {
157if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
161$parameters = array();
162$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
167if (empty($reshook)) {
168 $backurlforlist = DOL_URL_ROOT.
'/compta/facture/invoicetemplate_list.php';
170 if (empty($backtopage) || ($cancel && empty($id))) {
171 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
172 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
173 $backtopage = $backurlforlist;
175 $backtopage = DOL_URL_ROOT.
'/compta/facture/invoicetemplate_list.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
183 if (!empty($backtopageforcancel)) {
184 header(
"Location: ".$backtopageforcancel);
186 } elseif (!empty($backtopage)) {
187 header(
"Location: ".$backtopage);
194 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
197 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
199 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
201 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
210 if ($action ==
'add') {
211 if (!
GETPOST(
'title',
'alphanohtml')) {
212 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Title")),
null,
'errors');
227 if (empty($reyear) || empty($remonth) || empty($reday)) {
228 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Date")),
null,
'errors');
250 $object->frequency = $frequency;
252 $object->nb_gen_max = $nb_gen_max;
255 $object->fk_project = $projectid;
257 $date_next_execution =
dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
258 $object->date_when = $date_next_execution;
260 $ret = $extrafields->setOptionalsFromPost(
null, $object);
270 $srcObject->fetchObjectLinked();
272 if (!empty($srcObject->linkedObjectsIds[
'contrat'])) {
273 $contractidid = reset($srcObject->linkedObjectsIds[
'contrat']);
276 $object->origin_id = $contractidid;
283 $oldinvoice =
new Facture($db);
286 $onlylines =
GETPOST(
'toselect',
'array');
288 $result =
$object->create($user, $oldinvoice->id, 0, $onlylines);
290 $result = $oldinvoice->delete($user, 1);
305 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?facid='.
$object->id);
316 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'facture',
'supprimer')) {
319 header(
"Location: ".DOL_URL_ROOT.
'/compta/facture/invoicetemplate_list.php');
325 if ($action ==
'setconditions' && $usercancreate) {
327 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModified", $langs->transnoentitiesnoconv(
"PaymentTerm"));
329 } elseif ($action ==
'setmode' && $usercancreate) {
331 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModified", $langs->transnoentitiesnoconv(
"PaymentMode"));
333 } elseif ($action ==
'classin' && $usercancreate) {
335 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModified", $langs->transnoentitiesnoconv(
"Project"));
337 } elseif ($action ==
'setref' && $usercancreate) {
339 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModifiedFromYToZ", $langs->transnoentitiesnoconv(
"Title"),
$object->title, $ref);
340 $result =
$object->setValueFrom(
'titre', $ref,
'',
null,
'text',
'', $user,
'BILLREC_MODIFY');
346 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
347 $langs->load(
"errors");
348 setEventMessages($langs->trans(
'ErrorRefAlreadyExists', $ref),
null,
'errors');
353 } elseif ($action ==
'setbankaccount' && $usercancreate) {
355 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModified", $langs->transnoentitiesnoconv(
"Bank"));
357 } elseif ($action ==
'setfrequency' && $usercancreate) {
359 $object->context[
'actionmsg'] = $langs->trans(
"FieldXModified", $langs->transnoentitiesnoconv(
"Frequency"));
361 } elseif ($action ==
'setdate_when' && $usercancreate) {
367 } elseif ($action ==
'setnb_gen_max' && $usercancreate) {
370 } elseif ($action ==
'setauto_validate' && $usercancreate) {
373 } elseif ($action ==
'setgenerate_pdf' && $usercancreate) {
376 } elseif ($action ==
'setmodelpdf' && $usercancreate) {
379 } elseif ($action ==
'disable' && $usercancreate) {
383 $object->context[
'actionmsg'] = $langs->trans(
"RecordDisabled");
385 $res =
$object->setValueFrom(
'suspended', 1,
'',
null,
'text',
'', $user,
'BILLREC_MODIFY');
396 } elseif ($action ==
'enable' && $usercancreate) {
400 $object->context[
'actionmsg'] = $langs->trans(
"RecordEnabled");
402 $res =
$object->setValueFrom(
'suspended', 0,
'',
null,
'text',
'', $user,
'BILLREC_MODIFY');
413 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
415 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
416 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
422 if ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
433 if ($line->delete($user) > 0) {
434 $result =
$object->update_price(1);
447 } elseif ($action ==
'update_extras' && $usercancreate) {
451 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
457 $result =
$object->insertExtraFields(
'BILLREC_MODIFY');
466 if ($action ==
'addline' && $user->hasRight(
'facture',
'creer')) {
467 $langs->load(
'errors');
472 $product_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
475 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'alpha');
476 if ($prod_entry_mode ==
'free') {
482 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
487 $tva_tx = (
GETPOST(
'tva_tx',
'alpha') ?
GETPOST(
'tva_tx',
'alpha') : 0);
491 if (empty($remise_percent)) {
496 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
497 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
499 if (is_array($extralabelsline)) {
501 foreach ($extralabelsline as $key => $value) {
502 unset($_POST[
"options_".$key.$predef]);
506 if ((empty($idprod) || $idprod < 0) && ($price_ht < 0) && ($qty < 0)) {
507 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPriceHT'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
510 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
511 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
514 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && (!($price_ht >= 0) || $price_ht ==
'')) {
515 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")),
null,
'errors');
519 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
522 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
523 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
527 $langs->load(
"errors");
528 setEventMessages($langs->trans(
'ErrorQtyForCustomerInvoiceCantBeNegative'),
null,
'errors');
532 if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) {
538 $ret =
$object->fetch_thirdparty();
543 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
554 if (!empty($idprod) && $idprod > 0) {
556 $prod->fetch($idprod);
558 $label = ((
GETPOST(
'product_label') &&
GETPOST(
'product_label') != $prod->label) ?
GETPOST(
'product_label') :
'');
570 $datapriceofproduct = $prod->getSellPrice($mysoc,
$object->thirdparty, $pqp);
572 $pu_ht = $datapriceofproduct[
'pu_ht'];
573 $pu_ttc = $datapriceofproduct[
'pu_ttc'];
574 $price_min = $datapriceofproduct[
'price_min'];
575 $price_base_type = empty($datapriceofproduct[
'price_base_type']) ?
'HT' : $datapriceofproduct[
'price_base_type'];
579 $tmpvat = (float)
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
580 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string) $prod->tva_tx));
583 if (!empty($price_ht)) {
585 $pu_ttc =
price2num($pu_ht * (1 + ($tmpvat / 100)),
'MU');
586 } elseif ($tmpvat != $tmpprodvat) {
589 if ($price_base_type !=
'HT') {
590 $pu_ht =
price2num($pu_ttc / (1 + ($tmpvat / 100)),
'MU');
592 $pu_ttc =
price2num($pu_ht * (1 + ($tmpvat / 100)),
'MU');
600 $outputlangs = $langs;
602 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
603 $newlang =
GETPOST(
'lang_id',
'aZ09');
605 if (empty($newlang)) {
606 $newlang =
$object->thirdparty->default_lang;
608 if (!empty($newlang)) {
610 $outputlangs->setDefaultLang($newlang);
613 $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] [
"description"])) ? $prod->multilangs [$outputlangs->defaultlang] [
"description"] : $prod->
description;
615 $desc = $prod->description;
621 if (!
getDolGlobalString(
'MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE') && (!empty($prod->customcode) || !empty($prod->country_code))) {
625 $outputlangs = $langs;
627 if (empty($newlang) &&
GETPOST(
'lang_id',
'alpha')) {
628 $newlang =
GETPOST(
'lang_id',
'alpha');
630 if (empty($newlang)) {
631 $newlang =
$object->thirdparty->default_lang;
633 if (!empty($newlang)) {
635 $outputlangs->setDefaultLang($newlang);
636 $outputlangs->load(
'products');
638 if (!empty($prod->customcode)) {
639 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
641 if (!empty($prod->customcode) && !empty($prod->country_code)) {
644 if (!empty($prod->country_code)) {
645 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code, 0, $db, $outputlangs, 0);
648 if (!empty($prod->customcode)) {
649 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomCode").
': '.$prod->customcode;
651 if (!empty($prod->customcode) && !empty($prod->country_code)) {
654 if (!empty($prod->country_code)) {
655 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin").
': '.
getCountry($prod->country_code, 0, $db, $langs, 0);
663 $fk_unit = $prod->fk_unit;
667 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
668 $tva_tx = str_replace(
'*',
'', $tva_tx);
669 if (empty($tva_tx)) {
672 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
673 $desc = $product_desc;
675 $fk_unit =
GETPOST(
'units',
'alpha');
678 $date_start_fill =
GETPOSTINT(
'date_start_fill');
694 $fk_parent_line =
GETPOST(
'fk_parent_line',
'int');
696 if ($usercanproductignorepricemin && (!empty($price_min) && (
price2num($pu_ht) * (1 -
price2num($remise_percent) / 100) <
price2num($price_min)))) {
697 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
701 $result =
$object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits,
'', $pu_ttc, $type, -1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice, $fk_parent_line);
724 unset($_POST[
'prod_entry_mode']);
726 unset($_POST[
'qty']);
727 unset($_POST[
'type']);
728 unset($_POST[
'remise_percent']);
729 unset($_POST[
'price_ht']);
730 unset($_POST[
'multicurrency_price_ht']);
731 unset($_POST[
'price_ttc']);
732 unset($_POST[
'tva_tx']);
733 unset($_POST[
'product_ref']);
734 unset($_POST[
'product_label']);
735 unset($_POST[
'product_desc']);
736 unset($_POST[
'fournprice']);
737 unset($_POST[
'buying_price']);
738 unset($_POST[
'np_marginRate']);
739 unset($_POST[
'np_markRate']);
740 unset($_POST[
'dp_desc']);
741 unset($_POST[
'idprod']);
742 unset($_POST[
'units']);
744 unset($_POST[
'date_starthour']);
745 unset($_POST[
'date_startmin']);
746 unset($_POST[
'date_startsec']);
747 unset($_POST[
'date_startday']);
748 unset($_POST[
'date_startmonth']);
749 unset($_POST[
'date_startyear']);
750 unset($_POST[
'date_endhour']);
751 unset($_POST[
'date_endmin']);
752 unset($_POST[
'date_endsec']);
753 unset($_POST[
'date_endday']);
754 unset($_POST[
'date_endmonth']);
755 unset($_POST[
'date_endyear']);
757 unset($_POST[
'date_start_fill']);
758 unset($_POST[
'date_end_fill']);
760 unset($_POST[
'situations']);
761 unset($_POST[
'progress']);
769 } elseif ($action ==
'updateline' && $usercancreate && !
GETPOST(
'cancel',
'alpha')) {
770 if (!
$object->fetch($id) > 0) {
788 if (preg_match(
'/\*/', $vat_rate)) {
793 $vat_rate = str_replace(
'*',
'', $vat_rate);
802 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
803 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
806 if ($objectline->fetch(
GETPOSTINT(
'lineid'))) {
807 $objectline->array_options = $array_options;
808 $result = $objectline->insertExtraFields();
814 $position = ($objectline->rang >= 0 ? $objectline->rang : 0);
817 if (is_array($extralabelsline)) {
819 foreach ($extralabelsline as $key => $value) {
820 unset($_POST[
"options_".$key]);
826 if ($special_code == 3) {
843 if (empty($remise_percent)) {
849 if (!empty($productid)) {
851 $product->fetch($productid);
853 $type = $product->type;
855 $price_min = $product->price_min;
857 $price_min = $product->multiprices_min[
$object->thirdparty->price_level];
866 setEventMessages($langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, - 1, $conf->currency)),
null,
'errors');
871 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
875 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
880 $langs->load(
"errors");
881 setEventMessages($langs->trans(
'ErrorQtyForCustomerInvoiceCantBeNegative'),
null,
'errors');
885 $date_start_fill =
GETPOSTINT(
'date_start_fill');
887 $fk_parent_line =
GETPOST(
'fk_parent_line',
'int');
939 unset($_POST[
'qty']);
940 unset($_POST[
'type']);
941 unset($_POST[
'productid']);
942 unset($_POST[
'remise_percent']);
943 unset($_POST[
'price_ht']);
944 unset($_POST[
'multicurrency_price_ht']);
945 unset($_POST[
'price_ttc']);
946 unset($_POST[
'tva_tx']);
947 unset($_POST[
'product_ref']);
948 unset($_POST[
'product_label']);
949 unset($_POST[
'product_desc']);
950 unset($_POST[
'fournprice']);
951 unset($_POST[
'buying_price']);
952 unset($_POST[
'np_marginRate']);
953 unset($_POST[
'np_markRate']);
955 unset($_POST[
'dp_desc']);
956 unset($_POST[
'idprod']);
957 unset($_POST[
'units']);
959 unset($_POST[
'date_starthour']);
960 unset($_POST[
'date_startmin']);
961 unset($_POST[
'date_startsec']);
962 unset($_POST[
'date_startday']);
963 unset($_POST[
'date_startmonth']);
964 unset($_POST[
'date_startyear']);
965 unset($_POST[
'date_endhour']);
966 unset($_POST[
'date_endmin']);
967 unset($_POST[
'date_endsec']);
968 unset($_POST[
'date_endday']);
969 unset($_POST[
'date_endmonth']);
970 unset($_POST[
'date_endyear']);
972 unset($_POST[
'situations']);
973 unset($_POST[
'progress']);
986$title =
$object->ref.
" - ".$langs->trans(
'Card');
991$form =
new Form($db);
993if (isModEnabled(
'project')) {
996$companystatic =
new Societe($db);
1006if ($action ==
'create') {
1007 print
load_fiche_titre($langs->trans(
"CreateRepeatableInvoice"),
'',
'bill');
1010 $product_static =
new Product($db);
1012 if (
$object->fetch($id, $ref) > 0) {
1013 $result =
$object->getLinesArray();
1015 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1016 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1017 print
'<input type="hidden" name="action" value="add">';
1018 print
'<input type="hidden" name="facid" value="'.$object->id.
'">';
1023 if (isModEnabled(
'project')) {
1026 if (
$object->fk_account > 0) {
1030 print
'<table class="border centpercent">';
1035 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Title").
'</td><td>';
1036 print
'<input class="flat quatrevingtpercent" type="text" name="title" value="'.dol_escape_htmltag(
GETPOST(
"title",
'alphanohtml')).
'" autofocus>';
1040 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Customer").
'</td><td>'.
$object->thirdparty->getNomUrl(1,
'customer').
'</td>';
1045 print
"<tr><td>".$langs->trans(
"InvoiceSubtype").
"</td><td>";
1046 print $form->getSelectInvoiceSubtype(GETPOSTISSET(
'subtype') ?
GETPOST(
'subtype') :
$object->subtype,
'subtype', 0, 0,
'');
1050 $note_public = GETPOSTISSET(
'note_public') ?
GETPOST(
'note_public',
'restricthtml') :
$object->note_public;
1051 $note_private = GETPOSTISSET(
'note_private') ?
GETPOST(
'note_private',
'restricthtml') :
$object->note_private;
1056 $substitutionarray[
'__INVOICE_PREVIOUS_MONTH__'] = $langs->trans(
"PreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree(
$object->date, -1,
'm'),
'%m').
')';
1057 $substitutionarray[
'__INVOICE_MONTH__'] = $langs->trans(
"MonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
$object->date,
'%m').
')';
1059 $substitutionarray[
'__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans(
"TextPreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree(
$object->date, -1,
'm'),
'%B').
')';
1060 $substitutionarray[
'__INVOICE_MONTH_TEXT__'] = $langs->trans(
"TextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
$object->date,
'%B').
')';
1061 $substitutionarray[
'__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans(
"TextNextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree(
$object->date, 1,
'm'),
'%B').
')';
1063 $substitutionarray[
'__INVOICE_YEAR__'] = $langs->trans(
"YearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
$object->date,
'%Y').
')';
1066 $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').
')';
1067 $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').
')';
1068 $substitutionarray[
'__INVOICE_COUNTER_CURRENT__'] = $langs->trans(
"Count");
1069 $substitutionarray[
'__INVOICE_COUNTER_MAX__'] = $langs->trans(
"MaxPeriodNumber");
1071 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
1072 foreach ($substitutionarray as $key => $val) {
1073 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
1075 $htmltext .=
'</i>';
1078 print
"<tr><td>".$langs->trans(
"Author").
"</td><td>".$user->getFullName($langs).
"</td></tr>";
1081 print
"<tr><td>".$langs->trans(
"PaymentConditions").
"</td><td>";
1082 print $form->getSelectConditionsPaiements(GETPOSTISSET(
'cond_reglement_id') ?
GETPOSTINT(
'cond_reglement_id') :
$object->cond_reglement_id,
'cond_reglement_id', -1, 0, 0,
'');
1087 print
"<tr><td>".$langs->trans(
"PaymentMode").
"</td><td>";
1088 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
1089 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);
1094 if (
$object->fk_account > 0) {
1095 print
"<tr><td>".$langs->trans(
'BankAccount').
"</td><td>";
1096 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
1105 $extralabels = $extrafields->fetch_name_optionals_label($draft->table_element);
1106 if ($draft->fetch_optionals() > 0) {
1107 $object->array_options = array_merge(
$object->array_options, $draft->array_options);
1110 print
$object->showOptionals($extrafields,
'create', $parameters);
1113 if (isModEnabled(
'project') && is_object(
$object->thirdparty) &&
$object->thirdparty->id > 0) {
1115 $langs->load(
'projects');
1116 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td>';
1117 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1118 $numprojet = $formproject->select_projects(
$object->thirdparty->id, $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 0, 0,
'');
1119 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>';
1124 print
"<tr><td>".$langs->trans(
'Model').
"</td><td>";
1125 include_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
1127 print
img_picto(
'',
'generic',
'class="pictofixedwidth"');
1129 print $form->selectarray(
'modelpdf', $list, $conf->global->FACTURE_ADDON_PDF);
1134 print
'<td class="tdtop">';
1135 print $form->textwithpicto($langs->trans(
'NotePublic'), $htmltext, 1,
'help',
'', 0, 2,
'notepublic');
1138 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In', 0,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1139 print $doleditor->Create(1);
1142 if (empty($user->socid)) {
1144 print
'<td class="tdtop">';
1145 print $form->textwithpicto($langs->trans(
'NotePrivate'), $htmltext, 1,
'help',
'', 0, 2,
'noteprivate');
1148 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In', 0,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1149 print $doleditor->Create(1);
1159 $title = $langs->trans(
"Recurrence");
1162 print
'<span class="opacitymedium">'.$langs->trans(
"ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv(
'Module2300Name')).
'</span><br><br>';
1166 print
'<table class="border centpercent">';
1169 print
'<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans(
"Frequency"), $langs->transnoentitiesnoconv(
'toolTipFrequency')).
"</td><td>";
1170 print
'<input type="text" class="width50" name="frequency" value="'.GETPOST(
'frequency',
'int').
'"> ';
1171 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'));
1175 print
"<tr><td>".$langs->trans(
'NextDateToExecution').
"</td><td>";
1177 print $form->selectDate($date_next_execution,
'', 1, 1, 0,
"add", 1, 1);
1181 print
"<tr><td>".$langs->trans(
"MaxPeriodNumber").
"</td><td>";
1182 print
'<input type="text" class="width50" name="nb_gen_max" value="'.GETPOSTINT(
'nb_gen_max').
'">';
1186 print
"<tr><td>".$langs->trans(
"StatusOfAutoGeneratedInvoices").
"</td><td>";
1187 $select = array(
'0' => $langs->trans(
'BillStatusDraft'),
'1' => $langs->trans(
'BillStatusValidated'));
1188 print $form->selectarray(
'auto_validate', $select,
GETPOSTINT(
'auto_validate'));
1193 print
"<tr><td>".$langs->trans(
"StatusOfGeneratedDocuments").
"</td><td>";
1194 $select = array(
'0' => $langs->trans(
'DoNotGenerateDoc'),
'1' => $langs->trans(
'AutoGenerateDoc'));
1195 print $form->selectarray(
'generate_pdf', $select,
GETPOSTINT(
'generate_pdf'));
1198 print
'<input type="hidden" name="generate_pdf" value="1">';
1206 $title = $langs->trans(
"ProductsAndServices");
1207 if (!isModEnabled(
'service')) {
1208 $title = $langs->trans(
"Products");
1209 } elseif (!isModEnabled(
'product')) {
1210 $title = $langs->trans(
"Services");
1218 print
'<div class="div-table-responsive-no-min">';
1219 print
'<table id="tablelines" class="noborder noshadow centpercent">';
1223 $object->printOriginLinesList(
'', $selectedLines);
1232 if (!empty($flag_price_may_change)) {
1233 print
'<tr><td colspan="3" class="left">';
1234 print
'<select name="usenewprice" class="flat">';
1235 print
'<option value="0">'.$langs->trans(
"AlwaysUseFixedPrice").
'</option>';
1236 print
'<option value="1" disabled>'.$langs->trans(
"AlwaysUseNewPrice").
'</option>';
1242 print $form->buttonsSaveCancel(
"Create");
1257 if ($action ==
'ask_deleteline') {
1258 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'',
'no', 1);
1261 if ($action ==
'delete') {
1262 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteRepeatableInvoice'), $langs->trans(
'ConfirmDeleteRepeatableInvoice'),
'confirm_delete',
'',
'no', 1);
1266 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
1267 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
1268 if (empty($reshook)) {
1269 $formconfirm .= $hookmanager->resPrint;
1270 } elseif ($reshook > 0) {
1271 $formconfirm = $hookmanager->resPrint;
1276 $author =
new User($db);
1277 $author->fetch(
$object->user_author);
1281 print
dol_get_fiche_head($head,
'card', $langs->trans(
"RepeatableInvoice"), -1,
'bill');
1285 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/facture/invoicetemplate_list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
1288 if ($action !=
'editref') {
1289 $morehtmlref .= $form->editfieldkey(
$object->ref,
'ref',
$object->ref, $object, $user->hasRight(
'facture',
'creer'),
'',
'', 0, 2);
1291 $morehtmlref .= $form->editfieldval(
'',
'ref',
$object->ref, $object, $user->hasRight(
'facture',
'creer'),
'string');
1294 $morehtmlref .=
'<div class="refidno">';
1299 $morehtmlref .=
$object->thirdparty->getNomUrl(1,
'customer');
1301 if (isModEnabled(
'project')) {
1302 $langs->load(
"projects");
1303 $morehtmlref .=
'<br>';
1304 if ($user->hasRight(
'facture',
'creer')) {
1305 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
1306 if ($action !=
'classify') {
1307 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
1309 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
1311 if (!empty(
$object->fk_project)) {
1313 $proj->fetch(
$object->fk_project);
1314 $morehtmlref .=
' : '.$proj->getNomUrl(1);
1316 $morehtmlref .=
' - '.$proj->title;
1323 $morehtmlref .=
'</div>';
1325 $morehtmlstatus =
'';
1327 dol_banner_tab($object,
'ref', $linkback, 1,
'title',
'none', $morehtmlref,
'', 0,
'', $morehtmlstatus);
1329 print
'<div class="fichecenter">';
1330 print
'<div class="fichehalfleft">';
1331 print
'<div class="underbanner clearboth"></div>';
1333 print
'<table class="border centpercent tableforfield">';
1337 print
"<tr><td>".$langs->trans(
"InvoiceSubtype").
"</td><td>";
1339 print
$object->getSubtypeLabel(
'facture_rec');
1345 print
'<tr><td class="titlefield">'.$langs->trans(
"Author").
'</td><td>';
1346 print $author->getNomUrl(-1);
1350 print
'<tr><td>'.$langs->trans(
"AmountHT").
'</td>';
1351 print
'<td>'.price(
$object->total_ht, 0, $langs, 1, -1, -1, $conf->currency).
'</td>';
1355 print
'<tr><td>'.$langs->trans(
"AmountVAT").
'</td><td>'.
price(
$object->total_tva, 0, $langs, 1, -1, -1, $conf->currency).
'</td>';
1359 if (($mysoc->localtax1_assuj ==
"1" && $mysoc->useLocalTax(1)) ||
$object->total_localtax1 != 0) {
1360 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
1361 print
'<td class="nowrap">'.price(
$object->total_localtax1, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
1363 if (($mysoc->localtax2_assuj ==
"1" && $mysoc->useLocalTax(2)) ||
$object->total_localtax2 != 0) {
1364 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
1365 print
'<td class=nowrap">'.price(
$object->total_localtax2, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
1368 print
'<tr><td>'.$langs->trans(
"AmountTTC").
'</td><td colspan="3">'.
price(
$object->total_ttc, 0, $langs, 1, -1, -1, $conf->currency).
'</td>';
1374 print
'<table class="nobordernopadding centpercent"><tr><td>';
1375 print $langs->trans(
'PaymentConditionsShort');
1377 if ($action !=
'editconditions' && $user->hasRight(
'facture',
'creer')) {
1378 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>';
1380 print
'</tr></table>';
1382 if ($action ==
'editconditions') {
1383 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id,
$object->cond_reglement_id,
'cond_reglement_id');
1385 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id,
$object->cond_reglement_id,
'none');
1391 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1392 print $langs->trans(
'PaymentMode');
1394 if ($action !=
'editmode' && $user->hasRight(
'facture',
'creer')) {
1395 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>';
1397 print
'</tr></table>';
1399 if ($action ==
'editmode') {
1400 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id,
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
1402 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id,
$object->mode_reglement_id,
'none');
1407 if (isModEnabled(
'multicurrency')) {
1411 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1412 print $form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0);
1414 if ($usercancreate && $action !=
'editmulticurrencycode' &&
$object->suspended == $object::STATUS_SUSPENDED) {
1415 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmulticurrencycode&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetMultiCurrencyCode'), 1).
'</a></td>';
1417 print
'</tr></table>';
1419 $htmlname = (($usercancreate && $action ==
'editmulticurrencycode') ?
'multicurrency_code' :
'none');
1420 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_code, $htmlname);
1424 if (
$object->multicurrency_code != $conf->currency ||
$object->multicurrency_tx != 1) {
1427 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1428 print $form->editfieldkey(
'CurrencyRate',
'multicurrency_tx',
'', $object, 0);
1430 if ($usercancreate && $action !=
'editmulticurrencyrate' &&
$object->suspended == $object::STATUS_SUSPENDED &&
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency) {
1431 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmulticurrencyrate&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetMultiCurrencyCode'), 1).
'</a></td>';
1433 print
'</tr></table>';
1435 if ($action ==
'editmulticurrencyrate' || $action ==
'actualizemulticurrencyrate') {
1436 if ($action ==
'actualizemulticurrencyrate') {
1439 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_tx, ($usercancreate ?
'multicurrency_tx' :
'none'),
$object->multicurrency_code);
1441 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_tx,
'none',
$object->multicurrency_code);
1442 if (
$object->statut == $object::STATUS_DRAFT &&
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency) {
1443 print
'<div class="inline-block"> ';
1444 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=actualizemulticurrencyrate">'.$langs->trans(
"ActualizeCurrency").
'</a>';
1455 $dateexample =
$object->date_when;
1461 $substitutionarray[
'__INVOICE_PREVIOUS_MONTH__'] = $langs->trans(
"PreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%m').
')';
1462 $substitutionarray[
'__INVOICE_MONTH__'] = $langs->trans(
"MonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%m').
')';
1463 $substitutionarray[
'__INVOICE_NEXT_MONTH__'] = $langs->trans(
"NextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%m').
')';
1464 $substitutionarray[
'__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans(
"TextPreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%B').
')';
1465 $substitutionarray[
'__INVOICE_MONTH_TEXT__'] = $langs->trans(
"TextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%B').
')';
1466 $substitutionarray[
'__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans(
"TextNextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%B').
')';
1467 $substitutionarray[
'__INVOICE_PREVIOUS_YEAR__'] = $langs->trans(
"PreviousYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'y'),
'%Y').
')';
1468 $substitutionarray[
'__INVOICE_YEAR__'] = $langs->trans(
"YearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%Y').
')';
1469 $substitutionarray[
'__INVOICE_NEXT_YEAR__'] = $langs->trans(
"NextYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'y'),
'%Y').
')';
1471 $substitutionarray[
'__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans(
"DateNextInvoiceBeforeGen").
' ('.$langs->trans(
"Example").
': '.
dol_print_date((
$object->date_when ?
$object->date_when :
dol_now()),
'dayhour').
')';
1473 $substitutionarray[
'__INVOICE_COUNTER_CURRENT__'] =
$object->nb_gen_done;
1474 $substitutionarray[
'__INVOICE_COUNTER_MAX__'] =
$object->nb_gen_max;
1476 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
1477 foreach ($substitutionarray as $key => $val) {
1478 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
1480 $htmltext .=
'</i>';
1483 print
'<tr><td class="nowrap">';
1484 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1485 print $langs->trans(
'BankAccount');
1488 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>';
1490 print
'</tr></table>';
1492 if ($action ==
'editbankaccount') {
1493 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'fk_account', 1);
1495 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
1501 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1506 print $form->editfieldkey($form->textwithpicto($langs->trans(
'NotePublic'), $htmltext, 1,
'help',
'', 0, 2,
'notepublic'),
'note_public',
$object->note_public, $object, $user->hasRight(
'facture',
'creer'));
1507 print
'</td><td class="wordbreak">';
1508 print $form->editfieldval($langs->trans(
"NotePublic"),
'note_public',
$object->note_public, $object, $user->hasRight(
'facture',
'creer'),
'textarea:'.ROWS_4.
':90%',
'',
null,
null,
'', 1);
1514 print $form->editfieldkey($form->textwithpicto($langs->trans(
"NotePrivate"), $htmltext, 1,
'help',
'', 0, 2,
'noteprivate'),
'note_private',
$object->note_private, $object, $user->hasRight(
'facture',
'creer'));
1515 print
'</td><td class="wordbreak">';
1516 print $form->editfieldval($langs->trans(
"NotePrivate"),
'note_private',
$object->note_private, $object, $user->hasRight(
'facture',
'creer'),
'textarea:'.ROWS_4.
':90%',
'',
null,
null,
'', 1);
1521 print
'<tr><td class="nowrap">';
1522 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1523 print $langs->trans(
'Model');
1526 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>';
1528 print
'</tr></table>';
1530 if ($action ==
'editmodelpdf') {
1531 include_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
1534 foreach ($models as $k => $model) {
1535 $list[] = str_replace(
':',
'|', $k).
':'.$model;
1537 $select =
'select;'.implode(
',', $list);
1538 print $form->editfieldval($langs->trans(
"Model"),
'modelpdf',
$object->model_pdf, $object, $user->hasRight(
'facture',
'creer'), $select);
1552 print
'<div class="fichehalfright">';
1553 print
'<div class="underbanner clearboth"></div>';
1559 $title = $langs->trans(
"Recurrence");
1561 print
'<table class="border centpercent tableforfield">';
1563 print
'<tr><td colspan="2">'.img_picto(
'',
'recurring',
'class="pictofixedwidth"').$title.
'</td></tr>';
1566 print
'<tr><td style="width: 50%">';
1567 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1568 print $langs->trans(
'Frequency');
1570 if ($action !=
'editfrequency' && $user->hasRight(
'facture',
'creer')) {
1571 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>';
1573 print
'</tr></table>';
1575 if ($action ==
'editfrequency') {
1576 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'">';
1577 print
'<input type="hidden" name="action" value="setfrequency">';
1578 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1579 print
'<table class="nobordernopadding">';
1581 print
'<input type="text" name="frequency" class="width50 marginrightonly right" value="'.$object->frequency.
'">';
1582 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'));
1584 print
'<td class="left"><input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans(
"Modify").
'"></td>';
1585 print
'</tr></table></form>';
1588 print $langs->trans(
'FrequencyPer_'.
$object->unit_frequency,
$object->frequency);
1590 print
'<span class="opacitymedium">'.$langs->trans(
"NotARecurringInvoiceTemplate").
'</span>';
1597 if ($action ==
'date_when' ||
$object->frequency > 0) {
1598 print $form->editfieldkey($langs->trans(
"NextDateToExecution"),
'date_when',
$object->date_when, $object, $user->hasRight(
'facture',
'creer'),
'day');
1600 print $langs->trans(
"NextDateToExecution");
1603 if ($action ==
'date_when' ||
$object->frequency > 0) {
1604 print $form->editfieldval($langs->trans(
"NextDateToExecution"),
'date_when',
$object->date_when, $object, $user->hasRight(
'facture',
'creer'),
'day',
$object->date_when,
null,
'',
'', 0,
'strikeIfMaxNbGenReached');
1607 if (!
$object->isMaxNbGenReached()) {
1612 print
img_info($langs->trans(
"MaxNumberOfGenerationReached"));
1619 if ($action ==
'nb_gen_max' ||
$object->frequency > 0) {
1620 print $form->editfieldkey($langs->trans(
"MaxPeriodNumber"),
'nb_gen_max',
$object->nb_gen_max, $object, $user->hasRight(
'facture',
'creer'));
1622 print $langs->trans(
"MaxPeriodNumber");
1625 if ($action ==
'nb_gen_max' ||
$object->frequency > 0) {
1626 print $form->editfieldval($langs->trans(
"MaxPeriodNumber"),
'nb_gen_max',
$object->nb_gen_max ?
$object->nb_gen_max :
'',
$object, $user->hasRight(
'facture',
'creer'));
1635 if ($action ==
'auto_validate' ||
$object->frequency > 0) {
1636 print $form->editfieldkey($langs->trans(
"StatusOfAutoGeneratedInvoices"),
'auto_validate',
$object->auto_validate, $object, $user->hasRight(
'facture',
'creer'));
1638 print $langs->trans(
"StatusOfAutoGeneratedInvoices");
1641 $select =
'select;0:'.$langs->trans(
'BillStatusDraft').
',1:'.$langs->trans(
'BillStatusValidated');
1642 if ($action ==
'auto_validate' ||
$object->frequency > 0) {
1643 print $form->editfieldval($langs->trans(
"StatusOfAutoGeneratedInvoices"),
'auto_validate',
$object->auto_validate, $object, $user->hasRight(
'facture',
'creer'), $select);
1650 if ($action ==
'generate_pdf' ||
$object->frequency > 0) {
1651 print $form->editfieldkey($langs->trans(
"StatusOfGeneratedDocuments"),
'generate_pdf',
$object->generate_pdf, $object, $user->hasRight(
'facture',
'creer'));
1653 print $langs->trans(
"StatusOfGeneratedDocuments");
1657 $select =
'select;0:'.$langs->trans(
'DoNotGenerateDoc').
',1:'.$langs->trans(
'AutogenerateDoc');
1658 if ($action ==
'generate_pdf' ||
$object->frequency > 0) {
1659 print $form->editfieldval($langs->trans(
"StatusOfGeneratedDocuments"),
'generate_pdf',
$object->generate_pdf, $object, $user->hasRight(
'facture',
'creer'), $select);
1664 print
'<input type="hidden" name="generate_pdf" value="1">';
1673 if (!isModEnabled(
'cron')) {
1674 print
info_admin($langs->trans(
"EnableAndSetupModuleCron", $langs->transnoentitiesnoconv(
"Module2300Name")));
1677 print
'<div class="underbanner clearboth"></div>';
1678 print
'<table class="border centpercent tableforfield">';
1681 print
'<tr><td style="width: 50%">'.$langs->trans(
"NbOfGenerationDone").
'</td>';
1689 print $langs->trans(
"DateLastGeneration");
1703 print
'<div class="clearboth"></div><br>';
1707 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'#add' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">';
1708 print
'<input type="hidden" name="token" value="' .
newToken().
'">';
1709 print
'<input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">';
1710 print
'<input type="hidden" name="mode" value="">';
1711 print
'<input type="hidden" name="id" value="' .
$object->id.
'">';
1712 print
'<input type="hidden" name="page_y" value="">';
1714 if (!empty($conf->use_javascript_ajax) &&
$object->statut == 0) {
1715 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
1718 print
'<div class="div-table-responsive-no-min">';
1719 print
'<table id="tablelines" class="noborder noshadow centpercent">';
1722 $canchangeproduct = 1;
1723 $object->printObjectLines($action, $mysoc,
$object->thirdparty, $lineid, 0);
1727 if (
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer') && $action !=
'valid' && $action !=
'editline') {
1728 if ($action !=
'editline') {
1731 $parameters = array();
1732 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
1736 if (empty($reshook)) {
1753 print
'<div class="tabsAction">';
1755 $parameters = array();
1756 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1757 if (empty($reshook)) {
1760 'class' =>
'classfortooltip',
1763 if (empty(
$object->suspended)) {
1764 if ($user->hasRight(
'facture',
'creer')) {
1766 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' .
dol_escape_htmltag($langs->trans(
"MaxGenerationReached")) .
'">' . $langs->trans(
"CreateBill") .
'</a></div>';
1768 if (empty(
$object->frequency) ||
$object->date_when <= $nowlasthour) {
1769 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>';
1771 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' .
dol_escape_htmltag($langs->trans(
"DateIsNotEnough")) .
'">' . $langs->trans(
"CreateBill") .
'</a></div>';
1775 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">' . $langs->trans(
"CreateBill") .
'</a></div>';
1779 if ($user->hasRight(
'facture',
'creer')) {
1780 if (empty(
$object->suspended)) {
1781 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>';
1783 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>';
1788 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=delete&token=' .
newToken(),
'delete', $user->hasRight(
'facture',
'supprimer'));
1794 print
'<div class="fichecenter"><div class="fichehalfleft">';
1795 print
'<a name="builddoc"></a>';
1799 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'invoice'));
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
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
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.
static getIdAndTxFromCode($dbs, $code, $date_document='')
Get id and rate of currency from code.
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_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 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.
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.