forked from opencats/OpenCATS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataGrids.php
More file actions
413 lines (377 loc) · 20.1 KB
/
Copy pathdataGrids.php
File metadata and controls
413 lines (377 loc) · 20.1 KB
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
<?php
/*
* CATS
* Home Datagrid
*
* CATS Version: 0.9.7.4
*
* Copyright (C) 2005 - 2007 Cognizo Technologies, Inc.
*
*
* The contents of this file are subject to the CATS Public License
* Version 1.1a (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.catsone.com/. Software distributed under the License is
* distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is "CATS Standard Edition".
*
* The Initial Developer of the Original Code is Cognizo Technologies, Inc.
* Portions created by the Initial Developer are Copyright (C) 2005 - 2007
* (or from the year in which this file was created to the year 2007) by
* Cognizo Technologies, Inc. All Rights Reserved.
*
* $Id: dataGrids.php 3583 2007-11-12 23:04:42Z brian $
*/
include_once(LEGACY_ROOT . '/lib/Hooks.php');
include_once(LEGACY_ROOT . '/lib/InfoString.php');
include_once(LEGACY_ROOT . '/lib/Pipelines.php');
include_once(LEGACY_ROOT . '/lib/Width.php');
class ImportantPipelineDashboard extends DataGrid
{
protected $_siteID;
// FIXME: Fix ugly indenting - ~400 character lines = bad.
public function __construct($siteID, $parameters)
{
/* Pager configuration. */
$this->_tableWidth = new Width(100, "%");
$this->_defaultAlphabeticalSortBy = 'lastName';
$this->ajaxMode = true;
$this->showExportColumn = false;
$this->showExportCheckboxes = false;
$this->showActionArea = true;
$this->showChooseColumnsBox = true;
$this->allowResizing = true;
$this->dateCriterion = '';
$this->globalStyle = 'font-size:11px;';
$this->ignoreSavedColumnLayouts = true;
$this->defaultSortBy = 'dateModifiedSort';
$this->defaultSortDirection = 'DESC';
$this->_defaultColumns = array(
array('name' => 'First Name', 'width' => 85),
array('name' => 'Last Name', 'width' => 75),
array('name' => 'Status', 'width' => 75),
array('name' => 'Position', 'width' => 275),
array('name' => 'Company', 'width' => 210),
array('name' => 'Modified', 'width' => 80),
);
$this->_db = DatabaseConnection::getInstance();
$this->_siteID = $siteID;
$this->_assignedCriterion = "";
$this->_candidateIDColumn = 'company.company_id';
$this->_classColumns = array(
'First Name' => array('pagerRender' => '$ret = \'<img src="images/mru/candidate.gif" height="12" alt="" />\'; if ($rsData[\'isHot\'] == 1) $className = \'jobLinkHot\'; else $className = \'jobLinkCold\'; return $ret.\' <a href="'.CATSUtility::getIndexName().'?m=candidates&a=show&candidateID=\'.$rsData[\'candidateID\'].\'" style="font-size:11px;" class="\'.$className.\'" title="\'.htmlspecialchars(InfoString::make(DATA_ITEM_CANDIDATE,$rsData[\'candidateID\'],$rsData[\'siteID\'])).\'">\'.htmlspecialchars($rsData[\'firstName\']).\'</a>\';',
'sortableColumn' => 'firstName',
'pagerWidth' => 85,
'pagerOptional' => false,
'alphaNavigation' => true,
'filterHaving' => 'firstName'),
'Last Name' => array('pagerRender' => 'if ($rsData[\'isHot\'] == 1) $className = \'jobLinkHot\'; else $className = \'jobLinkCold\'; return \'<a href="'.CATSUtility::getIndexName().'?m=candidates&a=show&candidateID=\'.$rsData[\'candidateID\'].\'" style="font-size:11px;" class="\'.$className.\'" title="\'.htmlspecialchars(InfoString::make(DATA_ITEM_CANDIDATE,$rsData[\'candidateID\'],$rsData[\'siteID\'])).\'"> \'.htmlspecialchars($rsData[\'lastName\']).\'</a>\';',
'sortableColumn' => 'lastName',
'pagerWidth' => 75,
'pagerOptional' => false,
'alphaNavigation' => true,
'filterHaving' => 'lastName'),
'Status' => array('pagerRender' => 'return $rsData[\'status\'];',
'sortableColumn' => 'statusSort',
'pagerWidth' => 75,
'alphaNavigation' => true,
'filterHaving' => 'status'),
'Position' => array('pagerRender' => 'if ($rsData[\'jobOrderIsHot\'] == 1) $className = \'jobLinkHot\'; else $className = \'jobLinkCold\'; return \'<a href="'.CATSUtility::getIndexName().'?m=joborders&a=show&jobOrderID=\'.$rsData[\'joborderID\'].\'" style="font-size:11px;" class="\'.$className.\'">\'.htmlspecialchars($rsData[\'jobOrderTitle\']).\'</a>\';',
'sortableColumn' => 'jobOrderTitle',
'pagerWidth' => 220,
'alphaNavigation' => true,
'filterHaving' => 'jobOrderTitle'),
'Company' => array('pagerRender' => 'if ($rsData[\'companyIsHot\'] == 1) $className = \'jobLinkHot\'; else $className = \'jobLinkCold\'; return \'<a href="'.CATSUtility::getIndexName().'?m=companies&a=show&companyID=\'.$rsData[\'companyID\'].\'" style="font-size:11px;" class="\'.$className.\'">\'.htmlspecialchars($rsData[\'companyName\']).\'</a>\';',
'sortableColumn' => 'companyName',
'pagerWidth' => 180,
'alphaNavigation' => true,
'filterHaving' => 'companyName'),
'Modified' => array('pagerRender' => 'return $rsData[\'dateModified\'];',
'sortableColumn' => 'dateModifiedSort',
'pagerWidth' => 70,
'pagerOptional' => true,
'filterHaving' => 'DATE_FORMAT(candidate_joborder.date_modified, \'%m-%d-%y (%%h:%%i %%p)\')'),
);
parent::__construct("home:ImportantPipelineDashboard", $parameters);
}
/**
* Returns the sql statment for the pager.
*
* @return array clients data
*/
public function getSQL($selectSQL, $joinSQL, $whereSQL, $havingSQL, $orderSQL, $limitSQL, $distinct = '')
{
$sql = sprintf(
"SELECT SQL_CALC_FOUND_ROWS %s
candidate_joborder.candidate_joborder_id as candidateJoborderID,
candidate.first_name as firstName,
candidate.last_name as lastName,
candidate.candidate_id as candidateID,
candidate.site_id as siteID,
candidate.is_hot as isHot,
company.name as companyName,
company.company_id as companyID,
company.is_hot as companyIsHot,
joborder.title as jobOrderTitle,
joborder.is_hot as jobOrderIsHot,
joborder.joborder_id as joborderID,
user.first_name as userFirstName,
user.last_name as userLastName,
DATE_FORMAT(candidate_joborder.date_modified, '%%m-%%d-%%y ') as dateModified,
candidate_joborder.date_modified as dateModifiedSort,
IF(candidate_joborder.status = %s, 1, IF(candidate_joborder.status = %s, 2, 3)) as statusSort,
candidate_joborder_status.short_description as status
FROM
candidate_joborder
LEFT JOIN candidate ON
candidate.candidate_id = candidate_joborder.candidate_id
LEFT JOIN joborder ON
joborder.joborder_id = candidate_joborder.joborder_id
LEFT JOIN company ON
joborder.company_id = company.company_id
LEFT JOIN candidate_joborder_status ON
candidate_joborder.status = candidate_joborder_status.candidate_joborder_status_id
LEFT JOIN user ON
joborder.recruiter = user.user_id
WHERE
candidate_joborder.site_id = %s
AND
( candidate_joborder.status = %s
OR
candidate_joborder.status = %s
OR
candidate_joborder.status = %s
)
AND
joborder.status IN %s
%s
%s
%s
%s",
$distinct,
PIPELINE_STATUS_SUBMITTED,
PIPELINE_STATUS_INTERVIEWING,
$this->_siteID,
PIPELINE_STATUS_SUBMITTED,
PIPELINE_STATUS_INTERVIEWING,
PIPELINE_STATUS_OFFERED,
JobOrderStatuses::getOpenStatusSQL(),
(strlen($whereSQL) > 0) ? ' AND ' . $whereSQL : '',
(strlen($havingSQL) > 0) ? ' HAVING ' . $havingSQL : '',
$orderSQL,
$limitSQL
);
return $sql;
}
}
// FIXME: Includes in the middle of the file = bad.
// FIXME: Multiple classes per file probably also bad.
include_once(LEGACY_ROOT . '/lib/ActivityEntries.php');
include_once(LEGACY_ROOT . '/lib/Hooks.php');
include_once(LEGACY_ROOT . '/lib/InfoString.php');
class CallsDataGrid extends DataGrid
{
protected $_siteID;
// FIXME: Fix ugly indenting - ~400 character lines = bad.
public function __construct($siteID, $parameters)
{
/* Pager configuration. */
$this->_tableWidth = new Width(30, '%');
$this->_defaultAlphabeticalSortBy = 'lastName';
$this->ajaxMode = true;
$this->showExportColumn = false;
$this->showExportCheckboxes = false;
$this->showActionArea = true;
$this->allowSorting = false;
$this->showChooseColumnsBox = true;
$this->allowResizing = true;
$this->dateCriterion = '';
$this->globalStyle = 'font-size:11px; margin:1px; padding:1px;';
$this->listStyle = true;
$this->ignoreSavedColumnLayouts = true;
if (isset($parameters['period']) && !empty($parameters['period']))
{
$this->dateCriterion .= ' AND activity.date_occurred >= ' . $parameters['period'] . ' ';
}
else
{
if (isset($parameters['startDate']) && !empty($parameters['startDate']))
{
$this->dateCriterion .= ' AND activity.date_occurred >= \'' .$parameters['startDate'].'\' ';
}
if (isset($parameters['endDate']) && !empty($parameters['endDate']))
{
$this->dateCriterion .= ' AND activity.date_occurred <= \''.$parameters['endDate'].'\' ';
}
}
$this->defaultSortBy = 'dateCreatedSort';
$this->defaultSortDirection = 'DESC';
$this->_defaultColumns = array(
array('name' => 'Time', 'width' => 90),
array('name' => 'Name', 'width' => 175)
);
$this->_db = DatabaseConnection::getInstance();
$this->_siteID = $siteID;
$this->_userID = $_SESSION['CATS']->getUserID();
$this->_assignedCriterion = "";
$this->_dataItemIDColumn = 'company.company_id';
$this->_classColumns = array(
'Time' => array('pagerRender' => 'return $rsData[\'dateCreated\'].\':\';',
'sortableColumn' => 'dateCreatedSort',
'pagerWidth' => 90,
'pagerOptional' => false,
'alphaNavigation'=> true,
'filterHaving' => 'dateCreated'),
'Name' => array('pagerRender' => 'if ($rsData[\'dataItemType\']=='.DATA_ITEM_CANDIDATE.') {$ret = \'<img src="images/mru/candidate.gif" height="12" alt="" />\';} else if ($rsData[\'dataItemType\']=='.DATA_ITEM_CONTACT.') {$ret = \'<img src="images/mru/contact.gif" height="12">\';} else {$ret = \'<img src="images/mru/blank.gif">\';} if ($rsData[\'isHot\'] == 1) $className = \'jobLinkHot\'; else $className = \'jobLinkCold\'; if ($rsData[\'dataItemType\']=='.DATA_ITEM_CANDIDATE.') {$ret = $ret.\' <a style="font-size:11px;" href="'.CATSUtility::getIndexName().'?m=candidates&a=show&candidateID=\'.$rsData[\'dataItemID\'].\'" class="\'.$className.\'" title="\'.htmlspecialchars(InfoString::make($rsData[\'dataItemType\'],$rsData[\'dataItemID\'],$rsData[\'siteID\'])).\'">\'.htmlspecialchars($rsData[\'firstName\']).\'</a>\';} else {$ret = $ret.\' <a style="font-size:11px;" href="'.CATSUtility::getIndexName().'?m=contacts&a=show&contactID=\'.$rsData[\'dataItemID\'].\'" class="\'.$className.\'" title="\'.htmlspecialchars(InfoString::make($rsData[\'dataItemType\'],$rsData[\'dataItemID\'],$rsData[\'siteID\'])).\'">\'.htmlspecialchars($rsData[\'firstName\']).\'</a>\';} if ($rsData[\'dataItemType\']=='.DATA_ITEM_CANDIDATE.') {return $ret . \'<a style="font-size:11px;" href="'.CATSUtility::getIndexName().'?m=candidates&a=show&candidateID=\'.$rsData[\'dataItemID\'].\'" class="\'.$className.\'" title="\'.htmlspecialchars(InfoString::make($rsData[\'dataItemType\'],$rsData[\'dataItemID\'],$rsData[\'siteID\'])).\'"> \'.htmlspecialchars($rsData[\'lastName\']).\'</a>\';} else {return $ret . \'<a style="font-size:11px;" href="'.CATSUtility::getIndexName().'?m=contacts&a=show&contactID=\'.$rsData[\'dataItemID\'].\'" class="\'.$className.\'" title="\'.htmlspecialchars(InfoString::make($rsData[\'dataItemType\'],$rsData[\'dataItemID\'],$rsData[\'siteID\'])).\'"> \'.htmlspecialchars($rsData[\'lastName\']).\'</a>\';}',
'sortableColumn' => 'firstName',
'pagerWidth' => 120,
'pagerOptional' => false,
'alphaNavigation' => true,
'filterHaving' => 'firstName'),
);
parent::__construct("home:CallsDataGrid", $parameters);
}
/**
* Returns the sql statment for the pager.
*
* @return array clients data
*/
public function getSQL($selectSQL, $joinSQL, $whereSQL, $havingSQL, $orderSQL, $limitSQL, $distinct = '')
{
$sql = sprintf(
"SELECT SQL_CALC_FOUND_ROWS %s
activity.activity_id AS activityID,
activity.data_item_id AS dataItemID,
activity.data_item_type AS dataItemType,
activity.site_id AS siteID,
data_item_type.short_description AS item,
candidate.first_name AS firstName,
candidate.last_name AS lastName,
candidate.phone_work AS workPhone,
candidate.phone_cell AS cellPhone,
candidate.phone_home AS otherPhone,
candidate.is_hot AS isHot,
joborder.is_hot AS jobIsHot,
company.is_hot AS companyIsHot,
company.company_id AS companyID,
activity.joborder_id AS jobOrderID,
activity.notes AS notes,
activity_type.short_description AS typeDescription,
DATE_FORMAT(
activity.date_occurred, '%%m-%%d-%%y %%h:%%i %%p'
) AS dateCreated,
activity.date_occurred AS dateCreatedSort,
entered_by_user.first_name AS enteredByFirstName,
entered_by_user.last_name AS enteredByLastName,
CONCAT(entered_by_user.last_name, entered_by_user.first_name) AS enteredBySort,
IF(ISNULL(joborder.title),
'General',
CONCAT(joborder.title, ' (', company.name, ')'))
AS regarding,
joborder.title AS regardingJobTitle,
company.name AS regardingCompanyName
FROM
activity
JOIN data_item_type
ON activity.data_item_type = data_item_type.data_item_type_id
LEFT JOIN user AS entered_by_user
ON activity.entered_by = entered_by_user.user_id
LEFT JOIN activity_type
ON activity.type = activity_type.activity_type_id
LEFT JOIN joborder
ON activity.joborder_id = joborder.joborder_id
LEFT JOIN company
ON joborder.company_id = company.company_id
INNER JOIN candidate
ON activity.data_item_id = candidate.candidate_id
WHERE
activity.data_item_type = %s
AND
activity.entered_by = %s
AND
activity.site_id = %s
%s
%s
UNION
SELECT %s
activity.activity_id AS activityID,
activity.data_item_id AS dataItemID,
activity.data_item_type AS dataItemType,
activity.site_id AS siteID,
data_item_type.short_description AS item,
contact.first_name AS firstName,
contact.last_name AS lastName,
contact.phone_work AS workPhone,
contact.phone_cell AS cellPhone,
contact.phone_other AS otherPhone,
contact.is_hot AS isHot,
joborder.is_hot AS jobIsHot,
company.is_hot AS companyIsHot,
company.company_id AS companyID,
activity.joborder_id AS jobOrderID,
activity.notes AS notes,
activity_type.short_description AS typeDescription,
DATE_FORMAT(
activity.date_occurred, '%%m-%%d-%%y %%h:%%i %%p'
) AS dateCreated,
activity.date_occurred AS dateCreatedSort,
entered_by_user.first_name AS enteredByFirstName,
entered_by_user.last_name AS enteredByLastName,
CONCAT(entered_by_user.last_name, entered_by_user.first_name) AS enteredBySort,
IF(ISNULL(joborder.title),
'General',
CONCAT(joborder.title, ' (', company.name, ')'))
AS regarding,
joborder.title AS regardingJobTitle,
company.name AS regardingCompanyName
FROM
activity
JOIN data_item_type
ON activity.data_item_type = data_item_type.data_item_type_id
LEFT JOIN user AS entered_by_user
ON activity.entered_by = entered_by_user.user_id
LEFT JOIN activity_type
ON activity.type = activity_type.activity_type_id
LEFT JOIN joborder
ON activity.joborder_id = joborder.joborder_id
LEFT JOIN company
ON joborder.company_id = company.company_id
INNER JOIN contact
ON activity.data_item_id = contact.contact_id
WHERE
activity.data_item_type = %s
AND
activity.entered_by = %s
AND
activity.site_id = %s
%s
%s
%s
ORDER BY dateCreatedSort DESC
LIMIT 6",
$distinct,
DATA_ITEM_CANDIDATE,
$this->_userID,
$this->_siteID,
$this->dateCriterion,
(strlen($whereSQL) > 0) ? ' AND ' . $whereSQL : '',
$distinct,
DATA_ITEM_CONTACT,
$this->_userID,
$this->_siteID,
$this->dateCriterion,
(strlen($whereSQL) > 0) ? ' AND ' . $whereSQL : '',
(strlen($havingSQL) > 0) ? ' HAVING ' . $havingSQL : ''
);
return $sql;
}
}
?>