Пример #1
0
 /**
  * Update or delete manufacturer row
  * Checks is recieved url has duplicate before save.
  * If it has - throws an exception
  *
  * @param array $data
  * <pre>
  * Array(
  * 	id, name, key_word,
  *  description => array(
  *  	langId => array()
  *  )
  * )
  * </pre>
  * @return int Manufacturer id
  * @throws Axis_Exception
  */
 public function save(array $data)
 {
     $row = $this->getRow($data);
     //$row->setUrl();
     //before save
     $url = trim($data['key_word']);
     if (empty($url)) {
         $url = $data['name'];
     }
     //        $url = preg_replace('/[^a-zA-Z0-9]/', '-', $url);
     if (Axis::single('catalog/hurl')->hasDuplicate($url, array_keys(Axis_Collect_Site::collect()), (int) $row->id)) {
         throw new Axis_Exception(Axis::translate('core')->__('Column %s should be unique', 'url'));
     }
     $row->image = empty($row->image) ? '' : '/' . trim($row->image, '/');
     //end before save
     $row->save();
     //after save
     //add relation site
     $model = Axis::model('catalog/hurl');
     foreach (Axis_Collect_Site::collect() as $siteId => $siteName) {
         $model->save(array('site_id' => $siteId, 'key_id' => $row->id, 'key_type' => 'm', 'key_word' => $url));
     }
     //end after save
     return $row;
 }
Пример #2
0
 /**
  *
  * @static
  * @return array
  */
 public static function collect()
 {
     if (null === self::$_collection) {
         self::$_collection = Axis::single('core/site')->select(array('id', 'name'))->fetchPairs();
     }
     return self::$_collection;
 }
Пример #3
0
 public function indexAction()
 {
     $this->view->pageTitle = Axis::translate('sitemap')->__('Sitemap');
     $this->view->sitesList = Axis::single('core/site')->fetchAll()->toArray();
     $this->view->sites = Axis_Collect_Site::collect();
     $this->view->crawlers = array_values(Axis::model('sitemap/crawler')->toArray());
     $this->render();
 }
Пример #4
0
 public function __construct($options = null)
 {
     parent::__construct($options);
     $db = Axis::db();
     $this->setAttrib('id', 'form-customer');
     $this->addElement('select', 'site_id', array('label' => 'Site'));
     $this->getElement('site_id')->setMultiOptions(Axis_Collect_Site::collect());
     $this->addElement('text', 'email', array('required' => true, 'label' => 'Email'));
     $this->addElement('password', 'password', array('label' => 'Password'));
     $this->addElement('text', 'firstname', array('required' => true, 'label' => 'Firstname', 'class' => 'input-text required'));
     $this->addElement('text', 'lastname', array('required' => true, 'label' => 'Lastname', 'class' => 'input-text required'));
     $this->addElement('checkbox', 'is_active', array('label' => 'Active'));
     $this->addDisplayGroup(array('site_id', 'email', 'password', 'firstname', 'lastname', 'is_active'), 'login', array('legend' => 'General information'));
     $rows = Axis::single('account/customer_field')->getFields();
     $groupsFields = array();
     foreach ($rows as $row) {
         $field = 'field_' . $row['id'];
         $this->addElement($row['field_type'], $field, array('required' => (bool) $row['required'], 'label' => $row['field_label']));
         if ($row['required']) {
             $this->getElement($field)->addValidator('NotEmpty');
         }
         if (!empty($row['validator'])) {
             $this->getElement($field)->addValidator($row['validator']);
             if ($row['validator'] == 'Date') {
                 $this->getElement($field)->setAttrib('class', 'date-picker');
             }
         }
         if (isset($row['customer_valueset_id'])) {
             $values = Axis::single('account/Customer_ValueSet_Value')->getCustomValues($row['customer_valueset_id'], Axis_Locale::getLanguageId());
             $this->getElement($field)->setMultiOptions($values);
         }
         $groupsFields[$row['customer_field_group_id']][$row['id']] = $field;
     }
     /* add field groups */
     if (count($groupsFields)) {
         $groups = Axis::single('account/customer_fieldGroup')->getCustomGroups(array_keys($groupsFields), Axis_Locale::getLanguageId());
         foreach ($groups as $row) {
             $this->addDisplayGroup(array_values($groupsFields[$row['id']]), 'group_' . $row['id'], array('legend' => $row['group_label']));
             $this->getDisplayGroup('group_' . $row['id'])->setDisableTranslator(true);
         }
     }
 }
