39require
'../../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
43require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture-rec.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
51if (isModEnabled(
"product")) {
52 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
53 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
55if (isModEnabled(
'project')) {
56 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
57 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
60if (isModEnabled(
'variants')) {
61 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
63if (isModEnabled(
'accounting')) {
64 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
76$langs->loadLangs(array(
'bills',
'compta',
'suppliers',
'companies',
'products',
'banks',
'admin'));
77if (isModEnabled(
'incoterm')) {
78 $langs->load(
'incoterm');
83$action =
GETPOST(
'action',
'aZ09');
86$cancel =
GETPOST(
'cancel',
'alpha');
87$backtopage =
GETPOST(
'backtopage',
'alpha');
88$backtopageforcancel =
'';
92$origin =
GETPOST(
'origin',
'alpha');
103$hookmanager->initHooks(array(
'invoicesuppliercard',
'globalcard'));
109$extrafields->fetch_name_optionals_label(
$object->table_element);
112if ($id > 0 || !empty($ref)) {
113 $ret =
$object->fetch($id, $ref);
117 $ret =
$object->fetch_thirdparty();
125if (!empty($user->socid)) {
126 $socid = $user->socid;
130$result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture',
'fk_soc',
'rowid', $isdraft);
133$usercanread = ($user->hasRight(
"fournisseur",
"facture",
"lire") || $user->hasRight(
"supplier_invoice",
"lire"));
134$usercancreate = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
135$usercandelete = ($user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"supprimer"));
136$usercancreatecontract = $user->hasRight(
"contrat",
"creer");
139$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"validate")));
140$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"send"));
143$permissionnote = $usercancreate;
144$permissiondellink = $usercancreate;
145$permissiontoedit = $usercancreate;
146$permissiontoadd = $usercancreate;
147$permissiontodelete = $usercandelete;
156$parameters = array(
'socid' => $socid);
157$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
162if (empty($reshook)) {
163 $backurlforlist = DOL_URL_ROOT.
'/fourn/facture/list.php';
165 if (empty($backtopage) || ($cancel && empty($id))) {
166 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
167 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
168 $backtopage = $backurlforlist;
170 $backtopage = DOL_URL_ROOT.
'/fourn/facture/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
176 if (!empty($backtopageforcancel)) {
177 header(
"Location: ".$backtopageforcancel);
179 } elseif (!empty($backtopage)) {
180 header(
"Location: ".$backtopage);
186 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
188 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
190 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
193 if (
GETPOST(
'linkedOrder') && empty($cancel) && $id > 0 && $permissiontoadd) {
196 $result =
$object->add_object_linked(
'order_supplier',
GETPOST(
'linkedOrder'));
200 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
202 '@phan-var-force FactureFournisseur $objectutil';
204 if (
GETPOST(
'newsupplierref',
'alphanohtml')) {
205 $objectutil->ref_supplier =
GETPOST(
'newsupplierref',
'alphanohtml');
209 $result = $objectutil->createFromClone($user, $id);
211 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
214 $langs->load(
"errors");
218 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' && $usercanvalidate) {
219 $idwarehouse =
GETPOST(
'idwarehouse');
224 $qualified_for_stock_change = 0;
226 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
228 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
232 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
233 $langs->load(
"stocks");
234 if (!$idwarehouse || $idwarehouse == -1) {
236 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
244 $result =
$object->validate($user,
'', $idwarehouse);
254 $outputlangs = $langs;
257 $newlang =
GETPOST(
'lang_id',
'aZ09');
260 $newlang =
$object->thirdparty->default_lang;
262 if (!empty($newlang)) {
264 $outputlangs->setDefaultLang($newlang);
269 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
276 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontodelete) {
280 $isErasable =
$object->is_erasable();
282 if (($usercandelete && $isErasable > 0) || ($usercancreate && $isErasable == 1)) {
283 $revertstock =
GETPOST(
'revertstock');
286 $idwarehouse =
GETPOST(
'idwarehouse');
288 $qualified_for_stock_change = 0;
290 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
292 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
296 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
297 $langs->load(
"stocks");
298 if (!$idwarehouse || $idwarehouse == -1) {
300 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
303 $result =
$object->setDraft($user, $idwarehouse);
312 $result =
$object->delete($user);
314 header(
'Location: list.php?restore_lastsearch_values=1');
321 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
323 $result =
$object->deleteLine($lineid);
343 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
350 } elseif ($action ==
'unlinkdiscount' && $usercancreate) {
353 $result = $discount->fetch(
GETPOSTINT(
"discountid"));
354 $discount->unlink_invoice();
355 } elseif ($action ==
'confirm_paid' && $confirm ==
'yes' && $usercancreate) {
357 $result =
$object->setPaid($user);
361 } elseif ($action ==
'confirm_paid_partially' && $confirm ==
'yes' && $usercancreate) {
364 $close_code =
GETPOST(
"close_code",
'restricthtml');
365 $close_note =
GETPOST(
"close_note",
'restricthtml');
367 $result =
$object->setPaid($user, $close_code, $close_note);
372 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Reason")),
null,
'errors');
374 } elseif ($action ==
'confirm_canceled' && $confirm ==
'yes' && $usercancreate) {
377 $close_code =
GETPOST(
"close_code",
'restricthtml');
378 $close_note =
GETPOST(
"close_note",
'restricthtml');
380 $result =
$object->setCanceled($user, $close_code, $close_note);
385 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Reason")),
null,
'errors');
390 if ($action ==
'setref_supplier' && $usercancreate) {
393 if (
$object->update($user) < 0) {
397 $outputlangs = $langs;
400 $newlang =
GETPOST(
'lang_id',
'aZ09');
403 $newlang =
$object->thirdparty->default_lang;
405 if (!empty($newlang)) {
407 $outputlangs->setDefaultLang($newlang);
411 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
417 if ($action ==
'setconditions' && $usercancreate) {
419 $object->cond_reglement_code = 0;
420 $object->cond_reglement_id = 0;
435 $new_date_echeance =
$object->calculate_date_lim_reglement();
436 if ($new_date_echeance) {
437 $object->date_echeance = $new_date_echeance;
442 $result =
$object->update($user);
454 } elseif ($action ==
'set_incoterms' && isModEnabled(
'incoterm') && $usercancreate) {
457 } elseif ($action ==
'setmode' && $usercancreate) {
460 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
462 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
463 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
466 } elseif ($action ==
'setbankaccount' && $usercancreate) {
469 } elseif ($action ==
'setvatreversecharge' && $usercancreate) {
471 $vatreversecharge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
472 $result =
$object->setVATReverseCharge($vatreversecharge);
475 if ($action ==
'settransportmode' && $usercancreate) {
478 } elseif ($action ==
'setlabel' && $usercancreate) {
482 $result =
$object->update($user);
486 } elseif ($action ==
'setdatef' && $usercancreate) {
490 setEventMessages($langs->trans(
"WarningInvoiceDateInFuture"),
null,
'warnings');
492 setEventMessages($langs->trans(
"WarningInvoiceDateTooFarInFuture"),
null,
'warnings');
499 $date_echence_calc =
$object->calculate_date_lim_reglement();
500 if (!empty(
$object->date_echeance)) {
501 $object->date_echeance = $date_echence_calc;
507 $result =
$object->update($user);
511 } elseif ($action ==
'setdate_lim_reglement' && $usercancreate) {
516 setEventMessages($langs->trans(
"DatePaymentTermCantBeLowerThanObjectDate"),
null,
'warnings');
518 $result =
$object->update($user);
522 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
538 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
540 $discount->fetch(
GETPOSTINT(
"remise_id_for_payment"));
544 $remaintopay =
$object->getRemainToPay(0);
548 setEventMessages($langs->trans(
"ErrorDiscountLargerThanRemainToPaySplitItBefore"),
null,
'errors');
552 $result = $discount->link_to_invoice(0, $id);
559 $newremaintopay =
$object->getRemainToPay(0);
560 if ($newremaintopay == 0) {
571 $outputlangs = $langs;
574 $newlang =
GETPOST(
'lang_id',
'aZ09');
577 $newlang =
$object->thirdparty->default_lang;
579 if (!empty($newlang)) {
581 $outputlangs->setDefaultLang($newlang);
585 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
590 } elseif ($action ==
'confirm_converttoreduc' && $confirm ==
'yes' && $usercancreate) {
598 $result = $discountcheck->fetch(0, 0,
$object->id);
610 $amount_ht = $amount_tva = $amount_ttc = array();
611 $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array();
615 foreach (
$object->lines as $line) {
616 if ($line->product_type < 9 && $line->total_ht != 0) {
617 $keyforvatrate = $line->tva_tx.($line->vat_src_code ?
' ('.$line->vat_src_code.
')' :
'');
619 $amount_ht[$keyforvatrate] += $line->total_ht;
620 $amount_tva[$keyforvatrate] += $line->total_tva;
621 $amount_ttc[$keyforvatrate] += $line->total_ttc;
622 $multicurrency_amount_ht[$keyforvatrate] += $line->multicurrency_total_ht;
623 $multicurrency_amount_tva[$keyforvatrate] += $line->multicurrency_total_tva;
624 $multicurrency_amount_ttc[$keyforvatrate] += $line->multicurrency_total_ttc;
628 '@phan-var-force array<string,float> $amount_ht
629 @phan-var-force array<string,float> $amount_tva
630 @phan-var-force array<string,float> $amount_ttc
631 @phan-var-force array<string,float> $multicurrency_amount_ht
632 @phan-var-force array<string,float> $multicurrency_amount_tva
633 @phan-var-force array<string,float> $multicurrency_amount_ttc';
637 $alreadypaid =
$object->getSommePaiement();
638 if ($alreadypaid && abs($alreadypaid) < abs(
$object->total_ttc)) {
639 $ratio = abs((
$object->total_ttc - $alreadypaid) /
$object->total_ttc);
640 foreach ($amount_ht as $vatrate => $val) {
641 $amount_ht[$vatrate] =
price2num($amount_ht[$vatrate] * $ratio,
'MU');
642 $amount_tva[$vatrate] =
price2num($amount_tva[$vatrate] * $ratio,
'MU');
643 $amount_ttc[$vatrate] =
price2num($amount_ttc[$vatrate] * $ratio,
'MU');
644 $multicurrency_amount_ht[$vatrate] =
price2num($multicurrency_amount_ht[$vatrate] * $ratio,
'MU');
645 $multicurrency_amount_tva[$vatrate] =
price2num($multicurrency_amount_tva[$vatrate] * $ratio,
'MU');
646 $multicurrency_amount_ttc[$vatrate] =
price2num($multicurrency_amount_ttc[$vatrate] * $ratio,
'MU');
655 $discount->description =
'(CREDIT_NOTE)';
657 $discount->description =
'(DEPOSIT)';
659 $discount->description =
'(EXCESS PAID)';
661 setEventMessages($langs->trans(
'CantConvertToReducAnInvoiceOfThisType'),
null,
'errors');
663 $discount->discount_type = 1;
664 $discount->fk_soc =
$object->socid;
665 $discount->socid =
$object->socid;
666 $discount->fk_invoice_supplier_source =
$object->id;
674 $sql =
'SELECT SUM(pf.amount) as total_paiements';
675 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.
'paiementfourn as p';
676 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN ('.
getEntity(
'c_paiement').
')';
677 $sql .=
' WHERE pf.fk_facturefourn = '.((int)
$object->id);
678 $sql .=
' AND pf.fk_paiementfourn = p.rowid';
679 $sql .=
' AND p.entity IN ('.getEntity(
'invoice').
')';
681 $resql = $db->query($sql);
686 $res = $db->fetch_object($resql);
687 $total_paiements = $res->total_paiements;
690 $total_creditnote_and_deposit = 0;
691 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
692 $sql .=
" re.description, re.fk_invoice_supplier_source";
693 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
694 $sql .=
" WHERE fk_invoice_supplier = ".((int)
$object->id);
695 $resql = $db->query($sql);
696 if (!empty($resql)) {
697 while ($obj = $db->fetch_object($resql)) {
698 $total_creditnote_and_deposit += $obj->amount_ttc;
704 $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit -
$object->total_ttc;
705 $discount->amount_tva = 0;
706 $discount->tva_tx = 0;
707 $discount->vat_src_code =
'';
709 $result = $discount->create($user);
715 foreach ($amount_ht as $tva_tx => $xxx) {
716 $discount->amount_ht = abs((
float) $amount_ht[$tva_tx]);
717 $discount->amount_tva = abs((
float) $amount_tva[$tva_tx]);
718 $discount->amount_ttc = abs((
float) $amount_ttc[$tva_tx]);
719 $discount->multicurrency_amount_ht = abs((
float) $multicurrency_amount_ht[$tva_tx]);
720 $discount->multicurrency_amount_tva = abs((
float) $multicurrency_amount_tva[$tva_tx]);
721 $discount->multicurrency_amount_ttc = abs((
float) $multicurrency_amount_ttc[$tva_tx]);
726 if (preg_match(
'/\((.*)\)/', $tva_tx, $reg)) {
727 $vat_src_code = $reg[1];
728 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx);
731 $discount->tva_tx = abs((
float) $tva_tx);
732 $discount->vat_src_code = $vat_src_code;
734 $result = $discount->create($user);
745 $result =
$object->setPaid($user);
760 } elseif ($action ==
'confirm_delete_paiement' && $confirm ==
'yes' && $usercancreate) {
765 $result = $paiementfourn->fetch(
GETPOST(
'paiement_id'));
767 $result = $paiementfourn->delete($user);
769 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
777 } elseif ($action ==
'add' && $usercancreate) {
782 $selectedLines =
GETPOST(
'toselect',
'array');
790 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
804 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
809 if (empty($dateinvoice)) {
810 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
822 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ReplaceInvoice")),
null,
'errors');
836 $object->date_echeance = $datedue;
842 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
843 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
845 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
846 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
867 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CorrectInvoice")),
null,
'errors');
870 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Supplier')),
null,
'errors');
875 if (empty($dateinvoice)) {
876 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
886 if (!
GETPOST(
'ref_supplier')) {
887 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'RefSupplierBill')),
null,
'errors');
895 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
910 $object->date_echeance = $datedue;
916 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
917 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
919 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
920 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
925 $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice :
'';
934 if (
GETPOSTINT(
'invoiceAvoirWithLines') == 1 && $id > 0) {
936 if ($facture_source->fetch(
$object->fk_facture_source) > 0) {
939 foreach ($facture_source->lines as $line) {
941 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
945 $line->fk_facture_fourn =
$object->id;
946 $line->fk_parent_line = $fk_parent_line;
948 $line->subprice = -$line->subprice;
949 $line->pa_ht = -((float) $line->pa_ht);
950 $line->total_ht = -$line->total_ht;
951 $line->total_tva = -$line->total_tva;
952 $line->total_ttc = -$line->total_ttc;
953 $line->total_localtax1 = -$line->total_localtax1;
954 $line->total_localtax2 = -$line->total_localtax2;
956 $result = $line->insert();
961 if ($result > 0 && $line->product_type == 9) {
962 $fk_parent_line = $result;
970 if (
GETPOSTINT(
'invoiceAvoirWithPaymentRestAmount') == 1 &&
$id > 0) {
972 if ($facture_source->fetch(
$object->fk_facture_source) > 0) {
973 $totalpaid = $facture_source->getSommePaiement();
974 $totalcreditnotes = $facture_source->getSumCreditNotesUsed();
975 $totaldeposits = $facture_source->getSumDepositsUsed();
976 $remain_to_pay = abs($facture_source->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits);
977 $desc = $langs->trans(
'invoiceAvoirLineWithPaymentRestAmount');
978 $retAddLine =
$object->addline($desc, $remain_to_pay, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
'TTC');
980 if ($retAddLine < 0) {
988 if (empty($dateinvoice)) {
990 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
1000 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
1010 $object->note_public = trim(
GETPOST(
'note_public',
'restricthtml'));
1011 $object->note_private = trim(
GETPOST(
'note_private',
'restricthtml'));
1022 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
1023 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
1027 $object->fac_rec = $fac_recid;
1029 $fac_rec->fetch(
$object->fac_rec);
1030 $fac_rec->fetch_lines();
1031 $object->lines = $fac_rec->lines;
1038 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Supplier')),
null,
'errors');
1043 if (empty($dateinvoice)) {
1044 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
1054 if (!
GETPOST(
'ref_supplier')) {
1055 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'RefSupplierBill')),
null,
'errors');
1063 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
1080 $object->date_echeance = $datedue;
1086 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
1087 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
1089 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
1090 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
1095 if (empty(
$object->date_echeance)) {
1096 $object->date_echeance =
$object->calculate_date_lim_reglement();
1102 if (!$error &&
GETPOST(
'origin',
'alpha') &&
GETPOST(
'originid')) {
1104 $element = $subelement =
GETPOST(
'origin',
'alpha');
1112 if ($element ==
'order') {
1113 $element = $subelement =
'commande';
1115 if ($element ==
'propal') {
1116 $element =
'comm/propal';
1117 $subelement =
'propal';
1119 if ($element ==
'contract') {
1120 $element = $subelement =
'contrat';
1122 if ($element ==
'order_supplier') {
1124 $subelement =
'fournisseur.commande';
1126 if ($element ==
'project') {
1127 $element =
'projet';
1133 require_once DOL_DOCUMENT_ROOT.
'/'.$element.
'/class/'.$subelement.
'.class.php';
1134 $classname = ucfirst($subelement);
1135 if ($classname ==
'Fournisseur.commande') {
1136 $classname =
'CommandeFournisseur';
1138 $objectsrc =
new $classname($db);
1139 $objectsrc->fetch($originid);
1140 $objectsrc->fetch_thirdparty();
1147 if (
$object->origin ==
'reception') {
1148 $objectsrc->fetchObjectLinked();
1150 if (count($objectsrc->linkedObjectsIds[
'order_supplier']) > 0) {
1151 foreach ($objectsrc->linkedObjectsIds[
'order_supplier'] as $key => $value) {
1152 $object->linkedObjectsIds[
'order_supplier'] = $value;
1161 require_once DOL_DOCUMENT_ROOT.
'/'.$element.
'/class/'.$subelement.
'.class.php';
1162 $classname = ucfirst($subelement);
1163 if ($classname ==
'Fournisseur.commande') {
1164 $classname =
'CommandeFournisseur';
1166 $srcobject =
new $classname($db);
1168 $result = $srcobject->fetch(
GETPOSTINT(
'originid'));
1171 $typeamount =
GETPOST(
'typedeposit',
'alpha');
1176 $amountdeposit = array();
1178 if ($typeamount ==
'amount') {
1179 $amount = $valuedeposit;
1181 $amount = $srcobject->total_ttc * ((float) $valuedeposit / 100);
1184 $TTotalByTva = array();
1185 foreach ($srcobject->lines as &$line) {
1186 if (!empty($line->special_code)) {
1189 $TTotalByTva[$line->tva_tx] += $line->total_ttc;
1191 '@phan-var-force array<string,float> $TTotalByTva';
1193 $amount_ttc_diff = 0.;
1194 foreach ($TTotalByTva as $tva => &$total) {
1195 $coef = $total / $srcobject->total_ttc;
1196 $am = $amount * $coef;
1197 $amount_ttc_diff += $am;
1198 $amountdeposit[$tva] += $am / (1 + (float) $tva / 100);
1201 if ($typeamount ==
'amount') {
1202 $amountdeposit[0] = $valuedeposit;
1203 } elseif ($typeamount ==
'variable') {
1206 $lines = $srcobject->lines;
1207 $numlines = count($lines);
1208 for ($i = 0; $i < $numlines; $i++) {
1210 if (empty($lines[$i]->qty)) {
1213 if (!empty($lines[$i]->special_code)) {
1217 $totalamount += $lines[$i]->total_ht;
1218 $tva_tx = $lines[$i]->tva_tx;
1219 $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * (float) $valuedeposit) / 100;
1223 if ($totalamount == 0) {
1224 $amountdeposit[0] = 0;
1229 $amountdeposit[0] = 0;
1233 $amount_ttc_diff = $amountdeposit[0];
1236 foreach ($amountdeposit as $tva => $amount) {
1237 if (empty($amount)) {
1242 'amount' =>
'FixAmount',
1243 'variable' =>
'VarAmount'
1245 $descline =
'(DEPOSIT)';
1247 if ($typeamount ==
'amount') {
1248 $descline .=
' ('.price($valuedeposit, 0, $langs, 0, - 1, - 1, (!empty(
$object->multicurrency_code) ?
$object->multicurrency_code :
$conf->currency)).
')';
1249 } elseif ($typeamount ==
'variable') {
1250 $descline .=
' ('.$valuedeposit.
'%)';
1253 $descline .=
' - '.$srcobject->ref;
1283 $diff =
$object->total_ttc - $amount_ttc_diff;
1287 $subprice_diff =
$object->lines[0]->subprice - $diff / (1 +
$object->lines[0]->tva_tx / 100);
1293 $object->lines[0]->localtax1_tx,
1294 $object->lines[0]->localtax2_tx,
1296 $object->lines[0]->fk_product,
1299 $object->lines[0]->product_type,
1300 $object->lines[0]->remise_percent,
1302 $object->lines[0]->date_start,
1311 } elseif ($result > 0) {
1312 $lines = $srcobject->lines;
1313 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
1314 $srcobject->fetch_lines();
1315 $lines = $srcobject->lines;
1318 $num = count($lines);
1319 for ($i = 0; $i < $num; $i++) {
1320 if (!in_array($lines[$i]->
id, $selectedLines)) {
1324 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->product_label);
1325 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
1328 if (method_exists($lines[$i],
'fetch_optionals')) {
1329 $lines[$i]->fetch_optionals();
1334 $date_start = $lines[$i]->date_debut_prevue;
1335 if ($lines[$i]->date_debut_reel) {
1336 $date_start = $lines[$i]->date_debut_reel;
1338 if ($lines[$i]->date_start) {
1339 $date_start = $lines[$i]->date_start;
1341 $date_end = $lines[$i]->date_fin_prevue;
1342 if ($lines[$i]->date_fin_reel) {
1343 $date_end = $lines[$i]->date_fin_reel;
1345 if ($lines[$i]->date_end) {
1346 $date_end = $lines[$i]->date_end;
1349 $tva_tx = $lines[$i]->tva_tx;
1350 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', (
string) $tva_tx)) {
1351 $tva_tx .=
' ('.$lines[$i]->vat_src_code.
')';
1355 $object->special_code = $lines[$i]->special_code;
1360 $pu_currency = $lines[$i]->multicurrency_subprice;
1362 $pu = $lines[$i]->subprice;
1371 $lines[$i]->localtax1_tx,
1372 $lines[$i]->localtax2_tx,
1374 $lines[$i]->fk_product,
1375 $lines[$i]->remise_percent,
1379 $lines[$i]->info_bits,
1384 $lines[$i]->array_options,
1385 $lines[$i]->fk_unit,
1388 $lines[$i]->ref_supplier,
1389 $lines[$i]->special_code
1406 } elseif (!$error) {
1416 $langs->load(
"errors");
1426 $outputlangs = $langs;
1427 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1434 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
1437 } elseif ($action ==
'updateline' && $usercancreate) {
1441 if (!
$object->fetch($id) > 0) {
1447 $tva_tx = str_replace(
'*',
'', $tva_tx);
1449 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_subprice') !=
'') {
1451 $price_base_type =
'HT';
1454 $price_base_type =
'TTC';
1457 if (
GETPOST(
'productid') > 0) {
1459 if (
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY') == 1) {
1461 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1466 $prod->fetch(
GETPOST(
'productid'));
1467 $label = $prod->description;
1468 if (trim(
GETPOST(
'product_desc',
'restricthtml')) != trim($label)) {
1469 $label =
GETPOST(
'product_desc',
'restricthtml');
1472 $type = $prod->type;
1474 $label =
GETPOST(
'product_desc',
'restricthtml');
1483 if (preg_match(
'/\*/', $tva_tx)) {
1488 $tva_tx = str_replace(
'*',
'', $tva_tx);
1496 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1497 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1499 if (is_array($extralabelsline)) {
1500 foreach ($extralabelsline as $key => $value) {
1501 unset($_POST[
"options_".$key]);
1505 $result =
$object->updateline(
1527 unset($_POST[
'label']);
1528 unset($_POST[
'fourn_ref']);
1529 unset($_POST[
'date_starthour']);
1530 unset($_POST[
'date_startmin']);
1531 unset($_POST[
'date_startsec']);
1532 unset($_POST[
'date_startday']);
1533 unset($_POST[
'date_startmonth']);
1534 unset($_POST[
'date_startyear']);
1535 unset($_POST[
'date_endhour']);
1536 unset($_POST[
'date_endmin']);
1537 unset($_POST[
'date_endsec']);
1538 unset($_POST[
'date_endday']);
1539 unset($_POST[
'date_endmonth']);
1540 unset($_POST[
'date_endyear']);
1541 unset($_POST[
'price_ttc']);
1542 unset($_POST[
'price_ht']);
1549 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') && (
GETPOST(
'alldate_start',
'alpha') ||
GETPOST(
'alldate_end',
'alpha')) && $usercancreate) {
1553 foreach (
$object->lines as $line) {
1554 if ($line->product_type == 1) {
1555 $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);
1558 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') !=
'' && $usercancreate) {
1560 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
1561 $vat_rate = str_replace(
'*',
'', $vat_rate);
1564 foreach (
$object->lines as $line) {
1565 $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);
1567 } elseif ($action ==
'addline' && $usercancreate) {
1576 $ret =
$object->fetch_thirdparty();
1578 $langs->load(
'errors');
1583 $product_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
1587 $prod_entry_mode =
GETPOST(
'prod_entry_mode');
1588 if ($prod_entry_mode ==
'free') {
1595 $price_ht_devise =
'';
1597 $price_ttc_devise =
'';
1599 if (
GETPOST(
'price_ht') !==
'') {
1602 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
1605 if (
GETPOST(
'price_ttc') !==
'') {
1608 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
1609 $price_ttc_devise =
price2num(
GETPOST(
'multicurrency_price_ttc'),
'CU', 2);
1616 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef,
'alpha'),
'', 2) : 0);
1617 if (empty($remise_percent)) {
1618 $remise_percent = 0;
1622 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1623 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1625 if (is_array($extralabelsline)) {
1627 foreach ($extralabelsline as $key => $value) {
1628 unset($_POST[
"options_".$key]);
1632 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
1633 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1636 if ($prod_entry_mode ==
'free' && !
GETPOST(
'idprodfournprice') &&
GETPOST(
'type') < 0) {
1637 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
1642 if (($price_ht < 0 || $price_ttc < 0) && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) {
1643 $langs->load(
"errors");
1644 if (
$object->type == $object::TYPE_DEPOSIT) {
1646 setEventMessages($langs->trans(
"ErrorLinesCantBeNegativeOnDeposits"),
null,
'errors');
1648 setEventMessages($langs->trans(
"ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv(
"UnitPriceHT"), $langs->transnoentitiesnoconv(
"CustomerAbsoluteDiscountShort")),
null,
'errors');
1652 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"UnitPriceHT")),
null,
'errors');
1658 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' && $price_ht_devise ===
'') {
1659 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'UnitPrice')),
null,
'errors');
1662 if ($prod_entry_mode ==
'free' && !
GETPOST(
'dp_desc')) {
1663 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
1666 if (!
GETPOST(
'qty',
'alpha')) {
1667 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1671 if (!$error && isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1672 if ($combinations =
GETPOST(
'combinations',
'array')) {
1676 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1677 $idprod = $res->fk_product_child;
1679 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1685 if ($prod_entry_mode !=
'free' && empty($error)) {
1689 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
1694 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
1696 $res = $productsupplier->fetch($idprod);
1699 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
1701 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1702 if ($productsupplier->fourn_socid != $socid) {
1703 $productsupplier->ref_supplier =
'';
1706 $fksoctosearch =
$object->thirdparty->id;
1707 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1709 } elseif (
GETPOST(
'idprodfournprice',
'alpha') > 0) {
1710 $qtytosearch = $qty;
1712 $idprod = $productsupplier->get_buyprice(
GETPOST(
'idprodfournprice',
'alpha'), $qtytosearch);
1713 $res = $productsupplier->fetch($idprod);
1717 $label = $productsupplier->label;
1720 $outputlangs = $langs;
1722 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
1723 $newlang =
GETPOST(
'lang_id',
'aZ09');
1725 if (empty($newlang)) {
1726 $newlang =
$object->thirdparty->default_lang;
1728 if (!empty($newlang)) {
1730 $outputlangs->setDefaultLang($newlang);
1732 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->
description;
1734 $desc = $productsupplier->description;
1737 if (!empty($productsupplier->desc_supplier) &&
getDolGlobalString(
'PRODUIT_FOURN_TEXTS')) {
1738 $desc = $productsupplier->desc_supplier;
1742 if (trim($product_desc) == trim($desc) &&
getDolGlobalString(
'PRODUIT_AUTOFILL_DESC')) {
1746 $desc = $product_desc;
1748 if (!empty($product_desc) && trim($product_desc) != trim($desc)) {
1752 $ref_supplier = $productsupplier->ref_supplier;
1755 if (!GETPOSTISSET(
'tva_tx')) {
1756 $tmpidprodfournprice =
GETPOST(
'idprodfournprice',
'alpha');
1757 if (is_numeric($tmpidprodfournprice) && (
int) $tmpidprodfournprice > 0) {
1758 $tmpidprodfournprice = (int) $tmpidprodfournprice;
1760 $tmpidprodfournprice = 0;
1766 if (empty($tva_tx) || empty($tva_npr)) {
1772 $type = $productsupplier->type;
1773 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1774 $price_base_type =
'HT';
1776 $pu_devise =
price2num($price_ht_devise,
'CU');
1777 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
1778 $price_base_type =
'TTC';
1780 $pu_devise =
price2num($price_ttc_devise,
'CU');
1782 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
1783 if (empty(
$object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code !=
$object->multicurrency_code)) {
1784 $pu = $productsupplier->fourn_pu;
1787 $pu = $productsupplier->fourn_pu;
1788 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
1792 $ref_supplier = $productsupplier->ref_supplier;
1813 min($rank, count(
$object->lines) + 1),
1816 $productsupplier->fk_unit,
1819 GETPOST(
'fourn_ref',
'alpha'),
1823 if ($idprod == -99 || $idprod == 0) {
1826 $langs->load(
"errors");
1827 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
1829 if ($idprod == -1) {
1832 $langs->load(
"errors");
1833 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
1835 } elseif (empty($error)) {
1836 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1837 $tva_tx = str_replace(
'*',
'', $tva_tx);
1838 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1839 $desc = $product_desc;
1841 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1843 $fk_unit =
GETPOST(
'units',
'alpha');
1845 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
1853 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1857 $pu_ht =
price2num((
float) $pu_ttc / (1 + ((
float) $tva_tx / 100)),
'MU');
1859 $price_base_type =
'HT';
1860 $pu_devise =
price2num($price_ht_devise,
'CU');
1862 $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);
1866 if (!$error && $result > 0) {
1871 $outputlangs = $langs;
1874 $newlang =
GETPOST(
'lang_id',
'aZ09');
1877 $newlang =
$object->thirdparty->default_lang;
1879 if (!empty($newlang)) {
1881 $outputlangs->setDefaultLang($newlang);
1886 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1892 unset($_POST [
'prod_entry_mode']);
1894 unset($_POST[
'qty']);
1895 unset($_POST[
'type']);
1896 unset($_POST[
'remise_percent']);
1897 unset($_POST[
'pu']);
1898 unset($_POST[
'price_ht']);
1899 unset($_POST[
'multicurrency_price_ht']);
1900 unset($_POST[
'price_ttc']);
1901 unset($_POST[
'fourn_ref']);
1902 unset($_POST[
'tva_tx']);
1903 unset($_POST[
'label']);
1904 unset($localtax1_tx);
1905 unset($localtax2_tx);
1906 unset($_POST[
'np_marginRate']);
1907 unset($_POST[
'np_markRate']);
1908 unset($_POST[
'dp_desc']);
1909 unset($_POST[
'idprodfournprice']);
1910 unset($_POST[
'units']);
1912 unset($_POST[
'date_starthour']);
1913 unset($_POST[
'date_startmin']);
1914 unset($_POST[
'date_startsec']);
1915 unset($_POST[
'date_startday']);
1916 unset($_POST[
'date_startmonth']);
1917 unset($_POST[
'date_startyear']);
1918 unset($_POST[
'date_endhour']);
1919 unset($_POST[
'date_endmin']);
1920 unset($_POST[
'date_endsec']);
1921 unset($_POST[
'date_endday']);
1922 unset($_POST[
'date_endmonth']);
1923 unset($_POST[
'date_endyear']);
1930 } elseif ($action ==
'classin' && $usercancreate) {
1932 $result =
$object->setProject($projectid);
1933 } elseif ($action ==
'confirm_edit' && $confirm ==
'yes' && $usercancreate) {
1937 $totalpaid =
$object->getSommePaiement();
1938 $resteapayer =
$object->total_ttc - $totalpaid;
1941 $ventilExportCompta =
$object->getVentilExportCompta();
1943 if (!$ventilExportCompta) {
1946 $idwarehouse =
GETPOST(
'idwarehouse');
1950 $qualified_for_stock_change = 0;
1952 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1954 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1958 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
1959 $langs->load(
"stocks");
1960 if (!$idwarehouse || $idwarehouse == -1) {
1962 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1967 $object->setDraft($user, $idwarehouse);
1971 $outputlangs = $langs;
1974 $newlang =
GETPOST(
'lang_id',
'aZ09');
1977 $newlang =
$object->thirdparty->default_lang;
1979 if (!empty($newlang)) {
1981 $outputlangs->setDefaultLang($newlang);
1986 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1995 } elseif ($action ==
'reopen' && $usercancreate) {
1997 $result =
$object->fetch($id);
2000 $result =
$object->setUnpaid($user);
2002 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
2011 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
2014 $triggersendname =
'BILL_SUPPLIER_SENTBYMAIL';
2016 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
2017 $trackid =
'sinv'.$object->id;
2018 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
2021 $upload_dir =
$conf->fournisseur->facture->dir_output;
2022 $permissiontoadd = $usercancreate;
2023 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
2026 if ($action ==
'calculate' && $usercancreate) {
2027 $calculationrule =
GETPOST(
'calculationrule');
2031 $result =
$object->update_price(0, (($calculationrule ==
'totalofround') ?
'0' :
'1'), 0,
$object->thirdparty);
2037 if ($action ==
'update_extras' && $usercancreate) {
2041 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
2048 $result =
$object->insertExtraFields(
'BILL_SUPPLIER_MODIFY');
2056 $action =
'edit_extras';
2061 if ($action ==
'addcontact' && $usercancreate) {
2062 $result =
$object->fetch($id);
2064 if ($result > 0 && $id > 0) {
2067 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
2071 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2074 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2075 $langs->load(
"errors");
2076 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
2081 } elseif ($action ==
'swapstatut' && $usercancreate) {
2088 } elseif ($action ==
'deletecontact' && $usercancreate) {
2094 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2108$form =
new Form($db);
2110$bankaccountstatic =
new Account($db);
2112if (isModEnabled(
'project')) {
2118$title =
$object->ref.
" - ".$langs->trans(
'Card');
2119if ($action ==
'create') {
2120 $title = $langs->trans(
"NewSupplierInvoice");
2122$help_url =
'EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores|DE:Modul_Lieferantenrechnungen';
2123llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-fourn-facture page-card');
2126if ($action ==
'create') {
2128 $selectedLines = array();
2130 print
load_fiche_titre($langs->trans(
'NewSupplierInvoice'),
'',
'supplier_invoice');
2134 $currency_code =
$conf->currency;
2140 if (isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2141 $currency_code = $societe->multicurrency_code;
2145 if (!empty($origin) && !empty($originid)) {
2147 $element = $subelement = $origin;
2149 if ($element ==
'project') {
2150 $projectid = $originid;
2151 $element =
'projet';
2155 if ($element ==
'order') {
2156 $element = $subelement =
'commande';
2158 if ($element ==
'propal') {
2159 $element =
'comm/propal';
2160 $subelement =
'propal';
2162 if ($element ==
'contract') {
2163 $element = $subelement =
'contrat';
2165 if ($element ==
'order_supplier') {
2167 $subelement =
'fournisseur.commande';
2170 require_once DOL_DOCUMENT_ROOT.
'/'.$element.
'/class/'.$subelement.
'.class.php';
2171 $classname = ucfirst($subelement);
2172 if ($classname ==
'Fournisseur.commande') {
2173 $classname =
'CommandeFournisseur';
2175 $objectsrc =
new $classname($db);
2176 '@phan-var-force Project|Commande|Propal|Facture|Contrat|CommandeFournisseur|CommonObject $objectsrc';
2177 $objectsrc->fetch($originid);
2178 $objectsrc->fetch_thirdparty();
2180 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
2182 $soc = $objectsrc->thirdparty;
2184 $cond_reglement_id = 0;
2185 $mode_reglement_id = 0;
2189 $transport_mode_id = 0;
2192 if (!empty($objectsrc->cond_reglement_id)) {
2193 $cond_reglement_id = $objectsrc->cond_reglement_id;
2195 if (!empty($objectsrc->mode_reglement_id)) {
2196 $mode_reglement_id = $objectsrc->mode_reglement_id;
2198 if (!empty($objectsrc->fk_account)) {
2199 $fk_account = $objectsrc->fk_account;
2201 if (!empty($objectsrc->transport_mode_id)) {
2202 $transport_mode_id = $objectsrc->transport_mode_id;
2205 if (empty($cond_reglement_id)
2206 || empty($mode_reglement_id)
2207 || empty($fk_account)
2208 || empty($transport_mode_id)
2210 if ($origin ==
'reception') {
2212 if (!isset($objectsrc->supplier_order)) {
2213 $objectsrc->fetch_origin();
2216 if (!empty($objectsrc->origin_object)) {
2217 $originObject = $objectsrc->origin_object;
2218 if (empty($cond_reglement_id) && !empty($originObject->cond_reglement_id)) {
2219 $cond_reglement_id = $originObject->cond_reglement_id;
2221 if (empty($mode_reglement_id) && !empty($originObject->mode_reglement_id)) {
2222 $mode_reglement_id = $originObject->mode_reglement_id;
2224 if (empty($fk_account) && !empty($originObject->fk_account)) {
2225 $fk_account = $originObject->fk_account;
2227 if (empty($transport_mode_id) && !empty($originObject->transport_mode_id)) {
2228 $transport_mode_id = $originObject->transport_mode_id;
2235 if (empty($cond_reglement_id) && !empty($soc->cond_reglement_supplier_id)) {
2236 $cond_reglement_id = $soc->cond_reglement_supplier_id;
2238 if (empty($mode_reglement_id) && !empty($soc->mode_reglement_supplier_id)) {
2239 $mode_reglement_id = $soc->mode_reglement_supplier_id;
2241 if (empty($fk_account) && !empty($soc->fk_account)) {
2242 $fk_account = $soc->fk_account;
2244 if (empty($transport_mode_id) && !empty($soc->transport_mode_id)) {
2245 $transport_mode_id = $soc->transport_mode_id;
2250 if (isModEnabled(
"multicurrency")) {
2251 if (!empty($objectsrc->multicurrency_code)) {
2252 $currency_code = $objectsrc->multicurrency_code;
2254 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
2255 $currency_tx = $objectsrc->multicurrency_tx;
2260 $dateinvoice = ($datetmp ==
'' ? (!
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ? -1 :
'') : $datetmp);
2262 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2265 $objectsrc->fetch_optionals();
2266 $object->array_options = $objectsrc->array_options;
2268 $cond_reglement_id = !empty($societe->cond_reglement_supplier_id) ? $societe->cond_reglement_supplier_id : 0;
2269 $mode_reglement_id = !empty($societe->mode_reglement_supplier_id) ? $societe->mode_reglement_supplier_id : 0;
2270 $vat_reverse_charge = (empty($societe) ?
'' : $societe->vat_reverse_charge);
2271 $transport_mode_id = !empty($societe->transport_mode_supplier_id) ? $societe->transport_mode_supplier_id : 0;
2272 $fk_account = !empty($societe->fk_account) ? $societe->fk_account : 0;
2274 $dateinvoice = ($datetmp ==
'' ? (
getDolGlobalInt(
'MAIN_AUTOFILL_DATE') ?
'' : -1) : $datetmp);
2276 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2278 if (isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2279 $currency_code = $societe->multicurrency_code;
2284 if (empty($cond_reglement_id)) {
2285 $cond_reglement_id =
GETPOST(
"cond_reglement_id");
2289 if (empty($mode_reglement_id)) {
2290 $mode_reglement_id =
GETPOST(
"mode_reglement_id");
2294 if (!
GETPOST(
'changecompany')) {
2295 if (GETPOSTISSET(
'cond_reglement_id')) {
2296 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2298 if (GETPOSTISSET(
'mode_reglement_id')) {
2299 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2301 if (GETPOSTISSET(
'cond_reglement_id')) {
2306 $note_public =
$object->getDefaultCreateValueFor(
'note_public', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_public : null));
2307 $note_private =
$object->getDefaultCreateValueFor(
'note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_private : null));
2309 if ($origin ==
'contrat') {
2310 $langs->load(
"admin");
2311 $text = $langs->trans(
"ToCreateARecurringInvoice");
2312 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv(
"MenuFinancial"), $langs->transnoentitiesnoconv(
"SupplierBills"), $langs->transnoentitiesnoconv(
"ListOfTemplates"));
2314 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv(
'Module2300Name'));
2316 print
info_admin($text, 0, 0,
'0',
'opacitymedium').
'<br>';
2319 print
'<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
2320 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2321 print
'<input type="hidden" name="action" value="add">';
2322 print
'<input type="hidden" name="changecompany" value="0">';
2324 if (!empty($societe->id) && $societe->id > 0) {
2325 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">'.
"\n";
2327 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
2328 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
2329 if (!empty($currency_tx)) {
2330 print
'<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
2332 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2337 $parameters = array();
2339 $reshook = $hookmanager->executeHooks(
'tabContentCreateSupplierInvoice', $parameters,
$object, $action);
2340 if (empty($reshook)) {
2341 print
'<table class="border centpercent">';
2344 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
'Draft').
'</td></tr>';
2348 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2349 $invoice_predefined->fetch($fac_recid);
2353 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
2356 if (!empty($societe->id) && $societe->id > 0 && ($fac_recid <= 0 || !empty($invoice_predefined->frequency))) {
2357 $absolute_discount = $societe->getAvailableDiscounts(
null,
'', 0, 1);
2358 print $societe->getNomUrl(1,
'supplier');
2359 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
2361 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
2362 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');
2365 print
'<script type="text/javascript">
2366 $(document).ready(function() {
2367 $("#socid").change(function() {
2368 console.log("We have changed the company - Reload page");
2370 $("input[name=action]").val("create");
2371 $("input[name=changecompany]").val("1");
2372 $("form[name=add]").submit();
2377 if ($fac_recid <= 0) {
2378 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>';
2384 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2385 $invoice_predefined->fetch($fac_recid);
2387 $dateinvoice = $invoice_predefined->date_when;
2388 if (empty($projectid)) {
2389 $projectid = $invoice_predefined->fk_project;
2391 $cond_reglement_id = $invoice_predefined->cond_reglement_id;
2392 $mode_reglement_id = $invoice_predefined->mode_reglement_id;
2393 $fk_account = $invoice_predefined->fk_account;
2394 $note_public = $invoice_predefined->note_public;
2395 $note_private = $invoice_predefined->note_private;
2397 if (!empty($invoice_predefined->multicurrency_code)) {
2398 $currency_code = $invoice_predefined->multicurrency_code;
2400 if (!empty($invoice_predefined->multicurrency_tx)) {
2401 $currency_tx = $invoice_predefined->multicurrency_tx;
2404 $sql =
'SELECT r.rowid, r.titre as title, r.total_ttc';
2405 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn_rec as r';
2406 $sql .=
' WHERE r.fk_soc = '. (int) $invoice_predefined->socid;
2408 $resql = $db->query($sql);
2410 $num = $db->num_rows($resql);
2414 print
'<tr><td>'.$langs->trans(
'CreateFromRepeatableInvoice').
'</td><td>';
2416 print
'<select class="flat" id="fac_rec" name="fac_rec">';
2417 print
'<option value="0" selected></option>';
2419 $objp = $db->fetch_object($resql);
2420 print
'<option value="'.$objp->rowid.
'"';
2421 if ($fac_recid == $objp->rowid) {
2423 $exampletemplateinvoice->fetch($fac_recid);
2425 print
'>'.$objp->title.
' ('.
price($objp->total_ttc).
' '.$langs->trans(
"TTC").
')</option>';
2431 print
'<script type="text/javascript">
2432 $(document).ready(function() {
2433 $("#fac_rec").change(function() {
2434 console.log("We have changed the template invoice - Reload page");
2436 $("input[name=action]").val("create");
2437 $("form[name=add]").submit();
2451 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"';
2452 if (!empty($societe->id) && $societe->id > 0) {
2458 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'Type').
'</td><td>';
2460 print
'<div class="tagtable">'.
"\n";
2463 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2464 $tmp =
'<input type="radio" id="radio_standard" name="type" value="0"'.(GETPOSTINT(
'type') ?
'' :
'checked').
'> ';
2465 $desc = $form->textwithpicto($tmp.
'<label for="radio_standard">'.$langs->trans(
"InvoiceStandardAsk").
'</label>', $langs->transnoentities(
"InvoiceStandardDesc"), 1,
'help',
'', 0, 3);
2467 print
'</div></div>';
2469 if (empty($origin) || ($origin ==
'order_supplier' && !empty($originid))) {
2472 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2473 $tmp =
'<input type="radio" id="radio_deposit" name="type" value="3"' . (
GETPOSTINT(
'type') == 3 ?
' checked' :
'') .
'> ';
2474 print
'<script type="text/javascript">
2475 jQuery(document).ready(function() {
2476 jQuery("#typestandardinvoice, #valuestandardinvoice").click(function() {
2477 jQuery("#radio_standard").prop("checked", true);
2479 jQuery("#typedeposit, #valuedeposit").click(function() {
2480 jQuery("#radio_deposit").prop("checked", true);
2482 jQuery("#typedeposit").change(function() {
2483 console.log("We change type of down payment");
2484 jQuery("#radio_deposit").prop("checked", true);
2485 setRadioForTypeOfInvoice();
2487 jQuery("#radio_standard, #radio_deposit, #radio_replacement, #radio_template").change(function() {
2488 setRadioForTypeOfInvoice();
2490 function setRadioForTypeOfInvoice() {
2491 console.log("Change radio");
2492 if (jQuery("#radio_deposit").prop("checked") && (jQuery("#typedeposit").val() == \'amount\' || jQuery("#typedeposit").val() == \'variable\')) {
2493 jQuery(".checkforselect").prop("disabled", true);
2494 jQuery(".checkforselect").prop("checked", false);
2496 jQuery(".checkforselect").prop("disabled", false);
2497 jQuery(".checkforselect").prop("checked", true);
2503 $tmp = $tmp.
'<label for="radio_deposit" >'.$langs->trans(
"InvoiceDeposit").
'</label>';
2505 $desc = $form->textwithpicto($tmp, $langs->transnoentities(
"InvoiceDepositDesc"), 1,
'help',
'', 0, 3);
2506 print
'<table class="nobordernopadding"><tr>';
2510 if ($origin ==
'order_supplier') {
2511 print
'<td class="nowrap" style="padding-left: 15px">';
2513 'amount' => $langs->transnoentitiesnoconv(
'FixAmount', $langs->transnoentitiesnoconv(
'Deposit')),
2514 'variable' => $langs->transnoentitiesnoconv(
'VarAmountOneLine', $langs->transnoentitiesnoconv(
'Deposit')),
2515 'variablealllines' => $langs->transnoentitiesnoconv(
'VarAmountAllLines')
2517 print $form->selectarray(
'typedeposit', $arraylist,
GETPOST(
'typedeposit',
'aZ09'), 0, 0, 0,
'', 1);
2519 print
'<td class="nowrap" style="padding-left: 5px">';
2520 print
'<span class="opacitymedium paddingleft">'.$langs->trans(
"AmountOrPercent").
'</span><input type="text" id="valuedeposit" name="valuedeposit" class="width75 right" value="' .
GETPOSTINT(
'valuedeposit') .
'"/>';
2523 print
'</tr></table>';
2525 print
'</div></div>';
2594 if (empty($origin)) {
2595 if (!empty($societe->id) && $societe->id > 0) {
2599 $facids = $facturestatic->list_qualified_avoir_supplier_invoices($societe->id);
2606 foreach ($facids as $key => $valarray) {
2607 $newinvoice_static->id = $key;
2608 $newinvoice_static->ref = $valarray [
'ref'];
2609 $newinvoice_static->status = $valarray [
'status'];
2610 $newinvoice_static->statut = $valarray [
'status'];
2611 $newinvoice_static->type = $valarray [
'type'];
2612 $newinvoice_static->paid = $valarray [
'paye'];
2613 $newinvoice_static->paye = $valarray [
'paye'];
2615 $optionsav .=
'<option value="'.$key.
'"';
2617 $optionsav .=
' selected';
2620 $optionsav .= $newinvoice_static->ref;
2621 $optionsav .=
' ('.$newinvoice_static->getLibStatut(1, $valarray [
'paymentornot']).
')';
2622 $optionsav .=
'</option>';
2625 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2626 $tmp =
'<input type="radio" id="radio_creditnote" name="type" value="2"'.(GETPOST(
'type') == 2 ?
' checked' :
'');
2628 $tmp .=
' disabled';
2632 print
'<script type="text/javascript">
2633 jQuery(document).ready(function() {
2634 if (! jQuery("#radio_creditnote").is(":checked"))
2636 jQuery("#credit_note_options").hide();
2638 jQuery("#radio_creditnote").click(function() {
2639 jQuery("#credit_note_options").show();
2641 jQuery("#radio_standard, #radio_replacement, #radio_deposit").click(function() {
2642 jQuery("#credit_note_options").hide();
2646 $text = $tmp.
'<label for="radio_creditnote">'.$langs->transnoentities(
"InvoiceAvoirAsk").
'</label> ';
2648 $text .=
'<select class="flat valignmiddle" name="fac_avoir" id="fac_avoir"';
2650 $text .=
' disabled';
2654 $text .=
'<option value="-1"></option>';
2655 $text .= $optionsav;
2657 $text .=
'<option value="-1">'.$langs->trans(
"NoInvoiceToCorrect").
'</option>';
2659 $text .=
'</select>';
2660 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2663 print
'<div id="credit_note_options" class="clearboth">';
2664 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' :
'').
' /> ';
2665 print
'<label for="invoiceAvoirWithLines">'.$langs->trans(
'invoiceAvoirWithLines').
"</label>";
2666 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' :
'').
' /> ';
2667 print
'<label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans(
'invoiceAvoirWithPaymentRestAmount').
"</label>";
2670 print
'</div></div>';
2673 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2675 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="0" disabled> ';
2677 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="2"> ';
2679 $text = $tmp.$langs->trans(
"InvoiceAvoir").
' ';
2680 $text .=
'<span class="opacitymedium">('.$langs->trans(
"YouMustCreateInvoiceFromSupplierThird").
')</span> ';
2681 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2683 print
'</div></div>'.
"\n";
2694 print
'<tr><td class="fieldrequired">'.$langs->trans(
'InvoiceSubtype').
'</td><td colspan="2">';
2695 print $form->getSelectInvoiceSubtype(
GETPOST(
'subtype'),
'subtype', 1, 0,
'');
2699 if (!empty($societe->id) && $societe->id > 0) {
2701 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
2703 $thirdparty = $societe;
2705 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$societe->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
2706 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2712 print
'<tr><td>'.$langs->trans(
'Label').
'</td><td><input class="minwidth200" name="label" value="'.
dol_escape_htmltag(
GETPOST(
'label')).
'" type="text"></td></tr>';
2715 print
'<tr><td class="fieldrequired">'.$langs->trans(
'DateInvoice').
'</td><td>';
2716 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2717 print $form->selectDate($dateinvoice,
'', 0, 0, 0,
"add", 1, 1);
2721 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
2722 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
2723 print $form->getSelectConditionsPaiements($cond_reglement_id,
'cond_reglement_id', -1, 1);
2728 print
'<tr><td>'.$langs->trans(
'DateMaxPayment').
'</td><td>';
2729 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2730 print $form->selectDate($datedue,
'ech', 0, 0, 0,
"add", 1, 1);
2734 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
2735 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
2736 $form->select_types_paiements($mode_reglement_id,
'mode_reglement_id',
'DBIT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx');
2740 if (isModEnabled(
"bank")) {
2741 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
2743 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes($fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
2748 if (isModEnabled(
'project')) {
2751 $langs->load(
'projects');
2752 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td>';
2753 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');
2754 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>';
2759 if (isModEnabled(
'incoterm')) {
2761 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), !empty($objectsrc->label_incoterms) ? $objectsrc->label_incoterms :
'', 1).
'</label></td>';
2762 print
'<td colspan="3" class="maxwidthonsmartphone">';
2763 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2764 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 :
''));
2770 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
2771 print
'<tr><td>' . $langs->trans(
'VATReverseCharge') .
'</td><td>';
2773 if (GETPOSTISSET(
'vat_reverse_charge')) {
2774 $vat_reverse_charge = (
GETPOST(
'vat_reverse_charge',
'alpha') ==
'on' ||
GETPOST(
'vat_reverse_charge',
'alpha') ==
'1') ? 1 : 0;
2775 } elseif ($vat_reverse_charge == 1 || $societe->vat_reverse_charge == 1 || ($societe->country_code !=
'FR' &&
isInEEC($societe) && !empty($societe->tva_intra))) {
2776 $vat_reverse_charge = 1;
2778 $vat_reverse_charge = 0;
2781 print
'<input type="checkbox" name="vat_reverse_charge"'. (!empty($vat_reverse_charge) ?
' checked ' :
'') .
'>';
2786 if (isModEnabled(
"multicurrency")) {
2788 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'',
$object, 0).
'</td>';
2789 print
'<td class="maxwidthonsmartphone">';
2790 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
2791 $used_currency_code = $currency_code;
2792 if (!
GETPOST(
'changecompany')) {
2793 $used_currency_code = GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code',
'alpha') : $currency_code;
2795 print $form->selectMultiCurrency($used_currency_code,
'multicurrency_code');
2801 if ($fac_recid > 0) {
2802 $dateexample = $dateinvoice;
2803 if (empty($dateexample)) {
2806 $substitutionarray = array(
2807 '__TOTAL_HT__' => $langs->trans(
"AmountHT").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ht).
')',
2808 '__TOTAL_TTC__' => $langs->trans(
"AmountTTC").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ttc).
')',
2809 '__INVOICE_PREVIOUS_MONTH__' => $langs->trans(
"PreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%m').
')',
2810 '__INVOICE_MONTH__' => $langs->trans(
"MonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%m').
')',
2811 '__INVOICE_NEXT_MONTH__' => $langs->trans(
"NextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%m').
')',
2812 '__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans(
"TextPreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%B').
')',
2813 '__INVOICE_MONTH_TEXT__' => $langs->trans(
"TextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%B').
')',
2814 '__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans(
"TextNextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%B').
')',
2815 '__INVOICE_PREVIOUS_YEAR__' => $langs->trans(
"PreviousYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'y'),
'%Y').
')',
2816 '__INVOICE_YEAR__' => $langs->trans(
"YearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%Y').
')',
2817 '__INVOICE_NEXT_YEAR__' => $langs->trans(
"NextYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'y'),
'%Y').
')'
2820 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
2821 foreach ($substitutionarray as $key => $val) {
2822 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
2824 $htmltext .=
'</i>';
2828 if (isModEnabled(
'intracommreport')) {
2829 $langs->loadLangs(array(
"intracommreport"));
2830 print
'<!-- If module intracomm on -->'.
"\n";
2831 print
'<tr><td>'.$langs->trans(
'IntracommReportTransportMode').
'</td><td>';
2832 $form->selectTransportMode(GETPOSTISSET(
'transport_mode_id') ?
GETPOST(
'transport_mode_id') : $transport_mode_id,
'transport_mode_id');
2836 if (empty($reshook)) {
2837 print
$object->showOptionals($extrafields,
'create');
2841 print
'<tr><td>'.$langs->trans(
'NotePublic').
'</td>';
2843 $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%');
2844 print $doleditor->Create(1);
2850 print
'<tr><td>'.$langs->trans(
'NotePrivate').
'</td>';
2852 $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%');
2853 print $doleditor->Create(1);
2859 if (!empty($objectsrc) && is_object($objectsrc)) {
2860 print
"\n<!-- ".$classname.
" info -->";
2862 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2863 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2864 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2865 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2866 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2868 $txt = $langs->trans($classname);
2869 if ($classname ==
'CommandeFournisseur') {
2870 $langs->load(
'orders');
2871 $txt = $langs->trans(
"SupplierOrder");
2873 print
'<tr><td>'.$txt.
'</td><td>'.$objectsrc->getNomUrl(1);
2875 $objectsrc->fetchObjectLinked($originid, $origin,
null,
'invoice_supplier');
2877 $invoice_supplier = $objectsrc->linkedObjects[
'invoice_supplier'];
2878 '@phan-var-force null|FactureFournisseur[] $invoice_supplier';
2881 if (is_array($invoice_supplier)) {
2882 $cntinvoice = count($invoice_supplier);
2884 if ($cntinvoice >= 1) {
2886 echo
' ('.$langs->trans(
'LatestRelatedBill').end($invoice_supplier)->getNomUrl(1).
')';
2891 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
2892 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
2893 if ($mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
2894 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
2897 if ($mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
2898 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
2900 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
2902 if (isModEnabled(
"multicurrency")) {
2903 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
2904 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
2905 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2910 $parameters = array();
2911 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2912 print $hookmanager->resPrint;
2920 print $form->buttonsSaveCancel(
"CreateDraft");
2923 if (!empty($objectsrc) && is_object($objectsrc)) {
2926 $title = $langs->trans(
'ProductsAndServices');
2929 print
'<div class="div-table-responsive-no-min">';
2930 print
'<table class="noborder centpercent">';
2932 $objectsrc->printOriginLinesList(
'', $selectedLines);
2940 if ($id > 0 || !empty($ref)) {
2946 $productstatic =
new Product($db);
2948 $result =
$object->fetch($id, $ref);
2950 $langs->load(
"errors");
2951 print $langs->trans(
"ErrorRecordNotFound");
2957 $result =
$object->fetch_thirdparty();
2963 $societe =
$object->thirdparty;
2965 $totalpaid =
$object->getSommePaiement();
2966 $totalcreditnotes =
$object->getSumCreditNotesUsed();
2967 $totaldeposits =
$object->getSumDepositsUsed();
2975 $resteapayer =
price2num(
$object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
2978 $multicurrency_resteapayer = 0;
2979 if (isModEnabled(
"multicurrency")) {
2980 $multicurrency_totalpaid =
$object->getSommePaiement(1);
2981 $multicurrency_totalcreditnotes =
$object->getSumCreditNotesUsed(1);
2982 $multicurrency_totaldeposits =
$object->getSumDepositsUsed(1);
2983 $multicurrency_resteapayer =
price2num(
$object->multicurrency_total_ttc - $multicurrency_totalpaid - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits,
'MT');
2987 if ($resteapayer == 0 && $multicurrency_resteapayer != 0 &&
$object->multicurrency_code !=
$conf->currency) {
2988 $resteapayer =
price2num((
float) $multicurrency_resteapayer /
$object->multicurrency_tx,
'MT');
2995 $resteapayeraffiche = $resteapayer;
2998 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
2999 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
3001 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
3002 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
3005 $absolute_discount = $societe->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
3006 $absolute_creditnote = $societe->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
3007 $absolute_discount =
price2num($absolute_discount,
'MT');
3008 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
3012 $objectidnext =
$object->getIdReplacingInvoice();
3015 $titre = $langs->trans(
'SupplierInvoice');
3017 print
dol_get_fiche_head($head,
'card', $titre, -1,
'supplier_invoice', 0,
'',
'', 0,
'', 1);
3022 if ($action ==
'converttoreduc') {
3025 $type_fac =
'ExcessPaid';
3027 $type_fac =
'CreditNote';
3029 $type_fac =
'Deposit';
3031 $text = $langs->trans(
'ConfirmConvertToReducSupplier', strtolower($langs->transnoentities($type_fac)));
3032 $text .=
'<br>'.$langs->trans(
'ConfirmConvertToReducSupplier2');
3033 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id, $langs->trans(
'ConvertToReduc'), $text,
'confirm_converttoreduc',
'',
"yes", 2);
3037 if ($action ==
'clone') {
3039 $formquestion = array(
3040 array(
'type' =>
'text',
'name' =>
'newsupplierref',
'label' => $langs->trans(
"RefSupplierBill"),
'value' => $langs->trans(
"CopyOf").
' '.
$object->ref_supplier),
3041 array(
'type' =>
'date',
'name' =>
'newdate',
'label' => $langs->trans(
"Date"),
'value' =>
dol_now())
3044 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneInvoice',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1, 250);
3048 if ($action ==
'valid') {
3050 if (preg_match(
'/^[\(]?PROV/i',
$object->ref) || empty(
$object->ref)) {
3052 $numref =
$object->getNextNumRef($societe);
3061 $text = $langs->trans(
'ConfirmValidateBill', $numref);
3069 $formquestion = array();
3071 $qualified_for_stock_change = 0;
3073 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3075 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3078 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
3079 $langs->load(
"stocks");
3080 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3083 $warehouse_array = $warehouse->list_array();
3084 if (count($warehouse_array) == 1) {
3086 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3089 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3091 $formquestion = array(
3092 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3096 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateBill'), $text,
'confirm_valid', $formquestion, 1, 1);
3101 if ($action ==
'edit') {
3102 $formquestion = array();
3104 $qualified_for_stock_change = 0;
3106 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3108 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3110 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
3111 $langs->load(
"stocks");
3112 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3115 $warehouse_array = $warehouse->list_array();
3116 if (count($warehouse_array) == 1) {
3118 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3121 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3123 $formquestion = array(
3124 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3127 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'UnvalidateBill'), $langs->trans(
'ConfirmUnvalidateBill',
$object->ref),
'confirm_edit', $formquestion, 1, 1);
3131 if ($action ==
'paid' && ($resteapayer <= 0 || (
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') && $resteapayer ==
$object->total_ttc))) {
3132 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidBill',
$object->ref),
'confirm_paid',
'', 0, 1);
3135 if ($action ==
'paid' && $resteapayer > 0 && (!
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') || $resteapayer !=
$object->total_ttc)) {
3139 $close[$i][
'code'] =
'discount_vat';
3141 $close[$i][
'code'] =
'badsupplier';
3143 $close[$i][
'code'] =
'other';
3147 $close[$i][
'label'] = $langs->trans(
"HelpEscompte").
'<br><br>'.$langs->trans(
"ConfirmClassifyPaidPartiallyReasonDiscountVatDesc");
3149 $close[$i][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3151 $close[$i][
'label'] = $langs->trans(
"Other");
3155 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonDiscount", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3157 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadCustomer", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3159 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"Other"), $close[$i][
'label'], 1);
3162 $arrayreasons = array();
3163 foreach ($close as $key => $val) {
3164 $arrayreasons[$close[$key][
'code']] = $close[$key][
'reason'];
3168 $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'));
3170 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?facid='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidPartially',
$object->ref),
'confirm_paid_partially', $formquestion,
"yes", 1, 310);
3174 if ($action ==
'canceled') {
3176 $close[1][
'code'] =
'badsupplier';
3177 $close[2][
'code'] =
'abandon';
3179 $close[1][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3180 $close[2][
'label'] = $langs->trans(
"ConfirmClassifyAbandonReasonOtherDesc");
3182 $close[1][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadSupplier",
$object->ref), $close[1][
'label'], 1);
3183 $close[2][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyAbandonReasonOther"), $close[2][
'label'], 1);
3185 $arrayreasons[$close[1][
'code']] = $close[1][
'reason'];
3186 $arrayreasons[$close[2][
'code']] = $close[2][
'reason'];
3189 $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'));
3191 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'CancelBill'), $langs->trans(
'ConfirmCancelBill',
$object->ref),
'confirm_canceled', $formquestion,
"yes", 1, 280);
3195 if ($action ==
'delete') {
3196 $formquestion = array();
3198 $qualified_for_stock_change = 0;
3200 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3202 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3205 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
3206 $langs->load(
"stocks");
3207 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3210 $warehouse_array = $warehouse->list_array();
3212 $selectwarehouse =
'<span class="questionrevertstock hidden">';
3213 if (count($warehouse_array) == 1) {
3215 $selectwarehouse .=
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3218 $selectwarehouse .= $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3220 $selectwarehouse .=
'</span>';
3222 $selectyesno = array(0 => $langs->trans(
'No'), 1 => $langs->trans(
'Yes'));
3224 print
'<script type="text/javascript">
3225 $(document).ready(function() {
3226 $("#revertstock").change(function() {
3227 if(this.value > 0) {
3228 $(".questionrevertstock").removeClass("hidden");
3230 $(".questionrevertstock").addClass("hidden");
3236 $formquestion = array(
3237 array(
'type' =>
'select',
'name' =>
'revertstock',
'label' => $langs->trans(
"RevertProductsToStock"),
'select_show_empty' => 0,
'values' => $selectyesno),
3238 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $selectwarehouse,
'tdclass' =>
'questionrevertstock hidden')
3242 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteBill'), $langs->trans(
'ConfirmDeleteBill'),
'confirm_delete', $formquestion, 1, 1);
3244 if ($action ==
'deletepayment') {
3245 $payment_id =
GETPOST(
'paiement_id');
3246 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&paiement_id='.$payment_id, $langs->trans(
'DeletePayment'), $langs->trans(
'ConfirmDeletePayment'),
'confirm_delete_paiement',
'', 0, 1);
3250 if ($action ==
'ask_deleteline') {
3251 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
3254 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
3255 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
3256 if (empty($reshook)) {
3257 $formconfirm .= $hookmanager->resPrint;
3258 } elseif ($reshook > 0) {
3259 $formconfirm = $hookmanager->resPrint;
3267 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
3269 $morehtmlref =
'<div class="refidno">';
3271 $morehtmlref .= $form->editfieldkey(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, $usercancreate,
'string',
'', 0, 1);
3272 $morehtmlref .= $form->editfieldval(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, $usercancreate,
'string',
'',
null,
null,
'', 1);
3274 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1,
'supplier');
3276 $morehtmlref .=
' <div class="inline-block valignmiddle">(<a class="valignmiddle" href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.((int)
$object->thirdparty->id).
'&search_company='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherBills").
'</a>)</div>';
3279 if (isModEnabled(
'project')) {
3280 $langs->load(
"projects");
3281 $morehtmlref .=
'<br>';
3282 if ($permissiontoadd) {
3283 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
3284 if ($action !=
'classify') {
3285 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.((int)
$object->id).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
3287 $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');
3289 if (!empty(
$object->fk_project)) {
3291 $proj->fetch(
$object->fk_project);
3292 $morehtmlref .= $proj->getNomUrl(1);
3294 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
3299 $morehtmlref .=
'</div>';
3301 $object->totalpaid = $totalpaid;
3303 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
3306 $parameters = array();
3308 $reshook = $hookmanager->executeHooks(
'tabContentViewSupplierInvoice', $parameters,
$object, $action);
3309 if (empty($reshook)) {
3310 print
'<div class="fichecenter">';
3311 print
'<div class="fichehalfleft">';
3312 print
'<div class="underbanner clearboth"></div>';
3314 print
'<table class="border tableforfield centpercent">';
3317 print
'<tr><td class="titlefield">'.$langs->trans(
'Type').
'</td><td>';
3318 print
'<span class="badgeneutral">';
3322 print
' '.$object->getSubtypeLabel(
'facture_fourn');
3326 $facreplaced->fetch(
$object->fk_facture_source);
3327 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
'</span>';
3330 if (
$object->fk_facture_source > 0) {
3332 $facusing->fetch(
$object->fk_facture_source);
3333 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
'</span>';
3335 $langs->load(
"errors");
3336 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"WarningCorrectedInvoiceNotFound").
'</span>';
3340 $facidavoir =
$object->getListIdAvoirFromInvoice();
3341 if (count($facidavoir) > 0) {
3342 $invoicecredits = array();
3343 foreach ($facidavoir as $id) {
3345 $facavoir->fetch($id);
3346 $invoicecredits[] = $facavoir->getNomUrl(1);
3348 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"InvoiceHasAvoir") . (count($invoicecredits) ?
' ' :
'') . implode(
',', $invoicecredits);
3351 if (isset($objectidnext) && $objectidnext > 0) {
3354 $facthatreplace->fetch($objectidnext);
3355 print
' <span class="opacitymediumbycolor paddingleft">'.str_replace(
'{s1}', $facthatreplace->getNomUrl(1), $langs->transnoentities(
"ReplacedByInvoice",
'{s1}')).
'</span>';
3359 $result = $discount->fetch(0, 0,
$object->id);
3361 print
' <span class="opacitymediumbycolor paddingleft">';
3362 $s = $langs->trans(
"CreditNoteConvertedIntoDiscount",
'{s1}',
'{s2}');
3363 $s = str_replace(
'{s1}',
$object->getLibType(1), $s);
3364 $s = str_replace(
'{s2}', $discount->getNomUrl(1,
'discount'), $s);
3366 print
'</span><br>';
3370 if (
$object->fk_fac_rec_source > 0) {
3372 $result = $tmptemplate->fetch(
$object->fk_fac_rec_source);
3374 print
' <span class="opacitymediumbycolor paddingleft">';
3375 $link =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.$tmptemplate->id.
'">'.
dol_escape_htmltag($tmptemplate->title).
'</a>';
3376 $s = $langs->transnoentities(
"GeneratedFromSupplierTemplate", $link);
3386 print
'<!-- Discounts -->'.
"\n";
3387 print
'<tr><td>'.$langs->trans(
'DiscountStillRemaining');
3390 $thirdparty = $societe;
3392 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
3398 print
'<td>'.$form->editfieldkey(
"Label",
'label',
$object->label,
$object, $usercancreate).
'</td>';
3399 print
'<td>'.$form->editfieldval(
"Label",
'label',
$object->label,
$object, $usercancreate).
'</td>';
3407 print $form->editfieldkey(
"DateInvoice",
'datef',
$object->date,
$object, $form_permission,
'datepicker');
3408 print
'</td><td colspan="3">';
3409 print $form->editfieldval(
"Date",
'datef',
$object->date,
$object, $form_permission,
'datepicker');
3413 $langs->load(
'bills');
3414 print
'<tr><td class="nowrap">';
3415 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3416 print $langs->trans(
'PaymentConditions');
3418 if ($action !=
'editconditions' && $form_permission) {
3419 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>';
3421 print
'</tr></table>';
3423 if ($action ==
'editconditions') {
3424 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'cond_reglement_id');
3426 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'none');
3433 print $form->editfieldkey(
"DateMaxPayment",
'date_lim_reglement',
$object->date_echeance,
$object, $form_permission,
'datepicker');
3435 print $form->editfieldval(
"DateMaxPayment",
'date_lim_reglement',
$object->date_echeance,
$object, $form_permission,
'datepicker');
3436 if ($action !=
'editdate_lim_reglement' &&
$object->hasDelay()) {
3442 $langs->load(
'bills');
3443 print
'<tr><td class="nowrap">';
3444 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3445 print $langs->trans(
'PaymentMode');
3447 if ($action !=
'editmode' && $form_permission) {
3448 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>';
3450 print
'</tr></table>';
3452 if ($action ==
'editmode') {
3453 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
3455 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'none');
3460 if (isModEnabled(
"bank")) {
3461 print
'<tr><td class="nowrap">';
3462 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3463 print $langs->trans(
'BankAccount');
3465 if ($action !=
'editbankaccount' && $usercancreate) {
3466 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>';
3468 print
'</tr></table>';
3470 if ($action ==
'editbankaccount') {
3471 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'fk_account', 1);
3473 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
3481 print
'<tr><td class="nowrap">';
3482 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3483 print $langs->trans(
'VATReverseCharge');
3485 if ($action !=
'editvatreversecharge' && $usercancreate) {
3486 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editvatreversecharge&id='.
$object->id.
'">'.
img_edit($langs->trans(
'SetVATReverseCharge'), 1).
'</a></td>';
3488 print
'</tr></table>';
3490 if ($action ==
'editvatreversecharge') {
3491 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
3492 print
'<input type="hidden" name="action" value="setvatreversecharge">';
3493 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3495 print
'<input type="checkbox" name="vat_reverse_charge"' . (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
'>';
3497 print
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
3500 print
'<input type="checkbox" name="vat_reverse_charge"'. (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
' disabled>';
3506 if (isModEnabled(
'incoterm')) {
3508 print
'<table width="100%" class="nobordernopadding"><tr><td>';
3509 print $langs->trans(
'IncotermLabel');
3510 print
'<td><td class="right">';
3511 if ($usercancreate) {
3512 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.
$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit().
'</a>';
3516 print
'</td></tr></table>';
3519 if ($action !=
'editincoterm') {
3520 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3522 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
3528 if (isModEnabled(
'intracommreport')) {
3529 $langs->loadLangs(array(
"intracommreport"));
3530 print
'<!-- If module intracomm on -->'.
"\n";
3532 print
'<table class="nobordernopadding centpercent"><tr><td>';
3533 print $langs->trans(
'IntracommReportTransportMode');
3535 if ($action !=
'edittransportmode' && ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"))) {
3536 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edittransportmode&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit().
'</a></td>';
3538 print
'</tr></table>';
3541 if ($action ==
'edittransportmode') {
3542 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->transport_mode_id,
'transport_mode_id', 1, 1);
3544 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->transport_mode_id,
'none');
3551 if (
$object->status != $object::STATUS_DRAFT) {
3555 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3560 print
'<div class="fichehalfright">';
3561 print
'<div class="underbanner clearboth"></div>';
3563 print
'<table class="border tableforfield centpercent">';
3565 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
3568 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
3569 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3570 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3571 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3576 print
'<td>' . $langs->trans(
'AmountVAT') .
'</td>';
3577 print
'<td class="nowrap amountcard right">';
3578 if (
GETPOST(
'calculationrule')) {
3579 $calculationrule =
GETPOST(
'calculationrule',
'alpha');
3581 $calculationrule = (!
getDolGlobalString(
'MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND') ?
'totalofround' :
'roundoftotal');
3583 if ($calculationrule ==
'totalofround') {
3584 $calculationrulenum = 1;
3586 $calculationrulenum = 2;
3589 if (
$object->getVentilExportCompta() == 0) {
3590 $s =
'<span class="hideonsmartphone opacitymedium">' . $langs->trans(
"ReCalculate") .
' </span>';
3591 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&token='.newToken().
'&calculationrule=totalofround">' . $langs->trans(
"Mode1") .
'</a>';
3593 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&token='.newToken().
'&calculationrule=roundoftotal">' . $langs->trans(
"Mode2") .
'</a>';
3594 print
'<div class="inline-block">';
3595 print $form->textwithtooltip($s, $langs->trans(
"CalculationRuleDesc", $calculationrulenum) .
'<br>' . $langs->trans(
"CalculationRuleDescSupplier"), 2, 1,
img_picto(
'',
'help'),
'', 3,
'', 0,
'recalculate');
3596 print
' ';
3601 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3602 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3606 if ($societe->localtax1_assuj ==
"1") {
3608 print
'<td>' . $langs->transcountry(
"AmountLT1", $societe->country_code) .
'</td>';
3609 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 1, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3612 if ($societe->localtax2_assuj ==
"1") {
3614 print
'<td>' . $langs->transcountry(
"AmountLT2", $societe->country_code) .
'</td>';
3615 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 1, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3620 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
3621 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3622 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3623 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3641 if (isModEnabled(
'project')) {
3644 if (isModEnabled(
"bank")) {
3648 if (isModEnabled(
'incoterm')) {
3651 if (isModEnabled(
"multicurrency")) {
3656 if ($societe->localtax1_assuj ==
"1") {
3659 if ($societe->localtax2_assuj ==
"1") {
3663 $sql =
'SELECT p.datep as dp, p.ref, p.num_paiement as num_payment, p.rowid, p.fk_bank,';
3664 $sql .=
' c.id as payment_type, c.code as payment_code,';
3665 $sql .=
' pf.amount,';
3666 $sql .=
' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal';
3667 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn as p';
3668 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
3669 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
3670 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id';
3671 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid';
3672 $sql .=
' WHERE pf.fk_facturefourn = '.((int)
$object->id);
3673 $sql .=
' ORDER BY p.datep, p.tms';
3675 $result = $db->query($sql);
3677 $num = $db->num_rows($result);
3680 print
'<div class="div-table-responsive-no-min">';
3681 print
'<table class="noborder paymenttable centpercent">';
3682 print
'<tr class="liste_titre">';
3684 print
'<td><span class="hideonsmartphone">'.$langs->trans(
'Date').
'</span></td>';
3685 print
'<td><span class="hideonsmartphone">'.$langs->trans(
'Type').
'</span></td>';
3686 if (isModEnabled(
"bank")) {
3687 print
'<td class="right">'.$langs->trans(
'BankAccount').
'</td>';
3689 print
'<td class="right">'.$langs->trans(
'Amount').
'</td>';
3690 print
'<td width="18"> </td>';
3695 $objp = $db->fetch_object($result);
3697 $paymentstatic->id = $objp->rowid;
3698 $paymentstatic->datepaye = $db->jdate($objp->dp);
3699 $paymentstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
3700 $paymentstatic->num_payment = $objp->num_payment;
3702 $paymentstatic->paiementcode = $objp->payment_code;
3703 $paymentstatic->type_code = $objp->payment_code;
3704 $paymentstatic->type_label = $objp->payment_type;
3706 print
'<tr class="oddeven">';
3707 print
'<td class="nowraponall">';
3708 print $paymentstatic->getNomUrl(1);
3710 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
'</td>';
3711 $s = $form->form_modes_reglement(
'', $objp->payment_type,
'none',
'', 1, 0,
'', 1).
' '.$objp->num_payment;
3712 print
'<td class="tdoverflowmax125" title="'.dol_escape_htmltag($s).
'">';
3715 if (isModEnabled(
"bank")) {
3716 $bankaccountstatic->id = $objp->baid;
3717 $bankaccountstatic->ref = $objp->baref;
3718 $bankaccountstatic->label = $objp->baref;
3719 $bankaccountstatic->number = $objp->banumber;
3721 if (isModEnabled(
'accounting')) {
3722 $bankaccountstatic->account_number = $objp->account_number;
3725 $accountingjournal->fetch($objp->fk_accountancy_journal);
3726 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
3729 print
'<td class="right">';
3730 if ($objp->baid > 0) {
3731 print $bankaccountstatic->getNomUrl(1,
'transactions');
3735 print
'<td class="right">'.price($sign * $objp->amount).
'</td>';
3736 print
'<td class="center">';
3738 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deletepayment&token='.
newToken().
'&paiement_id='.$objp->rowid.
'">';
3744 $totalpaid += $objp->amount;
3748 print
'<tr class="oddeven"><td colspan="'.$nbcols.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td><td></td><td></td></tr>';
3771 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3772 print
'<span class="opacitymedium">';
3774 print $langs->trans(
'AlreadyPaidNoCreditNotesNoDeposits');
3776 print $langs->trans(
'AlreadyPaid');
3779 print
'</td><td class="right"'.(($totalpaid > 0) ?
' class="amountalreadypaid"' :
'').
'>'.
price($totalpaid).
'</td><td> </td></tr>';
3782 $resteapayeraffiche = $resteapayer;
3784 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
3787 $creditnoteamount = 0;
3790 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
3791 $sql .=
" re.description, re.fk_invoice_supplier_source";
3792 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
3793 $sql .=
" WHERE fk_invoice_supplier = ".((int)
$object->id);
3794 $resql = $db->query($sql);
3796 $num = $db->num_rows($resql);
3800 $obj = $db->fetch_object($resql);
3801 $invoice->fetch($obj->fk_invoice_supplier_source);
3802 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3804 print $langs->trans(
"CreditNote").
' ';
3807 print $langs->trans(
"Deposit").
' ';
3809 print $invoice->getNomUrl(0);
3811 print
'<td class="right">'.price($obj->amount_ttc).
'</td>';
3812 print
'<td class="right">';
3813 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=unlinkdiscount&discountid='.$obj->rowid.
'">';
3814 print
img_picto($langs->transnoentitiesnoconv(
"RemoveDiscount"),
'unlink');
3819 $creditnoteamount += $obj->amount_ttc;
3822 $depositamount += $obj->amount_ttc;
3831 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3832 print
'<span class="opacitymedium">';
3833 print $form->textwithpicto($langs->trans(
"Discount"), $langs->trans(
"HelpEscompte"), - 1);
3835 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3836 $resteapayeraffiche = 0;
3837 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3841 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3842 print
'<span class="opacitymedium">';
3843 print $form->textwithpicto($langs->trans(
"Abandoned"), $langs->trans(
"HelpAbandonBadCustomer"), - 1);
3845 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3847 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3851 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3852 print
'<span class="opacitymedium">';
3853 print $form->textwithpicto($langs->trans(
"ProductReturned"), $langs->trans(
"HelpAbandonProductReturned"), - 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 $text = $langs->trans(
"HelpAbandonOther");
3864 $text .=
'<br><br><b>'.$langs->trans(
"Reason").
'</b>:'.
$object->close_note;
3866 print
'<span class="opacitymedium">';
3868 print $form->textwithpicto($langs->trans(
"Abandoned"), $text, - 1);
3870 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3871 $resteapayeraffiche = 0;
3872 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3876 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3877 print
'<span class="opacitymedium">';
3878 print $langs->trans(
"Billed");
3880 print
'</td><td class="right">'.price(
$object->total_ttc).
'</td><td> </td></tr>';
3883 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3884 print
'<span class="opacitymedium">';
3885 print $langs->trans(
'RemainderToPay');
3886 if ($resteapayeraffiche < 0) {
3887 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
3891 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayeraffiche).
'</td><td> </td></tr>';
3894 if (isModEnabled(
'multicurrency') &&
$object->multicurrency_code !=
$conf->currency ||
$object->multicurrency_tx != 1) {
3895 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3896 print
'<span class="opacitymedium">';
3897 print $langs->trans(
'RemainderToPayMulticurrency');
3898 if ($resteapayeraffiche < 0) {
3899 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
3903 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price(
price2num($multicurrency_resteapayer,
'MT'), 0, $langs, 1, -1, -1,
$object->multicurrency_code).
'</td><td> </td></tr>';
3906 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3909 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3910 print $langs->trans(
'AlreadyPaidBack');
3911 print
' :</td><td class="right">'.price($sign * $totalpaid).
'</td><td> </td></tr>';
3914 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"Billed").
' :</td><td class="right">'.
price($sign *
$object->total_ttc).
'</td><td> </td></tr>';
3917 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3918 print
'<span class="opacitymedium">';
3919 print $langs->trans(
'RemainderToPayBack');
3920 if ($resteapayeraffiche > 0) {
3921 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
3925 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($sign * $resteapayeraffiche).
'</td><td> </td></tr>';
3928 if (isModEnabled(
'multicurrency') &&
$object->multicurrency_code !=
$conf->currency ||
$object->multicurrency_tx != 1) {
3929 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3930 print
'<span class="opacitymedium">';
3931 print $langs->trans(
'RemainderToPayBackMulticurrency');
3932 if ($resteapayeraffiche > 0) {
3933 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
3937 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>';
3952 print
'<div class="clearboth"></div><br>';
3955 $blocname =
'contacts';
3956 $title = $langs->trans(
'ContactsAddresses');
3957 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
3962 $blocname =
'notes';
3963 $title = $langs->trans(
'Notes');
3964 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
3971 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
3972 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3973 print
'<input type="hidden" name="action" value="'.(($action !=
'editline') ?
'addline' :
'updateline').
'">';
3974 print
'<input type="hidden" name="mode" value="">';
3975 print
'<input type="hidden" name="page_y" value="">';
3976 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
3977 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
3978 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
3981 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
3984 print
'<div class="div-table-responsive-no-min">';
3985 print
'<table id="tablelines" class="noborder noshadow centpercent">';
3987 global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax;
3990 $inputalsopricewithtax = 1;
3991 $senderissupplier = 2;
3993 if (
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY')) {
3994 $senderissupplier =
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY');
3999 $object->printObjectLines($action, $societe, $mysoc, $lineid, 1);
4006 if ($action !=
'editline') {
4009 $parameters = array();
4010 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters,
$object, $action);
4014 if (empty($reshook)) {
4015 $object->formAddObjectLine(1, $societe, $mysoc);
4028 if ($action !=
'presend') {
4031 print
'<div class="tabsAction">';
4033 $parameters = array();
4034 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
4036 if (empty($reshook)) {
4040 $ventilExportCompta =
$object->getVentilExportCompta();
4042 if ($ventilExportCompta == 0) {
4043 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
'Modify').
'</a>';
4045 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseDispatchedInBookkeeping").
'">'.$langs->trans(
'Modify').
'</span>';
4050 $result = $discount->fetch(0, 0,
$object->id);
4057 if (!$objectidnext &&
$object->close_code !=
'replaced' && $usercancreate) {
4058 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=reopen&token='.
newToken().
'">'.$langs->trans(
'ReOpen').
'</a>';
4060 if ($usercancreate) {
4061 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseReplacedInvoice").
'">'.$langs->trans(
'ReOpen').
'</span>';
4063 print
'<span class="butActionRefused classfortooltip">'.$langs->trans(
'ReOpen').
'</span>';
4073 if ($usercanvalidate) {
4074 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=valid&token='.
newToken().
'"';
4075 print
'>'.$langs->trans(
'Validate').
'</a>';
4077 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'"';
4078 print
'>'.$langs->trans(
'Validate').
'</a>';
4084 if (empty($user->socid)) {
4087 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a>';
4089 print
'<span class="butActionRefused classfortooltip">'.$langs->trans(
'SendMail').
'</span>';
4096 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>';
4103 if ($resteapayer == 0) {
4104 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseRemainderToPayIsZero").
'">'.$langs->trans(
'DoPaymentBack').
'</span>';
4106 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>';
4112 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.
newToken().
'">'.$langs->trans(
'ConvertExcessPaidToReduc').
'</a>';
4116 && (
getDolGlobalString(
'SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED') ||
$object->getSommePaiement() == 0)
4118 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>';
4122 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.
newToken().
'">'.$langs->trans(
'ConvertToReduc').
'</a>';
4133 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=paid&token='.
newToken().
'">'.$langs->trans(
'ClassifyPaid').
'</a>';
4138 if ($totalpaid > 0 || $totalcreditnotes > 0) {
4140 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=paid&token='.
newToken().
'">'.$langs->trans(
'ClassifyPaidPartially').
'</a>';
4143 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=canceled">'.$langs->trans(
'ClassifyCanceled').
'</a>';
4155 if (!$objectidnext) {
4156 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>';
4161 if ($action !=
'edit' && $usercancreate) {
4162 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=clone&socid='.
$object->socid.
'&token='.
newToken().
'">'.$langs->trans(
'ToClone').
'</a>';
4167 if (!$objectidnext && count(
$object->lines) > 0) {
4168 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.
$object->id.
'&action=create">'.$langs->trans(
"ChangeIntoRepeatableInvoice").
'</a>';
4173 $isErasable =
$object->is_erasable();
4174 if ($action !=
'confirm_edit' && ($usercandelete || ($usercancreate && $isErasable == 1))) {
4175 $enableDelete =
false;
4177 $params = (empty(
$conf->use_javascript_ajax) ? array() : array(
'attr' => array(
'class' =>
'reposition')));
4179 if ($isErasable == -4) {
4180 $htmltooltip = $langs->trans(
"DisabledBecausePayments");
4181 } elseif ($isErasable == -3) {
4182 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastSituationInvoice");
4183 } elseif ($isErasable == -2) {
4184 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastInvoice");
4185 } elseif ($isErasable == -1) {
4186 $htmltooltip = $langs->trans(
"DisabledBecauseDispatchedInBookkeeping");
4187 } elseif ($isErasable <= 0) {
4188 $htmltooltip = $langs->trans(
"DisabledBecauseNotErasable");
4190 $enableDelete =
true;
4197 if ($action !=
'confirm_edit') {
4198 print
'<div class="fichecenter"><div class="fichehalfleft">';
4205 $filedir =
$conf->fournisseur->facture->dir_output.
'/'.$subdir;
4206 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.
$object->id;
4207 $genallowed = $usercanread;
4208 $delallowed = $usercancreate;
4211 print $formfile->showdocuments(
'facture_fournisseur', $subdir, $filedir, $urlsource, $genallowed, $delallowed, $modelpdf, 1, 0, 0, 40, 0,
'',
'',
'', $societe->default_lang);
4212 $somethingshown = $formfile->numoffiles;
4215 $tmparray = $form->showLinkToObjectBlock(
$object, array(), array(
'invoice_supplier'), 1);
4216 $linktoelem = $tmparray[
'linktoelem'];
4217 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
4218 print $htmltoenteralink;
4220 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
4222 print
'</div><div class="fichehalfright">';
4225 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
4227 $somethingshown = $formactions->showactions(
$object,
'invoice_supplier', $socid, 1,
'listaction'.($genallowed ?
'largetitle' :
''));
4229 print
'</div></div>';
4235 if (
GETPOST(
'modelselected')) {
4236 $action =
'presend';
4240 $modelmail =
'invoice_supplier_send';
4241 $defaulttopic =
'SendBillRef';
4242 $diroutput =
$conf->fournisseur->facture->dir_output;
4243 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
4244 $trackid =
'sinv'.$object->id;
4246 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_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
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.