46require
'../../main.inc.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
50if (isModEnabled(
'margin')) {
51 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmargin.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
54require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
57require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
58require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
59require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
60require_once DOL_DOCUMENT_ROOT.
'/core/lib/invoice.lib.php';
61require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
62require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
63require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
64if (isModEnabled(
'order')) {
65 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
78$langs->loadLangs(array(
'bills',
'companies',
'products',
'categories'));
80$search_all = trim(
GETPOST(
'search_all',
'alphanohtml'));
86$action =
GETPOST(
'action',
'aZ09');
87$massaction =
GETPOST(
'massaction',
'alpha');
89$confirm =
GETPOST(
'confirm',
'alpha');
90$toselect =
GETPOST(
'toselect',
'array');
91$optioncss =
GETPOST(
'optioncss',
'alpha');
92$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'invoicelist';
95if ($contextpage ==
'poslist') {
101$search_refcustomer =
GETPOST(
'search_refcustomer',
'alpha');
102$search_type =
GETPOST(
'search_type',
'intcomma');
103$search_subtype =
GETPOST(
'search_subtype',
'intcomma');
104$search_project_ref =
GETPOST(
'search_project_ref',
'alpha');
105$search_project =
GETPOST(
'search_project',
'alpha');
106$search_company =
GETPOST(
'search_company',
'alpha');
107$search_company_alias =
GETPOST(
'search_company_alias',
'alpha');
108$search_parent_name = trim(
GETPOST(
'search_parent_name',
'alphanohtml'));
109$search_montant_ht =
GETPOST(
'search_montant_ht',
'alpha');
110$search_montant_vat =
GETPOST(
'search_montant_vat',
'alpha');
111$search_montant_localtax1 =
GETPOST(
'search_montant_localtax1',
'alpha');
112$search_montant_localtax2 =
GETPOST(
'search_montant_localtax2',
'alpha');
113$search_montant_ttc =
GETPOST(
'search_montant_ttc',
'alpha');
114$search_login =
GETPOST(
'search_login',
'alpha');
115$search_multicurrency_code =
GETPOST(
'search_multicurrency_code',
'alpha');
116$search_multicurrency_tx =
GETPOST(
'search_multicurrency_tx',
'alpha');
117$search_multicurrency_montant_ht =
GETPOST(
'search_multicurrency_montant_ht',
'alpha');
118$search_multicurrency_montant_vat =
GETPOST(
'search_multicurrency_montant_vat',
'alpha');
119$search_multicurrency_montant_ttc =
GETPOST(
'search_multicurrency_montant_ttc',
'alpha');
120$search_status =
GETPOST(
'search_status',
'intcomma');
121$search_paymentmode =
GETPOST(
'search_paymentmode',
'intcomma');
122$search_paymentterms =
GETPOST(
'search_paymentterms',
'intcomma');
123$search_module_source =
GETPOST(
'search_module_source',
'alpha');
124$search_pos_source =
GETPOST(
'search_pos_source',
'alpha');
125$search_town =
GETPOST(
'search_town',
'alpha');
126$search_zip =
GETPOST(
'search_zip',
'alpha');
127$search_state =
GETPOST(
"search_state");
128$search_country =
GETPOST(
"search_country",
'aZ09');
129$search_customer_code =
GETPOST(
"search_customer_code",
'alphanohtml');
130$search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'intcomma');
131$search_user =
GETPOST(
'search_user',
'intcomma');
132$search_sale =
GETPOST(
'search_sale',
'intcomma');
133$search_date_startday =
GETPOSTINT(
'search_date_startday');
134$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
135$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
136$search_date_endday =
GETPOSTINT(
'search_date_endday');
137$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
138$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
139$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
140$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
141$search_date_valid_startday =
GETPOSTINT(
'search_date_valid_startday');
142$search_date_valid_startmonth =
GETPOSTINT(
'search_date_valid_startmonth');
143$search_date_valid_startyear =
GETPOSTINT(
'search_date_valid_startyear');
144$search_date_valid_endday =
GETPOSTINT(
'search_date_valid_endday');
145$search_date_valid_endmonth =
GETPOSTINT(
'search_date_valid_endmonth');
146$search_date_valid_endyear =
GETPOSTINT(
'search_date_valid_endyear');
147$search_date_valid_start =
dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear);
148$search_date_valid_end =
dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear);
149$search_datelimit_startday =
GETPOSTINT(
'search_datelimit_startday');
150$search_datelimit_startmonth =
GETPOSTINT(
'search_datelimit_startmonth');
151$search_datelimit_startyear =
GETPOSTINT(
'search_datelimit_startyear');
152$search_datelimit_endday =
GETPOSTINT(
'search_datelimit_endday');
153$search_datelimit_endmonth =
GETPOSTINT(
'search_datelimit_endmonth');
154$search_datelimit_endyear =
GETPOSTINT(
'search_datelimit_endyear');
155$search_datelimit_start =
dol_mktime(0, 0, 0, $search_datelimit_startmonth, $search_datelimit_startday, $search_datelimit_startyear);
156$search_datelimit_end =
dol_mktime(23, 59, 59, $search_datelimit_endmonth, $search_datelimit_endday, $search_datelimit_endyear);
157$search_categ_cus =
GETPOST(
"search_categ_cus",
'intcomma');
158$search_product_category =
GETPOST(
'search_product_category',
'intcomma');
159$search_fac_rec_source_title =
GETPOST(
"search_fac_rec_source_title",
'alpha');
160$search_fk_fac_rec_source =
GETPOST(
'search_fk_fac_rec_source',
'int');
161$search_import_key = trim(
GETPOST(
"search_import_key",
"alpha"));
163$search_option =
GETPOST(
'search_option');
164if ($search_option ==
'late') {
165 $search_status =
'1';
169$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
170$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
172if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
175$offset = $limit * $page;
176if (!$sortorder &&
getDolGlobalString(
'INVOICE_DEFAULT_UNPAYED_SORT_ORDER') && $search_status ==
'1') {
183 $sortfield =
'f.datef';
185$pageprev = $page - 1;
186$pagenext = $page + 1;
188$diroutputmassaction =
$conf->facture->dir_output.
'/temp/massgeneration/'.$user->id;
195$hookmanager->initHooks(array($contextpage));
199$extrafields->fetch_name_optionals_label(
$object->table_element);
201$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
204$fieldstosearchall = array(
206 'f.ref_client' =>
'RefCustomer',
207 'f.note_public' =>
'NotePublic',
208 's.nom' =>
"ThirdParty",
209 's.code_client' =>
"CustomerCodeShort",
210 's.name_alias' =>
"AliasNameShort",
213 'pd.description' =>
'Description',
215if (empty($user->socid)) {
216 $fieldstosearchall[
"f.note_private"] =
"NotePrivate";
219$checkedtypetiers = 0;
221 'f.ref' => array(
'label' =>
"Ref",
'checked' => 1,
'position' => 5),
222 'f.ref_client' => array(
'label' =>
"RefCustomer",
'checked' => -1,
'position' => 10),
223 'f.type' => array(
'label' =>
"Type",
'checked' => 0,
'position' => 15),
224 'f.subtype' => array(
'label' =>
"InvoiceSubtype",
'checked' => 0,
'position' => 17),
225 'f.datef' => array(
'label' =>
"DateInvoice",
'checked' => 1,
'position' => 20),
226 'f.date_valid' => array(
'label' =>
"DateValidation",
'checked' => 0,
'position' => 22),
227 'f.date_lim_reglement' => array(
'label' =>
"DateDue",
'checked' => 1,
'position' => 25),
228 'f.date_closing' => array(
'label' =>
"DateClosing",
'checked' => 0,
'position' => 30),
229 'p.ref' => array(
'label' =>
"ProjectRef",
'langs' =>
'projects',
'checked' => 1,
'enabled' => (!isModEnabled(
'project') ? 0 : 1),
'position' => 40),
230 'p.title' => array(
'label' =>
"ProjectLabel",
'checked' => 0,
'enabled' => (!isModEnabled(
'project') ? 0 : 1),
'position' => 41),
231 's.nom' => array(
'label' =>
"ThirdParty",
'checked' => 1,
'position' => 50),
232 's.name_alias' => array(
'label' =>
"AliasNameShort",
'checked' => -1,
'position' => 51),
233 's.code_client' => array(
'label' =>
"CustomerCodeShort",
'checked' => -1,
'position' => 52),
234 's2.nom' => array(
'label' =>
'ParentCompany',
'position' => 32,
'checked' => 0),
235 's.town' => array(
'label' =>
"Town",
'checked' => -1,
'position' => 55),
236 's.zip' => array(
'label' =>
"Zip",
'checked' => -1,
'position' => 60),
237 'state.nom' => array(
'label' =>
"StateShort",
'checked' => 0,
'position' => 65),
238 'country.code_iso' => array(
'label' =>
"Country",
'checked' => 0,
'position' => 70),
239 'typent.code' => array(
'label' =>
"ThirdPartyType",
'checked' => $checkedtypetiers,
'position' => 75),
240 'f.fk_mode_reglement' => array(
'label' =>
"PaymentMode",
'checked' => 1,
'position' => 80),
241 'f.fk_cond_reglement' => array(
'label' =>
"PaymentConditionsShort",
'checked' => 1,
'position' => 85),
242 'f.module_source' => array(
'label' =>
"POSModule",
'langs' =>
'cashdesk',
'checked' => ($contextpage ==
'poslist' ? 1 : 0),
'enabled' =>
"(isModEnabled('cashdesk') || isModEnabled('takepos') || getDolGlobalInt('INVOICE_SHOW_POS'))",
'position' => 90),
243 'f.pos_source' => array(
'label' =>
"POSTerminal",
'langs' =>
'cashdesk',
'checked' => ($contextpage ==
'poslist' ? 1 : 0),
'enabled' =>
"(isModEnabled('cashdesk') || isModEnabled('takepos') || getDolGlobalInt('INVOICE_SHOW_POS'))",
'position' => 91),
244 'f.total_ht' => array(
'label' =>
"AmountHT",
'checked' => 1,
'position' => 95),
245 'f.total_tva' => array(
'label' =>
"AmountVAT",
'checked' => 0,
'position' => 100),
246 'f.total_localtax1' => array(
'label' => $langs->transcountry(
"AmountLT1", $mysoc->country_code),
'checked' => 0,
'enabled' => ($mysoc->localtax1_assuj ==
"1"),
'position' => 110),
247 'f.total_localtax2' => array(
'label' => $langs->transcountry(
"AmountLT2", $mysoc->country_code),
'checked' => 0,
'enabled' => ($mysoc->localtax2_assuj ==
"1"),
'position' => 120),
248 'f.total_ttc' => array(
'label' =>
"AmountTTC",
'checked' => 0,
'position' => 130),
249 'dynamount_payed' => array(
'label' =>
"AlreadyPaid",
'checked' => 0,
'position' => 140),
250 'rtp' => array(
'label' =>
"RemainderToPay",
'checked' => 0,
'position' => 150),
251 'f.multicurrency_code' => array(
'label' =>
'Currency',
'checked' => 0,
'enabled' => (!isModEnabled(
'multicurrency') ? 0 : 1),
'position' => 280),
252 'f.multicurrency_tx' => array(
'label' =>
'CurrencyRate',
'checked' => 0,
'enabled' => (!isModEnabled(
'multicurrency') ? 0 : 1),
'position' => 285),
253 'f.multicurrency_total_ht' => array(
'label' =>
'MulticurrencyAmountHT',
'checked' => 0,
'enabled' => (!isModEnabled(
'multicurrency') ? 0 : 1),
'position' => 290),
254 'f.multicurrency_total_vat' => array(
'label' =>
'MulticurrencyAmountVAT',
'checked' => 0,
'enabled' => (!isModEnabled(
'multicurrency') ? 0 : 1),
'position' => 291),
255 'f.multicurrency_total_ttc' => array(
'label' =>
'MulticurrencyAmountTTC',
'checked' => 0,
'enabled' => (!isModEnabled(
'multicurrency') ? 0 : 1),
'position' => 292),
256 'multicurrency_dynamount_payed' => array(
'label' =>
'MulticurrencyAlreadyPaid',
'checked' => 0,
'enabled' => (!isModEnabled(
'multicurrency') ? 0 : 1),
'position' => 295),
257 'multicurrency_rtp' => array(
'label' =>
'MulticurrencyRemainderToPay',
'checked' => 0,
'enabled' => (!isModEnabled(
'multicurrency') ? 0 : 1),
'position' => 296),
258 'total_pa' => array(
'label' => ((
getDolGlobalString(
'MARGIN_TYPE') ==
'1') ?
'BuyingPrice' :
'CostPrice'),
'checked' => 0,
'position' => 300,
'enabled' => (!isModEnabled(
'margin') || !$user->hasRight(
'margins',
'liretous') ? 0 : 1)),
259 'total_margin' => array(
'label' =>
'Margin',
'checked' => 0,
'position' => 301,
'enabled' => (!isModEnabled(
'margin') || !$user->hasRight(
'margins',
'liretous') ? 0 : 1)),
260 'total_margin_rate' => array(
'label' =>
'MarginRate',
'checked' => 0,
'position' => 302,
'enabled' => (!isModEnabled(
'margin') || !$user->hasRight(
'margins',
'liretous') || !
getDolGlobalString(
'DISPLAY_MARGIN_RATES') ? 0 : 1)),
261 'total_mark_rate' => array(
'label' =>
'MarkRate',
'checked' => 0,
'position' => 303,
'enabled' => (!isModEnabled(
'margin') || !$user->hasRight(
'margins',
'liretous') || !
getDolGlobalString(
'DISPLAY_MARK_RATES') ? 0 : 1)),
262 'f.datec' => array(
'label' =>
"DateCreation",
'checked' => 0,
'position' => 500),
263 'f.tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModificationShort',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 502),
264 'u.login' => array(
'label' =>
"UserAuthor",
'checked' => 1,
'visible' => -1,
'position' => 504),
265 'sale_representative' => array(
'label' =>
"SaleRepresentativesOfThirdParty",
'checked' => 0,
'position' => 506),
270 'f.note_public' => array(
'label' =>
'NotePublic',
'checked' => 0,
'position' => 520,
'enabled' => (!
getDolGlobalInt(
'MAIN_LIST_HIDE_PUBLIC_NOTES'))),
271 'f.note_private' => array(
'label' =>
'NotePrivate',
'checked' => 0,
'position' => 521,
'enabled' => (!
getDolGlobalInt(
'MAIN_LIST_HIDE_PRIVATE_NOTES'))),
272 'f.fk_fac_rec_source' => array(
'label' =>
'GeneratedFromTemplate',
'checked' => 0,
'position' => 530,
'enabled' =>
'1'),
273 'f.import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 999),
274 'f.fk_statut' => array(
'label' =>
"Status",
'checked' => 1,
'position' => 1000),
278 $arrayfields[
'f.retained_warranty'] = array(
'label' => $langs->trans(
"RetainedWarranty"),
'checked' => 0,
'position' => 86);
281$subtypearray =
$object->getArrayOfInvoiceSubtypes(0);
282if (empty($subtypearray)) {
283 unset($arrayfields[
'f.subtype']);
287foreach (
$object->fields as $key => $val) {
290 if (!empty($val[
'visible'])) {
291 $visible = (int)
dol_eval((
string) $val[
'visible'], 1, 1,
'1');
293 if (array_key_exists($key, $arrayfields)) {
295 } elseif (array_key_exists(
'f.'.$key, $arrayfields)) {
297 } elseif (array_key_exists(
's.'.$key, $arrayfields)) {
301 $arrayfields[$newkey] = array(
302 'label' => $val[
'label'],
303 'checked' => (($visible < 0) ? 0 : 1),
304 'enabled' => (abs($visible) != 3 && (bool)
dol_eval($val[
'enabled'], 1)),
305 'position' => $val[
'position'],
306 'help' => empty($val[
'help']) ?
'' : $val[
'help'],
312include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
317'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields';
319if (!$user->hasRight(
'societe',
'client',
'voir')) {
320 $search_sale = $user->id;
324$fieldid = (!empty($ref) ?
'ref' :
'rowid');
325if (!empty($user->socid)) {
326 $socid = $user->socid;
335if (
GETPOST(
'cancel',
'alpha')) {
339if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
343$parameters = array(
'socid' => $socid,
'arrayfields' => &$arrayfields);
344$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
349include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
352if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha')) {
355 $search_product_category =
'';
357 $search_refcustomer =
'';
359 $search_subtype =
'';
360 $search_project_ref =
'';
361 $search_project =
'';
362 $search_company =
'';
363 $search_company_alias =
'';
364 $search_parent_name =
'';
365 $search_montant_ht =
'';
366 $search_montant_vat =
'';
367 $search_montant_localtax1 =
'';
368 $search_montant_localtax2 =
'';
369 $search_montant_ttc =
'';
371 $search_multicurrency_code =
'';
372 $search_multicurrency_tx =
'';
373 $search_multicurrency_montant_ht =
'';
374 $search_multicurrency_montant_vat =
'';
375 $search_multicurrency_montant_ttc =
'';
377 $search_paymentmode =
'';
378 $search_paymentterms =
'';
379 $search_module_source =
'';
380 $search_pos_source =
'';
384 $search_country =
'';
385 $search_type_thirdparty =
'';
386 $search_customer_code =
'';
387 $search_date_startday =
'';
388 $search_date_startmonth =
'';
389 $search_date_startyear =
'';
390 $search_date_endday =
'';
391 $search_date_endmonth =
'';
392 $search_date_endyear =
'';
393 $search_date_start =
'';
394 $search_date_end =
'';
395 $search_date_valid_startday =
'';
396 $search_date_valid_startmonth =
'';
397 $search_date_valid_startyear =
'';
398 $search_date_valid_endday =
'';
399 $search_date_valid_endmonth =
'';
400 $search_date_valid_endyear =
'';
401 $search_date_valid_start =
'';
402 $search_date_valid_end =
'';
403 $search_datelimit_startday =
'';
404 $search_datelimit_startmonth =
'';
405 $search_datelimit_startyear =
'';
406 $search_datelimit_endday =
'';
407 $search_datelimit_endmonth =
'';
408 $search_datelimit_endyear =
'';
409 $search_datelimit_start =
'';
410 $search_datelimit_end =
'';
411 $search_fac_rec_source_title =
'';
413 $search_import_key =
'';
414 $search_categ_cus = 0;
418 $search_array_options = array();
421if (empty($reshook)) {
422 $objectclass =
'Facture';
423 $objectlabel =
'Invoices';
424 $permissiontoread = $user->hasRight(
"facture",
"lire");
425 $permissiontoadd = $user->hasRight(
"facture",
"creer");
426 $permissiontodelete = $user->hasRight(
"facture",
"supprimer");
427 $uploaddir =
$conf->facture->dir_output;
428 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
431if ($action ==
'makepayment_confirm' && $user->hasRight(
'facture',
'paiement')) {
432 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
433 $arrayofselected = is_array($toselect) ? $toselect : array();
434 if (!empty($arrayofselected)) {
438 if (empty($paiementdate)) {
439 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
441 $action =
'makepayment';
445 foreach ($arrayofselected as $toselectid) {
448 $result = $facture->fetch($toselectid);
457 $paiementAmount = $facture->getSommePaiement();
458 $totalcreditnotes = $facture->getSumCreditNotesUsed();
459 $totaldeposits = $facture->getSumDepositsUsed();
461 $totalallpayments = $paiementAmount + $totalcreditnotes + $totaldeposits;
462 $remaintopay =
price2num($facture->total_ttc - $totalallpayments);
465 $parameters = array(
'remaintopay' => $remaintopay);
466 $reshook = $hookmanager->executeHooks(
'finalizeAmountOfInvoice', $parameters, $facture, $action);
468 if (!empty($remain = $hookmanager->resArray[
'remaintopay'])) {
469 $remaintopay = $remain;
471 } elseif ($reshook < 0) {
473 setEventMessages($facture->ref.
' '.$langs->trans(
"ProcessingError"), $hookmanager->errors,
'errors');
476 if ($remaintopay != 0) {
477 $resultBank = $facture->setBankAccount($bankid);
478 if ($resultBank < 0) {
483 $paiement->datepaye = $paiementdate;
484 $paiement->amounts[$facture->id] = $remaintopay;
485 $paiement->multicurrency_amounts[$facture->id] = $remaintopay;
486 $paiement->paiementid = $paiementid;
487 $paiement_id = $paiement->create($user, 1, $facture->thirdparty);
488 if ($paiement_id < 0) {
489 $langs->load(
"errors");
490 setEventMessages($facture->ref.
' '.$langs->trans($paiement->error), $paiement->errors,
'errors');
493 $result = $paiement->addPaymentToBank($user,
'payment',
'', $bankid,
'',
'');
495 $langs->load(
"errors");
496 setEventMessages($facture->ref.
' '.$langs->trans($paiement->error), $paiement->errors,
'errors');
502 setEventMessage($langs->trans(
'NoPaymentAvailable', $facture->ref),
'warnings');
506 setEventMessage($langs->trans(
'BulkPaymentNotPossibleForInvoice', $facture->ref),
'warnings');
511 if (empty($errorpayment)) {
512 setEventMessage($langs->trans(
'PaymentRegisteredAndInvoiceSetToPaid', $facture->ref));
520} elseif ($massaction ==
'withdrawrequest') {
521 $langs->load(
"withdrawals");
523 if (!$user->hasRight(
'prelevement',
'bons',
'creer')) {
530 $arrayofselected = is_array($toselect) ? $toselect : array();
531 $listofbills = array();
532 foreach ($arrayofselected as $toselectid) {
534 $result = $objecttmp->fetch($toselectid);
536 $totalpaid = $objecttmp->getSommePaiement();
537 $totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
538 $totaldeposits = $objecttmp->getSumDepositsUsed();
539 $objecttmp->resteapayer =
price2num($objecttmp->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
542 $parameters = array(
'remaintopay' => $objecttmp->resteapayer);
543 $reshook = $hookmanager->executeHooks(
'finalizeAmountOfInvoice', $parameters, $objecttmp, $action);
545 if (!empty($remaintopay = $hookmanager->resArray[
'remaintopay'])) {
546 $objecttmp->resteapayer = $remaintopay;
548 } elseif ($reshook < 0) {
550 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"ProcessingError"), $hookmanager->errors,
'errors');
555 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"Draft"), $objecttmp->errors,
'errors');
556 } elseif ($objecttmp->paye || $objecttmp->resteapayer == 0) {
558 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AlreadyPaid"), $objecttmp->errors,
'errors');
559 } elseif ($objecttmp->resteapayer < 0) {
561 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"AmountMustBePositive"), $objecttmp->errors,
'errors');
564 $rsql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
565 $rsql .=
" , pfd.date_traite as date_traite";
566 $rsql .=
" , pfd.amount";
567 $rsql .=
" , u.rowid as user_id, u.lastname, u.firstname, u.login";
568 $rsql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
569 $rsql .=
" , ".MAIN_DB_PREFIX.
"user as u";
570 $rsql .=
" WHERE fk_facture = ".((int) $objecttmp->id);
571 $rsql .=
" AND pfd.fk_user_demande = u.rowid";
572 $rsql .=
" AND pfd.traite = 0";
573 $rsql .=
" ORDER BY pfd.date_demande DESC";
575 $result_sql = $db->query($rsql);
577 $numprlv = $db->num_rows($result_sql);
584 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"RequestAlreadyDone"), $objecttmp->errors,
'warnings');
585 } elseif (!empty($objecttmp->mode_reglement_code) && $objecttmp->mode_reglement_code !=
'PRE') {
586 $langs->load(
"errors");
588 setEventMessages($objecttmp->ref.
' '.$langs->trans(
"ErrorThisPaymentModeIsNotDirectDebit"), $objecttmp->errors,
'errors');
590 $listofbills[] = $objecttmp;
596 if (!empty($listofbills)) {
597 $nbwithdrawrequestok = 0;
598 foreach ($listofbills as $aBill) {
600 $result = $aBill->demande_prelevement($user, $aBill->resteapayer,
'direct-debit',
'facture');
603 $nbwithdrawrequestok++;
609 if ($nbwithdrawrequestok > 0) {
610 setEventMessages($langs->trans(
"WithdrawRequestsDone", $nbwithdrawrequestok),
null,
'mesgs');
622$form =
new Form($db);
626if (isModEnabled(
'margin')) {
629$bankaccountstatic =
new Account($db);
630$facturestatic =
new Facture($db);
632$companystatic =
new Societe($db);
633$companyparent =
new Societe($db);
635$company_url_list = array();
640 if (empty($search_company)) {
641 $search_company = $soc->name;
647$title = $langs->trans(
'BillsCustomers').
' '.(($socid > 0 && $soc !==
null) ?
' - '.$soc->name :
'');
648$help_url =
'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes';
650$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
651$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
657 $sql =
'SELECT DISTINCT';
659$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,';
660$sql .=
' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,';
661$sql .=
' f.fk_user_author,';
662$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,';
663$sql .=
' f.datef, f.date_valid, f.date_lim_reglement as datelimite, f.module_source, f.pos_source,';
664$sql .=
' f.paye as paye, f.fk_statut, f.import_key, f.close_code,';
665$sql .=
' f.datec as date_creation, f.tms as date_modification, f.date_closing as date_closing,';
666$sql .=
' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,';
667$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,';
668$sql .=
" s.parent as fk_parent,";
669$sql .=
" s2.nom as name2,";
670$sql .=
' typent.code as typent_code,';
671$sql .=
' state.code_departement as state_code, state.nom as state_name,';
672$sql .=
' country.code as country_code,';
673$sql .=
' f.fk_fac_rec_source,';
674$sql .=
' p.rowid as project_id, p.ref as project_ref, p.title as project_label,';
675$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';
685if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
686 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
687 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
691$parameters = array();
692$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
693$sql .= $hookmanager->resPrint;
694$sql = preg_replace(
'/,\s*$/',
'', $sql);
698$sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s';
699$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s2 ON s2.rowid = s.parent";
700$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
701$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
702$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
703$sql .=
', '.MAIN_DB_PREFIX.
'facture as f';
704if ($sortfield ==
"f.datef") {
705 $sql .= $db->hintindex(
'idx_facture_datef');
707if (isset($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
708 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (f.rowid = ef.fk_object)";
711 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facturedet as pd ON f.rowid = pd.fk_facture';
713if (!empty($search_fac_rec_source_title)) {
714 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_rec as facrec ON f.fk_fac_rec_source = facrec.rowid';
716$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"projet as p ON p.rowid = f.fk_projet";
717$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user AS u ON f.fk_user_author = u.rowid';
719$parameters = array();
720$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object);
721$sql .= $hookmanager->resPrint;
723$sql .=
' WHERE f.fk_soc = s.rowid';
724$sql .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
726 $sql .=
' AND s.rowid = '.((int) $socid);
730 $sql .=
' AND f.fk_user_author IS NULL';
732 $sql .=
' AND f.fk_user_author = '.((int) $userid);
738if ($search_refcustomer) {
741if ($search_type !=
'' && $search_type !=
'-1') {
742 $sql .=
" AND f.type IN (".$db->sanitize($db->escape($search_type)).
")";
744if ($search_subtype !=
'' && $search_subtype !=
'-1') {
745 $sql .=
" AND f.subtype IN (".$db->sanitize($db->escape($search_subtype)).
")";
747if ($search_project_ref) {
750if ($search_project) {
753if (empty($arrayfields[
's.name_alias'][
'checked']) && $search_company) {
754 $sql .=
natural_search(array(
"s.nom",
"s.name_alias"), $search_company);
756 if ($search_company) {
759 if ($search_company_alias) {
763if ($search_parent_name) {
766if ($search_customer_code) {
778if (strlen(trim($search_country))) {
780 $country_code_in_EEC = $country_code_in_EEC_without_me =
'';
781 foreach ($arrayofcode as $key => $value) {
782 $country_code_in_EEC .= ($country_code_in_EEC ?
"," :
"").
"'".$value.
"'";
783 if ($value != $mysoc->country_code) {
784 $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ?
"," :
"").
"'".$value.
"'";
787 if ($search_country ==
'special_allnotme') {
788 $sql .=
" AND country.code <> '".$db->escape($mysoc->country_code).
"'";
789 } elseif ($search_country ==
'special_eec') {
790 $sql .=
" AND country.code IN (".$db->sanitize($country_code_in_EEC, 1).
")";
791 } elseif ($search_country ==
'special_eecnotme') {
792 $sql .=
" AND country.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).
")";
793 } elseif ($search_country ==
'special_noteec') {
794 $sql .=
" AND country.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).
")";
799if ($search_type_thirdparty !=
'' && $search_type_thirdparty !=
'-1') {
800 $sql .=
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
802if ($search_montant_ht !=
'') {
805if ($search_montant_vat !=
'') {
808if ($search_montant_localtax1 !=
'') {
809 $sql .=
natural_search(
'f.localtax1', $search_montant_localtax1, 1);
811if ($search_montant_localtax2 !=
'') {
812 $sql .=
natural_search(
'f.localtax2', $search_montant_localtax2, 1);
814if ($search_montant_ttc !=
'') {
817if ($search_multicurrency_code !=
'') {
818 $sql .=
" AND f.multicurrency_code = '".$db->escape($search_multicurrency_code).
"'";
820if ($search_multicurrency_tx !=
'') {
821 $sql .=
natural_search(
'f.multicurrency_tx', $search_multicurrency_tx, 1);
823if ($search_multicurrency_montant_ht !=
'') {
824 $sql .=
natural_search(
'f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
826if ($search_multicurrency_montant_vat !=
'') {
827 $sql .=
natural_search(
'f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
829if ($search_multicurrency_montant_ttc !=
'') {
830 $sql .=
natural_search(
'f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1);
833 $sql .=
natural_search(array(
'u.login',
'u.firstname',
'u.lastname'), $search_login);
835if ($search_status !=
'-1' && $search_status !=
'') {
836 if (is_numeric($search_status) && $search_status >= 0) {
837 if ($search_status ==
'0') {
838 $sql .=
" AND f.fk_statut = 0";
840 if ($search_status ==
'1') {
841 $sql .=
" AND f.fk_statut = 1";
843 if ($search_status ==
'2') {
844 $sql .=
" AND f.fk_statut = 2";
846 if ($search_status ==
'3') {
847 $sql .=
" AND f.fk_statut = 3";
850 $sql .=
" AND f.fk_statut IN (".$db->sanitize($db->escape($search_status)).
")";
854if ($search_paymentmode > 0) {
855 $sql .=
" AND f.fk_mode_reglement = ".((int) $search_paymentmode);
857if ($search_paymentterms > 0) {
858 $sql .=
" AND f.fk_cond_reglement = ".((int) $search_paymentterms);
860if ($search_module_source) {
863if ($search_pos_source) {
866if ($search_date_start) {
867 $sql .=
" AND f.datef >= '".$db->idate($search_date_start).
"'";
869if ($search_date_end) {
870 $sql .=
" AND f.datef <= '".$db->idate($search_date_end).
"'";
872if ($search_date_valid_start) {
873 $sql .=
" AND f.date_valid >= '".$db->idate($search_date_valid_start).
"'";
875if ($search_date_valid_end) {
876 $sql .=
" AND f.date_valid <= '".$db->idate($search_date_valid_end).
"'";
878if ($search_datelimit_start) {
879 $sql .=
" AND f.date_lim_reglement >= '".$db->idate($search_datelimit_start).
"'";
881if ($search_datelimit_end) {
882 $sql .=
" AND f.date_lim_reglement <= '".$db->idate($search_datelimit_end).
"'";
884if ($search_option ==
'late') {
885 $sql .=
" AND f.date_lim_reglement < '".$db->idate(
dol_now() -
$conf->facture->client->warning_delay).
"'";
890if (!empty($search_fac_rec_source_title)) {
891 $sql .=
natural_search(
'facrec.titre', $search_fac_rec_source_title);
893if ($search_fk_fac_rec_source) {
894 $sql .=
' AND f.fk_fac_rec_source = ' . (int) $search_fk_fac_rec_source;
896if ($search_import_key) {
900if ($search_user > 0) {
901 $sql .=
" AND EXISTS (";
902 $sql .=
" SELECT ec.fk_c_type_contact, ec.element_id, ec.fk_socpeople";
903 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_contact as ec";
904 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"c_type_contact as tc";
905 $sql .=
" ON ec.fk_c_type_contact = tc.rowid AND tc.element='facture' AND tc.source='internal'";
906 $sql .=
" WHERE ec.element_id = f.rowid AND ec.fk_socpeople = ".((int) $search_user).
")";
909if ($search_sale && $search_sale !=
'-1') {
910 if ($search_sale == -2) {
911 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = f.fk_soc)";
912 } elseif ($search_sale > 0) {
913 $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).
")";
917$searchCategoryProductList = $search_product_category ? array($search_product_category) : array();
918$searchCategoryProductOperator = 0;
919if (!empty($searchCategoryProductList)) {
920 $searchCategoryProductSqlList = array();
921 $listofcategoryid =
'';
922 foreach ($searchCategoryProductList as $searchCategoryProduct) {
923 if (intval($searchCategoryProduct) == -2) {
924 $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)";
925 } elseif (intval($searchCategoryProduct) > 0) {
926 if ($searchCategoryProductOperator == 0) {
927 $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).
")";
929 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
933 if ($listofcategoryid) {
934 $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).
"))";
936 if ($searchCategoryProductOperator == 1) {
937 if (!empty($searchCategoryProductSqlList)) {
938 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
941 if (!empty($searchCategoryProductSqlList)) {
942 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
946$searchCategoryCustomerList = $search_categ_cus ? array($search_categ_cus) : array();
947$searchCategoryCustomerOperator = 0;
949if (!empty($searchCategoryCustomerList)) {
950 $searchCategoryCustomerSqlList = array();
951 $listofcategoryid =
'';
952 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
953 if (intval($searchCategoryCustomer) == -2) {
954 $searchCategoryCustomerSqlList[] =
"NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX.
"categorie_societe as ck WHERE s.rowid = ck.fk_soc)";
955 } elseif (intval($searchCategoryCustomer) > 0) {
956 if ($searchCategoryCustomerOperator == 0) {
957 $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).
")";
959 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryCustomer);
963 if ($listofcategoryid) {
964 $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).
"))";
966 if ($searchCategoryCustomerOperator == 1) {
967 if (!empty($searchCategoryCustomerSqlList)) {
968 $sql .=
" AND (".implode(
' OR ', $searchCategoryCustomerSqlList).
")";
971 if (!empty($searchCategoryCustomerSqlList)) {
972 $sql .=
" AND (".implode(
' AND ', $searchCategoryCustomerSqlList).
")";
977include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
979$parameters = array();
980$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
981$sql .= $hookmanager->resPrint;
984 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
988$parameters = array();
989$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object, $action);
990$sql .= empty($hookmanager->resPrint) ?
"" :
" HAVING 1=1 ".$hookmanager->resPrint;
993$nbtotalofrecords =
'';
996 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
997 $sqlforcount = preg_replace(
'/GROUP BY .*$/',
'', $sqlforcount);
999 $resql = $db->query($sqlforcount);
1001 $objforcount = $db->fetch_object($resql);
1002 $nbtotalofrecords = $objforcount->nbtotalofrecords;
1007 if (($page * $limit) > $nbtotalofrecords) {
1015$sql .= $db->order($sortfield, $sortorder);
1017 $sql .= $db->plimit($limit + 1, $offset);
1020$resql = $db->query($sql);
1026$num = $db->num_rows($resql);
1028$arrayofselected = is_array($toselect) ? $toselect : array();
1030if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all) {
1031 $obj = $db->fetch_object($resql);
1034 header(
"Location: ".DOL_URL_ROOT.
'/compta/facture/card.php?id='.
$id);
1041llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist');
1043if ($search_fk_fac_rec_source) {
1045 $object->fetch((
int) $search_fk_fac_rec_source);
1049 print
dol_get_fiche_head($head,
'generated', $langs->trans(
'InvoicesGeneratedFromRec'), -1,
'bill');
1053$param =
'&socid='.urlencode((
string) ($socid));
1055 $param .=
'&mode='.urlencode($mode);
1057if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
1058 $param .=
'&contextpage='.urlencode($contextpage);
1060if ($limit > 0 && $limit !=
$conf->liste_limit) {
1061 $param .=
'&limit='.((int) $limit);
1063if ($optioncss !=
'') {
1064 $param .=
'&optioncss='.urlencode($optioncss);
1067 $param .=
'&show_files='.urlencode((
string) ($show_files));
1070 $param .=
'&search_all='.urlencode($search_all);
1072if ($search_date_startday) {
1073 $param .=
'&search_date_startday='.urlencode((
string) ($search_date_startday));
1075if ($search_date_startmonth) {
1076 $param .=
'&search_date_startmonth='.urlencode((
string) ($search_date_startmonth));
1078if ($search_date_startyear) {
1079 $param .=
'&search_date_startyear='.urlencode((
string) ($search_date_startyear));
1081if ($search_date_endday) {
1082 $param .=
'&search_date_endday='.urlencode((
string) ($search_date_endday));
1084if ($search_date_endmonth) {
1085 $param .=
'&search_date_endmonth='.urlencode((
string) ($search_date_endmonth));
1087if ($search_date_endyear) {
1088 $param .=
'&search_date_endyear='.urlencode((
string) ($search_date_endyear));
1090if ($search_date_valid_startday) {
1091 $param .=
'&search_date_valid_startday='.urlencode((
string) ($search_date_valid_startday));
1093if ($search_date_valid_startmonth) {
1094 $param .=
'&search_date_valid_startmonth='.urlencode((
string) ($search_date_valid_startmonth));
1096if ($search_date_valid_startyear) {
1097 $param .=
'&search_date_valid_startyear='.urlencode((
string) ($search_date_valid_startyear));
1099if ($search_date_valid_endday) {
1100 $param .=
'&search_date_valid_endday='.urlencode((
string) ($search_date_valid_endday));
1102if ($search_date_valid_endmonth) {
1103 $param .=
'&search_date_valid_endmonth='.urlencode((
string) ($search_date_valid_endmonth));
1105if ($search_date_valid_endyear) {
1106 $param .=
'&search_date_valid_endyear='.urlencode((
string) ($search_date_valid_endyear));
1108if ($search_datelimit_startday) {
1109 $param .=
'&search_datelimit_startday='.urlencode((
string) ($search_datelimit_startday));
1111if ($search_datelimit_startmonth) {
1112 $param .=
'&search_datelimit_startmonth='.urlencode((
string) ($search_datelimit_startmonth));
1114if ($search_datelimit_startyear) {
1115 $param .=
'&search_datelimit_startyear='.urlencode((
string) ($search_datelimit_startyear));
1117if ($search_datelimit_endday) {
1118 $param .=
'&search_datelimit_endday='.urlencode((
string) ($search_datelimit_endday));
1120if ($search_datelimit_endmonth) {
1121 $param .=
'&search_datelimit_endmonth='.urlencode((
string) ($search_datelimit_endmonth));
1123if ($search_datelimit_endyear) {
1124 $param .=
'&search_datelimit_endyear='.urlencode((
string) ($search_datelimit_endyear));
1127 $param .=
'&search_ref='.urlencode($search_ref);
1129if ($search_refcustomer) {
1130 $param .=
'&search_refcustomer='.urlencode($search_refcustomer);
1132if ($search_project_ref) {
1133 $param .=
'&search_project_ref='.urlencode($search_project_ref);
1135if ($search_project) {
1136 $param .=
'&search_project='.urlencode($search_project);
1138if ($search_type !=
'') {
1139 $param .=
'&search_type='.urlencode($search_type);
1141if ($search_subtype !=
'') {
1142 $param .=
'&search_subtype='.urlencode($search_subtype);
1144if ($search_company) {
1145 $param .=
'&search_company='.urlencode($search_company);
1147if ($search_company_alias) {
1148 $param .=
'&search_company_alias='.urlencode($search_company_alias);
1150if ($search_parent_name !=
'') {
1151 $param .=
'&search_parent_name='.urlencode($search_parent_name);
1154 $param .=
'&search_town='.urlencode($search_town);
1157 $param .=
'&search_zip='.urlencode($search_zip);
1159if ($search_country) {
1160 $param .=
"&search_country=".urlencode($search_country);
1162if ($search_type_thirdparty !=
'') {
1163 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
1165if ($search_customer_code) {
1166 $param .=
'&search_customer_code='.urlencode($search_customer_code);
1168if ($search_sale > 0) {
1169 $param .=
'&search_sale='.urlencode((
string) $search_sale);
1171if ($search_user > 0) {
1172 $param .=
'&search_user='.urlencode((
string) $search_user);
1175 $param .=
'&search_login='.urlencode($search_login);
1177if ($search_product_category > 0) {
1178 $param .=
'&search_product_category='.urlencode((
string) $search_product_category);
1180if ($search_montant_ht !=
'') {
1181 $param .=
'&search_montant_ht='.urlencode($search_montant_ht);
1183if ($search_montant_vat !=
'') {
1184 $param .=
'&search_montant_vat='.urlencode($search_montant_vat);
1186if ($search_montant_localtax1 !=
'') {
1187 $param .=
'&search_montant_localtax1='.urlencode($search_montant_localtax1);
1189if ($search_montant_localtax2 !=
'') {
1190 $param .=
'&search_montant_localtax2='.urlencode($search_montant_localtax2);
1192if ($search_montant_ttc !=
'') {
1193 $param .=
'&search_montant_ttc='.urlencode($search_montant_ttc);
1195if ($search_multicurrency_code !=
'') {
1196 $param .=
'&search_multicurrency_code='.urlencode($search_multicurrency_code);
1198if ($search_multicurrency_tx !=
'') {
1199 $param .=
'&search_multicurrency_tx='.urlencode($search_multicurrency_tx);
1201if ($search_multicurrency_montant_ht !=
'') {
1202 $param .=
'&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht);
1204if ($search_multicurrency_montant_vat !=
'') {
1205 $param .=
'&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat);
1207if ($search_multicurrency_montant_ttc !=
'') {
1208 $param .=
'&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc);
1210if ($search_status !=
'') {
1211 $param .=
'&search_status='.urlencode($search_status);
1213if ($search_paymentmode > 0) {
1214 $param .=
'&search_paymentmode='.urlencode((
string) ($search_paymentmode));
1216if ($search_paymentterms > 0) {
1217 $param .=
'&search_paymentterms='.urlencode((
string) ($search_paymentterms));
1219if ($search_module_source) {
1220 $param .=
'&search_module_source='.urlencode($search_module_source);
1222if ($search_pos_source) {
1223 $param .=
'&search_pos_source='.urlencode($search_pos_source);
1225if ($search_option) {
1226 $param .=
"&search_option=".urlencode($search_option);
1228if ($search_categ_cus > 0) {
1229 $param .=
'&search_categ_cus='.urlencode((
string) ($search_categ_cus));
1231if (!empty($search_fac_rec_source_title)) {
1232 $param .=
'&search_fac_rec_source_title='.urlencode($search_fac_rec_source_title);
1234if ($search_fk_fac_rec_source) {
1235 $param .=
'&search_fk_fac_rec_source=' . (int) $search_fk_fac_rec_source;
1237if ($search_import_key !=
'') {
1238 $param .=
'&search_import_key='.urlencode($search_import_key);
1242include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
1244$parameters = array(
'param' => &$param);
1245$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
1246$param .= $hookmanager->resPrint;
1248$arrayofmassactions = array(
1249 'validate' =>
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Validate"),
1250 'generate_doc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
1251 'builddoc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
1252 'presend' =>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
1255if ($user->hasRight(
'facture',
'paiement')) {
1256 $arrayofmassactions[
'makepayment'] =
img_picto(
'',
'payment',
'class="pictofixedwidth"').$langs->trans(
"MakePaymentAndClassifyPayed");
1258if (isModEnabled(
'prelevement') && $user->hasRight(
'prelevement',
'bons',
'creer')) {
1259 $langs->load(
"withdrawals");
1260 $arrayofmassactions[
'withdrawrequest'] =
img_picto(
'',
'payment',
'class="pictofixedwidth"').$langs->trans(
"MakeWithdrawRequest");
1262if ($user->hasRight(
'facture',
'supprimer')) {
1264 $arrayofmassactions[
'predeletedraft'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Deletedraft");
1266 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
1269if (in_array($massaction, array(
'presend',
'predelete',
'makepayment'))) {
1270 $arrayofmassactions = array();
1272$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
1276if ($contextpage !=
'poslist') {
1277 $url = DOL_URL_ROOT.
'/compta/facture/card.php?action=create';
1279 $url .=
'&socid='.urlencode((
string)
$object->socid);
1282 $url .=
'&fac_rec='.urlencode((
string)
$object->id);
1284 $newcardbutton =
'';
1285 $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'));
1286 $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'));
1288 $newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewBill'),
'',
'fa fa-plus-circle', $url,
'', $user->hasRight(
"facture",
"creer"));
1292print
'<form method="POST" id="searchFormList" name="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
1293if ($optioncss !=
'') {
1294 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
1296print
'<input type="hidden" name="token" value="'.newToken().
'">';
1297print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
1298if (!in_array($massaction, array(
'makepayment'))) {
1299 print
'<input type="hidden" name="action" value="list">';
1301print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
1302print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
1303print
'<input type="hidden" name="search_status" value="'.$search_status.
'">';
1304print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
1305print
'<input type="hidden" name="socid" value="'.$socid.
'">';
1306print
'<input type="hidden" name="mode" value="'.$mode.
'">';
1308print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'bill', 0, $newcardbutton,
'', $limit, 0, 0, 1);
1310$topicmail =
"SendBillRef";
1311$modelmail =
"facture_send";
1313$trackid =
'inv'.$object->id;
1314include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
1316if ($massaction ==
'makepayment') {
1318 $formquestion = array(
1322 array(
'type' =>
'date',
'name' =>
'datepaiment',
'label' => $langs->trans(
"Date"),
'datenow' => 1),
1323 array(
'type' =>
'other',
'name' =>
'paiementid',
'label' => $langs->trans(
"PaymentMode"),
'value' => $form->select_types_paiements(
GETPOST(
'search_paymentmode'),
'paiementid',
'', 0, 0, 1, 0, 1,
'', 1)),
1324 array(
'type' =>
'other',
'name' =>
'bankid',
'label' => $langs->trans(
"BankAccount"),
'value' => $form->select_comptes(
'',
'bankid', 0,
'', 0,
'', 0,
'', 1)),
1327 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
'MakePaymentAndClassifyPayed'), $langs->trans(
'EnterPaymentReceivedFromCustomer'),
'makepayment_confirm', $formquestion, 1, 0, 200, 500, 1);
1332 foreach ($fieldstosearchall as $key => $val) {
1333 $fieldstosearchall[$key] = $langs->trans($val);
1335 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>';
1340if ($user->hasRight(
"user",
"user",
"lire")) {
1341 $langs->load(
"commercial");
1342 $moreforfilter .=
'<div class="divsearchfield">';
1343 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
1344 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'maxwidth200');
1345 $moreforfilter .=
'</div>';
1348if ($user->hasRight(
"user",
"user",
"lire")) {
1349 $moreforfilter .=
'<div class="divsearchfield">';
1350 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
1351 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth200');
1352 $moreforfilter .=
'</div>';
1355if (isModEnabled(
'category') && $user->hasRight(
"categorie",
"lire") && ($user->hasRight(
"produit",
"lire") || $user->hasRight(
"service",
"lire"))) {
1356 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1357 $moreforfilter .=
'<div class="divsearchfield">';
1358 $tmptitle = $langs->trans(
'IncludingProductWithTag');
1359 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 0, 0, 1);
1360 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0,
'', 0, 0, 0, 0,
'maxwidth300 widthcentpercentminusx', 1);
1361 $moreforfilter .=
'</div>';
1363if (isModEnabled(
'category') && $user->hasRight(
"categorie",
"lire")) {
1364 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1365 $moreforfilter .=
'<div class="divsearchfield">';
1366 $tmptitle = $langs->trans(
'CustomersProspectsCategoriesShort');
1367 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$formother->select_categories(
'customer', $search_categ_cus,
'search_categ_cus', 1, $tmptitle);
1368 $moreforfilter .=
'</div>';
1371$moreforfilter .=
'<div class="divsearchfield">';
1372$moreforfilter .=
'<label for="search_option">'.$langs->trans(
'Alert').
' </label><input type="checkbox" name="search_option" id="search_option" value="late"'.($search_option ==
'late' ?
' checked' :
'').
'>';
1373$moreforfilter .=
'</div>';
1375$parameters = array();
1376$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
1377if (empty($reshook)) {
1378 $moreforfilter .= $hookmanager->resPrint;
1380 $moreforfilter = $hookmanager->resPrint;
1383if (!empty($moreforfilter)) {
1384 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
1385 print $moreforfilter;
1389$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
1390$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
1393if ($massactionbutton && $contextpage !=
'poslist') {
1394 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
1397print
'<div class="div-table-responsive">';
1398print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
1402print
'<tr class="liste_titre_filter">';
1406 print
'<td class="liste_titre center maxwidthsearch actioncolumn">';
1407 $searchpicto = $form->showFilterButtons(
'left');
1413 print
'<td class="liste_titre">';
1417if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1418 print
'<td class="liste_titre" align="left">';
1419 print
'<input class="flat maxwidth50imp" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
1423if (!empty($arrayfields[
'f.ref_client'][
'checked'])) {
1424 print
'<td class="liste_titre">';
1425 print
'<input class="flat maxwidth50imp" type="text" name="search_refcustomer" value="'.dol_escape_htmltag($search_refcustomer).
'">';
1429if (!empty($arrayfields[
'f.type'][
'checked'])) {
1430 print
'<td class="liste_titre maxwidthonsmartphone">';
1442 print $form->selectarray(
'search_type', $listtype, $search_type, 1, 0, 0,
'', 0, 0, 0,
'',
'maxwidth100');
1446if (!empty($arrayfields[
'f.subtype'][
'checked'])) {
1447 print
'<td class="liste_titre maxwidthonsmartphone" align="center">';
1448 print $form->selectarray(
'search_subtype', $subtypearray, $search_subtype, 1, 0, 0,
'', 0, 0, 0,
'',
'maxwidth100');
1452if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1453 print
'<td class="liste_titre center">';
1454 print
'<div class="nowrapfordate">';
1455 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1457 print
'<div class="nowrapfordate">';
1458 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1463if (!empty($arrayfields[
'f.date_valid'][
'checked'])) {
1464 print
'<td class="liste_titre center">';
1465 print
'<div class="nowrapfordate">';
1466 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'));
1468 print
'<div class="nowrapfordate">';
1469 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'));
1474if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1475 print
'<td class="liste_titre center">';
1476 print
'<div class="nowrapfordate">';
1477 print $form->selectDate($search_datelimit_start ? $search_datelimit_start : -1,
'search_datelimit_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1479 print
'<div class="nowrapfordate">';
1480 print $form->selectDate($search_datelimit_end ? $search_datelimit_end : -1,
'search_datelimit_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1485if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1486 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).
'"></td>';
1489if (!empty($arrayfields[
'p.title'][
'checked'])) {
1490 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_project" value="'.dol_escape_htmltag($search_project).
'"></td>';
1493if (!empty($arrayfields[
's.nom'][
'checked'])) {
1494 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_company" value="'.dol_escape_htmltag($search_company).
'"'.($socid > 0 ?
" disabled" :
"").
'></td>';
1497if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1498 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).
'"></td>';
1501if (!empty($arrayfields[
's2.nom'][
'checked'])) {
1502 print
'<td class="liste_titre">';
1503 print
'<input class="flat maxwidth100" type="text" name="search_parent_name" value="'.dol_escape_htmltag($search_parent_name).
'">';
1507if (!empty($arrayfields[
's.code_client'][
'checked'])) {
1508 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_customer_code" value="'.dol_escape_htmltag($search_customer_code).
'"></td>';
1511if (!empty($arrayfields[
's.town'][
'checked'])) {
1512 print
'<td class="liste_titre"><input class="flat maxwidth75imp" type="text" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
1515if (!empty($arrayfields[
's.zip'][
'checked'])) {
1516 print
'<td class="liste_titre"><input class="flat maxwidth50imp" type="text" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
1519if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1520 print
'<td class="liste_titre">';
1521 print
'<input class="flat maxwidth50imp" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
1525if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1526 print
'<td class="liste_titre center">';
1527 print $form->select_country($search_country,
'search_country',
'', 0,
'minwidth150imp maxwidth150',
'code2', 1, 0, 1, array(), 1);
1531if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1532 print
'<td class="liste_titre maxwidthonsmartphone center">';
1533 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);
1537if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1538 print
'<td class="liste_titre">';
1539 print $form->select_types_paiements($search_paymentmode,
'search_paymentmode',
'', 0, 1, 1, 0, 1,
'minwidth100 maxwidth100', 1);
1543if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1544 print
'<td class="liste_titre left">';
1545 print $form->getSelectConditionsPaiements($search_paymentterms,
'search_paymentterms', -1, 1, 1,
'minwidth100 maxwidth100');
1549if (!empty($arrayfields[
'f.module_source'][
'checked'])) {
1550 print
'<td class="liste_titre">';
1551 print
'<input class="flat maxwidth75" type="text" name="search_module_source" value="'.dol_escape_htmltag($search_module_source).
'">';
1555if (!empty($arrayfields[
'f.pos_source'][
'checked'])) {
1556 print
'<td class="liste_titre">';
1557 print
'<input class="flat maxwidth50" type="text" name="search_pos_source" value="'.dol_escape_htmltag($search_pos_source).
'">';
1560if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1562 print
'<td class="liste_titre right">';
1563 print
'<input class="flat" type="text" size="4" name="search_montant_ht" value="'.dol_escape_htmltag($search_montant_ht).
'">';
1566if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
1568 print
'<td class="liste_titre right">';
1569 print
'<input class="flat" type="text" size="4" name="search_montant_vat" value="'.dol_escape_htmltag($search_montant_vat).
'">';
1572if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1574 print
'<td class="liste_titre right">';
1575 print
'<input class="flat" type="text" size="4" name="search_montant_localtax1" value="'.dol_escape_htmltag($search_montant_localtax1).
'">';
1578if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1580 print
'<td class="liste_titre right">';
1581 print
'<input class="flat" type="text" size="4" name="search_montant_localtax2" value="'.dol_escape_htmltag($search_montant_localtax2).
'">';
1584if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1586 print
'<td class="liste_titre right">';
1587 print
'<input class="flat" type="text" size="4" name="search_montant_ttc" value="'.dol_escape_htmltag($search_montant_ttc).
'">';
1590if (!empty($arrayfields[
'u.login'][
'checked'])) {
1592 print
'<td class="liste_titre" align="center">';
1593 print
'<input class="flat" size="4" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).
'">';
1596if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1597 print
'<td class="liste_titre"></td>';
1599if (!empty($arrayfields[
'f.retained_warranty'][
'checked'])) {
1600 print
'<td class="liste_titre" align="right">';
1603if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1604 print
'<td class="liste_titre right">';
1607if (!empty($arrayfields[
'rtp'][
'checked'])) {
1608 print
'<td class="liste_titre">';
1611if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1613 print
'<td class="liste_titre">';
1614 print $form->selectMultiCurrency($search_multicurrency_code,
'search_multicurrency_code', 1);
1617if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1619 print
'<td class="liste_titre">';
1620 print
'<input class="flat" type="text" size="4" name="search_multicurrency_tx" value="'.dol_escape_htmltag($search_multicurrency_tx).
'">';
1623if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1625 print
'<td class="liste_titre right">';
1626 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ht" value="'.dol_escape_htmltag($search_multicurrency_montant_ht).
'">';
1629if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1631 print
'<td class="liste_titre right">';
1632 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_vat" value="'.dol_escape_htmltag($search_multicurrency_montant_vat).
'">';
1635if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1637 print
'<td class="liste_titre right">';
1638 print
'<input class="flat" type="text" size="4" name="search_multicurrency_montant_ttc" value="'.dol_escape_htmltag($search_multicurrency_montant_ttc).
'">';
1641if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1642 print
'<td class="liste_titre">';
1645if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1646 print
'<td class="liste_titre right">';
1649if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1650 print
'<td class="liste_titre right">';
1653if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1654 print
'<td class="liste_titre right">';
1657if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1658 print
'<td class="liste_titre right">';
1661if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1662 print
'<td class="liste_titre right">';
1667include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
1670$parameters = array(
'arrayfields' => $arrayfields);
1671$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
1672print $hookmanager->resPrint;
1674if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1675 print
'<td class="liste_titre">';
1679if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1680 print
'<td class="liste_titre">';
1684if (!empty($arrayfields[
'f.date_closing'][
'checked'])) {
1685 print
'<td class="liste_titre">';
1688if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
1690 print
'<td class="liste_titre">';
1693if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
1695 print
'<td class="liste_titre">';
1698if (!empty($arrayfields[
'f.fk_fac_rec_source'][
'checked'])) {
1700 print
'<td class="liste_titre maxwidthonsmartphone right">';
1701 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).
'">';
1705if (!empty($arrayfields[
'f.import_key'][
'checked'])) {
1706 print
'<td class="liste_titre maxwidthonsmartphone center">';
1707 print
'<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).
'">';
1711if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1712 print
'<td class="liste_titre center parentonrightofpage">';
1713 $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"));
1715 print $form->selectarray(
'search_status', $liststatus, $search_status, 1, 0, 0,
'', 0, 0, 0,
'',
'search_status width100 onrightofpage', 1);
1720 print
'<td class="liste_titre center maxwidthsearch actioncolumn">';
1721 $searchpicto = $form->showFilterButtons();
1727$totalarray = array();
1728$totalarray[
'nbfield'] = 0;
1732print
'<tr class="liste_titre">';
1734 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
1735 $totalarray[
'nbfield']++;
1739 $totalarray[
'nbfield']++;
1741if (!empty($arrayfields[
'f.ref'][
'checked'])) {
1742 print_liste_field_titre($arrayfields[
'f.ref'][
'label'], $_SERVER[
'PHP_SELF'],
'f.ref',
'', $param,
'', $sortfield, $sortorder);
1743 $totalarray[
'nbfield']++;
1745if (!empty($arrayfields[
'f.ref_client'][
'checked'])) {
1746 print_liste_field_titre($arrayfields[
'f.ref_client'][
'label'], $_SERVER[
"PHP_SELF"],
'f.ref_client',
'', $param,
'', $sortfield, $sortorder);
1747 $totalarray[
'nbfield']++;
1749if (!empty($arrayfields[
'f.type'][
'checked'])) {
1750 print_liste_field_titre($arrayfields[
'f.type'][
'label'], $_SERVER[
"PHP_SELF"],
'f.type',
'', $param,
'', $sortfield, $sortorder);
1751 $totalarray[
'nbfield']++;
1753if (!empty($arrayfields[
'f.subtype'][
'checked'])) {
1754 print_liste_field_titre($arrayfields[
'f.subtype'][
'label'], $_SERVER[
"PHP_SELF"],
'f.subtype',
'', $param,
'', $sortfield, $sortorder);
1756if (!empty($arrayfields[
'f.datef'][
'checked'])) {
1757 print_liste_field_titre($arrayfields[
'f.datef'][
'label'], $_SERVER[
'PHP_SELF'],
'f.datef',
'', $param,
'', $sortfield, $sortorder,
'center ');
1758 $totalarray[
'nbfield']++;
1760if (!empty($arrayfields[
'f.date_valid'][
'checked'])) {
1761 print_liste_field_titre($arrayfields[
'f.date_valid'][
'label'], $_SERVER[
'PHP_SELF'],
'f.date_valid',
'', $param,
'', $sortfield, $sortorder,
'center ');
1762 $totalarray[
'nbfield']++;
1764if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
1765 print_liste_field_titre($arrayfields[
'f.date_lim_reglement'][
'label'], $_SERVER[
'PHP_SELF'],
"f.date_lim_reglement",
'', $param,
'', $sortfield, $sortorder,
'center ');
1766 $totalarray[
'nbfield']++;
1768if (!empty($arrayfields[
'p.ref'][
'checked'])) {
1769 $langs->load(
"projects");
1770 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
'PHP_SELF'],
"p.ref",
'', $param,
'', $sortfield, $sortorder);
1771 $totalarray[
'nbfield']++;
1773if (!empty($arrayfields[
'p.title'][
'checked'])) {
1774 print_liste_field_titre($arrayfields[
'p.title'][
'label'], $_SERVER[
'PHP_SELF'],
"p.title",
'', $param,
'', $sortfield, $sortorder);
1775 $totalarray[
'nbfield']++;
1777if (!empty($arrayfields[
's.nom'][
'checked'])) {
1778 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
'PHP_SELF'],
's.nom',
'', $param,
'', $sortfield, $sortorder);
1779 $totalarray[
'nbfield']++;
1781if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
1783 print_liste_field_titre($arrayfields[
's.name_alias'][
'label'], $_SERVER[
'PHP_SELF'],
's.name_alias',
'', $param,
'', $sortfield, $sortorder);
1784 $totalarray[
'nbfield']++;
1786if (!empty($arrayfields[
's2.nom'][
'checked'])) {
1787 print_liste_field_titre($arrayfields[
's2.nom'][
'label'], $_SERVER[
'PHP_SELF'],
's2.nom',
'', $param,
'', $sortfield, $sortorder);
1788 $totalarray[
'nbfield']++;
1790if (!empty($arrayfields[
's.code_client'][
'checked'])) {
1791 print_liste_field_titre($arrayfields[
's.code_client'][
'label'], $_SERVER[
'PHP_SELF'],
's.code_client',
'', $param,
'', $sortfield, $sortorder);
1792 $totalarray[
'nbfield']++;
1794if (!empty($arrayfields[
's.town'][
'checked'])) {
1795 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1796 $totalarray[
'nbfield']++;
1798if (!empty($arrayfields[
's.zip'][
'checked'])) {
1799 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1800 $totalarray[
'nbfield']++;
1802if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1803 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1804 $totalarray[
'nbfield']++;
1806if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1807 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1808 $totalarray[
'nbfield']++;
1810if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1811 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1812 $totalarray[
'nbfield']++;
1814if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
1815 print_liste_field_titre($arrayfields[
'f.fk_mode_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_mode_reglement",
"", $param,
"", $sortfield, $sortorder);
1816 $totalarray[
'nbfield']++;
1818if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
1819 print_liste_field_titre($arrayfields[
'f.fk_cond_reglement'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_cond_reglement",
"", $param,
"", $sortfield, $sortorder);
1820 $totalarray[
'nbfield']++;
1822if (!empty($arrayfields[
'f.module_source'][
'checked'])) {
1823 print_liste_field_titre($arrayfields[
'f.module_source'][
'label'], $_SERVER[
"PHP_SELF"],
"f.module_source",
"", $param,
"", $sortfield, $sortorder);
1824 $totalarray[
'nbfield']++;
1826if (!empty($arrayfields[
'f.pos_source'][
'checked'])) {
1827 print_liste_field_titre($arrayfields[
'f.pos_source'][
'label'], $_SERVER[
"PHP_SELF"],
"f.pos_source",
"", $param,
"", $sortfield, $sortorder);
1828 $totalarray[
'nbfield']++;
1830if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
1831 print_liste_field_titre($arrayfields[
'f.total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ht',
'', $param,
'', $sortfield, $sortorder,
'right ');
1832 $totalarray[
'nbfield']++;
1834if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
1835 print_liste_field_titre($arrayfields[
'f.total_tva'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_tva',
'', $param,
'', $sortfield, $sortorder,
'right ');
1836 $totalarray[
'nbfield']++;
1838if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
1839 print_liste_field_titre($arrayfields[
'f.total_localtax1'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax1',
'', $param,
'', $sortfield, $sortorder,
'right ');
1840 $totalarray[
'nbfield']++;
1842if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
1843 print_liste_field_titre($arrayfields[
'f.total_localtax2'][
'label'], $_SERVER[
'PHP_SELF'],
'f.localtax2',
'', $param,
'', $sortfield, $sortorder,
'right ');
1844 $totalarray[
'nbfield']++;
1846if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
1847 print_liste_field_titre($arrayfields[
'f.total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.total_ttc',
'', $param,
'', $sortfield, $sortorder,
'right ');
1848 $totalarray[
'nbfield']++;
1850if (!empty($arrayfields[
'u.login'][
'checked'])) {
1851 print_liste_field_titre($arrayfields[
'u.login'][
'label'], $_SERVER[
"PHP_SELF"],
'u.login',
'', $param,
'', $sortfield, $sortorder,
'center ');
1852 $totalarray[
'nbfield']++;
1854if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1855 print_liste_field_titre($arrayfields[
'sale_representative'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"",
"$param",
'', $sortfield, $sortorder);
1856 $totalarray[
'nbfield']++;
1858if (!empty($arrayfields[
'f.retained_warranty'][
'checked'])) {
1859 print_liste_field_titre($arrayfields[
'f.retained_warranty'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1860 $totalarray[
'nbfield']++;
1862if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
1863 print_liste_field_titre($arrayfields[
'dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1864 $totalarray[
'nbfield']++;
1866if (!empty($arrayfields[
'rtp'][
'checked'])) {
1867 print_liste_field_titre($arrayfields[
'rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1868 $totalarray[
'nbfield']++;
1870if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
1871 print_liste_field_titre($arrayfields[
'f.multicurrency_code'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_code',
'', $param,
'', $sortfield, $sortorder);
1872 $totalarray[
'nbfield']++;
1874if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
1875 print_liste_field_titre($arrayfields[
'f.multicurrency_tx'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_tx',
'', $param,
'', $sortfield, $sortorder);
1876 $totalarray[
'nbfield']++;
1878if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
1879 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ht'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ht',
'', $param,
'', $sortfield, $sortorder,
'right ');
1880 $totalarray[
'nbfield']++;
1882if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
1883 print_liste_field_titre($arrayfields[
'f.multicurrency_total_vat'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_tva',
'', $param,
'', $sortfield, $sortorder,
'right ');
1884 $totalarray[
'nbfield']++;
1886if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
1887 print_liste_field_titre($arrayfields[
'f.multicurrency_total_ttc'][
'label'], $_SERVER[
'PHP_SELF'],
'f.multicurrency_total_ttc',
'', $param,
'', $sortfield, $sortorder,
'right ');
1888 $totalarray[
'nbfield']++;
1890if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
1891 print_liste_field_titre($arrayfields[
'multicurrency_dynamount_payed'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1892 $totalarray[
'nbfield']++;
1894if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
1895 print_liste_field_titre($arrayfields[
'multicurrency_rtp'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1896 $totalarray[
'nbfield']++;
1898if (!empty($arrayfields[
'total_pa'][
'checked'])) {
1899 print_liste_field_titre($arrayfields[
'total_pa'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1900 $totalarray[
'nbfield']++;
1902if (!empty($arrayfields[
'total_margin'][
'checked'])) {
1903 print_liste_field_titre($arrayfields[
'total_margin'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1904 $totalarray[
'nbfield']++;
1906if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
1907 print_liste_field_titre($arrayfields[
'total_margin_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1908 $totalarray[
'nbfield']++;
1910if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
1911 print_liste_field_titre($arrayfields[
'total_mark_rate'][
'label'], $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'right ');
1912 $totalarray[
'nbfield']++;
1915include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1917$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => $totalarray);
1918$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1919print $hookmanager->resPrint;
1920if (!empty($arrayfields[
'f.datec'][
'checked'])) {
1921 print_liste_field_titre($arrayfields[
'f.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"f.datec",
"", $param,
'', $sortfield, $sortorder,
'nowraponall center ');
1922 $totalarray[
'nbfield']++;
1924if (!empty($arrayfields[
'f.tms'][
'checked'])) {
1925 print_liste_field_titre($arrayfields[
'f.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"f.tms",
"", $param,
'', $sortfield, $sortorder,
'nowraponall center ');
1926 $totalarray[
'nbfield']++;
1928if (!empty($arrayfields[
'f.date_closing'][
'checked'])) {
1929 print_liste_field_titre($arrayfields[
'f.date_closing'][
'label'], $_SERVER[
"PHP_SELF"],
"f.date_closing",
"", $param,
'', $sortfield, $sortorder,
'nowraponall center ');
1930 $totalarray[
'nbfield']++;
1932if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
1933 print_liste_field_titre($arrayfields[
'f.note_public'][
'label'], $_SERVER[
"PHP_SELF"],
"f.note_public",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1934 $totalarray[
'nbfield']++;
1936if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
1937 print_liste_field_titre($arrayfields[
'f.note_private'][
'label'], $_SERVER[
"PHP_SELF"],
"f.note_private",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1938 $totalarray[
'nbfield']++;
1940if (!empty($arrayfields[
'f.fk_fac_rec_source'][
'checked'])) {
1941 print_liste_field_titre($arrayfields[
'f.fk_fac_rec_source'][
'label'], $_SERVER[
"PHP_SELF"],
"facrec.titre",
"", $param,
'', $sortfield, $sortorder);
1942 $totalarray[
'nbfield']++;
1945if (!empty($arrayfields[
'f.import_key'][
'checked'])) {
1946 print_liste_field_titre($arrayfields[
'f.import_key'][
'label'], $_SERVER[
"PHP_SELF"],
"f.import_key",
"", $param,
'', $sortfield, $sortorder,
'center ');
1947 $totalarray[
'nbfield']++;
1950if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
1951 print_liste_field_titre($arrayfields[
'f.fk_statut'][
'label'], $_SERVER[
"PHP_SELF"],
"f.fk_statut,f.paye,f.type",
"", $param,
'', $sortfield, $sortorder,
'center ');
1952 $totalarray[
'nbfield']++;
1955 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'maxwidthsearch center ');
1956 $totalarray[
'nbfield']++;
1961$projectstatic =
new Project($db);
1963$userstatic =
new User($db);
1969 $savnbfield = $totalarray[
'nbfield'];
1970 $totalarray = array();
1971 $totalarray[
'nbfield'] = 0;
1972 $totalarray[
'val'] = array();
1973 $totalarray[
'val'][
'f.total_ht'] = 0;
1974 $totalarray[
'val'][
'f.total_tva'] = 0;
1975 $totalarray[
'val'][
'f.total_localtax1'] = 0;
1976 $totalarray[
'val'][
'f.total_localtax1'] = 0;
1977 $totalarray[
'val'][
'f.total_ttc'] = 0;
1978 $totalarray[
'val'][
'dynamount_payed'] = 0;
1979 $totalarray[
'val'][
'rtp'] = 0;
1981 $typenArray = $formcompany->typent_array(1);
1983 $with_margin_info =
false;
1984 if (isModEnabled(
'margin') && (
1985 !empty($arrayfields[
'total_pa'][
'checked'])
1986 || !empty($arrayfields[
'total_margin'][
'checked'])
1987 || !empty($arrayfields[
'total_margin_rate'][
'checked'])
1988 || !empty($arrayfields[
'total_mark_rate'][
'checked'])
1991 $with_margin_info =
true;
1996 $imaxinloop = ($limit ? min($num, $limit) : $num);
1997 while ($i < $imaxinloop) {
1998 $obj = $db->fetch_object($resql);
2000 $datelimit = $db->jdate($obj->datelimite);
2002 $facturestatic->id = $obj->id;
2003 $facturestatic->ref = $obj->ref;
2004 $facturestatic->ref_client = $obj->ref_client;
2005 $facturestatic->ref_customer = $obj->ref_client;
2006 $facturestatic->type = $obj->type;
2007 $facturestatic->subtype = $obj->subtype;
2008 $facturestatic->total_ht = $obj->total_ht;
2009 $facturestatic->total_tva = $obj->total_tva;
2010 $facturestatic->total_ttc = $obj->total_ttc;
2011 $facturestatic->multicurrency_code = $obj->multicurrency_code;
2012 $facturestatic->multicurrency_tx = $obj->multicurrency_tx;
2013 $facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht;
2014 $facturestatic->multicurrency_total_tva = $obj->multicurrency_total_vat;
2015 $facturestatic->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
2016 $facturestatic->statut = $obj->fk_statut;
2017 $facturestatic->status = $obj->fk_statut;
2018 $facturestatic->close_code = $obj->close_code;
2019 $facturestatic->total_ttc = $obj->total_ttc;
2020 $facturestatic->paye = $obj->paye;
2021 $facturestatic->socid = $obj->fk_soc;
2023 $facturestatic->date = $db->jdate($obj->datef);
2024 $facturestatic->date_validation = $db->jdate($obj->date_valid);
2025 $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite);
2027 $facturestatic->note_public = $obj->note_public;
2028 $facturestatic->note_private = $obj->note_private;
2031 $facturestatic->retained_warranty = $obj->retained_warranty;
2032 $facturestatic->retained_warranty_date_limit = $obj->retained_warranty_date_limit;
2033 $facturestatic->situation_final = $obj->retained_warranty_date_limit;
2034 $facturestatic->situation_final = $obj->retained_warranty_date_limit;
2035 $facturestatic->situation_cycle_ref = $obj->situation_cycle_ref;
2036 $facturestatic->situation_counter = $obj->situation_counter;
2039 $companystatic->id = $obj->socid;
2040 $companystatic->name = $obj->name;
2041 $companystatic->name_alias = $obj->alias;
2042 $companystatic->client = $obj->client;
2043 $companystatic->fournisseur = $obj->fournisseur;
2044 $companystatic->code_client = $obj->code_client;
2045 $companystatic->code_compta_client = $obj->code_compta_client;
2046 $companystatic->code_fournisseur = $obj->code_fournisseur;
2047 $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
2048 $companystatic->email = $obj->email;
2049 $companystatic->phone = $obj->phone;
2050 $companystatic->fax = $obj->fax;
2051 $companystatic->address = $obj->address;
2052 $companystatic->zip = $obj->zip;
2053 $companystatic->town = $obj->town;
2054 $companystatic->country_code = $obj->country_code;
2056 $projectstatic->id = $obj->project_id;
2057 $projectstatic->ref = $obj->project_ref;
2058 $projectstatic->title = $obj->project_label;
2060 $paiement = $facturestatic->getSommePaiement();
2061 $totalcreditnotes = $facturestatic->getSumCreditNotesUsed();
2062 $totaldeposits = $facturestatic->getSumDepositsUsed();
2063 $totalallpayments = $paiement + $totalcreditnotes + $totaldeposits;
2064 $remaintopay = $obj->total_ttc - $totalallpayments;
2066 $multicurrency_paiement = $facturestatic->getSommePaiement(1);
2067 $multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1);
2068 $multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1);
2070 $totalallpayments = $paiement + $totalcreditnotes + $totaldeposits;
2071 $remaintopay =
price2num($facturestatic->total_ttc - $totalallpayments);
2073 $multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits;
2074 $multicurrency_remaintopay =
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay);
2078 $multicurrency_remaintopay = 0;
2081 $remaincreditnote = $discount->getAvailableDiscounts($companystatic,
null,
'rc.fk_facture_source='.$facturestatic->id);
2082 $remaintopay = -$remaincreditnote;
2083 $totalallpayments =
price2num($facturestatic->total_ttc - $remaintopay);
2084 $multicurrency_remaincreditnote = $discount->getAvailableDiscounts($companystatic,
null,
'rc.fk_facture_source='.$facturestatic->id, 0, 0, 1);
2085 $multicurrency_remaintopay = -$multicurrency_remaincreditnote;
2086 $multicurrency_totalpay =
price2num($facturestatic->multicurrency_total_ttc - $multicurrency_remaintopay);
2089 $facturestatic->alreadypaid = $paiement;
2090 $facturestatic->totalpaid = $paiement;
2091 $facturestatic->totalcreditnotes = $totalcreditnotes;
2092 $facturestatic->totaldeposits = $totaldeposits;
2094 $marginInfo = array();
2095 if ($with_margin_info) {
2096 $facturestatic->fetch_lines();
2097 $marginInfo = $formmargin->getMarginInfosArray($facturestatic);
2098 $total_ht += $obj->total_ht;
2099 $total_margin += $marginInfo[
'total_margin'];
2104 if ($mode ==
'kanban') {
2106 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
2107 print
'<div class="box-flex-container kanban">';
2110 if ($massactionbutton || $massaction) {
2112 if (in_array(
$object->id, $arrayofselected)) {
2117 $arraydata = array(
'alreadypaid' => $paiement,
'thirdparty' => $companystatic->getNomUrl(1,
'', 12),
'userauthor' => $userstatic->getNomUrl(1),
'selected' => in_array(
$object->id, $arrayofselected));
2118 print $facturestatic->getKanbanView(
'', $arraydata);
2119 if ($i == ($imaxinloop - 1)) {
2126 print
'<tr data-rowid="'.$object->id.
'" class="oddeven"';
2127 if ($contextpage ==
'poslist') {
2128 print
' onclick="parent.$(\'#poslines\').load(\'invoice.php?action=history&placeid='.$obj->id.
'\',
function() {parent.$.colorbox.close();
';
2129 if (strpos($obj->ref, 'PROV
') !== false) {
2130 //If is a draft invoice, load var to be able to add products
2131 $place = str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref));
2132 print 'parent.place=\
''.dol_escape_js($place).
'\'';
2140 print
'<td class="nowrap center">';
2141 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
2143 if (in_array($obj->id, $arrayofselected)) {
2146 print
'<input id="cb'.$obj->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2150 $totalarray[
'nbfield']++;
2156 print
'<td>'.(($offset * $limit) + $i).
'</td>';
2158 $totalarray[
'nbfield']++;
2163 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
2164 print
'<td class="nowraponall">';
2166 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
2168 print
'<td class="nobordernopadding nowraponall">';
2169 if ($contextpage ==
'poslist') {
2172 print $facturestatic->getNomUrl(1,
'', 200, 0,
'', 0, 1);
2176 $filepath =
$conf->invoice->multidir_output[$obj->entity] ??
$conf->invoice->dir_output;
2177 $filedir = $filepath.
'/'.$filename;
2179 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->id;
2180 print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
2187 $totalarray[
'nbfield']++;
2192 if (!empty($arrayfields[
'f.ref_client'][
'checked'])) {
2193 print
'<td class="nowrap tdoverflowmax200">';
2197 $totalarray[
'nbfield']++;
2202 if (!empty($arrayfields[
'f.type'][
'checked'])) {
2203 print
'<td class="nowraponall tdoverflowmax100" title="'.$facturestatic->getLibType().
'">';
2204 print $facturestatic->getLibType(2);
2207 $totalarray[
'nbfield']++;
2212 if (!empty($arrayfields[
'f.subtype'][
'checked'])) {
2214 if ($facturestatic->subtype > 0) {
2215 $labeltoshow = $facturestatic->getSubtypeLabel(
'facture');
2217 print
'<td class="nowraponall tdoverflowmax300" title="'.$labeltoshow.
'">';
2221 $totalarray[
'nbfield']++;
2226 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
2227 print
'<td align="center" class="nowraponall">';
2231 $totalarray[
'nbfield']++;
2236 if (!empty($arrayfields[
'f.date_valid'][
'checked'])) {
2237 print
'<td align="center" class="nowraponall">';
2241 $totalarray[
'nbfield']++;
2246 if (!empty($arrayfields[
'f.date_lim_reglement'][
'checked'])) {
2247 print
'<td align="center" class="nowraponall">'.dol_print_date($datelimit,
'day');
2248 if ($facturestatic->hasDelay()) {
2249 print
img_warning($langs->trans(
'Alert').
' - '.$langs->trans(
'Late'));
2253 $totalarray[
'nbfield']++;
2258 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
2259 print
'<td class="nocellnopadd nowraponall">';
2260 if ($obj->project_id > 0) {
2261 print $projectstatic->getNomUrl(1);
2265 $totalarray[
'nbfield']++;
2270 if (!empty($arrayfields[
'p.title'][
'checked'])) {
2271 print
'<td class="nowraponall">';
2272 if ($obj->project_id > 0) {
2277 $totalarray[
'nbfield']++;
2282 if (!empty($arrayfields[
's.nom'][
'checked'])) {
2283 print
'<td class="tdoverflowmax150">';
2284 if ($contextpage ==
'poslist') {
2287 print $companystatic->getNomUrl(1,
'customer', 0, 0, -1, empty($arrayfields[
's.name_alias'][
'checked']) ? 0 : 1);
2291 $totalarray[
'nbfield']++;
2295 if (!empty($arrayfields[
's.name_alias'][
'checked'])) {
2296 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->name_alias).
'">';
2300 $totalarray[
'nbfield']++;
2304 if (!empty($arrayfields[
's2.nom'][
'checked'])) {
2305 print
'<td class="tdoverflowmax200">';
2306 if ($obj->fk_parent > 0) {
2307 if (!isset($company_url_list[$obj->fk_parent])) {
2308 $companyparent =
new Societe($db);
2309 $res = $companyparent->fetch($obj->fk_parent);
2311 $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1);
2314 if (isset($company_url_list[$obj->fk_parent])) {
2315 print $company_url_list[$obj->fk_parent];
2320 $totalarray[
'nbfield']++;
2324 if (!empty($arrayfields[
's.code_client'][
'checked'])) {
2325 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($companystatic->code_client).
'">';
2329 $totalarray[
'nbfield']++;
2333 if (!empty($arrayfields[
's.town'][
'checked'])) {
2334 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->town).
'">';
2338 $totalarray[
'nbfield']++;
2342 if (!empty($arrayfields[
's.zip'][
'checked'])) {
2343 print
'<td class="nowraponall">';
2347 $totalarray[
'nbfield']++;
2351 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
2352 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($obj->state_name).
'">'.
dol_escape_htmltag($obj->state_name).
"</td>\n";
2354 $totalarray[
'nbfield']++;
2358 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
2359 $tmparray =
getCountry($obj->fk_pays,
'all');
2360 print
'<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($tmparray[
'label']).
'">';
2364 $totalarray[
'nbfield']++;
2368 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
2369 if (!is_array($typenArray) || count($typenArray) == 0) {
2370 $typenArray = $formcompany->typent_array(1);
2372 print
'<td class="center tdoverflowmax100" title="'.dolPrintHTML($typenArray[$obj->typent_code]).
'">';
2373 if (!empty($obj->typent_code)) {
2374 print $typenArray[$obj->typent_code];
2378 $totalarray[
'nbfield']++;
2382 if (!empty($arrayfields[
'staff.code'][
'checked'])) {
2383 if (!is_array(
$conf->cache[
'staff']) || count(
$conf->cache[
'staff']) == 0) {
2384 $conf->cache[
'staff'] = $formcompany->effectif_array(1);
2386 print
'<td class="center tdoverflowmax100" title="'.dolPrintHTML(
$conf->cache[
'staff'][$obj->staff_code]).
'">';
2387 print
$conf->cache[
'staff'][$obj->staff_code];
2390 $totalarray[
'nbfield']++;
2395 if (!empty($arrayfields[
'f.fk_mode_reglement'][
'checked'])) {
2396 $s = $form->form_modes_reglement($_SERVER[
'PHP_SELF'], $obj->fk_mode_reglement,
'none',
'', -1, 0,
'', 1);
2397 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
2401 $totalarray[
'nbfield']++;
2406 if (!empty($arrayfields[
'f.fk_cond_reglement'][
'checked'])) {
2407 $s = $form->form_conditions_reglement($_SERVER[
'PHP_SELF'], $obj->fk_cond_reglement,
'none', 0,
'', -1, -1, 1);
2408 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($s).
'">';
2412 $totalarray[
'nbfield']++;
2417 if (!empty($arrayfields[
'f.module_source'][
'checked'])) {
2422 $totalarray[
'nbfield']++;
2427 if (!empty($arrayfields[
'f.pos_source'][
'checked'])) {
2432 $totalarray[
'nbfield']++;
2437 if (!empty($arrayfields[
'f.total_ht'][
'checked'])) {
2438 print
'<td class="right nowraponall amount">'.price($obj->total_ht).
"</td>\n";
2440 $totalarray[
'nbfield']++;
2443 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ht';
2445 $totalarray[
'val'][
'f.total_ht'] += $obj->total_ht;
2448 if (!empty($arrayfields[
'f.total_tva'][
'checked'])) {
2449 print
'<td class="right nowraponall amount">'.price($obj->total_tva).
"</td>\n";
2451 $totalarray[
'nbfield']++;
2454 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_tva';
2456 $totalarray[
'val'][
'f.total_tva'] += $obj->total_tva;
2459 if (!empty($arrayfields[
'f.total_localtax1'][
'checked'])) {
2460 print
'<td class="right nowraponall amount">'.price($obj->total_localtax1).
"</td>\n";
2462 $totalarray[
'nbfield']++;
2465 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_localtax1';
2467 $totalarray[
'val'][
'f.total_localtax1'] += $obj->total_localtax1;
2470 if (!empty($arrayfields[
'f.total_localtax2'][
'checked'])) {
2471 print
'<td class="right nowraponall amount">'.price($obj->total_localtax2).
"</td>\n";
2473 $totalarray[
'nbfield']++;
2476 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_localtax2';
2478 $totalarray[
'val'][
'f.total_localtax2'] += $obj->total_localtax2;
2481 if (!empty($arrayfields[
'f.total_ttc'][
'checked'])) {
2482 print
'<td class="right nowraponall amount">'.price($obj->total_ttc).
"</td>\n";
2484 $totalarray[
'nbfield']++;
2487 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'f.total_ttc';
2489 $totalarray[
'val'][
'f.total_ttc'] += $obj->total_ttc;
2492 $userstatic->id = $obj->fk_user_author;
2493 $userstatic->login = $obj->login;
2494 $userstatic->lastname = $obj->lastname;
2495 $userstatic->firstname = $obj->firstname;
2496 $userstatic->email = $obj->user_email;
2497 $userstatic->status = $obj->user_statut;
2498 $userstatic->entity = $obj->entity;
2499 $userstatic->photo = $obj->photo;
2500 $userstatic->office_phone = $obj->office_phone;
2501 $userstatic->office_fax = $obj->office_fax;
2502 $userstatic->user_mobile = $obj->user_mobile;
2503 $userstatic->job = $obj->job;
2504 $userstatic->gender = $obj->gender;
2507 if (!empty($arrayfields[
'u.login'][
'checked'])) {
2508 print
'<td class="tdoverflowmax200">';
2509 if ($userstatic->id) {
2510 print $userstatic->getNomUrl(-1);
2516 $totalarray[
'nbfield']++;
2520 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
2523 if ($obj->socid > 0) {
2524 $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user);
2525 if ($listsalesrepresentatives < 0) {
2528 $nbofsalesrepresentative = count($listsalesrepresentatives);
2529 if ($nbofsalesrepresentative > 6) {
2531 print $nbofsalesrepresentative;
2532 } elseif ($nbofsalesrepresentative > 0) {
2534 foreach ($listsalesrepresentatives as $val) {
2535 $userstatic->id = $val[
'id'];
2536 $userstatic->lastname = $val[
'lastname'];
2537 $userstatic->firstname = $val[
'firstname'];
2538 $userstatic->email = $val[
'email'];
2539 $userstatic->status = $val[
'statut'];
2540 $userstatic->entity = $val[
'entity'];
2541 $userstatic->photo = $val[
'photo'];
2542 $userstatic->login = $val[
'login'];
2543 $userstatic->office_phone = $val[
'office_phone'];
2544 $userstatic->office_fax = $val[
'office_fax'];
2545 $userstatic->user_mobile = $val[
'user_mobile'];
2546 $userstatic->job = $val[
'job'];
2547 $userstatic->gender = $val[
'gender'];
2549 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1,
'', 0, 0, 12) : $userstatic->getNomUrl(-2);
2551 if ($j < $nbofsalesrepresentative) {
2561 $totalarray[
'nbfield']++;
2565 if (!empty($arrayfields[
'f.retained_warranty'][
'checked'])) {
2566 print
'<td align="right">'.(!empty($obj->retained_warranty) ?
price($obj->retained_warranty).
'%' :
' ').
'</td>';
2568 $totalarray[
'nbfield']++;
2572 if (!empty($arrayfields[
'dynamount_payed'][
'checked'])) {
2573 print
'<td class="right nowraponall amount">'.(!empty($totalallpayments) ?
price($totalallpayments, 0, $langs) :
' ').
'</td>';
2575 $totalarray[
'nbfield']++;
2578 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'dynamount_payed';
2580 $totalarray[
'val'][
'dynamount_payed'] += $totalallpayments;
2584 if (!empty($arrayfields[
'rtp'][
'checked'])) {
2585 print
'<td class="right nowraponall amount">';
2586 print(!empty($remaintopay) ?
price($remaintopay, 0, $langs) :
' ');
2589 $totalarray[
'nbfield']++;
2592 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'rtp';
2594 $totalarray[
'val'][
'rtp'] += $remaintopay;
2599 if (!empty($arrayfields[
'f.multicurrency_code'][
'checked'])) {
2600 print
'<td class="nowraponall tdoverflowmax125" title="'.dol_escape_htmltag($obj->multicurrency_code.
' - '.$langs->transnoentitiesnoconv(
'Currency'.$obj->multicurrency_code)).
'">';
2602 print $langs->transnoentitiesnoconv(
'Currency'.$obj->multicurrency_code);
2608 $totalarray[
'nbfield']++;
2613 if (!empty($arrayfields[
'f.multicurrency_tx'][
'checked'])) {
2614 print
'<td class="nowraponall">';
2615 $form->form_multicurrency_rate($_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid, $obj->multicurrency_tx,
'none', $obj->multicurrency_code);
2618 $totalarray[
'nbfield']++;
2622 if (!empty($arrayfields[
'f.multicurrency_total_ht'][
'checked'])) {
2623 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_total_ht).
"</td>\n";
2625 $totalarray[
'nbfield']++;
2629 if (!empty($arrayfields[
'f.multicurrency_total_vat'][
'checked'])) {
2630 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_total_vat).
"</td>\n";
2632 $totalarray[
'nbfield']++;
2636 if (!empty($arrayfields[
'f.multicurrency_total_ttc'][
'checked'])) {
2637 print
'<td class="right nowraponall amount">'.price($obj->multicurrency_total_ttc).
"</td>\n";
2639 $totalarray[
'nbfield']++;
2643 if (!empty($arrayfields[
'multicurrency_dynamount_payed'][
'checked'])) {
2644 print
'<td class="right nowraponall amount">'.(!empty($multicurrency_totalpay) ?
price($multicurrency_totalpay, 0, $langs) :
' ').
'</td>';
2646 $totalarray[
'nbfield']++;
2651 if (!empty($arrayfields[
'multicurrency_rtp'][
'checked'])) {
2652 print
'<td class="right nowraponall amount">';
2653 print(!empty($multicurrency_remaintopay) ?
price($multicurrency_remaintopay, 0, $langs) :
' ');
2656 $totalarray[
'nbfield']++;
2661 if (!empty($arrayfields[
'total_pa'][
'checked'])) {
2662 print
'<td class="right nowrap">'.price($marginInfo[
'pa_total'], 0, $langs, 1, -1,
'MT').
'</td>';
2664 $totalarray[
'nbfield']++;
2665 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_pa';
2667 if (empty($totalarray[
'val'][
'total_pa'])) {
2668 $totalarray[
'val'][
'total_pa'] = 0;
2670 $totalarray[
'val'][
'total_pa'] += $marginInfo[
'pa_total'];
2673 if (!empty($arrayfields[
'total_margin'][
'checked'])) {
2674 print
'<td class="right nowrap">'.price($marginInfo[
'total_margin'], 0, $langs, 1, -1,
'MT').
'</td>';
2676 $totalarray[
'nbfield']++;
2677 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_margin';
2679 if (empty($totalarray[
'val'][
'total_margin'])) {
2680 $totalarray[
'val'][
'total_margin'] = 0;
2682 $totalarray[
'val'][
'total_margin'] += $marginInfo[
'total_margin'];
2685 if (!empty($arrayfields[
'total_margin_rate'][
'checked'])) {
2686 print
'<td class="right nowrap">'.(($marginInfo[
'total_margin_rate'] ==
'') ?
'' :
price($marginInfo[
'total_margin_rate'], 0,
'', 0, 0, 2).
'%').
'</td>';
2688 $totalarray[
'nbfield']++;
2692 if (!empty($arrayfields[
'total_mark_rate'][
'checked'])) {
2693 print
'<td class="right nowrap">'.(($marginInfo[
'total_mark_rate'] ==
'') ?
'' :
price($marginInfo[
'total_mark_rate'], 0,
'', 0, 0, 2).
'%').
'</td>';
2695 $totalarray[
'nbfield']++;
2696 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'total_mark_rate';
2698 if ($i >= $imaxinloop - 1) {
2699 if (!empty($total_ht)) {
2700 $totalarray[
'val'][
'total_mark_rate'] =
price2num($total_margin * 100 / $total_ht,
'MT');
2702 $totalarray[
'val'][
'total_mark_rate'] =
'';
2708 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
2710 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
2711 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
2712 print $hookmanager->resPrint;
2714 if (!empty($arrayfields[
'f.datec'][
'checked'])) {
2715 print
'<td class="nowraponall center">';
2716 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
2719 $totalarray[
'nbfield']++;
2723 if (!empty($arrayfields[
'f.tms'][
'checked'])) {
2724 print
'<td class="nowraponall center">';
2725 print
dol_print_date($db->jdate($obj->date_modification),
'dayhour',
'tzuser');
2728 $totalarray[
'nbfield']++;
2732 if (!empty($arrayfields[
'f.date_closing'][
'checked'])) {
2733 print
'<td class="nowraponall center">';
2734 print
dol_print_date($db->jdate($obj->date_closing),
'dayhour',
'tzuser');
2737 $totalarray[
'nbfield']++;
2741 if (!empty($arrayfields[
'f.note_public'][
'checked'])) {
2742 print
'<td class="sensiblehtmlcontent center">';
2746 $totalarray[
'nbfield']++;
2750 if (!empty($arrayfields[
'f.note_private'][
'checked'])) {
2751 print
'<td class="center">';
2755 $totalarray[
'nbfield']++;
2759 if (!empty($arrayfields[
'f.fk_fac_rec_source'][
'checked'])) {
2760 print
'<td class="center">';
2761 if (!empty($obj->fk_fac_rec_source)) {
2763 $result = $facrec->fetch($obj->fk_fac_rec_source);
2767 print $facrec->getNomUrl();
2772 $totalarray[
'nbfield']++;
2777 if (!empty($arrayfields[
'f.import_key'][
'checked'])) {
2778 print
'<td class="nowrap center">'.dol_escape_htmltag($obj->import_key).
'</td>';
2780 $totalarray[
'nbfield']++;
2785 if (!empty($arrayfields[
'f.fk_statut'][
'checked'])) {
2786 print
'<td class="nowrap center">';
2787 print $facturestatic->getLibStatut(5, $totalallpayments);
2790 $totalarray[
'nbfield']++;
2797 print
'<td class="nowrap center">';
2798 if (($massactionbutton || $massaction) && $contextpage !=
'poslist') {
2800 if (in_array($obj->id, $arrayofselected)) {
2803 print
'<input id="cb'.$obj->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
2807 $totalarray[
'nbfield']++;
2818 $totalarray[
'val'][
'total_pa'] = (isset($totalarray[
'val'][
'total_pa']) ?
price2num($totalarray[
'val'][
'total_pa'],
'MT') : null);
2819 $totalarray[
'val'][
'total_margin'] = (isset($totalarray[
'val'][
'total_margin']) ?
price2num($totalarray[
'val'][
'total_margin'],
'MT') : null);
2822 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
2828 foreach ($arrayfields as $key => $val) {
2829 if (!empty($val[
'checked'])) {
2833 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
2838$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
2839$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
2840print $hookmanager->resPrint;
2842print
'</table>'.
"\n";
2845print
'</form>'.
"\n";
2848if ($contextpage !=
'poslist') {
2849 $hidegeneratedfilelistifempty = 1;
2850 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
2851 $hidegeneratedfilelistifempty = 0;
2855 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
2856 $urlsource .= str_replace(
'&',
'&', $param);
2858 $filedir = $diroutputmassaction;
2859 $genallowed = $user->hasRight(
"facture",
"lire");
2860 $delallowed = $user->hasRight(
"facture",
"creer");
2863 print $formfile->showdocuments(
'massfilesarea_invoices',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage bank accounts.
Class to manage absolute discounts.
Class to manage 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_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.
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_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
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.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
setEventMessage($mesgs, $style='mesgs', $noduplicate=0, $attop=0)
Set event message in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.