39require
'../../main.inc.php';
48require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
52require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture-rec.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
57require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
58require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
59require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
61 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
62 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
65 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
66 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
70 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
73 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
76$langs->loadLangs(array(
'bills',
'compta',
'suppliers',
'companies',
'products',
'banks',
'admin'));
78 $langs->load(
'incoterm');
83$action =
GETPOST(
'action',
'aZ09');
86$cancel =
GETPOST(
'cancel',
'alpha');
87$backtopage =
GETPOST(
'backtopage',
'alpha');
88$backtopageforcancel =
'';
92$origin =
GETPOST(
'origin',
'alpha');
103$hookmanager->initHooks(array(
'invoicesuppliercard',
'globalcard'));
109$extrafields->fetch_name_optionals_label(
$object->table_element);
112if ($id > 0 || !empty($ref)) {
113 $ret =
$object->fetch($id, $ref);
117 $ret =
$object->fetch_thirdparty();
125if (!empty($user->socid)) {
126 $socid = $user->socid;
130$result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture',
'fk_soc',
'rowid', $isdraft);
133$usercanread = ($user->hasRight(
"fournisseur",
"facture",
"lire") || $user->hasRight(
"supplier_invoice",
"lire"));
134$usercancreate = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
135$usercandelete = (($user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"supprimer")) || ($usercancreate &&
$object->is_erasable() == 1));
136$usercancreatecontract = $user->hasRight(
"contrat",
"creer");
139$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"validate")));
140$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"send"));
141$usercancreatecreditransfer = $user->hasRight(
'paymentbybanktransfer',
'create');
144$permissionnote = $usercancreate;
145$permissiondellink = $usercancreate;
146$permissiontoedit = $usercancreate;
147$permissiontoadd = $usercancreate;
148$permissiontodelete = $usercandelete;
149$permissiontoeditextra = $permissiontoadd;
150if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
152 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
162$parameters = array(
'socid' => $socid);
163$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
168if (empty($reshook)) {
169 $backurlforlist = DOL_URL_ROOT.
'/fourn/facture/list.php';
171 if (empty($backtopage) || ($cancel && empty($id))) {
172 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
173 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
174 $backtopage = $backurlforlist;
176 $backtopage = DOL_URL_ROOT.
'/fourn/facture/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
182 if (!empty($backtopageforcancel)) {
183 header(
"Location: ".$backtopageforcancel);
185 } elseif (!empty($backtopage)) {
186 header(
"Location: ".$backtopage);
192 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
194 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
196 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
199 if (
GETPOST(
'linkedOrder') && empty($cancel) && $id > 0 && $permissiontoadd) {
202 $result =
$object->add_object_linked(
'order_supplier',
GETPOSTINT(
'linkedOrder'));
206 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
208 '@phan-var-force FactureFournisseur $objectutil';
210 if (
GETPOST(
'newsupplierref',
'alphanohtml')) {
211 $objectutil->ref_supplier =
GETPOST(
'newsupplierref',
'alphanohtml');
215 $result = $objectutil->createFromClone($user, $id);
217 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
220 $langs->load(
"errors");
224 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' && $usercanvalidate) {
225 $idwarehouse =
GETPOST(
'idwarehouse');
230 $qualified_for_stock_change = 0;
232 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
234 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
239 $langs->load(
"stocks");
240 if (!$idwarehouse || $idwarehouse == -1) {
242 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
250 $result =
$object->validate($user,
'', $idwarehouse);
257 $categories =
GETPOST(
'categories',
'array:int');
258 if (method_exists($object,
'setCategories')) {
259 $object->setCategories($categories);
267 $outputlangs = $langs;
270 $newlang =
GETPOST(
'lang_id',
'aZ09');
273 $newlang =
$object->thirdparty->default_lang;
275 if (!empty($newlang)) {
277 $outputlangs->setDefaultLang($newlang);
282 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
289 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontodelete) {
293 $isErasable =
$object->is_erasable();
295 if ($usercandelete && $isErasable > 0) {
296 $revertstock =
GETPOST(
'revertstock');
301 $qualified_for_stock_change = 0;
303 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
305 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
310 $langs->load(
"stocks");
311 if (!$idwarehouse || $idwarehouse == -1) {
313 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
316 $result =
$object->setDraft($user, $idwarehouse);
325 $result =
$object->delete($user);
327 header(
'Location: list.php?restore_lastsearch_values=1');
334 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
336 $result =
$object->deleteLine($lineid);
356 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
363 } elseif ($action ==
'unlinkdiscount' && $usercancreate) {
366 $result = $discount->fetch(
GETPOSTINT(
"discountid"));
367 $discount->unlink_invoice();
368 } elseif ($action ==
'confirm_paid' && $confirm ==
'yes' && $usercancreate) {
370 $result =
$object->setPaid($user);
374 } elseif ($action ==
'confirm_paid_partially' && $confirm ==
'yes' && $usercancreate) {
377 $close_code =
GETPOST(
"close_code",
'restricthtml');
378 $close_note =
GETPOST(
"close_note",
'restricthtml');
380 $result =
$object->setPaid($user, $close_code, $close_note);
385 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Reason")),
null,
'errors');
387 } elseif ($action ==
'confirm_canceled' && $confirm ==
'yes' && $usercancreate) {
390 $close_code =
GETPOST(
"close_code",
'restricthtml');
391 $close_note =
GETPOST(
"close_note",
'restricthtml');
393 $result =
$object->setCanceled($user, $close_code, $close_note);
398 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Reason")),
null,
'errors');
403 if ($action ==
'setref_supplier' && $usercancreate) {
406 if (
$object->update($user) < 0) {
410 $outputlangs = $langs;
413 $newlang =
GETPOST(
'lang_id',
'aZ09');
416 $newlang =
$object->thirdparty->default_lang;
418 if (!empty($newlang)) {
420 $outputlangs->setDefaultLang($newlang);
424 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
430 if ($action ==
'setconditions' && $usercancreate) {
432 $object->cond_reglement_code = 0;
433 $object->cond_reglement_id = 0;
448 $new_date_echeance =
$object->calculate_date_lim_reglement();
449 if ($new_date_echeance) {
450 $object->date_echeance = $new_date_echeance;
455 $result =
$object->update($user);
467 } elseif ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm') && $usercancreate) {
470 } elseif ($action ==
'settags' &&
isModEnabled(
'category') && $usercancreate) {
473 } elseif ($action ==
'setmode' && $usercancreate) {
476 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
478 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
479 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
482 } elseif ($action ==
'setbankaccount' && $usercancreate) {
485 } elseif ($action ==
'setvatreversecharge' && $usercancreate) {
487 $vatreversecharge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
488 $result =
$object->setVATReverseCharge($vatreversecharge);
491 if ($action ==
'settransportmode' && $usercancreate) {
494 } elseif ($action ==
'setlabel' && $usercancreate) {
498 $result =
$object->update($user);
502 } elseif ($action ==
'setdatef' && $usercancreate) {
506 setEventMessages($langs->trans(
"WarningInvoiceDateInFuture"),
null,
'warnings');
508 setEventMessages($langs->trans(
"WarningInvoiceDateTooFarInFuture"),
null,
'warnings');
515 $date_echence_calc =
$object->calculate_date_lim_reglement();
516 if (!empty(
$object->date_echeance)) {
517 $object->date_echeance = $date_echence_calc;
523 $result =
$object->update($user);
527 } elseif ($action ==
'setdate_lim_reglement' && $usercancreate) {
532 setEventMessages($langs->trans(
"DatePaymentTermCantBeLowerThanObjectDate"),
null,
'warnings');
534 $result =
$object->update($user);
538 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
554 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
556 $discount->fetch(
GETPOSTINT(
"remise_id_for_payment"));
560 $remaintopay =
$object->getRemainToPay(0);
564 setEventMessages($langs->trans(
"ErrorDiscountLargerThanRemainToPaySplitItBefore"),
null,
'errors');
568 $result = $discount->link_to_invoice(0, $id);
575 $newremaintopay =
$object->getRemainToPay(0);
576 if ($newremaintopay == 0) {
587 $outputlangs = $langs;
590 $newlang =
GETPOST(
'lang_id',
'aZ09');
593 $newlang =
$object->thirdparty->default_lang;
595 if (!empty($newlang)) {
597 $outputlangs->setDefaultLang($newlang);
601 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
606 } elseif ($action ==
'confirm_converttoreduc' && $confirm ==
'yes' && $usercancreate) {
614 $result = $discountcheck->fetch(0, 0,
$object->id);
626 $amount_ht = $amount_tva = $amount_ttc = array();
627 $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array();
631 foreach (
$object->lines as $line) {
632 if ($line->product_type < 9 && $line->total_ht != 0) {
633 $keyforvatrate = $line->tva_tx.($line->vat_src_code ?
' ('.$line->vat_src_code.
')' :
'');
635 $amount_ht[$keyforvatrate] += $line->total_ht;
636 $amount_tva[$keyforvatrate] += $line->total_tva;
637 $amount_ttc[$keyforvatrate] += $line->total_ttc;
638 $multicurrency_amount_ht[$keyforvatrate] += $line->multicurrency_total_ht;
639 $multicurrency_amount_tva[$keyforvatrate] += $line->multicurrency_total_tva;
640 $multicurrency_amount_ttc[$keyforvatrate] += $line->multicurrency_total_ttc;
644 '@phan-var-force array<string,float> $amount_ht
645 @phan-var-force array<string,float> $amount_tva
646 @phan-var-force array<string,float> $amount_ttc
647 @phan-var-force array<string,float> $multicurrency_amount_ht
648 @phan-var-force array<string,float> $multicurrency_amount_tva
649 @phan-var-force array<string,float> $multicurrency_amount_ttc';
653 $alreadypaid =
$object->getSommePaiement();
654 if ($alreadypaid && abs($alreadypaid) < abs(
$object->total_ttc)) {
655 $ratio = abs((
$object->total_ttc - $alreadypaid) /
$object->total_ttc);
656 foreach ($amount_ht as $vatrate => $val) {
657 $amount_ht[$vatrate] =
price2num($amount_ht[$vatrate] * $ratio,
'MU');
658 $amount_tva[$vatrate] =
price2num($amount_tva[$vatrate] * $ratio,
'MU');
659 $amount_ttc[$vatrate] =
price2num($amount_ttc[$vatrate] * $ratio,
'MU');
660 $multicurrency_amount_ht[$vatrate] =
price2num($multicurrency_amount_ht[$vatrate] * $ratio,
'MU');
661 $multicurrency_amount_tva[$vatrate] =
price2num($multicurrency_amount_tva[$vatrate] * $ratio,
'MU');
662 $multicurrency_amount_ttc[$vatrate] =
price2num($multicurrency_amount_ttc[$vatrate] * $ratio,
'MU');
671 $discount->description =
'(CREDIT_NOTE)';
673 $discount->description =
'(DEPOSIT)';
675 $discount->description =
'(EXCESS PAID)';
677 setEventMessages($langs->trans(
'CantConvertToReducAnInvoiceOfThisType'),
null,
'errors');
679 $discount->discount_type = 1;
680 $discount->fk_soc =
$object->socid;
681 $discount->socid =
$object->socid;
682 $discount->fk_invoice_supplier_source =
$object->id;
690 $sql =
'SELECT SUM(pf.amount) as total_paiements';
691 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.
'paiementfourn as p';
692 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN ('.
getEntity(
'c_paiement').
')';
693 $sql .=
' WHERE pf.fk_facturefourn = '.((int)
$object->id);
694 $sql .=
' AND pf.fk_paiementfourn = p.rowid';
695 $sql .=
' AND p.entity IN ('.getEntity(
'invoice').
')';
697 $resql = $db->query($sql);
702 $res = $db->fetch_object($resql);
703 $total_paiements = $res->total_paiements;
706 $total_creditnote_and_deposit = 0;
707 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
708 $sql .=
" re.description, re.fk_invoice_supplier_source";
709 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
710 $sql .=
" WHERE fk_invoice_supplier = ".((int)
$object->id);
711 $resql = $db->query($sql);
712 if (!empty($resql)) {
713 while ($obj = $db->fetch_object($resql)) {
714 $total_creditnote_and_deposit += $obj->amount_ttc;
720 $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit -
$object->total_ttc;
721 $discount->amount_tva = 0;
722 $discount->tva_tx = 0;
723 $discount->vat_src_code =
'';
725 $result = $discount->create($user);
731 foreach ($amount_ht as $tva_tx => $xxx) {
732 $discount->amount_ht = abs((
float) $amount_ht[$tva_tx]);
733 $discount->amount_tva = abs((
float) $amount_tva[$tva_tx]);
734 $discount->amount_ttc = abs((
float) $amount_ttc[$tva_tx]);
735 $discount->multicurrency_amount_ht = abs((
float) $multicurrency_amount_ht[$tva_tx]);
736 $discount->multicurrency_amount_tva = abs((
float) $multicurrency_amount_tva[$tva_tx]);
737 $discount->multicurrency_amount_ttc = abs((
float) $multicurrency_amount_ttc[$tva_tx]);
742 if (preg_match(
'/\((.*)\)/', $tva_tx, $reg)) {
743 $vat_src_code = $reg[1];
744 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx);
747 $discount->tva_tx = abs((
float) $tva_tx);
748 $discount->vat_src_code = $vat_src_code;
750 $result = $discount->create($user);
761 $result =
$object->setPaid($user);
776 } elseif ($action ==
'confirm_delete_paiement' && $confirm ==
'yes' && $usercancreate) {
781 $result = $paiementfourn->fetch(
GETPOSTINT(
'paiement_id'));
783 $result = $paiementfourn->delete($user);
785 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
793 } elseif ($action ==
'add' && $usercancreate) {
798 $selectedLines =
GETPOST(
'toselect',
'array:int');
806 $ret = $extrafields->setOptionalsFromPost(
null, $object);
820 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
825 if (empty($dateinvoice)) {
826 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
838 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ReplaceInvoice")),
null,
'errors');
852 $object->date_echeance = $datedue;
858 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
859 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
861 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
862 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
883 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CorrectInvoice")),
null,
'errors');
886 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Supplier')),
null,
'errors');
891 if (empty($dateinvoice)) {
892 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
902 if (!
GETPOST(
'ref_supplier')) {
903 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'RefSupplierBill')),
null,
'errors');
911 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
926 $object->date_echeance = $datedue;
932 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
933 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
935 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
936 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
941 $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice :
'';
950 if (
GETPOSTINT(
'invoiceAvoirWithLines') == 1 && $id > 0) {
952 if ($facture_source->fetch(
$object->fk_facture_source) > 0) {
955 foreach ($facture_source->lines as $line) {
957 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
961 $line->fk_facture_fourn =
$object->id;
962 $line->fk_parent_line = $fk_parent_line;
964 $line->subprice = -$line->subprice;
965 $line->pa_ht = -((float) $line->pa_ht);
966 $line->total_ht = -$line->total_ht;
967 $line->total_tva = -$line->total_tva;
968 $line->total_ttc = -$line->total_ttc;
969 $line->total_localtax1 = -$line->total_localtax1;
970 $line->total_localtax2 = -$line->total_localtax2;
972 $result = $line->insert();
977 if ($result > 0 && $line->product_type == 9) {
978 $fk_parent_line = $result;
986 if (
GETPOSTINT(
'invoiceAvoirWithPaymentRestAmount') == 1 &&
$id > 0) {
988 if ($facture_source->fetch(
$object->fk_facture_source) > 0) {
989 $totalpaid = $facture_source->getSommePaiement();
990 $totalcreditnotes = $facture_source->getSumCreditNotesUsed();
991 $totaldeposits = $facture_source->getSumDepositsUsed();
992 $remain_to_pay = abs($facture_source->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits);
993 $desc = $langs->trans(
'invoiceAvoirLineWithPaymentRestAmount');
994 $retAddLine =
$object->addline($desc, $remain_to_pay, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
'TTC');
996 if ($retAddLine < 0) {
1004 if (empty($dateinvoice)) {
1006 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
1016 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
1026 $object->note_public = trim(
GETPOST(
'note_public',
'restricthtml'));
1027 $object->note_private = trim(
GETPOST(
'note_private',
'restricthtml'));
1038 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
1039 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
1043 $object->fac_rec = $fac_recid;
1045 $fac_rec->fetch(
$object->fac_rec);
1046 $fac_rec->fetch_lines();
1047 $object->lines = $fac_rec->lines;
1054 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Supplier')),
null,
'errors');
1059 if (empty($dateinvoice)) {
1060 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
1070 if (!
GETPOST(
'ref_supplier')) {
1071 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'RefSupplierBill')),
null,
'errors');
1079 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
1096 $object->date_echeance = $datedue;
1102 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
1103 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
1105 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
1106 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
1111 if (empty(
$object->date_echeance)) {
1112 $object->date_echeance =
$object->calculate_date_lim_reglement();
1118 if (!$error &&
GETPOST(
'origin',
'alpha') &&
GETPOST(
'originid')) {
1120 $element = $subelement =
GETPOST(
'origin',
'alpha');
1128 if ($element ==
'order') {
1129 $element = $subelement =
'commande';
1131 if ($element ==
'propal') {
1132 $element =
'comm/propal';
1133 $subelement =
'propal';
1135 if ($element ==
'contract') {
1136 $element = $subelement =
'contrat';
1138 if ($element ==
'order_supplier') {
1140 $subelement =
'fournisseur.commande';
1142 if ($element ==
'project') {
1143 $element =
'projet';
1151 $classname = ucfirst($subelement);
1152 if ($classname ==
'Fournisseur.commande') {
1153 $classname =
'CommandeFournisseur';
1155 $objectsrc =
new $classname($db);
1156 $objectsrc->fetch($originid);
1157 $objectsrc->fetch_thirdparty();
1159 if (!empty(
$object->origin_type) && !empty(
$object->origin_id)) {
1164 if (
$object->origin_type ==
'reception') {
1165 $objectsrc->fetchObjectLinked();
1167 if (count($objectsrc->linkedObjectsIds[
'order_supplier']) > 0) {
1168 foreach ($objectsrc->linkedObjectsIds[
'order_supplier'] as $key => $value) {
1169 $object->linkedObjectsIds[
'order_supplier'][-1] = $value;
1179 $classname = ucfirst($subelement);
1180 if ($classname ==
'Fournisseur.commande') {
1181 $classname =
'CommandeFournisseur';
1183 $srcobject =
new $classname($db);
1185 $result = $srcobject->fetch(
GETPOSTINT(
'originid'));
1188 $typeamount =
GETPOST(
'typedeposit',
'alpha');
1193 $amountdeposit = array();
1195 if ($typeamount ==
'amount') {
1196 $amount = $valuedeposit;
1198 $amount = $srcobject->total_ttc * ((float) $valuedeposit / 100);
1201 $TTotalByTva = array();
1202 foreach ($srcobject->lines as &$line) {
1203 if (!empty($line->special_code)) {
1206 $TTotalByTva[$line->tva_tx] += $line->total_ttc;
1208 '@phan-var-force array<string,float> $TTotalByTva';
1210 $amount_ttc_diff = 0.;
1211 foreach ($TTotalByTva as $tva => &$total) {
1212 $coef = $total / $srcobject->total_ttc;
1213 $am = $amount * $coef;
1214 $amount_ttc_diff += $am;
1215 $amountdeposit[$tva] += $am / (1 + (float) $tva / 100);
1218 if ($typeamount ==
'amount') {
1219 $amountdeposit[0] = $valuedeposit;
1220 } elseif ($typeamount ==
'variable') {
1223 $lines = $srcobject->lines;
1224 $numlines = count($lines);
1225 for ($i = 0; $i < $numlines; $i++) {
1227 if (empty($lines[$i]->qty)) {
1230 if (!empty($lines[$i]->special_code)) {
1234 $totalamount += $lines[$i]->total_ht;
1235 $tva_tx = $lines[$i]->tva_tx;
1236 $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * (float) $valuedeposit) / 100;
1240 if ($totalamount == 0) {
1241 $amountdeposit[0] = 0;
1246 $amountdeposit[0] = 0;
1250 $amount_ttc_diff = array_key_exists(0, $amountdeposit) ? $amountdeposit[0] : 0;
1253 foreach ($amountdeposit as $tva => $amount) {
1254 if (empty($amount)) {
1259 'amount' =>
'FixAmount',
1260 'variable' =>
'VarAmount'
1262 $descline =
'(DEPOSIT)';
1264 if ($typeamount ==
'amount') {
1265 $descline .=
' ('.price($valuedeposit, 0, $langs, 0, - 1, - 1, (!empty(
$object->multicurrency_code) ?
$object->multicurrency_code : $conf->currency)).
')';
1266 } elseif ($typeamount ==
'variable') {
1267 $descline .=
' ('.$valuedeposit.
'%)';
1270 $descline .=
' - '.$srcobject->ref;
1300 $diff =
$object->total_ttc - $amount_ttc_diff;
1304 $subprice_diff =
$object->lines[0]->subprice - $diff / (1 +
$object->lines[0]->tva_tx / 100);
1310 $object->lines[0]->localtax1_tx,
1311 $object->lines[0]->localtax2_tx,
1313 $object->lines[0]->fk_product,
1316 $object->lines[0]->product_type,
1317 $object->lines[0]->remise_percent,
1319 $object->lines[0]->date_start,
1328 } elseif ($result > 0) {
1329 $lines = $srcobject->lines;
1330 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
1331 $srcobject->fetch_lines();
1332 $lines = $srcobject->lines;
1335 $num = count($lines);
1336 for ($i = 0; $i < $num; $i++) {
1337 if (!in_array($lines[$i]->
id, $selectedLines)) {
1341 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->product_label);
1342 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
1345 if (method_exists($lines[$i],
'fetch_optionals')) {
1346 $lines[$i]->fetch_optionals();
1351 $date_start = $lines[$i]->date_debut_prevue;
1352 if ($lines[$i]->date_debut_reel) {
1353 $date_start = $lines[$i]->date_debut_reel;
1355 if ($lines[$i]->date_start) {
1356 $date_start = $lines[$i]->date_start;
1358 $date_end = $lines[$i]->date_fin_prevue;
1359 if ($lines[$i]->date_fin_reel) {
1360 $date_end = $lines[$i]->date_fin_reel;
1362 if ($lines[$i]->date_end) {
1363 $date_end = $lines[$i]->date_end;
1366 $tva_tx = $lines[$i]->tva_tx;
1368 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', (
string) $tva_tx)) {
1369 $tva_tx .=
' ('.$lines[$i]->vat_src_code.
')';
1373 $object->special_code = $lines[$i]->special_code;
1376 if (
$object->multicurrency_code != $conf->currency ||
$object->multicurrency_tx != 1) {
1378 $pu_currency = $lines[$i]->multicurrency_subprice;
1380 $pu = $lines[$i]->subprice;
1389 $lines[$i]->localtax1_tx,
1390 $lines[$i]->localtax2_tx,
1392 $lines[$i]->fk_product,
1393 $lines[$i]->remise_percent,
1397 $lines[$i]->info_bits,
1402 $lines[$i]->array_options,
1403 $lines[$i]->fk_unit,
1406 $lines[$i]->ref_supplier,
1407 $lines[$i]->special_code
1424 $parameters = array(
'objFrom' => $srcobject);
1425 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $object, $action);
1435 } elseif (!$error) {
1445 $langs->load(
"errors");
1455 $outputlangs = $langs;
1456 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1463 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
1466 } elseif ($action ==
'updateline' && $usercancreate) {
1470 if (!
$object->fetch($id) > 0) {
1476 $tva_tx = str_replace(
'*',
'', $tva_tx);
1478 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_subprice') !=
'') {
1480 $price_base_type =
'HT';
1483 $price_base_type =
'TTC';
1486 if (
GETPOST(
'productid') > 0) {
1488 if (
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY') == 1) {
1490 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1496 $label = $prod->description;
1497 if (trim(
GETPOST(
'product_desc',
'restricthtml')) != trim($label)) {
1498 $label =
GETPOST(
'product_desc',
'restricthtml');
1501 $type = $prod->type;
1503 $label =
GETPOST(
'product_desc',
'restricthtml');
1512 if (preg_match(
'/\*/', $tva_tx)) {
1517 $tva_tx = str_replace(
'*',
'', $tva_tx);
1525 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1526 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1528 if (is_array($extralabelsline)) {
1529 foreach ($extralabelsline as $key => $value) {
1530 unset($_POST[
"options_".$key]);
1534 $result =
$object->updateline(
1546 (
float) $remise_percent,
1556 unset($_POST[
'label']);
1557 unset($_POST[
'fourn_ref']);
1558 unset($_POST[
'date_starthour']);
1559 unset($_POST[
'date_startmin']);
1560 unset($_POST[
'date_startsec']);
1561 unset($_POST[
'date_startday']);
1562 unset($_POST[
'date_startmonth']);
1563 unset($_POST[
'date_startyear']);
1564 unset($_POST[
'date_endhour']);
1565 unset($_POST[
'date_endmin']);
1566 unset($_POST[
'date_endsec']);
1567 unset($_POST[
'date_endday']);
1568 unset($_POST[
'date_endmonth']);
1569 unset($_POST[
'date_endyear']);
1570 unset($_POST[
'price_ttc']);
1571 unset($_POST[
'price_ht']);
1578 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') && (
GETPOST(
'alldate_start',
'alpha') ||
GETPOST(
'alldate_end',
'alpha')) && $usercancreate) {
1582 foreach (
$object->lines as $line) {
1583 if ($line->product_type == 1) {
1584 $result =
$object->updateline($line->id, $line->desc, $line->subprice, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->qty, $line->fk_product,
'HT', $line->info_bits, $line->product_type, $line->remise_percent, 0, $alldate_start, $alldate_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice, $line->ref_supplier, $line->rang);
1587 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') !=
'' && $usercancreate) {
1589 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
1590 $vat_rate = str_replace(
'*',
'', $vat_rate);
1593 foreach (
$object->lines as $line) {
1594 $result =
$object->updateline($line->id, $line->desc, $line->subprice, $vat_rate, $localtax1_rate, $localtax2_rate, $line->qty, $line->fk_product,
'HT', $line->info_bits, $line->product_type, $line->remise_percent, 0, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice, $line->ref_supplier, $line->rang);
1596 } elseif ($action ==
'addline' && $usercancreate) {
1605 $ret =
$object->fetch_thirdparty();
1607 $langs->load(
'errors');
1612 $line_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
1616 $prod_entry_mode =
GETPOST(
'prod_entry_mode');
1617 if ($prod_entry_mode ==
'free') {
1624 $price_ht_devise =
'';
1626 $price_ttc_devise =
'';
1628 if (
GETPOST(
'price_ht') !==
'') {
1631 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
1634 if (
GETPOST(
'price_ttc') !==
'') {
1637 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
1638 $price_ttc_devise =
price2num(
GETPOST(
'multicurrency_price_ttc'),
'CU', 2);
1645 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef,
'alpha'),
'', 2) : 0);
1646 if (empty($remise_percent)) {
1647 $remise_percent = 0;
1651 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1652 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1654 if (is_array($extralabelsline)) {
1656 foreach ($extralabelsline as $key => $value) {
1657 unset($_POST[
"options_".$key]);
1661 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
1662 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1665 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') &&
GETPOST(
'type') < 0) {
1666 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
1671 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1')
1672 && (((
float) $price_ht < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) || $price_ht ===
'')
1673 && (((
float) $price_ht_devise < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) || $price_ht_devise ===
'')
1674 && ((
float) $price_ttc < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES') || $price_ttc ===
'')
1675 && ((
float) $price_ttc_devise < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES') || $price_ttc_devise ===
'')
1676 &&
$object->type != $object::TYPE_CREDIT_NOTE) {
1677 if (((
float) $price_ht < 0 || (
float) $price_ttc < 0) && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) {
1678 $langs->load(
"errors");
1679 if (
$object->type == $object::TYPE_DEPOSIT) {
1681 setEventMessages($langs->trans(
"ErrorLinesCantBeNegativeOnDeposits"),
null,
'errors');
1683 setEventMessages($langs->trans(
"ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv(
"UnitPrice"), $langs->transnoentitiesnoconv(
"CustomerAbsoluteDiscountShort")),
null,
'errors');
1688 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' && $price_ht_devise ===
'') {
1689 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'UnitPrice')),
null,
'errors');
1693 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') && !
GETPOST(
'dp_desc')) {
1694 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
1697 if (!
GETPOST(
'qty',
'alpha')) {
1698 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1702 if (!$error &&
isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1703 if ($combinations =
GETPOST(
'combinations',
'array:alphanohtml')) {
1707 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1708 $idprod = $res->fk_product_child;
1710 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1716 if ($prod_entry_mode !=
'free' && empty($error)) {
1720 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
1725 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
1726 $idprod = (int) $reg[1];
1727 $res = $productsupplier->fetch($idprod);
1730 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
1732 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1733 if ($productsupplier->fourn_socid != $socid) {
1734 $productsupplier->ref_supplier =
'';
1737 $fksoctosearch =
$object->thirdparty->id;
1738 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1740 } elseif (
GETPOSTINT(
'idprodfournprice') > 0) {
1741 $qtytosearch = (float) $qty;
1743 $idprod = $productsupplier->get_buyprice(
GETPOSTINT(
'idprodfournprice'), $qtytosearch);
1744 $res = $productsupplier->fetch($idprod);
1748 $label = $productsupplier->label;
1751 $outputlangs = $langs;
1753 if (
GETPOST(
'lang_id',
'aZ09')) {
1754 $newlang =
GETPOST(
'lang_id',
'aZ09');
1756 if (empty($newlang)) {
1757 $newlang =
$object->thirdparty->default_lang;
1759 if (!empty($newlang)) {
1760 $outputlangs =
new Translate(
"", $conf);
1761 $outputlangs->setDefaultLang($newlang);
1763 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->
description;
1765 $desc = $productsupplier->description;
1768 if (!empty($productsupplier->desc_supplier) &&
getDolGlobalString(
'PRODUIT_FOURN_TEXTS')) {
1769 $desc = $productsupplier->desc_supplier;
1780 $ref_supplier = $productsupplier->ref_supplier;
1783 if (!GETPOSTISSET(
'tva_tx')) {
1784 $tmpidprodfournprice =
GETPOST(
'idprodfournprice',
'alpha');
1785 if (is_numeric($tmpidprodfournprice) && (
int) $tmpidprodfournprice > 0) {
1786 $tmpidprodfournprice = (int) $tmpidprodfournprice;
1788 $tmpidprodfournprice = 0;
1794 if (empty($tva_tx) || empty($tva_npr)) {
1800 $type = $productsupplier->type;
1801 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1802 $price_base_type =
'HT';
1804 $pu_devise =
price2num($price_ht_devise,
'CU');
1805 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
1806 $price_base_type =
'TTC';
1808 $pu_devise =
price2num($price_ttc_devise,
'CU');
1810 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
1811 if (empty(
$object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code !=
$object->multicurrency_code)) {
1812 $pu = $productsupplier->fourn_pu;
1815 $pu = $productsupplier->fourn_pu;
1816 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
1820 $ref_supplier = $productsupplier->ref_supplier;
1841 min($rank, count(
$object->lines) + 1),
1844 $productsupplier->fk_unit,
1847 GETPOST(
'fourn_ref',
'alpha'),
1851 if ($idprod == -99 || $idprod == 0) {
1854 $langs->load(
"errors");
1855 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
1857 if ($idprod == -1) {
1860 $langs->load(
"errors");
1861 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
1863 } elseif (empty($error)) {
1864 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1865 $tva_tx = str_replace(
'*',
'', $tva_tx);
1866 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1869 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1873 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
1881 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1885 $pu_ht =
price2num((
float) $pu_ttc / (1 + ((
float) $tva_tx / 100)),
'MU');
1887 $price_base_type =
'HT';
1888 $pu_devise =
price2num($price_ht_devise,
'CU');
1890 $result =
$object->addline($line_desc, (
float) $pu_ht, $tva_tx, $localtax1_tx, $localtax2_tx, (
float) $qty, 0, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit, 0, (
float) $pu_devise, $ref_supplier);
1894 if (!$error && $result > 0) {
1899 $outputlangs = $langs;
1902 $newlang =
GETPOST(
'lang_id',
'aZ09');
1905 $newlang =
$object->thirdparty->default_lang;
1907 if (!empty($newlang)) {
1908 $outputlangs =
new Translate(
"", $conf);
1909 $outputlangs->setDefaultLang($newlang);
1914 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1920 unset($_POST [
'prod_entry_mode']);
1922 unset($_POST[
'qty']);
1923 unset($_POST[
'type']);
1924 unset($_POST[
'remise_percent']);
1925 unset($_POST[
'pu']);
1926 unset($_POST[
'price_ht']);
1927 unset($_POST[
'multicurrency_price_ht']);
1928 unset($_POST[
'price_ttc']);
1929 unset($_POST[
'fourn_ref']);
1930 unset($_POST[
'tva_tx']);
1931 unset($_POST[
'label']);
1932 unset($localtax1_tx);
1933 unset($localtax2_tx);
1934 unset($_POST[
'np_marginRate']);
1935 unset($_POST[
'np_markRate']);
1936 unset($_POST[
'dp_desc']);
1937 unset($_POST[
'idprodfournprice']);
1938 unset($_POST[
'units']);
1940 unset($_POST[
'date_starthour']);
1941 unset($_POST[
'date_startmin']);
1942 unset($_POST[
'date_startsec']);
1943 unset($_POST[
'date_startday']);
1944 unset($_POST[
'date_startmonth']);
1945 unset($_POST[
'date_startyear']);
1946 unset($_POST[
'date_endhour']);
1947 unset($_POST[
'date_endmin']);
1948 unset($_POST[
'date_endsec']);
1949 unset($_POST[
'date_endday']);
1950 unset($_POST[
'date_endmonth']);
1951 unset($_POST[
'date_endyear']);
1958 } elseif ($action ==
'classin' && $usercancreate) {
1960 $result =
$object->setProject($projectid);
1961 } elseif ($action ==
'confirm_edit' && $confirm ==
'yes' && $usercancreate) {
1965 $totalpaid =
$object->getSommePaiement();
1966 $resteapayer =
$object->total_ttc - $totalpaid;
1969 $ventilExportCompta =
$object->getVentilExportCompta();
1971 if (!$ventilExportCompta) {
1974 $idwarehouse =
GETPOST(
'idwarehouse');
1978 $qualified_for_stock_change = 0;
1980 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1982 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1987 $langs->load(
"stocks");
1988 if (!$idwarehouse || $idwarehouse == -1) {
1990 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1995 $object->setDraft($user, $idwarehouse);
1999 $outputlangs = $langs;
2002 $newlang =
GETPOST(
'lang_id',
'aZ09');
2005 $newlang =
$object->thirdparty->default_lang;
2007 if (!empty($newlang)) {
2008 $outputlangs =
new Translate(
"", $conf);
2009 $outputlangs->setDefaultLang($newlang);
2014 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
2023 } elseif ($action ==
'reopen' && $usercancreate) {
2025 $result =
$object->fetch($id);
2028 $result =
$object->setUnpaid($user);
2030 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
2039 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
2042 $triggersendname =
'BILL_SUPPLIER_SENTBYMAIL';
2044 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
2045 $trackid =
'sinv'.$object->id;
2046 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
2049 $upload_dir = $conf->fournisseur->facture->dir_output;
2050 $permissiontoadd = $usercancreate;
2051 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
2054 if ($action ==
'calculate' && $usercancreate) {
2055 $calculationrule =
GETPOST(
'calculationrule');
2059 $result =
$object->update_price(0, (($calculationrule ==
'totalofround') ?
'0' :
'1'), 0,
$object->thirdparty);
2065 if ($action ==
'update_extras' && $permissiontoeditextra) {
2068 $attribute_name =
GETPOST(
'attribute',
'aZ09');
2071 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
2077 $result =
$object->updateExtraField($attribute_name,
'BILL_SUPPLIER_MODIFY');
2085 $action =
'edit_extras';
2090 if ($action ==
'addcontact' && $usercancreate) {
2091 $result =
$object->fetch($id);
2093 if ($result > 0 && $id > 0) {
2096 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
2100 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2103 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2104 $langs->load(
"errors");
2105 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
2110 } elseif ($action ==
'swapstatut' && $usercancreate) {
2117 } elseif ($action ==
'deletecontact' && $usercancreate) {
2123 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2137$form =
new Form($db);
2139$bankaccountstatic =
new Account($db);
2147$title =
$object->ref.
" - ".$langs->trans(
'Card');
2148if ($action ==
'create') {
2149 $title = $langs->trans(
"NewSupplierInvoice");
2151$help_url =
'EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores|DE:Modul_Lieferantenrechnungen';
2152llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-fourn-facture page-card');
2155if ($action ==
'create') {
2157 $selectedLines = array();
2159 print
load_fiche_titre($langs->trans(
'NewSupplierInvoice'),
'',
'supplier_invoice');
2163 $currency_code = $conf->currency;
2164 $vat_reverse_charge = 0;
2170 if (
isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2171 $currency_code = $societe->multicurrency_code;
2176 if (!empty($origin) && !empty($originid)) {
2178 $element = $subelement = $origin;
2180 if ($element ==
'project') {
2181 $projectid = $originid;
2182 $element =
'projet';
2186 if ($element ==
'order') {
2187 $element = $subelement =
'commande';
2189 if ($element ==
'propal') {
2190 $element =
'comm/propal';
2191 $subelement =
'propal';
2193 if ($element ==
'contract') {
2194 $element = $subelement =
'contrat';
2196 if ($element ==
'order_supplier') {
2198 $subelement =
'fournisseur.commande';
2202 $classname = ucfirst($subelement);
2203 if ($classname ==
'Fournisseur.commande') {
2204 $classname =
'CommandeFournisseur';
2206 $objectsrc =
new $classname($db);
2207 '@phan-var-force Project|Commande|Propal|Facture|Contrat|CommandeFournisseur|CommonObject $objectsrc';
2209 $objectsrc->fetch($originid);
2210 $objectsrc->fetch_thirdparty();
2212 $projectid = (int) $objectsrc->fk_project;
2214 $soc = $objectsrc->thirdparty;
2216 $cond_reglement_id = 0;
2217 $mode_reglement_id = 0;
2221 $transport_mode_id = 0;
2224 if (!empty($objectsrc->cond_reglement_id)) {
2225 $cond_reglement_id = $objectsrc->cond_reglement_id;
2227 if (!empty($objectsrc->mode_reglement_id)) {
2228 $mode_reglement_id = $objectsrc->mode_reglement_id;
2230 if (!empty($objectsrc->fk_account)) {
2231 $fk_account = $objectsrc->fk_account;
2233 if (!empty($objectsrc->transport_mode_id)) {
2234 $transport_mode_id = $objectsrc->transport_mode_id;
2237 if (empty($cond_reglement_id)
2238 || empty($mode_reglement_id)
2239 || empty($fk_account)
2240 || empty($transport_mode_id)
2242 if ($origin ==
'reception') {
2244 if (!isset($objectsrc->supplier_order)) {
2245 $objectsrc->fetch_origin();
2248 if (!empty($objectsrc->origin_object)) {
2249 $originObject = $objectsrc->origin_object;
2250 if (empty($cond_reglement_id) && !empty($originObject->cond_reglement_id)) {
2251 $cond_reglement_id = $originObject->cond_reglement_id;
2253 if (empty($mode_reglement_id) && !empty($originObject->mode_reglement_id)) {
2254 $mode_reglement_id = $originObject->mode_reglement_id;
2256 if (empty($fk_account) && !empty($originObject->fk_account)) {
2257 $fk_account = $originObject->fk_account;
2259 if (empty($transport_mode_id) && !empty($originObject->transport_mode_id)) {
2260 $transport_mode_id = $originObject->transport_mode_id;
2267 if (empty($cond_reglement_id) && !empty($soc->cond_reglement_supplier_id)) {
2268 $cond_reglement_id = $soc->cond_reglement_supplier_id;
2270 if (empty($mode_reglement_id) && !empty($soc->mode_reglement_supplier_id)) {
2271 $mode_reglement_id = $soc->mode_reglement_supplier_id;
2273 if (empty($fk_account) && !empty($soc->fk_account)) {
2274 $fk_account = $soc->fk_account;
2276 if (empty($transport_mode_id) && !empty($soc->transport_mode_id)) {
2277 $transport_mode_id = $soc->transport_mode_id;
2283 if (!empty($objectsrc->multicurrency_code)) {
2284 $currency_code = $objectsrc->multicurrency_code;
2286 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
2287 $currency_tx = $objectsrc->multicurrency_tx;
2292 $dateinvoice = ($datetmp ==
'' ? (!
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ? -1 :
'') : $datetmp);
2294 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2297 $objectsrc->fetch_optionals();
2298 $object->array_options = $objectsrc->array_options;
2300 $cond_reglement_id = !empty($societe->cond_reglement_supplier_id) ? $societe->cond_reglement_supplier_id : 0;
2301 $mode_reglement_id = !empty($societe->mode_reglement_supplier_id) ? $societe->mode_reglement_supplier_id : 0;
2302 $vat_reverse_charge = (empty($societe) ?
'' : $societe->vat_reverse_charge);
2303 $transport_mode_id = !empty($societe->transport_mode_supplier_id) ? $societe->transport_mode_supplier_id : 0;
2304 $fk_account = !empty($societe->fk_account) ? $societe->fk_account : 0;
2306 $dateinvoice = ($datetmp ==
'' ? (
getDolGlobalInt(
'MAIN_AUTOFILL_DATE') ?
'' : -1) : $datetmp);
2308 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2310 if (
isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2311 $currency_code = $societe->multicurrency_code;
2316 if (empty($cond_reglement_id)) {
2317 $cond_reglement_id =
GETPOST(
"cond_reglement_id");
2321 if (empty($mode_reglement_id)) {
2322 $mode_reglement_id =
GETPOST(
"mode_reglement_id");
2326 if (!
GETPOST(
'changecompany')) {
2327 if (GETPOSTISSET(
'cond_reglement_id')) {
2328 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2330 if (GETPOSTISSET(
'mode_reglement_id')) {
2331 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2333 if (GETPOSTISSET(
'cond_reglement_id')) {
2338 $note_public =
$object->getDefaultCreateValueFor(
'note_public', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_public : null));
2339 $note_private =
$object->getDefaultCreateValueFor(
'note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_private : null));
2341 if ($origin ==
'contrat') {
2342 $langs->load(
"admin");
2343 $text = $langs->trans(
"ToCreateARecurringInvoice");
2344 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv(
"MenuFinancial"), $langs->transnoentitiesnoconv(
"SupplierBills"), $langs->transnoentitiesnoconv(
"ListOfTemplates"));
2346 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv(
'Module2300Name'));
2348 print
info_admin($text, 0, 0,
'0',
'opacitymedium').
'<br>';
2351 print
'<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
2352 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2353 print
'<input type="hidden" name="action" value="add">';
2354 print
'<input type="hidden" name="changecompany" value="0">';
2356 if (!empty($societe->id) && $societe->id > 0) {
2357 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">'.
"\n";
2359 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
2360 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
2361 if (!empty($currency_tx)) {
2362 print
'<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
2364 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2369 $parameters = array();
2371 $reshook = $hookmanager->executeHooks(
'tabContentCreateSupplierInvoice', $parameters, $object, $action);
2372 if (empty($reshook)) {
2373 print
'<table class="border centpercent">';
2376 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
'Draft').
'</td></tr>';
2380 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2381 $invoice_predefined->fetch($fac_recid);
2385 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
2388 if (!empty($societe->id) && $societe->id > 0 && ($fac_recid <= 0 || !empty($invoice_predefined->frequency))) {
2389 $absolute_discount = $societe->getAvailableDiscounts(
null,
'', 0, 1);
2390 print $societe->getNomUrl(1,
'supplier');
2391 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
2393 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
2394 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(empty($societe->id) ? 0 : $societe->id,
'socid', $filter,
'SelectThirdParty', 1, 0, array(), 0,
'minwidth175 widthcentpercentminusxx maxwidth500');
2397 print
'<script type="text/javascript">
2398 $(document).ready(function() {
2399 $("#socid").change(function() {
2400 console.log("We have changed the company - Reload page");
2402 $("input[name=action]").val("create");
2403 $("input[name=changecompany]").val("1");
2404 $("form[name=add]").submit();
2409 if ($fac_recid <= 0) {
2410 print
' <a href="'.DOL_URL_ROOT.
'/societe/card.php?action=create&client=0&fournisseur=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddThirdParty").
'"></span></a>';
2416 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2417 $invoice_predefined->fetch($fac_recid);
2419 $dateinvoice = $invoice_predefined->date_when;
2420 if (empty($projectid)) {
2421 $projectid = $invoice_predefined->fk_project;
2423 $cond_reglement_id = $invoice_predefined->cond_reglement_id;
2424 $mode_reglement_id = $invoice_predefined->mode_reglement_id;
2425 $fk_account = $invoice_predefined->fk_account;
2426 $note_public = $invoice_predefined->note_public;
2427 $note_private = $invoice_predefined->note_private;
2429 if (!empty($invoice_predefined->multicurrency_code)) {
2430 $currency_code = $invoice_predefined->multicurrency_code;
2432 if (!empty($invoice_predefined->multicurrency_tx)) {
2433 $currency_tx = $invoice_predefined->multicurrency_tx;
2436 $sql =
'SELECT r.rowid, r.titre as title, r.total_ttc';
2437 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn_rec as r';
2438 $sql .=
' WHERE r.fk_soc = '. (int) $invoice_predefined->socid;
2440 $resql = $db->query($sql);
2442 $num = $db->num_rows($resql);
2446 print
'<tr><td>'.$langs->trans(
'CreateFromRepeatableInvoice').
'</td><td>';
2448 print
'<select class="flat" id="fac_rec" name="fac_rec">';
2449 print
'<option value="0" selected></option>';
2451 $objp = $db->fetch_object($resql);
2452 print
'<option value="'.$objp->rowid.
'"';
2453 if ($fac_recid == $objp->rowid) {
2455 $exampletemplateinvoice->fetch($fac_recid);
2457 print
'>'.$objp->title.
' ('.
price($objp->total_ttc).
' '.$langs->trans(
"TTC").
')</option>';
2463 print
'<script type="text/javascript">
2464 $(document).ready(function() {
2465 $("#fac_rec").change(function() {
2466 console.log("We have changed the template invoice - Reload page");
2468 $("input[name=action]").val("create");
2469 $("form[name=add]").submit();
2483 print
'<tr><td class="fieldrequired">'.$langs->trans(
'RefSupplierBill').
'</td><td><input name="ref_supplier" value="'.(GETPOSTISSET(
'ref_supplier') ?
GETPOST(
'ref_supplier') : (!empty($objectsrc->ref_supplier) ? $objectsrc->ref_supplier :
'')).
'" type="text" spellcheck="false"';
2484 if (!empty($societe->id) && $societe->id > 0) {
2490 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'Type').
'</td><td>';
2492 print
'<div class="tagtable">'.
"\n";
2495 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2496 $tmp =
'<input type="radio" id="radio_standard" name="type" value="0"'.(GETPOSTINT(
'type') ?
'' :
'checked').
'> ';
2497 $desc = $form->textwithpicto($tmp.
'<label for="radio_standard">'.$langs->trans(
"InvoiceStandardAsk").
'</label>', $langs->transnoentities(
"InvoiceStandardDesc"), 1,
'help',
'', 0, 3);
2499 print
'</div></div>';
2501 if (empty($origin) || (($origin ==
'supplier_proposal' || $origin ==
'order_supplier' || $origin ==
'reception') && !empty($originid))) {
2504 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2505 $tmp =
'<input type="radio" id="radio_deposit" name="type" value="3"' . (
GETPOSTINT(
'type') == 3 ?
' checked' :
'') .
'> ';
2506 print
'<script type="text/javascript">
2507 jQuery(document).ready(function() {
2508 jQuery("#typestandardinvoice, #valuestandardinvoice").click(function() {
2509 jQuery("#radio_standard").prop("checked", true);
2511 jQuery("#typedeposit, #valuedeposit").click(function() {
2512 jQuery("#radio_deposit").prop("checked", true);
2514 jQuery("#typedeposit").change(function() {
2515 console.log("We change type of down payment");
2516 jQuery("#radio_deposit").prop("checked", true);
2517 setRadioForTypeOfInvoice();
2519 jQuery("#radio_standard, #radio_deposit, #radio_replacement, #radio_template").change(function() {
2520 setRadioForTypeOfInvoice();
2522 function setRadioForTypeOfInvoice() {
2523 console.log("Change radio");
2524 if (jQuery("#radio_deposit").prop("checked") && (jQuery("#typedeposit").val() == \'amount\' || jQuery("#typedeposit").val() == \'variable\')) {
2525 jQuery(".checkforselect").prop("disabled", true);
2526 jQuery(".checkforselect").prop("checked", false);
2528 jQuery(".checkforselect").prop("disabled", false);
2529 jQuery(".checkforselect").prop("checked", true);
2535 $tmp = $tmp.
'<label for="radio_deposit" >'.$langs->trans(
"InvoiceDeposit").
'</label>';
2537 $desc = $form->textwithpicto($tmp, $langs->transnoentities(
"InvoiceDepositDesc"), 1,
'help',
'', 0, 3);
2538 print
'<table class="nobordernopadding"><tr>';
2542 if ($origin ==
'supplier_proposal' || $origin ==
'order_supplier' || $origin ==
'reception') {
2543 print
'<td class="nowrap" style="padding-left: 15px">';
2545 'amount' => $langs->transnoentitiesnoconv(
'FixAmount', $langs->transnoentitiesnoconv(
'Deposit')),
2546 'variable' => $langs->transnoentitiesnoconv(
'VarAmountOneLine', $langs->transnoentitiesnoconv(
'Deposit')),
2547 'variablealllines' => $langs->transnoentitiesnoconv(
'VarAmountAllLines')
2549 $typedeposit =
GETPOST(
'typedeposit',
'aZ09');
2550 $valuedeposit =
GETPOST(
'valuedeposit',
'int');
2551 $deposit_percent =
null;
2552 if ($origin ==
'reception') {
2554 if (!isset($objectsrc->origin_object)) {
2555 $objectsrc->fetch_origin();
2557 if (!empty($objectsrc->origin_object)) {
2558 $deposit_percent = $objectsrc->origin_object->deposit_percent;
2560 } elseif (!empty($objectsrc->deposit_percent)) {
2561 $deposit_percent = $objectsrc->deposit_percent;
2563 if (empty($typedeposit) && !empty($deposit_percent)) {
2564 $origin_payment_conditions_deposit_percent =
getDictionaryValue(
'c_payment_term',
'deposit_percent', $objectsrc->cond_reglement_id);
2565 if (!empty($origin_payment_conditions_deposit_percent)) {
2566 $typedeposit =
'variable';
2569 if (empty($valuedeposit) && $typedeposit ==
'variable' && !empty($deposit_percent)) {
2570 $valuedeposit = $deposit_percent;
2572 print $form->selectarray(
'typedeposit', $arraylist, $typedeposit, 0, 0, 0,
'', 1);
2574 print
'<td class="nowrap" style="padding-left: 5px">';
2575 print
'<span class="opacitymedium paddingleft">'.$langs->trans(
"AmountOrPercent").
'</span><input type="text" id="valuedeposit" name="valuedeposit" class="width75 right" value="' . $valuedeposit .
'"/>';
2578 print
'</tr></table>';
2580 print
'</div></div>';
2649 if (empty($origin)) {
2650 if (!empty($societe->id) && $societe->id > 0) {
2654 $facids = $facturestatic->list_qualified_avoir_supplier_invoices($societe->id);
2661 foreach ($facids as $key => $valarray) {
2662 $newinvoice_static->id = $key;
2663 $newinvoice_static->ref = $valarray [
'ref'];
2664 $newinvoice_static->status = $valarray [
'status'];
2665 $newinvoice_static->statut = $valarray [
'status'];
2666 $newinvoice_static->type = $valarray [
'type'];
2667 $newinvoice_static->paid = $valarray [
'paye'];
2668 $newinvoice_static->paye = $valarray [
'paye'];
2670 $optionsav .=
'<option value="'.$key.
'"';
2672 $optionsav .=
' selected';
2675 $optionsav .= $newinvoice_static->ref;
2676 $optionsav .=
' ('.$newinvoice_static->getLibStatut(1, $valarray [
'paymentornot']).
')';
2677 $optionsav .=
'</option>';
2680 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2681 $tmp =
'<input type="radio" id="radio_creditnote" name="type" value="2"'.(GETPOST(
'type') == 2 ?
' checked' :
'');
2683 $tmp .=
' disabled';
2687 print
'<script type="text/javascript">
2688 jQuery(document).ready(function() {
2689 if (! jQuery("#radio_creditnote").is(":checked"))
2691 jQuery("#credit_note_options").hide();
2693 jQuery("#radio_creditnote").click(function() {
2694 jQuery("#credit_note_options").show();
2696 jQuery("#radio_standard, #radio_replacement, #radio_deposit").click(function() {
2697 jQuery("#credit_note_options").hide();
2701 $text = $tmp.
'<label for="radio_creditnote">'.$langs->transnoentities(
"InvoiceAvoirAsk").
'</label> ';
2703 $text .=
'<select class="flat valignmiddle" name="fac_avoir" id="fac_avoir"';
2705 $text .=
' disabled';
2709 $text .=
'<option value="-1"></option>';
2710 $text .= $optionsav;
2712 $text .=
'<option value="-1">'.$langs->trans(
"NoInvoiceToCorrect").
'</option>';
2714 $text .=
'</select>';
2715 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2718 print
'<div id="credit_note_options" class="clearboth">';
2719 print
' <input type="checkbox" name="invoiceAvoirWithLines" id="invoiceAvoirWithLines" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithPaymentRestAmount\').removeAttr(\'checked\'); }" '.(GETPOSTINT(
'invoiceAvoirWithLines') > 0 ?
'checked' :
'').
' /> ';
2720 print
'<label for="invoiceAvoirWithLines">'.$langs->trans(
'invoiceAvoirWithLines').
"</label>";
2721 print
'<br> <input type="checkbox" name="invoiceAvoirWithPaymentRestAmount" id="invoiceAvoirWithPaymentRestAmount" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithLines\').removeAttr(\'checked\'); }" '.(GETPOSTINT(
'invoiceAvoirWithPaymentRestAmount') > 0 ?
'checked' :
'').
' /> ';
2722 print
'<label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans(
'invoiceAvoirWithPaymentRestAmount').
"</label>";
2725 print
'</div></div>';
2728 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2730 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="0" disabled> ';
2732 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="2"> ';
2734 $text = $tmp.$langs->trans(
"InvoiceAvoir").
' ';
2735 $text .=
'<span class="opacitymedium">('.$langs->trans(
"YouMustCreateInvoiceFromSupplierThird").
')</span> ';
2736 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2738 print
'</div></div>'.
"\n";
2749 print
'<tr><td class="fieldrequired">'.$langs->trans(
'InvoiceSubtype').
'</td><td colspan="2">';
2750 print $form->getSelectInvoiceSubtype(
GETPOSTINT(
'subtype'),
'subtype', 1, 0,
'');
2754 if (!empty($societe->id) && $societe->id > 0) {
2756 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
2758 $thirdparty = $societe;
2760 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$societe->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
2761 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2767 print
'<tr><td>'.$langs->trans(
'Label').
'</td><td><input class="minwidth200" name="label" value="'.
dol_escape_htmltag(
GETPOST(
'label')).
'" type="text"></td></tr>';
2771 print
'<tr><td class="fieldrequired">'.$langs->trans(
'DateInvoice').
'</td><td>';
2772 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2773 print $form->selectDate($dateinvoice ? (
int) $dateinvoice :
'',
'', 0, 0, 0,
"add", 1, 1);
2777 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
2778 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
2779 print $form->getSelectConditionsPaiements($cond_reglement_id,
'cond_reglement_id', -1, 1, 0,
'maxwidth200 widthcentpercentminusx');
2783 print
'<tr><td>'.$langs->trans(
'DateMaxPayment').
'</td><td>';
2784 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2785 print $form->selectDate($datedue,
'ech', 0, 0, 0,
"add", 1, 1);
2789 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
2790 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
2791 $form->select_types_paiements((
string) $mode_reglement_id,
'mode_reglement_id',
'DBIT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx');
2796 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
2798 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes((
int) $fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
2806 $langs->load(
'projects');
2807 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td>';
2808 print
img_picto(
'',
'project',
'class="pictofixedwidth"').$formproject->select_projects((!
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ? $societe->id : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx');
2809 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(!empty($soc->id) ? $soc->id : 0).
'&action=create&status=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create&socid='.(!empty($soc->id) ? $soc->id : 0).($fac_recid > 0 ?
'&fac_rec='.$fac_recid :
'')).
'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans(
"AddProject").
'"></span></a>';
2816 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), !empty($objectsrc->label_incoterms) ? $objectsrc->label_incoterms :
'', 1).
'</label></td>';
2817 print
'<td colspan="3" class="maxwidthonsmartphone">';
2818 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2819 print $form->select_incoterms(GETPOSTISSET(
'incoterm_id') ?
GETPOST(
'incoterm_id',
'alphanohtml') : (!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms :
''), GETPOSTISSET(
'location_incoterms') ?
GETPOST(
'location_incoterms',
'alphanohtml') : (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms :
''));
2825 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
2826 print
'<tr><td>' . $langs->trans(
'VATReverseCharge') .
'</td><td>';
2828 if (GETPOSTISSET(
'vat_reverse_charge')) {
2829 $vat_reverse_charge = (
GETPOST(
'vat_reverse_charge',
'alpha') ==
'on' ||
GETPOST(
'vat_reverse_charge',
'alpha') ==
'1') ? 1 : 0;
2830 } elseif ($vat_reverse_charge == 1 || $societe->vat_reverse_charge == 1 || ($societe->country_code !=
'FR' &&
isInEEC($societe) && !empty($societe->tva_intra))) {
2831 $vat_reverse_charge = 1;
2833 $vat_reverse_charge = 0;
2836 print
'<input type="checkbox" name="vat_reverse_charge"'. (!empty($vat_reverse_charge) ?
' checked ' :
'') .
'>';
2843 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
2844 print
'<td class="maxwidthonsmartphone">';
2845 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
2846 $used_currency_code = $currency_code;
2847 if (!
GETPOST(
'changecompany')) {
2848 $used_currency_code = GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code',
'alpha') : $currency_code;
2850 print $form->selectMultiCurrency($used_currency_code,
'multicurrency_code');
2856 if ($fac_recid > 0) {
2857 $dateexample = $dateinvoice;
2858 if (empty($dateexample)) {
2861 $substitutionarray = array(
2862 '__TOTAL_HT__' => $langs->trans(
"AmountHT").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ht).
')',
2863 '__TOTAL_TTC__' => $langs->trans(
"AmountTTC").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ttc).
')',
2864 '__INVOICE_PREVIOUS_MONTH__' => $langs->trans(
"PreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%m').
')',
2865 '__INVOICE_MONTH__' => $langs->trans(
"MonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%m').
')',
2866 '__INVOICE_NEXT_MONTH__' => $langs->trans(
"NextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%m').
')',
2867 '__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans(
"TextPreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%B').
')',
2868 '__INVOICE_MONTH_TEXT__' => $langs->trans(
"TextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%B').
')',
2869 '__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans(
"TextNextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%B').
')',
2870 '__INVOICE_PREVIOUS_YEAR__' => $langs->trans(
"PreviousYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'y'),
'%Y').
')',
2871 '__INVOICE_YEAR__' => $langs->trans(
"YearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%Y').
')',
2872 '__INVOICE_NEXT_YEAR__' => $langs->trans(
"NextYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'y'),
'%Y').
')'
2875 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
2876 foreach ($substitutionarray as $key => $val) {
2877 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
2879 $htmltext .=
'</i>';
2884 $langs->loadLangs(array(
"intracommreport"));
2885 print
'<!-- If module intracomm on -->'.
"\n";
2886 print
'<tr><td>'.$langs->trans(
'IntracommReportTransportMode').
'</td><td>';
2887 $form->selectTransportMode(GETPOSTISSET(
'transport_mode_id') ?
GETPOST(
'transport_mode_id') : $transport_mode_id,
'transport_mode_id');
2891 if (empty($reshook)) {
2892 print
$object->showOptionals($extrafields,
'create');
2897 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
2898 print $form->selectCategories(Categorie::TYPE_SUPPLIER_INVOICE,
'categories', $object);
2903 print
'<tr><td>'.$langs->trans(
'NotePublic').
'</td>';
2905 $doleditor =
new DolEditor(
'note_public', (GETPOSTISSET(
'note_public') ?
GETPOST(
'note_public',
'restricthtml') : $note_public),
'', 80,
'dolibarr_notes',
'In', false, false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
2906 print $doleditor->Create(1);
2912 print
'<tr><td>'.$langs->trans(
'NotePrivate').
'</td>';
2914 $doleditor =
new DolEditor(
'note_private', (GETPOSTISSET(
'note_private') ?
GETPOST(
'note_private',
'restricthtml') : $note_private),
'', 80,
'dolibarr_notes',
'In', false, false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
2915 print $doleditor->Create(1);
2921 if (!empty($objectsrc)) {
2922 print
"\n<!-- ".$classname.
" info -->";
2924 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2925 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2926 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2927 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2928 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2930 $txt = $langs->trans($classname);
2931 if ($classname ==
'CommandeFournisseur') {
2932 $langs->load(
'orders');
2933 $txt = $langs->trans(
"SupplierOrder");
2935 print
'<tr><td>'.$txt.
'</td><td>'.$objectsrc->getNomUrl(1);
2937 $objectsrc->fetchObjectLinked($originid, $origin,
null,
'invoice_supplier');
2939 if (isset($objectsrc->linkedObjects[
'invoice_supplier'])) {
2940 $invoice_supplier = $objectsrc->linkedObjects[
'invoice_supplier'];
2942 $invoice_supplier = [];
2944 '@phan-var-force null|FactureFournisseur[] $invoice_supplier';
2947 if (is_array($invoice_supplier)) {
2948 $cntinvoice = count($invoice_supplier);
2950 if ($cntinvoice >= 1) {
2952 echo
' ('.$langs->trans(
'LatestRelatedBill').end($invoice_supplier)->getNomUrl(1).
')';
2957 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
2958 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
2959 if (
$mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
2960 print
'<tr><td>'.$langs->transcountry(
"AmountLT1",
$mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
2963 if (
$mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
2964 print
'<tr><td>'.$langs->transcountry(
"AmountLT2",
$mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
2966 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
2969 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
2970 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
2971 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2976 $parameters = array();
2977 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2978 print $hookmanager->resPrint;
2986 print $form->buttonsSaveCancel(
"CreateDraft");
2989 if (!empty($objectsrc)) {
2992 $title = $langs->trans(
'ProductsAndServices');
2995 print
'<div class="div-table-responsive-no-min">';
2996 print
'<table class="noborder centpercent">';
2998 $objectsrc->printOriginLinesList(
'', $selectedLines);
3006 if ($id > 0 || !empty($ref)) {
3012 $result =
$object->fetch($id, $ref);
3017 $result =
$object->fetch_thirdparty();
3023 $societe =
$object->thirdparty;
3025 $totalpaid =
$object->getSommePaiement();
3026 $totalcreditnotes =
$object->getSumCreditNotesUsed();
3027 $totaldeposits =
$object->getSumDepositsUsed();
3035 $resteapayer =
price2num(
$object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
3038 $multicurrency_resteapayer = 0;
3040 $multicurrency_totalpaid =
$object->getSommePaiement(1);
3041 $multicurrency_totalcreditnotes =
$object->getSumCreditNotesUsed(1);
3042 $multicurrency_totaldeposits =
$object->getSumDepositsUsed(1);
3043 $multicurrency_resteapayer =
price2num(
$object->multicurrency_total_ttc - $multicurrency_totalpaid - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits,
'MT');
3047 if ($resteapayer == 0 && $multicurrency_resteapayer != 0 &&
$object->multicurrency_code != $conf->currency) {
3048 $resteapayer =
price2num((
float) $multicurrency_resteapayer /
$object->multicurrency_tx,
'MT');
3055 $resteapayeraffiche = $resteapayer;
3058 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
3059 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
3061 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
3062 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
3065 $absolute_discount = $societe->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
3066 $absolute_creditnote = $societe->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
3067 $absolute_discount =
price2num($absolute_discount,
'MT');
3068 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
3072 $objectidnext =
$object->getIdReplacingInvoice();
3075 $titre = $langs->trans(
'SupplierInvoice');
3077 print
dol_get_fiche_head($head,
'card', $titre, -1,
'supplier_invoice', 0,
'',
'', 0,
'', 1);
3082 if ($action ==
'converttoreduc') {
3085 $type_fac =
'ExcessPaid';
3087 $type_fac =
'CreditNote';
3089 $type_fac =
'Deposit';
3091 $text = $langs->trans(
'ConfirmConvertToReducSupplier', strtolower($langs->transnoentities($type_fac)));
3092 $text .=
'<br>'.$langs->trans(
'ConfirmConvertToReducSupplier2');
3093 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id, $langs->trans(
'ConvertToReduc'), $text,
'confirm_converttoreduc',
'',
"yes", 2);
3097 if ($action ==
'clone') {
3099 $formquestion = array(
3100 array(
'type' =>
'text',
'name' =>
'newsupplierref',
'label' => $langs->trans(
"RefSupplierBill"),
'value' => $langs->trans(
"CopyOf").
' '.
$object->ref_supplier),
3101 array(
'type' =>
'date',
'name' =>
'newdate',
'label' => $langs->trans(
"Date"),
'value' =>
dol_now())
3104 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneInvoice',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1, 250);
3108 if ($action ==
'valid') {
3110 if (preg_match(
'/^[\(]?PROV/i',
$object->ref) || empty(
$object->ref)) {
3112 $numref =
$object->getNextNumRef($societe);
3114 $numref = (string)
$object->ref;
3121 $text = $langs->trans(
'ConfirmValidateBill', $numref);
3129 $formquestion = array();
3131 $qualified_for_stock_change = 0;
3133 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3135 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3139 $langs->load(
"stocks");
3140 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3143 $warehouse_array = $warehouse->list_array();
3144 if (count($warehouse_array) == 1) {
3146 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3149 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3151 $formquestion = array(
3152 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3156 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateBill'), $text,
'confirm_valid', $formquestion, 1, 1);
3161 if ($action ==
'edit') {
3162 $formquestion = array();
3164 $qualified_for_stock_change = 0;
3166 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3168 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3171 $langs->load(
"stocks");
3172 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3175 $warehouse_array = $warehouse->list_array();
3176 if (count($warehouse_array) == 1) {
3178 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3181 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3183 $formquestion = array(
3184 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3187 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'UnvalidateBill'), $langs->trans(
'ConfirmUnvalidateBill',
$object->ref),
'confirm_edit', $formquestion, 1, 1);
3191 if ($action ==
'paid' && ($resteapayer <= 0 || (
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') && $resteapayer ==
$object->total_ttc))) {
3192 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidBill',
$object->ref),
'confirm_paid',
'', 0, 1);
3195 if ($action ==
'paid' && $resteapayer > 0 && (!
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') || $resteapayer !=
$object->total_ttc)) {
3199 $close[$i][
'code'] =
'discount_vat';
3201 $close[$i][
'code'] =
'badsupplier';
3203 $close[$i][
'code'] =
'other';
3207 $close[$i][
'label'] = $langs->trans(
"HelpEscompte").
'<br><br>'.$langs->trans(
"ConfirmClassifyPaidPartiallyReasonDiscountVatDesc");
3209 $close[$i][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3211 $close[$i][
'label'] = $langs->trans(
"Other");
3215 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonDiscount", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3217 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadCustomer", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3219 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"Other"), $close[$i][
'label'], 1);
3222 $arrayreasons = array();
3223 foreach ($close as $key => $val) {
3224 $arrayreasons[$close[$key][
'code']] = $close[$key][
'reason'];
3228 $formquestion = array(
'text' => $langs->trans(
"ConfirmClassifyPaidPartiallyQuestion"), 0 => array(
'type' =>
'radio',
'name' =>
'close_code',
'label' => $langs->trans(
"Reason"),
'values' => $arrayreasons), 1 => array(
'type' =>
'text',
'name' =>
'close_note',
'label' => $langs->trans(
"Comment"),
'value' =>
'',
'morecss' =>
'minwidth300'));
3230 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?facid='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidPartially',
$object->ref),
'confirm_paid_partially', $formquestion,
"yes", 1, 310);
3234 if ($action ==
'canceled') {
3236 $close[1][
'code'] =
'badsupplier';
3237 $close[2][
'code'] =
'abandon';
3239 $close[1][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3240 $close[2][
'label'] = $langs->trans(
"ConfirmClassifyAbandonReasonOtherDesc");
3242 $close[1][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadSupplier",
$object->ref), $close[1][
'label'], 1);
3243 $close[2][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyAbandonReasonOther"), $close[2][
'label'], 1);
3245 $arrayreasons[$close[1][
'code']] = $close[1][
'reason'];
3246 $arrayreasons[$close[2][
'code']] = $close[2][
'reason'];
3249 $formquestion = array(
'text' => $langs->trans(
"ConfirmCancelBillQuestion"), 0 => array(
'type' =>
'radio',
'name' =>
'close_code',
'label' => $langs->trans(
"Reason"),
'values' => $arrayreasons), 1 => array(
'type' =>
'text',
'name' =>
'close_note',
'label' => $langs->trans(
"Comment"),
'value' =>
'',
'morecss' =>
'minwidth300'));
3251 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'CancelBill'), $langs->trans(
'ConfirmCancelBill',
$object->ref),
'confirm_canceled', $formquestion,
"yes", 1, 280);
3255 if ($action ==
'delete') {
3256 $formquestion = array();
3258 $qualified_for_stock_change = 0;
3260 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3262 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3266 $langs->load(
"stocks");
3267 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3270 $warehouse_array = $warehouse->list_array();
3272 $selectwarehouse =
'<span class="questionrevertstock hidden">';
3273 if (count($warehouse_array) == 1) {
3275 $selectwarehouse .=
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3278 $selectwarehouse .= $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3280 $selectwarehouse .=
'</span>';
3282 $selectyesno = array(0 => $langs->trans(
'No'), 1 => $langs->trans(
'Yes'));
3284 print
'<script type="text/javascript">
3285 $(document).ready(function() {
3286 $("#revertstock").change(function() {
3287 if(this.value > 0) {
3288 $(".questionrevertstock").removeClass("hidden");
3290 $(".questionrevertstock").addClass("hidden");
3296 $formquestion = array(
3297 array(
'type' =>
'select',
'name' =>
'revertstock',
'label' => $langs->trans(
"RevertProductsToStock"),
'select_show_empty' => 0,
'values' => $selectyesno),
3298 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $selectwarehouse,
'tdclass' =>
'questionrevertstock hidden')
3302 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteBill'), $langs->trans(
'ConfirmDeleteBill'),
'confirm_delete', $formquestion, 1, 1);
3304 if ($action ==
'deletepayment') {
3305 $payment_id =
GETPOST(
'paiement_id');
3306 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&paiement_id='.$payment_id, $langs->trans(
'DeletePayment'), $langs->trans(
'ConfirmDeletePayment'),
'confirm_delete_paiement',
'', 0, 1);
3310 if ($action ==
'ask_deleteline') {
3311 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
3314 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
3315 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
3316 if (empty($reshook)) {
3317 $formconfirm .= $hookmanager->resPrint;
3318 } elseif ($reshook > 0) {
3319 $formconfirm = $hookmanager->resPrint;
3327 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
3329 $morehtmlref =
'<div class="refidno">';
3331 $morehtmlref .= $form->editfieldkey(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier, $object, (
int) $usercancreate,
'string',
'', 0, 1);
3332 $morehtmlref .= $form->editfieldval(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier, $object, $usercancreate,
'string',
'',
null,
null,
'', 1);
3334 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1,
'supplier');
3336 $morehtmlref .=
' <div class="inline-block valignmiddle">(<a class="valignmiddle" href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.((int)
$object->thirdparty->id).
'&search_company='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherBills").
'</a>)</div>';
3340 $langs->load(
"projects");
3341 $morehtmlref .=
'<br>';
3342 if ($permissiontoadd) {
3343 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
3344 if ($action !=
'classify') {
3345 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.((int)
$object->id).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
3347 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (!
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ?
$object->socid : -1), (string)
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
3349 if (!empty(
$object->fk_project)) {
3351 $proj->fetch(
$object->fk_project);
3352 $morehtmlref .= $proj->getNomUrl(1);
3354 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
3359 $morehtmlref .=
'</div>';
3361 $object->totalpaid = $totalpaid;
3363 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
3366 $parameters = array();
3368 $reshook = $hookmanager->executeHooks(
'tabContentViewSupplierInvoice', $parameters, $object, $action);
3369 if (empty($reshook)) {
3370 print
'<div class="fichecenter">';
3371 print
'<div class="fichehalfleft">';
3372 print
'<div class="underbanner clearboth"></div>';
3374 print
'<table class="border tableforfield centpercent">';
3377 print
'<tr><td>'.$langs->trans(
'Type').
'</td><td>';
3378 print
'<span class="badgeneutral">';
3382 print
' '.$object->getSubtypeLabel(
'facture_fourn');
3386 $facreplaced->fetch(
$object->fk_facture_source);
3387 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
'</span>';
3390 if (
$object->fk_facture_source > 0) {
3392 $facusing->fetch(
$object->fk_facture_source);
3393 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
'</span>';
3395 $langs->load(
"errors");
3396 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"WarningCorrectedInvoiceNotFound").
'</span>';
3401 $object->getListIdAvoirFromInvoice();
3403 if (!empty(
$object->creditnote_ids)) {
3404 $invoicecredits = array();
3405 foreach (
$object->creditnote_ids as $invoiceid) {
3407 $creditnote->fetch($invoiceid);
3408 $invoicecredits[] = $creditnote->getNomUrl(1);
3410 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"InvoiceHasAvoir") . (count($invoicecredits) ?
' ' :
'') . implode(
',', $invoicecredits);
3413 if (isset($objectidnext) && $objectidnext > 0) {
3416 $facthatreplace->fetch($objectidnext);
3417 print
' <span class="opacitymediumbycolor paddingleft">'.str_replace(
'{s1}', $facthatreplace->getNomUrl(1), $langs->transnoentities(
"ReplacedByInvoice",
'{s1}')).
'</span>';
3421 $result = $discount->fetch(0, 0,
$object->id);
3423 print
' <span class="opacitymediumbycolor paddingleft">';
3424 $s = $langs->trans(
"CreditNoteConvertedIntoDiscount",
'{s1}',
'{s2}');
3425 $s = str_replace(
'{s1}',
$object->getLibType(1), $s);
3426 $s = str_replace(
'{s2}', $discount->getNomUrl(1,
'discount'), $s);
3428 print
'</span><br>';
3432 if (
$object->fk_fac_rec_source > 0) {
3434 $result = $tmptemplate->fetch(
$object->fk_fac_rec_source);
3436 print
' <span class="opacitymediumbycolor paddingleft">';
3437 $link =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.$tmptemplate->id.
'">'.
dol_escape_htmltag($tmptemplate->title).
'</a>';
3438 $s = $langs->transnoentities(
"GeneratedFromSupplierTemplate", $link);
3448 print
'<!-- Discounts -->'.
"\n";
3449 print
'<tr><td>'.$langs->trans(
'DiscountStillRemaining');
3452 $thirdparty = $societe;
3454 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
3460 print
'<td>'.$form->editfieldkey(
"Label",
'label',
$object->label, $object, (
int) $usercancreate).
'</td>';
3461 print
'<td>'.$form->editfieldval(
"Label",
'label',
$object->label, $object, $usercancreate).
'</td>';
3469 print $form->editfieldkey(
"DateInvoice",
'datef', (
string)
$object->date,
$object, (int) $form_permission,
'datepicker');
3470 print
'</td><td colspan="3">';
3471 print $form->editfieldval(
"Date",
'datef',
$object->date, $object, $form_permission,
'datepicker');
3475 $langs->load(
'bills');
3476 print
'<tr><td class="nowrap">';
3477 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3478 print $langs->trans(
'PaymentConditions');
3480 if ($action !=
'editconditions' && $form_permission) {
3481 print
'<td class="right"><a class="editfielda reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=editconditions&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->trans(
'SetConditions'), 1).
'</a></td>';
3483 print
'</tr></table>';
3485 if ($action ==
'editconditions') {
3486 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id');
3488 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'none');
3495 print $form->editfieldkey(
"DateMaxPayment",
'date_lim_reglement', (
string)
$object->date_echeance, $object, (
int) $form_permission,
'datepicker');
3497 print $form->editfieldval(
"DateMaxPayment",
'date_lim_reglement',
$object->date_echeance, $object, $form_permission,
'datepicker');
3498 if ($action !=
'editdate_lim_reglement' &&
$object->hasDelay()) {
3504 $langs->load(
'bills');
3505 print
'<tr><td class="nowrap">';
3506 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3507 print $langs->trans(
'PaymentMode');
3509 if ($action !=
'editmode' && $form_permission) {
3510 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmode&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->trans(
'SetMode'), 1).
'</a></td>';
3512 print
'</tr></table>';
3514 if ($action ==
'editmode') {
3515 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
3517 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
3523 print
'<tr><td class="nowrap">';
3524 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3525 print $langs->trans(
'BankAccount');
3527 if ($action !=
'editbankaccount' && $usercancreate) {
3528 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>';
3530 print
'</tr></table>';
3532 if ($action ==
'editbankaccount') {
3533 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
3535 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'none');
3543 print
'<tr><td class="nowrap">';
3544 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3545 print $langs->trans(
'VATReverseCharge');
3547 if ($action !=
'editvatreversecharge' && $usercancreate) {
3548 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editvatreversecharge&id='.
$object->id.
'">'.
img_edit($langs->trans(
'SetVATReverseCharge'), 1).
'</a></td>';
3550 print
'</tr></table>';
3552 if ($action ==
'editvatreversecharge') {
3553 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
3554 print
'<input type="hidden" name="action" value="setvatreversecharge">';
3555 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3557 print
'<input type="checkbox" name="vat_reverse_charge"' . (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
'>';
3559 print
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
3562 print
'<input type="checkbox" name="vat_reverse_charge"'. (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
' disabled>';
3570 print
'<table width="100%" class="nobordernopadding"><tr><td>';
3571 print $langs->trans(
'IncotermLabel');
3572 print
'<td><td class="right">';
3573 if ($usercancreate) {
3574 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.
$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit().
'</a>';
3578 print
'</td></tr></table>';
3581 if ($action !=
'editincoterm') {
3582 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3584 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
3591 $langs->loadLangs(array(
"intracommreport"));
3592 print
'<!-- If module intracomm on -->'.
"\n";
3594 print
'<table class="nobordernopadding centpercent"><tr><td>';
3595 print $langs->trans(
'IntracommReportTransportMode');
3597 if ($action !=
'edittransportmode' && ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"))) {
3598 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edittransportmode&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit().
'</a></td>';
3600 print
'</tr></table>';
3603 if ($action ==
'edittransportmode') {
3604 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->transport_mode_id,
'transport_mode_id', 1, 1);
3606 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->transport_mode_id,
'none');
3614 print
'<table class="nobordernopadding centpercent"><tr><td>';
3615 print $langs->trans(
"Categories");
3616 print
'<td><td class="right">';
3617 if ($usercancreate) {
3618 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.
$object->id.
'&action=edittags&token='.
newToken().
'">'.
img_edit().
'</a>';
3622 print
'</td></tr></table>';
3625 if ($action ==
'edittags') {
3626 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?facid='.
$object->id.
'">';
3627 print
'<input type="hidden" name="action" value="settags">';
3628 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3629 print $form->selectCategories(Categorie::TYPE_SUPPLIER_INVOICE,
'categories', $object);
3630 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
3633 print $form->showCategories(
$object->id, Categorie::TYPE_SUPPLIER_INVOICE, 1);
3641 if (
$object->status != $object::STATUS_DRAFT) {
3645 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3650 print
'<div class="fichehalfright">';
3651 print
'<div class="underbanner clearboth"></div>';
3653 print
'<table class="border tableforfield centpercent">';
3655 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
3658 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
3659 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3661 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3666 print
'<td>' . $langs->trans(
'AmountVAT') .
'</td>';
3667 print
'<td class="nowrap amountcard right">';
3668 if (
GETPOST(
'calculationrule')) {
3669 $calculationrule =
GETPOST(
'calculationrule',
'alpha');
3671 $calculationrule = (!
getDolGlobalString(
'MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND_SUPPLIER') ?
'totalofround' :
'roundoftotal');
3673 if ($calculationrule ==
'totalofround') {
3674 $calculationrulenum = 1;
3676 $calculationrulenum = 2;
3679 if (
$object->getVentilExportCompta() == 0) {
3680 $s =
'<span class="hideonsmartphone opacitymedium">' . $langs->trans(
"ReCalculate") .
' </span>';
3681 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&token='.newToken().
'&calculationrule=totalofround">' . $langs->trans(
"Mode1") .
'</a>';
3683 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&token='.newToken().
'&calculationrule=roundoftotal">' . ($conf->dol_optimize_smallscreen ?
"2" : $langs->trans(
"Mode2")) .
'</a>';
3684 print
'<div class="inline-block">';
3685 print $form->textwithtooltip($s, $langs->trans(
"CalculationRuleDesc", $calculationrulenum) .
'<br>' . $langs->trans(
"CalculationRuleDescSupplier"), 2, 1,
img_picto(
'',
'help',
'class="paddingleft paddingright"'),
'', 3,
'', 0,
'recalculate');
3686 print
' ';
3689 print
'<span class="nowraponall">'.price(
$object->total_tva, 1, $langs, 0, -1, -1, $conf->currency).
'</span>';
3692 print
'<td class="nowraponall amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3696 if ($societe->localtax1_assuj ==
"1") {
3698 print
'<td>' . $langs->transcountry(
"AmountLT1", $societe->country_code) .
'</td>';
3699 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 1, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3702 if ($societe->localtax2_assuj ==
"1") {
3704 print
'<td>' . $langs->transcountry(
"AmountLT2", $societe->country_code) .
'</td>';
3705 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 1, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3710 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
3711 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ttc, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3713 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3746 if ($societe->localtax1_assuj ==
"1") {
3749 if ($societe->localtax2_assuj ==
"1") {
3753 $sql =
'SELECT p.datep as dp, p.ref, p.num_paiement as num_payment, p.rowid, p.fk_bank,';
3754 $sql .=
' c.id as payment_type, c.code as payment_code,';
3755 $sql .=
' pf.amount,';
3756 $sql .=
' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal';
3757 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn as p';
3758 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
3759 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
3760 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id';
3761 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid';
3762 $sql .=
' WHERE pf.fk_facturefourn = '.((int)
$object->id);
3763 $sql .=
' ORDER BY p.datep, p.tms';
3765 $result = $db->query($sql);
3767 $num = $db->num_rows($result);
3770 print
'<div class="div-table-responsive-no-min">';
3771 print
'<table class="noborder paymenttable centpercent">';
3772 print
'<tr class="liste_titre">';
3774 print
'<td><span class="hideonsmartphone">'.$langs->trans(
'Date').
'</span></td>';
3775 print
'<td><span class="hideonsmartphone">'.$langs->trans(
'Type').
'</span></td>';
3777 print
'<td class="right">'.$langs->trans(
'BankAccount').
'</td>';
3782 print
'<td class="right">'.$langs->trans(
'Amount').
'</td>';
3787 $objp = $db->fetch_object($result);
3789 $paymentstatic->id = $objp->rowid;
3790 $paymentstatic->datepaye = $db->jdate($objp->dp);
3791 $paymentstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
3792 $paymentstatic->num_payment = $objp->num_payment;
3794 $paymentstatic->paiementcode = $objp->payment_code;
3795 $paymentstatic->type_code = $objp->payment_code;
3796 $paymentstatic->type_label = $objp->payment_type;
3798 print
'<tr class="oddeven">';
3799 print
'<td class="nowraponall">';
3800 print $paymentstatic->getNomUrl(1);
3802 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
'</td>';
3803 $s = $form->form_modes_reglement(
'', $objp->payment_type,
'none',
'', 1, 0,
'', 1).
' '.$objp->num_payment;
3804 print
'<td class="tdoverflowmax125" title="'.dol_escape_htmltag($s).
'">';
3808 $bankaccountstatic->id = $objp->baid;
3809 $bankaccountstatic->ref = $objp->baref;
3810 $bankaccountstatic->label = $objp->baref;
3811 $bankaccountstatic->number = $objp->banumber;
3814 $bankaccountstatic->account_number = $objp->account_number;
3817 $accountingjournal->fetch($objp->fk_accountancy_journal);
3818 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
3821 print
'<td class="right nowraponall">';
3822 if ($objp->baid > 0) {
3823 print $bankaccountstatic->getNomUrl(1,
'transactions');
3828 print
'<td class="center">';
3830 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deletepayment&token='.
newToken().
'&paiement_id='.$objp->rowid.
'">';
3836 print
'<td class="right">'.price($sign * $objp->amount).
'</td>';
3838 $totalpaid += $objp->amount;
3842 print
'<tr class="oddeven"><td colspan="'.$nbcols.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td>';
3868 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
3869 print
'<span class="opacitymedium">';
3871 print $langs->trans(
'AlreadyPaidNoCreditNotesNoDeposits');
3873 print $langs->trans(
'AlreadyPaid');
3878 print
'<td class="right"'.(($totalpaid > 0) ?
' class="amountalreadypaid"' :
'').
'>'.
price($totalpaid).
'</td>';
3882 $resteapayeraffiche = $resteapayer;
3884 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
3887 $creditnoteamount = 0;
3890 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
3891 $sql .=
" re.description, re.fk_invoice_supplier_source";
3892 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
3893 $sql .=
" WHERE fk_invoice_supplier = ".((int)
$object->id);
3894 $resql = $db->query($sql);
3896 $num = $db->num_rows($resql);
3900 $obj = $db->fetch_object($resql);
3901 $invoice->fetch($obj->fk_invoice_supplier_source);
3902 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3904 print $langs->trans(
"CreditNote").
' ';
3907 print $langs->trans(
"Deposit").
' ';
3909 print $invoice->getNomUrl(0);
3912 print
'<td class="right">';
3913 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=unlinkdiscount&discountid='.$obj->rowid.
'">';
3914 print
img_picto($langs->transnoentitiesnoconv(
"RemoveDiscount"),
'unlink');
3918 print
'<td class="right">'.price($obj->amount_ttc).
'</td>';
3922 $creditnoteamount += $obj->amount_ttc;
3925 $depositamount += $obj->amount_ttc;
3934 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right nowrap">';
3935 print
'<span class="opacitymedium">';
3936 print $form->textwithpicto($langs->trans(
"Discount"), $langs->trans(
"HelpEscompte"), - 1);
3940 print
'<td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td>';
3942 $resteapayeraffiche = 0;
3943 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3947 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right nowrap">';
3948 print
'<span class="opacitymedium">';
3949 print $form->textwithpicto($langs->trans(
"Abandoned"), $langs->trans(
"HelpAbandonBadCustomer"), - 1);
3953 print
'<td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td>';
3956 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3960 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right nowrap">';
3961 print
'<span class="opacitymedium">';
3962 print $form->textwithpicto($langs->trans(
"ProductReturned"), $langs->trans(
"HelpAbandonProductReturned"), - 1);
3966 print
'<td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td>';
3968 $resteapayeraffiche = 0;
3969 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3973 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right nowrap">';
3974 $text = $langs->trans(
"HelpAbandonOther");
3976 $text .=
'<br><br><b>'.$langs->trans(
"Reason").
'</b>:'.
$object->close_note;
3978 print
'<span class="opacitymedium">';
3980 print $form->textwithpicto($langs->trans(
"Abandoned"), $text, - 1);
3984 print
'<td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td>';
3986 $resteapayeraffiche = 0;
3987 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3991 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
3992 print
'<span class="opacitymedium">';
3993 print $langs->trans(
"Billed");
3997 print
'<td class="right">'.price(
$object->total_ttc).
'</td>';
4001 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4002 print
'<span class="opacitymedium">';
4003 print $langs->trans(
'RemainderToPay');
4004 if ($resteapayeraffiche < 0) {
4005 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
4010 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayeraffiche).
'</td>';
4015 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4016 print
'<span class="opacitymedium">';
4017 print $langs->trans(
'RemainderToPayMulticurrency');
4018 if ($resteapayeraffiche < 0) {
4019 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
4024 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopaynoresize' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price(
price2num($multicurrency_resteapayer,
'MT'), 0, $langs, 1, -1, -1,
$object->multicurrency_code).
'</td>';
4028 $cssforamountpaymentcomplete =
'amountpaymentneutral';
4031 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4032 print $langs->trans(
'AlreadyPaidBack');
4035 print
'<td class="right">'.price($sign * $totalpaid).
'</td>';
4039 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">'.$langs->trans(
"Billed").
'</td>';
4041 print
'<td class="right">'.price($sign *
$object->total_ttc).
'</td>';
4045 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4046 print
'<span class="opacitymedium">';
4047 print $langs->trans(
'RemainderToPayBack');
4048 if ($resteapayeraffiche > 0) {
4049 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
4054 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($sign * $resteapayeraffiche).
'</td>';
4059 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4060 print
'<span class="opacitymedium">';
4061 print $langs->trans(
'RemainderToPayBackMulticurrency');
4062 if ($resteapayeraffiche > 0) {
4063 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
4068 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopaynoresize' : (
' '.$cssforamountpaymentcomplete)).
'">'.(!empty(
$object->multicurrency_code) ?
$object->multicurrency_code : $conf->currency).
' '.
price(
price2num($sign *
$object->multicurrency_tx * $resteapayeraffiche,
'MT')).
'</td>';
4084 print
'<div class="clearboth"></div><br>';
4087 $blocname =
'contacts';
4088 $title = $langs->trans(
'ContactsAddresses');
4089 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
4094 $blocname =
'notes';
4095 $title = $langs->trans(
'Notes');
4096 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
4103 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
4104 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4105 print
'<input type="hidden" name="action" value="'.(($action !=
'editline') ?
'addline' :
'updateline').
'">';
4106 print
'<input type="hidden" name="mode" value="">';
4107 print
'<input type="hidden" name="page_y" value="">';
4108 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
4109 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
4110 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
4113 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
4116 print
'<div class="div-table-responsive-no-min">';
4117 print
'<table id="tablelines" class="noborder noshadow centpercent">';
4119 global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax;
4122 $inputalsopricewithtax = 1;
4123 $senderissupplier = 2;
4124 if (
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY')) {
4125 $senderissupplier =
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY');
4130 $object->printObjectLines($action, $societe,
$mysoc, $lineid, 1);
4137 if ($action !=
'editline') {
4140 $parameters = array();
4141 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
4145 if (empty($reshook)) {
4159 if ($action !=
'presend') {
4162 print
'<div class="tabsAction">';
4164 $parameters = array();
4165 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
4167 if (empty($reshook)) {
4171 $ventilExportCompta =
$object->getVentilExportCompta();
4173 if ($ventilExportCompta == 0) {
4174 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
'Modify').
'</a>';
4176 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseDispatchedInBookkeeping").
'">'.$langs->trans(
'Modify').
'</span>';
4181 $result = $discount->fetch(0, 0,
$object->id);
4188 if (!$objectidnext &&
$object->close_code !=
'replaced' && $usercancreate) {
4189 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=reopen&token='.
newToken().
'">'.$langs->trans(
'ReOpen').
'</a>';
4191 if ($usercancreate) {
4192 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseReplacedInvoice").
'">'.$langs->trans(
'ReOpen').
'</span>';
4194 print
'<span class="butActionRefused classfortooltip">'.$langs->trans(
'ReOpen').
'</span>';
4204 if ($usercanvalidate) {
4205 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=valid&token='.
newToken().
'"';
4206 print
'>'.$langs->trans(
'Validate').
'</a>';
4208 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'"';
4209 print
'>'.$langs->trans(
'Validate').
'</a>';
4215 if (empty($user->socid)) {
4218 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'presend',
'mode' =>
'init'],
true).
'#formmailbeforetitle',
'');
4227 $langs->load(
"withdrawals");
4228 if ($resteapayer > 0) {
4229 if ($usercancreatecreditransfer) {
4230 if (!$objectidnext &&
$object->close_code !=
'replaced') {
4231 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/compta/facture/prelevement.php?facid='.
$object->id.
'&type=bank-transfer" title="'.
dol_escape_htmltag($langs->trans(
"MakeBankTransferOrder")).
'">'.$langs->trans(
"MakeBankTransferOrder").
'</a>';
4233 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseReplacedInvoice").
'">'.$langs->trans(
'MakeBankTransferOrder').
'</span>';
4245 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/facture/paiement.php?facid='.
$object->id.
'&action=create'.(
$object->fk_account > 0 ?
'&accountid='.$object->fk_account :
'').
'">'.$langs->trans(
'DoPayment').
'</a>';
4252 if ($resteapayer == 0) {
4253 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseRemainderToPayIsZero").
'">'.$langs->trans(
'DoPaymentBack').
'</span>';
4255 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/facture/paiement.php?facid='.
$object->id.
'&action=create&accountid='.
$object->fk_account.
'">'.$langs->trans(
'DoPaymentBack').
'</a>';
4261 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.
newToken().
'">'.$langs->trans(
'ConvertExcessPaidToReduc').
'</a>';
4265 && (
getDolGlobalString(
'SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED') ||
$object->getSommePaiement() == 0)
4267 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.
newToken().
'" title="'.
dol_escape_htmltag($langs->trans(
"ConfirmConvertToReducSupplier2")).
'">'.$langs->trans(
'ConvertToReduc').
'</a>';
4271 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.
newToken().
'">'.$langs->trans(
'ConvertToReduc').
'</a>';
4282 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=paid&token='.
newToken().
'">'.$langs->trans(
'ClassifyPaid').
'</a>';
4287 if ($totalpaid > 0 || $totalcreditnotes > 0) {
4289 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=paid&token='.
newToken().
'">'.$langs->trans(
'ClassifyPaidPartially').
'</a>';
4292 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=canceled">'.$langs->trans(
'ClassifyCanceled').
'</a>';
4304 if (!$objectidnext) {
4305 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?socid='.
$object->socid.
'&fac_avoir='.
$object->id.
'&action=create&type=2'.(
$object->fk_project > 0 ?
'&projectid='.$object->fk_project :
'').
'">'.$langs->trans(
"CreateCreditNote").
'</a>';
4310 if ($action !=
'edit' && $usercancreate) {
4311 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=clone&socid='.
$object->socid.
'&token='.
newToken().
'">'.$langs->trans(
'ToClone').
'</a>';
4316 if (!$objectidnext && count(
$object->lines) > 0) {
4317 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.
$object->id.
'&action=create">'.$langs->trans(
"ChangeIntoRepeatableInvoice").
'</a>';
4322 if ($action !=
'confirm_edit' && $usercandelete) {
4323 $isErasable =
$object->is_erasable();
4325 $enableDelete =
false;
4327 $params = (empty($conf->use_javascript_ajax) ? array() : array(
'attr' => array(
'class' =>
'reposition')));
4329 if ($isErasable == -4) {
4330 $htmltooltip = $langs->trans(
"DisabledBecausePayments");
4331 } elseif ($isErasable == -3) {
4332 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastSituationInvoice");
4333 } elseif ($isErasable == -2) {
4334 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastInvoice");
4335 } elseif ($isErasable == -1) {
4336 $htmltooltip = $langs->trans(
"DisabledBecauseDispatchedInBookkeeping");
4337 } elseif ($isErasable <= 0) {
4338 $htmltooltip = $langs->trans(
"DisabledBecauseNotErasable");
4340 $enableDelete =
true;
4343 print
dolGetButtonAction($htmltooltip, $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(), (
string)
$object->id, $enableDelete, $params);
4347 if ($action !=
'confirm_edit') {
4348 print
'<div class="fichecenter"><div class="fichehalfleft">';
4354 $subdir =
get_exdir(
$object->id, 2, 0, 0, $object,
'invoice_supplier').$ref;
4355 $filedir = $conf->fournisseur->facture->dir_output.
'/'.$subdir;
4356 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.
$object->id;
4357 $genallowed = $usercanread;
4358 $delallowed = $usercancreate;
4362 print $formfile->showdocuments(
'facture_fournisseur', $subdir, $filedir, $urlsource, (
int) $genallowed, (
int) $delallowed, $modelpdf, $genifempty, 0, 0, 40, 0,
'',
'',
'', $societe->default_lang);
4363 $somethingshown = $formfile->numoffiles;
4366 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'invoice_supplier'), 1);
4367 $linktoelem = $tmparray[
'linktoelem'];
4368 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
4369 print $htmltoenteralink;
4371 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
4373 print
'</div><div class="fichehalfright">';
4376 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
4378 $somethingshown = $formactions->showactions($object,
'invoice_supplier', $socid, 1,
'listaction'.($genallowed ?
'largetitle' :
''));
4380 print
'</div></div>';
4386 if (
GETPOST(
'modelselected')) {
4387 $action =
'presend';
4391 $modelmail =
'invoice_supplier_send';
4392 $defaulttopic =
'SendBillRef';
4393 $diroutput = $conf->fournisseur->facture->dir_output;
4394 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
4395 $trackid =
'sinv'.$object->id;
4397 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage bank accounts.
Class to manage accounting journals.
const TYPE_PROFORMA
Proforma invoice.
const TYPE_SITUATION
Situation invoice.
Class to manage absolute discounts.
Class to manage a WYSIWYG editor.
Class to manage warehouses.
Class to manage suppliers invoices.
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
const TYPE_REPLACEMENT
Replacement invoice.
const STATUS_VALIDATED
Validated (need to be paid)
const TYPE_STANDARD
Standard invoice.
const STATUS_ABANDONED
Classified abandoned and no payment done.
const STATUS_CLOSED
Classified paid.
Class to manage invoice templates.
Class to manage payments for supplier invoices.
Class ProductCombination Used to represent the relation between a product and one of its variants.
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.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
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.
facturefourn_prepare_head(FactureFournisseur $object)
Prepare array with list of tabs.
dol_now($mode='gmt')
Return date for now.
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
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.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolBuildUrl($url, $params=[], $addtoken=false)
Return path of url.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
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...
dol_htmloutput_events($disabledoutputofmessages=0)
Print formatted messages to output (Used to show messages on html output).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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...
getDictionaryValue($tablename, $field, $id, $checkentity=false, $rowidfield='rowid')
Return the value of a filed into a dictionary for the record $id.
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular VAT rate, when selling a product with vat $vatrate,...
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
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...
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.