User Creation changes

This commit is contained in:
gandhimathi Bharathirajan 2017-05-13 18:13:06 +05:30
parent ad8925a65a
commit 7bf58ede17
4 changed files with 284 additions and 94 deletions

View File

@ -22,49 +22,95 @@
<div class="box box-primary">
<div class="box-header">
<center><h3 class="box-title">Add User Details</h3></center>
<center><h3 class="box-title">Siddharth Industries - Add New User</h3></center>
</div><!-- /.box-header -->
<!-- form start -->
<form role="form" id="addUser" action="<?php echo base_url() ?>addNewUser" method="post" role="form">
<div class="box-body">
<div class="row">
<div class="col-md-6">
<div class="col-md-3">
<div class="form-group">
<label for="fname">Full Name</label>
<input type="text" class="form-control required" id="fname" name="fname" maxlength="128">
<label for="fname">Emp ID</label>
<select class="form-control required select" id="EmpList" name="EmpList">
<option value="0">Select Emp ID</option>
<?php
if(!empty($EmpList))
{
foreach ($EmpList as $EID)
{
$EmpID = $EID->EmpID;
if ($_POST['EmpList'] == $EmpID)
{
echo "<option value=\"".$EmpID."\" selected=\"selected\">".$EmpID.' - '. $EID->FirstName."</option>";
}
else
{
echo "<option value=\"".$EmpID."\">".$EmpID.' - '. $EID->FirstName ."</option>";
}
}
}
?>
</select>
</div>
</div>
<div class="col-md-6">
<div class="col-md-3">
<div class="form-group">
<label for="fname">First Name</label>
<input type="text" class="form-control required" readonly id="FirstName" name="FirstName" maxlength="128">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="fname">Last Name</label>
<input type="text" class="form-control required" readonly id="LastName" name="LastName" maxlength="128">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="email">Designation</label>
<input type="text" class="form-control required " readonly id="Designation" name="Designation" maxlength="128">
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label for="mobile">Department</label>
<input type="text" class="form-control required " readonly id="Department" name="Department" minlength="10"maxlength="10">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="email">Email address</label>
<input type="text" class="form-control required email" id="email" name="email" maxlength="128">
<input type="text" class="form-control required " readonly id="MailID" name="MailID" maxlength="128">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="mobile">Contact Number</label>
<input type="text" class="form-control required digits" readonly id="ContactNo" name="ContactNo" minlength="10"maxlength="10">
</div>
</div>
</div>
<div class="row">
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control required" id="password" name="password" maxlength="10">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="cpassword">Confirm Password</label>
<input type="password" class="form-control required equalTo" id="cpassword" name="cpassword" maxlength="10">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="mobile">Mobile Number</label>
<input type="text" class="form-control required digits" id="mobile" name="mobile" minlength="10"maxlength="10">
</div>
</div>
<div class="col-md-6">
<div class="col-md-3">
<div class="form-group">
<label for="role">Role</label>
<select class="form-control required" id="role" name="role">
@ -83,7 +129,20 @@
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control required" id="password" required name="password" maxlength="10">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="cpassword">Confirm Password</label>
<input type="password" class="form-control required equalTo" required id="cpassword" name="cpassword" maxlength="10">
</div>
</div>
</div>
</div><!-- /.box-body -->
<div class="box-footer" style="text-align:right">
@ -126,4 +185,48 @@
</section>
</div>
<script src="<?php echo base_url(); ?>assets/js/addUser.js" type="text/javascript"></script>
<script src="<?php echo base_url(); ?>assets/js/addUser.js" type="text/javascript"></script>
<script>
$('#EmpList').select2();
$('#EmpList').change(function() {
var id = $('#EmpList').val();
var y = <?php echo json_encode($EmpList, JSON_PRETTY_PRINT) ?>;
if(id != "0")
{
$.each(y, function(idx, obj) {
if(obj.EmpID === id)
{
$("#FirstName").val(obj.FirstName);
$("#LastName").val(obj.LastName);
$("#Designation").val(obj.Designation);
$("#Department").val(obj.DepartmentName);
$("#MailID").val(obj.EmailId);
$("#ContactNo").val(obj.ContactNumber);
}
});
}
else
{
alert('Please select Employee Details');
$("#FirstName").val('');
$("#LastName").val('');
$("#Designation").val('');
$("#Department").val('');
$("#MailID").val('');
$("#ContactNo").val('');
return false;
}
});
</script>

