46require
'../../main.inc.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
57require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
58require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
59require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
60require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
61require_once DOL_DOCUMENT_ROOT.
'/core/lib/invoice.lib.php';
62require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
63require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
64require_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
65require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
66require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
67require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
68require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
69require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
71 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
74 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
75 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcategory.class.php';
79$langs->loadLangs(array(
'bills',
'companies',
'products',
'categories',
'cashdesk'));
81$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
84$action =
GETPOST(
'action',
'aZ09');
85$massaction =
GETPOST(
'massaction',
'alpha');
87$confirm =
GETPOST(
'confirm',
'alpha');
88$toselect =
GETPOST(
'toselect',
'array:int');
89$optioncss =
GETPOST(
'optioncss',
'alpha');
90$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'invoicelist';
93if ($contextpage ==
'poslist') {
103$search_refcustomer =
GETPOST(
'search_refcustomer',
'alpha');
104$search_type =
GETPOST(
'search_type',
'intcomma');
105$search_subtype =
GETPOST(
'search_subtype',
'intcomma');
106$search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
107$search_project =
GETPOST(
'search_project',
'alpha');
108$search_company =
GETPOST(
'search_company',
'alpha');
109$search_company_alias =
GETPOST(
'search_company_alias',
'alpha');
110$search_parent_name = trim(
GETPOST(
'search_parent_name',
'alphanohtml'));
111$search_montant_ht =
GETPOST(
'search_montant_ht',
'alpha');
112$search_montant_vat =
GETPOST(
'search_montant_vat',
'alpha');
113$search_montant_localtax1 =
GETPOST(
'search_montant_localtax1',
'alpha');
114$search_montant_localtax2 =
GETPOST(
'search_montant_localtax2',
'alpha');
115$search_montant_ttc =
GETPOST(
'search_montant_ttc',
'alpha');
116$search_login =
GETPOST(
'search_login',
'alpha');
117$search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
118$search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
119$search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
120$search_multicurrency_montant_vat =
GETPOST(
'search_multicurrency_montant_vat',
'alpha');
121$search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
122$search_dispute_status =
GETPOST(
'search_dispute_status',
'intcomma');
123$search_status =
GETPOST(
'search_status',
'intcomma');
124$search_paymentmode =
GETPOST(
'search_paymentmode',
'intcomma');
125$search_paymentterms =
GETPOST(
'search_paymentterms',
'intcomma');
126$search_fk_input_reason =
GETPOSTINT(
'search_fk_input_reason');
127$search_module_source =
GETPOST(
'search_module_source',
'alpha');
128$search_pos_source =
GETPOST(
'search_pos_source',
'alpha');
129$search_town =
GETPOST(
'search_town',
'alpha');
130$search_zip =
GETPOST(
'search_zip',
'alpha');
131$search_state =
GETPOST(
"search_state");
132$search_country =
GETPOST(
"search_country",
'aZ09');
133$search_customer_code =
GETPOST(
"search_customer_code",
'alphanohtml');
134$search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'intcomma');
135$search_user =
GETPOST(
'search_user',
'intcomma');
136$search_sale =
GETPOST(
'search_sale',
'intcomma');
138$search_date_startday =
GETPOSTINT(
'search_date_startday');
139$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
140$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
141$search_date_endday =
GETPOSTINT(
'search_date_endday');
142$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
143$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
144$search_date_start =
GETPOSTDATE(
'search_date_start',
'getpost');
145$search_date_end =
GETPOSTDATE(
'search_date_end',
'getpostend');
147$search_date_valid_startday =
GETPOSTINT(
'search_date_valid_startday');
148$search_date_valid_startmonth =
GETPOSTINT(
'search_date_valid_startmonth');
149$search_date_valid_startyear =
GETPOSTINT(
'search_date_valid_startyear');
150$search_date_valid_endday =
GETPOSTINT(
'search_date_valid_endday');
151$search_date_valid_endmonth =
GETPOSTINT(
'search_date_valid_endmonth');
152$search_date_valid_endyear =
GETPOSTINT(
'search_date_valid_endyear');
153$search_date_valid_start =
GETPOSTDATE(
'search_date_valid_start',
'getpost');
154$search_date_valid_end =
GETPOSTDATE(
'search_date_valid_end',
'getpostend');
155$search_note_private =
GETPOST(
'search_note_private',
'alpha');
156$search_note_public =
GETPOST(
'search_note_public',
'alpha');
158$search_datelimit_startday =
GETPOSTINT(
'search_datelimit_startday');
159$search_datelimit_startmonth =
GETPOSTINT(
'search_datelimit_startmonth');
160$search_datelimit_startyear =
GETPOSTINT(
'search_datelimit_startyear');
161$search_datelimit_endday =
GETPOSTINT(
'search_datelimit_endday');
162$search_datelimit_endmonth =
GETPOSTINT(
'search_datelimit_endmonth');
163$search_datelimit_endyear =
GETPOSTINT(
'search_datelimit_endyear');
164$search_datelimit_start =
GETPOSTDATE(
'search_datelimit_start',
'getpost');
165$search_datelimit_end =
GETPOSTDATE(
'search_datelimit_end',
'getpostend');
168$search_datec_start =
GETPOSTDATE(
'search_datec_start',
'getpost',
'tzuserrel');
169$search_datec_end =
GETPOSTDATE(
'search_datec_end',
'getpostend',
'tzuserrel');
170$search_datem_start =
GETPOSTDATE(
'search_datem_start',
'getpost',
'tzuserrel');
171$search_datem_end =
GETPOSTDATE(
'search_datem_end',
'getpostend',
'tzuserrel');
173$search_categ_cus =
GETPOST(
"search_categ_cus",
'intcomma');
174$searchCategoryInvoiceOperator = 0;
175if (GETPOSTISSET(
'formfilteraction')) {
176 $searchCategoryInvoiceOperator =
GETPOSTINT(
'search_category_invoice_operator');
180$searchCategoryInvoiceList =
GETPOST(
'search_category_invoice_list',
'array:int');
183$search_product_category =
GETPOST(
'search_product_category',
'intcomma');
184$search_fac_rec_source_title =
GETPOST(
"search_fac_rec_source_title",
'alpha');
185$search_fk_fac_rec_source =
GETPOST(
'search_fk_fac_rec_source',
'int');
186$search_import_key = trim(
GETPOST(
"search_import_key",
"alpha"));
188$search_option =
GETPOST(
'search_option');
189if ($search_option ==
'late') {
190 $search_status =
'1';
194$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
195$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
197if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
202if ($contextpage ==
'poslist' && !GETPOSTISSET(
'limit')) {
206$offset = $limit * $page;
207if (!$sortorder &&
getDolGlobalString(
'INVOICE_DEFAULT_UNPAYED_SORT_ORDER') && $search_status ==
'1') {
214 $sortfield =
'f.datef';
216$pageprev = $page - 1;
217$pagenext = $page + 1;
219$diroutputmassaction = $conf->invoice->dir_output.
'/temp/massgeneration/'.$user->id;
227$hookmanager->initHooks(array($contextpage));
231$extrafields->fetch_name_optionals_label(
$object->table_element);
233$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_') ?: [];
236$fieldstosearchall = array(
238 'f.ref_client' =>
'RefCustomer',
239 'f.note_public' =>
'NotePublic',
240 's.nom' =>
"ThirdParty",
241 's.code_client' =>
"CustomerCodeShort",
242 's.name_alias' =>
"AliasNameShort",
245 'pd.description' =>
'ProductDescription',
247if (empty($user->socid)) {
248 $fieldstosearchall[
"f.note_private"] =
"NotePrivate";
254$checkedtypetiers =
'0';
256 'f.ref' => array(
'label' =>
"Ref",
'checked' =>
'1',
'position' => 5),
257 'f.ref_client' => array(
'label' =>
"RefCustomer",
'checked' =>
'-1',
'position' => 10),
258 'f.type' => array(
'label' =>
"Type",
'checked' =>
'0',
'position' => 15),
259 'f.subtype' => array(
'label' =>
"InvoiceSubtype",
'checked' =>
'0',
'position' => 17),
260 'f.datef' => array(
'label' =>
"DateInvoice",
'checked' =>
'1',
'position' => 20),
261 'f.date_valid' => array(
'label' =>
"DateValidation",
'checked' =>
'0',
'position' => 22),
262 'f.date_lim_reglement' => array(
'label' =>
"DateDue",
'checked' =>
'1',
'position' => 25),
263 'f.date_closing' => array(
'label' =>
"DateClosing",
'checked' =>
'0',
'position' => 30),
264 'p.ref' => array(
'label' =>
"ProjectRef",
'langfile' =>
'projects',
'checked' =>
'1',
'enabled' => (
isModEnabled(
'project') ?
'1' :
'0'),
'position' => 40),
265 'p.title' => array(
'label' =>
"ProjectLabel",
'langfile' =>
'projects',
'checked' =>
'0',
'enabled' => (
isModEnabled(
'project') ?
'1' :
'0'),
'position' => 41),
266 's.nom' => array(
'label' =>
"ThirdParty",
'checked' =>
'1',
'position' => 50),
267 's.name_alias' => array(
'label' =>
"AliasNameShort",
'checked' =>
'-1',
'position' => 51),
268 's.code_client' => array(
'label' =>
"CustomerCodeShort",
'checked' =>
'-1',
'position' => 52),
269 's2.nom' => array(
'label' =>
'ParentCompany',
'position' => 32,
'checked' =>
'0'),
270 's.town' => array(
'label' =>
"Town",
'checked' =>
'-1',
'position' => 55),
271 's.zip' => array(
'label' =>
"Zip",
'checked' =>
'-1',
'position' => 60),
272 'state.nom' => array(
'label' =>
"StateShort",
'checked' =>
'0',
'position' => 65),
273 'country.code_iso' => array(
'label' =>
"Country",
'checked' =>
'0',
'position' => 70),
274 'typent.code' => array(
'label' =>
"ThirdPartyType",
'checked' => $checkedtypetiers,
'position' => 75),
275 'f.fk_mode_reglement' => array(
'label' =>
"PaymentMode",
'checked' =>
'1',
'position' => 80),
276 'f.fk_cond_reglement' => array(
'label' =>
"PaymentConditionsShort",
'checked' =>
'0',
'position' => 85),
277 'f.fk_input_reason' => array(
'label' =>
"Source",
'checked' => 0,
'enabled' => 1,
'position' => 88),
278 'f.module_source' => array(
'label' =>
"POSModule",
'langfile' =>
'cashdesk',
'checked' => ($contextpage ==
'poslist' ?
'1' :
'0'),
'enabled' => $showpos,
'position' => 90),
279 'f.pos_source' => array(
'label' =>
"POSTerminal",
'langfile' =>
'cashdesk',
'checked' => ($contextpage ==
'poslist' ?
'1' :
'0'),
'enabled' => $showpos,
'position' => 91),
280 'f.total_ht' => array(
'label' =>
"AmountHT",
'checked' =>
'1',
'position' => 95),
281 'f.total_tva' => array(
'label' =>
"AmountVAT",
'checked' =>
'0',
'position' => 100),
282 'f.total_localtax1' => array(
'label' => $langs->transcountry(
"AmountLT1",
$mysoc->country_code),
'checked' =>
'0',
'enabled' => (
$mysoc->localtax1_assuj ==
"1"),
'position' => 110),
283 'f.total_localtax2' => array(
'label' => $langs->transcountry(
"AmountLT2",
$mysoc->country_code),
'checked' =>
'0',
'enabled' => (
$mysoc->localtax2_assuj ==
"1"),
'position' => 120),
284 'f.total_ttc' => array(
'label' =>
"AmountTTC",
'checked' =>
'0',
'position' => 130),
285 'dynamount_payed' => array(
'label' =>
"AlreadyPaid",
'checked' =>
'0',
'position' => 140),
286 'rtp' => array(
'label' =>
"RemainderToPay",
'checked' =>
'0',
'position' => 150),
287 'f.multicurrency_code' => array(
'label' =>
'Currency',
'checked' =>
'0',
'enabled' => (!
isModEnabled(
'multicurrency') ?
'0' :
'1'),
'position' => 280),
288 'f.multicurrency_tx' => array(
'label' =>
'CurrencyRate',
'checked' =>
'0',
'enabled' => (!
isModEnabled(
'multicurrency') ?
'0' :
'1'),
'position' => 285),
289 'f.multicurrency_total_ht' => array(
'label' =>
'MulticurrencyAmountHT',
'checked' =>
'0',
'enabled' => (!
isModEnabled(
'multicurrency') ?
'0' :
'1'),
'position' => 290),
290 'f.multicurrency_total_vat' => array(
'label' =>
'MulticurrencyAmountVAT',
'checked' =>
'0',
'enabled' => (!
isModEnabled(
'multicurrency') ?
'0' :
'1'),
'position' => 291),
291 'f.multicurrency_total_ttc' => array(
'label' =>
'MulticurrencyAmountTTC',
'checked' =>
'0',
'enabled' => (!
isModEnabled(
'multicurrency') ?
'0' :
'1'),
'position' => 292),
292 'multicurrency_dynamount_payed' => array(
'label' =>
'MulticurrencyAlreadyPaid',
'checked' =>
'0',
'enabled' => (!
isModEnabled(
'multicurrency') ?
'0' :
'1'),
'position' => 295),
293 'multicurrency_rtp' => array(
'label' =>
'MulticurrencyRemainderToPay',
'checked' =>
'0',
'enabled' => (!
isModEnabled(
'multicurrency') ?
'0' :
'1'),
'position' => 296),
294 'total_pa' => array(
'label' => ((
getDolGlobalString(
'MARGIN_TYPE') ==
'1') ?
'BuyingPrice' :
'CostPrice'),
'checked' =>
'0',
'position' => 300,
'enabled' => (!
isModEnabled(
'margin') || !$user->hasRight(
'margins',
'liretous') ?
'0' :
'1')),
295 'total_margin' => array(
'label' =>
'Margin',
'langfile' =>
'margins',
'checked' =>
'0',
'position' => 301,
'enabled' => (!
isModEnabled(
'margin') || !$user->hasRight(
'margins',
'liretous') ?
'0' :
'1')),
296 'total_margin_rate' => array(
'label' =>
'MarginRate',
'langfile' =>
'margins',
'checked' =>
'0',
'position' => 302,
'enabled' => (!
isModEnabled(
'margin') || !$user->hasRight(
'margins',
'liretous') || !
getDolGlobalString(
'DISPLAY_MARGIN_RATES') ?
'0' :
'1')),
297 'total_mark_rate' => array(
'label' =>
'MarkRate',
'langfile' =>
'margins',
'checked' =>
'0',
'position' => 303,
'enabled' => (!
isModEnabled(
'margin') || !$user->hasRight(
'margins',
'liretous') || !
getDolGlobalString(
'DISPLAY_MARK_RATES') ?
'0' :
'1')),
298 'f.datec' => array(
'label' =>
"DateCreation",
'checked' =>
'0',
'position' => 500),
299 'f.tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModificationShort',
'enabled' =>
'1',
'visible' => -1,
'notnull' => 1,
'position' => 502),
300 'u.login' => array(
'label' =>
"UserAuthor",
'checked' =>
'0',
'visible' => -1,
'position' => 504),
301 'sale_representative' => array(
'label' =>
"SaleRepresentativesOfThirdParty",
'checked' =>
'0',
'position' => 506),
306 'f.note_public' => array(
'label' =>
'NotePublic',
'checked' =>
'0',
'position' => 520,
'enabled' => (!
getDolGlobalInt(
'MAIN_LIST_HIDE_PUBLIC_NOTES'))),
307 'f.note_private' => array(
'label' =>
'NotePrivate',
'checked' =>
'0',
'position' => 521,
'enabled' => (!
getDolGlobalInt(
'MAIN_LIST_HIDE_PRIVATE_NOTES'))),
308 'f.fk_fac_rec_source' => array(
'label' =>
'GeneratedFromTemplate',
'checked' =>
'0',
'position' => 530,
'enabled' =>
'1'),
309 'f.import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' =>
'1',
'visible' => -2,
'position' => 990),
310 'f.dispute_status' => array(
'label' =>
"DisputeStatus",
'checked' =>
'-1',
'position' => 999),
311 'f.fk_statut' => array(
'label' =>
"Status",
'checked' =>
'1',
'position' => 1000),
315 $arrayfields[
'f.retained_warranty'] = array(
'label' => $langs->trans(
"RetainedWarranty"),
'checked' =>
'0',
'position' => 86);
318$subtypearray =
$object->getArrayOfInvoiceSubtypes(0);
319if (empty($subtypearray)) {
320 unset($arrayfields[
'f.subtype']);
324foreach (
$object->fields as $key => $val) {
327 if (!empty($val[
'visible'])) {
328 $visible = (int)
dol_eval((
string) $val[
'visible'], 1, 1,
'1');
330 if (array_key_exists($key, $arrayfields)) {
332 } elseif (array_key_exists(
'f.'.$key, $arrayfields)) {
334 } elseif (array_key_exists(
's.'.$key, $arrayfields)) {
338 $arrayfields[$newkey] = array(
339 'label' => $val[
'label'],
340 'checked' => (($visible < 0) ?
'0' :
'1'),
341 'enabled' => (string) (int) (abs($visible) != 3 && (bool)
dol_eval((string) $val[
'enabled'], 1)),
342 'position' => $val[
'position'],
343 'help' => empty($val[
'help']) ?
'' : $val[
'help'],
349include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
351$parameters = array(
'arrayfields' => &$arrayfields);
352$reshook = $hookmanager->executeHooks(
'completeArrayFields', $parameters, $object, $action);
355if ($contextpage ==
'poslist') {
356 $arrayfields[
"f.module_source"][
'checked'] = 1;
357 $arrayfields[
"f.pos_source"][
'checked'] = 1;
358 $arrayfields[
"f.date_lim_reglement"][
'checked'] = 0;
359 $arrayfields[
"f.total_ttc"][
'checked'] = 1;
360 $arrayfields[
"f.tms"][
'checked'] = 1;
361 $arrayfields[
"p.ref"][
'checked'] = 0;
369if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
370 $search_sale = $user->id;
374$fieldid = (!empty($ref) ?
'ref' :
'rowid');
375if (!empty($user->socid)) {
376 $socid = $user->socid;
378if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
379 $search_sale = $user->id;
389if (
GETPOST(
'cancel',
'alpha')) {
393if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
397$parameters = array(
'socid' => $socid,
'arrayfields' => &$arrayfields);
398$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
403include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
406if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha')) {
409 $search_product_category =
'';
410 $searchCategoryInvoiceList = array();
412 $search_refcustomer =
'';
414 $search_subtype =
'';
415 $search_project_ref =
'';
416 $search_project =
'';
417 $search_company =
'';
418 $search_company_alias =
'';
419 $search_parent_name =
'';
420 $search_montant_ht =
'';
421 $search_montant_vat =
'';
422 $search_montant_localtax1 =
'';
423 $search_montant_localtax2 =
'';
424 $search_montant_ttc =
'';
426 $search_multicurrency_code =
'';
427 $search_multicurrency_tx =
'';
428 $search_multicurrency_montant_ht =
'';
429 $search_multicurrency_montant_vat =
'';
430 $search_multicurrency_montant_ttc =
'';
431 $search_dispute_status =
'';
433 $search_paymentmode =
'';
434 $search_paymentterms =
'';
435 $search_fk_input_reason =
'';
436 $search_module_source =
'';
437 $search_pos_source =
'';
441 $search_country =
'';
442 $search_type_thirdparty =
'';
443 $search_customer_code =
'';
444 $search_date_startday =
'';
445 $search_date_startmonth =
'';
446 $search_date_startyear =
'';
447 $search_date_endday =
'';
448 $search_date_endmonth =
'';
449 $search_date_endyear =
'';
450 $search_date_start =
'';
451 $search_date_end =
'';
452 $search_date_valid_startday =
'';
453 $search_date_valid_startmonth =
'';
454 $search_date_valid_startyear =
'';
455 $search_date_valid_endday =
'';
456 $search_date_valid_endmonth =
'';
457 $search_date_valid_endyear =
'';
458 $search_date_valid_start =
'';
459 $search_date_valid_end =
'';
460 $search_datelimit_startday =
'';
461 $search_datelimit_startmonth =
'';
462 $search_datelimit_startyear =
'';
463 $search_datelimit_endday =
'';
464 $search_datelimit_endmonth =
'';
465 $search_datelimit_endyear =
'';
466 $search_datelimit_start =
'';
467 $search_datelimit_end =
'';
469 $search_datec_start =
'';
470 $search_datec_end =
'';
472 $search_datem_start =
'';
473 $search_datem_end =
'';
475 $search_fac_rec_source_title =
'';
477 $search_import_key =
'';
478 $search_categ_cus = 0;
482 $search_array_options = array();
485if (empty($reshook)) {
486 $objectclass =
'Facture';
487 $objectlabel =
'Invoices';
488 $permissiontoread = $user->hasRight(
"facture",
"lire");
489 $permissiontoadd = $user->hasRight(
"facture",
"creer");
490 $permissiontodelete = $user->hasRight(
"facture",
"supprimer");
491 $uploaddir = $conf->invoice->dir_output;
492 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
495if ($action ==
'makepayment_confirm' && $user->hasRight(
'facture',
'paiement')) {
496 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
497 $arrayofselected = is_array($toselect) ? $toselect : array();
498 if (!empty($arrayofselected)) {
502 if (empty($paiementdate)) {
503 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
505 $action =
'makepayment';
509 foreach ($arrayofselected as $toselectid) {
512 $result = $facture->fetch($toselectid);
522 $sommePaiement = $facture->getSommePaiement(-1);
523 $paiementAmount = $sommePaiement[
'alreadypaid'];
525 $totalcreditnotes = $facture->getSumCreditNotesUsed();
526 $totaldeposits = $facture->getSumDepositsUsed();
528 $totalallpayments = $paiementAmount + $totalcreditnotes + $totaldeposits;
529 $remaintopay = (float)
price2num($facture->total_ttc - $totalallpayments);
532 $parameters = array(
'remaintopay' => $remaintopay);
533 $reshook = $hookmanager->executeHooks(
'finalizeAmountOfInvoice', $parameters, $facture, $action);
535 if (!empty($remain = $hookmanager->resArray[
'remaintopay'])) {
536 $remaintopay = $remain;
538 } elseif ($reshook < 0) {
540 setEventMessages($facture->ref.
' '.$langs->trans(
"ProcessingError"), $hookmanager->errors,
'errors');
544 $multicurrency_remaintopay = (float)
price2num($facture->multicurrency_total_ttc - $sommePaiement[
'alreadypaid_multicurrency']);
546 if ($remaintopay != 0) {
547 $resultBank = $facture->setBankAccount($bankid);
548 if ($resultBank < 0) {
553 $paiement->datepaye = $paiementdate;
554 $paiement->amounts[$facture->id] = $remaintopay;
555 $paiement->multicurrency_amounts[$facture->id] = $multicurrency_remaintopay;
556 $paiement->paiementid = $paiementid;
557 $paiement_id = $paiement->create($user, 1, $facture->thirdparty);
558 if ($paiement_id < 0) {
559 $langs->load(
"errors");
560 setEventMessages($facture->ref.
' '.$langs->trans($paiement->error), $paiement->errors,
'errors');
563 $result = $paiement->addPaymentToBank($user,
'payment',
'', $bankid,
'',
'');
565 $langs->load(
"errors");
566 setEventMessages($facture->ref.
' '.$langs->trans($paiement->error), $paiement->errors,
'errors');
572 setEventMessage($langs->trans(
'NoPaymentAvailable', $facture->ref),
'warnings');
576 setEventMessage($langs->trans(
'BulkPaymentNotPossibleForInvoice', $facture->ref),
'warnings');
581 if (empty($errorpayment)) {
582 setEventMessage($langs->trans(
'PaymentRegisteredAndInvoiceSetToPaid', $facture->ref));
590} elseif ($massaction ==
'withdrawrequest') {
591 $langs->load(
"withdrawals");
593 if (!$user->hasRight(
'prelevement',
'bons',
'creer')) {
600 $arrayofselected = is_array($toselect) ? $toselect : array();
601 $listofbills = array();
602 foreach ($arrayofselected as $toselectid) {
604 $result = $objecttmp->fetch($toselectid);
606 $totalpaid = $objecttmp->getSommePaiement();
607 $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
608 $totaldeposits = $objecttmp->getSumDepositsUsed();
609 $objecttmp->resteapayer =
price2num($objecttmp->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
612 $parameters = array(
'remaintopay' => $objecttmp->resteapayer);
613 $reshook = $hookmanager->executeHooks(
'finalizeAmountOfInvoice', $parameters, $objecttmp, $action);
615 if (!empty($remaintopay = $hookmanager->resArray[
'remaintopay'])) {
616 $objecttmp->resteapayer = $remaintopay;
618 } elseif ($reshook < 0) {
620 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"ProcessingError"), $hookmanager->errors,
'errors');
625 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"Draft"), $objecttmp->errors,
'errors');
626 } elseif ($objecttmp->paye || $objecttmp->resteapayer == 0) {
628 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AlreadyPaid"), $objecttmp->errors,
'errors');
629 } elseif ($objecttmp->resteapayer < 0) {
631 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AmountMustBePositive"), $objecttmp->errors,
'errors');
634 $rsql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
635 $rsql .=
" , pfd.date_traite as date_traite";
636 $rsql .=
" , pfd.amount";
637 $rsql .=
" , u.rowid as user_id, u.lastname, u.firstname, u.login";
638 $rsql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
639 $rsql .=
" , ".MAIN_DB_PREFIX.
"user as u";
640 $rsql .=
" WHERE fk_facture = ".((int) $objecttmp->id);
641 $rsql .=
" AND pfd.fk_user_demande = u.rowid";
642 $rsql .=
" AND pfd.traite = 0";
643 $rsql .=
" ORDER BY pfd.date_demande DESC";
645 $result_sql = $db->query($rsql);
647 $numprlv = $db->num_rows($result_sql);
654 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"RequestAlreadyDone"), $objecttmp->errors,
'warnings');
655 } elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code !=
'PRE') {
656 $langs->load(
"errors");
658 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"ErrorThisPaymentModeIsNotDirectDebit"), $objecttmp->errors,
'errors');
660 $listofbills[] = $objecttmp;
666 if (!empty($listofbills)) {
667 $nbwithdrawrequestok = 0;
668 foreach ($listofbills as $aBill) {
675 $sql =
"SELECT SUM(pfd.amount) as amount";
676 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
680 $sql .=
" WHERE pfd.fk_facture = ".((int) $aBill->id);
682 $sql .=
" AND pfd.traite = 0";
684 $resql = $db->query($sql);
686 $obj = $db->fetch_object($resql);
688 $pending += (float) $obj->amount;
694 $sqlPending =
"SELECT SUM(pl.amount) as amount";
695 $sqlPending .=
" FROM ".$db->prefix().
"prelevement_lignes as pl";
696 $sqlPending .=
" INNER JOIN ".$db->prefix().
"prelevement as p ON p.fk_prelevement_lignes = pl.rowid";
700 $sqlPending .=
" WHERE p.fk_facture = ".((int) $aBill->id);
702 $sqlPending .=
" AND (pl.statut IS NULL OR pl.statut = 0)";
703 $resPending = $db->query($sqlPending);
705 if ($objPending = $db->fetch_object($resPending)) {
706 $pending += (float) $objPending->amount;
709 $db->free($resPending);
711 $requestAmount = $aBill->resteapayer - $pending;
714 $result = $aBill->demande_prelevement($user, $requestAmount,
'direct-debit',
'facture');
715 if ($requestAmount > 0) {
718 $nbwithdrawrequestok++;
724 $aBill->error =
'WithdrawRequestErrorNilAmount';
725 $aBill->errors[] = $aBill->error;
729 if ($nbwithdrawrequestok > 0) {
730 setEventMessages($langs->trans(
"WithdrawRequestsDone", $nbwithdrawrequestok),
null,
'mesgs');
742$form =
new Form($db);
746$facturestatic =
new Facture($db);
748$companystatic =
new Societe($db);
749$companyparent =
new Societe($db);
751$company_url_list = array();
756 if (empty($search_company)) {
757 $search_company = $soc->name;
763$title = $langs->trans(
'BillsCustomers').
' '.(($socid > 0 && $soc !==
null) ?
' - '.$soc->name :
'');
764$help_url =
'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes';
766$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
767$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
772$sql .=
' f.rowid as id, f.ref, f.ref_client, f.fk_soc, f.type, f.subtype, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total_ht, f.total_tva, f.total_ttc,';
773$sql .=
' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,';
774$sql .=
' f.fk_user_author,';
775$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,';
776$sql .=
' f.datef, f.date_valid, f.date_lim_reglement as datelimite,';
777$sql .=
" f.fk_input_reason,";
778$sql .=
" f.module_source, f.pos_source,";
779$sql .=
' f.paye as paye, f.fk_statut as status, f.import_key, f.close_code,';
780$sql .=
' f.datec as date_creation, f.tms as date_modification, f.date_closing as date_closing,';
781$sql .=
' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,';
782$sql .=
' f.payment_reference, f.dispute_status,';
783$sql .=
' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, 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,';
784$sql .=
" s.parent as fk_parent,";
785$sql .=
" s2.nom as name2,";
786$sql .=
' typent.code as typent_code,';
787$sql .=
' state.code_departement as state_code, state.nom as state_name,';
788$sql .=
' country.code as country_code,';
789$sql .=
' f.fk_fac_rec_source,';
790$sql .=
' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
791$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';
801if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
802 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
803 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
807$parameters = array();
808$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
809$sql .= $hookmanager->resPrint;
810$sql = preg_replace(
'/,\s*$/',
'', $sql);
814$sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
815$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s2 ON s2.rowid = s.parent";
816$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
817$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
818$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
819$sql .=
', '.MAIN_DB_PREFIX.
'facture as f';
821if ($sortfield ==
"f.datef") {
822 $hasAnotherfilter =
false;
823 foreach ($search_array_options as $v) {
824 if ($v !==
'' && (
string) $v !==
'-1') {
825 $hasAnotherfilter =
true;
829 if (!$hasAnotherfilter) {
830 $sql .= $db->hintindex(
'idx_facture_datef');
833if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
834 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (f.rowid = ef.fk_object)";
836if (!empty($search_fac_rec_source_title)) {
837 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_rec as facrec ON f.fk_fac_rec_source = facrec.rowid';
839$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = f.fk_projet";
840$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user AS u ON f.fk_user_author = u.rowid';
842$parameters = array();
843$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
844$sql .= $hookmanager->resPrint;
846$sql .=
' WHERE f.fk_soc = s.rowid';
847$sql .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
849 $sql .=
' AND s.rowid = '.((int) $socid);
853 $sql .=
' AND f.fk_user_author IS NULL';
855 $sql .=
' AND f.fk_user_author = '.((int) $userid);
861if ($search_refcustomer) {
864if ($search_type !=
'' && $search_type !=
'-1') {
865 $sql .=
" AND f.type IN (".$db->sanitize($db->escape($search_type)).
")";
867if ($search_subtype !=
'' && $search_subtype !=
'-1') {
868 $sql .=
" AND f.subtype IN (".$db->sanitize($db->escape($search_subtype)).
")";
870if ($search_project_ref) {
873if ($search_project) {
876if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
877 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
879 if ($search_company) {
882 if ($search_company_alias) {
886if ($search_parent_name) {
889if ($search_customer_code) {
901if (strlen(trim($search_country))) {
903 $country_code_in_EEC = $country_code_in_EEC_without_me =
'';
904 foreach ($arrayofcode as $key => $value) {
905 $country_code_in_EEC .= ($country_code_in_EEC ?
"," :
"").
"'".$value.
"'";
906 if ($value !=
$mysoc->country_code) {
907 $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ?
"," :
"").
"'".$value.
"'";
910 if ($search_country ==
'special_allnotme') {
911 $sql .=
" AND country.code <> '".$db->escape(
$mysoc->country_code).
"'";
912 } elseif ($search_country ==
'special_eec') {
913 $sql .=
" AND country.code IN (".$db->sanitize($country_code_in_EEC, 1).
")";
914 } elseif ($search_country ==
'special_eecnotme') {
915 $sql .=
" AND country.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).
")";
916 } elseif ($search_country ==
'special_noteec') {
917 $sql .=
" AND country.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).
")";
922if ($search_type_thirdparty !=
'' && $search_type_thirdparty !=
'-1') {
923 $sql .=
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
925if ($search_montant_ht !=
'') {
928if ($search_montant_vat !=
'') {
931if ($search_montant_localtax1 !=
'') {
932 $sql .=
natural_search(
'f.localtax1', $search_montant_localtax1, 1);
934if ($search_montant_localtax2 !=
'') {
935 $sql .=
natural_search(
'f.localtax2', $search_montant_localtax2, 1);
937if ($search_montant_ttc !=
'') {
940if ($search_multicurrency_code !=
'') {
941 $sql .=
" AND f.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
943if ($search_multicurrency_tx !=
'') {
944 $sql .=
natural_search(
'f.multicurrency_tx', $search_multicurrency_tx, 1);
946if ($search_multicurrency_montant_ht !=
'') {
947 $sql .=
natural_search(
'f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
949if ($search_multicurrency_montant_vat !=
'') {
950 $sql .=
natural_search(
'f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
952if ($search_multicurrency_montant_ttc !=
'') {
953 $sql .=
natural_search(
'f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
956 $sql .=
natural_search(array(
'u.login',
'u.firstname',
'u.lastname'), $search_login);
958if ($search_dispute_status !=
'-1' && $search_dispute_status !=
'') {
959 if ($search_dispute_status ==
'0') {
960 $sql .=
" AND (f.dispute_status IS NULL OR f.dispute_status = 0)";
962 $sql .=
" AND f.dispute_status IN (".$db->sanitize($search_dispute_status).
")";
965if ($search_status !=
'-1' && $search_status !=
'') {
966 if (is_numeric($search_status) && $search_status >= 0) {
967 if ($search_status ==
'0') {
968 $sql .=
" AND f.fk_statut = 0";
970 if ($search_status ==
'1') {
971 $sql .=
" AND f.fk_statut = 1";
973 if ($search_status ==
'2') {
974 $sql .=
" AND f.fk_statut = 2";
976 if ($search_status ==
'3') {
977 $sql .=
" AND f.fk_statut = 3";
980 $sql .=
" AND f.fk_statut IN (".$db->sanitize($search_status).
")";
984if ($search_paymentmode > 0) {
985 $sql .=
" AND f.fk_mode_reglement = ".((int) $search_paymentmode);
987if ($search_paymentterms > 0) {
988 $sql .=
" AND f.fk_cond_reglement = ".((int) $search_paymentterms);
990if ($search_fk_input_reason > 0) {
991 $sql .=
" AND f.fk_input_reason = ".((int) $search_fk_input_reason);
993if ($search_module_source) {
996if ($search_pos_source) {
999if ($search_date_start) {
1000 $sql .=
" AND f.datef >= '".$db->idate($search_date_start).
"'";
1002if ($search_date_end) {
1003 $sql .=
" AND f.datef <= '".$db->idate($search_date_end).
"'";
1005if ($search_date_valid_start) {
1006 $sql .=
" AND f.date_valid >= '".$db->idate($search_date_valid_start).
"'";
1008if ($search_date_valid_end) {
1009 $sql .=
" AND f.date_valid <= '".$db->idate($search_date_valid_end).
"'";
1011if ($search_datelimit_start) {
1012 $sql .=
" AND f.date_lim_reglement >= '".$db->idate($search_datelimit_start).
"'";
1014if ($search_datelimit_end) {
1015 $sql .=
" AND f.date_lim_reglement <= '".$db->idate($search_datelimit_end).
"'";
1017if ($search_note_public) {
1018 $sql .=
" AND p.note_public LIKE '%".$db->escape($db->escapeforlike($search_note_public)).
"%'";
1020if ($search_note_private) {
1021 $sql .=
" AND p.note_private LIKE '%".$db->escape($db->escapeforlike($search_note_private)).
"%'";
1023if ($search_datec_start) {
1024 $sql .=
" AND f.datec >= '".$db->idate($search_datec_start).
"'";
1026if ($search_datec_end) {
1027 $sql .=
" AND f.datec <= '".$db->idate($search_datec_end).
"'";
1029if ($search_datem_start) {
1030 $sql .=
" AND f.tms >= '".$db->idate($search_datem_start).
"'";
1032if ($search_datem_end) {
1033 $sql .=
" AND f.tms <= '".$db->idate($search_datem_end).
"'";
1035if ($search_option ==
'late') {
1036 $sql .=
" AND f.date_lim_reglement < '".$db->idate(
dol_now() - $conf->invoice->client->warning_delay).
"'";
1041if (!empty($search_fac_rec_source_title)) {
1042 $sql .=
natural_search(
'facrec.titre', $search_fac_rec_source_title);
1044if ($search_fk_fac_rec_source) {
1045 $sql .=
' AND f.fk_fac_rec_source = ' . (int) $search_fk_fac_rec_source;
1047if ($search_import_key) {
1051if ($search_user > 0) {
1052 $sql .=
" AND EXISTS (";
1053 $sql .=
" SELECT ec.fk_c_type_contact, ec.element_id, ec.fk_socpeople";
1054 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_contact as ec";
1055 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"c_type_contact as tc";
1056 $sql .=
" ON ec.fk_c_type_contact = tc.rowid AND tc.element = 'facture' AND tc.source = 'internal'";
1057 $sql .=
" WHERE ec.element_id = f.rowid AND ec.fk_socpeople = ".((int) $search_user).
")";
1060if ($search_sale && $search_sale !=
'-1') {
1061 if ($search_sale == -2) {
1062 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc)";
1063 } elseif ($search_sale > 0) {
1064 $sql .=
" AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc AND sc.fk_user = ".((int) $search_sale).
")";
1069if (!empty($searchCategoryInvoiceList)) {
1070 $searchCategoryInvoiceSqlList = array();
1071 $listofcategoryid =
'';
1072 foreach ($searchCategoryInvoiceList as $searchCategoryInvoice) {
1073 if (intval($searchCategoryInvoice) == -2) {
1074 $searchCategoryInvoiceSqlList[] =
"NOT EXISTS (SELECT ck.fk_invoice FROM ".MAIN_DB_PREFIX.
"categorie_invoice as ck WHERE f.rowid = ck.fk_invoice)";
1075 } elseif (intval($searchCategoryInvoice) > 0) {
1076 if ($searchCategoryInvoiceOperator == 0) {
1077 $searchCategoryInvoiceSqlList[] =
" EXISTS (SELECT ck.fk_invoice FROM ".MAIN_DB_PREFIX.
"categorie_invoice as ck WHERE f.rowid = ck.fk_invoice AND ck.fk_categorie = ".((int) $searchCategoryInvoice).
")";
1079 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryInvoice);
1083 if ($listofcategoryid) {
1084 $searchCategoryInvoiceSqlList[] =
" EXISTS (SELECT ck.fk_invoice FROM ".MAIN_DB_PREFIX.
"categorie_invoice as ck WHERE f.rowid = ck.fk_invoice AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
1086 if ($searchCategoryInvoiceOperator == 1) {
1087 if (!empty($searchCategoryInvoiceSqlList)) {
1088 $sql .=
" AND (".implode(
' OR ', $searchCategoryInvoiceSqlList).
")";
1091 if (!empty($searchCategoryInvoiceSqlList)) {
1092 $sql .=
" AND (".implode(
' AND ', $searchCategoryInvoiceSqlList).
")";
1098$searchCategoryProductList = $search_product_category ? array($search_product_category) : array();
1099$searchCategoryProductOperator = 0;
1100if (!empty($searchCategoryProductList)) {
1101 $searchCategoryProductSqlList = array();
1102 $listofcategoryid =
'';
1103 foreach ($searchCategoryProductList as $searchCategoryProduct) {
1104 if (intval($searchCategoryProduct) == -2) {
1105 $searchCategoryProductSqlList[] =
"NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"facturedet as fd WHERE fd.fk_facture = f.rowid AND fd.fk_product = ck.fk_product)";
1106 } elseif (intval($searchCategoryProduct) > 0) {
1107 if ($searchCategoryProductOperator == 0) {
1108 $searchCategoryProductSqlList[] =
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"facturedet as fd WHERE fd.fk_facture = f.rowid AND fd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).
")";
1110 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
1114 if ($listofcategoryid) {
1115 $searchCategoryProductSqlList[] =
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"facturedet as fd WHERE fd.fk_facture = f.rowid AND fd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
1117 if ($searchCategoryProductOperator == 1) {
1118 if (!empty($searchCategoryProductSqlList)) {
1119 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
1122 if (!empty($searchCategoryProductSqlList)) {
1123 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
1127$searchCategoryCustomerList = $search_categ_cus ? array($search_categ_cus) : array();
1128$searchCategoryCustomerOperator = 0;
1130if (!empty($searchCategoryCustomerList)) {
1131 $searchCategoryCustomerSqlList = array();
1132 $listofcategoryid =
'';
1133 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
1134 if (intval($searchCategoryCustomer) == -2) {
1135 $searchCategoryCustomerSqlList[] =
"NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe as ck WHERE s.rowid = ck.fk_soc)";
1136 } elseif (intval($searchCategoryCustomer) > 0) {
1137 if ($searchCategoryCustomerOperator == 0) {
1138 $searchCategoryCustomerSqlList[] =
" EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie = ".((int) $searchCategoryCustomer).
")";
1140 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryCustomer);
1144 if ($listofcategoryid) {
1145 $searchCategoryCustomerSqlList[] =
" EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
1147 if ($searchCategoryCustomerOperator == 1) {
1148 if (!empty($searchCategoryCustomerSqlList)) {
1149 $sql .=
" AND (".implode(
' OR ', $searchCategoryCustomerSqlList).
")";
1152 if (!empty($searchCategoryCustomerSqlList)) {
1153 $sql .=
" AND (".implode(
' AND ', $searchCategoryCustomerSqlList).
")";
1158include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1160$parameters = array();
1161$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1162$sql .= $hookmanager->resPrint;
1167 $fieldstosearchallwithoutpd = array();
1168 $fieldstosearchallwithpd = array();
1169 foreach ($fieldstosearchall as $key => $val) {
1170 if (!preg_match(
'/^pd\./', $key)) {
1171 $fieldstosearchallwithoutpd[$key] = $val;
1173 $fieldstosearchallwithpd[$key] = $val;
1177 if (count($fieldstosearchallwithpd) > 0) {
1178 $sqltoadd .=
" OR EXISTS (SELECT pd.rowid FROM ".MAIN_DB_PREFIX.
"facturedet as pd WHERE pd.fk_facture = f.rowid";
1179 $sqltoadd .=
natural_search(array_keys($fieldstosearchallwithpd),
'__KEYTOSEARCH__');
1183 $sql .=
natural_search(array_keys($fieldstosearchallwithoutpd), $search_all, 0, 0, $sqltoadd);
1186$parameters = array();
1187$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object, $action);
1188if (empty($reshook)) {
1189 $sql .= empty($hookmanager->resPrint) ?
"" :
" HAVING 1=1 ".$hookmanager->resPrint;
1191 $sql = $hookmanager->resPrint;
1195$nbtotalofrecords =
'';
1198 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1199 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1201 $resql = $db->query($sqlforcount);
1203 $objforcount = $db->fetch_object($resql);
1204 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1209 if (($page * $limit) > (
int) $nbtotalofrecords) {
1217$sql .= $db->order($sortfield, $sortorder);
1219 $sql .= $db->plimit($limit + 1, $offset);
1222$resql = $db->query($sql);
1228$num = $db->num_rows($resql);
1230$arrayofselected = is_array($toselect) ? $toselect : array();
1232if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
1233 $obj = $db->fetch_object($resql);
1236 header(
"Location: ".DOL_URL_ROOT.
'/compta/facture/card.php?id='.
$id);
1243llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist'.($contextpage ==
'poslist' ?
' '.$contextpage :
''));
1245if ($search_fk_fac_rec_source) {
1247 $object->fetch((
int) $search_fk_fac_rec_source);
1256 $param .=
'&mode='.urlencode($mode);
1258if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1259 $param .=
'&contextpage='.urlencode($contextpage);
1261if ($limit > 0 && $limit != $conf->liste_limit) {
1262 $param .=
'&limit='.((int) $limit);
1264if ($optioncss !=
'') {
1265 $param .=
'&optioncss='.urlencode($optioncss);
1268 $param .=
'&show_files='.urlencode((
string) ($show_files));
1271 $param .=
'&search_all='.urlencode($search_all);
1274 $param .=
'&socid='.((int) $socid);
1276if ($search_date_startday) {
1277 $param .=
'&search_date_startday='.urlencode((
string) ($search_date_startday));
1279if ($search_date_startmonth) {
1280 $param .=
'&search_date_startmonth='.urlencode((
string) ($search_date_startmonth));
1282if ($search_date_startyear) {
1283 $param .=
'&search_date_startyear='.urlencode((
string) ($search_date_startyear));
1285if ($search_date_endday) {
1286 $param .=
'&search_date_endday='.urlencode((
string) ($search_date_endday));
1288if ($search_date_endmonth) {
1289 $param .=
'&search_date_endmonth='.urlencode((
string) ($search_date_endmonth));
1291if ($search_date_endyear) {
1292 $param .=
'&search_date_endyear='.urlencode((
string) ($search_date_endyear));
1294if ($search_date_valid_startday) {
1295 $param .=
'&search_date_valid_startday='.urlencode((
string) ($search_date_valid_startday));
1297if ($search_date_valid_startmonth) {
1298 $param .=
'&search_date_valid_startmonth='.urlencode((
string) ($search_date_valid_startmonth));
1300if ($search_date_valid_startyear) {
1301 $param .=
'&search_date_valid_startyear='.urlencode((
string) ($search_date_valid_startyear));
1303if ($search_date_valid_endday) {
1304 $param .=
'&search_date_valid_endday='.urlencode((
string) ($search_date_valid_endday));
1306if ($search_date_valid_endmonth) {
1307 $param .=
'&search_date_valid_endmonth='.urlencode((
string) ($search_date_valid_endmonth));
1309if ($search_date_valid_endyear) {
1310 $param .=
'&search_date_valid_endyear='.urlencode((
string) ($search_date_valid_endyear));
1312if ($search_datelimit_startday) {
1313 $param .=
'&search_datelimit_startday='.urlencode((
string) ($search_datelimit_startday));
1315if ($search_datelimit_startmonth) {
1316 $param .=
'&search_datelimit_startmonth='.urlencode((
string) ($search_datelimit_startmonth));
1318if ($search_datelimit_startyear) {
1319 $param .=
'&search_datelimit_startyear='.urlencode((
string) ($search_datelimit_startyear));
1321if ($search_datelimit_endday) {
1322 $param .=
'&search_datelimit_endday='.urlencode((
string) ($search_datelimit_endday));
1324if ($search_datelimit_endmonth) {
1325 $param .=
'&search_datelimit_endmonth='.urlencode((
string) ($search_datelimit_endmonth));
1327if ($search_datelimit_endyear) {
1328 $param .=
'&search_datelimit_endyear='.urlencode((
string) ($search_datelimit_endyear));
1331 $param .=
'&search_ref='.urlencode($search_ref);
1333if ($search_refcustomer) {
1334 $param .=
'&search_refcustomer='.urlencode($search_refcustomer);
1336if ($search_project_ref) {
1337 $param .=
'&search_project_ref='.urlencode($search_project_ref);
1339if ($search_project) {
1340 $param .=
'&search_project='.urlencode($search_project);
1342if ($search_type !=
'') {
1343 $param .=
'&search_type='.urlencode($search_type);
1345if ($search_subtype !=
'') {
1346 $param .=
'&search_subtype='.urlencode($search_subtype);
1348if ($search_company) {
1349 $param .=
'&search_company='.urlencode($search_company);
1351if ($search_company_alias) {
1352 $param .=
'&search_company_alias='.urlencode($search_company_alias);
1354if ($search_parent_name !=
'') {
1355 $param .=
'&search_parent_name='.urlencode($search_parent_name);
1358 $param .=
'&search_town='.urlencode($search_town);
1361 $param .=
'&search_zip='.urlencode($search_zip);
1363if ($search_country) {
1364 $param .=
"&search_country=".urlencode($search_country);
1366if ($search_type_thirdparty !=
'') {
1367 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
1369if ($search_customer_code) {
1370 $param .=
'&search_customer_code='.urlencode($search_customer_code);
1372if ($search_sale > 0) {
1373 $param .=
'&search_sale='.urlencode((
string) $search_sale);
1375if ($search_user > 0) {
1376 $param .=
'&search_user='.urlencode((
string) $search_user);
1379 $param .=
'&search_login='.urlencode($search_login);
1381if ($searchCategoryInvoiceOperator == 1) {
1382 $param .=
"&search_category_invoice_operator=".urlencode((
string) ($searchCategoryInvoiceOperator));
1384foreach ($searchCategoryInvoiceList as $searchCategoryInvoice) {
1385 $param .=
"&search_category_invoice_list[]=".urlencode($searchCategoryInvoice);
1387if ($search_product_category > 0) {
1388 $param .=
'&search_product_category='.urlencode((
string) $search_product_category);
1390if ($search_montant_ht !=
'') {
1391 $param .=
'&search_montant_ht='.urlencode($search_montant_ht);
1393if ($search_montant_vat !=
'') {
1394 $param .=
'&search_montant_vat='.urlencode($search_montant_vat);
1396if ($search_montant_localtax1 !=
'') {
1397 $param .=
'&search_montant_localtax1='.urlencode($search_montant_localtax1);
1399if ($search_montant_localtax2 !=
'') {
1400 $param .=
'&search_montant_localtax2='.urlencode($search_montant_localtax2);
1402if ($search_montant_ttc !=
'') {
1403 $param .=
'&search_montant_ttc='.urlencode($search_montant_ttc);
1405if ($search_multicurrency_code !=
'') {
1406 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1408if ($search_multicurrency_tx !=
'') {
1409 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1411if ($search_multicurrency_montant_ht !=
'') {
1412 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1414if ($search_multicurrency_montant_vat !=
'') {
1415 $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
1417if ($search_multicurrency_montant_ttc !=
'') {
1418 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1420if ($search_dispute_status !=
'') {
1421 $param .=
'&search_dispute_status='.urlencode($search_dispute_status);
1423if ($search_status !=
'') {
1424 $param .=
'&search_status='.urlencode($search_status);
1426if ($search_paymentmode > 0) {
1427 $param .=
'&search_paymentmode='.urlencode((
string) ($search_paymentmode));
1429if ($search_paymentterms > 0) {
1430 $param .=
'&search_paymentterms='.urlencode((
string) ($search_paymentterms));
1432if ($search_fk_input_reason > 0) {
1433 $param .=
'&search_fk_input_reason='.urlencode((
string) $search_fk_input_reason);
1435if ($search_module_source) {
1436 $param .=
'&search_module_source='.urlencode($search_module_source);
1438if ($search_pos_source) {
1439 $param .=
'&search_pos_source='.urlencode($search_pos_source);
1441if ($search_option) {
1442 $param .=
"&search_option=".urlencode($search_option);
1444if ($search_categ_cus > 0) {
1445 $param .=
'&search_categ_cus='.urlencode((
string) ($search_categ_cus));
1447if (!empty($search_fac_rec_source_title)) {
1448 $param .=
'&search_fac_rec_source_title='.urlencode($search_fac_rec_source_title);
1450if ($search_fk_fac_rec_source) {
1451 $param .=
'&search_fk_fac_rec_source=' . (int) $search_fk_fac_rec_source;
1453if ($search_import_key !=
'') {
1454 $param .=
'&search_import_key='.urlencode($search_import_key);
1458include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1460$parameters = array(
'param' => &$param);
1461$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1462$param .= $hookmanager->resPrint;
1464$arrayofmassactions = array(
1465 'validate' =>
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate"),
1466 'generate_doc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1467 'builddoc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1468 'presend' =>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
1471if (
isModEnabled(
'category') && $user->hasRight(
'facture',
'creer')) {
1472 $arrayofmassactions[
'preaffecttag'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"AffectTag");
1474if ($user->hasRight(
'facture',
'paiement')) {
1475 $arrayofmassactions[
'makepayment'] =
img_picto(
'',
'payment',
'class="pictofixedwidth"').$langs->trans(
"MakePaymentAndClassifyPayed");
1477if (
isModEnabled(
'prelevement') && $user->hasRight(
'prelevement',
'bons',
'creer')) {
1478 $langs->load(
"withdrawals");
1479 $arrayofmassactions[
'withdrawrequest'] =
img_picto(
'',
'payment',
'class="pictofixedwidth"').$langs->trans(
"MakeWithdrawRequest");
1481if ($user->hasRight(
'facture',
'supprimer')) {
1483 $arrayofmassactions[
'predeletedraft'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Deletedraft");
1486if (in_array($massaction, array(
'presend',
'predelete',
'makepayment'))) {
1487 $arrayofmassactions = array();
1489$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1493if ($contextpage !=
'poslist') {
1494 $url = DOL_URL_ROOT.
'/compta/facture/card.php?action=create';
1496 $url .=
'&socid='.urlencode((
string)
$object->socid);
1499 $url .=
'&fac_rec='.urlencode((
string)
$object->id);
1501 $newcardbutton =
'';
1502 $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'));
1503 $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'));
1505 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewBill'),
'',
'fa fa-plus-circle', $url,
'', $user->hasRight(
"facture",
"creer"));
1510print
'<form method="POST" id="searchFormList" name="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
1511if ($optioncss !=
'') {
1512 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1514print
'<input type="hidden" name="token" value="'.newToken().
'">';
1515print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1516if (!in_array($massaction, array(
'makepayment'))) {
1517 print
'<input type="hidden" name="action" value="list">';
1519print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1520print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1521print
'<input type="hidden" name="search_status" value="'.$search_status.
'">';
1522print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1523print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1524print
'<input type="hidden" name="mode" value="'.$mode.
'">';
1526print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'bill', 0, $newcardbutton,
'', $limit, 0, 0, 1);
1528$topicmail =
"SendBillRef";
1529$modelmail =
"facture_send";
1531$trackid =
'inv'.$object->id;
1532include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1534if ($massaction ==
'makepayment') {
1536 $formquestion = array(
1540 array(
'type' =>
'date',
'name' =>
'datepaiment',
'label' => $langs->trans(
"Date"),
'datenow' => 1),
1541 array(
'type' =>
'other',
'name' =>
'paiementid',
'label' => $langs->trans(
"PaymentMode"),
'value' => $form->select_types_paiements(
GETPOST(
'search_paymentmode'),
'paiementid',
'', 0, 0, 1, 0, 1,
'', 1)),
1542 array(
'type' =>
'other',
'name' =>
'bankid',
'label' => $langs->trans(
"BankAccount"),
'value' => $form->select_comptes(
'',
'bankid', 0,
'', 0,
'', 0,
'', 1)),
1545 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
'MakePaymentAndClassifyPayed'), $langs->trans(
'EnterPaymentReceivedFromCustomer'),
'makepayment_confirm', $formquestion, 1, 0, 200, 500, 1);
1550 foreach ($fieldstosearchall as $key => $val) {
1551 $fieldstosearchall[$key] = $langs->trans($val);
1553 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>';
1559if (
isModEnabled(
'category') && $user->hasRight(
'categorie',
'read')) {
1561 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_INVOICE, $searchCategoryInvoiceList,
'minwidth300', $searchCategoryInvoiceOperator ? $searchCategoryInvoiceOperator : 0);
1564if ($user->hasRight(
"user",
"user",
"lire")) {
1565 $langs->load(
"commercial");
1566 $moreforfilter .=
'<div class="divsearchfield">';
1567 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1568 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth200');
1569 $moreforfilter .=
'</div>';
1572if ($user->hasRight(
"user",
"user",
"lire")) {
1573 $moreforfilter .=
'<div class="divsearchfield">';
1574 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1575 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
null, 0,
'',
'',
'0', 0, 0,
'', 0,
'',
'maxwidth200');
1576 $moreforfilter .=
'</div>';
1579if (
isModEnabled(
'category') && $user->hasRight(
"categorie",
"lire") && ($user->hasRight(
"produit",
"lire") || $user->hasRight(
"service",
"lire"))) {
1580 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1581 $moreforfilter .=
'<div class="divsearchfield">';
1582 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1583 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 0, 0, 1);
1584 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0,
'', 0, 0, 0,
'',
'maxwidth300 widthcentpercentminusx', 1);
1585 $moreforfilter .=
'</div>';
1587if (
isModEnabled(
'category') && $user->hasRight(
"categorie",
"lire")) {
1588 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1589 $moreforfilter .=
'<div class="divsearchfield">';
1590 $tmptitle = $langs->trans(
'CustomersProspectsCategoriesShort');
1591 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$formother->select_categories(
'customer', $search_categ_cus,
'search_categ_cus', 1, $tmptitle);
1592 $moreforfilter .=
'</div>';
1595$moreforfilter .=
'<div class="divsearchfield">';
1596$moreforfilter .=
'<label for="search_option">'.$langs->trans(
'Alert').
' </label><input type="checkbox" name="search_option" id="search_option" value="late"'.($search_option ==
'late' ?
' checked' :
'').
'>';
1597$moreforfilter .=
'</div>';
1599$parameters = array();
1600$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1601if (empty($reshook)) {
1602 $moreforfilter .= $hookmanager->resPrint;
1604 $moreforfilter = $hookmanager->resPrint;
1607if (!empty($moreforfilter)) {
1608 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1609 print $moreforfilter;
1613$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1614$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1617if ($massactionbutton && $contextpage !=
'poslist') {
1618 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
1621print
'<div class="div-table-responsive">';
1622print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1626print
'<tr class="liste_titre_filter">';
1630 print
'<td class="liste_titre center maxwidthsearch actioncolumn">';
1631 $searchpicto = $form->showFilterButtons(
'left');
1637 print
'<td class="liste_titre">';
1641if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1642 print
'<td class="liste_titre">';
1643 print
'<input class="flat maxwidth75imp" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1647if (!empty($arrayfields[
'f.ref_client'][
'checked'])) {
1648 print
'<td class="liste_titre">';
1649 print
'<input class="flat maxwidth50imp" type="text" name="search_refcustomer" value="'.dol_escape_htmltag($search_refcustomer).
'">';
1653if (!empty($arrayfields[
'f.type'][
'checked'])) {
1654 print
'<td class="liste_titre maxwidthonsmartphone">';
1666 print $form->selectarray(
'search_type', $listtype, $search_type, 1, 0, 0,
'', 0, 0, 0,
'',
'maxwidth75');
1670if (!empty($arrayfields[
'f.subtype'][
'checked'])) {
1671 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1672 print $form->selectarray(
'search_subtype', $subtypearray, $search_subtype, 1, 0, 0,
'', 0, 0, 0,
'',
'maxwidth100');
1676if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1677 print
'<td class="liste_titre center">';
1678 print
'<div class="nowrapfordate">';
1679 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1681 print
'<div class="nowrapfordate">';
1682 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1687if (!empty($arrayfields[
'f.date_valid'][
'checked'])) {
1688 print
'<td class="liste_titre center">';
1689 print
'<div class="nowrapfordate">';
1690 print $form->selectDate($search_date_valid_start ? $search_date_valid_start : -1,
'search_date_valid_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1692 print
'<div class="nowrapfordate">';
1693 print $form->selectDate($search_date_valid_end ? $search_date_valid_end : -1,
'search_date_valid_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1698if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1699 print
'<td class="liste_titre center">';
1700 print
'<div class="nowrapfordate">';
1701 print $form->selectDate($search_datelimit_start ? $search_datelimit_start : -1,
'search_datelimit_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1703 print
'<div class="nowrapfordate">';
1704 print $form->selectDate($search_datelimit_end ? $search_datelimit_end : -1,
'search_datelimit_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1709if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1710 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).
'"></td>';
1713if (!empty($arrayfields[
'p.title'][
'checked'])) {
1714 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_project" value="'.dol_escape_htmltag($search_project).
'"></td>';
1717if (!empty($arrayfields[
's.nom'][
'checked'])) {
1718 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_company" value="'.dol_escape_htmltag((
string) $search_company).
'"'.($socid > 0 ?
" disabled" :
"").
'></td>';
1721if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1722 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).
'"></td>';
1725if (!empty($arrayfields[
's2.nom'][
'checked'])) {
1726 print
'<td class="liste_titre">';
1727 print
'<input class="flat maxwidth100" type="text" name="search_parent_name" value="'.dol_escape_htmltag($search_parent_name).
'">';
1731if (!empty($arrayfields[
's.code_client'][
'checked'])) {
1732 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_customer_code" value="'.dol_escape_htmltag($search_customer_code).
'"></td>';
1735if (!empty($arrayfields[
's.town'][
'checked'])) {
1736 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
1739if (!empty($arrayfields[
's.zip'][
'checked'])) {
1740 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
1743if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1744 print
'<td class="liste_titre">';
1745 print
'<input class="flat maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1749if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1750 print
'<td class="liste_titre center">';
1751 print $form->select_country($search_country,
'search_country',
'', 0,
'minwidth150imp maxwidth150',
'code2', 1, 0, 1, array(), 1);
1755if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1756 print
'<td class="liste_titre maxwidthonsmartphone center">';
1757 print $form->selectarray(
"search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0,
'', 0, 0, 0, (!
getDolGlobalString(
'SOCIETE_SORT_ON_TYPEENT') ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT),
'maxwidth100', 1);
1761if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1762 print
'<td class="liste_titre">';
1763 print $form->select_types_paiements($search_paymentmode,
'search_paymentmode',
'', 0, 1, 1, 0, 1,
'minwidth100 maxwidth100', 1);
1767if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1768 print
'<td class="liste_titre left">';
1769 print $form->getSelectConditionsPaiements((
int) $search_paymentterms,
'search_paymentterms', -1, 1, 1,
'minwidth100 maxwidth100');
1773if (!empty($arrayfields[
'f.fk_input_reason'][
'checked'])) {
1774 print
'<td class="liste_titre">';
1775 $form->selectInputReason($search_fk_input_reason,
'search_fk_input_reason',
'', 1,
'', 1);
1779if (!empty($arrayfields[
'f.module_source'][
'checked'])) {
1780 print
'<td class="liste_titre">';
1781 print
'<input class="flat maxwidth75" type="text" name="search_module_source" value="'.dol_escape_htmltag($search_module_source).
'">';
1785if (!empty($arrayfields[
'f.pos_source'][
'checked'])) {
1786 print
'<td class="liste_titre">';
1787 print
'<input class="flat maxwidth50" type="text" name="search_pos_source" value="'.dol_escape_htmltag($search_pos_source).
'">';
1790if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1792 print
'<td class="liste_titre right">';
1793 print
'<input class="flat" type="text" size="4" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).
'">';
1796if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
1798 print
'<td class="liste_titre right">';
1799 print
'<input class="flat" type="text" size="4" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).
'">';
1802if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1804 print
'<td class="liste_titre right">';
1805 print
'<input class="flat" type="text" size="4" name="search_montant_localtax1" value="'.dol_escape_htmltag($search_montant_localtax1).
'">';
1808if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1810 print
'<td class="liste_titre right">';
1811 print
'<input class="flat" type="text" size="4" name="search_montant_localtax2" value="'.dol_escape_htmltag($search_montant_localtax2).
'">';
1814if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1816 print
'<td class="liste_titre right">';
1817 print
'<input class="flat" type="text" size="4" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).
'">';
1820if (!empty($arrayfields[
'u.login'][
'checked'])) {
1822 print
'<td class="liste_titre" align="center">';
1823 print
'<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).
'">';
1826if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1827 print
'<td class="liste_titre"></td>';
1829if (!empty($arrayfields[
'f.retained_warranty'][
'checked'])) {
1830 print
'<td class="liste_titre" align="right">';
1833if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1834 print
'<td class="liste_titre right">';
1837if (!empty($arrayfields[
'rtp'][
'checked'])) {
1838 print
'<td class="liste_titre">';
1841if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1843 print
'<td class="liste_titre">';
1844 print $form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1847if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1849 print
'<td class="liste_titre">';
1850 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1853if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1855 print
'<td class="liste_titre right">';
1856 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1859if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1861 print
'<td class="liste_titre right">';
1862 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).
'">';
1865if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1867 print
'<td class="liste_titre right">';
1868 print
'<input class="flat width75" type="text" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1871if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1872 print
'<td class="liste_titre">';
1875if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1876 print
'<td class="liste_titre right">';
1879if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1880 print
'<td class="liste_titre right">';
1883if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1884 print
'<td class="liste_titre right">';
1887if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1888 print
'<td class="liste_titre right">';
1891if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1892 print
'<td class="liste_titre right">';
1897include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1900$parameters = array(
'arrayfields' => $arrayfields);
1901$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1902print $hookmanager->resPrint;
1904if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1905 print
'<td class="liste_titre center">';
1906 print
'<div class="nowrapfordate">';
1907 print $form->selectDate($search_datec_start ? $search_datec_start : -1,
'search_datec_start', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'),
'tzuserrel');
1909 print
'<div class="nowrapfordate">';
1910 print $form->selectDate($search_datec_end ? $search_datec_end : -1,
'search_datec_end', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'),
'tzuserrel');
1915if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1916 print
'<td class="liste_titre center">';
1917 print
'<div class="nowrapfordate">';
1918 print $form->selectDate($search_datem_start ? $search_datem_start : -1,
'search_datem_start', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'),
'tzuserrel');
1920 print
'<div class="nowrapfordate">';
1921 print $form->selectDate($search_datem_end ? $search_datem_end : -1,
'search_datem_end', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'),
'tzuserrel');
1926if (!empty($arrayfields[
'f.date_closing'][
'checked'])) {
1927 print
'<td class="liste_titre">';
1930if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
1932 print
'<td class="liste_titre">';
1933 print
'<input class="flat maxwidth75" type="text" name="search_note_public" value="'.dol_escape_htmltag($search_note_public).
'">';
1936if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
1938 print
'<td class="liste_titre">';
1939 print
'<input class="flat maxwidth75" type="text" name="search_note_private" value="'.dol_escape_htmltag($search_note_private).
'">';
1942if (!empty($arrayfields[
'f.fk_fac_rec_source'][
'checked'])) {
1944 print
'<td class="liste_titre maxwidthonsmartphone right">';
1945 print
'<input class="flat maxwidth50imp" type="text" name="search_fac_rec_source_title" id="search_fac_rec_source_title" value="'.dol_escape_htmltag($search_fac_rec_source_title).
'">';
1949if (!empty($arrayfields[
'f.import_key'][
'checked'])) {
1950 print
'<td class="liste_titre maxwidthonsmartphone center">';
1951 print
'<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).
'">';
1955if (!empty($arrayfields[
'f.dispute_status'][
'checked'])) {
1956 print
'<td class="liste_titre center parentonrightofpage">';
1957 $liststatus = array(
'0' =>
"None",
'1' =>
"DisputeOpen",
'8' =>
"DisputeLost",
'9' =>
"DisputeWon");
1959 print $form->selectarray(
'search_dispute_status', $liststatus, $search_dispute_status, 1, 0, 0,
'', 1, 0, 0,
'',
'search_status width100 onrightofpage', 1);
1963if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1964 print
'<td class="liste_titre center parentonrightofpage">';
1965 $liststatus = array(
'0' => $langs->trans(
"BillShortStatusDraft"),
'0,1' => $langs->trans(
"BillShortStatusDraft").
'+'.$langs->trans(
"BillShortStatusNotPaid"),
'1' => $langs->trans(
"BillShortStatusNotPaid"),
'1,2' => $langs->trans(
"BillShortStatusNotPaid").
'+'.$langs->trans(
"BillShortStatusPaid"),
'2' => $langs->trans(
"BillShortStatusPaid"),
'3' => $langs->trans(
"BillShortStatusCanceled"));
1967 print $form->selectarray(
'search_status', $liststatus, $search_status, 1, 0, 0,
'', 0, 0, 0,
'',
'search_status width100 onrightofpage', 1);
1972 print
'<td class="liste_titre center maxwidthsearch actioncolumn">';
1973 $searchpicto = $form->showFilterButtons();
1984print
'<tr class="liste_titre">';
1986 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
1993if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1994 print_liste_field_titre($arrayfields[
'f.ref'][
'label'], $_SERVER[
'PHP_SELF'],
'f.ref',
'', $param,
'', $sortfield, $sortorder);
1997if (!empty($arrayfields[
'f.ref_client'][
'checked'])) {
1998 print_liste_field_titre($arrayfields[
'f.ref_client'][
'label'], $_SERVER[
"PHP_SELF"],
'f.ref_client',
'', $param,
'', $sortfield, $sortorder);
2001if (!empty($arrayfields[
'f.type'][
'checked'])) {
2002 print_liste_field_titre($arrayfields[
'f.type'][
'label'], $_SERVER[
"PHP_SELF"],
'f.type',
'', $param,
'', $sortfield, $sortorder);
2005if (!empty($arrayfields[
'f.subtype'][
'checked'])) {
2006 print_liste_field_titre($arrayfields[
'f.subtype'][
'label'], $_SERVER[
"PHP_SELF"],
'f.subtype',
'', $param,
'', $sortfield, $sortorder);
2008if (!empty($arrayfields[
'f.datef'][
'checked'])) {
2009 print_liste_field_titre($arrayfields[
'f.datef'][
'label'], $_SERVER[
'PHP_SELF'],
'f.datef',
'', $param,
'', $sortfield, $sortorder,
'center ');
2012if (!empty($arrayfields[
'f.date_valid'][
'checked'])) {
2013 print_liste_field_titre($arrayfields[
'f.date_valid'][
'label'], $_SERVER[
'PHP_SELF'],
'f.date_valid',
'', $param,
'', $sortfield, $sortorder,
'center ');
2016if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
2017 print_liste_field_titre($arrayfields[
'f.date_lim_reglement'][
'label'], $_SERVER[
'PHP_SELF'],
"f.date_lim_reglement",
'', $param,
'', $sortfield, $sortorder,
'center ');
2020if (!empty($arrayfields[
'p.ref'][
'checked'])) {
2021 $langs->load(
"projects");
2022 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
'PHP_SELF'],
"p.ref",
'', $param,
'', $sortfield, $sortorder);
2025if (!empty($arrayfields[
'p.title'][
'checked'])) {
2026 print_liste_field_titre($arrayfields[
'p.title'][
'label'], $_SERVER[
'PHP_SELF'],
"p.title",
'', $param,
'', $sortfield, $sortorder);
2029if (!empty($arrayfields[
's.nom'][
'checked'])) {
2030 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
'PHP_SELF'],
's.nom',
'', $param,
'', $sortfield, $sortorder);
2033if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2035 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2038if (!empty($arrayfields[
's2.nom'][
'checked'])) {
2039 print_liste_field_titre($arrayfields[
's2.nom'][
'label'], $_SERVER[
'PHP_SELF'],
's2.nom',
'', $param,
'', $sortfield, $sortorder);
2042if (!empty($arrayfields[
's.code_client'][
'checked'])) {
2043 print_liste_field_titre($arrayfields[
's.code_client'][
'label'], $_SERVER[
'PHP_SELF'],
's.code_client',
'', $param,
'', $sortfield, $sortorder);
2046if (!empty($arrayfields[
's.town'][
'checked'])) {
2047 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
2050if (!empty($arrayfields[
's.zip'][
'checked'])) {
2051 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
2054if (!empty($arrayfields[
'state.nom'][
'checked'])) {
2055 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
2058if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
2059 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
2062if (!empty($arrayfields[
'typent.code'][
'checked'])) {
2063 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
2066if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
2067 print_liste_field_titre($arrayfields[
'f.fk_mode_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_mode_reglement",
"", $param,
"", $sortfield, $sortorder);
2070if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
2071 print_liste_field_titre($arrayfields[
'f.fk_cond_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_cond_reglement",
"", $param,
"", $sortfield, $sortorder);
2074if (!empty($arrayfields[
'f.fk_input_reason'][
'checked'])) {
2075 print_liste_field_titre($arrayfields[
'f.fk_input_reason'][
'label'], $_SERVER[
'PHP_SELF'],
'f.fk_input_reason',
'', $param,
'', $sortfield, $sortorder);
2077if (!empty($arrayfields[
'f.module_source'][
'checked'])) {
2078 print_liste_field_titre($arrayfields[
'f.module_source'][
'label'], $_SERVER[
"PHP_SELF"],
"f.module_source",
"", $param,
"", $sortfield, $sortorder);
2081if (!empty($arrayfields[
'f.pos_source'][
'checked'])) {
2082 print_liste_field_titre($arrayfields[
'f.pos_source'][
'label'], $_SERVER[
"PHP_SELF"],
"f.pos_source",
"", $param,
"", $sortfield, $sortorder);
2085if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
2086 print_liste_field_titre($arrayfields[
'f.total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ht',
'', $param,
'', $sortfield, $sortorder,
'right ');
2089if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
2090 print_liste_field_titre($arrayfields[
'f.total_tva'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_tva',
'', $param,
'', $sortfield, $sortorder,
'right ');
2093if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
2094 print_liste_field_titre($arrayfields[
'f.total_localtax1'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax1',
'', $param,
'', $sortfield, $sortorder,
'right ');
2097if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
2098 print_liste_field_titre($arrayfields[
'f.total_localtax2'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax2',
'', $param,
'', $sortfield, $sortorder,
'right ');
2101if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
2102 print_liste_field_titre($arrayfields[
'f.total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ttc',
'', $param,
'', $sortfield, $sortorder,
'right ');
2105if (!empty($arrayfields[
'u.login'][
'checked'])) {
2106 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
'u.login',
'', $param,
'', $sortfield, $sortorder,
'center ');
2109if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
2110 print_liste_field_titre($arrayfields[
'sale_representative'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"",
"$param",
'', $sortfield, $sortorder);
2113if (!empty($arrayfields[
'f.retained_warranty'][
'checked'])) {
2114 print_liste_field_titre($arrayfields[
'f.retained_warranty'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2117if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
2118 print_liste_field_titre($arrayfields[
'dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2121if (!empty($arrayfields[
'rtp'][
'checked'])) {
2122 print_liste_field_titre($arrayfields[
'rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2125if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
2126 print_liste_field_titre($arrayfields[
'f.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
2129if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
2130 print_liste_field_titre($arrayfields[
'f.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
2133if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
2134 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ht',
'', $param,
'', $sortfield, $sortorder,
'right ');
2137if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
2138 print_liste_field_titre($arrayfields[
'f.multicurrency_total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_tva',
'', $param,
'', $sortfield, $sortorder,
'right ');
2141if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
2142 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ttc',
'', $param,
'', $sortfield, $sortorder,
'right ');
2145if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
2146 print_liste_field_titre($arrayfields[
'multicurrency_dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2149if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
2150 print_liste_field_titre($arrayfields[
'multicurrency_rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2153if (!empty($arrayfields[
'total_pa'][
'checked'])) {
2154 print_liste_field_titre($arrayfields[
'total_pa'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2157if (!empty($arrayfields[
'total_margin'][
'checked'])) {
2158 print_liste_field_titre($arrayfields[
'total_margin'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2161if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
2162 print_liste_field_titre($arrayfields[
'total_margin_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2165if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
2166 print_liste_field_titre($arrayfields[
'total_mark_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2170include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
2172$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &$totalarray);
2173$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2174print $hookmanager->resPrint;
2175if (!empty($arrayfields[
'f.datec'][
'checked'])) {
2176 print_liste_field_titre($arrayfields[
'f.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"f.datec",
"", $param,
'', $sortfield, $sortorder,
'nowraponall center ');
2179if (!empty($arrayfields[
'f.tms'][
'checked'])) {
2180 print_liste_field_titre($arrayfields[
'f.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"f.tms",
"", $param,
'', $sortfield, $sortorder,
'nowraponall center ');
2183if (!empty($arrayfields[
'f.date_closing'][
'checked'])) {
2184 print_liste_field_titre($arrayfields[
'f.date_closing'][
'label'], $_SERVER[
"PHP_SELF"],
"f.date_closing",
"", $param,
'', $sortfield, $sortorder,
'nowraponall center ');
2187if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
2188 print_liste_field_titre($arrayfields[
'f.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"f.note_public",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
2191if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
2192 print_liste_field_titre($arrayfields[
'f.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"f.note_private",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
2195if (!empty($arrayfields[
'f.fk_fac_rec_source'][
'checked'])) {
2196 print_liste_field_titre($arrayfields[
'f.fk_fac_rec_source'][
'label'], $_SERVER[
"PHP_SELF"],
"facrec.titre",
"", $param,
'', $sortfield, $sortorder);
2200if (!empty($arrayfields[
'f.import_key'][
'checked'])) {
2201 print_liste_field_titre($arrayfields[
'f.import_key'][
'label'], $_SERVER[
"PHP_SELF"],
"f.import_key",
"", $param,
'', $sortfield, $sortorder,
'center ');
2205if (!empty($arrayfields[
'f.dispute_status'][
'checked'])) {
2206 print_liste_field_titre($arrayfields[
'f.dispute_status'][
'label'], $_SERVER[
"PHP_SELF"],
"f.dispute_status,f.ref",
"", $param,
'', $sortfield, $sortorder,
'center ');
2210if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
2211 print_liste_field_titre($arrayfields[
'f.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_statut,f.paye,f.type",
"", $param,
'', $sortfield, $sortorder,
'center ');
2216 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch center ');
2222$projectstatic =
new Project($db);
2224$userstatic =
new User($db);
2242 $typenArray = $formcompany->typent_array(1);
2244 $with_margin_info =
false;
2246 !empty($arrayfields[
'total_pa'][
'checked'])
2247 || !empty($arrayfields[
'total_margin'][
'checked'])
2248 || !empty($arrayfields[
'total_margin_rate'][
'checked'])
2249 || !empty($arrayfields[
'total_mark_rate'][
'checked'])
2252 $with_margin_info =
true;
2257 $imaxinloop = ($limit ? min($num, $limit) : $num);
2258 while ($i < $imaxinloop) {
2259 $obj = $db->fetch_object($resql);
2261 $datelimit = $db->jdate($obj->datelimite);
2263 $facturestatic->id = $obj->id;
2264 $facturestatic->ref = $obj->ref;
2265 $facturestatic->ref_client = $obj->ref_client;
2266 $facturestatic->ref_customer = $obj->ref_client;
2267 $facturestatic->type = $obj->type;
2268 $facturestatic->subtype = $obj->subtype;
2269 $facturestatic->total_ht = $obj->total_ht;
2270 $facturestatic->total_tva = $obj->total_tva;
2271 $facturestatic->total_ttc = $obj->total_ttc;
2272 $facturestatic->multicurrency_code = $obj->multicurrency_code;
2273 $facturestatic->multicurrency_tx = $obj->multicurrency_tx;
2274 $facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht;
2275 $facturestatic->multicurrency_total_tva = $obj->multicurrency_total_vat;
2276 $facturestatic->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
2277 $facturestatic->status = $obj->status;
2278 $facturestatic->close_code = $obj->close_code;
2279 $facturestatic->total_ttc = $obj->total_ttc;
2280 $facturestatic->paye = $obj->paye;
2281 $facturestatic->socid = $obj->fk_soc;
2283 $facturestatic->date = $db->jdate($obj->datef);
2284 $facturestatic->date_validation = $db->jdate($obj->date_valid);
2285 $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite);
2287 $facturestatic->note_public = $obj->note_public;
2288 $facturestatic->note_private = $obj->note_private;
2291 $facturestatic->retained_warranty = $obj->retained_warranty;
2292 $facturestatic->retained_warranty_date_limit = $obj->retained_warranty_date_limit;
2293 $facturestatic->situation_final = $obj->retained_warranty_date_limit;
2294 $facturestatic->situation_final = $obj->retained_warranty_date_limit;
2295 $facturestatic->situation_cycle_ref = $obj->situation_cycle_ref;
2296 $facturestatic->situation_counter = $obj->situation_counter;
2299 $facturestatic->payment_reference = $obj->payment_reference;
2300 $facturestatic->dispute_status = $obj->dispute_status;
2302 $companystatic->id = $obj->socid;
2303 $companystatic->name = $obj->name;
2304 $companystatic->name_alias = $obj->alias;
2305 $companystatic->client = $obj->client;
2306 $companystatic->fournisseur = $obj->fournisseur;
2307 $companystatic->code_client = $obj->code_client;
2308 $companystatic->code_compta_client = $obj->code_compta_client;
2309 $companystatic->code_fournisseur = $obj->code_fournisseur;
2310 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
2311 $companystatic->email = $obj->email;
2312 $companystatic->phone = $obj->phone;
2313 $companystatic->fax = $obj->fax;
2314 $companystatic->address = $obj->address;
2315 $companystatic->zip = $obj->zip;
2316 $companystatic->town = $obj->town;
2317 $companystatic->country_code = $obj->country_code;
2319 $projectstatic->id = $obj->project_id;
2320 $projectstatic->ref = $obj->project_ref;
2321 $projectstatic->title = $obj->project_label;
2323 $paiement = $facturestatic->getSommePaiement();
2324 $totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
2325 $totaldeposits = $facturestatic->getSumDepositsUsed();
2326 $totalallpayments = $paiement + $totalcreditnotes + $totaldeposits;
2327 $remaintopay = $obj->total_ttc - $totalallpayments;
2329 $multicurrency_paiement = $facturestatic->getSommePaiement(1);
2330 $multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
2331 $multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
2333 $totalallpayments = $paiement + $totalcreditnotes + $totaldeposits;
2334 $remaintopay =
price2num($facturestatic->total_ttc - $totalallpayments);
2336 $multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
2337 $multicurrency_remaintopay =
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);
2341 $multicurrency_remaintopay = 0;
2344 $remaincreditnote = $discount->getAvailableDiscounts($companystatic,
null,
'rc.fk_facture_source='.$facturestatic->id);
2345 $remaintopay = -$remaincreditnote;
2346 $totalallpayments =
price2num($facturestatic->total_ttc - $remaintopay);
2347 $multicurrency_remaincreditnote = $discount->getAvailableDiscounts($companystatic,
null,
'rc.fk_facture_source='.$facturestatic->id, 0, 0, 1);
2348 $multicurrency_remaintopay = -$multicurrency_remaincreditnote;
2349 $multicurrency_totalpay =
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_remaintopay);
2352 $facturestatic->alreadypaid = $paiement;
2353 $facturestatic->totalpaid = $paiement;
2354 $facturestatic->totalcreditnotes = $totalcreditnotes;
2355 $facturestatic->totaldeposits = $totaldeposits;
2357 $marginInfo = array();
2358 if ($with_margin_info) {
2359 $facturestatic->fetch_lines();
2360 $marginInfo = $formmargin->getMarginInfosArray($facturestatic);
2361 $total_ht += $obj->total_ht;
2362 $total_margin += $marginInfo[
'total_margin'];
2367 if ($mode ==
'kanban') {
2369 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
2370 print
'<div class="box-flex-container kanban">';
2373 if ($massactionbutton || $massaction) {
2375 if (in_array(
$object->id, $arrayofselected)) {
2380 $arraydata = array(
'alreadypaid' => $paiement,
'thirdparty' => $companystatic->getNomUrl(1,
'', 12),
'userauthor' => $userstatic->getNomUrl(1),
'selected' => in_array(
$object->id, $arrayofselected));
2381 print $facturestatic->getKanbanView(
'', $arraydata);
2382 if ($i == ($imaxinloop - 1)) {
2389 print
'<tr data-rowid="'.$object->id.
'" class="oddeven row-with-select status'.
$object->status.((getDolGlobalInt(
'MAIN_FINISHED_LINES_OPACITY') == 1 && $obj->status > 1) ?
' opacitymedium' :
'').
'"';
2390 if ($contextpage ==
'poslist') {
2391 print
' onclick="parent.$(\'#poslines\').load(\'invoice.php?action=history&placeid='.$obj->id.
'\',
function() {parent.$.colorbox.close();
';
2392 if (strpos($obj->ref, 'PROV
') !== false) {
2393 //If is a draft invoice, load var to be able to add products
2394 $place = str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref));
2395 print 'parent.place=\
''.dol_escape_js($place).
'\'';
2403 print
'<td class="nowrap center">';
2404 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
2406 if (in_array($obj->id, $arrayofselected)) {
2409 print
'<input id="cb'.$obj->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2419 print
'<td>'.(($offset * $limit) + $i).
'</td>';
2426 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
2427 print
'<td class="nowraponall">';
2429 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
2431 print
'<td class="nobordernopadding nowraponall">';
2432 if ($contextpage ==
'poslist') {
2435 print $facturestatic->getNomUrl(1,
'', 200, 0,
'', 0, 1);
2439 $filepath = $conf->invoice->multidir_output[$obj->entity] ?? $conf->invoice->dir_output;
2440 $filedir = $filepath.
'/'.$filename;
2442 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->id;
2443 print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
2455 if (!empty($arrayfields[
'f.ref_client'][
'checked'])) {
2456 $tdcss = (
getDolGlobalInt(
'MAIN_SHOW_GLOBAL_REF_CUSTOMER_SUPPLIER') ?
'class="minwidth400 maxwidth400"' :
'class="nowrap tdoverflowmax200"');
2457 print
'<td title="'.dolPrintHTMLForAttribute($obj->ref_client).
'" '.$tdcss.
'>';
2466 if (!empty($arrayfields[
'f.type'][
'checked'])) {
2467 print
'<td class="nowraponall tdoverflowmax100" title="'.$facturestatic->getLibType().
'">';
2468 print $facturestatic->getLibType(2);
2476 if (!empty($arrayfields[
'f.subtype'][
'checked'])) {
2478 if ($facturestatic->subtype > 0) {
2479 $labeltoshow = $facturestatic->getSubtypeLabel(
'facture');
2481 print
'<td class="nowraponall tdoverflowmax300" title="'.$labeltoshow.
'">';
2490 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
2491 print
'<td align="center" class="nowraponall">';
2500 if (!empty($arrayfields[
'f.date_valid'][
'checked'])) {
2501 print
'<td align="center" class="nowraponall">';
2510 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
2511 print
'<td align="center" class="nowraponall">'.dol_print_date($datelimit,
'day');
2512 if ($facturestatic->hasDelay()) {
2513 print
img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
2522 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
2523 print
'<td class="nocellnopadd nowraponall">';
2524 if ($obj->project_id > 0) {
2525 print $projectstatic->getNomUrl(1);
2534 if (!empty($arrayfields[
'p.title'][
'checked'])) {
2535 print
'<td class="nowraponall">';
2536 if ($obj->project_id > 0) {
2546 if (!empty($arrayfields[
's.nom'][
'checked'])) {
2547 print
'<td class="tdoverflowmax150">';
2548 if ($contextpage ==
'poslist') {
2551 print $companystatic->getNomUrl(1,
'customer', 0, 0, -1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2559 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2560 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->name_alias).
'">';
2568 if (!empty($arrayfields[
's2.nom'][
'checked'])) {
2569 print
'<td class="tdoverflowmax200">';
2570 if ($obj->fk_parent > 0) {
2571 if (!isset($company_url_list[$obj->fk_parent])) {
2572 $companyparent =
new Societe($db);
2573 $res = $companyparent->fetch($obj->fk_parent);
2575 $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1);
2578 if (isset($company_url_list[$obj->fk_parent])) {
2579 print $company_url_list[$obj->fk_parent];
2588 if (!empty($arrayfields[
's.code_client'][
'checked'])) {
2589 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->code_client).
'">';
2597 if (!empty($arrayfields[
's.town'][
'checked'])) {
2598 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).
'">';
2606 if (!empty($arrayfields[
's.zip'][
'checked'])) {
2607 print
'<td class="nowraponall">';
2615 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
2616 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->state_name).
'">'.
dol_escape_htmltag($obj->state_name).
"</td>\n";
2622 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
2623 $tmparray =
getCountry($obj->fk_pays,
'all');
2624 print
'<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($tmparray[
'label']).
'">';
2632 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
2633 if (!is_array($typenArray) || count($typenArray) == 0) {
2634 $typenArray = $formcompany->typent_array(1);
2636 print
'<td class="center tdoverflowmax100" title="'.dolPrintHTMLForAttribute($typenArray[$obj->typent_code]).
'">';
2637 if (!empty($obj->typent_code)) {
2638 print $typenArray[$obj->typent_code];
2646 if (!empty($arrayfields[
'staff.code'][
'checked'])) {
2647 if (!is_array($conf->cache[
'staff']) || count($conf->cache[
'staff']) == 0) {
2648 $conf->cache[
'staff'] = $formcompany->effectif_array(1);
2650 print
'<td class="center tdoverflowmax100" title="'.dolPrintHTML($conf->cache[
'staff'][$obj->staff_code]).
'">';
2651 print $conf->cache[
'staff'][$obj->staff_code];
2659 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
2660 $s = $form->form_modes_reglement($_SERVER[
'PHP_SELF'], $obj->fk_mode_reglement,
'none',
'', -1, 0,
'', 1);
2661 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
2670 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
2671 $s = $form->form_conditions_reglement($_SERVER[
'PHP_SELF'], $obj->fk_cond_reglement,
'none', 0,
'', -1, -1, 1);
2672 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
2681 if (!empty($arrayfields[
'f.fk_input_reason'][
'checked'])) {
2683 $form->formInputReason($_SERVER[
'PHP_SELF'], (
string) $obj->fk_input_reason,
'none');
2691 if (!empty($arrayfields[
'f.module_source'][
'checked'])) {
2700 if (!empty($arrayfields[
'f.pos_source'][
'checked'])) {
2710 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
2711 print
'<td class="right nowraponall"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
2718 $totalarray[
'val'][
'f.total_ht'] += $obj->total_ht;
2721 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
2722 print
'<td class="right nowraponall amount">'.price($obj->total_tva).
"</td>\n";
2729 $totalarray[
'val'][
'f.total_tva'] += $obj->total_tva;
2732 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
2733 print
'<td class="right nowraponall amount">'.price($obj->total_localtax1).
"</td>\n";
2740 $totalarray[
'val'][
'f.total_localtax1'] += $obj->total_localtax1;
2743 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
2744 print
'<td class="right nowraponall amount">'.price($obj->total_localtax2).
"</td>\n";
2751 $totalarray[
'val'][
'f.total_localtax2'] += $obj->total_localtax2;
2754 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
2755 print
'<td class="right nowraponall amount">'.price($obj->total_ttc).
"</td>\n";
2762 $totalarray[
'val'][
'f.total_ttc'] += $obj->total_ttc;
2765 $userstatic->id = $obj->fk_user_author;
2766 $userstatic->login = $obj->login;
2767 $userstatic->lastname = $obj->lastname;
2768 $userstatic->firstname = $obj->firstname;
2769 $userstatic->email = $obj->user_email;
2770 $userstatic->status = $obj->user_statut;
2771 $userstatic->entity = $obj->entity;
2772 $userstatic->photo = $obj->photo;
2773 $userstatic->office_phone = $obj->office_phone;
2774 $userstatic->office_fax = $obj->office_fax;
2775 $userstatic->user_mobile = $obj->user_mobile;
2776 $userstatic->job = $obj->job;
2777 $userstatic->gender = $obj->gender;
2780 if (!empty($arrayfields[
'u.login'][
'checked'])) {
2781 print
'<td class="tdoverflowmax100">';
2782 if ($userstatic->id) {
2783 print $userstatic->getNomUrl(-1);
2793 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
2796 if ($obj->socid > 0) {
2797 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
2798 if ($listsalesrepresentatives < 0) {
2801 $nbofsalesrepresentative = count($listsalesrepresentatives);
2802 if ($nbofsalesrepresentative > 6) {
2804 print $nbofsalesrepresentative;
2805 } elseif ($nbofsalesrepresentative > 0) {
2807 foreach ($listsalesrepresentatives as $val) {
2808 $userstatic->id = $val[
'id'];
2809 $userstatic->lastname = $val[
'lastname'];
2810 $userstatic->firstname = $val[
'firstname'];
2811 $userstatic->email = $val[
'email'];
2812 $userstatic->status = $val[
'statut'];
2813 $userstatic->entity = $val[
'entity'];
2814 $userstatic->photo = $val[
'photo'];
2815 $userstatic->login = $val[
'login'];
2816 $userstatic->office_phone = $val[
'office_phone'];
2817 $userstatic->office_fax = $val[
'office_fax'];
2818 $userstatic->user_mobile = $val[
'user_mobile'];
2819 $userstatic->job = $val[
'job'];
2820 $userstatic->gender = $val[
'gender'];
2822 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1,
'', 0, 0, 12) : $userstatic->getNomUrl(-2);
2824 if ($j < $nbofsalesrepresentative) {
2838 if (!empty($arrayfields[
'f.retained_warranty'][
'checked'])) {
2839 print
'<td align="right">'.(!empty($obj->retained_warranty) ?
price($obj->retained_warranty).
'%' :
' ').
'</td>';
2845 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
2846 print
'<td class="right nowraponall amount">'.(!empty($totalallpayments) ?
price($totalallpayments, 0, $langs) :
' ').
'</td>';
2853 $totalarray[
'val'][
'dynamount_payed'] += $totalallpayments;
2857 if (!empty($arrayfields[
'rtp'][
'checked'])) {
2858 print
'<td class="right nowraponall amount">';
2859 print(!empty($remaintopay) ?
price($remaintopay, 0, $langs) :
' ');
2872 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
2873 if (!
getDolGlobalString(
'MAIN_SHOW_ONLY_CODE_MULTICURRENCY') && !empty($obj->multicurrency_code)) {
2874 $title = $obj->multicurrency_code.
' - '.$langs->transnoentitiesnoconv(
'Currency'.$obj->multicurrency_code);
2875 $label = $langs->transnoentitiesnoconv(
'Currency'.$obj->multicurrency_code);
2877 $title = $obj->multicurrency_code;
2878 $label = $obj->multicurrency_code;
2880 print
'<td class="nowraponall tdoverflowmax125" title="'.dolPrintHTMLForAttribute($title).
'">';
2889 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
2890 print
'<td class="nowraponall">';
2891 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
2898 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
2899 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_total_ht).
"</td>\n";
2905 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
2906 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_total_vat).
"</td>\n";
2912 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
2913 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_total_ttc).
"</td>\n";
2919 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
2920 print
'<td class="right nowraponall amount">'.(!empty($multicurrency_totalpay) ?
price($multicurrency_totalpay, 0, $langs) :
' ').
'</td>';
2927 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
2928 print
'<td class="right nowraponall amount">';
2929 print(!empty($multicurrency_remaintopay) ?
price($multicurrency_remaintopay, 0, $langs) :
' ');
2937 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
2938 print
'<td class="right nowrap">'.price($marginInfo[
'pa_total'], 0, $langs, 1, -1,
'MT').
'</td>';
2943 if (empty($totalarray[
'val'][
'total_pa'])) {
2946 $totalarray[
'val'][
'total_pa'] += $marginInfo[
'pa_total'];
2949 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
2950 print
'<td class="right nowrap">'.price($marginInfo[
'total_margin'], 0, $langs, 1, -1,
'MT').
'</td>';
2955 if (empty($totalarray[
'val'][
'total_margin'])) {
2958 $totalarray[
'val'][
'total_margin'] += $marginInfo[
'total_margin'];
2961 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
2962 print
'<td class="right nowrap">'.(($marginInfo[
'total_margin_rate'] ==
'') ?
'' :
price($marginInfo[
'total_margin_rate'], 0,
'', 0, 0, 2).
'%').
'</td>';
2968 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
2969 print
'<td class="right nowrap">'.(($marginInfo[
'total_mark_rate'] ==
'') ?
'' :
price($marginInfo[
'total_mark_rate'], 0,
'', 0, 0, 2).
'%').
'</td>';
2974 if ($i >= $imaxinloop - 1) {
2975 if (!empty($total_ht)) {
2984 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2986 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
2987 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2988 print $hookmanager->resPrint;
2990 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
2991 print
'<td class="nowraponall center">';
2992 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuserrel');
2999 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
3000 print
'<td class="nowraponall center">';
3001 print
dol_print_date($db->jdate($obj->date_modification),
'dayhour',
'tzuserrel');
3008 if (!empty($arrayfields[
'f.date_closing'][
'checked'])) {
3009 print
'<td class="nowraponall center">';
3010 print
dol_print_date($db->jdate($obj->date_closing),
'dayhour',
'tzuserrel');
3017 if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
3018 print
'<td class="sensiblehtmlcontent center">';
3019 print
'<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(
dolGetFirstLineOfText($obj->note_public, 5)).
'</div>';
3026 if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
3027 print
'<td class="sensiblehtmlcontent center">';
3028 print
'<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(
dolGetFirstLineOfText($obj->note_private, 5)).
'</div>';
3035 if (!empty($arrayfields[
'f.fk_fac_rec_source'][
'checked'])) {
3036 print
'<td class="center">';
3037 if (!empty($obj->fk_fac_rec_source)) {
3039 $result = $facrec->fetch($obj->fk_fac_rec_source);
3043 print $facrec->getNomUrl();
3053 if (!empty($arrayfields[
'f.import_key'][
'checked'])) {
3054 print
'<td class="nowrap center">'.dol_escape_htmltag($obj->import_key).
'</td>';
3061 if (!empty($arrayfields[
'f.dispute_status'][
'checked'])) {
3062 print
'<td class="nowrap center">';
3063 if ($facturestatic->dispute_status) {
3064 $liststatus = array(
'0' =>
"None",
'1' =>
"DisputeOpen",
'8' =>
"DisputeLost",
'9' =>
"DisputeWon");
3065 print $langs->trans($liststatus[$facturestatic->dispute_status]);
3074 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
3075 print
'<td class="nowrap center">';
3076 print $facturestatic->getLibStatut(5, $totalallpayments);
3086 print
'<td class="nowrap center">';
3087 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
3089 if (in_array($obj->id, $arrayofselected)) {
3092 print
'<input id="cb'.$obj->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
3107 $totalarray[
'val'][
'total_pa'] = (isset($totalarray[
'val'][
'total_pa']) ?
price2num($totalarray[
'val'][
'total_pa'],
'MT') : null);
3108 $totalarray[
'val'][
'total_margin'] = (isset($totalarray[
'val'][
'total_margin']) ?
price2num($totalarray[
'val'][
'total_margin'],
'MT') : null);
3111 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
3117 foreach ($arrayfields as $key => $val) {
3118 if (!empty($val[
'checked'])) {
3122 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
3127$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
3128$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
3129print $hookmanager->resPrint;
3131print
'</table>'.
"\n";
3134print
'</form>'.
"\n";
3137if ($contextpage !=
'poslist') {
3138 $hidegeneratedfilelistifempty = 1;
3139 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
3140 $hidegeneratedfilelistifempty = 0;
3144 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
3145 $urlsource .= str_replace(
'&',
'&', $param);
3147 $filedir = $diroutputmassaction;
3148 $genallowed = $user->hasRight(
"facture",
"lire");
3149 $delallowed = $user->hasRight(
"facture",
"creer");
3152 print $formfile->showdocuments(
'massfilesarea_invoices',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage absolute discounts.
Class to manage invoices.
const TYPE_REPLACEMENT
Replacement invoice.
const STATUS_DRAFT
Draft status.
const TYPE_STANDARD
Standard invoice.
const TYPE_SITUATION
Situation invoice.
const STATUS_VALIDATED
Validated (need to be paid)
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
const STATUS_CLOSED
Classified paid.
Class to manage invoice templates.
Class to manage payments of customer invoices.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
getCountriesInEEC()
Return list of countries that are inside the EEC (European Economic Community) Note: Try to keep this...
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
dolPrintLabel($s, $escapeonlyhtmltags=0)
Return a string label (so on 1 line only and that should not contains any HTML) ready to be output on...
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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...
invoice_rec_prepare_head($object)
Return array head with list of tabs to view object information.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.