예제 #1
0
 public function &generate($id, &$serial, $newSerial = false)
 {
     if (empty($id)) {
         $id = @$serial->serial_id;
     }
     if (empty($id)) {
         return false;
     }
     $history = new stdClass();
     $history->history_serial_id = $id;
     $history->history_created = time();
     $history->history_ip = hikaserial::getIP();
     $history->history_user_id = hikaserial::loadUser();
     if ($newSerial) {
         $history->history_type = 'creation';
     } else {
         $history->history_type = 'modification';
     }
     if (empty($serial->serial_status) && !$newSerial) {
         $serialClass = hikaserial::get('class.serial');
         $old = $serialClass->get((int) $id);
         $serial->serial_status = $old->order_status;
         unset($old);
     }
     $history->history_new_status = $serial->serial_status;
     if (!empty($serial->history)) {
         foreach (get_object_vars($serial->history) as $k => $v) {
             $history->{$k} = $v;
         }
     }
     return $history;
 }
예제 #2
0
 public function config($tpl = null)
 {
     hikaserial::setTitle(JText::_(self::name), self::icon, self::ctrl);
     $config = hikaserial::config();
     $this->assignRef('config', $config);
     $popup = hikaserial::get('shop.helper.popup');
     $this->assignRef('popup', $popup);
     $serialstatusType = hikaserial::get('type.serial_status');
     $this->assignRef('serial_status', $serialstatusType);
     $orderstatusType = hikaserial::get('type.order_status');
     $this->assignRef('orderstatusType', $orderstatusType);
     $manage = hikaserial::isAllowed($config->get('acl_config_manage', 'all'));
     $this->assignRef('manage', $manage);
     $toggleClass = hikaserial::get('helper.toggle');
     $languages = array();
     $lg = JFactory::getLanguage();
     $language = $lg->getTag();
     $styleRemind = 'float:right;margin-right:30px;position:relative;';
     $loadLink = $popup->display(JText::_('LOAD_LATEST_LANGUAGE'), 'EDIT_LANGUAGE_FILE', hikaserial::completeLink('config&task=latest&code=' . $language, true), 'loadlatest_language_' . $language, 800, 500, 'onclick="window.document.getElementById(\'hikashop_messages_warning\').style.display = \'none\';"', '', 'link');
     if (!file_exists(HIKASHOP_ROOT . 'language' . DS . $language . DS . $language . '.' . HIKASERIAL_COMPONENT . '.ini')) {
         if ($config->get('errorlanguagemissing', 1)) {
             $noteremind = '<small style="' . $styleRemind . '">' . $toggleClass->delete('hikashop_messages_warning', 'errorlanguagemissing-0', 'config', false, JText::_('DONT_REMIND')) . '</small>';
             hikaserial::display(JText::_('MISSING_LANGUAGE') . ' ' . $loadLink . ' ' . $noteremind, 'warning');
         }
     }
     $edit_image = HIKASHOP_IMAGES . 'icons/icon-16-edit.png';
     $new_image = HIKASHOP_IMAGES . 'icons/icon-16-new.png';
     jimport('joomla.filesystem.folder');
     $path = JLanguage::getLanguagePath(JPATH_ROOT);
     $dirs = JFolder::folders($path);
     foreach ($dirs as $dir) {
         $xmlFiles = JFolder::files($path . DS . $dir, '^([-_A-Za-z]*)\\.xml$');
         $xmlFile = array_pop($xmlFiles);
         if ($xmlFile == 'install.xml') {
             $xmlFile = array_pop($xmlFiles);
         }
         if (empty($xmlFile)) {
             continue;
         }
         $data = JApplicationHelper::parseXMLLangMetaFile($path . DS . $dir . DS . $xmlFile);
         $oneLanguage = new stdClass();
         $oneLanguage->language = $dir;
         $oneLanguage->name = $data['name'];
         $languageFiles = JFolder::files($path . DS . $dir, '^(.*)\\.' . HIKASERIAL_COMPONENT . '\\.ini$');
         $languageFile = reset($languageFiles);
         $linkEdit = hikaserial::completeLink('config&task=language&code=' . $oneLanguage->language, true, false, false);
         if (!empty($languageFile)) {
             $oneLanguage->edit = $popup->display('<img id="image' . $oneLanguage->language . '" src="' . $edit_image . '" alt="' . JText::_('EDIT_LANGUAGE_FILE', true) . '"/>', 'EDIT_LANGUAGE_FILE', $linkEdit, 'edit_language_' . $oneLanguage->language, 800, 500, '', '', 'link');
         } else {
             $oneLanguage->edit = $popup->display('<img id="image' . $oneLanguage->language . '" src="' . $new_image . '" alt="' . JText::_('ADD_LANGUAGE_FILE', true) . '"/>', 'ADD_LANGUAGE_FILE', $linkEdit, 'edit_language_' . $oneLanguage->language, 800, 500, '', '', 'link');
         }
         $languages[] = $oneLanguage;
     }
     $this->assignRef('languages', $languages);
     $this->toolbar = array('|', 'save', 'apply', 'hikacancel', '|', array('name' => 'pophelp', 'target' => 'config'), 'dashboard');
 }
예제 #3
0
 public function refresh()
 {
     $app = JFactory::getApplication();
     $orderClass = hikaserial::get('class.order');
     $orderId = hikaserial::getCID('order_id');
     if (empty($orderId)) {
         $app->redirect(hikaserial::completeLink('dashboard'));
     }
     $orderClass->refresh($orderId);
     $app->redirect(hikaserial::completeLink('shop.order&task=edit&cid[]=' . $orderId, false, true));
 }
예제 #4
0
파일: pack.php 프로젝트: q0821/esportshop
    public function displaySingle($map, $value, $delete = false)
    {
        static $jsInit = null;
        if ($jsInit !== true) {
            $display_format = 'data.pack_name';
            if ($this->app->isAdmin()) {
                $display_format = 'data.id + " - " + data.pack_name';
            }
            $js = '
if(!window.localPage)
	window.localPage = {};
window.localPage.fieldSetSinglePack = function(el, name) {
	window.hikaserial.submitFct = function(data) {
		var d = document,
			packInput = d.getElementById(name + "_input_id"),
			packSpan = d.getElementById(name + "_span_id");
		if(packInput) { packInput.value = data.id; }
		if(packSpan) { packSpan.innerHTML = ' . $display_format . '; }
	};
	window.hikaserial.openBox(el,null,(el.getAttribute("rel") == null));
	return false;
}
window.localPage.fieldRemSinglePack = function(el, name) {
	var d = document,
		packInput = d.getElementById(name + "_input_id"),
		packSpan = d.getElementById(name + "_span_id");
	if(packInput) { packInput.value = ""; }
	if(packSpan) { packSpan.innerHTML = " - "; }
}
';
            $doc = JFactory::getDocument();
            $doc->addScriptDeclaration($js);
        }
        $packClass = hikaserial::get('class.pack');
        $popup = hikaserial::get('shop.helper.popup');
        $name = str_replace(array('][', '[', ']'), '_', $map);
        $pack_id = (int) $value;
        $pack = $packClass->get($pack_id);
        $pack_name = '';
        if (!empty($pack)) {
            $pack_name = @$pack->pack_name;
        } else {
            $pack_id = '';
        }
        $pack_display_name = $pack_name;
        if ($this->app->isAdmin()) {
            $pack_display_name = $pack_id . ' - ' . $pack_name;
        }
        $ret = '<span id="' . $name . '_span_id">' . $pack_display_name . '</span>' . '<input type="hidden" id="' . $name . '_input_id" name="' . $map . '" value="' . $pack_id . '"/> ' . $popup->display('<img src="' . HIKASERIAL_IMAGES . 'icon-16/edit.png" style="vertical-align:middle;"/>', 'PACK_SELECTION', hikaserial::completeLink('pack&task=select&single=true', true), 'serial_set_pack_' . $name, 760, 480, 'onclick="return window.localPage.fieldSetSinglePack(this,\'' . $name . '\');"', '', 'link');
        if ($delete) {
            $ret .= ' <a title="' . JText::_('HIKA_DELETE') . '" href="#' . JText::_('HIKA_DELETE') . '" onclick="return window.localPage.fieldRemSinglePack(this, \'' . $name . '\');"><img src="' . HIKASERIAL_IMAGES . 'icon-16/delete.png" style="vertical-align:middle;"/></a>';
        }
        return $ret;
    }
