';
+ $moreforfilter .= $langs->trans('DateStart').': ';
+ $moreforfilter .= $form->selectDate($search_date_start ? $search_date_start : -1, 'date_start', 0, 0, 1, '', 1, 0);
+ $moreforfilter .= $langs->trans('DateEnd').': ';
+ $moreforfilter .= $form->selectDate($search_date_end ? $search_date_end : -1, 'date_end', 0, 0, 1, '', 1, 0);
+ $moreforfilter .= '
';
+
+ if (!empty($moreforfilter)) {
+ print '';
+ print $moreforfilter;
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+ print '
';
+ }
+
+ print '';
+
+ print '';
+ print '| ';
+ print $langs->trans('From');
+ print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, '');
+ print ' ';
+ print $langs->trans('to');
+ print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, '');
+ print ' | ';
+ print '';
+ $searchpicto = $form->showFilterAndCheckAddButtons(0);
+ print $searchpicto;
+ print ' | ';
+
+ print '
';
+
+ print '';
+ print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
+ print_liste_field_titre("Label", $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
+ print_liste_field_titre("Opening Balance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder);
+ print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder);
+ print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder);
+ print_liste_field_titre("Balance", $_SERVER["PHP_SELF"], "", $param, "", 'class="right"', $sortfield, $sortorder);
+ print_liste_field_titre('', $_SERVER["PHP_SELF"], "", $param, "", 'width="60" class="center"', $sortfield, $sortorder);
+ print "
\n";
+
+ $total_debit = 0;
+ $total_credit = 0;
+ $sous_total_debit = 0;
+ $sous_total_credit = 0;
+ $displayed_account = "";
+
+ $sql = "select t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance from ".MAIN_DB_PREFIX."accounting_bookkeeping as t where entity in (1) and t.doc_date < "
+ ."'".$db->idate($search_date_start)."' group by t.numero_compte";
+ $resql = $db->query($sql);
+ $nrows = $resql->num_rows;
+ $opening_balances = Array();
+ for($i = 0; $i < $nrows; $i++) {
+ $arr = $resql->fetch_array();
+ $opening_balances["'".$arr['numero_compte']."'"] = $arr['opening_balance'];
+ }
+
+ foreach ($object->lines as $line)
+ {
+ $link = '';
+ $total_debit += $line->debit;
+ $total_credit += $line->credit;
+ $description = $object->get_compte_desc($line->numero_compte); // Search description of the account
+ $root_account_description = $object->get_compte_racine($line->numero_compte);
+ if (empty($description)) {
+ $link = ''.img_edit_add().'';
+ }
+ print '';
+
+ // Permet d'afficher le compte comptable
+ if (empty($displayed_account) || $root_account_description != $displayed_account)
+ {
+ // Affiche un Sous-Total par compte comptable
+ if ($displayed_account != "") {
+ print '
| ' . $langs->trans("SubTotal") . ': | ' . price($sous_total_debit) . ' | ' . price($sous_total_credit) . ' | ' . price(price2num($sous_total_credit - $sous_total_debit)) . ' | ';
+ print " | \n";
+ print '
';
+ }
+
+ // Show first line of a break
+ print '';
+ print '| ' . $line->numero_compte . ($root_account_description ? ' - ' . $root_account_description : '') . ' | ';
+ print '
';
+
+ $displayed_account = $root_account_description;
+ $sous_total_debit = 0;
+ $sous_total_credit = 0;
+ }
+
+ // $object->get_compte_racine($line->numero_compte);
+
+ print ''.length_accountg($line->numero_compte).' | ';
+ print ''.$description.' | ';
+ print ''.price($opening_balances["'".$line->numero_compte."'"]).' | ';
+ print ''.price($line->debit).' | ';
+ print ''.price($line->credit).' | ';
+ print ''.price($line->debit - $line->credit).' | ';
+ print ''.$link;
+ print ' | ';
+ print "\n";
+
+ // Comptabilise le sous-total
+ $sous_total_debit += $line->debit;
+ $sous_total_credit += $line->credit;
+ }
+
+ print '| '.$langs->trans("SubTotal").': | '.price($sous_total_debit).' | '.price($sous_total_credit).' | '.price(price2num($sous_total_debit - $sous_total_credit)).' | ';
+ print " | \n";
+ print '
';
+
+ print '| '.$langs->trans("AccountBalance").': | '.price($total_debit).' | '.price($total_credit).' | '.price(price2num($total_debit - $total_credit)).' | ';
+ print " | \n";
+ print '
';
+
+ print "
";
+ print '