Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Support Reports
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 23 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -45,7 +45,7 @@ class _reports extends \IPS\Dispatcher\Controller
|
||||
/* Tabs */
|
||||
$tabs = array(
|
||||
'overview' => 'overview',
|
||||
'replies' => 'replies',
|
||||
'replies' => 'latest_replies',
|
||||
'feedback_ratings' => 'feedback_ratings',
|
||||
'latest_feedback' => 'latest_feedback',
|
||||
);
|
||||
@@ -55,64 +55,81 @@ class _reports extends \IPS\Dispatcher\Controller
|
||||
/* Staff Productivity */
|
||||
if ( $activeTab === 'overview' )
|
||||
{
|
||||
/* Build table */
|
||||
$staffProductivityTable = new \IPS\Helpers\Table\Db(
|
||||
'nexus_support_replies',
|
||||
\IPS\Http\Url::internal( 'app=nexus&module=support&controller=reports&act=productivity_table' ),
|
||||
array(
|
||||
array( 'reply_type=?', \IPS\nexus\Support\Reply::REPLY_STAFF ),
|
||||
\IPS\Db::i()->in( 'reply_member', array_keys( \IPS\nexus\Support\Request::staff() ) )
|
||||
),
|
||||
'reply_member'
|
||||
/* Filters */
|
||||
$filters = array(
|
||||
'last_24_hours' => \IPS\DateTime::create()->sub( new \DateInterval( 'P1D' ) )->getTimestamp(),
|
||||
'last_7_days' => \IPS\DateTime::create()->sub( new \DateInterval( 'P7D' ) )->getTimestamp(),
|
||||
'last_30_days' => \IPS\DateTime::create()->sub( new \DateInterval( 'P30D' ) )->getTimestamp(),
|
||||
);
|
||||
|
||||
/* Set default values */
|
||||
$data = array();
|
||||
foreach ( \IPS\nexus\Support\Request::staff() as $staffId => $name )
|
||||
{
|
||||
$data[ $staffId ] = array( 'name' => $name, 'reply_count' => 0 );
|
||||
if ( \IPS\Settings::i()->nexus_support_satisfaction )
|
||||
{
|
||||
$data[ $staffId ]['rating_count'] = 0;
|
||||
$data[ $staffId ]['rating_average'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get their replies */
|
||||
$where = array( array( \IPS\Db::i()->in( 'reply_member', array_keys( $data ) ) ) );
|
||||
if ( isset( \IPS\Request::i()->filter ) and array_key_exists( \IPS\Request::i()->filter, $filters ) )
|
||||
{
|
||||
$where[] = array( 'reply_date>?', $filters[ \IPS\Request::i()->filter ] );
|
||||
}
|
||||
foreach ( \IPS\Db::i()->select( 'COUNT(*) AS count, reply_member', 'nexus_support_replies', $where, NULL, NULL, 'reply_member' ) as $row )
|
||||
{
|
||||
$data[ $row['reply_member'] ]['reply_count'] = $row['count'];
|
||||
}
|
||||
|
||||
/* And their ratings */
|
||||
if ( \IPS\Settings::i()->nexus_support_satisfaction )
|
||||
{
|
||||
$where = array( \IPS\Db::i()->in( 'rating_staff', array_keys( $data ) ) );
|
||||
if ( isset( \IPS\Request::i()->filter ) and array_key_exists( \IPS\Request::i()->filter, $filters ) )
|
||||
{
|
||||
$where[] = array( 'rating_date>?', $filters[ \IPS\Request::i()->filter ] );
|
||||
}
|
||||
foreach ( \IPS\Db::i()->select( 'COUNT(*) AS count, AVG(rating_rating) AS rating, rating_staff', 'nexus_support_ratings', $where, NULL, NULL, 'rating_staff' ) as $row )
|
||||
{
|
||||
$data[ $row['rating_staff'] ]['rating_count'] = $row['count'];
|
||||
$data[ $row['rating_staff'] ]['rating_average'] = $row['rating'];
|
||||
}
|
||||
}
|
||||
|
||||
/* Build the table */
|
||||
$staffProductivityTable = new \IPS\Helpers\Table\Custom( $data, \IPS\Http\Url::internal( 'app=nexus&module=support&controller=reports&tab=overview' ) );
|
||||
$staffProductivityTable->langPrefix = 'staff_';
|
||||
$staffProductivityTable->selects = array( 'COUNT(*) AS reply_count' );
|
||||
$staffProductivityTable->include = array( 'name', 'reply_count' );
|
||||
$staffProductivityTable->widths = array( 'name' => 75, 'reply_count' => 25 );
|
||||
$staffProductivityTable->parsers['reply_count'] = function( $val ) { return intval( $val ); };
|
||||
$staffProductivityTable->widths = \IPS\Settings::i()->nexus_support_satisfaction ? array( 'name' => 50, 'reply_count' => 25, 'rating_average' => 25 ) : array( 'name' => 75, 'reply_count' => 25 );
|
||||
if ( \IPS\Settings::i()->nexus_support_satisfaction )
|
||||
{
|
||||
$staffProductivityTable->joins[] = array(
|
||||
'select' => 'rating_count, rating_average',
|
||||
'from' => \IPS\Db::i()->select( 'rating_reply, COUNT(*) AS rating_count, AVG(rating_rating) AS rating_average', 'nexus_support_ratings' ),
|
||||
'where' => 'rating_reply=reply_id'
|
||||
);
|
||||
|
||||
$staffProductivityTable->include[] = 'rating_average';
|
||||
$staffProductivityTable->widths = array( 'name' => 50, 'reply_count' => 25, 'rating_average' => 25 );
|
||||
$staffProductivityTable->parsers['rating_average'] = function( $val, $row ) {
|
||||
return \IPS\Theme::i()->getTemplate('supportreports')->averageRatingCell( $val, $row['rating_count'] );
|
||||
};
|
||||
$staffProductivityTable->include = array( 'name', 'reply_count', 'rating_average' );
|
||||
}
|
||||
$staffProductivityTable->sortBy = $staffProductivityTable->sortBy ?: 'reply_count';
|
||||
|
||||
/* We need to join the members table for the name */
|
||||
$staffProductivityTable->joins[] = array(
|
||||
'select' => 'name',
|
||||
'from' => 'core_members',
|
||||
'where' => 'member_id=reply_member'
|
||||
);
|
||||
$staffProductivityTable->quickSearch = 'name';
|
||||
|
||||
|
||||
/* Specify the filters and search options */
|
||||
$staffProductivityTable->filters = array(
|
||||
'last_24_hours' => array( 'reply_date>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P1D' ) )->getTimestamp() ),
|
||||
'last_7_days' => array( 'reply_date>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P7D' ) )->getTimestamp() ),
|
||||
'last_30_days' => array( 'reply_date>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P30D' ) )->getTimestamp() ),
|
||||
);
|
||||
$staffProductivityTable->filters = $filters;
|
||||
|
||||
/* Buttons for each member */
|
||||
$staffProductivityTable->rowButtons = function( $row )
|
||||
$staffProductivityTable->rowButtons = function( $row, $id )
|
||||
{
|
||||
return array(
|
||||
'report' => array(
|
||||
'icon' => 'search',
|
||||
'title' => 'view_report',
|
||||
'link' => \IPS\Http\Url::internal('app=nexus&module=support&controller=reports&do=staff')->setQueryString( 'id', $row['reply_member'] ),
|
||||
'link' => \IPS\Http\Url::internal('app=nexus&module=support&controller=reports&do=staff')->setQueryString( 'id', $id ),
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
/* Output */
|
||||
$activeTabContents = (string) $staffProductivityTable;
|
||||
}
|
||||
|
||||
@@ -122,6 +139,7 @@ class _reports extends \IPS\Dispatcher\Controller
|
||||
$staffRepliesChart = new \IPS\Helpers\Chart\Dynamic( \IPS\Http\Url::internal( 'app=nexus&module=support&controller=reports&tab=replies' ), 'nexus_support_replies', 'reply_date', '',
|
||||
array(
|
||||
'vAxis' => array( 'title' => \IPS\Member::loggedIn()->language()->addToStack('replies_made') ),
|
||||
'height' => 700
|
||||
),
|
||||
'LineChart', 'daily', array( 'start' => \IPS\DateTime::create()->sub( new \DateInterval( 'P1M' ) ), 'end' => 0 )
|
||||
);
|
||||
@@ -141,8 +159,9 @@ class _reports extends \IPS\Dispatcher\Controller
|
||||
$staffRatingsChart = new \IPS\Helpers\Chart\Dynamic( \IPS\Http\Url::internal( 'app=nexus&module=support&controller=reports&tab=feedback_ratings' ), 'nexus_support_ratings', 'rating_date', '',
|
||||
array(
|
||||
'vAxis' => array( 'title' => \IPS\Member::loggedIn()->language()->addToStack('average_rating'), 'viewWindow' => array( 'min' => 0, 'max' => 5 ) ),
|
||||
'height' => 700
|
||||
),
|
||||
'ColumnChart', 'monthly'
|
||||
'ColumnChart', 'monthly', array( 'start' => \IPS\DateTime::create()->sub( new \DateInterval( 'P1M' ) ), 'end' => \IPS\DateTime::create() )
|
||||
);
|
||||
$staffRatingsChart->plotZeros = FALSE;
|
||||
$staffRatingsChart->groupBy = 'rating_staff';
|
||||
@@ -253,19 +272,44 @@ class _reports extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Get average replies by hour for this staff member */
|
||||
$thisStaffMember = array();
|
||||
foreach( \IPS\Db::i()->select( "COUNT(*) AS count, reply_date AS unixtime, DATE_FORMAT( FROM_UNIXTIME( reply_date ), '{$group}' ) AS hour", 'nexus_support_replies', array_merge( $where, array( array( 'reply_member=?', $staff->member_id ) ) ), NULL, NULL, 'hour' ) as $row )
|
||||
{
|
||||
$thisStaffMemberCount = array();
|
||||
foreach( \IPS\Db::i()->select( "COUNT(*) AS count, reply_date AS unixtime, DATE_FORMAT( FROM_UNIXTIME( reply_date ), '{$group}' ) AS hour", 'nexus_support_replies', array_merge( $where, array( array( 'reply_member=?', $staff->member_id ) ) ), NULL, NULL, array( 'hour', 'reply_date' ) ) as $row )
|
||||
{
|
||||
$_group = $span === 'day' ? \IPS\DateTime::ts( $row['unixtime'] )->format('G') : \IPS\DateTime::ts( $row['unixtime'] )->format('w');
|
||||
$thisStaffMember[ $_group ] = round( ( $type === 'average' ) ? ( $row['count'] / $daysInTimeframe ) : $row['count'], 1 );
|
||||
|
||||
if ( !isset( $thisStaffMemberCount[ $_group ] ) )
|
||||
{
|
||||
$thisStaffMemberCount[ $_group ] = 0;
|
||||
}
|
||||
|
||||
$thisStaffMemberCount[ $_group ] = $thisStaffMemberCount[ $_group ] + $row['count'];
|
||||
}
|
||||
|
||||
foreach( $thisStaffMemberCount AS $_group => $count )
|
||||
{
|
||||
$thisStaffMember[ $_group ] = round( ( $type === 'average' ) ? ( $count / $daysInTimeframe ) : $count, 1 );
|
||||
}
|
||||
|
||||
/* Get average replies by hour for all staff members */
|
||||
if ( $numberOfStaffMembers > 1 )
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( "COUNT(*) AS count, reply_date AS unixtime, DATE_FORMAT( FROM_UNIXTIME( reply_date ), '{$group}' ) AS hour", 'nexus_support_replies', $where, NULL, NULL, 'hour' ) as $row )
|
||||
$allStaffMembers = array();
|
||||
$allStaffMembersCount = array();
|
||||
foreach( \IPS\Db::i()->select( "COUNT(*) AS count, reply_date AS unixtime, DATE_FORMAT( FROM_UNIXTIME( reply_date ), '{$group}' ) AS hour", 'nexus_support_replies', $where, NULL, NULL, array( 'hour', 'reply_date' ) ) as $row )
|
||||
{
|
||||
$_group = $span === 'day' ? \IPS\DateTime::ts( $row['unixtime'] )->format('G') : \IPS\DateTime::ts( $row['unixtime'] )->format('w');
|
||||
$allStaffMembers[ $_group ] = round( ( ( $type === 'average' ) ? ( $row['count'] / $daysInTimeframe ) : $row['count'] ) / $numberOfStaffMembers, 1 );
|
||||
|
||||
if ( !isset( $allStaffMembersCount[ $_group ] ) )
|
||||
{
|
||||
$allStaffMembersCount[ $_group ] = 0;
|
||||
}
|
||||
|
||||
$allStaffMembersCount[ $_group ] = $allStaffMembersCount[ $_group ] + $row['count'];
|
||||
}
|
||||
|
||||
foreach( $allStaffMembersCount AS $_group => $count )
|
||||
{
|
||||
$allStaffMembers[ $_group ] = round( ( ( $type === 'average' ) ? ( $count / $daysInTimeframe ) : $count ) / $numberOfStaffMembers, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user