Пример #5
0
 private function _initForm()
 {
     $this->view->sites = Axis_Collect_Site::collect();
     $this->view->customerGroups = Axis_Collect_CustomerGroup::collect();
     $this->view->manufactures = Axis_Collect_Manufacturer::collect();
     $languageId = Axis_Locale::getLanguageId();
     $this->view->categoryTrees = Axis::single('catalog/category')->select('*')->addName($languageId)->addKeyWord()->order('cc.lft')->fetchAllAndSortByColumn('site_id');
     $select = Axis::model('catalog/product_option_value')->select('*')->joinLeft('catalog_product_option_value_text', 'cpov.id = cpovt.option_value_id', 'name')->where('cpovt.language_id = ?', $languageId);
     $valuesetValues = array();
     foreach ($select->fetchAll() as $_row) {
         $valuesetValues[$_row['valueset_id']][$_row['id']] = $_row['name'];
     }
     $select = Axis::single('catalog/product_option')->select('*')->addNameAndDescription($languageId);
     $attributes = array();
     foreach ($select->fetchAll() as $_option) {
         if (isset($valuesetValues[$_option['valueset_id']])) {
             $attributes[$_option['id']] = array('name' => $_option['name'], 'option' => $valuesetValues[$_option['valueset_id']]);
         }
     }
     $this->view->attributes = $attributes;
 }
Пример #6
0
 public function indexAction()
 {
     $this->view->pageTitle = Axis::translate('Axis_Core')->__('Home');
     $siteId = $this->_getParam('siteId', 0);
     $this->view->siteId = $siteId;
     $date = Axis_Date::now()->setHour(0)->setMinute(0)->setSecond(0)->toPhpString('Y-m-d H:i:s');
     $currency = Axis::single('locale/currency')->getCurrency(Axis::config()->locale->main->currency);
     $modelOrder = Axis::single('sales/order');
     $selectOrderTotal = $modelOrder->select('SUM(order_total)')->addSiteFilter($siteId);
     $orderTotal = (double) $selectOrderTotal->fetchOne();
     $this->view->orderTotal = $currency->toCurrency($orderTotal);
     $count = $modelOrder->select()->addSiteFilter($siteId)->count();
     $this->view->orderAverage = $currency->toCurrency($count ? $orderTotal / $count : 0);
     $this->view->orderTotalToday = $currency->toCurrency((double) $selectOrderTotal->where('date_purchased_on > ? ', $date)->fetchOne());
     $this->view->orderCountToday = $modelOrder->select()->addSiteFilter($siteId)->where('date_purchased_on > ?', $date)->count('DISTINCT customer_email');
     $this->view->customerCount = Axis::single('account/customer')->select()->addSiteFilter($siteId)->count();
     $this->view->visitorToday = Axis::single('log/url')->select()->where('visit_at > ?', $date)->addSiteFilter($siteId)->count('DISTINCT visitor_id');
     $this->view->pageviewsToday = Axis::single('log/url')->select()->where('visit_at > ? ', $date)->addSiteFilter($siteId)->count();
     $this->view->sites = Axis_Collect_Site::collect();
     $this->view->date = $date;
     $this->render();
 }
Пример #7
0
 public function listAction()
 {
     function getChilds($node, $root)
     {
         $data = array();
         $select = Axis::model('cms/category')->select('*');
         if ($root) {
             $select->where('cc.site_id = ?', $node)->where('cc.parent_id is NULL');
         } else {
             $select->where('cc.parent_id = ?', $node);
         }
         //get categories
         foreach ($select->fetchAssoc() as $_category) {
             $data[] = array('leaf' => false, 'id' => $_category['id'], 'site_id' => $_category['site_id'], 'text' => $_category['name'], 'iconCls' => 'icon-folder', 'expanded' => true, 'cls' => $_category['is_active'] ? '' : 'disabledNode', 'children' => getChilds($_category['id'], false));
         }
         return $data;
     }
     $data = array();
     foreach (Axis_Collect_Site::collect() as $siteId => $siteName) {
         $data[] = array('leaf' => false, 'id' => "_" . $siteId, 'site_id' => $siteId, 'text' => $siteName, 'checked' => 'undefined', 'iconCls' => 'icon-folder', 'cls' => 'root-node', 'expanded' => true, 'children' => getChilds($siteId, true));
     }
     return $this->_helper->json->sendRaw($data);
 }
