public function service() { $categoryManager = new CategoryManager($this->config, $this->args); $categoryId = $this->secure($_REQUEST["category_id"]); $display_name = $this->secure($_REQUEST["display_name"]); $last_clickable = $this->secure($_REQUEST["last_clickable"]); $adminManager = new AdminManager($this->config, $this->args); $adminId = $this->sessionManager->getUser()->getId(); $adminDto = $adminManager->selectByPK($adminId); if ($adminDto) { $categoryDto = $categoryManager->getCategoryById($categoryId); if (!$categoryDto) { $jsonArr = array('status' => "err", "errText" => "System Error: Category doesn't exist!"); echo json_encode($jsonArr); return false; } $categoryManager->updateCategoryAttributes($categoryId, $display_name, $last_clickable); $jsonArr = array('status' => "ok", "message" => "ok"); echo json_encode($jsonArr); return true; } else { $jsonArr = array('status' => "err", "errText" => "System Error: You are not Admin!"); echo json_encode($jsonArr); return false; } }
public function service() { $categoryManager = new CategoryManager($this->config, $this->args); $categoryHierarchyManager = new CategoryHierarchyManager($this->config, $this->args); $categoryTitle = $this->secure($_REQUEST["category_title"]); $parentCategoryId = $this->secure($_REQUEST["parent_category_id"]); $adminManager = new AdminManager($this->config, $this->args); $adminId = $this->sessionManager->getUser()->getId(); $adminDto = $adminManager->selectByPK($adminId); if ($adminDto) { $sortIndex = count($categoryHierarchyManager->getCategoryChildrenIdsArray($parentCategoryId)) + 1; $categoryId = $categoryManager->addCategory($categoryTitle, '0', '0', '1'); $categoryHierarchyManager->addSubCategoryToCategory($parentCategoryId, $categoryId, $sortIndex); $jsonArr = array('status' => "ok", "message" => "ok"); echo json_encode($jsonArr); return true; } else { $jsonArr = array('status' => "err", "errText" => "System Error: You are not Admin!"); echo json_encode($jsonArr); return false; } }
public function service() { //todo check if user have access to given company $adminManager = new AdminManager($this->config, $this->args); $adminId = $this->sessionManager->getUser()->getId(); $adminDto = $adminManager->selectByPK($adminId); if (!$adminDto) { return false; } $companyId = $this->args[0]; $companyManager = CompanyManager::getInstance($this->config, $this->args); $company = $companyManager->selectByPK($companyId); if (!$company) { return false; } $ex = new excel_xml(); $header_style = array('bold' => 1, 'size' => '12', 'color' => '#FFFFFF', 'bgcolor' => '#4F81BD'); $ex->add_style('header', $header_style); $ex->add_row(array('Name', 'Price', 'VAT Price'), 'header'); $itemManager = ItemManager::getInstance($this->config, $this->args); $items = $itemManager->getCompanyItems($companyId); foreach ($items as $key => $itemDto) { $row = array(); $name = $itemDto->getDisplayName(); $row[] = $name; $price_usd = $itemDto->getDealerPrice(); $row[] = '$' . $price_usd; if ($itemDto->getVatPrice() > 0) { $price_vat_usd = $itemDto->getVatPrice(); $row[] = '$' . $price_vat_usd; } //$price_amd = $itemManager->exchangeFromUsdToAMD($itemDto->getDealerPrice()); $ex->add_row($row); } $ex->create_worksheet('Items'); $ex->generate(); $ex->download($company->getName()); }
public function getCustomer() { if (!$this->customer) { if ($this->getUserLevel() != UserGroups::$GUEST) { $userId = $this->getUserId(); if ($this->getUserLevel() == UserGroups::$USER) { $userManager = new UserManager($this->config, $this->args); $this->customer = $userManager->selectByPK($userId); } else { if ($this->getUserLevel() == UserGroups::$COMPANY) { $customerManager = new CompanyManager($this->config, $this->args); $this->customer = $customerManager->selectByPK($userId); } else { if ($this->getUserLevel() == UserGroups::$SERVICE_COMPANY) { $customerManager = new ServiceCompanyManager($this->config, $this->args); $this->customer = $customerManager->selectByPK($userId); } else { if ($this->getUserLevel() == UserGroups::$ADMIN) { $adminManager = new AdminManager($this->config, $this->args); $this->customer = $adminManager->selectByPK($userId); } } } } } } return $this->customer; }