Ajout test paramètres passés
This commit is contained in:
parent
915a2bb4ab
commit
75ba546149
3 changed files with 44 additions and 5 deletions
|
|
@ -45,15 +45,25 @@ class Acc_Ledger_Fin extends Acc_Ledger
|
|||
$this->type = 'FIN';
|
||||
}
|
||||
|
||||
/**\brief verify that the data are correct before inserting or confirming
|
||||
* \param an array (usually $_POST)
|
||||
* \return String
|
||||
* \throw Exception on error occurs
|
||||
/**
|
||||
* Verify that the data are correct before inserting or confirming
|
||||
* @brief verify the data
|
||||
* @param an array (usually $_POST)
|
||||
* @return String
|
||||
* @throw Exception on error occurs
|
||||
*/
|
||||
|
||||
public function verify($p_array)
|
||||
{
|
||||
global $g_user;
|
||||
if (is_array($p_array ) == false || empty($p_array))
|
||||
throw new Exception ("Array empty");
|
||||
/*
|
||||
* Check needed value
|
||||
*/
|
||||
check_parameter($p_array,'p_jrn');
|
||||
|
||||
|
||||
extract($p_array);
|
||||
/* check for a double reload */
|
||||
if (isset($mt) && $this->db->count_sql('select jr_mt from jrn where jr_mt=$1', array($mt)) != 0)
|
||||
|
|
|
|||
|
|
@ -61,7 +61,17 @@ class Acc_Ledger_Sold extends Acc_Ledger {
|
|||
|
||||
public function verify($p_array) {
|
||||
global $g_parameter, $g_user;
|
||||
|
||||
if (is_array($p_array ) == false || empty($p_array))
|
||||
throw new Exception ("Array empty");
|
||||
|
||||
extract($p_array);
|
||||
|
||||
/*
|
||||
* Check needed value
|
||||
*/
|
||||
check_parameter($p_array,'p_jrn,e_date,e_client');
|
||||
|
||||
/* check for a double reload */
|
||||
if (isset($mt) && $this->db->count_sql('select jr_mt from jrn where jr_mt=$1', array($mt)) != 0)
|
||||
throw new Exception(_('Double Encodage'), 5);
|
||||
|
|
@ -918,7 +928,10 @@ class Acc_Ledger_Sold extends Acc_Ledger {
|
|||
return $r;
|
||||
}
|
||||
|
||||
/* !\brief update the payment
|
||||
/**
|
||||
* @brief update the payment
|
||||
* @deprecated
|
||||
*
|
||||
*/
|
||||
|
||||
function show_unpaid() {
|
||||
|
|
|
|||
|
|
@ -226,4 +226,20 @@ function toNumber($p_num)
|
|||
$p_num=str_replace(',','.',$p_num);
|
||||
return $p_num;
|
||||
}
|
||||
/**
|
||||
* Check that all the index are in the array, used by function to check if
|
||||
* the array contains the needed variables before an extract
|
||||
* @param type $p_array array to check
|
||||
* @param type $needed string containing variable separated by comma
|
||||
* @throws Exception
|
||||
*/
|
||||
function check_parameter($p_array,$p_needed)
|
||||
{
|
||||
$needed = split(',',$p_needed);
|
||||
for ($e=0;$e<$needed;$e++) {
|
||||
if ( ! isset($p_array[$needed[$e]])) {
|
||||
throw new Exception (_('Paramètre manquant')." ".$needed[$e]);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue