<?php defined('BASEPATH') or exit('No direct script access allowed');
/**
 * Checkin Model
 *
 * @package Models
 */
class Checkin_model extends EA_Model {
    /**
     * Services_Model constructor.
     */
    public function __construct()
    {
        parent::__construct();
        $this->load->helper('data_validation');
    }

    /**
     * Update checkin record.
     *
     * @param array $checkin Contains the checkin data. The record id needs to be included in the array.
     *
     * @throws Exception If checkin record could not be updated.
     */
    public function update($checkin)
    {
        $this->db->where('checkin_id', $checkin['checkin_id']);
		$checkinId = $checkin['checkin_id'];
		unset($checkin['checkin_id']);
        if ( ! $this->db->update('checkin', $checkin))
        {
            throw new Exception('Could not update checkin record');
        } else {
			return $checkinId;
		}	
		
    }

    /**
     * Get active checkin record.
     *
     */
    public function get_active_checkins()
    {
        $this->db->where('bp_appointment_available', '0');
		$this->db->where('checkin_status', '0');
		$this->db->where('status', '0');
        return $this->db->get('checkin')->result_array();
    }

    /**
     * Get checkin approved status record.
     *
     */
    public function get_checkin_status()
    {
        $this->db->where('bp_appointment_available', '1');
		$this->db->where('checkin_status', '1');
		$this->db->where('status', '0');
        return $this->db->get('checkin')->result_array();
    }

}
