noalyss  Version-8.1
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes
Forecast_Item Class Reference

manage the table forecast_item contains the items, the item are part of category of forecast_cat, which are part of Forecast More...

+ Collaboration diagram for Forecast_Item:

Public Member Functions

 __construct ($p_init, $p_id=0)
 constructor More...
 
 delete ()
 
 get_info ()
 
 get_parameter ($p_string)
 
 insert ()
 
 load ()
 
 save ()
 
 set_parameter ($p_string, $p_value)
 
 update ()
 
 verify ()
 

Static Public Member Functions

static test_me ()
 unit test More...
 

Private Attributes

 $cn
 

Static Private Attributes

static $variable
 

Detailed Description

manage the table forecast_item contains the items, the item are part of category of forecast_cat, which are part of Forecast

See also
Forecast Forecast_Cat

Definition at line 34 of file forecast_item.class.php.

Constructor & Destructor Documentation

◆ __construct()

Forecast_Item::__construct (   $p_init,
  $p_id = 0 
)

constructor

Parameters
$p_initDatabase object

Definition at line 44 of file forecast_item.class.php.

45  {
46  $this->cn=$p_init;
47  $this->fi_id=$p_id;
48  }

References $p_id, and cn.

Member Function Documentation

◆ delete()

Forecast_Item::delete ( )

Definition at line 152 of file forecast_item.class.php.

153  {
154  $sql="delete from forecast_item where fi_id=$1";
155  $res=$this->cn->exec_sql($sql,array($this->fi_id));
156  }

References $res, $sql, and cn.

◆ get_info()

Forecast_Item::get_info ( )

Definition at line 71 of file forecast_item.class.php.

72  {
73  return var_export(self::$variable,true);
74  }

◆ get_parameter()

Forecast_Item::get_parameter (   $p_string)

Definition at line 49 of file forecast_item.class.php.

50  {
51  if ( array_key_exists($p_string,self::$variable) )
52  {
53  $idx=self::$variable[$p_string];
54  return $this->$idx;
55  }
56  else
57  throw new Exception("Attribut inexistant $p_string");
58  }

References $idx.

Referenced by save().

◆ insert()

Forecast_Item::insert ( )

Definition at line 91 of file forecast_item.class.php.

92  {
93  if ( $this->verify() != 0 ) return;
94 
95  $sql="INSERT INTO forecast_item(
96  fi_text, fi_account, fi_card, fi_order, fc_id, fi_amount,
97  fi_debit,fi_pid)
98  VALUES ($1, $2, $3, $4, $5, $6, $7,$8) returning fi_id;";
99  $res=$this->cn->exec_sql(
100  $sql,
101  array($this->fi_text,$this->fi_account,$this->fi_card,$this->fi_order,$this->fc_id,$this->fi_amount,$this->fi_debit,$this->fi_pid)
102  );
103  $this->fi_id=Database::fetch_result($res,0,0);
104  }

References $res, $sql, cn, DatabaseCore\fetch_result(), and verify().

Referenced by save().

+ Here is the call graph for this function:

◆ load()

Forecast_Item::load ( )

Definition at line 128 of file forecast_item.class.php.

129  {
130 
131  $sql="SELECT fi_id, fi_text, fi_account, fi_card, fi_order, fc_id, fi_amount,
132  fi_debit,fi_pid
133  FROM forecast_item where fi_id=$1";
134 
135  $res=$this->cn->exec_sql(
136  $sql,
137  array($this->fi_id)
138  );
139 
140  if ( Database::num_row($res) == 0 ) return;
142  foreach ($row as $idx=>$value)
143  {
144  $this->$idx=$value;
145  }
146 
147  }

References $idx, $res, $row, $sql, $value, cn, DatabaseCore\fetch_array(), and DatabaseCore\num_row().

+ Here is the call graph for this function:

◆ save()

Forecast_Item::save ( )

Definition at line 82 of file forecast_item.class.php.

83  {
84  /* please adapt */
85  if ( $this->get_parameter("id") == 0 )
86  $this->insert();
87  else
88  $this->update();
89  }

References get_parameter(), insert(), and update().

+ Here is the call graph for this function:

◆ set_parameter()

Forecast_Item::set_parameter (   $p_string,
  $p_value 
)

Definition at line 59 of file forecast_item.class.php.

60  {
61  if ( array_key_exists($p_string,self::$variable) )
62  {
63  $idx=self::$variable[$p_string];
64  $this->$idx=$p_value;
65  }
66  else
67  throw new Exception("Attribut inexistant $p_string");
68 
69 
70  }

References $idx.

◆ test_me()

static Forecast_Item::test_me ( )
static

unit test

Definition at line 160 of file forecast_item.class.php.

161  {}

◆ update()

Forecast_Item::update ( )

Definition at line 106 of file forecast_item.class.php.

107  {
108  if ( $this->verify() != 0 ) return;
109 
110  $sql="UPDATE forecast_item
111  SET fi_text=$1, fi_account=$2, fi_card=$3, fi_order=$4, fc_id=$5,
112  fi_amount=$6, fi_debit=$7,fi_pid=$8
113  WHERE fi_id=$9;";
114  $res=$this->cn->exec_sql($sql,
115  array($this->fi_text,
116  $this->fi_account,
117  $this->fi_card,
118  $this->fi_order,
119  $this->fc_id,
120  $this->fi_amount,
121  $this->fi_debit,
122  $this->fi_pid,
123  $this->fi_id)
124  );
125 
126  }

References $res, $sql, cn, and verify().

Referenced by save().

+ Here is the call graph for this function:

◆ verify()

Forecast_Item::verify ( )

Definition at line 75 of file forecast_item.class.php.

76  {
77  $this->fi_account= str_replace(" ", "", $this->fi_account);
78  // Verify that the elt we want to add is correct
79  // the f_name must be unique (case insensitive)
80  return 0;
81  }

Referenced by insert(), and update().

Field Documentation

◆ $cn

Forecast_Item::$cn
private

Definition at line 39 of file forecast_item.class.php.

◆ $variable

Forecast_Item::$variable
staticprivate
Initial value:
=array ("id"=>"fi_id","text"=>"fi_text","account"=>"fi_account",
"card"=>"fi_card","order"=>"fi_order","cat_id"=>"fc_id","amount"=>"fi_amount","debit"=>"fi_debit","periode"=>"fi_pid")

Definition at line 37 of file forecast_item.class.php.


The documentation for this class was generated from the following file:
Forecast_Item\insert
insert()
Definition: forecast_item.class.php:91
Forecast_Item\get_parameter
get_parameter($p_string)
Definition: forecast_item.class.php:49
cn
$input_from cn
Definition: balance.inc.php:73
DatabaseCore\fetch_array
static fetch_array($ret, $p_indice=0)
wrapper for the function pg_fetch_array
Definition: database_core.class.php:727
$sql
$sql
Definition: ajax_add_concerned_card.php:103
Forecast_Item\verify
verify()
Definition: forecast_item.class.php:75
DatabaseCore\fetch_result
static fetch_result($ret, $p_row=0, $p_col=0)
wrapper for the function pg_fetch_all
Definition: database_core.class.php:749
$value
$value
Definition: export_document.php:38
DatabaseCore\num_row
static num_row($ret)
wrapper for the function pg_NumRows
Definition: database_core.class.php:716
$idx
$idx
Definition: ajax_bookmark.php:79
$row
$row
Definition: ajax_anc_detail_operation.php:33
$p_id
$p_id
Definition: ajax_accounting.php:33
$res
$res
Definition: ajax_preference.php:56
Forecast_Item\update
update()
Definition: forecast_item.class.php:106