/include/imports_task.php
PHP | 1195 lines | 929 code | 125 blank | 141 comment | 113 complexity | a0833bbb890c6dcda77f87ad62fc25ce MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0
- <?php
- session_start();
- include("./connect_functions.php");
- include("./general_functions.php");
- if(isset($_SESSION['status_log']) && $_SESSION['status_log']=='ok')
- {
-
-
- connect_db();
- $message='';
- $info_msg='';
- $qry_depts='';
- $error_mess='';
- $readonly='';
- $readonly_flag=false;
- $from_import=false;
- $tblmsg='';
- if(isset($_POST['check_flag']))
- {
-
-
- $check_flag=intval($_POST['check_flag']);
- $cur_page=intval($_POST['cur_page']);
- $status=intval($_POST['status']);
- $status_val=$status;
- if($status==0)
- {
- $label="εισερχόμενο";
- $label_gen="εισερχομένου";
- }
- else
- {
- $label="εξερχόμενο";
- $label_gen="εξερχομένου";
- }
-
- $book_id=intval($_POST['book_id']);
-
- $import_id = isset ($_POST['import_id']) ? intval ($_POST['import_id']) : $book_id;
-
- switch($check_flag)
- {
- case 0:
- if($book_id>0)
- {
- //echo $book_id;
- $io_year=date("Y");
- $query="select io_year from book where id=" . $book_id;
- @mysql_query ('set character set utf8 ');
- $res=mysql_query($query);
- if($res)
- $io_year=mysql_result($res,0);
-
- $query="select count(pn) as protocol_number from book where import_id=".$book_id." and status=1 and io_year=" . $io_year . " and pn=(select pn from book where id=" . $book_id . ")";
- @mysql_query ('set character set utf8 ');
- $res=mysql_query($query);
- $row=mysql_fetch_array($res);
- if($row['protocol_number']>0)
- {
- $query="select * from book where import_id=".$book_id." and status=1 and io_year=" . $io_year . " and pn=(select pn from book where id=" . $book_id . ")";
- @mysql_query ('set character set utf8 ');
- $res=mysql_query($query);
- $num_res=mysql_num_rows($res);
- if($num_res > 0)
- {
- $row=mysql_fetch_array($res);
- $pn= $row['pn'];
- $ada = $row['ada'];
- $io_date=mysql2screen("/",$row['io_date']);
- $io_year=$row['io_year'];
-
- $tbl_date=explode("-", $io_date);
- $i_place=$row['i_place'];
- $io_folder=$row['io_folder'];
- $fakelos = $row['fakelos'];
- $proter = $row['proter'];
- $io_auth=$row['io_auth'];
- $i_num=$row['i_num'];
- $io_auth_date=mysql2screen("/",$row['io_auth_date']);
- $summary=$row['summary'];
- $announce=$row['announce'];
- $rem = $row['rem'];
- $mail_id=$row['mail_id'];
- $check_flag=2;
- $info_msg="To Εξερχόμενο : " . $row['pn'] . "/" . mysql2screen("-",$row['io_date']) . " υπάρχει!";
- //$readonly=" readonly=\"readonly\" ";
- //$readonly_flag=true;
- $book_id=$row['id'];
- $status_val=1;
- }
- }
- else
- {
- if ($import_id > 0)
- {
- $query="select * from book where status=1 and import_id=" . $import_id;
- @mysql_query ('set character set utf8 ');
- $res=mysql_query($query);
- $num_res=mysql_num_rows($res);
- }
- else $num_res = 0;
-
- if($num_res > 0)
- {
- $row=mysql_fetch_array($res);
- $pn = $row['pn'];
- $ada = $row['ada'];
- $io_date=mysql2screen("/",$row['io_date']);
- $io_year=$row['io_year'];
-
- $tbl_date=explode("-", $io_date);
- $i_place=$row['i_place'];
- $io_folder=$row['io_folder'];
- $fakelos = $row['fakelos'];
- $proter = $row['proter'];
- $io_auth=$row['io_auth'];
- $i_num=$row['i_num'];
- $io_auth_date=mysql2screen("/",$row['io_auth_date']);
- $summary=$row['summary'];
- $announce=$row['announce'];
- $rem = $row['rem']; // add
- $mail_id=$row['mail_id'];
- $check_flag=2;
- $info_msg="To Εξερχόμενο : " . $row['pn'] . "/" . mysql2screen("-",$row['io_date']) . " υπάρχει!";
- //$readonly=" readonly=\"readonly\" ";
- //$readonly_flag=true;
- $status_val=1;
-
- $book_id = $row['id'];
- }
- else
- {
- $pn_io_year=0;
- $query="select pn, io_year, io_date from book where status=0 and id=" . $book_id;
- @mysql_query ('set character set utf8 ');
- $res=mysql_query($query);
- $num_res=mysql_num_rows($res);
- if($num_res > 0)
- {
- $row=mysql_fetch_array($res);
- $pn=$row['pn'];
- $ada = $row['ada'];
- $pn_io_year=$row['io_year'];
- $io_date=date("d/n/Y");
- $io_year=date("Y");
- $i_num = $row['pn'];
- $ada = '';
- $io_auth_date = mysql2screen("/",$row['io_date']);
-
- //
- $i_place='';
- $io_folder='';
- $fakelos = '';
- $io_auth='';
- $proter=0;
- $summary='';
- $announce='';
- $rem = ''; // add
- $mail_id=0;
- $check_flag=1;
- $info_msg.="Νέο εξερχόμενο";
- $from_import=true;
- $status_val=1;
- $import_id = $book_id;
- $book_id=-1;
-
- }
- }
- }
- }
- else
- {
- $pn='';
- $ada = '';
- $io_date=date("d/n/Y");
- $io_year=date("Y");
- $i_place='';
- $io_folder='';
- $fakelos = '';
- $proter=0;
- $io_auth='';
- $i_num='';
- $io_auth_date='';
- $summary='';
- $announce='';
- $rem = '';
- $mail_id=0;
- $check_flag=1;
- $info_msg.="Νέο " . $label;
- }
-
-
-
-
- //$book_id=0;
- break;
- case 1:
- $i_place='';
- $ada = '';
- $io_folder='';
- $fakelos = '';
- $proter=0;
- $io_auth='';
- $i_num='';
- $io_auth_date='';
- $summary='';
- $announce='';
- $row='';
- $mail_id=0;
- $ins_qry_tbl=array();
- if($book_id==0)
- {
- // allagh vassilis
- $query="select max(pn) as protocol_number from book where io_year=" . date("Y")." and import_id=0";
- @mysql_query ('set character set utf8 ');
- $res=mysql_query($query);
- $row=mysql_fetch_array($res);
- $pn=++$row['protocol_number'];
- $status_val=$status;
- }
- else
- {
- $status_val=1;
- $label="εξερχόμενο";
- $label_gen="εξερχομένου";
- if(isset($_POST['pn']) && intval($_POST['pn']) >0)
- $pn=intval($_POST['pn']);
- else
- {
- //$pn="null";
- $query="select max(pn) as protocol_number from book where io_year=" . date("Y");
- @mysql_query ('set character set utf8 ');
- $res=mysql_query($query);
- $row=mysql_fetch_array($res);
- $pn=++$row['protocol_number'];
-
- }
-
- }
-
- array_push($ins_qry_tbl, "pn=" . $pn);
-
- $io_date=date("Y-m-d");
- array_push($ins_qry_tbl, "io_date='" . $io_date . "'");
-
- $io_year=date("Y");
- array_push($ins_qry_tbl, "io_year=" . $io_year);
-
- if(isset($_POST['i_num']) && trim($_POST['i_num'])!='')
- {
- $i_num=trim($_POST['i_num']);
- array_push($ins_qry_tbl, "i_num='". $i_num . "'");
- }
- else
- array_push($ins_qry_tbl, "i_num=null");
-
- if(isset($_POST['ada']) && trim($_POST['ada'])!='')
- {
- $ada=trim($_POST['ada']);
- array_push($ins_qry_tbl, "ada='" . $ada . "'");
- }
- else
- array_push($ins_qry_tbl, "ada=null");
-
- if(isset($_POST['i_place']) && trim($_POST['i_place'])!='')
- {
- $i_place=trim($_POST['i_place']);
- array_push($ins_qry_tbl, "i_place='" . $i_place . "'");
- }
- else
- array_push($ins_qry_tbl, "i_place=null");
-
- if(isset($_POST['io_folder']) && trim($_POST['io_folder'])!='')
- {
- $io_folder=trim($_POST['io_folder']);
- array_push($ins_qry_tbl, "io_folder='" . $io_folder . "'");
- }
- else
- array_push($ins_qry_tbl, "io_folder=null");
-
- if(isset($_POST['fakelos']) && trim($_POST['fakelos'])!='')
- {
- $fakelos=trim($_POST['fakelos']);
- array_push($ins_qry_tbl, "fakelos='" . $fakelos . "'");
- }
- else
- array_push($ins_qry_tbl, "fakelos=null");
-
- if(isset($_POST['io_auth']) && trim($_POST['io_auth'])!='')
- {
- $io_auth=trim($_POST['io_auth']);
- array_push($ins_qry_tbl, "io_auth='" . $io_auth . "'");
- }
- else
- array_push($ins_qry_tbl, "io_auth=null");
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- if(isset($_POST['io_auth_date']) && trim($_POST['io_auth_date'])!='')
- {
- $io_auth_date=screen2mysql("/", $_POST['io_auth_date']);
- if($io_auth_date!='')
- {
- array_push($ins_qry_tbl,"io_auth_date='" . $io_auth_date . "'");
- $io_auth_date=mysql2screen("/",$io_auth_date);
- }
- else
- array_push($ins_qry_tbl,"io_auth_date=null");
-
-
- }
- else
- {
- array_push($ins_qry_tbl,"io_auth_date=null");
- $io_auth_date='';
- }
-
-
- if(isset($_POST['summary']) && trim($_POST['summary'])!='')
- {
- $quotes=array("'","\"");
- //$summary=str_replace($quotes,"", trim($_POST['summary']));
- $summary = mysql_real_escape_string($_POST['summary']);
- array_push($ins_qry_tbl,"summary='" . $summary . "'");
- }
- else
- {
- $summary='';
- }
-
- if(isset($_POST['announce']) && trim($_POST['announce'])!='')
- {
- $quotes=array("'","\"");
- $announce=str_replace($quotes,"", trim($_POST['announce']));
- array_push($ins_qry_tbl,"announce='" . $announce . "'");
- }
- else
- {
-
- $announce='';
- }
-
- if(isset($_POST['proter']) && trim($_POST['proter'])!=0)
- {
- $proter=trim($_POST['proter']);
- array_push($ins_qry_tbl, "proter='" . $proter . "'");
- }
- else
- array_push($ins_qry_tbl, "proter=0");
-
- if(isset($_POST['rem']) && trim($_POST['rem'])!='')
- {
- $quotes=array("'","\"");
- $rem=str_replace($quotes,"", trim($_POST['rem']));
- array_push($ins_qry_tbl,"rem='" . $rem . "'");
- }
- else
- {
-
- $rem='';
- }
-
-
- array_push($ins_qry_tbl,"status=" . $status_val);
- array_push($ins_qry_tbl,"mail_id=0");
-
- if ($import_id > 0)
- {
- array_push ($ins_qry_tbl, "import_id=" . $import_id);
- }
-
-
- //$book_id=0;
-
- $query="insert into book set " . implode(",", $ins_qry_tbl);
- @mysql_query ('set character set utf8 ');
- @mysql_query($query);
- if(mysql_affected_rows()==1)
- {
- $book_id=mysql_insert_id();
- print_r(array_values($ins_qry_tbl));echo "<br>";
- $info_msg="Η εγγραφή του " . $label_gen . " " . $pn . "/" . $io_date . " έγινε με επιτυχία";
- $check_flag=2;
- //$myauth = str_replace("'","",substr($ins_qry_tbl[8],strpos($ins_qry_tbl[8],'=')+2,strlen($ins_qry_tbl[8])));
-
- //if(!is_numeric($myauth)){
- // echo $myauth;echo "<br>";
- // $qauth = "insert into apopros set io_auth='".$myauth."', syntomografia='".$myauth."'";
- // @mysql_query ('set character set utf8 ');
- //@mysql_query($qauth);
- //$qauth1 = "update book set io_auth=(select id from apopros where io_auth='".$myauth."') where id=". $book_id;
- // @mysql_query ('set character set utf8 ');
- // @mysql_query($qauth1);
- // }
-
- //$myplace = str_replace("'","",substr($ins_qry_tbl[5],strpos($ins_qry_tbl[5],'=')+2,strlen($ins_qry_tbl[5])));
- //print_r(array_values($ins_qry_tbl));echo "<br>";
- //if(!is_numeric($myplace)){
- //echo $myplace;echo "<br>";
- // $qplace = "insert into place set i_place='".$myplace."'";
- // @mysql_query ('set character set utf8 ');
- // @mysql_query($qplace);
- // $qplace1 = "update book set i_place=(select id from place where i_place='".$myplace."') where id=" . $book_id;
- // @mysql_query ('set character set utf8 ');
- // @mysql_query($qplace1);
- //echo $qplace1;
- //}
- if(isset($_POST['department']))
- {
- if(count($_POST['department']) > 0)
- {
- //echo "lala1";
- $ins_qry_tbl=array();
- $departments=array();
- $qry_depts="insert into bookdep (book_id,department_id, ch_date) values";
- $departments=$_POST['department'];
- for($i=0;$i<count($departments);$i++)
- {
- array_push($ins_qry_tbl,"(" . $book_id . ", " . $departments[$i] . ", '" . date("Y-m-d H:i:s") . "')");
- }
- $qry_depts.=implode("," , $ins_qry_tbl);
- @mysql_query ('set character set utf8 ');
- @mysql_query($qry_depts);
- }
- }
- else{
- //taytarithmos
- //echo "____lala____".date();
- if(KODIKOS_DDE=="888"){
- $querytayt = "insert into bookdep (book_id,department_id,ch_date)
- select ".$book_id.", department_id,'". date("Y-m-d H:i:s") . "' from bookdep where book_id="
- . " (select id from book where status=0 and pn=".$pn." and io_year=" . date("Y").")";
-
- //echo $querytayt;
- @mysql_query ('set character set utf8 ');
- @mysql_query($querytayt);
-
- }
- //taytarithmos
- }
-
-
- //-------------------------------------------------------------------------------------------------------
-
- }
- else
- {
- $info_msg=mysql_error() . " --- Δεν έγινε εισαγωγή εγγραφής";
- //$message.=$query;
- }
-
-
- break;
- case 2:
- $i_place='';
- $ada = '';
- $io_year='';
- $io_auth='';
- $i_num='';
- $io_auth_date='';
- $announce='';
- $summary='';
- $rem = '';
- $io_folder='';
- $fakelos='';
- $proter=0;
- $mail_id=0;
- $ins_qry_tbl=array();
- $pn=intval($_POST['pn']);
-
- $io_date=$_POST['io_date'];
- $io_year=intval($_POST['io_year']);
- //$io_date=screen2mysql("/", $io_date);
- $mail_id=$_POST['mail_id'];
- //array_push($ins_qry_tbl, "io_date='" . $io_date . "'");
-
- if(isset($_POST['i_num']) && trim($_POST['i_num'])!='')
- {
- $i_num=trim($_POST['i_num']);
- array_push($ins_qry_tbl, "i_num='". $i_num . "'");
- }
- else
- array_push($ins_qry_tbl, "i_num=null");
-
- if(isset($_POST['i_place']) && trim($_POST['i_place'])!='')
- {
- $i_place=trim($_POST['i_place']);
- array_push($ins_qry_tbl, "i_place='" . $i_place . "'");
- }
- else
- array_push($ins_qry_tbl, "i_place=null");
-
- if(isset($_POST['ada']) && trim($_POST['ada'])!='')
- {
- $ada=trim($_POST['ada']);
- array_push($ins_qry_tbl, "ada='" . $ada . "'");
- }
- else
- array_push($ins_qry_tbl, "ada=null");
-
- if(isset($_POST['io_folder']) && trim($_POST['io_folder'])!='')
- {
- $io_folder=trim($_POST['io_folder']);
- array_push($ins_qry_tbl, "io_folder='" . $io_folder . "'");
- }
- else
- array_push($ins_qry_tbl, "io_folder=null");
-
- if(isset($_POST['fakelos']) && trim($_POST['fakelos'])!='')
- {
- $fakelos=trim($_POST['fakelos']);
- //echo $fakelos;
- if(!is_numeric($fakelos))
- {
- $fakelos = substr($fakelos,0,strpos($fakelos,' '));
- $q1 = "select id from thematologio where fakelos like '%".$fakelos."%'";
- @mysql_query ('set character set utf8 ');
- $res1=mysql_query($q1);
- $num_res1=mysql_num_rows($res1);
- if($num_res1 > 0)
- {
- $row1=mysql_fetch_array($res1);
- $fakelos = $row1['id'];
- }
- //echo $fakelos;
- }
- array_push($ins_qry_tbl, "fakelos='" . $fakelos . "'");
- }
- else
- array_push($ins_qry_tbl, "fakelos=null");
-
- if(isset($_POST['io_auth']) && trim($_POST['io_auth'])!='')
- {
- $io_auth=trim($_POST['io_auth']);
- if(!is_numeric($io_auth))
- {
- $q1 = "select id from apopros where onomasia like '%".$io_auth."%' or syntomografia like '%".$io_auth."%'";
- @mysql_query ('set character set utf8 ');
- $res1=mysql_query($q1);
- $num_res1=mysql_num_rows($res1);
- if($num_res1 > 0)
- {
- $row1=mysql_fetch_array($res1);
- $io_auth = $row1['id'];
- }
- //echo $io_auth;
- }
- array_push($ins_qry_tbl, "io_auth='" . $io_auth . "'");
- }
- else
- array_push($ins_qry_tbl, "io_auth=null");
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////
- if(isset($_POST['io_auth_date']) && trim($_POST['io_auth_date'])!='')
- {
-
- $io_auth_date=screen2mysql("/", $_POST['io_auth_date']);
-
- if($io_auth_date!='')
- {
- array_push($ins_qry_tbl,"io_auth_date='" . $io_auth_date . "'");
- $io_auth_date=mysql2screen("/",$io_auth_date);
- }
- else
- array_push($ins_qry_tbl,"io_auth_date=null");
- }
- else
- {
- array_push($ins_qry_tbl,"io_auth_date=null");
- $io_auth_date='';
- }
-
-
- if(isset($_POST['summary']) && trim($_POST['summary'])!='')
- {
- $quotes=array("'","\"");
- //$summary=str_replace($quotes,"", trim($_POST['summary']));
- $summary = mysql_real_escape_string($_POST['summary']);
- array_push($ins_qry_tbl,"summary='" . $summary . "'");
- }
- else
- {
- $summary='';
- }
-
-
- if(isset($_POST['announce']) && trim($_POST['announce'])!='')
- {
- $quotes=array("'","\"");
- $announce=str_replace($quotes,"", trim($_POST['announce']));
- array_push($ins_qry_tbl,"announce='" . $announce . "'");
- }
- else
- {
- $announce='';
- }
-
- if(isset($_POST['rem']) && trim($_POST['rem'])!='')
- {
- $quotes=array("'","\"");
- $rem=str_replace($quotes,"", trim($_POST['rem']));
- array_push($ins_qry_tbl,"rem='" . $rem . "'");
- }
- else
- {
- $rem='';
- }
-
- if(isset($_POST['proter']) && trim($_POST['proter'])!=0)
- {
- $proter=trim($_POST['proter']);
- if(!is_numeric($proter))
- {
- $q1 = "select id from proteraiothta where perigrafi like '%".$proter."%'";
- @mysql_query ('set character set utf8 ');
- $res1=mysql_query($q1);
- $num_res1=mysql_num_rows($res1);
- if($num_res1 > 0)
- {
- $row1=mysql_fetch_array($res1);
- $proter = $row1['id'];
- }
- //echo $io_auth;
- }
- array_push($ins_qry_tbl, "proter='" . $proter . "'");
- }
- else
- array_push($ins_qry_tbl, "proter=0");
-
- $query="update book set " . implode(",", $ins_qry_tbl) . " where id=" . $book_id;
- //$myplace = str_replace("'","",substr($ins_qry_tbl[1],strpos($ins_qry_tbl[1],'=')+2,strlen($ins_qry_tbl[1])));
- // print_r(array_values($ins_qry_tbl));echo "<br>";
- //$qp1 = "select * from place where i_place='".$myplace."'";
- //@mysql_query ('set character set utf8 ');
- //$r1=mysql_query($qp1);
- //if(!is_numeric($myplace)){
- // //echo $myplace; echo "<br>"; echo mysql_num_rows($r1); echo "<br>";
- // if(mysql_num_rows($r1)==0){
- // $qplace = "insert into place set i_place='".$myplace."'";
- // @mysql_query ('set character set utf8 ');
- // @mysql_query($qplace);
-
- //}
-
- //echo $qplace1;
- //}
- //$myauth = str_replace("'","",substr($ins_qry_tbl[5],strpos($ins_qry_tbl[5],'=')+2,strlen($ins_qry_tbl[5])));
- //$qa1 = "select * from apopros where io_auth='".$myauth."'";
- //@mysql_query ('set character set utf8 ');
- // $r2=mysql_query($qa1);
- //if(!is_numeric($myauth)){
- // echo $myauth;echo "<br>";
- // if(mysql_num_rows($r2)==0){
- // $qauth = "insert into apopros set io_auth='".$myauth."', syntomografia='".$myauth."'";
- // @mysql_query ('set character set utf8 ');
- // @mysql_query($qauth);
-
- //}
-
- //echo $qauth1;
- //}
- @mysql_query ('set character set utf8 ');
- @mysql_query($query);
- if(mysql_affected_rows()==1)
- {
-
- // $qplace1 = "update book set i_place=(select id from place where i_place='".$myplace."') where id=" . $book_id;
- //@mysql_query ('set character set utf8 ');
- //@mysql_query($qplace1);
- //echo $qplace1;
-
- //$qauth1 = "update book set io_auth=(select id from apopros where io_auth='".$myauth."') where id=". $book_id;
- // @mysql_query ('set character set utf8 ');
- // @mysql_query($qauth1);
-
-
- $info_msg="Το " . $label . " " . $pn . "/" . $io_date . " ενημερώθηκε με επιτυχία";
-
- $check_flag=2;
-
- }
- else if(mysql_errno()!=0)
- {
- $info_msg=mysql_error(); " --- Δεν έγινε ενημέρωση εγγραφής";
- $check_flag=2;
- }
- else
- {
- $info_msg="Δέν έγινε καμία μεταβολή";
- $check_flag=2;
- }
-
- if(isset($_POST['department']))
- {
- if(count($_POST['department']) > 0)
- {
- //echo "lala2";
- $ins_qry_tbl=array();
- $departments=array();
- $qry_depts="insert into bookdep (book_id,department_id, ch_date) values";
- $departments=$_POST['department'];
-
- $qry_depts2="delete from bookdep where book_id=" . $book_id . " and department_id not in (" . implode(",",$departments) . ")";
- @mysql_query ('set character set utf8 ');
- @mysql_query($qry_depts2);
- if(mysql_affected_rows()>0)
- $info_msg="Το " . $label . " " . $pn . "/" . $io_date . " ενημερώθηκε με επιτυχία";
-
- //$qry_depts='';
- for($i=0;$i<count($departments);$i++)
- {
- array_push($ins_qry_tbl,"(" . $book_id . ", " . $departments[$i] . ", '" . date("Y-m-d H:i:s") . "')");
- }
- $qry_depts.=implode("," , $ins_qry_tbl) . " on duplicate key update ch_date=ch_date";
- @mysql_query ('set character set utf8 ');
- @mysql_query($qry_depts);
- if(mysql_affected_rows()>0)
- $info_msg="Το " . $label . " " . $pn . "/" . $io_date . " ενημερώθηκε με επιτυχία";
-
- }
-
- }
-
- else
- {
- //echo "lala3";
- $qry_depts="delete from bookdep where book_id=" . $book_id;
- @mysql_query ('set character set utf8 ');
- @mysql_query($qry_depts);
- if(mysql_affected_rows()>0)
- $info_msg="Το " . $label . " " . $pn . "/" . $io_date . " ενημερώθηκε με επιτυχία";
- }
-
- break;
- case 3:
- break;
- case 5:
- $query = "select * from book where id=" . $book_id;
- @mysql_query ('set character set utf8 ');
- $res=mysql_query($query);
- $num_res=mysql_num_rows($res);
- if($num_res > 0)
- {
- $row=mysql_fetch_array($res);
- $pn= $row['pn'];
- $ada= $row['ada'];
- $io_date=$row['io_date'];
- $io_year=$row['io_year'];
- $tbl_date=explode("-", $io_date);
- $io_date=mysql2screen("/", $io_date);
- $i_place=$row['i_place'];
- $io_folder=$row['io_folder'];
- $fakelos=$row['fakelos'];
- $proter=$row['proter'];
- $io_auth=$row['io_auth'];
- $i_num=$row['i_num'];
- $io_auth_date=mysql2screen("/",$row['io_auth_date']);
- $summary=$row['summary'];
- $announce=$row['announce'];
- $mail_id=$row['mail_id'];
- $rem = $row['rem'];
- $check_flag=2;
- if($status==0)
- $info_msg="Εισερχόμενο : " .$row['pn'] . "/" . $tbl_date[2] . "-" . $tbl_date[1] ."-" . $tbl_date[0];
- else
- $info_msg="Εξερχόμενο : " .$row['pn'] . "/" . $tbl_date[2] . "-" . $tbl_date[1] ."-" . $tbl_date[0];
- }
-
- break;
- }
-
- $message.="<fieldset id=\"fieldset_id\">";
- $message.="<div class=\"msgbar\">" . $info_msg . "</div>";
- //$message.="<p>" . $query . "<br />" . $qry_depts . "</p>";
- $message.="<input type=\"hidden\" name=\"check_flag\" id=\"chfl_id\" value=\"" . $check_flag . "\" />";
- $message.="<input type=\"hidden\" name=\"book_id\" id=\"book_id_id\" value=\"" . $book_id . "\" />";
- $message.="<input type=\"hidden\" name=\"io_year\" id=\"io_year_id\" value=\"" . $io_year . "\" />";
- $message.="<input type=\"hidden\" name=\"mail_id\" id=\"mail_id_id\" value=\"" . $mail_id . "\" />";
- $message.= "<input type=\"hidden\" name=\"status\" id=\"status_id\" value=\"" . $status . "\" />";
- $message.= "<input type=\"hidden\" name=\"cur_page\" id=\"cur_page_id\" value=\"" . $cur_page . "\" />";
-
- if($status_val==0) { //import
- $message.="<div style=\"position:relative;display:inline-block;float:left;clear:none;\">";
- $message.="<div class=\"break\">
- <label for=\"pn\">Αρ.Πρωτ.</label>
- <input type=\"text\" name=\"pn\" id=\"pn_id\" readonly=\"readonly\" value=\"" . $pn . "\" class=\"ui-widget ui-corner-all\" />
- <label for=\"io_date\" class=\"w50\">ημ/νία</label>
- <input type=\"text\" name=\"io_date\" id=\"io_date_id\" readonly=\"readonly\" value=\"" . $io_date . "\" class=\"ui-widget ui-corner-all w80\" />
- </div>";
-
- $pthem = "select * from place where convert(id,char)='".$i_place."'";
- @mysql_query ('set character set utf8 ');
- $res_place = mysql_query($pthem);
- $num_res_place = mysql_num_rows($res_place);
- $place_i_place = $i_place;
- //echo $place_i_place;
- if($num_res_place > 0)
- {
- $row_place=mysql_fetch_array($res_place);
- $place_i_place = $row_place['i_place'];
- $message.="<div class=\"break\">
- <label for=\"i_place\">Τόπος έκδοσης</label>
- <input type=\"text\" name=\"i_place\" id=\"i_place_id\" value=\"" . $place_i_place . "\" class=\"w200 ui-corner-all ui-widget\" onkeyup=\"autocomplet3()\"/>
- <ul id=\"i_place_list_id\"></ul></div>";
- }
- else {
- $message.="<div class=\"break\">
- <label for=\"io_auth\">Τόπος έκδοσης</label>
- <input type=\"text\" name=\"i_place\" id=\"i_place_id\" value=\"" . $place_i_place . "\" class=\"w200 ui-corner-all ui-widget\" onkeyup=\"autocomplet3()\"/>
- <ul id=\"i_place_list_id\"></ul></div>";
- }
- /*$message.="<div class=\"break\">
- <label for=\"io_auth\">Αρχή έκδοσης</label>
- <input type=\"text\" name=\"io_auth\" id=\"io_auth_id\" " . $readonly . " value=\"" . $io_auth . "\" class=\"w300 ui-corner-all ui-widget\" />
- </div>";*/
- $athem = "select * from apopros where convert(id,char)='".$io_auth."'";
- //echo $athem;
- @mysql_query ('set character set utf8 ');
- $res_apo = mysql_query($athem);
- $num_res_apo = mysql_num_rows($res_apo);
- $apo_io_auth = $io_auth;
- if($num_res_apo > 0)
- {
- $row_apo=mysql_fetch_array($res_apo);
- $apo_io_auth = $row_apo['io_auth'];
- //echo "<br>".$apo_io_auth;
- $message.="<div class=\"break\">
- <label for=\"io_auth\">Αρχή έκδοσης</label>
- <input type=\"text\" name=\"io_auth\" id=\"io_auth_id\" value=\"" . $apo_io_auth . "\" class=\"w200 ui-corner-all ui-widget\" onkeyup=\"autocomplet2()\"/>
- <ul id=\"io_auth_list_id\"></ul></div>";
- //$message .="</div>";
- //echo $message;
- //$message .="</select></div>";
-
- }
- else {
- $message.="<div class=\"break\">
- <label for=\"io_auth\">Αρχή έκδοσης</label>
- <input type=\"text\" name=\"io_auth\" id=\"io_auth_id\" value=\"" . $apo_io_auth . "\" class=\"w200 ui-corner-all ui-widget\" onkeyup=\"autocomplet2()\"/>
- <ul id=\"io_auth_list_id\"></ul></div>";
- }
-
- $message.=" <div class=\"break\">
- <label for=\"i_num\">Αρ. Εισερχ.</label>
- <input type=\"text\" name=\"i_num\" id=\"i_num_id\" " . $readonly . " value=\"" . $i_num . "\" class=\" ui-corner-all\" />
- <label for=\"io_auth_date\" class=\"w50\">ημ/νία</label>
- <input type=\"text\" name=\"io_auth_date\" id=\"io_auth_date_id\" value=\"" . $io_auth_date . "\" class=\"w80 ui-corner-all ui-widget\" />
- </div>";
- $message.="<div class=\"break\">
- <label for=\"ada\">ΑΔΑ</label>
- <input type=\"text\" name=\"ada\" id=\"ada_id\" " . $readonly . " value=\"" . $ada . "\" class=\"w200 ui-corner-all ui-widget\" />
- </div>";
- $message.="<div class=\"break\">
- <label for=\"summary\">Περίληψη Εισερχ</label>
- <textarea name=\"summary\" id=\"summary_id\" " . $readonly . " class=\" ui-corner-all ui-widget\">" . $summary . "</textarea>
- </div>";
- $message.="<div class=\"break\">
- <label for=\"announce\">Κοινοποίηση</label>
- <textarea name=\"announce\" id=\"summary_id\" " . $readonly . " class=\" ui-corner-all ui-widget\">" . $announce . "</textarea>
- </div>";
- $message .= "<div class=\"break\">
- <label for=\"rem\">Παρατηρήσεις</label>
- <textarea name=\"rem\" id=\"rem_id\" " . $readonly . " class=\" ui-corner-all ui-widget\">" . $rem . "</textarea>
- </div>";
-
- //proteraiothta
- $pthem = "select * from proteraiothta where id=".$proter;
- @mysql_query ('set character set utf8 ');
- $res_proter = mysql_query($pthem);
- $num_res_proter = mysql_num_rows($res_proter);
- if($num_res_proter > 0)
- {
- $row_proter=mysql_fetch_array($res_proter);
- $proter = $row_proter['id'];
- $message.="<div class=\"break\"><label for=\"fakelos\">Προτεραιότητα</label>";
- $message .= selectproter("proter",$proter);
- $message .="</div>";
-
- //$message .="</select></div>";
- // prosuhkh pedioy elava gnvsh gia PDE thess by vassilis
- //ervthma prin
-
- $qprin = "select elavagnosi from bookdep where book_id=$book_id and department_id=".$_SESSION['dep_id'];
- //echo $qprin;
- @mysql_query ('set character set utf8 ');
- $res_prin = mysql_query($qprin);
- $num_res_prin = mysql_num_rows($res_prin);
- if($num_res_prin > 0)
- {
- $row_prin=mysql_fetch_array($res_prin);
- $elavagnosi = $row_prin['elavagnosi'];
- }
- $message.="<div class=\"break\"> </div>";
- if($elavagnosi==1){
- $message .="<div class=\"break\">
- <label for=\"elavagnosi\">Έλαβα Γνώση</label>
- <input type=\"checkbox\" name=\"read\" checked value=\"1\"></div>";
-
- }
- else {
- $message .="<div class=\"break\">
- <label for=\"elavagnosi\">Έλαβα Γνώση</label>
- <input type=\"checkbox\" name=\"read\" value=\"0\"></div>";
-
- }
- //ervthma meta
- //onChange="this.form.submit()
- //telos allaghs elava gnosh
-
-
-
- }
- $message.="<div class=\"break\"> </div>";
- $qthem = "select * from thematologio where id=".$fakelos;
- @mysql_query ('set character set utf8 ');
- $res_them = mysql_query($qthem);
- $num_res_them = mysql_num_rows($res_them);
- if($num_res_them > 0)
- {
- $row_them=mysql_fetch_array($res_them);
- $fakelos_perigrafi = $row_them['fakelos']." ".$row_them['perigrafi'];
- $message.="<div class=\"break\">
- <label for=\"fakelos\">Φάκελος Αρχείου</label>
- <input type=\"text\" name=\"fakelos\" id=\"fakelos_id\" value=\"" . $fakelos_perigrafi . "\" class=\"w200 ui-corner-all ui-widget\" onkeyup=\"autocomplet()\"/>
- <ul id=\"fakelos_list_id\"></ul></div>";
- $message .="</div>";
-
- //$message .="</select></div>";
-
- }
- else {
- $fakelos_perigrafi = "Φάκελος Αρχείου";
- $message.="<div class=\"break\">
- <label for=\"fakelos\">Φάκελος Αρχείου</label>
- <input type=\"text\" name=\"fakelos\" id=\"fakelos_id\" value=\"" . $fakelos_perigrafi . "\" class=\"w200 ui-corner-all ui-widget\" onkeyup=\"autocomplet()\"/>
- <ul id=\"fakelos_list_id\"></ul></div>";
- $message .="</div>";
-
- }
-
-
- //
- }
- else { // outport
-
- $message.="<div style=\"position:relative;display:inline-block;float:left;clear:none;\">";
- //$message.=$query;
- $message.="<div class=\"break\">
- <label for=\"pn\">Αρ.Πρωτ.</label>
- <input type=\"text\" name=\"pn\" id=\"pn_id\" readonly=\"readonly\" value=\"" . $pn . "\" class=\"ui-widget ui-corner-all\" />
- <label for=\"io_date\" class=\"w50\">ημ/νία</label>
- <input type=\"text\" name=\"io_date\" id=\"io_date_id\" readonly=\"readonly\" value=\"" . $io_date . "\" class=\"ui-widget ui-corner-all w80\" />
- </div>";
- //$message.="<div class=\"break\">
- //<label for=\"io_auth\">Αρχή που απευθύνεται</label>
- //<input type=\"text\" name=\"io_auth\" id=\"io_auth_id\" " . $readonly . " value=\"" . $io_auth . "\" class=\"w300 ui-corner-all ui-widget\" />
- //</div>";
- $athem = "select * from apopros where convert(id,char)='".$io_auth."'";
- @mysql_query ('set character set utf8 ');
- $res_apo = mysql_query($athem);
- $num_res_apo = mysql_num_rows($res_apo);
- $apo_io_auth = $io_auth;
- if($num_res_apo > 0)
- {
- $row_apo=mysql_fetch_array($res_apo);
- $apo_io_auth = $row_apo['io_auth'];
- //echo "<br>".$apo_io_auth;
- $message.="<div class=\"break\">
- <label for=\"io_auth\">Αρχή που απευθύνεται</label>
- <input type=\"text\" name=\"io_auth\" id=\"io_auth_id\" value=\"" . $apo_io_auth . "\" class=\"w300 ui-corner-all ui-widget\" onkeyup=\"autocomplet2()\"/>
- <ul id=\"io_auth_list_id\"></ul></div>";
- //$message .="</div>";
- //echo $message;
- //$message .="</select></div>";
-
- }
- else {
- $message.="<div class=\"break\">
- <label for=\"io_auth\">Αρχή που απευθύνεται</label>
- <input type=\"text\" name=\"io_auth\" id=\"io_auth_id\" value=\"" . $apo_io_auth . "\" class=\"w300 ui-corner-all ui-widget\" onkeyup=\"autocomplet2()\"/>
- <ul id=\"io_auth_list_id\"></ul></div>";
- }
- $message.="<div class=\"break\">
- <label for=\"summary\">Περίληψη Εξερχ</label>
- <textarea name=\"summary\" id=\"summary_id\" " . $readonly . " class=\" ui-corner-all ui-widget\">" . $summary . "</textarea>
- </div>";
- $message.="<div class=\"break\">
- <label for=\"announce\">Κοινοποίηση</label>
- <textarea name=\"announce\" id=\"summary_id\" " . $readonly . " class=\" ui-corner-all ui-widget\">" . $announce . "</textarea>
- </div>";
- $message .= "<div class=\"break\">
- <label for=\"rem\">Παρατηρήσεις</label>
- <textarea name=\"rem\" id=\"rem_id\" " . $readonly . " class=\" ui-corner-all ui-widget\">" . $rem . "</textarea>
- </div>";
-
-
- $message.="<div class=\"break\">
- <label for=\"ada\">ΑΔΑ</label>
- <input type=\"text\" name=\"ada\" id=\"ada_id\" " . $readonly . " value=\"" . $ada . "\" class=\"w200 ui-corner-all ui-widget\" />
- </div>";
- $message.=" <div class=\"break\">
- <label for=\"i_num\">Σχετ. αριθ.</label>
- <input type=\"text\" name=\"i_num\" id=\"i_num_id\" " . $readonly . " value=\"" . $i_num . "\" class=\" ui-corner-all\" />
- <label for=\"io_auth_date\" >χρονολογ. διεκπ.</label>
- <input type=\"text\" name=\"io_auth_date\" id=\"io_auth_date_id\" " . $readonly . " value=\"" . $io_auth_date . "\" class=\"w80 ui-corner-all ui-widget\" />
-
- </div>";
-
- $qthem = "select * from thematologio where id=".$fakelos;
- @mysql_query ('set character set utf8 ');
- $res_them = mysql_query($qthem);
- $num_res_them = mysql_num_rows($res_them);
- if($num_res_them > 0)
- {
- $row_them=mysql_fetch_array($res_them);
- $fakelos_perigrafi = $row_them['fakelos']." ".$row_them['perigrafi'];
- $message.="<div class=\"break\">
- <label for=\"fakelos\">Φάκελος Αρχείου</label>
- <input type=\"text\" name=\"fakelos\" id=\"fakelos_id\" value=\"" . $fakelos_perigrafi . "\" class=\"w200 ui-corner-all ui-widget\" onkeyup=\"autocomplet()\"/>
- <ul id=\"fakelos_list_id\"></ul></div>";
- $message .="</div>";
-
- //$message .="</select></div>";
-
- }
- else {
- $fakelos_perigrafi = "Φάκελος Αρχείου";
- $message.="<div class=\"break\">
- <label for=\"fakelos\">Φάκελος Αρχείου</label>
- <input type=\"text\" name=\"fakelos\" id=\"fakelos_id\" value=\"" . $fakelos_perigrafi . "\" class=\"w200 ui-corner-all ui-widget\" onkeyup=\"autocomplet()\"/>
- <ul id=\"fakelos_list_id\"></ul></div>";
- $message .="</div>";
-
- }
- /*//proteraiothta
- $pthem = "select * from proteraiothta where id=".$proter;
- @mysql_query ('set character set utf8 ');
- $res_proter = mysql_query($pthem);
- $num_res_proter = mysql_num_rows($res_proter);
- if($num_res_proter > 0)
- {
- $row_proter=mysql_fetch_array($res_proter);
- $proter = $row_proter['id'];
- $message.="<div class=\"break\">";
- $message .= selectproter("proter",$proter);
- $message .="</div>";
-
-
- }*/
- //$message.="<div class=\"break\"><input type=\"text\" id=\"fakelos_id\" onkeyup=\"autocomplet()\"><ul id=\"fakelos_list_id\"></ul></div>";
-
- //<label for=\"io_auth\">Φάκελος Αρχείου</label>
- //<input type=\"text\" name=\"io_folder\" id=\"io_auth_id\" " . $readonly . " value=\"" . $io_folder . "\" class=\" ui-corner-all ui-widget\" />
-
- }
- if(isset($_SESSION['usrlvl']) && $_SESSION['usrlvl'] > 0 ) {
- $message.="<div style=\"position:relative;display:inline-block;float:left;clear:none;width:50%;\"><h3>Τμήματα</h3>";
- if(KODIKOS_DDE==284)
- $query_dep="SELECT b.book_id, d.id, d.name FROM departments d left join bookdep b on (d.id=b.department_id and b.book_id=" . $book_id . ") where d.hidden='0' order by d.name,d.id";
- else
- $query_dep="SELECT b.book_id, d.id, d.name FROM departments d left join bookdep b on (d.id=b.department_id and b.book_id=" . $book_id . ") where d.hidden='0' order by b.book_id desc, d.user_name,d.id";
- //$message.=$query_dep;
- @mysql_query ('set character set utf8 ');
- $res_dep=mysql_query($query_dep);
- $num_res_dep=mysql_num_rows($res_dep);
- if($num_res_dep > 0)
- {
- $message.="<div class=\"depts\">";
- for($k=0;$k<$num_res_dep;$k++)
- {
- $row_dep=mysql_fetch_array($res_dep);
- ((intval($row_dep['book_id'])==$book_id) && ($book_id!=0))?($check_str=" checked=\"checked\" "):($check_str="");
- if($_SESSION['usrlvl']==2)
- $message.="<div class=\"break\"><input type=\"checkbox\" name=\"department[]\" " . $check_str . " value=\"" . $row_dep['id'] . "\" /><span class=\"depts\">" . $row_dep['name'] . "</span></div>";
- else{
- $readonly=" readonly=\"readonly\" ";
- $message.="<div class=\"break\"><input disabled=\"disabled\" readonly=\"readonly\" type=\"checkbox\" name=\"department[]\" " . $check_str . " value=\"" . $row_dep['id'] . "\" /><span class=\"depts\">" . $row_dep['name'] . "</span></div>";
- }
- }
- $message.="</div></div>";
- }
- }
-
- if(intval($mail_id>0))
- {
- $mailquery="select * from mails where id=" . $mail_id;
- @mysql_query ('set character set utf8 ');
- $resmail=mysql_query($mailquery);
- $num_rows_mail=mysql_num_rows($resmail);
- if($num_rows_mail==1)
- {
- $rowmail=mysql_fetch_array($resmail);
- $message.="<div class=\"centcolumnpad\" >";
- $message.="<img src=\"./images/email4.png\" alt=\"mail_icon\" /><br />";
- //$message.= "Date : <u>" . mysql2screen("/",$rowmail['rt']) . "</u> <a href=\"#\" class=\"hid\" id=\"a_" . $rowmail['id'] . "\"><img src=\"./images/rollup.gif\" class=\"act\" alt=\"rollup\" /></a><br />";
- $message.= "Date : <u>" . mysql2screen("/",$rowmail['rt']) . "</u><br />";
- $message.= "From : <b>" . $rowmail['from'] . " [" . $rowmail['mail_address'] . "] </b><br />";
- $message.= "Subject : <b>" . $rowmail['subject'] . "</b><br />";
- $message.= "<span style='color: red; font-weight: bold;'>Κάντε κλικ στα βελάκια για να δείτε το μήνυμα</span> <a href=\"#\" class=\"hid\" id=\"a_" . $rowmail['id'] . "\"><img src=\"./images/rollup.gif\" alt=\"rollup\" /></a><br />";
- $message.= "<span id=\"b_a_" . $rowmail['id'] . "\" class=\"hidden_mail_body\"><b>Body message :</b><br />";
- $body = nl2br($rowmail['body']);
- $message.= $body . "</span>";
- $qryattach="select * from attachements where entry_id='" . $rowmail['entry_id'] . "' union select * from nomail_attachements where book_id=" . $book_id;
- //echo $qry . "<br />";
- @mysql_query ('set character set utf8 ');
- $res_att=mysql_query($qryattach);
- $num_row_att=mysql_num_rows($res_att);
- $message.= "attachements : " . $num_row_att . "<br />";
- if($num_row_att > 0)
- {
- for($j=0;$j<$num_row_att;$j++)
- {
- $row_att=mysql_fetch_array($res_att);
- if($row_att['entry_id']!='0')
- $message.= "<a href=\"./attachments/files/" . $rowmail['id'] . "_" . $row_att['file_name'] . "\" target=\"_blanc\">" . $row_att['file_name'] . "</a><br />";
- else
- $message.= "<a href=\"./attachments/nomail_files/" . $row_att['file_name'] . "\" target=\"_blanc\">" . $row_att['file_name'] . "</a>(no mail)<br />";
- }
-
- }
-
-
-
- $message.= "</div>";
- }
- }
- else
- {
- $qryattach=" select * from nomail_attachements where book_id=" . $book_id;
- //echo $qry . "<br />";
- @mysql_query ('set character set utf8 ');
- $res_att=mysql_query($qryattach);
- $num_row_att=mysql_num_rows($res_att);
- $message.="<div class=\"centcolumnpad\" >";
- $message.= "attachements : " . $num_row_att . "<br />";
- if($num_row_att > 0)
- {
-
-
- for($j=0;$j<$num_row_att;$j++)
- {
- $message."<div class=\"break\">";
- $row_att=mysql_fetch_array($res_att);
- $message.= "<a href=\"./attachments/nomail_files/" . $row_att['file_name'] . "\" target=\"_blanc\">" . $row_att['file_name'] . "</a>(no mail)<br />";
- $message."</div>";
- }
- }
- $message."</div>";
- }
-
-
-
- $message.="<div class=\"break\">";
- if($readonly_flag){
- $message.="<input type=\"button\" name=\"return\" id=\"btnrtn\" class=\" ui-corner-all ui-state-hover w120\" value=\"Επιστροφή\" />
- </div>";
- }
- else {
- // αλλαγή για να ξεχρεώνουν όλοι οι χρήστες Βασίλης το = στο >1 μπήκε
- //if(isset($_SESSION['usrlvl']) && $_SESSION['usrlvl'] > 1)
- if(isset($_SESSION['usrlvl']) && $_SESSION['usrlvl'] >= 1)
- // OLD SCRIPT : $message.="<input type=\"button\" name=\"accept\" id=\"accept_id\" class=\" ui-corner-all ui-state-hover w120\" value=\"Αποδοχή\" />";
- $message.="<input type=\"button\" name=\"accept\" onclick=\"accept_button_click ($import_id);\" class=\" ui-corner-all ui-state-hover w120\" value=\"Αποδοχή\" />";
-
- if($book_id>0 && !$from_import)
- //$message.="<a id=\"addup\" href=\"#\">add file</a>";
- $message.="<input type=\"button\" name=\"add_up\" id=\"addup\" class=\" ui-corner-all ui-state-hover w150\" value=\"Προσθήκη-Διαγραφή Αρχείου\" />";
- else
- $message.=" ";
-
- $message.="<input type=\"button\" name=\"return\" id=\"btnrtn\" class=\" ui-corner-all ui-state-hover w120\" value=\"Επιστροφή\" />
- </div>";
- }
-
- $message.="<p>" . $error_mess . "</p>";
-
- $message.="</fieldset>";
- if($book_id>0 && !$from_import)
- {
- $message.="<div class=\"break\">
-
- <div id=\"uploads\"><iframe src=\"./upload.php?bid=" . $book_id . "\" style=\"width:500px;height:400px;border:none;\"></iframe>";
- $message.="<p><a id=\"auploadid_" . $book_id . "\" class=\"aupload\" href=\"#\">επιστροφή</a></p>";
- $message.="</div>
- </div>";
- }
- if($tblmsg!='')
- $message.=$tblmsg;
- echo $message ;
- }
- }
- else
- {
- session_destroy();
- header("location: " . APP_URL . "login.php");
- }
-
- ?>