Add waste
This commit is contained in:
@@ -41,6 +41,7 @@ class Log extends BaseFitnessActiveRecord
|
||||
public static $TYPE_CREATE_CUSTOMER= 70;
|
||||
public static $TYPE_PROCUREMENT_UPDATE = 80;
|
||||
public static $TYPE_TICKET_COUNT_MOVE_OUT = 90;
|
||||
public static $TYPE_WASTE = 100;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
|
||||
@@ -275,7 +275,6 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
|
||||
$request->priority = $index;
|
||||
$date = \DateTime::createFromFormat("Y.m.d", $contract->started_at, new \DateTimeZone( 'UTC'));
|
||||
$date->modify("+$index month");
|
||||
// $date->modify("-1 day");
|
||||
$date->setTime(0, 0, 0);
|
||||
$request->request_target_time_at = $date->format ( 'Y-m-d H:i:s' );
|
||||
$request->request_processed_at = null;
|
||||
@@ -295,7 +294,6 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
|
||||
TicketInstallmentRequest::$STATUS_REJECTED=> 'Visszautasítva',
|
||||
TicketInstallmentRequest::$STATUS_ACCEPTED=> 'Sikeresen beszedés',
|
||||
TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL=> 'Személyesen fizetve',
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,6 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
const PAYMENT_METHOD_TRANSFER = 30; // ÁTUTALÁS
|
||||
const PAYMENT_METHOD_CAFETERY = 40; // SZÉCHENYI KÁRTYA
|
||||
// const PAYMENT_METHOD_DEBIT_MANDATE = 50;//CSOPORTOS BESZEDÉSI MEGBÍZÁS
|
||||
|
||||
const PAYMENT_METHOD_TRANSFER_LATER = 50;
|
||||
/**
|
||||
* @inheritdoc
|
||||
@@ -199,23 +198,20 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
"id_sale" => "id_object"
|
||||
] );
|
||||
}
|
||||
|
||||
public function getPaidByUser() {
|
||||
return $this->hasOne ( User::className (), [
|
||||
"id" => "paid_by"
|
||||
return $this->hasOne ( User::className (), [
|
||||
"id" => "paid_by"
|
||||
] );
|
||||
}
|
||||
|
||||
public function getPaidByName() {
|
||||
$result = "";
|
||||
$user = $this->paidByUser;
|
||||
if (isset ( $this->paidByUser )) {
|
||||
$result = $user->username;
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getObjectName() {
|
||||
$result = "";
|
||||
if ($this->type == Transfer::TYPE_TICKET) {
|
||||
@@ -431,9 +427,6 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
|
||||
return $transfer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function modelsToArray($transfers, $default = []) {
|
||||
if ($transfers == null) {
|
||||
return $default;
|
||||
@@ -489,10 +482,10 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
$transfers = [ ];
|
||||
|
||||
$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" );
|
||||
|
||||
// $query->innerJoinWith ( 'userSoldItem' );
|
||||
if ( Helper::isUserCartVisibilityUser()){
|
||||
// $query->innerJoinWith ( 'userSoldItem' );
|
||||
if (Helper::isUserCartVisibilityUser ()) {
|
||||
$query->andWhere ( [
|
||||
'user_sold_item.id_user' => $user->id
|
||||
] );
|
||||
@@ -527,24 +520,22 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
self::PAYMENT_METHOD_CASH => Yii::t ( 'common/transfer', 'Készpénz' ),
|
||||
self::PAYMENT_METHOD_BANCCARD => Yii::t ( 'common/transfer', 'Bankkártyás fizetés' ),
|
||||
self::PAYMENT_METHOD_TRANSFER => Yii::t ( 'common/transfer', 'Átutalás' ),
|
||||
self::PAYMENT_METHOD_CAFETERY => Yii::t ( 'common/transfer', 'Széchenyi kártya' ),
|
||||
self::PAYMENT_METHOD_CAFETERY => Yii::t ( 'common/transfer', 'Széchenyi kártya' ),
|
||||
self::PAYMENT_METHOD_TRANSFER_LATER => Yii::t ( 'common/transfer', 'Átutalás később' )
|
||||
]
|
||||
];
|
||||
// self::PAYMENT_METHOD_DEBIT_MANDATE => Yii::t('common/transfer','Csoportos beszedési megbízás'),
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public static function paymentMethodsForProduct() {
|
||||
return [
|
||||
self::PAYMENT_METHOD_CASH => Yii::t ( 'common/transfer', 'Készpénz' ),
|
||||
self::PAYMENT_METHOD_BANCCARD => Yii::t ( 'common/transfer', 'Bankkártyás fizetés' ),
|
||||
self::PAYMENT_METHOD_TRANSFER => Yii::t ( 'common/transfer', 'Átutalás' ),
|
||||
self::PAYMENT_METHOD_CAFETERY => Yii::t ( 'common/transfer', 'Széchenyi kártya' ),
|
||||
]
|
||||
self::PAYMENT_METHOD_CAFETERY => Yii::t ( 'common/transfer', 'Széchenyi kártya' )
|
||||
];
|
||||
// self::PAYMENT_METHOD_DEBIT_MANDATE => Yii::t('common/transfer','Csoportos beszedési megbízás'),
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public static function statuses() {
|
||||
return [
|
||||
self::STATUS_NOT_PAID => Yii::t ( 'common/transfer', 'Nincs fizetve' ),
|
||||
@@ -636,8 +627,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
$query->addSelect ( [
|
||||
new Expression ( 'transfer.id_account as account' ),
|
||||
new Expression ( ' COALESCE(sum( ( case when direction = ' . Transfer::DIRECTION_OUT . ' then -1 else 1 end )* transfer.money ),0) as money /** --' . $mode . '*/' )
|
||||
]
|
||||
);
|
||||
] );
|
||||
$query->from ( 'transfer' );
|
||||
|
||||
if (! RoleDefinition::isAdmin ()) {
|
||||
@@ -686,11 +676,11 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
self::notInInterval ( $query, 'transfer.created_at', $start, $end );
|
||||
}
|
||||
|
||||
// echo "start date is: ". $start;
|
||||
// echo "start date is: " . gettype( $start );
|
||||
// echo "start date is: ". $start;
|
||||
// echo "start date is: " . gettype( $start );
|
||||
|
||||
if ( !RoleDefinition::isAdmin() ){
|
||||
Helper::restrictIfNotAdminTheStartDate($query, $start);
|
||||
if (! RoleDefinition::isAdmin ()) {
|
||||
Helper::restrictIfNotAdminTheStartDate ( $query, $start );
|
||||
}
|
||||
|
||||
$query->groupBy ( 'transfer.id_account' );
|
||||
@@ -864,11 +854,11 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
* Ezt a függvényt használjuk a zárások összegének kiszámolására!
|
||||
* A számolás csak a következő feltételekkel bíró tranzakciókat
|
||||
* tartalmazza:
|
||||
* - trazakció típus: common\models\Account::TYPE_ALL
|
||||
* - tranzakció fizetési módja: készpénz
|
||||
* - tranzakció státusza: fizetve
|
||||
* -
|
||||
* */
|
||||
* - trazakció típus: common\models\Account::TYPE_ALL
|
||||
* - tranzakció fizetési módja: készpénz
|
||||
* - tranzakció státusza: fizetve
|
||||
* -
|
||||
*/
|
||||
public static function readPaid($start, $end, $idUser) {
|
||||
$query = (new \yii\db\Query ());
|
||||
$query->select ( [
|
||||
@@ -933,7 +923,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
|
||||
$ticket->save ( false );
|
||||
|
||||
if ( $ticket->part == 0 ){
|
||||
if ($ticket->part == 0) {
|
||||
TicketInstallmentRequest::updateAll ( [
|
||||
'status' => TicketInstallmentRequest::$STATUS_CANCELED
|
||||
], [
|
||||
@@ -941,9 +931,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
] );
|
||||
}
|
||||
|
||||
|
||||
// storno contract
|
||||
|
||||
// storno contract
|
||||
} else if ($this->type == Transfer::TYPE_PRODUCT) {
|
||||
$sale = $this->sale;
|
||||
$product = $this->sale->product;
|
||||
@@ -957,14 +945,16 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
$mm->save ( false );
|
||||
}
|
||||
|
||||
ShoppingCart::deleteAll(['id_transfer' => $this->id_transfer]);
|
||||
UserSoldItem::deleteAll(['id_transfer' => $this->id_transfer]);
|
||||
ShoppingCart::deleteAll ( [
|
||||
'id_transfer' => $this->id_transfer
|
||||
] );
|
||||
UserSoldItem::deleteAll ( [
|
||||
'id_transfer' => $this->id_transfer
|
||||
] );
|
||||
}
|
||||
|
||||
public function unstorono(){
|
||||
|
||||
public function unstorono() {
|
||||
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" );
|
||||
}
|
||||
|
||||
$this->status = Transfer::STATUS_NOT_PAID;
|
||||
@@ -977,21 +967,18 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
|
||||
$ticket->save ( false );
|
||||
|
||||
TicketInstallmentRequest::updateAll ( [
|
||||
'status' => TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL
|
||||
], [
|
||||
'id_ticket' => $ticket->id_ticket
|
||||
TicketInstallmentRequest::updateAll ( [
|
||||
'status' => TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL
|
||||
], [
|
||||
'id_ticket' => $ticket->id_ticket
|
||||
] );
|
||||
|
||||
|
||||
$item = new ShoppingCart();
|
||||
$item = new ShoppingCart ();
|
||||
$item->id_customer = $this->id_customer;
|
||||
$item->id_transfer = $this->id_transfer;
|
||||
$item->save(false);
|
||||
$item->save ( false );
|
||||
}
|
||||
|
||||
public function payout($id_account = null) {
|
||||
|
||||
if ($this->status != Transfer::STATUS_NOT_PAID) {
|
||||
return false;
|
||||
}
|
||||
@@ -1000,21 +987,22 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
$this->paid_at = Helper::getDateTimeString ();
|
||||
$this->paid_by = \Yii::$app->user->id;
|
||||
|
||||
if ( isset($id_account)){
|
||||
if (isset ( $id_account )) {
|
||||
$this->id_account = $id_account;
|
||||
}else{
|
||||
if( Helper::isUserCartVisibilityAll() ){
|
||||
$this->id_account = Account::readDefault();
|
||||
} else {
|
||||
if (Helper::isUserCartVisibilityAll ()) {
|
||||
$this->id_account = Account::readDefault ();
|
||||
}
|
||||
}
|
||||
|
||||
ShoppingCart::deleteAll ( [ 'id_transfer' => $this->id_transfer ] );
|
||||
UserSoldItem::deleteAll ( [ 'id_transfer' => $this->id_transfer
|
||||
ShoppingCart::deleteAll ( [
|
||||
'id_transfer' => $this->id_transfer
|
||||
] );
|
||||
return $this->save (false);
|
||||
UserSoldItem::deleteAll ( [
|
||||
'id_transfer' => $this->id_transfer
|
||||
] );
|
||||
return $this->save ( false );
|
||||
}
|
||||
|
||||
|
||||
public static function payoutAll($id_user, $id_array) {
|
||||
ShoppingCart::deleteAll ( [
|
||||
'in',
|
||||
@@ -1028,27 +1016,37 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
] );
|
||||
|
||||
$updateConfig = null;
|
||||
if ( Helper::isUserCartVisibilityUser() ){
|
||||
$updateConfig = [
|
||||
'status' => Transfer::STATUS_PAID,
|
||||
'paid_at' => Helper::getDateTimeString (),
|
||||
'paid_by' => $id_user
|
||||
if (Helper::isUserCartVisibilityUser ()) {
|
||||
$updateConfig = [
|
||||
'status' => Transfer::STATUS_PAID,
|
||||
'paid_at' => Helper::getDateTimeString (),
|
||||
'paid_by' => $id_user
|
||||
];
|
||||
}else{
|
||||
$updateConfig = [
|
||||
} else {
|
||||
$updateConfig = [
|
||||
'status' => Transfer::STATUS_PAID,
|
||||
'paid_at' => Helper::getDateTimeString (),
|
||||
'paid_by' => $id_user,
|
||||
'id_account' => Account::readDefault(),
|
||||
'id_account' => Account::readDefault ()
|
||||
];
|
||||
}
|
||||
|
||||
$updateConditions = [
|
||||
[ 'in','id_transfer', $id_array ],
|
||||
[ 'in', 'status', [ Transfer::STATUS_NOT_PAID ] ]
|
||||
[
|
||||
'in',
|
||||
'id_transfer',
|
||||
$id_array
|
||||
],
|
||||
[
|
||||
'in',
|
||||
'status',
|
||||
[
|
||||
Transfer::STATUS_NOT_PAID
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
Transfer::updateAll ( $updateConfig , $updateConditions );
|
||||
Transfer::updateAll ( $updateConfig, $updateConditions );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1072,10 +1070,10 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
$ticket->id_account = $account->id_account;
|
||||
$ticket->id_discount = null; // contract.id_discount
|
||||
$ticket->start = $request->request_target_time_at;
|
||||
$ticket->end = date( 'Y-m-d', strtotime( $request->request_target_time_at . " +1 month -1 day"));
|
||||
$ticket->end = date ( 'Y-m-d', strtotime ( $request->request_target_time_at . " +1 month -1 day" ) );
|
||||
$ticket->max_usage_count = $ticketType->max_usage_count;
|
||||
$ticket->usage_count = 0;
|
||||
$ticket->status = Ticket::STATUS_ACTIVE;
|
||||
$ticket->status = Ticket::STATUS_INACTIVE;
|
||||
$ticket->price_brutto = $request->money;
|
||||
$ticket->id_card = $card->id_card;
|
||||
$ticket->part = $request->priority;
|
||||
@@ -1103,31 +1101,30 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
||||
$transfer->comment = "Szerződéses bérlet létrehozás";
|
||||
$transfer->id_user = \Yii::$app->user->id;
|
||||
$transfer->id_customer = $customer->id_customer;
|
||||
$transfer->save (false);
|
||||
$transfer->save ( false );
|
||||
|
||||
|
||||
if ( $addToCustomerCart == true ){
|
||||
$cart = new ShoppingCart();
|
||||
if ($addToCustomerCart == true) {
|
||||
$cart = new ShoppingCart ();
|
||||
$cart->id_customer = $customer->id_customer;
|
||||
$cart->id_transfer = $transfer->id_transfer;
|
||||
$cart->save(false);
|
||||
$cart->save ( false );
|
||||
}
|
||||
|
||||
return [$transfer,$ticket];
|
||||
return [
|
||||
$transfer,
|
||||
$ticket
|
||||
];
|
||||
}
|
||||
|
||||
public static function canBeAddedToCart($payment_method) {
|
||||
if ( $payment_method == Transfer::PAYMENT_METHOD_TRANSFER_LATER){
|
||||
if ($payment_method == Transfer::PAYMENT_METHOD_TRANSFER_LATER) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function canMarkPaidByReception($payment_method) {
|
||||
if ( $payment_method == Transfer::PAYMENT_METHOD_TRANSFER_LATER){
|
||||
if ($payment_method == Transfer::PAYMENT_METHOD_TRANSFER_LATER) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
76
common/models/Waste.php
Normal file
76
common/models/Waste.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
|
||||
/**
|
||||
* This is the model class for table "waste".
|
||||
*
|
||||
* @property integer $id_waste
|
||||
* @property integer $count
|
||||
* @property integer $id_product
|
||||
* @property integer $stock_before
|
||||
* @property integer $stock_after
|
||||
* @property integer $id_user
|
||||
* @property string $comment
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*/
|
||||
class Waste extends \yii\db\ActiveRecord
|
||||
{
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'waste';
|
||||
}
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return ArrayHelper::merge( [
|
||||
[
|
||||
'class' => TimestampBehavior::className(),
|
||||
'value' => function(){ return date('Y-m-d H:i:s' ); }
|
||||
],
|
||||
], parent::behaviors());
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['count', 'id_product', ], 'integer'],
|
||||
[['comment'], 'string', 'max' => 255],
|
||||
[['productIdentifier'], 'string', 'max' => 128],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id_waste' => Yii::t('common/waste', 'Id Waste'),
|
||||
'count' => Yii::t('common/waste', 'Mennyiség'),
|
||||
'id_product' => Yii::t('common/waste', 'Termék'),
|
||||
'stock_before' => Yii::t('common/waste', 'Mennyiség előtte'),
|
||||
'stock_after' => Yii::t('common/waste', 'Mennyiség utána'),
|
||||
'id_user' => Yii::t('common/waste', 'Felhasználó'),
|
||||
'comment' => Yii::t('common/waste', 'Megjegyzés'),
|
||||
'created_at' => Yii::t('common/waste', 'Létrehozva'),
|
||||
'updated_at' => Yii::t('common/waste', 'Updated At'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user