00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024 include_once ("ac_common.php");
00025 include_once ("poste.php");
00026 include_once("preference.php");
00027 include_once("central_inc.php");
00028 include_once("check_priv.php");
00029 include_once("user_common.php");
00030 include_once ("postgres.php");
00031 include_once("jrn.php");
00032 include_once("class_widget.php");
00033
00034
00035 $rep=DbConnect();
00036 include_once ("class_user.php");
00037 $User=new cl_user($rep);
00038 $User->Check();
00039
00040 html_page_start($User->theme,"onLoad='window.focus();'");
00041 if ( ! isset ( $_SESSION['g_dossier'] ) ) {
00042 echo "You must choose a Dossier ";
00043 exit -2;
00044 }
00045
00046 $cn=DbConnect($_SESSION['g_dossier']);
00047
00048 if ( isset( $_GET['p_jrn'] )) {
00049 $p_jrn=$_GET['p_jrn'];
00050 } else {
00051 if ( ! isset ( $_GET['p_jrn']) )
00052 $p_jrn=0;
00053 else
00054 $p_jrn=$_GET['p_jrn'];
00055 }
00056 if ( isset ( $_GET['action'] ) ) {
00057 $action=$_GET['action'];
00058 }
00059 $_SESSION["p_jrn"]=$p_jrn;
00060
00061
00062 if ( isset ( $_POST['action'] ) ) {
00063 $action=$_POST['action'];
00064 }
00065 if ( ! isset ( $action )) {
00066 echo_error("modify_op.php No action asked ");
00067 exit();
00068 }
00069
00070
00071 echo JS_VIEW_JRN_MODIFY;
00072
00073 if ( $action == 'update' ) {
00074 if ( ($priv=CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$_GET['p_jrn'],true)) < 1 ) {
00075 NoAccess();
00076 exit -1;
00077
00078 }
00079
00080 $p_id=$_GET["line"];
00081 echo_debug('modify_op.php',__LINE__," action = update p_id = $p_id");
00082 echo JS_VIEW_JRN_DETAIL;
00083 echo JS_CONCERNED_OP;
00084 $r ='<FORM METHOD="POST" enctype="multipart/form-data" ACTION="modify_op.php">';
00085 $r.=UpdateJrn($cn,$p_id);
00086
00087 $r.='<INPUT TYPE="Hidden" name="action" value="update_record">';
00088 $r.="<br>";
00089 $r.="<br>";
00090 $r.="<br>";
00091 $r.='<input type="SUBMIT" name="update_record" value="Enregistre">';
00092 $r.=" ";
00093 $r.='<input type="button" value="Fermer" onClick="window.close();">';
00094 $r.='</FORM>';
00095
00096
00097 echo $r;
00098
00099 }
00100 if ( isset($_POST['update_record']) ) {
00101 if ( ($priv=CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$p_jrn,true)) !=2 ) {
00102 NoAccess();
00103 exit -1;
00104
00105 }
00106
00107
00108 StartSql($cn);
00109
00110 UpdateComment($cn,$_POST['jr_id'],$_POST['comment']);
00111 InsertRapt($cn,$_POST['jr_id'],$_POST['rapt']);
00112 if ( isset ($_FILES)) {
00113 save_upload_document($cn,$_POST['jr_grpt_id']);
00114 }
00115 if ( isset ($_POST['is_paid'] ))
00116 $Res=ExecSql($cn,"update jrn set jr_rapt='paid' where jr_id=".$_POST['jr_id']);
00117
00118 if ( isset ($_POST['to_remove'] )) {
00122 $ret=ExecSql($cn,"select jr_pj from jrn where jr_id=".$_POST['jr_id']);
00123 if (pg_num_rows($ret) != 0) {
00124 $r=pg_fetch_array($ret,0);
00125 $old_oid=$r['jr_pj'];
00126 if (strlen($old_oid) != 0)
00127 {
00128
00129 $c=CountSql($cn,"select * from jrn where jr_pj=".$old_oid);
00130 if ( $c == 1 )
00131 pg_lo_unlink($cn,$old_oid);
00132 }
00133 ExecSql($cn,"update jrn set jr_pj=null, jr_pj_name=null, ".
00134 "jr_pj_type=null where jr_id=".$_POST['jr_id']);
00135 }
00136 }
00137
00138
00139 Commit($cn);
00140
00141 echo ' <script>
00142 window.close();
00143 self.opener.RefreshMe();
00144 </script>';
00145 }
00146
00147 if ( $action == 'delete' ) {
00148 echo_debug('modify_op.php',__LINE__," Call DeleteRapt($cn,".$_GET['line'].",".$_GET['line2'].")");
00149 DeleteRapt($cn,$_GET['line'],$_GET['line2']);
00150 echo ' <script>
00151 window.close();
00152 self.opener.RefreshMe();
00153 </script>';
00154 }
00155 html_page_stop();
00156 ?>