예제 #1
0
 public function service()
 {
     $onlineUserManager = new OnlineUsersManager($this->config, $this->args);
     $customer = $this->getCustomer();
     if ($this->getUserLevel() !== UserGroups::$GUEST) {
         //add to online users table
         $customerEmail = $customer->getEmail();
         $newAdded = $onlineUserManager->addOnlineUser($this->getUserLevel(), $customer) > 0;
         if ($newAdded) {
             $customerMessagesAfterLoginManager = CustomerMessagesAfterLoginManager::getInstance($this->config, $this->args);
             $customerAfterLoginMessagesDtos = $customerMessagesAfterLoginManager->getCustomerMessages($customer->getEmail());
             $customerMessagesAfterLoginManager->incrementCustomerMessagesShowedCount($customerAfterLoginMessagesDtos);
             $customerAfterLoginMessagesDtosToArray = AbstractDto::dtosToArray($customerAfterLoginMessagesDtos);
         }
         //check user alerts
         $winUid = $_REQUEST['win_uid'];
         $customerAlertListManager = CustomerAlertListManager::getInstance($this->config, $this->args);
         $registeredCustomerAlertsDtosToArray = $customerAlertListManager->getRegisteredCustomerAlerts($customer, $winUid);
         $customerAlertsManager = CustomerAlertsManager::getInstance($this->config, $this->args);
         $customerMessagesDtos = $customerAlertsManager->getCustomerAlertsByCustomerLogin($customerEmail, $winUid);
         $customerMessagesToPhpArray = AbstractDto::dtosToArray($customerMessagesDtos);
     } else {
         //add guest in online users table
         $guest_online_table_id = $_COOKIE['guest_online_table_id'];
         if ($guest_online_table_id) {
             $onlineUser = $onlineUserManager->selectByPK($guest_online_table_id);
             if (isset($onlineUser)) {
                 $onlineUserManager->updateOnlineUserAttributes($onlineUser);
             } else {
                 $newId = $onlineUserManager->addOnlineUser($this->getUserLevel(), null);
                 if (isset($newId)) {
                     $this->setcookie('guest_online_table_id', $newId);
                 }
             }
         } else {
             $newId = $onlineUserManager->addOnlineUser($this->getUserLevel(), null);
             if (isset($newId)) {
                 $this->setcookie('guest_online_table_id', $newId);
             }
         }
     }
     $jsonArr = array('status' => "ok");
     if (!empty($registeredCustomerAlertsDtosToArray)) {
         $jsonArr['alerts'] = $registeredCustomerAlertsDtosToArray;
     }
     if (!empty($customerAfterLoginMessagesDtosToArray)) {
         $jsonArr['customer_after_login_messages'] = $customerAfterLoginMessagesDtos;
     }
     if (!empty($customerMessagesToPhpArray)) {
         $jsonArr['messages'] = $customerMessagesToPhpArray;
     }
     echo json_encode($jsonArr);
     return true;
 }
 public function getRegisteredCustomerAlerts($customerDto, $winUid)
 {
     $alerts_array = array();
     //company pending questions about item availability
     $customerType = UserManager::getCustomerTypeFromDto($customerDto);
     if ($customerType === UserGroups::$COMPANY) {
         $companyId = $customerDto->getId();
         $companyItemCheckListDtos = $this->companyItemCheckListManager->getCompanyQuestionsFromCustomers($companyId, $winUid);
         if (!empty($companyItemCheckListDtos)) {
             $alerts_array["check_items_availability"] = AbstractDto::dtosToArray($companyItemCheckListDtos);
             foreach ($companyItemCheckListDtos as $dto) {
                 $dto = $this->companyItemCheckListManager->selectByPK($dto->getId());
                 $sentToCompanyUid = $dto->getSentToCompanyUid();
                 if (empty($sentToCompanyUid)) {
                     $sentToCompanyUid = $winUid;
                 } else {
                     $sentToCompanyUid .= ',' . $winUid;
                 }
                 $this->companyItemCheckListManager->setSentToCompanyFieldValue($dto->getId(), $sentToCompanyUid);
             }
         }
     }
     //company replies about item availability for customers
     $customerEmail = $customerDto->getEmail();
     $companyRespondedItemAvailabilityDtos = $this->companyItemCheckListManager->getCustomerSentQuestionsResponses($customerEmail, $winUid);
     if (!empty($companyRespondedItemAvailabilityDtos)) {
         $alerts_array["responded_items_availability"] = AbstractDto::dtosToArray($companyRespondedItemAvailabilityDtos);
         foreach ($companyRespondedItemAvailabilityDtos as $dto) {
             $dto = $this->companyItemCheckListManager->selectByPK($dto->getId());
             $responseSentToCustomerUid = $dto->getResponseSentToCustomerUid();
             if (empty($responseSentToCustomerUid)) {
                 $responseSentToCustomerUid = $winUid;
             } else {
                 $responseSentToCustomerUid .= ',' . $winUid;
             }
             $this->companyItemCheckListManager->setResponseSentToCustomerFieldValue($dto->getId(), $responseSentToCustomerUid);
         }
     }
     return $alerts_array;
 }
