Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.39 KB | None | 0 0
  1. <?
  2. $page_level = 20;
  3. $page_name = "Просмотр списка договоров";
  4. include $_SERVER['DOCUMENT_ROOT']."/include/include.inc";
  5. include $system_path."include/connect.inc";
  6. include $system_path."header.inc";
  7.  
  8. /*
  9. foreach( $HTTP_POST_VARS as $key => $val)
  10. {
  11. echo ("POST ". $key ." => ". $val ."<br>");
  12. }
  13.  
  14. foreach( $HTTP_GET_VARS as $key => $val)
  15. {
  16. echo ("GET ". $key ." => ". $val ."<br>");
  17. }
  18. */
  19.  
  20. $on_page = 20;
  21. $on_line = 8;
  22. $link_pjuridical = array(1=>"Номер договора",2=>"Дата договора",3=>"ФИО",4=>"Группа");
  23. $order_array = array(1=>"payment_agreement",2=>"payment_dateagreement",3=>"surname_nominative, name_nominative, patr_nominative",4=>"studgroups_number");
  24.  
  25.  
  26. // страничка по умолчанию
  27. if (isset($HTTP_GET_VARS['page']))
  28. { $current_page = $HTTP_GET_VARS['page']; }
  29. else { $current_page = 1; }
  30.  
  31. // echo ("current_page " . $current_page . "<br/>");
  32.  
  33. // сортировка по умолчанию: по номеру счета
  34. if (!isset($order) && !isset($desc))
  35. { $order = 1; }
  36.  
  37. $select_count_query = "select card_id
  38. from card, payment, name, surname, patr,
  39. study, studgroups, dep
  40. where card_id = payment_card_id and
  41. name_id = card_name_id and
  42. surname_id = card_surname_id and
  43. patr_id = card_patr_id and
  44. study_id = payment_study_id and
  45. study_studgroups_id = studgroups_id and
  46. dep_id = study_dep_id
  47. ";
  48.  
  49. $payment_select = "select payment_id,
  50. payment_agreement,
  51. payment_dateagreement,
  52. payment_action,
  53. payment_close,
  54. payment_charge,
  55. payment_pay,
  56.  
  57. study_id,
  58. card_id,
  59. name_nominative,
  60. surname_nominative,
  61. patr_nominative,
  62. studgroups_number,
  63. dep_name,
  64. study_kurs
  65.  
  66. from
  67. study
  68. inner join card on card_id = study_card_id
  69. inner join name on name_id = card_name_id
  70. inner join surname on surname_id = card_surname_id
  71. inner join dep on dep_id = study_dep_id
  72. inner join studgroups on study_studgroups_id = studgroups_id
  73. left join payment on study_id = payment_study_id
  74. left join patr on patr_id = card_patr_id
  75. ";
  76.  
  77. if (isset($name_filter) && ($name_filter))
  78. {
  79. $payment_select .= " and name_nominative like '%" . $name_filter . "%' ";
  80. $select_count_query .= "and name_nominative like '%" . $name_filter . "%' ";
  81. }
  82. if (isset($surname_filter) && ($surname_filter))
  83. {
  84. $payment_select .= " and surname_nominative like '%" . $surname_filter . "%' ";
  85. $select_count_query .= "and name_nominative like '%" . $name_filter . "%' ";
  86. }
  87. if (isset($patr_filter) && ($patr_filter))
  88. {
  89. $payment_select .= " and patr_nominative like '%" . $patr . "%' ";
  90. $select_count_query .= "and patr_nominative like '%" . $patr . "%' ";
  91. }
  92. if (isset($group_filter) && ($group_filter))
  93. {
  94. $payment_select .= " and studgroups_number like '%" . $group_filter . "%' ";
  95. $select_count_query .= "and studgroups_number like '%" . $group_filter . "%' ";
  96. }
  97. if (isset($agreement_filter) && ($agreement_filter))
  98. {
  99. $payment_select .= " and payment_agreement like '%" . $agreement_filter . "%' ";
  100. $select_count_query .= "and payment_agreement like '%" . $agreement_filter . "%' ";
  101. }
  102. if (isset($debt_filter) && ($debt_filter == 1))
  103. {
  104. $payment_select .= " and (payment_charge - payment_pay) > 0 ";
  105. $select_count_query .= " and (payment_charge - payment_pay) > 0 ";
  106. }
  107. if (isset($debt_filter) && ($debt_filter == 2))
  108. {
  109. $payment_select .= " and (payment_charge - payment_pay) <= 0 ";
  110. $select_count_query .= " and (payment_charge - payment_pay) <= 0 ";
  111. }
  112.  
  113. if (isset($card_filter) && $card_filter){
  114. $payment_select .= " and card_id = '$card_filter' ";
  115. $select_count_query .= " and card_id = '$card_filter' ";
  116. }
  117. if (isset($study_filter) && $study_filter){
  118. $payment_select .= " and study_id = '$study_filter' ";
  119. $select_count_query .= " and study_id = '$study_filter' ";
  120. }
  121. if (isset($recordbook_filter) and $recordbook_filter){
  122. $payment_select .= " and study_recordbook like '$recordbook_filter%' ";
  123. $select_count_query .= " and study_recordbook like '$recordbook_filter%' ";
  124. }
  125.  
  126. if (isset($action_filter) && ($action_filter == 1))
  127. {
  128. $payment_select .= " and payment_action = 1 ";
  129. $select_count_query .= " and payment_action = 1 ";
  130. }
  131. if (isset($action_filter) && ($action_filter == 2))
  132. {
  133. $payment_select .= " and payment_action = 0 ";
  134. $select_count_query .= " and payment_action = 0 ";
  135. }
  136. if (isset($close_filter) && ($close_filter == 1))
  137. {
  138. $payment_select .= " and payment_close = 0 ";
  139. $select_count_query .= " and payment_close = 0 ";
  140. }
  141. if (isset($close_filter) && ($close_filter == 2))
  142. {
  143. $payment_select .= " and payment_close = 1 ";
  144. $select_count_query .= " and payment_close = 1 ";
  145. }
  146.  
  147. if (isset($dep_filter) && ($dep_filter))
  148. {
  149. $dep = select_dep_array();
  150. $payment_select .= " and dep_acronym like '".$dep[$dep_filter]."' ";
  151. $select_count_query .= " and dep_acronym like '".$dep[$dep_filter]."' ";
  152. }
  153. if (isset($kurs_filter) && ($kurs_filter > 1))
  154. {
  155. $payment_select .= " and study_kurs = ".($kurs_filter - 1)." ";
  156. $select_count_query .= " and study_kurs = ".($kurs_filter - 1)." ";
  157. }
  158.  
  159. // Леша: добавил фильтр по форме обучения и программе обучения
  160.  
  161. if (isset($educform_filter) && ($educform_filter >= 1))
  162. {
  163. $payment_select .= " and study_formeduc_id = ".$educform_filter." ";
  164. $select_count_query .= " and study_formeduc_id = ".$educform_filter." ";
  165. }
  166. if (isset($progr_filter) && ($progr_filter >= 1))
  167. {
  168. $payment_select .= " and study_program_id = ".$progr_filter." ";
  169. $select_count_query .= " and study_program_id = ".$progr_filter." ";
  170. }
  171.  
  172.  
  173. //проверка правильности даты
  174. if(preg_match( "/^\d(\d)?\.\d(\d)?\.\d\d\d\d$/", $date_from_filter))
  175. {
  176. $date_from_mysql = date_user_to_mysql($date_from_filter);
  177. }
  178. else
  179. {
  180. if($date_from_filter)
  181. $error_msg = "Дата введена неправильно.";
  182. }
  183.  
  184. if(preg_match( "/^\d(\d)?\.\d(\d)?\.\d\d\d\d$/", $date_to_filter))
  185. {
  186. $date_to_mysql = date_user_to_mysql($date_to_filter);
  187. }
  188. else
  189. {
  190. if($date_to_filter)
  191. $error_msg = "Дата введена неправильно.";
  192. }
  193.  
  194.  
  195. if ((isset($date_from_mysql) && ($date_from_mysql)) && !(isset($date_to_mysql) && ($date_to_mysql)))
  196. //если указана только дата от
  197. {
  198. $payment_select .= "and payment_date_agreement >= '".$date_from_mysql."' ";
  199. $select_count_query .= "and payment_date_agreement >= '".$date_from_mysql."' ";
  200. }
  201.  
  202. if (!(isset($date_from_mysql) && ($date_from_mysql)) && (isset($date_to_mysql) && ($date_to_mysql)))
  203. //если указана только дата до
  204. {
  205. $payment_select .= "and payment_dateagreement <= '".$date_to_mysql."' ";
  206. $select_count_query .= "and payment_dateagreement <= '".$date_to_mysql."' ";
  207. }
  208.  
  209. if ((isset($date_from_mysql) && ($date_from_mysql)) && (isset($date_to_mysql) && ($date_to_mysql)))
  210. //если указанs даты от и до
  211. {
  212. $payment_select .= "and payment_dateagreement >= '".$date_from_mysql."' and payment_dateagreement <= '".$date_to_mysql."' ";
  213. $select_count_query .= "and payment_dateagreement >= '".$date_from_mysql."' and payment_dateagreement <= '".$date_to_mysql."' ";
  214. }
  215.  
  216. if (isset($order) && ($order))
  217. {
  218. if($order == 3)
  219. //ФИО сортируем по трем полям,
  220. {
  221. if ($desc)
  222. {
  223. $payment_select .= " order by surname_nominative desc, name_nominative desc, patr_nominative desc";
  224. $select_count_query .= " order by surname_nominative desc, name_nominative desc, patr_nominative desc";
  225. }
  226. else
  227. {
  228. $payment_select .= " order by ".$order_array[$order];
  229. $select_count_query .= " order by ".$order_array[$order];
  230. }
  231.  
  232. }
  233. else
  234. {
  235. $payment_select .= " order by ".$order_array[$order];
  236. $select_count_query .= " order by ".$order_array[$order];
  237.  
  238. if ($desc)
  239. {
  240. $payment_select .= " desc ";
  241. $select_count_query .= " desc ";
  242. }
  243. }
  244. }
  245.  
  246. // echo "select_count_query: ".$select_count_query . "<br>";
  247. $result_count = mysql_query ($select_count_query) or die ("Error count query...");
  248. // $count_rows = mysql_fetch_object($result_count);
  249. $all_rec = mysql_num_rows($result_count);
  250.  
  251. // echo "select_orders_query= " . $select_orders_query . "<br>";
  252. // $pjuridical_summ_select .= " limit ". ($current_page-1)*$on_page.",".$on_page.";";
  253.  
  254.  
  255. $payment_select .= " limit ". ($current_page-1)*$on_page.",".$on_page.";";
  256.  
  257. // print_r($payment_select);
  258. // die();
  259.  
  260. $result_payment = mysql_query($payment_select) or die ("Error payment_select... ". $payment_select);
  261.  
  262. while($a = mysql_fetch_array($result_payment))
  263. {
  264. $payment[($current_page-1)*$on_page + $j] = array(
  265. "payment_id" => $a[payment_id],
  266. "study_id" => $a[study_id],
  267. "card_id" => $a[card_id],
  268. "summ" => $a[pjuridical_summ_summ],
  269. "agreement" => $a[payment_agreement],
  270. "dateagreement" => $a[payment_dateagreement],
  271. "name" => $a[name_nominative],
  272. "surname" => $a[surname_nominative],
  273. "patr" => $a[patr_nominative],
  274. "group" => $a[studgroups_number],
  275. "action" => $a[payment_action],
  276. "close" => $a[payment_close],
  277. "debt" => $a[payment_charge] - $a[payment_pay]
  278. );
  279. $j++;
  280. }
  281. $action_array = array(
  282. "0" => "Все",
  283. "1" => "Активные",
  284. "2" => "Неактивные"
  285. );
  286. $close_array = array(
  287. "0" => "Все",
  288. "1" => "Открытые",
  289. "2" => "Закрытые"
  290. );
  291. $debt_array = array(
  292. "0" => "Все",
  293. "1" => "Должники",
  294. "2" => "Без долга"
  295. );
  296. $program_array = array(
  297. "1" => "Первое высшее",
  298. "2" => "Второе высшее"
  299. );
  300.  
  301. $out = "page=".$current_page."&name_filter=".$name_filter."&surname_filter=".$surname_filter.
  302. "&patr_filter=".$patr_filter."&desc=".$desc."&order=".$order."&group_filter=".$group_filter."&agreement_filter=".$agreement_filter.
  303. "&debt_filter=".$debt_filter."&action_filter=".$action_filter."&close_filter=".$close_filter."&dep_filter=".$dep_filter."&kurs_filter=". $kurs_filter.
  304. "&date_from_filter=".$date_from_filter."&date_to_filter=".$date_to_filter."&educform_filter=".$educform_filter."&progr_filter=".$progr_filter.
  305. "&from_payments=1&study_filter=$study_filter&card_filter=$card_filter&recordbook_filter=$recordbook_filter";
  306. // echo $out;
  307. ?>
  308. <span class = header>Просмотр списка договоров</span><hr>
  309. <table align = center class = view width = 96% cellspacing = 0 cellpadding =0 border = 0>
  310. <form method = "get" action = "showallpayment_code.php" name="select">
  311. <input type = 'hidden' name = 'current_page' value = '<? echo $current_page; ?>'>
  312. <tr class = view>
  313. <td class=view> &nbsp <a href = "<? echo($global_path) ?>/payment/showallpayment_code.php">Сброс</a>&nbsp;&nbsp;
  314. &nbsp Всего: <?echo $all_rec ?></td>
  315. </tr>
  316. <tr class = view>
  317. <td class = view>
  318. &nbsp Выбор: &nbsp; Фамилия &nbsp;<input size=12 name='surname_filter' class=input value='<?echo $surname_filter;?>'>
  319. &nbsp;Имя &nbsp;<input size=12 name='name_filter' class=input value='<?echo $name_filter;?>'>
  320. &nbsp;Отчество &nbsp;<input size=12 name='patr_filter' class=input value='<?echo $patr_filter;?>'>
  321. &nbsp;Группа &nbsp;<input name='group_filter' size=6 class=input value='<?echo $group_filter;?>'>
  322. <br>
  323. &nbsp;Факультет&nbsp;
  324. <?select_box(select_dep_array(), "dep_filter", "Факультет", $dep_filter, "");?>
  325. &nbsp;
  326. Курс&nbsp;
  327. <?select_box($kurs_array, "kurs_filter", "Курс", $kurs_filter, "");?>&nbsp;
  328. &nbsp;
  329. Форма обучения&nbsp;
  330. <?select_box($education_form, "educform_filter", "Форма обучения", $educform_filter, "");?>&nbsp;
  331. &nbsp;
  332. Программа&nbsp;
  333. <?select_box($program_array, "progr_filter", "Программа", $progr_filter, "");?>&nbsp;
  334. <br>
  335. &nbsp;
  336. Состояние&nbsp;
  337. <?select_box($action_array, "action_filter", "Состояние", $action_filter, "");?>&nbsp;
  338. <?select_box($close_array, "close_filter", "Состояние", $close_filter, "");?>&nbsp;
  339. Долг&nbsp;
  340. <?select_box($debt_array, "debt_filter", "Долг", $debt_filter, "");?>&nbsp;
  341. <br>
  342. &nbsp;Код карточки &nbsp; <input class="input" type="text" size="7" name = 'card_filter' value="<?echo $card_filter?>">
  343. &nbsp;Код студента &nbsp; <input class="input" type="text" size="7" name = "study_filter" value="<?echo $study_filter?>">
  344. &nbsp;Зачетная книжка &nbsp; <input class="input" type="text" size="12" name= "recordbook_filter" value="<?echo $recordbook_filter?>">
  345.  
  346. <br>
  347. &nbsp;Дата c &nbsp;<input name='date_from_filter' size=6 class=input value='<?echo $date_from_filter;?>'>
  348. &nbsp;по&nbsp;<input name='date_to_filter' size=6 class=input value='<?echo $date_to_filter;?>'>
  349. &nbsp;Номер договора &nbsp;<input name='agreement_filter' size=6 class=input value='<?echo $agreement_filter;?>'>
  350. <br>
  351. </td>
  352. </tr>
  353. <tr class = view>
  354. <td class = view>&nbsp Порядок:
  355. <? select_box1($link_pjuridical, "order", "Поле сортировки", $order) ?>
  356. Обратный:<input type = "checkbox" name = "desc" <? if ($desc) {echo 'Checked';}; ?> >
  357. <input type = "submit" class = "submit" name="Filter" value = "Отбор">
  358. </td>
  359. </tr>
  360. </form>
  361. </table>
  362. <input type=hidden name=order value=<?echo $order;?>>
  363. <span class = go><a href = "/login/user_page.php">Возврат</a></span>
  364.  
  365. <!--
  366. // !!!!! Леша: кнопка печать
  367. -->
  368.  
  369. <span class = go><a href = "print_all_payment_code.php?<?
  370. // $out = urlencode($out);
  371. // $out = urlencode($out);
  372. echo($out);
  373. ?>" target= "_new">Печать</a></span>&nbsp;&nbsp;&nbsp;
  374.  
  375. <?
  376. if(isset($error_msg))
  377. {
  378. echo "<br><b>".$error_msg."</b>";
  379. die();
  380. }
  381. if(mysql_num_rows($result_payment))
  382. {
  383. echo '<table align = center class = view width = 96% cellspacing = 0 cellpadding =0>';
  384. echo '<tr class = view>';
  385. echo '<th class = view>&nbsp;№</th>';
  386. echo '<th class = view width=10%>Номер&nbsp;договора</th>';
  387. echo '<th class = view>&nbsp;</th>';
  388. echo '<th class = view>&nbsp;</th>';
  389. echo '<th class = view>долг</th>';
  390. echo '<th class = view>Дата</th>';
  391. echo '<th class = view>Фамилия</th>';
  392. echo '<th class = view>Имя</th>';
  393. echo '<th class = view>Отчество</th>';
  394. echo '<th class = view>Группа</th>';
  395. echo '<th class = view>&nbsp;</th>';
  396. echo '</tr>';
  397.  
  398. /*
  399. while($pjuridical_summ_row = mysql_fetch_object($result_pjuridical_summ))
  400. {
  401. include "showallagreement_form.php";
  402. $step++;
  403. }
  404. */
  405.  
  406. for($i=(($current_page-1)*$on_page); $i < (($current_page-1)*$on_page) + $on_page; $i++)
  407. {
  408. if(isset($payment[$i]))
  409. include "showallpayment_form.php";
  410. }
  411.  
  412. echo "</table>";
  413.  
  414. mysql_close() or die ("Error close session...");
  415. nav_make_pagelist("showallpayment_code.php", $on_line , $on_page, $all_rec , $current_page);
  416. }
  417. else
  418. {
  419. echo '<table align = center class = view width = 96% cellspacing = 0 cellpadding =0>';
  420. echo '<tr class = view>';
  421. echo '<th class = view>&nbsp;Нет договоров</th>';
  422. echo '</tr>';
  423. echo '</table>';
  424. }
  425.  
  426. include $system_path."footer.inc"; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement