Work on accounting reports.

This commit is contained in:
Laurent Destailleur 2017-08-31 18:29:57 +02:00
parent 8248bc1c64
commit 31a74d448c
20 changed files with 2481 additions and 2090 deletions

View File

@ -69,8 +69,8 @@ $arrayfields=array(
'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1),
'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), 'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>0), 'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>0),
'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>0), 'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>0, 'help'=>'PcgtypeDesc'),
'aa.pcg_subtype'=>array('label'=>$langs->trans("Pcgsubtype"), 'checked'=>0), 'aa.pcg_subtype'=>array('label'=>$langs->trans("Pcgsubtype"), 'checked'=>0, 'help'=>'PcgtypeDesc'),
'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1) 'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1)
); );
@ -264,8 +264,8 @@ if ($resql)
if (! empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"],"aa.account_number","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"],"aa.account_number","",$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"],"aa.label","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"],"aa.label","",$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"],"aa.account_parent", "", $param,'align="left"',$sortfield,$sortorder); if (! empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"],"aa.account_parent", "", $param,'align="left"',$sortfield,$sortorder);
if (! empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'],$_SERVER["PHP_SELF"],'aa.pcg_type','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'],$_SERVER["PHP_SELF"],'aa.pcg_type','',$param,'',$sortfield,$sortorder,'',$arrayfields['aa.pcg_type']['help']);
if (! empty($arrayfields['aa.pcg_subtype']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_subtype']['label'],$_SERVER["PHP_SELF"],'aa.pcg_subtype','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['aa.pcg_subtype']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_subtype']['label'],$_SERVER["PHP_SELF"],'aa.pcg_subtype','',$param,'',$sortfield,$sortorder,'',$arrayfields['aa.pcg_subtype']['help']);
if (! empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'],$_SERVER["PHP_SELF"],'aa.active','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'],$_SERVER["PHP_SELF"],'aa.active','',$param,'',$sortfield,$sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
print "</tr>\n"; print "</tr>\n";

View File

@ -458,6 +458,10 @@ $titlepicto='title_setup';
print load_fiche_titre($titre,$linkback,$titlepicto); print load_fiche_titre($titre,$linkback,$titlepicto);
if ($id == 32)
{
print $langs->trans("AccountingAccountGroupsDesc", $langs->transnoentitiesnoconv("ByPersonalizedAccountGroups")).'<br><br>';
}
// Confirmation de la suppression de la ligne // Confirmation de la suppression de la ligne
if ($action == 'delete') if ($action == 'delete')

View File

@ -336,17 +336,18 @@ class AccountancyCategory
* *
* @param int $cpt Id accounting account * @param int $cpt Id accounting account
* @param string $month Specifig month - Can be empty * @param string $month Specifig month - Can be empty
* @param string $year Specific year * @param string $date_start Date start
* @param string $date_end Date end
* @param int $sens Sens of the account 0: credit - debit 1: debit - credit * @param int $sens Sens of the account 0: credit - debit 1: debit - credit
*
* @return integer Result in table * @return integer Result in table
*/ */
public function getResult($cpt, $month, $year, $sens) { public function getResult($cpt, $month, $date_start, $date_end, $sens)
{
$sql = "SELECT SUM(t.debit) as debit, SUM(t.credit) as credit"; $sql = "SELECT SUM(t.debit) as debit, SUM(t.credit) as credit";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t";
$sql .= " WHERE t.numero_compte = '" . $cpt."'"; $sql .= " WHERE t.numero_compte = '" . $cpt."'";
$sql .= " AND YEAR(t.doc_date) = " . $year; if (! empty($date_start) && ! empty($date_end))
$sql.= " AND t.doc_date >= '".$this->db->idate($date_start)."' AND t.doc_date <= '".$this->db->idate($date_end)."'";
if (! empty($month)) { if (! empty($month)) {
$sql .= " AND MONTH(t.doc_date) = " . $month; $sql .= " AND MONTH(t.doc_date) = " . $month;
} }

View File

@ -138,6 +138,9 @@ print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step,
print "<br>\n"; print "<br>\n";
print '<br>';
print "<br>\n"; print "<br>\n";
print_fiche_titre($langs->trans("AccountancyAreaDescActionFreq"), '', 'object_calendarweek'); print_fiche_titre($langs->trans("AccountancyAreaDescActionFreq"), '', 'object_calendarweek');
print '<hr>'; print '<hr>';

View File

@ -24,6 +24,7 @@
/** /**
* \file htdocs/compta/resultat/clientfourn.php * \file htdocs/compta/resultat/clientfourn.php
* \ingroup compta, accountancy
* \brief Page reporting * \brief Page reporting
*/ */
@ -34,10 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$langs->loadLangs(array('compta','bills','donation','salaries'));
$langs->load("bills");
$langs->load("donation");
$langs->load("salaries");
$date_startmonth=GETPOST('date_startmonth'); $date_startmonth=GETPOST('date_startmonth');
$date_startday=GETPOST('date_startday'); $date_startday=GETPOST('date_startday');
@ -60,7 +58,7 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (! $sortfield) $sortfield='s.nom, s.rowid'; //if (! $sortfield) $sortfield='s.nom, s.rowid';
if (! $sortorder) $sortorder='ASC'; if (! $sortorder) $sortorder='ASC';
// Date range // Date range
@ -107,8 +105,18 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); }
} }
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES') // $date_start and $date_end are defined. We force $start_year and $nbofyear
$modecompta=(GETPOST("modecompta")?GETPOST("modecompta"):$conf->global->ACCOUNTING_MODE); $tmps=dol_getdate($date_start);
$start_year = $tmps['year'];
$tmpe=dol_getdate($date_end);
$year_end = $tmpe['year'];
$nbofyear = ($year_end - $start_year) + 1;
//var_dump($start_year." ".$end_year." ".$nbofyear);
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING')
$modecompta = $conf->global->ACCOUNTING_MODE;
if (! empty($conf->accounting->enabled)) $modecompta='BOOKKEEPING';
if (GETPOST("modecompta",'alpha')) $modecompta=GETPOST("modecompta",'alpha');
/* /*
@ -129,25 +137,41 @@ $total_ttc=0;
// Affiche en-tete de rapport // Affiche en-tete de rapport
if ($modecompta=="CREANCES-DETTES") if ($modecompta=="CREANCES-DETTES")
{ {
$name=$langs->trans("AnnualByCompaniesDueDebtMode"); $name=$langs->trans("AnnualByCompanies");
$calcmode=$langs->trans("CalcModeDebt"); $calcmode=$langs->trans("CalcModeDebt");
$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.(GETPOST("month")>0?'&month='.GETPOST("month"):'').'&modecompta=RECETTES-DEPENSES">','</a>').')'; $calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.(GETPOST("month")>0?'&month='.GETPOST("month"):'').'&modecompta=RECETTES-DEPENSES">','</a>').')';
$calcmode.='<br>('.$langs->trans("SeeReportInBookkeepingMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=BOOKKEEPING">','</a>').')';
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
//$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>'; $periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear-2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
$description=$langs->trans("RulesResultDue"); $description=$langs->trans("RulesResultDue");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
else $description.= $langs->trans("DepositsAreIncluded"); else $description.= $langs->trans("DepositsAreIncluded");
$builddate=time(); $builddate=time();
//$exportlink=$langs->trans("NotYetAvailable"); //$exportlink=$langs->trans("NotYetAvailable");
} }
else { elseif ($modecompta=="RECETTES-DEPENSES")
$name=$langs->trans("AnnualByCompaniesInputOutputMode"); {
$name=$langs->trans("AnnualByCompanies");
$calcmode=$langs->trans("CalcModeEngagement"); $calcmode=$langs->trans("CalcModeEngagement");
$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.(GETPOST("month")>0?'&month='.GETPOST("month"):'').'&modecompta=CREANCES-DETTES">','</a>').')';
$calcmode.='<br>('.$langs->trans("SeeReportInBookkeepingMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=BOOKKEEPING">','</a>').')';
//$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',1,1,0,'',1,0,1);
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear-2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
$description=$langs->trans("RulesResultInOut");
$builddate=time();
//$exportlink=$langs->trans("NotYetAvailable");
}
elseif ($modecompta=="BOOKKEEPING")
{
$name=$langs->trans("AnnualByCompanies");
$calcmode=$langs->trans("CalcModeBookkeeping");
$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.(GETPOST("month")>0?'&month='.GETPOST("month"):'').'&modecompta=RECETTES-DEPENSES">','</a>').')';
$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.(GETPOST("month")>0?'&month='.GETPOST("month"):'').'&modecompta=CREANCES-DETTES">','</a>').')'; $calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.(GETPOST("month")>0?'&month='.GETPOST("month"):'').'&modecompta=CREANCES-DETTES">','</a>').')';
//$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',1,1,0,'',1,0,1); //$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',1,1,0,'',1,0,1);
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
//$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>'; $periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear-2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
$description=$langs->trans("RulesResultInOut"); $description=$langs->trans("RulesResultBookkeepingPredefined", $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->transnoentitiesnoconv("Chartofaccounts"));
$builddate=time(); $builddate=time();
//$exportlink=$langs->trans("NotYetAvailable"); //$exportlink=$langs->trans("NotYetAvailable");
} }
@ -173,21 +197,82 @@ if ($date_endyear) $param.='&date_endyear='.$date_startyear;
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre(''); print_liste_field_titre('');
print_liste_field_titre("Name", $_SERVER["PHP_SELF"],'s.nom, s.rowid','',$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Groups"), $_SERVER["PHP_SELF"],'s.nom, s.rowid','',$param,'',$sortfield,$sortorder);
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'BOOKKEEPING')
{ {
print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"],'amount_ht','',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre("Amount", $_SERVER["PHP_SELF"],'amount','',$param,'align="right"',$sortfield,$sortorder);
}
else
{
if ($modecompta == 'CREANCES-DETTES')
{
print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"],'amount_ht','',$param,'align="right"',$sortfield,$sortorder);
}
print_liste_field_titre("AmountTTC", $_SERVER["PHP_SELF"],'amount_ttc','',$param,'align="right"',$sortfield,$sortorder);
} }
print_liste_field_titre("AmountTTC", $_SERVER["PHP_SELF"],'amount_ttc','',$param,'align="right"',$sortfield,$sortorder);
print "</tr>\n"; print "</tr>\n";
/*
if ($modecompta == 'BOOKKEEPING')
{
$sql = "SELECT f.thirdparty_code as name, -1 as socid, aa.pcg_type, aa.pcg_subtype, sum(f.credit - f.debit) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as f";
$sql.= ", ".MAIN_DB_PREFIX."accounting_account as aa";
$sql.= " WHERE f.numero_compte = aa.account_number";
$sql.= " AND pcg_type in ('EXPENSE','INCOME')";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.doc_date >= '".$db->idate($date_start)."' AND f.doc_date <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY name, socid, pcg_type, pcg_subtype";
$sql.= $db->order($sortfield, $sortorder);
$oldpcgtype = '';
dol_syslog("get bookkeeping entries", LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
$i = 0;
if ($num > 0)
{
while ($i < $num)
{
$objp = $db->fetch_object($result);
if ($objp->pcg_type != $oldpcgtype)
{
print '<tr><td colspan="4">'.$objp->pcg_type.'</td></tr>';
$oldpcgtype = $objp->pcg_type;
}
print '<tr class="oddeven">';
print '<td>&nbsp;</td>';
print '<td>'.$objp->pcg_type.($objp->pcg_subtype != 'XXXXXX'?' - '.$objp->pcg_subtype:'').($objp->name?' ('.$objp->name.')':'')."</td>\n";
print '<td align="right">'.price($objp->amount)."</td>\n";
print "</tr>\n";
$total_ht += (isset($objp->amount)?$objp->amount:0);
$total_ttc += (isset($objp->amount)?$objp->amount:0);
$i++;
}
}
else
{
print '<tr><td colspan="4" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}
}
else dol_print_error($db);
}
else
{
/*
* Factures clients * Factures clients
*/ */
print '<tr><td colspan="4">'.$langs->trans("CustomersInvoices").'</td></tr>'; print '<tr><td colspan="4">'.$langs->trans("CustomersInvoices").'</td></tr>';
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
{ {
$sql = "SELECT s.nom as name, s.rowid as socid, sum(f.total) as amount_ht, sum(f.total_ttc) as amount_ttc"; $sql = "SELECT s.nom as name, s.rowid as socid, sum(f.total) as amount_ht, sum(f.total_ttc) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."facture as f";
@ -199,9 +284,9 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.= " AND f.type IN (0,1,2,3,5)"; $sql.= " AND f.type IN (0,1,2,3,5)";
if (! empty($date_start) && ! empty($date_end)) if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
} }
else elseif ($modecompta == 'RECETTES-DEPENSES')
{ {
/* /*
* Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les
* vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin) * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin)
@ -216,15 +301,15 @@ else
$sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND f.fk_soc = s.rowid";
if (! empty($date_start) && ! empty($date_end)) if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
} }
$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.entity = ".$conf->entity;
if ($socid) $sql.= " AND f.fk_soc = ".$socid; if ($socid) $sql.= " AND f.fk_soc = ".$socid;
$sql.= " GROUP BY s.nom, s.rowid"; $sql.= " GROUP BY name, socid";
$sql.= $db->order($sortfield, $sortorder); $sql.= $db->order($sortfield, $sortorder);
dol_syslog("get customer invoices", LOG_DEBUG); dol_syslog("get customer invoices", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
@ -244,13 +329,13 @@ if ($result) {
$i++; $i++;
} }
$db->free($result); $db->free($result);
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
// On ajoute les paiements clients anciennes version, non lie par paiement_facture // On ajoute les paiements clients anciennes version, non lie par paiement_facture
if ($modecompta != 'CREANCES-DETTES') if ($modecompta == 'RECETTES-DEPENSES')
{ {
$sql = "SELECT 'Autres' as name, '0' as idp, sum(p.amount) as amount_ttc"; $sql = "SELECT 'Autres' as name, '0' as idp, sum(p.amount) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
@ -294,27 +379,27 @@ if ($modecompta != 'CREANCES-DETTES')
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
if ($total_ttc == 0) if ($total_ttc == 0)
{ {
print '<tr class="oddeven"><td>&nbsp;</td>'; print '<tr class="oddeven"><td>&nbsp;</td>';
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>'; print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>';
print '</tr>'; print '</tr>';
} }
print '<tr class="liste_total">'; print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" align="right">'.price($total_ht).'</td>'; print '<td colspan="3" align="right">'.price($total_ht).'</td>';
print '<td colspan="3" align="right">'.price($total_ttc).'</td>'; print '<td colspan="3" align="right">'.price($total_ttc).'</td>';
print '</tr>'; print '</tr>';
/* /*
* Suppliers invoices * Suppliers invoices
*/ */
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
{ {
$sql = "SELECT s.nom as name, s.rowid as socid, sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc"; $sql = "SELECT s.nom as name, s.rowid as socid, sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f"; $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f";
@ -326,9 +411,9 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.= " AND f.type IN (0,1,2,3)"; $sql.= " AND f.type IN (0,1,2,3)";
if (! empty($date_start) && ! empty($date_end)) if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
} }
else elseif ($modecompta == 'RECETTES-DEPENSES')
{ {
$sql = "SELECT s.nom as name, s.rowid as socid, sum(pf.amount) as amount_ttc"; $sql = "SELECT s.nom as name, s.rowid as socid, sum(pf.amount) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p"; $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
$sql.= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf"; $sql.= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
@ -339,19 +424,20 @@ else
$sql.= " WHERE p.rowid = pf.fk_paiementfourn "; $sql.= " WHERE p.rowid = pf.fk_paiementfourn ";
if (! empty($date_start) && ! empty($date_end)) if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
} }
$sql.= " AND f.entity = ".$conf->entity;
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
$sql .= " GROUP BY s.nom, s.rowid";
$sql.= $db->order($sortfield, $sortorder);
print '<tr><td colspan="4">'.$langs->trans("SuppliersInvoices").'</td></tr>'; $sql.= " AND f.entity = ".$conf->entity;
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
$sql .= " GROUP BY name, socid";
$sql.= $db->order($sortfield, $sortorder);
$subtotal_ht = 0; print '<tr><td colspan="4">'.$langs->trans("SuppliersInvoices").'</td></tr>';
$subtotal_ttc = 0;
dol_syslog("get suppliers invoices", LOG_DEBUG); $subtotal_ht = 0;
$result = $db->query($sql); $subtotal_ttc = 0;
if ($result) { dol_syslog("get suppliers invoices", LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
if ($num > 0) if ($num > 0)
@ -384,25 +470,25 @@ if ($result) {
} }
$db->free($result); $db->free($result);
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
print '<tr class="liste_total">'; print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" align="right">'.price(-$subtotal_ht).'</td>'; print '<td colspan="3" align="right">'.price(-$subtotal_ht).'</td>';
print '<td colspan="3" align="right">'.price(-$subtotal_ttc).'</td>'; print '<td colspan="3" align="right">'.price(-$subtotal_ttc).'</td>';
print '</tr>'; print '</tr>';
/* /*
* Charges sociales non deductibles * Charges sociales non deductibles
*/ */
print '<tr><td colspan="4">'.$langs->trans("SocialContributionsNondeductibles").'</td></tr>'; print '<tr><td colspan="4">'.$langs->trans("SocialContributionsNondeductibles").'</td></tr>';
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
{ {
$sql = "SELECT c.id, c.libelle as label, sum(cs.amount) as amount"; $sql = "SELECT c.id, c.libelle as label, sum(cs.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
@ -410,9 +496,9 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.= " AND c.deductible = 0"; $sql.= " AND c.deductible = 0";
if (! empty($date_start) && ! empty($date_end)) if (! empty($date_start) && ! empty($date_end))
$sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'"; $sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
} }
else elseif ($modecompta == 'RECETTES-DEPENSES')
{ {
$sql = "SELECT c.id, c.libelle as label, sum(p.amount) as amount"; $sql = "SELECT c.id, c.libelle as label, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
@ -422,20 +508,21 @@ else
$sql.= " AND c.deductible = 0"; $sql.= " AND c.deductible = 0";
if (! empty($date_start) && ! empty($date_end)) if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
} }
$sql.= " AND cs.entity = ".$conf->entity; $sql.= " AND cs.entity = ".$conf->entity;
$sql.= " GROUP BY c.libelle, c.id"; $sql.= " GROUP BY c.libelle, c.id";
$newsortfield = $sortfield; $newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'c.libelle, c.id'; if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'c.libelle, c.id';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount'; if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount'; if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql.= $db->order($newsortfield, $sortorder);
dol_syslog("get social contributions deductible=0", LOG_DEBUG); $sql.= $db->order($newsortfield, $sortorder);
$result=$db->query($sql);
$subtotal_ht = 0; dol_syslog("get social contributions deductible=0", LOG_DEBUG);
$subtotal_ttc = 0; $result=$db->query($sql);
if ($result) { $subtotal_ht = 0;
$subtotal_ttc = 0;
if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
if ($num) { if ($num) {
@ -460,24 +547,24 @@ if ($result) {
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>'; print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>';
print '</tr>'; print '</tr>';
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
print '<tr class="liste_total">'; print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" align="right">'.price(-$subtotal_ht).'</td>'; print '<td colspan="3" align="right">'.price(-$subtotal_ht).'</td>';
print '<td colspan="3" align="right">'.price(-$subtotal_ttc).'</td>'; print '<td colspan="3" align="right">'.price(-$subtotal_ttc).'</td>';
print '</tr>'; print '</tr>';
/* /*
* Charges sociales deductibles * Charges sociales deductibles
*/ */
print '<tr><td colspan="4">'.$langs->trans("SocialContributionsDeductibles").'</td></tr>'; print '<tr><td colspan="4">'.$langs->trans("SocialContributionsDeductibles").'</td></tr>';
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
{ {
$sql = "SELECT c.id, c.libelle as label, sum(cs.amount) as amount"; $sql = "SELECT c.id, c.libelle as label, sum(cs.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
@ -486,9 +573,9 @@ if ($modecompta == 'CREANCES-DETTES')
if (! empty($date_start) && ! empty($date_end)) if (! empty($date_start) && ! empty($date_end))
$sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'"; $sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
$sql.= " AND cs.entity = ".$conf->entity; $sql.= " AND cs.entity = ".$conf->entity;
} }
else elseif ($modecompta == 'RECETTES-DEPENSES')
{ {
$sql = "SELECT c.id, c.libelle as label, sum(p.amount) as amount"; $sql = "SELECT c.id, c.libelle as label, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
@ -499,19 +586,19 @@ else
if (! empty($date_start) && ! empty($date_end)) if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql.= " AND cs.entity = ".$conf->entity; $sql.= " AND cs.entity = ".$conf->entity;
} }
$sql.= " GROUP BY c.libelle, c.id"; $sql.= " GROUP BY c.libelle, c.id";
$newsortfield = $sortfield; $newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'c.libelle, c.id'; if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'c.libelle, c.id';
if ($newsortfield == 'amount_ht') $newsortfield = 'amount'; if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount'; if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql.= $db->order($newsortfield, $sortorder); $sql.= $db->order($newsortfield, $sortorder);
dol_syslog("get social contributions deductible=1", LOG_DEBUG); dol_syslog("get social contributions deductible=1", LOG_DEBUG);
$result=$db->query($sql); $result=$db->query($sql);
$subtotal_ht = 0; $subtotal_ht = 0;
$subtotal_ttc = 0; $subtotal_ttc = 0;
if ($result) { if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
if ($num) { if ($num) {
@ -537,17 +624,17 @@ if ($result) {
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>'; print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>';
print '</tr>'; print '</tr>';
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
print '<tr class="liste_total">'; print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" align="right">'.price(-$subtotal_ht).'</td>'; print '<td colspan="3" align="right">'.price(-$subtotal_ht).'</td>';
print '<td colspan="3" align="right">'.price(-$subtotal_ttc).'</td>'; print '<td colspan="3" align="right">'.price(-$subtotal_ttc).'</td>';
print '</tr>'; print '</tr>';
if ($mysoc->tva_assuj == 'franchise') // Non assujetti if ($mysoc->tva_assuj == 'franchise') // Non assujetti
{ {
// Total // Total
print '<tr>'; print '<tr>';
print '<td colspan="4">&nbsp;</td>'; print '<td colspan="4">&nbsp;</td>';
@ -562,22 +649,25 @@ if ($mysoc->tva_assuj == 'franchise') // Non assujetti
print '<tr>'; print '<tr>';
print '<td colspan="4">&nbsp;</td>'; print '<td colspan="4">&nbsp;</td>';
print '</tr>'; print '</tr>';
} }
/* /*
* Salaries * Salaries
*/ */
if (! empty($conf->salaries->enabled)) if (! empty($conf->salaries->enabled))
{ {
print '<tr><td colspan="4">'.$langs->trans("Salaries").'</td></tr>';
if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES')
{
if ($modecompta == 'CREANCES-DETTES') { if ($modecompta == 'CREANCES-DETTES') {
$column = 'p.datev'; $column = 'p.datev';
} else { } else {
$column = 'p.datep'; $column = 'p.datep';
} }
print '<tr><td colspan="4">'.$langs->trans("Salaries").'</td></tr>';
$sql = "SELECT u.rowid, u.firstname, u.lastname, p.fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; $sql = "SELECT u.rowid, u.firstname, u.lastname, p.fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user";
@ -591,6 +681,7 @@ if (! empty($conf->salaries->enabled))
if ($newsortfield == 'amount_ht') $newsortfield = 'amount'; if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount'; if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
$sql.= $db->order($newsortfield, $sortorder); $sql.= $db->order($newsortfield, $sortorder);
}
dol_syslog("get payment salaries"); dol_syslog("get payment salaries");
$result=$db->query($sql); $result=$db->query($sql);
@ -637,14 +728,17 @@ if (! empty($conf->salaries->enabled))
print '<td colspan="3" align="right">'.price(-$subtotal_ht).'</td>'; print '<td colspan="3" align="right">'.price(-$subtotal_ht).'</td>';
print '<td colspan="3" align="right">'.price(-$subtotal_ttc).'</td>'; print '<td colspan="3" align="right">'.price(-$subtotal_ttc).'</td>';
print '</tr>'; print '</tr>';
} }
/*
/*
* Expense * Expense
*/ */
if (! empty($conf->expensereport->enabled)) if (! empty($conf->expensereport->enabled))
{ {
if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES')
{
$langs->load('trips'); $langs->load('trips');
if ($modecompta == 'CREANCES-DETTES') { if ($modecompta == 'CREANCES-DETTES') {
$sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc"; $sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc";
@ -666,8 +760,6 @@ if (! empty($conf->expensereport->enabled))
$column='pe.datep'; $column='pe.datep';
} }
print '<tr><td colspan="4">'.$langs->trans("ExpenseReport").'</td></tr>';
if (! empty($date_start) && ! empty($date_end)) if (! empty($date_start) && ! empty($date_end))
{ {
$sql.= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; $sql.= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'";
@ -677,6 +769,9 @@ if (! empty($conf->expensereport->enabled))
$newsortfield = $sortfield; $newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'p.ref'; if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'p.ref';
$sql.= $db->order($newsortfield, $sortorder); $sql.= $db->order($newsortfield, $sortorder);
}
print '<tr><td colspan="4">'.$langs->trans("ExpenseReport").'</td></tr>';
dol_syslog("get expense report outcome"); dol_syslog("get expense report outcome");
$result=$db->query($sql); $result=$db->query($sql);
@ -715,19 +810,21 @@ if (! empty($conf->expensereport->enabled))
dol_print_error($db); dol_print_error($db);
} }
print '<tr class="liste_total">'; print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES') print '<td colspan="3" align="right">'.price(-$subtotal_ht).'</td>';
print '<td colspan="3" align="right">'.price(-$subtotal_ht).'</td>';
print '<td colspan="3" align="right">'.price(-$subtotal_ttc).'</td>'; print '<td colspan="3" align="right">'.price(-$subtotal_ttc).'</td>';
print '</tr>'; print '</tr>';
} }
/* /*
* Donations * Donations
*/ */
if (! empty($conf->don->enabled)) if (! empty($conf->don->enabled))
{ {
print '<tr><td colspan="4">'.$langs->trans("Donations").'</td></tr>'; print '<tr><td colspan="4">'.$langs->trans("Donations").'</td></tr>';
if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES')
{
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
{ {
$sql = "SELECT p.societe as name, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount"; $sql = "SELECT p.societe as name, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
@ -746,6 +843,7 @@ if (! empty($conf->don->enabled))
} }
if (! empty($date_start) && ! empty($date_end)) if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'"; $sql.= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'";
}
$sql.= " GROUP BY p.societe, p.firstname, p.lastname, dm"; $sql.= " GROUP BY p.societe, p.firstname, p.lastname, dm";
$newsortfield = $sortfield; $newsortfield = $sortfield;
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'p.societe, p.firstname, p.lastname, dm'; if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'p.societe, p.firstname, p.lastname, dm';
@ -798,18 +896,21 @@ if (! empty($conf->don->enabled))
print '<td colspan="3" align="right">'.price($subtotal_ht).'</td>'; print '<td colspan="3" align="right">'.price($subtotal_ht).'</td>';
print '<td colspan="3" align="right">'.price($subtotal_ttc).'</td>'; print '<td colspan="3" align="right">'.price($subtotal_ttc).'</td>';
print '</tr>'; print '</tr>';
} }
/*
/*
* VAT * VAT
*/ */
print '<tr><td colspan="4">'.$langs->trans("VAT").'</td></tr>'; print '<tr><td colspan="4">'.$langs->trans("VAT").'</td></tr>';
$subtotal_ht = 0; $subtotal_ht = 0;
$subtotal_ttc = 0; $subtotal_ttc = 0;
if ($modecompta == 'CREANCES-DETTES') if ($conf->tax->enabled && ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES'))
{ {
if ($modecompta == 'CREANCES-DETTES')
{
// TVA a payer // TVA a payer
$amount=0; $amount=0;
$sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.tva) as amount"; $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.tva) as amount";
@ -906,9 +1007,9 @@ if ($modecompta == 'CREANCES-DETTES')
print "<td align=\"right\">&nbsp;</td>\n"; print "<td align=\"right\">&nbsp;</td>\n";
print "<td align=\"right\">".price($amount)."</td>\n"; print "<td align=\"right\">".price($amount)."</td>\n";
print "</tr>\n"; print "</tr>\n";
} }
else else
{ {
// VAT really already paid // VAT really already paid
$amount=0; $amount=0;
$sql = "SELECT date_format(t.datev,'%Y-%m') as dm, sum(t.amount) as amount"; $sql = "SELECT date_format(t.datev,'%Y-%m') as dm, sum(t.amount) as amount";
@ -998,16 +1099,17 @@ else
print "<td align=\"right\">".price($amount)."</td>\n"; print "<td align=\"right\">".price($amount)."</td>\n";
print "<td align=\"right\">".price($amount)."</td>\n"; print "<td align=\"right\">".price($amount)."</td>\n";
print "</tr>\n"; print "</tr>\n";
} }
}
if ($mysoc->tva_assuj != 'franchise') // Assujetti
if ($mysoc->tva_assuj != 'franchise') // Assujetti {
{
print '<tr class="liste_total">'; print '<tr class="liste_total">';
if ($modecompta == 'CREANCES-DETTES') if ($modecompta == 'CREANCES-DETTES')
print '<td colspan="3" align="right">&nbsp;</td>'; print '<td colspan="3" align="right">&nbsp;</td>';
print '<td colspan="3" align="right">'.price(price2num($subtotal_ttc,'MT')).'</td>'; print '<td colspan="3" align="right">'.price(price2num($subtotal_ttc,'MT')).'</td>';
print '</tr>'; print '</tr>';
}
} }
$action = "balanceclient"; $action = "balanceclient";

View File

@ -22,6 +22,7 @@
/** /**
* \file htdocs/compta/resultat/index.php * \file htdocs/compta/resultat/index.php
* \ingroup compta, accountancy
* \brief Page reporting result * \brief Page reporting result
*/ */
@ -29,6 +30,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$langs->loadLangs(array('compta','bills','donation','salaries'));
$date_startmonth=GETPOST('date_startmonth'); $date_startmonth=GETPOST('date_startmonth');
$date_startday=GETPOST('date_startday'); $date_startday=GETPOST('date_startday');
@ -83,15 +85,24 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); }
} }
// $date_start and $date_end are defined. We force $start_year and $nbofyear
$tmps=dol_getdate($date_start);
$start_year = $tmps['year'];
$tmpe=dol_getdate($date_end);
$year_end = $tmpe['year'];
$nbofyear = ($year_end - $start_year) + 1;
//var_dump($start_year." ".$end_year." ".$nbofyear);
// Security check // Security check
$socid = GETPOST('socid','int'); $socid = GETPOST('socid','int');
if ($user->societe_id > 0) $socid = $user->societe_id; if ($user->societe_id > 0) $socid = $user->societe_id;
if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user,'compta','','','resultat'); if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user,'compta','','','resultat');
if (! empty($conf->accounting->enabled)) $result=restrictedArea($user,'accounting','','','comptarapport'); if (! empty($conf->accounting->enabled)) $result=restrictedArea($user,'accounting','','','comptarapport');
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING')
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES') $modecompta = $conf->global->ACCOUNTING_MODE;
$modecompta=(GETPOST("modecompta")?GETPOST("modecompta"):$conf->global->ACCOUNTING_MODE); if (! empty($conf->accounting->enabled)) $modecompta='BOOKKEEPING';
if (GETPOST("modecompta",'alpha')) $modecompta=GETPOST("modecompta",'alpha');
/* /*
@ -111,8 +122,9 @@ if ($modecompta == 'CREANCES-DETTES')
$name=$langs->trans("AnnualSummaryDueDebtMode"); $name=$langs->trans("AnnualSummaryDueDebtMode");
$calcmode=$langs->trans("CalcModeDebt"); $calcmode=$langs->trans("CalcModeDebt");
$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')'; $calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
$calcmode.='<br>('.$langs->trans("SeeReportInBookkeepingMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=BOOKKEEPING">','</a>').')';
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start+1)."&modecompta=".$modecompta."'>".img_next()."</a>":""); $periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear-2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
$description=$langs->trans("RulesAmountWithTaxIncluded"); $description=$langs->trans("RulesAmountWithTaxIncluded");
$description.='<br>'.$langs->trans("RulesResultDue"); $description.='<br>'.$langs->trans("RulesResultDue");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.="<br>".$langs->trans("DepositsAreNotIncluded"); if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.="<br>".$langs->trans("DepositsAreNotIncluded");
@ -120,17 +132,30 @@ if ($modecompta == 'CREANCES-DETTES')
$builddate=time(); $builddate=time();
//$exportlink=$langs->trans("NotYetAvailable"); //$exportlink=$langs->trans("NotYetAvailable");
} }
else { else if ($modecompta=="RECETTES-DEPENSES") {
$name=$langs->trans("AnnualSummaryInputOutputMode"); $name=$langs->trans("AnnualSummaryInputOutputMode");
$calcmode=$langs->trans("CalcModeEngagement"); $calcmode=$langs->trans("CalcModeEngagement");
$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')'; $calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
$calcmode.='<br>('.$langs->trans("SeeReportInBookkeepingMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=BOOKKEEPING">','</a>').')';
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start-1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year_start=".($year_start+1)."&modecompta=".$modecompta."'>".img_next()."</a>":""); $periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear-2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
$description=$langs->trans("RulesAmountWithTaxIncluded"); $description=$langs->trans("RulesAmountWithTaxIncluded");
$description.='<br>'.$langs->trans("RulesResultInOut"); $description.='<br>'.$langs->trans("RulesResultInOut");
$builddate=time(); $builddate=time();
//$exportlink=$langs->trans("NotYetAvailable"); //$exportlink=$langs->trans("NotYetAvailable");
} }
else if ($modecompta=="BOOKKEEPING")
{
$name=$langs->trans("AnnualSummaryDueDebtMode");
$calcmode=$langs->trans("CalcModeBookkeeping");
$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
$periodlink=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear-2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start+$nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>":"");
$description=$langs->trans("RulesAmountOnInOutBookkeepingRecord", $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->trans("AccountingCategory"));
$builddate=time();
//$exportlink=$langs->trans("NotYetAvailable");
}
$hselected='report'; $hselected='report';
@ -149,8 +174,10 @@ if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
$subtotal_ht = 0; $subtotal_ht = 0;
$subtotal_ttc = 0; $subtotal_ttc = 0;
if ($modecompta == 'CREANCES-DETTES') if (! empty($conf->facture->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
{ {
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT sum(f.total) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm"; $sql = "SELECT sum(f.total) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."facture as f";
@ -158,9 +185,11 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.= " AND f.fk_statut IN (1,2)"; $sql.= " AND f.fk_statut IN (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
else $sql.= " AND f.type IN (0,1,2,3,5)"; else $sql.= " AND f.type IN (0,1,2,3,5)";
} if (! empty($date_start) && ! empty($date_end))
else $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
{ }
else if ($modecompta=="RECETTES-DEPENSES")
{
/* /*
* Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les
* vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin) * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin)
@ -171,17 +200,20 @@ else
$sql.= ", ".MAIN_DB_PREFIX."paiement as p"; $sql.= ", ".MAIN_DB_PREFIX."paiement as p";
$sql.= " WHERE p.rowid = pf.fk_paiement"; $sql.= " WHERE p.rowid = pf.fk_paiement";
$sql.= " AND pf.fk_facture = f.rowid"; $sql.= " AND pf.fk_facture = f.rowid";
} if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
if ($socid) $sql.= " AND f.fk_soc = $socid"; }
$sql.= " GROUP BY dm";
$sql.= " ORDER BY dm";
//print $sql; $sql.= " AND f.entity = ".$conf->entity;
dol_syslog("get customers invoices", LOG_DEBUG); if ($socid) $sql.= " AND f.fk_soc = $socid";
$result=$db->query($sql); $sql.= " GROUP BY dm";
if ($result) $sql.= " ORDER BY dm";
{
//print $sql;
dol_syslog("get customers invoices", LOG_DEBUG);
$result=$db->query($sql);
if ($result)
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
@ -192,14 +224,21 @@ if ($result)
$i++; $i++;
} }
$db->free($result); $db->free($result);
} }
else { else {
dol_print_error($db); dol_print_error($db);
}
}
else if ($modecompta=="BOOKKEEPING")
{
// Nothing from this table
} }
// On ajoute les paiements clients anciennes version, non lies par paiement_facture if (! empty($conf->facture->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
if ($modecompta != 'CREANCES-DETTES')
{ {
// On ajoute les paiements clients anciennes version, non lies par paiement_facture
if ($modecompta != 'CREANCES-DETTES')
{
$sql = "SELECT sum(p.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm"; $sql = "SELECT sum(p.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
@ -209,6 +248,8 @@ if ($modecompta != 'CREANCES-DETTES')
$sql.= " AND p.fk_bank = b.rowid"; $sql.= " AND p.fk_bank = b.rowid";
$sql.= " AND b.fk_account = ba.rowid"; $sql.= " AND b.fk_account = ba.rowid";
$sql.= " AND ba.entity IN (".getEntity('bank_account').")"; $sql.= " AND ba.entity IN (".getEntity('bank_account').")";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
$sql.= " ORDER BY dm"; $sql.= " ORDER BY dm";
@ -233,6 +274,15 @@ if ($modecompta != 'CREANCES-DETTES')
else { else {
dol_print_error($db); dol_print_error($db);
} }
}
else if ($modecompta=="RECETTES-DEPENSES")
{
// Nothing from this table
}
}
else if ($modecompta=="BOOKKEEPING")
{
// Nothing from this table
} }
@ -242,31 +292,38 @@ if ($modecompta != 'CREANCES-DETTES')
$subtotal_ht = 0; $subtotal_ht = 0;
$subtotal_ttc = 0; $subtotal_ttc = 0;
if ($modecompta == 'CREANCES-DETTES') if (! empty($conf->facture->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
{ {
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm"; $sql = "SELECT sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc, date_format(f.datef,'%Y-%m') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
$sql.= " WHERE f.fk_statut IN (1,2)"; $sql.= " WHERE f.fk_statut IN (1,2)";
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
else $sql.= " AND f.type IN (0,1,2,3)"; else $sql.= " AND f.type IN (0,1,2,3)";
} if (! empty($date_start) && ! empty($date_end))
else $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
{ }
else if ($modecompta=="RECETTES-DEPENSES")
{
$sql = "SELECT sum(pf.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm"; $sql = "SELECT sum(pf.amount) as amount_ttc, date_format(p.datep,'%Y-%m') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p"; $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
$sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f"; $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f";
$sql.= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf"; $sql.= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
$sql.= " WHERE f.rowid = pf.fk_facturefourn"; $sql.= " WHERE f.rowid = pf.fk_facturefourn";
$sql.= " AND p.rowid = pf.fk_paiementfourn"; $sql.= " AND p.rowid = pf.fk_paiementfourn";
} if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
if ($socid) $sql.= " AND f.fk_soc = ".$socid; }
$sql.= " GROUP BY dm";
dol_syslog("get suppliers invoices", LOG_DEBUG); $sql.= " AND f.entity = ".$conf->entity;
$result=$db->query($sql); if ($socid) $sql.= " AND f.fk_soc = ".$socid;
if ($result) $sql.= " GROUP BY dm";
{
dol_syslog("get suppliers invoices", LOG_DEBUG);
$result=$db->query($sql);
if ($result)
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
@ -282,19 +339,28 @@ if ($result)
$i++; $i++;
} }
$db->free($result); $db->free($result);
} }
else { else {
dol_print_error($db); dol_print_error($db);
}
} }
else if ($modecompta=="BOOKKEEPING")
{
// Nothing from this table
}
/* /*
* TVA * TVA
*/ */
$subtotal_ht = 0; $subtotal_ht = 0;
$subtotal_ttc = 0; $subtotal_ttc = 0;
if ($modecompta == 'CREANCES-DETTES') if (! empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
{ {
if ($modecompta == 'CREANCES-DETTES')
{
// TVA a payer // TVA a payer
$sql = "SELECT sum(f.tva) as amount, date_format(f.datef,'%Y-%m') as dm"; $sql = "SELECT sum(f.tva) as amount, date_format(f.datef,'%Y-%m') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
@ -302,6 +368,8 @@ if ($modecompta == 'CREANCES-DETTES')
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)";
else $sql.= " AND f.type IN (0,1,2,3,5)"; else $sql.= " AND f.type IN (0,1,2,3,5)";
$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.entity = ".$conf->entity;
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
dol_syslog("get vat to pay", LOG_DEBUG); dol_syslog("get vat to pay", LOG_DEBUG);
@ -333,6 +401,8 @@ if ($modecompta == 'CREANCES-DETTES')
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
else $sql.= " AND f.type IN (0,1,2,3)"; else $sql.= " AND f.type IN (0,1,2,3)";
$sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.entity = ".$conf->entity;
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
dol_syslog("get vat to receive back", LOG_DEBUG); dol_syslog("get vat to receive back", LOG_DEBUG);
@ -357,13 +427,16 @@ if ($modecompta == 'CREANCES-DETTES')
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
else { else if ($modecompta=="RECETTES-DEPENSES")
{
// TVA reellement deja payee // TVA reellement deja payee
$sql = "SELECT sum(t.amount) as amount, date_format(t.datev,'%Y-%m') as dm"; $sql = "SELECT sum(t.amount) as amount, date_format(t.datev,'%Y-%m') as dm";
$sql.= " FROM ".MAIN_DB_PREFIX."tva as t"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
$sql.= " WHERE amount > 0"; $sql.= " WHERE amount > 0";
$sql.= " AND t.entity = ".$conf->entity; $sql.= " AND t.entity = ".$conf->entity;
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
dol_syslog("get vat really paid", LOG_DEBUG); dol_syslog("get vat really paid", LOG_DEBUG);
@ -393,6 +466,8 @@ else {
$sql.= " FROM ".MAIN_DB_PREFIX."tva as t"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as t";
$sql.= " WHERE amount < 0"; $sql.= " WHERE amount < 0";
$sql.= " AND t.entity = ".$conf->entity; $sql.= " AND t.entity = ".$conf->entity;
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
dol_syslog("get vat really received back", LOG_DEBUG); dol_syslog("get vat really received back", LOG_DEBUG);
@ -417,23 +492,33 @@ else {
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
}
}
else if ($modecompta=="BOOKKEEPING")
{
// Nothing from this table
} }
/* /*
* Charges sociales non deductibles * Charges sociales non deductibles
*/ */
$subtotal_ht = 0; $subtotal_ht = 0;
$subtotal_ttc = 0; $subtotal_ttc = 0;
if ($modecompta == 'CREANCES-DETTES') if (! empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
{ {
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount"; $sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql.= " WHERE cs.fk_type = c.id"; $sql.= " WHERE cs.fk_type = c.id";
$sql.= " AND c.deductible = 0"; $sql.= " AND c.deductible = 0";
} if (! empty($date_start) && ! empty($date_end))
else $sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
{ }
else if ($modecompta=="RECETTES-DEPENSES")
{
$sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount"; $sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
@ -441,13 +526,16 @@ else
$sql.= " WHERE p.fk_charge = cs.rowid"; $sql.= " WHERE p.fk_charge = cs.rowid";
$sql.= " AND cs.fk_type = c.id"; $sql.= " AND cs.fk_type = c.id";
$sql.= " AND c.deductible = 0"; $sql.= " AND c.deductible = 0";
} if (! empty($date_start) && ! empty($date_end))
$sql.= " AND cs.entity = ".$conf->entity; $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY c.libelle, dm"; }
dol_syslog("get social contributions deductible=0 ", LOG_DEBUG); $sql.= " AND cs.entity = ".$conf->entity;
$result=$db->query($sql); $sql.= " GROUP BY c.libelle, dm";
if ($result) {
dol_syslog("get social contributions deductible=0 ", LOG_DEBUG);
$result=$db->query($sql);
if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$var=false; $var=false;
$i = 0; $i = 0;
@ -464,9 +552,15 @@ if ($result) {
$i++; $i++;
} }
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
}
} }
else if ($modecompta=="BOOKKEEPING")
{
// Nothing from this table
}
/* /*
* Charges sociales deductibles * Charges sociales deductibles
@ -474,16 +568,20 @@ if ($result) {
$subtotal_ht = 0; $subtotal_ht = 0;
$subtotal_ttc = 0; $subtotal_ttc = 0;
if ($modecompta == 'CREANCES-DETTES') if (! empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
{ {
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount"; $sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql.= " WHERE cs.fk_type = c.id"; $sql.= " WHERE cs.fk_type = c.id";
$sql.= " AND c.deductible = 1"; $sql.= " AND c.deductible = 1";
} if (! empty($date_start) && ! empty($date_end))
else $sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
{ }
else if ($modecompta=="RECETTES-DEPENSES")
{
$sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount"; $sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
@ -491,13 +589,16 @@ else
$sql.= " WHERE p.fk_charge = cs.rowid"; $sql.= " WHERE p.fk_charge = cs.rowid";
$sql.= " AND cs.fk_type = c.id"; $sql.= " AND cs.fk_type = c.id";
$sql.= " AND c.deductible = 1"; $sql.= " AND c.deductible = 1";
} if (! empty($date_start) && ! empty($date_end))
$sql.= " AND cs.entity = ".$conf->entity; $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY c.libelle, dm"; }
dol_syslog("get social contributions paid deductible=1", LOG_DEBUG); $sql.= " AND cs.entity = ".$conf->entity;
$result=$db->query($sql); $sql.= " GROUP BY c.libelle, dm";
if ($result) {
dol_syslog("get social contributions paid deductible=1", LOG_DEBUG);
$result=$db->query($sql);
if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$var=false; $var=false;
$i = 0; $i = 0;
@ -514,68 +615,73 @@ if ($result) {
$i++; $i++;
} }
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
}
}
else if ($modecompta=="BOOKKEEPING")
{
// Nothing from this table
} }
$action = "balance";
$object = array(&$encaiss, &$encaiss_ttc, &$decaiss, &$decaiss_ttc);
$parameters["mode"] = $modecompta;
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('externalbalance'));
$reshook=$hookmanager->executeHooks('addReportInfo',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
/* /*
* Salaries * Salaries
*/ */
if (! empty($conf->salaries->enabled)) if (! empty($conf->salaries->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
{ {
if ($modecompta == 'CREANCES-DETTES') { if ($modecompta == 'CREANCES-DETTES') $column = 'p.datev';
$column = 'p.datev'; if ($modecompta == "RECETTES-DEPENSES") $column = 'p.datep';
} else {
$column = 'p.datep';
}
$subtotal_ht = 0; $subtotal_ht = 0;
$subtotal_ttc = 0; $subtotal_ttc = 0;
$sql = "SELECT p.label as nom, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; $sql = "SELECT p.label as nom, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; $sql .= " FROM " . MAIN_DB_PREFIX . "payment_salary as p";
$sql.= " WHERE p.entity = ".$conf->entity; $sql .= " WHERE p.entity = " . $conf->entity;
$sql.= " GROUP BY p.label, dm"; $sql .= " GROUP BY p.label, dm";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND ".$column." >= '".$db->idate($date_start)."' AND ".$column." <= '".$db->idate($date_end)."'";
dol_syslog("get social salaries payments"); dol_syslog("get social salaries payments");
$result=$db->query($sql); $result = $db->query($sql);
if ($result) if ($result) {
{
$num = $db->num_rows($result); $num = $db->num_rows($result);
$var=false; $var = false;
$i = 0; $i = 0;
if ($num) if ($num) {
{ while ($i < $num) {
while ($i < $num)
{
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0; if (! isset($decaiss[$obj->dm]))
$decaiss[$obj->dm] = 0;
$decaiss[$obj->dm] += $obj->amount; $decaiss[$obj->dm] += $obj->amount;
if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0; if (! isset($decaiss_ttc[$obj->dm]))
$decaiss_ttc[$obj->dm] = 0;
$decaiss_ttc[$obj->dm] += $obj->amount; $decaiss_ttc[$obj->dm] += $obj->amount;
$i++; $i ++;
} }
} }
} } else {
else
{
dol_print_error($db); dol_print_error($db);
} }
} }
elseif ($modecompta == "BOOKKEEPING")
{
// Nothing from this table
}
if (! empty($conf->expensereport->enabled))
/*
* Expense reports
*/
if (! empty($conf->expensereport->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
{ {
$langs->load('trips'); $langs->load('trips');
if ($modecompta == 'CREANCES-DETTES') { if ($modecompta == 'CREANCES-DETTES') {
$sql = "SELECT date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc"; $sql = "SELECT date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p";
@ -584,8 +690,10 @@ if (! empty($conf->expensereport->enabled))
$sql.= " AND p.fk_statut>=5"; $sql.= " AND p.fk_statut>=5";
$column='p.date_valid'; $column='p.date_valid';
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND ".$column." >= '".$db->idate($date_start)."' AND ".$column." <= '".$db->idate($date_end)."'";
} else { } elseif ($modecompta == 'RECETTES-DEPENSES') {
$sql = "SELECT date_format(pe.datep,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc"; $sql = "SELECT date_format(pe.datep,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as p";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
@ -595,6 +703,8 @@ if (! empty($conf->expensereport->enabled))
$sql.= " AND p.fk_statut>=5"; $sql.= " AND p.fk_statut>=5";
$column='pe.datep'; $column='pe.datep';
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND ".$column." >= '".$db->idate($date_start)."' AND ".$column." <= '".$db->idate($date_end)."'";
} }
$sql.= " GROUP BY dm"; $sql.= " GROUP BY dm";
@ -623,12 +733,18 @@ if (! empty($conf->expensereport->enabled))
{ {
dol_print_error($db); dol_print_error($db);
} }
} }
elseif ($modecompta == 'BOOKKEEPING') {
// Nothing from this table
}
/* /*
* Donation get dunning paiement * Donation get dunning paiement
*/ */
if (! empty($conf->don->enabled))
if (! empty($conf->don->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
{ {
$subtotal_ht = 0; $subtotal_ht = 0;
$subtotal_ttc = 0; $subtotal_ttc = 0;
@ -638,15 +754,20 @@ if (! empty($conf->don->enabled))
$sql.= " FROM ".MAIN_DB_PREFIX."don as p"; $sql.= " FROM ".MAIN_DB_PREFIX."don as p";
$sql.= " WHERE p.entity = ".$conf->entity; $sql.= " WHERE p.entity = ".$conf->entity;
$sql.= " AND fk_statut in (1,2)"; $sql.= " AND fk_statut in (1,2)";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'";
} }
else { elseif ($modecompta == 'RECETTES-DEPENSES') {
$sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount"; $sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(p.amount) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."don as p"; $sql.= " FROM ".MAIN_DB_PREFIX."don as p";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
$sql.= " WHERE p.entity = ".getEntity('donation'); $sql.= " WHERE p.entity = ".getEntity('donation');
$sql.= " AND fk_statut >= 2"; $sql.= " AND fk_statut >= 2";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND pe.datep >= '".$db->idate($date_start)."' AND pe.datep <= '".$db->idate($date_end)."'";
} }
$sql.= " GROUP BY p.societe, p.firstname, p.lastname, dm"; $sql.= " GROUP BY p.societe, p.firstname, p.lastname, dm";
dol_syslog("get donation payments"); dol_syslog("get donation payments");
@ -677,6 +798,72 @@ if (! empty($conf->don->enabled))
dol_print_error($db); dol_print_error($db);
} }
} }
elseif ($modecompta == 'BOOKKEEPING') {
// Nothing from this table
}
/*
* Donation get dunning paiement
*/
if (! empty($conf->accounting->enabled) && ($modecompta == 'BOOKKEEPING'))
{
$subtotal_ht = 0;
$subtotal_ttc = 0;
$sql = "SELECT b.doc_ref, b.numero_compte, b.subledger_account, b.subledger_label, pcg_type, date_format(b.doc_date,'%Y-%m') as dm, sum(b.debit) as debit, sum(b.credit) as credit, sum(b.montant) as amount";
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_account as aa";
$sql.= " WHERE b.numero_compte = aa.account_number AND b.entity = ".$conf->entity;
//$sql.= " AND fk_statut in (1,2)";
$sql.= " AND pcg_type in ('INCOME', 'EXPENSE')";
//$sql.= " AND code_journal in ('VT', 'AC')";
if (! empty($date_start) && ! empty($date_end))
$sql.= " AND b.doc_date >= '".$db->idate($date_start)."' AND b.doc_date <= '".$db->idate($date_end)."'";
$sql.= " GROUP BY b.doc_ref, b.numero_compte, b.subledger_account, b.subledger_label, pcg_type, dm";
//print $sql;
dol_syslog("get donation payments");
$result=$db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$var=false;
$i = 0;
if ($num)
{
while ($i < $num)
{
$obj = $db->fetch_object($result);
if (! isset($encaiss[$obj->dm])) $encaiss[$obj->dm]=0;
$encaiss[$obj->dm] += $obj->debit;
if (! isset($encaiss_ttc[$obj->dm])) $encaiss_ttc[$obj->dm]=0;
$encaiss_ttc[$obj->dm] += $obj->credit;
$i++;
}
}
}
else
{
dol_print_error($db);
}
}
$action = "balance";
$object = array(&$encaiss, &$encaiss_ttc, &$decaiss, &$decaiss_ttc);
$parameters["mode"] = $modecompta;
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('externalbalance'));
$reshook=$hookmanager->executeHooks('addReportInfo',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
/* /*
* Show result array * Show result array

View File

@ -29,11 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
$error = 0; $langs->loadLangs(array('compta','bills','donation','salaries'));
// Langs $error = 0;
$langs->load("accountancy");
$langs->load("compta");
$mesg = ''; $mesg = '';
$action = GETPOST('action','aZ09'); $action = GETPOST('action','aZ09');
@ -98,6 +96,24 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); }
} }
if (($date_start < dol_time_plus_duree($date_end, -1, 'y')) || ($date_start > $date_end))
{
$date_end = dol_time_plus_duree($date_start - 1, 1, 'y');
}
// $date_start and $date_end are defined. We force $start_year and $nbofyear
$tmps=dol_getdate($date_start);
$start_year = $tmps['year'];
$tmpe=dol_getdate($date_end);
$year_end = $tmpe['year'];
$nbofyear = ($year_end - $start_year) + 1;
$date_start_previous = dol_time_plus_duree($date_start, -1, 'y');
$date_end_previous = dol_time_plus_duree($date_end, -1, 'y');
//var_dump($date_start." ".$date_end." ".$date_start_previous." ".$date_end_previous." ".$nbofyear);
if($cat_id == 0){ if($cat_id == 0){
$cat_id = null; $cat_id = null;
} }
@ -125,8 +141,8 @@ llxheader('', $langs->trans('ReportInOut'));
$formaccounting = new FormAccounting($db); $formaccounting = new FormAccounting($db);
$form = new Form($db); $form = new Form($db);
$textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current - 1) . '">' . img_previous() . '</a>'; $textprevyear = '<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($start_year - 1) . '">' . img_previous() . '</a>';
$textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($year_current + 1) . '">' . img_next() . '</a>'; $textnextyear = '&nbsp;<a href="' . $_SERVER["PHP_SELF"] . '?year=' . ($start_year + 1) . '">' . img_next() . '</a>';
@ -135,8 +151,8 @@ if ($modecompta=="CREANCES-DETTES")
{ {
$name=$langs->trans("AnnualByAccountDueDebtMode"); $name=$langs->trans("AnnualByAccountDueDebtMode");
$calcmode=$langs->trans("CalcModeDebt"); $calcmode=$langs->trans("CalcModeDebt");
$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.(GETPOST("month")>0?'&month='.GETPOST("month"):'').'&modecompta=RECETTES-DEPENSES">','</a>').')'; $calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$start_year.(GETPOST("month")>0?'&month='.GETPOST("month"):'').'&modecompta=RECETTES-DEPENSES">','</a>').')';
$calcmode.='<br>('.$langs->trans("SeeReportInBookkeepingMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=BOOKKEEPING">','</a>').')'; $calcmode.='<br>('.$langs->trans("SeeReportInBookkeepingMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$start_year.'&modecompta=BOOKKEEPING">','</a>').')';
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
//$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>'; //$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
$description=$langs->trans("RulesResultDue"); $description=$langs->trans("RulesResultDue");
@ -149,7 +165,7 @@ else if ($modecompta=="RECETTES-DEPENSES") {
$name=$langs->trans("AnnualByAccountInputOutputMode"); $name=$langs->trans("AnnualByAccountInputOutputMode");
$calcmode=$langs->trans("CalcModeEngagement"); $calcmode=$langs->trans("CalcModeEngagement");
$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.(GETPOST("month")>0?'&month='.GETPOST("month"):'').'&modecompta=CREANCES-DETTES">','</a>').')'; $calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.(GETPOST("month")>0?'&month='.GETPOST("month"):'').'&modecompta=CREANCES-DETTES">','</a>').')';
$calcmode.='<br>('.$langs->trans("SeeReportInBookkeepingMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=BOOKKEEPING">','</a>').')'; $calcmode.='<br>('.$langs->trans("SeeReportInBookkeepingMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&modecompta=BOOKKEEPING">','</a>').')';
//$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',1,1,0,'',1,0,1); //$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',1,1,0,'',1,0,1);
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
//$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>'; //$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
@ -159,18 +175,18 @@ else if ($modecompta=="RECETTES-DEPENSES") {
} }
else if ($modecompta=="BOOKKEEPING") else if ($modecompta=="BOOKKEEPING")
{ {
$name = $langs->trans("ReportInOut").', '.$langs->trans("ByAccounts"); $name = $langs->trans("ReportInOut").', '.$langs->trans("ByPersonalizedAccountGroups");
$calcmode=$langs->trans("CalcModeBookkeeping"); $calcmode=$langs->trans("CalcModeBookkeeping");
$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')'; //$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')'; //$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
$nomlink = ''; $nomlink = '';
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
$period.=' &nbsp; '.$langs->trans("Detail").' '. $form->selectyesno('simple_report',$simple_report,0); $period.=' &nbsp; &nbsp; '.$langs->trans("DetailByAccount").' '. $form->selectyesno('simple_report',$simple_report,0);
$periodlink = $textprevyear . " " . $langs->trans("Year") . " " . $year_start . " " . $textnextyear ; $periodlink = $textprevyear . " " . $langs->trans("Year") . " " . $start_year . " " . $textnextyear ;
$exportlink = ''; $exportlink = '';
$description=$langs->trans("RulesResultDue"); $description=$langs->trans("RulesResultBookkeepingPersonalized", $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->trans("AccountingCategory"));
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); //if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
else $description.= $langs->trans("DepositsAreIncluded"); //else $description.= $langs->trans("DepositsAreIncluded");
$builddate = time(); $builddate = time();
} }
@ -203,30 +219,46 @@ $months = array( $langs->trans("JanuaryMin"),
); );
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<th class="liste_titre">'.$langs->trans("Account").'</th>'; print '<th class="liste_titre">'.$langs->trans("AccountingCategory").'</th>';
print '<th class="liste_titre">'.$langs->trans("Description").'</th>'; print '<th class="liste_titre"></th>';
print '<th class="liste_titre" align="center">N-1</th>'; print '<th class="liste_titre" align="right">'.$langs->trans("PreviousYear").'</th>';
print '<th class="liste_titre" align="center">'.$langs->trans("NReal").'</th>'; print '<th class="liste_titre" align="right">'.$langs->trans("SelectedPeriod").'</th>';
foreach($months as $k => $v){ foreach($months as $k => $v){
print '<th class="liste_titre" align="center">'.$langs->trans($v).'</th>'; print '<th class="liste_titre" align="right">'.$langs->trans($v).'</th>';
} }
print '</tr>'; print '</tr>';
if ($modecompta == 'CREANCES-DETTES')
{
//if (! empty($date_start) && ! empty($date_end))
// $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
}
else if ($modecompta=="RECETTES-DEPENSES")
{
//if (! empty($date_start) && ! empty($date_end))
// $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
}
else if ($modecompta=="BOOKKEEPING")
{
// TODO
//if (! empty($date_start) && ! empty($date_end))
// $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
//All categories
$cats = $AccCat->getCats();
if ($catsCalcule < 0) dol_print_error($db, $AccCat->error, $AccCat->errors);
//All categories $j=1;
$cats = $AccCat->getCats(); $sommes = array();
if ($catsCalcule < 0) dol_print_error($db, $AccCat->error, $AccCat->errors);
$j=1;
$sommes = array();
foreach($cats as $cat ){
if(!empty($cat['category_type'])){ // category calculed
foreach ($cats as $cat) // Loop on each group
{
if (!empty($cat['category_type'])) // category calculed
{
$formula = $cat['formula']; $formula = $cat['formula'];
print "<tr class='liste_titre'>"; print "<tr>";
//print '<td colspan="2"><font color="blue">' . $cat['label'] . '</font></td>';
print '<td colspan="2">' . $cat['label'] . '</td>'; print '<td colspan="2">' . $cat['label'] . '</td>';
$vars = array(); $vars = array();
@ -242,7 +274,7 @@ foreach($cats as $cat ){
$r = $AccCat->calculate($result); $r = $AccCat->calculate($result);
print '<td align="right"><font color="blue">' . price($r) . '</td>'; print '<td align="right"><font color="blue">' . price($r) . '</font></td>';
$code = $cat['code']; // code categorie de calcule $code = $cat['code']; // code categorie de calcule
$sommes[$code]['NP'] += $r; $sommes[$code]['NP'] += $r;
@ -257,7 +289,7 @@ foreach($cats as $cat ){
$r = $AccCat->calculate($result); $r = $AccCat->calculate($result);
print '<td align="right"><font color="blue">' . price($r) . '</td>'; print '<td align="right"><font color="blue">' . price($r) . '</font></td>';
$sommes[$code]['N'] += $r; $sommes[$code]['N'] += $r;
// Detail by month // Detail by month
@ -267,7 +299,7 @@ foreach($cats as $cat ){
} }
$result = strtr($formula, $vars); $result = strtr($formula, $vars);
$r = $AccCat->calculate($result); $r = $AccCat->calculate($result);
print '<td align="right"><font color="blue">' . price($r) . '</td>'; print '<td align="right"><font color="blue">' . price($r) . '</font></td>';
$sommes[$code]['M'][$k] += $r; $sommes[$code]['M'][$k] += $r;
} }
@ -275,25 +307,56 @@ foreach($cats as $cat ){
print "</tr>\n"; print "</tr>\n";
}else{ // normal category }
else // normal category
{
$totCat = array(); $totCat = array();
$totCat['NP'] = 0;
$totCat['N'] = 0;
$totCat['M'] = array(); $totCat['M'] = array();
foreach($months as $k => $v)
{
$totCat['M'][$k] = 0;
}
// get cpts of category // Get cpts of category/group
$cpts = $AccCat->getCptsCat($cat['rowid']); $cpts = $AccCat->getCptsCat($cat['rowid']);
print "<tr>";
print "<tr class='liste_titre'>"; // Column group
print '<td colspan="2">' . $cat['label'] . '</td>'; print '<td colspan="2">';
print $cat['label'];
foreach($cpts as $i => $cpt){ if (count($cpts) > 0)
$var = ! $var; {
$i=0;
foreach($cpts as $cpt)
{
if ($i > 5)
{
print '...)';
break;
}
if ($i > 0) print ', ';
else print ' (';
print $cpt['account_number'];
$i++;
}
if ($i <= 5) print ')';
}
else
{
print ' - <span class="warning">'.$langs->trans("GroupIsEmptyCheckSetup").'</span>';
}
print '</td>';
$code = $cat['code']; $code = $cat['code'];
// Column N Previous and N
foreach($cpts as $i => $cpt)
{
// N-1 // N-1
$return = $AccCat->getResult($cpt['account_number'], 0, $year_current -1, $cpt['dc']); $return = $AccCat->getResult($cpt['account_number'], 0, $date_start_previous, $date_end_previous, $cpt['dc']);
if ($return < 0) { if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors'); setEventMessages(null, $AccCat->errors, 'errors');
@ -303,7 +366,7 @@ foreach($cats as $cat ){
} }
//N //N
$return = $AccCat->getResult($cpt['account_number'], 0, $year_current, $cpt['dc']); $return = $AccCat->getResult($cpt['account_number'], 0, $date_start, $date_end, $cpt['dc']);
if ($return < 0) { if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors'); setEventMessages(null, $AccCat->errors, 'errors');
$resultN=0; $resultN=0;
@ -314,8 +377,9 @@ foreach($cats as $cat ){
$totCat['NP'] += $resultNP; $totCat['NP'] += $resultNP;
$totCat['N'] += $resultN; $totCat['N'] += $resultN;
foreach($months as $k => $v){ foreach($months as $k => $v)
$return = $AccCat->getResult($cpt['account_number'], $k+1, $year_current, $cpt['dc']); {
$return = $AccCat->getResult($cpt['account_number'], $k+1, $date_start, $date_end, $cpt['dc']);
if ($return < 0) { if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors'); setEventMessages(null, $AccCat->errors, 'errors');
$resultM=0; $resultM=0;
@ -323,7 +387,6 @@ foreach($cats as $cat ){
$resultM=$AccCat->sdc; $resultM=$AccCat->sdc;
} }
$totCat['M'][$k] += $resultM; $totCat['M'][$k] += $resultM;
} }
} }
@ -335,13 +398,11 @@ foreach($cats as $cat ){
} }
print "</tr>\n"; print "</tr>\n";
foreach($cpts as $i => $cpt){ //
$var = ! $var; foreach($cpts as $i => $cpt)
{
$code = $cat['code'];
// N-1 // N-1
$return = $AccCat->getResult($cpt['account_number'], 0, $year_current -1, $cpt['dc']); $return = $AccCat->getResult($cpt['account_number'], 0, $date_start_previous, $date_end_previous, $cpt['dc']);
if ($return < 0) { if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors'); setEventMessages(null, $AccCat->errors, 'errors');
@ -351,7 +412,7 @@ foreach($cats as $cat ){
} }
//N //N
$return = $AccCat->getResult($cpt['account_number'], 0, $year_current, $cpt['dc']); $return = $AccCat->getResult($cpt['account_number'], 0, $date_start, $date_end, $cpt['dc']);
if ($return < 0) { if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors'); setEventMessages(null, $AccCat->errors, 'errors');
$resultN=0; $resultN=0;
@ -361,16 +422,18 @@ foreach($cats as $cat ){
$sommes[$code]['NP'] += $resultNP; $sommes[$code]['NP'] += $resultNP;
$sommes[$code]['N'] += $resultN; $sommes[$code]['N'] += $resultN;
print '<tr'. $bc[$var].'>';
if ($simple_report == 'yes') { if ($simple_report == 'yes') {
print '<td>' . length_accountg($cpt['account_number']) . '</td>'; print '<tr>';
print '<td> &nbsp; &nbsp; ' . length_accountg($cpt['account_number']) . '</td>';
print '<td>' . $cpt['name_cpt'] . '</td>'; print '<td>' . $cpt['name_cpt'] . '</td>';
print '<td align="right">' . price($resultNP) . '</td>'; print '<td align="right">' . price($resultNP) . '</td>';
print '<td align="right">' . price($resultN) . '</td>'; print '<td align="right">' . price($resultN) . '</td>';
} }
foreach($months as $k => $v){ foreach($months as $k => $v)
$return = $AccCat->getResult($cpt['account_number'], $k+1, $year_current, $cpt['dc']); {
$return = $AccCat->getResult($cpt['account_number'], $k+1, $date_start, $date_end, $cpt['dc']);
if ($return < 0) { if ($return < 0) {
setEventMessages(null, $AccCat->errors, 'errors'); setEventMessages(null, $AccCat->errors, 'errors');
$resultM=0; $resultM=0;
@ -383,10 +446,12 @@ foreach($cats as $cat ){
} }
} }
if ($simple_report == 'yes') {
print "</tr>\n"; print "</tr>\n";
} }
} }
}
}
} }
print "</table>"; print "</table>";

View File

@ -186,6 +186,9 @@ if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
} }
$name=array();
// SQL request // SQL request
$catotal=0; $catotal=0;
$catotal_ht=0; $catotal_ht=0;

View File

@ -167,6 +167,8 @@ if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
} }
$name=array();
// Show array // Show array
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
// Extra parameters management // Extra parameters management

View File

@ -195,6 +195,8 @@ if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
} }
$name=array();
// Show Array // Show Array
$catotal=0; $catotal=0;
if ($modecompta == 'CREANCES-DETTES') { if ($modecompta == 'CREANCES-DETTES') {

View File

@ -27,6 +27,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$langs->loadLangs(array('compta','bills','donation','salaries'));
$date_startmonth=GETPOST('date_startmonth'); $date_startmonth=GETPOST('date_startmonth');
$date_startday=GETPOST('date_startday'); $date_startday=GETPOST('date_startday');

View File

@ -3284,11 +3284,12 @@ function dol_print_error_email($prefixcode, $errormessage='')
* @param string $sortfield Current field used to sort * @param string $sortfield Current field used to sort
* @param string $sortorder Current sort order * @param string $sortorder Current sort order
* @param string $prefix Prefix for css. Use space after prefix to add your own CSS tag. * @param string $prefix Prefix for css. Use space after prefix to add your own CSS tag.
* @param string $tooltip Tooltip
* @return void * @return void
*/ */
function print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $td="", $sortfield="", $sortorder="", $prefix="") function print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $td="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
{ {
print getTitleFieldOfList($name, 0, $file, $field, $begin, $moreparam, $td, $sortfield, $sortorder, $prefix); print getTitleFieldOfList($name, 0, $file, $field, $begin, $moreparam, $td, $sortfield, $sortorder, $prefix, 0, $tooltip);
} }
/** /**
@ -3305,11 +3306,12 @@ function print_liste_field_titre($name, $file="", $field="", $begin="", $morepar
* @param string $sortorder Current sort order (Ex: 'asc,desc') * @param string $sortorder Current sort order (Ex: 'asc,desc')
* @param string $prefix Prefix for css. Use space after prefix to add your own CSS tag. * @param string $prefix Prefix for css. Use space after prefix to add your own CSS tag.
* @param string $disablesortlink 1=Disable sort link * @param string $disablesortlink 1=Disable sort link
* @param string $tooltip Tooltip
* @return string * @return string
*/ */
function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0) function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='')
{ {
global $conf, $langs; global $conf, $langs, $form;
//print "$name, $file, $field, $begin, $options, $moreattrib, $sortfield, $sortorder<br>\n"; //print "$name, $file, $field, $begin, $options, $moreattrib, $sortfield, $sortorder<br>\n";
$sortorder=strtoupper($sortorder); $sortorder=strtoupper($sortorder);
@ -3350,7 +3352,8 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m
} }
} }
$out.=$langs->trans($name); if ($tooltip) $out.=$form->textwithpicto($langs->trans($name), $langs->trans($tooltip));
else $out.=$langs->trans($name);
if (empty($thead) && $field && empty($disablesortlink)) // If this is a sort field if (empty($thead) && $field && empty($disablesortlink)) // If this is a sort field
{ {

View File

@ -249,10 +249,10 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
-- Balance -- Balance
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2435__+MAX_llx_menu__, 'accountancy', 'balance', 2400__+MAX_llx_menu__, '/accountancy/bookkeeping/balance.php?mainmenu=accountancy&leftmenu=accountancy_balance', 'AccountBalance', 1, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 16, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2435__+MAX_llx_menu__, 'accountancy', 'balance', 2400__+MAX_llx_menu__, '/accountancy/bookkeeping/balance.php?mainmenu=accountancy&leftmenu=accountancy_balance', 'AccountBalance', 1, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 16, __ENTITY__);
-- Reports -- Reports
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2440__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2400__+MAX_llx_menu__, '/compta/resultat/result.php?mainmenu=accountancy&leftmenu=accountancy_report', 'Reportings', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 17, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2440__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2400__+MAX_llx_menu__, '/compta/resultat/index.php?mainmenu=accountancy&leftmenu=accountancy_report', 'Reportings', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 17, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2441__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2440__+MAX_llx_menu__, '/compta/resultat/index.php?mainmenu=accountancy&leftmenu=accountancy_report', 'ReportInOut', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 19, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2441__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2440__+MAX_llx_menu__, '/compta/resultat/index.php?mainmenu=accountancy&leftmenu=accountancy_report', 'ReportInOut', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 18, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2442__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2441__+MAX_llx_menu__, '/compta/resultat/result.php?mainmenu=accountancy&leftmenu=accountancy_report', 'ByAccounts', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 18, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2443__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2441__+MAX_llx_menu__, '/compta/resultat/clientfourn.php?mainmenu=accountancy&leftmenu=accountancy_report', 'ByPredefinedAccountGroups', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 19, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2443__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2441__+MAX_llx_menu__, '/compta/resultat/clientfourn.php?mainmenu=accountancy&leftmenu=accountancy_report', 'ByCompanies', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 20, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2442__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2441__+MAX_llx_menu__, '/compta/resultat/result.php?mainmenu=accountancy&leftmenu=accountancy_report', 'ByPersonalizedAccountGroups', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 20, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2444__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2440__+MAX_llx_menu__, '/compta/stats/index.php?mainmenu=accountancy&leftmenu=accountancy_report', 'ReportTurnover', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 21, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2444__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2440__+MAX_llx_menu__, '/compta/stats/index.php?mainmenu=accountancy&leftmenu=accountancy_report', 'ReportTurnover', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 21, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2445__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2444__+MAX_llx_menu__, '/compta/stats/casoc.php?mainmenu=accountancy&leftmenu=accountancy_report', 'ByCompanies', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 22, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2445__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2444__+MAX_llx_menu__, '/compta/stats/casoc.php?mainmenu=accountancy&leftmenu=accountancy_report', 'ByCompanies', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 22, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2446__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2444__+MAX_llx_menu__, '/compta/stats/cabyuser.php?mainmenu=accountancy&leftmenu=accountancy_report', 'ByUsers', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 23, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_report"', __HANDLER__, 'left', 2446__+MAX_llx_menu__, 'accountancy', 'accountancy_report', 2444__+MAX_llx_menu__, '/compta/stats/cabyuser.php?mainmenu=accountancy&leftmenu=accountancy_report', 'ByUsers', 3, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 23, __ENTITY__);

View File

@ -1118,11 +1118,11 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
// Reports // Reports
$langs->load("compta"); $langs->load("compta");
$newmenu->add("/compta/resultat/result.php?mainmenu=accountancy&amp;leftmenu=accountancy_report",$langs->trans("Reportings"),1,$user->rights->accounting->comptarapport->lire, '', $mainmenu, 'ca'); $newmenu->add("/compta/resultat/index.php?mainmenu=accountancy&amp;leftmenu=accountancy_report",$langs->trans("Reportings"),1,$user->rights->accounting->comptarapport->lire, '', $mainmenu, 'ca');
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/resultat/index.php?leftmenu=accountancy_report",$langs->trans("ReportInOut"),2,$user->rights->accounting->comptarapport->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/resultat/index.php?leftmenu=accountancy_report",$langs->trans("ReportInOut"),2,$user->rights->accounting->comptarapport->lire);
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/resultat/result.php?leftmenu=accountancy_report",$langs->trans("ByAccounts"),3,$user->rights->accounting->comptarapport->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=accountancy_report",$langs->trans("ByPredefinedAccountGroups"),3,$user->rights->accounting->comptarapport->lire);
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/resultat/clientfourn.php?leftmenu=accountancy_report",$langs->trans("ByCompanies"),3,$user->rights->accounting->comptarapport->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/resultat/result.php?leftmenu=accountancy_report",$langs->trans("ByPersonalizedAccountGroups"),3,$user->rights->accounting->comptarapport->lire);
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/index.php?leftmenu=accountancy_report",$langs->trans("ReportTurnover"),2,$user->rights->accounting->comptarapport->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/index.php?leftmenu=accountancy_report",$langs->trans("ReportTurnover"),2,$user->rights->accounting->comptarapport->lire);
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report",$langs->trans("ByCompanies"),3,$user->rights->accounting->comptarapport->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report",$langs->trans("ByCompanies"),3,$user->rights->accounting->comptarapport->lire);
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report",$langs->trans("ByUsers"),3,$user->rights->accounting->comptarapport->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report",$langs->trans("ByUsers"),3,$user->rights->accounting->comptarapport->lire);