예제 #3
0
 public function load()
 {
     $dbStructureManager = DbStructureManager::getInstance($this->config, $this->args);
     $tablesNames = $dbStructureManager->getTablesNames();
     $tablesNamesArrayUf = self::convertToUserFriendlyNamesArray($tablesNames);
     array_unshift($tablesNames, 0);
     array_unshift($tablesNamesArrayUf, 'Select Table...');
     $table_name = $this->secure($_REQUEST['table_name']);
     if (!empty($_REQUEST['page'])) {
         $page = intval($this->secure($_REQUEST['page']));
     } else {
         $page = 1;
     }
     if (isset($_REQUEST['order_by_field_name'])) {
         $order_by_field_name = $this->secure($_REQUEST['order_by_field_name']);
     }
     if (isset($_REQUEST['order_by_asc_desc'])) {
         $order_by_asc_desc = strtolower($this->secure($_REQUEST['order_by_asc_desc']));
     }
     $searchText = "";
     if (isset($_REQUEST['search_text'])) {
         $searchText = $_REQUEST['search_text'];
     }
     if (isset($_REQUEST['search_column_name'])) {
         $searchColumnName = $_REQUEST['search_column_name'];
     }
     $table_view_per_page_options = explode(',', $this->getCmsVar('table_view_per_page_options'));
     if (!empty($_REQUEST['rows_per_page'])) {
         $rows_per_page = intval($this->secure($_REQUEST['rows_per_page']));
     } else {
         $rows_per_page = intval($table_view_per_page_options[1]);
     }
     //$confirm_on_change_enable = $this->secure($_REQUEST['confirm_on_change_enable']);
     $this->addParam('table_view_per_page_options', $table_view_per_page_options);
     $this->addParam('all_table_names', $tablesNames);
     $this->addParam('all_table_names_uf', $tablesNamesArrayUf);
     $this->addParam('table_name', $table_name);
     $this->addParam('table_name_uf', self::generateUserFriendlyName($table_name));
     $this->addParam('rows_per_page', $rows_per_page);
     $this->addParam('page', $page);
     $this->addParam('search_text', $searchText);
     $this->addParam('search_column', $searchColumnName);
     $tableMapperClassName = $this->generateTableMapperClassName($table_name);
     if (!empty($tableMapperClassName)) {
         $tableMapper = call_user_func(array($tableMapperClassName, 'getInstance'));
         if ($tableMapper->getTableName() === $table_name) {
             //$tableManagerClassName = $this->generateTableManagerClassName($table_name);
             //$tableManager = & call_user_func(array($tableManagerClassName, 'getInstance'), $this->config, $this->args);
             $tableColumns = $dbStructureManager->getTableColumns($table_name);
             $tableColumnsNamesMapArray = $this->getColumnNamesArray($tableColumns);
             $tableColumnsNamesArray = array_keys($tableColumnsNamesMapArray);
             if (!isset($order_by_field_name) || !in_array($order_by_field_name, $tableColumnsNamesArray)) {
                 $order_by_field_name = '';
             }
             if (!isset($order_by_asc_desc) || $order_by_asc_desc != 'asc' && $order_by_asc_desc != 'desc') {
                 $order_by_asc_desc = 'asc';
             }
             $this->addParam('order_by_asc_desc', $order_by_asc_desc);
             $order_by_asc_desc_options = array('asc' => 'Ascending', 'desc' => 'Descending');
             $this->addParam('order_by_asc_desc_options', $order_by_asc_desc_options);
             $rowsCountWithoutLimit = $tableMapper->getAllByFiltersCount($searchText, $searchColumnName);
             $lastPage = intval($rowsCountWithoutLimit / $rows_per_page) + 1;
             if ($page > $lastPage) {
                 $page = $lastPage;
             }
             $selectAllByFilters = $tableMapper->selectAllByFilters(($page - 1) * $rows_per_page, $rows_per_page, $order_by_field_name, $order_by_asc_desc, $searchText, $searchColumnName);
             $tableColumnsNamesMapArrayUserFriendly = self::convertToUserFriendlyNamesArray($tableColumnsNamesMapArray);
             $this->addParam('tableColumnsNamesArray', $tableColumnsNamesMapArrayUserFriendly);
             array_unshift($tableColumnsNamesMapArrayUserFriendly, 'Default order');
             $this->addParam('tableColumnsNamesArrayForSorting', $tableColumnsNamesMapArrayUserFriendly);
             $this->addParam('table_exists', true);
             $this->addParam('order_by_field_name', $order_by_field_name);
             $this->addParam('rowDtos', AbstractDto::dtosToArray($selectAllByFilters));
             $this->addParam('tableColumns', $tableColumns);
             $this->addParam('tableColumnsNamesJoined', implode(',', $tableColumnsNamesArray));
             $this->addParam('totalRowsCount', $rowsCountWithoutLimit);
             $this->addParam('allPagesArray', range(1, $lastPage));
             $this->addParam('table_pk_name', $tableMapper->getPKFieldName());
         }
     }
 }
