459 lines
21 KiB
PHP
459 lines
21 KiB
PHP
|
|
<?php
|
||
|
|
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||
|
|
/*********************************************************************************
|
||
|
|
* SugarCRM is a customer relationship management program developed by
|
||
|
|
* SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.
|
||
|
|
*
|
||
|
|
* This program is free software; you can redistribute it and/or modify it under
|
||
|
|
* the terms of the GNU General Public License version 3 as published by the
|
||
|
|
* Free Software Foundation with the addition of the following permission added
|
||
|
|
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||
|
|
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||
|
|
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||
|
|
*
|
||
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||
|
|
* details.
|
||
|
|
*
|
||
|
|
* You should have received a copy of the GNU General Public License along with
|
||
|
|
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||
|
|
* 02110-1301 USA.
|
||
|
|
*
|
||
|
|
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||
|
|
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||
|
|
*
|
||
|
|
* The interactive user interfaces in modified source and object code versions
|
||
|
|
* of this program must display Appropriate Legal Notices, as required under
|
||
|
|
* Section 5 of the GNU General Public License version 3.
|
||
|
|
*
|
||
|
|
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||
|
|
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||
|
|
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||
|
|
* technical reasons, the Appropriate Legal Notices must display the words
|
||
|
|
* "Powered by SugarCRM".
|
||
|
|
********************************************************************************/
|
||
|
|
|
||
|
|
require_once('include/Dashlets/Dashlet.php');
|
||
|
|
require_once('include/Sugar_Smarty.php');
|
||
|
|
|
||
|
|
class MyEcmCallsMoreDashlets extends Dashlet {
|
||
|
|
|
||
|
|
var $height = '200';
|
||
|
|
var $user=array();
|
||
|
|
|
||
|
|
function MyEcmCallsMoreDashlets($id, $def) {
|
||
|
|
$this->loadLanguage('MyEcmCallsMoreDashlets');
|
||
|
|
|
||
|
|
if(!empty($def['height']))
|
||
|
|
$this->height = $def['height'];
|
||
|
|
|
||
|
|
$this->user = $def['user'];
|
||
|
|
if($def['date'])$this->date = $GLOBALS['timedate']->to_display_date($def['date']);
|
||
|
|
else $this->date=$GLOBALS['timedate']->to_display_date(date("Y-m-d"));
|
||
|
|
if(count($this->user)==0){
|
||
|
|
$w=$GLOBALS['db']->query("select id from users where deleted='0' and status='Active' and phone_work!=''");
|
||
|
|
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||
|
|
$this->user[]=$r['id'];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
parent::Dashlet($id); // call parent constructor
|
||
|
|
|
||
|
|
$this->isConfigurable = true; // dashlet is configurable
|
||
|
|
$this->hasScript = true; // dashlet has javascript attached to it
|
||
|
|
|
||
|
|
// if no custom title, use default
|
||
|
|
if(empty($def['title'])) $this->title = $this->dashletStrings['LBL_TITLE'];
|
||
|
|
else $this->title = $def['title'];
|
||
|
|
}
|
||
|
|
|
||
|
|
function display() {
|
||
|
|
$ss = new Sugar_Smarty();
|
||
|
|
$ss->assign('savedText', $this->savedText);
|
||
|
|
$ss->assign('saving', $this->dashletStrings['LBL_SAVING']);
|
||
|
|
$ss->assign('saved', $this->dashletStrings['LBL_SAVED']);
|
||
|
|
$ss->assign('id', $this->id);
|
||
|
|
$ss->assign('height', $this->height);
|
||
|
|
|
||
|
|
$str='';
|
||
|
|
|
||
|
|
//echo $this->date;
|
||
|
|
$exp=explode("-",$GLOBALS['timedate']->to_db_date($this->date));
|
||
|
|
//echo $GLOBALS['timedate']->to_db_date($this->date)."mm";
|
||
|
|
$dm=$exp[1];
|
||
|
|
$dd=$exp[2];
|
||
|
|
$dy=$exp[0];
|
||
|
|
|
||
|
|
$trd=array(
|
||
|
|
6=>0,
|
||
|
|
0=>1,
|
||
|
|
1=>2,
|
||
|
|
2=>3,
|
||
|
|
3=>4,
|
||
|
|
4=>5,
|
||
|
|
5=>6,
|
||
|
|
);
|
||
|
|
|
||
|
|
//echo "<br>".$dy." ".$dm." ".$dd;
|
||
|
|
|
||
|
|
$no_actual_day=date("w",mktime(0,0,0,$dm,$dd,$dy));
|
||
|
|
//echo $no_actual_day;
|
||
|
|
$date_first=date("Y-m-d",mktime(0,0,0,$dm,$dd,$dy)-($no_actual_day)*(3600*24)+3600*24);
|
||
|
|
//echo $date_first;
|
||
|
|
$expl=explode("-",$date_first);
|
||
|
|
$ds=array(0,1,2,3,4);
|
||
|
|
|
||
|
|
$m=0;
|
||
|
|
foreach($ds as $dss){
|
||
|
|
$days[$m]=date("Y-m-d",mktime(0,0,0,$expl[1],$expl[2],$expl[0])+$m*3600*24);
|
||
|
|
$m++;
|
||
|
|
}
|
||
|
|
//print_r($days);
|
||
|
|
/*
|
||
|
|
$days[$no_actual_day]=$GLOBALS['timedate']->to_db_date($this->date);
|
||
|
|
//echo $this->date;die();
|
||
|
|
if($no_actual_day>0){
|
||
|
|
for($i=0;$i<$no_actual_day;$i++){
|
||
|
|
$days[$i]=date("Y-m-d",mktime(0,0,0,$dm,$dd,$dy)-($i+1)*(3600*24));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
for($i=$no_actual_day+1;$i<=6;$i++){
|
||
|
|
$days[$i]=date("Y-m-d",mktime(0,0,0,$dm,$dd,$dy)+($i-$no_actual_day)*(3600*24));
|
||
|
|
}*/
|
||
|
|
//$this->user=array("178770a9-cd31-9f5e-6ee4-4acb40f6381c","dbf183f4-70da-2e17-1745-4acb40d0294b");
|
||
|
|
if(count($this->user)>0){
|
||
|
|
foreach($this->user as $u){
|
||
|
|
foreach($days as $ddd){
|
||
|
|
$w=$GLOBALS['db']->query("select * from ecmcallsphones where bean_id='".$u."'");
|
||
|
|
while($r=$GLOBALS['db']->fetchByAssoc($w)){
|
||
|
|
|
||
|
|
/*$p[$r['bean_id'][$ddd]]['busy']=mysql_num_rows($GLOBALS['db']->query("select id from cdr where disposition='BUSY' and src='".$r['phone']."' and (calldate like '".$ddd."%')"));
|
||
|
|
$ww=$GLOBALS['db']->query("select duration from cdr where disposition='BUSY' and src='".$r['phone']."' and (calldate like '".$ddd."%')");
|
||
|
|
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
|
||
|
|
$p[$r['bean_id']][$ddd]['busy_duration']+=$rr['duration'];
|
||
|
|
}*/
|
||
|
|
$p[$r['bean_id']][$ddd]['answered_up_60']=mysql_num_rows($GLOBALS['db']->query("select id from cdr where disposition like 'ANSWERED' and deleted='0' and duration>60 and src='".$r['phone']."' and (calldate like '".$ddd."%')"));
|
||
|
|
$ww=$GLOBALS['db']->query("select duration,dst from cdr where disposition='ANSWERED' and deleted='0' and duration>60 and src='".$r['phone']."' and (calldate like '".$ddd."%')");
|
||
|
|
$temp=array();
|
||
|
|
$dttt=0;
|
||
|
|
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
|
||
|
|
$p[$r['bean_id']][$ddd]['answered_up_60_duration']+=$rr['duration'];
|
||
|
|
$temp[$rr['dst']]+=$rr['duration'];
|
||
|
|
}
|
||
|
|
$p[$r['bean_id']][$ddd]['answered_up_60_distinct']=count($temp);
|
||
|
|
foreach($temp as $tte)$dttt+=$tte;
|
||
|
|
$p[$r['bean_id']][$ddd]['answered_up_60_distinct_duration']=$dttt;
|
||
|
|
|
||
|
|
$temp_cnt=0;
|
||
|
|
$dur_tt=0;
|
||
|
|
if(count($temp)>0){
|
||
|
|
foreach($temp as $temp_key=>$temp_value){
|
||
|
|
$www=$GLOBALS['db']->query("select dst,duration from cdr where disposition='ANSWERED' and deleted='0' and duration>60 and src='".$r['phone']."' and dst='".$temp_key."' and calldate like '".$ddd."%'");
|
||
|
|
if(mysql_num_rows($GLOBALS['db']->query("select dst,duration from cdr where disposition='ANSWERED' and deleted='0' and duration>60 and src='".$r['phone']."' and dst='".$temp_key."' and calldate<'".$ddd."'"))==0){
|
||
|
|
$temp_cnt++;
|
||
|
|
}
|
||
|
|
while($rrr=$GLOBALS['db']->fetchByAssoc($www))$dur_tt+=$rrr['duration'];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
$p[$r['bean_id']][$ddd]['answered_up_60_new']=$temp_cnt;
|
||
|
|
$p[$r['bean_id']][$ddd]['answered_up_60_new_duration']=$dur_tt;
|
||
|
|
|
||
|
|
$p[$r['bean_id']][$ddd]['failed']=mysql_num_rows($GLOBALS['db']->query("select id from cdr where disposition like 'ANSWERED' and deleted='0' and duration<=60 and src='".$r['phone']."' and (calldate like '".$ddd."%')"));
|
||
|
|
$ww=$GLOBALS['db']->query("select duration,dst from cdr where disposition like 'ANSWERED' and deleted='0' and duration<=60 and src='".$r['phone']."' and (calldate like '".$ddd."%')");
|
||
|
|
$temp=array();
|
||
|
|
$dttt=0;
|
||
|
|
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
|
||
|
|
$p[$r['bean_id']][$ddd]['failed_duration']+=$rr['duration'];
|
||
|
|
$temp[$rr['dst']]+=$rr['duration'];
|
||
|
|
}
|
||
|
|
$p[$r['bean_id']][$ddd]['failed_distinct']=count($temp);
|
||
|
|
foreach($temp as $tte)$dttt+=$tte;
|
||
|
|
$p[$r['bean_id']][$ddd]['failed_distinct_duration']=$dttt;
|
||
|
|
|
||
|
|
$temp_cnt=0;
|
||
|
|
$dur_tt=0;
|
||
|
|
if(count($temp)>0){
|
||
|
|
foreach($temp as $temp_key=>$temp_value){
|
||
|
|
$www=$GLOBALS['db']->query("select dst,duration from cdr where disposition like 'ANSWERED' and deleted='0' and duration<=60 and src='".$r['phone']."' and dst='".$temp_key."' and calldate like '".$ddd."%'");
|
||
|
|
if(mysql_num_rows($GLOBALS['db']->query("select dst,duration from cdr where disposition like 'ANSWERED' and deleted='0' and duration<=60 and src='".$r['phone']."' and dst='".$temp_key."' and calldate<'".$ddd."'"))==0){
|
||
|
|
$temp_cnt++;
|
||
|
|
}
|
||
|
|
while($rrr=$GLOBALS['db']->fetchByAssoc($www))$dur_tt+=$rrr['duration'];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
$p[$r['bean_id']][$ddd]['failed_new']=$temp_cnt;
|
||
|
|
$p[$r['bean_id']][$ddd]['failed_new_duration']=$dur_tt;
|
||
|
|
/*echo '<pre>';
|
||
|
|
print_r($p[$r['bean_id']]);
|
||
|
|
echo '</pre>';
|
||
|
|
$p[$r['bean_id']][$ddd]['failed']=mysql_num_rows($GLOBALS['db']->query("select id from cdr where disposition='FAILED' and src='".$r['phone']."' and (calldate like '".$ddd."%')"));
|
||
|
|
$ww=$GLOBALS['db']->query("select duration from cdr where disposition='FAILED' and src='".$r['phone']."' and (calldate like '".$ddd."%')");
|
||
|
|
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
|
||
|
|
$p[$r['bean_id']][$ddd]['failed_duration']+=$rr['duration'];
|
||
|
|
}
|
||
|
|
$p[$r['bean_id']][$ddd]['no_answer']=mysql_num_rows($GLOBALS['db']->query("select id from cdr where disposition='NO ANSWER' and src='".$r['phone']."' and (calldate like '".$ddd."%')"));
|
||
|
|
$ww=$GLOBALS['db']->query("select duration from cdr where disposition='NO ANSWER' and src='".$r['phone']."' and (calldate like '".$ddd."%')");
|
||
|
|
while($rr=$GLOBALS['db']->fetchByAssoc($ww)){
|
||
|
|
$p[$r['bean_id']][$ddd]['no_answer_duration']+=$rr['duration'];
|
||
|
|
}*/
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
$days=$this->multisort($days,array(array('key'=>0,'sort'=>'asc')));
|
||
|
|
//echo '<pre>';
|
||
|
|
//print_r($p);
|
||
|
|
//echo '</pre>';
|
||
|
|
$str.='<div style="border: 1px solid #cccccc;min-width:500px;max-width:700px;overflow:auto">';
|
||
|
|
$str.='<table cellspacing="0" cellpadding="0" border="0" width="100%">';
|
||
|
|
$str.='<tr class="listViewThLinkS1" align="center" valign="top">';
|
||
|
|
$str.='<td> </td>';
|
||
|
|
for($i=0;$i<count($days);$i++){
|
||
|
|
$str.='<td colspan="3" style="border: 1px solid #cccccc"><b>'.$GLOBALS['timedate']->to_display_date($days[$i]).'</b></td>';
|
||
|
|
}
|
||
|
|
$str.='<td colspan="3" style="border: 1px solid #cccccc"><b>Summary</b></td>';
|
||
|
|
$str.'</tr>';
|
||
|
|
$str.='<tr class="listViewThLinkS1" align="center" valign="top">';
|
||
|
|
$str.='<td class="listViewThS1"> </td>';
|
||
|
|
for($i=0;$i<=count($days);$i++){
|
||
|
|
$str.='<td colspan="2" align="center" style="text-align: center;" class="listViewThS1"><img src="modules/Home/Dashlets/MyEcmCallsMoreDashlets/blue.png" border="0" /></td>';
|
||
|
|
//$str.='<td class="listViewThS1">>60 (h:m)</td>';
|
||
|
|
$str.='<td class="listViewThS1"><img src="modules/Home/Dashlets/MyEcmCallsMoreDashlets/red.png" border="0" /></td>';
|
||
|
|
}
|
||
|
|
$str.='</tr>';
|
||
|
|
$type_arr=array("answered_up_60","failed");
|
||
|
|
$type_arr_distinct=array("answered_up_60_distinct","failed_distinct");
|
||
|
|
if(count($p)>0){
|
||
|
|
foreach($p as $k=>$v){
|
||
|
|
$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select first_name,last_name,phone_work from users where id='".$k."'"));
|
||
|
|
if($k){
|
||
|
|
$str.='<tr align="center" valign="top">';
|
||
|
|
$str.='<td style="width:60px;padding:2px;border-bottom: 1px solid #cccccc;">'.$r['first_name'].' '.$r['last_name'].' ('.$r['phone_work'].')</td>';
|
||
|
|
foreach($v as $kk=>$vv){
|
||
|
|
foreach($type_arr as $ta){
|
||
|
|
if($ta=="answered_up_60")$sty="border-left: 1px solid #cccccc";
|
||
|
|
else $sty="";
|
||
|
|
if($vv[$ta])$str.='<td style="'.$sty.';padding:2px;border-bottom: 1px solid #cccccc;">'.$vv[$ta].'<br><span alt="distinct" title="distinct">'.$vv[$ta.'_distinct'].'</span><br><span alt="new" title="new">'.$vv[$ta.'_new'].'</span></td>';
|
||
|
|
else $str.='<td style="'.$sty.';padding:2px;border-bottom: 1px solid #cccccc;">0<br><span alt="distinct" title="distinct">0</span><br><span alt="new" title="new">0</span></td>';
|
||
|
|
if($ta!="failed"){
|
||
|
|
if($vv[$ta.'_duration']){
|
||
|
|
$m=floor($vv[$ta.'_duration']/60);
|
||
|
|
$h=floor($vv[$ta.'_duration']/3600);
|
||
|
|
$m=$m-60*$h;
|
||
|
|
$m2=floor($vv[$ta.'_distinct_duration']/60);
|
||
|
|
$h2=floor($vv[$ta.'_distinct_duration']/3600);
|
||
|
|
$m2=$m2-60*$h2;
|
||
|
|
$m3=floor($vv[$ta.'_new_duration']/60);
|
||
|
|
$h3=floor($vv[$ta.'_new_duration']/3600);
|
||
|
|
$m3=$m3-60*$h3;
|
||
|
|
$str.='<td style="padding:2px;border-bottom: 1px solid #cccccc;">'.$h.'h '.$m.'m</td>';
|
||
|
|
}
|
||
|
|
else $str.='<td style="padding:2px;border-bottom: 1px solid #cccccc;">0h 0m</td>';
|
||
|
|
}
|
||
|
|
$all[$k][$ta]+=$vv[$ta];
|
||
|
|
$all[$k][$ta."_distinct"]+=$vv[$ta."_distinct"];
|
||
|
|
$all[$k][$ta."_new"]+=$vv[$ta."_new"];
|
||
|
|
if($ta!="failed")$all[$k][$ta.'_duration']+=$vv[$ta.'_duration'];
|
||
|
|
if($ta!="failed")$all[$k][$ta.'_distinct_duration']+=$vv[$ta.'_distinct_duration'];
|
||
|
|
if($ta!="failed")$all[$k][$ta.'_new_duration']+=$vv[$ta.'_new_duration'];
|
||
|
|
$alla[$kk][$ta]+=$vv[$ta];
|
||
|
|
$alla[$kk][$ta."_distinct"]+=$vv[$ta."_distinct"];
|
||
|
|
$alla[$kk][$ta."_new"]+=$vv[$ta."_new"];
|
||
|
|
if($ta!="failed")$alla[$kk][$ta.'_duration']+=$vv[$ta.'_duration'];
|
||
|
|
if($ta!="failed")$alla[$kk][$ta.'_distinct_duration']+=$vv[$ta.'_distinct_duration'];
|
||
|
|
if($ta!="failed")$alla[$kk][$ta.'_new_duration']+=$vv[$ta.'_new_duration'];
|
||
|
|
$allaa[$ta]+=$vv[$ta];
|
||
|
|
$allaa[$ta."_distinct"]+=$vv[$ta."_distinct"];
|
||
|
|
$allaa[$ta."_new"]+=$vv[$ta."_new"];
|
||
|
|
if($ta!="failed")$allaa[$ta.'_duration']+=$vv[$ta.'_duration'];
|
||
|
|
if($ta!="failed")$allaa[$ta.'_distinct_duration']+=$vv[$ta.'_distinct_duration'];
|
||
|
|
if($ta!="failed")$allaa[$ta.'_new_duration']+=$vv[$ta.'_new_duration'];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
foreach($type_arr as $ta){
|
||
|
|
if($ta=="answered_up_60")$sty="border-left: 1px solid #cccccc";
|
||
|
|
else $sty="";
|
||
|
|
if($all[$k][$ta])$str.='<td style="'.$sty.';padding:2px;border-bottom: 1px solid #cccccc;"><b>'.$all[$k][$ta].'<br><span alt="distinct" title="distinct">'.$all[$k][$ta."_distinct"].'</span><br><span alt="new" title="new">'.$all[$k][$ta."_new"].'</span></b></td>';
|
||
|
|
else $str.='<td style="'.$sty.';padding:2px;border-bottom: 1px solid #cccccc;"><b>0<br><span alt="distinct" title="distinct">0</span><br><span alt="new" title="new">0</span></b></td>';
|
||
|
|
if($ta!="failed"){
|
||
|
|
if($all[$k][$ta.'_duration']){
|
||
|
|
$m=floor($all[$k][$ta.'_duration']/60);
|
||
|
|
$h=floor($all[$k][$ta.'_duration']/3600);
|
||
|
|
$m=$m-60*$h;
|
||
|
|
$m2=floor($all[$k][$ta.'_distinct_duration']/60);
|
||
|
|
$h2=floor($all[$k][$ta.'_distinct_duration']/3600);
|
||
|
|
$m2=$m2-60*$h2;
|
||
|
|
$m3=floor($all[$k][$ta.'_new_duration']/60);
|
||
|
|
$h3=floor($all[$k][$ta.'_new_duration']/3600);
|
||
|
|
$m3=$m3-60*$h3;
|
||
|
|
$str.='<td style="padding:2px;border-bottom: 1px solid #cccccc;"><b>'.$h.'h '.$m.'m</b></td>';
|
||
|
|
}
|
||
|
|
else $str.='<td style="padding:2px;border-bottom: 1px solid #cccccc;"><b>0h 0m</b></td>';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
$str.='</tr>';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
$str.='<tr align="center" valign="top"><td><b>Summary</b></td>';
|
||
|
|
if(count($alla)>0){
|
||
|
|
foreach($alla as $al){
|
||
|
|
foreach($type_arr as $ta){
|
||
|
|
if($ta=="answered_up_60")$sty="border-left: 1px solid #cccccc";
|
||
|
|
else $sty="";
|
||
|
|
if($al[$ta])$str.='<td style="'.$sty.';padding:2px;border-bottom: 1px solid #cccccc;"><b>'.$al[$ta].'<br><span alt="distinct" title="distinct">'.$al[$ta."_distinct"].'</span><br><span alt="new" title="new">'.$al[$ta."_new"].'</span></b></td>';
|
||
|
|
else $str.='<td style="'.$sty.';padding:2px;border-bottom: 1px solid #cccccc;"><b>0<br><span alt="distinct" title="distinct">0</span><br><span alt="new" title="new">0</span></b></td>';
|
||
|
|
if($ta=="failed")continue;
|
||
|
|
if($al[$ta.'_duration']){
|
||
|
|
$m=floor($al[$ta.'_duration']/60);
|
||
|
|
$h=floor($al[$ta.'_duration']/3600);
|
||
|
|
$m=$m-60*$h;
|
||
|
|
$m2=floor($al[$ta.'_distinct_duration']/60);
|
||
|
|
$h2=floor($al[$ta.'_distinct_duration']/3600);
|
||
|
|
$m2=$m2-60*$h2;
|
||
|
|
$m3=floor($al[$ta.'_new_duration']/60);
|
||
|
|
$h3=floor($al[$ta.'_new_duration']/3600);
|
||
|
|
$m3=$m3-60*$h3;
|
||
|
|
$str.='<td style="padding:2px;border-bottom: 1px solid #cccccc;"><b>'.$h.'h '.$m.'m</b></td>';
|
||
|
|
}
|
||
|
|
else $str.='<td style="padding:2px;border-bottom: 1px solid #cccccc;"><b>0h 0m</b></td>';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
foreach($type_arr as $ta){
|
||
|
|
if($ta=="answered_up_60")$sty="border-left: 1px solid #cccccc";
|
||
|
|
else $sty="";
|
||
|
|
if($allaa[$ta])$str.='<td style="'.$sty.';padding:2px;border-bottom: 1px solid #cccccc;"><b>'.$allaa[$ta].'<br><span alt="distinct" title="distinct">'.$allaa[$ta."_distinct"].'</span><br><span alt="new" title="new">'.$allaa[$ta."_new"].'</span></b></td>';
|
||
|
|
else $str.='<td style="'.$sty.';padding:2px;border-bottom: 1px solid #cccccc;"><b>0<br><span alt="distinct" title="distinct">0</span><br><span alt="new" title="new">0</span></b></td>';
|
||
|
|
if($ta=="failed")continue;
|
||
|
|
if($allaa[$ta.'_duration']){
|
||
|
|
$m=floor($allaa[$ta.'_duration']/60);
|
||
|
|
$h=floor($allaa[$ta.'_duration']/3600);
|
||
|
|
$m=$m-60*$h;
|
||
|
|
$m2=floor($allaa[$ta.'_distinct_duration']/60);
|
||
|
|
$h2=floor($allaa[$ta.'_distinct_duration']/3600);
|
||
|
|
$m2=$m2-60*$h2;
|
||
|
|
$m3=floor($allaa[$ta.'_new_duration']/60);
|
||
|
|
$h3=floor($allaa[$ta.'_new_duration']/3600);
|
||
|
|
$m3=$m3-60*$h3;
|
||
|
|
$str.='<td style="padding:2px;border-bottom: 1px solid #cccccc;"><b>'.$h.'h '.$m.'m</b></td>';
|
||
|
|
}
|
||
|
|
else $str.='<td style="padding:2px;border-bottom: 1px solid #cccccc;"><b>0h 0m</b></td>';
|
||
|
|
}
|
||
|
|
$str.='</tr>';
|
||
|
|
$str.='</table>';
|
||
|
|
$str.='</div>';
|
||
|
|
return parent::display("") . $str . '<br />'; // return parent::display for title and such
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Displays the javascript for the dashlet
|
||
|
|
*
|
||
|
|
* @return string javascript to use with this dashlet
|
||
|
|
*/
|
||
|
|
|
||
|
|
function multisort($data,$keys)
|
||
|
|
{
|
||
|
|
if(count($data)>0)
|
||
|
|
{
|
||
|
|
foreach($data as $key => $row)
|
||
|
|
{
|
||
|
|
foreach($keys as $k)
|
||
|
|
{
|
||
|
|
$cols[$k['key']][$key] = $row[$k['key']];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
$idkeys=@array_keys($data);
|
||
|
|
$i=0;
|
||
|
|
foreach($keys as $k)
|
||
|
|
{
|
||
|
|
if($i>0)$sort.=',';
|
||
|
|
$sort.='$cols['.$k['key'].']';
|
||
|
|
if($k['sort'])$sort.=',SORT_'.strtoupper($k['sort']);
|
||
|
|
if($k['type'])$sort.=',SORT_'.strtoupper($k['type']);
|
||
|
|
$i++;
|
||
|
|
}
|
||
|
|
$sort.=',$idkeys';
|
||
|
|
$sort='@array_multisort('.$sort.');';
|
||
|
|
eval($sort);
|
||
|
|
foreach($idkeys as $idkey)
|
||
|
|
{
|
||
|
|
$result[$idkey]=$data[$idkey];
|
||
|
|
}
|
||
|
|
return $result;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
function displayScript() {
|
||
|
|
$ss = new Sugar_Smarty();
|
||
|
|
$ss->assign('saving', $this->dashletStrings['LBL_SAVING']);
|
||
|
|
$ss->assign('saved', $this->dashletStrings['LBL_SAVED']);
|
||
|
|
$ss->assign('id', $this->id);
|
||
|
|
|
||
|
|
$str = $ss->fetch('modules/Home/Dashlets/MyEcmCallsMoreDashlets/MyEcmCallsMoreDashletsScript.tpl');
|
||
|
|
return $str; // return parent::display for title and such
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Displays the configuration form for the dashlet
|
||
|
|
*
|
||
|
|
* @return string html to display form
|
||
|
|
*/
|
||
|
|
function displayOptions() {
|
||
|
|
global $app_strings;
|
||
|
|
|
||
|
|
$ss = new Sugar_Smarty();
|
||
|
|
|
||
|
|
$ua='<option value="All"';
|
||
|
|
if($this->user[0]=='All' || $this->user[0]=='')$ua.=' selected';
|
||
|
|
$ua.='>All</option>';
|
||
|
|
$w=$GLOBALS['db']->query("select first_name,last_name,id from users where deleted='0' and status='Active' and phone_work!='' order by user_name asc");
|
||
|
|
while($r=$GLOBALS['db']->fetchByAssoc($w))
|
||
|
|
{
|
||
|
|
$ua.='<option value="'.$r['id'].'"';
|
||
|
|
if(is_array($this->user)){
|
||
|
|
if(in_array($r['id'],$this->user)){
|
||
|
|
$ua.=' selected';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
$ua.='>'.$r['first_name'].' '.$r['last_name'].'</option>';
|
||
|
|
}
|
||
|
|
$ss->assign('user_options', $ua);
|
||
|
|
$ss->assign('date', $this->date);
|
||
|
|
|
||
|
|
$ss->assign('titleLbl', $this->dashletStrings['LBL_CONFIGURE_TITLE']);
|
||
|
|
$ss->assign('statusLbl', $this->dashletStrings['LBL_CONFIGURE_STATUS']);
|
||
|
|
$ss->assign('userLbl', $this->dashletStrings['LBL_CONFIGURE_USER']);
|
||
|
|
$ss->assign('typeLbl', $this->dashletStrings['LBL_CONFIGURE_TYPE']);
|
||
|
|
$ss->assign('saveLbl', $app_strings['LBL_SAVE_BUTTON_LABEL']);
|
||
|
|
$ss->assign('title', $this->title);
|
||
|
|
$ss->assign('height', $this->height);
|
||
|
|
$arr=array("d","m","Y","y");
|
||
|
|
$arrp=array("%d","%m","%Y","%y");
|
||
|
|
$ss->assign('format', str_replace($arr,$arrp,$GLOBALS['timedate']->get_date_format()));
|
||
|
|
$ss->assign('id', $this->id);
|
||
|
|
|
||
|
|
return parent::displayOptions() . $ss->fetch('modules/Home/Dashlets/MyEcmCallsMoreDashlets/MyEcmCallsMoreDashleOptions.tpl');
|
||
|
|
}
|
||
|
|
function saveOptions($req) {
|
||
|
|
global $sugar_config, $timedate, $current_user, $theme;
|
||
|
|
$options = array();
|
||
|
|
$options['title'] = $_REQUEST['title'];
|
||
|
|
$options['user'] = $_REQUEST['user'];
|
||
|
|
$exp=explode("-",$GLOBALS['timedate']->to_db_date($_REQUEST['date']));
|
||
|
|
$options['date'] = date("Y-m-d",mktime(0,0,0,$exp[1],$exp[2],$exp[0])+3600*24);
|
||
|
|
|
||
|
|
if(is_numeric($_REQUEST['height'])) {
|
||
|
|
if($_REQUEST['height'] > 0 && $_REQUEST['height'] <= 300) $options['height'] = $_REQUEST['height'];
|
||
|
|
elseif($_REQUEST['height'] > 300) $options['height'] = '300';
|
||
|
|
else $options['height'] = '100';
|
||
|
|
}
|
||
|
|
|
||
|
|
return $options;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
?>
|