public function service()
 {
     $companyManager = new CompanyManager($this->config, $this->args);
     $company_id = intval($this->secure($_REQUEST['company_id']));
     $company_offers = addslashes($this->secure($_REQUEST['offers']));
     $companyManager->setCompanyOffers($company_id, $company_offers);
     $jsonArr = array('status' => "ok");
     echo json_encode($jsonArr);
     return true;
 }
 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]);
 }
 /**
  * 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 CompanyManager($config, $args);
     }
     return self::$instance;
 }
 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()
 {
     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 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);
     $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 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);
 }
 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);
     }
 }
 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 service()
 {
     $userManager = new UserManager($this->config, $this->args);
     $companyManager = new CompanyManager($this->config, $this->args);
     $companyDealersManager = new CompanyDealersManager($this->config, $this->args);
     $access_key = $userManager->secure($_REQUEST["access_key"]);
     $company = $companyManager->getCompanyByAccessKey($access_key);
     if ($company) {
         $userId = $this->getUserId();
         $companyId = $company->getId();
         if (!$companyDealersManager->getByCompanyIdAndUserId($userId, $companyId)) {
             $customer = $this->getCustomer();
             $customerEmail = $customer->getEmail();
             $customerCartManager = CustomerCartManager::getInstance($this->args, $this->config);
             $items = $customerCartManager->getCustomerItemsByCompanyId($customerEmail, $companyId);
             $bundlesIds = $customerCartManager->getCustomerBundlesIdsByCompanyId($customerEmail, $companyId);
             $customerCartManager->deleteCompanyRelatedItemsFromCustomerCart($customerEmail, $companyId);
             $companyDealersManager->addUserToCompany($userId, $companyId);
             $message = $this->getPhrase(437) . ' ' . $company->getName() . "'! \n";
             if (!empty($items)) {
                 $message .= $this->getPhrase(436) . "'\n";
             }
             if (!empty($bundlesIds)) {
                 $message .= $this->getPhrase(435);
             }
             $jsonArr = array('status' => "ok", "message" => $message);
             echo json_encode($jsonArr);
             return true;
         } else {
             $jsonArr = array('status' => "err", "errText" => "You already have '" . $company->getName() . "' company in your list!");
             echo json_encode($jsonArr);
             return false;
         }
     } else {
         $jsonArr = array('status' => "err", "errText" => "Access key incorrect!");
         echo json_encode($jsonArr);
         return false;
     }
 }
 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;
 }
Example #17
0
 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());
 }
Example #19
0
 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 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);
 }
 public function createDefaultExCompanyProfile($companyId)
 {
     $dto = $this->mapper->createDto();
     $dto->setCompanyId($companyId);
     $companyManager = CompanyManager::getInstance($this->config, $this->args);
     $companyBranchesManager = CompanyBranchesManager::getInstance($this->config, $this->args);
     $companyDto = $companyManager->selectByPK($companyId);
     $companyBranches = $companyBranchesManager->getCompaniesBranches($companyId);
     list($phones, $addresses) = $this->getCompanyPhonesAndAddressesFromBranches($companyBranches);
     $emailBodyTemplate = $this->getPhrase(467);
     $emailBody = str_replace(array('{company_access_code}', '{company_id}', '{company_addresses}', '{company_phones}'), array($companyDto->getAccessKey(), $companyId, implode('<br>', $addresses), implode('<br>', $phones)), $emailBodyTemplate);
     $dto->setPriceEmailBody($emailBody);
     $dto->setPriceEmailSubject($companyDto->getName() . ' Price');
     $this->mapper->insertDto($dto);
 }
 public function service()
 {
     $companyManager = new CompanyManager($this->config, $this->args);
     $this->userManager = new UserManager($this->config, $this->args);
     $company_branch_id = $this->secure($_REQUEST["cp_branch_select"]);
     $company_name = $this->secure($_REQUEST["company_name"]);
     $change_pass = $this->secure($_REQUEST["change_pass"]);
     $new_pass = $this->secure($_REQUEST["new_pass"]);
     $repeat_new_pass = $this->secure($_REQUEST["repeat_new_pass"]);
     $phone1 = $this->secure($_REQUEST["phone1"]);
     $phone2 = $this->secure($_REQUEST["phone2"]);
     $phone3 = $this->secure($_REQUEST["phone3"]);
     $address = $this->secure($_REQUEST["address"]);
     $region = $this->secure($_REQUEST["region"]);
     $lng = $this->secure($_REQUEST["longitute"]);
     $lat = $this->secure($_REQUEST["latitude"]);
     $working_days = $this->secure($_REQUEST["working_days"]);
     $working_hours = $this->secure($_REQUEST["working_hours"]);
     $zip = $this->secure($_REQUEST["zip"]);
     $dealers_access_key = $this->secure($_REQUEST["dealers_access_key"]);
     $url = $this->secure($_REQUEST["url"]);
     $receive_email_on_stock_update = isset($_REQUEST["receive_email_on_stock_update"]) ? 1 : 0;
     $validFields = $this->validateCompanyProfileFields($company_name, $change_pass, $new_pass, $repeat_new_pass, $phone1, $phone2, $phone3, $address, $zip, $region, $working_days, $working_hours, $dealers_access_key, $url);
     $companyId = $this->getUserId();
     if ($validFields === 'ok') {
         if (isset($_FILES['company_logo'])) {
             ////////////////////////////
             $originalLogoFullName = null;
             $file_name = $_FILES['company_logo']['name'];
             $file_type = $_FILES['company_logo']['type'];
             $tmp_name = $_FILES['company_logo']['tmp_name'];
             $file_size = $_FILES['company_logo']['size'];
             $logoCheck = $this->checkInputFile('company_logo');
             //start to save new price file
             $logoExt = strtolower(end(explode('.', $file_name)));
             if ($logoCheck === 'ok' && !in_array($logoExt, $this->supported_file_formats)) {
                 $logoCheck = "Not supported file format! ()";
             }
             if ($logoCheck === 'ok') {
                 $dir = DATA_DIR . "/images/";
                 if (!is_dir($dir)) {
                     mkdir($dir, 0777);
                 }
                 $dir = DATA_DIR . "/images/company_logo/";
                 if (!is_dir($dir)) {
                     mkdir($dir, 0777);
                 }
                 $logoName = 'company_' . $companyId . '_logo';
                 $originalLogoFullName = $dir . $logoName . '_original' . '.' . 'png';
                 $resizedLogoFullName_55_30 = $dir . $logoName . '_55_30' . '.' . 'png';
                 $resizedLogoFullName_120_75 = $dir . $logoName . '_120_75' . '.' . 'png';
                 move_uploaded_file($tmp_name, $originalLogoFullName);
                 $resret1 = resizeImageToGivenType($originalLogoFullName, $resizedLogoFullName_55_30, 55, 30, 'png');
                 $resret2 = resizeImageToGivenType($originalLogoFullName, $resizedLogoFullName_120_75, 120, 75, 'png');
                 //resize image
                 if ($logoCheck === 'ok' && $resret1 == false) {
                     $logoCheck = "Error resizing image!";
                 }
                 if (is_file($originalLogoFullName)) {
                     unlink($originalLogoFullName);
                 }
             }
         }
         $sms_phone_number = '';
         if (isset($_REQUEST['enable_sms_on_price_upload'])) {
             $sms_phone_number = $this->secure($_REQUEST['sms_phone_number']);
         }
         $sms_from_time = date('H:i:s', strtotime($this->secure($_REQUEST['sms_from_time'])));
         $sms_to_duration_minutes = 0;
         if (isset($_REQUEST['sms_time_control'])) {
             $sms_to_duration_minutes = $this->secure($_REQUEST['sms_to_duration_minutes']);
         }
         $sms_receiving_days = $this->secure($_REQUEST['sms_receiving_days']);
         $companyManager->updateCompanyProfileFieldsById($companyId, $company_branch_id, $company_name, $change_pass, $new_pass, $phone1, $phone2, $phone3, $address, $zip, $region, $working_days, $working_hours, $dealers_access_key, $url, $sms_phone_number, $sms_receiving_days, $sms_from_time, $sms_to_duration_minutes, $receive_email_on_stock_update, $lng, $lat);
         $jsonArr = array('status' => "ok", "message" => $logoCheck);
         echo "<script>var l= new parent.ngs.ChangeCompanyProfileAction(); l.afterAction('" . json_encode($jsonArr) . "'); </script>";
         return true;
         ////////////////////////////
     } else {
         $jsonArr = array('status' => "err", "errText" => $validFields);
         echo "<script>var l= new parent.ngs.ChangeCompanyProfileAction(); l.afterAction('" . json_encode($jsonArr) . "'); </script>";
         return false;
     }
 }
 public function getCustomer()
 {
     if (!$this->customer) {
         if ($this->getUserLevel() != UserGroups::$GUEST) {
             $userId = $this->getUserId();
             if ($this->getUserLevel() == UserGroups::$USER) {
                 $userManager = new UserManager($this->config, $this->args);
                 $this->customer = $userManager->selectByPK($userId);
             } else {
                 if ($this->getUserLevel() == UserGroups::$COMPANY) {
                     $customerManager = new CompanyManager($this->config, $this->args);
                     $this->customer = $customerManager->selectByPK($userId);
                 } else {
                     if ($this->getUserLevel() == UserGroups::$SERVICE_COMPANY) {
                         $customerManager = new ServiceCompanyManager($this->config, $this->args);
                         $this->customer = $customerManager->selectByPK($userId);
                     } else {
                         if ($this->getUserLevel() == UserGroups::$ADMIN) {
                             $adminManager = new AdminManager($this->config, $this->args);
                             $this->customer = $adminManager->selectByPK($userId);
                         }
                     }
                 }
             }
         }
     }
     return $this->customer;
 }
 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');
     }
 }
Example #25
0
    if (file_exists('model/' . $myClass . '.php')) {
        include 'model/' . $myClass . '.php';
    } elseif (file_exists('controller/' . $myClass . '.php')) {
        include 'controller/' . $myClass . '.php';
    }
}
spl_autoload_register("classLoad");
include 'config.php';
include 'lib/pagination.php';
//classes loading end
session_start();
if (isset($_SESSION['userMerlaTrav']) and ($_SESSION['userMerlaTrav']->profil() == "admin" or $_SESSION['userMerlaTrav']->profil() == "manager")) {
    $idProjet = 0;
    $projetManager = new ProjetManager($pdo);
    $clientManager = new ClientManager($pdo);
    $companieManager = new CompanyManager($pdo);
    $projet = "";
    if (isset($_GET['idProjet']) and $_GET['idProjet'] > 0 and $_GET['idProjet'] <= $projetManager->getLastId() and (isset($_GET['codeClient']) and (bool) $clientManager->getCodeClient($_GET['codeClient']))) {
        $idProjet = $_GET['idProjet'];
        $codeClient = $_GET['codeClient'];
        $projet = $projetManager->getProjetById($idProjet);
        $client = $clientManager->getClientByCode($codeClient);
        $companies = $companieManager->getCompanys();
    }
    ?>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
<!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
 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);
 }
Example #27
0
 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);
 }
{
    if (file_exists('../model/' . $myClass . '.php')) {
        include '../model/' . $myClass . '.php';
    } elseif (file_exists('../controller/' . $myClass . '.php')) {
        include '../controller/' . $myClass . '.php';
    }
}
spl_autoload_register("classLoad");
include '../config.php';
include '../lib/image-processing.php';
require_once '../lib/tcpdf/tcpdf.php';
//classes loading end
session_start();
//classes managers
$contratEmployeManager = new ContratEmployeManager($pdo);
$companyManager = new CompanyManager($pdo);
$clientManager = new ClientManager($pdo);
$projetManager = new ProjetManager($pdo);
$employeManager = new EmployeManager($pdo);
//classes
$idContrat = $_GET['idContratEmploye'];
$contrat = $contratEmployeManager->getContratEmployeById($idContrat);
$projet = $projetManager->getProjetById($contrat->idProjet());
$employe = $employeManager->getEmployeById($contrat->employe());
//choix unité en arabe selon la valeur de l'unité
$unite = "";
if ($contrat->unite() == "m²") {
    $unite = "المتر المربع";
} else {
    if ($contrat->unite() == "m lineaire") {
        $unite = "المتر الخطي";
Example #30
0
 /**
  * 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);
 }