require_once("xorg.inc.php");
new_skinned_page('paiment/index.tpl', AUTH_MDP);
require_once('profil.func.inc.php');
-require_once("money.inc.php");
+require_once('money.inc.php');
// initialisation
$op = isset($_REQUEST['op']) ? $_REQUEST['op'] : 'select';
$page->assign('meth', $meth);
$page->assign('pay', $pay);
-$page->assign('prefix',$globals->money->table_prefix);
+$page->assign('prefix',$globals->money->mpay_tprefix);
$page->run();
?>
***************************************************************************/
require_once('xorg.inc.php');
-require_once("trezo.inc.php");
+require_once("money/trezo.inc.php");
new_admin_page('trezo/gere_operations.tpl');
//Table operations :
//+--------+---------------+------+-----+------------+----------------+
$action = clean_request('action');
-$annee_sel = clean_request('annee');
-$mois_sel = clean_request('mois');
$operation_id = clean_request('operation_id');
$operation_date = clean_request('operation_date');
$operation_label = clean_request('operation_label');
$operation_credit = clean_request('operation_credit');
$operation_debit = clean_request('operation_debit');
-//selection mois et date
-if (!$annee_sel) $annee_sel = date("Y");
-
-if ($mois_sel) {
- $from_date = $annee_sel."-".$mois_sel."-01";
- $to_date = $annee_sel."-".$mois_sel."-31";
- $mon_sel = $mois_fr[$mois_sel]." ".$annee_sel;
-} else {
- $from_date = date("Y-m")."-01";
- $to_date = date("Y-m")."-31";
- $mon_sel = $mois_fr[date("m")]." ".date("Y");
-}
+$annee_sel = isset($_REQUEST['annee']) ? $_REQUEST['annee'] : date("Y");
+$mois_sel = isset($_REQUEST['mois']) ? $_REQUEST['mois'] : sprintf("%02u", date('m'));
+
+$from_date = "$annee_sel-$mois_sel-01";
+$to_date = "$annee_sel-$mois_sel-31";
+$mon_sel = $trim_fr[$mois_sel]." $annee_sel";
switch($action) {
case "edit":
if ($operation_id) {
- $res=$globals->db->query("select date,label,credit,debit from trezo.operations where id='$operation_id'");
+ $res=$globals->db->query("select date,label,credit,debit from money_trezo where id='$operation_id'");
list($operation_date,$operation_label,$operation_credit,$operation_debit)=mysql_fetch_row($res);
}
break;
}
if ($operation_id) {
- $sql = "update trezo.operations set date='".$mydate."',label='".$operation_label."'".$sql_add." where id='".$operation_id."'";
+ $sql = "update money_trezo set date='".$mydate."',label='".$operation_label."'".$sql_add." where id='".$operation_id."'";
} else {
- $sql = "insert into trezo.operations set date='".$mydate."',label='".$operation_label."'".$sql_add;
+ $sql = "insert into money_trezo set date='".$mydate."',label='".$operation_label."'".$sql_add;
}
break;
case "del":
if ($operation_id) {
- $globals->db->query("delete from trezo.operations where id='".$operation_id."'");
+ $globals->db->query("delete from money_trezo where id='".$operation_id."'");
}
break;
$page->assign_by_ref('month_arr', $mois_fr);
$sql = "SELECT id,date,label,credit,debit
- FROM trezo.operations
+ FROM money_trezo
WHERE date >= '$from_date' AND date <= '$to_date'
ORDER BY date";
$page->mysql_assign($sql, 'ops');
***************************************************************************/
require_once("xorg.inc.php");
-require_once("trezo.inc.php");
+require_once("money/trezo.inc.php");
new_admin_page('trezo/index.tpl');
//Table operations :
//| debit | decimal(10,2) | | | 0.00 | |
//+--------+---------------+------+-----+------------+----------------+
-$annee_sel = clean_request('annee');
-$mois_sel = clean_request('mois');
+$annee_sel = isset($_REQUEST['annee']) ? $_REQUEST['annee'] : date("Y");
+$mois_sel = isset($_REQUEST['mois']) ? $_REQUEST['mois'] : sprintf("%02u", date('m') - (intval(date('m')-1)%3));
-if(isset($_REQUEST['action']) && $_REQUEST['action']=='lister') {
- if (!$annee_sel)
- $annee_sel = date("Y");
- $mois_sel_fin = sprintf("%02u",$mois_sel + 2);
-
- $from_date = $annee_sel."-".$mois_sel."-01";
- $to_date = $annee_sel."-".$mois_sel_fin."-31";
- $mon_sel = $trim_fr[$mois_sel]." ".$annee_sel;
-} else {
- $mois_sel = sprintf("%02u", date("m") - (date("m")%3) + 1);
- $mois_sel_fin = sprintf("%02u",$mois_sel + 2);
-
- $from_date = date("Y")."-".$mois_sel."-01";
- $to_date = date("Y")."-".$mois_sel_fin."-31";
- $mon_sel = $trim_fr[$mois_sel]." ".date("Y");
-}
+$mois_sel_fin = sprintf("%02u",$mois_sel + 2);
+$from_date = "$annee_sel-$mois_sel-01";
+$to_date = "$annee_sel-$mois_sel_fin-31";
+$mon_sel = $trim_fr[$mois_sel]." $annee_sel";
$page->assign('from_solde', solde_until($from_date));
$page->assign('to_solde', solde_until($to_date));
+$page->assign('annee_sel', $annee_sel);
+$page->assign('mois_sel', $mois_sel);
$page->assign('mon_sel', $mon_sel);
$page->assign_by_ref('month_arr', $trim_fr);
-$sql = "SELECT date,label,credit,debit FROM trezo.operations
+$sql = "SELECT date,label,credit,debit FROM money_trezo
WHERE date >= '$from_date' and date <= '$to_date'
ORDER BY date";
$page->mysql_assign($sql,'ops');
// }}}
-$this->banana = new BananaConfig;
+$globals->banana = new BananaConfig;
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
?>
// }}}
-$this->lists = new ListsConfig;
+$globals->lists = new ListsConfig;
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
?>
// }}}
-$this->mail = new MailConfig;
+$globals->mail = new MailConfig;
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
?>
class MoneyConfig
{
- var $payment_def = 0;
- var $method_def = 0;
- var $table_prefix = 'paiement.';
+ var $mpay_enable = true;
+ var $mpay_def_id = 0;
+ var $mpay_def_meth = 0;
+ var $mpay_tprefix = 'paiement.';
}
// }}}
-$this->money = new MoneyConfig;
+$globals->money = new MoneyConfig;
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
?>
<?php
-$this->addPrivateEntry(XOM_SERVICES, 30, 'Micropaiments', 'paiement/');
+if ($globals->money->mpay_enable) {
+ $this->addPrivateEntry(XOM_SERVICES, 30, 'Micropaiments', 'paiement/');
+}
?>
// }}}
-$this->newsletter = new NLConfig;
+$globals->newsletter = new NLConfig;
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
?>
// }}}
-$this->search = new SearchConfig;
+$globals->search = new SearchConfig;
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
?>
// }}}
-$this->skin = new SkinConfig;
+$globals->skin = new SkinConfig;
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
?>
// }}}
-$this->webredirect = new WebRedirConfig;
+$globals->webredirect = new WebRedirConfig;
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
?>
function Payment($ref=-1)
{
global $globals;
- $r = $ref==-1 ? $globals->money->payment_def : $ref;
+ $r = $ref==-1 ? $globals->money->mpay_def_id : $ref;
$res = $globals->db->query("SELECT id, text, url, flags, mail, montant_min, montant_max, montant_def
- FROM {$globals->money->table_prefix}paiements WHERE id='$r'");
+ FROM {$globals->money->mpay_tprefix}paiements WHERE id='$r'");
list($this->id, $this->text, $this->url, $flags, $this->mail,
$this->montant_min, $this->montant_max, $this->montant_def)
= mysql_fetch_row($res);
function PayMethod($id=-1)
{
global $globals;
- $i = $id==-1 ? $globals->money->method_def : $id;
- $res = $globals->db->query("SELECT id,text,include FROM {$globals->money->table_prefix}methodes WHERE id='$i'");
+ $i = $id==-1 ? $globals->money->mpay_def_meth : $id;
+ $res = $globals->db->query("SELECT id,text,include FROM {$globals->money->mpay_tprefix}methodes WHERE id='$i'");
list($this->id, $this->text, $this->inc) = mysql_fetch_row($res);
mysql_free_result($res);
}
function solde_until($date='')
{
global $globals;
- $sql = "select sum(credit)-sum(debit) from trezo.operations";
+ $sql = "select sum(credit)-sum(debit) from money_trezo";
if(!empty($date))
$sql .= " where date <= '$date'";
$res = $globals->db->query($sql);
}
?>
-
var $spoolroot = "/var/spool/xorg";
var $root = null;
- function XorgGlobals() {
- $this->root = dirname(dirname(__FILE__));
+ function init()
+ {
+ global $globals;
+ require_once("xorg/menu.inc.php");
+ require_once('xorg/session.inc.php');
- foreach(glob($this->root.'/include/conf.d/*.globals.inc.php') as $inc) {
+ $globals = new XorgGlobals;
+
+ $globals->root = dirname(dirname(__FILE__));
+
+ foreach(glob($globals->root.'/include/conf.d/*.globals.inc.php') as $inc) {
require_once($inc);
}
- $array = parse_ini_file($this->root.'/configs/platal.conf', true);
+ $array = parse_ini_file($globals->root.'/configs/platal.conf', true);
if (!is_array($array)) {
return;
}
foreach ($array as $cat=>$conf) {
$c = strtolower($cat);
foreach ($conf as $key=>$val) {
- if ($c == 'core' && isset($this->$key)) {
- $this->$key=$val;
+ if ($c == 'core' && isset($globals->$key)) {
+ $globals->$key=$val;
} else {
- $this->$c->$key = $val;
+ $globals->$c->$key = $val;
}
}
}
- $this->menu = new XOrgMenu($this->root.'/include/conf.d/');
+ $globals->menu = new XOrgMenu($globals->root.'/include/conf.d/');
session_start();
- $this->dbconnect();
- if ($this->debug) {
- $this->db->trace_on();
+ $globals->dbconnect();
+ if ($globals->debug) {
+ $globals->db->trace_on();
}
}
}
// {{{ import class definitions
require_once("xorg.globals.inc.php");
-require_once("xorg/menu.inc.php");
-require_once("xorg/session.inc.php");
-
-$globals = new XorgGlobals;
+XorgGlobals::init();
// }}}
// {{{ function _new_page()
--- /dev/null
+
+ Notes for the money module for plat/al
+
+STATUS
+------
+
+TODO:
+ tables are atm in paiments.* and we should put it in x4dat.money_*
+ we have to wait for x.net here.
+
+CONFIG OPTIONS
+--------------
+
+ All settings of the module are shown here with their default and meaning
+
+ [Money]
+
+ mpay_enable = 1 ; enable micro-payments
+ mpay_def_id = 0 ; id of the default micro-payment id
+ mpay_def_meth = 0 ; id of the default payment method
+ mpay_tprefix = paiments.
+ ; obsolete when TODO will be closed
+
+
+BUGS
+----
+
+ http://trackers.polytechnique.org/index.php?cat=16
+
+
+DEPENDS
+-------
+
+ platal
+
--- /dev/null
+INSERT INTO `admin_h2` VALUES (2,9,'Trésorerie',60);
+
+INSERT INTO `admin_a` VALUES (9,'Comptes','admin/gere_operations.php',0);
+INSERT INTO `admin_a` VALUES (9,'Paiements','admin/gerer_paiement.php',10);
+
--- /dev/null
+
+delete from admin_h2 where h2id=9;
+delete from admin_a where h2id=9;
+
***************************************************************************}
-{assign var=def_month value=$smarty.now|date_format:"%m"}
-{assign var=def_year value=$smarty.now|date_format:"%Y"}
-{assign var=month value=$smarty.request.mois|default:$def_month}
-
<form method="post" action="{$smarty.server.PHP_SELF}">
<div class="center">
<input type="hidden" name="action" value="lister" />
Afficher la période suivante :
<select name="mois" size="1">
{foreach key=key item=item from=$month_arr}
- <option value="{$key}" {if $month eq $key}selected="selected"{/if}>{$item}</option>
+ <option value="{$key}" {if $mois_sel eq $key}selected="selected"{/if}>{$item}</option>
{/foreach}
</select>
- <input type="text" name="annee" size="10" value="{$smarty.request.annee|default:$def_year}" />
+ <input type="text" name="annee" size="10" value="{$smarty.request.annee|default:$annee_sel}" />
<input type="submit" value="lister" />
</div>
</form>
{dynamic}
-<h1>
- Trésorerie pour {$mon_sel}
-</h1>
+<h1>Trésorerie pour {$mon_sel}</h1>
+
+{perms level=admin}
+<p>[<a href="{rel}/trezo/gere_operations.php">éditer les comptes</a>]</p>
+{/perms}
<table class="bicol">
<tr>
- <th>Solde en début de mois</th>
+ <th>Solde en début de période</th>
</tr>
<tr>
<td class="right">{$from_solde}</td>
insert into admin_a values(8, 'Valider', 'admin/valider.php', 0);
insert into admin_a values(8, 'Événements', 'admin/evenements.php', 10);
-insert into admin_a values(9, 'Comptes', 'admin/gere_operations.php', 0);
+insert into admin_a values(9, 'Comptes', 'trezo/gere_operations.php', 0);
insert into admin_a values(9, 'Paiements', 'admin/gerer_paiement.php', 10);
insert into admin_a values(10, 'Table auth_user_md5', 'admin/FormatePrenomNOM.php', 0);
--- /dev/null
+-- MySQL dump 9.11
+--
+-- Host: localhost Database: trezo
+-- ------------------------------------------------------
+-- Server version 4.0.22-log
+
+--
+-- Table structure for table `operations`
+--
+
+CREATE TABLE `money_trezo` (
+ `id` int(11) NOT NULL auto_increment,
+ `date` date NOT NULL default '0000-00-00',
+ `label` varchar(80) NOT NULL default '',
+ `credit` decimal(10,2) NOT NULL default '0.00',
+ `debit` decimal(10,2) NOT NULL default '0.00',
+ PRIMARY KEY (`id`)
+) TYPE=MyISAM COMMENT='Table des comptes de l''assoce';
+
+insert into money_trezo
+ select * from trezo.operations;
+
+drop table trezo.operations;
+drop database trezo;
+