public function init()
 {
     // Set the custom decorator
     $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator');
     $translate = Shineisp_Registry::get('Zend_Translate');
     $this->addElement('text', 'name', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Feature Name'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('multiselect', 'attributes', array('label' => $translate->_('Attributes'), 'decorators' => array('Bootstrap'), 'title' => $translate->_('Select ...'), 'data-header' => $translate->_('Select the product attributes...'), 'data-container' => 'body', 'data-selected-text-format' => 'count > 2', 'data-size' => 'auto', 'data-live-search' => 'true', 'class' => 'multiselect show-tick col-md-4'));
     $this->getElement('attributes')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(ProductsAttributes::getAttributes());
     $this->addElement('checkbox', 'isrecurring', array('label' => $translate->_('Is Recurring'), 'decorators' => array('Bootstrap')));
     $this->addElement('checkbox', 'iscomparable', array('label' => $translate->_('Is Comparable'), 'decorators' => array('Bootstrap')));
     $this->addElement('hidden', 'group_id');
 }
Example #2
0
 public function listAction()
 {
     $ns = new Zend_Session_Namespace();
     $products = array();
     // get the category uri
     $uri = $this->getRequest()->getParam('q');
     if (!empty($uri)) {
         // Save the path of the user
         $ns->lastcategory = $uri;
         // Get the category information
         $category = $this->categories->getAllInfobyURI($uri);
         if (!empty($category[0])) {
             $this->view->category = $category[0];
             // Get the subcategories
             $this->view->subcategory = ProductsCategories::getbyParentId($category[0]['category_id'], 1, true);
             // Set the Metatag information
             $this->view->headTitle()->prepend($category[0]['name']);
             if (!empty($category[0]['keywords'])) {
                 $this->view->headMeta()->setName('keywords', $category[0]['keywords']);
             }
             if (!empty($category[0]['description'])) {
                 $this->view->headMeta()->setName('description', $category[0]['description'] ? Shineisp_Commons_Utilities::truncate(strip_tags($category[0]['description'])) : '-');
             }
             $this->view->headertitle = $category[0]['name'];
             // Get the products information
             $fields = "pd.productdata_id as productdata_id, \n\t\t\t\t           pd.name as name, \n\t\t\t\t           pd.shortdescription as shortdescription, \n\t\t\t\t           pd.metakeywords as metakeywords, \n\t\t\t\t           pd.metadescription as metadescription, \n\t\t\t\t           p.*, pag.code as groupcode";
             $data = $this->categories->getProductListbyCatUri($uri, $fields, $ns->langid);
             if (!empty($data['records'])) {
                 // Get the media information for each product
                 foreach ($data['records'] as $product) {
                     $product['reviews'] = Reviews::countItems($product['product_id']);
                     $product['attributes'] = ProductsAttributes::getAttributebyProductID($product['product_id'], $ns->langid, true);
                     $products[] = $product;
                 }
                 $this->view->products = $products;
                 $this->view->pager = $data['pager'];
             }
             $this->view->layoutmode = !empty($ns->layoutmode) ? $ns->layoutmode : "list";
             $this->_helper->viewRenderer($ns->layoutmode);
         } else {
             $this->_helper->redirector('index', 'index', 'default');
         }
     }
 }
 /**
  * Update the Configuration of the Hosting Plan
  * 
  * 
  * Update the configuration of the service selected
  * with the new parameters of the service.
  * 
  * IMPORTANT:
  * We have to sync the parameters with the Isp Panel selected
  */
 public function updateconfAction()
 {
     $id = $this->getRequest()->getParam('id');
     if (is_numeric($id)) {
         // Get the service information
         $service = OrdersItems::getAllInfo($id, "product_id");
         if (!empty($service['product_id'])) {
             // Get the system parameters/attributes of the service selected
             $sysattributes = ProductsAttributes::getSysAttributes($service['product_id']);
             // Update the parameters in the service order detail
             OrdersItems::updateSysParameters($id, $sysattributes);
         }
         $this->_helper->redirector('edit', 'ordersitems', 'admin', array('id' => $id, 'mex' => $this->translator->translate('The task requested has been executed successfully.'), 'status' => 'success'));
     } else {
         $this->_helper->redirector('list', 'orders', 'admin', array('mex' => $this->translator->translate('Service item not found.'), 'status' => 'danger'));
     }
 }
Example #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Product::where('products_id', '=', $id)->delete();
     ProductsAttributes::where('products_id', '=', $id)->delete();
     ProductsDescription::where('products_id', '=', $id)->delete();
     return $this->response(array('statusCode' => 100, 'statusDescription' => 'Success', 'message' => "Product Deleted Successfully"));
 }
