31require
'../../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
45$langs->loadLangs(array(
"bills",
"companies",
"compta",
"accountancy",
"other",
"productbatch",
"products"));
47$action =
GETPOST(
'action',
'aZ09');
48$massaction =
GETPOST(
'massaction',
'alpha');
49$confirm =
GETPOST(
'confirm',
'alpha');
50$toselect =
GETPOST(
'toselect',
'array');
51$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'accountancysupplierlist';
52$optioncss =
GETPOST(
'optioncss',
'alpha');
54$default_account =
GETPOSTINT(
'default_account');
57$mesCasesCochees =
GETPOST(
'toselect',
'array');
60$search_lineid =
GETPOST(
'search_lineid',
'alpha');
61$search_societe =
GETPOST(
'search_societe',
'alpha');
62$search_ref =
GETPOST(
'search_ref',
'alpha');
63$search_ref_supplier =
GETPOST(
'search_ref_supplier',
'alpha');
64$search_invoice =
GETPOST(
'search_invoice',
'alpha');
65$search_label =
GETPOST(
'search_label',
'alpha');
66$search_desc =
GETPOST(
'search_desc',
'alpha');
67$search_amount =
GETPOST(
'search_amount',
'alpha');
68$search_account =
GETPOST(
'search_account',
'alpha');
69$search_vat =
GETPOST(
'search_vat',
'alpha');
70$search_date_startday =
GETPOSTINT(
'search_date_startday');
71$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
72$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
73$search_date_endday =
GETPOSTINT(
'search_date_endday');
74$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
75$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
76$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
77$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
78$search_country =
GETPOST(
'search_country',
'aZ09');
79$search_tvaintra =
GETPOST(
'search_tvaintra',
'alpha');
83$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
84$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
86if (empty($page) || $page < 0) {
89$offset = $limit * $page;
93 $sortfield =
"f.datef, f.ref, l.rowid";
104$hookmanager->initHooks(array(
'accountancysupplierlist'));
112if (!isModEnabled(
'accounting')) {
115if ($user->socid > 0) {
118if (!$user->hasRight(
'accounting',
'bind',
'write')) {
123if (empty($search_date_start) &&
getDolGlobalString(
'ACCOUNTING_DATE_START_BINDING')) {
132if (
GETPOST(
'cancel',
'alpha')) {
136if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
140$parameters = array();
141$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
146if (empty($reshook)) {
148 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
149 $search_societe =
'';
152 $search_ref_supplier =
'';
153 $search_invoice =
'';
157 $search_account =
'';
159 $search_date_startday =
'';
160 $search_date_startmonth =
'';
161 $search_date_startyear =
'';
162 $search_date_endday =
'';
163 $search_date_endmonth =
'';
164 $search_date_endyear =
'';
165 $search_date_start =
'';
166 $search_date_end =
'';
167 $search_country =
'';
168 $search_tvaintra =
'';
172 $objectclass =
'AccountingAccount';
173 $permissiontoread = $user->hasRight(
'accounting',
'read');
174 $permissiontodelete = $user->hasRight(
'accounting',
'delete');
175 $uploaddir = $conf->accounting->dir_output;
176 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
180if ($massaction ==
'ventil' && $user->hasRight(
'accounting',
'bind',
'write')) {
183 if (!empty($mesCasesCochees)) {
184 $msg =
'<div>'.$langs->trans(
"SelectedLines").
': '.count($mesCasesCochees).
'</div>';
185 $msg .=
'<div class="detail">';
190 foreach ($mesCasesCochees as $maLigneCochee) {
191 $maLigneCourante = explode(
"_", $maLigneCochee);
192 $monId = $maLigneCourante[0];
193 $monCompte =
GETPOST(
'codeventil'.$monId);
195 if ($monCompte <= 0) {
196 $msg .=
'<div><span class="error">'.$langs->trans(
"Lineofinvoice").
' '.$monId.
' - '.$langs->trans(
"NoAccountSelected").
'</span></div>';
199 $sql =
" UPDATE ".MAIN_DB_PREFIX.
"facture_fourn_det";
200 $sql .=
" SET fk_code_ventilation = ".((int) $monCompte);
201 $sql .=
" WHERE rowid = ".((int) $monId);
204 $accountventilated->fetch($monCompte,
'', 1);
206 dol_syslog(
'accountancy/supplier/list.php', LOG_DEBUG);
207 if ($db->query($sql)) {
208 $msg .=
'<div><span class="green">'.$langs->trans(
"Lineofinvoice").
' '.$monId.
' - '.$langs->trans(
"VentilatedinAccount").
' : '.
length_accountg($accountventilated->account_number).
'</span></div>';
211 $msg .=
'<div><span class="error">'.$langs->trans(
"ErrorDB").
' : '.$langs->trans(
"Lineofinvoice").
' '.$monId.
' - '.$langs->trans(
"NotVentilatedinAccount").
' : '.
length_accountg($accountventilated->account_number).
'<br> <pre>'.$sql.
'</pre></span></div>';
219 $msg .=
'<div>'.$langs->trans(
"EndProcessing").
'</div>';
223if (
GETPOST(
'sortfield') ==
'f.datef, f.ref, l.rowid') {
224 $value = (
GETPOST(
'sortorder') ==
'asc,asc,asc' ? 0 : 1);
225 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
226 $res =
dolibarr_set_const($db,
"ACCOUNTING_LIST_SORT_VENTILATION_TODO", $value,
'yesno', 0,
'', $conf->entity);
234$form =
new Form($db);
237$help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Liaisons_comptables';
239llxHeader(
'', $langs->trans(
"SuppliersVentilation"), $help_url,
'', 0, 0,
'',
'',
'',
'bodyforlist mod-accountancy accountancy-supplier page-list');
241if (empty($chartaccountcode)) {
242 print $langs->trans(
"ErrorChartOfAccountSystemNotSelected");
250$sql =
"SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype, f.fk_facture_source,";
251$sql .=
" l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
252$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,";
254 $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,";
255 $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,";
257 $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,";
258 $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,";
260$sql .=
" p.tosell as status, p.tobuy as status_buy,";
261$sql .=
" aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export, aa4.rowid as aarowid_thirdparty,";
262$sql .=
" co.code as country_code, co.label as country_label,";
263$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,";
265 $sql .=
" spe.accountancy_code_customer as code_compta_client,";
266 $sql .=
" spe.accountancy_code_supplier as code_compta_fournisseur,";
267 $sql .=
" spe.accountancy_code_buy as company_code_buy";
269 $sql .=
" s.code_compta as code_compta_client,";
270 $sql .=
" s.code_compta_fournisseur,";
271 $sql .=
" s.accountancy_code_buy as company_code_buy";
273$parameters = array();
274$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
275$sql .= $hookmanager->resPrint;
276$sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
277$sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = f.fk_soc";
279 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
281$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON co.rowid = s.fk_pays ";
282$sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
283$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = l.fk_product";
285 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
287$alias_societe_perentity = !
getDolGlobalString(
'MAIN_COMPANY_PERENTITY_SHARED') ?
"s" :
"spe";
288$alias_product_perentity = !
getDolGlobalString(
'MAIN_PRODUCT_PERENTITY_SHARED') ?
"p" :
"ppe";
289$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON " . $alias_product_perentity .
".accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode).
"' AND aa.entity = ".$conf->entity;
290$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa2 ON " . $alias_product_perentity .
".accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode).
"' AND aa2.entity = ".$conf->entity;
291$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa3 ON " . $alias_product_perentity .
".accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode).
"' AND aa3.entity = ".$conf->entity;
292$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa4 ON " . $alias_societe_perentity .
".accountancy_code_buy = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode).
"' AND aa4.entity = ".$conf->entity;
293$sql .=
" WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
294$sql .=
" AND l.product_type <= 2";
296if (strlen($search_lineid)) {
299if (strlen($search_societe)) {
302if (strlen(trim($search_invoice))) {
303 $sql .=
natural_search(array(
"f.ref",
"f.ref_supplier"), $search_invoice);
305if (strlen(trim($search_ref))) {
311if (strlen(trim($search_label))) {
312 $sql .=
natural_search(array(
"p.label",
"f.libelle"), $search_label);
314if (strlen(trim($search_desc))) {
317if (strlen(trim($search_amount))) {
320if (strlen(trim($search_account))) {
323if (strlen(trim($search_vat))) {
326if ($search_date_start) {
327 $sql .=
" AND f.datef >= '".$db->idate($search_date_start).
"'";
329if ($search_date_end) {
330 $sql .=
" AND f.datef <= '".$db->idate($search_date_end).
"'";
332if (strlen(trim($search_country))) {
334 $country_code_in_EEC = $country_code_in_EEC_without_me =
'';
335 foreach ($arrayofcode as $key => $value) {
336 $country_code_in_EEC .= ($country_code_in_EEC ?
"," :
"").
"'".$value.
"'";
337 if ($value != $mysoc->country_code) {
338 $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ?
"," :
"").
"'".$value.
"'";
341 if ($search_country ==
'special_allnotme') {
342 $sql .=
" AND co.code <> '".$db->escape($mysoc->country_code).
"'";
343 } elseif ($search_country ==
'special_eec') {
344 $sql .=
" AND co.code IN (".$db->sanitize($country_code_in_EEC, 1).
")";
345 } elseif ($search_country ==
'special_eecnotme') {
346 $sql .=
" AND co.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).
")";
347 } elseif ($search_country ==
'special_noteec') {
348 $sql .=
" AND co.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).
")";
353if (strlen(trim($search_tvaintra))) {
361$sql .=
" AND f.entity IN (".getEntity(
'facture_fourn', 0).
")";
364$parameters = array();
365$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
366$sql .= $hookmanager->resPrint;
368$sql .= $db->order($sortfield, $sortorder);
371$nbtotalofrecords =
'';
373 $result = $db->query($sql);
374 $nbtotalofrecords = $db->num_rows($result);
375 if (($page * $limit) > $nbtotalofrecords) {
381$sql .= $db->plimit($limit + 1, $offset);
383dol_syslog(
'accountancy/supplier/list.php', LOG_DEBUG);
386if ($db->type ==
'mysqli') {
387 $db->query(
"SET SQL_BIG_SELECTS=1");
390$result = $db->query($sql);
392 $num_lines = $db->num_rows($result);
395 $arrayofselected = is_array($toselect) ? $toselect : array();
398 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
399 $param .=
'&contextpage='.urlencode($contextpage);
401 if ($limit > 0 && $limit != $conf->liste_limit) {
402 $param .=
'&limit='.((int) $limit);
404 if ($search_lineid) {
405 $param .=
'&search_lineid='.urlencode((
string) ($search_lineid));
407 if ($search_societe) {
408 $param .=
'&search_societe='.urlencode($search_societe);
410 if ($search_date_startday) {
411 $param .=
'&search_date_startday='.urlencode((
string) ($search_date_startday));
413 if ($search_date_startmonth) {
414 $param .=
'&search_date_startmonth='.urlencode((
string) ($search_date_startmonth));
416 if ($search_date_startyear) {
417 $param .=
'&search_date_startyear='.urlencode((
string) ($search_date_startyear));
419 if ($search_date_endday) {
420 $param .=
'&search_date_endday='.urlencode((
string) ($search_date_endday));
422 if ($search_date_endmonth) {
423 $param .=
'&search_date_endmonth='.urlencode((
string) ($search_date_endmonth));
425 if ($search_date_endyear) {
426 $param .=
'&search_date_endyear='.urlencode((
string) ($search_date_endyear));
428 if ($search_invoice) {
429 $param .=
'&search_invoice='.urlencode($search_invoice);
432 $param .=
'&search_ref='.urlencode($search_ref);
434 if ($search_ref_supplier) {
435 $param .=
'&search_ref_supplier='.urlencode($search_ref_supplier);
438 $param .=
'&search_label='.urlencode($search_label);
441 $param .=
'&search_desc='.urlencode($search_desc);
443 if ($search_amount) {
444 $param .=
'&search_amount='.urlencode($search_amount);
447 $param .=
'&search_vat='.urlencode($search_vat);
449 if ($search_country) {
450 $param .=
"&search_country=".urlencode($search_country);
452 if ($search_tvaintra) {
453 $param .=
"&search_tvaintra=".urlencode($search_tvaintra);
456 $arrayofmassactions = array(
457 'set_default_account' =>
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"ConfirmPreselectAccount"),
458 'ventil' =>
img_picto(
'',
'check',
'class="pictofixedwidth"').$langs->trans(
"Ventilate")
464 $massactionbutton =
'';
465 if ($massaction !==
'set_default_account') {
466 $massactionbutton = $form->selectMassAction(
'ventil', $arrayofmassactions, 1);
469 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
470 print
'<input type="hidden" name="action" value="ventil">';
471 if ($optioncss !=
'') {
472 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
474 print
'<input type="hidden" name="token" value="'.newToken().
'">';
475 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
476 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
477 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
478 print
'<input type="hidden" name="page" value="'.$page.
'">';
481 print_barre_liste($langs->trans(
"InvoiceLines").
'<br><span class="opacitymedium small">'.$langs->trans(
"DescVentilTodoCustomer").
'</span>', $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords,
'title_accountancy', 0,
'',
'', $limit, 0, 0, 1);
483 if ($massaction ==
'set_default_account') {
484 $formquestion = array();
485 $formquestion[] = array(
'type' =>
'other',
486 'name' =>
'set_default_account',
487 'label' => $langs->trans(
"AccountancyCode"),
488 'value' => $formaccounting->select_account(
'',
'default_account', 1, array(), 0, 0,
'maxwidth200 maxwidthonsmartphone',
'cachewithshowemptyone'));
489 print $form->formconfirm($_SERVER[
"PHP_SELF"], $langs->trans(
"ConfirmPreselectAccount"), $langs->trans(
"ConfirmPreselectAccountQuestion", count($toselect)),
"confirm_set_default_account", $formquestion, 1, 0, 200, 500, 1);
498 print
'<div class="div-table-responsive">';
499 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
502 print
'<tr class="liste_titre_filter">';
503 print
'<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).
'"></td>';
504 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).
'"></td>';
506 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).
'"></td>';
507 print
'<td class="liste_titre center">';
508 print
'<div class="nowrapfordate">';
509 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
511 print
'<div class="nowrapfordate">';
512 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
515 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'"></td>';
516 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).
'"></td>';
517 print
'<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_amount" value="'.dol_escape_htmltag($search_amount).
'"></td>';
518 print
'<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).
'"></td>';
519 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).
'"></td>';
520 print
'<td class="liste_titre">';
521 print $form->select_country($search_country,
'search_country',
'', 0,
'maxwidth100',
'code2', 1, 0, 1);
524 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).
'"></td>';
525 print
'<td class="liste_titre"></td>';
526 print
'<td class="liste_titre"></td>';
527 print
'<td class="center liste_titre">';
528 $searchpicto = $form->showFilterButtons();
533 print
'<tr class="liste_titre">';
537 print_liste_field_titre(
"InvoiceLabel", $_SERVER[
"PHP_SELF"],
"f.libelle",
"", $param,
'', $sortfield, $sortorder);
538 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"f.datef, f.ref, l.rowid",
"", $param,
'', $sortfield, $sortorder,
'center ');
541 print_liste_field_titre(
"ProductDescription", $_SERVER[
"PHP_SELF"],
"l.description",
"", $param,
'', $sortfield, $sortorder);
542 print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"l.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right maxwidth50 ');
543 print_liste_field_titre(
"VATRate", $_SERVER[
"PHP_SELF"],
"l.tva_tx",
"", $param,
'', $sortfield, $sortorder,
'right ',
'', 1);
546 print_liste_field_titre(
"VATIntraShort", $_SERVER[
"PHP_SELF"],
"s.tva_intra",
"", $param,
'', $sortfield, $sortorder);
550 if ($massactionbutton) {
551 $checkpicto = $form->showCheckAddButtons(
'checkforselect', 1);
556 $thirdpartystatic =
new Societe($db);
559 $product_static =
new Product($db);
562 $accountingaccount_codetotid_cache = array();
563 $suggestedaccountingaccountfor =
'';
564 $suggestedaccountingaccountbydefaultfor =
'';
566 while ($i < min($num_lines, $limit)) {
567 $objp = $db->fetch_object($result);
576 $thirdpartystatic->id = $objp->socid;
577 $thirdpartystatic->name = $objp->name;
578 $thirdpartystatic->client = $objp->client;
579 $thirdpartystatic->fournisseur = $objp->fournisseur;
580 $thirdpartystatic->code_client = $objp->code_client;
581 $thirdpartystatic->code_compta_client = $objp->code_compta_client;
582 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
583 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
584 $thirdpartystatic->email = $objp->email;
585 $thirdpartystatic->country_code = $objp->country_code;
586 $thirdpartystatic->tva_intra = $objp->tva_intra;
587 $thirdpartystatic->code_compta_product = $objp->company_code_buy;
589 $product_static->ref = $objp->product_ref;
590 $product_static->id = $objp->product_id;
591 $product_static->type = $objp->type;
592 $product_static->label = $objp->product_label;
593 $product_static->status = $objp->status;
594 $product_static->status_buy = $objp->status_buy;
595 $product_static->accountancy_code_sell = $objp->code_sell;
596 $product_static->accountancy_code_sell_intra = $objp->code_sell_intra;
597 $product_static->accountancy_code_sell_export = $objp->code_sell_export;
598 $product_static->accountancy_code_buy = $objp->code_buy;
599 $product_static->accountancy_code_buy_intra = $objp->code_buy_intra;
600 $product_static->accountancy_code_buy_export = $objp->code_buy_export;
601 $product_static->tva_tx = $objp->tva_tx_prod;
603 $facturefourn_static->ref = $objp->ref;
604 $facturefourn_static->id = $objp->facid;
605 $facturefourn_static->type = $objp->ftype;
606 $facturefourn_static->ref_supplier = $objp->ref_supplier;
607 $facturefourn_static->label = $objp->invoice_label;
608 $facturefourn_static->date = $db->jdate($objp->datef);
609 $facturefourn_static->fk_facture_source = $objp->fk_facture_source;
611 $facturefourn_static_det->id = $objp->rowid;
612 $facturefourn_static_det->total_ht = $objp->total_ht;
613 $facturefourn_static_det->tva_tx = $objp->tva_tx_line;
614 $facturefourn_static_det->vat_src_code = $objp->vat_src_code;
615 $facturefourn_static_det->product_type = $objp->type_l;
616 $facturefourn_static_det->desc = $objp->description;
618 $accountingAccountArray = array(
619 'dom' => $objp->aarowid,
620 'intra' => $objp->aarowid_intra,
621 'export' => $objp->aarowid_export,
622 'thirdparty' => $objp->aarowid_thirdparty);
624 $code_buy_p_notset =
'';
625 $code_buy_t_notset =
'';
629 $return = $accountingAccount->getAccountingCodeToBind($mysoc, $thirdpartystatic, $product_static, $facturefourn_static, $facturefourn_static_det, $accountingAccountArray,
'supplier');
630 if (!is_array($return) && $return < 0) {
633 $suggestedid = $return[
'suggestedid'];
634 $suggestedaccountingaccountfor = $return[
'suggestedaccountingaccountfor'];
635 $suggestedaccountingaccountbydefaultfor = $return[
'suggestedaccountingaccountbydefaultfor'];
636 $code_buy_l = $return[
'code_l'];
637 $code_buy_p = $return[
'code_p'];
638 $code_buy_t = $return[
'code_t'];
642 if (!empty($code_buy_p)) {
645 $code_buy_p_notset =
'color:orange';
647 if (empty($code_buy_l) && empty($code_buy_p)) {
648 $code_buy_p_notset =
'color:red';
659 print
'<tr class="oddeven">';
662 print
'<td>'.$facturefourn_static_det->id.
'</td>';
665 print
'<td class="nowraponall">'.$facturefourn_static->getNomUrl(1);
666 if ($objp->ref_supplier) {
667 print
'<br><span class="opacitymedium small">'.dol_escape_htmltag($objp->ref_supplier).
'</span>';
677 print
'<td class="tdoverflowmax100 small" title="'.dol_escape_htmltag($objp->invoice_label).
'">';
682 print
'<td class="center">'.dol_print_date($facturefourn_static->date,
'day').
'</td>';
685 print
'<td class="tdoverflowmax100">';
686 if ($product_static->id > 0) {
687 print $product_static->getNomUrl(1);
689 if ($product_static->label) {
690 print
'<br><span class="opacitymedium small">'.dol_escape_htmltag($product_static->label).
'</span>';
696 print
'<td class="tdoverflowmax150 small classfortooltip" title="'.dol_escape_htmltag($text).
'">';
701 print
'<td class="right nowraponall amount">';
702 print
price($objp->total_ht);
706 $code_vat_differ =
'';
710 print
'<td class="right'.($code_vat_differ ?
' '.$code_vat_differ :
'').
'">';
711 print
vatrate($facturefourn_static_det->tva_tx.($facturefourn_static_det->vat_src_code ?
' ('.$facturefourn_static_det->vat_src_code.
')' :
''), false, 0, 0, 1);
715 print
'<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1,
'supplier').
'</td>';
718 $labelcountry = ($objp->country_code && ($langs->trans(
"Country".$objp->country_code) !=
"Country".$objp->country_code)) ? $langs->trans(
"Country".$objp->country_code) : $objp->country_label;
719 print
'<td class="tdoverflowmax100" title="'.dol_escape_htmltag($labelcountry).
'">';
724 print
'<td class="tdoverflowmax80" title="'.dol_escape_htmltag($objp->tva_intra).
'">'.
dol_escape_htmltag($objp->tva_intra).
'</td>';
727 print
'<td class="small">';
728 $s =
'1. '.(($facturefourn_static_det->product_type == 1) ? $langs->trans(
"DefaultForService") : $langs->trans(
"DefaultForProduct")).
': ';
731 if ($suggestedaccountingaccountbydefaultfor ==
'eec') {
732 $shelp .= $langs->trans(
"SaleEEC");
733 } elseif ($suggestedaccountingaccountbydefaultfor ==
'eecwithvat') {
734 $shelp = $langs->trans(
"SaleEECWithVAT");
735 } elseif ($suggestedaccountingaccountbydefaultfor ==
'eecwithoutvatnumber') {
736 $shelp = $langs->trans(
"SaleEECWithoutVATNumber");
738 } elseif ($suggestedaccountingaccountbydefaultfor ==
'export') {
739 $shelp .= $langs->trans(
"SaleExport");
741 $s .= ($code_buy_l > 0 ?
length_accountg($code_buy_l) :
'<span style="'.$code_buy_p_notset.
'">'.$langs->trans(
"NotDefined").
'</span>');
742 print $form->textwithpicto($s, $shelp, 1, $ttype,
'', 0, 2,
'', 1);
743 if ($product_static->id > 0) {
745 $s =
'2. '.(($facturefourn_static_det->product_type == 1) ? $langs->trans(
"ThisService") : $langs->trans(
"ThisProduct")).
': ';
748 if ($suggestedaccountingaccountfor ==
'eec') {
749 $shelp = $langs->trans(
"SaleEEC");
750 } elseif ($suggestedaccountingaccountfor ==
'eecwithvat') {
751 $shelp = $langs->trans(
"SaleEECWithVAT");
752 } elseif ($suggestedaccountingaccountfor ==
'eecwithoutvatnumber') {
753 $shelp = $langs->trans(
"SaleEECWithoutVATNumber");
755 } elseif ($suggestedaccountingaccountfor ==
'export') {
756 $shelp = $langs->trans(
"SaleExport");
758 $s .= (empty($code_buy_p) ?
'<span style="'.$code_buy_p_notset.
'">'.$langs->trans(
"NotDefined").
'</span>' :
length_accountg($code_buy_p));
759 print $form->textwithpicto($s, $shelp, 1, $ttype,
'', 0, 2,
'', 1);
762 $s =
'2. '.(($objp->type_l == 1) ? $langs->trans(
"ThisService") : $langs->trans(
"ThisProduct")).
': ';
764 $s .= $langs->trans(
"NotDefined");
765 print $form->textwithpicto($s, $shelp, 1,
'help',
'', 0, 2,
'', 1);
769 $s =
'3. '.(($facturefourn_static_det->product_type == 1) ? $langs->trans(
"ServiceForThisThirdparty") : $langs->trans(
"ProductForThisThirdparty")).
': ';
771 $s .= ($code_buy_t > 0 ?
length_accountg($code_buy_t) :
'<span style="'.$code_buy_t_notset.
'">'.$langs->trans(
"NotDefined").
'</span>');
772 print $form->textwithpicto($s, $shelp, 1,
'help',
'', 0, 2,
'', 1);
778 print $formaccounting->select_account(($default_account > 0 && $confirm ===
'yes' && in_array($objp->rowid.
"_".$i, $toselect)) ? $default_account : $suggestedid,
'codeventil'.$facturefourn_static_det->id, 1, array(), 0, 0,
'codeventil maxwidth150 maxwidthonsmartphone',
'cachewithshowemptyone');
782 print
'<td class="center">';
784 if (!empty($suggestedid) && $suggestedaccountingaccountfor !=
'' && $suggestedaccountingaccountfor !=
'eecwithoutvatnumber') {
788 if (!empty($toselect)) {
790 if (in_array($objp->rowid.
"_".$i, $toselect)) {
795 print
'<input type="checkbox" class="flat checkforselect checkforselect'.$facturefourn_static_det->id.
'" name="toselect[]" value="'.$facturefourn_static_det->id.
"_".$i.
'"'.($ischecked ?
" checked" :
"").
'/>';
801 if ($num_lines == 0) {
802 print
'<tr><td colspan="14"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
812if ($db->type ==
'mysqli') {
813 $db->query(
"SET SQL_BIG_SELECTS=0");
817print
'<script type="text/javascript">
818jQuery(document).ready(function() {
819 jQuery(".codeventil").change(function() {
820 var s=$(this).attr("id").replace("codeventil", "")
821 console.log(s+" "+$(this).val());
822 if ($(this).val() == -1) jQuery(".checkforselect"+s).prop("checked", false);
823 else jQuery(".checkforselect"+s).prop("checked", true);
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).
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.
const TYPE_SITUATION
Situation invoice.
Class to manage suppliers invoices.
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
const TYPE_REPLACEMENT
Replacement invoice.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage line invoices.
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.
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_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)
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 '.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show 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.
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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.