<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Setings extends CI_Controller {
    
    public function __construct() {
        parent::__construct();
         if (! $this->session->userdata ( 'user_logged_in' ) || !company_url($this->session->userdata ('company_slag'))) {
            redirect ( 'login', 'refresh' );
        }
        $this->load->vars ( array (
                'global' => 'Available to all views',
                'header' => 'common/header',
                'left' => 'common/left',
                'footer' => 'common/footer' 
        ) );

        $this->load->model('Setings_model');
    }

    public function index(){
        $data['setings'] = $this->Setings_model->get_setings();
        $this->load->view('setings',$data);
    }

    public function update_setings(){
        $update_data = array(
                'company_name' => $this->input->post('company_name'),
                'company_address' => $this->input->post('company_address'),
                'gst_no' => $this->input->post('gst_no'),
                'bank_account' => $this->input->post('bank_account'),
                'ifsc_code' => $this->input->post('ifsc_code'),
                'tac' => $this->input->post('tac')
            );

        $this->Setings_model->update_setings($update_data);
    }

    public function changepassword(){
        $this->load->view('change_password');
    }

    public function update_password(){
        $update_data = array(
                'login_password' => $this->input->post('newpwd')
            );

        $where_data = array(
                'login_password' => $this->input->post('curpwd')
            );
        $this->Setings_model->update_pswd($update_data,$where_data);
        // echo $this->db->last_query();die();
        echo 1;
    }
}?>