add wate to inventory

This commit is contained in:
2017-04-27 20:53:35 +02:00
parent ec5968511b
commit 567592b73e
6 changed files with 164 additions and 37 deletions

View File

@@ -2,6 +2,7 @@
namespace backend\controllers;
use common\models\Log;
use Yii;
use common\models\Product;
use backend\models\ProductSearch;
@@ -117,8 +118,19 @@ class ProductController extends \backend\controllers\BackendController
$accounts = Account::readAccounts($model->id_account);
$categories = ProductCategory::read($model->id_product_category);
$stockOriginal = $model->stock;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$stockUpdated = $model->stock;
$message = "Update product. Stock: " . $stockOriginal . " -> " . $stockUpdated;
Log::log([
'type' =>Log::$TYPE_CRUD,
'message' => $message,
'id_product' => $model->id_product
]);
return $this->redirect(['view', 'id' => $model->id_product]);
} else {
return $this->render('update', [