41require
'../../main.inc.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
57require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
58require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
59require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
60require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
61require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
64$langs->loadLangs(array(
'products',
'bills',
'companies',
'projects',
'banks'));
66$action =
GETPOST(
'action',
'aZ09');
67$massaction =
GETPOST(
'massaction',
'alpha');
69$confirm =
GETPOST(
'confirm',
'alpha');
70$toselect =
GETPOST(
'toselect',
'array:int');
71$optioncss =
GETPOST(
'optioncss',
'alpha');
72$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'supplierinvoicelist';
75$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
76$search_label =
GETPOST(
"search_label",
"alpha");
77$search_amount_no_tax =
GETPOST(
"search_amount_no_tax",
"alpha");
78$search_amount_all_tax =
GETPOST(
"search_amount_all_tax",
"alpha");
80$search_refsupplier =
GETPOST(
'search_refsupplier',
'alpha');
81$search_type =
GETPOST(
'search_type',
'intcomma');
82$search_subtype =
GETPOST(
'search_subtype',
'intcomma');
83$search_project =
GETPOST(
'search_project',
'alpha');
84$search_company =
GETPOST(
'search_company',
'alpha');
85$search_company_alias =
GETPOST(
'search_company_alias',
'alpha');
86$search_montant_ht =
GETPOST(
'search_montant_ht',
'alpha');
87$search_montant_vat =
GETPOST(
'search_montant_vat',
'alpha');
88$search_montant_localtax1 =
GETPOST(
'search_montant_localtax1',
'alpha');
89$search_montant_localtax2 =
GETPOST(
'search_montant_localtax2',
'alpha');
90$search_montant_ttc =
GETPOST(
'search_montant_ttc',
'alpha');
91$search_login =
GETPOST(
'search_login',
'alpha');
92$search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
93$search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
94$search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
95$search_multicurrency_montant_vat =
GETPOST(
'search_multicurrency_montant_vat',
'alpha');
96$search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
97$search_status =
GETPOST(
'search_status',
'array:intcomma');
98if (empty($search_status) &&
GETPOSTISSET(
'search_status')) {
100 $search_status =
GETPOST(
'search_status',
'intcomma');
101 if ($search_status !==
'' && $search_status !==
'-1') {
102 $search_status = array($search_status);
106} elseif (is_array($search_status) && count($search_status) == 0) {
109$search_paymentmode =
GETPOST(
'search_paymentmode',
'intcomma');
110$search_paymentcond =
GETPOST(
'search_paymentcond') ?
GETPOSTINT(
'search_paymentcond') :
'';
111$search_bankaccount =
GETPOST(
'search_bankaccount',
'intcomma');
112$search_vat_reverse_charge =
GETPOST(
'search_vat_reverse_charge',
'alpha');
113$search_town =
GETPOST(
'search_town',
'alpha');
114$search_zip =
GETPOST(
'search_zip',
'alpha');
115$search_state =
GETPOST(
"search_state");
116$search_note_private =
GETPOST(
'search_note_private',
'alpha');
117$search_note_public =
GETPOST(
'search_note_public',
'alpha');
118$search_country =
GETPOST(
"search_country",
'aZ09');
119$search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'intcomma');
120$search_user =
GETPOST(
'search_user',
'intcomma');
121$search_sale =
GETPOST(
'search_sale',
'intcomma');
122$search_date_start =
GETPOSTDATE(
'search_date_start',
'',
'tzserver');
123$search_date_end =
GETPOSTDATE(
'search_date_end',
'23:59:59',
'tzserver');
124$search_datelimit_startday =
GETPOSTINT(
'search_datelimit_startday');
125$search_datelimit_startmonth =
GETPOSTINT(
'search_datelimit_startmonth');
126$search_datelimit_startyear =
GETPOSTINT(
'search_datelimit_startyear');
127$search_datelimit_endday =
GETPOSTINT(
'search_datelimit_endday');
128$search_datelimit_endmonth =
GETPOSTINT(
'search_datelimit_endmonth');
129$search_datelimit_endyear =
GETPOSTINT(
'search_datelimit_endyear');
130$search_datelimit_start =
dol_mktime(0, 0, 0, $search_datelimit_startmonth, $search_datelimit_startday, $search_datelimit_startyear);
131$search_datelimit_end =
dol_mktime(23, 59, 59, $search_datelimit_endmonth, $search_datelimit_endday, $search_datelimit_endyear);
132$search_categ_sup =
GETPOST(
"search_categ_sup",
'intcomma');
133$searchCategorySupplierInvoiceList =
GETPOST(
'search_category_supplier_invoice_list',
'array:int');
134$searchCategorySupplierInvoiceOperator = 0;
136 $searchCategorySupplierInvoiceOperator =
GETPOSTINT(
'search_category_supplier_invoice_operator');
138 $searchCategorySupplierInvoiceOperator =
getDolGlobalString(
'MAIN_SEARCH_CAT_OR_BY_DEFAULT');
140$search_product_category =
GETPOST(
'search_product_category',
'intcomma');
141$search_fk_fac_rec_source =
GETPOST(
'search_fk_fac_rec_source',
'int');
143$option =
GETPOST(
'search_option');
144if ($option ==
'late') {
145 $search_status =
'1';
147$filter =
GETPOST(
'filtre',
'alpha');
151$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
152$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
154if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
158$offset = $limit * $page;
163 $sortfield =
"f.datef,f.rowid";
165$pageprev = $page - 1;
166$pagenext = $page + 1;
171if ($user->socid > 0) {
173 $socid = $user->socid;
180$hookmanager->initHooks(array(
'supplierinvoicelist'));
182$diroutputmassaction =
getMultidirTemp($object).
'/massgeneration/'.$user->id;
185$extrafields->fetch_name_optionals_label(
$object->table_element);
187$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
190$fieldstosearchall = array(
192 'f.ref_supplier' =>
'RefSupplier',
193 'f.note_public' =>
'NotePublic',
194 's.nom' =>
"ThirdParty",
195 's.code_fournisseur' =>
"SupplierCodeShort",
196 'pd.description' =>
'Description',
198if (empty($user->socid)) {
199 $fieldstosearchall[
"f.note_private"] =
"NotePrivate";
202$checkedtypetiers =
'0';
204 'f.ref' => array(
'label' =>
"Ref",
'checked' =>
'1',
'position' => 5),
205 'f.ref_supplier' => array(
'label' =>
"RefSupplier",
'checked' =>
'1',
'position' => 7),
206 'f.type' => array(
'label' =>
"Type",
'checked' =>
'0',
'position' => 15),
207 'f.subtype' => array(
'label' =>
"InvoiceSubtype",
'checked' =>
'0',
'position' => 17),
208 'f.label' => array(
'label' =>
"Label",
'checked' =>
'0',
'position' => 20),
209 'f.datef' => array(
'label' =>
"DateInvoice",
'checked' =>
'1',
'position' => 25),
210 'f.date_lim_reglement' => array(
'label' =>
"DateDue",
'checked' =>
'1',
'position' => 27),
211 'p.ref' => array(
'label' =>
"ProjectRef",
'checked' =>
'1',
'position' => 30,
'enabled' => (
isModEnabled(
'project') ?
'1' :
'0')),
212 's.nom' => array(
'label' =>
"ThirdParty",
'checked' =>
'1',
'position' => 41),
213 's.name_alias' => array(
'label' =>
"AliasNameShort",
'checked' =>
'0',
'position' => 42),
214 's.town' => array(
'label' =>
"Town",
'checked' =>
'-1',
'position' => 43),
215 's.zip' => array(
'label' =>
"Zip",
'checked' =>
'-1',
'position' => 44),
216 'state.nom' => array(
'label' =>
"StateShort",
'checked' =>
'0',
'position' => 45),
217 'country.code_iso' => array(
'label' =>
"Country",
'checked' =>
'0',
'position' => 46),
218 'typent.code' => array(
'label' =>
"ThirdPartyType",
'checked' => $checkedtypetiers,
'position' => 48),
219 'f.vat_reverse_charge' => array(
'label' =>
"VATReverseCharge",
'checked' =>
'0',
'position' => 49,
'enabled' => (
getDolGlobalString(
'ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE') ?
'1' :
'0')),
220 'f.fk_mode_reglement' => array(
'label' =>
"PaymentMode",
'checked' =>
'0',
'position' => 52),
221 'f.fk_cond_reglement' => array(
'label' =>
"PaymentConditionsShort",
'checked' =>
'0',
'position' => 50),
222 'ba.label' => array(
'label' =>
"BankAccount",
'langfile' =>
'banks',
'checked' =>
'0',
'enabled' => (string) (int) (
isModEnabled(
'bank')),
'position' => 192),
223 'f.total_ht' => array(
'label' =>
"AmountHT",
'checked' =>
'1',
'position' => 105),
224 'f.total_vat' => array(
'label' =>
"AmountVAT",
'checked' =>
'0',
'position' => 110),
225 'f.total_localtax1' => array(
'label' => $langs->transcountry(
"AmountLT1",
$mysoc->country_code),
'checked' =>
'0',
'enabled' => (string) (int) (
$mysoc->localtax1_assuj ==
"1"),
'position' => 95),
226 'f.total_localtax2' => array(
'label' => $langs->transcountry(
"AmountLT2",
$mysoc->country_code),
'checked' =>
'0',
'enabled' => (string) (int) (
$mysoc->localtax2_assuj ==
"1"),
'position' => 100),
227 'f.total_ttc' => array(
'label' =>
"AmountTTC",
'checked' =>
'1',
'position' => 115),
228 'supplier_available_discount' => array(
'label' =>
'DiscountStillRemaining',
'checked' =>
'0',
'position' => 116,
'help' =>
'SupplierAbsoluteDiscountAllUsers'),
229 'dynamount_payed' => array(
'label' =>
"Paid",
'checked' =>
'0',
'position' => 117),
230 'rtp' => array(
'label' =>
"Rest",
'checked' =>
'0',
'position' => 118),
231 'f.multicurrency_code' => array(
'label' =>
'Currency',
'checked' =>
'0',
'position' => 205,
'enabled' => (!
isModEnabled(
"multicurrency") ?
'0' :
'1')),
232 'f.multicurrency_tx' => array(
'label' =>
'CurrencyRate',
'checked' =>
'0',
'position' => 206,
'enabled' => (!
isModEnabled(
"multicurrency") ?
'0' :
'1')),
233 'f.multicurrency_total_ht' => array(
'label' =>
'MulticurrencyAmountHT',
'position' => 207,
'checked' =>
'0',
'enabled' => (!
isModEnabled(
"multicurrency") ?
'0' :
'1')),
234 'f.multicurrency_total_vat' => array(
'label' =>
'MulticurrencyAmountVAT',
'position' => 208,
'checked' =>
'0',
'enabled' => (!
isModEnabled(
"multicurrency") ?
'0' :
'1')),
235 'f.multicurrency_total_ttc' => array(
'label' =>
'MulticurrencyAmountTTC',
'position' => 209,
'checked' =>
'0',
'enabled' => (!
isModEnabled(
"multicurrency") ?
'0' :
'1')),
236 'multicurrency_dynamount_payed' => array(
'label' =>
'MulticurrencyAlreadyPaid',
'position' => 210,
'checked' =>
'0',
'enabled' => (!
isModEnabled(
"multicurrency") ?
'0' :
'1')),
237 'multicurrency_rtp' => array(
'label' =>
'MulticurrencyRemainderToPay',
'checked' =>
'0',
'position' => 211,
'enabled' => (!
isModEnabled(
"multicurrency") ?
'0' :
'1')),
238 'u.login' => array(
'label' =>
"Author",
'checked' =>
'-1',
'position' => 500),
239 'f.datec' => array(
'label' =>
"DateCreation",
'checked' =>
'0',
'position' => 501),
240 'f.tms' => array(
'label' =>
"DateModificationShort",
'checked' =>
'0',
'position' => 502),
241 'f.nb_docs' => array(
'label' =>
"Documents",
'checked' =>
'-1',
'position' => 510),
242 'f.note_public' => array(
'label' =>
'NotePublic',
'checked' =>
'0',
'position' => 520,
'enabled' => (
getDolGlobalInt(
'MAIN_LIST_HIDE_PUBLIC_NOTES') ?
'0' :
'1')),
243 'f.note_private' => array(
'label' =>
'NotePrivate',
'checked' =>
'0',
'position' => 521,
'enabled' => (
getDolGlobalInt(
'MAIN_LIST_HIDE_PRIVATE_NOTES') ?
'0' :
'1')),
244 'f.fk_statut' => array(
'label' =>
"Status",
'checked' =>
'1',
'position' => 1000),
247include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
249$parameters = array(
'arrayfields' => &$arrayfields);
250$reshook = $hookmanager->executeHooks(
'completeArrayFields', $parameters, $object, $action);
252$subtypearray =
$object->getArrayOfInvoiceSubtypes(0);
253if (empty($subtypearray)) {
254 unset($arrayfields[
'f.subtype']);
263if ((!$user->hasRight(
"fournisseur",
"facture",
"lire") && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD'))
264 || (!$user->hasRight(
"supplier_invoice",
"lire") &&
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD'))) {
269if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
270 $search_sale = $user->id;
273$permissiontoread = ($user->hasRight(
"fournisseur",
"facture",
"lire") || $user->hasRight(
"supplier_invoice",
"lire"));
274$permissiontoadd = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
275$permissiontodelete = ($user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"supprimer"));
282if (
GETPOST(
'cancel',
'alpha')) {
286if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
290$parameters = array(
'socid' => $socid,
'arrayfields' => &$arrayfields);
291$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
293 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
296if (empty($reshook)) {
298 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
301 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha')) {
305 $search_product_category =
'';
306 $searchCategorySupplierInvoiceList = array();
308 $search_refsupplier =
"";
310 $search_subtype =
'';
312 $search_project =
'';
313 $search_company =
"";
314 $search_company_alias =
"";
315 $search_amount_no_tax =
"";
316 $search_amount_all_tax =
"";
317 $search_montant_ht =
'';
318 $search_montant_vat =
'';
319 $search_montant_localtax1 =
'';
320 $search_montant_localtax2 =
'';
321 $search_montant_ttc =
'';
323 $search_multicurrency_code =
'';
324 $search_multicurrency_tx =
'';
325 $search_multicurrency_montant_ht =
'';
326 $search_multicurrency_montant_vat =
'';
327 $search_multicurrency_montant_ttc =
'';
329 $search_paymentmode =
'';
330 $search_paymentcond =
'';
331 $search_bankaccount =
'';
332 $search_vat_reverse_charge =
'';
336 $search_country =
'';
337 $search_type_thirdparty =
'';
338 $search_date_start =
'';
339 $search_date_end =
'';
340 $search_datelimit_startday =
'';
341 $search_datelimit_startmonth =
'';
342 $search_datelimit_startyear =
'';
343 $search_datelimit_endday =
'';
344 $search_datelimit_endmonth =
'';
345 $search_datelimit_endyear =
'';
346 $search_datelimit_start =
'';
347 $search_datelimit_end =
'';
348 $search_note_private =
'';
349 $search_note_public =
'';
351 $search_array_options = array();
352 $search_categ_sup = 0;
358 $objectclass =
'FactureFournisseur';
359 $objectlabel =
'SupplierInvoices';
363 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
365 if ($massaction ==
'banktransfertrequest') {
366 $langs->load(
"withdrawals");
368 if (!$user->hasRight(
"paymentbybanktransfer",
"create")) {
370 setEventMessages($langs->trans(
"NotEnoughPermissions"),
null,
'errors');
375 $arrayofselected = is_array($toselect) ? $toselect : array();
376 $listofbills = array();
377 foreach ($arrayofselected as $toselectid) {
379 $result = $objecttmp->fetch($toselectid);
381 $totalpaid = $objecttmp->getSommePaiement();
382 $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
383 $totaldeposits = $objecttmp->getSumDepositsUsed();
384 $objecttmp->resteapayer =
price2num($objecttmp->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
387 $parameters = array(
'remaintopay' => $objecttmp->resteapayer);
388 $reshook = $hookmanager->executeHooks(
'finalizeAmountOfInvoice', $parameters, $objecttmp, $action);
390 if (!empty($remaintopay = $hookmanager->resArray[
'remaintopay'])) {
391 $objecttmp->resteapayer = $remaintopay;
393 } elseif ($reshook < 0) {
395 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"ProcessingError"), $hookmanager->errors,
'errors');
400 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"Draft"), $objecttmp->errors,
'errors');
401 } elseif ($objecttmp->paid || $objecttmp->resteapayer == 0) {
403 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AlreadyPaid"), $objecttmp->errors,
'errors');
404 } elseif ($objecttmp->resteapayer < 0) {
406 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AmountMustBePositive"), $objecttmp->errors,
'errors');
409 $rsql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
410 $rsql .=
" , pfd.date_traite as date_traite";
411 $rsql .=
" , pfd.amount";
412 $rsql .=
" , u.rowid as user_id, u.lastname, u.firstname, u.login";
413 $rsql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
414 $rsql .=
" , ".MAIN_DB_PREFIX.
"user as u";
415 $rsql .=
" WHERE fk_facture_fourn = ".((int) $objecttmp->id);
416 $rsql .=
" AND pfd.fk_user_demande = u.rowid";
417 $rsql .=
" AND pfd.traite = 0";
418 $rsql .=
" ORDER BY pfd.date_demande DESC";
421 $result_sql = $db->query($rsql);
423 $numprlv = $db->num_rows($result_sql);
429 $sqlPending1 =
"SELECT SUM(pfd.amount) as amount";
430 $sqlPending1 .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
431 $sqlPending1 .=
" WHERE pfd.fk_facture_fourn = ".((int) $objecttmp->id);
432 $sqlPending1 .=
" AND pfd.traite = 0";
433 $resPending1 = $db->query($sqlPending1);
435 $objPending1 = $db->fetch_object($resPending1);
437 $pending += (float) $objPending1->amount;
440 $db->free($resPending1);
442 $sqlPending2 =
"SELECT SUM(pl.amount) as amount";
443 $sqlPending2 .=
" FROM ".$db->prefix().
"prelevement_lignes as pl";
444 $sqlPending2 .=
" INNER JOIN ".$db->prefix().
"prelevement as p ON p.fk_prelevement_lignes = pl.rowid";
445 $sqlPending2 .=
" WHERE p.fk_facture_fourn = ".((int) $objecttmp->id);
446 $sqlPending2 .=
" AND (pl.statut IS NULL OR pl.statut = 0)";
447 $resPending2 = $db->query($sqlPending2);
449 if ($objPending2 = $db->fetch_object($resPending2)) {
450 $pending += (float) $objPending2->amount;
453 $db->free($resPending2);
454 $remaintopaylesspendingdebit = $objecttmp->resteapayer - $pending;
456 if ($remaintopaylesspendingdebit <= 0) {
458 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AmountRequestedAlreadyReachesTotal"), $objecttmp->errors,
'warnings');
459 } elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code !=
'VIR') {
460 $langs->load(
"errors");
462 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"ErrorThisPaymentModeIsNotCreditTransfer"), $objecttmp->errors,
'errors');
464 $listofbills[] = $objecttmp;
470 if (!empty($listofbills)) {
471 $nbwithdrawrequestok = 0;
472 foreach ($listofbills as $aBill) {
479 $sql =
"SELECT SUM(pfd.amount) as amount";
480 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
482 $sql .=
" WHERE pfd.fk_facture_fourn = ".((int) $aBill->id);
486 $sql .=
" AND pfd.traite = 0";
488 $resql = $db->query($sql);
490 $obj = $db->fetch_object($resql);
492 $pending += (float) $obj->amount;
495 dol_print_error($db);
498 $sqlPending =
"SELECT SUM(pl.amount) as amount";
499 $sqlPending .=
" FROM ".$db->prefix().
"prelevement_lignes as pl";
500 $sqlPending .=
" INNER JOIN ".$db->prefix().
"prelevement as p ON p.fk_prelevement_lignes = pl.rowid";
502 $sqlPending .=
" WHERE p.fk_facture_fourn = ".((int) $aBill->id);
506 $sqlPending .=
" AND (pl.statut IS NULL OR pl.statut = 0)";
507 $resPending = $db->query($sqlPending);
509 if ($objPending = $db->fetch_object($resPending)) {
510 $pending += (float) $objPending->amount;
513 $db->free($resPending);
515 $requestAmount = $aBill->resteapayer - $pending;
516 if ($requestAmount > 0) {
518 $result = $aBill->demande_prelevement($user, $requestAmount,
'bank-transfer',
'supplier_invoice');
521 $nbwithdrawrequestok++;
524 setEventMessages($aBill->error, $aBill->errors,
'errors');
527 $aBill->error =
'WithdrawRequestErrorNilAmount';
528 $aBill->errors[] = $aBill->error;
529 setEventMessages($aBill->error, $aBill->errors,
'errors');
532 if ($nbwithdrawrequestok > 0) {
533 setEventMessages($langs->trans(
"WithdrawRequestsDone", $nbwithdrawrequestok),
null,
'mesgs');
545$form =
new Form($db);
549$accountstatic =
new Account($db);
552$subtypearray =
$object->getArrayOfInvoiceSubtypes(0);
559 if (empty($search_company)) {
560 $search_company = $soc->name;
564$title = $langs->trans(
"BillsSuppliers").($socid && ($soc !==
null) ?
' - '.$soc->name :
'');
565$help_url =
'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores';
570$sql .=
" f.rowid as facid, f.ref, f.ref_supplier, f.type, f.subtype, f.datef, f.date_lim_reglement as datelimite, f.fk_mode_reglement, f.fk_cond_reglement, ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number as bnumber, ba.account_number as baccount_number, ba.fk_accountancy_journal as baccountancy_journal, f.vat_reverse_charge,";
571$sql .=
" f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.close_code, f.fk_statut as fk_statut, f.libelle as label, f.datec as date_creation, f.tms as date_modification,";
572$sql .=
" f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,";
573$sql .=
' f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva as multicurrency_total_vat, f.multicurrency_total_ttc,';
574$sql .=
" f.note_public, f.note_private,";
575$sql .=
" f.fk_user_author,";
576$sql .=
" s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta as code_compta_client, s.code_compta_fournisseur,";
577$sql .=
" typent.code as typent_code,";
578$sql .=
" state.code_departement as state_code, state.nom as state_name,";
579$sql .=
" country.code as country_code,";
580$sql .=
" p.rowid as project_id, p.ref as project_ref, p.title as project_label,";
581$sql .=
' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender';
583if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
584 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
585 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
589$parameters = array();
590$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
591$sql .= $hookmanager->resPrint;
592$sql = preg_replace(
'/,\s*$/',
'', $sql);
596$sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
597$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
598$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
599$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
600$sql .=
', '.MAIN_DB_PREFIX.
'facture_fourn as f';
601if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
602 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (f.rowid = ef.fk_object)";
604$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user AS u ON f.fk_user_author = u.rowid';
605$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = f.fk_projet";
606$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON ba.rowid = f.fk_account';
607if ($search_user > 0) {
608 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
609 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
612$parameters = array();
613$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
614$sql .= $hookmanager->resPrint;
615$sql .=
' WHERE f.fk_soc = s.rowid';
616$sql .=
' AND f.entity IN ('.getEntity(
'facture_fourn').
')';
618 $sql .=
' AND s.rowid = '.((int) $socid);
621 if (is_numeric($search_ref)) {
630if ($search_refsupplier) {
633if ($search_type !=
'' && $search_type >= 0) {
634 if ($search_type ==
'0') {
635 $sql .=
" AND f.type = 0";
637 if ($search_type ==
'1') {
638 $sql .=
" AND f.type = 1";
640 if ($search_type ==
'2') {
641 $sql .=
" AND f.type = 2";
643 if ($search_type ==
'3') {
644 $sql .=
" AND f.type = 3";
649if ($search_subtype !=
'' && $search_subtype !=
'-1') {
650 $sql .=
" AND f.subtype IN (".$db->sanitize($db->escape($search_subtype)).
")";
652if ($search_project) {
655if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
656 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
658 if ($search_company) {
661 if ($search_company_alias) {
674if (strlen(trim($search_country))) {
676 $country_code_in_EEC = $country_code_in_EEC_without_me =
'';
677 foreach ($arrayofcode as $key => $value) {
678 $country_code_in_EEC .= ($country_code_in_EEC ?
"," :
"").
"'".$value.
"'";
679 if ($value !=
$mysoc->country_code) {
680 $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ?
"," :
"").
"'".$value.
"'";
683 if ($search_country ==
'special_allnotme') {
684 $sql .=
" AND country.code <> '".$db->escape(
$mysoc->country_code).
"'";
685 } elseif ($search_country ==
'special_eec') {
686 $sql .=
" AND country.code IN (".$db->sanitize($country_code_in_EEC, 1).
")";
687 } elseif ($search_country ==
'special_eecnotme') {
688 $sql .=
" AND country.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).
")";
689 } elseif ($search_country ==
'special_noteec') {
690 $sql .=
" AND country.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).
")";
695if ($search_type_thirdparty !=
'' && $search_type_thirdparty >= 0) {
696 $sql .=
" AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).
')';
698if ($search_montant_ht !=
'') {
701if ($search_montant_vat !=
'') {
704if ($search_montant_localtax1 !=
'') {
705 $sql .=
natural_search(
'f.localtax1', $search_montant_localtax1, 1);
707if ($search_montant_localtax2 !=
'') {
708 $sql .=
natural_search(
'f.localtax2', $search_montant_localtax2, 1);
710if ($search_montant_ttc !=
'') {
713if ($search_multicurrency_code !=
'') {
714 $sql .=
" AND f.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
716if ($search_multicurrency_tx !=
'') {
717 $sql .=
natural_search(
'f.multicurrency_tx', $search_multicurrency_tx, 1);
719if ($search_multicurrency_montant_ht !=
'') {
720 $sql .=
natural_search(
'f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
722if ($search_multicurrency_montant_vat !=
'') {
723 $sql .=
natural_search(
'f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
725if ($search_multicurrency_montant_ttc !=
'') {
726 $sql .=
natural_search(
'f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
729 $sql .=
natural_search(array(
'u.login',
'u.lastname',
'u.firstname'), $search_login);
731if (is_array($search_status) && count($search_status) > 0) {
732 $search_statusArray = $search_status;
733 $sql .=
" AND f.fk_statut IN (" . $db->sanitize(implode(
',', array_map(
'intval', $search_statusArray))) .
")";
735if ($search_paymentmode > 0) {
736 $sql .=
" AND f.fk_mode_reglement = ".((int) $search_paymentmode);
738if ($search_paymentcond > 0) {
739 $sql .=
" AND f.fk_cond_reglement = ".((int) $search_paymentcond);
741if ($search_bankaccount > 0) {
742 $sql .=
" AND ba.rowid = ".((int) $search_bankaccount);
744if ($search_vat_reverse_charge !==
'' && $search_vat_reverse_charge !==
'-1') {
745 $sql .=
" AND f.vat_reverse_charge = ".((int) $search_vat_reverse_charge);
747if ($search_date_start) {
748 $sql .=
" AND f.datef >= '" . $db->idate($search_date_start) .
"'";
750if ($search_date_end) {
751 $sql .=
" AND f.datef <= '" . $db->idate($search_date_end) .
"'";
753if ($search_note_public) {
754 $sql .=
" AND f.note_public LIKE '%".$db->escape($db->escapeforlike($search_note_public)).
"%'";
756if ($search_note_private) {
757 $sql .=
" AND f.note_private LIKE '%".$db->escape($db->escapeforlike($search_note_private)).
"%'";
759if ($search_datelimit_start) {
760 $sql .=
" AND f.date_lim_reglement >= '" . $db->idate($search_datelimit_start) .
"'";
762if ($search_datelimit_end) {
763 $sql .=
" AND f.date_lim_reglement <= '" . $db->idate($search_datelimit_end) .
"'";
765if ($option ==
'late') {
766 $sql .=
" AND f.date_lim_reglement < '".$db->idate(
dol_now() -
$conf->facture->fournisseur->warning_delay).
"'";
771if ($search_fk_fac_rec_source) {
772 $sql .=
" AND f.fk_fac_rec_source = ".(int) $search_fk_fac_rec_source;
775if ($search_sale && $search_sale !=
'-1') {
776 if ($search_sale == -2) {
777 $sql .=
" AND ".getSalesRepresentativeSqlFilter(
'f.fk_soc', 0, 1);
778 } elseif ($search_sale > 0) {
779 $sql .=
" AND ".getSalesRepresentativeSqlFilter(
'f.fk_soc', (
int) $search_sale);
783if (!empty($searchCategorySupplierInvoiceList)) {
784 $searchCategorySupplierInvoiceSqlList = array();
785 $listofcategoryid =
'';
786 foreach ($searchCategorySupplierInvoiceList as $searchCategorySupplierInvoice) {
787 if (intval($searchCategorySupplierInvoice) == -2) {
788 $searchCategorySupplierInvoiceSqlList[] =
"NOT EXISTS (SELECT ck.fk_supplier_invoice FROM ".MAIN_DB_PREFIX.
"categorie_supplier_invoice as ck WHERE f.rowid = ck.fk_supplier_invoice)";
789 } elseif (intval($searchCategorySupplierInvoice) > 0) {
790 if ($searchCategorySupplierInvoiceOperator == 0) {
791 $searchCategorySupplierInvoiceSqlList[] =
" EXISTS (SELECT ck.fk_supplier_invoice FROM ".MAIN_DB_PREFIX.
"categorie_supplier_invoice as ck WHERE f.rowid = ck.fk_supplier_invoice AND ck.fk_categorie = ".((int) $searchCategorySupplierInvoice).
")";
793 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategorySupplierInvoice);
797 if ($listofcategoryid) {
798 $searchCategorySupplierInvoiceSqlList[] =
" EXISTS (SELECT ck.fk_supplier_invoice FROM ".MAIN_DB_PREFIX.
"categorie_supplier_invoice as ck WHERE f.rowid = ck.fk_supplier_invoice AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
800 if ($searchCategorySupplierInvoiceOperator == 1) {
801 if (!empty($searchCategorySupplierInvoiceSqlList)) {
802 $sql .=
" AND (".implode(
' OR ', $searchCategorySupplierInvoiceSqlList).
")";
805 if (!empty($searchCategorySupplierInvoiceSqlList)) {
806 $sql .=
" AND (".implode(
' AND ', $searchCategorySupplierInvoiceSqlList).
")";
810$searchCategorySupplierList = $search_categ_sup ? array($search_categ_sup) : array();
811$searchCategorySupplierOperator = 0;
813if (!empty($searchCategorySupplierList)) {
814 $searchCategorySupplierSqlList = array();
815 $listofcategoryid =
'';
816 foreach ($searchCategorySupplierList as $searchCategorySupplier) {
817 if (intval($searchCategorySupplier) == -2) {
818 $searchCategorySupplierSqlList[] =
"NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)";
819 } elseif (intval($searchCategorySupplier) > 0) {
820 if ($searchCategorySupplierOperator == 0) {
821 $searchCategorySupplierSqlList[] =
" EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategorySupplier).
")";
823 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategorySupplier);
827 if ($listofcategoryid) {
828 $searchCategorySupplierSqlList[] =
" EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
830 if ($searchCategorySupplierOperator == 1) {
831 if (!empty($searchCategorySupplierSqlList)) {
832 $sql .=
" AND (".implode(
' OR ', $searchCategorySupplierSqlList).
")";
835 if (!empty($searchCategorySupplierSqlList)) {
836 $sql .=
" AND (".implode(
' AND ', $searchCategorySupplierSqlList).
")";
841$searchCategoryProductList = $search_product_category ? array($search_product_category) : array();
842$searchCategoryProductOperator = 0;
843if (!empty($searchCategoryProductList)) {
844 $searchCategoryProductSqlList = array();
845 $listofcategoryid =
'';
846 foreach ($searchCategoryProductList as $searchCategoryProduct) {
847 if (intval($searchCategoryProduct) == -2) {
848 $searchCategoryProductSqlList[] =
"NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND fd.fk_product = ck.fk_product)";
849 } elseif (intval($searchCategoryProduct) > 0) {
850 if ($searchCategoryProductOperator == 0) {
851 $searchCategoryProductSqlList[] =
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND fd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).
")";
853 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
857 if ($listofcategoryid) {
858 $searchCategoryProductSqlList[] =
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND fd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
860 if ($searchCategoryProductOperator == 1) {
861 if (!empty($searchCategoryProductSqlList)) {
862 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
865 if (!empty($searchCategoryProductSqlList)) {
866 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
870if ($filter && $filter != -1) {
871 $aFilter = explode(
',', $filter);
872 foreach ($aFilter as $fil) {
873 $filt = explode(
':', $fil);
876 if (count($filt) < 2) {
879 $sql .=
" AND ".$db->sanitize(trim($filt[0])).
" = '".$db->escape(trim($filt[1])).
"'";
884 unset($fieldstosearchall[
'pd.description']);
886 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all, 0, 1);
887 $sql .=
" OR EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX.
"facture_fourn_det as pd WHERE f.rowid = pd.fk_facture_fourn AND pd.description LIKE '%".$db->escape($db->escapeforlike($search_all)).
"%')";
889 $fieldstosearchall[
'pd.description'] =
'Description';
892if ($search_user > 0) {
893 $sql .=
" AND ec.fk_c_type_contact = tc.rowid AND tc.element='invoice_supplier' AND tc.source='internal' AND ec.element_id = f.rowid AND ec.fk_socpeople = ".((int) $search_user);
896include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
898$parameters = array();
899$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
900if (empty($reshook)) {
901 $sql .= $hookmanager->resPrint;
903 $sql = $hookmanager->resPrint;
907$parameters = array();
908$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object, $action);
909if (empty($reshook)) {
910 $sql .= empty($hookmanager->resPrint) ?
"" :
" HAVING 1=1 ".$hookmanager->resPrint;
912 $sql = $hookmanager->resPrint;
916$nbtotalofrecords =
'';
919 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
921 $resql = $db->query($sqlforcount);
923 $objforcount = $db->fetch_object($resql);
924 $nbtotalofrecords = $objforcount->nbtotalofrecords;
926 dol_print_error($db);
929 if (($page * $limit) > (
int) $nbtotalofrecords) {
937$sql .= $db->order($sortfield, $sortorder);
939 $sql .= $db->plimit($limit + 1, $offset);
943$resql = $db->query($sql);
945 dol_print_error($db);
949$num = $db->num_rows($resql);
952if ($num == 1 &&
getDolGlobalInt(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
953 $obj = $db->fetch_object($resql);
955 header(
"Location: ".DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.
$id);
962llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist mod-fourn-facture page-list');
964if ($search_fk_fac_rec_source) {
965 require_once DOL_DOCUMENT_ROOT .
'/fourn/class/fournisseur.facture-rec.class.php';
966 require_once DOL_DOCUMENT_ROOT .
'/core/lib/invoice.lib.php';
968 $object->fetch((
int) $search_fk_fac_rec_source);
977 if (empty($search_company)) {
978 $search_company = $soc->name;
979 $search_company_alias = $soc->name_alias;
983$arrayofselected = is_array($toselect) ? $toselect : array();
985$param =
'&socid='.$socid;
987 $param .=
'&mode='.urlencode($mode);
989if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
990 $param .=
'&contextpage='.urlencode($contextpage);
992if ($limit > 0 && $limit !=
$conf->liste_limit) {
993 $param .=
'&limit='.((int) $limit);
995if ($optioncss !=
'') {
996 $param .=
'&optioncss='.urlencode($optioncss);
999 $param .=
'&search_all='.urlencode($search_all);
1001if ($search_date_start) {
1002 $param .=
buildParamDate(
'search_date_start',
null,
'',
'tzserver');
1004if ($search_date_end) {
1005 $param .=
buildParamDate(
'search_date_end',
null,
'',
'tzserver');
1007if ($search_datelimit_startday) {
1008 $param .=
'&search_datelimit_startday='.urlencode((
string) ($search_datelimit_startday));
1010if ($search_datelimit_startmonth) {
1011 $param .=
'&search_datelimit_startmonth='.urlencode((
string) ($search_datelimit_startmonth));
1013if ($search_datelimit_startyear) {
1014 $param .=
'&search_datelimit_startyear='.urlencode((
string) ($search_datelimit_startyear));
1016if ($search_datelimit_endday) {
1017 $param .=
'&search_datelimit_endday='.urlencode((
string) ($search_datelimit_endday));
1019if ($search_datelimit_endmonth) {
1020 $param .=
'&search_datelimit_endmonth='.urlencode((
string) ($search_datelimit_endmonth));
1022if ($search_datelimit_endyear) {
1023 $param .=
'&search_datelimit_endyear='.urlencode((
string) ($search_datelimit_endyear));
1026 $param .=
'&search_ref='.urlencode($search_ref);
1028if ($search_refsupplier) {
1029 $param .=
'&search_refsupplier='.urlencode($search_refsupplier);
1031if ($search_type !=
'') {
1032 $param .=
'&search_type='.urlencode($search_type);
1034if ($search_subtype !=
'') {
1035 $param .=
'&search_subtype='.urlencode($search_subtype);
1038 $param .=
'&search_label='.urlencode($search_label);
1040if ($search_company) {
1041 $param .=
'&search_company='.urlencode($search_company);
1043if ($search_company_alias) {
1044 $param .=
'&search_company_alias='.urlencode($search_company_alias);
1047 $param .=
'&search_login='.urlencode($search_login);
1049if ($searchCategorySupplierInvoiceOperator == 1) {
1050 $param .=
"&search_category_supplier_invoice_operator=".urlencode((
string) ($searchCategorySupplierInvoiceOperator));
1052foreach ($searchCategorySupplierInvoiceList as $searchCategorySupplierInvoice) {
1053 $param .=
"&search_category_invoice_list[]=".urlencode($searchCategorySupplierInvoice);
1055if ($search_montant_ht !=
'') {
1056 $param .=
'&search_montant_ht='.urlencode($search_montant_ht);
1058if ($search_montant_vat !=
'') {
1059 $param .=
'&search_montant_vat='.urlencode($search_montant_vat);
1061if ($search_montant_localtax1 !=
'') {
1062 $param .=
'&search_montant_localtax1='.urlencode($search_montant_localtax1);
1064if ($search_montant_localtax2 !=
'') {
1065 $param .=
'&search_montant_localtax2='.urlencode($search_montant_localtax2);
1067if ($search_montant_ttc !=
'') {
1068 $param .=
'&search_montant_ttc='.urlencode($search_montant_ttc);
1070if ($search_multicurrency_code !=
'') {
1071 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1073if ($search_multicurrency_tx !=
'') {
1074 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1076if ($search_multicurrency_montant_ht !=
'') {
1077 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1079if ($search_multicurrency_montant_vat !=
'') {
1080 $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
1082if ($search_multicurrency_montant_ttc !=
'') {
1083 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1085if ($search_amount_no_tax) {
1086 $param .=
'&search_amount_no_tax='.urlencode($search_amount_no_tax);
1088if ($search_amount_all_tax) {
1089 $param .=
'&search_amount_all_tax='.urlencode($search_amount_all_tax);
1091if ($search_status !=
'') {
1092 if (is_array($search_status)) {
1093 foreach ($search_status as $key => $val) {
1094 $param .=
'&search_status[]='.urlencode($val);
1097 $param .=
'&search_status='.urlencode($search_status);
1100if ($search_paymentmode) {
1101 $param .=
'&search_paymentmode='.urlencode((
string) ($search_paymentmode));
1103if ($search_paymentcond) {
1104 $param .=
'&search_paymentcond='.urlencode((
string) ($search_paymentcond));
1106if ($search_bankaccount > 0) {
1107 $param .=
'&search_bankaccount='.urlencode((
string) ($search_bankaccount));
1109if ($search_vat_reverse_charge !==
'' && $search_vat_reverse_charge !==
'-1') {
1110 $param .=
'&search_vat_reverse_charge='.urlencode($search_vat_reverse_charge);
1113 $param .=
'&show_files='.urlencode((
string) ($show_files));
1116 $param .=
"&search_option=".urlencode($option);
1118if ($search_categ_sup > 0) {
1119 $param .=
'&search_categ_sup='.$search_categ_sup;
1121if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
1122 $param .=
'&search_type_thirdparty='.$search_type_thirdparty;
1124if ($search_fk_fac_rec_source) {
1125 $param .=
'&search_fk_fac_rec_source=' . (int) $search_fk_fac_rec_source;
1129include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1131$parameters = array(
'param' => &$param);
1132$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1133$param .= $hookmanager->resPrint;
1136$arrayofmassactions = array(
1137 'validate' => img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate"),
1138 'generate_doc' => img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1139 'builddoc' => img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1142if (
isModEnabled(
'category') && $user->hasRight(
"fournisseur",
"facture",
"lire")) {
1143 $arrayofmassactions[
'preaffecttag'] = img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"AffectTag");
1145if (
isModEnabled(
'paymentbybanktransfer') && $user->hasRight(
"paymentbybanktransfer",
"create")) {
1146 $langs->load(
'withdrawals');
1147 $arrayofmassactions[
'banktransfertrequest'] = img_picto(
'',
'payment',
'class="pictofixedwidth"').$langs->trans(
"MakeBankTransferOrder");
1149if (!empty($permissiontodelete)) {
1150 $arrayofmassactions[
'predelete'] = img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1152if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
1153 $arrayofmassactions = array();
1155$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1157$url = DOL_URL_ROOT.
'/fourn/facture/card.php?action=create';
1159 $url .=
'&socid='.urlencode((
string) (
$object->socid));
1162 $url .=
'&fac_rec='.urlencode((
string)
$object->id);
1165print
'<form method="POST" id="searchFormList" name="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
1166if ($optioncss !=
'') {
1167 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1169print
'<input type="hidden" name="token" value="'.newToken().
'">';
1170print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1171print
'<input type="hidden" name="action" value="list">';
1172print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1173print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1174print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1175print
'<input type="hidden" name="page" value="'.$page.
'">';
1176print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1177print
'<input type="hidden" name="page_y" value="">';
1178print
'<input type="hidden" name="mode" value="'.$mode.
'">';
1181$newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=common'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ((empty($mode) || $mode ==
'common') ? 2 : 1), array(
'morecss' =>
'reposition'));
1182$newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=kanban'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss' =>
'reposition'));
1183$newcardbutton .=
dolGetButtonTitle($langs->trans(
'Statistics'),
'',
'fa fa-chart-bar imgforviewmode', DOL_URL_ROOT.
'/compta/facture/stats/index.php?mode=supplier'.preg_replace(
'/(&|\?)*(mode|groupby)=[^&]+/',
'', $param),
'', ($mode ==
'statistics' ? 2 : 1), array(
'morecss' =>
'reposition'));
1185$newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewBill'),
'',
'fa fa-plus-circle', $url,
'', (
int) ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer")));
1187print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'supplier_invoice', 0, $newcardbutton,
'', $limit, 0, 0, 1);
1190$topicmail =
"SendBillRef";
1191$modelmail =
"invoice_supplier_send";
1193$trackid =
'sinv'.$object->id;
1194include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1198 foreach ($fieldstosearchall as $key => $val) {
1199 $fieldstosearchall[$key] = $langs->trans($val);
1200 $setupstring .= $key.
"=".$val.
";";
1202 print
'<!-- Search done like if SUPPLIER_INVOICE_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
1203 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>'.
"\n";
1208if (
isModEnabled(
'category') && $user->hasRight(
'categorie',
'read')) {
1209 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcategory.class.php';
1211 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_SUPPLIER_INVOICE, $searchCategorySupplierInvoiceList,
'minwidth300', $searchCategorySupplierInvoiceOperator ? $searchCategorySupplierInvoiceOperator : 0);
1213if ($user->hasRight(
"user",
"user",
"lire")) {
1214 $langs->load(
"commercial");
1215 $moreforfilter .=
'<div class="divsearchfield">';
1216 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1217 $moreforfilter .= img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth200');
1218 $moreforfilter .=
'</div>';
1221if ($user->hasRight(
"user",
"user",
"lire")) {
1222 $moreforfilter .=
'<div class="divsearchfield">';
1223 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1224 $moreforfilter .= img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
null, 0,
'',
'',
'', 0, 0,
'', 0,
'',
'maxwidth200');
1225 $moreforfilter .=
'</div>';
1228if (
isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
1229 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1230 $moreforfilter .=
'<div class="divsearchfield">';
1231 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1232 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 0, 0, 1);
1233 $moreforfilter .= img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0,
'', 0, 0, 0,
'',
'maxwidth300 widthcentpercentminusx', 1);
1234 $moreforfilter .=
'</div>';
1238 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1239 $moreforfilter .=
'<div class="divsearchfield">';
1240 $tmptitle = $langs->trans(
'SuppliersCategoriesShort');
1241 $moreforfilter .= img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$formother->select_categories(
'supplier', $search_categ_sup,
'search_categ_sup', 1, $tmptitle);
1242 $moreforfilter .=
'</div>';
1244$parameters = array();
1245$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1246if (empty($reshook)) {
1247 $moreforfilter .= $hookmanager->resPrint;
1249 $moreforfilter = $hookmanager->resPrint;
1252if (!empty($moreforfilter)) {
1253 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1254 print $moreforfilter;
1258$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1259$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
1260$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
1261$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1263print
'<div class="div-table-responsive">';
1264print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1268print
'<tr class="liste_titre_filter">';
1270if (
$conf->main_checkbox_left_column) {
1271 print
'<td class="liste_titre center maxwidthsearch">';
1272 $searchpicto = $form->showFilterButtons(
'left');
1277if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1278 print
'<td class="liste_titre left">';
1279 print
'<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1283if (!empty($arrayfields[
'f.ref_supplier'][
'checked'])) {
1284 print
'<td class="liste_titre">';
1285 print
'<input class="flat maxwidth75" type="text" name="search_refsupplier" value="'.dol_escape_htmltag($search_refsupplier).
'">';
1289if (!empty($arrayfields[
'f.type'][
'checked'])) {
1290 print
'<td class="liste_titre maxwidthonsmartphone">';
1297 print $form->selectarray(
'search_type', $typearray, $search_type, 1, 0, 0,
'', 0, 0, 0,
'ASC',
'maxwidth100');
1301if (!empty($arrayfields[
'f.subtype'][
'checked'])) {
1302 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1303 print $form->selectarray(
'search_subtype', $subtypearray, $search_subtype, 1, 0, 0,
'', 0, 0, 0,
'',
'maxwidth100');
1307if (!empty($arrayfields[
'f.label'][
'checked'])) {
1308 print
'<td class="liste_titre">';
1309 print
'<input class="flat maxwidth75" type="text" name="search_label" value="'.dol_escape_htmltag($search_label).
'">';
1313if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1314 print
'<td class="liste_titre center">';
1315 print
'<div class="nowrapfordate">';
1316 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1318 print
'<div class="nowrapfordate">';
1319 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1324if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1325 print
'<td class="liste_titre center">';
1326 print
'<div class="">';
1333 print $form->selectDate($search_datelimit_end ? $search_datelimit_end : -1,
'search_datelimit_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"Before"));
1335 print
'<div class="nowraponall inline-block valignmiddle"><input type="checkbox" class="valignmiddle" name="search_option" id="search_option" value="late"'.($option ==
'late' ?
' checked' :
'').
'><label for="search_option" class="valignmiddle">'.$langs->trans(
"Alert").
'</label></div>';
1340if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1341 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_project" value="'.dol_escape_htmltag($search_project).
'"></td>';
1344if (!empty($arrayfields[
's.nom'][
'checked'])) {
1345 print
'<td class="liste_titre"><input class="flat maxwidth100" type="text" name="search_company" value="'.dol_escape_htmltag((
string) $search_company).
'"'.($socid > 0 ?
" disabled" :
"").
'></td>';
1348if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1349 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).
'"></td>';
1352if (!empty($arrayfields[
's.town'][
'checked'])) {
1353 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
1356if (!empty($arrayfields[
's.zip'][
'checked'])) {
1357 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
1360if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1361 print
'<td class="liste_titre">';
1362 print
'<input class="flat maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1366if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1367 print
'<td class="liste_titre center">';
1368 print $form->select_country($search_country,
'search_country',
'', 0,
'minwidth150imp maxwidth150',
'code2', 1, 0, 1, array(), 1);
1372if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1373 print
'<td class="liste_titre maxwidthonsmartphone center">';
1374 print $form->selectarray(
"search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0,
'', 0, 0, 0,
getDolGlobalString(
'SOCIETE_SORT_ON_TYPEENT',
'ASC'),
'', 1);
1378if (!empty($arrayfields[
'f.vat_reverse_charge'][
'checked'])) {
1379 print
'<td class="liste_titre center">';
1380 print $form->selectyesno(
'search_vat_reverse_charge', $search_vat_reverse_charge, 1, 0, 1, 1);
1384if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1385 print
'<td class="liste_titre left">';
1386 print $form->getSelectConditionsPaiements($search_paymentcond,
'search_paymentcond', -1, 1, 1,
'maxwidth100');
1390if (!empty($arrayfields[
'ba.label'][
'checked'])) {
1391 print
'<td class="liste_titre">';
1392 $form->select_comptes($search_bankaccount,
'search_bankaccount', 0,
'', 1,
'', 0,
'maxwidth125');
1396if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1397 print
'<td class="liste_titre">';
1398 print $form->select_types_paiements($search_paymentmode,
'search_paymentmode',
'', 0, 1, 1, 20, 1,
'maxwidth100', 1);
1401if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1403 print
'<td class="liste_titre right">';
1404 print
'<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).
'">';
1407if (!empty($arrayfields[
'f.total_vat'][
'checked'])) {
1409 print
'<td class="liste_titre right">';
1410 print
'<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).
'">';
1413if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1415 print
'<td class="liste_titre right">';
1416 print
'<input class="flat" type="text" size="5" name="search_montant_localtax1" value="'.dol_escape_htmltag($search_montant_localtax1).
'">';
1419if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1421 print
'<td class="liste_titre right">';
1422 print
'<input class="flat" type="text" size="5" name="search_montant_localtax2" value="'.dol_escape_htmltag($search_montant_localtax2).
'">';
1425if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1427 print
'<td class="liste_titre right">';
1428 print
'<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).
'">';
1431if (!empty($arrayfields[
'supplier_available_discount'][
'checked'])) {
1432 print
'<td class="liste_titre"></td>';
1434if (!empty($arrayfields[
'f.nb_docs'][
'checked'])) {
1436 print
'<td class="liste_titre" align="center">';
1439if (!empty($arrayfields[
'u.login'][
'checked'])) {
1441 print
'<td class="liste_titre" align="center">';
1442 print
'<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).
'">';
1445if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1446 print
'<td class="liste_titre right">';
1449if (!empty($arrayfields[
'rtp'][
'checked'])) {
1450 print
'<td class="liste_titre">';
1453if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1455 print
'<td class="liste_titre">';
1456 print $form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1459if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1461 print
'<td class="liste_titre">';
1462 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1465if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1467 print
'<td class="liste_titre right">';
1468 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1471if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1473 print
'<td class="liste_titre right">';
1474 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).
'">';
1477if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1479 print
'<td class="liste_titre right">';
1480 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1483if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1484 print
'<td class="liste_titre">';
1487if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1488 print
'<td class="liste_titre right">';
1492include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1495$parameters = array(
'arrayfields' => $arrayfields);
1496$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1497print $hookmanager->resPrint;
1499if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1500 print
'<td class="liste_titre">';
1504if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1505 print
'<td class="liste_titre">';
1508if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
1510 print
'<td class="liste_titre">';
1511 print
'<input class="flat maxwidth75" type="text" name="search_note_public" value="'.dol_escape_htmltag($search_note_public).
'">';
1514if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
1516 print
'<td class="liste_titre">';
1517 print
'<input class="flat maxwidth75" type="text" name="search_note_private" value="'.dol_escape_htmltag($search_note_private).
'">';
1521if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1522 print
'<td class="liste_titre center minwidth75imp parentonrightofpage">';
1523 $liststatus = array(
'0' => $langs->trans(
"Draft"),
'1' => $langs->trans(
"Unpaid"),
'2' => $langs->trans(
"Paid"));
1525 print $form->multiselectarray(
'search_status', $liststatus, (is_array($search_status) ? $search_status : array()), 0, 0,
'center search_status width100 onrightofpage', 1, 0);
1529if (!
$conf->main_checkbox_left_column) {
1530 print
'<td class="liste_titre center maxwidthsearch actioncolumn">';
1531 $searchpicto = $form->showFilterButtons();
1538$totalarray = array();
1539$totalarray[
'nbfield'] = 0;
1543print
'<tr class="liste_titre">';
1545if (
$conf->main_checkbox_left_column) {
1546 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
1547 $totalarray[
'nbfield']++;
1549if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1550 print_liste_field_titre($arrayfields[
'f.ref'][
'label'], $_SERVER[
'PHP_SELF'],
'f.ref,f.rowid',
'', $param,
'', $sortfield, $sortorder);
1551 $totalarray[
'nbfield']++;
1553if (!empty($arrayfields[
'f.ref_supplier'][
'checked'])) {
1554 print_liste_field_titre($arrayfields[
'f.ref_supplier'][
'label'], $_SERVER[
"PHP_SELF"],
'f.ref_supplier',
'', $param,
'', $sortfield, $sortorder);
1555 $totalarray[
'nbfield']++;
1557if (!empty($arrayfields[
'f.type'][
'checked'])) {
1558 print_liste_field_titre($arrayfields[
'f.type'][
'label'], $_SERVER[
"PHP_SELF"],
'f.type',
'', $param,
'', $sortfield, $sortorder);
1559 $totalarray[
'nbfield']++;
1561if (!empty($arrayfields[
'f.subtype'][
'checked'])) {
1562 print_liste_field_titre($arrayfields[
'f.subtype'][
'label'], $_SERVER[
"PHP_SELF"],
'f.subtype',
'', $param,
'', $sortfield, $sortorder);
1564if (!empty($arrayfields[
'f.label'][
'checked'])) {
1565 print_liste_field_titre($arrayfields[
'f.label'][
'label'], $_SERVER[
'PHP_SELF'],
"f.libelle,f.rowid",
'', $param,
'', $sortfield, $sortorder);
1566 $totalarray[
'nbfield']++;
1568if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1569 print_liste_field_titre($arrayfields[
'f.datef'][
'label'], $_SERVER[
'PHP_SELF'],
'f.datef,f.rowid',
'', $param,
'', $sortfield, $sortorder,
'center ');
1570 $totalarray[
'nbfield']++;
1572if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1573 print_liste_field_titre($arrayfields[
'f.date_lim_reglement'][
'label'], $_SERVER[
'PHP_SELF'],
"f.date_lim_reglement",
'', $param,
'', $sortfield, $sortorder,
'center ');
1574 $totalarray[
'nbfield']++;
1576if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1577 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
'PHP_SELF'],
"p.ref",
'', $param,
'', $sortfield, $sortorder);
1578 $totalarray[
'nbfield']++;
1580if (!empty($arrayfields[
's.nom'][
'checked'])) {
1581 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
'PHP_SELF'],
's.nom',
'', $param,
'', $sortfield, $sortorder);
1582 $totalarray[
'nbfield']++;
1584if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1586 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
1587 $totalarray[
'nbfield']++;
1589if (!empty($arrayfields[
's.town'][
'checked'])) {
1590 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1591 $totalarray[
'nbfield']++;
1593if (!empty($arrayfields[
's.zip'][
'checked'])) {
1594 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1595 $totalarray[
'nbfield']++;
1597if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1598 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.name_alias",
"", $param,
'', $sortfield, $sortorder);
1599 $totalarray[
'nbfield']++;
1601if (!empty($arrayfields[
'state.name_alias'][
'checked'])) {
1602 print_liste_field_titre($arrayfields[
'state.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1603 $totalarray[
'nbfield']++;
1605if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1606 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1607 $totalarray[
'nbfield']++;
1609if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1610 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1611 $totalarray[
'nbfield']++;
1613if (!empty($arrayfields[
'f.vat_reverse_charge'][
'checked'])) {
1614 print_liste_field_titre($arrayfields[
'f.vat_reverse_charge'][
'label'], $_SERVER[
"PHP_SELF"],
"f.vat_reverse_charge",
"", $param,
"", $sortfield, $sortorder,
'center ');
1615 $totalarray[
'nbfield']++;
1617if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1618 print_liste_field_titre($arrayfields[
'f.fk_cond_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_cond_reglement",
"", $param,
"", $sortfield, $sortorder);
1619 $totalarray[
'nbfield']++;
1621if (!empty($arrayfields[
'ba.label'][
'checked'])) {
1622 print_liste_field_titre($arrayfields[
'ba.label'][
'label'], $_SERVER[
"PHP_SELF"],
"ba.label",
"", $param,
"", $sortfield, $sortorder);
1623 $totalarray[
'nbfield']++;
1625if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1626 print_liste_field_titre($arrayfields[
'f.fk_mode_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_mode_reglement",
"", $param,
"", $sortfield, $sortorder);
1627 $totalarray[
'nbfield']++;
1629if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1630 print_liste_field_titre($arrayfields[
'f.total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ht',
'', $param,
'', $sortfield, $sortorder,
'right ');
1631 $totalarray[
'nbfield']++;
1633if (!empty($arrayfields[
'f.total_vat'][
'checked'])) {
1634 print_liste_field_titre($arrayfields[
'f.total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_tva',
'', $param,
'', $sortfield, $sortorder,
'right ');
1635 $totalarray[
'nbfield']++;
1637if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1638 print_liste_field_titre($arrayfields[
'f.total_localtax1'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax1',
'', $param,
'', $sortfield, $sortorder,
'right ');
1639 $totalarray[
'nbfield']++;
1641if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1642 print_liste_field_titre($arrayfields[
'f.total_localtax2'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax2',
'', $param,
'', $sortfield, $sortorder,
'right ');
1643 $totalarray[
'nbfield']++;
1645if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1646 print_liste_field_titre($arrayfields[
'f.total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ttc',
'', $param,
'', $sortfield, $sortorder,
'right ');
1647 $totalarray[
'nbfield']++;
1649if (!empty($arrayfields[
'supplier_available_discount'][
'checked'])) {
1650 print_liste_field_titre($arrayfields[
'supplier_available_discount'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1651 $totalarray[
'nbfield']++;
1653if (!empty($arrayfields[
'f.nb_docs'][
'checked'])) {
1654 print_liste_field_titre($arrayfields[
'f.nb_docs'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1655 $totalarray[
'nbfield']++;
1657if (!empty($arrayfields[
'u.login'][
'checked'])) {
1658 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
'u.login',
'', $param,
'', $sortfield, $sortorder);
1659 $totalarray[
'nbfield']++;
1661if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1662 print_liste_field_titre($arrayfields[
'dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1663 $totalarray[
'nbfield']++;
1665if (!empty($arrayfields[
'rtp'][
'checked'])) {
1666 print_liste_field_titre($arrayfields[
'rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder);
1667 $totalarray[
'nbfield']++;
1669if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1670 print_liste_field_titre($arrayfields[
'f.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1671 $totalarray[
'nbfield']++;
1673if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1674 print_liste_field_titre($arrayfields[
'f.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1675 $totalarray[
'nbfield']++;
1677if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1678 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ht',
'', $param,
'"', $sortfield, $sortorder,
'right ');
1679 $totalarray[
'nbfield']++;
1681if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1682 print_liste_field_titre($arrayfields[
'f.multicurrency_total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_tva',
'', $param,
'', $sortfield, $sortorder,
'right ');
1683 $totalarray[
'nbfield']++;
1685if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1686 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ttc',
'', $param,
'', $sortfield, $sortorder,
'right ');
1687 $totalarray[
'nbfield']++;
1689if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1690 print_liste_field_titre($arrayfields[
'multicurrency_dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1691 $totalarray[
'nbfield']++;
1693if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1694 print_liste_field_titre($arrayfields[
'multicurrency_rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1695 $totalarray[
'nbfield']++;
1698include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1700$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &$totalarray);
1701$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1702print $hookmanager->resPrint;
1703if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1704 print_liste_field_titre($arrayfields[
'f.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"f.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1705 $totalarray[
'nbfield']++;
1707if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1708 print_liste_field_titre($arrayfields[
'f.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"f.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1709 $totalarray[
'nbfield']++;
1711if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
1712 print_liste_field_titre($arrayfields[
'f.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"f.note_public",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1713 $totalarray[
'nbfield']++;
1715if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
1716 print_liste_field_titre($arrayfields[
'f.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"f.note_private",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1717 $totalarray[
'nbfield']++;
1719if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1720 print_liste_field_titre($arrayfields[
'f.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"fk_statut,paye,type",
"", $param,
'', $sortfield, $sortorder,
'center ');
1721 $totalarray[
'nbfield']++;
1724if (!
$conf->main_checkbox_left_column) {
1725 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
1726 $totalarray[
'nbfield']++;
1732$projectstatic =
new Project($db);
1733$userstatic =
new User($db);
1739$savnbfield = $totalarray[
'nbfield'];
1740$totalarray = array();
1741$totalarray[
'nbfield'] = 0;
1742$totalarray[
'val'] = array();
1743$totalarray[
'val'][
'f.total_ht'] = 0;
1744$totalarray[
'val'][
'f.total_vat'] = 0;
1745$totalarray[
'val'][
'f.total_localtax1'] = 0;
1746$totalarray[
'val'][
'f.total_localtax2'] = 0;
1747$totalarray[
'val'][
'f.total_ttc'] = 0;
1748$totalarray[
'val'][
'totalam'] = 0;
1749$totalarray[
'val'][
'rtp'] = 0;
1750$supplierDiscountCache = array();
1752$imaxinloop = ($limit ? min($num, $limit) : $num);
1753while ($i < $imaxinloop) {
1754 $obj = $db->fetch_object($resql);
1759 $datelimit = $db->jdate($obj->datelimite);
1761 $userstatic->id = $obj->fk_user_author;
1762 $userstatic->login = $obj->login;
1763 $userstatic->lastname = $obj->lastname;
1764 $userstatic->firstname = $obj->firstname;
1765 $userstatic->email = $obj->user_email;
1766 $userstatic->statut = $obj->user_statut;
1767 $userstatic->status = $obj->user_statut;
1768 $userstatic->entity = $obj->entity;
1769 $userstatic->photo = $obj->photo;
1770 $userstatic->office_phone = $obj->office_phone;
1771 $userstatic->office_fax = $obj->office_fax;
1772 $userstatic->user_mobile = $obj->user_mobile;
1773 $userstatic->job = $obj->job;
1774 $userstatic->gender = $obj->gender;
1775 $facturestatic->id = $obj->facid;
1776 $facturestatic->ref = $obj->ref;
1777 $facturestatic->type = $obj->type;
1778 $facturestatic->subtype = $obj->subtype;
1779 $facturestatic->total_ht = $obj->total_ht;
1780 $facturestatic->total_tva = $obj->total_vat;
1781 $facturestatic->total_ttc = $obj->total_ttc;
1782 $facturestatic->close_code = $obj->close_code;
1783 $facturestatic->ref_supplier = $obj->ref_supplier;
1784 $facturestatic->date_echeance = $db->jdate($obj->datelimite);
1785 $facturestatic->statut = $obj->fk_statut;
1786 $facturestatic->status = $obj->fk_statut;
1787 $facturestatic->note_public = $obj->note_public;
1788 $facturestatic->note_private = $obj->note_private;
1789 $facturestatic->multicurrency_code = $obj->multicurrency_code;
1790 $facturestatic->multicurrency_tx = $obj->multicurrency_tx;
1791 $facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht;
1792 $facturestatic->multicurrency_total_tva = $obj->multicurrency_total_vat;
1793 $facturestatic->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
1794 $thirdparty->id = $obj->socid;
1795 $thirdparty->name = $obj->name;
1796 $thirdparty->name_alias = $obj->alias;
1797 $thirdparty->client = $obj->client;
1798 $thirdparty->fournisseur = $obj->fournisseur;
1799 $thirdparty->code_client = $obj->code_client;
1800 $thirdparty->code_compta_client = $obj->code_compta_client;
1801 $thirdparty->code_fournisseur = $obj->code_fournisseur;
1802 $thirdparty->code_compta_fournisseur = $obj->code_compta_fournisseur;
1803 $thirdparty->email = $obj->email;
1804 $thirdparty->country_code = $obj->country_code;
1806 $paiement = $facturestatic->getSommePaiement();
1807 $totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
1808 $totaldeposits = $facturestatic->getSumDepositsUsed();
1809 $totalpay = $paiement + $totalcreditnotes + $totaldeposits;
1810 $remaintopay = $obj->total_ttc - $totalpay;
1812 $multicurrency_paiement = $facturestatic->getSommePaiement(1);
1813 $multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
1814 $multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
1816 $totalpay = $paiement + $totalcreditnotes + $totaldeposits;
1817 $remaintopay =
price2num($facturestatic->total_ttc - $totalpay);
1819 $multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
1820 $multicurrency_remaintopay = (float)
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);
1824 $multicurrency_remaintopay = 0;
1827 $remaincreditnote = $discount->getAvailableDiscounts($thirdparty,
null,
'rc.fk_facture_source='.$facturestatic->id);
1828 $remaintopay = -$remaincreditnote;
1829 $totalpay =
price2num($facturestatic->total_ttc - $remaintopay);
1830 $multicurrency_remaincreditnote = $discount->getAvailableDiscounts($thirdparty,
null,
'rc.fk_facture_source='.$facturestatic->id, 0, 0, 1);
1831 $multicurrency_remaintopay = -$multicurrency_remaincreditnote;
1832 $multicurrency_totalpay = (float)
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_remaintopay);
1835 $facturestatic->alreadypaid = ($paiement ? $paiement : 0);
1837 $facturestatic->paye = $obj->paye;
1838 $facturestatic->paid = $obj->paye;
1840 $facturestatic->date = $db->jdate($obj->datef);
1846 if ($facturestatic->isCreditNoteUsed()) {
1847 $remaintopay = -$facturestatic->getSumFromThisCreditNotesNotUsed();
1851 if ($mode ==
'kanban') {
1853 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
1854 print
'<div class="box-flex-container kanban">';
1857 if ($massactionbutton || $massaction) {
1859 if (in_array(
$object->id, $arrayofselected)) {
1864 $arraydata = array(
'alreadypaid' => $paiement,
'thirdparty' => $thirdparty->getNomUrl(1,
'', 12),
'selected' => in_array(
$object->id, $arrayofselected));
1865 print $facturestatic->getKanbanView(
'', $arraydata);
1866 if ($i == ($imaxinloop - 1)) {
1873 print
'<tr data-rowid="'.$object->id.
'" class="oddeven row-with-select'.((
getDolGlobalInt(
'MAIN_FINISHED_LINES_OPACITY') == 1 && $obj->fk_statut > 1) ?
' opacitymedium' :
'').
'">';
1876 if (
$conf->main_checkbox_left_column) {
1877 print
'<td class="nowrap center">';
1878 if ($massactionbutton || $massaction) {
1880 if (in_array($obj->facid, $arrayofselected)) {
1883 print
'<input id="cb'.$obj->facid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1887 $totalarray[
'nbfield']++;
1890 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1891 print
'<td class="nowraponall">';
1893 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
1895 print
'<td class="nobordernopadding nowraponall">';
1896 print $facturestatic->getNomUrl(1,
'', 0, 0,
'', 0, -1, 1);
1900 $subdir =
get_exdir($obj->facid, 2, 0, 0, $facturestatic,
'invoice_supplier').dol_sanitizeFileName($obj->ref);
1901 print $formfile->getDocumentsLink(
'facture_fournisseur', $subdir, $filedir);
1902 print
'</td></tr></table>';
1906 $totalarray[
'nbfield']++;
1911 if (!empty($arrayfields[
'f.ref_supplier'][
'checked'])) {
1912 print
'<td class="nowrap tdoverflowmax150" title="'.dolPrintHTMLForAttribute($obj->ref_supplier).
'">';
1913 print
'<span class="doltext opacitymedium">';
1914 print dolPrintHTML($obj->ref_supplier);
1918 $totalarray[
'nbfield']++;
1923 if (!empty($arrayfields[
'f.type'][
'checked'])) {
1924 print
'<td class="nowrap">';
1925 print $facturestatic->getLibType();
1928 $totalarray[
'nbfield']++;
1933 if (!empty($arrayfields[
'f.subtype'][
'checked'])) {
1935 if ($facturestatic->subtype > 0) {
1936 $labeltoshow = $facturestatic->getSubtypeLabel(
'facture_fourn');
1938 print
'<td class="nowraponall tdoverflowmax300" title="'.$labeltoshow.
'">';
1942 $totalarray[
'nbfield']++;
1947 if (!empty($arrayfields[
'f.label'][
'checked'])) {
1948 print
'<td class="nowrap tdoverflowmax125" title="'.dol_escape_htmltag($obj->label).
'">';
1952 $totalarray[
'nbfield']++;
1957 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1958 print
'<td class="center nowrap">';
1962 $totalarray[
'nbfield']++;
1967 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1968 print
'<td class="center nowraponall">'.dol_print_date($datelimit,
'day');
1969 if ($facturestatic->hasDelay()) {
1970 print img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
1974 $totalarray[
'nbfield']++;
1979 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1980 print
'<td class="nowrap">';
1981 if ($obj->project_id > 0) {
1982 $projectstatic->id = $obj->project_id;
1983 $projectstatic->ref = $obj->project_ref;
1984 $projectstatic->title = $obj->project_label;
1985 print $projectstatic->getNomUrl(1);
1989 $totalarray[
'nbfield']++;
1994 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1995 print
'<td class="tdoverflowmax125">';
1996 print $thirdparty->getNomUrl(1,
'supplier', 0, 0, -1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
1999 $totalarray[
'nbfield']++;
2003 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2004 print
'<td class="tdoverflowmax150">';
2008 $totalarray[
'nbfield']++;
2012 if (!empty($arrayfields[
's.town'][
'checked'])) {
2013 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).
'">';
2017 $totalarray[
'nbfield']++;
2021 if (!empty($arrayfields[
's.zip'][
'checked'])) {
2022 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->zip).
'">';
2026 $totalarray[
'nbfield']++;
2030 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
2031 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->state_name).
'">';
2035 $totalarray[
'nbfield']++;
2039 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
2040 print
'<td class="center">';
2041 $tmparray =
getCountry($obj->fk_pays,
'all');
2042 print $tmparray[
'label'];
2045 $totalarray[
'nbfield']++;
2049 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
2050 print
'<td class="center">';
2051 if (empty($typenArray)) {
2052 $typenArray = $formcompany->typent_array(1);
2054 print $typenArray[$obj->typent_code];
2057 $totalarray[
'nbfield']++;
2061 if (!empty($arrayfields[
'f.vat_reverse_charge'][
'checked'])) {
2062 print
'<td class="center">';
2063 print yn($obj->vat_reverse_charge);
2066 $totalarray[
'nbfield']++;
2071 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
2072 $s = $form->form_conditions_reglement($_SERVER[
'PHP_SELF'], $obj->fk_cond_reglement,
'none', 1,
'', -1, -1, 1);
2073 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
2077 $totalarray[
'nbfield']++;
2081 if (!empty($arrayfields[
'ba.label'][
'checked'])) {
2083 if (!empty($obj->bid)) {
2084 $accountstatic->id = $obj->bid;
2085 $accountstatic->ref = $obj->bref;
2086 $accountstatic->label = $obj->blabel;
2087 $accountstatic->number = $obj->bnumber;
2088 $accountstatic->account_number = $obj->baccount_number;
2089 $accountstatic->accountancy_journal = $obj->baccountancy_journal;
2090 print $accountstatic->getNomUrl(1);
2094 $totalarray[
'nbfield']++;
2098 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
2099 $s = $form->form_modes_reglement($_SERVER[
'PHP_SELF'], $obj->fk_mode_reglement,
'none',
'', -1, 0,
'', 1);
2100 print
'<td class="tdoverflowmax100" title="'.dolPrintHTMLForAttribute($s).
'">';
2101 print dolPrintHTML($s);
2104 $totalarray[
'nbfield']++;
2109 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
2110 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
2112 $totalarray[
'nbfield']++;
2113 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ht';
2115 $totalarray[
'val'][
'f.total_ht'] += $obj->total_ht;
2118 if (!empty($arrayfields[
'f.total_vat'][
'checked'])) {
2119 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_vat).
"</span></td>\n";
2121 $totalarray[
'nbfield']++;
2122 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_vat';
2124 $totalarray[
'val'][
'f.total_vat'] += $obj->total_vat;
2127 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
2128 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_localtax1).
"</span></td>\n";
2130 $totalarray[
'nbfield']++;
2131 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_localtax1';
2133 $totalarray[
'val'][
'f.total_localtax1'] += $obj->total_localtax1;
2136 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
2137 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_localtax2).
"</span></td>\n";
2139 $totalarray[
'nbfield']++;
2140 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_localtax2';
2142 $totalarray[
'val'][
'f.total_localtax2'] += $obj->total_localtax2;
2145 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
2146 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
2148 $totalarray[
'nbfield']++;
2149 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ttc';
2151 $totalarray[
'val'][
'f.total_ttc'] += $obj->total_ttc;
2154 if (!empty($arrayfields[
'supplier_available_discount'][
'checked'])) {
2155 if (!array_key_exists($obj->socid, $supplierDiscountCache)) {
2156 $supplierDiscountCache[$obj->socid] = $thirdparty->getAvailableDiscounts(
null,
'', 0, 1);
2158 print
'<td class="right nowrap"><span class="amount">';
2159 if ($supplierDiscountCache[$obj->socid] >= 0) {
2160 $discountAmount =
price($supplierDiscountCache[$obj->socid]);
2161 if ($supplierDiscountCache[$obj->socid] > 0) {
2162 print
'<a href="'.DOL_URL_ROOT.
'/comm/remx.php?id='.((int) $obj->socid).
'&backtopage='.urlencode($_SERVER[
'REQUEST_URI']).
'">'.$discountAmount.
'</a>';
2164 print $discountAmount;
2167 print $langs->trans(
'Error');
2169 print
"</span></td>\n";
2171 $totalarray[
'nbfield']++;
2176 if (!empty($arrayfields[
'f.nb_docs'][
'checked'])) {
2177 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
2178 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
2179 $upload_dir =
getMultidirOutput($facturestatic).
'/'.
get_exdir($facturestatic->id, 2, 0, 0, $facturestatic,
'invoice_supplier').$facturestatic->ref;
2180 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
2181 $nbLinks =
Link::count($db, $facturestatic->element, $facturestatic->id);
2182 $nbTotal = $nbFiles + $nbLinks;
2183 echo
'<td class="center">'.(empty($nbTotal) ?
'' : $nbTotal).
'</td>';
2185 $totalarray[
'nbfield']++;
2190 if (!empty($arrayfields[
'u.login'][
'checked'])) {
2191 print
'<td class="tdoverflowmax100">';
2192 if ($userstatic->id) {
2193 print $userstatic->getNomUrl(-1);
2199 $totalarray[
'nbfield']++;
2204 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
2205 print
'<td class="right nowrap"><span class="amount">'.(!empty($totalpay) ?
price($totalpay, 0, $langs) :
'').
'</span></td>';
2207 $totalarray[
'nbfield']++;
2208 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalam';
2210 $totalarray[
'val'][
'totalam'] += $totalpay;
2214 if (!empty($arrayfields[
'rtp'][
'checked'])) {
2215 print
'<td class="right nowrap">'.(!empty($remaintopay) ?
price($remaintopay, 0, $langs) :
' ').
'</td>';
2217 $totalarray[
'nbfield']++;
2218 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'rtp';
2220 $totalarray[
'val'][
'rtp'] += $remaintopay;
2224 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
2225 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
2227 $totalarray[
'nbfield']++;
2232 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
2233 print
'<td class="nowrap">';
2234 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->facid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
2237 $totalarray[
'nbfield']++;
2240 $currencykey = !empty($obj->multicurrency_code) ? $obj->multicurrency_code :
$conf->currency;
2242 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
2243 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
2245 $totalarray[
'nbfield']++;
2246 $totalarray[
'pospercurrency'][$totalarray[
'nbfield']] =
'f.multicurrency_total_ht';
2248 $totalarray[
'valpercurrency'][$currencykey][
'f.multicurrency_total_ht'] = ($totalarray[
'valpercurrency'][$currencykey][
'f.multicurrency_total_ht'] ?? 0) + $obj->multicurrency_total_ht;
2251 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
2252 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat).
"</span></td>\n";
2254 $totalarray[
'nbfield']++;
2255 $totalarray[
'pospercurrency'][$totalarray[
'nbfield']] =
'f.multicurrency_total_vat';
2257 $totalarray[
'valpercurrency'][$currencykey][
'f.multicurrency_total_vat'] = ($totalarray[
'valpercurrency'][$currencykey][
'f.multicurrency_total_vat'] ?? 0) + $obj->multicurrency_total_vat;
2260 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
2261 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
2263 $totalarray[
'nbfield']++;
2264 $totalarray[
'pospercurrency'][$totalarray[
'nbfield']] =
'f.multicurrency_total_ttc';
2266 $totalarray[
'valpercurrency'][$currencykey][
'f.multicurrency_total_ttc'] = ($totalarray[
'valpercurrency'][$currencykey][
'f.multicurrency_total_ttc'] ?? 0) + $obj->multicurrency_total_ttc;
2269 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
2270 print
'<td class="right nowrap"><span class="amount">'.(!empty($multicurrency_totalpay) ?
price($multicurrency_totalpay, 0, $langs) :
'').
'</span></td>';
2272 $totalarray[
'nbfield']++;
2277 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
2278 print
'<td class="right nowrap"><span class="amount">';
2279 print(!empty($multicurrency_remaintopay) ?
price($multicurrency_remaintopay, 0, $langs) :
'');
2280 print
'</span></td>';
2282 $totalarray[
'nbfield']++;
2288 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2290 $parameters = array(
'arrayfields' => $arrayfields,
'object' => $object,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
2291 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2292 print $hookmanager->resPrint;
2295 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
2296 print
'<td class="center nowraponall">';
2297 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
2300 $totalarray[
'nbfield']++;
2304 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
2305 print
'<td class="center nowraponall">';
2306 print
dol_print_date($db->jdate($obj->date_modification),
'dayhour',
'tzuser');
2309 $totalarray[
'nbfield']++;
2313 if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
2314 print
'<td class="sensiblehtmlcontent center">';
2315 print
'<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(
dolGetFirstLineOfText($obj->note_public, 5)).
'</div>';
2318 $totalarray[
'nbfield']++;
2322 if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
2323 print
'<td class="sensiblehtmlcontent center">';
2324 print
'<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(
dolGetFirstLineOfText($obj->note_private, 5)).
'</div>';
2327 $totalarray[
'nbfield']++;
2331 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
2332 print
'<td class="center nowrap">';
2333 print $facturestatic->getLibStatut(5, $paiement);
2336 $totalarray[
'nbfield']++;
2341 if (!
$conf->main_checkbox_left_column) {
2342 print
'<td class="nowrap center">';
2343 if ($massactionbutton || $massaction) {
2345 if (in_array($obj->facid, $arrayofselected)) {
2348 print
'<input id="cb'.$obj->facid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2352 $totalarray[
'nbfield']++;
2363include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
2368 foreach ($arrayfields as $key => $val) {
2369 if (!empty($val[
'checked'])) {
2373 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2378$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2379$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
2380print $hookmanager->resPrint;
2382print
'</table>'.
"\n";
2385print
'</form>'.
"\n";
2387if (in_array(
'builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords ===
'' || $nbtotalofrecords)) {
2388 $hidegeneratedfilelistifempty = 1;
2389 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
2390 $hidegeneratedfilelistifempty = 0;
2393 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
2397 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
2398 $urlsource .= str_replace(
'&',
'&', $param);
2400 $filedir = $diroutputmassaction;
2401 $genallowed = $permissiontoread;
2402 $delallowed = $permissiontoadd;
2405 print $formfile->showdocuments(
'massfilesarea_supplier_invoice',
'', $filedir, $urlsource, 0, (
int) $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage bank accounts.
Class to manage absolute discounts.
Class to manage suppliers invoices.
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
const TYPE_REPLACEMENT
Replacement invoice.
const TYPE_STANDARD
Standard invoice.
const STATUS_CLOSED
Classified paid.
Class to manage invoice templates.
Class to manage suppliers.
static count($dbs, $objecttype, $objectid)
Return nb of links.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
getCountriesInEEC()
Return list of countries that are inside the EEC (European Economic Community) Note: Try to keep this...
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
getMultidirTemp($object, $module='', $forobject=0)
Return the full path of the directory where a module (or an object of a module) stores its temporary ...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
getMultidirOutput($object, $module='', $forobject=0, $mode='output')
Return the full path of the directory where a module (or an object of a module) stores its files.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
buildParamDate($prefix, $timestamp=null, $hourTime='', $gm='auto')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
supplier_invoice_rec_prepare_head($object)
Return array head with list of tabs to view object information.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.