diff --git a/application/controllers/Employeedetails.php b/application/controllers/Employeedetails.php index bd503b81..8f4ee342 100644 --- a/application/controllers/Employeedetails.php +++ b/application/controllers/Employeedetails.php @@ -3,11 +3,11 @@ require APPPATH . '/libraries/BaseController.php'; /** - * Class : purchaseorder (PurchaseorderController) + * Class : Employee (Employee Controller) * User Class to control all user related operations. - * @author : VenbaMail Mali + * @author : Gandhimathi * @version : 1.1 - * @since : 15 Feb 2016 + * @since : 07 Apr 2017 */ class Employeedetails extends BaseController { @@ -31,7 +31,7 @@ class Employeedetails extends BaseController } /** - * This function is used to load the Supplier list + * This function is used to load the Employee details */ function employeeListing() { @@ -41,6 +41,7 @@ class Employeedetails extends BaseController } else { + $this->load->model('Employeedetails_model'); $searchText = $this->input->post('searchText'); @@ -48,9 +49,9 @@ class Employeedetails extends BaseController $this->load->library('pagination'); - $count = $this->Employeedetails_model->employeeListingCount($searchText); - - $returns = $this->paginationCompress ( "employeeListing/", $count, 5 ); + $count = $this->Employeedetails_model->employeeListingCount(); + + $returns = $this->paginationCompress ( "employeeListing/", $count[0]['Count'], 10 ); $data['userRecords'] = $this->employeedetails_model->employeeListing($searchText, $returns["page"], $returns["segment"]); @@ -59,8 +60,77 @@ class Employeedetails extends BaseController $this->loadViews("employeeListing", $this->global, $data, NULL); } } + /** - * This function is used to load the add new supplier */ + * This function is used to save the new Employee form in the database + */ + + function AddNewEmployee() + { + if($this->isAdmin() == TRUE) + { + $this->loadThis(); + } + else + { + + $Picture = $this->add(); + + $FirstName = $this->input->post('FirstName'); + $LastName = $this->input->post('LastName'); + $FatherName = $this->input->post('FatherName'); + $DateofBirth = $this->input->post('DateofBirth'); + $ContactNumber = $this->input->post('contactnumber'); + $EmailId = $this->input->post('emailid'); + $Gender = $this->input->post('gender'); + $MartialStatus = $this->input->post('MartialStatus'); + $BloodGroup = $this->input->post('bloodgroup'); + $CurrentAddress = $this->input->post('currentaddress'); + $permanentaddress = $this->input->post('permanentaddress'); + $emergencycontactname = $this->input->post('emergencycontactname'); + $emergencycontactnumber = $this->input->post('emergencycontactnumber'); + $desigination = $this->input->post('desigination'); + $departmentCode = $this->input->post('departmentname'); + $dateofjoining = $this->input->post('dateofjoining'); + $Previousexperience = $this->input->post('Previousexperience'); + $eduqualifaction = $this->input->post('eduqualifaction'); + $addqualification = $this->input->post('addqualification'); + $referredby = $this->input->post('referredby'); + $referrercontno = $this->input->post('referrercontno'); + $accountno = $this->input->post('accountno'); + $ifsccode = $this->input->post('ifsccode'); + $bankbranchname = $this->input->post('bankbranchname'); + $bankaddress = $this->input->post('bankaddress'); + $aadharno = $this->input->post('aadharno'); + $panno = $this->input->post('panno'); + $passportno = $this->input->post('passportno'); + $ValidTill = $this->input->post('ValidTill'); + $addinfo = $this->input->post('addinfo'); + $IsActive = '1'; + $createdby = $this->session->userdata ( 'userId' ); + + $Employee = array('FirstName'=>$FirstName, 'LastName'=>$LastName,'FatherName'=>$FatherName,'Gender'=>$Gender,'DateofBirth'=>$DateofBirth,'ContactNumber'=>$ContactNumber,'EmailId'=>$EmailId,'BloodGroup'=>$BloodGroup,'MartialStatus'=>$MartialStatus,'DateofJoining'=>$dateofjoining,'PreviousYearsOfExp'=>$Previousexperience,'Designation'=>$desigination,'Departmentcode'=>$departmentCode,'PresentAddress'=>$CurrentAddress,'PermanentAddress'=>$permanentaddress,'EmergencyContactName'=>$emergencycontactname,'EmergencyContactNumber'=>$emergencycontactnumber,'Edu_Qualification'=>$eduqualifaction,'Additional_Qualification'=>$addqualification,'AadharNo'=>$aadharno,'PANNo'=>$panno,'BankAccountNo'=>$accountno,'IFSCCode'=>$ifsccode,'BankBranchName'=>$bankbranchname,'BankAddress'=>$bankaddress,'PassportNo'=>$passportno,'Passport_Valid_till'=>$ValidTill,'IsActive'=>$IsActive,'ProfilePic'=>$Picture,'Reference_Name'=>$referredby,'Reference_ContactNumber'=>$referrercontno,'Remarks'=>$addinfo,'CreatedBy'=>$createdby); + + $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', 'New Employee details not saved'); + } + + redirect('employeeListing'); + + } + } + + + /** + * This function is used to load the add new Employee form with dropdown values */ function addemployee() { if($this->isAdmin() == TRUE) @@ -70,234 +140,65 @@ class Employeedetails extends BaseController else { $this->load->model('employeedetails_model'); - + $GenderConfigID = 'C013'; + $MartialConfigID = 'C012'; + $QualificationConfigID = 'C014'; + $DesignationConfigID = 'C010'; + $BloodGroupConfigID = 'C011'; - $data['roles'] = $this->employeedetails_model->getUserRoles(); + $data['Gender'] = $this->employeedetails_model->getConfigValue($GenderConfigID); + $data['Martial'] = $this->employeedetails_model->getConfigValue($MartialConfigID); + $data['Qualification'] = $this->employeedetails_model->getConfigValue($QualificationConfigID); + $data['Designation'] = $this->employeedetails_model->getConfigValue($DesignationConfigID); + $data['BloodGroup'] = $this->employeedetails_model->getConfigValue($BloodGroupConfigID); - - $this->global['pageTitle'] = 'siddharth : AddNew Employee'; - + $data['Department'] = $this->employeedetails_model->getDepartment(); + $this->global['pageTitle'] = 'Siddharth : Add New 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); + } + + function add(){ + + + $picture = ''; + //Check whether user upload picture + if(!empty($_FILES['photo']['name'])) + { + + $config['upload_path'] = 'uploads/images/'; + $config['allowed_types'] = 'jpg|jpeg|png|gif'; + $config['file_name'] = $_FILES['photo']['name']; + + //Load upload library and initialize configuration + $this->load->library('upload',$config); + $this->upload->initialize($config); + + if($this->upload->do_upload('photo')) + { + $uploadData = $this->upload->data(); + $picture = $uploadData['file_name']; + } + else + { + $error = array('error' => $this->upload->display_errors()); + $picture = ''; + } + } + else + { + $picture = ''; + } + + return $picture ; } }