Skip to content

Commit

Permalink
Merge pull request #11 from hemantpurohit1/TJReport_Backend_Changes_F…
Browse files Browse the repository at this point in the history
…or_Manager_Report

Tj report backend changes for manager report
  • Loading branch information
vaivk369 authored Jun 29, 2017
2 parents ffb7ac6 + d10f6ac commit 158b1ae
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 80 deletions.
33 changes: 30 additions & 3 deletions tjreports/administrator/assets/css/tjreports.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@


.other-filters{
padding: 0 14px;
}
}

.show-hide-cols
{
position:relative;
}

.ColVis_collection
{
list-style: none;
width: 150px;
padding: 8px 8px 4px 8px;
margin: 0;
border: 1px solid #ccc;
border: 1px solid rgba( 0, 0, 0, 0.4 );
background-color: #f3f3f3;
overflow: hidden;
display: block;
opacity: 1;
position: absolute;
}

.report-top-bar
{
margin-top:10px;
}

#report-table thead input {
margin-bottom: 0px;
}
6 changes: 3 additions & 3 deletions tjreports/administrator/tjreports.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
<filename>index.html</filename>
<filename>tjreports.php</filename>
<filename>controller.php</filename>
<filename>router.php</filename>
<folder>views</folder>
<folder>models</folder>
<folder>controllers</folder>
<folder>helpers</folder>
<folder>assets</folder>
</files>
<media destination="com_tjreports" folder="media">
<folder>js</folder>
Expand Down Expand Up @@ -72,8 +72,8 @@
</languages>
</administration>
<config>
<fields>
<fieldset >
<fields name="params">
<fieldset name="component">
<field name="save_history" default="0" />
</fieldset>
</fields>
Expand Down
55 changes: 17 additions & 38 deletions tjreports/administrator/views/reports/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
$mainframe = JFactory::getApplication();
$document = JFactory::getDocument();
$user = JFactory::getUser();
$user_id = $user->id;
$user = $this->user;
$user_id = $this->user_id;

JHtml::script(Juri::root().'/components/com_tjreports/assets/js/jquery.twbsPagination.js');
JHtml::script(Juri::root().'/components/com_tjreports/assets/js/tjreports.js');
JHtml::stylesheet(Juri::root().'administrator/components/com_tjreports/assets/css/tjreports.css');

$document->addScript(JURI::root().'/components/com_tjreports/assets/js/jquery.twbsPagination.js');
$document->addScript(JURI::root().'/components/com_tjreports/assets/js/tjreports.js');
$document->addScriptDeclaration('var site_root = "' . JUri::base() . '"');

$input = JFactory::getApplication()->input;
Expand Down Expand Up @@ -80,11 +82,11 @@
<?php echo JText::_('COM_TJREPORTS_NO_REPORT'); ?>
</div>
<?php else: ?>
<div class="show-hide-cols span6">

<div class="show-hide-cols span2">
<input type="button" id="show-hide-cols-btn" class="btn btn-success" onclick="getColNames(); return false;" value="<?php echo JText::_('COM_TJREPORTS_HIDE_SHOW_COL_BUTTON'); ?>"></button>
<ul id="ul-columns-name" class="ColVis_collection" style="display:none">


<?php if (!empty($this->colToshow)): ?>
<?php $this->colToshow = $this->colToshow ?>
<?php endif; ?>
Expand All @@ -110,10 +112,12 @@
</label>
</li>
<?php endforeach; ?>
<input type="checkbox" checked="checked" name="userType" id="userType" style="display:none">
</ul>
</div>

<?php if (!empty($this->saveQueriesList)): ?>
<div class="span2">
<div class="span3">
<?php echo JHtml::_('select.genericlist', $this->saveQueriesList, "filter_saveQuery", 'class="" size="1" onchange="getQueryResult(this.value);" name="filter_saveQuery"', "value", "text", $currentQuery);
?>
</div>
Expand All @@ -136,12 +140,14 @@
</div>
</div>

<div class="span3 pull-right">
<input type="text" name="queryName" placeholder="Title for the Query" class="pull-right" style="display:none" id="queryName" />
<input type="button" class="btn btn-primary pull-right" id="saveQuery" onclick="saveThisQuery();" value="<?php echo JText::_('COM_TJREPORTS_SAVE_THIS_QUERY'); ?>" />
<div class="span5 pull-right input-append">
<input type="text" name="queryName" placeholder="Title for the Query" style="display:none" id="queryName" />
<input type="button" class="btn btn-primary" id="saveQuery" onclick="saveThisQuery();" value="<?php echo JText::_('COM_TJREPORTS_SAVE_THIS_QUERY'); ?>" />
</div>


