<?php

/**
* @version 2.8.9
* @package Joomla 2.5
* @subpackage DT Register
* @copyright Copyright (C) 2006 DTH Development
* @copyright contact dthdev@dthdevelopment.com
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/

  $acoObj = $this->getModel('aco');

  $aroObj = $this->getModel('aro');

  $aros = $aroObj->find();

  $acos = $acoObj->AcoGroup;

?>

<div><?php echo JText::_('DT_PERMISSIONS_HELP')?></div><br />

<form action="index.php" method="post" name="adminForm" id="adminForm">

<table>
 <tr>
   <td>
	 <div class="textbutton" style="clear:none">
     <a title="<?php echo JText::_('DT_ADD_USER'); ?>" class="colorbox" href="index.php?option=com_dtregister&controller=aro&task=add&tmpl=component"><?php echo JText::_('DT_ADD_USER')?></a>
     </div>
   </td style="padding-right: 25px">
   <td>
     <div class="textbutton" style="clear:none">
     <a title="<?php echo JText::_('DT_SYNC_GROUP'); ?>" class="colorbox" href="index.php?option=com_dtregister&controller=aro&task=sync&tmpl=component"><?php echo JText::_('DT_SYNC_GROUP')?></a>
     </div>
   </td>
 </tr>
</table>

<table>

 <tr>

   <th class="dt_heading">

      <?php echo JText::_("DT_ACO"); ?>

   </th>

   <?php

   foreach($acos as $name=>$aco){

    ?>

	  <th class="dt_heading_small">

       <?php echo JText::_($name);?>

      </th>

   <?php

   }

   ?>

 </tr>

 <?php

  foreach($aros as $aro){

    ?>

     <tr>

	   <td>
 
       <?php 
	        if($aro->type=="joomlaUser"){
			   ?>
			   <a class="arodelete" href="<?php echo JRoute::_("index.php?option=com_dtregister&controller=aro&task=delete&cid[]=".$aro->id)?>"><img src="components/com_dtregister/assets/images/delete.jpg" style="height:16px; width:16px; border:0px"></a>&nbsp;	
               <?php
			}
	        echo JText::_($aro->alias);
	    ?>

      </td>

        <?php

	   foreach($acos as $name=>$aco){

		   if(isset($this->matrix[$aro->id]) && isset($this->matrix[$aro->id][$name])){

			  $checked = "checked";

		   }else{

			  $checked = "";   

		   }

		?>

		  <td align="center" style="border: 1px solid #efefef;">

		    <input type="checkbox" value="1" name="data[permission][<?php echo $aro->id; ?>][<?php echo $name; ?>]" <?php echo $checked; ?> />

		  </td>

	   <?php 

	   }

       ?>

     </tr>

   <?php

  }

 ?>

</table>

 <input type="hidden" name="option" value="<?php echo DTR_COM_COMPONENT;?>" />

 <input type="hidden" name="controller" value="permission" />

 <input type="hidden" name="task" value="update" />

</form>
<?php

$document =& JFactory::getDocument();

$document->addStyleSheet(JURI::root(true).'/components/com_dtregister/assets/css/south-street/jquery-ui.css');

$document->addScript( JURI::root(true).'/components/com_dtregister/assets/js/dt_jquery.js');

$document->addScript( JURI::root(true).'/components/com_dtregister/assets/js/jquery-ui.js');

?>

<script type="text/javascript" language="javascript">

   DTjQuery(function(){
	   
	   DTjQuery(".colorbox").live('click',function(e){

		e.preventDefault();

		var horizontalPadding = 10;

		var verticalPadding = 10;
         
		var win_title = DTjQuery(this).attr('title');
		 
		DTjQuery('<iframe id="externalSite" style="display:none;" class="externalSite" src="'+DTjQuery(this).attr('href')+'" />').dialog({

			title:  win_title,

			autoOpen: true,

			width:  325,

			height: 270,

			modal: true,

			resizable: true,

			overlay: {

				opacity: 0.5,

				background: "black"

			}

		});

			     });
	      
   })
 
</script>