예제 #5
0
 public function listing()
 {
     hikaserial::setTitle(JText::_(self::name), self::icon, self::ctrl);
     $buttons = array(array('name' => JText::_('ADD_NEW_SERIAL'), 'url' => hikaserial::completeLink('serial&task=edit'), 'icon' => 'icon-48-add-serials'), array('name' => JText::_('HIKA_SERIALS'), 'url' => hikaserial::completeLink('serial'), 'icon' => 'icon-48-serials'), array('name' => JText::_('HIKA_PACKS'), 'url' => hikaserial::completeLink('pack'), 'icon' => 'icon-48-pack'), array('name' => JText::_('PLUGINS'), 'url' => hikaserial::completeLink('plugins'), 'icon' => 'icon-48-plugin'), array('name' => JText::_('HIKA_CONFIGURATION'), 'url' => hikaserial::completeLink('config'), 'icon' => 'icon-48-config'), array('name' => JText::_('IMPORT'), 'url' => hikaserial::completeLink('import'), 'icon' => 'icon-48-import'), array('name' => JText::_('UPDATE_ABOUT'), 'url' => hikaserial::completeLink('update'), 'icon' => 'icon-48-install'), array('name' => JText::_('HIKA_HELP'), 'url' => hikaserial::completeLink('documentation'), 'icon' => 'icon-48-help_header'));
     $this->assignRef('buttons', $buttons);
     if (HIKASHOP_J16 && JFactory::getUser()->authorise('core.admin', 'com_hikamarket')) {
         $this->toolbar[] = array('name' => 'preferences', 'component' => 'com_hikaserial');
     }
     $this->toolbar[] = array('name' => 'pophelp', 'target' => 'welcome');
     $toggleClass = hikaserial::get('helper.toggle');
     $this->assignRef('toggleClass', $toggleClass);
 }
예제 #6
0
파일: serial.php 프로젝트: q0821/esportshop
 public function remove()
 {
     JRequest::checkToken() || die('Invalid Token');
     $cids = JRequest::getVar('cid', array(), '', 'array');
     $serialClass = hikaserial::get('class.serial');
     $num = $serialClass->delete($cids);
     if ($num) {
         $app = JFactory::getApplication();
         $app->enqueueMessage(JText::sprintf('SUCC_DELETE_ELEMENTS', count($cids)), 'message');
     }
     return parent::listing();
 }
예제 #7
0
파일: update.php 프로젝트: q0821/esportshop
 public function update()
 {
     $config = hikaserial::config();
     if ($config->get('website') != HIKASHOP_LIVE) {
         $updateHelper = hikaserial::get('helper.update');
         $updateHelper->addUpdateSite();
     }
     hikaserial::setTitle(JText::_('UPDATE_ABOUT'), 'install', 'update');
     $bar = JToolBar::getInstance('toolbar');
     $bar->appendButton('Link', HIKASERIAL_LNAME, JText::_('HIKASHOP_CPANEL'), hikaserial::completeLink('dashboard'));
     $this->showIframe(HIKASERIAL_UPDATEURL . 'update');
     return false;
 }
예제 #8
0
 public function delete($elements)
 {
     $status = parent::delete($elements);
     if ($status) {
         $app = JFactory::getApplication();
         $orderClass = hikaserial::get('helper.order');
         $orderClass->pkey = 'consumer_id';
         $orderClass->table = 'consumer';
         $orderClass->groupMap = 'consumer_type';
         $orderClass->orderingMap = 'consumer_ordering';
         $orderClass->groupVal = $app->getUserStateFromRequest(HIKASERIAL_COMPONENT . '.consumer_plugin_type', 'consumer_plugin_type', '');
         $orderClass->reOrder();
     }
     return $status;
 }
예제 #9
0
 public function fetchButton($type = 'Popup', $name = '', $text = '', $url = '', $width = 640, $height = 480, $top = 0, $left = 0, $onClose = '', $title = '', $footer = '')
 {
     if (empty($title) && empty($footer)) {
         return parent::fetchButton($type, $name, $text, $url, $width, $height, $top, $left, $onClose);
     }
     JHtml::_('behavior.modal');
     $text = JText::_($text);
     $class = $this->fetchIconClass($name);
     $doTask = $url;
     //$this->_getCommand($name, $url, $width, $height, $top, $left);
     $id = 'modal-toolbar-' . $name;
     $popup = hikaserial::get('shop.helper.popup');
     $params = array('width' => $width, 'height' => $height, 'type' => 'link', 'footer' => $footer);
     $html = $popup->displayMootools('<span class="' . $class . '"></span>' . $text, $title, $doTask, $id, $params);
     return $html;
 }
예제 #10
0
파일: import.php 프로젝트: q0821/esportshop
 private function importTextarea()
 {
     $content = JRequest::getVar('textareaimport_content', '', '', 'string', JREQUEST_ALLOWRAW);
     $this->helper->pack_id = JRequest::getInt('textareaimport_pack');
     $productClass = hikaserial::get('class.product');
     $importAsCsv = JRequest::getInt('textareaimport_as_csv', 0);
     if ($importAsCsv == 0) {
         if ($this->helper->pack_id == 0) {
             return false;
         }
         $ret = $this->helper->handleTextContent($content);
         $productClass->refreshQuantities();
         return $ret;
     }
     $ret = $this->helper->handleCsvContent($content);
     $productClass->refreshQuantities();
     return $ret;
 }
예제 #11
0
 public function configurationLine($id = 0, $conf = null)
 {
     if (empty($this->toggleHelper)) {
         $this->toggleHelper = hikaserial::get('helper.toggle');
     }
     switch ($id) {
         case 'pack':
             if (empty($this->packs)) {
                 $db = JFactory::getDBO();
                 $db->setQuery('SELECT * FROM ' . hikaserial::table('pack'));
                 $this->packs = $db->loadObjectList('pack_id');
             }
             $ret = array();
             if (!empty($conf->plugin_params->pack_id) && isset($this->packs[(int) $conf->plugin_params->pack_id])) {
                 return '<a href="' . hikaserial::completeLink('pack&task=edit&cid=' . (int) $conf->plugin_params->pack_id) . '">' . $this->packs[(int) $conf->plugin_params->pack_id]->pack_name . '</a>';
             }
     }
     return null;
 }
