function date_params($_GET) { $filter['end_date'] = ""; $filter['start_date'] = ""; $ts_start_date = ""; $ts_end_date = ""; extract($_GET); // If no date range is specified use "current month" $days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); if (strftime("%Y") % 4 == 0 && strftime("%Y") % 100 != 0) { // Leap year $days_in_month[1] = 29; } if (isset($filter) && $filter['start_date'] != "" && $filter['end_date'] == "") { // If start_date is given and NOT end_date then we show transaction between // start_date and current date. $filter['end_date'] = strftime("%d/%m/%Y"); } if (isset($filter) && $filter['start_date'] == "" && $filter['end_date'] != "") { // If end_date is given and NOT start_date then we show transaction from the // start of the company to end_date $result = WFO::SQL("SELECT value FROM webfinance_pref WHERE type_pref='societe' AND owner=-1"); list($value) = mysql_fetch_array($result); mysql_free_result($result); $company = unserialize(base64_decode($value)); $filter['start_date'] = $company->date_creation; } if (isset($filter) && $filter['start_date'] == "") { $filter['start_date'] = strftime("01/%m/%Y"); } if ($filter['end_date'] == "") { $filter['end_date'] = strftime($days_in_month[strftime("%m") - 1] . "/%m/%Y"); } preg_match("!([0-9]{2})/([0-9]{2})/([0-9]{4})!", $filter['start_date'], $foo); $ts_start_date = mktime(0, 0, 0, $foo['2'], $foo['1'], $foo['3']); preg_match("!([0-9]{2})/([0-9]{2})/([0-9]{4})!", $filter['end_date'], $foo); $ts_end_date = mktime(0, 0, 0, $foo['2'], $foo['1'], $foo['3']); // end date must be after begin date. If not reverse them if ($ts_start_date > $ts_end_date) { // Reverse : switch timestamps and formated dates $foo = $filter['start_date']; $filter['start_date'] = $filter['end_date']; $filter['end_date'] = $foo; $foo = $ts_start_date; $ts_start_date = $ts_end_date; $ts_end_date = $foo; } return array($ts_start_date, $ts_end_date, $filter['start_date'], $filter['end_date']); }
} mysql_free_result($result); ?> </select> </div> <div id="action_change_category" style="display: none;"> <div style="display: block; float: left; width: 90px;"><?php echo _('Category is'); ?> </div> <select name="action[id_category]"> <option value="1"><?php echo _('-- Choose --'); ?> </option> <?php $result = WFO::SQL("SELECT id,name,color FROM webfinance_categories ORDER BY name"); while ($cat = mysql_fetch_object($result)) { printf('<option value="%d">%s</option>', $cat->id, $cat->name); } mysql_free_result($result); ?> </select> </div> </td> </tr> <tr class="row_even"> <td colspan="2" style="text-align: center"><input type="button" onclick="submitAction(this.form);" value="<?php echo _('Apply this action'); ?> " /></td> </tr>