Пример #1
0
 public function index()
 {
     $data = array();
     $data['systemMessageType'] = SYS_MSG_ADD_CREDIT;
     $data = array_merge($data, $this->parameters);
     $addCreditRequests = Messaging::getSystemMessages($data);
     //        $this->log->write(print_r($addCreditRequests, true));
     $this->data['customersToFilterBy'] = $this->getCustomers();
     $this->data['requests'] = array();
     foreach ($addCreditRequests as $addCreditRequest) {
         $customer = CustomerDAO::getInstance()->getCustomer($addCreditRequest['senderId']);
         $actions = array();
         if ($addCreditRequest['data']->status == ADD_CREDIT_STATUS_PENDING) {
             $actions['accept'] = array('text' => $this->language->get('ACCEPT'), 'onclick' => 'acceptRequest(' . $addCreditRequest['messageId'] . ', this)');
             $actions['reject'] = array('text' => $this->language->get('REJECT'), 'onclick' => 'rejectRequest(' . $addCreditRequest['messageId'] . ', this)');
         }
         $this->data['requests'][] = array('requestId' => $addCreditRequest['messageId'], 'actions' => $actions, 'amount' => $addCreditRequest['data']->amount, 'comment' => $addCreditRequest['data']->comment, 'currency' => $addCreditRequest['data']->currency, 'customerName' => $customer['lastname'] . ' ' . $customer['firstname'] . ' / ' . $customer['nickname'], 'customerUrl' => $this->url->link('sale/customer/update', 'token=' . $this->session->data['token'] . '&customer_id=' . $addCreditRequest['senderId'], 'SSL'), 'status' => $this->load->model('localisation/requestStatus')->getStatus($addCreditRequest['data']->status), 'statusId' => $addCreditRequest['data']->status, 'timeAdded' => $addCreditRequest['timeAdded']);
     }
     $this->data = array_merge($this->data, $this->parameters);
     /// Initialize interface
     $this->setBreadcrumps();
     $this->data['textActions'] = $this->language->get('ACTIONS');
     $this->data['textAmount'] = $this->language->get('AMOUNT');
     $this->data['textComment'] = $this->language->get('COMMENT');
     $this->data['textCustomer'] = $this->language->get('CUSTOMER');
     $this->data['textFilter'] = $this->language->get('FILTER');
     $this->data['textPaymentMethod'] = $this->language->get('PAYMENT_METHOD');
     $this->data['textRequestId'] = $this->language->get('REQUEST_ID');
     $this->data['textStatus'] = $this->language->get('STATUS');
     $this->data['textTimeAdded'] = $this->language->get('TIME_ADDED');
     $this->data['urlSelf'] = $this->url->link($this->selfRoute, 'token=' . $this->parameters['token'], 'SSL');
     $this->template = 'sale/creditManagement.tpl';
     $this->children = array('common/footer', 'common/header');
     $this->getResponse()->setOutput($this->render());
 }
Пример #2
0
 /**
  * @param int $transactionId
  */
 public function deleteTransaction($transactionId)
 {
     $transaction = $this->getTransaction($transactionId);
     $customer = CustomerDAO::getInstance()->getCustomer($transaction['customer_id']);
     $amountToReturn = $this->getCurrentCurrency()->convert($transaction['amount'], $transaction['currency_code'], $customer['base_currency_code']);
     $this->getDb()->query("\r\n            DELETE FROM customer_transaction\r\n            WHERE customer_transaction_id = " . (int) $transactionId);
     $this->getDb()->query("\r\n            UPDATE customer\r\n            SET balance = balance + {$amountToReturn}\r\n            WHERE customer_id = " . $transaction['customer_id']);
     $this->getCache()->delete('customer.' . $transaction['customer_id']);
 }
