Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- $page_level = 20;
- $page_name = "Просмотр списка договоров";
- include $_SERVER['DOCUMENT_ROOT']."/include/include.inc";
- include $system_path."include/connect.inc";
- include $system_path."header.inc";
- /*
- foreach( $HTTP_POST_VARS as $key => $val)
- {
- echo ("POST ". $key ." => ". $val ."<br>");
- }
- foreach( $HTTP_GET_VARS as $key => $val)
- {
- echo ("GET ". $key ." => ". $val ."<br>");
- }
- */
- $on_page = 20;
- $on_line = 8;
- $link_pjuridical = array(1=>"Номер договора",2=>"Дата договора",3=>"ФИО",4=>"Группа");
- $order_array = array(1=>"payment_agreement",2=>"payment_dateagreement",3=>"surname_nominative, name_nominative, patr_nominative",4=>"studgroups_number");
- // страничка по умолчанию
- if (isset($HTTP_GET_VARS['page']))
- { $current_page = $HTTP_GET_VARS['page']; }
- else { $current_page = 1; }
- // echo ("current_page " . $current_page . "<br/>");
- // сортировка по умолчанию: по номеру счета
- if (!isset($order) && !isset($desc))
- { $order = 1; }
- $select_count_query = "select card_id
- from card, payment, name, surname, patr,
- study, studgroups, dep
- where card_id = payment_card_id and
- name_id = card_name_id and
- surname_id = card_surname_id and
- patr_id = card_patr_id and
- study_id = payment_study_id and
- study_studgroups_id = studgroups_id and
- dep_id = study_dep_id
- ";
- $payment_select = "select payment_id,
- payment_agreement,
- payment_dateagreement,
- payment_action,
- payment_close,
- payment_charge,
- payment_pay,
- study_id,
- card_id,
- name_nominative,
- surname_nominative,
- patr_nominative,
- studgroups_number,
- dep_name,
- study_kurs
- from
- study
- inner join card on card_id = study_card_id
- inner join name on name_id = card_name_id
- inner join surname on surname_id = card_surname_id
- inner join dep on dep_id = study_dep_id
- inner join studgroups on study_studgroups_id = studgroups_id
- left join payment on study_id = payment_study_id
- left join patr on patr_id = card_patr_id
- ";
- if (isset($name_filter) && ($name_filter))
- {
- $payment_select .= " and name_nominative like '%" . $name_filter . "%' ";
- $select_count_query .= "and name_nominative like '%" . $name_filter . "%' ";
- }
- if (isset($surname_filter) && ($surname_filter))
- {
- $payment_select .= " and surname_nominative like '%" . $surname_filter . "%' ";
- $select_count_query .= "and name_nominative like '%" . $name_filter . "%' ";
- }
- if (isset($patr_filter) && ($patr_filter))
- {
- $payment_select .= " and patr_nominative like '%" . $patr . "%' ";
- $select_count_query .= "and patr_nominative like '%" . $patr . "%' ";
- }
- if (isset($group_filter) && ($group_filter))
- {
- $payment_select .= " and studgroups_number like '%" . $group_filter . "%' ";
- $select_count_query .= "and studgroups_number like '%" . $group_filter . "%' ";
- }
- if (isset($agreement_filter) && ($agreement_filter))
- {
- $payment_select .= " and payment_agreement like '%" . $agreement_filter . "%' ";
- $select_count_query .= "and payment_agreement like '%" . $agreement_filter . "%' ";
- }
- if (isset($debt_filter) && ($debt_filter == 1))
- {
- $payment_select .= " and (payment_charge - payment_pay) > 0 ";
- $select_count_query .= " and (payment_charge - payment_pay) > 0 ";
- }
- if (isset($debt_filter) && ($debt_filter == 2))
- {
- $payment_select .= " and (payment_charge - payment_pay) <= 0 ";
- $select_count_query .= " and (payment_charge - payment_pay) <= 0 ";
- }
- if (isset($card_filter) && $card_filter){
- $payment_select .= " and card_id = '$card_filter' ";
- $select_count_query .= " and card_id = '$card_filter' ";
- }
- if (isset($study_filter) && $study_filter){
- $payment_select .= " and study_id = '$study_filter' ";
- $select_count_query .= " and study_id = '$study_filter' ";
- }
- if (isset($recordbook_filter) and $recordbook_filter){
- $payment_select .= " and study_recordbook like '$recordbook_filter%' ";
- $select_count_query .= " and study_recordbook like '$recordbook_filter%' ";
- }
- if (isset($action_filter) && ($action_filter == 1))
- {
- $payment_select .= " and payment_action = 1 ";
- $select_count_query .= " and payment_action = 1 ";
- }
- if (isset($action_filter) && ($action_filter == 2))
- {
- $payment_select .= " and payment_action = 0 ";
- $select_count_query .= " and payment_action = 0 ";
- }
- if (isset($close_filter) && ($close_filter == 1))
- {
- $payment_select .= " and payment_close = 0 ";
- $select_count_query .= " and payment_close = 0 ";
- }
- if (isset($close_filter) && ($close_filter == 2))
- {
- $payment_select .= " and payment_close = 1 ";
- $select_count_query .= " and payment_close = 1 ";
- }
- if (isset($dep_filter) && ($dep_filter))
- {
- $dep = select_dep_array();
- $payment_select .= " and dep_acronym like '".$dep[$dep_filter]."' ";
- $select_count_query .= " and dep_acronym like '".$dep[$dep_filter]."' ";
- }
- if (isset($kurs_filter) && ($kurs_filter > 1))
- {
- $payment_select .= " and study_kurs = ".($kurs_filter - 1)." ";
- $select_count_query .= " and study_kurs = ".($kurs_filter - 1)." ";
- }
- // Леша: добавил фильтр по форме обучения и программе обучения
- if (isset($educform_filter) && ($educform_filter >= 1))
- {
- $payment_select .= " and study_formeduc_id = ".$educform_filter." ";
- $select_count_query .= " and study_formeduc_id = ".$educform_filter." ";
- }
- if (isset($progr_filter) && ($progr_filter >= 1))
- {
- $payment_select .= " and study_program_id = ".$progr_filter." ";
- $select_count_query .= " and study_program_id = ".$progr_filter." ";
- }
- //проверка правильности даты
- if(preg_match( "/^\d(\d)?\.\d(\d)?\.\d\d\d\d$/", $date_from_filter))
- {
- $date_from_mysql = date_user_to_mysql($date_from_filter);
- }
- else
- {
- if($date_from_filter)
- $error_msg = "Дата введена неправильно.";
- }
- if(preg_match( "/^\d(\d)?\.\d(\d)?\.\d\d\d\d$/", $date_to_filter))
- {
- $date_to_mysql = date_user_to_mysql($date_to_filter);
- }
- else
- {
- if($date_to_filter)
- $error_msg = "Дата введена неправильно.";
- }
- if ((isset($date_from_mysql) && ($date_from_mysql)) && !(isset($date_to_mysql) && ($date_to_mysql)))
- //если указана только дата от
- {
- $payment_select .= "and payment_date_agreement >= '".$date_from_mysql."' ";
- $select_count_query .= "and payment_date_agreement >= '".$date_from_mysql."' ";
- }
- if (!(isset($date_from_mysql) && ($date_from_mysql)) && (isset($date_to_mysql) && ($date_to_mysql)))
- //если указана только дата до
- {
- $payment_select .= "and payment_dateagreement <= '".$date_to_mysql."' ";
- $select_count_query .= "and payment_dateagreement <= '".$date_to_mysql."' ";
- }
- if ((isset($date_from_mysql) && ($date_from_mysql)) && (isset($date_to_mysql) && ($date_to_mysql)))
- //если указанs даты от и до
- {
- $payment_select .= "and payment_dateagreement >= '".$date_from_mysql."' and payment_dateagreement <= '".$date_to_mysql."' ";
- $select_count_query .= "and payment_dateagreement >= '".$date_from_mysql."' and payment_dateagreement <= '".$date_to_mysql."' ";
- }
- if (isset($order) && ($order))
- {
- if($order == 3)
- //ФИО сортируем по трем полям,
- {
- if ($desc)
- {
- $payment_select .= " order by surname_nominative desc, name_nominative desc, patr_nominative desc";
- $select_count_query .= " order by surname_nominative desc, name_nominative desc, patr_nominative desc";
- }
- else
- {
- $payment_select .= " order by ".$order_array[$order];
- $select_count_query .= " order by ".$order_array[$order];
- }
- }
- else
- {
- $payment_select .= " order by ".$order_array[$order];
- $select_count_query .= " order by ".$order_array[$order];
- if ($desc)
- {
- $payment_select .= " desc ";
- $select_count_query .= " desc ";
- }
- }
- }
- // echo "select_count_query: ".$select_count_query . "<br>";
- $result_count = mysql_query ($select_count_query) or die ("Error count query...");
- // $count_rows = mysql_fetch_object($result_count);
- $all_rec = mysql_num_rows($result_count);
- // echo "select_orders_query= " . $select_orders_query . "<br>";
- // $pjuridical_summ_select .= " limit ". ($current_page-1)*$on_page.",".$on_page.";";
- $payment_select .= " limit ". ($current_page-1)*$on_page.",".$on_page.";";
- // print_r($payment_select);
- // die();
- $result_payment = mysql_query($payment_select) or die ("Error payment_select... ". $payment_select);
- while($a = mysql_fetch_array($result_payment))
- {
- $payment[($current_page-1)*$on_page + $j] = array(
- "payment_id" => $a[payment_id],
- "study_id" => $a[study_id],
- "card_id" => $a[card_id],
- "summ" => $a[pjuridical_summ_summ],
- "agreement" => $a[payment_agreement],
- "dateagreement" => $a[payment_dateagreement],
- "name" => $a[name_nominative],
- "surname" => $a[surname_nominative],
- "patr" => $a[patr_nominative],
- "group" => $a[studgroups_number],
- "action" => $a[payment_action],
- "close" => $a[payment_close],
- "debt" => $a[payment_charge] - $a[payment_pay]
- );
- $j++;
- }
- $action_array = array(
- "0" => "Все",
- "1" => "Активные",
- "2" => "Неактивные"
- );
- $close_array = array(
- "0" => "Все",
- "1" => "Открытые",
- "2" => "Закрытые"
- );
- $debt_array = array(
- "0" => "Все",
- "1" => "Должники",
- "2" => "Без долга"
- );
- $program_array = array(
- "1" => "Первое высшее",
- "2" => "Второе высшее"
- );
- $out = "page=".$current_page."&name_filter=".$name_filter."&surname_filter=".$surname_filter.
- "&patr_filter=".$patr_filter."&desc=".$desc."&order=".$order."&group_filter=".$group_filter."&agreement_filter=".$agreement_filter.
- "&debt_filter=".$debt_filter."&action_filter=".$action_filter."&close_filter=".$close_filter."&dep_filter=".$dep_filter."&kurs_filter=". $kurs_filter.
- "&date_from_filter=".$date_from_filter."&date_to_filter=".$date_to_filter."&educform_filter=".$educform_filter."&progr_filter=".$progr_filter.
- "&from_payments=1&study_filter=$study_filter&card_filter=$card_filter&recordbook_filter=$recordbook_filter";
- // echo $out;
- ?>
- <span class = header>Просмотр списка договоров</span><hr>
- <table align = center class = view width = 96% cellspacing = 0 cellpadding =0 border = 0>
- <form method = "get" action = "showallpayment_code.php" name="select">
- <input type = 'hidden' name = 'current_page' value = '<? echo $current_page; ?>'>
- <tr class = view>
- <td class=view>   <a href = "<? echo($global_path) ?>/payment/showallpayment_code.php">Сброс</a>
-   Всего: <?echo $all_rec ?></td>
- </tr>
- <tr class = view>
- <td class = view>
-   Выбор: Фамилия <input size=12 name='surname_filter' class=input value='<?echo $surname_filter;?>'>
- Имя <input size=12 name='name_filter' class=input value='<?echo $name_filter;?>'>
- Отчество <input size=12 name='patr_filter' class=input value='<?echo $patr_filter;?>'>
- Группа <input name='group_filter' size=6 class=input value='<?echo $group_filter;?>'>
- <br>
- Факультет
- <?select_box(select_dep_array(), "dep_filter", "Факультет", $dep_filter, "");?>
-
- Курс
- <?select_box($kurs_array, "kurs_filter", "Курс", $kurs_filter, "");?>
-
- Форма обучения
- <?select_box($education_form, "educform_filter", "Форма обучения", $educform_filter, "");?>
-
- Программа
- <?select_box($program_array, "progr_filter", "Программа", $progr_filter, "");?>
- <br>
-
- Состояние
- <?select_box($action_array, "action_filter", "Состояние", $action_filter, "");?>
- <?select_box($close_array, "close_filter", "Состояние", $close_filter, "");?>
- Долг
- <?select_box($debt_array, "debt_filter", "Долг", $debt_filter, "");?>
- <br>
- Код карточки <input class="input" type="text" size="7" name = 'card_filter' value="<?echo $card_filter?>">
- Код студента <input class="input" type="text" size="7" name = "study_filter" value="<?echo $study_filter?>">
- Зачетная книжка <input class="input" type="text" size="12" name= "recordbook_filter" value="<?echo $recordbook_filter?>">
- <br>
- Дата c <input name='date_from_filter' size=6 class=input value='<?echo $date_from_filter;?>'>
- по <input name='date_to_filter' size=6 class=input value='<?echo $date_to_filter;?>'>
- Номер договора <input name='agreement_filter' size=6 class=input value='<?echo $agreement_filter;?>'>
- <br>
- </td>
- </tr>
- <tr class = view>
- <td class = view>  Порядок:
- <? select_box1($link_pjuridical, "order", "Поле сортировки", $order) ?>
- Обратный:<input type = "checkbox" name = "desc" <? if ($desc) {echo 'Checked';}; ?> >
- <input type = "submit" class = "submit" name="Filter" value = "Отбор">
- </td>
- </tr>
- </form>
- </table>
- <input type=hidden name=order value=<?echo $order;?>>
- <span class = go><a href = "/login/user_page.php">Возврат</a></span>
- <!--
- // !!!!! Леша: кнопка печать
- -->
- <span class = go><a href = "print_all_payment_code.php?<?
- // $out = urlencode($out);
- // $out = urlencode($out);
- echo($out);
- ?>" target= "_new">Печать</a></span>
- <?
- if(isset($error_msg))
- {
- echo "<br><b>".$error_msg."</b>";
- die();
- }
- if(mysql_num_rows($result_payment))
- {
- echo '<table align = center class = view width = 96% cellspacing = 0 cellpadding =0>';
- echo '<tr class = view>';
- echo '<th class = view> №</th>';
- echo '<th class = view width=10%>Номер договора</th>';
- echo '<th class = view> </th>';
- echo '<th class = view> </th>';
- echo '<th class = view>долг</th>';
- echo '<th class = view>Дата</th>';
- echo '<th class = view>Фамилия</th>';
- echo '<th class = view>Имя</th>';
- echo '<th class = view>Отчество</th>';
- echo '<th class = view>Группа</th>';
- echo '<th class = view> </th>';
- echo '</tr>';
- /*
- while($pjuridical_summ_row = mysql_fetch_object($result_pjuridical_summ))
- {
- include "showallagreement_form.php";
- $step++;
- }
- */
- for($i=(($current_page-1)*$on_page); $i < (($current_page-1)*$on_page) + $on_page; $i++)
- {
- if(isset($payment[$i]))
- include "showallpayment_form.php";
- }
- echo "</table>";
- mysql_close() or die ("Error close session...");
- nav_make_pagelist("showallpayment_code.php", $on_line , $on_page, $all_rec , $current_page);
- }
- else
- {
- echo '<table align = center class = view width = 96% cellspacing = 0 cellpadding =0>';
- echo '<tr class = view>';
- echo '<th class = view> Нет договоров</th>';
- echo '</tr>';
- echo '</table>';
- }
- include $system_path."footer.inc"; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement