Module Budget : card
This commit is contained in:
parent
bafc38ef81
commit
3e80a02b9b
3 changed files with 162 additions and 8 deletions
|
|
@ -60,6 +60,10 @@ switch($p_action) {
|
|||
case 'hypo':
|
||||
$def=1;
|
||||
break;
|
||||
case 'fiche':
|
||||
$def=2;
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -86,6 +90,16 @@ if ( $p_action == "hypo" )
|
|||
{
|
||||
require_once("bud_hypo.inc.php");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------
|
||||
// p_action == fiche
|
||||
//-----------------------------------------------------
|
||||
if ( $p_action == "fiche" )
|
||||
{
|
||||
require_once("bud_card.inc.php");
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------
|
||||
// p_action ==
|
||||
//-----------------------------------------------------
|
||||
|
|
|
|||
112
include/bud_card.inc.php
Normal file
112
include/bud_card.inc.php
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* $Revision$ */
|
||||
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
|
||||
/*! \file
|
||||
* \brief Manage the card for the budget module
|
||||
*/
|
||||
require_once ('class_bud_card.php');
|
||||
require_once ('class_widget.php');
|
||||
|
||||
echo '<form method="get">';
|
||||
$wHypo=new widget("select","","bh_id");
|
||||
$wHypo->value=make_array($cn,"select bh_id,bh_name from bud_hypothese");
|
||||
echo $wHypo->IOValue();
|
||||
echo widget::submit('recherche','recherche');
|
||||
echo dossier::hidden();
|
||||
echo widget::hidden("p_action","fiche");
|
||||
echo '</form>';
|
||||
echo '<hr>';
|
||||
if ( ! isset($_REQUEST['bh_id'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
if ( isset($_POST['remove'])){
|
||||
$obj=new Bud_Card($cn);
|
||||
$obj->from_array($_POST);
|
||||
$obj->delete();
|
||||
}
|
||||
|
||||
if ( isset($_POST['add'])){
|
||||
$obj=new Bud_Card($cn);
|
||||
$obj->from_array($_POST);
|
||||
$obj->add();
|
||||
|
||||
}
|
||||
|
||||
if ( isset($_POST['update'])){
|
||||
$obj=new Bud_Card($cn);
|
||||
$obj->from_array($_POST);
|
||||
$obj->update();
|
||||
|
||||
}
|
||||
|
||||
$list=Bud_Card::get_list($cn,$_REQUEST['bh_id']);
|
||||
|
||||
echo '<div class="lmenu">';
|
||||
$str_dossier=dossier::get();
|
||||
$bc_id=(isset($_REQUEST['bc_id']))?$_REQUEST['bc_id']:-1;
|
||||
if (! empty ($list)) {
|
||||
$row=array();
|
||||
foreach ($list as $r ) {
|
||||
$row[]=array('?'.$str_dossier.'&p_action=fiche&sa=detail&bc_id='.$r->bc_id,
|
||||
$r->bc_name,
|
||||
$r->bc_description,
|
||||
$r->bc_id);
|
||||
|
||||
}
|
||||
echo ShowItem($row,'V','mtitle','mtitle',$bc_id);
|
||||
}
|
||||
echo widget::button_href('Ajout','?'.$str_dossier.'&sa=add&p_action=fiche');
|
||||
echo '</div>';
|
||||
|
||||
|
||||
$sa=( isset($_REQUEST['sa']))?$_REQUEST['sa']:'';
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Add
|
||||
//------------------------------------------------------------------------------
|
||||
if ( $sa == "add" ) {
|
||||
echo '<div class="u_redcontent">';
|
||||
$obj=new Bud_Card($cn);
|
||||
echo '<form method="post">';
|
||||
echo $obj->form();
|
||||
echo widget::submit_button('add','Ajout');
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Detail
|
||||
//------------------------------------------------------------------------------
|
||||
if ( $sa == "detail" ) {
|
||||
$obj=new Bud_Card($cn,$_GET['bc_id']);
|
||||
$obj->load();
|
||||
echo '<div class="u_redcontent">';
|
||||
echo '<form method="post">';
|
||||
echo $obj->form();
|
||||
echo widget::submit_button('remove','Effacer','onClick="return confirm(\'Vous confirmez cet effacement ?\')"');
|
||||
echo widget::submit_button('update','Mise à jour');
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +76,20 @@ class Bud_Card {
|
|||
ExecSqlParam($this->db,$sql,$array);
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
*\brief convert an array to an object, if a idx is not set then the
|
||||
* corresponding property will be null
|
||||
* \param $p_array array to convert
|
||||
*/
|
||||
function from_array($p_array) {
|
||||
if ( empty($p_array) ) return;
|
||||
foreach (array ('bc_id','bc_code','bc_description','bc_price_unit','bc_unit')
|
||||
as $key ){
|
||||
$this->$key=(isset($p_array[$key]))?$p_array[$key]:null;
|
||||
}
|
||||
if ( $this->bc_id == null )
|
||||
throw new Exception(__FILE__.":".__LINE__." bc ne peut pas etre nul");
|
||||
}
|
||||
function delete() {
|
||||
ExecSql($this->db,"delete from bud_card where bc_id=".$this->bc_id);
|
||||
}
|
||||
|
|
@ -84,22 +97,37 @@ class Bud_Card {
|
|||
function load()
|
||||
{
|
||||
if ( $this->bc_id == 0 ) return ;
|
||||
$sql="select bc_code,bc_description, bc_price_unit,bc_unit ".
|
||||
$sql="select bc_id,bc_code,bc_description, bc_price_unit,bc_unit ".
|
||||
" from bud_card ".
|
||||
" where ".
|
||||
" bh_id =".$this->bc_id;
|
||||
" bc_id =".$this->bc_id;
|
||||
$res=ExecSql($this->db,$sql);
|
||||
|
||||
if ( pg_NumRows($res) == 0 ) return;
|
||||
if ( pg_NumRows($res) == 0 ) return null;
|
||||
|
||||
$a=pg_fetch_array($res,0);
|
||||
foreach ( array('bc_code','bc_description','bc_price','bc_price_unit') as $key) {
|
||||
$this->{"$key"}=$a[$key];
|
||||
}
|
||||
|
||||
$this->from_array($a);
|
||||
}
|
||||
|
||||
static function get_list($p_cn,$p_bh_id) {
|
||||
$sql="select * from bud_card where bh_id";
|
||||
$r=ExecSql($p_cn,$sql);
|
||||
$result=array();
|
||||
$get=pg_fetch_all($res);
|
||||
|
||||
if (empty ($get))
|
||||
return array();
|
||||
|
||||
foreach ($get as $row ) {
|
||||
$obj=new Bud_Card($p_cn);
|
||||
$obj->from_array($row);
|
||||
$result[]=clone $obj;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function form() {
|
||||
|
||||
}
|
||||
static function testme() {
|
||||
$cn=DbConnect(dossier::id());
|
||||
$a=new Bud_Card($cn);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue