<?php
/*
 * Generated by CRUDigniter v3.2
 * www.crudigniter.com
 */

class Historial_pago_model extends CI_Model
{
    function __construct()
    {
        parent::__construct();
    }

    /*
     * Get historial_pago by id
     */
    function get_historial_pago($id)
    {
        return $this->db->get_where('historial_pago',array('id'=>$id))->row_array();
    }

    function get_historial_pago_by_user($persona_id){
      $this->db->select('hp.*, pe.nombres as persona_nombre, pe.apellido_paterno as persona_apepaterno, pe.apellido_materno as persona_apematerno');
      $this->db->from('historial_pago hp, persona pe');
      $this->db->where("hp.persona_id = pe.id AND pe.id = {$persona_id}");
      return $this->db->get()->result_array();
    }


    /*
     * Get all historial_pago
     */
    function get_all_historial_pago()
    {
        $this->db->order_by('id', 'desc');
        return $this->db->get('historial_pago')->result_array();
    }

    /*
     * function to add new historial_pago
     */
    function add_historial_pago($params)
    {
        $this->db->insert('historial_pago',$params);
        return $this->db->insert_id();
    }

    /*
     * function to update historial_pago
     */
    function update_historial_pago($id,$params)
    {
        $this->db->where('id',$id);
        return $this->db->update('historial_pago',$params);
    }

    /*
     * function to delete historial_pago
     */
    function delete_historial_pago($id)
    {
        return $this->db->delete('historial_pago',array('id'=>$id));
    }
}
