コード例 #1
0
 public function service()
 {
     $serviceCompanyDealersManager = new ServiceCompanyDealersManager($this->config, $this->args);
     $userId = $serviceCompanyDealersManager->secure($_REQUEST["user_id"]);
     $serviceCompanyId = $this->sessionManager->getUser()->getId();
     if ($serviceCompanyDealersManager->getByCompanyIdAndUserId($userId, $serviceCompanyId)) {
         $serviceCompanyDealersManager->removeUserFromCompany($userId, $serviceCompanyId);
         $jsonArr = array('status' => "ok", "message" => "Dealer successfully removed from your company!");
         echo json_encode($jsonArr);
         return true;
     } else {
         $jsonArr = array('status' => "err", "errText" => "System Error: Dealer dosn't exist in your list!");
         echo json_encode($jsonArr);
         return false;
     }
 }
コード例 #2
0
 public function load()
 {
     $serviceCompanyDealersManager = ServiceCompanyDealersManager::getInstance($this->config, $this->args);
     $serviceCompanyId = $this->sessionManager->getUser()->getId();
     $dealers = $serviceCompanyDealersManager->getCompanyDealersJoindWithUsersFullInfo($serviceCompanyId);
     $this->addParam('dealers', $dealers);
 }
コード例 #3
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 ServiceCompanyDealersManager($config, $args);
     }
     return self::$instance;
 }
コード例 #4
0
 public function service()
 {
     $serviceCompanyManager = new ServiceCompanyManager($this->config, $this->args);
     $serviceCompanyDealersManager = new ServiceCompanyDealersManager($this->config, $this->args);
     $access_key = $this->secure($_REQUEST["access_key"]);
     $service_company_id = $this->secure($_REQUEST["service_company_id"]);
     $serviceCompany = $serviceCompanyManager->selectByPK($service_company_id);
     if (!isset($serviceCompany)) {
         $this->error(array("errText" => "System error! Company doesn't exists."));
     }
     if (strcasecmp($access_key, $serviceCompany->getAccessKey()) != 0) {
         $this->error(array("errText" => "Wrong access key!"));
     }
     $userId = $this->getUserId();
     $companyDealerDto = $serviceCompanyDealersManager->getByCompanyIdAndUserId($userId, $service_company_id);
     if (!isset($companyDealerDto)) {
         $serviceCompanyDealersManager->addUserToCompany($userId, $service_company_id);
         $message = $this->getPhrase(437) . ' ' . $serviceCompany->getName() . "'! \n";
         $this->ok(array("message" => $message));
     } else {
         $this->error(array("errText" => "You already have '" . $serviceCompany->getName() . "' company in your list!"));
     }
 }
コード例 #5
0
ファイル: UsersLoad.class.php プロジェクト: pars5555/pcstore
 public function load()
 {
     $userManager = UserManager::getInstance($this->config, $this->args);
     $allUsersDtos = $userManager->selectAll();
     $this->addParam("users", $allUsersDtos);
     $companyDealersManager = CompanyDealersManager::getInstance($this->config, $this->args);
     $serviceCompanyDealersManager = ServiceCompanyDealersManager::getInstance($this->config, $this->args);
     $allCompanyDealers = $companyDealersManager->getAllUsersCompaniesFull();
     $userCompanies = $this->getUserCompaniesArray($allCompanyDealers);
     $allServiceCompanyDealers = $serviceCompanyDealersManager->getAllUsersCompaniesFull();
     $userServiceCompanies = $this->getUserCompaniesArray($allServiceCompanyDealers);
     $this->addParam('userCompanies', $userCompanies);
     $this->addParam('userServiceCompanies', $userServiceCompanies);
     $this->addParam('visible_fields_names', array('id', 'email', 'name', 'lastName', 'phones', 'password', 'registeredDate', 'lastSmsValidationCode', 'vip'));
 }
