IMPROVE Show ledger in Quick_writing

This commit is contained in:
Dany De Bontridder 2008-10-09 21:29:09 +00:00
parent d06e479561
commit fb13db1ed7
2 changed files with 131 additions and 1 deletions

View file

@ -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 "<hr>$bar";
echo dossier::hidden();
$hid=new widget("hidden");
echo $list;
echo "$bar <hr>";
echo '</div>';
}
/*!
* \brief get_detail gives the detail of row
* this array must contains at least the field

View file

@ -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 '<div class="lmenu">';
$id=(isset ($_REQUEST['p_jrn']))?$_REQUEST['p_jrn']:-1;
echo ShowItem(
array(
array('?p_action='.$_REQUEST['p_action'].'&'.dossier::get().'&p_jrn='.$id.'&show_form','Encoder une Operation',
' Encoder une operation dans ce journal',0),
array('?p_action='.$_REQUEST['p_action'].'&'.dossier::get().'&p_jrn='.$id.'&sa=l','Voir Operation',
' Voir les operations de ce journal',1),
array('?p_action='.$_REQUEST['p_action'].'&'.dossier::get(),
'Autre journal',
'Choisir un autre journal')
),
'H',"mtitle","mtitle",$def,' width="100%"'
);
echo '</div>';
}
/*!\brief show a form for quick_writing */
function show_direct_form($cn,$ledger,$p_array) {
echo '<div class="content">';
$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 '<div class="content">';
echo '<h2 class="info"> Journal : '.$ledger->get_name().'</h2>';
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 '<div class="content">';
$Ledger=new Acc_Ledger($cn,$id);
$href=basename($_SERVER['PHP_SELF']);
echo '<form method="GET" action="'.$href.'">';
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 '</form>';
echo '</div>';
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 '<script>alert (\''.$e->getMessage()."'); </script>";
show_qw_menu();
show_direct_form($cn,$ledger,$_POST);
exit();
}
@ -183,6 +238,7 @@ if ( isset($_POST['save_it' ])) {
} catch (AcException $e) {
echo '<script>alert (\''.$e->getMessage()."'); </script>";
show_qw_menu();
show_direct_form($cn,$ledger,$_POST);
}
exit();