Changeset 144
- Timestamp:
- Feb 14, 2009, 6:52:05 PM (16 years ago)
- Location:
- www
- Files:
-
- 4 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
www/finance/bills.php
r140 r144 25 25 } 26 26 27 $Output = '<table width="100%"><tr><td colspan="2">'. 28 '<font size="6"><div align="center">Faktura - daňový doklad</font></div>'. 29 '<hr></td></tr>'. 30 '<tr><td valign="top" width="50%"><strong>Dodavatel:</strong><br>'. 31 'Ing. Jiří Hajda<br>'. 32 'Zděchov 208<br>'. 33 '75607 Zděchov<br>'. 34 'IČ: 75904535<br>'. 35 'DIČ: CZ8303255884<br>'. 36 'Účet: 218098370 / 0300<br>'. 37 'Neplátce DPH<br>'. 38 '</td><td valign="top">'. 39 '<strong>Odběratel:</strong><br>'. 40 $User['subject_name'].'<br>'. 41 $User['street'].'<br>'. 42 $User['psc'].' '.$User['town'].'<br>'; 43 if($User['ico'] != 0) $Output .= 'IČ: '.$User['ico'].'<br>'; 44 if($User['dic'] != '') $Output .= 'DIČ: '.$User['dic'].'<br>'; 45 $Output .= 46 '</td></tr>'. 47 '<tr><td colspan="2"><hr></td></tr>'. 48 '<tr><td width="50%" valign="top">'. 49 '<strong>Platební podmínky:</strong><br>'. 50 'Číslo dokladu: '.$Bill['BillCode'].'<br>'. 51 'Variabilní symbol: '.$User['id'].'<br>'. 52 'Specifický symbol: '.$this->SpecificSymbol.'<br>'. 53 'Konstantní symbol:<br>'. 54 'Způsob úhrady: převodem'. 55 '</td><td valign="top">'. 56 '<br>'. 57 'Datum vystavení: '.HumanDate($Bill['time_create']).'<br>'. 58 'Datum zdanitel. plnění: '.HumanDate($Bill['time_create']).'<br>'. 59 'Datum splatnosti: '.HumanDate($Bill['time_due']).'<br>'; 60 if(($Bill['time_from'] != '0000-00-00 00:00:00') and ($Bill['time_to'] != '0000-00-00 00:00:00')) 61 $Output .= 'Fakturované období: '.HumanDate($Bill['time_from']).' - '.HumanDate($Bill['time_to']).'<br>'; 62 $Output .= '</td></tr>'. 63 '<tr><td colspan="2">'. 64 '<hr>'. 65 '<br>'. 66 '<table border="0" width="100%">'. 67 '<tr><th align="left">Dodávka</th><th align="right">Množství</th><th align="right">Cena/MJ</th><th align="right">Celkem</th></tr>'. 68 '<tr><td colspan="4"><hr></td></tr>'; 69 70 $Total = 0; 71 foreach($Dodavka as $Polozka) 72 { 73 $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>'; 74 $Total += ($Polozka['quantity'] * $Polozka['price']); 75 } 76 $Output .= '<tr><th colspan="3" align="left">Celkem</th><th align="right">'.$Total.' Kč</th></tr>'; 77 $Output .= '</table>'. 78 '</td></tr>'. 79 '<tr><td colspan="2"><hr></td></tr>'. 80 '</table>'; 81 82 return($Output); 83 } 84 85 86 function GenerateIncomeBill($BillId) 87 { 88 global $Database, $SpecificSymbol; 89 90 $DbResult = $Database->select('finance_bills', '*', 'id='.$BillId); 91 $Bill = $DbResult->fetch_array(); 92 93 $DbResult = $Database->select('users', '*', 'id='.$Bill['user_id']); 94 $User = $DbResult->fetch_array(); 95 96 $Dodavka = array(); 97 $DbResult = $Database->select('finance_bills_items', '*', 'bill_id='.$BillId); 98 while($Item = $DbResult->fetch_array()) 99 { 100 $Dodavka[$Item['id']] = $Item; 101 } 102 103 $Output = '<table width="100%" border="1"><tr><td>'. 104 '<strong>Subjekt:</strong><br>'. 105 $User['subject_name'].'<br>'. 106 $User['street'].'<br>'. 107 $User['psc'].' '.$User['town'].'<br>'; 108 if($User['ico'] != 0) $Output .= 'IČ: '.$User['ico'].'<br>'; 109 if($User['dic'] != '') $Output .= 'DIČ: '.$User['dic'].'<br>'; 110 $Output .= 111 '</td><td>'. 112 'PŘÍJMOVÝ POKLADNÍ DOKLAD<br><br>'. 113 'Číslo dokladu: '.$Bill['BillCode'].'<br>'. 114 'Datum vystavení: '.HumanDate($Bill['time_create']).'<br>'. 115 '</td></tr>'. 116 '<tr><td colspan="2"><strong>Přijato od:</strong><br>'. 117 '</td></tr>'. 118 '<tr><td colspan="2"><strong>Částka: '. 119 '<strong>Platební podmínky:</strong><br>'. 120 'Variabilní symbol: '.$User['id'].'<br>'. 121 'Specifický symbol: '.$this->SpecificSymbol.'<br>'. 122 'Konstantní symbol:<br>'. 123 'Způsob úhrady: převodem'. 124 '</td><td valign="top">'. 125 '<br>'. 126 'Datum zdanitel. plnění: '.HumanDate($Bill['time_create']).'<br>'. 127 'Datum splatnosti: '.HumanDate($Bill['time_due']).'<br>'; 128 if(($Bill['time_from'] != '0000-00-00 00:00:00') and ($Bill['time_to'] != '0000-00-00 00:00:00')) 129 $Output .= 'Fakturované období: '.HumanDate($Bill['time_from']).' - '.HumanDate($Bill['time_to']).'<br>'; 130 $Output .= '</td></tr>'. 131 '<tr><td colspan="2">'. 132 '<hr>'. 133 '<br>'. 134 '<table border="0" width="100%">'. 135 '<tr><th align="left">Dodávka</th><th align="right">Množství</th><th align="right">Cena/MJ</th><th align="right">Celkem</th></tr>'. 136 '<tr><td colspan="4"><hr></td></tr>'; 137 138 $Total = 0; 139 foreach($Dodavka as $Polozka) 140 { 141 $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>'; 142 $Total += ($Polozka['quantity'] * $Polozka['price']); 143 } 144 $Output .= '<tr><th colspan="3" align="left">Celkem</th><th align="right">'.$Total.' Kč</th></tr>'; 145 $Output .= '</table>'. 146 '</td></tr>'. 147 '<tr><td colspan="2"><hr></td></tr>'. 148 '</table>'; 149 150 return($Output); 151 } 152 153 function CreateBill($UserId, $Items, $TimeFrom, $TimeTo, $BillCode) 154 { 155 global $Database; 156 157 $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)); 27 switch($Bill['Type']) 28 { 29 case 'invoice': 30 $Output = '<table width="100%"><tr><td colspan="2">'. 31 '<font size="6"><div align="center">Faktura - daňový doklad</font></div>'. 32 '<hr></td></tr>'. 33 '<tr><td valign="top" width="50%"><strong>Dodavatel:</strong><br>'. 34 'Ing. Jiří Hajda<br>'. 35 'Zděchov 208<br>'. 36 '75607 Zděchov<br>'. 37 'IČ: 75904535<br>'. 38 'DIČ: CZ8303255884<br>'. 39 'Účet: 218098370 / 0300<br>'. 40 'Neplátce DPH<br>'. 41 '</td><td valign="top">'. 42 '<strong>Odběratel:</strong><br>'. 43 $User['subject_name'].'<br>'. 44 $User['street'].'<br>'. 45 $User['psc'].' '.$User['town'].'<br>'; 46 if($User['ico'] != 0) $Output .= 'IČ: '.$User['ico'].'<br>'; 47 if($User['dic'] != '') $Output .= 'DIČ: '.$User['dic'].'<br>'; 48 $Output .= 49 '</td></tr>'. 50 '<tr><td colspan="2"><hr></td></tr>'. 51 '<tr><td width="50%" valign="top">'. 52 '<strong>Platební podmínky:</strong><br>'. 53 'Číslo dokladu: '.$Bill['BillCode'].'<br>'. 54 'Variabilní symbol: '.$User['id'].'<br>'. 55 'Specifický symbol: '.$this->SpecificSymbol.'<br>'. 56 'Konstantní symbol:<br>'. 57 'Způsob úhrady: převodem'. 58 '</td><td valign="top">'. 59 '<br>'. 60 'Datum vystavení: '.HumanDate($Bill['time_create']).'<br>'. 61 'Datum zdanitel. plnění: '.HumanDate($Bill['time_create']).'<br>'. 62 'Datum splatnosti: '.HumanDate($Bill['time_due']).'<br>'; 63 if(($Bill['time_from'] != '0000-00-00 00:00:00') and ($Bill['time_to'] != '0000-00-00 00:00:00')) 64 $Output .= 'Fakturované období: '.HumanDate($Bill['time_from']).' - '.HumanDate($Bill['time_to']).'<br>'; 65 $Output .= '</td></tr>'. 66 '<tr><td colspan="2">'. 67 '<hr>'. 68 '<br>'. 69 '<table border="0" width="100%">'. 70 '<tr><th align="left">Dodávka</th><th align="right">Množství</th><th align="right">Cena/MJ</th><th align="right">Celkem</th></tr>'. 71 '<tr><td colspan="4"><hr></td></tr>'; 72 73 $Total = 0; 74 foreach($Dodavka as $Polozka) 75 { 76 $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>'; 77 $Total += ($Polozka['quantity'] * $Polozka['price']); 78 } 79 $Output .= '<tr><th colspan="3" align="left">Celkem</th><th align="right">'.$Total.' Kč</th></tr>'; 80 $Output .= '</table>'. 81 '</td></tr>'. 82 '<tr><td colspan="2"><hr></td></tr>'. 83 '</table>'; 84 break; 85 case 'income': 86 $Output = '<table width="100%" border="1" cellspacing="0" cellpadding="3"><tr><td width="50%">'. 87 '<strong>Firma:</strong><br>'. 88 'Ing. Jiří Hajda<br>'. 89 'Zděchov 208<br>'. 90 '75607 Zděchov<br>'. 91 'IČ: 75904535<br>'. 92 'DIČ: CZ8303255884<br>'. 93 'Účet: 218098370 / 0300<br>'. 94 'Neplátce DPH</td><td width="50%" valign="top">'. 95 '<font size="5"><strong>PŘÍJMOVÝ POKLADNÍ DOKLAD</strong></font><br><br>'. 96 'Číslo dokladu: '.$Bill['BillCode'].'<br>'. 97 'Datum vystavení: '.HumanDate($Bill['time_create']).'<br>'. 98 '</td></tr>'. 99 '<tr><td colspan="2"><strong>Přijato od:</strong><br>'. 100 $User['subject_name'].'<br>'. 101 $User['street'].'<br>'. 102 $User['psc'].' '.$User['town'].'<br>'; 103 if($User['ico'] != 0) $Output .= 'IČ: '.$User['ico'].'<br>'; 104 if($User['dic'] != '') $Output .= 'DIČ: '.$User['dic'].'<br>'; 105 $Total = 0; 106 $Description = ''; 107 foreach($Dodavka as $Polozka) 108 { 109 $Description .= $Polozka['description'].'<br>'; 110 $Total += ($Polozka['quantity'] * $Polozka['price']); 111 } 112 $Output .= '</td></tr>'. 113 '<tr><td colspan="2"><strong>Částka:</strong> '.$Total.' Kč<br><br>'. 114 '</td></tr>'. 115 '<tr><td colspan="2"><strong>Účel platby:</strong><br>'.$Description.'</td></tr>'. 116 '<tr><td><br><br>Podpis příjemce:</td><td><br><br>Podpis pokladníka:</td></tr>'; 117 $Output .= '</table>'; 118 break; 119 } 120 return($Output); 121 } 122 123 function CreateBill($UserId, $Items, $TimeFrom, $TimeTo, $BillCode, $Type) 124 { 125 global $Database; 126 127 $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')); 158 128 $BillId = $Database->insert_id; 159 129 foreach($Items as $Item) … … 169 139 } 170 140 141 function CreateIncomeBill($UserId, $Description, $Price, $BillCode) 142 { 143 global $Database; 144 145 $Database->insert('finance_bills', array('time_create' => TimeToMysqlDateTime(time()), 'user_id' => $UserId, 'BillCode' => $BillCode, 'Type' => 'income')); 146 $BillId = $Database->insert_id; 147 $Database->insert('finance_bills_items', array('bill_id' => $BillId, 'description' => $Description, 'price' => $Price, 'quantity' => 1)); 148 //Header('Content-Type: application/pdf'); 149 $PdfData = $this->HtmlToPdf($this->GenerateBill($BillId)); 150 //echo($PdfData); 151 file_put_contents($this->FileFolder.'/'.$this->FileNamePrefix.$BillId.'.pdf', $PdfData); 152 //$Database->query('UPDATE finance_bills SET pdf = 0x'.bin2hex($PdfData).' WHERE id='.$BillId); 153 return($BillId); 154 } 155 171 156 function RegeneratePDF($BillId) 172 157 { … … 264 249 } else 265 250 { 266 ShowHeader(' Faktury', 'Faktury');251 ShowHeader('Doklady', 'Doklady'); 267 252 echo('Faktury:<br>'); 268 253 $DbResult = $Database->select('users', '*, CONCAT(second_name," ", first_name) as fullname', '1 ORDER BY fullname'); -
www/finance/manage.php
r133 r144 4 4 include('bills.php'); 5 5 6 /* 6 7 if(array_key_exists('Operation', $_GET)) $Operation = $_GET['Operation']; else $Operation = ''; 7 8 switch($Operation) … … 21 22 } 22 23 echo(FormatOutput($Output)); 24 */ 23 25 24 26 function CheckAdvancesAndLiabilities($Subject)
Note:
See TracChangeset
for help on using the changeset viewer.