コード例 #6
0
 public function load()
 {
     $loadPage = 0;
     if (isset($_REQUEST['load_page'])) {
         $loadPage = $_REQUEST['load_page'];
     }
     if ($loadPage == 1) {
         $this->addParam("page_loaded", 1);
         $userManager = UserManager::getInstance($this->config, $this->args);
         $allUsersDtos = $userManager->selectAll();
         $this->addParam("users", $allUsersDtos);
     } else {
         $this->addParam("page_loaded", 0);
     }
     $companyDealersManager = CompanyDealersManager::getInstance($this->config, $this->args);
     $serviceCompanyDealersManager = ServiceCompanyDealersManager::getInstance($this->config, $this->args);
     $allCompanyDealers = $companyDealersManager->getAllUsersCompaniesFull();
     $userCompanies = $this->getUserCompaniesArray($allCompanyDealers);
     $allServiceCompanyDealers = $serviceCompanyDealersManager->getAllUsersCompaniesFull();
     $userServiceCompanies = $this->getUserCompaniesArray($allServiceCompanyDealers);
     $this->addParam('userCompanies', $userCompanies);
     $this->addParam('userServiceCompanies', $userServiceCompanies);
 }
コード例 #7
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);
 }
コード例 #8
0
 public function addEventIntoEventsTableForOnlineCustomers($serviceCompany)
 {
     $customerAlertsManager = CustomerAlertsManager::getInstance($this->config, $this->args);
     $serviceCompanyDealersManager = ServiceCompanyDealersManager::getInstance($this->config, $this->args);
     $onlineUsersManager = OnlineUsersManager::getInstance($this->config, $this->args);
     $userManager = UserManager::getInstance($this->config, $this->args);
     $onlineRegisteredCustomers = $onlineUsersManager->getOnlineRegisteredCustomers();
     foreach ($onlineRegisteredCustomers as $onlineUsersDto) {
         $customerType = $userManager->getCustomerTypeByEmail($onlineUsersDto->getEmail());
         if ($customerType === UserGroups::$USER) {
             $userCustomer = $userManager->getUserByEmail($onlineUsersDto->getEmail());
             $dealerDto = $serviceCompanyDealersManager->getByCompanyIdAndUserId($userCustomer->getId(), $serviceCompany->getId());
             if (isset($dealerDto)) {
                 $customerAlertsManager->addPriceUploadCustomerAlert($onlineUsersDto->getEmail(), $serviceCompany, $onlineUsersDto->getLanguageCode());
             }
         } elseif ($customerType === UserGroups::$SERVICE_COMPANY || $customerType === UserGroups::$COMPANY || $customerType === UserGroups::$ADMIN) {
             $customerAlertsManager->addPriceUploadCustomerAlert($onlineUsersDto->getEmail(), $serviceCompany);
         }
     }
 }
