diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 5dd09b3c..019a321a 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -380,6 +380,7 @@ $routes->get('inprocess', 'Inprocess::index'); // Sales Controller $routes->get('sales_dashboard', 'Sales::sales_dashboard'); $routes->get('invoicedetails/ViewInvoice', 'Sales::ViewInvoice'); +$routes->get('getInvoiceAttachment', 'Sales::getInvoiceAttachments'); $routes->get('getInvoiceAttachments', 'Sales::getInvoiceAttachments'); $routes->get('deleteAttachment', 'Sales::deleteAttachment'); $routes->post('saveAttachment', 'Sales::saveAttachment'); diff --git a/app/Controllers/Emergencypurchaseorder.php b/app/Controllers/Emergencypurchaseorder.php index 8e6dab1e..4cecdeb2 100644 --- a/app/Controllers/Emergencypurchaseorder.php +++ b/app/Controllers/Emergencypurchaseorder.php @@ -386,7 +386,7 @@ class Emergencypurchaseorder extends BaseController function addNewRevenuePurchaseOrder() { - print_r($this->request->getPost());die; + // print_r($this->request->getPost());die; $txtspl = $this->request->getPost('txtSpecial'); diff --git a/app/Controllers/Employeedetails.php b/app/Controllers/Employeedetails.php index 33c68cc4..5769a066 100644 --- a/app/Controllers/Employeedetails.php +++ b/app/Controllers/Employeedetails.php @@ -35,8 +35,8 @@ class Employeedetails extends BaseController protected $appConfig; protected $emppaydate_model; protected $session; - - + + /** * This is default constructor of the class */ @@ -51,7 +51,6 @@ class Employeedetails extends BaseController $this->session = session(); helper('form'); //$this->load->library('form_validation'); $this->isLoggedIn(); - } /** * This function is used to load the Employee details @@ -202,176 +201,207 @@ class Employeedetails extends BaseController function AddNewEmployee() { - - - $photo = $this->request->getFile('photo'); - $Picture = ""; + $photo = $this->request->getFile('photo'); + $Picture = ""; + if (isset($photo)) { if ($photo->isValid() && !$photo->hasMoved()) { - $uploadDir = ROOTPATH . 'public/uploads/images/'; - $allowedTypes = ['jpg', 'jpeg', 'png', 'gif']; - if (in_array($photo->getExtension(), $allowedTypes)) { - $newName = $photo->getRandomName(); - if(!is_dir($uploadDir)) { mkdir($uploadDir, 0777, true); } - $photo->move($uploadDir, $newName); - $Picture = $newName; - } + $uploadDir = ROOTPATH . 'public/uploads/images/'; + $allowedTypes = ['jpg', 'jpeg', 'png', 'gif']; + if (in_array($photo->getExtension(), $allowedTypes)) { + $newName = $photo->getRandomName(); + if (!is_dir($uploadDir)) { + mkdir($uploadDir, 0777, true); + } + $photo->move($uploadDir, $newName); + $Picture = $newName; + } } - // $Profile = $this->request->getPost('photo'); - $FirstName = $this->request->getPost('FirstName'); - $FatherName = $this->request->getPost('FatherName'); - $DateofBirth = $this->request->getPost('DateofBirth'); - $ContactNumber = $this->request->getPost('ContactNumber'); - $EmailId = $this->request->getPost('emailid'); - $comEmailId = $this->request->getPost('comemailid'); - $Gender = $this->request->getPost('gender'); - $MartialStatus = $this->request->getPost('MartialStatus'); - $BloodGroup = $this->request->getPost('bloodgroup'); - $CurrentAddress = $this->request->getPost('currentaddress'); - $permanentaddress = $this->request->getPost('permanentaddress'); - $emergencycontactname = $this->request->getPost('emergencycontactname'); - $emergencycontactnumber = $this->request->getPost('emergencycontactnumber'); - $desigination = $this->request->getPost('desigination'); - $departmentCode = $this->request->getPost('departmentname'); - $dateofjoining = $this->request->getPost('dateofjoining'); - $pre_experience = $this->request->getPost('Previousexperience'); + } + // $Profile = $this->request->getPost('photo'); + $FirstName = $this->request->getPost('FirstName'); + $FatherName = $this->request->getPost('FatherName'); + $DateofBirth = $this->request->getPost('DateofBirth'); + $ContactNumber = $this->request->getPost('ContactNumber'); + $EmailId = $this->request->getPost('emailid'); + $comEmailId = $this->request->getPost('comemailid'); + $Gender = $this->request->getPost('gender'); + $MartialStatus = $this->request->getPost('MartialStatus'); + $BloodGroup = $this->request->getPost('bloodgroup'); + $CurrentAddress = $this->request->getPost('currentaddress'); + $permanentaddress = $this->request->getPost('permanentaddress'); + $emergencycontactname = $this->request->getPost('emergencycontactname'); + $emergencycontactnumber = $this->request->getPost('emergencycontactnumber'); + $desigination = $this->request->getPost('desigination'); + $departmentCode = $this->request->getPost('departmentname'); + $dateofjoining = $this->request->getPost('dateofjoining'); + $pre_experience = $this->request->getPost('Previousexperience'); - if ($pre_experience == '') { - $Previousexperience = null; - } else { - $Previousexperience = $pre_experience; - } + if ($pre_experience == '') { + $Previousexperience = null; + } else { + $Previousexperience = $pre_experience; + } - $eduqualifaction = $this->request->getPost('eduqualifaction'); - $addqualification = $this->request->getPost('addqualification'); - $referredby = $this->request->getPost('referredby'); - $referrercontno = $this->request->getPost('referrercontno'); - $accountno = $this->request->getPost('accountno'); - $ifsccode = $this->request->getPost('ifsccode'); - $bankbranchname = $this->request->getPost('bankbranchname'); - $bankaddress = $this->request->getPost('bankaddress'); - $aadharno = $this->request->getPost('aadharno'); - $panno = $this->request->getPost('panno'); - $panno = $panno !== null && is_string($panno) ? strtoupper($panno) : null; - $passportno = $this->request->getPost('passportno'); - $passportno = $passportno !== null && is_string($passportno) ? strtoupper($passportno) : null; - $ValidTill = $this->request->getPost('ValidTill'); - $addinfo = $this->request->getPost('addinfo'); - $IsActive = '1'; - $driverlicense = $this->request->getPost('driverlicense'); - $driverlicense = $driverlicense !== null && is_string($driverlicense) ? strtoupper($driverlicense) : null; - $licenseExpiryDate = $this->request->getPost('licenseExpiryDate'); - $VoterID = $this->request->getPost('voterID'); - $VoterID = $VoterID !== null && is_string($VoterID) ? strtoupper($VoterID) : null; - $PFno = $this->request->getPost('pfno'); - $ESIno = $this->request->getPost('esino'); - $Nominee = $this->request->getPost('nomineename'); - $createdby = $this->session->get('userId'); - $is_management_team = $this->request->getPost('is_management_team'); - $esi_applicable = $this->request->getPost('esi_applicable'); - $pf_applicable = $this->request->getPost('pf_applicable'); - $work_location = $this->request->getPost('work_location'); + $eduqualifaction = $this->request->getPost('eduqualifaction'); + $addqualification = $this->request->getPost('addqualification'); + $referredby = $this->request->getPost('referredby'); + $referrercontno = $this->request->getPost('referrercontno'); + $accountno = $this->request->getPost('accountno'); + $ifsccode = $this->request->getPost('ifsccode'); + $bankbranchname = $this->request->getPost('bankbranchname'); + $bankaddress = $this->request->getPost('bankaddress'); + $aadharno = $this->request->getPost('aadharno'); + $panno = $this->request->getPost('panno'); + $panno = $panno !== null && is_string($panno) ? strtoupper($panno) : null; + $passportno = $this->request->getPost('passportno'); + $passportno = $passportno !== null && is_string($passportno) ? strtoupper($passportno) : null; + $ValidTill = $this->request->getPost('ValidTill'); + $addinfo = $this->request->getPost('addinfo'); + $IsActive = '1'; + $driverlicense = $this->request->getPost('driverlicense'); + $driverlicense = $driverlicense !== null && is_string($driverlicense) ? strtoupper($driverlicense) : null; + $licenseExpiryDate = $this->request->getPost('licenseExpiryDate'); + $VoterID = $this->request->getPost('voterID'); + $VoterID = $VoterID !== null && is_string($VoterID) ? strtoupper($VoterID) : null; + $PFno = $this->request->getPost('pfno'); + $ESIno = $this->request->getPost('esino'); + $Nominee = $this->request->getPost('nomineename'); + $createdby = $this->session->get('userId'); + $is_management_team = $this->request->getPost('is_management_team'); + $esi_applicable = $this->request->getPost('esi_applicable'); + $pf_applicable = $this->request->getPost('pf_applicable'); + $work_location = $this->request->getPost('work_location'); - if ($licenseExpiryDate != '') { - //$License_ExpiryDate = get_date_format($licenseExpiryDate); - $License_ExpiryDate = get_date_time_format($licenseExpiryDate); - } else { - $License_ExpiryDate = null; - } + if ($licenseExpiryDate != '') { + //$License_ExpiryDate = get_date_format($licenseExpiryDate); + $License_ExpiryDate = get_date_time_format($licenseExpiryDate); + } else { + $License_ExpiryDate = null; + } - $DOB = get_date_time_format($DateofBirth); - $DOJ = get_date_time_format($dateofjoining); + $DOB = get_date_time_format($DateofBirth); + $DOJ = get_date_time_format($dateofjoining); - if ($ValidTill != '') { + if ($ValidTill != '') { - $Valid = get_date_time_format($ValidTill); - } else { - $Valid = null; - } + $Valid = get_date_time_format($ValidTill); + } else { + $Valid = null; + } - //echo $DOB; - $Employee = array( - 'FirstName' => $FirstName, 'FatherName' => $FatherName, - 'Gender' => $Gender, 'DateofBirth' => $DOB, 'ContactNumber' => $ContactNumber, 'EmailId' => $EmailId, - 'BloodGroup' => $BloodGroup, 'MartialStatus' => $MartialStatus, 'DateofJoining' => $DOJ, - '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' => $Valid, - 'IsActive' => $IsActive, 'ProfilePic' => $Picture, 'Reference_Name' => $referredby, - 'Reference_ContactNumber' => $referrercontno, 'Remarks' => $addinfo, 'CreatedBy' => $createdby, - 'personalEmailId' => $comEmailId, 'DriverLicense' => $driverlicense, - 'LicenseValidtill' => $License_ExpiryDate, 'VoterID' => $VoterID, 'PFNO' => $PFno, 'ESI' => $ESIno, - 'NomineeDetails' => $Nominee , 'is_management_team' => $is_management_team , 'esi_applicable'=>$esi_applicable, - 'pf_applicable'=>$pf_applicable,'work_location'=>$work_location - ); + //echo $DOB; + $Employee = array( + 'FirstName' => $FirstName, + 'FatherName' => $FatherName, + 'Gender' => $Gender, + 'DateofBirth' => $DOB, + 'ContactNumber' => $ContactNumber, + 'EmailId' => $EmailId, + 'BloodGroup' => $BloodGroup, + 'MartialStatus' => $MartialStatus, + 'DateofJoining' => $DOJ, + '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' => $Valid, + 'IsActive' => $IsActive, + 'ProfilePic' => $Picture, + 'Reference_Name' => $referredby, + 'Reference_ContactNumber' => $referrercontno, + 'Remarks' => $addinfo, + 'CreatedBy' => $createdby, + 'personalEmailId' => $comEmailId, + 'DriverLicense' => $driverlicense, + 'LicenseValidtill' => $License_ExpiryDate, + 'VoterID' => $VoterID, + 'PFNO' => $PFno, + 'ESI' => $ESIno, + 'NomineeDetails' => $Nominee, + 'is_management_team' => $is_management_team, + 'esi_applicable' => $esi_applicable, + 'pf_applicable' => $pf_applicable, + 'work_location' => $work_location + ); - //print_r($Employee);die(); - $result = $this->employeedetails_model->addNewemployee($Employee); + //print_r($Employee);die(); + $result = $this->employeedetails_model->addNewemployee($Employee); - if ($result) { + if ($result) { - // Get the uploaded files - $files = $this->request->getFiles(); - $fileNames = $this->request->getPost('file_name'); // Get user-entered file names - if(isset($files['emp_file'])) - { + // Get the uploaded files + $files = $this->request->getFiles(); + $fileNames = $this->request->getPost('file_name'); // Get user-entered file names + if (isset($files['emp_file'])) { foreach ($files['emp_file'] as $index => $file) { - if ($file->isValid() && !$file->hasMoved()) { - // Move the file to the desired directory - $newName = $file->getRandomName(); - $file->move(ROOTPATH . 'public/uploads/images/emp_files', $newName); - $path = ROOTPATH . 'public/uploads/images/emp_files/'.$newName; - // Store the file information in the database - $this->empFiles->save([ - 'file_name' => $fileNames[$index], // User-entered file name - 'emp_file' => $newName, // New file name - 'emp_id' => $result, - 'path' => $path - - ]); - } + if ($file->isValid() && !$file->hasMoved()) { + // Move the file to the desired directory + $newName = $file->getRandomName(); + $file->move(ROOTPATH . 'public/uploads/images/emp_files', $newName); + $path = ROOTPATH . 'public/uploads/images/emp_files/' . $newName; + // Store the file information in the database + $this->empFiles->save([ + 'file_name' => $fileNames[$index], // User-entered file name + 'emp_file' => $newName, // New file name + 'emp_id' => $result, + 'path' => $path + + ]); + } } } - $EmpID = $result; - $Total_Salary = $this->request->getPost('Total_salary'); - $Basic_Pay = $this->request->getPost('Basic_Pay'); - $HRA_Rate = $this->request->getPost('HRA_Rate'); - $HRA_Amount = $this->request->getPost('HRA_Amount'); - $PF_Rate = $this->request->getPost('PF_Rate'); - $ESI_Rate = $this->request->getPost('ESI_Rate'); - $CreateBy = $this->session->get('userId'); + $EmpID = $result; + $Total_Salary = $this->request->getPost('Total_salary'); + $Basic_Pay = $this->request->getPost('Basic_Pay'); + $HRA_Rate = $this->request->getPost('HRA_Rate'); + $HRA_Amount = $this->request->getPost('HRA_Amount'); + $PF_Rate = $this->request->getPost('PF_Rate'); + $ESI_Rate = $this->request->getPost('ESI_Rate'); + $CreateBy = $this->session->get('userId'); - $emppay = array('EmpID' => $EmpID, 'TotalSalary' => $Total_Salary, 'Basic_Pay' => $Basic_Pay, 'HRA_Rate' => $HRA_Rate, 'HRA_Amount' => $HRA_Amount, 'PF_Rate' => $PF_Rate, 'ESI_Rate' => $ESI_Rate, 'Created_By' => $CreateBy); - + $emppay = array('EmpID' => $EmpID, 'TotalSalary' => $Total_Salary, 'Basic_Pay' => $Basic_Pay, 'HRA_Rate' => $HRA_Rate, 'HRA_Amount' => $HRA_Amount, 'PF_Rate' => $PF_Rate, 'ESI_Rate' => $ESI_Rate, 'Created_By' => $CreateBy); - $this->emppaydate_model->addNewemppay($emppay); - // $this->session->set_flashdata('Success', 'New Employee created successfully!'); - $this->session->setFlashdata('success', 'New Employee created successfully!'); - // echo ""; - } else { + $this->emppaydate_model->addNewemppay($emppay); - // $this->session->set_flashdata('Error', 'New Employee details not saved'); - $this->session->setFlashdata('error', 'Record Not Saved!'); - // echo ""; - // redirect('employeeListing', 'refresh'); - } - return redirect()->route('employeeListing'); + // $this->session->set_flashdata('Success', 'New Employee created successfully!'); + $this->session->setFlashdata('success', 'New Employee created successfully!'); + return json_encode('true'); + // echo ""; + } else { + + // $this->session->set_flashdata('Error', 'New Employee details not saved'); + $this->session->setFlashdata('error', 'Record Not Saved!'); + return json_encode('false'); + // echo ""; + // redirect('employeeListing', 'refresh'); + } + // return redirect()->route('employeeListing'); // } } - function deleteEmployeeFile(){ + function deleteEmployeeFile() + { $id = $this->request->getPost('id'); - $update = $this->empFiles->set(['is_active' => 0])->where('id',$id)->update(); - if($update){ + $update = $this->empFiles->set(['is_active' => 0])->where('id', $id)->update(); + if ($update) { return true; - }else{ + } else { return false; } } @@ -379,8 +409,6 @@ class Employeedetails extends BaseController * This function is used to load the add new Employee form with dropdown values */ function addemployee() { - - $GenderConfigID = 'C013'; $MartialConfigID = 'C012'; $QualificationConfigID = 'C014'; @@ -396,16 +424,17 @@ class Employeedetails extends BaseController $data['BloodGroup'] = $this->employeedetails_model->getConfigValue($BloodGroupConfigID); $data['Location'] = $this->employeedetails_model->getConfigValue($LocationConfigID); $data['Department'] = $this->employeedetails_model->getDepartment(); - $data['hra_rate'] = $this->appConfig->where('config_key',1)->get()->getRow()->config_value; - $data['pf_rate'] = $this->appConfig->where('config_key',2)->get()->getRow()->config_value; - $data['esi_rate'] = $this->appConfig->where('config_key',3)->get()->getRow()->config_value; + $data['hra_rate'] = $this->appConfig->where('config_key', 1)->get()->getRow()->config_value; + $data['pf_rate'] = $this->appConfig->where('config_key', 2)->get()->getRow()->config_value; + $data['esi_rate'] = $this->appConfig->where('config_key', 3)->get()->getRow()->config_value; $this->global['pageTitle'] = 'Add New Employee'; // if($this->role == ROLE_ADMIN || $this->DEPCode == HR) // { - $this->loadViews("addEmployee", $this->global, $data, NULL); + // $this->loadViews("addEmployee", $this->global, $data, NULL); + $this->loadViews("addEmployeenew", $this->global, $data, NULL); // } @@ -422,7 +451,7 @@ class Employeedetails extends BaseController { $id = $this->request->getPost('id'); //print_r($id); - + $query = $this->employeedetails_model->checkMailExists($id); $response = ($query !== null && !empty($query)) ? $query[0]['EmailId'] : null; return $this->response->setJSON($response); @@ -433,7 +462,7 @@ class Employeedetails extends BaseController $id = $this->request->getPost('id'); //print_r($id); - + $query = $this->employeedetails_model->checkPANExists($id); $response = ($query !== null && !empty($query)) ? $query[0]['PANNo'] : null; return $this->response->setJSON($response); @@ -445,11 +474,10 @@ class Employeedetails extends BaseController $id = $this->request->getPost('id'); //print_r($id); - + $query = $this->employeedetails_model->checkAadharExists($id); $response = ($query !== null && !empty($query)) ? $query[0]['AadharNo'] : null; return $this->response->setJSON($response); - } @@ -460,7 +488,7 @@ class Employeedetails extends BaseController $Empid = $this->request->getPost('employeeid'); $PanNo = $this->request->getPost('panno'); - + $query = $this->employeedetails_model->checkPANExists($PanNo, $Empid); if (count($query) > 0) { // $this->validator->setMessage('Pan_validate_emp', 'The Entered PAN Number is already exists in the Database.'); @@ -476,7 +504,7 @@ class Employeedetails extends BaseController { $Empid = $this->request->getPost('employeeid'); $AadharNo = $this->request->getPost('aadharno'); - + $query = $this->employeedetails_model->checkAadharExists($AadharNo, $Empid); if (count($query) > 0) { // $this->validator->setMessage('Aadhar_validate_emp', 'The Entered Aadhar Number is exists in the Database.'); @@ -487,36 +515,38 @@ class Employeedetails extends BaseController } } - + public function add($photo) - { - $picture = ''; + { + $picture = ''; - - if ($photo->isValid() && !$photo->hasMoved()) { - // Define upload directory and allowed file types - $uploadDir = ROOTPATH . 'public/uploads/images/'; - $allowedTypes = ['jpg', 'jpeg', 'png', 'gif']; - // Validate file type - if (in_array($photo->getExtension(), $allowedTypes)) { - // Generate unique file name - $newName = $photo->getRandomName(); - if(!is_dir($uploadDir)) { mkdir($uploadDir, 0777, true); } - // Move the uploaded file to the upload directory - $photo->move($uploadDir, $newName); + if ($photo->isValid() && !$photo->hasMoved()) { + // Define upload directory and allowed file types + $uploadDir = ROOTPATH . 'public/uploads/images/'; + $allowedTypes = ['jpg', 'jpeg', 'png', 'gif']; - $picture = $newName; - } else { - // Handle invalid file type - $picture = ''; - } + // Validate file type + if (in_array($photo->getExtension(), $allowedTypes)) { + // Generate unique file name + $newName = $photo->getRandomName(); + if (!is_dir($uploadDir)) { + mkdir($uploadDir, 0777, true); } + // Move the uploaded file to the upload directory + $photo->move($uploadDir, $newName); - return $picture; + $picture = $newName; + } else { + // Handle invalid file type + $picture = ''; + } } + return $picture; + } + function ViewEmployee($EmpNO = '') { @@ -533,7 +563,7 @@ class Employeedetails extends BaseController $DesignationConfigID = 'C010'; $BloodGroupConfigID = 'C011'; $LocationConfigID = 'C031'; - + //print_r('hai'); $data['GenderList'] = $this->employeedetails_model->getConfigValue($GenderConfigID); $data['MartialList'] = $this->employeedetails_model->getConfigValue($MartialConfigID); @@ -544,12 +574,12 @@ class Employeedetails extends BaseController $data['Location'] = $this->employeedetails_model->getConfigValue($LocationConfigID); $data['DepartmentList'] = $this->employeedetails_model->getDepartment(); $data['EmpDetails'] = $this->employeedetails_model->viewemployee($EmpID); - $data['emp_data'] = $this->empFiles->where('emp_id',$EmpID)->where('is_active',1)->findAll(); + $data['emp_data'] = $this->empFiles->where('emp_id', $EmpID)->where('is_active', 1)->findAll(); $data['empPay'] = $this->emppaydate_model->getEmpPayData($EmpID); $this->global['pageTitle'] = 'View Employee'; - $this->loadViews("editEmployee", $this->global, $data, NULL); + $this->loadViews("editEmployeenew", $this->global, $data, NULL); } /* To Check the email exists in the database or not for the employee*/ function checkMailEmp() @@ -573,7 +603,7 @@ class Employeedetails extends BaseController { $EmpId = $this->request->getPost('employeeid'); - + //$mail = $this->this->.post('emailid'); // $this->validator->setRules([ // 'ContactNumber'=> 'trim|required|min_length[10]|max_length[10]', @@ -598,174 +628,218 @@ class Employeedetails extends BaseController // $this->ViewEmployee($EmpId); // } else { - - $EmpId = $this->request->getPost('employeeid'); - $PictureName = $this->request->getPost('Image'); - $ModifyPictureName = $this->request->getPost('ModifyImage'); - $Picture = ""; - if ($PictureName != '') { - //echo 'Exists'; - //$Picture = $PictureName; - if (strlen((string)$ModifyPictureName) == 0) { - //echo 'Exists But Not replace'; - $Picture = $PictureName; - } else { - //echo 'Exists But Replace'; - //$Picture = $ModifyPictureName; - //$Picture = $this->editimage($ModifyPictureName); - $photo = $this->request->getFile('ModifyImage'); + + $EmpId = $this->request->getPost('employeeid'); + $PictureName = $this->request->getPost('Image'); + $ModifyPictureName = $this->request->getPost('ModifyImage'); + $Picture = ""; + if ($PictureName != '') { + + //echo 'Exists'; + //$Picture = $PictureName; + if (strlen((string)$ModifyPictureName) == 0) { + //echo 'Exists But Not replace'; + $Picture = $PictureName; + } else { + // echo "
";
+        // // print_r($this->request->getPost());
+        // print_r($this->request->getFile('photo'));
+        // die;
+        //echo  'Exists But Replace';
+        //$Picture = $ModifyPictureName;
+        //$Picture = $this->editimage($ModifyPictureName);  
+        $photo = $this->request->getFile('ModifyImage');
+        if (!$photo || !$photo->isValid()) {
+            $photo = $this->request->getFile('photo');
+        }
+        if (isset($photo)) {
           if ($photo->isValid() && !$photo->hasMoved()) {
             $uploadDir = ROOTPATH . 'public/uploads/images/';
             $allowedTypes = ['jpg', 'jpeg', 'png', 'gif'];
             if (in_array($photo->getExtension(), $allowedTypes)) {
-                $newName = $photo->getRandomName();
-                if(!is_dir($uploadDir)) { mkdir($uploadDir, 0777, true); }
-                $photo->move($uploadDir, $newName);
-                $Picture = $newName;
-            } 
+              $newName = $photo->getRandomName();
+              if (!is_dir($uploadDir)) {
+                mkdir($uploadDir, 0777, true);
+              }
+              $photo->move($uploadDir, $newName);
+              $Picture = $newName;
+            }
           }
         }
