Beispiel #1
0
 public function onMarketProductBlocksDisplay(&$product, &$html)
 {
     if (!$this->init()) {
         return;
     }
     if (!defined('HIKAMARKET_COMPONENT')) {
         return;
     }
     $marketConfig = hikamarket::config();
     if (!$marketConfig->get('frontend_edition', 0)) {
         return;
     }
     if (!hikamarket::acl('product_edit_plugin_hikaserial')) {
         return;
     }
     $params = new HikaParameter('');
     if (!empty($product->product_id)) {
         $params->set('product_id', $product->product_id);
     } else {
         $params->set('product_id', 0);
     }
     $js = '';
     $ret = hikaserial::getLayout('productserial', 'market_block', $params, $js);
     if (!empty($ret)) {
         $html[] = $ret;
     }
 }
Beispiel #2
0
 public function saveForm(&$product)
 {
     if (!isset($product->product_id)) {
         return;
     }
     $product_id = (int) $product->product_id;
     $app = JFactory::getApplication();
     if (!$app->isAdmin()) {
         if (!hikaserial::initMarket()) {
             return;
         }
         if (!hikamarket::acl('product_edit_plugin_hikaserial')) {
             return;
         }
     }
     $formData = JRequest::getVar('data', array(), '', 'array');
     if (empty($formData) || empty($formData['hikaserial']['form'])) {
         return;
     }
     $serialData = $formData['hikaserial'];
     if (!$app->isAdmin()) {
         if (isset($serialData[$product_id])) {
             $serialData = $serialData[$product_id];
         } else {
             $serialData = array();
         }
     }
     $packs = array();
     if (isset($serialData['pack_qty']) && isset($serialData['pack_id'])) {
         $packs = array_combine($serialData['pack_id'], $serialData['pack_qty']);
     }
     $query = 'DELETE FROM ' . hikaserial::table('product_pack') . ' WHERE product_id = ' . $product_id;
     $this->db->setQuery($query);
     $this->db->query();
     if (!empty($packs)) {
         $query = 'INSERT IGNORE INTO ' . hikaserial::table('product_pack') . ' (`product_id`, `pack_id`, `quantity`) VALUES ';
         $data = array();
         foreach ($packs as $id => $qty) {
             if ((int) $qty > 0) {
                 $data[] = '(' . $product_id . ', ' . (int) $id . ', ' . (int) $qty . ')';
             }
             if (count($data) >= 50) {
                 $this->db->setQuery($query . implode(',', $data));
                 $this->db->query();
                 $data = array();
             }
         }
         if (count($data) > 0) {
             $this->db->setQuery($query . implode(',', $data));
             $this->db->query();
             $data = array();
         }
     }
     $this->refreshQuantity($product);
 }
Beispiel #3
0
 public function beforeMailPrepare(&$mail, &$mailer, &$do)
 {
     $mail_name = $mail->mail_name;
     if (isset($mail->hikaserial) && !empty($mail->hikaserial)) {
         $mail_name = 'serial.' . $mail_name;
         if (empty($mail->attachments)) {
             $shopMailClass = hikamarket::get('shop.class.mail');
             $mail->attachments = $shopMailClass->loadAttachments($mail_name);
         }
     }
 }
Beispiel #4
0
 public function useselection()
 {
     if (!hikaserial::initMarket()) {
         return false;
     }
     if (!hikamarket::loginVendor()) {
         return false;
     }
     $marketConfig = hikamarket::config();
     if (!$marketConfig->get('frontend_edition', 0)) {
         return false;
     }
     if (!hikamarket::acl('product_edit_plugin_hikaserial')) {
         return hikamarket::deny('vendor', JText::sprintf('HIKAM_ACTION_DENY', JText::sprintf('HIKAM_ACT_PLUGIN', HIKASERIAL_NAME)));
     }
     JRequest::setVar('layout', 'useselection');
     return parent::display();
 }
