Plugins  LAST
 All Data Structures Files Functions Variables Pages
Public Member Functions | Static Public Member Functions
Rapav_dd_Compute Class Reference

handle the param_detail type Compute More...

Inheritance diagram for Rapav_dd_Compute:
Inheritance graph
Collaboration diagram for Rapav_dd_Compute:
Collaboration graph

Public Member Functions

 compute ($p_start, $p_end)
 compute the amount for one detail rapport_advanced.formulaire_param_detail the attribute d_id and dr_id must be set before the call type $cn database connexion More...
 
 from_array ($p_array)
 the p_array contains a row from formulaire_param_detail it will be copied into this->form. More...
 

Static Public Member Functions

static factory ($p_array)
 create an object RAPAV_dd_Formula, RAPAV_dd_Account_Tva or Rapav_dd_compute following the idx type_detail More...
 

Detailed Description

handle the param_detail type Compute

See Also
RAPAV_Compute

Definition at line 937 of file class_rapav_declaration.php.

Member Function Documentation

Rapav_dd_Compute::compute (   $p_start,
  $p_end 
)

compute the amount for one detail rapport_advanced.formulaire_param_detail the attribute d_id and dr_id must be set before the call type $cn database connexion

Parameters
$p_start(date) : computed start date not used
$p_end(date) computed start date not used
Returns
numeric amount computed

Definition at line 949 of file class_rapav_declaration.php.

References $amount, $cn, and d_id.

950  {
951  global $cn;
952  $amount = 0;
953  bcscale(2);
954 
955  // copy $this->form->fp_formula to a variable
956  $formula = $this->form->fp_formula;
957 
958  // split the string from into smaller piece
959  preg_match_all("/\[([A-Z]*[0-9]*)*_*([0-9]*[A-Z]*)\]/i", $formula, $e);
960  $tmp = $e[0];
961 
962  foreach ($tmp as $piece)
963  {
964  // Find the code in the database
965  $search = str_replace('[', '', $piece);
966  $search = str_replace(']', '', $search);
967  $value = $cn->get_value('select coalesce(sum(dr_amount),0) as value
968  from rapport_advanced.declaration_row where d_id=$1 and dr_code=$2', array($this->d_id, $search));
969  $formula = str_replace($piece, $value, $formula);
970  }
971 
972  eval('$amount = ' . $formula . ';');
973  //
974  return $amount;
975  }
global $cn
static Rapav_Declaration_Detail::factory (   $p_array)
staticinherited

create an object RAPAV_dd_Formula, RAPAV_dd_Account_Tva or Rapav_dd_compute following the idx type_detail

Parameters
type$p_array
Returns
object RAPAV_dd_Formula, RAPAV_dd_Account_Tva or Rapav_dd_compute
Exceptions
ifthe type is not known

Definition at line 843 of file class_rapav_declaration.php.

References $ret.

Referenced by Rapav_Declaration_Param\compute(), and Rapav_Declaration_Param\compute_child().

844  {
845  switch ($p_array['type_detail'])
846  {
847  case '1':
848  $ret = new Rapav_dd_Formula();
849  break;
850  case '2':
851  $ret = new Rapav_dd_Account_Tva();
852  break;
853  case '3':
854  $ret = new Rapav_dd_Compute();
855  break;
856  case '4':
857  $ret = new Rapav_dd_Account();
858  break;
859  case '5':
860  $ret = new Rapav_dd_Reconcile();
861  break;
862  case '6' :
863  // For each child we have a Rapav_dd_Account
864  $ret = new Rapav_dd_Account();
865  break;
866  default:
867  throw new Exception("Type inconnu");
868  }
869 
870  $ret->from_array($p_array);
871  $ret->ddr_amount = 0; // cannot be null
872  return $ret;
873  }
$ret
handle the param_detail type Compute
handle the param_detail type Account The type_sum_account gives the type of total ...
handle the param_detail type Account The type_sum_account gives the type of total ...
handle the param_detail type Account_Tva The t_id gives the type of total
Rapav_Declaration_Detail::from_array (   $p_array)
inherited

the p_array contains a row from formulaire_param_detail it will be copied into this->form.

Parameters
type$p_arraymatch formulaire_param_detail table structure

Definition at line 880 of file class_rapav_declaration.php.

881  {
882  $this->form = new Formulaire_Param_Detail();
883  $attribute = explode(',', 'fp_id,p_id,tmp_val,tva_id,fp_formula,fp_signed,jrn_def_type,tt_id,type_detail,with_tmp_val,type_sum_account,operation_pcm_val,jrn_def_id,date_paid');
884  foreach ($attribute as $e)
885  {
886  $this->form->$e = $p_array[$e];
887  }
888  }

The documentation for this class was generated from the following file: