Esempio n. 1
0
 function order()
 {
     $jshopConfig = JSFactory::getConfig();
     checkUserLogin();
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $lang = JSFactory::getLang();
     JPluginHelper::importPlugin('jshoppingorder');
     $dispatcher = JDispatcher::getInstance();
     appendPathWay(_JSHOP_MY_ORDERS, SEFLink('index.php?option=com_jshopping&controller=user&task=orders', 0, 0, $jshopConfig->use_ssl));
     $seo = JTable::getInstance("seo", "jshop");
     $seodata = $seo->loadData("myorder-detail");
     if ($seodata->title == "") {
         $seodata->title = _JSHOP_MY_ORDERS;
     }
     setMetaData($seodata->title, $seodata->keyword, $seodata->description);
     $order_id = JRequest::getInt('order_id');
     $order = JTable::getInstance('order', 'jshop');
     $order->load($order_id);
     $dispatcher->trigger('onAfterLoadOrder', array(&$order, &$user));
     appendPathWay(_JSHOP_ORDER_NUMBER . ": " . $order->order_number);
     if ($user->id != $order->user_id) {
         JError::raiseError(500, "Error order number. You are not the owner of this order");
     }
     $order->items = $order->getAllItems();
     $order->weight = $order->getWeightItems();
     $order->status_name = $order->getStatus();
     $order->history = $order->getHistory();
     if ($jshopConfig->client_allow_cancel_order && $order->order_status != $jshopConfig->payment_status_for_cancel_client && !in_array($order->order_status, $jshopConfig->payment_status_disable_cancel_client)) {
         $allow_cancel = 1;
     } else {
         $allow_cancel = 0;
     }
     $order->birthday = getDisplayDate($order->birthday, $jshopConfig->field_birthday_format);
     $order->d_birthday = getDisplayDate($order->d_birthday, $jshopConfig->field_birthday_format);
     $shipping_method = JTable::getInstance('shippingMethod', 'jshop');
     $shipping_method->load($order->shipping_method_id);
     $name = $lang->get("name");
     $description = $lang->get("description");
     $order->shipping_info = $shipping_method->{$name};
     $pm_method = JTable::getInstance('paymentMethod', 'jshop');
     $pm_method->load($order->payment_method_id);
     $order->payment_name = $pm_method->{$name};
     if ($pm_method->show_descr_in_email) {
         $order->payment_description = $pm_method->{$description};
     } else {
         $order->payment_description = "";
     }
     $country = JTable::getInstance('country', 'jshop');
     $country->load($order->country);
     $field_country_name = $lang->get("name");
     $order->country = $country->{$field_country_name};
     $d_country = JTable::getInstance('country', 'jshop');
     $d_country->load($order->d_country);
     $field_country_name = $lang->get("name");
     $order->d_country = $d_country->{$field_country_name};
     $jshopConfig->user_field_client_type[0] = "";
     $order->client_type_name = $jshopConfig->user_field_client_type[$order->client_type];
     $order->delivery_time_name = '';
     $order->delivery_date_f = '';
     if ($jshopConfig->show_delivery_time_checkout) {
         $deliverytimes = JSFactory::getAllDeliveryTime();
         $order->delivery_time_name = $deliverytimes[$order->delivery_times_id];
         if ($order->delivery_time_name == "") {
             $order->delivery_time_name = $order->delivery_time;
         }
     }
     if ($jshopConfig->show_delivery_date && !datenull($order->delivery_date)) {
         $order->delivery_date_f = formatdate($order->delivery_date);
     }
     $order->order_tax_list = $order->getTaxExt();
     $show_percent_tax = 0;
     if (count($order->order_tax_list) > 1 || $jshopConfig->show_tax_in_product) {
         $show_percent_tax = 1;
     }
     if ($jshopConfig->hide_tax) {
         $show_percent_tax = 0;
     }
     $hide_subtotal = 0;
     if (($jshopConfig->hide_tax || count($order->order_tax_list) == 0) && $order->order_discount == 0 && $order->order_payment == 0 && $jshopConfig->without_shipping) {
         $hide_subtotal = 1;
     }
     $text_total = _JSHOP_ENDTOTAL;
     if (($jshopConfig->show_tax_in_product || $jshopConfig->show_tax_product_in_cart) && count($order->order_tax_list) > 0) {
         $text_total = _JSHOP_ENDTOTAL_INKL_TAX;
     }
     $tmp_fields = $jshopConfig->getListFieldsRegister();
     $config_fields = $tmp_fields["address"];
     $count_filed_delivery = $jshopConfig->getEnableDeliveryFiledRegistration('address');
     if ($jshopConfig->order_display_new_digital_products) {
         $product = JTable::getInstance('product', 'jshop');
         foreach ($order->items as $k => $v) {
             $product->product_id = $v->product_id;
             $product->setAttributeActive(unserialize($v->attributes));
             $files = $product->getSaleFiles();
             $order->items[$k]->files = serialize($files);
         }
     }
     $dispatcher->trigger('onBeforeDisplayOrder', array(&$order));
     $view_name = "order";
     $view_config = array("template_path" => JPATH_COMPONENT . "/templates/" . $jshopConfig->template . "/" . $view_name);
     $view = $this->getView($view_name, getDocumentType(), '', $view_config);
     $view->setLayout("order");
     $view->assign('order', $order);
     $view->assign('config', $jshopConfig);
     $view->assign('text_total', $text_total);
     $view->assign('show_percent_tax', $show_percent_tax);
     $view->assign('hide_subtotal', $hide_subtotal);
     $view->assign('image_path', $jshopConfig->live_path . "images");
     $view->assign('config_fields', $config_fields);
     $view->assign('count_filed_delivery', $count_filed_delivery);
     $view->assign('allow_cancel', $allow_cancel);
     $dispatcher->trigger('onBeforeDisplayOrderView', array(&$view));
     $view->display();
 }
Esempio n. 2
0
 function setInvoiceDate()
 {
     if (datenull($this->invoice_date)) {
         $db = JFactory::getDBO();
         $this->invoice_date = getJsDate();
         $query = "UPDATE `#__jshopping_orders` SET invoice_date='" . $db->escape($this->invoice_date) . "' WHERE order_id = '" . $db->escape($this->order_id) . "'";
         $db->setQuery($query);
         $db->query();
     }
 }