Beispiel #5
0
 function onAfterProductUpdate(&$product, $create = false)
 {
     $app = JFactory::getApplication();
     $vendor = null;
     if (!$app->isAdmin()) {
         if (!defined('HIKAMARKET_COMPONENT')) {
             return;
         }
         $marketConfig = hikamarket::config();
         if (!$marketConfig->get('frontend_edition', 0)) {
             return;
         }
         if (!hikamarket::acl('product_edit_plugin_shippingprices')) {
             return;
         }
         $vendor = hikamarket::loadVendor(false);
     }
     $formData = JRequest::getVar('shipping_prices', array(), '', 'array');
     if (empty($formData)) {
         return;
     }
     if (!$app->isAdmin()) {
         if (isset($formData[$product->product_id])) {
             $formData = $formData[$product->product_id];
         } else {
             if (isset($formData[0]) && $create) {
                 $formData = $formData[0];
             } else {
                 $formData = array();
             }
         }
     }
     if (empty($product->product_id)) {
         return;
     }
     $extra_filters = '';
     if ($vendor !== null && $vendor > 1) {
         $extra_filters = ' AND a.shipping_vendor_id IN (-1, 0, ' . (int) $vendor . ') ';
     }
     $db = JFactory::getDBO();
     $query = 'SELECT b.*, a.*, c.currency_symbol FROM ' . hikashop_table('shipping') . ' AS a INNER JOIN ' . hikashop_table('shipping_price') . ' AS b ON a.shipping_id = b.shipping_id INNER JOIN ' . hikashop_table('currency') . ' AS c ON c.currency_id = a.shipping_currency_id ' . 'WHERE a.shipping_params LIKE ' . $db->Quote('%s:20:"shipping_per_product";s:1:"1"%') . ' AND b.shipping_price_ref_id = ' . $product->product_id . ' AND b.shipping_price_ref_type = \'product\' ' . $extra_filters . 'ORDER BY a.shipping_id, b.shipping_price_min_quantity';
     $db->setQuery($query);
     $shippings = $db->loadObjectList('shipping_price_id');
     $toRemove = array_keys($shippings);
     if (!empty($toRemove)) {
         $toRemove = array_combine($toRemove, $toRemove);
     }
     $toInsert = array();
     $checks = array();
     foreach ($formData as &$data) {
         if (is_string($data)) {
             $data = null;
         } else {
             if (empty($checks[$data['shipping_id']])) {
                 $checks[$data['shipping_id']] = array();
             }
             if (!isset($checks[$data['shipping_id']][$data['qty']])) {
                 $checks[$data['shipping_id']][$data['qty']] = true;
             } else {
                 $data = null;
             }
         }
         unset($data);
     }
     unset($checks);
     foreach ($formData as $data) {
         if ($data == null) {
             continue;
         }
         $shipping = null;
         if (!empty($data['id']) && isset($shippings[$data['id']])) {
             if (empty($data['value']) && empty($data['fee'])) {
                 continue;
             }
             $shipping = $shippings[$data['id']];
             unset($toRemove[$data['id']]);
             if (empty($data['qty']) || (int) $data['qty'] < 1) {
                 $data['qty'] = 1;
             }
             if ((int) $shipping->shipping_price_min_quantity != (int) $data['qty'] || (double) $shipping->shipping_price_value != (double) $data['value'] || (double) $shipping->shipping_fee_value != (double) $data['fee']) {
                 $query = 'UPDATE ' . hikashop_table('shipping_price') . ' SET shipping_price_min_quantity = ' . (int) $data['qty'] . ', shipping_price_value = ' . (double) $data['value'] . ', shipping_fee_value = ' . (double) $data['fee'] . ' WHERE shipping_price_id = ' . $data['id'] . ' AND shipping_price_ref_id = ' . $product->product_id . ' AND shipping_price_ref_type = \'product\'';
                 $db->setQuery($query);
                 $db->query();
             }
         } else {
             if ((!empty($data['value']) || !empty($data['fee'])) && !empty($data['shipping_id'])) {
                 if (empty($data['qty']) || (int) $data['qty'] < 1) {
                     $data['qty'] = 1;
                 }
                 $toInsert[] = (int) $data['shipping_id'] . ',' . $product->product_id . ',\'product\',' . (int) $data['qty'] . ',' . (double) $data['value'] . ',' . (double) $data['fee'];
             }
         }
     }
     if (!empty($toRemove)) {
         $db->setQuery('DELETE FROM ' . hikashop_table('shipping_price') . ' WHERE shipping_price_ref_id = ' . $product->product_id . ' AND shipping_price_ref_type = \'product\' AND shipping_price_id IN (' . implode(',', $toRemove) . ')');
         $db->query();
     }
     if (!empty($toInsert)) {
         $db->setQuery('INSERT IGNORE INTO ' . hikashop_table('shipping_price') . ' (`shipping_id`,`shipping_price_ref_id`,`shipping_price_ref_type`,`shipping_price_min_quantity`,`shipping_price_value`,`shipping_fee_value`) VALUES (' . implode('),(', $toInsert) . ')');
         $db->query();
     }
 }
