| Current Path : /var/www/html/ukas/backend/modules/ppp/models/ |
| Current File : /var/www/html/ukas/backend/modules/ppp/models/Ppp.php |
<?php
namespace backend\modules\ppp\models;
use Yii;
/**
* This is the model class for table "ppp".
*
* @property int $ppp_id
* @property string|null $ppp_type
* @property string|null $ppp_name
* @property string|null $ppp_sector
* @property string|null $ppp_model
* @property string|null $ppp_agency
* @property string|null $ppp_agreement
* @property string|null $ppp_location
* @property string|null $ppp_details
* @property string|null $ppp_img
* @property string|null $ppp_gps
* @property string|null $created_at
* @property int|null $created_by
* @property string|null $updated_at
* @property int|null $updated_by
*/
class Ppp extends \yii\db\ActiveRecord {
/**
* {@inheritdoc}
*/
public static function tableName() {
return 'ppp';
}
/**
* {@inheritdoc}
*/
public function rules() {
return [
[['created_by', 'updated_by', 'created_at', 'updated_at', 'ppp_img', 'ppp_gps_lat', 'ppp_gps_long', 'ppp_details', 'ppp_location',
'ppp_model', 'ppp_agency', 'ppp_gps_list'], 'safe'],
[['ppp_type', 'ppp_name', 'ppp_sector', 'ppp_agreement',], 'required'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels() {
return [
'ppp_id' => 'Ppp ID',
'ppp_type' => 'Type',
'ppp_name' => 'Project Name',
'ppp_sector' => 'Sector',
'ppp_model' => 'Model',
'ppp_agency' => 'Implementing Ministry/Agency',
'ppp_agreement' => 'Agreement Signed',
'ppp_location' => 'Location',
'ppp_details' => 'Project Achievements/Information',
'ppp_img' => 'Image',
'ppp_gps_lat' => 'GPS Latitude',
'ppp_gps_long' => 'GPS Logitude',
'created_at' => 'Created At',
'created_by' => 'Created By',
'updated_at' => 'Updated At',
'updated_by' => 'Updated By',
];
}
public static function getmodeldetails($id) {
$output = '';
$model = Ppp::findOne($id);
if (!empty($model)) {
$arr = json_decode($model->ppp_model);
$arr2 = [];
if (!empty($model->ppp_model)) {
if (!empty($arr) && is_array($arr)) {
foreach ($arr as $code) {
if (!empty($code))
$arr2[] = \backend\modules\refdynawebv2\models\Ref::getDesc('PPP_MODEL', $code);
}
} else
$arr2[] = \backend\modules\refdynawebv2\models\Ref::getDesc('PPP_MODEL', $model->ppp_model);
}
if (!empty($arr2))
$output = implode(', ', $arr2);
else
$output = '-';
}
return $output;
}
public static function getagencydetails($id) {
$output = '';
$model = Ppp::findOne($id);
if (!empty($model)) {
$arr = json_decode($model->ppp_agency);
$arr2 = [];
if (!empty($model->ppp_agency)) {
if (!empty($arr) && is_array($arr)) {
foreach ($arr as $code) {
if (!empty($code))
$arr2[] = \backend\modules\refdynawebv2\models\Ref::getDesc('AGENCY', $code);
}
} else
$arr2[] = \backend\modules\refdynawebv2\models\Ref::getDesc('AGENCY', $model->ppp_agency);
}
if (!empty($arr2))
$output = implode(', ', $arr2);
else
$output = '-';
}
return $output;
}
public static function getgpsdetails($id) {
$output = '';
$model = Ppp::findOne($id);
if (!empty($model)) {
$arr = json_decode($model->ppp_gps_list);
$arr2 = [];
if (!empty($model->ppp_gps_list)) {
if (!empty($arr) && is_array($arr)) {
foreach ($arr as $code) {
if (!empty($code))
$arr2[] = $code;
}
}
}
if (!empty($arr2))
$output = implode('<br>', $arr2);
else
$output = '-';
}
return $output;
}
}