39 require
'../../main.inc.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
43 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture-rec.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
48 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
49 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
50 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
52 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
53 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
56 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
57 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
61 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
64 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
68 $langs->loadLangs(array(
'bills',
'compta',
'suppliers',
'companies',
'products',
'banks',
'admin'));
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);
104 if ($id > 0 || !empty($ref)) {
105 $ret =
$object->fetch($id, $ref);
109 $ret =
$object->fetch_thirdparty();
117 if (!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;
153 if (empty($reshook)) {
154 $backurlforlist = DOL_URL_ROOT.
'/fourn/facture/list.php';
156 if (empty($backtopage) || ($cancel && empty($id))) {
157 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
158 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
159 $backtopage = $backurlforlist;
161 $backtopage = DOL_URL_ROOT.
'/fourn/facture/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
167 if (!empty($backtopageforcancel)) {
168 header(
"Location: ".$backtopageforcancel);
170 } elseif (!empty($backtopage)) {
171 header(
"Location: ".$backtopage);
177 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
179 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
181 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
184 if (
GETPOST(
'linkedOrder') && empty($cancel) && $id > 0) {
187 $result =
$object->add_object_linked(
'order_supplier',
GETPOST(
'linkedOrder'));
191 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
193 '@phan-var-force FactureFournisseur $objectutil';
195 if (
GETPOST(
'newsupplierref',
'alphanohtml')) {
196 $objectutil->ref_supplier =
GETPOST(
'newsupplierref',
'alphanohtml');
200 $result = $objectutil->createFromClone($user, $id);
202 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
205 $langs->load(
"errors");
209 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' && $usercanvalidate) {
210 $idwarehouse =
GETPOST(
'idwarehouse');
215 $qualified_for_stock_change = 0;
217 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
219 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
224 $langs->load(
"stocks");
225 if (!$idwarehouse || $idwarehouse == -1) {
227 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
235 $result =
$object->validate($user,
'', $idwarehouse);
245 $outputlangs = $langs;
248 $newlang =
GETPOST(
'lang_id',
'aZ09');
251 $newlang =
$object->thirdparty->default_lang;
253 if (!empty($newlang)) {
255 $outputlangs->setDefaultLang($newlang);
260 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
267 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes') {
271 $isErasable =
$object->is_erasable();
273 if (($usercandelete && $isErasable > 0) || ($usercancreate && $isErasable == 1)) {
274 $revertstock =
GETPOST(
'revertstock');
277 $idwarehouse =
GETPOST(
'idwarehouse');
279 $qualified_for_stock_change = 0;
281 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
283 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
288 $langs->load(
"stocks");
289 if (!$idwarehouse || $idwarehouse == -1) {
291 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
294 $result =
$object->setDraft($user, $idwarehouse);
303 $result =
$object->delete($user);
305 header(
'Location: list.php?restore_lastsearch_values=1');
312 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
314 $result =
$object->deleteLine($lineid);
334 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
341 } elseif ($action ==
'unlinkdiscount' && $usercancreate) {
344 $result = $discount->fetch(
GETPOSTINT(
"discountid"));
345 $discount->unlink_invoice();
346 } elseif ($action ==
'confirm_paid' && $confirm ==
'yes' && $usercancreate) {
348 $result =
$object->setPaid($user);
352 } elseif ($action ==
'confirm_paid_partially' && $confirm ==
'yes') {
355 $close_code =
GETPOST(
"close_code",
'restricthtml');
356 $close_note =
GETPOST(
"close_note",
'restricthtml');
358 $result =
$object->setPaid($user, $close_code, $close_note);
363 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Reason")),
null,
'errors');
365 } elseif ($action ==
'confirm_canceled' && $confirm ==
'yes') {
368 $close_code =
GETPOST(
"close_code",
'restricthtml');
369 $close_note =
GETPOST(
"close_note",
'restricthtml');
371 $result =
$object->setCanceled($user, $close_code, $close_note);
376 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Reason")),
null,
'errors');
381 if ($action ==
'setref_supplier' && $usercancreate) {
384 if (
$object->update($user) < 0) {
388 $outputlangs = $langs;
391 $newlang =
GETPOST(
'lang_id',
'aZ09');
394 $newlang =
$object->thirdparty->default_lang;
396 if (!empty($newlang)) {
398 $outputlangs->setDefaultLang($newlang);
402 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
408 if ($action ==
'setconditions' && $usercancreate) {
410 $object->cond_reglement_code = 0;
411 $object->cond_reglement_id = 0;
426 $old_date_echeance =
$object->date_echeance;
427 $new_date_echeance =
$object->calculate_date_lim_reglement();
428 if ($new_date_echeance > $old_date_echeance) {
429 $object->date_echeance = $new_date_echeance;
434 $result =
$object->update($user);
446 } elseif ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm')) {
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' && ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"))) {
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) &&
$object->date_echeance < $date_echence_calc) {
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;
1342 $object->special_code = $lines[$i]->special_code;
1345 if (
$object->multicurrency_code != $conf->currency ||
$object->multicurrency_tx != 1) {
1347 $pu_currency = $lines[$i]->multicurrency_subprice;
1349 $pu = $lines[$i]->subprice;
1358 $lines[$i]->localtax1_tx,
1359 $lines[$i]->localtax2_tx,
1361 $lines[$i]->fk_product,
1362 $lines[$i]->remise_percent,
1366 $lines[$i]->info_bits,
1371 $lines[$i]->array_options,
1372 $lines[$i]->fk_unit,
1375 $lines[$i]->ref_supplier,
1376 $lines[$i]->special_code
1393 } elseif (!$error) {
1403 $langs->load(
"errors");
1413 $outputlangs = $langs;
1414 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1421 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
1424 } elseif ($action ==
'updateline' && $usercancreate) {
1428 if (!
$object->fetch($id) > 0) {
1434 $tva_tx = str_replace(
'*',
'', $tva_tx);
1436 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_subprice') !=
'') {
1438 $price_base_type =
'HT';
1441 $price_base_type =
'TTC';
1444 if (
GETPOST(
'productid') > 0) {
1448 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1453 $prod->fetch(
GETPOST(
'productid'));
1454 $label = $prod->description;
1455 if (trim(
GETPOST(
'product_desc',
'restricthtml')) != trim($label)) {
1456 $label =
GETPOST(
'product_desc',
'restricthtml');
1459 $type = $prod->type;
1461 $label =
GETPOST(
'product_desc',
'restricthtml');
1470 if (preg_match(
'/\*/', $tva_tx)) {
1475 $tva_tx = str_replace(
'*',
'', $tva_tx);
1483 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1484 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1486 if (is_array($extralabelsline)) {
1487 foreach ($extralabelsline as $key => $value) {
1488 unset($_POST[
"options_".$key]);
1492 $result =
$object->updateline(
1514 unset($_POST[
'label']);
1515 unset($_POST[
'fourn_ref']);
1516 unset($_POST[
'date_starthour']);
1517 unset($_POST[
'date_startmin']);
1518 unset($_POST[
'date_startsec']);
1519 unset($_POST[
'date_startday']);
1520 unset($_POST[
'date_startmonth']);
1521 unset($_POST[
'date_startyear']);
1522 unset($_POST[
'date_endhour']);
1523 unset($_POST[
'date_endmin']);
1524 unset($_POST[
'date_endsec']);
1525 unset($_POST[
'date_endday']);
1526 unset($_POST[
'date_endmonth']);
1527 unset($_POST[
'date_endyear']);
1528 unset($_POST[
'price_ttc']);
1529 unset($_POST[
'price_ht']);
1536 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') && (
GETPOST(
'alldate_start',
'alpha') ||
GETPOST(
'alldate_end',
'alpha')) && $usercancreate) {
1540 foreach (
$object->lines as $line) {
1541 if ($line->product_type == 1) {
1542 $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);
1545 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') !=
'' && $usercancreate) {
1547 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
1548 $vat_rate = str_replace(
'*',
'', $vat_rate);
1551 foreach (
$object->lines as $line) {
1552 $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);
1554 } elseif ($action ==
'addline' && $usercancreate) {
1563 $ret =
$object->fetch_thirdparty();
1565 $langs->load(
'errors');
1574 $prod_entry_mode =
GETPOST(
'prod_entry_mode');
1575 if ($prod_entry_mode ==
'free') {
1586 $price_ttc_devise =
price2num(
GETPOST(
'multicurrency_price_ttc'),
'CU', 2);
1590 if (empty($remise_percent)) {
1591 $remise_percent = 0;
1595 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1596 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1598 if (is_array($extralabelsline)) {
1600 foreach ($extralabelsline as $key => $value) {
1601 unset($_POST[
"options_".$key]);
1605 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
1606 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1609 if ($prod_entry_mode ==
'free' && !
GETPOST(
'idprodfournprice') &&
GETPOST(
'type') < 0) {
1610 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
1613 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' && $price_ht_devise ===
'') {
1614 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'UnitPrice')),
null,
'errors');
1617 if ($prod_entry_mode ==
'free' && !
GETPOST(
'dp_desc')) {
1618 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
1621 if (!
GETPOST(
'qty',
'alpha')) {
1622 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1626 if (!$error &&
isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1627 if ($combinations =
GETPOST(
'combinations',
'array')) {
1631 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1632 $idprod = $res->fk_product_child;
1634 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1640 if ($prod_entry_mode !=
'free' && empty($error)) {
1644 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
1649 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
1651 $res = $productsupplier->fetch($idprod);
1654 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
1656 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1657 if ($productsupplier->fourn_socid != $socid) {
1658 $productsupplier->ref_supplier =
'';
1661 $fksoctosearch =
$object->thirdparty->id;
1662 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1664 } elseif (
GETPOST(
'idprodfournprice',
'alpha') > 0) {
1665 $qtytosearch = $qty;
1667 $idprod = $productsupplier->get_buyprice(
GETPOST(
'idprodfournprice',
'alpha'), $qtytosearch);
1668 $res = $productsupplier->fetch($idprod);
1672 $label = $productsupplier->label;
1675 $outputlangs = $langs;
1677 if (empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
1678 $newlang =
GETPOST(
'lang_id',
'aZ09');
1680 if (empty($newlang)) {
1681 $newlang =
$object->thirdparty->default_lang;
1683 if (!empty($newlang)) {
1684 $outputlangs =
new Translate(
"", $conf);
1685 $outputlangs->setDefaultLang($newlang);
1687 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->description;
1689 $desc = $productsupplier->description;
1692 if (!empty($productsupplier->desc_supplier) &&
getDolGlobalString(
'PRODUIT_FOURN_TEXTS')) {
1693 $desc = $productsupplier->desc_supplier;
1697 if (trim($product_desc) == trim($desc) &&
getDolGlobalString(
'PRODUIT_AUTOFILL_DESC')) {
1701 $desc = $product_desc;
1703 if (!empty($product_desc) && trim($product_desc) != trim($desc)) {
1707 $ref_supplier = $productsupplier->ref_supplier;
1714 if (empty($tva_tx) || empty($tva_npr)) {
1720 $type = $productsupplier->type;
1721 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1722 $price_base_type =
'HT';
1724 $pu_devise =
price2num($price_ht_devise,
'CU');
1725 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
1726 $price_base_type =
'TTC';
1728 $pu_devise =
price2num($price_ttc_devise,
'CU');
1730 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
1731 if (empty(
$object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code !=
$object->multicurrency_code)) {
1732 $pu = $productsupplier->fourn_pu;
1735 $pu = $productsupplier->fourn_pu;
1736 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
1740 $ref_supplier = $productsupplier->ref_supplier;
1761 min($rank, count(
$object->lines) + 1),
1764 $productsupplier->fk_unit,
1767 GETPOST(
'fourn_ref',
'alpha'),
1771 if ($idprod == -99 || $idprod == 0) {
1774 $langs->load(
"errors");
1775 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
1777 if ($idprod == -1) {
1780 $langs->load(
"errors");
1781 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
1783 } elseif (empty($error)) {
1784 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1785 $tva_tx = str_replace(
'*',
'', $tva_tx);
1786 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1787 $desc = $product_desc;
1789 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1791 $fk_unit =
GETPOST(
'units',
'alpha');
1793 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
1801 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1805 $pu_ht =
price2num((
float) $pu_ttc / (1 + ((
float) $tva_tx / 100)),
'MU');
1807 $price_base_type =
'HT';
1808 $pu_devise =
price2num($price_ht_devise,
'CU');
1810 $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);
1814 if (!$error && $result > 0) {
1819 $outputlangs = $langs;
1822 $newlang =
GETPOST(
'lang_id',
'aZ09');
1825 $newlang =
$object->thirdparty->default_lang;
1827 if (!empty($newlang)) {
1828 $outputlangs =
new Translate(
"", $conf);
1829 $outputlangs->setDefaultLang($newlang);
1834 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1840 unset($_POST [
'prod_entry_mode']);
1842 unset($_POST[
'qty']);
1843 unset($_POST[
'type']);
1844 unset($_POST[
'remise_percent']);
1845 unset($_POST[
'pu']);
1846 unset($_POST[
'price_ht']);
1847 unset($_POST[
'multicurrency_price_ht']);
1848 unset($_POST[
'price_ttc']);
1849 unset($_POST[
'fourn_ref']);
1850 unset($_POST[
'tva_tx']);
1851 unset($_POST[
'label']);
1852 unset($localtax1_tx);
1853 unset($localtax2_tx);
1854 unset($_POST[
'np_marginRate']);
1855 unset($_POST[
'np_markRate']);
1856 unset($_POST[
'dp_desc']);
1857 unset($_POST[
'idprodfournprice']);
1858 unset($_POST[
'units']);
1860 unset($_POST[
'date_starthour']);
1861 unset($_POST[
'date_startmin']);
1862 unset($_POST[
'date_startsec']);
1863 unset($_POST[
'date_startday']);
1864 unset($_POST[
'date_startmonth']);
1865 unset($_POST[
'date_startyear']);
1866 unset($_POST[
'date_endhour']);
1867 unset($_POST[
'date_endmin']);
1868 unset($_POST[
'date_endsec']);
1869 unset($_POST[
'date_endday']);
1870 unset($_POST[
'date_endmonth']);
1871 unset($_POST[
'date_endyear']);
1878 } elseif ($action ==
'classin' && $usercancreate) {
1880 $result =
$object->setProject($projectid);
1881 } elseif ($action ==
'confirm_edit' && $confirm ==
'yes' && $usercancreate) {
1885 $totalpaid =
$object->getSommePaiement();
1886 $resteapayer =
$object->total_ttc - $totalpaid;
1889 $ventilExportCompta =
$object->getVentilExportCompta();
1891 if (!$ventilExportCompta) {
1894 $idwarehouse =
GETPOST(
'idwarehouse');
1898 $qualified_for_stock_change = 0;
1900 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1902 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1907 $langs->load(
"stocks");
1908 if (!$idwarehouse || $idwarehouse == -1) {
1910 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
1915 $object->setDraft($user, $idwarehouse);
1919 $outputlangs = $langs;
1922 $newlang =
GETPOST(
'lang_id',
'aZ09');
1925 $newlang =
$object->thirdparty->default_lang;
1927 if (!empty($newlang)) {
1928 $outputlangs =
new Translate(
"", $conf);
1929 $outputlangs->setDefaultLang($newlang);
1934 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1943 } elseif ($action ==
'reopen' && $usercancreate) {
1945 $result =
$object->fetch($id);
1948 $result =
$object->setUnpaid($user);
1950 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
1959 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1962 $triggersendname =
'BILL_SUPPLIER_SENTBYMAIL';
1964 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
1965 $trackid =
'sinv'.$object->id;
1966 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1969 $upload_dir = $conf->fournisseur->facture->dir_output;
1970 $permissiontoadd = $usercancreate;
1971 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1974 if ($action ==
'calculate') {
1975 $calculationrule =
GETPOST(
'calculationrule');
1979 $result =
$object->update_price(0, (($calculationrule ==
'totalofround') ?
'0' :
'1'), 0,
$object->thirdparty);
1985 if ($action ==
'update_extras') {
1989 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
1997 $result =
$object->insertExtraFields(
'BILL_SUPPLIER_MODIFY');
2005 $action =
'edit_extras';
2010 if ($action ==
'addcontact') {
2011 $result =
$object->fetch($id);
2013 if ($result > 0 && $id > 0) {
2016 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
2020 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2023 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2024 $langs->load(
"errors");
2025 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
2030 } elseif ($action ==
'swapstatut') {
2037 } elseif ($action ==
'deletecontact') {
2043 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2059 $bankaccountstatic =
new Account($db);
2067 $title =
$object->ref.
" - ".$langs->trans(
'Card');
2068 if ($action ==
'create') {
2069 $title = $langs->trans(
"NewSupplierInvoice");
2071 $help_url =
'EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores|DE:Modul_Lieferantenrechnungen';
2075 if ($action ==
'create') {
2077 $selectedLines = array();
2079 print
load_fiche_titre($langs->trans(
'NewSupplierInvoice'),
'',
'supplier_invoice');
2083 $currency_code = $conf->currency;
2089 if (
isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2090 $currency_code = $societe->multicurrency_code;
2094 if (!empty($origin) && !empty($originid)) {
2096 $element = $subelement = $origin;
2098 if ($element ==
'project') {
2099 $projectid = $originid;
2100 $element =
'projet';
2104 if ($element ==
'order') {
2105 $element = $subelement =
'commande';
2107 if ($element ==
'propal') {
2108 $element =
'comm/propal';
2109 $subelement =
'propal';
2111 if ($element ==
'contract') {
2112 $element = $subelement =
'contrat';
2114 if ($element ==
'order_supplier') {
2116 $subelement =
'fournisseur.commande';
2119 require_once DOL_DOCUMENT_ROOT.
'/'.$element.
'/class/'.$subelement.
'.class.php';
2120 $classname = ucfirst($subelement);
2121 if ($classname ==
'Fournisseur.commande') {
2122 $classname =
'CommandeFournisseur';
2124 $objectsrc =
new $classname($db);
2125 '@phan-var-force Project|Commande|Propal|Facture|Contrat|CommandeFournisseur|CommonObject $objectsrc';
2126 $objectsrc->fetch($originid);
2127 $objectsrc->fetch_thirdparty();
2129 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
2131 $soc = $objectsrc->thirdparty;
2133 $cond_reglement_id = 0;
2134 $mode_reglement_id = 0;
2138 $transport_mode_id = 0;
2141 if (!empty($objectsrc->cond_reglement_id)) {
2142 $cond_reglement_id = $objectsrc->cond_reglement_id;
2144 if (!empty($objectsrc->mode_reglement_id)) {
2145 $mode_reglement_id = $objectsrc->mode_reglement_id;
2147 if (!empty($objectsrc->fk_account)) {
2148 $fk_account = $objectsrc->fk_account;
2150 if (!empty($objectsrc->transport_mode_id)) {
2151 $transport_mode_id = $objectsrc->transport_mode_id;
2154 if (empty($cond_reglement_id)
2155 || empty($mode_reglement_id)
2156 || empty($fk_account)
2157 || empty($transport_mode_id)
2159 if ($origin ==
'reception') {
2161 if (!isset($objectsrc->supplier_order)) {
2162 $objectsrc->fetch_origin();
2165 if (!empty($objectsrc->origin_object)) {
2166 $originObject = $objectsrc->origin_object;
2167 if (empty($cond_reglement_id) && !empty($originObject->cond_reglement_id)) {
2168 $cond_reglement_id = $originObject->cond_reglement_id;
2170 if (empty($mode_reglement_id) && !empty($originObject->mode_reglement_id)) {
2171 $mode_reglement_id = $originObject->mode_reglement_id;
2173 if (empty($fk_account) && !empty($originObject->fk_account)) {
2174 $fk_account = $originObject->fk_account;
2176 if (empty($transport_mode_id) && !empty($originObject->transport_mode_id)) {
2177 $transport_mode_id = $originObject->transport_mode_id;
2184 if (empty($cond_reglement_id) && !empty($soc->cond_reglement_supplier_id)) {
2185 $cond_reglement_id = $soc->cond_reglement_supplier_id;
2187 if (empty($mode_reglement_id) && !empty($soc->mode_reglement_supplier_id)) {
2188 $mode_reglement_id = $soc->mode_reglement_supplier_id;
2190 if (empty($fk_account) && !empty($soc->fk_account)) {
2191 $fk_account = $soc->fk_account;
2193 if (empty($transport_mode_id) && !empty($soc->transport_mode_id)) {
2194 $transport_mode_id = $soc->transport_mode_id;
2200 if (!empty($objectsrc->multicurrency_code)) {
2201 $currency_code = $objectsrc->multicurrency_code;
2203 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
2204 $currency_tx = $objectsrc->multicurrency_tx;
2209 $dateinvoice = ($datetmp ==
'' ? (!
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ? -1 :
'') : $datetmp);
2211 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2214 $objectsrc->fetch_optionals();
2215 $object->array_options = $objectsrc->array_options;
2217 $cond_reglement_id = !empty($societe->cond_reglement_supplier_id) ? $societe->cond_reglement_supplier_id : 0;
2218 $mode_reglement_id = !empty($societe->mode_reglement_supplier_id) ? $societe->mode_reglement_supplier_id : 0;
2219 $vat_reverse_charge = (empty($societe) ?
'' : $societe->vat_reverse_charge);
2220 $transport_mode_id = !empty($societe->transport_mode_supplier_id) ? $societe->transport_mode_supplier_id : 0;
2221 $fk_account = !empty($societe->fk_account) ? $societe->fk_account : 0;
2223 $dateinvoice = ($datetmp ==
'' ? (
getDolGlobalInt(
'MAIN_AUTOFILL_DATE') ?
'' : -1) : $datetmp);
2225 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2227 if (
isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2228 $currency_code = $societe->multicurrency_code;
2233 if (empty($cond_reglement_id)) {
2234 $cond_reglement_id =
GETPOST(
"cond_reglement_id");
2238 if (empty($mode_reglement_id)) {
2239 $mode_reglement_id =
GETPOST(
"mode_reglement_id");
2243 if (!
GETPOST(
'changecompany')) {
2245 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2248 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2255 $note_public =
$object->getDefaultCreateValueFor(
'note_public', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_public :
null));
2256 $note_private =
$object->getDefaultCreateValueFor(
'note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_private :
null));
2258 if ($origin ==
'contrat') {
2259 $langs->load(
"admin");
2260 $text = $langs->trans(
"ToCreateARecurringInvoice");
2261 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv(
"MenuFinancial"), $langs->transnoentitiesnoconv(
"SupplierBills"), $langs->transnoentitiesnoconv(
"ListOfTemplates"));
2263 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv(
'Module2300Name'));
2265 print
info_admin($text, 0, 0, 0,
'opacitymedium').
'<br>';
2268 print
'<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
2269 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2270 print
'<input type="hidden" name="action" value="add">';
2271 print
'<input type="hidden" name="changecompany" value="0">';
2273 if (!empty($societe->id) && $societe->id > 0) {
2274 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">'.
"\n";
2276 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
2277 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
2278 if (!empty($currency_tx)) {
2279 print
'<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
2281 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2288 $reshook = $hookmanager->executeHooks(
'tabContentCreateSupplierInvoice',
$parameters,
$object, $action);
2289 if (empty($reshook)) {
2290 print
'<table class="border centpercent">';
2293 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
'Draft').
'</td></tr>';
2297 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2298 $invoice_predefined->fetch($fac_recid);
2302 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
2305 if (!empty($societe->id) && $societe->id > 0 && ($fac_recid <= 0 || !empty($invoice_predefined->frequency))) {
2306 $absolute_discount = $societe->getAvailableDiscounts(
null,
'', 0, 1);
2307 print $societe->getNomUrl(1,
'supplier');
2308 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
2310 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
2311 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');
2314 print
'<script type="text/javascript">
2315 $(document).ready(function() {
2316 $("#socid").change(function() {
2317 console.log("We have changed the company - Reload page");
2319 $("input[name=action]").val("create");
2320 $("input[name=changecompany]").val("1");
2321 $("form[name=add]").submit();
2326 if ($fac_recid <= 0) {
2327 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>';
2333 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2334 $invoice_predefined->fetch($fac_recid);
2336 $dateinvoice = $invoice_predefined->date_when;
2337 if (empty($projectid)) {
2338 $projectid = $invoice_predefined->fk_project;
2340 $cond_reglement_id = $invoice_predefined->cond_reglement_id;
2341 $mode_reglement_id = $invoice_predefined->mode_reglement_id;
2342 $fk_account = $invoice_predefined->fk_account;
2343 $note_public = $invoice_predefined->note_public;
2344 $note_private = $invoice_predefined->note_private;
2346 if (!empty($invoice_predefined->multicurrency_code)) {
2347 $currency_code = $invoice_predefined->multicurrency_code;
2349 if (!empty($invoice_predefined->multicurrency_tx)) {
2350 $currency_tx = $invoice_predefined->multicurrency_tx;
2353 $sql =
'SELECT r.rowid, r.titre as title, r.total_ttc';
2354 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn_rec as r';
2355 $sql .=
' WHERE r.fk_soc = '. (int) $invoice_predefined->socid;
2357 $resql = $db->query(
$sql);
2359 $num = $db->num_rows($resql);
2363 print
'<tr><td>'.$langs->trans(
'CreateFromRepeatableInvoice').
'</td><td>';
2365 print
'<select class="flat" id="fac_rec" name="fac_rec">';
2366 print
'<option value="0" selected></option>';
2368 $objp = $db->fetch_object($resql);
2369 print
'<option value="'.$objp->rowid.
'"';
2370 if ($fac_recid == $objp->rowid) {
2372 $exampletemplateinvoice->fetch($fac_recid);
2374 print
'>'.$objp->title.
' ('.
price($objp->total_ttc).
' '.$langs->trans(
"TTC").
')</option>';
2380 print
'<script type="text/javascript">
2381 $(document).ready(function() {
2382 $("#fac_rec").change(function() {
2383 console.log("We have changed the template invoice - Reload page");
2385 $("input[name=action]").val("create");
2386 $("form[name=add]").submit();
2400 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"';
2401 if (!empty($societe->id) && $societe->id > 0) {
2407 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'Type').
'</td><td>';
2409 print
'<div class="tagtable">'.
"\n";
2412 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2413 $tmp =
'<input type="radio" id="radio_standard" name="type" value="0"'.(GETPOSTINT(
'type') ?
'' :
'checked').
'> ';
2414 $desc =
$form->textwithpicto($tmp.
'<label for="radio_standard">'.$langs->trans(
"InvoiceStandardAsk").
'</label>', $langs->transnoentities(
"InvoiceStandardDesc"), 1,
'help',
'', 0, 3);
2416 print
'</div></div>';
2418 if (empty($origin) || ($origin ==
'order_supplier' && !empty($originid))) {
2421 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2422 $tmp =
'<input type="radio" id="radio_deposit" name="type" value="3"' . (
GETPOSTINT(
'type') == 3 ?
' checked' :
'') .
'> ';
2423 print
'<script type="text/javascript">
2424 jQuery(document).ready(function() {
2425 jQuery("#typestandardinvoice, #valuestandardinvoice").click(function() {
2426 jQuery("#radio_standard").prop("checked", true);
2428 jQuery("#typedeposit, #valuedeposit").click(function() {
2429 jQuery("#radio_deposit").prop("checked", true);
2431 jQuery("#typedeposit").change(function() {
2432 console.log("We change type of down payment");
2433 jQuery("#radio_deposit").prop("checked", true);
2434 setRadioForTypeOfInvoice();
2436 jQuery("#radio_standard, #radio_deposit, #radio_replacement, #radio_template").change(function() {
2437 setRadioForTypeOfInvoice();
2439 function setRadioForTypeOfInvoice() {
2440 console.log("Change radio");
2441 if (jQuery("#radio_deposit").prop("checked") && (jQuery("#typedeposit").val() == \'amount\' || jQuery("#typedeposit").val() == \'variable\')) {
2442 jQuery(".checkforselect").prop("disabled", true);
2443 jQuery(".checkforselect").prop("checked", false);
2445 jQuery(".checkforselect").prop("disabled", false);
2446 jQuery(".checkforselect").prop("checked", true);
2452 $tmp = $tmp.
'<label for="radio_deposit" >'.$langs->trans(
"InvoiceDeposit").
'</label>';
2454 $desc =
$form->textwithpicto($tmp, $langs->transnoentities(
"InvoiceDepositDesc"), 1,
'help',
'', 0, 3);
2455 print
'<table class="nobordernopadding"><tr>';
2459 if ($origin ==
'order_supplier') {
2460 print
'<td class="nowrap" style="padding-left: 15px">';
2462 'amount' => $langs->transnoentitiesnoconv(
'FixAmount', $langs->transnoentitiesnoconv(
'Deposit')),
2463 'variable' => $langs->transnoentitiesnoconv(
'VarAmountOneLine', $langs->transnoentitiesnoconv(
'Deposit')),
2464 'variablealllines' => $langs->transnoentitiesnoconv(
'VarAmountAllLines')
2466 print
$form->selectarray(
'typedeposit', $arraylist,
GETPOST(
'typedeposit',
'aZ09'), 0, 0, 0,
'', 1);
2468 print
'<td class="nowrap" style="padding-left: 5px">';
2469 print
'<span class="opacitymedium paddingleft">'.$langs->trans(
"AmountOrPercent").
'</span><input type="text" id="valuedeposit" name="valuedeposit" class="width75 right" value="' .
GETPOSTINT(
'valuedeposit') .
'"/>';
2472 print
'</tr></table>';
2474 print
'</div></div>';
2543 if (empty($origin)) {
2544 if (!empty($societe->id) && $societe->id > 0) {
2548 $facids = $facturestatic->list_qualified_avoir_supplier_invoices($societe->id);
2555 foreach ($facids as $key => $valarray) {
2556 $newinvoice_static->id = $key;
2557 $newinvoice_static->ref = $valarray [
'ref'];
2558 $newinvoice_static->status = $valarray [
'status'];
2559 $newinvoice_static->statut = $valarray [
'status'];
2560 $newinvoice_static->type = $valarray [
'type'];
2561 $newinvoice_static->paid = $valarray [
'paye'];
2562 $newinvoice_static->paye = $valarray [
'paye'];
2564 $optionsav .=
'<option value="'.$key.
'"';
2566 $optionsav .=
' selected';
2569 $optionsav .= $newinvoice_static->ref;
2570 $optionsav .=
' ('.$newinvoice_static->getLibStatut(1, $valarray [
'paymentornot']).
')';
2571 $optionsav .=
'</option>';
2574 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2575 $tmp =
'<input type="radio" id="radio_creditnote" name="type" value="2"'.(GETPOST(
'type') == 2 ?
' checked' :
'');
2577 $tmp .=
' disabled';
2581 print
'<script type="text/javascript">
2582 jQuery(document).ready(function() {
2583 if (! jQuery("#radio_creditnote").is(":checked"))
2585 jQuery("#credit_note_options").hide();
2587 jQuery("#radio_creditnote").click(function() {
2588 jQuery("#credit_note_options").show();
2590 jQuery("#radio_standard, #radio_replacement, #radio_deposit").click(function() {
2591 jQuery("#credit_note_options").hide();
2595 $text = $tmp.
'<label for="radio_creditnote">'.$langs->transnoentities(
"InvoiceAvoirAsk").
'</label> ';
2597 $text .=
'<select class="flat valignmiddle" name="fac_avoir" id="fac_avoir"';
2599 $text .=
' disabled';
2603 $text .=
'<option value="-1"></option>';
2604 $text .= $optionsav;
2606 $text .=
'<option value="-1">'.$langs->trans(
"NoInvoiceToCorrect").
'</option>';
2608 $text .=
'</select>';
2609 $desc =
$form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2612 print
'<div id="credit_note_options" class="clearboth">';
2613 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' :
'').
' /> ';
2614 print
'<label for="invoiceAvoirWithLines">'.$langs->trans(
'invoiceAvoirWithLines').
"</label>";
2615 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' :
'').
' /> ';
2616 print
'<label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans(
'invoiceAvoirWithPaymentRestAmount').
"</label>";
2619 print
'</div></div>';
2622 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2624 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="0" disabled> ';
2626 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="2"> ';
2628 $text = $tmp.$langs->trans(
"InvoiceAvoir").
' ';
2629 $text .=
'<span class="opacitymedium">('.$langs->trans(
"YouMustCreateInvoiceFromSupplierThird").
')</span> ';
2630 $desc =
$form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2632 print
'</div></div>'.
"\n";
2643 print
'<tr><td class="fieldrequired">'.$langs->trans(
'InvoiceSubtype').
'</td><td colspan="2">';
2644 print
$form->getSelectInvoiceSubtype(
GETPOST(
'subtype'),
'subtype', 1, 0,
'');
2648 if (!empty($societe->id) && $societe->id > 0) {
2650 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
2652 $thirdparty = $societe;
2654 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$societe->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
2655 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2661 print
'<tr><td>'.$langs->trans(
'Label').
'</td><td><input class="minwidth200" name="label" value="'.
dol_escape_htmltag(
GETPOST(
'label')).
'" type="text"></td></tr>';
2664 print
'<tr><td class="fieldrequired">'.$langs->trans(
'DateInvoice').
'</td><td>';
2665 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2666 print
$form->selectDate($dateinvoice,
'', 0, 0, 0,
"add", 1, 1);
2670 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
2671 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
2672 print
$form->getSelectConditionsPaiements($cond_reglement_id,
'cond_reglement_id', -1, 1);
2677 print
'<tr><td>'.$langs->trans(
'DateMaxPayment').
'</td><td>';
2678 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2679 print
$form->selectDate($datedue,
'ech', 0, 0, 0,
"add", 1, 1);
2683 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
2684 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
2685 $form->select_types_paiements($mode_reglement_id,
'mode_reglement_id',
'DBIT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx');
2690 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
2692 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes($fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
2700 $langs->load(
'projects');
2701 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td>';
2702 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');
2703 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>';
2710 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), !empty($objectsrc->label_incoterms) ? $objectsrc->label_incoterms :
'', 1).
'</label></td>';
2711 print
'<td colspan="3" class="maxwidthonsmartphone">';
2712 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2713 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 :
''));
2719 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
2720 print
'<tr><td>' . $langs->trans(
'VATReverseCharge') .
'</td><td>';
2722 if ($vat_reverse_charge == 1 || $societe->vat_reverse_charge == 1 || ($societe->country_code !=
'FR' &&
isInEEC($societe) && !empty($societe->tva_intra))) {
2723 $vat_reverse_charge = 1;
2725 $vat_reverse_charge = 0;
2728 print
'<input type="checkbox" name="vat_reverse_charge"'. (!empty($vat_reverse_charge) ?
' checked ' :
'') .
'>';
2735 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'',
$object, 0).
'</td>';
2736 print
'<td class="maxwidthonsmartphone">';
2737 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
2738 $used_currency_code = $currency_code;
2739 if (!
GETPOST(
'changecompany')) {
2740 $used_currency_code =
GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code',
'alpha') : $currency_code;
2742 print
$form->selectMultiCurrency($used_currency_code,
'multicurrency_code');
2748 if ($fac_recid > 0) {
2749 $dateexample = $dateinvoice;
2750 if (empty($dateexample)) {
2753 $substitutionarray = array(
2754 '__TOTAL_HT__' => $langs->trans(
"AmountHT").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ht).
')',
2755 '__TOTAL_TTC__' => $langs->trans(
"AmountTTC").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ttc).
')',
2756 '__INVOICE_PREVIOUS_MONTH__' => $langs->trans(
"PreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%m').
')',
2757 '__INVOICE_MONTH__' => $langs->trans(
"MonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%m').
')',
2758 '__INVOICE_NEXT_MONTH__' => $langs->trans(
"NextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%m').
')',
2759 '__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans(
"TextPreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%B').
')',
2760 '__INVOICE_MONTH_TEXT__' => $langs->trans(
"TextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%B').
')',
2761 '__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans(
"TextNextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%B').
')',
2762 '__INVOICE_PREVIOUS_YEAR__' => $langs->trans(
"PreviousYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'y'),
'%Y').
')',
2763 '__INVOICE_YEAR__' => $langs->trans(
"YearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%Y').
')',
2764 '__INVOICE_NEXT_YEAR__' => $langs->trans(
"NextYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'y'),
'%Y').
')'
2767 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
2768 foreach ($substitutionarray as $key => $val) {
2769 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
2771 $htmltext .=
'</i>';
2776 $langs->loadLangs(array(
"intracommreport"));
2777 print
'<!-- If module intracomm on -->'.
"\n";
2778 print
'<tr><td>'.$langs->trans(
'IntracommReportTransportMode').
'</td><td>';
2779 $form->selectTransportMode(
GETPOSTISSET(
'transport_mode_id') ?
GETPOST(
'transport_mode_id') : $transport_mode_id,
'transport_mode_id');
2783 if (empty($reshook)) {
2784 print
$object->showOptionals($extrafields,
'create');
2788 print
'<tr><td>'.$langs->trans(
'NotePublic').
'</td>';
2790 $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%');
2791 print $doleditor->Create(1);
2797 print
'<tr><td>'.$langs->trans(
'NotePrivate').
'</td>';
2799 $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%');
2800 print $doleditor->Create(1);
2806 if (!empty($objectsrc) && is_object($objectsrc)) {
2807 print
"\n<!-- ".$classname.
" info -->";
2809 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2810 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2811 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2812 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2813 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2815 $txt = $langs->trans($classname);
2816 if ($classname ==
'CommandeFournisseur') {
2817 $langs->load(
'orders');
2818 $txt = $langs->trans(
"SupplierOrder");
2820 print
'<tr><td>'.$txt.
'</td><td>'.$objectsrc->getNomUrl(1);
2822 $objectsrc->fetchObjectLinked($originid, $origin,
null,
'invoice_supplier');
2824 $invoice_supplier = $objectsrc->linkedObjects[
'invoice_supplier'];
2825 '@phan-var-force null|FactureFournisseur[] $invoice_supplier';
2828 if (is_array($invoice_supplier)) {
2829 $cntinvoice = count($invoice_supplier);
2831 if ($cntinvoice >= 1) {
2833 echo
' ('.$langs->trans(
'LatestRelatedBill').end($invoice_supplier)->getNomUrl(1).
')';
2838 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
2839 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
2840 if ($mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
2841 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
2844 if ($mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
2845 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
2847 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
2850 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
2851 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
2852 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2858 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters,
$object, $action);
2859 print $hookmanager->resPrint;
2867 print
$form->buttonsSaveCancel(
"CreateDraft");
2870 if (!empty($objectsrc) && is_object($objectsrc)) {
2873 $title = $langs->trans(
'ProductsAndServices');
2876 print
'<div class="div-table-responsive-no-min">';
2877 print
'<table class="noborder centpercent">';
2879 $objectsrc->printOriginLinesList(
'', $selectedLines);
2887 if ($id > 0 || !empty($ref)) {
2893 $productstatic =
new Product($db);
2895 $result =
$object->fetch($id, $ref);
2897 $langs->load(
"errors");
2898 print $langs->trans(
"ErrorRecordNotFound");
2904 $result =
$object->fetch_thirdparty();
2910 $societe =
$object->thirdparty;
2912 $totalpaid =
$object->getSommePaiement();
2913 $totalcreditnotes =
$object->getSumCreditNotesUsed();
2914 $totaldeposits =
$object->getSumDepositsUsed();
2922 $resteapayer =
price2num(
$object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
2925 $multicurrency_resteapayer = 0;
2927 $multicurrency_totalpaid =
$object->getSommePaiement(1);
2928 $multicurrency_totalcreditnotes =
$object->getSumCreditNotesUsed(1);
2929 $multicurrency_totaldeposits =
$object->getSumDepositsUsed(1);
2930 $multicurrency_resteapayer =
price2num(
$object->multicurrency_total_ttc - $multicurrency_totalpaid - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits,
'MT');
2934 if ($resteapayer == 0 && $multicurrency_resteapayer != 0 &&
$object->multicurrency_code != $conf->currency) {
2935 $resteapayer =
price2num((
float) $multicurrency_resteapayer /
$object->multicurrency_tx,
'MT');
2942 $resteapayeraffiche = $resteapayer;
2945 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
2946 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
2948 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
2949 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
2952 $absolute_discount = $societe->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
2953 $absolute_creditnote = $societe->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
2954 $absolute_discount =
price2num($absolute_discount,
'MT');
2955 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
2960 $objectidnext =
$object->getIdReplacingInvoice();
2963 $titre = $langs->trans(
'SupplierInvoice');
2965 print
dol_get_fiche_head($head,
'card', $titre, -1,
'supplier_invoice', 0,
'',
'', 0,
'', 1);
2970 if ($action ==
'converttoreduc') {
2973 $type_fac =
'ExcessPaid';
2975 $type_fac =
'CreditNote';
2977 $type_fac =
'Deposit';
2979 $text = $langs->trans(
'ConfirmConvertToReducSupplier', strtolower($langs->transnoentities($type_fac)));
2980 $text .=
'<br>'.$langs->trans(
'ConfirmConvertToReducSupplier2');
2981 $formconfirm =
$form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id, $langs->trans(
'ConvertToReduc'), $text,
'confirm_converttoreduc',
'',
"yes", 2);
2985 if ($action ==
'clone') {
2987 $formquestion = array(
2988 array(
'type' =>
'text',
'name' =>
'newsupplierref',
'label' => $langs->trans(
"RefSupplierBill"),
'value' => $langs->trans(
"CopyOf").
' '.
$object->ref_supplier),
2989 array(
'type' =>
'date',
'name' =>
'newdate',
'label' => $langs->trans(
"Date"),
'value' =>
dol_now())
2992 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneInvoice',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1, 250);
2996 if ($action ==
'valid') {
2998 if (preg_match(
'/^[\(]?PROV/i',
$object->ref) || empty(
$object->ref)) {
3000 $numref =
$object->getNextNumRef($societe);
3009 $text = $langs->trans(
'ConfirmValidateBill', $numref);
3017 $formquestion = array();
3019 $qualified_for_stock_change = 0;
3021 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3023 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3027 $langs->load(
"stocks");
3028 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3031 $warehouse_array = $warehouse->list_array();
3032 if (count($warehouse_array) == 1) {
3034 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3037 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3039 $formquestion = array(
3040 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3044 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateBill'), $text,
'confirm_valid', $formquestion, 1, 1);
3049 if ($action ==
'edit') {
3050 $formquestion = array();
3052 $qualified_for_stock_change = 0;
3054 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3056 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3059 $langs->load(
"stocks");
3060 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3063 $warehouse_array = $warehouse->list_array();
3064 if (count($warehouse_array) == 1) {
3066 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3069 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3071 $formquestion = array(
3072 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3075 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'UnvalidateBill'), $langs->trans(
'ConfirmUnvalidateBill',
$object->ref),
'confirm_edit', $formquestion, 1, 1);
3079 if ($action ==
'paid' && ($resteapayer <= 0 || (
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') && $resteapayer ==
$object->total_ttc))) {
3080 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidBill',
$object->ref),
'confirm_paid',
'', 0, 1);
3083 if ($action ==
'paid' && $resteapayer > 0 && (!
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') || $resteapayer !=
$object->total_ttc)) {
3087 $close[$i][
'code'] =
'discount_vat';
3089 $close[$i][
'code'] =
'badsupplier';
3091 $close[$i][
'code'] =
'other';
3095 $close[$i][
'label'] = $langs->trans(
"HelpEscompte").
'<br><br>'.$langs->trans(
"ConfirmClassifyPaidPartiallyReasonDiscountVatDesc");
3097 $close[$i][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3099 $close[$i][
'label'] = $langs->trans(
"Other");
3103 $close[$i][
'reason'] =
$form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonDiscount", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3105 $close[$i][
'reason'] =
$form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadCustomer", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3107 $close[$i][
'reason'] =
$form->textwithpicto($langs->transnoentities(
"Other"), $close[$i][
'label'], 1);
3110 $arrayreasons = array();
3111 foreach ($close as $key => $val) {
3112 $arrayreasons[$close[$key][
'code']] = $close[$key][
'reason'];
3116 $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'));
3118 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?facid='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidPartially',
$object->ref),
'confirm_paid_partially', $formquestion,
"yes", 1, 310);
3122 if ($action ==
'canceled') {
3124 $close[1][
'code'] =
'badsupplier';
3125 $close[2][
'code'] =
'abandon';
3127 $close[1][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3128 $close[2][
'label'] = $langs->trans(
"ConfirmClassifyAbandonReasonOtherDesc");
3130 $close[1][
'reason'] =
$form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadSupplier",
$object->ref), $close[1][
'label'], 1);
3131 $close[2][
'reason'] =
$form->textwithpicto($langs->transnoentities(
"ConfirmClassifyAbandonReasonOther"), $close[2][
'label'], 1);
3133 $arrayreasons[$close[1][
'code']] = $close[1][
'reason'];
3134 $arrayreasons[$close[2][
'code']] = $close[2][
'reason'];
3137 $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'));
3139 $formconfirm =
$form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'CancelBill'), $langs->trans(
'ConfirmCancelBill',
$object->ref),
'confirm_canceled', $formquestion,
"yes", 1, 280);
3143 if ($action ==
'delete') {
3144 $formquestion = array();
3146 $qualified_for_stock_change = 0;
3148 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3150 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3154 $langs->load(
"stocks");
3155 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3158 $warehouse_array = $warehouse->list_array();
3160 $selectwarehouse =
'<span class="questionrevertstock hidden">';
3161 if (count($warehouse_array) == 1) {
3163 $selectwarehouse .=
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3166 $selectwarehouse .= $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3168 $selectwarehouse .=
'</span>';
3170 $selectyesno = array(0 => $langs->trans(
'No'), 1 => $langs->trans(
'Yes'));
3172 print
'<script type="text/javascript">
3173 $(document).ready(function() {
3174 $("#revertstock").change(function() {
3175 if(this.value > 0) {
3176 $(".questionrevertstock").removeClass("hidden");
3178 $(".questionrevertstock").addClass("hidden");
3184 $formquestion = array(
3185 array(
'type' =>
'select',
'name' =>
'revertstock',
'label' => $langs->trans(
"RevertProductsToStock"),
'select_show_empty' => 0,
'values' => $selectyesno),
3186 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $selectwarehouse,
'tdclass' =>
'questionrevertstock hidden')
3190 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteBill'), $langs->trans(
'ConfirmDeleteBill'),
'confirm_delete', $formquestion, 1, 1);
3192 if ($action ==
'deletepayment') {
3193 $payment_id =
GETPOST(
'paiement_id');
3194 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&paiement_id='.$payment_id, $langs->trans(
'DeletePayment'), $langs->trans(
'ConfirmDeletePayment'),
'confirm_delete_paiement',
'', 0, 1);
3198 if ($action ==
'ask_deleteline') {
3199 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
3205 if (empty($reshook)) {
3207 } elseif ($reshook > 0) {
3217 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
3219 $morehtmlref =
'<div class="refidno">';
3221 $morehtmlref .=
$form->editfieldkey(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, $usercancreate,
'string',
'', 0, 1);
3222 $morehtmlref .=
$form->editfieldval(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, $usercancreate,
'string',
'',
null,
null,
'', 1);
3224 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1,
'supplier');
3226 $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>';
3230 $langs->load(
"projects");
3231 $morehtmlref .=
'<br>';
3232 if ($permissiontoadd) {
3233 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
3234 if ($action !=
'classify') {
3235 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.((int)
$object->id).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
3237 $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');
3239 if (!empty(
$object->fk_project)) {
3241 $proj->fetch(
$object->fk_project);
3242 $morehtmlref .= $proj->getNomUrl(1);
3244 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
3249 $morehtmlref .=
'</div>';
3251 $object->totalpaid = $totalpaid;
3253 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
3258 $reshook = $hookmanager->executeHooks(
'tabContentViewSupplierInvoice',
$parameters,
$object, $action);
3259 if (empty($reshook)) {
3260 print
'<div class="fichecenter">';
3261 print
'<div class="fichehalfleft">';
3262 print
'<div class="underbanner clearboth"></div>';
3264 print
'<table class="border tableforfield centpercent">';
3267 print
'<tr><td class="titlefield">'.$langs->trans(
'Type').
'</td><td>';
3268 print
'<span class="badgeneutral">';
3272 print
' '.$object->getSubtypeLabel(
'facture_fourn');
3276 $facreplaced->fetch(
$object->fk_facture_source);
3277 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
'</span>';
3280 if (
$object->fk_facture_source > 0) {
3282 $facusing->fetch(
$object->fk_facture_source);
3283 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
'</span>';
3285 $langs->load(
"errors");
3286 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"WarningCorrectedInvoiceNotFound").
'</span>';
3290 $facidavoir =
$object->getListIdAvoirFromInvoice();
3291 if (count($facidavoir) > 0) {
3292 $invoicecredits = array();
3293 foreach ($facidavoir as $id) {
3295 $facavoir->fetch($id);
3296 $invoicecredits[] = $facavoir->getNomUrl(1);
3298 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"InvoiceHasAvoir") . (count($invoicecredits) ?
' ' :
'') . implode(
',', $invoicecredits);
3301 if (isset($objectidnext) && $objectidnext > 0) {
3304 $facthatreplace->fetch($objectidnext);
3305 print
' <span class="opacitymediumbycolor paddingleft">'.str_replace(
'{s1}', $facthatreplace->getNomUrl(1), $langs->transnoentities(
"ReplacedByInvoice",
'{s1}')).
'</span>';
3309 $result = $discount->fetch(0, 0,
$object->id);
3311 print
' <span class="opacitymediumbycolor paddingleft">';
3312 $s = $langs->trans(
"CreditNoteConvertedIntoDiscount",
'{s1}',
'{s2}');
3313 $s = str_replace(
'{s1}',
$object->getLibType(1), $s);
3314 $s = str_replace(
'{s2}', $discount->getNomUrl(1,
'discount'), $s);
3316 print
'</span><br>';
3320 if (
$object->fk_fac_rec_source > 0) {
3322 $result = $tmptemplate->fetch(
$object->fk_fac_rec_source);
3324 print
' <span class="opacitymediumbycolor paddingleft">';
3325 $link =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.$tmptemplate->id.
'">'.
dol_escape_htmltag($tmptemplate->title).
'</a>';
3326 $s = $langs->transnoentities(
"GeneratedFromSupplierTemplate", $link);
3336 print
'<!-- Discounts -->'.
"\n";
3337 print
'<tr><td>'.$langs->trans(
'DiscountStillRemaining');
3340 $thirdparty = $societe;
3342 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
3348 print
'<td>'.$form->editfieldkey(
"Label",
'label',
$object->label,
$object, $usercancreate).
'</td>';
3349 print
'<td>'.$form->editfieldval(
"Label",
'label',
$object->label,
$object, $usercancreate).
'</td>';
3357 print
$form->editfieldkey(
"DateInvoice",
'datef',
$object->date,
$object, $form_permission,
'datepicker');
3358 print
'</td><td colspan="3">';
3359 print
$form->editfieldval(
"Date",
'datef',
$object->date,
$object, $form_permission,
'datepicker');
3363 $langs->load(
'bills');
3364 print
'<tr><td class="nowrap">';
3365 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3366 print $langs->trans(
'PaymentConditions');
3368 if ($action !=
'editconditions' && $form_permission) {
3369 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>';
3371 print
'</tr></table>';
3373 if ($action ==
'editconditions') {
3374 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'cond_reglement_id');
3376 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'none');
3383 print
$form->editfieldkey(
"DateMaxPayment",
'date_lim_reglement',
$object->date_echeance,
$object, $form_permission,
'datepicker');
3385 print
$form->editfieldval(
"DateMaxPayment",
'date_lim_reglement',
$object->date_echeance,
$object, $form_permission,
'datepicker');
3386 if ($action !=
'editdate_lim_reglement' &&
$object->hasDelay()) {
3392 $langs->load(
'bills');
3393 print
'<tr><td class="nowrap">';
3394 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3395 print $langs->trans(
'PaymentMode');
3397 if ($action !=
'editmode' && $form_permission) {
3398 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>';
3400 print
'</tr></table>';
3402 if ($action ==
'editmode') {
3403 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
3405 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'none');
3414 print
'<table class="nobordernopadding" width="100%"><tr><td>';
3415 print
$form->editfieldkey(
'Currency',
'multicurrency_code',
'',
$object, 0);
3417 if ($action !=
'editmulticurrencycode' &&
$object->status == $object::STATUS_DRAFT) {
3418 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>';
3420 print
'</tr></table>';
3422 if ($action ==
'editmulticurrencycode') {
3423 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_code,
'multicurrency_code');
3425 $form->form_multicurrency_code($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_code,
'none');
3430 if (
$object->multicurrency_code != $conf->currency ||
$object->multicurrency_tx != 1) {
3433 print
'<table class="nobordernopadding centpercent"><tr><td>';
3434 print
$form->editfieldkey(
'CurrencyRate',
'multicurrency_tx',
'',
$object, 0);
3436 if ($action !=
'editmulticurrencyrate' &&
$object->status == $object::STATUS_DRAFT &&
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency) {
3437 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>';
3439 print
'</tr></table>';
3441 if ($action ==
'editmulticurrencyrate' || $action ==
'actualizemulticurrencyrate') {
3442 if ($action ==
'actualizemulticurrencyrate') {
3445 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_tx,
'multicurrency_tx',
$object->multicurrency_code);
3447 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->multicurrency_tx,
'none',
$object->multicurrency_code);
3448 if (
$object->status == $object::STATUS_DRAFT &&
$object->multicurrency_code &&
$object->multicurrency_code != $conf->currency) {
3449 print
'<div class="inline-block"> ';
3450 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=actualizemulticurrencyrate">'.$langs->trans(
"ActualizeCurrency").
'</a>';
3460 print
'<tr><td class="nowrap">';
3461 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3462 print $langs->trans(
'BankAccount');
3464 if ($action !=
'editbankaccount' && $usercancreate) {
3465 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>';
3467 print
'</tr></table>';
3469 if ($action ==
'editbankaccount') {
3470 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'fk_account', 1);
3472 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
3480 print
'<tr><td class="nowrap">';
3481 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3482 print $langs->trans(
'VATReverseCharge');
3484 if ($action !=
'editvatreversecharge' && $usercancreate) {
3485 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editvatreversecharge&id='.
$object->id.
'">'.
img_edit($langs->trans(
'SetVATReverseCharge'), 1).
'</a></td>';
3487 print
'</tr></table>';
3489 if ($action ==
'editvatreversecharge') {
3490 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
3491 print
'<input type="hidden" name="action" value="setvatreversecharge">';
3492 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3494 print
'<input type="checkbox" name="vat_reverse_charge"' . (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
'>';
3496 print
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
3499 print
'<input type="checkbox" name="vat_reverse_charge"'. (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
' disabled>';
3507 print
'<table width="100%" class="nobordernopadding"><tr><td>';
3508 print $langs->trans(
'IncotermLabel');
3509 print
'<td><td class="right">';
3510 if ($usercancreate) {
3511 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.
$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit().
'</a>';
3515 print
'</td></tr></table>';
3518 if ($action !=
'editincoterm') {
3521 print
$form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
3528 $langs->loadLangs(array(
"intracommreport"));
3529 print
'<!-- If module intracomm on -->'.
"\n";
3531 print
'<table class="nobordernopadding centpercent"><tr><td>';
3532 print $langs->trans(
'IntracommReportTransportMode');
3534 if ($action !=
'edittransportmode' && ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"))) {
3535 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edittransportmode&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit().
'</a></td>';
3537 print
'</tr></table>';
3540 if ($action ==
'edittransportmode') {
3541 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->transport_mode_id,
'transport_mode_id', 1, 1);
3543 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->transport_mode_id,
'none');
3550 if (
$object->status != $object::STATUS_DRAFT) {
3554 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3559 print
'<div class="fichehalfright">';
3560 print
'<div class="underbanner clearboth"></div>';
3562 print
'<table class="border tableforfield centpercent">';
3565 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
3566 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3568 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3573 print
'<td>' . $langs->trans(
'AmountVAT') .
'</td>';
3574 print
'<td class="nowrap amountcard right">';
3575 if (
GETPOST(
'calculationrule')) {
3576 $calculationrule =
GETPOST(
'calculationrule',
'alpha');
3578 $calculationrule = (!
getDolGlobalString(
'MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND') ?
'totalofround' :
'roundoftotal');
3580 if ($calculationrule ==
'totalofround') {
3581 $calculationrulenum = 1;
3583 $calculationrulenum = 2;
3586 if (
$object->getVentilExportCompta() == 0) {
3587 $s =
'<span class="hideonsmartphone opacitymedium">' . $langs->trans(
"ReCalculate") .
' </span>';
3588 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&calculationrule=totalofround">' . $langs->trans(
"Mode1") .
'</a>';
3590 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&calculationrule=roundoftotal">' . $langs->trans(
"Mode2") .
'</a>';
3591 print
'<div class="inline-block">';
3592 print
$form->textwithtooltip($s, $langs->trans(
"CalculationRuleDesc", $calculationrulenum) .
'<br>' . $langs->trans(
"CalculationRuleDescSupplier"), 2, 1,
img_picto(
'',
'help'),
'', 3,
'', 0,
'recalculate');
3593 print
' ';
3596 print
price(
$object->total_tva, 1, $langs, 0, -1, -1, $conf->currency);
3599 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3603 if ($societe->localtax1_assuj ==
"1") {
3605 print
'<td>' . $langs->transcountry(
"AmountLT1", $societe->country_code) .
'</td>';
3606 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 1, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3609 if ($societe->localtax2_assuj ==
"1") {
3611 print
'<td>' . $langs->transcountry(
"AmountLT2", $societe->country_code) .
'</td>';
3612 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 1, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3617 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
3618 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ttc, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3620 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3653 if ($societe->localtax1_assuj ==
"1") {
3656 if ($societe->localtax2_assuj ==
"1") {
3660 $sql =
'SELECT p.datep as dp, p.ref, p.num_paiement as num_payment, p.rowid, p.fk_bank,';
3661 $sql .=
' c.id as payment_type, c.code as payment_code,';
3662 $sql .=
' pf.amount,';
3663 $sql .=
' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal';
3664 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn as p';
3665 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
3666 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
3667 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id';
3668 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid';
3669 $sql .=
' WHERE pf.fk_facturefourn = '.((int)
$object->id);
3670 $sql .=
' ORDER BY p.datep, p.tms';
3672 $result = $db->query(
$sql);
3674 $num = $db->num_rows($result);
3677 print
'<div class="div-table-responsive-no-min">';
3678 print
'<table class="noborder paymenttable centpercent">';
3679 print
'<tr class="liste_titre">';
3681 print
'<td>'.$langs->trans(
'Date').
'</td>';
3682 print
'<td>'.$langs->trans(
'Type').
'</td>';
3684 print
'<td class="right">'.$langs->trans(
'BankAccount').
'</td>';
3686 print
'<td class="right">'.$langs->trans(
'Amount').
'</td>';
3687 print
'<td width="18"> </td>';
3692 $objp = $db->fetch_object($result);
3694 $paymentstatic->id = $objp->rowid;
3695 $paymentstatic->datepaye = $db->jdate($objp->dp);
3696 $paymentstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
3697 $paymentstatic->num_payment = $objp->num_payment;
3699 $paymentstatic->paiementcode = $objp->payment_code;
3700 $paymentstatic->type_code = $objp->payment_code;
3701 $paymentstatic->type_label = $objp->payment_type;
3703 print
'<tr class="oddeven">';
3704 print
'<td class="nowraponall">';
3705 print $paymentstatic->getNomUrl(1);
3707 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
'</td>';
3708 $s =
$form->form_modes_reglement(
'', $objp->payment_type,
'none',
'', 1, 0,
'', 1).
' '.$objp->num_payment;
3709 print
'<td class="tdoverflowmax125" title="'.dol_escape_htmltag($s).
'">';
3713 $bankaccountstatic->id = $objp->baid;
3714 $bankaccountstatic->ref = $objp->baref;
3715 $bankaccountstatic->label = $objp->baref;
3716 $bankaccountstatic->number = $objp->banumber;
3719 $bankaccountstatic->account_number = $objp->account_number;
3722 $accountingjournal->fetch($objp->fk_accountancy_journal);
3723 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
3726 print
'<td class="right">';
3727 if ($objp->baid > 0) {
3728 print $bankaccountstatic->getNomUrl(1,
'transactions');
3732 print
'<td class="right">'.price($sign * $objp->amount).
'</td>';
3733 print
'<td class="center">';
3735 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deletepayment&token='.
newToken().
'&paiement_id='.$objp->rowid.
'">';
3741 $totalpaid += $objp->amount;
3745 print
'<tr class="oddeven"><td colspan="'.$nbcols.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td><td></td><td></td></tr>';
3768 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3769 print
'<span class="opacitymedium">';
3771 print $langs->trans(
'AlreadyPaidNoCreditNotesNoDeposits');
3773 print $langs->trans(
'AlreadyPaid');
3776 print
'</td><td class="right"'.(($totalpaid > 0) ?
' class="amountalreadypaid"' :
'').
'>'.
price($totalpaid).
'</td><td> </td></tr>';
3779 $resteapayeraffiche = $resteapayer;
3781 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
3784 $creditnoteamount = 0;
3787 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
3788 $sql .=
" re.description, re.fk_invoice_supplier_source";
3789 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
3790 $sql .=
" WHERE fk_invoice_supplier = ".((int)
$object->id);
3791 $resql = $db->query(
$sql);
3793 $num = $db->num_rows($resql);
3797 $obj = $db->fetch_object($resql);
3798 $invoice->fetch($obj->fk_invoice_supplier_source);
3799 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3801 print $langs->trans(
"CreditNote").
' ';
3804 print $langs->trans(
"Deposit").
' ';
3806 print $invoice->getNomUrl(0);
3808 print
'<td class="right">'.price($obj->amount_ttc).
'</td>';
3809 print
'<td class="right">';
3810 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=unlinkdiscount&discountid='.$obj->rowid.
'">';
3811 print
img_picto($langs->transnoentitiesnoconv(
"RemoveDiscount"),
'unlink');
3816 $creditnoteamount += $obj->amount_ttc;
3819 $depositamount += $obj->amount_ttc;
3828 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3829 print
'<span class="opacitymedium">';
3830 print
$form->textwithpicto($langs->trans(
"Discount"), $langs->trans(
"HelpEscompte"), - 1);
3832 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3833 $resteapayeraffiche = 0;
3834 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3838 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3839 print
'<span class="opacitymedium">';
3840 print
$form->textwithpicto($langs->trans(
"Abandoned"), $langs->trans(
"HelpAbandonBadCustomer"), - 1);
3842 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3844 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3848 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3849 print
'<span class="opacitymedium">';
3850 print
$form->textwithpicto($langs->trans(
"ProductReturned"), $langs->trans(
"HelpAbandonProductReturned"), - 1);
3852 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3853 $resteapayeraffiche = 0;
3854 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3858 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3859 $text = $langs->trans(
"HelpAbandonOther");
3861 $text .=
'<br><br><b>'.$langs->trans(
"Reason").
'</b>:'.
$object->close_note;
3863 print
'<span class="opacitymedium">';
3865 print
$form->textwithpicto($langs->trans(
"Abandoned"), $text, - 1);
3867 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3868 $resteapayeraffiche = 0;
3869 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3873 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3874 print
'<span class="opacitymedium">';
3875 print $langs->trans(
"Billed");
3877 print
'</td><td class="right">'.price(
$object->total_ttc).
'</td><td> </td></tr>';
3880 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3881 print
'<span class="opacitymedium">';
3882 print $langs->trans(
'RemainderToPay');
3883 if ($resteapayeraffiche < 0) {
3884 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
3888 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayeraffiche).
'</td><td> </td></tr>';
3892 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3893 print
'<span class="opacitymedium">';
3894 print $langs->trans(
'RemainderToPayMulticurrency');
3895 if ($resteapayeraffiche < 0) {
3896 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
3900 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>';
3903 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3906 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3907 print $langs->trans(
'AlreadyPaidBack');
3908 print
' :</td><td class="right">'.price($sign * $totalpaid).
'</td><td> </td></tr>';
3911 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"Billed").
' :</td><td class="right">'.
price($sign *
$object->total_ttc).
'</td><td> </td></tr>';
3914 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3915 print
'<span class="opacitymedium">';
3916 print $langs->trans(
'RemainderToPayBack');
3917 if ($resteapayeraffiche > 0) {
3918 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
3922 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($sign * $resteapayeraffiche).
'</td><td> </td></tr>';
3926 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3927 print
'<span class="opacitymedium">';
3928 print $langs->trans(
'RemainderToPayBackMulticurrency');
3929 if ($resteapayeraffiche > 0) {
3930 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
3934 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>';
3949 print
'<div class="clearboth"></div><br>';
3952 $blocname =
'contacts';
3953 $title = $langs->trans(
'ContactsAddresses');
3954 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
3959 $blocname =
'notes';
3960 $title = $langs->trans(
'Notes');
3961 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
3968 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
3969 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3970 print
'<input type="hidden" name="action" value="'.(($action !=
'editline') ?
'addline' :
'updateline').
'">';
3971 print
'<input type="hidden" name="mode" value="">';
3972 print
'<input type="hidden" name="page_y" value="">';
3973 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
3974 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
3975 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
3978 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
3981 print
'<div class="div-table-responsive-no-min">';
3982 print
'<table id="tablelines" class="noborder noshadow centpercent">';
3984 global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax;
3987 $inputalsopricewithtax = 1;
3988 $senderissupplier = 2;
3991 $senderissupplier = 1;
3996 $object->printObjectLines($action, $societe, $mysoc, $lineid, 1);
4003 if ($action !=
'editline') {
4007 $reshook = $hookmanager->executeHooks(
'formAddObjectLine',
$parameters,
$object, $action);
4011 if (empty($reshook)) {
4012 $object->formAddObjectLine(1, $societe, $mysoc);
4025 if ($action !=
'presend') {
4030 print
'<div class="tabsAction">';
4033 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters,
$object, $action);
4035 if (empty($reshook)) {
4039 $ventilExportCompta =
$object->getVentilExportCompta();
4041 if ($ventilExportCompta == 0) {
4042 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
'Modify').
'</a>';
4044 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseDispatchedInBookkeeping").
'">'.$langs->trans(
'Modify').
'</span>';
4049 $result = $discount->fetch(0, 0,
$object->id);
4056 if (!$objectidnext &&
$object->close_code !=
'replaced' && $usercancreate) {
4057 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=reopen&token='.
newToken().
'">'.$langs->trans(
'ReOpen').
'</a>';
4059 if ($usercancreate) {
4060 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseReplacedInvoice").
'">'.$langs->trans(
'ReOpen').
'</span>';
4062 print
'<span class="butActionRefused classfortooltip">'.$langs->trans(
'ReOpen').
'</span>';
4070 if ($usercanvalidate) {
4071 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=valid"';
4072 print
'>'.$langs->trans(
'Validate').
'</a>';
4074 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'"';
4075 print
'>'.$langs->trans(
'Validate').
'</a>';
4081 if (empty($user->socid)) {
4084 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a>';
4086 print
'<span class="butActionRefused classfortooltip">'.$langs->trans(
'SendMail').
'</span>';
4093 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>';
4100 if ($resteapayer == 0) {
4101 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseRemainderToPayIsZero").
'">'.$langs->trans(
'DoPaymentBack').
'</span>';
4103 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>';
4109 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc">'.$langs->trans(
'ConvertExcessPaidToReduc').
'</a>';
4113 && (
getDolGlobalString(
'SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED') ||
$object->getSommePaiement() == 0)
4115 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc" title="'.
dol_escape_htmltag($langs->trans(
"ConfirmConvertToReducSupplier2")).
'">'.$langs->trans(
'ConvertToReduc').
'</a>';
4119 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc">'.$langs->trans(
'ConvertToReduc').
'</a>';
4130 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=paid">'.$langs->trans(
'ClassifyPaid').
'</a>';
4135 if ($totalpaid > 0 || $totalcreditnotes > 0) {
4137 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=paid">'.$langs->trans(
'ClassifyPaidPartially').
'</a>';
4140 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=canceled">'.$langs->trans(
'ClassifyCanceled').
'</a>';
4153 if (!$objectidnext) {
4154 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>';
4159 if ($action !=
'edit' && $usercancreate) {
4160 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=clone&socid='.
$object->socid.
'">'.$langs->trans(
'ToClone').
'</a>';
4165 if (!$objectidnext && count(
$object->lines) > 0) {
4166 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.
$object->id.
'&action=create">'.$langs->trans(
"ChangeIntoRepeatableInvoice").
'</a>';
4171 $isErasable =
$object->is_erasable();
4172 if ($action !=
'confirm_edit' && ($usercandelete || ($usercancreate && $isErasable == 1))) {
4173 $enableDelete =
false;
4175 $params = (empty($conf->use_javascript_ajax) ? array() : array(
'attr' => array(
'class' =>
'reposition')));
4177 if ($isErasable == -4) {
4178 $htmltooltip = $langs->trans(
"DisabledBecausePayments");
4179 } elseif ($isErasable == -3) {
4180 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastSituationInvoice");
4181 } elseif ($isErasable == -2) {
4182 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastInvoice");
4183 } elseif ($isErasable == -1) {
4184 $htmltooltip = $langs->trans(
"DisabledBecauseDispatchedInBookkeeping");
4185 } elseif ($isErasable <= 0) {
4186 $htmltooltip = $langs->trans(
"DisabledBecauseNotErasable");
4188 $enableDelete =
true;
4195 if ($action !=
'confirm_edit') {
4196 print
'<div class="fichecenter"><div class="fichehalfleft">';
4203 $filedir = $conf->fournisseur->facture->dir_output.
'/'.$subdir;
4204 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.
$object->id;
4205 $genallowed = $usercanread;
4206 $delallowed = $usercancreate;
4207 $modelpdf = (!empty(
$object->model_pdf) ?
$object->model_pdf : (!
getDolGlobalString(
'INVOICE_SUPPLIER_ADDON_PDF') ?
'' : $conf->global->INVOICE_SUPPLIER_ADDON_PDF));
4209 print $formfile->showdocuments(
'facture_fournisseur', $subdir, $filedir, $urlsource, $genallowed, $delallowed, $modelpdf, 1, 0, 0, 40, 0,
'',
'',
'', $societe->default_lang);
4210 $somethingshown = $formfile->numoffiles;
4213 $linktoelem =
$form->showLinkToObjectBlock(
$object, array(), array(
'invoice_supplier'));
4214 $somethingshown =
$form->showLinkedObjectBlock(
$object, $linktoelem);
4216 print
'</div><div class="fichehalfright">';
4219 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
4221 $somethingshown =
$formactions->showactions(
$object,
'invoice_supplier', $socid, 1,
'listaction'.($genallowed ?
'largetitle' :
''));
4223 print
'</div></div>';
4229 if (
GETPOST(
'modelselected')) {
4230 $action =
'presend';
4234 $modelmail =
'invoice_supplier_send';
4235 $defaulttopic =
'SendBillRef';
4236 $diroutput = $conf->fournisseur->facture->dir_output;
4237 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
4238 $trackid =
'sinv'.$object->id;
4240 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
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)
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
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.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information in HTML for admin users or standard users.
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...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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...
$formconfirm
if ($action == 'delbookkeepingyear') {
div float
Buy price without taxes.
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.