From fb13db1ed737dfb74b39b15270cb8bbf41d896ab Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 9 Oct 2008 21:29:09 +0000 Subject: [PATCH] IMPROVE Show ledger in Quick_writing --- include/class_acc_ledger.php | 74 +++++++++++++++++++++++++++++++++++ include/quick_writing.inc.php | 58 ++++++++++++++++++++++++++- 2 files changed, 131 insertions(+), 1 deletion(-) diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php index de5a8d0a5..31efb2b17 100644 --- a/include/class_acc_ledger.php +++ b/include/class_acc_ledger.php @@ -421,6 +421,80 @@ class Acc_Ledger { return $array; }// end function get_rowSimple + /*!\brief Show all the operation, propose a form to select the + *ledger and the periode + *\return none + *\note echo directly, there is no return with the html code + */ + public function show_ledger() { + + $w=new widget("select"); + $User=new User($this->db); + // filter on the current year + $filter_year=" where p_exercice='".$User->get_exercice()."'"; + + $periode_start=make_array($this->db,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end",1); + $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']:""; + + $all=$this->get_all_fiche_def(); + echo JS_SEARCH_CARD; + echo JS_PROTOTYPE; + echo JS_AJAX_FICHE; + $w=new widget('js_search_only'); + $w->name='qcode'; + $w->value=$qcode; + $w->label=''; + $w->extra='filter'; + $w->extra2='QuickCode'; + $w->table=0; + $sp= new widget("span"); + echo $sp->IOValue("qcode_label","",$qcode); + echo $w->IOValue(); + + echo widget::submit('gl_submit','Recherche'); + // Show list of sell + // Date - date of payment - Customer - amount + if ( $current == -1) { + $cond=" jr_tech_per in (select p_id from parm_periode where p_exercice='".$User->get_exercice()."')"; + } else { + $cond=" jr_tech_per=".$current; + } + + $sql=SQL_LIST_ALL_INVOICE."where ".$cond." and jr_def_id=".$this->id ; + $step=$_SESSION['g_pagesize']; + $page=(isset($_GET['offset']))?$_GET['page']:1; + $offset=(isset($_GET['offset']))?$_GET['offset']:0; + $filter_ledger=" jr_def_id=".$this->id; + $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')) "; + $sql="where $cond $l and $filter_ledger "; + } + + list($max_line,$list)=ListJrn($this->db,$this->id,$sql,null,$offset,0); + $bar=jrn_navigation_bar($offset,$max_line,$step,$page); + + echo "
$bar"; + echo dossier::hidden(); + $hid=new widget("hidden"); + + echo $list; + + echo "$bar
"; + + echo ''; + + +} /*! * \brief get_detail gives the detail of row * this array must contains at least the field diff --git a/include/quick_writing.inc.php b/include/quick_writing.inc.php index 01e043715..a8fc4db7d 100644 --- a/include/quick_writing.inc.php +++ b/include/quick_writing.inc.php @@ -35,8 +35,30 @@ require_once('check_priv.php'); $cn=DbConnect(dossier::id()); $id=(isset ($_REQUEST['p_jrn']))?$_REQUEST['p_jrn']:-1; +/*!\brief show a form for quick_writing */ +function show_qw_menu($def=0) { + echo ''; +} + +/*!\brief show a form for quick_writing */ function show_direct_form($cn,$ledger,$p_array) { + echo '
'; + $id=(isset ($_REQUEST['p_jrn']))?$_REQUEST['p_jrn']:-1; echo JS_COMPUTE_DIRECT; echo Acc_Reconciliation::$javascript; @@ -105,8 +127,38 @@ if ( $User->AccessJrn($cn,$id) == false ) { } echo '
'; echo '

Journal : '.$ledger->get_name().'

'; -echo widget::button_href('Autre journal','?p_action='.$_REQUEST['p_action'].'&'.dossier::get()); +$sa=( isset ($_REQUEST['sa']))?$_REQUEST['sa']:''; +//====================================================================== +// See the ledger listing +if ($sa == 'l' && $id != -1) { + // Check privilege + + if ( CheckJrn(dossier::id(),$_SESSION['g_user'],$id) ==0 ) { + NoAccess(); + exit -1; + } + show_qw_menu(1); + echo '
'; + $Ledger=new Acc_Ledger($cn,$id); + $href=basename($_SERVER['PHP_SELF']); + + echo '
'; + echo widget::hidden("sa","l"); + echo widget::hidden("p_jrn",$id); + echo widget::hidden("p_action","quick_writing"); + echo dossier::hidden(); + $Ledger->show_ledger(); + echo '
'; + + echo '
'; + exit(); + + exit(0); +} + +//====================================================================== // User can write ? +// Write into the ledger if ( CheckJrn(dossier::id(),$_SESSION['g_user'],$id) != 2 ) { echo " @@ -124,6 +176,7 @@ if ( isset($_GET['show_form']) || isset($_POST['correct_it']) ) { } list($date,$devnull)=get_periode($cn,$default_periode); $array['date']=$date; + show_qw_menu(); show_direct_form($cn,$ledger,$array); exit(); } @@ -139,6 +192,7 @@ if ( isset ($_GET['use_opd'])) { $p_post=$op->compute_array(); } + show_qw_menu(); show_direct_form($cn,$ledger,$p_post); exit(); @@ -149,6 +203,7 @@ if ( isset($_POST['summary'])) { $ledger->verify($_POST ); } catch (AcException $e) { echo '"; + show_qw_menu(); show_direct_form($cn,$ledger,$_POST); exit(); } @@ -183,6 +238,7 @@ if ( isset($_POST['save_it' ])) { } catch (AcException $e) { echo '"; + show_qw_menu(); show_direct_form($cn,$ledger,$_POST); } exit();