コード例 #1
0
 public function service()
 {
     $company_id = intval($_REQUEST['company_id']);
     if ($this->getUserLevel() === UserGroups::$COMPANY) {
         $requestHistoryManager = RequestHistoryManager::getInstance($this->config, $this->args);
         $customerGivenRequestRecentCountByHours = $requestHistoryManager->getCustomerGivenRequestRecentCountByHours($this->getCustomerLogin(), 24, get_class());
         if ($customerGivenRequestRecentCountByHours > intval($this->getCmsVar('company_revert_price_limit'))) {
             $jsonArr = array('status' => "err", "errText" => $this->getPhrase(557) . ' ' . intval($this->getCmsVar('company_revert_price_limit')));
             echo json_encode($jsonArr);
             return false;
         }
     }
     $companiesPriceListManager = CompaniesPriceListManager::getInstance($this->config, $this->args);
     $ret = $companiesPriceListManager->removeCompanyLastPrice($company_id);
     if ($ret > 0) {
         $jsonArr = array('status' => "ok");
         echo json_encode($jsonArr);
         return true;
     } else {
         switch ($ret) {
             case -1:
                 $errMessage = "Price doesn't exist!";
                 break;
             default:
                 $errMessage = "You can not revert the price file! You have only 1 price file on pcstore.";
                 break;
         }
         $jsonArr = array('status' => "err", "errText" => "System Error: " . $errMessage);
         echo json_encode($jsonArr);
         return false;
     }
 }
コード例 #2
0
 public function load()
 {
     $companiesPriceListManager = CompaniesPriceListManager::getInstance($this->config, $this->args);
     $companyId = $_REQUEST['company_id'];
     $this->addParam("companiesPriceListManager", $companiesPriceListManager);
     $companiesZippedPricesByDaysNumber = $companiesPriceListManager->getCompaniesZippedPricesByDaysNumber($companyId);
     $groupCompaniesZippedPricesByCompanyId = $this->groupCompaniesZippedPricesByCompanyId($companiesZippedPricesByDaysNumber);
     $this->addParam("groupCompaniesZippedPricesByCompanyId", $groupCompaniesZippedPricesByCompanyId);
 }
コード例 #3
0
 /**
  * Initializes DB mappers
  *
  * @param object $config
  * @param object $args
  * @return
  */
 function __construct($config, $args)
 {
     $this->mapper = CompanyMapper::getInstance();
     $this->config = $config;
     $this->args = $args;
     $this->companyDealersManager = CompanyDealersManager::getInstance($this->config, $this->args);
     $this->requestHistoryManager = RequestHistoryManager::getInstance($this->config, $this->args);
     $this->companiesPriceListManager = CompaniesPriceListManager::getInstance($this->config, $this->args);
 }
コード例 #4
0
 public function service()
 {
     $companiesPriceListManager = CompaniesPriceListManager::getInstance($this->config, $this->args);
     $price_id = $this->secure($_REQUEST["price_id"]);
     $companiesPriceListManager->removeCompanyPrice($price_id);
     $jsonArr = array('status' => "ok");
     echo json_encode($jsonArr);
     return true;
 }
