Function Delete
function DELETEDatacty(){
var row = $('#resultcustype').datagrid('getSelected');
if (row){
row.menumm="<?=$menunameid;?>";
$.messager.confirm('Confirm','Are you sure you want to remove this data?',function(r){
if (r){
$.post('<?=site_url() ?>/masterp/hapuscty',{ID:row.CustType_ID,menunameid:row.menumm},function(resultcustype){
if (resultcustype.success){
$.messager.show({ // show error message
title: 'Success',
//msg: result.errorMsg
msg: resultcustype.success
});
$('#resultcustype').datagrid('reload'); // reload the user data
} else {
$.messager.show({ // show error message
title: 'Error',
//msg: result.errorMsg
msg: resultcustype.errorMsg
});
}
},'json');
}
});
}
}
Model
function hapuskitcty()
{
$id = $_REQUEST['ID'];
$menunameida = $_REQUEST['menunameid'];
if ($this->db->simple_query("DELETE FROM tb_m_custtype WHERE CustType_ID='" . $id . "'"))
{
$username = $this->session->userdata('username');
$actionlogg='DELETE';
$ambilget=$id;
$menunameid=$menunameida;
$petunjuk='C';
$this->load->model('san');
$this->san->updatelogz($username,$ambilget,$actionlogg,$menunameid,$petunjuk);
return json_encode(array('success' => 'Done'));
}
else
{
$result = array('errorMsg' =>'Data tidak dapat dihapus karena telah bereleasi dengan tabel lain');
return json_encode($result);
}
}
Tidak ada komentar:
Posting Komentar