-      } else {
-        //echo  'Not Exists';
-        $photo = $this->request->getFile('photo');
+      }
+    } else {
+      //echo  'Not Exists';
+      $photo = $this->request->getFile('photo');
+      if (isset($photo)) {
         if ($photo->isValid() && !$photo->hasMoved()) {
           $uploadDir = ROOTPATH . 'public/uploads/images/';
           $allowedTypes = ['jpg', 'jpeg', 'png', 'gif'];
           if (in_array($photo->getExtension(), $allowedTypes)) {
-              $newName = $photo->getRandomName();
-              if(!is_dir($uploadDir)) { mkdir($uploadDir, 0777, true); }
-              $photo->move($uploadDir, $newName);
-              $Picture = $newName;
-          } 
+            $newName = $photo->getRandomName();
+            if (!is_dir($uploadDir)) {
+              mkdir($uploadDir, 0777, true);
+            }
+            $photo->move($uploadDir, $newName);
+            $Picture = $newName;
+          }
         }
       }
-      //echo  $Picture;         
+    }
+    //echo  $Picture;         
 
-      $FirstName = $this->request->getPost('FirstName');
-      $LastName = $this->request->getPost('LastName');
-      $FatherName = $this->request->getPost('FatherName');
-      $DateofBirth = $this->request->getPost('DateofBirth');
-      $ContactNumber = $this->request->getPost('ContactNumber');
-      $EmailId = $this->request->getPost('emailid');
-      $comEmailId = $this->request->getPost('comemailid');
-      $Gender =  $this->request->getPost('gender');
-      $MartialStatus =  $this->request->getPost('MartialStatus');
-      $BloodGroup =  $this->request->getPost('bloodgroup');
-      $CurrentAddress =  $this->request->getPost('currentaddress');
-      $permanentaddress =  $this->request->getPost('permanentaddress');
-      $emergencycontactname =  $this->request->getPost('emergencycontactname');
-      $emergencycontactnumber =  $this->request->getPost('emergencycontactnumber');
-      $desigination =  $this->request->getPost('desigination');
-      $departmentCode =  $this->request->getPost('departmentname');
-      $dateofjoining =  $this->request->getPost('dateofjoining');
-      //$Previousexperience =  $this->request->getPost('Previousexperience');
-      $pre_experience =  $this->request->getPost('Previousexperience');
+    $FirstName = $this->request->getPost('FirstName');
+    $LastName = $this->request->getPost('LastName');
+    $FatherName = $this->request->getPost('FatherName');
+    $DateofBirth = $this->request->getPost('DateofBirth');
+    $ContactNumber = $this->request->getPost('ContactNumber');
+    $EmailId = $this->request->getPost('emailid');
+    $comEmailId = $this->request->getPost('comemailid');
+    $Gender =  $this->request->getPost('gender');
+    $MartialStatus =  $this->request->getPost('MartialStatus');
+    $BloodGroup =  $this->request->getPost('bloodgroup');
+    $CurrentAddress =  $this->request->getPost('currentaddress');
+    $permanentaddress =  $this->request->getPost('permanentaddress');
+    $emergencycontactname =  $this->request->getPost('emergencycontactname');
+    $emergencycontactnumber =  $this->request->getPost('emergencycontactnumber');
+    $desigination =  $this->request->getPost('desigination');
+    $departmentCode =  $this->request->getPost('departmentname');
+    $dateofjoining =  $this->request->getPost('dateofjoining');
+    //$Previousexperience =  $this->request->getPost('Previousexperience');
+    $pre_experience =  $this->request->getPost('Previousexperience');
 
-      if ($pre_experience == '') {
-        $Previousexperience = null;
-      } else {
-        $Previousexperience = $pre_experience;
-      }
-      $eduqualifaction =  $this->request->getPost('eduqualifaction');
-      $addqualification = $this->request->getPost('addqualification');
-      $referredby = $this->request->getPost('referredby');
-      $referrercontno = $this->request->getPost('referrercontno');
-      $accountno = $this->request->getPost('accountno');
-      $ifsccode = $this->request->getPost('ifsccode');
-      $bankbranchname = $this->request->getPost('bankbranchname');
-      $bankaddress = $this->request->getPost('bankaddress');
-      $aadharno = $this->request->getPost('aadharno');
-      $panno = $this->request->getPost('panno');
-      $panno = $panno !== null && is_string($panno) ? strtoupper($panno) : null;
-      $passportno = $this->request->getPost('passportno');
-      $passportno = $passportno !== null && is_string($passportno) ? strtoupper($passportno) : null;
-      $ValidTill = $this->request->getPost('ValidTill');
-      $addinfo = $this->request->getPost('addinfo');
-      $driverlicense = $this->request->getPost('driverlicense');
-      $driverlicense = $driverlicense !== null && is_string($driverlicense) ? strtoupper($driverlicense) : null;
-      $licenseExpiryDate = $this->request->getPost('LicenseExpiryDate');
-      $VoterID = $this->request->getPost('voterID');
-      $VoterID = $VoterID !== null && is_string($VoterID) ? strtoupper($VoterID) : null;
-      $pfno = $this->request->getPost('pfno');
-      $pfno = $pfno !== null && is_string($pfno) ? strtoupper($pfno) : null;
-      //$uano = $this->request->getPost('uano'); 
-      $esino = $this->request->getPost('esino');
-      $Nominee = $this->request->getPost('nomineename');
-      $chked =  $this->request->getPost('isactive');
-      $is_management_team = $this->request->getPost('is_management_team');
-      $esi_applicable = $this->request->getPost('esi_applicable');
-      $pf_applicable = $this->request->getPost('pf_applicable');
-      $work_location = $this->request->getPost('work_location');
-      // echo 'chkvalue'.  $chked ;
-      if ($chked != '') {
-        $IsActive = '1';
-      } else {
-        $IsActive = '0';
-      }
-      // echo 'chkvalue'. $IsActive ;
-      $UpdatedBY = $this->session->get('userId');
+    if ($pre_experience == '') {
+      $Previousexperience = null;
+    } else {
+      $Previousexperience = $pre_experience;
+    }
+    $eduqualifaction =  $this->request->getPost('eduqualifaction');
+    $addqualification = $this->request->getPost('addqualification');
+    $referredby = $this->request->getPost('referredby');
+    $referrercontno = $this->request->getPost('referrercontno');
+    $accountno = $this->request->getPost('accountno');
+    $ifsccode = $this->request->getPost('ifsccode');
+    $bankbranchname = $this->request->getPost('bankbranchname');
+    $bankaddress = $this->request->getPost('bankaddress');
+    $aadharno = $this->request->getPost('aadharno');
+    $panno = $this->request->getPost('panno');
+    $panno = $panno !== null && is_string($panno) ? strtoupper($panno) : null;
+    $passportno = $this->request->getPost('passportno');
+    $passportno = $passportno !== null && is_string($passportno) ? strtoupper($passportno) : null;
+    $ValidTill = $this->request->getPost('ValidTill');
+    $addinfo = $this->request->getPost('addinfo');
+    $driverlicense = $this->request->getPost('driverlicense');
+    $driverlicense = $driverlicense !== null && is_string($driverlicense) ? strtoupper($driverlicense) : null;
+    $licenseExpiryDate = $this->request->getPost('LicenseExpiryDate');
+    $VoterID = $this->request->getPost('voterID');
+    $VoterID = $VoterID !== null && is_string($VoterID) ? strtoupper($VoterID) : null;
+    $pfno = $this->request->getPost('pfno');
+    $pfno = $pfno !== null && is_string($pfno) ? strtoupper($pfno) : null;
+    //$uano = $this->request->getPost('uano'); 
+    $esino = $this->request->getPost('esino');
+    $Nominee = $this->request->getPost('nomineename');
+    $chked =  $this->request->getPost('isactive');
+    $is_management_team = $this->request->getPost('is_management_team');
+    $esi_applicable = $this->request->getPost('esi_applicable');
+    $pf_applicable = $this->request->getPost('pf_applicable');
+    $work_location = $this->request->getPost('work_location');
+    // echo 'chkvalue'.  $chked ;
+    if ($chked != '') {
+      $IsActive = '1';
+    } else {
+      $IsActive = '0';
+    }
+    // echo 'chkvalue'. $IsActive ;
+    $UpdatedBY = $this->session->get('userId');
 
-      //$licenseExpiryDate =  get_date_time_format($licenseExpiryDate);
-      $DOB = get_date_format($DateofBirth);
-      $DOJ =  get_date_format($dateofjoining);
-      if ($ValidTill != '') {
-        $Valid =  get_date_format($ValidTill);
-      } else {
-        $Valid = null;
-      }
+    //$licenseExpiryDate =  get_date_time_format($licenseExpiryDate);
+    $DOB = get_date_format($DateofBirth);
+    $DOJ =  get_date_format($dateofjoining);
+    if ($ValidTill != '') {
+      $Valid =  get_date_format($ValidTill);
+    } else {
+      $Valid = null;
+    }
 
-      if ($licenseExpiryDate != '') {
-        $License_ExpiryDate =  get_date_format($licenseExpiryDate);
-      } else {
-        $License_ExpiryDate = null;
-      }
+    if ($licenseExpiryDate != '') {
+      $License_ExpiryDate =  get_date_format($licenseExpiryDate);
+    } else {
+      $License_ExpiryDate = null;
+    }
 
-      //echo $DOB;
-      $Employee = array(
-        'FirstName' => $FirstName, 'LastName' => $LastName, 'FatherName' => $FatherName, 'Gender' => $Gender,
-        'DateofBirth' => $DOB, 'ContactNumber' => $ContactNumber, 'EmailId' => $EmailId,
-        'BloodGroup' => $BloodGroup, 'MartialStatus' => $MartialStatus, 'DateofJoining' => $DOJ,
-        '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' => $Valid,
-        'IsActive' => $IsActive, 'ProfilePic' => $Picture, 'Reference_Name' => $referredby,
-        'Reference_ContactNumber' => $referrercontno, 'Remarks' => $addinfo, 'UpdatedBY' => $UpdatedBY,
-        'personalEmailId' => $comEmailId, 'DriverLicense' => $driverlicense, 'LicenseValidtill' => $License_ExpiryDate,
-        'VoterID' => $VoterID, 'PFNO' => $pfno, 'ESI' => $esino, 'NomineeDetails' => $Nominee,'is_management_team' => $is_management_team ,
-        'esi_applicable'=>$esi_applicable,'pf_applicable'=>$pf_applicable,'work_location'=>$work_location
-      );
-      //print_r($Employee);die();
-      $result = $this->employeedetails_model->UpdateEmployee($Employee, $EmpId);
+    // echo $DOB;die;
+    $Employee = array(
+      'FirstName' => $FirstName,
+      'LastName' => $LastName,
+      'FatherName' => $FatherName,
+      'Gender' => $Gender,
+      'DateofBirth' => $DOB,
+      'ContactNumber' => $ContactNumber,
+      'EmailId' => $EmailId,
+      'BloodGroup' => $BloodGroup,
+      'MartialStatus' => $MartialStatus,
+      'DateofJoining' => $DOJ,
+      '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' => $Valid,
+      'IsActive' => $IsActive,
+      'ProfilePic' => $Picture,
+      'Reference_Name' => $referredby,
+      'Reference_ContactNumber' => $referrercontno,
+      'Remarks' => $addinfo,
+      'UpdatedBY' => $UpdatedBY,
+      'personalEmailId' => $comEmailId,
+      'DriverLicense' => $driverlicense,
+      'LicenseValidtill' => $License_ExpiryDate,
+      'VoterID' => $VoterID,
+      'PFNO' => $pfno,
+      'ESI' => $esino,
+      'NomineeDetails' => $Nominee,
+      'is_management_team' => $is_management_team,
+      'esi_applicable' => $esi_applicable,
+      'pf_applicable' => $pf_applicable,
+      'work_location' => $work_location
+    );
+    //print_r($Employee);die();
+    $result = $this->employeedetails_model->UpdateEmployee($Employee, $EmpId);
 
-      // Get the uploaded files
-      $files = $this->request->getFiles();
-      $fileNames = $this->request->getPost('file_name'); // Get user-entered file names
-      if(isset($files['emp_file']))
-      {
+    // Get the uploaded files
+    $files = $this->request->getFiles();
+    $fileNames = $this->request->getPost('file_name'); // Get user-entered file names
+    if (isset($files['emp_file'])) {
       foreach ($files['emp_file'] as $index => $file) {
-          if ($file->isValid() && !$file->hasMoved()) {
-              // Move the file to the desired directory
-              $newName = $file->getRandomName();
-              $file->move(ROOTPATH . 'public/uploads/images/emp_files', $newName);
-              $path = ROOTPATH . 'public/uploads/images/emp_files/'.$newName;
-              // Store the file information in the database
-              $this->empFiles->save([
-                  'file_name' => $fileNames[$index], // User-entered file name
-                  'emp_file' => $newName, // New file name
-                  'emp_id' => $EmpId,
-                  'path' => $path
-                  
-              ]);
-          }
+        if ($file->isValid() && !$file->hasMoved()) {
+          // Move the file to the desired directory
+          $newName = $file->getRandomName();
+          $file->move(ROOTPATH . 'public/uploads/images/emp_files', $newName);
+          $path = ROOTPATH . 'public/uploads/images/emp_files/' . $newName;
+          // Store the file information in the database
+          $this->empFiles->save([
+            'file_name' => $fileNames[$index], // User-entered file name
+            'emp_file' => $newName, // New file name
+            'emp_id' => $EmpId,
+            'path' => $path
+
+          ]);
+        }
       }
     }
 
 
-   
+
     $Total_Salary = $this->request->getPost('Total_salary');
     $Basic_Pay = $this->request->getPost('Basic_Pay');
     $HRA_Rate = $this->request->getPost('HRA_Rate');
@@ -774,160 +848,159 @@ class Employeedetails extends BaseController
     $ESI_Rate = $this->request->getPost('ESI_Rate');
     $CreateBy =   $this->session->get('userId');
     $emppay = array('EmpID' => $EmpId, 'TotalSalary' => $Total_Salary, 'Basic_Pay' => $Basic_Pay, 'HRA_Rate' => $HRA_Rate, 'HRA_Amount' => $HRA_Amount,  'PF_Rate' => $PF_Rate, 'ESI_Rate' => $ESI_Rate, 'Created_By' => $CreateBy);
-  
+
 
     $empPayUpdate = $this->emppaydate_model->editemppay($emppay);
 
-      if ($result + $empPayUpdate > 0) {
-        $this->session->setFlashdata('success', 'You Have Successfully updated the Employee Record!');
-      } else {
-        $this->session->setFlashdata('error', 'Record Not Updated!');
-      }
-      return redirect()->route('employeeListing');
-
+    if ($result + $empPayUpdate > 0) {
+      $this->session->setFlashdata('success', 'You Have Successfully updated the Employee Record!');
+      return json_encode(true);
+    } else {
+      $this->session->setFlashdata('error', 'Record Not Updated!');
+      return json_encode(false);
+    }
+    // return redirect()->route('employeeListing');
   }
 
   function exportemployee()
