johnburn

Decoded for: andr0id@waraxe.us

Aug 23rd, 2011
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 27.11 KB | None | 0 0
  1. <?php
  2. $rok = date('Y');
  3. if ($rok == '2010') {
  4.     $stawki_vat = false;
  5. } else {
  6.     $stawki_vat = true;
  7. }
  8. function wb($liczba) {
  9.     return ($liczba > 0) ? $liczba : $liczba * (-1);
  10. }
  11. function getInvoiceNr($oID, $fID) {
  12.     if ($fID == '3') {
  13.         $zapytanie = tep_db_query('select invoice_proforma_nr,invoice_proforma_date FROM ' . TABLE_ORDERS . '  WHERE orders_id=' . $oID);
  14.         $tablica = tep_db_fetch_array($zapytanie);
  15.         if ($tablica['invoice_proforma_nr'] > 0) {
  16.             $max_nr = strftime(PREFIX_FN, $tablica['invoice_proforma_date']) . sprintf(((FORMAT_FN == "") ? "%d" : FORMAT_FN), $tablica['invoice_proforma_nr']) . strftime(SUFFIX_FN, $tablica['invoice_proforma_date']);
  17.             $wynik = array("nr_faktury" => $max_nr, "data" => strftime('%d-%m-%Y', $tablica['invoice_proforma_date']), $tablica['invoice_proforma_date'], "nowa" => '0', "nowa_nr" => $tablica['invoice_proforma_nr']);
  18.             return $wynik;
  19.         } else {
  20.             if (CONTINUE_NUMERATION == 'false') {
  21.                 $current_year = date('Y', time());
  22.                 $begin_year = mktime(0, 0, 0, 1, 1, $current_year);
  23.                 $end_year = mktime(0, 0, 0, 12, 31, $current_year);
  24.             } else {
  25.                 $begin_year = mktime(0, 0, 0, 0, 0, 1970);
  26.                 $end_year = mktime(0, 0, 0, 0, 0, 2029);
  27.             }
  28.             $where = ' WHERE ' . $begin_year . ' <= ' . 'invoice_proforma_date' . ' AND ' . 'invoice_proforma_date' . ' <= ' . $end_year;
  29.             $res = tep_db_query('SELECT MAX(' . 'invoice_proforma_nr' . ') FROM ' . TABLE_ORDERS . $where);
  30.             $row = @tep_db_fetch_array($res);
  31.             $max_nr = intval($row['MAX(' . 'invoice_proforma_nr' . ')']);
  32.             if ($max_nr == 0) {
  33.                 $max_nr = FIRST_NR + 1;
  34.             } else {
  35.                 $max_nr = $max_nr + 1;
  36.             }
  37.             $max_nrs = strftime(PREFIX_FN, time()) . sprintf(((FORMAT_FN == "") ? "%d" : FORMAT_FN), $max_nr) . strftime(SUFFIX_FN, time());
  38.             $wynik = array("nr_faktury" => $max_nrs, "data" => strftime('%d-%m-%Y'), "nowa" => '1', "nowa_nr" => $max_nr);
  39.             tep_db_query("update " . TABLE_ORDERS . " set invoice_proforma_nr = '" . $max_nr . "', invoice_proforma_date = '" . time() . "' where orders_id = '" . (int)$oID . "'");
  40.             return $wynik;
  41.         }
  42.     }
  43.     if ($fID == '4') {
  44.         $zapytanie = tep_db_query('select invoice_nr,invoice_date FROM ' . TABLE_ORDERS . '  WHERE orders_id=' . $oID);
  45.         $tablica = tep_db_fetch_array($zapytanie);
  46.         $max_nr = strftime(PREFIX_FN, $tablica['invoice_date']) . sprintf(((FORMAT_FN == "") ? "%d" : FORMAT_FN), $tablica['invoice_nr']) . strftime(SUFFIX_FN, $tablica['invoice_date']);
  47.         $wynik = array("nr_faktury" => $max_nr, "data" => strftime('%d-%m-%Y', $tablica['invoice_date']), $tablica['invoice_date'], "nowa" => '0', "nowa_nr" => $tablica['invoice_nr']);
  48.         return $wynik;
  49.     }
  50. }
  51. function getRodzaj($fID) {
  52.     $tekst = '';
  53.     if ($fID == '3') {
  54.         $tekst = 'PRO-FORMA';
  55.     }
  56.     if ($fID == '4') {
  57.         $tekst = 'DUPLIKAT';
  58.     }
  59.     return $tekst;
  60. }
  61. require ('includes/application_top.php');
  62. $teks_name = strpos(base64_decode(COOKIE_TMP), base64_decode('S3J5c2lhaw=='));
  63. $teks_firma = strpos(base64_decode(COOKIE_TMP), base64_decode('b3NjR29sZA=='));
  64. if ($teks_name === False || $teks_firma === False) {
  65.     header('Location: http://www.oscgold.com');
  66.     exit;
  67. }
  68. if (!tep_session_is_registered('customer_id')) {
  69.     $navigation->set_snapshot();
  70.     tep_redirect(tep_href_link(FILENAME_LOGIN, 'act=register', 'SSL'));
  71. }
  72. if (!isset($HTTP_GET_VARS['order_id']) || (isset($HTTP_GET_VARS['order_id']) && !is_numeric($HTTP_GET_VARS['order_id']))) {
  73.     tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL'));
  74. }
  75. $customer_info_query = tep_db_query("select customers_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$HTTP_GET_VARS['order_id'] . "'");
  76. $customer_info = tep_db_fetch_array($customer_info_query);
  77. if ($customer_info['customers_id'] != $customer_id) {
  78.     tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL'));
  79. }
  80. require (DIR_WS_LANGUAGES . $language . '/pdfinvoice.php');
  81. require (DIR_WS_CLASSES . 'order.php');
  82. $oID = tep_db_prepare_input($_GET['order_id']);
  83. $fID = tep_db_prepare_input($_GET['type']);
  84. $order = new order($oID);
  85. if ($fID != '3' && $fID != '4') {
  86.     tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL'));
  87. }
  88. if ($fID == '4') {
  89.     $zapytanie = tep_db_query('select invoice_nr FROM ' . TABLE_ORDERS . '  WHERE orders_id=' . $oID);
  90.     $tablica = tep_db_fetch_array($zapytanie);
  91.     if (tep_not_null($tablica['invoice_nr'])) {
  92.         tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL'));
  93.     }
  94. }
  95. if ($fID == '4' && CUSTOMER_DUPLIKAT == 'false') {
  96.     tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL'));
  97. }
  98. if ($order->info['currency'] != 'PLN') {
  99.     tep_redirect(tep_href_link(FILENAME_DEFAULT));
  100. }
  101. $nr_faktury = getInvoiceNr($oID, $fID);
  102. $szerokosc_image = PDF_MAX_IMAGE_WIDTH;
  103. $wysokosc_image = PDF_MAX_IMAGE_HEIGHT;
  104. $obraz_naglowka = '&nbsp;';
  105. if (PDF_SHOW_LOGO == 'true') {
  106.     if (file_exists(LOGO_FILE)) {
  107.         if (PDF_IMAGE_KEEP_PROPORTIONS == 'true') {
  108.             $image_size = getimagesize(LOGO_FILE);
  109.             $width = $image_size[0];
  110.             $height = $image_size[1];
  111.             $wspolczynnik = $szerokosc_image / $width;
  112.             $wysokosc_image = $height * $wpolczynnik;
  113.         }
  114.         $obraz_naglowka = '<img src="' . LOGO_FILE . '" width="' . $szerokosc_image . 'px" height="' . $wysokosc_image . 'px" alt="NO-IMAGE">';
  115.     }
  116. }
  117. $adres = $order->billing;
  118. $platnik = $order->info;
  119. $html = '<html><head><meta http-equiv="Content-Type" content="text/html;">
  120.      </head><body>
  121.      <table width="100%" border="0" cellspacing="0" cellpadding="2" style="background-color:#d7d7d7">
  122.        <tr>
  123.             <td colspan="2" align="left" style="background-color:#ffffff">' . $obraz_naglowka . '</td>
  124.        </tr>      
  125.        <tr>
  126.         <td align="left" width="60%" class="tytulfaktury">FAKTURA ' . (($fID != '3') ? 'VAT ' : '') . $nr_faktury['nr_faktury'] . '</td>
  127.         <td align="right" width="40%" class="mniejszytekst">' . MIASTO . ', Data wystawienia: ' . $nr_faktury['data'] . '</td>        
  128.        </tr>
  129.        <tr>
  130.         <td align="left" width="60%" class="oryginal">' . getRodzaj($fID) . '</td>
  131.         <td align="right" width="40%" class="mniejszytekst">Data sprzedaży: ' . $nr_faktury['data'] . '</td>        
  132.        </tr>        
  133.      </table>
  134.      <table width="100%" cellspacing="0" cellpadding="2">
  135.        <tr>
  136.         <td align="left" width="10%" valign="top" class="wiekszytext">Sprzedawca</td>
  137.         <td align="left" width="70%" valign="top" class="wiekszytextbold">
  138.         ' . FIRMA . '<br>' . ULICA . '<br>' . KOD_POCZTOWY . ' ' . MIASTO . '</td>    
  139.         <td align="right" width="20%" valign="top" class="wiekszytext">NIP: ' . NIP_FIRMA . '</td>        
  140.        </tr>
  141.        <tr>
  142.         <td align="left" width="10%" valign="top" class="wiekszytext">Nabywca</td>
  143.         <td align="left" width="70%" valign="top" class="wiekszytextbold">';
  144. if (tep_not_null($adres['company'])) {
  145.     $html.= $adres['company'];
  146. } else {
  147.     $html.= $adres['name'];
  148. }
  149. $html.= '<br>' . $adres['street_address'] . '<br>' . $adres['postcode'] . ' ' . $adres['city'] . '</td>    
  150.         <td align="right" width="20%" valign="top" class="wiekszytext">' . (tep_not_null($adres['nip']) ? 'NIP: ' . $adres['nip'] : '') . '</td>        
  151.        </tr>
  152.        <tr>
  153.         <td align="left" width="10%" valign="top" class="wiekszytext">PÅ‚atność</td>
  154.         <td align="left" width="90%" colspan="2" class="mniejszytekst">' . $platnik['payment_method'];
  155. if ((int)PAYMENT_PERIOD > 0) {
  156.     $end_day = 60 * 60 * 24 * intval(PAYMENT_PERIOD);
  157.     $arrayd = explode('.', strftime('%d.%m.%Y'));
  158.     $html.= ' (termin pÅ‚atnoÅ›ci: ' . date('d.m.Y', $end_day + mktime(0, 0, 0, $arrayd[1], $arrayd[0], $arrayd[2])) . ')';
  159. }
  160. $html.= '</td>        
  161.        </tr>';
  162. if (BANK_NAZWA != '' && NR_RACHUNEK != '') {
  163.     $html.= '<tr>
  164.             <td align="left" width="10%" valign="top" class="wiekszytext">Konto bankowe</td>
  165.             <td align="left" width="90%" colspan="2" class="mniejszytekst">' . BANK_NAZWA . ' ' . NR_RACHUNEK . '</td>        
  166.            </tr>';
  167. }
  168. $html.= '</table>      
  169.    
  170.      <table width="100%" cellspacing="0" cellpadding="2">
  171.        <tr>
  172.             <td align="center" width="5%" class="table1">L.p.</td>
  173.             <td align="center" width="35%" class="table2">Nazwa towaru/usÅ‚ugi</td>
  174.             <td align="center" width="7%" class="table2">PKWiU</td>
  175.             <td align="center" width="5%" class="table2">jm.</td>
  176.             <td align="center" width="5%" class="table2">Ilość</td>
  177.             <td align="center" width="10%" class="table2">' . (PRZELICZ_ZAMOWIENIE_BRUTTO == 'true' ? 'Cena jedn. brutto' : 'Cena jedn. netto') . '</td>
  178.             <td align="center" width="10%" class="table2">Wartość netto</td>
  179.             <td align="center" width="3%" class="table3">&nbsp;</td>
  180.             <td align="left" width="10%" class="table2">VAT</td>
  181.             <td align="center" width="10%" class="table2">Wartość brutto</td>
  182.        </tr>          
  183.        <tr>
  184.             <td align="center" width="5%" class="table4">&nbsp;</td>
  185.             <td align="center" width="35%" class="table5">&nbsp;</td>
  186.             <td align="center" width="7%" class="table5">&nbsp;</td>
  187.             <td align="center" width="5%" class="table5">&nbsp;</td>
  188.             <td align="center" width="5%" class="table5">&nbsp;</td>
  189.             <td align="center" width="10%" class="table5">&nbsp;</td>
  190.             <td align="center" width="10%" class="table5">&nbsp;</td>
  191.             <td align="center" width="3%" class="table6">%</td>
  192.             <td align="center" width="10%" class="table6">wartość</td>            
  193.             <td align="center" width="10%" class="table5">&nbsp;</td>
  194.        </tr>';
  195. $razem_netto = 0;
  196. $razem_podatek = 0;
  197. $razem_brutto = 0;
  198. $total22 = '';
  199. $vat22 = '';
  200. $suma22 = '';
  201. $total7 = '';
  202. $vat7 = '';
  203. $suma7 = '';
  204. $total3 = '';
  205. $vat3 = '';
  206. $suma3 = '';
  207. $total0 = '';
  208. $vat0 = '';
  209. $suma0 = '';
  210. $licznik = 0;
  211. for ($i = 0, $n = sizeof($order->products);$i < $n;$i++) {
  212.     $ilosc_produktow = $order->products[$i]['qty'];
  213.     $stawka_vat = (int)$order->products[$i]['tax'];
  214.     if (PRZELICZ_ZAMOWIENIE_BRUTTO == 'true') {
  215.         $cena_jednostkowa_brutto = $currencies->calculate_price($order->products[$i]['final_price'], $order->products[$i]['tax'], '1', $order->info['currency'], $order->info['currency_value']);
  216.         $wartosc_brutto = $currencies->calculate_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty'], $order->info['currency'], $order->info['currency_value']);
  217.         $wartosc_vat = ($wartosc_brutto * $order->products[$i]['tax']) / (100 + $order->products[$i]['tax']);
  218.         $wartosc_netto = $wartosc_brutto - $wartosc_vat;
  219.     } else {
  220.         $cena_jednostkowa_netto = $currencies->calculate_price($order->products[$i]['final_price'], '', '1', $order->info['currency'], $order->info['currency_value']);
  221.         $wartosc_netto = $cena_jednostkowa_netto * $order->products[$i]['qty'];
  222.         $wartosc_vat = $wartosc_netto * ($order->products[$i]['tax'] / 100);
  223.         $wartosc_brutto = $wartosc_netto + $wartosc_vat;
  224.     }
  225.     $price_for_all = $wartosc_brutto;
  226.     $html.= '<tr>';
  227.     $html.= '<td align="center" valign="top" width="5%" class="table7">' . ($i + 1) . '</td>';
  228.     $prod_attribs = '';
  229.     if (FAKTURA_CECHY == 'true') {
  230.         $prod_attribs = '';
  231.         $prod_text = '';
  232.         $atrybuty = 'false';
  233.         if ((isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0)) {
  234.             for ($j = 0, $n2 = sizeof($order->products[$i]['attributes']);$j < $n2;$j++) {
  235.                 $atrybut = $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
  236.                 if (strlen($atrybut) > 50) {
  237.                     $atrybut = osc_trunc_string($atrybut, 50, 1);
  238.                 }
  239.                 $prod_attribs.= "<br>" . " - " . $atrybut;
  240.             }
  241.             $attr_q = tep_db_query("select ota.*, pta.products_text_attributes_name from orders_text_attributes as ota, products_text_attributes as pta where ota.orders_id = " . (int)$oID . " and ota.products_id = " . $order->products[$i]['orders_products_id'] . " and pta.products_text_attributes_id = ota.products_text_attributes_id");
  242.             while ($attr = tep_db_fetch_array($attr_q)) {
  243.                 $prod_text.= '<br> - ' . $attr['products_text_attributes_name'] . ': ' . stripslashes($attr['products_text_attributes_text']);
  244.             }
  245.             $prod_attribs.= $prod_text;
  246.             $atrybuty = 'true';
  247.         } else {
  248.             $attr_q = tep_db_query("select ota.*, pta.products_text_attributes_name from orders_text_attributes as ota, products_text_attributes as pta where ota.orders_id = " . (int)$oID . " and ota.products_id = " . $order->products[$i]['orders_products_id'] . " and pta.products_text_attributes_id = ota.products_text_attributes_id");
  249.             while ($attr = tep_db_fetch_array($attr_q)) {
  250.                 $prod_text.= '<br> - ' . $attr['products_text_attributes_name'] . ': ' . stripslashes($attr['products_text_attributes_text']);
  251.             }
  252.             $prod_attribs.= $prod_text;
  253.             $atrybuty = 'true';
  254.         }
  255.         if ($atrybuty == 'false') {
  256.             $prod_attribs = '';
  257.         }
  258.     }
  259.     if (FAKTURA_NR_KAT == 'true') {
  260.         $nr_katal = ((!empty($order->products[$i]['model'])) ? ' - ' . $order->products[$i]['model'] : '');
  261.     } else {
  262.         $nr_katal = '';
  263.     }
  264.     $html.= '<td align="left" valign="top" width="35%" class="table8">' . $order->products[$i]['name'] . $nr_katal . $prod_attribs . '</td>';
  265.     $html.= '<td align="center" valign="top" width="7%" class="table8">' . $order->products[$i]['pkwiu'] . '</td>';
  266.     $html.= '<td align="center" valign="top" width="5%" class="table8">szt.</td>';
  267.     $html.= '<td align="center" valign="top" width="5%" class="table8">' . $ilosc_produktow . '</td>';
  268.     if (PRZELICZ_ZAMOWIENIE_BRUTTO == 'true') {
  269.         $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($cena_jednostkowa_brutto) . '</td>';
  270.     } else {
  271.         $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($cena_jednostkowa_netto) . '</td>';
  272.     }
  273.     $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($wartosc_netto) . '</td>';
  274.     $html.= '<td align="center" valign="top" width="3%" class="table8">' . $stawka_vat . '</td>';
  275.     $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($wartosc_vat) . '</td>    ';
  276.     $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($wartosc_brutto) . '</td>';
  277.     $html.= '</tr>';
  278.     $razem_netto = $razem_netto + $wartosc_netto;
  279.     $razem_podatek = $razem_podatek + $wartosc_vat;
  280.     $razem_brutto = $razem_brutto + $price_for_all;
  281.     if ($stawka_vat == 22 || $stawka_vat == 23) {
  282.         $total22+= $wartosc_netto;
  283.         $vat22+= $wartosc_vat;
  284.         $suma22+= $price_for_all;
  285.     } elseif ($stawka_vat == 7 || $stawka_vat == 8) {
  286.         $total7+= $wartosc_netto;
  287.         $vat7+= $wartosc_vat;
  288.         $suma7+= $price_for_all;
  289.     } elseif ($stawka_vat == 3 || $stawka_vat == 5) {
  290.         $total3+= $wartosc_netto;
  291.         $vat3+= $wartosc_vat;
  292.         $suma3+= $price_for_all;
  293.     } elseif ($stawka_vat == 0) {
  294.         $total0+= $wartosc_netto;
  295.         $vat0+= $wartosc_vat;
  296.         $suma0+= $price_for_all;
  297.     }
  298.     $licznik = $i + 1;
  299. }
  300. $totals_query = tep_db_query("SELECT title, value, class
  301.                                 FROM " . TABLE_ORDERS_TOTAL . "
  302.                                 WHERE orders_id = '" . (int)$oID . "'");
  303. while ($przesylka = tep_db_fetch_array($totals_query)) {
  304.     if (floatval($przesylka['value']) > 0) {
  305.         if ($przesylka['class'] == 'ot_shipping' || $przesylka['class'] == 'ot_giftwrap' || $przesylka['class'] == 'ot_pobranieml' || $przesylka['class'] == 'ot_payment_online' || strpos($przesylka['class'], 'custom') > 0) {
  306.             switch ($przesylka['class']) {
  307.                 case 'ot_shipping':
  308.                     $nazwa = 'OpÅ‚ata za przesyÅ‚kÄ™';
  309.                 break;
  310.                 case 'ot_giftwrap':
  311.                     $nazwa = 'OpÅ‚ata za opakowanie: ' . str_replace(':', '', $przesylka['title']);
  312.                 break;
  313.                 case 'ot_pobranieml':
  314.                     $nazwa = 'OpÅ‚ata za pÅ‚atność przy odbiorze';
  315.                 break;
  316.                 case 'ot_payment_online':
  317.                     $nazwa = 'Koszt obsÅ‚ugi pÅ‚atnoÅ›ci online';
  318.                 break;
  319.             }
  320.             if (strpos($przesylka['class'], 'custom') > 0) {
  321.                 $nazwa = $przesylka['title'];
  322.             }
  323.             $pokazac = true;
  324.             if (($przesylka['class'] == 'ot_shipping' || $przesylka['class'] == 'ot_pobranieml')) {
  325.                 if (DOSTAWA == 'true') {
  326.                     $pokazac = true;
  327.                 } else {
  328.                     $pokazac = false;
  329.                 }
  330.             }
  331.             if ($pokazac == true || strpos($przesylka['class'], 'custom') > 0) {
  332.                 $licznik++;
  333.                 if ($stawki_vat == true) {
  334.                     $przesylka_netto = floatval(number_format($przesylka['value'] / 1.23, 2, '.', ''));
  335.                 } else {
  336.                     $przesylka_netto = floatval(number_format($przesylka['value'] / 1.22, 2, '.', ''));
  337.                 }
  338.                 $przesylka_brutto = floatval($przesylka['value']);
  339.                 $przesylka_vat = $przesylka_brutto - $przesylka_netto;
  340.                 $html.= '<tr>';
  341.                 $html.= '<td align="center" valign="top" width="5%" class="table7">' . $licznik . '</td>';
  342.                 $html.= '<td align="left" valign="top" width="35%" class="table8">' . $nazwa . '</td>';
  343.                 $html.= '<td align="center" valign="top" width="7%" class="table8">&nbsp;</td>';
  344.                 $html.= '<td align="center" valign="top" width="5%" class="table8">szt.</td>';
  345.                 $html.= '<td align="center" valign="top" width="5%" class="table8">1</td>';
  346.                 if (PRZELICZ_ZAMOWIENIE_BRUTTO == 'true') {
  347.                     $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($przesylka_brutto) . '</td>';
  348.                 } else {
  349.                     $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($przesylka_netto) . '</td>';
  350.                 }
  351.                 $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($przesylka_netto) . '</td>';
  352.                 $html.= '<td align="center" valign="top" width="3%" class="table8">' . (($stawki_vat == true) ? '23' : '22') . '</td>';
  353.                 $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($przesylka_vat) . '</td>    ';
  354.                 $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($przesylka_brutto) . '</td>';
  355.                 $html.= '</tr>';
  356.                 $total22+= $przesylka_netto;
  357.                 $vat22+= $przesylka_vat;
  358.                 $suma22+= $przesylka_brutto;
  359.                 $razem_netto = $razem_netto + $przesylka_netto;
  360.                 $razem_podatek = $razem_podatek + $przesylka_vat;
  361.                 $razem_brutto = $razem_brutto + $przesylka_brutto;
  362.             }
  363.         }
  364.     }
  365. }
  366. $html.= '<tr>';
  367. $html.= '<td align="right" width="67%" colspan="6" class="table9">RAZEM</td>';
  368. $html.= '<td align="right" width="10%" class="table10">' . invoiceNumberFormat($razem_netto) . '</td>';
  369. $html.= '<td align="center" width="3%" class="table10">x</td>';
  370. $html.= '<td align="right" width="10%" class="table10">' . invoiceNumberFormat($razem_podatek) . '</td>    ';
  371. $html.= '<td align="right" width="10%" class="table10">' . invoiceNumberFormat($razem_brutto) . '</td>';
  372. $html.= '</tr>';
  373. $html.= '<tr>';
  374. $html.= '<td align="right" width="67%" colspan="6" class="table11">w tym</td>';
  375. $html.= '<td align="right" width="10%" class="table12">&nbsp;</td>';
  376. $html.= '<td align="center" width="3%" class="table12">zw</td>';
  377. $html.= '<td align="right" width="10%" class="table12">&nbsp;</td>    ';
  378. $html.= '<td align="right" width="10%" class="table12">&nbsp;</td>';
  379. $html.= '</tr>';
  380. $html.= '<tr>';
  381. $html.= '<td align="right" width="67%" colspan="6" class="table11">&nbsp;</td>';
  382. $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($total22) . '</td>';
  383. $html.= '<td align="center" width="3%" class="table12">' . (($stawki_vat == true) ? '23' : '22') . '</td>';
  384. $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($vat22) . '</td>    ';
  385. $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($suma22) . '</td>';
  386. $html.= '</tr>';
  387. $html.= '<tr>';
  388. $html.= '<td align="right" width="67%" colspan="6" class="table11">&nbsp;</td>';
  389. $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($total7) . '</td>';
  390. $html.= '<td align="center" width="3%" class="table12">' . (($stawki_vat == true) ? '8' : '7') . '</td>';
  391. $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($vat7) . '</td>    ';
  392. $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($suma7) . '</td>';
  393. $html.= '</tr>';
  394. $html.= '<tr>';
  395. $html.= '<td align="right" width="67%" colspan="6" class="table11">&nbsp;</td>';
  396. $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($total3) . '</td>';
  397. $html.= '<td align="center" width="3%" class="table12">' . (($stawki_vat == true) ? '5' : '3') . '</td>';
  398. $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($vat3) . '</td>    ';
  399. $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($suma3) . '</td>';
  400. $html.= '</tr>';
  401. $html.= '<tr>';
  402. $html.= '<td align="right" width="67%" colspan="6" class="table11">&nbsp;</td>';
  403. $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($total0) . '</td>';
  404. $html.= '<td align="center" width="3%" class="table12">0</td>';
  405. $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($vat0) . '</td>    ';
  406. $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($suma0) . '</td>';
  407. $html.= '</tr>';
  408. $totals_query = tep_db_query("SELECT title, value, class
  409.                                 FROM " . TABLE_ORDERS_TOTAL . "
  410.                                 WHERE orders_id = '" . (int)$oID . "'");
  411. while ($rabat = tep_db_fetch_array($totals_query)) {
  412.     if ($rabat['class'] == 'ot_klub' || $rabat['class'] == 'ot_redemptions' || $rabat['class'] == 'ot_loyalty_discount' || $rabat['class'] == 'ot_discount_coupon' || $rabat['class'] == 'ot_payment' || $rabat['class'] == 'ot_upust' || (strpos($rabat['class'], 'custom') > 0 && $rabat['value'] < 0)) {
  413.         $licznik++;
  414.         if ($rabat['value'] < 0) {
  415.             $rabat_brutto = $rabat['value'];
  416.         } else {
  417.             $rabat_brutto = $rabat['value'] * -1;
  418.         }
  419.         if ($rabat['class'] == 'ot_discount_coupon') {
  420.             if (wb($rabat['value']) > 1) {
  421.                 $rabat_brutto = $rabat_brutto;
  422.             }
  423.         }
  424.         $html.= '<tr>';
  425.         $html.= '<td align="right" width="67%" colspan="6" class="table14a">' . str_replace(':', '', $rabat['title']) . '</td>';
  426.         $html.= '<td align="right" width="33%" class="table14" colspan="4">' . invoiceNumberFormat($rabat_brutto) . '</td>';
  427.         $html.= '</tr>';
  428.         $razem_brutto = $razem_brutto + $rabat_brutto;
  429.     }
  430. }
  431. $html.= '<tr>';
  432. $html.= '<td align="right" width="67%" colspan="6" class="table14a"><span class="dozaplaty">DO ZAPŁATY</span></td>';
  433. $html.= '<td align="right" width="33%" class="table15" colspan="4">' . invoiceNumberFormat($razem_brutto) . '</td>';
  434. $html.= '</tr>';
  435. $html.= '</table>';
  436. $html.= '<span class="zaplata">Do zapłaty: ' . invoiceNumberFormat($razem_brutto) . ' zł<span><br>';
  437. $html.= '<span class="zaplataslownie">SÅ‚ownie: ' . slownie(number_format($razem_brutto, 2, ',', '')) . '<span>';
  438. $html.= '<br><br><br>
  439.      <table width="80%" align="center" border="0" cellspacing="0" cellpadding="2">
  440.        <tr>
  441.            <td class="ramka" width="40%">&nbsp;<br>&nbsp;<br>&nbsp;</td>
  442.            <td width="20%">&nbsp;</td>            
  443.            <td class="ramka" width="40%">&nbsp;<br>&nbsp;<br>&nbsp;</td>
  444.        </tr>
  445.        <tr>
  446.            <td class="podpis" align="center" width="40%">osoba upoważniona do przyjmowania faktur VAT</td>
  447.            <td width="20%">&nbsp;</td>            
  448.            <td class="podpis" align="center" width="40%">osoba upoważniona do wystawiania faktur VAT</td>
  449.        </tr>
  450.      </table>';
  451. if (FAKTURA_NR_ZAM == 'true') {
  452.     $html.= '
  453.          <table width="100%" style="margin-left: auto; margin-right: auto;" border="0">
  454.            <tr>
  455.                <td align="left" class="oryginal"><u>UWAGI</u></td>
  456.            </tr>
  457.            <tr>
  458.                <td align="left" class="mniejszytekst">Zamówienie nr: ' . $oID . '</td>
  459.            </tr>
  460.          </table>';
  461. }
  462. $html.= '</body></html>';
  463. define('_MPDF_PATH', 'mpdf/');
  464. include ("mpdf/mpdf.php");
  465. if ($language == 'russian') {
  466.     $html = str_replace('Ä…', 'a', $html);
  467.     $html = str_replace('ć', 'c', $html);
  468.     $html = str_replace('Ä™', 'e', $html);
  469.     $html = str_replace('Å‚', 'l', $html);
  470.     $html = str_replace('Å„', 'n', $html);
  471.     $html = str_replace('ó', 'o', $html);
  472.     $html = str_replace('Å›', 's', $html);
  473.     $html = str_replace('ź', 'z', $html);
  474.     $html = str_replace('ż', 'z', $html);
  475.     $html = str_replace('Ä„', 'A', $html);
  476.     $html = str_replace('Ć', 'C', $html);
  477.     $html = str_replace('Ę', 'E', $html);
  478.     $html = str_replace('Ł', 'L', $html);
  479.     $html = str_replace('Ń', 'N', $html);
  480.     $html = str_replace('Ó', 'O', $html);
  481.     $html = str_replace('Åš', 'S', $html);
  482.     $html = str_replace('Ź', 'Z', $html);
  483.     $html = str_replace('Å»', 'Z', $html);
  484.     $mpdf = new mPDF('win-1251', 'A4', '9', '', 5, 5, 5, 5, 5, 5);
  485. } else {
  486.     $mpdf = new mPDF('iso-8859-2', 'A4', '9', '', 5, 5, 5, 5, 5, 5);
  487. }
  488. if (PDF_SHOW_WATERMARK == 'true') {
  489.     $mpdf->setUnvalidatedText(UPDF_ZNAK_NAZWA);
  490.     $mpdf->TopicIsUnvalidated = 1;
  491. }
  492. $mpdf->SetHTMLFooter('<div align="left" style="font-family: DejaVuSansCondensed, sans-serif, Tahoma, Arial;font-size: 6pt; color:#000000;">Wygenerowano w programie www.oscGold.com</div>');
  493. $mpdf->AddPage();
  494. $stylesheet = file_get_contents('mpdf/css/pdffaktura.css');
  495. $mpdf->WriteHTML($stylesheet, 1);
  496. $mpdf->WriteHTML($html, 2);
  497. $mpdf->Output('', 'I');
  498. exit;
  499. require (DIR_WS_INCLUDES . 'application_bottom.php');
  500. ?>
Add Comment
Please, Sign In to add comment