diff --git a/class_periode.php b/class_periode.php deleted file mode 100644 index 4aa2ae6d6..000000000 --- a/class_periode.php +++ /dev/null @@ -1,274 +0,0 @@ -cn=$p_cn; - } - function set_jrn($p_jrn) { - $this->jrn_def_id=$p_jrn; - } - function set_periode($pp_id){ - $this->p_id=$pp_id; - } - function is_closed() { - if ( $this->jrn_def_id != 0 ) - $sql="select status from jrn_periode ". - " where jrn_def_id=".$this->jrn_def_id. - " and p_id =".$this->p_id; - else - $sql="select p_closed as status from parm_periode ". - " where ". - " p_id =".$this->p_id; - $res=ExecSql($this->cn,$sql); - $status=pg_fetch_result($res,0,0); - echo_debug(__FILE__.':'.__LINE__.'- is_closed','return ',$status); - if ( $status == 'CL' || $status=='t' ||$status=='CE') - return 1; - return 0; - } - function is_open() { - if ( $this->jrn_def_id != 0 ) - $sql="select status from jrn_periode ". - " where jrn_def_id=".$this->jrn_def_id. - " and p_id =".$this->p_id; - else - $sql="select p_closed as status from parm_periode ". - " where ". - " p_id =".$this->p_id; - $res=ExecSql($this->cn,$sql); - $status=pg_fetch_result($res,0,0); - if ( $status == 'OP' || $status=='f' ) - return 1; - return 0; - } - function is_centralized() { - if ( $this->jrn_def_id != 0 ) - $sql="select status from jrn_periode ". - " where jrn_def_id=".$this->jrn_def_id. - " and p_id =".$this->p_id; - else - $sql="select p_centralized as status from parm_periode ". - " where ". - " p_id =".$this->p_id; - $res=ExecSql($this->cn,$sql); - $status=pg_fetch_result($res,0,0); - if ( $status == 'CE' || $status=='t' ) - return 1; - return 0; - } - function close() { - if ( $this->jrn_def_id == 0 ) { - ExecSql($this->cn,"update parm_periode set p_closed=true where p_id=". - $this->p_id); - ExecSql($this->cn,"update jrn_periode set status='CL' ". - " where p_id = ".$this->p_id); - - return; - }else { - ExecSql($this->cn,"update jrn_periode set status='CL' ". - " where jrn_def_id=".$this->jrn_def_id." and ". - " p_id = ".$this->p_id); - /* if all ledgers have this periode closed then synchro with - the table parm_periode - */ - $nJrn=CountSql( $this->cn,"select * from jrn_periode where ". - " p_id=".$this->p_id); - $nJrnPeriode=CountSql( $this->cn,"select * from jrn_periode where ". - " p_id=".$this->p_id." and status='CL'"); - - if ( $nJrnPeriode==$nJrn) - ExecSql($this->cn,"update parm_periode set p_closed=true where p_id=".$this->p_id); - return; - } - - } - function centralized() { - if ( $this->jrn_def_id == 0 ) { - ExecSql($this->cn,"update parm_periode set p_central=true"); - return; - }else { - ExecSql($this->cn,"update jrn_periode set status='CE' ". - " where ". - " p_id = ".$this->p_id); - return; - } - - } -/*! - * \brief Show all the periode and their status - * - * \param $p_cn database connection - * - * \return nothing - * - * - */ - - function display_form_periode() { - $str_dossier=dossier::get(); - - if ( $this->jrn_def_id==0 ) { - $Res=ExecSql($this->cn,"select p_id,to_char(p_start,'DD.MM.YYYY') as date_start,to_char(p_end,'DD.MM.YYYY') as date_end,p_central,p_closed,p_exercice - from parm_periode order by p_start,p_end"); - $Max=pg_NumRows($Res); - echo ''; - echo ""; - echo ''; - echo ''; - echo ''; - echo ""; - - for ($i=0;$i<$Max;$i++) { - $l_line=pg_fetch_array($Res,$i); - echo ''; - echo ''; - echo ''; - echo ''; - - if ( $l_line['p_closed'] == 't' ) { - $closed=($l_line['p_central']=='t')?'':''; - $change=''; - $remove=''; - } else { - $closed=''; - - } - echo ''; - echo dossier::hidden(); - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - - echo '
Date début Date fin Exercice
'.$l_line['date_start'].' '.$l_line['date_end'].' '.$l_line['p_exercice'].'CentraliséeFermée'; - $closed.=' Cloturer'; - $change=''; - $change.=' Changer"; - $remove=''; - $remove.=' Efface"; - - } - echo "$closed"; - echo $change; - - echo $remove; - - echo '
'; - echo '
'; - - } else { - $Res=ExecSql($this->cn,"select p_id,to_char(p_start,'DD.MM.YYYY') as date_start,to_char(p_end,'DD.MM.YYYY') as date_end,status,p_exercice - from parm_periode join jrn_periode using (p_id) where jrn_def_id=".$this->jrn_def_id." - order by p_start,p_end"); - $Max=pg_NumRows($Res); - $r=ExecSql($this->cn,'select jrn_Def_name from jrn_Def where jrn_Def_id='. - $this->jrn_def_id); - $jrn_name=pg_fetch_result($r,0,0); - echo '

Journal '.$jrn_name.'

'; - echo ''; - echo ""; - echo ''; - echo ''; - echo ''; - echo ""; - - for ($i=0;$i<$Max;$i++) { - $l_line=pg_fetch_array($Res,$i); - echo ''; - echo ''; - echo ''; - echo ''; - - if ( $l_line['status'] != 'OP' ) { - $closed=($l_line['status']=='CE')?'':''; - } else { - $closed=''; - } - echo "$closed"; - - echo ''; - - } - echo '
Date début Date fin Exercice
'.$l_line['date_start'].' '.$l_line['date_end'].' '.$l_line['p_exercice'].'CentraliseeFermée'; - $closed.=' Cloturer'; - $closed.='
'; - - } - } - function insert($p_date_start,$p_date_end,$p_exercice) { - if (isDate($p_date_start) == null || - isDate($p_date_end) == null || - strlen (trim($p_exercice)) == 0 || - (string) $p_exercice != (string)(int) $p_exercice) - { - return 1; - } - $p_id=NextSequence($this->cn,'s_periode'); - $sql=sprintf(" insert into parm_periode(p_id,p_start,p_end,p_closed,p_exercice)". - "values (%d,to_date('%s','DD.MM.YYYY'),to_date('%s','DD.MM.YYYY')". - ",'f','%s')", - $p_id, - $p_date_start, - $p_date_end, - $p_exercice); - try { - StartSql($this->cn); - $Res=ExecSql($this->cn,$sql); - $Res=ExecSql($this->cn,"insert into jrn_periode (jrn_def_id,p_id,status) ". - "select jrn_def_id,$p_id,'OP' from jrn_def"); - Commit($this->cn); - } catch (Exception $e) { - Rollback($this->cn); - echo_debug(__FILE__.':'.__LINE__.'- Periode insert','Exception ',$e); - echo_debug(__FILE__.':'.__LINE__.'- Periode insert','Exception ',$e->getMessage()); - return 1; - } - return 0; - } - static function test_me() { - $cn=DbConnect(dossier::id()); - $obj=new Periode($cn); - $obj->set_jrn(1); - $obj->display_form_periode(); - } -} diff --git a/html/.htaccess b/html/.htaccess deleted file mode 100644 index 4a4ab8d17..000000000 --- a/html/.htaccess +++ /dev/null @@ -1,11 +0,0 @@ - -php_value include_path .:../../include:../include:addon -php_flag magic_quotes_gpc off -php_flag session.auto_start on -php_value session.save_path /tmp -php_value max_execution_time 240 -php_value memory_limit 12M -# for php 5 php_value upload_tmp_dir /tmp -AddDefaultCharset utf-8 -php_value session.use_trans_sid 1 -php_value error_reporting 10239 diff --git a/html/confirm_remove.php b/html/confirm_remove.php deleted file mode 100644 index 6c1a85143..000000000 --- a/html/confirm_remove.php +++ /dev/null @@ -1,170 +0,0 @@ -theme,'onLoad="window.focus();"'); -$User->Check(); -if ($User->admin != 1) { - -print "

Désolé mais vous n' êtes pas administrateur

"; - - html_page_stop(); - return; -} -if ( ! isset ($_REQUEST['p_type'] ) || - ! isset ($_REQUEST['PHPSESSID']) || - ! isset ($_REQUEST['ob_id'])) -{ - print '

'; - print "Désolé vous n'avez pas appelé cette fonction avec les bons paramètres"; - print '

'; - print '
'; - return; -} -$cn=DbConnect(); - -switch($_REQUEST['p_type']) -{ - case 'db': - $msg="dossier"; - $name=getDbValue($cn,"select dos_name from ac_dossier where dos_id=".$_REQUEST['ob_id']); - if ( strlen(trim($name)) == 0 ) - { - echo "

$msg inexistant

"; - print '
'; - return; - } - - break; - case 'mod': - $msg="modèle"; - $name=getDbValue($cn,"select mod_name from modeledef where mod_id=".$_REQUEST['ob_id']); - if ( strlen(trim($name)) == 0 ) - { - echo "

$msg inexistant

"; - print '
'; - return; - } - if ( $_REQUEST['ob_id'] < 3 ) { - echo "

Désolé mais vous ne pouvez pas effacer les modèles de base

"; - print '
'; - return; - } - break; - default: - print '

'; - print "Désolé mais que voulez-vous effacer ? "; - print '

'; - print '
'; - return; - -} - -if ( isset($_POST['remove']) ) -{ - // Check if the radio is checked - // if yes removed the template and show a confirmation message - if ( isset($_POST['confirm']) ) - { - switch( $_POST['p_type'] ) - { - // Drop Modele - case 'mod': - $sql="drop database ".domaine."mod".$_POST['ob_id']; - ob_start(); - if ( pg_query($cn,$sql)==false) { - ob_end_clean(); - - echo "

- Base de donnée ".domaine."mod".$_POST['ob_id']." est accèdée, déconnectez-vous d'abord

"; - print '
'; - exit; - } - ob_flush(); - $sql="delete from modeledef where mod_id=".$_POST['ob_id']; - ExecSql($cn,$sql); - print '

'; - print "Voilà le modèle $name est effacé"; - print "

"; - print '
'; - break; - case 'db': - $sql="drop database ".domaine."dossier".$_POST['ob_id']; - ob_start(); - if ( pg_query($cn,$sql)==false) { - ob_end_clean(); - - echo "

- Base de donnée ".domaine."mod".$_POST['ob_id']." est accèdée, déconnectez-vous d'abord

"; - print '
'; - exit; - } - ob_flush(); - $sql="delete from priv_user where priv_id in (select jnt_id from jnt_use_dos where dos_id=".$_REQUEST['ob_id'].")"; - ExecSql($cn,$sql); - $sql="delete from jnt_use_dos where dos_id=".$_REQUEST['ob_id']; - ExecSql($cn,$sql); - $sql="delete from ac_dossier where dos_id=".$_REQUEST['ob_id']; - ExecSql($cn,$sql); - print '

'; - print "Voilà le modèle $name est effacé"; - print "

"; - print '
'; - - } - } - else - { - print '

'; - print "$msg $name n'est pas effacé"; - print '

'; - print "
"; - print "Vous n'avez pas coché la case"; - print '
'; - - } -} -else -{ - print "

Confirmer vous l'effacement du $msg $name ?

"; -?> -
- - - Cochez cette case si vous voulez vraiment effacer - -
- -
-Check(); - -include_once ("check_priv.php"); - -include_once ("user_menu.php"); - -$cn=DbConnect($gDossier); - -$User->can_request($cn,EXP_IMP_ECR); - -if ( !isset ($_GET['p_periode'])) { - echo 'Erreur : aucune periode demandée'; - exit(0); -} -$sql_from=get_array($cn,"select min(p_id) from parm_periode where p_exercice=".$_GET['p_periode']); - -$sql_to=get_array($cn,"select max(p_id) from parm_periode where p_exercice=".$_GET['p_periode']); - -$ret=get_array($cn,"select distinct j_poste::text - from jrnx inner join tmp_pcmn on (pcm_val=j_poste) - where - j_tech_per >= ".$sql_from[0]['min']." and - j_tech_per <= ".$sql_to[0]['max']." and j_poste::text not like '7%' - and j_poste::text not like '6%' - order by j_poste::text"); -if ( $ret == null ) {echo 'Rien à exporter'; exit();} -printf ("OUVERTURE\n"); -// check if the account are balanced -$sum=0; -foreach ($ret as $poste_id) { - - $Poste=new Acc_Account_Ledger($cn,$poste_id['j_poste']); - // fill the object - $Poste->load(); - // build sql stmt - $sql="j_tech_per >=". $sql_from[0]['min']." and j_tech_per <=".$sql_to[0]['max']; - $result=$Poste->get_solde_detail($sql ); - $Poste->label=str_replace(';','',$Poste->label); - - if ( $result['solde'] == 0 ) continue; - if ( $result['debit'] > $result ['credit'] ) { - printf ("d;%d;%s;%12.4f\n",$Poste->id,$Poste->label,$result['solde']); - $sum+=$result['solde']; - } else { - printf ("c;%d;%s;%12.4f\n",$Poste->id,$Poste->label,$result['solde']); - $sum-=$result['solde']; - } -} -// $sum must be equal to 0 -// $sum > 0 then deb is too big -// $sum < 0 then cred is too big -// rounded problem -if ( round($sum,4) != 0.0 ) -{ - printf("ATTENTION : COMPTE NON EQUILIBRE\n "); - $msg = ($sum > 0)?" Debit plus grand de $sum":"Credit plus grand de $sum"; - printf ("DIFFERENCE = $msg \n"); - -} -?> diff --git a/html/send_jrn_pdf.php b/html/send_jrn_pdf.php deleted file mode 100644 index 6039e24c9..000000000 --- a/html/send_jrn_pdf.php +++ /dev/null @@ -1,147 +0,0 @@ -get_name().$centr; - $ret=""; - $pdf=& new Cezpdf("A4"); - $pdf->selectFont('./addon/fonts/Helvetica.afm'); - -$offset=0;$limit=25;$step=25; -$rap_deb=0;$rap_cred=0; -while (1) { - $a=0; - list ($a_jrn,$tot_deb,$tot_cred)=get_dataJrnPdf($cn,$_GET,$limit,$offset); - echo_debug('send_jrn_pdf.php',__LINE__,"Total debit $tot_deb,credit $tot_cred"); - - if ( $a_jrn==null) break; - $offset+=$step; - foreach ($a_jrn as $key=>$element) { - echo_debug('send_jrn_pdf.php',__LINE__,"$key => $element"); - foreach ($element as $c1=>$c2) - echo_debug('send_jrn_pdf.php',__LINE__,"Array is $c1 => $c2"); - } - $first_id=$a_jrn[0]['j_id']; - $Exercice=get_exercice($cn,$a_jrn[0]['periode']); - - - list($rap_deb,$rap_cred)=get_rappel($cn,$first_id,$_GET["p_id"],$Exercice,FIRST, - $_GET['filter'], - $l_centr - ); - echo_debug('send_jrn_pdf.php',__LINE__,"MONTANT $rap_deb,$rap_cred"); - echo_debug('send_jrn_pdf.php',__LINE__," list($rap_deb,$rap_cred)=get_rappel($cn,$first_id,".$_GET["p_id"].",$Exercice,FIRST)"); - $pdf->ezText($name_jrn,30); - - if ( $l_centr == 1 ) { - // si centralisé montre les montants de rappel - $str_debit=sprintf( "report Débit % 10.2f",$rap_deb); - $str_credit=sprintf("report Crédit % 10.2f",$rap_cred); - $pdf->ezText($str_debit,12,array('justification'=>'right')); - $pdf->ezText($str_credit,12,array('justification'=>'right')); - } - - $pdf->ezTable($a_jrn, - array ('internal'=>'Opération', - 'j_date' => 'Date', - 'poste'=>'Poste', - 'description' => 'Description', - 'deb_montant'=> 'Débit', - 'cred_montant'=>'Crédit')," ", - array('shaded'=>0,'showHeadings'=>1,'width'=>500, - 'cols'=>array('deb_montant'=> array('justification'=>'right'), - 'cred_montant'=> array('justification'=>'right')))); - $a=1; - // Total Page - $apage=array(array('deb'=>sprintf("%8.2f",$tot_deb),'cred'=>$tot_cred)); - foreach ($apage as $key=>$element) echo_debug('send_jrn_pdf.php',__LINE__,"apage $key => $element"); - $pdf->ezTable($apage, - array ( - 'deb'=> 'Total Débit', - 'cred'=>'Total Crédit')," ", - array('shaded'=>0,'showHeadings'=>1,'width'=>200, - 'xPos'=>'right','xOrientation'=>'left', - 'cols'=>array('deb'=> array('justification'=>'right'), - 'cred'=> array('justification'=>'right')))); - - $count=count($a_jrn)-1; - $last_id=$a_jrn[$count]['j_id']; - $Exercice=get_exercice($cn,$a_jrn[$count]['periode']); - if ( $l_centr == 1) { - // Montant de rappel si centralisé - list($rap_deb,$rap_cred)=get_rappel($cn,$last_id,$_GET["p_id"],$Exercice,LAST,$_GET['filter'],$l_centr); - $str_debit=sprintf( "à reporter Débit % 10.2f",$rap_deb); - $str_credit=sprintf("à reporter Crédit % 10.2f",$rap_cred); - $pdf->ezText($str_debit,12,array('justification'=>'right')); - $pdf->ezText($str_credit,12,array('justification'=>'right')); - } - //New page - $pdf->ezNewPage(); -} -if ( $a == 1 ) { - $apage=array('deb'=>$tot_deb,'cred'=>$tot_cred); -$pdf->ezTable($apage, - array ( - 'deb'=> 'Total Débit', - 'cred'=>'Total Crédit')," ", - array('shaded'=>0,'showHeadings'=>1,'width'=>500, - 'cols'=>array('deb'=> array('justification'=>'right'), - 'cred'=> array('justification'=>'right')))); - $count=count($a_jrn)-1; - $last_id=$a_jrn[$count]['j_id']; - $Exercice=get_exercice($cn,$a_jrn[$count]['periode']); - - list($rap_deb,$rap_cred)=get_rappel($cn,$last_id,$_GET["p_id"],$Exercice,LAST,$l_GET['filter'],$l_centr); - $str_debit=sprintf( "à reporter Débit % 10.2f",$rap_deb); - $str_credit=sprintf("à reporter Crédit % 10.2f",$rap_cred); - $pdf->ezText($str_debit,12,array('justification'=>'right')); - $pdf->ezText($str_credit,12,array('justification'=>'right')); - -} -$pdf->ezStream(); - -?> diff --git a/html/send_poste_pdf.php b/html/send_poste_pdf.php deleted file mode 100644 index ba5736926..000000000 --- a/html/send_poste_pdf.php +++ /dev/null @@ -1,97 +0,0 @@ -$element) { - ${"$key"}=$element; -} -if ( isset ( $all_poste) ){ //choisit de voir tous les postes - $r_poste=ExecSql($cn,"select pcm_val from tmp_pcmn where pcm_val = any ". - " (select j_poste from jrnx) order by pcm_val::text"); - $nPoste=pg_numRows($r_poste); - for ( $i=0;$i<$nPoste;$i++) { - $t_poste=pg_fetch_array($r_poste,$i); - $poste[]=$t_poste['pcm_val']; - } -} - - - $ret=""; - $pdf=& new Cezpdf(); - $pdf->selectFont('./addon/fonts/Helvetica.afm'); -$cond=CreatePeriodeCond($periode); -//$rap_deb=0;$rap_cred=0; -for ( $i =0;$iezText($Libelle,30); - $pdf->ezTable($array, - array ('jr_internal'=>'Opération', - 'j_date' => 'Date', - 'jrn_name'=>'Journal', - 'description'=>'Description', - 'deb_montant'=> 'Montant', - 'cred_montant'=> 'Montant' - ),$Libelle, - array('shaded'=>0,'showHeadings'=>1,'width'=>500, - 'cols'=>array('montant'=> array('justification'=>'right'), - ))); -$str_debit=sprintf("Débit % 12.2f",$tot_deb); -$str_cred=sprintf("Crédit % 12.2f",$tot_cred); -$diff_solde=$tot_deb-$tot_cred; -if ( $diff_solde < 0 ) { - $solde=" C "; - $diff_solde*=-1; - } else - { - $solde=" D "; - } -$str_solde=sprintf(" Solde %s %12.2f",$solde,$diff_solde); - - $pdf->ezText($str_debit,10,array('justification'=>'right')); - $pdf->ezText($str_cred,10,array('justification'=>'right')); - $pdf->ezText($str_solde,14,array('justification'=>'right')); - - //New page - //$pdf->ezNewPage(); -} - -$pdf->ezStream(); - -?> diff --git a/html/style-color.css b/html/style-color.css index e606b7ea0..a6980f47d 100644 --- a/html/style-color.css +++ b/html/style-color.css @@ -242,6 +242,20 @@ tr.odd { tr { font-size:10px; } + +tr.odd:hover td +{ + text-decoration:none; + background-color:blue; + color:white; +} +tr.even:hover td +{ + text-decoration:none; + background-color:blue; + color:white; +} + td.odd{ background-color:#DDE6FF ; border-size:0px; diff --git a/include/class_parm_code.php b/include/class_parm_code.php deleted file mode 100644 index 97e05340b..000000000 --- a/include/class_parm_code.php +++ /dev/null @@ -1,154 +0,0 @@ -db=$p_cn; - $this->p_code=$p_id; - if ( $p_id != -1 ) - $this->Get(); - } -/*! - ************************************************** - * \brief - * Load all parmCode - * return an array of parm_code object - * - * \return array - */ - - function LoadAll() { - $sql="select * from parm_code order by p_code"; - $Res=ExecSql($this->db,$sql); - $r= pg_fetch_all($Res); - $idx=0; - $array=array(); - - if ( $r === false ) return null; - foreach ($r as $row ) - { - $o=new parm_code($this->db,$row['p_code']); - $array[$idx]=$o; - $idx++; - } - - return $array; - } - /*! - ************************************************** - * \brief update a parm_object into the database - * p_code is _not_ updatable - * \return - * nothing - */ - function Save() - { - // if p_code=="" nothing to save - if ( $this->p_code== -1) return; - $this->p_comment=FormatString($this->p_comment); - $this->p_value=FormatString($this->p_value); - $this->p_code=FormatString($this->p_code); - $sql="update parm_code set ". - "p_comment='".$this->p_comment."' ". - ",p_value='".$this->p_value."' ". - "where p_code='".$this->p_code."'"; - $Res=ExecSql($this->db,$sql); - } -/*! - ************************************************** - * \brief Display an object, with the tag - * - * \return - * string - */ - function Display() - { - $r=""; - $r.= ''.$this->p_code.''; - $r.= ''.$this->p_comment.''; - $r.= ''.$this->p_value.''; - - return $r; - } -/*! - ************************************************** - * \brief Display a form to enter info about - * a parm_code object with the tag - * - * \return string - */ - function Input() - { - $comment=new widget("text"); - $comment->name='p_comment'; - $comment->value=$this->p_comment; - $value=new widget("text"); - $value->name='p_value'; - $value->value=$this->p_value; - $poste=new widget("text"); - $poste->SetReadOnly(true); - $poste->name='p_code'; - $poste->value=$this->p_code; - $r=""; - $r.= ''.$poste->IOValue().''; - $r.= ''.$comment->IOValue().''; - $r.= ''.$value->IOValue().''; - - return $r; - - } - -/*! - ************************************************** - * \brief - * Complete a parm_code object thanks the p_code - * - * \return array - */ - - function Get() { - if ( $this->p_code == -1 ) return "p_code non initialisé"; - $sql=sprintf("select * from parm_code where p_code='%s' ", - $this->p_code); - $Res=ExecSql($this->db,$sql); - - if ( pg_NumRows($Res) == 0 ) return 'INCONNU'; - $row= pg_fetch_array($Res,0); - $this->p_value=$row['p_value']; - $this->p_comment=$row['p_comment']; - - } - -} diff --git a/include/class_rapport.php b/include/class_rapport.php deleted file mode 100644 index e69b2d9eb..000000000 --- a/include/class_rapport.php +++ /dev/null @@ -1,350 +0,0 @@ -db=$p_cn; - $this->id=$p_id; - $this->name='Nouveau'; - $this->aRapport_row=null; - } - /*!\brief Return the report's name - */ - function get_name() { - $ret=execSql($this->db,"select fr_label from formdef where fr_id=".$this->id); - if (pg_NumRows($ret) == 0) return $this->name; - $a=pg_fetch_array($ret,0); - $this->name=$a['fr_label']; - return $this->name; - } - /*!\brief return all the row and parse formula - * from a report - * \param $p_start start periode - * \param $p_end end periode - * \param $p_type_date type of the date : periode or calendar - */ - - function get_row($p_start,$p_end,$p_type_date) { - - $Res=ExecSql($this->db,"select fo_id , - fo_fr_id, - fo_pos, - fo_label, - fo_formula, - fr_label from form - inner join formdef on fr_id=fo_fr_id - where fr_id =".$this->id. - "order by fo_pos"); - $Max=pg_NumRows($Res); - if ($Max==0) { $this->row=0;return null;} - $col=array(); - for ($i=0;$i<$Max;$i++) { - $l_line=pg_fetch_array($Res,$i); - $col[]=ParseFormula($this->db, - $l_line['fo_label'], - $l_line['fo_formula'], - $p_start, - $p_end, - true, - $p_type_date - ); - - } //for ($i - $this->row=$col; - return $col; - } -/*! - * \brief Display a form for encoding a new report or update one - * - * \param $p_line number of line - * - */ -function form($p_line=0) { - $search_poste=new widget('JS_SEARCH_POSTE'); - $search_poste->extra='not'; - $r=""; - if ($p_line == 0 ) $p_line=count($this->aRapport_row); - $r.= dossier::hidden(); - $r.= widget::hidden('line',$p_line); - $r.= widget::hidden('fr_id',$this->id); - $wForm=new widget("text"); - $r.="Nom du rapport : "; - $r.=$wForm->IOValue('form_nom',$this->name); - - $r.= ''; - $r.= ""; - $r.= ""; - $r.= ""; - $r.= ""; - - $r.= ''; - $wName=new widget("text"); - $wName->size=50; - $wPos=new widget("text"); - $wPos->size=3; - $wForm=new widget("text"); - $wForm->size=35; - for ( $i =0 ; $i < $p_line;$i++) { - - $r.= ""; - - $r.= "'; - - - $r.= "'; - - $r.= "'; - - $r.= ""; - } - - $r.= "
Position Texte Formule
"; - $wPos->value=( isset($this->aRapport_row[$i]->fo_pos))?$this->aRapport_row[$i]->fo_pos:$i+1; - $r.=$wPos->IOValue("pos".$i); - $r.= '"; - $wName->value=( isset($this->aRapport_row[$i]->fo_label))?$this->aRapport_row[$i]->fo_label:""; - $r.=$wName->IOValue("text".$i); - $r.= '"; - $wForm->value=( isset($this->aRapport_row[$i]->fo_formula))?$this->aRapport_row[$i]->fo_formula:""; - $r.=$wForm->IOValue("form".$i); - - $r.= '
"; - $wButton=new widget("button"); - $wButton->javascript=' rapport_add_row();'; - $wButton->label="Ajout d'une ligne"; - $r.=$wButton->IOValue(); - return $r; - -} - /*!\brief save into form and form_def - */ - function save() { - - if ( strlen(trim($this->name)) == 0 ) - return; - if ( $this->id == 0 ) - $this->insert(); - else - $this->update(); - - } - function insert() { - try { - startSql($this->db); - $ret_sql=ExecSqlParam($this->db, - "insert into formdef (fr_label) values($1) returning fr_id", - array($this->name) - ); - $this->id=pg_fetch_result($ret_sql,0,0); - $ix=1; - foreach ( $this->aRapport_row as $row) { - if ( strlen(trim($row->get_parameter("name"))) != 0 && - strlen(trim($row->get_parameter("formula"))) != 0 ) - { - $ix=($row->get_parameter("position")!="")?$row->get_parameter("position"):$ix; - $row->set_parameter("position",$ix); - $ret_sql=ExecSqlParam($this->db, - "insert into form (fo_fr_id,fo_pos,fo_label,fo_formula)". - " values($1,$2,$3,$4)", - array($this->id, - $row->fo_pos, - $row->fo_label, - $row->fo_formula) - ); - } - } - - } catch (Exception $e) { - Rollback($this->db); - echo $e->getMessage(); - } - Commit($this->db); - - } - function update() { - try { - startSql($this->db); - $ret_sql=ExecSqlParam($this->db, - "update formdef set fr_label=$1 where fr_id=$2", - array($this->name,$this->id)); - $ret_sql=ExecSqlParam($this->db, - "delete from form where fo_fr_id=$1", - array($this->id)); - $ix=0; - - foreach ( $this->aRapport_row as $row) { - if ( strlen(trim($row->get_parameter("name"))) != 0 && - strlen(trim($row->get_parameter("formula"))) != 0 ) - { - - $ix=($row->get_parameter("position")!="")?$row->get_parameter("position"):$ix; - $row->set_parameter("position",$ix); - $ret_sql=ExecSqlParam($this->db, - "insert into form (fo_fr_id,fo_pos,fo_label,fo_formula)". - " values($1,$2,$3,$4)", - array($this->id, - $row->fo_pos, - $row->fo_label, - $row->fo_formula) - ); - } - } - - - }catch (Exception $e) { - Rollback($this->db); - echo $e->getMessage(); - } - Commit($this->db); - } - /*!\brief fill a form thanks an array, usually it is $_POST - *\param $p_array keys = fr_id, form_nom,textXX, formXX, posXX where - XX is an number - */ - function from_array($p_array) { - $this->id=(isset($p_array['fr_id']))?$p_array['fr_id']:0; - $this->name=(isset($p_array['form_nom']))?$p_array['form_nom']:""; - $ix=0; - - $rr=new Rapport_Row(); - $rr->set_parameter("form_id",$this->id); - $rr->set_parameter('database',$this->db); - - $this->aRapport_row=$rr->from_array($p_array); - - - } - /*!\brief the fr_id MUST be before called - */ - - - function load() { - $sql=ExecSqlParam($this->db, - "select fr_label from formdef where fr_id=$1", - array($this->id)); - if ( pg_NumRows($sql) == 0 ) return; - $this->name=pg_fetch_result($sql,0,0); - $sql=ExecSqlParam($this->db, - "select fo_id,fo_pos,fo_label,fo_formula ". - " from form ". - " where fo_fr_id=$1 order by fo_pos", - array($this->id)); - $f=pg_fetch_all($sql); - $array=array(); - if ( ! empty($f) ) { - foreach ($f as $r) { - $obj=new Rapport_Row(); - $obj->set_parameter("name",$r['fo_label']); - $obj->set_parameter("id",$r['fo_id']); - $obj->set_parameter("position",$r['fo_pos']); - $obj->set_parameter("formula",$r['fo_formula']); - $obj->set_parameter('database',$this->db); - $obj->set_parameter('form_id',$this->id); - $array[]=clone $obj; - } - } - $this->aRapport_row=$array; - - } - function delete() { - $ret=ExecSqlParam($this->db, - "delete from formdef where fr_id=$1", - array($this->id) - ); - } - /*!\brief get a list from formdef of all defined form - * - *\return array of object rapport - * - */ - function get_list() - { - $sql="select fr_id,fr_label from formdef order by fr_label"; - $ret=ExecSql($this->db,$sql); - if ( pg_NumRows($ret) == 0 ) return array(); - $array=pg_fetch_all($ret); - $obj=array(); - foreach ($array as $row) { - $tmp=new Rapport($this->db); - $tmp->id=$row['fr_id']; - $tmp->name=$row['fr_label']; - $obj[]=clone $tmp; - } - return $obj; - } - /*!\brief To make a SELECT button with the needed value, it is used - *by the SELECT widget - *\return string with html code - */ - function make_array() { - $sql=make_array($this->db,"select fr_id,fr_label from formdef order by fr_label"); - return $sql; - } - - function test_me() { - $cn=DbConnect(dossier::id()); - $a=new Rapport($cn); - print_r($a->get_list()); - $array=array("text0"=>"test1", - "form0"=>"7%", - "text1"=>"test2", - "form1"=>"6%", - "fr_id"=>110, - "form_nom"=>"Tableau" - ); - $a->from_array($array); - print_r($a); - echo '
'; - echo $a->form(10); - echo ''; - /* Add a line should be a javascript see comptanalytic */ - // $r.= ''; - echo ''; - - echo "
"; - if ( isset ($_POST['update'])) { - $b=new Rapport($cn); - $b->from_array($_POST); - echo '
'; - print_r($b); - } - } -} - -?> diff --git a/include/class_rapport_row.php b/include/class_rapport_row.php deleted file mode 100644 index ef24b3d31..000000000 --- a/include/class_rapport_row.php +++ /dev/null @@ -1,111 +0,0 @@ -"fo_label", - "formula"=>"fo_formula", - "id"=>"fo_id", - "position"=>"fo_pos", - "form_id"=>"fo_fr_id", - "database"=>"db" - ); - function __construct ($p_name=null,$p_formula=null) { - $this->set_parameter("id",0); - - $this->set_parameter("name",$p_name); - $this->set_parameter("formula",$p_formula); - } - 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'); - } - 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; - } - else - exit (__FILE__.":".__LINE__."$p_string ".'Erreur attribut inexistant'); - - - } - public function get_info() { - return var_export(self::$variable,true); - } - /*!\brief Convert an array into an array of row_rapport object - * the fo_id is 0, position = 0, the fo_frd_id (form_id) is - * the one of the current object, the db is also the current one - *\param $p_array contains the value - *\return an array of Rapport_Row object - */ - public function from_array($p_array) { - extract ($p_array); - $ret=array(); - $ix=0; - $found=0; - foreach ( $p_array as $r) { - - if ( isset(${'form'.$ix}) && isset ( ${'text'.$ix} )) { - $obj=new Rapport_Row( ${'text'.$ix},${'form'.$ix}); - if ( isset(${'pos'.$ix}) && isNumber(${'pos'.$ix})==1 ) - $obj->set_parameter("position",$ix); - else { - $obj->set_parameter("position",$found); - $found++; - } - $obj->fo_id=0; - $obj->fo_fr_id=$this->fo_fr_id; - $obj->db=$this->db; - - $ret[]=clone $obj; - } - $ix++; - - } - return $ret; - } - function test_me() - { - $cn=DbConnect(dossier::id()); - $a=new Rapport_Row(); - $array=array("text0"=>"test1", - "form0"=>"7%", - "text1"=>"test2", - "form1"=>"6%" - ); - - $b=$a->from_array($array); - print_r($b); - echo $a->get_info(); - } -} diff --git a/include/depense.inc.php b/include/depense.inc.php deleted file mode 100644 index 04701fb43..000000000 --- a/include/depense.inc.php +++ /dev/null @@ -1,461 +0,0 @@ -Liste'; -$tag_list_sel='Liste'; -$tag_unpaid='Non Paye'; -$tag_unpaid_sel='Non Paye'; - -$msg_tva='Si le montant de TVA est égal à 0, il sera automatiquement calculé'; - -// First we show the menu -// If nothing is asked the propose a blank form -// to enter a new invoice -if ( ! isset ($_REQUEST['p_jrn'])) { - // no journal are selected so we select the first one - $p_jrn=GetFirstJrnIdForJrnType(dossier::id(),'ACH'); - -} else -{ - $p_jrn=$_REQUEST['p_jrn']; -} -// for the back button -$retour=""; -$h_url=""; - -if ( isset ($_REQUEST['url'])) -{ - $retour=widget::button_href('Retour',urldecode($_REQUEST['url'])); - - $h_url=sprintf('',urldecode($_REQUEST['url'])); -} - -$sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:""; -//-------------------------------------------------------------------------------- -// use a predefined operation -//-------------------------------------------------------------------------------- -if ( $sub_action=="use_opd" ) { -echo '
'; -echo ShowMenuJrnUser($gDossier, - 'ACH', - $p_jrn, - $tag_list.$tag_unpaid); -echo '
'; - - $op=new Pre_op_ach($cn); - $op->set_od_id($_REQUEST['pre_def']); - $p_post=$op->compute_array(); - echo_debug(__FILE__.':'.__LINE__.'- ','p_post = ',$p_post); - // Submit button in the form - $submit=' - '; - - $form=FormAchInput($cn,$_GET['p_jrn'],$User->get_periode(),$p_post,$submit,false,$p_post['nb_item']); - // $form=FormAchInput($cn,$p_jrn,$User->get_periode(),$_POST,$submit,false,$nb_item); - - echo '
'; - echo $form; - //-------------------- - // predef op. - echo '
'; - $op=new Pre_operation($cn); - $op->p_jrn=$p_jrn; - $op->od_direct='f'; - - $hid=new widget("hidden"); - echo $hid->IOValue("p_action","depense"); - echo dossier::hidden(); - echo $hid->IOValue("p_jrn",$p_jrn); - echo $hid->IOValue("jrn_type","ACH"); - echo $hid->IOValue("sa","use_opd"); - - if ($op->count() != 0 ) - echo widget::submit('use_opd','Utilisez une op.prédéfinie'); - echo $op->show_button(); - - echo '
'; - - echo '
'; - exit(); - } - -//----------------------------------------------------- -// If a list of depense is asked -// -if ( $sub_action == "list") -{ - // show the menu with the list item selected - echo '
'; - echo ShowMenuJrnUser($gDossier,'ACH',0,$tag_list_sel.$tag_unpaid); - echo '
'; - // Ask to update payment - if ( isset ( $_GET['paid'])) - { - // reset all the paid flag because the checkbox is post only - // when checked - foreach ($_GET as $name=>$paid) - { - list($ad) = sscanf($name,"set_jr_id%d"); - if ( $ad == null ) continue; - $sql="update jrn set jr_rapt='' where jr_id=$ad"; - $Res=ExecSql($cn,$sql); - - } - // set a paid flag for the checked box - foreach ($_GET as $name=>$paid) - { - list ($id) = sscanf ($name,"rd_paid%d"); - - if ( $id == null ) continue; - - $paid=($paid=='on')?'paid':''; - $sql="update jrn set jr_rapt='$paid' where jr_id=$id"; - $Res=ExecSql($cn,$sql); - } - - } - - echo '
'; - - - - echo '
'; - echo dossier::hidden(); - $hid=new widget("hidden"); - - $hid->name="p_action"; - $hid->value="depense"; - echo $hid->IOValue(); - - - $hid->name="sa"; - $hid->value="list"; - echo $hid->IOValue(); - - - - $w=new widget("select"); - // filter on the current year - $filter_year=" where p_exercice='".$User->get_exercice()."'"; - - $periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end",1); - // User is already set User=new User($cn); - $current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode(); - $w->selected=$current; - - echo 'Période '.$w->IOValue("p_periode",$periode_start); - $qcode=(isset($_GET['qcode']))?$_GET['qcode']:""; - echo JS_SEARCH_CARD; - $w=new widget('js_search_only'); - $w->name='qcode'; - $w->value=$qcode; - $w->label=''; - $w->extra='all'; - $w->table=0; - $sp= new widget("span"); - echo $w->IOValue(); - echo $sp->IOValue("qcode_label","QuickCode",$qcode); - - echo widget::submit('gl_submit','Rechercher'); - - echo '
'.$retour; - - // Show list of sell - // Date - date of payment - Customer - amount - if ( $current != -1 ) - { - $filter_per=" and jr_tech_per=".$current; - } - else - { - $filter_per=" and jr_tech_per in (select p_id from parm_periode where p_exercice=". - $User->get_exercice().")"; - } - - $sql=SQL_LIST_ALL_INVOICE." $filter_per and jr_def_type='ACH'" ; - - $step=$_SESSION['g_pagesize']; - $page=(isset($_GET['offset']))?$_GET['page']:1; - $offset=(isset($_GET['offset']))?$_GET['offset']:0; - - $l=""; - // check if qcode contains something - if ( $qcode != "" ) - { - // add a condition to filter on the quick code - $l=" and jr_grpt_id in (select j_grpt from jrnx where j_qcode='$qcode') "; - } - /* security */ - $available_ledger=" and ".$User->get_ledger_sql(); - - list($max_line,$list)=ListJrn($cn,0, - "where jrn_def_type='ACH' $filter_per $l $available_ledger" - ,null,$offset,1); - $bar=jrn_navigation_bar($offset,$max_line,$step,$page); - - echo "
$bar"; - echo $list; - echo "$bar
"; - if ( $max_line !=0 ) - echo widget::submit('paid','Mise à jour paiement'); - echo '
'; - echo $retour; - - echo '
'; - - exit(); -} -//---------------------------------------------------------------------- -// Unpaid -if ( $sub_action == 'unpaid' ) { -echo '
'; -echo ShowMenuJrnUser($gDossier, - 'ACH', - 0, - $tag_list.$tag_unpaid_sel); -echo '
'; - - // Ask to update payment - if ( isset ( $_POST['paid'])) - { - // reset all the paid flag because the checkbox is post only - // when checked - foreach ($_POST as $name=>$paid) - { - list($ad) = sscanf($name,"set_jr_id%d"); - if ( $ad == null ) continue; - $sql="update jrn set jr_rapt='' where jr_id=$ad"; - $Res=ExecSql($cn,$sql); - - } - // set a paid flag for the checked box - foreach ($_POST as $name=>$paid) - { - list ($id) = sscanf ($name,"rd_paid%d"); - - if ( $id == null ) continue; - $paid=($paid=='on')?'paid':''; - $sql="update jrn set jr_rapt='$paid' where jr_id=$id"; - $Res=ExecSql($cn,$sql); - } - - } - /* security put a filter on the ledger */ - $available_ledger=$User->get_ledger_sql(); - -// Show list of unpaid sell -// Date - date of payment - Customer - amount - $sql=SQL_LIST_UNPAID_INVOICE_DATE_LIMIT." and $available_ledger ". - " and jrn_def_type='ACH'"; - $offset=(isset($_GET['offset']))?$_GET['offset']:0; - $step=$_SESSION['g_pagesize']; - $page=(isset($_GET['offset']))?$_GET['page']:1; - - list ($max_line,$list)=ListJrn($cn,0,$sql,null,$offset,1); - // $bar=jrn_navigation_bar($offset,$max_ligne,$step,$page); - - - $sql=SQL_LIST_UNPAID_INVOICE." and jrn_def_type='ACH' and $available_ledger"; - list ($max_line2,$list2)=ListJrn($cn,0,$sql,null,$offset,1); - - // Get the max line - $m=($max_line2>$max_line)?$max_line2:$max_line; - $bar2=jrn_navigation_bar($offset,$m,$step,$page); - - echo '
'; - echo '