예제 #12
0
 public function coupon()
 {
     $app = JFactory::getApplication();
     global $Itemid;
     $url_itemid = '';
     if (!empty($Itemid)) {
         $url_itemid = '&Itemid=' . $Itemid;
     }
     $this->assignRef('url_itemid', $url_itemid);
     $config = hikaserial::config();
     $this->assignRef('config', $config);
     $shopConfig = hikaserial::config(false);
     $this->assignRef('shopConfig', $shopConfig);
     $cart = $this->params->view->initCart();
     if (isset($cart->coupon)) {
         $this->assignRef('coupon', $cart->coupon);
     }
     $this->assignRef('step', $this->params->view->step);
     $cartHelper = hikaserial::get('shop.helper.cart');
     $this->assignRef('cartHelper', $cartHelper);
 }
예제 #13
0
 public function market_block($params = null)
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $config = hikaserial::config();
     $this->assignRef('config', $config);
     $popupHelper = hikaserial::get('shop.helper.popup');
     $this->assignRef('popupHelper', $popupHelper);
     $data = null;
     $product_id = 0;
     if (!empty($params)) {
         $product_id = (int) $params->get('product_id');
     }
     if ($product_id > 0) {
         $query = 'SELECT a.*, b.* FROM ' . hikaserial::table('product_pack') . ' as a INNER JOIN ' . hikaserial::table('pack') . ' as b ON a.pack_id = b.pack_id WHERE a.product_id = ' . $product_id;
         $db->setQuery($query);
         $data = $db->loadObjectList();
     }
     $this->assignRef('data', $data);
     $this->assignRef('product_id', $product_id);
 }
예제 #14
0
 function generateCoupon($allresults, $i, $user, $send)
 {
     $db =& JFactory::getDBO();
     $packClass = hikaserial::get('class.pack');
     $config = hikaserial::config();
     $generator = null;
     $serials = array();
     $order = null;
     list($pack_id, $serial_status) = explode('|', $allresults[1][$i]);
     if (empty($serial_status)) {
         $serial_status = $config->get('used_serial_status', 'used');
     }
     $pack = $packClass->get($pack_id);
     if (substr($pack->pack_generator, 0, 4) == 'plg.') {
         $pluginName = substr($pack->pack_generator, 4);
         if (strpos($pluginName, '-') !== false) {
             list($pluginName, $pluginId) = explode('-', $pluginName, 2);
             $pack->{$pluginName} = $pluginId;
         }
         $generator = hikaserial::import('hikaserial', $pluginName);
     }
     if ($generator != null && method_exists($generator, 'generate')) {
         if (!$send) {
             $generator->test = true;
         }
         ob_start();
         $generator->generate($pack, $order, 1, $serials);
         ob_get_clean();
     }
     if ($send && !empty($serials)) {
         $serial = reset($serials);
         $extra_data = '';
         if (is_object($serial)) {
             if (!empty($serial->extradata)) {
                 $extra_data = serialize($serial->extradata);
             }
             $serial = $serial->data;
         }
         $data = array('serial_pack_id' => (int) $pack_id, 'serial_data' => $db->Quote($serial), 'serial_status' => $db->Quote($serial_status), 'serial_assign_date' => 'NULL', 'serial_order_id' => 'NULL', 'serial_user_id' => 'NULL', 'serial_order_product_id' => 'NULL', 'serial_extradata' => $db->Quote($extra_data));
         $query = 'INSERT IGNORE INTO ' . hikaserial::table('serial') . ' (' . implode(',', array_keys($data)) . ') VALUES (' . implode(',', $data) . ')';
         $db->setQuery($query);
         $db->query();
         unset($query);
         return $serial;
     } elseif (!empty($serials)) {
         $serial = reset($serials);
         if (is_object($serial)) {
             $serial = $serial->data;
         }
         return $serial;
     }
     return '';
 }
예제 #15
0
 public function listing()
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $fieldsClass = hikaserial::get('shop.class.field');
     $fields = $fieldsClass->getData('backend_listing', 'user', false);
     $singleSelection = JRequest::getVar('single', false);
     $confirm = JRequest::getVar('confirm', true, '', 'boolean');
     $elemStruct = array('user_email', 'user_cms_id', 'name', 'username', 'email');
     $pageInfo = new stdClass();
     $pageInfo->filter = new stdClass();
     $pageInfo->filter->order = new stdClass();
     $pageInfo->limit = new stdClass();
     $pageInfo->elements = new stdClass();
     $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string');
     $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.user_id', 'cmd');
     $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word');
     $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int');
     if (empty($pageInfo->limit->value)) {
         $pageInfo->limit->value = 500;
     }
     $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int');
     $pageInfo->filter->filter_partner = $app->getUserStateFromRequest($this->paramBase . ".filter_partner", 'filter_partner', '', 'int');
     $filters = array();
     $searchMap = array('a.user_id', 'a.user_email', 'b.username', 'b.email', 'b.name');
     foreach ($fields as $field) {
         $searchMap[] = 'a.' . $field->field_namekey;
     }
     if (!empty($pageInfo->search)) {
         if (!HIKASHOP_J30) {
             $searchVal = '\'%' . $db->getEscaped(JString::strtolower($pageInfo->search), true) . '%\'';
         } else {
             $searchVal = '\'%' . $db->escape(JString::strtolower($pageInfo->search), true) . '%\'';
         }
         $filters[] = '(' . implode(' LIKE ' . $searchVal . ' OR ', $searchMap) . ' LIKE ' . $searchVal . ')';
     }
     $order = '';
     if (!empty($pageInfo->filter->order->value)) {
         $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir;
     }
     if (!empty($filters)) {
         $filters = ' WHERE ' . implode(' AND ', $filters);
     } else {
         $filters = '';
     }
     $query = ' FROM ' . hikaserial::table('user', 'shop') . ' AS a LEFT JOIN ' . hikaserial::table('users', false) . ' AS b ON a.user_cms_id = b.id ' . $filters . $order;
     $db->setQuery('SELECT a.*,b.*' . $query, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value);
     $rows = $db->loadObjectList();
     $fieldsClass->handleZoneListing($fields, $rows);
     if (!empty($rows)) {
         foreach ($rows as $k => $row) {
             if (!empty($row->user_params)) {
                 $rows[$k]->user_params = unserialize($row->user_params);
             }
         }
     }
     if (!empty($pageInfo->search)) {
         $rows = hikaserial::search($pageInfo->search, $rows, 'user_id');
     }
     $db->setQuery('SELECT COUNT(*)' . $query);
     $pageInfo->elements->total = $db->loadResult();
     $pageInfo->elements->page = count($rows);
     jimport('joomla.html.pagination');
     if ($pageInfo->limit->value == 500) {
         $pageInfo->limit->value = 100;
     }
     $pagination = new JPagination($pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value);
     $this->assignRef('rows', $rows);
     $this->assignRef('singleSelection', $singleSelection);
     $this->assignRef('confirm', $confirm);
     $this->assignRef('elemStruct', $elemStruct);
     $this->assignRef('pageInfo', $pageInfo);
     $this->assignRef('pagination', $pagination);
     $this->assignRef('fieldsClass', $fieldsClass);
     $this->assignRef('fields', $fields);
 }
