예제 #1
0
파일: profile.php 프로젝트: JexyRu/Ksenmart
 /**
  * KsenMartModelProfile::getOrder()
  * 
  * @param integer $order_id
  * @return
  */
 public function getOrder($order_id = 0)
 {
     $this->onExecuteBefore('getOrder', array(&$order_id));
     if ($order_id == 0) {
         $order_id = JRequest::getVar('id', 0);
     }
     $user = KSUsers::getUser();
     $order = KSMOrders::getOrder($order_id);
     $order->shipping_title = $this->getShippingTitle($order->shipping_id);
     if (empty($order->email)) {
         $order->email = $user->email;
     }
     if (empty($order->name)) {
         $order->name = $user->name;
     }
     if (empty($order->phone)) {
         $order->phone = $user->phone;
     }
     if (!empty($order)) {
         $order->items = KSMOrders::getOrderItems($order_id);
     }
     $this->onExecuteAfter('getOrder', array(&$order));
     return $order;
 }
예제 #2
0
파일: cart.php 프로젝트: JexyRu/Ksenmart
 public function closeOrder()
 {
     $this->onExecuteBefore('closeOrder');
     $cart = $this->getCart();
     $order = new stdClass();
     $jinput = JFactory::getApplication()->input;
     $customer_fields = $jinput->get('customer_fields', array(), 'array');
     $address_fields = $jinput->get('address_fields', array(), 'array');
     $order->id = $this->order_id;
     $order->status_id = 1;
     $order->region_id = $jinput->get('region_id', 0, 'int');
     $order->shipping_id = $jinput->get('shipping_id', 0, 'int');
     $order->payment_id = $jinput->get('payment_id', 0, 'int');
     $order->shipping_coords = $jinput->get('shipping_coords', 0, 'string');
     $order->customer_fields = json_encode($customer_fields);
     $order->address_fields = json_encode($address_fields);
     $order->note = $jinput->get('note', null, 'string');
     try {
         $result = $this->_db->updateObject('#__ksenmart_orders', $order, 'id');
     } catch (exception $e) {
     }
     try {
         $result = $this->_db->updateObject('#__ksenmart_orders', $order, 'id');
     } catch (exception $e) {
     }
     if (!empty($customer_fields['email'])) {
         KSMOrders::sendOrderMail($this->order_id);
     }
     KSMOrders::sendOrderMail($this->order_id, true);
     $this->onExecuteAfter('closeOrder');
     return true;
 }
