Пример #1
0
 /**
  * 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 CreditManager($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);
 }
Пример #4
0
 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);
 }
Пример #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));
         }
     }
 }
Пример #6
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
include_once "./Manager/ConnectionManager.php";
include_once "./Manager/ProductManager.php";
include_once "./Manager/CustomerManager.php";
include_once "./Manager/CreditManager.php";
$customerMgr = new CustomerManager();
$creditMgr = new CreditManager();
$productMgr = new ProductManager();
$email = '';
$key = '';
if (isset($_GET['email'])) {
    $email = $_GET['email'];
}
if (isset($_GET['key'])) {
    $key = $_GET['key'];
}
$invitation_link = $customerMgr->getInvitationLink($email);
$retrieved_key = substr($invitation_link, strpos($invitation_link, "=") + 1);
if (md5($retrieved_key) === $key) {
    session_start();
    $customerMgr->activateAccount($email);
    $_SESSION["userid"] = $email;
    $form_data['status'] = 'success';
    $form_data['message'] = "";
    //Add credit to the new signed-up account if there is credit sender information in session
    if (isset($_COOKIE["sender_email"])) {
        $sender_email = $_COOKIE["sender_email"];
        $creditMgr->addCredit($sender_email, $email);
Пример #7
0
 public function service()
 {
     $this->initManagers();
     list($cho_include_vat, $cho_do_shipping, $cho_shipping_recipient_name, $cho_shipping_address, $cho_shipping_region, $cho_shipping_tel, $cho_shipping_cell, $billing_is_different_checkbox, $cho_billing_recipient_name, $cho_billing_address, $cho_billing_region, $cho_billing_tel, $cho_billing_cell, $cho_payment_type, $cho_apply_user_points, $cho_credit_supplier_id, $cho_selected_deposit_amount, $cho_selected_credit_months, $metadataObject) = $this->checkoutManager->initShippingParamsFromRequest();
     $userTypeString = $this->getUserLevelString();
     $customer = $this->getCustomer();
     $userEmail = $customer->getEmail();
     $dollarExchange = $this->getCmsVar("us_dollar_exchange");
     $paymentType = $cho_payment_type;
     $userLevel = $this->getUserLevel();
     $customerCurrentCart = $this->customerCartManager->getCustomerCart($userEmail, $this->getUserId(), $userLevel);
     $calcCartTotalDealerPrice = $this->customerCartManager->calcCartTotalDealerPrice($customerCurrentCart, $cho_include_vat);
     $groupedCartItems = $this->customerCartManager->groupBundleItemsInArray($customerCurrentCart);
     $allItemsAreAvailable = $this->customerCartManager->areAllItemsAvailableInCustomerCart($groupedCartItems);
     if (!$allItemsAreAvailable) {
         $jsonArr = array('status' => "err", "message" => 'Some item(s) are missing!');
         echo json_encode($jsonArr);
         return false;
     }
     //calculating deals discounts
     //all cart items, bundle items grouped in sub array
     $cartTotalDealsDiscountAMD = 0;
     $existingDealsPromoCodes = "";
     if (!empty($_REQUEST['cho_promo_codes'])) {
         $checkoutManager = CheckoutManager::getInstance($this->config, $this->args);
         $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;
         $existingDealsPromoCodes = implode(',', $existingDealsPromoCodesArray);
         $cartTotalDealsDiscountAMD = $checkoutManager->getCartTotalDealsDiscountAMD($groupedCartItems);
     }
     list($grandTotalAMD, $grandTotalUSD) = $this->customerCartManager->calcCartTotal($groupedCartItems, true, $userLevel, $cho_include_vat);
     if ($grandTotalAMD < intval($this->getCmsVar("minimum_order_amount_amd"))) {
         $jsonArr = array('status' => "err", "message" => $this->getPhrase(420) . $this->getCmsVar("minimum_order_amount_amd"));
         echo json_encode($jsonArr);
         return false;
     }
     $shippingCost = 0;
     if ($cho_do_shipping != 1) {
         $cho_billing_cell = $this->secure($_REQUEST['send_to_cell_phone']);
     } else {
         $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;
         }
     }
     if ($shippingCost == -1) {
         $jsonArr = array('status' => "err", "message" => 'Shipping is not available!');
         echo json_encode($jsonArr);
         return false;
     }
     $usablePoints = 0;
     if ($userLevel === UserGroups::$USER) {
         $grandTotalAMDWithShipping = $grandTotalAMD + $shippingCost;
         $userPoints = $customer->getPoints();
         if ($userPoints > 0 && $grandTotalAMDWithShipping > 0 && $cho_apply_user_points == 1) {
             if ($userPoints > $grandTotalAMDWithShipping) {
                 $usablePoints = $grandTotalAMDWithShipping;
             } else {
                 $usablePoints = $userPoints;
             }
         }
     }
     //start order confirming
     $orderId = $this->ordersManager->addOrder($userEmail, $calcCartTotalDealerPrice, $cho_shipping_tel, $cho_billing_tel, $cho_shipping_cell, $cho_billing_cell, $paymentType, $userTypeString, $dollarExchange, $cho_do_shipping, $cho_shipping_address, $cho_billing_address, $cho_shipping_region, $cho_shipping_recipient_name, $cho_billing_recipient_name, $cho_billing_region, $billing_is_different_checkbox != '1', $usablePoints, $shippingCost, $grandTotalAMD, $grandTotalUSD, $existingDealsPromoCodes, $cartTotalDealsDiscountAMD, $cho_include_vat, $metadataObject);
     $this->orderDetailsManager->addOrderDetails($orderId, $userEmail, $this->getUser(), $cho_include_vat);
     //reduce user point if any used
     if ($usablePoints > 0) {
         $userManager = UserManager::getInstance($this->config, $this->args);
         $description = "User points used to pay for order numer {$orderId}.";
         $userManager->subtractUserPoints($this->getUserId(), $usablePoints, $description);
     }
     if ($paymentType == 'credit') {
         $this->creditOrdersManager = CreditOrdersManager::getInstance($this->config, $this->args);
         $creditSuppliersManager = CreditSuppliersManager::getInstance($this->config, $this->args);
         $creditSupplierDto = $creditSuppliersManager->selectByPK($cho_credit_supplier_id);
         $annualInterestPercent = floatval($creditSupplierDto->getAnnualInterestPercent());
         $annualInterestPercent += floatval($creditSupplierDto->getAnnualCommision());
         $commission = $creditSupplierDto->getCommission();
         $creditMonthlyPayment = CreditManager::calcCredit($grandTotalAMD, $cho_selected_deposit_amount, $annualInterestPercent, $cho_selected_credit_months, $commission);
         $this->creditOrdersManager->addCreditOrder($orderId, $cho_selected_deposit_amount, $cho_credit_supplier_id, $cho_selected_credit_months, $annualInterestPercent, $creditMonthlyPayment);
     }
     $this->customerCartManager->emptyCustomerCart($userEmail);
     $this->emailOrderDetails($orderId);
     if (isset($validPromoDiscount)) {
         $discountPromoCodesManager = DiscountPromoCodesManager::getInstance($this->config, $this->args);
         $discountDto = $discountPromoCodesManager->getByPromoCode($validPromoDiscount);
         if ($discountDto) {
             $discountDto->setUsed(1);
             $discountPromoCodesManager->updateByPK($discountDto);
         }
     }
     $jsonArr = array('status' => "ok", "order_id" => $orderId);
     echo json_encode($jsonArr);
     return true;
 }
Пример #8
0
 * and open the template in the editor.
 */
