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

class Parents extends MY_BackendController
{

    public function __construct()
    {
        parent::__construct();
        $this->load->model('Parents_model');
    }

    public function index()
    {
        $this->view('backend/parent/index', []);
    }

    public function add()
    {
        $default = ['status' => 1];
      
        $this->view('backend/parent/add', ['status' => $this->Parents_model->status, 'default' => $default]);
    }

    public function insert()
    {
    }

    public function edit()
    {
        $request = $this->input->post();
        $result = $this->Parents_model->one($request['id']);
        $this->view('backend/parent/edit', [
            'parent' => $result,
            'gender' => $this->Parents_model->gender,
            'parent_status' => $this->Parents_model->status,
        ]);
    }

    // Insert / Update
    public function save()
    {
    }

    public function delete()
    {
    }

    public function attach_student($username)
    {
        $parent = $this->Parents_model->getParentFromUsername($username);

        $searchStudent = $this->load->view('backend/parent/partials/search_student', [], true);
        $this->view('backend/parent/attach_student', [
            'parent' => $parent,
            'gender' => $this->Parents_model->gender,
            'search_student' => $searchStudent,
        ]);
        //		$this->Student_model->attachParent($student_no);
    }
}