File diff suppressed because it is too large Load Diff

View File

@ -24,6 +24,6 @@
-- Categories compte de résultat Français -- Categories compte de résultat Français
-- --
INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 1,'VTE', 'Ventes de marchandises', '707xxx', 0, 0, '', '10', 1, 1); INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 1, 'VTE', 'Ventes de marchandises', '707xxx', 0, 0, '', '10', 1, 1);
INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 2,'MAR', 'Coût achats marchandises vendues', '603xxx | 607xxx | 609xxx', 0, 0, '', '20', 1, 1); INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 2, 'MAR', 'Coût achats marchandises vendues', '603xxx | 607xxx | 609xxx', 0, 0, '', '20', 1, 1);
INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 3,'MARGE','Marge commerciale', '', 0, 1, '1 + 2', '30', 1, 1); INSERT INTO llx_c_accounting_category (rowid, code, label, range_account, sens, category_type, formula, position, fk_country, active) VALUES ( 3, 'MARGE', 'Marge commerciale', '', 0, 1, '1 + 2', '30', 1, 1);

View File

@ -208,6 +208,10 @@ UPDATE llx_const set name = 'ONLINE_PAYMENT_CSS_URL' where name = 'PAYPAL_CS
UPDATE llx_const set name = 'ONLINE_PAYMENT_NEWFORMTEXT' where name = 'PAYPAL_NEWFORMTEXT'; UPDATE llx_const set name = 'ONLINE_PAYMENT_NEWFORMTEXT' where name = 'PAYPAL_NEWFORMTEXT';
UPDATE llx_const set name = 'ONLINE_PAYMENT_LOGO' where name = 'PAYPAL_LOGO'; UPDATE llx_const set name = 'ONLINE_PAYMENT_LOGO' where name = 'PAYPAL_LOGO';
UPDATE llx_accounting_account SET pcg_type = 'INCOME' where pcg_type = 'PROD';
UPDATE llx_accounting_account SET pcg_type = 'EXPENSE' where pcg_type = 'CHARGE';
UPDATE llx_accounting_account SET pcg_type = 'INCOME' where pcg_type = 'VENTAS_E_INGRESOS';
UPDATE llx_accounting_account SET pcg_type = 'EXPENSE' where pcg_type = 'COMPRAS_GASTOS';
-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8;

