28 require
'../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
42 $langs->loadLangs(array(
"bills",
"companies",
"compta",
"accountancy",
"other",
"productbatch",
"products"));
44 $action =
GETPOST(
'action',
'aZ09');
45 $massaction =
GETPOST(
'massaction',
'alpha');
46 $show_files =
GETPOST(
'show_files',
'int');
47 $confirm =
GETPOST(
'confirm',
'alpha');
48 $toselect =
GETPOST(
'toselect',
'array');
51 $mesCasesCochees =
GETPOST(
'toselect',
'array');
54 $search_societe =
GETPOST(
'search_societe',
'alpha');
55 $search_lineid =
GETPOST(
'search_lineid',
'int');
56 $search_invoice =
GETPOST(
'search_invoice',
'alpha');
57 $search_ref =
GETPOST(
'search_ref',
'alpha');
58 $search_label =
GETPOST(
'search_label',
'alpha');
59 $search_desc =
GETPOST(
'search_desc',
'alpha');
60 $search_amount =
GETPOST(
'search_amount',
'alpha');
61 $search_account =
GETPOST(
'search_account',
'alpha');
62 $search_vat =
GETPOST(
'search_vat',
'alpha');
63 $search_day =
GETPOST(
"search_day",
"int");
64 $search_month =
GETPOST(
"search_month",
"int");
65 $search_year =
GETPOST(
"search_year",
"int");
66 $search_country =
GETPOST(
'search_country',
'alpha');
67 $search_tvaintra =
GETPOST(
'search_tvaintra',
'alpha');
69 $btn_ventil =
GETPOST(
'ventil',
'alpha');
72 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
73 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
74 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
76 if (empty($page) || $page < 0) { $page = 0; }
77 $offset = $limit * $page;
78 $pageprev = $page - 1;
79 $pagenext = $page + 1;
81 $sortfield =
"f.datef, f.ref, l.rowid";
83 if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) {
91 if (!$user->rights->accounting->bind->write)
95 $hookmanager->initHooks(array(
'accountancysupplierlist'));
100 $aarowid_s = $accounting->fetch(
'', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1);
101 $aarowid_p = $accounting->fetch(
'', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1);
103 $chartaccountcode =
dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS,
'accounting_system',
'rowid',
'pcg_version');
110 if (
GETPOST(
'cancel',
'alpha')) { $action =
'list'; $massaction =
''; }
111 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') { $massaction =
''; }
113 $parameters = array();
114 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
115 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
120 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
122 $search_societe =
'';
125 $search_invoice =
'';
129 $search_account =
'';
134 $search_country =
'';
135 $search_tvaintra =
'';
139 $objectclass =
'AccountingAccount';
140 $permissiontoread = $user->rights->accounting->read;
141 $permissiontodelete = $user->rights->accounting->delete;
142 $uploaddir = $conf->accounting->dir_output;
143 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
147 if ($massaction ==
'ventil') {
151 if (!empty($mesCasesCochees)) {
152 $msg =
'<div>'.$langs->trans(
"SelectedLines").
': '.count($mesCasesCochees).
'</div>';
153 $msg .=
'<div class="detail">';
158 foreach ($mesCasesCochees as $maLigneCochee) {
159 $maLigneCourante = explode(
"_", $maLigneCochee);
160 $monId = $maLigneCourante[0];
161 $monCompte =
GETPOST(
'codeventil'.$monId);
165 $msg .=
'<div><span style="color:red">'.$langs->trans(
"Lineofinvoice").
' '.$monId.
' - '.$langs->trans(
"NoAccountSelected").
'</span></div>';
168 $sql =
" UPDATE ".MAIN_DB_PREFIX.
"facture_fourn_det";
169 $sql .=
" SET fk_code_ventilation = ".$monCompte;
170 $sql .=
" WHERE rowid = ".$monId;
173 $accountventilated->fetch($monCompte,
'', 1);
175 dol_syslog(
'accountancy/supplier/list.php:: sql='.$sql, LOG_DEBUG);
176 if ($db->query($sql)) {
177 $msg .=
'<div><span style="color:green">'.$langs->trans(
"Lineofinvoice").
' '.$monId.
' - '.$langs->trans(
"VentilatedinAccount").
' : '.
length_accountg($accountventilated->account_number).
'</span></div>';
180 $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>';
188 $msg .=
'<div>'.$langs->trans(
"EndProcessing").
'</div>';
198 $form =
new Form($db);
201 llxHeader(
'', $langs->trans(
"SuppliersVentilation"));
203 if (empty($chartaccountcode))
205 print $langs->trans(
"ErrorChartOfAccountSystemNotSelected");
213 $sql =
"SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,";
214 $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,";
215 $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,";
216 $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,";
217 $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,";
218 $sql .=
" p.tosell as status, p.tobuy as status_buy,";
219 $sql .=
" aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,";
220 $sql .=
" co.code as country_code, co.label as country_label,";
221 $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, s.code_compta as code_compta_client, s.code_compta_fournisseur";
222 $parameters = array();
223 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
224 $sql .= $hookmanager->resPrint;
225 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f";
226 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = f.fk_soc";
227 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON co.rowid = s.fk_pays ";
228 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
229 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = l.fk_product";
230 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$db->escape($chartaccountcode).
"' AND aa.entity = ".$conf->entity;
231 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa2 ON p.accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode).
"' AND aa2.entity = ".$conf->entity;
232 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa3 ON p.accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode).
"' AND aa3.entity = ".$conf->entity;
233 $sql .=
" WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
234 $sql .=
" AND l.product_type <= 2";
236 if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
237 $sql .=
" AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING).
"'";
240 if ($search_societe) {
243 if ($search_lineid) {
246 if (strlen(trim($search_invoice))) {
249 if (strlen(trim($search_label))) {
252 if (strlen(trim($search_ref))) {
255 if (strlen(trim($search_desc))) {
258 if (strlen(trim($search_amount))) {
261 if (strlen(trim($search_account))) {
264 if (strlen(trim($search_vat))) {
267 $sql .=
dolSqlDateFilter(
'f.datef', $search_day, $search_month, $search_year);
268 if (strlen(trim($search_country))) {
270 $country_code_in_EEC = $country_code_in_EEC_without_me =
'';
271 foreach ($arrayofcode as $key => $value)
273 $country_code_in_EEC .= ($country_code_in_EEC ?
"," :
"").
"'".$value.
"'";
274 if ($value != $mysoc->country_code) $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ?
"," :
"").
"'".$value.
"'";
276 if ($search_country ==
'special_allnotme') $sql .=
" AND co.code <> '".$db->escape($mysoc->country_code).
"'";
277 elseif ($search_country ==
'special_eec') $sql .= " AND co.
code IN (".$country_code_in_EEC.")";
278 elseif ($search_country == 'special_eecnotme') $sql .= " AND co.
code IN (".$country_code_in_EEC_without_me.")";
279 elseif ($search_country == 'special_noteec') $sql .= " AND co.
code NOT IN (".$country_code_in_EEC.")";
282 if (strlen(trim($search_tvaintra))) {
285 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
290 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn', 0).
")";
293 $parameters = array();
294 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
295 $sql .= $hookmanager->resPrint;
297 $sql .= $db->order($sortfield, $sortorder);
300 $nbtotalofrecords =
'';
301 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
303 $result = $db->query($sql);
304 $nbtotalofrecords = $db->num_rows($result);
305 if (($page * $limit) > $nbtotalofrecords)
312 $sql .= $db->plimit($limit + 1, $offset);
315 $result = $db->query($sql);
318 $num_lines = $db->num_rows($result);
321 $arrayofselected = is_array($toselect) ? $toselect : array();
324 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
325 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
326 if ($search_societe) $param .=
'&search_societe='.urlencode($search_societe);
327 if ($search_lineid) $param .=
'&search_lineid='.urlencode($search_lineid);
328 if ($search_day) $param .=
'&search_day='.urlencode($search_day);
329 if ($search_month) $param .=
'&search_month='.urlencode($search_month);
330 if ($search_year) $param .=
'&search_year='.urlencode($search_year);
331 if ($search_invoice) $param .=
'&search_invoice='.urlencode($search_invoice);
332 if ($search_ref) $param .=
'&search_ref='.urlencode($search_ref);
333 if ($search_label) $param .=
'&search_label='.urlencode($search_label);
334 if ($search_desc) $param .=
'&search_desc='.urlencode($search_desc);
335 if ($search_amount) $param .=
'&search_amount='.urlencode($search_amount);
336 if ($search_vat) $param .=
'&search_vat='.urlencode($search_vat);
337 if ($search_country) $param .=
"&search_country=".urlencode($search_country);
338 if ($search_tvaintra) $param .=
"&search_tvaintra=".urlencode($search_tvaintra);
340 $arrayofmassactions = array(
341 'ventil'=>$langs->trans(
"Ventilate")
347 $massactionbutton = $form->selectMassAction(
'ventil', $arrayofmassactions, 1);
349 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
350 print '<input type="hidden" name="action" value="ventil">';
351 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
352 print '<input type="hidden" name="token" value="'.newToken().
'">';
353 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
354 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
355 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
356 print '<input type="hidden" name="page" value="'.$page.
'">';
358 print_barre_liste($langs->trans(
"InvoiceLines"), $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords,
'title_accountancy', 0,
'',
'', $limit);
360 print '<span class="opacitymedium">'.$langs->trans(
"DescVentilTodoCustomer").
'</span></br><br>';
362 if ($msg)
print $msg.
'<br>';
366 print '<div class="div-table-responsive">';
367 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
370 print '<tr class="liste_titre_filter">';
371 print
'<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).
'"></td>';
372 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).
'"></td>';
374 print
'<td class="liste_titre center nowraponall minwidth100imp">';
375 if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print
'<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.$search_day.
'">';
376 print
'<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.
'">';
377 $formother->select_year($search_year,
'search_year', 1, 20, 5);
379 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'"></td>';
380 print
'<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).
'"></td>';
381 print
'<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).
'"></td>';
382 print
'<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).
'"></td>';
383 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).
'"></td>';
384 print
'<td class="liste_titre">';
385 print $form->select_country($search_country,
'search_country',
'', 0,
'maxwidth125',
'code2', 1, 0, 1);
388 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).
'"></td>';
389 print
'<td class="liste_titre"></td>';
390 print
'<td class="liste_titre"></td>';
391 print
'<td class="center liste_titre">';
392 $searchpicto = $form->showFilterButtons();
397 print
'<tr class="liste_titre">';
401 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"f.datef, f.ref, l.rowid",
"", $param,
'', $sortfield, $sortorder,
'center ');
404 print_liste_field_titre(
"ProductDescription", $_SERVER[
"PHP_SELF"],
"l.description",
"", $param,
'', $sortfield, $sortorder);
405 print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"l.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right maxwidth50 ');
406 print_liste_field_titre(
"VATRate", $_SERVER[
"PHP_SELF"],
"l.tva_tx",
"", $param,
'', $sortfield, $sortorder,
'right ');
409 print_liste_field_titre(
"VATIntraShort", $_SERVER[
"PHP_SELF"],
"s.tva_intra",
"", $param,
'', $sortfield, $sortorder);
413 if ($massactionbutton) $checkpicto = $form->showCheckAddButtons(
'checkforselect', 1);
417 $thirdpartystatic =
new Societe($db);
419 $product_static =
new Product($db);
421 $isBuyerInEEC =
isInEEC($mysoc);
423 $accountingaccount_codetotid_cache = array();
425 while ($i < min($num_lines, $limit)) {
426 $objp = $db->fetch_object($result);
431 $objp->code_buy_l =
'';
432 $objp->code_buy_p =
'';
434 $thirdpartystatic->id = $objp->socid;
435 $thirdpartystatic->name = $objp->name;
436 $thirdpartystatic->client = $objp->client;
437 $thirdpartystatic->fournisseur = $objp->fournisseur;
438 $thirdpartystatic->code_client = $objp->code_client;
439 $thirdpartystatic->code_compta_client = $objp->code_compta_client;
440 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
441 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
442 $thirdpartystatic->email = $objp->email;
443 $thirdpartystatic->country_code = $objp->country_code;
445 $product_static->ref = $objp->product_ref;
446 $product_static->id = $objp->product_id;
447 $product_static->type = $objp->type;
448 $product_static->label = $objp->product_label;
449 $product_static->status = $objp->status;
450 $product_static->status_buy = $objp->status_buy;
451 $product_static->accountancy_code_sell = $objp->code_sell;
452 $product_static->accountancy_code_sell_intra = $objp->code_sell_intra;
453 $product_static->accountancy_code_sell_export = $objp->code_sell_export;
454 $product_static->accountancy_code_buy = $objp->code_buy;
455 $product_static->accountancy_code_buy_intra = $objp->code_buy_intra;
456 $product_static->accountancy_code_buy_export = $objp->code_buy_export;
458 $facturefourn_static->ref = $objp->ref;
459 $facturefourn_static->id = $objp->facid;
460 $facturefourn_static->type = $objp->type;
461 $facturefourn_static->label = $objp->invoice_label;
463 $code_buy_p_notset =
'';
464 $objp->aarowid_suggest =
'';
466 $isSellerInEEC =
isInEEC($objp);
468 $suggestedaccountingaccountbydefaultfor =
'';
469 if ($objp->type_l == 1) {
470 if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) {
471 $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT :
'');
472 $suggestedaccountingaccountbydefaultfor =
'';
474 if ($isSellerInEEC && $isBuyerInEEC) {
475 $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT :
'');
476 $suggestedaccountingaccountbydefaultfor =
'eec';
478 $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT :
'');
479 $suggestedaccountingaccountbydefaultfor =
'export';
482 } elseif ($objp->type_l == 0) {
483 if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) {
484 $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT :
'');
485 $suggestedaccountingaccountbydefaultfor =
'';
487 if ($isSellerInEEC && $isBuyerInEEC) {
488 $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT :
'');
489 $suggestedaccountingaccountbydefaultfor =
'eec';
491 $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT :
'');
492 $suggestedaccountingaccountbydefaultfor =
'export';
496 if ($objp->code_sell_l == -1) $objp->code_sell_l =
'';
499 $suggestedaccountingaccountfor =
'';
500 if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) {
501 $objp->code_buy_p = $objp->code_buy;
502 $objp->aarowid_suggest = $objp->aarowid;
503 $suggestedaccountingaccountfor =
'';
505 if ($isSellerInEEC && $isBuyerInEEC) {
506 $objp->code_buy_p = $objp->code_buy_intra;
507 $objp->aarowid_suggest = $objp->aarowid_intra;
508 $suggestedaccountingaccountfor =
'eec';
510 $objp->code_buy_p = $objp->code_buy_export;
511 $objp->aarowid_suggest = $objp->aarowid_export;
512 $suggestedaccountingaccountfor =
'export';
516 if (!empty($objp->code_buy_p)) {
519 $code_buy_p_notset =
'color:orange';
521 if (empty($objp->code_buy_l) && empty($objp->code_buy_p)) $code_buy_p_notset =
'color:red';
526 print
'<tr class="oddeven">';
529 print
'<td>'.$objp->rowid.
'</td>';
532 print
'<td class="nowraponall">'.$facturefourn_static->getNomUrl(1).
'</td>';
539 print
'<td class="center">'.dol_print_date($db->jdate($objp->datef),
'day').
'</td>';
542 print
'<td class="tdoverflowmax150">';
543 if ($product_static->id > 0)
544 print $product_static->getNomUrl(1);
545 if ($objp->product_label) print
'<br><span class="opacitymedium small">'.$objp->product_label.
'</span>';
549 print
'<td class="tdoverflowonsmartphone small">';
551 $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
552 print $form->textwithtooltip(
dol_trunc($text, $trunclength), $objp->description);
555 print
'<td class="nowrap right">';
556 print
price($objp->total_ht);
560 if ($objp->vat_tx_l != $objp->vat_tx_p)
561 $code_vat_differ =
'font-weight:bold; text-decoration:blink; color:red';
562 print
'<td style="'.$code_vat_differ.
'" class="right">';
563 print
vatrate($objp->tva_tx_line.($objp->vat_src_code ?
' ('.$objp->vat_src_code.
')' :
''));
567 print
'<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1,
'supplier').
'</td>';
571 $labelcountry = ($objp->country_code && ($langs->trans(
"Country".$objp->country_code) !=
"Country".$objp->country_code)) ? $langs->trans(
"Country".$objp->country_code) : $objp->country_label;
576 print
'<td>'.$objp->tva_intra.
'</td>';
580 $s =
'<span class="small">'.(($objp->type_l == 1) ? $langs->trans(
"DefaultForService") : $langs->trans(
"DefaultForProduct")).
': </span>';
582 if ($suggestedaccountingaccountbydefaultfor ==
'eec') $shelp .= $langs->trans(
"SaleEEC");
583 elseif ($suggestedaccountingaccountbydefaultfor ==
'export') $shelp .= $langs->trans("SaleExport");
584 $s .= ($objp->code_buy_l > 0 ?
length_accountg($objp->code_buy_l) : '<span style="'.$code_buy_p_notset.'">'.$langs->trans("NotDefined").'</span>');
585 print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
586 if ($objp->product_id > 0)
589 $s =
'<span class="small">'.(($objp->type_l == 1) ? $langs->trans(
"ThisService") : $langs->trans(
"ThisProduct")).
': </span>';
591 if ($suggestedaccountingaccountfor ==
'eec') $shelp = $langs->trans(
"SaleEEC");
592 elseif ($suggestedaccountingaccountfor ==
'export') $shelp = $langs->trans("SaleExport");
593 $s .= (empty($objp->code_buy_p) ? '<span style="'.$code_buy_p_notset.'">'.$langs->trans("NotDefined").'</span>' :
length_accountg($objp->code_buy_p));
594 print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
600 $suggestedid = $objp->aarowid_suggest;
601 if (empty($suggestedid) && empty($objp->code_buy_p) && !empty($objp->code_buy_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC))
603 if (empty($accountingaccount_codetotid_cache[$objp->code_buy_l]))
606 $tmpaccount->fetch(0, $objp->code_buy_l, 1);
607 if ($tmpaccount->id > 0) {
608 $suggestedid = $tmpaccount->id;
610 $accountingaccount_codetotid_cache[$objp->code_buy_l] = $tmpaccount->id;
612 $suggestedid = $accountingaccount_codetotid_cache[$objp->code_buy_l];
615 print $formaccounting->select_account($suggestedid,
'codeventil'.$objp->rowid, 1, array(), 0, 0,
'codeventil maxwidth200 maxwidthonsmartphone',
'cachewithshowemptyone');
619 print
'<td class="center">';
620 $ischecked = $objp->aarowid_suggest;
621 print
'<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.
'" name="toselect[]" value="'.$objp->rowid.
"_".$i.
'"'.($ischecked ?
"checked" :
"").
'/>';
635 if ($db->type ==
'mysqli') {
636 $db->query(
"SET SQL_BIG_SELECTS=0");
640 print
'<script type="text/javascript" language="javascript">
641 jQuery(document).ready(function() {
642 jQuery(".codeventil").change(function() {
643 var s=$(this).attr("id").replace("codeventil", "")
644 console.log(s+" "+$(this).val());
645 if ($(this).val() == -1) jQuery(".checkforselect"+s).prop("checked", false);
646 else jQuery(".checkforselect"+s).prop("checked", true);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
const TYPE_DEPOSIT
Deposit invoice.
if(!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'] country if(!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'] typent code
Class to manage products or services.
getCountriesInEEC()
Return list of countries that are inside the EEC (European Economic Community) Note: Try to keep this...
const TYPE_REPLACEMENT
Replacement invoice.
Class to manage suppliers invoices.
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...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
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...
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0)
Generate a SQL string to make a filter into a range (for second of date until last second of date) ...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages...
print $_SERVER["PHP_SELF"]
Edit parameters.
dolGetFirstLineOfText($text, $nboflines=1, $charset= 'UTF-8')
Return first line of text.
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0)
Return an id or code from a code or id.
const TYPE_CREDIT_NOTE
Credit note invoice.
print
Draft customers invoices.
const TYPE_SITUATION
Situation invoice.
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.
Class to manage accounting accounts.
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous) ...
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)