File Name :
<td width="200"> <button class="btn btn-danger" type="button" onclick="del_super('<?php echo $row['id'];?>','<?php echo $row['supr_id'];?>','<?php echo $row['doc_id']; ?>');">Delete</button></td>
<a href="#" class="btn btn-success" id="next" onclick=
"update_details()" type="button" name="SubmitDocument">
UPDATE</a>
<script>
function update_details() {
if ($('#title').val() == "" || $('#title').val() == null) {
$("#title").focus();
alert("Please Insert English Title ");
return false;
}
else if ($('#language').val() == "" || $('#language').val() == null)
{
$("#language").focus();
alert("Please Select language");
return false;
}
else if ($('#country').val() == "" || $('#country').val() == null)
{
$("#country").focus();
alert("Enter Document Priority");
return false;
}
else if ($('#doc_type').val() != 'doc' && $('#type').val() == "")
{
$("#type").focus();
alert("Enter doc Code");
return false;
}
else {
document.frm.action="database/myquery.php";
document.frm.method="post";
document.frm.submit();
}
}
</script>
<script>
function del_super(pid,sid,doc_no)
{
if(pid != '' && sid != '')
{
if(confirm("Are you sure to remove?"))
{
$.ajax({
url:"<?php echo $base_url;?>ittutorial/edit.php",
method:"POST",
data:{pid:pid,sid:sid,doc_no:doc_no},
success:function(data){
//window.location.href = "ProcessAction.php?ID="+isnum;
swal("success!", "Record successfully removed", "success");
//$("#del_"+sid).remove();
$("#del_"+sid).hide();
//location.reload();
}
});
}
}
}
$(document).ready(function(){
$("#add_super").click(function() {
var id = $('#super').val();
//var id = $('#super option:selected');
var id_length = id.length;
var sdm_doc_no = $('#doc_no').val();
if((id == '' || id == null) || (id == 'undefined' || id_length == 0))
{
swal("error!", "Please select ", "error");
}
if(id)
{
$.ajax({
url:"<?php echo $base_url;?>ittutorial/edit.php",
method:"POST",
data:{id:id,sdm_doc_no:sdm_doc_no},
success:function(data){
//window.location.href = "ProcessAction.php?ID="+isnum;
//location.reload();
//window.location.href = "edit.php?docno="+sdm_doc_no;
swal("success!", "Standards successfully added", "success");
$("#super").val('');
// $("#divid").load();
}
});
}
});
});
</script>
<script type="text/javascript">
$(document).ready(function() {
var msg_rollback="<?php echo $msg_rollback ?>";
if(msg_rollback=='Rollbacked')
{
alert("Rollback! Data Rollbacked!.");
}
});
</script>
<script>
function addstndrd() {
var id=$("#trow_counter").val();
id = eval(parseInt(id)+1);
alert("test");
alert(id);
if(id<=10)
{
var isid = document.getElementById('get_is').value;
if(isid!='' && isid!=null && isid!=0)
{
var select = document.getElementById('get_is');
var options = select.innerHTML;
html = "<div id='trow_"+id+"'><br/><select name='RevStds[]' id='"+id+"' class='form-control' style='display:inline-block;width:90%;'>"+options+"</select> <a href='javascript:removestndrds("+id+")' class='btn btn-danger'><i class='fa fa-minus' aria-hidden='true'></i></a></div>";
$("#addmore_stndrd").append(html);
$("#trow_counter").val(id.toString());
}
}
else {
alert('Please select IS No First.');
}
}
// remove stndrd field
function removestndrds(row) {
var id=$("#trow_counter").val();
$("#trow_"+row).remove();
id--;
$("#trow_counter").val(id);
}
/* finish add more stndrd*/
</script>
<script>
$('#doc_type_rev_show').bind('click', function() {
document.getElementById('DivSelectIs').style.display = "block";
document.getElementById('DivAllotIS').style.display = "block";
document.getElementById('pns').style.display = "none";
});
$('#doc_type_new1').bind('click', function() {
document.getElementById('DivSelectIs').style.display = "none";
document.getElementById('DivAllotIS').style.display = "none";
document.getElementById('IsDetails').style.display = "none";
document.getElementById('pns').style.display = "block";
});
</script>
File Name :
// ################# Delete ########################
if(!empty($_POST['pid']) && !empty($_POST['sid']) && !empty($_POST['doc_no']))
{
mysqli_autocommit($sql, false);
$state = true;
$pid = $_POST['pid'];
$sid = $_POST['sid'];
$doc_no = $_POST['doc_no'];
$qry = "delete from ittutorial where id=$pid and supr_id=$sid and doc_id=$doc_no";
$result = mysqli_query($sql,$qry);
if(!$result)
{
$state = false;
}
$dt_created = date('Y-m-d H:i:s');
$emp_number = "97978";
$qry1 = "insert into it_logs(doc_id,status,supr_id,ss_pid,action,created,created_by) values ('$doc_no','2','$sid','$pid','Remove','$dt_created','$emp_number')";
$result1 = mysqli_query($sql,$qry1);
if(!$result1)
{
$state = false;
}
if($state == true)
{
mysqli_commit($sql);
$_SESSION['msg_success']='Success';
}
else {
mysqli_rollback($sql);
$_SESSION['msg_rollback']='Rollbacked';
}
}
// ##################### Insert #########################
if(!empty($_POST['id']) && !empty($_POST['doc_no']))
{
$id = $_POST['id'];
$doc_no = $_POST['doc_no'];
$dt_created = date('Y-m-d H:i:s');
$emp_number = '565675';
mysqli_autocommit($sql, false);
$state = true;
$qry = "insert into ittutorial (doc_id,status,suprsid,created,created_by) values ('$doc_no','2','$id','$dt_created','$emp_number')";
$result = mysqli_query($sql,$qry);
$last_pki_id = mysqli_insert_id($sql);
if(!$result)
{
$state = false;
}
if($state == true)
{
mysqli_commit($sql);
$_SESSION['msg_success']='Success';
}
else {
mysqli_rollback($sql);
$_SESSION['msg_rollback']='Rollbacked';
}
}