public function get($productid) { $this->authenticate(); if (empty($productid)) { throw new Shineisp_Api_Exceptions(400002, ":: 'productid' field"); exit; } $product = new Products(); $details = $product->getAllInfo($productid); $details['ProductsUpgrades'] = ProductsUpgrades::getItemsbyProductID($productid); return $details; }
/** * Get a record and populate the application form * @return unknown_type */ public function editAction() { $form = $this->getForm('/admin/products/process'); $id = $this->getRequest()->getParam('id'); $orders = ""; // 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/products/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/products/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null))); if (!empty($id) && is_numeric($id)) { $this->session->productid = $id; $rs = $this->products->getAllInfo($id, $this->session->langid); if (!empty($rs)) { // Join the translated data information to populate the form $data = !empty($rs['ProductsData'][0]) ? $rs['ProductsData'][0] : array(); $rs = array_merge($rs, $data); $form = $this->createAttributesElements($form, $rs['group_id']); $this->view->isrecurring = $rs['ProductsAttributesGroups']['isrecurring']; $rs['language_id'] = $this->session->langid; // added to the form the language id selected $rs['related'] = ProductsRelated::getItemsbyProductID($rs['product_id']); //add panel for select upgrade $rs['upgrade'] = ProductsUpgrades::getItemsbyProductID($rs['product_id']); // Get the wiki pages attached to the product selected $rs['wikipages'] = Wikilinks::getWikiPagesList($rs['product_id'], "products", $this->session->langid); $form->populate($rs); $categories = explode("/", $rs['categories']); $this->view->categories = json_encode($this->createCategoryTree(0, $categories)); $this->view->title = !empty($rs['name']) ? $rs['name'] : ""; $this->view->icon = "fa fa-barcode"; $this->view->titlelink = !empty($rs['uri']) ? "/" . $rs['uri'] . ".html" : ""; $media = ProductsMedia::getMediabyProductId($id, "pm.media_id, pm.filename, pm.path"); if (isset($media[0])) { $this->view->media = array('records' => $media, 'delete' => array('controller' => 'products', 'action' => 'delmedia')); } $tranches = ProductsTranches::getTranches($id, "tranche_id, quantity, measurement, setupfee, price, bc.name as billingcycle, selected"); if (isset($tranches[0])) { $onclick = array(); foreach ($tranches as &$tranche) { $trancheid = $tranche['tranche_id']; $include = ProductsTranchesIncludes::getIncludeForTrancheId($trancheid); $textInclude = array(); if (array_key_exists('domains', $include)) { $textInclude[] = "Domains: " . implode(", ", $include['domains']); } $tranche['include'] = implode("<br/>", $textInclude); } $this->view->tranches = array('records' => $tranches, 'actions' => array('/admin/products/setdefaultrance/id/' => 'Set as default'), 'delete' => array('controller' => 'products', 'action' => 'deltranche')); } } $orders = array('records' => OrdersItems::ProductsInOrdersItems($id), 'edit' => array('controller' => 'ordersitems', 'action' => 'edit')); $this->view->buttons[] = array("url" => "/admin/products/confirm/id/{$id}", "label" => $this->translator->translate('Delete'), "params" => array('css' => null)); } $this->view->description = $this->translator->translate("Here you can edit the product details"); $this->view->mex = $this->getRequest()->getParam('mex'); $this->view->mexstatus = $this->getRequest()->getParam('status'); $this->view->orders = $orders; $this->view->isSold = (bool) OrdersItems::CheckIfProductExist($id); $this->view->form = $form; $this->render('applicantform'); }