@@ -279,73 +279,73 @@ public function data($ticketList = 'active')
279279 })
280280 ->leftJoin ('panichd_tags ' , 'panichd_taggables.tag_id ' , '= ' , 'panichd_tags.id ' );
281281
282+ if (config ('database.default ' ) == 'sqlite ' ) {
283+ $ int_start_date = 'cast(julianday(panichd_tickets.start_date) as real) ' ;
284+ $ int_limit_date = 'cast(julianday(panichd_tickets.limit_date) as real) ' ;
285+ } else {
286+ $ int_start_date = "CONVERT(date_format(panichd_tickets.start_date, '%Y%m%d%h%i%s'), SIGNED INTEGER) " ;
287+ $ int_limit_date = "CONVERT(date_format(panichd_tickets.limit_date, '%Y%m%d%h%i%s'), SIGNED INTEGER) " ;
288+ }
289+
290+ $ a_select = [
291+ 'panichd_tickets.id ' ,
292+ 'panichd_tickets.created_at ' ,
293+ 'panichd_tickets.subject AS subject ' ,
294+ 'panichd_tickets.hidden as hidden ' ,
295+ 'panichd_tickets.content AS content ' ,
296+ 'panichd_tickets.intervention AS intervention ' ,
297+ 'panichd_tickets.status_id as status_id ' ,
298+ 'panichd_statuses.name AS status ' ,
299+ 'panichd_statuses.color AS color_status ' ,
300+ 'panichd_priorities.color AS color_priority ' ,
301+ 'panichd_categories.color AS color_category ' ,
302+ 'panichd_tickets.start_date as start_date ' ,
303+ \DB ::raw (' 0- ' .$ int_start_date .' as inverse_start_date ' ),
304+ \DB ::raw ('CASE panichd_tickets.limit_date WHEN NULL THEN 0 ELSE 1 END as has_limit ' ),
305+ 'panichd_tickets.limit_date as limit_date ' ,
306+ \DB ::raw (' 0- ' .$ int_limit_date .' as inverse_limit_date ' ),
307+ 'panichd_tickets.limit_date as calendar ' ,
308+ 'panichd_tickets.updated_at AS updated_at ' ,
309+ 'panichd_tickets.completed_at AS completed_at ' ,
310+ 'panichd_tickets.agent_id ' ,
311+ 'panichd_tickets.read_by_agent ' ,
312+ 'agent.name as agent_name ' ,
313+ 'panichd_priorities.name AS priority ' ,
314+ 'panichd_priorities.magnitude AS priority_magnitude ' ,
315+ 'members.name AS owner_name ' ,
316+ 'creator.name as creator_name ' ,
317+ 'panichd_tickets.user_id ' ,
318+ 'panichd_tickets.creator_id ' ,
319+ 'panichd_categories.id as category_id ' ,
320+ 'panichd_categories.name AS category ' ,
321+
322+ // Tag Columns
323+ \DB ::raw ('group_concat(panichd_tags.id) AS tags_id ' ),
324+ \DB ::raw ('group_concat(panichd_tags.name) AS tags ' ),
325+ \DB ::raw ('group_concat(panichd_tags.bg_color) AS tags_bg_color ' ),
326+ \DB ::raw ('group_concat(panichd_tags.text_color) AS tags_text_color ' ),
327+ ];
328+
329+ if (Setting::grab ('departments_feature ' )) {
330+ $ collection ->leftJoin ('panichd_departments ' , 'panichd_departments.id ' , '= ' , 'members.department_id ' )
331+ ->leftJoin ('panichd_departments as dep_ancestor ' , 'panichd_departments.department_id ' , '= ' , 'dep_ancestor.id ' );
282332
283- if (config ('database.default ' )=='sqlite ' ){
284- $ int_start_date = 'cast(julianday(panichd_tickets.start_date) as real) ' ;
285- $ int_limit_date = 'cast(julianday(panichd_tickets.limit_date) as real) ' ;
286- }else {
287- $ int_start_date = "CONVERT(date_format(panichd_tickets.start_date, '%Y%m%d%h%i%s'), SIGNED INTEGER) " ;
288- $ int_limit_date = "CONVERT(date_format(panichd_tickets.limit_date, '%Y%m%d%h%i%s'), SIGNED INTEGER) " ;
289- }
290-
291- $ a_select = [
292- 'panichd_tickets.id ' ,
293- 'panichd_tickets.created_at ' ,
294- 'panichd_tickets.subject AS subject ' ,
295- 'panichd_tickets.hidden as hidden ' ,
296- 'panichd_tickets.content AS content ' ,
297- 'panichd_tickets.intervention AS intervention ' ,
298- 'panichd_tickets.status_id as status_id ' ,
299- 'panichd_statuses.name AS status ' ,
300- 'panichd_statuses.color AS color_status ' ,
301- 'panichd_priorities.color AS color_priority ' ,
302- 'panichd_categories.color AS color_category ' ,
303- 'panichd_tickets.start_date as start_date ' ,
304- \DB ::raw (' 0- ' .$ int_start_date .' as inverse_start_date ' ),
305- \DB ::raw ('CASE panichd_tickets.limit_date WHEN NULL THEN 0 ELSE 1 END as has_limit ' ),
306- 'panichd_tickets.limit_date as limit_date ' ,
307- \DB ::raw (' 0- ' .$ int_limit_date .' as inverse_limit_date ' ),
308- 'panichd_tickets.limit_date as calendar ' ,
309- 'panichd_tickets.updated_at AS updated_at ' ,
310- 'panichd_tickets.completed_at AS completed_at ' ,
311- 'panichd_tickets.agent_id ' ,
312- 'agent.name as agent_name ' ,
313- 'panichd_priorities.name AS priority ' ,
314- 'panichd_priorities.magnitude AS priority_magnitude ' ,
315- 'members.name AS owner_name ' ,
316- 'creator.name as creator_name ' ,
317- 'panichd_tickets.user_id ' ,
318- 'panichd_tickets.creator_id ' ,
319- 'panichd_categories.id as category_id ' ,
320- 'panichd_categories.name AS category ' ,
321-
322- // Tag Columns
323- \DB ::raw ('group_concat(panichd_tags.id) AS tags_id ' ),
324- \DB ::raw ('group_concat(panichd_tags.name) AS tags ' ),
325- \DB ::raw ('group_concat(panichd_tags.bg_color) AS tags_bg_color ' ),
326- \DB ::raw ('group_concat(panichd_tags.text_color) AS tags_text_color ' ),
327- ];
328-
329- if (Setting::grab ('departments_feature ' )){
330- $ collection ->leftJoin ('panichd_departments ' , 'panichd_departments.id ' , '= ' , 'members.department_id ' )
331- ->leftJoin ('panichd_departments as dep_ancestor ' , 'panichd_departments.department_id ' , '= ' , 'dep_ancestor.id ' );
332-
333- // Department columns
334- $ a_select [] = \DB ::raw ('CASE panichd_departments.department_id WHEN NULL THEN "" ELSE dep_ancestor.name END as dep_ancestor_name ' );
335-
336- if (config ('database.default ' )=='sqlite ' ){
337- $ a_select [] = \DB ::raw ('dep_ancestor.name + panichd_departments.name as dept_full_name ' ); #\''.trans('panichd::lang.colon').' +
338- }else {
339- $ a_select [] = \DB ::raw ('concat_ws( \'' . trans ('panichd::lang.colon ' ) . ' \', dep_ancestor.name, panichd_departments.name) as dept_full_name ' );
340- }
341- }else {
342- $ a_select [] = \DB ::raw ('"" as dep_ancestor_name ' );
343- }
344-
345- $ currentLevel = $ agent ->currentLevel ();
346-
347- $ collection
348- ->groupBy ('panichd_tickets.id ' )
333+ // Department columns
334+ $ a_select [] = \DB ::raw ('CASE panichd_departments.department_id WHEN NULL THEN "" ELSE dep_ancestor.name END as dep_ancestor_name ' );
335+
336+ if (config ('database.default ' ) == 'sqlite ' ) {
337+ $ a_select [] = \DB ::raw ('dep_ancestor.name + panichd_departments.name as dept_full_name ' ); //\''.trans('panichd::lang.colon').' +
338+ } else {
339+ $ a_select [] = \DB ::raw ('concat_ws( \'' .trans ('panichd::lang.colon ' ).' \', dep_ancestor.name, panichd_departments.name) as dept_full_name ' );
340+ }
341+ } else {
342+ $ a_select [] = \DB ::raw ('"" as dep_ancestor_name ' );
343+ }
344+
345+ $ currentLevel = $ this ->member ->currentLevel ();
346+
347+ $ collection
348+ ->groupBy ('panichd_tickets.id ' )
349349 ->select ($ a_select )
350350 ->with ('creator ' )
351351 ->with ('agent ' )
0 commit comments