-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate-ctvcontrol.php
More file actions
72 lines (64 loc) · 2.66 KB
/
template-ctvcontrol.php
File metadata and controls
72 lines (64 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/*
Template Name: CTVControl
Template Post Type: page
*/
/**
* @author Sergey Ilyin <developer@ilyins.ru>
*/
include_once 'config.php';
spl_autoload_register(function ($class) {
switch ($class) {
case 'Woocommerce':
break;
default:
include __DIR__."/classes/$class.class.php";
break;
}
});
if ($_POST){
$param = new stdClass();
$param->textDebt = $_POST['textDebt'] ?? false;
$param->street_id = $_POST['street_id'] ?? false;
$param->textHouse = $_POST['textHouse'] ?? false;
$bgbData = BGB::getData($param);
header( "Content-Type: application/vnd.ms-excel" );
header( "Content-disposition: attachment; filename=".date('Y-m-d')."-$param->street_id-$param->textHouse-$param->textDebt.xls" );
echo iconv('UTF-8', 'windows-1251', 'ФИО') . "\t" .
iconv('UTF-8', 'windows-1251', 'Телефон') . "\t" .
iconv('UTF-8', 'windows-1251', 'Улица') . "\t" .
iconv('UTF-8', 'windows-1251', 'Дом') . "\t" .
iconv('UTF-8', 'windows-1251', 'Квартира') . "\t" .
iconv('UTF-8', 'windows-1251', 'Тариф') . "\t" .
iconv('UTF-8', 'windows-1251', 'Баланс') . "\t" .
iconv('UTF-8', 'windows-1251', 'Комментарий') . "\n";
for ($i =0; $i < $bgbData->num_rows; $i++){
$row = $bgbData->fetch_object();
echo iconv('UTF-8', 'windows-1251', $row->fio) . "\t" .
$row->phone . "\t" .
iconv('UTF-8', 'windows-1251', $row->street) . "\t" .
iconv('UTF-8', 'windows-1251', $row->house) . "\t" .
iconv('UTF-8', 'windows-1251', $row->flat) . "\t" .
iconv('UTF-8', 'windows-1251', $row->tariff) . "\t" .
$row->balance . "\t" .
iconv('UTF-8', 'windows-1251', $row->comment) . "\n";
}
} else {
get_header();
$streets = BGB::getStreets();
echo '<div align="center"><form method="post">'
. 'Должники по дому с суммой долга более '
. '<input type="text" name="textDebt" id="textDebt">'
. ' рублей<br>'
. '<select name="street_id">'
. '<option value="0">Выберите улицу</option>';
for ($i =1; $i < $streets->num_rows; $i++){
$street = $streets->fetch_object();
echo "<option value='$street->id'>$street->title</option>";
}
echo '</select>'
. ' Дом <input type="text" name="textHouse" id="textHouse">'
. '<input type="submit" name="Submit" value="Скачать">'
. ' <a href="https://fialka.tv/control">Сбросить</a></div>';
get_footer();
}