application/controllers/Admin.php
/******MANAGE BILLING / INVOICES WITH STATUS*****/
MANAGE BILLING / INVOICES WITH STATUS
MANAGE BILLING / INVOICES WITH STATUS
function invoice($param1 = '', $param2 = '', $param3 = '')
    {
        if ($param1 == 'create') {
            $data['student_id']         = $this->input->post('student_id');
            $data['title']              = $this->input->post('title');
            $data['description']        = $this->input->post('description');
            $data['amount']             = $this->input->post('amount');
            $data['amount_paid']        = $this->input->post('amount_paid');
            $data['due']                = $data['amount'] - $data['amount_paid'];
            $data['method']             = $this->input->post('method');
						$data['status']             = $this->input->post('status');
            $data['creation_timestamp'] = strtotime($this->input->post('date'));
            $this->db->insert('invoice', $data);
            $invoice_id = $this->db->insert_id();
            $data2['invoice_id']        =   $invoice_id;
            $data2['student_id']        =   $this->input->post('student_id');
            $data2['title']             =   $this->input->post('title');
            $data2['description']       =   $this->input->post('description');
            $data2['payment_type']      =  'income';
            $data2['method']            =   $this->input->post('method');
            $data2['amount']            =   $this->input->post('amount_paid');
            $data2['timestamp']         =   strtotime($this->input->post('date'));
            $this->db->insert('payment' , $data2);
            $this->session->set_flashdata('flash_message' , get_phrase('data_added_successfully'));
            redirect(base_url() . 'admin/invoice', 'refresh');
        }
        if ($param1 == 'do_update') {
            $data['student_id']         = $this->input->post('student_id');
            $data['title']              = $this->input->post('title');
            $data['description']        = $this->input->post('description');
            $data['amount']             = $this->input->post('amount');
            $data['status']             = $this->input->post('status');
            $data['creation_timestamp'] = strtotime($this->input->post('date'));
            $this->db->where('invoice_id', $param2);
            $this->db->update('invoice', $data);
            $this->session->set_flashdata('flash_message' , get_phrase('data_updated'));
            redirect(base_url() . 'admin/invoice', 'refresh');
        } else if ($param1 == 'edit') {
            $page_data['edit_data'] = $this->db->get_where('invoice', array(
                'invoice_id' => $param2
            ))->result_array();
        }
        if ($param1 == 'take_payment') {
            $data['invoice_id']   =   $this->input->post('invoice_id');
            $data['student_id']   =   $this->input->post('student_id');
            $data['title']        =   $this->input->post('title');
            $data['description']  =   $this->input->post('description');
            $data['payment_type'] =   'income';
            $data['method']       =   $this->input->post('method');
            $data['amount']       =   $this->input->post('amount');
            $data['timestamp']    =   strtotime($this->input->post('timestamp'));
            $this->db->insert('payment' , $data);
            $data2['amount_paid']   =   $this->input->post('amount');
            $this->db->where('invoice_id' , $param2);
            $this->db->set('amount_paid', 'amount_paid + ' . $data2['amount_paid'], FALSE);
            $this->db->set('due', 'due - ' . $data2['amount_paid'], FALSE);
            $this->db->update('invoice');
            $this->session->set_flashdata('flash_message' , get_phrase('payment_successfull'));
            redirect(base_url() . 'admin/invoice', 'refresh');
        }
        if ($param1 == 'delete') {
            $this->db->where('invoice_id', $param2);
            $this->db->delete('invoice');
            $this->session->set_flashdata('flash_message' , get_phrase('data_deleted'));
            redirect(base_url() . 'admin/invoice', 'refresh');
        }
        $page_data['page_name']  = 'invoice';
        $page_data['page_title'] = get_phrase('manage_invoice/payment');
        $this->db->order_by('creation_timestamp', 'desc');
        $page_data['invoices'] = $this->db->get('invoice')->result_array();
        $this->load->view('backend/index', $page_data);
    }
