103 |
- |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* Copyright(C) 2009-2019 www.seopanel.in. All rights reserved.
|
|
|
4 |
* @author Geo Varghese
|
|
|
5 |
*
|
|
|
6 |
*/
|
|
|
7 |
class SD_Manager extends SeoDiary {
|
|
|
8 |
|
|
|
9 |
var $cronJob = false;
|
|
|
10 |
var $statusList;
|
|
|
11 |
|
|
|
12 |
function __construct() {
|
|
|
13 |
parent::__construct();
|
|
|
14 |
parent::initPlugin(true);
|
|
|
15 |
$this->statusList = array(
|
|
|
16 |
'new' => $this->pluginText['New'],
|
|
|
17 |
'closed' => $this->pluginText['Closed'],
|
|
|
18 |
'cancelled' => $this->pluginText['Cancelled'],
|
|
|
19 |
'inprogress' => $this->pluginText['Inprogress'],
|
|
|
20 |
'blocked' => $this->pluginText['Blocked'],
|
|
|
21 |
'feedback' => $this->pluginText['Feedback'],
|
|
|
22 |
);
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
function showSDList($info = "") {
|
|
|
26 |
$userId = isLoggedIn ();
|
|
|
27 |
$this->set ( 'post', $info );
|
|
|
28 |
$cond = "";
|
|
|
29 |
|
|
|
30 |
$projectCtrler = $this->createHelper ( 'Project' );
|
|
|
31 |
$projectList = $projectCtrler->__getAllProjects ( $userId, true );
|
|
|
32 |
$this->set ( 'projectList', $projectList );
|
|
|
33 |
|
|
|
34 |
if (!isAdmin ()) {
|
|
|
35 |
if (SD_ALLOW_USER_PROJECTS) {
|
|
|
36 |
$prjIdList = [0];
|
|
|
37 |
foreach ($projectList as $projectInfo) $prjIdList[] = $projectInfo['id'];
|
|
|
38 |
$cond .= " and d.project_id in (".implode(',', $prjIdList).")";
|
|
|
39 |
} else {
|
|
|
40 |
$cond .= " and d.assigned_user_id=$userId";
|
|
|
41 |
}
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
$cond .= !empty( $info ['project_id'] ) ? " and d.project_id=" . intval ( $info ['project_id'] ) : "";
|
|
|
45 |
$cond .= !empty( $info ['category_id'] ) ? " and d.category_id=" . intval ( $info ['category_id'] ) : "";
|
|
|
46 |
$cond .= !empty( $info ['assigned_user_id'] ) ? " and d.assigned_user_id=" . intval ( $info ['assigned_user_id'] ) : "";
|
|
|
47 |
$cond .= !empty( $info ['keyword'] ) ? " and (title LIKE '%" . addslashes ( $info ['keyword'] ) . "%' OR d.description LIKE '%" . addslashes ( $info ['keyword'] ) . "%')" : "";
|
|
|
48 |
$cond .= !empty( $info ['status'] ) ? " and d.status='" . addslashes( $info ['status'] ) ."'" : "";
|
|
|
49 |
$cond .= !empty( $info ['sort_col'] ) ? " order by " . addslashes ( $info ['sort_col'] ) : "";
|
|
|
50 |
$cond .= !empty( $info ['sort_val'] ) ? " " . addslashes ( $info ['sort_val'] ) : "";
|
|
|
51 |
|
|
|
52 |
$info ['user_id'] = intval ( $info ['assigned_user_id'] );
|
|
|
53 |
$pgScriptPath = PLUGIN_SCRIPT_URL . "&action=diaryManager";
|
|
|
54 |
$sql = "select d.*,p.name project_name, c.label category_label from sd_seo_diary d, sd_category c, sd_projects p
|
|
|
55 |
where d.project_id=p.id and d.category_id=c.id $cond ";
|
|
|
56 |
|
|
|
57 |
$userCtrler = new UserController ();
|
|
|
58 |
$userList = $userCtrler->__getAllUsers ();
|
|
|
59 |
$this->set( 'userList', $userList );
|
|
|
60 |
$userIdList = [];
|
|
|
61 |
|
|
|
62 |
foreach ( $userList as $userInfo ) {
|
|
|
63 |
$userIdList [$userInfo ['id']] = $userInfo;
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
$this->set ( 'userIdList', $userIdList );
|
|
|
67 |
$categoryList = $this->selectDiaryCategory ();
|
|
|
68 |
$this->set ( 'categoryList', $categoryList );
|
|
|
69 |
$this->set( 'statusList', $this->statusList);
|
|
|
70 |
|
|
|
71 |
// pagination setup
|
|
|
72 |
$this->db->query ( $sql, true );
|
|
|
73 |
$this->paging->setDivClass ( 'pagingdiv' );
|
|
|
74 |
$this->paging->loadPaging ( $this->db->noRows, SP_PAGINGNO );
|
|
|
75 |
$pagingDiv = $this->paging->printPages ( $pgScriptPath, 'searchform', 'scriptDoLoadPost', 'content', '');
|
|
|
76 |
$this->set ( 'pagingDiv', $pagingDiv );
|
|
|
77 |
$sql .= " limit " . $this->paging->start . "," . $this->paging->per_page;
|
|
|
78 |
|
|
|
79 |
$projectList = $this->db->select ( $sql );
|
|
|
80 |
$this->set ( 'list', $projectList );
|
|
|
81 |
$this->set ( 'pageNo', $_GET ['pageno'] );
|
|
|
82 |
$this->pluginRender ( 'diary_manager' );
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
/*
|
|
|
86 |
* func to create new project
|
|
|
87 |
*/
|
|
|
88 |
function newDiary($info = '') {
|
|
|
89 |
$userId = isLoggedIn ();
|
|
|
90 |
$userCtrler = new UserController ();
|
|
|
91 |
$userList = $userCtrler->__getAllUsers ();
|
|
|
92 |
$this->set ( 'userList', $userList );
|
|
|
93 |
|
|
|
94 |
$projectCtrler = $this->createHelper ( 'Project' );
|
|
|
95 |
$projectList = $projectCtrler->__getAllProjects ( $userId, true );
|
|
|
96 |
$this->set ( 'projectList', $projectList );
|
|
|
97 |
|
|
|
98 |
$categoryList = $this->selectDiaryCategory ();
|
|
|
99 |
$this->set ( 'categoryList', $categoryList );
|
|
|
100 |
$this->set( 'statusList', $this->statusList);
|
|
|
101 |
$this->set ( 'spTextReport', $this->getLanguageTexts('report', $_SESSION['lang_code']));
|
|
|
102 |
$this->pluginRender ( 'new_diary' );
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
/*
|
|
|
106 |
* func to create diary
|
|
|
107 |
*/
|
|
|
108 |
function createDiary($listInfo) {
|
|
|
109 |
$this->set ( 'post', $listInfo );
|
|
|
110 |
$now = date('Y-m-d H:i:s');
|
|
|
111 |
$errMsg ['project_id'] = formatErrorMsg ( $this->validate->checkBlank ( $listInfo ['project_id'] ) );
|
|
|
112 |
$errMsg ['category_id'] = formatErrorMsg ( $this->validate->checkBlank ( $listInfo ['category_id'] ) );
|
|
|
113 |
$errMsg ['title'] = formatErrorMsg ( $this->validate->checkBlank ( $listInfo ['title'] ) );
|
|
|
114 |
$errMsg ['description'] = formatErrorMsg ( $this->validate->checkBlank ( $listInfo ['description'] ) );
|
|
|
115 |
$errMsg ['status'] = formatErrorMsg ( $this->validate->checkBlank ( $listInfo ['status'] ) );
|
|
|
116 |
|
|
|
117 |
if (! $this->validate->flagErr) {
|
|
|
118 |
|
|
|
119 |
if ($this->__checkTitle ($listInfo ['title'], $listInfo ['project_id'] )) {
|
|
|
120 |
$errMsg ['title'] = formatErrorMsg ($this->pluginText['Diary already exist']);
|
|
|
121 |
$this->validate->flagErr = true;
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
if (!$this->validate->flagErr) {
|
|
|
125 |
$listInfo['created_user_id'] = isLoggedIn();
|
|
|
126 |
$listInfo['update_time'] = $now;
|
|
|
127 |
$listInfo['creation_time'] = $now;
|
|
|
128 |
$this->insertDiary($listInfo);
|
|
|
129 |
$this->showSDList(['keyword' => $listInfo ['title']]);
|
|
|
130 |
exit();
|
|
|
131 |
}
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
$this->set('errMsg', $errMsg );
|
|
|
135 |
$this->newDiary( $listInfo );
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
function insertDiary($listInfo) {
|
|
|
139 |
$sql = "INSERT INTO `sd_seo_diary`(`project_id`, `assigned_user_id`, `category_id`, `title`, `description`, `due_date`, `status`,
|
|
|
140 |
`email_notification`, `creation_time`, `update_time`, `created_user_id`)
|
|
|
141 |
VALUES('" . intval ( $listInfo ['project_id'] ) . "', '" . intval ( $listInfo ['assigned_user_id'] ) . "',
|
|
|
142 |
'" . intval ( $listInfo ['category_id'] ) . "', '" . addslashes ( $listInfo ['title'] ) . "',
|
|
|
143 |
'" . addslashes ( $listInfo ['description'] ) . "', '" . addslashes ( $listInfo ['due_date'] ) . "',
|
|
|
144 |
'" . addslashes ( $listInfo ['status'] ) . "', ".intval($listInfo['email_notification']).",
|
|
|
145 |
'" . addslashes ( $listInfo ['creation_time'] ) . "', '" . addslashes ( $listInfo ['creation_time'] ) . "', ".intval($listInfo['created_user_id']).")";
|
|
|
146 |
$this->db->query( $sql );
|
|
|
147 |
|
|
|
148 |
// email notification enabled, send mail
|
|
|
149 |
if (!empty($listInfo['email_notification']) && !empty($listInfo ['assigned_user_id'])) {
|
|
|
150 |
$this->sendNotificationMail($listInfo);
|
|
|
151 |
}
|
|
|
152 |
|
|
|
153 |
}
|
|
|
154 |
|
|
|
155 |
function sendNotificationMail($listInfo) {
|
|
|
156 |
$userId = $listInfo ['assigned_user_id'];
|
|
|
157 |
$subject = $this->pluginText['Assigned to You'] . ": " . $listInfo['title'];
|
|
|
158 |
$userController = new UserController ();
|
|
|
159 |
$userInfo = $userController->__getUserInfo ( $userId );
|
|
|
160 |
$userName = $userInfo ['first_name'] . "-" . $userInfo ['last_name'];
|
|
|
161 |
$adminInfo = $userController->__getAdminInfo();
|
|
|
162 |
$adminName = $adminInfo['first_name']."-".$adminInfo['last_name'];
|
|
|
163 |
$this->set ( 'userName', $userName );
|
|
|
164 |
$this->set ( 'listInfo', $listInfo);
|
|
|
165 |
$content = $this->getPluginViewContent('notification_mail');
|
|
|
166 |
|
|
|
167 |
if (sendMail( $adminInfo ['email'], $adminName, $userInfo['email'], $subject, $content )) {
|
|
|
168 |
showSuccessMsg("Notifiaction Mail send successfully to " . $userInfo ['email'], FALSE);
|
|
|
169 |
} else {
|
|
|
170 |
showErrorMsg('An internal error occured while sending mail!', FALSE);
|
|
|
171 |
}
|
|
|
172 |
}
|
|
|
173 |
|
|
|
174 |
/*
|
|
|
175 |
* func to edit diary
|
|
|
176 |
*/
|
|
|
177 |
function editDiary($diaryId, $listInfo = '') {
|
|
|
178 |
|
|
|
179 |
if (!empty( $diaryId )) {
|
|
|
180 |
|
|
|
181 |
if (empty($listInfo )) {
|
|
|
182 |
$listInfo = $this->__getDiaryInfo ( $diaryId );
|
|
|
183 |
}
|
|
|
184 |
|
|
|
185 |
$this->set ( 'post', $listInfo );
|
|
|
186 |
$userCtrler = new UserController ();
|
|
|
187 |
$userList = $userCtrler->__getAllUsers ();
|
|
|
188 |
$this->set ( 'userList', $userList );
|
|
|
189 |
|
|
|
190 |
$userId = isLoggedIn ();
|
|
|
191 |
$projectCtrler = $this->createHelper ( 'Project' );
|
|
|
192 |
$projectList = $projectCtrler->__getAllProjects ( $userId, true );
|
|
|
193 |
$this->set ( 'projectList', $projectList );
|
|
|
194 |
|
|
|
195 |
$categoryList = $this->selectDiaryCategory ();
|
|
|
196 |
$this->set ( 'categoryList', $categoryList );
|
|
|
197 |
$this->set( 'statusList', $this->statusList);
|
|
|
198 |
$this->set ( 'spTextReport', $this->getLanguageTexts('report', $_SESSION['lang_code']));
|
|
|
199 |
$this->pluginRender ( 'edit_diary' );
|
|
|
200 |
}
|
|
|
201 |
}
|
|
|
202 |
|
|
|
203 |
/*
|
|
|
204 |
* func to update project
|
|
|
205 |
*/
|
|
|
206 |
function updateDiary($listInfo) {
|
|
|
207 |
$this->set ( 'post', $listInfo );
|
|
|
208 |
$errMsg = [];
|
|
|
209 |
$errMsg ['project_id'] = formatErrorMsg ( $this->validate->checkBlank ( $listInfo ['project_id'] ) );
|
|
|
210 |
$errMsg ['category_id'] = formatErrorMsg ( $this->validate->checkBlank ( $listInfo ['category_id'] ) );
|
|
|
211 |
$errMsg ['title'] = formatErrorMsg ( $this->validate->checkBlank ( $listInfo ['title'] ) );
|
|
|
212 |
$errMsg ['description'] = formatErrorMsg ( $this->validate->checkBlank ( $listInfo ['description'] ) );
|
|
|
213 |
$errMsg ['status'] = formatErrorMsg ( $this->validate->checkBlank ( $listInfo ['status'] ) );
|
|
|
214 |
|
|
|
215 |
if (! $this->validate->flagErr) {
|
|
|
216 |
|
|
|
217 |
if ($this->__checkTitle ( $listInfo ['title'], $listInfo ['project_id'], $listInfo ['id'] )) {
|
|
|
218 |
$errMsg ['title'] = formatErrorMsg ($this->pluginText['Diary already exist']);
|
|
|
219 |
$this->validate->flagErr = true;
|
|
|
220 |
}
|
|
|
221 |
|
|
|
222 |
if (! $this->validate->flagErr) {
|
|
|
223 |
$oldDiaryInfo = $this->__getDiaryInfo($listInfo ['id']);
|
|
|
224 |
$sql = "update sd_seo_diary set project_id = " . intval ( $listInfo ['project_id'] ) . ", category_id = " . intval ( $listInfo ['category_id'] ) .
|
|
|
225 |
", title = '" . addslashes ( $listInfo ['title'] ) . "', description = '" . addslashes ( $listInfo ['description'] ) .
|
|
|
226 |
"', assigned_user_id = '" . intval ( $listInfo ['assigned_user_id'] ) . "', due_date = '" . addslashes ( $listInfo ['due_date'] ) .
|
|
|
227 |
"', update_time = '" . date ( "Y-m-d H:i:s" ) . "', status = '" . addslashes ( $listInfo ['status'] ) . "' where id=" . intval ( $listInfo ['id'] );
|
|
|
228 |
$this->db->query ( $sql );
|
|
|
229 |
|
|
|
230 |
// email notification enabled, send mail
|
|
|
231 |
if (!empty($listInfo['email_notification']) && !empty($listInfo ['assigned_user_id'])) {
|
|
|
232 |
if ($oldDiaryInfo['assigned_user_id'] != $listInfo ['assigned_user_id']) {
|
|
|
233 |
$this->sendNotificationMail($listInfo);
|
|
|
234 |
}
|
|
|
235 |
}
|
|
|
236 |
|
|
|
237 |
$this->showSDList(['keyword' => $listInfo ['title']]);
|
|
|
238 |
exit();
|
|
|
239 |
}
|
|
|
240 |
|
|
|
241 |
}
|
|
|
242 |
|
|
|
243 |
$this->set ( 'errMsg', $errMsg );
|
|
|
244 |
$this->editDiary( $listInfo ['id'], $listInfo );
|
|
|
245 |
}
|
|
|
246 |
|
|
|
247 |
/*
|
|
|
248 |
* func to delete project
|
|
|
249 |
*/
|
|
|
250 |
function deleteDiary($diaryId) {
|
|
|
251 |
$diaryId = intval ( $diaryId );
|
|
|
252 |
$sql = "delete from sd_seo_diary where id=" . intval ( $diaryId );
|
|
|
253 |
$this->db->query ( $sql );
|
|
|
254 |
$this->showSDList ();
|
|
|
255 |
}
|
|
|
256 |
|
|
|
257 |
function getUserDiaryList($userId) {
|
|
|
258 |
$cond = "";
|
|
|
259 |
$userId = intval($userId);
|
|
|
260 |
|
|
|
261 |
if (!isAdmin()) {
|
|
|
262 |
if (SD_ALLOW_USER_PROJECTS) {
|
|
|
263 |
$projectCtrler = $this->createHelper ( 'Project' );
|
|
|
264 |
$projectList = $projectCtrler->__getAllProjects ( $userId, true );
|
|
|
265 |
$prjIdList = [0];
|
|
|
266 |
foreach ($projectList as $projectInfo) $prjIdList[] = $projectInfo['id'];
|
|
|
267 |
$cond .= " project_id in (".implode(',', $prjIdList).")";
|
|
|
268 |
} else {
|
|
|
269 |
$cond .= " assigned_user_id=$userId";
|
|
|
270 |
}
|
|
|
271 |
}
|
|
|
272 |
|
|
|
273 |
$diaryList = $this->dbHelper->getAllRows('sd_seo_diary', $cond);
|
|
|
274 |
return $diaryList;
|
|
|
275 |
}
|
|
|
276 |
|
|
|
277 |
/*
|
|
|
278 |
* func to create new comments
|
|
|
279 |
*/
|
|
|
280 |
function newDiaryComments($info = '') {
|
|
|
281 |
$this->set ( 'post', $info );
|
|
|
282 |
$userId = isLoggedIn();
|
|
|
283 |
|
|
|
284 |
$diaryList = $this->getUserDiaryList($userId);
|
|
|
285 |
$this->set ( 'diaryList', $diaryList );
|
|
|
286 |
|
|
|
287 |
if (empty($info['diary_id'] )) {
|
|
|
288 |
$diaryId = $diaryList[0]['id'];
|
|
|
289 |
} else {
|
|
|
290 |
$diaryId = intval($info['diary_id']);
|
|
|
291 |
}
|
|
|
292 |
|
|
|
293 |
if (empty($diaryId)) {
|
|
|
294 |
showErrorMsg($_SESSION['text']['common']['No Records Found']);
|
|
|
295 |
}
|
|
|
296 |
|
|
|
297 |
$diaryInfo = $this->__getDiaryInfo($diaryId);
|
|
|
298 |
$this->set ('diaryInfo', $diaryInfo );
|
|
|
299 |
$this->set ('diaryId', $diaryId );
|
|
|
300 |
|
|
|
301 |
$userCtrler = new UserController ();
|
|
|
302 |
$userList = $userCtrler->__getAllUsers();
|
|
|
303 |
$userIdList = [];
|
|
|
304 |
foreach ( $userList as $userInfo ) $userIdList [$userInfo ['id']] = $userInfo;
|
|
|
305 |
$this->set ( 'userIdList', $userIdList );
|
|
|
306 |
|
|
|
307 |
$diaryCommentList = $this->getDiaryComments( " and diary_id=" . intval($diaryId));
|
|
|
308 |
$this->set ( 'diaryCommentList', $diaryCommentList );
|
|
|
309 |
$this->pluginRender ( 'diary_comments' );
|
|
|
310 |
}
|
|
|
311 |
|
|
|
312 |
/*
|
|
|
313 |
* func to create project
|
|
|
314 |
*/
|
|
|
315 |
function createDiaryComment($listInfo) {
|
|
|
316 |
$userId = isLoggedIn ();
|
|
|
317 |
$this->set ( 'post', $listInfo );
|
|
|
318 |
$errMsg ['diary_id'] = formatErrorMsg ( $this->validate->checkBlank ( $listInfo ['diary_id'] ) );
|
|
|
319 |
$errMsg ['comments'] = formatErrorMsg ( $this->validate->checkBlank ( $listInfo ['comments'] ) );
|
|
|
320 |
|
|
|
321 |
if (! $this->validate->flagErr) {
|
|
|
322 |
$sql = "INSERT INTO `sd_diary_comments`( `diary_id`, `user_id`, `comments`, `updated_time`)
|
|
|
323 |
VALUES ('" . intval ( $listInfo ['diary_id'] ) . "','" . intval ( $userId ) . "',
|
|
|
324 |
'" . addslashes ( $listInfo ['comments'] ) . "','". date("Y-m-d H:i:s")."')";
|
|
|
325 |
$this->db->query ( $sql );
|
|
|
326 |
$this->newDiaryComments(['diary_id' => $listInfo ['diary_id']]);
|
|
|
327 |
exit ();
|
|
|
328 |
}
|
|
|
329 |
|
|
|
330 |
$this->set ('errMsg', $errMsg );
|
|
|
331 |
$this->newDiaryComments ( $listInfo );
|
|
|
332 |
}
|
|
|
333 |
|
|
|
334 |
/*
|
|
|
335 |
* func to project shummary
|
|
|
336 |
*/
|
|
|
337 |
function showProjectSummery($info = '') {
|
|
|
338 |
$this->set ( 'post', $info );
|
|
|
339 |
$userId = isLoggedIn ();
|
|
|
340 |
$projectCtrler = $this->createHelper ( 'Project' );
|
|
|
341 |
$projectList = $projectCtrler->__getAllProjects ( $userId, true );
|
|
|
342 |
$this->set ( 'projectList', $projectList );
|
|
|
343 |
|
|
|
344 |
if (empty($info['project_id'] )) {
|
|
|
345 |
$projectId = $projectList[0]['id'];
|
|
|
346 |
} else {
|
|
|
347 |
$projectId = intval($info['project_id']);
|
|
|
348 |
}
|
|
|
349 |
|
|
|
350 |
if (empty($projectId)) {
|
|
|
351 |
showErrorMsg($_SESSION['text']['common']['No Records Found']);
|
|
|
352 |
}
|
|
|
353 |
|
|
|
354 |
$projectInfo = $projectCtrler->__getProjectInfo($projectId);
|
|
|
355 |
$this->set('projectInfo', $projectInfo);
|
|
|
356 |
|
|
|
357 |
$diaryList = $this->__getDiaryList(" project_id = " . intval($projectId));
|
|
|
358 |
foreach ( $diaryList as $i => $listInfo ) {
|
|
|
359 |
$diaryList[$i]['comment_count'] = $this->getDiarytCommentCount($listInfo['id']);
|
|
|
360 |
}
|
|
|
361 |
|
|
|
362 |
$this->set ( 'diaryList', $diaryList );
|
|
|
363 |
$this->set ( 'spTextSA', $this->getLanguageTexts('siteauditor', $_SESSION['lang_code']));
|
|
|
364 |
$this->pluginRender ( 'project_summery' );
|
|
|
365 |
}
|
|
|
366 |
|
|
|
367 |
/*
|
|
|
368 |
* show tasks assigned users
|
|
|
369 |
*/
|
|
|
370 |
function showTaskList($info = "") {
|
|
|
371 |
$this->set ( 'post', $info );
|
|
|
372 |
$userId = isLoggedIn ();
|
|
|
373 |
$cond .= " and d.assigned_user_id=$userId";
|
|
|
374 |
|
|
|
375 |
$cond .= !empty( $info ['project_id'] ) ? " and d.project_id=" . intval ( $info ['project_id'] ) : "";
|
|
|
376 |
$cond .= !empty( $info ['keyword'] ) ? " and (title LIKE '%" . addslashes ( $info ['keyword'] ) . "%' OR d.description LIKE '%" . addslashes ( $info ['keyword'] ) . "%')" : "";
|
|
|
377 |
$cond .= !empty( $info ['status'] ) ? " and d.status='" . addslashes( $info ['status'] ) ."'" : "";
|
|
|
378 |
$cond .= !empty( $info ['sort_col'] ) ? " order by " . addslashes ( $info ['sort_col'] ) : "";
|
|
|
379 |
$cond .= !empty( $info ['sort_val'] ) ? " " . addslashes ( $info ['sort_val'] ) : "";
|
|
|
380 |
|
|
|
381 |
$info ['user_id'] = intval ( $info ['assigned_user_id'] );
|
|
|
382 |
$pgScriptPath = PLUGIN_SCRIPT_URL . "&action=myTasks";
|
|
|
383 |
$sql = "select d.*,p.name project_name, c.label category_label from sd_seo_diary d, sd_category c, sd_projects p
|
|
|
384 |
where d.project_id=p.id and d.category_id=c.id $cond ";
|
|
|
385 |
|
|
|
386 |
$userCtrler = new UserController ();
|
|
|
387 |
$userList = $userCtrler->__getAllUsers ();
|
|
|
388 |
$this->set ( 'userList', $userList );
|
|
|
389 |
$userIdList = [ ];
|
|
|
390 |
|
|
|
391 |
foreach ( $userList as $userInfo ) {
|
|
|
392 |
$userIdList [$userInfo ['id']] = $userInfo;
|
|
|
393 |
}
|
|
|
394 |
|
|
|
395 |
$this->set ( 'userIdList', $userIdList );
|
|
|
396 |
|
|
|
397 |
$projectCtrler = $this->createHelper ( 'Project' );
|
|
|
398 |
$projectList = $projectCtrler->__getAllProjects ( $userId, true );
|
|
|
399 |
$this->set ( 'projectList', $projectList );
|
|
|
400 |
|
|
|
401 |
$categoryList = $this->selectDiaryCategory ();
|
|
|
402 |
$this->set ( 'categoryList', $categoryList );
|
|
|
403 |
$this->set ( 'statusList', $this->statusList );
|
|
|
404 |
|
|
|
405 |
// pagination setup
|
|
|
406 |
$this->db->query ( $sql, true );
|
|
|
407 |
$this->paging->setDivClass ( 'pagingdiv' );
|
|
|
408 |
$this->paging->loadPaging ( $this->db->noRows, SP_PAGINGNO );
|
|
|
409 |
$pagingDiv = $this->paging->printPages ( $pgScriptPath, 'searchform', 'scriptDoLoadPost', 'content', '');
|
|
|
410 |
$this->set ( 'pagingDiv', $pagingDiv );
|
|
|
411 |
$sql .= " limit " . $this->paging->start . "," . $this->paging->per_page;
|
|
|
412 |
|
|
|
413 |
$taskList = $this->db->select ( $sql );
|
|
|
414 |
$this->set ( 'list', $taskList );
|
|
|
415 |
$this->set ( 'pageNo', $_GET ['pageno'] );
|
|
|
416 |
$this->pluginRender ( 'my_task' );
|
|
|
417 |
}
|
|
|
418 |
|
|
|
419 |
/*
|
|
|
420 |
* func to get all category type
|
|
|
421 |
*/
|
|
|
422 |
function getDiaryComments($condtions = '') {
|
|
|
423 |
$sql = "select * from sd_diary_comments where 1=1";
|
|
|
424 |
$sql .= empty( $condtions ) ? "" : $condtions;
|
|
|
425 |
$diaryCommentList = $this->db->select( $sql );
|
|
|
426 |
return $diaryCommentList;
|
|
|
427 |
}
|
|
|
428 |
|
|
|
429 |
/*
|
|
|
430 |
* func to get all category type
|
|
|
431 |
*/
|
|
|
432 |
function selectDiaryCategory($condtions = '') {
|
|
|
433 |
$sql = "select id, label from sd_category";
|
|
|
434 |
$sql .= empty ( $condtions ) ? "" : $condtions;
|
|
|
435 |
$categoryList = $this->db->select ( $sql );
|
|
|
436 |
return $categoryList;
|
|
|
437 |
}
|
|
|
438 |
|
|
|
439 |
/*
|
|
|
440 |
* func to get all category type
|
|
|
441 |
*/
|
|
|
442 |
function getDiarytCommentCount($diaryId) {
|
|
|
443 |
$diaryCountInfo = $this->dbHelper->getRow('sd_diary_comments', "diary_id=".intval($diaryId), "count(*) count");
|
|
|
444 |
return !empty($diaryCountInfo['count']) ? $diaryCountInfo['count'] : 0;
|
|
|
445 |
}
|
|
|
446 |
|
|
|
447 |
/*
|
|
|
448 |
* function to check name of project already existing
|
|
|
449 |
*/
|
|
|
450 |
function __checkTitle($title, $projectId, $diaryId = 0) {
|
|
|
451 |
$diaryId = intval ( $diaryId );
|
|
|
452 |
$sql = "select id from sd_seo_diary where title='" . addslashes ( $title ) . "' and project_id=".intval($projectId);
|
|
|
453 |
$sql .= !empty( $diaryId ) ? " and id!=$diaryId" : "";
|
|
|
454 |
$listInfo = $this->db->select ( $sql, true );
|
|
|
455 |
return empty ( $listInfo ['id'] ) ? false : $listInfo ['id'];
|
|
|
456 |
}
|
|
|
457 |
|
|
|
458 |
/*
|
|
|
459 |
* func to get project info
|
|
|
460 |
*/
|
|
|
461 |
function __getDiaryInfo($diaryId) {
|
|
|
462 |
$sql = "select d.*,p.name project_name from sd_seo_diary d,sd_projects p where d.project_id=p.id and d.id=" . intval ( $diaryId );
|
|
|
463 |
$info = $this->db->select ( $sql, true );
|
|
|
464 |
return $info;
|
|
|
465 |
}
|
|
|
466 |
|
|
|
467 |
function __getDiaryList($cond = '') {
|
|
|
468 |
$diaryList = $this->dbHelper->getAllRows('sd_seo_diary', $cond);
|
|
|
469 |
return $diaryList;
|
|
|
470 |
}
|
|
|
471 |
|
|
|
472 |
/*function startCronJob() {
|
|
|
473 |
$this->cronJob = true;
|
|
|
474 |
$sql = "SELECT `id`,`assigned_user_id`, `due_date`, `status` FROM `sd_seo_diary` WHERE `status`= 'new' or `sd_seo_diary`.`status`='inprogress'";
|
|
|
475 |
$diaryList = $this->db->select($sql);
|
|
|
476 |
|
|
|
477 |
if (count($diaryList) > 0) {
|
|
|
478 |
foreach ($diaryList as $diaryListInfo) {
|
|
|
479 |
$diaryId =$diaryListInfo['id'];
|
|
|
480 |
$this->generateDairyList($diaryId);
|
|
|
481 |
|
|
|
482 |
}
|
|
|
483 |
} else {
|
|
|
484 |
echo "Diary List generated for all the projects!";
|
|
|
485 |
}
|
|
|
486 |
|
|
|
487 |
}
|
|
|
488 |
|
|
|
489 |
function generateDairyList($diaryId) {
|
|
|
490 |
|
|
|
491 |
$datetime = new DateTime(date('Y-m-d'));
|
|
|
492 |
$datetime->modify('+1 day');
|
|
|
493 |
$datetime->format('Y-m-d');
|
|
|
494 |
$diaryInfo = $this->__getDiaryInfo($diaryId);
|
|
|
495 |
|
|
|
496 |
|
|
|
497 |
if (($diaryInfo['status'] == "new" || "inprogress") || ($diaryInfo['due_date'] > $datetime)) {
|
|
|
498 |
$userId = $diaryInfo ['assigned_user_id'];
|
|
|
499 |
$subject = "your assingned diary was changed";
|
|
|
500 |
$content = $this->getViewContent('mailview', 'ajax', false);
|
|
|
501 |
$userController = new UserController ();
|
|
|
502 |
$userInfo = $userController->__getUserInfo ( $userId );
|
|
|
503 |
$adminInfo = $userController->__getAdminInfo ();
|
|
|
504 |
$userName = $userInfo ['first_name'] . "-" . $userInfo ['last_name'];
|
|
|
505 |
$this->set ( 'userName', $userName );
|
|
|
506 |
|
|
|
507 |
if (! sendMail ( $adminInfo ['email'], $userName, $userInfo ['email'], $subject, $content )) {
|
|
|
508 |
echo "Reports send successfully to " . $userInfo ['email'] . "\n";
|
|
|
509 |
} else {
|
|
|
510 |
echo 'An internal error occured while sending mail!';
|
|
|
511 |
}
|
|
|
512 |
?><br><?php print $adminInfo ['email'];
|
|
|
513 |
print $userName;
|
|
|
514 |
print $userInfo ['email'];
|
|
|
515 |
print $subject;
|
|
|
516 |
print $content;
|
|
|
517 |
}
|
|
|
518 |
}*/
|
|
|
519 |
|
|
|
520 |
}
|
|
|
521 |
|