Where clause get nothing & (local.ERROR: Undefined variable: meeting) even if defined - php

Instructor or Customer want to join a meeting through jitsi-meet which one of admin creates before. But when someone tried to join, this ->
"local.ERROR: Undefined variable: meeting"
error showing.
I var_dump $jitsimeetings from where clause but seeing nothing in it. some one help me please.
#Model
<?php
namespace App;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class JitsiMeeting extends Model
{
protected $table = 'jitsimeetings';
protected $fillable = ['meeting_id', 'owner_id', 'user_id','meeting_title', 'start_time', 'end_time','duration', 'jitsi_url', 'course_id', 'link_by', 'type', 'agenda', 'image'];
public function user()
{
return $this->belongsTo('App\User','user_id','id');
}
public function courses()
{
return $this->belongsTo('App\Course','course_id','id');
}
}
#Controller
public function joinMeetup($meetingid){
$userid = Auth::user()->id;
$jitsimeetings = JitsiMeeting::where([
['user_id', '=', $userid],
['meeting_id', '=', $meetingid]
])->get();
return view('admin.jitsimeeting.jitsimeet', compact('jitsimeetings'));
}
#View
<?php foreach($jitsimeetings as $key => $meeting){} ?>
<div class="container-fluid">
<div id='meet'></div>
</div>
<script src='https://meet.jit.si/external_api.js'></script>
<!-- <script src='https://localhost/external_api.js'></script> -->
<script>
const domain = 'meet.jit.si';
const options = {
roomName: <?php echo $meeting->meeting_id; ?>,
width: 1250,
height: 700,
parentNode: document.querySelector('#meet'),
userInfo: {
displayName: '<?php echo $meeting->meeting_title; ?>'
},
// jwt: '<jwt_token>',
configOverwrite:{
// doNotStoreRoom: true,
// startVideoMuted: 0,
startWithVideoMuted: true,
startWithAudioMuted: true,
// liveStreamingEnabled: true
// desktopSharingFrameRate: {
// min: 5,
// max: 5
// },
enableWelcomePage: false,
prejoinPageEnabled: false,
enableSaveLogs: false,
enableNoisyMicDetection: true
// disableRemoteMute: false
},
interfaceConfigOverwrite: {
// filmStripOnly: false,
SHOW_JITSI_WATERMARK: false,
SHOW_WATERMARK_FOR_GUESTS: false,
SHOW_BRAND_WATERMARK: false,
SHOW_POWERED_BY: false
// DEFAULT_REMOTE_DISPLAY_NAME: 'New User'
// TOOLBAR_BUTTONS: []
}
};
const api = new JitsiMeetExternalAPI(domain, options);
api.executeCommand('subject', '<?php echo $meeting->meeting_title; ?>');
</script>

You have closed foreach at the begining so
<!-- <script src='https://localhost/external_api.js'></script> -->
<script>
#foreach($jitsimeetings as $key => $meeting)
<div class="container-fluid">
<div id='meet'></div>
</div>
const domain = 'meet.jit.si';
const options = {
roomName:'{{$meeting->meeting_id}}' ,
width: 1250,
height: 700,
parentNode: document.querySelector('#meet'),
userInfo: {
displayName: '{{$meeting->meeting_title}}'
},
// jwt: '<jwt_token>',
configOverwrite:{
// doNotStoreRoom: true,
// startVideoMuted: 0,
startWithVideoMuted: true,
startWithAudioMuted: true,
// liveStreamingEnabled: true
// desktopSharingFrameRate: {
// min: 5,
// max: 5
// },
enableWelcomePage: false,
prejoinPageEnabled: false,
enableSaveLogs: false,
enableNoisyMicDetection: true
// disableRemoteMute: false
},
interfaceConfigOverwrite: {
// filmStripOnly: false,
SHOW_JITSI_WATERMARK: false,
SHOW_WATERMARK_FOR_GUESTS: false,
SHOW_BRAND_WATERMARK: false,
SHOW_POWERED_BY: false
// DEFAULT_REMOTE_DISPLAY_NAME: 'New User'
// TOOLBAR_BUTTONS: []
}
};
const api = new JitsiMeetExternalAPI(domain, options);
api.executeCommand('subject', '{{$meeting->meeting_title}}');
</script>
#endforeach

