40require
'../../main.inc.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;
157$parameters = array(
'socid' => $socid);
158$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
163if (empty($reshook)) {
164 $backurlforlist = DOL_URL_ROOT.
'/fourn/facture/list.php';
166 if (empty($backtopage) || ($cancel && empty($id))) {
167 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
168 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
169 $backtopage = $backurlforlist;
171 $backtopage = DOL_URL_ROOT.
'/fourn/facture/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
177 if (!empty($backtopageforcancel)) {
178 header(
"Location: ".$backtopageforcancel);
180 } elseif (!empty($backtopage)) {
181 header(
"Location: ".$backtopage);
187 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
189 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
191 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
194 if (
GETPOST(
'linkedOrder') && empty($cancel) && $id > 0 && $permissiontoadd) {
197 $result =
$object->add_object_linked(
'order_supplier',
GETPOST(
'linkedOrder'));
201 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
203 '@phan-var-force FactureFournisseur $objectutil';
205 if (
GETPOST(
'newsupplierref',
'alphanohtml')) {
206 $objectutil->ref_supplier =
GETPOST(
'newsupplierref',
'alphanohtml');
210 $result = $objectutil->createFromClone($user, $id);
212 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
215 $langs->load(
"errors");
219 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' && $usercanvalidate) {
220 $idwarehouse =
GETPOST(
'idwarehouse');
225 $qualified_for_stock_change = 0;
227 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
229 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
233 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
234 $langs->load(
"stocks");
235 if (!$idwarehouse || $idwarehouse == -1) {
237 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
245 $result =
$object->validate($user,
'', $idwarehouse);
255 $outputlangs = $langs;
258 $newlang =
GETPOST(
'lang_id',
'aZ09');
261 $newlang =
$object->thirdparty->default_lang;
263 if (!empty($newlang)) {
265 $outputlangs->setDefaultLang($newlang);
270 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
277 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontodelete) {
281 $isErasable =
$object->is_erasable();
283 if ($usercandelete && $isErasable > 0) {
284 $revertstock =
GETPOST(
'revertstock');
287 $idwarehouse =
GETPOST(
'idwarehouse');
289 $qualified_for_stock_change = 0;
291 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
293 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
297 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
298 $langs->load(
"stocks");
299 if (!$idwarehouse || $idwarehouse == -1) {
301 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
304 $result =
$object->setDraft($user, $idwarehouse);
313 $result =
$object->delete($user);
315 header(
'Location: list.php?restore_lastsearch_values=1');
322 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
324 $result =
$object->deleteLine($lineid);
344 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
351 } elseif ($action ==
'unlinkdiscount' && $usercancreate) {
354 $result = $discount->fetch(
GETPOSTINT(
"discountid"));
355 $discount->unlink_invoice();
356 } elseif ($action ==
'confirm_paid' && $confirm ==
'yes' && $usercancreate) {
358 $result =
$object->setPaid($user);
362 } elseif ($action ==
'confirm_paid_partially' && $confirm ==
'yes' && $usercancreate) {
365 $close_code =
GETPOST(
"close_code",
'restricthtml');
366 $close_note =
GETPOST(
"close_note",
'restricthtml');
368 $result =
$object->setPaid($user, $close_code, $close_note);
373 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Reason")),
null,
'errors');
375 } elseif ($action ==
'confirm_canceled' && $confirm ==
'yes' && $usercancreate) {
378 $close_code =
GETPOST(
"close_code",
'restricthtml');
379 $close_note =
GETPOST(
"close_note",
'restricthtml');
381 $result =
$object->setCanceled($user, $close_code, $close_note);
386 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Reason")),
null,
'errors');
391 if ($action ==
'setref_supplier' && $usercancreate) {
394 if (
$object->update($user) < 0) {
398 $outputlangs = $langs;
401 $newlang =
GETPOST(
'lang_id',
'aZ09');
404 $newlang =
$object->thirdparty->default_lang;
406 if (!empty($newlang)) {
408 $outputlangs->setDefaultLang($newlang);
412 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
418 if ($action ==
'setconditions' && $usercancreate) {
420 $object->cond_reglement_code = 0;
421 $object->cond_reglement_id = 0;
436 $new_date_echeance =
$object->calculate_date_lim_reglement();
437 if ($new_date_echeance) {
438 $object->date_echeance = $new_date_echeance;
443 $result =
$object->update($user);
455 } elseif ($action ==
'set_incoterms' && isModEnabled(
'incoterm') && $usercancreate) {
458 } elseif ($action ==
'setmode' && $usercancreate) {
461 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
463 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
464 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
467 } elseif ($action ==
'setbankaccount' && $usercancreate) {
470 } elseif ($action ==
'setvatreversecharge' && $usercancreate) {
472 $vatreversecharge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
473 $result =
$object->setVATReverseCharge($vatreversecharge);
476 if ($action ==
'settransportmode' && $usercancreate) {
479 } elseif ($action ==
'setlabel' && $usercancreate) {
483 $result =
$object->update($user);
487 } elseif ($action ==
'setdatef' && $usercancreate) {
491 setEventMessages($langs->trans(
"WarningInvoiceDateInFuture"),
null,
'warnings');
493 setEventMessages($langs->trans(
"WarningInvoiceDateTooFarInFuture"),
null,
'warnings');
500 $date_echence_calc =
$object->calculate_date_lim_reglement();
501 if (!empty(
$object->date_echeance)) {
502 $object->date_echeance = $date_echence_calc;
508 $result =
$object->update($user);
512 } elseif ($action ==
'setdate_lim_reglement' && $usercancreate) {
517 setEventMessages($langs->trans(
"DatePaymentTermCantBeLowerThanObjectDate"),
null,
'warnings');
519 $result =
$object->update($user);
523 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
539 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
541 $discount->fetch(
GETPOSTINT(
"remise_id_for_payment"));
545 $remaintopay =
$object->getRemainToPay(0);
549 setEventMessages($langs->trans(
"ErrorDiscountLargerThanRemainToPaySplitItBefore"),
null,
'errors');
553 $result = $discount->link_to_invoice(0, $id);
560 $newremaintopay =
$object->getRemainToPay(0);
561 if ($newremaintopay == 0) {
572 $outputlangs = $langs;
575 $newlang =
GETPOST(
'lang_id',
'aZ09');
578 $newlang =
$object->thirdparty->default_lang;
580 if (!empty($newlang)) {
582 $outputlangs->setDefaultLang($newlang);
586 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
591 } elseif ($action ==
'confirm_converttoreduc' && $confirm ==
'yes' && $usercancreate) {
599 $result = $discountcheck->fetch(0, 0,
$object->id);
611 $amount_ht = $amount_tva = $amount_ttc = array();
612 $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array();
616 foreach (
$object->lines as $line) {
617 if ($line->product_type < 9 && $line->total_ht != 0) {
618 $keyforvatrate = $line->tva_tx.($line->vat_src_code ?
' ('.$line->vat_src_code.
')' :
'');
620 $amount_ht[$keyforvatrate] += $line->total_ht;
621 $amount_tva[$keyforvatrate] += $line->total_tva;
622 $amount_ttc[$keyforvatrate] += $line->total_ttc;
623 $multicurrency_amount_ht[$keyforvatrate] += $line->multicurrency_total_ht;
624 $multicurrency_amount_tva[$keyforvatrate] += $line->multicurrency_total_tva;
625 $multicurrency_amount_ttc[$keyforvatrate] += $line->multicurrency_total_ttc;
629 '@phan-var-force array<string,float> $amount_ht
630 @phan-var-force array<string,float> $amount_tva
631 @phan-var-force array<string,float> $amount_ttc
632 @phan-var-force array<string,float> $multicurrency_amount_ht
633 @phan-var-force array<string,float> $multicurrency_amount_tva
634 @phan-var-force array<string,float> $multicurrency_amount_ttc';
638 $alreadypaid =
$object->getSommePaiement();
639 if ($alreadypaid && abs($alreadypaid) < abs(
$object->total_ttc)) {
640 $ratio = abs((
$object->total_ttc - $alreadypaid) /
$object->total_ttc);
641 foreach ($amount_ht as $vatrate => $val) {
642 $amount_ht[$vatrate] =
price2num($amount_ht[$vatrate] * $ratio,
'MU');
643 $amount_tva[$vatrate] =
price2num($amount_tva[$vatrate] * $ratio,
'MU');
644 $amount_ttc[$vatrate] =
price2num($amount_ttc[$vatrate] * $ratio,
'MU');
645 $multicurrency_amount_ht[$vatrate] =
price2num($multicurrency_amount_ht[$vatrate] * $ratio,
'MU');
646 $multicurrency_amount_tva[$vatrate] =
price2num($multicurrency_amount_tva[$vatrate] * $ratio,
'MU');
647 $multicurrency_amount_ttc[$vatrate] =
price2num($multicurrency_amount_ttc[$vatrate] * $ratio,
'MU');
656 $discount->description =
'(CREDIT_NOTE)';
658 $discount->description =
'(DEPOSIT)';
660 $discount->description =
'(EXCESS PAID)';
662 setEventMessages($langs->trans(
'CantConvertToReducAnInvoiceOfThisType'),
null,
'errors');
664 $discount->discount_type = 1;
665 $discount->fk_soc =
$object->socid;
666 $discount->socid =
$object->socid;
667 $discount->fk_invoice_supplier_source =
$object->id;
675 $sql =
'SELECT SUM(pf.amount) as total_paiements';
676 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.
'paiementfourn as p';
677 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN ('.
getEntity(
'c_paiement').
')';
678 $sql .=
' WHERE pf.fk_facturefourn = '.((int)
$object->id);
679 $sql .=
' AND pf.fk_paiementfourn = p.rowid';
680 $sql .=
' AND p.entity IN ('.getEntity(
'invoice').
')';
682 $resql = $db->query($sql);
687 $res = $db->fetch_object($resql);
688 $total_paiements = $res->total_paiements;
691 $total_creditnote_and_deposit = 0;
692 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
693 $sql .=
" re.description, re.fk_invoice_supplier_source";
694 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
695 $sql .=
" WHERE fk_invoice_supplier = ".((int)
$object->id);
696 $resql = $db->query($sql);
697 if (!empty($resql)) {
698 while ($obj = $db->fetch_object($resql)) {
699 $total_creditnote_and_deposit += $obj->amount_ttc;
705 $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit -
$object->total_ttc;
706 $discount->amount_tva = 0;
707 $discount->tva_tx = 0;
708 $discount->vat_src_code =
'';
711 $discount->multicurrency_code =
$object->multicurrency_code;
712 $discount->multicurrency_tx =
$object->multicurrency_tx;
713 $discount->multicurrency_total_ht = $discount->multicurrency_total_ttc = (float)
price2num((
float) $discount->amount_ttc * (float)
$object->multicurrency_tx,
'MT');
714 $discount->multicurrency_total_tva = 0;
716 $discount->multicurrency_amount_ht = $discount->multicurrency_amount_ttc = $discount->multicurrency_total_ttc;
717 $discount->multicurrency_amount_tva = 0;
719 $result = $discount->create($user);
725 foreach ($amount_ht as $tva_tx => $xxx) {
726 $discount->amount_ht = abs((
float) $amount_ht[$tva_tx]);
727 $discount->amount_tva = abs((
float) $amount_tva[$tva_tx]);
728 $discount->amount_ttc = abs((
float) $amount_ttc[$tva_tx]);
730 $discount->multicurrency_code =
$object->multicurrency_code;
731 $discount->multicurrency_tx =
$object->multicurrency_tx;
732 $discount->multicurrency_total_ht = abs((
float) $multicurrency_amount_ht[$tva_tx]);
733 $discount->multicurrency_total_tva = abs((
float) $multicurrency_amount_tva[$tva_tx]);
734 $discount->multicurrency_total_ttc = abs((
float) $multicurrency_amount_ttc[$tva_tx]);
736 $discount->multicurrency_amount_ht = abs((
float) $discount->multicurrency_total_ht);
737 $discount->multicurrency_amount_tva = abs((
float) $discount->multicurrency_total_tva);
738 $discount->multicurrency_amount_ttc = abs((
float) $discount->multicurrency_total_ttc);
743 if (preg_match(
'/\((.*)\)/', $tva_tx, $reg)) {
744 $vat_src_code = $reg[1];
745 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx);
748 $discount->tva_tx = abs((
float) $tva_tx);
749 $discount->vat_src_code = $vat_src_code;
751 $result = $discount->create($user);
762 $result =
$object->setPaid($user);
777 } elseif ($action ==
'confirm_delete_paiement' && $confirm ==
'yes' && $usercancreate) {
782 $result = $paiementfourn->fetch(
GETPOST(
'paiement_id'));
784 $result = $paiementfourn->delete($user);
786 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
794 } elseif ($action ==
'add' && $usercancreate) {
799 $selectedLines =
GETPOST(
'toselect',
'array');
807 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
821 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
826 if (empty($dateinvoice)) {
827 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
839 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ReplaceInvoice")),
null,
'errors');
853 $object->date_echeance = $datedue;
859 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
860 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
862 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
863 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
884 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CorrectInvoice")),
null,
'errors');
887 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Supplier')),
null,
'errors');
892 if (empty($dateinvoice)) {
893 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
903 if (!
GETPOST(
'ref_supplier')) {
904 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'RefSupplierBill')),
null,
'errors');
912 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
927 $object->date_echeance = $datedue;
933 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
934 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
936 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
937 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
942 $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice :
'';
951 if (
GETPOSTINT(
'invoiceAvoirWithLines') == 1 && $id > 0) {
953 if ($facture_source->fetch(
$object->fk_facture_source) > 0) {
956 foreach ($facture_source->lines as $line) {
958 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
962 $line->fk_facture_fourn =
$object->id;
963 $line->fk_parent_line = $fk_parent_line;
965 $line->subprice = -$line->subprice;
966 $line->pa_ht = -((float) $line->pa_ht);
967 $line->total_ht = -$line->total_ht;
968 $line->total_tva = -$line->total_tva;
969 $line->total_ttc = -$line->total_ttc;
970 $line->total_localtax1 = -$line->total_localtax1;
971 $line->total_localtax2 = -$line->total_localtax2;
973 $result = $line->insert();
978 if ($result > 0 && $line->product_type == 9) {
979 $fk_parent_line = $result;
987 if (
GETPOSTINT(
'invoiceAvoirWithPaymentRestAmount') == 1 &&
$id > 0) {
989 if ($facture_source->fetch(
$object->fk_facture_source) > 0) {
990 $totalpaid = $facture_source->getSommePaiement();
991 $totalcreditnotes = $facture_source->getSumCreditNotesUsed();
992 $totaldeposits = $facture_source->getSumDepositsUsed();
993 $remain_to_pay = abs($facture_source->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits);
994 $desc = $langs->trans(
'invoiceAvoirLineWithPaymentRestAmount');
995 $retAddLine =
$object->addline($desc, $remain_to_pay, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
'TTC');
997 if ($retAddLine < 0) {
1005 if (empty($dateinvoice)) {
1007 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
1017 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
1027 $object->note_public = trim(
GETPOST(
'note_public',
'restricthtml'));
1028 $object->note_private = trim(
GETPOST(
'note_private',
'restricthtml'));
1039 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
1040 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
1044 $object->fac_rec = $fac_recid;
1046 $fac_rec->fetch(
$object->fac_rec);
1047 $fac_rec->fetch_lines();
1048 $object->lines = $fac_rec->lines;
1055 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Supplier')),
null,
'errors');
1060 if (empty($dateinvoice)) {
1061 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
1071 if (!
GETPOST(
'ref_supplier')) {
1072 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'RefSupplierBill')),
null,
'errors');
1080 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
1097 $object->date_echeance = $datedue;
1103 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
1104 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
1106 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
1107 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
1112 if (empty(
$object->date_echeance)) {
1113 $object->date_echeance =
$object->calculate_date_lim_reglement();
1119 if (!$error &&
GETPOST(
'origin',
'alpha') &&
GETPOST(
'originid')) {
1121 $element = $subelement =
GETPOST(
'origin',
'alpha');
1129 if ($element ==
'order') {
1130 $element = $subelement =
'commande';
1132 if ($element ==
'propal') {
1133 $element =
'comm/propal';
1134 $subelement =
'propal';
1136 if ($element ==
'contract') {
1137 $element = $subelement =
'contrat';
1139 if ($element ==
'order_supplier') {
1141 $subelement =
'fournisseur.commande';
1143 if ($element ==
'project') {
1144 $element =
'projet';
1151 $classname = ucfirst($subelement);
1152 if ($classname ==
'Fournisseur.commande') {
1153 $classname =
'CommandeFournisseur';
1155 $objectsrc =
new $classname($db);
1156 $objectsrc->fetch($originid);
1157 $objectsrc->fetch_thirdparty();
1164 if (
$object->origin ==
'reception') {
1165 $objectsrc->fetchObjectLinked();
1167 if (count($objectsrc->linkedObjectsIds[
'order_supplier']) > 0) {
1168 foreach ($objectsrc->linkedObjectsIds[
'order_supplier'] as $key => $value) {
1169 $object->linkedObjectsIds[
'order_supplier'] = $value;
1179 $classname = ucfirst($subelement);
1180 if ($classname ==
'Fournisseur.commande') {
1181 $classname =
'CommandeFournisseur';
1183 $srcobject =
new $classname($db);
1185 $result = $srcobject->fetch(
GETPOSTINT(
'originid'));
1188 $typeamount =
GETPOST(
'typedeposit',
'alpha');
1193 $amountdeposit = array();
1195 if ($typeamount ==
'amount') {
1196 $amount = $valuedeposit;
1198 $amount = $srcobject->total_ttc * ((float) $valuedeposit / 100);
1201 $TTotalByTva = array();
1202 foreach ($srcobject->lines as &$line) {
1203 if (!empty($line->special_code)) {
1206 $TTotalByTva[$line->tva_tx] += $line->total_ttc;
1208 '@phan-var-force array<string,float> $TTotalByTva';
1210 $amount_ttc_diff = 0.;
1211 foreach ($TTotalByTva as $tva => &$total) {
1212 $coef = $total / $srcobject->total_ttc;
1213 $am = $amount * $coef;
1214 $amount_ttc_diff += $am;
1215 $amountdeposit[$tva] += $am / (1 + (float) $tva / 100);
1218 if ($typeamount ==
'amount') {
1219 $amountdeposit[0] = $valuedeposit;
1220 } elseif ($typeamount ==
'variable') {
1223 $lines = $srcobject->lines;
1224 $numlines = count($lines);
1225 for ($i = 0; $i < $numlines; $i++) {
1227 if (empty($lines[$i]->qty)) {
1230 if (!empty($lines[$i]->special_code)) {
1234 $totalamount += $lines[$i]->total_ht;
1235 $tva_tx = $lines[$i]->tva_tx;
1236 $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * (float) $valuedeposit) / 100;
1240 if ($totalamount == 0) {
1241 $amountdeposit[0] = 0;
1246 $amountdeposit[0] = 0;
1250 $amount_ttc_diff = $amountdeposit[0];
1253 foreach ($amountdeposit as $tva => $amount) {
1254 if (empty($amount)) {
1259 'amount' =>
'FixAmount',
1260 'variable' =>
'VarAmount'
1262 $descline =
'(DEPOSIT)';
1264 if ($typeamount ==
'amount') {
1265 $descline .=
' ('.price($valuedeposit, 0, $langs, 0, - 1, - 1, (!empty(
$object->multicurrency_code) ?
$object->multicurrency_code :
$conf->currency)).
')';
1266 } elseif ($typeamount ==
'variable') {
1267 $descline .=
' ('.$valuedeposit.
'%)';
1270 $descline .=
' - '.$srcobject->ref;
1300 $diff =
$object->total_ttc - $amount_ttc_diff;
1304 $subprice_diff =
$object->lines[0]->subprice - $diff / (1 +
$object->lines[0]->tva_tx / 100);
1310 $object->lines[0]->localtax1_tx,
1311 $object->lines[0]->localtax2_tx,
1313 $object->lines[0]->fk_product,
1316 $object->lines[0]->product_type,
1317 $object->lines[0]->remise_percent,
1319 $object->lines[0]->date_start,
1328 } elseif ($result > 0) {
1329 $lines = $srcobject->lines;
1330 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
1331 $srcobject->fetch_lines();
1332 $lines = $srcobject->lines;
1335 $num = count($lines);
1336 for ($i = 0; $i < $num; $i++) {
1337 if (!in_array($lines[$i]->
id, $selectedLines)) {
1341 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->product_label);
1342 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
1345 if (method_exists($lines[$i],
'fetch_optionals')) {
1346 $lines[$i]->fetch_optionals();
1351 $date_start = $lines[$i]->date_debut_prevue;
1352 if ($lines[$i]->date_debut_reel) {
1353 $date_start = $lines[$i]->date_debut_reel;
1355 if ($lines[$i]->date_start) {
1356 $date_start = $lines[$i]->date_start;
1358 $date_end = $lines[$i]->date_fin_prevue;
1359 if ($lines[$i]->date_fin_reel) {
1360 $date_end = $lines[$i]->date_fin_reel;
1362 if ($lines[$i]->date_end) {
1363 $date_end = $lines[$i]->date_end;
1366 $tva_tx = $lines[$i]->tva_tx;
1368 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', (
string) $tva_tx)) {
1369 $tva_tx .=
' ('.$lines[$i]->vat_src_code.
')';
1373 $object->special_code = $lines[$i]->special_code;
1378 $pu_currency = $lines[$i]->multicurrency_subprice;
1380 $pu = $lines[$i]->subprice;
1389 $lines[$i]->localtax1_tx,
1390 $lines[$i]->localtax2_tx,
1392 $lines[$i]->fk_product,
1393 $lines[$i]->remise_percent,
1397 $lines[$i]->info_bits,
1402 $lines[$i]->array_options,
1403 $lines[$i]->fk_unit,
1406 $lines[$i]->ref_supplier,
1407 $lines[$i]->special_code
1424 } elseif (!$error) {
1434 $langs->load(
"errors");
1444 $outputlangs = $langs;
1445 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1452 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
1455 } elseif ($action ==
'updateline' && $usercancreate) {
1459 if (!
$object->fetch($id) > 0) {
1465 $tva_tx = str_replace(
'*',
'', $tva_tx);
1467 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_subprice') !=
'') {
1469 $price_base_type =
'HT';
1472 $price_base_type =
'TTC';
1475 if (
GETPOST(
'productid') > 0) {
1477 if (
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY') == 1) {
1479 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1484 $prod->fetch(
GETPOST(
'productid'));
1485 $label = $prod->description;
1486 if (trim(
GETPOST(
'product_desc',
'restricthtml')) != trim($label)) {
1487 $label =
GETPOST(
'product_desc',
'restricthtml');
1490 $type = $prod->type;
1492 $label =
GETPOST(
'product_desc',
'restricthtml');
1501 if (preg_match(
'/\*/', $tva_tx)) {
1506 $tva_tx = str_replace(
'*',
'', $tva_tx);
1514 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1515 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1517 if (is_array($extralabelsline)) {
1518 foreach ($extralabelsline as $key => $value) {
1519 unset($_POST[
"options_".$key]);
1523 $result =
$object->updateline(
1545 unset($_POST[
'label']);
1546 unset($_POST[
'fourn_ref']);
1547 unset($_POST[
'date_starthour']);
1548 unset($_POST[
'date_startmin']);
1549 unset($_POST[
'date_startsec']);
1550 unset($_POST[
'date_startday']);
1551 unset($_POST[
'date_startmonth']);
1552 unset($_POST[
'date_startyear']);
1553 unset($_POST[
'date_endhour']);
1554 unset($_POST[
'date_endmin']);
1555 unset($_POST[
'date_endsec']);
1556 unset($_POST[
'date_endday']);
1557 unset($_POST[
'date_endmonth']);
1558 unset($_POST[
'date_endyear']);
1559 unset($_POST[
'price_ttc']);
1560 unset($_POST[
'price_ht']);
1567 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') && (
GETPOST(
'alldate_start',
'alpha') ||
GETPOST(
'alldate_end',
'alpha')) && $usercancreate) {
1571 foreach (
$object->lines as $line) {
1572 if ($line->product_type == 1) {
1573 $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);
1576 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') !=
'' && $usercancreate) {
1578 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
1579 $vat_rate = str_replace(
'*',
'', $vat_rate);
1582 foreach (
$object->lines as $line) {
1583 $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);
1585 } elseif ($action ==
'addline' && $usercancreate) {
1594 $ret =
$object->fetch_thirdparty();
1596 $langs->load(
'errors');
1601 $product_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
1605 $prod_entry_mode =
GETPOST(
'prod_entry_mode');
1606 if ($prod_entry_mode ==
'free') {
1613 $price_ht_devise =
'';
1615 $price_ttc_devise =
'';
1617 if (
GETPOST(
'price_ht') !==
'') {
1620 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
1623 if (
GETPOST(
'price_ttc') !==
'') {
1626 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
1627 $price_ttc_devise =
price2num(
GETPOST(
'multicurrency_price_ttc'),
'CU', 2);
1634 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef,
'alpha'),
'', 2) : 0);
1635 if (empty($remise_percent)) {
1636 $remise_percent = 0;
1640 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1641 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1643 if (is_array($extralabelsline)) {
1645 foreach ($extralabelsline as $key => $value) {
1646 unset($_POST[
"options_".$key]);
1650 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
1651 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1654 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') &&
GETPOST(
'type') < 0) {
1655 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
1660 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1')
1661 && (((
float) $price_ht < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) || $price_ht ===
'')
1662 && (((
float) $price_ht_devise < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) || $price_ht_devise ===
'')
1663 && ((
float) $price_ttc < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES') || $price_ttc ===
'')
1664 && ((
float) $price_ttc_devise < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES') || $price_ttc_devise ===
'')
1665 &&
$object->type != $object::TYPE_CREDIT_NOTE) {
1666 if (((
float) $price_ht < 0 || (
float) $price_ttc < 0) && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) {
1667 $langs->load(
"errors");
1668 if (
$object->type == $object::TYPE_DEPOSIT) {
1670 setEventMessages($langs->trans(
"ErrorLinesCantBeNegativeOnDeposits"),
null,
'errors');
1672 setEventMessages($langs->trans(
"ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv(
"UnitPrice"), $langs->transnoentitiesnoconv(
"CustomerAbsoluteDiscountShort")),
null,
'errors');
1677 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' && $price_ht_devise ===
'') {
1678 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'UnitPrice')),
null,
'errors');
1682 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') && !
GETPOST(
'dp_desc')) {
1683 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
1686 if (!
GETPOST(
'qty',
'alpha')) {
1687 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1691 if (!$error && isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1692 if ($combinations =
GETPOST(
'combinations',
'array')) {
1696 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1697 $idprod = $res->fk_product_child;
1699 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1705 if ($prod_entry_mode !=
'free' && empty($error)) {
1709 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
1714 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
1716 $res = $productsupplier->fetch($idprod);
1719 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
1721 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1722 if ($productsupplier->fourn_socid != $socid) {
1723 $productsupplier->ref_supplier =
'';
1726 $fksoctosearch =
$object->thirdparty->id;
1727 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1729 } elseif (
GETPOST(
'idprodfournprice',
'alpha') > 0) {
1730 $qtytosearch = $qty;
1732 $idprod = $productsupplier->get_buyprice(
GETPOST(
'idprodfournprice',
'alpha'), $qtytosearch);
1733 $res = $productsupplier->fetch($idprod);
1737 $label = $productsupplier->label;
1740 $outputlangs = $langs;
1742 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
1743 $newlang =
GETPOST(
'lang_id',
'aZ09');
1745 if (empty($newlang)) {
1746 $newlang =
$object->thirdparty->default_lang;
1748 if (!empty($newlang)) {
1750 $outputlangs->setDefaultLang($newlang);
1752 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->
description;
1754 $desc = $productsupplier->description;
1757 if (!empty($productsupplier->desc_supplier) &&
getDolGlobalString(
'PRODUIT_FOURN_TEXTS')) {
1758 $desc = $productsupplier->desc_supplier;
1762 if (trim($product_desc) == trim($desc) &&
getDolGlobalString(
'PRODUIT_AUTOFILL_DESC')) {
1766 $desc = $product_desc;
1768 if (!empty($product_desc) && trim($product_desc) != trim($desc)) {
1772 $ref_supplier = $productsupplier->ref_supplier;
1775 if (!GETPOSTISSET(
'tva_tx')) {
1776 $tmpidprodfournprice =
GETPOST(
'idprodfournprice',
'alpha');
1777 if (is_numeric($tmpidprodfournprice) && (
int) $tmpidprodfournprice > 0) {
1778 $tmpidprodfournprice = (int) $tmpidprodfournprice;
1780 $tmpidprodfournprice = 0;
1786 if (empty($tva_tx) || empty($tva_npr)) {
1792 $type = $productsupplier->type;
1793 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1794 $price_base_type =
'HT';
1796 $pu_devise =
price2num($price_ht_devise,
'CU');
1797 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
1798 $price_base_type =
'TTC';
1800 $pu_devise =
price2num($price_ttc_devise,
'CU');
1802 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
1803 if (empty(
$object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code !=
$object->multicurrency_code)) {
1804 $pu = $productsupplier->fourn_pu;
1807 $pu = $productsupplier->fourn_pu;
1808 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
1812 $ref_supplier = $productsupplier->ref_supplier;
1833 min($rank, count(
$object->lines) + 1),
1836 $productsupplier->fk_unit,
1839 GETPOST(
'fourn_ref',
'alpha'),
1843 if ($idprod == -99 || $idprod == 0) {
1846 $langs->load(
"errors");
1847 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
1849 if ($idprod == -1) {
1852 $langs->load(
"errors");
1853 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
1855 } elseif (empty($error)) {
1856 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1857 $tva_tx = str_replace(
'*',
'', $tva_tx);
1858 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1859 $desc = $product_desc;
1861 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1863 $fk_unit =
GETPOST(
'units',
'alpha');
1865 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
1873 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1877 $pu_ht =
price2num((
float) $pu_ttc / (1 + ((
float) $tva_tx / 100)),
'MU');
1879 $price_base_type =
'HT';
1880 $pu_devise =
price2num($price_ht_devise,
'CU');
1882 $result =
$object->addline($product_desc, $pu_ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit, 0, $pu_devise, $ref_supplier);
1886 if (!$error && $result > 0) {
1891 $outputlangs = $langs;
1894 $newlang =
GETPOST(
'lang_id',
'aZ09');
1897 $newlang =
$object->thirdparty->default_lang;
1899 if (!empty($newlang)) {
1901 $outputlangs->setDefaultLang($newlang);
1906 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1912 unset($_POST [
'prod_entry_mode']);
1914 unset($_POST[
'qty']);
1915 unset($_POST[
'type']);
1916 unset($_POST[
'remise_percent']);
1917 unset($_POST[
'pu']);
1918 unset($_POST[
'price_ht']);
1919 unset($_POST[
'multicurrency_price_ht']);
1920 unset($_POST[
'price_ttc']);
1921 unset($_POST[
'fourn_ref']);
1922 unset($_POST[
'tva_tx']);
1923 unset($_POST[
'label']);
1924 unset($localtax1_tx);
1925 unset($localtax2_tx);
1926 unset($_POST[
'np_marginRate']);
1927 unset($_POST[
'np_markRate']);
1928 unset($_POST[
'dp_desc']);
1929 unset($_POST[
'idprodfournprice']);
1930 unset($_POST[
'units']);
1932 unset($_POST[
'date_starthour']);
1933 unset($_POST[
'date_startmin']);
1934 unset($_POST[
'date_startsec']);
1935 unset($_POST[
'date_startday']);
1936 unset($_POST[
'date_startmonth']);
1937 unset($_POST[
'date_startyear']);
1938 unset($_POST[
'date_endhour']);
1939 unset($_POST[
'date_endmin']);
1940 unset($_POST[
'date_endsec']);
1941 unset($_POST[
'date_endday']);
1942 unset($_POST[
'date_endmonth']);
1943 unset($_POST[
'date_endyear']);
1950 } elseif ($action ==
'classin' && $usercancreate) {
1952 $result =
$object->setProject($projectid);
1953 } elseif ($action ==
'confirm_edit' && $confirm ==
'yes' && $usercancreate) {
1957 $totalpaid =
$object->getSommePaiement();
1958 $resteapayer =
$object->total_ttc - $totalpaid;
1961 $ventilExportCompta =
$object->getVentilExportCompta();
1963 if (!$ventilExportCompta) {
1966 $idwarehouse =
GETPOST(
'idwarehouse');
1970 $qualified_for_stock_change = 0;
1972 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1974 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1978 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
1979 $langs->load(
"stocks");
1980 if (!$idwarehouse || $idwarehouse == -1) {
1982 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1987 $object->setDraft($user, $idwarehouse);
1991 $outputlangs = $langs;
1994 $newlang =
GETPOST(
'lang_id',
'aZ09');
1997 $newlang =
$object->thirdparty->default_lang;
1999 if (!empty($newlang)) {
2001 $outputlangs->setDefaultLang($newlang);
2006 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
2015 } elseif ($action ==
'reopen' && $usercancreate) {
2017 $result =
$object->fetch($id);
2020 $result =
$object->setUnpaid($user);
2022 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
2031 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
2034 $triggersendname =
'BILL_SUPPLIER_SENTBYMAIL';
2036 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
2037 $trackid =
'sinv'.$object->id;
2038 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
2041 $upload_dir =
$conf->fournisseur->facture->dir_output;
2042 $permissiontoadd = $usercancreate;
2043 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
2046 if ($action ==
'calculate' && $usercancreate) {
2047 $calculationrule =
GETPOST(
'calculationrule');
2051 $result =
$object->update_price(0, (($calculationrule ==
'totalofround') ?
'0' :
'1'), 0,
$object->thirdparty);
2057 if ($action ==
'update_extras' && $usercancreate) {
2061 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
2068 $result =
$object->insertExtraFields(
'BILL_SUPPLIER_MODIFY');
2076 $action =
'edit_extras';
2081 if ($action ==
'addcontact' && $usercancreate) {
2082 $result =
$object->fetch($id);
2084 if ($result > 0 && $id > 0) {
2087 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
2091 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2094 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2095 $langs->load(
"errors");
2096 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
2101 } elseif ($action ==
'swapstatut' && $usercancreate) {
2108 } elseif ($action ==
'deletecontact' && $usercancreate) {
2114 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2128$form =
new Form($db);
2130$bankaccountstatic =
new Account($db);
2132if (isModEnabled(
'project')) {
2138$title =
$object->ref.
" - ".$langs->trans(
'Card');
2139if ($action ==
'create') {
2140 $title = $langs->trans(
"NewSupplierInvoice");
2142$help_url =
'EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores|DE:Modul_Lieferantenrechnungen';
2143llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-fourn-facture page-card');
2146if ($action ==
'create') {
2148 $selectedLines = array();
2150 print
load_fiche_titre($langs->trans(
'NewSupplierInvoice'),
'',
'supplier_invoice');
2154 $currency_code =
$conf->currency;
2160 if (isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2161 $currency_code = $societe->multicurrency_code;
2165 if (!empty($origin) && !empty($originid)) {
2167 $element = $subelement = $origin;
2169 if ($element ==
'project') {
2170 $projectid = $originid;
2171 $element =
'projet';
2175 if ($element ==
'order') {
2176 $element = $subelement =
'commande';
2178 if ($element ==
'propal') {
2179 $element =
'comm/propal';
2180 $subelement =
'propal';
2182 if ($element ==
'contract') {
2183 $element = $subelement =
'contrat';
2185 if ($element ==
'order_supplier') {
2187 $subelement =
'fournisseur.commande';
2191 $classname = ucfirst($subelement);
2192 if ($classname ==
'Fournisseur.commande') {
2193 $classname =
'CommandeFournisseur';
2195 $objectsrc =
new $classname($db);
2196 '@phan-var-force Project|Commande|Propal|Facture|Contrat|CommandeFournisseur|CommonObject $objectsrc';
2197 $objectsrc->fetch($originid);
2198 $objectsrc->fetch_thirdparty();
2200 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
2202 $soc = $objectsrc->thirdparty;
2204 $cond_reglement_id = 0;
2205 $mode_reglement_id = 0;
2209 $transport_mode_id = 0;
2212 if (!empty($objectsrc->cond_reglement_id)) {
2213 $cond_reglement_id = $objectsrc->cond_reglement_id;
2215 if (!empty($objectsrc->mode_reglement_id)) {
2216 $mode_reglement_id = $objectsrc->mode_reglement_id;
2218 if (!empty($objectsrc->fk_account)) {
2219 $fk_account = $objectsrc->fk_account;
2221 if (!empty($objectsrc->transport_mode_id)) {
2222 $transport_mode_id = $objectsrc->transport_mode_id;
2225 if (empty($cond_reglement_id)
2226 || empty($mode_reglement_id)
2227 || empty($fk_account)
2228 || empty($transport_mode_id)
2230 if ($origin ==
'reception') {
2232 if (!isset($objectsrc->supplier_order)) {
2233 $objectsrc->fetch_origin();
2236 if (!empty($objectsrc->origin_object)) {
2237 $originObject = $objectsrc->origin_object;
2238 if (empty($cond_reglement_id) && !empty($originObject->cond_reglement_id)) {
2239 $cond_reglement_id = $originObject->cond_reglement_id;
2241 if (empty($mode_reglement_id) && !empty($originObject->mode_reglement_id)) {
2242 $mode_reglement_id = $originObject->mode_reglement_id;
2244 if (empty($fk_account) && !empty($originObject->fk_account)) {
2245 $fk_account = $originObject->fk_account;
2247 if (empty($transport_mode_id) && !empty($originObject->transport_mode_id)) {
2248 $transport_mode_id = $originObject->transport_mode_id;
2255 if (empty($cond_reglement_id) && !empty($soc->cond_reglement_supplier_id)) {
2256 $cond_reglement_id = $soc->cond_reglement_supplier_id;
2258 if (empty($mode_reglement_id) && !empty($soc->mode_reglement_supplier_id)) {
2259 $mode_reglement_id = $soc->mode_reglement_supplier_id;
2261 if (empty($fk_account) && !empty($soc->fk_account)) {
2262 $fk_account = $soc->fk_account;
2264 if (empty($transport_mode_id) && !empty($soc->transport_mode_id)) {
2265 $transport_mode_id = $soc->transport_mode_id;
2270 if (isModEnabled(
"multicurrency")) {
2271 if (!empty($objectsrc->multicurrency_code)) {
2272 $currency_code = $objectsrc->multicurrency_code;
2274 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
2275 $currency_tx = $objectsrc->multicurrency_tx;
2280 $dateinvoice = ($datetmp ==
'' ? (!
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ? -1 :
'') : $datetmp);
2282 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2285 $objectsrc->fetch_optionals();
2286 $object->array_options = $objectsrc->array_options;
2288 $cond_reglement_id = !empty($societe->cond_reglement_supplier_id) ? $societe->cond_reglement_supplier_id : 0;
2289 $mode_reglement_id = !empty($societe->mode_reglement_supplier_id) ? $societe->mode_reglement_supplier_id : 0;
2290 $vat_reverse_charge = (empty($societe) ?
'' : $societe->vat_reverse_charge);
2291 $transport_mode_id = !empty($societe->transport_mode_supplier_id) ? $societe->transport_mode_supplier_id : 0;
2292 $fk_account = !empty($societe->fk_account) ? $societe->fk_account : 0;
2294 $dateinvoice = ($datetmp ==
'' ? (
getDolGlobalInt(
'MAIN_AUTOFILL_DATE') ?
'' : -1) : $datetmp);
2296 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2298 if (isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2299 $currency_code = $societe->multicurrency_code;
2304 if (empty($cond_reglement_id)) {
2305 $cond_reglement_id =
GETPOST(
"cond_reglement_id");
2309 if (empty($mode_reglement_id)) {
2310 $mode_reglement_id =
GETPOST(
"mode_reglement_id");
2314 if (!
GETPOST(
'changecompany')) {
2315 if (GETPOSTISSET(
'cond_reglement_id')) {
2316 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2318 if (GETPOSTISSET(
'mode_reglement_id')) {
2319 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2321 if (GETPOSTISSET(
'cond_reglement_id')) {
2326 $note_public =
$object->getDefaultCreateValueFor(
'note_public', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_public : null));
2327 $note_private =
$object->getDefaultCreateValueFor(
'note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_private : null));
2329 if ($origin ==
'contrat') {
2330 $langs->load(
"admin");
2331 $text = $langs->trans(
"ToCreateARecurringInvoice");
2332 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv(
"MenuFinancial"), $langs->transnoentitiesnoconv(
"SupplierBills"), $langs->transnoentitiesnoconv(
"ListOfTemplates"));
2334 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv(
'Module2300Name'));
2336 print
info_admin($text, 0, 0,
'0',
'opacitymedium').
'<br>';
2339 print
'<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
2340 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2341 print
'<input type="hidden" name="action" value="add">';
2342 print
'<input type="hidden" name="changecompany" value="0">';
2344 if (!empty($societe->id) && $societe->id > 0) {
2345 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">'.
"\n";
2347 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
2348 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
2349 if (!empty($currency_tx)) {
2350 print
'<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
2352 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2357 $parameters = array();
2359 $reshook = $hookmanager->executeHooks(
'tabContentCreateSupplierInvoice', $parameters,
$object, $action);
2360 if (empty($reshook)) {
2361 print
'<table class="border centpercent">';
2364 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
'Draft').
'</td></tr>';
2368 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2369 $invoice_predefined->fetch($fac_recid);
2373 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
2376 if (!empty($societe->id) && $societe->id > 0 && ($fac_recid <= 0 || !empty($invoice_predefined->frequency))) {
2377 $absolute_discount = $societe->getAvailableDiscounts(
null,
'', 0, 1);
2378 print $societe->getNomUrl(1,
'supplier');
2379 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
2381 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
2382 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');
2385 print
'<script type="text/javascript">
2386 $(document).ready(function() {
2387 $("#socid").change(function() {
2388 console.log("We have changed the company - Reload page");
2390 $("input[name=action]").val("create");
2391 $("input[name=changecompany]").val("1");
2392 $("form[name=add]").submit();
2397 if ($fac_recid <= 0) {
2398 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>';
2404 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2405 $invoice_predefined->fetch($fac_recid);
2407 $dateinvoice = $invoice_predefined->date_when;
2408 if (empty($projectid)) {
2409 $projectid = $invoice_predefined->fk_project;
2411 $cond_reglement_id = $invoice_predefined->cond_reglement_id;
2412 $mode_reglement_id = $invoice_predefined->mode_reglement_id;
2413 $fk_account = $invoice_predefined->fk_account;
2414 $note_public = $invoice_predefined->note_public;
2415 $note_private = $invoice_predefined->note_private;
2417 if (!empty($invoice_predefined->multicurrency_code)) {
2418 $currency_code = $invoice_predefined->multicurrency_code;
2420 if (!empty($invoice_predefined->multicurrency_tx)) {
2421 $currency_tx = $invoice_predefined->multicurrency_tx;
2424 $sql =
'SELECT r.rowid, r.titre as title, r.total_ttc';
2425 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn_rec as r';
2426 $sql .=
' WHERE r.fk_soc = '. (int) $invoice_predefined->socid;
2428 $resql = $db->query($sql);
2430 $num = $db->num_rows($resql);
2434 print
'<tr><td>'.$langs->trans(
'CreateFromRepeatableInvoice').
'</td><td>';
2436 print
'<select class="flat" id="fac_rec" name="fac_rec">';
2437 print
'<option value="0" selected></option>';
2439 $objp = $db->fetch_object($resql);
2440 print
'<option value="'.$objp->rowid.
'"';
2441 if ($fac_recid == $objp->rowid) {
2443 $exampletemplateinvoice->fetch($fac_recid);
2445 print
'>'.$objp->title.
' ('.
price($objp->total_ttc).
' '.$langs->trans(
"TTC").
')</option>';
2451 print
'<script type="text/javascript">
2452 $(document).ready(function() {
2453 $("#fac_rec").change(function() {
2454 console.log("We have changed the template invoice - Reload page");
2456 $("input[name=action]").val("create");
2457 $("form[name=add]").submit();
2471 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"';
2472 if (!empty($societe->id) && $societe->id > 0) {
2478 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'Type').
'</td><td>';
2480 print
'<div class="tagtable">'.
"\n";
2483 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2484 $tmp =
'<input type="radio" id="radio_standard" name="type" value="0"'.(GETPOSTINT(
'type') ?
'' :
'checked').
'> ';
2485 $desc = $form->textwithpicto($tmp.
'<label for="radio_standard">'.$langs->trans(
"InvoiceStandardAsk").
'</label>', $langs->transnoentities(
"InvoiceStandardDesc"), 1,
'help',
'', 0, 3);
2487 print
'</div></div>';
2489 if (empty($origin) || ($origin ==
'order_supplier' && !empty($originid))) {
2492 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2493 $tmp =
'<input type="radio" id="radio_deposit" name="type" value="3"' . (
GETPOSTINT(
'type') == 3 ?
' checked' :
'') .
'> ';
2494 print
'<script type="text/javascript">
2495 jQuery(document).ready(function() {
2496 jQuery("#typestandardinvoice, #valuestandardinvoice").click(function() {
2497 jQuery("#radio_standard").prop("checked", true);
2499 jQuery("#typedeposit, #valuedeposit").click(function() {
2500 jQuery("#radio_deposit").prop("checked", true);
2502 jQuery("#typedeposit").change(function() {
2503 console.log("We change type of down payment");
2504 jQuery("#radio_deposit").prop("checked", true);
2505 setRadioForTypeOfInvoice();
2507 jQuery("#radio_standard, #radio_deposit, #radio_replacement, #radio_template").change(function() {
2508 setRadioForTypeOfInvoice();
2510 function setRadioForTypeOfInvoice() {
2511 console.log("Change radio");
2512 if (jQuery("#radio_deposit").prop("checked") && (jQuery("#typedeposit").val() == \'amount\' || jQuery("#typedeposit").val() == \'variable\')) {
2513 jQuery(".checkforselect").prop("disabled", true);
2514 jQuery(".checkforselect").prop("checked", false);
2516 jQuery(".checkforselect").prop("disabled", false);
2517 jQuery(".checkforselect").prop("checked", true);
2523 $tmp = $tmp.
'<label for="radio_deposit" >'.$langs->trans(
"InvoiceDeposit").
'</label>';
2525 $desc = $form->textwithpicto($tmp, $langs->transnoentities(
"InvoiceDepositDesc"), 1,
'help',
'', 0, 3);
2526 print
'<table class="nobordernopadding"><tr>';
2530 if ($origin ==
'order_supplier') {
2531 print
'<td class="nowrap" style="padding-left: 15px">';
2533 'amount' => $langs->transnoentitiesnoconv(
'FixAmount', $langs->transnoentitiesnoconv(
'Deposit')),
2534 'variable' => $langs->transnoentitiesnoconv(
'VarAmountOneLine', $langs->transnoentitiesnoconv(
'Deposit')),
2535 'variablealllines' => $langs->transnoentitiesnoconv(
'VarAmountAllLines')
2537 print $form->selectarray(
'typedeposit', $arraylist,
GETPOST(
'typedeposit',
'aZ09'), 0, 0, 0,
'', 1);
2539 print
'<td class="nowrap" style="padding-left: 5px">';
2540 print
'<span class="opacitymedium paddingleft">'.$langs->trans(
"AmountOrPercent").
'</span><input type="text" id="valuedeposit" name="valuedeposit" class="width75 right" value="' .
GETPOSTINT(
'valuedeposit') .
'"/>';
2543 print
'</tr></table>';
2545 print
'</div></div>';
2614 if (empty($origin)) {
2615 if (!empty($societe->id) && $societe->id > 0) {
2619 $facids = $facturestatic->list_qualified_avoir_supplier_invoices($societe->id);
2626 foreach ($facids as $key => $valarray) {
2627 $newinvoice_static->id = $key;
2628 $newinvoice_static->ref = $valarray [
'ref'];
2629 $newinvoice_static->status = $valarray [
'status'];
2630 $newinvoice_static->statut = $valarray [
'status'];
2631 $newinvoice_static->type = $valarray [
'type'];
2632 $newinvoice_static->paid = $valarray [
'paye'];
2633 $newinvoice_static->paye = $valarray [
'paye'];
2635 $optionsav .=
'<option value="'.$key.
'"';
2637 $optionsav .=
' selected';
2640 $optionsav .= $newinvoice_static->ref;
2641 $optionsav .=
' ('.$newinvoice_static->getLibStatut(1, $valarray [
'paymentornot']).
')';
2642 $optionsav .=
'</option>';
2645 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2646 $tmp =
'<input type="radio" id="radio_creditnote" name="type" value="2"'.(GETPOST(
'type') == 2 ?
' checked' :
'');
2648 $tmp .=
' disabled';
2652 print
'<script type="text/javascript">
2653 jQuery(document).ready(function() {
2654 if (! jQuery("#radio_creditnote").is(":checked"))
2656 jQuery("#credit_note_options").hide();
2658 jQuery("#radio_creditnote").click(function() {
2659 jQuery("#credit_note_options").show();
2661 jQuery("#radio_standard, #radio_replacement, #radio_deposit").click(function() {
2662 jQuery("#credit_note_options").hide();
2666 $text = $tmp.
'<label for="radio_creditnote">'.$langs->transnoentities(
"InvoiceAvoirAsk").
'</label> ';
2668 $text .=
'<select class="flat valignmiddle" name="fac_avoir" id="fac_avoir"';
2670 $text .=
' disabled';
2674 $text .=
'<option value="-1"></option>';
2675 $text .= $optionsav;
2677 $text .=
'<option value="-1">'.$langs->trans(
"NoInvoiceToCorrect").
'</option>';
2679 $text .=
'</select>';
2680 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2683 print
'<div id="credit_note_options" class="clearboth">';
2684 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' :
'').
' /> ';
2685 print
'<label for="invoiceAvoirWithLines">'.$langs->trans(
'invoiceAvoirWithLines').
"</label>";
2686 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' :
'').
' /> ';
2687 print
'<label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans(
'invoiceAvoirWithPaymentRestAmount').
"</label>";
2690 print
'</div></div>';
2693 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2695 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="0" disabled> ';
2697 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="2"> ';
2699 $text = $tmp.$langs->trans(
"InvoiceAvoir").
' ';
2700 $text .=
'<span class="opacitymedium">('.$langs->trans(
"YouMustCreateInvoiceFromSupplierThird").
')</span> ';
2701 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2703 print
'</div></div>'.
"\n";
2714 print
'<tr><td class="fieldrequired">'.$langs->trans(
'InvoiceSubtype').
'</td><td colspan="2">';
2715 print $form->getSelectInvoiceSubtype(
GETPOST(
'subtype'),
'subtype', 1, 0,
'');
2719 if (!empty($societe->id) && $societe->id > 0) {
2721 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
2723 $thirdparty = $societe;
2725 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$societe->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
2726 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2732 print
'<tr><td>'.$langs->trans(
'Label').
'</td><td><input class="minwidth200" name="label" value="'.
dol_escape_htmltag(
GETPOST(
'label')).
'" type="text"></td></tr>';
2735 print
'<tr><td class="fieldrequired">'.$langs->trans(
'DateInvoice').
'</td><td>';
2736 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2737 print $form->selectDate($dateinvoice,
'', 0, 0, 0,
"add", 1, 1);
2741 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
2742 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
2743 print $form->getSelectConditionsPaiements($cond_reglement_id,
'cond_reglement_id', -1, 1);
2748 print
'<tr><td>'.$langs->trans(
'DateMaxPayment').
'</td><td>';
2749 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2750 print $form->selectDate($datedue,
'ech', 0, 0, 0,
"add", 1, 1);
2754 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
2755 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
2756 $form->select_types_paiements($mode_reglement_id,
'mode_reglement_id',
'DBIT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx');
2760 if (isModEnabled(
"bank")) {
2761 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
2763 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes($fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
2768 if (isModEnabled(
'project')) {
2771 $langs->load(
'projects');
2772 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td>';
2773 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');
2774 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>';
2779 if (isModEnabled(
'incoterm')) {
2781 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), !empty($objectsrc->label_incoterms) ? $objectsrc->label_incoterms :
'', 1).
'</label></td>';
2782 print
'<td colspan="3" class="maxwidthonsmartphone">';
2783 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2784 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 :
''));
2790 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
2791 print
'<tr><td>' . $langs->trans(
'VATReverseCharge') .
'</td><td>';
2793 if (GETPOSTISSET(
'vat_reverse_charge')) {
2794 $vat_reverse_charge = (
GETPOST(
'vat_reverse_charge',
'alpha') ==
'on' ||
GETPOST(
'vat_reverse_charge',
'alpha') ==
'1') ? 1 : 0;
2795 } elseif ($vat_reverse_charge == 1 || $societe->vat_reverse_charge == 1 || ($societe->country_code !=
'FR' &&
isInEEC($societe) && !empty($societe->tva_intra))) {
2796 $vat_reverse_charge = 1;
2798 $vat_reverse_charge = 0;
2801 print
'<input type="checkbox" name="vat_reverse_charge"'. (!empty($vat_reverse_charge) ?
' checked ' :
'') .
'>';
2806 if (isModEnabled(
"multicurrency")) {
2808 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'',
$object, 0).
'</td>';
2809 print
'<td class="maxwidthonsmartphone">';
2810 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
2811 $used_currency_code = $currency_code;
2812 if (!
GETPOST(
'changecompany')) {
2813 $used_currency_code = GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code',
'alpha') : $currency_code;
2815 print $form->selectMultiCurrency($used_currency_code,
'multicurrency_code');
2821 if ($fac_recid > 0) {
2822 $dateexample = $dateinvoice;
2823 if (empty($dateexample)) {
2826 $substitutionarray = array(
2827 '__TOTAL_HT__' => $langs->trans(
"AmountHT").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ht).
')',
2828 '__TOTAL_TTC__' => $langs->trans(
"AmountTTC").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ttc).
')',
2829 '__INVOICE_PREVIOUS_MONTH__' => $langs->trans(
"PreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%m').
')',
2830 '__INVOICE_MONTH__' => $langs->trans(
"MonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%m').
')',
2831 '__INVOICE_NEXT_MONTH__' => $langs->trans(
"NextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%m').
')',
2832 '__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans(
"TextPreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%B').
')',
2833 '__INVOICE_MONTH_TEXT__' => $langs->trans(
"TextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%B').
')',
2834 '__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans(
"TextNextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%B').
')',
2835 '__INVOICE_PREVIOUS_YEAR__' => $langs->trans(
"PreviousYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'y'),
'%Y').
')',
2836 '__INVOICE_YEAR__' => $langs->trans(
"YearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%Y').
')',
2837 '__INVOICE_NEXT_YEAR__' => $langs->trans(
"NextYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'y'),
'%Y').
')'
2840 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
2841 foreach ($substitutionarray as $key => $val) {
2842 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
2844 $htmltext .=
'</i>';
2848 if (isModEnabled(
'intracommreport')) {
2849 $langs->loadLangs(array(
"intracommreport"));
2850 print
'<!-- If module intracomm on -->'.
"\n";
2851 print
'<tr><td>'.$langs->trans(
'IntracommReportTransportMode').
'</td><td>';
2852 $form->selectTransportMode(GETPOSTISSET(
'transport_mode_id') ?
GETPOST(
'transport_mode_id') : $transport_mode_id,
'transport_mode_id');
2856 if (empty($reshook)) {
2857 print
$object->showOptionals($extrafields,
'create');
2861 print
'<tr><td>'.$langs->trans(
'NotePublic').
'</td>';
2863 $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%');
2864 print $doleditor->Create(1);
2870 print
'<tr><td>'.$langs->trans(
'NotePrivate').
'</td>';
2872 $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%');
2873 print $doleditor->Create(1);
2879 if (!empty($objectsrc) && is_object($objectsrc)) {
2880 print
"\n<!-- ".$classname.
" info -->";
2882 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2883 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2884 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2885 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2886 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2888 $txt = $langs->trans($classname);
2889 if ($classname ==
'CommandeFournisseur') {
2890 $langs->load(
'orders');
2891 $txt = $langs->trans(
"SupplierOrder");
2893 print
'<tr><td>'.$txt.
'</td><td>'.$objectsrc->getNomUrl(1);
2895 $objectsrc->fetchObjectLinked($originid, $origin,
null,
'invoice_supplier');
2897 $invoice_supplier = $objectsrc->linkedObjects[
'invoice_supplier'];
2898 '@phan-var-force null|FactureFournisseur[] $invoice_supplier';
2901 if (is_array($invoice_supplier)) {
2902 $cntinvoice = count($invoice_supplier);
2904 if ($cntinvoice >= 1) {
2906 echo
' ('.$langs->trans(
'LatestRelatedBill').end($invoice_supplier)->getNomUrl(1).
')';
2911 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
2912 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
2913 if ($mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
2914 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
2917 if ($mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
2918 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
2920 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
2922 if (isModEnabled(
"multicurrency")) {
2923 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
2924 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
2925 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2930 $parameters = array();
2931 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2932 print $hookmanager->resPrint;
2940 print $form->buttonsSaveCancel(
"CreateDraft");
2943 if (!empty($objectsrc) && is_object($objectsrc)) {
2946 $title = $langs->trans(
'ProductsAndServices');
2949 print
'<div class="div-table-responsive-no-min">';
2950 print
'<table class="noborder centpercent">';
2952 $objectsrc->printOriginLinesList(
'', $selectedLines);
2960 if ($id > 0 || !empty($ref)) {
2966 $productstatic =
new Product($db);
2968 $result =
$object->fetch($id, $ref);
2970 $langs->load(
"errors");
2971 print $langs->trans(
"ErrorRecordNotFound");
2977 $result =
$object->fetch_thirdparty();
2983 $societe =
$object->thirdparty;
2985 $totalpaid =
$object->getSommePaiement();
2986 $totalcreditnotes =
$object->getSumCreditNotesUsed();
2987 $totaldeposits =
$object->getSumDepositsUsed();
2995 $resteapayer =
price2num(
$object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
2998 $multicurrency_resteapayer = 0;
2999 if (isModEnabled(
"multicurrency")) {
3000 $multicurrency_totalpaid =
$object->getSommePaiement(1);
3001 $multicurrency_totalcreditnotes =
$object->getSumCreditNotesUsed(1);
3002 $multicurrency_totaldeposits =
$object->getSumDepositsUsed(1);
3003 $multicurrency_resteapayer =
price2num(
$object->multicurrency_total_ttc - $multicurrency_totalpaid - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits,
'MT');
3007 if ($resteapayer == 0 && $multicurrency_resteapayer != 0 &&
$object->multicurrency_code !=
$conf->currency) {
3008 $resteapayer =
price2num((
float) $multicurrency_resteapayer /
$object->multicurrency_tx,
'MT');
3015 $resteapayeraffiche = $resteapayer;
3018 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
3019 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
3021 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
3022 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
3025 $absolute_discount = $societe->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
3026 $absolute_creditnote = $societe->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
3027 $absolute_discount =
price2num($absolute_discount,
'MT');
3028 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
3032 $objectidnext =
$object->getIdReplacingInvoice();
3035 $titre = $langs->trans(
'SupplierInvoice');
3037 print
dol_get_fiche_head($head,
'card', $titre, -1,
'supplier_invoice', 0,
'',
'', 0,
'', 1);
3042 if ($action ==
'converttoreduc') {
3045 $type_fac =
'ExcessPaid';
3047 $type_fac =
'CreditNote';
3049 $type_fac =
'Deposit';
3051 $text = $langs->trans(
'ConfirmConvertToReducSupplier', strtolower($langs->transnoentities($type_fac)));
3052 $text .=
'<br>'.$langs->trans(
'ConfirmConvertToReducSupplier2');
3053 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id, $langs->trans(
'ConvertToReduc'), $text,
'confirm_converttoreduc',
'',
"yes", 2);
3057 if ($action ==
'clone') {
3059 $formquestion = array(
3060 array(
'type' =>
'text',
'name' =>
'newsupplierref',
'label' => $langs->trans(
"RefSupplierBill"),
'value' => $langs->trans(
"CopyOf").
' '.
$object->ref_supplier),
3061 array(
'type' =>
'date',
'name' =>
'newdate',
'label' => $langs->trans(
"Date"),
'value' =>
dol_now())
3064 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneInvoice',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1, 250);
3068 if ($action ==
'valid') {
3070 if (preg_match(
'/^[\(]?PROV/i',
$object->ref) || empty(
$object->ref)) {
3072 $numref =
$object->getNextNumRef($societe);
3081 $text = $langs->trans(
'ConfirmValidateBill', $numref);
3089 $formquestion = array();
3091 $qualified_for_stock_change = 0;
3093 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3095 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3098 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
3099 $langs->load(
"stocks");
3100 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3103 $warehouse_array = $warehouse->list_array();
3104 if (count($warehouse_array) == 1) {
3106 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3109 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3111 $formquestion = array(
3112 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3116 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateBill'), $text,
'confirm_valid', $formquestion, 1, 1);
3121 if ($action ==
'edit') {
3122 $formquestion = array();
3124 $qualified_for_stock_change = 0;
3126 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3128 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3130 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
3131 $langs->load(
"stocks");
3132 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3135 $warehouse_array = $warehouse->list_array();
3136 if (count($warehouse_array) == 1) {
3138 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3141 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3143 $formquestion = array(
3144 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3147 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'UnvalidateBill'), $langs->trans(
'ConfirmUnvalidateBill',
$object->ref),
'confirm_edit', $formquestion, 1, 1);
3151 if ($action ==
'paid' && ($resteapayer <= 0 || (
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') && $resteapayer ==
$object->total_ttc))) {
3152 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidBill',
$object->ref),
'confirm_paid',
'', 0, 1);
3155 if ($action ==
'paid' && $resteapayer > 0 && (!
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') || $resteapayer !=
$object->total_ttc)) {
3159 $close[$i][
'code'] =
'discount_vat';
3161 $close[$i][
'code'] =
'badsupplier';
3163 $close[$i][
'code'] =
'other';
3167 $close[$i][
'label'] = $langs->trans(
"HelpEscompte").
'<br><br>'.$langs->trans(
"ConfirmClassifyPaidPartiallyReasonDiscountVatDesc");
3169 $close[$i][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3171 $close[$i][
'label'] = $langs->trans(
"Other");
3175 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonDiscount", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3177 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadCustomer", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3179 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"Other"), $close[$i][
'label'], 1);
3182 $arrayreasons = array();
3183 foreach ($close as $key => $val) {
3184 $arrayreasons[$close[$key][
'code']] = $close[$key][
'reason'];
3188 $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'));
3190 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?facid='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidPartially',
$object->ref),
'confirm_paid_partially', $formquestion,
"yes", 1, 310);
3194 if ($action ==
'canceled') {
3196 $close[1][
'code'] =
'badsupplier';
3197 $close[2][
'code'] =
'abandon';
3199 $close[1][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3200 $close[2][
'label'] = $langs->trans(
"ConfirmClassifyAbandonReasonOtherDesc");
3202 $close[1][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadSupplier",
$object->ref), $close[1][
'label'], 1);
3203 $close[2][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyAbandonReasonOther"), $close[2][
'label'], 1);
3205 $arrayreasons[$close[1][
'code']] = $close[1][
'reason'];
3206 $arrayreasons[$close[2][
'code']] = $close[2][
'reason'];
3209 $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'));
3211 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'CancelBill'), $langs->trans(
'ConfirmCancelBill',
$object->ref),
'confirm_canceled', $formquestion,
"yes", 1, 280);
3215 if ($action ==
'delete') {
3216 $formquestion = array();
3218 $qualified_for_stock_change = 0;
3220 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3222 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3225 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
3226 $langs->load(
"stocks");
3227 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3230 $warehouse_array = $warehouse->list_array();
3232 $selectwarehouse =
'<span class="questionrevertstock hidden">';
3233 if (count($warehouse_array) == 1) {
3235 $selectwarehouse .=
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3238 $selectwarehouse .= $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3240 $selectwarehouse .=
'</span>';
3242 $selectyesno = array(0 => $langs->trans(
'No'), 1 => $langs->trans(
'Yes'));
3244 print
'<script type="text/javascript">
3245 $(document).ready(function() {
3246 $("#revertstock").change(function() {
3247 if(this.value > 0) {
3248 $(".questionrevertstock").removeClass("hidden");
3250 $(".questionrevertstock").addClass("hidden");
3256 $formquestion = array(
3257 array(
'type' =>
'select',
'name' =>
'revertstock',
'label' => $langs->trans(
"RevertProductsToStock"),
'select_show_empty' => 0,
'values' => $selectyesno),
3258 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $selectwarehouse,
'tdclass' =>
'questionrevertstock hidden')
3262 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteBill'), $langs->trans(
'ConfirmDeleteBill'),
'confirm_delete', $formquestion, 1, 1);
3264 if ($action ==
'deletepayment') {
3265 $payment_id =
GETPOST(
'paiement_id');
3266 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&paiement_id='.$payment_id, $langs->trans(
'DeletePayment'), $langs->trans(
'ConfirmDeletePayment'),
'confirm_delete_paiement',
'', 0, 1);
3270 if ($action ==
'ask_deleteline') {
3271 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
3274 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
3275 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
3276 if (empty($reshook)) {
3277 $formconfirm .= $hookmanager->resPrint;
3278 } elseif ($reshook > 0) {
3279 $formconfirm = $hookmanager->resPrint;
3287 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
3289 $morehtmlref =
'<div class="refidno">';
3291 $morehtmlref .= $form->editfieldkey(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, $usercancreate,
'string',
'', 0, 1);
3292 $morehtmlref .= $form->editfieldval(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, $usercancreate,
'string',
'',
null,
null,
'', 1);
3294 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1,
'supplier');
3296 $morehtmlref .=
' <div class="inline-block valignmiddle">(<a class="valignmiddle" href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.((int)
$object->thirdparty->id).
'">'.$langs->trans(
"OtherBills").
'</a>)</div>';
3299 if (isModEnabled(
'project')) {
3300 $langs->load(
"projects");
3301 $morehtmlref .=
'<br>';
3302 if ($permissiontoadd) {
3303 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
3304 if ($action !=
'classify') {
3305 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.((int)
$object->id).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
3307 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (!
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ?
$object->socid : -1),
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
3309 if (!empty(
$object->fk_project)) {
3311 $proj->fetch(
$object->fk_project);
3312 $morehtmlref .= $proj->getNomUrl(1);
3314 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
3319 $morehtmlref .=
'</div>';
3321 $object->totalpaid = $totalpaid;
3323 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
3326 $parameters = array();
3328 $reshook = $hookmanager->executeHooks(
'tabContentViewSupplierInvoice', $parameters,
$object, $action);
3329 if (empty($reshook)) {
3330 print
'<div class="fichecenter">';
3331 print
'<div class="fichehalfleft">';
3332 print
'<div class="underbanner clearboth"></div>';
3334 print
'<table class="border tableforfield centpercent">';
3337 print
'<tr><td class="titlefield">'.$langs->trans(
'Type').
'</td><td>';
3338 print
'<span class="badgeneutral">';
3342 print
' '.$object->getSubtypeLabel(
'facture_fourn');
3346 $facreplaced->fetch(
$object->fk_facture_source);
3347 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
'</span>';
3350 if (
$object->fk_facture_source > 0) {
3352 $facusing->fetch(
$object->fk_facture_source);
3353 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
'</span>';
3355 $langs->load(
"errors");
3356 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"WarningCorrectedInvoiceNotFound").
'</span>';
3360 $facidavoir =
$object->getListIdAvoirFromInvoice();
3361 if (count($facidavoir) > 0) {
3362 $invoicecredits = array();
3363 foreach ($facidavoir as $id) {
3365 $facavoir->fetch($id);
3366 $invoicecredits[] = $facavoir->getNomUrl(1);
3368 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"InvoiceHasAvoir") . (count($invoicecredits) ?
' ' :
'') . implode(
',', $invoicecredits);
3371 if (isset($objectidnext) && $objectidnext > 0) {
3374 $facthatreplace->fetch($objectidnext);
3375 print
' <span class="opacitymediumbycolor paddingleft">'.str_replace(
'{s1}', $facthatreplace->getNomUrl(1), $langs->transnoentities(
"ReplacedByInvoice",
'{s1}')).
'</span>';
3379 $result = $discount->fetch(0, 0,
$object->id);
3381 print
' <span class="opacitymediumbycolor paddingleft">';
3382 $s = $langs->trans(
"CreditNoteConvertedIntoDiscount",
'{s1}',
'{s2}');
3383 $s = str_replace(
'{s1}',
$object->getLibType(1), $s);
3384 $s = str_replace(
'{s2}', $discount->getNomUrl(1,
'discount'), $s);
3386 print
'</span><br>';
3390 if (
$object->fk_fac_rec_source > 0) {
3392 $result = $tmptemplate->fetch(
$object->fk_fac_rec_source);
3394 print
' <span class="opacitymediumbycolor paddingleft">';
3395 $link =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.$tmptemplate->id.
'">'.
dol_escape_htmltag($tmptemplate->title).
'</a>';
3396 $s = $langs->transnoentities(
"GeneratedFromSupplierTemplate", $link);
3406 print
'<!-- Discounts -->'.
"\n";
3407 print
'<tr><td>'.$langs->trans(
'DiscountStillRemaining');
3410 $thirdparty = $societe;
3412 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
3418 print
'<td>'.$form->editfieldkey(
"Label",
'label',
$object->label,
$object, $usercancreate).
'</td>';
3419 print
'<td>'.$form->editfieldval(
"Label",
'label',
$object->label,
$object, $usercancreate).
'</td>';
3427 print $form->editfieldkey(
"DateInvoice",
'datef',
$object->date,
$object, $form_permission,
'datepicker');
3428 print
'</td><td colspan="3">';
3429 print $form->editfieldval(
"Date",
'datef',
$object->date,
$object, $form_permission,
'datepicker');
3433 $langs->load(
'bills');
3434 print
'<tr><td class="nowrap">';
3435 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3436 print $langs->trans(
'PaymentConditions');
3438 if ($action !=
'editconditions' && $form_permission) {
3439 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>';
3441 print
'</tr></table>';
3443 if ($action ==
'editconditions') {
3444 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'cond_reglement_id');
3446 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'none');
3453 print $form->editfieldkey(
"DateMaxPayment",
'date_lim_reglement',
$object->date_echeance,
$object, $form_permission,
'datepicker');
3455 print $form->editfieldval(
"DateMaxPayment",
'date_lim_reglement',
$object->date_echeance,
$object, $form_permission,
'datepicker');
3456 if ($action !=
'editdate_lim_reglement' &&
$object->hasDelay()) {
3462 $langs->load(
'bills');
3463 print
'<tr><td class="nowrap">';
3464 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3465 print $langs->trans(
'PaymentMode');
3467 if ($action !=
'editmode' && $form_permission) {
3468 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>';
3470 print
'</tr></table>';
3472 if ($action ==
'editmode') {
3473 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
3475 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'none');
3480 if (isModEnabled(
"bank")) {
3481 print
'<tr><td class="nowrap">';
3482 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3483 print $langs->trans(
'BankAccount');
3485 if ($action !=
'editbankaccount' && $usercancreate) {
3486 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>';
3488 print
'</tr></table>';
3490 if ($action ==
'editbankaccount') {
3491 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'fk_account', 1);
3493 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
3501 print
'<tr><td class="nowrap">';
3502 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3503 print $langs->trans(
'VATReverseCharge');
3505 if ($action !=
'editvatreversecharge' && $usercancreate) {
3506 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editvatreversecharge&id='.
$object->id.
'">'.
img_edit($langs->trans(
'SetVATReverseCharge'), 1).
'</a></td>';
3508 print
'</tr></table>';
3510 if ($action ==
'editvatreversecharge') {
3511 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
3512 print
'<input type="hidden" name="action" value="setvatreversecharge">';
3513 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3515 print
'<input type="checkbox" name="vat_reverse_charge"' . (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
'>';
3517 print
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
3520 print
'<input type="checkbox" name="vat_reverse_charge"'. (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
' disabled>';
3526 if (isModEnabled(
'incoterm')) {
3528 print
'<table width="100%" class="nobordernopadding"><tr><td>';
3529 print $langs->trans(
'IncotermLabel');
3530 print
'<td><td class="right">';
3531 if ($usercancreate) {
3532 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.
$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit().
'</a>';
3536 print
'</td></tr></table>';
3539 if ($action !=
'editincoterm') {
3540 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3542 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
3548 if (isModEnabled(
'intracommreport')) {
3549 $langs->loadLangs(array(
"intracommreport"));
3550 print
'<!-- If module intracomm on -->'.
"\n";
3552 print
'<table class="nobordernopadding centpercent"><tr><td>';
3553 print $langs->trans(
'IntracommReportTransportMode');
3555 if ($action !=
'edittransportmode' && ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"))) {
3556 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edittransportmode&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit().
'</a></td>';
3558 print
'</tr></table>';
3561 if ($action ==
'edittransportmode') {
3562 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->transport_mode_id,
'transport_mode_id', 1, 1);
3564 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->transport_mode_id,
'none');
3571 if (
$object->status != $object::STATUS_DRAFT) {
3575 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3580 print
'<div class="fichehalfright">';
3581 print
'<div class="underbanner clearboth"></div>';
3583 print
'<table class="border tableforfield centpercent">';
3585 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
3588 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
3589 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3590 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3591 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3596 print
'<td>' . $langs->trans(
'AmountVAT') .
'</td>';
3597 print
'<td class="nowrap amountcard right">';
3598 if (
GETPOST(
'calculationrule')) {
3599 $calculationrule =
GETPOST(
'calculationrule',
'alpha');
3601 $calculationrule = (!
getDolGlobalString(
'MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND') ?
'totalofround' :
'roundoftotal');
3603 if ($calculationrule ==
'totalofround') {
3604 $calculationrulenum = 1;
3606 $calculationrulenum = 2;
3609 if (
$object->getVentilExportCompta() == 0) {
3610 $s =
'<span class="hideonsmartphone opacitymedium">' . $langs->trans(
"ReCalculate") .
' </span>';
3611 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&token='.newToken().
'&calculationrule=totalofround">' . $langs->trans(
"Mode1") .
'</a>';
3613 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&token='.newToken().
'&calculationrule=roundoftotal">' . $langs->trans(
"Mode2") .
'</a>';
3614 print
'<div class="inline-block">';
3615 print $form->textwithtooltip($s, $langs->trans(
"CalculationRuleDesc", $calculationrulenum) .
'<br>' . $langs->trans(
"CalculationRuleDescSupplier"), 2, 1,
img_picto(
'',
'help'),
'', 3,
'', 0,
'recalculate');
3616 print
' ';
3619 print
'<span class="nowraponall">'.price(
$object->total_tva, 1, $langs, 0, -1, -1,
$conf->currency).
'</span>';
3621 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3622 print
'<td class="nowraponall amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3626 if ($societe->localtax1_assuj ==
"1") {
3628 print
'<td>' . $langs->transcountry(
"AmountLT1", $societe->country_code) .
'</td>';
3629 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 1, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3632 if ($societe->localtax2_assuj ==
"1") {
3634 print
'<td>' . $langs->transcountry(
"AmountLT2", $societe->country_code) .
'</td>';
3635 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 1, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3640 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
3641 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3642 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3643 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3661 if (isModEnabled(
'project')) {
3664 if (isModEnabled(
"bank")) {
3668 if (isModEnabled(
'incoterm')) {
3671 if (isModEnabled(
"multicurrency")) {
3676 if ($societe->localtax1_assuj ==
"1") {
3679 if ($societe->localtax2_assuj ==
"1") {
3683 $sql =
'SELECT p.datep as dp, p.ref, p.num_paiement as num_payment, p.rowid, p.fk_bank,';
3684 $sql .=
' c.id as payment_type, c.code as payment_code,';
3685 $sql .=
' pf.amount,';
3686 $sql .=
' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal';
3687 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn as p';
3688 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
3689 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
3690 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id';
3691 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid';
3692 $sql .=
' WHERE pf.fk_facturefourn = '.((int)
$object->id);
3693 $sql .=
' ORDER BY p.datep, p.tms';
3695 $result = $db->query($sql);
3697 $num = $db->num_rows($result);
3700 print
'<div class="div-table-responsive-no-min">';
3701 print
'<table class="noborder paymenttable centpercent">';
3702 print
'<tr class="liste_titre">';
3704 print
'<td><span class="hideonsmartphone">'.$langs->trans(
'Date').
'</span></td>';
3705 print
'<td><span class="hideonsmartphone">'.$langs->trans(
'Type').
'</span></td>';
3706 if (isModEnabled(
"bank")) {
3707 print
'<td class="right">'.$langs->trans(
'BankAccount').
'</td>';
3709 print
'<td class="right">'.$langs->trans(
'Amount').
'</td>';
3710 print
'<td width="18"> </td>';
3715 $objp = $db->fetch_object($result);
3717 $paymentstatic->id = $objp->rowid;
3718 $paymentstatic->datepaye = $db->jdate($objp->dp);
3719 $paymentstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
3720 $paymentstatic->num_payment = $objp->num_payment;
3722 $paymentstatic->paiementcode = $objp->payment_code;
3723 $paymentstatic->type_code = $objp->payment_code;
3724 $paymentstatic->type_label = $objp->payment_type;
3726 print
'<tr class="oddeven">';
3727 print
'<td class="nowraponall">';
3728 print $paymentstatic->getNomUrl(1);
3730 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
'</td>';
3731 $s = $form->form_modes_reglement(
'', $objp->payment_type,
'none',
'', 1, 0,
'', 1).
' '.$objp->num_payment;
3732 print
'<td class="tdoverflowmax125" title="'.dol_escape_htmltag($s).
'">';
3735 if (isModEnabled(
"bank")) {
3736 $bankaccountstatic->id = $objp->baid;
3737 $bankaccountstatic->ref = $objp->baref;
3738 $bankaccountstatic->label = $objp->baref;
3739 $bankaccountstatic->number = $objp->banumber;
3741 if (isModEnabled(
'accounting')) {
3742 $bankaccountstatic->account_number = $objp->account_number;
3745 $accountingjournal->fetch($objp->fk_accountancy_journal);
3746 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
3749 print
'<td class="right">';
3750 if ($objp->baid > 0) {
3751 print $bankaccountstatic->getNomUrl(1,
'transactions');
3755 print
'<td class="right">'.price($sign * $objp->amount).
'</td>';
3756 print
'<td class="center">';
3758 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deletepayment&token='.
newToken().
'&paiement_id='.$objp->rowid.
'">';
3764 $totalpaid += $objp->amount;
3768 print
'<tr class="oddeven"><td colspan="'.$nbcols.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td><td></td><td></td></tr>';
3791 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3792 print
'<span class="opacitymedium">';
3794 print $langs->trans(
'AlreadyPaidNoCreditNotesNoDeposits');
3796 print $langs->trans(
'AlreadyPaid');
3799 print
'</td><td class="right"'.(($totalpaid > 0) ?
' class="amountalreadypaid"' :
'').
'>'.
price($totalpaid).
'</td><td> </td></tr>';
3802 $resteapayeraffiche = $resteapayer;
3804 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
3807 $creditnoteamount = 0;
3810 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
3811 $sql .=
" re.description, re.fk_invoice_supplier_source";
3812 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
3813 $sql .=
" WHERE fk_invoice_supplier = ".((int)
$object->id);
3814 $resql = $db->query($sql);
3816 $num = $db->num_rows($resql);
3820 $obj = $db->fetch_object($resql);
3821 $invoice->fetch($obj->fk_invoice_supplier_source);
3822 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3824 print $langs->trans(
"CreditNote").
' ';
3827 print $langs->trans(
"Deposit").
' ';
3829 print $invoice->getNomUrl(0);
3831 print
'<td class="right">'.price($obj->amount_ttc).
'</td>';
3832 print
'<td class="right">';
3833 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=unlinkdiscount&discountid='.$obj->rowid.
'">';
3834 print
img_picto($langs->transnoentitiesnoconv(
"RemoveDiscount"),
'unlink');
3839 $creditnoteamount += $obj->amount_ttc;
3842 $depositamount += $obj->amount_ttc;
3851 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3852 print
'<span class="opacitymedium">';
3853 print $form->textwithpicto($langs->trans(
"Discount"), $langs->trans(
"HelpEscompte"), - 1);
3855 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3856 $resteapayeraffiche = 0;
3857 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3861 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3862 print
'<span class="opacitymedium">';
3863 print $form->textwithpicto($langs->trans(
"Abandoned"), $langs->trans(
"HelpAbandonBadCustomer"), - 1);
3865 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3867 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3871 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3872 print
'<span class="opacitymedium">';
3873 print $form->textwithpicto($langs->trans(
"ProductReturned"), $langs->trans(
"HelpAbandonProductReturned"), - 1);
3875 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3876 $resteapayeraffiche = 0;
3877 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3881 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3882 $text = $langs->trans(
"HelpAbandonOther");
3884 $text .=
'<br><br><b>'.$langs->trans(
"Reason").
'</b>:'.
$object->close_note;
3886 print
'<span class="opacitymedium">';
3888 print $form->textwithpicto($langs->trans(
"Abandoned"), $text, - 1);
3890 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3891 $resteapayeraffiche = 0;
3892 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3896 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3897 print
'<span class="opacitymedium">';
3898 print $langs->trans(
"Billed");
3900 print
'</td><td class="right">'.price(
$object->total_ttc).
'</td><td> </td></tr>';
3903 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3904 print
'<span class="opacitymedium">';
3905 print $langs->trans(
'RemainderToPay');
3906 if ($resteapayeraffiche < 0) {
3907 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
3911 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayeraffiche).
'</td><td> </td></tr>';
3914 if (isModEnabled(
'multicurrency') &&
$object->multicurrency_code !=
$conf->currency ||
$object->multicurrency_tx != 1) {
3915 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3916 print
'<span class="opacitymedium">';
3917 print $langs->trans(
'RemainderToPayMulticurrency');
3918 if ($resteapayeraffiche < 0) {
3919 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
3923 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price(
price2num($multicurrency_resteapayer,
'MT'), 0, $langs, 1, -1, -1,
$object->multicurrency_code).
'</td><td> </td></tr>';
3926 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3929 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3930 print $langs->trans(
'AlreadyPaidBack');
3931 print
' :</td><td class="right">'.price($sign * $totalpaid).
'</td><td> </td></tr>';
3934 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"Billed").
' :</td><td class="right">'.
price($sign *
$object->total_ttc).
'</td><td> </td></tr>';
3937 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3938 print
'<span class="opacitymedium">';
3939 print $langs->trans(
'RemainderToPayBack');
3940 if ($resteapayeraffiche > 0) {
3941 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
3945 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($sign * $resteapayeraffiche).
'</td><td> </td></tr>';
3948 if (isModEnabled(
'multicurrency') &&
$object->multicurrency_code !=
$conf->currency ||
$object->multicurrency_tx != 1) {
3949 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3950 print
'<span class="opacitymedium">';
3951 print $langs->trans(
'RemainderToPayBackMulticurrency');
3952 if ($resteapayeraffiche > 0) {
3953 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
3957 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>';
3972 print
'<div class="clearboth"></div><br>';
3975 $blocname =
'contacts';
3976 $title = $langs->trans(
'ContactsAddresses');
3977 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
3982 $blocname =
'notes';
3983 $title = $langs->trans(
'Notes');
3984 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
3991 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
3992 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3993 print
'<input type="hidden" name="action" value="'.(($action !=
'editline') ?
'addline' :
'updateline').
'">';
3994 print
'<input type="hidden" name="mode" value="">';
3995 print
'<input type="hidden" name="page_y" value="">';
3996 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
3997 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
3998 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
4001 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
4004 print
'<div class="div-table-responsive-no-min">';
4005 print
'<table id="tablelines" class="noborder noshadow centpercent">';
4007 global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax;
4010 $inputalsopricewithtax = 1;
4011 $senderissupplier = 2;
4012 if (
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY')) {
4013 $senderissupplier =
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY');
4018 $object->printObjectLines($action, $societe, $mysoc, $lineid, 1);
4025 if ($action !=
'editline') {
4028 $parameters = array();
4029 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters,
$object, $action);
4033 if (empty($reshook)) {
4034 $object->formAddObjectLine(1, $societe, $mysoc);
4047 if ($action !=
'presend') {
4050 print
'<div class="tabsAction">';
4052 $parameters = array();
4053 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
4055 if (empty($reshook)) {
4059 $ventilExportCompta =
$object->getVentilExportCompta();
4061 if ($ventilExportCompta == 0) {
4062 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
'Modify').
'</a>';
4064 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseDispatchedInBookkeeping").
'">'.$langs->trans(
'Modify').
'</span>';
4069 $result = $discount->fetch(0, 0,
$object->id);
4076 if (!$objectidnext &&
$object->close_code !=
'replaced' && $usercancreate) {
4077 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=reopen&token='.
newToken().
'">'.$langs->trans(
'ReOpen').
'</a>';
4079 if ($usercancreate) {
4080 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseReplacedInvoice").
'">'.$langs->trans(
'ReOpen').
'</span>';
4082 print
'<span class="butActionRefused classfortooltip">'.$langs->trans(
'ReOpen').
'</span>';
4092 if ($usercanvalidate) {
4093 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=valid&token='.
newToken().
'"';
4094 print
'>'.$langs->trans(
'Validate').
'</a>';
4096 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'"';
4097 print
'>'.$langs->trans(
'Validate').
'</a>';
4103 if (empty($user->socid)) {
4106 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a>';
4108 print
'<span class="butActionRefused classfortooltip">'.$langs->trans(
'SendMail').
'</span>';
4115 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>';
4122 if ($resteapayer == 0) {
4123 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseRemainderToPayIsZero").
'">'.$langs->trans(
'DoPaymentBack').
'</span>';
4125 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>';
4131 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.
newToken().
'">'.$langs->trans(
'ConvertExcessPaidToReduc').
'</a>';
4135 && (
getDolGlobalString(
'SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED') ||
$object->getSommePaiement() == 0)
4137 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>';
4141 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.
newToken().
'">'.$langs->trans(
'ConvertToReduc').
'</a>';
4152 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=paid&token='.
newToken().
'">'.$langs->trans(
'ClassifyPaid').
'</a>';
4157 if ($totalpaid > 0 || $totalcreditnotes > 0) {
4159 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=paid&token='.
newToken().
'">'.$langs->trans(
'ClassifyPaidPartially').
'</a>';
4162 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=canceled">'.$langs->trans(
'ClassifyCanceled').
'</a>';
4174 if (!$objectidnext) {
4175 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>';
4180 if ($action !=
'edit' && $usercancreate) {
4181 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=clone&socid='.
$object->socid.
'&token='.
newToken().
'">'.$langs->trans(
'ToClone').
'</a>';
4186 if (!$objectidnext && count(
$object->lines) > 0) {
4187 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.
$object->id.
'&action=create">'.$langs->trans(
"ChangeIntoRepeatableInvoice").
'</a>';
4192 if ($action !=
'confirm_edit' && $usercandelete) {
4193 $isErasable =
$object->is_erasable();
4195 $enableDelete =
false;
4197 $params = (empty(
$conf->use_javascript_ajax) ? array() : array(
'attr' => array(
'class' =>
'reposition')));
4199 if ($isErasable == -4) {
4200 $htmltooltip = $langs->trans(
"DisabledBecausePayments");
4201 } elseif ($isErasable == -3) {
4202 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastSituationInvoice");
4203 } elseif ($isErasable == -2) {
4204 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastInvoice");
4205 } elseif ($isErasable == -1) {
4206 $htmltooltip = $langs->trans(
"DisabledBecauseDispatchedInBookkeeping");
4207 } elseif ($isErasable <= 0) {
4208 $htmltooltip = $langs->trans(
"DisabledBecauseNotErasable");
4210 $enableDelete =
true;
4217 if ($action !=
'confirm_edit') {
4218 print
'<div class="fichecenter"><div class="fichehalfleft">';
4225 $filedir =
$conf->fournisseur->facture->dir_output.
'/'.$subdir;
4226 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.
$object->id;
4227 $genallowed = $usercanread;
4228 $delallowed = $usercancreate;
4232 print $formfile->showdocuments(
'facture_fournisseur', $subdir, $filedir, $urlsource, $genallowed, $delallowed, $modelpdf, $genifempty, 0, 0, 40, 0,
'',
'',
'', $societe->default_lang);
4233 $somethingshown = $formfile->numoffiles;
4236 $tmparray = $form->showLinkToObjectBlock(
$object, array(), array(
'invoice_supplier'), 1);
4237 $linktoelem = $tmparray[
'linktoelem'];
4238 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
4239 print $htmltoenteralink;
4241 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
4243 print
'</div><div class="fichehalfright">';
4246 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
4248 $somethingshown = $formactions->showactions(
$object,
'invoice_supplier', $socid, 1,
'listaction'.($genallowed ?
'largetitle' :
''));
4250 print
'</div></div>';
4256 if (
GETPOST(
'modelselected')) {
4257 $action =
'presend';
4261 $modelmail =
'invoice_supplier_send';
4262 $defaulttopic =
'SendBillRef';
4263 $diroutput =
$conf->fournisseur->facture->dir_output;
4264 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
4265 $trackid =
'sinv'.$object->id;
4267 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
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.
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)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.