Esempio n. 3
0
 function show()
 {
     $order_id = JRequest::getInt("order_id");
     $lang = JSFactory::getLang();
     $db = JFactory::getDBO();
     $jshopConfig = JSFactory::getConfig();
     $orders = $this->getModel("orders");
     $order = JTable::getInstance('order', 'jshop');
     $order->load($order_id);
     $orderstatus = JTable::getInstance('orderStatus', 'jshop');
     $orderstatus->load($order->order_status);
     $name = $lang->get("name");
     $order->status_name = $orderstatus->{$name};
     $id_vendor_cuser = getIdVendorForCUser();
     $shipping_method = JTable::getInstance('shippingMethod', 'jshop');
     $shipping_method->load($order->shipping_method_id);
     $name = $lang->get("name");
     $order->shipping_info = $shipping_method->{$name};
     $pm_method = JTable::getInstance('paymentMethod', 'jshop');
     $pm_method->load($order->payment_method_id);
     $order->payment_name = $pm_method->{$name};
     $order_items = $order->getAllItems();
     if ($jshopConfig->admin_show_vendors) {
         $tmp_order_vendors = $order->getVendors();
         $order_vendors = array();
         foreach ($tmp_order_vendors as $v) {
             $order_vendors[$v->id] = $v;
         }
     }
     $order->weight = $order->getWeightItems();
     $order_history = $order->getHistory();
     $lists['status'] = JHTML::_('select.genericlist', $orders->getAllOrderStatus(), 'order_status', 'class = "inputbox" size = "1" id = "order_status"', 'status_id', 'name', $order->order_status);
     $country = JTable::getInstance('country', 'jshop');
     $country->load($order->country);
     $field_country_name = $lang->get("name");
     $order->country = $country->{$field_country_name};
     $d_country = JTable::getInstance('country', 'jshop');
     $d_country->load($order->d_country);
     $field_country_name = $lang->get("name");
     $order->d_country = $d_country->{$field_country_name};
     $order->title = $jshopConfig->user_field_title[$order->title];
     $order->d_title = $jshopConfig->user_field_title[$order->d_title];
     $order->birthday = getDisplayDate($order->birthday, $jshopConfig->field_birthday_format);
     $order->d_birthday = getDisplayDate($order->d_birthday, $jshopConfig->field_birthday_format);
     $jshopConfig->user_field_client_type[0] = "";
     $order->client_type_name = $jshopConfig->user_field_client_type[$order->client_type];
     $order->order_tax_list = $order->getTaxExt();
     if ($order->coupon_id) {
         $coupon = JTable::getInstance('coupon', 'jshop');
         $coupon->load($order->coupon_id);
         $order->coupon_code = $coupon->coupon_code;
     }
     $tmp_fields = $jshopConfig->getListFieldsRegister();
     $config_fields = $tmp_fields["address"];
     $count_filed_delivery = $jshopConfig->getEnableDeliveryFiledRegistration('address');
     $display_info_only_product = 0;
     if ($jshopConfig->admin_show_vendors && $id_vendor_cuser) {
         if ($order->vendor_id != $id_vendor_cuser) {
             $display_info_only_product = 1;
         }
     }
     $display_block_change_order_status = $order->order_created;
     if ($jshopConfig->admin_show_vendors && $id_vendor_cuser) {
         if ($order->vendor_id != $id_vendor_cuser) {
             $display_block_change_order_status = 0;
         }
         foreach ($order_items as $k => $v) {
             if ($v->vendor_id != $id_vendor_cuser) {
                 unset($order_items[$k]);
             }
         }
     }
     $order->delivery_time_name = '';
     $order->delivery_date_f = '';
     if ($jshopConfig->show_delivery_time_checkout) {
         $deliverytimes = JSFactory::getAllDeliveryTime();
         $order->delivery_time_name = $deliverytimes[$order->delivery_times_id];
         if ($order->delivery_time_name == "") {
             $order->delivery_time_name = $order->delivery_time;
         }
     }
     if ($jshopConfig->show_delivery_date && !datenull($order->delivery_date)) {
         $order->delivery_date_f = formatdate($order->delivery_date);
     }
     $stat_download = $order->getFilesStatDownloads(1);
     JPluginHelper::importPlugin('jshoppingorder');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeDisplayOrderAdmin', array(&$order, &$order_items, &$order_history));
     $print = JRequest::getInt("print");
     $view = $this->getView("orders", 'html');
     $view->setLayout("show");
     $view->assign('config', $jshopConfig);
     $view->assign('order', $order);
     $view->assign('order_history', $order_history);
     $view->assign('order_items', $order_items);
     $view->assign('lists', $lists);
     $view->assign('print', $print);
     $view->assign('config_fields', $config_fields);
     $view->assign('count_filed_delivery', $count_filed_delivery);
     $view->assign('display_info_only_product', $display_info_only_product);
     $view->assign('current_vendor_id', $id_vendor_cuser);
     $view->assign('display_block_change_order_status', $display_block_change_order_status);
     $view->_tmp_ext_discount = '';
     $view->_tmp_ext_shipping_package = '';
     $view->assign('stat_download', $stat_download);
     if ($jshopConfig->admin_show_vendors) {
         $view->assign('order_vendors', $order_vendors);
     }
     JPluginHelper::importPlugin('jshoppingadmin');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeShowOrder', array(&$view));
     $view->displayShow();
 }
Esempio n. 4
0
function getDisplayDate($date, $format = '%d.%m.%Y')
{
    if (datenull($date)) {
        return '';
    }
    $adate = array(substr($date, 0, 4), substr($date, 5, 2), substr($date, 8, 2));
    $str = str_replace(array("%Y", "%m", "%d"), $adate, $format);
    return $str;
}
Esempio n. 5
0
 public function onBeforeDisplayCheckoutFinish(&$text, &$order_id)
 {
     $user = JFactory::getUser();
     if ($user->id > 0) {
         return true;
     }
     // Скрытие текста
     $text = ' ';
     // Показ гостю копии страницы из личного кабинета
     // $dispatcher = JDispatcher::getInstance();
     $jshopConfig = JSFactory::getConfig();
     $lang = JSFactory::getLang();
     $order = JTable::getInstance('order', 'jshop');
     $order->load($order_id);
     $order->items = $order->getAllItems();
     $order->weight = $order->getWeightItems();
     $order->status_name = $order->getStatus();
     $order->history = $order->getHistory();
     $order->order_tax_list = $order->getTaxExt();
     $order->birthday = getDisplayDate($order->birthday, $jshopConfig->field_birthday_format);
     $order->d_birthday = getDisplayDate($order->d_birthday, $jshopConfig->field_birthday_format);
     $name = $lang->get("name");
     $description = $lang->get("description");
     $pm_method = JTable::getInstance('paymentMethod', 'jshop');
     $pm_method->load($order->payment_method_id);
     $order->payment_name = $pm_method->{$name};
     if ($pm_method->show_descr_in_email) {
         $order->payment_description = $pm_method->{$description};
     } else {
         $order->payment_description = "";
     }
     $country = JTable::getInstance('country', 'jshop');
     $country->load($order->country);
     $field_country_name = $lang->get("name");
     $order->country = $country->{$field_country_name};
     $d_country = JTable::getInstance('country', 'jshop');
     $d_country->load($order->d_country);
     $field_country_name = $lang->get("name");
     $order->d_country = $d_country->{$field_country_name};
     $jshopConfig->user_field_client_type[0] = "";
     $order->client_type_name = $jshopConfig->user_field_client_type[$order->client_type];
     $order->delivery_time_name = '';
     $order->delivery_date_f = '';
     if ($jshopConfig->show_delivery_time_checkout) {
         $deliverytimes = JSFactory::getAllDeliveryTime();
         $order->delivery_time_name = $deliverytimes[$order->delivery_times_id];
         if ($order->delivery_time_name == "") {
             $order->delivery_time_name = $order->delivery_time;
         }
     }
     if ($jshopConfig->show_delivery_date && !datenull($order->delivery_date)) {
         $order->delivery_date_f = formatdate($order->delivery_date);
     }
     if ($order->weight == 0 && $jshopConfig->hide_weight_in_cart_weight0) {
         $jshopConfig->show_weight_order = 0;
     }
     $jshopConfig->order_send_pdf_client = 0;
     $show_percent_tax = 0;
     if (count($order->order_tax_list) > 1 || $jshopConfig->show_tax_in_product) {
         $show_percent_tax = 1;
     }
     if ($jshopConfig->hide_tax) {
         $show_percent_tax = 0;
     }
     $hide_subtotal = 0;
     if (($jshopConfig->hide_tax || count($order->order_tax_list) == 0) && $order->order_discount == 0 && $order->order_payment == 0 && $jshopConfig->without_shipping) {
         $hide_subtotal = 1;
     }
     $text_total = _JSHOP_ENDTOTAL;
     if (($jshopConfig->show_tax_in_product || $jshopConfig->show_tax_product_in_cart) && count($order->order_tax_list) > 0) {
         $text_total = _JSHOP_ENDTOTAL_INKL_TAX;
     }
     $tmp_fields = $jshopConfig->getListFieldsRegister();
     $config_fields = $tmp_fields["address"];
     $count_filed_delivery = $jshopConfig->getEnableDeliveryFiledRegistration('address');
     $className = 'JshoppingViewOrder';
     $view_name = "order";
     if (!class_exists($className)) {
         require_once JPATH_COMPONENT . '/views/' . $view_name . '/view.html.php';
     }
     $view_config = array("template_path" => $jshopConfig->template_path . $jshopConfig->template . "/" . $view_name);
     $view = new $className($view_config);
     $view->setLayout("order");
     $view->assign('order', $order);
     $view->assign('config', $jshopConfig);
     $view->assign('text_total', $text_total);
     $view->assign('show_percent_tax', $show_percent_tax);
     $view->assign('hide_subtotal', $hide_subtotal);
     $view->assign('image_path', $jshopConfig->live_path . "images");
     $view->assign('config_fields', $config_fields);
     $view->assign('count_filed_delivery', $count_filed_delivery);
     $view->assign('allow_cancel', false);
     $view->display();
     return true;
 }
