27 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
41 $langs->loadLangs(array(
"compta",
"bills",
"other",
"accountancy",
"productbatch",
"products"));
43 $optioncss =
GETPOST(
'optioncss',
'aZ');
45 $account_parent =
GETPOST(
'account_parent');
46 $changeaccount =
GETPOST(
'changeaccount');
48 $search_societe =
GETPOST(
'search_societe',
'alpha');
49 $search_lineid =
GETPOST(
'search_lineid',
'int');
50 $search_ref =
GETPOST(
'search_ref',
'alpha');
51 $search_invoice =
GETPOST(
'search_invoice',
'alpha');
52 $search_label =
GETPOST(
'search_label',
'alpha');
53 $search_desc =
GETPOST(
'search_desc',
'alpha');
54 $search_amount =
GETPOST(
'search_amount',
'alpha');
55 $search_account =
GETPOST(
'search_account',
'alpha');
56 $search_vat =
GETPOST(
'search_vat',
'alpha');
57 $search_day =
GETPOST(
"search_day",
"int");
58 $search_month =
GETPOST(
"search_month",
"int");
59 $search_year =
GETPOST(
"search_year",
"int");
60 $search_country =
GETPOST(
'search_country',
'alpha');
61 $search_tvaintra =
GETPOST(
'search_tvaintra',
'alpha');
64 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
65 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
66 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
68 if (empty($page) || $page < 0) $page = 0;
69 $offset = $limit * $page;
70 $pageprev = $page - 1;
71 $pagenext = $page + 1;
73 $sortfield =
"f.datef, f.ref, l.rowid";
75 if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE > 0) {
83 if (!$user->rights->accounting->bind->write)
94 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
103 $search_account =
'';
108 $search_country =
'';
109 $search_tvaintra =
'';
112 if (is_array($changeaccount) && count($changeaccount) > 0) {
115 if (!(
GETPOST(
'account_parent',
'int') >= 0))
118 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Account")), null,
'errors');
126 $sql1 =
"UPDATE ".MAIN_DB_PREFIX.
"facture_fourn_det as l";
127 $sql1 .=
" SET l.fk_code_ventilation=".(GETPOST(
'account_parent',
'int') > 0 ?
GETPOST(
'account_parent',
'int') :
'0');
128 $sql1 .=
' WHERE l.rowid IN ('.implode(
',', $changeaccount).
')';
130 dol_syslog(
'accountancy/supplier/lines.php::changeaccount sql= '.$sql1);
131 $resql1 = $db->query($sql1);
144 $account_parent =
'';
153 $form =
new Form($db);
156 llxHeader(
'', $langs->trans(
"SuppliersVentilation").
' - '.$langs->trans(
"Dispatched"));
158 print '<script type="text/javascript">
160 $(\'#select-all\').click(function(event) {
161 // Iterate each checkbox
162 $(\':checkbox\').each(function() {
166 $(\'#unselect-all\').click(function(event) {
167 // Iterate each checkbox
168 $(\':checkbox\').each(function() {
169 this.checked = false;
178 $sql =
"SELECT f.rowid as facid, f.ref as ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.fk_soc,";
179 $sql .=
" l.rowid, l.fk_product, l.product_type as line_type, l.description, l.total_ht , l.qty, l.tva_tx, l.vat_src_code,";
180 $sql .=
" aa.label, aa.labelshort, aa.account_number,";
181 $sql .=
" p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tobuy, p.tosell,";
182 $sql .=
" p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,";
183 $sql .=
" co.code as country_code, co.label as country,";
184 $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";
185 $parameters = array();
186 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
187 $sql .= $hookmanager->resPrint;
188 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn_det as l";
189 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = l.fk_product";
190 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = l.fk_code_ventilation";
191 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"facture_fourn as f ON f.rowid = l.fk_facture_fourn";
192 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = f.fk_soc";
193 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON co.rowid = s.fk_pays ";
194 $sql .=
" WHERE f.rowid = l.fk_facture_fourn and f.fk_statut >= 1 AND l.fk_code_ventilation <> 0 ";
196 if ($search_societe) {
199 if ($search_lineid) {
202 if (strlen(trim($search_invoice))) {
205 if (strlen(trim($search_label))) {
208 if (strlen(trim($search_ref))) {
211 if (strlen(trim($search_desc))) {
214 if (strlen(trim($search_amount))) {
217 if (strlen(trim($search_account))) {
220 if (strlen(trim($search_vat))) {
223 $sql .=
dolSqlDateFilter(
'f.datef', $search_day, $search_month, $search_year);
224 if (strlen(trim($search_country))) {
226 $country_code_in_EEC = $country_code_in_EEC_without_me =
'';
227 foreach ($arrayofcode as $key => $value)
229 $country_code_in_EEC .= ($country_code_in_EEC ?
"," :
"").
"'".$value.
"'";
230 if ($value != $mysoc->country_code) $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ?
"," :
"").
"'".$value.
"'";
232 if ($search_country ==
'special_allnotme') $sql .=
" AND co.code <> '".$db->escape($mysoc->country_code).
"'";
233 elseif ($search_country ==
'special_eec') $sql .= " AND co.
code IN (".$country_code_in_EEC.")";
234 elseif ($search_country == 'special_eecnotme') $sql .= " AND co.
code IN (".$country_code_in_EEC_without_me.")";
235 elseif ($search_country == 'special_noteec') $sql .= " AND co.
code NOT IN (".$country_code_in_EEC.")";
238 if (strlen(trim($search_tvaintra))) {
241 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn', 0).
")";
244 $parameters = array();
245 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
246 $sql .= $hookmanager->resPrint;
248 $sql .= $db->order($sortfield, $sortorder);
251 $nbtotalofrecords =
'';
252 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
254 $result = $db->query($sql);
255 $nbtotalofrecords = $db->num_rows($result);
256 if (($page * $limit) > $nbtotalofrecords)
263 $sql .= $db->plimit($limit + 1, $offset);
265 dol_syslog(
"accountancy/supplier/lines.php", LOG_DEBUG);
266 $result = $db->query($sql);
268 $num_lines = $db->num_rows($result);
272 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
273 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
274 if ($search_societe) $param .=
"&search_societe=".urlencode($search_societe);
275 if ($search_invoice) $param .=
"&search_invoice=".urlencode($search_invoice);
276 if ($search_ref) $param .=
"&search_ref=".urlencode($search_ref);
277 if ($search_label) $param .=
"&search_label=".urlencode($search_label);
278 if ($search_desc) $param .=
"&search_desc=".urlencode($search_desc);
279 if ($search_account) $param .=
"&search_account=".urlencode($search_account);
280 if ($search_vat) $param .=
"&search_vat=".urlencode($search_vat);
281 if ($search_day) $param .=
'&search_day='.urlencode($search_day);
282 if ($search_month) $param .=
'&search_month='.urlencode($search_month);
283 if ($search_year) $param .=
'&search_year='.urlencode($search_year);
284 if ($search_country) $param .=
"&search_country=".urlencode($search_country);
285 if ($search_tvaintra) $param .=
"&search_tvaintra=".urlencode($search_tvaintra);
287 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">'.
"\n";
288 print
'<input type="hidden" name="action" value="ventil">';
289 if ($optioncss !=
'') print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
290 print
'<input type="hidden" name="token" value="'.newToken().
'">';
291 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
292 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
293 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
294 print
'<input type="hidden" name="page" value="'.$page.
'">';
296 print_barre_liste($langs->trans(
"InvoiceLinesDone"), $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords,
'title_accountancy', 0,
'',
'', $limit);
297 print
'<span class="opacitymedium">'.$langs->trans(
"DescVentilDoneSupplier").
'</span><br>';
299 print
'<br><div class="inline-block divButAction">'.$langs->trans(
"ChangeAccount").
'<br>';
300 print $formaccounting->select_account($account_parent,
'account_parent', 2, array(), 0, 0,
'maxwidth300 maxwidthonsmartphone valignmiddle');
301 print
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"ChangeBinding").
'"/></div>';
305 print
'<div class="div-table-responsive">';
306 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
309 print
'<tr class="liste_titre_filter">';
310 print
'<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).
'"></td>';
311 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).
'"></td>';
312 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="'.dol_escape_htmltag($search_label).
'"></td>';
313 print
'<td class="liste_titre center nowraponall">';
314 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.
'">';
315 print
'<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.$search_month.
'">';
316 $formother->select_year($search_year,
'search_year', 1, 20, 5);
318 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'"></td>';
319 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).
'"></td>';
320 print
'<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).
'"></td>';
321 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>';
322 print
'<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).
'"></td>';
323 print
'<td class="liste_titre">';
324 print $form->select_country($search_country,
'search_country',
'', 0,
'maxwidth150',
'code2', 1, 0, 1);
327 print
'<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).
'"></td>';
328 print
'<td class="liste_titre center"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).
'"></td>';
329 print
'<td class="liste_titre center">';
330 $searchpicto = $form->showFilterButtons();
332 print
"</td></tr>\n";
334 print
'<tr class="liste_titre">';
338 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"f.datef, f.ref, l.rowid",
"", $param,
'', $sortfield, $sortorder,
'center ');
341 print_liste_field_titre(
"ProductDescription", $_SERVER[
"PHP_SELF"],
"l.description",
"", $param,
'', $sortfield, $sortorder);
342 print_liste_field_titre(
"Amount", $_SERVER[
"PHP_SELF"],
"l.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right ');
343 print_liste_field_titre(
"VATRate", $_SERVER[
"PHP_SELF"],
"l.tva_tx",
"", $param,
'', $sortfield, $sortorder,
'right ');
346 print_liste_field_titre(
"VATIntraShort", $_SERVER[
"PHP_SELF"],
"s.tva_intra",
"", $param,
'', $sortfield, $sortorder);
347 print_liste_field_titre(
"AccountAccounting", $_SERVER[
"PHP_SELF"],
"aa.account_number",
"", $param,
'', $sortfield, $sortorder);
348 $checkpicto = $form->showCheckAddButtons();
352 $thirdpartystatic =
new Societe($db);
358 while ($i < min($num_lines, $limit))
360 $objp = $db->fetch_object($result);
362 $facturefournisseur_static->ref = $objp->ref;
363 $facturefournisseur_static->id = $objp->facid;
365 $thirdpartystatic->id = $objp->socid;
366 $thirdpartystatic->name = $objp->name;
367 $thirdpartystatic->client = $objp->client;
368 $thirdpartystatic->fournisseur = $objp->fournisseur;
369 $thirdpartystatic->code_client = $objp->code_client;
370 $thirdpartystatic->code_compta_client = $objp->code_compta_client;
371 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
372 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
373 $thirdpartystatic->email = $objp->email;
374 $thirdpartystatic->country_code = $objp->country_code;
376 $productstatic->ref = $objp->product_ref;
377 $productstatic->id = $objp->product_id;
378 $productstatic->label = $objp->product_label;
379 $productstatic->type = $objp->line_type;
380 $productstatic->status = $objp->tosell;
381 $productstatic->status_buy = $objp->tobuy;
382 $productstatic->accountancy_code_buy = $objp->accountancy_code_buy;
383 $productstatic->accountancy_code_buy_intra = $objp->accountancy_code_sell_buy;
384 $productstatic->accountancy_code_buy_export = $objp->accountancy_code_sell_buy;
386 $accountingaccountstatic->rowid = $objp->fk_compte;
387 $accountingaccountstatic->label = $objp->label;
388 $accountingaccountstatic->labelshort = $objp->labelshort;
389 $accountingaccountstatic->account_number = $objp->account_number;
391 print
'<tr class="oddeven">';
394 print
'<td>'.$objp->rowid.
'</td>';
397 print
'<td class="nowraponall">'.$facturefournisseur_static->getNomUrl(1).
'</td>';
399 print
'<td class="tdoverflowonsmartphone">';
400 print $objp->invoice_label;
404 print
'<td class="center">'.dol_print_date($db->jdate($objp->datef),
'day').
'</td>';
407 print
'<td class="tdoverflowmax100">';
408 if ($productstatic->id > 0) print $productstatic->getNomUrl(1);
409 if ($productstatic->id > 0 && $objp->product_label) print
'<br>';
410 if ($objp->product_label) print
'<span class="opacitymedium">'.$objp->product_label.
'</span>';
413 print
'<td class="tdoverflowonsmartphone">';
415 $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
416 print $form->textwithtooltip(
dol_trunc($text, $trunclength), $objp->description);
419 print
'<td class="nowrap right">'.price($objp->total_ht).
'</td>';
421 print
'<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ?
' ('.$objp->vat_src_code.
')' :
'')).
'</td>';
424 print
'<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1,
'supplier').
'</td>';
428 if ($objp->country_code)
430 print $langs->trans(
"Country".$objp->country_code).
' ('.$objp->country_code.
')';
434 print
'<td>'.$objp->tva_intra.
'</td>';
436 print
'<td class="center">';
437 print $accountingaccountstatic->getNomUrl(0, 1, 1,
'', 1);
438 print
' <a class="editfielda" href="./card.php?id='.$objp->rowid.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].($param ?
'?'.$param :
'')).
'">';
441 print
'<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.
'"/></td>';
449 if ($nbtotalofrecords > $limit) {
450 print_barre_liste(
'', $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num_lines, $nbtotalofrecords,
'', 0,
'',
'', $limit, 1);
455 print $db->lasterror();
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.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
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
getCountriesInEEC()
Return list of countries that are inside the EEC (European Economic Community) Note: Try to keep this...
Class to manage suppliers invoices.
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) ...
print $_SERVER["PHP_SELF"]
Edit parameters.
dolGetFirstLineOfText($text, $nboflines=1, $charset= 'UTF-8')
Return first line of text.
print
Draft customers invoices.
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.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
Class to manage predefined suppliers products.