Example #5
0
 /**
  * export the content in a excel file
  * @param array $items
  */
 public function bulk_xml($items = array())
 {
     // Get the records from the customer table
     $data = self::get_products($items);
     $xml = new ExSimpleXMLElement('<shineisp></shineisp>');
     $products = $xml->addChild('products');
     foreach ($data as $item) {
         $product = $products->addChild('product');
         $product->addAttribute('id', $item['product_id']);
         $product->addChild('sku', $item['sku']);
         $product->addChild('inserted_at', $item['inserted_at']);
         $product->addChild('updated_at', $item['updated_at']);
         $product->addChild('price', $item['price_1']);
         $product->addChild('setupfee', $item['setupfee']);
         if (!empty($item['ProductsMedia'])) {
             $media = $product->addChild('media');
             foreach ($item['ProductsMedia'] as $productmedia) {
                 $file = $media->addChild('file');
                 $file->addAttribute('id', $productmedia['media_id']);
                 $file->addChildCData('name', $productmedia['filename']);
                 $file->addChildCData('description', $productmedia['description']);
                 $file->addChildCData('path', $productmedia['path']);
             }
         }
         if (!empty($item['categories'])) {
             $categories = $product->addChild('categories');
             $theCats = ProductsCategories::getCategoriesByIds($item['categories']);
             foreach ($theCats as $categ) {
                 $category = $categories->addChild('category');
                 $category->addAttribute('id', $categ['id']);
                 $category->addChildCData('name', $categ['name']);
                 $category->addChildCData('description', $categ['description']);
                 $category->addChild('uri', $categ['uri']);
             }
         }
         if (!empty($item['ProductsData'][0])) {
             $product->addChildCData('name', $item['ProductsData'][0]['name']);
             $product->addChildCData('shortdescription', $item['ProductsData'][0]['shortdescription']);
             $product->addChildCData('description', $item['ProductsData'][0]['description']);
             $product->addChildCData('metakeywords', $item['ProductsData'][0]['metakeywords']);
             $product->addChildCData('metadescription', $item['ProductsData'][0]['metadescription']);
         }
         if (!empty($item['ProductsAttributesGroups'])) {
             $product->addAttribute('groupcode', $item['ProductsAttributesGroups']['code']);
             $product->addAttribute('groupname', $item['ProductsAttributesGroups']['name']);
         }
         if (!empty($item['ProductsAttributesIndexes'])) {
             $attributes = $product->addChild('attributes');
             foreach ($item['ProductsAttributesIndexes'] as $attr) {
                 $attribute = $attributes->addChild('attribute');
                 $theAttr = ProductsAttributes::getAllInfo($attr['attribute_id'], "attribute_id, code, type, is_visible_on_front, position, pad.label, pad.description, pad.prefix, pad.suffix");
                 $attribute->addAttribute('id', $attr['attribute_id']);
                 $attribute->addChild('code', $theAttr['code']);
                 $attribute->addChildCData('name', $theAttr['ProductsAttributesData'][0]['label']);
                 $attribute->addChildCData('description', $theAttr['ProductsAttributesData'][0]['description']);
                 $attribute->addChildCData('prefix', $theAttr['ProductsAttributesData'][0]['prefix']);
                 $attribute->addChildCData('suffix', $theAttr['ProductsAttributesData'][0]['suffix']);
                 $attribute->addChildCData('value', $attr['value']);
                 $attribute->addChild('type', $theAttr['type']);
                 $attribute->addChild('is_visible_on_front', $theAttr['is_visible_on_front']);
                 $attribute->addChild('position', $theAttr['position']);
             }
         }
         if (!empty($item['ProductsTranches'])) {
             $prices = $product->addChild('prices');
             foreach ($item['ProductsTranches'] as $tranches) {
                 $price = $prices->addChild('price');
                 $price->addChild('quantity', $tranches['quantity']);
                 $price->addChild('price', $tranches['price']);
                 $price->addChild('measurement', $tranches['measurement']);
                 if (!empty($tranches['BillingCycle'])) {
                     $price->addAttribute('id', $tranches['BillingCycle']['billing_cycle_id']);
                     $price->addAttribute('name', $tranches['BillingCycle']['name']);
                     $price->addAttribute('months', $tranches['BillingCycle']['months']);
                 }
             }
         }
     }
     $xml->saveXML(PUBLIC_PATH . "/tmp/products.xml");
     if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
         die(json_encode(array('url' => "/tmp/products.xml")));
     }
 }