function generatePDF($order)
{
    $jshopConfig = JSFactory::getConfig();
    $vendorinfo = $order->getVendorInfo();
    $pdf = new JorderPDF();
    JPluginHelper::importPlugin('jshoppingorder');
    $dispatcher = JDispatcher::getInstance();
    $dispatcher->trigger('onBeforeCreatePdfOrder', array(&$order, &$vendorinfo, &$pdf));
    $pdf->_vendorinfo = $vendorinfo;
    $pdf->SetFont('freesans', '', 8);
    $pdf->setPrintHeader(false);
    $pdf->setPrintFooter(false);
    $pdf->SetMargins(0, 0, 0);
    $pdf->addNewPage();
    $pdf->SetXY(20, 55);
    $pdf->setfontsize(6);
    $pdf->SetTextColor($pdf->pdfcolors[0][0], $pdf->pdfcolors[0][1], $pdf->pdfcolors[0][2]);
    $pdf->MultiCell(80, 3, $vendorinfo->company_name . ", " . $vendorinfo->adress . ", " . $vendorinfo->zip . " " . $vendorinfo->city, 0, 'L');
    $pdf->SetXY(110, 55);
    $pdf->SetFont('freesansb', '', 11);
    $pdf->SetTextColor($pdf->pdfcolors[0][0], $pdf->pdfcolors[0][1], $pdf->pdfcolors[0][2]);
    $pdf->MultiCell(80, 3, _JSHOP_EMAIL_BILL, 0, 'R');
    $pdf->SetFont('freesans', '', 11);
    $pdf->SetXY(20, 60);
    $pdf->MultiCell(80, 4.5, $order->firma_name . "\n" . $order->f_name . " " . $order->l_name . " " . $order->m_name . "\n" . $order->street . " " . $order->home . " " . $order->apartment . "\n" . $order->zip . " " . $order->city . "\n" . $order->country, 0, 'L');
    $pdf->SetFont('freesansi', '', 11);
    $pdf->SetXY(110, 65);
    $pdf->MultiCell(80, 4.5, _JSHOP_ORDER_SHORT_NR . " " . $order->order_number . "\n" . _JSHOP_ORDER_FROM . " " . $order->order_date, 0, 'R');
    if ($jshopConfig->date_invoice_in_invoice) {
        $pdf->SetXY(110, 77);
        $pdf->MultiCell(80, 4.5, _JSHOP_INVOICE_DATE . " " . strftime($jshopConfig->store_date_format, strtotime($order->invoice_date)), 0, 'R');
    }
    $pdf->SetDrawColor($pdf->pdfcolors[0][0], $pdf->pdfcolors[0][1], $pdf->pdfcolors[0][2]);
    $pdf->SetFont('freesans', '', 7);
    if ($vendorinfo->identification_number) {
        $pdf->SetXY(115, 102);
        $pdf->MultiCell(35, 4, _JSHOP_IDENTIFICATION_NUMBER, 1, 'L');
        $pdf->SetXY(150, 102);
        $pdf->MultiCell(40, 4, $vendorinfo->identification_number, 1, 'R');
    }
    if ($vendorinfo->tax_number) {
        $pdf->SetXY(115, 106);
        $pdf->MultiCell(35, 4, _JSHOP_TAX_NUMBER, 1, 'L');
        $pdf->SetXY(150, 106);
        $pdf->MultiCell(40, 4, $vendorinfo->tax_number, 1, 'R');
    }
    $width_filename = 65;
    if (!$jshopConfig->show_product_code_in_order) {
        $width_filename = 87;
    }
    $pdf->setfillcolor($pdf->pdfcolors[1][0], $pdf->pdfcolors[1][1], $pdf->pdfcolors[1][2]);
    $pdf->Rect(20, 116, 170, 4, 'F');
    $pdf->SetFont('freesansb', '', 7.5);
    $pdf->SetXY(20, 116);
    $pdf->MultiCell($width_filename, 4, _JSHOP_NAME_PRODUCT, 1, 'L');
    if ($jshopConfig->show_product_code_in_order) {
        $pdf->SetXY(85, 116);
        $pdf->MultiCell(22, 4, _JSHOP_EAN_PRODUCT, 1, 'L');
    }
    $pdf->SetXY(107, 116);
    $pdf->MultiCell(18, 4, _JSHOP_QUANTITY, 1, 'L');
    $pdf->SetXY(125, 116);
    $pdf->MultiCell(25, 4, _JSHOP_SINGLEPRICE, 1, 'L');
    $pdf->SetXY(150, 116);
    $pdf->MultiCell(40, 4, _JSHOP_TOTAL, 1, 'R');
    $y = 120;
    foreach ($order->products as $prod) {
        $pdf->SetFont('freesans', '', 7);
        $pdf->SetXY(20, $y + 2);
        $pdf->MultiCell($width_filename, 4, $prod->product_name, 0, 'L');
        if ($prod->manufacturer != '') {
            $pdf->SetXY(20, $pdf->getY());
            $pdf->MultiCell($width_filename, 4, _JSHOP_MANUFACTURER . ": " . $prod->manufacturer, 0, 'L');
        }
        if ($prod->product_attributes != "" || $prod->product_freeattributes != "" || $prod->delivery_time || $prod->extra_fields != '') {
            if ($prod->delivery_time) {
                $pdt = _JSHOP_DELIVERY_TIME . ": " . $prod->delivery_time;
            } else {
                $pdt = "";
            }
            $pdf->SetXY(23, $pdf->getY());
            $pdf->SetFont('freesans', '', 6);
            $attribute = sprintAtributeInOrder($prod->product_attributes, "pdf");
            $attribute .= sprintFreeAtributeInOrder($prod->product_freeattributes, "pdf");
            $attribute .= sprintExtraFiledsInOrder($prod->extra_fields, "pdf");
            $attribute .= $prod->_ext_attribute;
            $attribute .= $pdt;
            $pdf->MultiCell(62, 4, $attribute, 0, 'L');
            $pdf->SetFont('freesans', '', 7);
        }
        $y2 = $pdf->getY() + 2;
        if ($jshopConfig->show_product_code_in_order) {
            $pdf->SetXY(85, $y + 2);
            $pdf->MultiCell(22, 4, $prod->product_ean, 0, 'L');
            $y3 = $pdf->getY() + 2;
        } else {
            $y3 = $pdf->getY();
        }
        $pdf->SetXY(107, $y + 2);
        $pdf->MultiCell(18, 4, formatqty($prod->product_quantity) . $prod->_qty_unit, 0, 'L');
        $y4 = $pdf->getY() + 2;
        $pdf->SetXY(125, $y + 2);
        $pdf->MultiCell(25, 4, formatprice($prod->product_item_price, $order->currency_code), 0, 'L');
        if ($prod->_ext_price) {
            $pdf->SetXY(125, $pdf->getY());
            $pdf->MultiCell(25, 4, $prod->_ext_price, 0, 'R');
        }
        if ($jshopConfig->show_tax_product_in_cart && $prod->product_tax > 0) {
            $pdf->SetXY(125, $pdf->getY());
            $pdf->SetFont('freesans', '', 6);
            $text = productTaxInfo($prod->product_tax, $order->display_price);
            $pdf->MultiCell(25, 4, $text, 0, 'L');
        }
        if ($jshopConfig->cart_basic_price_show && $prod->basicprice > 0) {
            $pdf->SetXY(125, $pdf->getY());
            $pdf->SetFont('freesans', '', 6);
            $text = _JSHOP_BASIC_PRICE . ": " . sprintBasicPrice($prod);
            $pdf->MultiCell(25, 4, $text, 0, 'L');
        }
        $y5 = $pdf->getY() + 2;
        $pdf->SetFont('freesans', '', 7);
        $pdf->SetXY(150, $y + 2);
        $pdf->MultiCell(40, 4, formatprice($prod->product_quantity * $prod->product_item_price, $order->currency_code), 0, 'R');
        if ($prod->_ext_price_total) {
            $pdf->SetXY(150, $pdf->getY());
            $pdf->MultiCell(40, 4, $prod->_ext_price_total, 0, 'R');
        }
        if ($jshopConfig->show_tax_product_in_cart && $prod->product_tax > 0) {
            $pdf->SetXY(150, $pdf->getY());
            $pdf->SetFont('freesans', '', 6);
            $text = productTaxInfo($prod->product_tax, $order->display_price);
            $pdf->MultiCell(40, 4, $text, 0, 'R');
        }
        $y6 = $pdf->getY() + 2;
        $yn = max($y2, $y3, $y4, $y5, $y6);
        $pdf->Rect(20, $y, 170, $yn - $y);
        $pdf->Rect(20, $y, 130, $yn - $y);
        if ($jshopConfig->show_product_code_in_order) {
            $pdf->line(85, $y, 85, $yn);
        }
        $pdf->line(107, $y, 107, $yn);
        $pdf->line(125, $y, 125, $yn);
        $y = $yn;
        if ($y > 260) {
            $pdf->addNewPage();
            $y = 60;
        }
    }
    if ($y > 240) {
        $pdf->addNewPage();
        $y = 60;
    }
    $pdf->SetFont('freesans', '', 10);
    if (($jshopConfig->hide_tax || count($order->order_tax_list) == 0) && $order->order_discount == 0 && $order->order_payment == 0 && $jshopConfig->without_shipping) {
        $hide_subtotal = 1;
    } else {
        $hide_subtotal = 0;
    }
    if (!$hide_subtotal) {
        $pdf->SetXY(20, $y);
        $pdf->Rect(20, $y, 170, 5, 'F');
        $pdf->MultiCell(130, 5, _JSHOP_SUBTOTAL, '1', 'R');
        $pdf->SetXY(150, $y);
        $pdf->MultiCell(40, 5, formatprice($order->order_subtotal, $order->currency_code) . $order->_pdf_ext_subtotal, '1', 'R');
    } else {
        $y = $y - 5;
    }
    if ($order->order_discount > 0) {
        $y = $y + 5;
        $pdf->SetXY(20, $y);
        $pdf->Rect(20, $y, 170, 5, 'F');
        $pdf->MultiCell(130, 5, _JSHOP_RABATT_VALUE, '1', 'R');
        $pdf->SetXY(150, $y);
        $pdf->MultiCell(40, 5, "-" . formatprice($order->order_discount, $order->currency_code) . $order->_pdf_ext_discount, '1', 'R');
    }
    if (!$jshopConfig->without_shipping) {
        $pdf->SetXY(20, $y + 5);
        $pdf->Rect(20, $y + 5, 170, 5, 'F');
        $pdf->MultiCell(130, 5, _JSHOP_SHIPPING_PRICE, '1', 'R');
        $pdf->SetXY(150, $y + 5);
        $pdf->MultiCell(40, 5, formatprice($order->order_shipping, $order->currency_code) . $order->_pdf_ext_shipping, '1', 'R');
        if ($order->order_package > 0 || $jshopConfig->display_null_package_price) {
            $y = $y + 5;
            $pdf->SetXY(20, $y + 5);
            $pdf->Rect(20, $y + 5, 170, 5, 'F');
            $pdf->MultiCell(130, 5, _JSHOP_PACKAGE_PRICE, '1', 'R');
            $pdf->SetXY(150, $y + 5);
            $pdf->MultiCell(40, 5, formatprice($order->order_package, $order->currency_code) . $order->_pdf_ext_shipping_package, '1', 'R');
        }
    } else {
        $y = $y - 5;
    }
    if ($order->order_payment != 0) {
        $y = $y + 5;
        $pdf->SetXY(20, $y + 5);
        $pdf->Rect(20, $y + 5, 170, 5, 'F');
        $pdf->MultiCell(130, 5, $order->payment_name, '1', 'R');
        $pdf->SetXY(150, $y + 5);
        $pdf->MultiCell(40, 5, formatprice($order->order_payment, $order->currency_code) . $order->_pdf_ext_payment, '1', 'R');
    }
    $show_percent_tax = 0;
    if (count($order->order_tax_list) > 1 || $jshopConfig->show_tax_in_product) {
        $show_percent_tax = 1;
    }
    if ($jshopConfig->hide_tax) {
        $show_percent_tax = 0;
    }
    $dispatcher->trigger('onBeforeCreatePdfOrderBeforeEndTotal', array(&$order, &$pdf, &$y));
    if (!$jshopConfig->hide_tax) {
        foreach ($order->order_tax_list as $percent => $value) {
            $pdf->SetXY(20, $y + 10);
            $pdf->Rect(20, $y + 10, 170, 5, 'F');
            $text = displayTotalCartTaxName($order->display_price);
            if ($show_percent_tax) {
                $text = $text . " " . formattax($percent) . "%";
            }
            $pdf->MultiCell(130, 5, $text, '1', 'R');
            $pdf->SetXY(150, $y + 10);
            $pdf->MultiCell(40, 5, formatprice($value, $order->currency_code) . $order->_pdf_ext_tax[$percent], '1', 'R');
            $y = $y + 5;
        }
    }
    $text_total = _JSHOP_ENDTOTAL;
    if (($jshopConfig->show_tax_in_product || $jshopConfig->show_tax_product_in_cart) && count($order->order_tax_list) > 0) {
        $text_total = _JSHOP_ENDTOTAL_INKL_TAX;
    }
    $pdf->SetFont('freesansb', '', 10);
    $pdf->SetXY(20, $y + 10);
    $pdf->Rect(20, $y + 10, 170, 5.1, 'F');
    $pdf->MultiCell(130, 5, $text_total, '1', 'R');
    $pdf->SetXY(150, $y + 10);
    $pdf->MultiCell(40, 5, formatprice($order->order_total, $order->currency_code) . $order->_pdf_ext_total, '1', 'R');
    if ($jshopConfig->display_tax_id_in_pdf && $order->tax_number) {
        $y = $y + 5.2;
        $pdf->SetFont('freesans', '', 7);
        $pdf->SetXY(20, $y + 10);
        $pdf->MultiCell(170, 4, _JSHOP_TAX_NUMBER . ": " . $order->tax_number, '1', 'L');
    }
    $dispatcher->trigger('onBeforeCreatePdfOrderAfterEndTotal', array(&$order, &$pdf, &$y));
    $y = $y + 10;
    if ($jshopConfig->show_delivery_time_checkout && ($order->delivery_times_id || $order->delivery_time)) {
        if ($y > 250) {
            $pdf->addNewPage();
            $y = 60;
        }
        $deliverytimes = JSFactory::getAllDeliveryTime();
        $delivery = $deliverytimes[$order->delivery_times_id];
        if ($delivery == "") {
            $delivery = $order->delivery_time;
        }
        $y = $y + 8;
        $pdf->SetFont('freesans', '', 7);
        $pdf->SetXY(20, $y);
        $pdf->MultiCell(170, 4, _JSHOP_ORDER_DELIVERY_TIME . ": " . $delivery, '0', 'L');
    }
    if ($jshopConfig->show_delivery_date && !datenull($order->delivery_date)) {
        if ($y > 250) {
            $pdf->addNewPage();
            $y = 60;
        }
        $delivery_date_f = formatdate($order->delivery_date);
        $y = $y + 6;
        $pdf->SetFont('freesans', '', 7);
        $pdf->SetXY(20, $y);
        $pdf->MultiCell(170, 4, _JSHOP_DELIVERY_DATE . ": " . $delivery_date_f, '0', 'L');
    }
    if ($jshopConfig->weight_in_invoice) {
        if ($y > 250) {
            $pdf->addNewPage();
            $y = 60;
        }
        $y = $y + 6;
        $pdf->SetFont('freesans', '', 7);
        $pdf->SetXY(20, $y);
        $pdf->MultiCell(170, 4, _JSHOP_WEIGHT_PRODUCTS . ": " . formatweight($order->weight), '0', 'L');
    }
    if (!$jshopConfig->without_payment && $jshopConfig->payment_in_invoice) {
        if ($y > 240) {
            $pdf->addNewPage();
            $y = 60;
        }
        $y = $y + 6;
        $pdf->SetFont('freesansb', '', 7);
        $pdf->SetXY(20, $y);
        $pdf->MultiCell(170, 4, _JSHOP_PAYMENT_INFORMATION, '0', 'L');
        $y = $y + 4;
        $pdf->SetFont('freesans', '', 7);
        $pdf->SetXY(20, $y);
        $pdf->MultiCell(170, 4, $order->payment_name, '0', 'L');
        $payment_descr = trim(trim($order->payment_information) . "\n" . $order->payment_description);
        if ($payment_descr != '') {
            $y = $y + 4;
            $pdf->SetXY(20, $y);
            $pdf->MultiCell(170, 4, strip_tags($payment_descr), '0', 'L');
            $y = $pdf->getY() - 4;
        }
    }
    if (!$jshopConfig->without_shipping && $jshopConfig->shipping_in_invoice) {
        if ($y > 250) {
            $pdf->addNewPage();
            $y = 60;
        }
        $y = $y + 6;
        $pdf->SetFont('freesansb', '', 7);
        $pdf->SetXY(20, $y);
        $pdf->MultiCell(170, 4, _JSHOP_SHIPPING_INFORMATION, '0', 'L');
        $y = $y + 4;
        $pdf->SetFont('freesans', '', 7);
        $pdf->SetXY(20, $y);
        $pdf->MultiCell(170, 4, $order->shipping_information, '0', 'L');
    }
    $y = $y + 20;
    if ($y > 240) {
        $pdf->addNewPage();
        $y = 60;
    }
    $pdf->SetFont('freesans', '', 7);
    $y2 = 0;
    if ($vendorinfo->benef_bank_info || $vendorinfo->benef_bic || $vendorinfo->benef_conto || $vendorinfo->benef_payee || $vendorinfo->benef_iban || $vendorinfo->benef_swift) {
        $pdf->SetXY(115, $y);
        $pdf->Rect(115, $y, 75, 4, 'F');
        $pdf->MultiCell(75, 4, _JSHOP_BANK, '1', 'L');
    }
    if ($vendorinfo->benef_bank_info) {
        $y2 += 4;
        $pdf->SetXY(115, $y2 + $y);
        $pdf->MultiCell(75, 4, _JSHOP_BENEF_BANK_NAME, '1', 'L');
    }
    if ($vendorinfo->benef_bic) {
        $y2 += 4;
        $pdf->SetXY(115, $y2 + $y);
        $pdf->MultiCell(75, 4, _JSHOP_BENEF_BIC, '1', 'L');
    }
    if ($vendorinfo->benef_conto) {
        $y2 += 4;
        $pdf->SetXY(115, $y2 + $y);
        $pdf->MultiCell(75, 4, _JSHOP_BENEF_CONTO, '1', 'L');
    }
    if ($vendorinfo->benef_payee) {
        $y2 += 4;
        $pdf->SetXY(115, $y2 + $y);
        $pdf->MultiCell(75, 4, _JSHOP_BENEF_PAYEE, '1', 'L');
    }
    if ($vendorinfo->benef_iban) {
        $y2 += 4;
        $pdf->SetXY(115, $y2 + $y);
        $pdf->MultiCell(75, 4, _JSHOP_BENEF_IBAN, '1', 'L');
    }
    if ($vendorinfo->benef_swift) {
        $y2 += 4;
        $pdf->SetXY(115, $y2 + $y);
        $pdf->MultiCell(75, 4, _JSHOP_BENEF_SWIFT, '1', 'L');
    }
    if ($vendorinfo->interm_name || $vendorinfo->interm_swift) {
        $y2 += 4;
        $pdf->Rect(115, $y2 + $y, 75, 4, 'F');
        $pdf->SetXY(115, $y2 + $y);
        $pdf->MultiCell(75, 4, _JSHOP_INTERM_BANK, '1', 'L');
    }
    if ($vendorinfo->interm_name) {
        $y2 += 4;
        $pdf->SetXY(115, $y2 + $y);
        $pdf->MultiCell(75, 4, _JSHOP_INTERM_NAME, '1', 'L');
    }
    if ($vendorinfo->interm_swift) {
        $y2 += 4;
        $pdf->SetXY(115, $y2 + $y);
        $pdf->MultiCell(75, 4, _JSHOP_INTERM_SWIFT, '1', 'L');
    }
    $y2 = 0;
    if ($vendorinfo->benef_bank_info) {
        $y2 += 4;
        $pdf->SetXY(115, $y2 + $y);
        $pdf->MultiCell(75, 4, $vendorinfo->benef_bank_info, '0', 'R');
    }
    if ($vendorinfo->benef_bic) {
        $y2 += 4;
        $pdf->SetXY(115, $y2 + $y);
        $pdf->MultiCell(75, 4, $vendorinfo->benef_bic, '0', 'R');
    }
    if ($vendorinfo->benef_conto) {
        $y2 += 4;
        $pdf->SetXY(115, $y2 + $y);
        $pdf->MultiCell(75, 4, $vendorinfo->benef_conto, '0', 'R');
    }
    if ($vendorinfo->benef_payee) {
        $y2 += 4;
        $pdf->SetXY(115, $y2 + $y);
        $pdf->MultiCell(75, 4, $vendorinfo->benef_payee, '0', 'R');
    }
    if ($vendorinfo->benef_iban) {
        $y2 += 4;
        $pdf->SetXY(115, $y2 + $y);
        $pdf->MultiCell(75, 4, $vendorinfo->benef_iban, '0', 'R');
    }
    if ($vendorinfo->benef_swift) {
        $y2 += 4;
        $pdf->SetXY(115, $y2 + $y);
        $pdf->MultiCell(75, 4, $vendorinfo->benef_swift, '0', 'R');
    }
    $y2 += 4;
    if ($vendorinfo->interm_name) {
        $y2 += 4;
        $pdf->SetXY(115, $y2 + $y);
        $pdf->MultiCell(75, 4, $vendorinfo->interm_name, '0', 'R');
    }
    if ($vendorinfo->interm_swift) {
        $y2 += 4;
        $pdf->SetXY(115, $y2 + $y);
        $pdf->MultiCell(75, 4, $vendorinfo->interm_swift, '0', 'R');
    }
    if ($vendorinfo->additional_information) {
        if ($y2 + $y > 240) {
            $pdf->addNewPage();
            $y = 50;
            $y2 = 0;
        }
        $y2 += 6;
        $pdf->SetXY(20, $y2 + $y);
        $pdf->MultiCell(170, 4, $vendorinfo->additional_information, '0', 'L');
    }
    $name_pdf = $order->order_id . "_" . md5(uniqid(rand(0, 100))) . ".pdf";
    $dispatcher->trigger('onBeforeCreatePdfOrderEnd', array(&$order, &$pdf, &$name_pdf));
    $pdf->Output($jshopConfig->pdf_orders_path . "/" . $name_pdf, 'F');
    return $name_pdf;
}
Esempio n. 7
0
 function sendOrderEmail($order_id, $manuallysend = 0)
 {
     $mainframe = JFactory::getApplication();
     $lang = JSFactory::getLang();
     $jshopConfig = JSFactory::getConfig();
     $db = JFactory::getDBO();
     $order = JSFactory::getTable('order', 'jshop');
     $jshopConfig->user_field_title[0] = '';
     $jshopConfig->user_field_client_type[0] = '';
     $file_generete_pdf_order = $jshopConfig->file_generete_pdf_order;
     $tmp_fields = $jshopConfig->getListFieldsRegister();
     $config_fields = $tmp_fields["address"];
     $count_filed_delivery = $jshopConfig->getEnableDeliveryFiledRegistration('address');
     $order->load($order_id);
     $status = JSFactory::getTable('orderStatus', 'jshop');
     $status->load($order->order_status);
     $name = $lang->get("name");
     $order->status = $status->{$name};
     $order->order_date = strftime($jshopConfig->store_date_format, strtotime($order->order_date));
     $order->products = $order->getAllItems();
     $order->weight = $order->getWeightItems();
     if ($jshopConfig->show_delivery_time_checkout) {
         $deliverytimes = JSFactory::getAllDeliveryTime();
         $order->order_delivery_time = $deliverytimes[$order->delivery_times_id];
         if ($order->order_delivery_time == "") {
             $order->order_delivery_time = $order->delivery_time;
         }
     }
     $order->order_tax_list = $order->getTaxExt();
     $show_percent_tax = 0;
     if (count($order->order_tax_list) > 1 || $jshopConfig->show_tax_in_product) {
         $show_percent_tax = 1;
     }
     if ($jshopConfig->hide_tax) {
         $show_percent_tax = 0;
     }
     $hide_subtotal = 0;
     if (($jshopConfig->hide_tax || count($order->order_tax_list) == 0) && $order->order_discount == 0 && $jshopConfig->without_shipping && $order->order_payment == 0) {
         $hide_subtotal = 1;
     }
     if ($order->weight == 0 && $jshopConfig->hide_weight_in_cart_weight0) {
         $jshopConfig->show_weight_order = 0;
     }
     $country = JSFactory::getTable('country', 'jshop');
     $country->load($order->country);
     $field_country_name = $lang->get("name");
     $order->country = $country->{$field_country_name};
     $d_country = JSFactory::getTable('country', 'jshop');
     $d_country->load($order->d_country);
     $field_country_name = $lang->get("name");
     $order->d_country = $d_country->{$field_country_name};
     if ($jshopConfig->show_delivery_date && !datenull($order->delivery_date)) {
         $order->delivery_date_f = formatdate($order->delivery_date);
     } else {
         $order->delivery_date_f = '';
     }
     $order->title = $jshopConfig->user_field_title[$order->title];
     $order->d_title = $jshopConfig->user_field_title[$order->d_title];
     $order->birthday = getDisplayDate($order->birthday, $jshopConfig->field_birthday_format);
     $order->d_birthday = getDisplayDate($order->d_birthday, $jshopConfig->field_birthday_format);
     $order->client_type_name = $jshopConfig->user_field_client_type[$order->client_type];
     $shippingMethod = JSFactory::getTable('shippingMethod', 'jshop');
     $shippingMethod->load($order->shipping_method_id);
     $pm_method = JSFactory::getTable('paymentMethod', 'jshop');
     $pm_method->load($order->payment_method_id);
     $paymentsysdata = $pm_method->getPaymentSystemData();
     $payment_system = $paymentsysdata->paymentSystem;
     $name = $lang->get("name");
     $description = $lang->get("description");
     $order->shipping_information = $shippingMethod->{$name};
     $shippingForm = $shippingMethod->getShippingForm();
     if ($shippingForm) {
         $shippingForm->prepareParamsDispayMail($order, $shippingMethod);
     }
     $order->payment_name = $pm_method->{$name};
     $order->payment_information = $order->payment_params;
     if ($payment_system) {
         $payment_system->prepareParamsDispayMail($order, $pm_method);
     }
     if ($pm_method->show_descr_in_email) {
         $order->payment_description = $pm_method->{$description};
     } else {
         $order->payment_description = "";
     }
     $statictext = JSFactory::getTable("statictext", "jshop");
     $rowstatictext = $statictext->loadData("order_email_descr");
     $order_email_descr = $rowstatictext->text;
     $order_email_descr = str_replace("{name}", $order->f_name, $order_email_descr);
     $order_email_descr = str_replace("{family}", $order->l_name, $order_email_descr);
     $order_email_descr = str_replace("{email}", $order->email, $order_email_descr);
     $order_email_descr = str_replace("{title}", $order->title, $order_email_descr);
     $rowstatictext = $statictext->loadData("order_email_descr_end");
     $order_email_descr_end = $rowstatictext->text;
     $order_email_descr_end = str_replace("{name}", $order->f_name, $order_email_descr_end);
     $order_email_descr_end = str_replace("{family}", $order->l_name, $order_email_descr_end);
     $order_email_descr_end = str_replace("{email}", $order->email, $order_email_descr_end);
     $order_email_descr_end = str_replace("{title}", $order->title, $order_email_descr_end);
     if ($jshopConfig->show_return_policy_text_in_email_order) {
         $list = $order->getReturnPolicy();
         $listtext = array();
         foreach ($list as $v) {
             $listtext[] = $v->text;
         }
         $rptext = implode('<div class="return_policy_space"></div>', $listtext);
         $order_email_descr_end = $rptext . $order_email_descr_end;
     }
     $text_total = _JSHOP_ENDTOTAL;
     if (($jshopConfig->show_tax_in_product || $jshopConfig->show_tax_product_in_cart) && count($order->order_tax_list) > 0) {
         $text_total = _JSHOP_ENDTOTAL_INKL_TAX;
     }
     $uri = JURI::getInstance();
     $liveurlhost = $uri->toString(array("scheme", 'host', 'port'));
     if ($jshopConfig->admin_show_vendors) {
         $listVendors = $order->getVendors();
     } else {
         $listVendors = array();
     }
     $vendors_send_message = $jshopConfig->vendor_order_message_type == 1;
     $vendor_send_order = $jshopConfig->vendor_order_message_type == 2;
     $vendor_send_order_admin = $jshopConfig->vendor_order_message_type == 2 && $order->vendor_type == 0 && $order->vendor_id || $jshopConfig->vendor_order_message_type == 3;
     if ($vendor_send_order_admin) {
         $vendor_send_order = 0;
     }
     $admin_send_order = 1;
     if ($jshopConfig->admin_not_send_email_order_vendor_order && $vendor_send_order_admin && count($listVendors)) {
         $admin_send_order = 0;
     }
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeSendEmailsOrder', array(&$order, &$listVendors, &$file_generete_pdf_order, &$admin_send_order));
     //client message
     include_once JPATH_COMPONENT_SITE . "/views/checkout/view.html.php";
     $view_name = "checkout";
     $view_config = array("template_path" => $jshopConfig->template_path . $jshopConfig->template . "/" . $view_name);
     $view = new JshoppingViewCheckout($view_config);
     $view->setLayout("orderemail");
     $view->assign('client', 1);
     $view->assign('show_customer_info', 1);
     $view->assign('show_weight_order', 1);
     $view->assign('show_total_info', 1);
     $view->assign('show_payment_shipping_info', 1);
     $view->assign('config_fields', $config_fields);
     $view->assign('count_filed_delivery', $count_filed_delivery);
     $view->assign('order_email_descr', $order_email_descr);
     $view->assign('order_email_descr_end', $order_email_descr_end);
     $view->assign('config', $jshopConfig);
     $view->assign('order', $order);
     $view->assign('products', $order->products);
     $view->assign('show_percent_tax', $show_percent_tax);
     $view->assign('hide_subtotal', $hide_subtotal);
     $view->assign('noimage', $jshopConfig->noimage);
     $view->assign('text_total', $text_total);
     $view->assign('liveurlhost', $liveurlhost);
     $dispatcher->trigger('onBeforeCreateTemplateOrderMail', array(&$view));
     $message_client = $view->loadTemplate();
     //admin message
     $view_name = "checkout";
     $view_config = array("template_path" => $jshopConfig->template_path . $jshopConfig->template . "/" . $view_name);
     $view = new JshoppingViewCheckout($view_config);
     $view->setLayout("orderemail");
     $view->assign('client', 0);
     $view->assign('show_customer_info', 1);
     $view->assign('show_weight_order', 1);
     $view->assign('show_total_info', 1);
     $view->assign('show_payment_shipping_info', 1);
     $view->assign('config_fields', $config_fields);
     $view->assign('count_filed_delivery', $count_filed_delivery);
     $view->assign('order_email_descr', $order_email_descr);
     $view->assign('order_email_descr_end', $order_email_descr_end);
     $view->assign('config', $jshopConfig);
     $view->assign('order', $order);
     $view->assign('products', $order->products);
     $view->assign('show_percent_tax', $show_percent_tax);
     $view->assign('hide_subtotal', $hide_subtotal);
     $view->assign('noimage', $jshopConfig->noimage);
     $view->assign('text_total', $text_total);
     $view->assign('liveurlhost', $liveurlhost);
     $dispatcher->trigger('onBeforeCreateTemplateOrderMail', array(&$view));
     $message_admin = $view->loadTemplate();
     //vendors messages or order
     if ($vendors_send_message || $vendor_send_order) {
         foreach ($listVendors as $k => $datavendor) {
             if ($vendors_send_message) {
                 $show_customer_info = 0;
                 $show_weight_order = 0;
                 $show_total_info = 0;
                 $show_payment_shipping_info = 0;
             }
             if ($vendor_send_order) {
                 $show_customer_info = 1;
                 $show_weight_order = 0;
                 $show_total_info = 0;
                 $show_payment_shipping_info = 1;
             }
             $vendor_order_items = $order->getVendorItems($datavendor->id);
             $view_name = "checkout";
             $view_config = array("template_path" => $jshopConfig->template_path . $jshopConfig->template . "/" . $view_name);
             $view = new JshoppingViewCheckout($view_config);
             $view->setLayout("orderemail");
             $view->assign('client', 0);
             $view->assign('show_customer_info', $show_customer_info);
             $view->assign('show_weight_order', $show_weight_order);
             $view->assign('show_total_info', $show_total_info);
             $view->assign('show_payment_shipping_info', $show_payment_shipping_info);
             $view->assign('config_fields', $config_fields);
             $view->assign('count_filed_delivery', $count_filed_delivery);
             $view->assign('order_email_descr', $order_email_descr);
             $view->assign('order_email_descr_end', $order_email_descr_end);
             $view->assign('config', $jshopConfig);
             $view->assign('order', $order);
             $view->assign('products', $vendor_order_items);
             $view->assign('show_percent_tax', $show_percent_tax);
             $view->assign('hide_subtotal', $hide_subtotal);
             $view->assign('noimage', $jshopConfig->noimage);
             $view->assign('text_total', $text_total);
             $view->assign('liveurlhost', $liveurlhost);
             $view->assign('show_customer_info', $vendor_send_order);
             $dispatcher->trigger('onBeforeCreateTemplateOrderPartMail', array(&$view));
             $message_vendor = $view->loadTemplate();
             $listVendors[$k]->message = $message_vendor;
         }
     }
     $pdfsend = 1;
     if ($jshopConfig->send_invoice_manually && !$manuallysend) {
         $pdfsend = 0;
     }
     if ($pdfsend && ($jshopConfig->order_send_pdf_client || $jshopConfig->order_send_pdf_admin)) {
         include_once $file_generete_pdf_order;
         $order->setInvoiceDate();
         $order->pdf_file = generatePdf($order, $jshopConfig);
         $order->insertPDF();
     }
     $mailfrom = $mainframe->getCfg('mailfrom');
     $fromname = $mainframe->getCfg('fromname');
     //send mail client
     if ($order->email) {
         $mailer = JFactory::getMailer();
         $mailer->setSender(array($mailfrom, $fromname));
         $mailer->addRecipient($order->email);
         $mailer->setSubject(sprintf(_JSHOP_NEW_ORDER, $order->order_number, $order->f_name . " " . $order->l_name));
         $mailer->setBody($message_client);
         if ($pdfsend && $jshopConfig->order_send_pdf_client) {
             $mailer->addAttachment($jshopConfig->pdf_orders_path . "/" . $order->pdf_file);
         }
         $mailer->isHTML(true);
         $dispatcher->trigger('onBeforeSendOrderEmailClient', array(&$mailer, &$order, &$manuallysend, &$pdfsend));
         $send = $mailer->Send();
     }
     //send mail admin
     if ($admin_send_order) {
         $mailer = JFactory::getMailer();
         $mailer->setSender(array($mailfrom, $fromname));
         $mailer->addRecipient(explode(',', $jshopConfig->contact_email));
         $mailer->setSubject(sprintf(_JSHOP_NEW_ORDER, $order->order_number, $order->f_name . " " . $order->l_name));
         $mailer->setBody($message_admin);
         if ($pdfsend && $jshopConfig->order_send_pdf_admin) {
             $mailer->addAttachment($jshopConfig->pdf_orders_path . "/" . $order->pdf_file);
         }
         $mailer->isHTML(true);
         $dispatcher->trigger('onBeforeSendOrderEmailAdmin', array(&$mailer, &$order, &$manuallysend, &$pdfsend));
         $send = $mailer->Send();
     }
     //send mail vendors
     if ($vendors_send_message || $vendor_send_order) {
         foreach ($listVendors as $k => $vendor) {
             $mailer = JFactory::getMailer();
             $mailer->setSender(array($mailfrom, $fromname));
             $mailer->addRecipient($vendor->email);
             $mailer->setSubject(sprintf(_JSHOP_NEW_ORDER_V, $order->order_number, ""));
             $mailer->setBody($vendor->message);
             $mailer->isHTML(true);
             $dispatcher->trigger('onBeforeSendOrderEmailVendor', array(&$mailer, &$order, &$manuallysend, &$pdfsend, &$vendor, &$vendors_send_message, &$vendor_send_order));
             $send = $mailer->Send();
         }
     }
     //vendor send order
     if ($vendor_send_order_admin) {
         foreach ($listVendors as $k => $vendor) {
             $mailer = JFactory::getMailer();
             $mailer->setSender(array($mailfrom, $fromname));
             $mailer->addRecipient($vendor->email);
             $mailer->setSubject(sprintf(_JSHOP_NEW_ORDER, $order->order_number, $order->f_name . " " . $order->l_name));
             $mailer->setBody($message_admin);
             if ($pdfsend && $jshopConfig->order_send_pdf_admin) {
                 $mailer->addAttachment($jshopConfig->pdf_orders_path . "/" . $order->pdf_file);
             }
             $mailer->isHTML(true);
             $dispatcher->trigger('onBeforeSendOrderEmailVendorOrder', array(&$mailer, &$order, &$manuallysend, &$pdfsend, &$vendor, &$vendors_send_message, &$vendor_send_order));
             $send = $mailer->Send();
         }
     }
     $dispatcher->trigger('onAfterSendEmailsOrder', array(&$order));
 }
