public function service() { if (isset($_REQUEST['number'])) { $number = $this->secure($_REQUEST['number']); $sentSmsManager = SentSmsManager::getInstance($this->config, $this->args); $number = SentSmsManager::getValidArmenianNumber($number); if ($number == null) { $jsonArr = array('status' => "err", "errText" => "Invalid cell phone number!", 'number_valid' => "false"); echo json_encode($jsonArr); return false; } $company = $this->getCustomer(); $lastSmsValidationCode = substr(uniqid(rand(), true), 0, 6); $companyManager = CompanyManager::getInstance($this->config, $this->args); $companyManager->setLastSmsValidationCode($company->getId(), $lastSmsValidationCode); $sentSmsManager->sendSmsToArmenia($number, $lastSmsValidationCode); $jsonArr = array('status' => "ok", 'number_valid' => "true"); echo json_encode($jsonArr); return true; } elseif (isset($_REQUEST['code'])) { $code = $this->secure($_REQUEST['code']); $company = $this->getCustomer(); $c = $company->getLastSmsValidationCode(); if ($code == $c) { $jsonArr = array('status' => "ok", 'code_valid' => "true"); echo json_encode($jsonArr); return true; } else { $jsonArr = array('status' => "err", "errText" => "Invalid sms code!", 'code_valid' => "false"); echo json_encode($jsonArr); return false; } } }
public function load() { $companyManager = CompanyManager::getInstance($this->config, $this->args); $customer = $this->sessionManager->getUser(); $userLevel = $customer->getLevel(); if ($userLevel == UserGroups::$ADMIN) { $allCompaniesDtos = $companyManager->getAllCompanies(true, true); } else { $allCompaniesDtos = array($companyManager->selectByPK($customer->getId())); } $allCompaniesNames = array(); $allCompaniesIds = array(); foreach ($allCompaniesDtos as $key => $company) { $allCompaniesNames[] = $company->getName(); $allCompaniesIds[] = $company->getId(); } if (isset($_REQUEST["company_id"])) { $selectedCompanyId = $this->secure($_REQUEST["company_id"]); } else { $selectedCompanyId = $allCompaniesIds[0]; } $this->addParam('selectedCompanyId', $selectedCompanyId); $this->addParam('allCompaniesNames', $allCompaniesNames); $this->addParam('allCompaniesIds', $allCompaniesIds); $itemManager = ItemManager::getInstance($this->config, $this->args); $allCompanyItems = $itemManager->getCompanyItems($selectedCompanyId, true); $this->addParam('company_items', $allCompanyItems); if (isset($_COOKIE['copied_item_id'])) { $this->addParam('copied_item_id', $_COOKIE['copied_item_id']); } $this->addParam('itemManager', $itemManager); }
public function service() { $companies_ids = $this->secure($_REQUEST['companies_ids']); $companies_ids = explode(',', $companies_ids); $int_companies_ids = array(); foreach ($companies_ids as $cid) { $c = intval($cid); if ($c > 0) { $int_companies_ids[] = $c; } } $companies_ids = implode(',', $int_companies_ids); $companyManager = CompanyManager::getInstance($this->config, $this->args); $companyManager->setInterestedCompaniesIdsForSms($this->getUserId(), $companies_ids); $company = $companyManager->selectByPK($this->getUserId()); $sms_receive_phone_number = $company->getPriceUploadSmsPhoneNumber(); if (empty($sms_receive_phone_number)) { $jsonArr = array('status' => "warning", "message" => $this->getPhrase(404)); echo json_encode($jsonArr); return false; } $jsonArr = array('status' => "ok"); echo json_encode($jsonArr); return true; }
public function load() { $companyManager = CompanyManager::getInstance($this->config, $this->args); $adminManager = AdminManager::getInstance($this->config, $this->args); $userManager = UserManager::getInstance($this->config, $this->args); $companyDealersManager = CompanyDealersManager::getInstance($this->config, $this->args); $allAdmins = $adminManager->selectAll(); if ($this->getUserLevel() === UserGroups::$COMPANY) { $allCompanies = $companyManager->getAllCompanies(); $companyDealersJoindWithUsersFullInfo = $companyDealersManager->getCompanyDealersJoindWithUsersFullInfo($this->getUserId()); $this->addParam('allCompanies', $allCompanies); $this->addParam('allDealers', $companyDealersJoindWithUsersFullInfo); $this->addParam('allAdmins', $allAdmins); } if ($this->getUserLevel() === UserGroups::$SERVICE_COMPANY) { $allCompanies = $companyManager->getAllCompanies(); $this->addParam('allCompanies', $allCompanies); $this->addParam('allAdmins', $allAdmins); } if ($this->getUserLevel() === UserGroups::$ADMIN) { $allCompanies = $companyManager->getAllCompanies(true, true); $allUsers = $userManager->selectAll(); $this->addParam('allCompanies', $allCompanies); $this->addParam('allUsers', $allUsers); $this->addParam('allAdmins', $allAdmins); } if ($this->getUserLevel() === UserGroups::$USER) { $allCompanies = $companyManager->getAllCompanies(); $allUsers = $userManager->selectAll(); $dealerCompanies = $companyManager->getUserCompaniesJoindWithFullInfo($this->getUserId()); $this->addParam('allCompanies', $dealerCompanies); //$this->addParam('allUsers', $allUsers); $this->addParam('allAdmins', $allAdmins); } }
public function service() { //todo check if user have access to given company $customer = $this->sessionManager->getUser(); $cId = $customer->getId(); $companyId = $this->args[0]; if ($companyId != $cId) { return false; } $companyManager = CompanyManager::getInstance($this->config, $this->args); $company = $companyManager->selectByPK($companyId); if (!$company) { return false; } $ex = new excel_xml(); $header_style = array('bold' => 1, 'size' => '12', 'color' => '#FFFFFF', 'bgcolor' => '#4F81BD'); $ex->add_style('header', $header_style); $ex->add_row(array('Serial Number', 'Category', 'Customer', 'Customer Warranty Period', 'Customer Purchase Date', 'Supplier', 'Purchase Date From Supplier', 'Supplier Warranty Period'), 'header'); $itemWarrantiesManager = ItemWarrantiesManager::getInstance($this->config, $this->args); $allItemsWarrantiesDtos = $itemWarrantiesManager->getCompanyAllWarrantyItems($companyId); foreach ($allItemsWarrantiesDtos as $key => $itemWarrantyDto) { $c1 = $itemWarrantyDto->getSerialNumber(); $c2 = $itemWarrantyDto->getItemCategory(); $c3 = $itemWarrantyDto->getBuyer(); $c4 = $itemWarrantyDto->getCustomerWarrantyPeriod(); $c5 = $itemWarrantyDto->getCustomerWarrantyStartDate(); $c6 = $itemWarrantyDto->getSupplier(); $c7 = $itemWarrantyDto->getSupplierWarrantyStartDate(); $c8 = $itemWarrantyDto->getSupplierWarrantyPeriod(); $ex->add_row(array($c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8)); } $ex->create_worksheet('Items Warranties'); $ex->generate(); $ex->download($this->args[1]); }
public function load() { $loadPage = 0; if (isset($_REQUEST['load_page'])) { $loadPage = $_REQUEST['load_page']; } if ($loadPage == 1) { $this->addParam("page_loaded", 1); $companyManager = CompanyManager::getInstance($this->config, $this->args); $allCompanyDtos = $companyManager->getAllCompanies(false, false); $companyNames = array(); $companyIds = array(); foreach ($allCompanyDtos as $companyDto) { $companyNames[] = $companyDto->getName(); $companyIds[] = $companyDto->getId(); } $this->addParam("companyNames", $companyNames); $this->addParam("companyIds", $companyIds); $selectedCompanyId = $companyIds[0]; if (isset($_REQUEST['selected_company_id'])) { $selectedCompanyId = intval($_REQUEST['selected_company_id']); } $includeHiddens = false; if (isset($_REQUEST['include_hiddens'])) { $includeHiddens = intval($_REQUEST['include_hiddens']) == 1; } $this->addParam('include_hiddens', $includeHiddens); $emptyModel = 0; if (isset($_REQUEST['empty_model'])) { $emptyModel = intval($_REQUEST['empty_model']); } $this->addParam('empty_model', $emptyModel); $emptyShortSpec = 0; if (isset($_REQUEST['empty_short_spec'])) { $emptyShortSpec = intval($_REQUEST['empty_short_spec']); } $this->addParam('empty_short_spec', $emptyShortSpec); $emptyFullSpec = 0; if (isset($_REQUEST['empty_full_spec'])) { $emptyFullSpec = intval($_REQUEST['empty_full_spec']); } $this->addParam('empty_full_spec', $emptyFullSpec); $picturesCount = 'any'; if (isset($_REQUEST['pictures_count'])) { $picturesCount = strtolower($_REQUEST['pictures_count']); } $this->addParam('pictures_count', $picturesCount); $itemManager = ItemManager::getInstance($this->config, $this->args); $items = $itemManager->getItemsByAdminConditions($selectedCompanyId, $includeHiddens, $emptyModel, $emptyShortSpec, $emptyFullSpec, $picturesCount); $this->addParam("items", $items); } else { $this->addParam("page_loaded", 0); } }
public function load() { $companyManager = CompanyManager::getInstance($this->config, $this->args); $allCompanies = $companyManager->getAllCompanies(true, true); $companies = array(); $companies[0] = 'All'; foreach ($allCompanies as $company) { $companies[$company->getId()] = $company->getName(); } $this->addParam("companies", $companies); }
private function sendStockUpdatedEmailToCompany($company_id) { $emailSenderManager = new EmailSenderManager('gmail'); $companyManager = CompanyManager::getInstance($this->config, $this->args); $company = $companyManager->selectByPK($company_id); if (isset($company) && $company->getReceiveEmailOnStockUpdate() == 1) { $company_email = $company->getEmail(); $subject = $this->getPhrase(531, 'en'); $templateId = 'company_stock_updated'; $params = array("support_phone" => $this->getCmsVar('pcstore_support_phone_number')); $emailSenderManager->sendEmail('info', $company_email, $subject, $templateId, $params); } }
public function load() { $this->addParam('pcstore_contact_number', $this->getCmsVar('pcstore_sales_phone_number')); $customer = $this->getCustomer(); $sms_sent = false; if (isset($_REQUEST['co_code'])) { $code = $this->secure($_REQUEST['co_code']); $this->addParam('co_code', $code); if ($customer->getLastSmsValidationCode() === $code) { $this->addParam('order_confirmed', true); } else { $this->addParam('errorMessage', 223); } $this->addParam('sms_sent', true); return true; } $cell_phone_editable = $this->secure($_REQUEST['cho_do_shipping']) != 1; if ($cell_phone_editable) { $this->addParam('infoMessage', 362); } $cell_phone_number = $this->getPhoneNumberToSendSMS(); $validNumber = null; if ($cell_phone_number != null) { $validNumber = SentSmsManager::getValidArmenianNumber($cell_phone_number); } if ($validNumber != null) { $lastSmsValidationCode = substr(uniqid(rand(), true), 0, 6); if ($this->getUserLevel() == UserGroups::$USER) { $userManager = UserManager::getInstance($this->config, $this->args); $userManager->setLastSmsValidationCode($customer->getId(), $lastSmsValidationCode); } elseif ($this->getUserLevel() == UserGroups::$COMPANY) { $companyManager = CompanyManager::getInstance($this->config, $this->args); $companyManager->setLastSmsValidationCode($customer->getId(), $lastSmsValidationCode); } $sentSmsManager = SentSmsManager::getInstance($this->config, $this->args); $sentSmsManager->sendSmsToArmenia($validNumber, $lastSmsValidationCode); $this->addParam('infoMessage', "`319` ({$validNumber})"); $this->addParam('validNumber', "(" . $validNumber . ")"); $this->addParam('sms_sent', true); } else { if (!empty($cell_phone_number)) { $this->addParam('errorMessage', 318); } $this->addParam('cell_phone_number', $cell_phone_number); if (!$cell_phone_editable) { $this->addParam('infoMessage', 387); } } $this->addParam('cell_phone_editable', $cell_phone_editable); }
public function load() { $loadPage = 0; if (isset($_REQUEST['load_page'])) { $loadPage = $_REQUEST['load_page']; } if ($loadPage == 1) { $this->addParam("page_loaded", 1); $companyManager = CompanyManager::getInstance($this->config, $this->args); $allCompanyDtos = $companyManager->getAllCompanies(true, true); $this->addParam("companies", $allCompanyDtos); } else { $this->addParam("page_loaded", 0); } }
public function service() { $lc = $_REQUEST['l']; if ($lc === 'am' || $lc === 'en' || $lc === 'ru') { $this->setcookie('ul', $lc); $_COOKIE['ul'] = $lc; if ($this->getUserLevel() == UserGroups::$USER) { $userManager = UserManager::getInstance($this->config, $this->args); $userManager->setLanguageCode($this->getUserId(), $lc); } elseif ($this->getUserLevel() == UserGroups::$COMPANY) { $companyManager = CompanyManager::getInstance($this->config, $this->args); $companyManager->setLanguageCode($this->getUserId(), $lc); } } }
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); }
public function service() { if (!isset($_REQUEST['item_position'])) { $jsonArr = array('status' => "err", "errText" => "System Error: Item position is not set!"); echo json_encode($jsonArr); return false; } $item_position = $this->secure($_REQUEST['item_position']); if (!is_numeric($item_position)) { $jsonArr = array('status' => "err", "errText" => "System Error: Item position should be positive number!"); echo json_encode($jsonArr); return false; } if (!$_COOKIE['copied_item_id']) { $jsonArr = array('status' => "err", "errText" => "System Error: There is no copied item!"); echo json_encode($jsonArr); return false; } $copied_item_id = $this->secure($_COOKIE['copied_item_id']); $itemManager = ItemManager::getInstance($this->config, $this->args); $itemDto = $itemManager->selectByPK($copied_item_id); if (!isset($itemDto)) { $jsonArr = array('status' => "err", "errText" => "Error: Item does not exist! (id:{$copied_item_id})"); echo json_encode($jsonArr); return false; } if (!isset($_REQUEST['selected_company_id'])) { $jsonArr = array('status' => "err", "errText" => "System Error: Company id is not set!"); echo json_encode($jsonArr); return false; } $selected_company_id = $this->secure($_REQUEST['selected_company_id']); $companyManager = CompanyManager::getInstance($this->config, $this->args); $companyDto = $companyManager->selectByPK($selected_company_id); if (!isset($companyDto)) { $jsonArr = array('status' => "err", "errText" => "System Error: Company is not exist!"); echo json_encode($jsonArr); return false; } $itemManager->copyItem($copied_item_id, $selected_company_id, $item_position); $jsonArr = array('status' => "ok"); echo json_encode($jsonArr); return true; }
public function service() { $sound_on = $_REQUEST['on'] == 1 ? 1 : 0; if ($this->getUserLevel() != UserGroups::$GUEST) { $customerId = $this->getUserId(); switch ($this->getUserLevel()) { case UserGroups::$USER: $userManager = UserManager::getInstance($this->config, $this->args); $userManager->enableSound($customerId, $sound_on); break; case UserGroups::$COMPANY: $companyManager = CompanyManager::getInstance($this->config, $this->args); $companyManager->enableSound($customerId, $sound_on); break; case UserGroups::$ADMIN: $adminManager = AdminManager::getInstance($this->config, $this->args); $adminManager->enableSound($customerId, $sound_on); break; } $this->ok(); } }
public function service() { //todo check if user have access to given company $adminManager = new AdminManager($this->config, $this->args); $adminId = $this->sessionManager->getUser()->getId(); $adminDto = $adminManager->selectByPK($adminId); if (!$adminDto) { return false; } $companyId = $this->args[0]; $companyManager = CompanyManager::getInstance($this->config, $this->args); $company = $companyManager->selectByPK($companyId); if (!$company) { return false; } $ex = new excel_xml(); $header_style = array('bold' => 1, 'size' => '12', 'color' => '#FFFFFF', 'bgcolor' => '#4F81BD'); $ex->add_style('header', $header_style); $ex->add_row(array('Name', 'Price', 'VAT Price'), 'header'); $itemManager = ItemManager::getInstance($this->config, $this->args); $items = $itemManager->getCompanyItems($companyId); foreach ($items as $key => $itemDto) { $row = array(); $name = $itemDto->getDisplayName(); $row[] = $name; $price_usd = $itemDto->getDealerPrice(); $row[] = '$' . $price_usd; if ($itemDto->getVatPrice() > 0) { $price_vat_usd = $itemDto->getVatPrice(); $row[] = '$' . $price_vat_usd; } //$price_amd = $itemManager->exchangeFromUsdToAMD($itemDto->getDealerPrice()); $ex->add_row($row); } $ex->create_worksheet('Items'); $ex->generate(); $ex->download($company->getName()); }
public function service() { $userManager = new UserManager($this->config, $this->args); if (isset($_REQUEST['login_type'])) { $json_profile = $_REQUEST['json_profile']; $social_user_id = $this->secure($_REQUEST['social_user_id']); $first_name = $this->secure($_REQUEST['first_name']); $last_name = $this->secure($_REQUEST['last_name']); $custDto = $userManager->getUserByEmail($social_user_id); if (!isset($custDto)) { $userId = $userManager->createUser($social_user_id, uniqid(), $first_name, '', $last_name, $_REQUEST['login_type']); $userManager->setActive($userId); $userManager->setUserSocialProfile($userId, $json_profile); $custDto = $userManager->getUserByEmail($social_user_id); //bonus to inviter $invitation_code = $this->secure($_COOKIE["invc"]); $inviterId = $userManager->setSubUser($invitation_code, $userId); if ($inviterId > 0) { $invbonus = intval($this->getCmsVar("bonus_points_for_every_accepted_invitation")); $userManager->addUserPoints($inviterId, $invbonus, "{$invbonus} bonus for invitation accept from user number: {$userId}"); } } $userType = UserGroups::$USER; } else { $email = strtolower($userManager->secure($_REQUEST["user_email"])); $pass = $userManager->secure($_REQUEST["user_pass"]); $custDto = $userManager->getCustomerByEmailAndPassword($email, $pass); $userType = $userManager->getCustomerType($email, $pass); if ($userType == UserGroups::$USER && $custDto->getActive() == 0) { $jsonArr = array('status' => "err", "errText" => sprintf($this->getPhrase(380), $custDto->getEmail())); echo json_encode($jsonArr); return false; } } if ($custDto) { if ($userType !== UserGroups::$ADMIN && $custDto->getBlocked() == 1) { $jsonArr = array('status' => "err", "errText" => $this->getPhraseSpan(411) . ' ' . $this->getCmsVar("pcstore_support_phone_number")); echo json_encode($jsonArr); return false; } $user = null; if ($userType === UserGroups::$ADMIN) { $user = new AdminUser($custDto->getId()); } else { if ($userType === UserGroups::$USER) { $user = new CustomerUser($custDto->getId()); $this->setcookie('ul', $custDto->getLanguageCode()); } else { if ($userType === UserGroups::$COMPANY) { $user = new CompanyUser($custDto->getId()); $companyManager = CompanyManager::getInstance($this->config, $this->args); $companyManager->updateCompanyRating($custDto); $this->setcookie('ul', $custDto->getLanguageCode()); } else { if ($userType === UserGroups::$SERVICE_COMPANY) { $user = new ServiceCompanyUser($custDto->getId()); $companyManager = ServiceCompanyManager::getInstance($this->config, $this->args); $this->setcookie('ul', $custDto->getLanguageCode()); } } } } $user->setUniqueId($custDto->getHash()); $this->sessionManager->setUser($user, true, true); $jsonArr = array('status' => "ok"); echo json_encode($jsonArr); return true; } else { $jsonArr = array('status' => "err", "errText" => $this->getPhrase(412)); echo json_encode($jsonArr); return false; } }
public function load() { $companyManager = CompanyManager::getInstance($this->config, $this->args); $companyId = $this->getUserId(); if (!isset($_REQUEST['refresh']) || $_REQUEST['refresh'] != 1) { $companyLogin = $this->getCustomerLogin(); if (isset($_REQUEST['password'])) { $password = $_REQUEST['password']; $dto = $companyManager->getCompanyByEmailAndPassword($companyLogin, $password); if (!isset($dto)) { $this->addParam("message", $this->getPhraseSpan(581)); $this->addParam("checkPassword", 1); return; } } else { $this->addParam("checkPassword", 1); return; } } $companyAndBranchesDtos = $companyManager->getCompanyAndBranches($companyId); $companyBranchesNamesIdsMap = $this->getCompanyBranchesNamesArrayByCompanyAndBranchesDtos($companyAndBranchesDtos); $selectedBranchNames = array_values($companyBranchesNamesIdsMap); $this->addParam("company_branches_names", $selectedBranchNames); $selectedBranchIds = array_keys($companyBranchesNamesIdsMap); $this->addParam("company_branches_ids", $selectedBranchIds); $selectedCompanyBranchDto = null; if (isset($_REQUEST['selected_branch_id'])) { $selectedBranchId = intval($this->secure($_REQUEST['selected_branch_id'])); if (array_key_exists($selectedBranchId, $companyBranchesNamesIdsMap)) { $selectedCompanyBranchDto = $this->getCompanyBrancheByBranchId($companyAndBranchesDtos, $selectedBranchId); } } if (!isset($selectedCompanyBranchDto)) { $selectedCompanyBranchDto = $companyAndBranchesDtos[0]; } if (!isset($selectedCompanyBranchDto)) { echo 'Error: no company branch data!'; exit; } $this->addParam("selected_company_branch_id", $selectedCompanyBranchDto->getBranchId()); $companyPhones = trim($selectedCompanyBranchDto->getPhones()); $companyPhonesArray = array(); if (!empty($companyPhones)) { $companyPhonesArray = explode(',', $companyPhones); } $this->addParam("phones", $companyPhonesArray); $this->addParam("working_days", $selectedCompanyBranchDto->getWorkingDays()); $this->addParam("branch_address", $selectedCompanyBranchDto->getStreet()); $this->addParam("lat", $selectedCompanyBranchDto->getLat()); $this->addParam("lng", $selectedCompanyBranchDto->getLng()); $regions_phrase_ids_array = explode(',', $this->getCmsVar('armenia_regions_phrase_ids')); $this->addParam('regions_phrase_ids_array', $regions_phrase_ids_array); $region = trim($selectedCompanyBranchDto->getRegion()); $this->addParam('region_selected', $region); $minutes_block = 30; $start_time = '00:00:00'; $total_day_minutes = 24 * 60; $cycleIndex = -1; $times = array(); while (++$cycleIndex * $minutes_block < $total_day_minutes) { $timestamp = strtotime($start_time); $mins = $cycleIndex * $minutes_block; $time = strtotime("+{$mins} minutes", $timestamp); $times[] = date('H:i', $time); } $this->addParam('times', $times); }
public function addOnlineUser($userLevel, $customerDto) { $browserInfo = $this->getBrowser(); // if ($browserInfo["name"] === 'Unknown') { // return false; // } $userEmail = ''; if (isset($customerDto)) { $userEmail = $customerDto->getEmail(); } //last ping time set for customer $previousPing = null; switch ($userLevel) { case UserGroups::$ADMIN: $adminManager = AdminManager::getInstance($this->config, $this->args); $previousPing = $customerDto->getLastPing(); $adminManager->setLastPingToNow($customerDto->getId()); break; case UserGroups::$COMPANY: $companyManager = CompanyManager::getInstance($this->config, $this->args); $previousPing = $customerDto->getLastPing(); $companyManager->setLastPingToNow($customerDto->getId($customerDto->getId())); break; case UserGroups::$USER: $userManager = UserManager::getInstance($this->config, $this->args); $previousPing = $customerDto->getLastPing(); $userManager->setLastPingToNow($customerDto->getId($customerDto->getId())); break; } if (isset($customerDto)) { $onlineUser = $this->getOnlineUserByEmail($userEmail); if (isset($onlineUser)) { $this->updateOnlineUserAttributes($onlineUser); return false; } } $guest_online_table_id = $_COOKIE['guest_online_table_id']; $oldRow = $this->selectByPK($guest_online_table_id); $ip = $_SERVER["REMOTE_ADDR"]; $host = gethostbyaddr($_SERVER['REMOTE_ADDR']); $country = $_SERVER["GEOIP_COUNTRY_NAME"]; $browser = $browserInfo["name"]; $browserVersion = $browserInfo["version"]; $platform = $browserInfo["platform"]; $status = "online"; if ($browser != 'Unknown' && $platform != 'Unknown' && $browserVersion != '?') { if (!isset($oldRow)) { $dto = $this->mapper->createDto(); } else { $dto = $oldRow; } $dto->setEmail($userEmail); $dto->setIp($ip); $dto->setHost($host); $dto->setCountry($country); $dto->setBrowserName($browser); $dto->setBrowserVersion($browserVersion); $dto->setBrowserPlatform($platform); $dto->setLoginDateTime(date('Y-m-d H:i:s')); $dto->setStatus($status); if (!isset($oldRow)) { $id = $this->mapper->insertDto($dto); } else { $this->mapper->updateByPK($dto); $id = $dto->getId(); } } $loginHistoryManager = LoginHistoryManager::getInstance($this->config, $this->args); $ulstring = $this->getUserLevelString($userLevel); $loginHistoryManager->addRow($userEmail, $ulstring, $ip, $host, $country, $browser, $browserVersion, $platform); $customerMessagesAfterLoginManager = CustomerMessagesAfterLoginManager::getInstance($this->config, $this->args); $customerMessagesAfterLoginManager->addCustomerMessagesAfterLoginByPreviousPing($customerDto, $userLevel, $previousPing); return $id; }
public function initCompaniesSelectionList() { $userLevel = $this->getUserLevel(); $companyManager = CompanyManager::getInstance($this->config, $this->args); $companiesNames = array(); $companiesIds = array(); if ($userLevel === UserGroups::$COMPANY || $userLevel === UserGroups::$SERVICE_COMPANY || $userLevel === UserGroups::$ADMIN) { $allCompanies = $companyManager->getAllCompanies($userLevel === UserGroups::$ADMIN || false, $userLevel === UserGroups::$ADMIN); $companiesIds = $companyManager->getCompaniesIdsArray($allCompanies); $companiesNames = $companyManager->getCompaniesNamesArray($allCompanies); } elseif ($userLevel === UserGroups::$USER) { $userId = $this->getUserId(); $companiesDtos = $companyManager->getUserCompanies($userId, false); $companiesIds = $companyManager->getCompaniesIdsArray($companiesDtos); $companiesNames = $companyManager->getCompaniesNamesArray($companiesDtos); } $selectedCompanyId = 0; array_splice($companiesIds, 0, 0, 0); array_splice($companiesNames, 0, 0, $this->getPhrase(153)); $this->addParam("companiesIds", $companiesIds); $this->addParam("companiesNames", $companiesNames); if (isset($_REQUEST["sci"])) { $selectedCompanyId = $this->secure($_REQUEST["sci"]); } $this->addParam("selectedCompanyId", $selectedCompanyId); return $selectedCompanyId; }
private function determineCompanyIdFromPriceEmail($fromEmails) { if (is_array($fromEmails)) { $fromEmails = implode(',', $fromEmails); } $companyManager = CompanyManager::getInstance(null, null); $allCompaniesDtos = $companyManager->selectAll(); $selectedCompaniesIds = array(); foreach ($allCompaniesDtos as $companyDto) { $companyEmail = $companyDto->getEmail(); $priceEmailsKeywords = trim($companyDto->getPriceEmailsKeywords()); $priceEmailsKeywordsArray = array(); if (!empty($priceEmailsKeywords)) { $priceEmailsKeywordsArray = explode(',', $priceEmailsKeywords); } if (strpos($fromEmails, $companyEmail) !== false) { return array($companyDto->getId(), $companyDto->getName(), 'company'); } foreach ($priceEmailsKeywordsArray as $priceEmailsKeyword) { if (strpos($fromEmails, $priceEmailsKeyword) !== false) { $selectedCompaniesIds[$companyDto->getId()] = $companyDto->getName(); } } } $serviceCompanyManager = ServiceCompanyManager::getInstance(null, null); $allServiceCompaniesDtos = $serviceCompanyManager->selectAll(); $selectedServiceCompaniesIds = array(); foreach ($allServiceCompaniesDtos as $serviceCompanyDto) { $serviceCompanyEmail = $serviceCompanyDto->getEmail(); $priceEmailsKeywords = $serviceCompanyDto->getPriceEmailsKeywords(); if (!empty($priceEmailsKeywords)) { $priceEmailsKeywordsArray = explode(',', $priceEmailsKeywords); } if (strpos($fromEmails, $serviceCompanyEmail) !== false) { return array($serviceCompanyDto->getId(), $serviceCompanyDto->getName(), 'service_company'); } foreach ($priceEmailsKeywordsArray as $priceEmailsKeyword) { if (strpos($fromEmails, $priceEmailsKeyword) !== false) { $selectedServiceCompaniesIds[$serviceCompanyDto->getId()] = $serviceCompanyDto->getName(); } } } if (count($selectedCompaniesIds) === 1) { $keys = array_keys($selectedCompaniesIds); return array($keys[0], $selectedCompaniesIds[$keys[0]], 'company'); } if (count($selectedServiceCompaniesIds) === 1) { $keys = array_keys($selectedServiceCompaniesIds); return array($keys[0], $selectedServiceCompaniesIds[$keys[0]], 'service_company'); } //@TODO retrun the correct company id and type return array(false, false, false); }
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); }
/** * Creates en instance of admin user class and * initializes class members necessary for validation. * * @param object $adminId * @return */ public function __construct($id) { parent::__construct($id); $this->setCookieParam("ut", UserGroups::$COMPANY); $this->companyManager = CompanyManager::getInstance(null, null); }
public function sendSmsToSmsInterestedCompanies($companyId, $companyName) { $companyManager = CompanyManager::getInstance($this->config, $this->args); $companiesToReceiveSMS = $companyManager->getCompanyPriceInterestedForSmsCompanies($companyId); $sentSmsManager = SentSmsManager::getInstance($this->config, $this->args); foreach ($companiesToReceiveSMS as $key => $company) { $numberToReceiveSmsOnPriceUpload = $company->getPriceUploadSmsPhoneNumber(); if (empty($numberToReceiveSmsOnPriceUpload)) { continue; } $weekdays = $company->getSmsReceiveWeekdays(); $dayofweek = date('N'); if ($weekdays[$dayofweek - 1] != '1') { continue; } $duration = $company->getSmsToDurationMinutes(); if ($duration > 0) { $smsReceiveTimeStart = $company->getSmsReceiveTimeStart(); $smsReceiveStartDateTime = strtotime(date('Y-m-d') . ' ' . $smsReceiveTimeStart); $smsReceiveEndDateTime = strtotime("+{$duration} minutes", $smsReceiveStartDateTime); $now = time(); if ($now < $smsReceiveStartDateTime || $now > $smsReceiveEndDateTime) { continue; } } $sentSmsManager->sendSmsToArmenia($numberToReceiveSmsOnPriceUpload, "'" . $companyName . "' just uploaded price on PcStore! Best Regards www.pcstore.am"); } }
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'); } }
public function service() { $action = $_REQUEST['action']; $params = array(); switch ($action) { case 'delete_user': $this->deleteUser($_REQUEST['user_id']); break; case 'delete_all_unnecessary_items_pictures': $ret = $this->deleteAllUnnecessaryItemsPictures(); $params = array('removed_items_ids' => implode(',', $ret)); break; case 'set_item_spec': $itemId = $_REQUEST['item_id']; $shortSpec = $_REQUEST['short_spec']; $fullSpec = $_REQUEST['full_spec']; require_once CLASSES_PATH . "/managers/ItemManager.class.php"; $itemManager = ItemManager::getInstance($this->config, $this->args); $itemManager->updateTextField($itemId, 'short_description', $shortSpec); $itemManager->updateTextField($itemId, 'full_description', $fullSpec); break; case 'get_item_spec': $itemId = $_REQUEST['item_id']; require_once CLASSES_PATH . "/managers/ItemManager.class.php"; $itemManager = ItemManager::getInstance($this->config, $this->args); $itemDto = $itemManager->selectByPK($itemId); $params['short_spec'] = $itemDto->getShortDescription(); $params['full_spec'] = $itemDto->getFullDescription(); break; case 'get_camera_1_snap': $url = $this->getCmsVar('pcstore_camera_1_url'); $login = $this->getCmsVar('pcstore_camera_1_login'); $pass = $this->getCmsVar('pcstore_camera_1_pass'); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERPWD, $login . ':' . $pass); $img = curl_exec($ch); header("Content-Type: image/jpeg"); echo $img; exit; case 'filter_emails': require_once CLASSES_PATH . "/managers/EmailSenderManager.class.php"; require_once CLASSES_PATH . "/managers/UninterestingEmailsManager.class.php"; $emails = $_REQUEST['emails']; $emailsArray = EmailSenderManager::getEmailsFromText($emails); $uninterestingEmailsManager = UninterestingEmailsManager::getInstance($this->config, $this->args); $filteredEmailsArray = $uninterestingEmailsManager->removeUninterestingEmailsFromList($emailsArray); $params['count'] = count($filteredEmailsArray); $params['emails'] = implode(';', $filteredEmailsArray); break; case 'is_price_values_ready': $companyId = intval($_REQUEST['company_id']); require_once CLASSES_PATH . "/managers/PriceTextsManager.class.php"; $priceTextsManager = PriceTextsManager::getInstance($this->config, $this->args); $companyPriceValuesReady = $priceTextsManager->isCompanyPriceValuesReady($companyId); $params['ready'] = $companyPriceValuesReady ? '1' : '0'; break; case 'delete_price_values_column': $companyId = intval($_REQUEST['company_id']); $sheetIndex = intval($_REQUEST['sheet_index']); $priceIndex = intval($_REQUEST['price_index']); $columnLetter = $this->secure($_REQUEST['column_letter']); require_once CLASSES_PATH . "/managers/PriceValuesManager.class.php"; $priceValuesManager = PriceValuesManager::getInstance($this->config, $this->args); $priceValuesManager->moveColumnValuesToLastColumn($companyId, $priceIndex, $sheetIndex, $columnLetter); break; case 'delete_customer_amessage_after_login': $pk = intval($_REQUEST['id']); require_once CLASSES_PATH . "/managers/CustomerMessagesAfterLoginManager.class.php"; $customerMessagesAfterLoginManager = CustomerMessagesAfterLoginManager::getInstance($this->config, $this->args); $customerMessagesAfterLoginManager->deleteByPK($pk); break; case 'preview_customer_message': $pk = intval($_REQUEST['id']); require_once CLASSES_PATH . "/managers/CustomerMessagesAfterLoginManager.class.php"; $customerMessagesAfterLoginManager = CustomerMessagesAfterLoginManager::getInstance($this->config, $this->args); $dto = $customerMessagesAfterLoginManager->selectByPK($pk); $params = AbstractDto::dtoToArray($dto); break; case 'delete_old_hidden_items': $monthsNumber = intval($_REQUEST['months_number']); require_once CLASSES_PATH . "/managers/ItemManager.class.php"; $itemManager = ItemManager::getInstance($this->config, $this->args); $params['count'] = $itemManager->deleteOldHiddenItemsByMonthsNumber($monthsNumber); break; case 'update_companies_price_text': $company_id = intval($_REQUEST['company_id']); $companyManager = CompanyManager::getInstance($this->config, $this->args); if ($company_id == 0) { $allCompanies = $companyManager->getAllCompanies(true, true); } else { $allCompanies[] = $companyManager->selectByPK($company_id); } $cidsArray = array(); foreach ($allCompanies as $c) { $cidsArray[] = $c->getId(); } $this->updateCompanyPriceText(implode(',', $cidsArray)); break; case 'deploy_latest_pcstore_changes': $protocol = "http://"; if (isset($_SERVER["HTTPS"])) { $protocol = "https://"; } $content = file_get_contents($protocol . HTTP_HOST . '/8350e5a3e24c153df2275c9f80692773.php'); $params['message'] = $content; break; } $this->ok($params); }