diff --git a/common/components/accountstate/AccountStateWidget.php b/common/components/accountstate/AccountStateWidget.php index c368403..eca630a 100644 --- a/common/components/accountstate/AccountStateWidget.php +++ b/common/components/accountstate/AccountStateWidget.php @@ -1,16 +1,12 @@ 'money', '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', [ 'attribute' => 'start_date', diff --git a/common/models/AccountState.php b/common/models/AccountState.php index 0ec2689..8d3c8e8 100644 --- a/common/models/AccountState.php +++ b/common/models/AccountState.php @@ -2,9 +2,9 @@ namespace common\models; -use Yii; +use /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */ + Yii; use yii\helpers\ArrayHelper; -use yii\behaviors\TimestampBehavior; /** * This is the model class for table "account_state". @@ -29,8 +29,9 @@ use yii\behaviors\TimestampBehavior; * @property integer $collection_money * @property string $created_at * @property string $updated_at + * @property int non_cash_money */ -class AccountState extends \common\models\BaseFitnessActiveRecord +class AccountState extends BaseFitnessActiveRecord { const TYPE_OPEN = 10; @@ -38,17 +39,7 @@ class AccountState extends \common\models\BaseFitnessActiveRecord public $start_date; - /** - * @inheritdoc - */ -// public function behaviors() -// { -// return [[ -// 'class' => TimestampBehavior::className(), -// 'value' => function(){ return date('Y-m-d H:i' ); } -// ] ]; -// } - + /** * @inheritdoc */ @@ -138,7 +129,9 @@ class AccountState extends \common\models\BaseFitnessActiveRecord public function getAccountName(){ $result = ""; - $account = $this->account; + /** @noinspection PhpUndefinedFieldInspection */ + /** @var \common\models\Account $account */ + $account = $this->account; if (isset($account)){ $result = $account->name; } @@ -156,7 +149,8 @@ class AccountState extends \common\models\BaseFitnessActiveRecord public function getUserName(){ $result = ""; - $user = $this->user; + /** @noinspection PhpUndefinedFieldInspection */ + $user = $this->user; if (isset($this->user)){ $result = $user->username; } @@ -188,14 +182,14 @@ class AccountState extends \common\models\BaseFitnessActiveRecord } return $result; } - + /** * Read last accountstates * @param $type int the type of accountstate to load * @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){ $result = null; $query = AccountState::find(); @@ -224,20 +218,23 @@ class AccountState extends \common\models\BaseFitnessActiveRecord $start = null; $end = null; $prev = null; - $this->prev_money = 0; + /** @noinspection PhpUndefinedFieldInspection */ + $this->prev_money = 0; if ( $this->type == AccountState::TYPE_CLOSE){ $lastOpen = AccountState::readLast(AccountState::TYPE_OPEN,\Yii::$app->user->id, $this->id_account); if ( $lastOpen != null ){ $start = $lastOpen->created_at; - $this->prev_state = $lastOpen->id_account_state; - $this->prev_money = $lastOpen->money; + /** @noinspection PhpUndefinedFieldInspection */ + $this->prev_state = $lastOpen->id_account_state; + /** @noinspection PhpUndefinedFieldInspection */ + $this->prev_money = $lastOpen->money; } $end = date('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,7 +245,8 @@ class AccountState extends \common\models\BaseFitnessActiveRecord public function hasDifferenceToPrevState(){ $result = false; if ( $this->type == self::TYPE_CLOSE){ - $result = ( $this->prev_money + $this->collection_money) != $this->money; + /** @noinspection PhpUndefinedFieldInspection */ + $result = ( $this->prev_money + $this->collection_money) != $this->money; } return $result; } @@ -256,7 +254,8 @@ class AccountState extends \common\models\BaseFitnessActiveRecord public function hasPlus(){ $result = false; if ( $this->type == self::TYPE_CLOSE){ - $result = ( $this->prev_money + $this->collection_money) < $this->money; + /** @noinspection PhpUndefinedFieldInspection */ + $result = ( $this->prev_money + $this->collection_money) < $this->money; } return $result; } @@ -264,18 +263,21 @@ class AccountState extends \common\models\BaseFitnessActiveRecord public function hasMinus(){ $result = false; if ( $this->type == self::TYPE_CLOSE){ - $result =( $this->prev_money + $this->collection_money) > $this->money; + /** @noinspection PhpUndefinedFieldInspection */ + $result =( $this->prev_money + $this->collection_money) > $this->money; } return $result; } public function getSignedDiff(){ - $result = $this->money - ( $this->prev_money + $this->collection_money); + /** @noinspection PhpUndefinedFieldInspection */ + $result = $this->money - ( $this->prev_money + $this->collection_money); return $result; } public function getExpected(){ - $result = $this->prev_money + $this->collection_money ; + /** @noinspection PhpUndefinedFieldInspection */ + $result = $this->prev_money + $this->collection_money ; return $result; } diff --git a/common/models/Currency.php b/common/models/Currency.php index c169e1f..06d3504 100644 --- a/common/models/Currency.php +++ b/common/models/Currency.php @@ -2,7 +2,8 @@ namespace common\models; -use Yii; +use /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */ + Yii; /** * This is the model class for table "currency". @@ -14,7 +15,7 @@ use Yii; * @property string $created_at * @property string $updated_at */ -class Currency extends \common\models\BaseFitnessActiveRecord +class Currency extends BaseFitnessActiveRecord { /** * @inheritdoc @@ -51,11 +52,13 @@ class Currency extends \common\models\BaseFitnessActiveRecord 'updated_at' => Yii::t('common/currency', 'Updated At'), ]; } - + /** * @param integer $money - * @param common\models\Currency $currency - * */ + * @param \common\models\Currency $currency + * + * @return float + */ public static function applyCurrency( $money,$currency ) { $result = $money / $currency; return $result; diff --git a/common/models/Discount.php b/common/models/Discount.php index f5cc1f9..6ee89b4 100644 --- a/common/models/Discount.php +++ b/common/models/Discount.php @@ -2,7 +2,8 @@ namespace common\models; -use Yii; +use /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */ + Yii; use yii\behaviors\TimestampBehavior; use yii\helpers\ArrayHelper; @@ -18,6 +19,7 @@ use yii\helpers\ArrayHelper; * @property integer $ticket_enabled * @property string $created_at * @property string $updated_at + * @property mixed id_discount */ class Discount extends \yii\db\ActiveRecord { @@ -86,7 +88,7 @@ class Discount extends \yii\db\ActiveRecord public function getStatusHuman(){ $result = null; - $s = self::statuses($this->status); + $s = self::statuses(); if ( array_key_exists($this->status, $s)){ $result = $s[$this->status]; } @@ -101,41 +103,59 @@ class Discount extends \yii\db\ActiveRecord public function getTypeHuman(){ $result = null; - $s = self::types($this->type); + $s = self::types(); if ( array_key_exists($this->type, $s)){ $result = $s[$this->type]; } return $result; } - - public function getProcutEnabledHuman(){ + + /** + * @return string + */ + public function getProcutEnabledHuman(){ return $this->product_enabled == 1 ? 'Igen' : 'Nem'; } - - public function getTicketEnabledHuman(){ + + /** + * @return string + */ + public function getTicketEnabledHuman(){ return $this->ticket_enabled == 1 ? 'Igen' : 'Nem'; } - - public static function read(){ + + /** + * @return array|\yii\db\ActiveRecord[] + */ + public static function read(){ return Discount::find()->andWhere([ 'status' => self::STATUS_ACTIVE ])->all(); } - - - public static function readProductDiscounts(){ + + + /** + * @return array|\yii\db\ActiveRecord[] + */ + public static function readProductDiscounts(){ return Discount::find()->andWhere([ 'status' => self::STATUS_ACTIVE , 'product_enabled' => 1 ])->all(); } - - public static function readTicketDiscounts(){ + + /** + * @return array|\yii\db\ActiveRecord[] + */ + public static function readTicketDiscounts(){ return Discount::find()->andWhere([ 'status' => self::STATUS_ACTIVE , 'ticket_enabled' => 1 ])->all(); } - - /** - * @param integer $money - * @param common\models\Discount $discount - * */ + + /** + * @param integer $money + * @param \common\models\Discount $discount + * + * @return int + */ public static function applyDiscount($money,$discount){ - $result = $money; + /** @noinspection PhpUnusedLocalVariableInspection */ + $result = $money; $valueOfDiscount = floor( $money * $discount->value / 100 ); $result = $money - $valueOfDiscount; return $result; diff --git a/common/models/Ticket.php b/common/models/Ticket.php index 8f9dd1e..02f4437 100644 --- a/common/models/Ticket.php +++ b/common/models/Ticket.php @@ -29,6 +29,7 @@ use common\components\Helper; * @property string $comment * @property string $created_at * @property string $updated_at + * @property int id_contract */ class Ticket extends \common\models\BaseFitnessActiveRecord { @@ -133,7 +134,8 @@ class Ticket extends \common\models\BaseFitnessActiveRecord public function getCardNumber(){ $result = ""; - $card = $this->card; + /** @noinspection PhpUndefinedFieldInspection */ + $card = $this->card; if ( isset($card)){ $result = $card->number; } @@ -146,7 +148,8 @@ class Ticket extends \common\models\BaseFitnessActiveRecord public function getCustomerName(){ $result = ""; - $customer = $this->customer; + /** @noinspection PhpUndefinedFieldInspection */ + $customer = $this->customer; if ( isset($customer)){ $result = $customer->name; } @@ -171,23 +174,28 @@ class Ticket extends \common\models\BaseFitnessActiveRecord } public function getAccountName() { $result = ""; - $account = $this->account; + /** @noinspection PhpUndefinedFieldInspection */ + /** @var \common\models\Account $account */ + $account = $this->account; if ( isset($account) ){ - $result = $this->account->name; + $result = $account->name; } return $result; } public function getDiscountName() { $result = ""; - $discount = $this->discount; + /** @noinspection PhpUndefinedFieldInspection */ + /** @var \common\models\Discount $discount */ + $discount = $this->discount; if ( isset($discount) ){ - $result = $this->discount->name; + $result = $discount->name; } return $result; } public function getTicketTypeName() { $result = ""; - $ticketType = $this->ticketType; + /** @noinspection PhpUndefinedFieldInspection */ + $ticketType = $this->ticketType; if ( isset($ticketType) ){ $result = $ticketType->name; } @@ -195,17 +203,20 @@ class Ticket extends \common\models\BaseFitnessActiveRecord } public function getUserName() { $result = ""; - $user = $this->user; + /** @noinspection PhpUndefinedFieldInspection */ + $user = $this->user; if ( isset($user) ){ $result = $user->username; } 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 readActive($card){ if ( $card == null ) @@ -224,9 +235,12 @@ class Ticket extends \common\models\BaseFitnessActiveRecord 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){ if ( $card == null ) @@ -326,7 +340,7 @@ class Ticket extends \common\models\BaseFitnessActiveRecord /** * Apply request * - * @var common\models\TicketInstallmentRequest $request megbízás + * @var \common\models\TicketInstallmentRequest $request megbízás * */ public function applyTicketInstallmentRequest( $request ) { //ha csoportos beszedéses diff --git a/common/models/Transfer.php b/common/models/Transfer.php index ecea9f7..6e8f619 100644 --- a/common/models/Transfer.php +++ b/common/models/Transfer.php @@ -14,6 +14,7 @@ use yii\db\Query; use yii\db\Expression; use common\components\RoleDefinition; use common\components\Helper; +use yii\web\NotAcceptableHttpException; /** * This is the model class for table "transfer". @@ -37,6 +38,8 @@ use common\components\Helper; * @property integer $direction * @property string $paid_at * @property integer $id_customer + * @property int|string paid_by + * @property int payment_method */ class Transfer extends \common\models\BaseFitnessActiveRecord { const TYPE_PRODUCT = 10; @@ -205,7 +208,8 @@ class Transfer extends \common\models\BaseFitnessActiveRecord { } public function getPaidByName() { $result = ""; - $user = $this->paidByUser; + /** @noinspection PhpUndefinedFieldInspection */ + $user = $this->paidByUser; if (isset ( $this->paidByUser )) { $result = $user->username; } @@ -215,17 +219,21 @@ class Transfer extends \common\models\BaseFitnessActiveRecord { public function getObjectName() { $result = ""; if ($this->type == Transfer::TYPE_TICKET) { - $result = $this->ticketName; + /** @noinspection PhpUndefinedFieldInspection */ + $result = $this->ticketName; } else if ($this->type == Transfer::TYPE_PRODUCT) { - $result = $this->productName; + /** @noinspection PhpUndefinedFieldInspection */ + $result = $this->productName; } else if ($this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) { - $result = $this->moneyMovement->humanType; + /** @noinspection PhpUndefinedFieldInspection */ + $result = $this->moneyMovement->humanType; } return $result; } public function getUserName() { $result = ""; - $user = $this->user; + /** @noinspection PhpUndefinedFieldInspection */ + $user = $this->user; if (isset ( $this->user )) { $result = $user->username; } @@ -234,7 +242,8 @@ class Transfer extends \common\models\BaseFitnessActiveRecord { } public function getProductName() { $result = ""; - $product = $this->product; + /** @noinspection PhpUndefinedFieldInspection */ + $product = $this->product; if (isset ( $product )) { $result = $product->name; } @@ -243,16 +252,20 @@ class Transfer extends \common\models\BaseFitnessActiveRecord { } public function getTicketName() { $result = ""; - $ticket = $this->ticket; + /** @noinspection PhpUndefinedFieldInspection */ + /** @var \common\models\Ticket $ticket */ + $ticket = $this->ticket; if (isset ( $ticket )) { - $result = $this->ticket->ticketTypeName; + /** @noinspection PhpUndefinedFieldInspection */ + $result = $this->ticket->ticketTypeName; } return $result; } public function getAccountName() { $result = ""; - $account = $this->account; + /** @noinspection PhpUndefinedFieldInspection */ + $account = $this->account; if (isset ( $account )) { $result = $account->name; } @@ -272,7 +285,8 @@ class Transfer extends \common\models\BaseFitnessActiveRecord { } public function getSaleName() { $result = ""; - $sale = $this->sale; + /** @noinspection PhpUndefinedFieldInspection */ + $sale = $this->sale; if (isset ( $sale )) { $result = $sale->name; } @@ -305,22 +319,27 @@ class Transfer extends \common\models\BaseFitnessActiveRecord { $s .= $this->count; $s .= " " . Yii::t ( 'frontend/transfer', 'pieces' ) . " "; - $s .= $this->product->name; + /** @noinspection PhpUndefinedFieldInspection */ + $s .= $this->product->name; $s .= " - "; - $s .= $this->account->name; + /** @noinspection PhpUndefinedFieldInspection */ + $s .= $this->account->name; return $s; } - - /** - * - * @param $account common\models\Account - * @param $discount common\models\Discount - * @param $currency common\models\Currency - * @param $product common\models\Product - * @param $customer common\models\Customer - * - */ + + /** + * + * @param $sale + * @param $account \common\models\Account + * @param $discount \common\models\Discount + * @param $currency \common\models\Currency + * @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) { $transfer = new Transfer (); @@ -333,8 +352,9 @@ class Transfer extends \common\models\BaseFitnessActiveRecord { $transfer->count = $count; $totalPrice = $totalPrice * $count; - - if (isset ( $discount )) { + + /** @var \common\models\Discount $discount */ + if (isset ( $discount )) { $transfer->id_discount = $discount->id_discount; $totalPrice = Discount::applyDiscount ( $totalPrice, $discount ); } @@ -357,15 +377,15 @@ class Transfer extends \common\models\BaseFitnessActiveRecord { return $transfer; } - - /** - * - * @param $account common\models\Account - * @param $discount common\models\Discount - * @param $currency common\models\Currency - * @param $moneyMovement common\models\MoneyMovement - * - */ + + /** + * + * @param $account \common\models\Account + * @param $moneyMovement \common\models\MoneyMovement + * @return Transfer + * @internal param Discount $discount + * @internal param Currency $currency + */ public static function createMoneyMovementOutTransfer($account, $moneyMovement) { $transfer = new Transfer (); $transfer->payment_method = Transfer::PAYMENT_METHOD_CASH; @@ -388,14 +408,18 @@ class Transfer extends \common\models\BaseFitnessActiveRecord { return $transfer; } - /** - * - * @param $account common\models\Account - * @param $discount common\models\Discount - * @param $currency common\models\Currency - * @param $ticket common\models\Ticket - * - */ + + /** + * + * @param $account \common\models\Account + * @param $discount \common\models\Discount + * @param $currency \common\models\Currency + * @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) { $transfer = new Transfer (); @@ -412,15 +436,17 @@ class Transfer extends \common\models\BaseFitnessActiveRecord { $totalPrice = $totalPrice * $count; if (isset ( $discount )) { + /** @var \common\models\Discount $discount */ $transfer->id_discount = $discount->id_discount; - $totalPrice = Discount::applyDiscount ( $totalPrice, $discount ); + $totalPrice = Discount::applyDiscount ( $totalPrice, $discount ); } $transfer->money = $totalPrice; if (isset ( $currency )) { $transfer->rate = $currency->rate; - $transfer->money_currency = Currency::applyCurrency ( $totalPrice, $currency ); + /** @var \common\models\Currency $currency */ + $transfer->money_currency = Currency::applyCurrency ( $totalPrice, $currency ); } $transfer->id_account = $account->id_account; @@ -464,6 +490,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord { } else if ($transfer->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) { return "Pénzmozgás"; } + return "-"; } ] ] ); @@ -490,8 +517,6 @@ class Transfer extends \common\models\BaseFitnessActiveRecord { return $result; } public static function readUserSoldTransfers($user) { - $transfers = [ ]; - $query = Transfer::find (); $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 ] ); } - $transfers = $query->all (); + return $query->all (); - return $transfers; } public static function readCustomerCart($customer) { $transfers = [ ]; @@ -573,16 +597,20 @@ class Transfer extends \common\models\BaseFitnessActiveRecord { public function beforeDelete() { parent::beforeDelete (); if ($this->type == Transfer::TYPE_TICKET) { - $ticket = $this->ticket; + /** @noinspection PhpUndefinedFieldInspection */ + $ticket = $this->ticket; if ($ticket != null) { $ticket->delete (); } } else if ($this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) { - $mm = $this->moneyMovement; + /** @noinspection PhpUndefinedFieldInspection */ + $mm = $this->moneyMovement; $mm->delete (); } else if ($this->type == Transfer::TYPE_PRODUCT) { - $sale = $this->sale; - $product = $this->product; + /** @noinspection PhpUndefinedFieldInspection */ + $sale = $this->sale; + /** @noinspection PhpUndefinedFieldInspection */ + $product = $this->product; $product->stock = $product->stock + $this->count; @@ -599,39 +627,45 @@ class Transfer extends \common\models\BaseFitnessActiveRecord { return true; } - - /** - * - * @param string $mode - * The mode to load - * Available modes - *
Load all transfer which were created
- *Load all transfer which were paid
- *Load all transfer which were created and paid
- *Load all transfer which were created but not paid
- *Load all transfer which were not created but paid . Works correctly only, - * when start and end date given - *
- *Load all transfer which were created
+ *Load all transfer which were paid
+ *Load all transfer which were created and paid
+ *Load all transfer which were created but not paid
+ *Load all transfer which were not created but paid . Works correctly only, + * when start and end date given + *
+ *