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),
314 unset($arrayfields[
'f.note_private']);
317 $arrayfields[
'f.retained_warranty'] = array(
'label' => $langs->trans(
"RetainedWarranty"),
'checked' =>
'0',
'position' => 86);
320$subtypearray =
$object->getArrayOfInvoiceSubtypes(0);
321if (empty($subtypearray)) {
322 unset($arrayfields[
'f.subtype']);
326foreach (
$object->fields as $key => $val) {
329 if (!empty($val[
'visible'])) {
330 $visible = (int)
dol_eval((
string) $val[
'visible'], 1, 1,
'1');
332 if (array_key_exists($key, $arrayfields)) {
334 } elseif (array_key_exists(
'f.'.$key, $arrayfields)) {
336 } elseif (array_key_exists(
's.'.$key, $arrayfields)) {
340 $arrayfields[$newkey] = array(
341 'label' => $val[
'label'],
342 'checked' => (($visible < 0) ?
'0' :
'1'),
343 'enabled' => (string) (int) (abs($visible) != 3 && (bool)
dol_eval((string) $val[
'enabled'], 1)),
344 'position' => $val[
'position'],
345 'help' => empty($val[
'help']) ?
'' : $val[
'help'],
351include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
353$parameters = array(
'arrayfields' => &$arrayfields);
354$reshook = $hookmanager->executeHooks(
'completeArrayFields', $parameters, $object, $action);
357if ($contextpage ==
'poslist') {
358 $arrayfields[
"f.module_source"][
'checked'] = 1;
359 $arrayfields[
"f.pos_source"][
'checked'] = 1;
360 $arrayfields[
"f.date_lim_reglement"][
'checked'] = 0;
361 $arrayfields[
"f.total_ttc"][
'checked'] = 1;
362 $arrayfields[
"f.tms"][
'checked'] = 1;
363 $arrayfields[
"p.ref"][
'checked'] = 0;
371if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
372 $search_sale = $user->id;
376$fieldid = (!empty($ref) ?
'ref' :
'rowid');
377if (!empty($user->socid)) {
378 $socid = $user->socid;
380if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
381 $search_sale = $user->id;
391if (
GETPOST(
'cancel',
'alpha')) {
395if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
399$parameters = array(
'socid' => $socid,
'arrayfields' => &$arrayfields);
400$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
405include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
408if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha')) {
411 $search_product_category =
'';
412 $searchCategoryInvoiceList = array();
414 $search_refcustomer =
'';
416 $search_subtype =
'';
417 $search_project_ref =
'';
418 $search_project =
'';
419 $search_company =
'';
420 $search_company_alias =
'';
421 $search_parent_name =
'';
422 $search_montant_ht =
'';
423 $search_montant_vat =
'';
424 $search_montant_localtax1 =
'';
425 $search_montant_localtax2 =
'';
426 $search_montant_ttc =
'';
428 $search_multicurrency_code =
'';
429 $search_multicurrency_tx =
'';
430 $search_multicurrency_montant_ht =
'';
431 $search_multicurrency_montant_vat =
'';
432 $search_multicurrency_montant_ttc =
'';
433 $search_dispute_status =
'';
435 $search_paymentmode =
'';
436 $search_paymentterms =
'';
437 $search_fk_input_reason =
'';
438 $search_module_source =
'';
439 $search_pos_source =
'';
443 $search_country =
'';
444 $search_type_thirdparty =
'';
445 $search_customer_code =
'';
446 $search_date_startday =
'';
447 $search_date_startmonth =
'';
448 $search_date_startyear =
'';
449 $search_date_endday =
'';
450 $search_date_endmonth =
'';
451 $search_date_endyear =
'';
452 $search_date_start =
'';
453 $search_date_end =
'';
454 $search_date_valid_startday =
'';
455 $search_date_valid_startmonth =
'';
456 $search_date_valid_startyear =
'';
457 $search_date_valid_endday =
'';
458 $search_date_valid_endmonth =
'';
459 $search_date_valid_endyear =
'';
460 $search_date_valid_start =
'';
461 $search_date_valid_end =
'';
462 $search_datelimit_startday =
'';
463 $search_datelimit_startmonth =
'';
464 $search_datelimit_startyear =
'';
465 $search_datelimit_endday =
'';
466 $search_datelimit_endmonth =
'';
467 $search_datelimit_endyear =
'';
468 $search_datelimit_start =
'';
469 $search_datelimit_end =
'';
471 $search_datec_start =
'';
472 $search_datec_end =
'';
474 $search_datem_start =
'';
475 $search_datem_end =
'';
477 $search_fac_rec_source_title =
'';
479 $search_import_key =
'';
480 $search_categ_cus = 0;
484 $search_array_options = array();
487if (empty($reshook)) {
488 $objectclass =
'Facture';
489 $objectlabel =
'Invoices';
490 $permissiontoread = $user->hasRight(
"facture",
"lire");
491 $permissiontoadd = $user->hasRight(
"facture",
"creer");
492 $permissiontodelete = $user->hasRight(
"facture",
"supprimer");
493 $uploaddir = $conf->invoice->dir_output;
494 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
497if ($action ==
'makepayment_confirm' && $user->hasRight(
'facture',
'paiement')) {
498 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
499 $arrayofselected = is_array($toselect) ? $toselect : array();
500 if (!empty($arrayofselected)) {
504 if (empty($paiementdate)) {
505 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
507 $action =
'makepayment';
511 foreach ($arrayofselected as $toselectid) {
514 $result = $facture->fetch($toselectid);
524 $sommePaiement = $facture->getSommePaiement(-1);
525 $paiementAmount = $sommePaiement[
'alreadypaid'];
527 $totalcreditnotes = $facture->getSumCreditNotesUsed();
528 $totaldeposits = $facture->getSumDepositsUsed();
530 $totalallpayments = $paiementAmount + $totalcreditnotes + $totaldeposits;
531 $remaintopay = (float)
price2num($facture->total_ttc - $totalallpayments);
534 $parameters = array(
'remaintopay' => $remaintopay);
535 $reshook = $hookmanager->executeHooks(
'finalizeAmountOfInvoice', $parameters, $facture, $action);
537 if (!empty($remain = (
float) $hookmanager->resArray[
'remaintopay'])) {
538 $remaintopay = $remain;
540 } elseif ($reshook < 0) {
542 setEventMessages($facture->ref.
' '.$langs->trans(
"ProcessingError"), $hookmanager->errors,
'errors');
546 $multicurrency_remaintopay = (float)
price2num($facture->multicurrency_total_ttc - $sommePaiement[
'alreadypaid_multicurrency']);
548 if ($remaintopay != 0) {
549 $resultBank = $facture->setBankAccount($bankid);
550 if ($resultBank < 0) {
555 $paiement->datepaye = $paiementdate;
556 $paiement->amounts[$facture->id] = $remaintopay;
557 $paiement->multicurrency_amounts[$facture->id] = (float) $multicurrency_remaintopay;
558 $paiement->paiementid = $paiementid;
559 $paiement_id = $paiement->create($user, 1, $facture->thirdparty);
560 if ($paiement_id < 0) {
561 $langs->load(
"errors");
562 setEventMessages($facture->ref.
' '.$langs->trans($paiement->error), $paiement->errors,
'errors');
565 $result = $paiement->addPaymentToBank($user,
'payment',
'', $bankid,
'',
'');
567 $langs->load(
"errors");
568 setEventMessages($facture->ref.
' '.$langs->trans($paiement->error), $paiement->errors,
'errors');
574 setEventMessage($langs->trans(
'NoPaymentAvailable', $facture->ref),
'warnings');
578 setEventMessage($langs->trans(
'BulkPaymentNotPossibleForInvoice', $facture->ref),
'warnings');
583 if (empty($errorpayment)) {
584 setEventMessage($langs->trans(
'PaymentRegisteredAndInvoiceSetToPaid', $facture->ref));
592} elseif ($massaction ==
'withdrawrequest') {
593 $langs->load(
"withdrawals");
595 if (!$user->hasRight(
'prelevement',
'bons',
'creer')) {
602 $arrayofselected = is_array($toselect) ? $toselect : array();
603 $listofbills = array();
604 foreach ($arrayofselected as $toselectid) {
606 $result = $objecttmp->fetch($toselectid);
608 $totalpaid = $objecttmp->getSommePaiement();
609 $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
610 $totaldeposits = $objecttmp->getSumDepositsUsed();
611 $objecttmp->resteapayer =
price2num($objecttmp->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
614 $parameters = array(
'remaintopay' => $objecttmp->resteapayer);
615 $reshook = $hookmanager->executeHooks(
'finalizeAmountOfInvoice', $parameters, $objecttmp, $action);
617 if (!empty($remaintopay = $hookmanager->resArray[
'remaintopay'])) {
618 $objecttmp->resteapayer = $remaintopay;
620 } elseif ($reshook < 0) {
622 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"ProcessingError"), $hookmanager->errors,
'errors');
627 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"Draft"), $objecttmp->errors,
'errors');
628 } elseif ($objecttmp->paye || $objecttmp->resteapayer == 0) {
630 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AlreadyPaid"), $objecttmp->errors,
'errors');
631 } elseif ($objecttmp->resteapayer < 0) {
633 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AmountMustBePositive"), $objecttmp->errors,
'errors');
636 $rsql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
637 $rsql .=
" , pfd.date_traite as date_traite";
638 $rsql .=
" , pfd.amount";
639 $rsql .=
" , u.rowid as user_id, u.lastname, u.firstname, u.login";
640 $rsql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
641 $rsql .=
" , ".MAIN_DB_PREFIX.
"user as u";
642 $rsql .=
" WHERE fk_facture = ".((int) $objecttmp->id);
643 $rsql .=
" AND pfd.fk_user_demande = u.rowid";
644 $rsql .=
" AND pfd.traite = 0";
645 $rsql .=
" ORDER BY pfd.date_demande DESC";
647 $result_sql = $db->query($rsql);
649 $numprlv = $db->num_rows($result_sql);
656 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"RequestAlreadyDone"), $objecttmp->errors,
'warnings');
657 } elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code !=
'PRE') {
658 $langs->load(
"errors");
660 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"ErrorThisPaymentModeIsNotDirectDebit"), $objecttmp->errors,
'errors');
662 $listofbills[] = $objecttmp;
668 if (!empty($listofbills)) {
669 $nbwithdrawrequestok = 0;
670 foreach ($listofbills as $aBill) {
677 $sql =
"SELECT SUM(pfd.amount) as amount";
678 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
682 $sql .=
" WHERE pfd.fk_facture = ".((int) $aBill->id);
684 $sql .=
" AND pfd.traite = 0";
686 $resql = $db->query($sql);
688 $obj = $db->fetch_object($resql);
690 $pending += (float) $obj->amount;
696 $sqlPending =
"SELECT SUM(pl.amount) as amount";
697 $sqlPending .=
" FROM ".$db->prefix().
"prelevement_lignes as pl";
698 $sqlPending .=
" INNER JOIN ".$db->prefix().
"prelevement as p ON p.fk_prelevement_lignes = pl.rowid";
702 $sqlPending .=
" WHERE p.fk_facture = ".((int) $aBill->id);
704 $sqlPending .=
" AND (pl.statut IS NULL OR pl.statut = 0)";
705 $resPending = $db->query($sqlPending);
707 if ($objPending = $db->fetch_object($resPending)) {
708 $pending += (float) $objPending->amount;
711 $db->free($resPending);
713 $requestAmount = $aBill->resteapayer - $pending;
716 $result = $aBill->demande_prelevement($user, $requestAmount,
'direct-debit',
'facture');
717 if ($requestAmount > 0) {
720 $nbwithdrawrequestok++;
726 $aBill->error =
'WithdrawRequestErrorNilAmount';
727 $aBill->errors[] = $aBill->error;
731 if ($nbwithdrawrequestok > 0) {
732 setEventMessages($langs->trans(
"WithdrawRequestsDone", $nbwithdrawrequestok),
null,
'mesgs');
744$form =
new Form($db);
748$facturestatic =
new Facture($db);
750$companystatic =
new Societe($db);
751$companyparent =
new Societe($db);
753$company_url_list = array();
758 if (empty($search_company)) {
759 $search_company = $soc->name;
765$title = $langs->trans(
'BillsCustomers').
' '.(($socid > 0 && $soc !==
null) ?
' - '.$soc->name :
'');
766$help_url =
'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes';
768$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
769$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
774$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,';
775$sql .=
' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,';
776$sql .=
' f.fk_user_author,';
777$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,';
778$sql .=
' f.datef, f.date_valid, f.date_lim_reglement as datelimite,';
779$sql .=
" f.fk_input_reason,";
780$sql .=
" f.module_source, f.pos_source,";
781$sql .=
' f.paye as paye, f.fk_statut as status, f.import_key, f.close_code,';
782$sql .=
' f.datec as date_creation, f.tms as date_modification, f.date_closing as date_closing,';
783$sql .=
' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,';
784$sql .=
' f.payment_reference, f.dispute_status,';
785$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,';
786$sql .=
" s.parent as fk_parent,";
787$sql .=
" s2.nom as name2,";
788$sql .=
' typent.code as typent_code,';
789$sql .=
' state.code_departement as state_code, state.nom as state_name,';
790$sql .=
' country.code as country_code,';
791$sql .=
' f.fk_fac_rec_source,';
792$sql .=
' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
793$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';
803if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
804 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
805 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
809$parameters = array();
810$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
811$sql .= $hookmanager->resPrint;
812$sql = preg_replace(
'/,\s*$/',
'', $sql);
816$sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
817$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s2 ON s2.rowid = s.parent";
818$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
819$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
820$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
821$sql .=
', '.MAIN_DB_PREFIX.
'facture as f';
823if ($sortfield ==
"f.datef") {
824 $hasAnotherfilter =
false;
825 foreach ($search_array_options as $v) {
826 if ($v !==
'' && (
string) $v !==
'-1') {
827 $hasAnotherfilter =
true;
831 if (!$hasAnotherfilter) {
832 $sql .= $db->hintindex(
'idx_facture_datef');
835if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
836 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (f.rowid = ef.fk_object)";
838if (!empty($search_fac_rec_source_title)) {
839 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_rec as facrec ON f.fk_fac_rec_source = facrec.rowid';
841$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = f.fk_projet";
842$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user AS u ON f.fk_user_author = u.rowid';
844$parameters = array();
845$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
846$sql .= $hookmanager->resPrint;
848$sql .=
' WHERE f.fk_soc = s.rowid';
849$sql .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
851 $sql .=
' AND s.rowid = '.((int) $socid);
855 $sql .=
' AND f.fk_user_author IS NULL';
857 $sql .=
' AND f.fk_user_author = '.((int) $userid);
863if ($search_refcustomer) {
866if ($search_type !=
'' && $search_type !=
'-1') {
867 $sql .=
" AND f.type IN (".$db->sanitize($db->escape($search_type)).
")";
869if ($search_subtype !=
'' && $search_subtype !=
'-1') {
870 $sql .=
" AND f.subtype IN (".$db->sanitize($db->escape($search_subtype)).
")";
872if ($search_project_ref) {
875if ($search_project) {
878if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
879 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
881 if ($search_company) {
884 if ($search_company_alias) {
888if ($search_parent_name) {
891if ($search_customer_code) {
903if (strlen(trim($search_country))) {
905 $country_code_in_EEC = $country_code_in_EEC_without_me =
'';
906 foreach ($arrayofcode as $key => $value) {
907 $country_code_in_EEC .= ($country_code_in_EEC ?
"," :
"").
"'".$value.
"'";
908 if ($value !=
$mysoc->country_code) {
909 $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ?
"," :
"").
"'".$value.
"'";
912 if ($search_country ==
'special_allnotme') {
913 $sql .=
" AND country.code <> '".$db->escape(
$mysoc->country_code).
"'";
914 } elseif ($search_country ==
'special_eec') {
915 $sql .=
" AND country.code IN (".$db->sanitize($country_code_in_EEC, 1).
")";
916 } elseif ($search_country ==
'special_eecnotme') {
917 $sql .=
" AND country.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).
")";
918 } elseif ($search_country ==
'special_noteec') {
919 $sql .=
" AND country.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).
")";
924if ($search_type_thirdparty !=
'' && $search_type_thirdparty !=
'-1') {
925 $sql .=
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
927if ($search_montant_ht !=
'') {
930if ($search_montant_vat !=
'') {
933if ($search_montant_localtax1 !=
'') {
934 $sql .=
natural_search(
'f.localtax1', $search_montant_localtax1, 1);
936if ($search_montant_localtax2 !=
'') {
937 $sql .=
natural_search(
'f.localtax2', $search_montant_localtax2, 1);
939if ($search_montant_ttc !=
'') {
942if ($search_multicurrency_code !=
'') {
943 $sql .=
" AND f.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
945if ($search_multicurrency_tx !=
'') {
946 $sql .=
natural_search(
'f.multicurrency_tx', $search_multicurrency_tx, 1);
948if ($search_multicurrency_montant_ht !=
'') {
949 $sql .=
natural_search(
'f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
951if ($search_multicurrency_montant_vat !=
'') {
952 $sql .=
natural_search(
'f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
954if ($search_multicurrency_montant_ttc !=
'') {
955 $sql .=
natural_search(
'f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
958 $sql .=
natural_search(array(
'u.login',
'u.firstname',
'u.lastname'), $search_login);
960if ($search_dispute_status !=
'-1' && $search_dispute_status !=
'') {
961 if ($search_dispute_status ==
'0') {
962 $sql .=
" AND (f.dispute_status IS NULL OR f.dispute_status = 0)";
964 $sql .=
" AND f.dispute_status IN (".$db->sanitize($search_dispute_status).
")";
967if ($search_status !=
'-1' && $search_status !=
'') {
968 if (is_numeric($search_status) && $search_status >= 0) {
969 if ($search_status ==
'0') {
970 $sql .=
" AND f.fk_statut = 0";
972 if ($search_status ==
'1') {
973 $sql .=
" AND f.fk_statut = 1";
975 if ($search_status ==
'2') {
976 $sql .=
" AND f.fk_statut = 2";
978 if ($search_status ==
'3') {
979 $sql .=
" AND f.fk_statut = 3";
982 $sql .=
" AND f.fk_statut IN (".$db->sanitize($search_status).
")";
986if ($search_paymentmode > 0) {
987 $sql .=
" AND f.fk_mode_reglement = ".((int) $search_paymentmode);
989if ($search_paymentterms > 0) {
990 $sql .=
" AND f.fk_cond_reglement = ".((int) $search_paymentterms);
992if ($search_fk_input_reason > 0) {
993 $sql .=
" AND f.fk_input_reason = ".((int) $search_fk_input_reason);
995if ($search_module_source) {
998if ($search_pos_source) {
1001if ($search_date_start) {
1002 $sql .=
" AND f.datef >= '".$db->idate($search_date_start).
"'";
1004if ($search_date_end) {
1005 $sql .=
" AND f.datef <= '".$db->idate($search_date_end).
"'";
1007if ($search_date_valid_start) {
1008 $sql .=
" AND f.date_valid >= '".$db->idate($search_date_valid_start).
"'";
1010if ($search_date_valid_end) {
1011 $sql .=
" AND f.date_valid <= '".$db->idate($search_date_valid_end).
"'";
1013if ($search_datelimit_start) {
1014 $sql .=
" AND f.date_lim_reglement >= '".$db->idate($search_datelimit_start).
"'";
1016if ($search_datelimit_end) {
1017 $sql .=
" AND f.date_lim_reglement <= '".$db->idate($search_datelimit_end).
"'";
1019if ($search_note_public) {
1020 $sql .=
" AND p.note_public LIKE '%".$db->escape($db->escapeforlike($search_note_public)).
"%'";
1022if ($search_note_private) {
1023 $sql .=
" AND p.note_private LIKE '%".$db->escape($db->escapeforlike($search_note_private)).
"%'";
1025if ($search_datec_start) {
1026 $sql .=
" AND f.datec >= '".$db->idate($search_datec_start).
"'";
1028if ($search_datec_end) {
1029 $sql .=
" AND f.datec <= '".$db->idate($search_datec_end).
"'";
1031if ($search_datem_start) {
1032 $sql .=
" AND f.tms >= '".$db->idate($search_datem_start).
"'";
1034if ($search_datem_end) {
1035 $sql .=
" AND f.tms <= '".$db->idate($search_datem_end).
"'";
1037if ($search_option ==
'late') {
1038 $sql .=
" AND f.date_lim_reglement < '".$db->idate(
dol_now() - $conf->invoice->client->warning_delay).
"'";
1043if (!empty($search_fac_rec_source_title)) {
1044 $sql .=
natural_search(
'facrec.titre', $search_fac_rec_source_title);
1046if ($search_fk_fac_rec_source) {
1047 $sql .=
' AND f.fk_fac_rec_source = ' . (int) $search_fk_fac_rec_source;
1049if ($search_import_key) {
1053if ($search_user > 0) {
1054 $sql .=
" AND EXISTS (";
1055 $sql .=
" SELECT ec.fk_c_type_contact, ec.element_id, ec.fk_socpeople";
1056 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_contact as ec";
1057 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"c_type_contact as tc";
1058 $sql .=
" ON ec.fk_c_type_contact = tc.rowid AND tc.element = 'facture' AND tc.source = 'internal'";
1059 $sql .=
" WHERE ec.element_id = f.rowid AND ec.fk_socpeople = ".((int) $search_user).
")";
1062if ($search_sale && $search_sale !=
'-1') {
1063 if ($search_sale == -2) {
1064 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc)";
1065 } elseif ($search_sale > 0) {
1066 $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).
")";
1071if (!empty($searchCategoryInvoiceList)) {
1072 $searchCategoryInvoiceSqlList = array();
1073 $listofcategoryid =
'';
1074 foreach ($searchCategoryInvoiceList as $searchCategoryInvoice) {
1075 if (intval($searchCategoryInvoice) == -2) {
1076 $searchCategoryInvoiceSqlList[] =
"NOT EXISTS (SELECT ck.fk_invoice FROM ".MAIN_DB_PREFIX.
"categorie_invoice as ck WHERE f.rowid = ck.fk_invoice)";
1077 } elseif (intval($searchCategoryInvoice) > 0) {
1078 if ($searchCategoryInvoiceOperator == 0) {
1079 $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).
")";
1081 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryInvoice);
1085 if ($listofcategoryid) {
1086 $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).
"))";
1088 if ($searchCategoryInvoiceOperator == 1) {
1089 if (!empty($searchCategoryInvoiceSqlList)) {
1090 $sql .=
" AND (".implode(
' OR ', $searchCategoryInvoiceSqlList).
")";
1093 if (!empty($searchCategoryInvoiceSqlList)) {
1094 $sql .=
" AND (".implode(
' AND ', $searchCategoryInvoiceSqlList).
")";
1100$searchCategoryProductList = $search_product_category ? array($search_product_category) : array();
1101$searchCategoryProductOperator = 0;
1102if (!empty($searchCategoryProductList)) {
1103 $searchCategoryProductSqlList = array();
1104 $listofcategoryid =
'';
1105 foreach ($searchCategoryProductList as $searchCategoryProduct) {
1106 if (intval($searchCategoryProduct) == -2) {
1107 $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)";
1108 } elseif (intval($searchCategoryProduct) > 0) {
1109 if ($searchCategoryProductOperator == 0) {
1110 $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).
")";
1112 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
1116 if ($listofcategoryid) {
1117 $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).
"))";
1119 if ($searchCategoryProductOperator == 1) {
1120 if (!empty($searchCategoryProductSqlList)) {
1121 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
1124 if (!empty($searchCategoryProductSqlList)) {
1125 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
1129$searchCategoryCustomerList = $search_categ_cus ? array($search_categ_cus) : array();
1130$searchCategoryCustomerOperator = 0;
1132if (!empty($searchCategoryCustomerList)) {
1133 $searchCategoryCustomerSqlList = array();
1134 $listofcategoryid =
'';
1135 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
1136 if (intval($searchCategoryCustomer) == -2) {
1137 $searchCategoryCustomerSqlList[] =
"NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe as ck WHERE s.rowid = ck.fk_soc)";
1138 } elseif (intval($searchCategoryCustomer) > 0) {
1139 if ($searchCategoryCustomerOperator == 0) {
1140 $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).
")";
1142 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryCustomer);
1146 if ($listofcategoryid) {
1147 $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).
"))";
1149 if ($searchCategoryCustomerOperator == 1) {
1150 if (!empty($searchCategoryCustomerSqlList)) {
1151 $sql .=
" AND (".implode(
' OR ', $searchCategoryCustomerSqlList).
")";
1154 if (!empty($searchCategoryCustomerSqlList)) {
1155 $sql .=
" AND (".implode(
' AND ', $searchCategoryCustomerSqlList).
")";
1160include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
1162$parameters = array();
1163$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
1164$sql .= $hookmanager->resPrint;
1169 $fieldstosearchallwithoutpd = array();
1170 $fieldstosearchallwithpd = array();
1171 foreach ($fieldstosearchall as $key => $val) {
1172 if (!preg_match(
'/^pd\./', $key)) {
1173 $fieldstosearchallwithoutpd[$key] = $val;
1175 $fieldstosearchallwithpd[$key] = $val;
1179 if (count($fieldstosearchallwithpd) > 0) {
1180 $sqltoadd .=
" OR EXISTS (SELECT pd.rowid FROM ".MAIN_DB_PREFIX.
"facturedet as pd WHERE pd.fk_facture = f.rowid";
1181 $sqltoadd .=
natural_search(array_keys($fieldstosearchallwithpd),
'__KEYTOSEARCH__');
1185 $sql .=
natural_search(array_keys($fieldstosearchallwithoutpd), $search_all, 0, 0, $sqltoadd);
1188$parameters = array();
1189$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object, $action);
1190if (empty($reshook)) {
1191 $sql .= empty($hookmanager->resPrint) ?
"" :
" HAVING 1=1 ".$hookmanager->resPrint;
1193 $sql = $hookmanager->resPrint;
1197$nbtotalofrecords =
'';
1200 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
1201 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
1203 $resql = $db->query($sqlforcount);
1205 $objforcount = $db->fetch_object($resql);
1206 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1211 if (($page * $limit) > (
int) $nbtotalofrecords) {
1219$sql .= $db->order($sortfield, $sortorder);
1221 $sql .= $db->plimit($limit + 1, $offset);
1224$resql = $db->query($sql);
1230$num = $db->num_rows($resql);
1232$arrayofselected = is_array($toselect) ? $toselect : array();
1234if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
1235 $obj = $db->fetch_object($resql);
1238 header(
"Location: ".DOL_URL_ROOT.
'/compta/facture/card.php?id='.
$id);
1245llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist'.($contextpage ==
'poslist' ?
' '.$contextpage :
''));
1247if ($search_fk_fac_rec_source) {
1249 $object->fetch((
int) $search_fk_fac_rec_source);
1258 $param .=
'&mode='.urlencode($mode);
1260if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1261 $param .=
'&contextpage='.urlencode($contextpage);
1263if ($limit > 0 && $limit != $conf->liste_limit) {
1264 $param .=
'&limit='.((int) $limit);
1266if ($optioncss !=
'') {
1267 $param .=
'&optioncss='.urlencode($optioncss);
1270 $param .=
'&show_files='.urlencode((
string) ($show_files));
1273 $param .=
'&search_all='.urlencode($search_all);
1276 $param .=
'&socid='.((int) $socid);
1278if ($search_date_startday) {
1279 $param .=
'&search_date_startday='.urlencode((
string) ($search_date_startday));
1281if ($search_date_startmonth) {
1282 $param .=
'&search_date_startmonth='.urlencode((
string) ($search_date_startmonth));
1284if ($search_date_startyear) {
1285 $param .=
'&search_date_startyear='.urlencode((
string) ($search_date_startyear));
1287if ($search_date_endday) {
1288 $param .=
'&search_date_endday='.urlencode((
string) ($search_date_endday));
1290if ($search_date_endmonth) {
1291 $param .=
'&search_date_endmonth='.urlencode((
string) ($search_date_endmonth));
1293if ($search_date_endyear) {
1294 $param .=
'&search_date_endyear='.urlencode((
string) ($search_date_endyear));
1296if ($search_date_valid_startday) {
1297 $param .=
'&search_date_valid_startday='.urlencode((
string) ($search_date_valid_startday));
1299if ($search_date_valid_startmonth) {
1300 $param .=
'&search_date_valid_startmonth='.urlencode((
string) ($search_date_valid_startmonth));
1302if ($search_date_valid_startyear) {
1303 $param .=
'&search_date_valid_startyear='.urlencode((
string) ($search_date_valid_startyear));
1305if ($search_date_valid_endday) {
1306 $param .=
'&search_date_valid_endday='.urlencode((
string) ($search_date_valid_endday));
1308if ($search_date_valid_endmonth) {
1309 $param .=
'&search_date_valid_endmonth='.urlencode((
string) ($search_date_valid_endmonth));
1311if ($search_date_valid_endyear) {
1312 $param .=
'&search_date_valid_endyear='.urlencode((
string) ($search_date_valid_endyear));
1314if ($search_datelimit_startday) {
1315 $param .=
'&search_datelimit_startday='.urlencode((
string) ($search_datelimit_startday));
1317if ($search_datelimit_startmonth) {
1318 $param .=
'&search_datelimit_startmonth='.urlencode((
string) ($search_datelimit_startmonth));
1320if ($search_datelimit_startyear) {
1321 $param .=
'&search_datelimit_startyear='.urlencode((
string) ($search_datelimit_startyear));
1323if ($search_datelimit_endday) {
1324 $param .=
'&search_datelimit_endday='.urlencode((
string) ($search_datelimit_endday));
1326if ($search_datelimit_endmonth) {
1327 $param .=
'&search_datelimit_endmonth='.urlencode((
string) ($search_datelimit_endmonth));
1329if ($search_datelimit_endyear) {
1330 $param .=
'&search_datelimit_endyear='.urlencode((
string) ($search_datelimit_endyear));
1333 $param .=
'&search_ref='.urlencode($search_ref);
1335if ($search_refcustomer) {
1336 $param .=
'&search_refcustomer='.urlencode($search_refcustomer);
1338if ($search_project_ref) {
1339 $param .=
'&search_project_ref='.urlencode($search_project_ref);
1341if ($search_project) {
1342 $param .=
'&search_project='.urlencode($search_project);
1344if ($search_type !=
'') {
1345 $param .=
'&search_type='.urlencode($search_type);
1347if ($search_subtype !=
'') {
1348 $param .=
'&search_subtype='.urlencode($search_subtype);
1350if ($search_company) {
1351 $param .=
'&search_company='.urlencode($search_company);
1353if ($search_company_alias) {
1354 $param .=
'&search_company_alias='.urlencode($search_company_alias);
1356if ($search_parent_name !=
'') {
1357 $param .=
'&search_parent_name='.urlencode($search_parent_name);
1360 $param .=
'&search_town='.urlencode($search_town);
1363 $param .=
'&search_zip='.urlencode($search_zip);
1365if ($search_country) {
1366 $param .=
"&search_country=".urlencode($search_country);
1368if ($search_type_thirdparty !=
'') {
1369 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
1371if ($search_customer_code) {
1372 $param .=
'&search_customer_code='.urlencode($search_customer_code);
1374if ($search_sale > 0) {
1375 $param .=
'&search_sale='.urlencode((
string) $search_sale);
1377if ($search_user > 0) {
1378 $param .=
'&search_user='.urlencode((
string) $search_user);
1381 $param .=
'&search_login='.urlencode($search_login);
1383if ($searchCategoryInvoiceOperator == 1) {
1384 $param .=
"&search_category_invoice_operator=".urlencode((
string) ($searchCategoryInvoiceOperator));
1386foreach ($searchCategoryInvoiceList as $searchCategoryInvoice) {
1387 $param .=
"&search_category_invoice_list[]=".urlencode($searchCategoryInvoice);
1389if ($search_product_category > 0) {
1390 $param .=
'&search_product_category='.urlencode((
string) $search_product_category);
1392if ($search_montant_ht !=
'') {
1393 $param .=
'&search_montant_ht='.urlencode($search_montant_ht);
1395if ($search_montant_vat !=
'') {
1396 $param .=
'&search_montant_vat='.urlencode($search_montant_vat);
1398if ($search_montant_localtax1 !=
'') {
1399 $param .=
'&search_montant_localtax1='.urlencode($search_montant_localtax1);
1401if ($search_montant_localtax2 !=
'') {
1402 $param .=
'&search_montant_localtax2='.urlencode($search_montant_localtax2);
1404if ($search_montant_ttc !=
'') {
1405 $param .=
'&search_montant_ttc='.urlencode($search_montant_ttc);
1407if ($search_multicurrency_code !=
'') {
1408 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1410if ($search_multicurrency_tx !=
'') {
1411 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1413if ($search_multicurrency_montant_ht !=
'') {
1414 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1416if ($search_multicurrency_montant_vat !=
'') {
1417 $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
1419if ($search_multicurrency_montant_ttc !=
'') {
1420 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1422if ($search_dispute_status !=
'') {
1423 $param .=
'&search_dispute_status='.urlencode($search_dispute_status);
1425if ($search_status !=
'') {
1426 $param .=
'&search_status='.urlencode($search_status);
1428if ($search_paymentmode > 0) {
1429 $param .=
'&search_paymentmode='.urlencode((
string) ($search_paymentmode));
1431if ($search_paymentterms > 0) {
1432 $param .=
'&search_paymentterms='.urlencode((
string) ($search_paymentterms));
1434if ($search_fk_input_reason > 0) {
1435 $param .=
'&search_fk_input_reason='.urlencode((
string) $search_fk_input_reason);
1437if ($search_module_source) {
1438 $param .=
'&search_module_source='.urlencode($search_module_source);
1440if ($search_pos_source) {
1441 $param .=
'&search_pos_source='.urlencode($search_pos_source);
1443if ($search_option) {
1444 $param .=
"&search_option=".urlencode($search_option);
1446if ($search_categ_cus > 0) {
1447 $param .=
'&search_categ_cus='.urlencode((
string) ($search_categ_cus));
1449if (!empty($search_fac_rec_source_title)) {
1450 $param .=
'&search_fac_rec_source_title='.urlencode($search_fac_rec_source_title);
1452if ($search_fk_fac_rec_source) {
1453 $param .=
'&search_fk_fac_rec_source=' . (int) $search_fk_fac_rec_source;
1455if ($search_import_key !=
'') {
1456 $param .=
'&search_import_key='.urlencode($search_import_key);
1460include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1462$parameters = array(
'param' => &$param);
1463$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1464$param .= $hookmanager->resPrint;
1466$arrayofmassactions = array(
1467 'validate' =>
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate"),
1468 'generate_doc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1469 'builddoc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1470 'presend' =>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
1473if (
isModEnabled(
'category') && $user->hasRight(
'facture',
'creer')) {
1474 $arrayofmassactions[
'preaffecttag'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"AffectTag");
1476if ($user->hasRight(
'facture',
'paiement')) {
1477 $arrayofmassactions[
'makepayment'] =
img_picto(
'',
'payment',
'class="pictofixedwidth"').$langs->trans(
"MakePaymentAndClassifyPayed");
1479if (
isModEnabled(
'prelevement') && $user->hasRight(
'prelevement',
'bons',
'creer')) {
1480 $langs->load(
"withdrawals");
1481 $arrayofmassactions[
'withdrawrequest'] =
img_picto(
'',
'payment',
'class="pictofixedwidth"').$langs->trans(
"MakeWithdrawRequest");
1483if ($user->hasRight(
'facture',
'supprimer')) {
1485 $arrayofmassactions[
'predeletedraft'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Deletedraft");
1488if (in_array($massaction, array(
'presend',
'predelete',
'makepayment'))) {
1489 $arrayofmassactions = array();
1491$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1495if ($contextpage !=
'poslist') {
1496 $url = DOL_URL_ROOT.
'/compta/facture/card.php?action=create';
1498 $url .=
'&socid='.urlencode((
string)
$object->socid);
1501 $url .=
'&fac_rec='.urlencode((
string)
$object->id);
1503 $newcardbutton =
'';
1504 $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'));
1505 $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'));
1507 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewBill'),
'',
'fa fa-plus-circle', $url,
'', $user->hasRight(
"facture",
"creer"));
1512print
'<form method="POST" id="searchFormList" name="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
1513if ($optioncss !=
'') {
1514 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1516print
'<input type="hidden" name="token" value="'.newToken().
'">';
1517print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1518if (!in_array($massaction, array(
'makepayment'))) {
1519 print
'<input type="hidden" name="action" value="list">';
1521print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1522print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1523print
'<input type="hidden" name="search_status" value="'.$search_status.
'">';
1524print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1525print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1526print
'<input type="hidden" name="mode" value="'.$mode.
'">';
1528print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'bill', 0, $newcardbutton,
'', $limit, 0, 0, 1);
1530$topicmail =
"SendBillRef";
1531$modelmail =
"facture_send";
1533$trackid =
'inv'.$object->id;
1534include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1536if ($massaction ==
'makepayment') {
1538 $formquestion = array(
1542 array(
'type' =>
'date',
'name' =>
'datepaiment',
'label' => $langs->trans(
"Date"),
'datenow' => 1),
1543 array(
'type' =>
'other',
'name' =>
'paiementid',
'label' => $langs->trans(
"PaymentMode"),
'value' => $form->select_types_paiements(
GETPOST(
'search_paymentmode'),
'paiementid',
'', 0, 0, 1, 0, 1,
'', 1)),
1544 array(
'type' =>
'other',
'name' =>
'bankid',
'label' => $langs->trans(
"BankAccount"),
'value' => $form->select_comptes(
'',
'bankid', 0,
'', 0,
'', 0,
'', 1)),
1547 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
'MakePaymentAndClassifyPayed'), $langs->trans(
'EnterPaymentReceivedFromCustomer'),
'makepayment_confirm', $formquestion, 1, 0, 200, 500, 1);
1552 foreach ($fieldstosearchall as $key => $val) {
1553 $fieldstosearchall[$key] = $langs->trans($val);
1555 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>';
1561if (
isModEnabled(
'category') && $user->hasRight(
'categorie',
'read')) {
1563 $moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_INVOICE, $searchCategoryInvoiceList,
'minwidth300', $searchCategoryInvoiceOperator ? $searchCategoryInvoiceOperator : 0);
1566if ($user->hasRight(
"user",
"user",
"lire")) {
1567 $langs->load(
"commercial");
1568 $moreforfilter .=
'<div class="divsearchfield">';
1569 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1570 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth200');
1571 $moreforfilter .=
'</div>';
1574if ($user->hasRight(
"user",
"user",
"lire")) {
1575 $moreforfilter .=
'<div class="divsearchfield">';
1576 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1577 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
null, 0,
'',
'',
'0', 0, 0,
'', 0,
'',
'maxwidth200');
1578 $moreforfilter .=
'</div>';
1581if (
isModEnabled(
'category') && $user->hasRight(
"categorie",
"lire") && ($user->hasRight(
"produit",
"lire") || $user->hasRight(
"service",
"lire"))) {
1582 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1583 $moreforfilter .=
'<div class="divsearchfield">';
1584 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1585 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 0, 0, 1);
1586 $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);
1587 $moreforfilter .=
'</div>';
1589if (
isModEnabled(
'category') && $user->hasRight(
"categorie",
"lire")) {
1590 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1591 $moreforfilter .=
'<div class="divsearchfield">';
1592 $tmptitle = $langs->trans(
'CustomersProspectsCategoriesShort');
1593 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$formother->select_categories(
'customer', $search_categ_cus,
'search_categ_cus', 1, $tmptitle);
1594 $moreforfilter .=
'</div>';
1597$moreforfilter .=
'<div class="divsearchfield">';
1598$moreforfilter .=
'<label for="search_option">'.$langs->trans(
'Alert').
' </label><input type="checkbox" name="search_option" id="search_option" value="late"'.($search_option ==
'late' ?
' checked' :
'').
'>';
1599$moreforfilter .=
'</div>';
1601$parameters = array();
1602$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1603if (empty($reshook)) {
1604 $moreforfilter .= $hookmanager->resPrint;
1606 $moreforfilter = $hookmanager->resPrint;
1609if (!empty($moreforfilter)) {
1610 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1611 print $moreforfilter;
1615$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1616$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1619if ($massactionbutton && $contextpage !=
'poslist') {
1620 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
1623print
'<div class="div-table-responsive">';
1624print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1628print
'<tr class="liste_titre_filter">';
1632 print
'<td class="liste_titre center maxwidthsearch actioncolumn">';
1633 $searchpicto = $form->showFilterButtons(
'left');
1639 print
'<td class="liste_titre">';
1643if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1644 print
'<td class="liste_titre">';
1645 print
'<input class="flat maxwidth75imp" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1649if (!empty($arrayfields[
'f.ref_client'][
'checked'])) {
1650 print
'<td class="liste_titre">';
1651 print
'<input class="flat maxwidth50imp" type="text" name="search_refcustomer" value="'.dol_escape_htmltag($search_refcustomer).
'">';
1655if (!empty($arrayfields[
'f.type'][
'checked'])) {
1656 print
'<td class="liste_titre maxwidthonsmartphone">';
1668 print $form->selectarray(
'search_type', $listtype, $search_type, 1, 0, 0,
'', 0, 0, 0,
'',
'maxwidth75');
1672if (!empty($arrayfields[
'f.subtype'][
'checked'])) {
1673 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1674 print $form->selectarray(
'search_subtype', $subtypearray, $search_subtype, 1, 0, 0,
'', 0, 0, 0,
'',
'maxwidth100');
1678if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1679 print
'<td class="liste_titre center">';
1680 print
'<div class="nowrapfordate">';
1681 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1683 print
'<div class="nowrapfordate">';
1684 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1689if (!empty($arrayfields[
'f.date_valid'][
'checked'])) {
1690 print
'<td class="liste_titre center">';
1691 print
'<div class="nowrapfordate">';
1692 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'));
1694 print
'<div class="nowrapfordate">';
1695 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'));
1700if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1701 print
'<td class="liste_titre center">';
1702 print
'<div class="nowrapfordate">';
1703 print $form->selectDate($search_datelimit_start ? $search_datelimit_start : -1,
'search_datelimit_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1705 print
'<div class="nowrapfordate">';
1706 print $form->selectDate($search_datelimit_end ? $search_datelimit_end : -1,
'search_datelimit_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1711if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1712 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).
'"></td>';
1715if (!empty($arrayfields[
'p.title'][
'checked'])) {
1716 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_project" value="'.dol_escape_htmltag($search_project).
'"></td>';
1719if (!empty($arrayfields[
's.nom'][
'checked'])) {
1720 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>';
1723if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1724 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).
'"></td>';
1727if (!empty($arrayfields[
's2.nom'][
'checked'])) {
1728 print
'<td class="liste_titre">';
1729 print
'<input class="flat maxwidth100" type="text" name="search_parent_name" value="'.dol_escape_htmltag($search_parent_name).
'">';
1733if (!empty($arrayfields[
's.code_client'][
'checked'])) {
1734 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_customer_code" value="'.dol_escape_htmltag($search_customer_code).
'"></td>';
1737if (!empty($arrayfields[
's.town'][
'checked'])) {
1738 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
1741if (!empty($arrayfields[
's.zip'][
'checked'])) {
1742 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
1745if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1746 print
'<td class="liste_titre">';
1747 print
'<input class="flat maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1751if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1752 print
'<td class="liste_titre center">';
1753 print $form->select_country($search_country,
'search_country',
'', 0,
'minwidth150imp maxwidth150',
'code2', 1, 0, 1, array(), 1);
1757if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1758 print
'<td class="liste_titre maxwidthonsmartphone center">';
1759 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);
1763if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1764 print
'<td class="liste_titre">';
1765 print $form->select_types_paiements($search_paymentmode,
'search_paymentmode',
'', 0, 1, 1, 0, 1,
'minwidth100 maxwidth100', 1);
1769if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1770 print
'<td class="liste_titre left">';
1771 print $form->getSelectConditionsPaiements((
int) $search_paymentterms,
'search_paymentterms', -1, 1, 1,
'minwidth100 maxwidth100');
1775if (!empty($arrayfields[
'f.fk_input_reason'][
'checked'])) {
1776 print
'<td class="liste_titre">';
1777 $form->selectInputReason($search_fk_input_reason,
'search_fk_input_reason',
'', 1,
'', 1);
1781if (!empty($arrayfields[
'f.module_source'][
'checked'])) {
1782 print
'<td class="liste_titre">';
1783 print
'<input class="flat maxwidth75" type="text" name="search_module_source" value="'.dol_escape_htmltag($search_module_source).
'">';
1787if (!empty($arrayfields[
'f.pos_source'][
'checked'])) {
1788 print
'<td class="liste_titre">';
1789 print
'<input class="flat maxwidth50" type="text" name="search_pos_source" value="'.dol_escape_htmltag($search_pos_source).
'">';
1792if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1794 print
'<td class="liste_titre right">';
1795 print
'<input class="flat" type="text" size="4" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).
'">';
1798if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
1800 print
'<td class="liste_titre right">';
1801 print
'<input class="flat" type="text" size="4" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).
'">';
1804if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1806 print
'<td class="liste_titre right">';
1807 print
'<input class="flat" type="text" size="4" name="search_montant_localtax1" value="'.dol_escape_htmltag($search_montant_localtax1).
'">';
1810if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1812 print
'<td class="liste_titre right">';
1813 print
'<input class="flat" type="text" size="4" name="search_montant_localtax2" value="'.dol_escape_htmltag($search_montant_localtax2).
'">';
1816if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1818 print
'<td class="liste_titre right">';
1819 print
'<input class="flat" type="text" size="4" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).
'">';
1822if (!empty($arrayfields[
'u.login'][
'checked'])) {
1824 print
'<td class="liste_titre" align="center">';
1825 print
'<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).
'">';
1828if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1829 print
'<td class="liste_titre"></td>';
1831if (!empty($arrayfields[
'f.retained_warranty'][
'checked'])) {
1832 print
'<td class="liste_titre" align="right">';
1835if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1836 print
'<td class="liste_titre right">';
1839if (!empty($arrayfields[
'rtp'][
'checked'])) {
1840 print
'<td class="liste_titre">';
1843if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1845 print
'<td class="liste_titre">';
1846 print $form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1849if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1851 print
'<td class="liste_titre">';
1852 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1855if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1857 print
'<td class="liste_titre right">';
1858 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1861if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1863 print
'<td class="liste_titre right">';
1864 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).
'">';
1867if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1869 print
'<td class="liste_titre right">';
1870 print
'<input class="flat width75" type="text" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1873if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1874 print
'<td class="liste_titre">';
1877if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1878 print
'<td class="liste_titre right">';
1881if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1882 print
'<td class="liste_titre right">';
1885if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1886 print
'<td class="liste_titre right">';
1889if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1890 print
'<td class="liste_titre right">';
1893if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1894 print
'<td class="liste_titre right">';
1899include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1902$parameters = array(
'arrayfields' => $arrayfields);
1903$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1904print $hookmanager->resPrint;
1906if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1907 print
'<td class="liste_titre center">';
1908 print
'<div class="nowrapfordate">';
1909 print $form->selectDate($search_datec_start ? $search_datec_start : -1,
'search_datec_start', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'),
'tzuserrel');
1911 print
'<div class="nowrapfordate">';
1912 print $form->selectDate($search_datec_end ? $search_datec_end : -1,
'search_datec_end', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'),
'tzuserrel');
1917if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1918 print
'<td class="liste_titre center">';
1919 print
'<div class="nowrapfordate">';
1920 print $form->selectDate($search_datem_start ? $search_datem_start : -1,
'search_datem_start', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'),
'tzuserrel');
1922 print
'<div class="nowrapfordate">';
1923 print $form->selectDate($search_datem_end ? $search_datem_end : -1,
'search_datem_end', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'),
'tzuserrel');
1928if (!empty($arrayfields[
'f.date_closing'][
'checked'])) {
1929 print
'<td class="liste_titre">';
1932if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
1934 print
'<td class="liste_titre">';
1935 print
'<input class="flat maxwidth75" type="text" name="search_note_public" value="'.dol_escape_htmltag($search_note_public).
'">';
1938if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
1940 print
'<td class="liste_titre">';
1941 print
'<input class="flat maxwidth75" type="text" name="search_note_private" value="'.dol_escape_htmltag($search_note_private).
'">';
1944if (!empty($arrayfields[
'f.fk_fac_rec_source'][
'checked'])) {
1946 print
'<td class="liste_titre maxwidthonsmartphone right">';
1947 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).
'">';
1951if (!empty($arrayfields[
'f.import_key'][
'checked'])) {
1952 print
'<td class="liste_titre maxwidthonsmartphone center">';
1953 print
'<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).
'">';
1957if (!empty($arrayfields[
'f.dispute_status'][
'checked'])) {
1958 print
'<td class="liste_titre center parentonrightofpage">';
1959 $liststatus = array(
'0' =>
"None",
'1' =>
"DisputeOpen",
'8' =>
"DisputeLost",
'9' =>
"DisputeWon");
1961 print $form->selectarray(
'search_dispute_status', $liststatus, $search_dispute_status, 1, 0, 0,
'', 1, 0, 0,
'',
'search_status width100 onrightofpage', 1);
1965if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1966 print
'<td class="liste_titre center parentonrightofpage">';
1967 $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"));
1969 print $form->selectarray(
'search_status', $liststatus, $search_status, 1, 0, 0,
'', 0, 0, 0,
'',
'search_status width100 onrightofpage', 1);
1974 print
'<td class="liste_titre center maxwidthsearch actioncolumn">';
1975 $searchpicto = $form->showFilterButtons();
1986print
'<tr class="liste_titre">';
1988 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
1995if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1996 print_liste_field_titre($arrayfields[
'f.ref'][
'label'], $_SERVER[
'PHP_SELF'],
'f.ref',
'', $param,
'', $sortfield, $sortorder);
1999if (!empty($arrayfields[
'f.ref_client'][
'checked'])) {
2000 print_liste_field_titre($arrayfields[
'f.ref_client'][
'label'], $_SERVER[
"PHP_SELF"],
'f.ref_client',
'', $param,
'', $sortfield, $sortorder);
2003if (!empty($arrayfields[
'f.type'][
'checked'])) {
2004 print_liste_field_titre($arrayfields[
'f.type'][
'label'], $_SERVER[
"PHP_SELF"],
'f.type',
'', $param,
'', $sortfield, $sortorder);
2007if (!empty($arrayfields[
'f.subtype'][
'checked'])) {
2008 print_liste_field_titre($arrayfields[
'f.subtype'][
'label'], $_SERVER[
"PHP_SELF"],
'f.subtype',
'', $param,
'', $sortfield, $sortorder);
2010if (!empty($arrayfields[
'f.datef'][
'checked'])) {
2011 print_liste_field_titre($arrayfields[
'f.datef'][
'label'], $_SERVER[
'PHP_SELF'],
'f.datef',
'', $param,
'', $sortfield, $sortorder,
'center ');
2014if (!empty($arrayfields[
'f.date_valid'][
'checked'])) {
2015 print_liste_field_titre($arrayfields[
'f.date_valid'][
'label'], $_SERVER[
'PHP_SELF'],
'f.date_valid',
'', $param,
'', $sortfield, $sortorder,
'center ');
2018if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
2019 print_liste_field_titre($arrayfields[
'f.date_lim_reglement'][
'label'], $_SERVER[
'PHP_SELF'],
"f.date_lim_reglement",
'', $param,
'', $sortfield, $sortorder,
'center ');
2022if (!empty($arrayfields[
'p.ref'][
'checked'])) {
2023 $langs->load(
"projects");
2024 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
'PHP_SELF'],
"p.ref",
'', $param,
'', $sortfield, $sortorder);
2027if (!empty($arrayfields[
'p.title'][
'checked'])) {
2028 print_liste_field_titre($arrayfields[
'p.title'][
'label'], $_SERVER[
'PHP_SELF'],
"p.title",
'', $param,
'', $sortfield, $sortorder);
2031if (!empty($arrayfields[
's.nom'][
'checked'])) {
2032 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
'PHP_SELF'],
's.nom',
'', $param,
'', $sortfield, $sortorder);
2035if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2037 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
2040if (!empty($arrayfields[
's2.nom'][
'checked'])) {
2041 print_liste_field_titre($arrayfields[
's2.nom'][
'label'], $_SERVER[
'PHP_SELF'],
's2.nom',
'', $param,
'', $sortfield, $sortorder);
2044if (!empty($arrayfields[
's.code_client'][
'checked'])) {
2045 print_liste_field_titre($arrayfields[
's.code_client'][
'label'], $_SERVER[
'PHP_SELF'],
's.code_client',
'', $param,
'', $sortfield, $sortorder);
2048if (!empty($arrayfields[
's.town'][
'checked'])) {
2049 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
2052if (!empty($arrayfields[
's.zip'][
'checked'])) {
2053 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
2056if (!empty($arrayfields[
'state.nom'][
'checked'])) {
2057 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
2060if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
2061 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
2064if (!empty($arrayfields[
'typent.code'][
'checked'])) {
2065 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
2068if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
2069 print_liste_field_titre($arrayfields[
'f.fk_mode_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_mode_reglement",
"", $param,
"", $sortfield, $sortorder);
2072if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
2073 print_liste_field_titre($arrayfields[
'f.fk_cond_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_cond_reglement",
"", $param,
"", $sortfield, $sortorder);
2076if (!empty($arrayfields[
'f.fk_input_reason'][
'checked'])) {
2077 print_liste_field_titre($arrayfields[
'f.fk_input_reason'][
'label'], $_SERVER[
'PHP_SELF'],
'f.fk_input_reason',
'', $param,
'', $sortfield, $sortorder);
2079if (!empty($arrayfields[
'f.module_source'][
'checked'])) {
2080 print_liste_field_titre($arrayfields[
'f.module_source'][
'label'], $_SERVER[
"PHP_SELF"],
"f.module_source",
"", $param,
"", $sortfield, $sortorder);
2083if (!empty($arrayfields[
'f.pos_source'][
'checked'])) {
2084 print_liste_field_titre($arrayfields[
'f.pos_source'][
'label'], $_SERVER[
"PHP_SELF"],
"f.pos_source",
"", $param,
"", $sortfield, $sortorder);
2087if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
2088 print_liste_field_titre($arrayfields[
'f.total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ht',
'', $param,
'', $sortfield, $sortorder,
'right ');
2091if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
2092 print_liste_field_titre($arrayfields[
'f.total_tva'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_tva',
'', $param,
'', $sortfield, $sortorder,
'right ');
2095if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
2096 print_liste_field_titre($arrayfields[
'f.total_localtax1'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax1',
'', $param,
'', $sortfield, $sortorder,
'right ');
2099if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
2100 print_liste_field_titre($arrayfields[
'f.total_localtax2'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax2',
'', $param,
'', $sortfield, $sortorder,
'right ');
2103if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
2104 print_liste_field_titre($arrayfields[
'f.total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ttc',
'', $param,
'', $sortfield, $sortorder,
'right ');
2107if (!empty($arrayfields[
'u.login'][
'checked'])) {
2108 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
'u.login',
'', $param,
'', $sortfield, $sortorder,
'center ');
2111if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
2112 print_liste_field_titre($arrayfields[
'sale_representative'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"",
"$param",
'', $sortfield, $sortorder);
2115if (!empty($arrayfields[
'f.retained_warranty'][
'checked'])) {
2116 print_liste_field_titre($arrayfields[
'f.retained_warranty'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2119if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
2120 print_liste_field_titre($arrayfields[
'dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2123if (!empty($arrayfields[
'rtp'][
'checked'])) {
2124 print_liste_field_titre($arrayfields[
'rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2127if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
2128 print_liste_field_titre($arrayfields[
'f.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
2131if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
2132 print_liste_field_titre($arrayfields[
'f.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
2135if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
2136 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ht',
'', $param,
'', $sortfield, $sortorder,
'right ');
2139if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
2140 print_liste_field_titre($arrayfields[
'f.multicurrency_total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_tva',
'', $param,
'', $sortfield, $sortorder,
'right ');
2143if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
2144 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ttc',
'', $param,
'', $sortfield, $sortorder,
'right ');
2147if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
2148 print_liste_field_titre($arrayfields[
'multicurrency_dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2151if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
2152 print_liste_field_titre($arrayfields[
'multicurrency_rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2155if (!empty($arrayfields[
'total_pa'][
'checked'])) {
2156 print_liste_field_titre($arrayfields[
'total_pa'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2159if (!empty($arrayfields[
'total_margin'][
'checked'])) {
2160 print_liste_field_titre($arrayfields[
'total_margin'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2163if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
2164 print_liste_field_titre($arrayfields[
'total_margin_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2167if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
2168 print_liste_field_titre($arrayfields[
'total_mark_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
2172include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
2174$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &$totalarray);
2175$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
2176print $hookmanager->resPrint;
2177if (!empty($arrayfields[
'f.datec'][
'checked'])) {
2178 print_liste_field_titre($arrayfields[
'f.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"f.datec",
"", $param,
'', $sortfield, $sortorder,
'nowraponall center ');
2181if (!empty($arrayfields[
'f.tms'][
'checked'])) {
2182 print_liste_field_titre($arrayfields[
'f.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"f.tms",
"", $param,
'', $sortfield, $sortorder,
'nowraponall center ');
2185if (!empty($arrayfields[
'f.date_closing'][
'checked'])) {
2186 print_liste_field_titre($arrayfields[
'f.date_closing'][
'label'], $_SERVER[
"PHP_SELF"],
"f.date_closing",
"", $param,
'', $sortfield, $sortorder,
'nowraponall center ');
2189if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
2190 print_liste_field_titre($arrayfields[
'f.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"f.note_public",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
2193if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
2194 print_liste_field_titre($arrayfields[
'f.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"f.note_private",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
2197if (!empty($arrayfields[
'f.fk_fac_rec_source'][
'checked'])) {
2198 print_liste_field_titre($arrayfields[
'f.fk_fac_rec_source'][
'label'], $_SERVER[
"PHP_SELF"],
"facrec.titre",
"", $param,
'', $sortfield, $sortorder);
2202if (!empty($arrayfields[
'f.import_key'][
'checked'])) {
2203 print_liste_field_titre($arrayfields[
'f.import_key'][
'label'], $_SERVER[
"PHP_SELF"],
"f.import_key",
"", $param,
'', $sortfield, $sortorder,
'center ');
2207if (!empty($arrayfields[
'f.dispute_status'][
'checked'])) {
2208 print_liste_field_titre($arrayfields[
'f.dispute_status'][
'label'], $_SERVER[
"PHP_SELF"],
"f.dispute_status,f.ref",
"", $param,
'', $sortfield, $sortorder,
'center ');
2212if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
2213 print_liste_field_titre($arrayfields[
'f.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_statut,f.paye,f.type",
"", $param,
'', $sortfield, $sortorder,
'center ');
2218 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'', $param,
'', $sortfield, $sortorder,
'maxwidthsearch center ');
2224$projectstatic =
new Project($db);
2226$userstatic =
new User($db);
2244 $typenArray = $formcompany->typent_array(1);
2246 $with_margin_info =
false;
2248 !empty($arrayfields[
'total_pa'][
'checked'])
2249 || !empty($arrayfields[
'total_margin'][
'checked'])
2250 || !empty($arrayfields[
'total_margin_rate'][
'checked'])
2251 || !empty($arrayfields[
'total_mark_rate'][
'checked'])
2254 $with_margin_info =
true;
2259 $imaxinloop = ($limit ? min($num, $limit) : $num);
2260 while ($i < $imaxinloop) {
2261 $obj = $db->fetch_object($resql);
2263 $datelimit = $db->jdate($obj->datelimite);
2265 $facturestatic->id = $obj->id;
2266 $facturestatic->ref = $obj->ref;
2267 $facturestatic->ref_client = $obj->ref_client;
2268 $facturestatic->ref_customer = $obj->ref_client;
2269 $facturestatic->type = $obj->type;
2270 $facturestatic->subtype = $obj->subtype;
2271 $facturestatic->total_ht = $obj->total_ht;
2272 $facturestatic->total_tva = $obj->total_tva;
2273 $facturestatic->total_ttc = $obj->total_ttc;
2274 $facturestatic->multicurrency_code = $obj->multicurrency_code;
2275 $facturestatic->multicurrency_tx = $obj->multicurrency_tx;
2276 $facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht;
2277 $facturestatic->multicurrency_total_tva = $obj->multicurrency_total_vat;
2278 $facturestatic->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
2279 $facturestatic->status = $obj->status;
2280 $facturestatic->close_code = $obj->close_code;
2281 $facturestatic->total_ttc = $obj->total_ttc;
2282 $facturestatic->paye = $obj->paye;
2283 $facturestatic->socid = $obj->fk_soc;
2285 $facturestatic->date = $db->jdate($obj->datef);
2286 $facturestatic->date_validation = $db->jdate($obj->date_valid);
2287 $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite);
2289 $facturestatic->note_public = $obj->note_public;
2290 $facturestatic->note_private = $obj->note_private;
2293 $facturestatic->retained_warranty = $obj->retained_warranty;
2294 $facturestatic->retained_warranty_date_limit = $obj->retained_warranty_date_limit;
2295 $facturestatic->situation_final = $obj->retained_warranty_date_limit;
2296 $facturestatic->situation_final = $obj->retained_warranty_date_limit;
2297 $facturestatic->situation_cycle_ref = $obj->situation_cycle_ref;
2298 $facturestatic->situation_counter = $obj->situation_counter;
2301 $facturestatic->payment_reference = $obj->payment_reference;
2302 $facturestatic->dispute_status = $obj->dispute_status;
2304 $companystatic->id = $obj->socid;
2305 $companystatic->name = $obj->name;
2306 $companystatic->name_alias = $obj->alias;
2307 $companystatic->client = $obj->client;
2308 $companystatic->fournisseur = $obj->fournisseur;
2309 $companystatic->code_client = $obj->code_client;
2310 $companystatic->code_compta_client = $obj->code_compta_client;
2311 $companystatic->code_fournisseur = $obj->code_fournisseur;
2312 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
2313 $companystatic->email = $obj->email;
2314 $companystatic->phone = $obj->phone;
2315 $companystatic->fax = $obj->fax;
2316 $companystatic->address = $obj->address;
2317 $companystatic->zip = $obj->zip;
2318 $companystatic->town = $obj->town;
2319 $companystatic->country_code = $obj->country_code;
2321 $projectstatic->id = $obj->project_id;
2322 $projectstatic->ref = $obj->project_ref;
2323 $projectstatic->title = $obj->project_label;
2325 $paiement = $facturestatic->getSommePaiement();
2326 $totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
2327 $totaldeposits = $facturestatic->getSumDepositsUsed();
2328 $totalallpayments = $paiement + $totalcreditnotes + $totaldeposits;
2329 $remaintopay = $obj->total_ttc - $totalallpayments;
2331 $multicurrency_paiement = $facturestatic->getSommePaiement(1);
2332 $multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
2333 $multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
2335 $totalallpayments = $paiement + $totalcreditnotes + $totaldeposits;
2336 $remaintopay =
price2num($facturestatic->total_ttc - $totalallpayments);
2338 $multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
2339 $multicurrency_remaintopay = (float)
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);
2343 $multicurrency_remaintopay = 0;
2346 $remaincreditnote = $discount->getAvailableDiscounts($companystatic,
null,
'rc.fk_facture_source='.$facturestatic->id);
2347 $remaintopay = -$remaincreditnote;
2348 $totalallpayments =
price2num($facturestatic->total_ttc - $remaintopay);
2349 $multicurrency_remaincreditnote = $discount->getAvailableDiscounts($companystatic,
null,
'rc.fk_facture_source='.$facturestatic->id, 0, 0, 1);
2350 $multicurrency_remaintopay = -$multicurrency_remaincreditnote;
2351 $multicurrency_totalpay = (float)
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_remaintopay);
2354 $facturestatic->alreadypaid = $paiement;
2355 $facturestatic->totalpaid = $paiement;
2356 $facturestatic->totalcreditnotes = $totalcreditnotes;
2357 $facturestatic->totaldeposits = $totaldeposits;
2359 $marginInfo = array();
2360 if ($with_margin_info) {
2361 $facturestatic->fetch_lines();
2362 $marginInfo = $formmargin->getMarginInfosArray($facturestatic);
2363 $total_ht += $obj->total_ht;
2364 $total_margin += $marginInfo[
'total_margin'];
2369 if ($mode ==
'kanban') {
2371 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
2372 print
'<div class="box-flex-container kanban">';
2375 if ($massactionbutton || $massaction) {
2377 if (in_array(
$object->id, $arrayofselected)) {
2382 $arraydata = array(
'alreadypaid' => $paiement,
'thirdparty' => $companystatic->getNomUrl(1,
'', 12),
'userauthor' => $userstatic->getNomUrl(1),
'selected' => in_array(
$object->id, $arrayofselected));
2383 print $facturestatic->getKanbanView(
'', $arraydata);
2384 if ($i == ($imaxinloop - 1)) {
2391 print
'<tr data-rowid="'.$object->id.
'" class="oddeven row-with-select status'.
$object->status.((getDolGlobalInt(
'MAIN_FINISHED_LINES_OPACITY') == 1 && $obj->status > 1) ?
' opacitymedium' :
'').
'"';
2392 if ($contextpage ==
'poslist') {
2393 print
' onclick="parent.$(\'#poslines\').load(\'invoice.php?action=history&placeid='.$obj->id.
'\',
function() {parent.$.colorbox.close();
';
2394 if (strpos($obj->ref, 'PROV
') !== false) {
2395 //If is a draft invoice, load var to be able to add products
2396 $place = str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref));
2397 print 'parent.place=\
''.dol_escape_js($place).
'\'';
2405 print
'<td class="nowrap center">';
2406 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
2408 if (in_array($obj->id, $arrayofselected)) {
2411 print
'<input id="cb'.$obj->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2421 print
'<td>'.(($offset * $limit) + $i).
'</td>';
2428 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
2429 print
'<td class="nowraponall">';
2431 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
2433 print
'<td class="nobordernopadding nowraponall">';
2434 if ($contextpage ==
'poslist') {
2437 print $facturestatic->getNomUrl(1,
'', 200, 0,
'', 0, 1);
2441 $filepath = $conf->invoice->multidir_output[$obj->entity] ?? $conf->invoice->dir_output;
2442 $filedir = $filepath.
'/'.$filename;
2444 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->id;
2445 print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
2457 if (!empty($arrayfields[
'f.ref_client'][
'checked'])) {
2458 $tdcss = (
getDolGlobalInt(
'MAIN_SHOW_GLOBAL_REF_CUSTOMER_SUPPLIER') ?
'class="minwidth400 maxwidth400"' :
'class="nowrap tdoverflowmax200"');
2459 print
'<td title="'.dolPrintHTMLForAttribute($obj->ref_client).
'" '.$tdcss.
'>';
2468 if (!empty($arrayfields[
'f.type'][
'checked'])) {
2469 print
'<td class="nowraponall tdoverflowmax100" title="'.$facturestatic->getLibType().
'">';
2470 print $facturestatic->getLibType(2);
2478 if (!empty($arrayfields[
'f.subtype'][
'checked'])) {
2480 if ($facturestatic->subtype > 0) {
2481 $labeltoshow = $facturestatic->getSubtypeLabel(
'facture');
2483 print
'<td class="nowraponall tdoverflowmax300" title="'.$labeltoshow.
'">';
2492 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
2493 print
'<td align="center" class="nowraponall">';
2502 if (!empty($arrayfields[
'f.date_valid'][
'checked'])) {
2503 print
'<td align="center" class="nowraponall">';
2512 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
2513 print
'<td align="center" class="nowraponall">'.dol_print_date($datelimit,
'day');
2514 if ($facturestatic->hasDelay()) {
2515 print
img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
2524 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
2525 print
'<td class="nocellnopadd nowraponall">';
2526 if ($obj->project_id > 0) {
2527 print $projectstatic->getNomUrl(1);
2536 if (!empty($arrayfields[
'p.title'][
'checked'])) {
2537 print
'<td class="nowraponall">';
2538 if ($obj->project_id > 0) {
2548 if (!empty($arrayfields[
's.nom'][
'checked'])) {
2549 print
'<td class="tdoverflowmax150">';
2550 if ($contextpage ==
'poslist') {
2553 print $companystatic->getNomUrl(1,
'customer', 0, 0, -1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2561 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2562 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->name_alias).
'">';
2570 if (!empty($arrayfields[
's2.nom'][
'checked'])) {
2571 print
'<td class="tdoverflowmax200">';
2572 if ($obj->fk_parent > 0) {
2573 if (!isset($company_url_list[$obj->fk_parent])) {
2574 $companyparent =
new Societe($db);
2575 $res = $companyparent->fetch($obj->fk_parent);
2577 $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1);
2580 if (isset($company_url_list[$obj->fk_parent])) {
2581 print $company_url_list[$obj->fk_parent];
2590 if (!empty($arrayfields[
's.code_client'][
'checked'])) {
2591 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->code_client).
'">';
2599 if (!empty($arrayfields[
's.town'][
'checked'])) {
2600 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).
'">';
2608 if (!empty($arrayfields[
's.zip'][
'checked'])) {
2609 print
'<td class="nowraponall">';
2617 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
2618 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->state_name).
'">'.
dol_escape_htmltag($obj->state_name).
"</td>\n";
2624 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
2625 $tmparray =
getCountry($obj->fk_pays,
'all');
2626 print
'<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($tmparray[
'label']).
'">';
2634 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
2635 if (!is_array($typenArray) || count($typenArray) == 0) {
2636 $typenArray = $formcompany->typent_array(1);
2638 print
'<td class="center tdoverflowmax100" title="'.dolPrintHTMLForAttribute($typenArray[$obj->typent_code]).
'">';
2639 if (!empty($obj->typent_code)) {
2640 print $typenArray[$obj->typent_code];
2648 if (!empty($arrayfields[
'staff.code'][
'checked'])) {
2649 if (!is_array($conf->cache[
'staff']) || count($conf->cache[
'staff']) == 0) {
2650 $conf->cache[
'staff'] = $formcompany->effectif_array(1);
2652 print
'<td class="center tdoverflowmax100" title="'.dolPrintHTML($conf->cache[
'staff'][$obj->staff_code]).
'">';
2653 print $conf->cache[
'staff'][$obj->staff_code];
2661 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
2662 $s = $form->form_modes_reglement($_SERVER[
'PHP_SELF'], $obj->fk_mode_reglement,
'none',
'', -1, 0,
'', 1);
2663 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
2672 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
2673 $s = $form->form_conditions_reglement($_SERVER[
'PHP_SELF'], $obj->fk_cond_reglement,
'none', 0,
'', -1, -1, 1);
2674 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
2683 if (!empty($arrayfields[
'f.fk_input_reason'][
'checked'])) {
2685 $form->formInputReason($_SERVER[
'PHP_SELF'], (
string) $obj->fk_input_reason,
'none');
2693 if (!empty($arrayfields[
'f.module_source'][
'checked'])) {
2702 if (!empty($arrayfields[
'f.pos_source'][
'checked'])) {
2712 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
2713 print
'<td class="right nowraponall"><span class="amount">'.price($obj->total_ht).
"</span></td>\n";
2720 $totalarray[
'val'][
'f.total_ht'] += $obj->total_ht;
2723 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
2724 print
'<td class="right nowraponall amount">'.price($obj->total_tva).
"</td>\n";
2731 $totalarray[
'val'][
'f.total_tva'] += $obj->total_tva;
2734 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
2735 print
'<td class="right nowraponall amount">'.price($obj->total_localtax1).
"</td>\n";
2742 $totalarray[
'val'][
'f.total_localtax1'] += $obj->total_localtax1;
2745 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
2746 print
'<td class="right nowraponall amount">'.price($obj->total_localtax2).
"</td>\n";
2753 $totalarray[
'val'][
'f.total_localtax2'] += $obj->total_localtax2;
2756 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
2757 print
'<td class="right nowraponall amount">'.price($obj->total_ttc).
"</td>\n";
2764 $totalarray[
'val'][
'f.total_ttc'] += $obj->total_ttc;
2767 $userstatic->id = $obj->fk_user_author;
2768 $userstatic->login = $obj->login;
2769 $userstatic->lastname = $obj->lastname;
2770 $userstatic->firstname = $obj->firstname;
2771 $userstatic->email = $obj->user_email;
2772 $userstatic->status = $obj->user_statut;
2773 $userstatic->entity = $obj->entity;
2774 $userstatic->photo = $obj->photo;
2775 $userstatic->office_phone = $obj->office_phone;
2776 $userstatic->office_fax = $obj->office_fax;
2777 $userstatic->user_mobile = $obj->user_mobile;
2778 $userstatic->job = $obj->job;
2779 $userstatic->gender = $obj->gender;
2782 if (!empty($arrayfields[
'u.login'][
'checked'])) {
2783 print
'<td class="tdoverflowmax100">';
2784 if ($userstatic->id) {
2785 print $userstatic->getNomUrl(-1);
2795 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
2798 if ($obj->socid > 0) {
2799 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
2800 if ($listsalesrepresentatives < 0) {
2803 $nbofsalesrepresentative = count($listsalesrepresentatives);
2804 if ($nbofsalesrepresentative > 6) {
2806 print $nbofsalesrepresentative;
2807 } elseif ($nbofsalesrepresentative > 0) {
2809 foreach ($listsalesrepresentatives as $val) {
2810 $userstatic->id = $val[
'id'];
2811 $userstatic->lastname = $val[
'lastname'];
2812 $userstatic->firstname = $val[
'firstname'];
2813 $userstatic->email = $val[
'email'];
2814 $userstatic->status = $val[
'statut'];
2815 $userstatic->entity = $val[
'entity'];
2816 $userstatic->photo = $val[
'photo'];
2817 $userstatic->login = $val[
'login'];
2818 $userstatic->office_phone = $val[
'office_phone'];
2819 $userstatic->office_fax = $val[
'office_fax'];
2820 $userstatic->user_mobile = $val[
'user_mobile'];
2821 $userstatic->job = $val[
'job'];
2822 $userstatic->gender = $val[
'gender'];
2824 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1,
'', 0, 0, 12) : $userstatic->getNomUrl(-2);
2826 if ($j < $nbofsalesrepresentative) {
2840 if (!empty($arrayfields[
'f.retained_warranty'][
'checked'])) {
2841 print
'<td align="right">'.(!empty($obj->retained_warranty) ?
price($obj->retained_warranty).
'%' :
' ').
'</td>';
2847 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
2848 print
'<td class="right nowraponall amount">'.(!empty($totalallpayments) ?
price($totalallpayments, 0, $langs) :
' ').
'</td>';
2855 $totalarray[
'val'][
'dynamount_payed'] += $totalallpayments;
2859 if (!empty($arrayfields[
'rtp'][
'checked'])) {
2860 print
'<td class="right nowraponall amount">';
2861 print(!empty($remaintopay) ?
price($remaintopay, 0, $langs) :
' ');
2874 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
2875 if (!
getDolGlobalString(
'MAIN_SHOW_ONLY_CODE_MULTICURRENCY') && !empty($obj->multicurrency_code)) {
2876 $title = $obj->multicurrency_code.
' - '.$langs->transnoentitiesnoconv(
'Currency'.$obj->multicurrency_code);
2877 $label = $langs->transnoentitiesnoconv(
'Currency'.$obj->multicurrency_code);
2879 $title = $obj->multicurrency_code;
2880 $label = $obj->multicurrency_code;
2882 print
'<td class="nowraponall tdoverflowmax125" title="'.dolPrintHTMLForAttribute($title).
'">';
2891 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
2892 print
'<td class="nowraponall">';
2893 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->id, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
2900 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
2901 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_total_ht).
"</td>\n";
2907 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
2908 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_total_vat).
"</td>\n";
2914 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
2915 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_total_ttc).
"</td>\n";
2921 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
2922 print
'<td class="right nowraponall amount">'.(!empty($multicurrency_totalpay) ?
price($multicurrency_totalpay, 0, $langs) :
' ').
'</td>';
2929 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
2930 print
'<td class="right nowraponall amount">';
2931 print(!empty($multicurrency_remaintopay) ?
price($multicurrency_remaintopay, 0, $langs) :
' ');
2939 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
2940 print
'<td class="right nowrap">'.price($marginInfo[
'pa_total'], 0, $langs, 1, -1,
'MT').
'</td>';
2945 if (empty($totalarray[
'val'][
'total_pa'])) {
2948 $totalarray[
'val'][
'total_pa'] += $marginInfo[
'pa_total'];
2951 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
2952 print
'<td class="right nowrap">'.price($marginInfo[
'total_margin'], 0, $langs, 1, -1,
'MT').
'</td>';
2957 if (empty($totalarray[
'val'][
'total_margin'])) {
2960 $totalarray[
'val'][
'total_margin'] += $marginInfo[
'total_margin'];
2963 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
2964 print
'<td class="right nowrap">'.(($marginInfo[
'total_margin_rate'] ==
'') ?
'' :
price($marginInfo[
'total_margin_rate'], 0,
'', 0, 0, 2).
'%').
'</td>';
2970 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
2971 print
'<td class="right nowrap">'.(($marginInfo[
'total_mark_rate'] ==
'') ?
'' :
price($marginInfo[
'total_mark_rate'], 0,
'', 0, 0, 2).
'%').
'</td>';
2976 if ($i >= $imaxinloop - 1) {
2977 if (!empty($total_ht)) {
2986 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2988 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
2989 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2990 print $hookmanager->resPrint;
2992 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
2993 print
'<td class="nowraponall center">';
2994 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuserrel');
3001 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
3002 print
'<td class="nowraponall center">';
3003 print
dol_print_date($db->jdate($obj->date_modification),
'dayhour',
'tzuserrel');
3010 if (!empty($arrayfields[
'f.date_closing'][
'checked'])) {
3011 print
'<td class="nowraponall center">';
3012 print
dol_print_date($db->jdate($obj->date_closing),
'dayhour',
'tzuserrel');
3019 if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
3020 print
'<td class="sensiblehtmlcontent center">';
3021 print
'<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(
dolGetFirstLineOfText($obj->note_public, 5)).
'</div>';
3028 if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
3029 print
'<td class="sensiblehtmlcontent center">';
3030 print
'<div class="small lineheightsmall twolinesmax-normallineheight">'.dolPrintHTML(
dolGetFirstLineOfText($obj->note_private, 5)).
'</div>';
3037 if (!empty($arrayfields[
'f.fk_fac_rec_source'][
'checked'])) {
3038 print
'<td class="center">';
3039 if (!empty($obj->fk_fac_rec_source)) {
3041 $result = $facrec->fetch($obj->fk_fac_rec_source);
3045 print $facrec->getNomUrl();
3055 if (!empty($arrayfields[
'f.import_key'][
'checked'])) {
3056 print
'<td class="nowrap center">'.dol_escape_htmltag($obj->import_key).
'</td>';
3063 if (!empty($arrayfields[
'f.dispute_status'][
'checked'])) {
3064 print
'<td class="nowrap center">';
3065 if ($facturestatic->dispute_status) {
3066 $liststatus = array(
'0' =>
"None",
'1' =>
"DisputeOpen",
'8' =>
"DisputeLost",
'9' =>
"DisputeWon");
3067 print $langs->trans($liststatus[$facturestatic->dispute_status]);
3076 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
3077 print
'<td class="nowrap center">';
3078 print $facturestatic->getLibStatut(5, $totalallpayments);
3088 print
'<td class="nowrap center">';
3089 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
3091 if (in_array($obj->id, $arrayofselected)) {
3094 print
'<input id="cb'.$obj->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
3109 $totalarray[
'val'][
'total_pa'] = (isset($totalarray[
'val'][
'total_pa']) ?
price2num($totalarray[
'val'][
'total_pa'],
'MT') : null);
3110 $totalarray[
'val'][
'total_margin'] = (isset($totalarray[
'val'][
'total_margin']) ?
price2num($totalarray[
'val'][
'total_margin'],
'MT') : null);
3113 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
3119 foreach ($arrayfields as $key => $val) {
3120 if (!empty($val[
'checked'])) {
3124 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
3129$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
3130$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
3131print $hookmanager->resPrint;
3133print
'</table>'.
"\n";
3136print
'</form>'.
"\n";
3139if ($contextpage !=
'poslist') {
3140 $hidegeneratedfilelistifempty = 1;
3141 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
3142 $hidegeneratedfilelistifempty = 0;
3146 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
3147 $urlsource .= str_replace(
'&',
'&', $param);
3149 $filedir = $diroutputmassaction;
3150 $genallowed = $user->hasRight(
"facture",
"lire");
3151 $delallowed = $user->hasRight(
"facture",
"creer");
3154 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.