Echeance dépassée

'; - echo '
'; - echo dossier::hidden(); - echo $bar2; - echo $list; - - - echo '

Non Payée

'; - echo $list2; - echo $bar2; - $hid=new widget(); - echo '
'; - if ( $m != 0 ) - echo widget::submit('paid','Mise à jour paiement'); - echo '
'; - - echo '
'; - exit(); - } - -//----------------------------------------------------- -echo '
'; -echo ShowMenuJrnUser($gDossier, - 'ACH', - $p_jrn, - $tag_list.$tag_unpaid); -echo '
'; -//----------------------------------------------------- -// if we request to add an item -// the $_POST['add_item'] is set -// or if we ask to correct the invoice -if ( isset ($_POST['add_item']) || isset ($_POST["correct"]) ) -{ - if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) != 2 ) { - NoAccess(); - exit -1; - } - - $nb_item=$_POST['nb_item']; - if ( isset ($_POST['add_item'])) - $nb_item++; - // Submit button in the form - $submit=' - '; - - $form=FormAchInput($cn,$p_jrn,$User->get_periode(),$_POST,$submit,false,$nb_item); - echo '
'; - echo $form; - echo $msg_tva; - echo JS_CALC_LINE; - - echo '
'; - exit(); -} -//----------------------------------------------------- -// we want to save the invoice -// -if ( isset($_POST['save'])) -{ - if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) != 2 ) { - NoAccess(); - exit -1; - } - $nb_number=$_POST["nb_item"]; - if ( form_verify_input ($cn,$p_jrn,$User->get_periode(),$_POST,$nb_number) == true ) { - // we save the expense - list ($internal,$c)=RecordSell($cn,$_POST,$User,$p_jrn); - $form=FormAchView($cn,$p_jrn,$User->get_periode(),$_POST,"",$_POST['nb_item'],false); - echo '
'; - echo '