Пример #3
0
 public static function addTransaction($invoiceId, $customer, $amount, $currency_code, $description = '')
 {
     if (is_numeric($customer)) {
         /// customer ID is passed. Need to get customer object
         $customer = CustomerDAO::getInstance()->getCustomer($customer);
     }
     /// Now need to convert transaction amount to customer base currency
     $currency = Transaction::$instance->getRegistry()->get('currency');
     $amountInCustomerCurrency = (double) $currency->convert($amount, $currency_code, $customer['base_currency_code']);
     $newCustomerBalance = $customer['balance'] - $amountInCustomerCurrency;
     Transaction::$instance->getDb()->query("\r\n            INSERT INTO customer_transaction\r\n            SET\r\n                customer_id = " . (int) $customer['customer_id'] . ",\r\n                invoice_id = " . (int) $invoiceId . ",\r\n                description = '" . Transaction::$instance->getDb()->escape($description) . "',\r\n                amount = {$amountInCustomerCurrency},\r\n                currency_code = '" . $customer['base_currency_code'] . "',\r\n                date_added = NOW(),\r\n                balance = {$newCustomerBalance},\r\n                balance_currency = '" . Transaction::$instance->getDb()->escape($customer['base_currency_code']) . "'\r\n        ");
     //$transactionId = Transaction::$instance->getDb()->getLastId();
     /// Update customer's balance
     Transaction::$instance->getDb()->query("\r\n                UPDATE customer\r\n                SET\r\n                    balance = {$newCustomerBalance}\r\n                WHERE customer_id = " . $customer['customer_id']);
     Transaction::$instance->getCache()->delete('customer.' . $customer['customer_id']);
     if (Transaction::$instance->user->isLogged()) {
         Audit::getInstance(Transaction::$instance->getRegistry())->addAdminEntry(Transaction::$instance->user->getId(), AUDIT_ADMIN_TRANSACTION_ADD, $_REQUEST);
     } elseif (Transaction::$instance->customer->isLogged()) {
         Audit::getInstance(Transaction::$instance->getRegistry())->addUserEntry(Transaction::$instance->customer->getId(), AUDIT_ADMIN_TRANSACTION_ADD, $_REQUEST);
     }
 }
Пример #4
0
 private function validateDelete()
 {
     if (!$this->user->hasPermission('modify', 'localisation/zone')) {
         $this->error['warning'] = $this->language->get('error_permission');
     }
     $this->load->model('setting/store');
     $this->load->model('sale/affiliate');
     $this->load->model('localisation/geo_zone');
     foreach ($this->request->post['selected'] as $zone_id) {
         if ($this->config->get('config_zone_id') == $zone_id) {
             $this->error['warning'] = $this->language->get('error_default');
         }
         $store_total = $this->model_setting_store->getTotalStoresByZoneId($zone_id);
         if ($store_total) {
             $this->error['warning'] = sprintf($this->language->get('error_store'), $store_total);
         }
         $address_total = CustomerDAO::getInstance()->getTotalAddressesByZoneId($zone_id);
         if ($address_total) {
             $this->error['warning'] = sprintf($this->language->get('error_address'), $address_total);
         }
         $affiliate_total = $this->model_sale_affiliate->getTotalAffiliatesByZoneId($zone_id);
         if ($affiliate_total) {
             $this->error['warning'] = sprintf($this->language->get('error_affiliate'), $affiliate_total);
         }
         $zone_to_geo_zone_total = $this->model_localisation_geo_zone->getTotalZoneToGeoZoneByZoneId($zone_id);
         if ($zone_to_geo_zone_total) {
             $this->error['warning'] = sprintf($this->language->get('error_zone_to_geo_zone'), $zone_to_geo_zone_total);
         }
     }
     if (!$this->error) {
         return true;
     } else {
         return false;
     }
 }
Пример #5
0
 /**
  * @return array
  */
 public function getCustomer()
 {
     if (!isset($this->customer)) {
         $this->customer = CustomerDAO::getInstance()->getCustomer($this->customerId);
     }
     return $this->customer;
 }
Пример #6
0
 private function validateDelete()
 {
     if (!$this->user->hasPermission('modify', 'sale/customer_group')) {
         $this->error['warning'] = $this->language->get('error_permission');
     }
     $this->load->model('setting/store');
     foreach ($this->request->post['selected'] as $customer_group_id) {
         if ($this->config->get('config_registred_group_id') == $customer_group_id) {
             $this->error['warning'] = $this->language->get('error_registred');
         }
         if ($this->config->get('config_customer_group_id') == $customer_group_id) {
             $this->error['warning'] = $this->language->get('error_default');
         }
         $store_total = $this->model_setting_store->getTotalStoresByCustomerGroupId($customer_group_id);
         if ($store_total) {
             $this->error['warning'] = sprintf($this->language->get('error_store'), $store_total);
         }
         $customer_total = CustomerDAO::getInstance()->getTotalCustomersByCustomerGroupId($customer_group_id);
         if ($customer_total) {
             $this->error['warning'] = sprintf($this->language->get('error_customer'), $customer_total);
         }
     }
     if (!$this->error) {
         return true;
     } else {
         return false;
     }
 }