예제 #16
0
파일: import.php 프로젝트: q0821/esportshop
 public function handleCsvContent(&$contentFile)
 {
     $app = JFactory::getApplication();
     $encodingHelper = hikaserial::get('shop.helper.encoding');
     $db_quote = $this->quote . $this->quote;
     $contentFile = str_replace(array("\r\n", "\r"), "\n", trim($contentFile));
     $nlPos = strpos($contentFile, "\n");
     $header = substr($contentFile, 0, $nlPos);
     $contentFile = substr($contentFile, $nlPos + 1);
     if (!$this->autoHeader($header)) {
         return;
     }
     $contentFile = str_replace($db_quote, '&quot;', $contentFile);
     $contentFile = str_replace($this->separator . '&quot;' . $this->separator, $this->separator . $this->separator, $contentFile);
     $contentFile = str_replace($this->separator . '&quot;' . "\n", $this->separator . "\n", $contentFile);
     $contentFile .= "\n";
     $opt = array('add_status' => !in_array('serial_id', $this->columns) && !in_array('serial_status', $this->columns), 'add_pack' => !in_array('serial_pack_id', $this->fields), 'extradata' => $this->fields[count($this->fields) - 1] == 'serial_extradata');
     $inquotes = false;
     $start = 0;
     $insert = 'REPLACE INTO ' . hikaserial::table('serial') . ' (' . implode(',', $this->fields);
     if ($opt['add_status']) {
         $insert .= ',serial_status';
     }
     if ($opt['add_pack']) {
         if (empty($this->pack_id)) {
             $app->enqueueMessage('PACK_IMPORT_ERROR_NO_PACK_SPECIFIED');
             return false;
         }
         $insert .= ',serial_pack_id';
     }
     $insert .= ') VALUES (';
     $serials = array();
     $productsAssociations = array('insert' => array(), 'search' => array());
     $i = 0;
     $l = strlen($contentFile);
     while ($i < $l) {
         $char = $contentFile[$i];
         if ($char == $this->quote) {
             $inquotes = !$inquotes;
         }
         if (($char == $this->separator || $char == "\n") && !$inquotes) {
             $cell = substr($contentFile, $start, $i - $start);
             $cell = str_replace($this->quote, '', $cell);
             $cell = str_replace('&quot;', $this->quote, $cell);
             $data[] = $cell;
             $start = $i + 1;
             if ($char == "\n") {
                 if (count($data) == 0) {
                     continue;
                 }
                 if (count($data) != count($this->columns)) {
                     return false;
                 }
                 $serial = array();
                 $association = array();
                 $serial_extradata = array();
                 foreach ($this->columns as $k => $v) {
                     if (substr($v, 0, 10) == 'extradata.') {
                         if (!empty($data[$k])) {
                             $serial_extradata[substr($v, 10)] = $data[$k];
                         }
                         continue;
                     }
                     switch ($v) {
                         case 'pack_name':
                             if (!isset($this->packs[$data[$k]])) {
                                 $pack = new stdClass();
                                 $pack->pack_name = $data[$k];
                                 $pack->pack_data = 'sql';
                                 $pack->pack_generator = '';
                                 $pack->pack_published = '1';
                                 $pack->pack_params = new stdClass();
                                 $pack->pack_description = '';
                                 $ret = $this->packClass->save($pack);
                                 if ($ret) {
                                     $this->packs[$data[$k]] = $ret;
                                     $this->packCounter++;
                                 } else {
                                     $this->packs[$data[$k]] = 0;
                                 }
                             }
                             $association[$v] = $data[$k];
                             $serial[] = (int) $this->packs[$data[$k]];
                             break;
                         case 'pack_quantity':
                         case 'pack_id':
                         case 'product_id':
                         case 'product_code':
                             $association[$v] = $data[$k];
                             break;
                         default:
                             $serial[] = $this->db->quote($data[$k]);
                             break;
                     }
                 }
                 if ($opt['extradata']) {
                     $serial[] = $this->db->quote(serialize($serial_extradata));
                 }
                 if ((!empty($association['product_id']) || !empty($association['product_code'])) && (!empty($association['pack_name']) || !empty($association['pack_id']))) {
                     if (!isset($association['pack_quantity']) || (int) $association['pack_quantity'] <= 0 && trim($data['pack_quantity']) != '0') {
                         $association['pack_quantity'] = 1;
                     }
                     if (!empty($association['pack_id']) && !empty($association['product_id'])) {
                         $productsAssociations['insert'][] = array('pack_id' => (int) $association['pack_id'], 'product_id' => (int) $association['product_id'], 'pack_quantity' => (int) $association['pack_quantity']);
                     } else {
                         $productsAssociations['search'][] = array('pack_id' => (int) @$association['pack_id'], 'pack_name' => @$association['pack_name'], 'product_id' => (int) @$association['product_id'], 'product_code' => @$association['product_code'], 'pack_quantity' => (int) $association['pack_quantity']);
                     }
                     if (!empty($productsAssociations['search']) && count($productsAssociations['search']) >= $this->perBatch) {
                         $this->searchPackAssociation($productsAssociations);
                     }
                     if (!empty($productsAssociations['insert']) && count($productsAssociations['insert']) >= $this->perBatch) {
                         $this->productCounter = $this->processPackAssociation($productsAssociations['insert']);
                     }
                     $serial = array();
                 }
                 if (!empty($serial)) {
                     if ($opt['add_status']) {
                         $serial[] = "'free'";
                     }
                     if ($opt['add_pack']) {
                         $serial[] = $this->pack_id;
                     }
                     $serials[] = implode(',', $serial);
                     if (count($serials) >= $this->perBatch) {
                         $this->db->setQuery($insert . implode('),(', $serials) . ')');
                         $this->db->query();
                         $this->serialCounter += count($serials);
                         $serials = array();
                     }
                 }
                 $data = array();
             }
         }
         $i++;
     }
     if (count($serials) > 0) {
         $this->db->setQuery($insert . implode('),(', $serials) . ')');
         $this->db->query();
         $this->serialCounter += count($serials);
     }
     if (count($productsAssociations['search']) > 0) {
         $this->searchPackAssociation($productsAssociations);
     }
     if (count($productsAssociations['insert']) > 0) {
         $this->productCounter = $this->processPackAssociation($productsAssociations['insert']);
     }
     $app->enqueueMessage(JText::sprintf('%d serials imported', $this->serialCounter));
     // _('%d serials imported')
     if ($this->packCounter > 0) {
         $app->enqueueMessage(JText::sprintf('%d packs imported', $this->packCounter));
         // _('%d packs imported')
     }
     if ($this->productCounter > 0) {
         $app->enqueueMessage(JText::sprintf('%d product associations imported', $this->productCounter));
         // _('%d product associations imported')
     }
 }
예제 #17
0
파일: form.php 프로젝트: q0821/esportshop
								<td><?php 
            $val = preg_replace('#[^a-z0-9]#i', '_', strtoupper($history->history_type));
            $trans = JText::_($val);
            if ($val != $trans) {
                $history->history_type = $trans;
            }
            echo $history->history_type;
            ?>
</td>
								<td><?php 
            echo $this->serialStatusType->get($history->history_new_status);
            ?>
</td>
								<td><?php 
            if (!empty($history->history_user_id)) {
                $class = hikaserial::get('shop.class.user');
                $user = $class->get($history->history_user_id);
                echo $user->username . ' / ';
            }
            echo $history->history_ip;
            ?>