Related

Laravel 9: Converting image upload action to array for multiple files uploading

I have an action class that is reusable:
class UploadImageAction implements UploadImageContract
{
public function handle(Request $request, $imageProperty, $image, $imageDir)
{
if ($request->hasFile($imageProperty)) {
// Handle uploading lf_image
if (!is_null($image) && Storage::exists($image)) {
// Throw exceptions here
Storage::delete($image);
}
// Throw exceptions here
return $request->file($imageProperty)->store($imageDir);
}
}
}
I resolve() this class within a Service class, handleAttachments() method:
public function handleAttachments($request, $report)
{
// Handle Attachments
$uploadImageAction = resolve(UploadImageAction::class);
// Handle attachment action
if($request->file('attachment')) {
$report->attachment = $uploadImageAction->handle($request, 'attachment', $report->attachment, 'report/attachments');
}
return $report;
}
It works with only one file/image, how can this upload action be converted to array?
I have a code block but it's not as clean:
$image = [];
if($files = $request->file('attachment')) {
foreach($files as $file) {
$image_name = md5(rand(1000, 10000));
$ext = strtolower($file->getClientOriginalExtension());
$image_full_name = $image_name . '.' . $ext;
$upload_path = 'public/app/reports/attachments/';
$image_url = $upload_path . $image_full_name;
$file->move($upload_path, $image_name);
$image[] = $image_url;
implode('|', $image);
}
}
I am integrating Uppy which requires this kind of conversion. Below is the HTML used:
<div class="col-md-12">
<div class="text-center">
<h3 class="fw-bold required">Attachments</h3>
<p class="text-muted">Upload images related to the case</p>
</div>
<div class="DashboardContainer"></div>
</div>
Uppy configurations for .DashboardContainer class:
const uppy = new Uppy.Uppy({
autoProceed: false,
allowMultipleUploadBatches: true,
debug: true,
restrictions: {
maxFileSize: 10000000,
maxNumberOfFiles: 10,
minNumberOfFiles: 1,
allowedFileTypes: ['image/*', 'video/*'],
},
});
uppy.use(Uppy.Dashboard, {
id: 'dashboard',
trigger: null,
inline: true,
showLinkToFileUploadResult: true,
target: '.DashboardContainer',
replaceTargetContent: true,
showProgressDetails: true,
height: 470,
note: 'Images and videos only, you can upload up to 10 files.',
metaFields: [
{ id: 'name', name: 'Name', placeholder: 'file name' },
{ id: 'caption', name: 'Caption', placeholder: 'Describe what the image is about' }
],
browserBackButtonClose: false,
});
uppy.use(Uppy.Form, {
target: '#reportsForm',
addResultToForm: true,
resultName: 'uppyResult',
getMetaFromForm: true,
submitOnSuccess: false,
triggerUploadOnSubmit: false,
});
uppy.use(Uppy.XHRUpload, {
endpoint: './create/new',
limit: 10,
formData: true,
fieldName: 'attachment[]',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});

Why can't Fullcalendar show my data using Laravel Eloquent and jquery?

