Module Budget : bud_data
This commit is contained in:
parent
1899240be7
commit
d4097e2206
16 changed files with 566 additions and 24 deletions
|
|
@ -64,8 +64,10 @@ require_once ('class_bud_card.php');
|
|||
Bud_Card::testme();
|
||||
|
||||
|
||||
*/
|
||||
|
||||
require_once('class_bud_hypo.php');
|
||||
Bud_Hypo::testme();
|
||||
|
||||
*/
|
||||
require_once ('class_bud_data.php');
|
||||
Bud_Data::test_me();
|
||||
|
||||
|
|
|
|||
63
html/bud_ajax.php
Normal file
63
html/bud_ajax.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?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 Ajax action for budget remove or save record
|
||||
*
|
||||
*/
|
||||
//print_r($_POST);
|
||||
extract ($_POST);
|
||||
|
||||
require_once ('class_bud_detail.php');
|
||||
|
||||
$cn=DbConnect(dossier::id());
|
||||
|
||||
if ( $action == 'delete') {
|
||||
if ( $bd_id == 0 ) return;
|
||||
$obj=new Bud_Detail($cn,$bd_id);
|
||||
$obj->delete();
|
||||
header("Content-type: application/json charset=\"ISO8859-1\"",true);
|
||||
echo '{"bd_id":"'.$obj->bd_id.'","form_id":"'.$form_id.'"}';
|
||||
|
||||
}
|
||||
|
||||
if ( $action == 'save' ) {
|
||||
if ( $bd_id == 0 ) {
|
||||
$obj=new Bud_Detail($cn);
|
||||
$obj->po_id=$po_id;
|
||||
$obj->bc_id=${"bc_id".$form_id};
|
||||
$obj->pcm_val=${"account_".$form_id."_hidden"};
|
||||
$obj->bh_id=$bh_id;
|
||||
$obj->add();
|
||||
header("Content-type: application/json charset=\"ISO8859-1\"",true);
|
||||
echo '{"bd_id":"'.$obj->bd_id.'","form_id":"'.$form_id.'"}';
|
||||
exit()
|
||||
} else {
|
||||
$obj=new Bud_Detail($cn);
|
||||
$obj->po_id=$po_id;
|
||||
$obj->bc_id=${"bc_id".$form_id};
|
||||
$obj->pcm_val=${"account_".$form_id."_hidden"};
|
||||
$obj->bh_id=$bh_id;
|
||||
$obj->update();
|
||||
}
|
||||
|
||||
}
|
||||
109
html/js/bud_script.js
Normal file
109
html/js/bud_script.js
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* 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
|
||||
* open a windows for searching an account (poste comptable)
|
||||
*/
|
||||
|
||||
function bud_search_poste(p_sessid,p_dossier,p_ctl)
|
||||
{
|
||||
var comment="";
|
||||
if ( document.getElementById(p_ctl) ) {
|
||||
comment=document.getElementById(p_ctl).value;
|
||||
}
|
||||
|
||||
var win=window.open('bud_search_poste.php?gDossier='+p_dossier+'&p_ctl='+p_ctl+'&PHPSESSID='+p_sessid+"&comment="+comment+"&search",'Cherche','toolbar=no,width=600,height=600,scrollbars=yes,resizable=yes');
|
||||
}
|
||||
function GetIt() {
|
||||
window.close();
|
||||
}
|
||||
|
||||
function SetItChild(p_ctl,p_value,p_label) {
|
||||
self.opener.SetItParent(p_ctl,p_value,p_label);
|
||||
window.close();
|
||||
}
|
||||
function SetItParent(p_ctl,p_value,p_label) {
|
||||
$(p_ctl).value=p_value+' '+p_label;
|
||||
$(p_ctl+'_hidden').value=p_value;
|
||||
}
|
||||
function bud_form_enable(p_ctl) {
|
||||
$("form_"+p_ctl).enable();
|
||||
$('button_save'+p_ctl).show();
|
||||
$('button_change'+p_ctl).hide();
|
||||
$('button_delete'+p_ctl).show();
|
||||
}
|
||||
function bud_form_save(p_ctl,p_sessid,p_dossier) {
|
||||
query=$("form_"+p_ctl).serialize();
|
||||
query+="&action=save";
|
||||
$("form_"+p_ctl).disable();
|
||||
|
||||
$('button_change'+p_ctl).show();
|
||||
$('button_save'+p_ctl).hide();
|
||||
$('button_delete'+p_ctl).hide();
|
||||
bud_action(query,p_ctl);
|
||||
}
|
||||
function bud_form_delete(p_ctl,p_sessid,p_dossier) {
|
||||
if ( confirm ("Vous etes sur d'effacer") == false) { return;}
|
||||
query=$("form_"+p_ctl).serialize();
|
||||
query+="&action=delete";
|
||||
var elt=$("form_"+p_ctl).getElements();
|
||||
alert (elt);
|
||||
for (i=0;i < elt.length;i++) {
|
||||
if ( elt[i].name.search(/amount_/)!= -1 ) {
|
||||
elt[i].value="0";
|
||||
}
|
||||
if ( elt[i].name.search(/account_/) != -1 ) { elt[i].value=" ";}
|
||||
}
|
||||
$('button_change'+p_ctl).show();
|
||||
$('button_save'+p_ctl).hide();
|
||||
$('button_delete'+p_ctl).hide();
|
||||
$("form_"+p_ctl).disable();
|
||||
bud_action(query,p_ctl);
|
||||
}
|
||||
function display_error(request) {
|
||||
alert("L'operation a echoue");
|
||||
}
|
||||
|
||||
function display_success(request,json) {
|
||||
alert ('ok');
|
||||
var answer=request.responseText.evalJSON(true);
|
||||
var form=$('form_'+answer.form_id);
|
||||
var elt=form.getElements();
|
||||
|
||||
for (i = 0;i < elt.length;i++) {
|
||||
if ( elt[i].name.search(/bd_id/) != -1 ) {elt[i].value=answer.bd_id;}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
function bud_action(p_query,p_ctl) {
|
||||
var action=new Ajax.Request (
|
||||
"bud_ajax.php",
|
||||
{
|
||||
method:'post',
|
||||
parameters:p_query,
|
||||
onFailure:display_error,
|
||||
onSuccess:display_success
|
||||
}
|
||||
|
||||
);
|
||||
}
|
||||
73
html/test.php
Normal file
73
html/test.php
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
|
||||
<style type="text/css">
|
||||
<!--
|
||||
h2 {
|
||||
color:green;
|
||||
font-size:20px;
|
||||
}
|
||||
.error {
|
||||
color:red;
|
||||
font-size:20px;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
<?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
|
||||
|
||||
include_once("ac_common.php");
|
||||
include_once("postgres.php");
|
||||
require_once ('class_dossier.php');
|
||||
if ( ! file_exists('authorized_debug') ) {
|
||||
echo "Pour pouvoir utiliser ce fichier vous devez créer un fichier nomme authorized_debug
|
||||
dans le repertoire html du server";
|
||||
exit();
|
||||
|
||||
}
|
||||
// Test the connection
|
||||
echo __FILE__.":".__LINE__;
|
||||
if ( ! isset($_REQUEST['gDossier'])) {
|
||||
echo "Vous avez oublie de specifier le gDossier ;)";
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
require_once('class_plananalytic.php');
|
||||
PlanAnalytic::testme();
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
require_once("class_poste_analytic.php");
|
||||
Poste_analytique::testme();
|
||||
|
||||
|
||||
require_once ('class_bud_card.php');
|
||||
Bud_Card::testme();
|
||||
|
||||
|
||||
|
||||
require_once('class_bud_hypo.php');
|
||||
Bud_Hypo::testme();
|
||||
*/
|
||||
require_once ('class_bud_data.php');
|
||||
Bud_Data::test_me();
|
||||
|
||||
|
|
@ -106,3 +106,10 @@ if ( $po_id !== -1 ) {
|
|||
echo $button_other;
|
||||
|
||||
echo '<hr>';
|
||||
|
||||
$hidden=dossier::hidden().widget::hidden('bh_id',$_REQUEST['bh_id']).
|
||||
widget::hidden('po_id',$po_id).widget::hidden('p_action','detail');
|
||||
//----------------------------------------------------------------------
|
||||
// Show 20 lines by default
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -756,6 +756,7 @@ function get_propertie()
|
|||
$res=pg_fetch_all($r);
|
||||
|
||||
if ( empty($res) ) return null;
|
||||
print_r($res[0]);
|
||||
return $res[0];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ class Anc_Account
|
|||
$this->id=(isset ($p_array['po_id']))?$p_array['po_id']:-1;
|
||||
$this->ga_id=($p_array['ga_id']) == "-1" ?"":$p_array['ga_id'];
|
||||
}
|
||||
static function testme() {
|
||||
static function test_me() {
|
||||
$cn=DbConnect(dossier::id());
|
||||
$pa_id=getDBValue($cn,"select max(pa_id) from plan_analytique");
|
||||
$o=new Poste_Analytique($cn);
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ class Anc_Plan
|
|||
return ($a==0)?false:true;
|
||||
|
||||
}
|
||||
static function testme() {
|
||||
static function test_me() {
|
||||
$cn=DbConnect(dossier::id());
|
||||
echo "<h1>Plan analytique : test</h1>";
|
||||
echo "clean";
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ class Bud_Card {
|
|||
|
||||
return $r;
|
||||
}
|
||||
static function testme() {
|
||||
static function test_me() {
|
||||
$cn=DbConnect(dossier::id());
|
||||
$a=new Bud_Card($cn);
|
||||
|
||||
|
|
|
|||
248
include/class_bud_data.php
Normal file
248
include/class_bud_data.php
Normal file
|
|
@ -0,0 +1,248 @@
|
|||
<?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 it is a object including the class bud_detail bud_card,and
|
||||
* bud_detail_periode,
|
||||
* the purpose is to insert or save into bud_detail_periode
|
||||
*/
|
||||
require_once ('class_widget.php');
|
||||
require_once ('postgres.php');
|
||||
require_once ('constant.php');
|
||||
require_once ('debug.php');
|
||||
require_once ('ac_common.php');
|
||||
|
||||
|
||||
class Bud_Data {
|
||||
var $bh_id;
|
||||
var $bc_id;
|
||||
var $bd_id;
|
||||
var $pcm_val;
|
||||
var $bdp_id;
|
||||
var $amount;
|
||||
var $cn;
|
||||
function __construct($p_cn,$p_bh_id,$p_po_id) {
|
||||
echo "constructor";
|
||||
$this->cn=$p_cn;
|
||||
$this->bh_id=$p_bh_id;
|
||||
$this->po_id=$p_po_id;
|
||||
/*
|
||||
|
||||
pg_prepare($this->cn,"sql_periode",$sql_periode);
|
||||
*/
|
||||
}
|
||||
function load() {
|
||||
$sql=" select bd_id,bc_id,bc_code,bd.bh_id,bd.bh_name,".
|
||||
" tmp_pcmn.pcm_val,pcm_lib,bud_detail_periode.bdp_id ".
|
||||
" from bud_detail join bud_detail_periode using (bd_id)".
|
||||
" join bud_hypothese as bd using (bh_id) ".
|
||||
" join bud_card using (bc_id) ".
|
||||
" join tmp_pcmn using (pcm_val) ".
|
||||
" where bd.bh_id=".$this->bh_id.
|
||||
" and po_id=".$this->po_id;
|
||||
|
||||
|
||||
$res1=ExecSql($this->cn,$sql);
|
||||
$array=pg_fetch_all($res1);
|
||||
|
||||
|
||||
$sql_periode="select coalesce(bdp_amount,0) as bdp_amount,a.p_id as p_id ".
|
||||
" from bud_detail_periode left join parm_periode as a using (p_id) ".
|
||||
" where bdp_id=$1 order by p_start,p_end ";
|
||||
|
||||
print_r($sql_periode);
|
||||
|
||||
|
||||
$ret=array();
|
||||
|
||||
|
||||
if ( ! empty($array)){
|
||||
foreach ($array as $row) {
|
||||
$obj=new Bud_Data($this->cn,$this->bh_id,$this->po_id);
|
||||
$obj->load_from_array($row);
|
||||
|
||||
$res2=ExecSqlParam($this->db,"sql_periode",array($row['bdp_id']));
|
||||
$per=pg_fetch_all($r);
|
||||
|
||||
foreach ($per as $row2) {
|
||||
$p_id=$row['p_id'];
|
||||
$obj->amount[$p_id]=$row['bdp_amount'];
|
||||
}
|
||||
}
|
||||
$ret=clone $obj;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function create_empty_row() {
|
||||
$ret=new Bud_Data($this->cn,$this->bh_id,$this->po_id);
|
||||
$ret->bd_id=0;
|
||||
$ret->bdp_id=0;
|
||||
// populate the periode with 0
|
||||
$res_empty=get_array($this->cn,
|
||||
"select 0,p_id from parm_periode order by p_start,p_end");
|
||||
foreach ( $res_empty as $r) {
|
||||
$p_id=$r['p_id'];
|
||||
$ret->amount[$p_id]=0;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function load_from_array($p_array) {
|
||||
foreach (array('bd_id','bh_id','bc_id','pcm_val','bdp_id','pcm_lib','bh_name','bc_code') as $key) {
|
||||
$this->{$key}=$p_array[$key];
|
||||
}
|
||||
}
|
||||
function form() {
|
||||
$r="";
|
||||
$array=$this->load();
|
||||
$a=0;
|
||||
if ( ! empty ($array) ) {
|
||||
foreach ($array as $row) {
|
||||
$a++;
|
||||
$style=($a%2==0)?"even":"odd";
|
||||
$r.=$this->create_row($style);
|
||||
}
|
||||
}
|
||||
for ($i=count($array);$i< MAX_BUD_DETAIL;$i++) {
|
||||
$a++;
|
||||
$style=($a%2==0)?"even":"odd";
|
||||
|
||||
$obj=$this->create_empty_row($style);
|
||||
$r.=$obj->create_row();
|
||||
}
|
||||
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
private function create_row($p_style="odd") {
|
||||
static $p_number=0;
|
||||
$p_number++;
|
||||
$tot=0;
|
||||
|
||||
$wAmount=new widget('text');
|
||||
$wAmount->size=8;
|
||||
$wAmount->extra="disabled";
|
||||
|
||||
$wAccount=new widget('js_bud_search_poste');
|
||||
$wAccount->table=0;
|
||||
$wAccount->disabled=true;
|
||||
|
||||
$wBudCard=new widget('select');
|
||||
$wBudCard->value=$this->load_bud_card();
|
||||
$wBudCard->selected=$this->bc_id;
|
||||
$wBudCard->disabled=true;
|
||||
|
||||
foreach ($this->amount as $p_id=>$amount)
|
||||
$tot+=$amount;
|
||||
|
||||
$r='<form id="form_'.$p_number.'" disabled>';
|
||||
$r.=dossier::hidden();
|
||||
$r.=widget::hidden('po_id',$this->po_id);
|
||||
$r.=widget::hidden('bh_id',$this->bh_id);
|
||||
$r.=widget::hidden('bd_id',$this->bd_id);
|
||||
$r.=widget::hidden('bdp_id',$this->bdp_id);
|
||||
$r.=widget::hidden('form_id',$p_number);
|
||||
|
||||
|
||||
$r.="Compte d'exploitation ".$wAccount->IOValue('account_'.$p_number);
|
||||
|
||||
$r.="Fiche Budget ".$wBudCard->IOValue('bc_id'.$p_number);
|
||||
$r.='Total : <span id="form_'.$p_number.'"> '.$tot.' </span>';
|
||||
$r.='<table WIDTH="100%">';
|
||||
$r.=$this->header_table();
|
||||
$r.="<tr> ";
|
||||
foreach ($this->amount as $p_id=>$amount){
|
||||
$tot+=$amount;
|
||||
$r.='<td >'.$wAmount->IOValue('amount_'.$p_id,sprintf("%08.2f",$amount))."</td>";
|
||||
}
|
||||
$r.="</tr>";
|
||||
$r.="</table>";
|
||||
$r.=widget::hidden('PHPSESSID',$_REQUEST['PHPSESSID']);
|
||||
|
||||
$r.="</form>";
|
||||
$button_change=new widget('button','Change');
|
||||
$button_change->javascript='bud_form_enable('.$p_number.')';
|
||||
$r.=$button_change->IOValue('button_change'.$p_number);
|
||||
|
||||
$button_save=new widget('button','Sauve');
|
||||
$button_save->javascript='bud_form_save('.$p_number.')';
|
||||
$button_save->extra='style="display:none"';
|
||||
$r.=$button_save->IOValue('button_save'.$p_number);
|
||||
|
||||
$button_delete=new widget('button','Efface');
|
||||
$button_delete->javascript='bud_form_delete('.$p_number.')';
|
||||
$button_delete->extra='style="display:none"';
|
||||
$r.=$button_delete->IOValue('button_delete'.$p_number);
|
||||
$r.='<span id="Result'.$p_number.'"></span>';
|
||||
$r.="<hr>";
|
||||
return $r;
|
||||
}
|
||||
private function load_bud_card() {
|
||||
if ( !isset ($this->array_bud_card) )
|
||||
$this->array_bud_card=make_array($this->cn,
|
||||
'select bc_id,bc_code from bud_card '.
|
||||
'where bh_id='.$this->bh_id);
|
||||
return $this->array_bud_card;
|
||||
}
|
||||
|
||||
private function header_table() {
|
||||
if ( ! isset ($this->header ) ){
|
||||
$r='<table style="border: 2px outset blue; width: 100%;">';
|
||||
$r.="<tr>";
|
||||
$periode=get_array($this->cn,"select to_char(p_start,'MM/YY')as d from parm_periode ");
|
||||
foreach ($periode as $row)
|
||||
$r.='<th >'.$row['d'].'</th>';
|
||||
|
||||
$r.="</tr>";
|
||||
$this->header=$r;
|
||||
}
|
||||
return $this->header;
|
||||
}
|
||||
static function test_me() {
|
||||
echo JS_PROTOTYPE_JS;
|
||||
echo JS_BUD_SCRIPT;
|
||||
$cn=DbConnect(dossier::id());
|
||||
$sql="select bh_id||','||po_id,bh_name||' -- '||po_name ".
|
||||
" from bud_hypothese join poste_analytique using (pa_id)";
|
||||
$w=new widget("select");
|
||||
echo '<form>';
|
||||
echo dossier::hidden();
|
||||
$w->selected=(isset($_REQUEST['bh_po_id']))?$_REQUEST['bh_po_id']:"";
|
||||
echo $w->IOValue('bh_po_id',make_array($cn,$sql));
|
||||
echo widget::submit_button('search','Recherche');
|
||||
|
||||
echo '</form>';
|
||||
if ( isset($_REQUEST['search'])) {
|
||||
|
||||
list($bh_id,$po_id)=split(',',$_REQUEST['bh_po_id']);
|
||||
$obj=new Bud_Data($cn,$bh_id,$po_id);
|
||||
$r=$obj->load();
|
||||
print_r($obj);
|
||||
echo '<hr>';
|
||||
print_r($r);
|
||||
print_r($obj->create_empty_row());
|
||||
echo $obj->form();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -41,16 +41,19 @@ class Bud_Detail {
|
|||
var $po_id; /*!< PosteAnalytic id */
|
||||
var $bc_id; /*!< Budget Card id */
|
||||
var $pcm_val; /*!< from the table tmp_pcmn */
|
||||
var $bh_id;
|
||||
function __construct( $p_cn,$id = 0 ) {
|
||||
$this->db=$p_cn; $this->bd_id=$id;
|
||||
$this->po_id=null;$this->bc_id=null;$this->pcm_val=null;
|
||||
$this->bh_id=null;
|
||||
}
|
||||
function add () {
|
||||
$array=array($this->po_id,
|
||||
$this->bc_id,
|
||||
$this->pcm_val);
|
||||
$sql="insert into bud_detail (po_id,bc_id,pcm_val) ".
|
||||
" values ($1,$2,$3) returning bd_id ";
|
||||
$this->pcm_val,
|
||||
$this->bh_id);
|
||||
$sql="insert into bud_detail (po_id,bc_id,pcm_val,bh_id) ".
|
||||
" values ($1,$2,$3,$4) returning bd_id ";
|
||||
|
||||
$a=ExecSqlParam($this->db,$sql,$array);
|
||||
$x=pg_fetch_array($a,0);
|
||||
|
|
@ -98,12 +101,13 @@ class Bud_Detail {
|
|||
$pa_filter=($pa_id)?" and pa_id = $pa_id ":"";
|
||||
$sql="select * from bud_detail join bud_detail_periode using(bd_id) ".
|
||||
" right join parm_periode using (p_id) ".
|
||||
" where bh_id= $bh_id $pa_filter "
|
||||
" where bh_id= $bh_id $pa_filter ";
|
||||
}
|
||||
static function testme() {
|
||||
static function test_me() {
|
||||
$cn=DbConnect(dossier::id());
|
||||
$a=new Bud_Detail($cn);
|
||||
$a->po_id=4;
|
||||
$a->bh_id=4;
|
||||
echo "<h2> Ajout d'un bud_detail</h2>";
|
||||
$a->add();
|
||||
print_r($a);
|
||||
|
|
|
|||
|
|
@ -26,3 +26,8 @@
|
|||
/*! \brief
|
||||
*
|
||||
*/
|
||||
class Bud_Detail_Period{
|
||||
function __contruct ($p_cn,$bdp_id) {
|
||||
$sql="delete from budget_detail
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ class Bud_Hypo {
|
|||
|
||||
}
|
||||
|
||||
static function testme() {
|
||||
static function test_me() {
|
||||
$cn=DbConnect (dossier::id());
|
||||
ExecSql($cn,"delete from bud_hypothese");
|
||||
$a=new Bud_Hypo($cn);
|
||||
|
|
|
|||
|
|
@ -115,10 +115,11 @@ class widget {
|
|||
$this->name=$p_name;
|
||||
$this->value=($p_value===null)?$this->value:$p_value;
|
||||
$this->label=($p_label == "")?$this->label:$p_label;
|
||||
|
||||
|
||||
// Input text type
|
||||
$disabled = $this->disabled ? "readonly" : "";
|
||||
if (strtoupper($this->type)=="TEXT") {
|
||||
$extra=(isset($this->extra))?$this->extra:"";
|
||||
if ( $this->readonly==true ){
|
||||
$readonly=" readonly ";$style='style="border:solid 1px grey;color:black;background:lightblue;"';
|
||||
} else {
|
||||
|
|
@ -127,8 +128,8 @@ class widget {
|
|||
$this->value=str_replace('"','',$this->value);
|
||||
$r='<INPUT '.$style.' TYPE="TEXT" id="'.
|
||||
$this->name.'"'.
|
||||
'NAME="'.$this->name.'" VALUE="'.$this->value.'" '.
|
||||
'SIZE="'.$this->size.'" "'.$this->javascript." ".$disabled." $readonly >";
|
||||
'NAME="'.$this->name.'" VALUE="'.$this->value.'" '.
|
||||
'SIZE="'.$this->size.'" "'.$this->javascript." ".$disabled." $readonly $this->extra >";
|
||||
|
||||
if ($this->table==1) {
|
||||
if ( $this->label != "") {
|
||||
|
|
@ -149,8 +150,9 @@ class widget {
|
|||
if ( strtoupper($this->type) == "SELECT") {
|
||||
if ($this->readonly==false )
|
||||
{
|
||||
$disabled=($this->disabled==true)?"disabled":"";
|
||||
//echo "<b>Selected <b>".$this->selected;
|
||||
$r="<SELECT id=\"$this->name\" NAME=\"$this->name\" $this->javascript>";
|
||||
$r="<SELECT id=\"$this->name\" NAME=\"$this->name\" $this->javascript $disabled>";
|
||||
for ( $i=0;$i<sizeof($this->value);$i++)
|
||||
{
|
||||
$checked=($this->selected==$this->value[$i]['value'])?"SELECTED":"";
|
||||
|
|
@ -332,7 +334,7 @@ class widget {
|
|||
// Do we need to filter ??
|
||||
if ( $this->extra2 == null ) {
|
||||
$r=sprintf('<TD>
|
||||
<INPUT class="inp" TYPE="button" onClick=SearchPoste(\'%s\','.dossier::id().',\'%s\',\'%s\') value="Recherche">
|
||||
<INPUT class="inp" TYPE="button" onClick=SearchPoste(\'%s\','.dossier::id().',\'%s\',\'%s\') value="?">
|
||||
%s</TD><TD>
|
||||
|
||||
<INPUT style="border:groove 1px blue;" TYPE="Text" NAME="%s" ID="%s" VALUE="%s" SIZE="8">
|
||||
|
|
@ -348,7 +350,7 @@ class widget {
|
|||
|
||||
} else { // $p_list is not null, so we have a filter
|
||||
$r=sprintf('<TD>
|
||||
<INPUT TYPE="button" onClick=SearchPosteFilter(\'%s\','.dossier::id().',\'%s\',\'%s\',\'%s\') value="Recherche">
|
||||
<INPUT TYPE="button" onClick=SearchPosteFilter(\'%s\','.dossier::id().',\'%s\',\'%s\',\'%s\') value="?">
|
||||
%s</TD><TD>
|
||||
|
||||
<INPUT style="border:groove 1px blue;" TYPE="Text" NAME="%s" id="%s" VALUE="%s" SIZE="8">
|
||||
|
|
@ -375,6 +377,10 @@ class widget {
|
|||
);
|
||||
|
||||
} //else if readonly == true
|
||||
if ( $this->table==0) {
|
||||
$r=str_replace ('<TD>','',$r);
|
||||
$r=str_replace ('</TD>','',$r);
|
||||
}
|
||||
return $r;
|
||||
|
||||
} // end js_search_poste
|
||||
|
|
@ -384,9 +390,9 @@ class widget {
|
|||
$l_sessid=$_REQUEST['PHPSESSID'];
|
||||
if ( $this->readonly == false ) {
|
||||
$r=sprintf('<TD>
|
||||
<INPUT TYPE="button" onClick=NewCard(\'%s\',\'%s\',\'%s\',\'%s\') value="Nouveau">
|
||||
<INPUT TYPE="button" onClick=NewCard(\'%s\',\'%s\',\'%s\',\'%s\') value="+">
|
||||
</TD><TD>
|
||||
<INPUT TYPE="button" onClick=SearchCard(\'%s\',\'%s\',\'%s\',\'%s\') value="Recherche">
|
||||
<INPUT TYPE="button" onClick=SearchCard(\'%s\',\'%s\',\'%s\',\'%s\') value="?">
|
||||
%s
|
||||
<INPUT style="border:solid 1px blue;" TYPE="Text" ID="%s" NAME="%s" VALUE="%s" SIZE="8" onBlur="ajaxFid(\'%s\',\'%s\',\'%s\')">
|
||||
|
||||
|
|
@ -537,7 +543,7 @@ class widget {
|
|||
$l_sessid=$_REQUEST['PHPSESSID'];
|
||||
|
||||
$r=sprintf("$td
|
||||
<INPUT TYPE=\"button\" onClick=SearchJrn('%s',".dossier::id().",'%s',%s,'%s') value=\"Recherche\">
|
||||
<INPUT TYPE=\"button\" onClick=SearchJrn('%s',".dossier::id().",'%s',%s,'%s') value=\"?\">
|
||||
%s $etd $td
|
||||
<INPUT TYPE=\"text\" style=\"color:black;background:lightyellow;border:solid 1px grey;\" NAME=\"%s\" ID=\"%s\" VALUE=\"%s\" SIZE=\"8\" readonly>
|
||||
$etd",
|
||||
|
|
@ -561,15 +567,32 @@ class widget {
|
|||
// BUTTON
|
||||
//----------------------------------------------------------------------
|
||||
if ( strtolower($this->type)=="button") {
|
||||
$extra= ( isset($this->extra))?$this->extra:"";
|
||||
if ( $this->readonly==true) return "";
|
||||
$r='<input type="BUTTON" name="'.$this->name.'"'.
|
||||
' id="'.$this->name.'"'.
|
||||
' value="'.$this->label.'"'.
|
||||
' onClick="'.$this->javascript.'">';
|
||||
' onClick="'.$this->javascript.'"'.$extra.'>';
|
||||
return $r;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// JS_BUD_SEARCH_POSTE
|
||||
//----------------------------------------------------------------------
|
||||
if ( strtolower($this->type)=="js_bud_search_poste") {
|
||||
if ( $this->readonly==true) return "";
|
||||
$dis= ( $this->disabled==true) ? "disabled":"";
|
||||
|
||||
$this->javascript="bud_search_poste('".$_REQUEST['PHPSESSID']."',".dossier::id().",'$this->name')";
|
||||
$r='<input type="BUTTON" value="?"'.$dis.
|
||||
' onClick="'.$this->javascript.'" style="display:line">';
|
||||
$r.='<input type="text" readonly id="'.$this->name.'" name="'.
|
||||
$this->name.'" value ="'.$this->value.'" size="35">';
|
||||
|
||||
$r.='<input type="hidden" name="'.$this->name.'_hidden" id="'.$this->name.'_hidden" value="'.$this->value.'">';
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// JS_DATE
|
||||
//------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ define ("phpcompta_user","phpcompta");
|
|||
// the domain can't start by a number !!!
|
||||
define ("domaine","");
|
||||
define ("MAX_COMPTE",4);
|
||||
|
||||
define ('MAX_BUD_DETAIL',3);
|
||||
|
||||
define ("DEBUG","false");
|
||||
|
||||
|
|
@ -157,6 +157,9 @@ define ("JS_CONFIRM",
|
|||
define ("JS_SEARCH_POSTE",
|
||||
"<SCRIPT language=\"javascript\" src=\"js/search_poste.js\"> </SCRIPT>");
|
||||
|
||||
define ("JS_BUD_SCRIPT",
|
||||
"<SCRIPT language=\"javascript\" src=\"js/bud_script.js\"> </SCRIPT>");
|
||||
|
||||
define ("JS_VIEW_JRN_CANCEL",
|
||||
"<script language=\"javascript\" src=\"js/cancel_op.js\"> </script>");
|
||||
|
||||
|
|
|
|||
|
|
@ -223,6 +223,7 @@ CREATE TABLE bud_detail (
|
|||
bd_id integer NOT NULL,
|
||||
po_id integer,
|
||||
bc_id integer,
|
||||
bh_id integer,
|
||||
pcm_val poste_comptable
|
||||
);
|
||||
|
||||
|
|
@ -318,7 +319,10 @@ CREATE INDEX fki_tmp_pcmn ON bud_detail USING btree (pcm_val);
|
|||
--
|
||||
|
||||
ALTER TABLE ONLY bud_detail
|
||||
ADD CONSTRAINT fk_bud_card FOREIGN KEY (bc_id) REFERENCES bud_card(bc_id);
|
||||
ADD CONSTRAINT fk_bud_card FOREIGN KEY (bc_id) REFERENCES bud_card(bc_id) ON UPDATE CASCADE ON DELETE CASCADE;;
|
||||
|
||||
ALTER TABLE ONLY bud_detail
|
||||
set fk_bud_hypothese_not_null FOREIGN KEY (bh_id) REFERENCES bud_hypothese(bh_id) ON UPDATE CASCADE ON DELETE CASCADE;;
|
||||
|
||||
|
||||
--
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue