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';
68$langs->loadLangs(array(
'bills',
'compta',
'suppliers',
'companies',
'products',
'banks',
'admin'));
69if (isModEnabled(
'incoterm')) {
70 $langs->load(
'incoterm');
75$action =
GETPOST(
'action',
'aZ09');
78$cancel =
GETPOST(
'cancel',
'alpha');
79$backtopage =
GETPOST(
'backtopage',
'alpha');
80$backtopageforcancel =
'';
84$origin =
GETPOST(
'origin',
'alpha');
95$hookmanager->initHooks(array(
'invoicesuppliercard',
'globalcard'));
101$extrafields->fetch_name_optionals_label(
$object->table_element);
104if ($id > 0 || !empty($ref)) {
105 $ret =
$object->fetch($id, $ref);
109 $ret =
$object->fetch_thirdparty();
117if (!empty($user->socid)) {
118 $socid = $user->socid;
122$result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture',
'fk_soc',
'rowid', $isdraft);
125$usercanread = ($user->hasRight(
"fournisseur",
"facture",
"lire") || $user->hasRight(
"supplier_invoice",
"lire"));
126$usercancreate = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
127$usercandelete = ($user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"supprimer"));
128$usercancreatecontract = $user->hasRight(
"contrat",
"creer");
131$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"validate")));
132$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"send"));
135$permissionnote = $usercancreate;
136$permissiondellink = $usercancreate;
137$permissiontoedit = $usercancreate;
138$permissiontoadd = $usercancreate;
139$permissiontodelete = $usercandelete;
148$parameters = array(
'socid' => $socid);
149$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
154if (empty($reshook)) {
155 $backurlforlist = DOL_URL_ROOT.
'/fourn/facture/list.php';
157 if (empty($backtopage) || ($cancel && empty($id))) {
158 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
159 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
160 $backtopage = $backurlforlist;
162 $backtopage = DOL_URL_ROOT.
'/fourn/facture/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
168 if (!empty($backtopageforcancel)) {
169 header(
"Location: ".$backtopageforcancel);
171 } elseif (!empty($backtopage)) {
172 header(
"Location: ".$backtopage);
178 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
180 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
182 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
185 if (
GETPOST(
'linkedOrder') && empty($cancel) && $id > 0 && $permissiontoadd) {
188 $result =
$object->add_object_linked(
'order_supplier',
GETPOST(
'linkedOrder'));
192 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
194 '@phan-var-force FactureFournisseur $objectutil';
196 if (
GETPOST(
'newsupplierref',
'alphanohtml')) {
197 $objectutil->ref_supplier =
GETPOST(
'newsupplierref',
'alphanohtml');
201 $result = $objectutil->createFromClone($user, $id);
203 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
206 $langs->load(
"errors");
210 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' && $usercanvalidate) {
211 $idwarehouse =
GETPOST(
'idwarehouse');
216 $qualified_for_stock_change = 0;
218 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
220 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
224 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
225 $langs->load(
"stocks");
226 if (!$idwarehouse || $idwarehouse == -1) {
228 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
236 $result =
$object->validate($user,
'', $idwarehouse);
246 $outputlangs = $langs;
249 $newlang =
GETPOST(
'lang_id',
'aZ09');
252 $newlang =
$object->thirdparty->default_lang;
254 if (!empty($newlang)) {
256 $outputlangs->setDefaultLang($newlang);
261 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
268 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontodelete) {
272 $isErasable =
$object->is_erasable();
274 if (($usercandelete && $isErasable > 0) || ($usercancreate && $isErasable == 1)) {
275 $revertstock =
GETPOST(
'revertstock');
278 $idwarehouse =
GETPOST(
'idwarehouse');
280 $qualified_for_stock_change = 0;
282 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
284 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
288 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
289 $langs->load(
"stocks");
290 if (!$idwarehouse || $idwarehouse == -1) {
292 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
295 $result =
$object->setDraft($user, $idwarehouse);
304 $result =
$object->delete($user);
306 header(
'Location: list.php?restore_lastsearch_values=1');
313 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
315 $result =
$object->deleteLine($lineid);
335 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
342 } elseif ($action ==
'unlinkdiscount' && $usercancreate) {
345 $result = $discount->fetch(
GETPOSTINT(
"discountid"));
346 $discount->unlink_invoice();
347 } elseif ($action ==
'confirm_paid' && $confirm ==
'yes' && $usercancreate) {
349 $result =
$object->setPaid($user);
353 } elseif ($action ==
'confirm_paid_partially' && $confirm ==
'yes' && $usercancreate) {
356 $close_code =
GETPOST(
"close_code",
'restricthtml');
357 $close_note =
GETPOST(
"close_note",
'restricthtml');
359 $result =
$object->setPaid($user, $close_code, $close_note);
364 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Reason")),
null,
'errors');
366 } elseif ($action ==
'confirm_canceled' && $confirm ==
'yes' && $usercancreate) {
369 $close_code =
GETPOST(
"close_code",
'restricthtml');
370 $close_note =
GETPOST(
"close_note",
'restricthtml');
372 $result =
$object->setCanceled($user, $close_code, $close_note);
377 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Reason")),
null,
'errors');
382 if ($action ==
'setref_supplier' && $usercancreate) {
385 if (
$object->update($user) < 0) {
389 $outputlangs = $langs;
392 $newlang =
GETPOST(
'lang_id',
'aZ09');
395 $newlang =
$object->thirdparty->default_lang;
397 if (!empty($newlang)) {
399 $outputlangs->setDefaultLang($newlang);
403 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
409 if ($action ==
'setconditions' && $usercancreate) {
411 $object->cond_reglement_code = 0;
412 $object->cond_reglement_id = 0;
427 $new_date_echeance =
$object->calculate_date_lim_reglement();
428 if ($new_date_echeance) {
429 $object->date_echeance = $new_date_echeance;
434 $result =
$object->update($user);
446 } elseif ($action ==
'set_incoterms' && isModEnabled(
'incoterm') && $usercancreate) {
449 } elseif ($action ==
'setmode' && $usercancreate) {
452 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
454 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
455 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
458 } elseif ($action ==
'setbankaccount' && $usercancreate) {
461 } elseif ($action ==
'setvatreversecharge' && $usercancreate) {
463 $vatreversecharge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
464 $result =
$object->setVATReverseCharge($vatreversecharge);
467 if ($action ==
'settransportmode' && $usercancreate) {
470 } elseif ($action ==
'setlabel' && $usercancreate) {
474 $result =
$object->update($user);
478 } elseif ($action ==
'setdatef' && $usercancreate) {
482 setEventMessages($langs->trans(
"WarningInvoiceDateInFuture"),
null,
'warnings');
484 setEventMessages($langs->trans(
"WarningInvoiceDateTooFarInFuture"),
null,
'warnings');
491 $date_echence_calc =
$object->calculate_date_lim_reglement();
492 if (!empty(
$object->date_echeance)) {
493 $object->date_echeance = $date_echence_calc;
499 $result =
$object->update($user);
503 } elseif ($action ==
'setdate_lim_reglement' && $usercancreate) {
508 setEventMessages($langs->trans(
"DatePaymentTermCantBeLowerThanObjectDate"),
null,
'warnings');
510 $result =
$object->update($user);
514 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
530 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
532 $discount->fetch(
GETPOSTINT(
"remise_id_for_payment"));
536 $remaintopay =
$object->getRemainToPay(0);
540 setEventMessages($langs->trans(
"ErrorDiscountLargerThanRemainToPaySplitItBefore"),
null,
'errors');
544 $result = $discount->link_to_invoice(0, $id);
551 $newremaintopay =
$object->getRemainToPay(0);
552 if ($newremaintopay == 0) {
563 $outputlangs = $langs;
566 $newlang =
GETPOST(
'lang_id',
'aZ09');
569 $newlang =
$object->thirdparty->default_lang;
571 if (!empty($newlang)) {
573 $outputlangs->setDefaultLang($newlang);
577 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
582 } elseif ($action ==
'confirm_converttoreduc' && $confirm ==
'yes' && $usercancreate) {
590 $result = $discountcheck->fetch(0, 0,
$object->id);
602 $amount_ht = $amount_tva = $amount_ttc = array();
603 $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array();
607 foreach (
$object->lines as $line) {
608 if ($line->product_type < 9 && $line->total_ht != 0) {
609 $keyforvatrate = $line->tva_tx.($line->vat_src_code ?
' ('.$line->vat_src_code.
')' :
'');
611 $amount_ht[$keyforvatrate] += $line->total_ht;
612 $amount_tva[$keyforvatrate] += $line->total_tva;
613 $amount_ttc[$keyforvatrate] += $line->total_ttc;
614 $multicurrency_amount_ht[$keyforvatrate] += $line->multicurrency_total_ht;
615 $multicurrency_amount_tva[$keyforvatrate] += $line->multicurrency_total_tva;
616 $multicurrency_amount_ttc[$keyforvatrate] += $line->multicurrency_total_ttc;
620 '@phan-var-force array<string,float> $amount_ht
621 @phan-var-force array<string,float> $amount_tva
622 @phan-var-force array<string,float> $amount_ttc
623 @phan-var-force array<string,float> $multicurrency_amount_ht
624 @phan-var-force array<string,float> $multicurrency_amount_tva
625 @phan-var-force array<string,float> $multicurrency_amount_ttc';
629 $alreadypaid =
$object->getSommePaiement();
630 if ($alreadypaid && abs($alreadypaid) < abs(
$object->total_ttc)) {
631 $ratio = abs((
$object->total_ttc - $alreadypaid) /
$object->total_ttc);
632 foreach ($amount_ht as $vatrate => $val) {
633 $amount_ht[$vatrate] =
price2num($amount_ht[$vatrate] * $ratio,
'MU');
634 $amount_tva[$vatrate] =
price2num($amount_tva[$vatrate] * $ratio,
'MU');
635 $amount_ttc[$vatrate] =
price2num($amount_ttc[$vatrate] * $ratio,
'MU');
636 $multicurrency_amount_ht[$vatrate] =
price2num($multicurrency_amount_ht[$vatrate] * $ratio,
'MU');
637 $multicurrency_amount_tva[$vatrate] =
price2num($multicurrency_amount_tva[$vatrate] * $ratio,
'MU');
638 $multicurrency_amount_ttc[$vatrate] =
price2num($multicurrency_amount_ttc[$vatrate] * $ratio,
'MU');
647 $discount->description =
'(CREDIT_NOTE)';
649 $discount->description =
'(DEPOSIT)';
651 $discount->description =
'(EXCESS PAID)';
653 setEventMessages($langs->trans(
'CantConvertToReducAnInvoiceOfThisType'),
null,
'errors');
655 $discount->discount_type = 1;
656 $discount->fk_soc =
$object->socid;
657 $discount->socid =
$object->socid;
658 $discount->fk_invoice_supplier_source =
$object->id;
666 $sql =
'SELECT SUM(pf.amount) as total_paiements';
667 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.
'paiementfourn as p';
668 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN ('.
getEntity(
'c_paiement').
')';
669 $sql .=
' WHERE pf.fk_facturefourn = '.((int)
$object->id);
670 $sql .=
' AND pf.fk_paiementfourn = p.rowid';
671 $sql .=
' AND p.entity IN ('.getEntity(
'invoice').
')';
673 $resql = $db->query($sql);
678 $res = $db->fetch_object($resql);
679 $total_paiements = $res->total_paiements;
682 $total_creditnote_and_deposit = 0;
683 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
684 $sql .=
" re.description, re.fk_invoice_supplier_source";
685 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
686 $sql .=
" WHERE fk_invoice_supplier = ".((int)
$object->id);
687 $resql = $db->query($sql);
688 if (!empty($resql)) {
689 while ($obj = $db->fetch_object($resql)) {
690 $total_creditnote_and_deposit += $obj->amount_ttc;
696 $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit -
$object->total_ttc;
697 $discount->amount_tva = 0;
698 $discount->tva_tx = 0;
699 $discount->vat_src_code =
'';
701 $result = $discount->create($user);
707 foreach ($amount_ht as $tva_tx => $xxx) {
708 $discount->amount_ht = abs((
float) $amount_ht[$tva_tx]);
709 $discount->amount_tva = abs((
float) $amount_tva[$tva_tx]);
710 $discount->amount_ttc = abs((
float) $amount_ttc[$tva_tx]);
711 $discount->multicurrency_amount_ht = abs((
float) $multicurrency_amount_ht[$tva_tx]);
712 $discount->multicurrency_amount_tva = abs((
float) $multicurrency_amount_tva[$tva_tx]);
713 $discount->multicurrency_amount_ttc = abs((
float) $multicurrency_amount_ttc[$tva_tx]);
718 if (preg_match(
'/\((.*)\)/', $tva_tx, $reg)) {
719 $vat_src_code = $reg[1];
720 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx);
723 $discount->tva_tx = abs((
float) $tva_tx);
724 $discount->vat_src_code = $vat_src_code;
726 $result = $discount->create($user);
737 $result =
$object->setPaid($user);
752 } elseif ($action ==
'confirm_delete_paiement' && $confirm ==
'yes' && $usercancreate) {
757 $result = $paiementfourn->fetch(
GETPOST(
'paiement_id'));
759 $result = $paiementfourn->delete($user);
761 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
769 } elseif ($action ==
'add' && $usercancreate) {
774 $selectedLines =
GETPOST(
'toselect',
'array');
782 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
796 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
801 if (empty($dateinvoice)) {
802 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
814 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ReplaceInvoice")),
null,
'errors');
828 $object->date_echeance = $datedue;
834 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
835 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
837 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
838 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
846 $id =
$object->createFromCurrent($user);
859 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CorrectInvoice")),
null,
'errors');
862 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Supplier')),
null,
'errors');
867 if (empty($dateinvoice)) {
868 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
878 if (!
GETPOST(
'ref_supplier')) {
879 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'RefSupplierBill')),
null,
'errors');
887 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
902 $object->date_echeance = $datedue;
908 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
909 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
911 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
912 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
917 $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice :
'';
926 if (
GETPOSTINT(
'invoiceAvoirWithLines') == 1 && $id > 0) {
928 if ($facture_source->fetch(
$object->fk_facture_source) > 0) {
931 foreach ($facture_source->lines as $line) {
933 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
937 $line->fk_facture_fourn =
$object->id;
938 $line->fk_parent_line = $fk_parent_line;
940 $line->subprice = -$line->subprice;
941 $line->pa_ht = -$line->pa_ht;
942 $line->total_ht = -$line->total_ht;
943 $line->total_tva = -$line->total_tva;
944 $line->total_ttc = -$line->total_ttc;
945 $line->total_localtax1 = -$line->total_localtax1;
946 $line->total_localtax2 = -$line->total_localtax2;
948 $result = $line->insert();
953 if ($result > 0 && $line->product_type == 9) {
954 $fk_parent_line = $result;
962 if (
GETPOSTINT(
'invoiceAvoirWithPaymentRestAmount') == 1 && $id > 0) {
964 if ($facture_source->fetch(
$object->fk_facture_source) > 0) {
965 $totalpaid = $facture_source->getSommePaiement();
966 $totalcreditnotes = $facture_source->getSumCreditNotesUsed();
967 $totaldeposits = $facture_source->getSumDepositsUsed();
968 $remain_to_pay = abs($facture_source->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits);
969 $desc = $langs->trans(
'invoiceAvoirLineWithPaymentRestAmount');
970 $retAddLine =
$object->addline($desc, $remain_to_pay, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
'TTC');
972 if ($retAddLine < 0) {
980 if (empty($dateinvoice)) {
982 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
992 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
1002 $object->note_public = trim(
GETPOST(
'note_public',
'restricthtml'));
1003 $object->note_private = trim(
GETPOST(
'note_private',
'restricthtml'));
1014 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
1015 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
1019 $object->fac_rec = $fac_recid;
1021 $fac_rec->fetch(
$object->fac_rec);
1022 $fac_rec->fetch_lines();
1023 $object->lines = $fac_rec->lines;
1030 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Supplier')),
null,
'errors');
1035 if (empty($dateinvoice)) {
1036 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
1046 if (!
GETPOST(
'ref_supplier')) {
1047 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'RefSupplierBill')),
null,
'errors');
1055 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
1072 $object->date_echeance = $datedue;
1078 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
1079 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
1081 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
1082 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
1087 if (empty(
$object->date_echeance)) {
1088 $object->date_echeance =
$object->calculate_date_lim_reglement();
1094 if (!$error &&
GETPOST(
'origin',
'alpha') &&
GETPOST(
'originid')) {
1096 $element = $subelement =
GETPOST(
'origin',
'alpha');
1104 if ($element ==
'order') {
1105 $element = $subelement =
'commande';
1107 if ($element ==
'propal') {
1108 $element =
'comm/propal';
1109 $subelement =
'propal';
1111 if ($element ==
'contract') {
1112 $element = $subelement =
'contrat';
1114 if ($element ==
'order_supplier') {
1116 $subelement =
'fournisseur.commande';
1118 if ($element ==
'project') {
1119 $element =
'projet';
1125 require_once DOL_DOCUMENT_ROOT.
'/'.$element.
'/class/'.$subelement.
'.class.php';
1126 $classname = ucfirst($subelement);
1127 if ($classname ==
'Fournisseur.commande') {
1128 $classname =
'CommandeFournisseur';
1130 $objectsrc =
new $classname($db);
1131 $objectsrc->fetch($originid);
1132 $objectsrc->fetch_thirdparty();
1139 if (
$object->origin ==
'reception') {
1140 $objectsrc->fetchObjectLinked();
1142 if (count($objectsrc->linkedObjectsIds[
'order_supplier']) > 0) {
1143 foreach ($objectsrc->linkedObjectsIds[
'order_supplier'] as $key => $value) {
1144 $object->linkedObjectsIds[
'order_supplier'] = $value;
1153 require_once DOL_DOCUMENT_ROOT.
'/'.$element.
'/class/'.$subelement.
'.class.php';
1154 $classname = ucfirst($subelement);
1155 if ($classname ==
'Fournisseur.commande') {
1156 $classname =
'CommandeFournisseur';
1158 $srcobject =
new $classname($db);
1160 $result = $srcobject->fetch(
GETPOSTINT(
'originid'));
1163 $typeamount =
GETPOST(
'typedeposit',
'alpha');
1168 $amountdeposit = array();
1170 if ($typeamount ==
'amount') {
1171 $amount = $valuedeposit;
1173 $amount = $srcobject->total_ttc * ((float) $valuedeposit / 100);
1176 $TTotalByTva = array();
1177 foreach ($srcobject->lines as &$line) {
1178 if (!empty($line->special_code)) {
1181 $TTotalByTva[$line->tva_tx] += $line->total_ttc;
1183 '@phan-var-force array<string,float> $TTotalByTva';
1185 $amount_ttc_diff = 0.;
1186 foreach ($TTotalByTva as $tva => &$total) {
1187 $coef = $total / $srcobject->total_ttc;
1188 $am = $amount * $coef;
1189 $amount_ttc_diff += $am;
1190 $amountdeposit[$tva] += $am / (1 + $tva / 100);
1193 if ($typeamount ==
'amount') {
1194 $amountdeposit[0] = $valuedeposit;
1195 } elseif ($typeamount ==
'variable') {
1198 $lines = $srcobject->lines;
1199 $numlines = count($lines);
1200 for ($i = 0; $i < $numlines; $i++) {
1202 if (empty($lines[$i]->qty)) {
1205 if (!empty($lines[$i]->special_code)) {
1209 $totalamount += $lines[$i]->total_ht;
1210 $tva_tx = $lines[$i]->tva_tx;
1211 $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * (float) $valuedeposit) / 100;
1215 if ($totalamount == 0) {
1216 $amountdeposit[0] = 0;
1221 $amountdeposit[0] = 0;
1225 $amount_ttc_diff = $amountdeposit[0];
1228 foreach ($amountdeposit as $tva => $amount) {
1229 if (empty($amount)) {
1234 'amount' =>
'FixAmount',
1235 'variable' =>
'VarAmount'
1237 $descline =
'(DEPOSIT)';
1239 if ($typeamount ==
'amount') {
1240 $descline .=
' ('.price($valuedeposit, 0, $langs, 0, - 1, - 1, (!empty(
$object->multicurrency_code) ?
$object->multicurrency_code : $conf->currency)).
')';
1241 } elseif ($typeamount ==
'variable') {
1242 $descline .=
' ('.$valuedeposit.
'%)';
1245 $descline .=
' - '.$srcobject->ref;
1275 $diff =
$object->total_ttc - $amount_ttc_diff;
1279 $subprice_diff =
$object->lines[0]->subprice - $diff / (1 +
$object->lines[0]->tva_tx / 100);
1285 $object->lines[0]->localtax1_tx,
1286 $object->lines[0]->localtax2_tx,
1288 $object->lines[0]->fk_product,
1291 $object->lines[0]->product_type,
1292 $object->lines[0]->remise_percent,
1294 $object->lines[0]->date_start,
1303 } elseif ($result > 0) {
1304 $lines = $srcobject->lines;
1305 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
1306 $srcobject->fetch_lines();
1307 $lines = $srcobject->lines;
1310 $num = count($lines);
1311 for ($i = 0; $i < $num; $i++) {
1312 if (!in_array($lines[$i]->
id, $selectedLines)) {
1316 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->product_label);
1317 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
1320 if (method_exists($lines[$i],
'fetch_optionals')) {
1321 $lines[$i]->fetch_optionals();
1326 $date_start = $lines[$i]->date_debut_prevue;
1327 if ($lines[$i]->date_debut_reel) {
1328 $date_start = $lines[$i]->date_debut_reel;
1330 if ($lines[$i]->date_start) {
1331 $date_start = $lines[$i]->date_start;
1333 $date_end = $lines[$i]->date_fin_prevue;
1334 if ($lines[$i]->date_fin_reel) {
1335 $date_end = $lines[$i]->date_fin_reel;
1337 if ($lines[$i]->date_end) {
1338 $date_end = $lines[$i]->date_end;
1341 $tva_tx = $lines[$i]->tva_tx;
1342 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', $tva_tx)) {
1343 $tva_tx .=
' ('.$lines[$i]->vat_src_code.
')';
1347 $object->special_code = $lines[$i]->special_code;
1350 if (
$object->multicurrency_code != $conf->currency ||
$object->multicurrency_tx != 1) {
1352 $pu_currency = $lines[$i]->multicurrency_subprice;
1354 $pu = $lines[$i]->subprice;
1363 $lines[$i]->localtax1_tx,
1364 $lines[$i]->localtax2_tx,
1366 $lines[$i]->fk_product,
1367 $lines[$i]->remise_percent,
1371 $lines[$i]->info_bits,
1376 $lines[$i]->array_options,
1377 $lines[$i]->fk_unit,
1380 $lines[$i]->ref_supplier,
1381 $lines[$i]->special_code
1398 } elseif (!$error) {
1408 $langs->load(
"errors");
1418 $outputlangs = $langs;
1419 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1426 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
1429 } elseif ($action ==
'updateline' && $usercancreate) {
1433 if (!
$object->fetch($id) > 0) {
1439 $tva_tx = str_replace(
'*',
'', $tva_tx);
1441 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_subprice') !=
'') {
1443 $price_base_type =
'HT';
1446 $price_base_type =
'TTC';
1449 if (
GETPOST(
'productid') > 0) {
1453 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1458 $prod->fetch(
GETPOST(
'productid'));
1459 $label = $prod->description;
1460 if (trim(
GETPOST(
'product_desc',
'restricthtml')) != trim($label)) {
1461 $label =
GETPOST(
'product_desc',
'restricthtml');
1464 $type = $prod->type;
1466 $label =
GETPOST(
'product_desc',
'restricthtml');
1475 if (preg_match(
'/\*/', $tva_tx)) {
1480 $tva_tx = str_replace(
'*',
'', $tva_tx);
1488 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1489 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1491 if (is_array($extralabelsline)) {
1492 foreach ($extralabelsline as $key => $value) {
1493 unset($_POST[
"options_".$key]);
1497 $result =
$object->updateline(
1519 unset($_POST[
'label']);
1520 unset($_POST[
'fourn_ref']);
1521 unset($_POST[
'date_starthour']);
1522 unset($_POST[
'date_startmin']);
1523 unset($_POST[
'date_startsec']);
1524 unset($_POST[
'date_startday']);
1525 unset($_POST[
'date_startmonth']);
1526 unset($_POST[
'date_startyear']);
1527 unset($_POST[
'date_endhour']);
1528 unset($_POST[
'date_endmin']);
1529 unset($_POST[
'date_endsec']);
1530 unset($_POST[
'date_endday']);
1531 unset($_POST[
'date_endmonth']);
1532 unset($_POST[
'date_endyear']);
1533 unset($_POST[
'price_ttc']);
1534 unset($_POST[
'price_ht']);
1541 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') && (
GETPOST(
'alldate_start',
'alpha') ||
GETPOST(
'alldate_end',
'alpha')) && $usercancreate) {
1545 foreach (
$object->lines as $line) {
1546 if ($line->product_type == 1) {
1547 $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);
1550 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') !=
'' && $usercancreate) {
1552 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
1553 $vat_rate = str_replace(
'*',
'', $vat_rate);
1556 foreach (
$object->lines as $line) {
1557 $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);
1559 } elseif ($action ==
'addline' && $usercancreate) {
1568 $ret =
$object->fetch_thirdparty();
1570 $langs->load(
'errors');
1575 $product_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
1579 $prod_entry_mode =
GETPOST(
'prod_entry_mode');
1580 if ($prod_entry_mode ==
'free') {
1591 $price_ttc_devise =
price2num(
GETPOST(
'multicurrency_price_ttc'),
'CU', 2);
1594 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef,
'alpha'),
'', 2) : 0);
1595 if (empty($remise_percent)) {
1596 $remise_percent = 0;
1600 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1601 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1603 if (is_array($extralabelsline)) {
1605 foreach ($extralabelsline as $key => $value) {
1606 unset($_POST[
"options_".$key]);
1610 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
1611 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1614 if ($prod_entry_mode ==
'free' && !
GETPOST(
'idprodfournprice') &&
GETPOST(
'type') < 0) {
1615 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
1618 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' && $price_ht_devise ===
'') {
1619 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'UnitPrice')),
null,
'errors');
1622 if ($prod_entry_mode ==
'free' && !
GETPOST(
'dp_desc')) {
1623 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
1626 if (!
GETPOST(
'qty',
'alpha')) {
1627 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1631 if (!$error && isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1632 if ($combinations =
GETPOST(
'combinations',
'array')) {
1636 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1637 $idprod = $res->fk_product_child;
1639 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1645 if ($prod_entry_mode !=
'free' && empty($error)) {
1649 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
1654 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
1656 $res = $productsupplier->fetch($idprod);
1659 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
1661 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1662 if ($productsupplier->fourn_socid != $socid) {
1663 $productsupplier->ref_supplier =
'';
1666 $fksoctosearch =
$object->thirdparty->id;
1667 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1669 } elseif (
GETPOST(
'idprodfournprice',
'alpha') > 0) {
1670 $qtytosearch = $qty;
1672 $idprod = $productsupplier->get_buyprice(
GETPOST(
'idprodfournprice',
'alpha'), $qtytosearch);
1673 $res = $productsupplier->fetch($idprod);
1677 $label = $productsupplier->label;
1680 $outputlangs = $langs;
1682 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
1683 $newlang =
GETPOST(
'lang_id',
'aZ09');
1685 if (empty($newlang)) {
1686 $newlang =
$object->thirdparty->default_lang;
1688 if (!empty($newlang)) {
1689 $outputlangs =
new Translate(
"", $conf);
1690 $outputlangs->setDefaultLang($newlang);
1692 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->
description;
1694 $desc = $productsupplier->description;
1697 if (!empty($productsupplier->desc_supplier) &&
getDolGlobalString(
'PRODUIT_FOURN_TEXTS')) {
1698 $desc = $productsupplier->desc_supplier;
1702 if (trim($product_desc) == trim($desc) &&
getDolGlobalString(
'PRODUIT_AUTOFILL_DESC')) {
1706 $desc = $product_desc;
1708 if (!empty($product_desc) && trim($product_desc) != trim($desc)) {
1712 $ref_supplier = $productsupplier->ref_supplier;
1715 if (!GETPOSTISSET(
'tva_tx')) {
1719 if (empty($tva_tx) || empty($tva_npr)) {
1725 $type = $productsupplier->type;
1726 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1727 $price_base_type =
'HT';
1729 $pu_devise =
price2num($price_ht_devise,
'CU');
1730 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
1731 $price_base_type =
'TTC';
1733 $pu_devise =
price2num($price_ttc_devise,
'CU');
1735 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
1736 if (empty(
$object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code !=
$object->multicurrency_code)) {
1737 $pu = $productsupplier->fourn_pu;
1740 $pu = $productsupplier->fourn_pu;
1741 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
1745 $ref_supplier = $productsupplier->ref_supplier;
1766 min($rank, count(
$object->lines) + 1),
1769 $productsupplier->fk_unit,
1772 GETPOST(
'fourn_ref',
'alpha'),
1776 if ($idprod == -99 || $idprod == 0) {
1779 $langs->load(
"errors");
1780 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
1782 if ($idprod == -1) {
1785 $langs->load(
"errors");
1786 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
1788 } elseif (empty($error)) {
1789 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1790 $tva_tx = str_replace(
'*',
'', $tva_tx);
1791 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1792 $desc = $product_desc;
1794 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1796 $fk_unit =
GETPOST(
'units',
'alpha');
1798 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
1806 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1810 $pu_ht =
price2num((
float) $pu_ttc / (1 + ((
float) $tva_tx / 100)),
'MU');
1812 $price_base_type =
'HT';
1813 $pu_devise =
price2num($price_ht_devise,
'CU');
1815 $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);
1819 if (!$error && $result > 0) {
1824 $outputlangs = $langs;
1827 $newlang =
GETPOST(
'lang_id',
'aZ09');
1830 $newlang =
$object->thirdparty->default_lang;
1832 if (!empty($newlang)) {
1833 $outputlangs =
new Translate(
"", $conf);
1834 $outputlangs->setDefaultLang($newlang);
1839 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1845 unset($_POST [
'prod_entry_mode']);
1847 unset($_POST[
'qty']);
1848 unset($_POST[
'type']);
1849 unset($_POST[
'remise_percent']);
1850 unset($_POST[
'pu']);
1851 unset($_POST[
'price_ht']);
1852 unset($_POST[
'multicurrency_price_ht']);
1853 unset($_POST[
'price_ttc']);
1854 unset($_POST[
'fourn_ref']);
1855 unset($_POST[
'tva_tx']);
1856 unset($_POST[
'label']);
1857 unset($localtax1_tx);
1858 unset($localtax2_tx);
1859 unset($_POST[
'np_marginRate']);
1860 unset($_POST[
'np_markRate']);
1861 unset($_POST[
'dp_desc']);
1862 unset($_POST[
'idprodfournprice']);
1863 unset($_POST[
'units']);
1865 unset($_POST[
'date_starthour']);
1866 unset($_POST[
'date_startmin']);
1867 unset($_POST[
'date_startsec']);
1868 unset($_POST[
'date_startday']);
1869 unset($_POST[
'date_startmonth']);
1870 unset($_POST[
'date_startyear']);
1871 unset($_POST[
'date_endhour']);
1872 unset($_POST[
'date_endmin']);
1873 unset($_POST[
'date_endsec']);
1874 unset($_POST[
'date_endday']);
1875 unset($_POST[
'date_endmonth']);
1876 unset($_POST[
'date_endyear']);
1883 } elseif ($action ==
'classin' && $usercancreate) {
1885 $result =
$object->setProject($projectid);
1886 } elseif ($action ==
'confirm_edit' && $confirm ==
'yes' && $usercancreate) {
1890 $totalpaid =
$object->getSommePaiement();
1891 $resteapayer =
$object->total_ttc - $totalpaid;
1894 $ventilExportCompta =
$object->getVentilExportCompta();
1896 if (!$ventilExportCompta) {
1899 $idwarehouse =
GETPOST(
'idwarehouse');
1903 $qualified_for_stock_change = 0;
1905 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1907 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1911 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
1912 $langs->load(
"stocks");
1913 if (!$idwarehouse || $idwarehouse == -1) {
1915 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1920 $object->setDraft($user, $idwarehouse);
1924 $outputlangs = $langs;
1927 $newlang =
GETPOST(
'lang_id',
'aZ09');
1930 $newlang =
$object->thirdparty->default_lang;
1932 if (!empty($newlang)) {
1933 $outputlangs =
new Translate(
"", $conf);
1934 $outputlangs->setDefaultLang($newlang);
1939 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1948 } elseif ($action ==
'reopen' && $usercancreate) {
1950 $result =
$object->fetch($id);
1953 $result =
$object->setUnpaid($user);
1955 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
1964 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1967 $triggersendname =
'BILL_SUPPLIER_SENTBYMAIL';
1969 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
1970 $trackid =
'sinv'.$object->id;
1971 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1974 $upload_dir = $conf->fournisseur->facture->dir_output;
1975 $permissiontoadd = $usercancreate;
1976 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1979 if ($action ==
'calculate' && $usercancreate) {
1980 $calculationrule =
GETPOST(
'calculationrule');
1984 $result =
$object->update_price(0, (($calculationrule ==
'totalofround') ?
'0' :
'1'), 0,
$object->thirdparty);
1990 if ($action ==
'update_extras' && $usercancreate) {
1994 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
2001 $result =
$object->insertExtraFields(
'BILL_SUPPLIER_MODIFY');
2009 $action =
'edit_extras';
2014 if ($action ==
'addcontact') {
2015 $result =
$object->fetch($id);
2017 if ($result > 0 && $id > 0) {
2020 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
2024 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2027 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2028 $langs->load(
"errors");
2029 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
2034 } elseif ($action ==
'swapstatut') {
2041 } elseif ($action ==
'deletecontact') {
2047 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2061$form =
new Form($db);
2063$bankaccountstatic =
new Account($db);
2065if (isModEnabled(
'project')) {
2071$title =
$object->ref.
" - ".$langs->trans(
'Card');
2072if ($action ==
'create') {
2073 $title = $langs->trans(
"NewSupplierInvoice");
2075$help_url =
'EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores|DE:Modul_Lieferantenrechnungen';
2079if ($action ==
'create') {
2081 $selectedLines = array();
2083 print
load_fiche_titre($langs->trans(
'NewSupplierInvoice'),
'',
'supplier_invoice');
2087 $currency_code = $conf->currency;
2093 if (isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2094 $currency_code = $societe->multicurrency_code;
2098 if (!empty($origin) && !empty($originid)) {
2100 $element = $subelement = $origin;
2102 if ($element ==
'project') {
2103 $projectid = $originid;
2104 $element =
'projet';
2108 if ($element ==
'order') {
2109 $element = $subelement =
'commande';
2111 if ($element ==
'propal') {
2112 $element =
'comm/propal';
2113 $subelement =
'propal';
2115 if ($element ==
'contract') {
2116 $element = $subelement =
'contrat';
2118 if ($element ==
'order_supplier') {
2120 $subelement =
'fournisseur.commande';
2123 require_once DOL_DOCUMENT_ROOT.
'/'.$element.
'/class/'.$subelement.
'.class.php';
2124 $classname = ucfirst($subelement);
2125 if ($classname ==
'Fournisseur.commande') {
2126 $classname =
'CommandeFournisseur';
2128 $objectsrc =
new $classname($db);
2129 '@phan-var-force Project|Commande|Propal|Facture|Contrat|CommandeFournisseur|CommonObject $objectsrc';
2130 $objectsrc->fetch($originid);
2131 $objectsrc->fetch_thirdparty();
2133 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
2135 $soc = $objectsrc->thirdparty;
2137 $cond_reglement_id = 0;
2138 $mode_reglement_id = 0;
2142 $transport_mode_id = 0;
2145 if (!empty($objectsrc->cond_reglement_id)) {
2146 $cond_reglement_id = $objectsrc->cond_reglement_id;
2148 if (!empty($objectsrc->mode_reglement_id)) {
2149 $mode_reglement_id = $objectsrc->mode_reglement_id;
2151 if (!empty($objectsrc->fk_account)) {
2152 $fk_account = $objectsrc->fk_account;
2154 if (!empty($objectsrc->transport_mode_id)) {
2155 $transport_mode_id = $objectsrc->transport_mode_id;
2158 if (empty($cond_reglement_id)
2159 || empty($mode_reglement_id)
2160 || empty($fk_account)
2161 || empty($transport_mode_id)
2163 if ($origin ==
'reception') {
2165 if (!isset($objectsrc->supplier_order)) {
2166 $objectsrc->fetch_origin();
2169 if (!empty($objectsrc->origin_object)) {
2170 $originObject = $objectsrc->origin_object;
2171 if (empty($cond_reglement_id) && !empty($originObject->cond_reglement_id)) {
2172 $cond_reglement_id = $originObject->cond_reglement_id;
2174 if (empty($mode_reglement_id) && !empty($originObject->mode_reglement_id)) {
2175 $mode_reglement_id = $originObject->mode_reglement_id;
2177 if (empty($fk_account) && !empty($originObject->fk_account)) {
2178 $fk_account = $originObject->fk_account;
2180 if (empty($transport_mode_id) && !empty($originObject->transport_mode_id)) {
2181 $transport_mode_id = $originObject->transport_mode_id;
2188 if (empty($cond_reglement_id) && !empty($soc->cond_reglement_supplier_id)) {
2189 $cond_reglement_id = $soc->cond_reglement_supplier_id;
2191 if (empty($mode_reglement_id) && !empty($soc->mode_reglement_supplier_id)) {
2192 $mode_reglement_id = $soc->mode_reglement_supplier_id;
2194 if (empty($fk_account) && !empty($soc->fk_account)) {
2195 $fk_account = $soc->fk_account;
2197 if (empty($transport_mode_id) && !empty($soc->transport_mode_id)) {
2198 $transport_mode_id = $soc->transport_mode_id;
2203 if (isModEnabled(
"multicurrency")) {
2204 if (!empty($objectsrc->multicurrency_code)) {
2205 $currency_code = $objectsrc->multicurrency_code;
2207 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
2208 $currency_tx = $objectsrc->multicurrency_tx;
2213 $dateinvoice = ($datetmp ==
'' ? (!
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ? -1 :
'') : $datetmp);
2215 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2218 $objectsrc->fetch_optionals();
2219 $object->array_options = $objectsrc->array_options;
2221 $cond_reglement_id = !empty($societe->cond_reglement_supplier_id) ? $societe->cond_reglement_supplier_id : 0;
2222 $mode_reglement_id = !empty($societe->mode_reglement_supplier_id) ? $societe->mode_reglement_supplier_id : 0;
2223 $vat_reverse_charge = (empty($societe) ?
'' : $societe->vat_reverse_charge);
2224 $transport_mode_id = !empty($societe->transport_mode_supplier_id) ? $societe->transport_mode_supplier_id : 0;
2225 $fk_account = !empty($societe->fk_account) ? $societe->fk_account : 0;
2227 $dateinvoice = ($datetmp ==
'' ? (
getDolGlobalInt(
'MAIN_AUTOFILL_DATE') ?
'' : -1) : $datetmp);
2229 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2231 if (isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2232 $currency_code = $societe->multicurrency_code;
2237 if (empty($cond_reglement_id)) {
2238 $cond_reglement_id =
GETPOST(
"cond_reglement_id");
2242 if (empty($mode_reglement_id)) {
2243 $mode_reglement_id =
GETPOST(
"mode_reglement_id");
2247 if (!
GETPOST(
'changecompany')) {
2248 if (GETPOSTISSET(
'cond_reglement_id')) {
2249 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2251 if (GETPOSTISSET(
'mode_reglement_id')) {
2252 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2254 if (GETPOSTISSET(
'cond_reglement_id')) {
2259 $note_public =
$object->getDefaultCreateValueFor(
'note_public', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_public : null));
2260 $note_private =
$object->getDefaultCreateValueFor(
'note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_private : null));
2262 if ($origin ==
'contrat') {
2263 $langs->load(
"admin");
2264 $text = $langs->trans(
"ToCreateARecurringInvoice");
2265 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv(
"MenuFinancial"), $langs->transnoentitiesnoconv(
"SupplierBills"), $langs->transnoentitiesnoconv(
"ListOfTemplates"));
2267 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv(
'Module2300Name'));
2269 print
info_admin($text, 0, 0, 0,
'opacitymedium').
'<br>';
2272 print
'<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
2273 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2274 print
'<input type="hidden" name="action" value="add">';
2275 print
'<input type="hidden" name="changecompany" value="0">';
2277 if (!empty($societe->id) && $societe->id > 0) {
2278 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">'.
"\n";
2280 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
2281 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
2282 if (!empty($currency_tx)) {
2283 print
'<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
2285 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2290 $parameters = array();
2292 $reshook = $hookmanager->executeHooks(
'tabContentCreateSupplierInvoice', $parameters,
$object, $action);
2293 if (empty($reshook)) {
2294 print
'<table class="border centpercent">';
2297 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
'Draft').
'</td></tr>';
2301 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2302 $invoice_predefined->fetch($fac_recid);
2306 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
2309 if (!empty($societe->id) && $societe->id > 0 && ($fac_recid <= 0 || !empty($invoice_predefined->frequency))) {
2310 $absolute_discount = $societe->getAvailableDiscounts(
null,
'', 0, 1);
2311 print $societe->getNomUrl(1,
'supplier');
2312 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
2314 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
2315 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');
2318 print
'<script type="text/javascript">
2319 $(document).ready(function() {
2320 $("#socid").change(function() {
2321 console.log("We have changed the company - Reload page");
2323 $("input[name=action]").val("create");
2324 $("input[name=changecompany]").val("1");
2325 $("form[name=add]").submit();
2330 if ($fac_recid <= 0) {
2331 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>';
2337 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2338 $invoice_predefined->fetch($fac_recid);
2340 $dateinvoice = $invoice_predefined->date_when;
2341 if (empty($projectid)) {
2342 $projectid = $invoice_predefined->fk_project;
2344 $cond_reglement_id = $invoice_predefined->cond_reglement_id;
2345 $mode_reglement_id = $invoice_predefined->mode_reglement_id;
2346 $fk_account = $invoice_predefined->fk_account;
2347 $note_public = $invoice_predefined->note_public;
2348 $note_private = $invoice_predefined->note_private;
2350 if (!empty($invoice_predefined->multicurrency_code)) {
2351 $currency_code = $invoice_predefined->multicurrency_code;
2353 if (!empty($invoice_predefined->multicurrency_tx)) {
2354 $currency_tx = $invoice_predefined->multicurrency_tx;
2357 $sql =
'SELECT r.rowid, r.titre as title, r.total_ttc';
2358 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn_rec as r';
2359 $sql .=
' WHERE r.fk_soc = '. (int) $invoice_predefined->socid;
2361 $resql = $db->query($sql);
2363 $num = $db->num_rows($resql);
2367 print
'<tr><td>'.$langs->trans(
'CreateFromRepeatableInvoice').
'</td><td>';
2369 print
'<select class="flat" id="fac_rec" name="fac_rec">';
2370 print
'<option value="0" selected></option>';
2372 $objp = $db->fetch_object($resql);
2373 print
'<option value="'.$objp->rowid.
'"';
2374 if ($fac_recid == $objp->rowid) {
2376 $exampletemplateinvoice->fetch($fac_recid);
2378 print
'>'.$objp->title.
' ('.
price($objp->total_ttc).
' '.$langs->trans(
"TTC").
')</option>';
2384 print
'<script type="text/javascript">
2385 $(document).ready(function() {
2386 $("#fac_rec").change(function() {
2387 console.log("We have changed the template invoice - Reload page");
2389 $("input[name=action]").val("create");
2390 $("form[name=add]").submit();
2404 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"';
2405 if (!empty($societe->id) && $societe->id > 0) {
2411 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'Type').
'</td><td>';
2413 print
'<div class="tagtable">'.
"\n";
2416 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2417 $tmp =
'<input type="radio" id="radio_standard" name="type" value="0"'.(GETPOSTINT(
'type') ?
'' :
'checked').
'> ';
2418 $desc = $form->textwithpicto($tmp.
'<label for="radio_standard">'.$langs->trans(
"InvoiceStandardAsk").
'</label>', $langs->transnoentities(
"InvoiceStandardDesc"), 1,
'help',
'', 0, 3);
2420 print
'</div></div>';
2422 if (empty($origin) || ($origin ==
'order_supplier' && !empty($originid))) {
2425 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2426 $tmp =
'<input type="radio" id="radio_deposit" name="type" value="3"' . (
GETPOSTINT(
'type') == 3 ?
' checked' :
'') .
'> ';
2427 print
'<script type="text/javascript">
2428 jQuery(document).ready(function() {
2429 jQuery("#typestandardinvoice, #valuestandardinvoice").click(function() {
2430 jQuery("#radio_standard").prop("checked", true);
2432 jQuery("#typedeposit, #valuedeposit").click(function() {
2433 jQuery("#radio_deposit").prop("checked", true);
2435 jQuery("#typedeposit").change(function() {
2436 console.log("We change type of down payment");
2437 jQuery("#radio_deposit").prop("checked", true);
2438 setRadioForTypeOfInvoice();
2440 jQuery("#radio_standard, #radio_deposit, #radio_replacement, #radio_template").change(function() {
2441 setRadioForTypeOfInvoice();
2443 function setRadioForTypeOfInvoice() {
2444 console.log("Change radio");
2445 if (jQuery("#radio_deposit").prop("checked") && (jQuery("#typedeposit").val() == \'amount\' || jQuery("#typedeposit").val() == \'variable\')) {
2446 jQuery(".checkforselect").prop("disabled", true);
2447 jQuery(".checkforselect").prop("checked", false);
2449 jQuery(".checkforselect").prop("disabled", false);
2450 jQuery(".checkforselect").prop("checked", true);
2456 $tmp = $tmp.
'<label for="radio_deposit" >'.$langs->trans(
"InvoiceDeposit").
'</label>';
2458 $desc = $form->textwithpicto($tmp, $langs->transnoentities(
"InvoiceDepositDesc"), 1,
'help',
'', 0, 3);
2459 print
'<table class="nobordernopadding"><tr>';
2463 if ($origin ==
'order_supplier') {
2464 print
'<td class="nowrap" style="padding-left: 15px">';
2466 'amount' => $langs->transnoentitiesnoconv(
'FixAmount', $langs->transnoentitiesnoconv(
'Deposit')),
2467 'variable' => $langs->transnoentitiesnoconv(
'VarAmountOneLine', $langs->transnoentitiesnoconv(
'Deposit')),
2468 'variablealllines' => $langs->transnoentitiesnoconv(
'VarAmountAllLines')
2470 print $form->selectarray(
'typedeposit', $arraylist,
GETPOST(
'typedeposit',
'aZ09'), 0, 0, 0,
'', 1);
2472 print
'<td class="nowrap" style="padding-left: 5px">';
2473 print
'<span class="opacitymedium paddingleft">'.$langs->trans(
"AmountOrPercent").
'</span><input type="text" id="valuedeposit" name="valuedeposit" class="width75 right" value="' .
GETPOSTINT(
'valuedeposit') .
'"/>';
2476 print
'</tr></table>';
2478 print
'</div></div>';
2547 if (empty($origin)) {
2548 if (!empty($societe->id) && $societe->id > 0) {
2552 $facids = $facturestatic->list_qualified_avoir_supplier_invoices($societe->id);
2559 foreach ($facids as $key => $valarray) {
2560 $newinvoice_static->id = $key;
2561 $newinvoice_static->ref = $valarray [
'ref'];
2562 $newinvoice_static->status = $valarray [
'status'];
2563 $newinvoice_static->statut = $valarray [
'status'];
2564 $newinvoice_static->type = $valarray [
'type'];
2565 $newinvoice_static->paid = $valarray [
'paye'];
2566 $newinvoice_static->paye = $valarray [
'paye'];
2568 $optionsav .=
'<option value="'.$key.
'"';
2570 $optionsav .=
' selected';
2573 $optionsav .= $newinvoice_static->ref;
2574 $optionsav .=
' ('.$newinvoice_static->getLibStatut(1, $valarray [
'paymentornot']).
')';
2575 $optionsav .=
'</option>';
2578 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2579 $tmp =
'<input type="radio" id="radio_creditnote" name="type" value="2"'.(GETPOST(
'type') == 2 ?
' checked' :
'');
2581 $tmp .=
' disabled';
2585 print
'<script type="text/javascript">
2586 jQuery(document).ready(function() {
2587 if (! jQuery("#radio_creditnote").is(":checked"))
2589 jQuery("#credit_note_options").hide();
2591 jQuery("#radio_creditnote").click(function() {
2592 jQuery("#credit_note_options").show();
2594 jQuery("#radio_standard, #radio_replacement, #radio_deposit").click(function() {
2595 jQuery("#credit_note_options").hide();
2599 $text = $tmp.
'<label for="radio_creditnote">'.$langs->transnoentities(
"InvoiceAvoirAsk").
'</label> ';
2601 $text .=
'<select class="flat valignmiddle" name="fac_avoir" id="fac_avoir"';
2603 $text .=
' disabled';
2607 $text .=
'<option value="-1"></option>';
2608 $text .= $optionsav;
2610 $text .=
'<option value="-1">'.$langs->trans(
"NoInvoiceToCorrect").
'</option>';
2612 $text .=
'</select>';
2613 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2616 print
'<div id="credit_note_options" class="clearboth">';
2617 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' :
'').
' /> ';
2618 print
'<label for="invoiceAvoirWithLines">'.$langs->trans(
'invoiceAvoirWithLines').
"</label>";
2619 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' :
'').
' /> ';
2620 print
'<label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans(
'invoiceAvoirWithPaymentRestAmount').
"</label>";
2623 print
'</div></div>';
2626 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2628 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="0" disabled> ';
2630 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="2"> ';
2632 $text = $tmp.$langs->trans(
"InvoiceAvoir").
' ';
2633 $text .=
'<span class="opacitymedium">('.$langs->trans(
"YouMustCreateInvoiceFromSupplierThird").
')</span> ';
2634 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2636 print
'</div></div>'.
"\n";
2647 print
'<tr><td class="fieldrequired">'.$langs->trans(
'InvoiceSubtype').
'</td><td colspan="2">';
2648 print $form->getSelectInvoiceSubtype(
GETPOST(
'subtype'),
'subtype', 1, 0,
'');
2652 if (!empty($societe->id) && $societe->id > 0) {
2654 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
2656 $thirdparty = $societe;
2658 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$societe->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
2659 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2665 print
'<tr><td>'.$langs->trans(
'Label').
'</td><td><input class="minwidth200" name="label" value="'.
dol_escape_htmltag(
GETPOST(
'label')).
'" type="text"></td></tr>';
2668 print
'<tr><td class="fieldrequired">'.$langs->trans(
'DateInvoice').
'</td><td>';
2669 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2670 print $form->selectDate($dateinvoice,
'', 0, 0, 0,
"add", 1, 1);
2674 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
2675 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
2676 print $form->getSelectConditionsPaiements($cond_reglement_id,
'cond_reglement_id', -1, 1);
2681 print
'<tr><td>'.$langs->trans(
'DateMaxPayment').
'</td><td>';
2682 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2683 print $form->selectDate($datedue,
'ech', 0, 0, 0,
"add", 1, 1);
2687 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
2688 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
2689 $form->select_types_paiements($mode_reglement_id,
'mode_reglement_id',
'DBIT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx');
2693 if (isModEnabled(
"bank")) {
2694 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
2696 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes($fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
2701 if (isModEnabled(
'project')) {
2704 $langs->load(
'projects');
2705 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td>';
2706 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');
2707 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>';
2712 if (isModEnabled(
'incoterm')) {
2714 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), !empty($objectsrc->label_incoterms) ? $objectsrc->label_incoterms :
'', 1).
'</label></td>';
2715 print
'<td colspan="3" class="maxwidthonsmartphone">';
2716 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2717 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 :
''));
2723 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
2724 print
'<tr><td>' . $langs->trans(
'VATReverseCharge') .
'</td><td>';
2726 if (GETPOSTISSET(
'vat_reverse_charge')) {
2727 $vat_reverse_charge = (
GETPOST(
'vat_reverse_charge',
'alpha') ==
'on' ||
GETPOST(
'vat_reverse_charge',
'alpha') ==
'1') ? 1 : 0;
2728 } elseif ($vat_reverse_charge == 1 || $societe->vat_reverse_charge == 1 || ($societe->country_code !=
'FR' &&
isInEEC($societe) && !empty($societe->tva_intra))) {
2729 $vat_reverse_charge = 1;
2731 $vat_reverse_charge = 0;
2734 print
'<input type="checkbox" name="vat_reverse_charge"'. (!empty($vat_reverse_charge) ?
' checked ' :
'') .
'>';
2739 if (isModEnabled(
"multicurrency")) {
2741 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'',
$object, 0).
'</td>';
2742 print
'<td class="maxwidthonsmartphone">';
2743 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
2744 $used_currency_code = $currency_code;
2745 if (!
GETPOST(
'changecompany')) {
2746 $used_currency_code = GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code',
'alpha') : $currency_code;
2748 print $form->selectMultiCurrency($used_currency_code,
'multicurrency_code');
2754 if ($fac_recid > 0) {
2755 $dateexample = $dateinvoice;
2756 if (empty($dateexample)) {
2759 $substitutionarray = array(
2760 '__TOTAL_HT__' => $langs->trans(
"AmountHT").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ht).
')',
2761 '__TOTAL_TTC__' => $langs->trans(
"AmountTTC").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ttc).
')',
2762 '__INVOICE_PREVIOUS_MONTH__' => $langs->trans(
"PreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%m').
')',
2763 '__INVOICE_MONTH__' => $langs->trans(
"MonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%m').
')',
2764 '__INVOICE_NEXT_MONTH__' => $langs->trans(
"NextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%m').
')',
2765 '__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans(
"TextPreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%B').
')',
2766 '__INVOICE_MONTH_TEXT__' => $langs->trans(
"TextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%B').
')',
2767 '__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans(
"TextNextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%B').
')',
2768 '__INVOICE_PREVIOUS_YEAR__' => $langs->trans(
"PreviousYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'y'),
'%Y').
')',
2769 '__INVOICE_YEAR__' => $langs->trans(
"YearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%Y').
')',
2770 '__INVOICE_NEXT_YEAR__' => $langs->trans(
"NextYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'y'),
'%Y').
')'
2773 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
2774 foreach ($substitutionarray as $key => $val) {
2775 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
2777 $htmltext .=
'</i>';
2781 if (isModEnabled(
'intracommreport')) {
2782 $langs->loadLangs(array(
"intracommreport"));
2783 print
'<!-- If module intracomm on -->'.
"\n";
2784 print
'<tr><td>'.$langs->trans(
'IntracommReportTransportMode').
'</td><td>';
2785 $form->selectTransportMode(GETPOSTISSET(
'transport_mode_id') ?
GETPOST(
'transport_mode_id') : $transport_mode_id,
'transport_mode_id');
2789 if (empty($reshook)) {
2790 print
$object->showOptionals($extrafields,
'create');
2794 print
'<tr><td>'.$langs->trans(
'NotePublic').
'</td>';
2796 $doleditor =
new DolEditor(
'note_public', (GETPOSTISSET(
'note_public') ?
GETPOST(
'note_public',
'restricthtml') : $note_public),
'', 80,
'dolibarr_notes',
'In', 0, false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
2797 print $doleditor->Create(1);
2803 print
'<tr><td>'.$langs->trans(
'NotePrivate').
'</td>';
2805 $doleditor =
new DolEditor(
'note_private', (GETPOSTISSET(
'note_private') ?
GETPOST(
'note_private',
'restricthtml') : $note_private),
'', 80,
'dolibarr_notes',
'In', 0, false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
2806 print $doleditor->Create(1);
2812 if (!empty($objectsrc) && is_object($objectsrc)) {
2813 print
"\n<!-- ".$classname.
" info -->";
2815 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2816 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2817 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2818 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2819 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2821 $txt = $langs->trans($classname);
2822 if ($classname ==
'CommandeFournisseur') {
2823 $langs->load(
'orders');
2824 $txt = $langs->trans(
"SupplierOrder");
2826 print
'<tr><td>'.$txt.
'</td><td>'.$objectsrc->getNomUrl(1);
2828 $objectsrc->fetchObjectLinked($originid, $origin,
null,
'invoice_supplier');
2830 $invoice_supplier = $objectsrc->linkedObjects[
'invoice_supplier'];
2831 '@phan-var-force null|FactureFournisseur[] $invoice_supplier';
2834 if (is_array($invoice_supplier)) {
2835 $cntinvoice = count($invoice_supplier);
2837 if ($cntinvoice >= 1) {
2839 echo
' ('.$langs->trans(
'LatestRelatedBill').end($invoice_supplier)->getNomUrl(1).
')';
2844 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
2845 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
2846 if ($mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
2847 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
2850 if ($mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
2851 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
2853 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
2855 if (isModEnabled(
"multicurrency")) {
2856 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
2857 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
2858 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2863 $parameters = array();
2864 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2865 print $hookmanager->resPrint;
2873 print $form->buttonsSaveCancel(
"CreateDraft");
2876 if (!empty($objectsrc) && is_object($objectsrc)) {
2879 $title = $langs->trans(
'ProductsAndServices');
2882 print
'<div class="div-table-responsive-no-min">';
2883 print
'<table class="noborder centpercent">';
2885 $objectsrc->printOriginLinesList(
'', $selectedLines);
2893 if ($id > 0 || !empty($ref)) {
2899 $productstatic =
new Product($db);
2901 $result =
$object->fetch($id, $ref);
2903 $langs->load(
"errors");
2904 print $langs->trans(
"ErrorRecordNotFound");
2910 $result =
$object->fetch_thirdparty();
2916 $societe =
$object->thirdparty;
2918 $totalpaid =
$object->getSommePaiement();
2919 $totalcreditnotes =
$object->getSumCreditNotesUsed();
2920 $totaldeposits =
$object->getSumDepositsUsed();
2928 $resteapayer =
price2num(
$object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
2931 $multicurrency_resteapayer = 0;
2932 if (isModEnabled(
"multicurrency")) {
2933 $multicurrency_totalpaid =
$object->getSommePaiement(1);
2934 $multicurrency_totalcreditnotes =
$object->getSumCreditNotesUsed(1);
2935 $multicurrency_totaldeposits =
$object->getSumDepositsUsed(1);
2936 $multicurrency_resteapayer =
price2num(
$object->multicurrency_total_ttc - $multicurrency_totalpaid - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits,
'MT');
2940 if ($resteapayer == 0 && $multicurrency_resteapayer != 0 &&
$object->multicurrency_code != $conf->currency) {
2941 $resteapayer =
price2num((
float) $multicurrency_resteapayer /
$object->multicurrency_tx,
'MT');
2948 $resteapayeraffiche = $resteapayer;
2951 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
2952 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
2954 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
2955 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
2958 $absolute_discount = $societe->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
2959 $absolute_creditnote = $societe->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
2960 $absolute_discount =
price2num($absolute_discount,
'MT');
2961 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
2966 $objectidnext =
$object->getIdReplacingInvoice();
2969 $titre = $langs->trans(
'SupplierInvoice');
2971 print
dol_get_fiche_head($head,
'card', $titre, -1,
'supplier_invoice', 0,
'',
'', 0,
'', 1);
2976 if ($action ==
'converttoreduc') {
2979 $type_fac =
'ExcessPaid';
2981 $type_fac =
'CreditNote';
2983 $type_fac =
'Deposit';
2985 $text = $langs->trans(
'ConfirmConvertToReducSupplier', strtolower($langs->transnoentities($type_fac)));
2986 $text .=
'<br>'.$langs->trans(
'ConfirmConvertToReducSupplier2');
2987 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id, $langs->trans(
'ConvertToReduc'), $text,
'confirm_converttoreduc',
'',
"yes", 2);
2991 if ($action ==
'clone') {
2993 $formquestion = array(
2994 array(
'type' =>
'text',
'name' =>
'newsupplierref',
'label' => $langs->trans(
"RefSupplierBill"),
'value' => $langs->trans(
"CopyOf").
' '.
$object->ref_supplier),
2995 array(
'type' =>
'date',
'name' =>
'newdate',
'label' => $langs->trans(
"Date"),
'value' =>
dol_now())
2998 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneInvoice',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1, 250);
3002 if ($action ==
'valid') {
3004 if (preg_match(
'/^[\(]?PROV/i',
$object->ref) || empty(
$object->ref)) {
3006 $numref =
$object->getNextNumRef($societe);
3015 $text = $langs->trans(
'ConfirmValidateBill', $numref);
3023 $formquestion = array();
3025 $qualified_for_stock_change = 0;
3027 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3029 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3032 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
3033 $langs->load(
"stocks");
3034 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3037 $warehouse_array = $warehouse->list_array();
3038 if (count($warehouse_array) == 1) {
3040 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3043 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3045 $formquestion = array(
3046 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3050 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateBill'), $text,
'confirm_valid', $formquestion, 1, 1);
3055 if ($action ==
'edit') {
3056 $formquestion = array();
3058 $qualified_for_stock_change = 0;
3060 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3062 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3064 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
3065 $langs->load(
"stocks");
3066 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3069 $warehouse_array = $warehouse->list_array();
3070 if (count($warehouse_array) == 1) {
3072 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3075 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3077 $formquestion = array(
3078 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3081 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'UnvalidateBill'), $langs->trans(
'ConfirmUnvalidateBill',
$object->ref),
'confirm_edit', $formquestion, 1, 1);
3085 if ($action ==
'paid' && ($resteapayer <= 0 || (
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') && $resteapayer ==
$object->total_ttc))) {
3086 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidBill',
$object->ref),
'confirm_paid',
'', 0, 1);
3089 if ($action ==
'paid' && $resteapayer > 0 && (!
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') || $resteapayer !=
$object->total_ttc)) {
3093 $close[$i][
'code'] =
'discount_vat';
3095 $close[$i][
'code'] =
'badsupplier';
3097 $close[$i][
'code'] =
'other';
3101 $close[$i][
'label'] = $langs->trans(
"HelpEscompte").
'<br><br>'.$langs->trans(
"ConfirmClassifyPaidPartiallyReasonDiscountVatDesc");
3103 $close[$i][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3105 $close[$i][
'label'] = $langs->trans(
"Other");
3109 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonDiscount", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3111 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadCustomer", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3113 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"Other"), $close[$i][
'label'], 1);
3116 $arrayreasons = array();
3117 foreach ($close as $key => $val) {
3118 $arrayreasons[$close[$key][
'code']] = $close[$key][
'reason'];
3122 $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'));
3124 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?facid='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidPartially',
$object->ref),
'confirm_paid_partially', $formquestion,
"yes", 1, 310);
3128 if ($action ==
'canceled') {
3130 $close[1][
'code'] =
'badsupplier';
3131 $close[2][
'code'] =
'abandon';
3133 $close[1][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3134 $close[2][
'label'] = $langs->trans(
"ConfirmClassifyAbandonReasonOtherDesc");
3136 $close[1][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadSupplier",
$object->ref), $close[1][
'label'], 1);
3137 $close[2][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyAbandonReasonOther"), $close[2][
'label'], 1);
3139 $arrayreasons[$close[1][
'code']] = $close[1][
'reason'];
3140 $arrayreasons[$close[2][
'code']] = $close[2][
'reason'];
3143 $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'));
3145 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'CancelBill'), $langs->trans(
'ConfirmCancelBill',
$object->ref),
'confirm_canceled', $formquestion,
"yes", 1, 280);
3149 if ($action ==
'delete') {
3150 $formquestion = array();
3152 $qualified_for_stock_change = 0;
3154 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3156 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3159 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
3160 $langs->load(
"stocks");
3161 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3164 $warehouse_array = $warehouse->list_array();
3166 $selectwarehouse =
'<span class="questionrevertstock hidden">';
3167 if (count($warehouse_array) == 1) {
3169 $selectwarehouse .=
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3172 $selectwarehouse .= $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3174 $selectwarehouse .=
'</span>';
3176 $selectyesno = array(0 => $langs->trans(
'No'), 1 => $langs->trans(
'Yes'));
3178 print
'<script type="text/javascript">
3179 $(document).ready(function() {
3180 $("#revertstock").change(function() {
3181 if(this.value > 0) {
3182 $(".questionrevertstock").removeClass("hidden");
3184 $(".questionrevertstock").addClass("hidden");
3190 $formquestion = array(
3191 array(
'type' =>
'select',
'name' =>
'revertstock',
'label' => $langs->trans(
"RevertProductsToStock"),
'select_show_empty' => 0,
'values' => $selectyesno),
3192 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $selectwarehouse,
'tdclass' =>
'questionrevertstock hidden')
3196 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteBill'), $langs->trans(
'ConfirmDeleteBill'),
'confirm_delete', $formquestion, 1, 1);
3198 if ($action ==
'deletepayment') {
3199 $payment_id =
GETPOST(
'paiement_id');
3200 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&paiement_id='.$payment_id, $langs->trans(
'DeletePayment'), $langs->trans(
'ConfirmDeletePayment'),
'confirm_delete_paiement',
'', 0, 1);
3204 if ($action ==
'ask_deleteline') {
3205 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
3208 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
3209 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
3210 if (empty($reshook)) {
3211 $formconfirm .= $hookmanager->resPrint;
3212 } elseif ($reshook > 0) {
3213 $formconfirm = $hookmanager->resPrint;
3221 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
3223 $morehtmlref =
'<div class="refidno">';
3225 $morehtmlref .= $form->editfieldkey(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, $usercancreate,
'string',
'', 0, 1);
3226 $morehtmlref .= $form->editfieldval(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, $usercancreate,
'string',
'',
null,
null,
'', 1);
3228 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1,
'supplier');
3230 $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>';
3233 if (isModEnabled(
'project')) {
3234 $langs->load(
"projects");
3235 $morehtmlref .=
'<br>';
3236 if ($permissiontoadd) {
3237 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
3238 if ($action !=
'classify') {
3239 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.((int)
$object->id).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
3241 $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');
3243 if (!empty(
$object->fk_project)) {
3245 $proj->fetch(
$object->fk_project);
3246 $morehtmlref .= $proj->getNomUrl(1);
3248 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
3253 $morehtmlref .=
'</div>';
3255 $object->totalpaid = $totalpaid;
3257 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
3260 $parameters = array();
3262 $reshook = $hookmanager->executeHooks(
'tabContentViewSupplierInvoice', $parameters,
$object, $action);
3263 if (empty($reshook)) {
3264 print
'<div class="fichecenter">';
3265 print
'<div class="fichehalfleft">';
3266 print
'<div class="underbanner clearboth"></div>';
3268 print
'<table class="border tableforfield centpercent">';
3271 print
'<tr><td class="titlefield">'.$langs->trans(
'Type').
'</td><td>';
3272 print
'<span class="badgeneutral">';
3276 print
' '.$object->getSubtypeLabel(
'facture_fourn');
3280 $facreplaced->fetch(
$object->fk_facture_source);
3281 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
'</span>';
3284 if (
$object->fk_facture_source > 0) {
3286 $facusing->fetch(
$object->fk_facture_source);
3287 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
'</span>';
3289 $langs->load(
"errors");
3290 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"WarningCorrectedInvoiceNotFound").
'</span>';
3294 $facidavoir =
$object->getListIdAvoirFromInvoice();
3295 if (count($facidavoir) > 0) {
3296 $invoicecredits = array();
3297 foreach ($facidavoir as $id) {
3299 $facavoir->fetch($id);
3300 $invoicecredits[] = $facavoir->getNomUrl(1);
3302 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"InvoiceHasAvoir") . (count($invoicecredits) ?
' ' :
'') . implode(
',', $invoicecredits);
3305 if (isset($objectidnext) && $objectidnext > 0) {
3308 $facthatreplace->fetch($objectidnext);
3309 print
' <span class="opacitymediumbycolor paddingleft">'.str_replace(
'{s1}', $facthatreplace->getNomUrl(1), $langs->transnoentities(
"ReplacedByInvoice",
'{s1}')).
'</span>';
3313 $result = $discount->fetch(0, 0,
$object->id);
3315 print
' <span class="opacitymediumbycolor paddingleft">';
3316 $s = $langs->trans(
"CreditNoteConvertedIntoDiscount",
'{s1}',
'{s2}');
3317 $s = str_replace(
'{s1}',
$object->getLibType(1), $s);
3318 $s = str_replace(
'{s2}', $discount->getNomUrl(1,
'discount'), $s);
3320 print
'</span><br>';
3324 if (
$object->fk_fac_rec_source > 0) {
3326 $result = $tmptemplate->fetch(
$object->fk_fac_rec_source);
3328 print
' <span class="opacitymediumbycolor paddingleft">';
3329 $link =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.$tmptemplate->id.
'">'.
dol_escape_htmltag($tmptemplate->title).
'</a>';
3330 $s = $langs->transnoentities(
"GeneratedFromSupplierTemplate", $link);
3340 print
'<!-- Discounts -->'.
"\n";
3341 print
'<tr><td>'.$langs->trans(
'DiscountStillRemaining');
3344 $thirdparty = $societe;
3346 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
3352 print
'<td>'.$form->editfieldkey(
"Label",
'label',
$object->label,
$object, $usercancreate).
'</td>';
3353 print
'<td>'.$form->editfieldval(
"Label",
'label',
$object->label,
$object, $usercancreate).
'</td>';
3361 print $form->editfieldkey(
"DateInvoice",
'datef',
$object->date,
$object, $form_permission,
'datepicker');
3362 print
'</td><td colspan="3">';
3363 print $form->editfieldval(
"Date",
'datef',
$object->date,
$object, $form_permission,
'datepicker');
3367 $langs->load(
'bills');
3368 print
'<tr><td class="nowrap">';
3369 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3370 print $langs->trans(
'PaymentConditions');
3372 if ($action !=
'editconditions' && $form_permission) {
3373 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>';
3375 print
'</tr></table>';
3377 if ($action ==
'editconditions') {
3378 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'cond_reglement_id');
3380 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'none');
3387 print $form->editfieldkey(
"DateMaxPayment",
'date_lim_reglement',
$object->date_echeance,
$object, $form_permission,
'datepicker');
3389 print $form->editfieldval(
"DateMaxPayment",
'date_lim_reglement',
$object->date_echeance,
$object, $form_permission,
'datepicker');
3390 if ($action !=
'editdate_lim_reglement' &&
$object->hasDelay()) {
3396 $langs->load(
'bills');
3397 print
'<tr><td class="nowrap">';
3398 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3399 print $langs->trans(
'PaymentMode');
3401 if ($action !=
'editmode' && $form_permission) {
3402 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>';
3404 print
'</tr></table>';
3406 if ($action ==
'editmode') {
3407 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
3409 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'none');
3414 if (isModEnabled(
"multicurrency")) {
3418 print
'<table class="nobordernopadding" width="100%"><tr><td>';
3419 print $form->editfieldkey(
'Currency',
'multicurrency_code',
'',
$object, 0);
3421 if ($action !=
'editmulticurrencycode' &&
$object->status == $object::STATUS_DRAFT) {
3422 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmulticurrencycode&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetMultiCurrencyCode'), 1).
'</a></td>';
3424 print
'</tr></table>';
3426 if ($action ==
'editmulticurrencycode') {
3427 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_code,
'multicurrency_code');
3429 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_code,
'none');
3434 if (
$object->multicurrency_code != $conf->currency ||
$object->multicurrency_tx != 1) {
3437 print
'<table class="nobordernopadding centpercent"><tr><td>';
3438 print $form->editfieldkey(
'CurrencyRate',
'multicurrency_tx',
'',
$object, 0);
3440 if ($action !=
'editmulticurrencyrate' &&
$object->status == $object::STATUS_DRAFT &&
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency) {
3441 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmulticurrencyrate&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetMultiCurrencyCode'), 1).
'</a></td>';
3443 print
'</tr></table>';
3445 if ($action ==
'editmulticurrencyrate' || $action ==
'actualizemulticurrencyrate') {
3446 if ($action ==
'actualizemulticurrencyrate') {
3449 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_tx,
'multicurrency_tx',
$object->multicurrency_code);
3451 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_tx,
'none',
$object->multicurrency_code);
3452 if (
$object->status == $object::STATUS_DRAFT &&
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency) {
3453 print
'<div class="inline-block"> ';
3454 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=actualizemulticurrencyrate">'.$langs->trans(
"ActualizeCurrency").
'</a>';
3463 if (isModEnabled(
"bank")) {
3464 print
'<tr><td class="nowrap">';
3465 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3466 print $langs->trans(
'BankAccount');
3468 if ($action !=
'editbankaccount' && $usercancreate) {
3469 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>';
3471 print
'</tr></table>';
3473 if ($action ==
'editbankaccount') {
3474 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'fk_account', 1);
3476 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
3484 print
'<tr><td class="nowrap">';
3485 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3486 print $langs->trans(
'VATReverseCharge');
3488 if ($action !=
'editvatreversecharge' && $usercancreate) {
3489 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editvatreversecharge&id='.
$object->id.
'">'.
img_edit($langs->trans(
'SetVATReverseCharge'), 1).
'</a></td>';
3491 print
'</tr></table>';
3493 if ($action ==
'editvatreversecharge') {
3494 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
3495 print
'<input type="hidden" name="action" value="setvatreversecharge">';
3496 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3498 print
'<input type="checkbox" name="vat_reverse_charge"' . (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
'>';
3500 print
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
3503 print
'<input type="checkbox" name="vat_reverse_charge"'. (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
' disabled>';
3509 if (isModEnabled(
'incoterm')) {
3511 print
'<table width="100%" class="nobordernopadding"><tr><td>';
3512 print $langs->trans(
'IncotermLabel');
3513 print
'<td><td class="right">';
3514 if ($usercancreate) {
3515 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.
$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit().
'</a>';
3519 print
'</td></tr></table>';
3522 if ($action !=
'editincoterm') {
3523 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3525 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
3531 if (isModEnabled(
'intracommreport')) {
3532 $langs->loadLangs(array(
"intracommreport"));
3533 print
'<!-- If module intracomm on -->'.
"\n";
3535 print
'<table class="nobordernopadding centpercent"><tr><td>';
3536 print $langs->trans(
'IntracommReportTransportMode');
3538 if ($action !=
'edittransportmode' && ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"))) {
3539 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edittransportmode&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit().
'</a></td>';
3541 print
'</tr></table>';
3544 if ($action ==
'edittransportmode') {
3545 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->transport_mode_id,
'transport_mode_id', 1, 1);
3547 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->transport_mode_id,
'none');
3554 if (
$object->status != $object::STATUS_DRAFT) {
3558 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3563 print
'<div class="fichehalfright">';
3564 print
'<div class="underbanner clearboth"></div>';
3566 print
'<table class="border tableforfield centpercent">';
3569 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
3570 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3571 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
3572 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3577 print
'<td>' . $langs->trans(
'AmountVAT') .
'</td>';
3578 print
'<td class="nowrap amountcard right">';
3579 if (
GETPOST(
'calculationrule')) {
3580 $calculationrule =
GETPOST(
'calculationrule',
'alpha');
3582 $calculationrule = (!
getDolGlobalString(
'MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND') ?
'totalofround' :
'roundoftotal');
3584 if ($calculationrule ==
'totalofround') {
3585 $calculationrulenum = 1;
3587 $calculationrulenum = 2;
3590 if (
$object->getVentilExportCompta() == 0) {
3591 $s =
'<span class="hideonsmartphone opacitymedium">' . $langs->trans(
"ReCalculate") .
' </span>';
3592 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&token='.newToken().
'&calculationrule=totalofround">' . $langs->trans(
"Mode1") .
'</a>';
3594 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&token='.newToken().
'&calculationrule=roundoftotal">' . $langs->trans(
"Mode2") .
'</a>';
3595 print
'<div class="inline-block">';
3596 print $form->textwithtooltip($s, $langs->trans(
"CalculationRuleDesc", $calculationrulenum) .
'<br>' . $langs->trans(
"CalculationRuleDescSupplier"), 2, 1,
img_picto(
'',
'help'),
'', 3,
'', 0,
'recalculate');
3597 print
' ';
3600 print
price(
$object->total_tva, 1, $langs, 0, -1, -1, $conf->currency);
3602 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
3603 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3607 if ($societe->localtax1_assuj ==
"1") {
3609 print
'<td>' . $langs->transcountry(
"AmountLT1", $societe->country_code) .
'</td>';
3610 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 1, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3613 if ($societe->localtax2_assuj ==
"1") {
3615 print
'<td>' . $langs->transcountry(
"AmountLT2", $societe->country_code) .
'</td>';
3616 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 1, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3621 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
3622 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ttc, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3623 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency)) {
3624 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3642 if (isModEnabled(
'project')) {
3645 if (isModEnabled(
"bank")) {
3649 if (isModEnabled(
'incoterm')) {
3652 if (isModEnabled(
"multicurrency")) {
3657 if ($societe->localtax1_assuj ==
"1") {
3660 if ($societe->localtax2_assuj ==
"1") {
3664 $sql =
'SELECT p.datep as dp, p.ref, p.num_paiement as num_payment, p.rowid, p.fk_bank,';
3665 $sql .=
' c.id as payment_type, c.code as payment_code,';
3666 $sql .=
' pf.amount,';
3667 $sql .=
' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal';
3668 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn as p';
3669 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
3670 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
3671 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id';
3672 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid';
3673 $sql .=
' WHERE pf.fk_facturefourn = '.((int)
$object->id);
3674 $sql .=
' ORDER BY p.datep, p.tms';
3676 $result = $db->query($sql);
3678 $num = $db->num_rows($result);
3681 print
'<div class="div-table-responsive-no-min">';
3682 print
'<table class="noborder paymenttable centpercent">';
3683 print
'<tr class="liste_titre">';
3685 print
'<td>'.$langs->trans(
'Date').
'</td>';
3686 print
'<td>'.$langs->trans(
'Type').
'</td>';
3687 if (isModEnabled(
"bank")) {
3688 print
'<td class="right">'.$langs->trans(
'BankAccount').
'</td>';
3690 print
'<td class="right">'.$langs->trans(
'Amount').
'</td>';
3691 print
'<td width="18"> </td>';
3696 $objp = $db->fetch_object($result);
3698 $paymentstatic->id = $objp->rowid;
3699 $paymentstatic->datepaye = $db->jdate($objp->dp);
3700 $paymentstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
3701 $paymentstatic->num_payment = $objp->num_payment;
3703 $paymentstatic->paiementcode = $objp->payment_code;
3704 $paymentstatic->type_code = $objp->payment_code;
3705 $paymentstatic->type_label = $objp->payment_type;
3707 print
'<tr class="oddeven">';
3708 print
'<td class="nowraponall">';
3709 print $paymentstatic->getNomUrl(1);
3711 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
'</td>';
3712 $s = $form->form_modes_reglement(
'', $objp->payment_type,
'none',
'', 1, 0,
'', 1).
' '.$objp->num_payment;
3713 print
'<td class="tdoverflowmax125" title="'.dol_escape_htmltag($s).
'">';
3716 if (isModEnabled(
"bank")) {
3717 $bankaccountstatic->id = $objp->baid;
3718 $bankaccountstatic->ref = $objp->baref;
3719 $bankaccountstatic->label = $objp->baref;
3720 $bankaccountstatic->number = $objp->banumber;
3722 if (isModEnabled(
'accounting')) {
3723 $bankaccountstatic->account_number = $objp->account_number;
3726 $accountingjournal->fetch($objp->fk_accountancy_journal);
3727 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
3730 print
'<td class="right">';
3731 if ($objp->baid > 0) {
3732 print $bankaccountstatic->getNomUrl(1,
'transactions');
3736 print
'<td class="right">'.price($sign * $objp->amount).
'</td>';
3737 print
'<td class="center">';
3739 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deletepayment&token='.
newToken().
'&paiement_id='.$objp->rowid.
'">';
3745 $totalpaid += $objp->amount;
3749 print
'<tr class="oddeven"><td colspan="'.$nbcols.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td><td></td><td></td></tr>';
3772 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3773 print
'<span class="opacitymedium">';
3775 print $langs->trans(
'AlreadyPaidNoCreditNotesNoDeposits');
3777 print $langs->trans(
'AlreadyPaid');
3780 print
'</td><td class="right"'.(($totalpaid > 0) ?
' class="amountalreadypaid"' :
'').
'>'.
price($totalpaid).
'</td><td> </td></tr>';
3783 $resteapayeraffiche = $resteapayer;
3785 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
3788 $creditnoteamount = 0;
3791 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
3792 $sql .=
" re.description, re.fk_invoice_supplier_source";
3793 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
3794 $sql .=
" WHERE fk_invoice_supplier = ".((int)
$object->id);
3795 $resql = $db->query($sql);
3797 $num = $db->num_rows($resql);
3801 $obj = $db->fetch_object($resql);
3802 $invoice->fetch($obj->fk_invoice_supplier_source);
3803 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3805 print $langs->trans(
"CreditNote").
' ';
3808 print $langs->trans(
"Deposit").
' ';
3810 print $invoice->getNomUrl(0);
3812 print
'<td class="right">'.price($obj->amount_ttc).
'</td>';
3813 print
'<td class="right">';
3814 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=unlinkdiscount&discountid='.$obj->rowid.
'">';
3815 print
img_picto($langs->transnoentitiesnoconv(
"RemoveDiscount"),
'unlink');
3820 $creditnoteamount += $obj->amount_ttc;
3823 $depositamount += $obj->amount_ttc;
3832 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3833 print
'<span class="opacitymedium">';
3834 print $form->textwithpicto($langs->trans(
"Discount"), $langs->trans(
"HelpEscompte"), - 1);
3836 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3837 $resteapayeraffiche = 0;
3838 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3842 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3843 print
'<span class="opacitymedium">';
3844 print $form->textwithpicto($langs->trans(
"Abandoned"), $langs->trans(
"HelpAbandonBadCustomer"), - 1);
3846 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3848 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3852 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3853 print
'<span class="opacitymedium">';
3854 print $form->textwithpicto($langs->trans(
"ProductReturned"), $langs->trans(
"HelpAbandonProductReturned"), - 1);
3856 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3857 $resteapayeraffiche = 0;
3858 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3862 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3863 $text = $langs->trans(
"HelpAbandonOther");
3865 $text .=
'<br><br><b>'.$langs->trans(
"Reason").
'</b>:'.
$object->close_note;
3867 print
'<span class="opacitymedium">';
3869 print $form->textwithpicto($langs->trans(
"Abandoned"), $text, - 1);
3871 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3872 $resteapayeraffiche = 0;
3873 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3877 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3878 print
'<span class="opacitymedium">';
3879 print $langs->trans(
"Billed");
3881 print
'</td><td class="right">'.price(
$object->total_ttc).
'</td><td> </td></tr>';
3884 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3885 print
'<span class="opacitymedium">';
3886 print $langs->trans(
'RemainderToPay');
3887 if ($resteapayeraffiche < 0) {
3888 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
3892 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayeraffiche).
'</td><td> </td></tr>';
3895 if (isModEnabled(
'multicurrency') &&
$object->multicurrency_code != $conf->currency ||
$object->multicurrency_tx != 1) {
3896 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3897 print
'<span class="opacitymedium">';
3898 print $langs->trans(
'RemainderToPayMulticurrency');
3899 if ($resteapayeraffiche < 0) {
3900 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
3904 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.(!empty(
$object->multicurrency_code) ?
$object->multicurrency_code : $conf->currency).
' '.
price(
price2num($multicurrency_resteapayer,
'MT')).
'</td><td> </td></tr>';
3907 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3910 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3911 print $langs->trans(
'AlreadyPaidBack');
3912 print
' :</td><td class="right">'.price($sign * $totalpaid).
'</td><td> </td></tr>';
3915 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"Billed").
' :</td><td class="right">'.
price($sign *
$object->total_ttc).
'</td><td> </td></tr>';
3918 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3919 print
'<span class="opacitymedium">';
3920 print $langs->trans(
'RemainderToPayBack');
3921 if ($resteapayeraffiche > 0) {
3922 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
3926 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($sign * $resteapayeraffiche).
'</td><td> </td></tr>';
3929 if (isModEnabled(
'multicurrency') &&
$object->multicurrency_code != $conf->currency ||
$object->multicurrency_tx != 1) {
3930 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3931 print
'<span class="opacitymedium">';
3932 print $langs->trans(
'RemainderToPayBackMulticurrency');
3933 if ($resteapayeraffiche > 0) {
3934 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
3938 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>';
3953 print
'<div class="clearboth"></div><br>';
3956 $blocname =
'contacts';
3957 $title = $langs->trans(
'ContactsAddresses');
3958 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
3963 $blocname =
'notes';
3964 $title = $langs->trans(
'Notes');
3965 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
3972 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
3973 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3974 print
'<input type="hidden" name="action" value="'.(($action !=
'editline') ?
'addline' :
'updateline').
'">';
3975 print
'<input type="hidden" name="mode" value="">';
3976 print
'<input type="hidden" name="page_y" value="">';
3977 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
3978 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
3979 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
3982 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
3985 print
'<div class="div-table-responsive-no-min">';
3986 print
'<table id="tablelines" class="noborder noshadow centpercent">';
3988 global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax;
3991 $inputalsopricewithtax = 1;
3992 $senderissupplier = 2;
3995 $senderissupplier = 1;
4000 $object->printObjectLines($action, $societe, $mysoc, $lineid, 1);
4007 if ($action !=
'editline') {
4010 $parameters = array();
4011 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters,
$object, $action);
4015 if (empty($reshook)) {
4016 $object->formAddObjectLine(1, $societe, $mysoc);
4029 if ($action !=
'presend') {
4034 print
'<div class="tabsAction">';
4036 $parameters = array();
4037 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
4039 if (empty($reshook)) {
4043 $ventilExportCompta =
$object->getVentilExportCompta();
4045 if ($ventilExportCompta == 0) {
4046 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
'Modify').
'</a>';
4048 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseDispatchedInBookkeeping").
'">'.$langs->trans(
'Modify').
'</span>';
4053 $result = $discount->fetch(0, 0,
$object->id);
4060 if (!$objectidnext &&
$object->close_code !=
'replaced' && $usercancreate) {
4061 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=reopen&token='.
newToken().
'">'.$langs->trans(
'ReOpen').
'</a>';
4063 if ($usercancreate) {
4064 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseReplacedInvoice").
'">'.$langs->trans(
'ReOpen').
'</span>';
4066 print
'<span class="butActionRefused classfortooltip">'.$langs->trans(
'ReOpen').
'</span>';
4074 if ($usercanvalidate) {
4075 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=valid&token='.
newToken().
'"';
4076 print
'>'.$langs->trans(
'Validate').
'</a>';
4078 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'"';
4079 print
'>'.$langs->trans(
'Validate').
'</a>';
4085 if (empty($user->socid)) {
4088 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a>';
4090 print
'<span class="butActionRefused classfortooltip">'.$langs->trans(
'SendMail').
'</span>';
4097 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>';
4104 if ($resteapayer == 0) {
4105 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseRemainderToPayIsZero").
'">'.$langs->trans(
'DoPaymentBack').
'</span>';
4107 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>';
4113 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.
newToken().
'">'.$langs->trans(
'ConvertExcessPaidToReduc').
'</a>';
4117 && (
getDolGlobalString(
'SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED') ||
$object->getSommePaiement() == 0)
4119 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>';
4123 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.
newToken().
'">'.$langs->trans(
'ConvertToReduc').
'</a>';
4134 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=paid&token='.
newToken().
'">'.$langs->trans(
'ClassifyPaid').
'</a>';
4139 if ($totalpaid > 0 || $totalcreditnotes > 0) {
4141 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=paid&token='.
newToken().
'">'.$langs->trans(
'ClassifyPaidPartially').
'</a>';
4144 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=canceled">'.$langs->trans(
'ClassifyCanceled').
'</a>';
4157 if (!$objectidnext) {
4158 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>';
4163 if ($action !=
'edit' && $usercancreate) {
4164 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=clone&socid='.
$object->socid.
'&token='.
newToken().
'">'.$langs->trans(
'ToClone').
'</a>';
4169 if (!$objectidnext && count(
$object->lines) > 0) {
4170 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.
$object->id.
'&action=create">'.$langs->trans(
"ChangeIntoRepeatableInvoice").
'</a>';
4175 $isErasable =
$object->is_erasable();
4176 if ($action !=
'confirm_edit' && ($usercandelete || ($usercancreate && $isErasable == 1))) {
4177 $enableDelete =
false;
4179 $params = (empty($conf->use_javascript_ajax) ? array() : array(
'attr' => array(
'class' =>
'reposition')));
4181 if ($isErasable == -4) {
4182 $htmltooltip = $langs->trans(
"DisabledBecausePayments");
4183 } elseif ($isErasable == -3) {
4184 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastSituationInvoice");
4185 } elseif ($isErasable == -2) {
4186 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastInvoice");
4187 } elseif ($isErasable == -1) {
4188 $htmltooltip = $langs->trans(
"DisabledBecauseDispatchedInBookkeeping");
4189 } elseif ($isErasable <= 0) {
4190 $htmltooltip = $langs->trans(
"DisabledBecauseNotErasable");
4192 $enableDelete =
true;
4199 if ($action !=
'confirm_edit') {
4200 print
'<div class="fichecenter"><div class="fichehalfleft">';
4207 $filedir = $conf->fournisseur->facture->dir_output.
'/'.$subdir;
4208 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.
$object->id;
4209 $genallowed = $usercanread;
4210 $delallowed = $usercancreate;
4211 $modelpdf = (!empty(
$object->model_pdf) ?
$object->model_pdf : (!
getDolGlobalString(
'INVOICE_SUPPLIER_ADDON_PDF') ?
'' : $conf->global->INVOICE_SUPPLIER_ADDON_PDF));
4213 print $formfile->showdocuments(
'facture_fournisseur', $subdir, $filedir, $urlsource, $genallowed, $delallowed, $modelpdf, 1, 0, 0, 40, 0,
'',
'',
'', $societe->default_lang);
4214 $somethingshown = $formfile->numoffiles;
4217 $linktoelem = $form->showLinkToObjectBlock(
$object, array(), array(
'invoice_supplier'));
4218 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
4220 print
'</div><div class="fichehalfright">';
4223 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
4225 $somethingshown = $formactions->showactions(
$object,
'invoice_supplier', $socid, 1,
'listaction'.($genallowed ?
'largetitle' :
''));
4227 print
'</div></div>';
4233 if (
GETPOST(
'modelselected')) {
4234 $action =
'presend';
4238 $modelmail =
'invoice_supplier_send';
4239 $defaulttopic =
'SendBillRef';
4240 $diroutput = $conf->fournisseur->facture->dir_output;
4241 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
4242 $trackid =
'sinv'.$object->id;
4244 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage bank accounts.
Class to manage accounting journals.
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.
static getIdAndTxFromCode($dbs, $code, $date_document='')
Get id and rate of currency from code.
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.
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'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 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...
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.