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';
68$backtopage =
GETPOST(
'backtopage',
'alpha');
69$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
74$ref =
GETPOST(
'title',
'alphanohtml') ?
GETPOST(
'title',
'alphanohtml') :
GETPOST(
'ref',
'alphanohtml');
75$label =
GETPOST(
'label',
'alphanohtml');
76$ref_supplier =
GETPOST(
'ref_supplier',
'alphanohtml');
78$year_date_when =
GETPOST(
'year_date_when');
79$month_date_when =
GETPOST(
'month_date_when');
83 $socid = $user->socid;
85$objecttype =
'facture_fourn_rec';
86if ($action ==
"create" || $action ==
"add") {
91$sortfield =
GETPOST(
"sortfield",
'aZ09comma');
92$sortorder =
GETPOST(
"sortorder",
'aZ09comma');
94if (empty($page) || $page == -1) {
97$offset = $limit * $page;
102 $sortfield =
'f.titre';
104$pageprev = $page - 1;
105$pagenext = $page + 1;
108if (($id > 0 || $ref) && $action !=
'create' && $action !=
'add') {
109 $ret =
$object->fetch($id, $ref);
116$hookmanager->initHooks(array(
'supplierinvoicereccard',
'globalcard'));
120$extrafields->fetch_name_optionals_label(
$object->table_element);
122$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
124$permissionnote = $user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer");
125$permissiondellink = $user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer");
126$permissiontoedit = $user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer");
127$permissiontoadd = $user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer");
128$permissiontodelete = ($user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"supprimer"));
129$permissiontoeditextra = $permissiontoadd;
130if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
132 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
135$usercanread = $user->hasRight(
"fournisseur",
"facture",
"lire") || $user->hasRight(
"supplier_invoice",
"lire");
136$usercancreate = $user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer");
137$usercandelete = $user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"supprimer");
138$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"validate")));
139$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"send"));
141$usercanproductignorepricemin = ((
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
"produit",
"ignore_price_min_advance")) || !
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS'));
142$usercancreatemargin = $user->hasRight(
"margins",
"creer");
143$usercanreadallmargin = $user->hasRight(
"margins",
"liretous");
144$usercancreatewithdrarequest = $user->hasRight(
"prelevement",
"bons",
"creer");
159if (
GETPOST(
'cancel',
'alpha')) {
160 if ($action !=
'updateline') {
168if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
172$parameters = array(
'socid' => $socid);
173$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
178if (empty($reshook)) {
179 if (
GETPOST(
'cancel',
'alpha')) {
184 include DOL_DOCUMENT_ROOT .
'/core/actions_changeselectedfields.inc.php';
187 include DOL_DOCUMENT_ROOT .
'/core/actions_setnotes.inc.php';
189 include DOL_DOCUMENT_ROOT .
'/core/actions_dellink.inc.php';
191 include DOL_DOCUMENT_ROOT .
'/core/actions_lineupdown.inc.php';
194 if ($action ==
'add' && $permissiontoadd) {
195 if (!
GETPOST(
'title',
'alphanohtml')) {
196 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Title")),
null,
'errors');
211 if (empty($reyear) || empty($remonth) || empty($reday)) {
212 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Date")),
null,
'errors');
230 $object->frequency = $frequency;
232 $object->nb_gen_max = $nb_gen_max;
237 $date_next_execution =
dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
238 $object->date_when = $date_next_execution;
240 $ret = $extrafields->setOptionalsFromPost(
null, $object);
252 $onlylines =
GETPOST(
'toselect',
'array');
254 $result =
$object->create($user, $oldinvoice->id, 0, $onlylines);
257 $result = $oldinvoice->delete($user, 1);
272 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
'?facid=' .
$object->id);
283 if ($action ==
'confirm_deleteinvoice' && $confirm ==
'yes' && $permissiontodelete) {
286 header(
'Location: ' . DOL_URL_ROOT .
'/fourn/facture/list-rec.php');
292 if ($action ==
'setconditions' && $usercancreate) {
294 } elseif ($action ==
'setmode' && $usercancreate) {
297 } elseif ($action ==
'classin' && $usercancreate) {
300 } elseif ($action ==
'setref_supplier' && $usercancreate) {
301 $result =
$object->setValueFrom(
'ref_supplier', $ref_supplier,
'',
null,
'text',
'', $user);
305 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
306 $langs->load(
"errors");
307 setEventMessages($langs->trans(
'ErrorRefAlreadyExists', $ref_supplier),
null,
'errors');
312 } elseif ($action ==
'settitle' && $permissiontoadd) {
313 $result =
$object->setValueFrom(
'titre', $ref,
'',
null,
'text',
'', $user);
320 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
321 $langs->load(
"errors");
322 setEventMessages($langs->trans(
'ErrorTitreAlreadyExists', $ref),
null,
'errors');
327 } elseif ($action ==
'setbankaccount' && $permissiontoadd) {
330 } elseif ($action ==
'setfrequency' && $permissiontoadd) {
333 } elseif ($action ==
'setdate_when' && $permissiontoadd) {
339 } elseif ($action ==
'setnb_gen_max' && $permissiontoadd) {
342 } elseif ($action ==
'setauto_validate' && $permissiontoadd) {
345 } elseif ($action ==
'setgenerate_pdf' && $permissiontoadd) {
348 } elseif ($action ==
'setmodelpdf' && $permissiontoadd) {
351 } elseif ($action ==
'disable' && $permissiontoadd) {
357 $res =
$object->setValueFrom(
'suspended', 1);
368 } elseif ($action ==
'enable' && $permissiontoadd) {
372 $object->context[
'actionmsg'] = $langs->trans(
"RecordEnabled");
376 $res =
$object->setValueFrom(
'suspended', 0);
387 } elseif ($action ==
'setmulticurrencycode' && $permissiontoadd) {
389 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
390 } elseif ($action ==
'setmulticurrencyrate' && $permissiontoadd) {
393 } elseif ($action ==
'setlabel' && $permissiontoadd) {
395 $result =
$object->setValueFrom(
'libelle', $label,
'',
null,
'text',
'', $user);
399 if ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $permissiontoadd) {
410 if ($line->delete($user) > 0) {
411 $result =
$object->update_price(1);
424 } elseif ($action ==
'update_extras' && $permissiontoeditextra) {
427 $attribute_name =
GETPOST(
'attribute',
'aZ09');
430 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
436 $result =
$object->updateExtraField($attribute_name,
'BILLREC_MODIFY');
444 $action =
'edit_extras';
449 if ($action ==
'addline' && $permissiontoadd) {
450 $langs->load(
'errors');
455 $product_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
458 $prod_entry_mode =
GETPOST(
'prod_entry_mode',
'alpha');
459 if ($prod_entry_mode ==
'free') {
461 $tva_tx = (
GETPOST(
'tva_tx',
'alpha') ? (string)
GETPOST(
'tva_tx',
'alpha') : 0);
462 $ref_fournisseur = (GETPOSTISSET(
'fourn_ref') ?
GETPOST(
'fourn_ref',
'restricthtml') :
'');
468 $qty =
GETPOST(
'qty' . $predef,
'alpha');
469 $qty = ($qty ===
'') ?
'' : (float)
price2num(
GETPOST(
'qty' . $predef,
'alpha'),
'MS', 2);
473 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
474 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
476 if (is_array($extralabelsline)) {
478 foreach ($extralabelsline as $key => $value) {
479 unset($_POST[
"options_" . $key . $predef]);
483 if ((empty($idprod) || $idprod < 0) && ($price_ht < 0) && ((
float) $qty < 0)) {
484 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPriceHT'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
487 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) &&
GETPOST(
'type') < 0) {
488 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
491 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && (! ($price_ht >= 0) || $price_ht ==
'')) {
492 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")),
null,
'errors');
496 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
499 if ($prod_entry_mode ==
'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
500 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
504 $langs->load(
"errors");
505 setEventMessages($langs->trans(
'ErrorQtyForSupplierInvoiceCantBeNegative'),
null,
'errors');
509 $ref_fournisseur =
null;
510 if ($prod_entry_mode !=
'free' && empty($error)) {
514 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
518 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
519 $idprod = (int) $reg[1];
520 $res = $productsupplier->fetch($idprod);
523 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
525 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
526 if ($productsupplier->fourn_socid != $socid) {
527 $productsupplier->ref_supplier =
'';
530 $fksoctosearch =
$object->thirdparty->id;
531 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
533 } elseif (
GETPOSTINT(
'idprodfournprice') > 0) {
535 $idprod = $productsupplier->get_buyprice(
GETPOSTINT(
'idprodfournprice'), $qtytosearch);
536 $res = $productsupplier->fetch($idprod);
537 $ref_fournisseur = $productsupplier->ref_supplier;
541 if (! $error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) {
547 $ret =
$object->fetch_thirdparty();
552 $price_base_type = (
GETPOST(
'price_base_type',
'alpha') ?
GETPOST(
'price_base_type',
'alpha') :
'HT');
564 if (!empty($idprod) && $idprod > 0) {
566 $prod->fetch($idprod);
568 $label = ((
GETPOST(
'product_label') &&
GETPOST(
'product_label') != $prod->label) ?
GETPOST(
'product_label') :
'');
573 if (empty($tva_tx)) {
580 $datapriceofproduct = $prod->getSellPrice(
$object->thirdparty, $mysoc, $pqp);
582 $pu_ht = $datapriceofproduct[
'pu_ht'];
583 $pu_ttc = $datapriceofproduct[
'pu_ttc'];
584 $price_min = $datapriceofproduct[
'price_min'];
585 $price_base_type = empty($datapriceofproduct[
'price_base_type']) ?
'HT' : $datapriceofproduct[
'price_base_type'];
586 $tva_tx = $datapriceofproduct[
'tva_tx'];
587 $tva_npr = $datapriceofproduct[
'tva_npr'];
589 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string) $tva_tx));
590 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', (
string) $prod->tva_tx));
593 if (!empty($price_ht)) {
595 $pu_ttc =
price2num((
float) $pu_ht * (1 + ((
float) $tmpvat / 100)),
'MU');
596 } elseif ($tmpvat != $tmpprodvat) {
599 if ($price_base_type !=
'HT') {
600 $pu_ht =
price2num($pu_ttc / (1 + ((
float) $tmpvat / 100)),
'MU');
602 $pu_ttc =
price2num($pu_ht * (1 + ((
float) $tmpvat / 100)),
'MU');
606 $outputlangs = $langs;
612 if (
GETPOST(
'lang_id',
'aZ09')) {
613 $newlang =
GETPOST(
'lang_id',
'aZ09');
615 if (empty($newlang)) {
616 $newlang =
$object->thirdparty->default_lang;
618 if (!empty($newlang)) {
620 $outputlangs->setDefaultLang($newlang);
621 $outputlangs->load(
'products');
624 $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] [
"description"])) ? $prod->multilangs [$outputlangs->defaultlang] [
"description"] : $prod->
description;
626 $desc = $prod->description;
632 if (!
getDolGlobalString(
'MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE') && (!empty($prod->customcode) || !empty($prod->country_code))) {
636 if (!empty($prod->customcode)) {
637 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CustomsCode") .
': ' . $prod->customcode;
639 if (!empty($prod->customcode) && !empty($prod->country_code)) {
642 if (!empty($prod->country_code)) {
643 $tmptxt .= $outputlangs->transnoentitiesnoconv(
"CountryOrigin") .
': ' .
getCountry($prod->country_code,
'', $db, $outputlangs, 0);
646 if (!empty($prod->customcode)) {
647 $tmptxt .= $langs->transnoentitiesnoconv(
"CustomsCode") .
': ' . $prod->customcode;
649 if (!empty($prod->customcode) && !empty($prod->country_code)) {
652 if (!empty($prod->country_code)) {
653 $tmptxt .= $langs->transnoentitiesnoconv(
"CountryOrigin") .
': ' .
getCountry($prod->country_code,
'', $db, $langs, 0);
661 $fk_unit = $prod->fk_unit;
665 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
666 $tva_tx = str_replace(
'*',
'', $tva_tx);
667 if (empty($tva_tx)) {
670 $desc = $product_desc;
675 $date_start_fill =
GETPOSTINT(
'date_start_fill');
679 $fournprice = (int) (
GETPOST(
'fournprice' . $predef) ?
GETPOST(
'fournprice' . $predef) :
'');
692 $remise_percent = (float)
price2num($remise_percent);
694 $price_min = (float)
price2num((
float) $price_min);
695 if ($usercanproductignorepricemin && (!empty($price_min) && ($pu_ht * (1 - $remise_percent / 100) < $price_min))) {
696 $mesg = $langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency));
700 $result =
$object->addline($idprod, (
string) $ref_fournisseur, $label, $desc, $pu_ht, $pu_ttc, (
float) $qty, $remise_percent, (
float) $tva_tx, $localtax1_tx, $localtax2_tx, $price_base_type, $type, $date_start_fill, $date_end_fill, $info_bits, $special_code, -1, $fk_unit);
705 unset($_POST[
'prod_entry_mode']);
706 unset($_POST[
'qty']);
707 unset($_POST[
'type']);
708 unset($_POST[
'remise_percent']);
709 unset($_POST[
'price_ht']);
710 unset($_POST[
'multicurrency_price_ht']);
711 unset($_POST[
'price_ttc']);
712 unset($_POST[
'tva_tx']);
713 unset($_POST[
'product_ref']);
714 unset($_POST[
'product_label']);
715 unset($_POST[
'product_desc']);
716 unset($_POST[
'fournprice']);
717 unset($_POST[
'buying_price']);
718 unset($_POST[
'np_marginRate']);
719 unset($_POST[
'np_markRate']);
720 unset($_POST[
'dp_desc']);
721 unset($_POST[
'idprod']);
722 unset($_POST[
'units']);
723 unset($_POST[
'date_starthour']);
724 unset($_POST[
'date_startmin']);
725 unset($_POST[
'date_startsec']);
726 unset($_POST[
'date_startday']);
727 unset($_POST[
'date_startmonth']);
728 unset($_POST[
'date_startyear']);
729 unset($_POST[
'date_endhour']);
730 unset($_POST[
'date_endmin']);
731 unset($_POST[
'date_endsec']);
732 unset($_POST[
'date_endday']);
733 unset($_POST[
'date_endmonth']);
734 unset($_POST[
'date_endyear']);
735 unset($_POST[
'date_start_fill']);
736 unset($_POST[
'date_end_fill']);
737 unset($_POST[
'situations']);
738 unset($_POST[
'progress']);
739 unset($_POST[
'fourn_ref']);
747 } elseif ($action ==
'updateline' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
748 if (!
$object->fetch($id) > 0) {
757 $ref_fourn =
GETPOST(
'fourn_ref',
'alpha');
766 if (preg_match(
'/\*/', $vat_rate)) {
771 $vat_rate = str_replace(
'*',
'', $vat_rate);
776 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
777 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
780 if ($objectline->fetch(
GETPOSTINT(
'lineid'))) {
781 $objectline->array_options = $array_options;
782 $result = $objectline->insertExtraFields();
788 $position = ($objectline->rang >= 0 ? $objectline->rang : 0);
791 if (is_array($extralabelsline)) {
793 foreach ($extralabelsline as $key => $value) {
794 unset($_POST[
"options_" . $key]);
800 if (!
GETPOST(
'qty',
'alpha')) {
808 if (!empty($productid)) {
810 $product->fetch($productid);
812 $type = $product->type;
814 $price_min = $product->price_min;
816 $price_min = $product->multiprices_min[
$object->thirdparty->price_level];
819 $label = $product->label;
822 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))) {
823 setEventMessages($langs->trans(
"CantBeLessThanMinPrice",
price(
price2num($price_min,
'MU'), 0, $langs, 0, 0, -1,
$conf->currency)),
null,
'errors');
828 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
832 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
837 $langs->load(
"errors");
838 setEventMessages($langs->trans(
'ErrorQtyForSupplierInvoiceCantBeNegative'),
null,
'errors');
842 $date_start_fill =
GETPOSTINT(
'date_start_fill');
847 $result =
$object->updateline(
GETPOSTINT(
'lineid'),
GETPOSTINT(
'productid'), $ref_fourn, $label, $description, (
float) $pu_ht, (
float) $qty, $remise_percent, (
float) $vat_rate, $localtax1_rate, $localtax1_rate,
'HT', $type, $date_start_fill, $date_end_fill, $info_bits, $special_code, -1);
851 unset($_POST[
'qty']);
852 unset($_POST[
'type']);
853 unset($_POST[
'productid']);
854 unset($_POST[
'remise_percent']);
855 unset($_POST[
'price_ht']);
856 unset($_POST[
'multicurrency_price_ht']);
857 unset($_POST[
'price_ttc']);
858 unset($_POST[
'tva_tx']);
859 unset($_POST[
'product_ref']);
860 unset($_POST[
'product_label']);
861 unset($_POST[
'product_desc']);
862 unset($_POST[
'fournprice']);
863 unset($_POST[
'buying_price']);
864 unset($_POST[
'np_marginRate']);
865 unset($_POST[
'np_markRate']);
866 unset($_POST[
'dp_desc']);
867 unset($_POST[
'idprod']);
868 unset($_POST[
'units']);
869 unset($_POST[
'date_starthour']);
870 unset($_POST[
'date_startmin']);
871 unset($_POST[
'date_startsec']);
872 unset($_POST[
'date_startday']);
873 unset($_POST[
'date_startmonth']);
874 unset($_POST[
'date_startyear']);
875 unset($_POST[
'date_endhour']);
876 unset($_POST[
'date_endmin']);
877 unset($_POST[
'date_endsec']);
878 unset($_POST[
'date_endday']);
879 unset($_POST[
'date_endmonth']);
880 unset($_POST[
'date_endyear']);
881 unset($_POST[
'situations']);
882 unset($_POST[
'progress']);
883 unset($_POST[
'fourn_ref']);
896$title = $langs->trans(
"RepeatableSupplierInvoice");
898llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-fourn-facture page-card-rec');
900$form =
new Form($db);
902if (isModEnabled(
'project')) {
907$companystatic =
new Societe($db);
914if ($action ==
'create') {
915 print
load_fiche_titre($langs->trans(
"CreateRepeatableInvoice"),
'',
'bill');
918 $product_static =
new Product($db);
920 if (
$object->fetch($id, $ref) > 0) {
921 $result =
$object->fetch_lines();
923 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST">';
924 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
925 print
'<input type="hidden" name="action" value="add">';
926 print
'<input type="hidden" name="facid" value="' .
$object->id .
'">';
931 if (isModEnabled(
'project')) {
938 print
'<table class="border centpercent">';
943 print
'<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans(
"Title") .
'</td><td>';
944 print
'<input class="flat quatrevingtpercent" type="text" name="title" value="' .
dol_escape_htmltag(
GETPOST(
"title",
'alphanohtml')) .
'" autofocus>';
948 print
'<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans(
"RefSupplier") .
'</td><td>';
949 print
'<input class="flat maxwidth500" type="text" name="ref_supplier" value="' .
$object->ref_supplier .
'">';
953 print
'<tr><td class="titlefieldcreate">' . $langs->trans(
"Supplier") .
'</td><td>' .
$object->thirdparty->getNomUrl(1,
'supplier') .
'</td>';
958 print
"<tr><td>".$langs->trans(
"InvoiceSubtype").
"</td><td>";
959 print $form->getSelectInvoiceSubtype(GETPOSTISSET(
'subtype') ?
GETPOST(
'subtype') :
$object->subtype,
'subtype', 0, 0,
'');
963 $note_public = GETPOSTISSET(
'note_public') ?
GETPOST(
'note_public',
'restricthtml') :
$object->note_public;
964 $note_private = GETPOSTISSET(
'note_private') ?
GETPOST(
'note_private',
'restricthtml') :
$object->note_private;
967 $substitutionarray = getCommonSubstitutionArray($langs, 2,
null, $object);
969 $substitutionarray[
'__INVOICE_PREVIOUS_MONTH__'] = $langs->trans(
"PreviousMonthOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
dol_time_plus_duree(
$object->date, -1,
'm'),
'%m') .
')';
970 $substitutionarray[
'__INVOICE_MONTH__'] = $langs->trans(
"MonthOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
$object->date,
'%m') .
')';
971 $substitutionarray[
'__INVOICE_NEXT_MONTH__'] = $langs->trans(
"NextMonthOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
dol_time_plus_duree(
$object->date, 1,
'm'),
'%m') .
')';
972 $substitutionarray[
'__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans(
"TextPreviousMonthOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
dol_time_plus_duree(
$object->date, -1,
'm'),
'%B') .
')';
973 $substitutionarray[
'__INVOICE_MONTH_TEXT__'] = $langs->trans(
"TextMonthOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
$object->date,
'%B') .
')';
974 $substitutionarray[
'__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans(
"TextNextMonthOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
dol_time_plus_duree(
$object->date, 1,
'm'),
'%B') .
')';
975 $substitutionarray[
'__INVOICE_PREVIOUS_YEAR__'] = $langs->trans(
"PreviousYearOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
dol_time_plus_duree(
$object->date, -1,
'y'),
'%Y') .
')';
976 $substitutionarray[
'__INVOICE_YEAR__'] = $langs->trans(
"YearOfInvoice") .
' (' . $langs->trans(
"Example") .
': ' .
dol_print_date(
$object->date,
'%Y') .
')';
979 $substitutionarray[
'__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans(
"DateNextInvoiceBeforeGen") . (isset(
$object->date_when) ?
' (' . $langs->trans(
"Example") .
': ' .dol_print_date(
$object->date_when,
'dayhour') .
')' :
'');
980 $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') .
')' :
'');
981 $substitutionarray[
'__INVOICE_COUNTER_CURRENT__'] = $langs->trans(
"Count");
982 $substitutionarray[
'__INVOICE_COUNTER_MAX__'] = $langs->trans(
"MaxPeriodNumber");
984 $htmltext =
'<i>' . $langs->trans(
"FollowingConstantsWillBeSubstituted") .
':<br>';
985 foreach ($substitutionarray as $key => $val) {
986 $htmltext .= $key .
' = ' . $langs->trans($val) .
'<br>';
991 print
'<tr><td class="titlefieldcreate">' . $langs->trans(
"Label") .
'</td><td>';
992 print
'<input class="flat quatrevingtpercent" type="text" name="label" value="' .
$object->label .
'">';
996 print
"<tr><td>" . $langs->trans(
"Author") .
"</td><td>" . $user->getFullName($langs) .
"</td></tr>";
999 print
"<tr><td>" . $langs->trans(
"PaymentConditions") .
"</td><td>";
1000 print $form->getSelectConditionsPaiements(GETPOSTISSET(
'cond_reglement_id') ?
GETPOST(
'cond_reglement_id',
'int') :
$object->cond_reglement_id,
'cond_reglement_id', -1, 0, 0,
'');
1004 print
"<tr><td>" . $langs->trans(
"PaymentMode") .
"</td><td>";
1005 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
1006 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);
1010 if (isModEnabled(
'project') && $formproject !==
null && is_object(
$object->thirdparty) &&
$object->thirdparty->id > 0) {
1012 $langs->load(
'projects');
1013 print
'<tr><td>' . $langs->trans(
'Project') .
'</td><td>';
1014 $numprojet = $formproject->select_projects(
$object->thirdparty->id, $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 0, 0,
'');
1015 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>';
1020 if (
$object->fk_account > 0) {
1021 print
"<tr><td>" . $langs->trans(
'BankAccount') .
"</td><td>";
1022 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_account,
'none');
1031 $extralabels = $extrafields->fetch_name_optionals_label($draft->table_element);
1032 if ($draft->fetch_optionals() > 0) {
1033 $object->array_options = array_merge(
$object->array_options, $draft->array_options);
1036 print
$object->showOptionals($extrafields,
'create', $parameters);
1039 print
"<tr><td>" . $langs->trans(
'Model') .
"</td><td>";
1040 include_once DOL_DOCUMENT_ROOT .
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
1042 print $form->selectarray(
'modelpdf', $list,
$conf->global->INVOICE_SUPPLIER_ADDON_PDF);
1047 print
'<td class="tdtop">';
1048 print $form->textwithpicto($langs->trans(
'NotePublic'), $htmltext, 1,
'help',
'', 0, 2,
'notepublic');
1051 $doleditor =
new DolEditor(
'note_public', $note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1052 print $doleditor->Create(1);
1055 if (empty($user->socid)) {
1057 print
'<td class="tdtop">';
1058 print $form->textwithpicto($langs->trans(
'NotePrivate'), $htmltext, 1,
'help',
'', 0, 2,
'noteprivate');
1061 $doleditor =
new DolEditor(
'note_private', $note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1062 print $doleditor->Create(1);
1071 $title = $langs->trans(
"Recurrence");
1074 print
'<span class="opacitymedium">'.$langs->trans(
"ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv(
'Module2300Name')).
'</span><br><br>';
1078 print
'<table class="border centpercent">';
1081 print
'<tr><td class="titlefieldcreate">' . $form->textwithpicto($langs->trans(
"Frequency"), $langs->transnoentitiesnoconv(
'toolTipFrequency')) .
"</td><td>";
1082 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'));
1086 print
"<tr><td>" . $langs->trans(
'NextDateToExecution') .
"</td><td>";
1088 print $form->selectDate($date_next_execution,
'', 1, 1, 0,
"add", 1, 1);
1092 print
"<tr><td>" . $langs->trans(
"MaxPeriodNumber") .
"</td><td>";
1093 print
'<input type="text" class="width50" name="nb_gen_max" value="' .
GETPOSTINT(
'nb_gen_max') .
'">';
1097 print
"<tr><td>" . $langs->trans(
"StatusOfAutoGeneratedInvoices") .
"</td><td>";
1098 $select = array(
'0' => $langs->trans(
'BillStatusDraft'),
'1' => $langs->trans(
'BillStatusValidated'));
1099 print $form->selectarray(
'auto_validate', $select,
GETPOSTINT(
'auto_validate'));
1104 print
"<tr><td>" . $langs->trans(
"StatusOfGeneratedDocuments") .
"</td><td>";
1105 $select = array(
'0' => $langs->trans(
'DoNotGenerateDoc'),
'1' => $langs->trans(
'AutoGenerateDoc'));
1106 print $form->selectarray(
'generate_pdf', $select,
GETPOSTINT(
'generate_pdf'));
1109 print
'<input type="hidden" name="generate_pdf" value="1">';
1116 $title = $langs->trans(
"ProductsAndServices");
1117 if (!isModEnabled(
"service")) {
1118 $title = $langs->trans(
"Products");
1119 } elseif (!isModEnabled(
"product")) {
1120 $title = $langs->trans(
"Services");
1128 print
'<div class="div-table-responsive-no-min">';
1129 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
1135 $object->printObjectLines(
'',
$object->thirdparty, $mysoc, $lineid, 0);
1143 print $form->buttonsSaveCancel(
"Create");
1158 if ($action ==
'ask_deleteline') {
1159 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&lineid=' . $lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'',
'no', 1);
1163 if ($action ==
'ask_deleteinvoice') {
1164 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id, $langs->trans(
'DeleteRepeatableInvoice'), $langs->trans(
'ConfirmDeleteRepeatableInvoice'),
'confirm_deleteinvoice',
'',
'no', 1);
1169 $author =
new User($db);
1170 $author->fetch(
$object->user_author);
1174 print
dol_get_fiche_head($head,
'card', $langs->trans(
'RepeatableInvoice'), -1,
'bill');
1178 $linkback =
'<a href="' . DOL_URL_ROOT .
'/fourn/facture/list-rec.php?restore_lastsearch_values=1' . (!empty($socid) ?
'&socid=' . $socid :
'') .
'">' . $langs->trans(
'BackToList') .
'</a>';
1181 if ($action !=
'edittitle') {
1182 $morehtmlref .= $form->editfieldkey(
$object->title,
'title',
$object->title, $object, (
int) $usercancreate,
'',
'', 0, 2);
1184 $morehtmlref .= $form->editfieldval(
'',
'title',
$object->title, $object, $usercancreate,
'string');
1186 $morehtmlref .=
'<div class="refidno">';
1188 $morehtmlref .= $form->editfieldkey(
"RefSupplier",
'ref_supplier',
$object->ref_supplier, $object, (
int) $usercancreate,
'string',
'', 0, 1);
1189 $morehtmlref .= $form->editfieldval(
"RefSupplier",
'ref_supplier',
$object->ref_supplier, $object, $usercancreate,
'string',
'',
null,
null,
'', 1);
1191 $morehtmlref .=
'<br>' . $langs->trans(
'ThirdParty') .
' : ' .
$object->thirdparty->getNomUrl(1);
1194 if (isModEnabled(
'project') && $formproject !==
null) {
1195 $langs->load(
'projects');
1196 $morehtmlref .=
'<br>' . $langs->trans(
'Project') .
' ';
1197 if ($usercancreate) {
1198 if ($action !=
'classify') {
1199 $morehtmlref .=
'<a class="editfielda" href="' . $_SERVER[
'PHP_SELF'] .
'?action=classify&token=' .
newToken() .
'&id=' .
$object->id .
'">' .
img_edit($langs->transnoentitiesnoconv(
'SetProject')) .
'</a> : ';
1201 if ($action ==
'classify') {
1202 $morehtmlref .=
'<form method="post" action="' . $_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id .
'">';
1203 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
1204 $morehtmlref .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1205 $morehtmlref .= $formproject->select_projects(
$object->socid, (
string)
$object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
1206 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
1207 $morehtmlref .=
'</form>';
1209 $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');
1212 if (!empty(
$object->fk_project)) {
1214 $project->fetch(
$object->fk_project);
1215 $morehtmlref .=
' : ' . $project->getNomUrl(1);
1216 if ($project->title) {
1217 $morehtmlref .=
' - ' . $project->title;
1224 $morehtmlref .=
'</div>';
1226 $morehtmlstatus =
'';
1228 dol_banner_tab($object,
'ref', $linkback, 1,
'title',
'none', $morehtmlref,
'', 0,
'', $morehtmlstatus);
1230 print
'<div class="fichecenter">';
1231 print
'<div class="fichehalfleft">';
1232 print
'<div class="underbanner clearboth"></div>';
1234 print
'<table class="border centpercent tableforfield">';
1238 print
"<tr><td>".$langs->trans(
"InvoiceSubtype").
"</td><td>";
1239 print
$object->getSubtypeLabel(
'facture_fourn_rec');
1244 print
'<tr><td class="titlefield">' . $langs->trans(
'Author') .
'</td><td>';
1245 print $author->getNomUrl(-1);
1250 print
'<td>' . $form->editfieldkey(
"Label",
'label',
$object->label, $object, (
int) $usercancreate) .
'</td>';
1251 print
'<td>' . $form->editfieldval(
"Label",
'label',
$object->label, $object, $usercancreate) .
'</td>';
1256 print
'<table class="nobordernopadding centpercent"><tr><td>';
1257 print $langs->trans(
'PaymentConditionsShort');
1259 if ($action !=
'editconditions' && $usercancreate) {
1260 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>';
1262 print
'</tr></table>';
1264 if ($action ==
'editconditions') {
1265 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?facid=' .
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id');
1267 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'] .
'?facid=' .
$object->id, (
string)
$object->cond_reglement_id,
'none');
1274 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1275 print $langs->trans(
'PaymentMode');
1277 if ($action !=
'editmode' && $usercancreate) {
1278 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>';
1280 print
'</tr></table>';
1282 if ($action ==
'editmode') {
1283 $form->form_modes_reglement($_SERVER[
'PHP_SELF'] .
'?facid=' .
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'CRDT', 1, 1);
1285 $form->form_modes_reglement($_SERVER[
'PHP_SELF'] .
'?facid=' .
$object->id, (
string)
$object->mode_reglement_id,
'none');
1290 print
'<tr><td class="nowrap">';
1291 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1292 print $langs->trans(
'BankAccount');
1294 if ($action !=
'editbankaccount' && $usercancreate &&
$object->statut == FactureFournisseurRec::STATUS_NOTSUSPENDED) {
1295 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>';
1297 print
'</tr></table>';
1299 if ($action ==
'editbankaccount') {
1300 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
1302 $form->formSelectAccount($_SERVER[
'PHP_SELF'] .
'?id=' .
$object->id, (
string)
$object->fk_account,
'none');
1308 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1311 print
'<tr><td class="nowrap">';
1312 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
1313 print $langs->trans(
'Model');
1315 if ($action !=
'editmodelpdf' && $usercancreate &&
$object->statut == FactureFournisseurRec::STATUS_NOTSUSPENDED) {
1316 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>';
1318 print
'</tr></table>';
1320 if ($action ==
'editmodelpdf') {
1321 include_once DOL_DOCUMENT_ROOT .
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
1324 foreach ($models as $k => $model) {
1325 $list[] = str_replace(
':',
'|', $k) .
':' . $model;
1327 $select =
'select;' . implode(
',', $list);
1329 print $form->editfieldval($langs->trans(
'Model'),
'modelpdf',
$object->model_pdf, $object, $usercancreate, $select);
1342 print
'<div class="fichehalfright">';
1343 print
'<div class="underbanner clearboth"></div>';
1348 $title = $langs->trans(
"Recurrence");
1351 print
'<table class="border centpercent tableforfield">';
1353 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
1356 print
'<tr><td>' . $langs->trans(
'AmountHT') .
'</td>';
1357 print
'<td>' .
price(
$object->total_ht, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
1360 print
'<tr><td>' . $langs->trans(
"AmountVAT") .
'</td><td>' .
price(
$object->total_tva, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
1364 if (($mysoc->localtax1_assuj ==
"1" && $mysoc->useLocalTax(1)) ||
$object->total_localtax1 != 0) {
1365 print
'<tr><td>' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
1366 print
'<td class="nowrap">' .
price(
$object->total_localtax1, 1,
'', 1, -1, -1,
$conf->currency) .
'</td></tr>';
1368 if (($mysoc->localtax2_assuj ==
"1" && $mysoc->useLocalTax(2)) ||
$object->total_localtax2 != 0) {
1369 print
'<tr><td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
1370 print
'<td class=nowrap">' .
price(
$object->total_localtax2, 1,
'', 1, -1, -1,
$conf->currency) .
'</td></tr>';
1373 print
'<tr><td>' . $langs->trans(
"AmountTTC") .
'</td><td colspan="3">' .
price(
$object->total_ttc, 0, $langs, 1, -1, -1,
$conf->currency) .
'</td>';
1377 print
'<tr class="liste_titre"><td colspan="2" class="liste_titre">' .
img_picto(
'',
'recurring',
'class="pictofixedwidth"') . $title .
'</td></tr>';
1380 print
'<tr><td style="width: 50%">';
1381 print
'<table class="nobordernopadding" width="100%"><tr><td>';
1382 print $langs->trans(
'Frequency');
1384 if ($action !=
'editfrequency' && $usercancreate) {
1385 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>';
1387 print
'</tr></table>';
1389 if ($action ==
'editfrequency') {
1390 print
'<form method="post" action="' . $_SERVER[
"PHP_SELF"] .
'?facid=' .
$object->id .
'">';
1391 print
'<input type="hidden" name="action" value="setfrequency">';
1392 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1393 print
'<table class="nobordernopadding">';
1395 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'));
1397 print
'<td class="left"><input type="submit" class="button button-edit" value="' . $langs->trans(
"Modify") .
'"></td>';
1398 print
'</tr></table></form>';
1401 print $langs->trans(
'FrequencyPer_' .
$object->unit_frequency,
$object->frequency);
1403 print
'<span class="opacitymedium">'.$langs->trans(
"NotARecurringInvoiceTemplate").
'</span>';
1411 if ($action ==
'date_when' ||
$object->frequency > 0) {
1412 print $form->editfieldkey($langs->trans(
"NextDateToExecution"),
'date_when', (
string)
$object->date_when, $object, (
int) $usercancreate,
'day');
1414 print $langs->trans(
"NextDateToExecution");
1417 if ($action ==
'date_when' ||
$object->frequency > 0) {
1418 print $form->editfieldval($langs->trans(
"NextDateToExecution"),
'date_when',
$object->date_when, $object, $usercancreate,
'day',
$object->date_when,
null,
'',
'', 0,
'strikeIfMaxNbGenReached');
1421 if (!
$object->isMaxNbGenReached()) {
1426 print
img_info($langs->trans(
"MaxNumberOfGenerationReached"));
1433 if ($action ==
'nb_gen_max' ||
$object->frequency > 0) {
1434 print $form->editfieldkey($langs->trans(
"MaxPeriodNumber"),
'nb_gen_max', (
string)
$object->nb_gen_max, $object, (
int) $usercancreate);
1436 print $langs->trans(
"MaxPeriodNumber");
1439 if ($action ==
'nb_gen_max' ||
$object->frequency > 0) {
1440 print $form->editfieldval($langs->trans(
"MaxPeriodNumber"),
'nb_gen_max',
$object->nb_gen_max ?
$object->nb_gen_max :
'',
$object, $usercancreate);
1449 if ($action ==
'auto_validate' ||
$object->frequency > 0) {
1450 print $form->editfieldkey($langs->trans(
"StatusOfAutoGeneratedInvoices"),
'auto_validate', (
string)
$object->auto_validate, $object, (
int) $usercancreate);
1452 print $langs->trans(
"StatusOfAutoGeneratedInvoices");
1455 $select =
'select;0:' . $langs->trans(
'BillStatusDraft') .
',1:' . $langs->trans(
'BillStatusValidated');
1456 if ($action ==
'auto_validate' ||
$object->frequency > 0) {
1457 print $form->editfieldval($langs->trans(
"StatusOfAutoGeneratedInvoices"),
'auto_validate',
$object->auto_validate, $object, $usercancreate, $select);
1464 if ($action ==
'generate_pdf' ||
$object->frequency > 0) {
1465 print $form->editfieldkey($langs->trans(
"StatusOfGeneratedDocuments"),
'generate_pdf', (
string)
$object->generate_pdf, $object, (
int) $usercancreate);
1467 print $langs->trans(
"StatusOfGeneratedDocuments");
1471 $select =
'select;0:' . $langs->trans(
'DoNotGenerateDoc') .
',1:' . $langs->trans(
'AutogenerateDoc');
1472 if ($action ==
'generate_pdf' ||
$object->frequency > 0) {
1473 print $form->editfieldval($langs->trans(
"StatusOfGeneratedDocuments"),
'generate_pdf',
$object->generate_pdf, $object, $usercancreate, $select);
1478 print
'<input type="hidden" name="generate_pdf" value="1">';
1488 if (empty(
$conf->cron->enabled)) {
1489 print
info_admin($langs->trans(
"EnableAndSetupModuleCron", $langs->transnoentitiesnoconv(
"Module2300Name")));
1492 print
'<div class="underbanner clearboth"></div>';
1493 print
'<table class="border centpercent tableforfield">';
1496 print
'<tr><td style="width: 50%">' . $langs->trans(
"NbOfGenerationDone") .
'</td>';
1504 print $langs->trans(
"DateLastGeneration");
1518 print
'<div class="clearboth"></div><br>';
1521 print
' <form name="addproduct" id="addproduct" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id . (($action !=
'editline') ?
'#add' :
'#line_' .
GETPOSTINT(
'lineid')) .
'" method="POST">
1522 <input type="hidden" name="token" value="' .
newToken() .
'">
1523 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline') .
'">
1524 <input type="hidden" name="mode" value="">
1525 <input type="hidden" name="id" value="' .
$object->id .
'">
1528 if (!empty(
$conf->use_javascript_ajax) &&
$object->statut == 0) {
1529 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
1532 print
'<div class="div-table-responsive-no-min">';
1533 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
1537 global $canchangeproduct;
1538 $canchangeproduct = 0;
1541 $object->printObjectLines($action,
$object->thirdparty, $mysoc, $lineid, 0);
1546 if (
$object->statut == $object::STATUS_DRAFT && $usercancreate && $action !=
'valid' && $action !=
'editline') {
1547 if ($action !=
'editline') {
1550 $parameters = array();
1551 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
1555 if (empty($reshook)) {
1556 global $senderissupplier;
1558 $senderissupplier = 2;
1573 print
'<div class="tabsAction">';
1575 if (empty(
$object->suspended)) {
1576 if ($usercancreate) {
1578 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' .
dol_escape_htmltag($langs->trans(
"MaxGenerationReached")) .
'">' . $langs->trans(
"CreateBill") .
'</a></div>';
1580 if (empty(
$object->frequency) ||
$object->date_when <= $nowlasthour) {
1581 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>';
1583 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="' .
dol_escape_htmltag($langs->trans(
"DateIsNotEnough")) .
'">' . $langs->trans(
"CreateBill") .
'</a></div>';
1587 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">' . $langs->trans(
"CreateBill") .
'</a></div>';
1591 if ($usercancreate) {
1592 if (empty(
$object->suspended)) {
1593 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>';
1595 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>';
1600 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")));
1604 print
'<div class="fichecenter"><div class="fichehalfleft">';
1605 print
'<a name="builddoc"></a>';
1608 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'invoice'), 1);
1609 $linktoelem = $tmparray[
'linktoelem'];
1610 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
1611 print $htmltoenteralink;
1613 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
1615 print
'</div></div>';
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
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_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
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.
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.
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...
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.