Vote count:
0
I am using Larvel 4.2 and thujohn/pdf-l4 plugin.
I have a problem in converting an HTML page to PDF. When i convert an HTML page Everything on the page are displayed except the Morris chart on it.
My Route
Route::post('performanceDetail/preview',[
'as' => 'print.preview',
'uses' => 'PerformanceController@postPerformanceDetails']);
Controller
public function postPerformanceDetails()
{
$data = [
'event' => Input::get('events'),
'start_date' => Input::get('start_date'),
'to_date' => Input::get('to_date'),
];
$start_date = date('Y-m-d H:i:s',strtotime($data['start_date'].'00:00:00'));
$to_date = date('Y-m-d H:i:s',strtotime($data['to_date'].'23:59:59'));
$stats = Performance::where('event_type','=',$data['event'])
->where('campaign_id',Session::get('campaignid'))
->where('created_at', '>=',$start_date)
->where('created_at','<=',$to_date)
->groupBy('perf_date')
->orderBy('perf_date', 'DESC')
->remember(60)
->get([
DB::raw('Date(created_at) as perf_date'),
DB::raw('COUNT(id) as perf_count')
])
->toJSON();
//return $stats;
$campaign = Campaign::find(Session::get('campaignid'));
$list = CategoryList::find($campaign->categorylist_id);
$totalPerformance = TotalPerformance::find(Session::get('totalPerformance'));
//$this->layout->title = "Performance details";
return PDF::load(View::make('performance.show')
->with('stats',$stats)
->with('campaign',$campaign)
->with('list',$list)
->with('start_date',$data['start_date'])
->with('to_date',$data['to_date'])
->with('totalPerformance',$totalPerformance))->show();
}
View
{{-- Form to view performance details --}}
<html lang="en">
<head>
<p align="center">
<b> <font size="5" >Performance report</font></b>
</p>
</head>
<body>
<p align="center">
<font size="4" >{{{$campaign->template->title}}}</font></b>
</p>
<p>
<b>List: </b><font>{{$list->name}} </font>
</p>
<br>
<p>
<b>Total performance</b>
</p>
<p>
<table>
<thead>
<tr>
<th width="100">Campaign</th>
<th width="50" >Sent</th>
<th width="50" >Clicks</th>
<th width="50" >Loads</th>
<th width="50" >Opens</th>
<th width="50" >Views</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center" width="200">{{{$campaign->template->title}}}</td>
<td align="center" width="50">{{$totalPerformance->totalSent }}</td>
<td width="50" align="center">{{$totalPerformance->clicks }}</td>
<td width="50" align="center">{{$totalPerformance->loads }}</td>
<td width="50" align="center">{{$totalPerformance->opens }}</td>
<td width="50" align="center">{{$totalPerformance->views }}</td>
</tr>
</tbody>
</table>
</p>
<br>
<p>
<b>Date</b>
</p>
<p>
From: {{$start_date}} To: {{$to_date}}
</p>
{{-- hosted assets for Morris charts --}}
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css">
{{ HTML::script('../bower_components/jquery/dist/jquery.min.js') }}
{{ HTML::script('../bower_components/raphael/raphael-min.js') }}
{{ HTML::script('../bower_components/morrisjs/morris.min.js') }}
<input type="hidden" name="dataChart" id="dataChart" value="{{{$stats}}}">
<div id="mchart">
</div>
<script type="text/javascript">
$(document).ready(function()
{
var events = $('#dataChart').val();
console.log(events);
var chart = Morris.Bar({
barGap:1,
barSizeRatio:.10,
// ID of the element in which to draw the chart.
element: 'mchart',
// Set initial data (ideally you would provide an array of default data)
data: [0,0],
xkey: 'perf_date',
ykeys: ['perf_count'],
labels: ['Count'],
//barColors: ['#0B62A4','#f75b68','#4DA74D','#646464'],
hideHover: 'auto'
});
chart.setData(JSON.parse(events));
});
</script>
</body>
</html>
I have tried to display this view without conversion, it was successful. But, when executed the above code the Morris Chart is not displayed on PDF.
asked 37 secs ago
Laravel: How to load an HTML page with Morris chart as PDF using thujohn/pdf-l4 plugin?
Aucun commentaire:
Enregistrer un commentaire