Commit a458c50f authored by Vladislav's avatar Vladislav

Поправлено отображение данных

parent 3a61f332
......@@ -8,7 +8,8 @@ class Users extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->model('admins/mdl_users');
$this->load->model('admins/mdl_sites');
$this->user_id = $this->mdl_session->getData('user_id');
$this->usertype = $this->mdl_session->getData('usertype');
if ($this->usertype != 'admin') {
......@@ -52,7 +53,7 @@ class Users extends CI_Controller {
$data = $this->mdl_jqgrid->collectionData();
$data['user_id'] = $this->mdl_request->int('id');
echo json_encode($this->mdl_typos->getUserSites($data));
echo json_encode($this->mdl_sites->getUserSites($data));
return;
}
......
......@@ -117,7 +117,61 @@ class Mdl_sites extends CI_Model {
return $return_data;
}
/**
* Получаем сайты пользователя
*/
function getUserSites($data) {
$user_id = $data['user_id'];
//Данные для pagination jqGrid
if ($data['querysearchstring'] != '') {
$data['querysearchstring'] = " AND ".$data['querysearchstring']." ";
}
$data['query_count'] = "SELECT COUNT(DISTINCT user_id) AS count
FROM responsible AS r
WHERE user_id = '".(int)$user_id."'
".$data['querysearchstring']." ";
$data_pagination = $this->mdl_jqgrid->Pagination($data);
/**/
$return_data = array(
'page' => $data_pagination['page'],
'total' => $data_pagination['total'],
'records' => $data_pagination['records'],
'rows' => array(),
);
$query_users = "SELECT DISTINCT s.site_id AS site_id,
r.status AS rstatus,
s.site AS site,
s.status AS sstatus,
r.datetime_add AS datetime_add
FROM responsible AS r
JOIN site AS s ON s.site_id = r.site_id
WHERE r.user_id = '".(int)$user_id."'
".$data['querysearchstring']."
ORDER BY ".$data['sidx']." ".$data['sord']."
LIMIT ".$data_pagination['start']." , ".$data_pagination['limit']." ";
$query = $this->db->query($query_users);
if ($query->num_rows() > 0) {
foreach($query->result_array() as $row) {
$return_data['rows'][] = array(
'id' => $row['site_id'],
'cell' => array(
$row['site_id'],
$row['site'],
$row['rstatus'],
$row['datetime_add'],
)
);
}
}
return $return_data;
}
/*Добавление сайта*/
function addSite($data) {
return $this->mdl_stored_query->insertSite($data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment