noalyss  Version-6.7.2
Public Member Functions | Static Public Member Functions | Data Fields
Pre_operation Class Reference

manage the predefined operation, link to the table op_def and op_def_detail More...

Public Member Functions

 compute_array ()
 count ()
 count the number of pred operation for a ledger
 delete ()
 display ()
 display the detail of predefined operation, normally everything is loaded
 get_list_ledger ()
 get the list of the predef. operation of a ledger
 get_post ()
 fill the object with the $_POST variable
 load ()
 load the data from the database and return an array
 Pre_operation ($cn, $p_id=0)
 save ()
 save the predef check first is the name is unique
 set_jrn ($p_jrn)
 set the ledger
 show_button ()
 show the button for selecting a predefined operation

Static Public Member Functions

static save_propose ()
 Propose to save the operation into a predefined operation.

Data Fields

 $db
 $jrn_type
 $name
 $nb_item
 $p_jrn

Detailed Description

manage the predefined operation, link to the table op_def and op_def_detail

Definition at line 35 of file class_pre_operation.php.


Member Function Documentation

Definition at line 156 of file class_pre_operation.php.

References $array, $p_array, and load().

    {
        $p_array=$this->load();
        $array=array(
                   "e_comm"=>$p_array[0]["od_name"],
                   "nb_item"=>(($p_array[0]["od_item"]<10?10:$p_array[0]["od_item"]))   ,
                   "p_jrn"=>$p_array[0]["jrn_def_id"],
                   "jrn_type"=>$p_array[0]["od_jrn_type"],
                   "od_description"=>$p_array['0']['od_description']
               );
        return $array;

    }

count the number of pred operation for a ledger

Definition at line 187 of file class_pre_operation.php.

References $a, and db.

Referenced by save().

    {
        $a=$this->db->count_sql("select od_id,od_name from op_predef ".
                                " where jrn_def_id=".$this->p_jrn.
                                " and od_direct ='".$this->od_direct."'".
                                " order by od_name");
        return $a;
    }

Definition at line 88 of file class_pre_operation.php.

References $sql, and db.

    {
        $sql="delete from op_predef where od_id=".$this->od_id;
        $this->db->exec_sql($sql);
    }

display the detail of predefined operation, normally everything is loaded

Definition at line 221 of file class_pre_operation.php.

References $array, and echo.

    {
        $array=$this->detail->compute_array();
        echo $this->detail->display($array);
    }

get the list of the predef. operation of a ledger

Returns:
string

Definition at line 198 of file class_pre_operation.php.

References $all, $res, $sql, db, and Database\fetch_all().

    {
        $sql="select od_id,od_name,od_description from op_predef ".
             " where jrn_def_id=".$this->p_jrn.
             " and od_direct ='".$this->od_direct."'".
             " order by od_name";
        $res=$this->db->exec_sql($sql);
        $all=Database::fetch_all($res);
        return $all;
    }

fill the object with the $_POST variable

Definition at line 71 of file class_pre_operation.php.

References $_REQUEST, db, name, and trim().

    {
        $this->nb_item=$_POST['nb_item'];
        $this->p_jrn=$_REQUEST['p_jrn'];
        $this->jrn_type=$_POST['jrn_type'];
        
        $this->name=$_POST['opd_name'];

        $this->name=(trim($this->name)=='')?$_POST['e_comm']:$this->name;
        $this->description=  $_POST['od_description'];
        if ( $this->name=="")
        {
            $n=$this->db->get_next_seq('op_def_op_seq');
            $this->name=$this->jrn_type.$n;
            // common value
        }
    }

load the data from the database and return an array

Returns:
an array

Definition at line 128 of file class_pre_operation.php.

References $array, $res, $sql, db, and Database\fetch_all().

Referenced by compute_array().

    {
        $sql="select od_id,jrn_def_id,od_name,od_item,od_jrn_type,od_description".
             " from op_predef where od_id=".$this->od_id.
             " order by od_name";
        $res=$this->db->exec_sql($sql);
        $array=Database::fetch_all($res);
        foreach (array('jrn_def_id','od_name','od_item','od_jrn_type','od_description') as $field) {
            $this->$field=$array[0][$field];
        }
        switch ($this->od_jrn_type) {
            case 'ACH':
                $this->detail=new Pre_op_ach($this->db);
                break;
            case 'VEN':
                $this->detail=new Pre_Op_ven($this->db);
                break;
            case 'ODS':
                $this->detail=new Pre_op_advanced($this->db);
                break;
            default:
                throw new Exception('Load PreOperatoin failed'.$this->od_jrn_type);
          }
        $this->detail->set_od_id($this->od_id);
        $this->detail->jrn_def_id=$this->jrn_def_id;
        
        return $array;
    }