Example #6
0
 /**
  * Get just the panel var in the config.xml configuration file
  * 
  * 
  * @param array $attributes --> ShineISP System Product Attributes
  * @param array $internalAttr --> ShineISP System Product Attribute
  * 
  * @return mixed null or string
  */
 public static function getVar($panel, array $attributes, $internalAttr)
 {
     // Loop of system product attributes
     foreach ($attributes as $attribute => $value) {
         // Get the saved system attribute
         $sysAttribute = ProductsAttributes::getAttributebyCode($attribute);
         if (!empty($sysAttribute[0]['system_var'])) {
             $sysVariable = $sysAttribute[0]['system_var'];
             // Get the system product attribute
             $modAttribute = self::getXmlFieldbyAttribute($panel, $sysVariable);
             if (!empty($modAttribute['field'])) {
                 return $modAttribute['field'];
             }
         }
     }
     return null;
 }
Example #7
0
 /**
  * Add an item within an order
  *
  * @param Cart $item
  * @throws Exception
  * @return unknown
  */
 public static function addOrderItem(CartItem $item)
 {
     if (empty(self::$order)) {
         throw new Exception('The order has not been created yet', 1000);
     }
     try {
         // get the item subtotals
         $subtotals = $item->getSubtotals();
         // get the options
         $options = $item->getOptions();
         // Get the order object previously created
         $order = self::$order;
         // add a new item
         $orderitem = new OrdersItems();
         $orderitem->order_id = $order['order_id'];
         if ("domain" == $item->getType()) {
             // Create a new domain order item
             $orderitem->tld_id = !empty($options['domain']['tld']) ? $options['domain']['tld'] : null;
             $orderitem->parameters = json_encode($options);
         } else {
             $orderitem->product_id = $item->getId();
             $orderitem->parameters = json_encode(ProductsAttributes::getSystemAttributes($item->getId()));
         }
         $orderitem->status_id = Statuses::id("tobepaid", "orders");
         $orderitem->date_start = date('Y-m-d H:i:s');
         $orderitem->date_end = null;
         $orderitem->description = $item->getName();
         $orderitem->quantity = $item->getQty();
         $orderitem->price = $item->getUnitprice();
         $orderitem->billing_cycle_id = $item->getBillingid();
         $orderitem->vat = $subtotals['taxes'];
         $orderitem->percentage = $subtotals['percentage'];
         $orderitem->uuid = $item->getUid();
         // Count of the day until the expiring
         if ($item->getIsrecurring()) {
             // get the months until of the next service expiration
             $months = $subtotals['months'];
             if ($months > 0) {
                 $totmonths = intval($item->getQty() * $months);
                 // Calculate the total of the months
                 $date_end = Shineisp_Commons_Utilities::add_date(date('d-m-Y H:i:s'), null, $totmonths);
                 $orderitem->date_end = Shineisp_Commons_Utilities::formatDateIn($date_end);
             } else {
                 $orderitem->date_end = null;
             }
         }
         $orderitem->cost = $item->getCost();
         $orderitem->setupfee = $subtotals['setupfee'];
         $orderitem->subtotal = $subtotals['subtotal'];
         // Save the order item
         if ($orderitem->trySave()) {
             // Attach all the the domain to the order
             if ("domain" == $item->getType()) {
                 $domain = $options['domain']['name'];
                 $tld = $options['domain']['tld'];
                 $domainId = Domains::Create($domain, $tld, $order->customer_id, $orderitem->detail_id);
                 if (is_numeric($domainId)) {
                     $ordersitemsdomains = new OrdersItemsDomains();
                     $ordersitemsdomains->domain_id = $domainId;
                     $ordersitemsdomains->order_id = $order['order_id'];
                     $ordersitemsdomains->orderitem_id = $orderitem->detail_id;
                     $ordersitemsdomains->save();
                 }
             }
             // Update the totals of the order
             self::updateTotalsOrder($order['order_id']);
             return $orderitem;
         }
     } catch (Exception $e) {
         Shineisp_Commons_Utilities::log('There was a problem during the order creation: ' . $e->getMessage());
     }
     return false;
 }
Example #8
0
 /**
  * Match all the product attribute fields and IspConfig fields
  *
  *
  * Match all the system product attribute from ShineISP
  * and the IspConfig fields set in the configuration file
  * located in the /library/Shineisp/Plugins/Panels/IspConfig/config.xml
  *
  * @param array $attributes --> ShineISP System Product Attribute
  * @param array $record 	--> IspConfig Client Record
  * @return ArrayObject
  */
 public function matchFieldsValues(array $attributes, array $record = array())
 {
     $fields = array();
     // Loop of system product attributes
     foreach ($attributes as $attribute => $value) {
         // Get the saved system attribute
         $sysAttribute = ProductsAttributes::getAttributebyCode($attribute);
         if (!empty($sysAttribute[0]['system_var'])) {
             $sysVariable = $sysAttribute[0]['system_var'];
             // Get the system product attribute
             $modAttribute = Panels::getXmlFieldbyAttribute("IspConfig", $sysVariable);
             if (!empty($modAttribute['field'])) {
                 // Sum the old resource value with the new ones
                 if (!empty($record[$modAttribute['field']])) {
                     /**
                      * Now we have to sum the resource previously added
                      * in the client IspConfig profile with the new one
                      */
                     if ($modAttribute['type'] == "integer") {
                         if ($record[$modAttribute['field']] == "-1") {
                             $value = "-1";
                         } else {
                             $value += $record[$modAttribute['field']];
                         }
                     }
                 }
                 if (!empty($value)) {
                     $fields[$modAttribute['field']] = $value;
                 } else {
                     $fields[$modAttribute['field']] = $modAttribute['default'];
                 }
             }
         }
     }
     return $fields;
 }
