noalyss  Version-6.7.2
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...

Public Member Functions

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

Static Public Member Functions

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

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 class_forecast_cat.php.


Constructor & Destructor Documentation

Forecast_Cat::__construct ( p_init,
p_id = 0 
)

constructor

Parameters:
$p_initDatabase object

Definition at line 42 of file class_forecast_cat.php.

References cn.

    {
        $this->cn=$p_init;
        $this->fc_id=$p_id;
    }

Member Function Documentation

Definition at line 159 of file class_forecast_cat.php.

References $res, $sql, and cn.

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

Definition at line 69 of file class_forecast_cat.php.

    {
        return var_export(self::$variable,true);
    }
Forecast_Cat::get_parameter ( p_string)

Definition at line 47 of file class_forecast_cat.php.

References $idx, and exit.

Referenced by save().

    {
        if ( array_key_exists($p_string,self::$variable) )
        {
            $idx=self::$variable[$p_string];
            return $this->$idx;
        }
        else
            exit (__FILE__.":".__LINE__."[$p_string]".'Erreur attribut inexistant');
    }

Definition at line 91 of file class_forecast_cat.php.

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

Referenced by save().

    {
        if ( $this->verify() != 0 ) return;

        $sql="insert into forecast_cat (fc_desc,fc_order,f_id) ".
             " values ($1,$2,$3)  returning fc_id";
        $res=$this->cn->exec_sql(
                 $sql,
                 array($this->fc_desc,$this->fc_order,$this->f_id)
             );
        $this->fc_id=Database::fetch_result($res,0,0);
    }

Definition at line 129 of file class_forecast_cat.php.

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

    {

        $sql="select fc_desc, f_id,fc_order from forecast_cat where fc_id=$1";

        $res=$this->cn->exec_sql(
                 $sql,
                 array($this->fc_id)
             );

        if ( Database::num_row($res) == 0 ) return;
        $row=Database::fetch_array($res,0);
        foreach ($row as $idx=>$value)
        {
            $this->$idx=$value;
        }

    }
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 class_forecast_cat.php.

References $res, and $sql.

Referenced by Anticipation\form_cat_mod().

    {
        $sql="select fc_id,fc_desc,fc_order from forecast_cat where f_id=$1";

        $res=$p_cn->get_array($sql,array($p_id));

        return $res;
    }

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 class_forecast_cat.php.

References $ret, $sql, and cn.

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

Definition at line 83 of file class_forecast_cat.php.

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

    {
        if (  $this->get_parameter("id") == 0 )
            $this->insert();
        else
            $this->update();
    }
Forecast_Cat::set_parameter ( p_string,
p_value 
)

Definition at line 57 of file class_forecast_cat.php.

References $idx, and exit.

    {
        if ( array_key_exists($p_string,self::$variable) )
        {
            $idx=self::$variable[$p_string];
            $this->$idx=$p_value;
        }
        else
            exit (__FILE__.":".__LINE__."[$p_string]".'Erreur attribut inexistant');


    }
static Forecast_Cat::test_me ( ) [static]

unit test

Definition at line 167 of file class_forecast_cat.php.

    {}

Definition at line 104 of file class_forecast_cat.php.

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

Referenced by save().

    {
        if ( $this->verify() != 0 ) return;

        $sql="update forecast_cat set fc_desc=$1,f_id=$2,fc_order=$3 ".
             " where fc_id = $4";
        $res=$this->cn->exec_sql(
                 $sql,
                 array($this->fc_desc,$this->f_id, $this->fc_order,$this->fc_id)
             );
    }

Definition at line 73 of file class_forecast_cat.php.

References trim().

Referenced by insert(), and update().

    {
        if (strlen(trim($this->fc_order))==0)
        {
            $this->fc_order="1";
        }
        // Verify that the elt we want to add is correct
        // the f_name must be unique (case insensitive)
        return 0;
    }

Field Documentation

Forecast_Cat::$cn [private]

Definition at line 37 of file class_forecast_cat.php.

Forecast_Cat::$variable = array ("id"=>"fc_id","order"=>"fc_order","desc"=>"fc_desc","forecast"=>"f_id") [static, private]

Definition at line 36 of file class_forecast_cat.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations