<?php
/**
 * Screen users\index
 * @version 1.0.1
 * @package Backend\Users
 * 
*/
function sortArray(&$array, $item)
    {  
        $result_array = array();
            foreach ($array as $key => $row)
            {
                $result_array[$key] = $row->$item;
            }
          
                array_multisort($result_array, SORT_ASC , $array);
    }
?>
<div class="row" >
<div class="col-lg-12" >
            <h3><?=R('page_user_management_title') ?></h3>
			<?php $this->load('common/message',$this) ?>  
             <div class="panel panel-default">
	         <div class="panel-body">
	        	<button class="btn" onclick="window.location.href='<?= __SITEBASE ?>/users/newuser'"><?= R("btn_adduser")?></button>
	         </div>
	         </div>
	           <div class="panel panel-default">
	         <div class="panel-body">
            <div class="table-responsive" >
              <table id="table1" class="table table-hover table-striped tablesorter">
                <thead>
                  <tr>
                    <th class="header"><?= R("label_fullname")?> <i class="fa fa-sort"></i></th>
                    <th class="header"><?= R("label_username")?> <i class="fa fa-sort"></i></th>
                    <th class="header"><?= R("label_email")?> <i class="fa fa-sort"></i></th>
                    <th class="header"><?= R("label_organisation")?> <i class="fa fa-sort"></i></th>
                  </tr>
                </thead>
                <tbody>
                <?php 
                sortArray($this->data, 'fullname');
                foreach($this->data as $user)  {?>
                  <tr onclick="window.location.href='<?= __SITEBASE ?>/users/edit?id=<?= $user->id ?>'">
                    <td><?= $user->fullname ?></td>
                    <td><?= $user->username ?></td>
                    <td><?= $user->email ?></td>
                    <td><?= $user->organisationname ?></td>
                  </tr>
                <?php }?>
                </tbody>
              </table>
              </div>
              </div>
            </div>
       </div>
</div> 
          