Beispiel #6
0
 private function retrieveData($table, $field, &$serial, $order)
 {
     $field = trim($field);
     $table = trim($table);
     switch ($table) {
         case 'serial':
             if (substr($field, 0, 10) == 'extradata.') {
                 $field = substr($field, 10);
                 if (is_string($serial->serial_extradata)) {
                     $serial->serial_extradata = unserialize($serial->serial_extradata);
                 }
                 if (!empty($serial->serial_extradata->{$field})) {
                     return $serial->serial_extradata->{$field};
                 }
                 if (!empty($serial->serial_extradata[$field])) {
                     return $serial->serial_extradata[$field];
                 }
             } else {
                 if (!empty($serial->{$field})) {
                     return $serial->{$field};
                 }
             }
             break;
         case '_':
             return JText::_($field);
             break;
         case 'rawtext':
             return $field;
             break;
         case 'order':
             if (!empty($order->{$field})) {
                 return $order->{$field};
             }
             break;
         case 'customer':
             if (!empty($order->customer->{$field})) {
                 return $order->customer->{$field};
             }
             break;
         case 'order_product':
             if (empty($serial)) {
                 return null;
             }
             $opid = 0;
             $pid = (int) $serial->product_id;
             if (!empty($serial->serial_order_product_id)) {
                 $opid = (int) $serial->serial_order_product_id;
             }
             foreach ($order->products as $product) {
                 if ($opid > 0 && $product->order_product_id == $opid || $opid == 0 && $product->product_id == $pid) {
                     if (!empty($product->{$field})) {
                         if ($field == 'order_product_name') {
                             return strip_tags($product->{$field});
                         }
                         return $product->{$field};
                     }
                     return null;
                 }
             }
             break;
         case 'product_price':
         case 'full_product_price':
             if (empty($serial)) {
                 return null;
             }
             $opid = 0;
             $pid = (int) $serial->product_id;
             if (!empty($serial->serial_order_product_id)) {
                 $opid = (int) $serial->serial_order_product_id;
             }
             $price = null;
             foreach ($order->products as $product) {
                 if ($opid > 0 && $product->order_product_id == $opid || $opid == 0 && $product->product_id == $pid) {
                     if ($price === null) {
                         $price = 0.0;
                     }
                     $price += $product->order_product_price;
                     if ($field == 'incvat') {
                         $price += $product->order_product_tax;
                     }
                     if ($table == 'product_price') {
                         return $price;
                     }
                 }
                 if ($table == 'full_product_price' && $opid > 0 && $product->order_product_option_parent_id == $opid) {
                     if ($price === null) {
                         $price = 0.0;
                     }
                     $price += $product->order_product_price;
                     if ($field == 'incvat') {
                         $price += $product->order_product_tax;
                     }
                 }
             }
             if ($price != null) {
                 return $price;
             }
             break;
         case 'product':
             if ($field == 'image' || substr($field, 0, 6) == 'image.') {
                 if (!isset($this->cache['product_image'])) {
                     $this->cache['product_image'] = array();
                 }
                 if (!isset($this->cache['product_image'][$serial->product_id])) {
                     $db = JFactory::getDBO();
                     $db->setQuery('SELECT * FROM ' . hikaserial::table('shop.file') . ' as f LEFT JOIN ' . hikaserial::table('shop.product') . ' as p ON (f.file_ref_id = ' . $serial->product_id . ' OR f.file_ref_id = p.product_parent_id) WHERE file_type = \'product\' AND p.product_id = ' . $serial->product_id . ' ORDER BY product_parent_id DESC, file_ordering ASC, file_id ASC');
                     $this->cache['product_image'][$serial->product_id] = $db->loadObjectList();
                 }
                 $images = $this->cache['product_image'][$serial->product_id];
                 if ($field == 'image' || $field == 'image.0') {
                     $main_image = reset($images);
                     if (!empty($main_image)) {
                         return $main_image->file_path;
                     }
                 } else {
                     list($field, $pos) = explode('.', $field, 2);
                     $pos = (int) $pos;
                     foreach ($images as $k => $v) {
                         if ($k == $pos) {
                             return $v->file_path;
                         }
                     }
                 }
             } else {
                 if (empty($this->productClass)) {
                     $this->productClass = hikaserial::get('shop.class.product');
                 }
                 if (!isset($this->cache['product'])) {
                     $this->cache['product'] = array();
                 }
                 if (!isset($this->cache['product'][$serial->product_id])) {
                     $this->cache['product'][$serial->product_id] = $this->productClass->get($serial->product_id);
                 }
                 $product = $this->cache['product'][$serial->product_id];
                 if (!empty($product) && !empty($product->{$field})) {
                     return $product->{$field};
                 }
             }
             break;
         case 'shipping':
             if (!empty($order->shipping_address->{$field})) {
                 return $order->shipping_address->{$field};
             }
             break;
         case 'billing':
             if (!empty($order->billing_address->{$field})) {
                 return $order->billing_address->{$field};
             }
             break;
         case 'option_product':
             if (empty($serial)) {
                 return null;
             }
             if (strpos($field, '.') === false) {
                 return null;
             }
             list($pos, $field) = explode('.', $field, 2);
             $pos = (int) $pos + 1;
             if (empty($this->productClass)) {
                 $this->productClass = hikaserial::get('shop.class.product');
             }
             if (!isset($this->cache['product'])) {
                 $this->cache['product'] = array();
             }
             if (!isset($this->cache['product_image'])) {
                 $this->cache['product_image'] = array();
             }
             $opid = 0;
             $pid = (int) $serial->product_id;
             if (!empty($serial->serial_order_product_id)) {
                 $opid = (int) $serial->serial_order_product_id;
             }
             if (empty($opid)) {
                 foreach ($order->products as $product) {
                     if ($product->product_id == $pid) {
                         $opid = (int) $product->order_product_id;
                         break;
                     }
                 }
             }
             if ($opid <= 0) {
                 return null;
             }
             $i = 0;
             foreach ($order->products as $product) {
                 if ($product->order_product_option_parent_id != $opid) {
                     continue;
                 }
                 $i++;
                 if ($i != $pos) {
                     continue;
                 }
                 if ($field == 'image' || substr($field, 0, 6) == 'image.') {
                     if (!isset($this->cache['product_image'][$product->product_id])) {
                         $db = JFactory::getDBO();
                         $db->setQuery('SELECT * FROM ' . hikaserial::table('shop.file') . ' as f LEFT JOIN ' . hikaserial::table('shop.product') . ' as p ON (f.file_ref_id = ' . (int) $product->product_id . ' OR f.file_ref_id = p.product_parent_id) WHERE file_type = \'product\' AND p.product_id = ' . (int) $product->product_id . ' ORDER BY product_parent_id DESC, file_ordering ASC, file_id ASC');
                         $this->cache['product_image'][$product->product_id] = $db->loadObjectList();
                     }
                     $images = $this->cache['product_image'][$product->product_id];
                     if ($field == 'image' || $field == 'image.0') {
                         $main_image = reset($images);
                         if (!empty($main_image)) {
                             return $main_image->file_path;
                         }
                         return null;
                     }
                     list($field, $pos) = explode('.', $field, 2);
                     $pos = (int) $pos;
                     foreach ($images as $k => $v) {
                         if ($k == $pos) {
                             return $v->file_path;
                         }
                     }
                     return null;
                 }
                 if (!isset($this->cache['product'][$product->product_id])) {
                     $this->cache['product'][$product->product_id] = $this->productClass->get($product->product_id);
                 }
                 $full_product = $this->cache['product'][$product->product_id];
                 if (!empty($full_product) && !empty($full_product->{$field})) {
                     return $full_product->{$field};
                 }
                 return null;
             }
             break;
         case 'vendor_product':
             if (empty($serial)) {
                 return null;
             }
             if (!isset($this->cache['product_vendor'])) {
                 $this->cache['product_vendor'] = array();
             }
             if (!defined('HIKAMARKET_COMPONENT')) {
                 $marketHelper = rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . 'com_hikamarket' . DS . 'helpers' . DS . 'helper.php';
                 if (!file_exists($marketHelper)) {
                     return null;
                 }
                 include_once $marketHelper;
                 if (!defined('HIKAMARKET_COMPONENT')) {
                     return null;
                 }
             }
             if (!isset($this->cache['product_vendor'][$serial->product_id])) {
                 $query = 'SELECT * FROM ' . hikamarket::table('vendor') . ' AS v INNER JOIN ' . hikamarket::table('shop.product') . ' AS p ON p.product_vendor_id = v.vendor_id WHERE p.product_id = ' . $serial->product_id;
                 $db = JFactory::getDBO();
                 $db->setQuery($query);
                 $this->cache['product_vendor'][$serial->product_id] = $db->loadObject();
             }
             $vendor = $this->cache['product_vendor'][$serial->product_id];
             if (!empty($vendor) && !empty($vendor->{$field})) {
                 return $vendor->{$field};
             }
             break;
         case 'option_order':
             if (empty($serial)) {
                 return null;
             }
             if (strpos($field, '.') === false) {
                 return null;
             }
             list($pos, $field) = explode('.', $field, 2);
             $pos = (int) $pos + 1;
             $opid = 0;
             $pid = (int) $serial->product_id;
             if (!empty($serial->serial_order_product_id)) {
                 $opid = (int) $serial->serial_order_product_id;
             }
             if (empty($opid)) {
                 foreach ($order->products as $product) {
                     if ($product->product_id == $pid) {
                         $opid = $product->order_product_id;
                         break;
                     }
                 }
             }
             if ($opid > 0) {
                 $i = 0;
                 foreach ($order->products as $product) {
                     if ($opid > 0 && $product->order_product_option_parent_id == $opid) {
                         $i++;
                     }
                     if ($i == $pos) {
                         if (!empty($product->{$field})) {
                             if ($field == 'order_product_name') {
                                 return strip_tags($product->{$field});
                             }
                             return $product->{$field};
                         }
                         return null;
                     }
                 }
             }
             break;
         case 'entry':
             if (empty($order->entries)) {
                 $query = 'SELECT * FROM ' . hikaserial::table('shop.entry') . ' WHERE order_id=' . $order->order_id;
                 $db = JFactory::getDBO();
                 $db->setQuery($query);
                 $order->entries = $db->loadObjectList();
             }
             if (!empty($order->entries)) {
                 $opid = 0;
                 $pid = (int) $serial->product_id;
                 if (!empty($serial->serial_order_product_id)) {
                     $opid = (int) $serial->serial_order_product_id;
                 }
                 $cpt_product = 0;
                 $target_product = 0;
                 foreach ($order->products as $product) {
                     if ($product->product_id == $pid) {
                         $cpt_product += $product->order_product_quantity;
                     }
                     if ($opid > 0 && $opid == $product->order_product_id) {
                         $target_product = $cpt_product;
                     }
                 }
                 if ($target_product > 0) {
                     $fieldClass = hikaserial::get('shop.class.field');
                     $data = new stdClass();
                     $entryFields = $fieldClass->getFields('', $data, 'entry');
                     $accept_values = array();
                     foreach ($entryFields as $entryField) {
                         if ($entryField->field_options['product_id'] == $pid) {
                             $accept_values[$entryField->field_namekey] = $entryField->field_options['product_value'];
                         }
                     }
                     $cpt = 0;
                     if (empty($serial->position)) {
                         $serial->position = 1;
                     }
                     foreach ($order->entries as $entry) {
                         foreach ($accept_values as $key => $value) {
                             if ($entry->{$key} == $value || is_array($value) && in_array($entry->{$key}, $value)) {
                                 $cpt++;
                                 if ($cpt + $serial->position - 1 == $target_product) {
                                     return $entry->{$field};
                                 }
                             }
                         }
                     }
                 }
             }
             break;
     }
     return null;
 }
