Code cleaning and add the mode strict
This commit is contained in:
parent
b02a10474c
commit
91d7df88ab
18 changed files with 315 additions and 518 deletions
|
|
@ -35,6 +35,16 @@ require_once('class_todo_list.php');
|
|||
|
||||
$cn=DbConnect(dossier::id());
|
||||
$user=new User($cn);
|
||||
if ($user->AccessJrn($cn,dossier::id()) == false ){
|
||||
exit('<h2 class="error">Permission refusee </h2>');
|
||||
}
|
||||
|
||||
if ( DBVERSION!=dossier::get_version($cn)) {
|
||||
echo "Votre base de données n'est pas à jour, ";
|
||||
$a="cliquez ici pour appliquer le patch";
|
||||
$base=dirname($_SERVER['REQUEST_URI']).'/admin/setup.php';
|
||||
echo '<a hreF="'.$base.'">'.$a.'</a>';
|
||||
}
|
||||
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
echo '<div class="u_tmenu">';
|
||||
|
|
|
|||
|
|
@ -69,6 +69,14 @@ foreach ($l_array as $key=>$element) {
|
|||
if ( isset ($_POST['annul']) ) {
|
||||
/* Confirm it first */
|
||||
if ( ! isset ( $_POST['confirm'])) {
|
||||
$own=new Own($cn);
|
||||
if ( $own->MY_STRICT=='Y') {
|
||||
$msg="Vous utilisez le mode stricte, l'annulation est interdite";
|
||||
echo '<h2 class="info">Confirmation</h2>';
|
||||
echo '<p><span class="error">'.$msg.'</span></p>';
|
||||
exit();
|
||||
}
|
||||
|
||||
?>
|
||||
<p>
|
||||
<h2 class="info">Confirmation</h2>
|
||||
|
|
@ -146,9 +154,9 @@ if ($p_id != -1 ) { // A
|
|||
$per=new Periode($cn);
|
||||
$per->set_jrn($nJrn);
|
||||
$per->set_periode($period_id);
|
||||
|
||||
$own=new Own($cn);
|
||||
// Check the period_id
|
||||
if ( $per->is_open() == 0 )
|
||||
if ( $per->is_open() == 0 || $own->MY_STRICT=='Y')
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -47,20 +47,28 @@ if ( isset ($_POST["update"] ) ) {
|
|||
$p_lib=FormatString($_POST["p_lib"]);
|
||||
$p_parent=trim($_POST["p_parent"]);
|
||||
$old_line=trim($_POST["p_old"]);
|
||||
$p_type=$_POST['p_type'];
|
||||
// Check if p_parent and p_val are number
|
||||
if ( ! is_numeric($p_val) || ! is_numeric($p_parent) ) {
|
||||
// not number no update
|
||||
echo '<script> alert(\' Valeurs invalides, pas de changement opéré;\');
|
||||
$p_type=htmlentities($_POST['p_type']);
|
||||
$acc=new Acc_Account($cn);
|
||||
$acc->set_parameter('libelle',$p_lib);
|
||||
$acc->set_parameter('value',$p_val);
|
||||
$acc->set_parameter('parent',$p_parent);
|
||||
$acc->set_parameter('type',$p_type);
|
||||
// Check if the data are correct
|
||||
try {
|
||||
$acc->check() ;
|
||||
}catch (AcException $e) {
|
||||
$message="Valeurs invalides, pas de changement \n ".
|
||||
$e->getMessage();
|
||||
echo '<script> alert(\''.$message.'\');
|
||||
</script>';
|
||||
echo "<script>
|
||||
window.close();
|
||||
self.opener.RefreshMe();
|
||||
echo "<script>
|
||||
window.close();
|
||||
self.opener.RefreshMe();
|
||||
|
||||
</script>";
|
||||
exit();
|
||||
</script>";
|
||||
exit();
|
||||
|
||||
}
|
||||
}
|
||||
echo_debug('line_update.php',__LINE__,"Update old : $old_line News = $p_val $p_lib");
|
||||
if ( strlen ($p_val) != 0 && strlen ($p_lib) != 0 && strlen($old_line)!=0 ) {
|
||||
if (strlen ($p_val) == 1 ) {
|
||||
|
|
@ -72,12 +80,11 @@ if ( isset ($_POST["update"] ) ) {
|
|||
}
|
||||
}
|
||||
/* Parent existe */
|
||||
$Ret=ExecSql($cn,"select pcm_val from tmp_pcmn where pcm_val=$p_parent");
|
||||
$Ret=ExecSqlParam($cn,"select pcm_val from tmp_pcmn where pcm_val=$1",array($p_parent));
|
||||
if ( pg_NumRows($Ret) == 0 || $p_parent==$old_line ) {
|
||||
echo '<SCRIPT> alert(" Ne peut pas modifier; aucune poste parent"); </SCRIPT>';
|
||||
} else {
|
||||
|
||||
$Ret=ExecSql($cn,"update tmp_pcmn set pcm_val=$p_val, pcm_lib='$p_lib',pcm_val_parent=$p_parent,pcm_type='$p_type' where pcm_val=$old_line");
|
||||
$acc->update($old_line);
|
||||
}
|
||||
} else {
|
||||
echo '<script> alert(\'Update Valeurs invalides\'); </script>';
|
||||
|
|
@ -94,18 +101,17 @@ if ( isset ($_POST["update"] ) ) {
|
|||
?>
|
||||
<FORM ACTION="line_update.php" METHOD="POST">
|
||||
<?
|
||||
$acc=new Acc_Account($cn);
|
||||
$acc->pcm_val=$_GET['l'];
|
||||
$acc->pcm_val_parent=$_GET['p'];
|
||||
$acc->pcm_lib=$_GET['n'];
|
||||
$acc->pcm_type=(isset ($_GET['m']))?$_GET['m']:"";
|
||||
echo $acc->form(true);
|
||||
$acc=new Acc_Account($cn);
|
||||
$acc->set_parameter('value',$_GET['l']);
|
||||
$acc->load();
|
||||
|
||||
echo $acc->form(true);
|
||||
?>
|
||||
<TABLE>
|
||||
<TR>
|
||||
<TD><INPUT TYPE="Submit" VALUE="Sauve">
|
||||
<INPUT TYPE="HIDDEN" name="update">
|
||||
<?php printf ('<INPUT TYPE="HIDDEN" name="p_old" value="%s">',$acc->pcm_val); ?>
|
||||
<?php printf ('<INPUT TYPE="HIDDEN" name="p_old" value="%s">',$acc->get_parameter('value')); ?>
|
||||
</TD><TD><input type="button" Value="Retour sans sauver" onClick='window.close();'></TD></TR>
|
||||
</TABLE>
|
||||
</FORM>
|
||||
|
|
|
|||
|
|
@ -191,8 +191,9 @@ if ( $p_action=='company') {
|
|||
$m->MY_TEL=$p_tel;
|
||||
$m->MY_FAX=$p_fax;
|
||||
$m->MY_PAYS=$p_pays;
|
||||
$m->MY_ANALYTIC=$p_compta;
|
||||
$m->Save();
|
||||
$m->MY_ANALYTIC=$p_compta;
|
||||
$m->MY_STRICT=$p_strict;
|
||||
$m->Update();
|
||||
}
|
||||
|
||||
$my=new Own($cn);
|
||||
|
|
@ -202,9 +203,19 @@ if ( $p_action=='company') {
|
|||
array("value"=>"op",'label'=>"optionnel"),
|
||||
array("value"=>"nu",'label'=>"non utilisé")
|
||||
);
|
||||
$strict_array=array(
|
||||
array('value'=>'N','label'=>'Non'),
|
||||
array('value'=>'Y','label'=>'Oui')
|
||||
);
|
||||
|
||||
$compta=new widget("select");
|
||||
$compta->table=1;
|
||||
$compta->selected=$my->MY_ANALYTIC;
|
||||
|
||||
$strict=new widget("select");
|
||||
$strict->table=1;
|
||||
$strict->selected=$my->MY_STRICT;
|
||||
|
||||
// other parameters
|
||||
$all=new widget("text");
|
||||
$all->table=1;
|
||||
|
|
@ -221,6 +232,8 @@ if ( $p_action=='company') {
|
|||
echo "<tr>".$all->IOValue("p_pays",$my->MY_PAYS,"Pays")."</tr>";
|
||||
echo "<tr>".$all->IOValue("p_tva",$my->MY_TVA,"Numéro de Tva")."</tr>";
|
||||
echo "<tr>".$compta->IOValue("p_compta",$array,"Utilisation de la compta. analytique")."</tr>";
|
||||
echo "<tr>".$strict->IOValue("p_strict",$strict_array,"Utilisation du mode strict ")."</tr>";
|
||||
|
||||
echo "</table>";
|
||||
$submit=new widget("submit");
|
||||
echo widget::submit("record_company","Enregistre");
|
||||
|
|
|
|||
|
|
@ -522,15 +522,6 @@ function sql_filter_per($p_cn,$p_from,$p_to,$p_form='p_id',$p_field='jr_tech_per
|
|||
return $periode;
|
||||
}
|
||||
|
||||
/* !\brief return the label of the tva_id
|
||||
* \param $p_cn database connx
|
||||
* \param $p_tva_id tva_id
|
||||
*/
|
||||
function tva_get_label($p_cn,$p_tva_id)
|
||||
{
|
||||
$a=getDbValue($p_cn,"select tva_label from tva_rate where tva_id='".$p_tva_id."'");
|
||||
return $a;
|
||||
}
|
||||
/*!\brief alert in javascript
|
||||
*\param $p_msg is the message
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -27,52 +27,19 @@
|
|||
require_once ('postgres.php');
|
||||
require_once ('class_dossier.php');
|
||||
require_once ('class_widget.php');
|
||||
require_once('class_acexception.php');
|
||||
|
||||
class Acc_Account {
|
||||
var $db; /*!< $db database connection */
|
||||
var $pcm_val;
|
||||
var $pcm_type;
|
||||
var $pcm_parent;
|
||||
var $pcm_lib;
|
||||
function __construct ($p_cn,$p_id=0) {
|
||||
$this->db=$p_cn;
|
||||
$this->pcm_val=$p_id;
|
||||
}
|
||||
/*!\brief Return the name of a account
|
||||
* it doesn't change any data member
|
||||
* \return string with the pcm_lib
|
||||
*/
|
||||
function get_lib() {
|
||||
$ret=pg_exec($this->db,
|
||||
"select pcm_lib from tmp_pcmn where
|
||||
pcm_val=".$this->id);
|
||||
if ( pg_NumRows($ret) != 0) {
|
||||
$r=pg_fetch_array($ret);
|
||||
$this->name=$r['pcm_lib'];
|
||||
} else {
|
||||
$this->name="Poste inconnu";
|
||||
}
|
||||
return $this->name;
|
||||
}
|
||||
/*!\brief Get all the value for this object from the database
|
||||
* the data member are set
|
||||
* \return false if this account doesn't exist otherwise true
|
||||
*/
|
||||
function load()
|
||||
{
|
||||
$ret=ExecSql($this->db,"select pcm_lib,pcm_val_parent,pcm_type from
|
||||
tmp_pcmn where pcm_val=".$this->id);
|
||||
$r=pg_fetch_all($ret);
|
||||
|
||||
if ( ! $r ) return false;
|
||||
$this->pcm_lib=$r[0]['pcm_lib'];
|
||||
$this->pcm_val_parent=$r[0]['pcm_val_parent'];
|
||||
$this->pcm_type=$r[0]['pcm_type'];
|
||||
return true;
|
||||
|
||||
}
|
||||
function form($p_table=true){
|
||||
$array=array(
|
||||
static private $variable = array("value"=>'pcm_val',
|
||||
'type'=>'pcm_type',
|
||||
'parent'=>'pcm_val_parent',
|
||||
'libelle'=>'pcm_lib');
|
||||
private $pcm_val;
|
||||
private $pcm_type;
|
||||
private $pcm_parent;
|
||||
private $pcm_lib;
|
||||
static private $type=array(
|
||||
array('label'=>'Actif','value'=>'ACT'),
|
||||
array('label'=>'Passif','value'=>'PAS'),
|
||||
array('label'=>'Actif c. inverse','value'=>'ACTINV'),
|
||||
|
|
@ -83,9 +50,102 @@ class Acc_Account {
|
|||
array('label'=>'Charge Inverse','value'=>'CHAINV'),
|
||||
array('label'=>'Non defini','value'=>'CON')
|
||||
);
|
||||
|
||||
function __construct ($p_cn,$p_id=0) {
|
||||
$this->db=$p_cn;
|
||||
$this->pcm_val=$p_id;
|
||||
}
|
||||
public function get_parameter($p_string) {
|
||||
if ( array_key_exists($p_string,self::$variable) ) {
|
||||
$idx=self::$variable[$p_string];
|
||||
return $this->$idx;
|
||||
}
|
||||
else
|
||||
exit (__FILE__.":".__LINE__.'Erreur attribut inexistant');
|
||||
}
|
||||
|
||||
function set_parameter($p_string,$p_value) {
|
||||
if ( array_key_exists($p_string,self::$variable) ) {
|
||||
$idx=self::$variable[$p_string];
|
||||
if ($this->check($idx,$p_value) == true ) $this->$idx=$p_value;
|
||||
}
|
||||
else
|
||||
exit (__FILE__.":".__LINE__.'Erreur attribut inexistant');
|
||||
|
||||
|
||||
}
|
||||
/*!\brief Return the name of a account
|
||||
* it doesn't change any data member
|
||||
* \return string with the pcm_lib
|
||||
*/
|
||||
function get_lib() {
|
||||
$ret=ExecSqlParam($this->db,
|
||||
"select pcm_lib from tmp_pcmn where
|
||||
pcm_val=$1",array($this->pcm_value));
|
||||
if ( pg_NumRows($ret) != 0) {
|
||||
$r=pg_fetch_array($ret);
|
||||
$this->name=$r['pcm_lib'];
|
||||
} else {
|
||||
$this->name="Poste inconnu";
|
||||
}
|
||||
return $this->name;
|
||||
}
|
||||
/*!\brief Check that the value are valid
|
||||
*\return true if all value are valid otherwise false
|
||||
*/
|
||||
function check ($p_member='',$p_value='')
|
||||
{
|
||||
// if there is no argument we check all the member
|
||||
if ($p_member == '' && $p_value== '' ) {
|
||||
foreach (self::$variable as $l=>$k) {
|
||||
$this->check($k,$this->$k);
|
||||
}
|
||||
} else {
|
||||
// otherwise we check only the value
|
||||
if ( strcmp ($p_member,'pcm_val') == 0 ) {
|
||||
if (is_numeric($p_value) ==0 )
|
||||
throw new AcException('Poste comptable incorrect '.$p_value);
|
||||
else
|
||||
return true;
|
||||
} else if ( strcmp ($p_member,'pcm_val_parent') == 0 ) {
|
||||
if ( is_numeric($p_value) == 0 || $this->count($p_value) == 0)
|
||||
throw new AcException('Poste comptable parent incorrect '.$p_value);
|
||||
else
|
||||
return true;
|
||||
} else if ( strcmp ($p_member,'pcm_lib') == 0 ) {
|
||||
return true;
|
||||
} else if ( strcmp ($p_member,'pcm_type') == 0 ) {
|
||||
foreach (self::$type as $l=>$k) {
|
||||
if ( strcmp ($k['value'],$p_value) == 0 ) return true;
|
||||
|
||||
}
|
||||
throw new AcException('type de compte incorrect '.$p_value);
|
||||
}
|
||||
throw new AcException ('Donnee member inconnue '.$p_member);
|
||||
}
|
||||
|
||||
}
|
||||
/*!\brief Get all the value for this object from the database
|
||||
* the data member are set
|
||||
* \return false if this account doesn't exist otherwise true
|
||||
*/
|
||||
function load()
|
||||
{
|
||||
$ret=ExecSql($this->db,"select pcm_lib,pcm_val_parent,pcm_type from
|
||||
tmp_pcmn where pcm_val=".$this->pcm_val);
|
||||
$r=pg_fetch_all($ret);
|
||||
|
||||
if ( ! $r ) return false;
|
||||
$this->pcm_lib=$r[0]['pcm_lib'];
|
||||
$this->pcm_val_parent=$r[0]['pcm_val_parent'];
|
||||
$this->pcm_type=$r[0]['pcm_type'];
|
||||
return true;
|
||||
|
||||
}
|
||||
function form($p_table=true){
|
||||
$wType=new widget("select");
|
||||
$wType->name='p_type';
|
||||
$wType->value=$array;
|
||||
$wType->value=self::$type;
|
||||
|
||||
if ( ! $p_table ) {
|
||||
$ret=' <TR>
|
||||
|
|
@ -116,12 +176,27 @@ class Acc_Account {
|
|||
$ret.= '<td>'.$wType->IOValue().'</td>';
|
||||
$ret.="</TR> </TABLE>";
|
||||
$ret.=dossier::hidden();
|
||||
print_r($this);
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
function count($p_value) {
|
||||
$sql="select count(*) from tmp_pcmn where pcm_val=$1";
|
||||
return getDbValue($this->db,$sql,array($p_value));
|
||||
}
|
||||
/*!\brief for developper only during test */
|
||||
static function test_me() {
|
||||
$cn=DbConnect(dossier::id());
|
||||
|
||||
}
|
||||
function update($p_old) {
|
||||
$this->pcm_lib=substr(FormatString ($this->pcm_lib),0,50);
|
||||
$this->check();
|
||||
$sql="update tmp_pcmn set pcm_val=$1, pcm_lib=$2,pcm_val_parent=$3,pcm_type=$4 where pcm_val=$5";
|
||||
$Ret=ExecSqlParam($this->db,$sql,array($this->pcm_val,
|
||||
$this->pcm_lib,
|
||||
$this->pcm_val_parent,
|
||||
$this->pcm_type,
|
||||
$p_old));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -988,7 +988,6 @@ class Acc_Ledger {
|
|||
$ret.= '</td></tr>';
|
||||
|
||||
$ret.= '</table>';
|
||||
// $nb_row=(isset($nb))?$nb:$this->GetDefLine();
|
||||
$nb_row=(isset($nb_item) )?$nb_item:$this->nb;
|
||||
|
||||
$ret.=widget::hidden('nb_item',$nb_row);
|
||||
|
|
@ -1033,7 +1032,7 @@ class Acc_Ledger {
|
|||
$label='';
|
||||
if ( $poste->value != '' ) {
|
||||
$Poste=new Acc_Account($this->db);
|
||||
$Poste->id=$poste->value;
|
||||
$Poste->pcm_value=$poste->value;
|
||||
$label=$Poste->get_lib();
|
||||
}
|
||||
// Description of the line
|
||||
|
|
@ -1126,6 +1125,16 @@ class Acc_Ledger {
|
|||
echo_debug(__FILE__.':'.__LINE__.'- verify',' the periode is closed ');
|
||||
throw new AcException('Periode fermee',6);
|
||||
}
|
||||
/* check if we are using the strict mode */
|
||||
if( $this->check_strict() == true) {
|
||||
/* if we use the strict mode, we get the date of the last
|
||||
operation */
|
||||
$last_date=$this->get_last_date();
|
||||
if ( cmpDate($date,$last_date) < 0 )
|
||||
throw new AcException('Vous utilisez le mode strict la dernière operation est la date du '
|
||||
.$last_date.' vous ne pouvez pas encoder à une date antérieure',15);
|
||||
|
||||
}
|
||||
|
||||
for ($i=0;$i<$nb_item;$i++)
|
||||
{
|
||||
|
|
@ -1516,7 +1525,24 @@ class Acc_Ledger {
|
|||
$res=get_array($this->db,$sql,array($p_exercice));
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
*\brief Check if a Dossier is using the strict mode or not
|
||||
* \return true if we are using the strict_mode
|
||||
*/
|
||||
function check_strict() {
|
||||
$own=new Own($this->db);
|
||||
if ( $own->MY_STRICT=='Y') return true;
|
||||
if ( $own->MY_STRICT=='N') return false;
|
||||
exit("Valeur invalid ".__FILE__.':'.__LINE__);
|
||||
}
|
||||
|
||||
/*!\brief get the date of the last operation
|
||||
*/
|
||||
function get_last_date()
|
||||
{
|
||||
if ( $this->id==0) throw AcException (__FILE__.":".__LINE__."Journal incorrect ");
|
||||
$sql="select to_char(max(jr_date),'DD.MM.YYYY') from jrn where jr_def_id=$1";
|
||||
$date=getDbValue($this->db,$sql,array($this->id));
|
||||
return $date;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,20 @@ class Acc_Ledger_Fin extends Acc_Ledger {
|
|||
if ( cmpDate($e_date,$min) < 0 ||
|
||||
cmpDate($e_date,$max) > 0)
|
||||
throw new AcException('Date et periode ne correspondent pas',6);
|
||||
|
||||
/* check if we are using the strict mode */
|
||||
if( $this->check_strict() == true) {
|
||||
/* if we use the strict mode, we get the date of the last
|
||||
operation */
|
||||
$last_date=$this->get_last_date();
|
||||
if ( cmpDate($e_date,$last_date) < 0 )
|
||||
throw new AcException('Vous utilisez le mode strict la dernière operation est du '
|
||||
.$last_date.' vous ne pouvez pas encoder à une date antérieure',15);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$fiche=new fiche($this->db);
|
||||
$fiche->get_by_qcode($e_bank_account);
|
||||
if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true)
|
||||
|
|
|
|||
|
|
@ -64,6 +64,21 @@ class Acc_Ledger_Purchase extends Acc_Ledger {
|
|||
if ( cmpDate($e_date,$min) < 0 ||
|
||||
cmpDate($e_date,$max) > 0)
|
||||
throw new AcException('Date et periode ne correspondent pas',6);
|
||||
|
||||
|
||||
/* check if we are using the strict mode */
|
||||
if( $this->check_strict() == true) {
|
||||
/* if we use the strict mode, we get the date of the last
|
||||
operation */
|
||||
$last_date=$this->get_last_date();
|
||||
if ( cmpDate($e_date,$last_date) < 0 )
|
||||
throw new AcException('Vous utilisez le mode strict la dernière operation est à la date du '
|
||||
.$last_date.' vous ne pouvez pas encoder à une '.
|
||||
' date antérieure dans ce journal',13);
|
||||
|
||||
}
|
||||
|
||||
/* check the account */
|
||||
$fiche=new fiche($this->db);
|
||||
$fiche->get_by_qcode($e_client);
|
||||
if ( $fiche->empty_attribute(ATTR_DEF_ACCOUNT) == true)
|
||||
|
|
|
|||
|
|
@ -57,6 +57,16 @@ class Acc_Ledger_Sold extends Acc_Ledger {
|
|||
{
|
||||
throw new AcException('Periode fermee',6);
|
||||
}
|
||||
/* check if we are using the strict mode */
|
||||
if( $this->check_strict() == true) {
|
||||
/* if we use the strict mode, we get the date of the last
|
||||
operation */
|
||||
$last_date=$this->get_last_date();
|
||||
if ( cmpDate($e_date,$last_date) < 0 )
|
||||
throw new AcException('Vous utilisez le mode strict la dernière operation est date du '
|
||||
.$last_date.' vous ne pouvez pas encoder à une date antérieure',13);
|
||||
|
||||
}
|
||||
|
||||
/* check that the datum is in the choosen periode */
|
||||
$per=new Periode($this->db);
|
||||
|
|
|
|||
|
|
@ -58,6 +58,11 @@ class dossier {
|
|||
echo_error ('Dossier inconnu ');
|
||||
exit('Dossier invalide');
|
||||
}
|
||||
$id=$_REQUEST['gDossier'];
|
||||
if ( is_numeric ($id) == 0 ||
|
||||
strlen($id)> 6 ||
|
||||
$id > 999999)
|
||||
exit('gDossier Invalide : '.$id);
|
||||
|
||||
}
|
||||
/*!\brief return a string to put to gDossier into a GET */
|
||||
|
|
@ -140,5 +145,7 @@ class dossier {
|
|||
foreach ($row as $idx=>$value) { $this->$idx=$value; }
|
||||
}
|
||||
|
||||
|
||||
static function get_version($p_cn) {
|
||||
return getDbValue($p_cn,'select val from version');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,17 +40,36 @@ class Own {
|
|||
}
|
||||
|
||||
}
|
||||
function check(&$p_value) {
|
||||
if ($p_value == 'MY_STRICT'
|
||||
&& $this->MY_STRICT != 'Y'
|
||||
&& $this->MY_STRICT != 'N')
|
||||
$p_value='N';
|
||||
$p_value=htmlentities($p_value);
|
||||
}
|
||||
/*!
|
||||
**************************************************
|
||||
* \brief Update a row
|
||||
* \brief save the parameter into the database by inserting or updating
|
||||
*
|
||||
*
|
||||
* \param $p_attr give the attribut name
|
||||
*
|
||||
*/
|
||||
function UpdateRow($p_attr) {
|
||||
$value=FormatString($this->{"$p_attr"});
|
||||
$Res=ExecSql($this->db,"update parameter set pr_value='$value' where pr_id='$p_attr'");
|
||||
function save($p_attr) {
|
||||
$value=FormatString($this->$p_attr);
|
||||
$this->check($p_attr);
|
||||
// check if the parameter does exù
|
||||
if ( getDbValue($this->db,'select count(*) from parameter where pr_id=$1',array($p_attr)) != 0 )
|
||||
{
|
||||
$Res=ExecSqlParam($this->db,"update parameter set pr_value=$1 where pr_id=$2",
|
||||
array($value,$p_attr));
|
||||
} else {
|
||||
|
||||
$Res=ExecSqlParam($this->db,"insert into parameter (pr_id,pr_value) values( $1,$2)",
|
||||
array($p_attr,$value));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
@ -59,17 +78,19 @@ class Own {
|
|||
*
|
||||
*
|
||||
*/
|
||||
function Save() {
|
||||
$this->UpdateRow('MY_NAME');
|
||||
$this->UpdateRow('MY_TVA');
|
||||
$this->UpdateRow('MY_STREET');
|
||||
$this->UpdateRow('MY_NUMBER');
|
||||
$this->UpdateRow('MY_CP');
|
||||
$this->UpdateRow('MY_TEL');
|
||||
$this->UpdateRow('MY_PAYS');
|
||||
$this->UpdateRow('MY_COMMUNE');
|
||||
$this->UpdateRow('MY_FAX');
|
||||
$this->UpdateRow('MY_ANALYTIC');
|
||||
function update() {
|
||||
|
||||
$this->save('MY_NAME');
|
||||
$this->save('MY_TVA');
|
||||
$this->save('MY_STREET');
|
||||
$this->save('MY_NUMBER');
|
||||
$this->save('MY_CP');
|
||||
$this->save('MY_TEL');
|
||||
$this->save('MY_PAYS');
|
||||
$this->save('MY_COMMUNE');
|
||||
$this->save('MY_FAX');
|
||||
$this->save('MY_ANALYTIC');
|
||||
$this->save('MY_STRICT');
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,9 @@ class Todo_List
|
|||
"title"=>"tl_title",
|
||||
"desc"=>"tl_desc",
|
||||
"owner"=>"use_login");
|
||||
var $cn;
|
||||
private $cn;
|
||||
private $tl_id,$tl_date,$tl_title,$use_login;
|
||||
|
||||
function __construct ($p_init) {
|
||||
$this->cn=$p_init;
|
||||
$this->tl_id=0;
|
||||
|
|
@ -62,10 +64,17 @@ class Todo_List
|
|||
else
|
||||
exit (__FILE__.":".__LINE__.'Erreur attribut inexistant');
|
||||
}
|
||||
public function check($p_idx,&$p_value) {
|
||||
if ( strcmp ($idx, 'tl_id') == 0 ) { if ( strlen($p_value) > 6 || isNumeric ($p_value) == false) return false;}
|
||||
if ( strcmp ($idx, 'tl_date') == 0 ) { if ( strlen($p_value) > 12 || isDate ($p_value) == false) return false;}
|
||||
if ( strcmp ($idx, 'tl_title') == 0 ) { $p_value=subsrt(htmlentities($p_value),0,120) ; return true;}
|
||||
if ( strcmp ($idx, 'tl_desc') == 0 ) { $p_value=substr(htmlentities($p_value),0,400) ; return true;}
|
||||
return true;
|
||||
}
|
||||
public function set_parameter($p_string,$p_value) {
|
||||
if ( array_key_exists($p_string,self::$variable) ) {
|
||||
$idx=self::$variable[$p_string];
|
||||
$this->$idx=$p_value;
|
||||
if ($this->check($idx,$p_value) == true ) $this->$idx=$p_value;
|
||||
}
|
||||
else
|
||||
exit (__FILE__.":".__LINE__.'Erreur attribut inexistant');
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ require_once ('config.inc.php');
|
|||
|
||||
|
||||
|
||||
define ("DBVERSION",51);
|
||||
define ("DBVERSION",52);
|
||||
|
||||
define ("MAX_COMPTE",4);
|
||||
define ('MAX_BUD_DETAIL',20);
|
||||
|
|
|
|||
|
|
@ -50,59 +50,6 @@ function GetPosteLibelle($p_dossier,$p_id,$is_cn=0)
|
|||
$l_poste=pg_fetch_row($Res,0);
|
||||
return $l_poste[0];
|
||||
}
|
||||
/*!
|
||||
* \brief Max of ligne definie dans le journal
|
||||
*
|
||||
*
|
||||
* \param $p_dossier dossier id
|
||||
* \param $p_jrn ledger id
|
||||
* gen :
|
||||
* - none
|
||||
* return:
|
||||
* -
|
||||
* \todo obsolete ?
|
||||
*/
|
||||
function GetNumberLine($p_dossier,$p_jrn)
|
||||
{
|
||||
$cn=DbConnect($p_dossier);
|
||||
$Res=ExecSql($cn,"select jrn_deb_max_line,jrn_cred_max_line from jrn_def where jrn_def_id=$p_jrn");
|
||||
if ( pg_NumRows($Res) == 0 ) {
|
||||
echo "<H2 class=\"warning\"> Journal non trouvé </H2>";
|
||||
// return (3,3);
|
||||
}
|
||||
$l_line=pg_fetch_array($Res,0);
|
||||
$l_deb=$l_line['jrn_deb_max_line'];
|
||||
$l_cred=$l_line['jrn_cred_max_line'];
|
||||
return array ($l_deb,$l_cred);
|
||||
|
||||
}
|
||||
/*!
|
||||
* \brief Cree un form pour prendre les postes
|
||||
*
|
||||
*
|
||||
* \param connection
|
||||
*
|
||||
* \return
|
||||
* morceau de code d'html qui contient un multiselect
|
||||
* pour les postes
|
||||
*
|
||||
*/
|
||||
function PosteForm($p_cn) {
|
||||
$Res=ExecSql($p_cn,"select pcm_val,pcm_lib from tmp_pcmn
|
||||
where pcm_val = any (select j_poste from jrnx) order by pcm_val::text");
|
||||
$Max=pg_NumRows($Res);
|
||||
if ($Max==0) return null;
|
||||
$ret='<SELECT NAME="poste[]" SIZE="15" MULTIPLE>';
|
||||
for ( $i = 0;$i< $Max;$i++) {
|
||||
$line=pg_fetch_array($Res,$i);
|
||||
$ret.=sprintf('<OPTION VALUE="%s" > %s - %s',
|
||||
$line['pcm_val'],
|
||||
$line['pcm_val'],
|
||||
$line['pcm_lib']);
|
||||
}//for
|
||||
$ret.="</SELECT>";
|
||||
return $ret;
|
||||
}
|
||||
/*!
|
||||
* \brief give the balance of an account
|
||||
*
|
||||
|
|
|
|||
|
|
@ -80,6 +80,9 @@ function ShowDossier($p_type,$p_first=0,$p_max=10,$p_Num=0) {
|
|||
* \return the connection
|
||||
*/
|
||||
function DbConnect($p_db=-1,$p_type='dossier') {
|
||||
if ( IsNumber($p_db) == false || strlen($p_db) > 5 )
|
||||
die ("Dossier invalide");
|
||||
|
||||
if ( $p_db==-1)
|
||||
$l_dossier=sprintf("%saccount_repository",domaine);
|
||||
else {
|
||||
|
|
@ -255,26 +258,7 @@ function GetJnt($p_dossier,$p_user)
|
|||
$R=pg_fetch_array($Res,0);
|
||||
return $R['jnt_id'];
|
||||
}
|
||||
/* GetDbId
|
||||
* Get the dos_id of a dossier
|
||||
* parm: name of the folder
|
||||
*/
|
||||
function GetDbId($p_name)
|
||||
{
|
||||
$cn=DbConnect();
|
||||
$r_sql=ExecSql($cn,"select dos_id from ac_dossier
|
||||
where dos_name='".$p_name."'");
|
||||
$num=pg_NumRows($r_sql);
|
||||
if ( $num == 0 ) {
|
||||
return 0;
|
||||
} else {
|
||||
$l_db=pg_fetch_array($r_sql,0);
|
||||
return $l_db['dos_id'];
|
||||
}
|
||||
|
||||
}
|
||||
/* CountSql
|
||||
* \brief Count the number of row
|
||||
/*! \brief Count the number of row
|
||||
*
|
||||
* \param $p_conn connection handler
|
||||
* \param $p_sql sql string
|
||||
|
|
|
|||
|
|
@ -56,226 +56,6 @@ function GetTvaRate($p_cn,$p_tva_id) {
|
|||
return $r;
|
||||
|
||||
}
|
||||
/*!
|
||||
**************************************************
|
||||
*\brief Compute the vat,
|
||||
* the fiche.f_id are in a_fiche
|
||||
* the quantity in a_quant
|
||||
*
|
||||
*
|
||||
*
|
||||
* \param $p_cn database connection
|
||||
* \param $a_fiche fiche id array
|
||||
* \param $a_quantity array
|
||||
* \param $a_price array
|
||||
* \param $ap_vat Array of tva id
|
||||
* \param $a_amount_tva for the expense, if the tva amount is given
|
||||
* \param $all = false if we reduce VAT
|
||||
* \return: array
|
||||
* a[tva_id] = amount vat
|
||||
*/
|
||||
function ComputeTotalVat($p_cn, $a_fiche,$a_quant,$a_price,$ap_vat,$a_vat_amount=null,$all=false )
|
||||
{
|
||||
echo_debug('user_common.php',__LINE__,"ComputeTotalVat $a_fiche $a_quant $a_price");
|
||||
foreach ( $a_fiche as $t=>$el) {
|
||||
echo_debug('user_common.php',__LINE__,"t $t e $el");
|
||||
}
|
||||
$r=null;
|
||||
// foreach goods
|
||||
//--
|
||||
foreach ( $a_fiche as $idx=>$element) {
|
||||
echo_debug ('user_common.php',__LINE__,"idx $idx element $element");
|
||||
// if the card id is null or empty
|
||||
if ( strlen(trim($element))==0) continue;
|
||||
|
||||
// Get the tva_id
|
||||
if ( $ap_vat != null and
|
||||
isNumber($ap_vat[$idx])== 1 and $ap_vat[$idx] != -1 )
|
||||
{
|
||||
$tva_id=$ap_vat[$idx];
|
||||
echo_debug('user_common',__LINE__,' tva_id is given');
|
||||
echo_debug('user_common',__LINE__,$ap_vat);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tva_id=GetFicheAttribut($p_cn,$element,ATTR_DEF_TVA);
|
||||
echo_debug('user_common',__LINE__,'retrieve tva_id');
|
||||
}
|
||||
echo_debug('user_common',__LINE__,"tva id $tva_id");
|
||||
if ( $tva_id == null ) continue;
|
||||
// for each fiche find the tva_rate and tva_id
|
||||
$a_vat=GetTvaRate($p_cn,$tva_id);
|
||||
|
||||
// Get the attribut price of the card(fiche)
|
||||
if ( $a_vat != null and $a_vat['tva_id'] != "" )
|
||||
{
|
||||
$flag=true;
|
||||
$a=$a_vat['tva_id'];
|
||||
// Compute vat for this item
|
||||
$vat_amount=round($a_price[$idx]*$a_vat['tva_rate']*$a_quant[$idx],2);
|
||||
|
||||
// if a vat amount is given
|
||||
if ( $a_vat_amount != null &&
|
||||
$a_vat_amount[$idx] != 0 )
|
||||
{
|
||||
$vat_amount= $a_vat_amount[$idx] ;
|
||||
echo_debug(__FILE__.':'.__LINE__.'- VAT_AMOUNT IS GIVEN '.$vat_amount);
|
||||
|
||||
}
|
||||
echo_debug('user_common',__LINE__,"vat amount = $vat_amount");
|
||||
// only the deductible vat
|
||||
if ( $all == false )
|
||||
{
|
||||
//variable containing the nd part
|
||||
// used when a card has both special rule for vat
|
||||
$nd1=0;
|
||||
|
||||
$base=$a_price[$idx]*$a_vat['tva_rate']*$a_quant[$idx];
|
||||
$nd_amount3=0;
|
||||
// if a part is not deductible then reduce vat_amount
|
||||
$nd3=GetFicheAttribut($p_cn,$a_fiche[$idx],ATTR_DEF_DEP_PRIV);
|
||||
if ( $nd3 != null && strlen(trim($nd3)) != 0 && $nd3 != 0 )
|
||||
{
|
||||
// if tva amount is given we do not compute it
|
||||
if ( $a_vat_amount != null &&
|
||||
$a_vat_amount[$idx] != 0 ) {
|
||||
$nd_amount3=round($a_vat_amount[$idx]*$nd3,2);
|
||||
$a_vat_amount[$idx]-=$nd_amount3;
|
||||
}
|
||||
else
|
||||
$nd_amount3=round($a_price[$idx]*$a_vat['tva_rate']*$a_quant[$idx]*$nd3,2);
|
||||
|
||||
$vat_amount=$vat_amount-$nd_amount3;
|
||||
|
||||
$base=$base*$nd3;
|
||||
// when using both vat, their sum cannot exceed 1, if = 1 then vat = 0
|
||||
$flag=false;
|
||||
}
|
||||
|
||||
|
||||
// if a part is not deductible then reduce vat_amount
|
||||
$nd=GetFicheAttribut($p_cn,$a_fiche[$idx],ATTR_DEF_TVA_NON_DEDUCTIBLE);
|
||||
if ( $nd != null && strlen(trim($nd)) != 0 && $nd != 0 )
|
||||
{
|
||||
// if tva amount is given we do not compute it
|
||||
if ( $a_vat_amount != null &&
|
||||
$a_vat_amount[$idx] != 0 )
|
||||
$nd_amount=round($a_vat_amount[$idx]*$nd,2);
|
||||
else
|
||||
$nd_amount=round($base*$nd,2);
|
||||
|
||||
|
||||
// problem with round
|
||||
$vat_amount=$vat_amount-$nd_amount;
|
||||
echo_debug('user_common.php',__LINE__,
|
||||
"A - TVA Attr fiche [$nd] nd amount [ $nd_amount ]".
|
||||
"vat amount [ $vat_amount]");
|
||||
$flag=false;
|
||||
// save nd into nd1
|
||||
$nd1=$nd;
|
||||
}
|
||||
// if a part is not deductible then reduce vat_amount
|
||||
$nd=GetFicheAttribut($p_cn,$a_fiche[$idx],ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP);
|
||||
if ( $nd != null && strlen(trim($nd)) != 0 && $nd != 0 )
|
||||
{
|
||||
// if tva amount is given we do not compute it
|
||||
if ( $a_vat_amount != null &&
|
||||
$a_vat_amount[$idx] != 0 )
|
||||
$nd_amount2=round($a_vat_amount[$idx]*$nd,2);
|
||||
else
|
||||
$nd_amount2=round($base*$nd,2);
|
||||
|
||||
$vat_amount=$vat_amount-$nd_amount2;
|
||||
// when using both vat, their sum cannot exceed 1, if = 1 then vat = 0
|
||||
if ( ($nd+$nd1) == 1)
|
||||
$vat_amount=0;
|
||||
echo_debug('user_common.php',__LINE__,
|
||||
"B - TVA Attr fiche [$nd] nd amount [ $nd_amount2 ]".
|
||||
"vat amount [ $vat_amount]");
|
||||
|
||||
$flag=false;
|
||||
}
|
||||
}
|
||||
|
||||
$r[$a]=isset ( $r[$a] )?$r[$a]+$vat_amount:$vat_amount;
|
||||
}
|
||||
|
||||
}
|
||||
echo_debug('user_common.php',__LINE__," return ".var_export($r,true));
|
||||
return $r;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
**************************************************
|
||||
*\brief Compute the vat for only one elt,
|
||||
* the fiche.f_id are in p_fiche
|
||||
* the quantity in p_quant
|
||||
*
|
||||
*
|
||||
*
|
||||
* \param $p_cn database connection
|
||||
* \param $p_fiche fiche id int
|
||||
* \param $p_quantity int
|
||||
* \param $p_price float
|
||||
* \param $p_tva_id
|
||||
* -
|
||||
* \return the amount of vat
|
||||
*/
|
||||
function ComputeVat($p_cn, $p_fiche,$p_quant,$p_price,$p_vat )
|
||||
{
|
||||
echo_debug('user_common.php',__LINE__,"function ComputeVat($p_cn,$p_fiche,$p_quant,$p_price,$p_vat )");
|
||||
// Get the tva_id
|
||||
if ( $p_vat != null and isNumber($p_vat)== 1 and $p_vat != -1)
|
||||
$tva_id=$p_vat;
|
||||
else
|
||||
$tva_id=GetFicheAttribut($p_cn,$p_fiche,ATTR_DEF_TVA);
|
||||
|
||||
echo_debug('user_common',__LINE__,"ComputeVat tva id = $tva_id");
|
||||
if ( $tva_id == null ) return -1;
|
||||
// find the tva_rate and tva_id
|
||||
$a_vat=GetTvaRate($p_cn,$tva_id);
|
||||
$vat_amount=null;
|
||||
// Get the attribut price of the card(fiche)
|
||||
if ( $a_vat != null and $a_vat['tva_id'] != "" )
|
||||
{
|
||||
$a=$a_vat['tva_id'];
|
||||
$vat_amount=$p_price*$a_vat['tva_rate']*$p_quant;
|
||||
}
|
||||
echo_debug('user_common',__LINE__,'return tva'.round($vat_amount,2));
|
||||
return round($vat_amount,2);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
**************************************************
|
||||
*\brief Get the account of tva_rate.tva_poste
|
||||
* return the credit or the debit account
|
||||
* \param $p_cn connection
|
||||
* \param $p_tva_id tva_rate.tva_id
|
||||
* \param $p_cred type ( d or credit)
|
||||
*
|
||||
* \return
|
||||
* return the credit or the debit account
|
||||
* null if error
|
||||
*/
|
||||
function GetTvaPoste($p_cn,$p_tva_id,$p_cred) {
|
||||
$Res=ExecSql($p_cn,"select tva_poste from tva_rate where tva_id=$p_tva_id");
|
||||
if ( pg_NumRows($Res) == 0 ) return null;
|
||||
$a=pg_fetch_array($Res,0);
|
||||
list ($deb,$cred)=split(",",$a['tva_poste']);
|
||||
if ( $p_cred=='c' ) return $cred;
|
||||
if ($p_cred=='d') return $deb;
|
||||
echo_error ("Invalid $p_cred in GetTvaRate");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
*\brief show all the lines of the asked jrn, uses also the $_GET['o'] for the sort
|
||||
|
|
@ -312,6 +92,8 @@ function ListJrn($p_cn,$p_jrn,$p_where="",$p_array=null,$p_value=0,$p_paid=0)
|
|||
$sort_description="<th> <A class=\"mtitle\" HREF=\"?$url&o=ca\">$image_asc</A>Description <A class=\"mtitle\" HREF=\"?$url&o=cd\">$image_desc</A></th>";
|
||||
$sort_amount="<th> <A class=\"mtitle\" HREF=\"?$url&o=ma\">$image_asc</A>Montant <A class=\"mtitle\" HREF=\"?$url&o=md\">$image_desc</A></th>";
|
||||
$sort_echeance="<th> <A class=\"mtitle\" HREF=\"?$url&o=ea\">$image_asc</A>Echéance <A class=\"mtitle\" HREF=\"?$url&o=ed\">$image_desc</A> </th>";
|
||||
|
||||
$own=new Own($p_cn);
|
||||
// if an order is asked
|
||||
if ( isset ($_GET['o']) )
|
||||
{
|
||||
|
|
@ -660,7 +442,7 @@ $sort_echeance="<th> <A class=\"mtitle\" HREF=\"?$url&o=ea\">$image_asc</A>Ech&
|
|||
|
||||
if ( $row['jr_valid'] == 'f' ) {
|
||||
$r.="<TD> Opération annulée</TD>";
|
||||
} else {
|
||||
} else if ( $own->MY_STRICT=='N' ) {
|
||||
// all operations can be removed either by setting to 0 the amount
|
||||
// or by writing the opposite operation if the period is closed
|
||||
$r.="<TD>";
|
||||
|
|
@ -756,66 +538,6 @@ function InsertStockGoods($p_cn,$p_j_id,$p_good,$p_quant,$p_type)
|
|||
");
|
||||
return $Res;
|
||||
}
|
||||
/*! withStock($p_cn,$p_f_id)
|
||||
**************************************************
|
||||
*\brief return true if we manage stock for it
|
||||
* value is stored in attr_value
|
||||
*
|
||||
* parm :
|
||||
* - $p_cn database connection
|
||||
* - $p_f_id fiche.f_id
|
||||
* gen :
|
||||
* - none
|
||||
* return:
|
||||
* none
|
||||
*/
|
||||
function withStock($p_cn,$p_f_id)
|
||||
{
|
||||
$a=getFicheAttribut($p_cn,$p_f_id, ATTR_DEF_STOCK);
|
||||
if ( $a == "1" ) return true;
|
||||
return false;
|
||||
|
||||
}
|
||||
/*! VerifyOperationDate ($p_cn,$p_user,$p_date)
|
||||
**************************************************
|
||||
*\brief Verify if
|
||||
* the date is a valid date
|
||||
* the date is in the default period
|
||||
* the period is not closed
|
||||
*
|
||||
* parm :
|
||||
* - db connection
|
||||
* - user
|
||||
* - date
|
||||
* gen :
|
||||
* - none
|
||||
* return:
|
||||
* - null if error or date if ok
|
||||
*/
|
||||
function VerifyOperationDate($p_cn,$p_periode,$p_date) {
|
||||
|
||||
// Verify the date
|
||||
if ( isDate($p_date) == null ) {
|
||||
echo_error("Invalid date $p_date");
|
||||
echo_debug('user_common.php',__LINE__,"Invalid date $p_date");
|
||||
echo "<SCRIPT> alert('INVALID DATE $p_date !!!!');</SCRIPT>";
|
||||
return null;
|
||||
}
|
||||
// userPref contient la periode par default
|
||||
list ($l_date_start,$l_date_end)=get_periode($p_cn,$p_periode);
|
||||
|
||||
// Date dans la periode active
|
||||
echo_debug ("date start periode $l_date_start date fin periode $l_date_end date demandee $p_date");
|
||||
if ( cmpDate($p_date,$l_date_start)<0 ||
|
||||
cmpDate($p_date,$l_date_end)>0 )
|
||||
{
|
||||
$msg="Not in the active periode please change your preference";
|
||||
echo_error($msg); echo_error($msg);
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
return null;
|
||||
}
|
||||
return $p_date;
|
||||
}
|
||||
|
||||
/*!
|
||||
**************************************************
|
||||
|
|
@ -904,28 +626,6 @@ function GetConcerned ($p_cn, $jr_id) {
|
|||
}
|
||||
return $r;
|
||||
}
|
||||
/*! GetGrpt($p_cn,$p_jr_id)
|
||||
**************************************************
|
||||
*\brief Return the jr_grpt_id from jrn where
|
||||
* jr_id = $p_jr_id
|
||||
*
|
||||
* parm :
|
||||
* - $p_jr_id jrn.jr_id
|
||||
* - $p_cn database connection
|
||||
* gen :
|
||||
* - none
|
||||
* return:
|
||||
* - return the jrn.jr_grpt_id or null
|
||||
*/
|
||||
function GetGrpt($p_cn,$p_jr_id)
|
||||
{
|
||||
$Res=ExecSql($p_cn,"select jr_grpt_id from jrn where jr_id=".$p_jr_id);
|
||||
if ( pg_NumRows($Res) == 0 ) {
|
||||
return null;
|
||||
}
|
||||
$r=pg_fetch_array($Res,0);
|
||||
return $r['jr_grpt_id'];
|
||||
}
|
||||
/*! UpdateComment ($p_cn,$p_jr_id,$p_comment)
|
||||
**************************************************
|
||||
*\brief Update comment in jrn
|
||||
|
|
@ -1075,46 +775,6 @@ function jrn_navigation_bar($p_offset,$p_line,$p_size=0,$p_page=1,$p_javascript=
|
|||
return $r;
|
||||
}
|
||||
|
||||
|
||||
/*!\brief Verify that a fiche has a valid ledger. It must be verify before
|
||||
* entering data into jrnx. Called from the form_verify_input
|
||||
* \param $p_cn database connx
|
||||
* \param $qcode the quick_code
|
||||
* \return null if an error occurs + a alert message in javascript
|
||||
* otherwise 1
|
||||
*/
|
||||
function CheckPoste($p_cn,$qcode)
|
||||
{
|
||||
// check if the ATTR_DEF_ACCOUNT is set
|
||||
$poste=GetFicheAttribut($p_cn,$qcode,ATTR_DEF_ACCOUNT);
|
||||
echo_debug('poste.php',__LINE__,"poste value = ".$poste."size = ".strlen(trim($poste)));
|
||||
if ( $poste == null )
|
||||
{
|
||||
$msg="La fiche ".$qcode." n\'a pas de poste comptable";
|
||||
echo_error($msg); echo_debug('poste.php',__LINE__,$msg);
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
return null;
|
||||
|
||||
}
|
||||
if ( strlen(trim($poste))==0 )
|
||||
{
|
||||
$msg="La fiche ".$qcode." n\'a pas de poste comptable";
|
||||
echo_error($msg); echo_debug('poste.php',__LINE__,$msg);
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
return null;
|
||||
}
|
||||
// Check that the account exists
|
||||
if ( CountSql($p_cn,
|
||||
"select * from tmp_pcmn where pcm_val=$poste") == 0 )
|
||||
{
|
||||
$msg=" Le poste comptable $poste de la fiche ".$qcode." n\'existe pas, il faudra le creer manuellement dans le module comptabilite, menu : avance->plan comptable";
|
||||
echo_error($msg); echo_debug('poste.php',__LINE__,$msg);
|
||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||
return null;
|
||||
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*!
|
||||
* \brief Clean the url, remove the $_GET offset,step, page and size
|
||||
* \param none
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
begin;
|
||||
insert into parameter values ('MY_STRICT','N');
|
||||
commit;
|
||||
Loading…
Add table
Add a link
Reference in a new issue