new flags, ignore htdocs/images/banana
[platal.git] / htdocs / trezo / index.php
1 <?php
2 /***************************************************************************
3 * Copyright (C) 2003-2006 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
18 * Foundation, Inc., *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
21
22 require_once("xorg.inc.php");
23 require_once("money/trezo.inc.php");
24 new_skinned_page('trezo/index.tpl', AUTH_COOKIE);
25
26 //Table operations :
27 //+--------+---------------+------+-----+------------+----------------+
28 //| Field | Type | Null | Key | Default | Extra |
29 //+--------+---------------+------+-----+------------+----------------+
30 //| id | int(11) | | PRI | NULL | auto_increment |
31 //| date | date | | | 0000-00-00 | |
32 //| label | varchar(80) | | | | |
33 //| credit | decimal(10,2) | | | 0.00 | |
34 //| debit | decimal(10,2) | | | 0.00 | |
35 //+--------+---------------+------+-----+------------+----------------+
36
37 $annee_sel = isset($_REQUEST['annee']) ? $_REQUEST['annee'] : date("Y");
38 $mois_sel = isset($_REQUEST['mois']) ? $_REQUEST['mois'] : sprintf("%02u", date('m') - (intval(date('m')-1)%3));
39
40 $mois_sel_fin = sprintf("%02u",$mois_sel + 2);
41 $from_date = "$annee_sel-$mois_sel-01";
42 $to_date = "$annee_sel-$mois_sel_fin-31";
43 $mon_sel = $trim_fr[$mois_sel]." $annee_sel";
44
45 $page->assign('from_solde', solde_until($from_date));
46 $page->assign('to_solde', solde_until($to_date));
47 $page->assign('annee_sel', $annee_sel);
48 $page->assign('mois_sel', $mois_sel);
49 $page->assign('mon_sel', $mon_sel);
50 $page->assign_by_ref('month_arr', $trim_fr);
51
52 $page->assign('ops', $globals->xdb->iterator(
53 "SELECT date,label,credit,debit FROM money_trezo WHERE date >= {?} and date <= {?} ORDER BY date",
54 $from_date, $to_date));
55
56 $page->run();
57 ?>