<?php
include("../../include/db.php");

/********************************** CHECK ITEM FOR STORE CREATION***************************************/

function check_vehicle_no($vehicle_no)
  {   
       $sql_select = "select * from vehicle_entry where vehicle_no='$vehicle_no'";
       $rs=mysql_query($sql_select);
       $rs_count=mysql_num_rows($rs);
       return $rs_count; 
}

function get_vehicle_no_edit($vehicle_no)
{
  $sql_select = "select * from vehicle_entry where vehicle_no='$vehicle_no'";
  $rs=mysql_query($sql_select);
  $rscount1=mysql_num_rows($rs);
    if($rscount1!=0)
    {
      while($rsdata=mysql_fetch_object($rs))
     {
      $id=$rsdata->id;
     } 
	return $id;
    }
   }
 /********************************** ADD  QUERY ***************************************/
if(($_POST['action']=="ADD")) 
{
$start=$_POST['start'];
$end=$_POST['end'];
$description=$_POST['description'];
$create_date=date('Y-m-d');
$acadamic_yr=explode("-",$create_date);
$acdmc_yr_res=$acadamic_yr[0];
$Insql=mysql_query("insert into gab_interval(start,end,description,created_date)values('$start','$end','$description','$create_date')");
echo "Added Successfully!!";
}

/********************************** UPDATE QUERY ***************************************/
if(($_POST['action']=="EDIT"))
{
$edit_id = $_POST['edit_id']; 
$start=$_POST['start'];
$end=$_POST['end'];
$description=$_POST['description'];
$create_date=date('Y-m-d');
$acadamic_yr=explode("-",$create_date);
$acdmc_yr_res=$acadamic_yr[0];
$Insql=mysql_query("update gab_interval set start='$start',end='$end',description='$description',created_date='$create_date' where  id='$_POST[edit_id]'");
// $Insql=mysql_query("update ink_pur_sublist set particulars='$particulars' where particulars_id='$_POST[edit_id]'");
// $Insql=mysql_query("update stock_table set item_name='$particulars' where item_id='$_POST[edit_id]'");
//echo "update stock_table set item_name='$particulars' where item_id='$_POST[edit_id]'";
echo "Updated Successfully!!";
}

/********************************************DELETE*****************************************************************/
if($_POST['action']=="delete")
{ 		 
		   $delete2="delete from gab_interval where id='$_POST[id]'";
			mysql_query($delete2);
			echo "<script>alert('Deleted Succesfully')</script>";
			include("gapinterval_entry_list.php");
			
}


?>