diff --git a/backend/controllers/InventoryItemController.php b/backend/controllers/InventoryItemController.php index 75eba2e..d6dfb4d 100644 --- a/backend/controllers/InventoryItemController.php +++ b/backend/controllers/InventoryItemController.php @@ -202,14 +202,26 @@ class InventoryItemController extends Controller $model->save(false); - $prev = Url::previous("inventory-item-index"); + \Yii::$app->session->setFlash('success', "Mennyiség elmentve: " . $model->productName . ' - ' .$model->count . ' db'); - if (isset($prev)) { - return $this->redirect($prev); - } else { +// $prev = Url::previous("inventory-item-index"); + + + +// if (isset($prev)) { +// return $this->redirect($prev); +// } else { +// return $this->redirect(['index', 'id' => $inventory->id_inventory]); +// } + + $next = InventoryItem::findNextItemAlphabetical($model->id_inventory_item); + if ( isset($next)){ + return $this->redirect(['inventory-item/update', 'id' => $next]); + }else{ return $this->redirect(['index', 'id' => $inventory->id_inventory]); } + } else { return $this->render('update', [ 'model' => $model, diff --git a/backend/models/InventoryItemForm.php b/backend/models/InventoryItemForm.php index 00816d2..afb3991 100644 --- a/backend/models/InventoryItemForm.php +++ b/backend/models/InventoryItemForm.php @@ -2,18 +2,15 @@ namespace backend\models; -use Yii; +use /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */ + Yii; use yii\base\Model; -use common\models\Card; -use common\models\Customer; -use common\models\Ticket; -use common\models\Account; -use yii\web\UploadedFile; use common\models\Inventory; use yii\base\Exception; use common\models\Product; use common\models\InventoryGroup; use common\models\InventoryItem; +use yii\db\Expression; use yii\db\Query; use common\models\Procurement; use common\models\Transfer; @@ -51,7 +48,9 @@ class InventoryItemForm extends Model{ public $product_stock; public $last_inventory_item; public $inventory_item; - + + public $next_item_index; + public function rules(){ return [ [[ 'name', 'count'], 'required'], @@ -63,14 +62,16 @@ class InventoryItemForm extends Model{ ]; } - public function validateType($attribute,$params){ + public function validateType(/** @noinspection PhpUnusedParameterInspection */ + $attribute, $params){ if ( array_search($this->type, ['product','group']) === false ){ \Yii::error("Típus nem megfelelő: " . $this->type); $this->addError("name","Nincs termék vagy termék csoport kiválasztva"); } } - public function validateId($attribute,$params){ + public function validateId(/** @noinspection PhpUnusedParameterInspection */ + $attribute, $params){ if ( !$this->hasErrors('type')){ if ( $this->type == 'group'){ $this->inventoryGroup = InventoryGroup::findOne($this->id_product); @@ -170,6 +171,10 @@ class InventoryItemForm extends Model{ $query->innerJoin(Product::tableName(),"product.id_product = sale.id_product "); $query->andWhere(['in', 'transfer.status' ,[Transfer::STATUS_PAID ,Transfer::STATUS_NOT_PAID ] ]); $query->andWhere(['transfer.type' => Transfer::TYPE_PRODUCT]); + + if ( isset($this->last_inventory_item ) ){ + $query->andWhere([ '>', 'transfer.created_at' ,$this->last_inventory_item->created_at]); + } if ( $this->type == 'product') { $query->andWhere(['product.id_product' => $this->product->id_product]); @@ -275,16 +280,14 @@ class InventoryItemForm extends Model{ foreach ($this->products as $product ){ $this->productOptions[]= [ 'type' =>'product', 'id' => $product->id_product ,'name' => $product->name . " (Termék/" .$product->productCategoryName ."/" . $product->accountName .")" ]; - } foreach ($this->inventoryGroups as $inventoryGroup ){ $this->productOptions[] = ['type' =>'group', 'id' =>$inventoryGroup->id_inventory_group ,'name' =>$inventoryGroup->name ."/Termékcsoport" ]; - } } - + public function attributeLabels() { return [ @@ -293,5 +296,7 @@ class InventoryItemForm extends Model{ ]; } + + } \ No newline at end of file diff --git a/backend/views/inventory-item/create.php b/backend/views/inventory-item/create.php index 16056d1..d5efb0e 100644 --- a/backend/views/inventory-item/create.php +++ b/backend/views/inventory-item/create.php @@ -19,7 +19,7 @@ $options = []; $options['products'] = $model->productOptions; $options['url_product_find'] = Url::toRoute(['product/find']); -$this->registerJs('inventoryItemCreate.init( '. json_encode($options) .' );'); +$this-> registerJs('inventoryItemCreate.init( '. json_encode($options) .' );'); ?>
diff --git a/backend/views/inventory-item/index.php b/backend/views/inventory-item/index.php index a5b2718..cf24c49 100644 --- a/backend/views/inventory-item/index.php +++ b/backend/views/inventory-item/index.php @@ -24,6 +24,7 @@ $this->registerJs('inventoryItemIndex.init( ' . json_encode($options) . ' );'); ?> +