<?php
 define("_VALID_PHP", true);
 require_once("../../init.php");
$page = basename($_SERVER["PHP_SELF"]);
$id_user = $user->uid;
$lokal = $user->fname;
$heder = "Moj Profil";
$mali = " > podaci o korisniku";
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('id',$id_user);
$xcrud->change_type('userlevel', 'int');
$xcrud->change_type('userlevel','select','',array (1 => 'Objekat', 2 => 'Serviser', 3 => 'Manager',9 => 'Super Admin'));
$xcrud->table_name('Korisnik sistema za objekat - '.$lokal);
$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->label(array('dept_to' => 'Pripadaju odeljenja','country' => 'Kompanija','fname' => 'Ime korisnika','send_to' => 'Menadžer','username' => 'Korisničko ime','password' => 'Lozinka','lastlogin' => 'Zadnja prijava'));
$xcrud->validation_required('lokal')->validation_required('username')->validation_required('fname')->validation_required('country')->validation_required('send_to')->validation_required('dept_to');
$xcrud->disabled('lokal,username,fname,country,lastlogin');
$xcrud->relation('lokal','store','store_id','name');
if ($user->levelCheck("1"))//objekat
{
//$xcrud->columns('lokal,username,fname,country,dept_to,lastlogin');
$xcrud->columns('username,fname,country,dept_to,lastlogin');
//$xcrud->fields('lokal,username,password,email');
$xcrud->fields('username,password,email');
}
if ($user->levelCheck("2,3,4,6,9"))//objekat
{
$xcrud->columns('username,fname,country,dept_to,lastlogin');
$xcrud->fields('username,password,email');
}
$xcrud->unset_add();	
$xcrud->unset_remove();	
$xcrud->unset_print();
$xcrud->unset_csv();
$xcrud->unset_limitlist();
$xcrud->unset_search();
$xcrud->hide_button('save_new');
$xcrud->hide_button('save_edit');
$xcrud->change_type('password', 'password');
$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('view'); ?>
		<div class="note note-success">
			<h4 class="block">Objašnjenje</h4>
			<p>
				 Na ovoj strani možete promeniti svoju email adresu i lozinku.
			</p>
			<p>
				Klikom na plavu ikonicu na kraju reda, biće vam prikazani podaci o Vašem nalogu.
			</p>
			<p>
				Klikom na žutu ikonicu na kraju reda, omogućeno Vam je da promenite Vašu mail adresu i lozinku. Kliknite posle na "Sačuvaj i vrati se" dugme.
				Ako ne promenite ništa u polju "Lozinka" Vaša lozinka će ostati nepromenjena.
			</p>
	</div>
	</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>

