31require
'../../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
52$langs->loadLangs(array(
"bills",
"companies",
"compta",
"accountancy",
"other",
"productbatch",
"products"));
54$action =
GETPOST(
'action',
'aZ09');
55$massaction =
GETPOST(
'massaction',
'alpha');
56$confirm =
GETPOST(
'confirm',
'alpha');
57$toselect =
GETPOST(
'toselect',
'array:aZ09');
58$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'accountancycustomerlist';
59$optioncss =
GETPOST(
'optioncss',
'alpha');
61$default_account =
GETPOSTINT(
'default_account');
64$search_societe =
GETPOST(
'search_societe',
'alpha');
65$search_lineid =
GETPOST(
'search_lineid',
'alpha');
66$search_ref =
GETPOST(
'search_ref',
'alpha');
67$search_invoice =
GETPOST(
'search_invoice',
'alpha');
68$search_label =
GETPOST(
'search_label',
'alpha');
69$search_desc =
GETPOST(
'search_desc',
'alpha');
70$search_amount =
GETPOST(
'search_amount',
'alpha');
71$search_account =
GETPOST(
'search_account',
'alpha');
72$search_vat =
GETPOST(
'search_vat',
'alpha');
73$search_date_startday =
GETPOSTINT(
'search_date_startday');
74$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
75$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
76$search_date_endday =
GETPOSTINT(
'search_date_endday');
77$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
78$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
79$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
80$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
81$search_country =
GETPOST(
'search_country',
'aZ09');
82$search_tvaintra =
GETPOST(
'search_tvaintra',
'alpha');
85if (empty($search_date_start) &&
getDolGlobalInt(
'ACCOUNTING_DATE_START_BINDING')) {
91$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
92$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
94if (empty($page) || $page < 0) {
97$offset = $limit * $page;
101 $sortfield =
"f.datef, f.ref, l.rowid";
112$hookmanager->initHooks(array($contextpage));
125if ($user->socid > 0) {
128if (!$user->hasRight(
'accounting',
'bind',
'write')) {
133 'l.rowid' => array(
'label' =>
"LineId",
'position' => 1,
'checked' =>
'1',
'enabled' =>
'1'),
134 'f.ref' => array(
'label' =>
"Invoice",
'position' => 1,
'checked' =>
'1',
'enabled' =>
'1'),
135 'f.datef' => array(
'label' =>
"Date",
'position' => 1,
'checked' =>
'1',
'enabled' =>
'1'),
136 'p.ref' => array(
'label' =>
"ProductRef",
'position' => 1,
'checked' =>
'1',
'enabled' =>
'1'),
137 'l.description' => array(
'label' =>
"ProductDescription",
'position' => 1,
'checked' =>
'-1',
'enabled' =>
'1'),
138 'l.total_ht' => array(
'label' =>
"Amount",
'position' => 1,
'checked' =>
'1',
'enabled' =>
'1'),
139 'l.tva_tx' => array(
'label' =>
"VATRate",
'position' => 1,
'checked' =>
'1',
'enabled' =>
'1'),
140 's.nom' => array(
'label' =>
"ThirdParty",
'position' => 1,
'checked' =>
'1',
'enabled' =>
'1'),
141 'co.label' => array(
'label' =>
"Country",
'position' => 1,
'checked' =>
'1',
'enabled' =>
'1'),
142 's.tva_intra' => array(
'label' =>
"VATIntraShort",
'position' => 1,
'checked' =>
'1',
'enabled' =>
'1'),
143 'aa.data_suggest' => array(
'label' =>
"DataUsedToSuggestAccount",
'position' => 1,
'checked' =>
'1',
'enabled' =>
'1'),
144 'aa.account_number' => array(
'label' =>
"AccountAccountingSuggest",
'position' => 1,
'checked' =>
'1',
'enabled' =>
'1'),
154if (
GETPOST(
'cancel',
'alpha')) {
158if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
162$parameters = array(
'arrayfields' => &$arrayfields);
163$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
168if (empty($reshook)) {
170 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
173 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
174 $search_societe =
'';
177 $search_invoice =
'';
181 $search_account =
'';
183 $search_date_startday =
'';
184 $search_date_startmonth =
'';
185 $search_date_startyear =
'';
186 $search_date_endday =
'';
187 $search_date_endmonth =
'';
188 $search_date_endyear =
'';
189 $search_date_start =
'';
190 $search_date_end =
'';
191 $search_country =
'';
192 $search_tvaintra =
'';
196 $objectclass =
'AccountingAccount';
197 $permissiontoread = $user->hasRight(
'accounting',
'read');
198 $permissiontodelete = $user->hasRight(
'accounting',
'delete');
199 $uploaddir =
$conf->accounting->dir_output;
200 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
204if ($massaction ==
'ventil' && $user->hasRight(
'accounting',
'bind',
'write')) {
207 if (!empty($toselect)) {
208 $msg =
'<div>'.$langs->trans(
"SelectedLines").
': '.count($toselect).
'</div>';
209 $msg .=
'<div class="detail">';
214 foreach ($toselect as $maLigneCochee) {
215 $maLigneCourante = explode(
"_", $maLigneCochee);
216 $monId = $maLigneCourante[0];
219 if ($monCompte <= 0) {
220 $msg .=
'<div><span class="error">'.$langs->trans(
"Lineofinvoice").
' '.$monId.
' - '.$langs->trans(
"NoAccountSelected").
'</span></div>';
223 $sql =
" UPDATE ".MAIN_DB_PREFIX.
"facturedet";
224 $sql .=
" SET fk_code_ventilation = ".((int) $monCompte);
225 $sql .=
" WHERE rowid = ".((int) $monId);
228 $accountventilated->fetch($monCompte,
'', 1);
230 dol_syslog(
"accountancy/customer/list.php", LOG_DEBUG);
231 if (
$db->query($sql)) {
232 $msg .=
'<div><span style="color:green">'.$langs->trans(
"Lineofinvoice").
' '.$monId.
' - '.$langs->trans(
"VentilatedinAccount").
' : '.
length_accountg($accountventilated->account_number).
'</span></div>';
235 $msg .=
'<div><span style="color:red">'.$langs->trans(
"ErrorDB").
' : '.$langs->trans(
"Lineofinvoice").
' '.$monId.
' - '.$langs->trans(
"NotVentilatedinAccount").
' : '.
length_accountg($accountventilated->account_number).
'<br> <pre>'.$sql.
'</pre></span></div>';
243 $msg .=
'<div>'.$langs->trans(
"EndProcessing").
'</div>';
247if (
GETPOST(
'sortfield') ==
'f.datef, f.ref, l.rowid') {
248 $value = (
GETPOST(
'sortorder') ==
'asc,asc,asc' ? 0 : 1);
249 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
260$help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Liaisons_comptables';
262llxHeader(
'', $langs->trans(
"CustomersVentilation"), $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist mod-accountancy accountancy-customer page-list');
264if (empty($chartaccountcode)) {
265 print $langs->trans(
"ErrorChartOfAccountSystemNotSelected");
273$sql =
"SELECT f.rowid as facid, f.ref, f.datef, f.type as ftype, f.situation_cycle_ref, f.fk_facture_source,";
274$sql .=
" l.rowid, l.fk_product, l.description, l.total_ht, l.situation_percent, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
275$sql .=
" p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,";
277 $sql .=
" ppe.accountancy_code_sell as code_sell, ppe.accountancy_code_sell_intra as code_sell_intra, ppe.accountancy_code_sell_export as code_sell_export,";
278 $sql .=
" ppe.accountancy_code_buy as code_buy, ppe.accountancy_code_buy_intra as code_buy_intra, ppe.accountancy_code_buy_export as code_buy_export,";
280 $sql .=
" p.accountancy_code_sell as code_sell, p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,";
281 $sql .=
" p.accountancy_code_buy as code_buy, p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export,";
283$sql .=
" p.tosell as status, p.tobuy as status_buy,";
284$sql .=
" aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export, aa4.rowid as aarowid_thirdparty,";
285$sql .=
" co.code as country_code, co.label as country_label,";
286$sql .=
" s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur,";
288 $sql .=
" spe.accountancy_code_customer as code_compta_client,";
289 $sql .=
" spe.accountancy_code_supplier as code_compta_fournisseur,";
290 $sql .=
" spe.accountancy_code_sell as company_code_sell";
292 $sql .=
" s.code_compta as code_compta_client,";
293 $sql .=
" s.code_compta_fournisseur,";
294 $sql .=
" s.accountancy_code_sell as company_code_sell";
296$parameters = array();
297$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
298$sql .= $hookmanager->resPrint;
299$sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f";
300$sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = f.fk_soc";
302 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int)
$conf->entity);
304$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON co.rowid = s.fk_pays ";
305$sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"facturedet as l ON f.rowid = l.fk_facture";
306$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = l.fk_product";
308 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int)
$conf->entity);
310$alias_societe_perentity = !
getDolGlobalString(
'MAIN_COMPANY_PERENTITY_SHARED') ?
"s" :
"spe";
311$alias_product_perentity = !
getDolGlobalString(
'MAIN_PRODUCT_PERENTITY_SHARED') ?
"p" :
"ppe";
312$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON " . $alias_product_perentity .
".accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode).
"' AND aa.entity = ".
$conf->entity;
313$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa2 ON " . $alias_product_perentity .
".accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode).
"' AND aa2.entity = ".
$conf->entity;
314$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa3 ON " . $alias_product_perentity .
".accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode).
"' AND aa3.entity = ".
$conf->entity;
315$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa4 ON " . $alias_societe_perentity .
".accountancy_code_sell = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode).
"' AND aa4.entity = ".
$conf->entity;
317$parameters = array();
318$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
319$sql .= $hookmanager->resPrint;
321$sql .=
" WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
322$sql .=
" AND l.product_type <= 2";
324if ($search_societe) {
330if (strlen(trim($search_invoice))) {
333if (strlen(trim($search_ref))) {
336if (strlen(trim($search_label))) {
339if (strlen(trim($search_desc))) {
342if (strlen(trim($search_amount))) {
345if (strlen(trim($search_account))) {
348if (strlen(trim($search_vat))) {
351if ($search_date_start) {
352 $sql .=
" AND f.datef >= '".$db->idate($search_date_start).
"'";
354if ($search_date_end) {
355 $sql .=
" AND f.datef <= '".$db->idate($search_date_end).
"'";
357if (strlen(trim($search_country))) {
359 $country_code_in_EEC = $country_code_in_EEC_without_me =
'';
360 foreach ($arrayofcode as $key => $value) {
361 $country_code_in_EEC .= ($country_code_in_EEC ?
"," :
"").
"'".$value.
"'";
362 if ($value !=
$mysoc->country_code) {
363 $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ?
"," :
"").
"'".$value.
"'";
366 if ($search_country ==
'special_allnotme') {
367 $sql .=
" AND co.code <> '".$db->escape(
$mysoc->country_code).
"'";
368 } elseif ($search_country ==
'special_eec') {
369 $sql .=
" AND co.code IN (".$db->sanitize($country_code_in_EEC, 1).
")";
370 } elseif ($search_country ==
'special_eecnotme') {
371 $sql .=
" AND co.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).
")";
372 } elseif ($search_country ==
'special_noteec') {
373 $sql .=
" AND co.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).
")";
378if (strlen(trim($search_tvaintra))) {
386$sql .=
" AND f.entity IN (".getEntity(
'invoice', 0).
")";
389$parameters = array();
390$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
391$sql .= $hookmanager->resPrint;
393$sql .=
$db->order($sortfield, $sortorder);
396$nbtotalofrecords =
'';
398 $result =
$db->query($sql);
399 $nbtotalofrecords =
$db->num_rows($result);
400 if (($page * $limit) > (
int) $nbtotalofrecords) {
406$sql .=
$db->plimit($limit + 1, $offset);
408dol_syslog(
"accountancy/customer/list.php", LOG_DEBUG);
411if (
$db->type ==
'mysqli') {
412 $db->query(
"SET SQL_BIG_SELECTS=1");
415$result =
$db->query($sql);
417 $num_lines =
$db->num_rows($result);
420 $arrayofselected = is_array($toselect) ? $toselect : array();
423 if ($contextpage != $_SERVER[
"PHP_SELF"]) {
424 $param .=
'&contextpage='.urlencode($contextpage);
426 if ($limit > 0 && $limit !=
$conf->liste_limit) {
427 $param .=
'&limit='.((int) $limit);
429 if ($search_societe) {
430 $param .=
'&search_societe='.urlencode($search_societe);
432 if ($search_lineid) {
433 $param .=
'&search_lineid='.urlencode((
string) ($search_lineid));
435 if ($search_date_startday) {
436 $param .=
'&search_date_startday='.urlencode((
string) ($search_date_startday));
438 if ($search_date_startmonth) {
439 $param .=
'&search_date_startmonth='.urlencode((
string) ($search_date_startmonth));
441 if ($search_date_startyear) {
442 $param .=
'&search_date_startyear='.urlencode((
string) ($search_date_startyear));
444 if ($search_date_endday) {
445 $param .=
'&search_date_endday='.urlencode((
string) ($search_date_endday));
447 if ($search_date_endmonth) {
448 $param .=
'&search_date_endmonth='.urlencode((
string) ($search_date_endmonth));
450 if ($search_date_endyear) {
451 $param .=
'&search_date_endyear='.urlencode((
string) ($search_date_endyear));
453 if ($search_invoice) {
454 $param .=
'&search_invoice='.urlencode($search_invoice);
457 $param .=
'&search_ref='.urlencode($search_ref);
460 $param .=
'&search_label='.urlencode($search_label);
463 $param .=
'&search_desc='.urlencode($search_desc);
465 if ($search_amount) {
466 $param .=
'&search_amount='.urlencode($search_amount);
469 $param .=
'&search_vat='.urlencode($search_vat);
471 if ($search_country) {
472 $param .=
"&search_country=".urlencode($search_country);
474 if ($search_tvaintra) {
475 $param .=
"&search_tvaintra=".urlencode($search_tvaintra);
478 $parameters = array(
'param' => &$param);
479 $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
480 $param .= $hookmanager->resPrint;
482 $arrayofmassactions = array(
483 'set_default_account' =>
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"ConfirmPreselectAccount"),
484 'ventil' =>
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Ventilate")
490 $massactionbutton =
'';
491 if ($massaction !==
'set_default_account') {
492 $massactionbutton = $form->selectMassAction(
'ventil', $arrayofmassactions, 1);
495 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
496 print
'<input type="hidden" name="action" value="ventil">';
497 if ($optioncss !=
'') {
498 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
500 print
'<input type="hidden" name="token" value="'.newToken().
'">';
501 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
502 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
503 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
504 print
'<input type="hidden" name="page" value="'.$page.
'">';
507 print_barre_liste($langs->trans(
"InvoiceLines").
'<br><span class="opacityhigh small">'.$langs->trans(
"DescVentilTodoCustomer").
'</span>', $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, (
string) $massactionbutton, $num_lines, $nbtotalofrecords,
'title_accountancy', 0,
'',
'', $limit, 0, 0, 1);
510 if ($massaction ==
'set_default_account') {
511 $formquestion = array();
512 $formquestion[] = array(
'type' =>
'other',
513 'name' =>
'set_default_account',
514 'label' => $langs->trans(
"AccountancyCode"),
515 'value' => $formaccounting->select_account(
'',
'default_account', 1, array(), 0, 0,
'maxwidth200 maxwidthonsmartphone',
'cachewithshowemptyone'));
516 print $form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmPreselectAccount"), $langs->trans(
"ConfirmPreselectAccountQuestion", count($toselect)),
"confirm_set_default_account", $formquestion, 1, 0, 200, 500, 1);
525 $varpage = $contextpage;
526 $htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
527 $selectedfields = $htmlofselectarray;
528 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
530 print
'<div class="div-table-responsive">';
531 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
534 print
'<tr class="liste_titre_filter">';
536 if (
$conf->main_checkbox_left_column) {
537 print
'<td class="liste_titre maxwidthsearch center actioncolumn">';
538 $searchpicto = $form->showFilterButtons(
'left');
543 if (!empty($arrayfields[
'l.rowid'][
'checked'])) {
544 print
'<td class="liste_titre" data-key="lineid">';
545 print
'<input type="text" class="flat maxwidth40" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).
'">';
549 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
550 print
'<td class="liste_titre" data-key="invoice">';
551 print
'<input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).
'">';
555 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
556 print
'<td class="liste_titre center">';
557 print
'<div class="nowrapfordate">';
558 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
560 print
'<div class="nowrapfordate">';
561 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
566 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
567 print
'<td class="liste_titre" data-key="ref">';
568 print
'<input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
572 if (!empty($arrayfields[
'l.description'][
'checked'])) {
573 print
'<td class="liste_titre" data-key="desc">';
574 print
'<input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).
'">';
578 if (!empty($arrayfields[
'l.total_ht'][
'checked'])) {
579 print
'<td class="liste_titre" data-key="amount">';
580 print
'<input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).
'">';
584 if (!empty($arrayfields[
'l.tva_tx'][
'checked'])) {
585 print
'<td class="liste_titre" data-key="vat">';
586 print
'<input type="text" class="right flat maxwidth50" placeholder="%" name="search_vat" size="1" value="'.dol_escape_htmltag($search_vat).
'">';
590 if (!empty($arrayfields[
's.nom'][
'checked'])) {
591 print
'<td class="liste_titre" data-key="societe">';
592 print
'<input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).
'">';
596 if (!empty($arrayfields[
'co.label'][
'checked'])) {
597 print
'<td class="liste_titre" data-key="country">';
598 print $form->select_country($search_country,
'search_country',
'', 0,
'maxwidth125',
'code2', 1, 0, 1);
602 if (!empty($arrayfields[
's.tva_intra'][
'checked'])) {
603 print
'<td class="liste_titre">';
604 print
'<input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).
'">';
608 if (!empty($arrayfields[
'aa.data_suggest'][
'checked'])) {
609 print
'<td class="liste_titre"></td>';
612 if (!empty($arrayfields[
'aa.account_number'][
'checked'])) {
613 print
'<td class="liste_titre"></td>';
616 $parameters = array(
'arrayfields' => $arrayfields);
617 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
618 print $hookmanager->resPrint;
621 if (!
$conf->main_checkbox_left_column) {
622 print
'<td class="liste_titre center maxwidthsearch actioncolumn">';
623 $searchpicto = $form->showFilterButtons();
634 print
'<tr class="liste_titre">';
636 if (
$conf->main_checkbox_left_column) {
637 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
641 if (!empty($arrayfields[
'l.rowid'][
'checked'])) {
642 print_liste_field_titre($arrayfields[
'l.rowid'][
'label'], $_SERVER[
"PHP_SELF"],
"l.rowid",
"", $param,
'', $sortfield, $sortorder);
646 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
647 print_liste_field_titre($arrayfields[
'f.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"f.ref",
"", $param,
'', $sortfield, $sortorder);
651 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
652 print_liste_field_titre($arrayfields[
'f.datef'][
'label'], $_SERVER[
"PHP_SELF"],
"f.datef, f.ref, l.rowid",
"", $param,
'', $sortfield, $sortorder,
'center ');
656 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
657 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"p.ref",
"", $param,
'', $sortfield, $sortorder);
661 if (!empty($arrayfields[
'l.description'][
'checked'])) {
662 print_liste_field_titre($arrayfields[
'l.description'][
'label'], $_SERVER[
"PHP_SELF"],
"l.description",
"", $param,
'', $sortfield, $sortorder);
666 if (!empty($arrayfields[
'l.total_ht'][
'checked'])) {
667 print_liste_field_titre($arrayfields[
'l.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"l.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right ');
671 if (!empty($arrayfields[
'l.tva_tx'][
'checked'])) {
672 print_liste_field_titre($arrayfields[
'l.tva_tx'][
'label'], $_SERVER[
"PHP_SELF"],
"l.tva_tx",
"", $param,
'', $sortfield, $sortorder,
'right ');
676 if (!empty($arrayfields[
's.nom'][
'checked'])) {
677 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
'', $sortfield, $sortorder);
681 if (!empty($arrayfields[
'co.label'][
'checked'])) {
682 print_liste_field_titre($arrayfields[
'co.label'][
'label'], $_SERVER[
"PHP_SELF"],
"co.label",
"", $param,
'', $sortfield, $sortorder);
686 if (!empty($arrayfields[
's.tva_intra'][
'checked'])) {
687 print_liste_field_titre($arrayfields[
's.tva_intra'][
'label'], $_SERVER[
"PHP_SELF"],
"s.tva_intra",
"", $param,
'', $sortfield, $sortorder);
691 if (!empty($arrayfields[
'aa.data_suggest'][
'checked'])) {
692 print_liste_field_titre($arrayfields[
'aa.data_suggest'][
'label'], $_SERVER[
"PHP_SELF"],
"aa.account_number",
"", $param,
'', $sortfield, $sortorder);
696 if (!empty($arrayfields[
'aa.account_number'][
'checked'])) {
697 print_liste_field_titre($arrayfields[
'aa.account_number'][
'label'], $_SERVER[
"PHP_SELF"],
"aa.account_number",
"", $param,
'', $sortfield, $sortorder);
701 $parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
702 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
703 print $hookmanager->resPrint;
705 if (!
$conf->main_checkbox_left_column) {
706 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
717 $accountingaccount_codetotid_cache = array();
718 $suggestedaccountingaccountfor =
'';
719 $suggestedaccountingaccountbydefaultfor =
'';
721 while ($i < min($num_lines, $limit)) {
722 $objp =
$db->fetch_object($result);
731 $thirdpartystatic->id = $objp->socid;
732 $thirdpartystatic->name = $objp->name;
733 $thirdpartystatic->client = $objp->client;
734 $thirdpartystatic->fournisseur = $objp->fournisseur;
735 $thirdpartystatic->code_client = $objp->code_client;
736 $thirdpartystatic->code_compta = $objp->code_compta_client;
737 $thirdpartystatic->code_compta_client = $objp->code_compta_client;
738 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
739 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
740 $thirdpartystatic->email = $objp->email;
741 $thirdpartystatic->country_code = $objp->country_code;
742 $thirdpartystatic->tva_intra = $objp->tva_intra;
743 $thirdpartystatic->code_compta_product = $objp->company_code_sell;
745 $product_static->ref = $objp->product_ref;
746 $product_static->id = $objp->product_id;
747 $product_static->type = $objp->type;
748 $product_static->label = $objp->product_label;
749 $product_static->status = $objp->status;
750 $product_static->status_buy = $objp->status_buy;
751 $product_static->accountancy_code_sell = $objp->code_sell;
752 $product_static->accountancy_code_sell_intra = $objp->code_sell_intra;
753 $product_static->accountancy_code_sell_export = $objp->code_sell_export;
754 $product_static->accountancy_code_buy = $objp->code_buy;
755 $product_static->accountancy_code_buy_intra = $objp->code_buy_intra;
756 $product_static->accountancy_code_buy_export = $objp->code_buy_export;
757 $product_static->tva_tx = $objp->tva_tx_prod;
759 $facture_static->ref = $objp->ref;
760 $facture_static->id = $objp->facid;
761 $facture_static->type = $objp->ftype;
762 $facture_static->date =
$db->jdate($objp->datef);
763 $facture_static->fk_facture_source = $objp->fk_facture_source;
765 $facture_static_det->id = $objp->rowid;
766 $facture_static_det->total_ht = $objp->total_ht;
767 $facture_static_det->tva_tx = $objp->tva_tx_line;
768 $facture_static_det->vat_src_code = $objp->vat_src_code;
769 $facture_static_det->product_type = $objp->type_l;
770 $facture_static_det->desc = $objp->description;
772 $accountingAccountArray = array(
773 'dom' => $objp->aarowid,
774 'intra' => $objp->aarowid_intra,
775 'export' => $objp->aarowid_export,
776 'thirdparty' => $objp->aarowid_thirdparty);
778 $code_sell_p_notset =
'';
779 $code_sell_t_notset =
'';
783 $return = $accountingAccount->getAccountingCodeToBind($thirdpartystatic,
$mysoc, $product_static, $facture_static, $facture_static_det, $accountingAccountArray,
'customer');
784 if (!is_array($return) && $return < 0) {
787 $suggestedid = $return[
'suggestedid'];
788 $suggestedaccountingaccountfor = $return[
'suggestedaccountingaccountfor'];
789 $suggestedaccountingaccountbydefaultfor = $return[
'suggestedaccountingaccountbydefaultfor'];
790 $code_sell_l = $return[
'code_l'];
791 $code_sell_p = $return[
'code_p'];
792 $code_sell_t = $return[
'code_t'];
796 if (!empty($code_sell_p)) {
799 $code_sell_p_notset =
'color:orange';
801 if (empty($code_sell_l) && empty($code_sell_p)) {
802 $code_sell_p_notset =
'color:red';
804 if ($suggestedaccountingaccountfor ==
'eecwithoutvatnumber' && empty($code_sell_p_notset)) {
805 $code_sell_p_notset =
'color:orange';
813 print
'<tr class="oddeven">';
815 if (
$conf->main_checkbox_left_column) {
816 print
'<td class="nowrap center actioncolumn">';
817 $selected = in_array($objp->rowid.
"_".$i, $toselect);
818 print
'<input type="checkbox" class="flat checkforselect checkforselect'.$facture_static_det->id.
'" name="toselect[]" value="'.$facture_static_det->id.
"_".$i.
'"'.($selected ?
" checked" :
"").
'/>';
825 if (!empty($arrayfields[
'l.rowid'][
'checked'])) {
826 print
'<td>'.$facture_static_det->id.
'</td>';
830 if (!empty($arrayfields[
'f.ref'][
'checked'])) {
831 print
'<td class="nowraponall cell2linesheight">'.$facture_static->getNomUrl(1).
'</td>';
835 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
836 print
'<td class="center">'.dol_print_date($facture_static->date,
'day').
'</td>';
840 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
841 print
'<td class="tdoverflowmax125 cell2linesheight">';
842 if ($product_static->id > 0) {
843 print $product_static->getNomUrl(1);
845 if ($product_static->label) {
846 print
'<br><span class="opacitymedium small">'.dol_escape_htmltag($product_static->label).
'</span>';
852 if (!empty($arrayfields[
'l.description'][
'checked'])) {
854 print
'<td class="tdoverflowmax150 small classfortooltip" title="'.dol_escape_htmltag($text).
'">';
861 if (!empty($arrayfields[
'l.total_ht'][
'checked'])) {
862 print
'<td class="right nowraponall amount">';
865 $situation_ratio = 1;
867 if ($objp->situation_cycle_ref) {
869 if ($objp->situation_percent == 0) {
870 $situation_ratio = 0;
873 $line->fetch($objp->rowid);
876 $prev_progress = $line->get_prev_progress($objp->facid);
878 $situation_ratio = ($objp->situation_percent - $prev_progress) / $objp->situation_percent;
881 print
price($objp->total_ht * $situation_ratio);
883 print
price($objp->total_ht);
889 if (!empty($arrayfields[
'l.tva_tx'][
'checked'])) {
890 $code_vat_differ =
'';
891 if ($product_static->tva_tx !== $facture_static_det->tva_tx &&
price2num($product_static->tva_tx) &&
price2num($facture_static_det->tva_tx)) {
892 $code_vat_differ =
'warning bold';
894 print
'<td class="right cell2linesheight'.($code_vat_differ ?
' '.$code_vat_differ :
'').
'">';
895 print
vatrate($facture_static_det->tva_tx.($facture_static_det->vat_src_code ?
' ('.$facture_static_det->vat_src_code.
')' :
''), false, 0, 0, 1);
900 if (!empty($arrayfields[
's.nom'][
'checked'])) {
901 print
'<td class="tdoverflowmax125">'.$thirdpartystatic->getNomUrl(1,
'customer').
'</td>';
905 if (!empty($arrayfields[
'co.label'][
'checked'])) {
906 $labelcountry = ($objp->country_code && ($langs->trans(
"Country".$objp->country_code) !=
"Country".$objp->country_code)) ? $langs->trans(
"Country".$objp->country_code) : $objp->country_label;
907 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($labelcountry).
'">';
913 if (!empty($arrayfields[
's.tva_intra'][
'checked'])) {
914 print
'<td class="tdoverflowmax80" title="'.dol_escape_htmltag($objp->tva_intra).
'">'.
dol_escape_htmltag($objp->tva_intra).
'</td>';
918 if (!empty($arrayfields[
'aa.data_suggest'][
'checked'])) {
919 print
'<td class="small cell2linesheight">';
921 $s =
'1. '.(($facture_static_det->product_type == 1) ? $langs->trans(
"DefaultForService") : $langs->trans(
"DefaultForProduct")).
': ';
924 if ($suggestedaccountingaccountbydefaultfor ==
'eec') {
925 $shelp .= $langs->trans(
"SaleEEC");
926 } elseif ($suggestedaccountingaccountbydefaultfor ==
'eecwithvat') {
927 $shelp = $langs->trans(
"SaleEECWithVAT");
928 } elseif ($suggestedaccountingaccountbydefaultfor ==
'eecwithoutvatnumber') {
929 $shelp = $langs->trans(
"SaleEECWithoutVATNumber");
931 } elseif ($suggestedaccountingaccountbydefaultfor ==
'export') {
932 $shelp .= $langs->trans(
"SaleExport");
934 $s .= ($code_sell_l > 0 ?
length_accountg($code_sell_l) :
'<span style="'.$code_sell_p_notset.
'">'.$langs->trans(
"NotDefined").
'</span>');
935 $textforrule = $form->textwithpicto($s, $shelp, 1, $ttype,
'', 0, 2,
'', 1);
937 if ($product_static->id > 0) {
938 $textforrule .=
'<br>';
939 $s =
'2. '.(($facture_static_det->product_type == 1) ? $langs->trans(
"ThisService") : $langs->trans(
"ThisProduct")).
': ';
942 if ($suggestedaccountingaccountbydefaultfor ==
'eec') {
943 $shelp .= $langs->trans(
"SaleEEC");
944 } elseif ($suggestedaccountingaccountbydefaultfor ==
'eecwithvat') {
945 $shelp = $langs->trans(
"SaleEECWithVAT");
946 } elseif ($suggestedaccountingaccountbydefaultfor ==
'eecwithoutvatnumber') {
947 $shelp = $langs->trans(
"SaleEECWithoutVATNumber");
949 } elseif ($suggestedaccountingaccountbydefaultfor ==
'export') {
950 $shelp .= $langs->trans(
"SaleExport");
952 $s .= (empty($code_sell_p) ?
'<span style="'.$code_sell_p_notset.
'">'.$langs->trans(
"NotDefined").
'</span>' :
length_accountg($code_sell_p));
953 $textforrule .= $form->textwithpicto($s, $shelp, 1, $ttype,
'', 0, 2,
'', 1);
955 $textforrule .=
'<br>';
956 $s =
'2. '.(($objp->type_l == 1) ? $langs->trans(
"ThisService") : $langs->trans(
"ThisProduct")).
': ';
958 $s .= $langs->trans(
"NotDefined");
959 $textforrule .= $form->textwithpicto($s, $shelp, 1,
'help',
'', 0, 2,
'', 1);
962 $textforrule .=
'<br>';
963 $s =
'3. '.(($facture_static_det->product_type == 1) ? $langs->trans(
"ServiceForThisThirdparty") : $langs->trans(
"ProductForThisThirdparty")).
': ';
965 $s .= ($code_sell_t > 0 ?
length_accountg($code_sell_t) :
'<span style="'.$code_sell_t_notset.
'">'.$langs->trans(
"NotDefined").
'</span>');
966 $textforrule .= $form->textwithpicto($s, $shelp, 1,
'help',
'', 0, 2,
'', 1);
973 if (!empty($arrayfields[
'aa.account_number'][
'checked'])) {
975 print $formaccounting->select_account(($default_account > 0 && $confirm ===
'yes' && in_array($objp->rowid.
"_".$i, $toselect)) ? (
string) $default_account : (
string) $suggestedid,
'codeventil'.$facture_static_det->id, 1, array(), 0, 0,
'codeventil minwidth125onall maxwidth150',
'cachewithshowemptyone');
980 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $objp,
'i' => $i,
'totalarray' => &
$totalarray);
981 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
982 print $hookmanager->resPrint;
984 if (!
$conf->main_checkbox_left_column) {
985 print
'<td class="nowrap center actioncolumn">';
986 $selected = in_array($objp->rowid.
"_".$i, $toselect);
987 print
'<input type="checkbox" class="flat checkforselect checkforselect'.$facture_static_det->id.
'" name="toselect[]" value="'.$facture_static_det->id.
"_".$i.
'"'.($selected ?
" checked" :
"").
'/>';
997 if ($num_lines == 0) {
999 foreach ($arrayfields as $key => $val) {
1000 if (!empty($val[
'checked'])) {
1004 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1007 $parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
1008 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1009 print $hookmanager->resPrint;
1018if (
$db->type ==
'mysqli') {
1019 $db->query(
"SET SQL_BIG_SELECTS=0");
1023print
'<script type="text/javascript">
1024jQuery(document).ready(function() {
1025 jQuery(".codeventil").change(function() {
1026 var s=$(this).attr("id").replace("codeventil", "")
1027 console.log(s+" "+$(this).val());
1028 if ($(this).val() == -1) jQuery(".checkforselect"+s).prop("checked", false);
1029 else jQuery(".checkforselect"+s).prop("checked", true);
if(! $sortfield) if(! $sortorder) $object
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
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 accounting accounts.
Class to manage invoices.
const TYPE_REPLACEMENT
Replacement invoice.
const TYPE_SITUATION
Situation invoice.
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage invoice lines.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
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...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.