add card.flag implementation

This commit is contained in:
2016-03-09 20:16:19 +01:00
parent 1d3c476476
commit 42c326f407
25 changed files with 497 additions and 80 deletions

View File

@@ -13,6 +13,7 @@ use backend\models\CardImportRfidForm;
use yii\web\UploadedFile;
use common\components\Helper;
use backend\models\CardInsertForm;
use common\models\Ticket;
/**
* CardController implements the CRUD actions for Card model.
@@ -32,7 +33,8 @@ class CardController extends \backend\controllers\BackendController {
'update',
'list' ,
'import-rfid',
'insert'
'insert',
'recalculate',
],
'allow' => true,
'roles' => [
@@ -349,4 +351,21 @@ class CardController extends \backend\controllers\BackendController {
}
public function actionRecalculate(){
if (Yii::$app->request->isPost) {
$connection = \Yii::$app->db;
$command = $connection->createCommand( Ticket::$SQL_UPDATE );
$result = $command->execute();
\Yii::info("Tickets updated: " . $result );
\Yii::$app->session->setFlash('success', 'Módosított bérletek száma: ' . $result);
}
return $this->render("recalculate");
}
}

View File

@@ -8,6 +8,15 @@ use backend\models\InventorySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\InventoryItem;
use yii\data\ActiveDataProvider;
use common\components\Helper;
use common\models\User;
use common\models\Product;
use common\models\InventoryGroup;
use yii\db\Expression;
use yii\db\Query;
use backend\models\InventoryItemSearch;
/**
* InventoryController implements the CRUD actions for Inventory model.
@@ -48,8 +57,17 @@ class InventoryController extends Controller
*/
public function actionView($id)
{
$inventory = $this->findModel($id);
$searchModel = new InventoryItemSearch(['inventory' => $inventory]);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$query = new Query();
return $this->render('view', [
'model' => $this->findModel($id),
'model' => $inventory,
'dataProvider' => $dataProvider
]);
}

View File

@@ -9,6 +9,7 @@ use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use backend\models\InventoryItemForm;
use common\models\Inventory;
/**
* InventoryItemController implements the CRUD actions for InventoryItem model.
@@ -31,12 +32,19 @@ class InventoryItemController extends Controller
* Lists all InventoryItem models.
* @return mixed
*/
public function actionIndex()
public function actionIndex($id)
{
$searchModel = new InventoryItemSearch();
$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);
return $this->render('index', [
'model' => $inventory,
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
@@ -68,7 +76,7 @@ class InventoryItemController extends Controller
$model->read();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_inventory_item]);
return $this->redirect(['inventory-item/index', 'id' => $model->inventory->id_inventory]);
} else {
return $this->render('create', [
'model' => $model,
@@ -103,9 +111,11 @@ class InventoryItemController extends Controller
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
$item = $this->findModel($id);
$id_inventory = $item->id_inventory;
$item->delete();
return $this->redirect(['index']);
return $this->redirect(['index', 'id' => $id_inventory]);
}
/**