39require
'../../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
44require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture-rec.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
52if (isModEnabled(
"product")) {
53 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
56if (isModEnabled(
'project')) {
57 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
58 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
61if (isModEnabled(
'variants')) {
62 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
64if (isModEnabled(
'accounting')) {
65 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
77$langs->loadLangs(array(
'bills',
'compta',
'suppliers',
'companies',
'products',
'banks',
'admin'));
78if (isModEnabled(
'incoterm')) {
79 $langs->load(
'incoterm');
84$action =
GETPOST(
'action',
'aZ09');
87$cancel =
GETPOST(
'cancel',
'alpha');
88$backtopage =
GETPOST(
'backtopage',
'alpha');
89$backtopageforcancel =
'';
93$origin =
GETPOST(
'origin',
'alpha');
104$hookmanager->initHooks(array(
'invoicesuppliercard',
'globalcard'));
110$extrafields->fetch_name_optionals_label(
$object->table_element);
113if ($id > 0 || !empty($ref)) {
114 $ret =
$object->fetch($id, $ref);
118 $ret =
$object->fetch_thirdparty();
126if (!empty($user->socid)) {
127 $socid = $user->socid;
131$result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture',
'fk_soc',
'rowid', $isdraft);
134$usercanread = ($user->hasRight(
"fournisseur",
"facture",
"lire") || $user->hasRight(
"supplier_invoice",
"lire"));
135$usercancreate = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
136$usercandelete = (($user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"supprimer")) || ($usercancreate &&
$object->is_erasable() == 1));
137$usercancreatecontract = $user->hasRight(
"contrat",
"creer");
140$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"validate")));
141$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"send"));
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);
238 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
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);
256 if (isModEnabled(
'category')) {
257 $categories =
GETPOST(
'categories',
'array');
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);
309 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
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');
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';
1150 $classname = ucfirst($subelement);
1151 if ($classname ==
'Fournisseur.commande') {
1152 $classname =
'CommandeFournisseur';
1154 $objectsrc =
new $classname($db);
1155 $objectsrc->fetch($originid);
1156 $objectsrc->fetch_thirdparty();
1163 if (
$object->origin ==
'reception') {
1164 $objectsrc->fetchObjectLinked();
1166 if (count($objectsrc->linkedObjectsIds[
'order_supplier']) > 0) {
1167 foreach ($objectsrc->linkedObjectsIds[
'order_supplier'] as $key => $value) {
1168 $object->linkedObjectsIds[
'order_supplier'] = $value;
1178 $classname = ucfirst($subelement);
1179 if ($classname ==
'Fournisseur.commande') {
1180 $classname =
'CommandeFournisseur';
1182 $srcobject =
new $classname($db);
1184 $result = $srcobject->fetch(
GETPOSTINT(
'originid'));
1187 $typeamount =
GETPOST(
'typedeposit',
'alpha');
1192 $amountdeposit = array();
1194 if ($typeamount ==
'amount') {
1195 $amount = $valuedeposit;
1197 $amount = $srcobject->total_ttc * ((float) $valuedeposit / 100);
1200 $TTotalByTva = array();
1201 foreach ($srcobject->lines as &$line) {
1202 if (!empty($line->special_code)) {
1205 $TTotalByTva[$line->tva_tx] += $line->total_ttc;
1207 '@phan-var-force array<string,float> $TTotalByTva';
1209 $amount_ttc_diff = 0.;
1210 foreach ($TTotalByTva as $tva => &$total) {
1211 $coef = $total / $srcobject->total_ttc;
1212 $am = $amount * $coef;
1213 $amount_ttc_diff += $am;
1214 $amountdeposit[$tva] += $am / (1 + (float) $tva / 100);
1217 if ($typeamount ==
'amount') {
1218 $amountdeposit[0] = $valuedeposit;
1219 } elseif ($typeamount ==
'variable') {
1222 $lines = $srcobject->lines;
1223 $numlines = count($lines);
1224 for ($i = 0; $i < $numlines; $i++) {
1226 if (empty($lines[$i]->qty)) {
1229 if (!empty($lines[$i]->special_code)) {
1233 $totalamount += $lines[$i]->total_ht;
1234 $tva_tx = $lines[$i]->tva_tx;
1235 $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * (float) $valuedeposit) / 100;
1239 if ($totalamount == 0) {
1240 $amountdeposit[0] = 0;
1245 $amountdeposit[0] = 0;
1249 $amount_ttc_diff = array_key_exists(0, $amountdeposit) ? $amountdeposit[0] : 0;
1252 foreach ($amountdeposit as $tva => $amount) {
1253 if (empty($amount)) {
1258 'amount' =>
'FixAmount',
1259 'variable' =>
'VarAmount'
1261 $descline =
'(DEPOSIT)';
1263 if ($typeamount ==
'amount') {
1264 $descline .=
' ('.price($valuedeposit, 0, $langs, 0, - 1, - 1, (!empty(
$object->multicurrency_code) ?
$object->multicurrency_code :
$conf->currency)).
')';
1265 } elseif ($typeamount ==
'variable') {
1266 $descline .=
' ('.$valuedeposit.
'%)';
1269 $descline .=
' - '.$srcobject->ref;
1299 $diff =
$object->total_ttc - $amount_ttc_diff;
1303 $subprice_diff =
$object->lines[0]->subprice - $diff / (1 +
$object->lines[0]->tva_tx / 100);
1309 $object->lines[0]->localtax1_tx,
1310 $object->lines[0]->localtax2_tx,
1312 $object->lines[0]->fk_product,
1315 $object->lines[0]->product_type,
1316 $object->lines[0]->remise_percent,
1318 $object->lines[0]->date_start,
1327 } elseif ($result > 0) {
1328 $lines = $srcobject->lines;
1329 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
1330 $srcobject->fetch_lines();
1331 $lines = $srcobject->lines;
1334 $num = count($lines);
1335 for ($i = 0; $i < $num; $i++) {
1336 if (!in_array($lines[$i]->
id, $selectedLines)) {
1340 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->product_label);
1341 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
1344 if (method_exists($lines[$i],
'fetch_optionals')) {
1345 $lines[$i]->fetch_optionals();
1350 $date_start = $lines[$i]->date_debut_prevue;
1351 if ($lines[$i]->date_debut_reel) {
1352 $date_start = $lines[$i]->date_debut_reel;
1354 if ($lines[$i]->date_start) {
1355 $date_start = $lines[$i]->date_start;
1357 $date_end = $lines[$i]->date_fin_prevue;
1358 if ($lines[$i]->date_fin_reel) {
1359 $date_end = $lines[$i]->date_fin_reel;
1361 if ($lines[$i]->date_end) {
1362 $date_end = $lines[$i]->date_end;
1365 $tva_tx = $lines[$i]->tva_tx;
1367 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', (
string) $tva_tx)) {
1368 $tva_tx .=
' ('.$lines[$i]->vat_src_code.
')';
1372 $object->special_code = $lines[$i]->special_code;
1377 $pu_currency = $lines[$i]->multicurrency_subprice;
1379 $pu = $lines[$i]->subprice;
1388 $lines[$i]->localtax1_tx,
1389 $lines[$i]->localtax2_tx,
1391 $lines[$i]->fk_product,
1392 $lines[$i]->remise_percent,
1396 $lines[$i]->info_bits,
1401 $lines[$i]->array_options,
1402 $lines[$i]->fk_unit,
1405 $lines[$i]->ref_supplier,
1406 $lines[$i]->special_code
1423 $parameters = array(
'objFrom' => $srcobject);
1424 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters,
$object, $action);
1434 } elseif (!$error) {
1444 $langs->load(
"errors");
1454 $outputlangs = $langs;
1455 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1462 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
1465 } elseif ($action ==
'updateline' && $usercancreate) {
1469 if (!
$object->fetch($id) > 0) {
1475 $tva_tx = str_replace(
'*',
'', $tva_tx);
1477 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_subprice') !=
'') {
1479 $price_base_type =
'HT';
1482 $price_base_type =
'TTC';
1485 if (
GETPOST(
'productid') > 0) {
1487 if (
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY') == 1) {
1489 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1495 $label = $prod->description;
1496 if (trim(
GETPOST(
'product_desc',
'restricthtml')) != trim($label)) {
1497 $label =
GETPOST(
'product_desc',
'restricthtml');
1500 $type = $prod->type;
1502 $label =
GETPOST(
'product_desc',
'restricthtml');
1511 if (preg_match(
'/\*/', $tva_tx)) {
1516 $tva_tx = str_replace(
'*',
'', $tva_tx);
1524 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1525 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1527 if (is_array($extralabelsline)) {
1528 foreach ($extralabelsline as $key => $value) {
1529 unset($_POST[
"options_".$key]);
1533 $result =
$object->updateline(
1545 (
float) $remise_percent,
1555 unset($_POST[
'label']);
1556 unset($_POST[
'fourn_ref']);
1557 unset($_POST[
'date_starthour']);
1558 unset($_POST[
'date_startmin']);
1559 unset($_POST[
'date_startsec']);
1560 unset($_POST[
'date_startday']);
1561 unset($_POST[
'date_startmonth']);
1562 unset($_POST[
'date_startyear']);
1563 unset($_POST[
'date_endhour']);
1564 unset($_POST[
'date_endmin']);
1565 unset($_POST[
'date_endsec']);
1566 unset($_POST[
'date_endday']);
1567 unset($_POST[
'date_endmonth']);
1568 unset($_POST[
'date_endyear']);
1569 unset($_POST[
'price_ttc']);
1570 unset($_POST[
'price_ht']);
1577 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') && (
GETPOST(
'alldate_start',
'alpha') ||
GETPOST(
'alldate_end',
'alpha')) && $usercancreate) {
1581 foreach (
$object->lines as $line) {
1582 if ($line->product_type == 1) {
1583 $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);
1586 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') !=
'' && $usercancreate) {
1588 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
1589 $vat_rate = str_replace(
'*',
'', $vat_rate);
1592 foreach (
$object->lines as $line) {
1593 $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);
1595 } elseif ($action ==
'addline' && $usercancreate) {
1604 $ret =
$object->fetch_thirdparty();
1606 $langs->load(
'errors');
1611 $line_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
1615 $prod_entry_mode =
GETPOST(
'prod_entry_mode');
1616 if ($prod_entry_mode ==
'free') {
1623 $price_ht_devise =
'';
1625 $price_ttc_devise =
'';
1627 if (
GETPOST(
'price_ht') !==
'') {
1630 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
1633 if (
GETPOST(
'price_ttc') !==
'') {
1636 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
1637 $price_ttc_devise =
price2num(
GETPOST(
'multicurrency_price_ttc'),
'CU', 2);
1644 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef,
'alpha'),
'', 2) : 0);
1645 if (empty($remise_percent)) {
1646 $remise_percent = 0;
1650 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1651 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1653 if (is_array($extralabelsline)) {
1655 foreach ($extralabelsline as $key => $value) {
1656 unset($_POST[
"options_".$key]);
1660 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
1661 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1664 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') &&
GETPOST(
'type') < 0) {
1665 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
1670 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1')
1671 && (((
float) $price_ht < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) || $price_ht ===
'')
1672 && (((
float) $price_ht_devise < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) || $price_ht_devise ===
'')
1673 && ((
float) $price_ttc < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES') || $price_ttc ===
'')
1674 && ((
float) $price_ttc_devise < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES') || $price_ttc_devise ===
'')
1675 &&
$object->type != $object::TYPE_CREDIT_NOTE) {
1676 if (((
float) $price_ht < 0 || (
float) $price_ttc < 0) && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) {
1677 $langs->load(
"errors");
1678 if (
$object->type == $object::TYPE_DEPOSIT) {
1680 setEventMessages($langs->trans(
"ErrorLinesCantBeNegativeOnDeposits"),
null,
'errors');
1682 setEventMessages($langs->trans(
"ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv(
"UnitPrice"), $langs->transnoentitiesnoconv(
"CustomerAbsoluteDiscountShort")),
null,
'errors');
1687 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' && $price_ht_devise ===
'') {
1688 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'UnitPrice')),
null,
'errors');
1692 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') && !
GETPOST(
'dp_desc')) {
1693 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
1696 if (!
GETPOST(
'qty',
'alpha')) {
1697 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1701 if (!$error && isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1702 if ($combinations =
GETPOST(
'combinations',
'array')) {
1706 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1707 $idprod = $res->fk_product_child;
1709 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1715 if ($prod_entry_mode !=
'free' && empty($error)) {
1719 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
1724 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
1725 $idprod = (int) $reg[1];
1726 $res = $productsupplier->fetch($idprod);
1729 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
1731 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1732 if ($productsupplier->fourn_socid != $socid) {
1733 $productsupplier->ref_supplier =
'';
1736 $fksoctosearch =
$object->thirdparty->id;
1737 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1739 } elseif (
GETPOSTINT(
'idprodfournprice') > 0) {
1740 $qtytosearch = (float) $qty;
1742 $idprod = $productsupplier->get_buyprice(
GETPOSTINT(
'idprodfournprice'), $qtytosearch);
1743 $res = $productsupplier->fetch($idprod);
1747 $label = $productsupplier->label;
1750 $outputlangs = $langs;
1752 if (
GETPOST(
'lang_id',
'aZ09')) {
1753 $newlang =
GETPOST(
'lang_id',
'aZ09');
1755 if (empty($newlang)) {
1756 $newlang =
$object->thirdparty->default_lang;
1758 if (!empty($newlang)) {
1760 $outputlangs->setDefaultLang($newlang);
1762 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->
description;
1764 $desc = $productsupplier->description;
1767 if (!empty($productsupplier->desc_supplier) &&
getDolGlobalString(
'PRODUIT_FOURN_TEXTS')) {
1768 $desc = $productsupplier->desc_supplier;
1779 $ref_supplier = $productsupplier->ref_supplier;
1782 if (!GETPOSTISSET(
'tva_tx')) {
1783 $tmpidprodfournprice =
GETPOST(
'idprodfournprice',
'alpha');
1784 if (is_numeric($tmpidprodfournprice) && (
int) $tmpidprodfournprice > 0) {
1785 $tmpidprodfournprice = (int) $tmpidprodfournprice;
1787 $tmpidprodfournprice = 0;
1793 if (empty($tva_tx) || empty($tva_npr)) {
1799 $type = $productsupplier->type;
1800 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1801 $price_base_type =
'HT';
1803 $pu_devise =
price2num($price_ht_devise,
'CU');
1804 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
1805 $price_base_type =
'TTC';
1807 $pu_devise =
price2num($price_ttc_devise,
'CU');
1809 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
1810 if (empty(
$object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code !=
$object->multicurrency_code)) {
1811 $pu = $productsupplier->fourn_pu;
1814 $pu = $productsupplier->fourn_pu;
1815 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
1819 $ref_supplier = $productsupplier->ref_supplier;
1840 min($rank, count(
$object->lines) + 1),
1843 $productsupplier->fk_unit,
1846 GETPOST(
'fourn_ref',
'alpha'),
1850 if ($idprod == -99 || $idprod == 0) {
1853 $langs->load(
"errors");
1854 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
1856 if ($idprod == -1) {
1859 $langs->load(
"errors");
1860 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
1862 } elseif (empty($error)) {
1863 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1864 $tva_tx = str_replace(
'*',
'', $tva_tx);
1865 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1868 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1872 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
1880 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1884 $pu_ht =
price2num((
float) $pu_ttc / (1 + ((
float) $tva_tx / 100)),
'MU');
1886 $price_base_type =
'HT';
1887 $pu_devise =
price2num($price_ht_devise,
'CU');
1889 $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);
1893 if (!$error && $result > 0) {
1898 $outputlangs = $langs;
1901 $newlang =
GETPOST(
'lang_id',
'aZ09');
1904 $newlang =
$object->thirdparty->default_lang;
1906 if (!empty($newlang)) {
1908 $outputlangs->setDefaultLang($newlang);
1913 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1919 unset($_POST [
'prod_entry_mode']);
1921 unset($_POST[
'qty']);
1922 unset($_POST[
'type']);
1923 unset($_POST[
'remise_percent']);
1924 unset($_POST[
'pu']);
1925 unset($_POST[
'price_ht']);
1926 unset($_POST[
'multicurrency_price_ht']);
1927 unset($_POST[
'price_ttc']);
1928 unset($_POST[
'fourn_ref']);
1929 unset($_POST[
'tva_tx']);
1930 unset($_POST[
'label']);
1931 unset($localtax1_tx);
1932 unset($localtax2_tx);
1933 unset($_POST[
'np_marginRate']);
1934 unset($_POST[
'np_markRate']);
1935 unset($_POST[
'dp_desc']);
1936 unset($_POST[
'idprodfournprice']);
1937 unset($_POST[
'units']);
1939 unset($_POST[
'date_starthour']);
1940 unset($_POST[
'date_startmin']);
1941 unset($_POST[
'date_startsec']);
1942 unset($_POST[
'date_startday']);
1943 unset($_POST[
'date_startmonth']);
1944 unset($_POST[
'date_startyear']);
1945 unset($_POST[
'date_endhour']);
1946 unset($_POST[
'date_endmin']);
1947 unset($_POST[
'date_endsec']);
1948 unset($_POST[
'date_endday']);
1949 unset($_POST[
'date_endmonth']);
1950 unset($_POST[
'date_endyear']);
1957 } elseif ($action ==
'classin' && $usercancreate) {
1959 $result =
$object->setProject($projectid);
1960 } elseif ($action ==
'confirm_edit' && $confirm ==
'yes' && $usercancreate) {
1964 $totalpaid =
$object->getSommePaiement();
1965 $resteapayer =
$object->total_ttc - $totalpaid;
1968 $ventilExportCompta =
$object->getVentilExportCompta();
1970 if (!$ventilExportCompta) {
1973 $idwarehouse =
GETPOST(
'idwarehouse');
1977 $qualified_for_stock_change = 0;
1979 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1981 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1985 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
1986 $langs->load(
"stocks");
1987 if (!$idwarehouse || $idwarehouse == -1) {
1989 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1994 $object->setDraft($user, $idwarehouse);
1998 $outputlangs = $langs;
2001 $newlang =
GETPOST(
'lang_id',
'aZ09');
2004 $newlang =
$object->thirdparty->default_lang;
2006 if (!empty($newlang)) {
2008 $outputlangs->setDefaultLang($newlang);
2013 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
2022 } elseif ($action ==
'reopen' && $usercancreate) {
2024 $result =
$object->fetch($id);
2027 $result =
$object->setUnpaid($user);
2029 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
2038 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
2041 $triggersendname =
'BILL_SUPPLIER_SENTBYMAIL';
2043 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
2044 $trackid =
'sinv'.$object->id;
2045 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
2048 $upload_dir =
$conf->fournisseur->facture->dir_output;
2049 $permissiontoadd = $usercancreate;
2050 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
2053 if ($action ==
'calculate' && $usercancreate) {
2054 $calculationrule =
GETPOST(
'calculationrule');
2058 $result =
$object->update_price(0, (($calculationrule ==
'totalofround') ?
'0' :
'1'), 0,
$object->thirdparty);
2064 if ($action ==
'update_extras' && $permissiontoeditextra) {
2067 $attribute_name =
GETPOST(
'attribute',
'aZ09');
2070 $ret = $extrafields->setOptionalsFromPost(
null,
$object, $attribute_name);
2076 $result =
$object->updateExtraField($attribute_name,
'BILL_SUPPLIER_MODIFY');
2084 $action =
'edit_extras';
2089 if ($action ==
'addcontact' && $usercancreate) {
2090 $result =
$object->fetch($id);
2092 if ($result > 0 && $id > 0) {
2095 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
2099 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2102 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2103 $langs->load(
"errors");
2104 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
2109 } elseif ($action ==
'swapstatut' && $usercancreate) {
2116 } elseif ($action ==
'deletecontact' && $usercancreate) {
2122 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2136$form =
new Form($db);
2138$bankaccountstatic =
new Account($db);
2140if (isModEnabled(
'project')) {
2146$title =
$object->ref.
" - ".$langs->trans(
'Card');
2147if ($action ==
'create') {
2148 $title = $langs->trans(
"NewSupplierInvoice");
2150$help_url =
'EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores|DE:Modul_Lieferantenrechnungen';
2151llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-fourn-facture page-card');
2154if ($action ==
'create') {
2156 $selectedLines = array();
2158 print
load_fiche_titre($langs->trans(
'NewSupplierInvoice'),
'',
'supplier_invoice');
2162 $currency_code =
$conf->currency;
2163 $vat_reverse_charge = 0;
2169 if (isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2170 $currency_code = $societe->multicurrency_code;
2174 if (!empty($origin) && !empty($originid)) {
2176 $element = $subelement = $origin;
2178 if ($element ==
'project') {
2179 $projectid = $originid;
2180 $element =
'projet';
2184 if ($element ==
'order') {
2185 $element = $subelement =
'commande';
2187 if ($element ==
'propal') {
2188 $element =
'comm/propal';
2189 $subelement =
'propal';
2191 if ($element ==
'contract') {
2192 $element = $subelement =
'contrat';
2194 if ($element ==
'order_supplier') {
2196 $subelement =
'fournisseur.commande';
2200 $classname = ucfirst($subelement);
2201 if ($classname ==
'Fournisseur.commande') {
2202 $classname =
'CommandeFournisseur';
2204 $objectsrc =
new $classname($db);
2205 '@phan-var-force Project|Commande|Propal|Facture|Contrat|CommandeFournisseur|CommonObject $objectsrc';
2206 $objectsrc->fetch($originid);
2207 $objectsrc->fetch_thirdparty();
2209 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
2211 $soc = $objectsrc->thirdparty;
2213 $cond_reglement_id = 0;
2214 $mode_reglement_id = 0;
2218 $transport_mode_id = 0;
2221 if (!empty($objectsrc->cond_reglement_id)) {
2222 $cond_reglement_id = $objectsrc->cond_reglement_id;
2224 if (!empty($objectsrc->mode_reglement_id)) {
2225 $mode_reglement_id = $objectsrc->mode_reglement_id;
2227 if (!empty($objectsrc->fk_account)) {
2228 $fk_account = $objectsrc->fk_account;
2230 if (!empty($objectsrc->transport_mode_id)) {
2231 $transport_mode_id = $objectsrc->transport_mode_id;
2234 if (empty($cond_reglement_id)
2235 || empty($mode_reglement_id)
2236 || empty($fk_account)
2237 || empty($transport_mode_id)
2239 if ($origin ==
'reception') {
2241 if (!isset($objectsrc->supplier_order)) {
2242 $objectsrc->fetch_origin();
2245 if (!empty($objectsrc->origin_object)) {
2246 $originObject = $objectsrc->origin_object;
2247 if (empty($cond_reglement_id) && !empty($originObject->cond_reglement_id)) {
2248 $cond_reglement_id = $originObject->cond_reglement_id;
2250 if (empty($mode_reglement_id) && !empty($originObject->mode_reglement_id)) {
2251 $mode_reglement_id = $originObject->mode_reglement_id;
2253 if (empty($fk_account) && !empty($originObject->fk_account)) {
2254 $fk_account = $originObject->fk_account;
2256 if (empty($transport_mode_id) && !empty($originObject->transport_mode_id)) {
2257 $transport_mode_id = $originObject->transport_mode_id;
2264 if (empty($cond_reglement_id) && !empty($soc->cond_reglement_supplier_id)) {
2265 $cond_reglement_id = $soc->cond_reglement_supplier_id;
2267 if (empty($mode_reglement_id) && !empty($soc->mode_reglement_supplier_id)) {
2268 $mode_reglement_id = $soc->mode_reglement_supplier_id;
2270 if (empty($fk_account) && !empty($soc->fk_account)) {
2271 $fk_account = $soc->fk_account;
2273 if (empty($transport_mode_id) && !empty($soc->transport_mode_id)) {
2274 $transport_mode_id = $soc->transport_mode_id;
2279 if (isModEnabled(
"multicurrency")) {
2280 if (!empty($objectsrc->multicurrency_code)) {
2281 $currency_code = $objectsrc->multicurrency_code;
2283 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
2284 $currency_tx = $objectsrc->multicurrency_tx;
2289 $dateinvoice = ($datetmp ==
'' ? (!
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ? -1 :
'') : $datetmp);
2291 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2294 $objectsrc->fetch_optionals();
2295 $object->array_options = $objectsrc->array_options;
2297 $cond_reglement_id = !empty($societe->cond_reglement_supplier_id) ? $societe->cond_reglement_supplier_id : 0;
2298 $mode_reglement_id = !empty($societe->mode_reglement_supplier_id) ? $societe->mode_reglement_supplier_id : 0;
2299 $vat_reverse_charge = (empty($societe) ?
'' : $societe->vat_reverse_charge);
2300 $transport_mode_id = !empty($societe->transport_mode_supplier_id) ? $societe->transport_mode_supplier_id : 0;
2301 $fk_account = !empty($societe->fk_account) ? $societe->fk_account : 0;
2303 $dateinvoice = ($datetmp ==
'' ? (
getDolGlobalInt(
'MAIN_AUTOFILL_DATE') ?
'' : -1) : $datetmp);
2305 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2307 if (isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2308 $currency_code = $societe->multicurrency_code;
2313 if (empty($cond_reglement_id)) {
2314 $cond_reglement_id =
GETPOST(
"cond_reglement_id");
2318 if (empty($mode_reglement_id)) {
2319 $mode_reglement_id =
GETPOST(
"mode_reglement_id");
2323 if (!
GETPOST(
'changecompany')) {
2324 if (GETPOSTISSET(
'cond_reglement_id')) {
2325 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2327 if (GETPOSTISSET(
'mode_reglement_id')) {
2328 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2330 if (GETPOSTISSET(
'cond_reglement_id')) {
2335 $note_public =
$object->getDefaultCreateValueFor(
'note_public', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_public : null));
2336 $note_private =
$object->getDefaultCreateValueFor(
'note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_private : null));
2338 if ($origin ==
'contrat') {
2339 $langs->load(
"admin");
2340 $text = $langs->trans(
"ToCreateARecurringInvoice");
2341 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv(
"MenuFinancial"), $langs->transnoentitiesnoconv(
"SupplierBills"), $langs->transnoentitiesnoconv(
"ListOfTemplates"));
2343 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv(
'Module2300Name'));
2345 print
info_admin($text, 0, 0,
'0',
'opacitymedium').
'<br>';
2348 print
'<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
2349 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2350 print
'<input type="hidden" name="action" value="add">';
2351 print
'<input type="hidden" name="changecompany" value="0">';
2353 if (!empty($societe->id) && $societe->id > 0) {
2354 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">'.
"\n";
2356 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
2357 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
2358 if (!empty($currency_tx)) {
2359 print
'<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
2361 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2366 $parameters = array();
2368 $reshook = $hookmanager->executeHooks(
'tabContentCreateSupplierInvoice', $parameters,
$object, $action);
2369 if (empty($reshook)) {
2370 print
'<table class="border centpercent">';
2373 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
'Draft').
'</td></tr>';
2377 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2378 $invoice_predefined->fetch($fac_recid);
2382 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
2385 if (!empty($societe->id) && $societe->id > 0 && ($fac_recid <= 0 || !empty($invoice_predefined->frequency))) {
2386 $absolute_discount = $societe->getAvailableDiscounts(
null,
'', 0, 1);
2387 print $societe->getNomUrl(1,
'supplier');
2388 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
2390 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
2391 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');
2394 print
'<script type="text/javascript">
2395 $(document).ready(function() {
2396 $("#socid").change(function() {
2397 console.log("We have changed the company - Reload page");
2399 $("input[name=action]").val("create");
2400 $("input[name=changecompany]").val("1");
2401 $("form[name=add]").submit();
2406 if ($fac_recid <= 0) {
2407 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>';
2413 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2414 $invoice_predefined->fetch($fac_recid);
2416 $dateinvoice = $invoice_predefined->date_when;
2417 if (empty($projectid)) {
2418 $projectid = $invoice_predefined->fk_project;
2420 $cond_reglement_id = $invoice_predefined->cond_reglement_id;
2421 $mode_reglement_id = $invoice_predefined->mode_reglement_id;
2422 $fk_account = $invoice_predefined->fk_account;
2423 $note_public = $invoice_predefined->note_public;
2424 $note_private = $invoice_predefined->note_private;
2426 if (!empty($invoice_predefined->multicurrency_code)) {
2427 $currency_code = $invoice_predefined->multicurrency_code;
2429 if (!empty($invoice_predefined->multicurrency_tx)) {
2430 $currency_tx = $invoice_predefined->multicurrency_tx;
2433 $sql =
'SELECT r.rowid, r.titre as title, r.total_ttc';
2434 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn_rec as r';
2435 $sql .=
' WHERE r.fk_soc = '. (int) $invoice_predefined->socid;
2437 $resql = $db->query($sql);
2439 $num = $db->num_rows($resql);
2443 print
'<tr><td>'.$langs->trans(
'CreateFromRepeatableInvoice').
'</td><td>';
2445 print
'<select class="flat" id="fac_rec" name="fac_rec">';
2446 print
'<option value="0" selected></option>';
2448 $objp = $db->fetch_object($resql);
2449 print
'<option value="'.$objp->rowid.
'"';
2450 if ($fac_recid == $objp->rowid) {
2452 $exampletemplateinvoice->fetch($fac_recid);
2454 print
'>'.$objp->title.
' ('.
price($objp->total_ttc).
' '.$langs->trans(
"TTC").
')</option>';
2460 print
'<script type="text/javascript">
2461 $(document).ready(function() {
2462 $("#fac_rec").change(function() {
2463 console.log("We have changed the template invoice - Reload page");
2465 $("input[name=action]").val("create");
2466 $("form[name=add]").submit();
2480 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"';
2481 if (!empty($societe->id) && $societe->id > 0) {
2487 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'Type').
'</td><td>';
2489 print
'<div class="tagtable">'.
"\n";
2492 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2493 $tmp =
'<input type="radio" id="radio_standard" name="type" value="0"'.(GETPOSTINT(
'type') ?
'' :
'checked').
'> ';
2494 $desc = $form->textwithpicto($tmp.
'<label for="radio_standard">'.$langs->trans(
"InvoiceStandardAsk").
'</label>', $langs->transnoentities(
"InvoiceStandardDesc"), 1,
'help',
'', 0, 3);
2496 print
'</div></div>';
2498 if (empty($origin) || ($origin ==
'order_supplier' && !empty($originid))) {
2501 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2502 $tmp =
'<input type="radio" id="radio_deposit" name="type" value="3"' . (
GETPOSTINT(
'type') == 3 ?
' checked' :
'') .
'> ';
2503 print
'<script type="text/javascript">
2504 jQuery(document).ready(function() {
2505 jQuery("#typestandardinvoice, #valuestandardinvoice").click(function() {
2506 jQuery("#radio_standard").prop("checked", true);
2508 jQuery("#typedeposit, #valuedeposit").click(function() {
2509 jQuery("#radio_deposit").prop("checked", true);
2511 jQuery("#typedeposit").change(function() {
2512 console.log("We change type of down payment");
2513 jQuery("#radio_deposit").prop("checked", true);
2514 setRadioForTypeOfInvoice();
2516 jQuery("#radio_standard, #radio_deposit, #radio_replacement, #radio_template").change(function() {
2517 setRadioForTypeOfInvoice();
2519 function setRadioForTypeOfInvoice() {
2520 console.log("Change radio");
2521 if (jQuery("#radio_deposit").prop("checked") && (jQuery("#typedeposit").val() == \'amount\' || jQuery("#typedeposit").val() == \'variable\')) {
2522 jQuery(".checkforselect").prop("disabled", true);
2523 jQuery(".checkforselect").prop("checked", false);
2525 jQuery(".checkforselect").prop("disabled", false);
2526 jQuery(".checkforselect").prop("checked", true);
2532 $tmp = $tmp.
'<label for="radio_deposit" >'.$langs->trans(
"InvoiceDeposit").
'</label>';
2534 $desc = $form->textwithpicto($tmp, $langs->transnoentities(
"InvoiceDepositDesc"), 1,
'help',
'', 0, 3);
2535 print
'<table class="nobordernopadding"><tr>';
2539 if ($origin ==
'order_supplier') {
2540 print
'<td class="nowrap" style="padding-left: 15px">';
2542 'amount' => $langs->transnoentitiesnoconv(
'FixAmount', $langs->transnoentitiesnoconv(
'Deposit')),
2543 'variable' => $langs->transnoentitiesnoconv(
'VarAmountOneLine', $langs->transnoentitiesnoconv(
'Deposit')),
2544 'variablealllines' => $langs->transnoentitiesnoconv(
'VarAmountAllLines')
2546 print $form->selectarray(
'typedeposit', $arraylist,
GETPOST(
'typedeposit',
'aZ09'), 0, 0, 0,
'', 1);
2548 print
'<td class="nowrap" style="padding-left: 5px">';
2549 print
'<span class="opacitymedium paddingleft">'.$langs->trans(
"AmountOrPercent").
'</span><input type="text" id="valuedeposit" name="valuedeposit" class="width75 right" value="' .
GETPOSTINT(
'valuedeposit') .
'"/>';
2552 print
'</tr></table>';
2554 print
'</div></div>';
2623 if (empty($origin)) {
2624 if (!empty($societe->id) && $societe->id > 0) {
2628 $facids = $facturestatic->list_qualified_avoir_supplier_invoices($societe->id);
2635 foreach ($facids as $key => $valarray) {
2636 $newinvoice_static->id = $key;
2637 $newinvoice_static->ref = $valarray [
'ref'];
2638 $newinvoice_static->status = $valarray [
'status'];
2639 $newinvoice_static->statut = $valarray [
'status'];
2640 $newinvoice_static->type = $valarray [
'type'];
2641 $newinvoice_static->paid = $valarray [
'paye'];
2642 $newinvoice_static->paye = $valarray [
'paye'];
2644 $optionsav .=
'<option value="'.$key.
'"';
2646 $optionsav .=
' selected';
2649 $optionsav .= $newinvoice_static->ref;
2650 $optionsav .=
' ('.$newinvoice_static->getLibStatut(1, $valarray [
'paymentornot']).
')';
2651 $optionsav .=
'</option>';
2654 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2655 $tmp =
'<input type="radio" id="radio_creditnote" name="type" value="2"'.(GETPOST(
'type') == 2 ?
' checked' :
'');
2657 $tmp .=
' disabled';
2661 print
'<script type="text/javascript">
2662 jQuery(document).ready(function() {
2663 if (! jQuery("#radio_creditnote").is(":checked"))
2665 jQuery("#credit_note_options").hide();
2667 jQuery("#radio_creditnote").click(function() {
2668 jQuery("#credit_note_options").show();
2670 jQuery("#radio_standard, #radio_replacement, #radio_deposit").click(function() {
2671 jQuery("#credit_note_options").hide();
2675 $text = $tmp.
'<label for="radio_creditnote">'.$langs->transnoentities(
"InvoiceAvoirAsk").
'</label> ';
2677 $text .=
'<select class="flat valignmiddle" name="fac_avoir" id="fac_avoir"';
2679 $text .=
' disabled';
2683 $text .=
'<option value="-1"></option>';
2684 $text .= $optionsav;
2686 $text .=
'<option value="-1">'.$langs->trans(
"NoInvoiceToCorrect").
'</option>';
2688 $text .=
'</select>';
2689 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2692 print
'<div id="credit_note_options" class="clearboth">';
2693 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' :
'').
' /> ';
2694 print
'<label for="invoiceAvoirWithLines">'.$langs->trans(
'invoiceAvoirWithLines').
"</label>";
2695 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' :
'').
' /> ';
2696 print
'<label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans(
'invoiceAvoirWithPaymentRestAmount').
"</label>";
2699 print
'</div></div>';
2702 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2704 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="0" disabled> ';
2706 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="2"> ';
2708 $text = $tmp.$langs->trans(
"InvoiceAvoir").
' ';
2709 $text .=
'<span class="opacitymedium">('.$langs->trans(
"YouMustCreateInvoiceFromSupplierThird").
')</span> ';
2710 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2712 print
'</div></div>'.
"\n";
2723 print
'<tr><td class="fieldrequired">'.$langs->trans(
'InvoiceSubtype').
'</td><td colspan="2">';
2724 print $form->getSelectInvoiceSubtype(
GETPOSTINT(
'subtype'),
'subtype', 1, 0,
'');
2728 if (!empty($societe->id) && $societe->id > 0) {
2730 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
2732 $thirdparty = $societe;
2734 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$societe->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
2735 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2741 print
'<tr><td>'.$langs->trans(
'Label').
'</td><td><input class="minwidth200" name="label" value="'.
dol_escape_htmltag(
GETPOST(
'label')).
'" type="text"></td></tr>';
2745 print
'<tr><td class="fieldrequired">'.$langs->trans(
'DateInvoice').
'</td><td>';
2746 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2747 print $form->selectDate($dateinvoice ? (
int) $dateinvoice :
'',
'', 0, 0, 0,
"add", 1, 1);
2751 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
2752 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
2753 print $form->getSelectConditionsPaiements($cond_reglement_id,
'cond_reglement_id', -1, 1, 0,
'maxwidth200 widthcentpercentminusx');
2757 print
'<tr><td>'.$langs->trans(
'DateMaxPayment').
'</td><td>';
2758 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2759 print $form->selectDate($datedue,
'ech', 0, 0, 0,
"add", 1, 1);
2763 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
2764 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
2765 $form->select_types_paiements((
string) $mode_reglement_id,
'mode_reglement_id',
'DBIT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx');
2769 if (isModEnabled(
"bank")) {
2770 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
2772 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes($fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
2777 if (isModEnabled(
'project')) {
2780 $langs->load(
'projects');
2781 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td>';
2782 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');
2783 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>';
2788 if (isModEnabled(
'incoterm')) {
2790 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), !empty($objectsrc->label_incoterms) ? $objectsrc->label_incoterms :
'', 1).
'</label></td>';
2791 print
'<td colspan="3" class="maxwidthonsmartphone">';
2792 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2793 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 :
''));
2799 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
2800 print
'<tr><td>' . $langs->trans(
'VATReverseCharge') .
'</td><td>';
2802 if (GETPOSTISSET(
'vat_reverse_charge')) {
2803 $vat_reverse_charge = (
GETPOST(
'vat_reverse_charge',
'alpha') ==
'on' ||
GETPOST(
'vat_reverse_charge',
'alpha') ==
'1') ? 1 : 0;
2804 } elseif ($vat_reverse_charge == 1 || $societe->vat_reverse_charge == 1 || ($societe->country_code !=
'FR' &&
isInEEC($societe) && !empty($societe->tva_intra))) {
2805 $vat_reverse_charge = 1;
2807 $vat_reverse_charge = 0;
2810 print
'<input type="checkbox" name="vat_reverse_charge"'. (!empty($vat_reverse_charge) ?
' checked ' :
'') .
'>';
2815 if (isModEnabled(
"multicurrency")) {
2817 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'',
$object, 0).
'</td>';
2818 print
'<td class="maxwidthonsmartphone">';
2819 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
2820 $used_currency_code = $currency_code;
2821 if (!
GETPOST(
'changecompany')) {
2822 $used_currency_code = GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code',
'alpha') : $currency_code;
2824 print $form->selectMultiCurrency($used_currency_code,
'multicurrency_code');
2830 if ($fac_recid > 0) {
2831 $dateexample = $dateinvoice;
2832 if (empty($dateexample)) {
2835 $substitutionarray = array(
2836 '__TOTAL_HT__' => $langs->trans(
"AmountHT").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ht).
')',
2837 '__TOTAL_TTC__' => $langs->trans(
"AmountTTC").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ttc).
')',
2838 '__INVOICE_PREVIOUS_MONTH__' => $langs->trans(
"PreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%m').
')',
2839 '__INVOICE_MONTH__' => $langs->trans(
"MonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%m').
')',
2840 '__INVOICE_NEXT_MONTH__' => $langs->trans(
"NextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%m').
')',
2841 '__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans(
"TextPreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%B').
')',
2842 '__INVOICE_MONTH_TEXT__' => $langs->trans(
"TextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%B').
')',
2843 '__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans(
"TextNextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%B').
')',
2844 '__INVOICE_PREVIOUS_YEAR__' => $langs->trans(
"PreviousYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'y'),
'%Y').
')',
2845 '__INVOICE_YEAR__' => $langs->trans(
"YearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%Y').
')',
2846 '__INVOICE_NEXT_YEAR__' => $langs->trans(
"NextYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'y'),
'%Y').
')'
2849 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
2850 foreach ($substitutionarray as $key => $val) {
2851 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
2853 $htmltext .=
'</i>';
2857 if (isModEnabled(
'intracommreport')) {
2858 $langs->loadLangs(array(
"intracommreport"));
2859 print
'<!-- If module intracomm on -->'.
"\n";
2860 print
'<tr><td>'.$langs->trans(
'IntracommReportTransportMode').
'</td><td>';
2861 $form->selectTransportMode(GETPOSTISSET(
'transport_mode_id') ?
GETPOST(
'transport_mode_id') : $transport_mode_id,
'transport_mode_id');
2865 if (empty($reshook)) {
2866 print
$object->showOptionals($extrafields,
'create');
2870 if (isModEnabled(
"category")) {
2871 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
2872 print $form->selectCategories(Categorie::TYPE_SUPPLIER_INVOICE,
'categories',
$object);
2877 print
'<tr><td>'.$langs->trans(
'NotePublic').
'</td>';
2879 $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%');
2880 print $doleditor->Create(1);
2886 print
'<tr><td>'.$langs->trans(
'NotePrivate').
'</td>';
2888 $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%');
2889 print $doleditor->Create(1);
2895 if (!empty($objectsrc) && is_object($objectsrc)) {
2896 print
"\n<!-- ".$classname.
" info -->";
2898 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2899 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2900 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2901 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2902 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2904 $txt = $langs->trans($classname);
2905 if ($classname ==
'CommandeFournisseur') {
2906 $langs->load(
'orders');
2907 $txt = $langs->trans(
"SupplierOrder");
2909 print
'<tr><td>'.$txt.
'</td><td>'.$objectsrc->getNomUrl(1);
2911 $objectsrc->fetchObjectLinked($originid, $origin,
null,
'invoice_supplier');
2913 if (isset($objectsrc->linkedObjects[
'invoice_supplier'])) {
2914 $invoice_supplier = $objectsrc->linkedObjects[
'invoice_supplier'];
2916 $invoice_supplier = [];
2918 '@phan-var-force null|FactureFournisseur[] $invoice_supplier';
2921 if (is_array($invoice_supplier)) {
2922 $cntinvoice = count($invoice_supplier);
2924 if ($cntinvoice >= 1) {
2926 echo
' ('.$langs->trans(
'LatestRelatedBill').end($invoice_supplier)->getNomUrl(1).
')';
2931 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
2932 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
2933 if ($mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
2934 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
2937 if ($mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
2938 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
2940 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
2942 if (isModEnabled(
"multicurrency")) {
2943 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
2944 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
2945 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2950 $parameters = array();
2951 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2952 print $hookmanager->resPrint;
2960 print $form->buttonsSaveCancel(
"CreateDraft");
2963 if (!empty($objectsrc) && is_object($objectsrc)) {
2966 $title = $langs->trans(
'ProductsAndServices');
2969 print
'<div class="div-table-responsive-no-min">';
2970 print
'<table class="noborder centpercent">';
2972 $objectsrc->printOriginLinesList(
'', $selectedLines);
2980 if ($id > 0 || !empty($ref)) {
2986 $productstatic =
new Product($db);
2988 $result =
$object->fetch($id, $ref);
2993 $result =
$object->fetch_thirdparty();
2999 $societe =
$object->thirdparty;
3001 $totalpaid =
$object->getSommePaiement();
3002 $totalcreditnotes =
$object->getSumCreditNotesUsed();
3003 $totaldeposits =
$object->getSumDepositsUsed();
3011 $resteapayer =
price2num(
$object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
3014 $multicurrency_resteapayer = 0;
3015 if (isModEnabled(
"multicurrency")) {
3016 $multicurrency_totalpaid =
$object->getSommePaiement(1);
3017 $multicurrency_totalcreditnotes =
$object->getSumCreditNotesUsed(1);
3018 $multicurrency_totaldeposits =
$object->getSumDepositsUsed(1);
3019 $multicurrency_resteapayer =
price2num(
$object->multicurrency_total_ttc - $multicurrency_totalpaid - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits,
'MT');
3023 if ($resteapayer == 0 && $multicurrency_resteapayer != 0 &&
$object->multicurrency_code !=
$conf->currency) {
3024 $resteapayer =
price2num((
float) $multicurrency_resteapayer /
$object->multicurrency_tx,
'MT');
3031 $resteapayeraffiche = $resteapayer;
3034 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
3035 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
3037 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
3038 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
3041 $absolute_discount = $societe->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
3042 $absolute_creditnote = $societe->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
3043 $absolute_discount =
price2num($absolute_discount,
'MT');
3044 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
3048 $objectidnext =
$object->getIdReplacingInvoice();
3051 $titre = $langs->trans(
'SupplierInvoice');
3053 print
dol_get_fiche_head($head,
'card', $titre, -1,
'supplier_invoice', 0,
'',
'', 0,
'', 1);
3058 if ($action ==
'converttoreduc') {
3061 $type_fac =
'ExcessPaid';
3063 $type_fac =
'CreditNote';
3065 $type_fac =
'Deposit';
3067 $text = $langs->trans(
'ConfirmConvertToReducSupplier', strtolower($langs->transnoentities($type_fac)));
3068 $text .=
'<br>'.$langs->trans(
'ConfirmConvertToReducSupplier2');
3069 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id, $langs->trans(
'ConvertToReduc'), $text,
'confirm_converttoreduc',
'',
"yes", 2);
3073 if ($action ==
'clone') {
3075 $formquestion = array(
3076 array(
'type' =>
'text',
'name' =>
'newsupplierref',
'label' => $langs->trans(
"RefSupplierBill"),
'value' => $langs->trans(
"CopyOf").
' '.
$object->ref_supplier),
3077 array(
'type' =>
'date',
'name' =>
'newdate',
'label' => $langs->trans(
"Date"),
'value' =>
dol_now())
3080 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneInvoice',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1, 250);
3084 if ($action ==
'valid') {
3086 if (preg_match(
'/^[\(]?PROV/i',
$object->ref) || empty(
$object->ref)) {
3088 $numref =
$object->getNextNumRef($societe);
3097 $text = $langs->trans(
'ConfirmValidateBill', $numref);
3105 $formquestion = array();
3107 $qualified_for_stock_change = 0;
3109 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3111 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3114 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
3115 $langs->load(
"stocks");
3116 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3119 $warehouse_array = $warehouse->list_array();
3120 if (count($warehouse_array) == 1) {
3122 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3125 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3127 $formquestion = array(
3128 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3132 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateBill'), $text,
'confirm_valid', $formquestion, 1, 1);
3137 if ($action ==
'edit') {
3138 $formquestion = array();
3140 $qualified_for_stock_change = 0;
3142 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3144 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3146 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
3147 $langs->load(
"stocks");
3148 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3151 $warehouse_array = $warehouse->list_array();
3152 if (count($warehouse_array) == 1) {
3154 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3157 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3159 $formquestion = array(
3160 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3163 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'UnvalidateBill'), $langs->trans(
'ConfirmUnvalidateBill',
$object->ref),
'confirm_edit', $formquestion, 1, 1);
3167 if ($action ==
'paid' && ($resteapayer <= 0 || (
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') && $resteapayer ==
$object->total_ttc))) {
3168 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidBill',
$object->ref),
'confirm_paid',
'', 0, 1);
3171 if ($action ==
'paid' && $resteapayer > 0 && (!
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') || $resteapayer !=
$object->total_ttc)) {
3175 $close[$i][
'code'] =
'discount_vat';
3177 $close[$i][
'code'] =
'badsupplier';
3179 $close[$i][
'code'] =
'other';
3183 $close[$i][
'label'] = $langs->trans(
"HelpEscompte").
'<br><br>'.$langs->trans(
"ConfirmClassifyPaidPartiallyReasonDiscountVatDesc");
3185 $close[$i][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3187 $close[$i][
'label'] = $langs->trans(
"Other");
3191 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonDiscount", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3193 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadCustomer", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3195 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"Other"), $close[$i][
'label'], 1);
3198 $arrayreasons = array();
3199 foreach ($close as $key => $val) {
3200 $arrayreasons[$close[$key][
'code']] = $close[$key][
'reason'];
3204 $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'));
3206 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?facid='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidPartially',
$object->ref),
'confirm_paid_partially', $formquestion,
"yes", 1, 310);
3210 if ($action ==
'canceled') {
3212 $close[1][
'code'] =
'badsupplier';
3213 $close[2][
'code'] =
'abandon';
3215 $close[1][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3216 $close[2][
'label'] = $langs->trans(
"ConfirmClassifyAbandonReasonOtherDesc");
3218 $close[1][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadSupplier",
$object->ref), $close[1][
'label'], 1);
3219 $close[2][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyAbandonReasonOther"), $close[2][
'label'], 1);
3221 $arrayreasons[$close[1][
'code']] = $close[1][
'reason'];
3222 $arrayreasons[$close[2][
'code']] = $close[2][
'reason'];
3225 $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'));
3227 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'CancelBill'), $langs->trans(
'ConfirmCancelBill',
$object->ref),
'confirm_canceled', $formquestion,
"yes", 1, 280);
3231 if ($action ==
'delete') {
3232 $formquestion = array();
3234 $qualified_for_stock_change = 0;
3236 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3238 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3241 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
3242 $langs->load(
"stocks");
3243 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3246 $warehouse_array = $warehouse->list_array();
3248 $selectwarehouse =
'<span class="questionrevertstock hidden">';
3249 if (count($warehouse_array) == 1) {
3251 $selectwarehouse .=
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3254 $selectwarehouse .= $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3256 $selectwarehouse .=
'</span>';
3258 $selectyesno = array(0 => $langs->trans(
'No'), 1 => $langs->trans(
'Yes'));
3260 print
'<script type="text/javascript">
3261 $(document).ready(function() {
3262 $("#revertstock").change(function() {
3263 if(this.value > 0) {
3264 $(".questionrevertstock").removeClass("hidden");
3266 $(".questionrevertstock").addClass("hidden");
3272 $formquestion = array(
3273 array(
'type' =>
'select',
'name' =>
'revertstock',
'label' => $langs->trans(
"RevertProductsToStock"),
'select_show_empty' => 0,
'values' => $selectyesno),
3274 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $selectwarehouse,
'tdclass' =>
'questionrevertstock hidden')
3278 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteBill'), $langs->trans(
'ConfirmDeleteBill'),
'confirm_delete', $formquestion, 1, 1);
3280 if ($action ==
'deletepayment') {
3281 $payment_id =
GETPOST(
'paiement_id');
3282 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&paiement_id='.$payment_id, $langs->trans(
'DeletePayment'), $langs->trans(
'ConfirmDeletePayment'),
'confirm_delete_paiement',
'', 0, 1);
3286 if ($action ==
'ask_deleteline') {
3287 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
3290 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
3291 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
3292 if (empty($reshook)) {
3293 $formconfirm .= $hookmanager->resPrint;
3294 } elseif ($reshook > 0) {
3295 $formconfirm = $hookmanager->resPrint;
3303 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
3305 $morehtmlref =
'<div class="refidno">';
3307 $morehtmlref .= $form->editfieldkey(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, (
int) $usercancreate,
'string',
'', 0, 1);
3308 $morehtmlref .= $form->editfieldval(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, $usercancreate,
'string',
'',
null,
null,
'', 1);
3310 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1,
'supplier');
3312 $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>';
3315 if (isModEnabled(
'project')) {
3316 $langs->load(
"projects");
3317 $morehtmlref .=
'<br>';
3318 if ($permissiontoadd) {
3319 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
3320 if ($action !=
'classify') {
3321 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.((int)
$object->id).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
3323 $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');
3325 if (!empty(
$object->fk_project)) {
3327 $proj->fetch(
$object->fk_project);
3328 $morehtmlref .= $proj->getNomUrl(1);
3330 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
3335 $morehtmlref .=
'</div>';
3337 $object->totalpaid = $totalpaid;
3339 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
3342 $parameters = array();
3344 $reshook = $hookmanager->executeHooks(
'tabContentViewSupplierInvoice', $parameters,
$object, $action);
3345 if (empty($reshook)) {
3346 print
'<div class="fichecenter">';
3347 print
'<div class="fichehalfleft">';
3348 print
'<div class="underbanner clearboth"></div>';
3350 print
'<table class="border tableforfield centpercent">';
3353 print
'<tr><td class="titlefield">'.$langs->trans(
'Type').
'</td><td>';
3354 print
'<span class="badgeneutral">';
3358 print
' '.$object->getSubtypeLabel(
'facture_fourn');
3362 $facreplaced->fetch(
$object->fk_facture_source);
3363 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
'</span>';
3366 if (
$object->fk_facture_source > 0) {
3368 $facusing->fetch(
$object->fk_facture_source);
3369 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
'</span>';
3371 $langs->load(
"errors");
3372 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"WarningCorrectedInvoiceNotFound").
'</span>';
3377 $object->getListIdAvoirFromInvoice();
3379 if (!empty(
$object->creditnote_ids)) {
3380 $invoicecredits = array();
3381 foreach (
$object->creditnote_ids as $invoiceid) {
3383 $creditnote->fetch($invoiceid);
3384 $invoicecredits[] = $creditnote->getNomUrl(1);
3386 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"InvoiceHasAvoir") . (count($invoicecredits) ?
' ' :
'') . implode(
',', $invoicecredits);
3389 if (isset($objectidnext) && $objectidnext > 0) {
3392 $facthatreplace->fetch($objectidnext);
3393 print
' <span class="opacitymediumbycolor paddingleft">'.str_replace(
'{s1}', $facthatreplace->getNomUrl(1), $langs->transnoentities(
"ReplacedByInvoice",
'{s1}')).
'</span>';
3397 $result = $discount->fetch(0, 0,
$object->id);
3399 print
' <span class="opacitymediumbycolor paddingleft">';
3400 $s = $langs->trans(
"CreditNoteConvertedIntoDiscount",
'{s1}',
'{s2}');
3401 $s = str_replace(
'{s1}',
$object->getLibType(1), $s);
3402 $s = str_replace(
'{s2}', $discount->getNomUrl(1,
'discount'), $s);
3404 print
'</span><br>';
3408 if (
$object->fk_fac_rec_source > 0) {
3410 $result = $tmptemplate->fetch(
$object->fk_fac_rec_source);
3412 print
' <span class="opacitymediumbycolor paddingleft">';
3413 $link =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.$tmptemplate->id.
'">'.
dol_escape_htmltag($tmptemplate->title).
'</a>';
3414 $s = $langs->transnoentities(
"GeneratedFromSupplierTemplate", $link);
3424 print
'<!-- Discounts -->'.
"\n";
3425 print
'<tr><td>'.$langs->trans(
'DiscountStillRemaining');
3428 $thirdparty = $societe;
3430 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
3436 print
'<td>'.$form->editfieldkey(
"Label",
'label',
$object->label,
$object, (
int) $usercancreate).
'</td>';
3437 print
'<td>'.$form->editfieldval(
"Label",
'label',
$object->label,
$object, $usercancreate).
'</td>';
3445 print $form->editfieldkey(
"DateInvoice",
'datef', (
string)
$object->date,
$object, (int) $form_permission,
'datepicker');
3446 print
'</td><td colspan="3">';
3447 print $form->editfieldval(
"Date",
'datef',
$object->date,
$object, $form_permission,
'datepicker');
3451 $langs->load(
'bills');
3452 print
'<tr><td class="nowrap">';
3453 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3454 print $langs->trans(
'PaymentConditions');
3456 if ($action !=
'editconditions' && $form_permission) {
3457 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>';
3459 print
'</tr></table>';
3461 if ($action ==
'editconditions') {
3462 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id');
3464 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'none');
3471 print $form->editfieldkey(
"DateMaxPayment",
'date_lim_reglement', (
string)
$object->date_echeance,
$object, (
int) $form_permission,
'datepicker');
3473 print $form->editfieldval(
"DateMaxPayment",
'date_lim_reglement',
$object->date_echeance,
$object, $form_permission,
'datepicker');
3474 if ($action !=
'editdate_lim_reglement' &&
$object->hasDelay()) {
3480 $langs->load(
'bills');
3481 print
'<tr><td class="nowrap">';
3482 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3483 print $langs->trans(
'PaymentMode');
3485 if ($action !=
'editmode' && $form_permission) {
3486 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>';
3488 print
'</tr></table>';
3490 if ($action ==
'editmode') {
3491 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
3493 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
3498 if (isModEnabled(
"bank")) {
3499 print
'<tr><td class="nowrap">';
3500 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3501 print $langs->trans(
'BankAccount');
3503 if ($action !=
'editbankaccount' && $usercancreate) {
3504 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>';
3506 print
'</tr></table>';
3508 if ($action ==
'editbankaccount') {
3509 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
3511 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'none');
3519 print
'<tr><td class="nowrap">';
3520 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3521 print $langs->trans(
'VATReverseCharge');
3523 if ($action !=
'editvatreversecharge' && $usercancreate) {
3524 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editvatreversecharge&id='.
$object->id.
'">'.
img_edit($langs->trans(
'SetVATReverseCharge'), 1).
'</a></td>';
3526 print
'</tr></table>';
3528 if ($action ==
'editvatreversecharge') {
3529 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
3530 print
'<input type="hidden" name="action" value="setvatreversecharge">';
3531 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3533 print
'<input type="checkbox" name="vat_reverse_charge"' . (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
'>';
3535 print
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
3538 print
'<input type="checkbox" name="vat_reverse_charge"'. (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
' disabled>';
3544 if (isModEnabled(
'incoterm')) {
3546 print
'<table width="100%" class="nobordernopadding"><tr><td>';
3547 print $langs->trans(
'IncotermLabel');
3548 print
'<td><td class="right">';
3549 if ($usercancreate) {
3550 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.
$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit().
'</a>';
3554 print
'</td></tr></table>';
3557 if ($action !=
'editincoterm') {
3558 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3560 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
3566 if (isModEnabled(
'intracommreport')) {
3567 $langs->loadLangs(array(
"intracommreport"));
3568 print
'<!-- If module intracomm on -->'.
"\n";
3570 print
'<table class="nobordernopadding centpercent"><tr><td>';
3571 print $langs->trans(
'IntracommReportTransportMode');
3573 if ($action !=
'edittransportmode' && ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"))) {
3574 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edittransportmode&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit().
'</a></td>';
3576 print
'</tr></table>';
3579 if ($action ==
'edittransportmode') {
3580 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->transport_mode_id,
'transport_mode_id', 1, 1);
3582 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->transport_mode_id,
'none');
3588 if (isModEnabled(
'category')) {
3590 print
'<table class="nobordernopadding centpercent"><tr><td>';
3591 print $langs->trans(
"Categories");
3592 print
'<td><td class="right">';
3593 if ($usercancreate) {
3594 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.
$object->id.
'&action=edittags&token='.
newToken().
'">'.
img_edit().
'</a>';
3598 print
'</td></tr></table>';
3601 if ($action ==
'edittags') {
3602 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?facid='.
$object->id.
'">';
3603 print
'<input type="hidden" name="action" value="settags">';
3604 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3605 print $form->selectCategories(Categorie::TYPE_SUPPLIER_INVOICE,
'categories',
$object);
3606 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
3609 print $form->showCategories(
$object->id, Categorie::TYPE_SUPPLIER_INVOICE, 1);
3617 if (
$object->status != $object::STATUS_DRAFT) {
3621 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3626 print
'<div class="fichehalfright">';
3627 print
'<div class="underbanner clearboth"></div>';
3629 print
'<table class="border tableforfield centpercent">';
3631 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
3634 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
3635 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3636 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3637 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3642 print
'<td>' . $langs->trans(
'AmountVAT') .
'</td>';
3643 print
'<td class="nowrap amountcard right">';
3644 if (
GETPOST(
'calculationrule')) {
3645 $calculationrule =
GETPOST(
'calculationrule',
'alpha');
3647 $calculationrule = (!
getDolGlobalString(
'MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND_SUPPLIER') ?
'totalofround' :
'roundoftotal');
3649 if ($calculationrule ==
'totalofround') {
3650 $calculationrulenum = 1;
3652 $calculationrulenum = 2;
3655 if (
$object->getVentilExportCompta() == 0) {
3656 $s =
'<span class="hideonsmartphone opacitymedium">' . $langs->trans(
"ReCalculate") .
' </span>';
3657 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&token='.newToken().
'&calculationrule=totalofround">' . $langs->trans(
"Mode1") .
'</a>';
3659 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&token='.newToken().
'&calculationrule=roundoftotal">' . $langs->trans(
"Mode2") .
'</a>';
3660 print
'<div class="inline-block">';
3661 print $form->textwithtooltip($s, $langs->trans(
"CalculationRuleDesc", $calculationrulenum) .
'<br>' . $langs->trans(
"CalculationRuleDescSupplier"), 2, 1,
img_picto(
'',
'help'),
'', 3,
'', 0,
'recalculate');
3662 print
' ';
3665 print
'<span class="nowraponall">'.price(
$object->total_tva, 1, $langs, 0, -1, -1,
$conf->currency).
'</span>';
3667 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3668 print
'<td class="nowraponall amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3672 if ($societe->localtax1_assuj ==
"1") {
3674 print
'<td>' . $langs->transcountry(
"AmountLT1", $societe->country_code) .
'</td>';
3675 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 1, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3678 if ($societe->localtax2_assuj ==
"1") {
3680 print
'<td>' . $langs->transcountry(
"AmountLT2", $societe->country_code) .
'</td>';
3681 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 1, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3686 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
3687 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3688 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3689 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3707 if (isModEnabled(
'project')) {
3710 if (isModEnabled(
"bank")) {
3714 if (isModEnabled(
'incoterm')) {
3717 if (isModEnabled(
"multicurrency")) {
3722 if ($societe->localtax1_assuj ==
"1") {
3725 if ($societe->localtax2_assuj ==
"1") {
3729 $sql =
'SELECT p.datep as dp, p.ref, p.num_paiement as num_payment, p.rowid, p.fk_bank,';
3730 $sql .=
' c.id as payment_type, c.code as payment_code,';
3731 $sql .=
' pf.amount,';
3732 $sql .=
' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal';
3733 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn as p';
3734 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
3735 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
3736 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id';
3737 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid';
3738 $sql .=
' WHERE pf.fk_facturefourn = '.((int)
$object->id);
3739 $sql .=
' ORDER BY p.datep, p.tms';
3741 $result = $db->query($sql);
3743 $num = $db->num_rows($result);
3746 print
'<div class="div-table-responsive-no-min">';
3747 print
'<table class="noborder paymenttable centpercent">';
3748 print
'<tr class="liste_titre">';
3750 print
'<td><span class="hideonsmartphone">'.$langs->trans(
'Date').
'</span></td>';
3751 print
'<td><span class="hideonsmartphone">'.$langs->trans(
'Type').
'</span></td>';
3752 if (isModEnabled(
"bank")) {
3753 print
'<td class="right">'.$langs->trans(
'BankAccount').
'</td>';
3755 print
'<td class="right">'.$langs->trans(
'Amount').
'</td>';
3756 print
'<td width="18"> </td>';
3761 $objp = $db->fetch_object($result);
3763 $paymentstatic->id = $objp->rowid;
3764 $paymentstatic->datepaye = $db->jdate($objp->dp);
3765 $paymentstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
3766 $paymentstatic->num_payment = $objp->num_payment;
3768 $paymentstatic->paiementcode = $objp->payment_code;
3769 $paymentstatic->type_code = $objp->payment_code;
3770 $paymentstatic->type_label = $objp->payment_type;
3772 print
'<tr class="oddeven">';
3773 print
'<td class="nowraponall">';
3774 print $paymentstatic->getNomUrl(1);
3776 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
'</td>';
3777 $s = $form->form_modes_reglement(
'', $objp->payment_type,
'none',
'', 1, 0,
'', 1).
' '.$objp->num_payment;
3778 print
'<td class="tdoverflowmax125" title="'.dol_escape_htmltag($s).
'">';
3781 if (isModEnabled(
"bank")) {
3782 $bankaccountstatic->id = $objp->baid;
3783 $bankaccountstatic->ref = $objp->baref;
3784 $bankaccountstatic->label = $objp->baref;
3785 $bankaccountstatic->number = $objp->banumber;
3787 if (isModEnabled(
'accounting')) {
3788 $bankaccountstatic->account_number = $objp->account_number;
3791 $accountingjournal->fetch($objp->fk_accountancy_journal);
3792 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
3795 print
'<td class="right">';
3796 if ($objp->baid > 0) {
3797 print $bankaccountstatic->getNomUrl(1,
'transactions');
3801 print
'<td class="right">'.price($sign * $objp->amount).
'</td>';
3802 print
'<td class="center">';
3804 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deletepayment&token='.
newToken().
'&paiement_id='.$objp->rowid.
'">';
3810 $totalpaid += $objp->amount;
3814 print
'<tr class="oddeven"><td colspan="'.$nbcols.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td><td></td><td></td></tr>';
3837 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3838 print
'<span class="opacitymedium">';
3840 print $langs->trans(
'AlreadyPaidNoCreditNotesNoDeposits');
3842 print $langs->trans(
'AlreadyPaid');
3845 print
'</td><td class="right"'.(($totalpaid > 0) ?
' class="amountalreadypaid"' :
'').
'>'.
price($totalpaid).
'</td><td> </td></tr>';
3848 $resteapayeraffiche = $resteapayer;
3850 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
3853 $creditnoteamount = 0;
3856 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
3857 $sql .=
" re.description, re.fk_invoice_supplier_source";
3858 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
3859 $sql .=
" WHERE fk_invoice_supplier = ".((int)
$object->id);
3860 $resql = $db->query($sql);
3862 $num = $db->num_rows($resql);
3866 $obj = $db->fetch_object($resql);
3867 $invoice->fetch($obj->fk_invoice_supplier_source);
3868 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3870 print $langs->trans(
"CreditNote").
' ';
3873 print $langs->trans(
"Deposit").
' ';
3875 print $invoice->getNomUrl(0);
3877 print
'<td class="right">'.price($obj->amount_ttc).
'</td>';
3878 print
'<td class="right">';
3879 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=unlinkdiscount&discountid='.$obj->rowid.
'">';
3880 print
img_picto($langs->transnoentitiesnoconv(
"RemoveDiscount"),
'unlink');
3885 $creditnoteamount += $obj->amount_ttc;
3888 $depositamount += $obj->amount_ttc;
3897 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3898 print
'<span class="opacitymedium">';
3899 print $form->textwithpicto($langs->trans(
"Discount"), $langs->trans(
"HelpEscompte"), - 1);
3901 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3902 $resteapayeraffiche = 0;
3903 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3907 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3908 print
'<span class="opacitymedium">';
3909 print $form->textwithpicto($langs->trans(
"Abandoned"), $langs->trans(
"HelpAbandonBadCustomer"), - 1);
3911 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3913 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3917 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3918 print
'<span class="opacitymedium">';
3919 print $form->textwithpicto($langs->trans(
"ProductReturned"), $langs->trans(
"HelpAbandonProductReturned"), - 1);
3921 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3922 $resteapayeraffiche = 0;
3923 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3927 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3928 $text = $langs->trans(
"HelpAbandonOther");
3930 $text .=
'<br><br><b>'.$langs->trans(
"Reason").
'</b>:'.
$object->close_note;
3932 print
'<span class="opacitymedium">';
3934 print $form->textwithpicto($langs->trans(
"Abandoned"), $text, - 1);
3936 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3937 $resteapayeraffiche = 0;
3938 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3942 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3943 print
'<span class="opacitymedium">';
3944 print $langs->trans(
"Billed");
3946 print
'</td><td class="right">'.price(
$object->total_ttc).
'</td><td> </td></tr>';
3949 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3950 print
'<span class="opacitymedium">';
3951 print $langs->trans(
'RemainderToPay');
3952 if ($resteapayeraffiche < 0) {
3953 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
3957 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayeraffiche).
'</td><td> </td></tr>';
3960 if (isModEnabled(
'multicurrency') &&
$object->multicurrency_code !=
$conf->currency ||
$object->multicurrency_tx != 1) {
3961 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3962 print
'<span class="opacitymedium">';
3963 print $langs->trans(
'RemainderToPayMulticurrency');
3964 if ($resteapayeraffiche < 0) {
3965 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
3969 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price(
price2num($multicurrency_resteapayer,
'MT'), 0, $langs, 1, -1, -1,
$object->multicurrency_code).
'</td><td> </td></tr>';
3972 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3975 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3976 print $langs->trans(
'AlreadyPaidBack');
3977 print
' :</td><td class="right">'.price($sign * $totalpaid).
'</td><td> </td></tr>';
3980 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"Billed").
' :</td><td class="right">'.
price($sign *
$object->total_ttc).
'</td><td> </td></tr>';
3983 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3984 print
'<span class="opacitymedium">';
3985 print $langs->trans(
'RemainderToPayBack');
3986 if ($resteapayeraffiche > 0) {
3987 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
3991 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($sign * $resteapayeraffiche).
'</td><td> </td></tr>';
3994 if (isModEnabled(
'multicurrency') &&
$object->multicurrency_code !=
$conf->currency ||
$object->multicurrency_tx != 1) {
3995 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3996 print
'<span class="opacitymedium">';
3997 print $langs->trans(
'RemainderToPayBackMulticurrency');
3998 if ($resteapayeraffiche > 0) {
3999 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
4003 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.(!empty(
$object->multicurrency_code) ?
$object->multicurrency_code :
$conf->currency).
' '.
price(
price2num($sign *
$object->multicurrency_tx * $resteapayeraffiche,
'MT')).
'</td><td> </td></tr>';
4018 print
'<div class="clearboth"></div><br>';
4021 $blocname =
'contacts';
4022 $title = $langs->trans(
'ContactsAddresses');
4023 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
4028 $blocname =
'notes';
4029 $title = $langs->trans(
'Notes');
4030 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
4037 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
4038 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4039 print
'<input type="hidden" name="action" value="'.(($action !=
'editline') ?
'addline' :
'updateline').
'">';
4040 print
'<input type="hidden" name="mode" value="">';
4041 print
'<input type="hidden" name="page_y" value="">';
4042 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
4043 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
4044 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
4047 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
4050 print
'<div class="div-table-responsive-no-min">';
4051 print
'<table id="tablelines" class="noborder noshadow centpercent">';
4053 global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax;
4056 $inputalsopricewithtax = 1;
4057 $senderissupplier = 2;
4058 if (
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY')) {
4059 $senderissupplier =
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY');
4064 $object->printObjectLines($action, $societe, $mysoc, $lineid, 1);
4071 if ($action !=
'editline') {
4074 $parameters = array();
4075 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters,
$object, $action);
4079 if (empty($reshook)) {
4080 $object->formAddObjectLine(1, $societe, $mysoc);
4093 if ($action !=
'presend') {
4096 print
'<div class="tabsAction">';
4098 $parameters = array();
4099 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
4101 if (empty($reshook)) {
4105 $ventilExportCompta =
$object->getVentilExportCompta();
4107 if ($ventilExportCompta == 0) {
4108 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
'Modify').
'</a>';
4110 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseDispatchedInBookkeeping").
'">'.$langs->trans(
'Modify').
'</span>';
4115 $result = $discount->fetch(0, 0,
$object->id);
4122 if (!$objectidnext &&
$object->close_code !=
'replaced' && $usercancreate) {
4123 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=reopen&token='.
newToken().
'">'.$langs->trans(
'ReOpen').
'</a>';
4125 if ($usercancreate) {
4126 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseReplacedInvoice").
'">'.$langs->trans(
'ReOpen').
'</span>';
4128 print
'<span class="butActionRefused classfortooltip">'.$langs->trans(
'ReOpen').
'</span>';
4138 if ($usercanvalidate) {
4139 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=valid&token='.
newToken().
'"';
4140 print
'>'.$langs->trans(
'Validate').
'</a>';
4142 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'"';
4143 print
'>'.$langs->trans(
'Validate').
'</a>';
4149 if (empty($user->socid)) {
4152 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a>';
4154 print
'<span class="butActionRefused classfortooltip">'.$langs->trans(
'SendMail').
'</span>';
4161 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" 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>';
4168 if ($resteapayer == 0) {
4169 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseRemainderToPayIsZero").
'">'.$langs->trans(
'DoPaymentBack').
'</span>';
4171 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>';
4177 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.
newToken().
'">'.$langs->trans(
'ConvertExcessPaidToReduc').
'</a>';
4181 && (
getDolGlobalString(
'SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED') ||
$object->getSommePaiement() == 0)
4183 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>';
4187 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.
newToken().
'">'.$langs->trans(
'ConvertToReduc').
'</a>';
4198 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=paid&token='.
newToken().
'">'.$langs->trans(
'ClassifyPaid').
'</a>';
4203 if ($totalpaid > 0 || $totalcreditnotes > 0) {
4205 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=paid&token='.
newToken().
'">'.$langs->trans(
'ClassifyPaidPartially').
'</a>';
4208 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=canceled">'.$langs->trans(
'ClassifyCanceled').
'</a>';
4220 if (!$objectidnext) {
4221 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>';
4226 if ($action !=
'edit' && $usercancreate) {
4227 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=clone&socid='.
$object->socid.
'&token='.
newToken().
'">'.$langs->trans(
'ToClone').
'</a>';
4232 if (!$objectidnext && count(
$object->lines) > 0) {
4233 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.
$object->id.
'&action=create">'.$langs->trans(
"ChangeIntoRepeatableInvoice").
'</a>';
4238 if ($action !=
'confirm_edit' && $usercandelete) {
4239 $isErasable =
$object->is_erasable();
4241 $enableDelete =
false;
4243 $params = (empty(
$conf->use_javascript_ajax) ? array() : array(
'attr' => array(
'class' =>
'reposition')));
4245 if ($isErasable == -4) {
4246 $htmltooltip = $langs->trans(
"DisabledBecausePayments");
4247 } elseif ($isErasable == -3) {
4248 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastSituationInvoice");
4249 } elseif ($isErasable == -2) {
4250 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastInvoice");
4251 } elseif ($isErasable == -1) {
4252 $htmltooltip = $langs->trans(
"DisabledBecauseDispatchedInBookkeeping");
4253 } elseif ($isErasable <= 0) {
4254 $htmltooltip = $langs->trans(
"DisabledBecauseNotErasable");
4256 $enableDelete =
true;
4259 print
dolGetButtonAction($htmltooltip, $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(), (
string)
$object->id, $enableDelete, $params);
4263 if ($action !=
'confirm_edit') {
4264 print
'<div class="fichecenter"><div class="fichehalfleft">';
4271 $filedir =
$conf->fournisseur->facture->dir_output.
'/'.$subdir;
4272 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.
$object->id;
4273 $genallowed = $usercanread;
4274 $delallowed = $usercancreate;
4278 print $formfile->showdocuments(
'facture_fournisseur', $subdir, $filedir, $urlsource, (
int) $genallowed, (
int) $delallowed, $modelpdf, $genifempty, 0, 0, 40, 0,
'',
'',
'', $societe->default_lang);
4279 $somethingshown = $formfile->numoffiles;
4282 $tmparray = $form->showLinkToObjectBlock(
$object, array(), array(
'invoice_supplier'), 1);
4283 $linktoelem = $tmparray[
'linktoelem'];
4284 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
4285 print $htmltoenteralink;
4287 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
4289 print
'</div><div class="fichehalfright">';
4292 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
4294 $somethingshown = $formactions->showactions(
$object,
'invoice_supplier', $socid, 1,
'listaction'.($genallowed ?
'largetitle' :
''));
4296 print
'</div></div>';
4302 if (
GETPOST(
'modelselected')) {
4303 $action =
'presend';
4307 $modelmail =
'invoice_supplier_send';
4308 $defaulttopic =
'SendBillRef';
4309 $diroutput =
$conf->fournisseur->facture->dir_output;
4310 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
4311 $trackid =
'sinv'.$object->id;
4313 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage 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.
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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'.
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.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.