function invoice ( $ param1 = '' , $ param2 = '' , $ param3 = '' ) { if ( $ param1 == 'create' ) { $ data [ 'student_id' ] = $ this -> input -> post ( 'student_id' ) ; $ data [ 'title' ] = $ this -> input -> post ( 'title' ) ; $ data [ 'description' ] = $ this -> input -> post ( 'description' ) ; $ data [ 'amount' ] = $ this -> input -> post ( 'amount' ) ; $ data [ 'amount_paid' ] = $ this -> input -> post ( 'amount_paid' ) ; $ data [ 'due' ] = $ data [ 'amount' ] - $ data [ 'amount_paid' ] ; $ data [ 'method' ] = $ this -> input -> post ( 'method' ) ; $ data [ 'status' ] = $ this -> input -> post ( 'status' ) ; $ data [ 'creation_timestamp' ] = strtotime ( $ this -> input -> post ( 'date' ) ) ; $ this -> db -> insert ( 'invoice' , $ data ) ; $ invoice_id = $ this -> db -> insert_id ( ) ; $ data2 [ 'invoice_id' ] = $ invoice_id ; $ data2 [ 'student_id' ] = $ this -> input -> post ( 'student_id' ) ; $ data2 [ 'title' ] = $ this -> input -> post ( 'title' ) ; $ data2 [ 'description' ] = $ this -> input -> post ( 'description' ) ; $ data2 [ 'payment_type' ] = 'income' ; $ data2 [ 'method' ] = $ this -> input -> post ( 'method' ) ; $ data2 [ 'amount' ] = $ this -> input -> post ( 'amount_paid' ) ; $ data2 [ 'timestamp' ] = strtotime ( $ this -> input -> post ( 'date' ) ) ; $ this -> db -> insert ( 'payment' , $ data2 ) ; $ this -> session -> set_flashdata ( 'flash_message' , get_phrase ( 'data_added_successfully' ) ) ; redirect ( base_url ( ) . 'admin/invoice' , 'refresh' ) ; } if ( $ param1 == 'do_update' ) { $ data [ 'student_id' ] = $ this -> input -> post ( 'student_id' ) ; $ data [ 'title' ] = $ this -> input -> post ( 'title' ) ; $ data [ 'description' ] = $ this -> input -> post ( 'description' ) ; $ data [ 'amount' ] = $ this -> input -> post ( 'amount' ) ; $ data [ 'status' ] = $ this -> input -> post ( 'status' ) ; $ data [ 'creation_timestamp' ] = strtotime ( $ this -> input -> post ( 'date' ) ) ; $ this -> db -> where ( 'invoice_id' , $ param2 ) ; $ this -> db -> update ( 'invoice' , $ data ) ; $ this -> session -> set_flashdata ( 'flash_message' , get_phrase ( 'data_updated' ) ) ; redirect ( base_url ( ) . 'admin/invoice' , 'refresh' ) ; } else if ( $ param1 == 'edit' ) { $ page_data [ 'edit_data' ] = $ this -> db -> get_where ( 'invoice' , array ( 'invoice_id' => $ param2 ) ) -> result_array ( ) ; } if ( $ param1 == 'take_payment' ) { $ data [ 'invoice_id' ] = $ this -> input -> post ( 'invoice_id' ) ; $ data [ 'student_id' ] = $ this -> input -> post ( 'student_id' ) ; $ data [ 'title' ] = $ this -> input -> post ( 'title' ) ; $ data [ 'description' ] = $ this -> input -> post ( 'description' ) ; $ data [ 'payment_type' ] = 'income' ; $ data [ 'method' ] = $ this -> input -> post ( 'method' ) ; $ data [ 'amount' ] = $ this -> input -> post ( 'amount' ) ; $ data [ 'timestamp' ] = strtotime ( $ this -> input -> post ( 'timestamp' ) ) ; $ this -> db -> insert ( 'payment' , $ data ) ; $ data2 [ 'amount_paid' ] = $ this -> input -> post ( 'amount' ) ; $ this -> db -> where ( 'invoice_id' , $ param2 ) ; $ this -> db -> set ( 'amount_paid' , 'amount_paid + ' . $ data2 [ 'amount_paid' ] , FALSE ) ; $ this -> db -> set ( 'due' , 'due - ' . $ data2 [ 'amount_paid' ] , FALSE ) ; $ this -> db -> update ( 'invoice' ) ; $ this -> session -> set_flashdata ( 'flash_message' , get_phrase ( 'payment_successfull' ) ) ; redirect ( base_url ( ) . 'admin/invoice' , 'refresh' ) ; } if ( $ param1 == 'delete' ) { $ this -> db -> where ( 'invoice_id' , $ param2 ) ; $ this -> db -> delete ( 'invoice' ) ; $ this -> session -> set_flashdata ( 'flash_message' , get_phrase ( 'data_deleted' ) ) ; redirect ( base_url ( ) . 'admin/invoice' , 'refresh' ) ; } $ page_data [ 'page_name' ] = 'invoice' ; $ page_data [ 'page_title' ] = get_phrase ( 'manage_invoice/payment' ) ; $ this -> db -> order_by ( 'creation_timestamp' , 'desc' ) ; $ page_data [ 'invoices' ] = $ this -> db -> get ( 'invoice' ) -> result_array ( ) ; $ this -> load -> view ( 'backend/index' , $ page_data ) ; }
MANAGE BILLING / INVOICES WITH STATUS
MANAGE BILLING / INVOICES WITH STATUS