diff --git a/html/annulation.php b/html/annulation.php index 2844a95e0..4cd52c22c 100644 --- a/html/annulation.php +++ b/html/annulation.php @@ -95,17 +95,19 @@ if ($p_id != -1 ) { // A // Test whether date of the operation is in a closed periode // get the period_id $period_id=getPeriodeFromDate($cn,$e_op_date); - // Check the period_id - if ( PeriodeClosed($cn,$period_id) == true ){ + // Check the period_id + if ( PeriodeClosed($cn,$period_id) == 't' ){ // if the operation is in a closed or centralized period // the operation is voided thanks the opposite operation StartSql($cn); + $p_internal=SetInternalCode($cn,$p_id,$l_array['jr_id']); + $grp_new=NextSequence($cn,'s_jrn_'.$l_array['jr_id']); $sql= "insert into jrn ( jr_def_id,jr_montant,jr_comment, jr_date,jr_grpt_id,jr_internal ,jr_tech_per, jr_valid ) select jr_def_id,jr_montant,'Annulation '||jr_comment, - to_date('$e_op_date','DD.MM.YYYY'),$seq ,'ANNULE', + now(),$grp_new,'$p_internal', $period, true from jrn @@ -113,6 +115,19 @@ if ($p_id != -1 ) { // A $Res=ExecSql($cn,$sql); // Check return code if ( $Res == false ) { Rollback($cn);exit(-1);} + // Make also the change into jrnx + $sql= "insert into jrnx ( + j_date,j_montant,j_poste,j_grpt, + j_jrn_def,j_debit,j_text,j_internal,j_tech_user + ) select now(),j_montant,j_poste,$grp_new, + j_jrn_def,j_debit,j_text,'$p_internal','".$User->id."' + from + jrnx + where j_grpt=".$_POST['p_id']; + $Res=ExecSql($cn,$sql); + // Check return code + if ( $Res == false ) { Rollback($cn);exit(-1);} + // the table stock must updated // also in the stock table $sql="delete from stock_goods where sg_id = any ( select sg_id diff --git a/include/ac_common.php b/include/ac_common.php index 5c4dff8dd..21cbe2181 100644 --- a/include/ac_common.php +++ b/include/ac_common.php @@ -355,21 +355,21 @@ function getPeriodeName($p_cn,$p_id,$pos='p_start') { $a=pg_fetch_array($ret,0); return $a['t']; } -/* function getPeriodeFromDate +/* function getPeriodeFromMonth ************************************************** * Purpose : Return the period corresponding to the * date * * parm : * - p_cn database connection - * - the date 'MM.YYYY' + * - the month + year 'MM.YYYY' * gen : * - none * * return: * parm_periode.p_id */ -function getPeriodeFromDate($p_cn,$p_date) { +function getPeriodeFromMonth($p_cn,$p_date) { $R=ExecSql($p_cn,"select p_id from parm_periode where to_char(p_start,'DD.MM.YYYY') = '01.$p_date'"); if ( pg_NumRows($R) == 0 ) @@ -378,5 +378,30 @@ function getPeriodeFromDate($p_cn,$p_date) { return $a['p_id']; } +/* function getPeriodeFromDate + ************************************************** + * Purpose : Return the period corresponding to the + * date + * + * parm : + * - p_cn database connection + * - the date 'DD.MM.YYYY' + * gen : + * - none + * + * return: + * parm_periode.p_id + */ +function getPeriodeFromDate($p_cn,$p_date) { + $R=ExecSql($p_cn,"select p_id from parm_periode where + p_start <= to_date('$p_date','DD.MM.YYYY') + and p_end >= to_date('$p_date','DD.MM.YYYY') + "); + if ( pg_NumRows($R) == 0 ) + return -1; + $a=pg_fetch_array($R,0); + + return $a['p_id']; +} ?> diff --git a/include/impress_inc.php b/include/impress_inc.php index 2d300f944..5de90af4f 100644 --- a/include/impress_inc.php +++ b/include/impress_inc.php @@ -749,7 +749,7 @@ function ParseFormula($p_cn,$p_label,$p_formula,$p_start,$p_end,$p_eval=true) { // then we must modify the cond for the periode $from=str_replace("FROM=","",$afrom[0]); // Get the periode - $from=getPeriodeFromDate($p_cn,$from); + $from=getPeriodeFromMonth($p_cn,$from); // Compute the cond if ( $from == $p_end ) diff --git a/include/user_common.php b/include/user_common.php index a582a75ed..3a5568581 100644 --- a/include/user_common.php +++ b/include/user_common.php @@ -401,14 +401,14 @@ function ListJrn($p_cn,$p_jrn,$p_where="",$p_array=null) $r.="