38 require
'../../main.inc.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
47 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
50 $langs->loadLangs(array(
'products',
'bills',
'companies',
'projects'));
52 $action =
GETPOST(
'action',
'aZ09');
53 $massaction =
GETPOST(
'massaction',
'alpha');
54 $show_files =
GETPOST(
'show_files',
'int');
55 $confirm =
GETPOST(
'confirm',
'alpha');
56 $toselect =
GETPOST(
'toselect',
'array');
57 $optioncss =
GETPOST(
'optioncss',
'alpha');
58 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'supplierinvoicelist';
60 $socid =
GETPOST(
'socid',
'int');
63 if ($user->socid > 0) {
66 $socid = $user->socid;
69 $mode =
GETPOST(
"mode",
'aZ09');
71 $search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
72 $search_label =
GETPOST(
"search_label",
"alpha");
73 $search_amount_no_tax =
GETPOST(
"search_amount_no_tax",
"alpha");
74 $search_amount_all_tax =
GETPOST(
"search_amount_all_tax",
"alpha");
76 $search_refsupplier =
GETPOST(
'search_refsupplier',
'alpha');
77 $search_type =
GETPOST(
'search_type',
'int');
78 $search_project =
GETPOST(
'search_project',
'alpha');
79 $search_company =
GETPOST(
'search_company',
'alpha');
80 $search_company_alias =
GETPOST(
'search_company_alias',
'alpha');
81 $search_montant_ht =
GETPOST(
'search_montant_ht',
'alpha');
82 $search_montant_vat =
GETPOST(
'search_montant_vat',
'alpha');
83 $search_montant_localtax1 =
GETPOST(
'search_montant_localtax1',
'alpha');
84 $search_montant_localtax2 =
GETPOST(
'search_montant_localtax2',
'alpha');
85 $search_montant_ttc =
GETPOST(
'search_montant_ttc',
'alpha');
86 $search_login =
GETPOST(
'search_login',
'alpha');
87 $search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
88 $search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
89 $search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
90 $search_multicurrency_montant_vat =
GETPOST(
'search_multicurrency_montant_vat',
'alpha');
91 $search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
92 $search_status =
GETPOST(
'search_status',
'int');
93 $search_paymentmode =
GETPOST(
'search_paymentmode',
'int');
94 $search_paymentcond =
GETPOST(
'search_paymentcond',
'int');
95 $search_town =
GETPOST(
'search_town',
'alpha');
96 $search_zip =
GETPOST(
'search_zip',
'alpha');
97 $search_state =
GETPOST(
"search_state");
98 $search_country =
GETPOST(
"search_country",
'int');
99 $search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'int');
100 $search_user =
GETPOST(
'search_user',
'int');
101 $search_sale =
GETPOST(
'search_sale',
'int');
102 $search_date_startday =
GETPOST(
'search_date_startday',
'int');
103 $search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
104 $search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
105 $search_date_endday =
GETPOST(
'search_date_endday',
'int');
106 $search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
107 $search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
108 $search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
109 $search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
110 $search_datelimit_startday =
GETPOST(
'search_datelimit_startday',
'int');
111 $search_datelimit_startmonth =
GETPOST(
'search_datelimit_startmonth',
'int');
112 $search_datelimit_startyear =
GETPOST(
'search_datelimit_startyear',
'int');
113 $search_datelimit_endday =
GETPOST(
'search_datelimit_endday',
'int');
114 $search_datelimit_endmonth =
GETPOST(
'search_datelimit_endmonth',
'int');
115 $search_datelimit_endyear =
GETPOST(
'search_datelimit_endyear',
'int');
116 $search_datelimit_start =
dol_mktime(0, 0, 0, $search_datelimit_startmonth, $search_datelimit_startday, $search_datelimit_startyear);
117 $search_datelimit_end =
dol_mktime(23, 59, 59, $search_datelimit_endmonth, $search_datelimit_endday, $search_datelimit_endyear);
118 $search_btn =
GETPOST(
'button_search',
'alpha');
119 $search_remove_btn =
GETPOST(
'button_removefilter',
'alpha');
120 $search_categ_sup = trim(
GETPOST(
"search_categ_sup",
'int'));
121 $search_product_category =
GETPOST(
'search_product_category',
'int');
123 $option =
GETPOST(
'search_option');
124 if ($option ==
'late') {
125 $search_status =
'1';
127 $filter =
GETPOST(
'filtre',
'alpha');
129 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
130 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
131 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
133 if ($page == -1 || $page ==
null || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction ===
'0')) {
136 $offset = $limit * $page;
137 $pageprev = $page - 1;
138 $pagenext = $page + 1;
143 $sortfield =
"f.datef,f.rowid";
146 $diroutputmassaction = $conf->fournisseur->facture->dir_output.
'/temp/massgeneration/'.$user->id;
152 $hookmanager->initHooks(array(
'supplierinvoicelist'));
156 $extrafields->fetch_name_optionals_label($object->table_element);
158 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
161 $fieldstosearchall = array(
163 'f.ref_supplier'=>
'RefSupplier',
164 'f.note_public'=>
'NotePublic',
165 's.nom'=>
"ThirdParty",
166 'pd.description'=>
'Description',
168 if (empty($user->socid)) {
169 $fieldstosearchall[
"f.note_private"] =
"NotePrivate";
172 $checkedtypetiers = 0;
173 $arrayfields = array(
174 'f.ref'=>array(
'label'=>
"Ref",
'checked'=>1),
175 'f.ref_supplier'=>array(
'label'=>
"RefSupplier",
'checked'=>1),
176 'f.type'=>array(
'label'=>
"Type",
'checked'=>0),
177 'f.label'=>array(
'label'=>
"Label",
'checked'=>0),
178 'f.datef'=>array(
'label'=>
"DateInvoice",
'checked'=>1),
179 'f.date_lim_reglement'=>array(
'label'=>
"DateDue",
'checked'=>1),
180 'p.ref'=>array(
'label'=>
"ProjectRef",
'checked'=>0),
181 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1),
182 's.name_alias'=>array(
'label'=>
"AliasNameShort",
'checked'=>0),
183 's.town'=>array(
'label'=>
"Town",
'checked'=>-1),
184 's.zip'=>array(
'label'=>
"Zip",
'checked'=>1),
185 'state.nom'=>array(
'label'=>
"StateShort",
'checked'=>0),
186 'country.code_iso'=>array(
'label'=>
"Country",
'checked'=>0),
187 'typent.code'=>array(
'label'=>
"ThirdPartyType",
'checked'=>$checkedtypetiers),
188 'f.fk_cond_reglement'=>array(
'label'=>
"PaymentTerm",
'checked'=>1,
'position'=>50),
189 'f.fk_mode_reglement'=>array(
'label'=>
"PaymentMode",
'checked'=>1,
'position'=>52),
190 'f.total_ht'=>array(
'label'=>
"AmountHT",
'checked'=>1,
'position'=>105),
191 'f.total_vat'=>array(
'label'=>
"AmountVAT",
'checked'=>0,
'position'=>110),
192 'f.total_localtax1'=>array(
'label'=>$langs->transcountry(
"AmountLT1", $mysoc->country_code),
'checked'=>0,
'enabled'=>$mysoc->localtax1_assuj ==
"1",
'position'=>95),
193 'f.total_localtax2'=>array(
'label'=>$langs->transcountry(
"AmountLT2", $mysoc->country_code),
'checked'=>0,
'enabled'=>$mysoc->localtax2_assuj ==
"1",
'position'=>100),
194 'f.total_ttc'=>array(
'label'=>
"AmountTTC",
'checked'=>0,
'position'=>115),
195 'dynamount_payed'=>array(
'label'=>
"Paid",
'checked'=>0,
'position'=>116),
196 'rtp'=>array(
'label'=>
"Rest",
'checked'=>0,
'position'=>117),
197 'f.multicurrency_code'=>array(
'label'=>
'Currency',
'checked'=>0,
'enabled'=>(!
isModEnabled(
"multicurrency") ? 0 : 1)),
198 'f.multicurrency_tx'=>array(
'label'=>
'CurrencyRate',
'checked'=>0,
'enabled'=>(!
isModEnabled(
"multicurrency") ? 0 : 1)),
199 'f.multicurrency_total_ht'=>array(
'label'=>
'MulticurrencyAmountHT',
'checked'=>0,
'enabled'=>(!
isModEnabled(
"multicurrency") ? 0 : 1)),
200 'f.multicurrency_total_vat'=>array(
'label'=>
'MulticurrencyAmountVAT',
'checked'=>0,
'enabled'=>(!
isModEnabled(
"multicurrency") ? 0 : 1)),
201 'f.multicurrency_total_ttc'=>array(
'label'=>
'MulticurrencyAmountTTC',
'checked'=>0,
'enabled'=>(!
isModEnabled(
"multicurrency") ? 0 : 1)),
202 'multicurrency_dynamount_payed'=>array(
'label'=>
'MulticurrencyAlreadyPaid',
'checked'=>0,
'enabled'=>(!
isModEnabled(
"multicurrency") ? 0 : 1)),
203 'multicurrency_rtp'=>array(
'label'=>
'MulticurrencyRemainderToPay',
'checked'=>0,
'enabled'=>(!
isModEnabled(
"multicurrency") ? 0 : 1)),
204 'u.login'=>array(
'label'=>
"Author",
'checked'=>1,
'position'=>500),
205 'f.datec'=>array(
'label'=>
"DateCreation",
'checked'=>0,
'position'=>501),
206 'f.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>502),
207 'f.fk_statut'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000),
210 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
215 if ((!
isModEnabled(
'fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))
216 || (!
isModEnabled(
'supplier_invoice') && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))) {
219 if ((empty($user->rights->fournisseur->facture->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))
220 || (empty($user->rights->supplier_invoice->lire) && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))) {
230 if (
GETPOST(
'cancel',
'alpha')) {
231 $action =
'list'; $massaction =
'';
233 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
237 $parameters = array(
'socid'=>$socid);
238 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
243 if (empty($reshook)) {
244 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
246 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha')) {
250 $search_product_category =
'';
252 $search_refsupplier =
"";
255 $search_project =
'';
256 $search_company =
"";
257 $search_company_alias =
"";
258 $search_amount_no_tax =
"";
259 $search_amount_all_tax =
"";
260 $search_montant_ht =
'';
261 $search_montant_vat =
'';
262 $search_montant_localtax1 =
'';
263 $search_montant_localtax2 =
'';
264 $search_montant_ttc =
'';
266 $search_multicurrency_code =
'';
267 $search_multicurrency_tx =
'';
268 $search_multicurrency_montant_ht =
'';
269 $search_multicurrency_montant_vat =
'';
270 $search_multicurrency_montant_ttc =
'';
272 $search_paymentmode =
'';
273 $search_paymentcond =
'';
278 $search_country =
'';
279 $search_type_thirdparty =
'';
280 $search_date_startday =
'';
281 $search_date_startmonth =
'';
282 $search_date_startyear =
'';
283 $search_date_endday =
'';
284 $search_date_endmonth =
'';
285 $search_date_endyear =
'';
286 $search_date_start =
'';
287 $search_date_end =
'';
288 $search_datelimit_startday =
'';
289 $search_datelimit_startmonth =
'';
290 $search_datelimit_startyear =
'';
291 $search_datelimit_endday =
'';
292 $search_datelimit_endmonth =
'';
293 $search_datelimit_endyear =
'';
294 $search_datelimit_start =
'';
295 $search_datelimit_end =
'';
297 $search_array_options = array();
298 $search_categ_sup = 0;
305 $objectclass =
'FactureFournisseur';
306 $objectlabel =
'SupplierInvoices';
307 $permissiontoread = ($user->rights->fournisseur->facture->lire || $user->rights->supplier_invoice->lire);
308 $permissiontoadd = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
309 $permissiontodelete = ($user->rights->fournisseur->facture->supprimer || $user->rights->supplier_invoice->supprimer);
310 $uploaddir = $conf->fournisseur->facture->dir_output;
311 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
313 if ($massaction ==
'banktransfertrequest') {
314 $langs->load(
"withdrawals");
316 if (!$user->rights->paymentbybanktransfer->create) {
323 $arrayofselected = is_array($toselect) ? $toselect : array();
324 $listofbills = array();
325 foreach ($arrayofselected as $toselectid) {
327 $result = $objecttmp->fetch($toselectid);
329 $totalpaid = $objecttmp->getSommePaiement();
330 $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
331 $totaldeposits = $objecttmp->getSumDepositsUsed();
332 $objecttmp->resteapayer =
price2num($objecttmp->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
335 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"Draft"), $objecttmp->errors,
'errors');
336 } elseif ($objecttmp->paye || $objecttmp->resteapayer == 0) {
338 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AlreadyPaid"), $objecttmp->errors,
'errors');
339 } elseif ($objecttmp->resteapayer < 0) {
341 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AmountMustBePositive"), $objecttmp->errors,
'errors');
344 $rsql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
345 $rsql .=
" , pfd.date_traite as date_traite";
346 $rsql .=
" , pfd.amount";
347 $rsql .=
" , u.rowid as user_id, u.lastname, u.firstname, u.login";
348 $rsql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
349 $rsql .=
" , ".MAIN_DB_PREFIX.
"user as u";
350 $rsql .=
" WHERE fk_facture_fourn = ".((int) $objecttmp->id);
351 $rsql .=
" AND pfd.fk_user_demande = u.rowid";
352 $rsql .=
" AND pfd.traite = 0";
353 $rsql .=
" ORDER BY pfd.date_demande DESC";
355 $result_sql = $db->query($rsql);
357 $numprlv = $db->num_rows($result_sql);
362 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"RequestAlreadyDone"), $objecttmp->errors,
'warnings');
363 } elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code !=
'VIR') {
365 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"BadPaymentMethod"), $objecttmp->errors,
'errors');
367 $listofbills[] = $objecttmp;
373 if (!empty($listofbills)) {
374 $nbwithdrawrequestok = 0;
375 foreach ($listofbills as $aBill) {
377 $result = $aBill->demande_prelevement($user, $aBill->resteapayer,
'bank-transfer',
'supplier_invoice');
380 $nbwithdrawrequestok++;
386 if ($nbwithdrawrequestok > 0) {
387 setEventMessages($langs->trans(
"WithdrawRequestsDone", $nbwithdrawrequestok),
null,
'mesgs');
402 $bankaccountstatic =
new Account($db);
405 $thirdparty =
new Societe($db);
407 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
408 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
412 $sql =
'SELECT DISTINCT';
414 $sql .=
" f.rowid as facid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement as datelimite, f.fk_mode_reglement, f.fk_cond_reglement,";
415 $sql .=
" f.total_ht, f.total_ttc, f.total_tva as total_vat, f.paye as paye, f.fk_statut as fk_statut, f.libelle as label, f.datec as date_creation, f.tms as date_update,";
416 $sql .=
" f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,";
417 $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,';
418 $sql .=
" f.note_public, f.note_private,";
419 $sql .=
" f.fk_user_author,";
420 $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,";
421 $sql .=
" typent.code as typent_code,";
422 $sql .=
" state.code_departement as state_code, state.nom as state_name,";
423 $sql .=
" country.code as country_code,";
424 $sql .=
" p.rowid as project_id, p.ref as project_ref, p.title as project_label,";
425 $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';
429 $sql .=
', SUM(pf.amount) as dynamount_payed';
432 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
433 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
434 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
438 $parameters = array();
439 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
440 $sql .= $hookmanager->resPrint;
444 $sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
445 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
446 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
447 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
448 $sql .=
', '.MAIN_DB_PREFIX.
'facture_fourn as f';
449 if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
450 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (f.rowid = ef.fk_object)";
453 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
456 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_det as pd ON f.rowid=pd.fk_facture_fourn';
458 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user AS u ON f.fk_user_author = u.rowid';
459 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = f.fk_projet";
461 if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
462 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
464 if ($search_user > 0) {
465 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
466 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
469 $parameters = array();
470 $reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
471 $sql .= $hookmanager->resPrint;
472 $sql .=
' WHERE f.fk_soc = s.rowid';
473 $sql .=
' AND f.entity IN ('.getEntity(
'facture_fourn').
')';
474 if (empty($user->rights->societe->client->voir) && !$socid) {
475 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
478 $sql .=
' AND s.rowid = '.((int) $socid);
481 if (is_numeric($search_ref)) {
490 if ($search_refsupplier) {
493 if ($search_type !=
'' && $search_type >= 0) {
494 if ($search_type ==
'0') {
495 $sql .=
" AND f.type = 0";
497 if ($search_type ==
'1') {
498 $sql .=
" AND f.type = 1";
500 if ($search_type ==
'2') {
501 $sql .=
" AND f.type = 2";
503 if ($search_type ==
'3') {
504 $sql .=
" AND f.type = 3";
509 if ($search_project) {
512 if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
513 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
515 if ($search_company) {
518 if ($search_company_alias) {
531 if ($search_country) {
532 $sql .=
" AND s.fk_pays IN (".$db->sanitize($search_country).
')';
534 if ($search_type_thirdparty !=
'' && $search_type_thirdparty >= 0) {
535 $sql .=
" AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).
')';
537 if ($search_montant_ht !=
'') {
540 if ($search_montant_vat !=
'') {
543 if ($search_montant_localtax1 !=
'') {
544 $sql .=
natural_search(
'f.localtax1', $search_montant_localtax1, 1);
546 if ($search_montant_localtax2 !=
'') {
547 $sql .=
natural_search(
'f.localtax2', $search_montant_localtax2, 1);
549 if ($search_montant_ttc !=
'') {
552 if ($search_multicurrency_code !=
'') {
553 $sql .=
" AND f.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
555 if ($search_multicurrency_tx !=
'') {
556 $sql .=
natural_search(
'f.multicurrency_tx', $search_multicurrency_tx, 1);
558 if ($search_multicurrency_montant_ht !=
'') {
559 $sql .=
natural_search(
'f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
561 if ($search_multicurrency_montant_vat !=
'') {
562 $sql .=
natural_search(
'f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
564 if ($search_multicurrency_montant_ttc !=
'') {
565 $sql .=
natural_search(
'f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
568 $sql .=
natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $search_login);
570 if ($search_status !=
'' && $search_status >= 0) {
571 $sql .=
" AND f.fk_statut = ".((int) $search_status);
573 if ($search_paymentmode > 0) {
574 $sql .=
" AND f.fk_mode_reglement = ".((int) $search_paymentmode);
576 if ($search_paymentcond > 0) {
577 $sql .=
" AND f.fk_cond_reglement = ".((int) $search_paymentcond);
579 if ($search_date_start) {
580 $sql .=
" AND f.datef >= '" . $db->idate($search_date_start) .
"'";
582 if ($search_date_end) {
583 $sql .=
" AND f.datef <= '" . $db->idate($search_date_end) .
"'";
585 if ($search_datelimit_start) {
586 $sql .=
" AND f.date_lim_reglement >= '" . $db->idate($search_datelimit_start) .
"'";
588 if ($search_datelimit_end) {
589 $sql .=
" AND f.date_lim_reglement <= '" . $db->idate($search_datelimit_end) .
"'";
591 if ($option ==
'late') {
592 $sql .=
" AND f.date_lim_reglement < '".$db->idate(
dol_now() - $conf->facture->fournisseur->warning_delay).
"'";
597 $searchCategorySupplierList = $search_categ_sup ? array($search_categ_sup) : array();
598 $searchCategorySupplierOperator = 0;
600 if (!empty($searchCategorySupplierList)) {
601 $searchCategorySupplierSqlList = array();
602 $listofcategoryid =
'';
603 foreach ($searchCategorySupplierList as $searchCategorySupplier) {
604 if (intval($searchCategorySupplier) == -2) {
605 $searchCategorySupplierSqlList[] =
"NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)";
606 } elseif (intval($searchCategorySupplier) > 0) {
607 if ($searchCategorySupplierOperator == 0) {
608 $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).
")";
610 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategorySupplier);
614 if ($listofcategoryid) {
615 $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).
"))";
617 if ($searchCategorySupplierOperator == 1) {
618 if (!empty($searchCategorySupplierSqlList)) {
619 $sql .=
" AND (".implode(
' OR ', $searchCategorySupplierSqlList).
")";
622 if (!empty($searchCategorySupplierSqlList)) {
623 $sql .=
" AND (".implode(
' AND ', $searchCategorySupplierSqlList).
")";
628 $searchCategoryProductList = $search_product_category ? array($search_product_category) : array();
629 $searchCategoryProductOperator = 0;
630 if (!empty($searchCategoryProductList)) {
631 $searchCategoryProductSqlList = array();
632 $listofcategoryid =
'';
633 foreach ($searchCategoryProductList as $searchCategoryProduct) {
634 if (intval($searchCategoryProduct) == -2) {
635 $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 p.rowid = ck.fk_product)";
636 } elseif (intval($searchCategoryProduct) > 0) {
637 if ($searchCategoryProductOperator == 0) {
638 $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 p.rowid = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).
")";
640 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
644 if ($listofcategoryid) {
645 $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 p.rowid = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
647 if ($searchCategoryProductOperator == 1) {
648 if (!empty($searchCategoryProductSqlList)) {
649 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
652 if (!empty($searchCategoryProductSqlList)) {
653 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
657 if ($search_status !=
'' && $search_status >= 0) {
658 $sql .=
" AND f.fk_statut = ".((int) $search_status);
660 if ($filter && $filter != -1) {
661 $aFilter = explode(
',', $filter);
662 foreach ($aFilter as $fil) {
663 $filt = explode(
':', $fil);
664 $sql .=
" AND ".$db->escape(trim($filt[0])).
" = '".$db->escape(trim($filt[1])).
"'";
667 if ($search_sale > 0) {
668 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
670 if ($search_user > 0) {
671 $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);
674 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
676 $parameters = array();
677 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
678 $sql .= $hookmanager->resPrint;
681 $sql .=
" GROUP BY f.rowid, f.ref, f.ref_supplier, f.type, f.datef, f.date_lim_reglement, f.fk_mode_reglement, f.fk_cond_reglement,";
682 $sql .=
" f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,";
683 $sql .=
" f.localtax1, f.localtax2,";
684 $sql .=
' f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
685 $sql .=
" f.note_public, f.note_private,";
686 $sql .=
" f.fk_user_author,";
687 $sql .=
' s.rowid, s.nom, s.name_alias, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,';
688 $sql .=
" typent.code,";
689 $sql .=
" state.code_departement, state.nom,";
690 $sql .=
' country.code,';
691 $sql .=
" p.rowid, p.ref, p.title,";
692 $sql .=
" u.login, u.lastname, u.firstname, u.email, u.statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender";
693 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
694 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
696 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
",ef.".$key :
'');
700 $parameters = array(
'all' => $search_all,
'fieldstosearchall' => $fieldstosearchall);
701 $reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters, $object, $action);
702 $sql .= $hookmanager->resPrint;
704 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
708 $parameters = array();
709 $reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object, $action);
710 $sql .= empty($hookmanager->resPrint) ?
"" :
" HAVING 1=1 ".$hookmanager->resPrint;
714 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
716 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
717 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
718 $resql = $db->query($sqlforcount);
720 $objforcount = $db->fetch_object(
$resql);
734 $sql .= $db->order($sortfield, $sortorder);
736 $sql .= $db->plimit($limit + 1, $offset);
740 $resql = $db->query($sql);
745 $num = $db->num_rows(
$resql);
747 $arrayofselected = is_array($toselect) ? $toselect : array();
749 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) {
750 $obj = $db->fetch_object(
$resql);
753 header(
"Location: ".DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.$id);
757 llxHeader(
'', $langs->trans(
"SuppliersInvoices"),
'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores');
762 if (empty($search_company)) {
763 $search_company = $soc->name;
764 $search_company_alias = $soc->name_alias;
768 $param =
'&socid='.$socid;
769 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
770 $param .=
'&contextpage='.urlencode($contextpage);
772 if ($limit > 0 && $limit != $conf->liste_limit) {
773 $param .=
'&limit='.urlencode($limit);
776 $param .=
'&search_all='.urlencode($search_all);
778 if ($search_date_startday) {
779 $param .=
'&search_date_startday='.urlencode($search_date_startday);
781 if ($search_date_startmonth) {
782 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
784 if ($search_date_startyear) {
785 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
787 if ($search_date_endday) {
788 $param .=
'&search_date_endday='.urlencode($search_date_endday);
790 if ($search_date_endmonth) {
791 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
793 if ($search_date_endyear) {
794 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
796 if ($search_datelimit_startday) {
797 $param .=
'&search_datelimit_startday='.urlencode($search_datelimit_startday);
799 if ($search_datelimit_startmonth) {
800 $param .=
'&search_datelimit_startmonth='.urlencode($search_datelimit_startmonth);
802 if ($search_datelimit_startyear) {
803 $param .=
'&search_datelimit_startyear='.urlencode($search_datelimit_startyear);
805 if ($search_datelimit_endday) {
806 $param .=
'&search_datelimit_endday='.urlencode($search_datelimit_endday);
808 if ($search_datelimit_endmonth) {
809 $param .=
'&search_datelimit_endmonth='.urlencode($search_datelimit_endmonth);
811 if ($search_datelimit_endyear) {
812 $param .=
'&search_datelimit_endyear='.urlencode($search_datelimit_endyear);
815 $param .=
'&search_ref='.urlencode($search_ref);
817 if ($search_refsupplier) {
818 $param .=
'&search_refsupplier='.urlencode($search_refsupplier);
820 if ($search_type !=
'') {
821 $param .=
'&search_type='.urlencode($search_type);
824 $param .=
'&search_label='.urlencode($search_label);
826 if ($search_company) {
827 $param .=
'&search_company='.urlencode($search_company);
829 if ($search_company_alias) {
830 $param .=
'&search_company_alias='.urlencode($search_company_alias);
833 $param .=
'&search_login='.urlencode($search_login);
835 if ($search_montant_ht !=
'') {
836 $param .=
'&search_montant_ht='.urlencode($search_montant_ht);
838 if ($search_montant_vat !=
'') {
839 $param .=
'&search_montant_vat='.urlencode($search_montant_vat);
841 if ($search_montant_localtax1 !=
'') {
842 $param .=
'&search_montant_localtax1='.urlencode($search_montant_localtax1);
844 if ($search_montant_localtax2 !=
'') {
845 $param .=
'&search_montant_localtax2='.urlencode($search_montant_localtax2);
847 if ($search_montant_ttc !=
'') {
848 $param .=
'&search_montant_ttc='.urlencode($search_montant_ttc);
850 if ($search_multicurrency_code !=
'') {
851 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
853 if ($search_multicurrency_tx !=
'') {
854 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
856 if ($search_multicurrency_montant_ht !=
'') {
857 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
859 if ($search_multicurrency_montant_vat !=
'') {
860 $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
862 if ($search_multicurrency_montant_ttc !=
'') {
863 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
865 if ($search_amount_no_tax) {
866 $param .=
'&search_amount_no_tax='.urlencode($search_amount_no_tax);
868 if ($search_amount_all_tax) {
869 $param .=
'&search_amount_all_tax='.urlencode($search_amount_all_tax);
871 if ($search_status >= 0) {
872 $param .=
"&search_status=".urlencode($search_status);
875 $param .=
'&show_files='.urlencode($show_files);
878 $param .=
"&search_option=".urlencode($option);
880 if ($optioncss !=
'') {
881 $param .=
'&optioncss='.urlencode($optioncss);
883 if ($search_categ_sup > 0) {
884 $param .=
'&search_categ_sup='.urlencode($search_categ_sup);
886 if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
887 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
891 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
893 $parameters = array();
894 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
895 $param .= $hookmanager->resPrint;
898 $arrayofmassactions = array(
899 'validate'=>
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate"),
900 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
905 if (
isModEnabled(
'paymentbybanktransfer') && !empty($user->rights->paymentbybanktransfer->create)) {
906 $langs->load(
'withdrawals');
907 $arrayofmassactions[
'banktransfertrequest'] =
img_picto(
'',
'payment',
'class="pictofixedwidth"').$langs->trans(
"MakeBankTransferOrder");
909 if ($user->rights->fournisseur->facture->supprimer) {
910 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
912 if (in_array($massaction, array(
'presend',
'predelete'))) {
913 $arrayofmassactions = array();
915 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
917 $url = DOL_URL_ROOT.
'/fourn/facture/card.php?action=create';
918 if (!empty($socid)) {
919 $url .=
'&socid='.urlencode($socid);
921 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewBill'),
'',
'fa fa-plus-circle', $url,
'', ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer));
924 print
'<form method="POST" name="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
925 if ($optioncss !=
'') {
926 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
928 print
'<input type="hidden" name="token" value="'.newToken().
'">';
929 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
930 print
'<input type="hidden" name="action" value="list">';
931 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
932 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
933 print
'<input type="hidden" name="socid" value="'.$socid.
'">';
935 print_barre_liste($langs->trans(
"BillsSuppliers").($socid ?
' '.$soc->name :
''), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'supplier_invoice', 0, $newcardbutton,
'', $limit, 0, 0, 1);
937 $topicmail =
"SendBillRef";
938 $modelmail =
"invoice_supplier_send";
940 $trackid =
'sinv'.$object->id;
941 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
944 foreach ($fieldstosearchall as $key => $val) {
945 $fieldstosearchall[$key] = $langs->trans($val);
947 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>';
952 if ($user->rights->user->user->lire) {
953 $langs->load(
"commercial");
954 $moreforfilter .=
'<div class="divsearchfield">';
955 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
956 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth200');
957 $moreforfilter .=
'</div>';
960 if ($user->rights->user->user->lire) {
961 $moreforfilter .=
'<div class="divsearchfield">';
962 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
963 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth200');
964 $moreforfilter .=
'</div>';
967 if (
isModEnabled(
'categorie') && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) {
968 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
969 $moreforfilter .=
'<div class="divsearchfield">';
970 $tmptitle = $langs->trans(
'IncludingProductWithTag');
971 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
972 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0,
'', 0, 0, 0, 0,
'maxwidth300 widthcentpercentminusx', 1);
973 $moreforfilter .=
'</div>';
977 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
978 $moreforfilter .=
'<div class="divsearchfield">';
979 $tmptitle = $langs->trans(
'SuppliersCategoriesShort');
980 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$formother->select_categories(
'supplier', $search_categ_sup,
'search_categ_sup', 1, $tmptitle);
981 $moreforfilter .=
'</div>';
983 $parameters = array();
984 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
985 if (empty($reshook)) {
986 $moreforfilter .= $hookmanager->resPrint;
988 $moreforfilter = $hookmanager->resPrint;
991 if ($moreforfilter) {
992 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
993 print $moreforfilter;
997 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
998 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
999 if ($massactionbutton) {
1000 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
1003 print
'<div class="div-table-responsive">';
1004 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1007 print
'<tr class="liste_titre_filter">';
1010 print
'<td class="liste_titre middle">';
1011 $searchpicto =
$form->showFilterButtons(
'left');
1016 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1017 print
'<td class="liste_titre left">';
1018 print
'<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1022 if (!empty($arrayfields[
'f.ref_supplier'][
'checked'])) {
1023 print
'<td class="liste_titre">';
1024 print
'<input class="flat maxwidth75" type="text" name="search_refsupplier" value="'.dol_escape_htmltag($search_refsupplier).
'">';
1028 if (!empty($arrayfields[
'f.type'][
'checked'])) {
1029 print
'<td class="liste_titre maxwidthonsmartphone">';
1043 print
$form->selectarray(
'search_type', $listtype, $search_type, 1, 0, 0,
'', 0, 0, 0,
'ASC',
'maxwidth100');
1047 if (!empty($arrayfields[
'f.label'][
'checked'])) {
1048 print
'<td class="liste_titre">';
1049 print
'<input class="flat maxwidth75" type="text" name="search_label" value="'.dol_escape_htmltag($search_label).
'">';
1053 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1054 print
'<td class="liste_titre center">';
1055 print
'<div class="nowrap">';
1056 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1058 print
'<div class="nowrap">';
1059 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1064 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1065 print
'<td class="liste_titre center">';
1066 print
'<div class="nowrap">';
1073 print
$form->selectDate($search_datelimit_end ? $search_datelimit_end : -1,
'search_datelimit_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"Before"));
1074 print
'<br><input type="checkbox" name="search_option" value="late"'.($option ==
'late' ?
' checked' :
'').
'> '.$langs->trans(
"Alert");
1079 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1080 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_project" value="'.dol_escape_htmltag($search_project).
'"></td>';
1083 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1084 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).
'"'.($socid > 0 ?
" disabled" :
"").
'></td>';
1087 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1088 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).
'"></td>';
1091 if (!empty($arrayfields[
's.town'][
'checked'])) {
1092 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
1095 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1096 print
'<td class="liste_titre center"><input class="flat maxwidth50" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
1099 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1100 print
'<td class="liste_titre">';
1101 print
'<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1105 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1106 print
'<td class="liste_titre center">';
1107 print
$form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1111 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1112 print
'<td class="liste_titre maxwidthonsmartphone center">';
1113 print
$form->selectarray(
"search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0,
'', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT),
'', 1);
1117 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1118 print
'<td class="liste_titre left">';
1119 print
$form->getSelectConditionsPaiements($search_paymentcond,
'search_paymentcond', -1, 1, 1,
'maxwidth100');
1123 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1124 print
'<td class="liste_titre left">';
1125 print
$form->select_types_paiements($search_paymentmode,
'search_paymentmode',
'', 0, 1, 1, 20, 1,
'maxwidth100', 1);
1128 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1130 print
'<td class="liste_titre right">';
1131 print
'<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).
'">';
1134 if (!empty($arrayfields[
'f.total_vat'][
'checked'])) {
1136 print
'<td class="liste_titre right">';
1137 print
'<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).
'">';
1140 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1142 print
'<td class="liste_titre right">';
1143 print
'<input class="flat" type="text" size="5" name="search_montant_localtax1" value="'.dol_escape_htmltag($search_montant_localtax1).
'">';
1146 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1148 print
'<td class="liste_titre right">';
1149 print
'<input class="flat" type="text" size="5" name="search_montant_localtax2" value="'.dol_escape_htmltag($search_montant_localtax2).
'">';
1152 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1154 print
'<td class="liste_titre right">';
1155 print
'<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).
'">';
1158 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1160 print
'<td class="liste_titre" align="center">';
1161 print
'<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).
'">';
1164 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1165 print
'<td class="liste_titre right">';
1168 if (!empty($arrayfields[
'rtp'][
'checked'])) {
1169 print
'<td class="liste_titre">';
1172 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1174 print
'<td class="liste_titre">';
1175 print
$form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1178 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1180 print
'<td class="liste_titre">';
1181 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1184 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1186 print
'<td class="liste_titre right">';
1187 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1190 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1192 print
'<td class="liste_titre right">';
1193 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).
'">';
1196 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1198 print
'<td class="liste_titre right">';
1199 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1202 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1203 print
'<td class="liste_titre">';
1206 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1207 print
'<td class="liste_titre right">';
1211 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1214 $parameters = array(
'arrayfields'=>$arrayfields);
1215 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1216 print $hookmanager->resPrint;
1218 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1219 print
'<td class="liste_titre">';
1223 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1224 print
'<td class="liste_titre">';
1228 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1229 print
'<td class="liste_titre maxwidthonsmartphone right">';
1230 $liststatus = array(
'0'=>$langs->trans(
"Draft"),
'1'=>$langs->trans(
"Unpaid"),
'2'=>$langs->trans(
"Paid"));
1231 print
$form->selectarray(
'search_status', $liststatus, $search_status, 1, 0, 0,
'', 0, 0, 0,
'',
'onrightofpage', 1);
1236 print
'<td class="liste_titre middle">';
1237 $searchpicto =
$form->showFilterButtons();
1244 print
'<tr class="liste_titre">';
1246 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1248 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1249 print_liste_field_titre($arrayfields[
'f.ref'][
'label'], $_SERVER[
'PHP_SELF'],
'f.ref,f.rowid',
'', $param,
'', $sortfield, $sortorder);
1251 if (!empty($arrayfields[
'f.ref_supplier'][
'checked'])) {
1252 print_liste_field_titre($arrayfields[
'f.ref_supplier'][
'label'], $_SERVER[
"PHP_SELF"],
'f.ref_supplier',
'', $param,
'', $sortfield, $sortorder);
1254 if (!empty($arrayfields[
'f.type'][
'checked'])) {
1255 print_liste_field_titre($arrayfields[
'f.type'][
'label'], $_SERVER[
"PHP_SELF"],
'f.type',
'', $param,
'', $sortfield, $sortorder);
1257 if (!empty($arrayfields[
'f.label'][
'checked'])) {
1258 print_liste_field_titre($arrayfields[
'f.label'][
'label'], $_SERVER[
'PHP_SELF'],
"f.libelle,f.rowid",
'', $param,
'', $sortfield, $sortorder);
1260 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1261 print_liste_field_titre($arrayfields[
'f.datef'][
'label'], $_SERVER[
'PHP_SELF'],
'f.datef,f.rowid',
'', $param,
'', $sortfield, $sortorder,
'center ');
1263 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1264 print_liste_field_titre($arrayfields[
'f.date_lim_reglement'][
'label'], $_SERVER[
'PHP_SELF'],
"f.date_lim_reglement",
'', $param,
'', $sortfield, $sortorder,
'center ');
1266 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1267 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
'PHP_SELF'],
"p.ref",
'', $param,
'', $sortfield, $sortorder);
1269 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1270 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
'PHP_SELF'],
's.nom',
'', $param,
'', $sortfield, $sortorder);
1272 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1273 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
1275 if (!empty($arrayfields[
's.town'][
'checked'])) {
1276 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1278 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1279 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder,
'center ');
1281 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1282 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.name_alias",
"", $param,
'', $sortfield, $sortorder);
1284 if (!empty($arrayfields[
'state.name_alias'][
'checked'])) {
1285 print_liste_field_titre($arrayfields[
'state.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1287 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1288 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1290 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1291 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1293 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1294 print_liste_field_titre($arrayfields[
'f.fk_cond_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_cond_reglement",
"", $param,
"", $sortfield, $sortorder);
1296 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1297 print_liste_field_titre($arrayfields[
'f.fk_mode_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_mode_reglement",
"", $param,
"", $sortfield, $sortorder);
1299 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1300 print_liste_field_titre($arrayfields[
'f.total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ht',
'', $param,
'', $sortfield, $sortorder,
'right ');
1302 if (!empty($arrayfields[
'f.total_vat'][
'checked'])) {
1303 print_liste_field_titre($arrayfields[
'f.total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_tva',
'', $param,
'', $sortfield, $sortorder,
'right ');
1305 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1306 print_liste_field_titre($arrayfields[
'f.total_localtax1'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax1',
'', $param,
'', $sortfield, $sortorder,
'right ');
1308 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1309 print_liste_field_titre($arrayfields[
'f.total_localtax2'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax2',
'', $param,
'', $sortfield, $sortorder,
'right ');
1311 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1312 print_liste_field_titre($arrayfields[
'f.total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ttc',
'', $param,
'', $sortfield, $sortorder,
'right ');
1314 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1315 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
'u.login',
'', $param,
'align="center"', $sortfield, $sortorder);
1317 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1318 print_liste_field_titre($arrayfields[
'dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1320 if (!empty($arrayfields[
'rtp'][
'checked'])) {
1321 print_liste_field_titre($arrayfields[
'rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1323 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1324 print_liste_field_titre($arrayfields[
'f.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1326 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1327 print_liste_field_titre($arrayfields[
'f.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1329 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1330 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1332 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1333 print_liste_field_titre($arrayfields[
'f.multicurrency_total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1335 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1336 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1338 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1339 print_liste_field_titre($arrayfields[
'multicurrency_dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1341 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1342 print_liste_field_titre($arrayfields[
'multicurrency_rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1345 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1347 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
1348 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1349 print $hookmanager->resPrint;
1350 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1351 print_liste_field_titre($arrayfields[
'f.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"f.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1353 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1354 print_liste_field_titre($arrayfields[
'f.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"f.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1356 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1357 print_liste_field_titre($arrayfields[
'f.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"fk_statut,paye,type",
"", $param,
'', $sortfield, $sortorder,
'right ');
1360 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1366 $projectstatic =
new Project($db);
1367 $userstatic =
new User($db);
1371 $totalarray = array();
1372 $totalarray[
'nbfield']=0;
1373 $totalarray[
'val'] = array();
1374 $totalarray[
'val'][
'f.total_ht']=0;
1375 $totalarray[
'val'][
'f.total_vat']=0;
1376 $totalarray[
'val'][
'f.total_localtax1']=0;
1377 $totalarray[
'val'][
'f.total_localtax1']=0;
1378 $totalarray[
'val'][
'f.total_ttc']=0;
1380 while ($i < min($num, $limit)) {
1381 $obj = $db->fetch_object(
$resql);
1383 $datelimit = $db->jdate($obj->datelimite);
1384 $facturestatic->id = $obj->facid;
1385 $facturestatic->ref = $obj->ref;
1386 $facturestatic->type = $obj->type;
1387 $facturestatic->ref_supplier = $obj->ref_supplier;
1388 $facturestatic->date_echeance = $db->jdate($obj->datelimite);
1389 $facturestatic->statut = $obj->fk_statut;
1390 $facturestatic->note_public = $obj->note_public;
1391 $facturestatic->note_private = $obj->note_private;
1392 $facturestatic->multicurrency_code = $obj->multicurrency_code;
1393 $facturestatic->multicurrency_tx = $obj->multicurrency_tx;
1394 $facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht;
1395 $facturestatic->multicurrency_total_tva = $obj->multicurrency_total_vat;
1396 $facturestatic->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
1398 $thirdparty->id = $obj->socid;
1399 $thirdparty->name = $obj->name;
1400 $thirdparty->name_alias = $obj->alias;
1401 $thirdparty->client = $obj->client;
1402 $thirdparty->fournisseur = $obj->fournisseur;
1403 $thirdparty->code_client = $obj->code_client;
1404 $thirdparty->code_compta_client = $obj->code_compta_client;
1405 $thirdparty->code_fournisseur = $obj->code_fournisseur;
1406 $thirdparty->code_compta_fournisseur = $obj->code_compta_fournisseur;
1407 $thirdparty->email = $obj->email;
1408 $thirdparty->country_code = $obj->country_code;
1410 $paiement = $facturestatic->getSommePaiement();
1411 $totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
1412 $totaldeposits = $facturestatic->getSumDepositsUsed();
1413 $totalpay = $paiement + $totalcreditnotes + $totaldeposits;
1414 $remaintopay = $obj->total_ttc - $totalpay;
1415 $multicurrency_paiement = $facturestatic->getSommePaiement(1);
1416 $multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
1417 $multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
1418 $multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
1419 $multicurrency_remaintopay =
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);
1421 $facturestatic->alreadypaid = ($paiement ? $paiement : 0);
1422 $facturestatic->paye = $obj->paye;
1423 $facturestatic->statut = $obj->fk_statut;
1424 $facturestatic->type = $obj->type;
1429 if ($facturestatic->isCreditNoteUsed()) {
1430 $remaintopay = -$facturestatic->getSumFromThisCreditNotesNotUsed();
1434 print
'<tr class="oddeven">';
1437 print
'<td class="nowrap center">';
1438 if ($massactionbutton || $massaction) {
1440 if (in_array($obj->facid, $arrayofselected)) {
1443 print
'<input id="cb'.$obj->facid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1447 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1448 print
'<td class="nowraponall">';
1450 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
1452 print
'<td class="nobordernopadding nowraponall">';
1453 print $facturestatic->getNomUrl(1,
'', 0, 0,
'', 0, -1, 1);
1456 $filedir = $conf->fournisseur->facture->dir_output.
'/'.
get_exdir($obj->facid, 2, 0, 0, $facturestatic,
'invoice_supplier').dol_sanitizeFileName($obj->ref);
1457 $subdir =
get_exdir($obj->facid, 2, 0, 0, $facturestatic,
'invoice_supplier').dol_sanitizeFileName($obj->ref);
1458 print $formfile->getDocumentsLink(
'facture_fournisseur', $subdir, $filedir);
1459 print
'</td></tr></table>';
1463 $totalarray[
'nbfield']++;
1468 if (!empty($arrayfields[
'f.ref_supplier'][
'checked'])) {
1469 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_supplier).
'">';
1470 print $obj->ref_supplier;
1473 $totalarray[
'nbfield']++;
1478 if (!empty($arrayfields[
'f.type'][
'checked'])) {
1479 print
'<td class="nowrap">';
1480 print $facturestatic->getLibType();
1483 $totalarray[
'nbfield']++;
1488 if (!empty($arrayfields[
'f.label'][
'checked'])) {
1489 print
'<td class="nowrap">';
1493 $totalarray[
'nbfield']++;
1498 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1499 print
'<td class="center nowrap">';
1503 $totalarray[
'nbfield']++;
1508 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1509 print
'<td class="center nowraponall">'.dol_print_date($datelimit,
'day');
1510 if ($facturestatic->hasDelay()) {
1511 print
img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
1515 $totalarray[
'nbfield']++;
1520 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1521 print
'<td class="nowrap">';
1522 if ($obj->project_id > 0) {
1523 $projectstatic->id = $obj->project_id;
1524 $projectstatic->ref = $obj->project_ref;
1525 $projectstatic->title = $obj->project_label;
1526 print $projectstatic->getNomUrl(1);
1530 $totalarray[
'nbfield']++;
1535 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1536 print
'<td class="tdoverflowmax150">';
1537 print $thirdparty->getNomUrl(1,
'supplier', 0, 0, -1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
1540 $totalarray[
'nbfield']++;
1544 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1545 print
'<td class="tdoverflowmax150">';
1546 print $thirdparty->name_alias;
1549 $totalarray[
'nbfield']++;
1553 if (!empty($arrayfields[
's.town'][
'checked'])) {
1554 print
'<td class="nocellnopadd">';
1558 $totalarray[
'nbfield']++;
1562 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1563 print
'<td class="nocellnopadd center tdoverflowmax100" title="'.dol_escape_htmltag($obj->zip).
'">';
1567 $totalarray[
'nbfield']++;
1571 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1572 print
"<td>".$obj->state_name.
"</td>\n";
1574 $totalarray[
'nbfield']++;
1578 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1579 print
'<td class="center">';
1580 $tmparray =
getCountry($obj->fk_pays,
'all');
1581 print $tmparray[
'label'];
1584 $totalarray[
'nbfield']++;
1588 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1589 print
'<td class="center">';
1590 if (empty($typenArray)) {
1591 $typenArray = $formcompany->typent_array(1);
1593 print $typenArray[$obj->typent_code];
1596 $totalarray[
'nbfield']++;
1601 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1602 $s =
$form->form_conditions_reglement($_SERVER[
'PHP_SELF'], $obj->fk_cond_reglement,
'none', 1,
'', -1, -1, 1);
1603 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
1607 $totalarray[
'nbfield']++;
1611 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1612 $s =
$form->form_modes_reglement($_SERVER[
'PHP_SELF'], $obj->fk_mode_reglement,
'none',
'', -1, 0,
'', 1);
1613 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
1617 $totalarray[
'nbfield']++;
1622 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1623 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
1625 $totalarray[
'nbfield']++;
1628 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ht';
1630 $totalarray[
'val'][
'f.total_ht'] += $obj->total_ht;
1633 if (!empty($arrayfields[
'f.total_vat'][
'checked'])) {
1634 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_vat).
"</span></td>\n";
1636 $totalarray[
'nbfield']++;
1639 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_vat';
1641 $totalarray[
'val'][
'f.total_vat'] += $obj->total_vat;
1644 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1645 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_localtax1).
"</span></td>\n";
1647 $totalarray[
'nbfield']++;
1650 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_localtax1';
1652 $totalarray[
'val'][
'f.total_localtax1'] += $obj->total_localtax1;
1655 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1656 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_localtax2).
"</span></td>\n";
1658 $totalarray[
'nbfield']++;
1661 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_localtax2';
1663 $totalarray[
'val'][
'f.total_localtax2'] += $obj->total_localtax2;
1666 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1667 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
1669 $totalarray[
'nbfield']++;
1672 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ttc';
1674 $totalarray[
'val'][
'f.total_ttc'] += $obj->total_ttc;
1677 $userstatic->id = $obj->fk_user_author;
1678 $userstatic->login = $obj->login;
1679 $userstatic->lastname = $obj->lastname;
1680 $userstatic->firstname = $obj->firstname;
1681 $userstatic->email = $obj->user_email;
1682 $userstatic->statut = $obj->user_statut;
1683 $userstatic->entity = $obj->entity;
1684 $userstatic->photo = $obj->photo;
1685 $userstatic->office_phone = $obj->office_phone;
1686 $userstatic->office_fax = $obj->office_fax;
1687 $userstatic->user_mobile = $obj->user_mobile;
1688 $userstatic->job = $obj->job;
1689 $userstatic->gender = $obj->gender;
1692 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1693 print
'<td class="tdoverflowmax150">';
1694 if ($userstatic->id) {
1695 print $userstatic->getLoginUrl(-1);
1701 $totalarray[
'nbfield']++;
1705 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1706 print
'<td class="right nowrap"><span class="amount">'.(!empty($totalpay) ?
price($totalpay, 0, $langs) :
'').
'</span></td>';
1708 $totalarray[
'nbfield']++;
1711 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalam';
1713 $totalarray[
'val'][
'totalam'] += $totalpay;
1716 if (!empty($arrayfields[
'rtp'][
'checked'])) {
1717 print
'<td class="right nowrap">'.(!empty($remaintopay) ?
price($remaintopay, 0, $langs) :
' ').
'</td>';
1719 $totalarray[
'nbfield']++;
1722 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'rtp';
1724 $totalarray[
'val'][
'rtp'] += $remaintopay;
1728 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1729 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
1731 $totalarray[
'nbfield']++;
1736 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1737 print
'<td class="nowrap">';
1738 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
1741 $totalarray[
'nbfield']++;
1745 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1746 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
1748 $totalarray[
'nbfield']++;
1752 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1753 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat).
"</span></td>\n";
1755 $totalarray[
'nbfield']++;
1759 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1760 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
1762 $totalarray[
'nbfield']++;
1765 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1766 print
'<td class="right nowrap"><span class="amount">'.(!empty($multicurrency_totalpay) ?
price($multicurrency_totalpay, 0, $langs) :
'').
'</span></td>';
1768 $totalarray[
'nbfield']++;
1773 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1774 print
'<td class="right nowrap"><span class="amount">';
1775 print (!empty($multicurrency_remaintopay) ?
price($multicurrency_remaintopay, 0, $langs) :
'');
1776 print
'</span></td>';
1778 $totalarray[
'nbfield']++;
1784 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1786 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1787 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1788 print $hookmanager->resPrint;
1791 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1792 print
'<td class="center nowrap">';
1793 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
1796 $totalarray[
'nbfield']++;
1800 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1801 print
'<td class="center nowrap">';
1802 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
1805 $totalarray[
'nbfield']++;
1809 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1810 print
'<td class="right nowrap">';
1811 print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $paiement, $obj->type);
1814 $totalarray[
'nbfield']++;
1820 print
'<td class="nowrap center">';
1821 if ($massactionbutton || $massaction) {
1823 if (in_array($obj->facid, $arrayofselected)) {
1826 print
'<input id="cb'.$obj->facid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1831 $totalarray[
'nbfield']++;
1840 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1846 foreach ($arrayfields as $key => $val) {
1847 if (!empty($val[
'checked'])) {
1851 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1856 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
1857 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1858 print $hookmanager->resPrint;
1865 $hidegeneratedfilelistifempty = 1;
1866 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
1867 $hidegeneratedfilelistifempty = 0;
1871 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
1872 $urlsource .= str_replace(
'&',
'&', $param);
1874 $filedir = $diroutputmassaction;
1875 $genallowed = $user->rights->facture->lire;
1876 $delallowed = $user->rights->facture->creer;
1879 print $formfile->showdocuments(
'massfilesarea_supplier_invoice',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage bank accounts.
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.
Class to manage suppliers.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.
$nbtotalofrecords
Count total nb of records.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.