add multiple detsta upload

This commit is contained in:
Roland Schneider 2016-04-30 12:32:28 +02:00
parent 776e0ea3e0
commit 6458a72936
5 changed files with 80 additions and 20 deletions

View File

@ -6,6 +6,8 @@ use yii\base\Model;
use yii\web\UploadedFile; use yii\web\UploadedFile;
use common\components\giro\GiroDETSTA; use common\components\giro\GiroDETSTA;
use common\models\Ugiro; use common\models\Ugiro;
use common\components\DetStatProcessor;
use common\components\Helper;
class DestaUploadForm extends Model class DestaUploadForm extends Model
{ {
@ -41,26 +43,62 @@ class DestaUploadForm extends Model
$this->koteg = $koteg; $this->koteg = $koteg;
if (!isset($koteg)){ if (!isset($koteg)){
$this->addError($attribute,"Nincs ilyen köteg! ( Datum: $datum, Sorszam: $number )"); $this->addError($attribute,"Nincs ilyen köteg! ( Datum: $datum, Sorszam: $number )");
}else{
if ( $koteg->status != Ugiro::$STATUS_SENT ){
$idKoteg = $this->koteg->id_ugiro;
$this->addError($attribute,"A köteg detsta fájl-ja már fel van töltve !( Köteg azonosító: $idKoteg )");
}
} }
// else{
// if ( $koteg->status != Ugiro::$STATUS_SENT ){
// $idKoteg = $this->koteg->id_ugiro;
// $this->addError($attribute,"A köteg detsta fájl-ja már fel van töltve !( Köteg azonosító: $idKoteg )");
// }
// }
} }
} }
// public function saveMessageDetsta($filename){
// $uzenetSzoveg = $this->readDetstaUzenet($filename);
// $saver = new DetStaDBSave(
// [
// 'giroDETSTA' => $this->detstatUzenet,
// 'koteg' => $this->koteg,
// 'idUser' =>\Yii::$app->user->id
// ]);
// $saver->run();
// }
// public function readDetstaUzenet($filename){
// // $filename = \Yii::getAlias("@webroot") ."/" .$this->koteg->desta_path;
// $content = file_get_contents($filename);
// return GiroDETSTA::parse($content);
// }
public function upload() public function upload()
{ {
if ($this->validate()) { if ($this->validate()) {
$path = 'giro/valasz/' . $this->destaFile->baseName . '.' . $this->destaFile->extension; $path = 'giro/valasz/' . $this->destaFile->baseName . '.' . $this->destaFile->extension;
$this->destaFile->saveAs( $path ); $this->destaFile->saveAs( $path );
$this->koteg->desta_path = $path;
$this->koteg->status = Ugiro::$STATUS_RECIEVED;
$this->koteg->save(false); set_time_limit ( 1200 ); // 20 perc
$processor = new DetStatProcessor( [
'koteg' => $this->koteg,
'path' => $path
] );
$processor->run ();
Helper::flash("success", "Detsta fájl feldolgozva!");
return true; return true;
} else { } else {
return false; return false;

View File

@ -71,14 +71,14 @@ $attributes = [
if ( $model->status == Ugiro::$STATUS_RECIEVED || $model->status == Ugiro::$STATUS_FINISHED ){ // if ( $model->status == Ugiro::$STATUS_RECIEVED || $model->status == Ugiro::$STATUS_FINISHED ){
$attributes[] = [ // $attributes[] = [
'attribute' => 'desta_path', // 'attribute' => 'desta_path',
'label' => 'Detsta Fájl', // 'label' => 'Detsta Fájl',
'value' => Html::a( "Letöltés" , Url::base() ."/". $model->desta_path , ['target' =>'_blank' ,'download' =>'CS-BESZED.' .$model->id_ugiro ] ), // 'value' => Html::a( "Letöltés" , Url::base() ."/". $model->desta_path , ['target' =>'_blank' ,'download' =>'CS-BESZED.' .$model->id_ugiro ] ),
'format' => 'raw' // 'format' => 'raw'
]; // ];
} // }
?> ?>
@ -100,7 +100,14 @@ $attributes = [
'label' => 'Létrehozva' 'label' => 'Létrehozva'
], ],
[ [
'class' => ActionColumn::className() 'class' => ActionColumn::className() ,
'template' =>'{view}',
'urlCreator' => function ($action, $model, $key, $index){
if ($action == 'view' ){
return Url::toRoute(['message-detsta/view','id' => $model->id_message]);
}
return null;
}
] ]
] ]
@ -115,7 +122,7 @@ $attributes = [
<div class="btns"> <div class="btns">
<?php <?php
if ( $model->status == Ugiro::$STATUS_RECIEVED ){ if ( $model->status == Ugiro::$STATUS_RECIEVED ){
echo Html::a("DetSta Fájl Feldoglozás",['view', 'id' => $model->id_ugiro] ,['data-method' =>'post', 'class' => 'btn btn-danger']); //echo Html::a("DetSta Fájl Feldoglozás",['view', 'id' => $model->id_ugiro] ,['data-method' =>'post', 'class' => 'btn btn-danger']);
} }
echo Html::a("Megbízások a kötegben",['ticket-installment-request/index', 'TicketInstallmentRequestSearch[id_ugiro]' => $model->id_ugiro] ,[ 'class' => 'btn btn-primary']); echo Html::a("Megbízások a kötegben",['ticket-installment-request/index', 'TicketInstallmentRequestSearch[id_ugiro]' => $model->id_ugiro] ,[ 'class' => 'btn btn-primary']);
echo Html::a("PDF", Url::current(['output' => 'pdf']) ,[ 'class' => 'btn btn-primary']); echo Html::a("PDF", Url::current(['output' => 'pdf']) ,[ 'class' => 'btn btn-primary']);

View File

@ -36,6 +36,8 @@ class DetStaDBSave extends Object
/**messagedetsta lab*/ /**messagedetsta lab*/
public $messageLab; public $messageLab;
public $path;
/**messagedetsta tetelek*/ /**messagedetsta tetelek*/
public $messageTetelek = []; public $messageTetelek = [];
@ -56,6 +58,7 @@ class DetStaDBSave extends Object
protected function saveMessageDetsta( ) { protected function saveMessageDetsta( ) {
$this->message = new MessageDetsta(); $this->message = new MessageDetsta();
$this->message->id_user = $this->idUser; $this->message->id_user = $this->idUser;
$this->message->path = $this->path;
if ( isset( $this->koteg ) ){ if ( isset( $this->koteg ) ){
$this->message->id_ugiro = $this->koteg->id_ugiro; $this->message->id_ugiro = $this->koteg->id_ugiro;
} }

View File

@ -24,6 +24,8 @@ class DetStatProcessor extends Object{
/**aktuális koteg, config paraméterként kapju*/ /**aktuális koteg, config paraméterként kapju*/
public $koteg; public $koteg;
public $path;
public $idKoteg; public $idKoteg;
public $detstatUzenet; public $detstatUzenet;
public $megbizasok; public $megbizasok;
@ -44,6 +46,7 @@ class DetStatProcessor extends Object{
$saver = new DetStaDBSave( $saver = new DetStaDBSave(
[ [
'giroDETSTA' => $this->detstatUzenet, 'giroDETSTA' => $this->detstatUzenet,
'path' => $this->path,
'koteg' => $this->koteg, 'koteg' => $this->koteg,
'idUser' =>\Yii::$app->user->id 'idUser' =>\Yii::$app->user->id
]); ]);
@ -71,7 +74,7 @@ class DetStatProcessor extends Object{
public function readDetstaUzenet(){ public function readDetstaUzenet(){
$filename = \Yii::getAlias("@webroot") ."/" .$this->koteg->desta_path; $filename = \Yii::getAlias("@webroot") ."/" .$this->path;
$content = file_get_contents($filename); $content = file_get_contents($filename);
$this->detstatUzenet = GiroDETSTA::parse($content); $this->detstatUzenet = GiroDETSTA::parse($content);

View File

@ -3,6 +3,7 @@ namespace common\models;
use Yii; use Yii;
use yii\base\Model; use yii\base\Model;
use yii\helpers\VarDumper;
/** /**
* Login form * Login form
@ -68,6 +69,8 @@ class LoginForm extends Model
if ($this->validate()) { if ($this->validate()) {
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0); return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
} else { } else {
\Yii::error("Belépés - validáció sikertelen");
\Yii::error( $this->getErrors());
return false; return false;
} }
} }
@ -80,10 +83,12 @@ class LoginForm extends Model
protected function getUser() protected function getUser()
{ {
if ($this->_user === null) { if ($this->_user === null) {
\Yii::info("admin login - find user by name...");
$this->_user = User::findByUsername($this->username); $this->_user = User::findByUsername($this->username);
} }
if ( $this->_user != null ){ if ( $this->_user != null ){
\Yii::info("Felhasználónév rendben...");
if ( $this->roles != null ){ if ( $this->roles != null ){
$canLogin = false; $canLogin = false;
foreach ($this->roles as $role){ foreach ($this->roles as $role){
@ -91,10 +96,14 @@ class LoginForm extends Model
} }
if ( !$canLogin ){ if ( !$canLogin ){
\Yii::info("user ".$this->_user->username." has no permission to login to administration area!"); \Yii::error("user ".$this->_user->username." has no permission to login to administration area!");
$this->_user = null; $this->_user = null;
}else{
\Yii::info("user ".$this->_user->username." has permission to login to administration area!");
} }
} }
}else{
\Yii::error("Felhasználó nem található: " .$this->username);
} }
return $this->_user; return $this->_user;