parent_from = $def['parent_from'];
if(!empty($def['call_type'])) $this->call_type = $def['call_type'];
if(!empty($def['call_disposition'])) $this->call_disposition = $def['call_disposition'];
if(!empty($def['call_duration'])) $this->call_duration = $def['call_duration'];
if(!empty($def['call_duration_type'])) $this->call_duration_type = $def['call_duration_type'];
if(empty($def['title'])) $this->title = translate('LBL_DASHLET_MY_ECMCALLS', 'EcmCalls');
$this->searchFields = $dashletData['MyEcmCallsDashlet']['searchFields'];
$this->columns = $dashletData['MyEcmCallsDashlet']['columns'];
$this->seedBean = new EcmCall();
$this->lvs->quickViewLinks = false;
//var_dump($this->parent_from);
}
function buildWhere() {
global $current_user;
$returnArray = array();
if(!is_array($this->filters)) {
// use defaults
$this->filters = array();
foreach($this->searchFields as $name => $params) {
if(!empty($params['default']))
$this->filters[$name] = $params['default'];
}
}
foreach($this->filters as $name=>$params) {
if(!empty($params)) {
if($name == 'assigned_user_id' && $this->myItemsOnly) continue; // don't handle assigned user filter if filtering my items only
$widgetDef = $this->seedBean->field_defs[$name];
$widgetClass = $this->layoutManager->getClassFromWidgetDef($widgetDef, true);
$widgetDef['table'] = $this->seedBean->table_name;
$widgetDef['table_alias'] = $this->seedBean->table_name;
switch($widgetDef['type']) {// handle different types
case 'date':
case 'datetime':
if(!empty($params['date']))
$widgetDef['input_name0'] = $params['date'];
$_REQUEST['calldate_advanced'] = $params['type'];
break;
default:
$widgetDef['input_name0'] = $params;
if(is_array($params) && !empty($params)) { // handle array query
array_push($returnArray, $widgetClass->queryFilterone_of($widgetDef, false));
}
else {
array_push($returnArray, $widgetClass->queryFilterStarts_With($widgetDef, true));
}
$widgetDef['input_name0'] = $params;
break;
}
}
}
$_REQUEST['searchFormTab'] = "advanced_search";
if($this->call_type == "incoming") {
$_REQUEST['parent_to_advanced'] = "Users";
if($this->myItemsOnly)
$_REQUEST['parent_to_id_advanced'] = array($current_user->id);
else
$_REQUEST['parent_to_id_advanced'] = $this->parent_from;
}
else if($this->call_type == "outgoing" || $this->call_type == "both") {
$_REQUEST['parent_from_advanced'] = "Users";
if($this->myItemsOnly)
$_REQUEST['parent_from_id_advanced'] = array($current_user->id);
else
$_REQUEST['parent_from_id_advanced'] = $this->parent_from;
}
if($this->call_type == "both") $_REQUEST['in_out_advanced'] = 'on';
if($this->call_disposition) $_REQUEST['disposition_advanced'] = $this->call_disposition;
if($this->call_duration) $_REQUEST['duration_advanced'] = $this->call_duration;
if($this->call_duration_type) $_REQUEST['duration_type_advanced'] = $this->call_duration_type;
return $returnArray;
}
function saveOptions($req) {
$options = parent::saveOptions($req);
$options['parent_from'] = $req['parent_from'];
$options['call_type'] = $req['call_type'];
$options['call_disposition'] = $req['call_disposition'];
$options['call_duration'] = $req['call_duration'];
$options['call_duration_type'] = $req['call_duration_type'];
return $options;
}
function displayOptions() {
$this->processDisplayOptions();
require_once('modules/EcmCalls/EcmCall.php');
global $app_list_strings;
$this->currentSearchFields['calldate']['input'] = '';
$GLOBALS['db'] = new MysqlManager();
$GLOBALS['db']->connect();
$query = "SELECT `id`, CONCAT(IFNULL(CONCAT(`first_name`,' '),''), '', `last_name`) as `name` FROM `users` WHERE `status`='Active' and `deleted`=0 ORDER BY `name`";
$results = $GLOBALS['db']->query($query);
$arr = array();
if(is_resource($results)) {
while($row = $GLOBALS['db']->fetchByAssoc($results)) $arr[$row['id']] = $row['name'];
}
$this->currentSearchFields['parent_from']['input'] = '';
$this->currentSearchFields['call_type']['input'] = '';
$disp_arr=array(
''=>'select',
'ANSWERED'=>'Answered',
'BUSY'=>'Busy',
'FAILED'=>'Failed',
'NO ANSWER'=>'No answer',
);
$sel='';
$this->currentSearchFields['call_disposition']['input'] = $sel;
$this->currentSearchFields['call_disposition']['label'] = 'Disposition';
$cdt=array(
''=>'select',
'less'=>'<=',
'more'=>'>',
);
$sel='';
$this->currentSearchFields['call_duration']['input']=$sel.' s';
$this->currentSearchFields['call_duration']['label'] = 'Duration';
$this->configureSS->assign('searchFields', $this->currentSearchFields);
return $this->configureSS->fetch($this->configureTpl);
}
}
?>