コード例 #9
0
 public function service()
 {
     //todo check if user have access to given company
     $customer = $this->sessionManager->getUser();
     $userLevel = $customer->getLevel();
     $userId = $customer->getId();
     $companyManager = CompanyManager::getInstance($this->config, $this->args);
     $serviceCompanyManager = ServiceCompanyManager::getInstance($this->config, $this->args);
     if ($this->args[0] == "last_price") {
         $companyId = $this->args[1];
         if ($userLevel == UserGroups::$USER) {
             $companyDealersManager = CompanyDealersManager::getInstance($this->config, $this->args);
             $dto = $companyDealersManager->getByCompanyIdAndUserId($userId, $companyId);
             if (!isset($dto)) {
                 return false;
             }
         }
         $company = $companyManager->selectByPK($companyId);
         assert($company);
         $companiesPriceListManager = CompaniesPriceListManager::getInstance($this->config, $this->args);
         $companyLastPrices = $companiesPriceListManager->getCompanyLastPrices($companyId);
         if (!empty($companyLastPrices)) {
             if (count($companyLastPrices) === 1) {
                 $pricePath = DATA_DIR . "/companies_prices/" . $companyId . '/' . $companyLastPrices[0]->getFileName() . '.' . $companyLastPrices[0]->getFileExt();
                 if (file_exists($pricePath)) {
                     $companiesPriceListManager->downloadFile($pricePath, $company->getShortName() . "_" . $companyLastPrices[0]->getFileName());
                 } else {
                     echo "file not exists!";
                 }
             } else {
                 $filesPaths = array();
                 foreach ($companyLastPrices as $key => $clp) {
                     $fileName = $clp->getFileName() . '.' . $clp->getFileExt();
                     $filesPaths[] = array(DATA_DIR . "/companies_prices/" . $company->getId() . '/' . $fileName, $company->getShortName() . '_' . ($key + 1) . '_' . $fileName);
                 }
                 $uid = uniqid();
                 $this->createZip($filesPaths, DATA_DIR . "/temp/" . $uid . '.zip');
                 $companiesPriceListManager->downloadFile(DATA_DIR . "/temp/" . $uid . '.zip', $company->getShortName() . '_price');
                 unlink(DATA_DIR . "/temp/" . $uid . '.zip');
             }
         } else {
             echo "file not exists!";
         }
     }
     if ($this->args[0] == "service_last_price") {
         $companyId = $this->args[1];
         if ($userLevel == UserGroups::$USER) {
             $serviceCompanyDealersManager = ServiceCompanyDealersManager::getInstance($this->config, $this->args);
             $dto = $serviceCompanyDealersManager->getByCompanyIdAndUserId($userId, $companyId);
             if (!isset($dto)) {
                 return false;
             }
         }
         $company = $serviceCompanyManager->selectByPK($companyId);
         assert($company);
         $companiesPriceListManager = ServiceCompaniesPriceListManager::getInstance($this->config, $this->args);
         $companyLastPrices = $companiesPriceListManager->getCompanyLastPrices($companyId);
         if (!empty($companyLastPrices)) {
             if (count($companyLastPrices) === 1) {
                 $pricePath = DATA_DIR . "/service_companies_prices/" . $companyId . '/' . $companyLastPrices[0]->getFileName() . '.' . $companyLastPrices[0]->getFileExt();
                 if (file_exists($pricePath)) {
                     $companiesPriceListManager->downloadFile($pricePath, $company->getShortName() . "_" . $companyLastPrices[0]->getFileName());
                 } else {
                     echo "file not exists!";
                 }
             } else {
                 $filesPaths = array();
                 foreach ($companyLastPrices as $key => $clp) {
                     $fileName = $clp->getFileName() . '.' . $clp->getFileExt();
                     $filesPaths[] = array(DATA_DIR . "/service_companies_prices/" . $company->getId() . '/' . $fileName, $company->getShortName() . '_' . ($key + 1) . '_' . $fileName);
                 }
                 $uid = uniqid();
                 $this->createZip($filesPaths, DATA_DIR . "/temp/" . $uid . '.zip');
                 $companiesPriceListManager->downloadFile(DATA_DIR . "/temp/" . $uid . '.zip', $company->getShortName() . '_price');
                 unlink(DATA_DIR . "/temp/" . $uid . '.zip');
             }
         } else {
             echo "file not exists!";
         }
     }
     if ($this->args[0] == "zipped_price") {
         $zippedPriceId = $this->args[1];
         $companiesPriceListManager = CompaniesPriceListManager::getInstance($this->config, $this->args);
         $price = $companiesPriceListManager->selectByPK($zippedPriceId);
         $company_id = $price->getCompanyId();
         if ($userLevel == UserGroups::$USER) {
             $companyDealersManager = CompanyDealersManager::getInstance($this->config, $this->args);
             $dto = $companyDealersManager->getByCompanyIdAndUserId($userId, $company_id);
             if (!isset($dto)) {
                 return false;
             }
         }
         $company = $companyManager->selectByPK($company_id);
         assert($company);
         if ($price) {
             $pricePath = DATA_DIR . "/companies_prices/" . $price->getCompanyId() . '/' . $price->getFileName() . '.' . $price->getFileExt();
             if (file_exists($pricePath)) {
                 $companiesPriceListManager->downloadFile($pricePath, $company->getShortName() . "_" . $price->getFileName());
             } else {
                 echo "file not exists!";
             }
         } else {
             echo "file not exists!";
         }
     }
     if ($this->args[0] == "zipped_price_unzipped") {
         $zippedPriceId = $this->args[1];
         $companiesPriceListManager = CompaniesPriceListManager::getInstance($this->config, $this->args);
         $price = $companiesPriceListManager->selectByPK($zippedPriceId);
         $company_id = $price->getCompanyId();
         if ($userLevel == UserGroups::$USER) {
             $companyDealersManager = CompanyDealersManager::getInstance($this->config, $this->args);
             $dto = $companyDealersManager->getByCompanyIdAndUserId($userId, $company_id);
             if (!isset($dto)) {
                 return false;
             }
         }
         $company = $companyManager->selectByPK($company_id);
         assert($company);
         if ($price) {
             $pricePath = DATA_DIR . "/companies_prices/" . $price->getCompanyId() . '/' . $price->getFileName() . '.' . $price->getFileExt();
             if (file_exists($pricePath)) {
                 $unzipPriceFile = $companiesPriceListManager->unzipFile($pricePath);
                 if (count($unzipPriceFile) === 1) {
                     $companiesPriceListManager->downloadFile($unzipPriceFile[0], $company->getShortName() . "_" . $price->getFileName());
                 } else {
                     $companiesPriceListManager->downloadFile($pricePath, $company->getShortName() . "_" . $price->getFileName());
                 }
             } else {
                 echo "file not exists!";
             }
         } else {
             echo "file not exists!";
         }
     }
     if ($this->args[0] == "service_zipped_price_unzipped") {
         $zippedPriceId = $this->args[1];
         $companiesPriceListManager = ServiceCompaniesPriceListManager::getInstance($this->config, $this->args);
         $price = $companiesPriceListManager->selectByPK($zippedPriceId);
         $company_id = $price->getServiceCompanyId();
         if ($userLevel == UserGroups::$USER) {
             $serviceCompanyDealersManager = ServiceCompanyDealersManager::getInstance($this->config, $this->args);
             $dto = $serviceCompanyDealersManager->getByCompanyIdAndUserId($userId, $company_id);
             if (!isset($dto)) {
                 return false;
             }
         }
         $company = $serviceCompanyManager->selectByPK($company_id);
         assert($company);
         if ($price) {
             $pricePath = DATA_DIR . "/service_companies_prices/" . $price->getServiceCompanyId() . '/' . $price->getFileName() . '.' . $price->getFileExt();
             if (file_exists($pricePath)) {
                 $unzipPriceFile = $companiesPriceListManager->unzipFile($pricePath);
                 if (count($unzipPriceFile) === 1) {
                     $companiesPriceListManager->downloadFile($unzipPriceFile[0], $company->getShortName() . "_" . $price->getFileName());
                 } else {
                     $companiesPriceListManager->downloadFile($pricePath, $company->getShortName() . "_" . $price->getFileName());
                 }
             } else {
                 echo "file not exists!";
             }
         } else {
             echo "file not exists!";
         }
     }
     if ($this->args[0] == "all_zipped_prices") {
         $companiesList = array();
         if ($userLevel == UserGroups::$COMPANY) {
             $companiesList = $companyManager->getAllCompaniesByPriceHours();
         }
         if ($userLevel == UserGroups::$USER) {
             $companiesList = $companyManager->getUserCompaniesJoindWithFullInfo($userId);
         }
         if ($userLevel == UserGroups::$ADMIN) {
             $companiesList = $companyManager->getAllCompaniesByPriceHours(0, "", true, true);
         }
         $filesPaths = array();
         $companiesPriceListManager = CompaniesPriceListManager::getInstance($this->config, $this->args);
         foreach ($companiesList as $company) {
             $companyLastPrices = $companiesPriceListManager->getCompanyLastPrices($company->getId());
             foreach ($companyLastPrices as $key => $companyLastPrice) {
                 $fileName = $companyLastPrice->getFileName() . '.' . $companyLastPrice->getFileExt();
                 $filesPaths[] = array(DATA_DIR . "/companies_prices/" . $company->getId() . '/' . $fileName, $company->getShortName() . '_' . $fileName . '_' . ($key + 1));
             }
         }
         $uid = uniqid();
         $this->createZip($filesPaths, DATA_DIR . "/temp/" . $uid . '.zip');
         $companiesPriceListManager->downloadFile(DATA_DIR . "/temp/" . $uid . '.zip', 'all');
         unlink(DATA_DIR . "/temp/" . $uid . '.zip');
     }
 }