/**
  * Returns an singleton instance of this class
  *
  * @param object $config
  * @param object $args
  * @return
  */
 public static function getInstance($config, $args)
 {
     if (self::$instance == null) {
         self::$instance = new CreditSuppliersManager($config, $args);
     }
     return self::$instance;
 }
 public function load()
 {
     $payment_option_values = explode(',', $this->getCmsVar('payment_option_values'));
     $payment_options_display_names_ids = explode(',', $this->getCmsVar('payment_options_display_names_ids'));
     $this->addParam('payment_options_display_names_ids', $payment_options_display_names_ids);
     $this->addParam('payment_option_values', $payment_option_values);
     if (isset($_REQUEST['cho_payment_type']) && $_REQUEST['cho_payment_type'] == 'credit') {
         $checkoutManager = CheckoutManager::getInstance($this->config, $this->args);
         list($grandTotalAMD, $grandTotalUSD) = $checkoutManager->getCustomerCartGrandTotals($this->getCustomer(), $this->sessionManager->getUser(), $this->getUserLevel());
         $this->addParam("grandTotalAMD", $grandTotalAMD);
         $this->addParam("grandTotalUSD", $grandTotalUSD);
         //credit supplier
         $creditSuppliersManager = CreditSuppliersManager::getInstance($this->config, $this->args);
         $allCreditSuppliers = $creditSuppliersManager->getAllCreditSuppliers();
         $allCreditSuppliers = $creditSuppliersManager->getCreditSuppliersInMapArrayById($allCreditSuppliers);
         $creditSuppliersDisplayNamesIds = $creditSuppliersManager->getSuppliersDisplayNameIdsArray($allCreditSuppliers);
         $creditSuppliersDisplayNames = $this->getPhrases($creditSuppliersDisplayNamesIds);
         $defaultCreditSupplierDto = reset($allCreditSuppliers);
         $selected_credit_supplier_id = $defaultCreditSupplierDto->getId();
         if (isset($_REQUEST['cho_credit_supplier_id'])) {
             $selected_credit_supplier_id = $_REQUEST['cho_credit_supplier_id'];
         }
         $_REQUEST['cho_credit_supplier_id'] = $selected_credit_supplier_id;
         $this->addParam("creditSuppliersIds", array_keys($allCreditSuppliers));
         $this->addParam("creditSuppliersDisplayNames", $creditSuppliersDisplayNames);
         $selectedCreditSupplierDto = $allCreditSuppliers[$selected_credit_supplier_id];
         //credit supplier possible months
         $possibleCreditMonths = explode(',', $selectedCreditSupplierDto->getPossibleCreditMonths());
         $cho_selected_credit_months = $possibleCreditMonths[0];
         if (isset($_REQUEST['cho_selected_credit_months'])) {
             $cho_selected_credit_months = $_REQUEST['cho_selected_credit_months'];
         }
         if (!in_array($cho_selected_credit_months, $possibleCreditMonths)) {
             $cho_selected_credit_months = $possibleCreditMonths[0];
         }
         $_REQUEST['cho_selected_credit_months'] = $cho_selected_credit_months;
         $this->addParam("possibleCreditMonths", $possibleCreditMonths);
         //deposit amount
         $cho_selected_deposit_amount = 0;
         if (isset($_REQUEST['cho_selected_deposit_amount'])) {
             $cho_selected_deposit_amount = intval($this->secure($_REQUEST['cho_selected_deposit_amount']));
         }
         $_REQUEST['cho_selected_deposit_amount'] = $cho_selected_deposit_amount;
         //credit supplier interest
         $commission = $selectedCreditSupplierDto->getCommission();
         $annualInterestPercent = floatval($selectedCreditSupplierDto->getAnnualInterestPercent());
         $credit_supplier_annual_commision = floatval($selectedCreditSupplierDto->getAnnualCommision());
         $this->addParam("credit_supplier_interest_percent", $annualInterestPercent);
         $this->addParam("credit_supplier_annual_commision", $credit_supplier_annual_commision);
         //credit monthly payment calculation
         $creditManager = CreditManager::getInstance($this->config, $this->args);
         $monthlyPayment = $creditManager->calcCredit($grandTotalAMD, $cho_selected_deposit_amount, $annualInterestPercent + $credit_supplier_annual_commision, $cho_selected_credit_months, $commission);
         $this->addParam("credit_monthly_payment", round($monthlyPayment));
         $this->addParam("minimum_credit_amount", intval($selectedCreditSupplierDto->getMinimumCreditAmount()));
         $grandTotalAmdWithCommission = intval($grandTotalAMD / (1 - $commission / 100));
         $this->addParam("grandTotalAmdWithCommission", $grandTotalAmdWithCommission);
     }
     $this->addParam('req_params', $_REQUEST);
 }
 public function load()
 {
     if (isset($this->args['pcGrandTotalAmd']) && isset($this->args['pcGrandTotalUsd'])) {
         $_REQUEST['pcGrandTotalAmd'] = $this->args['pcGrandTotalAmd'];
         $_REQUEST['pcGrandTotalUsd'] = $this->args['pcGrandTotalUsd'];
     }
     //credit supplier
     $creditSuppliersManager = CreditSuppliersManager::getInstance($this->config, $this->args);
     $allCreditSuppliers = $creditSuppliersManager->getAllCreditSuppliers();
     $allCreditSuppliers = $creditSuppliersManager->getCreditSuppliersInMapArrayById($allCreditSuppliers);
     $creditSuppliersDisplayNamesIds = $creditSuppliersManager->getSuppliersDisplayNameIdsArray($allCreditSuppliers);
     $creditSuppliersDisplayNames = $this->getPhrases($creditSuppliersDisplayNamesIds);
     $defaultCreditSupplierDto = reset($allCreditSuppliers);
     $selected_credit_supplier_id = $defaultCreditSupplierDto->getId();
     if (isset($_REQUEST['pcc_credit_supplier_id'])) {
         $selected_credit_supplier_id = $_REQUEST['pcc_credit_supplier_id'];
     }
     $_REQUEST['pcc_credit_supplier_id'] = $selected_credit_supplier_id;
     $this->addParam("creditSuppliersIds", array_keys($allCreditSuppliers));
     $this->addParam("creditSuppliersDisplayNames", $creditSuppliersDisplayNames);
     $selectedCreditSupplierDto = $allCreditSuppliers[$selected_credit_supplier_id];
     //credit supplier possible months
     $possibleCreditMonths = explode(',', $selectedCreditSupplierDto->getPossibleCreditMonths());
     $pcc_selected_credit_months = $possibleCreditMonths[0];
     if (isset($_REQUEST['pcc_selected_credit_months'])) {
         $pcc_selected_credit_months = $_REQUEST['pcc_selected_credit_months'];
     }
     if (!in_array($pcc_selected_credit_months, $possibleCreditMonths)) {
         $pcc_selected_credit_months = $possibleCreditMonths[0];
     }
     $_REQUEST['pcc_selected_credit_months'] = $pcc_selected_credit_months;
     $this->addParam("possibleCreditMonths", $possibleCreditMonths);
     //deposit amount
     $pcc_selected_deposit_amount = 0;
     if (isset($_REQUEST['pcc_selected_deposit_amount'])) {
         $pcc_selected_deposit_amount = intval($_REQUEST['pcc_selected_deposit_amount']);
     }
     $_REQUEST['pcc_selected_deposit_amount'] = $pcc_selected_deposit_amount;
     //credit supplier interest
     $commission = $selectedCreditSupplierDto->getCommission();
     $annualInterestPercent = floatval($selectedCreditSupplierDto->getAnnualInterestPercent());
     $credit_supplier_annual_commision = floatval($selectedCreditSupplierDto->getAnnualCommision());
     $this->addParam("credit_supplier_interest_percent", $annualInterestPercent);
     $this->addParam("credit_supplier_annual_commision", $credit_supplier_annual_commision);
     //credit monthly payment calculation
     $creditManager = CreditManager::getInstance($this->config, $this->args);
     $grandTotalAmd = intval($this->secure($_REQUEST['pcGrandTotalAmd']));
     $grandTotalAmdWithCommission = intval($grandTotalAmd / (1 - $commission / 100));
     $monthlyPayment = $creditManager->calcCredit($grandTotalAmd, $pcc_selected_deposit_amount, $annualInterestPercent + $credit_supplier_annual_commision, $pcc_selected_credit_months, $commission);
     $this->addParam("credit_monthly_payment", round($monthlyPayment));
     $this->addParam("minimum_credit_amount", intval($selectedCreditSupplierDto->getMinimumCreditAmount()));
     $this->addParam('req_params', $_REQUEST);
     $this->addParam('grandTotalAmdWithCommission', $grandTotalAmdWithCommission);
 }
 public function load()
 {
     $customer = $this->getCustomer();
     $customerEmail = strtolower($customer->getEmail());
     $customerCartManager = CustomerCartManager::getInstance($this->config, $this->args);
     $checkoutManager = CheckoutManager::getInstance($this->config, $this->args);
     $bundleItemsManager = BundleItemsManager::getInstance($this->config, $this->args);
     $itemManager = ItemManager::getInstance($this->config, $this->args);
     $userLevel = $this->sessionManager->getUser()->getLevel();
     $user_id = $this->sessionManager->getUser()->getId();
     $cartItemsDtos = $customerCartManager->getCustomerCart($customerEmail, $user_id, $userLevel);
     $pv = $checkoutManager->getPriceVariety($cartItemsDtos, $userLevel);
     $discountAvailable = $checkoutManager->isDiscountAvailableForAtleastOneItem($cartItemsDtos);
     $groupedCartItems = $customerCartManager->groupBundleItemsInArray($cartItemsDtos);
     $cartChanges = $customerCartManager->getCustomerCartItemsChanges($groupedCartItems);
     $customerCartChangesMessages = $checkoutManager->getCustomerCartChangesMessages($cartChanges);
     if (!empty($customerCartChangesMessages)) {
         $this->addParam('customerMessages', $customerCartChangesMessages);
     }
     //all cart items, bundle items grouped in sub array
     $cartTotalDealsDiscountAMD = 0;
     if (!isset($_REQUEST['cho_payment_type']) || $_REQUEST['cho_payment_type'] != 'cash') {
         $_REQUEST['cho_promo_codes'] = '';
     }
     $cho_include_vat = isset($_REQUEST['cho_include_vat']) ? $this->secure($_REQUEST['cho_include_vat']) : null;
     if (isset($_REQUEST['cho_promo_codes']) && !empty($_REQUEST['cho_promo_codes'])) {
         $cho_promo_codes = $this->secure($_REQUEST['cho_promo_codes']);
         $cho_promo_codes_arrray = explode(',', $cho_promo_codes);
         $validPromoDiscount = $checkoutManager->applyAllItemsPromoOnCartItems($groupedCartItems, $cho_promo_codes_arrray, $cho_include_vat);
         $existingDealsPromoCodesArray = $checkoutManager->applyDealsDiscountsOnCartItems($groupedCartItems, $cho_promo_codes_arrray, $cho_include_vat);
         $existingDealsPromoCodesArray[] = $validPromoDiscount;
         $_REQUEST['cho_promo_codes'] = implode(',', $existingDealsPromoCodesArray);
         $cartTotalDealsDiscountAMD = $checkoutManager->getCartTotalDealsDiscountAMD($groupedCartItems);
         $this->addParam("cartTotalDealsDiscountAMD", $cartTotalDealsDiscountAMD);
     }
     list($grandTotalAMD, $grandTotalUSD) = $customerCartManager->calcCartTotal($groupedCartItems, true, $userLevel, $cho_include_vat);
     $allItemsAreAvailable = $customerCartManager->areAllItemsAvailableInCustomerCart($groupedCartItems);
     //discount available for at leat one item in the cart
     $this->addParam('discountAvailable', $discountAvailable);
     //priceVariety the price variety in customer cart. Can be 'amd', 'usd' or 'both';
     $this->addParam('priceVariety', $pv);
     $this->addParam('cartItems', $groupedCartItems);
     $this->addParam('itemManager', $itemManager);
     $this->addParam('checkoutManager', $checkoutManager);
     $this->addParam('allItemsAreAvailable', $allItemsAreAvailable);
     $this->addParam('emptyCart', empty($cartItemsDtos));
     $this->addParam('bundleItemsManager', $bundleItemsManager);
     //cart grand totla included discounts, this is the final value that customer should pay for his cart
     $this->addParam('grandTotalAMD', $grandTotalAMD);
     $this->addParam('grandTotalUSD', $grandTotalUSD);
     if (strtolower($_REQUEST['cho_shipping_region']) != 'yerevan' || $_REQUEST['billing_is_different_checkbox'] && strtolower($_REQUEST['cho_billing_region']) != 'yerevan') {
         $this->addParam('shipping_billing_region_ok', false);
     } else {
         $this->addParam('shipping_billing_region_ok', true);
     }
     $shippingCost = 0;
     if (isset($_REQUEST['cho_do_shipping']) && $_REQUEST['cho_do_shipping'] == 1) {
         $specialFeesManager = SpecialFeesManager::getInstance($this->config, $this->args);
         if ($grandTotalAMD < intval($this->getCmsVar('shipping_in_yerevan_free_amd_over'))) {
             $region = $this->secure($_REQUEST['cho_shipping_region']);
             $shippingCostDto = $specialFeesManager->getShippingCost($region);
             $shippingCost = intval(isset($shippingCostDto) ? intval($shippingCostDto->getPrice()) : -1);
         } else {
             $shippingCost = 0;
         }
         $this->addParam('shipping_cost', $shippingCost);
     }
     $grandTotalAMDWithShipping = intval($grandTotalAMD + ($shippingCost > 0 ? $shippingCost : 0));
     if ($userLevel === UserGroups::$USER) {
         $userPoints = $customer->getPoints();
         $usablePoints = 0;
         if ($userPoints > 0 && $grandTotalAMDWithShipping > 0) {
             $this->addParam('user_points_applicable', 'true');
             if ($userPoints > $grandTotalAMDWithShipping) {
                 $usablePoints = $grandTotalAMDWithShipping;
             } else {
                 $usablePoints = $userPoints;
             }
             $this->addParam('usablePoints', $usablePoints);
         }
     }
     if (isset($_REQUEST['cho_payment_type']) && $_REQUEST['cho_payment_type'] == 'credit') {
         $_REQUEST['cho_apply_user_points'] = 0;
     }
     if (isset($_REQUEST['cho_apply_user_points']) && $_REQUEST['cho_apply_user_points'] == 1) {
         $grandTotalAMDWithShipping -= $usablePoints;
     }
     $this->addParam('grandTotalAMDWithShipping', $grandTotalAMDWithShipping);
     $this->addParam('final_step', 'true');
     if (isset($_REQUEST['cho_payment_type']) && $_REQUEST['cho_payment_type'] == 'credit') {
         $cho_credit_supplier_id = $this->secure($_REQUEST['cho_credit_supplier_id']);
         $cho_selected_deposit_amount = $this->secure($_REQUEST['cho_selected_deposit_amount']);
         $cho_selected_credit_months = $this->secure($_REQUEST['cho_selected_credit_months']);
         $creditSuppliersManager = CreditSuppliersManager::getInstance($this->config, $this->args);
         $allCreditSuppliersDtos = $creditSuppliersManager->getAllCreditSuppliers();
         $creditSuppliersIds = $creditSuppliersManager->getSuppliersIdsArray($allCreditSuppliersDtos);
         $creditSuppliersInMapArrayById = $creditSuppliersManager->getCreditSuppliersInMapArrayById($allCreditSuppliersDtos);
         $creditSupplierDto = $creditSuppliersInMapArrayById[$cho_credit_supplier_id];
         //var_dump($creditSupplierDto);
         $creditSupplierDisplayName = $this->getPhrase($creditSupplierDto->getDisplayNameId());
         $this->addParam('creditSupplierDisplayName', $creditSupplierDisplayName);
         $creditManager = CreditManager::getInstance($this->config, $this->args);
         $commission = $creditSupplierDto->getCommission();
         $annualInterestPercent = floatval($creditSupplierDto->getAnnualInterestPercent());
         $annualInterestPercent += floatval($creditSupplierDto->getAnnualCommision());
         $monthlyPaymentAmount = $creditManager->calcCredit($grandTotalAMD, $cho_selected_deposit_amount, $annualInterestPercent, $cho_selected_credit_months, $commission);
         $this->addParam("monthlyPaymentAmount", round($monthlyPaymentAmount));
     }
     $this->addParam('req_params', $_REQUEST);
     $paymentType = $_REQUEST['cho_payment_type'];
     $payment_option_values = explode(',', $this->getCmsVar('payment_option_values'));
     $payment_options_display_names_ids = explode(',', $this->getCmsVar('payment_options_display_names_ids'));
     $index = array_search($paymentType, $payment_option_values);
     $paymentTypeDisplayNameId = $payment_options_display_names_ids[$index];
     $this->addParam('paymentTypeDisplayNameId', $paymentTypeDisplayNameId);
     $this->addParam('maxItemCartCount', intval($this->getCmsVar('max_item_cart_count')));
     $userManager = UserManager::getInstance($this->config, $this->args);
     $vipCustomer = $userManager->isVipAndVipEnabled($customer);
     $this->addParam('vip_enabled', $vipCustomer ? 1 : 0);
 }
