diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index e6697557775..15e7acd7deb 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -70,7 +70,8 @@ $form = new Form($db); if (empty($search_date_start) && ! GETPOSTISSET('formfilteraction')) { $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; - $sql .= " where date_start < now() and date_end > now() limit 1"; + $sql.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'"; + $sql.= $db->plimit(1); $res = $db->query($sql); if ($res->num_rows > 0) { $fiscalYear = $db->fetch_object($res); diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index c4be9d99181..08aa1aac19d 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -47,13 +47,11 @@ $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST( $search_accountancy_code = GETPOST("search_accountancy_code"); - $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); if ($search_accountancy_code_start == - 1) { $search_accountancy_code_start = ''; } $search_label_account = GETPOST('search_label_account', 'alpha'); - $search_mvt_label = GETPOST('search_mvt_label', 'alpha'); $search_direction = GETPOST('search_direction', 'alpha'); $search_ledger_code = GETPOST('search_ledger_code', 'alpha'); @@ -72,8 +70,10 @@ if ($sortfield == "") $sortfield = "t.rowid"; if (empty($search_date_start)) { $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; - $sql .= " where date_start < now() and date_end > now() limit 1"; + $sql.= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'"; + $sql.= $db->plimit(1); $res = $db->query($sql); + if ($res->num_rows > 0) { $fiscalYear = $db->fetch_object($res); $search_date_start = strtotime($fiscalYear->date_start); @@ -90,8 +90,6 @@ if (empty($search_date_start)) { } $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, 1, 1, dol_print_date(dol_now(), '%Y')); - $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y')); } } @@ -103,39 +101,38 @@ $filter = array (); if (! empty($search_date_start)) { $filter['t.doc_date>='] = $search_date_start; - $options .= '&date_startmonth=' . GETPOST('date_startmonth', 'int') . '&date_startday=' . GETPOST('date_startday', 'int') . '&date_startyear=' . GETPOST('date_startyear', 'int'); + $options .= '&date_startmonth=' . GETPOST('date_startmonth', 'int') . '&date_startday=' . GETPOST('date_startday', 'int') . '&date_startyear=' . GETPOST('date_startyear', 'int'); } if (! empty($search_date_end)) { $filter['t.doc_date<='] = $search_date_end; - $options .= '&date_endmonth=' . GETPOST('date_endmonth', 'int') . '&date_endday=' . GETPOST('date_endday', 'int') . '&date_endyear=' . GETPOST('date_endyear', 'int'); + $options .= '&date_endmonth=' . GETPOST('date_endmonth', 'int') . '&date_endday=' . GETPOST('date_endday', 'int') . '&date_endyear=' . GETPOST('date_endyear', 'int'); } if (! empty($search_doc_date)) { $filter['t.doc_date'] = $search_doc_date; - $options .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int'); + $options .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int'); } - if (! GETPOST('button_removefilter_x','alpha') && ! GETPOST('button_removefilter.x','alpha') && ! GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { if (! empty($search_accountancy_code_start)) { $filter['t.numero_compte'] = $search_accountancy_code_start; - $options .= '&search_accountancy_code_start=' . $search_accountancy_code_start; + $options .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); } if (! empty($search_label_account)) { $filter['t.label_operation'] = $search_label_account; - $options .= '&search_label_account=' . $search_label_account; + $options .= '&search_label_account=' . urlencode($search_label_account); } if (! empty($search_mvt_label)) { $filter['t.label_operation'] = $search_mvt_label; - $options .= '&search_mvt_label=' . $search_mvt_label; + $options .= '&search_mvt_label=' . urlencode($search_mvt_label); } if (! empty($search_direction)) { $filter['t.sens'] = $search_direction; - $options .= '&search_direction=' . $search_direction; + $options .= '&search_direction=' . urlencode($search_direction); } if (! empty($search_ledger_code)) { $filter['t.code_journal'] = $search_ledger_code; - $options .= '&search_ledger_code=' . $search_ledger_code; + $options .= '&search_ledger_code=' . urlencode($search_ledger_code); } } @@ -182,6 +179,7 @@ $title_page = $langs->trans("Bookkeeping") . ' ' . strtolower($langs->trans("By" llxHeader('', $title_page); + // List $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -192,6 +190,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { } $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter); + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -233,7 +232,11 @@ print '