Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $rok = date('Y');
- if ($rok == '2010') {
- $stawki_vat = false;
- } else {
- $stawki_vat = true;
- }
- function wb($liczba) {
- return ($liczba > 0) ? $liczba : $liczba * (-1);
- }
- function getInvoiceNr($oID, $fID) {
- if ($fID == '3') {
- $zapytanie = tep_db_query('select invoice_proforma_nr,invoice_proforma_date FROM ' . TABLE_ORDERS . ' WHERE orders_id=' . $oID);
- $tablica = tep_db_fetch_array($zapytanie);
- if ($tablica['invoice_proforma_nr'] > 0) {
- $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']);
- $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']);
- return $wynik;
- } else {
- if (CONTINUE_NUMERATION == 'false') {
- $current_year = date('Y', time());
- $begin_year = mktime(0, 0, 0, 1, 1, $current_year);
- $end_year = mktime(0, 0, 0, 12, 31, $current_year);
- } else {
- $begin_year = mktime(0, 0, 0, 0, 0, 1970);
- $end_year = mktime(0, 0, 0, 0, 0, 2029);
- }
- $where = ' WHERE ' . $begin_year . ' <= ' . 'invoice_proforma_date' . ' AND ' . 'invoice_proforma_date' . ' <= ' . $end_year;
- $res = tep_db_query('SELECT MAX(' . 'invoice_proforma_nr' . ') FROM ' . TABLE_ORDERS . $where);
- $row = @tep_db_fetch_array($res);
- $max_nr = intval($row['MAX(' . 'invoice_proforma_nr' . ')']);
- if ($max_nr == 0) {
- $max_nr = FIRST_NR + 1;
- } else {
- $max_nr = $max_nr + 1;
- }
- $max_nrs = strftime(PREFIX_FN, time()) . sprintf(((FORMAT_FN == "") ? "%d" : FORMAT_FN), $max_nr) . strftime(SUFFIX_FN, time());
- $wynik = array("nr_faktury" => $max_nrs, "data" => strftime('%d-%m-%Y'), "nowa" => '1', "nowa_nr" => $max_nr);
- tep_db_query("update " . TABLE_ORDERS . " set invoice_proforma_nr = '" . $max_nr . "', invoice_proforma_date = '" . time() . "' where orders_id = '" . (int)$oID . "'");
- return $wynik;
- }
- }
- if ($fID == '4') {
- $zapytanie = tep_db_query('select invoice_nr,invoice_date FROM ' . TABLE_ORDERS . ' WHERE orders_id=' . $oID);
- $tablica = tep_db_fetch_array($zapytanie);
- $max_nr = strftime(PREFIX_FN, $tablica['invoice_date']) . sprintf(((FORMAT_FN == "") ? "%d" : FORMAT_FN), $tablica['invoice_nr']) . strftime(SUFFIX_FN, $tablica['invoice_date']);
- $wynik = array("nr_faktury" => $max_nr, "data" => strftime('%d-%m-%Y', $tablica['invoice_date']), $tablica['invoice_date'], "nowa" => '0', "nowa_nr" => $tablica['invoice_nr']);
- return $wynik;
- }
- }
- function getRodzaj($fID) {
- $tekst = '';
- if ($fID == '3') {
- $tekst = 'PRO-FORMA';
- }
- if ($fID == '4') {
- $tekst = 'DUPLIKAT';
- }
- return $tekst;
- }
- require ('includes/application_top.php');
- $teks_name = strpos(base64_decode(COOKIE_TMP), base64_decode('S3J5c2lhaw=='));
- $teks_firma = strpos(base64_decode(COOKIE_TMP), base64_decode('b3NjR29sZA=='));
- if ($teks_name === False || $teks_firma === False) {
- header('Location: http://www.oscgold.com');
- exit;
- }
- if (!tep_session_is_registered('customer_id')) {
- $navigation->set_snapshot();
- tep_redirect(tep_href_link(FILENAME_LOGIN, 'act=register', 'SSL'));
- }
- if (!isset($HTTP_GET_VARS['order_id']) || (isset($HTTP_GET_VARS['order_id']) && !is_numeric($HTTP_GET_VARS['order_id']))) {
- tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL'));
- }
- $customer_info_query = tep_db_query("select customers_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$HTTP_GET_VARS['order_id'] . "'");
- $customer_info = tep_db_fetch_array($customer_info_query);
- if ($customer_info['customers_id'] != $customer_id) {
- tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL'));
- }
- require (DIR_WS_LANGUAGES . $language . '/pdfinvoice.php');
- require (DIR_WS_CLASSES . 'order.php');
- $oID = tep_db_prepare_input($_GET['order_id']);
- $fID = tep_db_prepare_input($_GET['type']);
- $order = new order($oID);
- if ($fID != '3' && $fID != '4') {
- tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL'));
- }
- if ($fID == '4') {
- $zapytanie = tep_db_query('select invoice_nr FROM ' . TABLE_ORDERS . ' WHERE orders_id=' . $oID);
- $tablica = tep_db_fetch_array($zapytanie);
- if (tep_not_null($tablica['invoice_nr'])) {
- tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL'));
- }
- }
- if ($fID == '4' && CUSTOMER_DUPLIKAT == 'false') {
- tep_redirect(tep_href_link(FILENAME_ACCOUNT_HISTORY, '', 'SSL'));
- }
- if ($order->info['currency'] != 'PLN') {
- tep_redirect(tep_href_link(FILENAME_DEFAULT));
- }
- $nr_faktury = getInvoiceNr($oID, $fID);
- $szerokosc_image = PDF_MAX_IMAGE_WIDTH;
- $wysokosc_image = PDF_MAX_IMAGE_HEIGHT;
- $obraz_naglowka = ' ';
- if (PDF_SHOW_LOGO == 'true') {
- if (file_exists(LOGO_FILE)) {
- if (PDF_IMAGE_KEEP_PROPORTIONS == 'true') {
- $image_size = getimagesize(LOGO_FILE);
- $width = $image_size[0];
- $height = $image_size[1];
- $wspolczynnik = $szerokosc_image / $width;
- $wysokosc_image = $height * $wpolczynnik;
- }
- $obraz_naglowka = '<img src="' . LOGO_FILE . '" width="' . $szerokosc_image . 'px" height="' . $wysokosc_image . 'px" alt="NO-IMAGE">';
- }
- }
- $adres = $order->billing;
- $platnik = $order->info;
- $html = '<html><head><meta http-equiv="Content-Type" content="text/html;">
- </head><body>
- <table width="100%" border="0" cellspacing="0" cellpadding="2" style="background-color:#d7d7d7">
- <tr>
- <td colspan="2" align="left" style="background-color:#ffffff">' . $obraz_naglowka . '</td>
- </tr>
- <tr>
- <td align="left" width="60%" class="tytulfaktury">FAKTURA ' . (($fID != '3') ? 'VAT ' : '') . $nr_faktury['nr_faktury'] . '</td>
- <td align="right" width="40%" class="mniejszytekst">' . MIASTO . ', Data wystawienia: ' . $nr_faktury['data'] . '</td>
- </tr>
- <tr>
- <td align="left" width="60%" class="oryginal">' . getRodzaj($fID) . '</td>
- <td align="right" width="40%" class="mniejszytekst">Data sprzedaży: ' . $nr_faktury['data'] . '</td>
- </tr>
- </table>
- <table width="100%" cellspacing="0" cellpadding="2">
- <tr>
- <td align="left" width="10%" valign="top" class="wiekszytext">Sprzedawca</td>
- <td align="left" width="70%" valign="top" class="wiekszytextbold">
- ' . FIRMA . '<br>' . ULICA . '<br>' . KOD_POCZTOWY . ' ' . MIASTO . '</td>
- <td align="right" width="20%" valign="top" class="wiekszytext">NIP: ' . NIP_FIRMA . '</td>
- </tr>
- <tr>
- <td align="left" width="10%" valign="top" class="wiekszytext">Nabywca</td>
- <td align="left" width="70%" valign="top" class="wiekszytextbold">';
- if (tep_not_null($adres['company'])) {
- $html.= $adres['company'];
- } else {
- $html.= $adres['name'];
- }
- $html.= '<br>' . $adres['street_address'] . '<br>' . $adres['postcode'] . ' ' . $adres['city'] . '</td>
- <td align="right" width="20%" valign="top" class="wiekszytext">' . (tep_not_null($adres['nip']) ? 'NIP: ' . $adres['nip'] : '') . '</td>
- </tr>
- <tr>
- <td align="left" width="10%" valign="top" class="wiekszytext">Płatność</td>
- <td align="left" width="90%" colspan="2" class="mniejszytekst">' . $platnik['payment_method'];
- if ((int)PAYMENT_PERIOD > 0) {
- $end_day = 60 * 60 * 24 * intval(PAYMENT_PERIOD);
- $arrayd = explode('.', strftime('%d.%m.%Y'));
- $html.= ' (termin płatności: ' . date('d.m.Y', $end_day + mktime(0, 0, 0, $arrayd[1], $arrayd[0], $arrayd[2])) . ')';
- }
- $html.= '</td>
- </tr>';
- if (BANK_NAZWA != '' && NR_RACHUNEK != '') {
- $html.= '<tr>
- <td align="left" width="10%" valign="top" class="wiekszytext">Konto bankowe</td>
- <td align="left" width="90%" colspan="2" class="mniejszytekst">' . BANK_NAZWA . ' ' . NR_RACHUNEK . '</td>
- </tr>';
- }
- $html.= '</table>
- <table width="100%" cellspacing="0" cellpadding="2">
- <tr>
- <td align="center" width="5%" class="table1">L.p.</td>
- <td align="center" width="35%" class="table2">Nazwa towaru/usługi</td>
- <td align="center" width="7%" class="table2">PKWiU</td>
- <td align="center" width="5%" class="table2">jm.</td>
- <td align="center" width="5%" class="table2">Ilość</td>
- <td align="center" width="10%" class="table2">' . (PRZELICZ_ZAMOWIENIE_BRUTTO == 'true' ? 'Cena jedn. brutto' : 'Cena jedn. netto') . '</td>
- <td align="center" width="10%" class="table2">Wartość netto</td>
- <td align="center" width="3%" class="table3"> </td>
- <td align="left" width="10%" class="table2">VAT</td>
- <td align="center" width="10%" class="table2">Wartość brutto</td>
- </tr>
- <tr>
- <td align="center" width="5%" class="table4"> </td>
- <td align="center" width="35%" class="table5"> </td>
- <td align="center" width="7%" class="table5"> </td>
- <td align="center" width="5%" class="table5"> </td>
- <td align="center" width="5%" class="table5"> </td>
- <td align="center" width="10%" class="table5"> </td>
- <td align="center" width="10%" class="table5"> </td>
- <td align="center" width="3%" class="table6">%</td>
- <td align="center" width="10%" class="table6">wartość</td>
- <td align="center" width="10%" class="table5"> </td>
- </tr>';
- $razem_netto = 0;
- $razem_podatek = 0;
- $razem_brutto = 0;
- $total22 = '';
- $vat22 = '';
- $suma22 = '';
- $total7 = '';
- $vat7 = '';
- $suma7 = '';
- $total3 = '';
- $vat3 = '';
- $suma3 = '';
- $total0 = '';
- $vat0 = '';
- $suma0 = '';
- $licznik = 0;
- for ($i = 0, $n = sizeof($order->products);$i < $n;$i++) {
- $ilosc_produktow = $order->products[$i]['qty'];
- $stawka_vat = (int)$order->products[$i]['tax'];
- if (PRZELICZ_ZAMOWIENIE_BRUTTO == 'true') {
- $cena_jednostkowa_brutto = $currencies->calculate_price($order->products[$i]['final_price'], $order->products[$i]['tax'], '1', $order->info['currency'], $order->info['currency_value']);
- $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']);
- $wartosc_vat = ($wartosc_brutto * $order->products[$i]['tax']) / (100 + $order->products[$i]['tax']);
- $wartosc_netto = $wartosc_brutto - $wartosc_vat;
- } else {
- $cena_jednostkowa_netto = $currencies->calculate_price($order->products[$i]['final_price'], '', '1', $order->info['currency'], $order->info['currency_value']);
- $wartosc_netto = $cena_jednostkowa_netto * $order->products[$i]['qty'];
- $wartosc_vat = $wartosc_netto * ($order->products[$i]['tax'] / 100);
- $wartosc_brutto = $wartosc_netto + $wartosc_vat;
- }
- $price_for_all = $wartosc_brutto;
- $html.= '<tr>';
- $html.= '<td align="center" valign="top" width="5%" class="table7">' . ($i + 1) . '</td>';
- $prod_attribs = '';
- if (FAKTURA_CECHY == 'true') {
- $prod_attribs = '';
- $prod_text = '';
- $atrybuty = 'false';
- if ((isset($order->products[$i]['attributes'])) && (sizeof($order->products[$i]['attributes']) > 0)) {
- for ($j = 0, $n2 = sizeof($order->products[$i]['attributes']);$j < $n2;$j++) {
- $atrybut = $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
- if (strlen($atrybut) > 50) {
- $atrybut = osc_trunc_string($atrybut, 50, 1);
- }
- $prod_attribs.= "<br>" . " - " . $atrybut;
- }
- $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");
- while ($attr = tep_db_fetch_array($attr_q)) {
- $prod_text.= '<br> - ' . $attr['products_text_attributes_name'] . ': ' . stripslashes($attr['products_text_attributes_text']);
- }
- $prod_attribs.= $prod_text;
- $atrybuty = 'true';
- } else {
- $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");
- while ($attr = tep_db_fetch_array($attr_q)) {
- $prod_text.= '<br> - ' . $attr['products_text_attributes_name'] . ': ' . stripslashes($attr['products_text_attributes_text']);
- }
- $prod_attribs.= $prod_text;
- $atrybuty = 'true';
- }
- if ($atrybuty == 'false') {
- $prod_attribs = '';
- }
- }
- if (FAKTURA_NR_KAT == 'true') {
- $nr_katal = ((!empty($order->products[$i]['model'])) ? ' - ' . $order->products[$i]['model'] : '');
- } else {
- $nr_katal = '';
- }
- $html.= '<td align="left" valign="top" width="35%" class="table8">' . $order->products[$i]['name'] . $nr_katal . $prod_attribs . '</td>';
- $html.= '<td align="center" valign="top" width="7%" class="table8">' . $order->products[$i]['pkwiu'] . '</td>';
- $html.= '<td align="center" valign="top" width="5%" class="table8">szt.</td>';
- $html.= '<td align="center" valign="top" width="5%" class="table8">' . $ilosc_produktow . '</td>';
- if (PRZELICZ_ZAMOWIENIE_BRUTTO == 'true') {
- $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($cena_jednostkowa_brutto) . '</td>';
- } else {
- $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($cena_jednostkowa_netto) . '</td>';
- }
- $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($wartosc_netto) . '</td>';
- $html.= '<td align="center" valign="top" width="3%" class="table8">' . $stawka_vat . '</td>';
- $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($wartosc_vat) . '</td> ';
- $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($wartosc_brutto) . '</td>';
- $html.= '</tr>';
- $razem_netto = $razem_netto + $wartosc_netto;
- $razem_podatek = $razem_podatek + $wartosc_vat;
- $razem_brutto = $razem_brutto + $price_for_all;
- if ($stawka_vat == 22 || $stawka_vat == 23) {
- $total22+= $wartosc_netto;
- $vat22+= $wartosc_vat;
- $suma22+= $price_for_all;
- } elseif ($stawka_vat == 7 || $stawka_vat == 8) {
- $total7+= $wartosc_netto;
- $vat7+= $wartosc_vat;
- $suma7+= $price_for_all;
- } elseif ($stawka_vat == 3 || $stawka_vat == 5) {
- $total3+= $wartosc_netto;
- $vat3+= $wartosc_vat;
- $suma3+= $price_for_all;
- } elseif ($stawka_vat == 0) {
- $total0+= $wartosc_netto;
- $vat0+= $wartosc_vat;
- $suma0+= $price_for_all;
- }
- $licznik = $i + 1;
- }
- $totals_query = tep_db_query("SELECT title, value, class
- FROM " . TABLE_ORDERS_TOTAL . "
- WHERE orders_id = '" . (int)$oID . "'");
- while ($przesylka = tep_db_fetch_array($totals_query)) {
- if (floatval($przesylka['value']) > 0) {
- if ($przesylka['class'] == 'ot_shipping' || $przesylka['class'] == 'ot_giftwrap' || $przesylka['class'] == 'ot_pobranieml' || $przesylka['class'] == 'ot_payment_online' || strpos($przesylka['class'], 'custom') > 0) {
- switch ($przesylka['class']) {
- case 'ot_shipping':
- $nazwa = 'Opłata za przesyłkę';
- break;
- case 'ot_giftwrap':
- $nazwa = 'Opłata za opakowanie: ' . str_replace(':', '', $przesylka['title']);
- break;
- case 'ot_pobranieml':
- $nazwa = 'Opłata za płatność przy odbiorze';
- break;
- case 'ot_payment_online':
- $nazwa = 'Koszt obsługi płatności online';
- break;
- }
- if (strpos($przesylka['class'], 'custom') > 0) {
- $nazwa = $przesylka['title'];
- }
- $pokazac = true;
- if (($przesylka['class'] == 'ot_shipping' || $przesylka['class'] == 'ot_pobranieml')) {
- if (DOSTAWA == 'true') {
- $pokazac = true;
- } else {
- $pokazac = false;
- }
- }
- if ($pokazac == true || strpos($przesylka['class'], 'custom') > 0) {
- $licznik++;
- if ($stawki_vat == true) {
- $przesylka_netto = floatval(number_format($przesylka['value'] / 1.23, 2, '.', ''));
- } else {
- $przesylka_netto = floatval(number_format($przesylka['value'] / 1.22, 2, '.', ''));
- }
- $przesylka_brutto = floatval($przesylka['value']);
- $przesylka_vat = $przesylka_brutto - $przesylka_netto;
- $html.= '<tr>';
- $html.= '<td align="center" valign="top" width="5%" class="table7">' . $licznik . '</td>';
- $html.= '<td align="left" valign="top" width="35%" class="table8">' . $nazwa . '</td>';
- $html.= '<td align="center" valign="top" width="7%" class="table8"> </td>';
- $html.= '<td align="center" valign="top" width="5%" class="table8">szt.</td>';
- $html.= '<td align="center" valign="top" width="5%" class="table8">1</td>';
- if (PRZELICZ_ZAMOWIENIE_BRUTTO == 'true') {
- $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($przesylka_brutto) . '</td>';
- } else {
- $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($przesylka_netto) . '</td>';
- }
- $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($przesylka_netto) . '</td>';
- $html.= '<td align="center" valign="top" width="3%" class="table8">' . (($stawki_vat == true) ? '23' : '22') . '</td>';
- $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($przesylka_vat) . '</td> ';
- $html.= '<td align="right" valign="top" width="10%" class="table8">' . invoiceNumberFormat($przesylka_brutto) . '</td>';
- $html.= '</tr>';
- $total22+= $przesylka_netto;
- $vat22+= $przesylka_vat;
- $suma22+= $przesylka_brutto;
- $razem_netto = $razem_netto + $przesylka_netto;
- $razem_podatek = $razem_podatek + $przesylka_vat;
- $razem_brutto = $razem_brutto + $przesylka_brutto;
- }
- }
- }
- }
- $html.= '<tr>';
- $html.= '<td align="right" width="67%" colspan="6" class="table9">RAZEM</td>';
- $html.= '<td align="right" width="10%" class="table10">' . invoiceNumberFormat($razem_netto) . '</td>';
- $html.= '<td align="center" width="3%" class="table10">x</td>';
- $html.= '<td align="right" width="10%" class="table10">' . invoiceNumberFormat($razem_podatek) . '</td> ';
- $html.= '<td align="right" width="10%" class="table10">' . invoiceNumberFormat($razem_brutto) . '</td>';
- $html.= '</tr>';
- $html.= '<tr>';
- $html.= '<td align="right" width="67%" colspan="6" class="table11">w tym</td>';
- $html.= '<td align="right" width="10%" class="table12"> </td>';
- $html.= '<td align="center" width="3%" class="table12">zw</td>';
- $html.= '<td align="right" width="10%" class="table12"> </td> ';
- $html.= '<td align="right" width="10%" class="table12"> </td>';
- $html.= '</tr>';
- $html.= '<tr>';
- $html.= '<td align="right" width="67%" colspan="6" class="table11"> </td>';
- $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($total22) . '</td>';
- $html.= '<td align="center" width="3%" class="table12">' . (($stawki_vat == true) ? '23' : '22') . '</td>';
- $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($vat22) . '</td> ';
- $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($suma22) . '</td>';
- $html.= '</tr>';
- $html.= '<tr>';
- $html.= '<td align="right" width="67%" colspan="6" class="table11"> </td>';
- $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($total7) . '</td>';
- $html.= '<td align="center" width="3%" class="table12">' . (($stawki_vat == true) ? '8' : '7') . '</td>';
- $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($vat7) . '</td> ';
- $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($suma7) . '</td>';
- $html.= '</tr>';
- $html.= '<tr>';
- $html.= '<td align="right" width="67%" colspan="6" class="table11"> </td>';
- $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($total3) . '</td>';
- $html.= '<td align="center" width="3%" class="table12">' . (($stawki_vat == true) ? '5' : '3') . '</td>';
- $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($vat3) . '</td> ';
- $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($suma3) . '</td>';
- $html.= '</tr>';
- $html.= '<tr>';
- $html.= '<td align="right" width="67%" colspan="6" class="table11"> </td>';
- $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($total0) . '</td>';
- $html.= '<td align="center" width="3%" class="table12">0</td>';
- $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($vat0) . '</td> ';
- $html.= '<td align="right" width="10%" class="table12">' . invoiceNumberFormat($suma0) . '</td>';
- $html.= '</tr>';
- $totals_query = tep_db_query("SELECT title, value, class
- FROM " . TABLE_ORDERS_TOTAL . "
- WHERE orders_id = '" . (int)$oID . "'");
- while ($rabat = tep_db_fetch_array($totals_query)) {
- 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)) {
- $licznik++;
- if ($rabat['value'] < 0) {
- $rabat_brutto = $rabat['value'];
- } else {
- $rabat_brutto = $rabat['value'] * -1;
- }
- if ($rabat['class'] == 'ot_discount_coupon') {
- if (wb($rabat['value']) > 1) {
- $rabat_brutto = $rabat_brutto;
- }
- }
- $html.= '<tr>';
- $html.= '<td align="right" width="67%" colspan="6" class="table14a">' . str_replace(':', '', $rabat['title']) . '</td>';
- $html.= '<td align="right" width="33%" class="table14" colspan="4">' . invoiceNumberFormat($rabat_brutto) . '</td>';
- $html.= '</tr>';
- $razem_brutto = $razem_brutto + $rabat_brutto;
- }
- }
- $html.= '<tr>';
- $html.= '<td align="right" width="67%" colspan="6" class="table14a"><span class="dozaplaty">DO ZAPÅATY</span></td>';
- $html.= '<td align="right" width="33%" class="table15" colspan="4">' . invoiceNumberFormat($razem_brutto) . '</td>';
- $html.= '</tr>';
- $html.= '</table>';
- $html.= '<span class="zaplata">Do zapłaty: ' . invoiceNumberFormat($razem_brutto) . ' zł<span><br>';
- $html.= '<span class="zaplataslownie">SÅ‚ownie: ' . slownie(number_format($razem_brutto, 2, ',', '')) . '<span>';
- $html.= '<br><br><br>
- <table width="80%" align="center" border="0" cellspacing="0" cellpadding="2">
- <tr>
- <td class="ramka" width="40%"> <br> <br> </td>
- <td width="20%"> </td>
- <td class="ramka" width="40%"> <br> <br> </td>
- </tr>
- <tr>
- <td class="podpis" align="center" width="40%">osoba upoważniona do przyjmowania faktur VAT</td>
- <td width="20%"> </td>
- <td class="podpis" align="center" width="40%">osoba upoważniona do wystawiania faktur VAT</td>
- </tr>
- </table>';
- if (FAKTURA_NR_ZAM == 'true') {
- $html.= '
- <table width="100%" style="margin-left: auto; margin-right: auto;" border="0">
- <tr>
- <td align="left" class="oryginal"><u>UWAGI</u></td>
- </tr>
- <tr>
- <td align="left" class="mniejszytekst">Zamówienie nr: ' . $oID . '</td>
- </tr>
- </table>';
- }
- $html.= '</body></html>';
- define('_MPDF_PATH', 'mpdf/');
- include ("mpdf/mpdf.php");
- if ($language == 'russian') {
- $html = str_replace('Ä…', 'a', $html);
- $html = str_replace('ć', 'c', $html);
- $html = str_replace('Ä™', 'e', $html);
- $html = str_replace('Å‚', 'l', $html);
- $html = str_replace('Å„', 'n', $html);
- $html = str_replace('ó', 'o', $html);
- $html = str_replace('Å›', 's', $html);
- $html = str_replace('ź', 'z', $html);
- $html = str_replace('ż', 'z', $html);
- $html = str_replace('Ä„', 'A', $html);
- $html = str_replace('Ć', 'C', $html);
- $html = str_replace('Ę', 'E', $html);
- $html = str_replace('Å', 'L', $html);
- $html = str_replace('Ń', 'N', $html);
- $html = str_replace('Ó', 'O', $html);
- $html = str_replace('Åš', 'S', $html);
- $html = str_replace('Ź', 'Z', $html);
- $html = str_replace('Å»', 'Z', $html);
- $mpdf = new mPDF('win-1251', 'A4', '9', '', 5, 5, 5, 5, 5, 5);
- } else {
- $mpdf = new mPDF('iso-8859-2', 'A4', '9', '', 5, 5, 5, 5, 5, 5);
- }
- if (PDF_SHOW_WATERMARK == 'true') {
- $mpdf->setUnvalidatedText(UPDF_ZNAK_NAZWA);
- $mpdf->TopicIsUnvalidated = 1;
- }
- $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>');
- $mpdf->AddPage();
- $stylesheet = file_get_contents('mpdf/css/pdffaktura.css');
- $mpdf->WriteHTML($stylesheet, 1);
- $mpdf->WriteHTML($html, 2);
- $mpdf->Output('', 'I');
- exit;
- require (DIR_WS_INCLUDES . 'application_bottom.php');
- ?>
Add Comment
Please, Sign In to add comment