36require
'../../main.inc.php';
47require_once DOL_DOCUMENT_ROOT .
'/fourn/class/fournisseur.facture-rec.class.php';
48require_once DOL_DOCUMENT_ROOT .
'/fourn/class/fournisseur.product.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';
57require_once DOL_DOCUMENT_ROOT .
'/core/class/extrafields.class.php';
60$langs->loadLangs(array(
'bills',
'companies',
'compta',
'admin',
'other',
'products',
'banks',
'suppliers'));
62$action =
GETPOST(
'action',
'alpha');
63$massaction =
GETPOST(
'massaction',
'alpha');
65$confirm =
GETPOST(
'confirm',
'alpha');
66$cancel =
GETPOST(
'cancel',
'alpha');
67$toselect =
GETPOST(
'toselect',
'array:int');
68$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'supplierinvoicetemplatelist';
69$backtopage =
GETPOST(
'backtopage',
'alpha');
70$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
75$ref =
GETPOST(
'title',
'alphanohtml') ?
GETPOST(
'title',
'alphanohtml') :
GETPOST(
'ref',
'alphanohtml');
76$label =
GETPOST(
'label',
'alphanohtml');
77$ref_supplier =
GETPOST(
'ref_supplier',
'alphanohtml');
79$year_date_when =
GETPOST(
'year_date_when');
80$month_date_when =
GETPOST(
'month_date_when');
84 $socid = $user->socid;
86$objecttype =
'facture_fourn_rec';
87if ($action ==
"create" || $action ==
"add") {
92$sortfield =
GETPOST(
"sortfield",
'aZ09comma');
93$sortorder =
GETPOST(
"sortorder",
'aZ09comma');
95if (empty($page) || $page == -1) {
98$offset = $limit * $page;
103 $sortfield =
'f.titre';
105$pageprev = $page - 1;
106$pagenext = $page + 1;
109if (($id > 0 || $ref) && $action !=
'create' && $action !=
'add') {
110 $ret =
$object->fetch($id, $ref);
112 setEventMessages($langs->trans(
"ErrorRecordNotFound"),
null,
'errors');
117$hookmanager->initHooks(array(
'supplierinvoicereccard',
'globalcard'));
121$extrafields->fetch_name_optionals_label(
$object->table_element);
123$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
125$permissionnote = $user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer");
126$permissiondellink = $user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer");
127$permissiontoedit = $user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer");
128$permissiontoadd = $user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer");
129$permissiontodelete = ($user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"supprimer"));
130$permissiontoeditextra = $permissiontoadd;
131if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
133 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
136$usercanread = $user->hasRight(
"fournisseur",
"facture",
"lire") || $user->hasRight(
"supplier_invoice",
"lire");
137$usercancreate = $user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer");
138$usercandelete = $user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"supprimer");
139$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"validate")));
140$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"send"));
142$usercanproductignorepricemin = ((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
"produit",
"ignore_price_min_advance")) || !
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS'));
143$usercancreatemargin = $user->hasRight(
"margins",
"creer");
144$usercanreadallmargin = $user->hasRight(
"margins",
"liretous");
145$usercancreatewithdrarequest = $user->hasRight(
"prelevement",
"bons",
"creer");
160if (
GETPOST(
'cancel',
'alpha')) {
161 if ($action !=
'updateline') {
169if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
173$parameters = array(
'socid' => $socid);
174$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
176 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
179if (empty($reshook)) {
180 if (
GETPOST(
'cancel',
'alpha')) {
185 include DOL_DOCUMENT_ROOT .
'/core/actions_changeselectedfields.inc.php';
188 include DOL_DOCUMENT_ROOT .
'/core/actions_setnotes.inc.php';
190 include DOL_DOCUMENT_ROOT .
'/core/actions_dellink.inc.php';
192 include DOL_DOCUMENT_ROOT .
'/core/actions_lineupdown.inc.php';
195 if ($action ==
'add' && $permissiontoadd) {
196 if (!
GETPOST(
'title',
'alphanohtml')) {
197 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Title")),
null,
'errors');
212 if (empty($reyear) || empty($remonth) || empty($reday)) {
213 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Date")),
null,
'errors');
231 $object->frequency = $frequency;
233 $object->nb_gen_max = $nb_gen_max;
238 $date_next_execution =
dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
239 $object->date_when = $date_next_execution;
241 $ret = $extrafields->setOptionalsFromPost(
null, $object);
243 setEventMessages($extrafields->error, $extrafields->errors,
'errors');
253 $onlylines =
GETPOST(
'toselect',
'array:int');
255 $result =
$object->create($user, $oldinvoice->id, 0, $onlylines);
258 $result = $oldinvoice->delete($user, 1);
261 setEventMessages($oldinvoice->error, $oldinvoice->errors,
'errors');
273 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
'?facid=' .
$object->id);
284 if ($action ==
'confirm_deleteinvoice' && $confirm ==
'yes' && $permissiontodelete) {
286 $result =
$object->delete($user);
288 header(
'Location: ' . DOL_URL_ROOT .
'/fourn/facture/list-rec.php');
297 if ($action ==
'setconditions' && $usercancreate) {
299 } elseif ($action ==
'setmode' && $usercancreate) {
302 } elseif ($action ==
'classin' && $usercancreate) {
305 } elseif ($action ==
'setref_supplier' && $usercancreate) {
306 $result =
$object->setValueFrom(
'ref_supplier', $ref_supplier,
'',
null,
'text',
'', $user);
310 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
311 $langs->load(
"errors");
312 setEventMessages($langs->trans(
'ErrorRefAlreadyExists', $ref_supplier),
null,
'errors');
317 } elseif ($action ==
'settitle' && $permissiontoadd) {
318 $result =
$object->setValueFrom(
'titre', $ref,
'',
null,
'text',
'', $user);
325 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
326 $langs->load(
"errors");
327 setEventMessages($langs->trans(
'ErrorTitreAlreadyExists', $ref),
null,
'errors');
332 } elseif ($action ==
'setbankaccount' && $permissiontoadd) {
335 } elseif ($action ==
'setfrequency' && $permissiontoadd) {
338 } elseif ($action ==
'setdate_when' && $permissiontoadd) {
344 } elseif ($action ==
'setnb_gen_max' && $permissiontoadd) {
347 } elseif ($action ==
'setauto_validate' && $permissiontoadd) {
350 } elseif ($action ==
'setgenerate_pdf' && $permissiontoadd) {
353 } elseif ($action ==
'setmodelpdf' && $permissiontoadd) {
356 } elseif ($action ==
'disable' && $permissiontoadd) {
362 $res =
$object->setValueFrom(
'suspended', 1);
373 } elseif ($action ==
'enable' && $permissiontoadd) {
377 $object->context[
'actionmsg'] = $langs->trans(
"RecordEnabled");
381 $res =
$object->setValueFrom(
'suspended', 0);
392 } elseif ($action ==
'setmulticurrencycode' && $permissiontoadd) {
394 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
395 } elseif ($action ==
'setmulticurrencyrate' && $permissiontoadd) {
397 if (!in_array(
GETPOSTINT(
'calculation_mode'), array(1, 2))) {
398 $langs->load(
"compta");
399 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CalculationMode")),
null,
'errors');
400 $action =
'editmulticurrencyrate';
404 } elseif ($action ==
'setlabel' && $permissiontoadd) {
406 $result =
$object->setValueFrom(
'libelle', $label,
'',
null,
'text',
'', $user);
410 if ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $permissiontoadd) {
421 if ($line->delete($user) > 0) {
422 $result =
$object->update_price(1);
429 setEventMessages($db->lasterror(),
null,
'errors');
433 setEventMessages($line->error, $line->errors,
'errors');
435 } elseif ($action ==
'update_extras' && $permissiontoeditextra) {
438 $attribute_name =
GETPOST(
'attribute',
'aZ09');
441 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
447 $result =
$object->updateExtraField($attribute_name,
'BILLREC_MODIFY');
455 $action =
'edit_extras';
460 if ($action ==
'addline' && $permissiontoadd) {
461 $langs->load(
'errors');
469 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'alpha');
470 if ($prod_entry_mode ==
'free') {
472 $tva_tx = (
GETPOST(
'tva_tx',
'alpha') ? (string)
GETPOST(
'tva_tx',
'alpha') : 0);
473 $ref_fournisseur = (
GETPOSTISSET(
'fourn_ref') ?
GETPOST(
'fourn_ref',
'restricthtml') :
'');
479 $qty =
GETPOST(
'qty' . $predef,
'alpha');
480 $qty = ($qty ===
'') ?
'' : (float)
price2num(
GETPOST(
'qty' . $predef,
'alpha'),
'MS', 2);
484 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
485 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
487 if (is_array($extralabelsline)) {
489 foreach ($extralabelsline as $key => $value) {
490 unset($_POST[
"options_" . $key . $predef]);
494 if ((empty($idprod) || $idprod < 0) && ($price_ht < 0) && ((
float) $qty < 0)) {
495 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPriceHT'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
498 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
499 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
502 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && (! ($price_ht >= 0) || $price_ht ==
'')) {
503 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")),
null,
'errors');
507 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
510 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
511 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
515 $langs->load(
"errors");
516 setEventMessages($langs->trans(
'ErrorQtyForSupplierInvoiceCantBeNegative'),
null,
'errors');
520 $ref_fournisseur =
null;
521 if ($prod_entry_mode !=
'free' && empty($error)) {
525 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
529 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
530 $idprod = (int) $reg[1];
531 $res = $productsupplier->fetch($idprod);
534 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
536 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
537 if ($productsupplier->fourn_socid != $socid) {
538 $productsupplier->ref_supplier =
'';
541 $fksoctosearch =
$object->thirdparty->id;
542 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
544 } elseif (
GETPOSTINT(
'idprodfournprice') > 0) {
546 $idprod = $productsupplier->get_buyprice(
GETPOSTINT(
'idprodfournprice'), $qtytosearch);
547 $res = $productsupplier->fetch($idprod);
548 $ref_fournisseur = $productsupplier->ref_supplier;
552 if (! $error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) {
555 dol_print_error($db,
$object->error);
558 $ret =
$object->fetch_thirdparty();
563 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
575 if (!empty($idprod) && $idprod > 0) {
577 $prod->fetch($idprod);
579 $label = ((
GETPOST(
'product_label') &&
GETPOST(
'product_label') != $prod->label) ?
GETPOST(
'product_label') :
'');
584 if (empty($tva_tx)) {
591 $datapriceofproduct = $prod->getSellPrice(
$object->thirdparty,
$mysoc, $pqp);
593 $pu_ht = $datapriceofproduct[
'pu_ht'];
594 $pu_ttc = $datapriceofproduct[
'pu_ttc'];
595 $price_min = $datapriceofproduct[
'price_min'];
596 $price_base_type = empty($datapriceofproduct[
'price_base_type']) ?
'HT' : $datapriceofproduct[
'price_base_type'];
597 $tva_tx = $datapriceofproduct[
'tva_tx'];
598 $tva_npr = $datapriceofproduct[
'tva_npr'];
600 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string) $tva_tx));
601 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string) $prod->tva_tx));
604 if (!empty($price_ht)) {
606 $pu_ttc =
price2num((
float) $pu_ht * (1 + ((
float) $tmpvat / 100)),
'MU');
607 } elseif ($tmpvat != $tmpprodvat) {
610 if ($price_base_type !=
'HT') {
611 $pu_ht =
price2num($pu_ttc / (1 + ((
float) $tmpvat / 100)),
'MU');
613 $pu_ttc =
price2num($pu_ht * (1 + ((
float) $tmpvat / 100)),
'MU');
617 $outputlangs = $langs;
623 if (
GETPOST(
'lang_id',
'aZ09')) {
624 $newlang =
GETPOST(
'lang_id',
'aZ09');
626 if (empty($newlang)) {
627 $newlang =
$object->thirdparty->default_lang;
629 if (!empty($newlang)) {
631 $outputlangs->setDefaultLang($newlang);
632 $outputlangs->load(
'products');
635 $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] [
"description"])) ? $prod->multilangs [$outputlangs->defaultlang] [
"description"] : $prod->
description;
637 $desc = $prod->description;
643 if (!
getDolGlobalString(
'MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE') && (!empty($prod->customcode) || !empty($prod->country_code))) {
647 if (!empty($prod->customcode)) {
648 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomsCode") .
': ' . $prod->customcode;
650 if (!empty($prod->customcode) && !empty($prod->country_code)) {
653 if (!empty($prod->country_code)) {
654 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin") .
': ' .
getCountry($prod->country_code,
'', $db, $outputlangs, 0);
657 if (!empty($prod->customcode)) {
658 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomsCode") .
': ' . $prod->customcode;
660 if (!empty($prod->customcode) && !empty($prod->country_code)) {
663 if (!empty($prod->country_code)) {
664 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin") .
': ' .
getCountry($prod->country_code,
'', $db, $langs, 0);
672 $fk_unit = $prod->fk_unit;
676 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
677 $tva_tx = str_replace(
'*',
'', $tva_tx);
678 if (empty($tva_tx)) {
681 $desc = $product_desc;
686 $date_start_fill =
GETPOSTINT(
'date_start_fill');
690 $fournprice = (int) (
GETPOST(
'fournprice' . $predef) ?
GETPOST(
'fournprice' . $predef) :
'');
703 $remise_percent = (float)
price2num($remise_percent);
705 $price_min = (float)
price2num((
float) $price_min);
706 if ($usercanproductignorepricemin && (!empty($price_min) && ($pu_ht * (1 - $remise_percent / 100) < $price_min))) {
707 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
708 setEventMessages($mesg,
null,
'errors');
711 $result =
$object->addline($idprod, (
string) $ref_fournisseur, $label, $desc, $pu_ht, $pu_ttc, (
float) $qty, $remise_percent, (
string) $tva_tx, $localtax1_tx, $localtax2_tx, $price_base_type, $type, $date_start_fill, $date_end_fill, $info_bits, $special_code, -1, $fk_unit);
716 unset($_POST[
'prod_entry_mode']);
717 unset($_POST[
'qty']);
718 unset($_POST[
'type']);
719 unset($_POST[
'remise_percent']);
720 unset($_POST[
'price_ht']);
721 unset($_POST[
'multicurrency_price_ht']);
722 unset($_POST[
'price_ttc']);
723 unset($_POST[
'tva_tx']);
724 unset($_POST[
'product_ref']);
725 unset($_POST[
'product_label']);
726 unset($_POST[
'product_desc']);
727 unset($_POST[
'fournprice']);
728 unset($_POST[
'buying_price']);
729 unset($_POST[
'np_marginRate']);
730 unset($_POST[
'np_markRate']);
731 unset($_POST[
'dp_desc']);
732 unset($_POST[
'idprod']);
733 unset($_POST[
'units']);
734 unset($_POST[
'date_starthour']);
735 unset($_POST[
'date_startmin']);
736 unset($_POST[
'date_startsec']);
737 unset($_POST[
'date_startday']);
738 unset($_POST[
'date_startmonth']);
739 unset($_POST[
'date_startyear']);
740 unset($_POST[
'date_endhour']);
741 unset($_POST[
'date_endmin']);
742 unset($_POST[
'date_endsec']);
743 unset($_POST[
'date_endday']);
744 unset($_POST[
'date_endmonth']);
745 unset($_POST[
'date_endyear']);
746 unset($_POST[
'date_start_fill']);
747 unset($_POST[
'date_end_fill']);
748 unset($_POST[
'situations']);
749 unset($_POST[
'progress']);
750 unset($_POST[
'fourn_ref']);
758 } elseif ($action ==
'updateline' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
759 if (!
$object->fetch($id) > 0) {
760 dol_print_error($db);
768 $ref_fourn =
GETPOST(
'fourn_ref',
'alpha');
777 if (preg_match(
'/\*/', $vat_rate)) {
782 $vat_rate = str_replace(
'*',
'', $vat_rate);
787 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
788 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
791 if ($objectline->fetch(
GETPOSTINT(
'lineid'))) {
792 $objectline->array_options = $array_options;
793 $result = $objectline->insertExtraFields();
795 setEventMessages($langs->trans(
'Error') . $result,
null,
'errors');
799 $position = ($objectline->rang >= 0 ? $objectline->rang : 0);
802 if (is_array($extralabelsline)) {
804 foreach ($extralabelsline as $key => $value) {
805 unset($_POST[
"options_" . $key]);
811 if (!
GETPOST(
'qty',
'alpha')) {
819 if (!empty($productid)) {
821 $product->fetch($productid);
823 $type = $product->type;
825 $price_min = $product->price_min;
827 $price_min = $product->multiprices_min[
$object->thirdparty->price_level];
830 $label = $product->label;
833 if (((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
"produit",
"ignore_price_min_advance")) || !
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS')) && $price_min && ((
float)
price2num($pu_ht) * (1 - (
float) $remise_percent / 100) < (
float)
price2num($price_min))) {
834 setEventMessages($langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency)),
null,
'errors');
839 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
843 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
848 $langs->load(
"errors");
849 setEventMessages($langs->trans(
'ErrorQtyForSupplierInvoiceCantBeNegative'),
null,
'errors');
853 $date_start_fill =
GETPOSTINT(
'date_start_fill');
858 $result =
$object->updateline(
GETPOSTINT(
'lineid'),
GETPOSTINT(
'productid'), $ref_fourn, $label, $description, (
float) $pu_ht, (
float) $qty, (
float) $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate,
'HT', $type, $date_start_fill, $date_end_fill, $info_bits, $special_code, -1);
862 unset($_POST[
'qty']);
863 unset($_POST[
'type']);
864 unset($_POST[
'productid']);
865 unset($_POST[
'remise_percent']);
866 unset($_POST[
'price_ht']);
867 unset($_POST[
'multicurrency_price_ht']);
868 unset($_POST[
'price_ttc']);
869 unset($_POST[
'tva_tx']);
870 unset($_POST[
'product_ref']);
871 unset($_POST[
'product_label']);
872 unset($_POST[
'product_desc']);
873 unset($_POST[
'fournprice']);
874 unset($_POST[
'buying_price']);
875 unset($_POST[
'np_marginRate']);
876 unset($_POST[
'np_markRate']);
877 unset($_POST[
'dp_desc']);
878 unset($_POST[
'idprod']);
879 unset($_POST[
'units']);
880 unset($_POST[
'date_starthour']);
881 unset($_POST[
'date_startmin']);
882 unset($_POST[
'date_startsec']);
883 unset($_POST[
'date_startday']);
884 unset($_POST[
'date_startmonth']);
885 unset($_POST[
'date_startyear']);
886 unset($_POST[
'date_endhour']);
887 unset($_POST[
'date_endmin']);
888 unset($_POST[
'date_endsec']);
889 unset($_POST[
'date_endday']);
890 unset($_POST[
'date_endmonth']);
891 unset($_POST[
'date_endyear']);
892 unset($_POST[
'situations']);
893 unset($_POST[
'progress']);
894 unset($_POST[
'fourn_ref']);
907$title = $langs->trans(
"RepeatableSupplierInvoice");
909llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-fourn-facture page-card-rec');
911$form =
new Form($db);
918$companystatic =
new Societe($db);
925if ($action ==
'create') {
926 print
load_fiche_titre($langs->trans(
"CreateRepeatableInvoice"),
'',
'bill');
929 $product_static =
new Product($db);
931 if (
$object->fetch($id, $ref) > 0) {
932 $result =
$object->fetch_lines();
934 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST">';
935 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
936 print
'<input type="hidden" name="action" value="add">';
937 print
'<input type="hidden" name="facid" value="' .
$object->id .
'">';
949 print
'<table class="border centpercent">';
954 print
'<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans(
"Title") .
'</td><td>';
955 print
'<input class="flat quatrevingtpercent" type="text" name="title" value="' .
dol_escape_htmltag(
GETPOST(
"title",
'alphanohtml')) .
'" autofocus>';
959 print
'<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans(
"RefSupplier") .
'</td><td>';
960 print
'<input class="flat maxwidth500" type="text" name="ref_supplier" value="' .
$object->ref_supplier .
'">';
964 print
'<tr><td class="titlefieldcreate">' . $langs->trans(
"Supplier") .
'</td><td>' .
$object->thirdparty->getNomUrl(1,
'supplier') .
'</td>';
969 print
"<tr><td>".$langs->trans(
"InvoiceSubtype").
"</td><td>";
978 $substitutionarray = getCommonSubstitutionArray($langs, 2,
null, $object);
980 $substitutionarray[
'__INVOICE_PREVIOUS_MONTH__'] = $langs->trans(
"PreviousMonthOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
dol_time_plus_duree(
$object->date, -1,
'm'),
'%m') .
')';
981 $substitutionarray[
'__INVOICE_MONTH__'] = $langs->trans(
"MonthOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
$object->date,
'%m') .
')';
982 $substitutionarray[
'__INVOICE_NEXT_MONTH__'] = $langs->trans(
"NextMonthOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
dol_time_plus_duree(
$object->date, 1,
'm'),
'%m') .
')';
983 $substitutionarray[
'__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans(
"TextPreviousMonthOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
dol_time_plus_duree(
$object->date, -1,
'm'),
'%B') .
')';
984 $substitutionarray[
'__INVOICE_MONTH_TEXT__'] = $langs->trans(
"TextMonthOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
$object->date,
'%B') .
')';
985 $substitutionarray[
'__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans(
"TextNextMonthOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
dol_time_plus_duree(
$object->date, 1,
'm'),
'%B') .
')';
986 $substitutionarray[
'__INVOICE_PREVIOUS_YEAR__'] = $langs->trans(
"PreviousYearOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
dol_time_plus_duree(
$object->date, -1,
'y'),
'%Y') .
')';
987 $substitutionarray[
'__INVOICE_YEAR__'] = $langs->trans(
"YearOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
$object->date,
'%Y') .
')';
990 $substitutionarray[
'__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans(
"DateNextInvoiceBeforeGen");
991 $substitutionarray[
'__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans(
"DateNextInvoiceAfterGen");
992 $substitutionarray[
'__INVOICE_COUNTER_CURRENT__'] = $langs->trans(
"Count");
993 $substitutionarray[
'__INVOICE_COUNTER_MAX__'] = $langs->trans(
"MaxPeriodNumber");
995 $htmltext =
'<i>' . $langs->trans(
"FollowingConstantsWillBeSubstituted") .
':<br>';
996 foreach ($substitutionarray as $key => $val) {
997 $htmltext .= $key .
' = ' . $langs->trans($val) .
'<br>';
1002 print
'<tr><td class="titlefieldcreate">' . $langs->trans(
"Label") .
'</td><td>';
1003 print
'<input class="flat quatrevingtpercent" type="text" name="label" value="' .
$object->label .
'">';
1007 print
"<tr><td>" . $langs->trans(
"Author") .
"</td><td>" . $user->getFullName($langs) .
"</td></tr>";
1010 print
"<tr><td>" . $langs->trans(
"PaymentConditions") .
"</td><td>";
1011 print $form->getSelectConditionsPaiements(
GETPOSTISSET(
'cond_reglement_id') ?
GETPOST(
'cond_reglement_id',
'int') :
$object->cond_reglement_id,
'cond_reglement_id', -1, 0, 0,
'');
1015 print
"<tr><td>" . $langs->trans(
"PaymentMode") .
"</td><td>";
1016 print img_picto(
'',
'payment',
'class="pictofixedwidth"');
1017 print $form->select_types_paiements(
GETPOSTISSET(
'mode_reglement_id') ?
GETPOST(
'mode_reglement_id',
'int') :
$object->mode_reglement_id,
'mode_reglement_id',
'', 0, 1, 0, 0, 1,
'', 1);
1023 $langs->load(
'projects');
1024 print
'<tr><td>' . $langs->trans(
'Project') .
'</td><td>';
1025 $numprojet = $formproject->select_projects((!
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ?
$object->thirdparty->id : -1), $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 0, 0,
'');
1026 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 :
'')) .
'">' . $langs->trans(
"AddProject") .
'</a>';
1031 if (
$object->fk_account > 0) {
1032 print
"<tr><td>" . $langs->trans(
'BankAccount') .
"</td><td>";
1033 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_account,
'none');
1041 $extralabels = $extrafields->fetch_name_optionals_label($draft->table_element);
1042 if ($draft->fetch_optionals() > 0) {
1043 $object->array_options = array_merge(
$object->array_options, $draft->array_options);
1046 print
$object->showOptionals($extrafields,
'create', $parameters);
1049 print
"<tr><td>" . $langs->trans(
'Model') .
"</td><td>";
1050 include_once DOL_DOCUMENT_ROOT .
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
1052 print $form->selectarray(
'modelpdf', $list,
getDolGlobalString(
'INVOICE_SUPPLIER_ADDON_PDF'));
1057 print
'<td class="tdtop">';
1058 print $form->textwithpicto($langs->trans(
'NotePublic'), $htmltext, 1,
'help',
'', 0, 2,
'notepublic');
1061 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1062 print $doleditor->Create(1);
1065 if (empty($user->socid)) {
1067 print
'<td class="tdtop">';
1068 print $form->textwithpicto($langs->trans(
'NotePrivate'), $htmltext, 1,
'help',
'', 0, 2,
'noteprivate');
1071 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1072 print $doleditor->Create(1);
1081 $title = $langs->trans(
"Recurrence");
1082 print
load_fiche_titre(img_picto(
'',
'recurring',
'class="pictofixedwidth"') . $title,
'',
'');
1084 print
'<span class="opacitymedium">'.$langs->trans(
"ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv(
'Module2300Name')).
'</span><br><br>';
1088 print
'<table class="border centpercent">';
1091 print
'<tr><td class="titlefieldcreate">' . $form->textwithpicto($langs->trans(
"Frequency"), $langs->transnoentitiesnoconv(
'toolTipFrequency')) .
"</td><td>";
1092 print
"<input type='text' class='width50' name='frequency' value='" .
GETPOSTINT(
'frequency') .
"' size='4' /> " . $form->selectarray(
'unit_frequency', array(
'd' => $langs->trans(
'Day'),
'm' => $langs->trans(
'Month'),
'y' => $langs->trans(
'Year')), (
GETPOST(
'unit_frequency') ?
GETPOST(
'unit_frequency') :
'm'));
1096 print
"<tr><td>" . $langs->trans(
'NextDateToExecution') .
"</td><td>";
1098 print $form->selectDate($date_next_execution,
'', 1, 1, 0,
"add", 1, 1);
1102 print
"<tr><td>" . $langs->trans(
"MaxPeriodNumber") .
"</td><td>";
1103 print
'<input type="text" class="width50" name="nb_gen_max" value="' .
GETPOSTINT(
'nb_gen_max') .
'">';
1107 print
"<tr><td>" . $langs->trans(
"StatusOfAutoGeneratedInvoices") .
"</td><td>";
1108 $select = array(
'0' => $langs->trans(
'BillStatusDraft'),
'1' => $langs->trans(
'BillStatusValidated'));
1109 print $form->selectarray(
'auto_validate', $select,
GETPOSTINT(
'auto_validate'));
1114 print
"<tr><td>" . $langs->trans(
"StatusOfGeneratedDocuments") .
"</td><td>";
1115 $select = array(
'0' => $langs->trans(
'DoNotGenerateDoc'),
'1' => $langs->trans(
'AutoGenerateDoc'));
1116 print $form->selectarray(
'generate_pdf', $select,
GETPOSTINT(
'generate_pdf'));
1119 print
'<input type="hidden" name="generate_pdf" value="1">';
1126 $title = $langs->trans(
"ProductsAndServices");
1128 $title = $langs->trans(
"Products");
1130 $title = $langs->trans(
"Services");
1138 print
'<div class="div-table-responsive-no-min">';
1139 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
1153 print $form->buttonsSaveCancel(
"Create");
1157 dol_print_error(
null,
"Error, no invoice " .
$object->id);
1168 if ($action ==
'ask_deleteline') {
1169 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'',
'no', 1);
1173 if ($action ==
'ask_deleteinvoice') {
1174 $formconfirm = $form->formconfirm(
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id]), $langs->trans(
'DeleteRepeatableInvoice'), $langs->trans(
'ConfirmDeleteRepeatableInvoice'),
'confirm_deleteinvoice',
'',
'no', 1);
1179 $author =
new User($db);
1180 $author->fetch(
$object->user_creation_id);
1188 $linkback =
'<a href="' . DOL_URL_ROOT .
'/fourn/facture/list-rec.php?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
'BackToList') .
'</a>';
1191 if ($action !=
'edittitle') {
1192 $morehtmlref .= $form->editfieldkey(
$object->title,
'title',
$object->title, $object, (
int) $usercancreate,
'',
'', 0, 2);
1194 $morehtmlref .= $form->editfieldval(
'',
'title',
$object->title, $object, $usercancreate,
'string');
1196 $morehtmlref .=
'<div class="refidno">';
1198 $morehtmlref .= $form->editfieldkey(
"RefSupplier",
'ref_supplier',
$object->ref_supplier, $object, (
int) $usercancreate,
'string',
'', 0, 1);
1199 $morehtmlref .= $form->editfieldval(
"RefSupplier",
'ref_supplier',
$object->ref_supplier, $object, $usercancreate,
'string',
'',
null,
null,
'', 1);
1201 $morehtmlref .=
'<br>' . $langs->trans(
'ThirdParty') .
' : ' .
$object->thirdparty->getNomUrl(1);
1204 if (
isModEnabled(
'project') && $formproject !==
null) {
1205 $langs->load(
'projects');
1206 $morehtmlref .=
'<br>' . $langs->trans(
'Project') .
' ';
1207 if ($usercancreate) {
1208 if ($action !=
'classify') {
1209 $morehtmlref .=
'<a class="editfielda" href="' . $_SERVER[
'PHP_SELF'] .
'?action=classify&token=' .
newToken() .
'&id=' .
$object->id .
'">' . img_edit($langs->transnoentitiesnoconv(
'SetProject')) .
'</a> : ';
1211 if ($action ==
'classify') {
1212 $morehtmlref .=
'<form method="post" action="' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'">';
1213 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
1214 $morehtmlref .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1215 $morehtmlref .= $formproject->select_projects((!
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ?
$object->socid : -1), (string)
$object->fk_project,
'projectid', 0, 0, 1, 0, 1, 0, 0,
'', 1);
1216 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
1217 $morehtmlref .=
'</form>';
1219 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ?
$object->socid : -1),
$object->fk_project,
'none', 0, 0, 0, 1,
'',
'maxwidth300');
1222 if (!empty(
$object->fk_project)) {
1224 $project->fetch(
$object->fk_project);
1225 $morehtmlref .=
' : ' . $project->getNomUrl(1);
1226 if ($project->title) {
1227 $morehtmlref .=
' - ' . $project->title;
1234 $morehtmlref .=
'</div>';
1236 $morehtmlstatus =
'';
1238 dol_banner_tab($object,
'ref', $linkback, 1,
'title',
'none', $morehtmlref,
'', 0,
'', $morehtmlstatus);
1240 print
'<div class="fichecenter">';
1241 print
'<div class="fichehalfleft">';
1242 print
'<div class="underbanner clearboth"></div>';
1244 print
'<table class="border centpercent tableforfield">';
1248 print
"<tr><td>".$langs->trans(
"InvoiceSubtype").
"</td><td>";
1249 print
$object->getSubtypeLabel(
'facture_fourn_rec');
1254 print
'<tr><td class="titlefield">' . $langs->trans(
'Author') .
'</td><td>';
1255 print $author->getNomUrl(-1);
1260 print
'<td>' . $form->editfieldkey(
"Label",
'label',
$object->label, $object, (
int) $usercancreate) .
'</td>';
1261 print
'<td>' . $form->editfieldval(
"Label",
'label',
$object->label, $object, $usercancreate) .
'</td>';
1266 print
'<table class="nobordernopadding centpercent"><tr><td>';
1267 print $langs->trans(
'PaymentConditionsShort');
1269 if ($action !=
'editconditions' && $usercancreate) {
1270 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>';
1272 print
'</tr></table>';
1274 if ($action ==
'editconditions') {
1275 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?facid=' .
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id');
1277 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?facid=' .
$object->id, (
string)
$object->cond_reglement_id,
'none');
1284 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1285 print $langs->trans(
'PaymentMode');
1287 if ($action !=
'editmode' && $usercancreate) {
1288 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>';
1290 print
'</tr></table>';
1292 if ($action ==
'editmode') {
1293 $form->form_modes_reglement($_SERVER[
'PHP_SELF'] .
'?facid=' .
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
1295 $form->form_modes_reglement($_SERVER[
'PHP_SELF'] .
'?facid=' .
$object->id, (
string)
$object->mode_reglement_id,
'none');
1300 print
'<tr><td class="nowrap">';
1301 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1302 print $langs->trans(
'BankAccount');
1304 if ($action !=
'editbankaccount' && $usercancreate &&
$object->status == FactureFournisseurRec::STATUS_NOTSUSPENDED) {
1305 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>';
1307 print
'</tr></table>';
1309 if ($action ==
'editbankaccount') {
1310 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
1312 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_account,
'none');
1318 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1321 print
'<tr><td class="nowrap">';
1322 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
1323 print $langs->trans(
'Model');
1325 if ($action !=
'editmodelpdf' && $usercancreate &&
$object->status == FactureFournisseurRec::STATUS_NOTSUSPENDED) {
1326 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>';
1328 print
'</tr></table>';
1330 if ($action ==
'editmodelpdf') {
1331 include_once DOL_DOCUMENT_ROOT .
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
1334 foreach ($models as $k => $model) {
1335 $list[] = str_replace(
':',
'|', $k) .
':' . $model;
1337 $select =
'select;' . implode(
',', $list);
1339 print $form->editfieldval($langs->trans(
'Model'),
'modelpdf',
$object->model_pdf, $object, $usercancreate, $select);
1352 print
'<div class="fichehalfright">';
1353 print
'<div class="underbanner clearboth"></div>';
1358 $title = $langs->trans(
"Recurrence");
1361 print
'<table class="border centpercent tableforfield">';
1363 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
1366 print
'<tr><td>' . $langs->trans(
'AmountHT') .
'</td>';
1367 print
'<td>' .
price(
$object->total_ht, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
1370 print
'<tr><td>' . $langs->trans(
"AmountVAT") .
'</td><td>' .
price(
$object->total_tva, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
1374 if ((
$mysoc->localtax1_assuj ==
"1" &&
$mysoc->useLocalTax(1)) ||
$object->total_localtax1 != 0) {
1375 print
'<tr><td>' . $langs->transcountry(
"AmountLT1",
$mysoc->country_code) .
'</td>';
1376 print
'<td class="nowrap">' .
price(
$object->total_localtax1, 1,
'', 1, -1, -1,
$conf->currency) .
'</td></tr>';
1378 if ((
$mysoc->localtax2_assuj ==
"1" &&
$mysoc->useLocalTax(2)) ||
$object->total_localtax2 != 0) {
1379 print
'<tr><td>' . $langs->transcountry(
"AmountLT2",
$mysoc->country_code) .
'</td>';
1380 print
'<td class=nowrap">' .
price(
$object->total_localtax2, 1,
'', 1, -1, -1,
$conf->currency) .
'</td></tr>';
1383 print
'<tr><td>' . $langs->trans(
"AmountTTC") .
'</td><td colspan="3">' .
price(
$object->total_ttc, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
1387 print
'<tr class="liste_titre"><td colspan="2" class="liste_titre">' . img_picto(
'',
'recurring',
'class="pictofixedwidth"') . $title .
'</td></tr>';
1390 print
'<tr><td style="width: 50%">';
1391 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1392 print $langs->trans(
'Frequency');
1394 if ($action !=
'editfrequency' && $usercancreate) {
1395 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>';
1397 print
'</tr></table>';
1399 if ($action ==
'editfrequency') {
1400 print
'<form method="post" action="' . $_SERVER[
"PHP_SELF"] .
'?facid=' .
$object->id .
'">';
1401 print
'<input type="hidden" name="action" value="setfrequency">';
1402 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1403 print
'<table class="nobordernopadding">';
1405 print
"<input type='text' name='frequency' value='" .
$object->frequency .
"' size='5' /> " . $form->selectarray(
'unit_frequency', array(
'd' => $langs->trans(
'Day'),
'm' => $langs->trans(
'Month'),
'y' => $langs->trans(
'Year')), (
$object->unit_frequency ?
$object->unit_frequency :
'm'));
1407 print
'<td class="left"><input type="submit" class="button button-edit" value="' . $langs->trans(
"Modify") .
'"></td>';
1408 print
'</tr></table></form>';
1411 print $langs->trans(
'FrequencyPer_' .
$object->unit_frequency,
$object->frequency);
1413 print
'<span class="opacitymedium">'.$langs->trans(
"NotARecurringInvoiceTemplate").
'</span>';
1421 if ($action ==
'date_when' ||
$object->frequency > 0) {
1422 print $form->editfieldkey($langs->trans(
"NextDateToExecution"),
'date_when', (
string)
$object->date_when, $object, (
int) $usercancreate,
'day');
1424 print $langs->trans(
"NextDateToExecution");
1427 if ($action ==
'date_when' ||
$object->frequency > 0) {
1428 print $form->editfieldval($langs->trans(
"NextDateToExecution"),
'date_when',
$object->date_when, $object, $usercancreate,
'day',
$object->date_when,
null,
'',
'', 0,
'strikeIfMaxNbGenReached');
1431 if (!
$object->isMaxNbGenReached()) {
1433 print img_warning($langs->trans(
"Late"));
1436 print img_info($langs->trans(
"MaxNumberOfGenerationReached"));
1443 if ($action ==
'nb_gen_max' ||
$object->frequency > 0) {
1444 print $form->editfieldkey($langs->trans(
"MaxPeriodNumber"),
'nb_gen_max', (
string)
$object->nb_gen_max, $object, (
int) $usercancreate);
1446 print $langs->trans(
"MaxPeriodNumber");
1449 if ($action ==
'nb_gen_max' ||
$object->frequency > 0) {
1450 print $form->editfieldval($langs->trans(
"MaxPeriodNumber"),
'nb_gen_max',
$object->nb_gen_max ?
$object->nb_gen_max :
'',
$object, $usercancreate);
1459 if ($action ==
'auto_validate' ||
$object->frequency > 0) {
1460 print $form->editfieldkey($langs->trans(
"StatusOfAutoGeneratedInvoices"),
'auto_validate', (
string)
$object->auto_validate, $object, (
int) $usercancreate);
1462 print $langs->trans(
"StatusOfAutoGeneratedInvoices");
1465 $select =
'select;0:' . $langs->trans(
'BillStatusDraft') .
',1:' . $langs->trans(
'BillStatusValidated');
1466 if ($action ==
'auto_validate' ||
$object->frequency > 0) {
1467 print $form->editfieldval($langs->trans(
"StatusOfAutoGeneratedInvoices"),
'auto_validate',
$object->auto_validate, $object, $usercancreate, $select);
1474 if ($action ==
'generate_pdf' ||
$object->frequency > 0) {
1475 print $form->editfieldkey($langs->trans(
"StatusOfGeneratedDocuments"),
'generate_pdf', (
string)
$object->generate_pdf, $object, (
int) $usercancreate);
1477 print $langs->trans(
"StatusOfGeneratedDocuments");
1481 $select =
'select;0:' . $langs->trans(
'DoNotGenerateDoc') .
',1:' . $langs->trans(
'AutogenerateDoc');
1482 if ($action ==
'generate_pdf' ||
$object->frequency > 0) {
1483 print $form->editfieldval($langs->trans(
"StatusOfGeneratedDocuments"),
'generate_pdf',
$object->generate_pdf, $object, $usercancreate, $select);
1488 print
'<input type="hidden" name="generate_pdf" value="1">';
1499 print
info_admin($langs->trans(
"EnableAndSetupModuleCron", $langs->transnoentitiesnoconv(
"Module2300Name")));
1502 print
'<div class="underbanner clearboth"></div>';
1503 print
'<table class="border centpercent tableforfield">';
1506 print
'<tr><td style="width: 50%">' . $langs->trans(
"NbOfGenerationDone") .
'</td>';
1514 print $langs->trans(
"DateLastGeneration");
1528 print
'<div class="clearboth"></div><br>';
1531 print
' <form name="addproduct" id="addproduct" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id . (($action !=
'editline') ?
'#add' :
'#line_' .
GETPOSTINT(
'lineid')) .
'" method="POST">
1532 <input type="hidden" name="token" value="' .
newToken() .
'">
1533 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline') .
'">
1534 <input type="hidden" name="mode" value="">
1535 <input type="hidden" name="id" value="' .
$object->id .
'">
1538 if (!empty(
$conf->use_javascript_ajax) &&
$object->status == FactureFournisseurRec::STATUS_NOTSUSPENDED) {
1539 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
1542 print
'<div class="div-table-responsive-no-min">';
1543 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
1547 global $canchangeproduct;
1548 $canchangeproduct = 0;
1557 if (
$object->status == FactureFournisseurRec::STATUS_NOTSUSPENDED && $usercancreate && $action !=
'valid' && $action !=
'editline') {
1558 if ($action !=
'editline') {
1561 $parameters = array();
1562 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
1564 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1566 if (empty($reshook)) {
1567 global $senderissupplier;
1569 $senderissupplier = 2;
1584 print
'<div class="tabsAction">';
1586 if (empty(
$object->suspended)) {
1587 if ($usercancreate) {
1589 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' .
dol_escape_htmltag($langs->trans(
"MaxGenerationReached")) .
'">' . $langs->trans(
"CreateBill") .
'</a></div>';
1591 if (empty(
$object->frequency) ||
$object->date_when <= $nowlasthour) {
1592 print
'<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT .
'/fourn/facture/card.php?action=create&socid=' .
$object->thirdparty->id .
'&fac_rec=' .
$object->id .
'">' . $langs->trans(
"CreateBill") .
'</a></div>';
1594 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' .
dol_escape_htmltag($langs->trans(
"DateIsNotEnough")) .
'">' . $langs->trans(
"CreateBill") .
'</a></div>';
1598 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">' . $langs->trans(
"CreateBill") .
'</a></div>';
1602 if ($usercancreate) {
1603 if (empty(
$object->suspended)) {
1604 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>';
1606 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>';
1611 print dolGetButtonAction($langs->trans(
"Delete"), $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=ask_deleteinvoice&token='.
newToken(),
'delete', ($user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"supprimer")), array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
1615 print
'<div class="fichecenter"><div class="fichehalfleft">';
1616 print
'<a name="builddoc"></a>';
1619 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'invoice'), 1);
1620 $linktoelem = $tmparray[
'linktoelem'];
1621 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
1622 print $htmltoenteralink;
1624 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
1626 print
'</div></div>';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage a WYSIWYG editor.
Class to manage suppliers invoices.
Class to manage supplier invoice lines of templates.
Class to manage invoice templates.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage predefined suppliers products.
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.
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 '.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that returns whether VAT must be recoverable collected VAT (e.g.: VAT NPR in France)
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
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.
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)
supplier_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.