<?php
@session_start();
error_reporting(0);
include("config.php");


$ltr=$_POST[ltr];
$paytype=$_POST[paytype];

$upte=$_POST[upte];
/***********************************/
$mode = $_REQUEST[mode];
$flag = $_REQUEST[flag];
$tpoint=$_POST[tpoint];
$oldltr=$_POST[oldltr];
/***********************************/
$id=$_POST[id];
/***********************************/
	
  //add minus     
  
    	  
		  
		   
		  if($upte == 'add')
		  {
			    $que4 = sprintf("SELECT * from  customer_product_point WHERE cid = '%s' ",$id);
                if(!($res4=mysql_query($que4))){echo mysql_error($que4); exit;}
                $customer_pointdata=mysql_fetch_assoc($res4);
				$createpoint = $customer_pointdata[point];
			  
			  
			    $ltrnew = $ltr  + $oldltr;
			   
			  $query_update=sprintf("UPDATE record SET price='%s',pay_typ='%s' where id='%s' ",$ltrnew,$paytype,$id);
	      if(!($result=mysql_query($query_update))){echo $query_update.mysql_error(); exit;}
	      //header("Location:report-list.php?flag=dn");exit;
		  
		     $balpoint = $tpoint  + $ltr;
			
			   $queryadd=sprintf("UPDATE customer_product_point SET point='$balpoint' where upid='%s' ",$id); 
	      if(!($resultqueryadd=mysql_query($queryadd))){echo $queryadd.mysql_error(); exit;}
	      header("Location:report-list.php?flag=dn");exit;
			  
			  
		  } else {
			  
			   $que4 = sprintf("SELECT * from  customer_product_point WHERE cid = '%s' ",$id);
                if(!($res4=mysql_query($que4))){echo mysql_error($que4); exit;}
                $customer_pointdata=mysql_fetch_assoc($res4);
				$createpoint = $customer_pointdata[point];
			  
			  
			    $ltrnew =   $oldltr - $ltr;
			   
			  $query_update=sprintf("UPDATE record SET price='%s',pay_typ='%s' where id='%s' ",$ltrnew,$paytype,$id);
	      if(!($result=mysql_query($query_update))){echo $query_update.mysql_error(); exit;}
	      //header("Location:report-list.php?flag=dn");exit;
		  
		      $balpoint = $tpoint  - $ltr;
			
			  $queryadd=sprintf("UPDATE customer_product_point SET point='$balpoint' where upid='%s' ",$id); 
	      if(!($resultqueryadd=mysql_query($queryadd))){echo $queryadd.mysql_error(); exit;}
	      header("Location:report-list.php?flag=dn");exit;
			  
			  
			  
		  }
		

?>
