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

this class is called normally from forecast, a forecast contains category like sales, expenses, each category contains items More...

+ Collaboration diagram for Forecast_Cat:

Public Member Functions

 __construct ($p_init, $p_id=0)
 constructor More...
 
 delete ()
 
 get_info ()
 
 get_parameter ($p_string)
 
 insert ()
 
 load ()
 
 make_array ($id)
 Make a array for a ISelect of the available cat. More...
 
 save ()
 
 set_parameter ($p_string, $p_value)
 
 update ()
 
 verify ()
 

Static Public Member Functions

static load_all ($p_cn, $p_id)
 Load all the cat. More...
 
static test_me ()
 unit test More...
 

Private Attributes

 $cn
 

Static Private Attributes

static $variable =array ("id"=>"fc_id","order"=>"fc_order","desc"=>"fc_desc","forecast"=>"f_id")
 

Detailed Description

this class is called normally from forecast, a forecast contains category like sales, expenses, each category contains items

See also
Forecast

Definition at line 33 of file forecast_cat.class.php.

Constructor & Destructor Documentation

◆ __construct()

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

constructor

Parameters
$p_initDatabase object

Definition at line 42 of file forecast_cat.class.php.

43  {
44  $this->cn=$p_init;
45  $this->fc_id=$p_id;
46  }

References $p_id, and cn.

Member Function Documentation

◆ delete()

Forecast_Cat::delete ( )

Definition at line 159 of file forecast_cat.class.php.

160  {
161  $sql="delete from forecast_cat where fc_id=$1";
162  $res=$this->cn->exec_sql($sql,array($this->fc_id));
163  }

References $res, $sql, and cn.

◆ get_info()

Forecast_Cat::get_info ( )

Definition at line 69 of file forecast_cat.class.php.

70  {
71  return var_export(self::$variable,true);
72  }

◆ get_parameter()

Forecast_Cat::get_parameter (   $p_string)

Definition at line 47 of file forecast_cat.class.php.

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

References $idx.

Referenced by save().

◆ insert()

Forecast_Cat::insert ( )

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

92  {
93  if ( $this->verify() != 0 ) return;
94 
95  $sql="insert into forecast_cat (fc_desc,fc_order,f_id) ".
96  " values ($1,$2,$3) returning fc_id";
97  $res=$this->cn->exec_sql(
98  $sql,
99  array($this->fc_desc,$this->fc_order,$this->f_id)
100  );
101  $this->fc_id=Database::fetch_result($res,0,0);
102  }

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

Referenced by save().

+ Here is the call graph for this function:

◆ load()

Forecast_Cat::load ( )

Definition at line 129 of file forecast_cat.class.php.

130  {
131 
132  $sql="select fc_desc, f_id,fc_order from forecast_cat where fc_id=$1";
133 
134  $res=$this->cn->exec_sql(
135  $sql,
136  array($this->fc_id)
137  );
138 
139  if ( Database::num_row($res) == 0 ) return;
141  foreach ($row as $idx=>$value)
142  {
143  $this->$idx=$value;
144  }
145 
146  }

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

+ Here is the call graph for this function:

◆ load_all()

static Forecast_Cat::load_all (   $p_cn,
  $p_id 
)
static

Load all the cat.

for a given forecast and return them into a array

Parameters
$p_cndatabase connx
$p_idis the forecast id (f_id)
Returns
an array with all the data

Definition at line 121 of file forecast_cat.class.php.

122  {
123  $sql="select fc_id,fc_desc,fc_order from forecast_cat where f_id=$1";
124 
125  $res=$p_cn->get_array($sql,array($p_id));
126 
127  return $res;
128  }

References $p_id, $res, and $sql.

Referenced by Anticipation\form_cat_mod().

◆ make_array()

Forecast_Cat::make_array (   $id)

Make a array for a ISelect of the available cat.

Parameters
$idis forecast::f_id
Returns
array for ISelect
See also
ISelect

Definition at line 153 of file forecast_cat.class.php.

154  {
155  $sql="select fc_id,fc_desc from forecast_cat where f_id=$id";
156  $ret=$this->cn->make_array($sql);
157  return $ret;
158  }

References $ret, $sql, and cn.

◆ save()

Forecast_Cat::save ( )

Definition at line 83 of file forecast_cat.class.php.

84  {
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_Cat::set_parameter (   $p_string,
  $p_value 
)

Definition at line 57 of file forecast_cat.class.php.

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

References $idx.

◆ test_me()

static Forecast_Cat::test_me ( )
static

unit test

Definition at line 167 of file forecast_cat.class.php.

168  {}

◆ update()

Forecast_Cat::update ( )

Definition at line 104 of file forecast_cat.class.php.

105  {
106  if ( $this->verify() != 0 ) return;
107 
108  $sql="update forecast_cat set fc_desc=$1,f_id=$2,fc_order=$3 ".
109  " where fc_id = $4";
110  $res=$this->cn->exec_sql(
111  $sql,
112  array($this->fc_desc,$this->f_id, $this->fc_order,$this->fc_id)
113  );
114  }

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

Referenced by save().

+ Here is the call graph for this function:

◆ verify()

Forecast_Cat::verify ( )

Definition at line 73 of file forecast_cat.class.php.

74  {
75  if (strlen(trim($this->fc_order))==0)
76  {
77  $this->fc_order="1";
78  }
79  // Verify that the elt we want to add is correct
80  // the f_name must be unique (case insensitive)
81  return 0;
82  }

Referenced by insert(), and update().

Field Documentation

◆ $cn

Forecast_Cat::$cn
private

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

◆ $variable

Forecast_Cat::$variable =array ("id"=>"fc_id","order"=>"fc_order","desc"=>"fc_desc","forecast"=>"f_id")
staticprivate

Definition at line 36 of file forecast_cat.class.php.


The documentation for this class was generated from the following file:
$ret
$ret
Definition: ajax_display_letter.php:52
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
Forecast_Cat\insert
insert()
Definition: forecast_cat.class.php:91
$sql
$sql
Definition: ajax_add_concerned_card.php:103
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
Forecast_Cat\update
update()
Definition: forecast_cat.class.php:104
Forecast_Cat\verify
verify()
Definition: forecast_cat.class.php:73
$p_id
$p_id
Definition: ajax_accounting.php:33
$res
$res
Definition: ajax_preference.php:56
Forecast_Cat\get_parameter
get_parameter($p_string)
Definition: forecast_cat.class.php:47