<?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->where('userlevel',3);
$xcrud->columns('fname,lname,email,username,country,dept_to,lastlogin,active,e_send');
$xcrud->fields('fname,lname,username,password,email,country,dept_to,active,e_send');
$xcrud->change_type('userlevel', 'int');
$xcrud->change_type('active','select','',array ('n' => 'Neaktivan', 'y' => 'Aktivan', 'b' => 'Blokiran','t' => 'Na čekanju'));
$xcrud->change_type('userlevel','select','',array (1 => 'Objekat', 2 => 'Serviser', 3 => 'Manager',9 => 'Super Admin'));
$xcrud->table_name('Korisnici sistema - MENADŽERI');
$xcrud->relation('country','country','country_id','country');
$xcrud->relation('dept_to','department','department_id','name','','','true');
$xcrud->label(array('lname' => 'Prezime','dept_to' => 'Sektor','active' => 'Status','e_send' => 'Prima mail','country' => 'Kompanija','fname' => 'Ime','send_to' => 'Šaljem','username' => 'Korisničko ime','password' => 'Lozinka','lastlogin' => 'Zadnja prijava'));
$xcrud->validation_required('lname')->validation_required('username')->validation_required('fname')->validation_required('country')->validation_required('email')->validation_required('active')->validation_required('e_send');
$xcrud->validation_pattern('email','email');
$xcrud->change_type('password', 'password');
$xcrud->pass_var('userlevel',3);
$xcrud->set_var('salt',SALT);
$xcrud->after_update('hash_password');
$xcrud->before_insert('hash_in_password');
$xcrud->highlight('active', '=', 'y', '#dff0d8');
//$xcrud->unset_remove();
?>
<!-- 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: 'Upsešno izmenjeni ili dodani podaci u bazu!!!',  // 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>