コード例 #5
0
 public function load()
 {
     $userLevel = $this->sessionManager->getUser()->getLevel();
     $companiesPriceListManager = CompaniesPriceListManager::getInstance($this->config, $this->args);
     $companyManager = CompanyManager::getInstance($this->config, $this->args);
     if ($userLevel === UserGroups::$COMPANY) {
         $companyId = $this->getUserId();
         $selectedCompanyId = $companyId;
         $companyExtendedProfileManager = CompanyExtendedProfileManager::getInstance($this->config, $this->args);
         $dto = $companyExtendedProfileManager->getByCompanyId($companyId);
         if (!isset($dto)) {
             $companyExtendedProfileManager->createDefaultExCompanyProfile($companyId);
         }
         $dto = $companyExtendedProfileManager->getByCompanyId($companyId);
         list($companyEmailServerLogins, $companyEmailServersEmailsCount) = $this->getCompanyEmailServerLogins($dto);
         $this->addParam("companyEmailServerLogins", $companyEmailServerLogins);
         $this->addParam("companyEmailServersEmailsCount", $companyEmailServersEmailsCount);
         $this->addParam("companyExProfileDto", $dto);
         $dealerEmails = trim($dto->getDealerEmails());
         $this->addParam("total_price_email_recipients_count", empty($dealerEmails) ? 0 : count(explode(';', $dealerEmails)));
         array_map('unlink', glob(HTDOCS_TMP_DIR_ATTACHMENTS . "/companies/" . $companyId . "/*"));
     } else {
         if ($userLevel === UserGroups::$ADMIN) {
             $allCompanies = $companyManager->getAllCompanies(true, true);
             $companiesIds = $companyManager->getCompaniesIdsArray($allCompanies);
             $companiesNames = $companyManager->getCompaniesNamesArray($allCompanies);
             if (isset($_REQUEST['selected_company'])) {
                 $selectedCompanyId = $this->secure($_REQUEST['selected_company']);
             } else {
                 $selectedCompanyId = $allCompanies[0]->getId();
             }
             $this->addParam("companiesIds", $companiesIds);
             $this->addParam("companiesNames", $companiesNames);
         }
     }
     $companyPrices = $companiesPriceListManager->getCompanyHistoryPricesOrderByDate($selectedCompanyId, 0, 50);
     $this->addParam("company_prices", $companyPrices);
     $this->addParam("selectedCompanyId", $selectedCompanyId);
     if (isset($_REQUEST['show_send_email_to_dealers']) && $_REQUEST['show_send_email_to_dealers'] == 1) {
         $this->addParam("show_send_email_to_dealers", 1);
     }
     $emailServersManager = EmailServersManager::getInstance($this->config, $this->args);
     $allEmailServers = $emailServersManager->selectAll();
     $this->addParam("allEmailServers", $allEmailServers);
 }
コード例 #6
0
ファイル: a.php プロジェクト: pars5555/pcstore
<?php

ini_set('display_errors', false);
if (!$_SERVER["DOCUMENT_ROOT"]) {
    $_SERVER = array();
    defined('__DIR__') or define('__DIR__', dirname(__FILE__));
    $_SERVER["DOCUMENT_ROOT"] = __DIR__ . "/../..";
    chdir($_SERVER["DOCUMENT_ROOT"]);
}
ini_set('memory_limit', '1G');
require_once $_SERVER["DOCUMENT_ROOT"] . "/conf/constants.php";
require_once CLASSES_PATH . "/framework/Dispatcher.class.php";
require_once CLASSES_PATH . "/loads/LoadMapper.class.php";
require_once CLASSES_PATH . "/util/db/DBMSFactory.class.php";
require_once CLASSES_PATH . "/managers/CompanyManager.class.php";
require_once CLASSES_PATH . "/managers/CompaniesPriceListManager.class.php";
$config = parse_ini_file(CONF_PATH . "/config.ini");
DBMSFactory::init($config);
$companiesPriceListManager = CompaniesPriceListManager::getInstance($config, null);
$companyIds = $_REQUEST['cid'];
$priceIndex = $_REQUEST['pi'];
$companyIdsArray = explode(',', $companyIds);
foreach ($companyIdsArray as $cid) {
    $companiesPriceListManager->cachePriceInTables($cid, $priceIndex);
}
コード例 #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 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');
     }
 }