Пример #7
0
 public function getShippingAddressId($orderId)
 {
     $query = $this->getDb()->query("\n            SELECT shipping_address_id\n            FROM `order`\n            WHERE order_id = " . (int) $orderId);
     if ($query->num_rows) {
         $addressModel = $this->load->model('reference/address');
         if ($query->row['shipping_address_id']) {
             // order already has address ID
             $orderAddressId = $query->row['shipping_address_id'];
         } else {
             $order = $this->getOrder($orderId);
             $orderShippingAddress = $addressModel->getAddress($order['shipping_lastname'], $order['shipping_firstname'], $order['shipping_company'], $order['shipping_address_1'], $order['shipping_address_2'], $order['shipping_city'], $order['shipping_postcode'], $order['shipping_zone_id'], $order['shipping_country_id']);
             $orderAddressId = 0;
             foreach (CustomerDAO::getInstance()->getAddresses($order['customer_id']) as $customerAddress) {
                 if ($addressModel->getAddress($customerAddress['address_id']) == $orderShippingAddress) {
                     $orderAddressId = $customerAddress['address_id'];
                     // found address, use its ID as order address ID
                     break;
                 }
             }
             if (!$orderAddressId) {
                 // no address found, create new one
                 $orderAddressId = $addressModel->addAddress($order['shipping_lastname'], $order['shipping_firstname'], $order['shipping_company'], $order['shipping_address_1'], $order['shipping_address_2'], $order['shipping_city'], $order['shipping_postcode'], $order['shipping_country_id'], $order['shipping_zone_id'], $order['customer_id']);
             }
             $this->getDb()->query("\n                        UPDATE `order`\n                        SET shipping_address_id = {$orderAddressId}\n                        WHERE order_id = " . (int) $orderId);
         }
         return $orderAddressId;
     } else {
         return null;
     }
 }
Пример #8
0
 /**
  * @param array $filter
  * @return array[]
  */
 public function getInvoiceCustomers($filter)
 {
     unset($filter['filterCustomerId']);
     $filter = $this->buildFilter($filter);
     $query = "\n            SELECT customer_id\n            FROM invoices AS i\n        ";
     if ($filter->isFilterSet()) {
         $query .= $filter->getFilterString(true);
     }
     $query .= "GROUP BY customer_id";
     $result = [];
     foreach ($this->getDb()->query($query, $filter->getParams())->rows as $row) {
         $result[] = CustomerDAO::getInstance()->getCustomer($row['customer_id']);
     }
     return $result;
 }