Пример #8
0
 /**
  * Get info about discount + discount rules (condition)
  *
  * @return array
  */
 public function getCustomInfo()
 {
     $array = $this->toArray();
     $rules = Axis::single('discount/eav')->getRulesByDiscountId($this->id);
     if (isset($rules['conditions'])) {
         $array['conditions'] = $rules['conditions'];
     }
     if (isset($rules['category'])) {
         $array['category'] = $rules['category'];
     }
     if (isset($rules['productId'])) {
         $array['productId'] = $rules['productId'];
     }
     if (isset($rules['manufacture'])) {
         $array['manufacture'] = array_intersect($rules['manufacture'], array_keys(Axis_Collect_Manufacturer::collect()));
     }
     if (isset($rules['site'])) {
         $array['site_ids'] = array_intersect($rules['site'], array_keys(Axis_Collect_Site::collect()));
     }
     if (isset($rules['group'])) {
         $array['customer_group_ids'] = array_intersect($rules['group'], array_keys(Axis_Collect_CustomerGroup::collect()));
     }
     if (isset($rules['special'])) {
         $array['special'] = current($rules['special']);
     }
     if (isset($rules['optionId'])) {
         foreach ($rules['optionId'] as $optionId) {
             if (!isset($rules['option[' . $optionId . ']'])) {
                 continue;
             }
             foreach ($rules['option[' . $optionId . ']'] as $optionValueId) {
                 $array['attributes'][] = array('optionId' => $optionId, 'optionValueId' => $optionValueId);
             }
         }
     }
     return $array;
 }
 public function indexAction()
 {
     $this->view->pageTitle = Axis::translate('admin')->__('Configuration');
     $this->view->sites = Axis_Collect_Site::collect();
     $this->render();
 }
Пример #10
0
 public function getPageTreeAction()
 {
     function getChilds($node, $root)
     {
         $data = array();
         $select = Axis::single('cms/category')->select('*');
         if ($root) {
             $select->where('cc.site_id = ?', $node)->where('cc.parent_id is NULL');
         } else {
             $select->where('cc.parent_id = ?', $node);
         }
         //get categories
         foreach ($select->fetchAssoc() as $_category) {
             $data[] = array('leaf' => false, 'id' => "_" . $_category['id'], 'siteId' => 'null', 'catId' => $_category['id'], 'pageId' => 'null', 'text' => $_category['name'], 'iconCls' => 'icon-folder', 'expanded' => true, 'cls' => $_category['is_active'] ? '' : 'disabledNode', 'children' => getChilds($_category['id'], false));
         }
         //get pages
         if (!$root) {
             $pages = Axis::single('cms/page')->select(array('name', 'id', 'is_active'))->join('cms_page_category', 'cp.id = cpc.cms_page_id', 'cms_category_id')->where('cpc.cms_category_id = ?', $node)->fetchAll();
             foreach ($pages as $page) {
                 $data[] = array('leaf' => true, 'siteId' => 'null', 'catId' => 'null', 'pageId' => $page['id'], 'text' => $page['name'], 'iconCls' => 'icon-page', 'cls' => $page['is_active'] ? '' : 'disabledNode');
             }
         }
         return $data;
     }
     //load pages that is not linked with category
     function getLostPage()
     {
         $result = array();
         $pages = Axis::single('cms/page')->select(array('name', 'id', 'is_active'))->addFilterByUncategorized()->fetchAll();
         foreach ($pages as $page) {
             $result[] = array('leaf' => true, 'siteId' => 'null', 'catId' => 'null', 'pageId' => $page['id'], 'text' => $page['name'], 'iconCls' => 'icon-page', 'cls' => $page['is_active'] ? '' : 'disabledNode');
         }
         return $result;
     }
     $data = array();
     //custom root node (uncategorized)
     $data[] = array('leaf' => false, 'id' => 'lost', 'siteId' => 'null', 'catId' => 'null', 'pageId' => 'null', 'text' => Axis::translate('cms')->__('Uncategorized Pages'), 'iconCls' => 'icon-bin', 'expanded' => true, 'children' => getLostPage());
     //autogenerated nodes
     foreach (Axis_Collect_Site::collect() as $siteId => $siteName) {
         $data[] = array('leaf' => false, 'id' => "__" . $siteId, 'siteId' => $siteId, 'catId' => 'null', 'pageId' => 'null', 'text' => $siteName, 'iconCls' => 'icon-folder', 'expanded' => true, 'children' => getChilds($siteId, true));
     }
     $this->_helper->json->sendRaw($data);
 }