-	{
-		
+  {
     $exportData = $this->employeedetails_model->export_excel();
 
-    $file_name = 'Employee_Details' .' '.  '.xls'; //save our workbook as this file name
-		$spreadsheet = new Spreadsheet();
-		$sheet = $spreadsheet->getActiveSheet();
-        $sheet->mergeCells('L3:S3');
-        $sheet->getStyle('L3')->getAlignment()->setHorizontal('center');    
-        $sheet->setTitle('Employee details');
+    $file_name = 'Employee_Details' . ' ' .  '.xls'; //save our workbook as this file name
+    $spreadsheet = new Spreadsheet();
+    $sheet = $spreadsheet->getActiveSheet();
+    $sheet->mergeCells('L3:S3');
+    $sheet->getStyle('L3')->getAlignment()->setHorizontal('center');
+    $sheet->setTitle('Employee details');
 
-        $headers = [
-          'L3'=>'RESICO Employee Details',
-          'A5'=>'EmpID',
-          'B5'=>'FirstName-LastName',
-          'C5'=>'FatherName',
-          'D5'=>'Gender',
-          'E5'=>'Date of Birth',
-          'F5'=>'ContactNumber',
-          'G5'=>'EmailId',
-          'H5'=>'BloodGroup',
-          'I5'=>'MartialStatus',
-          'J5'=>'DateofJoining',
-          'K5'=>'PreviousYearsOfExp',
-          'L5'=>'Designation',
-          'M5'=>'DepartmentName',
-          'N5'=>'PresentAddress',
-          'O5'=>'PermanentAddress',
-          'P5'=>'EmergencyContactName',
-          'Q5'=>'EmergencyContactNumber',
-          'R5'=>'Edu_Qualification',
-          'S5'=>'Additional_Qualification',
-          'T5'=>'Reference_Name',
-          'U5'=>'Reference_ContactNumber',
-          'V5'=>'BankStatemant',
-          'W5'=>'AadharNo',
-          'X5'=>'PANNo',
-          'Y5'=>'PassportNo',
-          'Z5'=>'Passport_Valid_till',
-          'AA5'=>'Voter ID',
-          'AB5'=>'Driving License',
-          'AC5'=>'Driving License Expiry Date',
-          'AD5'=>'Official Email ID',
-          'AE5'=>'IsActive',
-          'AF5'=>'PFNO',
-          'AG5'=>'ESI',
-          'AH5'=>'Nominee Details',
-          // 'AI5'=>'PF_Balance',
-          // 'AJ5'=>'PF_Bal_On',
-          'AI5'=>'Remarks',
-          'AJ5'=>'CreatedBy',
-          'AK5'=>'UpdatedBY'
+    $headers = [
+      'L3' => 'RESICO Employee Details',
+      'A5' => 'EmpID',
+      'B5' => 'FirstName-LastName',
+      'C5' => 'FatherName',
+      'D5' => 'Gender',
+      'E5' => 'Date of Birth',
+      'F5' => 'ContactNumber',
+      'G5' => 'EmailId',
+      'H5' => 'BloodGroup',
+      'I5' => 'MartialStatus',
+      'J5' => 'DateofJoining',
+      'K5' => 'PreviousYearsOfExp',
+      'L5' => 'Designation',
+      'M5' => 'DepartmentName',
+      'N5' => 'PresentAddress',
+      'O5' => 'PermanentAddress',
+      'P5' => 'EmergencyContactName',
+      'Q5' => 'EmergencyContactNumber',
+      'R5' => 'Edu_Qualification',
+      'S5' => 'Additional_Qualification',
+      'T5' => 'Reference_Name',
+      'U5' => 'Reference_ContactNumber',
+      'V5' => 'BankStatemant',
+      'W5' => 'AadharNo',
+      'X5' => 'PANNo',
+      'Y5' => 'PassportNo',
+      'Z5' => 'Passport_Valid_till',
+      'AA5' => 'Voter ID',
+      'AB5' => 'Driving License',
+      'AC5' => 'Driving License Expiry Date',
+      'AD5' => 'Official Email ID',
+      'AE5' => 'IsActive',
+      'AF5' => 'PFNO',
+      'AG5' => 'ESI',
+      'AH5' => 'Nominee Details',
+      // 'AI5'=>'PF_Balance',
+      // 'AJ5'=>'PF_Bal_On',
+      'AI5' => 'Remarks',
+      'AJ5' => 'CreatedBy',
+      'AK5' => 'UpdatedBY'
+    ];
+
+    foreach ($headers as $cell => $value) {
+      $sheet->setCellValue($cell, $value);
+      $sheet->getStyle($cell)->getFont()->setSize($cell == 'L3' ? 14 : 12);
+      $sheet->getStyle($cell)->getFont()->setBold(true);
+    }
+
+    if ($exportData) {
+      $i = 6;
+      $s = 1;
+      foreach ($exportData as $data) {
+        $rowData = [
+          'A' . $i,
+          $data['EmpID'],
+          'B' . $i => $data['FirstName'] . '-' . $data['LastName'],
+          'C' . $i => $data['FatherName'],
+          'D' . $i => $data['Gender'],
+          'E' . $i => $data['DateofBirth'],
+          'F' . $i => $data['ContactNumber'],
+          'G' . $i => $data['EmailId'],
+          'H' . $i => $data['BloodGroup'],
+          'I' . $i => $data['MartialStatus'],
+          'J' . $i => $data['DateofJoining'],
+          'K' . $i => $data['PreviousYearsOfExp'],
+          'L' . $i => $data['Designation'],
+          'M' . $i => $data['DepartmentName'],
+          'N' . $i => $data['PresentAddress'],
+          'O' . $i => $data['PermanentAddress'],
+          'P' . $i => $data['EmergencyContactName'],
+          'Q' . $i => $data['EmergencyContactNumber'],
+          'R' . $i => $data['Edu_Qualification'],
+          'S' . $i => $data['Additional_Qualification'],
+          'T' . $i => $data['Reference_Name'],
+          'U' . $i => $data['Reference_ContactNumber'],
+          'V' . $i => $data['BankAccountNo'] . '-' . $data['IFSCCode'] . '-' . $data['BankBranchName'] . $data['BankAddress'],
+          'W' . $i => $data['AadharNo'],
+          'X' . $i => $data['PANNo'],
+          'Y' . $i => $data['PassportNo'],
+          'Z' . $i => $data['Passport_Valid_till'],
+          'AA' . $i => $data['VoterID'],
+          'AB' . $i => $data['DriverLicense'],
+          'AC' . $i => $data['LicenseValidtill'],
+          'AD' . $i => $data['personalEmailId'],
+          'AE' . $i => $data['IsActive'],
+          'AF' . $i => $data['PFNO'],
+          'AG' . $i => $data['ESI'],
+          'AH' . $i => $data['NomineeDetails'],
+          // 'AI'. $i=>$data['PF_Balance'],
+          // 'AJ'. $i=>$data['PF_Bal_On'],
+          'AI' . $i => $data['Remarks'],
+          'AJ' . $i => $data['CreatedByName'],
+          'AK' . $i => $data['UpdatedByName'],
         ];
-        
-        foreach ($headers as $cell => $value) {
-            $sheet->setCellValue($cell, $value);
-            $sheet->getStyle($cell)->getFont()->setSize($cell == 'L3' ? 14 : 12);
-            $sheet->getStyle($cell)->getFont()->setBold(true);
+
+        foreach ($rowData as $cell => $value) {
+          $sheet->setCellValue($cell, $value);
         }
 
-        if($exportData){
-            $i = 6;$s = 1;
-            foreach ($exportData as $data) {
-                $rowData = [
-                  'A'. $i,$data['EmpID'],
-                  'B'. $i=>$data['FirstName'].'-'.$data['LastName'],
-                  'C'. $i=>$data['FatherName'],
-                  'D'. $i=>$data['Gender'],
-                  'E'. $i=>$data['DateofBirth'],
-                  'F'. $i=>$data['ContactNumber'],
-                  'G'. $i=>$data['EmailId'],
-                  'H'. $i=>$data['BloodGroup'],
-                  'I'. $i=>$data['MartialStatus'],
-                  'J'. $i=>$data['DateofJoining'],
-                  'K'. $i=>$data['PreviousYearsOfExp'],
-                  'L'. $i=>$data['Designation'],
-                  'M'. $i=>$data['DepartmentName'],
-                  'N'. $i=>$data['PresentAddress'],
-                  'O'. $i=>$data['PermanentAddress'],
-                  'P'. $i=>$data['EmergencyContactName'],
-                  'Q'. $i=>$data['EmergencyContactNumber'],
-                  'R'. $i=>$data['Edu_Qualification'],
-                  'S'. $i=>$data['Additional_Qualification'],
-                  'T'. $i=>$data['Reference_Name'],
-                  'U'. $i=>$data['Reference_ContactNumber'],
-                  'V'. $i=>$data['BankAccountNo'].'-'.$data['IFSCCode'].'-'.$data['BankBranchName'].$data['BankAddress'],
-                  'W'. $i=>$data['AadharNo'],
-                  'X'. $i=>$data['PANNo'],
-                  'Y'. $i=>$data['PassportNo'],
-                  'Z'. $i=>$data['Passport_Valid_till'],
-                  'AA'. $i=>$data['VoterID'],
-                  'AB'. $i=>$data['DriverLicense'],
-                  'AC'. $i=>$data['LicenseValidtill'],
-                  'AD'. $i=>$data['personalEmailId'],
-                  'AE'. $i=>$data['IsActive'],
-                  'AF'. $i=>$data['PFNO'],
-                  'AG'. $i=>$data['ESI'],
-                  'AH'. $i=>$data['NomineeDetails'],
-                  // 'AI'. $i=>$data['PF_Balance'],
-                  // 'AJ'. $i=>$data['PF_Bal_On'],
-                  'AI'. $i=>$data['Remarks'],
-                  'AJ'. $i=>$data['CreatedByName'],
-                  'AK'. $i=>$data['UpdatedByName'],
-                ];
-
-                foreach ($rowData as $cell => $value) {
-                    $sheet->setCellValue($cell, $value);
-                }
-
-                $i++;
-                $s++;
-            }
-
-        }
-		// $writer = new Xlsx($spreadsheet);
-		// $writer->save($file_name);
-		// header("Content-Type: application/vnd.ms-excel");
-		// header('Content-Disposition: attachment; filename="' . basename($file_name) . '"');
-		// header('Expires: 0');
-		// header('Cache-Control: must-revalidate');
-		// header('Pragma: public');
-		// header('Content-Length:' . filesize($file_name));
-		// flush();
-		// readfile($file_name);
-		// exit;
+        $i++;
+        $s++;
+      }
+    }
+    // $writer = new Xlsx($spreadsheet);
+    // $writer->save($file_name);
+    // header("Content-Type: application/vnd.ms-excel");
+    // header('Content-Disposition: attachment; filename="' . basename($file_name) . '"');
+    // header('Expires: 0');
+    // header('Cache-Control: must-revalidate');
+    // header('Pragma: public');
+    // header('Content-Length:' . filesize($file_name));
+    // flush();
+    // readfile($file_name);
+    // exit;
     // Clear the output buffer to prevent any other output
     ob_clean();
 
     $writer = new Xlsx($spreadsheet);
-    
+
 
     header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
-    header('Content-Disposition: attachment;filename="'. $file_name .'"');
+    header('Content-Disposition: attachment;filename="' . $file_name . '"');
     header('Cache-Control: max-age=0');
     header('Expires: 0');
     header('Pragma: public');
 
     $writer->save('php://output');
     exit;
-	}
-
-
   }
+}
diff --git a/app/Controllers/Emppaydate.php b/app/Controllers/Emppaydate.php
index 98423449..d71c129b 100644
--- a/app/Controllers/Emppaydate.php
+++ b/app/Controllers/Emppaydate.php
@@ -78,12 +78,6 @@ class Emppaydate extends BaseController
 
     function addNewemppay()
     {
-
-
-       
-      
-       
-
             $EmpID = $this->request->getPost('EmpID');
             $Loan_Amount = $this->request->getPost('Loan_Amount');
             $Load_Issued_date = $this->request->getPost('loan_issued_date');
@@ -96,13 +90,9 @@ class Emppaydate extends BaseController
             $Remaining_Due = $this->request->getPost('remaining_due');
             $Paid_Amount = $this->request->getPost('Paid_Amount');
             $CreateBy =   $this->session->get('userId');
-          
 
-          
             $loandetails = array('EmpID' => $EmpID, 'Loan_Amount' => $Loan_Amount, 'Loan_Issued_Date' => $Load_Issued_date, 'Monthly_Due' => $Due_Amount, 'Due_Start_Date' => $Due_Started, 'No_of_Dues' => $No_Of_Dues, 'Paid_Due' => $Paid_due, 'Remaining_Due' => $Remaining_Due, 'Paid_Amount' => $Paid_Amount, 'is_Active' => 1, 'Created_By' => $CreateBy);
 
-
-         
             if ($Loan_Amount != 0) {
                 $result2 = $this->emppaydate_model->addLoanInfo($loandetails, 'add');
                 if ($result2 > 0) {
@@ -111,8 +101,8 @@ class Emppaydate extends BaseController
                     echo "";
                 }
             }
-         
 
+            return redirect()->to('/emppayListings');
     }
 
     /**
@@ -123,6 +113,7 @@ class Emppaydate extends BaseController
 
         $data['emppay'] = $this->emppaydate_model->getUserInfo($paydataid);
 
+        // print_r($data);die;
 
         $this->global['pageTitle'] = 'Edit Employee Pay Monthly Details ';
 
@@ -151,16 +142,9 @@ class Emppaydate extends BaseController
             $Remaining_Due = $this->request->getPost('remaining_due');
             $Paid_Amount = $this->request->getPost('Paid_Amount');
             $Last_Mod_By = $this->session->get('userId');
-         
-
-
-
-
-
           
             $loandetails = array('Loan_ID' => $loan_ID, 'EmpID' => $EmpID, 'Loan_Amount' => $Loan_Amount, 'Loan_Issued_Date' => $Load_Issued_date, 'Monthly_Due' => $Due_Amount, 'Due_Start_Date' => $Due_Started, 'No_of_Dues' => $No_Of_Dues, 'Paid_Due' => $Paid_due, 'Remaining_Due' => $Remaining_Due, 'Paid_Amount' => $Paid_Amount, 'is_Active' => 1, 'Last_Mod_By' => $Last_Mod_By);
 
-
             if ($Loan_Amount != 0 and $loan_ID != '') {
                 $result2 = $this->emppaydate_model->addLoanInfo($loandetails, 'update');
                 if ($result2 > 0) {
@@ -177,19 +161,16 @@ class Emppaydate extends BaseController
                     echo "";
                 }
             }
-
-
-         
-
+            return redirect()->to('/emppayListings');
     }
 
 
 
     function deleteEmpPay()
     {
-        $EmpID = $this->request->getPost('id');
+        $LoanID = $this->request->getPost('id');
         //echo $EmpID; 
-        $result = $this->emppaydate_model->deleteEmployeePay($EmpID);
+        $result = $this->emppaydate_model->deleteEmployeePay($LoanID);
         if ($result == 1) {
             echo "Deleted Sucessfully..!";
         } else {
diff --git a/app/Controllers/Login.php b/app/Controllers/Login.php
index 410c9767..683ac74c 100644
--- a/app/Controllers/Login.php
+++ b/app/Controllers/Login.php
@@ -37,7 +37,9 @@ class Login extends BaseController
             return view('login');
         } else {
             // redirect('/dashboard');
-            return redirect()->to('/dashboard');
+            // return redirect()->to('/dashboard');
+            return redirect()->to('/sales_dashboard');
+            
         }
         
     }
@@ -53,7 +55,9 @@ class Login extends BaseController
             return view('login');
         } else {
             // return view('login');
-            return redirect()->to('/dashboard');
+            // return redirect()->to('/dashboard');
+            return redirect()->to('/sales_dashboard');
+
         }
     }
 
@@ -107,9 +111,11 @@ class Login extends BaseController
                 $DEPCode = $res->DEPCode;
 
                 if ($DEPCode == SECURITY) {
-                    return redirect()->to(site_url('/dashboard'));
+                    // return redirect()->to(site_url('/dashboard'));
+                    return redirect()->to(site_url('/sales_dashboard'));
                 } else {
-                    return redirect()->to(site_url('/dashboard'));
+                    return redirect()->to(site_url('/sales_dashboard'));
+                    // return redirect()->to(site_url('/dashboard'));
                 }
             }
         } else {
diff --git a/app/Controllers/Payslip.php b/app/Controllers/Payslip.php
index 1090edb5..b0b94253 100644
--- a/app/Controllers/Payslip.php
+++ b/app/Controllers/Payslip.php
@@ -61,12 +61,84 @@ class Payslip extends BaseController
 	public function callsp()
 	{
 
-		$payon = $this->request->getPost('payon');
-		$employee = $this->request->getPost('employee');
-		$result = $this->payroll_model->model_sp($payon, $employee);
-		// $result = $this->db->last_query();
-		return $result;
-		//$this->db->call_function('model_sp');
+		// $result = $this->payroll_model->model_sp($this->request->getPost('payon'), $this->request->getPost('employee'));
+		// return $result;
+		// die;
+
+		$PayOn = $this->request->getPost('payon');
+		$EmpId = $this->request->getPost('employee');
+   
+		$res = $this->payroll_model->getMonthlyPayDetails($EmpId, $PayOn);
+		$result = $res[0];
+		$loan = [];
+		$loanHistory = [];
+		$loan_id = 0;
+		if(is_null($result->Loan_ID)){
+  			
+		}else{
+			if($result->Loan_Recovered > 0)
+			{
+				$loan_id = $result->Loan_ID;
+
+				$loan = [
+					'Paid_Due' => $result->Paid_Due + 1,
+					'Remaining_Due' => $result->Remaining_Due - 1,
+					'Paid_Amount' => $result->Paid_Amount + $result->Loan_Recovered,
+				];
+
+				$loanHistory = [
+					'Loan_ID' => $loan_id,
+					'Due_Amount' => $result->Loan_Recovered,
+					'Balance_Amount' => $result->Loan_Amount - ($result->Paid_Amount + $result->Loan_Recovered),
+					'Due_Date' => $PayOn,
+				];
+
+				
+
+			}
+		}
+		// print_r($data);die;
+
+		$data = [
+			'PayOn' => $result->Month_Year,
+			'EmpID' => $result->EmpID,
+			'TotalCalDays' => $result->TotalCalDays,
+			'NoofDaysWorked' => $result->Days_worked,
+			'LOP' => $result->LOP_Days,
+			'Paid_Leave' => $result->Paid_leave,
+			'ActualSalary' => $result->ActualSalary,
+			'PerDaySalary' => $result->PerDaySalary,
+			'WorkedSalary' => $result->WorkedSalary,
+			'Basic' => $result->Basic,
+			'HRA' => $result->HRA,
+			'OT_Hrs_Worked' => $result->OT_Hrs_Worked,
+			'OTSalary' => $result->OTSalary,
+			'ESI' => $result->ESI,
+			'PF' => $result->PF,
+			'OtherDeductions' => $result->Other_Deductions,
+			'Festival_Bonus' => $result->Festival_Bonus,
+			'TotalSalary' => $result->Estimate,
+			'Advance' => $result->Loan_Recovered,
+			'BalanceAdvance' => 0,
+			'LessAdvance' => 0,
+			'BankAccountNumber' => $result->BankAccountNo,
+			'PFNumber' => $result->PFNO,
+			'ESINumber' => $result->ESINO,
+			'UANNO' => $result->PFNO,
+		];
+
+		
+		$insert = $this->payroll_model->insertPayroll($data);
+        if($insert){
+			if(count($loan)){
+				$this->payroll_model->updateLoan($loan_id,$result->EmpID,$loan);
+			}
+			if(count($loanHistory)){
+				$this->payroll_model->insertLoanHistory($loanHistory);
+			}
+		}
+		return $insert;
+		
 
 	}
 
@@ -615,9 +687,9 @@ class Payslip extends BaseController
 			// die;
 
 			$employeeSalary[] = round($salaryInCurrentday);
-			$esi[] = number_format($esiAmount,2);
-			$pf[] = number_format($pfAmount,2);
-			$ot[] = number_format($totSalayOT,2);
+			$esi[] = number_format($esiAmount,2, '.', '');
+			$pf[] = number_format($pfAmount,2, '.', '');
+			$ot[] = number_format($totSalayOT,2, '.', '');
 		}
 		$data['empSalary'] = $employeeSalary;
 		$data['esi'] = $esi;
@@ -638,7 +710,7 @@ class Payslip extends BaseController
 		$data['month'] = $this->monthlypay_model->monthlyListing($current);
 		$data['dropdownvalue'] = $current;
 		$data['fresh'] = $this->monthlypay_model->getEmpPayDetailsforMonthInputs($current);
-		//dd($data['fresh']);
+		// dd($data['fresh']);
 		
 		
 		$employeeSalary = [];
@@ -750,9 +822,9 @@ class Payslip extends BaseController
 			// die;
 
 			$employeeSalary[] = round($salaryInCurrentday);
-			$esi[] = number_format($esiAmount,2);
-			$pf[] = number_format($pfAmount,2);
-			$ot[] = number_format($totSalayOT,2);
+			$esi[] = number_format($esiAmount,2, '.', '');
+			$pf[] = number_format($pfAmount,2, '.', '');
+			$ot[] = number_format($totSalayOT,2, '.', '');
 		}
 		$data['empSalary'] = $employeeSalary;
 		$data['esi'] = $esi;
@@ -863,11 +935,7 @@ class Payslip extends BaseController
 					}
 				}
 
-				// $Incentives_first = explode(".", $Incentives);
-				// if (!is_numeric($Incentives) || (strlen((string)$Incentives)) > 8 || (strlen((string)$Incentives_first[0])) > 5) {
-				// 	//echo $EmpID . "-Loan Recoverd Invalid Data!";
-				// 	$ErrorFlag++;
-				// }
+				
 
 				$Festivalbonus_first = explode(".", $Festival_Bonus);
 				if (!is_numeric($Festival_Bonus) || (strlen((string)$Festival_Bonus)) > 8 || (strlen((string)$Festivalbonus_first[0])) > 5) {
@@ -905,26 +973,53 @@ class Payslip extends BaseController
 				
 				$EmpID = $j['Emp ID'];
 				$DaysWorked = $j['Days Worked'];
+				$TotalCalDays =  isset($j['Total Days']) ? $j['Total Days'] : 0.00 ;
+				$ActualSalary =  isset($j['Basic Salary']) ? $j['Basic Salary'] : 0.00 ;
+				$WorkedSalary =  isset($j['Worked Salary']) ? $j['Worked Salary'] : 0.00 ;
+				$PerDaySalary =  isset($j['Pre Day Salary']) ? $j['Pre Day Salary'] : 0.00 ;
+				$Basic =  isset($j['Basic Salary(0.7)']) ? $j['Basic Salary(0.7)'] : 0.00 ;
+				$HRA =  isset($j['HRA Salary(0.3)']) ? $j['HRA Salary(0.3)'] : 0.00 ;
+				$OTSalary =  isset($j['Over Time']) ? $j['Over Time'] : 0.00 ;
+				$ESI =  isset($j['ESI']) ? $j['ESI'] : 0.00 ;
+				$PF =  isset($j['PF']) ? $j['PF'] : 0.00 ;
 				$LOP_Days =  isset($j['LOP Days']) ? $j['LOP Days'] : 0.00;
 				$Paid_leave =   isset($j['Paid Leave']) ? $j['Paid Leave'] : 0.00;
 				$OT_Hrs_Worked =   isset($j['OT Hrs']) ? $j['OT Hrs'] : 0.00;
 				$Loan_Recovered =  isset($j['Auto Loan Due ₹']) ? $j['Auto Loan Due ₹'] : 0.00;
-				// if (is_string($Loan_Recovered)) {
-				// 	$Loan_Recovered = strtoupper($Loan_Recovered);
-				// }
-				// $Incentives =  isset($j['Incentives in ₹']) ? $j['Incentives in ₹'] : 0.00 ;
+				
 				$Festival_Bonus = isset($j['Festival Bonus in ₹']) ? $j['Festival Bonus in ₹'] : 0.00;
 				$tds_Deductions = isset($j['TDS Deductions in ₹']) ? $j['TDS Deductions in ₹'] : 0.00;
 				$Estimate = isset($j['Estimate in ₹']) ? $j['Estimate in ₹'] : 0.00;
 				$Created_By = $this->session->get('userId');
 
-				$monthlypaydata = array('Month_Year' => $month, 'EmpID' => $EmpID, 'Days_worked' => $DaysWorked, 'LOP_Days' => $LOP_Days, 'Paid_leave' => $Paid_leave, 'OT_Hrs_Worked' => $OT_Hrs_Worked,  'Festival_Bonus' => $Festival_Bonus, 'Other_Deductions' => $tds_Deductions, 'Estimate' => $Estimate, 'Created_By' => $Created_By ,'Loan_Recovered'=>$Loan_Recovered);
+				$monthlypaydata = array(
+					'Month_Year'       => $month,
+					'EmpID'            => $EmpID,
+					'Days_worked'      => $DaysWorked,
+					'LOP_Days'         => $LOP_Days,
+					'Paid_leave'       => $Paid_leave,
+					'OT_Hrs_Worked'   => $OT_Hrs_Worked,
+					'Festival_Bonus'   => $Festival_Bonus,
+					'Other_Deductions' => $tds_Deductions,
+					'Estimate'         => $Estimate,
+					'Created_By'       => $Created_By,
+					'Loan_Recovered'   => $Loan_Recovered,
+					'TotalCalDays'   => $TotalCalDays,
+					'ActualSalary'   => $ActualSalary,
+					'WorkedSalary'   => $WorkedSalary,
+					'PerDaySalary'   => $PerDaySalary,
+					'Basic'   => $Basic,
+					'HRA'   => $HRA,
+					'OTSalary'   => $OTSalary,
+					'ESI'   => $ESI,
+					'PF'   => $PF,
+				);
 				// print_r($monthlypaydata);	die;
 				$result = $this->monthlypay_model->saveMonthlyData_model($monthlypaydata);
 				$total = $total + $result;
 			}
 		}
-		$total = $total - 1;
+		
 		//echo "";
 		if (!empty($ErrorEmpId)) {
 			echo $ErrorEmpId . "- are have Invalid Data!";
@@ -1018,63 +1113,55 @@ class Payslip extends BaseController
 	public function PrintPdf()
 	{
 
+
+		        // $EmpID = 'RIPL056';
+			    // $Payon = '08-2024';
+				// $m = date("M", mktime(0, 0, 0, (int)$Payon, 10));
+				// $y = substr((string)$Payon, 3);
+				// //echo "EmpID" . $EmpID;
+				// $Data['PayDetails'] = $this->payroll_model->GetPayslipdata($Payon, $EmpID);
+
+				// $fname = $Data['PayDetails'][0]->FName;
+				// $filename = 'PayslipFor-' . $EmpID . ' ' . $fname . ' ' . $m . ' ' . $y;
+
+				// $totalsalary = $Data['PayDetails'][0]->TotalSalary;
+				// $totalsalaryinwords = $this->convertNumber(round($totalsalary));
+				// $Data['amtinwords'] = $totalsalaryinwords;
+				// // dd ($Data);
+				// echo  view("payslipgenerateprint",  $Data);
+				// die;
+
 		$filename = " ";
 		$html = "";
 		$All = $this->request->getPost('All');
-		// if ($All == '') {
-        //     $this->validator->setRules([
-        //         'Employee' => [
-        //             'label' => 'Employee',
-        //             'rules' => 'trim|callback_Employee_validate',
-        //         ]
-        //     ]);
-        // }
 
-		// $this->validator->setRules([
-        //     'PayOn' => [
-        //         'label' => 'PayOn',
-        //         'rules' => 'trim|callback_PayOn_validate',
-        //     ]
-        // ]);
-
-		// if ($this->validator->run() == FALSE) {
-		// 	$this->viewGenerator();
-		// } else {
 			$Payon = $this->request->getPost('PayOn');
 
 			$m = date("M", mktime(0, 0, 0, (int)$Payon, 10));
-			//$y =date("Y",mktime(0, 0, 0, $Payon, 10));
-			//$m=date("M-Y",mktime(0,0,0,$month,1,$year));
+			
 			$y = substr((string)$Payon, 3);
-			//echo "Payon" . $Payon;			
+					
 
 			if ($All != '') {
 				$filename = 'PayslipFor-' . $m . '-' . $y;
 				$result = $this->payroll_model->getEmpAll($Payon);
-				// print_r($result);
-				// die();
-
+				
 				if ($result > 0) {
 					for ($i = 0; $i < count($result); $i++) {
 
 						$EmpID =  $result[$i]['EmpId'];
-						//print_r( 
-						//$EmpID );
-						// die();
+						
 						$Data['PayDetails'] = $this->payroll_model->GetPayslipdata($Payon, $EmpID);
-						//
+						
 
 						$totalsalary = $Data['PayDetails'][0]->LessAdvance;
 						$totalsalaryinwords = $this->convertNumber(round($totalsalary));
 						$Data['amtinwords'] = $totalsalaryinwords;
-						// print_r ($Data);
-						// exit();
-						//$Data['Count'] = $i;
+						
 
 						$html .= view("payslipgenerateprint", $Data);
 
-						// print_r ($Data);
-						// exit();	
+						
 					}
 				}
 			} else {
@@ -1088,45 +1175,12 @@ class Payslip extends BaseController
 				$totalsalary = $Data['PayDetails'][0]->LessAdvance;
 				$totalsalaryinwords = $this->convertNumber(round($totalsalary));
 				$Data['amtinwords'] = $totalsalaryinwords;
-				//print_r ($Data);
-				//exit();
+				// print_r ($Data);
+				// exit();
 				$html = view("payslipgenerateprint",  $Data);
 			}
 
 
-			// $php  = $this->output->get_output();		
-
-			// // Load library
-			//  $this->load->library('dompdf_gen');
-
-			// 	if($All != '')
-			// 	{
-			// 		$filename = 'Payslip-'.$Payon.'.pdf' ;
-			// 	}
-			// 	else
-			// 	{
-			// 		$filename = 'Payslip-'.$EmpID . '-' .$Payon.'.pdf' ;
-			// 	}
-
-			// require_once(APPPATH .'third_party/dompdf/dompdf_config.inc.php');
-			// $dompdf = new DOMPDF();
-			// $dompdf->set_paper('A4', 'portrait');
-			// $dompdf->load_html($php);
-
-			// $dompdf->render();
-
-			// // add the header
-			// $canvas = $dompdf->get_canvas();
-			// $font = Font_Metrics::get_font("helvetica", "bold");
-
-			// // the same call as in my previous example
-			// $canvas->page_text(72, 18, "Page: {PAGE_NUM} of {PAGE_COUNT}",
-			//        $font, 6, array(0,0,0));
-
-			// $dompdf->stream($filename); 
-			// }
-
-			// $mpdf = new mPDF('utf-8', 'A4-P', 10, 10, 10, 10, 10, 24, 4, 6);
 			$mpdf = new Mpdf([
 				'mode' => 'utf-8',
 				'format' => 'A4-P',
@@ -1147,7 +1201,7 @@ class Payslip extends BaseController
 			$mpdf->SetTitle('Resico:Payslip');
 
        		 $mpdf->Output("Payslip-" . $filename . ".pdf", 'D');
-		//  }
+		
 	}
 
 	function updatePayslip()
diff --git a/app/Controllers/Sales.php b/app/Controllers/Sales.php
index 01c0cf1a..a7f60b98 100644
--- a/app/Controllers/Sales.php
+++ b/app/Controllers/Sales.php
@@ -5,18 +5,21 @@ namespace App\Controllers;
 use App\Controllers\BaseController;
 
 use App\Models\Ipinvoice_model;
+use App\Models\Ipattachment_model;
 require_once 'vendor/autoload.php';
 
 
 class Sales extends BaseController
 {
     protected  $ipinvoice_model;
+    protected  $ipattachment_model;
     protected $session;
 
     public function __construct()
     {
         parent::__construct();
         $this->ipinvoice_model = new Ipinvoice_model();
+        $this->ipattachment_model = new Ipattachment_model();
         $this->session = session();
         $this->isLoggedIn();
     }
@@ -91,8 +94,7 @@ class Sales extends BaseController
     
     // Invoice Attachments 
     function getInvoiceAttachments(){
-            $data['invoiceAttachment'] = $this->ipinvoice_model->getinvoiceAttachment($this->request->getGet('invoice_id'));
-
+            $data['invoiceAttachment'] = $this->ipinvoice_model->getinvoiceAttachment($this->request->getGet('invoice_number'));
             return json_encode($data);
     }
     
diff --git a/app/Controllers/User.php b/app/Controllers/User.php
index c3f79358..b0640664 100644
--- a/app/Controllers/User.php
+++ b/app/Controllers/User.php
@@ -7,12 +7,14 @@ use App\Controllers\BaseController;
 use CodeIgniter\Validation\Exceptions\ValidationException;
 
 use App\Models\Costcenter_model;
+use App\Models\Department_model;
 use App\Models\Dashboard_model;
 use App\Models\Employeedetails_model;
 use App\Models\User_model;
 use App\Models\Ipinvoice_model;
 use App\Models\Ipattachment_model;
 use App\Models\Zohobooks_api_model;
+
 require_once 'vendor/autoload.php';
 
 /**
@@ -26,6 +28,7 @@ require_once 'vendor/autoload.php';
 class User extends BaseController
 {
     protected  $costcenter_model;
+    protected  $department_model;
     protected  $dahsboard_Model;
     protected  $employeedetails_model;
     protected  $user_model;
@@ -39,9 +42,10 @@ class User extends BaseController
     public function __construct()
     {
         parent::__construct();
-        
+
         $this->dahsboard_Model = new Dashboard_model();
         $this->costcenter_model = new Costcenter_model();
+        $this->department_model = new Department_model();
         $this->employeedetails_model = new employeedetails_model();
         $this->user_model = new User_model();
         $this->ipinvoice_model = new Ipinvoice_model();
@@ -59,7 +63,7 @@ class User extends BaseController
         $this->global['pageTitle'] = 'Dashboard';
 
         log_message('error', '#####Dashboard session name : ' . $this->session->get('name'));
-        
+
         $data['EmpCount'] = $this->employeedetails_model->getEmployeeCount();
 
         $data['UserCount'] = $this->dahsboard_Model->getUserCount();
@@ -104,20 +108,20 @@ class User extends BaseController
 
         $data['capitalbud'] = $this->dahsboard_Model->capitalbud();
 
-        $data['typebal'] = [];// $this->dahsboard_Model->typebal();
+        $data['typebal'] = []; // $this->dahsboard_Model->typebal();
 
 
         /* HR DASHBOARD Controller Start*/
         $data['totemp'] = $this->dahsboard_Model->totemp();
-        
+
         $data['totloan'] = $this->dahsboard_Model->totloan();
-        
+
         $data['totpay'] = $this->dahsboard_Model->totpay();
-        
+
         $data['totrec'] = $this->dahsboard_Model->totrec();
-        
+
         $data['emplist'] = $this->dahsboard_Model->emplist();
-        
+
 
         $date = $this->request->getPost("id");
         $dates = date('Y-m');
@@ -250,13 +254,12 @@ class User extends BaseController
         $working = array();
         $overtime = array();
         //$holid = array();
-        for ($i = 1; $i <= $dat; $i++) 
-        {
+        for ($i = 1; $i <= $dat; $i++) {
             $Working[] = 'WH' . $i;
             $overtime[] = 'OT' . $i;
 
             $CUR_month = date('t');
-            
+
             // foreach ($holiday as $value)
             //     {
             //        //$holid []= 'WH'.$value;
@@ -266,7 +269,7 @@ class User extends BaseController
             //     }
 
         }
-        
+
         $WH = implode(",", $Working);
 
         $OT = implode(",", $overtime);
@@ -312,19 +315,19 @@ class User extends BaseController
                         /**one hour salay ot calculation**/
                         $totSalayOT = ($totalothour != 0) ? $totalothour * $onehoursSalary : 0;
                         /** if ot not equal zero **/
-                        
+
                         $currentDaySalary = $daySalary * $values;
                         /** current day salary working days calculation**/
 
                         $currentDayHra = $dayHra * $values;
                         /** total working days hra calculations**/
-                        
+
                         $currentDatePF = $currentDaySalary + $currentDayHra + $totSalayOT;
                         /** current date pf calculation**/
-                        
+
                         $esiAmount = ($totalsalary <= 20000) ? $currentDatePF * 1.75 / 100 : 0;
                         /** esiamount not elgiable for 20000 **/
-                        
+
                         $pfAmount = $currentDaySalary * 12 / 100;
                         /** pf amount per day**/
 
@@ -335,7 +338,7 @@ class User extends BaseController
 
                         $totalSalary = round($totalSalarys);
                         // $salarycurrentdate[] = $salaryInCurrentday;;
-                        
+
                     }
                 }
             }