Esempio n. 5
0
 public function load()
 {
     $this->addParam("searchLeftBarWidth", $this->getCmsVar("search_left_bar_width"));
     $itemManager = ItemManager::getInstance($this->config, $this->args);
     $this->setDescriptionTagValue('Serach any item you want. PC, Laptop, Tablet, Computer, Printer, Monitor...');
     $this->setTitleTagValue('Pcstore Search');
     if (isset($_COOKIE['copied_item_id'])) {
         $this->addParam('copied_item_id', $_COOKIE['copied_item_id']);
     }
     if (isset($this->args[0])) {
         $this->large_view_load_enable = true;
         $selectedItemId = $this->args[0];
         $this->addParam('selected_item_id', $selectedItemId);
     }
     $this->current_page_number = 1;
     if (isset($_REQUEST["spg"])) {
         $this->current_page_number = $_REQUEST["spg"];
     }
     $userLevel = $this->getUserLevel();
     $this->categoryManager = CategoryManager::getInstance($this->config, $this->args);
     $this->categoryHierarchyManager = CategoryHierarchyManager::getInstance($this->config, $this->args);
     $selectedCompanyId = $this->initCompaniesSelectionList();
     $selectedCategoryId = 0;
     if (!empty($_REQUEST["cid"])) {
         $selectedCategoryId = $this->secure($_REQUEST["cid"]);
     }
     $selected_category_property_ids = isset($_REQUEST["scpids"]) ? $this->secure($_REQUEST["scpids"]) : '';
     $groupedProperties = null;
     if (!empty($selected_category_property_ids)) {
         $this->addParam('selected_category_property_ids', $selected_category_property_ids);
         $selected_category_property_ids = explode(',', $selected_category_property_ids);
         $groupedProperties = $this->groupCategoryProperties($selected_category_property_ids);
     } else {
         $selected_category_property_ids = array();
         $groupedProperties = array();
     }
     $item_search_limit_rows = intval($this->getCmsVar("item_search_limit_rows"));
     $userId = $this->getUserId();
     $price_range_min = isset($_REQUEST["prmin"]) ? $this->secure($_REQUEST["prmin"]) : '';
     $price_range_max = isset($_REQUEST["prmax"]) ? $this->secure($_REQUEST["prmax"]) : '';
     $this->addParam('search_item_price_range_min_value', $price_range_min);
     $this->addParam('search_item_price_range_max_value', $price_range_max);
     if (!empty($price_range_min) && strlen($price_range_min) > 0) {
         $price_range_min = floatval($this->secure($_REQUEST["prmin"])) / floatval($this->getCmsVar('us_dollar_exchange'));
     }
     if (!empty($price_range_max) && strlen($price_range_max) > 0) {
         $price_range_max = floatval($this->secure($_REQUEST["prmax"])) / floatval($this->getCmsVar('us_dollar_exchange'));
     }
     $orderByFieldName = $this->initSortBySelectionList();
     if ($orderByFieldName === 'relevance') {
         $orderByFieldName = null;
     }
     $search_text = isset($_REQUEST["st"]) ? $this->secure($_REQUEST["st"]) : '';
     $this->addParam("search_text", $search_text);
     if (!empty($search_text)) {
         $cmsSearchRequestsManager = CmsSearchRequestsManager::getInstance($this->config, $this->args);
         $cmsSearchRequestsManager->addRow($search_text, date('Y-m-d H:i:s'), $_REQUEST['win_uid']);
     }
     $show_only_vat_items = 0;
     if (isset($_REQUEST['shov'])) {
         $show_only_vat_items = $this->secure($_REQUEST['shov']);
         $this->addParam('show_only_vat_items', 1);
     }
     $show_only_non_picture_items = null;
     if (isset($_REQUEST["show_only_non_picture_items"])) {
         $show_only_non_picture_items = intval($_REQUEST["show_only_non_picture_items"]);
         $this->addParam('show_only_non_picture_items', $show_only_non_picture_items);
     }
     $show_only_no_short_spec_items = null;
     if (isset($_REQUEST["show_only_no_short_spec_items"])) {
         $show_only_no_short_spec_items = intval($_REQUEST["show_only_no_short_spec_items"]);
         $this->addParam('show_only_no_short_spec_items', $show_only_no_short_spec_items);
     }
     $show_only_no_full_spec_items = null;
     if (isset($_REQUEST["show_only_no_full_spec_items"])) {
         $show_only_no_full_spec_items = intval($_REQUEST["show_only_no_full_spec_items"]);
         $this->addParam('show_only_no_full_spec_items', $show_only_no_full_spec_items);
     }
     searchStared:
     $offset = $item_search_limit_rows * ($this->current_page_number - 1);
     $foundItems = $itemManager->searchItemsByTitle($userId, $userLevel, $search_text, $selectedCompanyId, $price_range_min, $price_range_max, $selectedCategoryId, $groupedProperties, $show_only_vat_items, $show_only_non_picture_items, $show_only_no_short_spec_items, $show_only_no_full_spec_items, $offset, $item_search_limit_rows, $orderByFieldName);
     $itemsDtosOnlyCategories = $itemManager->searchItemsByTitleRowsCount($userId, $search_text, $selectedCompanyId, $price_range_min, $price_range_max, $selectedCategoryId, null, $show_only_vat_items, $show_only_non_picture_items, $show_only_no_short_spec_items, $show_only_no_full_spec_items);
     $this->totalItemsRowsCount = 0;
     $this->categories_count_array = array();
     $selectedCategoryGroupedSubProperties = array();
     $selectedCategorySubTreeIds = array();
     $propertyViewIsVisible = false;
     $selectedCategoryDto = $this->categoryManager->getCategoryById($selectedCategoryId);
     if ($selectedCategoryDto->getLastClickable() == 1) {
         $selectedCategoryGroupedSubProperties = $this->categoryHierarchyManager->getCategoryGroupedSubProperties($selectedCategoryId);
         $selectedCategorySubTreeIds = $this->categoryHierarchyManager->getCategorySubTreeIds($selectedCategoryId);
         $propertyViewIsVisible = true;
     }
     foreach ($itemsDtosOnlyCategories as $itemDto) {
         $categoriesIds = trim($itemDto->getCategoriesIds(), ',');
         $categoriesIdsArray = explode(',', $categoriesIds);
         $ItemIsVisible = true;
         foreach ($groupedProperties as $propertiesGroupStaticCategoryId => $propIdsArray) {
             if (!(empty($propIdsArray) || count(array_intersect($categoriesIdsArray, $propIdsArray)) > 0)) {
                 $ItemIsVisible = false;
                 break;
             }
         }
         if ($ItemIsVisible) {
             $this->totalItemsRowsCount++;
         }
         //here calculating categories count which is valid for only category menu items not properties
         if (!$propertyViewIsVisible) {
             foreach ($categoriesIdsArray as $catId) {
                 if (!in_array($catId, $selectedCategorySubTreeIds)) {
                     if (!array_key_exists($catId, $this->categories_count_array)) {
                         $this->categories_count_array[$catId] = 1;
                     } else {
                         $this->categories_count_array[$catId] += 1;
                     }
                 }
             }
         } else {
             //here calculating future selecting properties count
             foreach ($selectedCategoryGroupedSubProperties as $propertyGroupCategoryId => $propertiesIds) {
                 $isItemVisibleForCurrentlySelectedOtherPropertyGroup = true;
                 foreach ($groupedProperties as $propertiesGroupStaticCategoryId => $propIdsArray) {
                     if ($propertiesGroupStaticCategoryId == $propertyGroupCategoryId) {
                         continue;
                     }
                     if (!(empty($propIdsArray) || count(array_intersect($categoriesIdsArray, $propIdsArray)) > 0)) {
                         $isItemVisibleForCurrentlySelectedOtherPropertyGroup = false;
                         break;
                     }
                 }
                 foreach ($propertiesIds as $proertyId) {
                     if (in_array($proertyId, $selected_category_property_ids)) {
                         //this is for optimization
                         continue;
                     }
                     if ($isItemVisibleForCurrentlySelectedOtherPropertyGroup && in_array($proertyId, $categoriesIdsArray)) {
                         if (!array_key_exists($proertyId, $this->categories_count_array)) {
                             $this->categories_count_array[$proertyId] = 1;
                         } else {
                             $this->categories_count_array[$proertyId] += 1;
                         }
                     }
                 }
             }
         }
     }
     //if page number exceed last page number then go to last page
     if (count($foundItems) === 0 && $this->totalItemsRowsCount > 0) {
         $lastPageNumber = ceil($this->totalItemsRowsCount / $item_search_limit_rows);
         $this->current_page_number = $lastPageNumber;
         goto searchStared;
     }
     $this->addParam("foundItems", $foundItems);
     $this->addParam("itemManager", $itemManager);
     $this->addParam("totalItemsRowsCount", $this->totalItemsRowsCount);
     ///credit items calculation
     $creditManager = CreditManager::getInstance($this->config, $this->args);
     $creditSuppliersManager = CreditSuppliersManager::getInstance($this->config, $this->args);
     $allCreditSuppliersDtos = $creditSuppliersManager->getAllCreditSuppliers();
     $allCreditSuppliersDtos = $creditSuppliersManager->getCreditSuppliersInMapArrayById($allCreditSuppliersDtos);
     $creditPossibleMonths = $creditManager->getAllSuppliersCombinePossibleMonths($allCreditSuppliersDtos);
     $this->addParam("creditPossibleMonthsValues", $creditPossibleMonths);
     $this->addParam("defaultSelectedCreditMonths", end($creditPossibleMonths));
     $defaultCreditSupplierDto = reset($allCreditSuppliersDtos);
     $this->addParam("defaultSupplierCommission", floatval($defaultCreditSupplierDto->getCommission()));
     $this->addParam("defaultCreditInterestMonthlyRatio", floatval($defaultCreditSupplierDto->getAnnualInterestPercent() / 100 / 12 + $defaultCreditSupplierDto->getAnnualCommision() / 100 / 12));
     //categories
     if ($selectedCategoryDto->getLastClickable() == '0') {
         $itemCategoryModel = new ItemCategoryModel(!empty($selectedCategoryId) ? $selectedCategoryId : 0);
         $itemsCategoryMenuView = new ItemsCategoryMenuView($itemCategoryModel, $this->categories_count_array, $this->config, false);
         $this->addParam('itemsCategoryMenuView', $itemsCategoryMenuView);
     }
     //selected category properties
     $propertiesViews = array();
     if (isset($selectedCategoryId) && $this->categoryManager->getCategoryById($selectedCategoryId)->getLastClickable() == '1') {
         $propertiesHierarchyDtos = $this->categoryHierarchyManager->getCategoryChildren($selectedCategoryId);
         foreach ($propertiesHierarchyDtos as $propertyHierarchyDto) {
             $propertyView = new CategoryPropertyView($this->categoryManager, $this->categoryHierarchyManager, $this->categories_count_array, $propertyHierarchyDto->getChildId(), $selected_category_property_ids);
             $propertiesViews[] = $propertyView;
         }
     }
     $this->addParam("properties_views", $propertiesViews);
     $this->addParam('category_id', $selectedCategoryId);
     $this->addParam('category_dto', $selectedCategoryDto);
     if ($selectedCategoryId > 0) {
         $categoryFullPath = $this->categoryManager->getCategoryFullPath($selectedCategoryId);
         if (count($categoryFullPath) >= 1) {
             $this->addParam('category_path', $categoryFullPath);
             $this->addParam('itemSearchManager', ItemSearchManager::getInstance($this->config, $this->args));
         }
     }
 }
 private function emailOrderDetails($orderId)
 {
     $emailSenderManager = new EmailSenderManager('gmail');
     $customer = $this->getCustomer();
     $userManager = UserManager::getInstance($this->config, $this->args);
     $customerEmail = $userManager->getRealEmailAddressByUserDto($customer);
     $emailAccountsManager = EmailAccountsManager::getInstance($this->config, $this->args);
     $infoEmailAddress = $emailAccountsManager->getEmailAddressById('info');
     $recipients = array($customerEmail, $infoEmailAddress);
     $lname = $customer->getLastName();
     $userName = $customer->getName();
     if (isset($lname)) {
         $userName .= ' ' . $lname;
     }
     $orderJoinedDetailsDtos = $this->ordersManager->getOrderJoinedWithDetails($orderId);
     $goupedOrderJoinedDetailsDtos = $this->groupBundlesInOrderJoinedDetailsDtos($orderJoinedDetailsDtos);
     $paymentType = $orderJoinedDetailsDtos[0]->getPaymentType();
     $payment_option_values = explode(',', $this->getCmsVar('payment_option_values'));
     $payment_options_display_names_ids = explode(',', $this->getCmsVar('payment_options_display_names_ids'));
     $index = array_search($paymentType, $payment_option_values);
     $paymentTypeDisplayNameId = $payment_options_display_names_ids[$index];
     $subject = $this->getPhrase(299);
     if ($paymentType == 'credit') {
         $template = "customer_credit_order";
     } else {
         $template = "customer_cash_order";
     }
     $params = array("user_name" => $userName, "dtos" => $goupedOrderJoinedDetailsDtos, "itemManager" => $this->itemManager, "support_phone" => $this->getCmsVar('pcstore_support_phone_number'), 'paymentTypeDisplayNameId' => $paymentTypeDisplayNameId);
     if ($paymentType == 'credit') {
         $creditSuppliersManager = CreditSuppliersManager::getInstance($this->config, $this->args);
         $csid = $orderJoinedDetailsDtos[0]->getCreditOrdersCreditSupplierId();
         $creditSupplierDto = $creditSuppliersManager->selectByPK($csid);
         $commission = $creditSupplierDto->getCommission();
         $grandTotalAMD = intval($orderJoinedDetailsDtos[0]->getOrderTotalAmd());
         $grandTotalAmdWithCommission = intval($grandTotalAMD / (1 - $commission / 100));
         $params['grandTotalAmdWithCommission'] = $grandTotalAmdWithCommission;
     }
     $emailSenderManager->sendEmail('orders', $recipients, $subject, $template, $params, '', '', true, false);
 }