<?php
 define("_VALID_PHP", true);
 require_once("../../init.php");
$page = basename($_SERVER["PHP_SELF"]);
$heder = "Korisnici sistema";
$mali = " > podaci o korisnicima";
include('../../xcrud/xcrud.php');
Xcrud_config::$jquery_no_conflict = true; // jquery conflicts with SyntaxHighlighter
//odavde idu komnade ka xcrud-u
$xcrud = Xcrud::get_instance();
$xcrud->table('users');
$xcrud->change_type('userlevel', 'int');
$xcrud->change_type('userlevel','select','',array (1 => 'Objekat', 2 => 'Serviser', 3 => 'Manager',9 => 'Super Admin'));
$xcrud->table_name('Korisnici sistema');
$xcrud->relation('dept_to','department','department_id','name','','','true');
$xcrud->relation('country','country','country_id','country');
$xcrud->relation('send_to','users','id',array('fname','lname'),'users.userlevel > 2','','true');
$xcrud->relation('lokal','store','store_id','name');
//$xcrud->change_type('password', 'password', 'md5', array('maxlength'=>10,'placeholder'=>'enter password'));
$xcrud->columns('lokal,username,password,userlevel,email,fname,lname,country,send_to,dept_to,lastlogin');
$xcrud->set_var('salt',SALT);
$xcrud->after_update('hash_password');
?>
<!-- BEGIN PAGE HEADER-->
<h3 class="page-title">
<?php echo $heder;?><small><?php echo $mali;?></small>
</h3>
<div class="page-bar">
	<ul class="page-breadcrumb">
		<li>
			<i class="fa fa-home"></i>
			<a href="index.html">Home</a>
			<i class="fa fa-angle-right"></i>
		</li>
		<li>
			<a href="#"><?php echo $heder;?></a>
		</li>
	</ul>
	</div>
	<div id="alert_green">
	</div>
	<!-- END PAGE HEADER-->
	<!-- BEGIN PAGE CONTENT-->
	<div class="row">
	
	<div class="col-md-12">
	<?php echo $xcrud->render(); ?>
	</div>
</div>
<!-- END PAGE CONTENT-->
<script type="text/javascript">
jQuery(document).on("xcrudafterrequest",function(event,container){
    if(Xcrud.current_task == 'save')
    {
     Metronic.alert({
     place: 'append', // append or prepent in container 
     type: 'success',  // bootstrap state classes
     message: 'Successfully done!!!',  // alert's message
     close: true, // make alert closable
     reset: true, // close all previouse alerts first
     focus: true, // auto scroll to the alert after shown
     closeInSeconds: 7, // auto close after defined seconds
     icon: 'check' // put font awesome icon before the message
	});
    }
});
</script>