@@ -360,7 +363,7 @@ class User extends BaseController
         $WH = 'WH' . date('j', strtotime("-1 days"));
 
         $yesterday = $this->dahsboard_Model->attyesterday($WH, $date);
-        
+
         $values = 0;
         foreach ($yesterday as $weekda => $value) {
 
@@ -369,28 +372,28 @@ class User extends BaseController
                 $values++;
             }
         }
-        
+
         $data['values'] = $values;
 
 
 
 
         $date = $this->request->getPost("id");
-        
-        $daydate = format_date($date,0,'Y-m');
-        
+
+        $daydate = format_date($date, 0, 'Y-m');
+
         $daydate = $daydate . '-01';
-        
-        $WH = 'WH' . format_date($date,0,'j');
-        
+
+        $WH = 'WH' . format_date($date, 0, 'j');
+
         $yesterday = $this->dahsboard_Model->attyesterday($WH, $daydate);
 
         //$absEmp =array($absEmp);
         $values = 0;
         $absEmp = array();
-        
+
         foreach ($yesterday as $weekda => $value) {
-        
+
             if ($value[$WH] == 0) {
 
                 $values++;
@@ -400,14 +403,14 @@ class User extends BaseController
             }
         }
 
-        
+
         $data['today'] = $values;
         $data['absname'] = $absEmp;
 
