<?php

class Madrasah extends \Phalcon\Mvc\Model
{

    /**
     *
     * @var integer
     */
    public $id;

    /**
     *
     * @var integer
     */
    public $id_emis;

    /**
     *
     * @var string
     */
    public $statistic_num;

    /**
     *
     * @var string
     */
    public $npsn;

    /**
     *
     * @var string
     */
    public $name;

    /**
     *
     * @var string
     */
    public $status;

    /**
     *
     * @var string
     */
    public $phone;

    /**
     *
     * @var string
     */
    public $accreditation_status;

    /**
     *
     * @var string
     */
    public $category;

    /**
     *
     * @var integer
     */
    public $student_count;

    /**
     *
     * @var integer
     */
    public $jumlah_siswa;

    /**
     *
     * @var integer
     */
    public $rombel_count;

    /**
     *
     * @var integer
     */
    public $jumlah_rombel;

    /**
     *
     * @var integer
     */
    public $personnel_count;

    /**
     *
     * @var integer
     */
    public $waktu_pembelajaran_sesuai_kn;

    /**
     *
     * @var integer
     */
    public $mapel_wajib_sesuai_kn;

    /**
     *
     * @var integer
     */
    public $jumlah_lulusan_terakhir;

    /**
     *
     * @var integer
     */
    public $has_graduate;

    /**
     *
     * @var integer
     */
    public $institution_id;

    /**
     *
     * @var string
     */
    public $address;

    /**
     *
     * @var string
     */
    public $city_id;

    /**
     *
     * @var string
     */
    public $province_id;

    /**
     *
     * @var string
     */
    public $longitude;

    /**
     *
     * @var string
     */
    public $latitude;

    /**
     *
     * @var string
     */
    public $formatted_address;

    /**
     *
     * @var string
     */
    public $sub_district;

    /**
     *
     * @var string
     */
    public $district;

    /**
     *
     * @var string
     */
    public $city;

    /**
     *
     * @var string
     */
    public $province;

    /**
     *
     * @var integer
     */
    public $student_male;

    /**
     *
     * @var integer
     */
    public $student_female;

    /**
     *
     * @var integer
     */
    public $student_normal;

    /**
     *
     * @var integer
     */
    public $student_special_need;

    /**
     *
     * @var integer
     */
    public $student_with_study_group;

    /**
     *
     * @var integer
     */
    public $student_non_study_group;

    /**
     *
     * @var integer
     */
    public $student_stop_learning;

    /**
     *
     * @var integer
     */
    public $student_dropout;

    /**
     *
     * @var integer
     */
    public $student_ipa;

    /**
     *
     * @var integer
     */
    public $student_ips;

    /**
     *
     * @var integer
     */
    public $student_bahasa;

    /**
     *
     * @var integer
     */
    public $student_agama;

    /**
     *
     * @var integer
     */
    public $study_group_num;

    /**
     *
     * @var integer
     */
    public $personnel_teacher;

    /**
     *
     * @var integer
     */
    public $personnel_education_staff;

    /**
     *
     * @var integer
     */
    public $teacher_male;

    /**
     *
     * @var integer
     */
    public $teacher_female;

    /**
     *
     * @var integer
     */
    public $teacher_pns;

    /**
     *
     * @var integer
     */
    public $teacher_non_pns;

    /**
     *
     * @var integer
     */
    public $teacher_permanent;

    /**
     *
     * @var integer
     */
    public $teacher_temporary;

    /**
     *
     * @var integer
     */
    public $teacher_other;

    /**
     *
     * @var integer
     */
    public $education_staff_male;

    /**
     *
     * @var integer
     */
    public $education_staff_female;

    /**
     *
     * @var integer
     */
    public $education_staff_pns;

    /**
     *
     * @var integer
     */
    public $education_staff_non_pns;

    /**
     *
     * @var integer
     */
    public $education_staff_permanent;

    /**
     * @var string
     */
    public $created_at;

    /** @var string */
    public $updated_at;

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        $this->setSchema("jaga");
        $this->setSource("madrasah");
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'madrasah';
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return Madrasah[]|Madrasah|\Phalcon\Mvc\Model\ResultSetInterface
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return Madrasah|\Phalcon\Mvc\Model\ResultInterface
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

    public function isNeedUpdate($maxDaysNeedUpdate = 30) {
        $now = time();
        $updatedAt = strtotime($this->updated_at);
        return ($now - $updatedAt) / (60 * 60 * 24) > $maxDaysNeedUpdate;
    }

}
