Îðëà
Îáëàñòè
Êîìïàíèé
Ïîëüçîâàòåëè
Ãàëåðåÿ
Ôèêñèðîâàííûå íîâîñòè
Îðëà
Îòçûâû î ôèðìàõ
Òàðèôû
Ïîëüçîâàòåëè
Îáëàñòè
Áàíêîìàòû
Òîðãîâûå òî÷êè
Äîñêà îáúÿâëåíèé
Êóðñû âàëþò
Ñêèäêè
îðãàíèçàöèè Îðëà
îðãàíèçàöèè îáëàñòè
òîâàðû
ñàéòû
ñàéòû Îðåë
Äàííûå
Ðàçäåëû
Ïîèñê
Ïîèñê çàïðîñû
Ñòàòèñòèêà
Ïîêàçû êàòàëîãà îðãàíèçàöèé
Ñòàòèñòèêà êëèåíòû
Ïîëüçîâàòåëè
Ñàéòû
Óïðàâëåíèå ñàéòîì
Àíêåòà
Àïòåêè
Àôèøà
Àôèøà íîâàÿ
Áàííåðû
Áèçíåñ >
Âèêòîðèíà
Ãîëîñîâàíèå
Ãîñòü íà ñàéòå
Èñòîðèè
Êàëåíäàðü ñîáûòèé
Êàòàëîãè >
Êîíêóðñ êðàñîòû
Êîíêóðñ àóäèî
Êîíñóëüòàöèè
Ìåíþ
Íîâîå íà ñàéòå
Íîâîñòè >
Îðãàíèçàöèè >
Ïðîãðàììà ÒÂ
Ïóáëèêàöèè
Ðàçäåëû ñàéòà
Ðàññûëêà
Ðåñòîðàíû
Ñåêðåò ôèðìû >
Ñåðâèñû >
Ññûëêè
Òåñòû
Ôàéëîâûé ìåíåäæåð
Ôîðóì
Ôîòîãàëåðåÿ
Îáðàòíàÿ ñâÿçü
Íåäâèæèìîñòü
Íîâûé ãîä
Òåêñòû
Ïîëüçîâàòåëè
Þðèäè÷åñêèé ðåéòèíã
Îòçûâû íà òîâàðû
Áàí ïîëüçîâàòåëåé
Æàëîáû
Íîâûå òåñòû
Êîðîíàâèðóñ
Ôàéëîâûé ìåíåäæåð
Èìÿ ôàéëà
Organizations.php
Ñîäåðæèìîå
<?php namespace app\organizations; use App; use app\core\helpers\StringHelper; use app\core\storage\ImageUploader; use app\locality\Locality; use app\organizations\validators\AdditionalAddressAccessValidator; use app\organizations\validators\AddressValidator; use app\organizations\validators\EmailAccessValidator; use app\organizations\validators\EmailValidator; use app\organizations\validators\PhoneAccessValidator; use app\organizations\validators\PhoneValidator; use dimsog\arrayhelper\ArrayHelper; /** * КлаÑ�Ñ� длÑ� работы Ñ� организациÑ�ми. * Class Organizations * @package app\organizations */ class Organizations { /** * ПеречиÑ�ление Ñ�пиÑ�ка тарифов организации * из таблицы firma_tarif */ const TARIFF_GUEST = 0; const TARIFF_VIP = 1; const TARIFF_BUSINESS = 2; const TARIFF_STANDART = 3; const TARIFF_VISITKA = 5; const TARIFF_VISITKA_PACKET_1 = 7; const TARIFF_VISITKA_PACKET_2 = 8; const TARIFF_VISITKA_PACKET_3 = 9; public static function getLastOrganizations($count = 12) { $command = App::$command->createCommand(' SELECT firma.id, firma.name, firma.name_ur, firma.street, firma.house, firma.house_add, firma.corps, firma.build, firma.locality_id, firma.sub_adm_area_id, firma.adress, firma.address_add, firma_photo.photo, firma.build, firma_phone.number, locality.name as city_name FROM firma LEFT JOIN firma_photo ON firma_photo.firma_id = firma.id LEFT JOIN firma_phone ON firma_phone.id_firma = firma.id LEFT JOIN locality ON locality.id = firma.locality_id GROUP BY firma.id ORDER BY firma.id DESC LIMIT ' . $count ); $items = $command->queryAll(); foreach ($items as $key => $item) { $address = $item['city_name']; if ($item['street'] != '') { $address .= ', ' . $item['street']; } if ($item['house'] != '' && $item['house'] > 0) { if (is_numeric($item['house_add'])) { $address .= ', ' . $item['house'] . '/' . $item['house_add']; } else { $address .= ', ' . $item['house'] . ' ' . $item['house_add']; } } if ($item['corps'] != '') $address .= ' корпуÑ� ' . $item['corps']; if ($item['build'] != '') $address .= ' Ñ�троение ' . $item['build']; if ($item['address_add'] != '') $address .= ' ' . $item['address_add']; $items[$key]['address'] = $address; } return $items; } /** * ФункциÑ� возвращает общее количеÑ�тво моих орагинаций. * @param null $userId * @return int */ public static function getTotalCountMyOrganizations($userId = null) { if ($userId == null) { if (App::$user->isGuest() == true) { return 0; } $userId = App::$user->getId(); } return App::$command ->createCommand(' SELECT COUNT(*) as total FROM firma_superuser t1, firma t2 WHERE t1.user_id = :user_id and t1.firma_id=t2.id and (CURDATE() between t2.tarif_begin and t2.tarif_end) ') ->bindValue(':user_id', $userId) ->queryOne('total', 0); } /** * ФункциÑ� возвращает Ñ�пиÑ�ок моих организаций. * ИÑ�пользуетÑ�Ñ� в профиле пользователÑ�, длÑ� показа моих организаций * @param null $userId int - ID пользователÑ�. * ЕÑ�ли параметр задан как null, то беретÑ�Ñ� ид текущего авторизованного пользователÑ� * еÑ�ли пользователь не авторизован, возвращаетÑ�Ñ� пуÑ�той маÑ�Ñ�ив * * @param int|null $organizationId - ID организации. ЕÑ�ли нужно Ñ�делать выборку по пользователю * и по конкретной организации, или только по одной организации. * * @return array Ñ�пиÑ�ок организаций */ public static function getMyOrganizations($userId = null, $organizationId = null) { if ($userId == null) { if (App::$user->isGuest() == true) { return []; } $userId = App::$user->getId(); } $whereFragment = ''; if ($organizationId > 0) { $whereFragment = ' AND t2.id = ' . (int)$organizationId; } $command = App::$command ->createCommand(' SELECT t1.*, t2.* FROM firma_superuser t1, firma t2 WHERE t1.user_id=:user_id and t1.firma_id=t2.id and (CURDATE() between t2.tarif_begin and t2.tarif_end) ' . $whereFragment . ' ORDER BY t2.name '); $command->bindValue(':user_id', $userId); return $command->queryAll(); } /** * ФункциÑ� проверÑ�ет, Ñ�влÑ�етÑ�Ñ� ли организациÑ� моей или нет. * ФункциÑ� иÑ�пользуетÑ�Ñ� в профиле пользователÑ�, перед тем, как он начнет ее редактировать. * Чтобы Ñ�лучайно пользователь не Ñ�мог отредактировать чужую организацию. * * @param $organizationId int - ID организации * @param null $userId - int|null - id пользователÑ�, еÑ�ли параметр равен null, то беретÑ�Ñ� текущий пользователь * авторизованный пользователь, еÑ�ли пользователь не авторизован, возвращаетÑ�Ñ� false * * @return bool true - пользователю принадлежит организациÑ�, false - нет */ public static function isMyOrganization($organizationId, $userId = null) { if ($organizationId == null) { return false; } if ($userId == null) { if (App::$user->isGuest() == true) { return false; } $userId = App::$user->getId(); } $command = App::$command ->createCommand(' SELECT COUNT(id) as total FROM firma_superuser WHERE user_id = :user_id AND firma_id = :firma_id ') ->bindValue(':user_id', $userId) ->bindValue(':firma_id', $organizationId); return $command->queryOne('total', 0); } public static function isMyProduct($productId, $organizationId) { return App::$command ->createCommand(' SELECT COUNT(*) as total FROM `firma_shop_products` WHERE id_firm = :organization_id AND id = :product_id ') ->bindValue(':organization_id', $organizationId) ->bindValue(':product_id', $productId) ->queryOne('total') > 0; } public static function setDeliveryInfo($organizationId, $isDeliveryEnabled, $deliveryCategoryId, $deliveryImage, $deliveryText) { return App::$command ->createCommand(' UPDATE `firma` SET delivery_enabled = :delivery_enabled, delivery_text = :delivery_text, delivery_image = :delivery_image, delivery_category_id = :delivery_category_id WHERE id = :id ') ->bindValue(':delivery_enabled', (int) $isDeliveryEnabled) ->bindValue(':delivery_text', $deliveryText) ->bindValue(':delivery_image', $deliveryImage) ->bindValue(':delivery_category_id', $deliveryCategoryId) ->bindValue(':id', $organizationId) ->query(); } public static function isAllowNews($organizationId) { $tariff = static::findTariff($organizationId); if (empty($tariff)) { return false; } return $tariff['id'] >= self::TARIFF_VISITKA; } public static function isAllowReviews($organizationId) { $tariff = static::findTariff($organizationId); if (empty($tariff)) { return false; } return $tariff['id'] >= self::TARIFF_VISITKA; } /** * ФункциÑ� возвращает товары, которые выводÑ�Ñ‚Ñ�Ñ� на главной Ñ�транице и которые могут доÑ�тавлÑ�ть организации * @param int $limit */ public static function findDeliveryOrganizationsForIndexPage($limit = 20) { return App::$command ->createCommand(' SELECT f.id, f.name, f.firma_url, f.client_logo, f.delivery_enabled, f.delivery_text, f.delivery_image, f.delivery_category_id, c.name AS delivery_category_name, f.regim FROM firma f INNER JOIN firma_shop_categories c ON c.id = f.delivery_category_id WHERE f.shop_enabled = 1 GROUP BY f.id ORDER BY RAND() LIMIT ' . $limit . ' ') ->queryAll(); } public static function findDeliveryOrganizationsForCategory($categoryId, $page, $limit = 20) { $categoryId = (int) $categoryId; $page = (int) $page; $limit = (int) $limit; if ($page < 1) { $page = 1; } if ($limit < 1) { $limit = 1; } $whereFragment = ''; $offset = ($page - 1) * $limit; if ($categoryId > 0) { $whereFragment = 'AND f.delivery_category_id = ' . $categoryId; } return App::$command ->createCommand(' SELECT f.id, f.name, f.firma_url, f.client_logo, f.delivery_enabled, f.delivery_text, f.delivery_image, f.delivery_category_id, c.name AS delivery_category_name, f.regim FROM firma f INNER JOIN firma_shop_categories c ON c.id = f.delivery_category_id WHERE f.shop_enabled = 1 '. $whereFragment .' GROUP BY f.id ORDER BY RAND() LIMIT '. $offset .',' . $limit . ' ') ->queryAll(); } public static function findDeliveryImage(array $deliveryOrganization) { if (empty($deliveryOrganization['delivery_image']) == false) { return $deliveryOrganization['delivery_image']; } if (empty($deliveryOrganization['client_logo']) == false) { return $deliveryOrganization['client_logo']; } return 'images/organization-no-photo.png'; } public static function findTotalDeliveryOrganizations() { return App::$command ->createCommand(' SELECT COUNT(*) AS total FROM firma WHERE delivery_enabled = 1 ') ->queryOne('total'); } public static function getPreparedDeliveryText(array $deliveryOrganization) { return StringHelper::cut(htmlspecialchars($deliveryOrganization['delivery_text'], ENT_NOQUOTES), 255); } /** * ФункциÑ� проверÑ�ет, Ñ�ущеÑ�твует ли такаÑ� организациÑ� или нет * @param $id * @return bool */ public static function isExist($id) { return App::$command ->createCommand(' SELECT COUNT(id) as total FROM `firma` WHERE id = :id ') ->bindValue(':id', $id) ->queryOne('total', 0) > 0; } /** * ФункциÑ� проверÑ�ет, нужно ли делать редирект на Ñ�айт организации или нет. * ЕÑ�ли делать редирект нужно, то в Ñ�том Ñ�лучае функциÑ� вернет url адреÑ�, * еÑ�ли делать редирект не нужно, то функциÑ� вернет NULL * * @param $id - int - ID организации * @return string|null */ public static function getRedirectUrl($id) { $redirect = App::$command ->createCommand(' SELECT id, url_redirect FROM firma WHERE id = :id AND registr = 1 AND url_redirect != "" ') ->bindValue(':id', $id) ->queryOne('url_redirect'); if (mb_strpos($redirect, 'http') !== false) { return $redirect; } return null; } /** * ФункциÑ� возвращает организацию по $id или null, еÑ�ли организациÑ� не найдена * @param $id * @return array|null */ public static function getOrganization($id) { $data = App::$command ->createCommand(' SELECT firma.*, rubrik2.id_rubrik FROM `firma` INNER JOIN rubrik2 ON rubrik2.id_firm = firma.id WHERE firma.id = :id ') ->bindValue(':id', $id) ->queryOne(); if (isset($data['id']) == false) { return null; } $data['photos'] = OrganizationPhotos::getPhotos($id); $data['news'] = OrganizationNews::getNews($id); $data['phones'] = OrganizationPhones::getPhones($id); $data['emails'] = OrganizationEmails::getEmails($id); $data['videos'] = OrganizationVideos::getVideos($id); $data['files'] = OrganizationFiles::getFiles($id); $data['name_otrsl'] = Organizations::getOrganizationCategoryName($id); $data['site'] = OrganizationSites::findFirstSite($id); $streetFragment = ''; if (empty($data['street']) == false) { $streetFragment = ', ' . $data['street']; } $houseFragment = ''; if (empty($data['house']) == false) { $houseFragment = ', '. $data['house'] . $data['house_add']; } $data['full_address'] = Locality::getRayonName($data['sub_adm_area_id']) .', ' . Locality::getName($data['locality_id']) . $streetFragment . $houseFragment; if ($data['corps'] != '') { $data['full_address'] .= ', корпуÑ� ' . $data['corps']; } if ($data['build'] != '') { $data['full_address'] .= ', Ñ�троение ' . $data['build']; } if ($data['address_add'] != '') { $data['full_address'] .= ', ' . $data['address_add']; } $data['total_comments'] = Comments::total($data['id']); $data['category'] = (new OrganizationCategoryRepository())->findOne($data['id_rubrik']); $data['is_allow_news'] = static::isAllowNews($id); return $data; } public static function findBaseOrganizationInfo($id) { $data = App::$command ->createCommand(' SELECT firma.*, rubrik2.id_rubrik FROM `firma` INNER JOIN rubrik2 ON rubrik2.id_firm = firma.id WHERE firma.id = :id ') ->bindValue(':id', $id) ->queryOne(); if (empty($data)) { return null; } $data['city_id'] = (int) $data['locality_id']; $data['district_id'] = (int) $data['sub_adm_area_id']; $data['home'] = $data['house']; $data['apartment'] = (int) $data['address_add']; return $data; } public static function getOrganizationBasicInfo($id) { return App::$command ->createCommand(' SELECT id, firma_url, name FROM firma WHERE id = :id ') ->bindValue(':id', $id) ->queryOne(); } /** * @param $id * @return int|false */ public static function getOrganizationCategoryId($id) { return App::$command ->createCommand(' SELECT * FROM rubrik2 WHERE id_firm = :id ') ->bindValue(':id', $id) ->queryOne('id_rubrik', false); } /** * @param $id * @return string|false */ public static function getOrganizationCategoryName($id) { $id_rubrik=Organizations::getOrganizationCategoryId($id); return App::$command ->createCommand(' SELECT name_otrsl FROM otrasl2 WHERE id = :id ') ->bindValue(':id', $id_rubrik) ->queryOne('name_otrsl', false); } /** * ФункциÑ� возвращает маÑ�Ñ�ив хлебных крошек длÑ� организации $id * Ð�втомобили > Ð�втошколы * @param int $id - ID организации * @return array */ public static function getOrganizationBreadCrumbsArray($id) { $rootCategoryId = static::getOrganizationCategoryId($id); if ($rootCategoryId === false) { return []; } return Categories::getBreadCrumbsIds($rootCategoryId); } /** * ФункциÑ� проверÑ�ет * @param $organizationId * @return bool */ public static function isVisitka($organizationId) { return App::$command ->createCommand(' SELECT COUNT(*) as total FROM `firma` WHERE id = :id AND id_tarif > 0 AND tarif_begin <= CURDATE() AND tarif_end >= CURDATE() AND registr = 1 ') ->bindValue(':id', $organizationId) ->queryOne('total', 0) > 0; } public static function getAddress($organizationId) { $address_parts = []; $company = App::$command ->createCommand(' SELECT id, name, street, house_add, house, corps, build, sub_adm_area_id, address_add, locality_id FROM firma WHERE id = :id ') ->bindValue(':id', $organizationId) ->queryOne(); if (isset($company['id']) == false) { return null; } $localityName = Locality::getName($company['locality_id']); if (!preg_match('/город/', $localityName)) { $subArea = App::$command ->createCommand(" SELECT * FROM sub_admn_area WHERE id = :id ") ->bindValue(':id', $company['sub_adm_area_id']) ->queryOne(); if (isset($subArea['name'])) { $address_parts[] = $subArea['name']; } } $address_parts[] = $localityName; if ($company['street']!='') $address_parts[] = $company['street']; if ( $company['house'] != '' && $company['house'] > 0 ) { if ( $company['house_add'] != '' ) { if (is_numeric($company['house_add'])) $address_parts[] = $company['house'].'/'.$company['house_add']; else $address_parts[] = $company['house'].$company['house_add']; } else $address_parts[] = $company['house']; } if ( $company['corps'] != '' ) $address_parts[] = 'корпуÑ� ' . $company['corps']; if ( $company['build'] != '' ) $address_parts[] = 'Ñ�троение ' . $company['build']; if ( $company['address_add'] != '' ) $address_parts[] = $company['address_add']; return implode(', ', $address_parts); } public static function getAddresses($organizationId) { return App::$command ->createCommand(' SELECT * FROM `firma_address` WHERE firma_id = :id ORDER BY id ASC ') ->bindValue(':id', $organizationId) ->queryAll(); } public static function getWorkHours($organizationId) { return App::$command ->createCommand(' SELECT id, regim FROM firma WHERE id = :id ') ->bindValue(':id', $organizationId) ->queryOne('regim', null); } public function getRating($organizationId) { return Rating::get($organizationId); } /** * ФункциÑ� возвращает ID организации из запроÑ�а, * ID может быть передан как $_GET параметр, так и находитьÑ�Ñ� в базе, из которой мы вытащим его через ЧПУ * @return int|null */ public static function getOrganizationIdByRequest() { $organizationId = App::$request->get('id'); if ($organizationId > 0) { return $organizationId; } if (isset($_REQUEST['cpu']) && $_REQUEST['cpu'] != '') { return App::$command ->createCommand(' SELECT id FROM firma WHERE short_url = :short_url ') ->bindValue(':short_url', $_REQUEST['cpu']) ->queryOne('id', null); } // ЧПУ длÑ� организации. // ЧПУ вида http://infoorel.ru/company/tratata.html if (isset($_GET['firma_url'])) { return static::getOrganizationIdByUrl($_GET['firma_url']); } return null; } /** * @param $organizationId * @return array */ public static function getSliders($organizationId) { return App::$command ->createCommand(' SELECT * FROM firma_sliders WHERE firma_id = :firma_id ') ->bindValue(':firma_id', $organizationId) ->queryAll(); } /** * ФункциÑ� обновлÑ�ет проÑ�м * @param $organizationId * @return boolean */ public static function updateViews($organizationId) { return App::$command ->createCommand(' UPDATE `firma` SET views = views + 1 WHERE id = :id ') ->bindValue(':id', $organizationId) ->query(); } public static function updateName($organizationId, $name) { if (empty($name)) { throw new \DomainException("Укажите имÑ� организации"); } return App::$command ->createCommand(' UPDATE `firma` SET `name` = :name WHERE id = :id ') ->bindValue(':name', $name) ->bindValue(':id', $organizationId) ->query(); } /** * Ðтот метод обновлÑ�ет оÑ�новной адреÑ� организации * @param $organizationId * @param $cityId * @param $street * @param $home * @param $floor * @param $apartment * @return bool */ public static function updateAddress($organizationId, $cityId, $street, $home, $floor, $apartment) { $validator = new AddressValidator(); $validator->validateOrFail($cityId, $street, $home, $floor, $apartment); $city = Locality::find($cityId); return App::$command ->createCommand(' UPDATE `firma` SET sub_adm_area_id = :district_id, locality_id = :locality_id, adress = :address, house = :home, floor = :floor, address_add = :apartment WHERE id = :id ') ->bindValue(':district_id', $city['sub_admn_area_id']) ->bindValue(':locality_id', $city['id']) ->bindValue(':address', $street) ->bindValue(':home', $home) ->bindValue(':floor', $floor) ->bindValue(':apartment', $apartment) ->bindValue(':id', $organizationId) ->query(); } public static function addAdditionalAddress($organizationId, $cityId, $street, $home, $floor, $apartment) { $validator = new AddressValidator(); $validator->validateOrFail( $cityId, $street, $home, $floor, $apartment ); return App::$command ->createCommand(' INSERT INTO `firma_address` (firma_id, city_id, street, home, floor, apartment) VALUES (:organization_id, :city_id, :street, :home, :floor, :apartment) ') ->bindValue(':organization_id', $organizationId) ->bindValue(':city_id', $cityId) ->bindValue(':street', $street) ->bindValue(':home', $home) ->bindValue(':floor', $floor) ->bindValue(':apartment', $apartment) ->query(); } public static function findAdditionalAddresses($organizationId) { return App::$command ->createCommand(' SELECT firma_address.*, locality.sub_admn_area_id as district_id FROM `firma_address` LEFT JOIN locality ON locality.id = firma_address.city_id WHERE firma_address.firma_id = :id ') ->bindValue(':id', $organizationId) ->queryAll(); } public static function deleteAdditionalAddresses($organizationId) { return App::$command ->createCommand(' DELETE FROM `firma_address` WHERE firma_id = :firma_id ') ->bindValue(':firma_id', $organizationId) ->query(); } public static function findPhones($organizationId) { return App::$command ->createCommand(' SELECT * FROM `firma_phone` WHERE id_firma = :organization_id ORDER BY `id` ASC ') ->bindValue(':organization_id', $organizationId) ->queryAll(); } public static function addPhone($organizationId, $number, $ext, $comment = null, $active = false) { $validator = new PhoneValidator(); $validator->validateOrFail( $number, $ext, $comment, $active ); return App::$command ->createCommand(' INSERT INTO `firma_phone` (id_firma, `number`, ext, info, `type`, active) VALUES(:id_firma, :number, :ext, :info, :type, :active) ') ->bindValue(':id_firma', $organizationId) ->bindValue(':number', $number) ->bindValue(':ext', $ext) ->bindValue(':info', $comment) ->bindValue(':type', 1) ->bindValue(':active', (int) $active) ->query(); } public static function deletePhone($id) { return App::$command ->createCommand(' DELETE FROM `firma_phone` WHERE id = :id ') ->bindValue(':id', $id) ->query(); } public static function deletePhones($organizationId) { return App::$command ->createCommand(' DELETE FROM `firma_phone` WHERE id_firma = :id_firma ') ->bindValue(':id_firma', $organizationId) ->query(); } /** * ДобавлÑ�ем новый Email адреÑ� * @param $organizationId * @param $email * @return bool */ public static function addEmail($organizationId, $email) { if (filter_var($email, FILTER_VALIDATE_EMAIL) == false) { throw new \DomainException('Укажите Email в правильном формате'); } return App::$command ->createCommand(' INSERT INTO `firma_email` (id_firma, email) VALUES(:id_firma, :email) ') ->bindValue(':id_firma', $organizationId) ->bindValue(':email', $email) ->query(); } /** * УдалÑ�ем вÑ�е email адреÑ�а у организаций * @param $organizationId * @return bool */ public static function deleteEmails($organizationId) { return App::$command ->createCommand(' DELETE FROM `firma_email` WHERE id_firma = :organization_id ') ->bindValue(':organization_id', $organizationId) ->query(); } public static function findEmails($organizationId) { return App::$command ->createCommand(' SELECT * FROM `firma_email` WHERE id_firma = :organization_id ORDER BY `id` ASC ') ->bindValue(':organization_id', $organizationId) ->queryAll(); } /** * ФункциÑ� обновлÑ�ет логотип * @param $organizationId * @param $filePath * @return bool */ public static function updateLogo($organizationId, $filePath) { if (static::isMyOrganization($organizationId) == false) { return false; } return App::$command ->createCommand(' UPDATE firma SET client_logo = :client_logo WHERE id = :id ') ->bindValue(':id', $organizationId) ->bindValue(':client_logo', $filePath) ->query(); } public static function updateLogoFromRequest($organizationId, $field = 'client_logo') { if (isset($_FILES[$field]['tmp_name']) == false || file_exists($_FILES[$field]['tmp_name']) == false) { throw new \DomainException("Изображение длÑ� логотипа не передано"); } $clientLogo = ImageUploader::upload_foto( $_FILES[$field]['tmp_name'], 200, 350, 0, 1, "user_foto/company/logo" ); if ($clientLogo === false) { throw new \DomainException("Ð�е удалоÑ�ÑŒ загрузить логотип"); } static::updateLogo($organizationId, $clientLogo); } /** * ФункциÑ� возвращает ID тарифа организации. * @param $organizationId * @return mixed|null */ public static function getTarifId($organizationId) { return App::$command ->createCommand(' SELECT id_tarif FROM firma WHERE id = :id ') ->bindValue(':id', $organizationId) ->queryOne('id_tarif', 0); } public static function findTariff($organizationId) { $tariffId = static::getTarifId($organizationId); return App::$command ->createCommand(' SELECT * FROM `firma_tarif` WHERE id = :id ') ->bindValue(':id', $tariffId) ->queryOne(); } public static function isAllowProducts($organizationId) { // разрешаем вÑ�е return true; // $tariff = static::findTariff($organizationId); // return $tariff['product_count'] > 0; } /** * ФункциÑ� проверÑ�ет, можно ли еще добавлÑ�ть товары или нет * @param $organizationId * @return bool */ public static function isAllowAddProducts($organizationId) { // разрешаем пока вÑ�ем return true; // $total = App::$command // ->createCommand(' // SELECT COUNT(*) as total // FROM `firma_shop_products` // WHERE id_firm = :organization_id // ') // ->bindValue(':organization_id', $organizationId) // ->queryOne('total'); // $tariff = static::findTariff($organizationId); // // return $tariff['product_count'] > $total; } /** * ФункциÑ� возвращает ID организации, знаÑ� ее URL * @param $url * @return int|null */ public static function getOrganizationIdByUrl($url) { return App::$command ->createCommand(' SELECT id FROM firma WHERE firma_url = :url ') ->bindValue(':url', $url) ->queryOne('id', null); } /** * ФункциÑ� возвращает URL организации, знаÑ� ее $id * @param $id * @return string|null */ public static function getOrganizationUrlById($id) { return App::$command ->createCommand(' SELECT firma_url FROM firma WHERE id = :id ') ->bindValue(':id', $id) ->queryOne('firma_url', null); } /** * ФункциÑ� возвращает полный URL к организации, знаÑ� ее Id * @param $organizationId * @return string|null */ public function getFullUrl($organizationId) { $organizationData = App::$command ->createCommand(' SELECT firma_url WHERE id = :id ') ->bindValue(':id', $organizationId) ->queryOne('firma_url'); if ($organizationData === null) { return null; } return '/company/' . $organizationData['firma_url'] . '.html'; } }
/app/organizations/
Èìÿ
Äàòà
Ðàçìåð
..
2026-10-01
activerecord
2017-03-23
banners
2017-03-20
entity
2019-02-11
form
2020-04-06
helpers
2019-02-08
interfaces
2017-01-26
regions
2017-02-02
search
2019-02-12
shop
2020-04-06
statistic
2019-01-29
utils
2018-01-12
validators
2020-02-11
views
2018-01-16
Categories.php
2019-02-13
6 êá.
CommentVote.php
2024-08-23
5 êá.
CommentVote.php~
2017-01-26
5 êá.
Comments.php
2019-02-26
6 êá.
CommentsKarma.php
2017-01-26
308 áàéò
OrganizationCategory.php
2019-02-11
896 áàéò
OrganizationCategoryFactory.php
2018-01-12
1 êá.
OrganizationCategoryRepository.php
2019-02-12
2 êá.
OrganizationCommentsReader.php
2019-02-18
5 êá.
OrganizationEmails.php
2017-03-09
1 êá.
OrganizationFactory.php
2016-12-13
277 áàéò
OrganizationFiles.php
2017-02-15
645 áàéò
OrganizationIndexator.php
2017-08-18
349 áàéò
OrganizationNews.php
2019-08-23
2 êá.
OrganizationPhones.php
2019-02-11
7 êá.
OrganizationPhotos.php
2017-08-15
2 êá.
OrganizationRepository.php
2019-02-12
433 áàéò
OrganizationRubriks.php
2017-03-09
2 êá.
OrganizationSchedule.php
2018-01-12
2 êá.
OrganizationScheduleFactory.php
2018-01-12
844 áàéò
OrganizationSites.php
2020-04-09
1 êá.
OrganizationSlider.php
2019-08-12
1 êá.
OrganizationStatistics.php
2019-04-01
2 êá.
OrganizationVideos.php
2017-01-25
1 êá.
Organizations.php
2020-04-17
34 êá.
OrganizationsReader.php
2019-02-11
4 êá.
PhoneRepository.php
2019-02-11
1 êá.
Rating.php
2024-08-23
2 êá.
Rating.php~
2019-02-15
1 êá.
/app/organizations
Çàãðóçèòü ôàéëû
Ôàéë 1
Ôàéë 2
Ôàéë 3