Opération '.$internal.' enregistré

'; - echo $form; - echo '
'; - echo ''; - echo ' - '; - exit(); - } - else - { - $submit=''; - if ( $own->MY_ANALYTIC != "nu" ) - $submit.=''; - $submit.=''; - $form=FormAchView($cn,$p_jrn,$User->get_periode(),$_POST,$submit,$nb_number,true); - echo '
'; - echo $form; - echo '
'; - echo ''; - return; - } -} -//----------------------------------------------------- -// we show the confirmation screen -// -if ( isset ($_POST['view_invoice']) ) -{ - // Check privilege - if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) < 1 ) { - NoAccess(); - exit -1; - } - $nb_number=$_POST["nb_item"]; - $submit=''; - $submit.=''; - if ( form_verify_input ($cn,$p_jrn,$User->get_periode(),$_POST,$nb_number) == true ) { - // Should use a read only view instead of FormAch - // where we can check - $form=FormAchView($cn,$p_jrn,$User->get_periode(),$_POST,$submit,$nb_number); - } else { - // if something goes wrong, correct it - $submit=' - '; - $form=FormAchInput($cn,$p_jrn,$User->get_periode(),$_POST,$submit, false, $nb_number); - } - - echo '
'; - echo $form; - echo '
'; - exit(); - -} - - - -//----------------------------------------------------- -// By default we add a new invoice -if ( $p_jrn != -1 ) -{ - if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) != 2 ) { - exit -1; - } - - $jrn=new Acc_Ledger($cn, $p_jrn); - echo_debug('depense.inc.php',__LINE__,"Blank form"); - // Submit button in the form - $submit=' - '; - // Show an empty form of invoice - $form=FormAchInput($cn,$p_jrn,$User->get_periode(),null,$submit,false,$jrn->getDefLine()); - echo '
'; - echo $form; - echo $msg_tva; - //-------------------- - // predef op. - echo '
'; - $op=new Pre_operation($cn); - $op->p_jrn=$p_jrn; - $op->od_direct='f'; - - $hid=new widget("hidden"); - echo $hid->IOValue("p_action","depense"); - echo dossier::hidden(); - echo $hid->IOValue("p_jrn",$p_jrn); - echo $hid->IOValue("jrn_type","ACH"); - echo $hid->IOValue("sa","use_opd"); - - if ($op->count() != 0 ) - echo widget::submit('use_opd','Utilisez une op.prédéfinie'); - echo $op->show_button(); - - echo '
'; - - echo JS_CALC_LINE; - echo '
'; - -} diff --git a/include/facture.inc.php b/include/facture.inc.php deleted file mode 100644 index a98f1d13e..000000000 --- a/include/facture.inc.php +++ /dev/null @@ -1,455 +0,0 @@ -Liste'; -$tag_list_sel='Liste'; -$tag_unpaid='Non paye'; -$tag_unpaid_sel='Non paye'; - -/*!\file - * \brief the purpose off this file is to create invoices, to record them and to generate - * them, and of course to save them into the database - * - */ - - -// First we show the menu -// If nothing is asked the propose a blank form -// to enter a new invoice -if ( ! isset ($_REQUEST['p_jrn'])) { - // no journal are selected so we select the first one - $p_jrn=GetFirstJrnIdForJrnType($gDossier,'VEN'); -} else -{ - $p_jrn=$_REQUEST['p_jrn']; -} -// for the back button -$retour=""; -$h_url=""; - -if ( isset ($_REQUEST['url'])) -{ - $retour=widget::button_href('Retour',urldecode($_REQUEST['url'])); - - $h_url=sprintf('',urldecode($_REQUEST['url'])); -} - -$sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:""; -//----------------------------------------------------- -// If a list of invoice is asked -// -if ( $sub_action == "list") -{ - // Check privilege - /* if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) < 1 ) { - NoAccess(); - exit -1; - } - */ - // show the menu with the list item selected - echo '
'; - echo ShowMenuJrnUser($gDossier,'VEN',0,$tag_list_sel.$tag_unpaid); - echo '
'; - // Ask to update payment - if ( isset ( $_GET['paid'])) - { - // reset all the paid flag because the checkbox is post only - // when checked - foreach ($_GET as $name=>$paid) - { - list($ad) = sscanf($name,"set_jr_id%d"); - if ( $ad == null ) continue; - $sql="update jrn set jr_rapt='' where jr_id=$ad"; - $Res=ExecSql($cn,$sql); - - } - // set a paid flag for the checked box - foreach ($_GET as $name=>$paid) - { - list ($id) = sscanf ($name,"rd_paid%d"); - - if ( $id == null ) continue; - - $paid=($paid=='on')?'paid':''; - $sql="update jrn set jr_rapt='$paid' where jr_id=$id"; - $Res=ExecSql($cn,$sql); - } - - } - - echo '
'; - echo $retour; - - - echo '
'; - echo dossier::hidden(); - - $hid=new widget("hidden"); - - $hid->name="p_action"; - $hid->value="facture"; - echo $hid->IOValue(); - - - $hid->name="sa"; - $hid->value="list"; - echo $hid->IOValue(); - - - - $w=new widget("select"); - // Add filter on the year - $filter_year=" where p_exercice='".$User->get_exercice()."'"; - - $periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') ". - " from parm_periode $filter_year order by p_start,p_end",1); - // User is already set User=new User($cn); - $current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode(); - $w->selected=$current; - - echo 'Période '.$w->IOValue("p_periode",$periode_start); - $qcode=(isset($_GET['qcode']))?$_GET['qcode']:""; - - echo JS_SEARCH_CARD; - $w=new widget('js_search_only'); - $w->name='qcode'; - $w->value=$qcode; - $w->label=''; - $w->extra='all'; - $w->table=0; - $sp= new widget("span"); - - echo $sp->IOValue("qcode_label","",$qcode); - echo $w->IOValue(); -echo widget::submit('gl_submit','Rechercher'); - // Show list of sell - // Date - date of payment - Customer - amount - if ( $current == -1) { - $cond=" and jr_tech_per in (select p_id from parm_periode where p_exercice='".$User->get_exercice()."')"; - } else { - $cond=" and jr_tech_per=".$current; - } - $sql=SQL_LIST_ALL_INVOICE.$cond." and jr_def_type='VEN'" ; - $step=$_SESSION['g_pagesize']; - $page=(isset($_GET['offset']))?$_GET['page']:1; - $offset=(isset($_GET['offset']))?$_GET['offset']:0; - - $l=""; - // check if qcode contains something - if ( $qcode != "" ) - { - $qcode=Formatstring($qcode); - // add a condition to filter on the quick code - $l=" and jr_grpt_id in (select j_grpt from jrnx where j_qcode=upper('$qcode')) "; - } - /* security */ - $available_ledger=$User->get_ledger_sql(); - - echo_debug(__FILE__.':'.__LINE__.' - available_ledger','',$available_ledger); - list($max_line,$list)=ListJrn($cn,0,"where jrn_def_type='VEN' $cond $l and $available_ledger " - ,null,$offset,1); - $bar=jrn_navigation_bar($offset,$max_line,$step,$page); - - echo "
$bar"; - echo $list; - echo "$bar
"; - if ( $max_line !=0 ) - echo widget::submit('paid','Mise à jour paiement'); - echo '
'; - echo $retour; - - echo '
'; - - exit(); -} -if ( $sub_action=="unpaid") { -echo '
'; -echo ShowMenuJrnUser($gDossier,'VEN',0,$tag_list.$tag_unpaid_sel); -echo '
'; - - // Ask to update payment - if ( isset ( $_POST['paid'])) - { - // reset all the paid flag because the checkbox is post only - // when checked - foreach ($_POST as $name=>$paid) - { - list($ad) = sscanf($name,"set_jr_id%d"); - if ( $ad == null ) continue; - $sql="update jrn set jr_rapt='' where jr_id=$ad"; - $Res=ExecSql($cn,$sql); - - } - // set a paid flag for the checked box - foreach ($_POST as $name=>$paid) - { - list ($id) = sscanf ($name,"rd_paid%d"); - - if ( $id == null ) continue; - $paid=($paid=='on')?'paid':''; - $sql="update jrn set jr_rapt='$paid' where jr_id=$id"; - $Res=ExecSql($cn,$sql); - } - - } - -// Show list of unpaid sell -// Date - date of payment - Customer - amount - // Nav. bar - $step=$_SESSION['g_pagesize']; - $page=(isset($_GET['offset']))?$_GET['page']:1; - $offset=(isset($_GET['offset']))?$_GET['offset']:0; - /* security put a filter on the ledger */ - $available_ledger=$User->get_ledger_sql(); - - - $sql=SQL_LIST_UNPAID_INVOICE_DATE_LIMIT." and jrn_def_type='VEN' and $available_ledger"; - list($max_line,$list)=ListJrn($cn,0,$sql,null,$offset,1); - $sql=SQL_LIST_UNPAID_INVOICE." and ".$available_ledger. - " and jrn_def_type='VEN'"; - list($max_line2,$list2)=ListJrn($cn,0,$sql,null,$offset,1); - - // Get the max line - $m=($max_line2>$max_line)?$max_line2:$max_line; - $bar2=jrn_navigation_bar($offset,$m,$step,$page); - - echo '
'; - echo '
'; - echo dossier::hidden(); - echo $bar2; - echo '

Echeance dépassée

'; - echo $list; - echo '

Non Payée

'; - echo $list2; - echo $bar2; - // Add hidden parameter - $hid=new widget("hidden"); - - $hid->name="sa"; - $hid->value="unpaid"; - echo $hid->IOValue(); - - $hid->name="p_action"; - $hid->value="facture"; - echo $hid->IOValue(); - echo '
'; - - if ( $m != 0 ) - echo widget::submit('paid','Mise à jour paiement'); - - echo '
'; - echo '
'; - exit(); - } -//----------------------------------------------------- -echo '
'; -echo ShowMenuJrnUser($gDossier,'VEN',$p_jrn,$tag_list.$tag_unpaid); -echo '
'; -//-------------------------------------------------------------------------------- -// use a predefined operation -//-------------------------------------------------------------------------------- -if ( $sub_action=="use_opd" ) { - $op=new Pre_op_ven($cn); - $op->set_od_id($_REQUEST['pre_def']); - $p_post=$op->compute_array(); - echo_debug(__FILE__.':'.__LINE__.'- ','p_post = ',$p_post); - $form=FormVenInput($cn,$_GET['p_jrn'],$User->get_periode(),$p_post,false,$p_post['nb_item']); - echo '
'; - echo $form; - - //-------------------- - // predef op. - echo '
'; - $op=new Pre_operation($cn); - $op->p_jrn=$p_jrn; - $op->od_direct='f'; - $hid=new widget("hidden"); - echo $hid->IOValue("p_action","facture"); - echo dossier::hidden(); - echo $hid->IOValue("p_jrn",$p_jrn); - echo $hid->IOValue("jrn_type","VEN"); - echo $hid->IOValue("sa","use_opd"); - - if ($op->count() != 0 ) - echo widget::submit('use_opd','Utilisez une op.prédéfinie'); - echo $op->show_button(); - - echo '
'; - - echo '
'; - exit(); - } - -//----------------------------------------------------- -// if we request to add an item -// the $_POST['add_item'] is set -// or if we ask to correct the invoice -if ( isset ($_POST['add_item']) || isset ($_POST["correct_new_invoice"]) ) -{ - if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) != 2 ) { - NoAccess(); - exit -1; - } - - $nb_item=$_POST['nb_item']; - if ( isset ($_POST['add_item'])) - $nb_item++; - $form=FormVenInput($cn,$p_jrn,$User->get_periode(),$_POST,false,$nb_item); - echo '
'; - echo $form; - echo '
'; - exit(); -} -//----------------------------------------------------- -// we want to save the invoice and to generate a invoice -// -if ( isset($_POST['record_and_print_invoice'])) -{ - if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) != 2 ) { - NoAccess(); - exit -1; - } - $nb_number=$_POST['nb_item']; - // First we save the invoice, the internal code will be used to change the description - // and upload the file - if ( form_verify_input($cn,$p_jrn,$User->get_periode(),$_POST,$nb_number)== true) { - list ($internal,$e)=RecordInvoice($cn,$_POST,$User,$p_jrn); - $form=FormVenteView($cn,$p_jrn,$User->get_periode(),$_POST,$_POST['nb_item'],'noform',''); - - echo '
'; - echo '

Opération '.$internal.' enregistré

'; - echo $form; - echo '
'; - - // Show the details of the encoded invoice - // and the url of the invoice - if ( isset($_POST['gen_invoice'])) - { - $doc=new Document($cn); - $doc->f_id=$_POST['e_client']; - $doc->md_id=$_POST['gen_doc']; - $doc->ag_id=0; - $str_file=$doc->Generate(); - // Move the document to the jrn - $doc->MoveDocumentPj($internal); - // Update the comment with invoice number - $sql="update jrn set jr_comment='Facture ".$doc->d_number."' where jr_internal='$internal'"; - ExecSql($cn,$sql); - /* Save the additional information into jrn_info */ - $obj=new Acc_Ledger_Info($cn); - $jr_id=$obj->search_id_internal($internal); - if (strlen(trim($_POST['bon_comm'] )) != 0 ) { - $obj->set_type('BON_COMMANDE'); - $obj->set_value($_POST['bon_comm']); - $obj->insert(); - } - if (strlen(trim($_POST['other_info'] )) != 0 ) { - $obj->set_type('OTHER'); - $obj->set_value($_POST['other_info']); - $obj->insert(); - } - echo $str_file; - } - } else { - - echo("A cause d'erreur la facture ne peut-ètre validé "); - $form=FormVenteView($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$nb_number,"form"); - - } - - echo ''; - // Button return - printf ('', - $p_jrn,dossier::get()); - exit(); -} -//----------------------------------------------------- -// we show the confirmation screen it is proposed here to generate the -// invoice -if ( isset ($_POST['view_invoice']) ) -{ - // Check privilege - if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) < 1 ) { - NoAccess(); - exit -1; - } - $nb_number=$_POST["nb_item"]; - if ( form_verify_input($cn,$p_jrn,$User->get_periode(),$_POST,$nb_number) == true) - { - $form=FormVenteView($cn,$p_jrn,$User->get_periode(),$_POST,$nb_number); - - } else { - // Check failed : invalid date or quantity - echo_error("Cannot validate "); - $form=FormVenInput($cn,$p_jrn,$User->get_periode(),$_POST,false,$nb_number); - } - - echo '
'; - echo $form; - echo '
'; - exit(); - -} - - - -//----------------------------------------------------- -// By default we add a new invoice -if ( $p_jrn != -1 ) -{ - if ( CheckJrn($gDossier,$_SESSION['g_user'],$p_jrn) != 2 ) { - exit -1; - } - - $jrn=new Acc_Ledger($cn, $p_jrn); - echo_debug('facture.inc.php.php',__LINE__,"Blank form"); - // Show an empty form of invoice - $form=FormVenInput($cn,$p_jrn,$User->get_periode(),null,false,$jrn->GetDefLine()); - echo '
'; - echo $form; - - //-------------------- - // predef op. - echo '
'; - $op=new Pre_operation($cn); - $op->p_jrn=$p_jrn; - $op->od_direct='f'; - $hid=new widget("hidden"); - echo $hid->IOValue("p_action","facture"); - echo dossier::hidden(); - echo $hid->IOValue("p_jrn",$p_jrn); - echo $hid->IOValue("jrn_type","VEN"); - echo $hid->IOValue("sa","use_opd"); - - if ($op->count() != 0 ) - echo widget::submit('use_opd','Utilisez une op.prédéfinie'); - echo $op->show_button(); - - echo '
'; - echo '
'; -} diff --git a/include/user_action_ach.php b/include/user_action_ach.php deleted file mode 100644 index 6517b9b37..000000000 --- a/include/user_action_ach.php +++ /dev/null @@ -1,404 +0,0 @@ -Si le montant de TVA est égal à 0, il sera automatiquement calculé'; - -if ( ! isset ($_REQUEST['action'])){ - exit; -} -$action=$_REQUEST['action']; - -//-------------------------------------------------------------------------------- -// use a predefined operation -//-------------------------------------------------------------------------------- -if ( $action=="use_opd" ) { - $op=new Pre_op_ach($cn); - $op->set_od_id($_REQUEST['pre_def']); - $p_post=$op->compute_array(); - echo_debug(__FILE__.':'.__LINE__.'- ','p_post = ',$p_post); - $submit=' - '; - - $form=FormAchInput($cn,$_GET['p_jrn'],$User->get_periode(),$p_post,$submit,false,$p_post['nb_item']); - echo '
'; - echo $form; - - //-------------------- - // predef op. - echo '
'; - $op->set('ledger',$_GET['p_jrn']); - $op->set('ledger_type',"ACH"); - $op->set('direct','f'); - - echo $op->form_get(); - - echo '
'; - - echo "
".JS_CALC_LINE."
"; - echo "
"; - echo '
'; - exit(); - } - -// action = new -if ( $action == 'new' ) { -// We request a new form - // Check privilege - if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) != 2 ) { - NoAccess(); - exit -1; - } - - if ( isset($_GET['blank'] )) { - // Submit button in the form - $submit=' - '; - $jrn=new Acc_Ledger($cn, $_GET['p_jrn']); - $r=FormAchInput($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$submit,false,$jrn->getDefLine()); - //-------------------- - // predef op. - $op=new Pre_operation_detail($cn); - $op->set('ledger',$_GET['p_jrn']); - $op->set('ledger_type',"ACH"); - $op->set('direct','f'); - - - echo '
'; - echo $r; - echo $msg_tva; - //-------------------- - // predef op. - echo '
'; - echo $op->form_get(); - echo '
'; - - echo "
".JS_CALC_LINE."
"; - echo "
"; - - - } - - // Add an item - if ( isset ($_POST['add_item'])) { - // Add a line - $nb_number=$_POST["nb_item"]; - $nb_number++; - - // submit button in the form - $submit=' - '; - - $r=FormAchInput($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$submit,false, - $nb_number); - echo '
'; - echo $r; - echo $msg_tva; - - echo "
".JS_CALC_LINE."
"; - echo "
"; - } - // Correct it - if ( isset ($_POST['correct'])) { - // Get number of lines - $nb_number=$_POST["nb_item"]; - - // submit button in the form - $submit=' - '; - - $r=FormAchInput($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$submit,false, $nb_number); - echo '
'; - echo $r; - echo $msg_tva; - - echo "
".JS_CALC_LINE."
"; - echo "
"; - return; - } - - - // View the charge and show a submit button to save it - if ( isset ($_POST['view_invoice']) and - ! isset ($_POST['save'])) { - $nb_number=$_POST["nb_item"]; - $submit=''; - if ( $own->MY_ANALYTIC != "nu" ) - $submit.=''; - $submit.=''; - if ( form_verify_input ($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$nb_number) == true ) { - // Should use a read only view instead of FormAch - // where we can check - $r=FormAchView($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$submit,$nb_number); - } else { - // if something goes wrong, correct it - $submit=' - '; - $r=FormAchInput($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$submit, false, $nb_number); - } - echo '
'; - echo $r; - echo $msg_tva; - - echo "
".JS_CALC_LINE."
"; - echo "
"; - } - // Save the charge into database - if ( isset($_POST['save'] )) { - // Get number of lines - $nb_number=$_POST["nb_item"]; - if (form_verify_input ($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$nb_number) - == true ) { - list($internal,$comment)=RecordSell($cn,$_POST,$User,$_GET['p_jrn']); - - // submit button in the form - $submit='

