Report export

This commit is contained in:
Hillel Coren 2017-08-03 12:18:36 +03:00
parent 5f01112498
commit 0b81c3299d
4 changed files with 18 additions and 12 deletions

View File

@ -570,6 +570,9 @@ if (! defined('APP_NAME')) {
]; ];
define('CACHED_TABLES', serialize($cachedTables)); define('CACHED_TABLES', serialize($cachedTables));
// Fix for mPDF: https://github.com/kartik-v/yii2-mpdf/issues/9
define('_MPDF_TTFONTDATAPATH', storage_path('framework/cache/'));
// TODO remove these translation functions // TODO remove these translation functions
function uctrans($text) function uctrans($text)
{ {

View File

@ -185,7 +185,7 @@ class ReportController extends BaseController
$sheet->cells('A1:'.Utils::num2alpha(count($columns_labeled)-1).'1', function($cells) { $sheet->cells('A1:'.Utils::num2alpha(count($columns_labeled)-1).'1', function($cells) {
$cells->setBackground('#777777'); $cells->setBackground('#777777');
$cells->setFontColor('#FFFFFF'); $cells->setFontColor('#FFFFFF');
$cells->setFontSize(14); $cells->setFontSize(13);
$cells->setFontFamily('Calibri'); $cells->setFontFamily('Calibri');
$cells->setFontWeight('bold'); $cells->setFontWeight('bold');
}); });

View File

@ -1,4 +1,5 @@
<?php <?php
//https://github.com/PHPOffice/PHPExcel/issues/556#issuecomment-216722159 //https://github.com/PHPOffice/PHPExcel/issues/556#issuecomment-216722159
switch (PHP_OS) { switch (PHP_OS) {
case 'WINNT': case 'WINNT':
@ -323,7 +324,7 @@ return array(
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
*/ */
'DomPDF' => array( 'DomPDF' => array(
'path' => base_path('vendor/dompdf/dompdf/') 'path' => base_path('vendor/dompdf/dompdf/'),
), ),
/* /*

View File

@ -78,7 +78,8 @@
{!! Former::open()->addClass('report-form')->rules(['start_date' => 'required', 'end_date' => 'required']) !!} {!! Former::open()->addClass('report-form')->rules(['start_date' => 'required', 'end_date' => 'required']) !!}
<div style="display:none"> <div style="display:none">
{!! Former::text('action') !!} {!! Former::text('action') !!}
{!! Former::text('format') !!}
</div> </div>
{!! Former::populateField('start_date', $startDate) !!} {!! Former::populateField('start_date', $startDate) !!}
@ -157,13 +158,13 @@
<center> <center>
{!! Former::select('format') {!! DropdownButton::primary(trans('texts.export'))
->label(trans('texts.format_export')) ->large()
->options(['csv' => 'CSV', 'pdf' => 'PDF', 'xlsx' => 'Excel']) !!} ->withContents([
{!! Button::primary(trans('texts.export')) ['url' => 'javascript:onExportClick("csv")', 'label' => 'CSV'],
->withAttributes(array('onclick' => 'onExportClick()')) ['url' => 'javascript:onExportClick("xlsx")', 'label' => 'XLSX'],
->appendIcon(Icon::create('export')) ['url' => 'javascript:onExportClick("pdf")', 'label' => 'PDF'],
->large() !!} ]) !!}
{!! Button::success(trans('texts.run')) {!! Button::success(trans('texts.run'))
->withAttributes(array('id' => 'submitButton')) ->withAttributes(array('id' => 'submitButton'))
->submit() ->submit()
@ -256,8 +257,9 @@
<script type="text/javascript"> <script type="text/javascript">
function onExportClick() { function onExportClick(format) {
$('#action').val('export'); $('#action').val('export');
$('#format').val(format);
$('#submitButton').click(); $('#submitButton').click();
$('#action').val(''); $('#action').val('');
} }
@ -368,4 +370,4 @@
keyboardNavigation: false keyboardNavigation: false
}); });
@stop @stop