Changeset 152 for www/finance/bills.php
- Timestamp:
- Feb 16, 2009, 2:09:57 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
www/finance/bills.php
r151 r152 1 1 <?php 2 2 3 class InvoiceGenerator3 class Bill extends Module 4 4 { 5 5 var $SpecificSymbol = 1; // počítačová sít … … 9 9 function GenerateBill($BillId) 10 10 { 11 global $ Database, $SpecificSymbol;11 global $SpecificSymbol; 12 12 13 $DbResult = $ Database->select('finance_bills', '*', 'id='.$BillId);13 $DbResult = $this->Database->select('finance_bills', '*', 'id='.$BillId); 14 14 $Bill = $DbResult->fetch_array(); 15 15 16 $DbResult = $ Database->select('users', '*', 'id='.$Bill['user_id']);16 $DbResult = $this->Database->select('users', '*', 'id='.$Bill['user_id']); 17 17 $User = $DbResult->fetch_array(); 18 18 19 19 $Dodavka = array(); 20 $DbResult = $ Database->select('finance_bills_items', '*', 'bill_id='.$BillId);20 $DbResult = $this->Database->select('finance_bills_items', '*', 'bill_id='.$BillId); 21 21 while($Item = $DbResult->fetch_array()) 22 22 { … … 122 122 function CreateBill($UserId, $Items, $TimeFrom, $TimeTo, $BillCode, $Type) 123 123 { 124 global $Database; 125 126 $Database->insert('finance_bills', array('time_create' => TimeToMysqlDateTime(time()), 'user_id' => $UserId, 'time_from' => TimeToMysqlDateTime($TimeFrom), 'time_to' => TimeToMysqlDateTime($TimeTo), 'time_due' => TimeToMysqlDateTime($TimeFrom + 15*24*3600), 'BillCode' => $BillCode, 'Type' => 'invoice')); 127 $BillId = $Database->insert_id; 124 $this->Database->insert('finance_bills', array('time_create' => TimeToMysqlDateTime(time()), 'user_id' => $UserId, 'time_from' => TimeToMysqlDateTime($TimeFrom), 'time_to' => TimeToMysqlDateTime($TimeTo), 'time_due' => TimeToMysqlDateTime($TimeFrom + 15*24*3600), 'BillCode' => $BillCode, 'Type' => 'invoice')); 125 $BillId = $this->Database->insert_id; 128 126 foreach($Items as $Item) 129 127 { 130 $ Database->insert('finance_bills_items', array('bill_id' => $BillId, 'description' => $Item['description'], 'price' => $Item['price'], 'quantity' => $Item['quantity']));128 $this->Database->insert('finance_bills_items', array('bill_id' => $BillId, 'description' => $Item['description'], 'price' => $Item['price'], 'quantity' => $Item['quantity'])); 131 129 } 132 130 //Header('Content-Type: application/pdf'); … … 134 132 //echo($PdfData); 135 133 file_put_contents($this->FileFolder.'/'.$this->FileNamePrefix.$BillId.'.pdf', $PdfData); 136 //$ Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId);134 //$this->Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId); 137 135 return($BillId); 138 136 } … … 140 138 function CreateIncomeBill($UserId, $Description, $Price, $BillCode) 141 139 { 142 global $Database; 143 144 $Database->insert('finance_bills', array('time_create' => TimeToMysqlDateTime(time()), 'user_id' => $UserId, 'BillCode' => $BillCode, 'Type' => 'income')); 145 $BillId = $Database->insert_id; 146 $Database->insert('finance_bills_items', array('bill_id' => $BillId, 'description' => $Description, 'price' => $Price, 'quantity' => 1)); 140 $this->Database->insert('finance_bills', array('time_create' => TimeToMysqlDateTime(time()), 'user_id' => $UserId, 'BillCode' => $BillCode, 'Type' => 'income')); 141 $BillId = $this->Database->insert_id; 142 $this->Database->insert('finance_bills_items', array('bill_id' => $BillId, 'description' => $Description, 'price' => $Price, 'quantity' => 1)); 147 143 //Header('Content-Type: application/pdf'); 148 144 $PdfData = $this->HtmlToPdf($this->GenerateBill($BillId)); 149 145 //echo($PdfData); 150 146 file_put_contents($this->FileFolder.'/'.$this->FileNamePrefix.$BillId.'.pdf', $PdfData); 151 //$ Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId);147 //$this->Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId); 152 148 return($BillId); 153 149 } … … 160 156 //echo($this->FileFolder.'/'.$this->FileNamePrefix.$BillId.'.pdf'); 161 157 echo(file_put_contents($this->FileFolder.'/'.$this->FileNamePrefix.$BillId.'.pdf', $PdfData)); 162 //$ Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId);158 //$this->Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId); 163 159 } 164 160 … … 167 163 global $Database; 168 164 169 //$DbResult = $ Database->select('finance_bills', 'pdf', 'id='.$BillId);165 //$DbResult = $this->Database->select('finance_bills', 'pdf', 'id='.$BillId); 170 166 //if($DbResult->num_rows == 1) 171 167 //{ … … 204 200 global $Database; 205 201 206 $DbResult = $ Database->select('finance_operations', '*', '(date="2008-02-01" AND comment="Poplatek za měsíc Únor") OR '.202 $DbResult = $this->Database->select('finance_operations', '*', '(date="2008-02-01" AND comment="Poplatek za měsíc Únor") OR '. 207 203 '(date="2008-01-01" AND comment="Poplatek za měsíc Leden") OR (date="2007-12-01" AND comment="Poplatek za měsíc Prosinec") AND (bill_id = 0)'); 208 204 while($Row = $DbResult->fetch_array()) … … 211 207 $Time = MysqlDateToTime($Row['date']); 212 208 $BillId = $this->CreateBill($Row['user'], array(array('description' => 'Poplatek za připojení k síti', 'price' => (-$Row['money']), 'quantity' => 1)), $Time, $Time + (date("t", time()) - 1) * 24 * 3600); 213 $ Database->update('finance_operations', 'id='.$Row['id'], array('bill_id' => $BillId));209 $this->Database->update('finance_operations', 'id='.$Row['id'], array('bill_id' => $BillId)); 214 210 } 215 211 } … … 221 217 { 222 218 223 $DbResult = $ Database->select('finance_bills', '*', 'user_id='.$_GET['user']);219 $DbResult = $this->Database->select('finance_bills', '*', 'user_id='.$_GET['user']); 224 220 while($Item = $DbResult->fetch_array()) 225 221 { … … 250 246 ShowHeader('Doklady', 'Doklady'); 251 247 echo('Faktury:<br>'); 252 $DbResult = $ Database->select('users', '*, CONCAT(second_name," ", first_name) as fullname', '1 ORDER BY fullname');248 $DbResult = $this->Database->select('users', '*, CONCAT(second_name," ", first_name) as fullname', '1 ORDER BY fullname'); 253 249 while($User = $DbResult->fetch_array()) 254 250 { … … 260 256 } 261 257 262 $InvoiceGenerator = new InvoiceGenerator;263 264 258 ?>
Note:
See TracChangeset
for help on using the changeset viewer.