Пример #9
0
 public function index()
 {
     $this->getLoader()->language('common/home');
     $this->document->setTitle($this->getLanguage()->get('heading_title'));
     $this->data['heading_title'] = $this->getLanguage()->get('heading_title');
     $this->data['text_overview'] = $this->getLanguage()->get('text_overview');
     $this->data['text_statistics'] = $this->getLanguage()->get('text_statistics');
     $this->data['text_latest_10_orders'] = $this->getLanguage()->get('text_latest_10_orders');
     $this->data['text_total_sale'] = $this->getLanguage()->get('text_total_sale');
     $this->data['text_total_sale_year'] = $this->getLanguage()->get('text_total_sale_year');
     $this->data['text_total_order'] = $this->getLanguage()->get('text_total_order');
     $this->data['text_total_customer'] = $this->getLanguage()->get('text_total_customer');
     $this->data['text_total_customer_approval'] = $this->getLanguage()->get('text_total_customer_approval');
     $this->data['text_total_review_approval'] = $this->getLanguage()->get('text_total_review_approval');
     $this->data['text_total_affiliate'] = $this->getLanguage()->get('text_total_affiliate');
     $this->data['text_total_affiliate_approval'] = $this->getLanguage()->get('text_total_affiliate_approval');
     $this->data['text_day'] = $this->getLanguage()->get('text_day');
     $this->data['text_week'] = $this->getLanguage()->get('text_week');
     $this->data['text_month'] = $this->getLanguage()->get('text_month');
     $this->data['text_year'] = $this->getLanguage()->get('text_year');
     $this->data['text_no_results'] = $this->getLanguage()->get('text_no_results');
     $this->data['column_order'] = $this->getLanguage()->get('column_order');
     $this->data['column_customer'] = $this->getLanguage()->get('column_customer');
     $this->data['column_status'] = $this->getLanguage()->get('column_status');
     $this->data['column_date_added'] = $this->getLanguage()->get('column_date_added');
     $this->data['column_total'] = $this->getLanguage()->get('column_total');
     $this->data['column_firstname'] = $this->getLanguage()->get('column_firstname');
     $this->data['column_lastname'] = $this->getLanguage()->get('column_lastname');
     $this->data['column_action'] = $this->getLanguage()->get('column_action');
     $this->data['entry_range'] = $this->getLanguage()->get('entry_range');
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->getLanguage()->get('text_home'), 'href' => $this->getUrl()->link('common/home', 'token=' . $this->getSession()->data['token'], 'SSL'), 'separator' => false);
     $this->data['token'] = $this->getSession()->data['token'];
     $this->getLoader()->model('sale/order');
     $this->data['total_sale'] = $this->getCurrentCurrency()->format($this->model_sale_order->getTotalSales(), $this->config->get('config_currency'));
     $this->data['total_sale_year'] = $this->getCurrentCurrency()->format($this->model_sale_order->getTotalSalesByYear(date('Y')), $this->config->get('config_currency'));
     $this->data['total_order'] = $this->model_sale_order->getTotalOrders();
     $this->data['total_customer'] = CustomerDAO::getInstance()->getTotalCustomers();
     $this->data['total_customer_approval'] = CustomerDAO::getInstance()->getTotalCustomersAwaitingApproval();
     $this->getLoader()->model('catalog/review');
     $this->data['total_review'] = $this->model_catalog_review->getTotalReviews();
     $this->data['total_review_approval'] = $this->model_catalog_review->getTotalReviewsAwaitingApproval();
     $this->getLoader()->model('sale/affiliate');
     $this->data['total_affiliate'] = $this->model_sale_affiliate->getTotalAffiliates();
     $this->data['total_affiliate_approval'] = $this->model_sale_affiliate->getTotalAffiliatesAwaitingApproval();
     $this->data['orders'] = array();
     $data = array('sort' => 'o.date_added', 'order' => 'DESC', 'start' => 0, 'limit' => 10);
     $results = $this->model_sale_order->getOrders($data);
     foreach ($results as $result) {
         $action = array();
         $action[] = array('text' => $this->getLanguage()->get('text_view'), 'href' => $this->getUrl()->link('sale/order/info', 'token=' . $this->getSession()->data['token'] . '&order_id=' . $result['order_id'], 'SSL'));
         $this->data['orders'][] = array('order_id' => $result['order_id'], 'customer' => $result['customer'], 'status' => $result['status'], 'date_added' => date($this->getLanguage()->get('date_format_short'), strtotime($result['date_added'])), 'total' => $this->getCurrentCurrency()->format($result['total'], $result['currency_code'], $result['currency_value']), 'action' => $action);
     }
     //		if ($this->config->get('config_currency_auto')) {
     //			$this->getLoader()->model('localisation/currency');
     //
     //			$this->model_localisation_currency->updateCurrencies();
     //		}
     //if ($this->getUser()->getUsergroupId() == 1) {
     //		$this->template = ;
     //} else {
     //		$this->template = 'common/homecont.tpl.php';
     //}
     $this->children = array('common/header', 'common/footer');
     $this->getProducts();
     $this->getResponse()->setOutput($this->render('common/home.tpl.php'));
     //// <---- Clear cache button handler:
     $this->data['clear_cache'] = $this->data['home'] = HTTPS_SERVER . 'index.php?route=common/home&clear_cache=true&token=' . $this->getSession()->data['token'];
     if (isset($this->request->get['clear_cache'])) {
         // specify an array of what we need to clear:
         $cacheDirs = array('image_cache' => DIR_IMAGE . 'cache', 'system_cache' => DIR_CACHE);
         foreach ($cacheDirs as $cacheDir) {
             foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($cacheDir, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as $path) {
                 $path->isDir() ? rmdir($path->getPathname()) : unlink($path->getPathname());
             }
         }
     }
     //// ---->
 }