</div>
<div>
<button class="btn" type="button" title="Clear" onclick="window.location.reload();">Clear</button>
</div>

<?php if ($report == 'attemptreport'): ?>
Expand Down Expand Up @@ -266,30 +272,3 @@ function cleardate()
getFilterdata(-1, '', 'dateSearch');
}
</script>

<style>
.show-hide-cols
{
position:relative;
}

.ColVis_collection
{
list-style: none;
width: 150px;
padding: 8px 8px 4px 8px;
margin: 0;
border: 1px solid #ccc;
border: 1px solid rgba( 0, 0, 0, 0.4 );
background-color: #f3f3f3;
overflow: hidden;
display: block;
opacity: 1;
position: absolute;
}

.report-top-bar
{
margin-top:10px;
}
</style>
57 changes: 38 additions & 19 deletions tjreports/administrator/views/reports/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TjreportsViewReports extends JViewLegacy
protected $pagination;

protected $state;

protected $extension;

/**
Expand All @@ -46,21 +46,42 @@ class TjreportsViewReports extends JViewLegacy
*/
public function display($tpl = null)
{
$canDo = TjreportsHelpersTjreports::getActions();
$user = JFactory::getUser();
$user_id = $user->id;
$input = JFactory::getApplication()->input;
// Check for view report permission from respective extension e.g : com_tjlms
$reportsModel = $this->getModel();
$this->extension = $reportsModel->getState('extension');

$full_client = explode('.', $this->extension);

// Eg com_tjlms
$component = $full_client[0];
$eName = str_replace('com_', '', $component);
$file = JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component . '/helpers/' . $eName . '.php');

if (!$canDo->get('view.reports'))
if (file_exists($file))
{
JError::raiseError(500, JText::_('JERROR_ALERTNOAUTHOR'));
require_once $file;

$prefix = ucfirst(str_replace('com_', '', $component));
$cName = $prefix . 'Helper';

if (class_exists($cName))
{
$canDo = $cName::getActions();

return false;
if (!$canDo->get('view.reports'))
{
JError::raiseError(500, JText::_('JERROR_ALERTNOAUTHOR'));

return false;
}
}
}

$extension = JFactory::getApplication()->input->get('extension', '', 'word');
$this->user = JFactory::getUser();
$this->user_id = $this->user->id;
$input = JFactory::getApplication()->input;

