public function search_ajax() { $string = $this->params->query['string']; $res = array(); if (empty($string)) { $this->Error->setError('ERROR_251'); return false; } else { //поиск по услугам $name = 'name_' . lang_prefix(); $service_result = $this->Service->find('all', array('conditions' => array('OR' => array('name_ru LIKE' => '%' . $string . '%', 'name_en LIKE' => '%' . $string . '%', 'name_kz LIKE' => '%' . $string . '%')))); if (count($service_result) > 0) { foreach ($service_result as $result) { $category = $this->Categories->find('first', array('conditions' => array('id' => $result['Service']['main_category_id']))); if (count($category) > 0) { //pr($category); $category_prefix = $category['Categories']['url_prefix']; $res['elem'][] = array('name' => $result['Service'][$name], 'link' => site_url() . "/" . Configure::read('SERVICE_URL_PREFIX') . "/" . $category_prefix . "/" . $result['Service']['url_prefix'], 'type' => 'service'); } } } //поиск по категориям услуг $name = 'name_' . lang_prefix(); $category_result = $this->Categories->find('all', array('conditions' => array('OR' => array('name_ru LIKE' => '%' . $string . '%', 'name_en LIKE' => '%' . $string . '%', 'name_kz LIKE' => '%' . $string . '%')))); if ($category_result !== null) { foreach ($category_result as $result) { $res['elem'][] = array('name' => $result['Categories'][$name], 'link' => site_url() . "/" . Configure::read('SERVICE_URL_PREFIX') . "/" . $result['Categories']['url_prefix'], 'type' => 'category'); } } $user_result = $this->Master->find('all', array('conditions' => array('OR' => array('Master.lastname LIKE' => '%' . $string . '%', 'Master.firstname LIKE' => '%' . $string . '%')))); if (count($user_result) > 0) { foreach ($user_result as &$result) { $res['elem'][] = array('name' => prepare_fio($result['Master']['firstname'], $result['Master']['lastname'], $result['Master']['fathername']), 'link' => site_url() . "/profile/" . $result['Master']['login'] . "/", 'type' => 'master'); } } $response = array(); if ($result !== null) { $response["result"] = "success"; $response["query_data"] = $res; response_ajax($response, "success"); } else { $response["result"] = "error"; response_ajax($response, "error"); } exit; } }
public function setup_password() { $key = $this->params->key; if (!valid_hash($key)) { die(L('RECOVERY_KEY_NOT_HASH')); } //поиск ключа по базе $find_user = $this->User->find('first', array('conditions' => array('mail_key' => $key))); if (count($find_user) == 0) { $this->redirect(array('controller' => 'recovery', 'action' => 'failed')); exit; } else { //форма смены пароля $fio = prepare_fio($find_user['User']['firstname'], $find_user['User']['lastname'], $find_user['User']['fathername']); $image = $find_user['User']['main_foto']; $this->set('fio', $fio); $this->set('main_image', $image); $this->set('mail', $find_user['User']['mail']); $this->set('recover_user_id', $find_user['User']['id']); $this->Session->write('recover_user_id', $find_user['User']['id']); $this->Session->write('mail', $find_user['User']['mail']); } }
public function user_feeds() { $this->admin_path_title_name = "Управление заявками - отзывы о мастере - "; $this->set('title', Configure::read('SITENAME') . " - " . Configure::read('ADMIN_PANEL') . " - " . $this->admin_path_title_name); $id = $this->request->query['id']; $user = $this->Master->find('first', array('conditions' => array('id' => $id))); // если материал не существует if ($user !== null) { $this->Breadcrumbs->add(prepare_fio($user['Master']['firstname'], $user['Master']['lastname'], $user['Master']['fathername']), Router::url(array('plugin' => false, 'controller' => 'admin/user', 'action' => 'view/' . $user['Master']['id']))); $this->Breadcrumbs->add('Отзывы о мастере', ''); //список $this->loadModel('Feedback'); $user_feeds = $this->Feedback->find('all', array('conditions' => array('user_id' => $id), 'order' => 'created DESC')); $this->set('user_feeds', $user_feeds); } }
public function ajax_search_master() { $string = $this->params->data['find']; $order_id = $this->params->data['id']; $data = array(); if (empty($string)) { $this->Error->setError('ERROR_251'); return false; } else { if (!is_numeric($string)) { if (mb_strlen($string) < 3) { exit; } $user_result = $this->Master->find('all', array('conditions' => array('OR' => array(array('Master.lastname LIKE' => '%' . $string . '%'), array('Master.login LIKE' => '%' . $string . '%'), array('Master.firstname LIKE' => '%' . $string . '%'))), 'fields' => array('Master.firstname', 'Master.lastname', 'Master.fathername', 'Master.id', 'Master.login', 'Master.main_foto'))); } else { if (is_numeric($string)) { //поиск по мастерам $user_result = $this->Master->find('all', array('conditions' => array('OR' => array(array('Master.id LIKE' => '%' . $string . '%'))), 'fields' => array('Master.firstname', 'Master.lastname', 'Master.fathername', 'Master.id', 'Master.login', 'Master.main_foto'))); } } if ($user_result !== null) { foreach ($user_result as $result) { $user_id = $result['Master']['id']; $get_status = $this->Masterorder->find('first', array('conditions' => array('order_id' => $order_id, 'user_id' => $user_id))); if (count($get_status) == 0) { $get_status_text = 'free'; // admin_request, admin_reject, admin_done, admin_proceed } else { if ($get_status['Masterorder']['status'] == 'admin_request') { $get_status_text = 'already_sent'; } else { if ($get_status['Masterorder']['status'] == 'admin_reject') { $get_status_text = 'free'; } else { if ($get_status['Masterorder']['status'] == 'master_reject') { $get_status_text = 'master_reject'; } else { if ($get_status['Masterorder']['status'] == 'master_request') { $get_status_text = 'master_request'; } else { $get_status_text = 'free'; } } } } } $data[] = array('name' => prepare_fio($result['Master']['firstname'], $result['Master']['lastname'], $result['Master']['fathername']), 'link' => site_url() . "/profile/" . $result['Master']['login'] . "/", 'type' => 'master', 'id' => $user_id, 'foto' => site_url() . "/" . Configure::read('USER_FILE_UPLOAD_DIR_RELATIVE') . "/u" . $result['Master']['id'] . "/" . $result['Master']['main_foto'], 'order_status' => $get_status_text); } } $response = array(); if ($result !== null) { $response["result"] = "success"; $response["query_data"] = $data; response_ajax($response, "success"); } else { $response["result"] = "error"; response_ajax($response, "error"); } exit; } }
public function feed_success() { $this->title_name = L("FEED_SUCCESS"); $this->set('title', Configure::read('SITENAME') . " - " . $this->title_name); $profile_url_prefix = $this->request->params['profile']; $user = $this->Master->find('first', array('conditions' => array('login' => $profile_url_prefix))); // если профиль существует if ($user !== null) { $this->Breadcrumbs->add(prepare_fio($user['Master']['lastname'], $user['Master']['firstname'], $user['Master']['fathername']), Router::url(array('plugin' => false, 'controller' => 'profile', 'action' => 'index', 'profile' => $profile_url_prefix))); $user_id = $user['Master']['id']; $this->set('user_id', $user_id); } $this->Breadcrumbs->add(L("FEED_SUCCESS"), ''); $this->set('comeback_url', Router::url(array('plugin' => false, 'controller' => 'profile', 'action' => 'index', 'profile' => $profile_url_prefix))); }
public function view_user() { $id = $this->params->id; if (!is_numeric($id)) { $this->redirect(array('controller' => 'showerror', 'action' => '/')); exit; } $this->admin_path_title_name = "Управление пользователями"; $this->set('title', Configure::read('SITENAME') . " - " . Configure::read('ADMIN_PANEL') . " - " . $this->admin_path_title_name); //материал $user = $this->Master->find('first', array('conditions' => array('id' => $id))); // если материал не существует if ($user !== null) { $this->Breadcrumbs->add(prepare_fio($user['Master']['firstname'], $user['Master']['lastname'], $user['Master']['fathername']), ''); $this->loadModel('Userphone'); //$this->Userphone->useTable = "user_phones"; $user['phones'] = $this->Userphone->find('all', array('conditions' => array('user_id' => $id))); $this->set('user', $user); $view_data = isset($this->params->query['view']) ? $this->params->query['view'] : null; //список авторизаций if ($view_data == "auth") { $this->loadModel('Userauth'); $auths = $this->Userauth->find('first', array('conditions' => array('user_id' => $id))); $this->set('auths', $auths); } $this->set('view_data', $view_data); //Услуги //загрузка услуг пользователя $this->loadModel('Servicetouser'); $this->Servicetouser->useTable = 'service_to_users'; $user_services = $this->Servicetouser->find('all', array('conditions' => array('user_id' => $id))); $this->loadModel('Service'); foreach ($user_services as &$user_service) { $service_id = $user_service['Servicetouser']['service_id']; $service = $this->Service->find('all', array('conditions' => array('id' => $service_id))); $user_service['Servicetouser']['name_ru'] = $service[0]['Service']['name_ru']; $user_service['Servicetouser']['name_en'] = $service[0]['Service']['name_en']; $user_service['Servicetouser']['name_kz'] = $service[0]['Service']['name_kz']; } $this->set('user_services', $user_services); //загрузка расценок пользователя $this->loadModel('Userprices'); $this->Userprices->useTable = 'user_prices'; $user_prices = $this->Userprices->find('all', array('conditions' => array('user_id' => $id), 'joins' => array(array('table' => 'service_pay_types', 'alias' => 'Paytype', 'type' => 'INNER', 'conditions' => array('Paytype.id = Userprices.pay_type_id'))), 'fields' => array('Paytype.*', 'Userprices.*'))); $this->set('user_prices', $user_prices); } else { $this->redirect(array('controller' => 'showerror', 'action' => '/')); } }
public function view_all() { $parse_param = $this->params->id; $parse_param = explode("_", $parse_param); $type = $parse_param[0]; $id = $parse_param[1]; $types = array('user', 'admin'); if (!is_numeric($id)) { $this->redirect(array('controller' => 'showerror', 'action' => '/')); exit; } if (!in_array($type, $types)) { $this->redirect(array('controller' => 'showerror', 'action' => '/')); exit; } $this->admin_path_title_name = "Управление сообщениями"; $this->set('title', Configure::read('SITENAME') . " - " . Configure::read('ADMIN_PANEL') . " - " . $this->admin_path_title_name); if ($type == "user") { $user_message = $this->User->find('first', array('conditions' => array('id' => $id))); $this->Breadcrumbs->add("Переписка с пользователем " . prepare_fio($user_message['User']['lastname'], $user_message['User']['firstname'], $user_message['User']['fathername']), ''); } else { $user_message = $this->Admin->find('first', array('conditions' => array('id' => $id))); $this->Breadcrumbs->add("Переписка с администратором " . prepare_fio($user_message['Admin']['lastname'], $user_message['Admin']['firstname'], $user_message['Admin']['fathername']), ''); } //материал $message_data = $this->Adminticket->find('all', array('conditions' => array('OR' => array(array('sender_id' => $id, 'sender_type' => $type), array('receiver_id' => $id, 'receiver_type' => $type))), 'order' => 'date_sent DESC')); // если переписки нет if (count($message_data) > 0) { //$user_message = $this->User->find('first', array('conditions' => array('id' => $user_id))); foreach ($message_data as &$message) { $sender_type = $message['Adminticket']['sender_type']; $receiver_type = $message['Adminticket']['receiver_type']; $sender_id = $message['Adminticket']['sender_id']; $receiver_id = $message['Adminticket']['receiver_id']; if ($sender_type == "admin") { $admin = $this->Admin->find('first', array('conditions' => array('id' => $sender_id))); $message['Message']['sender_type'] = "Администратор"; $message['Message']['sender_link'] = "control"; $message['Message']['sender_firstname'] = $admin['Admin']['firstname']; $message['Message']['sender_lastname'] = $admin['Admin']['lastname']; $message['Message']['sender_fathername'] = $admin['Admin']['fathername']; } else { $user = $this->User->find('first', array('conditions' => array('id' => $sender_id))); $message['Message']['sender_type'] = "Пользователь"; $message['Message']['sender_link'] = "user"; $message['Message']['sender_firstname'] = $user['User']['firstname']; $message['Message']['sender_lastname'] = $user['User']['lastname']; $message['Message']['sender_fathername'] = $user['User']['fathername']; } if ($receiver_type == "admin") { $admin = $this->Admin->find('first', array('conditions' => array('id' => $receiver_id))); $message['Message']['receiver_type'] = "Администратор"; $message['Message']['receiver_link'] = "control"; $message['Message']['receiver_firstname'] = $admin['Admin']['firstname']; $message['Message']['receiver_lastname'] = $admin['Admin']['lastname']; $message['Message']['receiver_fathername'] = $admin['Admin']['fathername']; } else { $user = $this->User->find('first', array('conditions' => array('id' => $receiver_id))); $message['Message']['receiver_type'] = "Пользователь"; $message['Message']['receiver_link'] = "user"; $message['Message']['receiver_firstname'] = $user['User']['firstname']; $message['Message']['receiver_lastname'] = $user['User']['lastname']; $message['Message']['receiver_fathername'] = $user['User']['fathername']; } $message_type = $this->MessageType->find('first', array('conditions' => array('id' => $message['Adminticket']['message_type']))); $message['Message']['message_type'] = $message_type['MessageType']['name_ru']; } $this->set('message_data', $message_data); $this->set('sender_data', $sender_type . "_" . $sender_id); $this->set('receiver_data', $receiver_type . "_" . $receiver_id); } else { $this->set('message_data', null); } }