You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
simple-yewu/common/models/CarT.php

271 lines
7.7 KiB

<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "car_t".
*
* @property integer $id
* @property integer $user_id
* @property integer $car_type_id
* @property integer $car_use_id
* @property string $car_no
* @property string $factory_model
* @property string $car_model
* @property string $register_date
* @property string $insurer1_date
* @property string $insurer2_date
* @property string $id_man
* @property string $id_man_number
* @property string $engine_no
* @property string $car_frame_no
* @property integer $seats
* @property string $car_man
* @property string $car_man_phone
* @property string $remark
* @property integer $location
* @property string $print_date
* @property string $car_man_number
* @property integer $is_track
* @property integer $times
* @property string $old_user
* @property string $company
* @property string $op_user1
* @property string $op_user2
* @property string $from_src
* @property string $created_at
* @property string $updated_at
* @property integer $op1_id
* @property integer $op2_id
*/
class CarT extends \common\models\Base
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'car_t';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id'], 'required'],
[['user_id', 'car_type_id', 'car_use_id','seats','location','op1_id', 'op2_id'], 'integer'],
[['register_date', 'insurer1_date', 'insurer2_date','id_man','id_man_number','print_date','car_man_number', 'created_at', 'updated_at'], 'safe'],
[['car_no', 'factory_model', 'car_model', 'engine_no', 'car_frame_no','id_man_phone'], 'string', 'max' => 50],
[['car_man','car_man_phone','remark','company','op_user1','op_user2','from_src'], 'string', 'max' => 200],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'User ID',
'car_type_id' => 'Car Type ID',
'car_use_id' => 'Car Use ID',
'car_no' => 'Car No',
'factory_model' => 'Factory Model',
'car_model' => 'Car Model',
'register_date' => 'Register Date',
'insurer1_date' => 'Insurer 1 Date',
'insurer2_date' => 'Insurer 2 Date',
'id_man' => 'ID Man',
'id_man_number' => 'ID Number',
'engine_no' => 'Engine No',
'car_frame_no' => 'Car Frame No',
'seats' => 'Seats',
'car_man' => 'Car Man',
'car_man_phone' => 'Phone',
'remark' => 'Remark',
'location' => 'Location',
'print_date' => 'Print Date',
'car_man_number' => 'Car Man Number',
'is_track' => 'Is Track',
'times' => 'Times',
'old_user' => 'Old User',
'company' => 'Company',
'op_user1' => 'Op User1',
'op_user2' => 'Op User2',
'op_user3' => 'Op User3',
'from_src' => 'From Src',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
];
}
public function getLinkmen() {
return $this->hasMany(LinkmanT::className(),['car_id'=>'id']);
}
public function getUser()
{
return $this->hasOne(UserT::className(),['id'=>'user_id']);
}
public function getCarType()
{
return $this->hasOne(CarTypeT::className(),['id'=>'car_type_id']);
}
public function getCarUse()
{
return $this->hasOne(CarUseT::className(),['id'=>'car_use_id']);
}
public function getAppointment()
{
return $this->hasOne(AppointmentT::className(),['car_id'=>'id']);
}
public function getAppointments()
{
return $this->hasMany(AppointmentHistoryT::className(),['car_id'=>'id']);
}
public function getOrders()
{
return $this->hasMany(OrderT::className(),['car_id'=>'id']);
}
public function getLastOpUser1()
{
$count = OrderT::find()->where('car_id='.$this->id)->count();
if($count >1){
$order = OrderT::find()->where('car_id='.$this->id)->orderBy('id ASC')->one();
return $order->user->getShowName();
}
return '';
}
public function getBrand()
{
return $this->hasOne(BrandT::className(),['id'=>'brand_id']);
}
public function getInvalid()
{
return $this->hasOne(InvalidT::className(),['id'=>'invalid_id']);
}
public function getSeries()
{
return $this->hasOne(SeriesT::className(),['id'=>'series_id']);
}
public function getDisplacement()
{
return $this->hasOne(DisplacementT::className(),['id'=>'displacement_id']);
}
public function getLocation()
{
$name = '';
switch($this->location) {
case 1:
$car=CarT::findOne(['id'=>$this->id]);
if($car->qiyong==2){
$name = 'A库(永不启用)';
}else{
$name = 'A库';
}
break;
case 2:
$carb=CarBT::findOne(['id'=>$this->id]);
if($carb->back==1){
$name = 'B库(新保处理无效库)';
}else{
$name = 'B库';
}
break;
case 3:
$name = 'C库';
break;
case 4:
$name = 'D库';
$card=CarDT::findOne(['id'=>$this->id]);
if($card->back==1){
$name = 'D库(续保处理无效库)';
}else{
$name = 'D库';
}
break;
case 5:
$name = '无效库';
break;
case 6:
$name = 'E库';
break;
case 7:
$name = 'F库';
break;
case 8:
$name = 'F1新保四大公司无效库';
break;
case 9:
$name = 'F2新保其他小公司无效库';
break;
case 10:
$name = 'F3新保正常无效库';
break;
case 11:
$name = 'F4续保四大公司无效库';
break;
case 12:
$name = 'F5续保其他小公司无效库';
break;
case 13:
$name = 'F6续保正常无效库';
break;
case 14:
$name = '清洗岗数据库';
break;
case 15:
$name = '数据准确库';
break;
case 16:
$name = '数据不准确库';
break;
default:
$name = '';
}
return $name;
}
public function getLib()
{
if($this->location == 1)
return null;
if($this->location == 2)
return $this->hasOne(CarBT::className(),['id'=>'id']);
if($this->location == 3)
return $this->hasOne(CarCT::className(),['id'=>'id']);
if($this->location == 4)
return $this->hasOne(CarDT::className(),['id'=>'id']);
if($this->location == 5)
return $this->hasOne(CarInvalidT::className(),['id'=>'id']);
if($this->location == 7)
return $this->hasOne(CarFT::className(),['id'=>'id']);
return null;
}
public function getOp1()
{
return $this->hasOne(UserT::className(),['id'=>'op1_id']);
}
public function getOp2()
{
return $this->hasOne(UserT::className(),['id'=>'op2_id']);
}
}