Check(); html_page_start($User->theme,"onLoad='window.focus();'"); if ( ! isset ( $_SESSION['g_dossier'] ) ) { echo "You must choose a Dossier "; exit -2; } $cn=DbConnect($_SESSION['g_dossier']); if ( isset( $_GET['p_jrn'] )) { $p_jrn=$_GET['p_jrn']; } else { if ( ! isset ( $_GET['p_jrn']) ) $p_jrn=0; else $p_jrn=$_GET['p_jrn']; } if ( isset ( $_GET['action'] ) ) { $action=$_GET['action']; } $_SESSION["p_jrn"]=$p_jrn; if ( isset ( $_POST['action'] ) ) { $action=$_POST['action']; } if ( ! isset ( $action )) { echo_error("modify_op.php No action asked "); exit(); } // Javascript echo JS_VIEW_JRN_MODIFY; ////////////////////////////////////////////////////////////////////// if ( $action == 'update' ) { if ( ($priv=CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$_GET['p_jrn'],true)) < 1 ) { NoAccess(); exit -1; } // p_id is jrn.jr_id $p_id=$_GET["line"]; echo_debug('modify_op.php',__LINE__," action = update p_id = $p_id"); echo JS_VIEW_JRN_DETAIL; echo JS_CONCERNED_OP; $r ='
'; $r.=UpdateJrn($cn,$p_id); $r.=''; $r.="
"; $r.="
"; $r.="
"; $r.=''; $r.="      "; $r.=''; $r.='
'; // echo '
'; echo $r; // echo '
'; } if ( isset($_POST['update_record']) ) { if ( ($priv=CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$p_jrn,true)) !=2 ) { NoAccess(); exit -1; } // NO UPDATE except rapt & comment && upload pj StartSql($cn); UpdateComment($cn,$_POST['jr_id'],$_POST['comment']); InsertRapt($cn,$_POST['jr_id'],$_POST['rapt']); if ( isset ($_FILES)) { save_upload_document($cn,$_POST['jr_grpt_id']); } if ( isset ($_POST['is_paid'] )) $Res=ExecSql($cn,"update jrn set jr_rapt='paid' where jr_id=".$_POST['jr_id']); if ( isset ($_POST['to_remove'] )) { /*! \note we don't remove the document file if another * operation needs it. */ $ret=ExecSql($cn,"select jr_pj from jrn where jr_id=".$_POST['jr_id']); if (pg_num_rows($ret) != 0) { $r=pg_fetch_array($ret,0); $old_oid=$r['jr_pj']; if (strlen($old_oid) != 0) { // check if this pj is used somewhere else $c=CountSql($cn,"select * from jrn where jr_pj=".$old_oid); if ( $c == 1 ) pg_lo_unlink($cn,$old_oid); } ExecSql($cn,"update jrn set jr_pj=null, jr_pj_name=null, ". "jr_pj_type=null where jr_id=".$_POST['jr_id']); } } Commit($cn); echo ' '; } // if update_record ////////////////////////////////////////////////////////////////////// if ( $action == 'delete' ) { echo_debug('modify_op.php',__LINE__," Call DeleteRapt($cn,".$_GET['line'].",".$_GET['line2'].")"); DeleteRapt($cn,$_GET['line'],$_GET['line2']); echo ' '; } html_page_stop(); ?>