Beispiel #7
0
 public function useselection()
 {
     $products = JRequest::getVar('pid', array(), '', 'array');
     $rows = array();
     $data = '';
     $confirm = JRequest::getVar('confirm', true);
     $singleSelection = JRequest::getVar('single', false);
     $elemStruct = array('product_name', 'product_code', 'product_price', 'product_quantity');
     if (!empty($products)) {
         JArrayHelper::toInteger($products);
     }
     $this->assignRef('rows', $rows);
     $this->assignRef('data', $data);
     $this->assignRef('confirm', $confirm);
     $this->assignRef('singleSelection', $singleSelection);
     if ($confirm == true) {
         hikamarket::loadJslib('mootools');
         $js = 'window.hikashop.ready( function(){window.parent.hikashop.submitBox(' . $data . ');});';
         $doc = JFactory::getDocument();
         $doc->addScriptDeclaration($js);
     }
 }
Beispiel #8
0
 */
defined('_JEXEC') or die('Restricted access');
?>
<fieldset>
	<div class="toolbar" id="toolbar" style="float: right;">
		<button class="btn" type="button" onclick="window.hikamarket.submitform('galleryselect','adminForm');"><img style="vertical-align: middle" src="<?php 
echo HIKASHOP_IMAGES;
?>
save.png"/><?php 
echo JText::_('OK');
?>
</button>
	</div>
