Case registry - Joomla! Forum - community, help and support
hello, i'm vet , i've been trying customize 'project log' component make cancer case registry.
this main page list of cases (sorry, it's in italian).

the problem is, while it's okay admins see whole list, i'd registered users view cases project manager of.
i have tried this:
etc.
but in way getresultscounter , getpagescounter functions still work if results displayed (results - 1-7 of 7).

any suggestion? i'm attaching codes. many thanks!
this main page list of cases (sorry, it's in italian).

the problem is, while it's okay admins see whole list, i'd registered users view cases project manager of.
i have tried this:
code: select all
if($this->user->id == $p->manager || $user->usertype == "administrator" || $user->usertype == "super administrator" ) :
echo'<td>' . $p->release_id . '</td>
but in way getresultscounter , getpagescounter functions still work if results displayed (results - 1-7 of 7).

any suggestion? i'm attaching codes. many thanks!
code: select all
defined('_jexec') or die('no access');
jimport('joomla.application.component.model');
class projectlogmodelprojectlog extends jmodel
{
var $_id = null;
var $_project = null;
var $_data = null;
var $_total = null;
var $_pagination = null;
function __construct()
{
parent::__construct();
global $option;
$mainframe =& jfactory::getapplication() ;
$config = jfactory::getconfig() ;
$this->setid( jrequest::getint('project_id', '0' ));
// pagination request variables
$limit = $mainframe->getuserstatefromrequest( 'global.list.limit', 'limit', $config->getvalue('config.list_limit'), 'int' );
$limitstart = jrequest::getint( 'limitstart', 0 );
$this->setstate('limit', $limit);
$this->setstate('limitstart', $limitstart);
}
function setid($id)
{
$this->_id = $id;
}
function &getdata()
{
$this->loaddata() ;
if( $this->_pagination ) {
echo 'here!';
$data = array_slice( $this->_data, $this->getstate('limitstart'), $this->getstate('limit'));
return $data ;
} else {
return $this->_data ;
}
}
function loaddata()
{
// lets load content if doesn't exist
if (empty($this->_data))
{
$this->_data = array();
$where = $this->getwhere();
$orderby = $this->getorderby();
$limit = $this->getstate('limit');
$limitstart = $this->getstate('limitstart');
if( !$limit ) $limit = 99999;
$query = 'select p.* #__projectlog_projects p'.
' p.published = 1'.
$where .
$orderby .
' limit ' . $limitstart . ', ' . $limit;
$this->_db->setquery($query);
$this->_data = $this->_db->loadobjectlist();
return $this->_data;
}
return array() ;
}
function &getproject($project_id)
{
if (empty($this->_project))
{
$db = &jfactory::getdbo();
if( $project_id != null ) {
$this->_project_id = (int)$project_id ;
}
$query = 'select p.* #__projectlog_projects p id = '.(int)$this->_project_id;
$db->setquery($query);
$this->_project = $db->loadobject();
if( $this->_project == null ) {
return $this->_initproject();
}
}
return $this->_project;
}
function gettotal()
{
$this->_data = array();
$where = $this->getwhere() ;
$orderby = $this->getorderby() ;
$query = 'select p.* #__projectlog_projects p'.
' p.published = 1'.
$where .
$orderby ;
$this->_db->setquery($query);
$total = $this->_db->loadobjectlist();
$this->_total = count( $total) ;
return $this->_total;
}
function getpagination()
{
// lets load content if doesn't exist
if (empty($this->_pagination))
{
jimport('joomla.html.pagination');
$this->_pagination = new jpagination( $this->gettotal(), $this->getstate('limitstart'), $this->getstate('limit') );
}
return $this->_pagination;
}
function getwhere() {
global $mainframe;
$where = '' ;
$filter = $mainframe->getuserstatefromrequest( $option.'.filter', 'filter', '', 'int' );
$search = $mainframe->getuserstatefromrequest( $option.'.search', 'search', '', 'string' );
$search = $this->_db->getescaped( trim(jstring::strtolower( $search ) ) );
if ($search && $filter == 1) {
$where .= " , p.title '%" . $search . "%'";
}else if ($search && $filter == 2) {
$where .= " , p.release_id '%" . $search . "%'";
}
return $where ;
}
function getorderby() {
global $mainframe;
$sort = $mainframe->getuserstatefromrequest( $option.'.projectlog.filter_order', 'filter_order', 'p.release_date desc', 'cmd' );
$order = $mainframe->getuserstatefromrequest( $option.'.projectlog.filter_order_dir', 'filter_order_dir', '', 'word' );
$orderby = ' order ';
if ($sort && $order)
{
$orderby .= $sort .' '. $order;
}else{
$orderby .= 'p.release_date desc';
}
return $orderby;
}
function setlimit( $limit ) {
if( $limit > 0 ) {
$this->setstate('limit', $limit);
return true ;
}
return false ;
}
function _initproject() {
if (empty($this->_project))
{
$project = new stdclass();
$project->id = 0;
$project->release_id = null;
$project->job_id = null;
$project->task_id = null;
$project->workorder_id = null;
$project->title = null;
$project->description = null;
$project->release_date = null;
$project->contract_from = null;
$project->contract_to = null;
$project->location_gen = null;
$project->location_spec = null;
$project->manager = null;
$project->chief = null;
$project->technicians = null;
$project->deployment_from = null;
$project->deployment_to = null;
$project->onsite = null;
$project->surveytype = null;
$project->surveyor = null;
$project->status = null;
$project->published = 1;
$this->_project = $project;
}
return $this->_project;
}
function saveproject($post)
{
$query = 'select count(*)' .
' #__projectlog_projects' .
' id = '.(int) $post['id'];
$this->_db->setquery($query);
$project = $this->_db->loadresult();
$date = date('y-m-d h:i:s');
$release_id = $post['release_id'];
$job_id = $post['job_id'];
$task_id = $post['task_id'];
$workorder_id = $post['workorder_id'];
$title = $post['title'];
$description = $post['description'];
$release_date = $post['release_date'];
$contract_from = $post['contract_from'];
$contract_to = $post['contract_to'];
$location_gen = $post['location_gen'];
$location_spec = $post['location_spec'];
$manager = $post['manager'];
$chief = $post['chief'];
$technicians = $post['technicians'];
$deployment_from = $post['deployment_from'];
$deployment_to = $post['deployment_to'];
$onsite = $post['onsite'];
$surveytype = $post['surveytype'];
$surveyor = $post['surveyor'];
$status = $post['status'];
$published = 1;
code: select all
defined('_jexec') or die('no access');
$add_project_link = 'index.php?option=com_projectlog&view=projectlog&layout=form&itemid='. jrequest::getvar('itemid');
$user =& jfactory::getuser();
if($this->user->usertype == "administrator" || $user->usertype == "super administrator" ) :
?>
<div align="right">
<a href="<?php echo $add_project_link; ?>" class="red">[<?php echo jtext::_('nuova cartella'); ?>]</a>
</div>
<?php endif; ?>
<script language="javascript" type="text/javascript">
function tableordering( order, dir, task )
{
var form = document.adminform;
form.filter_order.value = order;
form.filter_order_dir.value = dir;
document.adminform.submit( task );
}
function listitemtask( id, task )
{
var form = document.adminform;
form.project_edit.value = id;
form.task.value = task;
document.adminform.submit( task );
}
</script>
<!-- body onload="document.getelementbyid('search').value='<?php echo $this->user->id; ?>'; document.adminform.submit();"> -->
<div class="main-article-title">
<h2 class="contentheading"><?php echo jtext::_('registro casi'); ?></h2>
</div>
<div class="main-article-block">
<div style="margin-bottom: 15px; margin-top: 15px">
<?php echo jtext::_('benvenuto/a, oggi è il'); ?><font color="#656379"><strong> <?php echo date('d/m/y'); ?></strong>.</font>
</div>
<form name="adminform" method="get" action="index.php">
<table class="ptable" width="100%" cellpadding="5" cellspacing="1">
<tr>
<td colspan="2">
<div align="left" class="prop_header_results">
<?php echo $this->pagination->getresultscounter(); ?>
</div>
</td>
<td colspan="5">
<div align="right" class="prop_header_results">
<?php echo jtext::_( 'cerca' ).' '.$this->lists['filter']; ?>
<input type="text" name="search" id="search" value="<?php echo $this->lists['search']; ?>" class="text_area" onchange="document.adminform.submit();" />
<button onclick="this.form.submit();"><?php echo jtext::_( 'vai' ); ?></button>
<button onclick="document.getelementbyid('search').value='';this.form.submit();"><?php echo jtext::_( 'reset' ); ?></button>
</div>
<br />
</td>
</tr>
<?php
//display results projects
if( $this->projects ) :
echo
'<tr class="ss-top">
<th align="left">'. jhtml::_('grid.sort', 'id', 'p.release_id', $this->lists['order_dir'], $this->lists['order'] ) . '</th>
<th align="left">'. jhtml::_('grid.sort', 'riferimento', 'p.manager', $this->lists['order_dir'], $this->lists['order'] ) . '</th>
<th align="left">'. jhtml::_('grid.sort', 'neoplasia', 'p.title', $this->lists['order_dir'], $this->lists['order'] ) . '</th>
<th align="left">'. jhtml::_('grid.sort', 'specie', 'p.surveytype', $this->lists['order_dir'], $this->lists['order'] ) . '</th>
<th align="left">'. jhtml::_('grid.sort', 'età', 'p.chief', $this->lists['order_dir'], $this->lists['order'] ) . '</th>
<th align="left">'. jhtml::_('grid.sort', 'sesso', 'p.status', $this->lists['order_dir'], $this->lists['order'] ) . '</th>
</tr>';
$i = 0;
foreach($this->projects $p) :
$delete_project_link = 'index.php?option=com_projectlog&view=projectlog&itemid='. jrequest::getvar('itemid') . '&task=deleteproject&id=' . $p->id;
switch( $p->status ){
case 'in progress':
$statusclass = 'green';
break;
case 'on hold':
$statusclass = 'orange';
break;
case 'complete':
$statusclass = 'red';
break;
}
echo '<tr>';
$user =& jfactory::getuser();
if($this->user->id == $p->manager || $user->usertype == "administrator" || $user->usertype == "super administrator" ) :
echo'<td><font color="#656379"><strong>' . $p->release_id . '</strong></font></td>
<td>' . projectlogviewhelper::getusername($p->manager) . '</td>
<td>
<a href="index.php?option=com_projectlog&view=project&project_id=' . $p->id . '">' . $p->title . '</a>
<br /><a href="'. $add_project_link . '&edit=' . $p->id . '" class="red">[modifica]</a>';
if($this->user->usertype == "administrator" || $user->usertype == "super administrator" ) :
echo'
<a href="'. $delete_project_link . '" class="red" onclick="if(confirm(\'sei sicuro di voler cancellare questo caso? questo comporterà la cancellazione di tutti dati sul follow-up e dei documenti allegati.\')){return true;}else{return false;};">[cancella]</a>';
endif;
'</td>';
echo' <td>' . $p->surveytype . '</td>
<td>' . $p->chief . '</td>
<td>'. $p->status . '</a></td>';
endif;
'</tr>';
endforeach;
echo
'<tr>
<td colspan="3" align="left">
' . $this->pagination->getpageslinks() . '
</td>
<td colspan="4" align="right">
mostra: ' . $this->pagination->getlimitbox() . '
</td>
</tr>
<tr>
<td colspan="7" align="center">
' . $this->pagination->getpagescounter() . '
</td>
</tr>';
else :
echo
'<tr>
<td colspan="7">
<div align="center">
nessun caso inserito.
</div>
</td>
</tr>';
endif;
?>
</table>
<input type="hidden" name="option" value="com_projectlog" />
<input type="hidden" name="view" value="<?php echo jrequest::getvar('view'); ?>" />
<input type="hidden" name="itemid" value="<?php echo jrequest::getvar('itemid'); ?>" />
<input type="hidden" name="filter_order" value="<?php echo $lists['order']; ?>" />
<input type="hidden" name="filter_order_dir" value="<?php echo $lists['order_dir']; ?>" />
<input type="hidden" name="project_edit" value="" />
<input type="hidden" name="task" value="" />
</form>
</div>
Comments
Post a Comment