Finish version/v.0.0.92
This commit is contained in:
commit
3748a2edd3
@ -48,7 +48,7 @@ class TransferSearch extends Transfer
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[['id_account', 'id_user', 'type', 'status', 'payment_method'], 'integer'],
|
[['id_account', 'id_user', 'type', 'status', 'payment_method','paid_by'], 'integer'],
|
||||||
[['customer_name','output','transfer_name', 'card_number' ], 'safe'],
|
[['customer_name','output','transfer_name', 'card_number' ], 'safe'],
|
||||||
// [[ 'searchObjectName' ], 'string'],
|
// [[ 'searchObjectName' ], 'string'],
|
||||||
// [[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
// [[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||||
@ -189,7 +189,12 @@ class TransferSearch extends Transfer
|
|||||||
$query->andFilterWhere([
|
$query->andFilterWhere([
|
||||||
'or',
|
'or',
|
||||||
['transfer.id_user' => $this->id_user],
|
['transfer.id_user' => $this->id_user],
|
||||||
['transfer.paid_by' => $this->id_user],
|
]);
|
||||||
|
}
|
||||||
|
if (isset($this->paid_by)) {
|
||||||
|
$query->andFilterWhere([
|
||||||
|
'or',
|
||||||
|
['transfer.paid_by' => $this->paid_by],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -69,6 +69,8 @@ use kartik\widgets\DateTimePicker;
|
|||||||
<?= $form->field($model, 'card_number')->label("Kártya szám") ?>
|
<?= $form->field($model, 'card_number')->label("Kártya szám") ?>
|
||||||
</div>
|
</div>
|
||||||
<div class='col-md-3'>
|
<div class='col-md-3'>
|
||||||
|
<?= $form->field($model, 'paid_by')->dropDownList( ['' => Yii::t('common/transfer', 'All')] +ArrayHelper::map($users,'id' , 'username') )
|
||||||
|
->label("Fizette")?>
|
||||||
</div>
|
</div>
|
||||||
<div class='col-md-3'>
|
<div class='col-md-3'>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
-0.0.92
|
||||||
|
- account state -> display non casch money
|
||||||
|
- add towel , search by towel in reception cutomer list
|
||||||
|
- add change transfer account
|
||||||
-0.0.91
|
-0.0.91
|
||||||
- invalidate door log changes
|
- invalidate door log changes
|
||||||
-0.0.90
|
-0.0.90
|
||||||
|
|||||||
@ -31,8 +31,9 @@ class TransferPayout extends \yii\base\Object{
|
|||||||
/**Ha a fizetési módot meg szeretnél változtatni*/
|
/**Ha a fizetési módot meg szeretnél változtatni*/
|
||||||
public $overridePaymentMethod = null;
|
public $overridePaymentMethod = null;
|
||||||
|
|
||||||
|
/**Ha a fizetési Kasszát meg szeretné változtatni.
|
||||||
|
* Fizetési kasszát csak bankártyásra lehet változtatni*/
|
||||||
|
public $overrideIdAccount = null;
|
||||||
|
|
||||||
|
|
||||||
public function payout(){
|
public function payout(){
|
||||||
@ -86,14 +87,20 @@ class TransferPayout extends \yii\base\Object{
|
|||||||
$transfer->status = Transfer::STATUS_PAID;
|
$transfer->status = Transfer::STATUS_PAID;
|
||||||
$transfer->paid_at = date('Y-m-d H:i:s' );
|
$transfer->paid_at = date('Y-m-d H:i:s' );
|
||||||
|
|
||||||
|
if ( isset($this->overrideIdAccount) && !empty($this->overrideIdAccount)){
|
||||||
|
$transfer->id_account = $this->overrideIdAccount;
|
||||||
|
}else{
|
||||||
$account = $transfer->account;
|
$account = $transfer->account;
|
||||||
|
|
||||||
if ( isset($account )){
|
if ( isset($account )){
|
||||||
/**Ha a tranzakció eredet kasszája látható típusu, akkor változtathatjuk az atuális kasszára. Különben nem*/
|
/**Ha a tranzakció eredeti kasszája látható típusú, akkor változtathatjuk az atuális kasszára. Különben nem*/
|
||||||
if ($account->type == Account::TYPE_ALL){
|
if ($account->type == Account::TYPE_ALL){
|
||||||
$transfer->id_account = Account::readDefault();
|
$transfer->id_account = Account::readDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\Yii::info("fizetési mód: " . $this->overridePaymentMethod);
|
\Yii::info("fizetési mód: " . $this->overridePaymentMethod);
|
||||||
|
|
||||||
|
|||||||
@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace common\components\accountstate;
|
namespace common\components\accountstate;
|
||||||
use yii\base\Widget;
|
use yii\base\Widget;
|
||||||
use common\models\AccountState;
|
|
||||||
use yii\data\ArrayDataProvider;
|
|
||||||
use yii\grid\GridView;
|
|
||||||
use yii\helpers\Html;
|
|
||||||
use yii\widgets\DetailView;
|
use yii\widgets\DetailView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the model class for widget display bank notes.
|
* This is the model class for widget display bank notes.
|
||||||
*
|
*
|
||||||
* @property common\models\AccountState $model
|
* @property \common\models\AccountState $model
|
||||||
* */
|
* */
|
||||||
class AccountStateWidget extends Widget{
|
class AccountStateWidget extends Widget{
|
||||||
|
|
||||||
@ -59,6 +55,16 @@ class AccountStateWidget extends Widget{
|
|||||||
'attribute' =>'money',
|
'attribute' =>'money',
|
||||||
'value' => \Yii::$app->formatter->asInteger($this->model->money) ." Ft",
|
'value' => \Yii::$app->formatter->asInteger($this->model->money) ." Ft",
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'non_cash_money',
|
||||||
|
'label' => 'Készpénz alapú forgalom',
|
||||||
|
'value' => \Yii::$app->formatter->asInteger($this->model->collection_money) ." Ft",
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'non_cash_money',
|
||||||
|
'label' => 'Nem készpénz alapú forgalom',
|
||||||
|
'value' => \Yii::$app->formatter->asInteger($this->model->non_cash_money) ." Ft",
|
||||||
|
],
|
||||||
'user.username',
|
'user.username',
|
||||||
[
|
[
|
||||||
'attribute' => 'start_date',
|
'attribute' => 'start_date',
|
||||||
|
|||||||
@ -5,7 +5,7 @@ return [
|
|||||||
'supportEmail' => 'rocho02@gmail.com',
|
'supportEmail' => 'rocho02@gmail.com',
|
||||||
'infoEmail' => 'info@rocho-net.hu',
|
'infoEmail' => 'info@rocho-net.hu',
|
||||||
'user.passwordResetTokenExpire' => 3600,
|
'user.passwordResetTokenExpire' => 3600,
|
||||||
'version' => 'v0.0.91',
|
'version' => 'v0.0.92',
|
||||||
'company' => 'movar',//gyor
|
'company' => 'movar',//gyor
|
||||||
'company_name' => "Freimann Kft.",
|
'company_name' => "Freimann Kft.",
|
||||||
'product_visiblity' => 'account',// on reception which products to display. account or global
|
'product_visiblity' => 'account',// on reception which products to display. account or global
|
||||||
|
|||||||
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace common\models;
|
namespace common\models;
|
||||||
|
|
||||||
use Yii;
|
use /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
|
||||||
|
Yii;
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
use yii\behaviors\TimestampBehavior;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the model class for table "account_state".
|
* This is the model class for table "account_state".
|
||||||
@ -29,8 +29,9 @@ use yii\behaviors\TimestampBehavior;
|
|||||||
* @property integer $collection_money
|
* @property integer $collection_money
|
||||||
* @property string $created_at
|
* @property string $created_at
|
||||||
* @property string $updated_at
|
* @property string $updated_at
|
||||||
|
* @property int non_cash_money
|
||||||
*/
|
*/
|
||||||
class AccountState extends \common\models\BaseFitnessActiveRecord
|
class AccountState extends BaseFitnessActiveRecord
|
||||||
{
|
{
|
||||||
|
|
||||||
const TYPE_OPEN = 10;
|
const TYPE_OPEN = 10;
|
||||||
@ -38,16 +39,6 @@ class AccountState extends \common\models\BaseFitnessActiveRecord
|
|||||||
|
|
||||||
public $start_date;
|
public $start_date;
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritdoc
|
|
||||||
*/
|
|
||||||
// public function behaviors()
|
|
||||||
// {
|
|
||||||
// return [[
|
|
||||||
// 'class' => TimestampBehavior::className(),
|
|
||||||
// 'value' => function(){ return date('Y-m-d H:i' ); }
|
|
||||||
// ] ];
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
@ -138,6 +129,8 @@ class AccountState extends \common\models\BaseFitnessActiveRecord
|
|||||||
|
|
||||||
public function getAccountName(){
|
public function getAccountName(){
|
||||||
$result = "";
|
$result = "";
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
|
/** @var \common\models\Account $account */
|
||||||
$account = $this->account;
|
$account = $this->account;
|
||||||
if (isset($account)){
|
if (isset($account)){
|
||||||
$result = $account->name;
|
$result = $account->name;
|
||||||
@ -156,6 +149,7 @@ class AccountState extends \common\models\BaseFitnessActiveRecord
|
|||||||
|
|
||||||
public function getUserName(){
|
public function getUserName(){
|
||||||
$result = "";
|
$result = "";
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$user = $this->user;
|
$user = $this->user;
|
||||||
if (isset($this->user)){
|
if (isset($this->user)){
|
||||||
$result = $user->username;
|
$result = $user->username;
|
||||||
@ -193,9 +187,9 @@ class AccountState extends \common\models\BaseFitnessActiveRecord
|
|||||||
* Read last accountstates
|
* Read last accountstates
|
||||||
* @param $type int the type of accountstate to load
|
* @param $type int the type of accountstate to load
|
||||||
* @param $user $id of user to load the account
|
* @param $user $id of user to load the account
|
||||||
* @return common\models\AccountState
|
* @param \common\models\Account|null $account
|
||||||
*
|
* @return AccountState
|
||||||
* */
|
*/
|
||||||
public static function readLast($type, $user = null,$account = null){
|
public static function readLast($type, $user = null,$account = null){
|
||||||
$result = null;
|
$result = null;
|
||||||
$query = AccountState::find();
|
$query = AccountState::find();
|
||||||
@ -224,20 +218,23 @@ class AccountState extends \common\models\BaseFitnessActiveRecord
|
|||||||
$start = null;
|
$start = null;
|
||||||
$end = null;
|
$end = null;
|
||||||
$prev = null;
|
$prev = null;
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$this->prev_money = 0;
|
$this->prev_money = 0;
|
||||||
|
|
||||||
if ( $this->type == AccountState::TYPE_CLOSE){
|
if ( $this->type == AccountState::TYPE_CLOSE){
|
||||||
$lastOpen = AccountState::readLast(AccountState::TYPE_OPEN,\Yii::$app->user->id, $this->id_account);
|
$lastOpen = AccountState::readLast(AccountState::TYPE_OPEN,\Yii::$app->user->id, $this->id_account);
|
||||||
if ( $lastOpen != null ){
|
if ( $lastOpen != null ){
|
||||||
$start = $lastOpen->created_at;
|
$start = $lastOpen->created_at;
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$this->prev_state = $lastOpen->id_account_state;
|
$this->prev_state = $lastOpen->id_account_state;
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$this->prev_money = $lastOpen->money;
|
$this->prev_money = $lastOpen->money;
|
||||||
}
|
}
|
||||||
$end = date('Y-m-d H:i:s' );
|
$end = date('Y-m-d H:i:s' );
|
||||||
// $end = Yii::$app->formatter->asDatetime(strtotime("now"), "php:Y-m-d H:i:s");
|
// $end = Yii::$app->formatter->asDatetime(strtotime("now"), "php:Y-m-d H:i:s");
|
||||||
$this->collection_money = Transfer::readPaid($start, $end, Yii::$app->user->id);
|
$this->collection_money = Transfer::readPaidCash($start, $end, Yii::$app->user->id);
|
||||||
|
|
||||||
|
|
||||||
|
$this->non_cash_money = Transfer::readPaidNonCash($start, $end, Yii::$app->user->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -248,6 +245,7 @@ class AccountState extends \common\models\BaseFitnessActiveRecord
|
|||||||
public function hasDifferenceToPrevState(){
|
public function hasDifferenceToPrevState(){
|
||||||
$result = false;
|
$result = false;
|
||||||
if ( $this->type == self::TYPE_CLOSE){
|
if ( $this->type == self::TYPE_CLOSE){
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$result = ( $this->prev_money + $this->collection_money) != $this->money;
|
$result = ( $this->prev_money + $this->collection_money) != $this->money;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
@ -256,6 +254,7 @@ class AccountState extends \common\models\BaseFitnessActiveRecord
|
|||||||
public function hasPlus(){
|
public function hasPlus(){
|
||||||
$result = false;
|
$result = false;
|
||||||
if ( $this->type == self::TYPE_CLOSE){
|
if ( $this->type == self::TYPE_CLOSE){
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$result = ( $this->prev_money + $this->collection_money) < $this->money;
|
$result = ( $this->prev_money + $this->collection_money) < $this->money;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
@ -264,17 +263,20 @@ class AccountState extends \common\models\BaseFitnessActiveRecord
|
|||||||
public function hasMinus(){
|
public function hasMinus(){
|
||||||
$result = false;
|
$result = false;
|
||||||
if ( $this->type == self::TYPE_CLOSE){
|
if ( $this->type == self::TYPE_CLOSE){
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$result =( $this->prev_money + $this->collection_money) > $this->money;
|
$result =( $this->prev_money + $this->collection_money) > $this->money;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSignedDiff(){
|
public function getSignedDiff(){
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$result = $this->money - ( $this->prev_money + $this->collection_money);
|
$result = $this->money - ( $this->prev_money + $this->collection_money);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getExpected(){
|
public function getExpected(){
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$result = $this->prev_money + $this->collection_money ;
|
$result = $this->prev_money + $this->collection_money ;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@ use common\components\Helper;
|
|||||||
* @property string $created_at
|
* @property string $created_at
|
||||||
* @property string $updated_at
|
* @property string $updated_at
|
||||||
* @property int flag_out
|
* @property int flag_out
|
||||||
|
* @property \common\models\Customer $customer relation
|
||||||
*/
|
*/
|
||||||
class Card extends \common\models\BaseFitnessActiveRecord
|
class Card extends \common\models\BaseFitnessActiveRecord
|
||||||
{
|
{
|
||||||
|
|||||||
@ -16,6 +16,7 @@ class CardSearch extends Card
|
|||||||
{
|
{
|
||||||
|
|
||||||
public $customerName;
|
public $customerName;
|
||||||
|
public $towel;
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
@ -23,7 +24,8 @@ class CardSearch extends Card
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['customerName','string','max' =>200],
|
['customerName','string','max' =>200],
|
||||||
['number','string','max' =>200]
|
['number','string','max' =>200],
|
||||||
|
['towel','integer']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +42,8 @@ class CardSearch extends Card
|
|||||||
return ArrayHelper::merge(parent::attributeLabels(),
|
return ArrayHelper::merge(parent::attributeLabels(),
|
||||||
[
|
[
|
||||||
'card_number' => 'Kártya szám',
|
'card_number' => 'Kártya szám',
|
||||||
'customerName' => 'Vendég'
|
'customerName' => 'Vendég',
|
||||||
|
'towel' => 'Törölköző'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -57,7 +60,7 @@ class CardSearch extends Card
|
|||||||
{
|
{
|
||||||
|
|
||||||
$query = new Query();
|
$query = new Query();
|
||||||
$query->select(['card.id_card as card_id_card', 'card.number as card_number' , 'customer.name as customer_name', 'customer.email as customer_email','customer.phone as customer_phone']);
|
$query->select(['card.id_card as card_id_card', 'card.number as card_number' , 'customer.name as customer_name', 'customer.email as customer_email','customer.phone as customer_phone','customer.towel_count as towel_count']);
|
||||||
$query->from('card');
|
$query->from('card');
|
||||||
$query->innerJoin('customer','card.id_card = customer.id_customer_card');
|
$query->innerJoin('customer','card.id_card = customer.id_customer_card');
|
||||||
$query->leftJoin("card_key_assignment", 'card.id_card = card_key_assignment.id_card');
|
$query->leftJoin("card_key_assignment", 'card.id_card = card_key_assignment.id_card');
|
||||||
@ -85,6 +88,10 @@ class CardSearch extends Card
|
|||||||
'asc' => ['customer.email' => SORT_ASC ],
|
'asc' => ['customer.email' => SORT_ASC ],
|
||||||
'desc' => ['customer.email' => SORT_DESC],
|
'desc' => ['customer.email' => SORT_DESC],
|
||||||
],
|
],
|
||||||
|
'towel_count' => [
|
||||||
|
'asc' => ['customer.towel_count' => SORT_ASC ],
|
||||||
|
'desc' => ['customer.towel_count' => SORT_DESC],
|
||||||
|
],
|
||||||
],
|
],
|
||||||
'defaultOrder' =>[
|
'defaultOrder' =>[
|
||||||
'customer_name' => SORT_ASC,
|
'customer_name' => SORT_ASC,
|
||||||
@ -115,6 +122,10 @@ class CardSearch extends Card
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( isset($this->towel) && !empty($this->towel)){
|
||||||
|
$query->andWhere(['>','customer.towel_count',0]);
|
||||||
|
}
|
||||||
|
|
||||||
$query->andFilterWhere(['like', 'customer.name', $this->customerName]);
|
$query->andFilterWhere(['like', 'customer.name', $this->customerName]);
|
||||||
|
|
||||||
return $dataProvider;
|
return $dataProvider;
|
||||||
|
|||||||
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
namespace common\models;
|
namespace common\models;
|
||||||
|
|
||||||
use Yii;
|
use /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
|
||||||
|
Yii;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the model class for table "currency".
|
* This is the model class for table "currency".
|
||||||
@ -14,7 +15,7 @@ use Yii;
|
|||||||
* @property string $created_at
|
* @property string $created_at
|
||||||
* @property string $updated_at
|
* @property string $updated_at
|
||||||
*/
|
*/
|
||||||
class Currency extends \common\models\BaseFitnessActiveRecord
|
class Currency extends BaseFitnessActiveRecord
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
@ -54,8 +55,10 @@ class Currency extends \common\models\BaseFitnessActiveRecord
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer $money
|
* @param integer $money
|
||||||
* @param common\models\Currency $currency
|
* @param \common\models\Currency $currency
|
||||||
* */
|
*
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
public static function applyCurrency( $money,$currency ) {
|
public static function applyCurrency( $money,$currency ) {
|
||||||
$result = $money / $currency;
|
$result = $money / $currency;
|
||||||
return $result;
|
return $result;
|
||||||
|
|||||||
@ -29,6 +29,7 @@ use Yii;
|
|||||||
* @property string $updated_at
|
* @property string $updated_at
|
||||||
* @property \common\models\Card card
|
* @property \common\models\Card card
|
||||||
* @property integer status
|
* @property integer status
|
||||||
|
* @property integer towel_count
|
||||||
* @property \common\models\User user
|
* @property \common\models\User user
|
||||||
* @property mixed bank_account
|
* @property mixed bank_account
|
||||||
*/
|
*/
|
||||||
@ -47,6 +48,7 @@ class Customer extends BaseFitnessActiveRecord
|
|||||||
|
|
||||||
public $photo_data;
|
public $photo_data;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
namespace common\models;
|
namespace common\models;
|
||||||
|
|
||||||
use Yii;
|
use /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
|
||||||
|
Yii;
|
||||||
use yii\behaviors\TimestampBehavior;
|
use yii\behaviors\TimestampBehavior;
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
|
|
||||||
@ -18,6 +19,7 @@ use yii\helpers\ArrayHelper;
|
|||||||
* @property integer $ticket_enabled
|
* @property integer $ticket_enabled
|
||||||
* @property string $created_at
|
* @property string $created_at
|
||||||
* @property string $updated_at
|
* @property string $updated_at
|
||||||
|
* @property mixed id_discount
|
||||||
*/
|
*/
|
||||||
class Discount extends \yii\db\ActiveRecord
|
class Discount extends \yii\db\ActiveRecord
|
||||||
{
|
{
|
||||||
@ -86,7 +88,7 @@ class Discount extends \yii\db\ActiveRecord
|
|||||||
|
|
||||||
public function getStatusHuman(){
|
public function getStatusHuman(){
|
||||||
$result = null;
|
$result = null;
|
||||||
$s = self::statuses($this->status);
|
$s = self::statuses();
|
||||||
if ( array_key_exists($this->status, $s)){
|
if ( array_key_exists($this->status, $s)){
|
||||||
$result = $s[$this->status];
|
$result = $s[$this->status];
|
||||||
}
|
}
|
||||||
@ -101,40 +103,58 @@ class Discount extends \yii\db\ActiveRecord
|
|||||||
|
|
||||||
public function getTypeHuman(){
|
public function getTypeHuman(){
|
||||||
$result = null;
|
$result = null;
|
||||||
$s = self::types($this->type);
|
$s = self::types();
|
||||||
if ( array_key_exists($this->type, $s)){
|
if ( array_key_exists($this->type, $s)){
|
||||||
$result = $s[$this->type];
|
$result = $s[$this->type];
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getProcutEnabledHuman(){
|
public function getProcutEnabledHuman(){
|
||||||
return $this->product_enabled == 1 ? 'Igen' : 'Nem';
|
return $this->product_enabled == 1 ? 'Igen' : 'Nem';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getTicketEnabledHuman(){
|
public function getTicketEnabledHuman(){
|
||||||
return $this->ticket_enabled == 1 ? 'Igen' : 'Nem';
|
return $this->ticket_enabled == 1 ? 'Igen' : 'Nem';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array|\yii\db\ActiveRecord[]
|
||||||
|
*/
|
||||||
public static function read(){
|
public static function read(){
|
||||||
return Discount::find()->andWhere([ 'status' => self::STATUS_ACTIVE ])->all();
|
return Discount::find()->andWhere([ 'status' => self::STATUS_ACTIVE ])->all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array|\yii\db\ActiveRecord[]
|
||||||
|
*/
|
||||||
public static function readProductDiscounts(){
|
public static function readProductDiscounts(){
|
||||||
return Discount::find()->andWhere([ 'status' => self::STATUS_ACTIVE , 'product_enabled' => 1 ])->all();
|
return Discount::find()->andWhere([ 'status' => self::STATUS_ACTIVE , 'product_enabled' => 1 ])->all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array|\yii\db\ActiveRecord[]
|
||||||
|
*/
|
||||||
public static function readTicketDiscounts(){
|
public static function readTicketDiscounts(){
|
||||||
return Discount::find()->andWhere([ 'status' => self::STATUS_ACTIVE , 'ticket_enabled' => 1 ])->all();
|
return Discount::find()->andWhere([ 'status' => self::STATUS_ACTIVE , 'ticket_enabled' => 1 ])->all();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer $money
|
* @param integer $money
|
||||||
* @param common\models\Discount $discount
|
* @param \common\models\Discount $discount
|
||||||
* */
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public static function applyDiscount($money,$discount){
|
public static function applyDiscount($money,$discount){
|
||||||
|
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||||
$result = $money;
|
$result = $money;
|
||||||
$valueOfDiscount = floor( $money * $discount->value / 100 );
|
$valueOfDiscount = floor( $money * $discount->value / 100 );
|
||||||
$result = $money - $valueOfDiscount;
|
$result = $money - $valueOfDiscount;
|
||||||
|
|||||||
@ -51,6 +51,8 @@ class Log extends BaseFitnessActiveRecord
|
|||||||
public static $TYPE_NEWSLETTER_SEND_END = 160;
|
public static $TYPE_NEWSLETTER_SEND_END = 160;
|
||||||
public static $TYPE_KEY_ASSIGN = 170;
|
public static $TYPE_KEY_ASSIGN = 170;
|
||||||
public static $TYPE_KEY_UNASSIGN = 180;
|
public static $TYPE_KEY_UNASSIGN = 180;
|
||||||
|
public static $TYPE_TOWEL_IN = 190;
|
||||||
|
public static $TYPE_TOWEL_OUT = 200;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
|
|||||||
@ -29,6 +29,7 @@ use common\components\Helper;
|
|||||||
* @property string $comment
|
* @property string $comment
|
||||||
* @property string $created_at
|
* @property string $created_at
|
||||||
* @property string $updated_at
|
* @property string $updated_at
|
||||||
|
* @property int id_contract
|
||||||
*/
|
*/
|
||||||
class Ticket extends \common\models\BaseFitnessActiveRecord
|
class Ticket extends \common\models\BaseFitnessActiveRecord
|
||||||
{
|
{
|
||||||
@ -133,6 +134,7 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
|||||||
|
|
||||||
public function getCardNumber(){
|
public function getCardNumber(){
|
||||||
$result = "";
|
$result = "";
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$card = $this->card;
|
$card = $this->card;
|
||||||
if ( isset($card)){
|
if ( isset($card)){
|
||||||
$result = $card->number;
|
$result = $card->number;
|
||||||
@ -146,6 +148,7 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
|||||||
|
|
||||||
public function getCustomerName(){
|
public function getCustomerName(){
|
||||||
$result = "";
|
$result = "";
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$customer = $this->customer;
|
$customer = $this->customer;
|
||||||
if ( isset($customer)){
|
if ( isset($customer)){
|
||||||
$result = $customer->name;
|
$result = $customer->name;
|
||||||
@ -171,22 +174,27 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
|||||||
}
|
}
|
||||||
public function getAccountName() {
|
public function getAccountName() {
|
||||||
$result = "";
|
$result = "";
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
|
/** @var \common\models\Account $account */
|
||||||
$account = $this->account;
|
$account = $this->account;
|
||||||
if ( isset($account) ){
|
if ( isset($account) ){
|
||||||
$result = $this->account->name;
|
$result = $account->name;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
public function getDiscountName() {
|
public function getDiscountName() {
|
||||||
$result = "";
|
$result = "";
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
|
/** @var \common\models\Discount $discount */
|
||||||
$discount = $this->discount;
|
$discount = $this->discount;
|
||||||
if ( isset($discount) ){
|
if ( isset($discount) ){
|
||||||
$result = $this->discount->name;
|
$result = $discount->name;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
public function getTicketTypeName() {
|
public function getTicketTypeName() {
|
||||||
$result = "";
|
$result = "";
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$ticketType = $this->ticketType;
|
$ticketType = $this->ticketType;
|
||||||
if ( isset($ticketType) ){
|
if ( isset($ticketType) ){
|
||||||
$result = $ticketType->name;
|
$result = $ticketType->name;
|
||||||
@ -195,6 +203,7 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
|||||||
}
|
}
|
||||||
public function getUserName() {
|
public function getUserName() {
|
||||||
$result = "";
|
$result = "";
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$user = $this->user;
|
$user = $this->user;
|
||||||
if ( isset($user) ){
|
if ( isset($user) ){
|
||||||
$result = $user->username;
|
$result = $user->username;
|
||||||
@ -204,8 +213,10 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param common\models\Card $card the card to which we are looking for
|
* @param \common\models\Card $card the card to which we are looking for
|
||||||
* */
|
*
|
||||||
|
* @return array|\yii\db\ActiveRecord[]
|
||||||
|
*/
|
||||||
public static function readActive($card){
|
public static function readActive($card){
|
||||||
|
|
||||||
if ( $card == null )
|
if ( $card == null )
|
||||||
@ -224,9 +235,12 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
|||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param common\models\Card $card the card to which we are looking for
|
* @param \common\models\Card $card the card to which we are looking for
|
||||||
* */
|
*
|
||||||
|
* @return array|\yii\db\ActiveRecord[]
|
||||||
|
*/
|
||||||
public static function readUnpaid($card){
|
public static function readUnpaid($card){
|
||||||
|
|
||||||
if ( $card == null )
|
if ( $card == null )
|
||||||
@ -326,7 +340,7 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
|||||||
/**
|
/**
|
||||||
* Apply request
|
* Apply request
|
||||||
*
|
*
|
||||||
* @var common\models\TicketInstallmentRequest $request megbízás
|
* @var \common\models\TicketInstallmentRequest $request megbízás
|
||||||
* */
|
* */
|
||||||
public function applyTicketInstallmentRequest( $request ) {
|
public function applyTicketInstallmentRequest( $request ) {
|
||||||
//ha csoportos beszedéses
|
//ha csoportos beszedéses
|
||||||
|
|||||||
@ -14,6 +14,7 @@ use yii\db\Query;
|
|||||||
use yii\db\Expression;
|
use yii\db\Expression;
|
||||||
use common\components\RoleDefinition;
|
use common\components\RoleDefinition;
|
||||||
use common\components\Helper;
|
use common\components\Helper;
|
||||||
|
use yii\web\NotAcceptableHttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the model class for table "transfer".
|
* This is the model class for table "transfer".
|
||||||
@ -37,6 +38,8 @@ use common\components\Helper;
|
|||||||
* @property integer $direction
|
* @property integer $direction
|
||||||
* @property string $paid_at
|
* @property string $paid_at
|
||||||
* @property integer $id_customer
|
* @property integer $id_customer
|
||||||
|
* @property int|string paid_by
|
||||||
|
* @property int payment_method
|
||||||
*/
|
*/
|
||||||
class Transfer extends \common\models\BaseFitnessActiveRecord {
|
class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||||
const TYPE_PRODUCT = 10;
|
const TYPE_PRODUCT = 10;
|
||||||
@ -205,6 +208,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
}
|
}
|
||||||
public function getPaidByName() {
|
public function getPaidByName() {
|
||||||
$result = "";
|
$result = "";
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$user = $this->paidByUser;
|
$user = $this->paidByUser;
|
||||||
if (isset ( $this->paidByUser )) {
|
if (isset ( $this->paidByUser )) {
|
||||||
$result = $user->username;
|
$result = $user->username;
|
||||||
@ -215,16 +219,20 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
public function getObjectName() {
|
public function getObjectName() {
|
||||||
$result = "";
|
$result = "";
|
||||||
if ($this->type == Transfer::TYPE_TICKET) {
|
if ($this->type == Transfer::TYPE_TICKET) {
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$result = $this->ticketName;
|
$result = $this->ticketName;
|
||||||
} else if ($this->type == Transfer::TYPE_PRODUCT) {
|
} else if ($this->type == Transfer::TYPE_PRODUCT) {
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$result = $this->productName;
|
$result = $this->productName;
|
||||||
} else if ($this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) {
|
} else if ($this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) {
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$result = $this->moneyMovement->humanType;
|
$result = $this->moneyMovement->humanType;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
public function getUserName() {
|
public function getUserName() {
|
||||||
$result = "";
|
$result = "";
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$user = $this->user;
|
$user = $this->user;
|
||||||
if (isset ( $this->user )) {
|
if (isset ( $this->user )) {
|
||||||
$result = $user->username;
|
$result = $user->username;
|
||||||
@ -234,6 +242,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
}
|
}
|
||||||
public function getProductName() {
|
public function getProductName() {
|
||||||
$result = "";
|
$result = "";
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$product = $this->product;
|
$product = $this->product;
|
||||||
if (isset ( $product )) {
|
if (isset ( $product )) {
|
||||||
$result = $product->name;
|
$result = $product->name;
|
||||||
@ -243,8 +252,11 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
}
|
}
|
||||||
public function getTicketName() {
|
public function getTicketName() {
|
||||||
$result = "";
|
$result = "";
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
|
/** @var \common\models\Ticket $ticket */
|
||||||
$ticket = $this->ticket;
|
$ticket = $this->ticket;
|
||||||
if (isset ( $ticket )) {
|
if (isset ( $ticket )) {
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$result = $this->ticket->ticketTypeName;
|
$result = $this->ticket->ticketTypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,6 +264,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
}
|
}
|
||||||
public function getAccountName() {
|
public function getAccountName() {
|
||||||
$result = "";
|
$result = "";
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$account = $this->account;
|
$account = $this->account;
|
||||||
if (isset ( $account )) {
|
if (isset ( $account )) {
|
||||||
$result = $account->name;
|
$result = $account->name;
|
||||||
@ -272,6 +285,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
}
|
}
|
||||||
public function getSaleName() {
|
public function getSaleName() {
|
||||||
$result = "";
|
$result = "";
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$sale = $this->sale;
|
$sale = $this->sale;
|
||||||
if (isset ( $sale )) {
|
if (isset ( $sale )) {
|
||||||
$result = $sale->name;
|
$result = $sale->name;
|
||||||
@ -305,8 +319,10 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
|
|
||||||
$s .= $this->count;
|
$s .= $this->count;
|
||||||
$s .= " " . Yii::t ( 'frontend/transfer', 'pieces' ) . " ";
|
$s .= " " . Yii::t ( 'frontend/transfer', 'pieces' ) . " ";
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$s .= $this->product->name;
|
$s .= $this->product->name;
|
||||||
$s .= " - ";
|
$s .= " - ";
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$s .= $this->account->name;
|
$s .= $this->account->name;
|
||||||
|
|
||||||
return $s;
|
return $s;
|
||||||
@ -314,12 +330,15 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param $account common\models\Account
|
* @param $sale
|
||||||
* @param $discount common\models\Discount
|
* @param $account \common\models\Account
|
||||||
* @param $currency common\models\Currency
|
* @param $discount \common\models\Discount
|
||||||
* @param $product common\models\Product
|
* @param $currency \common\models\Currency
|
||||||
* @param $customer common\models\Customer
|
* @param $count
|
||||||
*
|
* @param $product \common\models\Product
|
||||||
|
* @param int $status
|
||||||
|
* @param $customer \common\models\Customer
|
||||||
|
* @return Transfer
|
||||||
*/
|
*/
|
||||||
public static function createProductTransfer($sale, $account, $discount, $currency, $count, $product, $status = Transfer::STATUS_PAID, $customer = null) {
|
public static function createProductTransfer($sale, $account, $discount, $currency, $count, $product, $status = Transfer::STATUS_PAID, $customer = null) {
|
||||||
$transfer = new Transfer ();
|
$transfer = new Transfer ();
|
||||||
@ -334,6 +353,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
$transfer->count = $count;
|
$transfer->count = $count;
|
||||||
$totalPrice = $totalPrice * $count;
|
$totalPrice = $totalPrice * $count;
|
||||||
|
|
||||||
|
/** @var \common\models\Discount $discount */
|
||||||
if (isset ( $discount )) {
|
if (isset ( $discount )) {
|
||||||
$transfer->id_discount = $discount->id_discount;
|
$transfer->id_discount = $discount->id_discount;
|
||||||
$totalPrice = Discount::applyDiscount ( $totalPrice, $discount );
|
$totalPrice = Discount::applyDiscount ( $totalPrice, $discount );
|
||||||
@ -360,11 +380,11 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param $account common\models\Account
|
* @param $account \common\models\Account
|
||||||
* @param $discount common\models\Discount
|
* @param $moneyMovement \common\models\MoneyMovement
|
||||||
* @param $currency common\models\Currency
|
* @return Transfer
|
||||||
* @param $moneyMovement common\models\MoneyMovement
|
* @internal param Discount $discount
|
||||||
*
|
* @internal param Currency $currency
|
||||||
*/
|
*/
|
||||||
public static function createMoneyMovementOutTransfer($account, $moneyMovement) {
|
public static function createMoneyMovementOutTransfer($account, $moneyMovement) {
|
||||||
$transfer = new Transfer ();
|
$transfer = new Transfer ();
|
||||||
@ -388,13 +408,17 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
|
|
||||||
return $transfer;
|
return $transfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param $account common\models\Account
|
* @param $account \common\models\Account
|
||||||
* @param $discount common\models\Discount
|
* @param $discount \common\models\Discount
|
||||||
* @param $currency common\models\Currency
|
* @param $currency \common\models\Currency
|
||||||
* @param $ticket common\models\Ticket
|
* @param $count int
|
||||||
|
* @param $ticket \common\models\Ticket
|
||||||
*
|
*
|
||||||
|
* @param int $status
|
||||||
|
* @return Transfer
|
||||||
*/
|
*/
|
||||||
public static function createTicketTransfer($account, $discount, $currency, $count, $ticket, $status = Transfer::STATUS_NOT_PAID) {
|
public static function createTicketTransfer($account, $discount, $currency, $count, $ticket, $status = Transfer::STATUS_NOT_PAID) {
|
||||||
$transfer = new Transfer ();
|
$transfer = new Transfer ();
|
||||||
@ -412,6 +436,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
$totalPrice = $totalPrice * $count;
|
$totalPrice = $totalPrice * $count;
|
||||||
|
|
||||||
if (isset ( $discount )) {
|
if (isset ( $discount )) {
|
||||||
|
/** @var \common\models\Discount $discount */
|
||||||
$transfer->id_discount = $discount->id_discount;
|
$transfer->id_discount = $discount->id_discount;
|
||||||
$totalPrice = Discount::applyDiscount ( $totalPrice, $discount );
|
$totalPrice = Discount::applyDiscount ( $totalPrice, $discount );
|
||||||
}
|
}
|
||||||
@ -420,6 +445,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
|
|
||||||
if (isset ( $currency )) {
|
if (isset ( $currency )) {
|
||||||
$transfer->rate = $currency->rate;
|
$transfer->rate = $currency->rate;
|
||||||
|
/** @var \common\models\Currency $currency */
|
||||||
$transfer->money_currency = Currency::applyCurrency ( $totalPrice, $currency );
|
$transfer->money_currency = Currency::applyCurrency ( $totalPrice, $currency );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,6 +490,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
} else if ($transfer->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) {
|
} else if ($transfer->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) {
|
||||||
return "Pénzmozgás";
|
return "Pénzmozgás";
|
||||||
}
|
}
|
||||||
|
return "-";
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
] );
|
] );
|
||||||
@ -490,8 +517,6 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
public static function readUserSoldTransfers($user) {
|
public static function readUserSoldTransfers($user) {
|
||||||
$transfers = [ ];
|
|
||||||
|
|
||||||
$query = Transfer::find ();
|
$query = Transfer::find ();
|
||||||
$query->innerJoin ( "user_sold_item", "user_sold_item.id_transfer = transfer.id_transfer" );
|
$query->innerJoin ( "user_sold_item", "user_sold_item.id_transfer = transfer.id_transfer" );
|
||||||
|
|
||||||
@ -501,9 +526,8 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
'user_sold_item.id_user' => $user->id
|
'user_sold_item.id_user' => $user->id
|
||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
$transfers = $query->all ();
|
return $query->all ();
|
||||||
|
|
||||||
return $transfers;
|
|
||||||
}
|
}
|
||||||
public static function readCustomerCart($customer) {
|
public static function readCustomerCart($customer) {
|
||||||
$transfers = [ ];
|
$transfers = [ ];
|
||||||
@ -573,15 +597,19 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
public function beforeDelete() {
|
public function beforeDelete() {
|
||||||
parent::beforeDelete ();
|
parent::beforeDelete ();
|
||||||
if ($this->type == Transfer::TYPE_TICKET) {
|
if ($this->type == Transfer::TYPE_TICKET) {
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$ticket = $this->ticket;
|
$ticket = $this->ticket;
|
||||||
if ($ticket != null) {
|
if ($ticket != null) {
|
||||||
$ticket->delete ();
|
$ticket->delete ();
|
||||||
}
|
}
|
||||||
} else if ($this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) {
|
} else if ($this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) {
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$mm = $this->moneyMovement;
|
$mm = $this->moneyMovement;
|
||||||
$mm->delete ();
|
$mm->delete ();
|
||||||
} else if ($this->type == Transfer::TYPE_PRODUCT) {
|
} else if ($this->type == Transfer::TYPE_PRODUCT) {
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$sale = $this->sale;
|
$sale = $this->sale;
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$product = $this->product;
|
$product = $this->product;
|
||||||
|
|
||||||
$product->stock = $product->stock + $this->count;
|
$product->stock = $product->stock + $this->count;
|
||||||
@ -631,6 +659,12 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
* @param $start
|
||||||
|
* @param $end
|
||||||
|
* @param $idUser
|
||||||
|
* @param $types
|
||||||
|
* @param $idAccount
|
||||||
|
* @return Query
|
||||||
*/
|
*/
|
||||||
public static function mkTotalQuery($mode, $start, $end, $idUser, $types, $idAccount) {
|
public static function mkTotalQuery($mode, $start, $end, $idUser, $types, $idAccount) {
|
||||||
$query = new Query ();
|
$query = new Query ();
|
||||||
@ -698,6 +732,13 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \yii\db\Query $query
|
||||||
|
* @param string $field
|
||||||
|
* @param string $start
|
||||||
|
* @param string $end
|
||||||
|
*/
|
||||||
public static function notInInterval($query, $field, $start, $end) {
|
public static function notInInterval($query, $field, $start, $end) {
|
||||||
$query->andFilterWhere ( [
|
$query->andFilterWhere ( [
|
||||||
'or',
|
'or',
|
||||||
@ -713,6 +754,13 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
]
|
]
|
||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \yii\db\Query $query
|
||||||
|
* @param string $field
|
||||||
|
* @param string $start
|
||||||
|
* @param string $end
|
||||||
|
*/
|
||||||
public static function notPaid($query, $field, $start, $end) {
|
public static function notPaid($query, $field, $start, $end) {
|
||||||
$query->andFilterWhere ( [
|
$query->andFilterWhere ( [
|
||||||
'or',
|
'or',
|
||||||
@ -731,6 +779,13 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
]
|
]
|
||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \yii\db\Query $query
|
||||||
|
* @param string $field
|
||||||
|
* @param string $start
|
||||||
|
* @param string $end
|
||||||
|
*/
|
||||||
public static function inInterval($query, $field, $start, $end) {
|
public static function inInterval($query, $field, $start, $end) {
|
||||||
$query->andFilterWhere ( [
|
$query->andFilterWhere ( [
|
||||||
'>=',
|
'>=',
|
||||||
@ -751,6 +806,10 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
* @param mixed $queryResult
|
* @param mixed $queryResult
|
||||||
* an array, wchic contains items. each item has to key - value pairs: [ id_account => 0, money => 0 ]
|
* an array, wchic contains items. each item has to key - value pairs: [ id_account => 0, money => 0 ]
|
||||||
*
|
*
|
||||||
|
* @param $accounts
|
||||||
|
* @param $accountMap
|
||||||
|
* @param $idAccount
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function mkTotalsResultWithAllAvailableAccount($queryResult, $accounts, $accountMap, $idAccount) {
|
public static function mkTotalsResultWithAllAvailableAccount($queryResult, $accounts, $accountMap, $idAccount) {
|
||||||
$totals = [ ];
|
$totals = [ ];
|
||||||
@ -792,6 +851,13 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* create and execute a "total" query
|
* create and execute a "total" query
|
||||||
|
* @param $mode
|
||||||
|
* @param $start
|
||||||
|
* @param $end
|
||||||
|
* @param $idUser
|
||||||
|
* @param $types
|
||||||
|
* @param $idAccount
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function exTotalQuery($mode, $start, $end, $idUser, $types, $idAccount) {
|
public static function exTotalQuery($mode, $start, $end, $idUser, $types, $idAccount) {
|
||||||
$query = self::mkTotalQuery ( $mode, $start, $end, $idUser, $types, $idAccount );
|
$query = self::mkTotalQuery ( $mode, $start, $end, $idUser, $types, $idAccount );
|
||||||
@ -802,8 +868,17 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* find all transfers which were paid in the period
|
* find all transfers which were paid in the period
|
||||||
|
* @param $start
|
||||||
|
* @param $end
|
||||||
|
* @param $idUser
|
||||||
|
* @param $types
|
||||||
|
* @param $idAccount
|
||||||
|
* @param $accounts
|
||||||
|
* @param $accountMap
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function mkPaidAtTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
|
public static function mkPaidAtTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
|
||||||
|
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||||
$result = [ ];
|
$result = [ ];
|
||||||
$queryResult = self::exTotalQuery ( 'paid_at', $start, $end, $idUser, $types, $idAccount );
|
$queryResult = self::exTotalQuery ( 'paid_at', $start, $end, $idUser, $types, $idAccount );
|
||||||
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
|
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
|
||||||
@ -814,6 +889,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
* find all transfers in the period ( doesn't matter if paid or not )
|
* find all transfers in the period ( doesn't matter if paid or not )
|
||||||
*/
|
*/
|
||||||
public static function mkCreatedAtTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
|
public static function mkCreatedAtTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
|
||||||
|
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||||
$result = [ ];
|
$result = [ ];
|
||||||
$queryResult = self::exTotalQuery ( 'created_at', $start, $end, $idUser, $types, $idAccount );
|
$queryResult = self::exTotalQuery ( 'created_at', $start, $end, $idUser, $types, $idAccount );
|
||||||
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
|
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
|
||||||
@ -824,6 +900,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
* find transfers which were created but not paid in the period
|
* find transfers which were created but not paid in the period
|
||||||
*/
|
*/
|
||||||
public static function mkCreatedAtNotPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
|
public static function mkCreatedAtNotPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
|
||||||
|
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||||
$result = [ ];
|
$result = [ ];
|
||||||
$queryResult = self::exTotalQuery ( 'created_at_not_paid', $start, $end, $idUser, $types, $idAccount );
|
$queryResult = self::exTotalQuery ( 'created_at_not_paid', $start, $end, $idUser, $types, $idAccount );
|
||||||
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
|
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
|
||||||
@ -834,6 +911,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
* find transfers which were created and paid in the period
|
* find transfers which were created and paid in the period
|
||||||
*/
|
*/
|
||||||
public static function mkCreatedAtPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
|
public static function mkCreatedAtPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
|
||||||
|
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||||
$result = [ ];
|
$result = [ ];
|
||||||
$queryResult = self::exTotalQuery ( 'created_at_paid', $start, $end, $idUser, $types, $idAccount );
|
$queryResult = self::exTotalQuery ( 'created_at_paid', $start, $end, $idUser, $types, $idAccount );
|
||||||
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
|
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
|
||||||
@ -842,8 +920,17 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* find transfers, where depth was paid
|
* find transfers, where depth was paid
|
||||||
|
* @param $start
|
||||||
|
* @param $end
|
||||||
|
* @param $idUser
|
||||||
|
* @param $types
|
||||||
|
* @param $idAccount
|
||||||
|
* @param $accounts
|
||||||
|
* @param $accountMap
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function mkPaidAtNotCreatedAtPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
|
public static function mkPaidAtNotCreatedAtPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
|
||||||
|
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||||
$result = [ ];
|
$result = [ ];
|
||||||
$queryResult = self::exTotalQuery ( 'paid_at_not_created_at', $start, $end, $idUser, $types, $idAccount );
|
$queryResult = self::exTotalQuery ( 'paid_at_not_created_at', $start, $end, $idUser, $types, $idAccount );
|
||||||
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
|
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
|
||||||
@ -869,8 +956,12 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
* - tranzakció fizetési módja: készpénz
|
* - tranzakció fizetési módja: készpénz
|
||||||
* - tranzakció státusza: fizetve
|
* - tranzakció státusza: fizetve
|
||||||
* -
|
* -
|
||||||
|
* @param $start
|
||||||
|
* @param $end
|
||||||
|
* @param $idUser
|
||||||
|
* @return bool|string
|
||||||
*/
|
*/
|
||||||
public static function readPaid($start, $end, $idUser) {
|
public static function readPaidCash($start, $end, $idUser) {
|
||||||
$query = (new \yii\db\Query ());
|
$query = (new \yii\db\Query ());
|
||||||
$query->select ( [
|
$query->select ( [
|
||||||
'coalesce(sum( case when transfer.direction = ' . Transfer::DIRECTION_IN . ' then transfer.money else -1 * transfer.money end ),0) AS transfer_money'
|
'coalesce(sum( case when transfer.direction = ' . Transfer::DIRECTION_IN . ' then transfer.money else -1 * transfer.money end ),0) AS transfer_money'
|
||||||
@ -883,29 +974,14 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
|
|
||||||
$created_condition = [
|
$created_condition = [
|
||||||
'and',
|
'and',
|
||||||
[
|
[ '>=', 'transfer.created_at', $start ],
|
||||||
'>=',
|
[ '<', 'transfer.created_at', $end ]
|
||||||
'transfer.created_at',
|
|
||||||
$start
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'<',
|
|
||||||
'transfer.created_at',
|
|
||||||
$end
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$paid_condition = [
|
$paid_condition = [
|
||||||
'and',
|
'and',
|
||||||
[
|
[ '>=', 'transfer.paid_at', $start ],
|
||||||
'>=',
|
[ '<', 'transfer.paid_at', $end ]
|
||||||
'transfer.paid_at',
|
|
||||||
$start
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'<',
|
|
||||||
'transfer.paid_at',
|
|
||||||
$end
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$query->andFilterWhere ( [
|
$query->andFilterWhere ( [
|
||||||
@ -913,18 +989,17 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
$created_condition,
|
$created_condition,
|
||||||
$paid_condition
|
$paid_condition
|
||||||
] );
|
] );
|
||||||
|
|
||||||
$query->andWhere ( [
|
$query->andWhere ( [
|
||||||
'transfer.status' => Transfer::STATUS_PAID
|
'transfer.status' => Transfer::STATUS_PAID,
|
||||||
] );
|
'account.type' => Account::TYPE_ALL ,
|
||||||
$query->andWhere ( [
|
|
||||||
'account.type' => Account::TYPE_ALL
|
|
||||||
] );
|
|
||||||
$query->andWhere ( [
|
|
||||||
'transfer.payment_method' => Transfer::PAYMENT_METHOD_CASH
|
'transfer.payment_method' => Transfer::PAYMENT_METHOD_CASH
|
||||||
] );
|
] );
|
||||||
|
|
||||||
return $query->scalar ();
|
return $query->scalar ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function storno() {
|
public function storno() {
|
||||||
$this->status = Transfer::STATUS_STORNO;
|
$this->status = Transfer::STATUS_STORNO;
|
||||||
$this->save ( false );
|
$this->save ( false );
|
||||||
@ -944,13 +1019,17 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
|
|
||||||
// storno contract
|
// storno contract
|
||||||
} else if ($this->type == Transfer::TYPE_PRODUCT) {
|
} else if ($this->type == Transfer::TYPE_PRODUCT) {
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$sale = $this->sale;
|
$sale = $this->sale;
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
|
/** @var \common\models\Product $product */
|
||||||
$product = $this->sale->product;
|
$product = $this->sale->product;
|
||||||
$product->stock = $product->stock + $this->count;
|
$product->stock = $product->stock + $this->count;
|
||||||
$product->save ( false );
|
$product->save ( false );
|
||||||
$sale->status = Sale::STATUS_DELETED;
|
$sale->status = Sale::STATUS_DELETED;
|
||||||
$sale->save ( false );
|
$sale->save ( false );
|
||||||
} else if ($this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) {
|
} else if ($this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) {
|
||||||
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
$mm = $this->moneyMovement;
|
$mm = $this->moneyMovement;
|
||||||
$mm->status = MoneyMovement::STATUS_STORNO;
|
$mm->status = MoneyMovement::STATUS_STORNO;
|
||||||
$mm->save ( false );
|
$mm->save ( false );
|
||||||
@ -963,6 +1042,10 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
'id_transfer' => $this->id_transfer
|
'id_transfer' => $this->id_transfer
|
||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \yii\web\NotAcceptableHttpException
|
||||||
|
*/
|
||||||
public function unstorono() {
|
public function unstorono() {
|
||||||
if ($this->type != Transfer::TYPE_TICKET) {
|
if ($this->type != Transfer::TYPE_TICKET) {
|
||||||
throw new NotAcceptableHttpException ( "Csak bérletet lehet visszaállítani" );
|
throw new NotAcceptableHttpException ( "Csak bérletet lehet visszaállítani" );
|
||||||
@ -991,6 +1074,51 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $start $start date
|
||||||
|
* @param $end $end date
|
||||||
|
* @param $idUser $user
|
||||||
|
* @return bool|string
|
||||||
|
*/
|
||||||
|
public static function readPaidNonCash($start, $end, $idUser) {
|
||||||
|
$query = (new Query());
|
||||||
|
$query->select ( [
|
||||||
|
'coalesce(sum( case when transfer.direction = ' . Transfer::DIRECTION_IN . ' then transfer.money else -1 * transfer.money end ),0) AS transfer_money'
|
||||||
|
] );
|
||||||
|
$query->from ( 'transfer' );
|
||||||
|
$query->innerJoin ( "account", "account.id_account = transfer.id_account" );
|
||||||
|
$query->andWhere ( [
|
||||||
|
'transfer.paid_by' => $idUser
|
||||||
|
] );
|
||||||
|
|
||||||
|
$created_condition = [
|
||||||
|
'and',
|
||||||
|
[ '>=', 'transfer.created_at', $start ],
|
||||||
|
[ '<', 'transfer.created_at', $end ]
|
||||||
|
];
|
||||||
|
|
||||||
|
$paid_condition = [
|
||||||
|
'and',
|
||||||
|
[ '>=', 'transfer.paid_at', $start ],
|
||||||
|
[ '<', 'transfer.paid_at', $end ]
|
||||||
|
];
|
||||||
|
|
||||||
|
$query->andFilterWhere ( [
|
||||||
|
'or',
|
||||||
|
$created_condition,
|
||||||
|
$paid_condition
|
||||||
|
] );
|
||||||
|
|
||||||
|
$query->andWhere ( [
|
||||||
|
'transfer.status' => Transfer::STATUS_PAID,
|
||||||
|
'account.type' => Account::TYPE_ALL
|
||||||
|
] );
|
||||||
|
|
||||||
|
$query->andWhere(['<>' ,'transfer.payment_method', Transfer::PAYMENT_METHOD_CASH ]);
|
||||||
|
|
||||||
|
return $query->scalar ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function payout($id_account = null) {
|
public function payout($id_account = null) {
|
||||||
if ($this->status != Transfer::STATUS_NOT_PAID) {
|
if ($this->status != Transfer::STATUS_NOT_PAID) {
|
||||||
|
|||||||
@ -99,7 +99,10 @@ class DetstaConsoleController extends Controller
|
|||||||
|
|
||||||
$content = $detsta->toString();
|
$content = $detsta->toString();
|
||||||
|
|
||||||
file_put_contents('c:\tmp\detsta.txt', $content);
|
$fn = 'c:\tmp\detsta.txt';
|
||||||
|
|
||||||
|
file_put_contents($fn , $content);
|
||||||
|
echo "File saved: " . $fn;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,9 +25,9 @@ class TicketController extends Controller {
|
|||||||
$result = $command->execute ();
|
$result = $command->execute ();
|
||||||
\Yii::info ( "Tickets updated flag door: " . $result );
|
\Yii::info ( "Tickets updated flag door: " . $result );
|
||||||
|
|
||||||
// $command = $connection->createCommand ( Ticket::$SQL_UPDATE );
|
$command = $connection->createCommand ( Ticket::$SQL_UPDATE );
|
||||||
// $result = $command->execute ();
|
$result = $command->execute ();
|
||||||
// \Yii::info ( "Tickets updated: " . $result );
|
\Yii::info ( "Tickets updated: " . $result );
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// $command = $connection->createCommand ( Card::$SQL_FIX_KEY_STATUS );
|
// $command = $connection->createCommand ( Card::$SQL_FIX_KEY_STATUS );
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m161004_062500_alter__table__account_state_add_column_non_cash_money extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->addColumn("account_state", "non_cash_money", "int default 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m161004_062500_alter__table__account_state_add_column_non_cash_money cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m161017_054129_alter__table__customer__add__column_towel_count extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->addColumn("customer", "towel_count", "int default 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m161017_054129_alter__table__customer__add__column_towel_count cannot be reverted.\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@ -4,7 +4,8 @@ namespace frontend\controllers;
|
|||||||
|
|
||||||
use common\components\DateUtil;
|
use common\components\DateUtil;
|
||||||
use frontend\models\AccountstateSearchToday;
|
use frontend\models\AccountstateSearchToday;
|
||||||
use Yii;
|
use /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
|
||||||
|
Yii;
|
||||||
use common\models\AccountState;
|
use common\models\AccountState;
|
||||||
use frontend\models\AccountstateSearch;
|
use frontend\models\AccountstateSearch;
|
||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
@ -201,7 +202,7 @@ class AccountStateController extends Controller {
|
|||||||
$total += $cassaOpen->money;
|
$total += $cassaOpen->money;
|
||||||
$openDate = $cassaOpen->created_at;
|
$openDate = $cassaOpen->created_at;
|
||||||
}
|
}
|
||||||
$total += Transfer::readPaid($openDate, date('Y-m-d H:i:s'), \Yii::$app->user->id);
|
$total += Transfer::readPaidCash($openDate, date('Y-m-d H:i:s'), \Yii::$app->user->id);
|
||||||
return $total;
|
return $total;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,41 +228,7 @@ class AccountStateController extends Controller {
|
|||||||
throw new NotFoundHttpException ( 'The requested page does not exist.' );
|
throw new NotFoundHttpException ( 'The requested page does not exist.' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Creates a new AccountState model.
|
|
||||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
|
||||||
*
|
|
||||||
* @return mixed public function actionCreate()
|
|
||||||
* {
|
|
||||||
* $model = new AccountState();
|
|
||||||
*
|
|
||||||
* if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
|
||||||
* return $this->redirect(['view', 'id' => $model->id_account_state]);
|
|
||||||
* } else {
|
|
||||||
* return $this->render('create', [
|
|
||||||
* 'model' => $model,
|
|
||||||
* ]);
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Updates an existing AccountState model.
|
|
||||||
* If update is successful, the browser will be redirected to the 'view' page.
|
|
||||||
*
|
|
||||||
* @param integer $id
|
|
||||||
* @return mixed public function actionUpdate($id)
|
|
||||||
* {
|
|
||||||
* $model = $this->findModel($id);
|
|
||||||
*
|
|
||||||
* if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
|
||||||
* return $this->redirect(['view', 'id' => $model->id_account_state]);
|
|
||||||
* } else {
|
|
||||||
* return $this->render('update', [
|
|
||||||
* 'model' => $model,
|
|
||||||
* ]);
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* Deletes an existing AccountState model.
|
* Deletes an existing AccountState model.
|
||||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||||
@ -321,6 +288,7 @@ class AccountStateController extends Controller {
|
|||||||
$mpdf->useSubstitutions=false;
|
$mpdf->useSubstitutions=false;
|
||||||
$mpdf->simpleTables = true;
|
$mpdf->simpleTables = true;
|
||||||
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
|
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
|
||||||
|
/** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
|
||||||
$mpdf->setFooter('{PAGENO} / {nb}');
|
$mpdf->setFooter('{PAGENO} / {nb}');
|
||||||
|
|
||||||
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
|
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
|
||||||
@ -331,10 +299,12 @@ class AccountStateController extends Controller {
|
|||||||
'model' => $accountState,
|
'model' => $accountState,
|
||||||
'details' => $details
|
'details' => $details
|
||||||
]));
|
]));
|
||||||
|
/** @noinspection SpellCheckingInspection */
|
||||||
$type = $accountState->isTypeOpen() ? "kassza_nyitas" : "kassza_zaras";
|
$type = $accountState->isTypeOpen() ? "kassza_nyitas" : "kassza_zaras";
|
||||||
$dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username;
|
$dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username;
|
||||||
$fn= $type .$dt.".pdf";
|
$fn= $type .$dt.".pdf";
|
||||||
$mpdf->Output($fn, 'D');
|
$mpdf->Output($fn, 'D');
|
||||||
|
exit(0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -378,6 +348,7 @@ class AccountStateController extends Controller {
|
|||||||
$mpdf->useSubstitutions=false;
|
$mpdf->useSubstitutions=false;
|
||||||
$mpdf->simpleTables = true;
|
$mpdf->simpleTables = true;
|
||||||
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
|
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
|
||||||
|
/** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
|
||||||
$mpdf->setFooter('{PAGENO} / {nb}');
|
$mpdf->setFooter('{PAGENO} / {nb}');
|
||||||
|
|
||||||
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
|
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
|
||||||
@ -391,6 +362,7 @@ class AccountStateController extends Controller {
|
|||||||
'model' => $accountState,
|
'model' => $accountState,
|
||||||
'details' => $details
|
'details' => $details
|
||||||
]));
|
]));
|
||||||
|
/** @noinspection SpellCheckingInspection */
|
||||||
$type = $accountState->isTypeOpen() ? "kassza_nyitas" : "kassza_zaras";
|
$type = $accountState->isTypeOpen() ? "kassza_nyitas" : "kassza_zaras";
|
||||||
$dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username;
|
$dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username;
|
||||||
$fn= $type .$dt.".pdf";
|
$fn= $type .$dt.".pdf";
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace frontend\controllers;
|
namespace frontend\controllers;
|
||||||
|
|
||||||
|
use frontend\models\TowelForm;
|
||||||
use Yii;
|
use Yii;
|
||||||
use common\models\Customer;
|
use common\models\Customer;
|
||||||
use frontend\models\ReceptionForm;
|
use frontend\models\ReceptionForm;
|
||||||
@ -35,7 +36,7 @@ class CustomerController extends Controller
|
|||||||
],
|
],
|
||||||
'access' => [
|
'access' => [
|
||||||
'class' => \yii\filters\AccessControl::className(),
|
'class' => \yii\filters\AccessControl::className(),
|
||||||
'only' => ['create', 'update','reception','contract'],
|
'only' => ['create', 'update','reception','contract','towel'],
|
||||||
'rules' => [
|
'rules' => [
|
||||||
// allow authenticated users
|
// allow authenticated users
|
||||||
[
|
[
|
||||||
@ -91,8 +92,9 @@ class CustomerController extends Controller
|
|||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Displays a single Customer model.
|
* Displays a single Customer model.
|
||||||
* @param integer $id
|
* @param null $number
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @internal param int $id
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
public function actionView($id)
|
public function actionView($id)
|
||||||
@ -102,6 +104,26 @@ class CustomerController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
public function actionTowel($number = null)
|
||||||
|
{
|
||||||
|
$model = new TowelForm();
|
||||||
|
if ($model->load(Yii::$app->request->post()) ) {
|
||||||
|
if ( $model->save() ){
|
||||||
|
if ( $model->direction == 'in'){
|
||||||
|
\Yii::$app->session->setFlash ( 'success', 'Törölköző(k) visszaadva!' );
|
||||||
|
}else{
|
||||||
|
\Yii::$app->session->setFlash ( 'success', 'Törölköző(k) kiadva!' );
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
\Yii::$app->session->setFlash ( 'danger', 'Sikertelen törölköző művelet' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->redirect(['customer/reception', 'number' => $number ]);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Customer model.
|
* Creates a new Customer model.
|
||||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||||
|
|||||||
84
frontend/controllers/LogController.php
Normal file
84
frontend/controllers/LogController.php
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace frontend\controllers;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use common\models\Log;
|
||||||
|
use frontend\models\LogSearch;
|
||||||
|
use yii\web\Controller;
|
||||||
|
use yii\web\NotFoundHttpException;
|
||||||
|
use yii\filters\VerbFilter;
|
||||||
|
use common\models\Card;
|
||||||
|
use common\models\TicketInstallmentRequest;
|
||||||
|
use common\models\Ticket;
|
||||||
|
use common\models\Transfer;
|
||||||
|
use common\models\Account;
|
||||||
|
use common\components\Helper;
|
||||||
|
use common\models\Sale;
|
||||||
|
use common\models\Product;
|
||||||
|
use common\models\ShoppingCart;
|
||||||
|
use common\models\Customer;
|
||||||
|
use frontend\models\LogForm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LogController implements the CRUD actions for Log model.
|
||||||
|
*/
|
||||||
|
class LogController extends Controller {
|
||||||
|
public function behaviors() {
|
||||||
|
return [
|
||||||
|
'access' => [
|
||||||
|
'class' => \yii\filters\AccessControl::className(),
|
||||||
|
'only' => ['towel'],
|
||||||
|
'rules' => [
|
||||||
|
// allow authenticated users
|
||||||
|
[
|
||||||
|
'allow' => true,
|
||||||
|
'roles' => ['@'],
|
||||||
|
],
|
||||||
|
// everything else is denied
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists all Log models.
|
||||||
|
* @param $id_card
|
||||||
|
* @return mixed
|
||||||
|
* @throws \Yii\web\NotFoundHttpException
|
||||||
|
*/
|
||||||
|
public function actionTowel($id_card) {
|
||||||
|
$card = Card::findOne ( $id_card );
|
||||||
|
|
||||||
|
if (! isset ( $card ))
|
||||||
|
throw new NotFoundHttpException ( 'A bérlet nem található' );
|
||||||
|
|
||||||
|
$searchModel = new LogSearch ();
|
||||||
|
$searchModel->card = $card;
|
||||||
|
$searchModel->customer = $card->customer;
|
||||||
|
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
|
||||||
|
|
||||||
|
return $this->render ( 'index', [
|
||||||
|
'searchModel' => $searchModel,
|
||||||
|
'dataProvider' => $dataProvider
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the Log model based on its primary key value.
|
||||||
|
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||||
|
*
|
||||||
|
* @param integer $id
|
||||||
|
* @return Log the loaded model
|
||||||
|
* @throws NotFoundHttpException if the model cannot be found
|
||||||
|
*/
|
||||||
|
protected function findModel($id) {
|
||||||
|
if (($model = Log::findOne ( $id )) !== null) {
|
||||||
|
return $model;
|
||||||
|
} else {
|
||||||
|
throw new NotFoundHttpException ( 'The requested page does not exist.' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -401,6 +401,11 @@ class TransferController extends Controller
|
|||||||
return $this->redirect(['account/select']);
|
return $this->redirect(['account/select']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$hiddenAccounts = Account::find()
|
||||||
|
->andWhere(['type' => Account::TYPE_VALUE_HIDDEN])
|
||||||
|
->andWhere(['status' => Account::STATUS_ACTIVE])->all();
|
||||||
|
|
||||||
|
|
||||||
$customer = null;
|
$customer = null;
|
||||||
$card = Card::findOne($id_card);
|
$card = Card::findOne($id_card);
|
||||||
if ($card != null )
|
if ($card != null )
|
||||||
@ -413,6 +418,7 @@ class TransferController extends Controller
|
|||||||
|
|
||||||
$model = new CustomerCartForm();
|
$model = new CustomerCartForm();
|
||||||
$model->customer = $customer;
|
$model->customer = $customer;
|
||||||
|
$model->hiddenAccounts = $hiddenAccounts;
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->payout()) {
|
if ($model->load(Yii::$app->request->post()) && $model->payout()) {
|
||||||
return $this->redirect(['customer-cart','id_card' => $model->customer->card->id_card]);
|
return $this->redirect(['customer-cart','id_card' => $model->customer->card->id_card]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,8 @@ class CustomerCartForm extends Model
|
|||||||
public $money = 0;
|
public $money = 0;
|
||||||
public $selected = [];
|
public $selected = [];
|
||||||
public $customer;
|
public $customer;
|
||||||
|
public $hiddenAccounts;
|
||||||
|
public $id_account;
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
@ -28,7 +29,7 @@ class CustomerCartForm extends Model
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
['selected', 'each', 'rule' => ['integer']],
|
['selected', 'each', 'rule' => ['integer']],
|
||||||
[['money' ,'payment_method'],'integer'],
|
[['money' ,'payment_method' ,'id_account' ],'integer'],
|
||||||
[['payment_method'],'validatePaymentMethod'],
|
[['payment_method'],'validatePaymentMethod'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -44,7 +45,6 @@ class CustomerCartForm extends Model
|
|||||||
|
|
||||||
public function validatePaymentMethod( $attribute, $params ){
|
public function validatePaymentMethod( $attribute, $params ){
|
||||||
if ( !empty($this->payment_method)){
|
if ( !empty($this->payment_method)){
|
||||||
// echo $this->payment_method;
|
|
||||||
$arr = Transfer::paymentMethods();
|
$arr = Transfer::paymentMethods();
|
||||||
if ( !array_key_exists($this->payment_method, $arr) ){
|
if ( !array_key_exists($this->payment_method, $arr) ){
|
||||||
$this->addError($attribute, "Érvénytelen fizetési mód");
|
$this->addError($attribute, "Érvénytelen fizetési mód");
|
||||||
@ -52,6 +52,37 @@ class CustomerCartForm extends Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function validateIdAccount( $attribute, $params ){
|
||||||
|
if ( !empty($this->id_account)){
|
||||||
|
$account = $this->loadAvailableOverrideAccounts($this->id_account);
|
||||||
|
if ( !isset($account) ){
|
||||||
|
$this->addError($attribute, "Érvénytelen kassza");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function loadAvailableOverrideAccounts($id_account = null){
|
||||||
|
$accounts = null;
|
||||||
|
$query = Account::find();
|
||||||
|
|
||||||
|
$query->innerJoinWith('userAccountAssignments');
|
||||||
|
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id]);
|
||||||
|
$query->andWhere(['status' => Account::STATUS_ACTIVE])->all();
|
||||||
|
|
||||||
|
if ( isset($id_account)){
|
||||||
|
$query->andWhere(['account.id_account' => $id_account]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$query->orderBy( ['name' => SORT_ASC]);
|
||||||
|
|
||||||
|
|
||||||
|
$accounts = $query->all();
|
||||||
|
return $accounts;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function payout(){
|
public function payout(){
|
||||||
$valid = $this->validate();
|
$valid = $this->validate();
|
||||||
@ -71,6 +102,7 @@ class CustomerCartForm extends Model
|
|||||||
'idAccount' => Account::readDefault (),
|
'idAccount' => Account::readDefault (),
|
||||||
'cartType' => 'customer',
|
'cartType' => 'customer',
|
||||||
'overridePaymentMethod' => $this->payment_method,
|
'overridePaymentMethod' => $this->payment_method,
|
||||||
|
'overrideIdAccount' => $this->id_account,
|
||||||
'idCustomer' => $this->customer->id_customer
|
'idCustomer' => $this->customer->id_customer
|
||||||
] );
|
] );
|
||||||
|
|
||||||
@ -82,10 +114,10 @@ class CustomerCartForm extends Model
|
|||||||
|
|
||||||
} catch ( Exception $e ) {
|
} catch ( Exception $e ) {
|
||||||
$transaction->rollback ();
|
$transaction->rollback ();
|
||||||
Yii::error ( "faled to save :" . $e->getMessage () );
|
Yii::error ( "failed to save :" . $e->getMessage () );
|
||||||
} catch ( \Exception $e ) {
|
} catch ( \Exception $e ) {
|
||||||
$transaction->rollback ();
|
$transaction->rollback ();
|
||||||
Yii::error ( "faled to save :" . $e->getMessage () );
|
Yii::error ( "failed to save :" . $e->getMessage () );
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -101,6 +133,12 @@ class CustomerCartForm extends Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function changeAccount($item){
|
||||||
|
if ( !empty($this->id_account)){
|
||||||
|
$item->id_account = $this->id_account;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function run(){
|
public function run(){
|
||||||
$this->readTransfers();
|
$this->readTransfers();
|
||||||
}
|
}
|
||||||
|
|||||||
130
frontend/models/LogSearch.php
Normal file
130
frontend/models/LogSearch.php
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace frontend\models;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use yii\base\Model;
|
||||||
|
use yii\data\ActiveDataProvider;
|
||||||
|
use common\models\Log;
|
||||||
|
use yii\db\Expression;
|
||||||
|
use yii\db\Query;
|
||||||
|
use common\components\Helper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LogSearch represents the model behind the search form about `common\models\Log`.
|
||||||
|
*/
|
||||||
|
class LogSearch extends Log
|
||||||
|
{
|
||||||
|
|
||||||
|
public $start;
|
||||||
|
public $end;
|
||||||
|
public $timestampStart;
|
||||||
|
public $timestampEnd;
|
||||||
|
|
||||||
|
public $card;
|
||||||
|
public $customer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[[ 'start', ], 'date', 'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
|
||||||
|
[[ 'end' , ], 'date' ,'format' =>Yii::$app->formatter->datetimeFormat , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 = new Query();
|
||||||
|
$query->select([
|
||||||
|
'log.id_log as log_id_log',
|
||||||
|
'log.created_at as log_created_at',
|
||||||
|
'log.message as log_message',
|
||||||
|
'user.username as user_username',
|
||||||
|
'customer.name as customer_name',
|
||||||
|
new Expression("case when log.type = " .Log::$TYPE_TOWEL_IN ." then 'Visszaad' ".
|
||||||
|
" when log.type = ". Log::$TYPE_TOWEL_OUT . " then 'Bérel' ".
|
||||||
|
" else '-' end as log_type")
|
||||||
|
|
||||||
|
]);
|
||||||
|
$query->from("log");
|
||||||
|
$query->leftJoin("user"," user.id = log.id_user");
|
||||||
|
$query->leftJoin("customer"," customer.id_customer = log.id_customer");
|
||||||
|
|
||||||
|
|
||||||
|
$dataProvider = new ActiveDataProvider([
|
||||||
|
'query' => $query,
|
||||||
|
'sort' =>[
|
||||||
|
'defaultOrder' => [ 'log_created_at' => SORT_DESC],
|
||||||
|
'attributes' => Helper::mkYiiSortItems([
|
||||||
|
['log_id_log'],
|
||||||
|
['log_created_at'],
|
||||||
|
['log_message'],
|
||||||
|
['log_app'],
|
||||||
|
['log_app'],
|
||||||
|
['user_username'],
|
||||||
|
['customer_name'],
|
||||||
|
['log_type'],
|
||||||
|
|
||||||
|
])
|
||||||
|
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
$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(['>=', 'log.created_at', $this->timestampStart]);
|
||||||
|
$query->andFilterWhere(['<', 'log.created_at', $this->timestampEnd]);
|
||||||
|
|
||||||
|
$query->andFilterWhere([
|
||||||
|
'id_log' => $this->id_log,
|
||||||
|
'type' => $this->type,
|
||||||
|
'id_user' => $this->id_user,
|
||||||
|
'id_transfer' => $this->id_transfer,
|
||||||
|
'id_money_movement' => $this->id_money_movement,
|
||||||
|
'id_ticket' => $this->id_ticket,
|
||||||
|
'id_sale' => $this->id_sale,
|
||||||
|
'id_customer' => $this->id_customer,
|
||||||
|
'id_account' => $this->id_account,
|
||||||
|
'id_account_state' => $this->id_account_state,
|
||||||
|
'id_key' => $this->id_key,
|
||||||
|
'id_product' => $this->id_product,
|
||||||
|
'id_door_log' => $this->id_door_log,
|
||||||
|
'created_at' => $this->created_at,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$query->andFilterWhere(['like', 'message', $this->message])
|
||||||
|
->andFilterWhere(['like', 'url', $this->url])
|
||||||
|
->andFilterWhere(['like', 'app', $this->app]);
|
||||||
|
|
||||||
|
|
||||||
|
$query->andWhere(['in', 'log.type',[Log::$TYPE_TOWEL_IN,Log::$TYPE_TOWEL_OUT]]);
|
||||||
|
$query->andWhere([ '=', 'customer.id_customer' , $this->customer->id_customer]);
|
||||||
|
|
||||||
|
return $dataProvider;
|
||||||
|
}
|
||||||
|
}
|
||||||
116
frontend/models/TowelForm.php
Normal file
116
frontend/models/TowelForm.php
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace frontend\models;
|
||||||
|
|
||||||
|
use common\models\DoorLog;
|
||||||
|
use common\models\Log;
|
||||||
|
use Yii;
|
||||||
|
use yii\base\Model;
|
||||||
|
use common\models\CardKeyAssignment;
|
||||||
|
use common\models\Key;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
|
use common\components\Helper;
|
||||||
|
use common\models\Card;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ContactForm is the model behind the contact form.
|
||||||
|
*
|
||||||
|
* @property \common\models\Card $card
|
||||||
|
* @property \common\models\Key $key
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class TowelForm extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
public $count;
|
||||||
|
public $number;
|
||||||
|
public $direction;
|
||||||
|
|
||||||
|
public $card;
|
||||||
|
public $customer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['count'], 'integer', 'min' => 1, 'max' => 10 ],
|
||||||
|
[['number','direction'], 'safe' ],
|
||||||
|
[['count', 'number'], 'required'],
|
||||||
|
[['number'],'validateCard' ],
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function attributeLabels()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validateCard($a,$params){
|
||||||
|
|
||||||
|
$this->number = Helper::fixAsciiChars( $this->number );
|
||||||
|
|
||||||
|
$query = Card::find();
|
||||||
|
$query->leftJoin("card_key_assignment", 'card.id_card = card_key_assignment.id_card');
|
||||||
|
$query->leftJoin("key", 'key.id_key = card_key_assignment.id_key');
|
||||||
|
|
||||||
|
$query->andWhere(['or',
|
||||||
|
['and',[ 'in','card.number' , [$this->number]],"trim(coalesce(card.number, '')) <>'' " ],
|
||||||
|
['and', ['in','card.rfid_key' ,[ $this->number] ],"trim(coalesce(card.rfid_key, '')) <>'' "],
|
||||||
|
['and',[ 'in','key.number' , [$this->number]],"trim(coalesce(key.number, '')) <>'' " ],
|
||||||
|
['and', ['in','key.rfid_key' ,[ $this->number] ],"trim(coalesce(key.rfid_key, '')) <>'' "]
|
||||||
|
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->card = $query->one();
|
||||||
|
|
||||||
|
if ( $this->card != null ){
|
||||||
|
$this->customer = $this->card->customer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !isset($this->customer)){
|
||||||
|
$this->addError($a,"A megadott vendég nem található");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private function updateTowelCount(){
|
||||||
|
$count = $this->count;
|
||||||
|
if ( isset($this->direction) && $this->direction == 'in'){
|
||||||
|
$count = $this->customer->towel_count - $count;
|
||||||
|
$log_type = Log::$TYPE_TOWEL_IN;
|
||||||
|
}else{
|
||||||
|
$count = $this->customer->towel_count + $count;
|
||||||
|
$log_type = Log::$TYPE_TOWEL_OUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
$count = max(0, $count );
|
||||||
|
|
||||||
|
$this->customer->towel_count = $count;
|
||||||
|
$result = $this->customer->save(false);
|
||||||
|
if ( $result ){
|
||||||
|
Log::log([
|
||||||
|
'type' => $log_type,
|
||||||
|
'message' => '' .$this->customer->towel_count,
|
||||||
|
'id_customer' => $this->customer->id_customer
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save(){
|
||||||
|
if ( $this->validate()){
|
||||||
|
return $this->updateTowelCount();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -27,6 +27,9 @@ use yii\widgets\ActiveForm;
|
|||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<?php echo $form->field($model, 'number')->label("Kártya/kulcs szám") ?>
|
<?php echo $form->field($model, 'number')->label("Kártya/kulcs szám") ?>
|
||||||
</div>
|
</div>
|
||||||
|
<div class='col-md-3'>
|
||||||
|
<?= $form->field($model, 'towel')->dropDownList( ['' => "Mind" , '1' => "Bérel Törölközőt"] ) ?>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|||||||
@ -38,6 +38,10 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
'attribute' => 'customer_email',
|
'attribute' => 'customer_email',
|
||||||
'label' => 'E-mail',
|
'label' => 'E-mail',
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'towel_count',
|
||||||
|
'label' => 'Törölköző (db)',
|
||||||
|
],
|
||||||
// [
|
// [
|
||||||
// 'attribute' => 'customer.name',
|
// 'attribute' => 'customer.name',
|
||||||
// 'value' => 'customer.name',
|
// 'value' => 'customer.name',
|
||||||
@ -45,7 +49,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
|
|
||||||
|
|
||||||
['class' => 'yii\grid\ActionColumn',
|
['class' => 'yii\grid\ActionColumn',
|
||||||
'template' => '{ticket} {product} {ticket_history} {keys} {contract}',
|
'template' => '{ticket} {product} {ticket_history} {keys} {contract} {towel}',
|
||||||
'buttons' => [
|
'buttons' => [
|
||||||
'ticket' => function ($url, $model, $key) {
|
'ticket' => function ($url, $model, $key) {
|
||||||
return Html::a('Új bérlet', $url, ['class'=> 'btn btn-xs btn-success' ]) ;
|
return Html::a('Új bérlet', $url, ['class'=> 'btn btn-xs btn-success' ]) ;
|
||||||
@ -61,6 +65,9 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
},
|
},
|
||||||
'contract' => function ($url, $model, $key) {
|
'contract' => function ($url, $model, $key) {
|
||||||
return Html::a('Szerződések', $url, ['class'=> 'btn btn-xs btn-success' ]) ;
|
return Html::a('Szerződések', $url, ['class'=> 'btn btn-xs btn-success' ]) ;
|
||||||
|
},
|
||||||
|
'towel' => function ($url, $model, $key) {
|
||||||
|
return Html::a('Törölközők', $url, ['class'=> 'btn btn-xs btn-success' ]) ;
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
'urlCreator' => function ($action, $model, $key, $index){
|
'urlCreator' => function ($action, $model, $key, $index){
|
||||||
@ -75,6 +82,9 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
$url = Url::to(['key/index','id_card' => $model['card_id_card']]);
|
$url = Url::to(['key/index','id_card' => $model['card_id_card']]);
|
||||||
}else if ( 'contract' == $action ){
|
}else if ( 'contract' == $action ){
|
||||||
$url = Url::to(['contract/index','id_card' => $model['card_id_card']]);
|
$url = Url::to(['contract/index','id_card' => $model['card_id_card']]);
|
||||||
|
}else if ( 'towel' == $action ){
|
||||||
|
$start = Yii::$app->formatter->asDatetime(strtotime('today UTC'));
|
||||||
|
$url = Url::to(['log/towel','id_card' => $model['card_id_card'] ,'LogSearch[start]' =>$start ]);
|
||||||
}
|
}
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ use yii\helpers\Url;
|
|||||||
|
|
||||||
$route = \Yii::$app->controller->id .'/'. \Yii::$app->controller->action->id;
|
$route = \Yii::$app->controller->id .'/'. \Yii::$app->controller->action->id;
|
||||||
|
|
||||||
|
$todayDateTime = Yii::$app->formatter->asDatetime(strtotime('today UTC'));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -22,6 +22,7 @@ $items = [
|
|||||||
[ 'Szerződések', ['contract/index', 'id_card' => $card->id_card ]],
|
[ 'Szerződések', ['contract/index', 'id_card' => $card->id_card ]],
|
||||||
[ 'Kosár', ['transfer/customer-cart', 'id_card' => $card->id_card ]],
|
[ 'Kosár', ['transfer/customer-cart', 'id_card' => $card->id_card ]],
|
||||||
[ 'Kártya', ['card/info', 'id_card' => $card->id_card ]],
|
[ 'Kártya', ['card/info', 'id_card' => $card->id_card ]],
|
||||||
|
[ 'Törölköző Bérlés', ['log/towel', 'id_card' => $card->id_card , 'LogSearch[start]' => $todayDateTime ]],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -36,6 +36,10 @@ if ( $model->isCardWithCustomer() ){
|
|||||||
'label' => 'Telefon',
|
'label' => 'Telefon',
|
||||||
'value' => $model->customer->phone
|
'value' => $model->customer->phone
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'label' => 'Kiadott törölközők',
|
||||||
|
'value' => $model->customer->towel_count
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'label' => 'Kulcsok',
|
'label' => 'Kulcsok',
|
||||||
'value' =>
|
'value' =>
|
||||||
|
|||||||
@ -81,5 +81,28 @@ $card = $model->card;
|
|||||||
</div>
|
</div>
|
||||||
<?php ActiveForm::end(); ?>
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
<?php if ( isset($model->customer) ) { ?>
|
||||||
|
<?php $form = ActiveForm::begin([
|
||||||
|
'action' => ['customer/towel', 'number' => $model->getCardNumber()],
|
||||||
|
'method' => 'post',
|
||||||
|
]); ?>
|
||||||
|
<div class="row" style="margin-top: 6px; margin-bottom: 6px;">
|
||||||
|
<div class='col-md-12'>
|
||||||
|
<?php echo Html::hiddenInput('TowelForm[number]', $model->getCardNumber())?>
|
||||||
|
<?php echo Html::textInput('TowelForm[count]','',['class'=>"form-control", 'placeholder' =>'Törölköző darab' ,'type' => 'number']) ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class='col-md-6'>
|
||||||
|
<?= Html::submitButton(Yii::t('frontend/collection', 'Bérel'), [ 'name' => 'TowelForm[direction]', 'value' => 'out', 'class' => 'btn btn-primary btn-block']) ?>
|
||||||
|
</div>
|
||||||
|
<div class='col-md-6'>
|
||||||
|
<?= Html::submitButton(Yii::t('frontend/collection', 'Vissza ad'), ['name' => 'TowelForm[direction]', 'value' => 'in', 'class' => 'btn btn-primary btn-block']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
<?php }?>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -136,4 +136,23 @@ if ( isset( $model->unpaidTickets ) ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ( isset($model->customer)){
|
||||||
|
|
||||||
|
if ( $model->customer->towel_count > 0 ){
|
||||||
|
$towelText = "Kiadott törölközők (db):" . $model->customer->towel_count;
|
||||||
|
$towelClass = "alert alert-danger";
|
||||||
|
}else{
|
||||||
|
$towelText = "Nincs kiadott törölköző";
|
||||||
|
$towelClass = "alert alert-success";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
echo Html::beginTag("div",['class'=> $towelClass, "role"=>"alert"]);
|
||||||
|
echo Html::beginTag("strong",[ ]);
|
||||||
|
echo $towelText;
|
||||||
|
echo Html::endTag("strong");
|
||||||
|
echo Html::endTag("div");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
50
frontend/views/log/_search.php
Normal file
50
frontend/views/log/_search.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
use kartik\widgets\DateTimePicker;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\models\LogSearch */
|
||||||
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="log-search">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin([
|
||||||
|
'action' => ['towel', 'id_card' => $model->card->id_card ],
|
||||||
|
'method' => 'get',
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3">
|
||||||
|
|
||||||
|
<?= $form->field($model, 'start')->widget(DateTimePicker::classname(), [
|
||||||
|
'pluginOptions' => [
|
||||||
|
'autoclose'=>true,
|
||||||
|
'format' => 'yyyy.mm.dd hh:ii'
|
||||||
|
]
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<?= $form->field($model, 'end') ->widget(DateTimePicker::classname(), [
|
||||||
|
'pluginOptions' => [
|
||||||
|
'autoclose'=>true,
|
||||||
|
'format' => 'yyyy.mm.dd hh:ii'
|
||||||
|
]
|
||||||
|
]) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton(Yii::t('common/log', 'Keresés'), ['class' => 'btn btn-primary']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
38
frontend/views/log/index.php
Normal file
38
frontend/views/log/index.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\grid\GridView;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $searchModel frontend\models\LogSearch */
|
||||||
|
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||||
|
|
||||||
|
$this->title = Yii::t('common/log', 'Törölköző bérlés történet');
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<?php echo \frontend\components\CustomerTabWidget::widget(['card' => $searchModel->card])?>
|
||||||
|
<div class="log-index">
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||||
|
<?= GridView::widget([
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
'columns' => [
|
||||||
|
[
|
||||||
|
'attribute' => "log_created_at",
|
||||||
|
'label' => "Dátum idő",
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => "log_type",
|
||||||
|
'label' => "Esemény",
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => "log_message",
|
||||||
|
'label' => "Db",
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => "user_username",
|
||||||
|
'label' => "Felhasználó",
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]); ?>
|
||||||
|
</div>
|
||||||
@ -32,7 +32,13 @@ $this->registerJs ( 'new TransferCustomerCart( '. json_encode($options).');' );
|
|||||||
|
|
||||||
<div class="transfer-form">
|
<div class="transfer-form">
|
||||||
<?php $form = ActiveForm::begin(); ?>
|
<?php $form = ActiveForm::begin(); ?>
|
||||||
<?php echo $form->field($model, 'payment_method')->dropDownList( ['' => 'Aktuális'] + Transfer::paymentMethods())->label("Fizetése mód") ?>
|
<?php echo $form->field($model, 'payment_method')->dropDownList( ['' => 'Aktuális fizetési mód'] + Transfer::paymentMethods())->label("Fizetése mód") ?>
|
||||||
|
<?php echo $form->field($model, 'id_account')
|
||||||
|
->dropDownList( ['' => 'Aktuális kassza'] + array_reduce( $model->hiddenAccounts, function( $result, $item ){
|
||||||
|
$result[$item->id_account] = $item->name;
|
||||||
|
return $result;
|
||||||
|
} ,array()) )
|
||||||
|
->label("Kassza") ?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<span style="font-weight: bold;">Összesen:</span>
|
<span style="font-weight: bold;">Összesen:</span>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user