diff --git a/include/bank.inc.php b/include/bank.inc.php index 1b960edfe..9f81a2af7 100644 --- a/include/bank.inc.php +++ b/include/bank.inc.php @@ -123,11 +123,6 @@ if ( $sub_action == "solde" ) // 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 '
| Date : | $date |
| Description | $desc |
| Quick Code ou "; - $ret.="Poste | "; - $ret.="Montant | "; - $ret.="Débit | "; - $ret.="||
|---|---|---|---|---|
| ".${'qc_'.$i}.' - '. - $oqc->strAttribut(ATTR_DEF_NAME).$hidden->IOValue('qc_'.$i,${'qc_'.$i}). - ' | '; - } - - if ( trim(${'qc_'.$i})=="" && trim(${'poste'.$i}) != "") { - $oposte=new Acc_Account($this->db,${'poste'.$i}); - $strPoste=$oposte->id; - $ret.="".${"poste".$i}." - ". - $oposte->get_name().$hidden->IOValue('poste'.$i,${'poste'.$i}). - ' | '; - } - - if ( trim(${'qc_'.$i})=="" && trim(${'poste'.$i}) == "") - continue; - - $ret.="".${"amount".$i}.$hidden->IOValue('amount'.$i,${'amount'.$i})." | "; - $ret.=""; - $ret.=(isset(${"ck$i"}))?"D":"C"; - $ret.=(isset(${"ck$i"}))?$hidden->IOValue('ck'.$i,${'ck'.$i}):""; - $ret.=" | "; - // CA - - if ( $own->MY_ANALYTIC!='nu') // use of AA - { - if ( ereg("^[6,7]+",$strPoste)) { - // show form - $op=new Anc_Operation($this->db); - $null=($own->MY_ANALYTIC=='op')?1:0; - $ret.=''; - $ret.=$op->display_form_plan(null,$null,1,$count,round(${'amount'.$i},2)); - $ret.=' | '; - $count++; - } - - } - - - - $ret.="
| '; - $wDate=new widget('js_date','Date','date'); - $wDate->table=1; - $wDate->readonly=$p_readonly; - $wDate->value=(isset($date))?$date:''; - - $ret.=$wDate->IOValue(); - $ret.= ' |
| '; - $wDescription=new widget('text',"Description",'desc'); - $wDescription->readonly=$p_readonly; - $wDescription->table=1; - $wDescription->value=(isset($desc))?$desc:''; - $ret.=$wDescription->IOValue(); - $ret.= ' |
| Quickcode | '. - 'Poste | '. - 'Montant | '. - 'Débit | '. - '||||
|---|---|---|---|---|---|---|---|
| '.$quick_code->IOValue().' | '; - $ret.=''.$qc_span->IOValue().' | '; - $ret.=''.$poste->IOValue().' | '; - $ret.=''.$poste_span->IOValue().' | '; - $ret.=''.$amount->IOValue().' | '; - $ret.=''.$deb->IOValue().' | '; - $ret.='||
| Date : | $date |
| Description | $desc |
| Quick Code ou "; + $ret.="Poste | "; + $ret.="Montant | "; + $ret.="Débit | "; + $ret.="||
|---|---|---|---|---|
| ".${'qc_'.$i}.' - '. + $oqc->strAttribut(ATTR_DEF_NAME).$hidden->IOValue('qc_'.$i,${'qc_'.$i}). + ' | '; } - for ($i=0;$i<$this->nb;$i++) - { - $err=0; + if ( trim(${'qc_'.$i})=="" && trim(${'poste'.$i}) != "") { + $oposte=new Acc_Account($this->db,${'poste'.$i}); + $strPoste=$oposte->id; + $ret.="".${"poste".$i}." - ". + $oposte->get_name().$hidden->IOValue('poste'.$i,${'poste'.$i}). + ' | '; + } - // Check the balance - if ( ! isset (${'amount'.$i})) - continue; + if ( trim(${'qc_'.$i})=="" && trim(${'poste'.$i}) == "") + continue; - if ( isNumber(${'amount'.$i} ) == 0 ) - throw new AcException('Montant invalide',3); + $ret.="".${"amount".$i}.$hidden->IOValue('amount'.$i,${'amount'.$i})." | "; + $ret.=""; + $ret.=(isset(${"ck$i"}))?"D":"C"; + $ret.=(isset(${"ck$i"}))?$hidden->IOValue('ck'.$i,${'ck'.$i}):""; + $ret.=" | "; + // CA - $amount=round(${'amount'.$i},2); - $tot_deb+=(isset(${'ck'.$i}))?$amount:0; - $tot_cred+=(! isset(${'ck'.$i}))?$amount:0; - - // Check if the card is permitted - if ( isset (${'qc_'.$i}) && trim(${'qc_'.$i}) !="") { - $f=new fiche($this->db); - $f->quick_code=${'qc_'.$i}; - - if ( $f->belong_ledger($p_jrn) < 0 ) - throw new AcException("La fiche quick_code = ". - $f->quick_code." n\'est pas dans ce journal",4); - } - - // Check if the account is permitted - if ( isset (${'poste'.$i})) { - $p=new Acc_Account($this->db,${'poste'.$i}); - if ( $p->belong_ledger ($p_jrn) < 0 ) - throw new AcException("Le poste ".$p->id." n\'est pas dans ce journal",5); - } - - - } - if ( $tot_deb != $tot_cred ) - throw new AcException("Balance incorrecte debit = $tot_deb credit=$tot_cred ",1); - - } -/*! - * \brief - * - * \param $p_grpt id in jr_grpt_ - * - * \return string internal_code - * - - * - */ -function compute_internal_code($p_grpt) -{ -if ( $this->id==0) return; - $num = NextSequence($this->db,'s_internal'); - $num=strtoupper(hexdec($num)); - $atype=$this->get_propertie(); - $type=$atype['jrn_def_code']; - $internal_code=sprintf("%d%s-%s",dossier::id(),$type,$num); - echo_debug (__FILE__,__LINE__,"internal_code = $internal_code"); - return $internal_code; -} - - /*! - * \brief save the operation into the jrnx,jrn, , - * CA and pre_def - * \param $p_array - * - * \return array with [0] = false if failed otherwise true, [1] error - * code - */ - function save ($p_array) { - extract ($p_array); - try { - $this->verify($p_array); - - StartSql($this->db) ; - - $seq=NextSequence($this->db,'s_grpt'); - $internal=$this->compute_internal_code($seq); - - $group=NextSequence($this->db,"s_oa_group"); - $own=new own($this->db); - $tot_amount=0; - - $count=0; - for ($i=0;$i<$this->nb;$i++) - { - if ( ! isset (${'qc_'.$i}) && ! isset(${'poste'.$i})) - continue; - $acc_op=new Acc_Operation($this->db); - $quick_code=""; - // First we save the jrnx - if ( isset(${'qc_'.$i})) { - $qc=new fiche($this->db); - $qc->get_by_qcode(${'qc_'.$i},false); - $poste=$qc->strAttribut(ATTR_DEF_ACCOUNT); - $quick_code=${'qc_'.$i}; - } - else { - $poste=${'poste'.$i}; - } - $acc_op->date=$date; - $acc_op->desc=$desc; - $acc_op->amount=round(${'amount'.$i},2); - $acc_op->grpt=$seq; - $acc_op->poste=$poste; - $acc_op->jrn=$this->id; - $acc_op->type=(isset (${'ck'.$i}))?'d':'c'; - $acc_op->qcode=$quick_code; - $j_id=$acc_op->insert_jrnx(); - $tot_amount+=round($acc_op->amount,2); + if ( $own->MY_ANALYTIC!='nu') // use of AA + { + if ( ereg("^[6,7]+",$strPoste)) { + // show form + $op=new Anc_Operation($this->db); + $null=($own->MY_ANALYTIC=='op')?1:0; + $ret.=''; + $ret.=$op->display_form_plan(null,$null,1,$count,round(${'amount'.$i},2)); + $ret.=' | '; + $count++; + } - if ( $own->MY_ANALYTIC != "nu" ) - { - if ( ereg("^[6,7]+",$poste)) { - - // for each item, insert into operation_analytique */ - $op=new Anc_Operation($this->db); - $op->oa_group=$group; - $op->j_id=$j_id; - $op->oa_date=$date; - $op->oa_debit=($acc_op->type=='d' )?'t':'f'; - $op->oa_description=$desc; - $op->save_form_plan($p_array,$count); - $count++; - } - } - } - $acc_end=new Acc_Operation($this->db); - $acc_end->date=$date; - $acc_end->desc=$desc; - $acc_end->grpt=$seq; - $acc_end->jrn=$this->id; - $jr_id= $acc_end->insert_jrn(); - if ($jr_id == false ) - throw new Exception('Balance incorrecte'); + } - ExecSql($this->db,"update jrn set jr_internal='".$internal."' where ". - " jr_grpt_id = ".$seq); - // Save now the predef op - //------------------------ - if ( isset($save_opd)) { - $opd=new Pre_Op_Advanced($this->db); - $opd->name=(trim($desc)=='')?$internal:$desc; - $opd->get_post(); - $opd->save(); - } - if ( isset($this->with_concerned) && $this->with_concerned==true) { - $orap=new acc_reconciliation($this->db); - $orap->jr_id=$jr_id; - $orap->insert($jrn_concerned); - } + $ret.="
| '; + $wDate=new widget('js_date','Date','date'); + $wDate->table=1; + $wDate->readonly=$p_readonly; + $wDate->value=(isset($date))?$date:''; - /*! - * \brief get all the data from request and build the object - * \param - * \param - * \param - * - * - * \return - */ - function get_request() - { - $this->id=$_REQUEST['p_jrn']; + $ret.=$wDate->IOValue(); + $ret.= ' |
| '; + $wDescription=new widget('text',"Description",'desc'); + $wDescription->readonly=$p_readonly; + $wDescription->table=1; + $wDescription->value=(isset($desc))?$desc:''; + $ret.=$wDescription->IOValue(); + $ret.= ' |
| Quickcode | '. + 'Poste | '. + 'Montant | '. + 'Débit | '. + '||||
|---|---|---|---|---|---|---|---|
| '.$quick_code->IOValue().' | '; + $ret.=''.$qc_span->IOValue().' | '; + $ret.=''.$poste->IOValue().' | '; + $ret.=''.$poste_span->IOValue().' | '; + $ret.=''.$amount->IOValue().' | '; + $ret.=''.$deb->IOValue().' | '; + $ret.='||
| Date début | '; + echo 'Date fin | '; + echo 'Exercice | '; + echo ""; + + for ($i=0;$i<$Max;$i++) { + $l_line=pg_fetch_array($Res,$i); + echo '|||||||
|---|---|---|---|---|---|---|---|---|---|
| '.$l_line['date_start'].' | '; + echo ''.$l_line['date_end'].' | '; + echo ''.$l_line['p_exercice'].' | '; + + if ( $l_line['p_closed'] == 't' ) { + $closed=($l_line['p_central']=='t')?'Centralisée | ':'Fermée | '; + $change=''; + $remove=' | '; + } else { + $closed=' | '; + $closed.=' Cloturer'; + $change=' | '; + $change.=' Changer"; + $remove=' | '; + $remove.=' Efface"; + + } + echo "$closed"; + echo $change; + + echo $remove; + + echo ' |
| Date début | '; + echo 'Date fin | '; + echo 'Exercice | '; + echo ""; + + for ($i=0;$i<$Max;$i++) { + $l_line=pg_fetch_array($Res,$i); + echo '|||
|---|---|---|---|---|---|
| '.$l_line['date_start'].' | '; + echo ''.$l_line['date_end'].' | '; + echo ''.$l_line['p_exercice'].' | '; + + if ( $l_line['status'] != 'OP' ) { + $closed=($l_line['status']=='CE')?'Centralisée | ':'Fermée | '; + } else { + $closed=''; + $closed.=' Cloturer'; + $closed.=' | '; + } + echo "$closed"; + + echo '