35 require
'../../main.inc.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
39 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
45 if (!empty($conf->product->enabled)) {
46 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
49 if (!empty($conf->projet->enabled)) {
50 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
54 if (!empty($conf->variants->enabled)) {
55 require_once DOL_DOCUMENT_ROOT.
'/variants/class/ProductCombination.class.php';
57 if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
60 $langs->loadLangs(array(
'bills',
'compta',
'suppliers',
'companies',
'products',
'banks',
'admin'));
61 if (!empty($conf->incoterm->enabled)) $langs->load(
'incoterm');
64 $socid =
GETPOST(
'socid',
'int');
65 $action =
GETPOST(
'action',
'aZ09');
68 $cancel =
GETPOST(
'cancel',
'alpha');
69 $lineid =
GETPOST(
'lineid',
'int');
70 $projectid =
GETPOST(
'projectid',
'int');
71 $origin =
GETPOST(
'origin',
'alpha');
72 $originid =
GETPOST(
'originid',
'int');
75 $hidedetails = (
GETPOST(
'hidedetails',
'int') ?
GETPOST(
'hidedetails',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
76 $hidedesc = (
GETPOST(
'hidedesc',
'int') ?
GETPOST(
'hidedesc',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
77 $hideref = (
GETPOST(
'hideref',
'int') ?
GETPOST(
'hideref',
'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
80 $hookmanager->initHooks(array(
'invoicesuppliercard',
'globalcard'));
86 $extrafields->fetch_name_optionals_label($object->table_element);
89 if ($id > 0 || !empty($ref))
91 $ret = $object->fetch($id, $ref);
93 $ret = $object->fetch_thirdparty();
99 if (!empty($user->socid)) $socid = $user->socid;
101 $result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture',
'fk_soc',
'rowid', $isdraft);
104 $usercanread = $user->rights->fournisseur->facture->lire;
105 $usercancreate = $user->rights->fournisseur->facture->creer;
106 $usercandelete = $user->rights->fournisseur->facture->supprimer;
109 $usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate)));
110 $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->fournisseur->supplier_invoice_advance->send);
113 $permissionnote = $usercancreate;
114 $permissiondellink = $usercancreate;
115 $permissiontoedit = $usercancreate;
116 $permissiontoadd = $usercancreate;
125 $parameters = array(
'socid'=>$socid);
126 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
127 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
133 if (!empty($backtopage))
135 header(
"Location: ".$backtopage);
141 include DOL_DOCUMENT_ROOT.
'/core/actions_setnotes.inc.php';
143 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
145 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
148 if (
GETPOST(
'linkedOrder') && empty($cancel) && $id > 0)
151 $object->fetch_thirdparty();
152 $result = $object->add_object_linked(
'order_supplier',
GETPOST(
'linkedOrder'));
156 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $permissiontoadd)
160 if (
GETPOST(
'newsupplierref',
'alphanohtml')) $objectutil->ref_supplier =
GETPOST(
'newsupplierref',
'alphanohtml');
163 $result = $objectutil->createFromClone($user, $id);
166 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
'?id='.$result);
169 $langs->load(
"errors");
173 } elseif ($action ==
'confirm_valid' && $confirm ==
'yes' && $usercanvalidate) {
174 $idwarehouse =
GETPOST(
'idwarehouse');
177 $object->fetch_thirdparty();
179 $qualified_for_stock_change = 0;
180 if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
182 $qualified_for_stock_change = $object->hasProductsOrServices(2);
184 $qualified_for_stock_change = $object->hasProductsOrServices(1);
188 if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) {
189 $langs->load(
"stocks");
190 if (!$idwarehouse || $idwarehouse == -1)
193 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")), null,
'errors');
199 $result = $object->validate($user,
'', $idwarehouse);
204 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
206 $outputlangs = $langs;
208 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) $newlang =
GETPOST(
'lang_id',
'aZ09');
209 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
210 if (!empty($newlang)) {
212 $outputlangs->setDefaultLang($newlang);
214 $model = $object->model_pdf;
215 $ret = $object->fetch($id);
217 $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
222 } elseif ($action ==
'confirm_delete' && $confirm ==
'yes') {
224 $object->fetch_thirdparty();
226 $isErasable = $object->is_erasable();
228 if (($usercandelete && $isErasable > 0) || ($usercancreate && $isErasable == 1))
230 $result = $object->delete($user);
233 header(
'Location: list.php?restore_lastsearch_values=1');
242 elseif ($action ==
'confirm_deleteline' && $confirm ==
'yes' && $usercancreate)
244 $result = $object->deleteline($lineid);
263 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
273 elseif ($action ==
'unlinkdiscount' && $usercancreate)
276 $result = $discount->fetch(
GETPOST(
"discountid"));
277 $discount->unlink_invoice();
278 } elseif ($action ==
'confirm_paid' && $confirm ==
'yes' && $usercancreate) {
280 $result = $object->set_paid($user);
287 if ($action ==
'setref_supplier' && $usercancreate) {
288 $object->ref_supplier =
GETPOST(
'ref_supplier',
'alpha');
290 if ($object->update($user) < 0) {
294 $outputlangs = $langs;
296 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) {
297 $newlang =
GETPOST(
'lang_id',
'aZ09');
299 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
300 $newlang = $object->thirdparty->default_lang;
302 if (!empty($newlang)) {
304 $outputlangs->setDefaultLang($newlang);
306 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
307 $ret = $object->fetch($object->id);
308 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
314 if ($action ==
'setconditions' && $usercancreate) {
316 $object->cond_reglement_code = 0;
317 $object->cond_reglement_id = 0;
324 $result = $object->setPaymentTerms(
GETPOST(
'cond_reglement_id',
'int'));
332 $old_date_echeance = $object->date_echeance;
333 $new_date_echeance = $object->calculate_date_lim_reglement();
334 if ($new_date_echeance > $old_date_echeance) $object->date_echeance = $new_date_echeance;
335 if ($object->date_echeance < $object->date) $object->date_echeance = $object->date;
336 $result = $object->update($user);
351 elseif ($action ==
'set_incoterms' && !empty($conf->incoterm->enabled))
353 $result = $object->setIncoterms(
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
357 elseif ($action ==
'setmode' && $usercancreate)
359 $result = $object->setPaymentMethods(
GETPOST(
'mode_reglement_id',
'int'));
363 elseif ($action ==
'setmulticurrencycode' && $usercancreate) {
364 $result = $object->setMulticurrencyCode(
GETPOST(
'multicurrency_code',
'alpha'));
368 elseif ($action ==
'setmulticurrencyrate' && $usercancreate) {
369 $result = $object->setMulticurrencyRate(
price2num(
GETPOST(
'multicurrency_tx',
'alpha')),
GETPOST(
'calculation_mode',
'int'));
373 elseif ($action ==
'setbankaccount' && $usercancreate) {
374 $result = $object->setBankAccount(
GETPOST(
'fk_account',
'int'));
378 if ($action ==
'settransportmode' && $user->rights->fournisseur->facture->creer)
380 $result = $object->setTransportMode(
GETPOST(
'transport_mode_id',
'int'));
384 elseif ($action ==
'setlabel' && $usercancreate)
387 $object->label =
GETPOST(
'label');
388 $result = $object->update($user);
390 } elseif ($action ==
'setdatef' && $usercancreate) {
391 $newdate =
dol_mktime(0, 0, 0, $_POST[
'datefmonth'], $_POST[
'datefday'], $_POST[
'datefyear']);
392 if ($newdate > (
dol_now() + (empty($conf->global->INVOICE_MAX_OFFSET_IN_FUTURE) ? 0 : $conf->global->INVOICE_MAX_OFFSET_IN_FUTURE)))
394 if (empty($conf->global->INVOICE_MAX_OFFSET_IN_FUTURE))
setEventMessages($langs->trans(
"WarningInvoiceDateInFuture"), null,
'warnings');
395 else setEventMessages($langs->trans(
"WarningInvoiceDateTooFarInFuture"), null,
'warnings');
400 $object->date = $newdate;
401 $date_echence_calc = $object->calculate_date_lim_reglement();
402 if (!empty($object->date_echeance) && $object->date_echeance < $date_echence_calc)
404 $object->date_echeance = $date_echence_calc;
406 if ($object->date_echeance && $object->date_echeance < $object->date)
408 $object->date_echeance = $object->date;
411 $result = $object->update($user);
413 } elseif ($action ==
'setdate_lim_reglement' && $usercancreate) {
415 $object->date_echeance =
dol_mktime(12, 0, 0, $_POST[
'date_lim_reglementmonth'], $_POST[
'date_lim_reglementday'], $_POST[
'date_lim_reglementyear']);
416 if (!empty($object->date_echeance) && $object->date_echeance < $object->date)
418 $object->date_echeance = $object->date;
419 setEventMessages($langs->trans(
"DatePaymentTermCantBeLowerThanObjectDate"), null,
'warnings');
421 $result = $object->update($user);
423 } elseif ($action ==
"setabsolutediscount" && $usercancreate)
428 if (!empty($_POST[
"remise_id"])) {
429 $ret = $object->fetch($id);
431 $result = $object->insert_discount($_POST[
"remise_id"]);
440 if (!empty($_POST[
"remise_id_for_payment"]))
442 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
444 $discount->fetch($_POST[
"remise_id_for_payment"]);
452 setEventMessages($langs->trans(
"ErrorDiscountLargerThanRemainToPaySplitItBefore"), null,
'errors');
457 $result = $discount->link_to_invoice(0, $id);
464 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
466 $outputlangs = $langs;
468 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) $newlang =
GETPOST(
'lang_id',
'aZ09');
469 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
470 if (!empty($newlang)) {
472 $outputlangs->setDefaultLang($newlang);
474 $ret = $object->fetch($id);
476 $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
477 if ($result < 0)
setEventMessages($object->error, $object->errors,
'errors');
481 elseif ($action ==
'confirm_converttoreduc' && $confirm ==
'yes' && $usercancreate)
484 $object->fetch_thirdparty();
489 $result = $discountcheck->fetch(0, 0, $object->id);
498 $amount_ht = $amount_tva = $amount_ttc = array();
499 $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array();
503 foreach ($object->lines as $line)
505 if ($line->product_type < 9 && $line->total_ht != 0)
507 $amount_ht[$line->tva_tx] += $line->total_ht;
508 $amount_tva[$line->tva_tx] += $line->total_tva;
509 $amount_ttc[$line->tva_tx] += $line->total_ttc;
515 if (!empty($conf->global->SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED)) {
516 $alreadypaid = $object->getSommePaiement();
517 if ($alreadypaid && abs($alreadypaid) < abs($object->total_ttc)) {
518 $ratio = abs(($object->total_ttc - $alreadypaid) / $object->total_ttc);
519 foreach ($amount_ht as $vatrate => $val) {
520 $amount_ht[$vatrate] =
price2num($amount_ht[$vatrate] * $ratio,
'MU');
521 $amount_tva[$vatrate] =
price2num($amount_tva[$vatrate] * $ratio,
'MU');
522 $amount_ttc[$vatrate] =
price2num($amount_ttc[$vatrate] * $ratio,
'MU');
531 $discount->description =
'(CREDIT_NOTE)';
537 setEventMessages($langs->trans(
'CantConvertToReducAnInvoiceOfThisType'), null,
'errors');
539 $discount->discount_type = 1;
540 $discount->fk_soc = $object->socid;
541 $discount->fk_invoice_supplier_source = $object->id;
550 $sql =
'SELECT SUM(pf.amount) as total_paiements';
551 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.
'paiementfourn as p';
552 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id AND c.entity IN ('.
getEntity(
'c_paiement').
')';
553 $sql .=
' WHERE pf.fk_facturefourn = '.$object->id;
554 $sql .=
' AND pf.fk_paiementfourn = p.rowid';
555 $sql .=
' AND p.entity IN ('.getEntity(
'invoice').
')';
557 $resql = $db->query($sql);
560 $res = $db->fetch_object(
$resql);
561 $total_paiements = $res->total_paiements;
564 $total_creditnote_and_deposit = 0;
565 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
566 $sql .=
" re.description, re.fk_invoice_supplier_source";
567 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
568 $sql .=
" WHERE fk_invoice_supplier = ".$object->id;
569 $resql = $db->query($sql);
571 while ($obj = $db->fetch_object(
$resql)) {
572 $total_creditnote_and_deposit += $obj->amount_ttc;
576 $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $object->total_ttc;
577 $discount->amount_tva = 0;
578 $discount->tva_tx = 0;
580 $result = $discount->create($user);
588 foreach ($amount_ht as $tva_tx => $xxx)
590 $discount->amount_ht = abs($amount_ht[$tva_tx]);
591 $discount->amount_tva = abs($amount_tva[$tva_tx]);
592 $discount->amount_ttc = abs($amount_ttc[$tva_tx]);
593 $discount->tva_tx = abs($tva_tx);
595 $result = $discount->create($user);
608 $result = $object->set_paid($user);
628 elseif ($action ==
'confirm_delete_paiement' && $confirm ==
'yes' && $usercancreate)
634 $result = $paiementfourn->fetch(
GETPOST(
'paiement_id'));
636 $result = $paiementfourn->delete();
637 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$id);
646 elseif ($action ==
'add' && $usercancreate)
648 if ($socid > 0) $object->socid =
GETPOST(
'socid',
'int');
655 $ret = $extrafields->setOptionalsFromPost(null, $object);
656 if ($ret < 0) $error++;
664 if ($datefacture ==
'')
666 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')), null,
'errors');
668 $_GET[
'socid'] = $_POST[
'socid'];
671 if (!(
GETPOST(
'fac_replacement',
'int') > 0)) {
673 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ReplaceInvoice")), null,
'errors');
678 $result = $object->fetch(
GETPOST(
'fac_replacement',
'int'));
679 $object->fetch_thirdparty();
681 $object->ref =
GETPOST(
'ref',
'nohtml');
682 $object->ref_supplier =
GETPOST(
'ref_supplier',
'alpha');
683 $object->socid =
GETPOST(
'socid',
'int');
684 $object->libelle =
GETPOST(
'label',
'nohtml');
685 $object->date = $datefacture;
686 $object->date_echeance = $datedue;
687 $object->note_public =
GETPOST(
'note_public',
'restricthtml');
688 $object->note_private =
GETPOST(
'note_private',
'restricthtml');
689 $object->cond_reglement_id =
GETPOST(
'cond_reglement_id');
690 $object->mode_reglement_id =
GETPOST(
'mode_reglement_id');
691 $object->fk_account =
GETPOST(
'fk_account',
'int');
692 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
693 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
694 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
695 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
696 $object->multicurrency_tx =
GETPOST(
'originmulticurrency_tx',
'int');
697 $object->transport_mode_id =
GETPOST(
'transport_mode_id',
'int');
700 $object->fk_facture_source =
GETPOST(
'fac_replacement');
703 $id = $object->createFromCurrent($user);
714 $sourceinvoice =
GETPOST(
'fac_avoir',
'int');
715 if (!($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE))
718 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"CorrectInvoice")), null,
'errors');
720 if (
GETPOST(
'socid',
'int') < 1)
722 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Supplier')), null,
'errors');
726 if ($datefacture ==
'')
728 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')), null,
'errors');
730 $_GET[
'socid'] = $_POST[
'socid'];
735 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'RefSupplier')), null,
'errors');
737 $_GET[
'socid'] = $_POST[
'socid'];
743 $tmpproject =
GETPOST(
'projectid',
'int');
746 $object->ref =
GETPOST(
'ref',
'nohtml');
747 $object->ref_supplier =
GETPOST(
'ref_supplier',
'nohtml');
748 $object->socid =
GETPOST(
'socid',
'int');
749 $object->libelle =
GETPOST(
'label',
'nohtml');
750 $object->label =
GETPOST(
'label',
'nohtml');
751 $object->date = $datefacture;
752 $object->date_echeance = $datedue;
753 $object->note_public =
GETPOST(
'note_public',
'restricthtml');
754 $object->note_private =
GETPOST(
'note_private',
'restricthtml');
755 $object->cond_reglement_id =
GETPOST(
'cond_reglement_id');
756 $object->mode_reglement_id =
GETPOST(
'mode_reglement_id');
757 $object->fk_account =
GETPOST(
'fk_account',
'int');
758 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
759 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
760 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
761 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
762 $object->multicurrency_tx =
GETPOST(
'originmulticurrency_tx',
'int');
763 $object->transport_mode_id =
GETPOST(
'transport_mode_id',
'int');
766 $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice :
'';
769 $id = $object->create($user);
775 if (
GETPOST(
'invoiceAvoirWithLines',
'int') == 1 && $id > 0)
778 if ($facture_source->fetch($object->fk_facture_source) > 0)
782 foreach ($facture_source->lines as $line)
785 if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
789 $line->fk_facture_fourn = $object->id;
790 $line->fk_parent_line = $fk_parent_line;
792 $line->subprice = -$line->subprice;
793 $line->pa_ht = -$line->pa_ht;
794 $line->total_ht = -$line->total_ht;
795 $line->total_tva = -$line->total_tva;
796 $line->total_ttc = -$line->total_ttc;
797 $line->total_localtax1 = -$line->total_localtax1;
798 $line->total_localtax2 = -$line->total_localtax2;
800 $result = $line->insert();
802 $object->lines[] = $line;
805 if ($result > 0 && $line->product_type == 9) {
806 $fk_parent_line = $result;
810 $object->update_price(1);
814 if (
GETPOST(
'invoiceAvoirWithPaymentRestAmount',
'int') == 1 && $id > 0)
817 if ($facture_source->fetch($object->fk_facture_source) > 0)
819 $totalpaye = $facture_source->getSommePaiement();
820 $totalcreditnotes = $facture_source->getSumCreditNotesUsed();
821 $totaldeposits = $facture_source->getSumDepositsUsed();
822 $remain_to_pay = abs($facture_source->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits);
824 $object->addline($langs->trans(
'invoiceAvoirLineWithPaymentRestAmount'), $remain_to_pay, 0, 0, 0, 1, 0, 0,
'',
'',
'TTC');
833 if (
GETPOST(
'socid',
'int') < 1)
835 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Supplier')), null,
'errors');
840 if ($datefacture ==
'')
842 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'DateInvoice')), null,
'errors');
844 $_GET[
'socid'] = $_POST[
'socid'];
849 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'RefSupplier')), null,
'errors');
851 $_GET[
'socid'] = $_POST[
'socid'];
857 $tmpproject =
GETPOST(
'projectid',
'int');
860 $object->ref =
GETPOST(
'ref',
'nohtml');
861 $object->ref_supplier =
GETPOST(
'ref_supplier',
'nohtml');
862 $object->socid =
GETPOST(
'socid',
'int');
863 $object->libelle =
GETPOST(
'label',
'nohtml');
864 $object->date = $datefacture;
865 $object->date_echeance = $datedue;
866 $object->note_public =
GETPOST(
'note_public',
'restricthtml');
867 $object->note_private =
GETPOST(
'note_private',
'restricthtml');
868 $object->cond_reglement_id =
GETPOST(
'cond_reglement_id');
869 $object->mode_reglement_id =
GETPOST(
'mode_reglement_id');
870 $object->fk_account =
GETPOST(
'fk_account',
'int');
871 $object->fk_project = ($tmpproject > 0) ? $tmpproject : null;
872 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
873 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
874 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
875 $object->multicurrency_tx =
GETPOST(
'originmulticurrency_tx',
'int');
876 $object->transport_mode_id =
GETPOST(
'transport_mode_id');
879 if (empty($object->date_echeance)) $object->date_echeance = $object->calculate_date_lim_reglement();
881 $object->fetch_thirdparty();
887 $element = $subelement =
GETPOST(
'origin',
'alpha');
895 if ($element ==
'order') {
896 $element = $subelement =
'commande';
898 if ($element ==
'propal') {
899 $element =
'comm/propal'; $subelement =
'propal';
901 if ($element ==
'contract') {
902 $element = $subelement =
'contrat';
904 if ($element ==
'order_supplier') {
905 $element =
'fourn'; $subelement =
'fournisseur.commande';
907 if ($element ==
'project')
911 $object->origin =
GETPOST(
'origin',
'alpha');
912 $object->origin_id =
GETPOST(
'originid',
'int');
915 require_once DOL_DOCUMENT_ROOT.
'/'.$element.
'/class/'.$subelement.
'.class.php';
916 $classname = ucfirst($subelement);
917 if ($classname ==
'Fournisseur.commande') $classname =
'CommandeFournisseur';
918 $objectsrc =
new $classname($db);
919 $objectsrc->fetch($originid);
920 $objectsrc->fetch_thirdparty();
922 if (!empty($object->origin) && !empty($object->origin_id))
924 $object->linkedObjectsIds[$object->origin] = $object->origin_id;
928 if ($object->origin ==
'reception')
930 $objectsrc->fetchObjectLinked();
932 if (count($objectsrc->linkedObjectsIds[
'order_supplier']) > 0)
934 foreach ($objectsrc->linkedObjectsIds[
'order_supplier'] as $key => $value)
936 $object->linkedObjectsIds[
'order_supplier'] = $value;
941 $id = $object->create($user);
946 require_once DOL_DOCUMENT_ROOT.
'/'.$element.
'/class/'.$subelement.
'.class.php';
947 $classname = ucfirst($subelement);
948 if ($classname ==
'Fournisseur.commande') $classname =
'CommandeFournisseur';
949 $srcobject =
new $classname($db);
951 $result = $srcobject->fetch(
GETPOST(
'originid',
'int'));
954 $lines = $srcobject->lines;
955 if (empty($lines) && method_exists($srcobject,
'fetch_lines'))
957 $srcobject->fetch_lines();
958 $lines = $srcobject->lines;
961 $num = count($lines);
962 for ($i = 0; $i < $num; $i++)
964 $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
965 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
968 if (method_exists($lines[$i],
'fetch_optionals')) {
969 $lines[$i]->fetch_optionals();
974 $date_start = $lines[$i]->date_debut_prevue;
975 if ($lines[$i]->date_debut_reel) $date_start = $lines[$i]->date_debut_reel;
976 if ($lines[$i]->date_start) $date_start = $lines[$i]->date_start;
977 $date_end = $lines[$i]->date_fin_prevue;
978 if ($lines[$i]->date_fin_reel) $date_end = $lines[$i]->date_fin_reel;
979 if ($lines[$i]->date_end) $date_end = $lines[$i]->date_end;
982 $object->special_code = $lines[$i]->special_code;
985 if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1)
988 $pu_currency = $lines[$i]->multicurrency_subprice;
990 $pu = $lines[$i]->subprice;
995 $result = $object->addline(
999 $lines[$i]->localtax1_tx,
1000 $lines[$i]->localtax2_tx,
1002 $lines[$i]->fk_product,
1003 $lines[$i]->remise_percent,
1007 $lines[$i]->info_bits,
1012 $lines[$i]->array_options,
1013 $lines[$i]->fk_unit,
1016 $lines[$i]->ref_supplier,
1017 $lines[$i]->special_code
1028 $object->fetch_lines();
1037 $id = $object->create($user);
1048 $langs->load(
"errors");
1053 $_GET[
'socid'] = $_POST[
'socid'];
1057 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
1058 $outputlangs = $langs;
1059 $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
1067 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$id);
1073 elseif ($action ==
'updateline' && $usercancreate)
1077 $object->fetch($id);
1078 $object->fetch_thirdparty();
1082 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'multicurrency_subprice') !=
'') {
1084 $price_base_type =
'HT';
1087 $price_base_type =
'TTC';
1093 if (!empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY))
1097 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"), null,
'warnings');
1102 $prod->fetch(
GETPOST(
'productid'));
1103 $label = $prod->description;
1104 if (trim($_POST[
'product_desc']) != trim($label)) $label = $_POST[
'product_desc'];
1106 $type = $prod->type;
1108 $label = $_POST[
'product_desc'];
1109 $type = $_POST[
"type"] ? $_POST[
"type"] : 0;
1117 if (preg_match(
'/\*/', $tva_tx))
1121 $tva_tx = str_replace(
'*',
'', $tva_tx);
1122 $localtax1_tx =
get_localtax($tva_tx, 1, $mysoc, $object->thirdparty);
1123 $localtax2_tx =
get_localtax($tva_tx, 2, $mysoc, $object->thirdparty);
1125 $remise_percent =
GETPOST(
'remise_percent');
1126 $pu_ht_devise =
GETPOST(
'multicurrency_subprice');
1129 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
1130 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
1132 if (is_array($extralabelsline)) {
1133 foreach ($extralabelsline as $key => $value) {
1134 unset($_POST[
"options_".$key]);
1138 $result = $object->updateline(
GETPOST(
'lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx,
GETPOST(
'qty'),
GETPOST(
'productid'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST[
'units'], $pu_ht_devise,
GETPOST(
'fourn_ref',
'alpha'));
1141 unset($_POST[
'label']);
1142 unset($_POST[
'fourn_ref']);
1143 unset($_POST[
'date_starthour']);
1144 unset($_POST[
'date_startmin']);
1145 unset($_POST[
'date_startsec']);
1146 unset($_POST[
'date_startday']);
1147 unset($_POST[
'date_startmonth']);
1148 unset($_POST[
'date_startyear']);
1149 unset($_POST[
'date_endhour']);
1150 unset($_POST[
'date_endmin']);
1151 unset($_POST[
'date_endsec']);
1152 unset($_POST[
'date_endday']);
1153 unset($_POST[
'date_endmonth']);
1154 unset($_POST[
'date_endyear']);
1161 } elseif ($action ==
'addline' && $usercancreate) {
1164 $ret = $object->fetch($id);
1170 $ret = $object->fetch_thirdparty();
1172 $langs->load(
'errors');
1181 $prod_entry_mode =
GETPOST(
'prod_entry_mode');
1182 if ($prod_entry_mode ==
'free')
1188 $idprod =
GETPOST(
'idprod',
'int');
1194 $remise_percent =
GETPOST(
'remise_percent'.$predef);
1198 $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
1199 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
1201 if (is_array($extralabelsline)) {
1203 foreach ($extralabelsline as $key => $value) {
1204 unset($_POST[
"options_".$key]);
1208 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') < 0 && $qty < 0)
1210 setEventMessages($langs->trans(
'ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv(
'UnitPrice'), $langs->transnoentitiesnoconv(
'Qty')), null,
'errors');
1213 if ($prod_entry_mode ==
'free' && !
GETPOST(
'idprodfournprice') &&
GETPOST(
'type') < 0)
1215 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Type')), null,
'errors');
1218 if ($prod_entry_mode ==
'free' &&
GETPOST(
'price_ht') ===
'' &&
GETPOST(
'price_ttc') ===
'' && $price_ht_devise ===
'')
1220 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'UnitPrice')), null,
'errors');
1223 if ($prod_entry_mode ==
'free' && !
GETPOST(
'dp_desc'))
1225 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Description')), null,
'errors');
1230 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Qty')), null,
'errors');
1234 if (!$error && !empty($conf->variants->enabled) && $prod_entry_mode !=
'free') {
1235 if ($combinations =
GETPOST(
'combinations',
'array')) {
1239 if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
1240 $idprod = $res->fk_product_child;
1242 setEventMessages($langs->trans(
'ErrorProductCombinationNotFound'), null,
'errors');
1248 if ($prod_entry_mode !=
'free' && empty($error))
1253 if (
GETPOST(
'idprodfournprice',
'alpha') == -1 ||
GETPOST(
'idprodfournprice',
'alpha') ==
'') $idprod = -99;
1256 if (preg_match(
'/^idprod_([0-9]+)$/',
GETPOST(
'idprodfournprice',
'alpha'), $reg))
1259 $res = $productsupplier->fetch($idprod);
1262 if (!empty($conf->global->SUPPLIER_TAKE_FIRST_PRICE_IF_NO_PRICE_FOR_CURRENT_SUPPLIER))
1265 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1266 if ($productsupplier->fourn_socid != $socid)
1268 $productsupplier->ref_supplier =
'';
1271 $fksoctosearch = $object->thirdparty->id;
1272 $productsupplier->get_buyprice(0, -1, $idprod,
'none', $fksoctosearch);
1274 } elseif (
GETPOST(
'idprodfournprice',
'alpha') > 0)
1276 $qtytosearch = $qty;
1278 $idprod = $productsupplier->get_buyprice(
GETPOST(
'idprodfournprice',
'alpha'), $qtytosearch);
1279 $res = $productsupplier->fetch($idprod);
1284 $label = $productsupplier->label;
1287 if (!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) {
1288 $desc = $productsupplier->desc_supplier;
1289 }
else $desc = $productsupplier->description;
1291 if (trim($product_desc) != trim($desc)) $desc =
dol_concatdesc($desc, $product_desc,
'', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));
1293 $type = $productsupplier->type;
1294 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'price_ht_devise') !=
'') {
1295 $price_base_type =
'HT';
1297 $pu_ht_devise =
price2num($price_ht_devise,
'CU');
1299 $price_base_type = ($productsupplier->fourn_price_base_type ? $productsupplier->fourn_price_base_type :
'HT');
1300 if (empty($object->multicurrency_code) || ($productsupplier->fourn_multicurrency_code != $object->multicurrency_code)) {
1301 $pu = $productsupplier->fourn_pu;
1304 $pu = $productsupplier->fourn_pu;
1305 $pu_ht_devise = $productsupplier->fourn_multicurrency_unitprice;
1309 $ref_supplier = $productsupplier->ref_supplier;
1311 $tva_tx =
get_default_tva($object->thirdparty, $mysoc, $productsupplier->id,
GETPOST(
'idprodfournprice',
'alpha'));
1312 $tva_npr =
get_default_npr($object->thirdparty, $mysoc, $productsupplier->id,
GETPOST(
'idprodfournprice',
'alpha'));
1313 if (empty($tva_tx)) $tva_npr = 0;
1314 $localtax1_tx =
get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr);
1315 $localtax2_tx =
get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr);
1317 if (empty($pu)) $pu = 0;
1319 $result = $object->addline(
1337 $productsupplier->fk_unit,
1344 if ($idprod == -99 || $idprod == 0)
1348 $langs->load(
"errors");
1349 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProductOrService")), null,
'errors');
1355 $langs->load(
"errors");
1356 setEventMessages($langs->trans(
"ErrorQtyTooLowForThisSupplier"), null,
'errors');
1358 } elseif (empty($error))
1360 $tva_npr = (preg_match(
'/\*/', $tva_tx) ? 1 : 0);
1361 $tva_tx = str_replace(
'*',
'', $tva_tx);
1362 $label = (
GETPOST(
'product_label') ?
GETPOST(
'product_label') :
'');
1363 $desc = $product_desc;
1365 $ref_supplier =
GETPOST(
'fourn_ref',
'alpha');
1367 $fk_unit =
GETPOST(
'units',
'alpha');
1369 if (!preg_match(
'/\((.*)\)/', $tva_tx)) {
1374 $localtax1_tx =
get_localtax($tva_tx, 1, $mysoc, $object->thirdparty);
1375 $localtax2_tx =
get_localtax($tva_tx, 2, $mysoc, $object->thirdparty);
1377 if (
GETPOST(
'price_ht') !=
'' ||
GETPOST(
'price_ht_devise') !=
'') {
1381 $pu_ht =
price2num($pu_ttc / (1 + ($tva_tx / 100)),
'MU');
1383 $price_base_type =
'HT';
1384 $pu_ht_devise =
price2num($price_ht_devise,
'CU');
1386 $result = $object->addline($product_desc, $pu_ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit, 0, $pu_ht_devise, $ref_supplier);
1390 if (!$error && $result > 0)
1395 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
1397 $outputlangs = $langs;
1399 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) $newlang =
GETPOST(
'lang_id',
'aZ09');
1400 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
1401 if (!empty($newlang)) {
1402 $outputlangs =
new Translate(
"", $conf);
1403 $outputlangs->setDefaultLang($newlang);
1405 $model = $object->model_pdf;
1406 $ret = $object->fetch($id);
1408 $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1412 unset($_POST [
'prod_entry_mode']);
1414 unset($_POST[
'qty']);
1415 unset($_POST[
'type']);
1416 unset($_POST[
'remise_percent']);
1417 unset($_POST[
'pu']);
1418 unset($_POST[
'price_ht']);
1419 unset($_POST[
'multicurrency_price_ht']);
1420 unset($_POST[
'price_ttc']);
1421 unset($_POST[
'fourn_ref']);
1422 unset($_POST[
'tva_tx']);
1423 unset($_POST[
'label']);
1424 unset($localtax1_tx);
1425 unset($localtax2_tx);
1426 unset($_POST[
'np_marginRate']);
1427 unset($_POST[
'np_markRate']);
1428 unset($_POST[
'dp_desc']);
1429 unset($_POST[
'idprodfournprice']);
1430 unset($_POST[
'units']);
1432 unset($_POST[
'date_starthour']);
1433 unset($_POST[
'date_startmin']);
1434 unset($_POST[
'date_startsec']);
1435 unset($_POST[
'date_startday']);
1436 unset($_POST[
'date_startmonth']);
1437 unset($_POST[
'date_startyear']);
1438 unset($_POST[
'date_endhour']);
1439 unset($_POST[
'date_endmin']);
1440 unset($_POST[
'date_endsec']);
1441 unset($_POST[
'date_endday']);
1442 unset($_POST[
'date_endmonth']);
1443 unset($_POST[
'date_endyear']);
1450 } elseif ($action ==
'classin' && $usercancreate) {
1451 $object->fetch($id);
1452 $result = $object->setProject($projectid);
1457 elseif ($action ==
'confirm_edit' && $confirm ==
'yes' && $usercancreate)
1459 $object->fetch($id);
1461 $totalpaye = $object->getSommePaiement();
1462 $resteapayer = $object->total_ttc - $totalpaye;
1465 $ventilExportCompta = $object->getVentilExportCompta();
1467 if (!$ventilExportCompta)
1472 $idwarehouse =
GETPOST(
'idwarehouse');
1474 $object->fetch_thirdparty();
1476 $qualified_for_stock_change = 0;
1477 if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
1479 $qualified_for_stock_change = $object->hasProductsOrServices(2);
1481 $qualified_for_stock_change = $object->hasProductsOrServices(1);
1485 if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change)
1487 $langs->load(
"stocks");
1488 if (!$idwarehouse || $idwarehouse == -1)
1491 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
"Warehouse")), null,
'errors');
1496 $object->setDraft($user, $idwarehouse);
1499 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
1501 $outputlangs = $langs;
1503 if ($conf->global->MAIN_MULTILANGS && empty($newlang) &&
GETPOST(
'lang_id',
'aZ09')) $newlang =
GETPOST(
'lang_id',
'aZ09');
1504 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
1505 if (!empty($newlang)) {
1506 $outputlangs =
new Translate(
"", $conf);
1507 $outputlangs->setDefaultLang($newlang);
1509 $model = $object->model_pdf;
1510 $ret = $object->fetch($id);
1512 $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
1522 elseif ($action ==
'reopen' && $usercancreate)
1524 $result = $object->fetch($id);
1528 $result = $object->set_unpaid($user);
1531 header(
'Location: '.
$_SERVER[
"PHP_SELF"].
'?id='.$id);
1540 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1543 $triggersendname =
'BILL_SUPPLIER_SENTBYMAIL';
1545 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
1546 $trackid =
'sinv'.$object->id;
1547 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1550 $upload_dir = $conf->fournisseur->facture->dir_output;
1551 $permissiontoadd = $usercancreate;
1552 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1555 if ($action ==
'calculate')
1557 $calculationrule =
GETPOST(
'calculationrule');
1559 $object->fetch($id);
1560 $object->fetch_thirdparty();
1561 $result = $object->update_price(0, (($calculationrule ==
'totalofround') ?
'0' :
'1'), 0, $object->thirdparty);
1568 if ($action ==
'update_extras')
1573 $ret = $extrafields->setOptionalsFromPost(null, $object,
GETPOST(
'attribute',
'restricthtml'));
1574 if ($ret < 0) $error++;
1581 $result = $object->insertExtraFields(
'BILL_SUPPLIER_MODIFY');
1590 $action =
'edit_extras';
1593 if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate)
1595 if ($action ==
'addcontact')
1597 $result = $object->fetch($id);
1599 if ($result > 0 && $id > 0)
1603 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
1608 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
1611 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS')
1613 $langs->load(
"errors");
1614 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"), null,
'errors');
1622 elseif ($action ==
'swapstatut')
1624 if ($object->fetch($id))
1626 $result = $object->swapContactStatus(
GETPOST(
'ligne'));
1633 elseif ($action ==
'deletecontact')
1635 $object->fetch($id);
1636 $result = $object->delete_contact($_GET[
"lineid"]);
1640 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
1654 $form =
new Form($db);
1656 $bankaccountstatic =
new Account($db);
1658 if (!empty($conf->projet->enabled)) { $formproject =
new FormProjets($db); }
1662 $title = $langs->trans(
'SupplierInvoice').
" - ".$langs->trans(
'Card');
1663 $helpurl =
"EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores";
1667 if ($action ==
'create')
1675 $currency_code = $conf->currency;
1680 $societe->fetch(
GETPOST(
'socid',
'int'));
1681 if (!empty($conf->multicurrency->enabled) && !empty($societe->multicurrency_code)) $currency_code = $societe->multicurrency_code;
1684 if (!empty($origin) && !empty($originid)) {
1686 $element = $subelement = $origin;
1688 if ($element ==
'project') {
1689 $projectid = $originid;
1690 $element =
'projet';
1694 if ($element ==
'order') {
1695 $element = $subelement =
'commande';
1697 if ($element ==
'propal') {
1698 $element =
'comm/propal'; $subelement =
'propal';
1700 if ($element ==
'contract') {
1701 $element = $subelement =
'contrat';
1703 if ($element ==
'order_supplier') {
1704 $element =
'fourn'; $subelement =
'fournisseur.commande';
1707 require_once DOL_DOCUMENT_ROOT.
'/'.$element.
'/class/'.$subelement.
'.class.php';
1708 $classname = ucfirst($subelement);
1709 if ($classname ==
'Fournisseur.commande') $classname =
'CommandeFournisseur';
1710 $objectsrc =
new $classname($db);
1711 $objectsrc->fetch($originid);
1712 $objectsrc->fetch_thirdparty();
1714 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project :
'');
1717 $soc = $objectsrc->thirdparty;
1718 $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_supplier_id) ? $soc->cond_reglement_supplier_id : 0));
1719 $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_supplier_id) ? $soc->mode_reglement_supplier_id : 0));
1720 $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0));
1721 $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_supplier_percent) ? $soc->remise_supplier_percent : 0));
1722 $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0));
1723 $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 :
'';
1724 $transport_mode_id = (!empty($objectsrc->transport_mode_id) ? $objectsrc->transport_mode_id : (!empty($soc->transport_mode_id) ? $soc->transport_mode_id : 0));
1726 if (!empty($conf->multicurrency->enabled))
1728 if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code;
1729 if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($objectsrc->multicurrency_tx)) $currency_tx = $objectsrc->multicurrency_tx;
1733 $dateinvoice = ($datetmp ==
'' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 :
'') : $datetmp);
1734 $datetmp =
dol_mktime(12, 0, 0, $_POST[
'echmonth'], $_POST[
'echday'], $_POST[
'echyear']);
1735 $datedue = ($datetmp ==
'' ?-1 : $datetmp);
1738 $objectsrc->fetch_optionals();
1739 $object->array_options = $objectsrc->array_options;
1741 $cond_reglement_id = $societe->cond_reglement_supplier_id;
1742 $mode_reglement_id = $societe->mode_reglement_supplier_id;
1743 $transport_mode_id = $societe->transport_mode_supplier_id;
1744 $fk_account = $societe->fk_account;
1746 $dateinvoice = ($datetmp ==
'' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 :
'') : $datetmp);
1747 $datetmp =
dol_mktime(12, 0, 0, $_POST[
'echmonth'], $_POST[
'echday'], $_POST[
'echyear']);
1748 $datedue = ($datetmp ==
'' ?-1 : $datetmp);
1750 if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code;
1754 if (empty($cond_reglement_id)) {
1755 $cond_reglement_id =
GETPOST(
"cond_reglement_id");
1759 if (empty($mode_reglement_id)) {
1760 $mode_reglement_id =
GETPOST(
"mode_reglement_id");
1763 $note_public = $object->getDefaultCreateValueFor(
'note_public', ((!empty($origin) && !empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM)) ? $objectsrc->note_public : null));
1764 $note_private = $object->getDefaultCreateValueFor(
'note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM)) ? $objectsrc->note_private : null));
1766 print '<form name="add" action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
1767 print '<input type="hidden" name="token" value="'.newToken().
'">';
1768 print '<input type="hidden" name="action" value="add">';
1769 if ($societe->id > 0)
print '<input type="hidden" name="socid" value="'.$societe->id.
'">'.
"\n";
1770 print '<input type="hidden" name="origin" value="'.$origin.
'">';
1771 print '<input type="hidden" name="originid" value="'.$originid.
'">';
1772 if (!empty($currency_tx))
print '<input type="hidden" name="originmulticurrency_tx" value="'.$currency_tx.
'">';
1776 print '<table class="border centpercent">';
1779 print '<tr><td class="titlefieldcreate">'.$langs->trans(
'Ref').
'</td><td>'.$langs->trans(
'Draft').
'</td></tr>';
1782 print '<tr><td class="fieldrequired">'.$langs->trans(
'Supplier').
'</td>';
1785 if ($societe->id > 0)
1787 $absolute_discount = $societe->getAvailableDiscounts(
'',
'', 0, 1);
1788 print $societe->getNomUrl(1);
1789 print '<input type="hidden" name="socid" value="'.$societe->id.
'">';
1791 print img_picto(
'',
'company').$form->select_company($societe->id,
'socid',
's.fournisseur=1',
'SelectThirdParty', 0, 0, null, 0,
'minwidth300');
1793 if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE))
1795 print '<script type="text/javascript">
1796 $(document).ready(function() {
1797 $("#socid").change(function() {
1798 var socid = $(this).val();
1800 window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?action=create&socid="+socid;
1805 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>';
1810 print '<tr><td class="fieldrequired">'.$langs->trans(
'RefSupplier').
'</td><td><input name="ref_supplier" value="'.(isset($_POST[
'ref_supplier']) ? $_POST[
'ref_supplier'] : $objectsrc->ref_supplier).
'" type="text"';
1811 if ($societe->id > 0)
print ' autofocus';
1815 print '<tr><td class="tdtop fieldrequired">'.$langs->trans(
'Type').
'</td><td>';
1817 print '<div class="tagtable">'.
"\n";
1820 print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
1821 $tmp =
'<input type="radio" id="radio_standard" name="type" value="0"'.(GETPOST(
'type') == 0 ?
' checked' :
'').
'> ';
1822 $desc = $form->textwithpicto($tmp.$langs->trans(
"InvoiceStandardAsk"), $langs->transnoentities(
"InvoiceStandardDesc"), 1,
'help',
'', 0, 3);
1824 print '</div></div>';
1927 if ($societe->id > 0)
1930 if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE))
1933 $facids = $facturestatic->list_qualified_avoir_supplier_invoices($societe->id);
1941 foreach ($facids as $key => $valarray)
1943 $newinvoice_static->id = $key;
1944 $newinvoice_static->ref = $valarray [
'ref'];
1945 $newinvoice_static->statut = $valarray [
'status'];
1946 $newinvoice_static->type = $valarray [
'type'];
1947 $newinvoice_static->paye = $valarray [
'paye'];
1949 $optionsav .=
'<option value="'.$key.
'"';
1950 if ($key ==
GETPOST(
'fac_avoir',
'int'))
1951 $optionsav .=
' selected';
1953 $optionsav .= $newinvoice_static->ref;
1954 $optionsav .=
' ('.$newinvoice_static->getLibStatut(1, $valarray [
'paymentornot']).
')';
1955 $optionsav .=
'</option>';
1958 print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
1959 $tmp =
'<input type="radio" id="radio_creditnote" name="type" value="2"'.(GETPOST(
'type') == 2 ?
' checked' :
'');
1960 if (!$optionsav) $tmp .=
' disabled';
1963 print '<script type="text/javascript" language="javascript">
1964 jQuery(document).ready(function() {
1965 if (! jQuery("#radio_creditnote").is(":checked"))
1967 jQuery("#credit_note_options").hide();
1969 jQuery("#radio_creditnote").click(function() {
1970 jQuery("#credit_note_options").show();
1972 jQuery("#radio_standard, #radio_replacement, #radio_deposit").click(function() {
1973 jQuery("#credit_note_options").hide();
1977 $text = $tmp.$langs->transnoentities(
"InvoiceAvoirAsk").
' ';
1979 $text .=
'<select class="flat valignmiddle" name="fac_avoir" id="fac_avoir"';
1981 $text .=
' disabled';
1984 $text .=
'<option value="-1"></option>';
1985 $text .= $optionsav;
1987 $text .=
'<option value="-1">'.$langs->trans(
"NoInvoiceToCorrect").
'</option>';
1989 $text .=
'</select>';
1990 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
1993 print '<div id="credit_note_options" class="clearboth">';
1994 print ' <input type="checkbox" name="invoiceAvoirWithLines" id="invoiceAvoirWithLines" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithPaymentRestAmount\').removeAttr(\'checked\'); }" '.(GETPOST(
'invoiceAvoirWithLines',
'int') > 0 ?
'checked' :
'').
' /> ';
1995 print '<label for="invoiceAvoirWithLines">'.$langs->trans(
'invoiceAvoirWithLines').
"</label>";
1996 print '<br> <input type="checkbox" name="invoiceAvoirWithPaymentRestAmount" id="invoiceAvoirWithPaymentRestAmount" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithLines\').removeAttr(\'checked\'); }" '.(GETPOST(
'invoiceAvoirWithPaymentRestAmount',
'int') > 0 ?
'checked' :
'').
' /> ';
1997 print '<label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans(
'invoiceAvoirWithPaymentRestAmount').
"</label>";
2000 print '</div></div>';
2003 print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
2004 $tmp =
'<input type="radio" name="type" id="radio_creditnote" value="0" disabled> ';
2005 $text = $tmp.$langs->trans(
"InvoiceAvoir").
' ';
2006 $text .=
'<span class="opacitymedium">('.$langs->trans(
"YouMustCreateInvoiceFromSupplierThird").
')</span> ';
2007 $desc = $form->textwithpicto($text, $langs->transnoentities(
"InvoiceAvoirDesc"), 1,
'help',
'', 0, 3);
2009 print '</div></div>'.
"\n";
2017 if ($societe->id > 0)
2020 print '<tr><td>'.$langs->trans(
'Discounts').
'</td><td>';
2022 $thirdparty = $societe;
2024 $backtopage = urlencode(
$_SERVER[
"PHP_SELF"].
'?socid='.$societe->id.
'&action='.$action.
'&origin='.
GETPOST(
'origin').
'&originid='.
GETPOST(
'originid'));
2025 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2031 print '<tr><td>'.$langs->trans(
'Label').
'</td><td><input class="minwidth200" name="label" value="'.
dol_escape_htmltag(
GETPOST(
'label')).
'" type="text"></td></tr>';
2034 print '<tr><td class="fieldrequired">'.$langs->trans(
'DateInvoice').
'</td><td>';
2035 print $form->selectDate($dateinvoice,
'',
'',
'',
'',
"add", 1, 1);
2039 print '<tr><td>'.$langs->trans(
'DateMaxPayment').
'</td><td>';
2040 print $form->selectDate($datedue,
'ech',
'',
'',
'',
"add", 1, 1);
2044 print '<tr><td class="nowrap">'.$langs->trans(
'PaymentConditionsShort').
'</td><td>';
2045 $form->select_conditions_paiements(
GETPOSTISSET(
'cond_reglement_id') ?
GETPOST(
'cond_reglement_id',
'int') : $cond_reglement_id,
'cond_reglement_id');
2049 print '<tr><td>'.$langs->trans(
'PaymentMode').
'</td><td>';
2050 $form->select_types_paiements(
GETPOSTISSET(
'mode_reglement_id') ?
GETPOST(
'mode_reglement_id',
'int') : $mode_reglement_id,
'mode_reglement_id',
'DBIT');
2054 if (!empty($conf->banque->enabled))
2056 print '<tr><td>'.$langs->trans(
'BankAccount').
'</td><td>';
2057 print img_picto(
'',
'bank_account').$form->select_comptes((
GETPOSTISSET(
'fk_account') ?
GETPOST(
'fk_account',
'alpha') : $fk_account),
'fk_account', 0,
'', 1,
'', 0,
'', 1);
2062 if (!empty($conf->projet->enabled))
2066 $langs->load(
'projects');
2067 print '<tr><td>'.$langs->trans(
'Project').
'</td><td>';
2068 print img_picto(
'',
'project').$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
2073 if (!empty($conf->incoterm->enabled))
2076 print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans(
"IncotermLabel"), $objectsrc->label_incoterms, 1).
'</label></td>';
2077 print '<td colspan="3" class="maxwidthonsmartphone">';
2078 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 :
''));
2083 if (!empty($conf->multicurrency->enabled))
2086 print '<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
2087 print '<td class="maxwidthonsmartphone">';
2088 print $form->selectMultiCurrency((
GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code',
'alpha') : $currency_code),
'multicurrency_code');
2093 if (!empty($conf->intracommreport->enabled))
2095 $langs->loadLangs(array(
"intracommreport"));
2096 print '<tr><td>'.$langs->trans(
'IntracommReportTransportMode').
'</td><td>';
2097 $form->selectTransportMode(isset($_POST[
'transport_mode_id']) ? $_POST[
'transport_mode_id'] : $transport_mode_id,
'transport_mode_id');
2102 print '<tr><td>'.$langs->trans(
'NotePublic').
'</td>';
2104 $doleditor =
new DolEditor(
'note_public', (
GETPOSTISSET(
'note_public') ?
GETPOST(
'note_public',
'restricthtml') : $note_public),
'', 80,
'dolibarr_notes',
'In', 0,
false,
true, ROWS_3,
'90%');
2105 print $doleditor->Create(1);
2111 print '<tr><td>'.$langs->trans(
'NotePrivate').
'</td>';
2113 $doleditor =
new DolEditor(
'note_private', (
GETPOSTISSET(
'note_private') ?
GETPOST(
'note_private',
'restricthtml') : $note_private),
'', 80,
'dolibarr_notes',
'In', 0,
false,
true, ROWS_3,
'90%');
2114 print $doleditor->Create(1);
2119 if (empty($reshook))
2121 print $object->showOptionals($extrafields,
'edit');
2124 if (is_object($objectsrc))
2126 print "\n<!-- ".$classname.
" info -->";
2128 print '<input type="hidden" name="amount" value="'.$objectsrc->total_ht.
'">'.
"\n";
2129 print '<input type="hidden" name="total" value="'.$objectsrc->total_ttc.
'">'.
"\n";
2130 print '<input type="hidden" name="tva" value="'.$objectsrc->total_tva.
'">'.
"\n";
2131 print '<input type="hidden" name="origin" value="'.$objectsrc->element.
'">';
2132 print '<input type="hidden" name="originid" value="'.$objectsrc->id.
'">';
2134 $txt = $langs->trans($classname);
2135 if ($classname ==
'CommandeFournisseur') {
2136 $langs->load(
'orders');
2137 $txt = $langs->trans(
"SupplierOrder");
2139 print '<tr><td>'.$txt.
'</td><td>'.$objectsrc->getNomUrl(1);
2141 $objectsrc->fetchObjectLinked($originid, $origin,
'',
'invoice_supplier');
2143 $invoice_supplier = $objectsrc->linkedObjects[
'invoice_supplier'];
2146 if (is_array($invoice_supplier))
2148 $cntinvoice = count($invoice_supplier);
2150 if ($cntinvoice >= 1)
2153 echo
' ('.$langs->trans(
'LatestRelatedBill').end($invoice_supplier)->getNomUrl(1).
')';
2158 print '<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($objectsrc->total_ht).
'</td></tr>';
2159 print '<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($objectsrc->total_tva).
"</td></tr>";
2160 if ($mysoc->localtax1_assuj ==
"1" || $object->total_localtax1 != 0)
2162 print '<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax1).
"</td></tr>";
2165 if ($mysoc->localtax2_assuj ==
"1" || $object->total_localtax2 != 0)
2167 print '<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td><td>'.
price($objectsrc->total_localtax2).
"</td></tr>";
2169 print '<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($objectsrc->total_ttc).
"</td></tr>";
2171 if (!empty($conf->multicurrency->enabled))
2173 print '<tr><td>'.$langs->trans(
'MulticurrencyAmountHT').
'</td><td>'.
price($objectsrc->multicurrency_total_ht).
'</td></tr>';
2174 print '<tr><td>'.$langs->trans(
'MulticurrencyAmountVAT').
'</td><td>'.
price($objectsrc->multicurrency_total_tva).
"</td></tr>";
2175 print '<tr><td>'.$langs->trans(
'MulticurrencyAmountTTC').
'</td><td>'.
price($objectsrc->multicurrency_total_ttc).
"</td></tr>";
2180 $parameters = array();
2181 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2182 print $hookmanager->resPrint;
2189 print '<div class="center">';
2190 print '<input type="submit" class="button" name="bouton" value="'.$langs->trans(
'CreateDraft').
'">';
2191 print ' ';
2192 print '<input type="button" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'" onClick="javascript:history.go(-1)">';
2199 if (is_object($objectsrc)) {
2202 $title = $langs->trans(
'ProductsAndServices');
2205 print '<table class="noborder centpercent">';
2207 $objectsrc->printOriginLinesList();
2212 if ($id > 0 || !empty($ref)) {
2221 $productstatic =
new Product($db);
2223 $object->fetch($id, $ref);
2224 $result = $object->fetch_thirdparty();
2228 $result = $societe->fetch($object->socid);
2231 $totalpaye = $object->getSommePaiement();
2232 $totalcreditnotes = $object->getSumCreditNotesUsed();
2233 $totaldeposits = $object->getSumDepositsUsed();
2241 $resteapayer =
price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,
'MT');
2247 $resteapayeraffiche = $resteapayer;
2249 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
2250 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
2251 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
2253 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
2254 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
2257 $absolute_discount = $societe->getAvailableDiscounts(
'', $filterabsolutediscount, 0, 1);
2258 $absolute_creditnote = $societe->getAvailableDiscounts(
'', $filtercreditnote, 0, 1);
2259 $absolute_discount =
price2num($absolute_discount,
'MT');
2260 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
2266 $titre = $langs->trans(
'SupplierInvoice');
2273 if ($action ==
'converttoreduc') {
2277 $text = $langs->trans('ConfirmConvertToReducSupplier', strtolower($langs->transnoentities($type_fac)));
2278 $text .= '<br>'.$langs->trans('ConfirmConvertToReducSupplier2');
2279 $formconfirm = $form->formconfirm(
$_SERVER['PHP_SELF'].'?facid='.$object->
id, $langs->trans('ConvertToReduc'), $text, 'confirm_converttoreduc', '', "yes", 2);
2283 if ($action == 'clone')
2286 $formquestion = array(
2287 array(
'type' =>
'text',
'name' =>
'newsupplierref',
'label' => $langs->trans(
"RefSupplier"),
'value' => $langs->trans(
"CopyOf").
' '.$object->ref_supplier),
2288 array(
'type' =>
'date',
'name' =>
'newdate',
'label' => $langs->trans(
"Date"),
'value' =>
dol_now())
2291 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneInvoice', $object->ref),
'confirm_clone', $formquestion,
'yes', 1, 250);
2295 if ($action ==
'valid')
2298 if (preg_match(
'/^[\(]?PROV/i', $object->ref) || empty($object->ref)) {
2300 $numref = $object->getNextNumRef($societe);
2302 $numref = $object->ref;
2309 $text = $langs->trans(
'ConfirmValidateBill', $numref);
2317 $formquestion = array();
2319 $qualified_for_stock_change = 0;
2320 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
2321 $qualified_for_stock_change = $object->hasProductsOrServices(2);
2323 $qualified_for_stock_change = $object->hasProductsOrServices(1);
2326 if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change)
2328 $langs->load(
"stocks");
2329 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2332 $warehouse_array = $warehouse->list_array();
2333 if (count($warehouse_array) == 1) {
2334 $label = $object->type ==
FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans(
"WarehouseForStockDecrease", current($warehouse_array)) : $langs->trans(
"WarehouseForStockIncrease", current($warehouse_array));
2335 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
2338 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
2340 $formquestion = array(
2341 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
2345 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ValidateBill'), $text,
'confirm_valid', $formquestion, 1, 1);
2350 if ($action ==
'edit')
2352 $formquestion = array();
2354 $qualified_for_stock_change = 0;
2355 if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
2357 $qualified_for_stock_change = $object->hasProductsOrServices(2);
2359 $qualified_for_stock_change = $object->hasProductsOrServices(1);
2361 if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change)
2363 $langs->load(
"stocks");
2364 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2367 $warehouse_array = $warehouse->list_array();
2368 if (count($warehouse_array) == 1) {
2369 $label = $object->type ==
FactureFournisseur::TYPE_CREDIT_NOTE ? $langs->trans(
"WarehouseForStockIncrease", current($warehouse_array)) : $langs->trans(
"WarehouseForStockDecrease", current($warehouse_array));
2370 $value =
'<input type="hidden" id="idwarehouse" name="idwarehouse" value="'.key($warehouse_array).
'">';
2373 $value = $formproduct->selectWarehouses(
GETPOST(
'idwarehouse') ?
GETPOST(
'idwarehouse') :
'ifone',
'idwarehouse',
'', 1);
2375 $formquestion = array(
2376 array(
'type' =>
'other',
'name' =>
'idwarehouse',
'label' => $label,
'value' => $value)
2379 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'UnvalidateBill'), $langs->trans(
'ConfirmUnvalidateBill', $object->ref),
'confirm_edit', $formquestion, 1, 1);
2383 if ($action ==
'paid')
2385 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ClassifyPaid'), $langs->trans(
'ConfirmClassifyPaidBill', $object->ref),
'confirm_paid',
'', 0, 1);
2389 if ($action ==
'delete')
2391 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteBill'), $langs->trans(
'ConfirmDeleteBill'),
'confirm_delete',
'', 0, 1);
2393 if ($action ==
'deletepayment')
2395 $payment_id =
GETPOST(
'paiement_id');
2396 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&paiement_id='.$payment_id, $langs->trans(
'DeletePayment'), $langs->trans(
'ConfirmDeletePayment'),
'confirm_delete_paiement',
'', 0, 1);
2400 if ($action ==
'ask_deleteline')
2402 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteProductLine'), $langs->trans(
'ConfirmDeleteProductLine'),
'confirm_deleteline',
'', 0, 1);
2407 $parameters = array(
'formConfirm' => $formconfirm,
'lineid'=>$lineid);
2408 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2409 if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
2410 elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
2418 $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
2420 $morehtmlref = '<div class="refidno">';
2422 $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreate, '
string', '', 0, 1);
2423 $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreate, '
string', '', null, null, '', 1);
2425 $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
2426 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->
id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->
id.'&search_company='.urlencode($object->thirdparty->
name).'">'.$langs->trans("OtherBills").'</a>)';
2428 if (!empty($conf->projet->enabled))
2430 $langs->load(
"projects");
2431 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
2434 if ($action !=
'classify') {
2435 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
2437 if ($action ==
'classify') {
2439 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
2440 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
2441 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
2442 $morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
2443 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
2444 $morehtmlref .=
'</form>';
2446 $morehtmlref .= $form->form_project(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
2449 if (!empty($object->fk_project)) {
2451 $proj->fetch($object->fk_project);
2452 $morehtmlref .=
'<a href="'.DOL_URL_ROOT.
'/projet/card.php?id='.$object->fk_project.
'" title="'.$langs->trans(
'ShowProject').
'">';
2453 $morehtmlref .= $proj->ref;
2454 $morehtmlref .=
'</a>';
2460 $morehtmlref .=
'</div>';
2462 $object->totalpaye = $totalpaye;
2464 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
2466 print '<div class="fichecenter">';
2467 print '<div class="fichehalfleft">';
2468 print '<div class="underbanner clearboth"></div>';
2470 print '<table class="border tableforfield" width="100%">';
2473 print '<tr><td class="titlefield">'.$langs->trans(
'Type').
'</td><td>';
2474 print '<span class="badgeneutral">';
2475 print $object->getLibType();
2480 $facreplaced->fetch($object->fk_facture_source);
2481 print ' ('.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
')';
2486 $facusing->fetch($object->fk_facture_source);
2487 print ' ('.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
')';
2490 $facidavoir = $object->getListIdAvoirFromInvoice();
2491 if (count($facidavoir) > 0)
2493 print ' ('.$langs->transnoentities(
"InvoiceHasAvoir");
2495 foreach ($facidavoir as $id)
2497 if ($i == 0)
print ' ';
2500 $facavoir->fetch($id);
2501 print $facavoir->getNomUrl(1);
2505 if (isset($facidnext) && $facidnext > 0)
2508 $facthatreplace->fetch($facidnext);
2509 print ' ('.$langs->transnoentities(
"ReplacedByInvoice", $facthatreplace->getNomUrl(1)).
')';
2513 $result = $discount->fetch(0, 0, $object->id);
2515 print ' <span class="opacitymediumbycolor paddingleft">';
2516 $s = $langs->trans(
"CreditNoteConvertedIntoDiscount",
'{s1}',
'{s2}');
2517 $s = str_replace(
'{s1}', $object->getLibType(1), $s);
2518 $s = str_replace(
'{s2}', $discount->getNomUrl(1,
'discount'), $s);
2520 print '</span><br>';
2527 print '<!-- Discounts --><tr><td>'.$langs->trans(
'Discounts');
2530 $thirdparty = $societe;
2532 $backtopage = urlencode(
$_SERVER[
"PHP_SELF"].
'?facid='.$object->id);
2533 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
2539 print '<td>'.$form->editfieldkey(
"Label",
'label', $object->label, $object, ($usercancreate)).
'</td>';
2540 print '<td>'.$form->editfieldval(
"Label",
'label', $object->label, $object, ($usercancreate)).
'</td>';
2546 print '<tr><td>'.$form->editfieldkey(
"DateInvoice",
'datef', $object->datep, $object, $form_permission,
'datepicker').
'</td><td colspan="3">';
2547 print $form->editfieldval(
"Date",
'datef', $object->datep, $object, $form_permission,
'datepicker');
2551 $langs->load(
'bills');
2552 print '<tr><td class="nowrap">';
2553 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
2554 print $langs->trans(
'PaymentConditions');
2556 if ($action !=
'editconditions' && $usercancreate) {
2557 print '<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editconditions&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetConditions'), 1).
'</a></td>';
2559 print '</tr></table>';
2560 print '</td><td colspan="2">';
2561 if ($action ==
'editconditions')
2563 $form->form_conditions_reglement(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'cond_reglement_id');
2565 $form->form_conditions_reglement(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->cond_reglement_id,
'none');
2571 print '<tr><td>'.$form->editfieldkey(
"DateMaxPayment",
'date_lim_reglement', $object->date_echeance, $object, $form_permission,
'datepicker').
'</td><td colspan="3">';
2572 print $form->editfieldval(
"DateMaxPayment",
'date_lim_reglement', $object->date_echeance, $object, $form_permission,
'datepicker');
2573 if ($action !=
'editdate_lim_reglement' && $object->hasDelay()) {
2579 $langs->load(
'bills');
2580 print '<tr><td class="nowrap">';
2581 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
2582 print $langs->trans(
'PaymentMode');
2584 if ($action !=
'editmode' && $usercancreate) {
2585 print '<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmode&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetMode'), 1).
'</a></td>';
2587 print '</tr></table>';
2588 print '</td><td colspan="2">';
2589 if ($action ==
'editmode')
2591 $form->form_modes_reglement(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'mode_reglement_id',
'DBIT', 1, 1);
2593 $form->form_modes_reglement(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->mode_reglement_id,
'none');
2598 if (!empty($conf->multicurrency->enabled))
2603 print '<table class="nobordernopadding" width="100%"><tr><td>';
2604 print $form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0);
2606 if ($action !=
'editmulticurrencycode' && $object->statut == $object::STATUS_DRAFT)
2607 print '<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmulticurrencycode&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetMultiCurrencyCode'), 1).
'</a></td>';
2608 print '</tr></table>';
2609 print
'</td><td colspan="3">';
2610 if ($action ==
'editmulticurrencycode') {
2611 $form->form_multicurrency_code(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_code,
'multicurrency_code');
2613 $form->form_multicurrency_code(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_code,
'none');
2618 if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1)
2622 print
'<table class="nobordernopadding" width="100%"><tr><td>';
2623 print $form->editfieldkey(
'CurrencyRate',
'multicurrency_tx',
'', $object, 0);
2625 if ($action !=
'editmulticurrencyrate' && $object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency)
2626 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmulticurrencyrate&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetMultiCurrencyCode'), 1).
'</a></td>';
2627 print
'</tr></table>';
2628 print
'</td><td colspan="3">';
2629 if ($action ==
'editmulticurrencyrate' || $action ==
'actualizemulticurrencyrate') {
2630 if ($action ==
'actualizemulticurrencyrate') {
2633 $form->form_multicurrency_rate(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx,
'multicurrency_tx', $object->multicurrency_code);
2635 $form->form_multicurrency_rate(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->multicurrency_tx,
'none', $object->multicurrency_code);
2636 if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
2637 print
'<div class="inline-block"> ';
2638 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=actualizemulticurrencyrate">'.$langs->trans(
"ActualizeCurrency").
'</a>';
2647 if (!empty($conf->banque->enabled))
2649 print
'<tr><td class="nowrap">';
2650 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
2651 print $langs->trans(
'BankAccount');
2653 if ($action !=
'editbankaccount' && $usercancreate)
2654 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editbankaccount&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetBankAccount'), 1).
'</a></td>';
2655 print
'</tr></table>';
2656 print
'</td><td colspan="3">';
2657 if ($action ==
'editbankaccount') {
2658 $form->formSelectAccount(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'fk_account', 1);
2660 $form->formSelectAccount(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_account,
'none');
2667 if (!empty($conf->incoterm->enabled))
2670 print
'<table width="100%" class="nobordernopadding"><tr><td>';
2671 print $langs->trans(
'IncotermLabel');
2672 print
'<td><td class="right">';
2673 if ($usercancreate) print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.$object->id.
'&action=editincoterm">'.
img_edit().
'</a>';
2674 else print
' ';
2675 print
'</td></tr></table>';
2677 print
'<td colspan="3">';
2678 if ($action !=
'editincoterm')
2680 print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
2682 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''),
$_SERVER[
'PHP_SELF'].
'?id='.$object->id);
2688 if (!empty($conf->intracommreport->enabled)) {
2689 $langs->loadLangs(array(
"intracommreport"));
2690 print
'<tr><td class="nowrap">';
2691 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
2692 print $langs->trans(
'IntracommReportTransportMode');
2694 if ($action !=
'editmode' && $user->rights->fournisseur->facture->creer) {
2695 print
'<td class="right"><a href="'.$_SERVER[
"PHP_SELF"].
'?action=editmode&id='.$object->id.
'">'.
img_edit($langs->trans(
'SetMode'), 1).
'</a></td>';
2697 print
'</tr></table>';
2701 if ($action ==
'editmode')
2703 $form->formSelectTransportMode(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->transport_mode_id,
'transport_mode_id', 1, 1);
2706 $form->formSelectTransportMode(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->transport_mode_id,
'none');
2713 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2718 print
'<div class="fichehalfright">';
2719 print
'<div class="ficheaddleft">';
2720 print
'<div class="underbanner clearboth"></div>';
2722 print
'<table class="border tableforfield centpercent">';
2724 if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
2727 print
'<tr><td class="titlefieldmiddle">'.$form->editfieldkey(
'MulticurrencyAmountHT',
'multicurrency_total_ht',
'', $object, 0).
'</td>';
2728 print
'<td class="nowrap">'.price($object->multicurrency_total_ht,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
2732 print
'<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountVAT',
'multicurrency_total_tva',
'', $object, 0).
'</td>';
2733 print
'<td>'.price($object->multicurrency_total_tva,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
2737 print
'<tr><td height="10">'.$form->editfieldkey(
'MulticurrencyAmountTTC',
'multicurrency_total_ttc',
'', $object, 0).
'</td>';
2738 print
'<td>'.price($object->multicurrency_total_ttc,
'', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).
'</td>';
2743 print
'<tr><td class="titlefield">'.$langs->trans(
'AmountHT').
'</td><td>'.
price($object->total_ht, 1, $langs, 0, -1, -1, $conf->currency).
'</td></tr>';
2744 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($object->total_tva, 1, $langs, 0, -1, -1, $conf->currency).
'<div class="inline-block"> ';
2745 if (
GETPOST(
'calculationrule')) $calculationrule =
GETPOST(
'calculationrule',
'alpha');
2746 else $calculationrule = (empty($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND) ?
'totalofround' :
'roundoftotal');
2747 if ($calculationrule ==
'totalofround') $calculationrulenum = 1;
2748 else $calculationrulenum = 2;
2750 if ($object->getVentilExportCompta() == 0) {
2751 $s = $langs->trans(
"ReCalculate").
' ';
2752 $s .=
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=calculate&calculationrule=totalofround">'.$langs->trans(
"Mode1").
'</a>';
2754 $s .=
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=calculate&calculationrule=roundoftotal">'.$langs->trans(
"Mode2").
'</a>';
2755 print $form->textwithtooltip($s, $langs->trans(
"CalculationRuleDesc", $calculationrulenum).
'<br>'.$langs->trans(
"CalculationRuleDescSupplier"), 2, 1,
img_picto(
'',
'help'));
2757 print
'</div></td></tr>';
2761 if ($societe->localtax1_assuj ==
"1")
2763 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $societe->country_code).
'</td>';
2764 print
'<td>'.price($object->total_localtax1, 1, $langs, 0, -1, -1, $conf->currency).
'</td>';
2767 if ($societe->localtax2_assuj ==
"1")
2769 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $societe->country_code).
'</td>';
2770 print
'<td>'.price($object->total_localtax2, 1, $langs, 0, -1, -1, $conf->currency).
'</td>';
2773 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td colspan="3">'.
price($object->total_ttc, 1, $langs, 0, -1, -1, $conf->currency).
'</td></tr>';
2786 $nbrows = 9; $nbcols = 3;
2787 if (!empty($conf->projet->enabled)) $nbrows++;
2788 if (!empty($conf->banque->enabled)) { $nbrows++; $nbcols++; }
2789 if (!empty($conf->incoterm->enabled)) $nbrows++;
2790 if (!empty($conf->multicurrency->enabled)) $nbrows += 5;
2793 if ($societe->localtax1_assuj ==
"1") $nbrows++;
2794 if ($societe->localtax2_assuj ==
"1") $nbrows++;
2796 $sql =
'SELECT p.datep as dp, p.ref, p.num_paiement as num_payment, p.rowid, p.fk_bank,';
2797 $sql .=
' c.id as paiement_type,';
2798 $sql .=
' pf.amount,';
2799 $sql .=
' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.fk_accountancy_journal';
2800 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn as p';
2801 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
2802 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
2803 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id';
2804 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_paiementfourn = p.rowid';
2805 $sql .=
' WHERE pf.fk_facturefourn = '.$object->id;
2806 $sql .=
' ORDER BY p.datep, p.tms';
2808 $result = $db->query($sql);
2811 $num = $db->num_rows($result);
2814 print
'<div class="div-table-responsive-no-min">';
2815 print
'<table class="noborder paymenttable" width="100%">';
2816 print
'<tr class="liste_titre">';
2818 print
'<td>'.$langs->trans(
'Date').
'</td>';
2819 print
'<td>'.$langs->trans(
'Type').
'</td>';
2820 if (!empty($conf->banque->enabled)) print
'<td class="right">'.$langs->trans(
'BankAccount').
'</td>';
2821 print
'<td class="right">'.$langs->trans(
'Amount').
'</td>';
2822 print
'<td width="18"> </td>';
2829 $objp = $db->fetch_object($result);
2831 $paymentstatic->id = $objp->rowid;
2832 $paymentstatic->datepaye = $db->jdate($objp->dp);
2833 $paymentstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
2834 $paymentstatic->num_payment = $objp->num_payment;
2835 $paymentstatic->payment_code = $objp->payment_code;
2837 print
'<tr class="oddeven">';
2839 print $paymentstatic->getNomUrl(1);
2841 print
'<td>'.dol_print_date($db->jdate($objp->dp),
'day').
'</td>';
2843 print $form->form_modes_reglement(null, $objp->paiement_type,
'none').
' '.$objp->num_payment;
2845 if (!empty($conf->banque->enabled))
2847 $bankaccountstatic->id = $objp->baid;
2848 $bankaccountstatic->ref = $objp->baref;
2849 $bankaccountstatic->label = $objp->baref;
2850 $bankaccountstatic->number = $objp->banumber;
2852 if (!empty($conf->accounting->enabled)) {
2853 $bankaccountstatic->account_number = $objp->account_number;
2856 $accountingjournal->fetch($objp->fk_accountancy_journal);
2857 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1,
'', 1);
2860 print
'<td class="right">';
2861 if ($objp->baid > 0) print $bankaccountstatic->getNomUrl(1,
'transactions');
2864 print
'<td class="right">'.price($sign * $objp->amount).
'</td>';
2865 print
'<td class="center">';
2868 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=deletepayment&token='.
newToken().
'&paiement_id='.$objp->rowid.
'">';
2874 $totalpaye += $objp->amount;
2878 print
'<tr class="oddeven"><td colspan="'.$nbcols.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td><td></td><td></td></tr>';
2902 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
2903 print
'<span class="opacitymedium">';
2905 print $langs->trans(
'AlreadyPaidNoCreditNotesNoDeposits');
2906 else print $langs->trans(
'AlreadyPaid');
2908 print
'</td><td class="right"'.(($totalpaye > 0) ?
' class="amountalreadypaid"' :
'').
'>'.
price($totalpaye).
'</td><td> </td></tr>';
2911 $resteapayeraffiche = $resteapayer;
2913 $cssforamountpaymentcomplete =
'amountpaymentcomplete';
2916 $creditnoteamount = 0;
2920 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
2921 $sql .=
" re.description, re.fk_invoice_supplier_source";
2922 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
2923 $sql .=
" WHERE fk_invoice_supplier = ".$object->id;
2924 $resql = $db->query($sql);
2926 $num = $db->num_rows(
$resql);
2930 $obj = $db->fetch_object(
$resql);
2931 $invoice->fetch($obj->fk_invoice_supplier_source);
2932 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
2934 print $langs->trans(
"CreditNote").
' ';
2936 print $langs->trans(
"Deposit").
' ';
2937 print $invoice->getNomUrl(0);
2939 print
'<td class="right">'.price($obj->amount_ttc).
'</td>';
2940 print
'<td class="right">';
2941 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?facid='.$object->id.
'&action=unlinkdiscount&discountid='.$obj->rowid.
'">'.
img_delete().
'</a>';
2945 $creditnoteamount += $obj->amount_ttc;
2947 $depositamount += $obj->amount_ttc;
2955 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
2956 print
'<span class="opacitymedium">';
2957 print $form->textwithpicto($langs->trans(
"Discount"), $langs->trans(
"HelpEscompte"), - 1);
2959 print
'</td><td class="right">'.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).
'</td><td> </td></tr>';
2960 $resteapayeraffiche = 0;
2961 $cssforamountpaymentcomplete =
'amountpaymentneutral';
2965 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
2966 print
'<span class="opacitymedium">';
2967 print $form->textwithpicto($langs->trans(
"Abandoned"), $langs->trans(
"HelpAbandonBadCustomer"), - 1);
2969 print
'</td><td class="right">'.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).
'</td><td> </td></tr>';
2971 $cssforamountpaymentcomplete =
'amountpaymentneutral';
2975 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
2976 print
'<span class="opacitymedium">';
2977 print $form->textwithpicto($langs->trans(
"ProductReturned"), $langs->trans(
"HelpAbandonProductReturned"), - 1);
2979 print
'</td><td class="right">'.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).
'</td><td> </td></tr>';
2980 $resteapayeraffiche = 0;
2981 $cssforamountpaymentcomplete =
'amountpaymentneutral';
2985 print
'<tr><td colspan="'.$nbcols.
'" class="right nowrap">';
2986 $text = $langs->trans(
"HelpAbandonOther");
2987 if ($object->close_note)
2988 $text .=
'<br><br><b>'.$langs->trans(
"Reason").
'</b>:'.$object->close_note;
2989 print
'<span class="opacitymedium">';
2990 print $form->textwithpicto($langs->trans(
"Abandoned"), $text, - 1);
2992 print
'</td><td class="right">'.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).
'</td><td> </td></tr>';
2993 $resteapayeraffiche = 0;
2994 $cssforamountpaymentcomplete =
'amountpaymentneutral';
2998 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
2999 print
'<span class="opacitymedium">';
3000 print $langs->trans(
"Billed");
3002 print
'</td><td class="right">'.price($object->total_ttc).
'</td><td> </td></tr>';
3005 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3006 print
'<span class="opacitymedium">';
3007 if ($resteapayeraffiche >= 0)
3008 print $langs->trans(
'RemainderToPay');
3009 else print $langs->trans(
'ExcessPaid');
3012 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($resteapayeraffiche).
'</td>';
3013 print
'<td class="nowrap"> </td></tr>';
3016 $cssforamountpaymentcomplete =
'amountpaymentneutral';
3019 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3020 print $langs->trans(
'AlreadyPaidBack');
3021 print
' :</td><td class="right">'.price($sign * $totalpaye).
'</td><td> </td></tr>';
3024 print
'<tr><td colspan="'.$nbcols.
'" class="right">'.$langs->trans(
"Billed").
' :</td><td class="right">'.
price($sign * $object->total_ttc).
'</td><td> </td></tr>';
3027 print
'<tr><td colspan="'.$nbcols.
'" class="right">';
3028 print
'<span class="opacitymedium">';
3029 if ($resteapayeraffiche <= 0)
3030 print $langs->trans(
'RemainderToPayBack');
3031 else print $langs->trans(
'ExcessPaid');
3034 print
'<td class="right'.($resteapayeraffiche ?
' amountremaintopay' : (
' '.$cssforamountpaymentcomplete)).
'">'.
price($sign * $resteapayeraffiche).
'</td>';
3035 print
'<td class="nowrap"> </td></tr>';
3050 print
'<div class="clearboth"></div><br>';
3052 if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
3054 $blocname =
'contacts';
3055 $title = $langs->trans(
'ContactsAddresses');
3056 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
3059 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB))
3062 $blocname =
'notes';
3063 $title = $langs->trans(
'Notes');
3064 include DOL_DOCUMENT_ROOT.
'/core/tpl/bloc_showhide.tpl.php';
3071 print
'<form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action !=
'editline') ?
'#addline' :
'#line_'.
GETPOST(
'lineid')).
'" method="POST">';
3072 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3073 print
'<input type="hidden" name="action" value="'.(($action !=
'editline') ?
'addline' :
'updateline').
'">';
3074 print
'<input type="hidden" name="mode" value="">';
3075 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
3076 print
'<input type="hidden" name="socid" value="'.$societe->id.
'">';
3079 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
3082 print
'<div class="div-table-responsive-no-min">';
3083 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
3085 global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax;
3086 $forceall = 1; $dateSelector = 0; $inputalsopricewithtax = 1;
3087 $senderissupplier = 2;
3089 if (!empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier = 1;
3092 if (!empty($object->lines))
3093 $ret = $object->printObjectLines($action, $societe, $mysoc, $lineid, 1);
3095 $num = count($object->lines);
3100 if ($action !=
'editline')
3103 $object->formAddObjectLine(1, $societe, $mysoc);
3105 $parameters = array();
3106 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
3117 if ($action !=
'presend')
3123 print
'<div class="tabsAction">';
3125 $parameters = array();
3126 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3128 if (empty($reshook))
3134 $ventilExportCompta = $object->getVentilExportCompta();
3136 if ($ventilExportCompta == 0)
3138 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit">'.$langs->trans(
'Modify').
'</a></div>';
3140 print
'<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseDispatchedInBookkeeping").
'">'.$langs->trans(
'Modify').
'</span></div>';
3145 $result = $discount->fetch(0, 0, $object->id);
3152 if (!$facidnext && $object->close_code !=
'replaced' && $usercancreate)
3154 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=reopen">'.$langs->trans(
'ReOpen').
'</a></div>';
3156 if ($usercancreate) {
3157 print
'<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseReplacedInvoice").
'">'.$langs->trans(
'ReOpen').
'</span></div>';
3158 } elseif (empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) {
3159 print
'<div class="inline-block divButAction"><span class="butActionRefused classfortooltip">'.$langs->trans(
'ReOpen').
'</span></div>';
3165 if (empty($user->socid)) {
3170 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a></div>';
3171 }
else print
'<div class="inline-block divButAction"><span class="butActionRefused classfortooltip">'.$langs->trans(
'SendMail').
'</a></div>';
3178 print
'<div class="inline-block divButAction"><a class="butAction" href="paiement.php?facid='.$object->id.
'&action=create'.($object->fk_account > 0 ?
'&accountid='.$object->fk_account :
'').
'">'.$langs->trans(
'DoPayment').
'</a></div>';
3184 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=paid"';
3185 print
'>'.$langs->trans(
'ClassifyPaid').
'</a></div>';
3195 if ($resteapayer == 0)
3197 print
'<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans(
"DisabledBecauseRemainderToPayIsZero").
'">'.$langs->trans(
'DoPaymentBack').
'</span></div>';
3199 print
'<div class="inline-block divButAction"><a class="butAction" href="paiement.php?facid='.$object->id.
'&action=create&accountid='.$object->fk_account.
'">'.$langs->trans(
'DoPaymentBack').
'</a></div>';
3204 if ($object->type ==
FactureFournisseur::TYPE_STANDARD && empty($object->paye) && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) < 0 && $usercancreate && empty($discount->id))
3206 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.$object->id.
'&action=converttoreduc">'.$langs->trans(
'ConvertExcessPaidToReduc').
'</a></div>';
3210 && (!empty($conf->global->SUPPLIER_INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0)
3212 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.$object->id.
'&action=converttoreduc" title="'.
dol_escape_htmltag($langs->trans(
"ConfirmConvertToReducSupplier2")).
'">'.$langs->trans(
'ConvertToReduc').
'</a></div>';
3217 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?facid='.$object->id.
'&action=converttoreduc">'.$langs->trans(
'ConvertToReduc').
'</a></div>';
3224 if (count($object->lines))
3226 if ($usercanvalidate)
3228 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=valid"';
3229 print
'>'.$langs->trans(
'Validate').
'</a></div>';
3231 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotAllowed")).
'"';
3232 print
'>'.$langs->trans(
'Validate').
'</a></div>';
3244 if ($action !=
'edit' && $usercancreate)
3246 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=clone&socid='.$object->socid.
'">'.$langs->trans(
'ToClone').
'</a></div>';
3254 print
'<div class="inline-block divButAction"><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></div>';
3259 $isErasable = $object->is_erasable();
3260 if ($action !=
'confirm_edit' && ($user->rights->fournisseur->facture->supprimer || ($usercancreate && $isErasable == 1)))
3263 if ($isErasable == -4) {
3264 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"DisabledBecausePayments").
'">'.$langs->trans(
'Delete').
'</a></div>';
3265 } elseif ($isErasable == -3) {
3266 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"DisabledBecauseNotLastSituationInvoice").
'">'.$langs->trans(
'Delete').
'</a></div>';
3267 } elseif ($isErasable == -2) {
3268 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"DisabledBecauseNotLastInvoice").
'">'.$langs->trans(
'Delete').
'</a></div>';
3269 } elseif ($isErasable == -1) {
3270 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"DisabledBecauseDispatchedInBookkeeping").
'">'.$langs->trans(
'Delete').
'</a></div>';
3271 } elseif ($isErasable <= 0)
3273 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"DisabledBecauseNotErasable").
'">'.$langs->trans(
'Delete').
'</a></div>';
3275 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.
newToken().
'">'.$langs->trans(
'Delete').
'</a></div>';
3280 if ($action !=
'confirm_edit')
3282 print
'<div class="fichecenter"><div class="fichehalfleft">';
3288 $subdir =
get_exdir($object->id, 2, 0, 0, $object,
'invoice_supplier').$ref;
3289 $filedir = $conf->fournisseur->facture->dir_output.
'/'.$subdir;
3290 $urlsource =
$_SERVER[
'PHP_SELF'].
'?id='.$object->id;
3291 $genallowed = $usercanread;
3292 $delallowed = $usercancreate;
3293 $modelpdf = (!empty($object->model_pdf) ? $object->model_pdf : (empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF) ?
'' : $conf->global->INVOICE_SUPPLIER_ADDON_PDF));
3295 print $formfile->showdocuments(
'facture_fournisseur', $subdir, $filedir, $urlsource, $genallowed, $delallowed, $modelpdf, 1, 0, 0, 40, 0,
'',
'',
'', $societe->default_lang);
3296 $somethingshown = $formfile->numoffiles;
3299 $linktoelem = $form->showLinkToObjectBlock($object, null, array(
'invoice_supplier'));
3300 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
3302 print
'</div><div class="fichehalfright"><div class="ficheaddleft">';
3307 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3309 $somethingshown =
$formactions->showactions($object,
'invoice_supplier', $socid, 1,
'listaction'.($genallowed ?
'largetitle' :
''));
3311 print
'</div></div></div>';
3318 if (
GETPOST(
'modelselected')) {
3319 $action =
'presend';
3323 $modelmail =
'invoice_supplier_send';
3324 $defaulttopic =
'SendBillRef';
3325 $diroutput = $conf->fournisseur->facture->dir_output;
3326 $autocopy =
'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO';
3327 $trackid =
'sinv'.$object->id;
3329 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
const TYPE_STANDARD
Standard invoice.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action== 'set') elseif($action== 'specimen') elseif($action== 'setmodel') elseif($action== 'del') elseif($action== 'setdoc') $formactions
View.
dol_htmloutput_events($disabledoutputofmessages=0)
Print formated messages to output (Used to show messages on html output).
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
const TYPE_DEPOSIT
Deposit invoice.
static getIdAndTxFromCode($db, $code, $date_document= '')
Get id and rate of currency from code.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Class to manage products or services.
dol_now($mode= 'auto')
Return date for now.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for properties) With native = 0: P...
const TYPE_REPLACEMENT
Replacement invoice.
const STATUS_VALIDATED
Validated (need to be paid)
Class to manage suppliers invoices.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Fonction qui renvoie si tva doit etre tva percue recuperable.
$conf db name
Only used if Module[ID]Name translation string is not found.
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...
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate, from a $thirdparty_buyer to a $thirdparty_seller Note: This function applies same rules than get_default_tva.
Class to manage bank accounts.
Class to manage suppliers.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
Class to manage projects.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
Class to manage translations.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
Class ProductCombination Used to represent a product combination.
facturefourn_prepare_head($object)
Prepare array with list of tabs.
print $_SERVER["PHP_SELF"]
Edit parameters.
const STATUS_CLOSED
Classified paid.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
const TYPE_CREDIT_NOTE
Credit note invoice.
print
Draft customers invoices.
const TYPE_SITUATION
Situation invoice.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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) Si ...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Class to manage absolute discounts.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
const STATUS_ABANDONED
Classified abandoned and no payment done.
Class to manage a WYSIWYG editor.
Class to manage accounting accounts.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
Class to manage payments for supplier invoices.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Class to manage predefined suppliers products.
Class to manage warehouses.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...