add contraint , that everybody expect admin is limited to 3 days, Add card package
This commit is contained in:
@@ -8,6 +8,7 @@ use yii\data\ActiveDataProvider;
|
||||
use common\models\AccountState;
|
||||
use common\components\RoleDefinition;
|
||||
use common\models\Account;
|
||||
use common\components\Helper;
|
||||
|
||||
/**
|
||||
* AccountStateSearch represents the model behind the search form about `common\models\AccountState`.
|
||||
@@ -65,6 +66,8 @@ class AccountStateSearch extends AccountState
|
||||
if ( RoleDefinition::isReception()){
|
||||
$query->andWhere(['transfer.id_user' => Yii::$app->user->id ]);
|
||||
}
|
||||
|
||||
Helper::restrictIfNotAdminTheStartDate($query, $this->timestampStart,['account_state.created_at'],"date" );
|
||||
}
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
|
||||
30
backend/models/CardInsertForm.php
Normal file
30
backend/models/CardInsertForm.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use common\models\Card;
|
||||
use common\models\Customer;
|
||||
use common\models\Ticket;
|
||||
use common\models\Account;
|
||||
use yii\web\UploadedFile;
|
||||
|
||||
/**
|
||||
* ContactForm is the model behind the contact form.
|
||||
* @property \Yii\web\UploadedFile $file
|
||||
*/
|
||||
class CardInsertForm extends Model{
|
||||
|
||||
public $file;
|
||||
public $message;
|
||||
|
||||
public function rules(){
|
||||
return [
|
||||
[['file'], 'file']
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
32
backend/models/CardPackageImportForm.php
Normal file
32
backend/models/CardPackageImportForm.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use common\models\Card;
|
||||
use common\models\Customer;
|
||||
use common\models\Ticket;
|
||||
use common\models\Account;
|
||||
use yii\web\UploadedFile;
|
||||
|
||||
/**
|
||||
* ContactForm is the model behind the contact form.
|
||||
* @property \Yii\web\UploadedFile $file
|
||||
*/
|
||||
class CardPackageImportForm extends Model{
|
||||
|
||||
public $file;
|
||||
public $failed = 0;
|
||||
public $done = 0;
|
||||
|
||||
public function rules(){
|
||||
return [
|
||||
[['file'], 'file' ],
|
||||
[['file'], 'required' ],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
92
backend/models/CardPackageSearch.php
Normal file
92
backend/models/CardPackageSearch.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\CardPackage;
|
||||
|
||||
/**
|
||||
* CardPackageSearch represents the model behind the search form about `common\models\CardPackage`.
|
||||
*/
|
||||
class CardPackageSearch extends CardPackage
|
||||
|
||||
{
|
||||
|
||||
public static $STATUS_NOT_PRINTED = 10;
|
||||
public static $STATUS_PRINTED = 20;
|
||||
|
||||
public $printStatus;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id_card_package', 'id_user', 'printed','printStatus'], 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = CardPackage::find();
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
'sort' =>[
|
||||
'defaultOrder' => ['created_at' => SORT_DESC]
|
||||
]
|
||||
]);
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
$query->andFilterWhere([
|
||||
'id_card_package' => $this->id_card_package,
|
||||
'id_user' => $this->id_user,
|
||||
]);
|
||||
|
||||
if ( isset($this->printStatus)){
|
||||
switch ($this->printStatus){
|
||||
case self::$STATUS_NOT_PRINTED:
|
||||
$query->andWhere( ['or' ,['card_package.printed' => null], [ "card_package.printed" => 0 ] ]);
|
||||
break;
|
||||
case self::$STATUS_PRINTED:
|
||||
$query->andWhere( [">" ,"card_package.printed" , 0 ]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
public static function getPrintStatuses(){
|
||||
return [
|
||||
self::$STATUS_NOT_PRINTED => "Nincs letöltve",
|
||||
self::$STATUS_PRINTED => "Letöltve",
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -97,6 +97,8 @@ class TransferSearch extends Transfer
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
echo "start date:" .$this->timestampStart;
|
||||
|
||||
$query->andFilterWhere([
|
||||
'transfer.id_account' => $this->id_account,
|
||||
'transfer.type' => $this->type,
|
||||
@@ -111,6 +113,10 @@ class TransferSearch extends Transfer
|
||||
|
||||
$query->andFilterWhere(['or' , $created_condition , $paid_condition]);
|
||||
|
||||
if (!RoleDefinition::isAdmin()){
|
||||
Helper::restrictIfNotAdminTheStartDate($query, $this->timestampStart,['transfer.created_at','transfer.paid_at'],'date');
|
||||
}
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
@@ -127,8 +133,14 @@ class TransferSearch extends Transfer
|
||||
$accountMap = ArrayHelper::map( $accounts ,'id_account','name' );
|
||||
$idUser = $this->id_user;
|
||||
|
||||
/**mk totals need date time format*/
|
||||
$start = $this->timestampStart;
|
||||
if ( isset($start) && !empty($start)){
|
||||
$start .= " 00:00";
|
||||
}
|
||||
|
||||
$this->totals = Transfer::mkTotals($this->timestampStart, $this->timestampEnd, $idUser, $this->types, $this->id_account, $accounts, $accountMap);
|
||||
|
||||
$this->totals = Transfer::mkTotals($start, $this->timestampEnd, $idUser, $this->types, $this->id_account, $accounts, $accountMap);
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user