update CardRegister full CRUD
This commit is contained in:
@@ -20,6 +20,7 @@ use Yii;
|
||||
* @property string $address
|
||||
* @property int $created_at
|
||||
* @property int $modified_at
|
||||
* @property int $card_register_time
|
||||
*/
|
||||
class Staff extends \yii\db\ActiveRecord {
|
||||
|
||||
@@ -36,7 +37,7 @@ class Staff extends \yii\db\ActiveRecord {
|
||||
public function rules() {
|
||||
return [
|
||||
[['code', 'name', 'gender'], 'required'],
|
||||
[['code', 'card_number', 'department_id', 'birthday', 'date_in', 'created_at', 'modified_at'], 'integer'],
|
||||
[['code', 'card_number', 'department_id', 'birthday', 'date_in', 'created_at', 'modified_at', 'card_register_time'], 'integer'],
|
||||
[['address'], 'string'],
|
||||
[['name', 'email'], 'string', 'max' => 100],
|
||||
[['gender'], 'string', 'max' => 10],
|
||||
@@ -62,6 +63,7 @@ class Staff extends \yii\db\ActiveRecord {
|
||||
'address' => 'Địa chỉ',
|
||||
'created_at' => 'Thời gian tạo',
|
||||
'modified_at' => 'Thời gian sửa',
|
||||
'card_register_time' => 'Ngày đăng ký thẻ'
|
||||
];
|
||||
}
|
||||
|
||||
@@ -80,7 +82,8 @@ class Staff extends \yii\db\ActiveRecord {
|
||||
"date_in" => date_format(date_create_from_format('d/m/Y', $data["DateIn"]), 'U'),
|
||||
"address" => $data["Address"],
|
||||
"created_at" => time(),
|
||||
"modified_at" => time()
|
||||
"modified_at" => time(),
|
||||
"card_register_time" => time()
|
||||
], '');
|
||||
if ($r) {
|
||||
try {
|
||||
@@ -93,7 +96,7 @@ class Staff extends \yii\db\ActiveRecord {
|
||||
}
|
||||
|
||||
public function multiCreate($datas) {
|
||||
$field = ['code', 'name', 'card_number', 'department_id', 'gender', 'birthday', 'email', 'phone', 'date_in', 'address', 'created_at', 'modified_at'];
|
||||
$field = ['code', 'name', 'card_number', 'department_id', 'gender', 'birthday', 'email', 'phone', 'date_in', 'address', 'created_at', 'modified_at', 'card_register_time'];
|
||||
static::getDb()->createCommand()->batchInsert($this->tableName(), $field, $datas)->execute();
|
||||
return;
|
||||
}
|
||||
@@ -108,4 +111,13 @@ class Staff extends \yii\db\ActiveRecord {
|
||||
return ["status" => true, "description" => ""];
|
||||
}
|
||||
|
||||
public static function staffArray() {
|
||||
$lists = self::find()->andWhere(["card_number" => 0])->all();
|
||||
$results = [];
|
||||
foreach ($lists as $key => $value) {
|
||||
$results[$value->id] = $value->code . "-" . $value->name;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user