add transfer#list pdf download, fix helper#fixascii function

This commit is contained in:
2016-01-06 16:18:15 +01:00
parent 932f071c13
commit 39ae361505
29 changed files with 1519 additions and 373 deletions

View File

@@ -14,6 +14,7 @@ use backend\models\TransferListSearch;
use backend\models\TransferSaleSearch;
use common\models\ProductCategory;
use common\models\Product;
use backend\models\TransferListUserGroupedSearch;
/**
* TransferController implements the CRUD actions for Transfer model.
@@ -28,7 +29,7 @@ class TransferController extends \backend\controllers\BackendController
'rules' => [
// allow authenticated users
[
'actions' => [ 'index','view','summary','list',"sale","sale-pdf" ],
'actions' => [ 'index','view','summary','list',"sale","sale-pdf" ,'list-user-grouped'],
'allow' => true,
'roles' => ['admin','employee','reception'],
],
@@ -75,7 +76,75 @@ class TransferController extends \backend\controllers\BackendController
$searchModel->search(Yii::$app->request->queryParams);
return $this->render('list', [
if ( $searchModel->output == 'pdf'){
$user = User::findOne(\Yii::$app->user->id);
$mpdf=new \mPDF('utf-8', 'A4-L');
$fn = "";
$ov = '_total_content_pdf';
$dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username;
$interval="";
$account = "";
$currentUser= "";
if ( isset($searchModel->currentAccount) ){
$account =( "_kassza_".$searchModel->currentAccount->name);
}
if ( isset($searchModel->currentUser) ){
$currentUser = ( "_felhasznalo_".$searchModel->currentUser->username);
}
if ( isset($searchModel->timestampStart) ){
$interval .="_tol_". \Yii::$app->formatter->asDatetime($searchModel->timestampStart,'yyyyMMdd_HHmm');
}
if ( isset($searchModel->timestampEnd) ){
$interval .="_ig_". \Yii::$app->formatter->asDatetime($searchModel->timestampEnd,'yyyyMMdd_HHmm');
}
if ( $searchModel->outputView == 'easy'){
$ov = '_total_easy';
$fn="napi_bevetelek_egyszeru";
}else if ( $searchModel->outputView == 'medium'){
$ov = '_total_medium';
$fn="napi_bevetelek_kozepes";
}else if ( $searchModel->outputView == 'detailed'){
$ov = '_total_detailed';
$fn="napi_bevetelek_reszletes";
}else{
$ov = '_total_content_pdf';
$fn="napi_bevetelek.teljes";
}
$fn = $fn. $interval . $dt .$account .$currentUser. ".pdf";
$mpdf->useSubstitutions=false;
$mpdf->simpleTables = true;
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
$mpdf->setFooter('{PAGENO} / {nb}');
$mpdf->WriteHTML($this->renderPartial($ov, [
'searchModel' => $searchModel,
]));
$mpdf->Output($fn, 'D');
exit;
}else{
return $this->render('list', [
'searchModel' => $searchModel,
]);
}
}
/**
* Lists all Transfer models.
* @return mixed
*/
public function actionListUserGrouped()
{
$searchModel = new TransferListUserGroupedSearch();
$searchModel->accounts = Account::read();
$searchModel->users = User::read();
$searchModel->search(Yii::$app->request->queryParams);
return $this->render('list_user_grouped', [
'searchModel' => $searchModel,
]);
@@ -88,6 +157,7 @@ class TransferController extends \backend\controllers\BackendController
public function actionSale()
{
$searchModel = new TransferSaleSearch();
$searchModel->mode = 'admin';
$searchModel->accounts = Account::read();
$searchModel->users = User::read();
$searchModel->productCategories = ProductCategory::read();
@@ -104,6 +174,7 @@ class TransferController extends \backend\controllers\BackendController
public function actionSalePdf(){
$searchModel = new TransferSaleSearch();
$searchModel->mode = 'admin';
$searchModel->accounts = Account::read();
$searchModel->users = User::read();
$searchModel->productCategories = ProductCategory::read();