update autocomplete choose staff

This commit is contained in:
2020-12-21 16:57:30 +07:00
parent 5bb7d519fc
commit df644d539d
9 changed files with 133 additions and 40 deletions

View File

@@ -159,7 +159,7 @@ class ApiController extends Controller {
}
public function actionResetData() {
return file_get_contents("https://bischool.beetai.com/view/image/5f7c1b22dfe5aaf427a6dfa1");
// return file_get_contents("https://bischool.beetai.com/view/image/5f7c1b22dfe5aaf427a6dfa1");
\Yii::$app->db->createCommand()->truncateTable('capture_logs')->execute();
\Yii::$app->db->createCommand()->truncateTable('list_management')->execute();
}

View File

@@ -8,6 +8,7 @@ use app\models\CaptureLogsSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use app\models\ListManagement;
/**
* CaptureLogsController implements the CRUD actions for CaptureLogs model.
@@ -43,17 +44,17 @@ class CaptureLogsController extends Controller {
$dataProvider->query->andWhere(["BETWEEN", "capture_logs.time", $f, $t]);
$dataProvider->query->orderBy(["time" => SORT_DESC]);
$tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
'http' => [
'header' => "Content-Type: application/json",
'method' => "POST"
]
])), true);
$data = json_decode($tempConfig['data'], true);
$last = \app\models\ListManagement::find()->orderBy(['id' => SORT_DESC])->limit(1)->one();
if (!is_object($last))
$last = (object) ['id' => 0];
$idAuto = $data['data']['box_id'] . "_" . ($last->id + 1);
// $tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
// 'http' => [
// 'header' => "Content-Type: application/json",
// 'method' => "POST"
// ]
// ])), true);
// $data = json_decode($tempConfig['data'], true);
// $last = \app\models\ListManagement::find()->orderBy(['id' => SORT_DESC])->limit(1)->one();
// if (!is_object($last))
// $last = (object) ['id' => 0];
// $idAuto = $data['data']['box_id'] . "_" . ($last->id + 1);
return $this->render('index', [
'searchModel' => $searchModel,
@@ -61,7 +62,8 @@ class CaptureLogsController extends Controller {
'statusArray' => CaptureLogs::$statusArray,
'f' => $f,
't' => $t,
'idAuto' => $idAuto
// 'idAuto' => $idAuto,
"staffArray" => ListManagement::staffArray()
]);
}

View File

@@ -50,17 +50,17 @@ class ListManagementController extends Controller {
$dataProvider->query->andWhere(["gender" => $gender]);
$dataProvider->query->orderBy(["time" => SORT_DESC]);
$tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
'http' => [
'header' => "Content-Type: application/json",
'method' => "POST"
]
])), true);
$data = json_decode($tempConfig['data'], true);
$last = \app\models\ListManagement::find()->orderBy(['id' => SORT_DESC])->limit(1)->one();
if (!is_object($last))
$last = (object) ['id' => 0];
$idAuto = $data['data']['box_id'] . "_" . ($last->id + 1);
// $tempConfig = json_decode(file_get_contents("http://localhost:4004/ReadEngineConfig", false, stream_context_create([
// 'http' => [
// 'header' => "Content-Type: application/json",
// 'method' => "POST"
// ]
// ])), true);
// $data = json_decode($tempConfig['data'], true);
// $last = \app\models\ListManagement::find()->orderBy(['id' => SORT_DESC])->limit(1)->one();
// if (!is_object($last))
// $last = (object) ['id' => 0];
// $idAuto = $data['data']['box_id'] . "_" . ($last->id + 1);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
@@ -68,7 +68,8 @@ class ListManagementController extends Controller {
't' => $t,
'typeArray' => ListManagement::$typeArray,
'genderArray' => ListManagement::$genderArray,
'idAuto' => $idAuto
// 'idAuto' => $idAuto,
"staffArray" => ListManagement::staffArray()
]);
}
@@ -382,7 +383,7 @@ class ListManagementController extends Controller {
'type' => "wl",
'name' => $data['name'],
'image' => json_encode($ft),
'gender' => "",
'gender' => "Male",
'birthday' => "",
'telephone' => "",
'address' => $data['department']
@@ -451,4 +452,19 @@ class ListManagementController extends Controller {
}
}
public function actionChooseStaff() {
if (Yii::$app->request->post()) {
$post = Yii::$app->request->post();
$staff = ListManagement::findOne(['code' => $post['code']]);
Yii::$app->response->format = "json";
return [
"name" => $staff->name,
"gender" => $staff->gender,
"birthday" => date("d/m/Y", $staff->birthday),
"telephone" => $staff->telephone,
"department" => $staff->address
];
}
}
}