public function service() { $customer = $this->getCustomer(); $customerEmail = strtolower($customer->getEmail()); $customerCartManager = CustomerCartManager::getInstance($this->config, $this->args); if (isset($_REQUEST['update_basket_count'])) { $totalCount = $customerCartManager->getCustomerCartTotalCount($customerEmail); $jsonArr = array('status' => "ok", "cart_items_count" => $totalCount); echo json_encode($jsonArr); return true; } $add_count = 1; if (isset($_REQUEST['add_count'])) { $add_count = $this->secure($_REQUEST['add_count']); } if (isset($_REQUEST['item_id'])) { $item_id = $this->secure($_REQUEST['item_id']); } $itemManager = ItemManager::getInstance($this->config, $this->args); if (isset($item_id)) { $itemDto = $itemManager->selectByPK($item_id); if (!isset($itemDto)) { $jsonArr = array('status' => "err", "errText" => "Item is no more available!"); echo json_encode($jsonArr); return false; } $last_dealer_price = $itemDto->getDealerPrice(); } $customerCartManager->addToCart($customerEmail, $item_id, 0, $last_dealer_price, $add_count); $totalCount = $customerCartManager->getCustomerCartTotalCount($customerEmail); $jsonArr = array('status' => "ok", "cart_items_count" => $totalCount); echo json_encode($jsonArr); return true; }
public function load() { $dealsManager = DealsManager::getInstance($this->config, $this->args); $itemManager = ItemManager::getInstance($this->config, $this->args); $this->addParam("itemManager", $itemManager); //today deals $todayDealDto = $dealsManager->getTodayDeal(); if ($todayDealDto) { $itemId = $todayDealDto->getItemId(); $todayItem = $itemManager->getItemsForOrder($itemId, $this->getUserId(), $this->getUserLevel(), true); if (isset($todayItem) && ($todayItem->getIsDealerOfThisCompany() == 0 || $this->getUserLevel() === UserGroups::$ADMIN)) { $totalDurationSeconds = intval($todayDealDto->getDurationMinutes()) * 60; $currentTimeInSeconds = time(); $dealStartTimeInSeconds = strtotime($todayDealDto->getDate() . ' ' . $todayDealDto->getStartTime()); $dealEndTimeInSeconds = strtotime($todayDealDto->getDate() . ' ' . $todayDealDto->getStartTime()) + $totalDurationSeconds; $dealIsEnable = $currentTimeInSeconds > $dealStartTimeInSeconds && $currentTimeInSeconds < $dealEndTimeInSeconds - 10; if ($dealIsEnable) { $this->addParam("todayItem", $todayItem); $this->addParam("today_deal_seconds_to_end", $dealEndTimeInSeconds - $currentTimeInSeconds); $this->addParam('today_deal_promo_code', $todayDealDto->getPromoCode()); $this->addParam('today_deal_fixed_price', $todayDealDto->getPriceAmd()); } } } //lighting deals /* $lightingDeals = $dealsManager->getLightingDeals(); if (!empty($lightingDeals)) { $this->addParam("lightingDeals", $lightingDeals); } */ }
public function load() { $company_id = $_REQUEST['company_id']; $used_columns_indexes_array = array(2, 1, 9, 3, 4, 5, 6, 7); //explode(',', $_REQUEST['used_columns_indexes']); $importItemsTempManager = ImportItemsTempManager::getInstance($this->config, $this->args); $categoryHierarchyManager = CategoryHierarchyManager::getInstance($this->config, $this->args); $categoryManager = CategoryManager::getInstance($this->config, $this->args); $customerLogin = $this->getCustomerLogin(); $priceRowsDtos = $importItemsTempManager->getUserCurrentPriceChangedRows($customerLogin); $columnNames = ImportPriceManager::getColumnNamesMap($used_columns_indexes_array); $rootDto = $categoryManager->getRoot(); $firstLevelCategoriesHierarchyDtos = $categoryHierarchyManager->getCategoryChildren($rootDto->getId()); $firstLevelCategoriesNamesDtos = $categoryHierarchyManager->getCategoriesNamesByParentCategoryId($rootDto->getId()); $firstLevelCategoriesIds = array(); foreach ($firstLevelCategoriesHierarchyDtos as $key => $category) { $firstLevelCategoriesIds[] = $category->getChildId(); } $firstLevelCategoriesNames = array(); foreach ($firstLevelCategoriesNamesDtos as $key => $category) { $firstLevelCategoriesNames[] = $category->getDisplayName(); } $itemManager = ItemManager::getInstance($this->config, $this->args); $companyAllItems = $itemManager->getCompanyItems($company_id, true); $convertDtosArrayToArrayMapById = $this->convertDtosArrayToArrayMapById($companyAllItems); $this->addParam('stockItemsDtosMappedByIds', $convertDtosArrayToArrayMapById); $this->addParam('columnNames', $columnNames); $this->addParam('priceRowsDtos', $priceRowsDtos); $this->addParam('firstLevelCategoriesNames', $firstLevelCategoriesNames); $this->addParam('firstLevelCategoriesIds', $firstLevelCategoriesIds); list($changedRowIds, $changedFields) = $this->findChanges($priceRowsDtos, $convertDtosArrayToArrayMapById, $columnNames); $this->addParam('changedRowsIds', $changedRowIds); $this->addParam('changedFields', $changedFields); }
/** * Initializes DB mappers * * @param object $config * @param object $args * @return */ function __construct($config, $args) { $this->config = $config; $this->args = $args; $this->itemManager = ItemManager::getInstance($this->config, $this->args); $this->pcComponentValidatorManager = PcComponentValidatorManager::getInstance($this->config, $this->args); }
/** * Initializes DB mappers * * @param object $config * @param object $args * @return */ function __construct($config, $args) { $this->mapper = BundleItemsMapper::getInstance(); $this->config = $config; $this->args = $args; $this->itemManager = ItemManager::getInstance($this->config, $this->args); }
public function load() { $item_id = intval($_REQUEST['item_id']); $itemManager = ItemManager::getInstance($this->config, $this->args); $itemDto = $itemManager->selectByPK($item_id); $this->addParam('itemDto', $itemDto); }
public function load() { $companyManager = CompanyManager::getInstance($this->config, $this->args); $customer = $this->sessionManager->getUser(); $userLevel = $customer->getLevel(); if ($userLevel == UserGroups::$ADMIN) { $allCompaniesDtos = $companyManager->getAllCompanies(true, true); } else { $allCompaniesDtos = array($companyManager->selectByPK($customer->getId())); } $allCompaniesNames = array(); $allCompaniesIds = array(); foreach ($allCompaniesDtos as $key => $company) { $allCompaniesNames[] = $company->getName(); $allCompaniesIds[] = $company->getId(); } if (isset($_REQUEST["company_id"])) { $selectedCompanyId = $this->secure($_REQUEST["company_id"]); } else { $selectedCompanyId = $allCompaniesIds[0]; } $this->addParam('selectedCompanyId', $selectedCompanyId); $this->addParam('allCompaniesNames', $allCompaniesNames); $this->addParam('allCompaniesIds', $allCompaniesIds); $itemManager = ItemManager::getInstance($this->config, $this->args); $allCompanyItems = $itemManager->getCompanyItems($selectedCompanyId, true); $this->addParam('company_items', $allCompanyItems); if (isset($_COOKIE['copied_item_id'])) { $this->addParam('copied_item_id', $_COOKIE['copied_item_id']); } $this->addParam('itemManager', $itemManager); }
public function load() { if (isset($_REQUEST["item_id"])) { $item_id = $_REQUEST["item_id"]; if (strpos($item_id, ',') !== false) { $item_id = explode(',', $item_id); } $itemManager = ItemManager::getInstance($this->config, $this->args); $userLevel = $this->getUserLevel(); $userId = $this->getUserId(); if (is_array($item_id)) { $itemDto = array(); foreach ($item_id as $key => $itemId) { $itemD = $itemManager->getItemsForOrder($itemId, $userId, $userLevel); if ($itemD != null) { $itemDto[] = $itemD; } } $itemPicturesCount = 0; } else { $itemDto = $itemManager->getItemsForOrder($item_id, $userId, $userLevel); if ($itemDto == null) { //TODO tell user about that IMPORTANT return; } $itemPicturesCount = $itemDto->getPicturesCount(); } $this->addParam("item_id", $item_id); $this->addParam("item", $itemDto); $this->addParam("item_pictures_count", $itemPicturesCount); $this->addParam("itemManager", $itemManager); } }
public function load() { //Load First Level Categories from DB $categoryManager = CategoryManager::getInstance($this->config, $this->args); $categoryHierarchyManager = CategoryHierarchyManager::getInstance($this->config, $this->args); $rootDto = $categoryManager->getRoot(); $firstLevelCategoriesHierarchyDtos = $categoryHierarchyManager->getCategoryChildren($rootDto->getId()); $firstLevelCategoriesNamesDtos = $categoryHierarchyManager->getCategoriesNamesByParentCategoryId($rootDto->getId()); $firstLevelCategoriesIds = array(); foreach ($firstLevelCategoriesHierarchyDtos as $key => $category) { $firstLevelCategoriesIds[] = $category->getChildId(); } $firstLevelCategoriesNames = array(); foreach ($firstLevelCategoriesNamesDtos as $key => $category) { $firstLevelCategoriesNames[] = $category->getDisplayName(); } $this->addParam('firstLevelCategoriesNames', $firstLevelCategoriesNames); $this->addParam('firstLevelCategoriesIds', $firstLevelCategoriesIds); $item_warranty_options = explode(',', $this->getCmsVar('item_warranty_options')); $this->addParam('item_warranty_options', $item_warranty_options); $itemManager = ItemManager::getInstance($this->config, $this->args); if (isset($_REQUEST['item_id'])) { $itemId = $this->secure($_REQUEST['item_id']); $itemDto = $itemManager->selectByPK($itemId); $this->addParam('item_pictures_count', $itemDto->getPicturesCount()); $this->addParam('item_id', $itemDto->getId()); $this->addParam('item_title', $itemDto->getDisplayName()); $this->addParam('item_available', $itemManager->isItemAvailable($itemDto)); $this->addParam('short_description', $itemDto->getShortDescription()); $this->addParam('full_description', $itemDto->getFullDescription()); $this->addParam('dealer_price', $itemDto->getDealerPrice()); $this->addParam('vat_price', $itemDto->getVatPrice()); $this->addParam('dealer_price_amd', $itemDto->getDealerPriceAmd()); $this->addParam('vat_price_amd', $itemDto->getVatPriceAmd()); $this->addParam('selected_warranty_option', $itemDto->getWarranty()); $this->addParam('item_model', $itemDto->getModel()); $this->addParam('item_brand', $itemDto->getBrand()); $this->addParam('order_index_in_price', $itemDto->getOrderIndexInPrice()); $this->addParam('item_available_till_date', $itemDto->getItemAvailableTillDate()); $itemCategoriesIds = $itemDto->getCategoriesIds(); $itemCategoriesIds = trim($itemCategoriesIds, ','); assert(!empty($itemCategoriesIds)); $itemCategoriesIds = explode(',', $itemCategoriesIds); $selectedRootCategoryId = $itemCategoriesIds[0]; $subCategoriesIdsArray = array_slice($itemCategoriesIds, 1); $this->addParam('selectedRootCategoryId', $selectedRootCategoryId); $this->addParam('sub_categories_ids', join(',', $subCategoriesIdsArray)); } else { $selectedRootCategoryId = $firstLevelCategoriesHierarchyDtos[0]->getChildId(); $this->addParam('selected_warranty_option', $item_warranty_options[12]); $this->addParam('selectedRootCategoryId', $selectedRootCategoryId); $this->addParam('sub_categories_ids', ''); } $item_availability_options_names = array("Today", "2 days", "3 days", "1 week", "2 weeks", "1 month"); $item_availability_options_values = array(0, 1, 2, 6, 13, 29); $this->addParam('item_availability_options_names', $item_availability_options_names); $this->addParam('item_availability_options_values', $item_availability_options_values); $this->addParam('item_availability_selected', $item_availability_options_values[3]); $this->addParam('company_id', intval($this->secure($_REQUEST["company_id"]))); }
public function service() { $itemManager = ItemManager::getInstance($this->config, $this->args); $itemManager->UpdateAllAmdItemsPrices(); $jsonArr = array('status' => "ok"); echo json_encode($jsonArr); return true; }
/** * Initializes DB mappers * * @param object $config * @param object $args * @return */ function __construct($config, $args) { $this->mapper = OrderDetailsMapper::getInstance(); $this->config = $config; $this->args = $args; $this->customerCartManager = CustomerCartManager::getInstance($this->config, $this->args); $this->itemManager = ItemManager::getInstance($this->config, $this->args); $this->bundleItemsManager = BundleItemsManager::getInstance($this->config, $this->args); }
public function service() { $companyId = $_REQUEST['company_id']; $itemManager = ItemManager::getInstance($this->config, $this->args); $itemManager->hideCompanyItems($companyId); $jsonArr = array('status' => "ok"); echo json_encode($jsonArr); return false; }
private function initVars() { $customer = $this->getCustomer(); if ($customer) { $this->customerEmail = strtolower($customer->getEmail()); $this->customerCartManager = CustomerCartManager::getInstance($this->config, $this->args); $this->bundleItemsManager = BundleItemsManager::getInstance($this->config, $this->args); $this->itemManager = ItemManager::getInstance($this->config, $this->args); } }
public function load() { $loadPage = 0; if (isset($_REQUEST['load_page'])) { $loadPage = $_REQUEST['load_page']; } if ($loadPage == 1) { $this->addParam("page_loaded", 1); $companyManager = CompanyManager::getInstance($this->config, $this->args); $allCompanyDtos = $companyManager->getAllCompanies(false, false); $companyNames = array(); $companyIds = array(); foreach ($allCompanyDtos as $companyDto) { $companyNames[] = $companyDto->getName(); $companyIds[] = $companyDto->getId(); } $this->addParam("companyNames", $companyNames); $this->addParam("companyIds", $companyIds); $selectedCompanyId = $companyIds[0]; if (isset($_REQUEST['selected_company_id'])) { $selectedCompanyId = intval($_REQUEST['selected_company_id']); } $includeHiddens = false; if (isset($_REQUEST['include_hiddens'])) { $includeHiddens = intval($_REQUEST['include_hiddens']) == 1; } $this->addParam('include_hiddens', $includeHiddens); $emptyModel = 0; if (isset($_REQUEST['empty_model'])) { $emptyModel = intval($_REQUEST['empty_model']); } $this->addParam('empty_model', $emptyModel); $emptyShortSpec = 0; if (isset($_REQUEST['empty_short_spec'])) { $emptyShortSpec = intval($_REQUEST['empty_short_spec']); } $this->addParam('empty_short_spec', $emptyShortSpec); $emptyFullSpec = 0; if (isset($_REQUEST['empty_full_spec'])) { $emptyFullSpec = intval($_REQUEST['empty_full_spec']); } $this->addParam('empty_full_spec', $emptyFullSpec); $picturesCount = 'any'; if (isset($_REQUEST['pictures_count'])) { $picturesCount = strtolower($_REQUEST['pictures_count']); } $this->addParam('pictures_count', $picturesCount); $itemManager = ItemManager::getInstance($this->config, $this->args); $items = $itemManager->getItemsByAdminConditions($selectedCompanyId, $includeHiddens, $emptyModel, $emptyShortSpec, $emptyFullSpec, $picturesCount); $this->addParam("items", $items); } else { $this->addParam("page_loaded", 0); } }
public function service() { $itemId = $this->secure($_REQUEST['item_id']); $root = $this->secure($_REQUEST['root_category_id']); $subCategories = $this->secure($_REQUEST['sub_categories_ids']); $subCategoriesArray = explode(',', trim($subCategories, ',')); $categoriesIdsArray = $subCategoriesArray; array_unshift($categoriesIdsArray, $root); $itemManager = ItemManager::getInstance($this->config, $this->args); $itemManager->setItemCategories($itemId, $categoriesIdsArray); $this->ok(); }
public function service() { $company_id = $this->secure($_REQUEST["company_id"]); $itemManager = ItemManager::getInstance($this->config, $this->args); //first set all to 1 week availability $itemManager->increaseCompanyExpireItemsByGivenDays($company_id, 4); // then set by category $itemManager->increaseCompanyExpireItemsByGivenDays($company_id, 2, array(CategoriesConstants::HDD_HARD_DRIVE, CategoriesConstants::CPU_PROCESSOR)); $this->sendStockUpdatedEmailToCompany($company_id); $jsonArr = array('status' => "ok"); echo json_encode($jsonArr); return true; }
public function load() { $ordersManager = OrdersManager::getInstance($this->config, $this->args); if ($this->getUserLevel() === UserGroups::$ADMIN) { $showOnlyOrdersValues = array_merge(array(-1), $ordersManager->orderStatusesValues); $this->addParam('showOnlyOrdersValues', $showOnlyOrdersValues); $orderStatusesDisplayNames = array_merge(array($this->getPhrase(153)), $ordersManager->getOrderStatusesDisplayNamesPhrases()); $showOnlyOrdersDisplayNamesPphraseIdsArray = array_merge(array(153), $ordersManager->orderStatusesDisplayNamesIds); $this->addParam('showOnlyOrdersDisplayNames', $orderStatusesDisplayNames); $this->addParam('showOnlyOrdersDisplayNamesPphraseIdsArray', $showOnlyOrdersDisplayNamesPphraseIdsArray); $show_only = $showOnlyOrdersValues[1]; if (isset($_REQUEST['show_only'])) { $so = $this->secure($_REQUEST['show_only']); if (in_array($so, $showOnlyOrdersValues)) { $show_only = $so; } } $this->addParam('showOnlyOrdersSelected', $show_only); $customerOrders = $ordersManager->getAllOrdersJoinedWithDetails($show_only); } else { $customer = $this->getCustomer(); $customerEmail = strtolower($customer->getEmail()); $customerOrders = $ordersManager->getCustomerOrderJoinedWithDetails($customerEmail); } $groupedOrders = $this->groupCustomerOrders($customerOrders); $groupOrdersByOrderIdAndBundleId = $this->groupOrdersByOrderIdAndBundleId($customerOrders); $pv = $this->getPriceVariety($groupedOrders); $this->addParam('groupOrdersByOrderIdAndBundleId', $groupOrdersByOrderIdAndBundleId); $this->addParam('priceVariety', $pv); if (isset($_REQUEST['order_id'])) { $order_id = $_REQUEST['order_id']; $mess1 = $this->getPhrase(301); $mess2 = $this->getPhrase(329) . $order_id; $mess3 = $this->getPhrase(360); $this->addParam('customerMessages', array($mess1, $mess2, $mess3)); } if (isset($_SESSION['success_message'])) { $this->addParam('customerMessages', array($_SESSION['success_message'])); unset($_SESSION['success_message']); } if (isset($_SESSION['error_message'])) { $this->addParam('customerErrorMessages', array($_SESSION['error_message'])); unset($_SESSION['error_message']); } $this->addParam('itemManager', ItemManager::getInstance($this->config, $this->args)); $this->addParam('userManager', UserManager::getInstance($this->config, $this->args)); $this->addParam('orderManager', OrdersManager::getInstance($this->config, $this->args)); $this->addParam("orderStatusesValues", $ordersManager->orderStatusesValues); $this->addParam("orderStatusesDisplayNames", $ordersManager->getOrderStatusesDisplayNamesPhrases()); }
public function load() { $user = $this->getUser(); $pccm = PcConfiguratorManager::getInstance($this->config, $this->args); $selectedComponents = $pccm->getSelectedComponentsDtosOrderedInArray($user); $itemManager = ItemManager::getInstance($this->config, $this->args); $this->addParam("selected_components", $selectedComponents); $priceGroup = null; if ($this->getUserLevel() === UserGroups::$ADMIN) { $customer = $this->getCustomer(); $priceGroup = $customer->getPriceGroup(); } list($totalUsd, $totalAmd) = $pccm->getSelectedComponentSubTotalsAndTotals($selectedComponents, $user->getLevel(), $priceGroup); $required_components_ids = $pccm->getRequestComponentRequiredComponents($this->sessionManager->getUser()); if (count($required_components_ids) === 0) { $this->addParam("ready_to_order", "true"); } else { $this->addParam("ready_to_order", "false"); } if (isset($_REQUEST['configurator_mode_edit_cart_row_id']) && intval($_REQUEST['configurator_mode_edit_cart_row_id']) > 0) { $this->addParam("configurator_mode_edit_cart_row_id", intval($_REQUEST['configurator_mode_edit_cart_row_id'])); } $this->addParam("pccm", $pccm); $this->addParam("total_usd", $totalUsd); $this->addParam("total_amd", $totalAmd); $vipCustomer = 0; if ($this->getUserLevel() === UserGroups::$USER) { $customer = $this->getCustomer(); $userManager = UserManager::getInstance($this->config, $this->args); $vipCustomer = $userManager->isVipAndVipEnabled($customer); } if ($this->getUserLevel() === UserGroups::$ADMIN) { $customer = $this->getCustomer(); $vipCustomer = $customer->getPriceGroup() === 'vip'; } if ($vipCustomer) { $pc_configurator_discount = floatval($this->getCmsVar('vip_pc_configurator_discount')); } else { $pc_configurator_discount = floatval($this->getCmsVar('pc_configurator_discount')); } $this->addParam("pc_configurator_discount", $pc_configurator_discount); $selectedComponentProfitWithDiscount = $pccm->calcSelectedComponentProfitWithDiscount($selectedComponents, $user->getLevel(), $pc_configurator_discount, $priceGroup); $pcBuildFeeAMD = $pccm->calcPcBuildFee($selectedComponentProfitWithDiscount); $this->addParam("pc_build_fee_amd", $pcBuildFeeAMD); $this->pcGrandTotalAmd = $totalAmd * (1 - $pc_configurator_discount / 100) + $pcBuildFeeAMD; $this->pcGrandTotalUsd = $totalUsd; $this->addParam("grand_total_amd", $this->pcGrandTotalAmd); $this->addParam("itemManager", $itemManager); }
public function service() { $itemId = $this->secure($_REQUEST["item_id"]); $companyId = $this->secure($_REQUEST["company_id"]); $itemManager = ItemManager::getInstance($this->config, $this->args); $itemDto = $itemManager->selectByPK($itemId); if ($this->getUserLevel() !== UserGroups::$ADMIN && !($this->getUserLevel() === UserGroups::$COMPANY && $itemDto->getCompanyId() === $companyId)) { $jsonArr = array('status' => "err", "errText" => "System Error: Access denied!"); echo json_encode($jsonArr); return false; } $itemManager->deleteItemWithPictures($itemId); $jsonArr = array('status' => "ok", "message" => "ok"); echo json_encode($jsonArr); return true; }
public function service() { $companyItemCheckListManager = CompanyItemCheckListManager::getInstance($this->config, $this->args); $itemId = intval($this->secure($_REQUEST['item_id'])); $itemAvailability = intval($this->secure($_REQUEST['item_availability'])); $companyId = $this->getUserId(); $companyItemCheckListManager->setCompanyItemAvailability($companyId, $itemId, $itemAvailability); $itemManager = ItemManager::getInstance($this->config, $this->args); if ($itemAvailability === -1) { $itemManager->setItemHidden($itemId, 1); } elseif ($itemAvailability === 1) { $itemManager->setItemTillDateAttribute($itemId, date('Y-m-d', strtotime("tomorrow"))); } $jsonArr = array('status' => 'ok'); echo json_encode($jsonArr); return true; }
public function service() { $item_id = $this->secure($_REQUEST["item_id"]); $price_order_index = $this->secure($_REQUEST["price_order_index"]); $itemManager = ItemManager::getInstance($this->config, $this->args); $itemDto = $itemManager->selectByPK($item_id); if ($itemDto != null) { $itemManager->changeItemOrderIndexInPrice($item_id, $price_order_index); $itemDto = $itemManager->selectByPK($item_id); $jsonArr = array('status' => "ok", "item_id" => $item_id, "price_order_index" => $itemDto->getOrderIndexInPrice()); echo json_encode($jsonArr); return true; } else { $jsonArr = array('status' => "err", "errText" => "System Error: Item does not exist!"); echo json_encode($jsonArr); return false; } }
public function service() { $item_id = $this->secure($_REQUEST["item_id"]); $item_hidden = $this->secure($_REQUEST["item_hidden"]); $itemManager = ItemManager::getInstance($this->config, $this->args); $itemDto = $itemManager->selectByPK($item_id); if ($itemDto != null) { $itemManager->changeItemHiddenAttributeValue($item_id, $item_hidden); $itemDto = $itemManager->selectByPK($item_id); $jsonArr = array('status' => "ok", "item_id" => $item_id, "is_item_hidden" => $itemDto->getHidden(), "is_item_available" => $itemManager->isItemAvailable($itemDto)); echo json_encode($jsonArr); return true; } else { $jsonArr = array('status' => "err", "errText" => "System Error: Item does not exist!"); echo json_encode($jsonArr); return false; } }
public function service() { $item_id = $this->secure($_REQUEST["item_id"]); $display_name = $this->secure($_REQUEST["display_name"]); $itemManager = ItemManager::getInstance($this->config, $this->args); $itemDto = $itemManager->selectByPK($item_id); if ($itemDto != null) { $itemManager->changeItemDisplayNamePrice($item_id, $display_name); $itemDto = $itemManager->selectByPK($item_id); $jsonArr = array('status' => "ok", "item_id" => $item_id, "display_name" => $itemDto->getDisplayName()); echo json_encode($jsonArr); return true; } else { $jsonArr = array('status' => "err", "errText" => "System Error: Item does not exist!"); echo json_encode($jsonArr); return false; } }
public function service() { if (!isset($_REQUEST['item_position'])) { $jsonArr = array('status' => "err", "errText" => "System Error: Item position is not set!"); echo json_encode($jsonArr); return false; } $item_position = $this->secure($_REQUEST['item_position']); if (!is_numeric($item_position)) { $jsonArr = array('status' => "err", "errText" => "System Error: Item position should be positive number!"); echo json_encode($jsonArr); return false; } if (!$_COOKIE['copied_item_id']) { $jsonArr = array('status' => "err", "errText" => "System Error: There is no copied item!"); echo json_encode($jsonArr); return false; } $copied_item_id = $this->secure($_COOKIE['copied_item_id']); $itemManager = ItemManager::getInstance($this->config, $this->args); $itemDto = $itemManager->selectByPK($copied_item_id); if (!isset($itemDto)) { $jsonArr = array('status' => "err", "errText" => "Error: Item does not exist! (id:{$copied_item_id})"); echo json_encode($jsonArr); return false; } if (!isset($_REQUEST['selected_company_id'])) { $jsonArr = array('status' => "err", "errText" => "System Error: Company id is not set!"); echo json_encode($jsonArr); return false; } $selected_company_id = $this->secure($_REQUEST['selected_company_id']); $companyManager = CompanyManager::getInstance($this->config, $this->args); $companyDto = $companyManager->selectByPK($selected_company_id); if (!isset($companyDto)) { $jsonArr = array('status' => "err", "errText" => "System Error: Company is not exist!"); echo json_encode($jsonArr); return false; } $itemManager->copyItem($copied_item_id, $selected_company_id, $item_position); $jsonArr = array('status' => "ok"); echo json_encode($jsonArr); return true; }
public function load() { $customer = $this->getCustomer(); $vipCustomer = false; if (isset($customer)) { $userManager = UserManager::getInstance($this->config, $this->args); $vipCustomer = $userManager->isVipAndVipEnabled($customer); } if ($vipCustomer) { $pccDiscount = floatval($this->getCmsVar('vip_pc_configurator_discount')); } else { $pccDiscount = floatval($this->getCmsVar('pc_configurator_discount')); } $itemManager = ItemManager::getInstance($this->config, $this->args); if (isset($_REQUEST["item_id"])) { $item_id = $_REQUEST["item_id"]; } elseif ($this->args[0]) { $item_id = $this->args[0]; } $selectedItemDto = $itemManager->selectByPK($item_id); if (isset($selectedItemDto)) { $this->setDescriptionTagValue($selectedItemDto->getDisplayName()); $this->setKeywordsTagValue($selectedItemDto->getDisplayName()); $this->setTitleTagValue($selectedItemDto->getDisplayName()); } $userLevel = $this->getUserLevel(); $userId = $this->getUserId(); $itemDto = $itemManager->getItemsForOrder($item_id, $userId, $userLevel, true); $this->addParam('item_id', $item_id); if ($itemDto) { $itemManager->growItemShowsCountByOne($itemDto); $itemPicturesCount = $itemDto->getPicturesCount(); $this->addParam('item', $itemDto); //$this->addParam('userLevel', $userLevel); $this->addParam('itemManager', $itemManager); $this->addParam('itemPicturesCount', $itemPicturesCount); $this->addParam('itemPropertiesHierarchy', $itemManager->getItemProperties($item_id)); } if ($this->getUserLevel() === UserGroups::$ADMIN) { $this->initRootCategories(); } }
public function service() { $item_id = $this->secure($_REQUEST["item_id"]); $dealer_price_amd = intval($this->secure($_REQUEST["dealer_price_amd"])); $itemManager = ItemManager::getInstance($this->config, $this->args); $itemDto = $itemManager->selectByPK($item_id); if ($itemDto != null) { $dealer_price_usd = $itemManager->exchangeFromAMDToUSD($dealer_price_amd); $itemManager->changeItemDealerPrice($item_id, $dealer_price_usd); $itemManager->changeItemDealerPriceAmd($item_id, $dealer_price_amd); $itemDto = $itemManager->selectByPK($item_id); $jsonArr = array('status' => "ok", "item_id" => $item_id, "dealer_price_amd" => $itemDto->getDealerPriceAmd(), "dealer_price" => $itemDto->getDealerPrice()); echo json_encode($jsonArr); return true; } else { $jsonArr = array('status' => "err", "errText" => "System Error: Item does not exist!"); echo json_encode($jsonArr); return false; } }
public function service() { if (!isset($_REQUEST['item_id'])) { $jsonArr = array('status' => "err", "errText" => "Error: Item id must be specified!"); echo json_encode($jsonArr); return false; } $item_id = $this->secure($_REQUEST['item_id']); $itemManager = ItemManager::getInstance($this->config, $this->args); $itemDto = $itemManager->selectByPK($item_id); if (!isset($itemDto)) { $jsonArr = array('status' => "err", "errText" => "Error: Item does not exist! (id:{$item_id})"); echo json_encode($jsonArr); return false; } $this->setCookie('copied_item_id', $item_id); $jsonArr = array('status' => "ok"); echo json_encode($jsonArr); return true; }
public function service() { $item_id = $this->secure($_REQUEST["item_id"]); $spec = $_REQUEST["spec"]; $shortSpec = false; if (isset($_REQUEST["short_spec"])) { $shortSpec = true; } $itemManager = ItemManager::getInstance($this->config, $this->args); $itemDto = $itemManager->selectByPK($item_id); if ($itemDto != null) { $itemManager->updateTextField($item_id, $shortSpec ? "short_description" : "full_description", $spec); $jsonArr = array('status' => "ok", "item_id" => $item_id); echo json_encode($jsonArr); return true; } else { $jsonArr = array('status' => "err", "errText" => "System Error: Item does not exist!"); echo json_encode($jsonArr); return false; } }
private function addItemPicture($itemId) { $itemManager = ItemManager::getInstance($this->config, $this->args); $logoCheck = $this->checkInputFile('item_picture'); if ($logoCheck != 'ok') { $jsonArr = array('status' => "error", "errText" => $logoCheck); echo "<script>var l= new parent.ngs.AddRemoveItemPictureAction(); l.afterAction('" . json_encode($jsonArr) . "'); </script>"; return false; } $itemDto = $itemManager->selectByPK($itemId); $ret = $itemManager->addPicture($itemDto, 'item_picture'); if ($ret === true) { $jsonArr = array('status' => "ok", "item_id" => $itemId); echo "<script>var l= new parent.ngs.AddRemoveItemPictureAction(); l.afterAction('" . json_encode($jsonArr) . "'); </script>"; return true; } else { $jsonArr = array('status' => "error", "errText" => $ret); echo "<script>var l= new parent.ngs.AddRemoveItemPictureAction(); l.afterAction('" . json_encode($jsonArr) . "'); </script>"; return false; } }
public function getItemsOffsetAndLimit($search_text) { $vipCustomer = 0; if ($this->getUserLevel() === UserGroups::$USER) { $customer = $this->getCustomer(); $userManager = UserManager::getInstance($this->config, $this->args); $vipCustomer = $userManager->isVipAndVipEnabled($customer); } if ($vipCustomer) { $pc_configurator_discount = floatval($this->getCmsVar('vip_pc_configurator_discount')); } else { $pc_configurator_discount = floatval($this->getCmsVar('pc_configurator_discount')); } $this->addParam("pc_configurator_discount", $pc_configurator_discount); $itemManager = ItemManager::getInstance($this->config, $this->args); $load_more = false; $offset = 0; if (isset($_REQUEST['load_more'])) { $load_more = true; if (isset($_REQUEST['loaded_items_count'])) { $offset = intval($this->secure($_REQUEST['loaded_items_count'])); } } $this->addParam('load_more', $load_more); if (isset($_REQUEST['take_in_count_search_text']) && $_REQUEST['take_in_count_search_text'] == 1) { $this->addParam('only_update_component_container', 1); } $limit = 0; if (!$load_more) { $limit = $this->getSelectedSameItemsCount(); } $limit += intval($this->getCmsVar('pcc_load_more_count')); $itemsTotalCount = intval($itemManager->getPccItemsByCategoryFormulaCount($this->getRequiredCategoriesFormulasArray(), $search_text)); if ($offset + $limit < $itemsTotalCount) { $this->addParam("load_more_reach_to_end", 'false'); } else { $this->addParam("load_more_reach_to_end", 'true'); } return array($offset, $limit); }