PageRenderTime 75ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/include/imports_task.php

https://bitbucket.org/phpdecode/eprotocol
PHP | 1195 lines | 929 code | 125 blank | 141 comment | 113 complexity | a0833bbb890c6dcda77f87ad62fc25ce MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. session_start();
  3. include("./connect_functions.php");
  4. include("./general_functions.php");
  5. if(isset($_SESSION['status_log']) && $_SESSION['status_log']=='ok')
  6. {
  7. connect_db();
  8. $message='';
  9. $info_msg='';
  10. $qry_depts='';
  11. $error_mess='';
  12. $readonly='';
  13. $readonly_flag=false;
  14. $from_import=false;
  15. $tblmsg='';
  16. if(isset($_POST['check_flag']))
  17. {
  18. $check_flag=intval($_POST['check_flag']);
  19. $cur_page=intval($_POST['cur_page']);
  20. $status=intval($_POST['status']);
  21. $status_val=$status;
  22. if($status==0)
  23. {
  24. $label="εισερχόμενο";
  25. $label_gen="εισερχομένου";
  26. }
  27. else
  28. {
  29. $label="εξερχόμενο";
  30. $label_gen="εξερχομένου";
  31. }
  32. $book_id=intval($_POST['book_id']);
  33. $import_id = isset ($_POST['import_id']) ? intval ($_POST['import_id']) : $book_id;
  34. switch($check_flag)
  35. {
  36. case 0:
  37. if($book_id>0)
  38. {
  39. //echo $book_id;
  40. $io_year=date("Y");
  41. $query="select io_year from book where id=" . $book_id;
  42. @mysql_query ('set character set utf8 ');
  43. $res=mysql_query($query);
  44. if($res)
  45. $io_year=mysql_result($res,0);
  46. $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 . ")";
  47. @mysql_query ('set character set utf8 ');
  48. $res=mysql_query($query);
  49. $row=mysql_fetch_array($res);
  50. if($row['protocol_number']>0)
  51. {
  52. $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 . ")";
  53. @mysql_query ('set character set utf8 ');
  54. $res=mysql_query($query);
  55. $num_res=mysql_num_rows($res);
  56. if($num_res > 0)
  57. {
  58. $row=mysql_fetch_array($res);
  59. $pn= $row['pn'];
  60. $ada = $row['ada'];
  61. $io_date=mysql2screen("/",$row['io_date']);
  62. $io_year=$row['io_year'];
  63. $tbl_date=explode("-", $io_date);
  64. $i_place=$row['i_place'];
  65. $io_folder=$row['io_folder'];
  66. $fakelos = $row['fakelos'];
  67. $proter = $row['proter'];
  68. $io_auth=$row['io_auth'];
  69. $i_num=$row['i_num'];
  70. $io_auth_date=mysql2screen("/",$row['io_auth_date']);
  71. $summary=$row['summary'];
  72. $announce=$row['announce'];
  73. $rem = $row['rem'];
  74. $mail_id=$row['mail_id'];
  75. $check_flag=2;
  76. $info_msg="To Εξερχόμενο : " . $row['pn'] . "/" . mysql2screen("-",$row['io_date']) . " υπάρχει!";
  77. //$readonly=" readonly=\"readonly\" ";
  78. //$readonly_flag=true;
  79. $book_id=$row['id'];
  80. $status_val=1;
  81. }
  82. }
  83. else
  84. {
  85. if ($import_id > 0)
  86. {
  87. $query="select * from book where status=1 and import_id=" . $import_id;
  88. @mysql_query ('set character set utf8 ');
  89. $res=mysql_query($query);
  90. $num_res=mysql_num_rows($res);
  91. }
  92. else $num_res = 0;
  93. if($num_res > 0)
  94. {
  95. $row=mysql_fetch_array($res);
  96. $pn = $row['pn'];
  97. $ada = $row['ada'];
  98. $io_date=mysql2screen("/",$row['io_date']);
  99. $io_year=$row['io_year'];
  100. $tbl_date=explode("-", $io_date);
  101. $i_place=$row['i_place'];
  102. $io_folder=$row['io_folder'];
  103. $fakelos = $row['fakelos'];
  104. $proter = $row['proter'];
  105. $io_auth=$row['io_auth'];
  106. $i_num=$row['i_num'];
  107. $io_auth_date=mysql2screen("/",$row['io_auth_date']);
  108. $summary=$row['summary'];
  109. $announce=$row['announce'];
  110. $rem = $row['rem']; // add
  111. $mail_id=$row['mail_id'];
  112. $check_flag=2;
  113. $info_msg="To Εξερχόμενο : " . $row['pn'] . "/" . mysql2screen("-",$row['io_date']) . " υπάρχει!";
  114. //$readonly=" readonly=\"readonly\" ";
  115. //$readonly_flag=true;
  116. $status_val=1;
  117. $book_id = $row['id'];
  118. }
  119. else
  120. {
  121. $pn_io_year=0;
  122. $query="select pn, io_year, io_date from book where status=0 and id=" . $book_id;
  123. @mysql_query ('set character set utf8 ');
  124. $res=mysql_query($query);
  125. $num_res=mysql_num_rows($res);
  126. if($num_res > 0)
  127. {
  128. $row=mysql_fetch_array($res);
  129. $pn=$row['pn'];
  130. $ada = $row['ada'];
  131. $pn_io_year=$row['io_year'];
  132. $io_date=date("d/n/Y");
  133. $io_year=date("Y");
  134. $i_num = $row['pn'];
  135. $ada = '';
  136. $io_auth_date = mysql2screen("/",$row['io_date']);
  137. //
  138. $i_place='';
  139. $io_folder='';
  140. $fakelos = '';
  141. $io_auth='';
  142. $proter=0;
  143. $summary='';
  144. $announce='';
  145. $rem = ''; // add
  146. $mail_id=0;
  147. $check_flag=1;
  148. $info_msg.="Νέο εξερχόμενο";
  149. $from_import=true;
  150. $status_val=1;
  151. $import_id = $book_id;
  152. $book_id=-1;
  153. }
  154. }
  155. }
  156. }
  157. else
  158. {
  159. $pn='';
  160. $ada = '';
  161. $io_date=date("d/n/Y");
  162. $io_year=date("Y");
  163. $i_place='';
  164. $io_folder='';
  165. $fakelos = '';
  166. $proter=0;
  167. $io_auth='';
  168. $i_num='';
  169. $io_auth_date='';
  170. $summary='';
  171. $announce='';
  172. $rem = '';
  173. $mail_id=0;
  174. $check_flag=1;
  175. $info_msg.="Νέο " . $label;
  176. }
  177. //$book_id=0;
  178. break;
  179. case 1:
  180. $i_place='';
  181. $ada = '';
  182. $io_folder='';
  183. $fakelos = '';
  184. $proter=0;
  185. $io_auth='';
  186. $i_num='';
  187. $io_auth_date='';
  188. $summary='';
  189. $announce='';
  190. $row='';
  191. $mail_id=0;
  192. $ins_qry_tbl=array();
  193. if($book_id==0)
  194. {
  195. // allagh vassilis
  196. $query="select max(pn) as protocol_number from book where io_year=" . date("Y")." and import_id=0";
  197. @mysql_query ('set character set utf8 ');
  198. $res=mysql_query($query);
  199. $row=mysql_fetch_array($res);
  200. $pn=++$row['protocol_number'];
  201. $status_val=$status;
  202. }
  203. else
  204. {
  205. $status_val=1;
  206. $label="εξερχόμενο";
  207. $label_gen="εξερχομένου";
  208. if(isset($_POST['pn']) && intval($_POST['pn']) >0)
  209. $pn=intval($_POST['pn']);
  210. else
  211. {
  212. //$pn="null";
  213. $query="select max(pn) as protocol_number from book where io_year=" . date("Y");
  214. @mysql_query ('set character set utf8 ');
  215. $res=mysql_query($query);
  216. $row=mysql_fetch_array($res);
  217. $pn=++$row['protocol_number'];
  218. }
  219. }
  220. array_push($ins_qry_tbl, "pn=" . $pn);
  221. $io_date=date("Y-m-d");
  222. array_push($ins_qry_tbl, "io_date='" . $io_date . "'");
  223. $io_year=date("Y");
  224. array_push($ins_qry_tbl, "io_year=" . $io_year);
  225. if(isset($_POST['i_num']) && trim($_POST['i_num'])!='')
  226. {
  227. $i_num=trim($_POST['i_num']);
  228. array_push($ins_qry_tbl, "i_num='". $i_num . "'");
  229. }
  230. else
  231. array_push($ins_qry_tbl, "i_num=null");
  232. if(isset($_POST['ada']) && trim($_POST['ada'])!='')
  233. {
  234. $ada=trim($_POST['ada']);
  235. array_push($ins_qry_tbl, "ada='" . $ada . "'");
  236. }
  237. else
  238. array_push($ins_qry_tbl, "ada=null");
  239. if(isset($_POST['i_place']) && trim($_POST['i_place'])!='')
  240. {
  241. $i_place=trim($_POST['i_place']);
  242. array_push($ins_qry_tbl, "i_place='" . $i_place . "'");
  243. }
  244. else
  245. array_push($ins_qry_tbl, "i_place=null");
  246. if(isset($_POST['io_folder']) && trim($_POST['io_folder'])!='')
  247. {
  248. $io_folder=trim($_POST['io_folder']);
  249. array_push($ins_qry_tbl, "io_folder='" . $io_folder . "'");
  250. }
  251. else
  252. array_push($ins_qry_tbl, "io_folder=null");
  253. if(isset($_POST['fakelos']) && trim($_POST['fakelos'])!='')
  254. {
  255. $fakelos=trim($_POST['fakelos']);
  256. array_push($ins_qry_tbl, "fakelos='" . $fakelos . "'");
  257. }
  258. else
  259. array_push($ins_qry_tbl, "fakelos=null");
  260. if(isset($_POST['io_auth']) && trim($_POST['io_auth'])!='')
  261. {
  262. $io_auth=trim($_POST['io_auth']);
  263. array_push($ins_qry_tbl, "io_auth='" . $io_auth . "'");
  264. }
  265. else
  266. array_push($ins_qry_tbl, "io_auth=null");
  267. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  268. if(isset($_POST['io_auth_date']) && trim($_POST['io_auth_date'])!='')
  269. {
  270. $io_auth_date=screen2mysql("/", $_POST['io_auth_date']);
  271. if($io_auth_date!='')
  272. {
  273. array_push($ins_qry_tbl,"io_auth_date='" . $io_auth_date . "'");
  274. $io_auth_date=mysql2screen("/",$io_auth_date);
  275. }
  276. else
  277. array_push($ins_qry_tbl,"io_auth_date=null");
  278. }
  279. else
  280. {
  281. array_push($ins_qry_tbl,"io_auth_date=null");
  282. $io_auth_date='';
  283. }
  284. if(isset($_POST['summary']) && trim($_POST['summary'])!='')
  285. {
  286. $quotes=array("'","\"");
  287. //$summary=str_replace($quotes,"", trim($_POST['summary']));
  288. $summary = mysql_real_escape_string($_POST['summary']);
  289. array_push($ins_qry_tbl,"summary='" . $summary . "'");
  290. }
  291. else
  292. {
  293. $summary='';
  294. }
  295. if(isset($_POST['announce']) && trim($_POST['announce'])!='')
  296. {
  297. $quotes=array("'","\"");
  298. $announce=str_replace($quotes,"", trim($_POST['announce']));
  299. array_push($ins_qry_tbl,"announce='" . $announce . "'");
  300. }
  301. else
  302. {
  303. $announce='';
  304. }
  305. if(isset($_POST['proter']) && trim($_POST['proter'])!=0)
  306. {
  307. $proter=trim($_POST['proter']);
  308. array_push($ins_qry_tbl, "proter='" . $proter . "'");
  309. }
  310. else
  311. array_push($ins_qry_tbl, "proter=0");
  312. if(isset($_POST['rem']) && trim($_POST['rem'])!='')
  313. {
  314. $quotes=array("'","\"");
  315. $rem=str_replace($quotes,"", trim($_POST['rem']));
  316. array_push($ins_qry_tbl,"rem='" . $rem . "'");
  317. }
  318. else
  319. {
  320. $rem='';
  321. }
  322. array_push($ins_qry_tbl,"status=" . $status_val);
  323. array_push($ins_qry_tbl,"mail_id=0");
  324. if ($import_id > 0)
  325. {
  326. array_push ($ins_qry_tbl, "import_id=" . $import_id);
  327. }
  328. //$book_id=0;
  329. $query="insert into book set " . implode(",", $ins_qry_tbl);
  330. @mysql_query ('set character set utf8 ');
  331. @mysql_query($query);
  332. if(mysql_affected_rows()==1)
  333. {
  334. $book_id=mysql_insert_id();
  335. print_r(array_values($ins_qry_tbl));echo "<br>";
  336. $info_msg="Η εγγραφή του " . $label_gen . " " . $pn . "/" . $io_date . " έγινε με επιτυχία";
  337. $check_flag=2;
  338. //$myauth = str_replace("'","",substr($ins_qry_tbl[8],strpos($ins_qry_tbl[8],'=')+2,strlen($ins_qry_tbl[8])));
  339. //if(!is_numeric($myauth)){
  340. // echo $myauth;echo "<br>";
  341. // $qauth = "insert into apopros set io_auth='".$myauth."', syntomografia='".$myauth."'";
  342. // @mysql_query ('set character set utf8 ');
  343. //@mysql_query($qauth);
  344. //$qauth1 = "update book set io_auth=(select id from apopros where io_auth='".$myauth."') where id=". $book_id;
  345. // @mysql_query ('set character set utf8 ');
  346. // @mysql_query($qauth1);
  347. // }
  348. //$myplace = str_replace("'","",substr($ins_qry_tbl[5],strpos($ins_qry_tbl[5],'=')+2,strlen($ins_qry_tbl[5])));
  349. //print_r(array_values($ins_qry_tbl));echo "<br>";
  350. //if(!is_numeric($myplace)){
  351. //echo $myplace;echo "<br>";
  352. // $qplace = "insert into place set i_place='".$myplace."'";
  353. // @mysql_query ('set character set utf8 ');
  354. // @mysql_query($qplace);
  355. // $qplace1 = "update book set i_place=(select id from place where i_place='".$myplace."') where id=" . $book_id;
  356. // @mysql_query ('set character set utf8 ');
  357. // @mysql_query($qplace1);
  358. //echo $qplace1;
  359. //}
  360. if(isset($_POST['department']))
  361. {
  362. if(count($_POST['department']) > 0)
  363. {
  364. //echo "lala1";
  365. $ins_qry_tbl=array();
  366. $departments=array();
  367. $qry_depts="insert into bookdep (book_id,department_id, ch_date) values";
  368. $departments=$_POST['department'];
  369. for($i=0;$i<count($departments);$i++)
  370. {
  371. array_push($ins_qry_tbl,"(" . $book_id . ", " . $departments[$i] . ", '" . date("Y-m-d H:i:s") . "')");
  372. }
  373. $qry_depts.=implode("," , $ins_qry_tbl);
  374. @mysql_query ('set character set utf8 ');
  375. @mysql_query($qry_depts);
  376. }
  377. }
  378. else{
  379. //taytarithmos
  380. //echo "____lala____".date();
  381. if(KODIKOS_DDE=="888"){
  382. $querytayt = "insert into bookdep (book_id,department_id,ch_date)
  383. select ".$book_id.", department_id,'". date("Y-m-d H:i:s") . "' from bookdep where book_id="
  384. . " (select id from book where status=0 and pn=".$pn." and io_year=" . date("Y").")";
  385. //echo $querytayt;
  386. @mysql_query ('set character set utf8 ');
  387. @mysql_query($querytayt);
  388. }
  389. //taytarithmos
  390. }
  391. //-------------------------------------------------------------------------------------------------------
  392. }
  393. else
  394. {
  395. $info_msg=mysql_error() . " --- Δεν έγινε εισαγωγή εγγραφής";
  396. //$message.=$query;
  397. }
  398. break;
  399. case 2:
  400. $i_place='';
  401. $ada = '';
  402. $io_year='';
  403. $io_auth='';
  404. $i_num='';
  405. $io_auth_date='';
  406. $announce='';
  407. $summary='';
  408. $rem = '';
  409. $io_folder='';
  410. $fakelos='';
  411. $proter=0;
  412. $mail_id=0;
  413. $ins_qry_tbl=array();
  414. $pn=intval($_POST['pn']);
  415. $io_date=$_POST['io_date'];
  416. $io_year=intval($_POST['io_year']);
  417. //$io_date=screen2mysql("/", $io_date);
  418. $mail_id=$_POST['mail_id'];
  419. //array_push($ins_qry_tbl, "io_date='" . $io_date . "'");
  420. if(isset($_POST['i_num']) && trim($_POST['i_num'])!='')
  421. {
  422. $i_num=trim($_POST['i_num']);
  423. array_push($ins_qry_tbl, "i_num='". $i_num . "'");
  424. }
  425. else
  426. array_push($ins_qry_tbl, "i_num=null");
  427. if(isset($_POST['i_place']) && trim($_POST['i_place'])!='')
  428. {
  429. $i_place=trim($_POST['i_place']);
  430. array_push($ins_qry_tbl, "i_place='" . $i_place . "'");
  431. }
  432. else
  433. array_push($ins_qry_tbl, "i_place=null");
  434. if(isset($_POST['ada']) && trim($_POST['ada'])!='')
  435. {
  436. $ada=trim($_POST['ada']);
  437. array_push($ins_qry_tbl, "ada='" . $ada . "'");
  438. }
  439. else
  440. array_push($ins_qry_tbl, "ada=null");
  441. if(isset($_POST['io_folder']) && trim($_POST['io_folder'])!='')
  442. {
  443. $io_folder=trim($_POST['io_folder']);
  444. array_push($ins_qry_tbl, "io_folder='" . $io_folder . "'");
  445. }
  446. else
  447. array_push($ins_qry_tbl, "io_folder=null");
  448. if(isset($_POST['fakelos']) && trim($_POST['fakelos'])!='')
  449. {
  450. $fakelos=trim($_POST['fakelos']);
  451. //echo $fakelos;
  452. if(!is_numeric($fakelos))
  453. {
  454. $fakelos = substr($fakelos,0,strpos($fakelos,' '));
  455. $q1 = "select id from thematologio where fakelos like '%".$fakelos."%'";
  456. @mysql_query ('set character set utf8 ');
  457. $res1=mysql_query($q1);
  458. $num_res1=mysql_num_rows($res1);
  459. if($num_res1 > 0)
  460. {
  461. $row1=mysql_fetch_array($res1);
  462. $fakelos = $row1['id'];
  463. }
  464. //echo $fakelos;
  465. }
  466. array_push($ins_qry_tbl, "fakelos='" . $fakelos . "'");
  467. }
  468. else
  469. array_push($ins_qry_tbl, "fakelos=null");
  470. if(isset($_POST['io_auth']) && trim($_POST['io_auth'])!='')
  471. {
  472. $io_auth=trim($_POST['io_auth']);
  473. if(!is_numeric($io_auth))
  474. {
  475. $q1 = "select id from apopros where onomasia like '%".$io_auth."%' or syntomografia like '%".$io_auth."%'";
  476. @mysql_query ('set character set utf8 ');
  477. $res1=mysql_query($q1);
  478. $num_res1=mysql_num_rows($res1);
  479. if($num_res1 > 0)
  480. {
  481. $row1=mysql_fetch_array($res1);
  482. $io_auth = $row1['id'];
  483. }
  484. //echo $io_auth;
  485. }
  486. array_push($ins_qry_tbl, "io_auth='" . $io_auth . "'");
  487. }
  488. else
  489. array_push($ins_qry_tbl, "io_auth=null");
  490. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  491. if(isset($_POST['io_auth_date']) && trim($_POST['io_auth_date'])!='')
  492. {
  493. $io_auth_date=screen2mysql("/", $_POST['io_auth_date']);
  494. if($io_auth_date!='')
  495. {
  496. array_push($ins_qry_tbl,"io_auth_date='" . $io_auth_date . "'");
  497. $io_auth_date=mysql2screen("/",$io_auth_date);
  498. }
  499. else
  500. array_push($ins_qry_tbl,"io_auth_date=null");
  501. }
  502. else
  503. {
  504. array_push($ins_qry_tbl,"io_auth_date=null");
  505. $io_auth_date='';
  506. }
  507. if(isset($_POST['summary']) && trim($_POST['summary'])!='')
  508. {
  509. $quotes=array("'","\"");
  510. //$summary=str_replace($quotes,"", trim($_POST['summary']));
  511. $summary = mysql_real_escape_string($_POST['summary']);
  512. array_push($ins_qry_tbl,"summary='" . $summary . "'");
  513. }
  514. else
  515. {
  516. $summary='';
  517. }
  518. if(isset($_POST['announce']) && trim($_POST['announce'])!='')
  519. {
  520. $quotes=array("'","\"");
  521. $announce=str_replace($quotes,"", trim($_POST['announce']));
  522. array_push($ins_qry_tbl,"announce='" . $announce . "'");
  523. }
  524. else
  525. {
  526. $announce='';
  527. }
  528. if(isset($_POST['rem']) && trim($_POST['rem'])!='')
  529. {
  530. $quotes=array("'","\"");
  531. $rem=str_replace($quotes,"", trim($_POST['rem']));
  532. array_push($ins_qry_tbl,"rem='" . $rem . "'");
  533. }
  534. else
  535. {
  536. $rem='';
  537. }
  538. if(isset($_POST['proter']) && trim($_POST['proter'])!=0)
  539. {
  540. $proter=trim($_POST['proter']);
  541. if(!is_numeric($proter))
  542. {
  543. $q1 = "select id from proteraiothta where perigrafi like '%".$proter."%'";
  544. @mysql_query ('set character set utf8 ');
  545. $res1=mysql_query($q1);
  546. $num_res1=mysql_num_rows($res1);
  547. if($num_res1 > 0)
  548. {
  549. $row1=mysql_fetch_array($res1);
  550. $proter = $row1['id'];
  551. }
  552. //echo $io_auth;
  553. }
  554. array_push($ins_qry_tbl, "proter='" . $proter . "'");
  555. }
  556. else
  557. array_push($ins_qry_tbl, "proter=0");
  558. $query="update book set " . implode(",", $ins_qry_tbl) . " where id=" . $book_id;
  559. //$myplace = str_replace("'","",substr($ins_qry_tbl[1],strpos($ins_qry_tbl[1],'=')+2,strlen($ins_qry_tbl[1])));
  560. // print_r(array_values($ins_qry_tbl));echo "<br>";
  561. //$qp1 = "select * from place where i_place='".$myplace."'";
  562. //@mysql_query ('set character set utf8 ');
  563. //$r1=mysql_query($qp1);
  564. //if(!is_numeric($myplace)){
  565. // //echo $myplace; echo "<br>"; echo mysql_num_rows($r1); echo "<br>";
  566. // if(mysql_num_rows($r1)==0){
  567. // $qplace = "insert into place set i_place='".$myplace."'";
  568. // @mysql_query ('set character set utf8 ');
  569. // @mysql_query($qplace);
  570. //}
  571. //echo $qplace1;
  572. //}
  573. //$myauth = str_replace("'","",substr($ins_qry_tbl[5],strpos($ins_qry_tbl[5],'=')+2,strlen($ins_qry_tbl[5])));
  574. //$qa1 = "select * from apopros where io_auth='".$myauth."'";
  575. //@mysql_query ('set character set utf8 ');
  576. // $r2=mysql_query($qa1);
  577. //if(!is_numeric($myauth)){
  578. // echo $myauth;echo "<br>";
  579. // if(mysql_num_rows($r2)==0){
  580. // $qauth = "insert into apopros set io_auth='".$myauth."', syntomografia='".$myauth."'";
  581. // @mysql_query ('set character set utf8 ');
  582. // @mysql_query($qauth);
  583. //}
  584. //echo $qauth1;
  585. //}
  586. @mysql_query ('set character set utf8 ');
  587. @mysql_query($query);
  588. if(mysql_affected_rows()==1)
  589. {
  590. // $qplace1 = "update book set i_place=(select id from place where i_place='".$myplace."') where id=" . $book_id;
  591. //@mysql_query ('set character set utf8 ');
  592. //@mysql_query($qplace1);
  593. //echo $qplace1;
  594. //$qauth1 = "update book set io_auth=(select id from apopros where io_auth='".$myauth."') where id=". $book_id;
  595. // @mysql_query ('set character set utf8 ');
  596. // @mysql_query($qauth1);
  597. $info_msg="Το " . $label . " " . $pn . "/" . $io_date . " ενημερώθηκε με επιτυχία";
  598. $check_flag=2;
  599. }
  600. else if(mysql_errno()!=0)
  601. {
  602. $info_msg=mysql_error(); " --- Δεν έγινε ενημέρωση εγγραφής";
  603. $check_flag=2;
  604. }
  605. else
  606. {
  607. $info_msg="Δέν έγινε καμία μεταβολή";
  608. $check_flag=2;
  609. }
  610. if(isset($_POST['department']))
  611. {
  612. if(count($_POST['department']) > 0)
  613. {
  614. //echo "lala2";
  615. $ins_qry_tbl=array();
  616. $departments=array();
  617. $qry_depts="insert into bookdep (book_id,department_id, ch_date) values";
  618. $departments=$_POST['department'];
  619. $qry_depts2="delete from bookdep where book_id=" . $book_id . " and department_id not in (" . implode(",",$departments) . ")";
  620. @mysql_query ('set character set utf8 ');
  621. @mysql_query($qry_depts2);
  622. if(mysql_affected_rows()>0)
  623. $info_msg="Το " . $label . " " . $pn . "/" . $io_date . " ενημερώθηκε με επιτυχία";
  624. //$qry_depts='';
  625. for($i=0;$i<count($departments);$i++)
  626. {
  627. array_push($ins_qry_tbl,"(" . $book_id . ", " . $departments[$i] . ", '" . date("Y-m-d H:i:s") . "')");
  628. }
  629. $qry_depts.=implode("," , $ins_qry_tbl) . " on duplicate key update ch_date=ch_date";
  630. @mysql_query ('set character set utf8 ');
  631. @mysql_query($qry_depts);
  632. if(mysql_affected_rows()>0)
  633. $info_msg="Το " . $label . " " . $pn . "/" . $io_date . " ενημερώθηκε με επιτυχία";
  634. }
  635. }
  636. else
  637. {
  638. //echo "lala3";
  639. $qry_depts="delete from bookdep where book_id=" . $book_id;
  640. @mysql_query ('set character set utf8 ');
  641. @mysql_query($qry_depts);
  642. if(mysql_affected_rows()>0)
  643. $info_msg="Το " . $label . " " . $pn . "/" . $io_date . " ενημερώθηκε με επιτυχία";
  644. }
  645. break;
  646. case 3:
  647. break;
  648. case 5:
  649. $query = "select * from book where id=" . $book_id;
  650. @mysql_query ('set character set utf8 ');
  651. $res=mysql_query($query);
  652. $num_res=mysql_num_rows($res);
  653. if($num_res > 0)
  654. {
  655. $row=mysql_fetch_array($res);
  656. $pn= $row['pn'];
  657. $ada= $row['ada'];
  658. $io_date=$row['io_date'];
  659. $io_year=$row['io_year'];
  660. $tbl_date=explode("-", $io_date);
  661. $io_date=mysql2screen("/", $io_date);
  662. $i_place=$row['i_place'];
  663. $io_folder=$row['io_folder'];
  664. $fakelos=$row['fakelos'];
  665. $proter=$row['proter'];
  666. $io_auth=$row['io_auth'];
  667. $i_num=$row['i_num'];
  668. $io_auth_date=mysql2screen("/",$row['io_auth_date']);
  669. $summary=$row['summary'];
  670. $announce=$row['announce'];
  671. $mail_id=$row['mail_id'];
  672. $rem = $row['rem'];
  673. $check_flag=2;
  674. if($status==0)
  675. $info_msg="Εισερχόμενο : " .$row['pn'] . "/" . $tbl_date[2] . "-" . $tbl_date[1] ."-" . $tbl_date[0];
  676. else
  677. $info_msg="Εξερχόμενο : " .$row['pn'] . "/" . $tbl_date[2] . "-" . $tbl_date[1] ."-" . $tbl_date[0];
  678. }
  679. break;
  680. }
  681. $message.="<fieldset id=\"fieldset_id\">";
  682. $message.="<div class=\"msgbar\">" . $info_msg . "</div>";
  683. //$message.="<p>" . $query . "<br />" . $qry_depts . "</p>";
  684. $message.="<input type=\"hidden\" name=\"check_flag\" id=\"chfl_id\" value=\"" . $check_flag . "\" />";
  685. $message.="<input type=\"hidden\" name=\"book_id\" id=\"book_id_id\" value=\"" . $book_id . "\" />";
  686. $message.="<input type=\"hidden\" name=\"io_year\" id=\"io_year_id\" value=\"" . $io_year . "\" />";
  687. $message.="<input type=\"hidden\" name=\"mail_id\" id=\"mail_id_id\" value=\"" . $mail_id . "\" />";
  688. $message.= "<input type=\"hidden\" name=\"status\" id=\"status_id\" value=\"" . $status . "\" />";
  689. $message.= "<input type=\"hidden\" name=\"cur_page\" id=\"cur_page_id\" value=\"" . $cur_page . "\" />";
  690. if($status_val==0) { //import
  691. $message.="<div style=\"position:relative;display:inline-block;float:left;clear:none;\">";
  692. $message.="<div class=\"break\">
  693. <label for=\"pn\">Αρ.Πρωτ.</label>
  694. <input type=\"text\" name=\"pn\" id=\"pn_id\" readonly=\"readonly\" value=\"" . $pn . "\" class=\"ui-widget ui-corner-all\" />
  695. <label for=\"io_date\" class=\"w50\">ημ/νία</label>
  696. <input type=\"text\" name=\"io_date\" id=\"io_date_id\" readonly=\"readonly\" value=\"" . $io_date . "\" class=\"ui-widget ui-corner-all w80\" />
  697. </div>";
  698. $pthem = "select * from place where convert(id,char)='".$i_place."'";
  699. @mysql_query ('set character set utf8 ');
  700. $res_place = mysql_query($pthem);
  701. $num_res_place = mysql_num_rows($res_place);
  702. $place_i_place = $i_place;
  703. //echo $place_i_place;
  704. if($num_res_place > 0)
  705. {
  706. $row_place=mysql_fetch_array($res_place);
  707. $place_i_place = $row_place['i_place'];
  708. $message.="<div class=\"break\">
  709. <label for=\"i_place\">Τόπος έκδοσης</label>
  710. <input type=\"text\" name=\"i_place\" id=\"i_place_id\" value=\"" . $place_i_place . "\" class=\"w200 ui-corner-all ui-widget\" onkeyup=\"autocomplet3()\"/>
  711. <ul id=\"i_place_list_id\"></ul></div>";
  712. }
  713. else {
  714. $message.="<div class=\"break\">
  715. <label for=\"io_auth\">Τόπος έκδοσης</label>
  716. <input type=\"text\" name=\"i_place\" id=\"i_place_id\" value=\"" . $place_i_place . "\" class=\"w200 ui-corner-all ui-widget\" onkeyup=\"autocomplet3()\"/>
  717. <ul id=\"i_place_list_id\"></ul></div>";
  718. }
  719. /*$message.="<div class=\"break\">
  720. <label for=\"io_auth\">Αρχή έκδοσης</label>
  721. <input type=\"text\" name=\"io_auth\" id=\"io_auth_id\" " . $readonly . " value=\"" . $io_auth . "\" class=\"w300 ui-corner-all ui-widget\" />
  722. </div>";*/
  723. $athem = "select * from apopros where convert(id,char)='".$io_auth."'";
  724. //echo $athem;
  725. @mysql_query ('set character set utf8 ');
  726. $res_apo = mysql_query($athem);
  727. $num_res_apo = mysql_num_rows($res_apo);
  728. $apo_io_auth = $io_auth;
  729. if($num_res_apo > 0)
  730. {
  731. $row_apo=mysql_fetch_array($res_apo);
  732. $apo_io_auth = $row_apo['io_auth'];
  733. //echo "<br>".$apo_io_auth;
  734. $message.="<div class=\"break\">
  735. <label for=\"io_auth\">Αρχή έκδοσης</label>
  736. <input type=\"text\" name=\"io_auth\" id=\"io_auth_id\" value=\"" . $apo_io_auth . "\" class=\"w200 ui-corner-all ui-widget\" onkeyup=\"autocomplet2()\"/>
  737. <ul id=\"io_auth_list_id\"></ul></div>";
  738. //$message .="</div>";
  739. //echo $message;
  740. //$message .="</select></div>";
  741. }
  742. else {
  743. $message.="<div class=\"break\">
  744. <label for=\"io_auth\">Αρχή έκδοσης</label>
  745. <input type=\"text\" name=\"io_auth\" id=\"io_auth_id\" value=\"" . $apo_io_auth . "\" class=\"w200 ui-corner-all ui-widget\" onkeyup=\"autocomplet2()\"/>
  746. <ul id=\"io_auth_list_id\"></ul></div>";
  747. }
  748. $message.=" <div class=\"break\">
  749. <label for=\"i_num\">Αρ. Εισερχ.</label>
  750. <input type=\"text\" name=\"i_num\" id=\"i_num_id\" " . $readonly . " value=\"" . $i_num . "\" class=\" ui-corner-all\" />
  751. <label for=\"io_auth_date\" class=\"w50\">ημ/νία</label>
  752. <input type=\"text\" name=\"io_auth_date\" id=\"io_auth_date_id\" value=\"" . $io_auth_date . "\" class=\"w80 ui-corner-all ui-widget\" />
  753. </div>";
  754. $message.="<div class=\"break\">
  755. <label for=\"ada\">ΑΔΑ</label>
  756. <input type=\"text\" name=\"ada\" id=\"ada_id\" " . $readonly . " value=\"" . $ada . "\" class=\"w200 ui-corner-all ui-widget\" />
  757. </div>";
  758. $message.="<div class=\"break\">
  759. <label for=\"summary\">Περίληψη Εισερχ</label>
  760. <textarea name=\"summary\" id=\"summary_id\" " . $readonly . " class=\" ui-corner-all ui-widget\">" . $summary . "</textarea>
  761. </div>";
  762. $message.="<div class=\"break\">
  763. <label for=\"announce\">Κοινοποίηση</label>
  764. <textarea name=\"announce\" id=\"summary_id\" " . $readonly . " class=\" ui-corner-all ui-widget\">" . $announce . "</textarea>
  765. </div>";
  766. $message .= "<div class=\"break\">
  767. <label for=\"rem\">Παρατηρήσεις</label>
  768. <textarea name=\"rem\" id=\"rem_id\" " . $readonly . " class=\" ui-corner-all ui-widget\">" . $rem . "</textarea>
  769. </div>";
  770. //proteraiothta
  771. $pthem = "select * from proteraiothta where id=".$proter;
  772. @mysql_query ('set character set utf8 ');
  773. $res_proter = mysql_query($pthem);
  774. $num_res_proter = mysql_num_rows($res_proter);
  775. if($num_res_proter > 0)
  776. {
  777. $row_proter=mysql_fetch_array($res_proter);
  778. $proter = $row_proter['id'];
  779. $message.="<div class=\"break\"><label for=\"fakelos\">Προτεραιότητα</label>";
  780. $message .= selectproter("proter",$proter);
  781. $message .="</div>";
  782. //$message .="</select></div>";
  783. // prosuhkh pedioy elava gnvsh gia PDE thess by vassilis
  784. //ervthma prin
  785. $qprin = "select elavagnosi from bookdep where book_id=$book_id and department_id=".$_SESSION['dep_id'];
  786. //echo $qprin;
  787. @mysql_query ('set character set utf8 ');
  788. $res_prin = mysql_query($qprin);
  789. $num_res_prin = mysql_num_rows($res_prin);
  790. if($num_res_prin > 0)
  791. {
  792. $row_prin=mysql_fetch_array($res_prin);
  793. $elavagnosi = $row_prin['elavagnosi'];
  794. }
  795. $message.="<div class=\"break\">&nbsp;</div>";
  796. if($elavagnosi==1){
  797. $message .="<div class=\"break\">
  798. <label for=\"elavagnosi\">Έλαβα Γνώση</label>
  799. <input type=\"checkbox\" name=\"read\" checked value=\"1\"></div>";
  800. }
  801. else {
  802. $message .="<div class=\"break\">
  803. <label for=\"elavagnosi\">Έλαβα Γνώση</label>
  804. <input type=\"checkbox\" name=\"read\" value=\"0\"></div>";
  805. }
  806. //ervthma meta
  807. //onChange="this.form.submit()
  808. //telos allaghs elava gnosh
  809. }
  810. $message.="<div class=\"break\">&nbsp;</div>";
  811. $qthem = "select * from thematologio where id=".$fakelos;
  812. @mysql_query ('set character set utf8 ');
  813. $res_them = mysql_query($qthem);
  814. $num_res_them = mysql_num_rows($res_them);
  815. if($num_res_them > 0)
  816. {
  817. $row_them=mysql_fetch_array($res_them);
  818. $fakelos_perigrafi = $row_them['fakelos']." ".$row_them['perigrafi'];
  819. $message.="<div class=\"break\">
  820. <label for=\"fakelos\">Φάκελος Αρχείου</label>
  821. <input type=\"text\" name=\"fakelos\" id=\"fakelos_id\" value=\"" . $fakelos_perigrafi . "\" class=\"w200 ui-corner-all ui-widget\" onkeyup=\"autocomplet()\"/>
  822. <ul id=\"fakelos_list_id\"></ul></div>";
  823. $message .="</div>";
  824. //$message .="</select></div>";
  825. }
  826. else {
  827. $fakelos_perigrafi = "Φάκελος Αρχείου";
  828. $message.="<div class=\"break\">
  829. <label for=\"fakelos\">Φάκελος Αρχείου</label>
  830. <input type=\"text\" name=\"fakelos\" id=\"fakelos_id\" value=\"" . $fakelos_perigrafi . "\" class=\"w200 ui-corner-all ui-widget\" onkeyup=\"autocomplet()\"/>
  831. <ul id=\"fakelos_list_id\"></ul></div>";
  832. $message .="</div>";
  833. }
  834. //
  835. }
  836. else { // outport
  837. $message.="<div style=\"position:relative;display:inline-block;float:left;clear:none;\">";
  838. //$message.=$query;
  839. $message.="<div class=\"break\">
  840. <label for=\"pn\">Αρ.Πρωτ.</label>
  841. <input type=\"text\" name=\"pn\" id=\"pn_id\" readonly=\"readonly\" value=\"" . $pn . "\" class=\"ui-widget ui-corner-all\" />
  842. <label for=\"io_date\" class=\"w50\">ημ/νία</label>
  843. <input type=\"text\" name=\"io_date\" id=\"io_date_id\" readonly=\"readonly\" value=\"" . $io_date . "\" class=\"ui-widget ui-corner-all w80\" />
  844. </div>";
  845. //$message.="<div class=\"break\">
  846. //<label for=\"io_auth\">Αρχή που απευθύνεται</label>
  847. //<input type=\"text\" name=\"io_auth\" id=\"io_auth_id\" " . $readonly . " value=\"" . $io_auth . "\" class=\"w300 ui-corner-all ui-widget\" />
  848. //</div>";
  849. $athem = "select * from apopros where convert(id,char)='".$io_auth."'";
  850. @mysql_query ('set character set utf8 ');
  851. $res_apo = mysql_query($athem);
  852. $num_res_apo = mysql_num_rows($res_apo);
  853. $apo_io_auth = $io_auth;
  854. if($num_res_apo > 0)
  855. {
  856. $row_apo=mysql_fetch_array($res_apo);
  857. $apo_io_auth = $row_apo['io_auth'];
  858. //echo "<br>".$apo_io_auth;
  859. $message.="<div class=\"break\">
  860. <label for=\"io_auth\">Αρχή που απευθύνεται</label>
  861. <input type=\"text\" name=\"io_auth\" id=\"io_auth_id\" value=\"" . $apo_io_auth . "\" class=\"w300 ui-corner-all ui-widget\" onkeyup=\"autocomplet2()\"/>
  862. <ul id=\"io_auth_list_id\"></ul></div>";
  863. //$message .="</div>";
  864. //echo $message;
  865. //$message .="</select></div>";
  866. }
  867. else {
  868. $message.="<div class=\"break\">
  869. <label for=\"io_auth\">Αρχή που απευθύνεται</label>
  870. <input type=\"text\" name=\"io_auth\" id=\"io_auth_id\" value=\"" . $apo_io_auth . "\" class=\"w300 ui-corner-all ui-widget\" onkeyup=\"autocomplet2()\"/>
  871. <ul id=\"io_auth_list_id\"></ul></div>";
  872. }
  873. $message.="<div class=\"break\">
  874. <label for=\"summary\">Περίληψη Εξερχ</label>
  875. <textarea name=\"summary\" id=\"summary_id\" " . $readonly . " class=\" ui-corner-all ui-widget\">" . $summary . "</textarea>
  876. </div>";
  877. $message.="<div class=\"break\">
  878. <label for=\"announce\">Κοινοποίηση</label>
  879. <textarea name=\"announce\" id=\"summary_id\" " . $readonly . " class=\" ui-corner-all ui-widget\">" . $announce . "</textarea>
  880. </div>";
  881. $message .= "<div class=\"break\">
  882. <label for=\"rem\">Παρατηρήσεις</label>
  883. <textarea name=\"rem\" id=\"rem_id\" " . $readonly . " class=\" ui-corner-all ui-widget\">" . $rem . "</textarea>
  884. </div>";
  885. $message.="<div class=\"break\">
  886. <label for=\"ada\">ΑΔΑ</label>
  887. <input type=\"text\" name=\"ada\" id=\"ada_id\" " . $readonly . " value=\"" . $ada . "\" class=\"w200 ui-corner-all ui-widget\" />
  888. </div>";
  889. $message.=" <div class=\"break\">
  890. <label for=\"i_num\">Σχετ. αριθ.</label>
  891. <input type=\"text\" name=\"i_num\" id=\"i_num_id\" " . $readonly . " value=\"" . $i_num . "\" class=\" ui-corner-all\" />
  892. <label for=\"io_auth_date\" >χρονολογ. διεκπ.</label>
  893. <input type=\"text\" name=\"io_auth_date\" id=\"io_auth_date_id\" " . $readonly . " value=\"" . $io_auth_date . "\" class=\"w80 ui-corner-all ui-widget\" />
  894. </div>";
  895. $qthem = "select * from thematologio where id=".$fakelos;
  896. @mysql_query ('set character set utf8 ');
  897. $res_them = mysql_query($qthem);
  898. $num_res_them = mysql_num_rows($res_them);
  899. if($num_res_them > 0)
  900. {
  901. $row_them=mysql_fetch_array($res_them);
  902. $fakelos_perigrafi = $row_them['fakelos']." ".$row_them['perigrafi'];
  903. $message.="<div class=\"break\">
  904. <label for=\"fakelos\">Φάκελος Αρχείου</label>
  905. <input type=\"text\" name=\"fakelos\" id=\"fakelos_id\" value=\"" . $fakelos_perigrafi . "\" class=\"w200 ui-corner-all ui-widget\" onkeyup=\"autocomplet()\"/>
  906. <ul id=\"fakelos_list_id\"></ul></div>";
  907. $message .="</div>";
  908. //$message .="</select></div>";
  909. }
  910. else {
  911. $fakelos_perigrafi = "Φάκελος Αρχείου";
  912. $message.="<div class=\"break\">
  913. <label for=\"fakelos\">Φάκελος Αρχείου</label>
  914. <input type=\"text\" name=\"fakelos\" id=\"fakelos_id\" value=\"" . $fakelos_perigrafi . "\" class=\"w200 ui-corner-all ui-widget\" o…

Large files files are truncated, but you can click here to view the full file