include_once "./Manager/ConnectionManager.php";
include_once "./Manager/ProductManager.php";
include_once "./Manager/CustomerManager.php";
include_once "./Manager/CreditManager.php";
$errors = array();
//To store errors
$form_data = array();
//Pass back the data to `form.php`
/* Validate the form on the server side */
$userid = addslashes(filter_input(INPUT_POST, 'userid'));
$pwd = addslashes(filter_input(INPUT_POST, 'pwdInput'));
$customerMgr = new CustomerManager();
$customer = $customerMgr->getCustomerByIDPassword($userid, $pwd);
$creditMgr = new CreditManager();
$productMgr = new ProductManager();
session_start();
//echo mysql_num_rows($resultSet);
if ($customer !== []) {
    $form_data['success'] = true;
    $_SESSION["userid"] = $userid;
    if (isset($_COOKIE["sender_email"])) {
        $sender_email = $_COOKIE["sender_email"];
        if ($sender_email !== $userid) {
            $has_received = $creditMgr->checkInvitationStatus($sender_email, $userid);
            if ($has_received === null) {
                $creditMgr->addCredit($sender_email, $userid);
                $customerMgr->updateCredit($userid, 10.0);
                setcookie('sender_email', '', time() - 1);
                $form_data['status'] = 'success';
Пример #9
0
$_SESSION["admin_id"] = "michael";
include 'protect/admin_protect.php';
include_once "./Manager/ConnectionManager.php";
include_once "./Manager/ProductManager.php";
include_once "./Manager/CreditManager.php";
include_once "./Manager/FdpManager.php";
include_once "./Manager/CustomerManager.php";
include_once "./Manager/PhotoManager.php";
include_once "./Manager/RewardManager.php";
include_once "./Manager/OrderManager.php";
include_once "./Manager/AddressManager.php";
$admin = $_SESSION["admin_id"];
$productMgr = new ProductManager();
$product_list = $productMgr->getAllProduct();
$no_of_products = sizeof($product_list);
$creditMgr = new CreditManager();
$total_no_invitation = $creditMgr->getNoOfInvitation();
$fdpMgr = new FdpManager();
$current_cutoff = $fdpMgr->getCutoff();
$current_charge = $fdpMgr->getCharge();
?>

<html>   
    <head>
        <script type="text/javascript" src="public_html/js/jquery-1.11.0.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.form/3.51/jquery.form.js"></script> 
        <script>
        $(window).load(function(){
            var hash = window.location.hash;
            if(hash != ''){
                $("#dashboard").attr('class','tab-pane fade');
Пример #10
0
<?php

include_once './Manager/ConnectionManager.php';
include_once './Manager/CustomerManager.php';
include_once './Manager/CreditManager.php';
/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
$customerMgr = new CustomerManager();
$creditMgr = new CreditManager();
if (isset($_GET['src']) && !empty($_GET['src'])) {
    #Construct sender invitation link
    $invitation_link = 'invite.php?src=' . $_GET['src'];
    #get sender information
    $sender = $customerMgr->getCustomerByInvitationLink($invitation_link);
    if ($sender === []) {
        #Situation 2: no such invitation exist. Redirect to index page with popup message
        $status = 'error';
        $message = "There's error in your friend's referral!";
        header("Location: index.php?status={$status}&message={$message}");
        exit;
    }
    session_start();
    $receiver_email = null;
    $sender_email = $sender['customer_id'];
    if (!empty($_SESSION["userid"])) {
        #Situation 3: browser contains login information
        $receiver_email = $_SESSION["userid"];
        if ($receiver_email == $sender_email) {
Пример #11
0
foreach ($checkoutList as $checkout) {
    $product = $productMgr->getProduct($checkout["productId"]);
    $item = [];
    $photoList = $photoMgr->getPhotos($product["product_id"]);
    $item["product_id"] = $product["product_id"];
    $item["product_name"] = $product["product_name"];
    $item["color"] = $checkout["color"];
    $item["thumbnail"] = $photoList[$item["color"]];
    $item["quantity"] = $checkout["quantity"];
    $item["price"] = $product["price"];
    $item["subtotal"] = $checkout["quantity"] * $product["price"];
    $item["add_to_cart_time"] = $checkout["create_time"];
    array_push($list, $item);
}
include_once "./templates/header2.php";
$creditMgr = new CreditManager();
$creditList = $creditMgr->getUnusedCreditListByReceiverId($userid);
?>
      
    <form id="paymentForm" action="https://securepayments.paypal.com/webapps/HostedSoleSolutionApp/webflow/sparta/hostedSoleSolutionProcess" method="post" class="form-horizontal">
        <input type="hidden" name="cmd" value="_hosted-payment">
        <input type="hidden" name="business" value="6USHCFXJ739JN">
        <input type="hidden" name="paymentaction" value="sale">
        <input type="hidden" name="return" value="https://gosg.net/success.php">
        <input type="hidden" name="currency_code" value="SGD">
        <div class="col-lg-12">
            <div class="page-header">
                 <font style="color:#008ba4;font-weight: bold; font-size:17px"><i class="fa fa-map-marker"></i> Shipping Address </font>
            </div>
        </div>
        <div class="col-lg-12 col-md-6">
Пример #12
0
use PayPal\Api\FundingInstrument;
use PayPal\Api\Transaction;
use PayPal\Api\RedirectUrls;
include_once __DIR__ . "/../../Manager/ConnectionManager.php";
include_once __DIR__ . "/../../Manager/RewardManager.php";
include_once __DIR__ . "/../../Manager/CreditManager.php";
include_once __DIR__ . "/../../Manager/CustomerManager.php";
include_once __DIR__ . "/../../Manager/OrderManager.php";
include_once __DIR__ . "/../../Manager/ProductManager.php";
if (!isset($_SESSION)) {
    session_start();
}
$userid = null;
$userid = $_SESSION["userid"];
$rewardMgr = new RewardManager();
$creditMgr = new CreditManager();
$customerMgr = new CustomerManager();
$orderMgr = new OrderManager();
$productMgr = new ProductManager();
// ### CreditCard
// A resource representing a credit card that can be
// used to fund a payment.
$card = new CreditCard();
//$card->setType("visa")
//   ->setNumber("4148529247832259")
//    ->setExpireMonth("11")
//    ->setExpireYear("2019")
//    ->setCvv2("012")
//   ->setFirstName("Joe")
//    ->setLastName("Shopper");
$creditcard_type = $_POST["creditcard"];