Esempio n. 8
0
 function prepareOrderPrint($page = '', $date_format = 0)
 {
     $jshopConfig = JSFactory::getConfig();
     $lang = JSFactory::getLang();
     $jshopConfig->user_field_title[0] = '';
     $jshopConfig->user_field_client_type[0] = '';
     if ($page == 'order_show') {
         $this->status_name = $this->getStatus();
     } else {
         $this->status = $this->getStatus();
     }
     if (!isset($this->order_date_print)) {
         $this->order_date_print = formatdate($this->order_date);
         $this->order_datetime_print = formatdate($this->order_date, 1);
         if ($date_format) {
             $this->order_date = $this->order_date_print;
         }
     }
     $this->products = $this->getAllItems();
     $this->weight = $this->getWeightItems();
     if ($jshopConfig->show_delivery_time_checkout) {
         $deliverytimes = JSFactory::getAllDeliveryTime();
         if (isset($deliverytimes[$this->delivery_times_id])) {
             $this->order_delivery_time = $deliverytimes[$this->delivery_times_id];
         } else {
             $this->order_delivery_time = '';
         }
         if ($this->order_delivery_time == "") {
             $this->order_delivery_time = $this->delivery_time;
         }
         if ($page == 'order_show') {
             $this->delivery_time_name = $this->order_delivery_time;
         }
     }
     $this->order_tax_list = $this->getTaxExt();
     if (!isset($this->country_id)) {
         $this->country_id = $this->country;
         $this->d_country_id = $this->d_country;
     }
     $country = JSFactory::getTable('country', 'jshop');
     $country->load($this->country_id);
     $this->country = $country->getName();
     $d_country = JSFactory::getTable('country', 'jshop');
     $d_country->load($this->d_country_id);
     $this->d_country = $d_country->getName();
     if ($jshopConfig->show_delivery_date && !datenull($this->delivery_date)) {
         $this->delivery_date_f = formatdate($this->delivery_date);
     } else {
         $this->delivery_date_f = '';
     }
     if (!isset($this->title_id)) {
         $this->title_id = $this->title;
         $this->d_title_id = $this->d_title;
     }
     if (!isset($this->birthday_date)) {
         $this->birthday_date = $this->birthday;
         $this->d_birthday_date = $this->d_birthday;
     }
     $this->title = $jshopConfig->user_field_title[$this->title_id];
     $this->d_title = $jshopConfig->user_field_title[$this->d_title_id];
     $this->birthday = getDisplayDate($this->birthday_date, $jshopConfig->field_birthday_format);
     $this->d_birthday = getDisplayDate($this->d_birthday_date, $jshopConfig->field_birthday_format);
     $this->client_type_name = $this->getClientTypeName();
     $shippingMethod = $this->getShipping();
     $pm_method = $this->getPayment();
     $paymentsysdata = $pm_method->getPaymentSystemData();
     $payment_system = $paymentsysdata->paymentSystem;
     if ($page == 'order_show') {
         $this->shipping_info = $shippingMethod->getName();
     } else {
         $this->shipping_information = $shippingMethod->getName();
     }
     $shippingForm = $shippingMethod->getShippingForm();
     if ($shippingForm) {
         $shippingForm->prepareParamsDispayMail($order, $shippingMethod);
     }
     $this->payment_name = $pm_method->getName();
     $this->payment_information = $this->payment_params;
     if ($payment_system) {
         $payment_system->prepareParamsDispayMail($order, $pm_method);
     }
     if ($pm_method->show_descr_in_email) {
         $this->payment_description = $pm_method->getDescription();
     } else {
         $this->payment_description = "";
     }
     if ($this->coupon_id) {
         $coupon = JSFactory::getTable('coupon', 'jshop');
         $coupon->load($this->coupon_id);
         $this->coupon_code = $coupon->coupon_code;
     }
     if ($page == 'order_show') {
         $this->history = $this->getHistory();
     }
     $this->prepareOrderPrint = 1;
 }