Finish version/v.0.0.84
This commit is contained in:
commit
323b9d985d
31
backend/assets/InventoryItemUpdateAsset.php
Normal file
31
backend/assets/InventoryItemUpdateAsset.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 InventoryItemUpdateAsset extends AssetBundle
|
||||||
|
{
|
||||||
|
public $basePath = '@webroot';
|
||||||
|
public $baseUrl = '@web';
|
||||||
|
public $css = [
|
||||||
|
];
|
||||||
|
public $js = [
|
||||||
|
'js/app.js',
|
||||||
|
'js/inventory,item.update.js',
|
||||||
|
];
|
||||||
|
public $depends = [
|
||||||
|
'backend\assets\AppAsset',
|
||||||
|
'yii\jui\JuiAsset',
|
||||||
|
'common\assets\TypeAheadAsset',
|
||||||
|
];
|
||||||
|
}
|
||||||
@ -2,15 +2,14 @@
|
|||||||
|
|
||||||
namespace backend\controllers;
|
namespace backend\controllers;
|
||||||
|
|
||||||
use Yii;
|
use /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
|
||||||
|
Yii;
|
||||||
use common\models\Inventory;
|
use common\models\Inventory;
|
||||||
use backend\models\InventorySearch;
|
use backend\models\InventorySearch;
|
||||||
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 common\models\User;
|
use common\models\User;
|
||||||
use yii\db\Query;
|
|
||||||
use backend\models\InventoryItemSearch;
|
|
||||||
use common\models\InventoryItem;
|
use common\models\InventoryItem;
|
||||||
use common\components\Helper;
|
use common\components\Helper;
|
||||||
|
|
||||||
|
|||||||
@ -2,9 +2,12 @@
|
|||||||
|
|
||||||
namespace backend\controllers;
|
namespace backend\controllers;
|
||||||
|
|
||||||
use Yii;
|
use /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
|
||||||
|
Yii;
|
||||||
use common\models\InventoryItem;
|
use common\models\InventoryItem;
|
||||||
use backend\models\InventoryItemSearch;
|
use backend\models\InventoryItemSearch;
|
||||||
|
use yii\base\Exception;
|
||||||
|
use yii\db\Query;
|
||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
use yii\filters\VerbFilter;
|
use yii\filters\VerbFilter;
|
||||||
@ -33,7 +36,9 @@ class InventoryItemController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all InventoryItem models.
|
* Lists all InventoryItem models.
|
||||||
|
* @param $id
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
public function actionIndex($id)
|
public function actionIndex($id)
|
||||||
{
|
{
|
||||||
@ -64,9 +69,11 @@ class InventoryItemController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function downloadIndexXls($dataProvider){
|
/**
|
||||||
|
* @param $dataProvider
|
||||||
|
*/
|
||||||
|
protected function downloadIndexXls($dataProvider)
|
||||||
|
{
|
||||||
$defs = [['item_created_at', 'Létrehozva'],
|
$defs = [['item_created_at', 'Létrehozva'],
|
||||||
['item_name', 'Termék/Termék csoport'],
|
['item_name', 'Termék/Termék csoport'],
|
||||||
['user_username', 'Felhasználó'],
|
['user_username', 'Felhasználó'],
|
||||||
@ -79,7 +86,9 @@ class InventoryItemController extends Controller
|
|||||||
];
|
];
|
||||||
$cols = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P'];
|
$cols = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P'];
|
||||||
|
|
||||||
|
/** @noinspection PhpUndefinedMethodInspection */
|
||||||
$models = $dataProvider->getModels();
|
$models = $dataProvider->getModels();
|
||||||
|
/** @noinspection PhpUndefinedClassInspection */
|
||||||
$objPHPExcel = new \PHPExcel ();
|
$objPHPExcel = new \PHPExcel ();
|
||||||
|
|
||||||
$sheet = $objPHPExcel->setActiveSheetIndex(0);
|
$sheet = $objPHPExcel->setActiveSheetIndex(0);
|
||||||
@ -112,7 +121,6 @@ class InventoryItemController extends Controller
|
|||||||
// 'name' => 'Verdana'
|
// 'name' => 'Verdana'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach (range('A', 'I') as $columnID) {
|
foreach (range('A', 'I') as $columnID) {
|
||||||
$sheet->getColumnDimension($columnID)->setAutoSize(true);
|
$sheet->getColumnDimension($columnID)->setAutoSize(true);
|
||||||
$sheet->getStyle($columnID . '1')->applyFromArray($styleArray);
|
$sheet->getStyle($columnID . '1')->applyFromArray($styleArray);
|
||||||
@ -129,6 +137,7 @@ class InventoryItemController extends Controller
|
|||||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
|
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
|
||||||
header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
|
header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
|
||||||
header('Pragma: public'); // HTTP/1.0
|
header('Pragma: public'); // HTTP/1.0
|
||||||
|
/** @noinspection PhpUndefinedClassInspection */
|
||||||
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
||||||
$objWriter->save('php://output');
|
$objWriter->save('php://output');
|
||||||
exit ();
|
exit ();
|
||||||
@ -149,7 +158,9 @@ class InventoryItemController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Creates a new InventoryItem model.
|
* Creates a new InventoryItem model.
|
||||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||||
|
* @param Integer $id the item id
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function actionCreate($id)
|
public function actionCreate($id)
|
||||||
{
|
{
|
||||||
@ -173,6 +184,8 @@ class InventoryItemController extends Controller
|
|||||||
* If update is successful, the browser will be redirected to the 'view' page.
|
* If update is successful, the browser will be redirected to the 'view' page.
|
||||||
* @param integer $id
|
* @param integer $id
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws NotAcceptableHttpException
|
||||||
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
public function actionUpdate($id)
|
public function actionUpdate($id)
|
||||||
{
|
{
|
||||||
@ -205,6 +218,108 @@ class InventoryItemController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param integer $id the inventory item id
|
||||||
|
* @return string
|
||||||
|
* @throws Exception
|
||||||
|
* @throws NotAcceptableHttpException
|
||||||
|
* @throws NotFoundHttpException
|
||||||
|
*/
|
||||||
|
public function actionUpdateItem($idInventory = null,$id = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
if ( !isset($idInventory ) && !isset($id)){
|
||||||
|
\Yii::error("Neither inventory id nor inventory item id");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset($id)){
|
||||||
|
$model = $this->findModel($id);
|
||||||
|
$inventory = Inventory::findOne($model->id_inventory);
|
||||||
|
}else{
|
||||||
|
$inventory = Inventory::findOne($idInventory);
|
||||||
|
$model = new InventoryItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$inventory->isOpen()) {
|
||||||
|
throw new NotAcceptableHttpException("A leltár elem nem található");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (Yii::$app->request->getIsAjax()) {
|
||||||
|
$arr = [
|
||||||
|
'id_inventory_item' => $model->id_inventory_item,
|
||||||
|
'productName' => $model->productName,
|
||||||
|
'count' => $model->count,
|
||||||
|
'type' => $model->type
|
||||||
|
];
|
||||||
|
|
||||||
|
return json_encode($arr);
|
||||||
|
} else {
|
||||||
|
if (Yii::$app->request->isPost && $model->isNewRecord ){
|
||||||
|
\Yii::error("Failed to save inventory-item: post , but no item id");
|
||||||
|
throw new Exception("Hiba történt mentés közben");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
|
||||||
|
|
||||||
|
$model->recalculateTotalPriceBrutto();
|
||||||
|
|
||||||
|
if ( $model->save(false) ){
|
||||||
|
\Yii::$app->session->setFlash('success', "Mennyiség elmentve: " . $model->productName . ' - ' .$model->count . ' db');
|
||||||
|
}else{
|
||||||
|
\Yii::error("Nem sikerült elmenteni a leltár element.");
|
||||||
|
throw new Exception("Nem sikerült elmenteni a leltár element");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset($_POST['_next'])){
|
||||||
|
return $this->redirect(['update-item', 'idInventory' => $inventory->id_inventory]);
|
||||||
|
}else{
|
||||||
|
return $this->redirect(['index', 'id' => $inventory->id_inventory]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$query = new Query();
|
||||||
|
$query->select([
|
||||||
|
'product.id_product as product_id_product',
|
||||||
|
'product.name as product_name',
|
||||||
|
'account.name as account_name',
|
||||||
|
'product_category.name as product_category_name',
|
||||||
|
'inventory_item.id_inventory_item as inventory_item_id_inventory_item',
|
||||||
|
]);
|
||||||
|
$query->from(['product']);
|
||||||
|
|
||||||
|
$query
|
||||||
|
->innerJoin("product_category", "product_category.id_product_category = product.id_product_category")
|
||||||
|
->innerJoin("account", "product.id_account = account.id_account")
|
||||||
|
->innerJoin("inventory_item", "inventory_item.id_product = product.id_product")
|
||||||
|
->andWhere(["inventory_item.id_inventory" => $inventory->id_inventory])->all();
|
||||||
|
$productsRaw = $query->all();
|
||||||
|
|
||||||
|
|
||||||
|
$products = [];
|
||||||
|
foreach ($productsRaw as $product ){
|
||||||
|
$arr = [];
|
||||||
|
$arr['id_inventory_item'] = $product['inventory_item_id_inventory_item'];
|
||||||
|
$arr['id_product'] = $product['product_id_product'];
|
||||||
|
$arr['name'] = $product['product_name'] ."( ". $product['account_name'].")";
|
||||||
|
$arr['product_name'] = $product['account_name'] ;
|
||||||
|
$products[] = $arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $this->render("update_item", [
|
||||||
|
'model' => $model,
|
||||||
|
'inventory' => $inventory,
|
||||||
|
'products' => $products
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes an existing InventoryItem model.
|
* Deletes an existing InventoryItem model.
|
||||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||||
|
|||||||
@ -373,14 +373,17 @@ class UgiroController extends Controller {
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function actionDelete($id) {
|
public function actionDelete($id) {
|
||||||
|
|
||||||
$this->findModel ( $id )->delete ();
|
$this->findModel ( $id )->delete ();
|
||||||
|
|
||||||
return $this->redirect ( [
|
return $this->redirect ( [
|
||||||
'index'
|
'index'
|
||||||
] );
|
] );
|
||||||
|
|
||||||
}
|
}
|
||||||
public function actionDetsta() {
|
public function actionDetsta() {
|
||||||
$ugiro = Ugiro::findOne ( 31 );
|
$ugiro = Ugiro::findOne ( 31 );
|
||||||
|
|
||||||
$model = new DetStatProcessor ( [
|
$model = new DetStatProcessor ( [
|
||||||
'koteg' => $ugiro
|
'koteg' => $ugiro
|
||||||
] );
|
] );
|
||||||
|
|||||||
@ -7,19 +7,15 @@ use yii\widgets\ActiveForm;
|
|||||||
/* @var $model common\models\InventoryItem */
|
/* @var $model common\models\InventoryItem */
|
||||||
/* @var $form yii\widgets\ActiveForm */
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
?>
|
?>
|
||||||
|
<div id="inventory-form" class="inventory-item-form">
|
||||||
<div class="inventory-item-form">
|
|
||||||
|
|
||||||
<?php $form = ActiveForm::begin( ); ?>
|
<?php $form = ActiveForm::begin( ); ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'type')->hiddenInput()->label(false) ?>
|
<?= $form->field($model, 'type')->hiddenInput()->label(false) ?>
|
||||||
<?= $form->field($model, 'count')->textInput() ?>
|
<?= $form->field($model, 'count')->textInput() ?>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton( Yii::t('common/inventory-item', 'Mentés/Következő')
|
||||||
|
, ['class' => 'btn btn-success',
|
||||||
|
'name'=> '_next' ]) ?>
|
||||||
<?= Html::submitButton( Yii::t('common/inventory-item', 'Mentés') , ['class' => 'btn btn-success' ]) ?>
|
<?= Html::submitButton( Yii::t('common/inventory-item', 'Mentés') , ['class' => 'btn btn-success' ]) ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php ActiveForm::end(); ?>
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -9,6 +9,7 @@ use backend\assets\InventoryItemIndexAsset;
|
|||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $searchModel backend\models\InventoryItemSearch */
|
/* @var $searchModel backend\models\InventoryItemSearch */
|
||||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||||
|
/* @var $model \common\models\Inventory */
|
||||||
|
|
||||||
$this->title = Yii::t('common/inventory-item', 'Leltár részletei');
|
$this->title = Yii::t('common/inventory-item', 'Leltár részletei');
|
||||||
$this->params['breadcrumbs'][] = $this->title;
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
@ -27,6 +28,7 @@ $this->registerJs('inventoryItemIndex.init( '. json_encode($options) .' );');
|
|||||||
.table th {
|
.table th {
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table td {
|
.table td {
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
}
|
}
|
||||||
@ -37,11 +39,8 @@ $this->registerJs('inventoryItemIndex.init( '. json_encode($options) .' );');
|
|||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class="inventory-item-index">
|
<div class="inventory-item-index">
|
||||||
|
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
<?= DetailView::widget([
|
<?= DetailView::widget([
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
@ -60,17 +59,12 @@ $this->registerJs('inventoryItemIndex.init( '. json_encode($options) .' );');
|
|||||||
'created_at:datetime',
|
'created_at:datetime',
|
||||||
],
|
],
|
||||||
]) ?>
|
]) ?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if ($model->isOpen()) {
|
if ($model->isOpen()) {
|
||||||
echo Html::a("Lezárás", ['inventory/close', 'id' => $model->id_inventory], ['data-method' => 'post', 'class' => 'btn btn-danger']);
|
echo Html::a("Lezárás", ['inventory/close', 'id' => $model->id_inventory], ['data-method' => 'post', 'class' => 'btn btn-danger']);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
|
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Magyarázat:
|
Magyarázat:
|
||||||
<ul>
|
<ul>
|
||||||
@ -94,13 +88,10 @@ $this->registerJs('inventoryItemIndex.init( '. json_encode($options) .' );');
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<?php echo Html::a("XLS letöltése", Url::current(['InventoryItemSearch[output]' => 'xls']), ['class' => 'btn btn-primary']) ?>
|
<?php echo Html::a("XLS letöltése", Url::current(['InventoryItemSearch[output]' => 'xls']), ['class' => 'btn btn-primary']) ?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$columns = [
|
$columns = [
|
||||||
[
|
[
|
||||||
'attribute' => 'item_name',
|
'attribute' => 'item_name',
|
||||||
@ -160,32 +151,30 @@ $this->registerJs('inventoryItemIndex.init( '. json_encode($options) .' );');
|
|||||||
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($model->isOpen()) {
|
if ($model->isOpen()) {
|
||||||
|
|
||||||
$columns[] = ['class' => 'yii\grid\ActionColumn',
|
$columns[] = ['class' => 'yii\grid\ActionColumn',
|
||||||
'template' => '{update}',
|
'template' => '{update}',
|
||||||
'urlCreator' => function ($action, $model, $key, $index){
|
|
||||||
return Url::to(['inventory-item/update', 'id' => $model['item_id_inventory_item' ] ]) ;
|
|
||||||
},
|
|
||||||
'buttons' => [
|
'buttons' => [
|
||||||
'update' =>function ($url, $model, $key) {
|
'update' => function ($url) {
|
||||||
return Html::a('Módosítás', $url, ['class' => 'btn btn-xs btn-success',
|
return Html::a('Módosítás', $url, ['class' => 'btn btn-xs btn-success',
|
||||||
'data' => [
|
'data' => [
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
'urlCreator' => function ($action, $model) {
|
||||||
|
$result = "";
|
||||||
|
if ($action == 'update') {
|
||||||
|
$result = Url::toRoute(['update-item', 'id' => $model['item_id_inventory_item']]);
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo GridView::widget([
|
echo GridView::widget([
|
||||||
'dataProvider' => $dataProvider,
|
'dataProvider' => $dataProvider,
|
||||||
'columns' => $columns
|
'columns' => $columns
|
||||||
|
|
||||||
]);
|
]);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|||||||
64
backend/views/inventory-item/update_item.php
Normal file
64
backend/views/inventory-item/update_item.php
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?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' => Yii::t('common/inventory-item', 'Leltár termék'), 'url' => ['inventory-item/index','id' => $inventory->id_inventory]];
|
||||||
|
$this->params['breadcrumbs'][] = Yii::t('common/inventory-item', 'Leltár mennyiség');
|
||||||
|
|
||||||
|
\backend\assets\InventoryItemUpdateAsset::register($this);
|
||||||
|
|
||||||
|
$options = [];
|
||||||
|
$options['products'] = $products;
|
||||||
|
$options['url_find_inventory_item'] = \yii\helpers\Url::toRoute(['inventory-item/update-item']);
|
||||||
|
$options['url_save'] = \yii\helpers\Url::toRoute(['inventory-item/update-item']);
|
||||||
|
$options['id_product'] = $model->id_product;
|
||||||
|
|
||||||
|
$this->registerJs('FitnessAdmin.InventoryItem.Update.init( '. json_encode( $options ) .' );');
|
||||||
|
?>
|
||||||
|
<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',
|
||||||
|
],
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
<?php echo Html::a("Ugrás a leltárhoz",['inventory-item/index','id'=> $inventory->id_inventory ], ['class' => 'btn btn-primary']) ?>
|
||||||
|
|
||||||
|
<h2>Termék keresése a leltárban</h2>
|
||||||
|
<?php $form = \yii\widgets\ActiveForm::begin(); ?>
|
||||||
|
|
||||||
|
<?php echo Html::textInput("product_autocomplete","",['class' => 'form-control', 'id' => 'product_autocomplete','autocomplete' => 'off']) ?>
|
||||||
|
<?php echo Html::hiddenInput("product_id","",[ 'id' => 'product_id','autocomplete' => 'off']) ?>
|
||||||
|
|
||||||
|
<?php \yii\widgets\ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
<div id="inventory-product">
|
||||||
|
<h2>Termék</h2>
|
||||||
|
<table class="table table-striped table-bordered detail-view">
|
||||||
|
<tbody><tr><th>Név</th><td id="inventory_product_name"> <?php echo Html::getAttributeValue($model, 'name') ?> </td></tr></tbody>
|
||||||
|
</table>
|
||||||
|
<?= $this->render('_form', [
|
||||||
|
'model' => $model,
|
||||||
|
]) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
127
backend/web/js/inventory,item.update.js
Normal file
127
backend/web/js/inventory,item.update.js
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
var FitnessAdmin;
|
||||||
|
|
||||||
|
FitnessAdmin = {};
|
||||||
|
|
||||||
|
FitnessAdmin.InventoryItem = {};
|
||||||
|
|
||||||
|
FitnessAdmin.InventoryItem.Update = new function(){
|
||||||
|
|
||||||
|
var defaults = {
|
||||||
|
'selector_product' : '#product_autocomplete',
|
||||||
|
'url_find_inventory_item' : 'inventory-item/update-item',
|
||||||
|
"products" : [],
|
||||||
|
"url_save" : '',
|
||||||
|
"id_product": null
|
||||||
|
};
|
||||||
|
|
||||||
|
var _SELECTORS = {
|
||||||
|
INVENTORY_PRODUCT_NAME: '#inventory_product_name',
|
||||||
|
INVENTORYITEM_TYPE: '#inventoryitem-type',
|
||||||
|
INVENTORYITEM_COUNT: '#inventoryitem-count',
|
||||||
|
INVENTORY_FORM: '#inventory-product'
|
||||||
|
};
|
||||||
|
|
||||||
|
var inventoryItem = null;
|
||||||
|
|
||||||
|
this.init = function (options) {
|
||||||
|
defaults = $.extend(defaults,options);
|
||||||
|
createGUI();
|
||||||
|
preselectProduct();
|
||||||
|
};
|
||||||
|
|
||||||
|
var preselectProduct = function () {
|
||||||
|
if ( defaults.id_product ){
|
||||||
|
for (var i = 0; i < defaults.products.length ;i++ ){
|
||||||
|
var p = defaults.products[i];
|
||||||
|
if ( p.id_product == defaults.id_product){
|
||||||
|
$(defaults.selector_product).val(p.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$(_SELECTORS.INVENTORY_FORM).hide();
|
||||||
|
}
|
||||||
|
$(defaults.selector_product).focus().select();
|
||||||
|
};
|
||||||
|
|
||||||
|
var createGUI = function () {
|
||||||
|
initAutoComplete();
|
||||||
|
};
|
||||||
|
|
||||||
|
var initAutoComplete = function () {
|
||||||
|
var $input = $(defaults.selector_product);
|
||||||
|
$input.typeahead({source : 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()) {
|
||||||
|
// This means the exact match is found. Use toLowerCase() if you want case insensitive match.
|
||||||
|
//noinspection JSUnresolvedVariable
|
||||||
|
console.info(current);
|
||||||
|
_findProduct(current.id_inventory_item);
|
||||||
|
} 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
|
||||||
|
inventoryItem = null;
|
||||||
|
renderForm();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Nothing is active so it is a new value (or maybe empty value)
|
||||||
|
inventoryItem = null;
|
||||||
|
renderForm();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var selectInventoryItem = function (data) {
|
||||||
|
console.info('data',data);
|
||||||
|
inventoryItem = data;
|
||||||
|
};
|
||||||
|
|
||||||
|
var _findProduct = function (id){
|
||||||
|
var data, url;
|
||||||
|
|
||||||
|
url = defaults.url_find_inventory_item;
|
||||||
|
data = {
|
||||||
|
'id' : id
|
||||||
|
};
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
dataType: "json",
|
||||||
|
url: url,
|
||||||
|
data: data
|
||||||
|
}).then(selectInventoryItem).then(renderForm);
|
||||||
|
};
|
||||||
|
|
||||||
|
function renderForm( ) {
|
||||||
|
console.info( "render",inventoryItem);
|
||||||
|
var name = "",type = "",count = "";
|
||||||
|
if ( inventoryItem){
|
||||||
|
name = inventoryItem.productName;
|
||||||
|
type = inventoryItem.type;
|
||||||
|
if ( inventoryItem.count != null ){
|
||||||
|
count = inventoryItem.count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$(_SELECTORS.INVENTORY_PRODUCT_NAME).html(name);
|
||||||
|
$(_SELECTORS.INVENTORYITEM_TYPE).val(type);
|
||||||
|
$(_SELECTORS.INVENTORYITEM_COUNT).val(count);
|
||||||
|
|
||||||
|
var formContainer = $(_SELECTORS.INVENTORY_FORM);
|
||||||
|
var form = $(_SELECTORS.INVENTORY_FORM).find('form');
|
||||||
|
|
||||||
|
if ( inventoryItem == null ){
|
||||||
|
formContainer.hide();
|
||||||
|
}else {
|
||||||
|
formContainer.show();
|
||||||
|
form.attr('action', defaults.url_save +"&id="+inventoryItem.id_inventory_item);
|
||||||
|
$(_SELECTORS.INVENTORYITEM_COUNT).focus().select();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
@ -26,8 +26,6 @@ function WasteCreate(o){
|
|||||||
|
|
||||||
|
|
||||||
function initAutocomplete(){
|
function initAutocomplete(){
|
||||||
// var colors = ["red", "blue", "green", "yellow", "brown", "black"];
|
|
||||||
// $('#product_search').typeahead( {source: colors } );
|
|
||||||
|
|
||||||
var $input = $(defaults.selector_product);
|
var $input = $(defaults.selector_product);
|
||||||
console.info("len:" + $input.length);
|
console.info("len:" + $input.length);
|
||||||
@ -69,10 +67,9 @@ function WasteCreate(o){
|
|||||||
|
|
||||||
function _findProduct(id){
|
function _findProduct(id){
|
||||||
var data, url;
|
var data, url;
|
||||||
|
|
||||||
url = defaults.url_product_find;
|
url = defaults.url_product_find;
|
||||||
data = {
|
data = {
|
||||||
'id' : id,
|
'id' : id
|
||||||
};
|
};
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
-0.0.84
|
||||||
|
- add faster inventory item edit
|
||||||
-0.0.83
|
-0.0.83
|
||||||
- add rfid ascii char fix to key save/update
|
- add rfid ascii char fix to key save/update
|
||||||
-0.0.82
|
-0.0.82
|
||||||
|
|||||||
@ -5,7 +5,7 @@ return [
|
|||||||
'supportEmail' => 'rocho02@gmail.com',
|
'supportEmail' => 'rocho02@gmail.com',
|
||||||
'infoEmail' => 'info@rocho-net.hu',
|
'infoEmail' => 'info@rocho-net.hu',
|
||||||
'user.passwordResetTokenExpire' => 3600,
|
'user.passwordResetTokenExpire' => 3600,
|
||||||
'version' => 'v0.0.83',
|
'version' => 'v0.0.84',
|
||||||
'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
|
||||||
|
|||||||
@ -23,11 +23,11 @@ use common\components\ProductAwareBehavior;
|
|||||||
* @property integer $id_inventory_group
|
* @property integer $id_inventory_group
|
||||||
* @property integer $id_user
|
* @property integer $id_user
|
||||||
* @property integer $id_inventory_item_prev
|
* @property integer $id_inventory_item_prev
|
||||||
* @property integer $id_user
|
|
||||||
* @property integer $price_brutto
|
* @property integer $price_brutto
|
||||||
* @property integer $total_price_brutto
|
* @property integer $total_price_brutto
|
||||||
* @property string $created_at
|
* @property string $created_at
|
||||||
* @property string $updated_at
|
* @property string $updated_at
|
||||||
|
* @property mixed productName
|
||||||
*/
|
*/
|
||||||
class InventoryItem extends BaseFitnessActiveRecord
|
class InventoryItem extends BaseFitnessActiveRecord
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user