Jump to content
Sign in to follow this  
knyazev

история заказов в списке заказов

Recommended Posts

Добрый день!

Пытаюсь вывести в списке заказов колонку с историей (комментариями админа к заказам).

В контроллере и шаблоне все прописал, но никак не выводит... С комментариями пользователя все показывает, а как прикрутить админские?

Может модуль есть какой или кто подскажет как это сделать? 

Share this post


Link to post
Share on other sites

Вам вероятно нужны данные из обеих таблиц: customer_history и order_history

Share this post


Link to post
Share on other sites

Мне нужно только ту историю, которую правит админ в заказе. Чтобы заходя в список заказов была колонка с комментом администратора и не надо было нажимать просмотр или правка заказа.

Я понимаю, что нужно в контроллере и шаблоне переменные прописать...Но ничего не получается. Пробовал делать по аналогии с именем, но пишет undefined 'history'. 

Как эту хистори объявить в контроллере и шаблоне, чтобы сработало?

Share this post


Link to post
Share on other sites

Есть вот такой допиленный vqmod. Пробовал сюда добавить переменные связанные с order_history, но не знаю как сделать запрос select по таблице order_history.

<file name="admin/model/sale/order.php">
		<operation error="log">
			<search position="replace"><![CDATA[
$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.total, o.currency_code, o.currency_value, o.date_added, o.date_modified FROM `" . DB_PREFIX . "order` o";
			]]></search>
			<add><![CDATA[
$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.total, o.currency_code, o.currency_value, o.date_added, o.date_modified, o.telephone, o.shipping_country, o.shipping_zone, o.shipping_address_1, o.shipping_city, o.email, o.comment, o.payment_postcode, o.payment_method, o.shipping_method FROM `" . DB_PREFIX . "order` o";
			]]></add>
		</operation>
		<operation error="log">
			<search position="before"><![CDATA[
public function getOrderProducts($order_id) {
			]]></search>
			<add><![CDATA[
	public function getOrderProductsList($order_id) {
		$query = $this->db->query("SELECT op.*, p.image FROM " . DB_PREFIX . "order_product op LEFT JOIN " . DB_PREFIX . "product p ON op.product_id = p.product_id WHERE op.order_id = '" . (int)$order_id . "'");
		
		return $query->rows;
	}
			]]></add>
		</operation>
	</file>
	<file name="admin/controller/sale/order.php">
		<operation error="log">
			<search position="before"><![CDATA[
$action = array();
			]]></search>
			<add><![CDATA[
		    $this->load->model('tool/image');
		
		    $this->data['products'] = array();

			$order_id = $result['order_id'];
			
			$products = $this->model_sale_order->getOrderProductsList($result['order_id']);

			foreach ($products as $product) {
				$option_data = array();

				$options = $this->model_sale_order->getOrderOptions($result['order_id'], $product['order_product_id']);

				foreach ($options as $option) {
					if ($option['type'] != 'file') {
						$option_data[] = array(
							'name'  => $option['name'],
							'value' => $option['value'],
							'type'  => $option['type']
						);
					} else {
						$option_data[] = array(
							'name'  => $option['name'],
							'value' => utf8_substr($option['value'], 0, utf8_strrpos($option['value'], '.')),
							'type'  => $option['type'],
							'href'  => $this->url->link('sale/order/download', 'token=' . $this->session->data['token'] . '&order_id=' . $result['order_id'] . '&order_option_id=' . $option['order_option_id'], 'SSL')
						);						
					}
				}

				$this->data['products'][] = array(
					'order_product_id' => $product['order_product_id'],
					'order_id'         => $order_id,
					'product_id'       => $product['product_id'],
					'name'    	 	   => $product['name'],
					'popup'    	 	   => $this->model_tool_image->resize($product['image'], 500, 500),
					'thumb'    	 	   => $this->model_tool_image->resize($product['image'], 50, 50),
					'model'    		   => $product['model'],
					'option'   		   => $option_data,
					'quantity'		   => $product['quantity'],
					'price'    		   => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0)),
					'href'     		   => $this->url->link('catalog/product/update', 'token=' . $this->session->data['token'] . '&product_id=' . $product['product_id'], 'SSL')
				);
			}
			]]></add>
		</operation>
		<operation error="log">
			<search position="after"><![CDATA[
$result['customer'],
			]]></search>
			<add><![CDATA[
				'telephone'   		 => $result['telephone'],	
				'email'              => $result['email'],
				'products'           => $this->data['products'],
				
			]]></add>
		</operation>
	</file>
	<file name="admin/view/template/sale/order_list.tpl">
		<operation error="log">
			<search position="before"><![CDATA[
<td class="left"><?php if ($sort == 'status') { ?>
			]]></search>
			<add><![CDATA[
<td class="left">Контакты</td>
<td class="left">Товары</td>
			]]></add>
		</operation>
		<operation error="log">
			<search position="before"><![CDATA[
<td><select name="filter_order_status_id">
			]]></search>
			<add><![CDATA[
<td></td><td></td>
			]]></add>
		</operation>
		<operation error="log">
			<search position="after"><![CDATA[
<td class="left"><?php echo $order['customer']; ?></td>
			]]></search>
			<add><![CDATA[
              <td class="left">
			  <?php if ($order['telephone']) { ?>
			  <b>Телефон:</b></br>
			  <?php echo $order['telephone']; ?></br></br>
			  <?php } ?>
			  <?php if ($order['email']) { ?>
			  <b>Email:</b></br>
			  <?php echo $order['email']; ?></br></br>
			  <?php } ?>  
			  </td>
			  <td class="left">
               <?php foreach ($order['products'] as $product) { ?>
                <div style="clear: both;">
				<?php if ($product['thumb']) { ?><div style="float: left;"><a href="<?php echo $product['popup']; ?>" class="colorbox"><img style="border: 1px solid #DDDDDD; margin-right: 3px;" src="<?php echo $product['thumb']; ?>" id="image" /></a></div><?php } ?>
				[ <?php echo $product['model']; ?> ] <a href="<?php echo $product['href']; ?>" target="_blank"><?php echo $product['name']; ?></a></br>
                <?php foreach ($product['option'] as $option) { ?>
                <?php if ($option['type'] != 'file') { ?>
                 <small> - <?php echo $option['name']; ?>: <?php echo $option['value']; ?></small>
                <?php } else { ?>
                 <small> - <?php echo $option['name']; ?>: <a href="<?php echo $option['href']; ?>"><?php echo $option['value']; ?></a></small>
                <?php } ?></br>
                <?php } ?> ( <?php echo $product['price']; ?> x <?php echo $product['quantity']; ?> )
				</div></br></br>
               <?php } ?>
			  
			  </td>
			]]></add>
		</operation>
		<operation error="log">
			<search position="before"><![CDATA[
<?php echo $footer; ?>
			]]></search>
			<add><![CDATA[
<link rel="stylesheet" type="text/css" href="view/javascript/jquery/colorbox/colorbox.css" media="screen" />
<script type="text/javascript" src="view/javascript/jquery/colorbox/jquery.colorbox-min.js"></script>
<script type="text/javascript"><!--
$(document).ready(function() {
	$('.colorbox').colorbox({
		overlayClose: true,
		opacity: 0.5,
		rel: "colorbox"
	});
});
//--></script> 
			]]></add>
		</operation>
	</file>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.