Undefined Index: data
Undefined Index: data
I must have done something really dumb here, but I can't seem to see what.
On editing a record I get in the post "undefined index error" as below:
Notice: Undefined index: data in C:\Apache24\htdocs\CMBSSchedule\php\lib\Editor\Editor.php on line 569
Warning: Invalid argument supplied for foreach() in C:\Apache24\htdocs\CMBSSchedule\php\lib\Editor\Editor.php on line 569
Notice: Undefined index: data in C:\Apache24\htdocs\CMBSSchedule\php\lib\Editor\Editor.php on line 653
Warning: Invalid argument supplied for foreach() in C:\Apache24\htdocs\CMBSSchedule\php\lib\Editor\Editor.php on line 653
Notice: Undefined index: data in C:\Apache24\htdocs\CMBSSchedule\php\lib\Editor\Editor.php on line 586
Warning: Invalid argument supplied for foreach() in C:\Apache24\htdocs\CMBSSchedule\php\lib\Editor\Editor.php on line 586
{"data":[]}
Here is my js:
/*
* Editor client script for DB table CMBSCodes
* Created by http://editor.datatables.net/generator
*/
(function($){
$(document).ready(function() {
var editor = new $.fn.dataTable.Editor( {
ajax: 'php/table.CMBSCodes.php',
table: '#CMBSCodes',
fields: [
{
"label": "Effective Date:",
"name": "CMBSCodes.EffectiveDate",
"type": "datetime",
"format": "ddd, D MMM YYYY"
},
{
"label": "Schedule Type:",
"name": "CMBSCodes.ScheduleTypeID",
"type": "select"
},
{
"label": "Time:",
"name": "CMBSCodes.ScheduleTime",
"className": "full"
},
{
"label": "Item Code:",
"name": "CMBSCodes.ScheduleItemCode"
},
{
"label": "Schedule Fee:",
"name": "CMBSCodes.ScheduleFee"
},
{
"label": "Loading Type:",
"name": "CMBSCodes.LoadingType",
"type": "select"
},
{
"label": "Loading Item Code:",
"name": "CMBSCodes.LoadingItemCode"
},
{
"label": "Loading Percentage:",
"name": "CMBSCodes.LoadingAmount"
},
{
"label": "Loading Fee:",
"name": "CMBSCodes.LoadingFee"
},
{
"label": "Minimum Time (mins):",
"name": "CMBSCodes.MinTime"
},
{
"label": "Maximum Time (mins):",
"name": "CMBSCodes.MaxTime"
},
{
"label": "Maximum Claim Amount:",
"name": "CMBSCodes.MaxClaimAmount"
},
{
"label": "Inactive:",
"name": "CMBSCodes.Inactive",
"type": "checkbox",
"separator": "|",
"options": [
{ label: '', value: 1}
]
}
]
} );
var table = $('#CMBSCodes').DataTable( {
dom: 'Bfrtip',
ajax: 'php/table.CMBSCodes.php',
order: [
[2, 'asc'],[ 0,'asc']
],
columns: [
{ "data": "CMBSScheduleType.TypeDescription" },
{ "data": "CMBSCodes.ScheduleTime" },
{
"data": "CMBSCodes.ScheduleItemCode",
"className": "dt-body-center"
},
{
"data": "CMBSCodes.ScheduleFee",
"render": $.fn.dataTable.render.number(',', '.', 2, '$'),
"className": "dt-body-right"
},
{ "data": "CMBSLoadingType.LoadingDescription" },
{
"data": "CMBSCodes.LoadingItemCode",
"className": "dt-body-center"
},
{
"data": "CMBSCodes.LoadingAmount",
"render": $.fn.dataTable.render.number(',', '.', 2, '', '%'),
"className": "dt-body-right"
},
{
"data": "CMBSCodes.LoadingFee",
"render": $.fn.dataTable.render.number(',', '.', 2, '$'),
"className": "dt-body-right"
},
{
"data": "CMBSCodes.MinTime",
"className": "dt-body-center"
},
{
"data": "CMBSCodes.MaxTime",
"className": "dt-body-center"
},
{
"data": "CMBSCodes.MaxClaimAmount",
"render": $.fn.dataTable.render.number(',', '.', 2, '$'),
"className": "dt-body-right"
},
{
"data": "CMBSCodes.Inactive",
"render": function (data, type, row){
if (type === 'display'){
return '<input type="checkbox" class="editor-active">';
}
return data;
},
"className": "dt-body-center"
}
],
select: {
style: 'single',
selector: 'td:not(:last-child)' // no row selection on last column
},
lengthChange: false,
responsive: true,
buttons: [
{ extend: 'create', editor: editor },
{ extend: 'edit', editor: editor },
{ extend: 'remove', editor: editor }
],
rowCallback: function ( row, data ) {
// Set the checked state of the checkbox in the table
$('input.editor-active', row).prop( 'checked', data.CMBSCodes.Inactive == 1 );
}
} );
$('#CMBSCodes').on( 'change', 'input.editor-active', function () {
editor
.edit( $(this).closest('tr'), false )
.set( 'CMBSCodes.Inactive', $(this).prop( 'checked' ) ? 1 : 0 )
.submit();
} );
} );
}(jQuery));
Here is my php:
<?php
/*
* Editor server script for DB table CMBSCodes
* Created by http://editor.datatables.net/generator
*/
// DataTables PHP library and database connection
include( "lib/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'CMBSCodes', 'ID' )
->fields(
Field::inst( 'CMBSCodes.EffectiveDate' )
->validator( 'Validate::notEmpty' )
->validator( 'Validate::dateFormat', array( 'format'=>'D, j M y' ) )
->getFormatter( 'Format::date_sql_to_format', 'D, j M y' )
->setFormatter( 'Format::date_format_to_sql', 'D, j M y' ),
Field::inst( 'CMBSCodes.ScheduleTypeID' )
->options( 'CMBSScheduleType','ScheduleTypeID', 'TypeDescription')
->validator( 'Validate::dbValues' ),
Field::inst( 'CMBSScheduleType.TypeDescription' ),
Field::inst( 'CMBSCodes.ScheduleTime' )
->validator( 'Validate::notEmpty' )
->validator( 'Validate::maxLen',50),
Field::inst( 'CMBSCodes.ScheduleItemCode' )
->validator( 'Validate::notEmpty' )
->validator( 'Validate::maxLen',15),
Field::inst( 'CMBSCodes.ScheduleFee' )
->validator( 'Validate::numeric' ),
Field::inst( 'CMBSCodes.LoadingType' )
->options( 'CMBSLoadingType','LoadingType', 'LoadingDescription')
->validator( 'Validate::dbValues',array('valid' => array('') ))
->setFormatter( 'Format::nullEmpty'),
Field::inst( 'CMBSLoadingType.LoadingDescription' ),
Field::inst( 'CMBSCodes.LoadingItemCode' )
->validator( 'Validate::maxLen',15)
->setFormatter( 'Format::nullEmpty'),
Field::inst( 'CMBSCodes.LoadingAmount' )
->validator( 'Validate::numeric' ),
Field::inst( 'CMBSCodes.LoadingFee' )
->validator( 'Validate::numeric' ),
Field::inst( 'CMBSCodes.MinTime' )
->validator( 'Validate::numeric' )
->setFormatter( 'Format::nullEmpty'),
Field::inst( 'CMBSCodes.MaxTime' )
->validator( 'Validate::numeric' )
->setFormatter( 'Format::nullEmpty'),
Field::inst( 'CMBSCodes.MaxClaimAmount' )
->validator( 'Validate::numeric' )
->setFormatter( 'Format::nullEmpty'),
Field::inst( 'CMBSCodes.Inactive' )
->setFormatter(function ($val, $data, $opts) {
return ! $val ? 0 : 1;
})
)
->leftJoin( 'CMBSLoadingType', 'CMBSLoadingType.LoadingType', '=', 'CMBSCodes.LoadingType' )
->leftJoin( 'CMBSScheduleType' ,'CMBSScheduleType.ScheduleTypeID', '=', 'CMBSCodes.ScheduleTypeID')
->where( 'CMBSCodes.EffectiveDate', '2012-11-01', '=')
->process( $_POST )
->json();
<?php
>
```
?>
Here is the data Extract:
{
"data":[
{
"DT_RowId":"row_13",
"CMBSCodes":{"EffectiveDate":"Thu, 1 Nov 12",
"ScheduleTypeID":"CONF",
"ScheduleTime":"< 30 mins",
"ScheduleItemCode":"855",
"ScheduleFee":"118.25",
"LoadingType":"T ",
"LoadingItemCode":"288",
"LoadingAmount":".5000",
"LoadingFee":"59.13",
"MinTime":"0",
"MaxTime":"30",
"MaxClaimAmount":null,
"Inactive":null},
"CMBSScheduleType":{"TypeDescription":"Community Conference"},
"CMBSLoadingType":{"LoadingDescription":"Telepsychiatry"}
},
{
"DT_RowId":"row_14",
"CMBSCodes":{"EffectiveDate":"Thu, 1 Nov 12",
"ScheduleTypeID":"CONF",
"ScheduleTime":"> 45 mins",
"ScheduleItemCode":"858",
"ScheduleFee":"236.45",
"LoadingType":"T ",
"LoadingItemCode":"288",
"LoadingAmount":".5000",
"LoadingFee":"118.23",
"MinTime":"45",
"MaxTime":null,
"MaxClaimAmount":null,
"Inactive":null},
"CMBSScheduleType":{"TypeDescription":"Community Conference"},
"CMBSLoadingType":{"LoadingDescription":"Telepsychiatry"}
},
{
"DT_RowId":"row_15",
"CMBSCodes":{"EffectiveDate":"Thu, 1 Nov 12",
"ScheduleTypeID":"CONF",
"ScheduleTime":"30 - 45 mins",
"ScheduleItemCode":"857",
"ScheduleFee":"177.40",
"LoadingType":"T ",
"LoadingItemCode":"288",
"LoadingAmount":".5000",
"LoadingFee":"88.70",
"MinTime":"30",
"MaxTime":"45",
"MaxClaimAmount":null,
"Inactive":null},
"CMBSScheduleType":{"TypeDescription":"Community Conference"},
"CMBSLoadingType":{"LoadingDescription":"Telepsychiatry"}
}
],
"options":
{
"CMBSCodes.ScheduleTypeID":
[
{"label":"Community Conference","value":"CONF"},
{"label":"Consulting Room","value":"CORM"},
{"label":"Electroconvulsive Therapy","value":"ECT "},
{"label":"F\/U Assessment for GP","value":"FAGP"},
{"label":"Home Visits","value":"HMV "},
{"label":"Initial Assessment for GP","value":"IAGP"},
{"label":"Non-Patient","value":"NPAT"}
],
"CMBSCodes.LoadingType":
[
{"label":"Telepsychiatry","value":"T "}
]
},
"files":[]
}
```
Attached project in zip for reference: