186 lines
4.7 KiB
PHP
186 lines
4.7 KiB
PHP
<?php
|
|
|
|
namespace backend\controllers;
|
|
|
|
use Yii;
|
|
use common\models\Ugiro;
|
|
use backend\models\UgiroSearch;
|
|
use yii\web\Controller;
|
|
use yii\web\NotFoundHttpException;
|
|
use yii\filters\VerbFilter;
|
|
use common\components\DetStatProcessor;
|
|
use backend\models\DestaUploadForm;
|
|
use yii\web\UploadedFile;
|
|
|
|
/**
|
|
* UgiroController implements the CRUD actions for Ugiro model.
|
|
*/
|
|
class UgiroController extends Controller
|
|
{
|
|
public function behaviors()
|
|
{
|
|
return [
|
|
'verbs' => [
|
|
'class' => VerbFilter::className(),
|
|
'actions' => [
|
|
'delete' => ['post'],
|
|
],
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Lists all Ugiro models.
|
|
* @return mixed
|
|
*/
|
|
public function actionIndex()
|
|
{
|
|
$searchModel = new UgiroSearch();
|
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
|
|
|
return $this->render('index', [
|
|
'searchModel' => $searchModel,
|
|
'dataProvider' => $dataProvider,
|
|
]);
|
|
}
|
|
/**
|
|
* Lists all Ugiro models.
|
|
* @return mixed
|
|
*/
|
|
public function actionItems($id)
|
|
{
|
|
$searchModel = new UgiroSearch();
|
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
|
|
|
return $this->render('index', [
|
|
'searchModel' => $searchModel,
|
|
'dataProvider' => $dataProvider,
|
|
]);
|
|
}
|
|
|
|
public function actionActivate(){
|
|
|
|
}
|
|
|
|
/**
|
|
* Displays a single Ugiro model.
|
|
* @param integer $id
|
|
* @return mixed
|
|
*/
|
|
public function actionView($id)
|
|
{
|
|
$model = $this->findModel($id);
|
|
if (Yii::$app->request->isPost) {
|
|
if ($model->status == Ugiro::$STATUS_RECIEVED){
|
|
set_time_limit(1200);//20 perc
|
|
$processor = new DetStatProcessor(
|
|
['koteg' => $model]
|
|
);
|
|
$processor->run();
|
|
}else{
|
|
\Yii::$app->session->setFlash('danger','Nem lehet futtatni a fájlt');
|
|
\Yii::error("a koteg státusza nem STATUS_RECIEVED. A koteg azonosíótja:" . $model->id_ugiro );
|
|
}
|
|
}
|
|
|
|
return $this->render('view', [
|
|
'model' => $this->findModel($id),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Creates a new Ugiro model.
|
|
* If creation is successful, the browser will be redirected to the 'view' page.
|
|
* @return mixed
|
|
*/
|
|
public function actionCreate()
|
|
{
|
|
$model = new Ugiro();
|
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
|
return $this->redirect(['view', 'id' => $model->id_ugiro]);
|
|
} else {
|
|
return $this->render('create', [
|
|
'model' => $model,
|
|
]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Updates an existing Ugiro model.
|
|
* If update is successful, the browser will be redirected to the 'view' page.
|
|
* @param integer $id
|
|
* @return mixed
|
|
*/
|
|
public function actionUpdate($id)
|
|
{
|
|
$model = $this->findModel($id);
|
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
|
return $this->redirect(['view', 'id' => $model->id_ugiro]);
|
|
} else {
|
|
return $this->render('update', [
|
|
'model' => $model,
|
|
]);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Deletes an existing Ugiro model.
|
|
* If deletion is successful, the browser will be redirected to the 'index' page.
|
|
* @param integer $id
|
|
* @return mixed
|
|
*/
|
|
public function actionDelete($id)
|
|
{
|
|
$this->findModel($id)->delete();
|
|
|
|
return $this->redirect(['index']);
|
|
}
|
|
|
|
public function actionDetsta(){
|
|
|
|
$ugiro = Ugiro::findOne(31);
|
|
$model = new DetStatProcessor(
|
|
['koteg' => $ugiro]
|
|
);
|
|
|
|
|
|
return $this->render('detsta', [
|
|
'model' => $model,
|
|
]);
|
|
}
|
|
|
|
public function actionUpload(){
|
|
$model = new DestaUploadForm();
|
|
|
|
if (Yii::$app->request->isPost) {
|
|
$model->destaFile = UploadedFile::getInstance($model, 'destaFile');
|
|
if ($model->upload()) {
|
|
// file is uploaded successfully
|
|
return $this->redirect(['view', 'id' => $model->koteg->id_ugiro]);
|
|
}
|
|
}
|
|
|
|
return $this->render('upload', ['model' => $model]);
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* Finds the Ugiro model based on its primary key value.
|
|
* If the model is not found, a 404 HTTP exception will be thrown.
|
|
* @param integer $id
|
|
* @return Ugiro the loaded model
|
|
* @throws NotFoundHttpException if the model cannot be found
|
|
*/
|
|
protected function findModel($id)
|
|
{
|
|
if (($model = Ugiro::findOne($id)) !== null) {
|
|
return $model;
|
|
} else {
|
|
throw new NotFoundHttpException('The requested page does not exist.');
|
|
}
|
|
}
|
|
}
|