Example #9
0
 /**
  * Get a record by ID
  * 
  * @param $id
  * @return ARRAY Record
  */
 public static function getAllInfo($id, $locale = 1)
 {
     $dq = Doctrine_Query::create()->from('Products p')->leftJoin('p.ProductsAttributesGroups pag')->leftJoin("p.ProductsData pd WITH pd.language_id = {$locale}")->leftJoin('p.Taxes t')->leftJoin('p.ProductsAttributesIndexes pai')->leftJoin('p.ProductsTranches pt')->leftJoin('pt.BillingCycle bc')->where('p.product_id = ?', $id)->addWhere("p.isp_id = ?", Isp::getCurrentId());
     $product = $dq->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     if (isset($product[0])) {
         if (array_key_exists('ProductsTranches', $product[0])) {
             $tranches = $product[0]['ProductsTranches'];
             $tranchesIndex = array();
             foreach ($tranches as $tranche) {
                 $tranchesIndex[$tranche['tranche_id']] = $tranche;
             }
             unset($product[0]['ProductsTranches']);
             $product[0]['ProductsTranches'] = $tranchesIndex;
         }
         // Handle the Attributes Values
         if (!empty($product[0]['ProductsAttributesIndexes'])) {
             $attributes = $product[0]['ProductsAttributesIndexes'];
             foreach ($attributes as $attribute) {
                 $attr = ProductsAttributes::find($attribute['attribute_id']);
                 $code = $attr['code'];
                 $product[0][$code] = $attribute['value'];
             }
             unset($product[0]['ProductsAttributesIndexes']);
         }
         return $product[0];
     } else {
         return array();
     }
 }
 /**
  * processAction
  * Update the record previously selected
  * @return unknown_type
  */
 public function processAction()
 {
     $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
     $form = $this->getForm("/admin/productsattributes/process");
     $request = $this->getRequest();
     // Create the buttons in the edit form
     $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/productsattributes/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/productsattributes/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null)));
     try {
         // Check if we have a POST request
         if (!$request->isPost()) {
             return $this->_helper->redirector('list', 'productsattributes', 'admin');
         }
         if ($form->isValid($request->getPost())) {
             $params = $request->getParams();
             $id = $params['attribute_id'];
             $code = $params['code'];
             $label = $params['label'];
             $type = $params['type'];
             $prefix = $params['prefix'];
             $suffix = $params['suffix'];
             $is_system_var = $params['system'];
             $description = $params['description'];
             $position = $params['position'];
             $is_visible_on_front = $params['is_visible_on_front'];
             $active = $params['active'];
             $system = $params['system'];
             $system_var = $params['system_var'];
             $defaultvalue = $params['defaultvalue'];
             $is_required = $params['is_required'];
             $is_comparable = $params['is_comparable'];
             $on_product_listing = !empty($params['on_product_listing']) && $params['on_product_listing'] == 1 ? true : false;
             $language_id = $params['language_id'];
             $id = ProductsAttributes::addNew($id, $code, $label, $type, $language_id, $position, $active, $prefix, $suffix, $description, $is_visible_on_front, $is_system_var, $system_var, $defaultvalue, $is_required, $is_comparable, $on_product_listing);
             if ($id === false) {
                 $this->_helper->redirector('list', 'productsattributes', 'admin', array('mex' => "There was an error during the saving process. Check all the parameters.", 'status' => 'danger'));
             }
             $this->_helper->redirector('edit', 'productsattributes', 'admin', array('id' => $id, 'mex' => $this->translator->translate('The task requested has been executed successfully.'), 'status' => 'success'));
         } else {
             $this->view->form = $form;
             $this->view->title = $this->translator->translate("Hosting Plan Feature details");
             $this->view->description = $this->translator->translate("Here you can fix the hosting plan feature details.");
             return $this->render('applicantform');
         }
     } catch (Exception $e) {
         $this->_helper->redirector('edit', 'productsattributes', 'admin', array('id' => $id, 'mex' => $e->getMessage(), 'status' => 'danger'));
     }
 }