本文整理汇总了PHP中DAO_Worker::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP DAO_Worker::getAll方法的具体用法?PHP DAO_Worker::getAll怎么用?PHP DAO_Worker::getAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DAO_Worker
的用法示例。
在下文中一共展示了DAO_Worker::getAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTimeSpentWorkerReportAction
function getTimeSpentWorkerReportAction()
{
$db = DevblocksPlatform::getDatabaseService();
$subtotal = array();
$total_cm = array();
DevblocksPlatform::getExtensions('timetracking.source', true);
@($sel_worker_id = DevblocksPlatform::importGPC($_REQUEST['worker_id'], 'integer', 0));
@($report_type = DevblocksPlatform::importGPC($_REQUEST['report_type'], 'integer', 0));
// Security
if (null == ($active_worker = CerberusApplication::getActiveWorker())) {
die($translate->_('common.access_denied'));
}
$tpl = DevblocksPlatform::getTemplateService();
$tpl->cache_lifetime = "0";
$tpl->assign('path', $this->tpl_path);
// import dates from form
@($start = DevblocksPlatform::importGPC($_REQUEST['start'], 'string', ''));
@($end = DevblocksPlatform::importGPC($_REQUEST['end'], 'string', ''));
// use date rang@$sel_worker_id = DevblocksPlatform::importGPC($_REQUEST['worker_id'],'integer',0);e if specified, else use duration prior to now
$start_time = 0;
$end_time = 0;
if (empty($start) && empty($end)) {
$start = "Last Monday";
$end = "now";
$start_time = strtotime($start);
$end_time = strtotime($end);
} else {
$start_time = strtotime($start);
$end_time = strtotime($end);
}
if ($start_time === false || $end_time === false) {
$start = "Last Monday";
$end = "now";
$start_time = strtotime($start);
$end_time = strtotime($end);
$tpl->assign('invalidDate', true);
}
// reload variables in template
$tpl->assign('start', $start);
$tpl->assign('end', $end);
$workers = DAO_Worker::getAll();
$tpl->assign('workers', $workers);
$sources = DAO_TimeTrackingEntry::getSources();
$tpl->assign('sources', $sources);
$sql = "SELECT tte.log_date, tte.time_actual_mins, tte.worker_id, tte.notes, ";
$sql .= "tte.source_extension_id, tte.source_id, ";
$sql .= "tta.name activity_name ";
$sql .= "FROM timetracking_entry tte ";
$sql .= "INNER JOIN timetracking_activity tta ON tte.activity_id = tta.id ";
$sql .= "INNER JOIN worker w ON tte.worker_id = w.id ";
$sql .= sprintf("WHERE log_date > %d AND log_date <= %d ", $start_time, $end_time);
if ($sel_worker_id) {
$sql .= sprintf("AND tte.worker_id = %d ", $sel_worker_id);
}
// Do Not use Group By it breaks things.
// $sql .= "GROUP BY activity_name ";
$sql .= "ORDER BY w.last_name, w.first_name, activity_name, w.id, tte.log_date ";
// echo $sql;
$rs = $db->Execute($sql);
$time_entries = array();
$filename = "worker-" . $active_worker->id . ".csv";
$full_filename = getcwd() . '/storage/answernet/' . $filename;
if (file_exists($full_filename)) {
if (!is_writable($full_filename)) {
die("The file: {$full_filename} is not writable");
}
} elseif (!is_writable(getcwd() . '/storage/answernet/')) {
die("you cannot create files in this directory. Check the permissions");
}
//open the file for Writing
$fh = fopen($full_filename, "w");
//Lock the file for the write operation
flock($fh, LOCK_EX);
$label = array("Worker Name", "Ticket No", "Client", "Asset", "Site Name", "Billing Group", "Billing Min", "Sub-Total", "Total", "Date Recorded", "Notes");
fputcsv($fh, $label, ",", "\"");
if (is_a($rs, 'ADORecordSet')) {
while (!$rs->EOF) {
$csv = array();
$custom_fields = array();
$mins = intval($rs->fields['time_actual_mins']);
$worker_id = intval($rs->fields['worker_id']);
$org_id = intval($rs->fields['org_id']);
$activity = $rs->fields['activity_name'];
$log_date = intval($rs->fields['log_date']);
$notes = $rs->fields['notes'];
if (!isset($time_entries[$worker_id])) {
$time_entries[$worker_id] = array();
$time_entries[$worker_id]['mins'] = array();
}
if (!isset($subtotal)) {
$subtotal = array();
$subtotal_activity = $activity;
$subtotal['name'] = $workers[$worker_id]->getName(false);
$subtotal['source_id'] = "";
$subtotal['client'] = "";
$subtotal['asset'] = "";
$subtotal['sitename'] = "";
$subtotal['activity_name'] = $activity;
$subtotal['mins'] = "";
} else {
//.........这里部分代码省略.........
示例2: run
function run()
{
$logger = DevblocksPlatform::getConsoleLog();
$logger->info("[Alerts] Starting...");
$alerts = DAO_Alert::getAll();
$check_sensors = DAO_Sensor::getAll();
$workers = DAO_Worker::getAll();
if (is_array($alerts)) {
foreach ($alerts as $alert) {
/* @var $alert Model_Alert */
if (!isset($workers[$alert->worker_id])) {
continue;
}
$logger->info(sprintf("[Alerts] Checking '%s' for %s...", $alert->name, $workers[$alert->worker_id]->getName()));
$hit_sensors = $alert->getMatches($check_sensors);
if (is_array($hit_sensors)) {
$alert->run($hit_sensors);
}
}
}
$logger->info("[Alerts] Finished!");
}
示例3: getMatches
/**
* @return Model_WatcherMailFilter[]|false
*/
static function getMatches(CerberusTicket $ticket, $event, $only_worker_id = null)
{
$matches = array();
if (!empty($only_worker_id)) {
$filters = DAO_WatcherMailFilter::getWhere(sprintf("%s = %d AND %s = %d", DAO_WatcherMailFilter::WORKER_ID, $only_worker_id, DAO_WatcherMailFilter::IS_DISABLED, 0));
} else {
$filters = DAO_WatcherMailFilter::getWhere(sprintf("%s = %d", DAO_WatcherMailFilter::IS_DISABLED, 0));
}
// [JAS]: Don't send obvious spam to watchers.
if ($ticket->spam_score >= 0.9) {
return false;
}
// Build our objects
$ticket_from = DAO_Address::get($ticket->last_wrote_address_id);
$ticket_group_id = $ticket->team_id;
// [TODO] These expensive checks should only populate when needed
$messages = DAO_Ticket::getMessagesByTicket($ticket->id);
$message_headers = array();
if (empty($messages)) {
return false;
}
if (null != @($message_last = array_pop($messages))) {
/* @var $message_last CerberusMessage */
$message_headers = $message_last->getHeaders();
}
// Clear the rest of the message manifests
unset($messages);
$custom_fields = DAO_CustomField::getAll();
// Lazy load when needed on criteria basis
$ticket_field_values = null;
$address_field_values = null;
$org_field_values = null;
// Worker memberships (for checking permissions)
$workers = DAO_Worker::getAll();
$group_rosters = DAO_Group::getRosters();
// Check filters
if (is_array($filters)) {
foreach ($filters as $filter) {
/* @var $filter Model_WatcherMailFilter */
$passed = 0;
// check the worker's group memberships
if (!isset($workers[$filter->worker_id]) || $workers[$filter->worker_id]->is_disabled || !$workers[$filter->worker_id]->is_superuser && !isset($group_rosters[$ticket->team_id][$filter->worker_id])) {
// no membership
continue;
}
// check criteria
foreach ($filter->criteria as $rule_key => $rule) {
@($value = $rule['value']);
switch ($rule_key) {
case 'dayofweek':
$current_day = strftime('%w');
//$current_day = 1;
// Forced to English abbrevs as indexes
$days = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
// Is the current day enabled?
if (isset($rule[$days[$current_day]])) {
$passed++;
}
break;
case 'timeofday':
$current_hour = strftime('%H');
$current_min = strftime('%M');
//$current_hour = 17;
//$current_min = 5;
if (null != ($from_time = @$rule['from'])) {
list($from_hour, $from_min) = explode(':', $from_time);
}
if (null != ($to_time = @$rule['to'])) {
if (list($to_hour, $to_min) = explode(':', $to_time)) {
}
}
// Do we need to wrap around to the next day's hours?
if ($from_hour > $to_hour) {
// yes
$to_hour += 24;
// add 24 hrs to the destination (1am = 25th hour)
}
// Are we in the right 24 hourly range?
if ((int) $current_hour >= $from_hour && (int) $current_hour <= $to_hour) {
// If we're in the first hour, are we minutes early?
if ($current_hour == $from_hour && (int) $current_min < $from_min) {
break;
}
// If we're in the last hour, are we minutes late?
if ($current_hour == $to_hour && (int) $current_min > $to_min) {
break;
}
$passed++;
}
break;
case 'event':
if (!empty($event) && is_array($rule) && isset($rule[$event])) {
$passed++;
}
break;
case 'groups':
if (null !== @($group_buckets = $rule['groups'][$ticket->team_id]) && (empty($group_buckets) || in_array($ticket->category_id, $group_buckets))) {
//.........这里部分代码省略.........
示例4: handleRequest
function handleRequest(DevblocksHttpRequest $request)
{
$worker = CerberusApplication::getActiveWorker();
if (empty($worker)) {
return;
}
$stack = $request->path;
array_shift($stack);
// print
@($object = strtolower(array_shift($stack)));
// ticket|message|etc
$tpl = DevblocksPlatform::getTemplateService();
$tpl->assign('path', $this->_TPL_PATH);
$settings = DevblocksPlatform::getPluginSettingsService();
$tpl->assign('settings', $settings);
$translate = DevblocksPlatform::getTranslationService();
$tpl->assign('translate', $translate);
$teams = DAO_Group::getAll();
$tpl->assign('teams', $teams);
$buckets = DAO_Bucket::getAll();
$tpl->assign('buckets', $buckets);
$workers = DAO_Worker::getAll();
$tpl->assign('workers', $workers);
// Security
$active_worker = CerberusApplication::getActiveWorker();
$active_worker_memberships = $active_worker->getMemberships();
// [TODO] Make this pluggable
// Subcontroller
switch ($object) {
case 'ticket':
@($id = array_shift($stack));
@($ticket = is_numeric($id) ? DAO_Ticket::getTicket($id) : DAO_Ticket::getTicketByMask($id));
$convo_timeline = array();
$messages = $ticket->getMessages();
foreach ($messages as $message_id => $message) {
/* @var $message CerberusMessage */
$key = $message->created_date . '_m' . $message_id;
// build a chrono index of messages
$convo_timeline[$key] = array('m', $message_id);
}
@($mail_inline_comments = DAO_WorkerPref::get($active_worker->id, 'mail_inline_comments', 1));
if ($mail_inline_comments) {
// if inline comments are enabled
$comments = DAO_TicketComment::getByTicketId($ticket->id);
arsort($comments);
$tpl->assign('comments', $comments);
// build a chrono index of comments
foreach ($comments as $comment_id => $comment) {
/* @var $comment Model_TicketComment */
$key = $comment->created . '_c' . $comment_id;
$convo_timeline[$key] = array('c', $comment_id);
}
}
ksort($convo_timeline);
$tpl->assign('convo_timeline', $convo_timeline);
// Comment parent addresses
$comment_addresses = array();
foreach ($comments as $comment) {
/* @var $comment Model_TicketComment */
$address_id = intval($comment->address_id);
if (!isset($comment_addresses[$address_id])) {
$address = DAO_Address::get($address_id);
$comment_addresses[$address_id] = $address;
}
}
$tpl->assign('comment_addresses', $comment_addresses);
// Message Notes
$notes = DAO_MessageNote::getByTicketId($ticket->id);
$message_notes = array();
// Index notes by message id
if (is_array($notes)) {
foreach ($notes as $note) {
if (!isset($message_notes[$note->message_id])) {
$message_notes[$note->message_id] = array();
}
$message_notes[$note->message_id][$note->id] = $note;
}
}
$tpl->assign('message_notes', $message_notes);
// Make sure we're allowed to view this ticket or message
if (!isset($active_worker_memberships[$ticket->team_id])) {
echo "<H1>" . $translate->_('common.access_denied') . "</H1>";
return;
}
$tpl->assign('ticket', $ticket);
$tpl->display('file:' . $this->_TPL_PATH . 'print/ticket.tpl');
break;
case 'message':
@($id = array_shift($stack));
@($message = DAO_Ticket::getMessage($id));
@($ticket = DAO_Ticket::getTicket($message->ticket_id));
// Make sure we're allowed to view this ticket or message
if (!isset($active_worker_memberships[$ticket->team_id])) {
echo "<H1>" . $translate->_('common.access_denied') . "</H1>";
return;
}
// Message Notes
$notes = DAO_MessageNote::getByTicketId($ticket->id);
$message_notes = array();
// Index notes by message id
//.........这里部分代码省略.........
示例5: saveWorkerPeekAction
function saveWorkerPeekAction()
{
$translate = DevblocksPlatform::getTranslationService();
$active_worker = FegApplication::getActiveWorker();
if (!$active_worker || !$active_worker->is_superuser) {
return;
}
@($id = DevblocksPlatform::importGPC($_POST['id'], 'integer'));
@($view_id = DevblocksPlatform::importGPC($_POST['view_id'], 'string'));
@($first_name = DevblocksPlatform::importGPC($_POST['first_name'], 'string'));
@($last_name = DevblocksPlatform::importGPC($_POST['last_name'], 'string'));
@($title = DevblocksPlatform::importGPC($_POST['title'], 'string'));
@($email = DevblocksPlatform::importGPC($_POST['email'], 'string'));
@($password = DevblocksPlatform::importGPC($_POST['password'], 'string'));
@($is_superuser = DevblocksPlatform::importGPC($_POST['is_superuser'], 'integer', 0));
@($disabled = DevblocksPlatform::importGPC($_POST['is_disabled'], 'integer', 0));
// @$group_ids = DevblocksPlatform::importGPC($_POST['group_ids'],'array');
// @$group_roles = DevblocksPlatform::importGPC($_POST['group_roles'],'array');
@($delete = DevblocksPlatform::importGPC($_POST['do_delete'], 'integer', 0));
// [TODO] The superuser set bit here needs to be protected by ACL
if (empty($first_name)) {
$first_name = "Anonymous";
}
if (!empty($id) && !empty($delete)) {
// Can't delete or disable self
if ($active_worker->id != $id) {
DAO_Worker::delete($id);
}
} else {
if (empty($id) && null == DAO_Worker::getWhere(sprintf("%s=%s", DAO_Worker::EMAIL, Feg_ORMHelper::qstr($email)))) {
$workers = DAO_Worker::getAll();
$license = FegLicense::getInstance();
if (!empty($license) && !empty($license['serial']) || count($workers) < 3) {
// Creating new worker. If password is empty, email it to them
if (empty($password)) {
$settings = DevblocksPlatform::getPluginSettingsService();
$replyFrom = $settings->get('feg.core', FegSettings::DEFAULT_REPLY_FROM);
$replyPersonal = $settings->get('feg.core', FegSettings::DEFAULT_REPLY_PERSONAL, '');
$url = DevblocksPlatform::getUrlService();
$password = FegApplication::generatePassword(8);
}
$fields = array(DAO_Worker::EMAIL => $email, DAO_Worker::PASS => $password);
$id = DAO_Worker::create($fields);
}
}
// end create worker
// Update
$fields = array(DAO_Worker::FIRST_NAME => $first_name, DAO_Worker::LAST_NAME => $last_name, DAO_Worker::TITLE => $title, DAO_Worker::EMAIL => $email, DAO_Worker::IS_SUPERUSER => $is_superuser, DAO_Worker::IS_DISABLED => $disabled);
// if we're resetting the password
if (!empty($password)) {
$fields[DAO_Worker::PASS] = md5($password);
}
// Update worker
DAO_Worker::update($id, $fields);
// Custom field saves
@($field_ids = DevblocksPlatform::importGPC($_POST['field_ids'], 'array', array()));
DAO_CustomFieldValue::handleFormPost(FegCustomFieldSource_Worker::ID, $id, $field_ids);
}
if (!empty($view_id)) {
$view = Feg_AbstractViewLoader::getView($view_id);
$view->render();
}
}
示例6: render
function render()
{
$tpl = DevblocksPlatform::getTemplateService();
$active_worker = CerberusApplication::getActiveWorker();
$memberships = $active_worker->getMemberships();
$response = DevblocksPlatform::getHttpResponse();
@($section = $response->path[1]);
//print_r($_REQUEST);exit();
//@$page = DevblocksPlatform::importGPC($_GET['password']);
@($page = DevblocksPlatform::importGPC($_REQUEST['page'], 'integer'));
if ($page == NULL) {
$page = 0;
}
if (isset($_POST['a2'])) {
@($section = $_POST['a2']);
} else {
@($section = $response->path[2]);
}
//print_r($section);
//echo $section;
switch ($section) {
case 'search':
$title = 'Search';
$query = $_POST['query'];
if ($query && false === strpos($query, '*')) {
$query = '*' . $query . '*';
}
if (!is_null($query)) {
$params = array();
$type = $_POST['type'];
switch ($type) {
case "mask":
$params[SearchFields_Ticket::TICKET_MASK] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_MASK, DevblocksSearchCriteria::OPER_LIKE, strtoupper($query));
break;
case "sender":
$params[SearchFields_Ticket::TICKET_FIRST_WROTE] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_FIRST_WROTE, DevblocksSearchCriteria::OPER_LIKE, strtolower($query));
break;
case "subject":
$params[SearchFields_Ticket::TICKET_SUBJECT] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_SUBJECT, DevblocksSearchCriteria::OPER_LIKE, $query);
break;
case "content":
$params[SearchFields_Ticket::TICKET_MESSAGE_CONTENT] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_MESSAGE_CONTENT, DevblocksSearchCriteria::OPER_LIKE, $query);
break;
}
} else {
//show the search form because no search has been submitted
$tpl->display('file:' . dirname(__FILE__) . '/templates/tickets/search.tpl');
return;
}
break;
case 'sidebar':
$groups = DAO_Group::getAll();
$tpl->assign('groups', $groups);
$group_buckets = DAO_Bucket::getTeams();
$tpl->assign('group_buckets', $group_buckets);
$workers = DAO_Worker::getAll();
$tpl->assign('workers', $workers);
$group_counts = DAO_Overview::getGroupTotals();
$tpl->assign('group_counts', $group_counts);
$waiting_counts = DAO_Overview::getWaitingTotals();
$tpl->assign('waiting_counts', $waiting_counts);
$worker_counts = DAO_Overview::getWorkerTotals();
$tpl->assign('worker_counts', $worker_counts);
$tpl->display('file:' . dirname(__FILE__) . '/templates/tickets/sidebar.tpl');
return;
break;
case 'overview':
default:
$workers = DAO_Worker::getAll();
$group_buckets = DAO_Bucket::getTeams();
$groups = DAO_Group::getAll();
@($filter = $response->path[3]);
switch ($filter) {
case 'group':
@($filter_group_id = $response->path[4]);
$params = array(SearchFields_Ticket::TICKET_CLOSED => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_CLOSED, '=', CerberusTicketStatus::OPEN), SearchFields_Ticket::TICKET_WAITING => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_WAITING, '=', 0), SearchFields_Ticket::TICKET_NEXT_WORKER_ID => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_NEXT_WORKER_ID, '=', 0));
if (!is_null($filter_group_id) && isset($groups[$filter_group_id])) {
$tpl->assign('filter_group_id', $filter_group_id);
$title = $groups[$filter_group_id]->name;
$params[SearchFields_Ticket::TICKET_TEAM_ID] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_TEAM_ID, '=', $filter_group_id);
@($filter_bucket_id = $response->path[5]);
if (!is_null($filter_bucket_id)) {
$tpl->assign('filter_bucket_id', $filter_bucket_id);
@($title .= ': ' . ($filter_bucket_id == 0 ? 'Inbox' : $group_buckets[$filter_group_id][$filter_bucket_id]->name));
$params[SearchFields_Ticket::TICKET_CATEGORY_ID] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_CATEGORY_ID, '=', $filter_bucket_id);
} else {
@($title .= ' (Spam Filtered)');
$params[SearchFields_Ticket::TICKET_SPAM_SCORE] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_SPAM_SCORE, '<=', '0.9000');
}
}
break;
case 'waiting':
@($filter_waiting_id = $response->path[4]);
$params = array(SearchFields_Ticket::TICKET_CLOSED => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_CLOSED, '=', CerberusTicketStatus::OPEN), SearchFields_Ticket::TICKET_WAITING => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_WAITING, '=', 1));
if (!is_null($filter_waiting_id) && isset($groups[$filter_waiting_id])) {
$tpl->assign('filter_waiting_id', $filter_waiting_id);
$title = '[Waiting] ' . $groups[$filter_waiting_id]->name;
$params[SearchFields_Ticket::TICKET_TEAM_ID] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_TEAM_ID, '=', $filter_waiting_id);
@($filter_bucket_id = $response->path[5]);
if (!is_null($filter_bucket_id)) {
//.........这里部分代码省略.........
示例7: renderCriteriaParam
function renderCriteriaParam($param)
{
$field = $param->field;
$values = !is_array($param->value) ? array($param->value) : $param->value;
switch ($field) {
case SearchFields_CrmOpportunity::WORKER_ID:
$workers = DAO_Worker::getAll();
$strings = array();
foreach ($values as $val) {
if (empty($val)) {
$strings[] = "Nobody";
} elseif (!isset($workers[$val])) {
continue;
} else {
$strings[] = $workers[$val]->getName();
}
}
echo implode(", ", $strings);
break;
default:
parent::renderCriteriaParam($param);
break;
}
}
示例8: render
function render()
{
$tpl = DevblocksPlatform::getTemplateService();
$tpl->cache_lifetime = "0";
$tpl->assign('path', $this->tpl_path);
$tpl->assign('start', '-30 days');
$tpl->assign('end', 'now');
$db = DevblocksPlatform::getDatabaseService();
$workers = DAO_Worker::getAll();
$tpl->assign('workers', $workers);
// Teams
$teams = DAO_Group::getAll();
$tpl->assign('teams', $teams);
// Categories
$team_categories = DAO_Bucket::getTeams();
// [TODO] Cache these
$tpl->assign('team_categories', $team_categories);
// Security
if (null == ($active_worker = CerberusApplication::getActiveWorker())) {
die($translate->_('common.access_denied'));
}
$tpl->assign('active_worker', $active_worker);
$filename = "report-plus1-" . $active_worker->id . ".csv";
$href_filename = 'storage/answernet/' . $filename;
$tpl->assign('href_filename', $href_filename);
$tpl->display('file:' . $this->tpl_path . '/report_plus1_time.tpl');
}
示例9: showComposePeekAction
function showComposePeekAction()
{
@($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', ''));
@($to = DevblocksPlatform::importGPC($_REQUEST['to'], 'string', ''));
$tpl = DevblocksPlatform::getTemplateService();
$tpl_path = $this->_TPL_PATH;
$tpl->assign('path', $tpl_path);
$tpl->assign('view_id', $view_id);
$tpl->assign('to', $to);
$teams = DAO_Group::getAll();
$tpl->assign_by_ref('teams', $teams);
$workers = DAO_Worker::getAll();
$tpl->assign('workers', $workers);
$tpl->display('file:' . $this->_TPL_PATH . 'tickets/compose/peek.tpl');
}
示例10: showContactHistoryAction
function showContactHistoryAction()
{
$visit = CerberusApplication::getVisit();
/* @var $visit CerberusVisit */
$translate = DevblocksPlatform::getTranslationService();
@($ticket_id = DevblocksPlatform::importGPC($_REQUEST['ticket_id'], 'integer'));
$tpl = DevblocksPlatform::getTemplateService();
$tpl->assign('path', $this->_TPL_PATH);
// Ticket
$ticket = DAO_Ticket::getTicket($ticket_id);
$tpl->assign('ticket', $ticket);
$requesters = $ticket->getRequesters();
// Addy
$contact = DAO_Address::get($ticket->first_wrote_address_id);
$tpl->assign('contact', $contact);
// Scope
$scope = $visit->get('display.history.scope', '');
// [TODO] Sanitize scope preference
// Defaults
$defaults = new C4_AbstractViewModel();
$defaults->class_name = 'C4_TicketView';
$defaults->id = 'contact_history';
$defaults->name = $translate->_('addy_book.history.view.title');
$defaults->view_columns = array(SearchFields_Ticket::TICKET_LAST_ACTION_CODE, SearchFields_Ticket::TICKET_CREATED_DATE, SearchFields_Ticket::TICKET_TEAM_ID, SearchFields_Ticket::TICKET_CATEGORY_ID);
$defaults->params = array();
$defaults->renderLimit = 10;
$defaults->renderSortBy = SearchFields_Ticket::TICKET_CREATED_DATE;
$defaults->renderSortAsc = false;
// View
$view = C4_AbstractViewLoader::getView('contact_history', $defaults);
// Sanitize scope options
if ('org' == $scope) {
if (empty($contact->contact_org_id)) {
$scope = '';
}
if (null == ($contact_org = DAO_ContactOrg::get($contact->contact_org_id))) {
$scope = '';
}
}
if ('domain' == $scope) {
$email_parts = explode('@', $contact->email);
if (!is_array($email_parts) || 2 != count($email_parts)) {
$scope = '';
}
}
switch ($scope) {
case 'org':
$view->params = array(SearchFields_Ticket::TICKET_FIRST_CONTACT_ORG_ID => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_FIRST_CONTACT_ORG_ID, '=', $contact->contact_org_id), SearchFields_Ticket::TICKET_DELETED => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_DELETED, '=', 0));
$view->name = ucwords($translate->_('contact_org.name')) . ": " . $contact_org->name;
break;
case 'domain':
$view->params = array(SearchFields_Ticket::REQUESTER_ADDRESS => new DevblocksSearchCriteria(SearchFields_Ticket::REQUESTER_ADDRESS, 'like', '*@' . $email_parts[1]), SearchFields_Ticket::TICKET_DELETED => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_DELETED, '=', 0));
$view->name = ucwords($translate->_('common.email')) . ": *@" . $email_parts[1];
break;
default:
case 'email':
$scope = 'email';
$view->params = array(SearchFields_Ticket::REQUESTER_ID => new DevblocksSearchCriteria(SearchFields_Ticket::REQUESTER_ID, 'in', array_keys($requesters)), SearchFields_Ticket::TICKET_DELETED => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_DELETED, '=', 0));
$view->name = ucwords($translate->_('common.email')) . ": " . $contact->email;
break;
}
$tpl->assign('scope', $scope);
$view->renderPage = 0;
$tpl->assign('view', $view);
C4_AbstractViewLoader::setView($view->id, $view);
$workers = DAO_Worker::getAll();
$tpl->assign('workers', $workers);
$teams = DAO_Group::getAll();
$tpl->assign('teams', $teams);
$buckets = DAO_Bucket::getAll();
$tpl->assign('buckets', $buckets);
$team_categories = DAO_Bucket::getTeams();
$tpl->assign('team_categories', $team_categories);
$tpl->display('file:' . $this->_TPL_PATH . 'display/modules/history/index.tpl');
}
示例11: render
function render()
{
$this->_sanitize();
$tpl = DevblocksPlatform::getTemplateService();
$tpl->assign('id', $this->id);
$tpl->assign('view', $this);
$workers = DAO_Worker::getAll();
$tpl->assign('workers', $workers);
$tpl->cache_lifetime = "0";
$tpl->assign('view_fields', $this->getColumns());
$tpl->display('file:' . DEVBLOCKS_PLUGIN_PATH . 'cerberusweb.core/templates/home/tabs/my_events/view.tpl');
}
示例12: render
function render()
{
$db = DevblocksPlatform::getDatabaseService();
$tpl = DevblocksPlatform::getTemplateService();
$tpl->assign('path', $this->tpl_path);
$workers = DAO_Worker::getAll();
$tpl->assign('workers', $workers);
// Year shortcuts
$years = array();
$sql = "SELECT date_format(from_unixtime(created_date),'%Y') as year FROM ticket WHERE created_date > 0 GROUP BY year having year <= date_format(now(),'%Y') ORDER BY year desc limit 0,10";
$rs = $db->query($sql);
if (is_a($rs, 'ADORecordSet')) {
while (!$rs->EOF) {
$years[] = intval($rs->fields['year']);
$rs->MoveNext();
}
}
$tpl->assign('years', $years);
// Dates
@($age = DevblocksPlatform::importGPC($_REQUEST['age'], 'string', '30d'));
@($start = DevblocksPlatform::importGPC($_REQUEST['start'], 'string', ''));
@($end = DevblocksPlatform::importGPC($_REQUEST['end'], 'string', ''));
@($worker_id = DevblocksPlatform::importGPC($_REQUEST['worker_id'], 'integer', 0));
$tpl->assign('worker_id', $worker_id);
// use date range if specified, else use duration prior to now
$start_time = 0;
$end_time = 0;
if (!$worker_id) {
$worker = CerberusApplication::getActiveWorker();
$worker_id = $worker->id;
}
if (empty($start) && empty($end)) {
$start = "-30 days";
$end = "now";
$start_time = strtotime($start);
$end_time = strtotime($end);
} else {
$start_time = strtotime($start);
$end_time = strtotime($end);
}
$tpl->assign('start', $start);
$tpl->assign('end', $end);
// Table
$sql = sprintf("SELECT t.id, t.mask, t.subject, a.email as email, " . "date_format(from_unixtime(m.created_date),'%%Y-%%m-%%d') as day " . "FROM ticket t " . "INNER JOIN message m ON t.id = m.ticket_id " . "INNER JOIN worker w ON m.worker_id = w.id " . "INNER JOIN address a on t.first_wrote_address_id = a.id " . "WHERE m.created_date > %d AND m.created_date <= %d " . "AND m.is_outgoing = 1 " . "AND t.is_deleted = 0 " . "AND w.id = %d " . "GROUP BY day, t.id " . "order by m.created_date", $start_time, $end_time, $worker_id);
$rs = $db->Execute($sql);
$tickets_replied = array();
if (is_a($rs, 'ADORecordSet')) {
while (!$rs->EOF) {
$created_day = $rs->fields['day'];
unset($reply_date_ticket);
$reply_date_ticket->mask = $rs->fields['mask'];
$reply_date_ticket->email = $rs->fields['email'];
$reply_date_ticket->subject = $rs->fields['subject'];
$reply_date_ticket->id = intval($rs->fields['id']);
$tickets_replied[$created_day][] = $reply_date_ticket;
$rs->MoveNext();
}
}
$tpl->assign('tickets_replied', $tickets_replied);
// Chart
$sql = sprintf("SELECT count(*) AS hits, m.worker_id " . "FROM message m " . "INNER JOIN ticket t ON (t.id=m.ticket_id) " . "INNER JOIN worker w ON w.id=m.worker_id " . "WHERE m.created_date > %d AND m.created_date <= %d " . "AND m.is_outgoing = 1 " . "AND t.is_deleted = 0 " . "GROUP BY m.worker_id ORDER BY w.last_name DESC ", $start_time, $end_time);
$rs_workers = $db->Execute($sql);
/* @var $rs_workers ADORecordSet */
$worker_counts = array();
$data = array();
$iter = 0;
while (!$rs_workers->EOF) {
$hits = intval($rs_workers->fields['hits']);
$worker_id = intval($rs_workers->fields['worker_id']);
if (!isset($workers[$worker_id])) {
continue;
}
$data[$iter++] = array('value' => $workers[$worker_id]->getName(), 'hits' => $hits);
$rs_workers->MoveNext();
}
$tpl->assign('data', $data);
// Template
$tpl->display('file:' . $this->tpl_path . '/reports/worker/worker_history/index.tpl');
}
示例13: saveWorkerAction
function saveWorkerAction()
{
$translate = DevblocksPlatform::getTranslationService();
$active_worker = CerberusApplication::getActiveWorker();
if (!$active_worker || !$active_worker->is_superuser) {
echo $translate->_('common.access_denied');
return;
}
if (DEMO_MODE) {
DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('config', 'workers')));
return;
}
@($id = DevblocksPlatform::importGPC($_POST['id'], 'integer'));
@($first_name = DevblocksPlatform::importGPC($_POST['first_name'], 'string'));
@($last_name = DevblocksPlatform::importGPC($_POST['last_name'], 'string'));
@($title = DevblocksPlatform::importGPC($_POST['title'], 'string'));
@($primary_email = DevblocksPlatform::importGPC($_POST['primary_email'], 'string'));
@($email = DevblocksPlatform::importGPC($_POST['email'], 'string'));
@($password = DevblocksPlatform::importGPC($_POST['password'], 'string'));
@($is_superuser = DevblocksPlatform::importGPC($_POST['is_superuser'], 'integer'));
@($group_ids = DevblocksPlatform::importGPC($_POST['group_ids'], 'array'));
@($group_roles = DevblocksPlatform::importGPC($_POST['group_roles'], 'array'));
@($disabled = DevblocksPlatform::importGPC($_POST['do_disable'], 'integer', 0));
@($delete = DevblocksPlatform::importGPC($_POST['do_delete'], 'integer', 0));
// [TODO] The superuser set bit here needs to be protected by ACL
if (empty($first_name)) {
$first_name = "Anonymous";
}
if (!empty($id) && !empty($delete)) {
// Can't delete or disable self
if ($active_worker->id == $id) {
return;
}
DAO_Worker::deleteAgent($id);
} else {
if (empty($id) && null == DAO_Worker::lookupAgentEmail($email)) {
$workers = DAO_Worker::getAll();
$license = CerberusLicense::getInstance();
if (!empty($license) && !empty($license['serial']) || count($workers) < 3) {
// Creating new worker. If password is empty, email it to them
if (empty($password)) {
$settings = CerberusSettings::getInstance();
$replyFrom = $settings->get(CerberusSettings::DEFAULT_REPLY_FROM);
$replyPersonal = $settings->get(CerberusSettings::DEFAULT_REPLY_PERSONAL, '');
$url = DevblocksPlatform::getUrlService();
$password = CerberusApplication::generatePassword(8);
try {
$mail_service = DevblocksPlatform::getMailService();
$mailer = $mail_service->getMailer(CerberusMail::getMailerDefaults());
$mail = $mail_service->createMessage();
$sendTo = new Swift_Address($email, $first_name . $last_name);
$sendFrom = new Swift_Address($replyFrom, $replyPersonal);
$mail->setSubject('Your new helpdesk login information!');
$mail->generateId();
$mail->headers->set('X-Mailer', 'Cerberus Helpdesk (Build ' . APP_BUILD . ')');
$body = sprintf("Your new helpdesk login information is below:\r\n" . "\r\n" . "URL: %s\r\n" . "Login: %s\r\n" . "Password: %s\r\n" . "\r\n" . "You should change your password from Preferences after logging in for the first time.\r\n" . "\r\n", $url->write('', true), $email, $password);
$mail->attach(new Swift_Message_Part($body, 'text/plain', 'base64', LANG_CHARSET_CODE));
if (!$mailer->send($mail, $sendTo, $sendFrom)) {
throw new Exception('Password notification email failed to send.');
}
} catch (Exception $e) {
// [TODO] need to report to the admin when the password email doesn't send. The try->catch
// will keep it from killing php, but the password will be empty and the user will never get an email.
}
}
$id = DAO_Worker::create($email, $password, '', '', '');
} else {
//not licensed and worker limit reached
DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('config', 'workers')));
return;
}
}
$fields = array(DAO_Worker::FIRST_NAME => $first_name, DAO_Worker::LAST_NAME => $last_name, DAO_Worker::TITLE => $title, DAO_Worker::EMAIL => $email, DAO_Worker::IS_SUPERUSER => $is_superuser, DAO_Worker::IS_DISABLED => $disabled);
// if we're resetting the password
if (!empty($password)) {
$fields[DAO_Worker::PASSWORD] = md5($password);
}
// Update worker
DAO_Worker::updateAgent($id, $fields);
// Update group memberships
if (is_array($group_ids) && is_array($group_roles)) {
foreach ($group_ids as $idx => $group_id) {
if (empty($group_roles[$idx])) {
DAO_Group::unsetTeamMember($group_id, $id);
} else {
DAO_Group::setTeamMember($group_id, $id, 2 == $group_roles[$idx]);
}
}
}
// Add the worker e-mail to the addresses table
if (!empty($email)) {
DAO_Address::lookupAddress($email, true);
}
// Addresses
if (null == DAO_AddressToWorker::getByAddress($email)) {
DAO_AddressToWorker::assign($email, $id);
DAO_AddressToWorker::update($email, array(DAO_AddressToWorker::IS_CONFIRMED => 1));
}
}
DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('config', 'workers')));
//.........这里部分代码省略.........
示例14: AnswernetMetlifeReportGroupReport1Action
function AnswernetMetlifeReportGroupReport1Action()
{
$db = DevblocksPlatform::getDatabaseService();
$translate = DevblocksPlatform::getTranslationService();
$url = DevblocksPlatform::getUrlService();
$workers = DAO_Worker::getAll();
$radius = 12;
// Security
if (null == ($active_worker = CerberusApplication::getActiveWorker())) {
die($translate->_('common.access_denied'));
}
// import dates from form
@($start_time = DevblocksPlatform::importGPC($_REQUEST['start'], 'string', ''));
@($group = DevblocksPlatform::importGPC($_REQUEST['group'], 'string', ''));
if (empty($start_time) || !is_numeric($start_time)) {
return;
}
if (empty($group)) {
return;
}
$end_time = $start_time + 604800;
print $translate->_('answernet.er.metlife.week.number');
print date("W", $start_time);
print '<br>';
print $translate->_('answernet.er.metlife.generate.report');
switch ($group) {
case "All":
$filename = "report-metlife-week-" . date("W", $start_time) . ".xls";
$group_sql = "and (t.team_id = 756 or t.team_id = 782) ";
print " Group: ALL ";
$group_text = "All";
break;
case "fp":
$filename = "report-metlife-first-person-week-" . date("W", $start_time) . ".xls";
$group_sql = "and t.team_id = 756 ";
print " Group: First Person ";
$group_text = "First Person";
break;
case "iDesign":
$filename = "report-metlife-iDesign-week-" . date("W", $start_time) . ".xls";
$group_sql = "and team_id = 782 ";
print " Group: iDesign ";
$group_text = "iDesign";
break;
default:
print "Error: Group not set: " . $group;
return;
}
print '<br>';
print $translate->_('answernet.er.metlife.generating');
$full_filename = getcwd() . '/storage/answernet/' . $filename;
$href_filename = $url->write('storage/answernet/' . $filename, true);
$week_range_text = "Week # " . date("W - n/j/y", $start_time) . " - " . date("n/j/y", $start_time + 518400);
// Create new Excel Spreadsheet.
$workbook = new Spreadsheet_Excel_Writer($full_filename);
// Create metrics Tab and set Column Width and Row Hight.
$worksheet_metrics =& $workbook->addWorksheet('Weekly Metrics');
$worksheet_metrics->setColumn(0, 0, $radius * 1.71);
$worksheet_metrics->setColumn(0, 0, $radius * 0.5);
$worksheet_metrics->setRow(0, 56);
// Create ACD Calls(Inbound) Tab and set Column Width and Row Hight.
$worksheet_acd_in =& $workbook->addWorksheet('ACD calls(Inbound)');
$worksheet_acd_in->setColumn(0, 1, $radius * 0.78);
$worksheet_acd_in->setColumn(2, 2, $radius * 1.05);
$worksheet_acd_in->setColumn(3, 3, $radius * 1.23);
$worksheet_acd_in->setColumn(4, 4, $radius * 1.11);
$worksheet_acd_in->setColumn(5, 5, $radius * 1.15);
$worksheet_acd_in->setColumn(6, 6, $radius * 2.0);
$worksheet_acd_in->setColumn(7, 7, $radius * 0.78);
$worksheet_acd_in->setColumn(8, 8, $radius * 2.0);
$worksheet_acd_in->setColumn(9, 9, $radius * 0.78);
$worksheet_acd_in->setRow(0, 28);
$worksheet_acd_in->setRow(2, 32);
// Create ACD Calls(Outbound) Tab and set Column Width and Row Hight.
$worksheet_acd_out =& $workbook->addWorksheet('ACD calls(Outbound)');
// Create Phone Tickets Tab and set Column Width and Row Hight.
$worksheet_phone_tickets =& $workbook->addWorksheet('Phone Tickets');
// Create Email Tickets Tab and set Column Width and Row Hight.
$worksheet_email_tickets =& $workbook->addWorksheet('Email Tickets');
// Create Email Tickets Tab and set Column Width and Row Hight.
$worksheet_call_count =& $workbook->addWorksheet('Call Count');
// Create Inbound Count Tab and set Column Width and Row Hight.
$worksheet_in_count =& $workbook->addWorksheet('Inbound Email Count');
$worksheet_in_count->setColumn(0, 0, $radius * 2.87);
$worksheet_in_count->setColumn(1, 1, $radius * 0.66);
$worksheet_in_count->setColumn(2, 2, $radius * 2.87);
$worksheet_in_count->setColumn(3, 3, $radius * 0.62);
$worksheet_in_count->setColumn(4, 4, $radius * 0.66);
$worksheet_in_count->setColumn(5, 5, $radius * 2.87);
$worksheet_in_count->setColumn(6, 6, $radius * 0.66);
$worksheet_in_count->setRow(0, 32);
$worksheet_in_count->freezePanes(array(2, 0, 2, 0));
// Create Outbound Count Tab and set Column Width and Row Hight.
$worksheet_out_count =& $workbook->addWorksheet('Outbound Email Count');
$worksheet_out_count->setColumn(0, 0, $radius * 2.87);
$worksheet_out_count->setColumn(1, 1, $radius * 0.66);
$worksheet_out_count->setColumn(2, 2, $radius * 2.87);
$worksheet_out_count->setColumn(3, 3, $radius * 0.62);
$worksheet_out_count->setColumn(4, 4, $radius * 0.66);
$worksheet_out_count->setColumn(5, 5, $radius * 2.87);
//.........这里部分代码省略.........
示例15: renderCriteriaParam
function renderCriteriaParam($param)
{
$field = $param->field;
$vals = $param->value;
if (!is_array($vals)) {
$vals = array($vals);
}
// Do we need to do anything special on custom fields?
if ('cf_' == substr($field, 0, 3)) {
$field_id = intval(substr($field, 3));
$custom_fields = DAO_CustomField::getAll();
switch ($custom_fields[$field_id]->type) {
case Model_CustomField::TYPE_WORKER:
$workers = DAO_Worker::getAll();
foreach ($vals as $idx => $worker_id) {
if (isset($workers[$worker_id])) {
$vals[$idx] = $workers[$worker_id]->getName();
}
}
break;
}
}
echo implode(', ', $vals);
}