Пример #10
0
 public function address()
 {
     $json = array();
     if (isset($_REQUEST['address_id']) && $_REQUEST['address_id']) {
         $json = CustomerDAO::getInstance()->getAddress($_REQUEST['address_id']);
     }
     $this->getResponse()->setOutput(json_encode($json));
 }
Пример #11
0
 public function index()
 {
     $this->load->language('sale/contact');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->load->model('sale/customer_group');
     $this->load->model('sale/affiliate');
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         $this->load->model('setting/store');
         $store_info = $this->model_setting_store->getStore($this->request->post['store_id']);
         if ($store_info) {
             $store_name = $store_info['name'];
         } else {
             $store_name = $this->config->get('config_name');
         }
         $emails = array();
         switch ($this->request->post['to']) {
             case 'newsletter':
                 $results = CustomerDAO::getInstance()->getCustomersByNewsletter();
                 foreach ($results as $result) {
                     $emails[] = $result['email'];
                 }
                 break;
             case 'customer_all':
                 $results = CustomerDAO::getInstance()->getCustomers();
                 foreach ($results as $result) {
                     $emails[] = $result['email'];
                 }
                 break;
             case 'customer_group':
                 $results = CustomerDAO::getInstance()->getCustomersByCustomerGroupId($this->request->post['customer_group_id']);
                 foreach ($results as $result) {
                     $emails[$result['customer_id']] = $result['email'];
                 }
                 break;
             case 'customer':
                 if (isset($this->request->post['customer'])) {
                     foreach ($this->request->post['customer'] as $customer_id) {
                         $customer_info = CustomerDAO::getInstance()->getCustomer($customer_id);
                         if ($customer_info) {
                             $emails[] = $customer_info['email'];
                         }
                     }
                 }
                 break;
             case 'affiliate_all':
                 $results = $this->model_sale_affiliate->getAffiliates();
                 foreach ($results as $result) {
                     $emails[] = $result['email'];
                 }
                 break;
             case 'affiliate':
                 if (isset($this->request->post['affiliate'])) {
                     foreach ($this->request->post['affiliate'] as $affiliate_id) {
                         $affiliate_info = $this->model_sale_affiliate->getAffiliate($affiliate_id);
                         if ($affiliate_info) {
                             $emails[] = $affiliate_info['email'];
                         }
                     }
                 }
                 break;
             case 'product':
                 if (isset($this->request->post['product'])) {
                     foreach ($this->request->post['product'] as $product_id) {
                         $results = CustomerDAO::getInstance()->getCustomersByProduct($product_id);
                         foreach ($results as $result) {
                             $emails[] = $result['email'];
                         }
                     }
                 }
                 break;
         }
         $emails = array_unique($emails);
         if ($emails) {
             $message = '<html dir="ltr" lang="en">' . "\n";
             $message .= '<head>' . "\n";
             $message .= '<title>' . $this->request->post['subject'] . '</title>' . "\n";
             $message .= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . "\n";
             $message .= '</head>' . "\n";
             $message .= '<body>' . html_entity_decode($this->request->post['message'], ENT_QUOTES, 'UTF-8') . '</body>' . "\n";
             $message .= '</html>' . "\n";
             $attachments = array();
             if (preg_match_all('#(src="([^"]*)")#mis', $message, $matches)) {
                 foreach ($matches[2] as $key => $value) {
                     $filename = md5(basename($value)) . strrchr($value, '.');
                     $path = rtrim($this->request->server['DOCUMENT_ROOT'], '/') . parse_url($value, PHP_URL_PATH);
                     $attachments[] = array('filename' => $filename, 'path' => $path);
                     $message = str_replace($value, 'cid:' . $filename, $message);
                 }
             }
             foreach ($emails as $email) {
                 $mail = new Mail();
                 $mail->protocol = $this->config->get('config_mail_protocol');
                 $mail->parameter = $this->config->get('config_mail_parameter');
                 $mail->hostname = $this->config->get('config_smtp_host');
                 $mail->username = $this->config->get('config_smtp_username');
                 $mail->password = $this->config->get('config_smtp_password');
                 $mail->port = $this->config->get('config_smtp_port');
                 $mail->timeout = $this->config->get('config_smtp_timeout');
                 $mail->setTo($email);
                 $mail->setFrom($this->config->get('config_email'));
                 $mail->setSender($store_name);
                 $mail->setSubject($this->request->post['subject']);
                 foreach ($attachments as $attachment) {
                     $mail->addAttachment($attachment['path'], $attachment['filename']);
                 }
                 $mail->setHtml($message);
                 $mail->send();
             }
         }
         $this->session->data['success'] = $this->language->get('text_success');
     }
     $this->data['heading_title'] = $this->language->get('heading_title');
     $this->data['text_default'] = $this->language->get('text_default');
     $this->data['text_newsletter'] = $this->language->get('text_newsletter');
     $this->data['text_customer_all'] = $this->language->get('text_customer_all');
     $this->data['text_customer'] = $this->language->get('text_customer');
     $this->data['text_customer_group'] = $this->language->get('text_customer_group');
     $this->data['text_affiliate_all'] = $this->language->get('text_affiliate_all');
     $this->data['text_affiliate'] = $this->language->get('text_affiliate');
     $this->data['text_product'] = $this->language->get('text_product');
     $this->data['entry_store'] = $this->language->get('entry_store');
     $this->data['entry_to'] = $this->language->get('entry_to');
     $this->data['entry_customer_group'] = $this->language->get('entry_customer_group');
     $this->data['entry_customer'] = $this->language->get('entry_customer');
     $this->data['entry_affiliate'] = $this->language->get('entry_affiliate');
     $this->data['entry_product'] = $this->language->get('entry_product');
     $this->data['entry_subject'] = $this->language->get('entry_subject');
     $this->data['entry_message'] = $this->language->get('entry_message');
     $this->data['button_send'] = $this->language->get('button_send');
     $this->data['button_cancel'] = $this->language->get('button_cancel');
     $this->data['tab_general'] = $this->language->get('tab_general');
     $this->data['token'] = $this->session->data['token'];
     if (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
     } else {
         $this->data['error_warning'] = '';
     }
     if (isset($this->error['subject'])) {
         $this->data['error_subject'] = $this->error['subject'];
     } else {
         $this->data['error_subject'] = '';
     }
     if (isset($this->error['message'])) {
         $this->data['error_message'] = $this->error['message'];
     } else {
         $this->data['error_message'] = '';
     }
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => false);
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('heading_title'), 'href' => $this->url->link('sale/contact', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => ' :: ');
     if (isset($this->session->data['success'])) {
         $this->data['success'] = $this->session->data['success'];
         unset($this->session->data['success']);
     } else {
         $this->data['success'] = '';
     }
     $this->data['action'] = $this->url->link('sale/contact', 'token=' . $this->session->data['token'], 'SSL');
     $this->data['cancel'] = $this->url->link('sale/contact', 'token=' . $this->session->data['token'], 'SSL');
     if (isset($this->request->post['store_id'])) {
         $this->data['store_id'] = $this->request->post['store_id'];
     } else {
         $this->data['store_id'] = '';
     }
     $this->load->model('setting/store');
     $this->data['stores'] = $this->model_setting_store->getStores();
     if (isset($this->request->post['to'])) {
         $this->data['to'] = $this->request->post['to'];
     } else {
         $this->data['to'] = '';
     }
     if (isset($this->request->post['customer_group_id'])) {
         $this->data['customer_group_id'] = $this->request->post['customer_group_id'];
     } else {
         $this->data['customer_group_id'] = '';
     }
     $this->data['customer_groups'] = $this->model_sale_customer_group->getCustomerGroups(0);
     $this->data['customers'] = array();
     if (isset($this->request->post['customer'])) {
         foreach ($this->request->post['customer'] as $customer_id) {
             $customer_info = CustomerDAO::getInstance()->getCustomer($customer_id);
             if ($customer_info) {
                 $this->data['customers'][] = array('customer_id' => $customer_info['customer_id'], 'name' => $customer_info['firstname'] . ' ' . $customer_info['lastname']);
             }
         }
     }
     $this->data['affiliates'] = array();
     if (isset($this->request->post['affiliate'])) {
         foreach ($this->request->post['affiliate'] as $affiliate_id) {
             $affiliate_info = $this->model_sale_affiliate->getAffiliate($affiliate_id);
             if ($affiliate_info) {
                 $this->data['affiliates'][] = array('affiliate_id' => $affiliate_info['affiliate_id'], 'name' => $affiliate_info['firstname'] . ' ' . $affiliate_info['lastname']);
             }
         }
     }
     $this->load->model('catalog/product');
     $this->data['products'] = array();
     if (isset($this->request->post['product'])) {
         foreach ($this->request->post['product'] as $product_id) {
             $product_info = $this->model_catalog_product->getProduct($product_id);
             if ($product_info) {
                 $this->data['products'][] = array('product_id' => $product_info['product_id'], 'name' => $product_info['name']);
             }
         }
     }
     if (isset($this->request->post['subject'])) {
         $this->data['subject'] = $this->request->post['subject'];
     } else {
         $this->data['subject'] = '';
     }
     if (isset($this->request->post['message'])) {
         $this->data['message'] = $this->request->post['message'];
     } else {
         $this->data['message'] = '';
     }
     $this->template = 'sale/contact.tpl';
     $this->children = array('common/header', 'common/footer');
     $this->getResponse()->setOutput($this->render());
 }
