40require
'../../main.inc.php';
49require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
53require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture-rec.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
57require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
58require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
59require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
60require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
62 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
63 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
66 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
67 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
71 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
74 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
77$langs->loadLangs(array(
'bills',
'compta',
'suppliers',
'companies',
'products',
'banks',
'admin'));
79 $langs->load(
'incoterm');
84$action =
GETPOST(
'action',
'aZ09');
87$cancel =
GETPOST(
'cancel',
'alpha');
88$backtopage =
GETPOST(
'backtopage',
'alpha');
89$backtopageforcancel =
'';
93$origin =
GETPOST(
'origin',
'alpha');
104$hookmanager->initHooks(array(
'invoicesuppliercard',
'globalcard'));
110$extrafields->fetch_name_optionals_label(
$object->table_element);
113if ($id > 0 || !empty($ref)) {
114 $ret =
$object->fetch($id, $ref);
118 $ret =
$object->fetch_thirdparty();
126if (!empty($user->socid)) {
127 $socid = $user->socid;
131$result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture',
'fk_soc',
'rowid', $isdraft);
134$usercanread = ($user->hasRight(
"fournisseur",
"facture",
"lire") || $user->hasRight(
"supplier_invoice",
"lire"));
135$usercancreate = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
136$usercandelete = (($user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"supprimer")) || ($usercancreate &&
$object->is_erasable() == 1));
137$usercancreatecontract = $user->hasRight(
"contrat",
"creer");
140$usercanvalidate = ((!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"validate")));
141$usercansend = (!
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') || $user->hasRight(
"fournisseur",
"supplier_invoice_advance",
"send"));
142$usercancreatecreditransfer = $user->hasRight(
'paymentbybanktransfer',
'create');
145$permissionnote = $usercancreate;
146$permissiondellink = $usercancreate;
147$permissiontoedit = $usercancreate;
148$permissiontoadd = $usercancreate;
149$permissiontodelete = $usercandelete;
150$permissiontoeditextra = $permissiontoadd;
151if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
153 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
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);
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);
258 $categories =
GETPOST(
'categories',
'array:int');
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);
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:int');
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';
1168 $classname = ucfirst($subelement);
1169 if ($classname ==
'Fournisseur.commande') {
1170 $classname =
'CommandeFournisseur';
1172 $objectsrc =
new $classname($db);
1173 $objectsrc->fetch($originid);
1174 $objectsrc->fetch_thirdparty();
1176 if (!empty(
$object->origin_type) && !empty(
$object->origin_id)) {
1181 if (
$object->origin_type ==
'reception') {
1182 $objectsrc->fetchObjectLinked();
1184 if (count($objectsrc->linkedObjectsIds[
'order_supplier']) > 0) {
1185 foreach ($objectsrc->linkedObjectsIds[
'order_supplier'] as $key => $value) {
1186 $object->linkedObjectsIds[
'order_supplier'][-1] = $value;
1196 $classname = ucfirst($subelement);
1197 if ($classname ==
'Fournisseur.commande') {
1198 $classname =
'CommandeFournisseur';
1200 $srcobject =
new $classname($db);
1202 $result = $srcobject->fetch(
GETPOSTINT(
'originid'));
1205 $typeamount =
GETPOST(
'typedeposit',
'alpha');
1210 $amountdeposit = array();
1212 if ($typeamount ==
'amount') {
1213 $amount = $valuedeposit;
1215 $amount = $srcobject->total_ttc * ((float) $valuedeposit / 100);
1218 $TTotalByTva = array();
1219 foreach ($srcobject->lines as &$line) {
1220 if (!empty($line->special_code)) {
1223 $TTotalByTva[$line->tva_tx] += $line->total_ttc;
1225 '@phan-var-force array<string,float> $TTotalByTva';
1227 $amount_ttc_diff = 0.;
1228 foreach ($TTotalByTva as $tva => &$total) {
1229 $coef = $total / $srcobject->total_ttc;
1230 $am = $amount * $coef;
1231 $amount_ttc_diff += $am;
1232 $amountdeposit[$tva] += $am / (1 + (float) $tva / 100);
1235 if ($typeamount ==
'amount') {
1236 $amountdeposit[0] = $valuedeposit;
1237 } elseif ($typeamount ==
'variable') {
1240 $lines = $srcobject->lines;
1241 $numlines = count($lines);
1242 for ($i = 0; $i < $numlines; $i++) {
1244 if (empty($lines[$i]->qty)) {
1247 if (!empty($lines[$i]->special_code)) {
1251 $totalamount += $lines[$i]->total_ht;
1252 $tva_tx = $lines[$i]->tva_tx;
1253 $amountdeposit[$tva_tx] += ($lines[$i]->total_ht * (float) $valuedeposit) / 100;
1257 if ($totalamount == 0) {
1258 $amountdeposit[0] = 0;
1263 $amountdeposit[0] = 0;
1267 $amount_ttc_diff = array_key_exists(0, $amountdeposit) ? $amountdeposit[0] : 0;
1270 foreach ($amountdeposit as $tva => $amount) {
1271 if (empty($amount)) {
1276 'amount' =>
'FixAmount',
1277 'variable' =>
'VarAmount'
1279 $descline =
'(DEPOSIT)';
1281 if ($typeamount ==
'amount') {
1282 $descline .=
' ('.price($valuedeposit, 0, $langs, 0, - 1, - 1, (!empty(
$object->multicurrency_code) ?
$object->multicurrency_code : $conf->currency)).
')';
1283 } elseif ($typeamount ==
'variable') {
1284 $descline .=
' ('.$valuedeposit.
'%)';
1287 $descline .=
' - '.$srcobject->ref;
1317 $diff =
$object->total_ttc - $amount_ttc_diff;
1321 $subprice_diff =
$object->lines[0]->subprice - $diff / (1 +
$object->lines[0]->tva_tx / 100);
1327 $object->lines[0]->localtax1_tx,
1328 $object->lines[0]->localtax2_tx,
1330 $object->lines[0]->fk_product,
1333 $object->lines[0]->product_type,
1334 $object->lines[0]->remise_percent,
1336 $object->lines[0]->date_start,
1345 } elseif ($result > 0) {
1346 $lines = $srcobject->lines;
1347 if (empty($lines) && method_exists($srcobject,
'fetch_lines')) {
1348 $srcobject->fetch_lines();
1349 $lines = $srcobject->lines;
1352 $num = count($lines);
1353 for ($i = 0; $i < $num; $i++) {
1354 if (!in_array($lines[$i]->
id, $selectedLines)) {
1358 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->product_label);
1359 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
1362 if (method_exists($lines[$i],
'fetch_optionals')) {
1363 $lines[$i]->fetch_optionals();
1368 $date_start = $lines[$i]->date_debut_prevue;
1369 if ($lines[$i]->date_debut_reel) {
1370 $date_start = $lines[$i]->date_debut_reel;
1372 if ($lines[$i]->date_start) {
1373 $date_start = $lines[$i]->date_start;
1375 $date_end = $lines[$i]->date_fin_prevue;
1376 if ($lines[$i]->date_fin_reel) {
1377 $date_end = $lines[$i]->date_fin_reel;
1379 if ($lines[$i]->date_end) {
1380 $date_end = $lines[$i]->date_end;
1383 $tva_tx = $lines[$i]->tva_tx;
1385 if (!empty($lines[$i]->vat_src_code) && !preg_match(
'/\(/', (
string) $tva_tx)) {
1386 $tva_tx .=
' ('.$lines[$i]->vat_src_code.
')';
1390 $object->special_code = $lines[$i]->special_code;
1393 if (
$object->multicurrency_code != $conf->currency ||
$object->multicurrency_tx != 1) {
1395 $pu_currency = $lines[$i]->multicurrency_subprice;
1397 $pu = $lines[$i]->subprice;
1406 $lines[$i]->localtax1_tx,
1407 $lines[$i]->localtax2_tx,
1409 $lines[$i]->fk_product,
1410 $lines[$i]->remise_percent,
1414 $lines[$i]->info_bits,
1419 $lines[$i]->array_options,
1420 $lines[$i]->fk_unit,
1423 $lines[$i]->ref_supplier,
1424 $lines[$i]->special_code
1441 $parameters = array(
'objFrom' => $srcobject);
1442 $reshook = $hookmanager->executeHooks(
'createFrom', $parameters, $object, $action);
1452 } elseif (!$error) {
1462 $langs->load(
"errors");
1472 $outputlangs = $langs;
1473 $result =
$object->generateDocument(
$object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1480 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
1483 } elseif ($action ==
'updateline' && $usercancreate) {
1487 if (!
$object->fetch($id) > 0) {
1493 $tva_tx = str_replace(
'*',
'', $tva_tx);
1495 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_subprice') !=
'') {
1497 $price_base_type =
'HT';
1500 $price_base_type =
'TTC';
1503 if (
GETPOST(
'productid') > 0) {
1505 if (
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY') == 1) {
1507 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'warnings');
1513 $label = $prod->description;
1514 if (trim(
GETPOST(
'product_desc',
'restricthtml')) != trim($label)) {
1515 $label =
GETPOST(
'product_desc',
'restricthtml');
1518 $type = $prod->type;
1520 $label =
GETPOST(
'product_desc',
'restricthtml');
1529 if (preg_match(
'/\*/', $tva_tx)) {
1534 $tva_tx = str_replace(
'*',
'', $tva_tx);
1542 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1543 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line);
1545 if (is_array($extralabelsline)) {
1546 foreach ($extralabelsline as $key => $value) {
1547 unset($_POST[
"options_".$key]);
1551 $result =
$object->updateline(
1563 (
float) $remise_percent,
1573 unset($_POST[
'label']);
1574 unset($_POST[
'fourn_ref']);
1575 unset($_POST[
'date_starthour']);
1576 unset($_POST[
'date_startmin']);
1577 unset($_POST[
'date_startsec']);
1578 unset($_POST[
'date_startday']);
1579 unset($_POST[
'date_startmonth']);
1580 unset($_POST[
'date_startyear']);
1581 unset($_POST[
'date_endhour']);
1582 unset($_POST[
'date_endmin']);
1583 unset($_POST[
'date_endsec']);
1584 unset($_POST[
'date_endday']);
1585 unset($_POST[
'date_endmonth']);
1586 unset($_POST[
'date_endyear']);
1587 unset($_POST[
'price_ttc']);
1588 unset($_POST[
'price_ht']);
1595 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') && (
GETPOST(
'alldate_start',
'alpha') ||
GETPOST(
'alldate_end',
'alpha')) && $usercancreate) {
1599 foreach (
$object->lines as $line) {
1600 if ($line->product_type == 1) {
1601 $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);
1604 } elseif ($action ==
'addline' &&
GETPOST(
'submitforalllines',
'aZ09') &&
GETPOST(
'vatforalllines',
'alpha') !=
'' && $usercancreate) {
1606 $vat_rate = (
GETPOST(
'vatforalllines') ?
GETPOST(
'vatforalllines') : 0);
1607 $vat_rate = str_replace(
'*',
'', $vat_rate);
1610 foreach (
$object->lines as $line) {
1611 $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);
1613 } elseif ($action ==
'addline' && $usercancreate) {
1622 $ret =
$object->fetch_thirdparty();
1624 $langs->load(
'errors');
1629 $line_desc = (GETPOSTISSET(
'dp_desc') ?
GETPOST(
'dp_desc',
'restricthtml') :
'');
1633 $prod_entry_mode =
GETPOST(
'prod_entry_mode');
1634 if ($prod_entry_mode ==
'free') {
1641 $price_ht_devise =
'';
1643 $price_ttc_devise =
'';
1645 if (
GETPOST(
'price_ht') !==
'') {
1648 if (
GETPOST(
'multicurrency_price_ht') !==
'') {
1651 if (
GETPOST(
'price_ttc') !==
'') {
1654 if (
GETPOST(
'multicurrency_price_ttc') !==
'') {
1655 $price_ttc_devise =
price2num(
GETPOST(
'multicurrency_price_ttc'),
'CU', 2);
1662 $remise_percent = (GETPOSTISSET(
'remise_percent'.$predef) ?
price2num(
GETPOST(
'remise_percent'.$predef,
'alpha'),
'', 2) : 0);
1663 if (empty($remise_percent)) {
1664 $remise_percent = 0;
1668 $extralabelsline = $extrafields->fetch_name_optionals_label(
$object->table_element_line);
1669 $array_options = $extrafields->getOptionalsFromPost(
$object->table_element_line, $predef);
1671 if (is_array($extralabelsline)) {
1673 foreach ($extralabelsline as $key => $value) {
1674 unset($_POST[
"options_".$key]);
1678 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0) {
1679 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1682 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') &&
GETPOST(
'type') < 0) {
1683 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')),
null,
'errors');
1688 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1')
1689 && (((
float) $price_ht < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) || $price_ht ===
'')
1690 && (((
float) $price_ht_devise < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) || $price_ht_devise ===
'')
1691 && ((
float) $price_ttc < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES') || $price_ttc ===
'')
1692 && ((
float) $price_ttc_devise < 0 && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES') || $price_ttc_devise ===
'')
1693 &&
$object->type != $object::TYPE_CREDIT_NOTE) {
1694 if (((
float) $price_ht < 0 || (
float) $price_ttc < 0) && !
getDolGlobalString(
'SUPPLIER_INVOICE_ENABLE_NEGATIVE_LINES')) {
1695 $langs->load(
"errors");
1696 if (
$object->type == $object::TYPE_DEPOSIT) {
1698 setEventMessages($langs->trans(
"ErrorLinesCantBeNegativeOnDeposits"),
null,
'errors');
1700 setEventMessages($langs->trans(
"ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv(
"UnitPrice"), $langs->transnoentitiesnoconv(
"CustomerAbsoluteDiscountShort")),
null,
'errors');
1705 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' && $price_ht_devise ===
'') {
1706 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'UnitPrice')),
null,
'errors');
1710 if ($prod_entry_mode ==
'free' && (!
GETPOST(
'idprodfournprice') ||
GETPOST(
'idprodfournprice') ==
'-1') && !
GETPOST(
'dp_desc')) {
1711 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')),
null,
'errors');
1714 if (!
GETPOST(
'qty',
'alpha')) {
1715 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')),
null,
'errors');
1719 if (!$error &&
isModEnabled(
'variants') && $prod_entry_mode !=
'free') {
1720 if ($combinations =
GETPOST(
'combinations',
'array:alphanohtml')) {
1724 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1725 $idprod = $res->fk_product_child;
1727 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'),
null,
'errors');
1733 if ($prod_entry_mode !=
'free' && empty($error)) {
1737 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') {
1742 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg)) {
1743 $idprod = (int) $reg[1];
1744 $res = $productsupplier->fetch($idprod);
1747 if (
getDolGlobalString(
'SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER')) {
1749 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1750 if ($productsupplier->fourn_socid != $socid) {
1751 $productsupplier->ref_supplier =
'';
1754 $fksoctosearch =
$object->thirdparty->id;
1755 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1757 } elseif (
GETPOSTINT(
'idprodfournprice') > 0) {
1758 $qtytosearch = (float) $qty;
1760 $idprod = $productsupplier->get_buyprice(
GETPOSTINT(
'idprodfournprice'), $qtytosearch);
1761 $res = $productsupplier->fetch($idprod);
1765 $label = $productsupplier->label;
1768 $outputlangs = $langs;
1770 if (
GETPOST(
'lang_id',
'aZ09')) {
1771 $newlang =
GETPOST(
'lang_id',
'aZ09');
1773 if (empty($newlang)) {
1774 $newlang =
$object->thirdparty->default_lang;
1776 if (!empty($newlang)) {
1777 $outputlangs =
new Translate(
"", $conf);
1778 $outputlangs->setDefaultLang($newlang);
1780 $desc = (!empty($productsupplier->multilangs[$outputlangs->defaultlang][
"description"])) ? $productsupplier->multilangs[$outputlangs->defaultlang][
"description"] : $productsupplier->
description;
1782 $desc = $productsupplier->description;
1785 if (!empty($productsupplier->desc_supplier) &&
getDolGlobalString(
'PRODUIT_FOURN_TEXTS')) {
1786 $desc = $productsupplier->desc_supplier;
1797 $ref_supplier = $productsupplier->ref_supplier;
1800 if (!GETPOSTISSET(
'tva_tx')) {
1801 $tmpidprodfournprice =
GETPOST(
'idprodfournprice',
'alpha');
1802 if (is_numeric($tmpidprodfournprice) && (
int) $tmpidprodfournprice > 0) {
1803 $tmpidprodfournprice = (int) $tmpidprodfournprice;
1805 $tmpidprodfournprice = 0;
1811 if (empty($tva_tx) || empty($tva_npr)) {
1817 $type = $productsupplier->type;
1818 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1819 $price_base_type =
'HT';
1821 $pu_devise =
price2num($price_ht_devise,
'CU');
1822 } elseif (
GETPOST(
'price_ttc') !=
'' ||
GETPOST(
'multicurrency_price_ttc') !=
'') {
1823 $price_base_type =
'TTC';
1825 $pu_devise =
price2num($price_ttc_devise,
'CU');
1827 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
1828 if (empty(
$object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code !=
$object->multicurrency_code)) {
1829 $pu = $productsupplier->fourn_pu;
1832 $pu = $productsupplier->fourn_pu;
1833 $pu_devise = $productsupplier->fourn_multicurrency_unitprice;
1837 $ref_supplier = $productsupplier->ref_supplier;
1858 min($rank, count(
$object->lines) + 1),
1861 $productsupplier->fk_unit,
1864 GETPOST(
'fourn_ref',
'alpha'),
1868 if ($idprod == -99 || $idprod == 0) {
1871 $langs->load(
"errors");
1872 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")),
null,
'errors');
1874 if ($idprod == -1) {
1877 $langs->load(
"errors");
1878 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"),
null,
'errors');
1880 } elseif (empty($error)) {
1881 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1882 $tva_tx = str_replace(
'*',
'', $tva_tx);
1883 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1886 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1890 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
1898 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_price_ht') !=
'') {
1902 $pu_ht =
price2num((
float) $pu_ttc / (1 + ((
float) $tva_tx / 100)),
'MU');
1904 $price_base_type =
'HT';
1905 $pu_devise =
price2num($price_ht_devise,
'CU');
1907 $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);
1911 if (!$error && $result > 0) {
1916 $outputlangs = $langs;
1919 $newlang =
GETPOST(
'lang_id',
'aZ09');
1922 $newlang =
$object->thirdparty->default_lang;
1924 if (!empty($newlang)) {
1925 $outputlangs =
new Translate(
"", $conf);
1926 $outputlangs->setDefaultLang($newlang);
1931 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1937 unset($_POST [
'prod_entry_mode']);
1939 unset($_POST[
'qty']);
1940 unset($_POST[
'type']);
1941 unset($_POST[
'remise_percent']);
1942 unset($_POST[
'pu']);
1943 unset($_POST[
'price_ht']);
1944 unset($_POST[
'multicurrency_price_ht']);
1945 unset($_POST[
'price_ttc']);
1946 unset($_POST[
'fourn_ref']);
1947 unset($_POST[
'tva_tx']);
1948 unset($_POST[
'label']);
1949 unset($localtax1_tx);
1950 unset($localtax2_tx);
1951 unset($_POST[
'np_marginRate']);
1952 unset($_POST[
'np_markRate']);
1953 unset($_POST[
'dp_desc']);
1954 unset($_POST[
'idprodfournprice']);
1955 unset($_POST[
'units']);
1957 unset($_POST[
'date_starthour']);
1958 unset($_POST[
'date_startmin']);
1959 unset($_POST[
'date_startsec']);
1960 unset($_POST[
'date_startday']);
1961 unset($_POST[
'date_startmonth']);
1962 unset($_POST[
'date_startyear']);
1963 unset($_POST[
'date_endhour']);
1964 unset($_POST[
'date_endmin']);
1965 unset($_POST[
'date_endsec']);
1966 unset($_POST[
'date_endday']);
1967 unset($_POST[
'date_endmonth']);
1968 unset($_POST[
'date_endyear']);
1975 } elseif ($action ==
'classin' && $usercancreate) {
1977 $result =
$object->setProject($projectid);
1978 } elseif ($action ==
'confirm_edit' && $confirm ==
'yes' && $usercancreate) {
1982 $totalpaid =
$object->getSommePaiement();
1983 $resteapayer =
$object->total_ttc - $totalpaid;
1986 $ventilExportCompta =
$object->getVentilExportCompta();
1988 if (!$ventilExportCompta) {
1991 $idwarehouse =
GETPOST(
'idwarehouse');
1995 $qualified_for_stock_change = 0;
1997 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
1999 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
2004 $langs->load(
"stocks");
2005 if (!$idwarehouse || $idwarehouse == -1) {
2007 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")),
null,
'errors');
2012 $object->setDraft($user, $idwarehouse);
2016 $outputlangs = $langs;
2019 $newlang =
GETPOST(
'lang_id',
'aZ09');
2022 $newlang =
$object->thirdparty->default_lang;
2024 if (!empty($newlang)) {
2025 $outputlangs =
new Translate(
"", $conf);
2026 $outputlangs->setDefaultLang($newlang);
2031 $result =
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
2040 } elseif ($action ==
'reopen' && $usercancreate) {
2042 $result =
$object->fetch($id);
2045 $result =
$object->setUnpaid($user);
2047 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$id);
2056 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
2059 $triggersendname =
'BILL_SUPPLIER_SENTBYMAIL';
2061 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
2062 $trackid =
'sinv'.$object->id;
2063 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
2066 $upload_dir = $conf->fournisseur->facture->dir_output;
2067 $permissiontoadd = $usercancreate;
2068 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
2071 if ($action ==
'calculate' && $usercancreate) {
2072 $calculationrule =
GETPOST(
'calculationrule');
2076 $result =
$object->update_price(0, (($calculationrule ==
'totalofround') ?
'0' :
'1'), 0,
$object->thirdparty);
2082 if ($action ==
'update_extras' && $permissiontoeditextra) {
2085 $attribute_name =
GETPOST(
'attribute',
'aZ09');
2088 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
2094 $result =
$object->updateExtraField($attribute_name,
'BILL_SUPPLIER_MODIFY');
2102 $action =
'edit_extras';
2107 if ($action ==
'addcontact' && $usercancreate) {
2108 $result =
$object->fetch($id);
2110 if ($result > 0 && $id > 0) {
2113 $result =
$object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
2117 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2120 if (
$object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2121 $langs->load(
"errors");
2122 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
2127 } elseif ($action ==
'swapstatut' && $usercancreate) {
2134 } elseif ($action ==
'deletecontact' && $usercancreate) {
2140 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
2154$form =
new Form($db);
2156$bankaccountstatic =
new Account($db);
2164$title =
$object->ref.
" - ".$langs->trans(
'Card');
2165if ($action ==
'create') {
2166 $title = $langs->trans(
"NewSupplierInvoice");
2168$help_url =
'EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores|DE:Modul_Lieferantenrechnungen';
2169llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-fourn-facture page-card');
2172if ($action ==
'create') {
2174 $selectedLines = array();
2176 print
load_fiche_titre($langs->trans(
'NewSupplierInvoice'),
'',
'supplier_invoice');
2180 $currency_code = $conf->currency;
2181 $vat_reverse_charge = 0;
2187 if (
isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2188 $currency_code = $societe->multicurrency_code;
2193 if (!empty($origin) && !empty($originid)) {
2195 $element = $subelement = $origin;
2197 if ($element ==
'project') {
2198 $projectid = $originid;
2199 $element =
'projet';
2203 if ($element ==
'order') {
2204 $element = $subelement =
'commande';
2206 if ($element ==
'propal') {
2207 $element =
'comm/propal';
2208 $subelement =
'propal';
2210 if ($element ==
'contract') {
2211 $element = $subelement =
'contrat';
2213 if ($element ==
'order_supplier') {
2215 $subelement =
'fournisseur.commande';
2219 $classname = ucfirst($subelement);
2220 if ($classname ==
'Fournisseur.commande') {
2221 $classname =
'CommandeFournisseur';
2223 $objectsrc =
new $classname($db);
2224 '@phan-var-force Project|Commande|Propal|Facture|Contrat|CommandeFournisseur|CommonObject $objectsrc';
2226 $objectsrc->fetch($originid);
2227 $objectsrc->fetch_thirdparty();
2229 $projectid = (int) $objectsrc->fk_project;
2231 $soc = $objectsrc->thirdparty;
2233 $cond_reglement_id = 0;
2234 $mode_reglement_id = 0;
2238 $transport_mode_id = 0;
2241 if (!empty($objectsrc->cond_reglement_id)) {
2242 $cond_reglement_id = $objectsrc->cond_reglement_id;
2244 if (!empty($objectsrc->mode_reglement_id)) {
2245 $mode_reglement_id = $objectsrc->mode_reglement_id;
2247 if (!empty($objectsrc->fk_account)) {
2248 $fk_account = $objectsrc->fk_account;
2250 if (!empty($objectsrc->transport_mode_id)) {
2251 $transport_mode_id = $objectsrc->transport_mode_id;
2254 if (empty($cond_reglement_id)
2255 || empty($mode_reglement_id)
2256 || empty($fk_account)
2257 || empty($transport_mode_id)
2259 if ($origin ==
'reception') {
2261 if (!isset($objectsrc->supplier_order)) {
2262 $objectsrc->fetch_origin();
2265 if (!empty($objectsrc->origin_object)) {
2266 $originObject = $objectsrc->origin_object;
2267 if (empty($cond_reglement_id) && !empty($originObject->cond_reglement_id)) {
2268 $cond_reglement_id = $originObject->cond_reglement_id;
2270 if (empty($mode_reglement_id) && !empty($originObject->mode_reglement_id)) {
2271 $mode_reglement_id = $originObject->mode_reglement_id;
2273 if (empty($fk_account) && !empty($originObject->fk_account)) {
2274 $fk_account = $originObject->fk_account;
2276 if (empty($transport_mode_id) && !empty($originObject->transport_mode_id)) {
2277 $transport_mode_id = $originObject->transport_mode_id;
2284 if (empty($cond_reglement_id) && !empty($soc->cond_reglement_supplier_id)) {
2285 $cond_reglement_id = $soc->cond_reglement_supplier_id;
2287 if (empty($mode_reglement_id) && !empty($soc->mode_reglement_supplier_id)) {
2288 $mode_reglement_id = $soc->mode_reglement_supplier_id;
2290 if (empty($fk_account) && !empty($soc->fk_account)) {
2291 $fk_account = $soc->fk_account;
2293 if (empty($transport_mode_id) && !empty($soc->transport_mode_id)) {
2294 $transport_mode_id = $soc->transport_mode_id;
2300 if (!empty($objectsrc->multicurrency_code)) {
2301 $currency_code = $objectsrc->multicurrency_code;
2303 if (
getDolGlobalString(
'MULTICURRENCY_USE_ORIGIN_TX') && !empty($objectsrc->multicurrency_tx)) {
2304 $currency_tx = $objectsrc->multicurrency_tx;
2309 $dateinvoice = ($datetmp ==
'' ? (!
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ? -1 :
'') : $datetmp);
2311 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2314 $objectsrc->fetch_optionals();
2315 $object->array_options = $objectsrc->array_options;
2317 $cond_reglement_id = !empty($societe->cond_reglement_supplier_id) ? $societe->cond_reglement_supplier_id : 0;
2318 $mode_reglement_id = !empty($societe->mode_reglement_supplier_id) ? $societe->mode_reglement_supplier_id : 0;
2319 $vat_reverse_charge = (empty($societe) ?
'' : $societe->vat_reverse_charge);
2320 $transport_mode_id = !empty($societe->transport_mode_supplier_id) ? $societe->transport_mode_supplier_id : 0;
2321 $fk_account = !empty($societe->fk_account) ? $societe->fk_account : 0;
2323 $dateinvoice = ($datetmp ==
'' ? (
getDolGlobalInt(
'MAIN_AUTOFILL_DATE') ?
'' : -1) : $datetmp);
2325 $datedue = ($datetmp ==
'' ? -1 : $datetmp);
2327 if (
isModEnabled(
"multicurrency") && !empty($societe->multicurrency_code)) {
2328 $currency_code = $societe->multicurrency_code;
2333 if (empty($cond_reglement_id)) {
2334 $cond_reglement_id =
GETPOST(
"cond_reglement_id");
2338 if (empty($mode_reglement_id)) {
2339 $mode_reglement_id =
GETPOST(
"mode_reglement_id");
2343 if (!
GETPOST(
'changecompany')) {
2344 if (GETPOSTISSET(
'cond_reglement_id')) {
2345 $cond_reglement_id =
GETPOSTINT(
'cond_reglement_id');
2347 if (GETPOSTISSET(
'mode_reglement_id')) {
2348 $mode_reglement_id =
GETPOSTINT(
'mode_reglement_id');
2350 if (GETPOSTISSET(
'cond_reglement_id')) {
2355 $note_public =
$object->getDefaultCreateValueFor(
'note_public', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_public : null));
2356 $note_private =
$object->getDefaultCreateValueFor(
'note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc) &&
getDolGlobalString(
'FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM')) ? $objectsrc->note_private : null));
2358 if ($origin ==
'contrat') {
2359 $langs->load(
"admin");
2360 $text = $langs->trans(
"ToCreateARecurringInvoice");
2361 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGene", $langs->transnoentitiesnoconv(
"MenuFinancial"), $langs->transnoentitiesnoconv(
"SupplierBills"), $langs->transnoentitiesnoconv(
"ListOfTemplates"));
2363 $text .=
' '.$langs->trans(
"ToCreateARecurringInvoiceGeneAuto", $langs->transnoentitiesnoconv(
'Module2300Name'));
2365 print
info_admin($text, 0, 0,
'0',
'opacitymedium').
'<br>';
2368 print
'<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
2369 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2370 print
'<input type="hidden" name="action" value="add">';
2371 print
'<input type="hidden" name="changecompany" value="0">';
2373 if (!empty($societe->id) && $societe->id > 0) {
2374 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">'.
"\n";
2376 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
2377 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
2378 if (!empty($currency_tx)) {
2379 print
'<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
2381 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
2386 $parameters = array();
2388 $reshook = $hookmanager->executeHooks(
'tabContentCreateSupplierInvoice', $parameters, $object, $action);
2389 if (empty($reshook)) {
2390 print
'<table class="border centpercent">';
2393 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
'Draft').
'</td></tr>';
2397 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2398 $invoice_predefined->fetch($fac_recid);
2402 print
'<tr><td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
2405 if (!empty($societe->id) && $societe->id > 0 && ($fac_recid <= 0 || !empty($invoice_predefined->frequency))) {
2406 $absolute_discount = $societe->getAvailableDiscounts(
null,
'', 0, 1);
2407 print $societe->getNomUrl(1,
'supplier');
2408 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
2410 $filter =
'((s.fournisseur:=:1) AND (s.status:=:1))';
2411 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');
2414 print
'<script type="text/javascript">
2415 $(document).ready(function() {
2416 $("#socid").change(function() {
2417 console.log("We have changed the company - Reload page");
2419 $("input[name=action]").val("create");
2420 $("input[name=changecompany]").val("1");
2421 $("form[name=add]").submit();
2426 if ($fac_recid <= 0) {
2427 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>';
2433 if (empty($origin) && empty($originid) && $fac_recid > 0) {
2434 $invoice_predefined->fetch($fac_recid);
2436 $dateinvoice = $invoice_predefined->date_when;
2437 if (empty($projectid)) {
2438 $projectid = $invoice_predefined->fk_project;
2440 $cond_reglement_id = $invoice_predefined->cond_reglement_id;
2441 $mode_reglement_id = $invoice_predefined->mode_reglement_id;
2442 $fk_account = $invoice_predefined->fk_account;
2443 $note_public = $invoice_predefined->note_public;
2444 $note_private = $invoice_predefined->note_private;
2446 if (!empty($invoice_predefined->multicurrency_code)) {
2447 $currency_code = $invoice_predefined->multicurrency_code;
2449 if (!empty($invoice_predefined->multicurrency_tx)) {
2450 $currency_tx = $invoice_predefined->multicurrency_tx;
2453 $sql =
'SELECT r.rowid, r.titre as title, r.total_ttc';
2454 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn_rec as r';
2455 $sql .=
' WHERE r.fk_soc = '. (int) $invoice_predefined->socid;
2457 $resql = $db->query($sql);
2459 $num = $db->num_rows($resql);
2463 print
'<tr><td>'.$langs->trans(
'CreateFromRepeatableInvoice').
'</td><td>';
2465 print
'<select class="flat" id="fac_rec" name="fac_rec">';
2466 print
'<option value="0" selected></option>';
2468 $objp = $db->fetch_object($resql);
2469 print
'<option value="'.$objp->rowid.
'"';
2470 if ($fac_recid == $objp->rowid) {
2472 $exampletemplateinvoice->fetch($fac_recid);
2474 print
'>'.$objp->title.
' ('.
price($objp->total_ttc).
' '.$langs->trans(
"TTC").
')</option>';
2480 print
'<script type="text/javascript">
2481 $(document).ready(function() {
2482 $("#fac_rec").change(function() {
2483 console.log("We have changed the template invoice - Reload page");
2485 $("input[name=action]").val("create");
2486 $("form[name=add]").submit();
2500 print
'<tr><td class="fieldrequired">'.$langs->trans(
'RefSupplierBill').
'</td><td><input name="ref_supplier" value="'.(GETPOSTISSET(
'ref_supplier') ?
GETPOST(
'ref_supplier') : (!empty($objectsrc->ref_supplier) ? $objectsrc->ref_supplier :
'')).
'" type="text" spellcheck="false"';
2501 if (!empty($societe->id) && $societe->id > 0) {
2507 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'Type').
'</td><td>';
2509 print
'<div class="tagtable">'.
"\n";
2512 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2513 $tmp =
'<input type="radio" id="radio_standard" name="type" value="0"'.(GETPOSTINT(
'type') ?
'' :
'checked').
'> ';
2514 $desc = $form->textwithpicto($tmp.
'<label for="radio_standard">'.$langs->trans(
"InvoiceStandardAsk").
'</label>', $langs->transnoentities(
"InvoiceStandardDesc"), 1,
'help',
'', 0, 3);
2516 print
'</div></div>';
2518 if (empty($origin) || (($origin ==
'supplier_proposal' || $origin ==
'order_supplier' || $origin ==
'reception') && !empty($originid))) {
2521 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2522 $tmp =
'<input type="radio" id="radio_deposit" name="type" value="3"' . (
GETPOSTINT(
'type') == 3 ?
' checked' :
'') .
'> ';
2523 print
'<script type="text/javascript">
2524 jQuery(document).ready(function() {
2525 jQuery("#typestandardinvoice, #valuestandardinvoice").click(function() {
2526 jQuery("#radio_standard").prop("checked", true);
2528 jQuery("#typedeposit, #valuedeposit").click(function() {
2529 jQuery("#radio_deposit").prop("checked", true);
2531 jQuery("#typedeposit").change(function() {
2532 console.log("We change type of down payment");
2533 jQuery("#radio_deposit").prop("checked", true);
2534 setRadioForTypeOfInvoice();
2536 jQuery("#radio_standard, #radio_deposit, #radio_replacement, #radio_template").change(function() {
2537 setRadioForTypeOfInvoice();
2539 function setRadioForTypeOfInvoice() {
2540 console.log("Change radio");
2541 if (jQuery("#radio_deposit").prop("checked") && (jQuery("#typedeposit").val() == \'amount\' || jQuery("#typedeposit").val() == \'variable\')) {
2542 jQuery(".checkforselect").prop("disabled", true);
2543 jQuery(".checkforselect").prop("checked", false);
2545 jQuery(".checkforselect").prop("disabled", false);
2546 jQuery(".checkforselect").prop("checked", true);
2552 $tmp = $tmp.
'<label for="radio_deposit" >'.$langs->trans(
"InvoiceDeposit").
'</label>';
2554 $desc = $form->textwithpicto($tmp, $langs->transnoentities(
"InvoiceDepositDesc"), 1,
'help',
'', 0, 3);
2555 print
'<table class="nobordernopadding"><tr>';
2559 if ($origin ==
'supplier_proposal' || $origin ==
'order_supplier' || $origin ==
'reception') {
2560 print
'<td class="nowrap" style="padding-left: 15px">';
2562 'amount' => $langs->transnoentitiesnoconv(
'FixAmount', $langs->transnoentitiesnoconv(
'Deposit')),
2563 'variable' => $langs->transnoentitiesnoconv(
'VarAmountOneLine', $langs->transnoentitiesnoconv(
'Deposit')),
2564 'variablealllines' => $langs->transnoentitiesnoconv(
'VarAmountAllLines')
2566 $typedeposit =
GETPOST(
'typedeposit',
'aZ09');
2567 $valuedeposit =
GETPOST(
'valuedeposit',
'int');
2568 $deposit_percent =
null;
2569 if ($origin ==
'reception') {
2571 if (!isset($objectsrc->origin_object)) {
2572 $objectsrc->fetch_origin();
2574 if (!empty($objectsrc->origin_object)) {
2575 $deposit_percent = $objectsrc->origin_object->deposit_percent;
2577 } elseif (!empty($objectsrc->deposit_percent)) {
2578 $deposit_percent = $objectsrc->deposit_percent;
2580 if (empty($typedeposit) && !empty($deposit_percent)) {
2581 $origin_payment_conditions_deposit_percent =
getDictionaryValue(
'c_payment_term',
'deposit_percent', $objectsrc->cond_reglement_id);
2582 if (!empty($origin_payment_conditions_deposit_percent)) {
2583 $typedeposit =
'variable';
2586 if (empty($valuedeposit) && $typedeposit ==
'variable' && !empty($deposit_percent)) {
2587 $valuedeposit = $deposit_percent;
2589 print $form->selectarray(
'typedeposit', $arraylist, $typedeposit, 0, 0, 0,
'', 1);
2591 print
'<td class="nowrap" style="padding-left: 5px">';
2592 print
'<span class="opacitymedium paddingleft">'.$langs->trans(
"AmountOrPercent").
'</span><input type="text" id="valuedeposit" name="valuedeposit" class="width75 right" value="' . $valuedeposit .
'"/>';
2595 print
'</tr></table>';
2597 print
'</div></div>';
2666 if (empty($origin)) {
2667 if (!empty($societe->id) && $societe->id > 0) {
2671 $facids = $facturestatic->list_qualified_avoir_supplier_invoices($societe->id);
2678 foreach ($facids as $key => $valarray) {
2679 $newinvoice_static->id = $key;
2680 $newinvoice_static->ref = $valarray [
'ref'];
2681 $newinvoice_static->status = $valarray [
'status'];
2682 $newinvoice_static->statut = $valarray [
'status'];
2683 $newinvoice_static->type = $valarray [
'type'];
2684 $newinvoice_static->paid = $valarray [
'paye'];
2685 $newinvoice_static->paye = $valarray [
'paye'];
2687 $optionsav .=
'<option value="'.$key.
'"';
2689 $optionsav .=
' selected';
2692 $optionsav .= $newinvoice_static->ref;
2693 $optionsav .=
' ('.$newinvoice_static->getLibStatut(1, $valarray [
'paymentornot']).
')';
2694 $optionsav .=
'</option>';
2697 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2698 $tmp =
'<input type="radio" id="radio_creditnote" name="type" value="2"'.(GETPOST(
'type') == 2 ?
' checked' :
'');
2700 $tmp .=
' disabled';
2704 print
'<script type="text/javascript">
2705 jQuery(document).ready(function() {
2706 if (! jQuery("#radio_creditnote").is(":checked"))
2708 jQuery("#credit_note_options").hide();
2710 jQuery("#radio_creditnote").click(function() {
2711 jQuery("#credit_note_options").show();
2713 jQuery("#radio_standard, #radio_replacement, #radio_deposit").click(function() {
2714 jQuery("#credit_note_options").hide();
2718 $text = $tmp.
'<label for="radio_creditnote">'.$langs->transnoentities(
"InvoiceAvoirAsk").
'</label> ';
2720 $text .=
'<select class="flat valignmiddle" name="fac_avoir" id="fac_avoir"';
2722 $text .=
' disabled';
2726 $text .=
'<option value="-1"></option>';
2727 $text .= $optionsav;
2729 $text .=
'<option value="-1">'.$langs->trans(
"NoInvoiceToCorrect").
'</option>';
2731 $text .=
'</select>';
2732 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2735 print
'<div id="credit_note_options" class="clearboth">';
2736 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' :
'').
' /> ';
2737 print
'<label for="invoiceAvoirWithLines">'.$langs->trans(
'invoiceAvoirWithLines').
"</label>";
2738 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' :
'').
' /> ';
2739 print
'<label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans(
'invoiceAvoirWithPaymentRestAmount').
"</label>";
2742 print
'</div></div>';
2745 print
'<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2747 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="0" disabled> ';
2749 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="2"> ';
2751 $text = $tmp.$langs->trans(
"InvoiceAvoir").
' ';
2752 $text .=
'<span class="opacitymedium">('.$langs->trans(
"YouMustCreateInvoiceFromSupplierThird").
')</span> ';
2753 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2755 print
'</div></div>'.
"\n";
2766 print
'<tr><td class="fieldrequired">'.$langs->trans(
'InvoiceSubtype').
'</td><td colspan="2">';
2767 print $form->getSelectInvoiceSubtype(
GETPOSTINT(
'subtype'),
'subtype', 1, 0,
'');
2771 if (!empty($societe->id) && $societe->id > 0) {
2773 print
'<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
2775 $thirdparty = $societe;
2777 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?socid='.$societe->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
2778 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2784 print
'<tr><td>'.$langs->trans(
'Label').
'</td><td><input class="minwidth200" name="label" value="'.
dol_escape_htmltag(
GETPOST(
'label')).
'" type="text"></td></tr>';
2788 print
'<tr><td class="fieldrequired">'.$langs->trans(
'DateInvoice').
'</td><td>';
2789 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2790 print $form->selectDate($dateinvoice ? (
int) $dateinvoice :
'',
'', 0, 0, 0,
"add", 1, 1);
2794 print
'<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
2795 print
img_picto(
'',
'payment',
'class="pictofixedwidth"');
2796 print $form->getSelectConditionsPaiements($cond_reglement_id,
'cond_reglement_id', -1, 1, 0,
'maxwidth200 widthcentpercentminusx');
2800 print
'<tr><td>'.$langs->trans(
'DateMaxPayment').
'</td><td>';
2801 print
img_picto(
'',
'action',
'class="pictofixedwidth"');
2802 print $form->selectDate($datedue,
'ech', 0, 0, 0,
"add", 1, 1);
2806 print
'<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
2807 print
img_picto(
'',
'bank',
'class="pictofixedwidth"');
2808 $form->select_types_paiements((
string) $mode_reglement_id,
'mode_reglement_id',
'DBIT', 0, 1, 0, 0, 1,
'maxwidth200 widthcentpercentminusx');
2813 print
'<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
2815 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"').$form->select_comptes((
int) $fk_account,
'fk_account', 0,
'', 1,
'', 0,
'maxwidth200 widthcentpercentminusx', 1);
2823 $langs->load(
'projects');
2824 print
'<tr><td>'.$langs->trans(
'Project').
'</td><td>';
2825 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');
2826 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>';
2833 print
'<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), !empty($objectsrc->label_incoterms) ? $objectsrc->label_incoterms :
'', 1).
'</label></td>';
2834 print
'<td colspan="3" class="maxwidthonsmartphone">';
2835 print
img_picto(
'',
'incoterm',
'class="pictofixedwidth"');
2836 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 :
''));
2842 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
2843 print
'<tr><td>' . $langs->trans(
'VATReverseCharge') .
'</td><td>';
2845 if (GETPOSTISSET(
'vat_reverse_charge')) {
2846 $vat_reverse_charge = (
GETPOST(
'vat_reverse_charge',
'alpha') ==
'on' ||
GETPOST(
'vat_reverse_charge',
'alpha') ==
'1') ? 1 : 0;
2847 } elseif ($vat_reverse_charge == 1 || $societe->vat_reverse_charge == 1 || ($societe->country_code !=
'FR' &&
isInEEC($societe) && !empty($societe->tva_intra))) {
2848 $vat_reverse_charge = 1;
2850 $vat_reverse_charge = 0;
2853 print
'<input type="checkbox" name="vat_reverse_charge"'. (!empty($vat_reverse_charge) ?
' checked ' :
'') .
'>';
2860 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
2861 print
'<td class="maxwidthonsmartphone">';
2862 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
2863 $used_currency_code = $currency_code;
2864 if (!
GETPOST(
'changecompany')) {
2865 $used_currency_code = GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code',
'alpha') : $currency_code;
2867 print $form->selectMultiCurrency($used_currency_code,
'multicurrency_code');
2873 if ($fac_recid > 0) {
2874 $dateexample = $dateinvoice;
2875 if (empty($dateexample)) {
2878 $substitutionarray = array(
2879 '__TOTAL_HT__' => $langs->trans(
"AmountHT").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ht).
')',
2880 '__TOTAL_TTC__' => $langs->trans(
"AmountTTC").
' ('.$langs->trans(
"Example").
': '.
price($exampletemplateinvoice->total_ttc).
')',
2881 '__INVOICE_PREVIOUS_MONTH__' => $langs->trans(
"PreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%m').
')',
2882 '__INVOICE_MONTH__' => $langs->trans(
"MonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%m').
')',
2883 '__INVOICE_NEXT_MONTH__' => $langs->trans(
"NextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%m').
')',
2884 '__INVOICE_PREVIOUS_MONTH_TEXT__' => $langs->trans(
"TextPreviousMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'm'),
'%B').
')',
2885 '__INVOICE_MONTH_TEXT__' => $langs->trans(
"TextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%B').
')',
2886 '__INVOICE_NEXT_MONTH_TEXT__' => $langs->trans(
"TextNextMonthOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'm'),
'%B').
')',
2887 '__INVOICE_PREVIOUS_YEAR__' => $langs->trans(
"PreviousYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, -1,
'y'),
'%Y').
')',
2888 '__INVOICE_YEAR__' => $langs->trans(
"YearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date($dateexample,
'%Y').
')',
2889 '__INVOICE_NEXT_YEAR__' => $langs->trans(
"NextYearOfInvoice").
' ('.$langs->trans(
"Example").
': '.
dol_print_date(
dol_time_plus_duree($dateexample, 1,
'y'),
'%Y').
')'
2892 $htmltext =
'<i>'.$langs->trans(
"FollowingConstantsWillBeSubstituted").
':<br>';
2893 foreach ($substitutionarray as $key => $val) {
2894 $htmltext .= $key.
' = '.$langs->trans($val).
'<br>';
2896 $htmltext .=
'</i>';
2901 $langs->loadLangs(array(
"intracommreport"));
2902 print
'<!-- If module intracomm on -->'.
"\n";
2903 print
'<tr><td>'.$langs->trans(
'IntracommReportTransportMode').
'</td><td>';
2904 $form->selectTransportMode(GETPOSTISSET(
'transport_mode_id') ?
GETPOST(
'transport_mode_id') : $transport_mode_id,
'transport_mode_id');
2908 if (empty($reshook)) {
2909 print
$object->showOptionals($extrafields,
'create');
2914 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
2915 print $form->selectCategories(Categorie::TYPE_SUPPLIER_INVOICE,
'categories', $object);
2920 print
'<tr><td>'.$langs->trans(
'NotePublic').
'</td>';
2922 $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%');
2923 print $doleditor->Create(1);
2929 print
'<tr><td>'.$langs->trans(
'NotePrivate').
'</td>';
2931 $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%');
2932 print $doleditor->Create(1);
2938 if (!empty($objectsrc)) {
2939 print
"\n<!-- ".$classname.
" info -->";
2941 print
'<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2942 print
'<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2943 print
'<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2944 print
'<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2945 print
'<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2947 $txt = $langs->trans($classname);
2948 if ($classname ==
'CommandeFournisseur') {
2949 $langs->load(
'orders');
2950 $txt = $langs->trans(
"SupplierOrder");
2952 print
'<tr><td>'.$txt.
'</td><td>'.$objectsrc->getNomUrl(1);
2954 $objectsrc->fetchObjectLinked($originid, $origin,
null,
'invoice_supplier');
2956 if (isset($objectsrc->linkedObjects[
'invoice_supplier'])) {
2957 $invoice_supplier = $objectsrc->linkedObjects[
'invoice_supplier'];
2959 $invoice_supplier = [];
2961 '@phan-var-force null|FactureFournisseur[] $invoice_supplier';
2964 if (is_array($invoice_supplier)) {
2965 $cntinvoice = count($invoice_supplier);
2967 if ($cntinvoice >= 1) {
2969 echo
' ('.$langs->trans(
'LatestRelatedBill').end($invoice_supplier)->getNomUrl(1).
')';
2974 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
2975 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
2976 if (
$mysoc->localtax1_assuj ==
"1" ||
$object->total_localtax1 != 0) {
2977 print
'<tr><td>'.$langs->transcountry(
"AmountLT1",
$mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
2980 if (
$mysoc->localtax2_assuj ==
"1" ||
$object->total_localtax2 != 0) {
2981 print
'<tr><td>'.$langs->transcountry(
"AmountLT2",
$mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
2983 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
2986 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
2987 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
2988 print
'<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2993 $parameters = array();
2994 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2995 print $hookmanager->resPrint;
3003 print $form->buttonsSaveCancel(
"CreateDraft");
3006 if (!empty($objectsrc)) {
3009 $title = $langs->trans(
'ProductsAndServices');
3012 print
'<div class="div-table-responsive-no-min">';
3013 print
'<table class="noborder centpercent">';
3015 $objectsrc->printOriginLinesList(
'', $selectedLines);
3023 if ($id > 0 || !empty($ref)) {
3029 $result =
$object->fetch($id, $ref);
3034 $result =
$object->fetch_thirdparty();
3040 $societe =
$object->thirdparty;
3042 $totalpaid =
$object->getSommePaiement();
3043 $totalcreditnotes =
$object->getSumCreditNotesUsed();
3044 $totaldeposits =
$object->getSumDepositsUsed();
3052 $resteapayer =
price2num(
$object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
3055 $multicurrency_resteapayer = 0;
3057 $multicurrency_totalpaid =
$object->getSommePaiement(1);
3058 $multicurrency_totalcreditnotes =
$object->getSumCreditNotesUsed(1);
3059 $multicurrency_totaldeposits =
$object->getSumDepositsUsed(1);
3060 $multicurrency_resteapayer =
price2num(
$object->multicurrency_total_ttc - $multicurrency_totalpaid - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits,
'MT');
3064 if ($resteapayer == 0 && $multicurrency_resteapayer != 0 &&
$object->multicurrency_code != $conf->currency) {
3065 $resteapayer =
price2num((
float) $multicurrency_resteapayer /
$object->multicurrency_tx,
'MT');
3072 $resteapayeraffiche = $resteapayer;
3075 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
3076 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
3078 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
3079 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
3082 $absolute_discount = $societe->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
3083 $absolute_creditnote = $societe->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
3084 $absolute_discount =
price2num($absolute_discount,
'MT');
3085 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
3089 $objectidnext =
$object->getIdReplacingInvoice();
3092 $titre = $langs->trans(
'SupplierInvoice');
3094 print
dol_get_fiche_head($head,
'card', $titre, -1,
'supplier_invoice', 0,
'',
'', 0,
'', 1);
3099 if ($action ==
'converttoreduc') {
3102 $type_fac =
'ExcessPaid';
3104 $type_fac =
'CreditNote';
3106 $type_fac =
'Deposit';
3108 $text = $langs->trans(
'ConfirmConvertToReducSupplier', strtolower($langs->transnoentities($type_fac)));
3109 $text .=
'<br>'.$langs->trans(
'ConfirmConvertToReducSupplier2');
3110 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.
$object->id, $langs->trans(
'ConvertToReduc'), $text,
'confirm_converttoreduc',
'',
"yes", 2);
3114 if ($action ==
'clone') {
3116 $formquestion = array(
3117 array(
'type' =>
'text',
'name' =>
'newsupplierref',
'label' => $langs->trans(
"RefSupplierBill"),
'value' => $langs->trans(
"CopyOf").
' '.
$object->ref_supplier),
3118 array(
'type' =>
'date',
'name' =>
'newdate',
'label' => $langs->trans(
"Date"),
'value' =>
dol_now())
3121 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneInvoice',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1, 250);
3125 if ($action ==
'valid') {
3127 if (preg_match(
'/^[\(]?PROV/i',
$object->ref) || empty(
$object->ref)) {
3129 $numref =
$object->getNextNumRef($societe);
3131 $numref = (string)
$object->ref;
3138 $text = $langs->trans(
'ConfirmValidateBill', $numref);
3146 $formquestion = array();
3148 $qualified_for_stock_change = 0;
3150 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3152 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3156 $langs->load(
"stocks");
3157 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3160 $warehouse_array = $warehouse->list_array();
3161 if (count($warehouse_array) == 1) {
3163 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3166 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3168 $formquestion = array(
3169 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3173 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ValidateBill'), $text,
'confirm_valid', $formquestion, 1, 1);
3178 if ($action ==
'edit') {
3179 $formquestion = array();
3181 $qualified_for_stock_change = 0;
3183 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3185 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3188 $langs->load(
"stocks");
3189 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3192 $warehouse_array = $warehouse->list_array();
3193 if (count($warehouse_array) == 1) {
3195 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3198 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3200 $formquestion = array(
3201 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
3204 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'UnvalidateBill'), $langs->trans(
'ConfirmUnvalidateBill',
$object->ref),
'confirm_edit', $formquestion, 1, 1);
3208 if ($action ==
'paid' && ($resteapayer <= 0 || (
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') && $resteapayer ==
$object->total_ttc))) {
3209 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidBill',
$object->ref),
'confirm_paid',
'', 0, 1);
3212 if ($action ==
'paid' && $resteapayer > 0 && (!
getDolGlobalString(
'SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID') || $resteapayer !=
$object->total_ttc)) {
3216 $close[$i][
'code'] =
'discount_vat';
3218 $close[$i][
'code'] =
'badsupplier';
3220 $close[$i][
'code'] =
'other';
3224 $close[$i][
'label'] = $langs->trans(
"HelpEscompte").
'<br><br>'.$langs->trans(
"ConfirmClassifyPaidPartiallyReasonDiscountVatDesc");
3226 $close[$i][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3228 $close[$i][
'label'] = $langs->trans(
"Other");
3232 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonDiscount", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3234 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadCustomer", $resteapayer, $langs->trans(
"Currency".$conf->currency)), $close[$i][
'label'], 1);
3236 $close[$i][
'reason'] = $form->textwithpicto($langs->transnoentities(
"Other"), $close[$i][
'label'], 1);
3239 $arrayreasons = array();
3240 foreach ($close as $key => $val) {
3241 $arrayreasons[$close[$key][
'code']] = $close[$key][
'reason'];
3245 $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'));
3247 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?facid='.
$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidPartially',
$object->ref),
'confirm_paid_partially', $formquestion,
"yes", 1, 310);
3251 if ($action ==
'canceled') {
3253 $close[1][
'code'] =
'badsupplier';
3254 $close[2][
'code'] =
'abandon';
3256 $close[1][
'label'] = $langs->trans(
"ConfirmClassifyPaidPartiallyReasonBadSupplierDesc");
3257 $close[2][
'label'] = $langs->trans(
"ConfirmClassifyAbandonReasonOtherDesc");
3259 $close[1][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyPaidPartiallyReasonBadSupplier",
$object->ref), $close[1][
'label'], 1);
3260 $close[2][
'reason'] = $form->textwithpicto($langs->transnoentities(
"ConfirmClassifyAbandonReasonOther"), $close[2][
'label'], 1);
3262 $arrayreasons[$close[1][
'code']] = $close[1][
'reason'];
3263 $arrayreasons[$close[2][
'code']] = $close[2][
'reason'];
3266 $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'));
3268 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $langs->trans(
'CancelBill'), $langs->trans(
'ConfirmCancelBill',
$object->ref),
'confirm_canceled', $formquestion,
"yes", 1, 280);
3272 if ($action ==
'delete') {
3273 $formquestion = array();
3275 $qualified_for_stock_change = 0;
3277 $qualified_for_stock_change =
$object->hasProductsOrServices(2);
3279 $qualified_for_stock_change =
$object->hasProductsOrServices(1);
3283 $langs->load(
"stocks");
3284 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3287 $warehouse_array = $warehouse->list_array();
3289 $selectwarehouse =
'<span class="questionrevertstock hidden">';
3290 if (count($warehouse_array) == 1) {
3292 $selectwarehouse .=
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
3295 $selectwarehouse .= $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
3297 $selectwarehouse .=
'</span>';
3299 $selectyesno = array(0 => $langs->trans(
'No'), 1 => $langs->trans(
'Yes'));
3301 print
'<script type="text/javascript">
3302 $(document).ready(function() {
3303 $("#revertstock").change(function() {
3304 if(this.value > 0) {
3305 $(".questionrevertstock").removeClass("hidden");
3307 $(".questionrevertstock").addClass("hidden");
3313 $formquestion = array(
3314 array(
'type' =>
'select',
'name' =>
'revertstock',
'label' => $langs->trans(
"RevertProductsToStock"),
'select_show_empty' => 0,
'values' => $selectyesno),
3315 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $selectwarehouse,
'tdclass' =>
'questionrevertstock hidden')
3319 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteBill'), $langs->trans(
'ConfirmDeleteBill'),
'confirm_delete', $formquestion, 1, 1);
3321 if ($action ==
'deletepayment') {
3322 $payment_id =
GETPOST(
'paiement_id');
3323 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&paiement_id='.$payment_id, $langs->trans(
'DeletePayment'), $langs->trans(
'ConfirmDeletePayment'),
'confirm_delete_paiement',
'', 0, 1);
3327 if ($action ==
'ask_deleteline') {
3328 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
3331 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
3332 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
3333 if (empty($reshook)) {
3334 $formconfirm .= $hookmanager->resPrint;
3335 } elseif ($reshook > 0) {
3336 $formconfirm = $hookmanager->resPrint;
3344 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
3346 $morehtmlref =
'<div class="refidno">';
3348 $morehtmlref .= $form->editfieldkey(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier, $object, (
int) $usercancreate,
'string',
'', 0, 1);
3349 $morehtmlref .= $form->editfieldval(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier, $object, $usercancreate,
'string',
'',
null,
null,
'', 1);
3351 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1,
'supplier');
3353 $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>';
3357 $langs->load(
"projects");
3358 $morehtmlref .=
'<br>';
3359 if ($permissiontoadd) {
3360 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
3361 if ($action !=
'classify') {
3362 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.((int)
$object->id).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
3364 $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');
3366 if (!empty(
$object->fk_project)) {
3368 $proj->fetch(
$object->fk_project);
3369 $morehtmlref .= $proj->getNomUrl(1);
3371 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
3376 $morehtmlref .=
'</div>';
3378 $object->totalpaid = $totalpaid;
3380 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
3383 $parameters = array();
3385 $reshook = $hookmanager->executeHooks(
'tabContentViewSupplierInvoice', $parameters, $object, $action);
3386 if (empty($reshook)) {
3387 print
'<div class="fichecenter">';
3388 print
'<div class="fichehalfleft">';
3389 print
'<div class="underbanner clearboth"></div>';
3391 print
'<table class="border tableforfield centpercent">';
3394 print
'<tr><td>'.$langs->trans(
'Type').
'</td><td>';
3395 print
'<span class="badgeneutral">';
3399 print
' '.$object->getSubtypeLabel(
'facture_fourn');
3403 $facreplaced->fetch(
$object->fk_facture_source);
3404 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
'</span>';
3407 if (
$object->fk_facture_source > 0) {
3409 $facusing->fetch(
$object->fk_facture_source);
3410 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
'</span>';
3412 $langs->load(
"errors");
3413 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"WarningCorrectedInvoiceNotFound").
'</span>';
3418 $object->getListIdAvoirFromInvoice();
3420 if (!empty(
$object->creditnote_ids)) {
3421 $invoicecredits = array();
3422 foreach (
$object->creditnote_ids as $invoiceid) {
3424 $creditnote->fetch($invoiceid);
3425 $invoicecredits[] = $creditnote->getNomUrl(1);
3427 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"InvoiceHasAvoir") . (count($invoicecredits) ?
' ' :
'') . implode(
',', $invoicecredits);
3430 if (isset($objectidnext) && $objectidnext > 0) {
3433 $facthatreplace->fetch($objectidnext);
3434 print
' <span class="opacitymediumbycolor paddingleft">'.str_replace(
'{s1}', $facthatreplace->getNomUrl(1), $langs->transnoentities(
"ReplacedByInvoice",
'{s1}')).
'</span>';
3438 $result = $discount->fetch(0, 0,
$object->id);
3440 print
' <span class="opacitymediumbycolor paddingleft">';
3441 $s = $langs->trans(
"CreditNoteConvertedIntoDiscount",
'{s1}',
'{s2}');
3442 $s = str_replace(
'{s1}',
$object->getLibType(1), $s);
3443 $s = str_replace(
'{s2}', $discount->getNomUrl(1,
'discount'), $s);
3445 print
'</span><br>';
3449 if (
$object->fk_fac_rec_source > 0) {
3451 $result = $tmptemplate->fetch(
$object->fk_fac_rec_source);
3453 print
' <span class="opacitymediumbycolor paddingleft">';
3454 $link =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.$tmptemplate->id.
'">'.
dol_escape_htmltag($tmptemplate->title).
'</a>';
3455 $s = $langs->transnoentities(
"GeneratedFromSupplierTemplate", $link);
3465 print
'<!-- Discounts -->'.
"\n";
3466 print
'<tr><td>'.$langs->trans(
'DiscountStillRemaining');
3469 $thirdparty = $societe;
3471 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
3477 print
'<td>'.$form->editfieldkey(
"Label",
'label',
$object->label, $object, (
int) $usercancreate).
'</td>';
3478 print
'<td>'.$form->editfieldval(
"Label",
'label',
$object->label, $object, $usercancreate).
'</td>';
3486 print $form->editfieldkey(
"DateInvoice",
'datef', (
string)
$object->date,
$object, (int) $form_permission,
'datepicker');
3487 print
'</td><td colspan="3">';
3488 print $form->editfieldval(
"Date",
'datef',
$object->date, $object, $form_permission,
'datepicker');
3492 $langs->load(
'bills');
3493 print
'<tr><td class="nowrap">';
3494 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3495 print $langs->trans(
'PaymentConditions');
3497 if ($action !=
'editconditions' && $form_permission) {
3498 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>';
3500 print
'</tr></table>';
3502 if ($action ==
'editconditions') {
3503 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id');
3505 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'none');
3512 print $form->editfieldkey(
"DateMaxPayment",
'date_lim_reglement', (
string)
$object->date_echeance, $object, (
int) $form_permission,
'datepicker');
3514 print $form->editfieldval(
"DateMaxPayment",
'date_lim_reglement',
$object->date_echeance, $object, $form_permission,
'datepicker');
3515 if ($action !=
'editdate_lim_reglement' &&
$object->hasDelay()) {
3521 $langs->load(
'bills');
3522 print
'<tr><td class="nowrap">';
3523 print
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
3524 print $langs->trans(
'PaymentMode');
3526 if ($action !=
'editmode' && $form_permission) {
3527 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>';
3529 print
'</tr></table>';
3531 if ($action ==
'editmode') {
3532 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
3534 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
3540 print
'<tr><td class="nowrap">';
3541 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3542 print $langs->trans(
'BankAccount');
3544 if ($action !=
'editbankaccount' && $usercancreate) {
3545 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>';
3547 print
'</tr></table>';
3549 if ($action ==
'editbankaccount') {
3550 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
3552 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'none');
3560 print
'<tr><td class="nowrap">';
3561 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
3562 print $langs->trans(
'VATReverseCharge');
3564 if ($action !=
'editvatreversecharge' && $usercancreate) {
3565 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editvatreversecharge&id='.
$object->id.
'">'.
img_edit($langs->trans(
'SetVATReverseCharge'), 1).
'</a></td>';
3567 print
'</tr></table>';
3569 if ($action ==
'editvatreversecharge') {
3570 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'">';
3571 print
'<input type="hidden" name="action" value="setvatreversecharge">';
3572 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3574 print
'<input type="checkbox" name="vat_reverse_charge"' . (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
'>';
3576 print
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
3579 print
'<input type="checkbox" name="vat_reverse_charge"'. (
$object->vat_reverse_charge ==
'1' ?
' checked ' :
'') .
' disabled>';
3587 print
'<table width="100%" class="nobordernopadding"><tr><td>';
3588 print $langs->trans(
'IncotermLabel');
3589 print
'<td><td class="right">';
3590 if ($usercancreate) {
3591 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.
$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit().
'</a>';
3595 print
'</td></tr></table>';
3598 if ($action !=
'editincoterm') {
3599 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3601 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
3608 $langs->loadLangs(array(
"intracommreport"));
3609 print
'<!-- If module intracomm on -->'.
"\n";
3611 print
'<table class="nobordernopadding centpercent"><tr><td>';
3612 print $langs->trans(
'IntracommReportTransportMode');
3614 if ($action !=
'edittransportmode' && ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"))) {
3615 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edittransportmode&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit().
'</a></td>';
3617 print
'</tr></table>';
3620 if ($action ==
'edittransportmode') {
3621 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->transport_mode_id,
'transport_mode_id', 1, 1);
3623 $form->formSelectTransportMode($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->transport_mode_id,
'none');
3631 print
'<table class="nobordernopadding centpercent"><tr><td>';
3632 print $langs->trans(
"Categories");
3633 print
'<td><td class="right">';
3634 if ($usercancreate) {
3635 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.
$object->id.
'&action=edittags&token='.
newToken().
'">'.
img_edit().
'</a>';
3639 print
'</td></tr></table>';
3642 if ($action ==
'edittags') {
3643 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'?facid='.
$object->id.
'">';
3644 print
'<input type="hidden" name="action" value="settags">';
3645 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3646 print $form->selectCategories(Categorie::TYPE_SUPPLIER_INVOICE,
'categories', $object);
3647 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
3650 print $form->showCategories(
$object->id, Categorie::TYPE_SUPPLIER_INVOICE, 1);
3658 if (
$object->status != $object::STATUS_DRAFT) {
3662 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3667 print
'<div class="fichehalfright">';
3668 print
'<div class="underbanner clearboth"></div>';
3670 print
'<table class="border tableforfield centpercent">';
3672 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
3675 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
3676 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ht, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3678 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3683 print
'<td>' . $langs->trans(
'AmountVAT') .
'</td>';
3684 print
'<td class="nowrap amountcard right">';
3685 if (
GETPOST(
'calculationrule')) {
3686 $calculationrule =
GETPOST(
'calculationrule',
'alpha');
3688 $calculationrule = (!
getDolGlobalString(
'MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND_SUPPLIER') ?
'totalofround' :
'roundoftotal');
3690 if ($calculationrule ==
'totalofround') {
3691 $calculationrulenum = 1;
3693 $calculationrulenum = 2;
3696 if (
$object->getVentilExportCompta() == 0) {
3697 $s =
'<span class="hideonsmartphone opacitymedium">' . $langs->trans(
"ReCalculate") .
' </span>';
3698 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&token='.newToken().
'&calculationrule=totalofround">' . $langs->trans(
"Mode1") .
'</a>';
3700 $s .=
'<a href="' . $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=calculate&token='.newToken().
'&calculationrule=roundoftotal">' . ($conf->dol_optimize_smallscreen ?
"2" : $langs->trans(
"Mode2")) .
'</a>';
3701 print
'<div class="inline-block">';
3702 print $form->textwithtooltip($s, $langs->trans(
"CalculationRuleDesc", $calculationrulenum) .
'<br>' . $langs->trans(
"CalculationRuleDescSupplier"), 2, 1,
img_picto(
'',
'help',
'class="paddingleft paddingright"'),
'', 3,
'', 0,
'recalculate');
3703 print
' ';
3706 print
'<span class="nowraponall">'.price(
$object->total_tva, 1, $langs, 0, -1, -1, $conf->currency).
'</span>';
3709 print
'<td class="nowraponall amountcard right">' .
price(
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3713 if ($societe->localtax1_assuj ==
"1") {
3715 print
'<td>' . $langs->transcountry(
"AmountLT1", $societe->country_code) .
'</td>';
3716 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax1, 1, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3719 if ($societe->localtax2_assuj ==
"1") {
3721 print
'<td>' . $langs->transcountry(
"AmountLT2", $societe->country_code) .
'</td>';
3722 print
'<td class="nowrap amountcard right">' .
price(
$object->total_localtax2, 1, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3727 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
3728 print
'<td class="nowrap amountcard right">' .
price(
$object->total_ttc, 0, $langs, 0, -1, -1, $conf->currency) .
'</td>';
3730 print
'<td class="nowrap amountcard right">' .
price(
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
3763 if ($societe->localtax1_assuj ==
"1") {
3766 if ($societe->localtax2_assuj ==
"1") {
3770 $sql =
'SELECT p.datep as dp, p.ref, p.num_paiement as num_payment, p.rowid, p.fk_bank,';
3771 $sql .=
' c.id as payment_type, c.code as payment_code,';
3772 $sql .=
' pf.amount,';
3773 $sql .=
' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal';
3774 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn as p';
3775 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
3776 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
3777 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id';
3778 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid';
3779 $sql .=
' WHERE pf.fk_facturefourn = '.((int)
$object->id);
3780 $sql .=
' ORDER BY p.datep, p.tms';
3782 $result = $db->query($sql);
3784 $num = $db->num_rows($result);
3787 print
'<div class="div-table-responsive-no-min">';
3788 print
'<table class="noborder paymenttable centpercent">';
3789 print
'<tr class="liste_titre">';
3791 print
'<td><span class="hideonsmartphone">'.$langs->trans(
'Date').
'</span></td>';
3792 print
'<td><span class="hideonsmartphone">'.$langs->trans(
'Type').
'</span></td>';
3794 print
'<td class="right">'.$langs->trans(
'BankAccount').
'</td>';
3799 print
'<td class="right">'.$langs->trans(
'Amount').
'</td>';
3804 $objp = $db->fetch_object($result);
3806 $paymentstatic->id = $objp->rowid;
3807 $paymentstatic->datepaye = $db->jdate($objp->dp);
3808 $paymentstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
3809 $paymentstatic->num_payment = $objp->num_payment;
3811 $paymentstatic->paiementcode = $objp->payment_code;
3812 $paymentstatic->type_code = $objp->payment_code;
3813 $paymentstatic->type_label = $objp->payment_type;
3815 print
'<tr class="oddeven">';
3816 print
'<td class="nowraponall">';
3817 print $paymentstatic->getNomUrl(1);
3819 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
'</td>';
3820 $s = $form->form_modes_reglement(
'', $objp->payment_type,
'none',
'', 1, 0,
'', 1).
' '.$objp->num_payment;
3821 print
'<td class="tdoverflowmax125" title="'.dol_escape_htmltag($s).
'">';
3825 $bankaccountstatic->id = $objp->baid;
3826 $bankaccountstatic->ref = $objp->baref;
3827 $bankaccountstatic->label = $objp->baref;
3828 $bankaccountstatic->number = $objp->banumber;
3831 $bankaccountstatic->account_number = $objp->account_number;
3834 $accountingjournal->fetch($objp->fk_accountancy_journal);
3835 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
3838 print
'<td class="right nowraponall">';
3839 if ($objp->baid > 0) {
3840 print $bankaccountstatic->getNomUrl(1,
'transactions');
3845 print
'<td class="center">';
3847 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deletepayment&token='.
newToken().
'&paiement_id='.$objp->rowid.
'">';
3853 print
'<td class="right">'.price($sign * $objp->amount).
'</td>';
3855 $totalpaid += $objp->amount;
3859 print
'<tr class="oddeven"><td colspan="'.$nbcols.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td>';
3885 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
3886 print
'<span class="opacitymedium">';
3888 print $langs->trans(
'AlreadyPaidNoCreditNotesNoDeposits');
3890 print $langs->trans(
'AlreadyPaid');
3895 print
'<td class="right"'.(($totalpaid > 0) ?
' class="amountalreadypaid"' :
'').
'>'.
price($totalpaid).
'</td>';
3899 $resteapayeraffiche = $resteapayer;
3901 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
3904 $creditnoteamount = 0;
3907 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
3908 $sql .=
" re.description, re.fk_invoice_supplier_source";
3909 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
3910 $sql .=
" WHERE fk_invoice_supplier = ".((int)
$object->id);
3911 $resql = $db->query($sql);
3913 $num = $db->num_rows($resql);
3917 $obj = $db->fetch_object($resql);
3918 $invoice->fetch($obj->fk_invoice_supplier_source);
3919 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3921 print $langs->trans(
"CreditNote").
' ';
3924 print $langs->trans(
"Deposit").
' ';
3926 print $invoice->getNomUrl(0);
3929 print
'<td class="right">';
3930 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=unlinkdiscount&discountid='.$obj->rowid.
'">';
3931 print
img_picto($langs->transnoentitiesnoconv(
"RemoveDiscount"),
'unlink');
3935 print
'<td class="right">'.price($obj->amount_ttc).
'</td>';
3939 $creditnoteamount += $obj->amount_ttc;
3942 $depositamount += $obj->amount_ttc;
3951 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right nowrap">';
3952 print
'<span class="opacitymedium">';
3953 print $form->textwithpicto($langs->trans(
"Discount"), $langs->trans(
"HelpEscompte"), - 1);
3957 print
'<td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td>';
3959 $resteapayeraffiche = 0;
3960 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3964 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right nowrap">';
3965 print
'<span class="opacitymedium">';
3966 print $form->textwithpicto($langs->trans(
"Abandoned"), $langs->trans(
"HelpAbandonBadCustomer"), - 1);
3970 print
'<td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td>';
3973 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3977 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right nowrap">';
3978 print
'<span class="opacitymedium">';
3979 print $form->textwithpicto($langs->trans(
"ProductReturned"), $langs->trans(
"HelpAbandonProductReturned"), - 1);
3983 print
'<td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td>';
3985 $resteapayeraffiche = 0;
3986 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3990 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right nowrap">';
3991 $text = $langs->trans(
"HelpAbandonOther");
3993 $text .=
'<br><br><b>'.$langs->trans(
"Reason").
'</b>:'.
$object->close_note;
3995 print
'<span class="opacitymedium">';
3997 print $form->textwithpicto($langs->trans(
"Abandoned"), $text, - 1);
4001 print
'<td class="right">'.price(
$object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).
'</td>';
4003 $resteapayeraffiche = 0;
4004 $cssforamountpaymentcomplete =
'amountpaymentneutral';
4008 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4009 print
'<span class="opacitymedium">';
4010 print $langs->trans(
"Billed");
4014 print
'<td class="right">'.price(
$object->total_ttc).
'</td>';
4018 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4019 print
'<span class="opacitymedium">';
4020 print $langs->trans(
'RemainderToPay');
4021 if ($resteapayeraffiche < 0) {
4022 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
4027 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayeraffiche).
'</td>';
4032 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4033 print
'<span class="opacitymedium">';
4034 print $langs->trans(
'RemainderToPayMulticurrency');
4035 if ($resteapayeraffiche < 0) {
4036 print
' ('.$langs->trans(
'NegativeIfExcessPaid').
')';
4041 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopaynoresize' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price(
price2num($multicurrency_resteapayer,
'MT'), 0, $langs, 1, -1, -1,
$object->multicurrency_code).
'</td>';
4045 $cssforamountpaymentcomplete =
'amountpaymentneutral';
4048 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4049 print $langs->trans(
'AlreadyPaidBack');
4052 print
'<td class="right">'.price($sign * $totalpaid).
'</td>';
4056 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">'.$langs->trans(
"Billed").
'</td>';
4058 print
'<td class="right">'.price($sign *
$object->total_ttc).
'</td>';
4062 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4063 print
'<span class="opacitymedium">';
4064 print $langs->trans(
'RemainderToPayBack');
4065 if ($resteapayeraffiche > 0) {
4066 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
4071 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($sign * $resteapayeraffiche).
'</td>';
4076 print
'<tr><td colspan="'.($nbcols + 1).
'" class="right">';
4077 print
'<span class="opacitymedium">';
4078 print $langs->trans(
'RemainderToPayBackMulticurrency');
4079 if ($resteapayeraffiche > 0) {
4080 print
' ('.$langs->trans(
'NegativeIfExcessRefunded').
')';
4085 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopaynoresize' : (
' '.$cssforamountpaymentcomplete)).
'">'.(!empty(
$object->multicurrency_code) ?
$object->multicurrency_code : $conf->currency).
' '.
price(
price2num($sign *
$object->multicurrency_tx * $resteapayeraffiche,
'MT')).
'</td>';
4101 print
'<div class="clearboth"></div><br>';
4104 $blocname =
'contacts';
4105 $title = $langs->trans(
'ContactsAddresses');
4106 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
4111 $blocname =
'notes';
4112 $title = $langs->trans(
'Notes');
4113 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
4120 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'" method="POST">';
4121 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4122 print
'<input type="hidden" name="action" value="'.(($action !=
'editline') ?
'addline' :
'updateline').
'">';
4123 print
'<input type="hidden" name="mode" value="">';
4124 print
'<input type="hidden" name="page_y" value="">';
4125 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
4126 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
4127 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
4130 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
4133 print
'<div class="div-table-responsive-no-min">';
4134 print
'<table id="tablelines" class="noborder noshadow centpercent">';
4136 global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax;
4139 $inputalsopricewithtax = 1;
4140 $senderissupplier = 2;
4141 if (
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY')) {
4142 $senderissupplier =
getDolGlobalInt(
'SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY');
4147 $object->printObjectLines($action, $societe,
$mysoc, $lineid, 1);
4154 if ($action !=
'editline') {
4157 $parameters = array();
4158 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
4162 if (empty($reshook)) {
4176 if ($action !=
'presend') {
4179 print
'<div class="tabsAction">';
4181 $parameters = array();
4182 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
4184 if (empty($reshook)) {
4188 $ventilExportCompta =
$object->getVentilExportCompta();
4190 if ($ventilExportCompta == 0) {
4191 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
'Modify').
'</a>';
4193 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseDispatchedInBookkeeping").
'">'.$langs->trans(
'Modify').
'</span>';
4198 $result = $discount->fetch(0, 0,
$object->id);
4205 if (!$objectidnext &&
$object->close_code !=
'replaced' && $usercancreate) {
4206 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=reopen&token='.
newToken().
'">'.$langs->trans(
'ReOpen').
'</a>';
4208 if ($usercancreate) {
4209 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseReplacedInvoice").
'">'.$langs->trans(
'ReOpen').
'</span>';
4211 print
'<span class="butActionRefused classfortooltip">'.$langs->trans(
'ReOpen').
'</span>';
4221 if ($usercanvalidate) {
4222 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=valid&token='.
newToken().
'"';
4223 print
'>'.$langs->trans(
'Validate').
'</a>';
4225 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'"';
4226 print
'>'.$langs->trans(
'Validate').
'</a>';
4232 if (empty($user->socid)) {
4235 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email',
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'id' =>
$object->id,
'action' =>
'presend',
'mode' =>
'init'],
true).
'#formmailbeforetitle',
'');
4244 $langs->load(
"withdrawals");
4245 if ($resteapayer > 0) {
4246 if ($usercancreatecreditransfer) {
4247 if (!$objectidnext &&
$object->close_code !=
'replaced') {
4248 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/compta/facture/prelevement.php?facid='.
$object->id.
'&type=bank-transfer" title="'.
dol_escape_htmltag($langs->trans(
"MakeBankTransferOrder")).
'">'.$langs->trans(
"MakeBankTransferOrder").
'</a>';
4250 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseReplacedInvoice").
'">'.$langs->trans(
'MakeBankTransferOrder').
'</span>';
4262 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/facture/paiement.php?facid='.
$object->id.
'&action=create'.(
$object->fk_account > 0 ?
'&accountid='.$object->fk_account :
'').
'">'.$langs->trans(
'DoPayment').
'</a>';
4269 if ($resteapayer == 0) {
4270 print
'<span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseRemainderToPayIsZero").
'">'.$langs->trans(
'DoPaymentBack').
'</span>';
4271 } elseif ($usercancreate) {
4272 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>';
4278 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.
newToken().
'">'.$langs->trans(
'ConvertExcessPaidToReduc').
'</a>';
4282 && (
getDolGlobalString(
'SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED') ||
$object->getSommePaiement() == 0)
4284 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>';
4288 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.
$object->id.
'&action=converttoreduc&token='.
newToken().
'">'.$langs->trans(
'ConvertToReduc').
'</a>';
4299 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=paid&token='.
newToken().
'">'.$langs->trans(
'ClassifyPaid').
'</a>';
4304 if ($totalpaid > 0 || $totalcreditnotes > 0) {
4306 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=paid&token='.
newToken().
'">'.$langs->trans(
'ClassifyPaidPartially').
'</a>';
4309 print
'<a class="butAction'.($conf->use_javascript_ajax ?
' reposition' :
'').
'" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=canceled">'.$langs->trans(
'ClassifyCanceled').
'</a>';
4321 if (!$objectidnext) {
4322 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>';
4327 if ($action !=
'edit' && $usercancreate) {
4328 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=clone&socid='.
$object->socid.
'&token='.
newToken().
'">'.$langs->trans(
'ToClone').
'</a>';
4333 if (!$objectidnext && count(
$object->lines) > 0) {
4334 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/fourn/facture/card-rec.php?facid='.
$object->id.
'&action=create">'.$langs->trans(
"ChangeIntoRepeatableInvoice").
'</a>';
4339 if ($action !=
'confirm_edit' && $usercandelete) {
4340 $isErasable =
$object->is_erasable();
4342 $enableDelete =
false;
4344 $params = (empty($conf->use_javascript_ajax) ? array() : array(
'attr' => array(
'class' =>
'reposition')));
4346 if ($isErasable == -4) {
4347 $htmltooltip = $langs->trans(
"DisabledBecausePayments");
4348 } elseif ($isErasable == -3) {
4349 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastSituationInvoice");
4350 } elseif ($isErasable == -2) {
4351 $htmltooltip = $langs->trans(
"DisabledBecauseNotLastInvoice");
4352 } elseif ($isErasable == -1) {
4353 $htmltooltip = $langs->trans(
"DisabledBecauseDispatchedInBookkeeping");
4354 } elseif ($isErasable <= 0) {
4355 $htmltooltip = $langs->trans(
"DisabledBecauseNotErasable");
4357 $enableDelete =
true;
4360 print
dolGetButtonAction($htmltooltip, $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(), (
string)
$object->id, $enableDelete, $params);
4364 if ($action !=
'confirm_edit') {
4365 print
'<div class="fichecenter"><div class="fichehalfleft">';
4371 $subdir =
get_exdir(
$object->id, 2, 0, 0, $object,
'invoice_supplier').$ref;
4372 $filedir = $conf->fournisseur->facture->dir_output.
'/'.$subdir;
4373 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.
$object->id;
4374 $genallowed = $usercanread;
4375 $delallowed = $usercancreate;
4379 print $formfile->showdocuments(
'facture_fournisseur', $subdir, $filedir, $urlsource, (
int) $genallowed, (
int) $delallowed, $modelpdf, $genifempty, 0, 0, 40, 0,
'',
'',
'', $societe->default_lang);
4380 $somethingshown = $formfile->numoffiles;
4383 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'invoice_supplier'), 1);
4384 $linktoelem = $tmparray[
'linktoelem'];
4385 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
4386 print $htmltoenteralink;
4388 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
4390 print
'</div><div class="fichehalfright">';
4393 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
4395 $somethingshown = $formactions->showactions($object,
'invoice_supplier', $socid, 1,
'listaction'.($genallowed ?
'largetitle' :
''));
4397 print
'</div></div>';
4403 if (
GETPOST(
'modelselected')) {
4404 $action =
'presend';
4408 $modelmail =
'invoice_supplier_send';
4409 $defaulttopic =
'SendBillRef';
4410 $diroutput = $conf->fournisseur->facture->dir_output;
4411 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
4412 $trackid =
'sinv'.$object->id;
4414 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage bank accounts.
Class to manage accounting journals.
const TYPE_PROFORMA
Proforma invoice.
const TYPE_SITUATION
Situation invoice.
Class to manage absolute discounts.
Class to manage a WYSIWYG editor.
Class to manage warehouses.
Class to manage suppliers invoices.
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
const TYPE_REPLACEMENT
Replacement invoice.
const STATUS_VALIDATED
Validated (need to be paid)
const TYPE_STANDARD
Standard invoice.
const STATUS_ABANDONED
Classified abandoned and no payment done.
const STATUS_CLOSED
Classified paid.
Class to manage invoice templates.
Class to manage payments for supplier invoices.
Class ProductCombination Used to represent the relation between a product and one of its variants.
Class to manage predefined suppliers products.
Class to manage products or services.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
dol_get_last_hour($date, $gm='tzserver')
Return GMT time for last hour of a given GMT date (it replaces hours, min and second part to 23:59:59...
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
facturefourn_prepare_head(FactureFournisseur $object)
Prepare array with list of tabs.
dol_now($mode='gmt')
Return date for now.
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolBuildUrl($url, $params=[], $addtoken=false)
Return path of url.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that returns whether VAT must be recoverable collected VAT (e.g.: VAT NPR in France)
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dol_htmloutput_events($disabledoutputofmessages=0)
Print formatted messages to output (Used to show messages on html output).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
getDictionaryValue($tablename, $field, $id, $checkentity=false, $rowidfield='rowid')
Return the value of a filed into a dictionary for the record $id.
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular VAT rate, when selling a product with vat $vatrate,...
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.