Ma depaseste problema. Deci in primul fisier din administrare/index.php am
Cod: Selectaţi tot
<li><a class="lnk" href="contabilitate/facturi/index.php">Facturi</a> </li>
<script type="text/javascript">
$(document).ready(function () {
$('a.lnk').click(function () {
var url = $(this).attr('href');
$('#continut').load(url);
return false;
});
});
</script>
In fiserul facturi/index.php preluat in div cu id="continut" am urmatorul script care de fapt prelucreaza un form si apeleaza la un alt fisier numit response.php in care se fac operatii CRUD intr-o baza mysql:
Cod: Selectaţi tot
<script>
$(document).ready(function () {
var grid = $("#employee_grid").bootgrid({
ajax: true,
rowSelect: true,
post: function () {
/* To accumulate custom parameter with the request object */
return {
idFactura: "b0df282a-0d67-40e5-8558-c9e93b7befed"
};
},
url: "../administrator/contabilitate/facturi/response.php",
formatters: {
"actiuni": function (column, row) {
return "<button type=\"button\" class=\"btn btn-xs btn-default command-edit\" data-row-id=\"" + row.idFactura + "\"><span class=\"glyphicon glyphicon-edit\"></span></button> " +
"<button type=\"button\" class=\"btn btn-xs btn-default command-delete\" data-row-id=\"" + row.idFactura + "\"><span class=\"glyphicon glyphicon-trash\"></span></button>";
}
}
}).on("loaded.rs.jquery.bootgrid", function () {
/* Executes after data is loaded and rendered */
grid.find(".command-edit").on("click", function (e) {
//alert("You pressed edit on row: " + $(this).data("row-id"));
var ele = $(this).parent();
var g_id = $(this).parent().siblings(':first').html();
var g_name = $(this).parent().siblings(':nth-of-type(2)').html();
console.log(g_id);
console.log(g_name);
//console.log(grid.data());
$('#edit_model').modal('show');
if ($(this).data("row-id") > 0) {
// collect the data
$('#edit_id').val(ele.siblings(':first').html()); // in case we're changing the key
$('#edit_idFur').val(ele.siblings(':nth-of-type(2)').html());
$('#edit_codBare').val(ele.siblings(':nth-of-type(3)').html());
$('#edit_numar').val(ele.siblings(':nth-of-type(4)').html());
$('#edit_serie').val(ele.siblings(':nth-of-type(5)').html());
$('#edit_dataScadenta').val(ele.siblings(':nth-of-type(6)').html());
$('#edit_dataEmitere').val(ele.siblings(':nth-of-type(7)').html());
$('#edit_suma').val(ele.siblings(':nth-of-type(8)').html());
$('#edit_descriere').val(ele.siblings(':nth-of-type(9)').html());
} else {
alert('Acum selectati randul! Prima oara selectati randul, apoi apasati butonul editare');
}
}).end().find(".command-delete").on("click", function (e) {
var conf = confirm('Stergeti randul ' + $(this).data("row-id") + ' ?');
alert(conf);
if (conf) {
$.post('../administrator/contabilitate/facturi/response.php', {
idFactura: $(this).data("row-id"),
action: 'delete'
}
, function () {
// when ajax returns (callback),
$("#employee_grid").bootgrid('reload');
});
//$(this).parent('tr').remove();
//$("#employee_grid").bootgrid('remove', $(this).data("row-id"))
}
});
});
function ajaxAction(action) {
data = $("#frm_" + action).serializeArray();
$.ajax({
type: "POST",
url: "../administrator/contabilitate/facturi/response.php",
data: data,
dataType: "json",
success: function (response) {
$('#' + action + '_model').modal('hide');
$("#employee_grid").bootgrid('reload');
}
});
}
$("#command-add").click(function () {
$('#add_model').modal('show');
});
$("#btn_add").click(function () {
ajaxAction('add');
});
$("#btn_edit").click(function () {
ajaxAction('edit');
});
});
</script>
E cineva dispus sa ma ajute sa rezolv acest conflict?