whoami7 - Manager
:
/
home
/
papecmvm
/
public_html
/
application
/
controllers
/
webapp
/
master
/
Upload File:
files >> //home/papecmvm/public_html/application/controllers/webapp/master/Ledger.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Ledger extends CI_Controller { function __construct() { parent::__construct(); $this->load->model('app', "model"); $CI = & get_instance(); $this->db = $CI->load->database('default', TRUE); $this->db2 = $CI->load->database('db2', TRUE); } public function index($offset = '0') { $data['count'] = $this->model->getDatamodel('tbl_registration'); $cnt=count($data['count']); $this->load->library('pagination'); $config['base_url'] = base_url().'webapp/master/ledger/index'; $config['total_rows'] = $cnt; $config['per_page'] = 25; $config['full_tag_open'] = '<div class="pagination"><ul class="list-inline">'; $config['full_tag_close'] = '</ul></div>'; $config['first_link'] = '« First'; $config['first_tag_open'] = '<li class="prev page">'; $config['first_tag_close'] = '</li>'; $config['last_link'] = 'Last »'; $config['last_tag_open'] = '<li class="next page">'; $config['last_tag_close'] = '</li>'; $config['next_link'] = 'Next →'; $config['next_tag_open'] = '<li class="next page">'; $config['next_tag_close'] = '</li>'; $config['prev_link'] = '← Previous'; $config['prev_tag_open'] = '<li class="prev page">'; $config['prev_tag_close'] = '</li>'; $config['cur_tag_open'] = '<li class="active"><a href="">'; $config['cur_tag_close'] = '</a></li>'; $config['num_tag_open'] = '<li class="page">'; $config['num_tag_close'] = '</li>'; $this->pagination->initialize($config); $data['ledger'] = $this->model->getLedger($config['per_page'], $offset); $where_cust = array('type' => 'customer', 'status' =>'1'); $data['cust'] = $this->db2->get_where('tbl_registration', $where_cust)->result_array(); $this->load->view("webapp/master/ledger/view", $data); } public function add() { if($this->input->post('save')=='save') { //$gid = implode(',', $this->input->post('gid')); if($this->input->post('bal_type') == 'Dr'){ $ob = $this->input->post('open_balance'); $ob = '-'.$ob; }else{ $ob = $this->input->post('open_balance'); } $data = array( 'gid' => $this->input->post('gid'), 'l_name'=>$this->input->post('l_name'), 'rid'=>$this->input->post('rid'), 'sg_id'=>$this->input->post('sg_id'), 'open_balance'=> $ob, 'bal_type'=>$this->input->post('bal_type'), 'state'=>$this->input->post('state'), 'city'=>$this->input->post('city'), 'address'=>$this->input->post('address'), 'gst'=>$this->input->post('gst'), 'pan'=>$this->input->post('pan') ); $this->model->insertData('tbl_ledger', $data); $this->session->set_flashdata('msg', ' <div class="alert alert-success alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span></button> <strong>Success!</strong> Data has been Inserted. </div>'); redirect('webapp/master/ledger'); }else{ $where_cust = array('type' => 'customer', 'status' =>'1'); $data['cust'] = $this->db2->get_where('tbl_registration', $where_cust)->result_array(); $data['group'] = $this->model->getDatamodel('tbl_group'); $this->load->view("webapp/master/ledger/add", $data); } } public function add_ajax() { //$gid = implode(',', $this->input->post('gid')); if($this->input->post('bal_type') == 'Dr'){ $ob = $this->input->post('open_balance'); $ob = '-'.$ob; }else{ $ob = $this->input->post('open_balance'); } $data = array( 'gid' => $this->input->post('gid'), 'l_name'=>$this->input->post('l_name'), 'rid'=>$this->input->post('rid'), 'sg_id'=>$this->input->post('sg_id'), 'open_balance'=>$ob, 'bal_type'=>$this->input->post('bal_type'), 'state'=>$this->input->post('state'), 'city'=>$this->input->post('city'), 'address'=>$this->input->post('address'), 'gst'=>$this->input->post('gst'), 'pan'=>$this->input->post('pan') ); $this->model->insertData('tbl_ledger', $data); $ledger = $this->model->getFormLedger($this->input->post('rid')); $html = ''; $html.=' <select class="form-control multiselect" name="ms_ledger" required> <option value="">--SELECT--</option>'; foreach($ledger as $key => $led){ $html.='<option value="'.$led['lid'].'">'.$led['l_name'].'</option>'; } $html.='</select> '; $resultArrauy['html'] = $html; echo json_encode($resultArrauy); } public function add_ajax_two() { //$gid = implode(',', $this->input->post('gid')); if($this->input->post('bal_type') == 'Dr'){ $ob = $this->input->post('open_balance'); $ob = '-'.$ob; }else{ $ob = $this->input->post('open_balance'); } $data = array( 'gid' => $this->input->post('gid'), 'l_name'=>$this->input->post('l_name'), 'rid'=>$this->input->post('rid'), 'sg_id'=>$this->input->post('sg_id'), 'open_balance'=>$ob, 'bal_type'=>$this->input->post('bal_type'), 'state'=>$this->input->post('state'), 'city'=>$this->input->post('city'), 'address'=>$this->input->post('address'), 'gst'=>$this->input->post('gst'), 'pan'=>$this->input->post('pan') ); $this->model->insertData('tbl_ledger', $data); $stage = $this->input->post('stage'); $where = array('voucher' => $stage); $ledger = $this->model->DetailData('tbl_grouped_voucher', $where); $gid = explode('|', $ledger[0]['gid']); //$new_ledger = $this->model->get_gl($gid, $this->input->post('cid')); $new_ledger = $this->model->selGroup($where, $this->input->post('rid')); $html = ''; $html.=' <select class="form-control multiselect" name="ms_ledger"> <option value="0">--SELECT--</option>'; foreach($new_ledger as $key => $led){ $html.='<option value="'.$led['lid'].'">'.$led['l_name'].'</option>'; } $html.='</select> '; $resultArrauy['html'] = $html; echo json_encode($resultArrauy); } public function edit($enc_id) { $lid = $this->model->decryptdata($enc_id); if($this->input->post('save')=='save') { //echo "<pre>"; print_r ($_POST); echo "</pre>"; die; //$gid = implode(',', $this->input->post('gid')); $data = array( 'gid' => $this->input->post('gid'), 'l_name'=>$this->input->post('l_name'), 'rid'=>$this->input->post('rid'), 'sg_id'=>$this->input->post('sg_id'), 'open_balance'=>$this->input->post('open_balance'), 'bal_type'=>$this->input->post('bal_type'), 'state'=>$this->input->post('state'), 'city'=>$this->input->post('city'), 'address'=>$this->input->post('address'), 'gst'=>$this->input->post('gst'), 'pan'=>$this->input->post('pan') ); //echo $enc_id; die; $where = array('lid' => $enc_id); $this->model->UpdateData('tbl_ledger', $data, $where); $this->session->set_flashdata('msg', ' <div class="alert alert-success alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span></button> <strong>Success!</strong> Data has been Uploaded. </div>'); $rid = $this->db2->get_where('tbl_ledger', array('lid' => $enc_id))->row('rid'); $encrypt = $this->model->encryptdata($rid); redirect('webapp/master/ledger/view_ledger/'.$encrypt); }else{ $where_cust = array('type' => 'customer', 'status' =>'1'); $data['cust'] = $this->db2->get_where('tbl_registration', $where_cust)->result_array(); $where = array('lid' => $lid); $data['ledger'] = $this->model->DetailData('tbl_ledger', $where); $data['group'] = $this->model->getDatamodel('tbl_group'); $gid = $data['ledger'][0]['gid']; $data['sub_group'] = $this->db2->get_where('tbl_subgroup', array('gid' => $gid))->result_array(); $this->load->view("webapp/master/ledger/add", $data); } } public function trash($enc_id) { $lid = $this->model->decryptdata($enc_id); $where = array('lid' => $lid); $this->model->DeleteData('tbl_ledger', $where); $this->session->set_flashdata('msg', ' <div class="alert alert-success alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span></button> <strong>Success!</strong> Data has been Deleted. </div>'); redirect('webapp/master/ledger'); } public function get_subgr($gid){ $data = $this->db2->get_where('tbl_subgroup', array('gid' => $gid))->result_array(); $html = ''; $html.='<option value="">--Select--</option>'; foreach ($data as $k => $v) { $html.='<option value="'.$v["sg_id"].'">'.$v["sg_name"].'</option>'; } $array['html'] = $html; echo json_encode($array); } public function import_ledger(){ $this->load->library('excel'); //echo "<pre>"; print_r ($_POST); echo "</pre>"; //echo "<pre>"; print_r ($_FILES); echo "</pre>"; $rid = $this->input->post('rid'); if(isset($_FILES["ledger_file"]["name"])) { $path = $_FILES["ledger_file"]["tmp_name"]; $object = PHPExcel_IOFactory::load($path); foreach($object->getWorksheetIterator() as $worksheet) { $highestRow = $worksheet->getHighestRow(); $highestColumn = $worksheet->getHighestColumn(); for($row=2; $row<=$highestRow; $row++) { $l_name = $worksheet->getCellByColumnAndRow(0, $row)->getValue(); $open_balance = $worksheet->getCellByColumnAndRow(1, $row)->getValue(); if($open_balance < 0){ $bal_type = 'Dr'; }else{ $bal_type = 'Cr'; } $group = $worksheet->getCellByColumnAndRow(2, $row)->getValue(); if($group != ''){ $gid = $this->model->getGroupID($group); }else{ $gid = $this->model->getGroupID('Suspense A/c'); } $sub_group = $worksheet->getCellByColumnAndRow(3, $row)->getValue(); if($sub_group != ''){ $sg_id = $this->model->getSubGroupID($sub_group); }else{ $sg_id = 0; } $state = $worksheet->getCellByColumnAndRow(4, $row)->getValue(); $city = $worksheet->getCellByColumnAndRow(5, $row)->getValue(); $address = $worksheet->getCellByColumnAndRow(6, $row)->getValue(); $gst = $worksheet->getCellByColumnAndRow(7, $row)->getValue(); $pan = $worksheet->getCellByColumnAndRow(8, $row)->getValue(); $data = array( 'l_name' => $l_name, 'open_balance' => $open_balance, 'bal_type' => $bal_type, 'gid' => $gid, 'sg_id' => $sg_id, 'rid' => $rid, 'state' => $state, 'city' => $city, 'address' => $address, 'gst' => $gst, 'pan' => $pan ); $this->model->insertData('tbl_ledger', $data); } } //echo "<pre>"; print_r ($data); echo "</pre>"; } $this->session->set_flashdata('msg', ' <div class="alert alert-success alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span></button> <strong>Success!</strong> New Ledgers has been imported. </div>'); redirect('webapp/master/ledger'); } public function view_ledger($enc_id, $offset = '0'){ $rid = $this->model->decryptdata($enc_id); $cnt = $this->db2->get_where('tbl_ledger', array('rid' => $rid))->num_rows(); $this->load->library('pagination'); $config['base_url'] = base_url().'webapp/master/ledger/view_ledger/'.$enc_id; $config['total_rows'] = $cnt; $config['per_page'] = 25; $config['full_tag_open'] = '<div class="pagination"><ul class="list-inline">'; $config['full_tag_close'] = '</ul></div>'; $config['first_link'] = '« First'; $config['first_tag_open'] = '<li class="prev page">'; $config['first_tag_close'] = '</li>'; $config['last_link'] = 'Last »'; $config['last_tag_open'] = '<li class="next page">'; $config['last_tag_close'] = '</li>'; $config['next_link'] = 'Next →'; $config['next_tag_open'] = '<li class="next page">'; $config['next_tag_close'] = '</li>'; $config['prev_link'] = '← Previous'; $config['prev_tag_open'] = '<li class="prev page">'; $config['prev_tag_close'] = '</li>'; $config['cur_tag_open'] = '<li class="active"><a href="">'; $config['cur_tag_close'] = '</a></li>'; $config['num_tag_open'] = '<li class="page">'; $config['num_tag_close'] = '</li>'; $this->pagination->initialize($config); $data['ledger'] = $this->model->getLedgerView($rid, $config['per_page'], $offset); $this->load->view("webapp/master/ledger/viewLedger", $data); } public function ledger_xml($enc_id){ $rid = $this->model->decryptdata($enc_id); $data['cust'] = $this->db2->get_where('tbl_registration', array('rid' => $rid))->row_array(); $data['ledger'] = $this->model->getLedgerXml($rid); //echo "<pre>"; print_r ($data['ledger']); echo "</pre>"; die; $this->load->view("webapp/master/ledger/ledger_xml", $data); } public function test(){ //echo "hi"; $data = $this->model->getDatamodel('tbl_ledger'); if (!empty($data)) { $html = '<option value="" >Select</option>'; foreach ($data as $val) { $sp_id = $val['lid']; $job_fun_spec = $val['l_name']; $html .= '<option value="' . $sp_id . '" >' . $job_fun_spec . '</option>'; } } else { $html = '<option value="" >Select</option>'; } if (!empty($data)) { $resultArrauy['status'] = 'Success'; $resultArrauy['html'] = $html; echo json_encode($resultArrauy); } else { $resultArrauy['status'] = 'error'; $resultArrauy['html'] = $html; echo json_encode($resultArrauy); } } }
Copyright ©2021 || Defacer Indonesia