Changeset 156 for www/finance/bills.php
- Timestamp:
- Feb 17, 2009, 10:00:28 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
www/finance/bills.php
r152 r156 11 11 global $SpecificSymbol; 12 12 13 $DbResult = $this->Database->select(' finance_bills', '*', 'id='.$BillId);14 $Bill = $DbResult->fetch_a rray();13 $DbResult = $this->Database->select('FinanceBills', '*', 'Id='.$BillId); 14 $Bill = $DbResult->fetch_assoc(); 15 15 16 $DbResult = $this->Database->select(' users', '*', 'id='.$Bill['user_id']);17 $ User = $DbResult->fetch_array();16 $DbResult = $this->Database->select('Subject', '*', 'Id='.$Bill['Subject']); 17 $Subject = $DbResult->fetch_assoc(); 18 18 19 19 $Dodavka = array(); 20 $DbResult = $this->Database->select(' finance_bills_items', '*', 'bill_id='.$BillId);21 while($Item = $DbResult->fetch_a rray())22 { 23 $Dodavka[$Item[' id']] = $Item;20 $DbResult = $this->Database->select('FinanceBillsItems', '*', 'Bill='.$BillId); 21 while($Item = $DbResult->fetch_assoc()) 22 { 23 $Dodavka[$Item['Id']] = $Item; 24 24 } 25 25 … … 40 40 '</td><td valign="top">'. 41 41 '<strong>Odběratel:</strong><br>'. 42 $ User['subject_name'].'<br>'.43 $ User['street'].'<br>'.44 $ User['psc'].' '.$User['town'].'<br>';45 if($ User['ico'] != 0) $Output .= 'IČ: '.$User['ico'].'<br>';46 if($ User['dic'] != '') $Output .= 'DIČ: '.$User['dic'].'<br>';42 $Subject['Name'].'<br>'. 43 $Subject['AddressStreet'].'<br>'. 44 $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>'; 45 if($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>'; 46 if($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>'; 47 47 $Output .= 48 48 '</td></tr>'. … … 51 51 '<strong>Platební podmínky:</strong><br>'. 52 52 'Číslo dokladu: '.$Bill['BillCode'].'<br>'. 53 'Variabilní symbol: '.$ User['id'].'<br>'.53 'Variabilní symbol: '.$Subject['Id'].'<br>'. 54 54 'Specifický symbol: '.$this->SpecificSymbol.'<br>'. 55 55 'Konstantní symbol:<br>'. … … 57 57 '</td><td valign="top">'. 58 58 '<br>'. 59 'Datum vystavení: '.HumanDate($Bill[' time_create']).'<br>'.60 'Datum zdanitel. plnění: '.HumanDate($Bill[' time_create']).'<br>'.61 'Datum splatnosti: '.HumanDate($Bill[' time_due']).'<br>';62 if(($Bill[' time_from'] != '0000-00-00 00:00:00') and ($Bill['time_to'] != '0000-00-00 00:00:00'))63 $Output .= 'Fakturované období: '.HumanDate($Bill[' time_from']).' - '.HumanDate($Bill['time_to']).'<br>';59 'Datum vystavení: '.HumanDate($Bill['TimeCreate']).'<br>'. 60 'Datum zdanitel. plnění: '.HumanDate($Bill['TimeCreate']).'<br>'. 61 'Datum splatnosti: '.HumanDate($Bill['TimeDue']).'<br>'; 62 if(($Bill['TimeFrom'] != '0000-00-00 00:00:00') and ($Bill['TimeTo'] != '0000-00-00 00:00:00')) 63 $Output .= 'Fakturované období: '.HumanDate($Bill['TimeFrom']).' - '.HumanDate($Bill['TimeTo']).'<br>'; 64 64 $Output .= '</td></tr>'. 65 65 '<tr><td colspan="2">'. … … 73 73 foreach($Dodavka as $Polozka) 74 74 { 75 $Output .= '<tr><td>'.$Polozka[' description'].'</td><td align="right">'.$Polozka['quantity'].'</td><td align="right">'.$Polozka['price'].' Kč</td><td align="right">'.($Polozka['quantity'] * $Polozka['price']).' Kč</td></tr>';76 $Total += ($Polozka[' quantity'] * $Polozka['price']);75 $Output .= '<tr><td>'.$Polozka['Description'].'</td><td align="right">'.$Polozka['Quantity'].'</td><td align="right">'.$Polozka['Price'].' Kč</td><td align="right">'.($Polozka['Quantity'] * $Polozka['Price']).' Kč</td></tr>'; 76 $Total += ($Polozka['Quantity'] * $Polozka['Price']); 77 77 } 78 78 $Output .= '<tr><th colspan="3" align="left">Celkem</th><th align="right">'.$Total.' Kč</th></tr>'; … … 94 94 '<font size="5"><strong>PŘÍJMOVÝ POKLADNÍ DOKLAD</strong></font><br><br>'. 95 95 'Číslo dokladu: '.$Bill['BillCode'].'<br>'. 96 'Datum vystavení: '.HumanDate($Bill[' time_create']).'<br>'.96 'Datum vystavení: '.HumanDate($Bill['TimeCreate']).'<br>'. 97 97 '</td></tr>'. 98 98 '<tr><td colspan="2"><strong>Přijato od:</strong><br>'. 99 $ User['subject_name'].'<br>'.100 $ User['street'].'<br>'.101 $ User['psc'].' '.$User['town'].'<br>';102 if($ User['ico'] != 0) $Output .= 'IČ: '.$User['ico'].'<br>';103 if($ User['dic'] != '') $Output .= 'DIČ: '.$User['dic'].'<br>';99 $Subject['Name'].'<br>'. 100 $Subject['AddressStreet'].'<br>'. 101 $Subject['AddressPSC'].' '.$Subject['AddressTown'].'<br>'; 102 if($Subject['IC'] != 0) $Output .= 'IČ: '.$Subject['IC'].'<br>'; 103 if($Subject['DIC'] != '') $Output .= 'DIČ: '.$Subject['DIC'].'<br>'; 104 104 $Total = 0; 105 105 $Description = ''; 106 106 foreach($Dodavka as $Polozka) 107 107 { 108 $Description .= $Polozka[' description'].'<br>';109 $Total += ($Polozka[' quantity'] * $Polozka['price']);108 $Description .= $Polozka['Description'].'<br>'; 109 $Total += ($Polozka['Quantity'] * $Polozka['Price']); 110 110 } 111 111 $Output .= '</td></tr>'. … … 120 120 } 121 121 122 function CreateBill($ UserId, $Items, $TimeFrom, $TimeTo, $BillCode, $Type)123 { 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'));122 function CreateBill($SubjectId, $Items, $TimeFrom, $TimeTo, $BillCode, $Type) 123 { 124 $this->Database->insert('FinanceBills', array('TimeCreate' => TimeToMysqlDateTime(time()), 'Subject' => $SubjectId, 'TimeFrom' => TimeToMysqlDateTime($TimeFrom), 'TimeTo' => TimeToMysqlDateTime($TimeTo), 'TimeDue' => TimeToMysqlDateTime($TimeFrom + 15*24*3600), 'BillCode' => $BillCode, 'Type' => 'invoice')); 125 125 $BillId = $this->Database->insert_id; 126 126 foreach($Items as $Item) 127 127 { 128 $this->Database->insert(' finance_bills_items', array('bill_id' => $BillId, 'description' => $Item['description'], 'price' => $Item['price'], 'quantity' => $Item['quantity']));128 $this->Database->insert('FinanceBillsItems', array('Bill' => $BillId, 'Description' => $Item['Description'], 'Price' => $Item['Price'], 'Quantity' => $Item['Quantity'])); 129 129 } 130 130 //Header('Content-Type: application/pdf'); … … 136 136 } 137 137 138 function CreateIncomeBill($ UserId, $Description, $Price, $BillCode)139 { 140 $this->Database->insert(' finance_bills', array('time_create' => TimeToMysqlDateTime(time()), 'user_id' => $UserId, 'BillCode' => $BillCode, 'Type' => 'income'));138 function CreateIncomeBill($SubjectId, $Description, $Price, $BillCode) 139 { 140 $this->Database->insert('FinanceBills', array('TimeCreate' => TimeToMysqlDateTime(time()), 'Subject' => $SubjectId, 'BillCode' => $BillCode, 'Type' => 'income')); 141 141 $BillId = $this->Database->insert_id; 142 $this->Database->insert(' finance_bills_items', array('bill_id' => $BillId, 'description' => $Description, 'price' => $Price, 'quantity' => 1));142 $this->Database->insert('FinanceBillsItems', array('Bill' => $BillId, 'Description' => $Description, 'Price' => $Price, 'Quantity' => 1)); 143 143 //Header('Content-Type: application/pdf'); 144 144 $PdfData = $this->HtmlToPdf($this->GenerateBill($BillId)); … … 206 206 echo($Row['id']."<br>\n"); 207 207 $Time = MysqlDateToTime($Row['date']); 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);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); 209 209 $this->Database->update('finance_operations', 'id='.$Row['id'], array('bill_id' => $BillId)); 210 210 } … … 214 214 { 215 215 global $Database; 216 if(array_key_exists(' user', $_GET))216 if(array_key_exists('subject', $_GET)) 217 217 { 218 218 219 $DbResult = $this->Database->select(' finance_bills', '*', 'user_id='.$_GET['user']);219 $DbResult = $this->Database->select('FinanceBills', '*', 'Subject='.$_GET['subject']); 220 220 while($Item = $DbResult->fetch_array()) 221 221 { 222 echo('<a href="?bill='.$Item[' id'].'">faktura '.$Item['id'].'</a> <a href="?billpdf='.$Item['id'].'">Uložené PDF</a> <a href="?billpdf2='.$Item['id'].'">Generované PDF</a> <a href="?regenerate='.$Item['id'].'">Přegenerovat</a><br>');222 echo('<a href="?bill='.$Item['Id'].'">faktura '.$Item['Id'].'</a> <a href="?billpdf='.$Item['Id'].'">Uložené PDF</a> <a href="?billpdf2='.$Item['Id'].'">Generované PDF</a> <a href="?regenerate='.$Item['Id'].'">Přegenerovat</a><br>'); 223 223 } 224 224 } else … … 241 241 if(array_key_exists('generate', $_GET)) 242 242 { 243 $this->CreateBill(1, array(array(' description' => 'Poplatek za připojení k síti', 'price' => 1000, 'quantity' => 1)), time(), time());243 $this->CreateBill(1, array(array('Description' => 'Poplatek za připojení k síti', 'Price' => 1000, 'Quantity' => 1)), time(), time()); 244 244 } else 245 245 { 246 246 ShowHeader('Doklady', 'Doklady'); 247 echo('Faktury:<br >');248 $DbResult = $this->Database->select(' users', '*, CONCAT(second_name," ", first_name) as fullname', '1 ORDER BY fullname');249 while($ User = $DbResult->fetch_array())247 echo('Faktury:<br />'); 248 $DbResult = $this->Database->select('Subject', '*', '1 ORDER BY Name'); 249 while($Subject = $DbResult->fetch_assoc()) 250 250 { 251 echo('<a href="?user='.$ User['id'].'">'.$User['fullname'].'</a><br>');251 echo('<a href="?user='.$Subject['Id'].'">'.$Subject['Name'].'</a><br />'); 252 252 } 253 253 ShowFooter();
Note:
See TracChangeset
for help on using the changeset viewer.