Opération '.$internal.'

'; - $r=FormAchView($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,"",$nb_number,false); - echo '
'; - echo $submit; - echo $r; - echo "
"; - }else { - $submit=''; - if ( $own->MY_ANALYTIC != "nu" ) - $submit.=''; - - $submit.=''; - - $r=FormAchView($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$submit,$nb_number); - echo '
'; - // echo $submit; - echo $r; - echo "
"; - - } - } - - -} -if ( $action == 'voir_jrn' ) { - // Check privilege - if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) < 1 ) { - NoAccess(); - exit -1; - } -?> -
-
- -name="p_jrn"; -$hid->value=$p_jrn; -echo $hid->IOValue(); - -$hid->name="jrn_type"; -$hid->value=$jrn_type; -echo $hid->IOValue(); - -$hid->name="action"; -$hid->value="voir_jrn"; -echo $hid->IOValue(); - - -$w=new widget("select"); -$w->name="p_periode"; -// filter on the current year -$filter_year=" where p_exercice='".$User->get_exercice()."'"; - -$periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end",1); -$User=new User($cn); -$current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode(); -$w->selected=$current; - -echo 'Période '.$w->IOValue("p_periode",$periode_start).widget::submit('gl_submit','Valider'); -?> -
-$paid) - { - list($ad) = sscanf($name,"set_jr_id%d"); - if ( $ad == null ) continue; - $sql="update jrn set jr_rapt='' where jr_id=$ad"; - $Res=ExecSql($cn,$sql); - - } - // set a paid flag for the checked box - foreach ($_POST as $name=>$paid) - { - list ($id) = sscanf ($name,"rd_paid%d"); - - if ( $id == null ) continue; - - $paid=($paid=='on')?'paid':''; - $sql="update jrn set jr_rapt='$paid' where jr_id=$id"; - $Res=ExecSql($cn,$sql); - } - - } - - // Show list of sell - echo_debug ("user_action_ach.php"); - // Date - date of payment - Customer - amount - if ( $current == -1) { - $cond=" and jr_tech_per in (select p_id from parm_periode where p_exercice='".$User->get_exercice()."')"; - } else { - $cond=" and jr_tech_per=".$current; - } - - $sql=SQL_LIST_ALL_INVOICE.$cond." and jr_def_id=".$_GET['p_jrn']; - - $step=$_SESSION['g_pagesize']; - $page=(isset($_GET['offset']))?$_GET['page']:1; - $offset=(isset($_GET['offset']))?$_GET['offset']:0; - - list ($max_ligne,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1); - $bar=jrn_navigation_bar($offset,$max_ligne,$step,$page); - echo '
'; - echo dossier::hidden(); - - echo "
$bar"; - echo $list; - echo "$bar
"; - $hid=new widget(); - if ( $max_ligne != 0 ) - echo widget::submit('paid','Mise à jour paiement'); - echo '
'; - echo '
'; -} -if ( $action == 'voir_jrn_non_paye' ) { - // Check privilege - if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) < 1 ) { - NoAccess(); - exit -1; - } - // Ask to update payment - if ( isset ( $_POST['paid'])) - { - // reset all the paid flag because the checkbox is post only - // when checked - foreach ($_POST as $name=>$paid) - { - list($ad) = sscanf($name,"set_jr_id%d"); - if ( $ad == null ) continue; - $sql="update jrn set jr_rapt='' where jr_id=$ad"; - $Res=ExecSql($cn,$sql); - - } - // set a paid flag for the checked box - foreach ($_POST as $name=>$paid) - { - list ($id) = sscanf ($name,"rd_paid%d"); - - if ( $id == null ) continue; - $paid=($paid=='on')?'paid':''; - $sql="update jrn set jr_rapt='$paid' where jr_id=$id"; - $Res=ExecSql($cn,$sql); - } - - } - -// Show list of unpaid sell -// Date - date of payment - Customer - amount - $sql=SQL_LIST_UNPAID_INVOICE_DATE_LIMIT." and jr_def_id=".$_GET['p_jrn'] ; - $offset=(isset($_GET['offset']))?$_GET['offset']:0; - $step=$_SESSION['g_pagesize']; - $page=(isset($_GET['offset']))?$_GET['page']:1; - - list ($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1); - // $bar=jrn_navigation_bar($offset,$max_ligne,$step,$page); - - - $sql=SQL_LIST_UNPAID_INVOICE." and jr_def_id=".$_GET['p_jrn'] ; - list ($max_line2,$list2)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1); - - // Get the max line - $m=($max_line2>$max_line)?$max_line2:$max_line; - $bar2=jrn_navigation_bar($offset,$m,$step,$page); - - echo '
'; - echo '

Echeance dépassée

'; - echo '
'; - echo dossier::hidden(); - echo $bar2; - echo $list; - - - echo '

Non Payée

'; - echo $list2; - echo $bar2; - $hid=new widget(); - echo '
'; - if ( $m != 0 ) - echo widget::submit('paid','Mise à jour paiement'); - echo '
'; - - echo '
'; -} - -//Search -if ( $action == 'search' ) { - // Check privilege - if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) < 1 ) { - NoAccess(); - exit -1; - } - - // PhpSessid - $sessid=$_REQUEST['PHPSESSID']; - // Search modules - $offset=(isset($_GET['offset']))?$_GET['offset']:0; - $step=$_SESSION['g_pagesize']; - $page=(isset($_GET['offset']))?$_GET['page']:1; - -// display a search box - $search_box=u_ShowMenuRecherche($cn,$_GET['p_jrn'],$sessid,$_POST); - echo '
'; - echo $search_box; - // if nofirst is set then show result - if ( isset ($_GET['nofirst'] ) ) { - list ($max_line,$a)=ListJrn($cn,$_GET['p_jrn'],"",$_POST); - echo $a; - } - echo '
'; -} -require_once("user_update.php"); -?> diff --git a/include/user_action_fin.php b/include/user_action_fin.php deleted file mode 100644 index a47b2bc3b..000000000 --- a/include/user_action_fin.php +++ /dev/null @@ -1,310 +0,0 @@ -set_od_id($_REQUEST['pre_def']); - $p_post=$op->compute_array(); - echo_debug(__FILE__.':'.__LINE__.'- ','p_post = ',$p_post); - // submit button in the form - $submit=''. - ''; - - $form=FormFin($cn,$_GET['p_jrn'],$User->get_periode(),$submit,$p_post,false,$p_post['nb_item']); - echo '
'; - echo $form; - echo '
'; - exit(); - } - -//----------------------------------------------------- -// action = new -//----------------------------------------------------- -if ( $action == 'new' ) { - // Check privilege - if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) != 2 ) { - NoAccess(); - exit -1; - } - -// We request a new form - if ( isset($_GET['blank'] )) { - // Submit button in the form - $submit=' - '; - // add a one-line calculator - $p_jrn=$_GET['p_jrn']; - $jrn=new Acc_Ledger($cn, $p_jrn); - - $r=FormFin($cn,$p_jrn,$User->get_periode(),$submit,null,false,$jrn->GetDefLine()); - echo '
'; - echo $r; - echo "
"; - //-------------------- - // predef op. - echo '
'; - $op=new Pre_operation($cn); - $op->p_jrn=$_GET['p_jrn']; - $op->od_direct='f'; - - $hid=new widget("hidden"); - echo $hid->IOValue("action","use_opd"); - echo dossier::hidden(); - echo $hid->IOValue("p_jrn",$_GET['p_jrn']); - echo $hid->IOValue("jrn_type","FIN"); - - if ($op->count() != 0 ) - echo widget::submit('use_opd','Utilisez une op.prédéfinie'); - echo $op->show_button(); - - echo '
'; - - echo "

On-line calculator

".JS_CALC_LINE."
"; - - echo "
"; - - - } - - // Add an item - if ( isset ($_POST['add_item'])) { - // Add a line - $nb_number=$_POST["nb_item"]; - $nb_number++; - - // submit button in the form - $submit=' - '; - - $r=FormFin($cn,$_GET['p_jrn'],$User->get_periode(),$submit,$_POST,false, $nb_number); - echo '
'; - echo $r; - echo "

On-line calculator

".JS_CALC_LINE."
"; - - echo "
"; - } - // Correct it - if ( isset ($_POST['correct'])) { - // Get number of lines - $nb_number=$_POST["nb_item"]; - - // submit button in the form - $submit=' - '; - - $r=FormFin($cn,$_GET['p_jrn'],$User->get_periode(),$submit,$_POST,false, $nb_number); - echo '
'; - echo $r; - echo "

On-line calculator

".JS_CALC_LINE."
"; - - echo "
"; - } - - - // View the charge and show a submit button to save it - if ( isset ($_POST['view_invoice']) ) { - $nb_number=$_POST["nb_item"]; - $r=form_verify_input($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$nb_number); - // if something goes wrong correct it - if ( $r == null ) - { - // submit button in the form - $submit=' - '; - - $r=FormFin($cn,$_GET['p_jrn'],$User->get_periode(),$submit,$_POST,false, $nb_number); - } - else - { - $submit=''; - $submit.=''; - - $r=FormFin($cn,$_GET['p_jrn'],$User->get_periode(),$submit,$_POST,true,$nb_number); - } - - echo '
'; - echo $r; - echo "

On-line calculator

".JS_CALC_LINE."
"; - echo "
"; - } - // Save the charge into database - if ( isset($_POST['save'] )) { - $internal=RecordFin($cn,$_POST,$User,$_GET['p_jrn']); - // Get number of lines - $nb_number=$_POST["nb_item"]; - - // submit button in the form - //$submit='

Enregistré '.$r.'

'; - $submit=""; - $r=FormFin($cn,$_GET['p_jrn'],$User->get_periode(),$submit,$_POST,true, $nb_number,true); - echo '
'; - echo '

Enregistré '.$internal.'

'; - echo $submit; - echo $r; - echo "
"; - - } - - -} -//----------------------------------------------------- -// see jrn -//----------------------------------------------------- -if ( $action == 'voir_jrn' ) { - // Check privilege - if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) < 1 ) { - NoAccess(); - exit -1; - } -?> -
- -
- -name="p_jrn"; -$hid->value=$p_jrn; -echo $hid->IOValue(); - -$hid->name="action"; -$hid->value="voir_jrn"; -echo $hid->IOValue(); - - -$hid->name="jrn_type"; -$hid->value=$jrn_type; -echo $hid->IOValue(); - - -$w=new widget("select"); -// filter on the current year -$filter_year=" where p_exercice='".$User->get_exercice()."'"; - -$periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end",1); -$User=new User($cn); -$current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode(); -$w->selected=$current; - -echo 'Période '.$w->IOValue("p_periode",$periode_start).widget::submit('gl_submit','Valider'); -?> -
-get_exercice()."')"; - } else { - $cond=" and jr_tech_per=".$current; - } - - // Date - date of payment - Customer - amount - $sql=SQL_LIST_ALL_INVOICE.$cond." and jr_def_id=".$_GET['p_jrn']; - - // Nav. bar - $step=$_SESSION['g_pagesize']; - $page=(isset($_GET['offset']))?$_GET['page']:1; - $offset=(isset($_GET['offset']))?$_GET['offset']:0; - // SQL - list($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset); - - $bar=jrn_navigation_bar($offset,$max_line,$step,$page); - - echo $bar; - echo $list; - echo $bar; - echo '
'; -} -//----------------------------------------------------- -// balance -//----------------------------------------------------- -if ( $action == 'solde' ) { - require_once("poste.php"); - // find the bank account - // NOTE : those values are in a table because - // they are _national_ parameters - $banque=new Acc_Parm_Code($cn,'BANQUE'); - $caisse=new Acc_Parm_Code($cn,'CAISSE'); - $vir_interne=new Acc_Parm_Code($cn,'VIREMENT_INTERNE'); - $accountSql="select distinct pcm_val::text,pcm_lib from - tmp_pcmn - where pcm_val::text like '".$banque->p_value."%' or pcm_val::text like '".$vir_interne->p_value."%' - or pcm_val::text like '".$caisse->p_value."%' - order by pcm_val::text"; - $ResAccount=ExecSql($cn,$accountSql); - echo '
'; - echo ""; - // for each account - for ( $i = 0; $i < pg_NumRows($ResAccount);$i++) { - // get the saldo - $l=pg_fetch_array($ResAccount,$i); - $m=get_solde($cn,$l['pcm_val'],' and j_tech_per in (select '. - 'p_id from parm_periode where p_exercice='.$User->get_exercice().') '); - // print the result if the saldo is not equal to 0 - if ( $m != 0.0 ) { - echo ""; - echo "". - ""."".""; - } - }// for - echo "
". - $l['pcm_val']. - "". - $l['pcm_lib']. - "". - $m. - "
"; - echo "
"; - } -//----------------------------------------------------- -require_once("user_update.php"); - - -?> diff --git a/include/user_action_ods.php b/include/user_action_ods.php deleted file mode 100644 index 142d453ff..000000000 --- a/include/user_action_ods.php +++ /dev/null @@ -1,296 +0,0 @@ -set_od_id($_REQUEST['pre_def']); - $p_post=$op->compute_array(); - echo_debug(__FILE__.':'.__LINE__.'- ','p_post = ',$p_post); - $submit=''. - ''; - - // $form=FormVenInput($cn,$_GET['p_jrn'],$User->get_periode(),$p_post,false,$p_post['nb_item']); - $form=FormODS($cn,$_REQUEST['p_jrn'],$User->get_periode(),$submit,$p_post,false,$p_post['nb_item']); - - echo '
'; - echo $form; - //-------------------- - // predef op. - echo '
'; - $op=new Pre_operation_detail($cn); - $op->set('ledger',$_GET['p_jrn']); - $op->set('ledger_type',"ODS"); - $op->set('direct','f'); - echo $op->form_get(); - - echo '
'; - - echo '
'; - exit(); - } - -// action = new -if ( $action == 'new' ) { - - // Check privilege - if ( CheckJrn($gDossier,$_SESSION['g_user'],$_REQUEST['p_jrn']) != 2 ) { - NoAccess(); - exit -1; - } -// We request a new form - if ( isset($_GET['blank'] )) { - // Submit button in the form - $submit=' - '; - // add a one-line calculator - $jrn=new Acc_Ledger($cn,$_GET['p_jrn']); - $prop=$jrn->get_propertie(); - $line=$prop['jrn_deb_max_line']; - $r=FormODS($cn,$_REQUEST['p_jrn'],$User->get_periode(),$submit,null,false,$line); - echo '
'; - echo $r; - echo "
"; - //-------------------- - // predef op. - echo '
'; - $op=new Pre_operation_detail($cn); - $op->set('ledger',$_GET['p_jrn']); - $op->set('ledger_type',"ODS"); - $op->set('direct','f'); - echo $op->form_get(); - - echo '
'; - - - echo "

On-line calculator

".JS_CALC_LINE."
"; - echo "
"; - - - } - - // Add an item - if ( isset ($_POST['add_item'])) { - // Add a line - $nb_number=$_POST["nb_item"]; - $nb_number++; - - // submit button in the form - $submit=' - '; - - $r=FormODS($cn,$_POST['p_jrn'],$User->get_periode(),$submit,$_POST,false, $nb_number); - echo '
'; - echo $r; - echo "

On-line calculator

".JS_CALC_LINE."
"; - echo "
"; - } - // Correct it - if ( isset ($_POST['correct'])) { - // Get number of lines - $nb_number=$_POST["nb_item"]; - - // submit button in the form - $submit=' - '; - - $r=FormODS($cn,$_POST['p_jrn'],$User->get_periode(),$submit,$_POST,false, $nb_number); - echo '
'; - echo $r; - echo "

On-line calculator

".JS_CALC_LINE."
"; - echo "
"; - } - - - // View the charge and show a submit button to save it - // TODO: the name 'view_invoice' should be changed to something more self-explaining, like - // 'submit_od', no? - if ( isset ($_POST['view_invoice']) ) { - $nb_number=$_POST["nb_item"]; - $submit=''; - if ( $own->MY_ANALYTIC != "nu" ) - $submit.=''; - $submit.=''; - - $r=FormODS($cn,$_POST['p_jrn'],$User->get_periode(),$submit,$_POST,true,$nb_number); - - // if something goes wrong, correct it - if ( $r == null ) { - // submit button in the form - $submit=' - '; - - $r=FormODS($cn,$_POST['p_jrn'],$User->get_periode(),$submit,$_POST,false, $nb_number); - }else { - $submit=' - '; - - - } - echo '
'; - echo $r; - echo "

On-line calculator

".JS_CALC_LINE."
"; - echo "
"; - } - // Save the change into database - if ( isset($_POST['save'] )) { - $r=RecordODS($cn,$_POST,$User,$_POST['p_jrn']); - // Get number of lines - $nb_number=$_POST["nb_item"]; - if ( $r != null ) { - // submit button in the form - $submit='

Recorded'.$r.'