예제 #3
0
파일: order.php 프로젝트: JexyRu/Ksenmart
 public function getOrders($editDate)
 {
     $this->onExecuteBefore('getOrders');
     $query = $this->_db->getQuery(true);
     $query->select('
             o.id,
             o.cost AS order_price,
             o.roistat,
             o.discounts,
             o.user_id,
             o.shipping_coords,
             o.customer_fields,
             o.address_fields, 
             o.status_id AS status,
             o.date_add,
             r.title AS region,
             p.title AS payment,
             s.title AS shipping,
             SUM(oi.purchase_price) AS cost
         ')->from($this->_db->qn('#__ksenmart_orders', 'o'))->leftjoin($this->_db->qn('#__ksenmart_order_items', 'oi') . ' ON ' . $this->_db->qn('o.id') . '=' . $this->_db->qn('oi.order_id'))->leftjoin($this->_db->qn('#__ksenmart_regions', 'r') . ' ON ' . $this->_db->qn('r.id') . '=' . $this->_db->qn('o.region_id'))->leftjoin($this->_db->qn('#__ksenmart_payments', 'p') . ' ON ' . $this->_db->qn('p.id') . '=' . $this->_db->qn('o.payment_id'))->leftjoin($this->_db->qn('#__ksenmart_shippings', 's') . ' ON ' . $this->_db->qn('s.id') . '=' . $this->_db->qn('o.shipping_id'))->where('DATE_FORMAT(' . $this->_db->qn('o.date_add') . ', \'%Y-%m-%d\') > FROM_UNIXTIME(' . $this->_db->q($editDate) . ', \'%Y-%m-%d\')')->group($this->_db->qn('oi.order_id'));
     $this->_db->setQuery($query);
     $orders = $this->_db->loadObjectList();
     foreach ($orders as &$order) {
         KSMOrders::setUserInfoField2Order($order);
         $date = new JDate($order->date_add);
         $order->date_create = $date->toUnix();
         $order->date_update = $order->date_create;
         $order->price = $order->order_price;
         unset($order->order_price);
         unset($order->date_add);
         $order->fields = array();
         foreach ($order as $key => &$field) {
             if (!in_array($key, $this->_roistatFields)) {
                 $key_name = JText::_('KSM_ROISTAT_FIELDS_' . strtoupper($key) . '_TITLE');
                 if (is_array($field)) {
                     $field = implode(', ', $field);
                 } elseif (is_object($field)) {
                     $field = JArrayHelper::fromObject($field);
                     $field = implode(', ', $field);
                 }
                 $order->fields[$key_name] = $field;
                 unset($order->{$key});
             }
         }
     }
     $this->onExecuteAfter('getOrders', array(&$orders));
     return $orders;
 }
예제 #4
0
	<tr>
		<td colspan="3">&nbsp;</td>
	</tr>
	<tr>
		<td class=leftAlign>Покупатель:</td>
		<td class="leftAlign underlined"><b class="inline_edit"><?php 
echo KSMOrders::getPrintformCustomerName($this->order->customer_fields);
?>
</b></td>
		<td>(6)</td>
	</tr>
	<tr>
		<td class=leftAlign>Адрес:</td>
		<td class="leftAlign underlined"><b class="inline_edit">
			<?php 
echo KSMOrders::getPrintformCustomerAddress($this->order->address_fields);
?>
&nbsp;
			<?php 
echo isset($this->order->customer_fields['phone']) && $this->order->customer_fields['phone'] != '' ? 'тел.: ' . $this->order->customer_fields['phone'] : '';
?>
		</b></td>
		<td>(6а)</td>
	</tr>
	<tr>
		<td class=leftAlign>ИНН/КПП покупателя:</td>
		<td class="leftAlign underlined">
		<table style="display:inline;"><tr>
		<td style="width:50mm;font-weight: bold;" class="inline_edit"></td>
		<td style="font-weight: bold;">/</td>
		<td style="width:50mm;font-weight: bold;" class="inline_edit"></td>
예제 #5
0
파일: orders.php 프로젝트: JexyRu/Ksenmart
 public static function sendOrderMail($order_id, $admin = false)
 {
     self::onExecuteBefore(array(&$order_id, &$admin));
     $db = JFactory::getDBO();
     JRequest::setVar('id', $order_id);
     $model = KSSystem::getModel('orders');
     $order = $model->getOrder();
     $order->items = KSMOrders::getOrderItems($order_id);
     $query = $db->getQuery(true);
     $query->select('*')->from('#__ksenmart_shipping_fields')->where('shipping_id=' . $order->shipping_id)->where('position=' . $db->quote('address'))->where('published=1')->order('ordering');
     $db->setQuery($query);
     $address_fields = $db->loadObjectList();
     $address = array();
     foreach ($address_fields as $address_field) {
         if ($address_field->system && isset($order->address_fields[$address_field->title])) {
             $value = $order->address_fields[$address_field->title];
         } elseif (!$address_field->system && isset($order->address_fields[$address_field->id])) {
             $value = $order->address_fields[$address_field->id];
         } else {
             $value = '';
         }
         $title = $address_field->system ? JText::_('ksm_cart_shipping_field_' . $address_field->title) : $address_field->title;
         $address[] = $title . ' - ' . $value;
     }
     $order->address_fields = implode(', ', $address);
     $order->customer_name = '';
     if (isset($order->customer_fields['name']) && !empty($order->customer_fields['name'])) {
         $order->customer_name .= $order->customer_fields['name'];
     }
     if (isset($order->customer_fields['last_name']) && !empty($order->customer_fields['last_name'])) {
         $order->customer_name .= $order->customer_fields['last_name'] . ' ';
     }
     if (isset($order->customer_fields['first_name']) && !empty($order->customer_fields['first_name'])) {
         $order->customer_name .= $order->customer_fields['first_name'] . ' ';
     }
     if (isset($order->customer_fields['middle_name']) && !empty($order->customer_fields['middle_name'])) {
         $order->customer_name .= $order->customer_fields['middle_name'];
     }
     $order->phone = isset($order->customer_fields['phone']) && !empty($order->customer_fields['phone']) ? $order->customer_fields['phone'] : '';
     $mail = JFactory::getMailer();
     $params = JComponentHelper::getParams('com_ksenmart');
     $sender = array($params->get('shop_email'), $params->get('shop_name'));
     $content = KSSystem::loadTemplate(array('order' => $order), 'order', 'default', 'mail');
     $mail->isHTML(true);
     $mail->setSender($sender);
     $mail->Subject = 'Новый заказ №' . $order_id;
     $mail->Body = $content;
     if (!$admin) {
         $mail->AddAddress($order->customer_fields['email'], $order->customer_fields['name']);
     } else {
         $mail->AddAddress($params->get('shop_email'), $params->get('shop_name'));
     }
     $mail->Send();
     self::onExecuteAfter();
     return true;
 }
예제 #6
0
파일: cart.php 프로젝트: JexyRu/Ksenmart
 public function updateOrderField()
 {
     $jinput = JFactory::getApplication()->input;
     $session = JFactory::getSession();
     $oid = $session->get('shop_order_id', 0);
     $column = $jinput->get('column', null, 'string');
     if (!empty($column)) {
         $data = new stdClass();
         $data->{$column} = $jinput->get('field', 0, 'int');
         KSMOrders::updateOrderFields($oid, $data);
     }
 }
예제 #7
0
					<?php 
echo KSMOrders::getPrintformCustomerAddress($this->order->address_fields);
?>
&nbsp;
					<?php 
echo isset($this->order->customer_fields['phone']) && $this->order->customer_fields['phone'] != '' ? 'тел.: ' . $this->order->customer_fields['phone'] : '';
?>
				</b></td>
			</tr>
			<tr>
				<td class="reportSmallFont name_cell">Основание</td>
				<td width="100%" class="reportSmallFont underlined"><b class="inline_edit">По заказу № <?php 
echo $this->order->id;
?>
 от <?php 
echo KSMOrders::getPrintformDate($this->order->date_add);
?>
 г.</b></td>
			</tr>
			<tr>
				<td colspan=2>&nbsp;</td>
		</table>

		<table cellpadding="0" cellspacing="0" border="0" width="100%">
			<tr>
				<td align=center>

				<table cellpadding="0" cellspacing="0" border="0">
					<tr>
						<td rowspan=2 class="reportSmallFont docNameLabels" valign=bottom>
						<b>ТОВАРНАЯ	НАКЛАДНАЯ&nbsp;</b>