From 998e221893c9bd5514cbdbfd377253e88aacdb9b Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sun, 13 Mar 2005 17:35:01 +0000 Subject: [PATCH] Task 3778 remove old document when overwritting --- include/jrn.php | 8 ++++++++ include/postgres.php | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/include/jrn.php b/include/jrn.php index 079be045b..4005a4ab8 100644 --- a/include/jrn.php +++ b/include/jrn.php @@ -343,6 +343,12 @@ if ( $p_update == 0 ) echo " table=1; + //document + $r.="".sprintf('%s', + $content['jr_id'], + $content['jr_grpt_id'], + $content['jr_pj_name']).""; + $r.="
"; $r.= ""; $r.="".$file->IOValue("pj","","Pièce justificative").""; @@ -1008,6 +1014,7 @@ function GetDataJrnJrId ($p_cn,$p_jr_id) { j_montant, jr_montant, j_id, + jr_pj_name, jr_grpt_id, jr_comment, to_char(jr_ech,'DD.MM.YYYY') as jr_ech, @@ -1038,6 +1045,7 @@ function GetDataJrnJrId ($p_cn,$p_jr_id) { $array['jr_rapt']=$line['jr_rapt']; $array['jrn_def_type']=$line['jrn_def_type']; $array['jr_grpt_id']=$line['jr_grpt_id']; + $array['jr_pj_name']=$line['jr_pj_name']; // $array['']=$line['']; $ret_array[$i]=$array; diff --git a/include/postgres.php b/include/postgres.php index e3bdf271b..76b6abe3a 100644 --- a/include/postgres.php +++ b/include/postgres.php @@ -389,6 +389,15 @@ function save_upload_document ($cn,$seq) { return; } echo_debug(__FILE__,__LINE__,"Loading document"); + // Remove old document + $ret=ExecSql($cn,"select jr_pj from jrn where jr_grpt_id=$seq"); + if (pg_num_rows($ret) != 0) { + $r=pg_fetch_array($ret,0); + $old_oid=$r['jr_pj']; + if (strlen($old_oid) != 0) + pg_lo_unlink($cn,$old_oid); + } + // Load new document ExecSql($cn,"update jrn set jr_pj=".$oid.", jr_pj_name='".$_FILES['pj']['name']."', ". "jr_pj_type='".$_FILES['pj']['type']."' where jr_grpt_id=$seq");