forked from Furgas/php-api-library
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkyTicket.php
executable file
·2121 lines (1879 loc) · 60.9 KB
/
kyTicket.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
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
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Kayako Ticket object.
*
* @author Tomasz Sawicki (https://github.com/Furgas)
* @link http://wiki.kayako.com/display/DEV/REST+-+Ticket
* @since Kayako version 4.40.1079
* @package Object\Ticket
*
* @noinspection PhpDocSignatureInspection
*/
class kyTicket extends kyObjectWithCustomFieldsBase
{
const FLAG_NONE = 0;
const FLAG_PURPLE = 1;
const FLAG_ORANGE = 2;
const FLAG_GREEN = 3;
const FLAG_YELLOW = 4;
const FLAG_RED = 5;
const FLAG_BLUE = 6;
const CREATOR_AUTO = 0;
const CREATOR_STAFF = 1;
const CREATOR_USER = 2;
const CREATOR_CLIENT = 2;
const CREATION_MODE_SUPPORTCENTER = 1;
const CREATION_MODE_STAFFCP = 2;
const CREATION_MODE_EMAIL = 3;
const CREATION_MODE_API = 4;
const CREATION_MODE_SITEBADGE = 5;
const CREATION_TYPE_DEFAULT = 'default';
const CREATION_TYPE_PHONE = 'phone';
/**
* Flag for searching using query - search the Ticket ID & Mask ID.
* @var string
*/
const SEARCH_TICKET_ID = 'ticketid';
/**
* Flag for searching using query - search the Ticket Post Contents.
* @var string
*/
const SEARCH_CONTENTS = 'contents';
/**
* Flag for searching using query - search the Full Name & Email.
* @var string
*/
const SEARCH_AUTHOR = 'author';
/**
* Flag for searching using query - search the Email Address (Ticket & Posts).
* @var string
*/
const SEARCH_EMAIL = 'email';
/**
* Flag for searching using query - search the Email Address (only Tickets).
* @var string
*/
const SEARCH_CREATOR_EMAIL = 'creatoremail';
/**
* Flag for searching using query - search the Full Name.
* @var string
*/
const SEARCH_FULL_NAME = 'fullname';
/**
* Flag for searching using query - search the Ticket Notes.
* @var string
*/
const SEARCH_NOTES = 'notes';
/**
* Flag for searching using query - search the User Group.
* @var string
*/
const SEARCH_USER_GROUP = 'usergroup';
/**
* Flag for searching using query - search the User Organization.
* @var string
*/
const SEARCH_USER_ORGANIZATION = 'userorganization';
/**
* Flag for searching using query - search the User (Full Name, Email).
* @var string
*/
const SEARCH_USER = 'user';
/**
* Flag for searching using query - search the Ticket Tags.
* @var string
*/
const SEARCH_TAGS = 'tags';
static protected $controller = '/Tickets/Ticket';
static protected $object_xml_name = 'ticket';
static protected $custom_field_group_class = 'kyTicketCustomFieldGroup';
static protected $object_id_field = 'ticketid';
/**
* Default status identifier for new tickets.
* @see kyTicket::setDefaults
* @var int
*/
static private $default_status_id = null;
/**
* Default priority identifier for new tickets.
* @see kyTicket::setDefaults
* @var int
*/
static private $default_priority_id = null;
/**
* Default type identifier for new tickets.
* @see kyTicket::setDefaults
* @var int
*/
static private $default_type_id = null;
/**
* Default status identifier for new tickets.
* @see kyTicket::setDefaults
* @var int
*/
static private $auto_create_user = true;
/**
* Ticket identifier.
* @apiField
* @var int
*/
protected $id;
/**
* Ticket flag type.
*
* @see kyTicket::FLAG constants.
*
* @apiField
* @var int
*/
protected $flag_type;
/**
* Ticket display identifier.
* @apiField
* @var string
*/
protected $display_id;
/**
* Ticket department identifier.
* @apiField required_create=true
* @var int
*/
protected $department_id;
/**
* Ticket status identifier.
* @apiField required_create=true
* @var int
*/
protected $status_id;
/**
* Ticket priority identifier.
* @apiField required_create=true
* @var int
*/
protected $priority_id;
/**
* Ticket type identifier.
* @apiField required_create=true
* @var int
*/
protected $type_id;
/**
* Identifier of the user ticket was created by.
* @apiField
* @var int
*/
protected $user_id;
/**
* Name of the organization of the user ticket was created by.
* @apiField
* @var string
*/
protected $user_organization_name;
/**
* Identifier of the organization of the user ticket was created by.
* @apiField
* @var int
*/
protected $user_organization_id;
/**
* Identifier of staff user who owns the ticket.
* @apiField
* @var int
*/
protected $owner_staff_id;
/**
* Full name of staff user who owns the ticket.
* @apiField
* @var string
*/
protected $owner_staff_name;
/**
* Full name of creator of the ticket.
* @apiField required_create=true
* @var int
*/
protected $full_name;
/**
* E-mail of creator of the ticket.
* @apiField required_create=true
* @var string
*/
protected $email;
/**
* Full name of the last replier to this ticket.
* @apiField
* @var string
*/
protected $last_replier;
/**
* Ticket subject.
* @apiField required_create=true
* @var string
*/
protected $subject;
/**
* Timestamp of when this ticket was created.
* @apiField
* @var int
*/
protected $creation_time;
/**
* Timestamp of last activity in this ticket.
* @apiField
* @var int
*/
protected $last_activity;
/**
* Timestamp of last staff user reply.
* @apiField
* @var int
*/
protected $last_staff_reply;
/**
* Timestamp of last user reply.
* @apiField
* @var int
*/
protected $last_user_reply;
/**
* Service Level Agreement plan identifier.
* @apiField
* @var int
*/
protected $sla_plan_id;
/**
* Timestamp of when the next replay is due.
* @apiField
* @var int
*/
protected $next_reply_due;
/**
* Timestamp of when resolution of the ticket is due.
* @apiField
* @var int
*/
protected $resolution_due;
/**
* Reply count.
* @apiField
* @var int
*/
protected $replies;
/**
* IP address from which the ticket was created.
* @apiField
* @var string
*/
protected $ip_address;
/**
* Type of the ticket creator.
*
* @see kyTicket::CREATOR constants.
*
* @apiField
* @var int
*/
protected $creator;
/**
* Ticket creation mode.
*
* @see kyTicket::CREATION_MODE constants.
*
* @apiField
* @var int
*/
protected $creation_mode;
/**
* Ticket creation type.
*
* @see kyTicket::CREATION_TYPE constants.
*
* @apiField alias=type
* @var int
*/
protected $creation_type;
/**
* Is this ticket escalated.
* @apiField
* @var bool
*/
protected $is_escalated;
/**
* Escalation rule identifier.
* @apiField
* @var int
*/
protected $escalation_rule_id;
/**
* Template group identifier.
* @apiField getter=getTemplateGroupId setter=setTemplateGroup alias=templategroup
* @var int
*/
protected $template_group_id;
/**
* Template group name.
* @apiField getter=getTemplateGroupName setter=setTemplateGroup
* @var string
*/
protected $template_group_name;
/**
* Ticket tags.
* @apiField
* @var string
*/
protected $tags;
/**
* Ticket watchers.
* @apiField
* @var array
*/
protected $watchers;
/**
* Ticket workflows.
* @apiField
* @var array
*/
protected $workflows;
/**
* Identifier os staff user who will create this ticket.
* @apiField
* @var int
*/
protected $staff_id;
/**
* Ticket contents.
* @apiField required_create=true
* @var string
*/
protected $contents = null;
/**
* Option to disable autoresponder e-mail.
* @apiField
* @var bool
*/
protected $ignore_auto_responder = false;
/**
* Ticket status.
* @var kyTicketStatus
*/
private $status;
/**
* Ticket priority.
* @var kyTicketPriority
*/
private $priority;
/**
* Ticket type.
* @var kyTicketType
*/
private $type;
/**
* User, the creator of this ticket.
* @var kyUser
*/
private $user;
/**
* Organization of user who created this ticket.
* @var kyUserOrganization
*/
private $user_organization;
/**
* Staff user, the creator of this ticket.
* @var kyStaff
*/
private $staff;
/**
* Staff user who is the owner of this ticket.
* @var kyStaff
*/
private $owner_staff;
/**
* Department of this ticket.
* @var kyDepartment
*/
private $department = null;
/**
* List of ticket notes.
* @var kyTicketNote[]
*/
private $notes = null;
/**
* List of ticket time tracks.
* @var kyTicketTimeTrack[]
*/
private $time_tracks = null;
/**
* List of ticket posts.
* @var kyTicketPost[]
*/
private $posts = null;
/**
* List of ticket attachments.
* @var kyTicketAttachment[]
*/
private $attachments = null;
/**
* Tickets statistic.
* @var array
*/
static private $statistics = null;
/**
* Sets default status, priority and type for newly created tickets.
*
* @param int $status_id Default ticket status identifier.
* @param int $priority_id Default ticket priority identifier.
* @param int $type_id Default ticket type identifier.
* @param bool $auto_create_user True to automatically create user if none is provided as creator. False otherwise.
*/
static public function setDefaults($status_id, $priority_id, $type_id, $auto_create_user = true)
{
self::$default_status_id = $status_id;
self::$default_priority_id = $priority_id;
self::$default_type_id = $type_id;
self::$auto_create_user = $auto_create_user;
}
protected function parseData($data)
{
$this->id = intval($data['_attributes']['id']);
$this->flag_type = intval($data['_attributes']['flagtype']);
$this->display_id = $data['displayid'];
$this->department_id = ky_assure_positive_int((int)$data['departmentid']);
$this->status_id = ky_assure_positive_int((int)$data['statusid']);
$this->priority_id = ky_assure_positive_int((int)$data['priorityid']);
$this->type_id = ky_assure_positive_int((int)$data['typeid']);
$this->user_id = ky_assure_positive_int((int)$data['userid']);
$this->user_organization_name = $data['userorganization'];
$this->user_organization_id = ky_assure_positive_int((int)$data['userorganizationid']);
$this->owner_staff_id = ky_assure_positive_int((int)$data['ownerstaffid']);
$this->owner_staff_name = $data['ownerstaffname'];
$this->full_name = $data['fullname'];
$this->email = $data['email'];
$this->last_replier = $data['lastreplier'];
$this->subject = $data['subject'];
$this->creation_time = ky_assure_positive_int((int)$data['creationtime']);
$this->last_activity = ky_assure_positive_int((int)$data['lastactivity']);
$this->last_staff_reply = ky_assure_positive_int((int)$data['laststaffreply']);
$this->last_user_reply = ky_assure_positive_int((int)$data['lastuserreply']);
$this->sla_plan_id = ky_assure_positive_int((int)$data['slaplanid']);
$this->next_reply_due = ky_assure_positive_int((int)$data['nextreplydue']);
$this->resolution_due = ky_assure_positive_int((int)$data['resolutiondue']);
$this->replies = intval($data['replies']);
$this->ip_address = $data['ipaddress'];
$this->creator = intval($data['creator']);
$this->creation_mode = intval($data['creationmode']);
$this->creation_type = intval($data['creationtype']);
$this->is_escalated = ky_assure_bool((bool)$data['isescalated']);
$this->escalation_rule_id = ky_assure_positive_int((int)$data['escalationruleid']);
$this->template_group_id = ky_assure_positive_int((int)$data['templategroupid']);
if (is_numeric($data['templategroupid']) && !empty($data['templategroupid']) && isset($data['templategroupname'])) {
$this->template_group_name = $data['templategroupname'];
}
$this->tags = $data['tags'];
$this->watchers = array();
if (array_key_exists('watcher', $data)) {
foreach ($data['watcher'] as $watcher) {
$this->watchers[] = array('staff_id' => intval((int)$watcher['_attributes']['staffid']), 'name' => $watcher['_attributes']['name']);
}
}
$this->workflows = array();
if (array_key_exists('workflow', $data)) {
foreach ($data['workflow'] as $workflow) {
$this->workflows[] = array('id' => intval((int)$workflow['_attributes']['id']), 'title' => $workflow['_attributes']['title']);
}
}
/**
* Notes and time tracks.
*/
if (array_key_exists('note', $data)) {
foreach ($data['note'] as $note_data) {
/*
* Includes workaround for old format of TimeTrack object - if "timeworked" key is present than it's a time track.
*/
if ($note_data['_attributes']['type'] === 'timetrack' || array_key_exists('timeworked', $note_data['_attributes'])) {
if ($this->time_tracks === null)
$this->time_tracks = array();
$this->time_tracks[] = new kyTicketTimeTrack($note_data);
} else {
if ($this->notes === null)
$this->notes = array();
$this->notes[] = new kyTicketNote($note_data);
}
}
}
/**
* Posts.
*/
if (array_key_exists('posts', $data)) {
$this->posts = array();
// This is a change from the Kayako PHP library on GitHub. We
// may have tickets with no posts due to migration from NetSuite
// which violates the data model for Kayako. Added an if statement
// here to handle this situation.
if (is_array($data['posts']) && count($data['posts']) > 0) {
foreach ($data['posts'][0]['post'] as $post_data) {
$this->posts[] = new kyTicketPost($post_data);
}
}
}
}
public function buildData($create)
{
$this->checkRequiredAPIFields($create);
$data = array();
$data['subject'] = $this->subject;
$data['fullname'] = $this->full_name;
$data['email'] = $this->email;
$data['departmentid'] = $this->department_id;
$data['ticketstatusid'] = $this->status_id;
$data['ticketpriorityid'] = $this->priority_id;
$data['tickettypeid'] = $this->type_id;
if ($this->owner_staff_id > 0) {
$data['ownerstaffid'] = $this->owner_staff_id;
}
$data['templategroup'] = is_numeric($this->template_group_id) ? $this->template_group_id : $this->template_group_name;
if ($create) {
switch ($this->creator) {
case self::CREATOR_STAFF:
$data['staffid'] = $this->staff_id;
break;
case self::CREATOR_USER:
$data['userid'] = $this->user_id;
break;
case self::CREATOR_AUTO:
if (self::$auto_create_user) {
$data['autouserid'] = 1;
break;
}
default:
throw new kyException("Value for API fields 'staffid' or 'userid' is required or automatic ticket user creation should be enabled for this operation to complete.");
break;
}
$data['contents'] = $this->contents;
$data['type'] = $this->creation_type;
$data['ignoreautoresponder'] = $this->ignore_auto_responder;
} else {
$data['userid'] = $this->user_id;
}
return $data;
}
/**
* Searches for tickets based on provided data. You must provide at least one department identifier.
*
* @param kyDepartment|kyResultSet $departments Non-empty list of department identifiers.
* @param array|kyResultSet|kyTicketStatus $ticket_statuses List of ticket status identifiers.
* @param array|kyResultSet|kyStaff $owner_staffs List of staff (ticket owners) identifiers.
* @param array|kyResultSet|kyUser $users List of user (ticket creators) identifiers.
* @param $rowsPerPage (OPTIONAL)
* @param $rowOffset (OPTIONAL)
* @throws InvalidArgumentException
* @return kyResultSet
*/
static public function getAll($search_parameters = array())
{
list($departments, $ticket_statuses, $owner_staffs, $users, $max_items, $starting_ticket_id) = $search_parameters;
if (!is_array($ticket_statuses)) {
$ticket_statuses = array();
}
if (!is_array($owner_staffs)) {
$owner_staffs = array();
}
if (!is_array($users)) {
$users = array();
}
unset($search_parameters);
$search_parameters = array('ListAll');
$department_ids = array();
if ($departments instanceof kyDepartment) {
$department_ids = array($departments->getId());
} elseif ($departments instanceof kyResultSet) {
$department_ids = $departments->collectId();
}
//department
if (count($department_ids) === 0)
throw new InvalidArgumentException('You must provide at least one department to search for tickets.');
$ticket_status_ids = array();
if ($ticket_statuses instanceof kyTicketStatus) {
$ticket_status_ids = array($ticket_statuses->getId());
} elseif ($ticket_statuses instanceof kyResultSet) {
$ticket_status_ids = $ticket_statuses->collectId();
} elseif (is_array($ticket_statuses)) {
$ticket_status_ids = $ticket_statuses;
}
$owner_staff_ids = array();
if ($owner_staffs instanceof kyStaff) {
$owner_staff_ids = array($owner_staffs->getId());
} elseif ($owner_staffs instanceof kyResultSet) {
$owner_staff_ids = $owner_staffs->collectId();
}
else if (is_array($owner_staffs))
{
$owner_staff_ids = $owner_staffs;
}
$user_ids = array();
if ($users instanceof kyUser) {
$user_ids = array($users->getId());
} elseif ($users instanceof kyResultSet) {
$user_ids = $users->collectId();
}
else if (is_array($users))
{
$user_ids = $users;
}
$search_parameters[] = implode(',', $department_ids);
//ticket status
if (count($ticket_status_ids) > 0)
$search_parameters[] = implode(',', $ticket_status_ids);
else
$search_parameters[] = '-1';
//owner staff
if (count($owner_staff_ids) > 0)
$search_parameters[] = implode(',', $owner_staff_ids);
else
$search_parameters[] = '-1';
//user
if (count($user_ids) > 0)
$search_parameters[] = implode(',', $user_ids);
else
$search_parameters[] = '-1';
if (is_numeric($starting_ticket_id) && $starting_ticket_id > 0) {
if (!is_numeric($max_items) || $max_items <= 0) {
$max_items = 1000;
}
$search_parameters[] = $max_items;
$search_parameters[] = $starting_ticket_id;
}
return parent::getAll($search_parameters);
}
/**
* Searches objects from server using query and search flags.
* Example:
* kyTicket::search("something", array(kyTicket::SEARCH_CONTENTS, kyTicket::SEARCH_NOTES));
*
* @param string $query What to search for.
* @param array $areas List of areas where to search for as array with kyTicket::SEARCH_ constants.
* @return kyResultSet
*/
static public function search($query, $areas)
{
$data = array();
$data['query'] = $query;
foreach ($areas as $area) {
$data[$area] = 1;
}
$result = self::getRESTClient()->post('/Tickets/TicketSearch', array(), $data);
$objects = array();
if (array_key_exists(static::$object_xml_name, $result)) {
foreach ($result[static::$object_xml_name] as $object_data) {
$objects[] = new static($object_data);
}
}
return new kyResultSet($objects);
}
public function toString()
{
return sprintf("%s %s (creator: %s)", $this->getDisplayId(), $this->getSubject(), $this->getFullName());
}
public function getId($complete = false)
{
return $complete ? array($this->id) : $this->id;
}
/**
* Sets the creator (User or Staff) of this post.
*
* @see kyTicket::CREATOR constants.
*
* @param int|kyUser|kyStaff $creator User identifier OR staff identifier OR user OR staff user.
* @param int $type Creator type. Required only when $creator is an identifier.
* @return kyTicket
*/
public function setCreator($creator, $type = null)
{
if (is_numeric($creator)) {
switch ($type) {
case self::CREATOR_USER:
$this->setUserId($creator);
break;
case self::CREATOR_STAFF:
$this->setStaffId($creator);
break;
}
} elseif ($creator instanceof kyUser) {
$this->setUser($creator);
} elseif ($creator instanceof kyStaff) {
$this->setStaff($creator);
}
return $this;
}
/**
* Sets the creator to be automatically created (or assigned) by the server based on specified data.
*
* @param string $full_name Full name of the creator.
* @param string $email E-mail of the creator.
* @return kyTicket
*/
public function setCreatorAuto($full_name, $email)
{
$this->setFullName($full_name);
$this->setEmail($email);
$this->creator = self::CREATOR_AUTO;
$this->user = null;
$this->user_id = null;
$this->staff = null;
$this->staff_id = null;
return $this;
}
/**
* Returns flag type for the ticket.
*
* @see kyTicket::FLAG constants.
*
* @return int
* @filterBy
* @orderBy
*/
public function getFlagType()
{
return $this->flag_type;
}
/**
* Return display identifier of the ticket.
*
* @return string
* @filterBy
* @orderBy
*/
public function getDisplayId()
{
return $this->display_id;
}
/**
* Returns identifier of department associated with the ticket.
*
* @return int
* @filterBy
* @orderBy
*/
public function getDepartmentId()
{
return $this->department_id;
}
/**
* Sets identifier of department the ticket belongs to.
*
* @param int $department_id Department identifier.
* @return kyTicket
*/
public function setDepartmentId($department_id)
{
$this->department_id = ky_assure_positive_int($department_id);
$this->department = null;
return $this;
}
/**
* Returns department object associated with the ticket.
*
* Result is cached until the end of script.
*
* @param bool $reload True to reload data from server. False to use the cached value (if present).
* @return kyDepartment
*/
public function getDepartment($reload = false)
{
if ($this->department !== null && !$reload)
return $this->department;
if ($this->department_id === null)
return null;
$this->department = kyDepartment::get($this->department_id);
return $this->department;
}
/**
* Sets the department the ticket belongs to.
*
* @param kyDepartment $department Department.
* @return kyTicket
*/
public function setDepartment($department)
{
$this->department = ky_assure_object($department, 'kyDepartment');
$this->department_id = $this->department !== null ? $this->department->getId() : null;
return $this;
}
/**
* Returns identifier of this ticket status.
*
* @return int
* @filterBy
* @orderBy
*/
public function getStatusId()
{
return $this->status_id;
}
/**
* Sets identifier of this ticket status.
*
* @param int $ticket_status_id Ticket status identifier.
* @return kyTicket
*/
public function setStatusId($ticket_status_id)
{
$this->status_id = ky_assure_positive_int($ticket_status_id);
$this->status = null;
return $this;
}
/**
* Returns ticket status.
*
* Result is cached until the end of script.
*
* @param bool $reload True to reload data from server. False to use the cached value (if present).
* @return kyTicketStatus
*/
public function getStatus($reload = false)
{
if ($this->status !== null && !$reload)
return $this->status;
if ($this->status_id === null)
return null;
$this->status = kyTicketStatus::get($this->status_id);
return $this->status;
}
/**
* Sets ticket status.
*
* @param kyTicketStatus $ticket_status Ticket status.
* @return kyTicket
*/
public function setStatus($ticket_status)
{
$this->status = ky_assure_object($ticket_status, 'kyTicketStatus');
$this->status_id = $this->status !== null ? $this->status->getId() : null;
return $this;
}
/**
* Returns identifier of this ticket priority.
*
* @return int
* @filterBy
* @orderBy
*/
public function getPriorityId()
{
return $this->priority_id;
}
/**
* Sets identifier of this ticket priority.
* @param int $ticket_priority_id Ticket priority identifier.
* @return kyTicket