29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
37$langs->loadLangs(array(
"compta",
"bills",
"other",
"accountancy"));
53$year_end = $year_start + 1;
54$month_end = $month_start - 1;
59$search_date_start =
dol_mktime(0, 0, 0, $month_start, 1, $year_start);
61$year_current = $year_start;
64$action =
GETPOST(
'action',
'aZ09');
69if (!isModEnabled(
'accounting')) {
72if ($user->socid > 0) {
75if (!$user->hasRight(
'accounting',
'bind',
'write')) {
84if (($action ==
'clean' || $action ==
'validatehistory') && $user->hasRight(
'accounting',
'bind',
'write')) {
87 $sql1 =
"UPDATE ".$db->prefix().
"facture_fourn_det as fd";
88 $sql1 .=
" SET fk_code_ventilation = 0";
89 $sql1 .=
' WHERE fd.fk_code_ventilation NOT IN';
90 $sql1 .=
' (SELECT accnt.rowid ';
91 $sql1 .=
" FROM ".$db->prefix().
"accounting_account as accnt";
92 $sql1 .=
" INNER JOIN ".$db->prefix().
"accounting_system as syst";
93 $sql1 .=
" ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid = ".getDolGlobalInt(
'CHARTOFACCOUNTS').
" AND accnt.entity = ".((int) $conf->entity).
")";
94 $sql1 .=
" AND fd.fk_facture_fourn IN (SELECT rowid FROM ".$db->prefix().
"facture_fourn WHERE entity = ".((int) $conf->entity).
")";
95 $sql1 .=
" AND fk_code_ventilation <> 0";
97 dol_syslog(
"htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
98 $resql1 = $db->query($sql1);
109if ($action ==
'validatehistory' && $user->hasRight(
'accounting',
'bind',
'write')) {
119 $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,";
120 $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,";
121 $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,";
123 $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,";
125 $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,";
127 $sql .=
" aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export, aa4.rowid as aarowid_thirdparty,";
128 $sql .=
" co.code as country_code, co.label as country_label,";
129 $sql .=
" s.tva_intra,";
131 $sql .=
" spe.accountancy_code_buy as company_code_buy";
133 $sql .=
" s.accountancy_code_buy as company_code_buy";
135 $sql .=
" FROM ".$db->prefix().
"facture_fourn as f";
136 $sql .=
" INNER JOIN ".$db->prefix().
"societe as s ON s.rowid = f.fk_soc";
138 $sql .=
" LEFT JOIN " . $db->prefix() .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
140 $sql .=
" LEFT JOIN ".$db->prefix().
"c_country as co ON co.rowid = s.fk_pays ";
141 $sql .=
" INNER JOIN ".$db->prefix().
"facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
142 $sql .=
" LEFT JOIN ".$db->prefix().
"product as p ON p.rowid = l.fk_product";
144 $sql .=
" LEFT JOIN " . $db->prefix() .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
146 $alias_societe_perentity = !
getDolGlobalString(
'MAIN_COMPANY_PERENTITY_SHARED') ?
"s" :
"spe";
147 $alias_product_perentity = !
getDolGlobalString(
'MAIN_PRODUCT_PERENTITY_SHARED') ?
"p" :
"ppe";
148 $sql .=
" LEFT JOIN ".$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;
149 $sql .=
" LEFT JOIN ".$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;
150 $sql .=
" LEFT JOIN ".$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;
151 $sql .=
" LEFT JOIN ".$db->prefix().
"accounting_account as aa4 ON " . $alias_product_perentity .
".accountancy_code_buy = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode).
"' AND aa4.entity = ".$conf->entity;
152 $sql .=
" WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
153 $sql .=
" AND l.product_type <= 2";
154 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn', 0).
")";
156 $sql .=
" AND f.datef >= '".$db->idate(
getDolGlobalString(
'ACCOUNTING_DATE_START_BINDING')).
"'";
158 if ($validatemonth && $validateyear) {
162 dol_syslog(
'htdocs/accountancy/supplier/index.php');
164 $result = $db->query($sql);
169 $num_lines = $db->num_rows($result);
171 $isBuyerInEEC =
isInEEC($mysoc);
173 $thirdpartystatic =
new Societe($db);
176 $product_static =
new Product($db);
179 while ($i < min($num_lines, 10000)) {
180 $objp = $db->fetch_object($result);
182 $thirdpartystatic->id = !empty($objp->socid) ? $objp->socid : 0;
183 $thirdpartystatic->name = !empty($objp->name) ? $objp->name :
"";
184 $thirdpartystatic->client = !empty($objp->client) ? $objp->client :
"";
185 $thirdpartystatic->fournisseur = !empty($objp->fournisseur) ? $objp->fournisseur :
"";
186 $thirdpartystatic->code_client = !empty($objp->code_client) ? $objp->code_client :
"";
187 $thirdpartystatic->code_compta_client = !empty($objp->code_compta_client) ? $objp->code_compta_client :
"";
188 $thirdpartystatic->code_fournisseur = !empty($objp->code_fournisseur) ? $objp->code_fournisseur :
"";
189 $thirdpartystatic->code_compta_fournisseur = !empty($objp->code_compta_fournisseur) ? $objp->code_compta_fournisseur :
"";
190 $thirdpartystatic->email = !empty($objp->email) ? $objp->email :
"";
191 $thirdpartystatic->country_code = !empty($objp->country_code) ? $objp->country_code :
"";
192 $thirdpartystatic->tva_intra = !empty($objp->tva_intra) ? $objp->tva_intra :
"";
193 $thirdpartystatic->code_compta_product = $objp->company_code_buy;
195 $product_static->ref = $objp->product_ref;
196 $product_static->id = $objp->product_id;
197 $product_static->type = $objp->type;
198 $product_static->label = $objp->product_label;
199 $product_static->status = !empty($objp->status) ? $objp->status : 0;
200 $product_static->status_buy = !empty($objp->status_buy) ? $objp->status_buy : 0;
201 $product_static->accountancy_code_sell = $objp->code_sell;
202 $product_static->accountancy_code_sell_intra = $objp->code_sell_intra;
203 $product_static->accountancy_code_sell_export = $objp->code_sell_export;
204 $product_static->accountancy_code_buy = !empty($objp->code_buy) ? $objp->code_buy :
"";
205 $product_static->accountancy_code_buy_intra = !empty($objp->code_buy_intra) ? $objp->code_buy_intra :
"";
206 $product_static->accountancy_code_buy_export = !empty($objp->code_buy_export) ? $objp->code_buy_export :
"";
207 $product_static->tva_tx = $objp->tva_tx_prod;
209 $facture_static->ref = $objp->ref;
210 $facture_static->id = $objp->facid;
211 $facture_static->type = $objp->ftype;
212 $facture_static->ref_supplier = $objp->ref_supplier;
213 $facture_static->label = $objp->invoice_label;
214 $facture_static->date = $db->jdate($objp->datef);
215 $facture_static->fk_facture_source = $objp->fk_facture_source;
217 $facture_static_det->id = $objp->rowid;
218 $facture_static_det->total_ht = $objp->total_ht;
219 $facture_static_det->tva_tx = $objp->tva_tx_line;
220 $facture_static_det->vat_src_code = $objp->vat_src_code;
221 $facture_static_det->product_type = $objp->type_l;
222 $facture_static_det->desc = $objp->description;
224 $accountingAccountArray = array(
225 'dom' => $objp->aarowid,
226 'intra' => $objp->aarowid_intra,
227 'export' => $objp->aarowid_export,
228 'thirdparty' => $objp->aarowid_thirdparty);
230 $code_buy_p_notset =
'';
231 $code_buy_t_notset =
'';
235 $return = $accountingAccount->getAccountingCodeToBind($mysoc, $thirdpartystatic, $product_static, $facture_static, $facture_static_det, $accountingAccountArray,
'supplier');
236 if (!is_array($return) && $return < 0) {
239 $suggestedid = $return[
'suggestedid'];
240 $suggestedaccountingaccountfor = $return[
'suggestedaccountingaccountfor'];
242 if (!empty($suggestedid) && $suggestedaccountingaccountfor !=
'' && $suggestedaccountingaccountfor !=
'eecwithoutvatnumber') {
243 $suggestedid = $return[
'suggestedid'];
249 if ($suggestedid > 0) {
250 $sqlupdate =
"UPDATE ".$db->prefix().
"facture_fourn_det";
251 $sqlupdate .=
" SET fk_code_ventilation = ".((int) $suggestedid);
252 $sqlupdate .=
" WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".((int) $facture_static_det->id);
254 $resqlupdate = $db->query($sqlupdate);
270 if ($num_lines > 10000) {
271 $notpossible += ($num_lines - 10000);
279 setEventMessages($langs->trans(
'AutomaticBindingDone', $nbbinddone, $notpossible),
null, ($notpossible ?
'warnings' :
'mesgs'));
281 setEventMessages($langs->trans(
'DoManualBindingForFailedRecord', $nbbindfailed),
null,
'warnings');
290$help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Liaisons_comptables';
292llxHeader(
'', $langs->trans(
"SuppliersVentilation"), $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy accountancy-supplier page-index');
294$textprevyear =
'<a href="'.$_SERVER[
"PHP_SELF"].
'?year='.($year_current - 1).
'">'.
img_previous().
'</a>';
295$textnextyear =
' <a href="'.$_SERVER[
"PHP_SELF"].
'?year='.($year_current + 1).
'">'.
img_next().
'</a>';
297print
load_fiche_titre($langs->trans(
"SuppliersVentilation").
" ".$textprevyear.
" ".$langs->trans(
"Year").
" ".$year_start.
" ".$textnextyear,
'',
'title_accountancy');
299print
'<span class="opacitymedium">'.$langs->trans(
"DescVentilSupplier").
'</span><br>';
300print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"DescVentilMore", $langs->transnoentitiesnoconv(
"ValidateHistory"), $langs->transnoentitiesnoconv(
"ToBind")).
'<br>';
305$buttonbind =
'<a class="button small" href="'.$_SERVER[
'PHP_SELF'].
'?action=validatehistory&token='.
newToken().
'&year='.$year_current.
'">'.
img_picto($langs->trans(
"ValidateHistory"),
'link',
'class="pictofixedwidth fa-color-unset"').$langs->trans(
"ValidateHistory").
'</a>';
308print_barre_liste(
img_picto(
'',
'unlink',
'class="paddingright fa-color-unset"').$langs->trans(
"OverviewOfAmountOfLinesNotBound"),
'',
'',
'',
'',
'',
'', -1,
'',
'', 0,
'',
'', 0, 1, 1, 0, $buttonbind);
311print
'<div class="div-table-responsive-no-min">';
312print
'<table class="noborder centpercent">';
313print
'<tr class="liste_titre"><td class="minwidth100">'.$langs->trans(
"Account").
'</td>';
314for ($i = 1; $i <= 12; $i++) {
320 if ($cursormonth > 12) {
323 $cursoryear = ($cursormonth <
getDolGlobalInt(
'SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y;
326 print
'<td width="60" class="right">';
327 if (!empty($tmp[
'mday'])) {
328 $param =
'search_date_startday=1&search_date_startmonth='.$cursormonth.
'&search_date_startyear='.$cursoryear;
329 $param .=
'&search_date_endday='.$tmp[
'mday'].
'&search_date_endmonth='.$tmp[
'mon'].
'&search_date_endyear='.$tmp[
'year'];
330 print
'<a href="'.DOL_URL_ROOT.
'/accountancy/supplier/list.php?'.$param.
'">';
332 print $langs->trans(
'MonthShort'.str_pad((
string) $j, 2,
'0', STR_PAD_LEFT));
333 if (!empty($tmp[
'mday'])) {
338print
'<td width="60" class="right"><b>'.$langs->trans(
"Total").
'</b></td></tr>';
340$sql =
"SELECT ".$db->ifsql(
'aa.account_number IS NULL',
"'tobind'",
'aa.account_number').
" AS codecomptable,";
341$sql .=
" ".$db->ifsql(
'aa.label IS NULL',
"'tobind'",
'aa.label').
" AS intitule,";
342for ($i = 1; $i <= 12; $i++) {
347 $sql .=
" SUM(".$db->ifsql(
"MONTH(ff.datef) = ".((
int) $j),
"ffd.total_ht",
"0").
") AS month".str_pad((
string) $j, 2,
"0", STR_PAD_LEFT).
",";
348 $sql .=
" SUM(".$db->ifsql(
"MONTH(ff.datef) = ".((
string) $j),
"1",
"0").
") AS nbmonth".str_pad((
string) $j, 2,
"0", STR_PAD_LEFT).
",";
350$sql .=
" SUM(ffd.total_ht) as total, COUNT(ffd.rowid) as nb";
351$sql .=
" FROM ".$db->prefix().
"facture_fourn_det as ffd";
352$sql .=
" LEFT JOIN ".$db->prefix().
"facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
353$sql .=
" LEFT JOIN ".$db->prefix().
"accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
354$sql .=
" WHERE ff.datef >= '".$db->idate($search_date_start).
"'";
355$sql .=
" AND ff.datef <= '".$db->idate($search_date_end).
"'";
358 $sql .=
" AND ff.datef >= '".$db->idate(
getDolGlobalString(
'ACCOUNTING_DATE_START_BINDING')).
"'";
360$sql .=
" AND ff.fk_statut > 0";
361$sql .=
" AND ffd.product_type <= 2";
362$sql .=
" AND ff.entity IN (".getEntity(
'facture_fourn', 0).
")";
363$sql .=
" AND aa.account_number IS NULL";
369$sql .=
" GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
371dol_syslog(
'htdocs/accountancy/supplier/index.php', LOG_DEBUG);
372$resql = $db->query($sql);
374 $num = $db->num_rows($resql);
376 while ($row = $db->fetch_row($resql)) {
377 print
'<tr class="oddeven">';
379 if ($row[0] ==
'tobind') {
386 if ($row[0] ==
'tobind') {
388 if ($startmonth > 12) {
391 $startyear = ($startmonth <
getDolGlobalInt(
'SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y;
393 if ($endmonth > 12) {
396 $endyear = ($endmonth <
getDolGlobalInt(
'SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y;
397 print $langs->trans(
"UseMenuToSetBindindManualy", DOL_URL_ROOT.
'/accountancy/supplier/list.php?search_date_startday=1&search_date_startmonth='.((
int) $startmonth).
'&search_date_startyear='.((
int) $startyear).
'&search_date_endday=&search_date_endmonth='.((
int) $endmonth).
'&search_date_endyear='.((
int) $endyear), $langs->transnoentitiesnoconv(
"ToBind"));
402 for ($i = 2; $i <= 13; $i++) {
403 $cursormonth = (
getDolGlobalInt(
'SOCIETE_FISCAL_MONTH_START', 1) + $i - 2);
404 if ($cursormonth > 12) {
407 $cursoryear = ($cursormonth <
getDolGlobalInt(
'SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y;
410 print
'<td class="right nowraponall amount" title="'.price($row[2*$i - 2]).
' - '.$row[2*$i - 1].
' lines">';
411 print
price($row[2*$i - 2]);
413 if (!empty(
price2num($row[2*$i - 2])) || !empty($row[2*$i - 1])) {
414 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=validatehistory&year='.$y.
'&validatemonth='.((int) $cursormonth).
'&validateyear='.((int) $cursoryear).
'&token='.
newToken().
'">';
415 print
img_picto($langs->trans(
"ValidateHistory").
' ('.$langs->trans(
'Month'.str_pad((
string) $cursormonth, 2,
'0', STR_PAD_LEFT)).
' '.$cursoryear.
')',
'link',
'class="marginleft2"');
420 print
'<td class="right nowraponall amount"><b>'.price($row[26]).
'</b></td>';
426 print
'<tr class="oddeven"><td colspan="15">';
427 print
'<span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span>';
431 print $db->lasterror();
440print_barre_liste(
img_picto(
'',
'link',
'class="paddingright fa-color-unset"').$langs->trans(
"OverviewOfAmountOfLinesBound"),
'',
'',
'',
'',
'',
'', -1,
'',
'', 0,
'',
'', 0, 1, 1);
443print
'<div class="div-table-responsive-no-min">';
444print
'<table class="noborder centpercent">';
445print
'<tr class="liste_titre"><td class="minwidth100">'.$langs->trans(
"Account").
'</td>';
446for ($i = 1; $i <= 12; $i++) {
452 if ($cursormonth > 12) {
455 $cursoryear = ($cursormonth <
getDolGlobalInt(
'SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y;
458 print
'<td width="60" class="right">';
459 if (!empty($tmp[
'mday'])) {
460 $param =
'search_date_startday=1&search_date_startmonth='.$cursormonth.
'&search_date_startyear='.$cursoryear;
461 $param .=
'&search_date_endday='.$tmp[
'mday'].
'&search_date_endmonth='.$tmp[
'mon'].
'&search_date_endyear='.$tmp[
'year'];
462 print
'<a href="'.DOL_URL_ROOT.
'/accountancy/supplier/lines.php?'.$param.
'">';
464 print $langs->trans(
'MonthShort'.str_pad((
string) $j, 2,
'0', STR_PAD_LEFT));
465 if (!empty($tmp[
'mday'])) {
470print
'<td width="60" class="right"><b>'.$langs->trans(
"Total").
'</b></td></tr>';
472$sql =
"SELECT ".$db->ifsql(
'aa.account_number IS NULL',
"'tobind'",
'aa.account_number').
" AS codecomptable,";
473$sql .=
" ".$db->ifsql(
'aa.label IS NULL',
"'tobind'",
'aa.label').
" AS intitule,";
474for ($i = 1; $i <= 12; $i++) {
479 $sql .=
" SUM(".$db->ifsql(
"MONTH(ff.datef) = ".((
int) $j),
"ffd.total_ht",
"0").
") AS month".str_pad((
string) $j, 2,
"0", STR_PAD_LEFT).
",";
481$sql .=
" SUM(ffd.total_ht) as total";
482$sql .=
" FROM ".$db->prefix().
"facture_fourn_det as ffd";
483$sql .=
" LEFT JOIN ".$db->prefix().
"facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
484$sql .=
" LEFT JOIN ".$db->prefix().
"accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
485$sql .=
" WHERE ff.datef >= '".$db->idate($search_date_start).
"'";
486$sql .=
" AND ff.datef <= '".$db->idate($search_date_end).
"'";
489 $sql .=
" AND ff.datef >= '".$db->idate(
getDolGlobalString(
'ACCOUNTING_DATE_START_BINDING')).
"'";
491$sql .=
" AND ff.entity IN (".getEntity(
'facture_fourn', 0).
")";
492$sql .=
" AND ff.fk_statut > 0";
493$sql .=
" AND ffd.product_type <= 2";
499$sql .=
" AND aa.account_number IS NOT NULL";
500$sql .=
" GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
501$sql .=
' ORDER BY aa.account_number';
503dol_syslog(
'htdocs/accountancy/supplier/index.php');
504$resql = $db->query($sql);
506 $num = $db->num_rows($resql);
508 while ($row = $db->fetch_row($resql)) {
509 print
'<tr class="oddeven">';
510 print
'<td class="tdoverflowmax300"'.(empty($row[1]) ?
'' :
' title="'.dol_escape_htmltag($row[1]).
'"').
'>';
511 if ($row[0] ==
'tobind') {
519 if ($row[0] ==
'tobind') {
520 print $langs->trans(
"UseMenuToSetBindindManualy", DOL_URL_ROOT.
'/accountancy/supplier/list.php?search_year='.((
int) $y), $langs->transnoentitiesnoconv(
"ToBind"));
526 for ($i = 2; $i <= 13; $i++) {
527 print
'<td class="right nowraponall amount">';
528 print
price($row[$i]);
531 print
'<td class="right nowraponall amount"><b>'.price($row[14]).
'</b></td>';
537 print
'<tr class="oddeven"><td colspan="15">';
538 print
'<span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span>';
542 print $db->lasterror();
552 print_barre_liste($langs->trans(
"OtherInfo"),
'',
'',
'',
'',
'',
'', -1,
'',
'', 0,
'',
'', 0, 1, 1);
555 print
'<div class="div-table-responsive-no-min">';
556 print
'<table class="noborder centpercent">';
557 print
'<tr class="liste_titre"><td>'.$langs->trans(
"Total").
'</td>';
558 for ($i = 1; $i <= 12; $i++) {
563 print
'<td width="60" class="right">'.$langs->trans(
'MonthShort'.str_pad((
string) $j, 2,
'0', STR_PAD_LEFT)).
'</td>';
565 print
'<td width="60" class="right"><b>'.$langs->trans(
"Total").
'</b></td></tr>';
567 $sql =
"SELECT '".$db->escape($langs->trans(
"CAHTF")).
"' AS label,";
568 for ($i = 1; $i <= 12; $i++) {
573 $sql .=
" SUM(".$db->ifsql(
"MONTH(ff.datef) = ".((
int) $j),
"ffd.total_ht",
"0").
") AS month".str_pad((
string) $j, 2,
"0", STR_PAD_LEFT).
",";
575 $sql .=
" SUM(ffd.total_ht) as total";
576 $sql .=
" FROM ".$db->prefix().
"facture_fourn_det as ffd";
577 $sql .=
" LEFT JOIN ".$db->prefix().
"facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
578 $sql .=
" WHERE ff.datef >= '".$db->idate($search_date_start).
"'";
579 $sql .=
" AND ff.datef <= '".$db->idate($search_date_end).
"'";
582 $sql .=
" AND ff.datef >= '".$db->idate(
getDolGlobalString(
'ACCOUNTING_DATE_START_BINDING')).
"'";
584 $sql .=
" AND ff.entity IN (".getEntity(
'facture_fourn', 0).
")";
585 $sql .=
" AND ff.fk_statut > 0";
586 $sql .=
" AND ffd.product_type <= 2";
593 dol_syslog(
'htdocs/accountancy/supplier/index.php');
594 $resql = $db->query($sql);
596 $num = $db->num_rows($resql);
598 while ($row = $db->fetch_row($resql)) {
599 print
'<tr><td>'.$row[0].
'</td>';
600 for ($i = 1; $i <= 12; $i++) {
601 print
'<td class="right nowraponall amount">'.price($row[$i]).
'</td>';
603 print
'<td class="right nowraponall amount"><b>'.price($row[13]).
'</b></td>';
608 print $db->lasterror();
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
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 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.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_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.
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.
dol_now($mode='auto')
Return date for now.
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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
img_previous($titlealt='default', $moreatt='')
Show previous logo.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_next($titlealt='default', $moreatt='')
Show next logo.
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_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
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.