</fieldset>
<form action="<?php 
echo hikamarket::completeLink('upload&task=galleryimage', true);
?>
" method="post" name="adminForm" id="adminForm">
	<table width="100%" height="100%" class="adminlist" style="width:100%;height:100%;">
		<thead>
			<tr>
				<th></th>
				<th>
					<?php 
echo JText::_('FILTER');
?>
:
					<input type="text" name="search" value="<?php 
echo $this->escape($this->pageInfo->search);
?>
" class="text_area" onchange="document.adminForm.submit();" />
Beispiel #9
0
 function _getVendorInfo()
 {
     static $vendor = null;
     if ($vendor !== null) {
         return $vendor;
     }
     $app = JFactory::getApplication();
     $vendor_id = (int) hikashop_getCID('vendor_id');
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     if (empty($menu) && !empty($Itemid)) {
         $menus->setActive($Itemid);
         $menu = $menus->getItem($Itemid);
     }
     if (empty($vendor_id) && is_object($menu) && !empty($menu->params)) {
         jimport('joomla.html.parameter');
         $params = new JParameter($menu->params);
         $vendor_id = $params->get('vendor_id');
     }
     $vendor = false;
     if (!empty($vendor_id)) {
         $vendorClass = hikamarket::get('class.vendor');
         $vendor = $vendorClass->get($vendor_id);
     }
     return $vendor;
 }
Beispiel #10
0
 */
defined('_JEXEC') or die('Restricted access');
?>
<fieldset>
	<div class="toolbar" id="toolbar" style="float: right;">
		<button class="btn" type="button" onclick="hikamarket.submitform('addimage','hikashop_form');"><img style="vertical-align:middle" src="<?php 
echo HIKASHOP_IMAGES;
?>
save.png"/><?php 
echo JText::_('OK');
?>
</button>
	</div>
</fieldset>
<form action="<?php 
echo hikamarket::completeLink('upload&task=image');
?>
" method="post" name="hikashop_form" id="hikashop_form" enctype="multipart/form-data">
	<table width="100%">
		<tr>
<?php 
if (empty($this->element->file_path)) {
    ?>
			<td class="key">
				<label for="files"><?php 
    echo JText::_('HIKA_IMAGE');
    ?>
</label>
			</td>
			<td>
				<input type="file" name="files[]" size="30" />