View File

@ -31,6 +31,10 @@ ConfirmDeleteCptCategory=Are you sure you want to remove this accounting account
JournalizationInLedgerStatus=Status of journalization JournalizationInLedgerStatus=Status of journalization
AlreadyInGeneralLedger=Already journalized in ledgers AlreadyInGeneralLedger=Already journalized in ledgers
NotYetInGeneralLedger=Not yet journalized in ledgers NotYetInGeneralLedger=Not yet journalized in ledgers
PreviousYear=Previous year
SelectedPeriod=Selected period
GroupIsEmptyCheckSetup=Group is empty, check setup of the accounting group
DetailByAccount=Show detail by account
MainAccountForCustomersNotDefined=Main accounting account for customers not defined in setup MainAccountForCustomersNotDefined=Main accounting account for customers not defined in setup
MainAccountForSuppliersNotDefined=Main accounting account for suppliers not defined in setup MainAccountForSuppliersNotDefined=Main accounting account for suppliers not defined in setup
@ -150,7 +154,10 @@ NumPiece=Piece number
TransactionNumShort=Num. transaction TransactionNumShort=Num. transaction
AccountingCategory=Accounting account groups AccountingCategory=Accounting account groups
GroupByAccountAccounting=Group by accounting account GroupByAccountAccounting=Group by accounting account
AccountingAccountGroupsDesc=You can define here some groups of accounting account. It will be used in the report <b>%s</b> to show your income/expense with data grouped according to your groups.
ByAccounts=By accounts ByAccounts=By accounts
ByPredefinedAccountGroups=By predefined groups
ByPersonalizedAccountGroups=By personalized groups
NotMatch=Not Set NotMatch=Not Set
DeleteMvt=Delete Ledger lines DeleteMvt=Delete Ledger lines
DelYear=Year to delete DelYear=Year to delete
@ -180,8 +187,9 @@ ListAccounts=List of the accounting accounts
UnknownAccountForThirdparty=Unknown third party account. We will use %s UnknownAccountForThirdparty=Unknown third party account. We will use %s
UnknownAccountForThirdpartyBlocking=Unknown third party account. Blocking error UnknownAccountForThirdpartyBlocking=Unknown third party account. Blocking error
Pcgtype=Class of account Pcgtype=Group of account
Pcgsubtype=Subclass of account Pcgsubtype=Subgroup of account
PcgtypeDesc=Group and subgroup of account are used as predefined 'filter' and 'grouping' criterias for some accounting reports. For example, 'INCOME' or 'EXPENSE' are used as group for accounting account products to build the expense/income report.
TotalVente=Total turnover before tax TotalVente=Total turnover before tax
TotalMarge=Total sales margin TotalMarge=Total sales margin

