예제 #1
0
 * Search for tickets with "power cable" text in contents of posts or notes.
 */
$tickets = kyTicket::search("power cable", array(kyTicket::SEARCH_CONTENTS, kyTicket::SEARCH_NOTES));
//print them
print "Searching tickets:\n" . $tickets;
/**
 * Search for open and assigned tickets with no replies in all departments.
 * WARNING: Can be time consuming.
 */
$tickets = kyTicket::getAll(kyDepartment::getAll())->filterByStatusId(kyTicketStatus::getAll()->filterByTitle(array("!=", "Closed"))->collectId())->filterByReplies(array('<=', 1))->filterByOwnerStaffId(array("!=", null));
//print them
print "Searching tickets:\n" . $tickets;
/**
 * Filtering, sorting and paging results.
 */
//print available filter methods for User objects
print "User available filter methods:\n";
print_r(kyUser::getAvailableFilterMethods());
//print available order methods for Staff objects
print "Staff available order methods:\n";
print_r(kyStaff::getAvailableOrderMethods());
//find the user with email someuser@example.com
$user = kyUser::getAll()->filterByEmail("*****@*****.**")->first();
//find ticket time tracks with billable time greater than 10 minutes and sort them ascending using time worked
$time_tracks = $ticket->getTimeTracks()->filterByTimeBillable(array(">", 10 * 60))->orderByTimeWorked();
//find department with title "General"
$general_department = kyDepartment::getAll()->filterByTitle("General")->first();
//find tickets in "General" department with word "help" in subject
$tickets = kyTicket::getAll($general_department->getId())->filterBySubject(array("~", "/help/i"));
//assuming 10 items per page, get second page from list of staff users ordered by fullname
$staff_page_2 = kyStaff::getAll()->orderByFullName()->getPage(2, 10);