-        $OT = 'OT' .format_date($date,0,'j');
+        $OT = 'OT' . format_date($date, 0, 'j');
 
         $CUR_month = date('t');
-        
+
         $toDayEmployee = $this->dahsboard_Model->dayAllPersentEmpSalary($WH, $OT, $daydate);
         //$EmpID = $toDayEmployee[0]->EmpID;
 
@@ -463,14 +466,14 @@ class User extends BaseController
 
                     $currentDatePF = $currentDaySalary + $currentDayHra + $totSalayOT;
                     /** current date pf calculation**/
-                    
+
                     $esiAmount = ($totalsalary <= 20000) ? $currentDatePF * 1.75 / 100 : 0;
                     /** esiamount not elgiable for 20000 **/
-                    
+
                     $pfAmount = $currentDaySalary * 12 / 100;
                     /** pf amount per day**/
 
-                    
+
                     $salaryInCurrentdays = $currentDaySalary + $totSalayOT + $currentDayHra + $Food_Allowances;
                     $salaryInCurrentday =  $salaryInCurrentdays - ($esiAmount + $pfAmount);
                     $employeeSalary += round($salaryInCurrentday);
@@ -485,7 +488,7 @@ class User extends BaseController
         $working = array();
         $overtime = array();
         //$holid = array();
