From e585bb0d3a32a823568c12e2e7b7eb3117218c69 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Wed, 2 Nov 2011 23:03:49 +0000 Subject: [PATCH] ODS : add a verify before screen to confirm --- include/class_acc_ledger.php | 3 +- include/compta_ods.inc.php | 159 ++--------------------------------- 2 files changed, 11 insertions(+), 151 deletions(-) diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php index 5be5c8c9d..0a80f19df 100644 --- a/include/class_acc_ledger.php +++ b/include/class_acc_ledger.php @@ -1209,7 +1209,8 @@ class Acc_Ledger */ function confirm($p_array,$p_readonly=false) { - $this->id=$p_array['p_jrn']; + if (! $p_readonly ) $this->verify($p_array); + $this->id=$p_array['p_jrn']; if ( empty($p_array)) return 'Aucun résultat'; $anc=null; extract($p_array); diff --git a/include/compta_ods.inc.php b/include/compta_ods.inc.php index 9323d3246..5762ec9db 100644 --- a/include/compta_ods.inc.php +++ b/include/compta_ods.inc.php @@ -64,7 +64,15 @@ if (!isset($_POST['summary']) && !isset($_POST['save'])) } elseif (isset($_POST['summary'])) { - require_once 'operation_ods_confirm.inc.php'; + try { + $ledger->verify($_POST); + require_once 'operation_ods_confirm.inc.php'; + } catch (Exception $e) + { + echo alert($e->getMessage()); + require('operation_ods_new.inc.php'); + + } exit(); } elseif (isset($_POST['save'])) @@ -95,152 +103,3 @@ elseif (isset($_POST['save'])) } exit(); - - -if ( $g_user->check_jrn($id) == 'X' ) -{ - alert(_("L'acces a ce journal est interdit, \n contactez votre responsable")); - exit(); -} - -//====================================================================== -// See the ledger listing -if ($sa == 'l' && $id != -1) -{ -// Check privilege - - if ( $g_user->check_jrn($id) == 'X') - { - NoAccess(); - exit -1; - } - show_qw_menu(1); - echo '
'; - $Ledger=new Acc_Ledger($cn,$id); - - $type=$Ledger->get_type(); - $href=basename($_SERVER['PHP_SELF']); - - echo '
'; - echo HtmlInput::hidden("sa","l"); - echo HtmlInput::hidden("p_jrn",$id); - echo HtmlInput::hidden("ac",$_REQUEST['sa']); - echo dossier::hidden(); - echo $Ledger->search_form($type,0); - echo HtmlInput::submit("qwlist",_("Recherche")); - echo '
'; - - $array=$_GET; - list($sql,$where)=$Ledger->build_search_sql($array); - - $max_line=$cn->count_sql($sql); - - $step=$_SESSION['g_pagesize']; - $page=(isset($_GET['offset']))?$_GET['page']:1; - $offset=(isset($_GET['offset']))?$_GET['offset']:0; - $bar=jrn_navigation_bar($offset,$max_line,$step,$page); - - - echo $bar; - list($count,$html)= $Ledger->list_operation($sql,$offset,0); - echo $html; - echo $bar; - /* - * Export to csv - */ - $r=HtmlInput::get_to_hidden(array('l','date_start','date_end','desc','amount_min','amount_max','qcode','accounting','unpaid','gDossier','ledger_type','ac')); - if (isset($_GET['r_jrn'])) { - foreach ($_GET['r_jrn'] as $k=>$v) - $r.=HtmlInput::hidden('r_jrn['.$k.']',$v); - } - echo '
'; - echo $r; - echo HtmlInput::hidden('act','CSV/histo'); - echo HtmlInput::submit('viewsearch','Export vers CSV'); - - echo '
'; - - echo '
'; - exit(); -} - -//====================================================================== -// User can write ? -// Write into the ledger - -if ( $g_user->check_jrn($id) == 'X' ) -{ - alert(_("Vous ne pouvez pas accèder à ce journal, contactez votre responsable")); - exit -1; -} - -if ( $g_user->check_jrn($id)=='W' ) -{ - if ( ($sa=='n' || isset($_POST['correct_it'])) && ! isset($_POST['summary'])) - { - $array=$_POST; - $default_periode=$g_user->get_periode(); - /* check if the ledger is closed */ - - show_qw_menu(); - show_direct_form($cn,$ledger,$array); - exit(); - } - -// reload with a predefined operation -// - if ( isset ($_GET['use_opd'])) - { - $op=new Pre_op_advanced($cn); - $p_post=null; - if ( isset($_REQUEST['pre_def']) && $_REQUEST['pre_def'] != '') - { - $op->set_od_id($_REQUEST['pre_def']); - //$op->p_jrn=$id; - - $p_post=$op->compute_array(); - } - show_qw_menu(); - show_direct_form($cn,$ledger,$p_post); - - exit(); - - } - - if ( isset($_POST['save_it' ])) - { - $array=$_POST; - - try - { - $ledger->save($array); - $jr_id=$cn->get_value('select jr_id from jrn where jr_internal=$1',array($ledger->internal)); - - echo '

Opération enregistrée Piece '.h($ledger->pj).'

'; - if ( strcmp($ledger->pj,$_POST['e_pj']) != 0 ) - { - echo '

'._('Attention numéro pièce existante, elle a du être adaptée').'

'; - } - printf ('%s
', - $jr_id,dossier::id(),$ledger->internal); - - echo HtmlInput::button_anchor(_('Autre opération dans ce journal'), - "?".dossier::get(). - '&show_form'. - '&p_action=quick_writing&p_jrn='. - $_REQUEST['p_jrn']); - - } - catch (Exception $e) - { - alert ($e->getMessage()); - show_qw_menu(); - show_direct_form($cn,$ledger,$_POST); - } - exit(); - } -} // if check_jrn=='W' -else -{ - show_qw_menu(); -}