diff --git a/application/controllers/department.php b/application/controllers/department.php index 148e921f..897c8657 100755 --- a/application/controllers/department.php +++ b/application/controllers/department.php @@ -18,8 +18,8 @@ class department extends BaseController { parent::__construct(); $this->load->model('department_model'); - $this->load->library('form_validation'); - $this->load->library('pagination'); + // $this->load->library('form_validation'); + // $this->load->library('pagination'); $this->load->library('Excel'); $this->isLoggedIn(); } @@ -29,33 +29,35 @@ class department extends BaseController public function index() { - $this->global['pageTitle'] = 'Siddharth : Department'; + $this->global['pageTitle'] = 'Siddharth : Department Details'; $this->loadViews("departmentListing", $this->global, NULL , NULL); } /** - * This function is used to load the Supplier list + * This function is used to load the Department list */ function departmentListing() { - + if($this->isAdmin() == TRUE) + { + $this->loadThis(); + } + else + { $this->load->model('department_model'); - $searchText = $this->input->post('searchText'); - $data['searchText'] = $searchText; - + //$searchText = $this->input->post('searchText'); + //$data['searchText'] = $searchText; + //$count = $this->department_model->departmentListing($searchText); + //$returns = $this->paginationCompress ( "departmentListing/", $count, 20 ); - $count = $this->department_model->departmentListing($searchText); - - $returns = $this->paginationCompress ( "departmentListing/", $count, 20 ); + $data['userRecords'] = $this->department_model->departmentListing();//$searchText, $returns["page"], $returns["segment"]); - $data['userRecords'] = $this->department_model->departmentListing($searchText, $returns["page"], $returns["segment"]); - - $this->global['pageTitle'] = 'Siddharth Industries : department Listing'; + $this->global['pageTitle'] = 'Siddharth Industries : Department Listing'; $this->loadViews("departmentListing", $this->global, $data, NULL); - + } } /** * This function is used to load the add new supplier */ @@ -63,6 +65,7 @@ class department extends BaseController { //$data['payment'] = $this->department_model->getpayment(); + //$data['depcode'] = $this->department_model->getdepcode(); $data['depcode'] = $this->department_model->getdepcode(); $this->global['pageTitle'] = 'siddharth : AddNew Department'; @@ -76,8 +79,6 @@ class department extends BaseController function addNewdepartment() { - - $DepartmentName = $this->input->post('DepartmentName'); $DEPCode = $this->input->post('DEPCode'); $HeadDept = $this->input->post('HeadDept'); @@ -98,14 +99,15 @@ class department extends BaseController if($result > 0) { - redirect('departmentListing','refresh'); - echo ""; + echo ""; + redirect('departmentListing','refresh'); } else { - redirect('departmentListing','refresh'); - echo ""; + echo ""; + redirect('departmentListing','refresh'); + } } @@ -145,14 +147,14 @@ class department extends BaseController if($result == True) { - redirect('departmentListing','refresh'); - echo ""; + echo ""; + redirect('departmentListing','refresh'); } else { + echo ""; redirect('departmentListing','refresh'); - echo ""; } @@ -191,33 +193,16 @@ class department extends BaseController $this->load->library('excel'); $this->excel->setActiveSheetIndex(0); - $this->excel->getActiveSheet()->setTitle('supplier details'); + $this->excel->getActiveSheet()->setTitle('Department Details'); - $this->excel->getActiveSheet()->setCellValue('A1', 'DepartmentID'); - $this->excel->getActiveSheet()->setCellValue('B1', 'SupplierName'); - $this->excel->getActiveSheet()->setCellValue('C1', 'Address'); - $this->excel->getActiveSheet()->setCellValue('D1', 'ContactNumber'); - $this->excel->getActiveSheet()->setCellValue('E1', 'AlternateContactNumber'); - $this->excel->getActiveSheet()->setCellValue('F1', 'EmailAddress'); - $this->excel->getActiveSheet()->setCellValue('G1', 'Exiseregistration'); - $this->excel->getActiveSheet()->setCellValue('H1', 'TIN'); - $this->excel->getActiveSheet()->setCellValue('I1', 'PAN'); - $this->excel->getActiveSheet()->setCellValue('J1', 'CSTNO'); - $this->excel->getActiveSheet()->setCellValue('K1', 'CST Date'); - $this->excel->getActiveSheet()->setCellValue('L1', 'GST NO'); - $this->excel->getActiveSheet()->setCellValue('M1', 'GST Range'); - $this->excel->getActiveSheet()->setCellValue('N1', 'Collectrate Address'); - $this->excel->getActiveSheet()->setCellValue('O1', 'UANumber'); - $this->excel->getActiveSheet()->setCellValue('P1', 'PaymentTerms'); - $this->excel->getActiveSheet()->setCellValue('Q1', 'PaymentDays'); - $this->excel->getActiveSheet()->setCellValue('R1', 'PayableAT'); - $this->excel->getActiveSheet()->setCellValue('S1', 'Createdby'); - $this->excel->getActiveSheet()->setCellValue('T1', 'UpdatedBy'); - $this->excel->getActiveSheet()->setCellValue('U1', 'IsActive'); + $this->excel->getActiveSheet()->setCellValue('A1', 'Department ID'); + $this->excel->getActiveSheet()->setCellValue('B1', 'Department Name'); + $this->excel->getActiveSheet()->setCellValue('C1', 'Head Deptment ID'); + $this->excel->getActiveSheet()->setCellValue('D1', 'Is Active'); + $this->excel->getActiveSheet()->setCellValue('E1', 'Created By'); + $this->excel->getActiveSheet()->setCellValue('F1', 'Created Date'); - - $this->excel->getActiveSheet()->getStyle('A1')->getFont()->setSize(12); $this->excel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true); $this->excel->getActiveSheet()->getStyle('B1')->getFont()->setSize(12); @@ -230,77 +215,28 @@ class department extends BaseController $this->excel->getActiveSheet()->getStyle('E1')->getFont()->setBold(true); $this->excel->getActiveSheet()->getStyle('F1')->getFont()->setSize(12); $this->excel->getActiveSheet()->getStyle('F1')->getFont()->setBold(true); - $this->excel->getActiveSheet()->getStyle('G1')->getFont()->setSize(12); - $this->excel->getActiveSheet()->getStyle('G1')->getFont()->setBold(true); - $this->excel->getActiveSheet()->getStyle('H1')->getFont()->setSize(12); - $this->excel->getActiveSheet()->getStyle('H1')->getFont()->setBold(true); - $this->excel->getActiveSheet()->getStyle('I1')->getFont()->setSize(12); - $this->excel->getActiveSheet()->getStyle('I1')->getFont()->setBold(true); - $this->excel->getActiveSheet()->getStyle('J1')->getFont()->setSize(12); - $this->excel->getActiveSheet()->getStyle('J1')->getFont()->setBold(true); - $this->excel->getActiveSheet()->getStyle('K1')->getFont()->setSize(12); - $this->excel->getActiveSheet()->getStyle('K1')->getFont()->setBold(true); - $this->excel->getActiveSheet()->getStyle('L1')->getFont()->setSize(12); - $this->excel->getActiveSheet()->getStyle('L1')->getFont()->setBold(true); - $this->excel->getActiveSheet()->getStyle('M1')->getFont()->setSize(12); - $this->excel->getActiveSheet()->getStyle('M1')->getFont()->setBold(true); - $this->excel->getActiveSheet()->getStyle('N1')->getFont()->setSize(12); - $this->excel->getActiveSheet()->getStyle('N1')->getFont()->setBold(true); - $this->excel->getActiveSheet()->getStyle('O1')->getFont()->setSize(12); - $this->excel->getActiveSheet()->getStyle('O1')->getFont()->setBold(true); - $this->excel->getActiveSheet()->getStyle('P1')->getFont()->setSize(12); - $this->excel->getActiveSheet()->getStyle('P1')->getFont()->setBold(true); - $this->excel->getActiveSheet()->getStyle('Q1')->getFont()->setSize(12); - $this->excel->getActiveSheet()->getStyle('Q1')->getFont()->setBold(true); - $this->excel->getActiveSheet()->getStyle('R1')->getFont()->setSize(12); - $this->excel->getActiveSheet()->getStyle('R1')->getFont()->setBold(true); - $this->excel->getActiveSheet()->getStyle('S1')->getFont()->setSize(12); - $this->excel->getActiveSheet()->getStyle('S1')->getFont()->setBold(true); - $this->excel->getActiveSheet()->getStyle('T1')->getFont()->setSize(12); - $this->excel->getActiveSheet()->getStyle('T1')->getFont()->setBold(true); - $this->excel->getActiveSheet()->getStyle('U1')->getFont()->setSize(12); - $this->excel->getActiveSheet()->getStyle('U1')->getFont()->setBold(true); - + - $exportData = $this->supplier_model->export_excel(); + $exportData = $this->department_model->export_excel(); if ($exportData) { $i = 2; $s = 1; foreach ($exportData as $data) { - $this->excel->getActiveSheet()->setCellValue('A' . $i,$data['DepartmentID']); - $this->excel->getActiveSheet()->setCellValue('B' . $i,$data['SupplierName']); - $this->excel->getActiveSheet()->setCellValue('C' . $i,$data['Address']); - $this->excel->getActiveSheet()->setCellValue('D' . $i,$data['ContactNumber']); - $this->excel->getActiveSheet()->setCellValue('E' . $i,$data['AlternateContactNumber']); - $this->excel->getActiveSheet()->setCellValue('F' . $i,$data['EmailAddress']); - $this->excel->getActiveSheet()->setCellValue('G' . $i,$data['Exiseregistration']); - $this->excel->getActiveSheet()->setCellValue('H' . $i,$data['TIN']); - $this->excel->getActiveSheet()->setCellValue('I' . $i,$data['PAN']); - $this->excel->getActiveSheet()->setCellValue('J' . $i,$data['CSTNO']); - $this->excel->getActiveSheet()->setCellValue('K' . $i,$data['CSTDate']); - $this->excel->getActiveSheet()->setCellValue('L' . $i,$data['GSTNO']); - $this->excel->getActiveSheet()->setCellValue('M' . $i,$data['GSTRange']); - $this->excel->getActiveSheet()->setCellValue('N' . $i,$data['CollectrateAddress']); - $this->excel->getActiveSheet()->setCellValue('O' . $i,$data['UANumber']); - $this->excel->getActiveSheet()->setCellValue('P' . $i,$data['PaymentTerms']); - $this->excel->getActiveSheet()->setCellValue('Q' . $i,$data['PaymentDays']); - $this->excel->getActiveSheet()->setCellValue('R' . $i,$data['PayableAT']); - $this->excel->getActiveSheet()->setCellValue('S' . $i,$data['firstname']); - $this->excel->getActiveSheet()->setCellValue('T' . $i,$data['Update_by']); - $this->excel->getActiveSheet()->setCellValue('U' . $i,$data['IsActive']); - - - + $this->excel->getActiveSheet()->setCellValue('A' . $i,$data['DEPCode']); + $this->excel->getActiveSheet()->setCellValue('B' . $i,$data['DepartmentName']); + $this->excel->getActiveSheet()->setCellValue('C' . $i,$data['HeadDept']); + $this->excel->getActiveSheet()->setCellValue('D' . $i,$data['firstname']); + $this->excel->getActiveSheet()->setCellValue('E' . $i,$data['CreatedDt']); + $this->excel->getActiveSheet()->setCellValue('F' . $i,$data['IsActive']); - $i++; $s++; } } - $filename = 'supplierdetails' .' '. '.xls'; //save our workbook as this file name + $filename = 'departmentdetails' .' '. '.xls'; //save our workbook as this file name header('Content-Type: application/vnd.ms-excel'); //mime type header('Content-Disposition: attachment;filename="' . $filename . '"'); //tell browser what's the file name header('Cache-Control: max-age=0'); //no cache diff --git a/application/models/department_model.php b/application/models/department_model.php index 48dfce2d..445c9350 100755 --- a/application/models/department_model.php +++ b/application/models/department_model.php @@ -7,37 +7,37 @@ class department_model extends CI_Model * @param string $searchText : This is optional search text * @return number $count : This is row count */ - function departmentListingCount($searchText = '') - { - $this->db->select('BaseT.DepartmentID, BaseT.SupplierName, BaseT.Address, BaseT.ContactNumber, BaseT.AlternateContactNumber,BaseT.EmailAddress,BaseT.Exiseregistration,BaseT.TIN,BaseT.PAN,BaseT.GSTNO,BaseT.GSTRange,BaseT.CollectrateAddress,BaseT.UANumber,BaseT.PaymentTerms,BaseT.PaymentDays,BaseT.PayableAT'); - $this->db->from('T_DepartmentDetails as BaseT'); - //$this->db->join('tbl_users as users', 'users.userId = BaseT.userId','left'); - //$this->db->join('T_SupplierDetails as ID', 'ID.DepartmentID = BaseT.DepartmentID','left'); - if(!empty($searchText)) { - $likeCriteria = "(BaseT.DepartmentID LIKE '%".$searchText."%' - OR BaseT.SupplierName LIKE '%".$searchText."%' - OR BaseT.Address LIKE '%".$searchText."%' - OR BaseT.ContactNumber LIKE '%".$searchText."%' - OR BaseT.AlternateContactNumber LIKE '%".$searchText."%' - OR BaseT.EmailAddress LIKE '%".$searchText."%' - OR BaseT.Exiseregistration LIKE '%".$searchText."%' - OR BaseT.TIN LIKE '%".$searchText."%' - OR BaseT.PAN LIKE '%".$searchText."%' - OR BaseT.GSTNO LIKE '%".$searchText."%' - OR BaseT.GSTRange LIKE '%".$searchText."%' - OR BaseT.CollectrateAddress LIKE '%".$searchText."%' - OR BaseT.UANumber LIKE '%".$searchText."%' - OR BaseT.PaymentTerms LIKE '%".$searchText."%' - OR BaseT.PaymentDays LIKE '%".$searchText."%' - OR BaseT.PayableAT LIKE '%".$searchText."%')"; - $this->db->where($likeCriteria); - } - //$this->db->where('BaseT.isDeleted', 0); - //$this->db->where('BaseT.userId !=', 1); - $query = $this->db->get(); + // function departmentListingCount($searchText = '') + // { + // $this->db->select('BaseT.DepartmentID, BaseT.SupplierName, BaseT.Address, BaseT.ContactNumber, BaseT.AlternateContactNumber,BaseT.EmailAddress,BaseT.Exiseregistration,BaseT.TIN,BaseT.PAN,BaseT.GSTNO,BaseT.GSTRange,BaseT.CollectrateAddress,BaseT.UANumber,BaseT.PaymentTerms,BaseT.PaymentDays,BaseT.PayableAT'); + // $this->db->from('T_DepartmentDetails as BaseT'); + // //$this->db->join('tbl_users as users', 'users.userId = BaseT.userId','left'); + // //$this->db->join('T_SupplierDetails as ID', 'ID.DepartmentID = BaseT.DepartmentID','left'); + // if(!empty($searchText)) { + // $likeCriteria = "(BaseT.DepartmentID LIKE '%".$searchText."%' + // OR BaseT.SupplierName LIKE '%".$searchText."%' + // OR BaseT.Address LIKE '%".$searchText."%' + // OR BaseT.ContactNumber LIKE '%".$searchText."%' + // OR BaseT.AlternateContactNumber LIKE '%".$searchText."%' + // OR BaseT.EmailAddress LIKE '%".$searchText."%' + // OR BaseT.Exiseregistration LIKE '%".$searchText."%' + // OR BaseT.TIN LIKE '%".$searchText."%' + // OR BaseT.PAN LIKE '%".$searchText."%' + // OR BaseT.GSTNO LIKE '%".$searchText."%' + // OR BaseT.GSTRange LIKE '%".$searchText."%' + // OR BaseT.CollectrateAddress LIKE '%".$searchText."%' + // OR BaseT.UANumber LIKE '%".$searchText."%' + // OR BaseT.PaymentTerms LIKE '%".$searchText."%' + // OR BaseT.PaymentDays LIKE '%".$searchText."%' + // OR BaseT.PayableAT LIKE '%".$searchText."%')"; + // $this->db->where($likeCriteria); + // } + // //$this->db->where('BaseT.isDeleted', 0); + // //$this->db->where('BaseT.userId !=', 1); + // $query = $this->db->get(); - return count($query->result()); - } + // return count($query->result()); + // } /** * This function is used to get the user listing count * @param string $searchText : This is optional search text @@ -45,37 +45,39 @@ class department_model extends CI_Model * @param number $segment : This is pagination limit * @return array $result : This is result */ - function departmentListing($searchText = '') + function departmentListing() { $this->db->select('BaseT.DepartmentName, BaseT.DEPCode, BaseT.HeadDept, BaseT.IsActive'); $this->db->from('T_DepartmentDetails as BaseT'); - if(!empty($searchText)) { - $likeCriteria = "(BaseT.DepartmentName LIKE '%".$searchText."%' - OR BaseT.DEPCode LIKE '%".$searchText."%' - OR BaseT.HeadDept LIKE '%".$searchText."%' - OR BaseT.IsActive LIKE '%".$searchText."%')"; - $this->db->where($likeCriteria); - } - //$this->db->where('BaseT.isDeleted', 0); - //$this->db->where('BaseT.userId !=', 1); - // $this->db->limit($page, $segment); + $this->db->order_by("BaseT.DEPCode", "asc"); $query = $this->db->get(); - $result = $query->result(); return $result; } + + // function ($searchText = '') + // { + // if(!empty($searchText)) { + // $likeCriteria = "(BaseT.DepartmentName LIKE '%".$searchText."%' + // OR BaseT.DEPCode LIKE '%".$searchText."%' + // OR BaseT.HeadDept LIKE '%".$searchText."%' + // OR BaseT.IsActive LIKE '%".$searchText."%')"; + // $this->db->where($likeCriteria); + // } + // //$this->db->where('BaseT.isDeleted', 0); + // //$this->db->where('BaseT.userId !=', 1); + // // $this->db->limit($page, $segment); + // $query = $this->db->get(); + + // $result = $query->result(); + // return $result; + // } /** * This function used to get user information by id * @param number $userId : This is user id * @return array $result : This is user information */ - - - - - - function addNewdepartment($department) { @@ -89,9 +91,12 @@ function addNewdepartment($department) function getdepcode() { + //$limit = 12; $this->db->distinct(); - $this->db->select('HeadDept'); + $this->db->select('DEPCode, DepartmentName'); $this->db->from('T_DepartmentDetails'); + $this->db->where('IsActive =', 1); + //$this->db->limit($limit); $query = $this->db->get(); return $query->result(); diff --git a/application/views/adddepartment.php b/application/views/adddepartment.php index ea48ed38..bbf8151e 100755 --- a/application/views/adddepartment.php +++ b/application/views/adddepartment.php @@ -80,16 +80,16 @@ -