add inventory to frontend
This commit is contained in:
30
frontend/assets/InventoryItemIndexAsset.php
Normal file
30
frontend/assets/InventoryItemIndexAsset.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* @link http://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license http://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
namespace frontend\assets;
|
||||
|
||||
use yii\web\AssetBundle;
|
||||
|
||||
/**
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @since 2.0
|
||||
*/
|
||||
class InventoryItemIndexAsset extends AssetBundle
|
||||
{
|
||||
public $basePath = '@webroot';
|
||||
public $baseUrl = '@web';
|
||||
public $css = [
|
||||
];
|
||||
public $js = [
|
||||
'js/inventory.item.index.js',
|
||||
];
|
||||
public $depends = [
|
||||
'frontend\assets\AppAsset',
|
||||
'yii\jui\JuiAsset',
|
||||
'common\assets\TypeAheadAsset',
|
||||
];
|
||||
}
|
||||
@@ -88,7 +88,8 @@ class FrontendMenuStructure{
|
||||
// }
|
||||
|
||||
$items[] = ['label' => Yii::t('frontend/card','Vendégek'), 'url' => [ '/card/index' ] ];
|
||||
$items[] = ['label' => Yii::t('frontend/card','Leltár'), 'url' => [ '/product/inventory' ] ];
|
||||
// $items[] = ['label' => Yii::t('frontend/card','Leltár'), 'url' => [ '/product/inventory' ] ];
|
||||
$items[] = ['label' => Yii::t('frontend/card','Leltár'), 'url' => [ '/inventory/index' ] ];
|
||||
|
||||
|
||||
$this->menuItems[] = ['label' => Yii::t('frontend/account', 'Account'),
|
||||
|
||||
86
frontend/controllers/InventoryController.php
Normal file
86
frontend/controllers/InventoryController.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use common\models\Inventory;
|
||||
use frontend\models\InventorySearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use common\models\User;
|
||||
|
||||
/**
|
||||
* InventoryController implements the CRUD actions for Inventory model.
|
||||
*/
|
||||
class InventoryController extends Controller
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Inventory models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new InventorySearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new Inventory model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new Inventory();
|
||||
$user = User::findOne(\Yii::$app->user->id);
|
||||
|
||||
|
||||
$model->name = 'Leltár_'.date('Ymd_His') .'_' . $user->username;
|
||||
|
||||
$model->id_user = \Yii::$app->user->id;
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['inventory-item/index', 'id' => $model->id_inventory]);
|
||||
} else {
|
||||
}
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Finds the Inventory model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return Inventory the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = Inventory::findOne($id)) !== null) {
|
||||
return $model;
|
||||
} else {
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
||||
}
|
||||
228
frontend/controllers/InventoryItemController.php
Normal file
228
frontend/controllers/InventoryItemController.php
Normal file
@@ -0,0 +1,228 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use Yii;
|
||||
use common\models\InventoryItem;
|
||||
use frontend\models\InventoryItemSearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use backend\models\InventoryItemForm;
|
||||
use common\models\Inventory;
|
||||
use yii\helpers\Url;
|
||||
use common\models\Product;
|
||||
|
||||
/**
|
||||
* InventoryItemController implements the CRUD actions for InventoryItem model.
|
||||
*/
|
||||
class InventoryItemController extends Controller
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all InventoryItem models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex($id)
|
||||
{
|
||||
$inventory = Inventory::findOne($id);
|
||||
|
||||
if ( !isset($inventory)){
|
||||
throw new NotFoundHttpException("Leltár nem található");
|
||||
}
|
||||
|
||||
$searchModel = new InventoryItemSearch(['inventory' => $inventory]);
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
$productOptions = Product::buildProductAndInventoryGroupList();
|
||||
|
||||
if ($searchModel->output == 'xls') {
|
||||
$this->downloadIndexXls($dataProvider);
|
||||
}else{
|
||||
Url::remember(Url::current(),"inventory-item-index");
|
||||
}
|
||||
|
||||
|
||||
return $this->render('index', [
|
||||
'model' => $inventory,
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
'productOptions' =>$productOptions
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
protected function downloadIndexXls($dataProvider){
|
||||
|
||||
|
||||
$defs = [['item_created_at', 'Létrehozva'],
|
||||
['item_name', 'Termék/Termék csoport'],
|
||||
['user_username', 'Felhasználó'],
|
||||
['item_count_prev', 'Előző leltár (db)'],
|
||||
['item_count_sold', 'Eladott mennyiség (db)'],
|
||||
['item_count_in', 'Beszerzett mennyiség (db)'],
|
||||
['item_count', 'Leltározott mennyiség (db)'],
|
||||
['item_difference', 'Különbség (db)'],
|
||||
['item_count_system', 'Rendszer szerinti mennyiség (db)'],
|
||||
];
|
||||
$cols = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P'];
|
||||
|
||||
$models = $dataProvider->getModels ();
|
||||
$objPHPExcel = new \PHPExcel ();
|
||||
|
||||
$sheet = $objPHPExcel->setActiveSheetIndex ( 0 );
|
||||
/**
|
||||
* Termék azonosító Termék neve Termék szám Termék vonalkód Termék raktáron Termék eladva
|
||||
*/
|
||||
$row = 1;
|
||||
$col = 0;
|
||||
foreach ( $defs as $def ) {
|
||||
$sheet->setCellValue ( $cols [$col] . $row, $def [1] );
|
||||
$col ++;
|
||||
}
|
||||
|
||||
foreach ( $models as $model ) {
|
||||
$row ++;
|
||||
$col = 0;
|
||||
foreach ( $defs as $def ) {
|
||||
$sheet->setCellValue ( $cols [$col] . $row, $model[$def [0]] );
|
||||
$col ++;
|
||||
}
|
||||
}
|
||||
|
||||
$styleArray = array (
|
||||
'font' => array (
|
||||
'bold' => true
|
||||
)
|
||||
);
|
||||
// 'color' => array('rgb' => 'FF0000'),
|
||||
// 'size' => 15,
|
||||
// 'name' => 'Verdana'
|
||||
|
||||
|
||||
|
||||
foreach ( range ( 'A', 'I' ) as $columnID ) {
|
||||
$sheet->getColumnDimension ( $columnID )->setAutoSize ( true );
|
||||
$sheet->getStyle ( $columnID . '1' )->applyFromArray ( $styleArray );
|
||||
}
|
||||
|
||||
// Redirect output to a client’s web browser (Excel5)
|
||||
header ( 'Content-Type: application/vnd.ms-excel' );
|
||||
header ( 'Content-Disposition: attachment;filename="leltar.xls"' );
|
||||
header ( 'Cache-Control: max-age=0' );
|
||||
// If you're serving to IE 9, then the following may be needed
|
||||
header ( 'Cache-Control: max-age=1' );
|
||||
// If you're serving to IE over SSL, then the following may be needed
|
||||
header ( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ); // Date in the past
|
||||
header ( 'Last-Modified: ' . gmdate ( 'D, d M Y H:i:s' ) . ' GMT' ); // always modified
|
||||
header ( 'Cache-Control: cache, must-revalidate' ); // HTTP/1.1
|
||||
header ( 'Pragma: public' ); // HTTP/1.0
|
||||
$objWriter = \PHPExcel_IOFactory::createWriter ( $objPHPExcel, 'Excel5' );
|
||||
$objWriter->save ( 'php://output' );
|
||||
exit ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single InventoryItem model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new InventoryItem model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate($id)
|
||||
{
|
||||
$model = new InventoryItemForm([
|
||||
'id_inventory' => $id
|
||||
]);
|
||||
|
||||
$model->read();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['inventory-item/index', 'id' => $model->inventory->id_inventory]);
|
||||
} else {
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing InventoryItem 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);
|
||||
$inventory = Inventory::findOne($model->id_inventory);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
|
||||
$prev = Url::previous("inventory-item-index");
|
||||
if ( isset($prev)){
|
||||
return $this->redirect($prev);
|
||||
}else{
|
||||
return $this->redirect([ 'index', 'id' => $inventory->id_inventory ]);
|
||||
}
|
||||
|
||||
} else {
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
'inventory' => $inventory,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing InventoryItem model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$item = $this->findModel($id);
|
||||
$id_inventory = $item->id_inventory;
|
||||
$item->delete();
|
||||
|
||||
return $this->redirect(['index', 'id' => $id_inventory]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the InventoryItem model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return InventoryItem the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = InventoryItem::findOne($id)) !== null) {
|
||||
return $model;
|
||||
} else {
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
||||
}
|
||||
135
frontend/models/InventoryItemSearch.php
Normal file
135
frontend/models/InventoryItemSearch.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\InventoryItem;
|
||||
use yii\db\Query;
|
||||
use yii\db\Expression;
|
||||
use common\models\User;
|
||||
use common\models\Product;
|
||||
use common\models\InventoryGroup;
|
||||
use common\components\Helper;
|
||||
use common\models\Inventory;
|
||||
|
||||
/**
|
||||
* InventoryItemSearch represents the model behind the search form about `common\models\InventoryItem`.
|
||||
*/
|
||||
class InventoryItemSearch extends InventoryItem
|
||||
{
|
||||
public $inventory;
|
||||
public $output;
|
||||
public $item_name;
|
||||
public $item_type;
|
||||
public $item_id;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id_inventory_item', 'id_inventory', 'count_in', 'count_sold', 'count', 'type', 'id_product', 'id_inventory_group', 'id_user'], 'integer'],
|
||||
['output', 'string'],
|
||||
['item_name', 'string'],
|
||||
['item_type', 'string'],
|
||||
['item_id', 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = new Query();
|
||||
|
||||
$query->select([
|
||||
'inventory_item.id_inventory_item as item_id_inventory_item',
|
||||
'inventory_item.created_at as item_created_at',
|
||||
new Expression('case when inventory_item.id_product is null then inventory_group.name else product.name end as item_name'),
|
||||
'user.username as user_username',
|
||||
'coalesce(inventory_item.count_prev ,0)as item_count_prev',
|
||||
'coalesce(inventory_item.count_in,0) as item_count_in',
|
||||
'coalesce(inventory_item.count_sold,0) as item_count_sold',
|
||||
'coalesce(inventory_item.count,0) as item_count',
|
||||
'coalesce(inventory_item.count_system,0) as item_count_system',
|
||||
'inventory.created_at as inventory_created_at',
|
||||
'inventory_prev.id_inventory as inventory_prev_id_inventory',
|
||||
'inventory_prev.name as inventory_prev_name',
|
||||
new Expression('(coalesce(inventory_item.count,0) - ( coalesce(inventory_item.count_prev,0) + coalesce(inventory_item.count_in,0) - coalesce(inventory_item.count_sold,0) )) as item_difference'),
|
||||
]);
|
||||
|
||||
$query->from(InventoryItem::tableName());
|
||||
|
||||
|
||||
$query->innerJoin(User::tableName(), "user.id = inventory_item.id_user");
|
||||
$query->leftJoin(Product::tableName(), "product.id_product = inventory_item.id_product");
|
||||
$query->leftJoin(InventoryGroup::tableName(), "inventory_group.id_inventory_group = inventory_item.id_inventory_group");
|
||||
$query->leftJoin(Inventory::tableName(), "inventory.id_inventory = inventory_item.id_inventory");
|
||||
|
||||
$query->leftJoin( "inventory_item as item_prev", "item_prev.id_inventory_item = inventory_item.id_inventory_item_prev" );
|
||||
$query->leftJoin( "inventory as inventory_prev", "inventory_prev.id_inventory = item_prev.id_inventory" );
|
||||
|
||||
$query->andWhere( ['inventory_item.id_inventory' => $this->inventory->id_inventory] );
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
$dataProvider = new ActiveDataProvider(
|
||||
['query' => $query ,
|
||||
'pagination' => ( empty($this->output) ? [] : false ),
|
||||
'sort' => [
|
||||
'defaultOrder' => ['item_name' => SORT_ASC],
|
||||
'attributes' => Helper::mkYiiSortItems([
|
||||
['item_created_at', 'item_created_at'],
|
||||
['item_name', 'item_name'],
|
||||
['user_username', 'user_username'],
|
||||
['item_count_prev', 'item_count_prev'],
|
||||
['item_count_sold', 'item_count_sold'],
|
||||
['item_count_in', 'item_count_in'],
|
||||
['item_count', 'item_count'],
|
||||
['item_count', 'item_count'],
|
||||
['item_difference', 'item_difference'],
|
||||
['item_count_system', 'item_count_system'],
|
||||
['inventory.id_inventory', 'inventory_id_inventory'],
|
||||
['inventory.name', 'inventory_name'],
|
||||
['inventory_prev_name', 'inventory_prev_name'],
|
||||
])
|
||||
,
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
if ( !empty($this->item_type) && is_numeric($this->item_id) ){
|
||||
if ( $this->item_type == 'product'){
|
||||
$query->andFilterWhere(['product.id_product' => $this->item_id]);
|
||||
}else if ( $this->item_type == 'group' ){
|
||||
$query->andFilterWhere(['inventory_group.id_inventory_group' => $this->item_id]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
70
frontend/models/InventorySearch.php
Normal file
70
frontend/models/InventorySearch.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\Inventory;
|
||||
|
||||
/**
|
||||
* InventorySearch represents the model behind the search form about `common\models\Inventory`.
|
||||
*/
|
||||
class InventorySearch extends Inventory
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id_inventory', 'id_user'], 'integer'],
|
||||
[['created_at', 'updated_at'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 = Inventory::find();
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
'sort' =>[
|
||||
'defaultOrder' => [ 'created_at' => SORT_DESC ]
|
||||
]
|
||||
]);
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
$query->andFilterWhere([
|
||||
'id_inventory' => $this->id_inventory,
|
||||
'id_user' => $this->id_user,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
25
frontend/views/inventory-item/_form.php
Normal file
25
frontend/views/inventory-item/_form.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\InventoryItem */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="inventory-item-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'type')->hiddenInput()->label(false) ?>
|
||||
<?= $form->field($model, 'count')->textInput() ?>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton( Yii::t('common/inventory-item', 'Mentés') , ['class' => 'btn btn-success' ]) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
34
frontend/views/inventory-item/_search.php
Normal file
34
frontend/views/inventory-item/_search.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\models\InventoryItemSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="inventory-item-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['index','id' => $model->inventory->id_inventory],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'item_type')->hiddenInput()->label(false) ?>
|
||||
<?= $form->field($model, 'item_id')->hiddenInput()->label(false) ?>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<?= $form->field($model, 'item_name')->label("Termék/Termék csoport neve") ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton(Yii::t('common/inventory-item', 'Keresés'), ['class' => 'btn btn-primary']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
33
frontend/views/inventory-item/create.php
Normal file
33
frontend/views/inventory-item/create.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use backend\assets\InventoryItemCreateAsset;
|
||||
use yii\helpers\Url;
|
||||
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\InventoryItem */
|
||||
|
||||
$this->title = Yii::t('common/inventory-item', 'Új leltár elem');
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Leltár' , 'url' => ['inventory/view', 'id' => $model->inventory->id_inventory]];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
|
||||
InventoryItemCreateAsset::register($this);
|
||||
|
||||
|
||||
$options = [];
|
||||
$options['products'] = $model->productOptions;
|
||||
$options['url_product_find'] = Url::toRoute(['product/find']);
|
||||
|
||||
$this->registerJs('inventoryItemCreate.init( '. json_encode($options) .' );');
|
||||
|
||||
?>
|
||||
<div class="inventory-item-create">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
146
frontend/views/inventory-item/index.php
Normal file
146
frontend/views/inventory-item/index.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
use yii\widgets\DetailView;
|
||||
use yii\helpers\Url;
|
||||
use backend\assets\InventoryItemIndexAsset;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\models\InventoryItemSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = Yii::t('common/inventory-item', 'Leltár részletei');
|
||||
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Leltár lista' , 'url' => ['inventory/index']];;
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
|
||||
|
||||
InventoryItemIndexAsset::register($this);
|
||||
|
||||
$options = [];
|
||||
$options['products'] = $productOptions;
|
||||
|
||||
$this->registerJs('inventoryItemIndex.init( '. json_encode($options) .' );');
|
||||
|
||||
?>
|
||||
<style>
|
||||
.table thead th{
|
||||
white-space: normal;
|
||||
}
|
||||
</style>
|
||||
<div class="inventory-item-index">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id_inventory',
|
||||
'name',
|
||||
['attribute'=>'id_user',
|
||||
'value'=>$model->userName
|
||||
],
|
||||
['attribute'=>'id_account',
|
||||
'value'=>$model->accountName
|
||||
],
|
||||
'created_at:datetime',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
Magyarázat:
|
||||
<ul>
|
||||
<li>
|
||||
Előző leltár (db): az előző leltárban összeszámolt mennyiség. Ha ez a termék első leltározása akkor 0.
|
||||
</li>
|
||||
<li>
|
||||
Beszerzett mennyiség: Az előző leltár óta történt beszerzett mennyiségek összege
|
||||
</li>
|
||||
<li>
|
||||
Eladott mennyiség: Az előző leltár óta eladott darabszám összege
|
||||
</li>
|
||||
<li>
|
||||
Leltározott mennyiség: A felhasználó által összeszámolt és leltár létrehozásakor beírt mennyiség
|
||||
</li>
|
||||
<li>
|
||||
Rendszer szerinti mennyiség: a rendszer által számolt és aktuális látott mennyiség
|
||||
</li>
|
||||
<li>
|
||||
Különbség: = "Leltározott mennyiség - ( "Előző leltár" + "Beszerzett mennyiség" - "Eladott mennyiség" )
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<?php echo Html::a("XLS letöltése", Url::current(['InventoryItemSearch[output]' =>'xls']),['class' =>'btn btn-primary'])?>
|
||||
</p>
|
||||
|
||||
<?php
|
||||
echo GridView::widget( [
|
||||
'dataProvider' => $dataProvider,
|
||||
'columns' =>[
|
||||
[
|
||||
'attribute' => 'item_name',
|
||||
'label' => 'Név',
|
||||
|
||||
],
|
||||
[
|
||||
'attribute' => 'item_count_system',
|
||||
'label' => 'Rendszer szerinti mennyiség (db)',
|
||||
|
||||
],
|
||||
|
||||
|
||||
[
|
||||
'attribute' => 'item_count',
|
||||
'label' => 'Leltározott mennyiség (db)',
|
||||
|
||||
],
|
||||
[
|
||||
'attribute' => 'item_count_prev',
|
||||
'label' => 'Előzö leltár (db)'
|
||||
|
||||
],
|
||||
[
|
||||
'attribute' => 'item_count_in',
|
||||
'label' => 'Beszerzett mennyiség (db)'
|
||||
|
||||
],
|
||||
[
|
||||
'attribute' => 'item_count_sold',
|
||||
'label' => 'Eladott mennyiség (db)',
|
||||
|
||||
],
|
||||
|
||||
|
||||
[
|
||||
'attribute' => 'item_difference',
|
||||
'label' => 'Különbség (db)',
|
||||
|
||||
],
|
||||
['class' => 'yii\grid\ActionColumn',
|
||||
'template' => '{update}',
|
||||
'urlCreator' => function ($action, $model, $key, $index){
|
||||
return Url::to(['inventory-item/update', 'id' => $model['item_id_inventory_item' ] ]) ;
|
||||
},
|
||||
'buttons' =>[
|
||||
'update' =>function ($url, $model, $key) {
|
||||
return Html::a('Módosítás', $url,['class' => 'btn btn-xs btn-success',
|
||||
'data' => [
|
||||
],
|
||||
]) ;
|
||||
}
|
||||
]
|
||||
|
||||
]
|
||||
]
|
||||
|
||||
]);
|
||||
?>
|
||||
|
||||
</div>
|
||||
81
frontend/views/inventory-item/update.php
Normal file
81
frontend/views/inventory-item/update.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\InventoryItem */
|
||||
|
||||
$this->title = Yii::t('common/inventory-item', 'Leltár termék');
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Leltár lista', 'url' => ['inventory/index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Leltár', 'url' => ['inventory-item/index', 'id' => $model->id_inventory ]];
|
||||
$this->params['breadcrumbs'][] = Yii::t('common/inventory-item', 'Update');
|
||||
?>
|
||||
<div class="inventory-item-update">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<h2>Leltár</h2>
|
||||
<?= DetailView::widget([
|
||||
'model' => $inventory,
|
||||
'attributes' => [
|
||||
'id_inventory',
|
||||
'name',
|
||||
['attribute'=>'id_user',
|
||||
'value'=>$inventory->userName
|
||||
],
|
||||
['attribute'=>'id_account',
|
||||
'value'=>$inventory->accountName
|
||||
],
|
||||
'created_at:datetime',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
<h2>Termék</h2>
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
[
|
||||
|
||||
'value' => $model->name,
|
||||
'label' =>"Név"
|
||||
],
|
||||
[
|
||||
'value' => $model->count_system,
|
||||
'label' => 'Rendszer szerinti mennyiség (db)',
|
||||
],
|
||||
[
|
||||
'value' => $model->count,
|
||||
'label' => 'Leltározott mennyiség (db)',
|
||||
],
|
||||
[
|
||||
'value' => $model->count_prev,
|
||||
'label' => 'Előző leltár (db)',
|
||||
],
|
||||
[
|
||||
'value' => $model->count_in,
|
||||
'label' => 'Beszerzett mennyiség (db)',
|
||||
],
|
||||
[
|
||||
'value' => $model->count_sold,
|
||||
'label' => 'Eladott mennyiség (db)',
|
||||
],
|
||||
[
|
||||
'value' => $model->getDifference(),
|
||||
'label' => 'Különbség',
|
||||
],
|
||||
[
|
||||
'value' => '',
|
||||
'label' => '',
|
||||
],
|
||||
|
||||
|
||||
|
||||
],
|
||||
]) ?>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
45
frontend/views/inventory-item/view.php
Normal file
45
frontend/views/inventory-item/view.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\InventoryItem */
|
||||
|
||||
$this->title = $model->id_inventory_item;
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/inventory-item', 'Inventory Items'), 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="inventory-item-view">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<p>
|
||||
<?= Html::a(Yii::t('common/inventory-item', 'Update'), ['update', 'id' => $model->id_inventory_item], ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::a(Yii::t('common/inventory-item', 'Delete'), ['delete', 'id' => $model->id_inventory_item], [
|
||||
'class' => 'btn btn-danger',
|
||||
'data' => [
|
||||
'confirm' => Yii::t('common/inventory-item', 'Are you sure you want to delete this item?'),
|
||||
'method' => 'post',
|
||||
],
|
||||
]) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id_inventory_item',
|
||||
'id_inventory',
|
||||
'count_in',
|
||||
'count_sold',
|
||||
'count',
|
||||
'type',
|
||||
'id_product',
|
||||
'id_inventory_group',
|
||||
'id_user',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
32
frontend/views/inventory/_form.php
Normal file
32
frontend/views/inventory/_form.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
use common\models\Account;
|
||||
use common\components\Helper;
|
||||
use frontend\components\HtmlHelper;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Inventory */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
$accounts = ['' =>'Mind'] + HtmlHelper::mkAccountOptions( Account::readAccounts() );
|
||||
?>
|
||||
|
||||
<div class="inventory-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<?php echo $form->field($model, "id_account")->dropDownList($accounts)?>
|
||||
<?php echo $form->field($model, "name")->textInput()?>
|
||||
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/inventory', 'Létrehoz') : Yii::t('common/inventory', 'Módosít'), [ 'name'=>'Inventory[submit]' ,'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
33
frontend/views/inventory/_search.php
Normal file
33
frontend/views/inventory/_search.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\models\InventorySearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="inventory-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['index'],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'id_inventory') ?>
|
||||
|
||||
<?= $form->field($model, 'id_user') ?>
|
||||
|
||||
<?= $form->field($model, 'created_at') ?>
|
||||
|
||||
<?= $form->field($model, 'updated_at') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton(Yii::t('common/inventory', 'Search'), ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton(Yii::t('common/inventory', 'Reset'), ['class' => 'btn btn-default']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
21
frontend/views/inventory/create.php
Normal file
21
frontend/views/inventory/create.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Inventory */
|
||||
|
||||
$this->title = Yii::t('common/inventory', 'Új leltár');
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/inventory', 'Leltár lista'), 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="inventory-create">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
50
frontend/views/inventory/index.php
Normal file
50
frontend/views/inventory/index.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
use yii\helpers\Url;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\models\InventorySearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = Yii::t('common/inventory', 'Leltár lista');
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="inventory-index">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a(Yii::t('common/inventory', 'Új leltár'), ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'columns' => [
|
||||
|
||||
'id_inventory',
|
||||
'name',
|
||||
[ 'attribute' => 'id_user', "value" =>"userName" ],
|
||||
'created_at:datetime',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn',
|
||||
'template' => '{view}',
|
||||
'urlCreator' => function( $action, $model, $key, $index ){
|
||||
if ( $action == 'view' ){
|
||||
return Url::to(['inventory-item/index' , 'id'=> $model->id_inventory]);
|
||||
}
|
||||
},
|
||||
'buttons' =>[
|
||||
'view' =>function ($url, $model, $key) {
|
||||
return Html::a('Részletek', $url,['class' => 'btn btn-xs btn-primary',
|
||||
]) ;
|
||||
}
|
||||
]
|
||||
|
||||
],
|
||||
],
|
||||
]); ?>
|
||||
|
||||
</div>
|
||||
23
frontend/views/inventory/update.php
Normal file
23
frontend/views/inventory/update.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Inventory */
|
||||
|
||||
$this->title = Yii::t('common/inventory', 'Update {modelClass}: ', [
|
||||
'modelClass' => 'Inventory',
|
||||
]) . ' ' . $model->id_inventory;
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/inventory', 'Inventories'), 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->id_inventory, 'url' => ['view', 'id' => $model->id_inventory]];
|
||||
$this->params['breadcrumbs'][] = Yii::t('common/inventory', 'Update');
|
||||
?>
|
||||
<div class="inventory-update">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
89
frontend/views/inventory/view.php
Normal file
89
frontend/views/inventory/view.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
use yii\grid\GridView;
|
||||
use yii\base\Widget;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Inventory */
|
||||
|
||||
$this->title = $model->id_inventory;
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/inventory', 'Leltár lista'), 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = "Leltár";
|
||||
?>
|
||||
<div class="inventory-view">
|
||||
|
||||
<h1><?= Html::encode("Leltár") ?></h1>
|
||||
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id_inventory',
|
||||
'name',
|
||||
['attribute'=>'id_user',
|
||||
'value'=>$model->userName
|
||||
],
|
||||
'created_at:datetime',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<?= Html::a(Yii::t('common/inventory', 'Új termék'), ['inventory-item/create','id' =>$model->id_inventory], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
<?php
|
||||
|
||||
echo GridView::widget( [
|
||||
'dataProvider' => $dataProvider,
|
||||
'columns' =>[
|
||||
[
|
||||
'attribute' => 'item_created_at',
|
||||
'label' => 'Létrehozva',
|
||||
'format' => 'datetime'
|
||||
],
|
||||
[
|
||||
'attribute' => 'item_name',
|
||||
'label' => 'Név',
|
||||
|
||||
],
|
||||
[
|
||||
'attribute' => 'user_username',
|
||||
'label' => 'Felhasználó',
|
||||
|
||||
],
|
||||
[
|
||||
'attribute' => 'item_count_prev',
|
||||
'label' => 'Előzö leltár (db)'
|
||||
|
||||
],
|
||||
[
|
||||
'attribute' => 'item_count_in',
|
||||
'label' => 'Beszerzett mennyiség (db)'
|
||||
|
||||
],
|
||||
[
|
||||
'attribute' => 'item_count_sold',
|
||||
'label' => 'Eladott mennyiség (db)',
|
||||
|
||||
],
|
||||
[
|
||||
'attribute' => 'item_count',
|
||||
'label' => 'Leltározott mennyiség (db)',
|
||||
|
||||
],
|
||||
[
|
||||
'attribute' => 'item_difference',
|
||||
'label' => 'Különbség (db)',
|
||||
|
||||
],
|
||||
]
|
||||
|
||||
]);
|
||||
?>
|
||||
|
||||
58
frontend/web/js/inventory.item.index.js
Normal file
58
frontend/web/js/inventory.item.index.js
Normal file
@@ -0,0 +1,58 @@
|
||||
|
||||
|
||||
var inventoryItemIndex = {
|
||||
|
||||
defaults : {
|
||||
products: [],
|
||||
selector_type : '#inventoryitemsearch-item_type',
|
||||
selector_name : '#inventoryitemsearch-item_name',
|
||||
selector_id : '#inventoryitemsearch-item_id',
|
||||
},
|
||||
product: null,
|
||||
init: function(o){
|
||||
this.defaults = $.extend( this.defaults, o );
|
||||
this.initAutocomplete();
|
||||
|
||||
},
|
||||
|
||||
initAutocomplete : function (){
|
||||
var self = this;
|
||||
|
||||
var $input = $(self.defaults.selector_name);
|
||||
$input.typeahead({source : self.defaults.products,
|
||||
autoSelect: true,
|
||||
items: 20,
|
||||
minLength: 3,
|
||||
});
|
||||
$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()) {
|
||||
self.product = current;
|
||||
} else {
|
||||
self.product = null;
|
||||
}
|
||||
} else {
|
||||
self.product = null;
|
||||
}
|
||||
self.productChange();
|
||||
});
|
||||
},
|
||||
productChange: function( ){
|
||||
this.clearProductData();
|
||||
this.setProductData();
|
||||
},
|
||||
clearProductData: function(){
|
||||
$(this.defaults.selector_type).val('');
|
||||
$(this.defaults.selector_id).val('');
|
||||
},
|
||||
setProductData: function(){
|
||||
if ( this.product ){
|
||||
$(this.defaults.selector_type).val( this.product.type);
|
||||
$(this.defaults.selector_id ).val( this.product.id);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user