add fingerpint frontend gui
This commit is contained in:
68
frontend/models/FingerprintSearch.php
Normal file
68
frontend/models/FingerprintSearch.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace frontend\models;
|
||||
|
||||
|
||||
use common\models\Card;
|
||||
use common\models\Customer;
|
||||
use common\models\Fingerprint;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\web\NotFoundHttpException;
|
||||
|
||||
class FingerprintSearch extends Fingerprint
|
||||
{
|
||||
|
||||
public $id_card;
|
||||
|
||||
public $customer;
|
||||
public $card;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[[ 'id_card'], 'integer'],
|
||||
[[ 'id_card'], 'required']
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $params
|
||||
* @return ActiveDataProvider
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public function search($params){
|
||||
|
||||
$this->load($params);
|
||||
$this->validate();
|
||||
|
||||
|
||||
$query = Fingerprint::find();
|
||||
|
||||
/** @var Card $card */
|
||||
$card = Card::findOne($this->id_card);
|
||||
|
||||
if ( !isset($card)){
|
||||
throw new NotFoundHttpException('Card not found:' . $this->id_card);
|
||||
}
|
||||
$this->card = $card;
|
||||
|
||||
$customer = Customer::findOne($card->customer);
|
||||
|
||||
if ( !isset($customer)){
|
||||
throw new NotFoundHttpException('Customer not found');
|
||||
}
|
||||
|
||||
|
||||
$this->customer = $customer;
|
||||
|
||||
$query->andWhere(['id_customer' => $customer->id_customer]);
|
||||
return new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user