$GLOBALS['PHONEBOOK'] = PSU::db('phonebook'); /*******************[End Database Connections]*****************/ $idm = new IDMObject($GLOBALS['BANNER']); $GLOBALS['BannerIDM'] =& $idm; $GLOBALS['BannerGeneral'] = new BannerGeneral($GLOBALS['BANNER']); $user = new User($db); // User object $GLOBALS['user'] =& $user; $restore = new Restore($db); // Restore object $new_call = new NewCall($db); // New Call object IDMObject::authN(); $GLOBALS['is_employee'] = checkEmployee(); $GLOBALS['go'] = new go(); if (!checkEmployee() && $_SERVER['SCRIPT_NAME'] != '/webapp/calllog/add_new_call.html' && $_SERVER['SCRIPT_NAME'] != '/webapp/calllog/update_call_details.html') { exit('Not a Valid Employee'); } elseif ($_SERVER['SCRIPT_NAME'] == '/webapp/calllog/add_new_call.html' && $_POST && ($_GET['call_source'] == 'support' || $_GET['call_source'] == 'feedback')) { $_POST['problem_details'] = filter_var($_POST['problem_details'], FILTER_SANITIZE_STRING); $prevent_file_upload = true; $GLOBALS['end_user_email'] = true; $person = new PSUPerson($_SESSION['username']); $_POST['caller_user_name'] = $_POST['call_log_username'] = $person->username ? $person->username : $person->wp_id; $_POST['caller_first_name'] = $person->formatName('f'); $_POST['caller_last_name'] = $person->formatName('l'); if ($person->phones['OF'][0]) { $_POST['caller_phone_number'] = '(' . $person->phones['OF'][0]->phone_area . ')' . $person->phones['OF'][0]->phone_number; } else { $_POST['caller_phone_number'] = ''; } //end else
function sendOpenCallMail($call_info, $action) { global $db; $person_cache = array(); $call = $db->GetRow("SELECT * FROM call_log WHERE call_id = ?", array($call_info['call_id'])); $call_info['call_date'] = $call['call_date'] . ' ' . $call['call_time']; $headers = array(); $headers['content-type'] = 'text/html'; $caller = PSU::nvl($call_info['caller_wp_id'], $call_info['caller_pidm'], $call_info['call_log_username']); $caller_data = $GLOBALS['user']->getCallerData($caller); $logger = $person_cache[$call_info['call_log_username']] = PSUPerson::get($call_info['call_log_username']); $groupInfo = getGroupInfo($call_info['its_group_assigned_to']); $call_log_employee = checkEmployee($call_info['call_log_username']); $assigned_employee = checkEmployee($call_info['tlc_assigned_to']); $to = array(); // always send to the submitter if the submitter is an employee if ($call_log_employee) { if ($logger->system_account_exists) { $to[] = $logger->wp_email; } //end } else { $end_user_to = $logger->wp_email; } //end else if ($action == "its_staff") { $call_info['call_id'] = $call_info['new_call_id'] . $call_info['call_id']; $call_info['comments'] = $call_info['problem_details'] . $call_info['comments']; if ($call_info['tlc_assigned_to'] != "unassigned") { if ($assigned_employee) { $to[] = PSUPerson::get($call_info['tlc_assigned_to'])->wp_email; } elseif ($call_info['tlc_assigned_to'] == 'caller' && $call_info['call_id']) { $sql = "SELECT caller_username \n\t\t\t\t\t\t\t\t\tFROM call_log \n\t\t\t\t\t\t\t\t WHERE call_log.call_id = ?"; $end_user_to = $db->GetOne($sql, array($call_info['call_id'])); if ($end_user_to) { $end_user = PSUPerson::get($end_user_to); if ($end_user) { $end_user_to = $end_user->wp_email; } } //end if } else { $end_user = PSUPerson::get($call_info['tlc_assigned_to']); $end_user_to = $end_user->wp_email; } //end if } //end if if ($call_info['its_assigned_group'] != 0) { $sql = "SELECT email_to \n\t\t\t\t\t\t\t\tFROM itsgroups\n\t\t\t\t\t\t\t\t , call_log \n\t\t\t\t\t\t\t\t\t\t , call_history \n\t\t\t\t\t\t\t WHERE itsgroups.deleted = 0 \n\t\t\t\t\t\t\t\t AND call_log.call_id = call_history.call_id \n\t\t\t\t\t\t\t\t AND itsgroups.itsgroupid = ?\n\t\t\t AND call_log.call_id = ?"; $email_to = $db->GetOne($sql, array($call_info['its_assigned_group'], $call_info['call_id'])); if ($email_to == 'all') { $sql = "SELECT user_name\n\t\t\t\t\t\t\t\t\tFROM itsgroups\n\t\t\t\t\t\t\t\t\t , its_employee_groups\n\t\t\t\t\t\t\t\t\t , call_log_employee\n\t\t\t\t\t\t\t\t\tWHERE itsgroups.deleted = 0 \n\t\t\t\t\t\t\t\t\t\tAND call_log_employee.call_log_user_id = its_employee_groups.employee_id \n\t\t\t\t\t\t\t\t\t\tAND its_employee_groups.group_id = ?\n\t\t\t\t\t\t\t\t\t\tAND itsgroups.itsgroupid = its_employee_groups.group_id \n\t\t\t\t\t\t\t\t\t\tAND call_log_employee.status = 'active' \n\t\t\t\t AND its_employee_groups.option_id = '2'"; $email_list = $db->GetCol($sql, array($call_info['its_assigned_group'])); } else { $email_list = explode(',', $email_to); } //end else foreach ((array) $email_list as $identifier) { $user = PSUPerson::get($identifier); $to[] = $user->wp_email; } //end foreach } //end if if ($call_info['its_group_assigned_to'] != 0) { $subject = '[Call Log] [' . $groupInfo[1] . '] ' . $caller_data['name_full']; } else { $subject = '[Call Log] ' . $caller_data['name_full']; } $subject .= ' (#' . $call_info['call_id'] . ')'; if ($call_info['call_status'] == 'closed') { $subject .= ' [CLOSED]'; // always send close to the owner, if they are allowed to see the // full history $caller_identifier = $db->GetOne("SELECT calllog_username FROM call_log WHERE call_log.call_id = '{$call_info['call_id']}'"); $caller_user = PSUPerson::get($caller_identifier); if ($GLOBALS['end_user_email']) { $closing_user = PSUPerson::get($_SESSION['wp_id']); if ($caller_user->wp_email == $closing_user->wp_email) { $end_user_to = $closing_user->wp_email; } //end if } elseif (checkEmployee($caller_to)) { $to[] = $caller_user->wp_email; } //end else } $sql = "SELECT * \n\t\t\t\t\t\t\tFROM call_log\n\t\t\t\t\t\t\t , call_history \n\t\t\t\t\t\t WHERE call_log.call_id = ?\n\t\t\t\t\t\t\t AND call_log.call_id = call_history.call_id\n\t\t\t\t\t\t ORDER BY date_assigned DESC\n\t\t , time_assigned DESC"; $call_info_query = $db->Execute($sql, array($call_info['call_id'])); foreach ($call_info_query as $call_info2) { $group_name = getGroupInfo($call_info2['its_assigned_group']); if ($group_name[0] == '') { $group_name = 'Unassigned'; } else { $group_name = $group_name[0]; } $call_info2['group_name'] = $group_name; $call_info2['update_date'] = $call_info2['date_assigned'] . ' ' . $call_info2['time_assigned']; if ($call_info2['tlc_assigned_to'] && $call_info2['tlc_assigned_to'] != 'unassigned') { if (!$person_cache[$call_info2['tlc_assigned_to']]) { $person_cache[$call_info2['tlc_assigned_to']] = PSUPerson::get($call_info2['tlc_assigned_to']); } //end else $call_info2['assigned_to'] = $call_info2['tlc_assigned_to']; } //end if if ($call_info2['updated_by']) { if (!$person_cache[$call_info2['updated_by']]) { $person_cache[$call_info2['updated_by']] = PSUPerson::get($call_info2['updated_by']); } //end else $call_info2['logger'] = $call_info2['updated_by']; } //end if $history[] = $call_info2; } $caller_id = $caller_data['identifier']; if (!$person_cache[$caller_id]) { $person_cache[$caller_id] = PSUPerson::get($caller_id); } //end else $current = array_slice($history, 0, 1); $current = $current[0]; // email ITS $tpl = new PSUTemplate(); $tpl->assign('caller', $caller_data); $tpl->assign('caller_id', $caller_id); $tpl->assign('pcache', $person_cache); $tpl->assign('call', $call_info); $tpl->assign('current', $current); $tpl->assign('history', array_slice($history, 1)); $text_message = $tpl->fetch('email.ticket.text.tpl'); $html_message = $tpl->fetch('email.ticket.html.tpl'); $to = implode(',', array_unique($to)); if ($to) { $headers['from'] = $logger->formatName('f l') . ' <' . $logger->wp_email . '>'; PSU::mail($to, $subject, array($text_message, $html_message), $headers); } //end if // email user if ($end_user_to) { $headers['from'] = 'Support Tickets <*****@*****.**>'; $tpl->assign('is_caller', true); $tpl->assign('history', array()); $text_message = $tpl->fetch('email.ticket.text.tpl'); $html_message = $tpl->fetch('email.ticket.html.tpl'); PSU::mail($end_user_to, $subject, array($text_message, $html_message), $headers); } //end if } }
addCoupon(); } if ($function == "get_order") { getOrder(); } if ($function == "get_orders") { getOrders(); } if ($function == "add_review") { addReview(); } if ($function == "get_reviews") { getReviews(); } if ($function == "check_employee") { checkEmployee(); } if ($function == "register_employee") { registerEmployee(); } if ($function == "get_managed_employees") { getManagedEmployees(); } if ($function == "get_employee_username") { getEmployeeUsername(); } if ($function == "get_warehouses") { getWarehouses(); } if ($function == "add_warehouse") { addWarehouse();