Пример #12
0
 public function removeReward()
 {
     $json = array();
     if (!$this->user->hasPermission('modify', 'sale/order')) {
         $json['error'] = $this->language->get('error_permission');
     } elseif (isset($this->request->get['order_id'])) {
         $order_info = $this->model_sale_order->getOrder($this->request->get['order_id']);
         if ($order_info && $order_info['customer_id']) {
             CustomerDAO::getInstance()->deleteReward($this->request->get['order_id']);
             $json['success'] = $this->language->get('text_reward_removed');
         } else {
             $json['error'] = $this->language->get('error_action');
         }
     }
     $this->getResponse()->setOutput(json_encode($json));
 }
Пример #13
0
 private function showCreateForm()
 {
     //$this->log->write(print_r($this->request->request, true));
     if (!sizeof($this->parameters['selectedItems'])) {
         return;
     }
     $orderItems = OrderItemDAO::getInstance()->getOrderItems(array('selected_items' => $this->parameters['selectedItems']), null, true);
     //print_r($orderItems);
     /// Initialize interface values
     $this->data['button_action'] = $this->language->get('buttonCreate');
     $this->data['readOnly'] = "";
     /// Check whether input for invoice creation is valid
     $this->validateInput($orderItems);
     /// Prepare list
     $totalWeight = 0;
     $total = 0;
     $totalCustomerCurrency = 0;
     $orderItemIdParam = '';
     $localShipping = [];
     foreach ($orderItems as $orderItem) {
         //            $orderItemObject = new OrderItem($this->registry, $orderItem['affiliate_id'],
         //                $orderItem['affiliate_transaction_id'], $orderItem['comment'], $orderItem['customer_id'],
         //                $orderItem['customer_name'], $orderItem['customer_nick'], $orderItem['order_item_id'],
         //                $orderItem['image_path'], $orderItem['internal_model'], $orderItem['model'], $orderItem['name'],
         //                $orderItem['order_id'], $orderItem['price'], $orderItem['product_id'], $orderItem['public_comment'],
         //                $orderItem['quantity'], $orderItem['shipping'], $orderItem['status_date'], $orderItem['status_id'],
         //                $orderItem['supplier_group_id'], $orderItem['supplier_id'], $orderItem['supplier_name'], $orderItem['total'],
         //                $orderItem['weight'], $orderItem['weight_class_id']);
         $this->data['orderItems'][$orderItem->getId()] = array('id' => $orderItem->getId(), 'comment' => $orderItem->getPublicComment(), 'image_path' => $this->registry->get('model_tool_image')->getImage($orderItem->getImagePath()), 'model' => $orderItem->getModel(), 'name' => $orderItem->getName(), 'order_id' => $orderItem->getOrderId(), 'options' => OrderItemDAO::getInstance()->getOrderItemOptionsString($orderItem->getId()), 'price' => $this->getCurrency()->format($orderItem->getPrice(), $this->getConfig()->get('config_currency')), 'quantity' => $orderItem->getQuantity(), 'shipping' => $orderItem->getShippingCost(), 'subtotal' => $this->getCurrency()->format($orderItem->getPrice() * $orderItem->getQuantity() + $orderItem->getShippingCost(), $this->getConfig()->get('config_currency')), 'subtotalCustomerCurrency' => $this->getCurrency()->format($orderItem->getPrice(true) * $orderItem->getQuantity() + $orderItem->getShippingCost(true), $orderItem->getCustomer()['base_currency_code'], 1));
         $totalWeight += $this->weight->convert($orderItem->getWeight(), $orderItem->getWeightClassId(), $this->getConfig()->get('config_weight_class_id')) * $orderItem->getQuantity();
         $total += $orderItem->getPrice() * $orderItem->getQuantity();
         // + $orderItem->getShippingCost();
         $totalCustomerCurrency += $orderItem->getPrice(true) * $orderItem->getQuantity();
         // + $orderItem->getShippingCost(true);
         $orderItemIdParam .= '&orderItemId[]=' . $orderItem->getId();
         /// Calculate local shipping
         $localShipping = $this->calculateLocalShipping($orderItem, $localShipping);
     }
     /// Check whether suppliers have free shipping
     $this->checkFreeLocalShipping($localShipping, $total, $totalCustomerCurrency);
     /// Set invoice data
     $firstItemOrder = $this->modelSaleOrder->getOrder($orderItems[0]->getOrderId());
     //        $this->log->write(print_r($firstItemOrder, true));
     $customer = CustomerDAO::getInstance()->getCustomer($firstItemOrder['customer_id']);
     //        $shippingCost = \Shipping::getCost($orderItems, $firstItemOrder['shipping_method'], array('weight' => $totalWeight), $this->registry);
     $shippingCost = ShippingMethodDAO::getInstance()->getMethod(explode('.', $firstItemOrder['shipping_method'])[0])->getCost($firstItemOrder['shipping_method'], $orderItems, ['weight' => $totalWeight]);
     $this->data['comment'] = '';
     $this->data['discount'] = 0;
     $this->data['invoiceId'] = 0;
     $this->data['packageNumber'] = '';
     $this->data['shippingAddress'] = nl2br($this->getOrderAddressString($firstItemOrder)) . " (" . $firstItemOrder['shipping_phone'] . ")";
     $this->data['shippingCost'] = $this->getCurrency()->format($shippingCost, $this->getConfig()->get('config_currency'));
     $this->data['shippingCostRoute'] = $this->url->link('sale/invoice/getShippingCost', 'token=' . $this->parameters['token'] . $orderItemIdParam, 'SSL');
     $this->data['shippingMethod'] = $firstItemOrder['shipping_method'];
     $this->data['shippingMethodCode'] = $firstItemOrder['shipping_method'];
     $this->data['total'] = $this->getCurrency()->format($total, $this->getConfig()->get('config_currency'));
     $this->data['totalRaw'] = $total;
     $this->data['totalWeight'] = $totalWeight;
     $this->data['grandTotal'] = $this->getCurrency()->format($total + $shippingCost, $this->getConfig()->get('config_currency'));
     $this->data['totalCustomerCurrency'] = $this->getCurrency()->format($totalCustomerCurrency + $this->getCurrency()->convert($shippingCost, $this->getConfig()->get('config_currency'), $customer['base_currency_code']), $customer['base_currency_code'], 1);
     $this->data['shippingMethods'] = ShippingMethodDAO::getInstance()->getShippingOptions($this->getOrderAddress($firstItemOrder));
     //        $this->log->write(print_r($this->data, true));
     $this->data['customerCurrencyCode'] = $customer['base_currency_code'];
 }