Pre_operation::Pre_operation ( cn,
p_id = 0 
)

Definition at line 43 of file class_pre_operation.php.

References $cn, and db.

    {
        $this->db=$cn;
        $this->od_direct='false';
        $this->od_id=$p_id;
    }

save the predef check first is the name is unique

Returns:
true op.success otherwise false

Definition at line 96 of file class_pre_operation.php.

References $sql, count(), db, echo, and name.

    {

        if (    $this->db->count_sql("select * from op_predef ".
                                  "where upper(od_name)=upper('".Database::escape_string($this->name)."')".
                                  "and jrn_def_id=".$this->p_jrn)
                != 0 )
        {
            echo "<span class=\"notice\"> Ce modèle d' op&eacute;ration a d&eacute;j&agrave; &eacute;t&eacute; sauv&eacute;</span>";
            return false;
        }
        if ( $this->count()  > MAX_PREDEFINED_OPERATION )
        {
            echo '<span class="notice">Vous avez atteint le max. d\'op&eacute;ration pr&eacute;d&eacute;finie, d&eacute;sol&eacute;</span>';
            return false;
        }
        $sql='insert into op_predef (jrn_def_id,od_name,od_item,od_jrn_type,od_direct,od_description)'.
                     'values'.
                     "($1,$2,$3,$4,$5  ,$6               )";
        $this->db->exec_sql($sql,array($this->p_jrn,
                     $this->name,
                     $this->nb_item,
                     $this->jrn_type,
                     $this->od_direct,
                     $this->description,
            ));
        $this->od_id=$this->db->get_current_seq('op_def_op_seq');
        return true;
    }
static Pre_operation::save_propose ( ) [static]

Propose to save the operation into a predefined operation.

Returns:
HTML string

Definition at line 53 of file class_pre_operation.php.

References $opd_description, and $r.

                                   {
        $r="<h2>Modèle d'opération</h2>";
        $r.= '<p class="decale">';
        $r.= "Donnez un nom pour sauver cette opération comme modèle <br>";
        $opd_name = new IText('opd_name');
        $r.= "Nom du modèle " . $opd_name->input();
        $opd_description=new ITextarea('od_description');
        $opd_description->style=' class="itextarea" style="width:30em;height:4em;vertical-align:top"';
        $r.='</p>';
        $r.= '<p class="decale">';
        $r.= 'Description (max 50 car.)';   
        $r.='<br>';
        $r.=$opd_description->input();
        $r.='</p>';
        return $r;
    }
Pre_operation::set_jrn ( p_jrn)

set the ledger

Parameters:
$p_jrnis the ledger (jrn_id)

Definition at line 211 of file class_pre_operation.php.

References $p_jrn.

    {
        $this->p_jrn=$p_jrn;
    }

show the button for selecting a predefined operation

Definition at line 171 of file class_pre_operation.php.

References $r, $value, and db.

    {

        $select=new ISelect();
        $value=$this->db->make_array("select od_id,od_name from op_predef ".
                                     " where jrn_def_id=".$this->p_jrn.
                                     " and od_direct ='".$this->od_direct."'".
                                     " order by od_name");

        if ( empty($value)==true) return "";
        $select->value=$value;
        $r=$select->input("pre_def");

        return $r;
    }

Field Documentation

Pre_operation::$db

$db database connection

Definition at line 37 of file class_pre_operation.php.

Pre_operation::$jrn_type

$jrn_type

Definition at line 40 of file class_pre_operation.php.

Pre_operation::$name

$name name of the predef. operation

Definition at line 41 of file class_pre_operation.php.

Pre_operation::$nb_item

$nb_item nb of item

Definition at line 38 of file class_pre_operation.php.

Pre_operation::$p_jrn

$p_jrn jrn_def_id

Definition at line 39 of file class_pre_operation.php.

Referenced by set_jrn().


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