</td>
								<td><?php 
            echo hikaserial::getDate($history->history_created, '%Y-%m-%d %H:%M');
            ?>
</td>
								<td><?php 
            echo $history->history_data;
            ?>
</td>
							</tr>
예제 #18
0
파일: serial.php 프로젝트: q0821/esportshop
 public function delete($elements)
 {
     if (!is_array($elements)) {
         $elements = array($elements);
     }
     $config = hikaserial::config();
     JPluginHelper::importPlugin('hikashop');
     JPluginHelper::importPlugin('hikaserial');
     $dispatcher = JDispatcher::getInstance();
     $do = true;
     $dispatcher->trigger('onBeforeSerialDelete', array(&$elements, &$do));
     if (!$do) {
         return false;
     }
     $deleted_status = 'deleted';
     $useDeletedStatus = $config->get('use_deleted_serial_status', false);
     if (!$useDeletedStatus) {
         $result = parent::delete($elements);
         if ($result) {
             $query = 'DELETE FROM ' . hikaserial::table('history') . ' WHERE history_serial_id IN (' . implode(',', $elements) . ')';
             $this->db->setQuery($query);
             $this->db->query();
             $dispatcher->trigger('onAfterSerialDelete', array(&$elements));
         }
     } else {
         $query = 'DELETE FROM ' . hikaserial::table('serial') . ' WHERE serial_id IN (' . implode(',', $elements) . ') AND serial_status = ' . $this->db->Quote($deleted_status);
         $this->db->setQuery($query);
         $this->db->query();
         $result = true;
         $query = 'SELECT serial_id FROM ' . hikaserial::table('serial') . ' WHERE serial_id IN (' . implode(',', $elements) . ')';
         $this->db->setQuery($query);
         if (!HIKASHOP_J25) {
             $updateIds = $this->db->loadResultArray();
         } else {
             $updateIds = $this->db->loadColumn();
         }
         if (!empty($updateIds)) {
             $query = 'UPDATE ' . hikaserial::table('serial') . ' SET serial_status = ' . $this->db->Quote($deleted_status) . ' WHERE serial_id IN (' . implode(',', $updateIds) . ')';
             $this->db->setQuery($query);
             $this->db->query();
             $query = 'DELETE FROM ' . hikaserial::table('history') . ' WHERE history_serial_id IN (' . implode(',', $elements) . ') AND history_serial_id NOT IN (' . implode(',', $updateIds) . ')';
             $this->db->setQuery($query);
             $this->db->query();
             if ($config->get('save_history', 1)) {
                 $historyClass = hikaserial::get('class.history');
                 $histories = array();
                 foreach ($updateIds as $id) {
                     $histories[] = $historyClass->create($id, $deleted_status, 'delete');
                 }
                 if (!empty($histories)) {
                     $historyClass->save($histories);
                 }
             }
         } else {
             $query = 'DELETE FROM ' . hikaserial::table('history') . ' WHERE history_serial_id IN (' . implode(',', $elements) . ')';
             $this->db->setQuery($query);
             $this->db->query();
         }
         $dispatcher->trigger('onAfterSerialDelete', array(&$elements));
     }
     $productClass = hikaserial::get('class.product');
     $productClass->refreshQuantities();
     return $result;
 }
			<td class="key"><label for="data[plugin][plugin_params][attach_email]"><?php 
echo JText::_('ATTACH_IN_EMAILS');
?>
</label></td>
			<td><?php 
echo JHTML::_('hikaselect.booleanlist', "data[plugin][plugin_params][attach_email]", '', @$this->element->plugin_params->attach_email);
?>
</td>
		</tr>
		<tr>
			<td class="key"><label for="data[plugin][plugin_params][packs]"><?php 
echo JText::_('SERIAL_PACKS');
?>
</label></td>
			<td><?php 
$packType = hikaserial::get('type.pack');
echo $packType->displayMultiple('data[plugin][plugin_params][packs]', @$this->element->plugin_params->packs);
?>
</td>
		</tr>
		<tr>
			<td class="key"><label for="data[plugin][plugin_params][attach_download]"><?php 
echo JText::_('ATTACH_AS_DOWNLOAD');
?>
</label></td>
			<td><?php 
