diff --git a/html/annulation.php b/html/annulation.php index f18588b65..43b7b79af 100644 --- a/html/annulation.php +++ b/html/annulation.php @@ -32,6 +32,8 @@ include_once("jrn.php"); require_once("class_widget.php"); require_once("class_acc_ledger.php"); require_once("class_acc_operation.php"); +require_once ('class_periode.php'); + /* Admin. Dossier */ include_once ("class_user.php"); require_once('class_dossier.php'); @@ -43,7 +45,7 @@ $User->Check(); html_page_start($User->theme,"onLoad='window.focus();'"); echo JS_VIEW_JRN_MODIFY; -if ( isset( $_GET['p_jrn'] )) { +if ( isset( $_REQUEST['p_jrn'] )) { $p_jrn=$_GET['p_jrn']; } @@ -75,8 +77,7 @@ if ( isset ($_POST['annul']) ) {

-

-Voulez-vous vraiment annuler cette information soit par une remise à zéro des montants +

Voulez-vous vraiment annuler cette information soit par une remise à zéro des montants soit par son écriture inverse ?

@@ -119,36 +120,46 @@ if ($p_id != -1 ) { // A // userPref contient la periode par default $userPref=$User->get_periode($cn); list ($l_date_start,$l_date_end)=get_periode($cn,$userPref); - - // Periode fermée - if ( PeriodeClosed ($cn,$userPref)=='t' ) + $per=new Periode($cn); + $per->set_jrn($p_jrn); + $per->set_periode($userPref); + + // Periode ferme + if ( $per->is_open()==0) { - $msg="Votre periode par defaut est fermee, changez vos préférences"; - echo_error($msg); - echo ""; - // set an incorrect pid to get out from here - $p_id=-1; + $msg="Votre periode par defaut est fermee, changez vos preferences"; + echo_error($msg); + echo ""; + $p_id=-1; } - + if ( $p_id != -1 ) { //B // Test whether date of the operation is in a closed periode // get the period_id $period_id=getPeriodeFromDate($cn,$e_op_date); + // thanks jrn_op (jrn.jr_id) we find out the concerned ledger + $sql="select jr_def_id from jrn where jr_id=".$_REQUEST['jrn_op']; + $r=ExecSql($cn,$sql); + $nJrn=pg_fetch_result($r,0,0); + $per=new Periode($cn); + $per->set_jrn(nJrn); + $per->set_periode($period_id); + // Check the period_id - if ( PeriodeClosed($cn,$period_id) == 't' ) + if ( $per->is_open() == 0 ) { - try - { - - // if the operation is in a closed or centralized period - // the operation is voided thanks the opposite operation - StartSql($cn); - $grp_new=NextSequence($cn,'s_grpt'); - $seq=NextSequence($cn,"s_jrn"); -$oJrn=new Acc_Ledger($cn,$l_array['jr_def_id']); - $p_internal=$oJrn->compute_internal_code($seq); - - $sql= "insert into jrn ( + try + { + + // if the operation is in a closed or centralized period + // the operation is voided thanks the opposite operation + StartSql($cn); + $grp_new=NextSequence($cn,'s_grpt'); + $seq=NextSequence($cn,"s_jrn"); + $oJrn=new Acc_Ledger($cn,$l_array['jr_def_id']); + $p_internal=$oJrn->compute_internal_code($seq); + + $sql= "insert into jrn ( jr_id,jr_def_id,jr_montant,jr_comment, jr_date,jr_grpt_id,jr_internal ,jr_tech_per, jr_valid @@ -230,8 +241,8 @@ $oJrn=new Acc_Ledger($cn,$l_array['jr_def_id']); catch (Exception $e) { Rollback($cn); - $msg="Désolé mais il n a pas été possible d'annuler ". - "cette opération"; + $msg="Désolé mais il n a pas été possible d'annuler ". + "cette opération"; echo ""; @@ -249,7 +260,7 @@ $oJrn=new Acc_Ledger($cn,$l_array['jr_def_id']); } Commit($cn); // close the window - echo '

Opération Annulée

'; + echo '

Opération Annulée

'; ?> "; echo ''. @@ -350,7 +361,7 @@ self.opener.RefreshMe(); } Commit($cn); - echo '

Opération Annulée

'; + echo '

Opération Annulée

'; ?>