View File

@ -143,8 +143,9 @@ CalcModeLT2Debt=Mode <b>%sIRPF on customer invoices%s</b>
CalcModeLT2Rec= Mode <b>%sIRPF on suppliers invoices%s</b> CalcModeLT2Rec= Mode <b>%sIRPF on suppliers invoices%s</b>
AnnualSummaryDueDebtMode=Balance of income and expenses, annual summary AnnualSummaryDueDebtMode=Balance of income and expenses, annual summary
AnnualSummaryInputOutputMode=Balance of income and expenses, annual summary AnnualSummaryInputOutputMode=Balance of income and expenses, annual summary
AnnualByCompaniesDueDebtMode=Balance of income and expenses, detail by third parties, mode <b>%sClaims-Debts%s</b> said <b>Commitment accounting</b>. AnnualByCompanies=Income / Expenses, By predefined groups of account
AnnualByCompaniesInputOutputMode=Balance of income and expenses, detail by third parties, mode <b>%sIncomes-Expenses%s</b> said <b>cash accounting</b>. AnnualByCompaniesDueDebtMode=Balance of income and expenses, detail by predefined groups, mode <b>%sClaims-Debts%s</b> said <b>Commitment accounting</b>.
AnnualByCompaniesInputOutputMode=Balance of income and expenses, detail by predefined groups, mode <b>%sIncomes-Expenses%s</b> said <b>cash accounting</b>.
SeeReportInInputOutputMode=See report <b>%sIncomes-Expenses%s</b> said <b>cash accounting</b> for a calculation on actual payments made SeeReportInInputOutputMode=See report <b>%sIncomes-Expenses%s</b> said <b>cash accounting</b> for a calculation on actual payments made
SeeReportInDueDebtMode=See report <b>%sClaims-Debts%s</b> said <b>commitment accounting</b> for a calculation on issued invoices SeeReportInDueDebtMode=See report <b>%sClaims-Debts%s</b> said <b>commitment accounting</b> for a calculation on issued invoices
SeeReportInBookkeepingMode=See report <b>%sBookeeping%s</b> for a calculation on bookkeeping table analysis SeeReportInBookkeepingMode=See report <b>%sBookeeping%s</b> for a calculation on bookkeeping table analysis
@ -153,6 +154,9 @@ RulesResultDue=- It includes outstanding invoices, expenses, VAT, donations whet
RulesResultInOut=- It includes the real payments made on invoices, expenses, VAT and salaries. <br>- It is based on the payment dates of the invoices, expenses, VAT and salaries. The donation date for donation. RulesResultInOut=- It includes the real payments made on invoices, expenses, VAT and salaries. <br>- It is based on the payment dates of the invoices, expenses, VAT and salaries. The donation date for donation.
RulesCADue=- It includes the client's due invoices whether they are paid or not. <br>- It is based on the validation date of these invoices.<br> RulesCADue=- It includes the client's due invoices whether they are paid or not. <br>- It is based on the validation date of these invoices.<br>
RulesCAIn=- It includes all the effective payments of invoices received from clients.<br>- It is based on the payment date of these invoices<br> RulesCAIn=- It includes all the effective payments of invoices received from clients.<br>- It is based on the payment date of these invoices<br>
RulesAmountOnInOutBookkeepingRecord=It includes record in your Ledger with accounting accounts that has the group "EXPENSE" or "INCOME" (See <b>%s</b>)
RulesResultBookkeepingPredefined=It includes record in your Ledger with accounting accounts that has the group "EXPENSE" or "INCOME" (See <b>%s</b>)
RulesResultBookkeepingPersonalized=It show record in your Ledger with accounting accounts <b>grouped by personalized groups</b> (See menu <b>%s</b> to define accounting account groups)
DepositsAreNotIncluded=- Down payment invoices are nor included DepositsAreNotIncluded=- Down payment invoices are nor included
DepositsAreIncluded=- Down payment invoices are included DepositsAreIncluded=- Down payment invoices are included
LT2ReportByCustomersInInputOutputModeES=Report by third party IRPF LT2ReportByCustomersInInputOutputModeES=Report by third party IRPF
@ -227,3 +231,4 @@ ImportDataset_tax_vat=Vat payments
ErrorBankAccountNotFound=Error: Bank account not found ErrorBankAccountNotFound=Error: Bank account not found
FiscalPeriod=Accounting period FiscalPeriod=Accounting period
ListSocialContributionAssociatedProject=List of social contributions associated with the project ListSocialContributionAssociatedProject=List of social contributions associated with the project
DeleteFromCat=Remove from accounting group

View File

@ -69,6 +69,7 @@ class MyObject extends CommonObject
* 'position' is the sort order of field. * 'position' is the sort order of field.
* 'searchall' is 1 if we want to search in this field when making a search from the quick search button. * 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
* 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
* 'help' is a string visible as a tooltip on field
* 'comment' is not used. You can store here any text of your choice. * 'comment' is not used. You can store here any text of your choice.
*/ */
@ -81,7 +82,7 @@ class MyObject extends CommonObject
'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'),
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'index'=>1, 'position'=>20), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'index'=>1, 'position'=>20),
'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1), 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1),
'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'searchall'=>0, 'isameasure'=>1), 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Amount'),
'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>1, 'position'=>1000), 'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>1, 'position'=>1000),
'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500),
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500),