add inventory admin fix, add procurement update
This commit is contained in:
@@ -11,6 +11,8 @@ use yii\filters\VerbFilter;
|
||||
use common\models\User;
|
||||
use yii\db\Query;
|
||||
use backend\models\InventoryItemSearch;
|
||||
use common\models\InventoryItem;
|
||||
use common\components\Helper;
|
||||
|
||||
/**
|
||||
* InventoryController implements the CRUD actions for Inventory model.
|
||||
@@ -23,7 +25,7 @@ class InventoryController extends Controller
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
'close' => ['post'],
|
||||
],
|
||||
],
|
||||
];
|
||||
@@ -55,12 +57,13 @@ class InventoryController extends Controller
|
||||
$model = new Inventory();
|
||||
$user = User::findOne(\Yii::$app->user->id);
|
||||
|
||||
|
||||
$model->status = Inventory::$STATUS_OPEN;
|
||||
|
||||
$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(['view', 'id' => $model->id_inventory]);
|
||||
return $this->redirect(['inventory-item/index', 'id' => $model->id_inventory]);
|
||||
} else {
|
||||
}
|
||||
return $this->render('create', [
|
||||
@@ -69,6 +72,22 @@ class InventoryController extends Controller
|
||||
}
|
||||
|
||||
|
||||
public function actionClose($id){
|
||||
$model = $this->findModel($id);
|
||||
|
||||
$model->status = Inventory::$STATUS_CLOSED;
|
||||
|
||||
$model->save(false);
|
||||
|
||||
$db = \Yii::$app->db;
|
||||
$command = $db->createCommand(InventoryItem::$UPDATE_COUNT,[':id_inventory' => $id]);
|
||||
$command->execute();
|
||||
|
||||
Helper::flash("success", "Leltár lezárva, leltározott termékek darabszáma felülírva!");
|
||||
|
||||
return $this->redirect(['inventory-item/index','id' => $model->id_inventory]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds the Inventory model based on its primary key value.
|
||||
|
||||
Reference in New Issue
Block a user