I've been having trouble with Full Calendar. I already tried different approaches but to no avail. The json response doesn't shows up in the calendar.
View:
<div class="col-lg-12 col-md-12">
<div id="calendar">
</div>
</div>
Controller:
public function calendar(Request $request){
if($request->ajax()){
$data= Table::where('id',Auth::user()->id)
->where('DateFrom','>',$request->start)
->where('DateTo','<',$request->end)
->get();
return response()->json($data);
}
}
Route:
Route::get('/calendar', [CalendarController::class, 'calendar'])->name('calendar');
Script (mix):
$('#calendar').fullCalendar({
events: 'calendar',
eventColor: '#378006',
displayEventTime: true,
eventRender: function (event, element, view) {
if (event.allDay === 'true') {
event.allDay = true;
} else {
event.allDay = false;
}
},
selectable: true,
selectHelper: true,
})
There are no errors, the data is also being fetched but the problem is the calendar can't render it. May I ask is there any problem with this? Do I need to actually create a partial view for this and then include it to another blade file?
The problem was that I was fetching a different type of date which doesn't match up with the dates from the Fullcalendar. So to show/highlight those dates I did this.
Controller:
public function calendar(Request $request){
if($request->ajax()){
$event= Table::where('id',Auth::user()->id)
->where('DateFrom','>',date('Y-m-d',$request->start)) //converts date
->where('DateTo','<',date('Y-m-d',$request->end)) //converts date
->get();
$data = [];
foreach($event as $row){
$data[] = [
'title' => $row->title,
'start' => date(DATE_ISO8601,strtotime($row->DateFrom)),
'end' => date(DATE_ISO8601,strtotime($row->DateTo))
];
}
return response()->json(collect($data));
}
return view('partials._calendar-details',compact('data'));
}
and then for my script:
$('#calendar').fullCalendar({
// events: 'calendar',
eventColor: '#378006',
displayEventTime: false,
eventSources: [
{
events: function(start, end, timezone, callback ){
$.ajax({
url: '/calendar',
type: 'GET',
data: {
// our hypothetical feed requires UNIX timestamps
start: start.unix(),
end: end.unix()
},
dataType: 'json',
success: function(res) {
var events = [];
for (var i = 0; i < res.length; i++){
console.log(res[0].title);
events.push({
title: res[0].title,
start: res[0].start,
end: res[0].end
});
}
callback(events);
},
});
},
color: 'darkblue', // an option!
textColor: 'white', // an option!
}
],
eventRender: function (event, element, view) {
if (event.allDay === 'true') {
event.allDay = true;
} else {
event.allDay = false;
}
},
selectable: true,
selectHelper: true,
})

Server-side processing with ajax source data

I tried to submit dynamic data to jscript and render the data using php from api url, but how can I pass the pagination number to the datable jscript and letting php to define the pageindex dynamically?
I tried to pass the value into the function, it will totally reload the ajax table for me and stay back at page number 1 instead of page number 2.
the api returns:
{
"data": [...],
"pageindex": 1,
"totalrecord": 708,
"totalpage": 71
}
My Form jquery:
$('.form-filter form').on('submit', function(e) {
e.preventDefault();
const start = $('.form-filter [name=start]').val();
const end = $('.form-filter [name=end]').val();
const type = $('.form-filter [name=type]').val();
const status = $('.form-filter [name=status]').val();
if (this.checkValidity() !== false) {
action_handle('fire_search');
var datetime = timezone(start, end);
paymentTable(datetime[0], datetime[1], type, status);
}
});
The datatable jscript:
function paymentTable(from, to, type, status) {
const paymentTable = $('#table').DataTable({
ajax: {
type : "POST",
url: "/api/somethinng/history",
data: {"start": from, "end": to, "type": type, "status": status},
dataSrc: function(json) {
if(json == "no data") {
return [];
} else {
return json.data;
}
}
},
responsive: {
details: {
renderer: $.fn.dataTable.Responsive.renderer.tableAll({
tableClass: 'ui display nowrap table-sm table-bordered'
})
}
},
processing: true,
serverSide: true,
deferRender: true,
destroy: true,
order: [[0,"desc"]],
}
});
paymentTable.draw();
}
My PHP function to get the data from api:
public function api_history() {
$raw = $this->balance_model->data_source([
'type' => 1,
'status' => 1,
'fromdate' => '2020-10-01',
'todate'=> '2020-10-05',
'pageindex' => 1,
'rowperpage' => 1000
]);
if( $raw['code'] == 1 && $raw['data'] != [] ):
asort($raw['data']);
$data = [];
foreach( $raw['data'] as $ph ):
$row = [];
$row[] = $ph['date'];
$row[] = $ph['id'];
$row[] = $ph['amount'];
$data[] = $row;
endforeach;
echo json_encode([
'data' => $data
'draw' => (int)$_POST['draw'],
'recordsTotal' => $raw['totalRecord'],
'recordsFiltered' => $raw['totalRecord']
]);
else:
echo json_encode(['no data']);
endif;
}

