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');
104$hookmanager->initHooks(array(
'invoicesuppliercard',
'globalcard'));
110$extrafields->fetch_name_optionals_label(
$object->table_element);
113if ($id > 0 || !empty($ref)) {
114 $ret =
$object->fetch($id, $ref);
118 $ret =
$object->fetch_thirdparty();
126if (!empty($user->socid)) {
127 $socid = $user->socid;
131$result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture',
'fk_soc',
'rowid', $isdraft);
134$usercanread = ($user->hasRight(
"fournisseur",
"facture",
"lire") || $user->hasRight(
"supplier_invoice",
"lire"));
135$usercancreate = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
136$usercandelete = (($user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"supprimer")) || ($usercancreate &&
$object->is_erasable() == 1));
137$usercancreatecontract = $user->hasRight(
"contrat",
"creer");
140$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"validate")));
141$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"send"));
142$usercancreatecreditransfer = $user->hasRight(
'paymentbybanktransfer',
'create');
145$permissionnote = $usercancreate;
146$permissiondellink = $usercancreate;
147$permissiontoedit = $usercancreate;
148$permissiontoadd = $usercancreate;
149$permissiontodelete = $usercandelete;
150$permissiontoeditextra = $permissiontoadd;
151if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
153 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
164$parameters = array(
'socid' => $socid);
165$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
170if (empty($reshook)) {
171 $backurlforlist =
dolBuildUrl(DOL_URL_ROOT.
'/fourn/facture/list.php');
173 if (empty($backtopage) || ($cancel && empty($id))) {
174 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
175 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
176 $backtopage = $backurlforlist;
178 $backtopage =
dolBuildUrl(DOL_URL_ROOT.
'/fourn/facture/card.php', [
'id' => ((!empty($id) && $id > 0) ? $id :
'__ID__')]);
184 if (!empty($backtopageforcancel)) {
185 header(
"Location: ".$backtopageforcancel);
187 } elseif (!empty($backtopage)) {
188 header(
"Location: ".$backtopage);
194 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
196 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
198 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
201 if (
GETPOST(
'linkedOrder') && empty($cancel) && $id > 0 && $permissiontoadd) {
204 $result =
$object->add_object_linked(
'order_supplier',
GETPOSTINT(
'linkedOrder'));
208 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
210 '@phan-var-force FactureFournisseur $objectutil';
212 if (
GETPOST(
'newsupplierref',
'alphanohtml')) {
213 $objectutil->ref_supplier =
GETPOST(
'newsupplierref',
'alphanohtml');
217 $result = $objectutil->createFromClone($user, $id);
219 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
222 $langs->load(
"errors");
226 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' && $usercanvalidate) {
227 $idwarehouse =
GETPOST(
'idwarehouse');
232 $qualified_for_stock_change = 0;
234 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
236 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
241 $langs->load(
"stocks");
242 if (!$idwarehouse || $idwarehouse == -1) {
244 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
252 $result =
$object->validate($user,
'', $idwarehouse);
259 $categories =
GETPOST(
'categories',
'array:int');
260 if (method_exists($object,
'setCategories')) {
261 $object->setCategories($categories);
269 $outputlangs = $langs;
272 $newlang =
GETPOST(
'lang_id',
'aZ09');
275 $newlang =
$object->thirdparty->default_lang;
277 if (!empty($newlang)) {
279 $outputlangs->setDefaultLang($newlang);
284 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
291 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontodelete) {
295 $isErasable =
$object->is_erasable();
297 if ($usercandelete && $isErasable > 0) {
298 $revertstock =
GETPOST(
'revertstock');
303 $qualified_for_stock_change = 0;
305 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
307 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
312 $langs->load(
"stocks");
313 if (!$idwarehouse || $idwarehouse == -1) {
315 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
318 $result =
$object->setDraft($user, $idwarehouse);
327 $result =
$object->delete($user);
329 header(
'Location: list.php?restore_lastsearch_values=1');
336 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
338 $result =
$object->deleteLine($lineid);
358 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
365 } elseif ($action ==
'unlinkdiscount' && $usercancreate) {
368 $result = $discount->fetch(
GETPOSTINT(
"discountid"));
369 $discount->unlink_invoice();
370 } elseif ($action ==
'confirm_paid' && $confirm ==
'yes' && $usercancreate) {
372 $result =
$object->setPaid($user);
376 } elseif ($action ==
'confirm_paid_partially' && $confirm ==
'yes' && $usercancreate) {
379 $close_code =
GETPOST(
"close_code",
'restricthtml');
380 $close_note =
GETPOST(
"close_note",
'restricthtml');
382 $result =
$object->setPaid($user, $close_code, $close_note);
387 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Reason")),
null,
'errors');
389 } elseif ($action ==
'confirm_canceled' && $confirm ==
'yes' && $usercancreate) {
392 $close_code =
GETPOST(
"close_code",
'restricthtml');
393 $close_note =
GETPOST(
"close_note",
'restricthtml');
395 $result =
$object->setCanceled($user, $close_code, $close_note);
400 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Reason")),
null,
'errors');
405 if ($action ==
'setref_supplier' && $usercancreate) {
408 if (
$object->update($user) < 0) {
412 $outputlangs = $langs;
415 $newlang =
GETPOST(
'lang_id',
'aZ09');
418 $newlang =
$object->thirdparty->default_lang;
420 if (!empty($newlang)) {
422 $outputlangs->setDefaultLang($newlang);
426 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
432 if ($action ==
'setconditions' && $usercancreate) {
434 $object->cond_reglement_code = 0;
435 $object->cond_reglement_id = 0;
450 $new_date_echeance =
$object->calculate_date_lim_reglement();
451 if ($new_date_echeance) {
452 $object->date_echeance = $new_date_echeance;
457 $result =
$object->update($user);
469 } elseif ($action ==
'set_incoterms' &&
isModEnabled(
'incoterm') && $usercancreate) {
472 } elseif ($action ==
'settags' &&
isModEnabled(
'category') && $usercancreate) {
475 } elseif ($action ==
'setmode' && $usercancreate) {
478 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
480 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
481 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
484 } elseif ($action ==
'setbankaccount' && $usercancreate) {
487 } elseif ($action ==
'setvatreversecharge' && $usercancreate) {
489 $vatreversecharge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
490 $result =
$object->setVATReverseCharge($vatreversecharge);
493 if ($action ==
'settransportmode' && $usercancreate) {
496 } elseif ($action ==
'setlabel' && $usercancreate) {
500 $result =
$object->update($user);
504 } elseif ($action ==
'setdatef' && $usercancreate) {
508 setEventMessages($langs->trans(
"WarningInvoiceDateInFuture"),
null,
'warnings');
510 setEventMessages($langs->trans(
"WarningInvoiceDateTooFarInFuture"),
null,
'warnings');
517 $date_echence_calc =
$object->calculate_date_lim_reglement();
518 if (!empty(
$object->date_echeance)) {
519 $object->date_echeance = $date_echence_calc;
525 $result =
$object->update($user);
529 } elseif ($action ==
'setdate_lim_reglement' && $usercancreate) {
534 setEventMessages($langs->trans(
"DatePaymentTermCantBeLowerThanObjectDate"),
null,
'warnings');
536 $result =
$object->update($user);
540 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
556 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
558 $discount->fetch(
GETPOSTINT(
"remise_id_for_payment"));
562 $remaintopay =
$object->getRemainToPay(0);
566 setEventMessages($langs->trans(
"ErrorDiscountLargerThanRemainToPaySplitItBefore"),
null,
'errors');
570 $result = $discount->link_to_invoice(0, $id);
577 $newremaintopay =
$object->getRemainToPay(0);
578 if ($newremaintopay == 0) {
589 $outputlangs = $langs;
592 $newlang =
GETPOST(
'lang_id',
'aZ09');
595 $newlang =
$object->thirdparty->default_lang;
597 if (!empty($newlang)) {
599 $outputlangs->setDefaultLang($newlang);
603 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
608 } elseif ($action ==
'confirm_converttoreduc' && $confirm ==
'yes' && $usercancreate) {
616 $result = $discountcheck->fetch(0, 0,
$object->id);
628 $amount_ht = $amount_tva = $amount_ttc = array();
629 $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array();
633 foreach (
$object->lines as $line) {
634 if ($line->product_type < 9 && $line->total_ht != 0) {
635 $keyforvatrate = $line->tva_tx.($line->vat_src_code ?
' ('.$line->vat_src_code.
')' :
'');
637 $amount_ht[$keyforvatrate] += $line->total_ht;
638 $amount_tva[$keyforvatrate] += $line->total_tva;
639 $amount_ttc[$keyforvatrate] += $line->total_ttc;
640 $multicurrency_amount_ht[$keyforvatrate] += $line->multicurrency_total_ht;
641 $multicurrency_amount_tva[$keyforvatrate] += $line->multicurrency_total_tva;
642 $multicurrency_amount_ttc[$keyforvatrate] += $line->multicurrency_total_ttc;
646 '@phan-var-force array<string,float> $amount_ht
647 @phan-var-force array<string,float> $amount_tva
648 @phan-var-force array<string,float> $amount_ttc
649 @phan-var-force array<string,float> $multicurrency_amount_ht
650 @phan-var-force array<string,float> $multicurrency_amount_tva
651 @phan-var-force array<string,float> $multicurrency_amount_ttc';
655 $alreadypaid =
$object->getSommePaiement();
656 if ($alreadypaid && abs($alreadypaid) < abs(
$object->total_ttc)) {
657 $ratio = abs((
$object->total_ttc - $alreadypaid) /
$object->total_ttc);
658 foreach ($amount_ht as $vatrate => $val) {
659 $amount_ht[$vatrate] =
price2num($amount_ht[$vatrate] * $ratio,
'MU');
660 $amount_tva[$vatrate] =
price2num($amount_tva[$vatrate] * $ratio,
'MU');
661 $amount_ttc[$vatrate] =
price2num($amount_ttc[$vatrate] * $ratio,
'MU');
662 $multicurrency_amount_ht[$vatrate] =
price2num($multicurrency_amount_ht[$vatrate] * $ratio,
'MU');
663 $multicurrency_amount_tva[$vatrate] =
price2num($multicurrency_amount_tva[$vatrate] * $ratio,
'MU');
664 $multicurrency_amount_ttc[$vatrate] =
price2num($multicurrency_amount_ttc[$vatrate] * $ratio,
'MU');
673 $discount->description =
'(CREDIT_NOTE)';
675 $discount->description =
'(DEPOSIT)';
677 $discount->description =
'(EXCESS PAID)';
679 setEventMessages($langs->trans(
'CantConvertToReducAnInvoiceOfThisType'),
null,
'errors');
681 $discount->discount_type = 1;
682 $discount->fk_soc =
$object->socid;
683 $discount->socid =
$object->socid;
684 $discount->fk_invoice_supplier_source =
$object->id;
692 $sql =
'SELECT SUM(pf.amount) as total_paiements';
693 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.
'paiementfourn as p';
694 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN ('.
getEntity(
'c_paiement').
')';
695 $sql .=
' WHERE pf.fk_facturefourn = '.((int)
$object->id);
696 $sql .=
' AND pf.fk_paiementfourn = p.rowid';
697 $sql .=
' AND p.entity IN ('.getEntity(
'invoice').
')';
699 $resql =
$db->query($sql);
704 $res =
$db->fetch_object($resql);
705 $total_paiements = $res->total_paiements;
708 $total_creditnote_and_deposit = 0;
709 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
710 $sql .=
" re.description, re.fk_invoice_supplier_source";
711 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
712 $sql .=
" WHERE fk_invoice_supplier = ".((int)
$object->id);
713 $resql =
$db->query($sql);
714 if (!empty($resql)) {
715 while ($obj =
$db->fetch_object($resql)) {
716 $total_creditnote_and_deposit += $obj->amount_ttc;
722 $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit -
$object->total_ttc;
723 $discount->amount_tva = 0;
724 $discount->tva_tx = 0;
725 $discount->vat_src_code =
'';
727 $result = $discount->create($user);
733 foreach ($amount_ht as $tva_tx => $xxx) {
734 $discount->amount_ht = abs((
float) $amount_ht[$tva_tx]);
735 $discount->amount_tva = abs((
float) $amount_tva[$tva_tx]);
736 $discount->amount_ttc = abs((
float) $amount_ttc[$tva_tx]);
737 $discount->multicurrency_amount_ht = abs((
float) $multicurrency_amount_ht[$tva_tx]);
738 $discount->multicurrency_amount_tva = abs((
float) $multicurrency_amount_tva[$tva_tx]);
739 $discount->multicurrency_amount_ttc = abs((
float) $multicurrency_amount_ttc[$tva_tx]);
744 if (preg_match(
'/\((.*)\)/', $tva_tx, $reg)) {
745 $vat_src_code = $reg[1];
746 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx);
749 $discount->tva_tx = abs((
float) $tva_tx);
750 $discount->vat_src_code = $vat_src_code;
752 $result = $discount->create($user);
763 $result =
$object->setPaid($user);
778 } elseif ($action ==
'confirm_delete_paiement' && $confirm ==
'yes' && $usercancreate) {
783 $result = $paiementfourn->fetch(
GETPOSTINT(
'paiement_id'));
785 $result = $paiementfourn->delete($user);
787 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
795 } elseif ($action ==
'add' && $usercancreate) {
800 $selectedLines =
GETPOST(
'toselect',
'array:int');
808 $ret = $extrafields->setOptionalsFromPost(
null, $object);
822 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
827 if (empty($dateinvoice)) {
828 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
840 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ReplaceInvoice")),
null,
'errors');
854 $object->date_echeance = $datedue;
860 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
861 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
863 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
864 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
885 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CorrectInvoice")),
null,
'errors');
888 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Supplier')),
null,
'errors');
893 if (empty($dateinvoice)) {
894 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
904 if (!
GETPOST(
'ref_supplier')) {
905 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'RefSupplierBill')),
null,
'errors');
913 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
928 $object->date_echeance = $datedue;
934 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
935 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
937 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
938 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
943 $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice :
'';
952 if (
GETPOSTINT(
'invoiceAvoirWithLines') == 1 && $id > 0) {
954 if ($facture_source->fetch(
$object->fk_facture_source) > 0) {
957 foreach ($facture_source->lines as $line) {
959 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
963 $line->fk_facture_fourn =
$object->id;
964 $line->fk_parent_line = $fk_parent_line;
966 $line->subprice = -$line->subprice;
967 $line->pa_ht = -((float) $line->pa_ht);
968 $line->total_ht = -$line->total_ht;
969 $line->total_tva = -$line->total_tva;
970 $line->total_ttc = -$line->total_ttc;
971 $line->total_localtax1 = -$line->total_localtax1;
972 $line->total_localtax2 = -$line->total_localtax2;
973 $line->multicurrency_total_ht = -$line->multicurrency_total_ht;
974 $line->multicurrency_total_tva = -$line->multicurrency_total_tva;
975 $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc;
977 $result = $line->insert();
982 if ($result > 0 && $line->product_type == 9) {
983 $fk_parent_line = $result;
991 if (
GETPOSTINT(
'invoiceAvoirWithPaymentRestAmount') == 1 &&
$id > 0) {
993 if ($facture_source->fetch(
$object->fk_facture_source) > 0) {
994 $totalpaid = $facture_source->getSommePaiement();
995 $totalcreditnotes = $facture_source->getSumCreditNotesUsed();
996 $totaldeposits = $facture_source->getSumDepositsUsed();
997 $remain_to_pay = abs($facture_source->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits);
998 $desc = $langs->trans(
'invoiceAvoirLineWithPaymentRestAmount');
999 $retAddLine =
$object->addline($desc, $remain_to_pay, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
'TTC');
1001 if ($retAddLine < 0) {
1009 if (empty($dateinvoice)) {
1011 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
1021 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
1031 $object->note_public = trim(
GETPOST(
'note_public',
'restricthtml'));
1032 $object->note_private = trim(
GETPOST(
'note_private',
'restricthtml'));
1041 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
1042 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
1046 $object->fac_rec = $fac_recid;
1048 $fac_rec->fetch(
$object->fac_rec);
1049 $fac_rec->fetch_lines();
1050 $object->lines = $fac_rec->lines;
1057 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Supplier')),
null,
'errors');
1062 if (empty($dateinvoice)) {
1063 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
1073 if (!
GETPOST(
'ref_supplier')) {
1074 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'RefSupplierBill')),
null,
'errors');
1082 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
1099 $object->date_echeance = $datedue;
1105 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
1106 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
1108 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
1109 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
1114 if (empty(
$object->date_echeance)) {
1115 $object->date_echeance =
$object->calculate_date_lim_reglement();
1121 if (!$error &&
GETPOST(
'origin',
'alpha') &&
GETPOST(
'originid')) {
1123 $element = $subelement =
GETPOST(
'origin',
'alpha');
1131 if ($element ==
'order') {
1132 $element = $subelement =
'commande';
1134 if ($element ==
'propal') {
1135 $element =
'comm/propal';
1136 $subelement =
'propal';
1138 if ($element ==
'contract') {
1139 $element = $subelement =
'contrat';
1141 if ($element ==
'order_supplier') {
1143 $subelement =
'fournisseur.commande';
1145 if ($element ==
'project') {
1146 $element =
'projet';
1154 $classname = ucfirst($subelement);
1155 if ($classname ==
'Fournisseur.commande') {
1156 $classname =
'CommandeFournisseur';
1158 $objectsrc =
new $classname(
$db);
1159 $objectsrc->fetch($originid);
1160 $objectsrc->fetch_thirdparty();
1162 if (!empty(
$object->origin_type) && !empty(
$object->origin_id)) {
1167 if (
$object->origin_type ==
'reception') {
1168 $objectsrc->fetchObjectLinked();
1170 if (count($objectsrc->linkedObjectsIds[
'order_supplier']) > 0) {
1171 foreach ($objectsrc->linkedObjectsIds[
'order_supplier'] as $key => $value) {
1172 $object->linkedObjectsIds[
'order_supplier'][-1] = $value;
1182 $classname = ucfirst($subelement);
1183 if ($classname ==
'Fournisseur.commande') {
1184 $classname =
'CommandeFournisseur';
1186 $srcobject =
new $classname(
$db);
1188 $result = $srcobject->fetch(
GETPOSTINT(
'originid'));
1191 $typeamount =
GETPOST(
'typedeposit',
'alpha');
1196 $amountdeposit = array();
1198 if ($typeamount ==
'amount') {
1199 $amount = $valuedeposit;
1201 $amount = $srcobject->total_ttc * ((float) $valuedeposit / 100);
1204 $TTotalByTva = array();
1205 foreach ($srcobject->lines as &$line) {
1206 if (!empty($line->special_code)) {
1209 $TTotalByTva[$line->tva_tx] += $line->total_ttc;
1211 '@phan-var-force array<string,float> $TTotalByTva';
1213 $amount_ttc_diff = 0.;
1214 foreach ($TTotalByTva as $tva => &$total) {
1215 $coef = $total / $srcobject->total_ttc;
1216 $am = $amount * $coef;
1217 $amount_ttc_diff += $am;
1218 $amountdeposit[$tva] += $am / (1 + (float) $tva / 100);
1221 if ($typeamount ==
'amount') {
1222 $amountdeposit[0] = $valuedeposit;
1223 } elseif ($typeamount ==
'variable') {
1226 $lines = $srcobject->lines;
1227 $numlines = count($lines);
1228 for ($i = 0; $i < $numlines; $i++) {
1230 if (empty($lines[$i]->qty)) {
1233 if (!empty($lines[$i]->special_code)) {
1237 $totalamount += $lines[$i]->total_ht;
1238 $tva_tx = $lines[$i]->tva_tx;
1239 $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * (float) $valuedeposit) / 100;
1243 if ($totalamount == 0) {
1244 $amountdeposit[0] = 0;
1249 $amountdeposit[0] = 0;
1253 $amount_ttc_diff = array_key_exists(0, $amountdeposit) ? $amountdeposit[0] : 0;
1256 foreach ($amountdeposit as $tva => $amount) {
1257 if (empty($amount)) {
1262 'amount' =>
'FixAmount',
1263 'variable' =>
'VarAmount'
1265 $descline =
'(DEPOSIT)';
1267 if ($typeamount ==
'amount') {
1268 $descline .=
' ('.price($valuedeposit, 0, $langs, 0, - 1, - 1, (!empty(
$object->multicurrency_code) ?
$object->multicurrency_code :
$conf->currency)).
')';
1269 } elseif ($typeamount ==
'variable') {
1270 $descline .=
' ('.$valuedeposit.
'%)';
1273 $descline .=
' - '.$srcobject->ref;
1303 $diff =
$object->total_ttc - $amount_ttc_diff;
1307 $subprice_diff =
$object->lines[0]->subprice - $diff / (1 +
$object->lines[0]->tva_tx / 100);
1313 $object->lines[0]->localtax1_tx,
1314 $object->lines[0]->localtax2_tx,
1316 $object->lines[0]->fk_product,
1319 $object->lines[0]->product_type,
1320 $object->lines[0]->remise_percent,
1322 $object->lines[0]->date_start,
1331 } elseif ($result > 0) {
1332 $lines = $srcobject->lines;
1333 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
1334 $srcobject->fetch_lines();
1335 $lines = $srcobject->lines;
1338 $num = count($lines);
1339 for ($i = 0; $i < $num; $i++) {
1340 if (!in_array($lines[$i]->
id, $selectedLines)) {
1344 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->product_label);
1345 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
1348 if (method_exists($lines[$i],
'fetch_optionals')) {
1349 $lines[$i]->fetch_optionals();
1355 if ($lines[$i]->date_debut_reel) {
1358 if ($lines[$i]->date_start) {
1361 $date_end = $lines[$i]->date_fin_prevue;
1362 if ($lines[$i]->date_fin_reel) {
1363 $date_end = $lines[$i]->date_fin_reel;
1365 if ($lines[$i]->date_end) {
1366 $date_end = $lines[$i]->date_end;
1369 $tva_tx = $lines[$i]->tva_tx;
1371 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', (
string) $tva_tx)) {
1372 $tva_tx .=
' ('.$lines[$i]->vat_src_code.
')';
1376 $object->special_code = $lines[$i]->special_code;
1381 $pu_currency = $lines[$i]->multicurrency_subprice;
1383 $pu = $lines[$i]->subprice;
1392 $lines[$i]->localtax1_tx,
1393 $lines[$i]->localtax2_tx,
1395 $lines[$i]->fk_product,
1396 $lines[$i]->remise_percent,
1400 $lines[$i]->info_bits,
1405 $lines[$i]->array_options,
1406 $lines[$i]->fk_unit,
1409 $lines[$i]->ref_supplier,
1410 $lines[$i]->special_code
1427 $parameters = array(
'objFrom' => $srcobject);
1428 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $object, $action);
1438 } elseif (!$error) {
1448 $langs->load(
"errors");
1458 $outputlangs = $langs;
1459 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1466 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
1469 } elseif ($action ==
'updateline' && $usercancreate) {
1473 if (!
$object->fetch($id) > 0) {
1479 $tva_tx = str_replace(
'*',
'', $tva_tx);
1481 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_subprice') !=
'') {
1483 $price_base_type =
'HT';
1486 $price_base_type =
'TTC';
1489 if (
GETPOST(
'productid') > 0) {
1491 if (
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY') == 1) {
1493 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1499 $label =
$prod->description;
1500 if (trim(
GETPOST(
'product_desc',
'restricthtml')) != trim($label)) {
1501 $label =
GETPOST(
'product_desc',
'restricthtml');
1504 $type =
$prod->type;
1506 $label =
GETPOST(
'product_desc',
'restricthtml');
1515 if (preg_match(
'/\*/', $tva_tx)) {
1520 $tva_tx = str_replace(
'*',
'', $tva_tx);
1528 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1529 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1531 if (is_array($extralabelsline)) {
1532 foreach ($extralabelsline as $key => $value) {
1533 unset($_POST[
"options_".$key]);
1537 $result =
$object->updateline(
1549 (
float) $remise_percent,
1559 unset($_POST[
'label']);
1560 unset($_POST[
'fourn_ref']);
1561 unset($_POST[
'date_starthour']);
1562 unset($_POST[
'date_startmin']);
1563 unset($_POST[
'date_startsec']);
1564 unset($_POST[
'date_startday']);
1565 unset($_POST[
'date_startmonth']);
1566 unset($_POST[
'date_startyear']);
1567 unset($_POST[
'date_endhour']);
1568 unset($_POST[
'date_endmin']);
1569 unset($_POST[
'date_endsec']);
1570 unset($_POST[
'date_endday']);
1571 unset($_POST[
'date_endmonth']);
1572 unset($_POST[
'date_endyear']);
1573 unset($_POST[
'price_ttc']);
1574 unset($_POST[
'price_ht']);
1581 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') && (
GETPOST(
'alldate_start',
'alpha') ||
GETPOST(
'alldate_end',
'alpha')) && $usercancreate) {
1585 foreach (
$object->lines as $line) {
1586 if ($line->product_type == 1) {
1587 $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);
1590 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'alpha') &&
GETPOST(
'remiseforalllines',
'alpha') !==
'' && $usercancreate) {
1592 $remise_percent = (
GETPOST(
'remiseforalllines') ?
GETPOST(
'remiseforalllines') : 0);
1593 $remise_percent = (float) str_replace(
'*',
'', $remise_percent);
1594 foreach (
$object->lines as $line) {
1595 $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, $remise_percent, 0, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice, $line->ref_supplier, $line->rang);
1597 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') !=
'' && $usercancreate) {
1599 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
1600 $vat_rate = str_replace(
'*',
'', $vat_rate);
1603 foreach (
$object->lines as $line) {
1604 $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);
1606 } elseif ($action ==
'addline' && $usercancreate) {
1615 $ret =
$object->fetch_thirdparty();
1617 $langs->load(
'errors');
1622 $line_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
1626 $prod_entry_mode =
GETPOST(
'prod_entry_mode');
1627 if ($prod_entry_mode ==
'free') {
1634 $price_ht_devise =
'';
1636 $price_ttc_devise =
'';
1638 if (
GETPOST(
'price_ht') !==
'') {
1641 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
1644 if (
GETPOST(
'price_ttc') !==
'') {
1647 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
1648 $price_ttc_devise =
price2num(
GETPOST(
'multicurrency_price_ttc'),
'CU', 2);
1655 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef,
'alpha'),
'', 2) : 0);
1656 if (empty($remise_percent)) {
1657 $remise_percent = 0;
1661 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1662 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1664 if (is_array($extralabelsline)) {
1666 foreach ($extralabelsline as $key => $value) {
1667 unset($_POST[
"options_".$key]);
1671 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
1672 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1675 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') &&
GETPOSTINT(
'type') < 0) {
1676 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
1681 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1')
1682 && (((
float) $price_ht < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) || $price_ht ===
'')
1683 && (((
float) $price_ht_devise < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) || $price_ht_devise ===
'')
1684 && ((
float) $price_ttc < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES') || $price_ttc ===
'')
1685 && ((
float) $price_ttc_devise < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES') || $price_ttc_devise ===
'')
1686 &&
$object->type != $object::TYPE_CREDIT_NOTE) {
1687 if (((
float) $price_ht < 0 || (
float) $price_ttc < 0) && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) {
1688 $langs->load(
"errors");
1689 if (
$object->type == $object::TYPE_DEPOSIT) {
1691 setEventMessages($langs->trans(
"ErrorLinesCantBeNegativeOnDeposits"),
null,
'errors');
1693 setEventMessages($langs->trans(
"ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv(
"UnitPrice"), $langs->transnoentitiesnoconv(
"CustomerAbsoluteDiscountShort")),
null,
'errors');
1698 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' && $price_ht_devise ===
'') {
1699 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'UnitPrice')),
null,
'errors');
1703 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') && !
GETPOST(
'dp_desc')) {
1704 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
1707 if (!
GETPOST(
'qty',
'alpha')) {
1708 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1712 if (!$error &&
isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1713 if ($combinations =
GETPOST(
'combinations',
'array:alphanohtml')) {
1717 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1718 $idprod = $res->fk_product_child;
1720 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1726 if ($prod_entry_mode !=
'free' && empty($error)) {
1730 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
1735 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
1736 $idprod = (int) $reg[1];
1737 $res = $productsupplier->fetch($idprod);
1740 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
1742 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1743 if ($productsupplier->fourn_socid != $socid) {
1744 $productsupplier->ref_supplier =
'';
1747 $fksoctosearch =
$object->thirdparty->id;
1748 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1750 } elseif (
GETPOSTINT(
'idprodfournprice') > 0) {
1751 $qtytosearch = (float) $qty;
1753 $idprod = $productsupplier->get_buyprice(
GETPOSTINT(
'idprodfournprice'), $qtytosearch);
1754 $res = $productsupplier->fetch($idprod);
1758 $label = $productsupplier->label;
1761 $outputlangs = $langs;
1763 if (
GETPOST(
'lang_id',
'aZ09')) {
1764 $newlang =
GETPOST(
'lang_id',
'aZ09');
1766 if (empty($newlang)) {
1767 $newlang =
$object->thirdparty->default_lang;
1769 if (!empty($newlang)) {
1771 $outputlangs->setDefaultLang($newlang);
1773 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->
description;
1775 $desc = $productsupplier->description;
1778 if (!empty($productsupplier->desc_supplier) &&
getDolGlobalString(
'PRODUIT_FOURN_TEXTS')) {
1779 $desc = $productsupplier->desc_supplier;
1790 $ref_supplier = $productsupplier->ref_supplier;
1793 if (!GETPOSTISSET(
'tva_tx')) {
1794 $tmpidprodfournprice =
GETPOST(
'idprodfournprice',
'alpha');
1795 if (is_numeric($tmpidprodfournprice) && (
int) $tmpidprodfournprice > 0) {
1796 $tmpidprodfournprice = (int) $tmpidprodfournprice;
1798 $tmpidprodfournprice = 0;
1804 if (empty($tva_tx) || empty($tva_npr)) {
1810 $type = $productsupplier->type;
1811 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1812 $price_base_type =
'HT';
1814 $pu_devise =
price2num($price_ht_devise,
'CU');
1815 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
1816 $price_base_type =
'TTC';
1818 $pu_devise =
price2num($price_ttc_devise,
'CU');
1820 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
1821 if (empty(
$object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code !=
$object->multicurrency_code)) {
1822 $pu = $productsupplier->fourn_pu;
1825 $pu = $productsupplier->fourn_pu;
1826 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
1830 $ref_supplier = $productsupplier->ref_supplier;
1851 min($rank, count(
$object->lines) + 1),
1854 $productsupplier->fk_unit,
1857 GETPOST(
'fourn_ref',
'alpha'),
1861 if ($idprod == -99 || $idprod == 0) {
1864 $langs->load(
"errors");
1865 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
1867 if ($idprod == -1) {
1870 $langs->load(
"errors");
1871 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
1873 } elseif (empty($error)) {
1874 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1875 $tva_tx = str_replace(
'*',
'', $tva_tx);
1876 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1879 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1883 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
1891 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1895 $pu_ht =
price2num((
float) $pu_ttc / (1 + ((
float) $tva_tx / 100)),
'MU');
1897 $price_base_type =
'HT';
1898 $pu_devise =
price2num($price_ht_devise,
'CU');
1900 $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);
1904 if (!$error && $result > 0) {
1909 $outputlangs = $langs;
1912 $newlang =
GETPOST(
'lang_id',
'aZ09');
1915 $newlang =
$object->thirdparty->default_lang;
1917 if (!empty($newlang)) {
1919 $outputlangs->setDefaultLang($newlang);
1924 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1930 unset($_POST [
'prod_entry_mode']);
1932 unset($_POST[
'qty']);
1933 unset($_POST[
'type']);
1934 unset($_POST[
'remise_percent']);
1935 unset($_POST[
'pu']);
1936 unset($_POST[
'price_ht']);
1937 unset($_POST[
'multicurrency_price_ht']);
1938 unset($_POST[
'price_ttc']);
1939 unset($_POST[
'fourn_ref']);
1940 unset($_POST[
'tva_tx']);
1941 unset($_POST[
'label']);
1942 unset($localtax1_tx);
1943 unset($localtax2_tx);
1944 unset($_POST[
'np_marginRate']);
1945 unset($_POST[
'np_markRate']);
1946 unset($_POST[
'dp_desc']);
1947 unset($_POST[
'idprodfournprice']);
1948 unset($_POST[
'units']);
1950 unset($_POST[
'date_starthour']);
1951 unset($_POST[
'date_startmin']);
1952 unset($_POST[
'date_startsec']);
1953 unset($_POST[
'date_startday']);
1954 unset($_POST[
'date_startmonth']);
1955 unset($_POST[
'date_startyear']);
1956 unset($_POST[
'date_endhour']);
1957 unset($_POST[
'date_endmin']);
1958 unset($_POST[
'date_endsec']);
1959 unset($_POST[
'date_endday']);
1960 unset($_POST[
'date_endmonth']);
1961 unset($_POST[
'date_endyear']);
1968 } elseif ($action ==
'classin' && $usercancreate) {
1970 $result =
$object->setProject($projectid);
1971 } elseif ($action ==
'confirm_edit' && $confirm ==
'yes' && $usercancreate) {
1975 $totalpaid =
$object->getSommePaiement();
1976 $resteapayer =
$object->total_ttc - $totalpaid;
1979 $ventilExportCompta =
$object->getVentilExportCompta();
1981 if (!$ventilExportCompta) {
1984 $idwarehouse =
GETPOST(
'idwarehouse');
1988 $qualified_for_stock_change = 0;
1990 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1992 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
1997 $langs->load(
"stocks");
1998 if (!$idwarehouse || $idwarehouse == -1) {
2000 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
2005 $object->setDraft($user, $idwarehouse);
2009 $outputlangs = $langs;
2012 $newlang =
GETPOST(
'lang_id',
'aZ09');
2015 $newlang =
$object->thirdparty->default_lang;
2017 if (!empty($newlang)) {
2019 $outputlangs->setDefaultLang($newlang);
2024 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
2033 } elseif ($action ==
'reopen' && $usercancreate) {
2035 $result =
$object->fetch($id);
2038 $result =
$object->setUnpaid($user);
2040 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
2049 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
2052 $triggersendname =
'BILL_SUPPLIER_SENTBYMAIL';
2054 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
2055 $trackid =
'sinv'.$object->id;
2056 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
2060 $permissiontoadd = $usercancreate;
2061 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
2064 if ($action ==
'calculate' && $usercancreate) {
2065 $calculationrule =
GETPOST(
'calculationrule');
2069 $result =
$object->update_price(0, (($calculationrule ==
'totalofround') ?
'0' :
'1'), 0,
$object->thirdparty);
2075 if ($action ==
'update_extras' && $permissiontoeditextra) {
2078 $attribute_name =
GETPOST(
'attribute',
'aZ09');
2081 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
2087 $result =
$object->updateExtraField($attribute_name,
'BILL_SUPPLIER_MODIFY');
2095 $action =
'edit_extras';
2100 if ($action ==
'addcontact' && $usercancreate) {
2101 $result =
$object->fetch($id);
2103 if ($result > 0 && $id > 0) {
2106 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
2110 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2113 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2114 $langs->load(
"errors");
2115 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
2120 } elseif ($action ==
'swapstatut' && $usercancreate) {
2127 } elseif ($action ==
'deletecontact' && $usercancreate) {
2133 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2157$title =
$object->ref.
" - ".$langs->trans(
'Card');
2158if ($action ==
'create') {
2159 $title = $langs->trans(
"NewSupplierInvoice");
2161$help_url =
'EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores|DE:Modul_Lieferantenrechnungen';
2162llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-fourn-facture page-card');
2165if ($action ==
'create') {
2167 $selectedLines = array();
2169 print
load_fiche_titre($langs->trans(
'NewSupplierInvoice'),
'',
'supplier_invoice');
2173 $currency_code =
$conf->currency;
2174 $vat_reverse_charge = 0;
2180 if (
isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2181 $currency_code = $societe->multicurrency_code;
2186 if (!empty($origin) && !empty($originid)) {
2188 $element = $subelement = $origin;
2190 if ($element ==
'project') {
2191 $projectid = $originid;
2192 $element =
'projet';
2196 if ($element ==
'order') {
2197 $element = $subelement =
'commande';
2199 if ($element ==
'propal') {
2200 $element =
'comm/propal';
2201 $subelement =
'propal';
2203 if ($element ==
'contract') {
2204 $element = $subelement =
'contrat';
2206 if ($element ==
'order_supplier') {
2208 $subelement =
'fournisseur.commande';
2212 $classname = ucfirst($subelement);
2213 if ($classname ==
'Fournisseur.commande') {
2214 $classname =
'CommandeFournisseur';
2216 $objectsrc =
new $classname(
$db);
2217 '@phan-var-force Project|Commande|Propal|Facture|Contrat|CommandeFournisseur|CommonObject $objectsrc';
2219 $objectsrc->fetch($originid);
2220 $objectsrc->fetch_thirdparty();
2222 $projectid = (int) $objectsrc->fk_project;
2224 $soc = $objectsrc->thirdparty;
2226 $cond_reglement_id = 0;
2227 $mode_reglement_id = 0;
2229 $transport_mode_id = 0;
2232 if (!empty($objectsrc->cond_reglement_id)) {
2233 $cond_reglement_id = $objectsrc->cond_reglement_id;
2235 if (!empty($objectsrc->mode_reglement_id)) {
2236 $mode_reglement_id = $objectsrc->mode_reglement_id;
2238 if (!empty($objectsrc->fk_account)) {
2239 $fk_account = $objectsrc->fk_account;
2241 if (!empty($objectsrc->transport_mode_id)) {
2242 $transport_mode_id = $objectsrc->transport_mode_id;
2245 if (empty($cond_reglement_id)
2246 || empty($mode_reglement_id)
2247 || empty($fk_account)
2248 || empty($transport_mode_id)
2250 if ($origin ==
'reception') {
2252 if (!isset($objectsrc->supplier_order)) {
2253 $objectsrc->fetch_origin();
2256 if (!empty($objectsrc->origin_object)) {
2257 $originObject = $objectsrc->origin_object;
2258 if (empty($cond_reglement_id) && !empty($originObject->cond_reglement_id)) {
2259 $cond_reglement_id = $originObject->cond_reglement_id;
2261 if (empty($mode_reglement_id) && !empty($originObject->mode_reglement_id)) {
2262 $mode_reglement_id = $originObject->mode_reglement_id;
2264 if (empty($fk_account) && !empty($originObject->fk_account)) {
2265 $fk_account = $originObject->fk_account;
2267 if (empty($transport_mode_id) && !empty($originObject->transport_mode_id)) {
2268 $transport_mode_id = $originObject->transport_mode_id;
2275 if (empty($cond_reglement_id) && !empty($soc->cond_reglement_supplier_id)) {
2276 $cond_reglement_id = $soc->cond_reglement_supplier_id;
2278 if (empty($mode_reglement_id) && !empty($soc->mode_reglement_supplier_id)) {
2279 $mode_reglement_id = $soc->mode_reglement_supplier_id;
2281 if (empty($fk_account) && !empty($soc->fk_account)) {
2282 $fk_account = $soc->fk_account;
2284 if (empty($transport_mode_id) && !empty($soc->transport_mode_id)) {
2285 $transport_mode_id = $soc->transport_mode_id;
2291 if (!empty($objectsrc->multicurrency_code)) {
2292 $currency_code = $objectsrc->multicurrency_code;
2294 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
2295 $currency_tx = $objectsrc->multicurrency_tx;
2300 $dateinvoice = ($datetmp ==
'' ? (
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ?
'' : -1) : $datetmp);
2302 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2305 $objectsrc->fetch_optionals();
2306 $object->array_options = $objectsrc->array_options;
2308 $cond_reglement_id = !empty($societe->cond_reglement_supplier_id) ? $societe->cond_reglement_supplier_id : 0;
2309 $mode_reglement_id = !empty($societe->mode_reglement_supplier_id) ? $societe->mode_reglement_supplier_id : 0;
2310 $vat_reverse_charge = (empty($societe) ?
'' : $societe->vat_reverse_charge);
2311 $transport_mode_id = !empty($societe->transport_mode_supplier_id) ? $societe->transport_mode_supplier_id : 0;
2312 $fk_account = !empty($societe->fk_account) ? $societe->fk_account : 0;
2314 $dateinvoice = ($datetmp ==
'' ? (
getDolGlobalInt(
'MAIN_AUTOFILL_DATE') ?
'' : -1) : $datetmp);
2316 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2318 if (
isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2319 $currency_code = $societe->multicurrency_code;
2324 if (empty($cond_reglement_id)) {
2325 $cond_reglement_id =
GETPOST(
"cond_reglement_id");
2329 if (empty($mode_reglement_id)) {
2330 $mode_reglement_id =
GETPOST(
"mode_reglement_id");
2334 if (!
GETPOST(
'changecompany')) {
2335 if (GETPOSTISSET(
'cond_reglement_id')) {
2336 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2338 if (GETPOSTISSET(
'mode_reglement_id')) {
2339 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2341 if (GETPOSTISSET(
'cond_reglement_id')) {
2346 $note_public =
$object->getDefaultCreateValueFor(
'note_public', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_public : null));
2347 $note_private =
$object->getDefaultCreateValueFor(
'note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_private : null));
2349 if ($origin ==
'contrat') {
2350 $langs->load(
"admin");
2351 $text = $langs->trans(
"ToCreateARecurringInvoice");
2352 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv(
"MenuFinancial"), $langs->transnoentitiesnoconv(
"SupplierBills"), $langs->transnoentitiesnoconv(
"ListOfTemplates"));
2354 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv(
'Module2300Name'));
2356 print
info_admin($text, 0, 0,
'0',
'opacitymedium').
'<br>';
2359 print
'<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
2360 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2361 print
'<input type="hidden" name="action" value="add">';
2362 print
'<input type="hidden" name="changecompany" value="0">';
2364 if (!empty($societe->id) && $societe->id > 0) {
2365 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">'.
"\n";
2367 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
2368 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
2369 if (!empty($currency_tx)) {
2370 print
'<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
2372 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2377 $parameters = array();
2379 $reshook = $hookmanager->executeHooks(
'tabContentCreateSupplierInvoice', $parameters, $object, $action);
2380 if (empty($reshook)) {
2381 print
'<table class="border centpercent">';
2388 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2389 $invoice_predefined->fetch($fac_recid);
2393 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
2396 if (!empty($societe->id) && $societe->id > 0 && ($fac_recid <= 0 || !empty($invoice_predefined->frequency))) {
2397 $absolute_discount = $societe->getAvailableDiscounts(
null,
'', 0, 1);
2398 print $societe->getNomUrl(1,
'supplier');
2399 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
2401 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
2402 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');
2405 print
'<script type="text/javascript">
2406 $(document).ready(function() {
2407 $("#socid").change(function() {
2408 console.log("We have changed the company - Reload page");
2410 $("input[name=action]").val("create");
2411 $("input[name=changecompany]").val("1");
2412 $("form[name=add]").submit();
2417 if ($fac_recid <= 0) {
2418 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>';
2424 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2425 $invoice_predefined->fetch($fac_recid);
2427 $dateinvoice = $invoice_predefined->date_when;
2428 if (empty($projectid)) {
2429 $projectid = $invoice_predefined->fk_project;
2431 $cond_reglement_id = $invoice_predefined->cond_reglement_id;
2432 $mode_reglement_id = $invoice_predefined->mode_reglement_id;
2433 $fk_account = $invoice_predefined->fk_account;
2434 $note_public = $invoice_predefined->note_public;
2435 $note_private = $invoice_predefined->note_private;
2437 if (!empty($invoice_predefined->multicurrency_code)) {
2438 $currency_code = $invoice_predefined->multicurrency_code;
2440 if (!empty($invoice_predefined->multicurrency_tx)) {
2441 $currency_tx = $invoice_predefined->multicurrency_tx;
2444 $sql =
'SELECT r.rowid, r.titre as title, r.total_ttc';
2445 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn_rec as r';
2446 $sql .=
' WHERE r.fk_soc = '. (int) $invoice_predefined->socid;
2448 $resql =
$db->query($sql);
2450 $num =
$db->num_rows($resql);
2454 print
'<tr><td>'.$langs->trans(
'CreateFromRepeatableInvoice').
'</td><td>';
2456 print
'<select class="flat" id="fac_rec" name="fac_rec">';
2457 print
'<option value="0" selected></option>';
2459 $objp =
$db->fetch_object($resql);
2460 print
'<option value="'.$objp->rowid.
'"';
2461 if ($fac_recid == $objp->rowid) {
2463 $exampletemplateinvoice->fetch($fac_recid);
2465 print
'>'.$objp->title.
' ('.
price($objp->total_ttc).
' '.$langs->trans(
"TTC").
')</option>';
2471 print
'<script type="text/javascript">
2472 $(document).ready(function() {
2473 $("#fac_rec").change(function() {
2474 console.log("We have changed the template invoice - Reload page");
2476 $("input[name=action]").val("create");
2477 $("form[name=add]").submit();
2490 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'Type').
'</td><td>';
2492 print
'<div class="tagtable">'.
"\n";
2495 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2496 $tmp =
'<input type="radio" id="radio_standard" name="type" value="0"'.(GETPOSTINT(
'type') ?
'' :
'checked').
'> ';
2497 $desc = $form->textwithpicto($tmp.
'<label for="radio_standard">'.$langs->trans(
"InvoiceStandardAsk").
'</label>', $langs->transnoentities(
"InvoiceStandardDesc"), 1,
'help',
'', 0, 3);
2499 print
'</div></div>';
2501 if (empty($origin) || (($origin ==
'supplier_proposal' || $origin ==
'order_supplier' || $origin ==
'reception') && !empty($originid))) {
2504 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2505 $tmp =
'<input type="radio" id="radio_deposit" name="type" value="3"' . (
GETPOSTINT(
'type') == 3 ?
' checked' :
'') .
'> ';
2506 print
'<script type="text/javascript">
2507 jQuery(document).ready(function() {
2508 jQuery("#typestandardinvoice, #valuestandardinvoice").click(function() {
2509 jQuery("#radio_standard").prop("checked", true);
2511 jQuery("#typedeposit, #valuedeposit").click(function() {
2512 jQuery("#radio_deposit").prop("checked", true);
2514 jQuery("#typedeposit").change(function() {
2515 console.log("We change type of down payment");
2516 jQuery("#radio_deposit").prop("checked", true);
2517 setRadioForTypeOfInvoice();
2519 jQuery("#radio_standard, #radio_deposit, #radio_replacement, #radio_template").change(function() {
2520 setRadioForTypeOfInvoice();
2522 function setRadioForTypeOfInvoice() {
2523 console.log("Change radio");
2524 if (jQuery("#radio_deposit").prop("checked") && (jQuery("#typedeposit").val() == \'amount\' || jQuery("#typedeposit").val() == \'variable\')) {
2525 jQuery(".checkforselect").prop("disabled", true);
2526 jQuery(".checkforselect").prop("checked", false);
2528 jQuery(".checkforselect").prop("disabled", false);
2529 jQuery(".checkforselect").prop("checked", true);
2535 $tmp = $tmp.
'<label for="radio_deposit" >'.$langs->trans(
"InvoiceDeposit").
'</label>';
2537 $desc = $form->textwithpicto($tmp, $langs->transnoentities(
"InvoiceDepositDesc"), 1,
'help',
'', 0, 3);
2538 print
'<table class="nobordernopadding"><tr>';
2542 if ($origin ==
'supplier_proposal' || $origin ==
'order_supplier' || $origin ==
'reception') {
2543 print
'<td class="nowrap" style="padding-left: 15px">';
2545 'amount' => $langs->transnoentitiesnoconv(
'FixAmount', $langs->transnoentitiesnoconv(
'Deposit')),
2546 'variable' => $langs->transnoentitiesnoconv(
'VarAmountOneLine', $langs->transnoentitiesnoconv(
'Deposit')),
2547 'variablealllines' => $langs->transnoentitiesnoconv(
'VarAmountAllLines')
2549 $typedeposit =
GETPOST(
'typedeposit',
'aZ09');
2550 $valuedeposit =
GETPOST(
'valuedeposit',
'int');
2551 $deposit_percent =
null;
2552 if ($origin ==
'reception') {
2554 if (!isset($objectsrc->origin_object)) {
2555 $objectsrc->fetch_origin();
2557 if (!empty($objectsrc->origin_object)) {
2558 $deposit_percent = $objectsrc->origin_object->deposit_percent;
2560 } elseif (!empty($objectsrc->deposit_percent)) {
2561 $deposit_percent = $objectsrc->deposit_percent;
2563 if (empty($typedeposit) && !empty($deposit_percent)) {
2564 $origin_payment_conditions_deposit_percent = getDictionaryValue(
'c_payment_term',
'deposit_percent', $objectsrc->cond_reglement_id);
2565 if (!empty($origin_payment_conditions_deposit_percent)) {
2566 $typedeposit =
'variable';
2569 if (empty($valuedeposit) && $typedeposit ==
'variable' && !empty($deposit_percent)) {
2570 $valuedeposit = $deposit_percent;
2572 print $form->selectarray(
'typedeposit', $arraylist, $typedeposit, 0, 0, 0,
'', 1);
2574 print
'<td class="nowrap" style="padding-left: 5px">';
2575 print
'<span class="opacitymedium paddingleft">'.$langs->trans(
"AmountOrPercent").
'</span><input type="text" id="valuedeposit" name="valuedeposit" class="width75 right" value="' . $valuedeposit .
'"/>';
2578 print
'</tr></table>';
2580 print
'</div></div>';
2649 if (empty($origin)) {
2650 if (!empty($societe->id) && $societe->id > 0) {
2654 $facids = $facturestatic->list_qualified_avoir_supplier_invoices($societe->id);
2661 foreach ($facids as $key => $valarray) {
2662 $newinvoice_static->id = $key;
2663 $newinvoice_static->ref = $valarray [
'ref'];
2664 $newinvoice_static->status = $valarray [
'status'];
2665 $newinvoice_static->statut = $valarray [
'status'];
2666 $newinvoice_static->type = $valarray [
'type'];
2667 $newinvoice_static->paid = $valarray [
'paye'];
2668 $newinvoice_static->paye = $valarray [
'paye'];
2670 $optionsav .=
'<option value="'.$key.
'"';
2672 $optionsav .=
' selected';
2675 $optionsav .= $newinvoice_static->ref;
2676 $optionsav .=
' ('.$newinvoice_static->getLibStatut(1, $valarray [
'paymentornot']).
')';
2677 $optionsav .=
'</option>';
2680 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2681 $tmp =
'<input type="radio" id="radio_creditnote" name="type" value="2"'.(GETPOSTINT(
'type') == 2 ?
' checked' :
'');
2683 $tmp .=
' disabled';
2687 print
'<script type="text/javascript">
2688 jQuery(document).ready(function() {
2689 if (! jQuery("#radio_creditnote").is(":checked"))
2691 jQuery("#credit_note_options").hide();
2693 jQuery("#radio_creditnote").click(function() {
2694 jQuery("#credit_note_options").show();
2696 jQuery("#radio_standard, #radio_replacement, #radio_deposit").click(function() {
2697 jQuery("#credit_note_options").hide();
2701 $text = $tmp.
'<label for="radio_creditnote">'.$langs->transnoentities(
"InvoiceAvoirAsk").
'</label> ';
2703 $text .=
'<select class="flat valignmiddle" name="fac_avoir" id="fac_avoir"';
2705 $text .=
' disabled';
2709 $text .=
'<option value="-1"></option>';
2710 $text .= $optionsav;
2712 $text .=
'<option value="-1">'.$langs->trans(
"NoInvoiceToCorrect").
'</option>';
2714 $text .=
'</select>';
2715 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2718 print
'<div id="credit_note_options" class="clearboth">';
2719 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' :
'').
' /> ';
2720 print
'<label for="invoiceAvoirWithLines">'.$langs->trans(
'invoiceAvoirWithLines').
"</label>";
2721 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' :
'').
' /> ';
2722 print
'<label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans(
'invoiceAvoirWithPaymentRestAmount').
"</label>";
2725 print
'</div></div>';
2728 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2730 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="0" disabled> ';
2732 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="2"> ';
2734 $text = $tmp.$langs->trans(
"InvoiceAvoir").
' ';
2735 $text .=
'<span class="opacitymedium">('.$langs->trans(
"YouMustCreateInvoiceFromSupplierThird").
')</span> ';
2736 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2738 print
'</div></div>'.
"\n";
2748 print
'<tr><td class="fieldrequired">';
2749 print $form->textwithpicto($langs->trans(
'RefSupplierBill'), $langs->trans(
"RefOfOnVendorSide", $langs->trans(
"SupplierBill"))).
'</td><td>';
2750 print
'<input name="ref_supplier" value="'.(GETPOSTISSET(
'ref_supplier') ?
GETPOST(
'ref_supplier') : (!empty($objectsrc->ref_supplier) ? $objectsrc->ref_supplier :
'')).
'" type="text" spellcheck="false"';
2751 if (!empty($societe->id) && $societe->id > 0) {
2760 print
'<tr><td class="fieldrequired">'.$langs->trans(
'InvoiceSubtype').
'</td><td colspan="2">';
2761 print $form->getSelectInvoiceSubtype(
GETPOSTINT(
'subtype'),
'subtype', 1, 0,
'');
2765 if (!empty($societe->id) && $societe->id > 0) {
2767 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
2769 $thirdparty = $societe;
2771 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$societe->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
2772 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2778 print
'<tr><td>'.$langs->trans(
'Label').
'</td><td><input class="minwidth300" name="label" value="'.
dol_escape_htmltag(
GETPOST(
'label')).
'" type="text"></td></tr>';
2782 print
'<tr><td class="fieldrequired">'.$langs->trans(
'DateInvoice').
'</td><td>';
2783 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2784 print $form->selectDate($dateinvoice ? (
int) $dateinvoice :
'',
'', 0, 0, 0,
"add", 1, 1);
2788 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
2789 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
2790 print $form->getSelectConditionsPaiements($cond_reglement_id,
'cond_reglement_id', -1, 1, 0,
'maxwidth200 widthcentpercentminusx');
2794 print
'<tr><td>'.$langs->trans(
'DateMaxPayment').
'</td><td>';
2795 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2796 print $form->selectDate($datedue,
'ech', 0, 0, 0,
"add", 1, 1);
2800 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
2801 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
2802 $form->select_types_paiements((
string) $mode_reglement_id,
'mode_reglement_id',
'DBIT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx');
2807 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
2809 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes((
int) $fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
2817 $langs->load(
'projects');
2818 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td>';
2819 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');
2820 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>';
2827 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), !empty($objectsrc->label_incoterms) ? $objectsrc->label_incoterms :
'', 1).
'</label></td>';
2828 print
'<td colspan="3" class="maxwidthonsmartphone">';
2829 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2830 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 :
''));
2836 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
2837 print
'<tr><td>' . $langs->trans(
'VATReverseCharge') .
'</td><td>';
2839 if (GETPOSTISSET(
'vat_reverse_charge')) {
2840 $vat_reverse_charge = (
GETPOST(
'vat_reverse_charge',
'alpha') ==
'on' ||
GETPOST(
'vat_reverse_charge',
'alpha') ==
'1') ? 1 : 0;
2841 } elseif ($vat_reverse_charge == 1 || $societe->vat_reverse_charge == 1 || ($societe->country_code !=
'FR' &&
isInEEC($societe) && !empty($societe->tva_intra))) {
2842 $vat_reverse_charge = 1;
2844 $vat_reverse_charge = 0;
2847 print
'<input type="checkbox" name="vat_reverse_charge"'. (!empty($vat_reverse_charge) ?
' checked ' :
'') .
'>';
2854 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
2855 print
'<td class="maxwidthonsmartphone">';
2856 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
2857 $used_currency_code = $currency_code;
2858 if (!
GETPOST(
'changecompany')) {
2859 $used_currency_code = GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code',
'alpha') : $currency_code;
2861 print $form->selectMultiCurrency($used_currency_code,
'multicurrency_code');
2867 if ($fac_recid > 0) {
2868 $dateexample = $dateinvoice;
2869 if (empty($dateexample)) {
2872 $substitutionarray = array(
2873 '__TOTAL_HT__' => $langs->trans(
"AmountHT").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ht).
')',
2874 '__TOTAL_TTC__' => $langs->trans(
"AmountTTC").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ttc).
')',
2875 '__INVOICE_PREVIOUS_MONTH__' => $langs->trans(
"PreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%m').
')',
2876 '__INVOICE_MONTH__' => $langs->trans(
"MonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%m').
')',
2877 '__INVOICE_NEXT_MONTH__' => $langs->trans(
"NextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%m').
')',
2878 '__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans(
"TextPreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%B').
')',
2879 '__INVOICE_MONTH_TEXT__' => $langs->trans(
"TextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%B').
')',
2880 '__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans(
"TextNextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%B').
')',
2881 '__INVOICE_PREVIOUS_YEAR__' => $langs->trans(
"PreviousYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'y'),
'%Y').
')',
2882 '__INVOICE_YEAR__' => $langs->trans(
"YearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%Y').
')',
2883 '__INVOICE_NEXT_YEAR__' => $langs->trans(
"NextYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'y'),
'%Y').
')'
2886 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
2887 foreach ($substitutionarray as $key => $val) {
2888 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
2890 $htmltext .=
'</i>';
2895 $langs->loadLangs(array(
"intracommreport"));
2896 print
'<!-- If module intracomm on -->'.
"\n";
2897 print
'<tr><td>'.$langs->trans(
'IntracommReportTransportMode').
'</td><td>';
2898 $form->selectTransportMode(GETPOSTISSET(
'transport_mode_id') ?
GETPOST(
'transport_mode_id') : $transport_mode_id,
'transport_mode_id');
2902 if (empty($reshook)) {
2903 print
$object->showOptionals($extrafields,
'create');
2908 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
2909 print $form->selectCategories(Categorie::TYPE_SUPPLIER_INVOICE,
'categories', $object);
2914 print
'<tr><td>'.$langs->trans(
'NotePublic').
'</td>';
2916 $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%');
2917 print $doleditor->Create(1);
2923 print
'<tr><td>'.$langs->trans(
'NotePrivate').
'</td>';
2925 $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%');
2926 print $doleditor->Create(1);
2932 if (!empty($objectsrc) && $classname !==
null) {
2933 print
"\n<!-- ".$classname.
" info -->";
2935 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2936 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2937 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2938 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2939 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2941 $txt = $langs->trans($classname);
2942 if ($classname ==
'CommandeFournisseur') {
2943 $langs->load(
'orders');
2944 $txt = $langs->trans(
"SupplierOrder");
2946 print
'<tr><td>'.$txt.
'</td><td>'.$objectsrc->getNomUrl(1);
2948 $objectsrc->fetchObjectLinked($originid, $origin,
null,
'invoice_supplier');
2950 if (isset($objectsrc->linkedObjects[
'invoice_supplier'])) {
2951 $invoice_supplier = $objectsrc->linkedObjects[
'invoice_supplier'];
2953 $invoice_supplier = [];
2955 '@phan-var-force null|FactureFournisseur[] $invoice_supplier';
2958 if (is_array($invoice_supplier)) {
2959 $cntinvoice = count($invoice_supplier);
2961 if ($cntinvoice >= 1) {
2963 echo
' ('.$langs->trans(
'LatestRelatedBill').end($invoice_supplier)->getNomUrl(1).
')';
2968 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
2969 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
2970 if (
$mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
2971 print
'<tr><td>'.$langs->transcountry(
"AmountLT1",
$mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
2974 if (
$mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
2975 print
'<tr><td>'.$langs->transcountry(
"AmountLT2",
$mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
2977 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
2980 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
2981 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
2982 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2987 $parameters = array();
2988 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2989 print $hookmanager->resPrint;
2997 print $form->buttonsSaveCancel(
"CreateDraft");
3000 if (!empty($objectsrc)) {
3003 $title = $langs->trans(
'ProductsAndServices');
3006 print
'<div class="div-table-responsive-no-min">';
3007 print
'<table class="noborder centpercent">';
3009 $objectsrc->printOriginLinesList(
'', $selectedLines);
3017 if ($id > 0 || !empty($ref)) {
3023 $result =
$object->fetch($id, $ref);
3025 recordNotFound(
'', 0);
3028 $result =
$object->fetch_thirdparty();
3034 $societe =
$object->thirdparty;
3036 $totalpaid =
$object->getSommePaiement();
3037 $totalcreditnotes =
$object->getSumCreditNotesUsed();
3038 $totaldeposits =
$object->getSumDepositsUsed();
3046 $resteapayer =
price2num(
$object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
3049 $multicurrency_resteapayer = 0;
3051 $multicurrency_totalpaid =
$object->getSommePaiement(1);
3052 $multicurrency_totalcreditnotes =
$object->getSumCreditNotesUsed(1);
3053 $multicurrency_totaldeposits =
$object->getSumDepositsUsed(1);
3054 $multicurrency_resteapayer =
price2num(
$object->multicurrency_total_ttc - $multicurrency_totalpaid - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits,
'MT');
3058 if ($resteapayer == 0 && $multicurrency_resteapayer != 0 &&
$object->multicurrency_code !=
$conf->currency) {
3059 $resteapayer =
price2num((
float) $multicurrency_resteapayer /
$object->multicurrency_tx,
'MT');
3066 $resteapayeraffiche = $resteapayer;
3069 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
3070 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
3072 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
3073 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
3076 $absolute_discount = $societe->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
3077 $absolute_creditnote = $societe->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
3078 $absolute_discount =
price2num($absolute_discount,
'MT');
3079 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
3083 $objectidnext =
$object->getIdReplacingInvoice();
3086 $titre = $langs->trans(
'SupplierInvoice');
3088 print
dol_get_fiche_head($head,
'card', $titre, -1,
'supplier_invoice', 0,
'',
'', 0,
'', 1);
3093 if ($action ==
'converttoreduc') {
3096 $type_fac =
'ExcessPaid';
3098 $type_fac =
'CreditNote';
3100 $type_fac =
'Deposit';
3102 $text = $langs->trans(
'ConfirmConvertToReducSupplier', strtolower($langs->transnoentities($type_fac)));
3103 $text .=
'<br>'.$langs->trans(
'ConfirmConvertToReducSupplier2');
3104 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id, $langs->trans(
'ConvertToReduc'), $text,
'confirm_converttoreduc',
'',
"yes", 2);
3108 if ($action ==
'clone') {
3110 $formquestion = array(
3111 array(
'type' =>
'text',
'name' =>
'newsupplierref',
'label' => $langs->trans(
"RefSupplierBill"),
'value' => $langs->trans(
"CopyOf").
' '.
$object->ref_supplier),
3112 array(
'type' =>
'date',
'name' =>
'newdate',
'label' => $langs->trans(
"Date"),
'value' =>
dol_now())
3115 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneInvoice',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1, 0);
3119 if ($action ==
'valid') {
3121 if (preg_match(
'/^[\(]?PROV/i',
$object->ref) || empty(
$object->ref)) {
3123 $numref =
$object->getNextNumRef($societe);
3132 $text = $langs->trans(
'ConfirmValidateBill', $numref);
3140 $formquestion = array();
3142 $qualified_for_stock_change = 0;
3144 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3146 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3150 $langs->load(
"stocks");
3151 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3154 $warehouse_array = $warehouse->list_array();
3155 if (count($warehouse_array) == 1) {
3157 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3160 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3162 $formquestion = array(
3163 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3167 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateBill'), $text,
'confirm_valid', $formquestion, 1, 1);
3172 if ($action ==
'edit') {
3173 $formquestion = array();
3175 $qualified_for_stock_change = 0;
3177 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3179 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3182 $langs->load(
"stocks");
3183 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3186 $warehouse_array = $warehouse->list_array();
3187 if (count($warehouse_array) == 1) {
3189 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3192 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3194 $formquestion = array(
3195 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3198 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'UnvalidateBill'), $langs->trans(
'ConfirmUnvalidateBill',
$object->ref),
'confirm_edit', $formquestion, 1, 1);
3202 if ($action ==
'paid' && ($resteapayer <= 0 || (
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') && $resteapayer ==
$object->total_ttc))) {
3203 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidBill',
$object->ref),
'confirm_paid',
'', 0, 1);
3206 if ($action ==
'paid' && $resteapayer > 0 && (!
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') || $resteapayer !=
$object->total_ttc)) {
3210 $close[$i][
'code'] =
'discount_vat';
3212 $close[$i][
'code'] =
'badsupplier';
3214 $close[$i][
'code'] =
'other';
3218 $close[$i][
'label'] = $langs->trans(
"HelpEscompte").
'<br><br>'.$langs->trans(
"ConfirmClassifyPaidPartiallyReasonDiscountVatDesc");
3220 $close[$i][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3222 $close[$i][
'label'] = $langs->trans(
"Other");
3226 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonDiscount", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3228 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadCustomer", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3230 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"Other"), $close[$i][
'label'], 1);
3233 $arrayreasons = array();
3234 foreach ($close as $key => $val) {
3235 $arrayreasons[$close[$key][
'code']] = $close[$key][
'reason'];
3239 $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'));
3241 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?facid='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidPartially',
$object->ref),
'confirm_paid_partially', $formquestion,
"yes", 1, 310);
3245 if ($action ==
'canceled') {
3247 $close[1][
'code'] =
'badsupplier';
3248 $close[2][
'code'] =
'abandon';
3250 $close[1][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3251 $close[2][
'label'] = $langs->trans(
"ConfirmClassifyAbandonReasonOtherDesc");
3253 $close[1][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadSupplier",
$object->ref), $close[1][
'label'], 1);
3254 $close[2][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyAbandonReasonOther"), $close[2][
'label'], 1);
3256 $arrayreasons[$close[1][
'code']] = $close[1][
'reason'];
3257 $arrayreasons[$close[2][
'code']] = $close[2][
'reason'];
3260 $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'));
3262 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'CancelBill'), $langs->trans(
'ConfirmCancelBill',
$object->ref),
'confirm_canceled', $formquestion,
"yes", 1, 280);
3266 if ($action ==
'delete') {
3267 $formquestion = array();
3269 $qualified_for_stock_change = 0;
3271 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3273 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3277 $langs->load(
"stocks");
3278 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3281 $warehouse_array = $warehouse->list_array();
3283 $selectwarehouse =
'<span class="questionrevertstock hidden">';
3284 if (count($warehouse_array) == 1) {
3286 $selectwarehouse .=
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3289 $selectwarehouse .= $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3291 $selectwarehouse .=
'</span>';
3293 $selectyesno = array(0 => $langs->trans(
'No'), 1 => $langs->trans(
'Yes'));
3295 print
'<script type="text/javascript">
3296 $(document).ready(function() {
3297 $("#revertstock").change(function() {
3298 if(this.value > 0) {
3299 $(".questionrevertstock").removeClass("hidden");
3301 $(".questionrevertstock").addClass("hidden");
3307 $formquestion = array(
3308 array(
'type' =>
'select',
'name' =>
'revertstock',
'label' => $langs->trans(
"RevertProductsToStock"),
'select_show_empty' => 0,
'values' => $selectyesno),
3309 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $selectwarehouse,
'tdclass' =>
'questionrevertstock hidden')
3313 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteBill'), $langs->trans(
'ConfirmDeleteBill'),
'confirm_delete', $formquestion, 1, 1);
3315 if ($action ==
'deletepayment') {
3316 $payment_id =
GETPOST(
'paiement_id');
3317 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&paiement_id='.$payment_id, $langs->trans(
'DeletePayment'), $langs->trans(
'ConfirmDeletePayment'),
'confirm_delete_paiement',
'', 0, 1);
3321 if ($action ==
'ask_deleteline') {
3322 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
3326 if ($action ==
'add_title_line') {
3327 $langs->load(
'subtotals');
3329 $depth_array =
$object->getPossibleLevels($langs);
3330 require DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_create.tpl.php';
3331 } elseif ($action ==
'add_subtotal_line') {
3332 $langs->load(
'subtotals');
3334 $titles =
$object->getPossibleTitles();
3335 require DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_create.tpl.php';
3339 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
3340 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
3341 if (empty($reshook)) {
3342 $formconfirm .= $hookmanager->resPrint;
3343 } elseif ($reshook > 0) {
3344 $formconfirm = $hookmanager->resPrint;
3352 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
3354 $morehtmlref =
'<div class="refidno">';
3356 $morehtmlref .= $form->editfieldkey(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier, $object, (
int) $usercancreate,
'string',
'', 0, 1);
3357 $morehtmlref .= $form->editfieldval(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier, $object, $usercancreate,
'string',
'',
null,
null,
'', 1);
3359 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1,
'supplier');
3361 $morehtmlref .=
' <div class="inline-block valignmiddle">(<a class="valignmiddle" href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.((int)
$object->thirdparty->id).
'&search_company='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherBills").
'</a>)</div>';
3365 $langs->load(
"projects");
3366 $morehtmlref .=
'<br>';
3367 if ($permissiontoadd) {
3368 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
3369 if ($action !=
'classify') {
3370 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.((int)
$object->id).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
3372 $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');
3374 if (!empty(
$object->fk_project)) {
3376 $proj->fetch(
$object->fk_project);
3377 $morehtmlref .= $proj->getNomUrl(1);
3379 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
3384 $morehtmlref .=
'</div>';
3386 $object->totalpaid = $totalpaid;
3388 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
3391 $parameters = array();
3393 $reshook = $hookmanager->executeHooks(
'tabContentViewSupplierInvoice', $parameters, $object, $action);
3394 if (empty($reshook)) {
3395 print
'<div class="fichecenter">';
3396 print
'<div class="fichehalfleft">';
3397 print
'<div class="underbanner clearboth"></div>';
3399 print
'<table class="border tableforfield centpercent">';
3402 print
'<tr><td>'.$langs->trans(
'Type').
'</td><td>';
3403 print
'<span class="badgeneutral">';
3407 print
' '.$object->getSubtypeLabel(
'facture_fourn');
3411 $facreplaced->fetch(
$object->fk_facture_source);
3412 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
'</span>';
3415 if (
$object->fk_facture_source > 0) {
3417 $facusing->fetch(
$object->fk_facture_source);
3418 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
'</span>';
3420 $langs->load(
"errors");
3421 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"WarningCorrectedInvoiceNotFound").
'</span>';
3426 $object->getListIdAvoirFromInvoice();
3428 if (!empty(
$object->creditnote_ids)) {
3429 $invoicecredits = array();
3430 foreach (
$object->creditnote_ids as $invoiceid) {
3432 $creditnote->fetch($invoiceid);
3433 $invoicecredits[] = $creditnote->getNomUrl(1);
3435 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"InvoiceHasAvoir") . (count($invoicecredits) ?
' ' :
'') . implode(
',', $invoicecredits);
3438 if (isset($objectidnext) && $objectidnext > 0) {
3441 $facthatreplace->fetch($objectidnext);
3442 print
' <span class="opacitymediumbycolor paddingleft">'.str_replace(
'{s1}', $facthatreplace->getNomUrl(1), $langs->transnoentities(
"ReplacedByInvoice",
'{s1}')).
'</span>';
3446 $result = $discount->fetch(0, 0,
$object->id);
3448 print
' <span class="opacitymediumbycolor paddingleft">';
3449 $s = $langs->trans(
"CreditNoteConvertedIntoDiscount",
'{s1}',
'{s2}');
3450 $s = str_replace(
'{s1}',
$object->getLibType(1), $s);
3451 $s = str_replace(
'{s2}', $discount->getNomUrl(1,
'discount'), $s);
3453 print
'</span><br>';
3457 if (
$object->fk_fac_rec_source > 0) {
3459 $result = $tmptemplate->fetch(
$object->fk_fac_rec_source);
3461 print
' <span class="opacitymediumbycolor paddingleft">';
3462 $link =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.$tmptemplate->id.
'">'.
dol_escape_htmltag($tmptemplate->title).
'</a>';
3463 $s = $langs->transnoentities(
"GeneratedFromSupplierTemplate", $link);
3473 print
'<!-- Discounts -->'.
"\n";
3474 print
'<tr><td>'.$langs->trans(
'DiscountStillRemaining');
3477 $thirdparty = $societe;
3479 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
3485 print
'<td>'.$form->editfieldkey(
"Label",
'label',
$object->label, $object, (
int) $usercancreate).
'</td>';
3486 print
'<td>'.$form->editfieldval(
"Label",
'label',
$object->label, $object, $usercancreate).
'</td>';
3494 print $form->editfieldkey(
"DateInvoice",
'datef', (
string)
$object->date,
$object, (int) $form_permission,
'datepicker');
3495 print
'</td><td colspan="3">';
3496 print $form->editfieldval(
"Date",
'datef',
$object->date, $object, $form_permission,
'datepicker');
3500 $langs->load(
'bills');
3501 print
'<tr><td class="nowrap">';
3502 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3503 print $langs->trans(
'PaymentConditions');
3505 if ($action !=
'editconditions' && $form_permission) {
3506 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>';
3508 print
'</tr></table>';
3510 if ($action ==
'editconditions') {
3511 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id');
3513 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'none');
3520 print $form->editfieldkey(
"DateMaxPayment",
'date_lim_reglement', (
string)
$object->date_echeance, $object, (
int) $form_permission,
'datepicker');
3522 print $form->editfieldval(
"DateMaxPayment",
'date_lim_reglement',
$object->date_echeance, $object, $form_permission,
'datepicker');
3523 if ($action !=
'editdate_lim_reglement' &&
$object->hasDelay()) {
3529 $langs->load(
'bills');
3530 print
'<tr><td class="nowrap">';
3531 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3532 print $langs->trans(
'PaymentMode');
3534 if ($action !=
'editmode' && $form_permission) {
3535 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>';
3537 print
'</tr></table>';
3539 if ($action ==
'editmode') {
3540 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
3542 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
3548 print
'<tr><td class="nowrap">';
3549 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3550 print $langs->trans(
'BankAccount');
3552 if ($action !=
'editbankaccount' && $usercancreate) {
3553 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>';
3555 print
'</tr></table>';
3557 if ($action ==
'editbankaccount') {
3558 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
3560 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'none');
3568 print
'<tr><td class="nowrap">';
3569 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3570 print $langs->trans(
'VATReverseCharge');
3572 if ($action !=
'editvatreversecharge' && $usercancreate) {
3573 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editvatreversecharge&id='.
$object->id.
'">'.
img_edit($langs->trans(
'SetVATReverseCharge'), 1).
'</a></td>';
3575 print
'</tr></table>';
3577 if ($action ==
'editvatreversecharge') {
3578 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
3579 print
'<input type="hidden" name="action" value="setvatreversecharge">';
3580 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3582 print
'<input type="checkbox" name="vat_reverse_charge"' . (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
'>';
3584 print
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
3587 print
'<input type="checkbox" name="vat_reverse_charge"'. (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
' disabled>';
3595 print
'<table width="100%" class="nobordernopadding"><tr><td>';
3596 print $langs->trans(
'IncotermLabel');
3597 print
'<td><td class="right">';
3598 if ($usercancreate) {
3599 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.
$object->id.
'&action=editincoterm&token='.newToken().
'">'.
img_edit().
'</a>';
3603 print
'</td></tr></table>';
3606 if ($action !=
'editincoterm') {
3607 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3609 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
3616 $langs->loadLangs(array(
"intracommreport"));
3617 print
'<!-- If module intracomm on -->'.
"\n";
3619 print
'<table class="nobordernopadding centpercent"><tr><td>';
3620 print $langs->trans(
'IntracommReportTransportMode');
3622 if ($action !=
'edittransportmode' && ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"))) {
3623 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edittransportmode&token='.newToken().
'&id='.
$object->id.
'">'.
img_edit().
'</a></td>';
3625 print
'</tr></table>';
3628 if ($action ==
'edittransportmode') {
3629 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->transport_mode_id,
'transport_mode_id', 1, 1);
3631 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->transport_mode_id,
'none');
3639 print
'<table class="nobordernopadding centpercent"><tr><td>';
3640 print $langs->trans(
"Categories");
3641 print
'<td><td class="right">';
3642 if ($usercancreate) {
3643 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.
$object->id.
'&action=edittags&token='.newToken().
'">'.
img_edit().
'</a>';
3647 print
'</td></tr></table>';
3650 if ($action ==
'edittags') {
3651 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?facid='.
$object->id.
'">';
3652 print
'<input type="hidden" name="action" value="settags">';
3653 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3654 print $form->selectCategories(Categorie::TYPE_SUPPLIER_INVOICE,
'categories', $object);
3655 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
3658 print $form->showCategories(
$object->id, Categorie::TYPE_SUPPLIER_INVOICE, 1);
3666 if (
$object->status != $object::STATUS_DRAFT) {
3670 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3675 print
'<div class="fichehalfright">';
3676 print
'<div class="underbanner clearboth"></div>';
3678 print
'<table class="border tableforfield centpercent">';
3680 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
3683 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
3684 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3686 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3691 print
'<td>' . $langs->trans(
'AmountVAT') .
'</td>';
3692 print
'<td class="nowrap amountcard right">';
3693 if (
GETPOST(
'calculationrule')) {
3694 $calculationrule =
GETPOST(
'calculationrule',
'alpha');
3696 $calculationrule = (!
getDolGlobalString(
'MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND_SUPPLIER') ?
'totalofround' :
'roundoftotal');
3698 if ($calculationrule ==
'totalofround') {
3699 $calculationrulenum = 1;
3701 $calculationrulenum = 2;
3704 if (
$object->getVentilExportCompta() == 0) {
3705 $s =
'<span class="hideonsmartphone opacitymedium">' . $langs->trans(
"ReCalculate") .
' </span>';
3706 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&token='.newToken().
'&calculationrule=totalofround">' . $langs->trans(
"Mode1") .
'</a>';
3708 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&token='.newToken().
'&calculationrule=roundoftotal">' . (
$conf->dol_optimize_smallscreen ?
"2" : $langs->trans(
"Mode2")) .
'</a>';
3709 print
'<div class="inline-block">';
3710 print $form->textwithtooltip($s, $langs->trans(
"CalculationRuleDesc", $calculationrulenum) .
'<br>' . $langs->trans(
"CalculationRuleDescSupplier"), 2, 1,
img_picto(
'',
'help',
'class="paddingleft paddingright"'),
'', 3,
'', 0,
'recalculate');
3711 print
' ';
3714 print
'<span class="nowraponall">'.price(
$object->total_tva, 1, $langs, 0, -1, -1,
$conf->currency).
'</span>';
3717 print
'<td class="nowraponall amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3721 if ($societe->localtax1_assuj ==
"1") {
3723 print
'<td>' . $langs->transcountry(
"AmountLT1", $societe->country_code) .
'</td>';
3724 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 1, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3727 if ($societe->localtax2_assuj ==
"1") {
3729 print
'<td>' . $langs->transcountry(
"AmountLT2", $societe->country_code) .
'</td>';
3730 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 1, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3735 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
3736 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3738 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3771 if ($societe->localtax1_assuj ==
"1") {
3774 if ($societe->localtax2_assuj ==
"1") {
3778 $sql =
'SELECT p.datep as dp, p.ref, p.num_paiement as num_payment, p.rowid, p.fk_bank,';
3779 $sql .=
' c.id as payment_type, c.code as payment_code,';
3780 $sql .=
' pf.amount,';
3781 $sql .=
' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal';
3782 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn as p';
3783 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
3784 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
3785 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id';
3786 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid';
3787 $sql .=
' WHERE pf.fk_facturefourn = '.((int)
$object->id);
3788 $sql .=
' ORDER BY p.datep, p.tms';
3790 $result =
$db->query($sql);
3792 $num =
$db->num_rows($result);
3795 print
'<div class="div-table-responsive-no-min">';
3796 print
'<table class="noborder paymenttable centpercent">';
3797 print
'<tr class="liste_titre">';
3799 print
'<td><span class="hideonsmartphone">'.$langs->trans(
'Date').
'</span></td>';
3800 print
'<td><span class="hideonsmartphone">'.$langs->trans(
'Type').
'</span></td>';
3802 print
'<td class="right">'.$langs->trans(
'BankAccount').
'</td>';
3807 print
'<td class="right">'.$langs->trans(
'Amount').
'</td>';
3812 $objp =
$db->fetch_object($result);
3814 $paymentstatic->id = $objp->rowid;
3815 $paymentstatic->datepaye =
$db->jdate($objp->dp);
3816 $paymentstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
3817 $paymentstatic->num_payment = $objp->num_payment;
3819 $paymentstatic->paiementcode = $objp->payment_code;
3820 $paymentstatic->type_code = $objp->payment_code;
3821 $paymentstatic->type_label = $objp->payment_type;
3823 print
'<tr class="oddeven">';
3824 print
'<td class="nowraponall">';
3825 print $paymentstatic->getNomUrl(1);
3827 print
'<td>'.dol_print_date(
$db->jdate($objp->dp),
'day').
'</td>';
3828 $s = $form->form_modes_reglement(
'', $objp->payment_type,
'none',
'', 1, 0,
'', 1).
' '.$objp->num_payment;
3829 print
'<td class="tdoverflowmax125" title="'.dol_escape_htmltag($s).
'">';
3833 $bankaccountstatic->id = $objp->baid;
3834 $bankaccountstatic->ref = $objp->baref;
3835 $bankaccountstatic->label = $objp->baref;
3836 $bankaccountstatic->number = $objp->banumber;
3839 $bankaccountstatic->account_number = $objp->account_number;
3842 $accountingjournal->fetch($objp->fk_accountancy_journal);
3843 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
3846 print
'<td class="right nowraponall">';
3847 if ($objp->baid > 0) {
3848 print $bankaccountstatic->getNomUrl(1,
'transactions');
3853 print
'<td class="center">';
3855 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deletepayment&token='.newToken().
'&paiement_id='.$objp->rowid.
'">';
3861 print
'<td class="right">'.price($sign * $objp->amount).
'</td>';
3863 $totalpaid += $objp->amount;
3867 print
'<tr class="oddeven"><td colspan="'.$nbcols.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td>';
3893 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
3894 print
'<span class="opacitymedium">';
3896 print $langs->trans(
'AlreadyPaidNoCreditNotesNoDeposits');
3898 print $langs->trans(
'AlreadyPaid');
3903 print
'<td class="right"'.(($totalpaid > 0) ?
' class="amountalreadypaid"' :
'').
'>'.
price($totalpaid).
'</td>';
3907 $resteapayeraffiche = $resteapayer;
3909 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
3912 $creditnoteamount = 0;
3915 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
3916 $sql .=
" re.description, re.fk_invoice_supplier_source";
3917 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
3918 $sql .=
" WHERE fk_invoice_supplier = ".((int)
$object->id);
3919 $resql =
$db->query($sql);
3921 $num =
$db->num_rows($resql);
3925 $obj =
$db->fetch_object($resql);
3926 $invoice->fetch($obj->fk_invoice_supplier_source);
3927 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3929 print $langs->trans(
"CreditNote").
' ';
3932 print $langs->trans(
"Deposit").
' ';
3934 print $invoice->getNomUrl(0);
3937 print
'<td class="right">';
3938 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=unlinkdiscount&discountid='.$obj->rowid.
'">';
3939 print
img_picto($langs->transnoentitiesnoconv(
"RemoveDiscount"),
'unlink');
3943 print
'<td class="right">'.price($obj->amount_ttc).
'</td>';
3947 $creditnoteamount += $obj->amount_ttc;
3950 $depositamount += $obj->amount_ttc;
3959 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right nowrap">';
3960 print
'<span class="opacitymedium">';
3961 print $form->textwithpicto($langs->trans(
"Discount"), $langs->trans(
"HelpEscompte"), - 1);
3965 print
'<td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td>';
3967 $resteapayeraffiche = 0;
3968 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3972 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right nowrap">';
3973 print
'<span class="opacitymedium">';
3974 print $form->textwithpicto($langs->trans(
"Abandoned"), $langs->trans(
"HelpAbandonBadCustomer"), - 1);
3978 print
'<td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td>';
3981 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3985 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right nowrap">';
3986 print
'<span class="opacitymedium">';
3987 print $form->textwithpicto($langs->trans(
"ProductReturned"), $langs->trans(
"HelpAbandonProductReturned"), - 1);
3991 print
'<td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td>';
3993 $resteapayeraffiche = 0;
3994 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3998 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right nowrap">';
3999 $text = $langs->trans(
"HelpAbandonOther");
4001 $text .=
'<br><br><b>'.$langs->trans(
"Reason").
'</b>:'.
$object->close_note;
4003 print
'<span class="opacitymedium">';
4005 print $form->textwithpicto($langs->trans(
"Abandoned"), $text, - 1);
4009 print
'<td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td>';
4011 $resteapayeraffiche = 0;
4012 $cssforamountpaymentcomplete =
'amountpaymentneutral';
4016 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4017 print
'<span class="opacitymedium">';
4018 print $langs->trans(
"Billed");
4022 print
'<td class="right">'.price(
$object->total_ttc).
'</td>';
4026 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4027 print
'<span class="opacitymedium">';
4028 print $langs->trans(
'RemainderToPay');
4029 if ($resteapayeraffiche < 0) {
4030 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
4035 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayeraffiche).
'</td>';
4040 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4041 print
'<span class="opacitymedium">';
4042 print $langs->trans(
'RemainderToPayMulticurrency');
4043 if ($resteapayeraffiche < 0) {
4044 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
4049 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopaynoresize' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price(
price2num($multicurrency_resteapayer,
'MT'), 0, $langs, 1, -1, -1,
$object->multicurrency_code).
'</td>';
4053 $cssforamountpaymentcomplete =
'amountpaymentneutral';
4056 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4057 print $langs->trans(
'AlreadyPaidBack');
4060 print
'<td class="right">'.price($sign * $totalpaid).
'</td>';
4064 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">'.$langs->trans(
"Billed").
'</td>';
4066 print
'<td class="right">'.price($sign *
$object->total_ttc).
'</td>';
4070 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4071 print
'<span class="opacitymedium">';
4072 print $langs->trans(
'RemainderToPayBack');
4073 if ($resteapayeraffiche > 0) {
4074 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
4079 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($sign * $resteapayeraffiche).
'</td>';
4084 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4085 print
'<span class="opacitymedium">';
4086 print $langs->trans(
'RemainderToPayBackMulticurrency');
4087 if ($resteapayeraffiche > 0) {
4088 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
4093 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>';
4109 print
'<div class="clearboth"></div><br>';
4112 $blocname =
'contacts';
4113 $title = $langs->trans(
'ContactsAddresses');
4114 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
4119 $blocname =
'notes';
4120 $title = $langs->trans(
'Notes');
4121 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
4128 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
4129 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4130 print
'<input type="hidden" name="action" value="'.(($action !=
'editline') ?
'addline' :
'updateline').
'">';
4131 print
'<input type="hidden" name="mode" value="">';
4132 print
'<input type="hidden" name="page_y" value="">';
4133 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
4134 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
4135 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
4139 include DOL_DOCUMENT_ROOT .
'/core/tpl/subtotal_ajaxrow.tpl.php';
4141 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
4145 print
'<div class="div-table-responsive-no-min">';
4146 print
'<table id="tablelines" class="noborder noshadow centpercent">';
4148 global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax;
4151 $inputalsopricewithtax = 1;
4152 $senderissupplier = 2;
4153 if (
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY')) {
4154 $senderissupplier =
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY');
4159 $object->printObjectLines($action, $societe,
$mysoc, $lineid, 1);
4166 if ($action !=
'editline') {
4169 $parameters = array();
4170 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
4174 if (empty($reshook)) {
4188 if ($action !=
'presend') {
4191 print
'<div class="tabsAction">';
4193 $parameters = array();
4194 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
4196 if (empty($reshook)) {
4199 $langs->load(
'subtotals');
4201 $url_button = array();
4203 $url_button[] = array(
4204 'lang' =>
'subtotals',
4206 'perm' => (
bool) $usercancreate,
4207 'label' => $langs->trans(
'AddTitleLine'),
4208 'url' =>
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'add_title_line'],
true)
4211 $url_button[] = array(
4212 'lang' =>
'subtotals',
4214 'perm' => (
bool) $usercancreate,
4215 'label' => $langs->trans(
'AddSubtotalLine'),
4216 'url' =>
dolBuildUrl($_SERVER[
'PHP_SELF'], [
'id' =>
$object->id,
'action' =>
'add_subtotal_line'],
true)
4219 print dolGetButtonAction(
'', $langs->trans(
'Subtotal'),
'default', $url_button,
'',
true);
4224 $ventilExportCompta =
$object->getVentilExportCompta();
4226 if ($ventilExportCompta == 0) {
4227 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=edit&token='.newToken().
'">'.$langs->trans(
'Modify').
'</a>';
4229 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseDispatchedInBookkeeping").
'">'.$langs->trans(
'Modify').
'</span>';
4234 $result = $discount->fetch(0, 0,
$object->id);
4241 if (!$objectidnext &&
$object->close_code !=
'replaced' && $usercancreate) {
4242 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=reopen&token='.newToken().
'">'.$langs->trans(
'ReOpen').
'</a>';
4244 if ($usercancreate) {
4245 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseReplacedInvoice").
'">'.$langs->trans(
'ReOpen').
'</span>';
4247 print
'<span class="butActionRefused classfortooltip">'.$langs->trans(
'ReOpen').
'</span>';
4257 if ($usercanvalidate) {
4258 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=valid&token='.newToken().
'"';
4259 print
'>'.$langs->trans(
'Validate').
'</a>';
4261 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'"';
4262 print
'>'.$langs->trans(
'Validate').
'</a>';
4268 if (empty($user->socid)) {
4271 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'presend',
'mode' =>
'init'],
true).
'#formmailbeforetitle',
'');
4273 print dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
'#',
'',
false);
4280 $langs->load(
"withdrawals");
4281 if ($resteapayer > 0) {
4282 if ($usercancreatecreditransfer) {
4283 if (!$objectidnext &&
$object->close_code !=
'replaced') {
4284 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>';
4286 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseReplacedInvoice").
'">'.$langs->trans(
'MakeBankTransferOrder').
'</span>';
4298 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>';
4305 if ($resteapayer == 0) {
4306 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseRemainderToPayIsZero").
'">'.$langs->trans(
'DoPaymentBack').
'</span>';
4308 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>';
4314 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.newToken().
'">'.$langs->trans(
'ConvertExcessPaidToReduc').
'</a>';
4318 && (
getDolGlobalString(
'SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED') ||
$object->getSommePaiement() == 0)
4320 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>';
4324 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.newToken().
'">'.$langs->trans(
'ConvertToReduc').
'</a>';
4335 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=paid&token='.newToken().
'">'.$langs->trans(
'ClassifyPaid').
'</a>';
4340 if ($totalpaid > 0 || $totalcreditnotes > 0) {
4342 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=paid&token='.newToken().
'">'.$langs->trans(
'ClassifyPaidPartially').
'</a>';
4345 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=canceled">'.$langs->trans(
'ClassifyCanceled').
'</a>';
4357 if (!$objectidnext) {
4358 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>';
4363 if ($action !=
'edit' && $usercancreate) {
4364 print
'<a class="butAction butActionClone" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=clone&socid='.
$object->socid.
'&token='.newToken().
'">'.$langs->trans(
'ToClone').
'</a>';
4369 if (!$objectidnext && count(
$object->lines) > 0) {
4370 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.
$object->id.
'&action=create">'.$langs->trans(
"ChangeIntoRepeatableInvoice").
'</a>';
4375 if ($action !=
'confirm_edit' && $usercandelete) {
4376 $isErasable =
$object->is_erasable();
4378 $enableDelete =
false;
4380 $params = (empty(
$conf->use_javascript_ajax) ? array() : array(
'attr' => array(
'class' =>
'reposition')));
4382 if ($isErasable == -4) {
4383 $htmltooltip = $langs->trans(
"DisabledBecausePayments");
4384 } elseif ($isErasable == -3) {
4385 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastSituationInvoice");
4386 } elseif ($isErasable == -2) {
4387 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastInvoice");
4388 } elseif ($isErasable == -1) {
4389 $htmltooltip = $langs->trans(
"DisabledBecauseDispatchedInBookkeeping");
4390 } elseif ($isErasable <= 0) {
4391 $htmltooltip = $langs->trans(
"DisabledBecauseNotErasable");
4393 $enableDelete =
true;
4396 print dolGetButtonAction($htmltooltip, $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.newToken(), (
string)
$object->id, $enableDelete, $params);
4400 if ($action !=
'confirm_edit') {
4401 print
'<div class="fichecenter"><div class="fichehalfleft">';
4407 $subdir =
get_exdir(
$object->id, 2, 0, 0, $object,
'invoice_supplier').$ref;
4409 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.
$object->id;
4410 $genallowed = $usercanread;
4411 $delallowed = $usercancreate;
4415 print $formfile->showdocuments(
'facture_fournisseur', $subdir, $filedir, $urlsource, (
int) $genallowed, (
int) $delallowed, $modelpdf, $genifempty, 0, 0, 40, 0,
'',
'',
'', $societe->default_lang);
4416 $somethingshown = $formfile->numoffiles;
4419 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'invoice_supplier'), 1);
4420 $linktoelem = $tmparray[
'linktoelem'];
4421 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
4422 print $htmltoenteralink;
4424 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
4426 print
'</div><div class="fichehalfright">';
4429 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
4431 $somethingshown = $formactions->showactions($object,
'invoice_supplier', $socid, 1,
'listaction'.($genallowed ?
'largetitle' :
''));
4433 print
'</div></div>';
4439 if (
GETPOST(
'modelselected')) {
4440 $action =
'presend';
4444 $modelmail =
'invoice_supplier_send';
4445 $defaulttopic =
'SendBillRef';
4447 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
4448 $trackid =
'sinv'.$object->id;
4450 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 translations.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
dol_get_last_hour($date, $gm='tzserver')
Return GMT time for last hour of a given GMT date (it replaces hours, min and second part to 23:59:59...
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
$date_start
Variables from include:
facturefourn_prepare_head(FactureFournisseur $object)
Prepare array with list of tabs.
dol_now($mode='gmt')
Return date for now.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
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.
getMultidirOutput($object, $module='', $forobject=0, $mode='output')
Return the full path of the directory where a module (or an object of a module) stores its files.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
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.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular VAT 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...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
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.