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

Common function to RAPAV_Listing RAPAV_Formulaire and RAPAV_Declaration. More...

Collaboration diagram for RAPAV:
Collaboration graph

Static Public Member Functions

static get_ledger_name ($p_jrn)
 Return the ledger's name of p_jrn. More...
 
static str_date_type ($p_type)
 Compute the string to display for date. More...
 
static get_sql_date ($p_date, $p_prefix="")
 Compute the SQL for the date. More...
 
static verify_compute ($p_formula)
 check if the formula is valid, return 1 for an error and set errcode to the error msg errcode is global variable More...
 
static verify_formula ($p_formula)
 

Detailed Description

Common function to RAPAV_Listing RAPAV_Formulaire and RAPAV_Declaration.

Author
dany

Definition at line 27 of file class_rapav.php.

Member Function Documentation

static RAPAV::get_ledger_name (   $p_jrn)
static

Return the ledger's name of p_jrn.

Parameters
$p_jrnjrn_def::jrn_def_id if -1, it means all the ledger
Returns
string

Definition at line 35 of file class_rapav.php.

References $cn, and $ledger.

Referenced by RAPAV_Formula\display_row(), RAPAV_Account_Tva\display_row(), RAPAV_Account\display_row(), and RAPAV_Reconcile\display_row().

36  {
37  global $cn;
38  $ledger = "";
39  if ($p_jrn == null || $p_jrn == -1)
40  {
41  $ledger = " tous les journaux";
42  } else
43  {
44  $tledger = $cn->get_value('select jrn_def_name from jrn_def where jrn_def_id=$1', array($p_jrn));
45  $ledger.=" le journal " . $tledger;
46  }
47  return $ledger;
48  }
global $cn
static RAPAV::get_sql_date (   $p_date,
  $p_prefix = "" 
)
static

Compute the SQL for the date.

  • 0 given date
  • 1 Date of payment
  • 2 Limit Date
    Parameters
    $p_dateinteger
    Returns
    string
    Exceptions
    Exceptionif $p_date not valid

Definition at line 84 of file class_rapav.php.

References $p_date.

Referenced by Rapav_dd_Account\compute(), Rapav_dd_Account_Tva\compute_amount(), and Rapav_dd_Account_Tva\compute_tva().

85  {
86  if ($p_prefix != "") {$p_prefix=$p_prefix.".";}
87  switch ($p_date)
88  {
89  case 0:
90  $sql_date = "and (".$p_prefix."j_date >= to_date($2,'DD.MM.YYYY') and ".$p_prefix."j_date <= to_date($3,'DD.MM.YYYY'))";
91  break;
92  case 1:
93  $sql_date = " and ".$p_prefix."j_id in
94  (select j_id from jrnx join jrn on (j_grpt = jr_grpt_id)
95  where
96  coalesce(jr_date_paid,to_date('01.01.1900','DD.MM.YYYY')) >= to_date($2,'DD.MM.YYYY')
97  and coalesce(jr_date_paid,to_date('01.01.1900','DD.MM.YYYY')) <= to_date($3,'DD.MM.YYYY')
98  )
99  ";
100  break;
101  case 2:
102  $sql_date = " and ".$p_prefix."j_id in
103  (select j_id from jrnx join jrn on (j_grpt = jr_grpt_id)
104  where
105  coalesce(jr_ech,to_date('01.01.1900','DD.MM.YYYY')) >= to_date($2,'DD.MM.YYYY')
106  and coalesce(jr_ech,to_date('01.01.1900','DD.MM.YYYY')) <= to_date($3,'DD.MM.YYYY')
107  )
108  ";
109  break;
110 
111  default:
112  throw new Exception('get_sql_date paramètre invalide');
113  break;
114  }
115  return $sql_date;
116  }
static RAPAV::str_date_type (   $p_type)
static

Compute the string to display for date.

Parameters
$p_type
Returns
string
Exceptions
Exception

Definition at line 58 of file class_rapav.php.

References $p_type.

Referenced by RAPAV_Formula\display_row(), RAPAV_Account_Tva\display_row(), and RAPAV_Account\display_row().

59  {
60  switch ($p_type)
61  {
62  case 0:
63  return "la date concerne la date d'opération";
64  break;
65  case 1:
66  return "la date concerne la date de paiement, la recherche sera limitée au journaux de type ACH & VEN";
67  break;
68  case 2:
69  return "la date concerne la date d'échéance, la recherche sera limitée au journaux de type ACH & VEN";
70  break;
71  }
72  throw new Exception('str_date_type : type de date inconnu');
73  }
static RAPAV::verify_compute (   $p_formula)
static

check if the formula is valid, return 1 for an error and set errcode to the error msg errcode is global variable

Definition at line 123 of file class_rapav.php.

References $errcode.

Referenced by RAPAV_Formula\verify(), and RAPAV_Compute\verify().

124  {
125  global $errcode;
126  $errcode = "";
127  if (trim($p_formula) == "")
128  {
129  $errcode = " Aucune formule trouvée";
130  return 1;
131  }
132 
133  // copy $this->form->fp_formula to a variable
134  $formula = $p_formula;
135 
136  // remove the valid
137  preg_match_all("/\[([A-Z]*[0-9]*)*([0-9]*[A-Z]*)\]/i", $formula, $e);
138  $formula = preg_replace('/_/', '', $formula);
139  $formula = preg_replace("/\[([A-Z]*[0-9]*)*([0-9]*[A-Z]*)%*s*d*c*\]/i", '', $formula);
140  $formula = preg_replace("/\[([a-z]*[0-9]*)*([0-9]*[A-Z]*)%*s*d*c*\]/i", '', $formula);
141  $formula = preg_replace('/([0-9]+.{0,1}[0.9]*)*(\+|-|\*|\/)*/', '', $formula);
142  $formula = preg_replace('/(\(|\))/', '', $formula);
143  $formula = preg_replace('/\s/', '', $formula);
144  $formula = preg_replace('/</', '', $formula);
145  $formula = preg_replace('/>/', '', $formula);
146  $formula = preg_replace('/=/', '', $formula);
147  $formula = preg_replace('/\?/', '', $formula);
148 
149  // if something remains it should be a mistake
150  if ($formula != '')
151  {
152  $errcode = _(" Erreur dans la formule ") . $formula;
153  return 1;
154  }
155  return 0;
156  }
static RAPAV::verify_formula (   $p_formula)
static

Definition at line 158 of file class_rapav.php.

References $errcode.

159  {
160  global $errcode;
161  $errcode = "";
162  if (Impress::check_formula($p_formula) == false)
163  {
164  $errcode = "Erreur dans votre formule";
165  return 1;
166  }
167  if (trim($p_formula) == "")
168  {
169  $errcode = " Aucune formule trouvée";
170  return 1;
171  }
172  return 0;
173  }

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