not able to get the x axis and y -axis data or values from php array using canvaschart js using php

first page screen shots
second page screen shots
not able to display the x- axis and y-axis data from array in canvaschart js using php or zendframework and mysql
<?php
namespace Dashboard\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\Session\Container;
use Application\Entity\PyPayGroup;
use Application\Entity\PyPayPeriod;
use Zend\Session\SessionManager;
use Application\Entity\CommonCompanyHeader;
use Dashboard\Form\PayrollspendForm;
class PayrollspendController extends AbstractActionController
{
private $entityManager;
private $payrollspendManager;
private $sessionContainer;
private $pyPayPeriodClass;
private $pyPayGroupClass;
private $companyClass;
public function __construct($entityManager,$payrollspendManager)
{
$this->payrollspendManager = $payrollspendManager;
$this->entityManager = $entityManager;
$this->pyPayGroupClass = $this->entityManager->getRepository(PyPayGroup::class);
$this->pyPayPeriodClass = $this->entityManager->getRepository(PyPayPeriod::class);
$this->companyClass = $this->entityManager->getRepository(CommonCompanyHeader::class);
$sessionManager = new SessionManager();
$this->sessionContainer = new Container('ContainerNamespace', $sessionManager);
$arrLabel = ['payroll_calendar','label_payroll_group','emp_id','emp_name','label_total_earnings','label_payroll_period','company','label_process_id','session_id','label_employer_contribution','pay_item'];
}
public function addAction()
{
if ($this->sessionContainer->empId == "") {
return $this->redirect()->toRoute('admin_user_login');
}
if (!in_array('PY', $this->sessionContainer->arrRole)) {
if (!in_array('py_admin', $this->sessionContainer->arrRole)) {
return $this->redirect()->toRoute('dashboard_ess_index');
}
}
$reportForm = new PayrollspendForm();
$payGroup = $this->pyPayGroupClass->findBy([
'ouCode' => $this->sessionContainer->ouCode,
'langCode' => $this->sessionContainer->langCode,
'pgActive' => 1
]);
$reportForm->buildPayGroupData($payGroup);
$company = $this->companyClass->findBy([
'ouCode' => $this->sessionContainer->ouCode,
'langCode' => $this->sessionContainer->langCode
]);
$reportForm->buildCompanyData($company);
$payPeriodData = ['' => 'Select'];
$reportForm->get('payPeriod')->setValueOptions($payPeriodData);
$postData = $this->getRequest()->getPost()->toArray();
$postData['ouCode'] = $this->sessionContainer->ouCode;
$postData['langCode'] = $this->sessionContainer->langCode;
$compData = $this->payrollspendManager->buildCTCCompensationData($postData);
$groupByData = [
'' => 'Select',
'location' => 'Location',
'department' => 'Department',
'cost-center' => 'Cost center'
];
$reportForm->get('groupby')->setValueOptions($groupByData);
return new ViewModel([
'form' => $reportForm,
'ouCode' => $this->sessionContainer->ouCode,
'reportData' => $compData ,
'langCode' => $this->sessionContainer->langCode,
]);
}
This is model
public function getAllCTCCompensationData($postData)
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('ppp.payperiodSdesc , ppesa.grossPay, pptpp.pfEmployerContribution, pptpp.esiEmployerContribution, pplw.employercontribution')
->from(PyProcessEmpStatusApproved::class, 'ppesa')
->leftJoin(PyProcessTdsPfPt::class, 'pptpp', 'with', 'ppesa.ouCode = pptpp.ouCode')
->leftJoin(PyPayGroup::class, 'ppg', 'with', 'pptpp.pgCode = ppg.pgCode')
->leftJoin(PyProcessLabourWelfare::class, 'pplw', 'with', 'ppg.pgCode = pplw.pgCode')
->leftJoin(PyPayPeriod::class,'ppp','with','pplw.payperiodCode = ppp.payperiodCode')
->leftJoin(PyPayrollCalendar::class, 'ppc', 'with', 'ppp.paycalCode = ppc.paycalCode')
->where('ppesa.ouCode = ?1')
->andWhere('ppesa.langCode = ?2')
->setParameter('1', $postData['ouCode'])
->setParameter('2', $postData['langCode'])
->setMaxResults(60);
$compData = $queryBuilder->getQuery()->getResult();
$data = [];
if(!empty($compData))
{
$total = 0;
foreach($compData as $dataC)
{
$statData = $this->getStatuoryData($postData,$dataC['payperiodSdesc']);
if(isset($statData['payperiodSdesc']))
{
$data[$dataC['payperiodSdesc']]['PAYPERIOD'] = $this->payPERIODdata($postData,$dataC['payperiodSdesc']);
}
else
{
$data[$dataC['payperiodSdesc']]['PAYPERIOD'] = $this->payPERIODdata($postData,$dataC['payperiodSdesc']);
}
if(isset($statData['pfEmployerContribution']))
{
$data[$dataC['payperiodSdesc']]['PF'] = $this->getPFData($postData,$dataC['payperiodSdesc']);
}
else
{
$data[$dataC['payperiodSdesc']]['PF'] = $this->getPFData($postData,$dataC['payperiodSdesc']);
}
if(isset($statData['pfPensionFund']))
{
$data[$dataC['payperiodSdesc']]['PFF'] = $this->getPFData($postData,$dataC['payperiodSdesc']);
}
else
{
$data[$dataC['payperiodSdesc']]['PFF'] = $this->getPFData($postData,$dataC['payperiodSdesc']);
}
if(isset($statData['grossPay']))
{
$data[$dataC['payperiodSdesc']]['GROSS'] = $this->getGROSSPAYData($postData,$dataC['payperiodSdesc']);
}
else
{
$data[$dataC['payperiodSdesc']]['GROSS'] = $this->getGROSSPAYData($postData,$dataC['payperiodSdesc']);
}
if(isset($statData['employercontribution']))
{
$data[$dataC['payperiodSdesc']]['LABOURWELFARE'] = $this->getEMPLOYERCONTRIBUTIONData($postData,$dataC['payperiodSdesc']);
}
else
{
$data[$dataC['payperiodSdesc']]['LABOURWELFARE'] = $this->getEMPLOYERCONTRIBUTIONData($postData,$dataC['payperiodSdesc']);
}
if(isset($statData['esiEmployerContribution']))
{
$data[$dataC['payperiodSdesc']]['ESIC'] = $this->getESICData($postData,$dataC['payperiodSdesc']);
}
else
{
$data[$dataC['payperiodSdesc']]['ESIC'] = $this->getESICData($postData,$dataC['payperiodSdesc']);
}
$data[$dataC['payperiodSdesc']]['Total'] = $this->getCTCCompensationSum($postData,
isset($data[$dataC['payperiodSdesc']]['payperiodSdesc']),
isset($data[$dataC['payperiodSdesc']]['pfEmployerContribution']),
isset($data[$dataC['payperiodSdesc']]['pfPensionFund']),
isset($data[$dataC['payperiodSdesc']]['esiEmployerContribution']),
isset($data[$dataC['payperiodSdesc']]['grossPay']),
isset($data[$dataC['payperiodSdesc']]['employercontribution']));
$data = [$data[$dataC['payperiodSdesc']]['Total']];
}
}
return $data;
}
This is view file or canvaschartjs
<script>
window.onload = function () {
var chart1 = new CanvasJS.Chart("chartContainer1", {
animationEnabled: true,
title: {
text: ""
},
axisX: {
labelFontColor: "#000000",
labelFontStyle: "oblique",
},
axisY: {
title: "",
titleFontColor: "#4F81BC",
lineColor: "#4F81BC",
labelFontColor: "#4F81BC",
tickColor: "#4F81BC"
},
axisY2: {
title: "",
titleFontColor: "#C0504E",
lineColor: "#C0504E",
labelFontColor: "#C0504E",
tickColor: "#C0504E"
},
toolTip: {
shared: true
},
legend: {
cursor: "pointer",
itemclick: toggleDataSeries
},
data: [{
type: "column",
name: "Total",
legendText: "Total",
showInLegend: true,
dataPoints: [
<?php
echo '<pre>';
print_r($compData);
die;
if(!empty($compData))
{
?>
<?php
foreach($compData as $key => $value)
{
?>
{label: "<?php echo $key; ?>", y:<?php echo $value[$data[$dataC['payperiodSdesc']]['Total']]; ?>},
<?php } ?>
<?php } ?>
]
},
{
type: "column",
name: "Closed",
legendText: "Closed",
showInLegend: true,
dataPoints: [
<?php
if(!empty($compData))
{
?>
<?php
foreach($compData as $key => $value)
{
?>
{label: "<?php echo $key; ?>", y: <?php echo $value[$data[$dataC['payperiodSdesc']]['Total']]; ?>},
<?php } ?>
<?php } ?>
]
},
{
type: "column",
name: "Lapsed",
legendText: "Lapsed",
showInLegend: true,
dataPoints: [
<?php if(!empty($compData)) { ?>
<?php foreach($compData as $key => $value) { ?>
{label: "<?php echo $key; ?>", y: <?php echo $value[$data[$dataC['payperiodSdesc']]['Total']]; ?>},
<?php } ?>
<?php } ?>
]
}]
});
}
chart1.render();
}
</script>
<script>
window.onload = function () {
var chart1 = new CanvasJS.Chart("chartContainer1", {
animationEnabled: true,
title: {
text: ""
},
axisX: {
labelFontColor: "#000000",
labelFontStyle: "oblique",
},
axisY: {
title: "",
titleFontColor: "#4F81BC",
lineColor: "#4F81BC",
labelFontColor: "#4F81BC",
tickColor: "#4F81BC"
},
axisY2: {
title: "",
titleFontColor: "#C0504E",
lineColor: "#C0504E",
labelFontColor: "#C0504E",
tickColor: "#C0504E"
},
toolTip: {
shared: true
},
legend: {
cursor: "pointer",
itemclick: toggleDataSeries
},
data: [{
type: "column",
name: "Total",
legendText: "Total",
showInLegend: true,
dataPoints: [
<?php
echo '<pre>';
print_r($compData);
die;
if(!empty($compData))
{
?>
<?php
foreach($compData[0] as $key => $value)
{
?>
{label: "<?php echo $key; ?>", y:<?php echo $value[$data[$dataC['payperiodSdesc']]['Total']]; ?>},
<?php } ?>
<?php } ?>
]
},
{
type: "column",
name: "Closed",
legendText: "Closed",
showInLegend: true,
dataPoints: [
<?php
if(!empty($compData))
{
?>
<?php
foreach($compData[1] as $key => $value)
{
?>
{label: "<?php echo $key; ?>", y: <?php echo $value[$data[$dataC['payperiodSdesc']]['Total']]; ?>},
<?php } ?>
<?php } ?>
]
},
{
type: "column",
name: "Lapsed",
legendText: "Lapsed",
showInLegend: true,
dataPoints: [
<?php if(!empty($compData)) { ?>
<?php foreach($compData[2] as $key => $value) { ?>
{label: "<?php echo $key; ?>", y: <?php echo $value[$data[$dataC['payperiodSdesc']]['Total']]; ?>},
<?php } ?>
<?php } ?>
]
}]
});
function toggleDataSeries(e) {
if (typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
e.dataSeries.visible = false;
} else {
e.dataSeries.visible = true;
}
}
chart1.render();
}
</script>
I am trying to draw a barchart of months of x-axis and Total spend on y-axis in graph.In controller class the data which i m sending to the view is $compData = $this->payrollspendManager->buildCTCCompensationData($postData);
The x-axis will show the month ie $data[$dataC['payperiodSdesc']]['PAYPERIOD'] and y-axis will show the total spend ie $data[$dataC['payperiodSdesc']]['Total']. This month and total spend you will find in model.
Here i m using canvasjs using zendframework.Now my data ie $compData is send from controller to view file.This compData has 7 elements and i want to display the zero elemnet in y-axis and sixth element in x-axis.
for canvasjs refer to https://canvasjs.com website using php.
if anybody require more code ...will help you
what is the issue in the code?
The graph should have both x-axis and y-axis.
i m recieving the data in controller in the form of array($compData).
This array i m sending it to view.
Then the array goes in foreach loop and display the zero element from array on x axis and last field ie 6th element on y-axis.
i m displaying the data on x and y-axis dynamically using canvas
js chart.
how to display the graph using canvaschart js ?
if anybody not getting clear about question can ask more for clearty
i m trying to draw a barchart of months of x-axis and Total spend on y-axis in graph
.In controller class the data which i m sending to the view is $compData = $this->payrollspendManager->buildCTCCompensationData($postData);
THe x-axis will show the month ie $data[$dataC['payperiodSdesc']]['PAYPERIOD'] and y-axis will show the total spend ie $data[$dataC['payperiodSdesc']]['Total'] .This month and total spend you will find in model.
here i m using canvasjs using zendframework.Now my data ie $compData is send from controller to view file.This compData has 7 elements and i want to display the zero elemnet in y-axis and sixth element in x-axis.
for canvasjs refer to https://canvasjs.com website using php.
i want to display the PAYPERIOD which is the first array from details array and Total from Details which is last array