echo JHTML::_('hikaselect.booleanlist', "data[plugin][plugin_params][attach_download]", '', @$this->element->plugin_params->attach_download);
if (!empty($this->element) && !empty($this->element->plugin_id)) {
    echo '<br/>#hikaserial:attachserial:' . (int) $this->element->plugin_id;
}
?>
예제 #20
0
 public function downloadHikaShopFile($file_id, $order_id = 0, $file_pos = 1, $serial = '')
 {
     $app = JFactory::getApplication();
     $fileClass = hikaserial::get('shop.class.file');
     $file = $fileClass->get($file_id);
     $file_pos = (int) $file_pos;
     if ($file_pos <= 0) {
         $file_pos = 1;
     }
     if (!$app->isAdmin() && empty($file->file_free_download)) {
         $orderClass = hikaserial::get('shop.class.order');
         $order = $orderClass->get($order_id);
         $file->order = $order;
         $file->order_id = $order_id;
         if (empty($order) || $order->order_type != 'sale') {
             $app->enqueueMessage(JText::_('WRONG_ORDER'));
             return 'wrong_order';
         }
         $shopConfig = hikaserial::config(false);
         $order_status_for_download = $shopConfig->get('order_status_for_download', 'confirmed,shipped');
         if (!in_array($order->order_status, explode(',', $order_status_for_download))) {
             $app->enqueueMessage(JText::_('BECAUSE_STATUS_NO_DOWNLOAD'));
             return 'status';
         }
         $download_time_limit = $shopConfig->get('download_time_limit', 0);
         if (!empty($download_time_limit) && $download_time_limit + $order->order_created < time()) {
             $app->enqueueMessage(JText::_('TOO_LATE_NO_DOWNLOAD'));
             return 'date';
         }
         $query = 'SELECT a.* FROM ' . hikaserial::table('shop.order_product') . ' AS a WHERE a.order_id = ' . $order_id;
         $this->db->setQuery($query);
         $order->products = $this->db->loadObjectList();
         $product_ids = array();
         foreach ($order->products as $product) {
             if ((int) $product->order_product_quantity >= $file_pos || $file_pos == 1) {
                 $product_ids[] = $product->product_id;
             }
         }
         if (empty($product_ids)) {
             $app->enqueueMessage(JText::_('INVALID_FILE_NUMBER'));
             return 'status';
         }
         $query = 'SELECT * FROM ' . hikaserial::table('shop.product') . ' WHERE product_id IN (' . implode(',', $product_ids) . ') AND product_type=\'variant\'';
         $this->db->setQuery($query);
         $products = $this->db->loadObjectList();
         if (!empty($products)) {
             foreach ($products as $product) {
                 foreach ($order->products as $item) {
                     if ($product->product_id == $item->product_id && !empty($product->product_parent_id)) {
                         $item->product_parent_id = $product->product_parent_id;
                         $product_ids[] = $product->product_parent_id;
                     }
                 }
             }
         }
         $filters = array('a.file_ref_id IN (' . implode(',', $product_ids) . ')', 'a.file_type=\'file\'', 'a.file_id=' . $file_id);
         if (substr($file->file_path, 0, 1) == '@' || substr($file->file_path, 0, 1) == '#') {
             $query = 'SELECT a.*,b.* FROM ' . hikaserial::table('shop.file') . ' AS a ' . ' LEFT JOIN ' . hikaserial::table('shop.download') . ' AS b ON b.order_id=' . $order->order_id . ' AND a.file_id = b.file_id AND b.file_pos = ' . $file_pos . ' WHERE ' . implode(' AND ', $filters);
         } else {
             $query = 'SELECT a.*, b.*, c.order_product_quantity FROM ' . hikaserial::table('shop.file') . ' AS a ' . ' LEFT JOIN ' . hikaserial::table('shop.download') . ' AS b ON b.order_id=' . $order->order_id . ' AND a.file_id = b.file_id ' . ' LEFT JOIN ' . hikaserial::table('shop.order_product') . ' AS c ON c.order_id=' . $order->order_id . ' AND c.product_id = a.file_ref_id ' . ' WHERE ' . implode(' AND ', $filters);
         }
         $this->db->setQuery($query);
         $fileData = $this->db->loadObject();
         if (!empty($fileData)) {
             if (!empty($file->file_limit) && (int) $file->file_limit != 0) {
                 $download_number_limit = (int) $file->file_limit;
             } else {
                 $download_number_limit = $shopConfig->get('download_number_limit', 0);
             }
             if ($download_number_limit < 0) {
                 $download_number_limit = 0;
             }
             if (isset($fileData->order_product_quantity) && (int) $fileData->order_product_quantity > 0) {
                 $download_number_limit *= (int) $fileData->order_product_quantity;
             }
             if (!empty($download_number_limit) && $download_number_limit <= $fileData->download_number) {
                 $app->enqueueMessage(JText::_('MAX_REACHED_NO_DOWNLOAD'));
                 return 'limit';
             }
         } else {
             $app->enqueueMessage(JText::_('FILE_NOT_FOUND'));
             return 'no_file';
         }
         $serials = $this->getOrderFileSerials($file);
         if (empty($serials)) {
             return 'no_serial';
         }
         $f = false;
         foreach ($serials as $s) {
             if ($s->serial_data == $serial) {
                 $f = true;
                 break;
             }
         }
         if (!$f) {
             return 'wrong_serial';
         }
     }
     if (!empty($file)) {
         $path = $fileClass->getPath('file');
         if (substr($file->file_path, 0, 7) == 'http://' || substr($file->file_path, 0, 1) == '@' || substr($file->file_path, 0, 1) == '#' || file_exists($path . $file->file_path) || file_exists($file->file_path)) {
             if (!$app->isAdmin()) {
                 if (!empty($file->file_free_download)) {
                     $order_id = 0;
                 }
                 $query = 'SELECT * FROM ' . hikaserial::table('shop.download') . ' WHERE file_id=' . $file->file_id . ' AND order_id=' . $order_id . ' AND file_pos=' . $file_pos;
                 $this->db->setQuery($query);
                 $download = $this->db->loadObject();
                 if (empty($download)) {
                     $query = 'INSERT INTO ' . hikaserial::table('shop.download') . ' (file_id,order_id,download_number,file_pos) VALUES(' . $file->file_id . ',' . $order_id . ',1,' . $file_pos . ');';
                 } else {
                     $query = 'UPDATE ' . hikaserial::table('shop.download') . ' SET download_number=download_number+1 WHERE file_id=' . $file->file_id . ' AND order_id=' . $order_id . ' AND file_pos=' . $file_pos;
                 }
                 $this->db->setQuery($query);
                 $this->db->query();
             }
             $file->order_id = (int) $order_id;
             $file->file_pos = $file_pos;
             $fileClass->sendFile($file, true, $path);
         }
     }
     $app->enqueueMessage(JText::_('FILE_NOT_FOUND'));
     return false;
 }
예제 #21
0
파일: serial.php 프로젝트: q0821/esportshop
 public function download()
 {
     $app = JFactory::getApplication();
     JRequest::setVar('layout', 'consume');
     $order_id = hikaserial::getCID('order_id');
     $file_id = JRequest::getInt('file_id');
     $file_pos = JRequest::getInt('file_pos', 1);
     $serial = JRequest::getString('serial', '');
     if (empty($order_id)) {
         return parent::display();
     }
     $downloadClass = hikaserial::get('class.download');
     $ret = $downloadClass->downloadHikaShopFile($file_id, $order_id, $file_pos, $serial);
     if ($ret !== true) {
         switch ($ret) {
             case 'login':
                 break;
             case 'no_order':
                 break;
             default:
                 break;
         }
     }
     return parent::display();
 }
예제 #22
0
파일: pack.php 프로젝트: q0821/esportshop
 public function checkQuantity(&$pack)
 {
     if (empty($pack->pack_params->stock_level_notify) || $pack->pack_params->stock_level_notify <= 0) {
         return true;
     }
     $status = 'free';
     $query = 'SELECT count(*) as qty FROM ' . hikaserial::table('serial') . ' AS a WHERE a.serial_status = ' . $this->db->Quote($status) . ' AND a.serial_pack_id=' . $pack->pack_id;
     $this->db->setQuery($query);
     $pack->current_quantity = $this->db->loadResult();
     if (!empty($pack->pack_params->stock_level_notify) && (int) $pack->current_quantity <= (int) $pack->pack_params->stock_level_notify) {
         $mailClass = hikaserial::get('class.mail');
         $mail = $mailClass->load('pack_quantity_low', $pack);
         if (!empty($mail)) {
             $mail->subject = JText::sprintf($mail->subject, HIKASERIAL_LIVE);
             $shopConfig =& hikaserial::config(false);
             if (!empty($pack->email)) {
                 $mail->dst_email = $pack->email;
             } else {
                 $mail->dst_email = $shopConfig->get('from_email');
             }
             if (!empty($pack->name)) {
                 $mail->dst_name = $pack->name;
             } else {
                 $mail->dst_name = $shopConfig->get('from_name');
             }
             $mailClass->sendMail($mail);
         }
     }
     unset($pack->current_quantity);
     return true;
 }
예제 #23
0
 public function onAfterCheckoutStep($controllerName, &$go_back, $original_go_back, &$controller)
 {
     if ($controllerName == 'plg.serial.coupon') {
         if (!$this->init()) {
             return;
         }
         $checkoutClass = hikaserial::get('class.checkout');
         $checkoutClass->afterCheckoutStep($controllerName, $go_back, $original_go_back, $controller);
     }
 }
