Доброе время суток
Я новенький в этой среде
У меня проблема с сортировкой таблицы которая выводится на странице.
Есть 3 страницы 2 с задачами общими а 1 с личными но эта страница формируется с одной общей таблицы когда я нажимаю на сортировку по какому либо полю меня перенаправляет на основную и сортирует там(на основных сортировка работает)
1.Я не понимаю каким принципом формируется эта страница
2.Мне нужно чтобы на личных задачах происходила сортировка а не перенаправляла на основную страницу
эта crm была сделана до меня и непонятно кем + здесь стоит ядро от joomla
это код
PHP |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
| <?php
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.model' );
class clicModelTask extends JModel
{
var $_page = null;
function getItems()
{
global $app;
$limitstart = JRequest::getInt('limitstart');
$limit = 1000;
$user = &JFactory::getUser();
if($user->id!=0)
{
$where = ' where task_published='.JRequest::getInt('published',1);
if(!JRequest::getInt('project_id'))
if(!JRequest::getInt('task_status'))
if(JRequest::getVar('task')!='all_task'&&!JRequest::getInt('user_id'))
$where .= ' and task_user_id='.$user->id;
else
if(JRequest::getInt('user_id'))
$where .= ' and task_user_id='.JRequest::getInt('user_id');
if(JRequest::getInt('project_id'))
$where .= ' and task_project_id = '.JRequest::getInt('project_id');
if(JRequest::getInt('task_status'))
$where .= ' and task_status = '.JRequest::getInt('task_status').' and project_manager_id='.$user->id;
if(JRequest::getVar('task')=='my_task')
$where .= ' and task_status = 1';
if($user->id==42)
{
if(JRequest::getVar('task')=='all_task')
{
$where = ' ';
}
}else
{
jimport('joomla.user.helper');
$user_groups = JUserHelper::getUserGroups($user->id);
$user_group = current($user_groups);
if(($user_group==6||$user_group==7)&&JRequest::getVar('task')=='all_task')
$where .= ' and project_manager_id='.$user->id;
}
$order = '';
if(JRequest::getVar('order')!=''&&JRequest::getVar('order'))
$order = ' order by '.JRequest::getVar('order').' '.JRequest::getVar('order_dir');
$query = 'SELECT *,T2.name, T4.name manager_name, T3.project_name FROM `#__clic_task` T1
JOIN #__users T2 ON T1.task_user_id=T2.id
JOIN #__clic_projects T3 ON T1.task_project_id=T3.project_id
LEFT JOIN #__users T4 ON T3.project_manager_id=T4.id '.$where.' '. $order;
$db = &JFactory::getDBO();
$this->_data = $this->_getList($query,$limitstart,$limit);
$db->setQuery('SELECT count(1) FROM `#__clic_task` T1
JOIN #__users T2 ON T1.task_user_id=T2.id
JOIN #__clic_projects T3 ON T1.task_project_id=T3.project_id
LEFT JOIN #__users T4 ON T3.project_manager_id=T4.id '.$where);
$total = $db->loadResult();
if(JRequest::getVar('task')=='all_task')
{
$db->setQuery('UPDATE `#__clic_task` T1,`#__clic_projects` T2 SET task_status_change=0 WHERE T2.project_manager_id='.$user->id);
//echo 'UPDATE `#__clic_task` T1,`#__clic_projects` T2 SET task_status_change=0 WHERE T2.project_manager_id='.$user->id;
$db->query();
}
jimport('joomla.html.pagination');
$this->_page = new JPagination($total, $limitstart, $limit);
return $this->_data;
}
}
function getItem()
{
$id = JRequest::getVar('cid');
$table = $this->getTable();
$table->load($id[0]);
return $table;
}
function getPagination()
{
if (is_null($this->_list) || is_null($this->_page))
{
$this->getItems();
}
return $this->_page;
}
function delete($id)
{
$table = $this->getTable();
$table->load($id);
$table->task_published = 0;
$table->store();
}
function save()
{
$post = JRequest::get('post');
if($post['task_name_select']!='0')
$post['task_name'] = $post['task_name_select'];
$table = $this->getTable();
if(!$table->bind($post))
JError::raiseError(500, $table->getError() );
if(!$table->store())
JError::raiseError(500, $table->getError() );
}
function setStatus()
{
$user = &JFactory::getUser();
$status = JRequest::getInt('status');
if($status == 2)
$status = 0;
$table = $this->getTable();
$table->load(JRequest::getInt('task_id'));
$table->task_status = JRequest::getInt('status');
$table->task_status_change = 1;
if(JRequest::getInt('status')==2)
$table->task_is_new = 0;
else
if(JRequest::getInt('status')==1)
$table->task_is_new = 1;
$table->task_who_change = $user->id;
$table->store();
}
function makeNewTask($project_id,$man_id,$task_name){
$user = &JFactory::getUser();
$table = $this->getTable();
$table->task_project_id = $project_id;
$table->task_user_id = $man_id;
$table->task_name = $task_name;
$table->task_status = 1;
$table->task_published = 1;
$table->task_is_new = 1;
$table->store();
return '1';
}
function hasProjectTask($project_id,$task_name){
$db = &JFactory::getDBO();
$db->setQuery('SELECT count(1) FROM `#__clic_task` '.
' where (task_project_id='.(int)$project_id.')'.
' and (task_name="'.mysql_real_escape_string($task_name).'")');
return $db->loadResult();
}
}
?> |
|