-        $len = format_date($date,0,'d');
+        $len = format_date($date, 0, 'd');
         for ($i = 1; $i <= $len; $i++) //echo $dat; die;
         {
 
@@ -522,7 +525,7 @@ class User extends BaseController
 
                 if ($value[$work] != 0 || $value['OT' . substr($work, 2)] != 0) {
                     $totalothour = $value['OT' . substr($work, 2)];
-                  
+
                     $values = 1;
 
                     $Empid = $value['EmpID'];
@@ -548,10 +551,10 @@ class User extends BaseController
 
                         $onehoursSalary = ($daySalary + $dayHra) / 8;
                         /**one hour salay ot calculation**/
-                        
+
                         $totSalayOT =  ($totalothour != 0) ? $totalothour * $onehoursSalary : 0;
                         /** if ot not equal zero **/
-                        
+
                         $currentDaySalary = $daySalary * $values;
                         /** current day salary working days calculation**/
 
@@ -560,10 +563,10 @@ class User extends BaseController
 
                         $currentDatePF = $currentDaySalary + $currentDayHra + $totSalayOT;
                         /** current date pf calculation**/
-                        
+
                         $esiAmount = ($totalsalary <= 20000) ? $currentDatePF * 1.75 / 100 : 0;
                         /** esiamount not elgiable for 20000 **/
-                        
+
                         $pfAmount = $currentDaySalary * 12 / 100;
                         /** pf amount per day**/
 
@@ -630,7 +633,7 @@ class User extends BaseController
     {
 
         $date = date('Y-m');
-        
+
         $dates = $date . '-01';
         $EmpID = '';
         if (empty($empID)) {
@@ -638,7 +641,7 @@ class User extends BaseController
         } else {
             $EmpID = $empID;
         }
-        
+
         $monthabs = $this->dahsboard_Model->attendance($EmpID, $dates);
         $persent_month = date('t'); //current month of days 31
         $values = array();
@@ -697,11 +700,10 @@ class User extends BaseController
         $totalwhhours  = array_sum($values);
 
         $totalwhhour = $totalwhhours / 8;
-        
+
         if ($CURMONTH == $doj_month && $CURYEAR == $doj_year) {
-        
+
             $data['CUR_month'] = $CURDATE - $doj_day + 1;
-        
         } else {
             $data['CUR_month'] = $date;
         }
@@ -868,7 +870,7 @@ class User extends BaseController
             $TotalNoofDays = $TotalNoofDays + $CURDATE;
             $DaysWorked = $DaysWorked + $values;
             $final_res = round(($DaysWorked / $TotalNoofDays) * 100);
-            
+
             $data['workeds'] = $DaysWorked;
             $data['yeardata'] = $final_res;
             $data['totaldays'] = $TotalNoofDays;
@@ -918,8 +920,14 @@ class User extends BaseController
         // {            		
         $data['EmpList'] = $this->user_model->getAllEmployees();
         $data['roles'] = $this->user_model->getUserRoles();
-        // $data['Department'] = $this->costcenter_model->getDepartment();
+        $data['Department'] = json_decode(json_encode($this->department_model->departmentListing()), true);
 
+        // echo "
";
+        // print_r($data['Department']);
+        // die;
+
+        // echo "
";
+        // print_r($data['Department']);die;
         $this->global['pageTitle'] = 'Add New User';
         $this->loadViews("addUser", $this->global, $data, NULL);
         // }
@@ -1000,7 +1008,7 @@ class User extends BaseController
         $email = $this->request->getPost('MailID');
         $SelectedDepartment = (string)$this->request->getPost('txtSelectedDepartment');
         $comma_separated = explode(':', $SelectedDepartment);
-        if(count($comma_separated)== 1 && in_array('DEP27', $comma_separated)){
+        if (count($comma_separated) == 1 && in_array('DEP27', $comma_separated)) {
             $roleId = '6';
         }
         $userInfo = [
@@ -1116,27 +1124,27 @@ class User extends BaseController
         // if ($this->validator->run() == FALSE) {
         //     $this->editOld($userId);
         // } else {
-            $EmpID = $this->request->getPost('EmpList');
-            $role = $this->request->getPost('role');
-            $password = $this->request->getPost('password');
-           
-            $updatedDate =  get_current_date_time();
+        $EmpID = $this->request->getPost('EmpList');
+        $role = $this->request->getPost('role');
+        $password = $this->request->getPost('password');
 
-            //    echo $EmpID;
+        $updatedDate =  get_current_date_time();
 
-            $userInfo = array();
+        //    echo $EmpID;
 
-            $userInfo = array('password' => getHashedPassword($password), 'roleId' => $role, 'EmpId' => $EmpID, 'updatedDtm' => $updatedDate);
+        $userInfo = array();
 
-            $result = $this->user_model->editUser($userInfo,  $EmpID);
+        $userInfo = array('password' => getHashedPassword($password), 'roleId' => $role, 'EmpId' => $EmpID, 'updatedDtm' => $updatedDate);
 
-            if ($result == true) {
-                $this->session->setFlashdata('success', 'User updated successfully');
-            } else {
-                $this->session->setFlashdata('error', 'User updation failed');
-            }
+        $result = $this->user_model->editUser($userInfo,  $EmpID);
 
-            return redirect()->route('userListing');
+        if ($result == true) {
+            $this->session->setFlashdata('success', 'User updated successfully');
+        } else {
+            $this->session->setFlashdata('error', 'User updation failed');
+        }
+
+        return redirect()->route('userListing');
         // }
         //}
     }
@@ -1150,7 +1158,7 @@ class User extends BaseController
     {
         echo 'Delete';
         $Uid = $this->request->getPost('id');
-        
+
         $updatedDate =  get_current_date_time();
 
         $userInfo = array('isDeleted' => 1, 'updatedBy' => $this->vendorId, 'updatedDtm' => $updatedDate);
@@ -1167,7 +1175,7 @@ class User extends BaseController
     {
         $this->global['pageTitle'] = 'Change Password';
 
-        $this->loadViews("changePassword", $this->global, NULL, NULL);
+        $this->loadViews("changePassword", $this->global, [], NULL);
     }
 
 
@@ -1178,29 +1186,27 @@ class User extends BaseController
     {
         helper('form'); //$this->load->library('form_validation');
 
-        $this->validator->setRules(['oldPassword', 'Old password'=> 'required|max_length[20]']);
-        $this->validator->setRules(['newPassword', 'New password'=> 'required|max_length[20]']);
-        $this->validator->setRules(['cNewPassword', 'Confirm new password'=> 'required|matches[newPassword]|max_length[20]']);
+        // $this->validator->setRules(['oldPassword', 'Old password'=> 'required|max_length[20]']);
+        // $this->validator->setRules(['newPassword', 'New password'=> 'required|max_length[20]']);
+        // $this->validator->setRules(['cNewPassword', 'Confirm new password'=> 'required|matches[newPassword]|max_length[20]']);
 
-        if ($this->validator->run() == FALSE) {
-            $this->loadChangePass();
-        } else {
+        // if ($this->validator->run() == FALSE) {
             $oldPassword = $this->request->getPost('oldPassword');
             $newPassword = $this->request->getPost('newPassword');
-
+            $cNewPassword = $this->request->getPost('newPassword');
+        if($newPassword === $cNewPassword && $oldPassword != $newPassword) {
             $resultPas = $this->user_model->matchOldPassword($this->vendorId, $oldPassword);
-
             if (empty($resultPas)) {
                 $this->session->setFlashdata('nomatch', 'Your old password not correct');
                 return redirect()->route('loadChangePass');
             } else {
                 $usersData = array(
-                    'password' => getHashedPassword($newPassword), 'updatedBy' => $this->vendorId,
+                    'password' => getHashedPassword($newPassword),
+                    'updatedBy' => $this->vendorId,
                     'updatedDtm' => date('Y-m-d H:i:sa')
                 );
-
+                $this->session->setFlashdata('error', 'Password updation failed');
                 $result = $this->user_model->changePassword($this->vendorId, $usersData);
-
                 if ($result > 0) {
                     $this->session->setFlashdata('success', 'Password updation successful');
                 } else {
@@ -1227,7 +1233,6 @@ class User extends BaseController
 
             $data['fy'] = $this->user_model->fincalYear();
             $data['per'] = $this->user_model->deliver_perform($fa, $aa, $m);
-
         }
 
         $data['fy'] = $this->user_model->fincalYear();
@@ -1256,7 +1261,7 @@ class User extends BaseController
         $status = $this->request->getPost('status');
         $CreateBy = $this->session->get('userId');
 
-        
+
         $createddt =  get_current_date_time();
         $menu = $this->request->getPost('menu');
         // $RowCount =  $this->request->getPost('txtRowCount'); 
@@ -1264,7 +1269,7 @@ class User extends BaseController
         // $comma_separated = explode(':', $DeletedRow); 
         $favourite = array('Menu_Name' => $name, 'Menu_URL' => $url, 'Status' => $status, 'Created_BY' => $CreateBy, 'Created_ON' => $createddt, 'Menu_ID' => $menu);
         $getdata = $this->user_model->favouriteadd($favourite);
-        
+
         if ($getdata == 1) {
             echo "success";
         } else {
@@ -1272,380 +1277,358 @@ class User extends BaseController
         }
     }
 
-    function zohobooks_api_fetch_all(){
+    function zohobooks_api_fetch_all()
+    {
         //  print_r($_GET);
         // echo isset($_GET['from']) ? $_GET['from'] : 'n';
         // echo isset($_GET['to']) ? $_GET['to'] : 'n';
         // die();
-        try{
+        try {
             // if (isset($_POST['sync']) || $_GET['from'] != null && $_GET['to'] != null) 
             // {
-                // $ch=curl_init();
-                //$this->load->helper('zohobooks_fetch_api_helper');
-                helper('zohobook');
-                $Zohobook_model = model('Zohobook_api_model');
-                if(isset($_GET['from']) && $_GET['from'] != null && isset($_GET['to']) && $_GET['to'] != null)
-                {
-                    $date_today = $_GET['to'];
-                    $date_yesterday = $_GET['from'];
+            // $ch=curl_init();
+            //$this->load->helper('zohobooks_fetch_api_helper');
+            helper('zohobook');
+            $Zohobook_model = model('Zohobook_api_model');
+            if (isset($_GET['from']) && $_GET['from'] != null && isset($_GET['to']) && $_GET['to'] != null) {
+                $date_today = $_GET['to'];
+                $date_yesterday = $_GET['from'];
+            } else {
+                $date_today = date('Y-m-d');
+                $date_yesterday = date('Y-m-d', strtotime('-3 day', strtotime($date_today)));
+            }
+            // echo $date_today.'--'.$date_yesterday;die;
+            $chk_acc_token_val = $Zohobook_model->get_data('zohobook_accesstoken', 'id', 1);
+            // print_r($chk_acc_token_val);//die();
+            $date = new \DateTime($chk_acc_token_val[0]['created_at']);
+            //print_r($date);
+            $date->add(new \DateInterval('PT1H'));
+            //print_r($date);
+            //echo '****************';
+            //print_r(date('Y-m-d h:i:s'));
+            $token = 0;
+            if ($date->format('Y-m-d H:i:s') > date('Y-m-d H:i:s')) {
+                $token = $chk_acc_token_val[0]['token'];
+            } else {
+                $token = generateNewToken();
+                $tokendata['token'] = $token;
+                $Zohobook_model->customUpdate($tokendata, 1, 'zohobook_accesstoken');
+            }
+            // $token = generateNewToken(); $tokendata['token'] = $token; 
+            //$Zohobook_model->update($tokendata , 1,'zohobook_accesstoken');  
+            $result = getheringInvoiceDetails($date_today, $date_yesterday, $token);
+            $headers_new = $result['headers_new'];
+            $res = json_decode($result['data'], true);
+            $inv_array = $res['invoices'];
+            // print_r($inv_array);
+            // echo "rrrr";
+            // die();
+            foreach ($inv_array as $inv) {
+                $invoice_id = $inv['invoice_id'];
+                //filter only einvoice status pushed invoices only
+                //&& isset($inv['einvoice_details']) && isset($inv['einvoice_details']['status']) && ($inv['einvoice_details']['status'] == 'pushed')
+                if ($invoice_id !== "") {
+                    $organization_id = '776847408';
+                    $result2 = getheringInvoiceSubDetails($invoice_id, $organization_id, $headers_new);
+                    $resall = json_decode($result2, true);
+                    $res2[] = $resall['invoice'];
                 }
-                else
-                {
-                    $date_today = date('Y-m-d');
-                    $date_yesterday = date('Y-m-d',strtotime('-3 day',strtotime($date_today)));
-                }
-                // echo $date_today.'--'.$date_yesterday;die;
-                $chk_acc_token_val = $Zohobook_model->get_data('zohobook_accesstoken','id' , 1);
-                // print_r($chk_acc_token_val);//die();
-                $date = new \DateTime($chk_acc_token_val[0]['created_at']); 
-                //print_r($date);
-                $date->add(new \DateInterval('PT1H'));
-                //print_r($date);
-                //echo '****************';
-                //print_r(date('Y-m-d h:i:s'));
-                $token = 0;
-                if ($date->format('Y-m-d H:i:s') > date('Y-m-d H:i:s')) {  $token = $chk_acc_token_val[0]['token']; } 
-                else { $token = generateNewToken(); $tokendata['token'] = $token; $Zohobook_model->customUpdate($tokendata , 1,'zohobook_accesstoken'); }
-                    // $token = generateNewToken(); $tokendata['token'] = $token; 
-                    //$Zohobook_model->update($tokendata , 1,'zohobook_accesstoken');  
-                    $result = getheringInvoiceDetails($date_today , $date_yesterday , $token);
-                    $headers_new = $result['headers_new'];
-                    $res = json_decode($result['data'],true);
-                    $inv_array = $res['invoices'];
-                    // print_r($inv_array);
-                    // echo "rrrr";
-                    // die();
-                    foreach($inv_array as $inv){
-                        $invoice_id = $inv['invoice_id'];
-                        //filter only einvoice status pushed invoices only
-                        //&& isset($inv['einvoice_details']) && isset($inv['einvoice_details']['status']) && ($inv['einvoice_details']['status'] == 'pushed')
-                        if($invoice_id !== "" ){
-                            $organization_id = '776847408';
-                            $result2=getheringInvoiceSubDetails($invoice_id,$organization_id,$headers_new);
-                            $resall = json_decode($result2,true);
-                            $res2[] = $resall['invoice'];
-                        }
+            }
+            $insert_count = 0;
+            $update_count = 0;
+            foreach ($res2 as $rs) {
+                $gst_no = $rs['gst_no'];
+                $invoice_number = $rs['invoice_number'];
+                $invoice_date = $rs['date'];
+                $status = $rs['status'];
+                $due_date = $rs['due_date'];
+                $invoice_url = $rs['invoice_url'];
+                $einvoice_number = $rs['einvoice_details']['inv_ref_num'];
+
+                $invoice_time = $rs['created_time'];
+                $time_array = explode("T", $invoice_time);
+                $time_array = explode("+", $time_array[1]);
+                $invoice_time = $time_array[0];
+
+                $sql_invoice_chk = $Zohobook_model->ip_invoices($invoice_number, $invoice_date);
+                if ($sql_invoice_chk <= 0) {
+
+                    $gst_sql = $Zohobook_model->ip_clients($gst_no);
+                    if ($gst_sql) {
+                        $client_id = $gst_sql[0]['client_id'];
+                        log_message('error', 'Data fetch success DB : ip_clients , client_id : ' . $client_id);
+                    } else {
+                        log_message('error', 'No data => Data fetch failed DB : ip_clients ' . $gst_no);
+                        $gst_no_data['client_tax_code'] = $gst_no;
+                        $gst_inserted_id = $Zohobook_model->customInsert($gst_no_data, 'ip_clients');
+                        $client_id = $gst_inserted_id;
+                        log_message('error', 'New Data Created : DB : ip_clients , client_id : ' . $client_id);
                     }
-                    $insert_count = 0;
-                    $update_count = 0;
-                    foreach($res2 as $rs)
-                    {
-                        $gst_no = $rs['gst_no'];
-                        $invoice_number = $rs['invoice_number'];
-                        $invoice_date = $rs['date']; 
-                        $status = $rs['status'];
-                        $due_date = $rs['due_date'];
-                        $invoice_url = $rs['invoice_url'];
-                        $einvoice_number = $rs['einvoice_details']['inv_ref_num'];
 
-                            $invoice_time=$rs['created_time'];
-                            $time_array = explode("T", $invoice_time);
-                            $time_array = explode("+",$time_array[1]);
-                            $invoice_time = $time_array[0];
-                        
-                        $sql_invoice_chk = $Zohobook_model->ip_invoices($invoice_number , $invoice_date);
-                        if($sql_invoice_chk <= 0)
-                        {  
 
-                                $gst_sql = $Zohobook_model->ip_clients($gst_no);
-                                if($gst_sql)
-                                {
-                                    $client_id = $gst_sql[0]['client_id'];
-                                    log_message('error', 'Data fetch success DB : ip_clients , client_id : '.$client_id);
+                    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+                    $charactersLength = strlen($characters);
+                    $randomString = '';
+                    for ($i = 0; $i < 16; $i++) {
+                        $randomString .= $characters[rand(0, $charactersLength - 1)];
+                    }
+                    $url_key = $randomString;
+
+                    $ip_invoices['user_id'] = 1;
+                    $ip_invoices['client_id'] = $client_id;
+                    $ip_invoices['invoice_group_id'] = 6;
+                    $ip_invoices['invoice_status_id'] = ($status == 'draft' ? 1 : (($status == 'sent' || $status == 'overdue') ? 2 : 5));
+                    $ip_invoices['invoice_date_created'] = $invoice_date;
+                    $ip_invoices['invoice_time_created'] = $invoice_time;
+                    $ip_invoices['invoice_date_due'] = $due_date;
+                    $ip_invoices['invoice_number'] = $invoice_number;
+                    $ip_invoices['invoice_url_key'] = $url_key;
+                    $ip_invoices['receivedstatus'] = 'ST066';
+                    $ip_invoices['credit_status'] = 0;
+                    $ip_invoices['status'] = $status;
+                    $ip_invoices['e_invoice_number'] = $einvoice_number;
+                    $ip_invoices['invoice_url'] = $invoice_url;
+                    $invoice_insert_id = $Zohobook_model->customInsert($ip_invoices, 'ip_invoices');
+                    if ($invoice_insert_id) {
+                        log_message('error', 'Data insert success DB : ip_invoices client id :' . $client_id);
+                        $insert_count = $insert_count + 1;
+                        //start invoice level custom fields
+
+                        //custom fields insert
+
+                        $batch_no = isset($rs['custom_fields'][5]['value']) ? $rs['custom_fields'][5]['value'] : "";
+                        // $batch_no = "";
+                        $vehicle_number = isset($rs['custom_field_hash']['cf_vehicle_number']) ? $rs['custom_field_hash']['cf_vehicle_number'] : '';
+                        $transport_mode = isset($rs['custom_field_hash']['cf_transport_mode']) ? $rs['custom_field_hash']['cf_transport_mode'] : '';
+                        $purchase_order_date = isset($rs['custom_field_hash']['cf_purchase_order_date']) ? $rs['custom_field_hash']['cf_purchase_order_date'] : '';
+                        $driver = isset($rs['custom_field_hash']['cf_driver']) ? $rs['custom_field_hash']['cf_driver'] : '';
+                        $place_of_supply = isset($rs['custom_field_hash']['cf_place_of_supply']) ? $rs['custom_field_hash']['cf_place_of_supply'] : '';
+                        // batch_no
+                        $ip_invoice_custom_b['invoice_id'] = $invoice_insert_id;
+                        $ip_invoice_custom_b['invoice_custom_fieldid'] = 62;
+                        $ip_invoice_custom_b['invoice_custom_fieldvalue'] = $batch_no;
+                        $result_invoice_custom_insert = $Zohobook_model->customInsert($ip_invoice_custom_b, 'ip_invoice_custom');
+                        if ($result_invoice_custom_insert)
+                            log_message('error', 'Data insert success DB : ip_invoice_custom ');
+                        else
+                            log_message('error', 'Data insert failed DB : ip_invoice_custom ');
+                        // vehicle_number
+                        $ip_invoice_custom_v['invoice_id'] = $invoice_insert_id;
+                        $ip_invoice_custom_v['invoice_custom_fieldid'] = 8;
+                        $ip_invoice_custom_v['invoice_custom_fieldvalue'] = $vehicle_number;
+                        $res_vehicle = $Zohobook_model->customInsert($ip_invoice_custom_v, 'ip_invoice_custom');
+                        if ($res_vehicle)
+                            log_message('error', 'Data insert success DB : ip_invoice_custom ');
+                        else
+                            log_message('error', 'Data insert failed DB : ip_invoice_custom ');
+                        // transport_mode
+                        $ip_invoice_custom_t['invoice_id'] = $invoice_insert_id;
+                        $ip_invoice_custom_t['invoice_custom_fieldid'] = 7;
+                        $ip_invoice_custom_t['invoice_custom_fieldvalue'] = $transport_mode;
+                        $res_transport_mode = $Zohobook_model->customInsert($ip_invoice_custom_t, 'ip_invoice_custom');
+                        if ($res_transport_mode)
+                            log_message('error', 'Data insert success DB : ip_invoice_custom ');
+                        else
+                            log_message('error', 'Data insert failed DB : ip_invoice_custom ');
+                        // purchase_order_date
+                        $ip_invoice_custom_p['invoice_id'] = $invoice_insert_id;
+                        $ip_invoice_custom_p['invoice_custom_fieldid'] = 15;
+                        $ip_invoice_custom_p['invoice_custom_fieldvalue'] = $purchase_order_date;
+                        $res_purchase_order_date = $Zohobook_model->customInsert($ip_invoice_custom_p, 'ip_invoice_custom');
+                        if ($res_purchase_order_date)
+                            log_message('error', 'Data insert success DB : ip_invoice_custom ');
+                        else
+                            log_message('error', 'Data insert failed DB : ip_invoice_custom ');
+                        // driver
+                        $ip_invoice_custom_d['invoice_id'] = $invoice_insert_id;
+                        $ip_invoice_custom_d['invoice_custom_fieldid'] = 58;
+                        $ip_invoice_custom_d['invoice_custom_fieldvalue'] = $driver;
+                        $res_driver = $Zohobook_model->customInsert($ip_invoice_custom_d, 'ip_invoice_custom');
+                        if ($res_driver)
+                            log_message('error', 'Data insert success DB : ip_invoice_custom ');
+                        else
+                            log_message('error', 'Data insert failed DB : ip_invoice_custom ');
+                        // place_of_supply
+                        $ip_invoice_custom_d['invoice_id'] = $invoice_insert_id;
+                        $ip_invoice_custom_d['invoice_custom_fieldid'] = 10;
+                        $ip_invoice_custom_d['invoice_custom_fieldvalue'] = $place_of_supply;
+                        $res_place = $Zohobook_model->customInsert($ip_invoice_custom_d, 'ip_invoice_custom');
+                        if ($res_place)
+                            log_message('error', 'Data insert success DB : ip_invoice_custom ');
+                        else
+                            log_message('error', 'Data insert failed DB : ip_invoice_custom ');
+                        //end  invoice level custom fields
+
+                        //if line items available
+                        if (isset($rs['line_items']) && count($rs['line_items']) > 0) {
+                            log_message('error', 'Processing line items' . count($rs['line_items']));
+
+                            for ($i = 0; $i < count($rs['line_items']); $i++) {            //start insert line items
+                                $sku = $rs['line_items'][$i]['sku'];
+
+
+                                $item_price = $rs['line_items'][$i]['rate'];
+                                $item_order =  $rs['line_items'][$i]['item_order'];
+                                $item_product_unit = $rs['line_items'][$i]['unit'];
+                                $item_name = $rs['line_items'][$i]['name'];
+                                $item_description = $rs['line_items'][$i]['description'];
+                                $item_quantity = $rs['line_items'][$i]['quantity'];
+                                $cgst = $rs['line_items'][$i]['line_item_taxes'][1]['tax_name'];
+                                $sgst = $rs['line_items'][$i]['line_item_taxes'][0]['tax_name'];
+                                $cgst = $cgst[4];
+                                $sgst = $sgst[4];
+                                $cgst = $cgst . '.000';
+                                $getcgsttax = $Zohobook_model->ip_tax_rates($cgst);
+                                if ($getcgsttax) {
+                                    $cgsttaxid = $getcgsttax[0]['tax_rate_id'];
+                                    log_message('error', 'Data fetch success DB : ip_tax_rates cgst' . $cgst);
+                                } else {
+                                    log_message('error', 'No data => Data fetch failed DB : ip_tax_rates ' . $cgst);
+                                    $cgst_data['tax_rate_percent'] = $cgst;
+                                    $getcgsttax = $Zohobook_model->customInsert($cgst_data, 'ip_tax_rates');
+                                    $cgsttaxid = $getcgsttax;
+                                    log_message('error', 'New Data Created : DB : ip_tax_rates , tax_rate_id : ' . $cgsttaxid);
                                 }
+
+                                $sgst = $sgst . '.000';
+                                $getsgsttax = $Zohobook_model->ip_tax_rates($sgst);
+                                if ($getsgsttax) {
+                                    $sgsttaxid = $getsgsttax[0]['tax_rate_id'];
+                                    log_message('error', 'Data fetch success DB : ip_tax_rates sgst' . $sgst);
+                                } else {
+                                    log_message('error', 'No data => Data fetch failed DB : ip_tax_rates ' . $sgst);
+                                    $sgst_data['tax_rate_percent'] = $sgst;
+                                    $getsgsttax = $Zohobook_model->customInsert($sgst_data, 'ip_tax_rates');
+                                    $sgsttaxid = $getsgsttax;
+                                    log_message('error', 'New Data Created : DB : ip_tax_rates , tax_rate_id : ' . $sgsttaxid);
+                                }
+
+                                $item_subtotal = $rs['line_items'][$i]['item_total'];
+
+
+                                $item_sgst_amt = $rs['line_items'][$i]['line_item_taxes'][0]['tax_amount'];
+                                $item_cgst_amt = $rs['line_items'][$i]['line_item_taxes'][1]['tax_amount'];
+                                $item_tax_total = ($item_sgst_amt + $item_cgst_amt);
+                                $item_total = ($item_subtotal + $item_tax_total);
+
+                                $item_discount = 0.00;
+                                $item_igst_amt = 0.00;
+                                // if($batch_no==""){ $batch_no = "";}
+
+
+                                $sku_sql = $Zohobook_model->ip_products($sku);
+                                if (!empty($sku_sql)) {
+                                    $product_id = $sku_sql[0]['product_id'];
+                                    log_message('error', 'Data fetch success DB : ip_products , product_id : ' . $product_id);
+                                } else {
+                                    log_message('error', 'No data => Data fetch failed DB : ip_products ' . $sku);
+                                    $sku_data['product_name'] = $item_name;
+                                    $sku_data['product_description'] = $item_description;
+                                    $sku_data['sku'] = $sku;
+                                    $sku_inserted_id = $Zohobook_model->customInsert($sku_data, 'ip_products');
+                                    $product_id = $sku_inserted_id;
+                                    log_message('error', '$sku_sql => Data fetch failed DB : ip_products ' . $sku_sql);
+
+                                    log_message('error', 'sku' . $sku);
+                                    log_message('error', 'New Data Created : DB : product_id , product_id : ' . $product_id);
+                                }
+
+                                //#1
+
+                                $ip_invoice_items['invoice_id'] = $invoice_insert_id;
+                                $ip_invoice_items['item_product_id'] = $product_id;
+                                $ip_invoice_items['item_date_added'] = $invoice_date;
+                                $ip_invoice_items['item_name'] = $item_name;
+                                $ip_invoice_items['item_description'] = $item_description;
+                                $ip_invoice_items['item_quantity'] = $item_quantity;
+                                $ip_invoice_items['item_price'] = $item_price;
+                                $ip_invoice_items['item_order'] = $item_order;
+                                $ip_invoice_items['item_product_unit'] = $item_product_unit;
+                                $ip_invoice_items['Sgst_item_tax_rate_id'] = $sgsttaxid;
+                                $ip_invoice_items['Cgst_item_tax_rate_id'] = $cgsttaxid;
+                                $item_insert_id = $Zohobook_model->customInsert($ip_invoice_items, 'ip_invoice_items');
+                                if ($item_insert_id)
+                                    log_message('error', 'Data insert success DB : ip_invoice_items => Sgst_item_tax_rate_id :' . $sgsttaxid);
                                 else
-                                {
-                                    log_message('error', 'No data => Data fetch failed DB : ip_clients '.$gst_no);
-                                    $gst_no_data['client_tax_code'] = $gst_no;
-                                    $gst_inserted_id = $Zohobook_model->customInsert($gst_no_data,'ip_clients');
-                                    $client_id = $gst_inserted_id;
-                                    log_message('error', 'New Data Created : DB : ip_clients , client_id : '.$client_id);
-                                }
+                                    log_message('error', 'Data insert failed DB : ip_invoice_items => Sgst_item_tax_rate_id :' . $sgsttaxid);
 
-
-                                $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
-                                $charactersLength = strlen($characters);
-                                $randomString = '';
-                                for ($i = 0; $i < 16; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; }
-                                $url_key = $randomString;
-    
-                                    $ip_invoices['user_id'] = 1;
-                                    $ip_invoices['client_id'] = $client_id;
-                                    $ip_invoices['invoice_group_id'] = 6;
-                                    $ip_invoices['invoice_status_id'] = ($status == 'draft' ? 1 : (($status == 'sent' || $status == 'overdue') ? 2 : 5));
-                                    $ip_invoices['invoice_date_created'] = $invoice_date;
-                                    $ip_invoices['invoice_time_created'] = $invoice_time;
-                                    $ip_invoices['invoice_date_due'] = $due_date;
-                                    $ip_invoices['invoice_number'] = $invoice_number;
-                                    $ip_invoices['invoice_url_key'] = $url_key;
-                                    $ip_invoices['receivedstatus'] = 'ST066';
-                                    $ip_invoices['credit_status'] = 0;
-                                    $ip_invoices['status'] = $status;
-                                    $ip_invoices['e_invoice_number'] = $einvoice_number;
-                                    $ip_invoices['invoice_url'] = $invoice_url;
-                                $invoice_insert_id = $Zohobook_model->customInsert($ip_invoices,'ip_invoices');
-                                if($invoice_insert_id)
-                                {
-                                    log_message('error', 'Data insert success DB : ip_invoices client id :'. $client_id);
-                                    $insert_count = $insert_count + 1;
-                                    //start invoice level custom fields
-
-                                    //custom fields insert
-
-                                        $batch_no = isset($rs['custom_fields'][5]['value']) ? $rs['custom_fields'][5]['value'] : "";
-                                            // $batch_no = "";
-                                        $vehicle_number = isset($rs['custom_field_hash']['cf_vehicle_number']) ? $rs['custom_field_hash']['cf_vehicle_number']: '';
-                                        $transport_mode =isset($rs['custom_field_hash']['cf_transport_mode']) ? $rs['custom_field_hash']['cf_transport_mode'] : '';
-                                        $purchase_order_date = isset($rs['custom_field_hash']['cf_purchase_order_date'])?$rs['custom_field_hash']['cf_purchase_order_date']:'';
-                                        $driver = isset($rs['custom_field_hash']['cf_driver']) ? $rs['custom_field_hash']['cf_driver'] : '';
-                                        $place_of_supply = isset($rs['custom_field_hash']['cf_place_of_supply']) ? $rs['custom_field_hash']['cf_place_of_supply']:'';
-                                // batch_no
-                                    $ip_invoice_custom_b['invoice_id'] = $invoice_insert_id;
-                                    $ip_invoice_custom_b['invoice_custom_fieldid'] = 62;
-                                    $ip_invoice_custom_b['invoice_custom_fieldvalue'] = $batch_no;
-                                    $result_invoice_custom_insert = $Zohobook_model->customInsert($ip_invoice_custom_b,'ip_invoice_custom');
-                                    if($result_invoice_custom_insert)
-                                        log_message('error', 'Data insert success DB : ip_invoice_custom ');
-                                    else
-                                        log_message('error', 'Data insert failed DB : ip_invoice_custom ');
-                                // vehicle_number
-                                    $ip_invoice_custom_v['invoice_id'] = $invoice_insert_id;
-                                    $ip_invoice_custom_v['invoice_custom_fieldid'] = 8;
-                                    $ip_invoice_custom_v['invoice_custom_fieldvalue'] = $vehicle_number;
-                                    $res_vehicle = $Zohobook_model->customInsert($ip_invoice_custom_v,'ip_invoice_custom');
-                                    if($res_vehicle)
-                                        log_message('error', 'Data insert success DB : ip_invoice_custom ');
-                                    else
-                                        log_message('error', 'Data insert failed DB : ip_invoice_custom ');
-                                // transport_mode
-                                    $ip_invoice_custom_t['invoice_id'] = $invoice_insert_id;
-                                    $ip_invoice_custom_t['invoice_custom_fieldid'] = 7;
-                                    $ip_invoice_custom_t['invoice_custom_fieldvalue'] = $transport_mode;
-                                    $res_transport_mode = $Zohobook_model->customInsert($ip_invoice_custom_t,'ip_invoice_custom');
-                                    if($res_transport_mode)
-                                        log_message('error', 'Data insert success DB : ip_invoice_custom ');
-                                    else
-                                        log_message('error', 'Data insert failed DB : ip_invoice_custom ');
-                                // purchase_order_date
-                                    $ip_invoice_custom_p['invoice_id'] = $invoice_insert_id;
-                                    $ip_invoice_custom_p['invoice_custom_fieldid'] = 15;
-                                    $ip_invoice_custom_p['invoice_custom_fieldvalue'] = $purchase_order_date;
-                                    $res_purchase_order_date =$Zohobook_model->customInsert($ip_invoice_custom_p,'ip_invoice_custom');
-                                    if($res_purchase_order_date)
-                                        log_message('error', 'Data insert success DB : ip_invoice_custom ');
-                                    else
-                                        log_message('error', 'Data insert failed DB : ip_invoice_custom ');
-                                // driver
-                                    $ip_invoice_custom_d['invoice_id'] = $invoice_insert_id;
-                                    $ip_invoice_custom_d['invoice_custom_fieldid'] = 58;
-                                    $ip_invoice_custom_d['invoice_custom_fieldvalue'] = $driver;
-                                    $res_driver = $Zohobook_model->customInsert($ip_invoice_custom_d,'ip_invoice_custom');
-                                    if($res_driver)
-                                        log_message('error', 'Data insert success DB : ip_invoice_custom ');
-                                    else
-                                        log_message('error', 'Data insert failed DB : ip_invoice_custom ');
-                                // place_of_supply
-                                    $ip_invoice_custom_d['invoice_id'] = $invoice_insert_id;
-                                    $ip_invoice_custom_d['invoice_custom_fieldid'] = 10;
-                                    $ip_invoice_custom_d['invoice_custom_fieldvalue'] = $place_of_supply;
-                                    $res_place = $Zohobook_model->customInsert($ip_invoice_custom_d,'ip_invoice_custom');
-                                    if($res_place)
-                                        log_message('error', 'Data insert success DB : ip_invoice_custom ');
-                                    else
-                                        log_message('error', 'Data insert failed DB : ip_invoice_custom ');
-                                    //end  invoice level custom fields
-
-                                    //if line items available
-                                    if(isset($rs['line_items']) && count($rs['line_items']) > 0)
-                                    {
-                                        log_message('error', 'Processing line items'.count($rs['line_items']));
-
-                                        for($i = 0; $i< count($rs['line_items']);$i++)
-                                        {            //start insert line items
-                                                    $sku = $rs['line_items'][$i]['sku'];
-                                                    
-                                                    
-                                                    $item_price = $rs['line_items'][$i]['rate'];
-                                                    $item_order =  $rs['line_items'][$i]['item_order'];
-                                                    $item_product_unit = $rs['line_items'][$i]['unit'];
-                                                    $item_name = $rs['line_items'][$i]['name'];
-                                                    $item_description = $rs['line_items'][$i]['description'];
-                                                    $item_quantity = $rs['line_items'][$i]['quantity'];
-                                                    $cgst = $rs['line_items'][$i]['line_item_taxes'][1]['tax_name'];
-                                                    $sgst = $rs['line_items'][$i]['line_item_taxes'][0]['tax_name'];
-                                                    $cgst = $cgst[4];
-                                                    $sgst = $sgst[4];
-                                                    $cgst = $cgst.'.000';
-                                                    $getcgsttax = $Zohobook_model->ip_tax_rates($cgst);
-                                                    if($getcgsttax)
-                                                    {
-                                                        $cgsttaxid = $getcgsttax[0]['tax_rate_id'];
-                                                        log_message('error', 'Data fetch success DB : ip_tax_rates cgst'. $cgst);
-                                                    }
-                                                    else
-                                                    {
-                                                        log_message('error', 'No data => Data fetch failed DB : ip_tax_rates '. $cgst);
-                                                        $cgst_data['tax_rate_percent'] = $cgst;
-                                                        $getcgsttax = $Zohobook_model->customInsert($cgst_data,'ip_tax_rates');
-                                                        $cgsttaxid = $getcgsttax;
-                                                        log_message('error', 'New Data Created : DB : ip_tax_rates , tax_rate_id : '.$cgsttaxid);
-                                                    }
-                        
-                                                    $sgst = $sgst.'.000';
-                                                    $getsgsttax = $Zohobook_model->ip_tax_rates($sgst);
-                                                    if($getsgsttax)
-                                                    {
-                                                        $sgsttaxid = $getsgsttax[0]['tax_rate_id'];
-                                                        log_message('error', 'Data fetch success DB : ip_tax_rates sgst'. $sgst);
-                                                    }
-                                                    else
-                                                    {
-                                                        log_message('error', 'No data => Data fetch failed DB : ip_tax_rates '. $sgst);
-                                                        $sgst_data['tax_rate_percent'] = $sgst;
-                                                        $getsgsttax = $Zohobook_model->customInsert($sgst_data,'ip_tax_rates');
-                                                        $sgsttaxid = $getsgsttax;
-                                                        log_message('error', 'New Data Created : DB : ip_tax_rates , tax_rate_id : '.$sgsttaxid);
-                                                    }
-                        
-                                                    $item_subtotal = $rs['line_items'][$i]['item_total'];
-                                                    
-                                                    
-                                                    $item_sgst_amt = $rs['line_items'][$i]['line_item_taxes'][0]['tax_amount'];
-                                                    $item_cgst_amt = $rs['line_items'][$i]['line_item_taxes'][1]['tax_amount'];
-                                                    $item_tax_total = ($item_sgst_amt + $item_cgst_amt);
-                                                    $item_total = ($item_subtotal + $item_tax_total);
-                        
-                                                    $item_discount = 0.00;
-                                                    $item_igst_amt = 0.00;
-                                                    // if($batch_no==""){ $batch_no = "";}
-                                                    
-                        
-                                                    $sku_sql = $Zohobook_model->ip_products($sku);
-                                                    if(!empty($sku_sql))
-                                                    {
-                                                        $product_id = $sku_sql[0]['product_id'];
-                                                        log_message('error', 'Data fetch success DB : ip_products , product_id : '.$product_id);
-                                                    }
-                                                    else
-                                                    {
-                                                        log_message('error', 'No data => Data fetch failed DB : ip_products '. $sku);
-                                                        $sku_data['product_name'] = $item_name;
-                                                        $sku_data['product_description'] = $item_description;
-                                                        $sku_data['sku'] = $sku;
-                                                        $sku_inserted_id = $Zohobook_model->customInsert($sku_data,'ip_products');
-                                                        $product_id = $sku_inserted_id;
-                                                        log_message('error', '$sku_sql => Data fetch failed DB : ip_products '. $sku_sql);
-
-                                                        log_message('error', 'sku'.$sku);
-                                                        log_message('error', 'New Data Created : DB : product_id , product_id : '.$product_id);
-                                                    }
-                        
-                                                    //#1
-                        
-                                                    $ip_invoice_items['invoice_id'] = $invoice_insert_id;
-                                                    $ip_invoice_items['item_product_id'] = $product_id;
-                                                    $ip_invoice_items['item_date_added'] = $invoice_date;
-                                                    $ip_invoice_items['item_name'] = $item_name;
-                                                    $ip_invoice_items['item_description'] = $item_description;
-                                                    $ip_invoice_items['item_quantity'] = $item_quantity;
-                                                    $ip_invoice_items['item_price'] = $item_price;
-                                                    $ip_invoice_items['item_order'] = $item_order;
-                                                    $ip_invoice_items['item_product_unit'] = $item_product_unit;
-                                                    $ip_invoice_items['Sgst_item_tax_rate_id'] = $sgsttaxid;
-                                                    $ip_invoice_items['Cgst_item_tax_rate_id'] = $cgsttaxid;
-                                                    $item_insert_id = $Zohobook_model->customInsert($ip_invoice_items,'ip_invoice_items');
-                                                    if($item_insert_id)
-                                                        log_message('error', 'Data insert success DB : ip_invoice_items => Sgst_item_tax_rate_id :'. $sgsttaxid);
-                                                    else
-                                                        log_message('error', 'Data insert failed DB : ip_invoice_items => Sgst_item_tax_rate_id :'. $sgsttaxid);
-                        
-                                                    //tax amount --  ip_invoice_item_amounts - table
-                                                        $ip_invoice_item_amounts['item_id'] = $item_insert_id;
-                                                        $ip_invoice_item_amounts['item_subtotal'] = $item_subtotal;
-                                                        $ip_invoice_item_amounts['item_tax_total'] = $item_tax_total;
-                                                        $ip_invoice_item_amounts['item_total'] = $item_total;
-                                                        $ip_invoice_item_amounts['item_sgst_amt'] = $item_sgst_amt;
-                                                        $ip_invoice_item_amounts['item_cgst_amt'] = $item_cgst_amt;
-                                                        $ip_invoice_item_amounts['item_discount'] = $item_discount;
-                                                        $ip_invoice_item_amounts['item_igst_amt'] = $item_igst_amt;
-                                                    $result_tax_amount_insert = $Zohobook_model->customInsert($ip_invoice_item_amounts,'ip_invoice_item_amounts');
-                                                    if($result_tax_amount_insert)
-                                                        log_message('error', 'Data insert success DB : ip_invoice_item_amounts ');
-                                                    else
-                                                        log_message('error', 'Data insert failed DB : ip_invoice_item_amounts ');
-                                                        
-                                        }         //end line items insert    
-
-                                    }   
-                                    else
-                                    {
-                                        log_message('error', 'Line Items not found in API result');
-                                    }
-                                }
+                                //tax amount --  ip_invoice_item_amounts - table
+                                $ip_invoice_item_amounts['item_id'] = $item_insert_id;
+                                $ip_invoice_item_amounts['item_subtotal'] = $item_subtotal;
+                                $ip_invoice_item_amounts['item_tax_total'] = $item_tax_total;
+                                $ip_invoice_item_amounts['item_total'] = $item_total;
+                                $ip_invoice_item_amounts['item_sgst_amt'] = $item_sgst_amt;
+                                $ip_invoice_item_amounts['item_cgst_amt'] = $item_cgst_amt;
+                                $ip_invoice_item_amounts['item_discount'] = $item_discount;
+                                $ip_invoice_item_amounts['item_igst_amt'] = $item_igst_amt;
+                                $result_tax_amount_insert = $Zohobook_model->customInsert($ip_invoice_item_amounts, 'ip_invoice_item_amounts');
+                                if ($result_tax_amount_insert)
+                                    log_message('error', 'Data insert success DB : ip_invoice_item_amounts ');
                                 else
-                                {
-                                    log_message('error', 'Data insert failed DB : ip_invoice_items client id :'. $client_id);
-                                }
-                                
-                                
-                        }   
-                        else // update invoice status, especially for cancelled invoices
-                        {
-                            // if($status == "void" || $status == "sent" ||  $status == "overdue")
-                            // {
-                                $sql_invoice_update = array();
-                                $sql_invoice_update['invoice_status_id'] = (($status == "sent" || $status == "overdue") ? 2 : 5);
-                                // echo 'script' . $invoice_number. $status;
-                                // print_r( $sql_invoice_update);
-                                // echo '
'; - $sql_invoice_update = $Zohobook_model->sql_invoice_update($sql_invoice_update,$invoice_number,$invoice_date,'ip_invoices'); - if($sql_invoice_update) - { - log_message('error', 'Data update success DB : ip_invoices '); - } - else - { - log_message('error', 'Data update failed DB : ip_invoices '); - } - $update_count = $update_count + 1; - // } + log_message('error', 'Data insert failed DB : ip_invoice_item_amounts '); + } //end line items insert + + } else { + log_message('error', 'Line Items not found in API result'); } + } else { + log_message('error', 'Data insert failed DB : ip_invoice_items client id :' . $client_id); + } + } else // update invoice status, especially for cancelled invoices + { + // if($status == "void" || $status == "sent" || $status == "overdue") + // { + $sql_invoice_update = array(); + $sql_invoice_update['invoice_status_id'] = (($status == "sent" || $status == "overdue") ? 2 : 5); + // echo 'script' . $invoice_number. $status; + // print_r( $sql_invoice_update); + // echo '
'; + $sql_invoice_update = $Zohobook_model->sql_invoice_update($sql_invoice_update, $invoice_number, $invoice_date, 'ip_invoices'); + if ($sql_invoice_update) { + log_message('error', 'Data update success DB : ip_invoices '); + } else { + log_message('error', 'Data update failed DB : ip_invoices '); + } + $update_count = $update_count + 1; + // } + } // echo 'new invoice inserted count- ' . $insert_count . '/' . 'status updated count - ' . $update_count; - }$response = [ - 'status' => true, - 'message' => "Successfully data inserted. Total inserted: " . $insert_count . ", Total Updated: " . $update_count - ]; - return json_encode($response); - - // curl_close($ch); + } + $response = [ + 'status' => true, + 'message' => "Successfully data inserted. Total inserted: " . $insert_count . ", Total Updated: " . $update_count + ]; + return json_encode($response); + + // curl_close($ch); // } - } - catch (\Exception $e) { + } catch (\Exception $e) { $data['err'] = $e->getMessage(); // $db = \Config\Database::connect(); // $data['last_query'] = $db->getLastQuery();; - $Zohobook_model->customInsert($data,'zohobook_api_err'); + $Zohobook_model->customInsert($data, 'zohobook_api_err'); log_message('error', "Data insertion failed : " . $e->getMessage()); - + return json_encode("Data insertion failed : " . $e->getMessage()); } } // END zoho API - function fetchEmployeeDetails() { + function fetchEmployeeDetails() + { $EmpID = $this->request->getPost('EmpID'); - + if (!$EmpID) { return $this->response->setJSON(['success' => false, 'message' => 'Employee ID not provided']); } - + $userInfo = $this->user_model->findEmp($EmpID); - + if ($userInfo) { return $this->response->setJSON(['success' => true, 'userInfo' => $userInfo]); } else { return $this->response->setJSON(['success' => false, 'message' => 'Employee not found']); } } -} \ No newline at end of file +} diff --git a/app/Helpers/cias_helper.php b/app/Helpers/cias_helper.php index c48c5d5c..f3f5b341 100755 --- a/app/Helpers/cias_helper.php +++ b/app/Helpers/cias_helper.php @@ -48,9 +48,9 @@ if (!function_exists('generateCopyrightNotice')) { { $current_year = date('Y'); if ($current_year > 2024) { - return " Copyright © 2024 - $current_year "; + return " © 2024 - $current_year "; } else { - return " Copyright © $current_year "; + return " © $current_year "; } } } diff --git a/app/Models/Emppaydate_model.php b/app/Models/Emppaydate_model.php index 17bdf4ba..5d65ce5b 100644 --- a/app/Models/Emppaydate_model.php +++ b/app/Models/Emppaydate_model.php @@ -1,11 +1,12 @@ -db->table('t_loan_master') - ->select('t_loan_master.*,t_emp_pay_data.*,t_employee_details.FirstName') - ->join('t_employee_details','t_loan_master.EmpID = t_employee_details.EmpID','LEFT') - ->join('t_emp_pay_data','t_loan_master.EmpID = t_emp_pay_data.EmpID','LEFT'); - $query =$builder->get(); - $result = $query->getResult(); + ->select('t_loan_master.*,t_emp_pay_data.*,t_employee_details.FirstName') + ->join('t_employee_details', 't_loan_master.EmpID = t_employee_details.EmpID', 'LEFT') + ->join('t_emp_pay_data', 't_loan_master.EmpID = t_emp_pay_data.EmpID', 'LEFT'); + $query = $builder->get(); + $result = $query->getResult(); return $result; } - - function deleteEmployeePay($EmpID) + + function deleteEmployeePay($Loan_ID) { - $query = $this->db->table('t_emp_pay_data')->delete(['EmpID' => $EmpID]); + $query = $this->db->table('t_loan_master')->delete(['Loan_ID' => $Loan_ID]); return $query; - } - - - - + + + + function addNewemppay($emppay) { $this->db->transStart(); $builder = $this->db->table('t_emp_pay_data'); - $builder->insert($emppay); - + $builder->insert($emppay); + $paydataid = $this->db->insertId(); - + $this->db->transComplete(); - + return $emppay; } - - function addLoanInfo($dataarray,$string) - { - if($string == 'add'){ - $builder = $this->db->table('t_loan_master'); - $builder->insert($dataarray); - $loanid = $this->db->affectedRows(); - return $loanid; - } - else if($string == 'update') - { - $loanid = $dataarray['Loan_ID']; - - $this->db->table('t_loan_master') - ->where('Loan_ID',$loanid) - ->update($dataarray); - - $loanid = $this->db->affectedRows(); - return $loanid; - } - } - function getUserInfo($paydataid) + function addLoanInfo($dataarray, $string) { - $sql = 'select t_emp_pay_data.Pay_Data_ID,t_emp_pay_data.EmpID as PAYEMPID,t_emp_pay_data.Basic_Pay,t_emp_pay_data.HRA_Rate,t_emp_pay_data.Allowances,t_emp_pay_data.Food_Allowances,t_emp_pay_data.Incentives,t_emp_pay_data.PF_Rate,t_emp_pay_data.ESI_Rate,t_emp_pay_data.HRA_Amount,t_emp_pay_data.TotalSalary,t_employee_details.FirstName,t_employee_details.LastName,t_loan_master.*from t_emp_pay_data + if ($string == 'add') { + $builder = $this->db->table('t_loan_master'); + $builder->insert($dataarray); + + $loanid = $this->db->affectedRows(); + return $loanid; + } else if ($string == 'update') { + $loanid = $dataarray['Loan_ID']; + + $this->db->table('t_loan_master') + ->where('Loan_ID', $loanid) + ->update($dataarray); + + $loanid = $this->db->affectedRows(); + return $loanid; + } + } + function getUserInfo($paydataid) + { + $sql = 'select t_emp_pay_data.Pay_Data_ID,t_emp_pay_data.EmpID as PAYEMPID,t_emp_pay_data.Basic_Pay,t_emp_pay_data.HRA_Rate,t_emp_pay_data.Allowances,t_emp_pay_data.Food_Allowances,t_emp_pay_data.Incentives,t_emp_pay_data.PF_Rate,t_emp_pay_data.ESI_Rate,t_emp_pay_data.HRA_Amount,t_emp_pay_data.TotalSalary,t_employee_details.FirstName,t_employee_details.LastName,t_loan_master.*from t_emp_pay_data join t_employee_details on t_emp_pay_data.EmpID=t_employee_details.EmpID left join t_loan_master on t_emp_pay_data.EmpID=t_loan_master.EmpID and t_loan_master.is_Active = 1 where t_emp_pay_data.Pay_Data_ID = ?;'; - $query = $this->db->query($sql,array($paydataid)); - + $query = $this->db->query($sql, array($paydataid)); + return $query->getResult(); } function getEmpPayData($EmpID) { - $sql = 'select t_emp_pay_data.Pay_Data_ID,t_emp_pay_data.EmpID,t_emp_pay_data.Basic_Pay,t_emp_pay_data.HRA_Rate,t_emp_pay_data.Allowances,t_emp_pay_data.Food_Allowances,t_emp_pay_data.Incentives,t_emp_pay_data.PF_Rate,t_emp_pay_data.ESI_Rate,t_emp_pay_data.HRA_Amount,t_emp_pay_data.TotalSalary from t_emp_pay_data + $sql = 'select t_emp_pay_data.Pay_Data_ID,t_emp_pay_data.EmpID,t_emp_pay_data.Basic_Pay,t_emp_pay_data.HRA_Rate,t_emp_pay_data.Allowances,t_emp_pay_data.Food_Allowances,t_emp_pay_data.Incentives,t_emp_pay_data.PF_Rate,t_emp_pay_data.ESI_Rate,t_emp_pay_data.HRA_Amount,t_emp_pay_data.TotalSalary from t_emp_pay_data where t_emp_pay_data.EmpID = ?;'; - $query = $this->db->query($sql,array($EmpID)); - + $query = $this->db->query($sql, array($EmpID)); + return $query->getRow(); } - - - function editemppay($emppaydatas) + + + function editemppay($emppaydatas) { - $EmpID=$emppaydatas['EmpID']; - //echo $paydateid; - //print_r($emppaydatas);die(); + $EmpID = $emppaydatas['EmpID']; + //echo $paydateid; + //print_r($emppaydatas);die(); $this->db->table('t_emp_pay_data') ->where('EmpID', $EmpID) ->update($emppaydatas); return TRUE; } - - - function viewemppay($emppaydata, $paydateid) + + + function viewemppay($emppaydata, $paydateid) { $this->db->table('t_emp_pay_data') ->where('Pay_Data_ID', $paydateid) ->update($emppaydata); - - + + return TRUE; } - - } -?> diff --git a/app/Models/Inwardgateregister_model.php b/app/Models/Inwardgateregister_model.php index 79c5ccb1..1e9534d1 100755 --- a/app/Models/Inwardgateregister_model.php +++ b/app/Models/Inwardgateregister_model.php @@ -342,10 +342,21 @@ class Inwardgateregister_model extends Model function ViewigrListing() { - $builder = $this->db->table('t_igr_master igr') - ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType') + // $builder = $this->db->table('t_igr_master igr') + // ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName') + // ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO') + // ->join('t_supplierdetailsn` sup', 'PO.SupplierID = sup.SupplierID') + // ->join('t_transporter` trans', 'igr.TransporterId = trans.id' , 'left') + // ->where('igr.IGRStatus !=', MRIR_CREATED) + // ->orderBy('igr.CreatedDate', 'desc'); + + $builder = $this->db->table('t_igr_details igr_details') + ->select('igr.*,PO.IsOpenOrder,PO.DeliveryDate,sup.SupplierName,PO.POType,trans.name as TransporterName,item.MaterialName, igr_details.QuantityAsPerInvoice as ReceivedQuantity , igr_details.NetWeight as NetWeight') + ->join('t_igr_master igr', 'igr_details.IGRNo = igr.IGRNo') ->join('t_purchaseorder_master PO', 'igr.PONO = PO.PONO') ->join('t_supplierdetailsn` sup', 'PO.SupplierID = sup.SupplierID') + ->join('t_transporter` trans', 'igr.TransporterId = trans.id' , 'left') + ->join('t_materialmaster` item', 'igr_details.MaterialCode = item.MaterialCode' , 'left') ->where('igr.IGRStatus !=', MRIR_CREATED) ->orderBy('igr.CreatedDate', 'desc'); $query = $builder->get(); diff --git a/app/Models/Monthlypay_model.php b/app/Models/Monthlypay_model.php index 98c3665a..82fa5014 100644 --- a/app/Models/Monthlypay_model.php +++ b/app/Models/Monthlypay_model.php @@ -84,7 +84,7 @@ class Monthlypay_model extends Model $month = '0' . $month; } - //echo $month; + $current = '01-' . $current; //echo $current; @@ -100,7 +100,7 @@ class Monthlypay_model extends Model //echo $lastdate; //left join t_payroll on t_employee_details.EmpID = t_payroll.EmpID and month(t_payroll.PayOn) = month(?) and year(t_payroll.PayOn) = year(?) - $sql = "select t_emp_pay_data.EmpID,t_emp_pay_data.*,t_employee_details.FirstName,t_employee_details.DateofJoining,t_employee_details.Designation,t_employee_details.esi_applicable,t_employee_details.pf_applicable,t_employee_details.is_management_team,t_attendance.Days_Worked as Days_worked,t_attendance.Absent as LOP_Days,t_attendance.Paid_Leave as Paid_leave,t_attendance.Total_OTHrs as OT_Hrs_Worked,t_attendance.NoofDays,t_attendance.sunday_count,t_loan_master.Loan_ID,t_loan_master.Monthly_Due,t_loan_master.Due_Start_Date as DueDate,t_loan_master.Loan_Amount,t_loan_master.Paid_Amount,t_payroll.Key,t_monthly_pay_inputs.Incentives as MonthlyIncentives,t_monthly_pay_inputs.Loan_Recovered,t_monthly_pay_inputs.Estimate,t_monthly_pay_inputs.Festival_Bonus,t_monthly_pay_inputs.Other_Deductions,t_loan_history .Balance_Amount + $sql = "select t_emp_pay_data.EmpID,t_emp_pay_data.*,t_employee_details.FirstName,t_employee_details.DateofJoining,t_employee_details.Designation,t_employee_details.esi_applicable,t_employee_details.pf_applicable,t_employee_details.is_management_team,t_attendance.Days_Worked as Days_worked,t_attendance.Absent as LOP_Days,t_attendance.Paid_Leave as Paid_leave,t_attendance.Total_OTHrs as OT_Hrs_Worked,t_attendance.NoofDays,t_attendance.sunday_count,t_loan_master.Loan_ID,t_loan_master.Monthly_Due,t_loan_master.Due_Start_Date as DueDate,t_loan_master.Loan_Amount,t_loan_master.Paid_Amount,t_payroll.Key,t_monthly_pay_inputs.Loan_Recovered,t_monthly_pay_inputs.Estimate,t_monthly_pay_inputs.Festival_Bonus,t_monthly_pay_inputs.Other_Deductions,t_loan_history .Balance_Amount from t_emp_pay_data left join t_employee_details on t_employee_details.EmpID = t_emp_pay_data.EmpID left join t_payroll on t_employee_details.EmpID = t_payroll.EmpID and t_payroll.PayOn = ? @@ -113,6 +113,9 @@ class Monthlypay_model extends Model order by t_employee_details.EmpID"; $query = $this->db->query($sql, array($month, $month, $lastdate, $current, $current)); + // Get the last executed query + // $last_query = $this->db->getLastQuery(); + // echo $last_query; return $query->getResult(); } @@ -371,7 +374,7 @@ join t_departmentdetails as Dep on Dep.DEPCode=Emp.Departmentcode where Emp.IsA $pre_year = $curr_split[0]; $curr_year = $curr_split[1]; - $sql = "select t_monthly_pay_inputs.EmpID,t_employee_details.FirstName,t_employee_details.LastName,sum(Incentives) as Incentives,sum(Festival_Bonus) as Bonus + $sql = "select t_monthly_pay_inputs.EmpID,t_employee_details.FirstName,t_employee_details.LastName,sum(Festival_Bonus) as Bonus from t_monthly_pay_inputs join t_employee_details on t_monthly_pay_inputs.EmpID = t_employee_details.EmpID where @@ -393,7 +396,7 @@ join t_departmentdetails as Dep on Dep.DEPCode=Emp.Departmentcode where Emp.IsA $pre_year = $curr_split[0]; $curr_year = $curr_split[1]; - $sql = "select t_monthly_pay_inputs.EmpID,t_monthly_pay_inputs.Month_Year,t_employee_details.FirstName,t_employee_details.LastName,sum(Incentives) as Incentives,sum(Festival_Bonus) as Bonus + $sql = "select t_monthly_pay_inputs.EmpID,t_monthly_pay_inputs.Month_Year,t_employee_details.FirstName,t_employee_details.LastName,sum(Festival_Bonus) as Bonus from t_monthly_pay_inputs join t_employee_details on t_monthly_pay_inputs.EmpID = t_employee_details.EmpID and t_monthly_pay_inputs.EmpID = ? diff --git a/app/Models/Payroll_model.php b/app/Models/Payroll_model.php index 84001a78..aebe4db9 100644 --- a/app/Models/Payroll_model.php +++ b/app/Models/Payroll_model.php @@ -376,8 +376,10 @@ class Payroll_model extends Model function getEmpID() { - $builder = $this->db->table('t_employee_details') - ->select('EmpID,FirstName,LastName'); + $builder = $this->db->table('t_employee_details E') + ->select('E.EmpID, E.FirstName, E.LastName') + ->join('t_loan_master LM', 'LM.EmpID = E.EmpID', 'left') + ->where('LM.Loan_ID IS NULL'); $query = $builder->get(); return $query->getResult(); @@ -487,4 +489,42 @@ class Payroll_model extends Model //return $query_count; return $query->getResult(); } + + + function getMonthlyPayDetails($EmpId, $PayOn) + { + $builder = $this->db->table('t_monthly_pay_inputs MonthlyPay ') + ->select('MonthlyPay.*, E.BankAccountNo , E.PFNO , E.ESI as ESINO , L.*') + ->join('t_employee_details as E', 'MonthlyPay.EmpID = E.EmpID', 'left') + ->join('t_loan_master as L', 'MonthlyPay.EmpID = L.EmpID and L.is_Active = 1', 'left') + ->where('MonthlyPay.EmpID', $EmpId) + ->where('MonthlyPay.Month_Year', $PayOn); + + $query = $builder->get(); + return $query->getResult(); + } + + function insertPayroll($data) + { + $builder = $this->db->table('t_payroll'); + $builder->insert($data); + $count = $this->db->affectedRows(); + return $count; + } + function insertLoanHistory($data) + { + $builder = $this->db->table('t_loan_history'); + $builder->insert($data); + $count = $this->db->affectedRows(); + return $count; + } + function updateLoan($LoanID,$EmpID,$data) + { + $builder = $this->db->table('t_loan_master') + ->where('Loan_ID', $LoanID) + ->where('EmpID', $EmpID) + ->update($data); + $count = $this->db->affectedRows(); + return $count; + } } \ No newline at end of file diff --git a/app/Models/User_model.php b/app/Models/User_model.php index 0d996a9b..8098fd00 100644 --- a/app/Models/User_model.php +++ b/app/Models/User_model.php @@ -134,14 +134,17 @@ class User_model extends Model * @param number $userId : This is user id * @return boolean $result : TRUE / FALSE */ - function deleteUser($userId, $userInfo) + function deleteUser($userId) { + // Delete the user record $this->db->table('tbl_users') ->where('userId', $userId) - ->update($userInfo); - + ->delete(); + + // Return the number of affected rows to confirm the deletion return $this->db->affectedRows(); } + /** @@ -157,7 +160,6 @@ class User_model extends Model $query = $builder->get(); $user = $query->getResult(); - if (!empty($user)) { if (password_verify($oldPassword, $user[0]->password)) { @@ -215,7 +217,9 @@ class User_model extends Model $builder = $this->db->table('t_employee_details EMP') ->select('EMP.EmpID,EMP.FirstName,EMP.LastName,EMP.Designation,EMP.EmailId,EMP.ContactNumber,DEPT.DEPCode,DEPT.DepartmentName') ->join('t_departmentdetails DEPT', 'EMP.Departmentcode = DEPT.DEPCode') - ->where('EMP.IsActive ', 1); + ->join('tbl_users U', 'EMP.EmpID = U.EmpID', 'left') + ->where('EMP.IsActive ', 1) + ->where('U.EmpID IS NULL'); $query = $builder->get(); return $query->getResult(); } @@ -311,10 +315,9 @@ GROUP BY financial_year "; function findEmp($EmpId) { - $builder = $this->db->table('tbl_users') - ->select('tbl_users.*, t_employee_details.*') - ->join('t_employee_details', 'tbl_users.EmpID = t_employee_details.EmpID' ,'left') - ->where('tbl_users.EmpID', $EmpId); + $builder = $this->db->table('t_employee_details') + ->select('t_employee_details.*') + ->where('t_employee_details.EmpID', $EmpId); $query = $builder->get(); return $query->getResult(); diff --git a/app/Views/Report_pending_purchase.php b/app/Views/Report_pending_purchase.php index 321afeac..03bc0e6f 100644 --- a/app/Views/Report_pending_purchase.php +++ b/app/Views/Report_pending_purchase.php @@ -129,7 +129,7 @@
- +
@@ -138,7 +138,7 @@
- +
diff --git a/app/Views/addEmployeenew.php b/app/Views/addEmployeenew.php new file mode 100644 index 00000000..50414640 --- /dev/null +++ b/app/Views/addEmployeenew.php @@ -0,0 +1,1431 @@ + + +
+
+
+
+
+
+
+
+
+

Add Employee

+
+
+
+ Back +
+
+
+ + +
+ +
+ +
+
+ +
+
+ your image
+ + +
+
+
+
+
+ Full Name* + +
+ +
Father / Husband Name* + +
+ +
Contact Number* + +
+ +
Gender* + +
+
Date Of Birth* + +
+
+
+
Age + +
+
Personal Email ID + +
+
Official Email ID + +
+
+ + Blood group* + +
+ +
+ Marital Status* + +
+
+
+
+ Current Address* + +
+
+ Current address same as permanent address +
+
+ Permanent Address* + +
+
+
+
+ Emergency Contact Name + +
+ +
+ Emergency Contact Number + +
+
+
+
+ +
+ +
+ +
+
+
+
+
+
+
+
Designation* + + +
+
Department* + + +
+
Date Of Joining* + +
+
Previous Years of Experience + +
+
+
+ +
Qualification* + + +
+ + + +
+
+ +
Work Location* + + +
+
+
+ Management + Team + +
+
+
+
+
+
+ +
+ +
+ +
+
+
+
+
+
+
+
Bank Name* + +
+
Account Number* + +
+
IFSC Code* + +
+
Bank Address + +
+
+
+ + +
+
+
+
+
+
+
+
+ Total Salary + * + + + +
+
+
+
+ Basic Pay + * + + +
+
+
+
+ HRA Rate(%) + * + + +
+
+
+
+ HRA Amount + * + + +
+
+
+
+ ESI + Applicable + +
+
+
+
ESI Number + +
+
+
+
+ ESI Rate(%) + * + + +
+
+
+
+
+ PF + Applicable + +
+
+
+
UAN + +
+
+ +
+
+ PF Rate(%) + * + + +
+
+
+
+ +
+ +
+ +
+ +
+
+
+
+
+
+
+
Aadhar Number * + +
+
PAN Number + +
+
Passport Number + +
+
Passport Expiry Date + +
+ +
Voter ID + +
+
Driving License + +
+ +
Driving License Expiry Date + +
+ +
+
+
+
+
+
+
+
+
Nominee reference + +
+ +
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ File Name + +
+
+ File + +
+
+ +
+
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/app/Views/addUser.php b/app/Views/addUser.php index 4b7e8135..b1a13a43 100644 --- a/app/Views/addUser.php +++ b/app/Views/addUser.php @@ -81,22 +81,6 @@ ?> - -
- - -
@@ -194,7 +178,6 @@ $("#Designation").val(data.userInfo[0].Designation); $("#MailID").val(data.userInfo[0].EmailId); $("#ContactNo").val(data.userInfo[0].ContactNumber); - $("#Department").val(data.userInfo[0].DepartmentName); } else { alert('Employee not found'); } @@ -210,7 +193,6 @@ $("#Designation").val(''); $("#MailID").val(''); $("#ContactNo").val(''); - $("#Department").val(''); } }); }); @@ -218,20 +200,17 @@ $('#addPop').click(function() { if ($('#distriList option:selected').val() != null) { if ($('#distriList option:selected').val() == 0) { - alert('please select Department'); } else { var tempSelect = $('#distriList option:selected').val(); var tempText = $('#distriList option:selected').text(); var o = new Option(tempText, tempSelect); var hidval = tempSelect; - var orgVal = $('#txtSelectedDepartment').val(); var Selectedval = '' if (orgVal != '') { Selectedval = orgVal + ':' + hidval; } else { Selectedval = hidval } - $('#txtSelectedDepartment').val(Selectedval); $(o).html(tempText); $("#selectDistriList").append(o); $('#distriList option:selected').remove(); diff --git a/app/Views/addemppaydate.php b/app/Views/addemppaydate.php index 835df076..3b78043a 100644 --- a/app/Views/addemppaydate.php +++ b/app/Views/addemppaydate.php @@ -1,303 +1,290 @@ - -
- -
-
-

Add Employee Pay

-
-
- -
-
- Back -
-
-
- -
- - -
- - - -
- - -
- - - - - - -
- Loan Details -
- -
- -
-
- Employee ID - * -
- - 'Select Employee'); - - if(!empty($empdetails)){ - foreach($empdetails as $emp){ - $EmpID=$emp->EmpID; - $Employee+= array($EmpID => $emp->EmpID . "-" . $emp->FirstName); - - } - } - - $js = array('id'=> 'emp'); - echo form_dropdown('EmpID', $Employee,set_value('EmpID'),'class="form-control"',$js); - - ?> -
-
-
- - -
-
-
- - - Loan Amount - -
-
-
- - - - -
-
-
- Loan Issue(d) Date - -
-
-
- - -
-
-
- Monthly Due - -
-
-
-
-
-
- Due Started - -
-
-
-
-
-
- No Of Due(s) - -
-
-
-
-
-
- Paid Amount - -
-
-
- - -
- - - -
- - -
- - -
-
-
- getFlashdata('error'); - if($error) - { - ?> -
- - getFlashdata('error'); ?> -
- - getFlashdata('success'); - if($success) - { - ?> -
- - getFlashdata('success'); ?> -
- - -
-
- listErrors('
', '
'); ?> +
+
+ +
+ +
+
+
+

Create Loan

+
+ Back +
-
-
+ +
+
+
+
+

Loan Details

+
+
+
+
+
+ +
+
+
+
+ Employee ID + * +
+ + 'Select Employee'); + + if (!empty($empdetails)) { + foreach ($empdetails as $emp) { + $EmpID = $emp->EmpID; + $Employee += array($EmpID => $emp->EmpID . "-" . $emp->FirstName); + } + } + + $js = array('id' => 'emp'); + echo form_dropdown('EmpID', $Employee, set_value('EmpID'), 'class="form-control"', $js); + + ?> +
+
+
+
+
+
+ Loan Amount + +
+
+
+
+
+
+ Loan Issue(d) Date + +
+
+
+
+
+
+ Monthly Due + +
+
+
+
+
+
+
+
+ Due Started + +
+
+
+
+
+
+ No Of Due(s) + +
+
+
+
+
+
+ Paid Amount + +
+
+
+
+ + +
+
+
+ + +
+
+ +
+
+ getFlashdata('listErrors'); + if ($listErrors) { + ?> +
+
+
+ + getFlashdata('listErrors'); ?> +
+
+
+ + +
+ getFlashdata('error'); + if ($error) { + ?> +
+ + getFlashdata('error'); ?> +
+ + + getFlashdata('success'); + if ($success) { + ?> +
+ + getFlashdata('success'); ?> +
+ + +
+
+
+
+ +
+ + - \ No newline at end of file diff --git a/app/Views/alterpurchaseorder.php b/app/Views/alterpurchaseorder.php index d331a1e1..f10c9456 100644 --- a/app/Views/alterpurchaseorder.php +++ b/app/Views/alterpurchaseorder.php @@ -1901,39 +1901,39 @@ if (!empty($INRSYMBOL)) { } $(document).ready(function() { $('#ServiceMaterialCode').change(function() { - var selectedMaterialCode = ''; - selectedMaterialCode = $("#ServiceMaterialCode").val(); - $.each(JSON.parse(materialData), function(index, value) { - if (selectedMaterialCode == value.MaterialCode) { - $("#ServiceDescription").val(value.MaterialName); - $("#ServiceUOM").val(value.UOM); - if ($('#ScheduleType').val().trim() != 'Recurring') { - $('#FrequencyChange').val('One Time'); + var selectedMaterialCode = ''; + selectedMaterialCode = $("#ServiceMaterialCode").val(); + $.each(JSON.parse(materialData), function(index, value) { + if (selectedMaterialCode == value.MaterialCode) { + $("#ServiceDescription").val(value.MaterialName); + $("#ServiceUOM").val(value.UOM); + if ($('#ScheduleType').val().trim() != 'Recurring') { + $('#FrequencyChange').val('One Time'); - $('#ServiceNo').val(1); - } else { - $('#FrequencyChange').val($('#ScheduleType').val()); + $('#ServiceNo').val(1); + } else { + $('#FrequencyChange').val($('#ScheduleType').val()); + } } - } + + }); + var d = $('#drpSupplier').val(); + $.ajax({ + url: "VerifyWithSupplierForPendingPO", + type: 'POST', + data: { + supplierid: d, + materialcode: selectedMaterialCode + }, + success: function(response) { + if (response) alert(response); + } + }); }); - var d = $('#drpSupplier').val(); - $.ajax({ - url: "VerifyWithSupplierForPendingPO", - type: 'POST', - data: { - supplierid: d, - materialcode: selectedMaterialCode - }, - success: function(response) { - if (response) alert(response); - } - }); - - }); let materialData; @@ -2309,7 +2309,6 @@ if (!empty($INRSYMBOL)) { 'form-label-left CreatealterPO ', 'name' => 'CreatealterPO', 'id' => 'CreatealterPO'); - echo form_open(base_url() . '/purchaseorder/addalterPO/', $attributes); ?>
@@ -2559,7 +2558,8 @@ if (!empty($INRSYMBOL)) {
'PODate', 'value' => set_value('PODate', $CurrentDate), 'id' => 'PODate', 'class' => 'form-control', 'required' => 'true', 'onkeypress' => 'return false;'); + $formattedDate = $dt->format('Y-m-d'); + $data = array('type' => 'date', 'name' => 'PODate', 'value' => set_value('PODate', $formattedDate), 'id' => 'PODate', 'class' => 'form-control', 'required' => 'true', 'onkeypress' => 'return false;'); echo form_input($data); ?>
@@ -2759,7 +2759,7 @@ if (!empty($INRSYMBOL)) {
-
+