diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 965c3dea5ac..42328fbc1ed 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -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.= ''; -$groupby = ' ' . $langs->trans("GroupByAccountAccounting") . ''; +$groupby = ' ' . $langs->trans("GroupByAccountAccounting") . ''; $addbutton = '' . $langs->trans("NewAccountingMvt") . ''; 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 ''; while ($i < $totalarray['nbfield']) { $i++; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 08aa1aac19d..c450fb5bb63 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -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 '
'; -$viewflat = ' ' . $langs->trans("ViewFlatList") . ''; +$viewflat = ' ' . $langs->trans("ViewFlatList") . ''; $addbutton = '' . $langs->trans("NewAccountingMvt") . ''; -$param=$options; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 248b9177d85..cecfbe1ed49 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -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)