View File

@ -1,19 +1,22 @@
<?php
$Empcnt = '';
//echo $DEPCode;
//echo ROLE_MANAGER;
if(!empty($EmpCount))
{
foreach ($EmpCount as $Emp)
{
$Empcnt = $Emp->EmpCount;
}
}
?>
<div class="content-wrapper">
<section class="content">
<!-- Dashboard for Account department-->
<?php
if($role == ROLE_ACCOUNTS)
<?php
if($DEPCode == FINANCE)
{
?>
<div class="content-wrapper">

View File

@ -1,25 +1,40 @@
<?php
$userId = '';
$name = '';
$email = '';
$mobile = '';
$roleId = '';
$isDeleted = '';
if(!empty($userInfo))
$EmpId = '';
$FirstName = '';
$LastName = '';
$ContactNo = '';
$EmailId = '';
$Role = '';
$Department = '';
$Designation = '';
if(!empty($EmpRole))
{
foreach ($userInfo as $uf)
foreach ($EmpRole as $Er)
{
$userId = $uf->userId;
$name = $uf->name;
$email = $uf->email;
$mobile = $uf->mobile;
$roleId = $uf->roleId;
$isDeleted = $uf->isDeleted;
$Role = $Er->role;
}
}
if(!empty($EmpList))
{
foreach ($EmpList as $Emp)
{
$EmpId = $Emp->EmpID;
$FirstName = $Emp->FirstName;
$LastName = $Emp->LastName;
$ContactNo = $Emp->ContactNumber;
$EmailId = $Emp->EmailId;
$Department = $Emp->DepartmentName;
$Designation = $Emp->Designation;
}
}
?>
<div class="content-wrapper">
@ -52,55 +67,77 @@ if(!empty($userInfo))
<form role="form" action="<?php echo base_url() ?>editUser" method="post" id="editUser" role="form">
<div class="box-body">
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label for="fname">Full Name</label>
<input type="text" class="form-control" id="fname" placeholder="Full Name" name="fname" value="<?php echo $name; ?>" maxlength="128">
<input type="hidden" value="<?php echo $userId; ?>" name="userId" id="userId" />
<label for="fname">Emp ID</label>
<input type="text" class="form-control required" value="<?php echo $EmpId ?>" readonly id="EmpList" name="EmpList" maxlength="128">
</div>
</div>
<div class="col-md-6">
<div class="col-md-3">
<div class="form-group">
<label for="fname">First Name</label>
<input type="text" class="form-control required" value="<?php echo $FirstName ?>" readonly id="FirstName" name="FirstName" maxlength="128">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="fname">Last Name</label>
<input type="text" class="form-control required" value="<?php echo $LastName ?>" readonly id="LastName" name="LastName" maxlength="128">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="email">Designation</label>
<input type="text" class="form-control required " value="<?php echo $Designation ?>" readonly id="Designation" name="Designation" maxlength="128">
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label for="mobile">Department</label>
<input type="text" class="form-control required" value="<?php echo $Department ?>" readonly id="Department" name="Department" minlength="10"maxlength="10">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="email">Email address</label>
<input type="email" class="form-control" id="email" placeholder="Enter email" name="email" value="<?php echo $email; ?>" maxlength="128">
<input type="text" class="form-control required email" value="<?php echo $EmailId ?>" readonly id="MailID" name="MailID" maxlength="128">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="mobile">Contact Number</label>
<input type="text" class="form-control required digits" value="<?php echo $ContactNo ?>" readonly id="ContactNo" name="ContactNo" minlength="10"maxlength="10">
</div>
</div>
</div>
<div class="row">
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" placeholder="Password" name="password" maxlength="10">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="cpassword">Confirm Password</label>
<input type="password" class="form-control" id="cpassword" placeholder="Confirm Password" name="cpassword" maxlength="10">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="mobile">Mobile Number</label>
<input type="text" class="form-control" id="mobile" placeholder="Mobile Number" name="mobile" value="<?php echo $mobile; ?>" maxlength="10">
</div>
</div>
<div class="col-md-6">
<div class="col-md-3">
<div class="form-group">
<label for="role">Role</label>
<select class="form-control" id="role" name="role">
<option value="0">Select Role</option>
<select class="form-control required" id="role" name="role">
<option value="<?php echo $Role ?>"><?php echo $Role ?></option>
<?php
if(!empty($roles))
{
foreach ($roles as $rl)
{
?>
<option value="<?php echo $rl->roleId; ?>" <?php if($rl->roleId == $roleId) {echo "selected=selected";} ?>><?php echo $rl->role ?></option>
<option value="<?php echo $rl->roleId ?>"><?php echo $rl->role ?></option>
<?php
}
}
@ -108,11 +145,21 @@ if(!empty($userInfo))
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" required name="password" maxlength="10">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="cpassword">Confirm Password</label>
<input type="password" class="form-control equalTo" id="cpassword" name="cpassword" maxlength="10">
</div>
</div>
</div>
</div>
<!-- /.box-body -->
</div><!-- /.box-body -->
<div class="box-footer" style="text-align:right">
<input type="submit" class="btn btn-info" value="Submit" />

View File

@ -30,15 +30,16 @@
</form>
</div>
</div><!-- /.box-header -->
<div class="box-body table-responsive no-padding">
<div class="box-body table-responsive no-padding tableSorter">
<table class="table table-hover">
<tr>
<th>ID</th>
<th>Name</th>
<tr bgcolor="steelblue">
<th>User Id</th>
<th>User Name</th>
<th>Email</th>
<th>Mobile</th>
<th>Role</th>
<th>Deleted</th>
<th>Contact Number</th>
<th>Designation</th>
<th>Department</th>
<th>Role Name</th>
<th>Actions</th>
</tr>
<?php
@ -49,14 +50,15 @@
?>
<tr>
<td><?php echo $record->userId ?></td>
<td><?php echo $record->name ?></td>
<td><?php echo $record->email ?></td>
<td><?php echo $record->mobile ?></td>
<td><?php echo $record->role ?></td>
<td><?php echo $record->isDeleted ?></td>
<td><?php echo $record->FirstName ?></td>
<td><?php echo $record->EmailId ?></td>
<td><?php echo $record->ContactNumber ?></td>
<td><?php echo $record->Designation ?></td>
<td><?php echo $record->DepartmentName ?></td>
<td><?php echo $record->role ?></td>
<td>
<a href="<?php echo base_url().'editOld/'.$record->userId; ?>"><i class="fa fa-pencil"></i>&nbsp;&nbsp;&nbsp;</a>
<a href="#" data-userid="<?php echo $record->userId; ?>" class="deleteUser"><i class="fa fa-trash"></i>&nbsp;&nbsp;&nbsp;</a>
<a href="<?php echo base_url().'User/editOld?UID='.$record->userId;?>"><i class="fa fa-pencil"></i>&nbsp;&nbsp;&nbsp;</a>
<a onclick="deleteUser(<?php echo $record->userId;?>)"><i class="fa fa-trash"></i>&nbsp;&nbsp;&nbsp;</a>
</td>
</tr>
<?php
@ -76,6 +78,13 @@
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/common.js" charset="utf-8"></script>
<script type="text/javascript">
$(document).ready(function() {
$('table').tableSort( {
animation :'slide',
speed:500
} );
});
jQuery(document).ready(function(){
jQuery('ul.pagination li a').click(function (e) {
e.preventDefault();
@ -85,4 +94,32 @@
jQuery("#searchList").submit();
});
});
function deleteUser(userid)
{
var answer = confirm(" Do you want to delete the user from the List?")
if (answer)
{
$.ajax({
data:{id:userid},
type:"POST",
url:"<?php echo base_url() ?>User/deleteUser",
success:function(data) {
if(data)
{
$('#content').loader('hide');
alert(data);
location.reload();
}
else
{
alert("Error");
}
}});
}
}
</script>