FIX labels into ledger are same that into screen

FIX pagination
FIX init of fiscal year
Fix tr balance
This commit is contained in:
Laurent Destailleur 2018-02-02 17:24:40 +01:00
parent a41847d084
commit fe1f276d85
3 changed files with 37 additions and 80 deletions

View File

@ -87,7 +87,7 @@ $offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if ($sortorder == "") $sortorder = "ASC";
if ($sortfield == "") $sortfield = "t.rowid";
if ($sortfield == "") $sortfield = "t.piece_num,t.rowid";
$object = new BookKeeping($db);
@ -98,25 +98,30 @@ $form = new Form($db);
if (! in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && GETPOST('page','int') == '' && ! GETPOST('noreset','int'))
{
$query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$query.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1";
$res = $db->query($query);
if ($res->num_rows > 0) {
$fiscalYear = $db->fetch_object($res);
$search_date_start = strtotime($fiscalYear->date_start);
$search_date_end = strtotime($fiscalYear->date_end);
} else {
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
$year_start = dol_print_date(dol_now(), '%Y');
$year_end = $year_start + 1;
$month_end = $month_start - 1;
if ($month_end < 1)
{
$month_end = 12;
$year_end--;
if (empty($search_date_start) && empty($search_date_end))
{
$query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$query.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1";
$res = $db->query($query);
if ($res->num_rows > 0) {
$fiscalYear = $db->fetch_object($res);
$search_date_start = strtotime($fiscalYear->date_start);
$search_date_end = strtotime($fiscalYear->date_end);
} else {
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
$year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
$year_end = $year_start + 1;
$month_end = $month_start - 1;
if ($month_end < 1)
{
$month_end = 12;
$year_end--;
}
$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
$search_date_end = dol_get_last_day($year_end, $month_end);
}
$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
$search_date_end = dol_get_last_day($year_end, $month_end);
}
}
@ -430,7 +435,7 @@ else $button.= $langs->trans("ExportList");
$button.= '</a>';
$groupby = ' <a class="nohover" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php"">' . $langs->trans("GroupByAccountAccounting") . '</a>';
$groupby = ' <a class="nohover" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param.'">' . $langs->trans("GroupByAccountAccounting") . '</a>';
$addbutton = '<a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a>';
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, $groupby.$addbutton, '', $limit);
@ -704,6 +709,7 @@ if ($num > 0)
if (isset($totalarray['totaldebitfield']) || isset($totalarray['totalcreditfield']))
{
$i=0;
print '<tr class="liste_total">';
while ($i < $totalarray['nbfield'])
{
$i++;

View File

@ -68,7 +68,7 @@ $pagenext = $page + 1;
if ($sortorder == "") $sortorder = "ASC";
if ($sortfield == "") $sortfield = "t.rowid";
if (empty($search_date_start)) {
if (empty($search_date_start) && empty($search_date_end)) {
$sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$sql.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'";
$sql.= $db->plimit(1);
@ -81,6 +81,7 @@ if (empty($search_date_start)) {
} else {
$month_start= ($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1);
$year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
$year_end = $year_start + 1;
$month_end = $month_start - 1;
if ($month_end < 1)
@ -225,14 +226,13 @@ if ($action == 'delbookkeepingyear') {
}
$param=$options;
print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
$viewflat = ' <a class="nohover" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php">' . $langs->trans("ViewFlatList") . '</a>';
$viewflat = ' <a class="nohover" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param.'">' . $langs->trans("ViewFlatList") . '</a>';
$addbutton = '<a class="butAction" href="./card.php?action=create">' . $langs->trans("NewAccountingMvt") . '</a>';
$param=$options;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);

View File

@ -402,7 +402,9 @@ if (! $error && $action == 'writebookkeeping') {
$now = dol_now();
$error = 0;
foreach ( $tabpay as $key => $val ) { // $key is rowid into llx_bank
foreach ( $tabpay as $key => $val ) // $key is rowid into llx_bank
{
$date = dol_print_date($db->jdate($val["date"]), 'day');
$ref = getSourceDocRef($val, $tabtype[$key]);
@ -450,31 +452,8 @@ if (! $error && $action == 'writebookkeeping') {
$bookkeeping->date_create = $now;
// No subledger_account value for the bank line but add a specific label_operation
if ($tabtype[$key] == 'payment') {
$bookkeeping->subledger_account = '';
$bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref;
} else if ($tabtype[$key] == 'payment_supplier') {
$bookkeeping->subledger_account = '';
$bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref;
} else if ($tabtype[$key] == 'payment_expensereport') {
$bookkeeping->subledger_account = '';
$bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref;
} else if ($tabtype[$key] == 'payment_salary') {
$bookkeeping->subledger_account = '';
$bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref;
} else if ($tabtype[$key] == 'payment_vat') {
$bookkeeping->subledger_account = '';
$bookkeeping->label_operation = $ref;
} else if ($tabtype[$key] == 'payment_donation') {
$bookkeeping->subledger_account = '';
$bookkeeping->label_operation = $ref;
} else if ($tabtype[$key] == 'payment_various') {
$bookkeeping->subledger_account = '';
$bookkeeping->label_operation = $ref;
} else if ($tabtype[$key] == 'unknown') {
// ???
$bookkeeping->subledger_account = '';
}
$bookkeeping->subledger_account = '';
$bookkeeping->label_operation = $reflabel;
$totaldebit += $bookkeeping->debit;
$totalcredit += $bookkeeping->credit;
@ -713,11 +692,6 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
$companystatic = new Client($db);
$userstatic = new User($db);
//var_dump($langs);exit;
// CSV header line
print '"' . $langs->trans("BankId").'"' . $sep;
print '"' . $langs->trans("Date") . '"' . $sep;
@ -732,35 +706,12 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
print "\n";
foreach ( $tabpay as $key => $val ) {
foreach ( $tabpay as $key => $val )
{
$date = dol_print_date($db->jdate($val["date"]), 'day');
$ref = getSourceDocRef($val, $tabtype[$key]);
// Third party (company or user)
if (! empty($tabcompany[$key]['id']))
{
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
}
else
{
$companystatic->id = 0;
$companystatic->name = '';
}
if (! empty($tabuser[$key]['id']))
{
$userstatic->id = $tabuser[$key]['id'];
$userstatic->lastname = $tabuser[$key]['lastname'];
$userstatic->firstname = $tabuser[$key]['firstname'];
}
else
{
$userstatic->id = 0;
$userstatic->lastname = '';
$userstatic->firstname = '';
}
// Bank
foreach ( $tabbq[$key] as $k => $mt ) {
if ($mt)