예제 #4
0
 public function load()
 {
     $this->setDescriptionTagValue('Companies that are registered in pcstore.am and their products are listed.');
     $this->setTitleTagValue('Pcstore Company List');
     $this->setKeywordsTagValue('Companies that are registered in pcstore.am and their products are listed.');
     $companyManager = CompanyManager::getInstance($this->config, $this->args);
     $serviceCompanyManager = ServiceCompanyManager::getInstance($this->config, $this->args);
     $companiesPriceListManager = CompaniesPriceListManager::getInstance($this->config, $this->args);
     $serviceCompaniesPriceListManager = ServiceCompaniesPriceListManager::getInstance($this->config, $this->args);
     $show_only_last_hours_values = array(0, 10, 24, 72, 168);
     $ph_all = $this->getPhrase(461);
     $ph_last = $this->getPhrase(456);
     $ph_hours = $this->getPhrase(455);
     $ph_days = $this->getPhrase(459);
     $ph_week = $this->getPhrase(460);
     $ph_updated = $this->getPhrase(457);
     $show_only_last_hours_names_phrase_ids_array = array(461, "`456` 10 `455` `457`", "`456` 24 `455` `457`", "`456` 3 `459` `457`", "`456` `460` `457`");
     $show_only_last_hours_names = array($ph_all, $ph_last . ' 10 ' . $ph_hours . ' ' . $ph_updated, $ph_last . ' 24 ' . $ph_hours . ' ' . $ph_updated, $ph_last . ' 3 ' . $ph_days . ' ' . $ph_updated, $ph_last . ' ' . $ph_week . ' ' . $ph_updated);
     $show_only_last_hours_selected = 0;
     if (isset($_REQUEST['show_only_last_hours_selected'])) {
         $show_only_last_hours_selected = intval($_REQUEST['show_only_last_hours_selected']);
     }
     $this->addParam("show_only_last_hours_values", $show_only_last_hours_values);
     $this->addParam("show_only_last_hours_names", $show_only_last_hours_names);
     $this->addParam("show_only_last_hours_names_phrase_ids_array", $show_only_last_hours_names_phrase_ids_array);
     $this->addParam("show_only_last_hours_selected", $show_only_last_hours_selected);
     $searchText = "";
     if (isset($_REQUEST['search_text'])) {
         $searchText = $this->secure($_REQUEST['search_text']);
     }
     $this->addParam("search_text", $searchText);
     $userLevel = $this->getUserLevel();
     $userId = $this->getUserId();
     $companiesList = array();
     $allServiceCompaniesWithBranches = $serviceCompanyManager->getAllServiceCompaniesWithBranches();
     foreach ($allServiceCompaniesWithBranches as $serviceCompanyDto) {
         $serviceCompanyDto->setShowPrice(1);
     }
     if ($userLevel == UserGroups::$USER) {
         $serviceCompanyDealersManager = ServiceCompanyDealersManager::getInstance($this->config, $this->args);
         $userserviceCompaniesIdsArray = $serviceCompanyDealersManager->getUserCompaniesIdsArray($userId);
         foreach ($allServiceCompaniesWithBranches as $serviceCompanyDto) {
             if (in_array($serviceCompanyDto->getId(), $userserviceCompaniesIdsArray)) {
                 $serviceCompanyDto->setShowPrice(1);
             } else {
                 $serviceCompanyDto->setShowPrice(0);
             }
         }
     }
     if ($userLevel == UserGroups::$COMPANY || $userLevel == UserGroups::$SERVICE_COMPANY) {
         $companiesList = $companyManager->getAllCompaniesByPriceHours($show_only_last_hours_selected, $searchText);
     }
     if ($userLevel == UserGroups::$USER) {
         $companiesList = $companyManager->getUserCompaniesJoindWithFullInfo($userId, $show_only_last_hours_selected, $searchText);
     }
     if ($userLevel == UserGroups::$ADMIN) {
         $companiesList = $companyManager->getAllCompaniesByPriceHours($show_only_last_hours_selected, $searchText, true, true);
     }
     $this->addParam('allCompanies', $companiesList);
     $this->addParam('allServiceCompanies', $allServiceCompaniesWithBranches);
     $allNonHiddenCompanies = $companyManager->getAllCompanies();
     $this->addParam('allNonHiddenCompanies', $allNonHiddenCompanies);
     $this->addParam('allCompaniesDtosToArray', json_encode(AbstractDto::dtosToArray($companiesList, array("id" => "id", "name" => "name", "rating" => "rating"))));
     $this->addParam('allServiceCompaniesDtosToArray', json_encode(AbstractDto::dtosToArray($allServiceCompaniesWithBranches, array("id" => "id", "name" => "name"))));
     // $this->addParam('userLevel', $userLevel);
     // $this->addParam('userGroupsUser', UserGroups::$USER);
     $companyBranchesManager = CompanyBranchesManager::getInstance($this->config, $this->args);
     $serviceCompanyBranchesManager = ServiceCompanyBranchesManager::getInstance($this->config, $this->args);
     $cids = $this->getCompanyIdsArray($companiesList);
     $scids = $this->getCompanyIdsArray($allServiceCompaniesWithBranches);
     $companiesBranchesDtos = $companyBranchesManager->getCompaniesBranches($cids);
     $serviceCompaniesBranchesDtos = $serviceCompanyBranchesManager->getServiceCompaniesBranches($scids);
     $this->addParam('allCompaniesBranchesDtosToArray', json_encode(AbstractDto::dtosToArray($companiesBranchesDtos)));
     $this->addParam('allServiceCompaniesBranchesDtosToArray', json_encode(AbstractDto::dtosToArray($serviceCompaniesBranchesDtos)));
     $this->addParam("companiesPriceListManager", $companiesPriceListManager);
     $this->addParam("serviceCompaniesPriceListManager", $serviceCompaniesPriceListManager);
     $companiesZippedPricesByDaysNumber = $companiesPriceListManager->getCompaniesZippedPricesByDaysNumber($cids, 360);
     $serviceCompaniesZippedPricesByDaysNumber = $serviceCompaniesPriceListManager->getCompaniesZippedPricesByDaysNumber($cids, 360);
     $groupCompaniesZippedPricesByCompanyId = $this->groupCompaniesZippedPricesByCompanyId($companiesZippedPricesByDaysNumber);
     $groupServiceCompaniesZippedPricesByCompanyId = $this->groupServiceCompaniesZippedPricesByCompanyId($serviceCompaniesZippedPricesByDaysNumber);
     $this->addParam("groupCompaniesZippedPricesByCompanyId", $groupCompaniesZippedPricesByCompanyId);
     $this->addParam("groupServiceCompaniesZippedPricesByCompanyId", $groupServiceCompaniesZippedPricesByCompanyId);
 }