예제 #24
0
 public function store()
 {
     $this->plugin = JRequest::getCmd('name', '');
     $this->plugin_type = JRequest::getCmd('plugin_type', 'generator');
     if (empty($this->plugin) || !in_array($this->plugin_type, array('generator', 'consumer', 'plugin'))) {
         return false;
     }
     $data = hikaserial::import('hikaserial', $this->plugin);
     $element = new stdClass();
     $id = hikaserial::getCID($this->plugin_type . '_id');
     $formData = JRequest::getVar('data', array(), '', 'array');
     $params_name = $this->plugin_type . '_params';
     if (!empty($formData[$this->plugin_type])) {
         $element = new stdClass();
         $plugin_id = $this->plugin_type . '_id';
         $element->{$plugin_id} = $id;
         foreach ($formData[$this->plugin_type] as $column => $value) {
             hikaserial::secureField($column);
             if (is_array($value)) {
                 if ($column == $params_name) {
                     $element->{$params_name} = new stdClass();
                     foreach ($formData[$this->plugin_type][$column] as $key => $val) {
                         hikaserial::secureField($key);
                         if (!is_array($val)) {
                             $element->{$params_name}->{$key} = strip_tags($val);
                         } else {
                             $element->{$params_name}->{$key} = $val;
                         }
                     }
                 }
             } else {
                 $element->{$column} = strip_tags($value);
             }
         }
         $plugin_description = $this->plugin_type . '_description';
         $plugin_description_data = JRequest::getVar($plugin_description, '', '', 'string', JREQUEST_ALLOWRAW);
         $element->{$plugin_description} = $plugin_description_data;
     }
     $function = 'on' . ucfirst($this->plugin_type) . 'ConfigurationSave';
     if (method_exists($data, $function)) {
         $data->{$function}($element);
     }
     if (!empty($element)) {
         $pluginClass = hikaserial::get('class.' . $this->plugin_type);
         if (isset($element->{$params_name})) {
             $element->{$params_name} = serialize($element->{$params_name});
         }
         $status = $pluginClass->save($element);
         if (!$status) {
             JRequest::setVar('fail', $element);
         } else {
             $app = JFactory::getApplication();
             $app->enqueueMessage(JText::_('HIKASHOP_SUCC_SAVED'), 'message');
             if (empty($id)) {
                 JRequest::setVar($this->plugin_type . '_id', $status);
             }
         }
     }
 }
예제 #25
0
파일: toggle.php 프로젝트: q0821/esportshop
 public function delete()
 {
     list($value1, $value2) = explode('-', JRequest::getCmd('value'));
     $table = JRequest::getVar('table', '', '', 'word');
     $controller = hikaserial::get('controller.' . $table);
     if (empty($controller)) {
         echo 'No controller';
         exit;
     }
     if (!$controller->authorize('delete')) {
         echo 'Forbidden';
         exit;
     }
     $function = 'delete' . ucfirst($table);
     if (method_exists($this, $function)) {
         $this->{$function}($value1, $value2);
         exit;
     }
     $destClass = hikaserial::get('class.' . $table);
     $deleteToggle = $destClass->toggleDelete();
     list($key1, $key2) = reset($deleteToggle);
     $table = key($deleteToggle);
     if (empty($key1) || empty($key2) || empty($value1) || empty($value2)) {
         echo 'No value';
         exit;
     }
     $db = JFactory::getDBO();
     $db->setQuery('DELETE FROM ' . hikaserial::table($table) . ' WHERE ' . $key1 . ' = ' . $db->Quote($value1) . ' AND ' . $key2 . ' = ' . $db->Quote($value2));
     $db->query();
     exit;
 }
예제 #26
0
 public function configurationLine($id = 0, $conf = null)
 {
     if (empty($this->discountClass)) {
         $this->discountClass = hikaserial::get('shop.class.discount');
     }
     switch ($id) {
         case 1:
             $d = null;
             if (!empty($conf->generator_params->discount_id)) {
                 $d = $this->discountClass->get($conf->generator_params->discount_id);
             }
             if (empty($d)) {
                 return '<img src="' . HIKASERIAL_IMAGES . 'icon-16/unpublish.png" alt="' . JText::_('ERROR') . '"/>';
             }
             return '<a href="' . hikaserial::completeLink('shop.discount&task=edit&cid=' . $conf->generator_params->discount_id) . '">' . $d->discount_code . '</a>';
         case 2:
             if (!empty($conf->generator_params->discount_percent)) {
                 return $conf->generator_params->discount_percent . '%';
             }
             return '';
         case 3:
             if (empty($conf->generator_params->format)) {
                 return $this->serial_default_format;
             }
             return $conf->generator_params->format;
         case 4:
             if (empty($conf->generator_params->size)) {
                 return 12;
             }
             return $conf->generator_params->size;
     }
     return null;
 }
예제 #27
0
 private function givePoints($user_id, $points, $data = null, $mode = null)
 {
     if ($points === 0) {
         return true;
     }
     $points_mode = @$this->plugin_params->mode;
     if ($mode !== null) {
         $points_mode = $mode;
     }
     if ($points_mode == 'aup') {
         if ($this->getAUP(true)) {
             $aupid = AlphaUserPointsHelper::getAnyUserReferreID($user_id);
             AlphaUserPointsHelper::newpoints('plgaup_orderValidation', $aupid, '', $data, $points);
             return true;
         }
         return false;
     }
     if ($points_mode == 'hks') {
         if (hikaserial::initShop()) {
             $app = JFactory::getApplication();
             $ret = true;
             $userClass = hikaserial::get('shop.class.user');
             $oldUser = $userClass->get($user_id, 'cms');
             if (!isset($oldUser->user_points) && !in_array('user_points', array_keys(get_object_vars($oldUser)))) {
                 return false;
             }
             if (empty($oldUser->user_points)) {
                 $oldUser->user_points = 0;
             }
             $user = new stdClass();
             $user->user_id = $oldUser->user_id;
             $user->user_points = (int) $oldUser->user_points + $points;
             if ($user->user_points < 0) {
                 $app->enqueueMessage(JText::_('CANT_HAVE_NEGATIVE_POINTS'), 'error');
                 $points = -$oldUser->user_points;
                 $user->user_points = 0;
                 $ret = false;
             } else {
                 $app->enqueueMessage(JText::sprintf('HIKAPOINTS_EARN_X_POINTS', $points), 'success');
             }
             $userClass->save($user);
             return $ret;
         }
         return false;
     }
     if ($points_mode == 'hkp') {
         if (hikaserial::initPoints()) {
             return hikapoints::trigger($user_id, 'hikaserial_points_consumer', $points);
         }
         return false;
     }
     if (substr($points_mode, 0, 4) == 'hkp.') {
         if (hikaserial::initPoints()) {
             $category_id = (int) substr($points_mode, 4);
             $pointsClass = hikapoints::get('class.points');
             return $pointsClass->add($user_id, $category_id, $points);
         }
         return false;
     }
     return false;
 }
예제 #28
0
 private function generateImageBarCode($img, $d)
 {
     $format = 'ean13';
     $width = 1;
     $showText = true;
     if (empty($d['size'])) {
         $d['size'] = 40;
     }
     $BarCode = hikaserial::get('inc.barcode', 'ean13', $d['size'], $width, $showText);
     $barcode_image = $BarCode->getImage($d['text']);
     if (empty($barcode_image)) {
         return null;
     }
     $imgH = imagesy($barcode_image);
     $imgW = imagesx($barcode_image);
     imagesavealpha($img, false);
     imagealphablending($img, true);
     imagecopyresized($img, $barcode_image, $d['x'], $d['y'], 0, 0, $imgW, $imgH, $imgW, $imgH);
     imagedestroy($barcode_image);
     imagealphablending($img, false);
     imagesavealpha($img, true);
     return null;
 }
