40require
'../../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
45require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture-rec.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
53if (isModEnabled(
"product")) {
54 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
55 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
57if (isModEnabled(
'project')) {
58 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
59 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
62if (isModEnabled(
'variants')) {
63 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
65if (isModEnabled(
'accounting')) {
66 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
78$langs->loadLangs(array(
'bills',
'compta',
'suppliers',
'companies',
'products',
'banks',
'admin'));
79if (isModEnabled(
'incoterm')) {
80 $langs->load(
'incoterm');
85$action =
GETPOST(
'action',
'aZ09');
88$cancel =
GETPOST(
'cancel',
'alpha');
89$backtopage =
GETPOST(
'backtopage',
'alpha');
90$backtopageforcancel =
'';
94$origin =
GETPOST(
'origin',
'alpha');
105$hookmanager->initHooks(array(
'invoicesuppliercard',
'globalcard'));
111$extrafields->fetch_name_optionals_label(
$object->table_element);
114if ($id > 0 || !empty($ref)) {
115 $ret =
$object->fetch($id, $ref);
119 $ret =
$object->fetch_thirdparty();
127if (!empty($user->socid)) {
128 $socid = $user->socid;
132$result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture',
'fk_soc',
'rowid', $isdraft);
135$usercanread = ($user->hasRight(
"fournisseur",
"facture",
"lire") || $user->hasRight(
"supplier_invoice",
"lire"));
136$usercancreate = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
137$usercandelete = (($user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"supprimer")) || ($usercancreate &&
$object->is_erasable() == 1));
138$usercancreatecontract = $user->hasRight(
"contrat",
"creer");
141$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"validate")));
142$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"send"));
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')]);
163$parameters = array(
'socid' => $socid);
164$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
169if (empty($reshook)) {
170 $backurlforlist = DOL_URL_ROOT.
'/fourn/facture/list.php';
172 if (empty($backtopage) || ($cancel && empty($id))) {
173 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
174 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
175 $backtopage = $backurlforlist;
177 $backtopage = DOL_URL_ROOT.
'/fourn/facture/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
183 if (!empty($backtopageforcancel)) {
184 header(
"Location: ".$backtopageforcancel);
186 } elseif (!empty($backtopage)) {
187 header(
"Location: ".$backtopage);
193 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
195 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
197 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
200 if (
GETPOST(
'linkedOrder') && empty($cancel) && $id > 0 && $permissiontoadd) {
203 $result =
$object->add_object_linked(
'order_supplier',
GETPOSTINT(
'linkedOrder'));
207 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd) {
209 '@phan-var-force FactureFournisseur $objectutil';
211 if (
GETPOST(
'newsupplierref',
'alphanohtml')) {
212 $objectutil->ref_supplier =
GETPOST(
'newsupplierref',
'alphanohtml');
216 $result = $objectutil->createFromClone($user, $id);
218 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
221 $langs->load(
"errors");
225 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' && $usercanvalidate) {
226 $idwarehouse =
GETPOST(
'idwarehouse');
231 $qualified_for_stock_change = 0;
233 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
235 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
239 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
240 $langs->load(
"stocks");
241 if (!$idwarehouse || $idwarehouse == -1) {
243 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
251 $result =
$object->validate($user,
'', $idwarehouse);
257 if (isModEnabled(
'category')) {
258 $categories =
GETPOST(
'categories',
'array');
259 if (method_exists(
$object,
'setCategories')) {
260 $object->setCategories($categories);
268 $outputlangs = $langs;
271 $newlang =
GETPOST(
'lang_id',
'aZ09');
274 $newlang =
$object->thirdparty->default_lang;
276 if (!empty($newlang)) {
278 $outputlangs->setDefaultLang($newlang);
283 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
290 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes' && $permissiontodelete) {
294 $isErasable =
$object->is_erasable();
296 if ($usercandelete && $isErasable > 0) {
297 $revertstock =
GETPOST(
'revertstock');
302 $qualified_for_stock_change = 0;
304 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
306 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
310 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
311 $langs->load(
"stocks");
312 if (!$idwarehouse || $idwarehouse == -1) {
314 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
317 $result =
$object->setDraft($user, $idwarehouse);
326 $result =
$object->delete($user);
328 header(
'Location: list.php?restore_lastsearch_values=1');
335 } elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate) {
337 $result =
$object->deleteLine($lineid);
357 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
364 } elseif ($action ==
'unlinkdiscount' && $usercancreate) {
367 $result = $discount->fetch(
GETPOSTINT(
"discountid"));
368 $discount->unlink_invoice();
369 } elseif ($action ==
'confirm_paid' && $confirm ==
'yes' && $usercancreate) {
371 $result =
$object->setPaid($user);
375 } elseif ($action ==
'confirm_paid_partially' && $confirm ==
'yes' && $usercancreate) {
378 $close_code =
GETPOST(
"close_code",
'restricthtml');
379 $close_note =
GETPOST(
"close_note",
'restricthtml');
381 $result =
$object->setPaid($user, $close_code, $close_note);
386 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Reason")),
null,
'errors');
388 } elseif ($action ==
'confirm_canceled' && $confirm ==
'yes' && $usercancreate) {
391 $close_code =
GETPOST(
"close_code",
'restricthtml');
392 $close_note =
GETPOST(
"close_note",
'restricthtml');
394 $result =
$object->setCanceled($user, $close_code, $close_note);
399 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Reason")),
null,
'errors');
404 if ($action ==
'setref_supplier' && $usercancreate) {
407 if (
$object->update($user) < 0) {
411 $outputlangs = $langs;
414 $newlang =
GETPOST(
'lang_id',
'aZ09');
417 $newlang =
$object->thirdparty->default_lang;
419 if (!empty($newlang)) {
421 $outputlangs->setDefaultLang($newlang);
425 $object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
431 if ($action ==
'setconditions' && $usercancreate) {
433 $object->cond_reglement_code = 0;
434 $object->cond_reglement_id = 0;
449 $new_date_echeance =
$object->calculate_date_lim_reglement();
450 if ($new_date_echeance) {
451 $object->date_echeance = $new_date_echeance;
456 $result =
$object->update($user);
468 } elseif ($action ==
'set_incoterms' && isModEnabled(
'incoterm') && $usercancreate) {
471 } elseif ($action ==
'settags' && isModEnabled(
'category') && $usercancreate) {
474 } elseif ($action ==
'setmode' && $usercancreate) {
477 } elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
479 $result =
$object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
480 } elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
483 } elseif ($action ==
'setbankaccount' && $usercancreate) {
486 } elseif ($action ==
'setvatreversecharge' && $usercancreate) {
488 $vatreversecharge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
489 $result =
$object->setVATReverseCharge($vatreversecharge);
492 if ($action ==
'settransportmode' && $usercancreate) {
495 } elseif ($action ==
'setlabel' && $usercancreate) {
499 $result =
$object->update($user);
503 } elseif ($action ==
'setdatef' && $usercancreate) {
507 setEventMessages($langs->trans(
"WarningInvoiceDateInFuture"),
null,
'warnings');
509 setEventMessages($langs->trans(
"WarningInvoiceDateTooFarInFuture"),
null,
'warnings');
516 $date_echence_calc =
$object->calculate_date_lim_reglement();
517 if (!empty(
$object->date_echeance)) {
518 $object->date_echeance = $date_echence_calc;
524 $result =
$object->update($user);
528 } elseif ($action ==
'setdate_lim_reglement' && $usercancreate) {
533 setEventMessages($langs->trans(
"DatePaymentTermCantBeLowerThanObjectDate"),
null,
'warnings');
535 $result =
$object->update($user);
539 } elseif ($action ==
"setabsolutediscount" && $usercancreate) {
555 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
557 $discount->fetch(
GETPOSTINT(
"remise_id_for_payment"));
561 $remaintopay =
$object->getRemainToPay(0);
565 setEventMessages($langs->trans(
"ErrorDiscountLargerThanRemainToPaySplitItBefore"),
null,
'errors');
569 $result = $discount->link_to_invoice(0, $id);
576 $newremaintopay =
$object->getRemainToPay(0);
577 if ($newremaintopay == 0) {
588 $outputlangs = $langs;
591 $newlang =
GETPOST(
'lang_id',
'aZ09');
594 $newlang =
$object->thirdparty->default_lang;
596 if (!empty($newlang)) {
598 $outputlangs->setDefaultLang($newlang);
602 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
607 } elseif ($action ==
'confirm_converttoreduc' && $confirm ==
'yes' && $usercancreate) {
615 $result = $discountcheck->fetch(0, 0,
$object->id);
627 $amount_ht = $amount_tva = $amount_ttc = array();
628 $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array();
632 foreach (
$object->lines as $line) {
633 if ($line->product_type < 9 && $line->total_ht != 0) {
634 $keyforvatrate = $line->tva_tx.($line->vat_src_code ?
' ('.$line->vat_src_code.
')' :
'');
636 $amount_ht[$keyforvatrate] += $line->total_ht;
637 $amount_tva[$keyforvatrate] += $line->total_tva;
638 $amount_ttc[$keyforvatrate] += $line->total_ttc;
639 $multicurrency_amount_ht[$keyforvatrate] += $line->multicurrency_total_ht;
640 $multicurrency_amount_tva[$keyforvatrate] += $line->multicurrency_total_tva;
641 $multicurrency_amount_ttc[$keyforvatrate] += $line->multicurrency_total_ttc;
645 '@phan-var-force array<string,float> $amount_ht
646 @phan-var-force array<string,float> $amount_tva
647 @phan-var-force array<string,float> $amount_ttc
648 @phan-var-force array<string,float> $multicurrency_amount_ht
649 @phan-var-force array<string,float> $multicurrency_amount_tva
650 @phan-var-force array<string,float> $multicurrency_amount_ttc';
654 $alreadypaid =
$object->getSommePaiement();
655 if ($alreadypaid && abs($alreadypaid) < abs(
$object->total_ttc)) {
656 $ratio = abs((
$object->total_ttc - $alreadypaid) /
$object->total_ttc);
657 foreach ($amount_ht as $vatrate => $val) {
658 $amount_ht[$vatrate] =
price2num($amount_ht[$vatrate] * $ratio,
'MU');
659 $amount_tva[$vatrate] =
price2num($amount_tva[$vatrate] * $ratio,
'MU');
660 $amount_ttc[$vatrate] =
price2num($amount_ttc[$vatrate] * $ratio,
'MU');
661 $multicurrency_amount_ht[$vatrate] =
price2num($multicurrency_amount_ht[$vatrate] * $ratio,
'MU');
662 $multicurrency_amount_tva[$vatrate] =
price2num($multicurrency_amount_tva[$vatrate] * $ratio,
'MU');
663 $multicurrency_amount_ttc[$vatrate] =
price2num($multicurrency_amount_ttc[$vatrate] * $ratio,
'MU');
672 $discount->description =
'(CREDIT_NOTE)';
674 $discount->description =
'(DEPOSIT)';
676 $discount->description =
'(EXCESS PAID)';
678 setEventMessages($langs->trans(
'CantConvertToReducAnInvoiceOfThisType'),
null,
'errors');
680 $discount->discount_type = 1;
681 $discount->fk_soc =
$object->socid;
682 $discount->socid =
$object->socid;
683 $discount->fk_invoice_supplier_source =
$object->id;
691 $sql =
'SELECT SUM(pf.amount) as total_paiements';
692 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.
'paiementfourn as p';
693 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN ('.
getEntity(
'c_paiement').
')';
694 $sql .=
' WHERE pf.fk_facturefourn = '.((int)
$object->id);
695 $sql .=
' AND pf.fk_paiementfourn = p.rowid';
696 $sql .=
' AND p.entity IN ('.getEntity(
'invoice').
')';
698 $resql = $db->query($sql);
703 $res = $db->fetch_object($resql);
704 $total_paiements = $res->total_paiements;
707 $total_creditnote_and_deposit = 0;
708 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
709 $sql .=
" re.description, re.fk_invoice_supplier_source";
710 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
711 $sql .=
" WHERE fk_invoice_supplier = ".((int)
$object->id);
712 $resql = $db->query($sql);
713 if (!empty($resql)) {
714 while ($obj = $db->fetch_object($resql)) {
715 $total_creditnote_and_deposit += $obj->amount_ttc;
721 $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit -
$object->total_ttc;
722 $discount->amount_tva = 0;
723 $discount->tva_tx = 0;
724 $discount->vat_src_code =
'';
727 $discount->multicurrency_code =
$object->multicurrency_code;
728 $discount->multicurrency_tx =
$object->multicurrency_tx;
729 $discount->multicurrency_total_ht = $discount->multicurrency_total_ttc = (float)
price2num((
float) $discount->amount_ttc * (float)
$object->multicurrency_tx,
'MT');
730 $discount->multicurrency_total_tva = 0;
732 $discount->multicurrency_amount_ht = $discount->multicurrency_amount_ttc = $discount->multicurrency_total_ttc;
733 $discount->multicurrency_amount_tva = 0;
735 $result = $discount->create($user);
741 foreach ($amount_ht as $tva_tx => $xxx) {
742 $discount->amount_ht = abs((
float) $amount_ht[$tva_tx]);
743 $discount->amount_tva = abs((
float) $amount_tva[$tva_tx]);
744 $discount->amount_ttc = abs((
float) $amount_ttc[$tva_tx]);
746 $discount->multicurrency_code =
$object->multicurrency_code;
747 $discount->multicurrency_tx =
$object->multicurrency_tx;
748 $discount->multicurrency_total_ht = abs((
float) $multicurrency_amount_ht[$tva_tx]);
749 $discount->multicurrency_total_tva = abs((
float) $multicurrency_amount_tva[$tva_tx]);
750 $discount->multicurrency_total_ttc = abs((
float) $multicurrency_amount_ttc[$tva_tx]);
752 $discount->multicurrency_amount_ht = abs((
float) $discount->multicurrency_total_ht);
753 $discount->multicurrency_amount_tva = abs((
float) $discount->multicurrency_total_tva);
754 $discount->multicurrency_amount_ttc = abs((
float) $discount->multicurrency_total_ttc);
759 if (preg_match(
'/\((.*)\)/', $tva_tx, $reg)) {
760 $vat_src_code = $reg[1];
761 $tva_tx = preg_replace(
'/\s*\(.*\)/',
'', $tva_tx);
764 $discount->tva_tx = abs((
float) $tva_tx);
765 $discount->vat_src_code = $vat_src_code;
767 $result = $discount->create($user);
778 $result =
$object->setPaid($user);
793 } elseif ($action ==
'confirm_delete_paiement' && $confirm ==
'yes' && $usercancreate) {
798 $result = $paiementfourn->fetch(
GETPOSTINT(
'paiement_id'));
800 $result = $paiementfourn->delete($user);
802 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
810 } elseif ($action ==
'add' && $usercancreate) {
815 $selectedLines =
GETPOST(
'toselect',
'array');
823 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
837 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
842 if (empty($dateinvoice)) {
843 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
855 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ReplaceInvoice")),
null,
'errors');
869 $object->date_echeance = $datedue;
875 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
876 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
878 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
879 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
900 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CorrectInvoice")),
null,
'errors');
903 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Supplier')),
null,
'errors');
908 if (empty($dateinvoice)) {
909 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
919 if (!
GETPOST(
'ref_supplier')) {
920 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'RefSupplierBill')),
null,
'errors');
928 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
943 $object->date_echeance = $datedue;
949 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
950 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
952 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
953 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
958 $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice :
'';
967 if (
GETPOSTINT(
'invoiceAvoirWithLines') == 1 && $id > 0) {
969 if ($facture_source->fetch(
$object->fk_facture_source) > 0) {
972 foreach ($facture_source->lines as $line) {
974 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
978 $line->fk_facture_fourn =
$object->id;
979 $line->fk_parent_line = $fk_parent_line;
981 $line->subprice = -$line->subprice;
982 $line->pa_ht = -((float) $line->pa_ht);
983 $line->total_ht = -$line->total_ht;
984 $line->total_tva = -$line->total_tva;
985 $line->total_ttc = -$line->total_ttc;
986 $line->total_localtax1 = -$line->total_localtax1;
987 $line->total_localtax2 = -$line->total_localtax2;
989 $result = $line->insert();
994 if ($result > 0 && $line->product_type == 9) {
995 $fk_parent_line = $result;
1003 if (
GETPOSTINT(
'invoiceAvoirWithPaymentRestAmount') == 1 &&
$id > 0) {
1005 if ($facture_source->fetch(
$object->fk_facture_source) > 0) {
1006 $totalpaid = $facture_source->getSommePaiement();
1007 $totalcreditnotes = $facture_source->getSumCreditNotesUsed();
1008 $totaldeposits = $facture_source->getSumDepositsUsed();
1009 $remain_to_pay = abs($facture_source->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits);
1010 $desc = $langs->trans(
'invoiceAvoirLineWithPaymentRestAmount');
1011 $retAddLine =
$object->addline($desc, $remain_to_pay, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
'TTC');
1013 if ($retAddLine < 0) {
1021 if (empty($dateinvoice)) {
1023 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
1033 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
1043 $object->note_public = trim(
GETPOST(
'note_public',
'restricthtml'));
1044 $object->note_private = trim(
GETPOST(
'note_private',
'restricthtml'));
1055 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
1056 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
1060 $object->fac_rec = $fac_recid;
1062 $fac_rec->fetch(
$object->fac_rec);
1063 $fac_rec->fetch_lines();
1064 $object->lines = $fac_rec->lines;
1071 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Supplier')),
null,
'errors');
1076 if (empty($dateinvoice)) {
1077 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')),
null,
'errors');
1087 if (!
GETPOST(
'ref_supplier')) {
1088 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'RefSupplierBill')),
null,
'errors');
1096 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"InvoiceSubtype")),
null,
'errors');
1113 $object->date_echeance = $datedue;
1119 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
1120 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
1122 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
1123 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
1128 if (empty(
$object->date_echeance)) {
1129 $object->date_echeance =
$object->calculate_date_lim_reglement();
1135 if (!$error &&
GETPOST(
'origin',
'alpha') &&
GETPOST(
'originid')) {
1137 $element = $subelement =
GETPOST(
'origin',
'alpha');
1145 if ($element ==
'order') {
1146 $element = $subelement =
'commande';
1148 if ($element ==
'propal') {
1149 $element =
'comm/propal';
1150 $subelement =
'propal';
1152 if ($element ==
'contract') {
1153 $element = $subelement =
'contrat';
1155 if ($element ==
'order_supplier') {
1157 $subelement =
'fournisseur.commande';
1159 if ($element ==
'project') {
1160 $element =
'projet';
1167 $classname = ucfirst($subelement);
1168 if ($classname ==
'Fournisseur.commande') {
1169 $classname =
'CommandeFournisseur';
1171 $objectsrc =
new $classname($db);
1172 $objectsrc->fetch($originid);
1173 $objectsrc->fetch_thirdparty();
1180 if (
$object->origin ==
'reception') {
1181 $objectsrc->fetchObjectLinked();
1183 if (count($objectsrc->linkedObjectsIds[
'order_supplier']) > 0) {
1184 foreach ($objectsrc->linkedObjectsIds[
'order_supplier'] as $key => $value) {
1185 $object->linkedObjectsIds[
'order_supplier'] = $value;
1195 $classname = ucfirst($subelement);
1196 if ($classname ==
'Fournisseur.commande') {
1197 $classname =
'CommandeFournisseur';
1199 $srcobject =
new $classname($db);
1201 $result = $srcobject->fetch(
GETPOSTINT(
'originid'));
1204 $typeamount =
GETPOST(
'typedeposit',
'alpha');
1209 $amountdeposit = array();
1211 if ($typeamount ==
'amount') {
1212 $amount = $valuedeposit;
1214 $amount = $srcobject->total_ttc * ((float) $valuedeposit / 100);
1217 $TTotalByTva = array();
1218 foreach ($srcobject->lines as &$line) {
1219 if (!empty($line->special_code)) {
1222 $TTotalByTva[$line->tva_tx] += $line->total_ttc;
1224 '@phan-var-force array<string,float> $TTotalByTva';
1226 $amount_ttc_diff = 0.;
1227 foreach ($TTotalByTva as $tva => &$total) {
1228 $coef = $total / $srcobject->total_ttc;
1229 $am = $amount * $coef;
1230 $amount_ttc_diff += $am;
1231 $amountdeposit[$tva] += $am / (1 + (float) $tva / 100);
1234 if ($typeamount ==
'amount') {
1235 $amountdeposit[0] = $valuedeposit;
1236 } elseif ($typeamount ==
'variable') {
1239 $lines = $srcobject->lines;
1240 $numlines = count($lines);
1241 for ($i = 0; $i < $numlines; $i++) {
1243 if (empty($lines[$i]->qty)) {
1246 if (!empty($lines[$i]->special_code)) {
1250 $totalamount += $lines[$i]->total_ht;
1251 $tva_tx = $lines[$i]->tva_tx;
1252 $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * (float) $valuedeposit) / 100;
1256 if ($totalamount == 0) {
1257 $amountdeposit[0] = 0;
1262 $amountdeposit[0] = 0;
1266 $amount_ttc_diff = array_key_exists(0, $amountdeposit) ? $amountdeposit[0] : 0;
1269 foreach ($amountdeposit as $tva => $amount) {
1270 if (empty($amount)) {
1275 'amount' =>
'FixAmount',
1276 'variable' =>
'VarAmount'
1278 $descline =
'(DEPOSIT)';
1280 if ($typeamount ==
'amount') {
1281 $descline .=
' ('.price($valuedeposit, 0, $langs, 0, - 1, - 1, (!empty(
$object->multicurrency_code) ?
$object->multicurrency_code :
$conf->currency)).
')';
1282 } elseif ($typeamount ==
'variable') {
1283 $descline .=
' ('.$valuedeposit.
'%)';
1286 $descline .=
' - '.$srcobject->ref;
1316 $diff =
$object->total_ttc - $amount_ttc_diff;
1320 $subprice_diff =
$object->lines[0]->subprice - $diff / (1 +
$object->lines[0]->tva_tx / 100);
1326 $object->lines[0]->localtax1_tx,
1327 $object->lines[0]->localtax2_tx,
1329 $object->lines[0]->fk_product,
1332 $object->lines[0]->product_type,
1333 $object->lines[0]->remise_percent,
1335 $object->lines[0]->date_start,
1344 } elseif ($result > 0) {
1345 $lines = $srcobject->lines;
1346 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
1347 $srcobject->fetch_lines();
1348 $lines = $srcobject->lines;
1351 $num = count($lines);
1352 for ($i = 0; $i < $num; $i++) {
1353 if (!in_array($lines[$i]->
id, $selectedLines)) {
1357 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->product_label);
1358 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
1361 if (method_exists($lines[$i],
'fetch_optionals')) {
1362 $lines[$i]->fetch_optionals();
1367 $date_start = $lines[$i]->date_debut_prevue;
1368 if ($lines[$i]->date_debut_reel) {
1369 $date_start = $lines[$i]->date_debut_reel;
1371 if ($lines[$i]->date_start) {
1372 $date_start = $lines[$i]->date_start;
1374 $date_end = $lines[$i]->date_fin_prevue;
1375 if ($lines[$i]->date_fin_reel) {
1376 $date_end = $lines[$i]->date_fin_reel;
1378 if ($lines[$i]->date_end) {
1379 $date_end = $lines[$i]->date_end;
1382 $tva_tx = $lines[$i]->tva_tx;
1384 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', (
string) $tva_tx)) {
1385 $tva_tx .=
' ('.$lines[$i]->vat_src_code.
')';
1389 $object->special_code = $lines[$i]->special_code;
1394 $pu_currency = $lines[$i]->multicurrency_subprice;
1396 $pu = $lines[$i]->subprice;
1405 $lines[$i]->localtax1_tx,
1406 $lines[$i]->localtax2_tx,
1408 $lines[$i]->fk_product,
1409 $lines[$i]->remise_percent,
1413 $lines[$i]->info_bits,
1418 $lines[$i]->array_options,
1419 $lines[$i]->fk_unit,
1422 $lines[$i]->ref_supplier,
1423 $lines[$i]->special_code
1440 $parameters = array(
'objFrom' => $srcobject);
1441 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters,
$object, $action);
1451 } elseif (!$error) {
1461 $langs->load(
"errors");
1471 $outputlangs = $langs;
1472 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1479 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
1482 } elseif ($action ==
'updateline' && $usercancreate) {
1486 if (!
$object->fetch($id) > 0) {
1492 $tva_tx = str_replace(
'*',
'', $tva_tx);
1494 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_subprice') !=
'') {
1496 $price_base_type =
'HT';
1499 $price_base_type =
'TTC';
1502 if (
GETPOST(
'productid') > 0) {
1504 if (
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY') == 1) {
1506 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1512 $label = $prod->description;
1513 if (trim(
GETPOST(
'product_desc',
'restricthtml')) != trim($label)) {
1514 $label =
GETPOST(
'product_desc',
'restricthtml');
1517 $type = $prod->type;
1519 $label =
GETPOST(
'product_desc',
'restricthtml');
1528 if (preg_match(
'/\*/', $tva_tx)) {
1533 $tva_tx = str_replace(
'*',
'', $tva_tx);
1541 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1542 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1544 if (is_array($extralabelsline)) {
1545 foreach ($extralabelsline as $key => $value) {
1546 unset($_POST[
"options_".$key]);
1550 $result =
$object->updateline(
1562 (
float) $remise_percent,
1572 unset($_POST[
'label']);
1573 unset($_POST[
'fourn_ref']);
1574 unset($_POST[
'date_starthour']);
1575 unset($_POST[
'date_startmin']);
1576 unset($_POST[
'date_startsec']);
1577 unset($_POST[
'date_startday']);
1578 unset($_POST[
'date_startmonth']);
1579 unset($_POST[
'date_startyear']);
1580 unset($_POST[
'date_endhour']);
1581 unset($_POST[
'date_endmin']);
1582 unset($_POST[
'date_endsec']);
1583 unset($_POST[
'date_endday']);
1584 unset($_POST[
'date_endmonth']);
1585 unset($_POST[
'date_endyear']);
1586 unset($_POST[
'price_ttc']);
1587 unset($_POST[
'price_ht']);
1594 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') && (
GETPOST(
'alldate_start',
'alpha') ||
GETPOST(
'alldate_end',
'alpha')) && $usercancreate) {
1598 foreach (
$object->lines as $line) {
1599 if ($line->product_type == 1) {
1600 $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);
1603 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') !=
'' && $usercancreate) {
1605 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
1606 $vat_rate = str_replace(
'*',
'', $vat_rate);
1609 foreach (
$object->lines as $line) {
1610 $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);
1612 } elseif ($action ==
'addline' && $usercancreate) {
1621 $ret =
$object->fetch_thirdparty();
1623 $langs->load(
'errors');
1628 $line_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
1632 $prod_entry_mode =
GETPOST(
'prod_entry_mode');
1633 if ($prod_entry_mode ==
'free') {
1640 $price_ht_devise =
'';
1642 $price_ttc_devise =
'';
1644 if (
GETPOST(
'price_ht') !==
'') {
1647 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
1650 if (
GETPOST(
'price_ttc') !==
'') {
1653 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
1654 $price_ttc_devise =
price2num(
GETPOST(
'multicurrency_price_ttc'),
'CU', 2);
1661 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef,
'alpha'),
'', 2) : 0);
1662 if (empty($remise_percent)) {
1663 $remise_percent = 0;
1667 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1668 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1670 if (is_array($extralabelsline)) {
1672 foreach ($extralabelsline as $key => $value) {
1673 unset($_POST[
"options_".$key]);
1677 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
1678 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1681 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') &&
GETPOST(
'type') < 0) {
1682 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
1687 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1')
1688 && (((
float) $price_ht < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) || $price_ht ===
'')
1689 && (((
float) $price_ht_devise < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) || $price_ht_devise ===
'')
1690 && ((
float) $price_ttc < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES') || $price_ttc ===
'')
1691 && ((
float) $price_ttc_devise < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES') || $price_ttc_devise ===
'')
1692 &&
$object->type != $object::TYPE_CREDIT_NOTE) {
1693 if (((
float) $price_ht < 0 || (
float) $price_ttc < 0) && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) {
1694 $langs->load(
"errors");
1695 if (
$object->type == $object::TYPE_DEPOSIT) {
1697 setEventMessages($langs->trans(
"ErrorLinesCantBeNegativeOnDeposits"),
null,
'errors');
1699 setEventMessages($langs->trans(
"ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv(
"UnitPrice"), $langs->transnoentitiesnoconv(
"CustomerAbsoluteDiscountShort")),
null,
'errors');
1704 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' && $price_ht_devise ===
'') {
1705 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'UnitPrice')),
null,
'errors');
1709 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') && !
GETPOST(
'dp_desc')) {
1710 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
1713 if (!
GETPOST(
'qty',
'alpha')) {
1714 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1718 if (!$error && isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1719 if ($combinations =
GETPOST(
'combinations',
'array')) {
1723 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1724 $idprod = $res->fk_product_child;
1726 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1732 if ($prod_entry_mode !=
'free' && empty($error)) {
1736 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
1741 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
1742 $idprod = (int) $reg[1];
1743 $res = $productsupplier->fetch($idprod);
1746 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
1748 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1749 if ($productsupplier->fourn_socid != $socid) {
1750 $productsupplier->ref_supplier =
'';
1753 $fksoctosearch =
$object->thirdparty->id;
1754 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1756 } elseif (
GETPOSTINT(
'idprodfournprice') > 0) {
1757 $qtytosearch = (float) $qty;
1759 $idprod = $productsupplier->get_buyprice(
GETPOSTINT(
'idprodfournprice'), $qtytosearch);
1760 $res = $productsupplier->fetch($idprod);
1764 $label = $productsupplier->label;
1767 $outputlangs = $langs;
1769 if (
GETPOST(
'lang_id',
'aZ09')) {
1770 $newlang =
GETPOST(
'lang_id',
'aZ09');
1772 if (empty($newlang)) {
1773 $newlang =
$object->thirdparty->default_lang;
1775 if (!empty($newlang)) {
1777 $outputlangs->setDefaultLang($newlang);
1779 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->
description;
1781 $desc = $productsupplier->description;
1784 if (!empty($productsupplier->desc_supplier) &&
getDolGlobalString(
'PRODUIT_FOURN_TEXTS')) {
1785 $desc = $productsupplier->desc_supplier;
1796 $ref_supplier = $productsupplier->ref_supplier;
1799 if (!GETPOSTISSET(
'tva_tx')) {
1800 $tmpidprodfournprice =
GETPOST(
'idprodfournprice',
'alpha');
1801 if (is_numeric($tmpidprodfournprice) && (
int) $tmpidprodfournprice > 0) {
1802 $tmpidprodfournprice = (int) $tmpidprodfournprice;
1804 $tmpidprodfournprice = 0;
1810 if (empty($tva_tx) || empty($tva_npr)) {
1816 $type = $productsupplier->type;
1817 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1818 $price_base_type =
'HT';
1820 $pu_devise =
price2num($price_ht_devise,
'CU');
1821 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
1822 $price_base_type =
'TTC';
1824 $pu_devise =
price2num($price_ttc_devise,
'CU');
1826 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
1827 if (empty(
$object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code !=
$object->multicurrency_code)) {
1828 $pu = $productsupplier->fourn_pu;
1831 $pu = $productsupplier->fourn_pu;
1832 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
1836 $ref_supplier = $productsupplier->ref_supplier;
1857 min($rank, count(
$object->lines) + 1),
1860 $productsupplier->fk_unit,
1863 GETPOST(
'fourn_ref',
'alpha'),
1867 if ($idprod == -99 || $idprod == 0) {
1870 $langs->load(
"errors");
1871 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
1873 if ($idprod == -1) {
1876 $langs->load(
"errors");
1877 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
1879 } elseif (empty($error)) {
1880 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1881 $tva_tx = str_replace(
'*',
'', $tva_tx);
1882 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1885 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1889 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
1897 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1901 $pu_ht =
price2num((
float) $pu_ttc / (1 + ((
float) $tva_tx / 100)),
'MU');
1903 $price_base_type =
'HT';
1904 $pu_devise =
price2num($price_ht_devise,
'CU');
1906 $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);
1910 if (!$error && $result > 0) {
1915 $outputlangs = $langs;
1918 $newlang =
GETPOST(
'lang_id',
'aZ09');
1921 $newlang =
$object->thirdparty->default_lang;
1923 if (!empty($newlang)) {
1925 $outputlangs->setDefaultLang($newlang);
1930 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1936 unset($_POST [
'prod_entry_mode']);
1938 unset($_POST[
'qty']);
1939 unset($_POST[
'type']);
1940 unset($_POST[
'remise_percent']);
1941 unset($_POST[
'pu']);
1942 unset($_POST[
'price_ht']);
1943 unset($_POST[
'multicurrency_price_ht']);
1944 unset($_POST[
'price_ttc']);
1945 unset($_POST[
'fourn_ref']);
1946 unset($_POST[
'tva_tx']);
1947 unset($_POST[
'label']);
1948 unset($localtax1_tx);
1949 unset($localtax2_tx);
1950 unset($_POST[
'np_marginRate']);
1951 unset($_POST[
'np_markRate']);
1952 unset($_POST[
'dp_desc']);
1953 unset($_POST[
'idprodfournprice']);
1954 unset($_POST[
'units']);
1956 unset($_POST[
'date_starthour']);
1957 unset($_POST[
'date_startmin']);
1958 unset($_POST[
'date_startsec']);
1959 unset($_POST[
'date_startday']);
1960 unset($_POST[
'date_startmonth']);
1961 unset($_POST[
'date_startyear']);
1962 unset($_POST[
'date_endhour']);
1963 unset($_POST[
'date_endmin']);
1964 unset($_POST[
'date_endsec']);
1965 unset($_POST[
'date_endday']);
1966 unset($_POST[
'date_endmonth']);
1967 unset($_POST[
'date_endyear']);
1974 } elseif ($action ==
'classin' && $usercancreate) {
1976 $result =
$object->setProject($projectid);
1977 } elseif ($action ==
'confirm_edit' && $confirm ==
'yes' && $usercancreate) {
1981 $totalpaid =
$object->getSommePaiement();
1982 $resteapayer =
$object->total_ttc - $totalpaid;
1985 $ventilExportCompta =
$object->getVentilExportCompta();
1987 if (!$ventilExportCompta) {
1990 $idwarehouse =
GETPOST(
'idwarehouse');
1994 $qualified_for_stock_change = 0;
1996 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1998 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2002 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
2003 $langs->load(
"stocks");
2004 if (!$idwarehouse || $idwarehouse == -1) {
2006 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
2011 $object->setDraft($user, $idwarehouse);
2015 $outputlangs = $langs;
2018 $newlang =
GETPOST(
'lang_id',
'aZ09');
2021 $newlang =
$object->thirdparty->default_lang;
2023 if (!empty($newlang)) {
2025 $outputlangs->setDefaultLang($newlang);
2030 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
2039 } elseif ($action ==
'reopen' && $usercancreate) {
2041 $result =
$object->fetch($id);
2044 $result =
$object->setUnpaid($user);
2046 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
2055 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
2058 $triggersendname =
'BILL_SUPPLIER_SENTBYMAIL';
2060 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
2061 $trackid =
'sinv'.$object->id;
2062 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
2065 $upload_dir =
$conf->fournisseur->facture->dir_output;
2066 $permissiontoadd = $usercancreate;
2067 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
2070 if ($action ==
'calculate' && $usercancreate) {
2071 $calculationrule =
GETPOST(
'calculationrule');
2075 $result =
$object->update_price(0, (($calculationrule ==
'totalofround') ?
'0' :
'1'), 0,
$object->thirdparty);
2081 if ($action ==
'update_extras' && $permissiontoeditextra) {
2084 $attribute_name =
GETPOST(
'attribute',
'aZ09');
2087 $ret = $extrafields->setOptionalsFromPost(
null,
$object, $attribute_name);
2093 $result =
$object->updateExtraField($attribute_name,
'BILL_SUPPLIER_MODIFY');
2101 $action =
'edit_extras';
2106 if ($action ==
'addcontact' && $usercancreate) {
2107 $result =
$object->fetch($id);
2109 if ($result > 0 && $id > 0) {
2112 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
2116 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2119 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2120 $langs->load(
"errors");
2121 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
2126 } elseif ($action ==
'swapstatut' && $usercancreate) {
2133 } elseif ($action ==
'deletecontact' && $usercancreate) {
2139 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2153$form =
new Form($db);
2155$bankaccountstatic =
new Account($db);
2157if (isModEnabled(
'project')) {
2163$title =
$object->ref.
" - ".$langs->trans(
'Card');
2164if ($action ==
'create') {
2165 $title = $langs->trans(
"NewSupplierInvoice");
2167$help_url =
'EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores|DE:Modul_Lieferantenrechnungen';
2168llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-fourn-facture page-card');
2171if ($action ==
'create') {
2173 $selectedLines = array();
2175 print
load_fiche_titre($langs->trans(
'NewSupplierInvoice'),
'',
'supplier_invoice');
2179 $currency_code =
$conf->currency;
2180 $vat_reverse_charge = 0;
2186 if (isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2187 $currency_code = $societe->multicurrency_code;
2191 if (!empty($origin) && !empty($originid)) {
2193 $element = $subelement = $origin;
2195 if ($element ==
'project') {
2196 $projectid = $originid;
2197 $element =
'projet';
2201 if ($element ==
'order') {
2202 $element = $subelement =
'commande';
2204 if ($element ==
'propal') {
2205 $element =
'comm/propal';
2206 $subelement =
'propal';
2208 if ($element ==
'contract') {
2209 $element = $subelement =
'contrat';
2211 if ($element ==
'order_supplier') {
2213 $subelement =
'fournisseur.commande';
2217 $classname = ucfirst($subelement);
2218 if ($classname ==
'Fournisseur.commande') {
2219 $classname =
'CommandeFournisseur';
2221 $objectsrc =
new $classname($db);
2222 '@phan-var-force Project|Commande|Propal|Facture|Contrat|CommandeFournisseur|CommonObject $objectsrc';
2223 $objectsrc->fetch($originid);
2224 $objectsrc->fetch_thirdparty();
2226 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
2228 $soc = $objectsrc->thirdparty;
2230 $cond_reglement_id = 0;
2231 $mode_reglement_id = 0;
2235 $transport_mode_id = 0;
2238 if (!empty($objectsrc->cond_reglement_id)) {
2239 $cond_reglement_id = $objectsrc->cond_reglement_id;
2241 if (!empty($objectsrc->mode_reglement_id)) {
2242 $mode_reglement_id = $objectsrc->mode_reglement_id;
2244 if (!empty($objectsrc->fk_account)) {
2245 $fk_account = $objectsrc->fk_account;
2247 if (!empty($objectsrc->transport_mode_id)) {
2248 $transport_mode_id = $objectsrc->transport_mode_id;
2251 if (empty($cond_reglement_id)
2252 || empty($mode_reglement_id)
2253 || empty($fk_account)
2254 || empty($transport_mode_id)
2256 if ($origin ==
'reception') {
2258 if (!isset($objectsrc->supplier_order)) {
2259 $objectsrc->fetch_origin();
2262 if (!empty($objectsrc->origin_object)) {
2263 $originObject = $objectsrc->origin_object;
2264 if (empty($cond_reglement_id) && !empty($originObject->cond_reglement_id)) {
2265 $cond_reglement_id = $originObject->cond_reglement_id;
2267 if (empty($mode_reglement_id) && !empty($originObject->mode_reglement_id)) {
2268 $mode_reglement_id = $originObject->mode_reglement_id;
2270 if (empty($fk_account) && !empty($originObject->fk_account)) {
2271 $fk_account = $originObject->fk_account;
2273 if (empty($transport_mode_id) && !empty($originObject->transport_mode_id)) {
2274 $transport_mode_id = $originObject->transport_mode_id;
2281 if (empty($cond_reglement_id) && !empty($soc->cond_reglement_supplier_id)) {
2282 $cond_reglement_id = $soc->cond_reglement_supplier_id;
2284 if (empty($mode_reglement_id) && !empty($soc->mode_reglement_supplier_id)) {
2285 $mode_reglement_id = $soc->mode_reglement_supplier_id;
2287 if (empty($fk_account) && !empty($soc->fk_account)) {
2288 $fk_account = $soc->fk_account;
2290 if (empty($transport_mode_id) && !empty($soc->transport_mode_id)) {
2291 $transport_mode_id = $soc->transport_mode_id;
2296 if (isModEnabled(
"multicurrency")) {
2297 if (!empty($objectsrc->multicurrency_code)) {
2298 $currency_code = $objectsrc->multicurrency_code;
2300 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
2301 $currency_tx = $objectsrc->multicurrency_tx;
2306 $dateinvoice = ($datetmp ==
'' ? (!
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ? -1 :
'') : $datetmp);
2308 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2311 $objectsrc->fetch_optionals();
2312 $object->array_options = $objectsrc->array_options;
2314 $cond_reglement_id = !empty($societe->cond_reglement_supplier_id) ? $societe->cond_reglement_supplier_id : 0;
2315 $mode_reglement_id = !empty($societe->mode_reglement_supplier_id) ? $societe->mode_reglement_supplier_id : 0;
2316 $vat_reverse_charge = (empty($societe) ?
'' : $societe->vat_reverse_charge);
2317 $transport_mode_id = !empty($societe->transport_mode_supplier_id) ? $societe->transport_mode_supplier_id : 0;
2318 $fk_account = !empty($societe->fk_account) ? $societe->fk_account : 0;
2320 $dateinvoice = ($datetmp ==
'' ? (
getDolGlobalInt(
'MAIN_AUTOFILL_DATE') ?
'' : -1) : $datetmp);
2322 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2324 if (isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2325 $currency_code = $societe->multicurrency_code;
2330 if (empty($cond_reglement_id)) {
2331 $cond_reglement_id =
GETPOST(
"cond_reglement_id");
2335 if (empty($mode_reglement_id)) {
2336 $mode_reglement_id =
GETPOST(
"mode_reglement_id");
2340 if (!
GETPOST(
'changecompany')) {
2341 if (GETPOSTISSET(
'cond_reglement_id')) {
2342 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2344 if (GETPOSTISSET(
'mode_reglement_id')) {
2345 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2347 if (GETPOSTISSET(
'cond_reglement_id')) {
2352 $note_public =
$object->getDefaultCreateValueFor(
'note_public', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_public : null));
2353 $note_private =
$object->getDefaultCreateValueFor(
'note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_private : null));
2355 if ($origin ==
'contrat') {
2356 $langs->load(
"admin");
2357 $text = $langs->trans(
"ToCreateARecurringInvoice");
2358 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv(
"MenuFinancial"), $langs->transnoentitiesnoconv(
"SupplierBills"), $langs->transnoentitiesnoconv(
"ListOfTemplates"));
2360 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv(
'Module2300Name'));
2362 print
info_admin($text, 0, 0,
'0',
'opacitymedium').
'<br>';
2365 print
'<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
2366 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2367 print
'<input type="hidden" name="action" value="add">';
2368 print
'<input type="hidden" name="changecompany" value="0">';
2370 if (!empty($societe->id) && $societe->id > 0) {
2371 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">'.
"\n";
2373 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
2374 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
2375 if (!empty($currency_tx)) {
2376 print
'<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
2378 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2383 $parameters = array();
2385 $reshook = $hookmanager->executeHooks(
'tabContentCreateSupplierInvoice', $parameters,
$object, $action);
2386 if (empty($reshook)) {
2387 print
'<table class="border centpercent">';
2390 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
'Draft').
'</td></tr>';
2394 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2395 $invoice_predefined->fetch($fac_recid);
2399 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
2402 if (!empty($societe->id) && $societe->id > 0 && ($fac_recid <= 0 || !empty($invoice_predefined->frequency))) {
2403 $absolute_discount = $societe->getAvailableDiscounts(
null,
'', 0, 1);
2404 print $societe->getNomUrl(1,
'supplier');
2405 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
2407 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
2408 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');
2411 print
'<script type="text/javascript">
2412 $(document).ready(function() {
2413 $("#socid").change(function() {
2414 console.log("We have changed the company - Reload page");
2416 $("input[name=action]").val("create");
2417 $("input[name=changecompany]").val("1");
2418 $("form[name=add]").submit();
2423 if ($fac_recid <= 0) {
2424 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>';
2430 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2431 $invoice_predefined->fetch($fac_recid);
2433 $dateinvoice = $invoice_predefined->date_when;
2434 if (empty($projectid)) {
2435 $projectid = $invoice_predefined->fk_project;
2437 $cond_reglement_id = $invoice_predefined->cond_reglement_id;
2438 $mode_reglement_id = $invoice_predefined->mode_reglement_id;
2439 $fk_account = $invoice_predefined->fk_account;
2440 $note_public = $invoice_predefined->note_public;
2441 $note_private = $invoice_predefined->note_private;
2443 if (!empty($invoice_predefined->multicurrency_code)) {
2444 $currency_code = $invoice_predefined->multicurrency_code;
2446 if (!empty($invoice_predefined->multicurrency_tx)) {
2447 $currency_tx = $invoice_predefined->multicurrency_tx;
2450 $sql =
'SELECT r.rowid, r.titre as title, r.total_ttc';
2451 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn_rec as r';
2452 $sql .=
' WHERE r.fk_soc = '. (int) $invoice_predefined->socid;
2454 $resql = $db->query($sql);
2456 $num = $db->num_rows($resql);
2460 print
'<tr><td>'.$langs->trans(
'CreateFromRepeatableInvoice').
'</td><td>';
2462 print
'<select class="flat" id="fac_rec" name="fac_rec">';
2463 print
'<option value="0" selected></option>';
2465 $objp = $db->fetch_object($resql);
2466 print
'<option value="'.$objp->rowid.
'"';
2467 if ($fac_recid == $objp->rowid) {
2469 $exampletemplateinvoice->fetch($fac_recid);
2471 print
'>'.$objp->title.
' ('.
price($objp->total_ttc).
' '.$langs->trans(
"TTC").
')</option>';
2477 print
'<script type="text/javascript">
2478 $(document).ready(function() {
2479 $("#fac_rec").change(function() {
2480 console.log("We have changed the template invoice - Reload page");
2482 $("input[name=action]").val("create");
2483 $("form[name=add]").submit();
2497 print
'<tr><td class="fieldrequired">'.$langs->trans(
'RefSupplierBill').
'</td><td><input name="ref_supplier" value="'.(GETPOSTISSET(
'ref_supplier') ?
GETPOST(
'ref_supplier') : (!empty($objectsrc->ref_supplier) ? $objectsrc->ref_supplier :
'')).
'" type="text"';
2498 if (!empty($societe->id) && $societe->id > 0) {
2504 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'Type').
'</td><td>';
2506 print
'<div class="tagtable">'.
"\n";
2509 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2510 $tmp =
'<input type="radio" id="radio_standard" name="type" value="0"'.(GETPOSTINT(
'type') ?
'' :
'checked').
'> ';
2511 $desc = $form->textwithpicto($tmp.
'<label for="radio_standard">'.$langs->trans(
"InvoiceStandardAsk").
'</label>', $langs->transnoentities(
"InvoiceStandardDesc"), 1,
'help',
'', 0, 3);
2513 print
'</div></div>';
2515 if (empty($origin) || ($origin ==
'order_supplier' && !empty($originid))) {
2518 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2519 $tmp =
'<input type="radio" id="radio_deposit" name="type" value="3"' . (
GETPOSTINT(
'type') == 3 ?
' checked' :
'') .
'> ';
2520 print
'<script type="text/javascript">
2521 jQuery(document).ready(function() {
2522 jQuery("#typestandardinvoice, #valuestandardinvoice").click(function() {
2523 jQuery("#radio_standard").prop("checked", true);
2525 jQuery("#typedeposit, #valuedeposit").click(function() {
2526 jQuery("#radio_deposit").prop("checked", true);
2528 jQuery("#typedeposit").change(function() {
2529 console.log("We change type of down payment");
2530 jQuery("#radio_deposit").prop("checked", true);
2531 setRadioForTypeOfInvoice();
2533 jQuery("#radio_standard, #radio_deposit, #radio_replacement, #radio_template").change(function() {
2534 setRadioForTypeOfInvoice();
2536 function setRadioForTypeOfInvoice() {
2537 console.log("Change radio");
2538 if (jQuery("#radio_deposit").prop("checked") && (jQuery("#typedeposit").val() == \'amount\' || jQuery("#typedeposit").val() == \'variable\')) {
2539 jQuery(".checkforselect").prop("disabled", true);
2540 jQuery(".checkforselect").prop("checked", false);
2542 jQuery(".checkforselect").prop("disabled", false);
2543 jQuery(".checkforselect").prop("checked", true);
2549 $tmp = $tmp.
'<label for="radio_deposit" >'.$langs->trans(
"InvoiceDeposit").
'</label>';
2551 $desc = $form->textwithpicto($tmp, $langs->transnoentities(
"InvoiceDepositDesc"), 1,
'help',
'', 0, 3);
2552 print
'<table class="nobordernopadding"><tr>';
2556 if ($origin ==
'order_supplier') {
2557 print
'<td class="nowrap" style="padding-left: 15px">';
2559 'amount' => $langs->transnoentitiesnoconv(
'FixAmount', $langs->transnoentitiesnoconv(
'Deposit')),
2560 'variable' => $langs->transnoentitiesnoconv(
'VarAmountOneLine', $langs->transnoentitiesnoconv(
'Deposit')),
2561 'variablealllines' => $langs->transnoentitiesnoconv(
'VarAmountAllLines')
2563 print $form->selectarray(
'typedeposit', $arraylist,
GETPOST(
'typedeposit',
'aZ09'), 0, 0, 0,
'', 1);
2565 print
'<td class="nowrap" style="padding-left: 5px">';
2566 print
'<span class="opacitymedium paddingleft">'.$langs->trans(
"AmountOrPercent").
'</span><input type="text" id="valuedeposit" name="valuedeposit" class="width75 right" value="' .
GETPOSTINT(
'valuedeposit') .
'"/>';
2569 print
'</tr></table>';
2571 print
'</div></div>';
2640 if (empty($origin)) {
2641 if (!empty($societe->id) && $societe->id > 0) {
2645 $facids = $facturestatic->list_qualified_avoir_supplier_invoices($societe->id);
2652 foreach ($facids as $key => $valarray) {
2653 $newinvoice_static->id = $key;
2654 $newinvoice_static->ref = $valarray [
'ref'];
2655 $newinvoice_static->status = $valarray [
'status'];
2656 $newinvoice_static->statut = $valarray [
'status'];
2657 $newinvoice_static->type = $valarray [
'type'];
2658 $newinvoice_static->paid = $valarray [
'paye'];
2659 $newinvoice_static->paye = $valarray [
'paye'];
2661 $optionsav .=
'<option value="'.$key.
'"';
2663 $optionsav .=
' selected';
2666 $optionsav .= $newinvoice_static->ref;
2667 $optionsav .=
' ('.$newinvoice_static->getLibStatut(1, $valarray [
'paymentornot']).
')';
2668 $optionsav .=
'</option>';
2671 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2672 $tmp =
'<input type="radio" id="radio_creditnote" name="type" value="2"'.(GETPOST(
'type') == 2 ?
' checked' :
'');
2674 $tmp .=
' disabled';
2678 print
'<script type="text/javascript">
2679 jQuery(document).ready(function() {
2680 if (! jQuery("#radio_creditnote").is(":checked"))
2682 jQuery("#credit_note_options").hide();
2684 jQuery("#radio_creditnote").click(function() {
2685 jQuery("#credit_note_options").show();
2687 jQuery("#radio_standard, #radio_replacement, #radio_deposit").click(function() {
2688 jQuery("#credit_note_options").hide();
2692 $text = $tmp.
'<label for="radio_creditnote">'.$langs->transnoentities(
"InvoiceAvoirAsk").
'</label> ';
2694 $text .=
'<select class="flat valignmiddle" name="fac_avoir" id="fac_avoir"';
2696 $text .=
' disabled';
2700 $text .=
'<option value="-1"></option>';
2701 $text .= $optionsav;
2703 $text .=
'<option value="-1">'.$langs->trans(
"NoInvoiceToCorrect").
'</option>';
2705 $text .=
'</select>';
2706 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2709 print
'<div id="credit_note_options" class="clearboth">';
2710 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' :
'').
' /> ';
2711 print
'<label for="invoiceAvoirWithLines">'.$langs->trans(
'invoiceAvoirWithLines').
"</label>";
2712 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' :
'').
' /> ';
2713 print
'<label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans(
'invoiceAvoirWithPaymentRestAmount').
"</label>";
2716 print
'</div></div>';
2719 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2721 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="0" disabled> ';
2723 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="2"> ';
2725 $text = $tmp.$langs->trans(
"InvoiceAvoir").
' ';
2726 $text .=
'<span class="opacitymedium">('.$langs->trans(
"YouMustCreateInvoiceFromSupplierThird").
')</span> ';
2727 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2729 print
'</div></div>'.
"\n";
2740 print
'<tr><td class="fieldrequired">'.$langs->trans(
'InvoiceSubtype').
'</td><td colspan="2">';
2741 print $form->getSelectInvoiceSubtype(
GETPOSTINT(
'subtype'),
'subtype', 1, 0,
'');
2745 if (!empty($societe->id) && $societe->id > 0) {
2747 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
2749 $thirdparty = $societe;
2751 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$societe->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
2752 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2758 print
'<tr><td>'.$langs->trans(
'Label').
'</td><td><input class="minwidth200" name="label" value="'.
dol_escape_htmltag(
GETPOST(
'label')).
'" type="text"></td></tr>';
2762 print
'<tr><td class="fieldrequired">'.$langs->trans(
'DateInvoice').
'</td><td>';
2763 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2764 print $form->selectDate($dateinvoice ? (
int) $dateinvoice :
'',
'', 0, 0, 0,
"add", 1, 1);
2768 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
2769 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
2770 print $form->getSelectConditionsPaiements($cond_reglement_id,
'cond_reglement_id', -1, 1, 0,
'maxwidth200 widthcentpercentminusx');
2774 print
'<tr><td>'.$langs->trans(
'DateMaxPayment').
'</td><td>';
2775 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2776 print $form->selectDate($datedue,
'ech', 0, 0, 0,
"add", 1, 1);
2780 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
2781 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
2782 $form->select_types_paiements((
string) $mode_reglement_id,
'mode_reglement_id',
'DBIT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx');
2786 if (isModEnabled(
"bank")) {
2787 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
2789 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes($fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
2794 if (isModEnabled(
'project')) {
2797 $langs->load(
'projects');
2798 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td>';
2799 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');
2800 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>';
2805 if (isModEnabled(
'incoterm')) {
2807 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), !empty($objectsrc->label_incoterms) ? $objectsrc->label_incoterms :
'', 1).
'</label></td>';
2808 print
'<td colspan="3" class="maxwidthonsmartphone">';
2809 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2810 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 :
''));
2816 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
2817 print
'<tr><td>' . $langs->trans(
'VATReverseCharge') .
'</td><td>';
2819 if (GETPOSTISSET(
'vat_reverse_charge')) {
2820 $vat_reverse_charge = (
GETPOST(
'vat_reverse_charge',
'alpha') ==
'on' ||
GETPOST(
'vat_reverse_charge',
'alpha') ==
'1') ? 1 : 0;
2821 } elseif ($vat_reverse_charge == 1 || $societe->vat_reverse_charge == 1 || ($societe->country_code !=
'FR' &&
isInEEC($societe) && !empty($societe->tva_intra))) {
2822 $vat_reverse_charge = 1;
2824 $vat_reverse_charge = 0;
2827 print
'<input type="checkbox" name="vat_reverse_charge"'. (!empty($vat_reverse_charge) ?
' checked ' :
'') .
'>';
2832 if (isModEnabled(
"multicurrency")) {
2834 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'',
$object, 0).
'</td>';
2835 print
'<td class="maxwidthonsmartphone">';
2836 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
2837 $used_currency_code = $currency_code;
2838 if (!
GETPOST(
'changecompany')) {
2839 $used_currency_code = GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code',
'alpha') : $currency_code;
2841 print $form->selectMultiCurrency($used_currency_code,
'multicurrency_code');
2847 if ($fac_recid > 0) {
2848 $dateexample = $dateinvoice;
2849 if (empty($dateexample)) {
2852 $substitutionarray = array(
2853 '__TOTAL_HT__' => $langs->trans(
"AmountHT").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ht).
')',
2854 '__TOTAL_TTC__' => $langs->trans(
"AmountTTC").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ttc).
')',
2855 '__INVOICE_PREVIOUS_MONTH__' => $langs->trans(
"PreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%m').
')',
2856 '__INVOICE_MONTH__' => $langs->trans(
"MonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%m').
')',
2857 '__INVOICE_NEXT_MONTH__' => $langs->trans(
"NextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%m').
')',
2858 '__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans(
"TextPreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%B').
')',
2859 '__INVOICE_MONTH_TEXT__' => $langs->trans(
"TextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%B').
')',
2860 '__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans(
"TextNextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%B').
')',
2861 '__INVOICE_PREVIOUS_YEAR__' => $langs->trans(
"PreviousYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'y'),
'%Y').
')',
2862 '__INVOICE_YEAR__' => $langs->trans(
"YearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%Y').
')',
2863 '__INVOICE_NEXT_YEAR__' => $langs->trans(
"NextYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'y'),
'%Y').
')'
2866 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
2867 foreach ($substitutionarray as $key => $val) {
2868 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
2870 $htmltext .=
'</i>';
2874 if (isModEnabled(
'intracommreport')) {
2875 $langs->loadLangs(array(
"intracommreport"));
2876 print
'<!-- If module intracomm on -->'.
"\n";
2877 print
'<tr><td>'.$langs->trans(
'IntracommReportTransportMode').
'</td><td>';
2878 $form->selectTransportMode(GETPOSTISSET(
'transport_mode_id') ?
GETPOST(
'transport_mode_id') : $transport_mode_id,
'transport_mode_id');
2882 if (empty($reshook)) {
2883 print
$object->showOptionals($extrafields,
'create');
2887 if (isModEnabled(
"category")) {
2888 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
2889 print $form->selectCategories(Categorie::TYPE_SUPPLIER_INVOICE,
'categories',
$object);
2894 print
'<tr><td>'.$langs->trans(
'NotePublic').
'</td>';
2896 $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%');
2897 print $doleditor->Create(1);
2903 print
'<tr><td>'.$langs->trans(
'NotePrivate').
'</td>';
2905 $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%');
2906 print $doleditor->Create(1);
2912 if (!empty($objectsrc) && is_object($objectsrc)) {
2913 print
"\n<!-- ".$classname.
" info -->";
2915 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2916 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2917 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2918 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2919 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2921 $txt = $langs->trans($classname);
2922 if ($classname ==
'CommandeFournisseur') {
2923 $langs->load(
'orders');
2924 $txt = $langs->trans(
"SupplierOrder");
2926 print
'<tr><td>'.$txt.
'</td><td>'.$objectsrc->getNomUrl(1);
2928 $objectsrc->fetchObjectLinked($originid, $origin,
null,
'invoice_supplier');
2930 if (isset($objectsrc->linkedObjects[
'invoice_supplier'])) {
2931 $invoice_supplier = $objectsrc->linkedObjects[
'invoice_supplier'];
2933 $invoice_supplier = [];
2935 '@phan-var-force null|FactureFournisseur[] $invoice_supplier';
2938 if (is_array($invoice_supplier)) {
2939 $cntinvoice = count($invoice_supplier);
2941 if ($cntinvoice >= 1) {
2943 echo
' ('.$langs->trans(
'LatestRelatedBill').end($invoice_supplier)->getNomUrl(1).
')';
2948 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
2949 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
2950 if ($mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
2951 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
2954 if ($mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
2955 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
2957 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
2959 if (isModEnabled(
"multicurrency")) {
2960 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
2961 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
2962 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2967 $parameters = array();
2968 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2969 print $hookmanager->resPrint;
2977 print $form->buttonsSaveCancel(
"CreateDraft");
2980 if (!empty($objectsrc) && is_object($objectsrc)) {
2983 $title = $langs->trans(
'ProductsAndServices');
2986 print
'<div class="div-table-responsive-no-min">';
2987 print
'<table class="noborder centpercent">';
2989 $objectsrc->printOriginLinesList(
'', $selectedLines);
2997 if ($id > 0 || !empty($ref)) {
3003 $productstatic =
new Product($db);
3005 $result =
$object->fetch($id, $ref);
3010 $result =
$object->fetch_thirdparty();
3016 $societe =
$object->thirdparty;
3018 $totalpaid =
$object->getSommePaiement();
3019 $totalcreditnotes =
$object->getSumCreditNotesUsed();
3020 $totaldeposits =
$object->getSumDepositsUsed();
3028 $resteapayer =
price2num(
$object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
3031 $multicurrency_resteapayer = 0;
3032 if (isModEnabled(
"multicurrency")) {
3033 $multicurrency_totalpaid =
$object->getSommePaiement(1);
3034 $multicurrency_totalcreditnotes =
$object->getSumCreditNotesUsed(1);
3035 $multicurrency_totaldeposits =
$object->getSumDepositsUsed(1);
3036 $multicurrency_resteapayer =
price2num(
$object->multicurrency_total_ttc - $multicurrency_totalpaid - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits,
'MT');
3040 if ($resteapayer == 0 && $multicurrency_resteapayer != 0 &&
$object->multicurrency_code !=
$conf->currency) {
3041 $resteapayer =
price2num((
float) $multicurrency_resteapayer /
$object->multicurrency_tx,
'MT');
3048 $resteapayeraffiche = $resteapayer;
3051 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
3052 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
3054 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
3055 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
3058 $absolute_discount = $societe->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
3059 $absolute_creditnote = $societe->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
3060 $absolute_discount =
price2num($absolute_discount,
'MT');
3061 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
3065 $objectidnext =
$object->getIdReplacingInvoice();
3068 $titre = $langs->trans(
'SupplierInvoice');
3070 print
dol_get_fiche_head($head,
'card', $titre, -1,
'supplier_invoice', 0,
'',
'', 0,
'', 1);
3075 if ($action ==
'converttoreduc') {
3078 $type_fac =
'ExcessPaid';
3080 $type_fac =
'CreditNote';
3082 $type_fac =
'Deposit';
3084 $text = $langs->trans(
'ConfirmConvertToReducSupplier', strtolower($langs->transnoentities($type_fac)));
3085 $text .=
'<br>'.$langs->trans(
'ConfirmConvertToReducSupplier2');
3086 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id, $langs->trans(
'ConvertToReduc'), $text,
'confirm_converttoreduc',
'',
"yes", 2);
3090 if ($action ==
'clone') {
3092 $formquestion = array(
3093 array(
'type' =>
'text',
'name' =>
'newsupplierref',
'label' => $langs->trans(
"RefSupplierBill"),
'value' => $langs->trans(
"CopyOf").
' '.
$object->ref_supplier),
3094 array(
'type' =>
'date',
'name' =>
'newdate',
'label' => $langs->trans(
"Date"),
'value' =>
dol_now())
3097 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneInvoice',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1, 250);
3101 if ($action ==
'valid') {
3103 if (preg_match(
'/^[\(]?PROV/i',
$object->ref) || empty(
$object->ref)) {
3105 $numref =
$object->getNextNumRef($societe);
3114 $text = $langs->trans(
'ConfirmValidateBill', $numref);
3122 $formquestion = array();
3124 $qualified_for_stock_change = 0;
3126 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3128 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3131 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
3132 $langs->load(
"stocks");
3133 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3136 $warehouse_array = $warehouse->list_array();
3137 if (count($warehouse_array) == 1) {
3139 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3142 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3144 $formquestion = array(
3145 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3149 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateBill'), $text,
'confirm_valid', $formquestion, 1, 1);
3154 if ($action ==
'edit') {
3155 $formquestion = array();
3157 $qualified_for_stock_change = 0;
3159 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3161 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3163 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
3164 $langs->load(
"stocks");
3165 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3168 $warehouse_array = $warehouse->list_array();
3169 if (count($warehouse_array) == 1) {
3171 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3174 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3176 $formquestion = array(
3177 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3180 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'UnvalidateBill'), $langs->trans(
'ConfirmUnvalidateBill',
$object->ref),
'confirm_edit', $formquestion, 1, 1);
3184 if ($action ==
'paid' && ($resteapayer <= 0 || (
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') && $resteapayer ==
$object->total_ttc))) {
3185 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidBill',
$object->ref),
'confirm_paid',
'', 0, 1);
3188 if ($action ==
'paid' && $resteapayer > 0 && (!
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') || $resteapayer !=
$object->total_ttc)) {
3192 $close[$i][
'code'] =
'discount_vat';
3194 $close[$i][
'code'] =
'badsupplier';
3196 $close[$i][
'code'] =
'other';
3200 $close[$i][
'label'] = $langs->trans(
"HelpEscompte").
'<br><br>'.$langs->trans(
"ConfirmClassifyPaidPartiallyReasonDiscountVatDesc");
3202 $close[$i][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3204 $close[$i][
'label'] = $langs->trans(
"Other");
3208 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonDiscount", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3210 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadCustomer", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3212 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"Other"), $close[$i][
'label'], 1);
3215 $arrayreasons = array();
3216 foreach ($close as $key => $val) {
3217 $arrayreasons[$close[$key][
'code']] = $close[$key][
'reason'];
3221 $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'));
3223 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?facid='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidPartially',
$object->ref),
'confirm_paid_partially', $formquestion,
"yes", 1, 310);
3227 if ($action ==
'canceled') {
3229 $close[1][
'code'] =
'badsupplier';
3230 $close[2][
'code'] =
'abandon';
3232 $close[1][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3233 $close[2][
'label'] = $langs->trans(
"ConfirmClassifyAbandonReasonOtherDesc");
3235 $close[1][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadSupplier",
$object->ref), $close[1][
'label'], 1);
3236 $close[2][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyAbandonReasonOther"), $close[2][
'label'], 1);
3238 $arrayreasons[$close[1][
'code']] = $close[1][
'reason'];
3239 $arrayreasons[$close[2][
'code']] = $close[2][
'reason'];
3242 $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'));
3244 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'CancelBill'), $langs->trans(
'ConfirmCancelBill',
$object->ref),
'confirm_canceled', $formquestion,
"yes", 1, 280);
3248 if ($action ==
'delete') {
3249 $formquestion = array();
3251 $qualified_for_stock_change = 0;
3253 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3255 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3258 if (isModEnabled(
'stock') &&
getDolGlobalString(
'STOCK_CALCULATE_ON_SUPPLIER_BILL') && $qualified_for_stock_change) {
3259 $langs->load(
"stocks");
3260 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3263 $warehouse_array = $warehouse->list_array();
3265 $selectwarehouse =
'<span class="questionrevertstock hidden">';
3266 if (count($warehouse_array) == 1) {
3268 $selectwarehouse .=
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3271 $selectwarehouse .= $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3273 $selectwarehouse .=
'</span>';
3275 $selectyesno = array(0 => $langs->trans(
'No'), 1 => $langs->trans(
'Yes'));
3277 print
'<script type="text/javascript">
3278 $(document).ready(function() {
3279 $("#revertstock").change(function() {
3280 if(this.value > 0) {
3281 $(".questionrevertstock").removeClass("hidden");
3283 $(".questionrevertstock").addClass("hidden");
3289 $formquestion = array(
3290 array(
'type' =>
'select',
'name' =>
'revertstock',
'label' => $langs->trans(
"RevertProductsToStock"),
'select_show_empty' => 0,
'values' => $selectyesno),
3291 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $selectwarehouse,
'tdclass' =>
'questionrevertstock hidden')
3295 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteBill'), $langs->trans(
'ConfirmDeleteBill'),
'confirm_delete', $formquestion, 1, 1);
3297 if ($action ==
'deletepayment') {
3298 $payment_id =
GETPOST(
'paiement_id');
3299 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&paiement_id='.$payment_id, $langs->trans(
'DeletePayment'), $langs->trans(
'ConfirmDeletePayment'),
'confirm_delete_paiement',
'', 0, 1);
3303 if ($action ==
'ask_deleteline') {
3304 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
3307 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
3308 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
3309 if (empty($reshook)) {
3310 $formconfirm .= $hookmanager->resPrint;
3311 } elseif ($reshook > 0) {
3312 $formconfirm = $hookmanager->resPrint;
3320 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
3322 $morehtmlref =
'<div class="refidno">';
3324 $morehtmlref .= $form->editfieldkey(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, (
int) $usercancreate,
'string',
'', 0, 1);
3325 $morehtmlref .= $form->editfieldval(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, $usercancreate,
'string',
'',
null,
null,
'', 1);
3327 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1,
'supplier');
3329 $morehtmlref .=
' <div class="inline-block valignmiddle">(<a class="valignmiddle" href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.((int)
$object->thirdparty->id).
'">'.$langs->trans(
"OtherBills").
'</a>)</div>';
3332 if (isModEnabled(
'project')) {
3333 $langs->load(
"projects");
3334 $morehtmlref .=
'<br>';
3335 if ($permissiontoadd) {
3336 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
3337 if ($action !=
'classify') {
3338 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.((int)
$object->id).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
3340 $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');
3342 if (!empty(
$object->fk_project)) {
3344 $proj->fetch(
$object->fk_project);
3345 $morehtmlref .= $proj->getNomUrl(1);
3347 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
3352 $morehtmlref .=
'</div>';
3354 $object->totalpaid = $totalpaid;
3356 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
3359 $parameters = array();
3361 $reshook = $hookmanager->executeHooks(
'tabContentViewSupplierInvoice', $parameters,
$object, $action);
3362 if (empty($reshook)) {
3363 print
'<div class="fichecenter">';
3364 print
'<div class="fichehalfleft">';
3365 print
'<div class="underbanner clearboth"></div>';
3367 print
'<table class="border tableforfield centpercent">';
3370 print
'<tr><td class="titlefield">'.$langs->trans(
'Type').
'</td><td>';
3371 print
'<span class="badgeneutral">';
3375 print
' '.$object->getSubtypeLabel(
'facture_fourn');
3379 $facreplaced->fetch(
$object->fk_facture_source);
3380 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
'</span>';
3383 if (
$object->fk_facture_source > 0) {
3385 $facusing->fetch(
$object->fk_facture_source);
3386 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
'</span>';
3388 $langs->load(
"errors");
3389 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"WarningCorrectedInvoiceNotFound").
'</span>';
3394 $object->getListIdAvoirFromInvoice();
3396 if (!empty(
$object->creditnote_ids)) {
3397 $invoicecredits = array();
3398 foreach (
$object->creditnote_ids as $invoiceid) {
3400 $creditnote->fetch($invoiceid);
3401 $invoicecredits[] = $creditnote->getNomUrl(1);
3403 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"InvoiceHasAvoir") . (count($invoicecredits) ?
' ' :
'') . implode(
',', $invoicecredits);
3406 if (isset($objectidnext) && $objectidnext > 0) {
3409 $facthatreplace->fetch($objectidnext);
3410 print
' <span class="opacitymediumbycolor paddingleft">'.str_replace(
'{s1}', $facthatreplace->getNomUrl(1), $langs->transnoentities(
"ReplacedByInvoice",
'{s1}')).
'</span>';
3414 $result = $discount->fetch(0, 0,
$object->id);
3416 print
' <span class="opacitymediumbycolor paddingleft">';
3417 $s = $langs->trans(
"CreditNoteConvertedIntoDiscount",
'{s1}',
'{s2}');
3418 $s = str_replace(
'{s1}',
$object->getLibType(1), $s);
3419 $s = str_replace(
'{s2}', $discount->getNomUrl(1,
'discount'), $s);
3421 print
'</span><br>';
3425 if (
$object->fk_fac_rec_source > 0) {
3427 $result = $tmptemplate->fetch(
$object->fk_fac_rec_source);
3429 print
' <span class="opacitymediumbycolor paddingleft">';
3430 $link =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.$tmptemplate->id.
'">'.
dol_escape_htmltag($tmptemplate->title).
'</a>';
3431 $s = $langs->transnoentities(
"GeneratedFromSupplierTemplate", $link);
3441 print
'<!-- Discounts -->'.
"\n";
3442 print
'<tr><td>'.$langs->trans(
'DiscountStillRemaining');
3445 $thirdparty = $societe;
3447 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
3453 print
'<td>'.$form->editfieldkey(
"Label",
'label',
$object->label,
$object, (
int) $usercancreate).
'</td>';
3454 print
'<td>'.$form->editfieldval(
"Label",
'label',
$object->label,
$object, $usercancreate).
'</td>';
3462 print $form->editfieldkey(
"DateInvoice",
'datef', (
string)
$object->date,
$object, (int) $form_permission,
'datepicker');
3463 print
'</td><td colspan="3">';
3464 print $form->editfieldval(
"Date",
'datef',
$object->date,
$object, $form_permission,
'datepicker');
3468 $langs->load(
'bills');
3469 print
'<tr><td class="nowrap">';
3470 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3471 print $langs->trans(
'PaymentConditions');
3473 if ($action !=
'editconditions' && $form_permission) {
3474 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>';
3476 print
'</tr></table>';
3478 if ($action ==
'editconditions') {
3479 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id');
3481 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'none');
3488 print $form->editfieldkey(
"DateMaxPayment",
'date_lim_reglement', (
string)
$object->date_echeance,
$object, (
int) $form_permission,
'datepicker');
3490 print $form->editfieldval(
"DateMaxPayment",
'date_lim_reglement',
$object->date_echeance,
$object, $form_permission,
'datepicker');
3491 if ($action !=
'editdate_lim_reglement' &&
$object->hasDelay()) {
3497 $langs->load(
'bills');
3498 print
'<tr><td class="nowrap">';
3499 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3500 print $langs->trans(
'PaymentMode');
3502 if ($action !=
'editmode' && $form_permission) {
3503 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>';
3505 print
'</tr></table>';
3507 if ($action ==
'editmode') {
3508 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
3510 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
3515 if (isModEnabled(
"bank")) {
3516 print
'<tr><td class="nowrap">';
3517 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3518 print $langs->trans(
'BankAccount');
3520 if ($action !=
'editbankaccount' && $usercancreate) {
3521 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>';
3523 print
'</tr></table>';
3525 if ($action ==
'editbankaccount') {
3526 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
3528 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'none');
3536 print
'<tr><td class="nowrap">';
3537 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3538 print $langs->trans(
'VATReverseCharge');
3540 if ($action !=
'editvatreversecharge' && $usercancreate) {
3541 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editvatreversecharge&id='.
$object->id.
'">'.
img_edit($langs->trans(
'SetVATReverseCharge'), 1).
'</a></td>';
3543 print
'</tr></table>';
3545 if ($action ==
'editvatreversecharge') {
3546 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
3547 print
'<input type="hidden" name="action" value="setvatreversecharge">';
3548 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3550 print
'<input type="checkbox" name="vat_reverse_charge"' . (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
'>';
3552 print
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
3555 print
'<input type="checkbox" name="vat_reverse_charge"'. (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
' disabled>';
3561 if (isModEnabled(
'incoterm')) {
3563 print
'<table width="100%" class="nobordernopadding"><tr><td>';
3564 print $langs->trans(
'IncotermLabel');
3565 print
'<td><td class="right">';
3566 if ($usercancreate) {
3567 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.
$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit().
'</a>';
3571 print
'</td></tr></table>';
3574 if ($action !=
'editincoterm') {
3575 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3577 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
3583 if (isModEnabled(
'intracommreport')) {
3584 $langs->loadLangs(array(
"intracommreport"));
3585 print
'<!-- If module intracomm on -->'.
"\n";
3587 print
'<table class="nobordernopadding centpercent"><tr><td>';
3588 print $langs->trans(
'IntracommReportTransportMode');
3590 if ($action !=
'edittransportmode' && ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"))) {
3591 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edittransportmode&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit().
'</a></td>';
3593 print
'</tr></table>';
3596 if ($action ==
'edittransportmode') {
3597 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->transport_mode_id,
'transport_mode_id', 1, 1);
3599 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->transport_mode_id,
'none');
3605 if (isModEnabled(
'category')) {
3607 print
'<table class="nobordernopadding centpercent"><tr><td>';
3608 print $langs->trans(
"Categories");
3609 print
'<td><td class="right">';
3610 if ($usercancreate) {
3611 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.
$object->id.
'&action=edittags&token='.
newToken().
'">'.
img_edit().
'</a>';
3615 print
'</td></tr></table>';
3618 if ($action ==
'edittags') {
3619 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?facid='.
$object->id.
'">';
3620 print
'<input type="hidden" name="action" value="settags">';
3621 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3622 print $form->selectCategories(Categorie::TYPE_SUPPLIER_INVOICE,
'categories',
$object);
3623 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
3626 print $form->showCategories(
$object->id, Categorie::TYPE_SUPPLIER_INVOICE, 1);
3634 if (
$object->status != $object::STATUS_DRAFT) {
3638 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3643 print
'<div class="fichehalfright">';
3644 print
'<div class="underbanner clearboth"></div>';
3646 print
'<table class="border tableforfield centpercent">';
3648 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
3651 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
3652 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3653 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3654 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3659 print
'<td>' . $langs->trans(
'AmountVAT') .
'</td>';
3660 print
'<td class="nowrap amountcard right">';
3661 if (
GETPOST(
'calculationrule')) {
3662 $calculationrule =
GETPOST(
'calculationrule',
'alpha');
3664 $calculationrule = (!
getDolGlobalString(
'MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND_SUPPLIER') ?
'totalofround' :
'roundoftotal');
3666 if ($calculationrule ==
'totalofround') {
3667 $calculationrulenum = 1;
3669 $calculationrulenum = 2;
3672 if (
$object->getVentilExportCompta() == 0) {
3673 $s =
'<span class="hideonsmartphone opacitymedium">' . $langs->trans(
"ReCalculate") .
' </span>';
3674 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&token='.newToken().
'&calculationrule=totalofround">' . $langs->trans(
"Mode1") .
'</a>';
3676 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&token='.newToken().
'&calculationrule=roundoftotal">' . $langs->trans(
"Mode2") .
'</a>';
3677 print
'<div class="inline-block">';
3678 print $form->textwithtooltip($s, $langs->trans(
"CalculationRuleDesc", $calculationrulenum) .
'<br>' . $langs->trans(
"CalculationRuleDescSupplier"), 2, 1,
img_picto(
'',
'help'),
'', 3,
'', 0,
'recalculate');
3679 print
' ';
3682 print
'<span class="nowraponall">'.price(
$object->total_tva, 1, $langs, 0, -1, -1,
$conf->currency).
'</span>';
3684 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3685 print
'<td class="nowraponall amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3689 if ($societe->localtax1_assuj ==
"1") {
3691 print
'<td>' . $langs->transcountry(
"AmountLT1", $societe->country_code) .
'</td>';
3692 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 1, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3695 if ($societe->localtax2_assuj ==
"1") {
3697 print
'<td>' . $langs->transcountry(
"AmountLT2", $societe->country_code) .
'</td>';
3698 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 1, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3703 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
3704 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
3705 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
3706 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3724 if (isModEnabled(
'project')) {
3727 if (isModEnabled(
"bank")) {
3731 if (isModEnabled(
'incoterm')) {
3734 if (isModEnabled(
"multicurrency")) {
3739 if ($societe->localtax1_assuj ==
"1") {
3742 if ($societe->localtax2_assuj ==
"1") {
3746 $sql =
'SELECT p.datep as dp, p.ref, p.num_paiement as num_payment, p.rowid, p.fk_bank,';
3747 $sql .=
' c.id as payment_type, c.code as payment_code,';
3748 $sql .=
' pf.amount,';
3749 $sql .=
' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal';
3750 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn as p';
3751 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
3752 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
3753 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id';
3754 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid';
3755 $sql .=
' WHERE pf.fk_facturefourn = '.((int)
$object->id);
3756 $sql .=
' ORDER BY p.datep, p.tms';
3758 $result = $db->query($sql);
3760 $num = $db->num_rows($result);
3763 print
'<div class="div-table-responsive-no-min">';
3764 print
'<table class="noborder paymenttable centpercent">';
3765 print
'<tr class="liste_titre">';
3767 print
'<td><span class="hideonsmartphone">'.$langs->trans(
'Date').
'</span></td>';
3768 print
'<td><span class="hideonsmartphone">'.$langs->trans(
'Type').
'</span></td>';
3769 if (isModEnabled(
"bank")) {
3770 print
'<td class="right">'.$langs->trans(
'BankAccount').
'</td>';
3772 print
'<td class="right">'.$langs->trans(
'Amount').
'</td>';
3773 print
'<td width="18"> </td>';
3778 $objp = $db->fetch_object($result);
3780 $paymentstatic->id = $objp->rowid;
3781 $paymentstatic->datepaye = $db->jdate($objp->dp);
3782 $paymentstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
3783 $paymentstatic->num_payment = $objp->num_payment;
3785 $paymentstatic->paiementcode = $objp->payment_code;
3786 $paymentstatic->type_code = $objp->payment_code;
3787 $paymentstatic->type_label = $objp->payment_type;
3789 print
'<tr class="oddeven">';
3790 print
'<td class="nowraponall">';
3791 print $paymentstatic->getNomUrl(1);
3793 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
'</td>';
3794 $s = $form->form_modes_reglement(
'', $objp->payment_type,
'none',
'', 1, 0,
'', 1).
' '.$objp->num_payment;
3795 print
'<td class="tdoverflowmax125" title="'.dol_escape_htmltag($s).
'">';
3798 if (isModEnabled(
"bank")) {
3799 $bankaccountstatic->id = $objp->baid;
3800 $bankaccountstatic->ref = $objp->baref;
3801 $bankaccountstatic->label = $objp->baref;
3802 $bankaccountstatic->number = $objp->banumber;
3804 if (isModEnabled(
'accounting')) {
3805 $bankaccountstatic->account_number = $objp->account_number;
3808 $accountingjournal->fetch($objp->fk_accountancy_journal);
3809 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
3812 print
'<td class="right">';
3813 if ($objp->baid > 0) {
3814 print $bankaccountstatic->getNomUrl(1,
'transactions');
3818 print
'<td class="right">'.price($sign * $objp->amount).
'</td>';
3819 print
'<td class="center">';
3821 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deletepayment&token='.
newToken().
'&paiement_id='.$objp->rowid.
'">';
3827 $totalpaid += $objp->amount;
3831 print
'<tr class="oddeven"><td colspan="'.$nbcols.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td><td></td><td></td></tr>';
3854 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3855 print
'<span class="opacitymedium">';
3857 print $langs->trans(
'AlreadyPaidNoCreditNotesNoDeposits');
3859 print $langs->trans(
'AlreadyPaid');
3862 print
'</td><td class="right"'.(($totalpaid > 0) ?
' class="amountalreadypaid"' :
'').
'>'.
price($totalpaid).
'</td><td> </td></tr>';
3865 $resteapayeraffiche = $resteapayer;
3867 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
3870 $creditnoteamount = 0;
3873 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
3874 $sql .=
" re.description, re.fk_invoice_supplier_source";
3875 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
3876 $sql .=
" WHERE fk_invoice_supplier = ".((int)
$object->id);
3877 $resql = $db->query($sql);
3879 $num = $db->num_rows($resql);
3883 $obj = $db->fetch_object($resql);
3884 $invoice->fetch($obj->fk_invoice_supplier_source);
3885 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3887 print $langs->trans(
"CreditNote").
' ';
3890 print $langs->trans(
"Deposit").
' ';
3892 print $invoice->getNomUrl(0);
3894 print
'<td class="right">'.price($obj->amount_ttc).
'</td>';
3895 print
'<td class="right">';
3896 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=unlinkdiscount&discountid='.$obj->rowid.
'">';
3897 print
img_picto($langs->transnoentitiesnoconv(
"RemoveDiscount"),
'unlink');
3902 $creditnoteamount += $obj->amount_ttc;
3905 $depositamount += $obj->amount_ttc;
3914 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3915 print
'<span class="opacitymedium">';
3916 print $form->textwithpicto($langs->trans(
"Discount"), $langs->trans(
"HelpEscompte"), - 1);
3918 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3919 $resteapayeraffiche = 0;
3920 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3924 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3925 print
'<span class="opacitymedium">';
3926 print $form->textwithpicto($langs->trans(
"Abandoned"), $langs->trans(
"HelpAbandonBadCustomer"), - 1);
3928 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3930 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3934 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3935 print
'<span class="opacitymedium">';
3936 print $form->textwithpicto($langs->trans(
"ProductReturned"), $langs->trans(
"HelpAbandonProductReturned"), - 1);
3938 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3939 $resteapayeraffiche = 0;
3940 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3944 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
3945 $text = $langs->trans(
"HelpAbandonOther");
3947 $text .=
'<br><br><b>'.$langs->trans(
"Reason").
'</b>:'.
$object->close_note;
3949 print
'<span class="opacitymedium">';
3951 print $form->textwithpicto($langs->trans(
"Abandoned"), $text, - 1);
3953 print
'</td><td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td><td> </td></tr>';
3954 $resteapayeraffiche = 0;
3955 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3959 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3960 print
'<span class="opacitymedium">';
3961 print $langs->trans(
"Billed");
3963 print
'</td><td class="right">'.price(
$object->total_ttc).
'</td><td> </td></tr>';
3966 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3967 print
'<span class="opacitymedium">';
3968 print $langs->trans(
'RemainderToPay');
3969 if ($resteapayeraffiche < 0) {
3970 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
3974 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayeraffiche).
'</td><td> </td></tr>';
3977 if (isModEnabled(
'multicurrency') &&
$object->multicurrency_code !=
$conf->currency ||
$object->multicurrency_tx != 1) {
3978 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3979 print
'<span class="opacitymedium">';
3980 print $langs->trans(
'RemainderToPayMulticurrency');
3981 if ($resteapayeraffiche < 0) {
3982 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
3986 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price(
price2num($multicurrency_resteapayer,
'MT'), 0, $langs, 1, -1, -1,
$object->multicurrency_code).
'</td><td> </td></tr>';
3989 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3992 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3993 print $langs->trans(
'AlreadyPaidBack');
3994 print
' :</td><td class="right">'.price($sign * $totalpaid).
'</td><td> </td></tr>';
3997 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"Billed").
' :</td><td class="right">'.
price($sign *
$object->total_ttc).
'</td><td> </td></tr>';
4000 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
4001 print
'<span class="opacitymedium">';
4002 print $langs->trans(
'RemainderToPayBack');
4003 if ($resteapayeraffiche > 0) {
4004 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
4008 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($sign * $resteapayeraffiche).
'</td><td> </td></tr>';
4011 if (isModEnabled(
'multicurrency') &&
$object->multicurrency_code !=
$conf->currency ||
$object->multicurrency_tx != 1) {
4012 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
4013 print
'<span class="opacitymedium">';
4014 print $langs->trans(
'RemainderToPayBackMulticurrency');
4015 if ($resteapayeraffiche > 0) {
4016 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
4020 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.(!empty(
$object->multicurrency_code) ?
$object->multicurrency_code :
$conf->currency).
' '.
price(
price2num($sign *
$object->multicurrency_tx * $resteapayeraffiche,
'MT')).
'</td><td> </td></tr>';
4035 print
'<div class="clearboth"></div><br>';
4038 $blocname =
'contacts';
4039 $title = $langs->trans(
'ContactsAddresses');
4040 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
4045 $blocname =
'notes';
4046 $title = $langs->trans(
'Notes');
4047 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
4054 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
4055 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4056 print
'<input type="hidden" name="action" value="'.(($action !=
'editline') ?
'addline' :
'updateline').
'">';
4057 print
'<input type="hidden" name="mode" value="">';
4058 print
'<input type="hidden" name="page_y" value="">';
4059 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
4060 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
4061 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
4064 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
4067 print
'<div class="div-table-responsive-no-min">';
4068 print
'<table id="tablelines" class="noborder noshadow centpercent">';
4070 global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax;
4073 $inputalsopricewithtax = 1;
4074 $senderissupplier = 2;
4075 if (
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY')) {
4076 $senderissupplier =
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY');
4081 $object->printObjectLines($action, $societe, $mysoc, $lineid, 1);
4088 if ($action !=
'editline') {
4091 $parameters = array();
4092 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters,
$object, $action);
4096 if (empty($reshook)) {
4097 $object->formAddObjectLine(1, $societe, $mysoc);
4110 if ($action !=
'presend') {
4113 print
'<div class="tabsAction">';
4115 $parameters = array();
4116 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
4118 if (empty($reshook)) {
4122 $ventilExportCompta =
$object->getVentilExportCompta();
4124 if ($ventilExportCompta == 0) {
4125 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
'Modify').
'</a>';
4127 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseDispatchedInBookkeeping").
'">'.$langs->trans(
'Modify').
'</span>';
4132 $result = $discount->fetch(0, 0,
$object->id);
4139 if (!$objectidnext &&
$object->close_code !=
'replaced' && $usercancreate) {
4140 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=reopen&token='.
newToken().
'">'.$langs->trans(
'ReOpen').
'</a>';
4142 if ($usercancreate) {
4143 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseReplacedInvoice").
'">'.$langs->trans(
'ReOpen').
'</span>';
4145 print
'<span class="butActionRefused classfortooltip">'.$langs->trans(
'ReOpen').
'</span>';
4155 if ($usercanvalidate) {
4156 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=valid&token='.
newToken().
'"';
4157 print
'>'.$langs->trans(
'Validate').
'</a>';
4159 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'"';
4160 print
'>'.$langs->trans(
'Validate').
'</a>';
4166 if (empty($user->socid)) {
4169 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a>';
4171 print
'<span class="butActionRefused classfortooltip">'.$langs->trans(
'SendMail').
'</span>';
4178 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.DOL_URL_ROOT.
'/fourn/facture/paiement.php?facid='.
$object->id.
'&action=create'.(
$object->fk_account > 0 ?
'&accountid='.$object->fk_account :
'').
'">'.$langs->trans(
'DoPayment').
'</a>';
4185 if ($resteapayer == 0) {
4186 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseRemainderToPayIsZero").
'">'.$langs->trans(
'DoPaymentBack').
'</span>';
4188 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>';
4194 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.
newToken().
'">'.$langs->trans(
'ConvertExcessPaidToReduc').
'</a>';
4198 && (
getDolGlobalString(
'SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED') ||
$object->getSommePaiement() == 0)
4200 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>';
4204 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.
newToken().
'">'.$langs->trans(
'ConvertToReduc').
'</a>';
4215 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=paid&token='.
newToken().
'">'.$langs->trans(
'ClassifyPaid').
'</a>';
4220 if ($totalpaid > 0 || $totalcreditnotes > 0) {
4222 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=paid&token='.
newToken().
'">'.$langs->trans(
'ClassifyPaidPartially').
'</a>';
4225 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=canceled">'.$langs->trans(
'ClassifyCanceled').
'</a>';
4237 if (!$objectidnext) {
4238 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>';
4243 if ($action !=
'edit' && $usercancreate) {
4244 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=clone&socid='.
$object->socid.
'&token='.
newToken().
'">'.$langs->trans(
'ToClone').
'</a>';
4249 if (!$objectidnext && count(
$object->lines) > 0) {
4250 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.
$object->id.
'&action=create">'.$langs->trans(
"ChangeIntoRepeatableInvoice").
'</a>';
4255 if ($action !=
'confirm_edit' && $usercandelete) {
4256 $isErasable =
$object->is_erasable();
4258 $enableDelete =
false;
4260 $params = (empty(
$conf->use_javascript_ajax) ? array() : array(
'attr' => array(
'class' =>
'reposition')));
4262 if ($isErasable == -4) {
4263 $htmltooltip = $langs->trans(
"DisabledBecausePayments");
4264 } elseif ($isErasable == -3) {
4265 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastSituationInvoice");
4266 } elseif ($isErasable == -2) {
4267 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastInvoice");
4268 } elseif ($isErasable == -1) {
4269 $htmltooltip = $langs->trans(
"DisabledBecauseDispatchedInBookkeeping");
4270 } elseif ($isErasable <= 0) {
4271 $htmltooltip = $langs->trans(
"DisabledBecauseNotErasable");
4273 $enableDelete =
true;
4276 print
dolGetButtonAction($htmltooltip, $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(), (
string)
$object->id, $enableDelete, $params);
4280 if ($action !=
'confirm_edit') {
4281 print
'<div class="fichecenter"><div class="fichehalfleft">';
4288 $filedir =
$conf->fournisseur->facture->dir_output.
'/'.$subdir;
4289 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.
$object->id;
4290 $genallowed = $usercanread;
4291 $delallowed = $usercancreate;
4295 print $formfile->showdocuments(
'facture_fournisseur', $subdir, $filedir, $urlsource, (
int) $genallowed, (
int) $delallowed, $modelpdf, $genifempty, 0, 0, 40, 0,
'',
'',
'', $societe->default_lang);
4296 $somethingshown = $formfile->numoffiles;
4299 $tmparray = $form->showLinkToObjectBlock(
$object, array(), array(
'invoice_supplier'), 1);
4300 $linktoelem = $tmparray[
'linktoelem'];
4301 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
4302 print $htmltoenteralink;
4304 $somethingshown = $form->showLinkedObjectBlock(
$object, $linktoelem);
4306 print
'</div><div class="fichehalfright">';
4309 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
4311 $somethingshown = $formactions->showactions(
$object,
'invoice_supplier', $socid, 1,
'listaction'.($genallowed ?
'largetitle' :
''));
4313 print
'</div></div>';
4319 if (
GETPOST(
'modelselected')) {
4320 $action =
'presend';
4324 $modelmail =
'invoice_supplier_send';
4325 $defaulttopic =
'SendBillRef';
4326 $diroutput =
$conf->fournisseur->facture->dir_output;
4327 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
4328 $trackid =
'sinv'.$object->id;
4330 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage bank accounts.
Class to manage accounting journals.
const TYPE_PROFORMA
Proforma invoice.
const TYPE_SITUATION
Situation invoice.
Class to manage absolute discounts.
Class to manage a WYSIWYG editor.
Class to manage warehouses.
Class to manage suppliers invoices.
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
const TYPE_REPLACEMENT
Replacement invoice.
const STATUS_VALIDATED
Validated (need to be paid)
const TYPE_STANDARD
Standard invoice.
const STATUS_ABANDONED
Classified abandoned and no payment done.
const STATUS_CLOSED
Classified paid.
Class to manage invoice templates.
Class to manage payments for supplier invoices.
Class ProductCombination Used to represent the relation between a product and one of its variants.
Class to manage predefined suppliers products.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
dol_get_last_hour($date, $gm='tzserver')
Return GMT time for last hour of a given GMT date (it replaces hours, min and second part to 23:59:59...
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
facturefourn_prepare_head(FactureFournisseur $object)
Prepare array with list of tabs.
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that returns whether VAT must be recoverable collected VAT (e.g.: VAT NPR in France)
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dol_htmloutput_events($disabledoutputofmessages=0)
Print formatted messages to output (Used to show messages on html output).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.