コード例 #9
0
 public function addCustomerMessagesAfterLoginByPreviousPing($custDto, $userLevel, $previousPing)
 {
     if ($userLevel === UserGroups::$GUEST) {
         return false;
     }
     $custEmail = $custDto->getEmail();
     $companyDealersManager = CompanyDealersManager::getInstance($this->config, $this->args);
     $userCompaniesIdsArray = array();
     if ($userLevel === UserGroups::$USER) {
         $userCompaniesIdsArray = $companyDealersManager->getUserCompaniesIdsArray($custDto->getId());
     }
     if ($userLevel === UserGroups::$COMPANY || $userLevel === UserGroups::$ADMIN || !empty($userCompaniesIdsArray)) {
         //new prices after last ping
         $companiesPriceListManager = CompaniesPriceListManager::getInstance($this->config, $this->args);
         $allPricesAfterTime = $companiesPriceListManager->getAllPricesAfterTime($previousPing, $userCompaniesIdsArray);
         if (!empty($allPricesAfterTime)) {
             $pre = HTTP_PROTOCOL . HTTP_HOST;
             $massage = '';
             foreach ($allPricesAfterTime as $dto) {
                 $companyName = $dto->getCompanyName() . ' (`558`: ' . $dto->getUploadDateTime() . ')';
                 $companyId = $dto->getCompanyId();
                 $pricePath = HTTP_PROTOCOL . HTTP_HOST . '/price/last_price/' . $companyId;
                 $massage .= '<div><a href="' . $pricePath . '"><img src="' . $pre . '/images/small_logo/' . $companyId . '" style="vertical-align: middle;" /> ' . $companyName . '</a></div>';
             }
             $this->addCustomerMessage($custEmail, '540', $massage, 1, 'attention');
         }
     }
     //new added dealers messages for (company only)
     if ($userLevel === UserGroups::$COMPANY || $userLevel === UserGroups::$ADMIN) {
         $dealersAfterGivenDatetime = $companyDealersManager->getAfterGivenDatetime($userLevel === UserGroups::$ADMIN ? 0 : intval($custDto->getId()), $previousPing);
         if (!empty($dealersAfterGivenDatetime)) {
             $this->addCustomerMessage($custEmail, '543', '`541` ' . count($dealersAfterGivenDatetime) . '`542`', 1, 'attention');
         }
     }
     //alert to admin if dollar rate doeasn't match to config rate
     if ($userLevel === UserGroups::$ADMIN) {
         $cbaRatesManager = CbaRatesManager::getInstance($this->config, $this->args);
         $latestUSDExchange = $cbaRatesManager->getLatestUSDExchange();
         $us_dollar_exchange = floatval($this->getCmsVar('us_dollar_exchange'));
         $us_dollar_exchange_down = floatval($this->getCmsVar('us_dollar_exchange_down'));
         $pcstoreAverageUSDExchange = ($us_dollar_exchange + $us_dollar_exchange_down) / 2;
         $maxAllowedDollarDifferenceParcent = floatval($this->getCmsVar('admin_alert_if_cba_dollar_rate_is_more_than_percent'));
         if (abs($latestUSDExchange - $pcstoreAverageUSDExchange) / $latestUSDExchange > $maxAllowedDollarDifferenceParcent / 100) {
             $this->addCustomerMessage($custEmail, '483', 'Cba rate for USD Dollar ($) is: ' . $latestUSDExchange, 1, 'warning');
         }
     }
     //new added bonuses to user (users only)
     if ($userLevel === UserGroups::$USER) {
         $bonusHistoryManager = BonusHistoryManager::getInstance($this->config, $this->args);
         $userBonusesAfterGivenDatetime = $bonusHistoryManager->getUserBonusesAfterGivenDatetime($custDto->getId(), $previousPing);
         if (!empty($userBonusesAfterGivenDatetime)) {
             $pointSum = 0;
             foreach ($userBonusesAfterGivenDatetime as $bDto) {
                 $pointSum += intval($bDto->getPoints());
             }
             $pointSum = intval($pointSum);
             if ($pointSum > 0) {
                 $phraseId = '544';
             } else {
                 $phraseId = '548';
             }
             $this->addCustomerMessage($custEmail, '545', '`' . $phraseId . '` ' . strval(intval(abs($pointSum))) . 'դր.`542`', 1, 'attention');
         }
     }
     //new added sub users (users only)
     if ($userLevel === UserGroups::$USER) {
         $userSubUsersManager = UserSubUsersManager::getInstance($this->config, $this->args);
         $rowsAddedAfterGivenDatetime = $userSubUsersManager->getRowsAddedAfterGivenDatetime($custDto->getId(), $previousPing);
         if (!empty($rowsAddedAfterGivenDatetime)) {
             $this->addCustomerMessage($custEmail, '546', strval(count($rowsAddedAfterGivenDatetime)) . ' `547`', 1, 'attention');
         }
     }
     $customerLocalEmailsManager = CustomerLocalEmailsManager::getInstance($this->config, $this->args);
     $unreadEmailsCount = $customerLocalEmailsManager->getCustomerInboxUnreadEmailsCountCustomerEmail($custEmail);
     if ($unreadEmailsCount > 0) {
         $customerAlertsManager = CustomerAlertsManager::getInstance($this->config, $this->args);
         $customerAlertsManager->addUnreadEmailsCustomerAlert($custEmail, $unreadEmailsCount);
     }
 }
