budget listBudgets editBudget editajax

This commit is contained in:
2018-04-02 19:37:58 +02:00
parent 9b83d1dc09
commit ad9bd84844
5 changed files with 146 additions and 4 deletions

View File

@@ -0,0 +1,53 @@
<?php
//debug($budget);
echo '<h2>' . $budget['wl_kurz_bezeichnung'] .'</h2>';
?>
<div class="controls">
<button name="load" id="load" class="intext-btn">Load</button>
<button name="save" id="save" class="intext-btn">Save</button>
<label><input name="autosave" id="autosave" checked="checked" autocomplete="off" type="checkbox">Autosave</label>
</div>
<pre id="example1console" class="console">Data loaded</pre>
<div id="editbudget"></div>
<script>
var data = <?php echo json_encode($data); ?>;
var container = document.getElementById('editbudget');
var exampleConsole = document.getElementById('example1console');
var autosave = document.getElementById('autosave');
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: 1000,
rowHeaders: true,
wordWrap: false,
colHeaders: ['SNR','Name','Count','Comment'] ,
colWidths: ['50','500','50','500'],
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',$budget['id']), true); ?>",
data: JSON.stringify(hot.getData()),
type: 'POST',
success: function (res) {
//console.log(res);
//var data = JSON.parse(res);
}
});
});
</script>