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

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

    public function fetchAttachment($staff_id = null, $mask_id = null)
    {
    	$this->db->select('*');
    	if($staff_id) $this->db->where('user_id',$staff_id);
        if($mask_id) $this->db->where('mask_id',$mask_id);
    	$this->db->where('is_delete',0);
    	$query = $this->db->get('user__professional_academic_attachment');

    	return ($query->num_rows() > 0)?$query->result() : null;
    }

    public function fetchAttachment_edu_in_progress($staff_id = null, $mask_id = null)
    {
        
        $this->db->select('a.*');
        if($staff_id)$this->db->where('user_id',$staff_id);
        if($mask_id)$this->db->where('mask_id',$mask_id);
        $query = $this->db->get('user__pursuing_study_attachment a');

        return ($query->num_rows() > 0)?$query->result() : null;
    }

    public function createAttachment($input)
    {
    	$this->db->insert('user__professional_academic_attachment',$input);
		return $this->db->insert_id();
    }

    public function editAttachment($input, $id = null, $professional_academic_id = null)
    {
        if($professional_academic_id) $this->db->where('professional_academic_id',$professional_academic_id);
        if($id) $this->db->where('id',$id);

        $this->db->update('user__professional_academic_attachment',$input);
    }

    public function createAttachment_edu($input)
    {
        $this->db->insert('user__pursuing_study_attachment',$input);

        return $this->db->insert_id();
    }

    public function editAttachment_edu($input, $id = null, $qualification_id = null)
    {
        if($qualification_id) $this->db->where('academic_qualification_id',$qualification_id);
        if($id) $this->db->where('id',$id);
        $this->db->set($input);
        $this->db->update('user__pursuing_study_attachment');
    }
}
?>