'; - - $r.=FormODS($cn,$_POST['p_jrn'],$User->get_periode(),$submit,$_POST,true, $nb_number,true); - }else { - // CA incorrecte - $submit=''; - if ( $own->MY_ANALYTIC != "nu" ) - $submit.=''; - $submit.=''; - - $r=FormODS($cn,$_POST['p_jrn'],$User->get_periode(),$submit,$_POST,true,$nb_number); - - } - echo '
'; - echo $r; - echo "
"; - - } - - -} -if ( $action == 'voir_jrn' ) { - // Check privilege - if ( CheckJrn($gDossier,$_SESSION['g_user'],$_REQUEST['p_jrn']) < 1 ) { - NoAccess(); - exit -1; - } - - // Show list of cells - echo_debug ("user_action_ods.php"); - // Date - date of payment - Customer - amount -?> -
- -
- -name="p_jrn"; -$hid->value=$p_jrn; -echo $hid->IOValue(); - -$hid->name="action"; -$hid->value="voir_jrn"; -echo $hid->IOValue(); - - -$hid->name="jrn_type"; -$hid->value=$jrn_type; -echo $hid->IOValue(); - - - -$w=new widget("select"); -// filter on the current year -$filter_year=" where p_exercice='".$User->get_exercice()."'"; - -$periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end",1); -$User=new User($cn); -$current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode(); -$w->selected=$current; - -echo 'Période '.$w->IOValue("p_periode",$periode_start).widget::submit('gl_submit','Valider'); -?> -
-get_exercice()."')"; - } else { - $cond=" and jr_tech_per=".$current; - } - - $sql=SQL_LIST_ALL_INVOICE.$cond." and jr_def_id=".$_GET['p_jrn'] ; - $step=$_SESSION['g_pagesize']; - $page=(isset($_GET['offset']))?$_GET['page']:1; - $offset=(isset($_GET['offset']))?$_GET['offset']:0; - list ($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset); - $bar=jrn_navigation_bar($offset,$max_line,$step,$page); - echo $bar; - echo $list; - echo $bar; - echo '
'; -} - -//Search -if ( $action == 'search' ) { - // Check privilege - if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) <1 ) { - NoAccess(); - exit -1; - } - - // PhpSessid - $sessid=(isset ($_POST['PHPSESSID']))?$_POST['PHPSESSID']:$_GET['PHPSESSID']; - -// display a search box - $search_box=u_ShowMenuRecherche($cn,$_GET['p_jrn'],$sessid,$_POST); - echo '
'; - echo $search_box; - // if nofirst is set then show result - if ( isset ($_GET['nofirst'] ) ) { - list ($max_line,$a)=ListJrn($cn,$_GET['p_jrn'],"",$_POST); - echo $a; - } - echo '
'; -} -require_once("user_update.php"); -?> diff --git a/include/user_action_ven.php b/include/user_action_ven.php deleted file mode 100644 index 8a75b721e..000000000 --- a/include/user_action_ven.php +++ /dev/null @@ -1,381 +0,0 @@ -set_od_id($_REQUEST['pre_def']); - - $p_post=$op->compute_array(); - echo_debug(__FILE__.':'.__LINE__.'- ','p_post = ',$p_post); - $form=FormVenInput($cn,$_GET['p_jrn'],$User->get_periode(),$p_post,false,$p_post['nb_item']); - echo '
'; - echo $form; - - //-------------------- - // predef op. - echo '
'; - $op->set('ledger',$_GET['p_jrn']); - $op->set('ledger_type',"VEN"); - $op->set('direct','f'); - - echo $op->form_get(); - echo '
'; - echo '
'; - - exit(); - } -if ( $action == 'insert_vente' ) { - - // Add item - if (isset($_POST["add_item"]) ) { - echo_debug('user_action_ven.php',__LINE__,"Add an item"); - $nb_number=$_POST["nb_item"]; - $nb_number++; - - $form=FormVenInput($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,false,$nb_number); - echo '
'; - echo $form; - echo '
'; - - } // add an item - - // We want to see the encoded invoice - if ( isset ($_POST["view_invoice"])) { - $nb_number=$_POST["nb_item"]; - if ( form_verify_input($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$nb_number) == true) - { - $form=FormVenteView($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$nb_number); - // Check failed : invalid date or quantity - } else { - echo_debug(__FILE__.':'.__LINE__," Impossible d'accepter le formulaire"); - $form=FormVenInput($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,false,$nb_number); - } - echo '
'; - echo $form; - echo '
'; - - } - - // We want a blank form - if ( $blank==1) - { - $jrn=new Acc_Ledger($cn, $_GET['p_jrn']); - $op=new Pre_op_ven($cn); - echo_debug('user_action_ven.php',__LINE__,"Blank form"); - // Show an empty form of invoice - $form=FormVenInput($cn,$_GET['p_jrn'],$User->get_periode(),null,false,$jrn->GetDefLine()); - echo '
'; - echo $form; - //-------------------- - // predef op. - - echo '
'; - $op->set('ledger',$_REQUEST['p_jrn']); - $op->set('ledger_type',"VEN"); - $op->set('direct','f'); - echo $op->form_get(); - echo '
'; - echo '
'; - } - -} - - - // Save the invoice -if ( isset($_POST["record_invoice"])) { - // Check privilege - if ( CheckJrn($gDossier,$User,$_GET['p_jrn']) != 2 ) { - NoAccess(); - exit -1; - } - - // echo "RECORD INVOICE"; - list($internal,$comment)=RecordInvoice($cn,$_POST,$User,$_GET['p_jrn']); -} -if (isset ($_POST['correct_new_invoice'])) { - // Check privilege - if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) != 2 ) { - NoAccess(); - exit -1; - } - - $nb=$_POST['nb_item']; - $form=FormVenInput($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,false,$nb); - echo '
'; - echo $form; - echo '
'; -} -// Save and print the invoice -if ( isset($_POST["record_and_print_invoice"])) { - // Check privilege - if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) != 2 ) { - NoAccess(); - exit -1; - } - - $nb_number=$_POST["nb_item"]; - echo_debug(__FILE__.':'.__LINE__.'- record_and_print_invoice'); - if ( form_verify_input($cn,$p_jrn,$User->get_periode(),$_POST,$nb_number)== true) { - echo '
'; - list($internal,$comment)=RecordInvoice($cn,$_POST,$User,$_GET['p_jrn']); - echo '

Opération '.$internal.'

'; - $form=FormVenteView($cn,$p_jrn,$User->get_periode(),$_POST,$nb_number,'noform',$comment); - echo '
'; - } else { - - echo("A cause d'erreur la facture ne peut-ètre validé "); - $form=FormVenteView($cn,$_GET['p_jrn'],$User->get_periode(),$_POST,$nb_number,"form"); - } - - echo '
'; - echo $form; - echo "
"; -} - - - if ( $action == 'voir_jrn' ) { - // Check privilege - if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) < 1 ) { - NoAccess(); - exit -1; - } - // Extract the page number we want - $debut=(isset($_REQUEST['p_page']))?$_REQUEST['p_page']:0; - - -?> -
- -
- -name="p_jrn"; -$hid->value=$p_jrn; -echo $hid->IOValue(); - -$hid->name="action"; -$hid->value="voir_jrn"; -echo $hid->IOValue(); - - -$hid->name="jrn_type"; -$hid->value=$jrn_type; -echo $hid->IOValue(); - - - -$w=new widget("select"); - -// filter on the current year -$filter_year=" where p_exercice='".$User->get_exercice()."'"; - -$periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end",1); -// User is already set User=new User($cn); -$current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->get_periode(); -$w->selected=$current; - -echo 'Période '.$w->IOValue("p_periode",$periode_start).widget::submit('gl_submit','Valider'); -?> -
-$paid) - { - list($ad) = sscanf($name,"set_jr_id%d"); - if ( $ad == null ) continue; - $sql="update jrn set jr_rapt='' where jr_id=$ad"; - $Res=ExecSql($cn,$sql); - - } - // set a paid flag for the checked box - foreach ($_POST as $name=>$paid) - { - list ($id) = sscanf ($name,"rd_paid%d"); - - if ( $id == null ) continue; - - $paid=($paid=='on')?'paid':''; - $sql="update jrn set jr_rapt='$paid' where jr_id=$id"; - $Res=ExecSql($cn,$sql); - } - - } - // Show list of sell - // Date - date of payment - Customer - amount - if ( $current == -1) { - $cond=" and jr_tech_per in (select p_id from parm_periode where p_exercice='".$User->get_exercice()."')"; - } else { - $cond=" and jr_tech_per=".$current; - } - - $sql=SQL_LIST_ALL_INVOICE.$cond." and jr_def_id=".$_GET['p_jrn'] ; - $step=$_SESSION['g_pagesize']; - $page=(isset($_GET['offset']))?$_GET['page']:1; - $offset=(isset($_GET['offset']))?$_GET['offset']:0; - - list($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1); - $bar=jrn_navigation_bar($offset,$max_line,$step,$page); - - echo "
$bar"; - echo '
'; - echo dossier::hidden(); - $hid=new widget("hidden"); - - $hid->name="p_jrn"; - $hid->value=$p_jrn; - echo $hid->IOValue(); - - $hid->name="action"; - $hid->value="voir_jrn"; - echo $hid->IOValue(); - - - $hid->name="jrn_type"; - $hid->value=$jrn_type; - echo $hid->IOValue(); - - - echo $list; - if ( $max_line !=0 ) - echo widget::submit('paid','Mise à jour paiement'); - echo '
'; - echo "$bar
"; - - echo '
'; -} -if ( $action == 'voir_jrn_non_paye' ) { - // Check privilege - if ( CheckJrn($gDossier,$_SESSION['g_user'],$_GET['p_jrn']) < 1 ) { - NoAccess(); - exit -1; - } - // Ask to update payment - if ( isset ( $_POST['paid'])) - { - // reset all the paid flag because the checkbox is post only - // when checked - foreach ($_POST as $name=>$paid) - { - list($ad) = sscanf($name,"set_jr_id%d"); - if ( $ad == null ) continue; - $sql="update jrn set jr_rapt='' where jr_id=$ad"; - $Res=ExecSql($cn,$sql); - - } - // set a paid flag for the checked box - foreach ($_POST as $name=>$paid) - { - list ($id) = sscanf ($name,"rd_paid%d"); - - if ( $id == null ) continue; - $paid=($paid=='on')?'paid':''; - $sql="update jrn set jr_rapt='$paid' where jr_id=$id"; - $Res=ExecSql($cn,$sql); - } - - } - -// Show list of unpaid sell -// Date - date of payment - Customer - amount - // Nav. bar - $step=$_SESSION['g_pagesize']; - $page=(isset($_GET['offset']))?$_GET['page']:1; - $offset=(isset($_GET['offset']))?$_GET['offset']:0; - - $sql=SQL_LIST_UNPAID_INVOICE_DATE_LIMIT." and jr_def_id=".$_GET['p_jrn'] ; - list($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1); - $sql=SQL_LIST_UNPAID_INVOICE." and jr_def_id=".$_GET['p_jrn'] ; - list($max_line2,$list2)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1); - - // Get the max line - $m=($max_line2>$max_line)?$max_line2:$max_line; - $bar2=jrn_navigation_bar($offset,$m,$step,$page); - - echo '
'; - echo '
'; - echo dossier::hidden(); - echo $bar2; - echo '

Echeance dépassée

'; - echo $list; - echo '

Non Payée

