bf13fdf78477cf9c47545133840f24bbfea4d39f
2 /***************************************************************************
3 * Copyright (C) 2003-2004 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
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. *
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. *
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 *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 require_once('xorg.inc.php');
23 require_once("money/trezo.inc.php");
24 new_admin_page('trezo/gere_operations.tpl');
25 $page->assign('xorg_title','Polytechnique.org - Administration - Trezo : gestion');
27 $action = clean_request('action');
28 $op_id = clean_request('op_id');
29 $op_date = clean_request('op_date');
30 $op_label = clean_request('op_label');
31 $op_credit = clean_request('op_credit');
32 $op_debit = clean_request('op_debit');
34 $annee_sel = isset($_REQUEST['annee']) ?
$_REQUEST['annee'] : date("Y");
35 $mois_sel = isset($_REQUEST['mois']) ?
$_REQUEST['mois'] : sprintf("%02u", date('m'));
37 $from_date = "$annee_sel-$mois_sel-01";
38 $to_date = "$annee_sel-$mois_sel-31";
39 $mon_sel = $trim_fr[$mois_sel]." $annee_sel";
44 $res = $globals->xdb
->query("SELECT date,label,credit,debit FROM money_trezo WHERE id={?}", $op_id);
45 list($op_date,$op_label,$op_credit,$op_debit) = $res->fetchOneRow();
50 if (isDate($op_date)){
51 $mydatefr = explode("/",$op_date);
52 $mydate = $mydatefr[2]."-".$mydatefr[1]."-".$mydatefr[0];
54 $mydate = date("Y-m-d");
57 $sql = "replace into money_trezo set date='$mydate',label='".addslashes($op_label)."'";
59 if ($op_credit) { $sql .= ',credit='.$op_credit; }
60 if ($op_debit) { $sql .= ",debit=".$op_debit; }
61 if ($op_id) { $sql .= ",id='$op_id'"; }
63 $globals->xdb
->execute($sql);
68 $globals->xdb
->execute("DELETE FROM money_trezo WHERE id={?}", $op_id);
73 $page->assign('op_id', $op_id);
74 $page->assign('annee_sel', $annee_sel);
75 $page->assign('mois_sel', $mois_sel);
76 $page->assign('op_date', $op_date);
77 $page->assign('op_label', $op_label);
78 $page->assign('op_debit', $op_debit);
79 $page->assign('op_credit', $op_credit);
80 $page->assign('mon_sel', $mon_sel);
82 $page->assign('from_solde', solde_until($from_date));
83 $page->assign('to_solde', solde_until($to_date));
84 $page->assign('month_arr', $mois_fr);
85 $page->assign('ops', $globals->xdb
->iterator(
86 "SELECT id,date,label,credit,debit FROM money_trezo WHERE date >= {?} and date <= {?} ORDER BY date",
87 $from_date, $to_date));