Пример #11
0
 public function loadAction()
 {
     $orderId = $this->_getParam('orderId');
     $this->view->order = $order = Axis::single('sales/order')->find($orderId)->current();
     $products = $order->getProducts();
     foreach ($products as &$product) {
         $product['price'] = $product['price'] * $order->currency_rate;
         $product['final_price'] = $product['final_price'] * $order->currency_rate;
         $product['tax_rate'] = $product['tax'] * 100 / $product['final_price'];
     }
     $data['products'] = array_values($products);
     $totals = $order->getTotals();
     foreach ($totals as &$total) {
         $total['value'] = $total['value'] * $order->currency_rate;
     }
     $this->view->totals = $data['totals'] = $totals;
     $data['history'] = $order->getStatusHistory();
     $customer = Axis::single('account/customer')->find($order->customer_id)->current();
     if ($customer instanceof Axis_Db_Table_Row) {
         $data['customer'] = $customer->toArray();
         unset($data['customer']['password']);
         //paranoid
         $data['customer']['group'] = Axis::single('account/customer_group')->getName($customer->group_id);
     } else {
         $data['customer'] = array('firstname' => '-//-', 'lastname' => '-//-', 'group' => 'Guest', 'group_id' => Axis_Account_Model_Customer_Group::GROUP_GUEST_ID, 'email' => $order->customer_email);
     }
     $delivery = $order->getDelivery();
     $data['address']['delivery'] = $delivery->toFlatArray();
     $billing = $order->getBilling();
     $data['address']['billing'] = $billing->toFlatArray();
     $this->view->cc = Axis::single('sales/order_creditcard')->find($order->id)->current();
     $form = $this->view->paymentForm($order->payment_method_code, 'view');
     $data['payment'] = array('name' => $order->payment_method, 'code' => $order->payment_method_code, 'form' => $form);
     $data['shipping'] = array('name' => $order->shipping_method, 'code' => $order->shipping_method_code);
     $order = $order->toArray();
     $order['status_name'] = Axis_Collect_OrderStatusText::getName($order['order_status_id']);
     $order['site_name'] = Axis_Collect_Site::getName($order['site_id']);
     // convert price with rates that was available
     // during order was created (not current rates)
     $order['order_total'] = $order['order_total'] * $order['currency_rate'];
     $data['order'] = $order;
     return $this->_helper->json->setData($data)->sendSuccess();
 }
Пример #12
0
 /**
  *
  * @return Zend_Db_Table_Rowset
  *
  * @param int $minId[required] exclusive bound of product_id
  * @param int $limit[optional] max count of rowset
  * @param array $filters[optional] example:
  *     array(
  *         'status' => 0 - disabled, 1 - enabled, 2 - all,
  *         'stock' => 0 - out of stock, 1 - in stock, 2 - all,
  *         'name' => 'Cellphone',
  *         'sku' => '10002',
  *         'site' => '1,2' site ids, 'all' - all sites
  *     )
  */
 public function getProductSet($minId, $limit = 1, array $filters = null)
 {
     if (!is_numeric($minId)) {
         return array();
     }
     $select = Axis::single('catalog/product')->select()->setIntegrityCheck(false)->distinct()->from('catalog_product')->where('cp.id > ' . $minId)->order('cp.id ASC')->limit($limit);
     if (null !== $filters) {
         if (isset($filters['status']) && $filters['status'] != 2 && is_numeric($filters['status'])) {
             $select->where('cp.is_active = ' . intval($filters['status']));
         }
         if (isset($filters['stock']) && $filters['stock'] != 2 && is_numeric($filters['stock'])) {
             $select->join('catalog_product_stock', 'cp.id = cps.product_id')->where('cps.in_stock = ?', intval($filters['stock']));
         }
         if (isset($filters['site']) && $filters['site'] != 'all' && trim($filters['site'], ' ,') != '') {
             $site_count = count(Axis_Collect_Site::collect());
             $filter_sites = explode(',', trim($filters['site'], ' ,'));
             $filters_site_count = count($filter_sites);
             if ($site_count != $filters_site_count) {
                 $select->join('catalog_product_category', 'cp.id = cpc.product_id')->join('catalog_category', 'cpc.category_id = cc.id')->where('cc.site_id IN (?)', $filter_sites);
             }
         }
         if (isset($filters['name']) && $filters['name'] != '') {
             $select->join('catalog_product_description', 'cp.id = cpd.product_id')->where('cpd.name LIKE ?', $filters['name'] . '%');
         }
         if (isset($filters['sku']) && $filters['sku'] != '') {
             $select->where('cp.sku LIKE ?', $filters['sku'] . '%');
         }
         /* price filter */
         if (isset($filters['price_from']) && $filters['price_from'] != '' && is_numeric($filters['price_from'])) {
             $select->where('cp.price >= ?', $filters['price_from']);
         }
         if (isset($filters['price_to']) && $filters['price_to'] != '' && is_numeric($filters['price_to'])) {
             $select->where('cp.price <= ?', $filters['price_to']);
         }
         /* qty filter */
         if (isset($filters['qty_from']) && $filters['qty_from'] != '' && is_numeric($filters['qty_from'])) {
             $select->where('cp.quantity >= ?', $filters['qty_from']);
         }
         if (isset($filters['qty_to']) && $filters['qty_to'] != '' && is_numeric($filters['qty_to'])) {
             $select->where('cp.quantity <= ?', $filters['qty_to']);
         }
     }
     return Axis::single('catalog/product')->fetchAll($select);
 }