36require
'../../main.inc.php';
37require_once DOL_DOCUMENT_ROOT .
'/fourn/class/fournisseur.facture-rec.class.php';
38require_once DOL_DOCUMENT_ROOT .
'/fourn/class/fournisseur.product.class.php';
39require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
40require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formother.class.php';
41if (isModEnabled(
'project')) {
42 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
44require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
45require_once DOL_DOCUMENT_ROOT .
'/core/class/doleditor.class.php';
46require_once DOL_DOCUMENT_ROOT .
'/core/lib/invoice.lib.php';
47require_once DOL_DOCUMENT_ROOT .
'/core/class/extrafields.class.php';
59$langs->loadLangs(array(
'bills',
'companies',
'compta',
'admin',
'other',
'products',
'banks',
'suppliers'));
61$action =
GETPOST(
'action',
'alpha');
62$massaction =
GETPOST(
'massaction',
'alpha');
64$confirm =
GETPOST(
'confirm',
'alpha');
65$cancel =
GETPOST(
'cancel',
'alpha');
66$toselect =
GETPOST(
'toselect',
'array');
67$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'supplierinvoicetemplatelist';
70$sortfield =
GETPOST(
"sortfield",
'alpha');
71$sortorder =
GETPOST(
"sortorder",
'alpha');
77$title =
GETPOST(
'title',
'alpha');
78$libelle =
GETPOST(
'libelle',
'alpha');
79$ref_supplier =
GETPOST(
'ref_supplier',
'alpha');
81$year_date_when =
GETPOST(
'year_date_when');
82$month_date_when =
GETPOST(
'month_date_when');
86 $socid = $user->socid;
88$objecttype =
'facture_fourn_rec';
89if ($action ==
"create" || $action ==
"add") {
93if (empty($page) || $page == -1) {
96$offset = $limit * $page;
101 $sortfield =
'f.titre';
103$pageprev = $page - 1;
104$pagenext = $page + 1;
107if (($id > 0 || $title) && $action !=
'create' && $action !=
'add') {
108 $ret =
$object->fetch($id, $title);
115$hookmanager->initHooks(array(
'supplierinvoicereccard',
'globalcard'));
119$extrafields->fetch_name_optionals_label(
$object->table_element);
121$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
123$permissionnote = $user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer");
124$permissiondellink = $user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer");
125$permissiontoedit = $user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer");
126$permissiontoadd = $user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer");
127$permissiontodelete = ($user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"supprimer"));
129$usercanread = $user->hasRight(
"fournisseur",
"facture",
"lire") || $user->hasRight(
"supplier_invoice",
"lire");
130$usercancreate = $user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer");
131$usercandelete = $user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"supprimer");
132$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"validate")));
133$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"send"));
135$usercanproductignorepricemin = ((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
"produit",
"ignore_price_min_advance")) || !
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS'));
136$usercancreatemargin = $user->hasRight(
"margins",
"creer");
137$usercanreadallmargin = $user->hasRight(
"margins",
"liretous");
138$usercancreatewithdrarequest = $user->hasRight(
"prelevement",
"bons",
"creer");
151if (
GETPOST(
'cancel',
'alpha')) {
155if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
159$parameters = array(
'socid' => $socid);
160$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
165if (empty($reshook)) {
166 if (
GETPOST(
'cancel',
'alpha')) {
171 include DOL_DOCUMENT_ROOT .
'/core/actions_changeselectedfields.inc.php';
174 include DOL_DOCUMENT_ROOT .
'/core/actions_setnotes.inc.php';
176 include DOL_DOCUMENT_ROOT .
'/core/actions_dellink.inc.php';
178 include DOL_DOCUMENT_ROOT .
'/core/actions_lineupdown.inc.php';
181 if ($action ==
'add' && $permissiontoadd) {
182 if (!
GETPOST(
'title',
'alphanohtml')) {
183 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Title")),
null,
'errors');
198 if (empty($reyear) || empty($remonth) || empty($reday)) {
199 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Date")),
null,
'errors');
218 $object->frequency = $frequency;
220 $object->nb_gen_max = $nb_gen_max;
224 $date_next_execution =
dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
225 $object->date_when = $date_next_execution;
227 $ret = $extrafields->setOptionalsFromPost(
null, $object);
239 $result =
$object->create($user, $oldinvoice->id);
242 $result = $oldinvoice->delete($user, 1);
257 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
'?facid=' .
$object->id);
271 if ($action ==
'confirm_deleteinvoice' && $confirm ==
'yes' && $permissiontodelete) {
274 header(
'Location: ' . DOL_URL_ROOT .
'/fourn/facture/list-rec.php');
280 if ($action ==
'setconditions' && $usercancreate) {
282 } elseif ($action ==
'setmode' && $usercancreate) {
285 } elseif ($action ==
'classin' && $usercancreate) {
288 } elseif ($action ==
'setref_supplier' && $usercancreate) {
289 $result =
$object->setValueFrom(
'ref_supplier', $ref_supplier,
'',
null,
'text',
'', $user);
293 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
294 $langs->load(
"errors");
295 setEventMessages($langs->trans(
'ErrorRefAlreadyExists', $ref_supplier),
null,
'errors');
300 } elseif ($action ==
'settitle' && $permissiontoadd) {
301 $result =
$object->setValueFrom(
'titre', $title,
'',
null,
'text',
'', $user);
309 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
310 $langs->load(
"errors");
311 setEventMessages($langs->trans(
'ErrorTitreAlreadyExists', $title),
null,
'errors');
316 } elseif ($action ==
'setbankaccount' && $permissiontoadd) {
319 } elseif ($action ==
'setfrequency' && $permissiontoadd) {
322 } elseif ($action ==
'setdate_when' && $permissiontoadd) {
328 } elseif ($action ==
'setnb_gen_max' && $permissiontoadd) {
331 } elseif ($action ==
'setauto_validate' && $permissiontoadd) {
334 } elseif ($action ==
'setgenerate_pdf' && $permissiontoadd) {
337 } elseif ($action ==
'setmodelpdf' && $permissiontoadd) {
340 } elseif ($action ==
'disable' && $permissiontoadd) {
346 $res =
$object->setValueFrom(
'suspended', 1);
357 } elseif ($action ==
'enable' && $permissiontoadd) {
363 $res =
$object->setValueFrom(
'suspended', 0);
374 } elseif ($action ==
'setmulticurrencycode' && $permissiontoadd) {
376 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
377 } elseif ($action ==
'setmulticurrencyrate' && $permissiontoadd) {
380 } elseif ($action ==
'setlibelle' && $permissiontoadd) {
385 $result =
$object->update($user);
393 if ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $permissiontoadd) {
404 if ($line->delete($user) > 0) {
405 $result =
$object->update_price(1);
418 } elseif ($action ==
'update_extras' && $permissiontoadd) {
422 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
428 $result =
$object->insertExtraFields(
'BILLREC_MODIFY');
437 if ($action ==
'addline' && $permissiontoadd) {
438 $langs->load(
'errors');
443 $product_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
446 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'alpha');
447 if ($prod_entry_mode ==
'free') {
449 $tva_tx = (
GETPOST(
'tva_tx',
'alpha') ?
GETPOST(
'tva_tx',
'alpha') : 0);
450 $ref_fournisseur = (GETPOSTISSET(
'fourn_ref') ?
GETPOST(
'fourn_ref',
'restricthtml') :
'');
460 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
461 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
463 if (is_array($extralabelsline)) {
465 foreach ($extralabelsline as $key => $value) {
466 unset($_POST[
"options_" . $key . $predef]);
470 if ((empty($idprod) || $idprod < 0) && ($price_ht < 0) && ($qty < 0)) {
471 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPriceHT'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
474 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
475 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
478 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && (! ($price_ht >= 0) || $price_ht ==
'')) {
479 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")),
null,
'errors');
483 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
486 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
487 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
491 $langs->load(
"errors");
492 setEventMessages($langs->trans(
'ErrorQtyForSupplierInvoiceCantBeNegative'),
null,
'errors');
496 if ($prod_entry_mode !=
'free' && empty($error)) {
500 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
504 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
505 $idprod = (int) $reg[1];
506 $res = $productsupplier->fetch($idprod);
509 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
511 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
512 if ($productsupplier->fourn_socid != $socid) {
513 $productsupplier->ref_supplier =
'';
516 $fksoctosearch =
$object->thirdparty->id;
517 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
519 } elseif (
GETPOST(
'idprodfournprice',
'alpha') > 0) {
521 $idprod = $productsupplier->get_buyprice(
GETPOST(
'idprodfournprice',
'alpha'), $qtytosearch);
522 $res = $productsupplier->fetch($idprod);
523 $ref_fournisseur = $productsupplier->ref_supplier;
527 if (! $error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) {
533 $ret =
$object->fetch_thirdparty();
536 $date_start =
dol_mktime(
GETPOST(
'date_start' . $predef .
'hour'),
GETPOST(
'date_start' . $predef .
'min'),
GETPOST(
'date_start' . $predef .
'sec'),
GETPOST(
'date_start' . $predef .
'month'),
GETPOST(
'date_start' . $predef .
'day'),
GETPOST(
'date_start' . $predef .
'year'));
537 $date_end =
dol_mktime(
GETPOST(
'date_end' . $predef .
'hour'),
GETPOST(
'date_end' . $predef .
'min'),
GETPOST(
'date_end' . $predef .
'sec'),
GETPOST(
'date_end' . $predef .
'month'),
GETPOST(
'date_end' . $predef .
'day'),
GETPOST(
'date_end' . $predef .
'year'));
538 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
549 if (!empty($idprod) && $idprod > 0) {
551 $prod->fetch($idprod);
553 $label = ((
GETPOST(
'product_label') &&
GETPOST(
'product_label') != $prod->label) ?
GETPOST(
'product_label') :
'');
558 if (empty($tva_tx)) {
565 $datapriceofproduct = $prod->getSellPrice(
$object->thirdparty, $mysoc, $pqp);
567 $pu_ht = $datapriceofproduct[
'pu_ht'];
568 $pu_ttc = $datapriceofproduct[
'pu_ttc'];
569 $price_min = $datapriceofproduct[
'price_min'];
570 $price_base_type = empty($datapriceofproduct[
'price_base_type']) ?
'HT' : $datapriceofproduct[
'price_base_type'];
571 $tva_tx = $datapriceofproduct[
'tva_tx'];
572 $tva_npr = $datapriceofproduct[
'tva_npr'];
574 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string) $tva_tx));
575 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string) $prod->tva_tx));
578 if (!empty($price_ht)) {
580 $pu_ttc =
price2num((
float) $pu_ht * (1 + ((
float) $tmpvat / 100)),
'MU');
581 } elseif ($tmpvat != $tmpprodvat) {
584 if ($price_base_type !=
'HT') {
585 $pu_ht =
price2num($pu_ttc / (1 + ((
float) $tmpvat / 100)),
'MU');
587 $pu_ttc =
price2num($pu_ht * (1 + ((
float) $tmpvat / 100)),
'MU');
595 $outputlangs = $langs;
597 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
598 $newlang =
GETPOST(
'lang_id',
'aZ09');
600 if (empty($newlang)) {
601 $newlang =
$object->thirdparty->default_lang;
603 if (!empty($newlang)) {
605 $outputlangs->setDefaultLang($newlang);
608 $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] [
"description"])) ? $prod->multilangs [$outputlangs->defaultlang] [
"description"] : $prod->
description;
610 $desc = $prod->description;
616 if (!
getDolGlobalString(
'MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE') && (!empty($prod->customcode) || !empty($prod->country_code))) {
620 $outputlangs = $langs;
622 if (empty($newlang) &&
GETPOST(
'lang_id',
'alpha')) {
623 $newlang =
GETPOST(
'lang_id',
'alpha');
625 if (empty($newlang)) {
626 $newlang =
$object->thirdparty->default_lang;
628 if (!empty($newlang)) {
630 $outputlangs->setDefaultLang($newlang);
631 $outputlangs->load(
'products');
633 if (!empty($prod->customcode)) {
634 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomCode") .
': ' . $prod->customcode;
636 if (!empty($prod->customcode) && !empty($prod->country_code)) {
639 if (!empty($prod->country_code)) {
640 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin") .
': ' .
getCountry($prod->country_code,
'', $db, $outputlangs, 0);
643 if (!empty($prod->customcode)) {
644 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomCode") .
': ' . $prod->customcode;
646 if (!empty($prod->customcode) && !empty($prod->country_code)) {
649 if (!empty($prod->country_code)) {
650 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin") .
': ' .
getCountry($prod->country_code,
'', $db, $langs, 0);
658 $fk_unit = $prod->fk_unit;
662 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
663 $tva_tx = str_replace(
'*',
'', $tva_tx);
664 if (empty($tva_tx)) {
667 $desc = $product_desc;
669 $fk_unit =
GETPOST(
'units',
'alpha');
672 $date_start_fill = !empty(
GETPOSTINT(
'date_start_fill')) ?
GETPOSTINT(
'date_start_fill') : null;
689 $remise_percent = (float)
price2num($remise_percent);
691 $price_min = (float)
price2num($price_min);
692 if ($usercanproductignorepricemin && (!empty($price_min) && ($pu_ht * (1 - $remise_percent / 100) < $price_min))) {
693 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
697 $result =
$object->addline($idprod, $ref_fournisseur, $label, $desc, $pu_ht, $pu_ttc, $qty, $remise_percent, $tva_tx, $localtax1_tx, $localtax2_tx, $price_base_type, $type, $date_start_fill, $date_end_fill, $info_bits, $special_code, -1, $fk_unit);
702 unset($_POST[
'prod_entry_mode']);
703 unset($_POST[
'qty']);
704 unset($_POST[
'type']);
705 unset($_POST[
'remise_percent']);
706 unset($_POST[
'price_ht']);
707 unset($_POST[
'multicurrency_price_ht']);
708 unset($_POST[
'price_ttc']);
709 unset($_POST[
'tva_tx']);
710 unset($_POST[
'product_ref']);
711 unset($_POST[
'product_label']);
712 unset($_POST[
'product_desc']);
713 unset($_POST[
'fournprice']);
714 unset($_POST[
'buying_price']);
715 unset($_POST[
'np_marginRate']);
716 unset($_POST[
'np_markRate']);
717 unset($_POST[
'dp_desc']);
718 unset($_POST[
'idprod']);
719 unset($_POST[
'units']);
720 unset($_POST[
'date_starthour']);
721 unset($_POST[
'date_startmin']);
722 unset($_POST[
'date_startsec']);
723 unset($_POST[
'date_startday']);
724 unset($_POST[
'date_startmonth']);
725 unset($_POST[
'date_startyear']);
726 unset($_POST[
'date_endhour']);
727 unset($_POST[
'date_endmin']);
728 unset($_POST[
'date_endsec']);
729 unset($_POST[
'date_endday']);
730 unset($_POST[
'date_endmonth']);
731 unset($_POST[
'date_endyear']);
732 unset($_POST[
'date_start_fill']);
733 unset($_POST[
'date_end_fill']);
734 unset($_POST[
'situations']);
735 unset($_POST[
'progress']);
743 } elseif ($action ==
'updateline' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
744 if (!
$object->fetch($id) > 0) {
753 $ref_fourn =
GETPOST(
'fourn_ref',
'alpha');
761 if (preg_match(
'/\*/', $vat_rate)) {
766 $vat_rate = str_replace(
'*',
'', $vat_rate);
771 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
772 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
775 if ($objectline->fetch(
GETPOSTINT(
'lineid'))) {
776 $objectline->array_options = $array_options;
777 $result = $objectline->insertExtraFields();
783 $position = ($objectline->rang >= 0 ? $objectline->rang : 0);
786 if (is_array($extralabelsline)) {
788 foreach ($extralabelsline as $key => $value) {
789 unset($_POST[
"options_" . $key]);
795 if (!
GETPOST(
'qty',
'alpha')) {
803 if (!empty($productid)) {
805 $product->fetch($productid);
807 $type = $product->type;
809 $price_min = $product->price_min;
811 $price_min = $product->multiprices_min[
$object->thirdparty->price_level];
814 $label = $product->label;
817 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))) {
818 setEventMessages($langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency)),
null,
'errors');
823 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
827 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
832 $langs->load(
"errors");
833 setEventMessages($langs->trans(
'ErrorQtyForSupplierInvoiceCantBeNegative'),
null,
'errors');
837 $date_start_fill = !empty(
GETPOSTINT(
'date_start_fill')) ?
GETPOSTINT(
'date_start_fill') :
'NULL';
842 $result =
$object->updateline(
GETPOSTINT(
'lineid'),
GETPOSTINT(
'productid'), $ref_fourn, $label, $description, $pu_ht, $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax1_rate,
'HT', $type, $date_start_fill, $date_end_fill, $info_bits, $special_code, -1);
846 unset($_POST[
'qty']);
847 unset($_POST[
'type']);
848 unset($_POST[
'productid']);
849 unset($_POST[
'remise_percent']);
850 unset($_POST[
'price_ht']);
851 unset($_POST[
'multicurrency_price_ht']);
852 unset($_POST[
'price_ttc']);
853 unset($_POST[
'tva_tx']);
854 unset($_POST[
'product_ref']);
855 unset($_POST[
'product_label']);
856 unset($_POST[
'product_desc']);
857 unset($_POST[
'fournprice']);
858 unset($_POST[
'buying_price']);
859 unset($_POST[
'np_marginRate']);
860 unset($_POST[
'np_markRate']);
861 unset($_POST[
'dp_desc']);
862 unset($_POST[
'idprod']);
863 unset($_POST[
'units']);
864 unset($_POST[
'date_starthour']);
865 unset($_POST[
'date_startmin']);
866 unset($_POST[
'date_startsec']);
867 unset($_POST[
'date_startday']);
868 unset($_POST[
'date_startmonth']);
869 unset($_POST[
'date_startyear']);
870 unset($_POST[
'date_endhour']);
871 unset($_POST[
'date_endmin']);
872 unset($_POST[
'date_endsec']);
873 unset($_POST[
'date_endday']);
874 unset($_POST[
'date_endmonth']);
875 unset($_POST[
'date_endyear']);
876 unset($_POST[
'situations']);
877 unset($_POST[
'progress']);
891llxHeader(
'', $langs->trans(
"RepeatableSupplierInvoice"), $help_url,
'', 0, 0,
'',
'',
'',
'mod-fourn-facture page-card-rec');
893$form =
new Form($db);
895if (isModEnabled(
'project')) {
898$companystatic =
new Societe($db);
906if ($action ==
'create') {
907 print
load_fiche_titre($langs->trans(
"CreateRepeatableInvoice"),
'',
'bill');
910 $product_static =
new Product($db);
913 $result =
$object->fetch_lines();
915 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST">';
916 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
917 print
'<input type="hidden" name="action" value="add">';
918 print
'<input type="hidden" name="facid" value="' .
$object->id .
'">';
923 if (isModEnabled(
'project')) {
930 print
'<table class="border centpercent">';
935 print
'<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans(
"Title") .
'</td><td>';
936 print
'<input class="flat quatrevingtpercent" type="text" name="title" value="' .
dol_escape_htmltag(
GETPOST(
"title",
'alphanohtml')) .
'" autofocus>';
940 print
'<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans(
"RefSupplier") .
'</td><td>';
941 print
'<input class="flat maxwidth500" type="text" name="ref_supplier" value="' .
$object->ref_supplier .
'">';
945 print
'<tr><td class="titlefieldcreate">' . $langs->trans(
"Supplier") .
'</td><td>' .
$object->thirdparty->getNomUrl(1,
'supplier') .
'</td>';
950 print
"<tr><td>".$langs->trans(
"InvoiceSubtype").
"</td><td>";
951 print $form->getSelectInvoiceSubtype(GETPOSTISSET(
'subtype') ?
GETPOST(
'subtype') :
$object->subtype,
'subtype', 0, 0,
'');
955 $note_public = GETPOSTISSET(
'note_public') ?
GETPOST(
'note_public',
'restricthtml') :
$object->note_public;
956 $note_private = GETPOSTISSET(
'note_private') ?
GETPOST(
'note_private',
'restricthtml') :
$object->note_private;
961 $substitutionarray[
'__INVOICE_PREVIOUS_MONTH__'] = $langs->trans(
"PreviousMonthOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
dol_time_plus_duree(
$object->date, -1,
'm'),
'%m') .
')';
962 $substitutionarray[
'__INVOICE_MONTH__'] = $langs->trans(
"MonthOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
$object->date,
'%m') .
')';
963 $substitutionarray[
'__INVOICE_NEXT_MONTH__'] = $langs->trans(
"NextMonthOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
dol_time_plus_duree(
$object->date, 1,
'm'),
'%m') .
')';
964 $substitutionarray[
'__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans(
"TextPreviousMonthOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
dol_time_plus_duree(
$object->date, -1,
'm'),
'%B') .
')';
965 $substitutionarray[
'__INVOICE_MONTH_TEXT__'] = $langs->trans(
"TextMonthOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
$object->date,
'%B') .
')';
966 $substitutionarray[
'__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans(
"TextNextMonthOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
dol_time_plus_duree(
$object->date, 1,
'm'),
'%B') .
')';
967 $substitutionarray[
'__INVOICE_PREVIOUS_YEAR__'] = $langs->trans(
"PreviousYearOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
dol_time_plus_duree(
$object->date, -1,
'y'),
'%Y') .
')';
968 $substitutionarray[
'__INVOICE_YEAR__'] = $langs->trans(
"YearOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
$object->date,
'%Y') .
')';
971 $substitutionarray[
'__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans(
"DateNextInvoiceBeforeGen") . (isset(
$object->date_when) ?
' (' . $langs->trans(
"Example") .
': ' .dol_print_date(
$object->date_when,
'dayhour') .
')' :
'');
972 $substitutionarray[
'__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans(
"DateNextInvoiceAfterGen") . (isset(
$object->date_when) ?
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
dol_time_plus_duree(
$object->date_when,
$object->frequency,
$object->unit_frequency),
'dayhour') .
')' :
'');
973 $substitutionarray[
'__INVOICE_COUNTER_CURRENT__'] = $langs->trans(
"Count");
974 $substitutionarray[
'__INVOICE_COUNTER_MAX__'] = $langs->trans(
"MaxPeriodNumber");
976 $htmltext =
'<i>' . $langs->trans(
"FollowingConstantsWillBeSubstituted") .
':<br>';
977 foreach ($substitutionarray as $key => $val) {
978 $htmltext .= $key .
' = ' . $langs->trans($val) .
'<br>';
983 print
'<tr><td class="titlefieldcreate">' . $langs->trans(
"Label") .
'</td><td>';
984 print
'<input class="flat quatrevingtpercent" type="text" name="libelle" value="' .
$object->label .
'">';
988 print
"<tr><td>" . $langs->trans(
"Author") .
"</td><td>" . $user->getFullName($langs) .
"</td></tr>";
991 print
"<tr><td>" . $langs->trans(
"PaymentConditions") .
"</td><td>";
992 print $form->getSelectConditionsPaiements(GETPOSTISSET(
'cond_reglement_id') ?
GETPOST(
'cond_reglement_id',
'int') :
$object->cond_reglement_id,
'cond_reglement_id', -1, 0, 0,
'');
996 print
"<tr><td>" . $langs->trans(
"PaymentMode") .
"</td><td>";
997 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
998 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);
1002 if (isModEnabled(
'project') && is_object(
$object->thirdparty) &&
$object->thirdparty->id > 0) {
1004 $langs->load(
'projects');
1005 print
'<tr><td>' . $langs->trans(
'Project') .
'</td><td>';
1006 $numprojet = $formproject->select_projects(
$object->thirdparty->id, $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 0, 0,
'');
1007 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>';
1012 if (
$object->fk_account > 0) {
1013 print
"<tr><td>" . $langs->trans(
'BankAccount') .
"</td><td>";
1014 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->fk_account,
'none');
1020 $draft->fetch(
GETPOST(
'facid',
'int'));
1023 $extralabels = $extrafields->fetch_name_optionals_label($draft->table_element);
1024 if ($draft->fetch_optionals() > 0) {
1025 $object->array_options = array_merge(
$object->array_options, $draft->array_options);
1028 print
$object->showOptionals($extrafields,
'create', $parameters);
1031 print
"<tr><td>" . $langs->trans(
'Model') .
"</td><td>";
1032 include_once DOL_DOCUMENT_ROOT .
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
1034 print $form->selectarray(
'modelpdf', $list,
$conf->global->INVOICE_SUPPLIER_ADDON_PDF);
1039 print
'<td class="tdtop">';
1040 print $form->textwithpicto($langs->trans(
'NotePublic'), $htmltext, 1,
'help',
'', 0, 2,
'notepublic');
1043 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1044 print $doleditor->Create(1);
1047 if (empty($user->socid)) {
1049 print
'<td class="tdtop">';
1050 print $form->textwithpicto($langs->trans(
'NotePrivate'), $htmltext, 1,
'help',
'', 0, 2,
'noteprivate');
1053 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1054 print $doleditor->Create(1);
1063 $title = $langs->trans(
"Recurrence");
1066 print
'<span class="opacitymedium">'.$langs->trans(
"ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv(
'Module2300Name')).
'</span><br><br>';
1070 print
'<table class="border centpercent">';
1073 print
'<tr><td class="titlefieldcreate">' . $form->textwithpicto($langs->trans(
"Frequency"), $langs->transnoentitiesnoconv(
'toolTipFrequency')) .
"</td><td>";
1074 print
"<input type='text' 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'));
1078 print
"<tr><td>" . $langs->trans(
'NextDateToExecution') .
"</td><td>";
1080 print $form->selectDate($date_next_execution,
'', 1, 1, 0,
"add", 1, 1);
1084 print
"<tr><td>" . $langs->trans(
"MaxPeriodNumber") .
"</td><td>";
1085 print
'<input type="text" name="nb_gen_max" value="' .
GETPOST(
'nb_gen_max') .
'" size="5" />';
1089 print
"<tr><td>" . $langs->trans(
"StatusOfAutoGeneratedInvoices") .
"</td><td>";
1090 $select = array(
'0' => $langs->trans(
'BillStatusDraft'),
'1' => $langs->trans(
'BillStatusValidated'));
1091 print $form->selectarray(
'auto_validate', $select,
GETPOST(
'auto_validate'));
1096 print
"<tr><td>" . $langs->trans(
"StatusOfGeneratedDocuments") .
"</td><td>";
1097 $select = array(
'0' => $langs->trans(
'DoNotGenerateDoc'),
'1' => $langs->trans(
'AutoGenerateDoc'));
1098 print $form->selectarray(
'generate_pdf', $select,
GETPOST(
'generate_pdf'));
1101 print
'<input type="hidden" name="generate_pdf" value="1">';
1108 $title = $langs->trans(
"ProductsAndServices");
1109 if (!isModEnabled(
"service")) {
1110 $title = $langs->trans(
"Products");
1111 } elseif (!isModEnabled(
"product")) {
1112 $title = $langs->trans(
"Services");
1120 print
'<div class="div-table-responsive-no-min">';
1121 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
1127 $object->printObjectLines(
'',
$object->thirdparty, $mysoc, $lineid, 0);
1135 print $form->buttonsSaveCancel(
"Create");
1150 if ($action ==
'ask_deleteline') {
1151 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'',
'no', 1);
1155 if ($action ==
'ask_deleteinvoice') {
1156 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id, $langs->trans(
'DeleteRepeatableInvoice'), $langs->trans(
'ConfirmDeleteRepeatableInvoice'),
'confirm_deleteinvoice',
'',
'no', 1);
1161 $author =
new User($db);
1162 $author->fetch(
$object->user_author);
1166 print
dol_get_fiche_head($head,
'card', $langs->trans(
'RepeatableInvoice'), -1,
'bill');
1170 $linkback =
'<a href="' . DOL_URL_ROOT .
'/fourn/facture/list-rec.php?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
'BackToList') .
'</a>';
1173 if ($action !=
'edittitle') {
1174 $morehtmlref .= $form->editfieldkey(
$object->title,
'title',
$object->title, $object, $usercancreate,
'',
'', 0, 2);
1176 $morehtmlref .= $form->editfieldval(
'',
'title',
$object->title, $object, $usercancreate,
'string');
1178 $morehtmlref .=
'<div class="refidno">';
1180 $morehtmlref .= $form->editfieldkey(
"RefSupplier",
'ref_supplier',
$object->ref_supplier, $object, $usercancreate,
'string',
'', 0, 1);
1181 $morehtmlref .= $form->editfieldval(
"RefSupplier",
'ref_supplier',
$object->ref_supplier, $object, $usercancreate,
'string',
'',
null,
null,
'', 1);
1183 $morehtmlref .=
'<br>' . $langs->trans(
'ThirdParty') .
' : ' .
$object->thirdparty->getNomUrl(1);
1186 if (isModEnabled(
'project')) {
1187 $langs->load(
'projects');
1188 $morehtmlref .=
'<br>' . $langs->trans(
'Project') .
' ';
1189 if ($usercancreate) {
1190 if ($action !=
'classify') {
1191 $morehtmlref .=
'<a class="editfielda" href="' . $_SERVER[
'PHP_SELF'] .
'?action=classify&token=' .
newToken() .
'&id=' .
$object->id .
'">' .
img_edit($langs->transnoentitiesnoconv(
'SetProject')) .
'</a> : ';
1193 if ($action ==
'classify') {
1194 $morehtmlref .=
'<form method="post" action="' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'">';
1195 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
1196 $morehtmlref .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1197 $morehtmlref .= $formproject->select_projects(
$object->socid,
$object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
1198 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
1199 $morehtmlref .=
'</form>';
1201 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->socid,
$object->fk_project,
'none', 0, 0, 0, 1,
'',
'maxwidth300');
1204 if (!empty(
$object->fk_project)) {
1206 $project->fetch(
$object->fk_project);
1207 $morehtmlref .=
' : ' . $project->getNomUrl(1);
1208 if ($project->title) {
1209 $morehtmlref .=
' - ' . $project->title;
1216 $morehtmlref .=
'</div>';
1218 $morehtmlstatus =
'';
1220 dol_banner_tab($object,
'ref', $linkback, 1,
'title',
'none', $morehtmlref,
'', 0,
'', $morehtmlstatus);
1222 print
'<div class="fichecenter">';
1223 print
'<div class="fichehalfleft">';
1224 print
'<div class="underbanner clearboth"></div>';
1226 print
'<table class="border centpercent tableforfield">';
1230 print
"<tr><td>".$langs->trans(
"InvoiceSubtype").
"</td><td>";
1231 print
$object->getSubtypeLabel(
'facture_fourn_rec');
1235 print
'<tr><td class="titlefield">' . $langs->trans(
'Author') .
'</td><td>';
1236 print $author->getNomUrl(-1);
1241 print
'<td>' . $form->editfieldkey(
"Label",
'libelle',
$object->libelle, $object, $usercancreate) .
'</td>';
1242 print
'<td>' . $form->editfieldval(
"Label",
'libelle',
$object->libelle, $object, $usercancreate) .
'</td>';
1245 print
'<tr><td>' . $langs->trans(
'AmountHT') .
'</td>';
1246 print
'<td>' .
price(
$object->total_ht, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
1249 print
'<tr><td>' . $langs->trans(
"AmountVAT") .
'</td><td>' .
price(
$object->total_tva, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
1253 if (($mysoc->localtax1_assuj ==
"1" && $mysoc->useLocalTax(1)) ||
$object->total_localtax1 != 0) {
1254 print
'<tr><td>' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
1255 print
'<td class="nowrap">' .
price(
$object->total_localtax1, 1,
'', 1, -1, -1,
$conf->currency) .
'</td></tr>';
1257 if (($mysoc->localtax2_assuj ==
"1" && $mysoc->useLocalTax(2)) ||
$object->total_localtax2 != 0) {
1258 print
'<tr><td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
1259 print
'<td class=nowrap">' .
price(
$object->total_localtax2, 1,
'', 1, -1, -1,
$conf->currency) .
'</td></tr>';
1262 print
'<tr><td>' . $langs->trans(
"AmountTTC") .
'</td><td colspan="3">' .
price(
$object->total_ttc, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
1267 print
'<table class="nobordernopadding centpercent"><tr><td>';
1268 print $langs->trans(
'PaymentConditionsShort');
1270 if ($action !=
'editconditions' && $usercancreate) {
1271 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>';
1273 print
'</tr></table>';
1275 if ($action ==
'editconditions') {
1276 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?facid=' .
$object->id,
$object->cond_reglement_id,
'cond_reglement_id');
1278 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?facid=' .
$object->id,
$object->cond_reglement_id,
'none');
1285 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1286 print $langs->trans(
'PaymentMode');
1288 if ($action !=
'editmode' && $usercancreate) {
1289 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>';
1291 print
'</tr></table>';
1293 if ($action ==
'editmode') {
1294 $form->form_modes_reglement($_SERVER[
'PHP_SELF'] .
'?facid=' .
$object->id,
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
1296 $form->form_modes_reglement($_SERVER[
'PHP_SELF'] .
'?facid=' .
$object->id,
$object->mode_reglement_id,
'none');
1301 print
'<tr><td class="nowrap">';
1302 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1303 print $langs->trans(
'BankAccount');
1305 if ($action !=
'editbankaccount' && $usercancreate &&
$object->statut == FactureFournisseurRec::STATUS_NOTSUSPENDED) {
1306 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>';
1308 print
'</tr></table>';
1310 if ($action ==
'editbankaccount') {
1311 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->fk_account,
'fk_account', 1);
1313 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id,
$object->fk_account,
'none');
1319 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1322 print
'<tr><td class="nowrap">';
1323 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1324 print $langs->trans(
'Model');
1326 if ($action !=
'editmodelpdf' && $usercancreate &&
$object->statut == FactureFournisseurRec::STATUS_NOTSUSPENDED) {
1327 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>';
1329 print
'</tr></table>';
1331 if ($action ==
'editmodelpdf') {
1332 include_once DOL_DOCUMENT_ROOT .
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
1335 foreach ($models as $k => $model) {
1336 $list[] = str_replace(
':',
'|', $k) .
':' . $model;
1338 $select =
'select;' . implode(
',', $list);
1340 print $form->editfieldval($langs->trans(
'Model'),
'modelpdf',
$object->model_pdf, $object, $usercancreate, $select);
1353 print
'<div class="fichehalfright">';
1354 print
'<div class="underbanner clearboth"></div>';
1359 $title = $langs->trans(
"Recurrence");
1362 print
'<table class="border centpercent tableforfield">';
1364 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
1366 print
'<tr><td colspan="2">' .
img_picto(
'',
'recurring',
'class="pictofixedwidth"') . $title .
'</td></tr>';
1369 print
'<tr><td style="width: 50%">';
1370 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1371 print $langs->trans(
'Frequency');
1373 if ($action !=
'editfrequency' && $usercancreate) {
1374 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>';
1376 print
'</tr></table>';
1378 if ($action ==
'editfrequency') {
1379 print
'<form method="post" action="' . $_SERVER[
"PHP_SELF"] .
'?facid=' .
$object->id .
'">';
1380 print
'<input type="hidden" name="action" value="setfrequency">';
1381 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1382 print
'<table class="nobordernopadding">';
1384 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'));
1386 print
'<td class="left"><input type="submit" class="button button-edit" value="' . $langs->trans(
"Modify") .
'"></td>';
1387 print
'</tr></table></form>';
1390 print $langs->trans(
'FrequencyPer_' .
$object->unit_frequency,
$object->frequency);
1392 print $langs->trans(
"NotARecurringInvoiceTemplate");
1399 if ($action ==
'date_when' ||
$object->frequency > 0) {
1400 print $form->editfieldkey($langs->trans(
"NextDateToExecution"),
'date_when',
$object->date_when, $object, $usercancreate,
'day');
1402 print $langs->trans(
"NextDateToExecution");
1405 if ($action ==
'date_when' ||
$object->frequency > 0) {
1406 print $form->editfieldval($langs->trans(
"NextDateToExecution"),
'date_when',
$object->date_when, $object, $usercancreate,
'day',
$object->date_when,
null,
'',
'', 0,
'strikeIfMaxNbGenReached');
1409 if (!
$object->isMaxNbGenReached()) {
1414 print
img_info($langs->trans(
"MaxNumberOfGenerationReached"));
1421 if ($action ==
'nb_gen_max' ||
$object->frequency > 0) {
1422 print $form->editfieldkey($langs->trans(
"MaxPeriodNumber"),
'nb_gen_max',
$object->nb_gen_max, $object, $usercancreate);
1424 print $langs->trans(
"MaxPeriodNumber");
1427 if ($action ==
'nb_gen_max' ||
$object->frequency > 0) {
1428 print $form->editfieldval($langs->trans(
"MaxPeriodNumber"),
'nb_gen_max',
$object->nb_gen_max ?
$object->nb_gen_max :
'',
$object, $usercancreate);
1437 if ($action ==
'auto_validate' ||
$object->frequency > 0) {
1438 print $form->editfieldkey($langs->trans(
"StatusOfAutoGeneratedInvoices"),
'auto_validate',
$object->auto_validate, $object, $usercancreate);
1440 print $langs->trans(
"StatusOfAutoGeneratedInvoices");
1443 $select =
'select;0:' . $langs->trans(
'BillStatusDraft') .
',1:' . $langs->trans(
'BillStatusValidated');
1444 if ($action ==
'auto_validate' ||
$object->frequency > 0) {
1445 print $form->editfieldval($langs->trans(
"StatusOfAutoGeneratedInvoices"),
'auto_validate',
$object->auto_validate, $object, $usercancreate, $select);
1452 if ($action ==
'generate_pdf' ||
$object->frequency > 0) {
1453 print $form->editfieldkey($langs->trans(
"StatusOfGeneratedDocuments"),
'generate_pdf',
$object->generate_pdf, $object, $usercancreate);
1455 print $langs->trans(
"StatusOfGeneratedDocuments");
1459 $select =
'select;0:' . $langs->trans(
'DoNotGenerateDoc') .
',1:' . $langs->trans(
'AutogenerateDoc');
1460 if ($action ==
'generate_pdf' ||
$object->frequency > 0) {
1461 print $form->editfieldval($langs->trans(
"StatusOfGeneratedDocuments"),
'generate_pdf',
$object->generate_pdf, $object, $usercancreate, $select);
1466 print
'<input type="hidden" name="generate_pdf" value="1">';
1475 if (empty(
$conf->cron->enabled)) {
1476 print
info_admin($langs->trans(
"EnableAndSetupModuleCron", $langs->transnoentitiesnoconv(
"Module2300Name")));
1479 print
'<div class="underbanner clearboth"></div>';
1480 print
'<table class="border centpercent tableforfield">';
1483 print
'<tr><td style="width: 50%">' . $langs->trans(
"NbOfGenerationDone") .
'</td>';
1491 print $langs->trans(
"DateLastGeneration");
1505 print
'<div class="clearboth"></div><br>';
1508 print
' <form name="addproduct" id="addproduct" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id . (($action !=
'editline') ?
'#add' :
'#line_' .
GETPOSTINT(
'lineid')) .
'" method="POST">
1509 <input type="hidden" name="token" value="' .
newToken() .
'">
1510 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline') .
'">
1511 <input type="hidden" name="mode" value="">
1512 <input type="hidden" name="id" value="' .
$object->id .
'">
1515 if (!empty(
$conf->use_javascript_ajax) &&
$object->statut == 0) {
1516 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
1519 print
'<div class="div-table-responsive-no-min">';
1520 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
1524 $canchangeproduct = 1;
1526 foreach (
$object->lines as $line) {
1527 $line->ref = $line->label;
1528 $line->product_label = $line->label;
1529 $line->subprice = $line->pu_ht;
1532 global $canchangeproduct;
1533 $canchangeproduct = 0;
1536 $object->printObjectLines($action,
$object->thirdparty, $mysoc, $lineid, 0);
1541 if (
$object->statut == $object::STATUS_DRAFT && $usercancreate && $action !=
'valid' && $action !=
'editline') {
1542 if ($action !=
'editline') {
1545 $parameters = array();
1546 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
1550 if (empty($reshook)) {
1551 global $senderissupplier;
1553 $senderissupplier = 2;
1568 print
'<div class="tabsAction">';
1570 if (empty(
$object->suspended)) {
1571 if ($usercancreate) {
1573 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' .
dol_escape_htmltag($langs->trans(
"MaxGenerationReached")) .
'">' . $langs->trans(
"CreateBill") .
'</a></div>';
1575 if (empty(
$object->frequency) ||
$object->date_when <= $nowlasthour) {
1576 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>';
1578 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' .
dol_escape_htmltag($langs->trans(
"DateIsNotEnough")) .
'">' . $langs->trans(
"CreateBill") .
'</a></div>';
1582 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">' . $langs->trans(
"CreateBill") .
'</a></div>';
1586 if ($usercancreate) {
1587 if (empty(
$object->suspended)) {
1588 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>';
1590 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>';
1595 print
dolGetButtonAction($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")));
1599 print
'<div class="fichecenter"><div class="fichehalfleft">';
1600 print
'<a name="builddoc"></a>';
1603 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'invoice'), 1);
1604 $linktoelem = $tmparray[
'linktoelem'];
1605 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
1606 print $htmltoenteralink;
1608 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
1610 print
'</div></div>';
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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
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)
Add a delay to a date.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_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'.
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.
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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
get_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, 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...
supplier_invoice_rec_prepare_head($object)
Return array head with list of tabs to view object information.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.