コード例 #10
0
 public function load()
 {
     ini_set('max_execution_time', '120');
     ini_set('memory_limit', "1G");
     $importPriceManager = ImportPriceManager::getInstance($this->config, $this->args);
     $company_id = $_REQUEST['company_id'];
     $companiesPriceListManager = CompaniesPriceListManager::getInstance($this->config, $this->args);
     $companyLastPrices = $companiesPriceListManager->getCompanyLastPrices($company_id);
     $selectPriceIndex = 0;
     if (isset($_REQUEST['price_index'])) {
         $selectPriceIndex = intval($_REQUEST['price_index']);
     }
     $companyPriceNames = array();
     foreach ($companyLastPrices as $priceIndex => $priceDto) {
         $companyPriceNames[$priceIndex] = 'Price' . ($priceIndex + 1);
     }
     $this->addParam('price_names', $companyPriceNames);
     $this->addParam('selected_price_index', $selectPriceIndex);
     $companyPriceSheetsNames = $importPriceManager->getCompanyPriceSheetsNamesFromCache($company_id, $selectPriceIndex);
     $this->addParam('price_sheets_names', $companyPriceSheetsNames);
     $selectSheetIndex = 0;
     if (isset($_REQUEST['sheet_index'])) {
         $selectSheetIndex = intval($_REQUEST['sheet_index']);
     }
     $this->addParam('selected_sheet_index', $selectSheetIndex);
     $selected_rows_index = array();
     if (isset($_REQUEST['selected_rows_index']) && strlen($_REQUEST['selected_rows_index']) > 0) {
         $selected_rows_index = explode(',', $_REQUEST['selected_rows_index']);
     }
     $this->addParam('selected_rows_index', $selected_rows_index);
     $values = $importPriceManager->loadCompanyPriceFromCache($company_id, $selectPriceIndex, $selectSheetIndex);
     if (!$values) {
         $this->addParam('priceNotFound', true);
         return false;
     }
     $this->addParam('priceNotFound', false);
     /* foreach ($values as $rowKey => $row) {
        foreach ($row as $cellKey => $cellValue) {
        echo '[' . $rowKey . '][' . $cellKey . ']=' . $cellValue . ', ';
        }
        echo '<br>';
        }exit; */
     $this->addParam('priceColumnOptions', ImportPriceManager::$COLUMNS);
     $this->addParam('allColumns', array_keys($importPriceManager->getColumnsNamesMap()));
     $this->addParam('valuesByRows', $values);
     $itemModelColumnName = $importPriceManager->getItemModelColumnName();
     if (isset($itemModelColumnName)) {
         $this->addParam('modelColumnName', $itemModelColumnName);
     }
     $itemNameColumnName = $importPriceManager->getItemNameColumnName();
     $this->addParam('itemNameColumnName', $itemNameColumnName);
     $dealerPriceColumnName = $importPriceManager->getDealerPriceColumnName();
     if (isset($dealerPriceColumnName)) {
         $this->addParam('dealerPriceColumnName', $dealerPriceColumnName);
     }
     $dealerPriceAmdColumnName = $importPriceManager->getDealerPriceAmdColumnName();
     if (isset($dealerPriceAmdColumnName)) {
         $this->addParam('dealerPriceAmdColumnName', $dealerPriceAmdColumnName);
     }
     $vatPriceColumnName = $importPriceManager->getVatPriceColumnName();
     if (isset($vatPriceColumnName)) {
         $this->addParam('vatPriceColumnName', $vatPriceColumnName);
     }
     $vatPriceAmdColumnName = $importPriceManager->getVatPriceAmdColumnName();
     if (isset($vatPriceAmdColumnName)) {
         $this->addParam('vatPriceAmdColumnName', $vatPriceAmdColumnName);
     }
 }
