Skip to content

Commit

Permalink
Dev: inserted the required js-libraries and started on wrinting workers
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Nov 24, 2016
1 parent 8165e5a commit 5ca3f0f
Show file tree
Hide file tree
Showing 7 changed files with 17,200 additions and 1 deletion.
8 changes: 8 additions & 0 deletions application/config/third_party.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,14 @@
'jquery',
'bootstrap'
)
),

'jspdf' => array(
'basePath' => 'third_party.jspdf',
'js' => array(
'jspdf.debug.js'
// 'jspdf.min.js'
)
)


Expand Down
2 changes: 2 additions & 0 deletions application/controllers/admin/statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ public function simpleStatistics($surveyid)
//Call the javascript file
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'statistics.js');
$this->registerScriptFile( 'ADMIN_SCRIPT_PATH', 'json-js/json2.min.js');
yii::app()->clientScript->registerPackage('jspdf');
echo $this->_renderWrappedTemplate('export', 'statistics_user_view', $aData);
}

Expand All @@ -829,6 +830,7 @@ public function setIncompleteanswers()
protected function _renderWrappedTemplate($sAction = 'export', $aViewUrls = array(), $aData = array())
{
yii::app()->clientScript->registerPackage('bootstrap-switch');
yii::app()->clientScript->registerPackage('jspdf');

$aData['menu']['closeurl'] = Yii::app()->request->getUrlReferrer(Yii::app()->createUrl("/admin/survey/sa/view/surveyid/".$aData['surveyid']) );

Expand Down
1 change: 1 addition & 0 deletions application/core/LSYii_Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public function __construct($aApplicationConfig = null)
{
$this->setConfig($key, $value);
}
App()->getAssetManager()->linkAssets = true;
// Asset manager path can only be set after App was constructed because it relies on App()
App()->getAssetManager()->setBaseUrl($settings['tempurl']. '/assets');
App()->getAssetManager()->setBasePath($settings['tempdir'] . '/assets');
Expand Down
6 changes: 5 additions & 1 deletion application/views/admin/export/statistics_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

<!-- Javascript variables -->
<?php $this->renderPartial('/admin/export/statistics_subviews/_statistics_view_scripts', array('sStatisticsLanguage'=>$sStatisticsLanguage, 'surveyid'=>$surveyid, 'showtextinline'=>$showtextinline)) ; ?>

<div class="container-center">
<div class="row">
<div class="col-sm-4 col-sm-offset-4 col-xs-12"><button id="action_js_export_to_pdf" class="btn btn-primary btn-block"><?php eT("Export to PDF");?></button></div>
</div>
</div>
<div id='statisticsview' class='side-body <?php echo getSideBodyClass(false); ?>'>
<h3>
<span class="glyphicon glyphicon-stats"></span> &nbsp;&nbsp;&nbsp;
Expand Down
13 changes: 13 additions & 0 deletions scripts/admin/statistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -729,3 +729,16 @@ function changeGraphType (cmd, id) {
});

}

$(document).ready(function(){
$('body').on('click','#action_js_export_to_pdf', function(){
var doc = new jsPDF();
console.log("Getting the pdf");
$('#statisticsview').find('.statisticstable').each(function(i, table){
doc.addPage();
doc.fromHTML(table, 210, 297, {width: 590});

});
var dataurl = doc.output('dataurlnewwindow');
});
});

0 comments on commit 5ca3f0f

Please sign in to comment.