| Current Path : /var/www/html/maiwp.bak/backend/models/ |
| Current File : /var/www/html/maiwp.bak/backend/models/Ref.php |
<?php
namespace backend\models;
use yii\helpers\ArrayHelper;
use Yii;
use backend\models\ReleaseThemes;
/**
* This is the model class for table "life_expectancy".
*
*/
class Ref extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName() {
return 'ref';
}
/**
* @inheritdoc
*/
public function rules()
{
}
public function attributeLabels()
{
}
public static function GetEthnic($Placeholder = true, $Sorting = 'sort')
{
$name_ethnic = Ref::find()->where(['cat' => 'LIFE_EXPECTANCY'])->all();
if($Placeholder)
$arr = [''=>'Please Choose Your Ethnic'];
else
$arr = [];
foreach ($name_ethnic as $Ref) {
$arr[$Ref->descr] = $Ref->descr;
}
return $arr;
}
public static function Directory($Placeholder = true, $Sorting = 'sort')
{
$directory = ReleaseThemes::find()->where(['theme_parent_id' => NULL])->orderBy(['theme_id' => SORT_ASC])->all();
if($Placeholder)
$arr = [''=>'--Sila Pilih--'];
else
$arr = [];
foreach ($directory as $Ref) {
if($Ref->theme_name == "Negeri Dosm")
{
}else{
$arr[$Ref->theme_id] = $Ref->theme_name;
}
}
return $arr;
}
public static function DirectoryState($Placeholder = true, $Sorting = 'sort')
{
$directory1 = ReleaseThemes::find()->where(['theme_parent_id' => 29])->orderBy(['theme_id' => SORT_ASC])->all();
if($Placeholder)
$arr = [''=>'--Sila Pilih--'];
else
$arr = [];
foreach ($directory1 as $Ref) {
$arr[$Ref->theme_id] = $Ref->theme_name;
}
return $arr;
}
public static function getparentid($code, $cat) {
$output = 0;
if (($model = ReleaseThemes::findOne(['theme_parent_id' => $code, 'theme_id' => $cat])) !== null)
$output = $model->theme_id;
return $output;
}
public static function DirectoryStateOne($state,$Placeholder = true, $Sorting = 'sort')
{
$directory1 = ReleaseThemes::find()->where(['theme_parent_id' => $state])->orderBy(['theme_id' => SORT_ASC])->all();
if($Placeholder)
$arr = [''=>'--Sila Pilih--'];
else
$arr = [];
foreach ($directory1 as $Ref) {
$arr[$Ref->theme_id] = $Ref->theme_name;
}
return $arr;
}
public static function DirectoryGrade($Placeholder = true)
{
$sql = 'SELECT * FROM ref WHERE CAT = "GRADE"';
$grade = Yii::$app->db->createCommand($sql)->queryAll();
if($Placeholder)
$arr = [''=>'--Sila Pilih--'];
else
$arr = [];
foreach ($grade as $Ref) {
$arr[$Ref['code']] = $Ref['descr'];
}
return $arr;
}
}