예제 #29
0
 private function sendCustomEmail($serials, &$order)
 {
     $send_serials = array();
     $custom_field_value = '';
     list($type, $custom_field) = explode('.', $this->plugin_params->custom_field, 2);
     if (!in_array($type, array('order', 'item'))) {
         return false;
     }
     if ($type == 'order') {
         foreach ($serials as $k => $serial) {
             if (is_string($this->plugin_params->packs) && strpos(',' . $this->plugin_params->packs . ',', ',' . $serial->serial_pack_id . ',') === false) {
                 continue;
             }
             if (is_array($this->plugin_params->packs) && !in_array($serial->serial_pack_id, $this->plugin_params->packs)) {
                 continue;
             }
             $send_serials[] = $serial;
         }
         if (!empty($order->{$custom_field})) {
             $custom_field_value = $order->{$custom_field};
         }
     }
     if ($type == 'item') {
         $send_serials[] = $serials;
         foreach ($order->products as $k => $product) {
             if ((int) $product->order_product_id == (int) $serials->serial_order_product_id) {
                 if (!empty($product->{$custom_field})) {
                     $custom_field_value = $product->{$custom_field};
                 }
                 break;
             }
         }
     }
     $custom_field_value = trim($custom_field_value);
     if (empty($custom_field_value)) {
         return false;
     }
     if (!preg_match('/^([a-z0-9_\'&\\.\\-\\+=])+\\@(([a-z0-9\\-])+\\.)+([a-z0-9]{2,10})+$/i', $custom_field_value)) {
         return false;
     }
     $data = new stdClass();
     $data->serials = $send_serials;
     $data->dest_email = $custom_field_value;
     $data->order =& $order;
     $mailClass = hikaserial::get('class.mail');
     $mail = $mailClass->load('mailtocustomfield', $data);
     if (empty($mail)) {
         return false;
     }
     if (!empty($this->plugin_params->call_attachserial)) {
         $attachserialPlugin = hikaserial::import('hikaserial', 'attachserial');
         $attachserialPlugin->onBeforeSerialMailSend($mail, $mail->mailer, $send_serials, $order);
     }
     $mail->subject = JText::sprintf($mail->subject, HIKASERIAL_LIVE);
     $shopConfig =& hikaserial::config(false);
     if (empty($mail->from_email)) {
         $mail->from_email = $shopConfig->get('from_email');
         $mail->from_name = $shopConfig->get('from_name');
     }
     if (empty($mail->reply_email)) {
         $mail->reply_email = $shopConfig->get('from_email');
         $mail->reply_name = $shopConfig->get('from_name');
     }
     if (empty($mail->dst_email)) {
         $mail->dst_email = $custom_field_value;
     }
     if (empty($mail->dst_name)) {
         $mail->dst_name = $custom_field_value;
     }
     $mailClass->sendMail($mail);
     return true;
 }
예제 #30
0
 public function select()
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $config = hikaserial::config();
     $this->assignRef('config', $config);
     $toggleClass = hikaserial::get('helper.toggle');
     $this->assignRef('toggleClass', $toggleClass);
     $packGeneratorType = hikaserial::get('type.pack_generator');
     $this->assignRef('packGeneratorType', $packGeneratorType);
     $serialStatusType = hikaserial::get('type.serial_status');
     $this->assignRef('serialStatusType', $serialStatusType);
     $filterType = $app->getUserStateFromRequest($this->paramBase . ".filter_type", 'filter_type', 0, 'int');
     $singleSelection = JRequest::getVar('single', false);
     $confirm = JRequest::getVar('confirm', true);
     $cfg = array('table' => 'pack', 'main_key' => 'pack_id', 'order_sql_value' => 'a.pack_id');
     $elemStruct = array('pack_name', 'pack_data', 'pack_generator');
     $manage = true;
     $this->assignRef('manage', $manage);
     $pageInfo = new stdClass();
     $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string');
     $pageInfo->filter = new stdClass();
     $pageInfo->filter->order = new stdClass();
     $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.pack_id', 'cmd');
     $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word');
     $pageInfo->limit = new stdClass();
     $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int');
     if (empty($pageInfo->limit->value)) {
         $pageInfo->limit->value = 500;
     }
     $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int');
     $pageInfo->filter->filter_partner = $app->getUserStateFromRequest($this->paramBase . ".filter_partner", 'filter_partner', '', 'int');
     $pageInfo->search = JString::strtolower($app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string'));
     $this->assignRef('pageInfo', $pageInfo);
     $filters = array();
     $searchMap = array('a.pack_id', 'a.pack_name', 'a.pack_data', 'a.pack_generator');
     if (!empty($pageInfo->search)) {
         $searchVal = '\'%' . $db->getEscaped($pageInfo->search, true) . '%\'';
         $filters[] = '(' . implode(' LIKE ' . $searchVal . ' OR ', $searchMap) . ' LIKE ' . $searchVal . ')';
     }
     if (!empty($filters)) {
         $filters = ' WHERE ' . implode(' AND ', $filters);
     } else {
         $filters = '';
     }
     $order = '';
     if (!empty($pageInfo->filter->order->value)) {
         $order = ' ORDER BY ' . $pageInfo->filter->order->value . ' ' . $pageInfo->filter->order->dir;
     }
     $query = ' FROM ' . hikaserial::table('pack') . ' AS a ' . $filters . $order;
     $db->setQuery('SELECT * ' . $query, (int) $pageInfo->limit->start, (int) $pageInfo->limit->value);
     $rows = $db->loadObjectList();
     if (!empty($pageInfo->search)) {
         $rows = hikaserial::search($pageInfo->search, $rows, 'pack_id');
     }
     $this->assignRef('rows', $rows);
     $db->setQuery('SELECT COUNT(*)' . $query);
     $pageInfo->elements = new stdClass();
     $pageInfo->elements->total = $db->loadResult();
     $pageInfo->elements->page = count($rows);
     $query = 'SELECT serial_pack_id, serial_status, COUNT(serial_id) AS counter FROM ' . hikaserial::table('serial') . ' GROUP BY serial_pack_id, serial_status ORDER BY serial_pack_id, serial_status';
     $db->setQuery($query);
     $dbcounters = $db->loadObjectList();
     $counters = array();
     foreach ($dbcounters as $counter) {
         if (!isset($counters[$counter->serial_pack_id])) {
             $counters[$counter->serial_pack_id] = array();
         }
         $counters[$counter->serial_pack_id][$counter->serial_status] = $counter->counter;
     }
     unset($dbcounters);
     $this->assignRef('counters', $counters);
     jimport('joomla.html.pagination');
     if ($pageInfo->limit->value == 500) {
         $pageInfo->limit->value = 100;
     }
     $pagination = new JPagination($pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value);
     $this->assignRef('pagination', $pagination);
     $doOrdering = !$filterType;
     $this->assignRef('doOrdering', $doOrdering);
     if ($doOrdering) {
         $ordering = new stdClass();
         $ordering->ordering = false;
         $ordering->orderUp = 'orderup';
         $ordering->orderDown = 'orderdown';
         $ordering->reverse = false;
         if ($pageInfo->filter->order->value == 'a.ordering') {
             $ordering->ordering = true;
             if ($pageInfo->filter->order->dir == 'desc') {
                 $ordering->orderUp = 'orderdown';
                 $ordering->orderDown = 'orderup';
                 $ordering->reverse = true;
             }
         }
         $this->assignRef('ordering', $ordering);
     }
     $this->assignRef('singleSelection', $singleSelection);
     $this->assignRef('confirm', $confirm);
     $this->assignRef('elemStruct', $elemStruct);
     $this->assignRef('pageInfo', $pageInfo);
 }