Add waste
This commit is contained in:
parent
a6fdfb1c83
commit
f8e1f90a8e
31
backend/assets/WasteCreateAsset.php
Normal file
31
backend/assets/WasteCreateAsset.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @link http://www.yiiframework.com/
|
||||||
|
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||||
|
* @license http://www.yiiframework.com/license/
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace backend\assets;
|
||||||
|
|
||||||
|
use yii\web\AssetBundle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||||
|
* @since 2.0
|
||||||
|
*/
|
||||||
|
class WasteCreateAsset extends AssetBundle
|
||||||
|
{
|
||||||
|
public $basePath = '@webroot';
|
||||||
|
public $baseUrl = '@web';
|
||||||
|
public $css = [
|
||||||
|
];
|
||||||
|
public $js = [
|
||||||
|
'js/app.js',
|
||||||
|
'js/waste.create.js',
|
||||||
|
];
|
||||||
|
public $depends = [
|
||||||
|
'backend\assets\AppAsset',
|
||||||
|
'yii\jui\JuiAsset',
|
||||||
|
'common\assets\TypeAheadAsset',
|
||||||
|
];
|
||||||
|
}
|
||||||
@ -91,6 +91,7 @@ class AdminMenuStructure{
|
|||||||
$items = [];
|
$items = [];
|
||||||
$items[] = ['label' => 'Termékek', 'url' => ['/product/index'] ];
|
$items[] = ['label' => 'Termékek', 'url' => ['/product/index'] ];
|
||||||
$items[] = ['label' => 'Beszerzések', 'url' => ['/procurement/index'] ];
|
$items[] = ['label' => 'Beszerzések', 'url' => ['/procurement/index'] ];
|
||||||
|
$items[] = ['label' => 'Selejt', 'url' => ['/waste/index' ,'WasteSearch[date_start]' =>$today,'WasteSearch[date_end]' => $tomorrow ] ];
|
||||||
$items[] = ['label' => 'Leltár csoport', 'url' => ['/inventory-group/index'] ];
|
$items[] = ['label' => 'Leltár csoport', 'url' => ['/inventory-group/index'] ];
|
||||||
$items[] = ['label' => 'Leltár', 'url' => ['/inventory/index'] ];
|
$items[] = ['label' => 'Leltár', 'url' => ['/inventory/index'] ];
|
||||||
$items[] = ['label' => 'Részletes eladások', 'url' => ['/transfer/sale' ,'TransferSaleSearch[start]' =>$todayDatetime,'TransferSaleSearch[end]' => $tomorrowDatetime ] ];
|
$items[] = ['label' => 'Részletes eladások', 'url' => ['/transfer/sale' ,'TransferSaleSearch[start]' =>$todayDatetime,'TransferSaleSearch[end]' => $tomorrowDatetime ] ];
|
||||||
@ -98,6 +99,7 @@ class AdminMenuStructure{
|
|||||||
$this->menuItems[] = ['label' => 'Termékek', 'url' => $this->emptyUrl,
|
$this->menuItems[] = ['label' => 'Termékek', 'url' => $this->emptyUrl,
|
||||||
'items' => $items
|
'items' => $items
|
||||||
];
|
];
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// Pénzügy
|
// Pénzügy
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
|
|||||||
135
backend/controllers/WasteController.php
Normal file
135
backend/controllers/WasteController.php
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\controllers;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use common\models\Waste;
|
||||||
|
use backend\models\WasteSearch;
|
||||||
|
use yii\web\Controller;
|
||||||
|
use yii\web\NotFoundHttpException;
|
||||||
|
use yii\filters\VerbFilter;
|
||||||
|
use common\models\Product;
|
||||||
|
use backend\models\WasteCreateForm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WasteController implements the CRUD actions for Waste model.
|
||||||
|
*/
|
||||||
|
class WasteController extends Controller {
|
||||||
|
public function behaviors() {
|
||||||
|
return [
|
||||||
|
'verbs' => [
|
||||||
|
'class' => VerbFilter::className (),
|
||||||
|
'actions' => [
|
||||||
|
'delete' => [
|
||||||
|
'post'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists all Waste models.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionIndex() {
|
||||||
|
$searchModel = new WasteSearch ();
|
||||||
|
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
|
||||||
|
|
||||||
|
return $this->render ( 'index', [
|
||||||
|
'searchModel' => $searchModel,
|
||||||
|
'dataProvider' => $dataProvider
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a single Waste model.
|
||||||
|
*
|
||||||
|
* @param integer $id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionView($id) {
|
||||||
|
return $this->render ( 'view', [
|
||||||
|
'model' => $this->findModel ( $id )
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Waste model.
|
||||||
|
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionCreate() {
|
||||||
|
$model = new WasteCreateForm ();
|
||||||
|
|
||||||
|
$products = Product::find ()->all ();
|
||||||
|
$products = Product::modelToMapIdNameLong ( $products );
|
||||||
|
|
||||||
|
if ($model->load ( Yii::$app->request->post () ) && $model->validate ()) {
|
||||||
|
|
||||||
|
$model->save ( );
|
||||||
|
return $this->redirect ( [
|
||||||
|
'index'
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
return $this->render ( 'create', [
|
||||||
|
'model' => $model,
|
||||||
|
'products' => $products
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates an existing Waste 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_waste
|
||||||
|
] );
|
||||||
|
} else {
|
||||||
|
return $this->render ( 'update', [
|
||||||
|
'model' => $model
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes an existing Waste model.
|
||||||
|
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||||
|
*
|
||||||
|
* @param integer $id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionDelete($id) {
|
||||||
|
$this->findModel ( $id )->delete ();
|
||||||
|
|
||||||
|
return $this->redirect ( [
|
||||||
|
'index'
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the Waste model based on its primary key value.
|
||||||
|
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||||
|
*
|
||||||
|
* @param integer $id
|
||||||
|
* @return Waste the loaded model
|
||||||
|
* @throws NotFoundHttpException if the model cannot be found
|
||||||
|
*/
|
||||||
|
protected function findModel($id) {
|
||||||
|
if (($model = Waste::findOne ( $id )) !== null) {
|
||||||
|
return $model;
|
||||||
|
} else {
|
||||||
|
throw new NotFoundHttpException ( 'The requested page does not exist.' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
102
backend/models/WasteCreateForm.php
Normal file
102
backend/models/WasteCreateForm.php
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\models;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use yii\base\Model;
|
||||||
|
use yii\web\UploadedFile;
|
||||||
|
use common\models\Product;
|
||||||
|
use common\models\Waste;
|
||||||
|
use yii\web\HttpException;
|
||||||
|
use common\models\Log;
|
||||||
|
use common\components\Helper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ContactForm is the model behind the contact form.
|
||||||
|
* @property \Yii\web\UploadedFile $file
|
||||||
|
*/
|
||||||
|
class WasteCreateForm extends Model{
|
||||||
|
|
||||||
|
|
||||||
|
public $productIdentifier;
|
||||||
|
public $id_product;
|
||||||
|
public $comment;
|
||||||
|
public $count;
|
||||||
|
|
||||||
|
private $_product;
|
||||||
|
|
||||||
|
public function rules(){
|
||||||
|
return [
|
||||||
|
[['count', 'id_product', ], 'integer'],
|
||||||
|
[['count', ], 'required'],
|
||||||
|
[['comment'], 'string', 'max' => 255],
|
||||||
|
[['productIdentifier'], 'string', 'max' => 128],
|
||||||
|
[['id_product'] ,'validateProduct','skipOnEmpty' => false, 'skipOnError' => false]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validateProduct($attribute,$params){
|
||||||
|
$this->_product = null;
|
||||||
|
|
||||||
|
|
||||||
|
if ( isset($this->productIdentifier)){
|
||||||
|
$this->_product = Product::findOne($this->id_product);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $this->_product == null ){
|
||||||
|
$this->addError('productIdentifier' , Yii::t("common/procurement", "Invalid product"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function attributeLabels( ) {
|
||||||
|
return [
|
||||||
|
'count' => "Mennyiség",
|
||||||
|
'comment' => "Megjegyzés"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save(){
|
||||||
|
|
||||||
|
$connection = \Yii::$app->db;
|
||||||
|
|
||||||
|
$transaction = $connection->beginTransaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
$model = new Waste();
|
||||||
|
$model->id_product = $this->id_product;
|
||||||
|
$model->count = $this->count;
|
||||||
|
$model->stock_before = $this->_product->stock;
|
||||||
|
$model->stock_after = $this->_product->stock - $this->count;
|
||||||
|
$model->id_user = \Yii::$app->user->id;
|
||||||
|
$model->comment = $this->comment;
|
||||||
|
|
||||||
|
if ( !$model->save(false)){
|
||||||
|
throw new HttpException("Nem sikerült menteni a selejtet");
|
||||||
|
}
|
||||||
|
|
||||||
|
$product = $this->_product;
|
||||||
|
$product->stock = $product->stock - $this->count;
|
||||||
|
|
||||||
|
if ( !$product->save(false) ){
|
||||||
|
throw new HttpException("Nem sikerült menteni a terméket");
|
||||||
|
}
|
||||||
|
|
||||||
|
Log::log([
|
||||||
|
'type' =>Log::$TYPE_WASTE,
|
||||||
|
'message' => "Selejt létrehozva. Termék:".$product->name ." Mennyiség: ". $this->count ,
|
||||||
|
'id_product' => $product->id_product
|
||||||
|
]);
|
||||||
|
|
||||||
|
$transaction->commit();
|
||||||
|
|
||||||
|
Helper::flash('success', Yii::t('backend/procurement', 'Selejtezés mentve'));
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$transaction->rollback();
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
117
backend/models/WasteSearch.php
Normal file
117
backend/models/WasteSearch.php
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\models;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use yii\base\Model;
|
||||||
|
use yii\data\ActiveDataProvider;
|
||||||
|
use common\models\Waste;
|
||||||
|
use yii\db\Query;
|
||||||
|
use common\components\Helper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WasteSearch represents the model behind the search form about `common\models\Waste`.
|
||||||
|
*/
|
||||||
|
class WasteSearch extends Waste
|
||||||
|
{
|
||||||
|
|
||||||
|
public $date_start;
|
||||||
|
public $date_end;
|
||||||
|
|
||||||
|
public $timestampStart;
|
||||||
|
public $timestampEnd;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['id_waste', 'count', 'id_product', 'stock_before', 'stock_after', 'id_user'], 'integer'],
|
||||||
|
[['comment', 'created_at', 'updated_at'], 'safe'],
|
||||||
|
[[ 'date_start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||||
|
[[ 'date_end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 = Waste::find();
|
||||||
|
|
||||||
|
$query = new Query();
|
||||||
|
$query->select([
|
||||||
|
"p.name as product_name",
|
||||||
|
'w.count as waste_count',
|
||||||
|
'w.created_at as waste_created_at',
|
||||||
|
'w.comment as waste_comment',
|
||||||
|
'w.stock_before as waste_stock_before',
|
||||||
|
'w.stock_after as waste_stock_after',
|
||||||
|
'u.username as user_username',
|
||||||
|
]);
|
||||||
|
$query->from("waste as w");
|
||||||
|
$query->innerJoin("product as p","p.id_product = w.id_product");
|
||||||
|
$query->innerJoin("user as u","u.id = w.id_user");
|
||||||
|
|
||||||
|
$dataProvider = new ActiveDataProvider([
|
||||||
|
'query' => $query,
|
||||||
|
'sort' =>[
|
||||||
|
'defaultOrder' => [
|
||||||
|
'waste_created_at' => SORT_DESC
|
||||||
|
],
|
||||||
|
'attributes' => Helper::mkYiiSortItems([
|
||||||
|
['product_name'],
|
||||||
|
['waste_count'],
|
||||||
|
['waste_created_at'],
|
||||||
|
['waste_comment'],
|
||||||
|
['waste_stock_before'],
|
||||||
|
['waste_stock_after'],
|
||||||
|
['user_username'],
|
||||||
|
|
||||||
|
])
|
||||||
|
]]);
|
||||||
|
|
||||||
|
$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([
|
||||||
|
'w.id_user' => $this->id_user,
|
||||||
|
'w.id_product' => $this->id_product,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ( empty($this->date_start) ){
|
||||||
|
$this->timestampStart = '';
|
||||||
|
}
|
||||||
|
if ( empty($this->date_end) ){
|
||||||
|
$this->timestampEnd = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$query->andFilterWhere([ '>=', 'w.created_at', $this->timestampStart ] );
|
||||||
|
$query->andFilterWhere([ '<', 'w.created_at', $this->timestampEnd ] );
|
||||||
|
|
||||||
|
$query->andFilterWhere(['like', 'w.comment', $this->comment]);
|
||||||
|
|
||||||
|
return $dataProvider;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -54,7 +54,7 @@ $warehouses = mkOptions( ArrayHelper::map( $warehouses ,'id_warehouse','name')
|
|||||||
'autoclose'=>true,
|
'autoclose'=>true,
|
||||||
'format' => 'yyyy.mm.dd'
|
'format' => 'yyyy.mm.dd'
|
||||||
]
|
]
|
||||||
]) ?>
|
])->label("Időintervallum kezdete") ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<?= $form->field($model, 'date_end') ->widget(DatePicker::classname(), [
|
<?= $form->field($model, 'date_end') ->widget(DatePicker::classname(), [
|
||||||
@ -62,7 +62,7 @@ $warehouses = mkOptions( ArrayHelper::map( $warehouses ,'id_warehouse','name')
|
|||||||
'autoclose'=>true,
|
'autoclose'=>true,
|
||||||
'format' => 'yyyy.mm.dd'
|
'format' => 'yyyy.mm.dd'
|
||||||
]
|
]
|
||||||
]) ?>
|
])->label("Időintervallum vége") ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
30
backend/views/waste/_form.php
Normal file
30
backend/views/waste/_form.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model common\models\Waste */
|
||||||
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="waste-form">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin(); ?>
|
||||||
|
|
||||||
|
|
||||||
|
<?= $form->field($model, 'productIdentifier')->textInput(['autocomplete' => 'off'])->label('Írja be a termék nevét') ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'id_product')->hiddenInput()->label(false) ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'count')->textInput() ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'comment')->textInput(['maxlength' => true]) ?>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton( Yii::t('common/waste', 'Létrehoz') , ['class' => 'btn btn-success' ]) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
69
backend/views/waste/_search.php
Normal file
69
backend/views/waste/_search.php
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
use common\models\Product;
|
||||||
|
use common\models\User;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
|
use kartik\widgets\DatePicker;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\models\WasteSearch */
|
||||||
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
function mkOptions($options){
|
||||||
|
// $o = $options;
|
||||||
|
|
||||||
|
$all = ['' => Yii::t('common/product','All' ) ];
|
||||||
|
|
||||||
|
$o = $all + $options;
|
||||||
|
|
||||||
|
return $o;
|
||||||
|
}
|
||||||
|
|
||||||
|
$products = mkOptions( ArrayHelper::map( Product::find()->all() ,'id_product','name') );
|
||||||
|
$users = mkOptions( ArrayHelper::map( User::find()->all() ,'id','username') );
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="waste-search">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin([
|
||||||
|
'action' => ['index'],
|
||||||
|
'method' => 'get',
|
||||||
|
]); ?>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'id_user')->dropDownList($users) ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'id_product')->dropDownList($products) ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'date_start')->widget(DatePicker::classname(), [
|
||||||
|
'pluginOptions' => [
|
||||||
|
'autoclose'=>true,
|
||||||
|
'format' => 'yyyy.mm.dd'
|
||||||
|
]
|
||||||
|
])->label("Időintervallum kezdete") ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'date_end') ->widget(DatePicker::classname(), [
|
||||||
|
'pluginOptions' => [
|
||||||
|
'autoclose'=>true,
|
||||||
|
'format' => 'yyyy.mm.dd'
|
||||||
|
]
|
||||||
|
]) ->label("Időintervallum vége") ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton(Yii::t('common/waste', 'Keresés'), ['class' => 'btn btn-primary']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
51
backend/views/waste/create.php
Normal file
51
backend/views/waste/create.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use backend\assets\WasteCreateAsset;
|
||||||
|
use yii\helpers\Url;
|
||||||
|
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model common\models\Waste */
|
||||||
|
|
||||||
|
$this->title = Yii::t('common/waste', 'Új selejt');
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/waste', 'Selejtek'), 'url' => ['index']];
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
|
||||||
|
WasteCreateAsset::register($this);
|
||||||
|
|
||||||
|
$options = [];
|
||||||
|
$options['products'] = $products;
|
||||||
|
$options['url_product_find'] = Url::toRoute(['product/find']);
|
||||||
|
|
||||||
|
$this->registerJs(' new WasteCreate( '. json_encode($options) .' );');
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div class="waste-create">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<tr>
|
||||||
|
<th>Terméknév</th>
|
||||||
|
<td class="product-name"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Mennyiség</th>
|
||||||
|
<td class="product-stock"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Termék kategória</th>
|
||||||
|
<td class="product-category"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?= $this->render('_form', [
|
||||||
|
'model' => $model,
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
51
backend/views/waste/index.php
Normal file
51
backend/views/waste/index.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\grid\GridView;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $searchModel backend\models\WasteSearch */
|
||||||
|
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||||
|
|
||||||
|
$this->title = Yii::t('common/waste', 'Selejtek');
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="waste-index">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?= Html::a(Yii::t('common/waste', 'Új selejt'), ['create'], ['class' => 'btn btn-success']) ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?= GridView::widget([
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
'columns' => [
|
||||||
|
|
||||||
|
[
|
||||||
|
'attribute' => "waste_created_at",
|
||||||
|
'label' => "Létrehozva"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => "user_username",
|
||||||
|
'label' => "Felhasználó"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => "product_name",
|
||||||
|
'label' => "Termék"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => "waste_count",
|
||||||
|
'label' => "Mennyiség"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => "waste_comment",
|
||||||
|
'label' => "Megjegyzés"
|
||||||
|
],
|
||||||
|
|
||||||
|
// ['class' => 'yii\grid\ActionColumn'],
|
||||||
|
],
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
23
backend/views/waste/update.php
Normal file
23
backend/views/waste/update.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model common\models\Waste */
|
||||||
|
|
||||||
|
$this->title = Yii::t('common/waste', 'Update {modelClass}: ', [
|
||||||
|
'modelClass' => 'Waste',
|
||||||
|
]) . ' ' . $model->id_waste;
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/waste', 'Wastes'), 'url' => ['index']];
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => $model->id_waste, 'url' => ['view', 'id' => $model->id_waste]];
|
||||||
|
$this->params['breadcrumbs'][] = Yii::t('common/waste', 'Update');
|
||||||
|
?>
|
||||||
|
<div class="waste-update">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<?= $this->render('_form', [
|
||||||
|
'model' => $model,
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
43
backend/views/waste/view.php
Normal file
43
backend/views/waste/view.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\DetailView;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model common\models\Waste */
|
||||||
|
|
||||||
|
$this->title = $model->id_waste;
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/waste', 'Wastes'), 'url' => ['index']];
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="waste-view">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?= Html::a(Yii::t('common/waste', 'Update'), ['update', 'id' => $model->id_waste], ['class' => 'btn btn-primary']) ?>
|
||||||
|
<?= Html::a(Yii::t('common/waste', 'Delete'), ['delete', 'id' => $model->id_waste], [
|
||||||
|
'class' => 'btn btn-danger',
|
||||||
|
'data' => [
|
||||||
|
'confirm' => Yii::t('common/waste', 'Are you sure you want to delete this item?'),
|
||||||
|
'method' => 'post',
|
||||||
|
],
|
||||||
|
]) ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?= DetailView::widget([
|
||||||
|
'model' => $model,
|
||||||
|
'attributes' => [
|
||||||
|
'id_waste',
|
||||||
|
'count',
|
||||||
|
'id_product',
|
||||||
|
'stock_before',
|
||||||
|
'stock_after',
|
||||||
|
'id_user',
|
||||||
|
'comment',
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
],
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
114
backend/web/js/waste.create.js
Normal file
114
backend/web/js/waste.create.js
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
|
||||||
|
|
||||||
|
function WasteCreate(o){
|
||||||
|
|
||||||
|
|
||||||
|
var defaults = {
|
||||||
|
'selector_product' : '#wastecreateform-productidentifier',
|
||||||
|
'url_product_find' : 'product/find',
|
||||||
|
"products" : []
|
||||||
|
};
|
||||||
|
|
||||||
|
var product = null;
|
||||||
|
|
||||||
|
init();
|
||||||
|
|
||||||
|
function init(){
|
||||||
|
defaults = $.extend(defaults,o);
|
||||||
|
addPreventEnterToProduct();
|
||||||
|
initAutocomplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function addPreventEnterToProduct(){
|
||||||
|
doPreventSubmit($(defaults.selector_product));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function initAutocomplete(){
|
||||||
|
// var colors = ["red", "blue", "green", "yellow", "brown", "black"];
|
||||||
|
// $('#product_search').typeahead( {source: colors } );
|
||||||
|
|
||||||
|
var $input = $(defaults.selector_product);
|
||||||
|
console.info("len:" + $input.length);
|
||||||
|
console.info('products: ' + defaults.products.length);
|
||||||
|
$input.typeahead({source : defaults.products,
|
||||||
|
autoSelect: true,
|
||||||
|
items: 20,
|
||||||
|
minLength: 3,
|
||||||
|
// displayText: function (item){
|
||||||
|
// return item.text;
|
||||||
|
// }
|
||||||
|
|
||||||
|
});
|
||||||
|
$input.change(function() {
|
||||||
|
var current = $input.typeahead("getActive");
|
||||||
|
$("#filter_text").val('');
|
||||||
|
if (current) {
|
||||||
|
// Some item from your model is active!
|
||||||
|
if (current.name == $input.val()) {
|
||||||
|
// This means the exact match is found. Use toLowerCase() if you want case insensitive match.
|
||||||
|
// console.info(current);
|
||||||
|
_findProduct(current.id_product);
|
||||||
|
} else {
|
||||||
|
// This means it is only a partial match, you can either add a new item
|
||||||
|
// or take the active if you don't want new items
|
||||||
|
// console.info('partial');
|
||||||
|
product = null;
|
||||||
|
updateTableProduct();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Nothing is active so it is a new value (or maybe empty value)
|
||||||
|
// console.info('incactive');
|
||||||
|
product = null;
|
||||||
|
updateTableProduct();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _findProduct(id){
|
||||||
|
var data, url;
|
||||||
|
|
||||||
|
url = defaults.url_product_find;
|
||||||
|
data = {
|
||||||
|
'id' : id,
|
||||||
|
};
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
dataType: "json",
|
||||||
|
url: url,
|
||||||
|
data: data,
|
||||||
|
success: onFindProductReady
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearTableProduct(){
|
||||||
|
$('.product-name').html('');
|
||||||
|
$('.product-stock').html('');
|
||||||
|
$('.product-category').html('');
|
||||||
|
$('#wastecreateform-id_product').val('');
|
||||||
|
}
|
||||||
|
|
||||||
|
function fillTableProduct(){
|
||||||
|
$('.product-name').html(product.name);
|
||||||
|
$('.product-stock').html(product.stock);
|
||||||
|
$('.product-category').html(product.category);
|
||||||
|
$('#wastecreateform-id_product').val(product.id_product);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateTableProduct(){
|
||||||
|
clearTableProduct();
|
||||||
|
fillTableProduct();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function onFindProductReady(json){
|
||||||
|
product = json.product;
|
||||||
|
fillTableProduct();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,3 +1,6 @@
|
|||||||
|
-0.0.69
|
||||||
|
- add waste
|
||||||
|
- add default inactive on ticket sale
|
||||||
-0.0.68
|
-0.0.68
|
||||||
- add multi detsta upload
|
- add multi detsta upload
|
||||||
- add doorlog console changes
|
- add doorlog console changes
|
||||||
|
|||||||
@ -7,6 +7,7 @@ use common\models\Account;
|
|||||||
use yii\base\Exception;
|
use yii\base\Exception;
|
||||||
use common\models\ShoppingCart;
|
use common\models\ShoppingCart;
|
||||||
use common\models\UserSoldItem;
|
use common\models\UserSoldItem;
|
||||||
|
use common\models\Ticket;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -104,6 +105,16 @@ class TransferPayout extends \yii\base\Object{
|
|||||||
throw new Exception("Tranzakció fizetése sikertelen volt!");
|
throw new Exception("Tranzakció fizetése sikertelen volt!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $transfer->type == Transfer::TYPE_TICKET){
|
||||||
|
$ticket = $transfer->ticket;
|
||||||
|
$ticket->status = Ticket::STATUS_ACTIVE;
|
||||||
|
|
||||||
|
if ( $ticket->save(false) == false ){
|
||||||
|
\Yii::error("Tranzakció kifizetése sikertelen volt: ");
|
||||||
|
throw new Exception("Tranzakció fizetése sikertelen volt!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
ShoppingCart::deleteAll( ['id_transfer' => $transfer->id_transfer] );
|
ShoppingCart::deleteAll( ['id_transfer' => $transfer->id_transfer] );
|
||||||
UserSoldItem::deleteAll( ['id_transfer' => $transfer->id_transfer] );
|
UserSoldItem::deleteAll( ['id_transfer' => $transfer->id_transfer] );
|
||||||
|
|||||||
@ -4,7 +4,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.68',
|
'version' => 'v0.0.69',
|
||||||
'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
|
||||||
|
|||||||
@ -41,6 +41,7 @@ class Log extends BaseFitnessActiveRecord
|
|||||||
public static $TYPE_CREATE_CUSTOMER= 70;
|
public static $TYPE_CREATE_CUSTOMER= 70;
|
||||||
public static $TYPE_PROCUREMENT_UPDATE = 80;
|
public static $TYPE_PROCUREMENT_UPDATE = 80;
|
||||||
public static $TYPE_TICKET_COUNT_MOVE_OUT = 90;
|
public static $TYPE_TICKET_COUNT_MOVE_OUT = 90;
|
||||||
|
public static $TYPE_WASTE = 100;
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -275,7 +275,6 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
|
|||||||
$request->priority = $index;
|
$request->priority = $index;
|
||||||
$date = \DateTime::createFromFormat("Y.m.d", $contract->started_at, new \DateTimeZone( 'UTC'));
|
$date = \DateTime::createFromFormat("Y.m.d", $contract->started_at, new \DateTimeZone( 'UTC'));
|
||||||
$date->modify("+$index month");
|
$date->modify("+$index month");
|
||||||
// $date->modify("-1 day");
|
|
||||||
$date->setTime(0, 0, 0);
|
$date->setTime(0, 0, 0);
|
||||||
$request->request_target_time_at = $date->format ( 'Y-m-d H:i:s' );
|
$request->request_target_time_at = $date->format ( 'Y-m-d H:i:s' );
|
||||||
$request->request_processed_at = null;
|
$request->request_processed_at = null;
|
||||||
@ -295,7 +294,6 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
|
|||||||
TicketInstallmentRequest::$STATUS_REJECTED=> 'Visszautasítva',
|
TicketInstallmentRequest::$STATUS_REJECTED=> 'Visszautasítva',
|
||||||
TicketInstallmentRequest::$STATUS_ACCEPTED=> 'Sikeresen beszedés',
|
TicketInstallmentRequest::$STATUS_ACCEPTED=> 'Sikeresen beszedés',
|
||||||
TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL=> 'Személyesen fizetve',
|
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_TRANSFER = 30; // ÁTUTALÁS
|
||||||
const PAYMENT_METHOD_CAFETERY = 40; // SZÉCHENYI KÁRTYA
|
const PAYMENT_METHOD_CAFETERY = 40; // SZÉCHENYI KÁRTYA
|
||||||
// const PAYMENT_METHOD_DEBIT_MANDATE = 50;//CSOPORTOS BESZEDÉSI MEGBÍZÁS
|
// const PAYMENT_METHOD_DEBIT_MANDATE = 50;//CSOPORTOS BESZEDÉSI MEGBÍZÁS
|
||||||
|
|
||||||
const PAYMENT_METHOD_TRANSFER_LATER = 50;
|
const PAYMENT_METHOD_TRANSFER_LATER = 50;
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
@ -199,13 +198,11 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
"id_sale" => "id_object"
|
"id_sale" => "id_object"
|
||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPaidByUser() {
|
public function getPaidByUser() {
|
||||||
return $this->hasOne ( User::className (), [
|
return $this->hasOne ( User::className (), [
|
||||||
"id" => "paid_by"
|
"id" => "paid_by"
|
||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPaidByName() {
|
public function getPaidByName() {
|
||||||
$result = "";
|
$result = "";
|
||||||
$user = $this->paidByUser;
|
$user = $this->paidByUser;
|
||||||
@ -215,7 +212,6 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getObjectName() {
|
public function getObjectName() {
|
||||||
$result = "";
|
$result = "";
|
||||||
if ($this->type == Transfer::TYPE_TICKET) {
|
if ($this->type == Transfer::TYPE_TICKET) {
|
||||||
@ -431,9 +427,6 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
|
|
||||||
return $transfer;
|
return $transfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function modelsToArray($transfers, $default = []) {
|
public static function modelsToArray($transfers, $default = []) {
|
||||||
if ($transfers == null) {
|
if ($transfers == null) {
|
||||||
return $default;
|
return $default;
|
||||||
@ -529,22 +522,20 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
self::PAYMENT_METHOD_TRANSFER => Yii::t ( 'common/transfer', 'Átutalá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_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'),
|
// self::PAYMENT_METHOD_DEBIT_MANDATE => Yii::t('common/transfer','Csoportos beszedési megbízás'),
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
public static function paymentMethodsForProduct() {
|
public static function paymentMethodsForProduct() {
|
||||||
return [
|
return [
|
||||||
self::PAYMENT_METHOD_CASH => Yii::t ( 'common/transfer', 'Készpénz' ),
|
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_BANCCARD => Yii::t ( 'common/transfer', 'Bankkártyás fizetés' ),
|
||||||
self::PAYMENT_METHOD_TRANSFER => Yii::t ( 'common/transfer', 'Átutalá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'),
|
// self::PAYMENT_METHOD_DEBIT_MANDATE => Yii::t('common/transfer','Csoportos beszedési megbízás'),
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
public static function statuses() {
|
public static function statuses() {
|
||||||
return [
|
return [
|
||||||
self::STATUS_NOT_PAID => Yii::t ( 'common/transfer', 'Nincs fizetve' ),
|
self::STATUS_NOT_PAID => Yii::t ( 'common/transfer', 'Nincs fizetve' ),
|
||||||
@ -636,8 +627,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
$query->addSelect ( [
|
$query->addSelect ( [
|
||||||
new Expression ( 'transfer.id_account as account' ),
|
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 . '*/' )
|
new Expression ( ' COALESCE(sum( ( case when direction = ' . Transfer::DIRECTION_OUT . ' then -1 else 1 end )* transfer.money ),0) as money /** --' . $mode . '*/' )
|
||||||
]
|
] );
|
||||||
);
|
|
||||||
$query->from ( 'transfer' );
|
$query->from ( 'transfer' );
|
||||||
|
|
||||||
if (! RoleDefinition::isAdmin ()) {
|
if (! RoleDefinition::isAdmin ()) {
|
||||||
@ -868,7 +858,7 @@ 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
|
||||||
* -
|
* -
|
||||||
* */
|
*/
|
||||||
public static function readPaid($start, $end, $idUser) {
|
public static function readPaid($start, $end, $idUser) {
|
||||||
$query = (new \yii\db\Query ());
|
$query = (new \yii\db\Query ());
|
||||||
$query->select ( [
|
$query->select ( [
|
||||||
@ -941,9 +931,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// storno contract
|
// storno contract
|
||||||
|
|
||||||
} else if ($this->type == Transfer::TYPE_PRODUCT) {
|
} else if ($this->type == Transfer::TYPE_PRODUCT) {
|
||||||
$sale = $this->sale;
|
$sale = $this->sale;
|
||||||
$product = $this->sale->product;
|
$product = $this->sale->product;
|
||||||
@ -957,12 +945,14 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
$mm->save ( false );
|
$mm->save ( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
ShoppingCart::deleteAll(['id_transfer' => $this->id_transfer]);
|
ShoppingCart::deleteAll ( [
|
||||||
UserSoldItem::deleteAll(['id_transfer' => $this->id_transfer]);
|
'id_transfer' => $this->id_transfer
|
||||||
|
] );
|
||||||
|
UserSoldItem::deleteAll ( [
|
||||||
|
'id_transfer' => $this->id_transfer
|
||||||
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
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" );
|
||||||
}
|
}
|
||||||
@ -983,15 +973,12 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
'id_ticket' => $ticket->id_ticket
|
'id_ticket' => $ticket->id_ticket
|
||||||
] );
|
] );
|
||||||
|
|
||||||
|
|
||||||
$item = new ShoppingCart ();
|
$item = new ShoppingCart ();
|
||||||
$item->id_customer = $this->id_customer;
|
$item->id_customer = $this->id_customer;
|
||||||
$item->id_transfer = $this->id_transfer;
|
$item->id_transfer = $this->id_transfer;
|
||||||
$item->save ( false );
|
$item->save ( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1008,13 +995,14 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ShoppingCart::deleteAll ( [ 'id_transfer' => $this->id_transfer ] );
|
ShoppingCart::deleteAll ( [
|
||||||
UserSoldItem::deleteAll ( [ 'id_transfer' => $this->id_transfer
|
'id_transfer' => $this->id_transfer
|
||||||
|
] );
|
||||||
|
UserSoldItem::deleteAll ( [
|
||||||
|
'id_transfer' => $this->id_transfer
|
||||||
] );
|
] );
|
||||||
return $this->save ( false );
|
return $this->save ( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function payoutAll($id_user, $id_array) {
|
public static function payoutAll($id_user, $id_array) {
|
||||||
ShoppingCart::deleteAll ( [
|
ShoppingCart::deleteAll ( [
|
||||||
'in',
|
'in',
|
||||||
@ -1039,13 +1027,23 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
'status' => Transfer::STATUS_PAID,
|
'status' => Transfer::STATUS_PAID,
|
||||||
'paid_at' => Helper::getDateTimeString (),
|
'paid_at' => Helper::getDateTimeString (),
|
||||||
'paid_by' => $id_user,
|
'paid_by' => $id_user,
|
||||||
'id_account' => Account::readDefault(),
|
'id_account' => Account::readDefault ()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$updateConditions = [
|
$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 );
|
||||||
@ -1075,7 +1073,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
$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->max_usage_count = $ticketType->max_usage_count;
|
||||||
$ticket->usage_count = 0;
|
$ticket->usage_count = 0;
|
||||||
$ticket->status = Ticket::STATUS_ACTIVE;
|
$ticket->status = Ticket::STATUS_INACTIVE;
|
||||||
$ticket->price_brutto = $request->money;
|
$ticket->price_brutto = $request->money;
|
||||||
$ticket->id_card = $card->id_card;
|
$ticket->id_card = $card->id_card;
|
||||||
$ticket->part = $request->priority;
|
$ticket->part = $request->priority;
|
||||||
@ -1105,7 +1103,6 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
$transfer->id_customer = $customer->id_customer;
|
$transfer->id_customer = $customer->id_customer;
|
||||||
$transfer->save ( false );
|
$transfer->save ( false );
|
||||||
|
|
||||||
|
|
||||||
if ($addToCustomerCart == true) {
|
if ($addToCustomerCart == true) {
|
||||||
$cart = new ShoppingCart ();
|
$cart = new ShoppingCart ();
|
||||||
$cart->id_customer = $customer->id_customer;
|
$cart->id_customer = $customer->id_customer;
|
||||||
@ -1113,21 +1110,21 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
|
|||||||
$cart->save ( false );
|
$cart->save ( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
return [$transfer,$ticket];
|
return [
|
||||||
|
$transfer,
|
||||||
|
$ticket
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function canBeAddedToCart($payment_method) {
|
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 false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function canMarkPaidByReception($payment_method) {
|
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 false;
|
||||||
}
|
}
|
||||||
return true;
|
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'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
43
console/controllers/DetstaConsoleController.php
Normal file
43
console/controllers/DetstaConsoleController.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
namespace console\controllers;
|
||||||
|
|
||||||
|
|
||||||
|
use yii\console\Controller;
|
||||||
|
use frontend\models\ContractForm;
|
||||||
|
use common\models\TicketType;
|
||||||
|
use common\models\Customer;
|
||||||
|
use common\models\Transfer;
|
||||||
|
|
||||||
|
|
||||||
|
class DetstaConsoleController extends Controller{
|
||||||
|
|
||||||
|
|
||||||
|
public function actionCreateContract(){
|
||||||
|
|
||||||
|
|
||||||
|
$contractForm = new ContractForm(
|
||||||
|
[
|
||||||
|
'idAccount' => 1,
|
||||||
|
'idUser' => 1
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$customer = Customer::findOne(5559);
|
||||||
|
$contractForm->customer = $customer;
|
||||||
|
$contractForm->payment_method = Transfer::PAYMENT_METHOD_TRANSFER;
|
||||||
|
|
||||||
|
|
||||||
|
$contractForm->ticketType = TicketType::find()->andWhere(['status' => TicketType::STATUS_ACTIVE ,'installment_enabled' => '1'])->one();
|
||||||
|
|
||||||
|
|
||||||
|
$start = new \DateTime();
|
||||||
|
$startString = $start->format("'Y-m-d");
|
||||||
|
|
||||||
|
|
||||||
|
$contractForm->make();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
48
console/migrations/m160502_055142_add_table_waste.php
Normal file
48
console/migrations/m160502_055142_add_table_waste.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m160502_055142_add_table_waste extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$tableOptions = null;
|
||||||
|
if ($this->db->driverName === 'mysql') {
|
||||||
|
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
|
||||||
|
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->createTable('{{%waste}}', [
|
||||||
|
'id_waste' => $this->primaryKey(),
|
||||||
|
'count' => $this->integer(11),
|
||||||
|
'id_product' => $this->integer(11),
|
||||||
|
'stock_before' => $this->integer(11),
|
||||||
|
'stock_after' => $this->integer(11),
|
||||||
|
'id_user' => $this->integer(11),
|
||||||
|
'comment' => $this->string(),
|
||||||
|
'created_at' => $this->dateTime()->notNull(),
|
||||||
|
'updated_at' => $this->dateTime()->notNull(),
|
||||||
|
], $tableOptions);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m160502_055142_add_table_waste cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@ -293,7 +293,9 @@ class ContractController extends Controller {
|
|||||||
|
|
||||||
|
|
||||||
$model = new ContractForm ( [
|
$model = new ContractForm ( [
|
||||||
'customer' => $customer
|
'customer' => $customer ,
|
||||||
|
'idUser' => \Yii::$app->user->id,
|
||||||
|
'idAccount' => Account::readDefault ()
|
||||||
] );
|
] );
|
||||||
|
|
||||||
$model->started_at = date(date('Y.m.d'));
|
$model->started_at = date(date('Y.m.d'));
|
||||||
|
|||||||
@ -9,12 +9,10 @@ use frontend\models\CustomerSearch;
|
|||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
use yii\filters\VerbFilter;
|
use yii\filters\VerbFilter;
|
||||||
use yii\base\Object;
|
|
||||||
use common\models\Card;
|
use common\models\Card;
|
||||||
use frontend\models\CustomerUpdate;
|
use frontend\models\CustomerUpdate;
|
||||||
use frontend\models\CustomerCreate;
|
use frontend\models\CustomerCreate;
|
||||||
use common\models\Image;
|
use common\models\Image;
|
||||||
use frontend\models\ContractForm;
|
|
||||||
use yii\base\Exception;
|
use yii\base\Exception;
|
||||||
use common\models\Log;
|
use common\models\Log;
|
||||||
|
|
||||||
|
|||||||
@ -114,7 +114,8 @@ class TicketController extends FrontendController
|
|||||||
|
|
||||||
$model->customer = $receptionForm->customer;
|
$model->customer = $receptionForm->customer;
|
||||||
$model->id_user = \Yii::$app->user->id;
|
$model->id_user = \Yii::$app->user->id;
|
||||||
$model->status = Ticket::STATUS_ACTIVE;
|
|
||||||
|
|
||||||
$model->usage_count = 0;
|
$model->usage_count = 0;
|
||||||
$model->id_card = $receptionForm->card->id_card;
|
$model->id_card = $receptionForm->card->id_card;
|
||||||
$model->id_account = Account::readDefault();
|
$model->id_account = Account::readDefault();
|
||||||
|
|||||||
@ -36,11 +36,13 @@ class ContractForm extends Model {
|
|||||||
private $ticket;
|
private $ticket;
|
||||||
private $transfer;
|
private $transfer;
|
||||||
public $contract;
|
public $contract;
|
||||||
private $ticketType;
|
public $ticketType;
|
||||||
private $money;
|
private $money;
|
||||||
private $discount;
|
private $discount;
|
||||||
public $started_at;
|
public $started_at;
|
||||||
public $timestampStart;
|
public $timestampStart;
|
||||||
|
public $idUser;
|
||||||
|
public $idAccount;
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
@ -244,8 +246,9 @@ class ContractForm extends Model {
|
|||||||
public function createTicket() {
|
public function createTicket() {
|
||||||
|
|
||||||
$ticket = new Ticket ();
|
$ticket = new Ticket ();
|
||||||
$ticket->id_user = \Yii::$app->user->id;
|
$ticket->id_user = $this->getUserId();
|
||||||
$ticket->id_account = Account::readDefault ();
|
$ticket->id_account = $this->getAccountId();
|
||||||
|
|
||||||
$ticket->id_discount = $this->id_discount;
|
$ticket->id_discount = $this->id_discount;
|
||||||
$ticket->start = $this->started_at;
|
$ticket->start = $this->started_at;
|
||||||
$date = new \DateTime ( $this->timestampStart);
|
$date = new \DateTime ( $this->timestampStart);
|
||||||
@ -278,9 +281,9 @@ class ContractForm extends Model {
|
|||||||
$transfer->item_price = $this->money;
|
$transfer->item_price = $this->money;
|
||||||
$transfer->count = 1;
|
$transfer->count = 1;
|
||||||
$transfer->money = $this->money;
|
$transfer->money = $this->money;
|
||||||
$transfer->id_user = \Yii::$app->user->id;
|
$transfer->id_user = $this->getUserId();
|
||||||
$transfer->comment = "Szerződéses bérlet";
|
$transfer->comment = "Szerződéses bérlet";
|
||||||
$transfer->id_account = Account::readDefault ();
|
$transfer->id_account = $this->getAccountId();
|
||||||
$transfer->direction = Transfer::DIRECTION_IN;
|
$transfer->direction = Transfer::DIRECTION_IN;
|
||||||
$transfer->id_customer = $this->customer->id_customer;
|
$transfer->id_customer = $this->customer->id_customer;
|
||||||
$transfer->payment_method = $this->payment_method;
|
$transfer->payment_method = $this->payment_method;
|
||||||
@ -301,7 +304,7 @@ class ContractForm extends Model {
|
|||||||
|
|
||||||
$contract = new Contract ();
|
$contract = new Contract ();
|
||||||
$contract->id_customer = $this->customer->id_customer;
|
$contract->id_customer = $this->customer->id_customer;
|
||||||
$contract->id_user = \Yii::$app->user->id;
|
$contract->id_user = $this->getUserId();
|
||||||
$contract->status = Contract::$STATUS_PAID;
|
$contract->status = Contract::$STATUS_PAID;
|
||||||
$contract->flag = Contract::$FLAG_ACTIVE;
|
$contract->flag = Contract::$FLAG_ACTIVE;
|
||||||
$contract->part_count = $this->ticketType->installment_count;
|
$contract->part_count = $this->ticketType->installment_count;
|
||||||
@ -342,4 +345,21 @@ class ContractForm extends Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function getUserId(){
|
||||||
|
if ( isset($this->idUser)){
|
||||||
|
return $this->idUser;
|
||||||
|
}
|
||||||
|
return \Yii::$app->user->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function getAccountId(){
|
||||||
|
if ( isset($this->idAccount)){
|
||||||
|
return $this->idAccount;
|
||||||
|
}
|
||||||
|
return Account::readDefault();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -141,6 +141,13 @@ class TicketCreate extends Ticket{
|
|||||||
$result = parent::beforeSave($insert);
|
$result = parent::beforeSave($insert);
|
||||||
if ( $result ){
|
if ( $result ){
|
||||||
if ($insert){
|
if ($insert){
|
||||||
|
|
||||||
|
if ( $this->isAppendToCustomerCart() || $this->isAppendToUserCart()){
|
||||||
|
$this->status = Ticket::STATUS_INACTIVE;
|
||||||
|
}else{
|
||||||
|
$this->status = Ticket::STATUS_ACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
$ticketType = TicketType::findOne($this->id_ticket_type);
|
$ticketType = TicketType::findOne($this->id_ticket_type);
|
||||||
if ( isset($ticketType) && $ticketType->isInstallment() ){
|
if ( isset($ticketType) && $ticketType->isInstallment() ){
|
||||||
$this->part = 0;
|
$this->part = 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user