Есть платный модуль счета ПДФ, нужна помощь в изменении кода

Тема в разделе "OpenCart", создана пользователем VjS, 10 ноя 2016.

Метки:
  1. VjS

    VjS

    Регистрация:
    9 ноя 2016
    Сообщения:
    13
    Симпатии:
    2
    Здравствуйте,
    есть платный модуль счета ПДФ,
    ПДФ генерируется и отсылается клиенту на майл после подтверждения заказа,
    Задача:
    Сайт имеет два языка,
    и после подтверждения заказа ПДФ отправляется клиенту на том языке на котором он просматривал сайт и из админки ПДФ генерируется на том языке на котором админка.
    Надо подправить чтоб ПДФ генерировался только на одном языке независимо от того на котором языке смотрит клиент и не зависимо от того на котором админка.
    Изменения в языковых файлах, 100% результат не дали, так как в шаблоне присутствуют переменные которые берутся из базы
    например:
    <?php foreach ($total_data as $total) { ?>
    <tr><td align="right" colspan="<?php echo $colspan; ?>"><b><?php echo $total['title']; ?></b></td><td align="right"><?php echo $total['text']; ?></td></tr>
    <?php } ?>
    </tbody></table>

    можно ли в эту переменную добавить ID языка чтоб из базы брался только определенный язык?
    чтото вроде <?php echo ID_language = 2 AND $total['title']; ?>
    как это правильно реализовать?
     
  2. fanton123

    fanton123

    Регистрация:
    24 дек 2012
    Сообщения:
    279
    Симпатии:
    31
    что вам мешает заменить эти переменные если информация в них статическая. Или переписать запросы к базе на нужные.
    Вообще какой-то бред в этой строчке.

    Нужно смотреть конкретный пример с запросами в БД и прочее.
     
  3. VjS

    VjS

    Регистрация:
    9 ноя 2016
    Сообщения:
    13
    Симпатии:
    2
    Информация не статическая, (статическую инфо я заменил в языковых файлах)
    вот так выглядит счет в админке на англ языке, а клиент делал заказ на русской версии сайта:
    [​IMG]
    то что на английском, то я могу перевести в языковых файлах модуля
    то что выделено красным берется из БД на том языке на котором просматривал сайт клиент
    в шаблоне пдф эти переменные выглядят так:
    1:
    <?php echo strip_tags($order_info['payment_method']); ?>
    <?php echo $order_info['shipping_method']; ?>
    2:
    <?php foreach ($total_data as $total) { ?>
    <tr><td align="right" colspan="<?php echo $colspan; ?>"><b><?php echo $total['title']; ?></b></td><td align="right"><?php echo $total['text']; ?></td></tr>
    <?php } ?>
    </tbody></table>

    то что в моем примере в той строчке был бред, я знаю :Acute:
    я не программист пхп, просто думаю что должна быть возможность как то указать чтоб данные передовались только с одного языка.

    Как переписать запросы к БД на нужные не знаю,

    если вы знаете как, то подскажите пожалуйста.
     
  4. VjS

    VjS

    Регистрация:
    9 ноя 2016
    Сообщения:
    13
    Симпатии:
    2
    Может быть можно как то назначить язык счета по умолчанию?
    Кто знает как решить эту задачу, подскажите пожалуйста.
     
  5. fanton123

    fanton123

    Регистрация:
    24 дек 2012
    Сообщения:
    279
    Симпатии:
    31
    Это только вывод в файле .tpl
    Вам необходимо найти файл .php с запросами к базе данных.
    Типа:
    Код:
    $sql .= " FROM " . DB_PREFIX . "category_path cp LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (cp.category_id = p2c.category_id)";
    
    или
    
    $sql = "SELECT p.product_id, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating, (SELECT price FROM " . DB_PREFIX . "product_discount pd2 WHERE pd2.product_id = p.product_id AND pd2.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND pd2.quantity = '1' AND ((pd2.date_start = '0000-00-00' OR pd2.date_start < NOW()) AND (pd2.date_end = '0000-00-00' OR pd2.date_end > NOW())) ORDER BY pd2.priority ASC, pd2.price ASC LIMIT 1) AS discount, (SELECT price FROM " . DB_PREFIX . "product_special ps WHERE ps.product_id = p.product_id AND ps.customer_group_id = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((ps.date_start = '0000-00-00' OR ps.date_start < NOW()) AND (ps.date_end = '0000-00-00' OR ps.date_end > NOW())) ORDER BY ps.priority ASC, ps.price ASC LIMIT 1) AS special";
    И там использовать "language_id" для нужного языка
     
  6. VjS

    VjS

    Регистрация:
    9 ноя 2016
    Сообщения:
    13
    Симпатии:
    2
    нашел только один файл в модуле с запросом DB_PREFIX файл install.xml вот код файла:
    Код:
    <file path="admin/view/template/sale/order_list.tpl">
        <operation>
          <search>
            <![CDATA[
            <button type="submit" id="button-invoice" form="form-order" formaction="<?php echo $invoice; ?>" data-toggle="tooltip" title="<?php echo $button_invoice_print; ?>" class="btn btn-info"><i class="fa fa-print"></i></button>
            ]]>
          </search>
          <add position="after">
            <![CDATA[
          <button type="submit" id="button-pdf" form="form-order" formaction="<?php echo $pdf; ?>" data-toggle="tooltip" title="TAX INVOICE PDF" class="btn btn-info"><i class="fa fa-file-pdf-o"></i></button>
            ]]>
          </add>
        </operation>
        <operation>
          <search>
            <![CDATA[
            $('#button-shipping, #button-invoice').prop('disabled', true);
            ]]>
          </search>
          <add position="after">
            <![CDATA[  
            $('#button-pdf').prop('disabled', true);
            ]]>
          </add>
        </operation>
         <operation>
          <search>
            <![CDATA[
            $('#button-invoice').prop('disabled', false);
            ]]>
          </search>
          <add position="after">
            <![CDATA[  
            $('#button-pdf').prop('disabled', false);
            ]]>
          </add>
        </operation>
      </file>
      <file path="admin/controller/sale/order.php">
        <operation>
          <search>
            <![CDATA[$data['text_list'] = $this->language->get('text_list');]]>
          </search>
          <add position="after">
            <![CDATA[$data['pdf'] = $this->url->link('sale/order/pdf', 'token=' . $this->session->data['token'], 'SSL');]]>
          </add>
        </operation>
        <operation>
          <search>
            <![CDATA[public function invoice() {]]>
          </search>
          <add position="before">
            <![CDATA[  
    
                public function pdf() {
    
        $this->load->language('sale/order');
        $this->load->language('module/portdf');
    
        $data['title'] = $this->language->get('text_invoice');
    
        if ($this->request->server['HTTPS']) {
          $data['base'] = HTTPS_SERVER;
        } else {
          $data['base'] = HTTP_SERVER;
        }
    
        if (is_file(DIR_IMAGE . $this->config->get('config_logo')) && $this->config->get('pdforders_logo')) {
          $data['logo'] = HTTP_CATALOG . 'image/' . $this->config->get('config_logo');
        } else {
          $data['logo'] = '';
        }
       
        $data['direction'] = $this->language->get('direction');
        $data['lang'] = $this->language->get('code');
    
        $data['text_invoice'] = $this->language->get('text_invoice');
        $data['text_invoiceno'] = $this->language->get('text_invoiceno');
        $data['text_order_detail'] = $this->language->get('text_order_detail');
        $data['text_order_id'] = $this->language->get('text_order_id');
        $data['text_date_added'] = $this->language->get('text_date_added');
        $data['text_telephone'] = $this->language->get('text_telephone');
        $data['text_address'] = $this->language->get('text_address');
        $data['text_fax'] = $this->language->get('text_fax');
        $data['text_email'] = $this->language->get('text_email');
        $data['text_website'] = $this->language->get('text_website');
        $data['text_vattin']  = $this->language->get('text_vattin');
        $data['text_to'] = $this->language->get('text_to');
        $data['text_ship_to'] = $this->language->get('text_ship_to');
        $data['text_payment_method'] = $this->language->get('text_payment_method');
        $data['text_shipping_method'] = $this->language->get('text_shipping_method');
    
        $data['column_product'] = $this->language->get('column_product');
        $data['column_model'] = $this->language->get('column_model');
        $data['column_quantity'] = $this->language->get('column_quantity');
        $data['column_price'] = $this->language->get('column_price');
        $data['column_total'] = $this->language->get('column_total');
        $data['column_image'] = "Image";$data['column_comment'] = $this->language->get('column_comment'); require_once('../tcpdf/tcpdf.php');
        $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);$pdf->SetCreator(PDF_CREATOR);$pdf->SetAuthor($this->config->get('config_owner'));$pdf->SetTitle('Order PDF');$pdf->SetSubject('PDF Invoice');$pdf->SetKeywords('TCPDF, PDF Invoice');$pdf->setPrintHeader(false);$pdf->setFooterData(array(0,64,0), array(0,64,128));$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    
        $this->load->model('sale/order');
    
        $this->load->model('setting/setting');
    
        $data['orders'] = array();
        $orders = array();
    
        if (isset($this->request->post['selected'])) {
          $orders = $this->request->post['selected'];
        } elseif (isset($this->request->get['order_id'])) {
          $orders[] = $this->request->get['order_id'];
        }
    
        foreach ($orders as $order_id) {
          $order_info = $this->model_sale_order->getOrder($order_id);
          $data['order_info'] = $order_info;
          $data['order_id'] = $order_id;
          if ($order_info) {
            $store_info = $this->model_setting_setting->getSetting('config', $order_info['store_id']);
    
            if ($store_info) {
              $data['store_address'] = $store_info['config_address'];
              $data['store_email'] = $store_info['config_email'];
              $data['store_telephone'] = $store_info['config_telephone'];
              $data['store_fax'] = $store_info['config_fax'];
            } else {
              $data['store_address'] = $this->config->get('config_address');
              $data['store_email'] = $this->config->get('config_email');
              $data['store_telephone'] = $this->config->get('config_telephone');
              $data['store_fax'] = $this->config->get('config_fax');
            }
    
            $data['date_added'] = date($this->language->get('date_format_short'), strtotime($order_info['date_added']));
    
            if ($order_info['invoice_no']) {
              $data['invoice_no'] = $order_info['invoice_prefix'] . $order_info['invoice_no'];
            } else {
              $data['invoice_no'] = '';
            }
    
            if ($order_info['payment_address_format']) {
              $format = $order_info['payment_address_format'];
            } else {
              $format = '{firstname} {lastname}' . "\n " . '{company}' .  "\n " . '{address_1}' .  "\n " . '{address_2}' .  "\n " . '{city} {postcode}' .  "\n " . '{zone}' . "\n " . '{country}';
            }
    
            $find = array(
              '{firstname}',
              '{lastname}',
              '{company}',
              '{address_1}',
              '{address_2}',
              '{city}',
              '{postcode}',
              '{zone}',
              '{zone_code}',
              '{country}'
            );
    
            $replace = array(
              'firstname' => $order_info['payment_firstname'],
              'lastname'  => $order_info['payment_lastname'],
              'company'   => $order_info['payment_company'],
              'address_1' => $order_info['payment_address_1'],
              'address_2' => $order_info['payment_address_2'],
              'city'      => $order_info['payment_city'],
              'postcode'  => $order_info['payment_postcode'],
              'zone'      => $order_info['payment_zone'],
              'zone_code' => $order_info['payment_zone_code'],
              'country'   => $order_info['payment_country']
            );
    
            $data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
    
            if ($order_info['shipping_address_format']) {
              $format = $order_info['shipping_address_format'];
            } else {
              $format = '{firstname} {lastname}' .  "\n " . '{company}' .  "\n " . '{address_1}' .  "\n " . '{address_2}' .  "\n ". '{city} {postcode}' .  "\n " . '{zone}' .  "\n " . '{country}';
            }
            $pdf->SetFont($this->config->get('pdforders_fontstyle'), '',$this->config->get('pdforders_fontsize') , '', true);
           
            $find = array(
              '{firstname}',
              '{lastname}',
              '{company}',
              '{address_1}',
              '{address_2}',
              '{city}',
              '{postcode}',
              '{zone}',
              '{zone_code}',
              '{country}'
            );
    
            $replace = array(
              'firstname' => $order_info['shipping_firstname'],
              'lastname'  => $order_info['shipping_lastname'],
              'company'   => $order_info['shipping_company'],
              'address_1' => $order_info['shipping_address_1'],
              'address_2' => $order_info['shipping_address_2'],
              'city'      => $order_info['shipping_city'],
              'postcode'  => $order_info['shipping_postcode'],
              'zone'      => $order_info['shipping_zone'],
              'zone_code' => $order_info['shipping_zone_code'],
              'country'   => $order_info['shipping_country']
            );
    
            $data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
    
            $this->load->model('tool/upload');
            $this->load->model('tool/image');
    
            $data['product_data'] = array();
    
            $products = $this->model_sale_order->getOrderProducts($order_id);
            $productcount  = count($products);
            $data['addextrarows'] = false;
            if($this->config->get('pdforders_numberproducts') > $productcount) {
              $data['addextrarows'] = true;
            }
            foreach ($products as $product) {
              $option_data = array();
    
              $options = $this->model_sale_order->getOrderOptions($order_id, $product['order_product_id']);
    
              foreach ($options as $option) {
                if ($option['type'] != 'file') {
                  $value = $option['value'];
                } else {
                  $upload_info = $this->model_tool_upload->getUploadByCode($option['value']);
    
                  if ($upload_info) {
                    $value = $upload_info['name'];
                  } else {
                    $value = '';
                  }
                }
    
                $option_data[] = array(
                  'name'  => $option['name'],
                  'value' => $value
                );
              }
              if($this->config->get('pdforders_showimage')) {
                $image = $this->model_sale_order->getProductiimage($product['product_id']);
    
               
                if (is_file(DIR_IMAGE . $image)) {
                  $image = $this->model_tool_image->resize($image, 60, 60);
                  $image = str_replace(' ','%20',$image);
                } else {
                  $image = $this->model_tool_image->resize('no_image.png', 60, 60);
                }
    
              } else {
                $image = "";
              }
              $data['product_data'][] = array(
                'name'     => $product['name'],
                'thumb'     => $image,
                'model'    => $product['model'],
                'option'   => $option_data,
                'quantity' => $product['quantity'],
                'price'    => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']),
                'total'    => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? ($product['tax'] * $product['quantity']) : 0), $order_info['currency_code'], $order_info['currency_value'])
              );
            }
         
            $pdf->AddPage($this->config->get('pdforders_orientation'), $this->config->get('pdforders_format'));
           
            $data['voucher_data'] = array();
    
            $vouchers = $this->model_sale_order->getOrderVouchers($order_id);
    
            foreach ($vouchers as $voucher) {
              $data['voucher_data'][] = array(
                'description' => $voucher['description'],
                'amount'      => $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value'])
              );
            }
    
           $data['total_data'] = array();
    
            $totals = $this->model_sale_order->getOrderTotals($order_id);
    
            foreach ($totals as $total) {
              $data['total_data'][] = array(
                'title' => $total['title'],
                'text'  => $this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']),
              );
            } 
    
            $data['vattin'] = $this->config->get('pdforders_vattin');
            $data['configaddextrarows'] =  $this->config->get('pdforders_addextrarows');
            $data['numberextrarows'] =  $this->config->get('pdforders_numberextrarows');
            $data['showimage'] = $this->config->get('pdforders_showimage');
            $message = $this->config->get('pdforders_textfooter');
            $data['message'] = "";
            if (isset($message[$this->config->get('config_language_id')])) { 
              $data['message'] = $message[$this->config->get('config_language_id')]['name'];
            }
            $data['signatureimage'] = $this->config->get('pdforders_signatureimage');
            $data['signaturethumbimage'] = HTTP_CATALOG.'image/'.$this->config->get('pdforders_signatureimagethumb');
            $tbl = $this->load->view('portdf/invce1.tpl', $data);
            $pdf->writeHTML($tbl, true, false, false, false, '');
          }
        }
        $pdf->Output('Tax_Invoice.pdf', 'I');
      }
    ]]>
          </add>
        </operation>
      </file>
       <file path="admin/model/sale/order.php">
         <operation>
          <search><![CDATA[public function createInvoiceNo($order_id) {]]></search>
          <add position="before"><![CDATA[
              public function getProductiimage($product_id) {
        $query = $this->db->query("SELECT image FROM `" . DB_PREFIX . "product` WHERE product_id = '".$product_id."'");
        return $query->row['image'];
      }
      ]]></add>
        </operation>
      </file>
    
    
      <file path="catalog/controller/account/order.php">
        <operation>
          <search>
            <![CDATA['href'       => $this->url->link('account/order/info', 'order_id=' . $result['order_id'], 'SSL'),]]>
          </search>
          <add position="after">
            <![CDATA[ 
          'pdf'       => $this->url->link('account/order/pdf', 'order_id=' . $result['order_id'], 'SSL'),
          'order_status_id' => $this->model_account_order->getOrderstatusid($result['order_id']),
            ]]>
          </add>
        </operation>
        <operation>
          <search>
            <![CDATA[$order_total = $this->model_account_order->getTotalOrders();]]>
          </search>
          <add position="after">
            <![CDATA[$data['pdforders_order_status_customer'] = $this->config->get('pdforders_order_status_customer');]]>
          </add>
        </operation>
       
        <operation>
          <search>
            <![CDATA[public function reorder() {]]>
          </search>
          <add position="before">
            <![CDATA[  
    
            public function pdf() {
    
        $this->load->language('account/order');
        $this->load->language('module/portdf');
    
        if (isset($this->request->get['order_id'])) {
          $order_id = $this->request->get['order_id'];
        } else {
          $order_id = 0;
        }
    
        if (!$this->customer->isLogged()) {
          $this->session->data['redirect'] = $this->url->link('account/order/info', 'order_id=' . $order_id, 'SSL');
    
          $this->response->redirect($this->url->link('account/login', '', 'SSL'));
        }
    
    
        $data['title'] = $this->language->get('text_invoice');
    
        if ($this->request->server['HTTPS']) {
          $data['base'] = HTTPS_SERVER;
        } else {
          $data['base'] = HTTP_SERVER;
        }
    
        if (is_file(DIR_IMAGE . $this->config->get('config_logo')) && $this->config->get('pdforders_logo')) {
          $data['logo'] = HTTP_SERVER . 'image/' . $this->config->get('config_logo');
        } else {
          $data['logo'] = '';
        }
       
        $data['direction'] = $this->language->get('direction');
        $data['lang'] = $this->language->get('code');
    
        $data['text_invoice'] = $this->language->get('text_invoice');
        $data['text_invoiceno'] = $this->language->get('text_invoiceno');
        $data['text_order_detail'] = $this->language->get('text_order_detail');
        $data['text_order_id'] = $this->language->get('text_order_id');
        $data['text_date_added'] = $this->language->get('text_date_added');
        $data['text_telephone'] = $this->language->get('text_telephone');
        $data['text_address'] = $this->language->get('text_address');
        $data['text_fax'] = $this->language->get('text_fax');
        $data['text_email'] = $this->language->get('text_email');
        $data['text_website'] = $this->language->get('text_website');
        $data['text_vattin']  = $this->language->get('text_vattin');
        $data['text_to'] = $this->language->get('text_to');
        $data['text_ship_to'] = $this->language->get('text_ship_to');
        $data['text_payment_method'] = $this->language->get('text_payment_method');
        $data['text_shipping_method'] = $this->language->get('text_shipping_method');
    
        $data['column_product'] = $this->language->get('column_product_name');
        $data['column_model'] = $this->language->get('column_model');
        $data['column_quantity'] = $this->language->get('column_quantity');
        $data['column_price'] = $this->language->get('column_price');
        $data['column_total'] = $this->language->get('column_total');$data['column_image'] = "Image";$data['column_comment'] = $this->language->get('column_comment');require_once('tcpdf/tcpdf.php');$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, $this->config->get('pdforders_format'), true, 'UTF-8', false);$pdf->SetCreator(PDF_CREATOR);$pdf->SetAuthor($this->config->get('config_owner'));$pdf->SetTitle('Order PDF');$pdf->SetSubject('PDF Invoice');$pdf->SetKeywords('TCPDF, PDF Invoice');$pdf->setPrintHeader(false);$pdf->setFooterData(array(0,64,0), array(0,64,128));$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    
        $this->load->model('account/order');
        $this->load->model('setting/setting');
    
      $order_info = $this->model_account_order->getOrder($order_id);
    
      if ($order_info) {
            $data['order_info'] = $order_info;
            $data['order_id'] = $order_id;
            $store_info = $this->model_setting_setting->getSetting('config', $order_info['store_id']);
    
            if ($store_info) {
              $data['store_address'] = $store_info['config_address'];
              $data['store_email'] = $store_info['config_email'];
              $data['store_telephone'] = $store_info['config_telephone'];
              $data['store_fax'] = $store_info['config_fax'];
            } else {
              $data['store_address'] = $this->config->get('config_address');
              $data['store_email'] = $this->config->get('config_email');
              $data['store_telephone'] = $this->config->get('config_telephone');
              $data['store_fax'] = $this->config->get('config_fax');
            }
    
            $data['date_added'] = date($this->language->get('date_format_short'), strtotime($order_info['date_added']));
    
            if ($order_info['invoice_no']) {
              $data['invoice_no'] = $order_info['invoice_prefix'] . $order_info['invoice_no'];
            } else {
              $data['invoice_no'] = '';
            }
    
            if ($order_info['payment_address_format']) {
              $format = $order_info['payment_address_format'];
            } else {
              $format = '{firstname} {lastname}' . "\n " . '{company}' .  "\n " . '{address_1}' .  "\n " . '{address_2}' .  "\n " . '{city} {postcode}' .  "\n " . '{zone}' . "\n " . '{country}';
            }
    
             $name = ucwords(sprintf($this->language->get('text_customer_name'),$order_info['firstname']." ".$order_info['lastname']));
    
             $pdf->SetAuthor($this->config->get('config_owner'));$pdf->SetTitle($this->language->get('text_invoice_detail').$name." #".$order_id);$pdf->SetSubject($this->language->get('text_invoice_detail').$name." #".$order_id);$pdf->SetKeywords('invoice');
    
            $find = array(
              '{firstname}',
              '{lastname}',
              '{company}',
              '{address_1}',
              '{address_2}',
              '{city}',
              '{postcode}',
              '{zone}',
              '{zone_code}',
              '{country}'
            );
    
            $replace = array(
              'firstname' => $order_info['payment_firstname'],
              'lastname'  => $order_info['payment_lastname'],
              'company'   => $order_info['payment_company'],
              'address_1' => $order_info['payment_address_1'],
              'address_2' => $order_info['payment_address_2'],
              'city'      => $order_info['payment_city'],
              'postcode'  => $order_info['payment_postcode'],
              'zone'      => $order_info['payment_zone'],
              'zone_code' => $order_info['payment_zone_code'],
              'country'   => $order_info['payment_country']
            );
            $pdf->SetFont($this->config->get('pdforders_fontstyle'), '',$this->config->get('pdforders_fontsize') , '', true);
            $data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
    
            if ($order_info['shipping_address_format']) {
              $format = $order_info['shipping_address_format'];
            } else {
              $format = '{firstname} {lastname}' .  "\n " . '{company}' .  "\n " . '{address_1}' .  "\n " . '{address_2}' .  "\n ". '{city} {postcode}' .  "\n " . '{zone}' .  "\n " . '{country}';
            }
    
            $find = array(
              '{firstname}',
              '{lastname}',
              '{company}',
              '{address_1}',
              '{address_2}',
              '{city}',
              '{postcode}',
              '{zone}',
              '{zone_code}',
              '{country}'
            );
    
            $replace = array(
              'firstname' => $order_info['shipping_firstname'],
              'lastname'  => $order_info['shipping_lastname'],
              'company'   => $order_info['shipping_company'],
              'address_1' => $order_info['shipping_address_1'],
              'address_2' => $order_info['shipping_address_2'],
              'city'      => $order_info['shipping_city'],
              'postcode'  => $order_info['shipping_postcode'],
              'zone'      => $order_info['shipping_zone'],
              'zone_code' => $order_info['shipping_zone_code'],
              'country'   => $order_info['shipping_country']
            );
    
            $data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
    
            $this->load->model('tool/upload');
            $this->load->model('tool/image');
    
            $data['product_data'] = array();
    
            $products = $this->model_account_order->getOrderProducts($order_id);
    
            $productcount  = count($products);
            $data['addextrarows'] = false;
            if($this->config->get('pdforders_numberproducts') > $productcount) {
              $data['addextrarows'] = true;
            }
    
            foreach ($products as $product)   {
              $option1_data =   array();
    
              $options = $this->model_account_order->getOrderOptions($order_id, $product['order_product_id']);
    
              foreach ($options as $option) {
                if ($option['type'] != 'file') {
                  $value = $option['value'];
                } else {
                  $upload_info = $this->model_tool_upload->getUploadByCode($option['value']);
    
                  if ($upload_info) {
                    $value = $upload_info['name'];
                  } else {
                    $value = '';
                  }
                }
    
                $option1_data[] = array(
                  'name'  => $option['name'],
                  'value' => $value
                );
              }
    
              if($this->config->get('pdforders_showimage')) {
                  $image = $this->model_account_order->getProductimage($product['product_id']);
    
                  if (is_file(DIR_IMAGE . $image)) {
                    $image = $this->model_tool_image->resize($image, 60, 60);
                    $image = str_replace(' ','%20',$image);
                  } else {
                    $image = $this->model_tool_image->resize('no_image.png', 60, 60);
                  }
              } else {
                $image = "";
              } 
    
              $data['product_data'][] = array(
                'name'     => $product['name'],
                'thumb'     => $image,
                'model'    => $product['model'],
                'option'   => $option1_data,
                'quantity' => $product['quantity'],
                'price'    => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']),
                'total'    => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? ($product['tax'] * $product['quantity']) : 0), $order_info['currency_code'], $order_info['currency_value'])
              );
            }
           
            $pdf->AddPage($this->config->get('pdforders_orientation'), $this->config->get('pdforders_format'));
           
            $voucher_data = array();
    
            $data['voucher_data'] = array();
     
            $voucher_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_voucher WHERE order_id = '" . (int)$order_id . "'");
     
            foreach ($voucher_query->rows as $voucher) {
              $data['voucher_data'][] = array(
                'description' => $voucher['description'],
                'amount'      => $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']),
              );
            }
    
            $data['total_data'] = array();
    
            $totals = $this->model_account_order->getOrderTotals($order_id);
    
            foreach ($totals as $total) {
              $data['total_data'][] = array(
                'title' => $total['title'],
                'text'  => $this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']),
              );
            } 
    
            $data['vattin'] = $this->config->get('pdforders_vattin');
            $data['configaddextrarows'] =  $this->config->get('pdforders_addextrarows');
            $data['numberextrarows'] =  $this->config->get('pdforders_numberextrarows');
            $data['showimage'] = $this->config->get('pdforders_showimage');
            $message = $this->config->get('pdforders_textfooter');
            $data['message'] = "";
            if (isset($message[$this->config->get('config_language_id')])) { 
              $data['message'] = $message[$this->config->get('config_language_id')]['name'];
            }
            $data['signatureimage'] = $this->config->get('pdforders_signatureimage');
            $data['signaturethumbimage'] = $data['base'].'image/'.$this->config->get('pdforders_signatureimagethumb');
           
    
            $version = str_replace(".","",VERSION);
            $tbl = "";
            if($version >= 2200) {
               $tbl = $this->load->view('portdf/invce1.tpl', $data);
            } else {
                if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/portdf/invce1.tpl')) {
                  $tbl = $this->load->view($this->config->get('config_template') . '/template/portdf/invce1.tpl', $data);
                } else {
                  $tbl = $this->load->view('default/template/portdf/invce1.tpl', $data);
                }
            }
    
            $pdf->writeHTML($tbl, true, false, false, false, '');
          }
       
          $pdf->Output('Invoice-Order'.$order_id.'.pdf', 'I');
      }
    
    ]]></add>
        </operation>
      </file>
      <file path="catalog/model/account/order.php">
         <operation>
          <search><![CDATA[public function getOrderProducts($order_id) {]]></search>
          <add position="before"><![CDATA[
              public function getProductimage($product_id) {
        $query = $this->db->query("SELECT image FROM `" . DB_PREFIX . "product` WHERE product_id = '".$product_id."'");
        return $query->row['image'];
      }
      public function getOrderstatusid($order_id) {
        $query = $this->db->query("SELECT order_status_id FROM `" . DB_PREFIX . "order` WHERE `order_id` = '" . (int)$order_id . "'");
    
        return $query->row['order_status_id'];
      }
      ]]></add>
        </operation>
      </file>
    
       
      <file path="catalog/view/theme/*/template/account/order_list.tpl">
         <operation>
          <search><![CDATA[<td class="text-right"><?php echo $column_total; ?></td>]]></search>
          <add position="after"><![CDATA[
           <td class="text-right">Tax Invoice (PDF)</td>
          ]]></add>
        </operation>
        <operation>
          <search><![CDATA[<td class="text-right"><?php echo $order['total']; ?></td>]]></search>
          <add position="after"><![CDATA[
            <?php if(in_array($order['order_status_id'],$pdforders_order_status_customer)) { ?>
             <td class="text-right"><a href="<?php echo $order['pdf']; ?>" style="color:white;" target="_blank" data-toggle="tooltip" title="TAX INVOICE PDF" class="btn btn-info"><i class="fa fa-file-pdf-o"></i></a></td>
            <?php } else { ?>
             <td class="text-right"><a disabled data-toggle="tooltip" style="color:white;"  title="TAX INVOICE PDF" class="btn btn-info"><i class="fa fa-file-pdf-o"></i></a></td>
            <?php } ?>
      ]]></add>
        </operation>
      </file>
    
     <file path="catalog/model/checkout/order.php">
       <operation>
          <search><![CDATA[if (!$order_info['order_status_id'] && $order_status_id) {]]></search>
          <add position="after"><![CDATA[
            if($this->config->get('pdforders_autogenerateinvoiceno')) {
              $query = $this->db->query("SELECT MAX(invoice_no) AS invoice_no FROM `" . DB_PREFIX . "order` WHERE invoice_prefix = '" . $this->db->escape($order_info['invoice_prefix']) . "'");
    
              if ($query->row['invoice_no']) {
                $invoice_no = $query->row['invoice_no'] + 1;
              } else {
                $invoice_no = 1;
              }
    
              $this->db->query("UPDATE `" . DB_PREFIX . "order` SET invoice_no = '" . (int)$invoice_no . "' WHERE order_id = '" . (int)$order_id . "'");
              $order_info['invoice_no'] = $invoice_no;
          }
      ]]></add>
        </operation>
         <operation>
          <search><![CDATA[public function deleteOrder($order_id) {]]></search>
          <add position="before"><![CDATA[
        public function createPdf($order_info) {
    
        $this->load->language('account/order');
        $this->load->language('module/portdf');
        $data['title'] = $this->language->get('text_invoice');
    
        if ($this->request->server['HTTPS']) {
          $data['base'] = HTTPS_SERVER;
        } else {
          $data['base'] = HTTP_SERVER;
        }
    
        if (is_file(DIR_IMAGE . $this->config->get('config_logo')) && $this->config->get('pdforders_logo')) {
          $data['logo'] = HTTP_SERVER . 'image/' . $this->config->get('config_logo');
        } else {
          $data['logo'] = '';
        }
       
        $data['direction'] = $this->language->get('direction');
        $data['lang'] = $this->language->get('code');
    
        $data['text_invoice'] = $this->language->get('text_invoice');
        $data['text_invoiceno'] = $this->language->get('text_invoiceno');
        $data['text_order_detail'] = $this->language->get('text_order_detail');
        $data['text_order_id'] = $this->language->get('text_order_id');
        $data['text_date_added'] = $this->language->get('text_date_added');
        $data['text_telephone'] = $this->language->get('text_telephone');
        $data['text_address'] = $this->language->get('text_address');
        $data['text_fax'] = $this->language->get('text_fax');
        $data['text_email'] = $this->language->get('text_email');
        $data['text_website'] = $this->language->get('text_website');
        $data['text_vattin']  = $this->language->get('text_vattin');
        $data['text_to'] = $this->language->get('text_to');
        $data['text_ship_to'] = $this->language->get('text_ship_to');
        $data['text_payment_method'] = $this->language->get('text_payment_method');
        $data['text_shipping_method'] = $this->language->get('text_shipping_method');
    
        $data['column_product'] = $this->language->get('column_product_name');
        $data['column_model'] = $this->language->get('column_model');
        $data['column_quantity'] = $this->language->get('column_quantity');
        $data['column_price'] = $this->language->get('column_price');
        $data['column_total'] = $this->language->get('column_total');$data['column_image'] = "Image";$data['column_comment'] = $this->language->get('column_comment');require_once('tcpdf/tcpdf.php');$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, $this->config->get('pdforders_format'), true, 'UTF-8', false);$pdf->SetCreator(PDF_CREATOR);$pdf->SetAuthor($this->config->get('config_owner'));$pdf->SetTitle('Order PDF');$pdf->SetSubject('PDF Invoice');$pdf->SetKeywords('TCPDF, PDF Invoice');$pdf->setPrintHeader(false);$pdf->setFooterData(array(0,64,0), array(0,64,128));$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
    
        $this->load->model('account/order');
        $this->load->model('setting/setting');
    
        $data['order_info'] = $order_info;
        $data['order_id'] = $order_info['order_id'];
        $order_id = $order_info['order_id'];
        $store_info = $this->model_setting_setting->getSetting('config', $order_info['store_id']);
    
        if ($store_info) {
          $data['store_address'] = $store_info['config_address'];
          $data['store_email'] = $store_info['config_email'];
          $data['store_telephone'] = $store_info['config_telephone'];
          $data['store_fax'] = $store_info['config_fax'];
        } else {
          $data['store_address'] = $this->config->get('config_address');
          $data['store_email'] = $this->config->get('config_email');
          $data['store_telephone'] = $this->config->get('config_telephone');
          $data['store_fax'] = $this->config->get('config_fax');
        }
    
        $data['date_added'] = date($this->language->get('date_format_short'), strtotime($order_info['date_added']));
    
        if ($order_info['invoice_no']) {
          $data['invoice_no'] = $order_info['invoice_prefix'] . $order_info['invoice_no'];
        } else {
          $data['invoice_no'] = '';
        }
    
        if ($order_info['payment_address_format']) {
          $format = $order_info['payment_address_format'];
        } else {
          $format = '{firstname} {lastname}' . "\n " . '{company}' .  "\n " . '{address_1}' .  "\n " . '{address_2}' .  "\n " . '{city} {postcode}' .  "\n " . '{zone}' . "\n " . '{country}';
        }
    
        $find = array(
          '{firstname}',
          '{lastname}',
          '{company}',
          '{address_1}',
          '{address_2}',
          '{city}',
          '{postcode}',
          '{zone}',
          '{zone_code}',
          '{country}'
        );
    
        $replace = array(
          'firstname' => $order_info['payment_firstname'],
          'lastname'  => $order_info['payment_lastname'],
          'company'   => $order_info['payment_company'],
          'address_1' => $order_info['payment_address_1'],
          'address_2' => $order_info['payment_address_2'],
          'city'      => $order_info['payment_city'],
          'postcode'  => $order_info['payment_postcode'],
          'zone'      => $order_info['payment_zone'],
          'zone_code' => $order_info['payment_zone_code'],
          'country'   => $order_info['payment_country']
        );
        $pdf->SetFont($this->config->get('pdforders_fontstyle'), '',$this->config->get('pdforders_fontsize') , '', true);
        $data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
    
        if ($order_info['shipping_address_format']) {
          $format = $order_info['shipping_address_format'];
        } else {
          $format = '{firstname} {lastname}' .  "\n " . '{company}' .  "\n " . '{address_1}' .  "\n " . '{address_2}' .  "\n ". '{city} {postcode}' .  "\n " . '{zone}' .  "\n " . '{country}';
        }
    
        $name = ucwords(sprintf($this->language->get('text_customer_name'),$order_info['firstname']." ".$order_info['lastname']));
    
        $pdf->SetAuthor($this->config->get('config_owner'));$pdf->SetTitle($this->language->get('text_invoice_detail').$name." #".$order_id);$pdf->SetSubject($this->language->get('text_invoice_detail').$name." #".$order_id);$pdf->SetKeywords('invoice');
    
        $find = array(
          '{firstname}',
          '{lastname}',
          '{company}',
          '{address_1}',
          '{address_2}',
          '{city}',
          '{postcode}',
          '{zone}',
          '{zone_code}',
          '{country}'
        );
    
        $replace = array(
          'firstname' => $order_info['shipping_firstname'],
          'lastname'  => $order_info['shipping_lastname'],
          'company'   => $order_info['shipping_company'],
          'address_1' => $order_info['shipping_address_1'],
          'address_2' => $order_info['shipping_address_2'],
          'city'      => $order_info['shipping_city'],
          'postcode'  => $order_info['shipping_postcode'],
          'zone'      => $order_info['shipping_zone'],
          'zone_code' => $order_info['shipping_zone_code'],
          'country'   => $order_info['shipping_country']
        );
    
        $data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
    
        $this->load->model('tool/upload');
        $this->load->model('tool/image');
    
        $data['product_data'] = array();
    
        $products = $this->model_account_order->getOrderProducts($order_id);
    
        $productcount  = count($products);
        $data['addextrarows'] = false;
        if($this->config->get('pdforders_numberproducts') > $productcount) {
          $data['addextrarows'] = true;
        }
    
        foreach ($products as $product)   {
          $option1_data =   array();
    
          $options = $this->model_account_order->getOrderOptions($order_id, $product['order_product_id']);
    
          foreach ($options as $option) {
            if ($option['type'] != 'file') {
              $value = $option['value'];
            } else {
              $upload_info = $this->model_tool_upload->getUploadByCode($option['value']);
    
              if ($upload_info) {
                $value = $upload_info['name'];
              } else {
                $value = '';
              }
            }
    
            $option1_data[] = array(
              'name'  => $option['name'],
              'value' => $value
            );
          }
    
          if($this->config->get('pdforders_showimage')) {
              $image = $this->model_account_order->getProductimage($product['product_id']);
    
              if (is_file(DIR_IMAGE . $image)) {
                $image = $this->model_tool_image->resize($image, 60, 60);
                $image = str_replace(' ','%20',$image);
              } else {
                $image = $this->model_tool_image->resize('no_image.png', 60, 60);
              }
          } else {
            $image = "";
          } 
    
          $data['product_data'][] = array(
            'name'     => $product['name'],
            'thumb'     => $image,
            'model'    => $product['model'],
            'option'   => $option1_data,
            'quantity' => $product['quantity'],
            'price'    => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']),
            'total'    => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? ($product['tax'] * $product['quantity']) : 0), $order_info['currency_code'], $order_info['currency_value'])
          );
        }
       
        $pdf->AddPage($this->config->get('pdforders_orientation'), $this->config->get('pdforders_format'));
       
        $voucher_data = array();
    
        $data['voucher_data'] = array();
    
        $voucher_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_voucher WHERE order_id = '" . (int)$order_id . "'");
    
        foreach ($voucher_query->rows as $voucher) {
          $data['voucher_data'][] = array(
            'description' => $voucher['description'],
            'amount'      => $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']),
          );
        }
    
        $data['total_data'] = array();
    
        $totals = $this->model_account_order->getOrderTotals($order_id);
    
        foreach ($totals as $total) {
          $data['total_data'][] = array(
            'title' => $total['title'],
            'text'  => $this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']),
          );
        } 
    
        $data['vattin'] = $this->config->get('pdforders_vattin');
        $data['configaddextrarows'] =  $this->config->get('pdforders_addextrarows');
        $data['numberextrarows'] =  $this->config->get('pdforders_numberextrarows');
        $data['showimage'] = $this->config->get('pdforders_showimage');
        $message = $this->config->get('pdforders_textfooter');
        $data['message'] = "";
        if (isset($message[$this->config->get('config_language_id')])) { 
          $data['message'] = $message[$this->config->get('config_language_id')]['name'];
        }
        $data['signatureimage'] = $this->config->get('pdforders_signatureimage');
        $data['signaturethumbimage'] = $data['base'].'image/'.$this->config->get('pdforders_signatureimagethumb');
       
    
        $version = str_replace(".","",VERSION);
        $tbl = "";
        if($version >= 2200) {
           $tbl = $this->load->view('portdf/invce1.tpl', $data);
        } else {
            if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/portdf/invce1.tpl')) {
              $tbl = $this->load->view($this->config->get('config_template') . '/template/portdf/invce1.tpl', $data);
            } else {
              $tbl = $this->load->view('default/template/portdf/invce1.tpl', $data);
            }
        }
    
      $pdf->writeHTML($tbl, true, false, false, false, '');
       
          $filename = DIR_DOWNLOAD."TAX_INVOICE_".$order_id.".pdf";
          //pdf email data
         // $this->log->write(print_r($tbl,true));
          $pdf->Output($filename, 'F');
      }
      ]]></add>
        </operation>
         <operation>
          <search><![CDATA[$mail->setTo($order_info['email']);]]></search>
          <add position="after"><![CDATA[
            $pdforders_order_status_customer = $this->config->get('pdforders_order_status_customer');
            if ($this->config->get('pdforders_attachemail') && (in_array($order_status_id,$pdforders_order_status_customer))) {
              $this->createPdf($order_info);
              $mail->addAttachment(DIR_DOWNLOAD."TAX_INVOICE_".$order_id.".pdf");
            }
        ]]></add>
        </operation>
         <operation>
          <search><![CDATA[$mail->setTo($this->config->get('config_email'));]]></search>
          <add position="after"><![CDATA[
            $pdforders_order_status_customer = $this->config->get('pdforders_order_status_customer');
            if ($this->config->get('pdforders_attachemail') && (in_array($order_status_id,$pdforders_order_status_customer))) {
              if (file_exists(DIR_DOWNLOAD."TAX_INVOICE_".$order_id.".pdf")) {
                $mail->addAttachment(DIR_DOWNLOAD."TAX_INVOICE_".$order_id.".pdf");
              }
            }
        ]]></add>
        </operation>
        <operation>
          <search><![CDATA[if (in_array($order_info['order_status_id'], $this->config->get('config_complete_status'))) {]]></search>
          <add position="before"><![CDATA[
            if (is_file(DIR_DOWNLOAD."TAX_INVOICE_".$order_id.".pdf")) {
              unlink(DIR_DOWNLOAD."TAX_INVOICE_".$order_id.".pdf");
              $this->load->language('api/order');
            }
    ]]></add>
        </operation>
      </file>
    
    возможно эта часть кода отвечает за генерацию ПДФ, как правильно вставить language_id ?
    Код:
     
       <operation>
          <search><![CDATA[if (!$order_info['order_status_id'] && $order_status_id) {]]></search>
          <add position="after"><![CDATA[
            if($this->config->get('pdforders_autogenerateinvoiceno')) {
              $query = $this->db->query("SELECT MAX(invoice_no) AS invoice_no FROM `" . DB_PREFIX . "order` WHERE invoice_prefix = '" . $this->db->escape($order_info['invoice_prefix']) . "'");
    
              if ($query->row['invoice_no']) {
                $invoice_no = $query->row['invoice_no'] + 1;
              } else {
                $invoice_no = 1;
              }
    
              $this->db->query("UPDATE `" . DB_PREFIX . "order` SET invoice_no = '" . (int)$invoice_no . "' WHERE order_id = '" . (int)$order_id . "'");
              $order_info['invoice_no'] = $invoice_no;
          }
      ]]></add>
        </operation>
    
     
  7. fanton123

    fanton123

    Регистрация:
    24 дек 2012
    Сообщения:
    279
    Симпатии:
    31
    Модуль использует стандартные запросы движка из файла /admin/model/sale/order.php
    Первое что приходит в голову сделать копию данного файла со своими правками и подключить вместо стандартного.
     
  8. VjS

    VjS

    Регистрация:
    9 ноя 2016
    Сообщения:
    13
    Симпатии:
    2
    вот код файла: admin/model/sale/order.php
    как правильно изменить?
    Код:
    <?php
    class ModelSaleOrder extends Model {
        public function getOrder($order_id) {
            $order_query = $this->db->query("SELECT *, (SELECT CONCAT(c.firstname, ' ', c.lastname) FROM " . DB_PREFIX . "customer c WHERE c.customer_id = o.customer_id) AS customer FROM `" . DB_PREFIX . "order` o WHERE o.order_id = '" . (int)$order_id . "'");
    
            if ($order_query->num_rows) {
                $reward = 0;
    
                $order_product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
    
                foreach ($order_product_query->rows as $product) {
                    $reward += $product['reward'];
                }
    
                $country_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE country_id = '" . (int)$order_query->row['payment_country_id'] . "'");
    
                if ($country_query->num_rows) {
                    $payment_iso_code_2 = $country_query->row['iso_code_2'];
                    $payment_iso_code_3 = $country_query->row['iso_code_3'];
                } else {
                    $payment_iso_code_2 = '';
                    $payment_iso_code_3 = '';
                }
    
                $zone_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE zone_id = '" . (int)$order_query->row['payment_zone_id'] . "'");
    
                if ($zone_query->num_rows) {
                    $payment_zone_code = $zone_query->row['code'];
                } else {
                    $payment_zone_code = '';
                }
    
                $country_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "country` WHERE country_id = '" . (int)$order_query->row['shipping_country_id'] . "'");
    
                if ($country_query->num_rows) {
                    $shipping_iso_code_2 = $country_query->row['iso_code_2'];
                    $shipping_iso_code_3 = $country_query->row['iso_code_3'];
                } else {
                    $shipping_iso_code_2 = '';
                    $shipping_iso_code_3 = '';
                }
    
                $zone_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "zone` WHERE zone_id = '" . (int)$order_query->row['shipping_zone_id'] . "'");
    
                if ($zone_query->num_rows) {
                    $shipping_zone_code = $zone_query->row['code'];
                } else {
                    $shipping_zone_code = '';
                }
    
                if ($order_query->row['affiliate_id']) {
                    $affiliate_id = $order_query->row['affiliate_id'];
                } else {
                    $affiliate_id = 0;
                }
    
                $this->load->model('marketing/affiliate');
    
                $affiliate_info = $this->model_marketing_affiliate->getAffiliate($affiliate_id);
    
                if ($affiliate_info) {
                    $affiliate_firstname = $affiliate_info['firstname'];
                    $affiliate_lastname = $affiliate_info['lastname'];
                } else {
                    $affiliate_firstname = '';
                    $affiliate_lastname = '';
                }
    
                $this->load->model('localisation/language');
    
                $language_info = $this->model_localisation_language->getLanguage($order_query->row['language_id']);
    
                if ($language_info) {
                    $language_code = $language_info['code'];
                    $language_directory = $language_info['directory'];
                } else {
                    $language_code = '';
                    $language_directory = '';
                }
    
                return array(
                    'order_id'                => $order_query->row['order_id'],
                    'invoice_no'              => $order_query->row['invoice_no'],
                    'invoice_prefix'          => $order_query->row['invoice_prefix'],
                    'store_id'                => $order_query->row['store_id'],
                    'store_name'              => $order_query->row['store_name'],
                    'store_url'               => $order_query->row['store_url'],
                    'customer_id'             => $order_query->row['customer_id'],
                    'customer'                => $order_query->row['customer'],
                    'customer_group_id'       => $order_query->row['customer_group_id'],
                    'firstname'               => $order_query->row['firstname'],
                    'lastname'                => $order_query->row['lastname'],
                    'email'                   => $order_query->row['email'],
                    'telephone'               => $order_query->row['telephone'],
                    'fax'                     => $order_query->row['fax'],
                    'custom_field'            => json_decode($order_query->row['custom_field'], true),
                    'payment_firstname'       => $order_query->row['payment_firstname'],
                    'payment_lastname'        => $order_query->row['payment_lastname'],
                    'payment_company'         => $order_query->row['payment_company'],
                    'payment_address_1'       => $order_query->row['payment_address_1'],
                    'payment_address_2'       => $order_query->row['payment_address_2'],
                    'payment_postcode'        => $order_query->row['payment_postcode'],
                    'payment_city'            => $order_query->row['payment_city'],
                    'payment_zone_id'         => $order_query->row['payment_zone_id'],
                    'payment_zone'            => $order_query->row['payment_zone'],
                    'payment_zone_code'       => $payment_zone_code,
                    'payment_country_id'      => $order_query->row['payment_country_id'],
                    'payment_country'         => $order_query->row['payment_country'],
                    'payment_iso_code_2'      => $payment_iso_code_2,
                    'payment_iso_code_3'      => $payment_iso_code_3,
                    'payment_address_format'  => $order_query->row['payment_address_format'],
                    'payment_custom_field'    => json_decode($order_query->row['payment_custom_field'], true),
                    'payment_method'          => $order_query->row['payment_method'],
                    'payment_code'            => $order_query->row['payment_code'],
                    'shipping_firstname'      => $order_query->row['shipping_firstname'],
                    'shipping_lastname'       => $order_query->row['shipping_lastname'],
                    'shipping_company'        => $order_query->row['shipping_company'],
                    'shipping_address_1'      => $order_query->row['shipping_address_1'],
                    'shipping_address_2'      => $order_query->row['shipping_address_2'],
                    'shipping_postcode'       => $order_query->row['shipping_postcode'],
                    'shipping_city'           => $order_query->row['shipping_city'],
                    'shipping_zone_id'        => $order_query->row['shipping_zone_id'],
                    'shipping_zone'           => $order_query->row['shipping_zone'],
                    'shipping_zone_code'      => $shipping_zone_code,
                    'shipping_country_id'     => $order_query->row['shipping_country_id'],
                    'shipping_country'        => $order_query->row['shipping_country'],
                    'shipping_iso_code_2'     => $shipping_iso_code_2,
                    'shipping_iso_code_3'     => $shipping_iso_code_3,
                    'shipping_address_format' => $order_query->row['shipping_address_format'],
                    'shipping_custom_field'   => json_decode($order_query->row['shipping_custom_field'], true),
                    'shipping_method'         => $order_query->row['shipping_method'],
                    'shipping_code'           => $order_query->row['shipping_code'],
                    'comment'                 => $order_query->row['comment'],
                    'total'                   => $order_query->row['total'],
                    'reward'                  => $reward,
                    'order_status_id'         => $order_query->row['order_status_id'],
                    'affiliate_id'            => $order_query->row['affiliate_id'],
                    'affiliate_firstname'     => $affiliate_firstname,
                    'affiliate_lastname'      => $affiliate_lastname,
                    'commission'              => $order_query->row['commission'],
                    'language_id'             => $order_query->row['language_id'],
                    'language_code'           => $language_code,
                    'language_directory'      => $language_directory,
                    'currency_id'             => $order_query->row['currency_id'],
                    'currency_code'           => $order_query->row['currency_code'],
                    'currency_value'          => $order_query->row['currency_value'],
                    'ip'                      => $order_query->row['ip'],
                    'forwarded_ip'            => $order_query->row['forwarded_ip'],
                    'user_agent'              => $order_query->row['user_agent'],
                    'accept_language'         => $order_query->row['accept_language'],
                    'date_added'              => $order_query->row['date_added'],
                    'date_modified'           => $order_query->row['date_modified']
                );
            } else {
                return;
            }
        }
    
        public function getOrders($data = array()) {
            $sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS status, o.shipping_code, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified FROM `" . DB_PREFIX . "order` o";
    
            if (isset($data['filter_order_status'])) {
                $implode = array();
    
                $order_statuses = explode(',', $data['filter_order_status']);
    
                foreach ($order_statuses as $order_status_id) {
                    $implode[] = "o.order_status_id = '" . (int)$order_status_id . "'";
                }
    
                if ($implode) {
                    $sql .= " WHERE (" . implode(" OR ", $implode) . ")";
                }
            } else {
                $sql .= " WHERE o.order_status_id > '0'";
            }
    
            if (!empty($data['filter_order_id'])) {
                $sql .= " AND o.order_id = '" . (int)$data['filter_order_id'] . "'";
            }
    
            if (!empty($data['filter_customer'])) {
                $sql .= " AND CONCAT(o.firstname, ' ', o.lastname) LIKE '%" . $this->db->escape($data['filter_customer']) . "%'";
            }
    
            if (!empty($data['filter_date_added'])) {
                $sql .= " AND DATE(o.date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
            }
    
            if (!empty($data['filter_date_modified'])) {
                $sql .= " AND DATE(o.date_modified) = DATE('" . $this->db->escape($data['filter_date_modified']) . "')";
            }
    
            if (!empty($data['filter_total'])) {
                $sql .= " AND o.total = '" . (float)$data['filter_total'] . "'";
            }
    
            $sort_data = array(
                'o.order_id',
                'customer',
                'status',
                'o.date_added',
                'o.date_modified',
                'o.total'
            );
    
            if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
                $sql .= " ORDER BY " . $data['sort'];
            } else {
                $sql .= " ORDER BY o.order_id";
            }
    
            if (isset($data['order']) && ($data['order'] == 'DESC')) {
                $sql .= " DESC";
            } else {
                $sql .= " ASC";
            }
    
            if (isset($data['start']) || isset($data['limit'])) {
                if ($data['start'] < 0) {
                    $data['start'] = 0;
                }
    
                if ($data['limit'] < 1) {
                    $data['limit'] = 20;
                }
    
                $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
            }
    
            $query = $this->db->query($sql);
    
            return $query->rows;
        }
    
        public function getOrderProducts($order_id) {
            $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
    
            return $query->rows;
        }
    
        public function getOrderOptions($order_id, $order_product_id) {
            $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . (int)$order_product_id . "'");
    
            return $query->rows;
        }
    
        public function getOrderVouchers($order_id) {
            $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_voucher WHERE order_id = '" . (int)$order_id . "'");
    
            return $query->rows;
        }
    
        public function getOrderVoucherByVoucherId($voucher_id) {
            $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_voucher` WHERE voucher_id = '" . (int)$voucher_id . "'");
    
            return $query->row;
        }
    
        public function getOrderTotals($order_id) {
            $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int)$order_id . "' ORDER BY sort_order");
    
            return $query->rows;
        }
    
        public function getTotalOrders($data = array()) {
            $sql = "SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order`";
    
            if (isset($data['filter_order_status'])) {
                $implode = array();
    
                $order_statuses = explode(',', $data['filter_order_status']);
    
                foreach ($order_statuses as $order_status_id) {
                    $implode[] = "order_status_id = '" . (int)$order_status_id . "'";
                }
    
                if ($implode) {
                    $sql .= " WHERE (" . implode(" OR ", $implode) . ")";
                }
            } else {
                $sql .= " WHERE order_status_id > '0'";
            }
    
            if (!empty($data['filter_order_id'])) {
                $sql .= " AND order_id = '" . (int)$data['filter_order_id'] . "'";
            }
    
            if (!empty($data['filter_customer'])) {
                $sql .= " AND CONCAT(firstname, ' ', lastname) LIKE '%" . $this->db->escape($data['filter_customer']) . "%'";
            }
    
            if (!empty($data['filter_date_added'])) {
                $sql .= " AND DATE(date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
            }
    
            if (!empty($data['filter_date_modified'])) {
                $sql .= " AND DATE(date_modified) = DATE('" . $this->db->escape($data['filter_date_modified']) . "')";
            }
    
            if (!empty($data['filter_total'])) {
                $sql .= " AND total = '" . (float)$data['filter_total'] . "'";
            }
    
            $query = $this->db->query($sql);
    
            return $query->row['total'];
        }
    
        public function getTotalOrdersByStoreId($store_id) {
            $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE store_id = '" . (int)$store_id . "'");
    
            return $query->row['total'];
        }
    
        public function getTotalOrdersByOrderStatusId($order_status_id) {
            $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id = '" . (int)$order_status_id . "' AND order_status_id > '0'");
    
            return $query->row['total'];
        }
    
        public function getTotalOrdersByProcessingStatus() {
            $implode = array();
    
            $order_statuses = $this->config->get('config_processing_status');
    
            foreach ($order_statuses as $order_status_id) {
                $implode[] = "order_status_id = '" . (int)$order_status_id . "'";
            }
    
            if ($implode) {
                $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE " . implode(" OR ", $implode));
    
                return $query->row['total'];
            } else {
                return 0;
            }
        }
    
        public function getTotalOrdersByCompleteStatus() {
            $implode = array();
    
            $order_statuses = $this->config->get('config_complete_status');
    
            foreach ($order_statuses as $order_status_id) {
                $implode[] = "order_status_id = '" . (int)$order_status_id . "'";
            }
    
            if ($implode) {
                $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE " . implode(" OR ", $implode) . "");
    
                return $query->row['total'];
            } else {
                return 0;
            }
        }
    
        public function getTotalOrdersByLanguageId($language_id) {
            $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE language_id = '" . (int)$language_id . "' AND order_status_id > '0'");
    
            return $query->row['total'];
        }
    
        public function getTotalOrdersByCurrencyId($currency_id) {
            $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE currency_id = '" . (int)$currency_id . "' AND order_status_id > '0'");
    
            return $query->row['total'];
        }
    
        public function createInvoiceNo($order_id) {
            $order_info = $this->getOrder($order_id);
    
            if ($order_info && !$order_info['invoice_no']) {
                $query = $this->db->query("SELECT MAX(invoice_no) AS invoice_no FROM `" . DB_PREFIX . "order` WHERE invoice_prefix = '" . $this->db->escape($order_info['invoice_prefix']) . "'");
    
                if ($query->row['invoice_no']) {
                    $invoice_no = $query->row['invoice_no'] + 1;
                } else {
                    $invoice_no = 1;
                }
    
                $this->db->query("UPDATE `" . DB_PREFIX . "order` SET invoice_no = '" . (int)$invoice_no . "', invoice_prefix = '" . $this->db->escape($order_info['invoice_prefix']) . "' WHERE order_id = '" . (int)$order_id . "'");
    
                return $order_info['invoice_prefix'] . $invoice_no;
            }
        }
    
        public function getOrderHistories($order_id, $start = 0, $limit = 10) {
            if ($start < 0) {
                $start = 0;
            }
    
            if ($limit < 1) {
                $limit = 10;
            }
    
            $query = $this->db->query("SELECT oh.date_added, os.name AS status, oh.comment, oh.notify FROM " . DB_PREFIX . "order_history oh LEFT JOIN " . DB_PREFIX . "order_status os ON oh.order_status_id = os.order_status_id WHERE oh.order_id = '" . (int)$order_id . "' AND os.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY oh.date_added DESC LIMIT " . (int)$start . "," . (int)$limit);
    
            return $query->rows;
        }
    
        public function getTotalOrderHistories($order_id) {
            $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "order_history WHERE order_id = '" . (int)$order_id . "'");
    
            return $query->row['total'];
        }
    
        public function getTotalOrderHistoriesByOrderStatusId($order_status_id) {
            $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "order_history WHERE order_status_id = '" . (int)$order_status_id . "'");
    
            return $query->row['total'];
        }
    
        public function getEmailsByProductsOrdered($products, $start, $end) {
            $implode = array();
    
            foreach ($products as $product_id) {
                $implode[] = "op.product_id = '" . (int)$product_id . "'";
            }
    
            $query = $this->db->query("SELECT DISTINCT email FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_product op ON (o.order_id = op.order_id) WHERE (" . implode(" OR ", $implode) . ") AND o.order_status_id <> '0' LIMIT " . (int)$start . "," . (int)$end);
    
            return $query->rows;
        }
    
        public function getTotalEmailsByProductsOrdered($products) {
            $implode = array();
    
            foreach ($products as $product_id) {
                $implode[] = "op.product_id = '" . (int)$product_id . "'";
            }
    
            $query = $this->db->query("SELECT DISTINCT email FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_product op ON (o.order_id = op.order_id) WHERE (" . implode(" OR ", $implode) . ") AND o.order_status_id <> '0'");
    
            return $query->row['total'];
        }
    }
    
    
     
  9. fanton123

    fanton123

    Регистрация:
    24 дек 2012
    Сообщения:
    279
    Симпатии:
    31
    Код:
    $language_info = $this->model_localisation_language->getLanguage($order_query->row['language_id']);
    
                if ($language_info) {
                    $language_code = $language_info['code'];
                    $language_directory = $language_info['directory'];
                } else {
                    $language_code = '';
                    $language_directory = '';
                }
    Подставить свои значения. Предупреждаю что с этим файлом нельзя работать нужно копию создать и подключить. А уже в нем тестировать. Иначе сломаете все!
     
  10. VjS

    VjS

    Регистрация:
    9 ноя 2016
    Сообщения:
    13
    Симпатии:
    2
    Значения поставил (незнаю правильно или нет), ничего не слетело но и не помогло, счет идет все также без изменений.
    поменял так:
    Код:
            $language_info = $this->model_localisation_language->getLanguage($order_query->row['language_id']);
    
                if ($language_info) {
                    $language_code = 'lv';
                    $language_directory = 'latvian';
                } else {
                    $language_code = 'lv';
                    $language_directory = 'latvian';
                }
    }
     
  11. bestleshka

    bestleshka

    Регистрация:
    10 мар 2014
    Сообщения:
    108
    Симпатии:
    80
    Добрый день, установил данный модуль PDF Invoice Pro For Orders. Проблемы с кириллицей или кодировкой. Вместо русских букв знаки вопроса! Хелп!
     
  12. bestleshka

    bestleshka

    Регистрация:
    10 мар 2014
    Сообщения:
    108
    Симпатии:
    80
    Проблема с кириллицей решилась установкой шрифта FREE SERIF в настройках модуля!