load->model('department_model'); $this->load->library('form_validation'); $this->load->library('pagination'); $this->load->library('Excel'); $this->isLoggedIn(); } /** * This function used to load the first screen of the user */ public function index() { $this->global['pageTitle'] = 'Siddharth : Department'; $this->loadViews("departmentListing", $this->global, NULL , NULL); } /** * This function is used to load the Supplier list */ function departmentListing() { $this->load->model('department_model'); $searchText = $this->input->post('searchText'); $data['searchText'] = $searchText; $count = $this->department_model->departmentListing($searchText); $returns = $this->paginationCompress ( "departmentListing/", $count, 20 ); $data['userRecords'] = $this->department_model->departmentListing($searchText, $returns["page"], $returns["segment"]); $this->global['pageTitle'] = 'Siddharth Industries : department Listing'; $this->loadViews("departmentListing", $this->global, $data, NULL); } /** * This function is used to load the add new supplier */ function adddepartment() { //$data['payment'] = $this->department_model->getpayment(); $data['depcode'] = $this->department_model->getdepcode(); $this->global['pageTitle'] = 'siddharth : AddNew Department'; $this->loadViews("adddepartment", $this->global,$data, NULL); } function addNewdepartment() { $DepartmentName = $this->input->post('DepartmentName'); $DEPCode = $this->input->post('DEPCode'); $HeadDept = $this->input->post('HeadDept'); $Createdby = $this->session->userdata ( 'userId' ); $chked = $this->input->post('IsActive'); if( $chked != '') { $IsActive = '1'; } else { $IsActive = '0'; } $department = array('DepartmentName'=>$DepartmentName, 'DEPCode'=>$DEPCode, 'HeadDept'=>$HeadDept,'Createdby'=>$Createdby,'IsActive'=>$IsActive); $result = $this->department_model->addNewdepartment($department); if($result > 0) { redirect('departmentListing','refresh'); echo ""; } else { redirect('departmentListing','refresh'); echo ""; } } function getDateformat($Val) { $date = new DateTime($Val); $retDate = $date->format('Y-m-d H:i:s'); return $retDate; } /** * This function is used to edit the department information */ function editdepartment() { $DepartmentName = $this->input->post('DepartmentName'); $DEPCode = $this->input->post('DEPCode'); $HeadDept = $this->input->post('HeadDept'); $Createdby = $this->session->userdata ( 'userId' ); $chked = $this->input->post('IsActive'); if( $chked != '') { $IsActive = '1'; } else { $IsActive = '0'; } $department = array('DepartmentName'=>$DepartmentName, 'DEPCode'=>$DEPCode,'HeadDept'=>$HeadDept,'IsActive'=>$IsActive); $result = $this->department_model->Updatedepartment($department, $DEPCode); if($result == True) { redirect('departmentListing','refresh'); echo ""; } else { redirect('departmentListing','refresh'); echo ""; } } function viewdepartment($SID = '') { //print_r('hello');die(); if($SID == '') { $DepartmentID = $_GET['SID']; } else { $DepartmentID = $SID; } $data['department'] = $this->department_model->getDeptInfo($DepartmentID); $data['depcode'] = $this->department_model->getdepcode(); $this->global['pageTitle'] = 'Siddharth : Edit Supplier'; $this->loadViews("editdepartment", $this->global,$data, NULL); } /** this function can be use for excel report **/ function export_departmentdetails(){ $this->load->library('excel'); $this->excel->setActiveSheetIndex(0); $this->excel->getActiveSheet()->setTitle('supplier 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()->getStyle('A1')->getFont()->setSize(12); $this->excel->getActiveSheet()->getStyle('A1')->getFont()->setBold(true); $this->excel->getActiveSheet()->getStyle('B1')->getFont()->setSize(12); $this->excel->getActiveSheet()->getStyle('B1')->getFont()->setBold(true); $this->excel->getActiveSheet()->getStyle('C1')->getFont()->setSize(12); $this->excel->getActiveSheet()->getStyle('C1')->getFont()->setBold(true); $this->excel->getActiveSheet()->getStyle('D1')->getFont()->setSize(12); $this->excel->getActiveSheet()->getStyle('D1')->getFont()->setBold(true); $this->excel->getActiveSheet()->getStyle('E1')->getFont()->setSize(12); $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(); 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']); $i++; $s++; } } $filename = 'supplierdetails' .' '. '.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 $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5'); if (ob_get_contents()) ob_end_clean(); ob_start(); $objWriter->save('php://output'); } function pageNotFound() { $this->global['pageTitle'] = 'Siddharth : 404 - Page Not Found'; $this->loadViews("404", $this->global, NULL, NULL); } } ?>