38require
'../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
47require_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';
61$socid =
GETPOST(
'socid',
'int');
64if ($user->socid > 0) {
67 $socid = $user->socid;
70$search_all = trim((
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml'));
71$search_label =
GETPOST(
"search_label",
"alpha");
72$search_amount_no_tax =
GETPOST(
"search_amount_no_tax",
"alpha");
73$search_amount_all_tax =
GETPOST(
"search_amount_all_tax",
"alpha");
75$search_refsupplier =
GETPOST(
'search_refsupplier',
'alpha');
76$search_type =
GETPOST(
'search_type',
'int');
77$search_project =
GETPOST(
'search_project',
'alpha');
78$search_company =
GETPOST(
'search_company',
'alpha');
79$search_company_alias =
GETPOST(
'search_company_alias',
'alpha');
80$search_montant_ht =
GETPOST(
'search_montant_ht',
'alpha');
81$search_montant_vat =
GETPOST(
'search_montant_vat',
'alpha');
82$search_montant_localtax1 =
GETPOST(
'search_montant_localtax1',
'alpha');
83$search_montant_localtax2 =
GETPOST(
'search_montant_localtax2',
'alpha');
84$search_montant_ttc =
GETPOST(
'search_montant_ttc',
'alpha');
85$search_login =
GETPOST(
'search_login',
'alpha');
86$search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
87$search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
88$search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
89$search_multicurrency_montant_vat =
GETPOST(
'search_multicurrency_montant_vat',
'alpha');
90$search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
91$search_status =
GETPOST(
'search_status',
'int');
92$search_paymentmode =
GETPOST(
'search_paymentmode',
'int');
93$search_paymentcond =
GETPOST(
'search_paymentcond',
'int');
94$search_town =
GETPOST(
'search_town',
'alpha');
95$search_zip =
GETPOST(
'search_zip',
'alpha');
96$search_state =
GETPOST(
"search_state");
97$search_country =
GETPOST(
"search_country",
'int');
98$search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'int');
99$search_user =
GETPOST(
'search_user',
'int');
100$search_sale =
GETPOST(
'search_sale',
'int');
101$search_date_start =
GETPOSTDATE(
'search_date_start',
'',
'tzserver');
102$search_date_end =
GETPOSTDATE(
'search_date_end',
'23:59:59',
'tzserver');
103$search_datelimit_startday =
GETPOST(
'search_datelimit_startday',
'int');
104$search_datelimit_startmonth =
GETPOST(
'search_datelimit_startmonth',
'int');
105$search_datelimit_startyear =
GETPOST(
'search_datelimit_startyear',
'int');
106$search_datelimit_endday =
GETPOST(
'search_datelimit_endday',
'int');
107$search_datelimit_endmonth =
GETPOST(
'search_datelimit_endmonth',
'int');
108$search_datelimit_endyear =
GETPOST(
'search_datelimit_endyear',
'int');
109$search_datelimit_start =
dol_mktime(0, 0, 0, $search_datelimit_startmonth, $search_datelimit_startday, $search_datelimit_startyear);
110$search_datelimit_end =
dol_mktime(23, 59, 59, $search_datelimit_endmonth, $search_datelimit_endday, $search_datelimit_endyear);
111$search_btn =
GETPOST(
'button_search',
'alpha');
112$search_remove_btn =
GETPOST(
'button_removefilter',
'alpha');
113$search_categ_sup = trim(
GETPOST(
"search_categ_sup",
'int'));
114$search_product_category =
GETPOST(
'search_product_category',
'int');
116$option =
GETPOST(
'search_option');
117if ($option ==
'late') {
118 $search_status =
'1';
120$filter =
GETPOST(
'filtre',
'alpha');
123$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
124$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
125$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
126$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
127if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
131$offset = $limit * $page;
132$pageprev = $page - 1;
133$pagenext = $page + 1;
138 $sortfield =
"f.datef,f.rowid";
141$diroutputmassaction = $conf->fournisseur->facture->dir_output.
'/temp/massgeneration/'.$user->id;
147$hookmanager->initHooks(array(
'supplierinvoicelist'));
151$extrafields->fetch_name_optionals_label($object->table_element);
153$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
156$fieldstosearchall = array(
158 'f.ref_supplier'=>
'RefSupplier',
159 'f.note_public'=>
'NotePublic',
160 's.nom'=>
"ThirdParty",
161 'pd.description'=>
'Description',
163if (empty($user->socid)) {
164 $fieldstosearchall[
"f.note_private"] =
"NotePrivate";
167$checkedtypetiers = 0;
169 'f.ref'=>array(
'label'=>
"Ref",
'checked'=>1),
170 'f.ref_supplier'=>array(
'label'=>
"RefSupplier",
'checked'=>1),
171 'f.type'=>array(
'label'=>
"Type",
'checked'=>0),
172 'f.label'=>array(
'label'=>
"Label",
'checked'=>0),
173 'f.datef'=>array(
'label'=>
"DateInvoice",
'checked'=>1),
174 'f.date_lim_reglement'=>array(
'label'=>
"DateDue",
'checked'=>1),
175 'p.ref'=>array(
'label'=>
"ProjectRef",
'checked'=>0),
176 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1,
'position'=>41),
177 's.name_alias'=>array(
'label'=>
"AliasNameShort",
'checked'=>0,
'position'=>42),
178 's.town'=>array(
'label'=>
"Town",
'checked'=>-1,
'position'=>43),
179 's.zip'=>array(
'label'=>
"Zip",
'checked'=>1,
'position'=>44),
180 'state.nom'=>array(
'label'=>
"StateShort",
'checked'=>0,
'position'=>45),
181 'country.code_iso'=>array(
'label'=>
"Country",
'checked'=>0,
'position'=>46),
182 'typent.code'=>array(
'label'=>
"ThirdPartyType",
'checked'=>$checkedtypetiers,
'position'=>49),
183 'f.fk_cond_reglement'=>array(
'label'=>
"PaymentTerm",
'checked'=>1,
'position'=>50),
184 'f.fk_mode_reglement'=>array(
'label'=>
"PaymentMode",
'checked'=>1,
'position'=>52),
185 'f.total_ht'=>array(
'label'=>
"AmountHT",
'checked'=>1,
'position'=>105),
186 'f.total_vat'=>array(
'label'=>
"AmountVAT",
'checked'=>0,
'position'=>110),
187 'f.total_localtax1'=>array(
'label'=>$langs->transcountry(
"AmountLT1", $mysoc->country_code),
'checked'=>0,
'enabled'=>$mysoc->localtax1_assuj ==
"1",
'position'=>95),
188 'f.total_localtax2'=>array(
'label'=>$langs->transcountry(
"AmountLT2", $mysoc->country_code),
'checked'=>0,
'enabled'=>$mysoc->localtax2_assuj ==
"1",
'position'=>100),
189 'f.total_ttc'=>array(
'label'=>
"AmountTTC",
'checked'=>0,
'position'=>115),
190 'dynamount_payed'=>array(
'label'=>
"Paid",
'checked'=>0,
'position'=>116),
191 'rtp'=>array(
'label'=>
"Rest",
'checked'=>0,
'position'=>117),
192 'f.multicurrency_code'=>array(
'label'=>
'Currency',
'checked'=>0,
'position'=>205,
'enabled'=>(!isModEnabled(
"multicurrency") ? 0 : 1)),
193 'f.multicurrency_tx'=>array(
'label'=>
'CurrencyRate',
'checked'=>0,
'position'=>206,
'enabled'=>(!isModEnabled(
"multicurrency") ? 0 : 1)),
194 'f.multicurrency_total_ht'=>array(
'label'=>
'MulticurrencyAmountHT',
'position'=>207,
'checked'=>0,
'enabled'=>(!isModEnabled(
"multicurrency") ? 0 : 1)),
195 'f.multicurrency_total_vat'=>array(
'label'=>
'MulticurrencyAmountVAT',
'position'=>208,
'checked'=>0,
'enabled'=>(!isModEnabled(
"multicurrency") ? 0 : 1)),
196 'f.multicurrency_total_ttc'=>array(
'label'=>
'MulticurrencyAmountTTC',
'position'=>209,
'checked'=>0,
'enabled'=>(!isModEnabled(
"multicurrency") ? 0 : 1)),
197 'multicurrency_dynamount_payed'=>array(
'label'=>
'MulticurrencyAlreadyPaid',
'position'=>210,
'checked'=>0,
'enabled'=>(!isModEnabled(
"multicurrency") ? 0 : 1)),
198 'multicurrency_rtp'=>array(
'label'=>
'MulticurrencyRemainderToPay',
'checked'=>0,
'position'=>211,
'enabled'=>(!isModEnabled(
"multicurrency") ? 0 : 1)),
199 'u.login'=>array(
'label'=>
"Author",
'checked'=>1,
'position'=>500),
200 'f.datec'=>array(
'label'=>
"DateCreation",
'checked'=>0,
'position'=>501),
201 'f.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>502),
202 'f.fk_statut'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000),
205include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
210if (!isModEnabled(
'supplier_invoice')) {
213if ((!$user->hasRight(
"fournisseur",
"facture",
"lire") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))
214 || (!$user->hasRight(
"supplier_invoice",
"lire") && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))) {
218$permissiontoread = ($user->hasRight(
"fournisseur",
"facture",
"lire") || $user->hasRight(
"supplier_invoice",
"lire"));
219$permissiontoadd = ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer"));
220$permissiontodelete = ($user->hasRight(
"fournisseur",
"facture",
"supprimer") || $user->hasRight(
"supplier_invoice",
"supprimer"));
227if (
GETPOST(
'cancel',
'alpha')) {
231if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
235$parameters = array(
'socid'=>$socid);
236$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
241if (empty($reshook)) {
243 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_start =
'';
281 $search_date_end =
'';
282 $search_datelimit_startday =
'';
283 $search_datelimit_startmonth =
'';
284 $search_datelimit_startyear =
'';
285 $search_datelimit_endday =
'';
286 $search_datelimit_endmonth =
'';
287 $search_datelimit_endyear =
'';
288 $search_datelimit_start =
'';
289 $search_datelimit_end =
'';
291 $search_array_options = array();
292 $search_categ_sup = 0;
299 $objectclass =
'FactureFournisseur';
300 $objectlabel =
'SupplierInvoices';
301 $uploaddir = $conf->fournisseur->facture->dir_output;
302 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
304 if ($massaction ==
'banktransfertrequest') {
305 $langs->load(
"withdrawals");
307 if (!$user->hasRight(
"paymentbybanktransfer",
"create")) {
314 $arrayofselected = is_array($toselect) ? $toselect : array();
315 $listofbills = array();
316 foreach ($arrayofselected as $toselectid) {
318 $result = $objecttmp->fetch($toselectid);
320 $totalpaid = $objecttmp->getSommePaiement();
321 $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
322 $totaldeposits = $objecttmp->getSumDepositsUsed();
323 $objecttmp->resteapayer =
price2num($objecttmp->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
326 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"Draft"), $objecttmp->errors,
'errors');
327 } elseif ($objecttmp->paye || $objecttmp->resteapayer == 0) {
329 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AlreadyPaid"), $objecttmp->errors,
'errors');
330 } elseif ($objecttmp->resteapayer < 0) {
332 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AmountMustBePositive"), $objecttmp->errors,
'errors');
335 $rsql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
336 $rsql .=
" , pfd.date_traite as date_traite";
337 $rsql .=
" , pfd.amount";
338 $rsql .=
" , u.rowid as user_id, u.lastname, u.firstname, u.login";
339 $rsql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
340 $rsql .=
" , ".MAIN_DB_PREFIX.
"user as u";
341 $rsql .=
" WHERE fk_facture_fourn = ".((int) $objecttmp->id);
342 $rsql .=
" AND pfd.fk_user_demande = u.rowid";
343 $rsql .=
" AND pfd.traite = 0";
344 $rsql .=
" ORDER BY pfd.date_demande DESC";
346 $result_sql = $db->query($rsql);
348 $numprlv = $db->num_rows($result_sql);
353 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"RequestAlreadyDone"), $objecttmp->errors,
'warnings');
354 } elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code !=
'VIR') {
356 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"BadPaymentMethod"), $objecttmp->errors,
'errors');
358 $listofbills[] = $objecttmp;
364 if (!empty($listofbills)) {
365 $nbwithdrawrequestok = 0;
366 foreach ($listofbills as $aBill) {
368 $result = $aBill->demande_prelevement($user, $aBill->resteapayer,
'bank-transfer',
'supplier_invoice');
371 $nbwithdrawrequestok++;
377 if ($nbwithdrawrequestok > 0) {
378 setEventMessages($langs->trans(
"WithdrawRequestsDone", $nbwithdrawrequestok),
null,
'mesgs');
390$form =
new Form($db);
393$bankaccountstatic =
new Account($db);
400$title = $langs->trans(
"BillsSuppliers").($socid ?
' '.$soc->name :
'');
401$help_url =
'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores';
407 $sql =
'SELECT DISTINCT';
409$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,";
410$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,";
411$sql .=
" f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,";
412$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,';
413$sql .=
" f.note_public, f.note_private,";
414$sql .=
" f.fk_user_author,";
415$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,";
416$sql .=
" typent.code as typent_code,";
417$sql .=
" state.code_departement as state_code, state.nom as state_name,";
418$sql .=
" country.code as country_code,";
419$sql .=
" p.rowid as project_id, p.ref as project_ref, p.title as project_label,";
420$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';
424 $sql .=
', SUM(pf.amount) as dynamount_payed';
427if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
428 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
429 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
433$parameters = array();
434$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
435$sql .= $hookmanager->resPrint;
436$sql = preg_replace(
'/,\s*$/',
'', $sql);
440$sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
441$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
442$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
443$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
444$sql .=
', '.MAIN_DB_PREFIX.
'facture_fourn as f';
445if (isset($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
446 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (f.rowid = ef.fk_object)";
449 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn as pf ON pf.fk_facturefourn = f.rowid';
452 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn_det as pd ON f.rowid=pd.fk_facture_fourn';
454$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user AS u ON f.fk_user_author = u.rowid';
455$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = f.fk_projet";
457if ($search_sale > 0 || (!$user->hasRight(
"societe",
"client",
"voir") && !$socid)) {
458 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
460if ($search_user > 0) {
461 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
462 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
465$parameters = array();
466$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
467$sql .= $hookmanager->resPrint;
468$sql .=
' WHERE f.fk_soc = s.rowid';
469$sql .=
' AND f.entity IN ('.getEntity(
'facture_fourn').
')';
470if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
471 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
474 $sql .=
' AND s.rowid = '.((int) $socid);
477 if (is_numeric($search_ref)) {
486if ($search_refsupplier) {
489if ($search_type !=
'' && $search_type >= 0) {
490 if ($search_type ==
'0') {
491 $sql .=
" AND f.type = 0";
493 if ($search_type ==
'1') {
494 $sql .=
" AND f.type = 1";
496 if ($search_type ==
'2') {
497 $sql .=
" AND f.type = 2";
499 if ($search_type ==
'3') {
500 $sql .=
" AND f.type = 3";
505if ($search_project) {
508if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
509 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
511 if ($search_company) {
514 if ($search_company_alias) {
527if ($search_country) {
528 $sql .=
" AND s.fk_pays IN (".$db->sanitize($search_country).
')';
530if ($search_type_thirdparty !=
'' && $search_type_thirdparty >= 0) {
531 $sql .=
" AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).
')';
533if ($search_montant_ht !=
'') {
536if ($search_montant_vat !=
'') {
539if ($search_montant_localtax1 !=
'') {
540 $sql .=
natural_search(
'f.localtax1', $search_montant_localtax1, 1);
542if ($search_montant_localtax2 !=
'') {
543 $sql .=
natural_search(
'f.localtax2', $search_montant_localtax2, 1);
545if ($search_montant_ttc !=
'') {
548if ($search_multicurrency_code !=
'') {
549 $sql .=
" AND f.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
551if ($search_multicurrency_tx !=
'') {
552 $sql .=
natural_search(
'f.multicurrency_tx', $search_multicurrency_tx, 1);
554if ($search_multicurrency_montant_ht !=
'') {
555 $sql .=
natural_search(
'f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
557if ($search_multicurrency_montant_vat !=
'') {
558 $sql .=
natural_search(
'f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
560if ($search_multicurrency_montant_ttc !=
'') {
561 $sql .=
natural_search(
'f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
564 $sql .=
natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $search_login);
566if ($search_status !=
'' && $search_status >= 0) {
567 $sql .=
" AND f.fk_statut = ".((int) $search_status);
569if ($search_paymentmode > 0) {
570 $sql .=
" AND f.fk_mode_reglement = ".((int) $search_paymentmode);
572if ($search_paymentcond > 0) {
573 $sql .=
" AND f.fk_cond_reglement = ".((int) $search_paymentcond);
575if ($search_date_start) {
576 $sql .=
" AND f.datef >= '" . $db->idate($search_date_start) .
"'";
578if ($search_date_end) {
579 $sql .=
" AND f.datef <= '" . $db->idate($search_date_end) .
"'";
581if ($search_datelimit_start) {
582 $sql .=
" AND f.date_lim_reglement >= '" . $db->idate($search_datelimit_start) .
"'";
584if ($search_datelimit_end) {
585 $sql .=
" AND f.date_lim_reglement <= '" . $db->idate($search_datelimit_end) .
"'";
587if ($option ==
'late') {
588 $sql .=
" AND f.date_lim_reglement < '".$db->idate(
dol_now() - $conf->facture->fournisseur->warning_delay).
"'";
593$searchCategorySupplierList = $search_categ_sup ? array($search_categ_sup) : array();
594$searchCategorySupplierOperator = 0;
596if (!empty($searchCategorySupplierList)) {
597 $searchCategorySupplierSqlList = array();
598 $listofcategoryid =
'';
599 foreach ($searchCategorySupplierList as $searchCategorySupplier) {
600 if (intval($searchCategorySupplier) == -2) {
601 $searchCategorySupplierSqlList[] =
"NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)";
602 } elseif (intval($searchCategorySupplier) > 0) {
603 if ($searchCategorySupplierOperator == 0) {
604 $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).
")";
606 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategorySupplier);
610 if ($listofcategoryid) {
611 $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).
"))";
613 if ($searchCategorySupplierOperator == 1) {
614 if (!empty($searchCategorySupplierSqlList)) {
615 $sql .=
" AND (".implode(
' OR ', $searchCategorySupplierSqlList).
")";
618 if (!empty($searchCategorySupplierSqlList)) {
619 $sql .=
" AND (".implode(
' AND ', $searchCategorySupplierSqlList).
")";
624$searchCategoryProductList = $search_product_category ? array($search_product_category) : array();
625$searchCategoryProductOperator = 0;
626if (!empty($searchCategoryProductList)) {
627 $searchCategoryProductSqlList = array();
628 $listofcategoryid =
'';
629 foreach ($searchCategoryProductList as $searchCategoryProduct) {
630 if (intval($searchCategoryProduct) == -2) {
631 $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)";
632 } elseif (intval($searchCategoryProduct) > 0) {
633 if ($searchCategoryProductOperator == 0) {
634 $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).
")";
636 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
640 if ($listofcategoryid) {
641 $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).
"))";
643 if ($searchCategoryProductOperator == 1) {
644 if (!empty($searchCategoryProductSqlList)) {
645 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
648 if (!empty($searchCategoryProductSqlList)) {
649 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
653if ($search_status !=
'' && $search_status >= 0) {
654 $sql .=
" AND f.fk_statut = ".((int) $search_status);
656if ($filter && $filter != -1) {
657 $aFilter = explode(
',', $filter);
658 foreach ($aFilter as $fil) {
659 $filt = explode(
':', $fil);
660 $sql .=
" AND ".$db->escape(trim($filt[0])).
" = '".$db->escape(trim($filt[1])).
"'";
663if ($search_sale > 0) {
664 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
666if ($search_user > 0) {
667 $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);
670include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
672$parameters = array();
673$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
674$sql .= $hookmanager->resPrint;
677 $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,";
678 $sql .=
" f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,";
679 $sql .=
" f.localtax1, f.localtax2,";
680 $sql .=
' f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,';
681 $sql .=
" f.note_public, f.note_private,";
682 $sql .=
" f.fk_user_author,";
683 $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,';
684 $sql .=
" typent.code,";
685 $sql .=
" state.code_departement, state.nom,";
686 $sql .=
' country.code,';
687 $sql .=
" p.rowid, p.ref, p.title,";
688 $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";
689 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
690 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
692 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
",ef.".$key :
'');
696 $parameters = array(
'all' => $search_all,
'fieldstosearchall' => $fieldstosearchall);
697 $reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters, $object, $action);
698 $sql .= $hookmanager->resPrint;
700 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
704$parameters = array();
705$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object, $action);
706$sql .= empty($hookmanager->resPrint) ?
"" :
" HAVING 1=1 ".$hookmanager->resPrint;
709$nbtotalofrecords =
'';
712 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(DISTINCT f.rowid) as nbtotalofrecords', $sql);
714 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
715 $resql = $db->query($sqlforcount);
717 $objforcount = $db->fetch_object($resql);
718 $nbtotalofrecords = $objforcount->nbtotalofrecords;
723 if (($page * $limit) > $nbtotalofrecords) {
731$sql .= $db->order($sortfield, $sortorder);
733 $sql .= $db->plimit($limit + 1, $offset);
737$resql = $db->query($sql);
743$num = $db->num_rows($resql);
745if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) {
746 $obj = $db->fetch_object($resql);
749 header(
"Location: ".DOL_URL_ROOT.
'/fourn/facture/card.php?facid='.$id);
761 if (empty($search_company)) {
762 $search_company = $soc->name;
763 $search_company_alias = $soc->name_alias;
767$arrayofselected = is_array($toselect) ? $toselect : array();
769$param =
'&socid='.$socid;
771 $param .=
'&mode='.urlencode($mode);
773if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
774 $param .=
'&contextpage='.urlencode($contextpage);
776if ($limit > 0 && $limit != $conf->liste_limit) {
777 $param .=
'&limit='.((int) $limit);
779if ($optioncss !=
'') {
780 $param .=
'&optioncss='.urlencode($optioncss);
783 $param .=
'&search_all='.urlencode($search_all);
785if ($search_date_start) {
786 $param .=
buildParamDate(
'search_date_start',
null,
'',
'tzserver');
788if ($search_date_end) {
789 $param .=
buildParamDate(
'search_date_end',
null,
'',
'tzserver');
791if ($search_datelimit_startday) {
792 $param .=
'&search_datelimit_startday='.urlencode($search_datelimit_startday);
794if ($search_datelimit_startmonth) {
795 $param .=
'&search_datelimit_startmonth='.urlencode($search_datelimit_startmonth);
797if ($search_datelimit_startyear) {
798 $param .=
'&search_datelimit_startyear='.urlencode($search_datelimit_startyear);
800if ($search_datelimit_endday) {
801 $param .=
'&search_datelimit_endday='.urlencode($search_datelimit_endday);
803if ($search_datelimit_endmonth) {
804 $param .=
'&search_datelimit_endmonth='.urlencode($search_datelimit_endmonth);
806if ($search_datelimit_endyear) {
807 $param .=
'&search_datelimit_endyear='.urlencode($search_datelimit_endyear);
810 $param .=
'&search_ref='.urlencode($search_ref);
812if ($search_refsupplier) {
813 $param .=
'&search_refsupplier='.urlencode($search_refsupplier);
815if ($search_type !=
'') {
816 $param .=
'&search_type='.urlencode($search_type);
819 $param .=
'&search_label='.urlencode($search_label);
821if ($search_company) {
822 $param .=
'&search_company='.urlencode($search_company);
824if ($search_company_alias) {
825 $param .=
'&search_company_alias='.urlencode($search_company_alias);
828 $param .=
'&search_login='.urlencode($search_login);
830if ($search_montant_ht !=
'') {
831 $param .=
'&search_montant_ht='.urlencode($search_montant_ht);
833if ($search_montant_vat !=
'') {
834 $param .=
'&search_montant_vat='.urlencode($search_montant_vat);
836if ($search_montant_localtax1 !=
'') {
837 $param .=
'&search_montant_localtax1='.urlencode($search_montant_localtax1);
839if ($search_montant_localtax2 !=
'') {
840 $param .=
'&search_montant_localtax2='.urlencode($search_montant_localtax2);
842if ($search_montant_ttc !=
'') {
843 $param .=
'&search_montant_ttc='.urlencode($search_montant_ttc);
845if ($search_multicurrency_code !=
'') {
846 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
848if ($search_multicurrency_tx !=
'') {
849 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
851if ($search_multicurrency_montant_ht !=
'') {
852 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
854if ($search_multicurrency_montant_vat !=
'') {
855 $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
857if ($search_multicurrency_montant_ttc !=
'') {
858 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
860if ($search_amount_no_tax) {
861 $param .=
'&search_amount_no_tax='.urlencode($search_amount_no_tax);
863if ($search_amount_all_tax) {
864 $param .=
'&search_amount_all_tax='.urlencode($search_amount_all_tax);
866if ($search_status >= 0) {
867 $param .=
"&search_status=".urlencode($search_status);
869if ($search_paymentmode) {
870 $param .=
'&search_paymentmode='.urlencode($search_paymentmode);
872if ($search_paymentcond) {
873 $param .=
'&search_paymentcond='.urlencode($search_paymentcond);
876 $param .=
'&show_files='.urlencode($show_files);
879 $param .=
"&search_option=".urlencode($option);
881if ($search_categ_sup > 0) {
882 $param .=
'&search_categ_sup='.urlencode($search_categ_sup);
884if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
885 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
889include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
891$parameters = array();
892$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
893$param .= $hookmanager->resPrint;
896$arrayofmassactions = array(
897 'validate'=>
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate"),
898 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
903if (isModEnabled(
'paymentbybanktransfer') && $user->hasRight(
"paymentbybanktransfer",
"create")) {
904 $langs->load(
'withdrawals');
905 $arrayofmassactions[
'banktransfertrequest'] =
img_picto(
'',
'payment',
'class="pictofixedwidth"').$langs->trans(
"MakeBankTransferOrder");
907if (!empty($permissiontodelete)) {
908 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
910if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
911 $arrayofmassactions = array();
913$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
915$url = DOL_URL_ROOT.
'/fourn/facture/card.php?action=create';
917 $url .=
'&socid='.urlencode($socid);
921print
'<form method="POST" id="searchFormList" name="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
922if ($optioncss !=
'') {
923 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
925print
'<input type="hidden" name="token" value="'.newToken().
'">';
926print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
927print
'<input type="hidden" name="action" value="list">';
928print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
929print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
930print
'<input type="hidden" name="socid" value="'.$socid.
'">';
931print
'<input type="hidden" name="page" value="'.$page.
'">';
932print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
933print
'<input type="hidden" name="page_y" value="">';
934print
'<input type="hidden" name="mode" value="'.$mode.
'">';
937$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'));
938$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'));
940$newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewBill'),
'',
'fa fa-plus-circle', $url,
'', ($user->hasRight(
"fournisseur",
"facture",
"creer") || $user->hasRight(
"supplier_invoice",
"creer")));
942print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'supplier_invoice', 0, $newcardbutton,
'', $limit, 0, 0, 1);
944$topicmail =
"SendBillRef";
945$modelmail =
"invoice_supplier_send";
947$trackid =
'sinv'.$object->id;
948include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
952 foreach ($fieldstosearchall as $key => $val) {
953 $fieldstosearchall[$key] = $langs->trans($val);
954 $setupstring .= $key.
"=".$val.
";";
956 print
'<!-- Search done like if SUPPLIER_INVOICE_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
957 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>'.
"\n";
962if ($user->hasRight(
"user",
"user",
"lire")) {
963 $langs->load(
"commercial");
964 $moreforfilter .=
'<div class="divsearchfield">';
965 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
966 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth200');
967 $moreforfilter .=
'</div>';
970if ($user->hasRight(
"user",
"user",
"lire")) {
971 $moreforfilter .=
'<div class="divsearchfield">';
972 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
973 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth200');
974 $moreforfilter .=
'</div>';
977if (isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
978 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
979 $moreforfilter .=
'<div class="divsearchfield">';
980 $tmptitle = $langs->trans(
'IncludingProductWithTag');
981 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
982 $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);
983 $moreforfilter .=
'</div>';
986if (isModEnabled(
'categorie')) {
987 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
988 $moreforfilter .=
'<div class="divsearchfield">';
989 $tmptitle = $langs->trans(
'SuppliersCategoriesShort');
990 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$formother->select_categories(
'supplier', $search_categ_sup,
'search_categ_sup', 1, $tmptitle);
991 $moreforfilter .=
'</div>';
993$parameters = array();
994$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
995if (empty($reshook)) {
996 $moreforfilter .= $hookmanager->resPrint;
998 $moreforfilter = $hookmanager->resPrint;
1001if (!empty($moreforfilter)) {
1002 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1003 print $moreforfilter;
1007$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1008$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1009$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
1011print
'<div class="div-table-responsive">';
1012print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1016print
'<tr class="liste_titre_filter">';
1019 print
'<td class="liste_titre center maxwidthsearch">';
1020 $searchpicto = $form->showFilterButtons(
'left');
1025if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1026 print
'<td class="liste_titre left">';
1027 print
'<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1031if (!empty($arrayfields[
'f.ref_supplier'][
'checked'])) {
1032 print
'<td class="liste_titre">';
1033 print
'<input class="flat maxwidth75" type="text" name="search_refsupplier" value="'.dol_escape_htmltag($search_refsupplier).
'">';
1037if (!empty($arrayfields[
'f.type'][
'checked'])) {
1038 print
'<td class="liste_titre maxwidthonsmartphone">';
1052 print $form->selectarray(
'search_type', $listtype, $search_type, 1, 0, 0,
'', 0, 0, 0,
'ASC',
'maxwidth100');
1056if (!empty($arrayfields[
'f.label'][
'checked'])) {
1057 print
'<td class="liste_titre">';
1058 print
'<input class="flat maxwidth75" type="text" name="search_label" value="'.dol_escape_htmltag($search_label).
'">';
1062if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1063 print
'<td class="liste_titre center">';
1064 print
'<div class="nowrap">';
1065 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1067 print
'<div class="nowrap">';
1068 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1073if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1074 print
'<td class="liste_titre center">';
1075 print
'<div class="nowrap">';
1082 print $form->selectDate($search_datelimit_end ? $search_datelimit_end : -1,
'search_datelimit_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"Before"));
1083 print
'<br><input type="checkbox" name="search_option" value="late"'.($option ==
'late' ?
' checked' :
'').
'> '.$langs->trans(
"Alert");
1088if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1089 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_project" value="'.dol_escape_htmltag($search_project).
'"></td>';
1092if (!empty($arrayfields[
's.nom'][
'checked'])) {
1093 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).
'"'.($socid > 0 ?
" disabled" :
"").
'></td>';
1096if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1097 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).
'"></td>';
1100if (!empty($arrayfields[
's.town'][
'checked'])) {
1101 print
'<td class="liste_titre"><input class="flat maxwidth50" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
1104if (!empty($arrayfields[
's.zip'][
'checked'])) {
1105 print
'<td class="liste_titre center"><input class="flat maxwidth50" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
1108if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1109 print
'<td class="liste_titre">';
1110 print
'<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1114if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1115 print
'<td class="liste_titre center">';
1116 print $form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
1120if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1121 print
'<td class="liste_titre maxwidthonsmartphone center">';
1122 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);
1126if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1127 print
'<td class="liste_titre left">';
1128 print $form->getSelectConditionsPaiements($search_paymentcond,
'search_paymentcond', -1, 1, 1,
'maxwidth100');
1132if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1133 print
'<td class="liste_titre left">';
1134 print $form->select_types_paiements($search_paymentmode,
'search_paymentmode',
'', 0, 1, 1, 20, 1,
'maxwidth100', 1);
1137if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1139 print
'<td class="liste_titre right">';
1140 print
'<input class="flat" type="text" size="5" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).
'">';
1143if (!empty($arrayfields[
'f.total_vat'][
'checked'])) {
1145 print
'<td class="liste_titre right">';
1146 print
'<input class="flat" type="text" size="5" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).
'">';
1149if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1151 print
'<td class="liste_titre right">';
1152 print
'<input class="flat" type="text" size="5" name="search_montant_localtax1" value="'.dol_escape_htmltag($search_montant_localtax1).
'">';
1155if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1157 print
'<td class="liste_titre right">';
1158 print
'<input class="flat" type="text" size="5" name="search_montant_localtax2" value="'.dol_escape_htmltag($search_montant_localtax2).
'">';
1161if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1163 print
'<td class="liste_titre right">';
1164 print
'<input class="flat" type="text" size="5" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).
'">';
1167if (!empty($arrayfields[
'u.login'][
'checked'])) {
1169 print
'<td class="liste_titre" align="center">';
1170 print
'<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).
'">';
1173if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1174 print
'<td class="liste_titre right">';
1177if (!empty($arrayfields[
'rtp'][
'checked'])) {
1178 print
'<td class="liste_titre">';
1181if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1183 print
'<td class="liste_titre">';
1184 print $form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1187if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1189 print
'<td class="liste_titre">';
1190 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1193if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1195 print
'<td class="liste_titre right">';
1196 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1199if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1201 print
'<td class="liste_titre right">';
1202 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).
'">';
1205if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1207 print
'<td class="liste_titre right">';
1208 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1211if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1212 print
'<td class="liste_titre">';
1215if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1216 print
'<td class="liste_titre right">';
1220include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1223$parameters = array(
'arrayfields'=>$arrayfields);
1224$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1225print $hookmanager->resPrint;
1227if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1228 print
'<td class="liste_titre">';
1232if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1233 print
'<td class="liste_titre">';
1237if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1238 print
'<td class="liste_titre right parentonrightofpage">';
1239 $liststatus = array(
'0'=>$langs->trans(
"Draft"),
'1'=>$langs->trans(
"Unpaid"),
'2'=>$langs->trans(
"Paid"));
1240 print $form->selectarray(
'search_status', $liststatus, $search_status, 1, 0, 0,
'', 0, 0, 0,
'',
'search_status width100 onrightofpage', 1);
1245 print
'<td class="liste_titre center maxwidthsearch">';
1246 $searchpicto = $form->showFilterButtons();
1253$totalarray = array();
1254$totalarray[
'nbfield'] = 0;
1258print
'<tr class="liste_titre">';
1260 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1261 $totalarray[
'nbfield']++;
1263if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1264 print_liste_field_titre($arrayfields[
'f.ref'][
'label'], $_SERVER[
'PHP_SELF'],
'f.ref,f.rowid',
'', $param,
'', $sortfield, $sortorder);
1265 $totalarray[
'nbfield']++;
1267if (!empty($arrayfields[
'f.ref_supplier'][
'checked'])) {
1268 print_liste_field_titre($arrayfields[
'f.ref_supplier'][
'label'], $_SERVER[
"PHP_SELF"],
'f.ref_supplier',
'', $param,
'', $sortfield, $sortorder);
1269 $totalarray[
'nbfield']++;
1271if (!empty($arrayfields[
'f.type'][
'checked'])) {
1272 print_liste_field_titre($arrayfields[
'f.type'][
'label'], $_SERVER[
"PHP_SELF"],
'f.type',
'', $param,
'', $sortfield, $sortorder);
1273 $totalarray[
'nbfield']++;
1275if (!empty($arrayfields[
'f.label'][
'checked'])) {
1276 print_liste_field_titre($arrayfields[
'f.label'][
'label'], $_SERVER[
'PHP_SELF'],
"f.libelle,f.rowid",
'', $param,
'', $sortfield, $sortorder);
1277 $totalarray[
'nbfield']++;
1279if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1280 print_liste_field_titre($arrayfields[
'f.datef'][
'label'], $_SERVER[
'PHP_SELF'],
'f.datef,f.rowid',
'', $param,
'', $sortfield, $sortorder,
'center ');
1281 $totalarray[
'nbfield']++;
1283if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1284 print_liste_field_titre($arrayfields[
'f.date_lim_reglement'][
'label'], $_SERVER[
'PHP_SELF'],
"f.date_lim_reglement",
'', $param,
'', $sortfield, $sortorder,
'center ');
1285 $totalarray[
'nbfield']++;
1287if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1288 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
'PHP_SELF'],
"p.ref",
'', $param,
'', $sortfield, $sortorder);
1289 $totalarray[
'nbfield']++;
1291if (!empty($arrayfields[
's.nom'][
'checked'])) {
1292 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
'PHP_SELF'],
's.nom',
'', $param,
'', $sortfield, $sortorder);
1293 $totalarray[
'nbfield']++;
1295if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1296 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
1297 $totalarray[
'nbfield']++;
1299if (!empty($arrayfields[
's.town'][
'checked'])) {
1300 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1301 $totalarray[
'nbfield']++;
1303if (!empty($arrayfields[
's.zip'][
'checked'])) {
1304 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder,
'center ');
1305 $totalarray[
'nbfield']++;
1307if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1308 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.name_alias",
"", $param,
'', $sortfield, $sortorder);
1309 $totalarray[
'nbfield']++;
1311if (!empty($arrayfields[
'state.name_alias'][
'checked'])) {
1312 print_liste_field_titre($arrayfields[
'state.name_alias'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1313 $totalarray[
'nbfield']++;
1315if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1316 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1317 $totalarray[
'nbfield']++;
1319if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1320 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1321 $totalarray[
'nbfield']++;
1323if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1324 print_liste_field_titre($arrayfields[
'f.fk_cond_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_cond_reglement",
"", $param,
"", $sortfield, $sortorder);
1325 $totalarray[
'nbfield']++;
1327if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1328 print_liste_field_titre($arrayfields[
'f.fk_mode_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_mode_reglement",
"", $param,
"", $sortfield, $sortorder);
1329 $totalarray[
'nbfield']++;
1331if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1332 print_liste_field_titre($arrayfields[
'f.total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ht',
'', $param,
'', $sortfield, $sortorder,
'right ');
1333 $totalarray[
'nbfield']++;
1335if (!empty($arrayfields[
'f.total_vat'][
'checked'])) {
1336 print_liste_field_titre($arrayfields[
'f.total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_tva',
'', $param,
'', $sortfield, $sortorder,
'right ');
1337 $totalarray[
'nbfield']++;
1339if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1340 print_liste_field_titre($arrayfields[
'f.total_localtax1'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax1',
'', $param,
'', $sortfield, $sortorder,
'right ');
1341 $totalarray[
'nbfield']++;
1343if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1344 print_liste_field_titre($arrayfields[
'f.total_localtax2'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax2',
'', $param,
'', $sortfield, $sortorder,
'right ');
1345 $totalarray[
'nbfield']++;
1347if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1348 print_liste_field_titre($arrayfields[
'f.total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ttc',
'', $param,
'', $sortfield, $sortorder,
'right ');
1349 $totalarray[
'nbfield']++;
1351if (!empty($arrayfields[
'u.login'][
'checked'])) {
1352 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
'u.login',
'', $param,
'align="center"', $sortfield, $sortorder);
1353 $totalarray[
'nbfield']++;
1355if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1356 print_liste_field_titre($arrayfields[
'dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1357 $totalarray[
'nbfield']++;
1359if (!empty($arrayfields[
'rtp'][
'checked'])) {
1360 print_liste_field_titre($arrayfields[
'rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1361 $totalarray[
'nbfield']++;
1363if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1364 print_liste_field_titre($arrayfields[
'f.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1365 $totalarray[
'nbfield']++;
1367if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1368 print_liste_field_titre($arrayfields[
'f.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1369 $totalarray[
'nbfield']++;
1371if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1372 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ht',
'', $param,
'class="right"', $sortfield, $sortorder);
1373 $totalarray[
'nbfield']++;
1375if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1376 print_liste_field_titre($arrayfields[
'f.multicurrency_total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_tva',
'', $param,
'class="right"', $sortfield, $sortorder);
1377 $totalarray[
'nbfield']++;
1379if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1380 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ttc',
'', $param,
'class="right"', $sortfield, $sortorder);
1381 $totalarray[
'nbfield']++;
1383if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1384 print_liste_field_titre($arrayfields[
'multicurrency_dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1385 $totalarray[
'nbfield']++;
1387if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1388 print_liste_field_titre($arrayfields[
'multicurrency_rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'class="right"', $sortfield, $sortorder);
1389 $totalarray[
'nbfield']++;
1392include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1394$parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray'=>&$totalarray);
1395$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1396print $hookmanager->resPrint;
1397if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1398 print_liste_field_titre($arrayfields[
'f.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"f.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1399 $totalarray[
'nbfield']++;
1401if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1402 print_liste_field_titre($arrayfields[
'f.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"f.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1403 $totalarray[
'nbfield']++;
1405if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1406 print_liste_field_titre($arrayfields[
'f.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"fk_statut,paye,type",
"", $param,
'', $sortfield, $sortorder,
'right ');
1407 $totalarray[
'nbfield']++;
1410 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1411 $totalarray[
'nbfield']++;
1417$projectstatic =
new Project($db);
1418$userstatic =
new User($db);
1423$savnbfield = $totalarray[
'nbfield'];
1424$totalarray = array();
1425$totalarray[
'nbfield'] = 0;
1426$totalarray[
'val'] = array();
1427$totalarray[
'val'][
'f.total_ht']=0;
1428$totalarray[
'val'][
'f.total_vat']=0;
1429$totalarray[
'val'][
'f.total_localtax1']=0;
1430$totalarray[
'val'][
'f.total_localtax1']=0;
1431$totalarray[
'val'][
'f.total_ttc']=0;
1432$imaxinloop = ($limit ? min($num, $limit) : $num);
1433while ($i < $imaxinloop) {
1434 $obj = $db->fetch_object($resql);
1439 $datelimit = $db->jdate($obj->datelimite);
1441 $userstatic->id = $obj->fk_user_author;
1442 $userstatic->login = $obj->login;
1443 $userstatic->lastname = $obj->lastname;
1444 $userstatic->firstname = $obj->firstname;
1445 $userstatic->email = $obj->user_email;
1446 $userstatic->statut = $obj->user_statut;
1447 $userstatic->entity = $obj->entity;
1448 $userstatic->photo = $obj->photo;
1449 $userstatic->office_phone = $obj->office_phone;
1450 $userstatic->office_fax = $obj->office_fax;
1451 $userstatic->user_mobile = $obj->user_mobile;
1452 $userstatic->job = $obj->job;
1453 $userstatic->gender = $obj->gender;
1455 $facturestatic->id = $obj->facid;
1456 $facturestatic->ref = $obj->ref;
1457 $facturestatic->type = $obj->type;
1458 $facturestatic->ref_supplier = $obj->ref_supplier;
1459 $facturestatic->date_echeance = $db->jdate($obj->datelimite);
1460 $facturestatic->statut = $obj->fk_statut;
1461 $facturestatic->note_public = $obj->note_public;
1462 $facturestatic->note_private = $obj->note_private;
1463 $facturestatic->multicurrency_code = $obj->multicurrency_code;
1464 $facturestatic->multicurrency_tx = $obj->multicurrency_tx;
1465 $facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht;
1466 $facturestatic->multicurrency_total_tva = $obj->multicurrency_total_vat;
1467 $facturestatic->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
1469 $thirdparty->id = $obj->socid;
1470 $thirdparty->name = $obj->name;
1471 $thirdparty->name_alias = $obj->alias;
1472 $thirdparty->client = $obj->client;
1473 $thirdparty->fournisseur = $obj->fournisseur;
1474 $thirdparty->code_client = $obj->code_client;
1475 $thirdparty->code_compta_client = $obj->code_compta_client;
1476 $thirdparty->code_fournisseur = $obj->code_fournisseur;
1477 $thirdparty->code_compta_fournisseur = $obj->code_compta_fournisseur;
1478 $thirdparty->email = $obj->email;
1479 $thirdparty->country_code = $obj->country_code;
1481 $paiement = $facturestatic->getSommePaiement();
1482 $totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
1483 $totaldeposits = $facturestatic->getSumDepositsUsed();
1484 $totalpay = $paiement + $totalcreditnotes + $totaldeposits;
1485 $remaintopay = $obj->total_ttc - $totalpay;
1486 $multicurrency_paiement = $facturestatic->getSommePaiement(1);
1487 $multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
1488 $multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
1489 $multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
1490 $multicurrency_remaintopay =
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);
1492 $facturestatic->alreadypaid = ($paiement ? $paiement : 0);
1493 $facturestatic->paye = $obj->paye;
1494 $facturestatic->statut = $obj->fk_statut;
1495 $facturestatic->type = $obj->type;
1496 $facturestatic->socid = $thirdparty->getNomUrl(1,
'supplier', 3);
1497 $facturestatic->total_ht = $obj->total_ht;
1498 $facturestatic->date = $db->jdate($obj->datef);
1500 $object = $facturestatic;
1504 if ($facturestatic->isCreditNoteUsed()) {
1505 $remaintopay = -$facturestatic->getSumFromThisCreditNotesNotUsed();
1509 if ($mode ==
'kanban') {
1511 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
1512 print
'<div class="box-flex-container kanban">';
1515 if ($massactionbutton || $massaction) {
1517 if (in_array($object->id, $arrayofselected)) {
1522 $arraydata = array(
'alreadypaid' => $paiement,
'thirdparty' => $thirdparty->getNomUrl(1,
'', 12));
1523 print $facturestatic->getKanbanView(
'', $arraydata);
1524 if ($i == ($imaxinloop - 1)) {
1531 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
1535 print
'<td class="nowrap center">';
1536 if ($massactionbutton || $massaction) {
1538 if (in_array($obj->facid, $arrayofselected)) {
1541 print
'<input id="cb'.$obj->facid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1545 $totalarray[
'nbfield']++;
1548 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1549 print
'<td class="nowraponall">';
1551 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
1553 print
'<td class="nobordernopadding nowraponall">';
1554 print $facturestatic->getNomUrl(1,
'', 0, 0,
'', 0, -1, 1);
1557 $filedir = $conf->fournisseur->facture->dir_output.
'/'.
get_exdir($obj->facid, 2, 0, 0, $facturestatic,
'invoice_supplier').dol_sanitizeFileName($obj->ref);
1558 $subdir =
get_exdir($obj->facid, 2, 0, 0, $facturestatic,
'invoice_supplier').dol_sanitizeFileName($obj->ref);
1559 print $formfile->getDocumentsLink(
'facture_fournisseur', $subdir, $filedir);
1560 print
'</td></tr></table>';
1564 $totalarray[
'nbfield']++;
1569 if (!empty($arrayfields[
'f.ref_supplier'][
'checked'])) {
1570 print
'<td class="nowrap tdoverflowmax150" title="'.dol_escape_htmltag($obj->ref_supplier).
'">';
1571 print $obj->ref_supplier;
1574 $totalarray[
'nbfield']++;
1579 if (!empty($arrayfields[
'f.type'][
'checked'])) {
1580 print
'<td class="nowrap">';
1581 print $facturestatic->getLibType();
1584 $totalarray[
'nbfield']++;
1589 if (!empty($arrayfields[
'f.label'][
'checked'])) {
1590 print
'<td class="nowrap">';
1594 $totalarray[
'nbfield']++;
1599 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1600 print
'<td class="center nowrap">';
1604 $totalarray[
'nbfield']++;
1609 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1610 print
'<td class="center nowraponall">'.dol_print_date($datelimit,
'day');
1611 if ($facturestatic->hasDelay()) {
1612 print
img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
1616 $totalarray[
'nbfield']++;
1621 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1622 print
'<td class="nowrap">';
1623 if ($obj->project_id > 0) {
1624 $projectstatic->id = $obj->project_id;
1625 $projectstatic->ref = $obj->project_ref;
1626 $projectstatic->title = $obj->project_label;
1627 print $projectstatic->getNomUrl(1);
1631 $totalarray[
'nbfield']++;
1636 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1637 print
'<td class="tdoverflowmax150">';
1638 print $thirdparty->getNomUrl(1,
'supplier', 0, 0, -1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
1641 $totalarray[
'nbfield']++;
1645 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1646 print
'<td class="tdoverflowmax150">';
1650 $totalarray[
'nbfield']++;
1654 if (!empty($arrayfields[
's.town'][
'checked'])) {
1655 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).
'">';
1659 $totalarray[
'nbfield']++;
1663 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1664 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->zip).
'">';
1668 $totalarray[
'nbfield']++;
1672 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1673 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->state_name).
'">';
1677 $totalarray[
'nbfield']++;
1681 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1682 print
'<td class="center">';
1683 $tmparray =
getCountry($obj->fk_pays,
'all');
1684 print $tmparray[
'label'];
1687 $totalarray[
'nbfield']++;
1691 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1692 print
'<td class="center">';
1693 if (empty($typenArray)) {
1694 $typenArray = $formcompany->typent_array(1);
1696 print $typenArray[$obj->typent_code];
1699 $totalarray[
'nbfield']++;
1704 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1705 $s = $form->form_conditions_reglement($_SERVER[
'PHP_SELF'], $obj->fk_cond_reglement,
'none', 1,
'', -1, -1, 1);
1706 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
1710 $totalarray[
'nbfield']++;
1714 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1715 $s = $form->form_modes_reglement($_SERVER[
'PHP_SELF'], $obj->fk_mode_reglement,
'none',
'', -1, 0,
'', 1);
1716 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
1720 $totalarray[
'nbfield']++;
1725 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1726 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
1728 $totalarray[
'nbfield']++;
1731 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ht';
1733 $totalarray[
'val'][
'f.total_ht'] += $obj->total_ht;
1736 if (!empty($arrayfields[
'f.total_vat'][
'checked'])) {
1737 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_vat).
"</span></td>\n";
1739 $totalarray[
'nbfield']++;
1742 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_vat';
1744 $totalarray[
'val'][
'f.total_vat'] += $obj->total_vat;
1747 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1748 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_localtax1).
"</span></td>\n";
1750 $totalarray[
'nbfield']++;
1753 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_localtax1';
1755 $totalarray[
'val'][
'f.total_localtax1'] += $obj->total_localtax1;
1758 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1759 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_localtax2).
"</span></td>\n";
1761 $totalarray[
'nbfield']++;
1764 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_localtax2';
1766 $totalarray[
'val'][
'f.total_localtax2'] += $obj->total_localtax2;
1769 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1770 print
'<td class="right nowrap"><span class="amount">'.price($obj->total_ttc).
"</span></td>\n";
1772 $totalarray[
'nbfield']++;
1775 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ttc';
1777 $totalarray[
'val'][
'f.total_ttc'] += $obj->total_ttc;
1781 if (!empty($arrayfields[
'u.login'][
'checked'])) {
1782 print
'<td class="tdoverflowmax150">';
1783 if ($userstatic->id) {
1784 print $userstatic->getNomUrl(-1);
1790 $totalarray[
'nbfield']++;
1794 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1795 print
'<td class="right nowrap"><span class="amount">'.(!empty($totalpay) ?
price($totalpay, 0, $langs) :
'').
'</span></td>';
1797 $totalarray[
'nbfield']++;
1800 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'totalam';
1802 $totalarray[
'val'][
'totalam'] += $totalpay;
1805 if (!empty($arrayfields[
'rtp'][
'checked'])) {
1806 print
'<td class="right nowrap">'.(!empty($remaintopay) ?
price($remaintopay, 0, $langs) :
' ').
'</td>';
1808 $totalarray[
'nbfield']++;
1811 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'rtp';
1813 $totalarray[
'val'][
'rtp'] += $remaintopay;
1817 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1818 print
'<td class="nowrap">'.$obj->multicurrency_code.
' - '.$langs->trans(
'Currency'.$obj->multicurrency_code).
"</td>\n";
1820 $totalarray[
'nbfield']++;
1825 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1826 print
'<td class="nowrap">';
1827 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
1830 $totalarray[
'nbfield']++;
1834 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1835 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ht).
"</span></td>\n";
1837 $totalarray[
'nbfield']++;
1841 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1842 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_vat).
"</span></td>\n";
1844 $totalarray[
'nbfield']++;
1848 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1849 print
'<td class="right nowrap"><span class="amount">'.price($obj->multicurrency_total_ttc).
"</span></td>\n";
1851 $totalarray[
'nbfield']++;
1854 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1855 print
'<td class="right nowrap"><span class="amount">'.(!empty($multicurrency_totalpay) ?
price($multicurrency_totalpay, 0, $langs) :
'').
'</span></td>';
1857 $totalarray[
'nbfield']++;
1862 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1863 print
'<td class="right nowrap"><span class="amount">';
1864 print (!empty($multicurrency_remaintopay) ?
price($multicurrency_remaintopay, 0, $langs) :
'');
1865 print
'</span></td>';
1867 $totalarray[
'nbfield']++;
1873 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1875 $parameters = array(
'arrayfields'=>$arrayfields,
'object'=>$object,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1876 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1877 print $hookmanager->resPrint;
1880 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1881 print
'<td class="center nowrap">';
1882 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
1885 $totalarray[
'nbfield']++;
1889 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1890 print
'<td class="center nowrap">';
1891 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
1894 $totalarray[
'nbfield']++;
1898 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1899 print
'<td class="right nowrap">';
1900 print $facturestatic->getLibStatut(5, $paiement);
1903 $totalarray[
'nbfield']++;
1909 print
'<td class="nowrap center">';
1910 if ($massactionbutton || $massaction) {
1912 if (in_array($obj->facid, $arrayofselected)) {
1915 print
'<input id="cb'.$obj->facid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1919 $totalarray[
'nbfield']++;
1930include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1935 foreach ($arrayfields as $key => $val) {
1936 if (!empty($val[
'checked'])) {
1940 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1945$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
1946$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1947print $hookmanager->resPrint;
1949print
'</table>'.
"\n";
1952print
'</form>'.
"\n";
1954$hidegeneratedfilelistifempty = 1;
1955if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
1956 $hidegeneratedfilelistifempty = 0;
1960$urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
1961$urlsource .= str_replace(
'&',
'&', $param);
1963$filedir = $diroutputmassaction;
1964$genallowed = $user->hasRight(
'facture',
'lire');
1965$delallowed = $user->hasRight(
'facture',
'creer');
1968print $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.
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.
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...
GETPOSTDATE($prefix, $hourTime='', $gm='auto')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
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.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
buildParamDate($prefix, $timestamp=null, $hourTime='', $gm='auto')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.