'; - echo $list2; - echo $bar2; - // Add hidden parameter - $hid=new widget("hidden"); - - $hid->name="p_jrn"; - $hid->value=$p_jrn; - echo $hid->IOValue(); - - $hid->name="action"; - $hid->value="voir_jrn_non_paye"; - echo $hid->IOValue(); - - - $hid->name="jrn_type"; - $hid->value=$jrn_type; - echo $hid->IOValue(); - - echo '
'; - - if ( $m != 0 ) - echo widget::submit('paid','Mise à jour paiement'); - - echo '
'; - echo '
'; -} - -require_once("user_update.php"); -?> diff --git a/include/user_form_ach.php b/include/user_form_ach.php deleted file mode 100644 index fd9f491af..000000000 --- a/include/user_form_ach.php +++ /dev/null @@ -1,1053 +0,0 @@ - - *
  • e_client (quickcode), - *
  • e_marchX quickcode, - *
  • e_march_buyX, - *
  • e_march0_tva_id, - *
  • e_quant0,nb_item, - *
  • jrn_type, - *
  • e_date, - *
  • e_ech, - *
  • e_comm - * - *\param $p_jrn the ledger - *\param $p_periode = periode - *\param $pview_only if we cannot change it (no right or centralized op) - *\param $p_article number of article - * - * \return: string with the form - */ -function FormAchInput($p_cn,$p_jrn,$p_periode,$p_array=null,$p_submit="",$pview_only=true,$p_article=1) -{ -echo_debug('user_form_ach.php',__LINE__,"Enter FormAchInput($p_cn,$p_jrn,$p_periode,$p_array,$p_submit,$pview_only,$p_article"); - if ( $p_array != null) { - // array contains old value - extract($p_array); - } - // The date - list ($l_date_start,$l_date_end)=get_periode($p_cn,$p_periode); - // $op_date=( ! isset($e_date) ) - // ?substr($l_date_start,2,8):$e_date; - $op_date=( ! isset($e_date) ) ?$l_date_start:$e_date; - $e_ech=(isset($e_ech))?$e_ech:""; - $e_comm=(isset($e_comm))?$e_comm:""; - - // Save old value and set a new one - echo_debug('user_form_ach.php',__LINE__,"form_input.php.FormSell_op_date is $op_date"); - $r=""; - if ( $pview_only == false) { - $r.=JS_SEARCH_CARD; - $r.=JS_SHOW_TVA; - $r.=JS_TVA; - // Compute href - $href=basename($_SERVER['PHP_SELF']); - switch ($href) - { - // user_jrn.php - case 'user_jrn.php': - $href="user_jrn.php?action=new&p_jrn=$p_jrn"; - break; - case 'commercial.php': - $href="commercial.php?p_action=depense&p_jrn=$p_jrn"; - break; - default: - echo_error('user_form_ach.php',__LINE__,'Erreur invalid request uri '.$href); - exit (-1); - } - $r.="
    "; - $r.=dossier::hidden(); - } - $r.='
    '; - $r.='Detail Fournisseur'; - $r.=''; - // Date widget - //-- - $Date=new widget("js_date"); - $Date->SetReadOnly($pview_only); - $Date->table=1; - $r.=""; - $r.=$Date->IOValue("e_date",$op_date,"Date"); - $r.=""; - // Payment limit widget - //-- - $Echeance=new widget("js_date"); - $Echeance->SetReadOnly($pview_only); - $Echeance->table=1; - $r.=""; - $r.=$Echeance->IOValue("e_ech",$e_ech,"Echeance"); - $r.=""; - // Comment - //-- - $Commentaire=new widget("text"); - $Commentaire->table=1; - $Commentaire->SetReadOnly($pview_only); - $Commentaire->size=80; - $r.=""; - $r.=$Commentaire->IOValue("e_comm",$e_comm,"Description"); - $r.=""; - include_once("fiche_inc.php"); - // Display the supplier - //-- - $fiche='cred'; - echo_debug('user_form_ach.php',__LINE__,"Fournisseurs Nombre d'enregistrement ".sizeof($fiche)); - // Save old value and set a new one - $e_client=( isset ($e_client) )?$e_client:""; - - $e_client_label=""; - - // retrieve e_client_label - $a_client=GetFicheAttribut($p_cn,$e_client); - if ( $a_client != null) - $e_client_label=$a_client['vw_name']." adresse ".$a_client['vw_addr']." ".$a_client['vw_cp']; - - // widget search - $W1=new widget("js_search"); - $W1->label="Fournisseur"; - $W1->name="e_client"; - $W1->value=$e_client; - $W1->extra=$fiche; // list of card - $W1->extra2=$p_jrn; - $r.="".$W1->IOValue(); - $client_label=new widget("span"); - $r.= $client_label->IOValue("e_client_label",$e_client_label).""; - $r.="
    "; - // Set correctly the REQUEST param for jrn_type - $h=new widget('hidden'); - $h->name='jrn_type'; - $h->value='ACH'; - $r.=$h->IOValue(); - - // Record the current number of article - $Hid=new widget('hidden'); - $r.=$Hid->IOValue("nb_item",$p_article); - $e_comment=(isset($e_comment))?$e_comment:""; - $r.='
    '; - - // Start the div for item to sell - $r.="
    "; - $r.='

    détail articles achetés

    '; - $r.=''; - $r.=''; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=''; - // For each article - // compute amount - // verify if card exists - // retrieve vat label - //-- - for ($i=0;$i< $p_article;$i++) { - // Code id - $march=(isset(${"e_march$i"}))?${"e_march$i"}:""; - $march_buy=(isset(${"e_march".$i."_buy"}))?${"e_march".$i."_buy"}:""; - $march_tva_id=(isset(${"e_march$i"."_tva_id"}))?${"e_march$i"."_tva_id"}:""; - $march_tva_amount=(isset(${"e_march$i"."_tva_amount"}))?${"e_march$i"."_tva_amount"}:"0"; - $march_tva_label=""; - $march_label=""; - - // If $march has a value - if ( strlen(trim($march)) != 0 && isFicheOfJrn($p_cn,$p_jrn,$march,'deb') == 0 ) { - $msg="user_form_achat@".__LINE__."Fiche inexistante !!! "; - echo_error($msg); echo_error($msg); - $march=""; - } else { - // retrieve the tva label and name - $a_fiche=GetFicheAttribut($p_cn, $march); - if ( $a_fiche != null ) { - if ( $march_tva_id == "" ) { - $march_tva_id=$a_fiche['tva_id']; - $march_tva_label=$a_fiche['tva_label']; - } - $march_label=$a_fiche['vw_name']; - } - } - - // Show input - - $W1=new widget("js_search"); - $W1->label=""; - $W1->name="e_march".$i; - $W1->value=$march; - $W1->extra='deb'; // credits - $W1->extra2=$p_jrn; - $W1->readonly=$pview_only; - $r.="".$W1->IOValue().""; - $Span=new widget ("span"); - $Span->SetReadOnly($pview_only); - // card's name - $r.=""; - // price - $Price=new widget("text"); - $Price->SetReadOnly($pview_only); - $Price->table=1; - $Price->size=9; - $r.=$Price->IOValue("e_march".$i."_buy",$march_buy); - // vat label - $select_tva=make_array($p_cn,"select tva_id,tva_label from tva_rate order by tva_rate desc",0); - $Tva=new widget("select"); - $Tva->table=1; - $Tva->selected=$march_tva_id; - $r.=$Tva->IOValue("e_march$i"."_tva_id",$select_tva); - // tva_amount - $Tva_amount=new widget("text"); - $Tva_amount->SetReadOnly($pview_only); - $Tva_amount->table=1; - $Tva_amount->size=9; - $r.=$Tva_amount->IOValue("e_march".$i."_tva_amount",$march_tva_amount); - - // quantity - $quant=(isset(${"e_quant$i"}))?${"e_quant$i"}:"1"; - $Quantity=new widget("text"); - $Quantity->SetReadOnly($pview_only); - $Quantity->table=1; - $Quantity->size=9; - $r.=$Quantity->IOValue("e_quant".$i,$quant); - $r.=''; - } - - - - $r.="
    CodeDénominationprixtvaMontant TVAquantité
    ".$Span->IOValue("e_march".$i."_label",$march_label)."
    "; - $r.="
    "; - - if ($pview_only == false ) { - $r.=$p_submit; - $r.="
    "; - $r.="
    "; - } else { - $r.="
  • "; - - } - - - - return $r; - - -} -/*! - ************************************************** - * \brief verify if the data to insert are valid - * - * \param $p_cn database connection - *\param $p_jrn concerned ledger - *\param $p_periode User periode - *\param $p_array array with the post data - *\param $p_number number of items - * - * \return null if error - */ -function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number) -{ - echo_debug('user_form_ach.php',__LINE__,"Enter form_verify_input $p_cn,$p_jrn,$p_periode,".var_export($p_array,true).",$p_number"); - foreach ($p_array as $name=>$content) { - ${"$name"}=$content; - } - // Verify the amount for each - // - // Check for CA - $own = new Own($p_cn); - - - // Verify the date - if ( isDate($e_date) == null ) - { - echo_error("Invalid date $e_date"); - echo_debug('user_form_ach.php',__LINE__,"Invalid date $e_date"); - echo ""; - return null; - } - $tot=0; -// Verify the quantity - for ($o = 0;$o < $p_number; $o++) - { - if ( isNumber(${"e_quant$o"}) == 0 ) - { - echo_debug('user_form_ach.php',__LINE__,"invalid quantity ".${"e_quant$o"}); - echo_error("invalid quantity ".${"e_quant$o"}); - echo ""; - return null; - } - // check if vat is correct - if ( strlen(trim(${"e_march$o"."_tva_id"})) !=0 - and - ${"e_march$o"."_tva_id"} != "-1") - { - // vat is given we check it now check if valid - if (isNumber(${"e_march$o"."_tva_id"}) == 0 - or CountSql($p_cn,"select tva_id from tva_rate where tva_id=".${"e_march$o"."_tva_id"}) ==0) - { - $msg="Invalid TVA !!! e_march".$o."_tva_id = ".${"e_march".$o."_tva_id"}; - echo_error($msg); echo_error($msg); - echo ""; - return null; - - } - - } - // if tva_amount is not a number than reset to 0 - if ( strlen(trim(${"e_march".$o."_tva_amount"})) !=0 && - isNumber (${"e_march".$o."_tva_amount"}) == 0) - { - ${"e_march".$o."_tva_amount"}=0; - } - // if amount is not empty and is not a number - if ( strlen(trim(${"e_march".$o."_buy"})) !=0 && isNumber(${"e_march".$o."_buy"}) == 0 ) - { - echo_debug('user_form_ach.php',__LINE__,"Prix invalide ".${"e_march$o"}); - echo_error("Prix n'est pas un montant valide ".${"e_march$o"}); - echo ""; - return null; - - } - if ( $own->MY_ANALYTIC!='nu') // use of AA - { - if ( isset (${"amount_t".$o})){ - $hidden_amount=${"amount_t".$o}; - $ca_amount=0; - // first we get the number of row for each item - for ($line=1;$line <=${"nb_t".$o};$line++) { - $ca_amount+=${"val".$o."l".$line}; - } - - // compare hidden value and computed - if ( round($ca_amount-$hidden_amount,2) != 0 ) { - - $msg="Montant CA est différent total marchandise"; - - echo ""; - - return null; - - } - - } - } - - $tot+=${"e_march".$o."_buy"}*${"e_quant$o"}; - } - - // if total amount == 0 we don't go further - if ( $tot == 0 ) - return null; - - // Verify the ech - if (strlen($e_ech) != 0 and isNumber($e_ech) == 0 and isDate ($e_ech) == null ) - { - $msg="Echeance invalide"; - echo_error($msg); echo_error($msg); - echo ""; - return null; - } - - // if ech is a number of days then compute date limit - if ( strlen($e_ech) != 0 and isNumber($e_ech) == 1) - { - list($day,$month,$year)=explode(".",$e_date); - echo_debug('user_form_ach.php',__LINE__," date $e_date = $day.$month.$year"); - $p_ech=date('d.m.Y',mktime(0,0,0,$month,$day+$e_ech,$year)); - echo_debug('user_form_ach.php',__LINE__,"p_ech = $e_ech $p_ech"); - $e_ech=$p_ech; - $wHidden=new widget("hidden"); - $data.=$wHidden->IOValue("e_ech",$e_ech); - - } - - // Check if the fiche is in the jrn - if (IsFicheOfJrn($p_cn , $p_jrn, $e_client,'cred') == 0 ) - { - $msg="Client invalid please recheck"; - echo_error($msg); - echo ""; - return null; - } - // Check if the customer card has a valid account - if ( CheckPoste($p_cn,$e_client) == null ) - return null; - - // check if all e_march are in fiche - for ($i=0;$i<$p_number;$i++) - { - if ( trim(${"e_march$i"}) == "" ) { - // no goods to sell - continue; - } - - // Check - if ( isFicheOfJrn($p_cn,$p_jrn,${"e_march$i"},'deb') == 0 ) { - $msg="Fiche inexistante !!! "; - echo_error(__FILE__.__LINE__.$msg); - echo ""; - return null; - } - if ( CheckPoste($p_cn,${"e_march".$i}) == null ) - return null; - - // Check if the percentage indicated in this field is valid - $non_dedu=GetFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_DEPENSE_NON_DEDUCTIBLE); - if ( $non_dedu != null && strlen(trim($non_dedu)) != 0 ) - { - if ( isNumber($non_dedu) == 0 || $non_dedu > 1.00 ) - { - $msg="La fiche ".${"e_march$i"}." a un pourcentage invalide,il doit etre compris entre 0 et 1"; - echo_error($msg); echo_debug('user_form_ach.php',__LINE__,$msg); - echo ""; - return null; - - } - } - // Check if the percentage indicated in this field is valid - $non_dedu=GetFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_TVA_NON_DEDUCTIBLE); - if ( $non_dedu != null && strlen(trim($non_dedu)) != 0 ) - { - if ( isNumber($non_dedu) == 0 || $non_dedu > 1.00 ) - { - $msg="La fiche ".${"e_march$i"}." a un pourcentage invalide, il doit etre compris entre 0 et 1"; - echo_error($msg); echo_debug('user_form_ach.php',__LINE__,$msg); - echo ""; - return null; - - } - } // Check if the percentage indicated in this field is valid - $non_dedu=GetFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP); - if ( $non_dedu != null && strlen(trim($non_dedu)) != 0 ) - { - if ( isNumber($non_dedu) == 0 || $non_dedu > 1.00 ) - { - $msg="La fiche ".${"e_march$i"}." a un pourcentage invalide, il doit etre compris entre 0 et 1"; - echo_error($msg); echo_debug('user_form_ach.php',__LINE__,$msg); - echo ""; - return null; - - } - } - - } -// Verify the userperiode - -// p_periode 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 ('user_form_ach',__LINE__,"date start periode $l_date_start date fin periode $l_date_end date demande $e_date"); - if ( cmpDate($e_date,$l_date_start)<0 || - cmpDate($e_date,$l_date_end)>0 ) - { - $msg="Not in the active periode please change your preference"; - echo_error($msg); echo_error($msg); - echo ""; - return null; - } - // Periode ferm� - $per=new Periode($p_cn); - $per->set_jrn($p_jrn); - $per->set_periode($p_periode); - - // Periode ferme - if ( $per->is_open() == 0) - { - $msg="Cette periode est fermee pour ce journal"; - echo_error($msg); echo_error($msg); - echo ""; - return null; - } - return true; -} -/*! - ************************************************** - * \brief Show the invoice before inserting it - * the database - * - * \param $p_cn database connection - * \param p_jrn journal - * \param $p_periode - * \param $p_array array of value - * \param $p_number nb of item - *\param $p_piece == true we can upload a doc. - * - */ - -function FormAchView ($p_cn,$p_jrn,$p_periode,$p_array,$p_submit,$p_number,$p_piece=true) -{ - echo_debug(__FILE__.':'.__LINE__.'- FormAchView'); - $r=""; - $data=""; - $own=new own($p_cn); - // Keep all the data if hidden - // and store the array in variables - $hidden=new widget("hidden"); - foreach ($p_array as $name=>$content) { - // not the CA data - if ( strpos( $name,"ta_")===false && - strpos( $name,"nb_t")===false && - strpos( $name,"val")===false ) - $data.=$hidden->IOValue($name,$content); - - ${"$name"}=$content; - } - // Compute href - // $href=basename($_SERVER['PHP_SELF']); - $href=basename($_SERVER['PHP_SELF']); - switch ($href) - { - // user_jrn.php - case 'user_jrn.php': - $href="user_jrn.php?action=new&p_jrn=$p_jrn"; - break; - case 'commercial.php': - $href="commercial.php?p_action=depense&p_jrn=$p_jrn"; - break; - default: - echo_error('user_form_ach.php',__LINE__,'Erreur invalid request uri'); - exit (-1); - } - - $r.='
    '; - $r.=dossier::hidden(); - // start table - $r.=''; - // Show the Date - $r.=""; - $r.=""; - $r.=""; - // Show the customer Name - $r.=""; - $r.=""; - $r.=""; - - // show date limit - $r.=""; - $r.=""; - $r.=""; - // Show desc - $r.=""; - $r.=""; - - $r.=""; - - $sum_with_vat=0.0; - $sum_march=0.0; - // show all article, price vat and sum - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - for ($i=0;$i<$p_number;$i++) - { - if ( trim(${"e_march$i"}) == "" ) - { - // no goods to sell - continue; - } - - // Get the name - $fiche_name=getFicheName($p_cn,${"e_march$i"}); - - // Quantity - $fiche_quant=${"e_quant$i"}; - - // No row if there is quantity - if ( $fiche_quant == 0.0 ) continue; - - - // If the price is not a number, retrieve the price from the database - if ( isNumber(${"e_march$i"."_buy"}) == 0 ) - { - $fiche_price=getFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_PRIX_VENTE); - } else - { - $fiche_price=${"e_march$i"."_buy"}; - } - // round it - $fiche_price=round($fiche_price,2); - - // get TVA Amount - $tva_amount=round(${"e_march".$i."_tva_amount"},2); - - // VAT - $vat=(isNumber(${"e_march$i"."_tva_id"})==0 || ${"e_march$i"."_tva_id"}==-1 )?getFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_TVA):${"e_march$i"."_tva_id"}; - - // vat label - // vat rate - $a_vat=GetTvaRate($p_cn,$vat); - if ( $a_vat == null ) - { - $vat_label=""; - $vat_rate=0.0; - } - else - { - $vat_label=$a_vat['tva_label']; - $vat_rate=$a_vat['tva_rate']; - } - - // Total card without vat - $fiche_sum=$fiche_price*$fiche_quant; - // Sum of invoice - $sum_march+=$fiche_sum; - // vat of the card - if ( $tva_amount == 0) - { - $fiche_amount_vat=round($fiche_price*$fiche_quant*$vat_rate,2); - echo_debug(__FILE__.':'.__LINE__.'- Tva Amount is computed '.$fiche_amount_vat); - - // value card + vat - $fiche_with_vat=round($fiche_price*$fiche_quant,2)+$fiche_amount_vat; - } - else - { - echo_debug(__FILE__.':'.__LINE__.'- Tva Amount is given '.$tva_amount); - $fiche_amount_vat=$tva_amount; - // value card + vat - $fiche_with_vat=round($fiche_price*$fiche_quant,2)+$tva_amount; - } - // Sum of invoice vat - $sum_with_vat+=$fiche_with_vat; - echo_debug(__FILE__.':'.__LINE__.'- Sum_with_vat='.$fiche_with_vat); - // Show the data - $r.=''; - $r.=''; - $r.=''; - $r.=''; - $r.=""; - $r.=''; - $r.=''; - - $r.=''; - //---------------------------------------------------------------------- - // CA - //---------------------------------------------------------------------- - // to show a select list for the analytic - // if analytic is op (optionnel) there is a blank line - - // encode the pa - - if ( $own->MY_ANALYTIC!='nu') // use of AA - { - // show form - $op=new Anc_Operation($p_cn); - $null=($own->MY_ANALYTIC=='op')?1:0; - $p_mode=($p_piece)?1:0; - $r.=''; - - } - - //---------------------------------------------------------------------- - $r.=""; - } - - // end table - $r.='
    Date : $e_date
    Client : ".getFicheName($p_cn,$e_client)."
    Echeance : $e_ech
    Description : $e_comm
    Articlequantitéprix unit.taux tvaMontant HTVAMontant TVATotal
    '.$fiche_name.''.$fiche_quant.''.$fiche_price.' $vat_label '.round($fiche_sum,2).''.round($fiche_amount_vat,2).''.round($fiche_with_vat,2).''; - $r.=$op->display_form_plan($_POST,$null,$p_mode,$i,round($fiche_sum,2)); - $r.='
    '; - $r.='
    '; - $r.="Total HTVA =".round( $sum_march,2)."
    "; - $r.="Total = ".round($sum_with_vat,2); - - - $r.="
    "; - - // check for upload piece - // Set correctly the REQUEST param for jrn_type - $h=new widget('hidden'); - $h->name='jrn_type'; - $h->value=$_REQUEST['jrn_type']; - $r.=$h->IOValue(); - - $file=new widget("file"); - $file->table=1; - $r.="
    "; - $r.= ""; - if ( $p_piece) $r.="".$file->IOValue("pj","","Pièce justificative").""; - // propose to save the pre_operation - if ( $p_piece ) { - $chk=new widget('checkbox'); - $chk->selected=true; - $r.="Sauvez l'opération ?"; - $r.=$chk->IOValue('opd_save'); - - } - $r.="
    "; - $r.="
    "; - - $r.=$data; - $r.=$p_submit; - - $r.='
    '; - - return $r; - -} - -/*! - ************************************************** - * \brief Record an invoice in the table jrn & - * jrnx - * - * parm : - * - $p_cn Database connection - * - $p_array contains all the invoice data - * e_date => e : 01.01.2003 - * e_client => e : 3 - * nb_item => e : 3 - * e_march0 => e : 6 - * e_quant0 => e : 0 - * e_march0_buy=>e:1 - * e_march1 => e : 6 - * e_quant1 => e : 2 - * e_march1_buy=>e:1 - * e_march2 => e : 7 - * e_quant2 => e : 3 - * e_march2_buy=>e:1 -V : view_invoice => e : Voir cette facture -V : record_invoice => e : Sauver - * - $p_periode periode - * - $p_jrn current folder (journal) - * gen : - * - none - * return: - * true on success - */ -function RecordSell($p_cn,$p_array,$p_user,$p_jrn) -{ - echo_debug('user_form_ach',__LINE__,"function RecordSell($p_cn,$p_array,$p_user->id,$p_jrn)"); - foreach ( $p_array as $v => $e) - { - ${"$v"}=$e; - } - - // Get the default period - $periode=$p_user->get_periode(); - $amount=0.0; - $amount_jrn=0.0; - $sum_tva_nd=0.0; - // own - $own=new own($p_cn); - $group=NextSequence($p_cn,"s_oa_group"); - - // Computing total customer - for ($i=0;$i<$nb_item;$i++) { - // store quantity & goods in array - $a_good[$i]=${"e_march$i"}; - $a_quant[$i]=${"e_quant$i"}; - $a_price[$i]=0; - $a_vat_good[$i]=${"e_march$i"."_tva_id"}; - $a_vat_amount[$i]=round(${"e_march".$i."_tva_amount"},2); - - // check wether the price is set or no - if ( isNumber(${"e_march$i"."_buy"}) == 0 ) { - if ( $a_good[$i] !="" ) - { - // If the price is not set we have to find it from the database - $a_price[$i]=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_PRIX_VENTE); - } - } - else - { - // The price is valid - $a_price[$i]=${"e_march$i"."_buy"}; - } - - $a_price[$i]=round($a_price[$i],2); - - $cost=$a_price[$i]*$a_quant[$i]; - $amount+=$cost; - $amount_jrn+=$cost; - echo_debug('user_form_ach.php',__LINE__,'Total customer:'.$amount_jrn); - } - // $amount_jrn=round( - $comm=FormatString($e_comm); - - // Compute vat with ded - echo_debug('user_form_achat.php',__LINE__,"Call ComputeTotalVat"); - $a_vat=ComputeTotalVat($p_cn,$a_good,$a_quant,$a_price,$a_vat_good,$a_vat_amount,false); - try { - StartSql($p_cn); - - // Compute the j_grpt - $seq=NextSequence($p_cn,'s_grpt'); - // Set Internal code and Comment - $oJrn=new Acc_Ledger($p_cn,$p_jrn); - $internal=$oJrn->compute_internal_code($seq); - - - - // Credit = goods - for ( $i = 0; $i < $nb_item;$i++) { - - // store not deductible and vat deductible via tax - $aNd_amount[$i]=0.0; - $aTva_ded_impot[$i]=0.0; - $aTva_ded_impot_recup[$i]=0.0; - $aDep_priv[$i]=0.0; - - - $poste=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_ACCOUNT); - - // don't record operation of 0 - if ( $a_price[$i]*$a_quant[$i] == 0 ) continue; - - $amount=$a_price[$i]*$a_quant[$i]; - //We don't compute vat if it's given - $lvat=($a_vat_amount[$i]==0)?ComputeVat($p_cn,$a_good[$i],$a_quant[$i],$a_price[$i], $a_vat_good[$i],$a_vat_amount[$i] ):$a_vat_amount[$i]; - //---------------------------------------------------------------------- - // Put the non deductible part into a special account - $non_dedu=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_DEPENSE_NON_DEDUCTIBLE); - echo_debug('user_form_ach.php',__LINE__,"value non ded : $non_dedu"); - if ( $non_dedu != null && strlen(trim($non_dedu)) != 0) - { - // this doens't concern the vat - $nd_amount=round($a_quant[$i]*$a_price[$i]*$non_dedu,2); - // save it - echo_debug('user_form_ach.php',__LINE__,"InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,'6740',$e_date,round($nd_amount,2),$seq,$periode);"); - $dna=new Acc_Parm_Code($p_cn,'DNA'); - $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$dna->p_value,$e_date,round($nd_amount,2),$seq,$periode); - $amount=$amount-$nd_amount; - - // save the ND in an array (for the easy view) - $aNd_amount[$i]=$nd_amount; - } - //---------------------------------------------------------------------- - // Put the non deductible part into a special account - $non_dedu=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_DEP_PRIV); - echo_debug('user_form_ach.php',__LINE__,"value non ded : $non_dedu"); - if ( $non_dedu != null && strlen(trim($non_dedu)) != 0) - { - // Remove also the vat - $nd_amount=round($a_quant[$i]*$a_price[$i]*$non_dedu,2); - $tva_nd=round($lvat*$non_dedu,2); - $nd_amount+=$tva_nd; - - // save it - $dna=new Acc_Parm_Code($p_cn,'DEP_PRIV'); - $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$dna->p_value,$e_date,round($nd_amount,2),$seq,$periode); - - // modify sum - $amount=$amount-$nd_amount+$tva_nd; - $lvat-=$tva_nd; - - $sum_tva_nd+=$tva_nd; - - // save the ND in an array (for the easy view) - $aDep_priv[$i]=$nd_amount; - } - - //---------------------------------------------------------------------- - // Put the non deductible part into a special account - $non_dedu=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_TVA_NON_DEDUCTIBLE); - echo_debug('user_form_ach.php',__LINE__,"TVA value non ded : $non_dedu"); - if ( $non_dedu != null && strlen(trim($non_dedu)) != 0) - { - $ded_vat=($lvat != null )?$lvat*$non_dedu:0; - $ded_vat=round($ded_vat,2); - $aTva_ded_impot[$i]=$ded_vat; - $sum_tva_nd+=$ded_vat; - - // compute the NDA TVA - $tva_dna=new Acc_Parm_Code($p_cn,'TVA_DNA'); - echo_debug('user_form_ach.php',__LINE__, - "InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,".$tva_dna->p_value.",$e_date,round($ded_vat,2),$seq,$periode);"); - - $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$tva_dna->p_value,$e_date,round($ded_vat,2),$seq,$periode); - } - //---------------------------------------------------------------------- - // Put the non deductible part into a special account - $non_dedu=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_TVA_NON_DEDUCTIBLE_RECUP); - echo_debug('user_form_ach.php',__LINE__,"TVA value non ded : $non_dedu"); - - if ( $non_dedu != null && strlen(trim($non_dedu)) != 0 ) - { - - $ded_vat=($lvat != null )?$lvat*$non_dedu:0; - - $sum_tva_nd+=round($ded_vat,2); - $aTva_ded_impot_recup[$i]=round($ded_vat,2); - - // Save it - $tva_ded_impot=new Acc_Parm_Code($p_cn,'TVA_DED_IMPOT'); - echo_debug('user_form_ach.php',__LINE__, - "InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,".$tva_ded_impot->p_value.",$e_date,round($ded_vat,2),$seq,$periode);"); - - $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$tva_ded_impot->p_value,$e_date,round($ded_vat,2),$seq,$periode); - } - //---------------------------------------------------------------------- - - - - // record into jrnx - echo_debug('user_form_ach.php',__LINE__,"InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($amount,2),$seq,$periode);"); - $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($amount,2),$seq,$periode,$a_good[$i]); - - /*! \brief if the quantity is < 0 then the stock increase (return of - * material) - */ - $nNeg=($a_quant[$i]<0)?-1:1; - - // always save quantity but in withStock we can find what card need a stock management - InsertStockGoods($p_cn,$j_id,$a_good[$i],$nNeg*$a_quant[$i],'d'); - echo_debug('user_form_ach.php',__LINE__,"value non ded : ".$a_good[$i]."is"); - if ( $own->MY_ANALYTIC != "nu" ) - { - // for each item, insert into operation_analytique */ - $op=new Anc_Operation($p_cn); - $op->oa_group=$group; - $op->j_id=$j_id; - $op->oa_date=$e_date; - $op->oa_debit=($op->oa_amount < 0 )?'f':'t'; - $op->oa_description=$comm; - $op->save_form_plan($_POST,$i); - } - //--------------------------------------------------------- - // insert into quant_purchase - //--------------------------------------------------------- - - echo_debug(__FILE__.":".__LINE__,"a_vat = ",$a_vat); - // echo_debug(__FILE__.":".__LINE__."a_vat[$i] =",$a_vat[$i]); - //!\note - // $a_vat_good[$i] contains the tva_id - // $a_vat_amount[$i] contains the amount of vat - $vat_code=$a_vat_good[$i]; - // $computed_vat=$lvat-$aNd_amount[$i]-$aTva_ded_impot[$i]-$aTva_ded_impot_recup[$i]; - $computed_vat=$lvat-$aTva_ded_impot[$i]-$aTva_ded_impot_recup[$i]; - $qp_vat=($vat_code==-1)?0:$computed_vat; - - echo_debug('form_ach',__LINE__,"Insert into insert_quant_purchase"); - $r=ExecSql($p_cn,"select insert_quant_purchase ". - "('".$internal."'". - ",".$j_id. - ",'".$a_good[$i]."'". - ",".$a_quant[$i].",". - round($amount,2). - ",".$qp_vat. - ",".$vat_code. - ",".$aNd_amount[$i]. - ",".$aTva_ded_impot[$i]. - ",".$aTva_ded_impot_recup[$i]. - ",".$aDep_priv[$i]. - ",'".$e_client."')"); - - - - } // end loop - - // set up internal code for quant_purchase - - // Insert Vat - $sum_tva=0.0; - if ( $a_vat != null ) // no vat - { - echo_debug('user_form_ach',__LINE__,'a_vat = '.var_export($a_vat,true)); - foreach ($a_vat as $tva_id => $e_tva_amount ) - { - echo_debug('user_form_ach',__LINE__," tva_amount = $e_tva_amount tva_id=$tva_id"); - //if ($e_tva_amount == 0 ) continue; - - $poste=GetTvaPoste($p_cn,$tva_id,'d'); - - $r=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($e_tva_amount,2),$seq,$periode); - $sum_tva+=round($e_tva_amount,2); - } - } - echo_debug('user_form_ach.php',__LINE__,"echeance = $e_ech"); - echo_debug('user_form_ach.php',__LINE__,"sum_tva = $sum_tva"); - echo_debug('user_form_ach.php',__LINE__,"amount_jrn = $amount_jrn"); - echo_debug('user_form_ach.php',__LINE__,"sum_tva_nd = $sum_tva_nd"); - - // Debit = client - $poste=GetFicheAttribut($p_cn,$e_client,ATTR_DEF_ACCOUNT); - echo_debug('user_form_achat.php',__LINE__,"get e_client $e_client poste $poste"); - echo_debug('user_form_achat.php',__LINE__,"insert client"); - - $r=InsertJrnx($p_cn,'c',$p_user->id,$p_jrn,$poste,$e_date,round($amount_jrn+$sum_tva+$sum_tva_nd,2),$seq, - $periode,$e_client); - - - $r=InsertJrn($p_cn,$e_date,$e_ech,$p_jrn,"--",$seq,$periode); - - // Set Internal code and Comment - $Res=ExecSql($p_cn,"update jrn set jr_internal='".$internal."' where ". - " jr_grpt_id = ".$seq); - - $comment=(FormatString($e_comm) == null )?$internal." Fournisseur : ".GetFicheName($p_cn,$e_client):FormatString($e_comm); - - // Update and set the invoice's comment - $Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq); - - if ( isset ($_FILES)) - save_upload_document($p_cn,$seq); - // Save the operation - if ( isset($_POST['opd_save']) && $_POST['opd_save']=='on' ){ - echo_debug(__FILE__.':'.__LINE__.'- ','save opd'); - $opd=new Pre_op_ach($p_cn); - $opd->get_post(); - $opd->save(); - echo_debug(__FILE__.':'.__LINE__.'- ',"opd = ",$opd); - } - } catch (Exception $e) { - echo ''. - 'Erreur dans l\'enregistrement '. - __FILE__.':'.__LINE__.' '. - $e->getMessage(); - Rollback($p_cn); - exit(); - } - Commit($p_cn); - - return array($internal,$comment); -} - -?> diff --git a/include/user_form_fin.php b/include/user_form_fin.php deleted file mode 100644 index 1b90416a2..000000000 --- a/include/user_form_fin.php +++ /dev/null @@ -1,501 +0,0 @@ -$content) { - ${"$name"}=$content; - } - // Verify the date - if ( isDate($e_date) == null ) { - echo_error('user_form_fin.php',__LINE__,"Invalid date $e_date"); - echo ""; - return null; - } - - - // Check if the fiche is in the jrn - if (IsFicheOfJrn($p_cn , $p_jrn, $e_bank_account,'deb') == 0 ) - { - $msg="Mauvais compte en banque"; - echo_error('user_form_fin.php',__LINE__,$msg); - echo ""; - return null; - } - // Check if the card has a valid account - if ( CheckPoste($p_cn,$e_bank_account) == null ) - return null; - $empty=0; - // check if all e_march are in fiche - for ($i=0;$i<$p_number;$i++) { - if ( trim(${"e_other$i"}) == "" ) { - // nothing to do - $empty++; - continue; - } - // Check amount - if ( isNumber(${"e_other".$i."_amount"}) == 0) { - $msg="Montant invalide !!! "; - echo_error('user_form_fin.php',__LINE__,$msg); - echo ""; - return null; - } - // Check - if ( isFicheOfJrn($p_cn,$p_jrn,${"e_other$i"},'cred') == 0 ) { - $msg="Fiche inexistante !!! "; - echo_error('user_form_fin.php',__LINE__,$msg); - echo ""; - return null; - } - // Check if the card has a valid account - if ( CheckPoste($p_cn,${"e_other".$i}) == null ) - return null; - } - if ( $empty == $p_number) { - $msg="Aucune fiche n'est donnee "; - echo ""; - return null; - } -// Verify the userperiode - -// p_periode 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 ('user_form_fin',__LINE__,"date start periode $l_date_start date fin periode $l_date_end date demande $e_date"); - if ( cmpDate($e_date,$l_date_start)<0 || - cmpDate($e_date,$l_date_end)>0 ) - { - $msg="Not in the active periode please change your preference"; - echo_debug('user_form_fin.php',__LINE__,$msg); - echo ""; - return null; - } - // Periode ferm� - $per=new Periode($p_cn); - $per->set_jrn($p_jrn); - $per->set_periode($p_periode); - if ( $per->is_open()==0 ) - { - $msg="Cette periode est fermee pour ce journal"; - echo_debug('user_form_fin.php',__LINE__,$msg); - echo ""; - return null; - } - return true; -} - - -/*! - * \brief Display the form for financial - * Used to show detail, encode a new fin op - * or update one - * - * \param $p_cn database connection - * \param $p_jrn ledger id (jr_id) - * \param $p_submit contains the submit string - * \param $p_array (default=null) containing the $_POST - * \param $p_view_only (default=true) true if we cannot change it (no right or centralized op) - * \param $p_item number of article (default=4) - * \param $p_save (default false) if the operation is already recorded - * - * - * \return string with the form, in readonly or writable mode - */ -function FormFin($p_cn,$p_jrn,$p_periode,$p_submit,$p_array=null,$pview_only=true,$p_item=4,$p_save=false) -{ - include_once("poste.php"); - if ( $p_array != null ) { - // array contains old value - foreach ( $p_array as $a=>$v) { - ${"$a"}=$v; - } - } - // The date - list ($l_date_start,$l_date_end)=get_periode($p_cn,$p_periode); - $flag=(isset($e_date))?1:0; - // $e_date=( ! isset($e_date) ) ? substr($l_date_start,2,8):$e_date; - $e_date=( ! isset($e_date) ) ? $l_date_start:$e_date; - // Comment - $e_comment=(isset($e_comment))?$e_comment:""; - - $r=""; - if ( $pview_only == false) { - $r.=JS_SEARCH_CARD; - $r.=JS_CONCERNED_OP; - } - // Compute href - // $href=basename($_SERVER['PHP_SELF']); - $href=basename($_SERVER['PHP_SELF']); - switch ($href) - { - // user_jrn.php module "Comptable" - case 'user_jrn.php': - $href="user_jrn.php?action=new&p_jrn=$p_jrn"; - break; - // commercial.php module "Gestion" - case 'commercial.php': - $href="commercial.php?p_action=bank&p_jrn=$p_jrn"; - break; - default: - echo_error('user_form_fin.php',__LINE__,'Erreur invalid request uri'); - exit (-1); - } - - $r.="
    "; - $r.=dossier::hidden(); - $hid=new widget('hidden'); - $r.=$hid->IOValue('p_jrn',$p_jrn); - $r.='
    '; - $r.='Banque'; - $r.=''; - $Date=new widget("js_date"); - $Date->SetReadOnly($pview_only); - $Date->table=1; - $r.=""; - $r.=$Date->IOValue("e_date",$e_date,"Date"); - $r.=""; - - - include_once("fiche_inc.php"); - $r.=''; - - // bank_account operation - // Save old value and set a new one - $e_bank_account=( isset ($e_bank_account) )?$e_bank_account:""; - $e_bank_account_label=""; - - // retrieve e_bank_account_label - if ( $e_bank_account != "" ) { - $a_client=GetFicheAttribut($p_cn,$e_bank_account); - if ( $a_client != null) - $e_bank_account_label=$a_client['vw_name']." adresse ".$a_client['vw_addr']." ".$a_client['vw_cp']; - } - // search widget - $W1=new widget("js_search"); - $W1->readonly=$pview_only; - $W1->label="Banque"; - $W1->name="e_bank_account"; - $W1->value=$e_bank_account; - $W1->extra=FICHE_TYPE_FIN; // credits - $W1->extra2=$p_jrn; - $r.="".$W1->IOValue().""; - $Span=new widget ("span"); - $Span->SetReadOnly($pview_only); - $r.=""; - - $r.="
    ".$Span->IOValue("e_bank_account_label",$e_bank_account_label)."
    "; - - - - // ComputeBanqueSaldo - // - if ( $pview_only == true ) { - $solde=get_solde($p_cn,GetFicheAttribut($p_cn,$e_bank_account,ATTR_DEF_ACCOUNT)); - $r.=" Solde = ".$solde." "; - $new_solde=$solde; - } - $r.='
    '; - // Start the div for item to move money - $r.="
    "; - $r.='

    détails opérations

    '; - $r.=''; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=''; - $r.=""; - // Parse each " tiers" - for ($i=0; $i < $p_item; $i++) { - $tiers=(isset(${"e_other".$i}))?${"e_other".$i}:""; - $tiers_label=""; - $tiers_amount=(isset(${"e_other$i"."_amount"}))?round(${"e_other$i"."_amount"},2):0; - - $tiers_comment=(isset (${"e_other$i"."_comment"}))?${"e_other$i"."_comment"}:""; - // If $tiers has a value - if ( $tiers != "" ) - { - // retrieve the tva label and name - $a_fiche=GetFicheAttribut($p_cn, $tiers); - if ( $a_fiche != null ) { - $tiers_label=$a_fiche['vw_name']; - } - } - ${"e_other$i"."_amount"}=(isset (${"e_other$i"."_amount"}))?${"e_other$i"."_amount"}:0; - - $W1=new widget("js_search"); - $W1->label=""; - $W1->name="e_other".$i; - $W1->value=$tiers; - $W1->extra='cred'; // credits - $W1->extra2=$p_jrn; - $W1->readonly=$pview_only; - $r.="".$W1->IOValue().""; - // label - $other=new widget("span"); - $r.="'; - // if not recorded the new amount must be recalculate - // if recorded the old amount is recalculated - if ( $pview_only == true) - $new_solde=($p_save==false)?$new_solde+$tiers_amount:$new_solde-$tiers_amount; - } - -$r.="
    codeDénominationDescriptionMontant Op. Concernée(s)
    "; - $r.=$other->IOValue("e_other$i"."_label", $tiers_label); - // Comment - $wComment=new widget("text"); - $wComment->table=1; - $wComment->SetReadOnly($pview_only); - $r.=$wComment->IOValue("e_other$i"."_comment",$tiers_comment); - // amount - $wAmount=new widget("text"); - $wAmount->table=1; - $wAmount->size=7; - $wAmount->SetReadOnly($pview_only); - $r.=$wAmount->IOValue("e_other$i"."_amount",$tiers_amount); - // concerned - ${"e_concerned".$i}=(isset(${"e_concerned".$i}))?${"e_concerned".$i}:""; - $wConcerned=new widget("js_concerned"); - $wConcerned->SetReadOnly($pview_only); - $wConcerned->extra=0; - $wConcerned->table=1; - $wConcerned->extra2='paid'; - $r.=$wConcerned->IOValue("e_concerned".$i,${"e_concerned".$i}); - $r.='
    "; - - if ( $pview_only==true && $p_save==false) { - // check for upload piece - $file=new widget("file"); - $file->table=1; - $r.="
    "; - $r.= ""; - $r.="".$file->IOValue("pj","","Pièce justificative").""; - $r.="
    "; - $r.="
    "; - $chk=new widget('checkbox'); - $chk->selected=false; - $r.="Sauvez l'opération ?"; - $r.=$chk->IOValue('opd_save'); - - $name=new widget('text'); - $r.='nom de l\' opération ?'.$name->IOValue('predef'); - - } - // Set correctly the REQUEST param for jrn_type - $h=new widget('hidden'); - $h->name='jrn_type'; - $h->value='FIN'; - $r.=$h->IOValue(); - -$r.=$p_submit; -$r.="
    "; -$r.="
    "; - -// if view_only is true -//Put the new saldo here (old saldo - operation) - if ( $pview_only==true) { - $solde=round($solde,2); - $new_solde=round($new_solde,2); - - // if not recorded the new amount must be recalculate - if ( $p_save == false) { - $r.=" Ancien Solde = ".$solde."
    "; - $op=$new_solde-$solde; - $r.=" Montant opération =".$op."
    "; - $r.=" Nouveau Solde = ".$new_solde."
    "; - } - // if recorded the old amount is recalculated - if ($p_save == true ) { - $op=$solde-$new_solde; - $r.=" Ancien Solde = ".$new_solde."
    "; - $r.=" Montant opération =".$op."
    "; - $r.=" Nouveau Solde = ".$solde."
    "; - } - } - -return $r; - - -} - -/*! - ************************************************** - * \brief Record an invoice in the table jrn & - * jrnx - * - * - * \param $p_cn Database connection - * \param $p_array contains all the invoice data - * e_date => e : 01.01.2003 - * e_bank_account => e : 3 - * \param $p_user userid - * \param $p_jrn current folder (journal) - * \param array e_other$i, e_other$i_amount, e_other$i_label - - * \return true on success - * - */ -function RecordFin($p_cn,$p_array,$p_user,$p_jrn) { - $internal_code=""; - $oid=0; - echo_debug('user_form_fin.php',__LINE__,"RecordFin"); - foreach ( $p_array as $v => $e) - { - ${"$v"}=$e; - } - // Get the default period - $periode=$p_user->get_periode(); - - // Debit = banque - $poste_bq=GetFicheAttribut($p_cn,$e_bank_account,ATTR_DEF_ACCOUNT); - try - { - StartSql($p_cn); - $amount=0.0; - // Credit = goods - for ( $i = 0; $i < $nb_item;$i++) { - // if tiers is set and amount != 0 insert it into the database - // and quit the loop ? - if ( ${"e_other$i"."_amount"} == 0 || strlen(trim(${"e_other$i"}))==0 ) continue; - $poste=GetFicheAttribut($p_cn,${"e_other$i"},ATTR_DEF_ACCOUNT); - - // round it - ${"e_other$i"."_amount"}=round( ${"e_other$i"."_amount"},2); - - $amount+=${"e_other$i"."_amount"}; - // Record a line for the bank - // Compute the j_grpt - $seq=NextSequence($p_cn,'s_grpt'); - // Set Internal code and Comment - $oJrn=new Acc_Ledger($p_cn,$p_jrn); - $internal=$oJrn->compute_internal_code($seq); - - - InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste_bq,$e_date,round(${"e_other$i"."_amount"},2), - $seq,$periode,$e_bank_account) ; - - - // Record a line for the other account - $j_id=InsertJrnx($p_cn,'c',$p_user->id,$p_jrn,$poste,$e_date, - round(${"e_other$i"."_amount"},2),$seq,$periode,${"e_other$i"}); - - echo_debug('user_form_fin.php',__LINE__," $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,".${"e_other$i"}."_amount".",$seq,$periode);"); - - $jr_id=InsertJrn($p_cn,$e_date,'',$p_jrn,FormatString(${"e_other$i"."_comment"}), - $seq,$periode); - - if ( trim(${"e_concerned".$i}) != "" ) { - if ( strpos(${"e_concerned".$i},',') !== 0 ) - { - $aRapt=split(',',${"e_concerned".$i}); - foreach ($aRapt as $rRapt) { - if ( isNumber($rRapt) == 1 ) - { - InsertRapt($p_cn,$jr_id,$rRapt); - } - } - } else - if ( isNumber(${"e_concerned".$i}) == 1 ) - { - InsertRapt($p_cn,$jr_id,${"e_concerned$i"}); - } - } - - // Set Internal code and Comment - $Res=ExecSql($p_cn,"update jrn set jr_internal='".$internal."' where ". - " jr_grpt_id = ".$seq); - - $comment=$internal." compte : ".GetFicheName($p_cn,$e_bank_account); - if ( FormatString(${"e_other$i"."_comment"}) == null ) { - // Update comment if comment is blank - $Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq); - } - - - if ( $i == 0 ) - { - // first record we upload the files and - // keep variable to update other row of jrn - if ( isset ($_FILES)) - $oid=save_upload_document($p_cn,$seq); - - } else { - if ( $oid != 0 ) - { - ExecSql($p_cn,"update jrn set jr_pj=".$oid.", jr_pj_name='".$_FILES['pj']['name']."', ". - "jr_pj_type='".$_FILES['pj']['type']."' where jr_grpt_id=$seq"); - } - } - - } // for nbitem - // Save pre_operatoin - // Save the operation - if ( isset($_POST['opd_save']) && $_POST['opd_save']=='on' ){ - echo_debug(__FILE__.':'.__LINE__.'- ','save opd'); - $opd=new Pre_op_fin($p_cn); - $opd->get_post(); - $opd->operation->name=$_POST['predef']; - - $opd->save(); - echo_debug(__FILE__.':'.__LINE__.'- ',"opd = ",$opd); - } - - } - catch (Exception $e) - { - echo ''. - 'Erreur dans l\'enregistrement '. - __FILE__.':'.__LINE__.' '. - $e->getMessage(); - Rollback($p_cn); - exit(); - - } - Commit($p_cn); - return $internal; -} -?> diff --git a/include/user_form_ven.php b/include/user_form_ven.php deleted file mode 100644 index a2e5dec29..000000000 --- a/include/user_form_ven.php +++ /dev/null @@ -1,885 +0,0 @@ -$v) { - ${"$a"}=$v; - } - } - // The date - list ($l_date_start,$l_date_end)=get_periode($p_cn,$p_periode); - // $op_date=( ! isset($e_date) ) - // ?substr($l_date_start,2,8):$e_date; - $op_date=( ! isset($e_date) ) ?$l_date_start:$e_date; - $e_ech=(isset($e_ech))?$e_ech:""; - $e_comm=(isset($e_comm))?$e_comm:""; - // $e_jrn=(isset($e_jrn))?$e_jrn:""; - // Save old value and set a new one - - echo_debug('user_form_ven.php',__LINE__,"form_input.php.FormVentep_op_date is $op_date"); - $r=""; - if ( $pview_only == false) { - $r.=JS_SEARCH_CARD; - $r.=JS_SHOW_TVA; - $r.=JS_TVA; - // Compute href - // $href=basename($_SERVER['PHP_SELF']); - $href=basename($_SERVER['PHP_SELF']); - switch ($href) - { - // user_jrn.php - case 'user_jrn.php': - $href="user_jrn.php?action=insert_vente&p_jrn=$p_jrn"; - break; - case 'commercial.php': - $href="commercial.php?p_action=facture&p_jrn=$p_jrn"; - break; - default: - echo_error('user_form_ven.php',__LINE__,'Erreur invalid request uri'); - exit (-1); - } - - $r.="
    "; - $r.=dossier::hidden(); - - - } - $r.="
    "; - $r.="Detail client "; - - $r.=''; - // Date - //-- - $Date=new widget("js_date"); - $Date->SetReadOnly($pview_only); - $Date->table=1; - $Date->tabindex=1; - $r.=""; - $r.=$Date->IOValue("e_date",$op_date,"Date"); - $r.=""; - // Payment limit - //-- - $Echeance=new widget("js_date"); - $Echeance->SetReadOnly($pview_only); - $Echeance->table=1; - $Echeance->tabindex=2; - $r.=""; - $r.=$Echeance->IOValue("e_ech",$e_ech,"Echeance"); - $r.=""; - // Comment - //-- - $Commentaire=new widget("text"); - $Commentaire->table=1; - $Commentaire->SetReadOnly($pview_only); - $Commentaire->size=80; - $Commentaire->tabindex=3; - $r.=""; - $r.=$Commentaire->IOValue("e_comm",$e_comm,"Description"); - $r.=""; - include_once("fiche_inc.php"); - // Display the customer - //-- - $fiche='deb'; - echo_debug('user_form_ven.php',__LINE__,"Client Nombre d'enregistrement ".sizeof($fiche)); - // Save old value and set a new one - //-- - $e_client=( isset ($e_client) )?$e_client:""; - $e_client_label=""; - - // retrieve e_client_label - //-- - $a_client=GetFicheAttribut($p_cn,$e_client); - if ( $a_client != null) - $e_client_label=$a_client['vw_name']." adresse ".$a_client['vw_addr']." ".$a_client['vw_cp']; - - - $W1=new widget("js_search"); - $W1->label="Client"; - $W1->name="e_client"; - $W1->tabindex=3; - $W1->value=$e_client; - $W1->extra=$fiche; // list of card - $W1->extra2=$p_jrn; - $r.="".$W1->IOValue(); - $client_label=new widget("span"); - $r.= $client_label->IOValue("e_client_label",$e_client_label).""; - $r.="
    "; - - // Record the current number of article - $Hid=new widget('hidden'); - $r.=$Hid->IOValue("nb_item",$p_article); - $e_comment=(isset($e_comment))?$e_comment:""; - $r.="
    "; - - // Start the div for item to sell - $r.="
    "; - $r.='

    Détail articles vendus

    '; - $r.=''; - $r.=''; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=''; - // For each article - //-- - for ($i=0;$i< $p_article;$i++) { - // Code id, price & vat code - //-- - $march=(isset(${"e_march$i"}))?${"e_march$i"}:""; - $march_sell=(isset(${"e_march".$i."_sell"}))?${"e_march".$i."_sell"}:""; - $march_tva_id=(isset(${"e_march$i"."_tva_id"}))?${"e_march$i"."_tva_id"}:""; - - $march_tva_label=""; - $march_label=""; - - // retrieve the tva label and name - //-- - $a_fiche=GetFicheAttribut($p_cn, $march); - if ( $a_fiche != null ) { - if ( $march_tva_id == "" ) { - $march_tva_id=$a_fiche['tva_id']; - $march_tva_label=$a_fiche['tva_label']; - } - $march_label=$a_fiche['vw_name']; - } - - - // Show input - //-- - $W1=new widget("js_search"); - $W1->label=""; - $W1->name="e_march".$i; - $W1->value=$march; - $W1->extra='cred'; // credits - $W1->extra2=$p_jrn; - $W1->readonly=$pview_only; - $r.="".$W1->IOValue().""; - $Span=new widget ("span"); - $Span->SetReadOnly($pview_only); - // card's name, price - //-- - $r.=""; - // price - $Price=new widget("text"); - $Price->SetReadOnly($pview_only); - $Price->table=1; - $Price->size=9; - $r.=$Price->IOValue("e_march".$i."_sell",$march_sell); - // vat label - //-- - $select_tva=make_array($p_cn,"select tva_id,tva_label from tva_rate order by tva_rate desc",0); - $Tva=new widget("select"); - $Tva->table=1; - $Tva->selected=$march_tva_id; - $r.=$Tva->IOValue("e_march$i"."_tva_id",$select_tva); - - // quantity - //-- - $quant=(isset(${"e_quant$i"}))?${"e_quant$i"}:"1"; - $Quantity=new widget("text"); - $Quantity->SetReadOnly($pview_only); - $Quantity->table=1; - $Quantity->size=9; - //$r.=InputType("","TEXT","e_quant".$i,$quant,$pview_only); - $r.=$Quantity->IOValue("e_quant".$i,$quant); - $r.=""; - } - - - - $r.="
    CodeDénominationprixtvaquantité
    ".$Span->IOValue("e_march".$i."_label",$march_label)."
    "; - $r.="
    "; - // Set correctly the REQUEST param for jrn_type - $h=new widget('hidden'); - $h->name='jrn_type'; - $h->value='VEN'; - $r.=$h->IOValue(); - - if ($pview_only == false ) { - $r.=''; - $r.=''; - $r.="
    "; - $r.="
    "; - $r.=JS_CALC_LINE; - } else { - $r.="
    "; - - } - - - - return $r; - - -} -/*! form_verify_input - ************************************************** - * \brief verify if the data to insert are valid - * - * - * \param $p_cn database connection - * \param $p_jrn concerned ledger - * \param $User periode - * \param $array with the post data - * \param $p_number number of items - * - * \return null if error or true if everything is correct - */ -function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number) -{ - foreach ($p_array as $name=>$content) { - ${"$name"}=$content; - } - // Verify the amount for each - // - // Check for CA - $own = new Own($p_cn); - - // Verify the date - if ( isDate($e_date) == null ) { - echo_error("Invalid date $e_date"); - echo_debug('user_form_ven.php',__LINE__,"Invalid date $e_date"); - echo ""; - return null; - } -// Verify the quantity - for ($o = 0;$o < $p_number; $o++) { - if ( isNumber(${"e_quant$o"}) == 0 ) { - echo_debug('user_form_ven.php',__LINE__,"invalid quantity ".${"e_quant$o"}); - echo_error("invalid quantity ".${"e_quant$o"}); - echo ""; - return null; - } - // check if vat is correct - if ( strlen(trim(${"e_march$o"."_tva_id"})) !=0 - and - ${"e_march$o"."_tva_id"} != "-1") - { - // vat is given we check it now check if valid - if (isNumber(${"e_march$o"."_tva_id"}) == 0 - or CountSql($p_cn,"select tva_id from tva_rate where tva_id=".${"e_march$o"."_tva_id"}) ==0) - { - $msg="Invalid TVA !!! e_march".$o."_tva_id = ".${"e_march".$o."_tva_id"}; - echo_error($msg); - echo ""; - return null; - - } - } - - // encode the pa Check only for mandatory CA - if ( $own->MY_ANALYTIC!="nu") // use of AA - { - - if ( isset (${"amount_t".$o})){ - - $hidden_amount=${"amount_t".$o}; - $ca_amount=0; - // first we get the number of row for each item - for ($line=1;$line <=${"nb_t".$o};$line++) { - $ca_amount+=${"val".$o."l".$line}; - } - - // compare hidden value and computed - if ( round($ca_amount-$hidden_amount,2) != 0 ) { - - $msg="Montant CA est different total marchandise"; - $msg.="montant encode $ca_amount marchandise $hidden_amount"; - echo ""; - - return null; - - } - - } - } - - - } - -// Verify the ech - if (strlen($e_ech) != 0 and isNumber($e_ech) == 0 and isDate ($e_ech) == null ) { - $msg="Echeance invalide"; - echo_error($msg); echo_error($msg); - echo ""; - return null; - } - - // if ech is a number of days then compute date limit - if ( strlen($e_ech) != 0 and isNumber($e_ech) == 1) { - list($day,$month,$year)=explode(".",$e_date); - echo_debug('user_form_ven.php',__LINE__," date $e_date = $day.$month.$year"); - $p_ech=date('d.m.Y',mktime(0,0,0,$month,$day+$e_ech,$year)); - echo_debug('user_form_ven.php',__LINE__,"p_ech = $e_ech $p_ech"); - $e_ech=$p_ech; - $wHidden=new widget("hidden"); - $data.=$wHidden->IOValue("e_ech",$e_ech); - } - - // Check if the fiche is in the jrn - if (IsFicheOfJrn($p_cn , $p_jrn, $e_client,'deb') == 0 ) - { - $msg="Client invalid please recheck"; - echo_error($msg); - echo ""; - return null; - } - // Check if the card has a valid account - if ( CheckPoste($p_cn,$e_client) == null ) - return null; - - // check if all e_march are in fiche - for ($i=0;$i<$p_number;$i++) { - if ( trim(${"e_march$i"}) == "" ) { - // no goods to sell - continue; - } - - - // Check - if ( isFicheOfJrn($p_cn,$p_jrn,${"e_march$i"},'cred') == 0 ) { - $msg="Fiche inexistante !!! "; - echo_error(__FILE__.__LINE__.$msg); - echo ""; - return null; - } - // Check if the card has a valid account - if ( CheckPoste($p_cn,${"e_march$i"}) == null ) - return null; - } -// Verify the userperiode - -// p_periode 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 ('user_form_ven',__LINE__,"date start periode $l_date_start date fin periode $l_date_end date demande $e_date"); - if ( cmpDate($e_date,$l_date_start)<0 || - cmpDate($e_date,$l_date_end)>0 ) - { - $msg="Not in the active periode please change your preference"; - echo ""; - return null; - } - // Periode ferm� - $per=new Periode($p_cn); - $per->set_jrn($p_jrn); - $per->set_periode($p_periode); - - // Periode ferme - if ( $per->is_open()==0) - { - $msg="Cette periode est fermee pour ce journal"; - echo_error($msg); echo_error($msg); - echo ""; - return null; - } - return true; -} -/*! FormVenteView ($p_cn,$p_jrn,$p_periode,$p_array,$p_number,$p_doc='html',$p_comment='') - ************************************************** - * \brief Show the invoice before inserting it - * the database. - * - * - * \param p_cn database connection - * \param p_jrn journal - * \param p_periode - * \param array of value - * \param nb of item - * \param p_doc type form for a form - * \return string - * - */ - -function FormVenteView ($p_cn,$p_jrn,$p_periode,$p_array,$p_number,$p_doc='form',$p_comment='') -{ - $own=new own($p_cn); - - $r=""; - $data=""; - $head_ca=""; - // Keep all the data if hidden - // and store the array in variables - $hidden=new widget("hidden"); - foreach ($p_array as $name=>$content) { - // not the CA data - if ( strpos( $name,"ta_")===false && - strpos( $name,"nb_t")===false && - strpos( $name,"val")===false ) - $data.=$hidden->IOValue($name,$content); - ${"$name"}=$content; - } - // Compute href - // $href=basename($_SERVER['PHP_SELF']); - $href=basename($_SERVER['PHP_SELF']); - switch ($href) - { - // user_jrn.php - case 'user_jrn.php': - $href="user_jrn.php?action=record&p_jrn=$p_jrn"; - break; - case 'commercial.php': - $href="commercial.php?p_action=facture&sa=record&p_jrn=$p_jrn"; - break; - default: - echo_error('user_form_ven.php',__LINE__,'Erreur invalid request uri'); - exit (-1); - } - //---------------------------------------------------------------------- - - $r.='
    '; - $r.=dossier::hidden(); - // start table - $r.=''; - // Show the Date - $r.=""; - $r.=""; - $r.=""; - // Show the customer Name - $r.=""; - $r.=""; - $r.=""; - - // show date limit - $r.=""; - $r.=""; - $r.=""; - // Show desc - $r.=""; - $r.=""; - $r.=""; - - $sum_with_vat=0.0; - $sum_march=0.0; - // show all article, price vat and sum - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - $r.=""; - for ($i=0;$i<$p_number;$i++) { - if ( trim(${"e_march$i"}) == "" ) { - // no goods to sell - continue; - } - - // Get the name - $fiche_name=getFicheName($p_cn,${"e_march$i"}); - - // Quantity - $fiche_quant=${"e_quant$i"}; - - // No row if there is quantity - if ( $fiche_quant == 0.0 ) continue; - - - // If the price is not a number, retrieve the price from the database - if ( isNumber(${"e_march$i"."_sell"}) == 0 ) { - $fiche_price=getFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_PRIX_VENTE); - } else { - $fiche_price=${"e_march$i"."_sell"}; - } - - - // VAT - $vat=(isNumber(${"e_march$i"."_tva_id"})==0)?getFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_TVA):${"e_march$i"."_tva_id"}; - - // vat label - // vat rate - $a_vat=GetTvaRate($p_cn,$vat); - if ( $a_vat == null ) { - $vat_label=""; - $vat_rate=0.0; - } else { - $vat_label=$a_vat['tva_label']; - $vat_rate=$a_vat['tva_rate']; - } - $fiche_price=round($fiche_price,2); - // Total card without vat - $fiche_sum=$fiche_price*$fiche_quant; - $fiche_sum=round($fiche_sum,2); - - // Sum of invoice - $sum_march+=$fiche_sum; - // vat of the card - $fiche_amount_vat=round($fiche_price*$fiche_quant*$vat_rate,2); - // value card + vat - $fiche_with_vat=$fiche_price*$fiche_quant+$fiche_amount_vat; - // store in array - if ( $vat_label != "") { - if ( ! isset($a_sum_tva_cat[$vat_label])) { - $a_sum_tva_cat[$vat_label]=0.0; - } - $a_sum_tva_cat[$vat_label]+=$fiche_amount_vat; - } - // Sum of invoice vat - $sum_with_vat+=$fiche_with_vat; - // Show the data - $r.=''; - $r.=''; - $r.=''; - $r.=''; - $r.=""; - $r.=''; - $r.=''; - - $r.=''; - - // to show a select list for the analytic - // if analytic is op (optionnel) there is a blank line - $own = new Own($p_cn); - // encode the pa - if ( $own->MY_ANALYTIC!='nu') // use of AA - { - // show form - $op=new Anc_Operation($p_cn); - $null=($own->MY_ANALYTIC=='op')?1:0; - $r.=''; - } - - $r.=""; - } - - // end table - $r.='
    Date : $e_date
    Client : ".getFicheName($p_cn,$e_client)."
    Echeance : $e_ech
    Description : $e_comm
    Articlequantitéprix unit.taux tvaMontant HTVAMontant TVATotal
    '.$fiche_name.''.$fiche_quant.''.$fiche_price.' $vat_label '.round($fiche_sum,2).''.round($fiche_amount_vat,2).''.round($fiche_with_vat,2).''; - $p_mode=($p_doc=="form")?1:0; - $r.=$op->display_form_plan($_POST,$null,$p_mode,$i,round($fiche_sum,2)); - $r.='
    '; - $total_vat=0.0; - $r.='
    '; - $r.="HTVA =".round( $sum_march,2)."
    "; - if ( isset($a_sum_tva_cat) && empty ($a_sum_tva_cat) != true) { - foreach ($a_sum_tva_cat as $tva_cat=>$tva_amount) { - $r.="Tva ".$tva_cat." =".$tva_amount."
    "; - $total_vat+=$tva_amount; - } - } - $r.="TVA =".$total_vat.'
    '; - $r.="TTC = ".round($sum_with_vat,2); - - - $r.="
    "; - if ( $p_doc == 'form' ) { - // Propose to save - $chk=new widget('checkbox'); - $chk->selected=true; - $r.="Sauvez l'opération ?"; - $r.=$chk->IOValue('opd_save'); - - - // check for upload piece - $file=new widget("file"); - $file->table=1; - $r.="
    "; - $r.= ""; - $r.="".$file->IOValue("pj","","Pièce justificative").""; - $r.="
    "; - $r.="
    "; - - - // if we were in the management module, appl. propose to generate an invoice - // if ( $_SERVER['PHP_SELF'] == '/commercial.php') - echo_debug('user_form_ven',__LINE__," _SERVER['PHP_SELF'] ".$_SERVER['PHP_SELF']); - if ( basename($_SERVER['PHP_SELF']) == 'commercial.php') - { - // if a template exists propose to choose an invoice template - if ( CountSql($p_cn, - "select md_id,md_name from document_modele where md_type=4") > 0 ) - { - $r.='
    Génération de facture'; - $obj=new widget('TEXT'); - $r.='Numero de bon de commande : '.$obj->IOValue('bon_comm').'
    '; - $r.='Autre information : '.$obj->IOValue('other_info').'
    '; - - $r.='Générer une facture '; - // We propose to generate the invoice and some template - $doc_gen=new widget("select"); - $doc_gen->name="gen_doc"; - $doc_gen->value=make_array($p_cn, - "select md_id,md_name from document_modele where md_type=4"); - $r.=$doc_gen->IOValue().'
    '; - $r.="
    "; - } - } - - - $r.=$data; - if ( $sum_with_vat != 0 ) { - $r.=''; - if ( $own->MY_ANALYTIC != "nu" ) - $r.=''; - } - $r.=''; - - $r.='
    '; - } - return $r; - -} - -/*! RecordInvoice($p_cn,$p_array,$p_user,$p_jrn) - ************************************************** - * \brief Record an invoice in the table jrn & - * jrnx - * - * \param $p_cn Database connection - * \param $p_array array contains all the invoice data - * - e_date => e : 01.01.2003 - * - e_client => e : 3 - * - nb_item => e : 3 - * - e_march0 => e : 6 - * - e_quant0 => e : 0 - * - e_march0_sell=>e:1 - * - e_march1 => e : 6 - * - e_quant1 => e : 2 - * - e_march1_sell=>e:1 - * - e_march2 => e : 7 - * - e_quant2 => e : 3 - * - e_march2_sell=>e:1 - * * V : view_invoice => e : Voir cette facture - * * V : record_invoice => e : Sauver - * \param $p_periode periode - * \param $p_jrn current folder (journal) - * - * \return array ( internal_code,true on success) - */ -function RecordInvoice($p_cn,$p_array,$p_user,$p_jrn) -{ - echo_debug('RecordInvoice',0,"p_array = $p_array"); - - foreach ( $p_array as $v => $e) - { - ${"$v"}=$e; - } - - // Get the default period - $periode=$p_user->get_periode(); - $amount=0.0; - $own=new own($p_cn); - $group=NextSequence($p_cn,"s_oa_group"); - - // Computing total customer - //-- - for ($i=0;$i<$nb_item;$i++) { - // store quantity & goods in array - $a_good[$i]=${"e_march$i"}; - $a_quant[$i]=${"e_quant$i"}; - $a_price[$i]=0; - $a_vat[$i]=${"e_march$i"."_tva_id"}; - // check whether the price is set or no - if ( isNumber(${"e_march$i"."_sell"}) == 0 ) { - if ( $a_good[$i] != "" ) { - // If the price is not set we have to find it from the database - $a_price[$i]=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_PRIX_VENTE); - } - } else { - // The price is valid - $a_price[$i]=${"e_march$i"."_sell"}; - } - $a_price[$i]=round($a_price[$i],2); - $cost=$a_price[$i]*$a_quant[$i]; - $amount+=$cost; - - echo_debug('RecordInvoice',__LINE__,"cost = $cost amount = $amount "); - }// for - echo_debug(__FILE__,__LINE__,"Dossier is ".dossier::id()); - - $comm=FormatString($e_comm); - // Compute VAT - //-- - $a_vat_new=ComputeTotalVat($p_cn,$a_good,$a_quant,$a_price,$a_vat); - $sum_vat=0.0; - echo_debug(__FILE__,__LINE__,"Dossier is ".dossier::id()); - - if ( $a_vat_new != null ){ - foreach ( $a_vat_new as $element => $t) { - echo_debug('user_form_ven.php',__LINE__," a_vat element $element t $t"); - $sum_vat+=$t; - echo_debug('user_form_ven.php',__LINE__,"sum_vat = $sum_vat"); - } - } - // First we add in jrnx - - // Compute the j_grpt - $seq=NextSequence($p_cn,'s_grpt'); - $oJrn=new Acc_Ledger($p_cn,$p_jrn); - $internal=$oJrn->compute_internal_code($seq); - - echo_debug(__FILE__,__LINE__,"Dossier is ".dossier::id()); - // Debit = client - $poste=GetFicheAttribut($p_cn,$e_client,ATTR_DEF_ACCOUNT); - echo_debug(__FILE__,__LINE__,"Dossier is ".dossier::id()); - try - { - StartSql($p_cn); - $r=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($amount,2)+round($sum_vat,2),$seq,$periode,$e_client); - - - // Credit = goods - for ( $i = 0; $i < $nb_item;$i++) { - if ( $a_good[$i] == "" ) continue; - $poste=GetFicheAttribut($p_cn,$a_good[$i],ATTR_DEF_ACCOUNT); - - // don't record operation of 0 - if ( $a_price[$i]*$a_quant[$i] == 0 ) continue; - - // record into jrnx - $j_id=InsertJrnx($p_cn,'c',$p_user->id,$p_jrn,$poste,$e_date,round($a_price[$i]*$a_quant[$i],2),$seq,$periode,$a_good[$i]); - - /* \brief if the quantity is < 0 then the stock increase (return of - * material) - */ - $nNeg=($a_quant[$i]<0)?-1:1; - - // always save quantity but in withStock we can find - // what card need a stock management - - InsertStockGoods($p_cn,$j_id,$a_good[$i],$nNeg*$a_quant[$i],'c') ; - if ( $own->MY_ANALYTIC != "nu" ) - { - // for each item, insert into operation_analytique */ - $op=new Anc_Operation($p_cn); - $op->oa_group=$group; - $op->j_id=$j_id; - $op->oa_date=$e_date; - $op->oa_debit=($op->oa_amount < 0 )?'t':'f'; - echo_debug(__FILE__.':'.__LINE__,"Description is $e_comm"); - $op->oa_description=FormatString($e_comm); - $op->save_form_plan($_POST,$i); - } - $computed_vat=ComputeVat($p_cn,$a_good[$i],$a_quant[$i],$a_price[$i],$a_vat[$i]); - $qs_vat=($a_vat[$i]==-1)?0:$computed_vat; - $r=ExecSql($p_cn,"select insert_quant_sold ". - "('".$internal."',".$j_id.",'".$a_good[$i] - ."',".$a_quant[$i].",".$a_price[$i]*$a_quant[$i]. - ",".$qs_vat. - ",".$a_vat[$i].",'".$e_client."')"); - - - } // end loop - - // Insert Vat - - if ( $a_vat_new != null ) // no vat - - { - foreach ($a_vat_new as $tva_id => $tva_amount ) { - $poste=GetTvaPoste($p_cn,$tva_id,'c'); - // if ($tva_amount == 0 ) continue; - $r=InsertJrnx($p_cn,'c',$p_user->id,$p_jrn,$poste,$e_date,round($tva_amount,2),$seq,$periode); - } - } - echo_debug('user_form_ven.php',__LINE__,"echeance = $e_ech"); - $r=InsertJrn($p_cn,$e_date,$e_ech,$p_jrn,"Invoice",$seq,$periode); - - // Set Internal code and Comment - $Res=ExecSql($p_cn,"update jrn set jr_internal='".$internal."' where ". - " jr_grpt_id = ".$seq); - - $comment=(FormatString($e_comm) == null )?$internal." client : ".GetFicheName($p_cn,$e_client):FormatString($e_comm); - - // Update and set the invoice's comment - $Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq); - - if ( isset ($_FILES)) { - if ( sizeof($_FILES) != 0 ) - save_upload_document($p_cn,$seq); - } - - // save the quantity, then we can make an invoice - for ( $i=0;$i < $nb_item;$i++) - { - // don't record operation of 0 - if ( $a_price[$i]*$a_quant[$i] == 0 ) continue; - - // insert into the table quant_sold - // Note that negative value are also saved but not the vat ! - if ( $a_vat[$i] == -1) { - $computed_vat=0; - $vat_code="null"; - } else { - $computed_vat=ComputeVat($p_cn,$a_good[$i],$a_quant[$i],$a_price[$i],$a_vat[$i]); - $vat_code=$a_vat[$i]; - } - } - // Save the operation - if ( isset($_POST['opd_save']) && $_POST['opd_save']=='on' ){ - echo_debug(__FILE__.':'.__LINE__.'- ','save opd'); - $opd=new Pre_op_ven($p_cn); - $opd->get_post(); - $opd->save(); - echo_debug(__FILE__.':'.__LINE__.'- ',"opd = ",$opd); - } - }//try - catch (Exception $e) - { - echo ''. - 'Erreur dans l\'enregistrement '. - __FILE__.':'.__LINE__.' '. - $e->getMessage(); - Rollback($p_cn); - exit(); - } - Commit($p_cn); - return array($internal,$comment); -} - -?>