58 lines
1.8 KiB
PHP
58 lines
1.8 KiB
PHP
<?php
|
|
//debug($data);
|
|
for($i=0;$i<sizeof($data);$i++) {
|
|
$data[$i][1] = $this->Html->link($data[$i][1],array('controller' => 'schools', 'action' => 'showbudgets',$data[$i][0]));
|
|
}
|
|
echo '<h2>' . $budget['wl_kurz_bezeichnung'] .'</h2>';
|
|
//debug($data);
|
|
?>
|
|
|
|
<div class="controls">
|
|
<button name="load" id="load" class="intext-btn">Load</button>
|
|
<button name="save" id="save" class="intext-btn">Save</button>
|
|
</div>
|
|
<div id="editbudget"></div>
|
|
<script>
|
|
var data = <?php echo json_encode($data); ?>;
|
|
|
|
var container = document.getElementById('editbudget');
|
|
var load = document.getElementById('load');
|
|
var save = document.getElementById('save');
|
|
var autosaveNotification;
|
|
var rotated = false;
|
|
|
|
var hot = new Handsontable(container, {
|
|
data: data,
|
|
width: 1400,
|
|
height: 800,
|
|
rowHeaders: true,
|
|
wordWrap: false,
|
|
colHeaders: ['SNR','Name','Count','Comment'] ,
|
|
colWidths: ['50','500','50','500'],
|
|
columns: [{renderer: "text", readOnly: true},{renderer: "html", readOnly: true},{renderer: "text"},{renderer: "text"}],
|
|
filters: true,
|
|
dropdownMenu: true
|
|
});
|
|
|
|
Handsontable.dom.addEvent(save, 'click', function() {
|
|
// save all cell's data
|
|
//console.log(hot.getData());
|
|
//console.log(JSON.stringify({data: hot.getData()}));
|
|
$.ajax({
|
|
//url: "editajax?id=<?php echo $budget['id']; ?>",
|
|
url: "<?php echo $this->Url->build(array('controller' => 'budget', 'action' => 'editajax'), true) . '?budget=' . $budget['id'] . '&schooltype=' . $schooltype ?>",
|
|
data: JSON.stringify(hot.getData()),
|
|
type: 'POST',
|
|
success: function (res) {
|
|
//console.log(res);
|
|
//var data = JSON.parse(res);
|
|
|
|
}
|
|
});
|
|
});
|
|
|
|
$('#load').click(function() {
|
|
location.reload(true);
|
|
});
|
|
|
|
</script>
|