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

class Report_header_model extends CI_Model
{
    public function insert($data)
    {
        $this->db->insert('report_header_master', $data);
        return $this->db->insert_id();
    }

    public function selectall()
    {
        $this->db->select('id, report_header_name, terms_condition, bank_details, signature, status');
        $this->db->where('is_deleted', 0);
        $this->db->order_by('id', 'DESC');
        return $this->db->get('report_header_master')->result();
    }

    public function getbyid($id)
    {
        $this->db->where('id', $id);
        return $this->db->get('report_header_master')->result();
    }

    public function getByName($name)
    {
        $this->db->where('report_header_name', $name);
        $this->db->where('is_deleted', 0);
        $this->db->where('status', 1);
        return $this->db->get('report_header_master')->result();
    }

    public function update($id, $data)
    {
        return $this->db->update('report_header_master', $data, ['id' => $id]);
    }

    public function delete($id)
    {
        $this->db->where('id', $id);
        $this->db->delete('report_header_master');
        return $this->db->affected_rows() > 0;
    }
}
