siddharth_application/application/controllers/Employeedetails.php
saravanakumar_kandasami 9a4c13b92a updated code for demo
2017-03-28 11:30:22 +05:30

304 lines
12 KiB
PHP

<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php';
/**
* Class : purchaseorder (PurchaseorderController)
* User Class to control all user related operations.
* @author : VenbaMail Mali
* @version : 1.1
* @since : 15 Feb 2016
*/
class Employeedetails extends BaseController
{
/**
* This is default constructor of the class
*/
public function __construct()
{
parent::__construct();
$this->load->model('employeedetails_model');
$this->isLoggedIn();
}
/**
* This function used to load the first screen of the user
*/
public function index()
{
$this->global['pageTitle'] = 'Siddharth : Employee Details';
$this->loadViews("employeeListing", $this->global, NULL , NULL);
}
/**
* This function is used to load the Supplier list
*/
function employeeListing()
{
if($this->isAdmin() == TRUE)
{
$this->loadThis();
}
else
{
$this->load->model('Employeedetails_model');
$searchText = $this->input->post('searchText');
$data['searchText'] = $searchText;
$this->load->library('pagination');
$count = $this->Employeedetails_model->employeeListingCount($searchText);
$returns = $this->paginationCompress ( "employeeListing/", $count, 5 );
$data['userRecords'] = $this->employeedetails_model->employeeListing($searchText, $returns["page"], $returns["segment"]);
$this->global['pageTitle'] = 'Siddharth : Employee Listing';
$this->loadViews("employeeListing", $this->global, $data, NULL);
}
}
/**
* This function is used to load the add new supplier */
function addemployee()
{
if($this->isAdmin() == TRUE)
{
$this->loadThis();
}
else
{
$this->load->model('employeedetails_model');
$data['roles'] = $this->employeedetails_model->getUserRoles();
$this->global['pageTitle'] = 'siddharth : AddNew Employee';
$this->loadViews("addemployee", $this->global, $data, NULL);
}
}
/**
* This function is used to add new user to the system
*/
function addNewemployee()
{
if($this->isAdmin() == TRUE)
{
$this->loadThis();
}
else
{
$this->load->library('form_validation');
//$PO = $this->input->post('SupplierID');
$this->form_validation->set_rules('FirstName','FirstName','trim|required|');
$this->form_validation->set_rules('LastName','LastName','trim|required');
$this->form_validation->set_rules('DateofBirth','DateofBirth','trim');
$this->form_validation->set_rules('ContactNumber','ContactNumber','trim');
$this->form_validation->set_rules('EmailId','EmailId','trim|email|xss_clean');
$this->form_validation->set_rules('DateofJoining','DateofJoining','trim|required');
$this->form_validation->set_rules('role','role','trim|required');
$this->form_validation->set_rules('Address1','Address1','trim|required');
$this->form_validation->set_rules('Address2','Address2','trim|required');
$this->form_validation->set_rules('Place','Place','trim|required');
$this->form_validation->set_rules('City','City','trim|required');
$this->form_validation->set_rules('State','State','trim|required');
$this->form_validation->set_rules('Pin','Pin','trim|required');
$this->form_validation->set_rules('DepartmentName','DepartmentName','trim|required');
$this->form_validation->set_rules('User_Comments','User Comments','trim|required');
if($this->form_validation->run() == FALSE)
{
$this->addemployee();
}
else
{
$FirstName = ucwords(strtolower($this->input->post('FirstName')));
$LastName = $this->input->post('LastName');
$DateofBirth = $this->input->post('DateofBirth');
$ContactNumber = $this->input->post('ContactNumber');
$EmailId = $this->input->post('EmailId');
$DateofJoining = $this->input->post('DateofJoining');
$role = $this->input->post('role');
$Address1 = $this->input->post('Address1');
$Address2 = $this->input->post('Address2');
$Place = $this->input->post('Place');
$City = $this->input->post('City');
$State = $this->input->post('State');
$Pin = $this->input->post('Pin');
$DepartmentName = $this->input->post('DepartmentName');
$User_Comments = $this->input->post('User_Comments');
$Employee = array('FirstName'=>$FirstName, 'LastName'=>$LastName,'DateofBirth'=>$DateofBirth,'ContactNumber'=>$ContactNumber,'EmailId'=>$EmailId,'DateofJoining'=>$DateofJoining,'role'=>$role,'Address1'=>$Address1,'Address2'=>$Address2,'Place'=>$Place,'City'=>$City,'State'=>$State,'Pin'=>$Pin,'DepartmentName'=>$DepartmentName,'User_Comments'=>$User_Comments,'Created_date'=>date('Y-m-d H:i:sa'));
$this->load->model('Employeedetails_model');
$result = $this->Employeedetails_model->addNewemployee($Employee);
if($result > 0)
{
$this->session->set_flashdata('success', 'New Employee created successfully');
}
else
{
$this->session->set_flashdata('error', 'Employee Not Create');
}
redirect('employeeListing');
}
}
}
/**
* This function is used load user edit information
* @param number $userId : Optional : This is user id
*/
function editOldemployee($EmployeeID = NULL)
{
if($this->isAdmin() == TRUE )
{
$this->loadThis();
}
else
{
if($EmployeeID == null)
{
redirect('employeeListing');
}
//$data['roles'] = $this->Employeedetails_model->getUserRoles();
$data['userRecords'] = $this->employeedetails_model->getuserInfo($EmployeeID);
$data['roles'] = $this->employeedetails_model->getUserRoles();
$this->global['pageTitle'] = 'Siddharth : Edit Employee';
$this->loadViews("editOldemployee", $this->global,$data, NULL);
}
}
/**
* This function is used to edit the user information
*/
function editemployee()
{
if($this->isAdmin() == TRUE)
{
$this->loadThis();
}
else
{
$this->load->library('form_validation');
$this->form_validation->set_rules('EmpID','Employee ID','trim');
$this->form_validation->set_rules('FirstName','FirstName','trim|required|');
$this->form_validation->set_rules('LastName','LastName','trim');
$this->form_validation->set_rules('DateofBirth','DateofBirth','trim');
$this->form_validation->set_rules('ContactNumber','ContactNumber','trim');
$this->form_validation->set_rules('EmailId','EmailId','trim');
$this->form_validation->set_rules('DateofJoining','DateofJoining','trim');
$this->form_validation->set_rules('role','role','trim');
$this->form_validation->set_rules('Address1','Address1','trim');
$this->form_validation->set_rules('Address2','Address2','trim');
$this->form_validation->set_rules('Place','Place','trim');
$this->form_validation->set_rules('City','City','trim');
$this->form_validation->set_rules('State','State','trim');
$this->form_validation->set_rules('Pin','Pin','trim');
$this->form_validation->set_rules('DepartmentName','DepartmentName','trim');
$this->form_validation->set_rules('User_Comments','User_Comments','trim');
if($this->form_validation->run() == FALSE)
{
$this->editemployee($EmpID);
}
else
{
$EmpID = $this->input->post('EmpID');
$FirstName = ucwords(strtolower($this->input->post('FirstName')));
$LastName = $this->input->post('LastName');
$DateofBirth = $this->input->post('DateofBirth');
$ContactNumber = $this->input->post('ContactNumber');
$EmailId = $this->input->post('EmailId');
$DateofJoining = $this->input->post('DateofJoining');
$role = $this->input->post('role');
$Address1 = $this->input->post('Address1');
$Address2 = $this->input->post('Address2');
$Place = $this->input->post('Place');
$City = $this->input->post('City');
$State = $this->input->post('State');
$Pin = $this->input->post('Pin');
$DepartmentName = $this->input->post('DepartmentName');
$User_Comments = $this->input->post('User_Comments');
echo 'validation completed';
$Emp = array();
$Emp = array('EmpID'=>$EmpID,'FirstName'=>$FirstName, 'LastName'=>$LastName,'DateofBirth'=>$DateofBirth,'ContactNumber'=>$ContactNumber,'EmailId'=>$EmailId,'DateofJoining'=>$DateofJoining,'role'=>$role,'Address1'=>$Address1,'Address2'=>$Address2,'Place'=>$Place,'City'=>$City,'State'=>$State,'Pin'=>$Pin,'DepartmentName'=>$DepartmentName,'User_Comments'=>$User_Comments,'created_Date'=>date('Y-m-d H:i:sa'));
echo 'pass';
//echo $Emp;
$result = $this->employeedetails_model->editemployee($Emp, $EmpID);
echo'insert';
if($result == true)
{
$this->session->set_flashdata('success', 'Employee updated successfully');
}
else
{
$this->session->set_flashdata('error', 'Employee updation failed');
}
//redirect('employeeListing');
}
}
}
/**
* This function is used to delete the user using userId
* @return boolean $result : TRUE / FALSE
function deleteUser()
{
if($this->isAdmin() == TRUE)
{
echo(json_encode(array('status'=>'access')));
}
else
{
$userId = $this->input->post('userId');
$userInfo = array('isDeleted'=>1,'updatedBy'=>$this->vendorId, 'updatedDtm'=>date('Y-m-d H:i:sa'));
$result = $this->user_model->deleteUser($userId, $userInfo);
if ($result > 0) { echo(json_encode(array('status'=>TRUE))); }
else { echo(json_encode(array('status'=>FALSE))); }
}
}*/
function pageNotFound()
{
$this->global['pageTitle'] = 'CodeInsect : 404 - Page Not Found';
$this->loadViews("404", $this->global, NULL, NULL);
}
}
?>