<?php
include('db_connection.php');
$Mainclass=new DB_Controller();


$Product_Id=ltrim($_REQUEST['Product_Code'],'^');
$Product_Id=ltrim($Product_Id,'~');



//=====================================//
/*$ScanProductSize=strlen($Product_Id);

if($ScanProductSize<6)
{
   
	
	 $contains_letters = preg_match('/[A-Za-z]+/', $Product_Id);
	 
	 if( $contains_letters==1)
	 {
	    $ProductFristCh=substr($Product_Id, 0, 1);
	    $RestProductCh=substr($Product_Id, 1, 5);
		$RestNewCode=sprintf("%05d", $RestProductCh);
		 
		$CreatePrCode=$ProductFristCh.$RestNewCode;
	 }
	 else{
	 
	       $CreatePrCode=sprintf("%06d", $Product_Id);
	 }
	 
	  $Product_Id=$CreatePrCode;

}
else{

      $Product_Id=$Product_Id;

}

*/



//==========================================//


//=========check diamond========//

if(substr($Product_Id, -1)=="D")
{
    $Product_Id=$Product_Id;
}
else
{ 
     $Product_Id=substr($Product_Id, 0, 11);
}


//$Product_Id=substr($Product_Id, 0, 6);


$Order_No=$_REQUEST['Order_No'];

$Indent_No=$_REQUEST['Indent_No'];


if($Product_Id!='')
{




	
	

		 
		 
	
	  
	   $UpdateIndDtl="update gold_indent_details set Scan2='1', Sequence='".date('Y-m-d H:i:s')."' where Order_No='".$Order_No."' and Product_Code='".$Product_Id."' and Scan2='' order By SLN limit 1";
	   $rs=mysqli_query($Mainclass->dbh,$UpdateIndDtl);
	   
	   $r=mysqli_affected_rows($Mainclass->dbh);
	   
	   echo $r;
	

	

	

	
	
	
	
	

}
?>