Coudn't get result of highchart

I am using highchart, it gives result.
But, when I am going to make date range, nothing is happening and even my result goes blank!
I just want to find where I am wrong!
Here is my code:
<script type="text/javascript">
$(document).ready(function()
{
var options = {
chart:
{
renderTo: 'container',
type: 'column',
marginRight: 130,
marginBottom: 25
},
rangeSelector:
{
selected: 1,
inputDateFormat: '%Y-%m-%d',
inputEditDateFormat: '%Y-%m-%d'
},
title:
{
text: 'Project Requests',
x: -20 //center
},
subtitle:
{
text: '',
x: -20
},
xAxis:
{
categories: []
},
yAxis:
{
title:
{
text: 'Requests'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip:
{
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+this.x +': '+ this.y;
}
},
legend:
{
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
series: []
}
$.getJSON("data", function(json)
{
options.xAxis.categories = json[0]['data'];
options.series[0] = json[1];
options.series[1] = json[2];
// options.series[2] = json[3];
chart = new Highcharts.StockCart(options);
});
function (chart)
{
setTimeout(function ()
{
$('input.highcharts-range-selector', $(chart.container).parent())
.datepicker({
format: "dd/mm/yyyy",
todayBtn: "linked",
orientation: "auto left",
autoclose: true,
todayHighlight: true
});
}, 0);
$.datepicker.setDefaults
({
dateFormat: 'yy-mm-dd',
onSelect: function (dateText) {
this.onchange();
this.onblur();
}
});
</script>
Here my Controller:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Chart extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->database();
$this->load->model('Data');
$this->load->helper('url');
}
public function index()
{
//echo "adsf";exit;
$this->load->view('allindex');
}
public function data()
{
$data = $this->Data->get_data();
$category = array();
$category['name'] = 'date';
$series1 = array();
$series1['name'] = 'employee_id';
$series2 = array();
$series2['name'] = 'customer_id';
// $series3 = array();
// $series3['name'] = 'sale_id';
foreach ($data as $row)
{
$category['data'][] = $row->date;
$series1['data'][] = $row->employee_id;
$series2['data'][] = $row->customer_id;
// $series3['data'][] = $row->sale_id;
}
$result = array();
array_push($result,$category);
array_push($result,$series1);
array_push($result,$series2);
// array_push($result,$series3);
print json_encode($result, JSON_NUMERIC_CHECK);
}
Here is Model:
<?php
class Data extends CI_Model
{
public function __construct()
{
parent::__construct();
}
public function get_data()
{
$this->db->select('date,sale_id,employee_id,customer_id');
$this->db->from('ospos_sales');
$this->db->where("`date` BETWEEN '2013-10-11' AND '2013-10-12'");
$query = $this->db->get();
return $query->result();
}
}
The only idea that there is a problem with dateFormat. Try to comment this lines
inputDateFormat: '%Y-%m-%d',
inputEditDateFormat: '%Y-%m-%d'
i have no more idea

Categories