40require
'../../main.inc.php';
49require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
53require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture-rec.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
57require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
58require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
59require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
60require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
62 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
63 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
66 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
67 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
71 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
74 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
77$langs->loadLangs(array(
'bills',
'compta',
'suppliers',
'companies',
'products',
'banks',
'admin'));
79 $langs->load(
'incoterm');
84$action =
GETPOST(
'action',
'aZ09');
87$cancel =
GETPOST(
'cancel',
'alpha');
88$backtopage =
GETPOST(
'backtopage',
'alpha');
89$backtopageforcancel =
'';
93$origin =
GETPOST(
'origin',
'alpha');
106$hookmanager->initHooks(array(
'invoicesuppliercard',
'globalcard'));
112$extrafields->fetch_name_optionals_label(
$object->table_element);
115if ($id > 0 || !empty($ref)) {
116 $ret =
$object->fetch($id, $ref);
123 $ret =
$object->fetch_thirdparty();
131if (!empty($user->socid)) {
132 $socid = $user->socid;
136$result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture',
'fk_soc',
'rowid', $isdraft);
139$usercanread = ($user->hasRight(
"fournisseur",
"facture",
"lire") || $user->hasRight(
"supplier_invoice",
"lire"));
140$usercancreate = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
141$usercandelete = (($user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"supprimer")) || ($usercancreate &&
$object->is_erasable() == 1));
142$usercancreatecontract = $user->hasRight(
"contrat",
"creer");
145$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"validate")));
146$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"send"));
147$usercancreatecreditransfer = $user->hasRight(
'paymentbybanktransfer',
'create');
150$permissionnote = $usercancreate;
151$permissiondellink = $usercancreate;
152$permissiontoedit = $usercancreate;
153$permissiontoadd = $usercancreate;
154$permissiontodelete = $usercandelete;
155$permissiontoeditextra = $permissiontoadd;
156if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
158 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
168$parameters = array(
'socid' => $socid);
169$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
174if (empty($reshook)) {
175 $backurlforlist = DOL_URL_ROOT.
'/fourn/facture/list.php';
177 if (empty($backtopage) || ($cancel && empty($id))) {
178 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
179 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
180 $backtopage = $backurlforlist;
182 $backtopage = DOL_URL_ROOT.
'/fourn/facture/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
188 if (!empty($backtopageforcancel)) {
189 header(
"Location: ".$backtopageforcancel);
191 } elseif (!empty($backtopage)) {
192 header(
"Location: ".$backtopage);
198 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
200 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
202 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
205 if (
GETPOST(
'linkedOrder') && empty($cancel) && $id > 0 && $permissiontoadd) {
208 $result =
$object->add_object_linked(
'order_supplier',
GETPOSTINT(
'linkedOrder'));
212 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
214 '@phan-var-force FactureFournisseur $objectutil';
216 if (
GETPOST(
'newsupplierref',
'alphanohtml')) {
217 $objectutil->ref_supplier =
GETPOST(
'newsupplierref',
'alphanohtml');
221 $result = $objectutil->createFromClone($user, $id);
223 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
226 $langs->load(
"errors");
230 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' && $usercanvalidate) {
231 $idwarehouse =
GETPOST(
'idwarehouse');
236 $qualified_for_stock_change = 0;
238 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
240 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
245 $langs->load(
"stocks");
246 if (!$idwarehouse || $idwarehouse == -1) {
248 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
256 $result =
$object->validate($user,
'', $idwarehouse);
266 $outputlangs = $langs;
269 $newlang =
GETPOST(
'lang_id',
'aZ09');
272 $newlang =
$object->thirdparty->default_lang;
274 if (!empty($newlang)) {
276 $outputlangs->setDefaultLang($newlang);
281 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
288 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontodelete) {
292 $isErasable =
$object->is_erasable();
294 if ($usercandelete && $isErasable > 0) {
295 $revertstock =
GETPOST(
'revertstock');
300 $qualified_for_stock_change = 0;
302 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
304 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
309 $langs->load(
"stocks");
310 if (!$idwarehouse || $idwarehouse == -1) {
312 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
315 $result =
$object->setDraft($user, $idwarehouse);
324 $result =
$object->delete($user);
326 header(
'Location: list.php?restore_lastsearch_values=1');
333 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
335 $result =
$object->deleteLine($lineid);
355 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
362 } elseif ($action ==
'unlinkdiscount' && $usercancreate) {
365 $result = $discount->fetch(
GETPOSTINT(
"discountid"));
366 if ($result > 0 &&
$object->id > 0 && $discount->fk_invoice_supplier ==
$object->id) {
367 $discount->unlink_invoice();
371 } elseif ($action ==
'confirm_paid' && $confirm ==
'yes' && $usercancreate) {
373 $result =
$object->setPaid($user);
377 } elseif ($action ==
'confirm_paid_partially' && $confirm ==
'yes' && $usercancreate) {
380 $close_code =
GETPOST(
"close_code",
'restricthtml');
381 $close_note =
GETPOST(
"close_note",
'restricthtml');
383 $result =
$object->setPaid($user, $close_code, $close_note);
388 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Reason")),
null,
'errors');
390 } elseif ($action ==
'confirm_canceled' && $confirm ==
'yes' && $usercancreate) {
393 $close_code =
GETPOST(
"close_code",
'restricthtml');
394 $close_note =
GETPOST(
"close_note",
'restricthtml');
396 $result =
$object->setCanceled($user, $close_code, $close_note);
401 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Reason")),
null,
'errors');
406 if ($action ==
'setref_supplier' && $usercancreate) {
409 if (
$object->update($user) < 0) {
413 $outputlangs = $langs;
416 $newlang =
GETPOST(
'lang_id',
'aZ09');
419 $newlang =
$object->thirdparty->default_lang;
421 if (!empty($newlang)) {
423 $outputlangs->setDefaultLang($newlang);
427 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
433 if ($action ==
'setconditions' && $usercancreate) {
435 $object->cond_reglement_code = 0;
436 $object->cond_reglement_id = 0;
451 $new_date_echeance =
$object->calculate_date_lim_reglement();
452 if ($new_date_echeance) {
453 $object->date_echeance = $new_date_echeance;
458 $result =
$object->update($user);
470 } elseif ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm') && $usercancreate) {
473 } elseif ($action ==
'settags' &&
isModEnabled(
'category') && $usercancreate) {
476 } elseif ($action ==
'setmode' && $usercancreate) {
479 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
481 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
482 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
485 } elseif ($action ==
'setbankaccount' && $usercancreate) {
488 } elseif ($action ==
'setvatreversecharge' && $usercancreate) {
490 $vatreversecharge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
491 $result =
$object->setVATReverseCharge($vatreversecharge);
494 if ($action ==
'settransportmode' && $usercancreate) {
497 } elseif ($action ==
'setlabel' && $usercancreate) {
501 $result =
$object->update($user);
505 } elseif ($action ==
'setdatef' && $usercancreate) {
509 setEventMessages($langs->trans(
"WarningInvoiceDateInFuture"),
null,
'warnings');
511 setEventMessages($langs->trans(
"WarningInvoiceDateTooFarInFuture"),
null,
'warnings');
518 $date_echence_calc =
$object->calculate_date_lim_reglement();
519 if (!empty(
$object->date_echeance)) {
520 $object->date_echeance = $date_echence_calc;
526 $result =
$object->update($user);
530 } elseif ($action ==
'setdate_pointoftax' && $usercancreate) {
534 $object->date_pointoftax = $date_pointoftax;
536 $result =
$object->update($user);
539 $action =
'editdate_pointoftax';
541 } elseif ($action ==
'setdate_lim_reglement' && $usercancreate) {
546 setEventMessages($langs->trans(
"DatePaymentTermCantBeLowerThanObjectDate"),
null,
'warnings');
548 $result =
$object->update($user);
552 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
568 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
570 $discount->fetch(
GETPOSTINT(
"remise_id_for_payment"));
574 $remaintopay =
$object->getRemainToPay(0);
578 setEventMessages($langs->trans(
"ErrorDiscountLargerThanRemainToPaySplitItBefore"),
null,
'errors');
582 $result = $discount->link_to_invoice(0, $id);
589 $newremaintopay =
$object->getRemainToPay(0);
590 if ($newremaintopay == 0) {
601 $outputlangs = $langs;
604 $newlang =
GETPOST(
'lang_id',
'aZ09');
607 $newlang =
$object->thirdparty->default_lang;
609 if (!empty($newlang)) {
611 $outputlangs->setDefaultLang($newlang);
615 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
620 } elseif ($action ==
'confirm_converttoreduc' && $confirm ==
'yes' && $usercancreate) {
628 $result = $discountcheck->fetch(0, 0,
$object->id);
640 $amount_ht = $amount_tva = $amount_ttc = array();
641 $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array();
645 foreach (
$object->lines as $line) {
646 if ($line->product_type < 9 && $line->total_ht != 0) {
647 $keyforvatrate = $line->tva_tx.($line->vat_src_code ?
' ('.$line->vat_src_code.
')' :
'');
649 $amount_ht[$keyforvatrate] += $line->total_ht;
650 $amount_tva[$keyforvatrate] += $line->total_tva;
651 $amount_ttc[$keyforvatrate] += $line->total_ttc;
652 $multicurrency_amount_ht[$keyforvatrate] += $line->multicurrency_total_ht;
653 $multicurrency_amount_tva[$keyforvatrate] += $line->multicurrency_total_tva;
654 $multicurrency_amount_ttc[$keyforvatrate] += $line->multicurrency_total_ttc;
658 '@phan-var-force array<string,float> $amount_ht
659 @phan-var-force array<string,float> $amount_tva
660 @phan-var-force array<string,float> $amount_ttc
661 @phan-var-force array<string,float> $multicurrency_amount_ht
662 @phan-var-force array<string,float> $multicurrency_amount_tva
663 @phan-var-force array<string,float> $multicurrency_amount_ttc';
667 $alreadypaid =
$object->getSommePaiement();
668 if ($alreadypaid && abs($alreadypaid) < abs(
$object->total_ttc)) {
669 $ratio = abs((
$object->total_ttc - $alreadypaid) /
$object->total_ttc);
670 foreach ($amount_ht as $vatrate => $val) {
671 $amount_ht[$vatrate] =
price2num($amount_ht[$vatrate] * $ratio,
'MU');
672 $amount_tva[$vatrate] =
price2num($amount_tva[$vatrate] * $ratio,
'MU');
673 $amount_ttc[$vatrate] =
price2num($amount_ttc[$vatrate] * $ratio,
'MU');
674 $multicurrency_amount_ht[$vatrate] =
price2num($multicurrency_amount_ht[$vatrate] * $ratio,
'MU');
675 $multicurrency_amount_tva[$vatrate] =
price2num($multicurrency_amount_tva[$vatrate] * $ratio,
'MU');
676 $multicurrency_amount_ttc[$vatrate] =
price2num($multicurrency_amount_ttc[$vatrate] * $ratio,
'MU');
685 $discount->description =
'(CREDIT_NOTE)';
687 $discount->description =
'(DEPOSIT)';
689 $discount->description =
'(EXCESS PAID)';
691 setEventMessages($langs->trans(
'CantConvertToReducAnInvoiceOfThisType'),
null,
'errors');
693 $discount->discount_type = 1;
694 $discount->fk_soc =
$object->socid;
695 $discount->socid =
$object->socid;
696 $discount->fk_invoice_supplier_source =
$object->id;
704 $sql =
'SELECT SUM(pf.amount) as total_paiements';
705 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.
'paiementfourn as p';
706 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN ('.
getEntity(
'c_paiement').
')';
707 $sql .=
' WHERE pf.fk_facturefourn = '.((int)
$object->id);
708 $sql .=
' AND pf.fk_paiementfourn = p.rowid';
709 $sql .=
' AND p.entity IN ('.getEntity(
'invoice').
')';
711 $resql = $db->query($sql);
716 $res = $db->fetch_object($resql);
717 $total_paiements = $res->total_paiements;
720 $total_creditnote_and_deposit = 0;
721 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
722 $sql .=
" re.description, re.fk_invoice_supplier_source";
723 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
724 $sql .=
" WHERE fk_invoice_supplier = ".((int)
$object->id);
725 $resql = $db->query($sql);
726 if (!empty($resql)) {
727 while ($obj = $db->fetch_object($resql)) {
728 $total_creditnote_and_deposit += $obj->amount_ttc;
734 $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit -
$object->total_ttc;
735 $discount->amount_tva = 0;
736 $discount->tva_tx = 0;
737 $discount->vat_src_code =
'';
740 $discount->multicurrency_code =
$object->multicurrency_code;
741 $discount->multicurrency_tx =
$object->multicurrency_tx;
742 $discount->multicurrency_total_ht = $discount->multicurrency_total_ttc = (float)
price2num((
float) $discount->amount_ttc * (float)
$object->multicurrency_tx,
'MT');
743 $discount->multicurrency_total_tva = 0;
745 $discount->multicurrency_amount_ht = $discount->multicurrency_amount_ttc = $discount->multicurrency_total_ttc;
746 $discount->multicurrency_amount_tva = 0;
748 $result = $discount->create($user);
754 foreach ($amount_ht as $tva_tx => $xxx) {
756 $discount->multicurrency_code =
$object->multicurrency_code;
757 $discount->multicurrency_tx =
$object->multicurrency_tx;
760 $discount->amount_ht = -((float) $amount_ht[$tva_tx]);
761 $discount->amount_tva = -((float) $amount_tva[$tva_tx]);
762 $discount->amount_ttc = -((float) $amount_ttc[$tva_tx]);
763 $discount->multicurrency_total_ht = -((float) $multicurrency_amount_ht[$tva_tx]);
764 $discount->multicurrency_total_tva = -((float) $multicurrency_amount_tva[$tva_tx]);
765 $discount->multicurrency_total_ttc = -((float) $multicurrency_amount_ttc[$tva_tx]);
767 $discount->amount_ht = abs((
float) $amount_ht[$tva_tx]);
768 $discount->amount_tva = abs((
float) $amount_tva[$tva_tx]);
769 $discount->amount_ttc = abs((
float) $amount_ttc[$tva_tx]);
770 $discount->multicurrency_total_ht = abs((
float) $multicurrency_amount_ht[$tva_tx]);
771 $discount->multicurrency_total_tva = abs((
float) $multicurrency_amount_tva[$tva_tx]);
772 $discount->multicurrency_total_ttc = abs((
float) $multicurrency_amount_ttc[$tva_tx]);
775 $discount->multicurrency_amount_ht = $discount->multicurrency_total_ht;
776 $discount->multicurrency_amount_tva = $discount->multicurrency_total_tva;
777 $discount->multicurrency_amount_ttc = $discount->multicurrency_total_ttc;
782 if (preg_match(
'/\((.*)\)/', $tva_tx, $reg)) {
783 $vat_src_code = $reg[1];
784 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx);
787 $discount->tva_tx = abs((
float) $tva_tx);
788 $discount->vat_src_code = $vat_src_code;
790 $result = $discount->create($user);
801 $result =
$object->setPaid($user);
816 } elseif ($action ==
'confirm_delete_paiement' && $confirm ==
'yes' && $usercancreate) {
821 $result = $paiementfourn->fetch(
GETPOSTINT(
'paiement_id'));
823 $result = $paiementfourn->delete($user);
825 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
833 } elseif ($action ==
'add' && $usercancreate) {
838 $selectedLines =
GETPOST(
'toselect',
'array:int');
846 $ret = $extrafields->setOptionalsFromPost(
null, $object);
860 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
865 if (empty($dateinvoice)) {
866 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
878 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ReplaceInvoice")),
null,
'errors');
894 $object->date_pointoftax = $date_pointoftax;
895 $object->date_echeance = $datedue;
901 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
902 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
904 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
905 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
926 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CorrectInvoice")),
null,
'errors');
929 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Supplier')),
null,
'errors');
934 if (empty($dateinvoice)) {
935 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
945 if (!
GETPOST(
'ref_supplier')) {
946 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'RefSupplierBill')),
null,
'errors');
954 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
969 $object->date_pointoftax = $date_pointoftax;
970 $object->date_echeance = $datedue;
976 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
977 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
979 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
980 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
985 $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice :
'';
994 if (
GETPOSTINT(
'invoiceAvoirWithLines') == 1 && $id > 0) {
996 if ($facture_source->fetch(
$object->fk_facture_source) > 0) {
999 foreach ($facture_source->lines as $line) {
1001 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
1002 $fk_parent_line = 0;
1005 $line->fk_facture_fourn =
$object->id;
1006 $line->fk_parent_line = $fk_parent_line;
1008 $line->subprice = -$line->subprice;
1009 $line->pa_ht = -((float) $line->pa_ht);
1010 $line->total_ht = -$line->total_ht;
1011 $line->total_tva = -$line->total_tva;
1012 $line->total_ttc = -$line->total_ttc;
1013 $line->total_localtax1 = -$line->total_localtax1;
1014 $line->total_localtax2 = -$line->total_localtax2;
1016 $result = $line->insert();
1021 if ($result > 0 && $line->product_type == 9) {
1022 $fk_parent_line = $result;
1030 if (
GETPOSTINT(
'invoiceAvoirWithPaymentRestAmount') == 1 &&
$id > 0) {
1032 if ($facture_source->fetch(
$object->fk_facture_source) > 0) {
1033 $totalpaid = $facture_source->getSommePaiement();
1034 $totalcreditnotes = $facture_source->getSumCreditNotesUsed();
1035 $totaldeposits = $facture_source->getSumDepositsUsed();
1036 $remain_to_pay = abs($facture_source->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits);
1037 $desc = $langs->trans(
'invoiceAvoirLineWithPaymentRestAmount');
1041 $retAddLine =
$object->addline($desc, -$remain_to_pay, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
'TTC');
1043 if ($retAddLine < 0) {
1051 if (empty($dateinvoice)) {
1053 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
1063 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
1073 $object->date_pointoftax = $date_pointoftax;
1074 $object->note_public = trim(
GETPOST(
'note_public',
'restricthtml'));
1075 $object->note_private = trim(
GETPOST(
'note_private',
'restricthtml'));
1086 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
1087 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
1091 $object->fac_rec = $fac_recid;
1093 $fac_rec->fetch(
$object->fac_rec);
1094 $fac_rec->fetch_lines();
1095 $object->lines = $fac_rec->lines;
1102 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Supplier')),
null,
'errors');
1107 if (empty($dateinvoice)) {
1108 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
1118 if (!
GETPOST(
'ref_supplier')) {
1119 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'RefSupplierBill')),
null,
'errors');
1127 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
1144 $object->date_pointoftax = $date_pointoftax;
1145 $object->date_echeance = $datedue;
1151 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
1152 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
1154 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
1155 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
1160 if (empty(
$object->date_echeance)) {
1161 $object->date_echeance =
$object->calculate_date_lim_reglement();
1167 if (!$error &&
GETPOST(
'origin',
'alpha') &&
GETPOST(
'originid')) {
1169 $element = $subelement =
GETPOST(
'origin',
'alpha');
1177 if ($element ==
'order') {
1178 $element = $subelement =
'commande';
1180 if ($element ==
'propal') {
1181 $element =
'comm/propal';
1182 $subelement =
'propal';
1184 if ($element ==
'contract') {
1185 $element = $subelement =
'contrat';
1187 if ($element ==
'order_supplier') {
1189 $subelement =
'fournisseur.commande';
1191 if ($element ==
'project') {
1192 $element =
'projet';
1200 $classname = ucfirst($subelement);
1201 if ($classname ==
'Fournisseur.commande') {
1202 $classname =
'CommandeFournisseur';
1204 $objectsrc =
new $classname($db);
1205 $objectsrc->fetch($originid);
1206 $objectsrc->fetch_thirdparty();
1208 if (!empty(
$object->origin_type) && !empty(
$object->origin_id)) {
1213 if (
$object->origin_type ==
'reception') {
1214 $objectsrc->fetchObjectLinked();
1216 if (count($objectsrc->linkedObjectsIds[
'order_supplier']) > 0) {
1217 foreach ($objectsrc->linkedObjectsIds[
'order_supplier'] as $key => $value) {
1218 $object->linkedObjectsIds[
'order_supplier'][-1] = $value;
1228 $classname = ucfirst($subelement);
1229 if ($classname ==
'Fournisseur.commande') {
1230 $classname =
'CommandeFournisseur';
1232 $srcobject =
new $classname($db);
1234 $result = $srcobject->fetch(
GETPOSTINT(
'originid'));
1237 $typeamount =
GETPOST(
'typedeposit',
'alpha');
1242 $amountdeposit = array();
1244 if ($typeamount ==
'amount') {
1245 $amount = $valuedeposit;
1247 $amount = $srcobject->total_ttc * ((float) $valuedeposit / 100);
1250 $TTotalByTva = array();
1251 foreach ($srcobject->lines as &$line) {
1252 if (!empty($line->special_code)) {
1255 $TTotalByTva[$line->tva_tx] += $line->total_ttc;
1257 '@phan-var-force array<string,float> $TTotalByTva';
1259 $amount_ttc_diff = 0.;
1260 foreach ($TTotalByTva as $tva => &$total) {
1261 $coef = $total / $srcobject->total_ttc;
1262 $am = $amount * $coef;
1263 $amount_ttc_diff += $am;
1264 $amountdeposit[$tva] += $am / (1 + (float) $tva / 100);
1267 if ($typeamount ==
'amount') {
1268 $amountdeposit[0] = $valuedeposit;
1269 } elseif ($typeamount ==
'variable') {
1272 $lines = $srcobject->lines;
1273 $numlines = count($lines);
1274 for ($i = 0; $i < $numlines; $i++) {
1276 if (empty($lines[$i]->qty)) {
1279 if (!empty($lines[$i]->special_code)) {
1283 $totalamount += $lines[$i]->total_ht;
1284 $tva_tx = $lines[$i]->tva_tx;
1285 $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * (float) $valuedeposit) / 100;
1289 if ($totalamount == 0) {
1290 $amountdeposit[0] = 0;
1295 $amountdeposit[0] = 0;
1299 $amount_ttc_diff = array_key_exists(0, $amountdeposit) ? $amountdeposit[0] : 0;
1302 foreach ($amountdeposit as $tva => $amount) {
1303 if (empty($amount)) {
1308 'amount' =>
'FixAmount',
1309 'variable' =>
'VarAmount'
1311 $descline =
'(DEPOSIT)';
1313 if ($typeamount ==
'amount') {
1314 $descline .=
' ('.price($valuedeposit, 0, $langs, 0, - 1, - 1, (!empty(
$object->multicurrency_code) ?
$object->multicurrency_code : $conf->currency)).
')';
1315 } elseif ($typeamount ==
'variable') {
1316 $descline .=
' ('.$valuedeposit.
'%)';
1319 $descline .=
' - '.$srcobject->ref;
1349 $diff =
$object->total_ttc - $amount_ttc_diff;
1353 $subprice_diff =
$object->lines[0]->subprice - $diff / (1 +
$object->lines[0]->tva_tx / 100);
1359 $object->lines[0]->localtax1_tx,
1360 $object->lines[0]->localtax2_tx,
1362 $object->lines[0]->fk_product,
1365 $object->lines[0]->product_type,
1366 $object->lines[0]->remise_percent,
1368 $object->lines[0]->date_start,
1377 } elseif ($result > 0) {
1378 $lines = $srcobject->lines;
1379 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
1380 $srcobject->fetch_lines();
1381 $lines = $srcobject->lines;
1384 $num = count($lines);
1385 for ($i = 0; $i < $num; $i++) {
1386 if (!in_array($lines[$i]->
id, $selectedLines)) {
1390 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->product_label);
1391 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
1394 if (method_exists($lines[$i],
'fetch_optionals')) {
1395 $lines[$i]->fetch_optionals();
1400 $date_start = $lines[$i]->date_debut_prevue;
1401 if ($lines[$i]->date_debut_reel) {
1402 $date_start = $lines[$i]->date_debut_reel;
1404 if ($lines[$i]->date_start) {
1405 $date_start = $lines[$i]->date_start;
1407 $date_end = $lines[$i]->date_fin_prevue;
1408 if ($lines[$i]->date_fin_reel) {
1409 $date_end = $lines[$i]->date_fin_reel;
1411 if ($lines[$i]->date_end) {
1412 $date_end = $lines[$i]->date_end;
1415 $tva_tx = $lines[$i]->tva_tx;
1417 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', (
string) $tva_tx)) {
1418 $tva_tx .=
' ('.$lines[$i]->vat_src_code.
')';
1422 $object->special_code = $lines[$i]->special_code;
1425 if (
$object->multicurrency_code != $conf->currency ||
$object->multicurrency_tx != 1) {
1427 $pu_currency = $lines[$i]->multicurrency_subprice;
1429 $pu = $lines[$i]->subprice;
1438 $lines[$i]->localtax1_tx,
1439 $lines[$i]->localtax2_tx,
1441 $lines[$i]->fk_product,
1442 $lines[$i]->remise_percent,
1446 $lines[$i]->info_bits,
1451 $lines[$i]->array_options,
1452 $lines[$i]->fk_unit,
1455 $lines[$i]->ref_supplier,
1456 $lines[$i]->special_code
1465 if ($result > 0 && !empty($lines[$i]->extraparams)) {
1467 $newline->id = $result;
1468 $newline->extraparams = $lines[$i]->extraparams;
1469 $newline->setExtraParameters();
1481 $parameters = array(
'objFrom' => $srcobject);
1482 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $object, $action);
1492 } elseif (!$error) {
1502 $langs->load(
"errors");
1510 $categories =
GETPOST(
'categories',
'array:int');
1511 if (method_exists($object,
'setCategories')) {
1512 $object->setCategories($categories);
1519 $outputlangs = $langs;
1520 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1527 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
1530 } elseif ($action ==
'updateline' && $usercancreate) {
1534 if (!
$object->fetch($id) > 0) {
1540 $tva_tx = str_replace(
'*',
'', $tva_tx);
1542 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_subprice') !=
'') {
1544 $price_base_type =
'HT';
1547 $price_base_type =
'TTC';
1550 if (
GETPOST(
'productid') > 0) {
1552 if (
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY') == 1) {
1554 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1560 $label = $prod->description;
1561 if (trim(
GETPOST(
'product_desc',
'restricthtml')) != trim($label)) {
1562 $label =
GETPOST(
'product_desc',
'restricthtml');
1565 $type = $prod->type;
1567 $label =
GETPOST(
'product_desc',
'restricthtml');
1576 if (preg_match(
'/\*/', $tva_tx)) {
1581 $tva_tx = str_replace(
'*',
'', $tva_tx);
1589 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1590 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1592 if (is_array($extralabelsline)) {
1593 foreach ($extralabelsline as $key => $value) {
1594 unset($_POST[
"options_".$key]);
1598 $result =
$object->updateline(
1610 (
float) $remise_percent,
1620 unset($_POST[
'label']);
1621 unset($_POST[
'fourn_ref']);
1622 unset($_POST[
'date_starthour']);
1623 unset($_POST[
'date_startmin']);
1624 unset($_POST[
'date_startsec']);
1625 unset($_POST[
'date_startday']);
1626 unset($_POST[
'date_startmonth']);
1627 unset($_POST[
'date_startyear']);
1628 unset($_POST[
'date_endhour']);
1629 unset($_POST[
'date_endmin']);
1630 unset($_POST[
'date_endsec']);
1631 unset($_POST[
'date_endday']);
1632 unset($_POST[
'date_endmonth']);
1633 unset($_POST[
'date_endyear']);
1634 unset($_POST[
'price_ttc']);
1635 unset($_POST[
'price_ht']);
1642 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') && (
GETPOST(
'alldate_start',
'alpha') ||
GETPOST(
'alldate_end',
'alpha')) && $usercancreate) {
1646 foreach (
$object->lines as $line) {
1647 if ($line->product_type == 1) {
1648 $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);
1651 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') !=
'' && $usercancreate) {
1653 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
1654 $vat_rate = str_replace(
'*',
'', $vat_rate);
1657 foreach (
$object->lines as $line) {
1658 $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);
1660 } elseif ($action ==
'addline' && $usercancreate) {
1669 $ret =
$object->fetch_thirdparty();
1671 $langs->load(
'errors');
1676 $line_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
1680 $prod_entry_mode =
GETPOST(
'prod_entry_mode');
1681 if ($prod_entry_mode ==
'free') {
1688 $price_ht_devise =
'';
1690 $price_ttc_devise =
'';
1692 if (
GETPOST(
'price_ht') !==
'') {
1695 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
1698 if (
GETPOST(
'price_ttc') !==
'') {
1701 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
1702 $price_ttc_devise =
price2num(
GETPOST(
'multicurrency_price_ttc'),
'CU', 2);
1709 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef,
'alpha'),
'', 2) : 0);
1710 if (empty($remise_percent)) {
1711 $remise_percent = 0;
1715 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1716 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1718 if (is_array($extralabelsline)) {
1720 foreach ($extralabelsline as $key => $value) {
1721 unset($_POST[
"options_".$key]);
1725 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
1726 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1729 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') &&
GETPOST(
'type') < 0) {
1730 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
1735 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1')
1736 && (((
float) $price_ht < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) || $price_ht ===
'')
1737 && (((
float) $price_ht_devise < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) || $price_ht_devise ===
'')
1738 && ((
float) $price_ttc < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES') || $price_ttc ===
'')
1739 && ((
float) $price_ttc_devise < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES') || $price_ttc_devise ===
'')
1740 &&
$object->type != $object::TYPE_CREDIT_NOTE) {
1741 if (((
float) $price_ht < 0 || (
float) $price_ttc < 0) && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) {
1742 $langs->load(
"errors");
1743 if (
$object->type == $object::TYPE_DEPOSIT) {
1745 setEventMessages($langs->trans(
"ErrorLinesCantBeNegativeOnDeposits"),
null,
'errors');
1747 setEventMessages($langs->trans(
"ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv(
"UnitPrice"), $langs->transnoentitiesnoconv(
"CustomerAbsoluteDiscountShort")),
null,
'errors');
1752 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' && $price_ht_devise ===
'') {
1753 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'UnitPrice')),
null,
'errors');
1757 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') && !
GETPOST(
'dp_desc')) {
1758 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
1761 if (!
GETPOST(
'qty',
'alpha')) {
1762 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1766 if (!$error &&
isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1767 if ($combinations =
GETPOST(
'combinations',
'array:alphanohtml')) {
1771 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1772 $idprod = $res->fk_product_child;
1774 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1780 if ($prod_entry_mode !=
'free' && empty($error)) {
1784 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
1789 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
1790 $idprod = (int) $reg[1];
1791 $res = $productsupplier->fetch($idprod);
1794 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
1796 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1797 if ($productsupplier->fourn_socid != $socid) {
1798 $productsupplier->ref_supplier =
'';
1801 $fksoctosearch =
$object->thirdparty->id;
1802 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1804 } elseif (
GETPOSTINT(
'idprodfournprice') > 0) {
1805 $qtytosearch = (float) $qty;
1807 $idprod = $productsupplier->get_buyprice(
GETPOSTINT(
'idprodfournprice'), $qtytosearch);
1808 $res = $productsupplier->fetch($idprod);
1812 $label = $productsupplier->label;
1815 $outputlangs = $langs;
1817 if (
GETPOST(
'lang_id',
'aZ09')) {
1818 $newlang =
GETPOST(
'lang_id',
'aZ09');
1820 if (empty($newlang)) {
1821 $newlang =
$object->thirdparty->default_lang;
1823 if (!empty($newlang)) {
1824 $outputlangs =
new Translate(
"", $conf);
1825 $outputlangs->setDefaultLang($newlang);
1827 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->
description;
1829 $desc = $productsupplier->description;
1832 if (!empty($productsupplier->desc_supplier) &&
getDolGlobalString(
'PRODUIT_FOURN_TEXTS')) {
1833 $desc = $productsupplier->desc_supplier;
1844 $ref_supplier = $productsupplier->ref_supplier;
1847 if (!GETPOSTISSET(
'tva_tx')) {
1848 $tmpidprodfournprice =
GETPOST(
'idprodfournprice',
'alpha');
1849 if (is_numeric($tmpidprodfournprice) && (
int) $tmpidprodfournprice > 0) {
1850 $tmpidprodfournprice = (int) $tmpidprodfournprice;
1852 $tmpidprodfournprice = 0;
1858 if (empty($tva_tx) || empty($tva_npr)) {
1864 $type = $productsupplier->type;
1865 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1866 $price_base_type =
'HT';
1868 $pu_devise =
price2num($price_ht_devise,
'CU');
1869 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
1870 $price_base_type =
'TTC';
1872 $pu_devise =
price2num($price_ttc_devise,
'CU');
1874 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
1875 if (empty(
$object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code !=
$object->multicurrency_code)) {
1876 $pu = $productsupplier->fourn_pu;
1879 $pu = $productsupplier->fourn_pu;
1880 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
1884 $ref_supplier = $productsupplier->ref_supplier;
1905 min($rank, count(
$object->lines) + 1),
1908 $productsupplier->fk_unit,
1911 GETPOST(
'fourn_ref',
'alpha'),
1915 if ($idprod == -99 || $idprod == 0) {
1918 $langs->load(
"errors");
1919 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
1921 if ($idprod == -1) {
1924 $langs->load(
"errors");
1925 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
1927 } elseif (empty($error)) {
1928 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1929 $tva_tx = str_replace(
'*',
'', $tva_tx);
1930 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1933 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1937 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
1945 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1949 $pu_ht =
price2num((
float) $pu_ttc / (1 + ((
float) $tva_tx / 100)),
'MU');
1951 $price_base_type =
'HT';
1952 $pu_devise =
price2num($price_ht_devise,
'CU');
1954 $result =
$object->addline($line_desc, (
float) $pu_ht, $tva_tx, $localtax1_tx, $localtax2_tx, (
float) $qty, 0, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit, 0, (
float) $pu_devise, $ref_supplier);
1958 if (!$error && $result > 0) {
1963 $outputlangs = $langs;
1966 $newlang =
GETPOST(
'lang_id',
'aZ09');
1969 $newlang =
$object->thirdparty->default_lang;
1971 if (!empty($newlang)) {
1972 $outputlangs =
new Translate(
"", $conf);
1973 $outputlangs->setDefaultLang($newlang);
1978 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1984 unset($_POST [
'prod_entry_mode']);
1986 unset($_POST[
'qty']);
1987 unset($_POST[
'type']);
1988 unset($_POST[
'remise_percent']);
1989 unset($_POST[
'pu']);
1990 unset($_POST[
'price_ht']);
1991 unset($_POST[
'multicurrency_price_ht']);
1992 unset($_POST[
'price_ttc']);
1993 unset($_POST[
'fourn_ref']);
1994 unset($_POST[
'tva_tx']);
1995 unset($_POST[
'label']);
1996 unset($localtax1_tx);
1997 unset($localtax2_tx);
1998 unset($_POST[
'np_marginRate']);
1999 unset($_POST[
'np_markRate']);
2000 unset($_POST[
'dp_desc']);
2001 unset($_POST[
'idprodfournprice']);
2002 unset($_POST[
'units']);
2004 unset($_POST[
'date_starthour']);
2005 unset($_POST[
'date_startmin']);
2006 unset($_POST[
'date_startsec']);
2007 unset($_POST[
'date_startday']);
2008 unset($_POST[
'date_startmonth']);
2009 unset($_POST[
'date_startyear']);
2010 unset($_POST[
'date_endhour']);
2011 unset($_POST[
'date_endmin']);
2012 unset($_POST[
'date_endsec']);
2013 unset($_POST[
'date_endday']);
2014 unset($_POST[
'date_endmonth']);
2015 unset($_POST[
'date_endyear']);
2022 } elseif ($action ==
'classin' && $usercancreate) {
2024 $result =
$object->setProject($projectid);
2025 } elseif ($action ==
'confirm_edit' && $confirm ==
'yes' && $usercancreate) {
2029 $totalpaid =
$object->getSommePaiement();
2030 $resteapayer =
$object->total_ttc - $totalpaid;
2033 $ventilExportCompta =
$object->getVentilExportCompta();
2035 if (!$ventilExportCompta) {
2038 $idwarehouse =
GETPOST(
'idwarehouse');
2042 $qualified_for_stock_change = 0;
2044 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
2046 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2051 $langs->load(
"stocks");
2052 if (!$idwarehouse || $idwarehouse == -1) {
2054 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
2059 $object->setDraft($user, $idwarehouse);
2063 $outputlangs = $langs;
2066 $newlang =
GETPOST(
'lang_id',
'aZ09');
2069 $newlang =
$object->thirdparty->default_lang;
2071 if (!empty($newlang)) {
2072 $outputlangs =
new Translate(
"", $conf);
2073 $outputlangs->setDefaultLang($newlang);
2078 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
2087 } elseif ($action ==
'reopen' && $usercancreate) {
2089 $result =
$object->fetch($id);
2092 $result =
$object->setUnpaid($user);
2094 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
2103 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
2106 $triggersendname =
'BILL_SUPPLIER_SENTBYMAIL';
2108 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
2109 $trackid =
'sinv'.$object->id;
2110 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
2113 $upload_dir = $conf->fournisseur->facture->dir_output;
2114 $permissiontoadd = $usercancreate;
2115 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
2118 if ($action ==
'calculate' && $usercancreate) {
2119 $calculationrule =
GETPOST(
'calculationrule');
2123 $result =
$object->update_price(0, (($calculationrule ==
'totalofround') ?
'0' :
'1'), 0,
$object->thirdparty);
2129 if ($action ==
'update_extras' && $permissiontoeditextra) {
2132 $attribute_name =
GETPOST(
'attribute',
'aZ09');
2135 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
2141 $result =
$object->updateExtraField($attribute_name,
'BILL_SUPPLIER_MODIFY');
2149 $action =
'edit_extras';
2154 if ($action ==
'addcontact' && $usercancreate) {
2155 $result =
$object->fetch($id);
2157 if ($result > 0 && $id > 0) {
2160 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
2164 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2167 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2168 $langs->load(
"errors");
2169 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
2174 } elseif ($action ==
'swapstatut' && $usercancreate) {
2181 } elseif ($action ==
'deletecontact' && $usercancreate) {
2187 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2201$form =
new Form($db);
2203$bankaccountstatic =
new Account($db);
2211$title =
$object->ref.
" - ".$langs->trans(
'Card');
2212if ($action ==
'create') {
2213 $title = $langs->trans(
"NewSupplierInvoice");
2215$help_url =
'EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores|DE:Modul_Lieferantenrechnungen';
2216llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-fourn-facture page-card');
2219if ($action ==
'create') {
2221 $selectedLines = array();
2223 print
load_fiche_titre($langs->trans(
'NewSupplierInvoice'),
'',
'supplier_invoice');
2227 $currency_code = $conf->currency;
2228 $vat_reverse_charge = 0;
2234 if (
isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2235 $currency_code = $societe->multicurrency_code;
2240 if (!empty($origin) && !empty($originid)) {
2242 $element = $subelement = $origin;
2244 if ($element ==
'project') {
2245 $projectid = $originid;
2246 $element =
'projet';
2250 if ($element ==
'order') {
2251 $element = $subelement =
'commande';
2253 if ($element ==
'propal') {
2254 $element =
'comm/propal';
2255 $subelement =
'propal';
2257 if ($element ==
'contract') {
2258 $element = $subelement =
'contrat';
2260 if ($element ==
'order_supplier') {
2262 $subelement =
'fournisseur.commande';
2266 $classname = ucfirst($subelement);
2267 if ($classname ==
'Fournisseur.commande') {
2268 $classname =
'CommandeFournisseur';
2270 $objectsrc =
new $classname($db);
2271 '@phan-var-force Project|Commande|Propal|Facture|Contrat|CommandeFournisseur|CommonObject $objectsrc';
2273 $objectsrc->fetch($originid);
2274 $objectsrc->fetch_thirdparty();
2276 $projectid = (int) $objectsrc->fk_project;
2278 $soc = $objectsrc->thirdparty;
2280 $cond_reglement_id = 0;
2281 $mode_reglement_id = 0;
2285 $transport_mode_id = 0;
2288 if (!empty($objectsrc->cond_reglement_id)) {
2289 $cond_reglement_id = $objectsrc->cond_reglement_id;
2291 if (!empty($objectsrc->mode_reglement_id)) {
2292 $mode_reglement_id = $objectsrc->mode_reglement_id;
2294 if (!empty($objectsrc->fk_account)) {
2295 $fk_account = $objectsrc->fk_account;
2297 if (!empty($objectsrc->transport_mode_id)) {
2298 $transport_mode_id = $objectsrc->transport_mode_id;
2301 if (empty($cond_reglement_id)
2302 || empty($mode_reglement_id)
2303 || empty($fk_account)
2304 || empty($transport_mode_id)
2306 if ($origin ==
'reception') {
2308 if (!isset($objectsrc->supplier_order)) {
2309 $objectsrc->fetch_origin();
2312 if (!empty($objectsrc->origin_object)) {
2313 $originObject = $objectsrc->origin_object;
2314 if (empty($cond_reglement_id) && !empty($originObject->cond_reglement_id)) {
2315 $cond_reglement_id = $originObject->cond_reglement_id;
2317 if (empty($mode_reglement_id) && !empty($originObject->mode_reglement_id)) {
2318 $mode_reglement_id = $originObject->mode_reglement_id;
2320 if (empty($fk_account) && !empty($originObject->fk_account)) {
2321 $fk_account = $originObject->fk_account;
2323 if (empty($transport_mode_id) && !empty($originObject->transport_mode_id)) {
2324 $transport_mode_id = $originObject->transport_mode_id;
2331 if (empty($cond_reglement_id) && !empty($soc->cond_reglement_supplier_id)) {
2332 $cond_reglement_id = $soc->cond_reglement_supplier_id;
2334 if (empty($mode_reglement_id) && !empty($soc->mode_reglement_supplier_id)) {
2335 $mode_reglement_id = $soc->mode_reglement_supplier_id;
2337 if (empty($fk_account) && !empty($soc->fk_account)) {
2338 $fk_account = $soc->fk_account;
2340 if (empty($transport_mode_id) && !empty($soc->transport_mode_id)) {
2341 $transport_mode_id = $soc->transport_mode_id;
2347 if (!empty($objectsrc->multicurrency_code)) {
2348 $currency_code = $objectsrc->multicurrency_code;
2350 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
2351 $currency_tx = $objectsrc->multicurrency_tx;
2356 $dateinvoice = ($datetmp ==
'' ? (!
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ? -1 :
'') : $datetmp);
2358 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2361 $objectsrc->fetch_optionals();
2362 $object->array_options = $objectsrc->array_options;
2364 $cond_reglement_id = !empty($societe->cond_reglement_supplier_id) ? $societe->cond_reglement_supplier_id : 0;
2365 $mode_reglement_id = !empty($societe->mode_reglement_supplier_id) ? $societe->mode_reglement_supplier_id : 0;
2366 $vat_reverse_charge = (empty($societe) ?
'' : $societe->vat_reverse_charge);
2367 $transport_mode_id = !empty($societe->transport_mode_supplier_id) ? $societe->transport_mode_supplier_id : 0;
2368 $fk_account = !empty($societe->fk_account) ? $societe->fk_account : 0;
2370 $dateinvoice = ($datetmp ==
'' ? (
getDolGlobalInt(
'MAIN_AUTOFILL_DATE') ?
'' : -1) : $datetmp);
2372 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2374 if (
isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2375 $currency_code = $societe->multicurrency_code;
2380 if (empty($cond_reglement_id)) {
2381 $cond_reglement_id =
GETPOST(
"cond_reglement_id");
2385 if (empty($mode_reglement_id)) {
2386 $mode_reglement_id =
GETPOST(
"mode_reglement_id");
2390 if (!
GETPOST(
'changecompany')) {
2391 if (GETPOSTISSET(
'cond_reglement_id')) {
2392 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2394 if (GETPOSTISSET(
'mode_reglement_id')) {
2395 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2397 if (GETPOSTISSET(
'cond_reglement_id')) {
2402 $note_public =
$object->getDefaultCreateValueFor(
'note_public', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_public : null));
2403 $note_private =
$object->getDefaultCreateValueFor(
'note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_private : null));
2405 if ($origin ==
'contrat') {
2406 $langs->load(
"admin");
2407 $text = $langs->trans(
"ToCreateARecurringInvoice");
2408 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv(
"MenuFinancial"), $langs->transnoentitiesnoconv(
"SupplierBills"), $langs->transnoentitiesnoconv(
"ListOfTemplates"));
2410 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv(
'Module2300Name'));
2412 print
info_admin($text, 0, 0,
'0',
'opacitymedium').
'<br>';
2415 print
'<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
2416 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2417 print
'<input type="hidden" name="action" value="add">';
2418 print
'<input type="hidden" name="changecompany" value="0">';
2420 if (!empty($societe->id) && $societe->id > 0) {
2421 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">'.
"\n";
2423 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
2424 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
2425 if (!empty($currency_tx)) {
2426 print
'<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
2428 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2433 $parameters = array();
2435 $reshook = $hookmanager->executeHooks(
'tabContentCreateSupplierInvoice', $parameters, $object, $action);
2436 if (empty($reshook)) {
2437 print
'<table class="border centpercent">';
2440 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
'Draft').
'</td></tr>';
2444 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2445 $invoice_predefined->fetch($fac_recid);
2449 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
2452 if (!empty($societe->id) && $societe->id > 0 && ($fac_recid <= 0 || !empty($invoice_predefined->frequency))) {
2453 $absolute_discount = $societe->getAvailableDiscounts(
null,
'', 0, 1);
2454 print $societe->getNomUrl(1,
'supplier');
2455 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
2457 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
2458 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');
2461 print
'<script type="text/javascript">
2462 $(document).ready(function() {
2463 $("#socid").change(function() {
2464 console.log("We have changed the company - Reload page");
2466 $("input[name=action]").val("create");
2467 $("input[name=changecompany]").val("1");
2468 $("form[name=add]").submit();
2473 if ($fac_recid <= 0) {
2474 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>';
2480 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2481 $invoice_predefined->fetch($fac_recid);
2483 $dateinvoice = $invoice_predefined->date_when;
2484 if (empty($projectid)) {
2485 $projectid = $invoice_predefined->fk_project;
2487 $cond_reglement_id = $invoice_predefined->cond_reglement_id;
2488 $mode_reglement_id = $invoice_predefined->mode_reglement_id;
2489 $fk_account = $invoice_predefined->fk_account;
2490 $note_public = $invoice_predefined->note_public;
2491 $note_private = $invoice_predefined->note_private;
2493 if (!empty($invoice_predefined->multicurrency_code)) {
2494 $currency_code = $invoice_predefined->multicurrency_code;
2496 if (!empty($invoice_predefined->multicurrency_tx)) {
2497 $currency_tx = $invoice_predefined->multicurrency_tx;
2500 $sql =
'SELECT r.rowid, r.titre as title, r.total_ttc';
2501 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn_rec as r';
2502 $sql .=
' WHERE r.fk_soc = '. (int) $invoice_predefined->socid;
2504 $resql = $db->query($sql);
2506 $num = $db->num_rows($resql);
2510 print
'<tr><td>'.$langs->trans(
'CreateFromRepeatableInvoice').
'</td><td>';
2512 print
'<select class="flat" id="fac_rec" name="fac_rec">';
2513 print
'<option value="0" selected></option>';
2515 $objp = $db->fetch_object($resql);
2516 print
'<option value="'.$objp->rowid.
'"';
2517 if ($fac_recid == $objp->rowid) {
2519 $exampletemplateinvoice->fetch($fac_recid);
2521 print
'>'.$objp->title.
' ('.
price($objp->total_ttc).
' '.$langs->trans(
"TTC").
')</option>';
2527 print
'<script type="text/javascript">
2528 $(document).ready(function() {
2529 $("#fac_rec").change(function() {
2530 console.log("We have changed the template invoice - Reload page");
2532 $("input[name=action]").val("create");
2533 $("form[name=add]").submit();
2547 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" spellcheck="false"';
2548 if (!empty($societe->id) && $societe->id > 0) {
2554 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'Type').
'</td><td>';
2556 print
'<div class="tagtable">'.
"\n";
2559 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2560 $tmp =
'<input type="radio" id="radio_standard" name="type" value="0"'.(GETPOSTINT(
'type') ?
'' :
'checked').
'> ';
2561 $desc = $form->textwithpicto($tmp.
'<label for="radio_standard">'.$langs->trans(
"InvoiceStandardAsk").
'</label>', $langs->transnoentities(
"InvoiceStandardDesc"), 1,
'help',
'', 0, 3);
2563 print
'</div></div>';
2565 if (empty($origin) || (($origin ==
'supplier_proposal' || $origin ==
'order_supplier' || $origin ==
'reception') && !empty($originid))) {
2568 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2569 $tmp =
'<input type="radio" id="radio_deposit" name="type" value="3"' . (
GETPOSTINT(
'type') == 3 ?
' checked' :
'') .
'> ';
2570 print
'<script type="text/javascript">
2571 jQuery(document).ready(function() {
2572 jQuery("#typestandardinvoice, #valuestandardinvoice").click(function() {
2573 jQuery("#radio_standard").prop("checked", true);
2575 jQuery("#typedeposit, #valuedeposit").click(function() {
2576 jQuery("#radio_deposit").prop("checked", true);
2578 jQuery("#typedeposit").change(function() {
2579 console.log("We change type of down payment");
2580 jQuery("#radio_deposit").prop("checked", true);
2581 setRadioForTypeOfInvoice();
2583 jQuery("#radio_standard, #radio_deposit, #radio_replacement, #radio_template").change(function() {
2584 setRadioForTypeOfInvoice();
2586 function setRadioForTypeOfInvoice() {
2587 console.log("Change radio");
2588 if (jQuery("#radio_deposit").prop("checked") && (jQuery("#typedeposit").val() == \'amount\' || jQuery("#typedeposit").val() == \'variable\')) {
2589 jQuery(".checkforselect").prop("disabled", true);
2590 jQuery(".checkforselect").prop("checked", false);
2592 jQuery(".checkforselect").prop("disabled", false);
2593 jQuery(".checkforselect").prop("checked", true);
2599 $tmp = $tmp.
'<label for="radio_deposit" >'.$langs->trans(
"InvoiceDeposit").
'</label>';
2601 $desc = $form->textwithpicto($tmp, $langs->transnoentities(
"InvoiceDepositDesc"), 1,
'help',
'', 0, 3);
2602 print
'<table class="nobordernopadding"><tr>';
2606 if ($origin ==
'supplier_proposal' || $origin ==
'order_supplier' || $origin ==
'reception') {
2607 print
'<td class="nowrap" style="padding-left: 15px">';
2609 'amount' => $langs->transnoentitiesnoconv(
'FixAmount', $langs->transnoentitiesnoconv(
'Deposit')),
2610 'variable' => $langs->transnoentitiesnoconv(
'VarAmountOneLine', $langs->transnoentitiesnoconv(
'Deposit')),
2611 'variablealllines' => $langs->transnoentitiesnoconv(
'VarAmountAllLines')
2613 $typedeposit =
GETPOST(
'typedeposit',
'aZ09');
2614 $valuedeposit =
GETPOST(
'valuedeposit',
'int');
2615 $deposit_percent =
null;
2616 if ($origin ==
'reception') {
2618 if (!isset($objectsrc->origin_object)) {
2619 $objectsrc->fetch_origin();
2621 if (!empty($objectsrc->origin_object)) {
2622 $deposit_percent = $objectsrc->origin_object->deposit_percent;
2624 } elseif (!empty($objectsrc->deposit_percent)) {
2625 $deposit_percent = $objectsrc->deposit_percent;
2627 if (empty($typedeposit) && !empty($deposit_percent)) {
2628 $origin_payment_conditions_deposit_percent =
getDictionaryValue(
'c_payment_term',
'deposit_percent', $objectsrc->cond_reglement_id);
2629 if (!empty($origin_payment_conditions_deposit_percent)) {
2630 $typedeposit =
'variable';
2633 if (empty($valuedeposit) && $typedeposit ==
'variable' && !empty($deposit_percent)) {
2634 $valuedeposit = $deposit_percent;
2636 print $form->selectarray(
'typedeposit', $arraylist, $typedeposit, 0, 0, 0,
'', 1);
2638 print
'<td class="nowrap" style="padding-left: 5px">';
2639 print
'<span class="opacitymedium paddingleft">'.$langs->trans(
"AmountOrPercent").
'</span><input type="text" id="valuedeposit" name="valuedeposit" class="width75 right" value="' . $valuedeposit .
'"/>';
2642 print
'</tr></table>';
2644 print
'</div></div>';
2713 if (empty($origin)) {
2714 if (!empty($societe->id) && $societe->id > 0) {
2718 $facids = $facturestatic->list_qualified_avoir_supplier_invoices($societe->id);
2725 foreach ($facids as $key => $valarray) {
2726 $newinvoice_static->id = $key;
2727 $newinvoice_static->ref = $valarray [
'ref'];
2728 $newinvoice_static->status = $valarray [
'status'];
2729 $newinvoice_static->statut = $valarray [
'status'];
2730 $newinvoice_static->type = $valarray [
'type'];
2731 $newinvoice_static->paid = $valarray [
'paye'];
2732 $newinvoice_static->paye = $valarray [
'paye'];
2734 $optionsav .=
'<option value="'.$key.
'"';
2736 $optionsav .=
' selected';
2739 $optionsav .= $newinvoice_static->ref;
2740 $optionsav .=
' ('.$newinvoice_static->getLibStatut(1, $valarray [
'paymentornot']).
')';
2741 $optionsav .=
'</option>';
2744 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2745 $tmp =
'<input type="radio" id="radio_creditnote" name="type" value="2"'.(GETPOST(
'type') == 2 ?
' checked' :
'');
2747 $tmp .=
' disabled';
2751 print
'<script type="text/javascript">
2752 jQuery(document).ready(function() {
2753 if (! jQuery("#radio_creditnote").is(":checked"))
2755 jQuery("#credit_note_options").hide();
2757 jQuery("#radio_creditnote").click(function() {
2758 jQuery("#credit_note_options").show();
2760 jQuery("#radio_standard, #radio_replacement, #radio_deposit").click(function() {
2761 jQuery("#credit_note_options").hide();
2765 $text = $tmp.
'<label for="radio_creditnote">'.$langs->transnoentities(
"InvoiceAvoirAsk").
'</label> ';
2767 $text .=
'<select class="flat valignmiddle" name="fac_avoir" id="fac_avoir"';
2769 $text .=
' disabled';
2773 $text .=
'<option value="-1"></option>';
2774 $text .= $optionsav;
2776 $text .=
'<option value="-1">'.$langs->trans(
"NoInvoiceToCorrect").
'</option>';
2778 $text .=
'</select>';
2779 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2782 print
'<div id="credit_note_options" class="clearboth">';
2783 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' :
'').
' /> ';
2784 print
'<label for="invoiceAvoirWithLines">'.$langs->trans(
'invoiceAvoirWithLines').
"</label>";
2785 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' :
'').
' /> ';
2786 print
'<label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans(
'invoiceAvoirWithPaymentRestAmount').
"</label>";
2789 print
'</div></div>';
2792 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2794 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="0" disabled> ';
2796 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="2"> ';
2798 $text = $tmp.$langs->trans(
"InvoiceAvoir").
' ';
2799 $text .=
'<span class="opacitymedium">('.$langs->trans(
"YouMustCreateInvoiceFromSupplierThird").
')</span> ';
2800 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2802 print
'</div></div>'.
"\n";
2813 print
'<tr><td class="fieldrequired">'.$langs->trans(
'InvoiceSubtype').
'</td><td colspan="2">';
2814 print $form->getSelectInvoiceSubtype(
GETPOSTINT(
'subtype'),
'subtype', 1, 0,
'');
2818 if (!empty($societe->id) && $societe->id > 0) {
2820 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
2822 $thirdparty = $societe;
2824 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$societe->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
2825 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2831 print
'<tr><td>'.$langs->trans(
'Label').
'</td><td><input class="minwidth200" name="label" value="'.
dol_escape_htmltag(
GETPOST(
'label')).
'" type="text"></td></tr>';
2835 print
'<tr><td class="fieldrequired">'.$langs->trans(
'DateInvoice').
'</td><td>';
2836 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2837 print $form->selectDate($dateinvoice ? (
int) $dateinvoice :
'',
'', 0, 0, 0,
"add", 1, 1);
2842 print
'<tr><td class="fieldrequired">'.$langs->trans(
'DatePointOfTax').
'</td><td>';
2843 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2844 print $form->selectDate($date_pointoftax ? $date_pointoftax : -1,
'date_pointoftax', 0, 0, 0,
"add", 1, 1);
2849 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
2850 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
2851 print $form->getSelectConditionsPaiements($cond_reglement_id,
'cond_reglement_id', -1, 1, 0,
'maxwidth200 widthcentpercentminusx');
2855 print
'<tr><td>'.$langs->trans(
'DateMaxPayment').
'</td><td>';
2856 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2857 print $form->selectDate($datedue,
'ech', 0, 0, 0,
"add", 1, 1);
2861 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
2862 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
2863 $form->select_types_paiements((
string) $mode_reglement_id,
'mode_reglement_id',
'DBIT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx');
2868 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
2870 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes((
int) $fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
2878 $langs->load(
'projects');
2879 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td>';
2880 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');
2881 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>';
2888 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), !empty($objectsrc->label_incoterms) ? $objectsrc->label_incoterms :
'', 1).
'</label></td>';
2889 print
'<td colspan="3" class="maxwidthonsmartphone">';
2890 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2891 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 :
''));
2897 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
2898 print
'<tr><td>' . $langs->trans(
'VATReverseCharge') .
'</td><td>';
2900 if (GETPOSTISSET(
'vat_reverse_charge')) {
2901 $vat_reverse_charge = (
GETPOST(
'vat_reverse_charge',
'alpha') ==
'on' ||
GETPOST(
'vat_reverse_charge',
'alpha') ==
'1') ? 1 : 0;
2902 } elseif ($vat_reverse_charge == 1 || $societe->vat_reverse_charge == 1 || ($societe->country_code !=
$mysoc->country_code &&
isInEEC(
$mysoc) &&
isInEEC($societe) && !empty($societe->tva_intra))) {
2903 $vat_reverse_charge = 1;
2905 $vat_reverse_charge = 0;
2908 print
'<input type="checkbox" name="vat_reverse_charge"'. (!empty($vat_reverse_charge) ?
' checked ' :
'') .
'>';
2915 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
2916 print
'<td class="maxwidthonsmartphone">';
2917 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
2918 $used_currency_code = $currency_code;
2919 if (!
GETPOST(
'changecompany')) {
2920 $used_currency_code = GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code',
'alpha') : $currency_code;
2922 print $form->selectMultiCurrency($used_currency_code,
'multicurrency_code');
2928 if ($fac_recid > 0) {
2929 $dateexample = $dateinvoice;
2930 if (empty($dateexample)) {
2933 $substitutionarray = array(
2934 '__TOTAL_HT__' => $langs->trans(
"AmountHT").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ht).
')',
2935 '__TOTAL_TTC__' => $langs->trans(
"AmountTTC").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ttc).
')',
2936 '__INVOICE_PREVIOUS_MONTH__' => $langs->trans(
"PreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%m').
')',
2937 '__INVOICE_MONTH__' => $langs->trans(
"MonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%m').
')',
2938 '__INVOICE_NEXT_MONTH__' => $langs->trans(
"NextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%m').
')',
2939 '__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans(
"TextPreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%B').
')',
2940 '__INVOICE_MONTH_TEXT__' => $langs->trans(
"TextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%B').
')',
2941 '__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans(
"TextNextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%B').
')',
2942 '__INVOICE_PREVIOUS_YEAR__' => $langs->trans(
"PreviousYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'y'),
'%Y').
')',
2943 '__INVOICE_YEAR__' => $langs->trans(
"YearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%Y').
')',
2944 '__INVOICE_NEXT_YEAR__' => $langs->trans(
"NextYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'y'),
'%Y').
')'
2947 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
2948 foreach ($substitutionarray as $key => $val) {
2949 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
2951 $htmltext .=
'</i>';
2956 $langs->loadLangs(array(
"intracommreport"));
2957 print
'<!-- If module intracomm on -->'.
"\n";
2958 print
'<tr><td>'.$langs->trans(
'IntracommReportTransportMode').
'</td><td>';
2959 $form->selectTransportMode(GETPOSTISSET(
'transport_mode_id') ?
GETPOST(
'transport_mode_id') : $transport_mode_id,
'transport_mode_id');
2963 if (empty($reshook)) {
2964 print
$object->showOptionals($extrafields,
'create');
2969 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
2970 print $form->selectCategories(Categorie::TYPE_SUPPLIER_INVOICE,
'categories', $object);
2975 print
'<tr><td>'.$langs->trans(
'NotePublic').
'</td>';
2977 $doleditor =
new DolEditor(
'note_public', (GETPOSTISSET(
'note_public') ?
GETPOST(
'note_public',
'restricthtml') : $note_public),
'', 80,
'dolibarr_notes',
'In', false, false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
2978 print $doleditor->Create(1);
2984 print
'<tr><td>'.$langs->trans(
'NotePrivate').
'</td>';
2986 $doleditor =
new DolEditor(
'note_private', (GETPOSTISSET(
'note_private') ?
GETPOST(
'note_private',
'restricthtml') : $note_private),
'', 80,
'dolibarr_notes',
'In', false, false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
2987 print $doleditor->Create(1);
2993 if (!empty($objectsrc)) {
2994 print
"\n<!-- ".$classname.
" info -->";
2996 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2997 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2998 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2999 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
3000 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
3002 $txt = $langs->trans($classname);
3003 if ($classname ==
'CommandeFournisseur') {
3004 $langs->load(
'orders');
3005 $txt = $langs->trans(
"SupplierOrder");
3007 print
'<tr><td>'.$txt.
'</td><td>'.$objectsrc->getNomUrl(1);
3009 $objectsrc->fetchObjectLinked($originid, $origin,
null,
'invoice_supplier');
3011 if (isset($objectsrc->linkedObjects[
'invoice_supplier'])) {
3012 $invoice_supplier = $objectsrc->linkedObjects[
'invoice_supplier'];
3014 $invoice_supplier = [];
3016 '@phan-var-force null|FactureFournisseur[] $invoice_supplier';
3019 if (is_array($invoice_supplier)) {
3020 $cntinvoice = count($invoice_supplier);
3022 if ($cntinvoice >= 1) {
3024 echo
' ('.$langs->trans(
'LatestRelatedBill').end($invoice_supplier)->getNomUrl(1).
')';
3029 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
3030 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
3031 if (
$mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
3032 print
'<tr><td>'.$langs->transcountry(
"AmountLT1",
$mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
3035 if (
$mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
3036 print
'<tr><td>'.$langs->transcountry(
"AmountLT2",
$mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
3038 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
3041 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
'</td></tr>';
3042 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
"</td></tr>";
3043 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc, 0, $langs, 1, -1, -1, $objectsrc->multicurrency_code).
"</td></tr>";
3048 $parameters = array();
3049 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
3050 print $hookmanager->resPrint;
3058 print $form->buttonsSaveCancel(
"CreateDraft");
3061 if (!empty($objectsrc)) {
3064 $title = $langs->trans(
'ProductsAndServices');
3067 print
'<div class="div-table-responsive-no-min">';
3068 print
'<table class="noborder centpercent">';
3070 $objectsrc->printOriginLinesList(
'', $selectedLines);
3078 if ($id > 0 || !empty($ref)) {
3084 $result =
$object->fetch($id, $ref);
3089 $result =
$object->fetch_thirdparty();
3095 $societe =
$object->thirdparty;
3097 $totalpaid =
$object->getSommePaiement();
3098 $totalcreditnotes =
$object->getSumCreditNotesUsed();
3099 $totaldeposits =
$object->getSumDepositsUsed();
3107 $resteapayer =
price2num(
$object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
3110 $multicurrency_resteapayer = 0;
3112 $multicurrency_totalpaid =
$object->getSommePaiement(1);
3113 $multicurrency_totalcreditnotes =
$object->getSumCreditNotesUsed(1);
3114 $multicurrency_totaldeposits =
$object->getSumDepositsUsed(1);
3115 $multicurrency_resteapayer =
price2num(
$object->multicurrency_total_ttc - $multicurrency_totalpaid - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits,
'MT');
3119 if ($resteapayer == 0 && $multicurrency_resteapayer != 0 &&
$object->multicurrency_code != $conf->currency) {
3120 $resteapayer =
price2num((
float) $multicurrency_resteapayer /
$object->multicurrency_tx,
'MT');
3127 $resteapayeraffiche = $resteapayer;
3130 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
3131 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
3133 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
3134 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
3137 $absolute_discount = $societe->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
3138 $absolute_creditnote = $societe->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
3139 $absolute_discount =
price2num($absolute_discount,
'MT');
3140 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
3144 $objectidnext =
$object->getIdReplacingInvoice();
3147 $titre = $langs->trans(
'SupplierInvoice');
3149 print
dol_get_fiche_head($head,
'card', $titre, -1,
'supplier_invoice', 0,
'',
'', 0,
'', 1);
3154 if ($action ==
'converttoreduc') {
3157 $type_fac =
'ExcessPaid';
3159 $type_fac =
'CreditNote';
3161 $type_fac =
'Deposit';
3163 $text = $langs->trans(
'ConfirmConvertToReducSupplier', strtolower($langs->transnoentities($type_fac)));
3164 $text .=
'<br>'.$langs->trans(
'ConfirmConvertToReducSupplier2');
3165 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id, $langs->trans(
'ConvertToReduc'), $text,
'confirm_converttoreduc',
'',
"yes", 2);
3169 if ($action ==
'clone') {
3171 $formquestion = array(
3172 array(
'type' =>
'text',
'name' =>
'newsupplierref',
'label' => $langs->trans(
"RefSupplierBill"),
'value' => $langs->trans(
"CopyOf").
' '.
$object->ref_supplier),
3173 array(
'type' =>
'date',
'name' =>
'newdate',
'label' => $langs->trans(
"Date"),
'value' =>
dol_now())
3176 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneInvoice',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1, 250);
3180 if ($action ==
'valid') {
3182 if (preg_match(
'/^[\(]?PROV/i',
$object->ref) || empty(
$object->ref)) {
3184 $numref =
$object->getNextNumRef($societe);
3186 $numref = (string)
$object->ref;
3193 $text = $langs->trans(
'ConfirmValidateBill', $numref);
3201 $formquestion = array();
3203 $qualified_for_stock_change = 0;
3205 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3207 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3211 $langs->load(
"stocks");
3212 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3215 $warehouse_array = $warehouse->list_array();
3216 if (count($warehouse_array) == 1) {
3218 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3221 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3223 $formquestion = array(
3224 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3228 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateBill'), $text,
'confirm_valid', $formquestion, 1, 1);
3233 if ($action ==
'edit') {
3234 $formquestion = array();
3236 $qualified_for_stock_change = 0;
3238 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3240 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3243 $langs->load(
"stocks");
3244 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3247 $warehouse_array = $warehouse->list_array();
3248 if (count($warehouse_array) == 1) {
3250 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3253 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3255 $formquestion = array(
3256 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3259 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'UnvalidateBill'), $langs->trans(
'ConfirmUnvalidateBill',
$object->ref),
'confirm_edit', $formquestion, 1, 1);
3263 if ($action ==
'paid' && ($resteapayer <= 0 || (
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') && $resteapayer ==
$object->total_ttc))) {
3264 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidBill',
$object->ref),
'confirm_paid',
'', 0, 1);
3267 if ($action ==
'paid' && $resteapayer > 0 && (!
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') || $resteapayer !=
$object->total_ttc)) {
3271 $close[$i][
'code'] =
'discount_vat';
3273 $close[$i][
'code'] =
'badsupplier';
3275 $close[$i][
'code'] =
'other';
3279 $close[$i][
'label'] = $langs->trans(
"HelpEscompte").
'<br><br>'.$langs->trans(
"ConfirmClassifyPaidPartiallyReasonDiscountVatDesc");
3281 $close[$i][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3283 $close[$i][
'label'] = $langs->trans(
"Other");
3287 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonDiscount", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3289 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadCustomer", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3291 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"Other"), $close[$i][
'label'], 1);
3294 $arrayreasons = array();
3295 foreach ($close as $key => $val) {
3296 $arrayreasons[$close[$key][
'code']] = $close[$key][
'reason'];
3300 $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'));
3302 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?facid='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidPartially',
$object->ref),
'confirm_paid_partially', $formquestion,
"yes", 1, 310);
3306 if ($action ==
'canceled') {
3308 $close[1][
'code'] =
'badsupplier';
3309 $close[2][
'code'] =
'abandon';
3311 $close[1][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3312 $close[2][
'label'] = $langs->trans(
"ConfirmClassifyAbandonReasonOtherDesc");
3314 $close[1][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadSupplier",
$object->ref), $close[1][
'label'], 1);
3315 $close[2][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyAbandonReasonOther"), $close[2][
'label'], 1);
3317 $arrayreasons[$close[1][
'code']] = $close[1][
'reason'];
3318 $arrayreasons[$close[2][
'code']] = $close[2][
'reason'];
3321 $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'));
3323 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'CancelBill'), $langs->trans(
'ConfirmCancelBill',
$object->ref),
'confirm_canceled', $formquestion,
"yes", 1, 280);
3327 if ($action ==
'delete') {
3328 $formquestion = array();
3330 $qualified_for_stock_change = 0;
3332 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3334 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3338 $langs->load(
"stocks");
3339 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3342 $warehouse_array = $warehouse->list_array();
3344 $selectwarehouse =
'<span class="questionrevertstock hidden">';
3345 if (count($warehouse_array) == 1) {
3347 $selectwarehouse .=
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3350 $selectwarehouse .= $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3352 $selectwarehouse .=
'</span>';
3354 $selectyesno = array(0 => $langs->trans(
'No'), 1 => $langs->trans(
'Yes'));
3356 print
'<script type="text/javascript">
3357 $(document).ready(function() {
3358 $("#revertstock").change(function() {
3359 if(this.value > 0) {
3360 $(".questionrevertstock").removeClass("hidden");
3362 $(".questionrevertstock").addClass("hidden");
3368 $formquestion = array(
3369 array(
'type' =>
'select',
'name' =>
'revertstock',
'label' => $langs->trans(
"RevertProductsToStock"),
'select_show_empty' => 0,
'values' => $selectyesno),
3370 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $selectwarehouse,
'tdclass' =>
'questionrevertstock hidden')
3374 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteBill'), $langs->trans(
'ConfirmDeleteBill'),
'confirm_delete', $formquestion, 1, 1);
3376 if ($action ==
'deletepayment') {
3377 $payment_id =
GETPOST(
'paiement_id');
3378 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&paiement_id='.$payment_id, $langs->trans(
'DeletePayment'), $langs->trans(
'ConfirmDeletePayment'),
'confirm_delete_paiement',
'', 0, 1);
3382 if ($action ==
'ask_deleteline') {
3383 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
3386 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
3387 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
3388 if (empty($reshook)) {
3389 $formconfirm .= $hookmanager->resPrint;
3390 } elseif ($reshook > 0) {
3391 $formconfirm = $hookmanager->resPrint;
3399 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
3401 $morehtmlref =
'<div class="refidno">';
3403 $morehtmlref .= $form->editfieldkey(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier, $object, (
int) $usercancreate,
'string',
'', 0, 1);
3404 $morehtmlref .= $form->editfieldval(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier, $object, $usercancreate,
'string',
'',
null,
null,
'', 1);
3406 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1,
'supplier');
3408 $morehtmlref .=
' <div class="inline-block valignmiddle">(<a class="valignmiddle" href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.((int)
$object->thirdparty->id).
'">'.$langs->trans(
"OtherBills").
'</a>)</div>';
3412 $langs->load(
"projects");
3413 $morehtmlref .=
'<br>';
3414 if ($permissiontoadd) {
3415 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
3416 if ($action !=
'classify') {
3417 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.((int)
$object->id).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
3419 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (!
getDolGlobalString(
'PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS') ?
$object->socid : -1), (string)
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
3421 if (!empty(
$object->fk_project)) {
3423 $proj->fetch(
$object->fk_project);
3424 $morehtmlref .= $proj->getNomUrl(1);
3426 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
3431 $morehtmlref .=
'</div>';
3433 $object->totalpaid = $totalpaid;
3435 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
3438 $parameters = array();
3440 $reshook = $hookmanager->executeHooks(
'tabContentViewSupplierInvoice', $parameters, $object, $action);
3441 if (empty($reshook)) {
3442 print
'<div class="fichecenter">';
3443 print
'<div class="fichehalfleft">';
3444 print
'<div class="underbanner clearboth"></div>';
3446 print
'<table class="border tableforfield centpercent">';
3449 print
'<tr><td>'.$langs->trans(
'Type').
'</td><td>';
3450 print
'<span class="badgeneutral">';
3454 print
' '.$object->getSubtypeLabel(
'facture_fourn');
3458 $facreplaced->fetch(
$object->fk_facture_source);
3459 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
'</span>';
3462 if (
$object->fk_facture_source > 0) {
3464 $facusing->fetch(
$object->fk_facture_source);
3465 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
'</span>';
3467 $langs->load(
"errors");
3468 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"WarningCorrectedInvoiceNotFound").
'</span>';
3473 $object->getListIdAvoirFromInvoice();
3475 if (!empty(
$object->creditnote_ids)) {
3476 $invoicecredits = array();
3477 foreach (
$object->creditnote_ids as $invoiceid) {
3479 $creditnote->fetch($invoiceid);
3480 $invoicecredits[] = $creditnote->getNomUrl(1);
3482 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"InvoiceHasAvoir") . (count($invoicecredits) ?
' ' :
'') . implode(
',', $invoicecredits);
3485 if (isset($objectidnext) && $objectidnext > 0) {
3488 $facthatreplace->fetch($objectidnext);
3489 print
' <span class="opacitymediumbycolor paddingleft">'.str_replace(
'{s1}', $facthatreplace->getNomUrl(1), $langs->transnoentities(
"ReplacedByInvoice",
'{s1}')).
'</span>';
3493 $result = $discount->fetch(0, 0,
$object->id);
3495 print
' <span class="opacitymediumbycolor paddingleft">';
3496 $s = $langs->trans(
"CreditNoteConvertedIntoDiscount",
'{s1}',
'{s2}');
3497 $s = str_replace(
'{s1}',
$object->getLibType(1), $s);
3498 $s = str_replace(
'{s2}', $discount->getNomUrl(1,
'discount'), $s);
3500 print
'</span><br>';
3504 if (
$object->fk_fac_rec_source > 0) {
3506 $result = $tmptemplate->fetch(
$object->fk_fac_rec_source);
3508 print
' <span class="opacitymediumbycolor paddingleft">';
3509 $link =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.$tmptemplate->id.
'">'.
dol_escape_htmltag($tmptemplate->title).
'</a>';
3510 $s = $langs->transnoentities(
"GeneratedFromSupplierTemplate", $link);
3520 print
'<!-- Discounts -->'.
"\n";
3521 print
'<tr><td>'.$langs->trans(
'DiscountStillRemaining');
3524 $thirdparty = $societe;
3526 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
3532 print
'<td>'.$form->editfieldkey(
"Label",
'label',
$object->label, $object, (
int) $usercancreate).
'</td>';
3533 print
'<td>'.$form->editfieldval(
"Label",
'label',
$object->label, $object, $usercancreate).
'</td>';
3541 print $form->editfieldkey(
"DateInvoice",
'datef', (
string)
$object->date,
$object, (int) $form_permission,
'datepicker');
3542 print
'</td><td colspan="3">';
3543 print $form->editfieldval(
"Date",
'datef',
$object->date, $object, $form_permission,
'datepicker');
3549 print $form->editfieldkey(
"DatePointOfTax",
'date_pointoftax', (
string)
$object->date_pointoftax,
$object, (int) $pointoftax_form_permission,
'datepicker');
3550 print
'</td><td colspan="3">';
3551 print $form->editfieldval(
"DatePointOfTax",
'date_pointoftax',
$object->date_pointoftax, $object, $pointoftax_form_permission,
'datepicker');
3556 $langs->load(
'bills');
3557 print
'<tr><td class="nowrap">';
3558 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3559 print $langs->trans(
'PaymentConditions');
3561 if ($action !=
'editconditions' && $form_permission) {
3562 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>';
3564 print
'</tr></table>';
3566 if ($action ==
'editconditions') {
3567 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id');
3569 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'none');
3576 print $form->editfieldkey(
"DateMaxPayment",
'date_lim_reglement', (
string)
$object->date_echeance, $object, (
int) $form_permission,
'datepicker');
3578 print $form->editfieldval(
"DateMaxPayment",
'date_lim_reglement',
$object->date_echeance, $object, $form_permission,
'datepicker');
3579 if ($action !=
'editdate_lim_reglement' &&
$object->hasDelay()) {
3585 $langs->load(
'bills');
3586 print
'<tr><td class="nowrap">';
3587 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3588 print $langs->trans(
'PaymentMode');
3590 if ($action !=
'editmode' && $form_permission) {
3591 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>';
3593 print
'</tr></table>';
3595 if ($action ==
'editmode') {
3596 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
3598 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
3604 print
'<tr><td class="nowrap">';
3605 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3606 print $langs->trans(
'BankAccount');
3608 if ($action !=
'editbankaccount' && $usercancreate) {
3609 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>';
3611 print
'</tr></table>';
3613 if ($action ==
'editbankaccount') {
3614 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
3616 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'none');
3624 print
'<tr><td class="nowrap">';
3625 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3626 print $langs->trans(
'VATReverseCharge');
3628 if ($action !=
'editvatreversecharge' && $usercancreate) {
3629 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editvatreversecharge&id='.
$object->id.
'">'.
img_edit($langs->trans(
'SetVATReverseCharge'), 1).
'</a></td>';
3631 print
'</tr></table>';
3633 if ($action ==
'editvatreversecharge') {
3634 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
3635 print
'<input type="hidden" name="action" value="setvatreversecharge">';
3636 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3638 print
'<input type="checkbox" name="vat_reverse_charge"' . (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
'>';
3640 print
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
3643 print
'<input type="checkbox" name="vat_reverse_charge"'. (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
' disabled>';
3651 print
'<table width="100%" class="nobordernopadding"><tr><td>';
3652 print $langs->trans(
'IncotermLabel');
3653 print
'<td><td class="right">';
3654 if ($usercancreate) {
3655 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.
$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit().
'</a>';
3659 print
'</td></tr></table>';
3662 if ($action !=
'editincoterm') {
3663 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3665 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
3672 $langs->loadLangs(array(
"intracommreport"));
3673 print
'<!-- If module intracomm on -->'.
"\n";
3675 print
'<table class="nobordernopadding centpercent"><tr><td>';
3676 print $langs->trans(
'IntracommReportTransportMode');
3678 if ($action !=
'edittransportmode' && ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"))) {
3679 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edittransportmode&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit().
'</a></td>';
3681 print
'</tr></table>';
3684 if ($action ==
'edittransportmode') {
3685 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->transport_mode_id,
'transport_mode_id', 1, 1);
3687 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->transport_mode_id,
'none');
3695 print
'<table class="nobordernopadding centpercent"><tr><td>';
3696 print $langs->trans(
"Categories");
3697 print
'<td><td class="right">';
3698 if ($usercancreate) {
3699 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.
$object->id.
'&action=edittags&token='.
newToken().
'">'.
img_edit().
'</a>';
3703 print
'</td></tr></table>';
3706 if ($action ==
'edittags') {
3707 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?facid='.
$object->id.
'">';
3708 print
'<input type="hidden" name="action" value="settags">';
3709 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3710 print $form->selectCategories(Categorie::TYPE_SUPPLIER_INVOICE,
'categories', $object);
3711 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
3714 print $form->showCategories(
$object->id, Categorie::TYPE_SUPPLIER_INVOICE, 1);
3722 if (
$object->status != $object::STATUS_DRAFT) {
3726 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3731 print
'<div class="fichehalfright">';
3732 print
'<div class="underbanner clearboth"></div>';
3734 print
'<table class="border tableforfield centpercent">';
3736 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
3739 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
3740 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3742 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3747 print
'<td>' . $langs->trans(
'AmountVAT') .
'</td>';
3748 print
'<td class="nowrap amountcard right">';
3749 if (
GETPOST(
'calculationrule')) {
3750 $calculationrule =
GETPOST(
'calculationrule',
'alpha');
3752 $calculationrule = (!
getDolGlobalString(
'MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND_SUPPLIER') ?
'totalofround' :
'roundoftotal');
3754 if ($calculationrule ==
'totalofround') {
3755 $calculationrulenum = 1;
3757 $calculationrulenum = 2;
3760 if (
$object->getVentilExportCompta() == 0) {
3761 $s =
'<span class="hideonsmartphone opacitymedium">' . $langs->trans(
"ReCalculate") .
' </span>';
3762 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&token='.newToken().
'&calculationrule=totalofround">' . $langs->trans(
"Mode1") .
'</a>';
3764 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&token='.newToken().
'&calculationrule=roundoftotal">' . ($conf->dol_optimize_smallscreen ?
"2" : $langs->trans(
"Mode2")) .
'</a>';
3765 print
'<div class="inline-block">';
3766 print $form->textwithtooltip($s, $langs->trans(
"CalculationRuleDesc", $calculationrulenum) .
'<br>' . $langs->trans(
"CalculationRuleDescSupplier"), 2, 1,
img_picto(
'',
'help',
'class="paddingleft paddingright"'),
'', 3,
'', 0,
'recalculate');
3767 print
' ';
3770 print
'<span class="nowraponall">'.price(
$object->total_tva, 1, $langs, 0, -1, -1, $conf->currency).
'</span>';
3773 print
'<td class="nowraponall amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3777 if ($societe->localtax1_assuj ==
"1") {
3779 print
'<td>' . $langs->transcountry(
"AmountLT1", $societe->country_code) .
'</td>';
3780 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 1, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3783 if ($societe->localtax2_assuj ==
"1") {
3785 print
'<td>' . $langs->transcountry(
"AmountLT2", $societe->country_code) .
'</td>';
3786 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 1, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3791 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
3792 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ttc, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3794 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3827 if ($societe->localtax1_assuj ==
"1") {
3830 if ($societe->localtax2_assuj ==
"1") {
3834 $sql =
'SELECT p.datep as dp, p.ref, p.num_paiement as num_payment, p.rowid, p.fk_bank,';
3835 $sql .=
' c.id as payment_type, c.code as payment_code,';
3836 $sql .=
' pf.amount,';
3837 $sql .=
' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal';
3838 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn as p';
3839 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
3840 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
3841 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id';
3842 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid';
3843 $sql .=
' WHERE pf.fk_facturefourn = '.((int)
$object->id);
3844 $sql .=
' ORDER BY p.datep, p.tms';
3846 $result = $db->query($sql);
3848 $num = $db->num_rows($result);
3851 print
'<div class="div-table-responsive-no-min">';
3852 print
'<table class="noborder paymenttable centpercent">';
3853 print
'<tr class="liste_titre">';
3855 print
'<td><span class="hideonsmartphone">'.$langs->trans(
'Date').
'</span></td>';
3856 print
'<td><span class="hideonsmartphone">'.$langs->trans(
'Type').
'</span></td>';
3858 print
'<td class="right">'.$langs->trans(
'BankAccount').
'</td>';
3863 print
'<td class="right">'.$langs->trans(
'Amount').
'</td>';
3868 $objp = $db->fetch_object($result);
3870 $paymentstatic->id = $objp->rowid;
3871 $paymentstatic->datepaye = $db->jdate($objp->dp);
3872 $paymentstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
3873 $paymentstatic->num_payment = $objp->num_payment;
3875 $paymentstatic->paiementcode = $objp->payment_code;
3876 $paymentstatic->type_code = $objp->payment_code;
3877 $paymentstatic->type_label = $objp->payment_type;
3879 print
'<tr class="oddeven">';
3880 print
'<td class="nowraponall">';
3881 print $paymentstatic->getNomUrl(1);
3883 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
'</td>';
3884 $s = $form->form_modes_reglement(
'', $objp->payment_type,
'none',
'', 1, 0,
'', 1).
' '.$objp->num_payment;
3885 print
'<td class="tdoverflowmax125" title="'.dol_escape_htmltag($s).
'">';
3889 $bankaccountstatic->id = $objp->baid;
3890 $bankaccountstatic->ref = $objp->baref;
3891 $bankaccountstatic->label = $objp->baref;
3892 $bankaccountstatic->number = $objp->banumber;
3895 $bankaccountstatic->account_number = $objp->account_number;
3898 $accountingjournal->fetch($objp->fk_accountancy_journal);
3899 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
3902 print
'<td class="right nowraponall">';
3903 if ($objp->baid > 0) {
3904 print $bankaccountstatic->getNomUrl(1,
'transactions');
3909 print
'<td class="center">';
3911 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deletepayment&token='.
newToken().
'&paiement_id='.$objp->rowid.
'">';
3917 print
'<td class="right">'.price($sign * $objp->amount).
'</td>';
3919 $totalpaid += $objp->amount;
3923 print
'<tr class="oddeven"><td colspan="'.$nbcols.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td>';
3949 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
3950 print
'<span class="opacitymedium">';
3952 print $langs->trans(
'AlreadyPaidNoCreditNotesNoDeposits');
3954 print $langs->trans(
'AlreadyPaid');
3959 print
'<td class="right"'.(($totalpaid > 0) ?
' class="amountalreadypaid"' :
'').
'>'.
price($totalpaid).
'</td>';
3963 $resteapayeraffiche = $resteapayer;
3965 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
3968 $creditnoteamount = 0;
3971 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
3972 $sql .=
" re.description, re.fk_invoice_supplier_source";
3973 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
3974 $sql .=
" WHERE fk_invoice_supplier = ".((int)
$object->id);
3975 $resql = $db->query($sql);
3977 $num = $db->num_rows($resql);
3981 $obj = $db->fetch_object($resql);
3982 $invoice->fetch($obj->fk_invoice_supplier_source);
3983 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3985 print $langs->trans(
"CreditNote").
' ';
3988 print $langs->trans(
"Deposit").
' ';
3990 print $invoice->getNomUrl(0);
3993 print
'<td class="right">';
3994 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=unlinkdiscount&discountid='.$obj->rowid.
'">';
3995 print
img_picto($langs->transnoentitiesnoconv(
"RemoveDiscount"),
'unlink');
3999 print
'<td class="right">'.price($obj->amount_ttc).
'</td>';
4003 $creditnoteamount += $obj->amount_ttc;
4006 $depositamount += $obj->amount_ttc;
4015 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right nowrap">';
4016 print
'<span class="opacitymedium">';
4017 print $form->textwithpicto($langs->trans(
"Discount"), $langs->trans(
"HelpEscompte"), - 1);
4021 print
'<td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td>';
4023 $resteapayeraffiche = 0;
4024 $cssforamountpaymentcomplete =
'amountpaymentneutral';
4028 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right nowrap">';
4029 print
'<span class="opacitymedium">';
4030 print $form->textwithpicto($langs->trans(
"Abandoned"), $langs->trans(
"HelpAbandonBadCustomer"), - 1);
4034 print
'<td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td>';
4037 $cssforamountpaymentcomplete =
'amountpaymentneutral';
4041 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right nowrap">';
4042 print
'<span class="opacitymedium">';
4043 print $form->textwithpicto($langs->trans(
"ProductReturned"), $langs->trans(
"HelpAbandonProductReturned"), - 1);
4047 print
'<td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td>';
4049 $resteapayeraffiche = 0;
4050 $cssforamountpaymentcomplete =
'amountpaymentneutral';
4054 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right nowrap">';
4055 $text = $langs->trans(
"HelpAbandonOther");
4057 $text .=
'<br><br><b>'.$langs->trans(
"Reason").
'</b>:'.
$object->close_note;
4059 print
'<span class="opacitymedium">';
4061 print $form->textwithpicto($langs->trans(
"Abandoned"), $text, - 1);
4065 print
'<td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td>';
4067 $resteapayeraffiche = 0;
4068 $cssforamountpaymentcomplete =
'amountpaymentneutral';
4072 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4073 print
'<span class="opacitymedium">';
4074 print $langs->trans(
"Billed");
4078 print
'<td class="right">'.price(
$object->total_ttc).
'</td>';
4082 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4083 print
'<span class="opacitymedium">';
4084 print $langs->trans(
'RemainderToPay');
4085 if ($resteapayeraffiche < 0) {
4086 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
4091 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayeraffiche).
'</td>';
4096 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4097 print
'<span class="opacitymedium">';
4098 print $langs->trans(
'RemainderToPayMulticurrency');
4099 if ($resteapayeraffiche < 0) {
4100 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
4105 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopaynoresize' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price(
price2num($multicurrency_resteapayer,
'MT'), 0, $langs, 1, -1, -1,
$object->multicurrency_code).
'</td>';
4109 $cssforamountpaymentcomplete =
'amountpaymentneutral';
4112 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4113 print $langs->trans(
'AlreadyPaidBack');
4116 print
'<td class="right">'.price($sign * $totalpaid).
'</td>';
4120 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">'.$langs->trans(
"Billed").
'</td>';
4122 print
'<td class="right">'.price($sign *
$object->total_ttc).
'</td>';
4126 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4127 print
'<span class="opacitymedium">';
4128 print $langs->trans(
'RemainderToPayBack');
4129 if ($resteapayeraffiche > 0) {
4130 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
4135 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($sign * $resteapayeraffiche).
'</td>';
4140 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4141 print
'<span class="opacitymedium">';
4142 print $langs->trans(
'RemainderToPayBackMulticurrency');
4143 if ($resteapayeraffiche > 0) {
4144 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
4149 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopaynoresize' : (
' '.$cssforamountpaymentcomplete)).
'">'.(!empty(
$object->multicurrency_code) ?
$object->multicurrency_code : $conf->currency).
' '.
price(
price2num($sign *
$object->multicurrency_tx * $resteapayeraffiche,
'MT')).
'</td>';
4165 print
'<div class="clearboth"></div><br>';
4168 $blocname =
'contacts';
4169 $title = $langs->trans(
'ContactsAddresses');
4170 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
4175 $blocname =
'notes';
4176 $title = $langs->trans(
'Notes');
4177 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
4184 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
4185 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4186 print
'<input type="hidden" name="action" value="'.(($action !=
'editline') ?
'addline' :
'updateline').
'">';
4187 print
'<input type="hidden" name="mode" value="">';
4188 print
'<input type="hidden" name="page_y" value="">';
4189 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
4190 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
4191 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
4194 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
4197 print
'<div class="div-table-responsive-no-min">';
4198 print
'<table id="tablelines" class="noborder noshadow centpercent">';
4200 global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax;
4203 $inputalsopricewithtax = 1;
4204 $senderissupplier = 2;
4205 if (
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY')) {
4206 $senderissupplier =
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY');
4211 $object->printObjectLines($action, $societe,
$mysoc, $lineid, 1);
4218 if ($action !=
'editline') {
4221 $parameters = array();
4222 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
4226 if (empty($reshook)) {
4240 if ($action !=
'presend') {
4243 print
'<div class="tabsAction">';
4245 $parameters = array();
4246 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
4248 if (empty($reshook)) {
4252 $ventilExportCompta =
$object->getVentilExportCompta();
4254 if ($ventilExportCompta == 0) {
4255 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
'Modify').
'</a>';
4257 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseDispatchedInBookkeeping").
'">'.$langs->trans(
'Modify').
'</span>';
4262 $result = $discount->fetch(0, 0,
$object->id);
4269 if (!$objectidnext &&
$object->close_code !=
'replaced' && $usercancreate) {
4270 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=reopen&token='.
newToken().
'">'.$langs->trans(
'ReOpen').
'</a>';
4272 if ($usercancreate) {
4273 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseReplacedInvoice").
'">'.$langs->trans(
'ReOpen').
'</span>';
4275 print
'<span class="butActionRefused classfortooltip">'.$langs->trans(
'ReOpen').
'</span>';
4285 if ($usercanvalidate) {
4286 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=valid&token='.
newToken().
'"';
4287 print
'>'.$langs->trans(
'Validate').
'</a>';
4289 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'"';
4290 print
'>'.$langs->trans(
'Validate').
'</a>';
4296 if (empty($user->socid)) {
4299 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'presend',
'mode' =>
'init'],
true).
'#formmailbeforetitle',
'');
4308 $langs->load(
"withdrawals");
4309 if ($resteapayer > 0) {
4310 if ($usercancreatecreditransfer) {
4311 if (!$objectidnext &&
$object->close_code !=
'replaced') {
4312 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/compta/facture/prelevement.php?facid='.
$object->id.
'&type=bank-transfer" title="'.
dol_escape_htmltag($langs->trans(
"MakeBankTransferOrder")).
'">'.$langs->trans(
"MakeBankTransferOrder").
'</a>';
4314 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseReplacedInvoice").
'">'.$langs->trans(
'MakeBankTransferOrder').
'</span>';
4326 print
'<a class="butAction" 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>';
4333 if ($resteapayer == 0) {
4334 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseRemainderToPayIsZero").
'">'.$langs->trans(
'DoPaymentBack').
'</span>';
4335 } elseif ($usercancreate) {
4336 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>';
4342 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.
newToken().
'">'.$langs->trans(
'ConvertExcessPaidToReduc').
'</a>';
4346 && (
getDolGlobalString(
'SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED') ||
$object->getSommePaiement() == 0)
4348 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.
newToken().
'" title="'.
dol_escape_htmltag($langs->trans(
"ConfirmConvertToReducSupplier2")).
'">'.$langs->trans(
'ConvertToReduc').
'</a>';
4352 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.
newToken().
'">'.$langs->trans(
'ConvertToReduc').
'</a>';
4363 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=paid&token='.
newToken().
'">'.$langs->trans(
'ClassifyPaid').
'</a>';
4368 if ($totalpaid > 0 || $totalcreditnotes > 0) {
4370 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=paid&token='.
newToken().
'">'.$langs->trans(
'ClassifyPaidPartially').
'</a>';
4373 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=canceled&token='.
newToken().
'">'.$langs->trans(
'ClassifyCanceled').
'</a>';
4385 if (!$objectidnext) {
4386 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>';
4391 if ($action !=
'edit' && $usercancreate) {
4392 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=clone&socid='.
$object->socid.
'&token='.
newToken().
'">'.$langs->trans(
'ToClone').
'</a>';
4397 if (!$objectidnext && count(
$object->lines) > 0) {
4398 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.
$object->id.
'&action=create">'.$langs->trans(
"ChangeIntoRepeatableInvoice").
'</a>';
4403 if ($action !=
'confirm_edit' && $usercandelete) {
4404 $isErasable =
$object->is_erasable();
4406 $enableDelete =
false;
4408 $params = (empty($conf->use_javascript_ajax) ? array() : array(
'attr' => array(
'class' =>
'reposition')));
4410 if ($isErasable == -4) {
4411 $htmltooltip = $langs->trans(
"DisabledBecausePayments");
4412 } elseif ($isErasable == -3) {
4413 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastSituationInvoice");
4414 } elseif ($isErasable == -2) {
4415 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastInvoice");
4416 } elseif ($isErasable == -1) {
4417 $htmltooltip = $langs->trans(
"DisabledBecauseDispatchedInBookkeeping");
4418 } elseif ($isErasable <= 0) {
4419 $htmltooltip = $langs->trans(
"DisabledBecauseNotErasable");
4421 $enableDelete =
true;
4424 print
dolGetButtonAction($htmltooltip, $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(), (
string)
$object->id, $enableDelete, $params);
4428 if ($action !=
'confirm_edit') {
4429 print
'<div class="fichecenter"><div class="fichehalfleft">';
4435 $subdir =
get_exdir(
$object->id, 2, 0, 0, $object,
'invoice_supplier').$ref;
4436 $filedir = $conf->fournisseur->facture->dir_output.
'/'.$subdir;
4437 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.
$object->id;
4438 $genallowed = $usercanread;
4439 $delallowed = $usercancreate;
4443 print $formfile->showdocuments(
'facture_fournisseur', $subdir, $filedir, $urlsource, (
int) $genallowed, (
int) $delallowed, $modelpdf, $genifempty, 0, 0, 40, 0,
'',
'',
'', $societe->default_lang);
4444 $somethingshown = $formfile->numoffiles;
4447 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'invoice_supplier'), 1);
4448 $linktoelem = $tmparray[
'linktoelem'];
4449 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
4450 print $htmltoenteralink;
4452 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
4454 print
'</div><div class="fichehalfright">';
4457 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
4459 $somethingshown = $formactions->showactions($object,
'invoice_supplier', $socid, 1,
'listaction'.($genallowed ?
'largetitle' :
''));
4461 print
'</div></div>';
4467 if (
GETPOST(
'modelselected')) {
4468 $action =
'presend';
4472 $modelmail =
'invoice_supplier_send';
4473 $defaulttopic =
'SendBillRef';
4474 $diroutput = $conf->fournisseur->facture->dir_output;
4475 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
4476 $trackid =
'sinv'.$object->id;
4478 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage bank accounts.
Class to manage accounting journals.
const TYPE_PROFORMA
Proforma invoice.
const TYPE_SITUATION
Situation invoice.
Class to manage absolute discounts.
Class to manage a WYSIWYG editor.
Class to manage warehouses.
Class to manage suppliers invoices.
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
const TYPE_REPLACEMENT
Replacement invoice.
const STATUS_VALIDATED
Validated (need to be paid)
const TYPE_STANDARD
Standard invoice.
const STATUS_ABANDONED
Classified abandoned and no payment done.
const STATUS_CLOSED
Classified paid.
Class to manage invoice templates.
Class to manage payments for supplier invoices.
Class ProductCombination Used to represent the relation between a product and one of its variants.
Class to manage predefined suppliers products.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage line invoices.
Class to manage translations.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
dol_get_last_hour($date, $gm='tzserver')
Return GMT time for last hour of a given GMT date (it replaces hours, min and second part to 23:59:59...
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0, $tz='')
Add a delay to a date.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
facturefourn_prepare_head(FactureFournisseur $object)
Prepare array with list of tabs.
dol_now($mode='gmt')
Return date for now.
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolBuildUrl($url, $params=[], $addtoken=false)
Return path of url.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that returns whether VAT must be recoverable collected VAT (e.g.: VAT NPR in France)
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dol_htmloutput_events($disabledoutputofmessages=0)
Print formatted messages to output (Used to show messages on html output).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
getDictionaryValue($tablename, $field, $id, $checkentity=false, $rowidfield='rowid')
Return the value of a filed into a dictionary for the record $id.
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular VAT rate, when selling a product with vat $vatrate,...
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.