コード例 #11
0
 private function sendEmailToDealersEmails($companyExProfiledto, $byMandrill = false)
 {
     $dealerEmailsText = $companyExProfiledto->getDealerEmails();
     $dealerEmailsArray = explode(';', $dealerEmailsText);
     $subject = $companyExProfiledto->getPriceEmailSubject();
     $body = stripslashes($companyExProfiledto->getPriceEmailBody());
     $fromEmail = $companyExProfiledto->getFromEmail();
     $companyName = $this->getCustomer()->getName();
     $isServiceCompany = $this->getUserLevel() == UserGroups::$SERVICE_COMPANY;
     $priceFiles = array();
     if ($isServiceCompany) {
         $companiesPriceListManager = ServiceCompaniesPriceListManager::getInstance($this->config, $this->args);
         $companyId = $companyExProfiledto->getServiceCompanyId();
         $companyLastPrices = $companiesPriceListManager->getCompanyLastPrices($companyId);
         if (!empty($companyLastPrices)) {
             foreach ($companyLastPrices as $key => $clp) {
                 $priceFiles[] = DATA_DIR . "/service_companies_prices/" . $companyId . '/' . $clp->getFileName() . '.' . $clp->getFileExt();
             }
         }
         $tmpSubdirectoryName = 'service_companies';
     } else {
         $companiesPriceListManager = CompaniesPriceListManager::getInstance($this->config, $this->args);
         $companyId = $companyExProfiledto->getCompanyId();
         $companyLastPrices = $companiesPriceListManager->getCompanyLastPrices($companyId);
         if (!empty($companyLastPrices)) {
             foreach ($companyLastPrices as $key => $clp) {
                 $priceFiles[] = DATA_DIR . "/companies_prices/" . $companyId . '/' . $clp->getFileName() . '.' . $clp->getFileExt();
             }
         }
         $tmpSubdirectoryName = 'companies';
     }
     $allEmailFileAttachments = array();
     foreach ($priceFiles as $key => $priceFile) {
         $pfnParts = explode('.', $priceFile);
         $priceFileExtention = end($pfnParts);
         if (file_exists($priceFile)) {
             $postfix = "";
             if ($key > 0) {
                 $postfix = '_' . ($key + 1);
             }
             $allEmailFileAttachments[$companyName . ' Pricelist' . $postfix . '.' . $priceFileExtention] = $priceFile;
         }
     }
     $additionalAttachedFiles = array();
     $dir = HTDOCS_TMP_DIR_ATTACHMENTS . '/' . $tmpSubdirectoryName . '/' . $companyId . '/';
     if (is_dir($dir)) {
         $additionalAttachedFiles = scandir($dir);
     }
     foreach ($additionalAttachedFiles as $file) {
         $fileFullPath = $dir . $file;
         if (is_file($fileFullPath)) {
             $path_parts = pathinfo($fileFullPath);
             $basename = $path_parts['basename'];
             $fileDisplayName = substr($basename, strpos($basename, '_') + 1);
             $allEmailFileAttachments[$fileDisplayName] = $fileFullPath;
         }
     }
     if ($byMandrill == true) {
         $mandrillEmailSenderManager = new MandrillEmailSenderManager($this->getCmsVar("mandrill_api_key"));
         $body .= '<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>';
         $body .= '<p style="font-size:10px"><a href="*|UNSUB:http://pcstore.am/unsub/' . ($isServiceCompany ? 'sc' : 's') . '/' . $companyId . '|*">Click here to unsubscribe.</a></p>';
         $res = $mandrillEmailSenderManager->sendHtmlEmail($dealerEmailsArray, $subject, $body, $fromEmail, $companyName, $allEmailFileAttachments, ($isServiceCompany ? 'service_company' : 'company') . '_' . $companyId);
         $sentSuccess = is_array($res);
     } else {
         $emailSenderManager = new EmailSenderManager('gmail');
         $res = $emailSenderManager->sendBulkEmailWithAttachmentsUsingPcstoreEmails($dealerEmailsArray, $subject, $body, array(), $allEmailFileAttachments, $fromEmail, $companyName);
         $sentSuccess = $res === true;
     }
     if ($sentSuccess !== true) {
         return $res;
     } else {
         $companyPriceEmailHistoryManager = CompanyPriceEmailHistoryManager::getInstance($this->config, $this->args);
         $companyPriceEmailHistoryManager->addRow($companyId, $isServiceCompany ? "service_company" : "company", $fromEmail, $dealerEmailsArray, $body, $subject, array_keys($allEmailFileAttachments));
     }
     return true;
 }
コード例 #12
0
 public function checkIfSamePriceAlreadyExists($companyId, $tmp_name)
 {
     $companiesPriceListManager = CompaniesPriceListManager::getInstance($this->config, $this->args);
     $companyLastPrices = $companiesPriceListManager->getCompanyLastPrices($companyId);
     $uploadedFileContentMd5 = md5_file($tmp_name);
     $duplicatedUpload = false;
     foreach ($companyLastPrices as $companyLastPrice) {
         $lastPriceContentMd5 = md5_file($companiesPriceListManager->getPricePath($companyLastPrice));
         if ($uploadedFileContentMd5 === $lastPriceContentMd5) {
             $duplicatedUpload = true;
             break;
         }
     }
     return $duplicatedUpload;
 }