-
Notifications
You must be signed in to change notification settings - Fork 0
/
object_report_water.php
105 lines (94 loc) · 5.27 KB
/
object_report_water.php
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
print '<table border="0" cellpadding="0" cellspacing="0"><tbody>';
print '<tr><td align=center class="m_separator" colspan="2">Îò÷åò àáîíåíòà çà '.$prevmonth.'</td></tr>';
print '<tr><td align=center class="m_separator">Íàçíà÷åíèå</td><td align=center class="menuitem">Äëÿ ïåðåäà÷è ïîñòàâùèêó</td></tr>';
print '<tr><td align="center" colspan="2"><h1>Îò÷åò àáîíåíòà çà ìàé 2011ã.</h1></td></tr>';
print '<tr><td align="left" class="simple" colspan="2" style="font-size:12px"><strong>Âî èñïîëíåíèè äîãîâîðà ¹ îò 2011 ã.</strong>
<br>íà îòïóñê ïèòüåâîé âîäû è ïðèåì ñòî÷íûõ âîä ï.ï. 2.2.2., 4.1.2. è ï. 32 (ðàçäåë 4), ï. 88 (ðàçäåë 8)
<br>"Ïðàâèë ïîëüçîâàíèÿ ñèñòåìàìè êîììóíàëüíîãî âîäîñíàáæåíèÿ è êàíàëèçàöèè â ÐÔ", óòâåðæäåííûõ "Ïîñòàíîâëåíèåì Ïðàâèòåëüñòâà ÐÔ " ¹ 167 îò 12.02.1999 ã.
<br>Àáîíåíò '.$name.' íàïðàâëÿåò Âàì ñâåäåíèÿ ïî ó÷åòó ïîëó÷åííîé ïèòüåâîé âîäû è ñáðîøåííûõ ñòî÷íûõ âîä.
</td></tr>';
print '<tr><td align=left colspan="2">';
print '<table width="1000px">';
print '<tr><td class="m_separator">¹ ï/ï</td><td class="m_separator" align="center">Íàèìåíîâàíèå óñëóãè</td>
<td class="m_separator" align="center">Àäðåñ îáúåêòà</td>
<td class="m_separator" align="center">Êîä ïðèñîåäèíåíèÿ</td>
<td class="m_separator" align="center" colspan="2">Ïîêàçàíèÿ ïðèáîðîâ ó÷åòà</td>
<td class="m_separator" align="center">Ðàñõîä çà ìåñÿö, ì3</td></tr>';
$today=getdate(); $startday=1;
if ($_GET["year"]=='') $ye=$today["year"];
else $ye=$_GET["year"];
if ($_GET["month"]=='') $mn=$today["mon"];
else $mn=$_GET["month"];
$adr=strstr ($name,"óë.");
$repdata=$mn.$ye;
if ($startday==1)
{
$date1=sprintf ("%d%02d%02d000000",$ye,$mn+1,$startday);
$date2=sprintf ("%d%02d%02d000000",$ye,$mn,$startday);
}
else
{
$date1=sprintf ("%d%02d01000000",$ye,$mn,$startday);
$date2=sprintf ("%d%02d%02d000000",$ye,$mn-1,$startday);
}
echo $date2.' - '.$date1.'<br>';
$data1=$data2=$dat1=$dat2='-';
$query = 'SELECT * FROM data WHERE type=2 AND prm=12 AND source=26 AND device='.$device.' AND date<='.$date1.' ORDER BY date DESC';
//echo $query;
$a = mysql_query ($query,$i);
if ($a) $uy = mysql_fetch_row ($a);
if ($uy) { $data1=$uy[3]; $dat1=substr($uy[2],0,10); }
$query = 'SELECT * FROM data WHERE type=2 AND prm=12 AND source=26 AND device='.$device.' AND date>='.$date2.' ORDER BY date';
//echo $query;
$a = mysql_query ($query,$i);
if ($a) $uy = mysql_fetch_row ($a);
if ($uy) { $data2=$uy[3]; $dat2=substr($uy[2],0,10); }
print '<tr><td class="m_separator"></td><td class="menuitem" align="center"></td>
<td class="menuitem"></td>
<td class="menuitem"></td>
<td class="menuitem" align="center">Ïðåäûäóùèå íà '.$dat2.'</td><td class="menuitem" align="center">Ïîñëåäíèå íà '.$dat1.'</td>
<td class="menuitem" align="center"></td></tr>';
print '<tr><td class="m_separator">1</td><td class="simple" align="center">ÕÂÑ</td>
<td class="simple">'.$adr.'</td>
<td class="simple"></td>';
if ($data2>0) print '<td class="simple" align="center">'.number_format($data2,2).'</td>';
else print '<td class="simple" align="center">-</td>';
if ($data1>0) print '<td class="simple" align="center">'.number_format($data1,2).'</td>';
else print '<td class="simple" align="center">-</td>';
if ($data1>0 && $data2>0) print '<td class="simple" align="center">'.number_format($data1-$data2,2).'</td></tr>';
else print '<td class="simple" align="center">-</td></tr>';
require_once 'phpexcel/Classes/PHPExcel.php';
require_once 'phpexcel/Classes/PHPExcel/Cell/AdvancedValueBinder.php';
PHPExcel_Cell::setValueBinder( new PHPExcel_Cell_AdvancedValueBinder() );
$objPHPExcel = PHPExcel_IOFactory::load('reports/water.xls');
// Set properties
$objPHPExcel->getProperties()->setCreator("rpksu")
->setLastModifiedBy("Olejek")
->setTitle("Water report")
->setSubject("Water report")
->setDescription("Water report")
->setKeywords("office 2003 openxml php")
->setCategory("Report");
// Rename sheet
//echo date('H:i:s') . " Rename sheet\n";
//$objPHPExcel->getActiveSheet()->setTitle('Heat Report');
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
//$objPHPExcel->getActiveSheet()->setCellValue('D11',$name);
$objPHPExcel->getActiveSheet()->setCellValue('D11',iconv ('CP1251','UTF-8',$name));
//$objPHPExcel->getActiveSheet()->setCellValue('D13',$name);
$itogo='Îò÷åò àáîíåíòà çà '.$prevmonth;
$yach='A6'; $objPHPExcel->getActiveSheet()->setCellValue($yach,iconv ('CP1251','UTF-8',$itogo));
$yach='C18';// $objPHPExcel->getActiveSheet()->setCellValue($yach,$name);
$objPHPExcel->getActiveSheet()->setCellValue($yach,iconv ('CP1251','UTF-8',$adr));
$yach='E18'; $objPHPExcel->getActiveSheet()->setCellValue($yach,$data2);
$yach='F18'; $objPHPExcel->getActiveSheet()->setCellValue($yach,$data1);
$yach='G18'; $objPHPExcel->getActiveSheet()->setCellValue($yach,number_format($data1-$data2,2));
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
//$objWriter->setOffice2003Compatibility(true);
$filename='reports/report_water_'.$repdata.'.xlsx';
$objWriter->save($filename);
print '<tr><td align=center class="menuitem" colspan=2><a href="'.$filename.'">Ñêà÷àòü îò÷åò â ôîðìàòå Excel</a></td></tr>';
print '</table>';
?>