if ($extension)
if ($this->extension)
{
TjreportsHelper::addSubmenu('reports');
$this->sidebar = JHtmlSidebar::render();
Expand All @@ -74,7 +95,7 @@ public function display($tpl = null)

if ($reportId)
{
$allow_permission = $user->authorise('core.viewall', 'com_tjreports.tjreport.' . $reportId);
$allow_permission = $this->user->authorise('core.viewall', 'com_tjreports.tjreport.' . $reportId);
$input->set('allow_permission', $allow_permission);
}

Expand All @@ -89,14 +110,14 @@ public function display($tpl = null)
$TjreportsModelReports = new TjreportsModelReports;

// Get saved queries by the logged in users
$this->saveQueries = $TjreportsModelReports->getSavedQueries($user_id, $reportToBuild);
$this->saveQueries = $TjreportsModelReports->getSavedQueries($this->user_id, $reportToBuild);

// Call helper function
$TjreportsHelper = new TjreportsHelpersTjreports;
$TjreportsHelper->getLanguageConstant();

// Get all enable plugins
$this->enableReportPlugins= $TjreportsModelReports->getenableReportPlugins();
$this->enableReportPlugins = $TjreportsModelReports->getenableReportPlugins();

$this->colToshow = array();

Expand Down Expand Up @@ -145,7 +166,7 @@ public function display($tpl = null)
protected function addToolbar()
{
// Old code
$extension = JFactory::getApplication()->input->get('extension', '', 'word');

$bar = JToolBar::getInstance('toolbar');
JToolBarHelper::title(JText::_('COM_TJREPORTS_TITLE_REPORT'), 'list');

Expand All @@ -154,13 +175,12 @@ protected function addToolbar()
class='icon-download'></span>" . JText::_('COM_TJREPORTS_CSV_EXPORT') . "</a>";
$bar->appendButton('Custom', $button);

// list of plugin

if($extension)
// List of plugin
if ($this->extension)
{
foreach ($this->enableReportPlugins as $eachPlugin) :
$button = "<a class='btn button report-btn' id='" . $eachPlugin->element . "'
onclick=\"loadReport('" . $eachPlugin->element . "','". $extension. "'); \" ><span
onclick=\"loadReport('" . $eachPlugin->element . "','" . $this->extension . "'); \" ><span
class='icon-list'></span>" . JText::_($eachPlugin->name) . "</a>";
$bar->appendButton('Custom', $button);
endforeach;
Expand Down Expand Up @@ -193,4 +213,3 @@ class='icon-list'></span>" . JText::_($eachPlugin->name) . "</a>";
*/
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,8 @@ COM_TJREPORTS_LAST_COMPLETED_ATTEMPT="Last completed attempt"
COM_TJREPORTS_FORM_OPT_COURSE_CERTIFICATE_TERM_NOCERTI="No Certificate"
COM_TJREPORTS_FORM_OPT_COURSE_CERTIFICATE_TERM_COMPALL="Complete all Lessons"
COM_TJREPORTS_FORM_OPT_COURSE_CERTIFICATE_TERM_PASSALL="Pass all Lessons"
COM_TJREPORTS_FORM_OPT_COURSE_CERTIFICATE_TERM_PASSALL="Pass all Lessons"
COM_TJREPORTS_NO_USER_REPORTING_MESSAGE="Currently no user is reporting to you"
COM_TJREPORTS_NOT_SUPER_USER_MESSAGE="You are not a super user"
COM_TJREPORTS_NOT_CREATED_COURSE_MESSAGE="You haven't created any course"
COM_TJREPORTS_NO_REPORT_FOUND="No report found"
49 changes: 33 additions & 16 deletions tjreports/site/views/reports/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,18 @@ class TjreportsViewReports extends JViewLegacy
public function display($tpl = null)
{
$canDo = TjreportsHelpersTjreports::getActions();
$user = JFactory::getUser();
$user_id = $user->id;
$this->user = JFactory::getUser();
$this->user_id = $this->user->id;
$input = JFactory::getApplication()->input;
$TjreportsModelReports = new TjreportsModelReports;
$app = JFactory::getApplication();
$mainframe = JFactory::getApplication();
$this->user->authorise('core.view', 'com_tjreports');
$this->user->authorise('core.viewall', 'com_tjreports');

$user->authorise('core.view', 'com_tjreports');
$user->authorise('core.viewall', 'com_tjreports');

if (!($user->authorise('core.view', 'com_tjreports') || $user->authorise('core.viewall', 'com_tjreports')))
if (!($this->user->authorise('core.view', 'com_tjreports') || $this->user->authorise('core.viewall', 'com_tjreports')))
{
if ($user->guest)
if ($this->user->guest)
{
$return = base64_encode(JUri::getInstance());
$login_url_with_return = JRoute::_('index.php?option=com_users&view=login&return=' . $return);
Expand All @@ -67,16 +66,34 @@ public function display($tpl = null)
}
}

/*
if (!$canDo->get('view.reports'))
$reportsModel = $this->getModel();
$client = $reportsModel->getState('client');
$full_client = explode(',', $client);

// Eg com_tjlms
$component = $full_client[0];
$eName = str_replace('com_', '', $component);
$file = JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $component . '/helpers/' . $eName . '.php');

if (file_exists($file))
{
JError::raiseError(500, JText::_('JERROR_ALERTNOAUTHOR'));
require_once $file;

return false;
}
*/
$prefix = ucfirst(str_replace('com_', '', $component));
$cName = $prefix . 'Helper';

$client = $input->get('client', '', 'STRING');
if (class_exists($cName))
{
$canDo = $cName::getActions();

if (!$canDo->get('view.reports'))
{
JError::raiseError(500, JText::_('JERROR_ALERTNOAUTHOR'));

return false;
}
}
}

// Get all vendars from backend
if (empty($client))
Expand All @@ -93,7 +110,7 @@ public function display($tpl = null)

$this->options = $this->get('reportoptions');

$this->isSuperUser = $user->authorise('core.viewall', 'com_tjreports');
$this->isSuperUser = $this->user->authorise('core.viewall', 'com_tjreports');

$user = JFactory::getUser();

Expand All @@ -114,7 +131,7 @@ public function display($tpl = null)

// Get saved queries by the logged in users

$this->saveQueries = $TjreportsModelReports->getSavedQueries($user_id, $reportToBuild);
$this->saveQueries = $TjreportsModelReports->getSavedQueries($this->user_id, $reportToBuild);

// Call helper function
$TjreportsHelper = new TjreportsHelpersTjreports;
Expand Down
1 change: 0 additions & 1 deletion tjreports/tjreports.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
<filename>index.html</filename>
<filename>tjreports.php</filename>
<filename>controller.php</filename>
<filename>router1.php</filename>
<folder>views</folder>
<folder>models</folder>
<folder>controllers</folder>
Expand Down

0 comments on commit 158b1ae

Please sign in to comment.