28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
36$langs->loadLangs(array(
"compta",
"bills",
"other",
"accountancy"));
38$validatemonth =
GETPOST(
'validatemonth',
'int');
39$validateyear =
GETPOST(
'validateyear',
'int');
42if (!isModEnabled(
'accounting')) {
45if ($user->socid > 0) {
48if (!$user->hasRight(
'accounting',
'bind',
'write')) {
54$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
56 $year_start =
GETPOST(
"year",
'int');
63$year_end = $year_start + 1;
64$month_end = $month_start - 1;
69$search_date_start =
dol_mktime(0, 0, 0, $month_start, 1, $year_start);
71$year_current = $year_start;
74$action =
GETPOST(
'action',
'aZ09');
79if (!isModEnabled(
'accounting')) {
82if ($user->socid > 0) {
85if (!$user->hasRight(
'accounting',
'mouvements',
'lire')) {
94if (($action ==
'clean' || $action ==
'validatehistory') && $user->hasRight(
'accounting',
'bind',
'write')) {
97 $sql1 =
"UPDATE ".$db->prefix().
"facture_fourn_det as fd";
98 $sql1 .=
" SET fk_code_ventilation = 0";
99 $sql1 .=
' WHERE fd.fk_code_ventilation NOT IN';
100 $sql1 .=
' (SELECT accnt.rowid ';
101 $sql1 .=
" FROM ".$db->prefix().
"accounting_account as accnt";
102 $sql1 .=
" INNER JOIN ".$db->prefix().
"accounting_system as syst";
103 $sql1 .=
" ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid = ".getDolGlobalInt(
'CHARTOFACCOUNTS').
" AND accnt.entity = ".((int) $conf->entity).
")";
104 $sql1 .=
" AND fd.fk_facture_fourn IN (SELECT rowid FROM ".$db->prefix().
"facture_fourn WHERE entity = ".((int) $conf->entity).
")";
105 $sql1 .=
" AND fk_code_ventilation <> 0";
107 dol_syslog(
"htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
108 $resql1 = $db->query($sql1);
119if ($action ==
'validatehistory') {
129 $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,";
130 $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,";
131 $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,";
132 if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
133 $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,";
135 $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,";
137 $sql .=
" aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export, aa4.rowid as aarowid_thirdparty,";
138 $sql .=
" co.code as country_code, co.label as country_label,";
139 $sql .=
" s.tva_intra,";
140 if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
141 $sql .=
" spe.accountancy_code_buy as company_code_buy";
143 $sql .=
" s.accountancy_code_buy as company_code_buy";
145 $sql .=
" FROM ".$db->prefix().
"facture_fourn as f";
146 $sql .=
" INNER JOIN ".$db->prefix().
"societe as s ON s.rowid = f.fk_soc";
147 if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
148 $sql .=
" LEFT JOIN " . $db->prefix() .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
150 $sql .=
" LEFT JOIN ".$db->prefix().
"c_country as co ON co.rowid = s.fk_pays ";
151 $sql .=
" INNER JOIN ".$db->prefix().
"facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
152 $sql .=
" LEFT JOIN ".$db->prefix().
"product as p ON p.rowid = l.fk_product";
153 if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
154 $sql .=
" LEFT JOIN " . $db->prefix() .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
156 $alias_societe_perentity = empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED) ?
"s" :
"spe";
157 $alias_product_perentity = empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ?
"p" :
"ppe";
158 $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;
159 $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;
160 $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;
161 $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;
162 $sql .=
" WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
163 $sql .=
" AND l.product_type <= 2";
164 $sql .=
" AND f.entity IN (".getEntity(
'facture_fourn', 0).
")";
165 if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
166 $sql .=
" AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING).
"'";
168 if ($validatemonth && $validateyear) {
172 dol_syslog(
'htdocs/accountancy/supplier/index.php');
174 $result = $db->query($sql);
179 $num_lines = $db->num_rows($result);
181 $isBuyerInEEC =
isInEEC($mysoc);
183 $thirdpartystatic =
new Societe($db);
186 $product_static =
new Product($db);
189 while ($i < min($num_lines, 10000)) {
190 $objp = $db->fetch_object($result);
192 $thirdpartystatic->id = $objp->socid;
193 $thirdpartystatic->name = $objp->name;
194 $thirdpartystatic->client = $objp->client;
195 $thirdpartystatic->fournisseur = $objp->fournisseur;
196 $thirdpartystatic->code_client = $objp->code_client;
197 $thirdpartystatic->code_compta_client = $objp->code_compta_client;
198 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
199 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
200 $thirdpartystatic->email = $objp->email;
201 $thirdpartystatic->country_code = $objp->country_code;
202 $thirdpartystatic->tva_intra = $objp->tva_intra;
203 $thirdpartystatic->code_compta_product = $objp->company_code_buy;
205 $product_static->ref = $objp->product_ref;
206 $product_static->id = $objp->product_id;
207 $product_static->type = $objp->type;
208 $product_static->label = $objp->product_label;
209 $product_static->status = $objp->status;
210 $product_static->status_buy = $objp->status_buy;
211 $product_static->accountancy_code_sell = $objp->code_sell;
212 $product_static->accountancy_code_sell_intra = $objp->code_sell_intra;
213 $product_static->accountancy_code_sell_export = $objp->code_sell_export;
214 $product_static->accountancy_code_buy = $objp->code_buy;
215 $product_static->accountancy_code_buy_intra = $objp->code_buy_intra;
216 $product_static->accountancy_code_buy_export = $objp->code_buy_export;
217 $product_static->tva_tx = $objp->tva_tx_prod;
219 $facture_static->ref = $objp->ref;
220 $facture_static->id = $objp->facid;
221 $facture_static->type = $objp->ftype;
222 $facture_static->ref_supplier = $objp->ref_supplier;
223 $facture_static->label = $objp->invoice_label;
224 $facture_static->date = $db->jdate($objp->datef);
225 $facture_static->fk_facture_source = $objp->fk_facture_source;
227 $facture_static_det->id = $objp->rowid;
228 $facture_static_det->total_ht = $objp->total_ht;
229 $facture_static_det->tva_tx = $objp->tva_tx_line;
230 $facture_static_det->vat_src_code = $objp->vat_src_code;
231 $facture_static_det->product_type = $objp->type_l;
232 $facture_static_det->desc = $objp->description;
234 $accountingAccountArray = array(
235 'dom'=>$objp->aarowid,
236 'intra'=>$objp->aarowid_intra,
237 'export'=>$objp->aarowid_export,
238 'thirdparty' =>$objp->aarowid_thirdparty);
240 $code_buy_p_notset =
'';
241 $code_buy_t_notset =
'';
245 $return = $accountingAccount->getAccountingCodeToBind($mysoc, $thirdpartystatic, $product_static, $facture_static, $facture_static_det, $accountingAccountArray,
'supplier');
246 if (!is_array($return) && $return<0) {
249 $suggestedid = $return[
'suggestedid'];
250 $suggestedaccountingaccountfor = $return[
'suggestedaccountingaccountfor'];
252 if (!empty($suggestedid) && $suggestedaccountingaccountfor !=
'' && $suggestedaccountingaccountfor !=
'eecwithoutvatnumber') {
253 $suggestedid = $return[
'suggestedid'];
259 if ($suggestedid > 0) {
260 $sqlupdate =
"UPDATE ".$db->prefix().
"facture_fourn_det";
261 $sqlupdate .=
" SET fk_code_ventilation = ".((int) $suggestedid);
262 $sqlupdate .=
" WHERE fk_code_ventilation <= 0 AND product_type <= 2 AND rowid = ".((int) $facture_static_det->id);
264 $resqlupdate = $db->query($sqlupdate);
280 if ($num_lines > 10000) {
281 $notpossible += ($num_lines - 10000);
289 setEventMessages($langs->trans(
'AutomaticBindingDone', $nbbinddone, $notpossible),
null, ($notpossible ?
'warnings' :
'mesgs'));
291 setEventMessages($langs->trans(
'DoManualBindingForFailedRecord', $nbbindfailed),
null,
'warnings');
301llxHeader(
'', $langs->trans(
"SuppliersVentilation"));
303$textprevyear =
'<a href="'.$_SERVER[
"PHP_SELF"].
'?year='.($year_current - 1).
'">'.
img_previous().
'</a>';
304$textnextyear =
' <a href="'.$_SERVER[
"PHP_SELF"].
'?year='.($year_current + 1).
'">'.
img_next().
'</a>';
306print
load_fiche_titre($langs->trans(
"SuppliersVentilation").
" ".$textprevyear.
" ".$langs->trans(
"Year").
" ".$year_start.
" ".$textnextyear,
'',
'title_accountancy');
308print
'<span class="opacitymedium">'.$langs->trans(
"DescVentilSupplier").
'</span><br>';
309print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"DescVentilMore", $langs->transnoentitiesnoconv(
"ValidateHistory"), $langs->transnoentitiesnoconv(
"ToBind")).
'<br>';
314$buttonbind =
'<a class="butAction smallpaddingimp" href="'.$_SERVER[
'PHP_SELF'].
'?action=validatehistory&token='.newToken().
'">'.
img_picto(
'',
'link',
'class="paddingright fa-color-unset smallpaddingimp"').$langs->trans(
"ValidateHistory").
'</a>';
317print_barre_liste(
img_picto(
'',
'unlink',
'class="paddingright fa-color-unset"').$langs->trans(
"OverviewOfAmountOfLinesNotBound"),
'',
'',
'',
'',
'',
'', -1,
'',
'', 0,
'',
'', 0, 1, 1, 0, $buttonbind);
320print
'<div class="div-table-responsive-no-min">';
321print
'<table class="noborder centpercent">';
322print
'<tr class="liste_titre"><td class="minwidth100">'.$langs->trans(
"Account").
'</td>';
323print
'<td>'.$langs->trans(
"Label").
'</td>';
324for ($i = 1; $i <= 12; $i++) {
325 $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
330 if ($cursormonth > 12) {
333 $cursoryear = ($cursormonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y;
336 print
'<td width="60" class="right">';
337 if (!empty($tmp[
'mday'])) {
338 $param =
'search_date_startday=1&search_date_startmonth='.$cursormonth.
'&search_date_startyear='.$cursoryear;
339 $param .=
'&search_date_endday='.$tmp[
'mday'].
'&search_date_endmonth='.$tmp[
'mon'].
'&search_date_endyear='.$tmp[
'year'];
340 print
'<a href="'.DOL_URL_ROOT.
'/accountancy/supplier/list.php?'.$param.
'">';
342 print $langs->trans(
'MonthShort'.str_pad($j, 2,
'0', STR_PAD_LEFT));
343 if (!empty($tmp[
'mday'])) {
348print
'<td width="60" class="right"><b>'.$langs->trans(
"Total").
'</b></td></tr>';
350$sql =
"SELECT ".$db->ifsql(
'aa.account_number IS NULL',
"'tobind'",
'aa.account_number').
" AS codecomptable,";
351$sql .=
" ".$db->ifsql(
'aa.label IS NULL',
"'tobind'",
'aa.label').
" AS intitule,";
352for ($i = 1; $i <= 12; $i++) {
353 $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
357 $sql .=
" SUM(".$db->ifsql(
"MONTH(ff.datef)=".$j,
"ffd.total_ht",
"0").
") AS month".str_pad($j, 2,
"0", STR_PAD_LEFT).
",";
359$sql .=
" SUM(ffd.total_ht) as total";
360$sql .=
" FROM ".$db->prefix().
"facture_fourn_det as ffd";
361$sql .=
" LEFT JOIN ".$db->prefix().
"facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
362$sql .=
" LEFT JOIN ".$db->prefix().
"accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
363$sql .=
" WHERE ff.datef >= '".$db->idate($search_date_start).
"'";
364$sql .=
" AND ff.datef <= '".$db->idate($search_date_end).
"'";
366if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
367 $sql .=
" AND ff.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING).
"'";
369$sql .=
" AND ff.fk_statut > 0";
370$sql .=
" AND ffd.product_type <= 2";
371$sql .=
" AND ff.entity IN (".getEntity(
'facture_fourn', 0).
")";
372$sql .=
" AND aa.account_number IS NULL";
373if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
378$sql .=
" GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
380dol_syslog(
'htdocs/accountancy/supplier/index.php', LOG_DEBUG);
381$resql = $db->query($sql);
383 $num = $db->num_rows($resql);
385 while ($row = $db->fetch_row($resql)) {
386 print
'<tr class="oddeven">';
388 if ($row[0] ==
'tobind') {
389 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
395 if ($row[0] ==
'tobind') {
396 $startmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1);
397 if ($startmonth > 12) {
400 $startyear = ($startmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y;
401 $endmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) + 11;
402 if ($endmonth > 12) {
405 $endyear = ($endmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y;
406 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"));
411 for ($i = 2; $i <= 13; $i++) {
412 $cursormonth = (($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) + $i - 2);
413 if ($cursormonth > 12) {
416 $cursoryear = ($cursormonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y;
419 print
'<td class="right nowraponall amount">';
420 print
price($row[$i]);
423 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=validatehistory&year='.$y.
'&validatemonth='.((int) $cursormonth).
'&validateyear='.((int) $cursoryear).
'&token='.newToken().
'">';
424 print
img_picto($langs->trans(
"ValidateHistory").
' ('.$langs->trans(
'Month'.str_pad($cursormonth, 2,
'0', STR_PAD_LEFT)).
' '.$cursoryear.
')',
'link',
'class="marginleft2"');
429 print
'<td class="right nowraponall amount"><b>'.price($row[14]).
'</b></td>';
435 print
'<tr class="oddeven"><td colspan="16">';
436 print
'<span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span>';
440 print $db->lasterror();
449print_barre_liste(
img_picto(
'',
'link',
'class="paddingright fa-color-unset"').$langs->trans(
"OverviewOfAmountOfLinesBound"),
'',
'',
'',
'',
'',
'', -1,
'',
'', 0,
'',
'', 0, 1, 1);
452print
'<div class="div-table-responsive-no-min">';
453print
'<table class="noborder centpercent">';
454print
'<tr class="liste_titre"><td class="minwidth100">'.$langs->trans(
"Account").
'</td>';
455print
'<td>'.$langs->trans(
"Label").
'</td>';
456for ($i = 1; $i <= 12; $i++) {
457 $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
462 if ($cursormonth > 12) {
465 $cursoryear = ($cursormonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y;
468 print
'<td width="60" class="right">';
469 if (!empty($tmp[
'mday'])) {
470 $param =
'search_date_startday=1&search_date_startmonth='.$cursormonth.
'&search_date_startyear='.$cursoryear;
471 $param .=
'&search_date_endday='.$tmp[
'mday'].
'&search_date_endmonth='.$tmp[
'mon'].
'&search_date_endyear='.$tmp[
'year'];
472 print
'<a href="'.DOL_URL_ROOT.
'/accountancy/supplier/lines.php?'.$param.
'">';
474 print $langs->trans(
'MonthShort'.str_pad($j, 2,
'0', STR_PAD_LEFT));
475 if (!empty($tmp[
'mday'])) {
480print
'<td width="60" class="right"><b>'.$langs->trans(
"Total").
'</b></td></tr>';
482$sql =
"SELECT ".$db->ifsql(
'aa.account_number IS NULL',
"'tobind'",
'aa.account_number').
" AS codecomptable,";
483$sql .=
" ".$db->ifsql(
'aa.label IS NULL',
"'tobind'",
'aa.label').
" AS intitule,";
484for ($i = 1; $i <= 12; $i++) {
485 $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
489 $sql .=
" SUM(".$db->ifsql(
"MONTH(ff.datef)=".$j,
"ffd.total_ht",
"0").
") AS month".str_pad($j, 2,
"0", STR_PAD_LEFT).
",";
491$sql .=
" SUM(ffd.total_ht) as total";
492$sql .=
" FROM ".$db->prefix().
"facture_fourn_det as ffd";
493$sql .=
" LEFT JOIN ".$db->prefix().
"facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
494$sql .=
" LEFT JOIN ".$db->prefix().
"accounting_account as aa ON aa.rowid = ffd.fk_code_ventilation";
495$sql .=
" WHERE ff.datef >= '".$db->idate($search_date_start).
"'";
496$sql .=
" AND ff.datef <= '".$db->idate($search_date_end).
"'";
498if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
499 $sql .=
" AND ff.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING).
"'";
501$sql .=
" AND ff.entity IN (".getEntity(
'facture_fourn', 0).
")";
502$sql .=
" AND ff.fk_statut > 0";
503$sql .=
" AND ffd.product_type <= 2";
504if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
509$sql .=
" AND aa.account_number IS NOT NULL";
510$sql .=
" GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
511$sql .=
' ORDER BY aa.account_number';
513dol_syslog(
'htdocs/accountancy/supplier/index.php');
514$resql = $db->query($sql);
516 $num = $db->num_rows($resql);
518 while ($row = $db->fetch_row($resql)) {
519 print
'<tr class="oddeven">';
521 if ($row[0] ==
'tobind') {
522 print $langs->trans(
"Unknown");
528 print
'<td class="tdoverflowmax300"'.(empty($row[1]) ?
'' :
' title="'.dol_escape_htmltag($row[1]).
'"').
'>';
529 if ($row[0] ==
'tobind') {
530 print $langs->trans(
"UseMenuToSetBindindManualy", DOL_URL_ROOT.
'/accountancy/supplier/list.php?search_year='.((
int) $y), $langs->transnoentitiesnoconv(
"ToBind"));
536 for ($i = 2; $i <= 13; $i++) {
537 print
'<td class="right nowraponall amount">';
538 print
price($row[$i]);
541 print
'<td class="right nowraponall amount"><b>'.price($row[14]).
'</b></td>';
547 print
'<tr class="oddeven"><td colspan="16">';
548 print
'<span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span>';
552 print $db->lasterror();
562 print_barre_liste($langs->trans(
"OtherInfo"),
'',
'',
'',
'',
'',
'', -1,
'',
'', 0,
'',
'', 0, 1, 1);
565 print
'<div class="div-table-responsive-no-min">';
566 print
'<table class="noborder centpercent">';
567 print
'<tr class="liste_titre"><td>'.$langs->trans(
"Total").
'</td>';
568 for ($i = 1; $i <= 12; $i++) {
569 $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
573 print
'<td width="60" class="right">'.$langs->trans(
'MonthShort'.str_pad($j, 2,
'0', STR_PAD_LEFT)).
'</td>';
575 print
'<td width="60" class="right"><b>'.$langs->trans(
"Total").
'</b></td></tr>';
577 $sql =
"SELECT '".$db->escape($langs->trans(
"CAHTF")).
"' AS label,";
578 for ($i = 1; $i <= 12; $i++) {
579 $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
583 $sql .=
" SUM(".$db->ifsql(
"MONTH(ff.datef)=".$j,
"ffd.total_ht",
"0").
") AS month".str_pad($j, 2,
"0", STR_PAD_LEFT).
",";
585 $sql .=
" SUM(ffd.total_ht) as total";
586 $sql .=
" FROM ".$db->prefix().
"facture_fourn_det as ffd";
587 $sql .=
" LEFT JOIN ".$db->prefix().
"facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
588 $sql .=
" WHERE ff.datef >= '".$db->idate($search_date_start).
"'";
589 $sql .=
" AND ff.datef <= '".$db->idate($search_date_end).
"'";
591 if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
592 $sql .=
" AND ff.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING).
"'";
594 $sql .=
" AND ff.entity IN (".getEntity(
'facture_fourn', 0).
")";
595 $sql .=
" AND ff.fk_statut > 0";
596 $sql .=
" AND ffd.product_type <= 2";
597 if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
603 dol_syslog(
'htdocs/accountancy/supplier/index.php');
604 $resql = $db->query($sql);
606 $num = $db->num_rows($resql);
608 while ($row = $db->fetch_row($resql)) {
609 print
'<tr><td>'.$row[0].
'</td>';
610 for ($i = 1; $i <= 12; $i++) {
611 print
'<td class="right nowraponall amount">'.price($row[$i]).
'</td>';
613 print
'<td class="right nowraponall amount"><b>'.price($row[13]).
'</b></td>';
618 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()
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 informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
setEventMessage($mesgs, $style='mesgs', $noduplicate=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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
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.
img_next($titlealt='default', $moreatt='')
Show next logo.
getDolGlobalString($key, $default='')
Return 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.