public function service() { $action = $_REQUEST['action']; $companyBranchesManager = CompanyBranchesManager::getInstance($this->config, $this->args); if ($action == 'add') { $branch_address = $this->secure($_REQUEST['branch_address']); $branch_region = $this->secure($_REQUEST['branch_region']); $branch_zip = $this->secure($_REQUEST['branch_zip']); if (empty($branch_address)) { $this->error(array('errMsg' => 'Branch address is empty!')); } if ($this->getUserLevel() !== UserGroups::$COMPANY) { $this->error(array('errMsg' => 'System Error: this action is for only companies!')); } $br_id = $companyBranchesManager->addBranch($this->getUserId(), $branch_address, strtolower($branch_region), $branch_zip); } if ($action == 'delete') { $branch_id = $this->secure($_REQUEST['branch_id']); $companyBranchesManager->deleteByPK($branch_id); } $this->ok(array('selected_branch_id' => $br_id)); }
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); }
public function createDefaultExCompanyProfile($companyId) { $dto = $this->mapper->createDto(); $dto->setCompanyId($companyId); $companyManager = CompanyManager::getInstance($this->config, $this->args); $companyBranchesManager = CompanyBranchesManager::getInstance($this->config, $this->args); $companyDto = $companyManager->selectByPK($companyId); $companyBranches = $companyBranchesManager->getCompaniesBranches($companyId); list($phones, $addresses) = $this->getCompanyPhonesAndAddressesFromBranches($companyBranches); $emailBodyTemplate = $this->getPhrase(467); $emailBody = str_replace(array('{company_access_code}', '{company_id}', '{company_addresses}', '{company_phones}'), array($companyDto->getAccessKey(), $companyId, implode('<br>', $addresses), implode('<br>', $phones)), $emailBodyTemplate); $dto->setPriceEmailBody($emailBody); $dto->setPriceEmailSubject($companyDto->getName() . ' Price'); $this->mapper->insertDto($dto); }
public function updateCompanyProfileFieldsById($id, $company_branch_id, $name, $change_pass, $new_pass, $phone1, $phone2, $phone3, $address, $zip, $region, $working_days, $working_hours, $dealers_access_key, $url, $sms_receive_number, $sms_receive_weekdays, $sms_receive_time_start, $sms_to_duration_minutes, $receive_email_on_stock_update, $lng, $lat) { $companyDto = $this->selectByPK($id); $companyDto->setName($name); if ($change_pass) { $companyDto->setPassword($new_pass); } $phonesArray = array(); if (!empty($phone1)) { $phonesArray[] = $phone1; } if (!empty($phone2)) { $phonesArray[] = $phone2; } if (!empty($phone3)) { $phonesArray[] = $phone3; } $phones = implode(',', $phonesArray); $companyBranchesManager = CompanyBranchesManager::getInstance($this->config, $this->args); $companyBranchesManager->setBranchFields($company_branch_id, $phones, $address, $region, $working_days, $working_hours, $zip, $lng, $lat); $companyDto->setAccessKey($dealers_access_key); $companyDto->setUrl($url); $companyDto->setPriceUploadSmsPhoneNumber($sms_receive_number); $companyDto->setSmsReceiveWeekdays($sms_receive_weekdays); $companyDto->setSmsReceiveTimeStart($sms_receive_time_start); $companyDto->setSmsToDurationMinutes($sms_to_duration_minutes); $companyDto->setReceiveEmailOnStockUpdate($receive_email_on_stock_update); $this->mapper->updateByPK($companyDto); }