diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index ca98431a16e..c3dd606adb2 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -112,7 +112,7 @@ $arrayfields=array(
't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1),
't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
't.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1),
- 't.crebit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1),
+ 't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1),
't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1),
't.date_creation'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0),
);
@@ -410,11 +410,11 @@ print '
';
if (! empty($arrayfields['t.piece_num']['checked']))
{
print ' | ';
- print '';
}
// Date document
if (! empty($arrayfields['t.doc_date']['checked']))
{
+ print ' | ';
print '';
print $langs->trans('From') . ' ';
print $form->select_date($search_date_start, 'date_start', 0, 0, 1);
@@ -501,6 +501,7 @@ if (! empty($arrayfields['t.code_journal']['checked']))
// Date creation
if (! empty($arrayfields['t.date_creation']['checked']))
{
+ print ' ';
print ' ';
print $langs->trans('From') . ' ';
print $form->select_date($search_date_creation_start, 'date_creation_start', 0, 0, 1);
@@ -511,6 +512,7 @@ if (! empty($arrayfields['t.date_creation']['checked']))
print ' ';
print ' | ';
}
+// Action column
print ' ';
$searchpicto=$form->showFilterButtons();
print $searchpicto;
@@ -532,59 +534,129 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="c
print " | |
\n";
-$total_debit = 0;
-$total_credit = 0;
-
-$i=0;
-while ($i < min($num, $limit))
+if ($num > 0)
{
- $line = $object->lines[$i];
-
- $total_debit += $line->debit;
- $total_credit += $line->credit;
-
- print '';
-
- print '| ' . $line->piece_num . ' | ';
- print '' . dol_print_date($line->doc_date, 'day') . ' | ';
- print '' . $line->doc_ref . ' | ';
- print '' . length_accountg($line->numero_compte) . ' | ';
- print '' . length_accounta($line->subledger_account) . ' | ';
- print '' . $line->label_operation . ' | ';
- print '' . ($line->debit ? price($line->debit) : ''). ' | ';
- print '' . ($line->credit ? price($line->credit) : '') . ' | ';
-
- $accountingjournal = new AccountingJournal($db);
- $result = $accountingjournal->fetch('',$line->code_journal);
- $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0,0,0,'',0) : $line->code_journal);
- print '' . $journaltoshow . ' | ';
- if (! empty($arrayfields['t.date_creation']['checked']))
+ $i=0;
+ $totalarray=array();
+ while ($i < min($num, $limit))
{
- print '' . dol_print_date($line->date_creation, 'day') . ' | ';
+ $line = $object->lines[$i];
+
+ $total_debit += $line->debit;
+ $total_credit += $line->credit;
+
+ print '
';
+
+ // Piece number
+ if (! empty($arrayfields['t.piece_num']['checked']))
+ {
+ print '| ' . $line->piece_num . ' | ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+
+ // Document date
+ if (! empty($arrayfields['t.doc_date']['checked']))
+ {
+ print '' . dol_print_date($line->doc_date, 'day') . ' | ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+
+ // Document ref
+ if (! empty($arrayfields['t.doc_ref']['checked']))
+ {
+ print '' . $line->doc_ref . ' | ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+
+ // Account number
+ if (! empty($arrayfields['t.numero_compte']['checked']))
+ {
+ print '' . length_accountg($line->numero_compte) . ' | ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+
+ // Subledger account
+ if (! empty($arrayfields['t.subledger_account']['checked']))
+ {
+ print '' . length_accounta($line->subledger_account) . ' | ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+
+ // Label operation
+ if (! empty($arrayfields['t.label_operation']['checked']))
+ {
+ print '' . $line->label_operation . ' | ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+
+ // Amount debit
+ if (! empty($arrayfields['t.debit']['checked']))
+ {
+ print '' . ($line->debit ? price($line->debit) : ''). ' | ';
+ if (! $i) $totalarray['nbfield']++;
+ if (! $i) $totalarray['totaldebitfield']=$totalarray['nbfield'];
+ $totalarray['totaldebit'] += $line->debit;
+ }
+
+ // Amount credit
+ if (! empty($arrayfields['t.credit']['checked']))
+ {
+ print '' . ($line->credit ? price($line->credit) : '') . ' | ';
+ if (! $i) $totalarray['nbfield']++;
+ if (! $i) $totalarray['totalcreditfield']=$totalarray['nbfield'];
+ $totalarray['totalcredit'] += $line->credit;
+ }
+
+ // Journal code
+ if (! empty($arrayfields['t.code_journal']['checked']))
+ {
+ $accountingjournal = new AccountingJournal($db);
+ $result = $accountingjournal->fetch('',$line->code_journal);
+ $journaltoshow = (($result > 0)?$accountingjournal->getNomUrl(0,0,0,'',0) : $line->code_journal);
+ print '' . $journaltoshow . ' | ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+
+ // Creation operation date
+ if (! empty($arrayfields['t.date_creation']['checked']))
+ {
+ print '' . dol_print_date($line->date_creation, 'day') . ' | ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+
+ // Action column
+ print '';
+ print '' . img_edit() . ' ';
+ print '' . img_delete() . '';
+ print ' | ';
+ if (! $i) $totalarray['nbfield']++;
+
+ print "
\n";
+
+ $i++;
}
- print '';
- print '' . img_edit() . ' ';
- print '' . img_delete() . '';
- print ' | ';
- print "\n";
+ // Show total line
+ if (isset($totalarray['totaldebitfield']) || isset($totalarray['totalcreditfield']))
+ {
+ $i=0;
+ while ($i < $totalarray['nbfield'])
+ {
+ $i++;
+ if ($i == 1)
+ {
+ if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").' | ';
+ else print ''.$langs->trans("Totalforthispage").' | ';
+ }
+ elseif ($totalarray['totaldebitfield'] == $i) print ''.price($totalarray['totaldebit']).' | ';
+ elseif ($totalarray['totalcreditfield'] == $i) print ''.price($totalarray['totalcredit']).' | ';
+ else print ' | ';
+ }
+ print '';
- $i++;
+ }
}
-print '';
-if ($num < $limit) print '| '.$langs->trans("Total").' | ';
-else print ''.$langs->trans("Totalforthispage").' | ';
-print '';
-print '';
-print price($total_debit);
-print ' | ';
-print '';
-print price($total_credit);
-print ' | ';
-print ' | ';
-print '
';
-
print "";
print '';
diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php
index cf35a3d8fff..2f5e1a6bbd7 100644
--- a/htdocs/accountancy/class/bookkeeping.class.php
+++ b/htdocs/accountancy/class/bookkeeping.class.php
@@ -678,6 +678,8 @@ class BookKeeping extends CommonObject
$sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\'';
} elseif ($key == 't.label_operation') {
$sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\'';
+ } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') {
+ $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
} else {
$sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
}
@@ -798,6 +800,8 @@ class BookKeeping extends CommonObject
$sqlwhere[] = $key . '=' . $value;
} elseif ($key == 't.subledger_account' || $key == 't.numero_compte') {
$sqlwhere[] = $key . ' LIKE \'' . $this->db->escape($value) . '%\'';
+ } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') {
+ $sqlwhere[] = $key . '\'' . $this->db->idate($value) . '\'';
} else {
$sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
}