<?php


function admin_login ($username, $password) {





	$user_qry = db_query("SELECT * FROM admin_tbl WHERE username='".$username."' && password='".$password."' && status='Y' ");





	$status= 'N';


	if(db_num_rows($user_qry)>0) {


		$adminArr = db_fetch_assoc($user_qry);


		$_SESSION['LOGINNAME'] = $adminArr['contact_name'];


		$_SESSION['LOGINUSERNAME'] = $adminArr['username'];





		$status= 'Y';


	} 





	return ($status);


}





function getUserName ($slno) {





	$user_qry = db_query("SELECT * FROM admin_tbl WHERE slno='".$slno."' ");


	


	if(db_num_rows($user_qry)>0) {


		$adminArr = db_fetch_assoc($user_qry);


		$name = $adminArr['contact_name'];


	} 





	return ($name);


}





function date_display_daymonthyear($display_date) {


	$dt = new DateTime($display_date);


  	echo $dt->format('j F, Y');


}





function display_date_display_daymonthyear($display_date) {


	$dt = new DateTime($display_date);


  	return($dt->format('j F, Y'));


}





function date_short_daymonthyear($display_date) {


	$dt = new DateTime($display_date);


  	echo $dt->format('j M Y');


}





function create_valid_flnm($catgName) {	





	/*$flnm_1 = strip_tags(strtolower(trim($catgName)));


    $flnm_1 = str_replace("'", "", $flnm_1);


    $flnm_1 = str_replace("\?", "", $flnm_1);    	    


 	$flnm_1 = preg_replace("/[^_0-9a-zA-Z]/i", " ", stripslashes($flnm_1));


    $flnm_1 = preg_replace("/[[:space:]]+/i", " ",$flnm_1);


    $flnm_1 = str_replace(" ", "-",trim($flnm_1));    


	return ($flnm_1);*/


	$flnm_1 = strip_tags(trim(strtolower($catgName)));


	$flnm_1 = str_replace(["'", "?"], "", $flnm_1);


	// Allow "/" and replace all other unwanted characters with a space


	$flnm_1 = preg_replace("/[^\/_0-9a-z]/", " ", $flnm_1);


	// Replace multiple spaces with a single space, then convert spaces to hyphens


	$flnm_1 = str_replace(" ", "-", trim(preg_replace("/\s+/", " ", $flnm_1)));


	return ($flnm_1);


}





function getCountryName($contName) {


	//echo "SELECT * FROM country WHERE country_code='".$contName."' <br>";


	$country_qry = db_query("SELECT * FROM country WHERE country_code='".$contName."' ");


	$contArr = db_fetch_assoc($country_qry);


	if(!empty($contArr['country_name'])) {


		$country_name = $contArr['country_name'];


	}


	else {


		$country_name = $contName;	


	}


	return $country_name;


}





function getProductCategoryName($catg_slno) {





	$catgName ='';


	if(!empty($catg_slno)) {


		$pcategory_qry = db_query("SELECT * FROM product_category WHERE slno='".$catg_slno."' ");


		$catgArr = db_fetch_assoc($pcategory_qry);


		$catgName = $catgArr['category_name'];


	}


	return ($catgName);


}





// delete all files and sub-folders from a folder


function deleteDirwithFile($dir) {


	foreach(glob($dir.'/*') as $file) {


		if(is_dir($file)) {


			deleteDirwithFile($file);


		}


		else {


			unlink($file);


		}		


	}


	rmdir($dir);


}





function display_pagination ($arr){


	$pageno = ($arr['page'])?($arr['page']):('1');





	if(!empty($pageno)) {


		//$pageno = $arr['page'];


		$limit = $arr['limit'];


		$numrows = $arr['numrows'];


		$link 	 = $arr['link'];


		$filename = $_SERVER['SCRIPT_FILENAME'];


		$filename = basename($filename); //file name





		$startFrom = ($page * $limit) - $limit;


		$total_pages = ceil($numrows/$limit);





		$firstPage = 1;


		$nextPage = $page + 1;


		$previousPage = $page - 1;





		$disp_last_record = $startFrom+$limit;





		if($disp_last_record>$numrows) {


			$disp_last_record = $numrows;


		}


		?>


		<style type="text/css">


		.pagination-bg { background-color: #e585463b; padding: 0; height: 30px; 


			vertical-align: middle; display: flex; align-items: center; padding: 13px }


		.pagination-bg span { font-size: 13px }


		.pagination1>li { display: inline }


		.pagination1 { display: inline-block; padding-left: 0; margin: 20px 20px;


		 border-radius: 4px }


		.pagination1>li a { font-weight: 400; color: black }	


		.row {margin-right: 0px!important; margin-left: 0px!important;}


		</style>


		<div class="row">





		<div class="col-sm-8  pagination-bg">


		<span>Page <?php echo $pageno;?> of <?php echo ceil($numrows/$limit);?>, Showing <?php echo $limit; ?> of <?php echo $numrows; ?> Records || Current Page No.: <b class="text-danger" style="font-size: 18px;"><?php echo $pageno;?></b></span>


		</div>		





		<div class="col-sm-4 text-right  pagination-bg">


			<ul class="pagination1">


				<li><a href="?page=1<?php echo $link;?>">First</a></li>


				<li class="<?php if($pageno <= 1){ echo 'disabled'; } ?>" style="padding: 5px;">


				<?php


				if($pageno <= 1) {


					?>


					<a href="#">&laquo; Prev</a>


					<?php


				}


				else {


					?>


					<a href="<?php echo $filename;?>?page=<?php echo ($pageno -1)?><?php echo $link;?>">&laquo; Prev</a>


					<?php


				}?>


				</li>





				<li class="<?php if($pageno >= $total_pages){ echo 'disabled'; } ?>" style="padding: 5px;">


				<?php


				if($pageno >= $total_pages) {


					?>


					<a href="#">Next &raquo;</a>


					<?php


				}


				else {


					?>


					<a href="<?php echo $filename;?>?page=<?php echo ($pageno + 1)?><?php echo $link;?>">Next &raquo;</a>


					<?php


				}?>


				</li>


				<li><a href="?page=<?php echo $total_pages; ?><?php echo $link;?>">Last</a></li>


			</ul>


			</div>


		</div>


		<?php


	}


}


function Get_Order_No(){


	$sql=db_query("SELECT max(right(order_no,4)) as odrn from order_members");	


	$row=db_fetch_assoc($sql);


	if($row['odrn']!=''){


		$orderid=$row['odrn'];


		$Number=$orderid+1;	


	} else { $Number="0001"; }


	$pInvID = "TFHORD/".sprintf('%05d',$Number);


	return $pInvID;


}





function getIndianCurrency(float $number) {


    $decimal = round($number - ($no = floor($number)), 2) * 100;


    $hundred = null;


    $digits_length = strlen($no);


    $i = 0;


    $str = array();


    $words = array(0 => '', 1 => 'one', 2 => 'two',


        3 => 'three', 4 => 'four', 5 => 'five', 6 => 'six',


        7 => 'seven', 8 => 'eight', 9 => 'nine',


        10 => 'ten', 11 => 'eleven', 12 => 'twelve',


        13 => 'thirteen', 14 => 'fourteen', 15 => 'fifteen',


        16 => 'sixteen', 17 => 'seventeen', 18 => 'eighteen',


        19 => 'nineteen', 20 => 'twenty', 30 => 'thirty',


        40 => 'forty', 50 => 'fifty', 60 => 'sixty',


        70 => 'seventy', 80 => 'eighty', 90 => 'ninety');





    $digits = array('', 'hundred','thousand','lakh', 'crore');


    while( $i < $digits_length ) {


        $divider = ($i == 2) ? 10 : 100;


        $number = floor($no % $divider);


        $no = floor($no / $divider);


        $i += $divider == 10 ? 1 : 2;


        if ($number) {


            $plural = (($counter = count($str)) && $number > 9) ? 's' : null;


            $hundred = ($counter == 1 && $str[0]) ? ' and ' : null;


            $str [] = ($number < 21) ? $words[$number].' '. $digits[$counter]. $plural.' '.$hundred:$words[floor($number / 10) * 10].' '.$words[$number % 10]. ' '.$digits[$counter].$plural.' '.$hundred;


        } else $str[] = null;


    }


    $Rupees = implode('', array_reverse($str));


    $paise = ($decimal > 0) ? "." . ($words[$decimal / 10] . " " . $words[$decimal % 10]) . ' Paise' : '';


    //return ($Rupees ? $Rupees . 'Rupees ' : '') . $paise;





    return ($Rupees ? $Rupees . '' : '') . $paise;


}





function mail_sent_func($mailArr) {


	$mailto     = $mailArr['MEM_EMAIL'];


    $mailsub    = $mailArr['MAIL_SUBJECT'];


    $mailfrom   = $mailArr['MAIL_FROM'];


    $mail_msg   = $mailArr['MEM_MESSAGE']; 





    $header = "From: Thefamoushalwai.com <$mailfrom>\n";


	$header .= "X-Mailer: PHP/". phpversion();


	$header .= "X-Priority: 3 \n";


	//$header .= "Cc:afgh@somedomain.com \r\n";


	$header .= "MIME-Version: 1.0\r\n";


	$header .= "Content-Type: text/html; charset=iso-8859-1\n"; 


	//$header .= "Content-type: text/html\r\n";*/	


	//display_mail_sent($mailArr, $mailFrom);		


	mail($mailto, $mailsub, $mail_msg, $header);





}





function frontend_pagination ($arr){


	$pageno = ($arr['page'])?($arr['page']):('1');





	if(!empty($pageno)) {


		//$pageno = $arr['page'];


		$limit = $arr['limit'];


		$numrows = $arr['numrows'];


		$link 	 = $arr['link'];


		$filename = $_SERVER['SCRIPT_FILENAME'];


		$filename = basename($filename); //file name





		$startFrom = ($page * $limit) - $limit;


		$total_pages = ceil($numrows/$limit);





		$firstPage = 1;


		$nextPage = $page + 1;


		$previousPage = $page - 1;





		$disp_last_record = $startFrom+$limit;





		if($disp_last_record>$numrows) {


			$disp_last_record = $numrows;


		}


		?>


		<style type="text/css">


		.pagination-bg { background-color: #e585463b; padding: 0; height: 30px; 


			vertical-align: middle; display: flex; align-items: center; padding: 13px }


		.pagination-bg span { font-size: 13px }


		.pagination1>li { display: inline }


		.pagination1 { display: inline-block; padding-left: 0; margin: 20px 20px;


		 border-radius: 4px }


		.pagination1>li a { font-weight: 400; color: black }	


		.row {margin-right: 0px!important; margin-left: 0px!important;}


		</style>


		<div class="row">





		<div class="col-sm-8  pagination-bg">


		<span>Page <?php echo $pageno;?> of <?php echo ceil($numrows/$limit);?>, Showing <?php echo $limit; ?> of <?php echo $numrows; ?> Records || Current Page No.: <b class="text-danger" style="font-size: 18px;"><?php echo $pageno;?></b></span>


		</div>		





		<div class="col-sm-4 text-right  pagination-bg">


			<ul class="pagination1">


				<li><a href="?page=1<?php echo $link;?>">First</a></li>


				<li class="<?php if($pageno <= 1){ echo 'disabled'; } ?>" style="padding: 5px;">


				<?php


				if($pageno <= 1) {


					?>


					<a href="#">&laquo; Prev</a>


					<?php


				}


				else {


					?>


					<a href="<?php echo $filename;?>?page=<?php echo ($pageno -1)?><?php echo $link;?>">&laquo; Prev</a>


					<?php


				}?>


				</li>





				<li class="<?php if($pageno >= $total_pages){ echo 'disabled'; } ?>" style="padding: 5px;">


				<?php


				if($pageno >= $total_pages) {


					?>


					<a href="#">Next &raquo;</a>


					<?php


				}


				else {


					?>


					<a href="<?php echo $filename;?>?page=<?php echo ($pageno + 1)?><?php echo $link;?>">Next &raquo;</a>


					<?php


				}?>


				</li>


				<li><a href="?page=<?php echo $total_pages; ?><?php echo $link;?>">Last</a></li>


			</ul>


			</div>


		</div>


		<?php


	}


}





function full_category_name ($cid) {


	$prod_catg_qry = db_query("select * from product_category WHERE cid='".$cid."' ");


	if(db_num_rows($prod_catg_qry)>0) {


		$catgArr = db_fetch_assoc($prod_catg_qry);





		return ($catgArr['product_catg']);


	}


	else {


		return ($cid);


	}


}





function Get_imageResize($imageResourceId,$width,$height) {





  $dimetions=calculateDimensions($width,$height,1000,1000);


  $targetWidth =$dimetions['width'];


  $targetHeight =$dimetions['height'];  


  $targetLayer=imagecreatetruecolor($targetWidth,$targetHeight);


  imagecopyresampled($targetLayer,$imageResourceId,0,0,0,0,$targetWidth,$targetHeight, $width,$height);


  return $targetLayer;


}





function calculateDimensions($width,$height,$maxwidth,$maxheight) {





  if($width != $height) {


    if($width > $height) {


      $t_width = $maxwidth;


      $t_height = (($t_width * $height)/$width);


      //fix height


      if($t_height > $maxheight) {


          $t_height = $maxheight;


          $t_width = (($width * $t_height)/$height);


      }


    }


    else {


      $t_height = $maxheight;


      $t_width = (($width * $t_height)/$height);


      //fix width


      if($t_width > $maxwidth) {


        $t_width = $maxwidth;


        $t_height = (($t_width * $height)/$width);


      }


    }


  }


  else {


    $t_width = $t_height = min($maxheight,$maxwidth);


  }





  return array('height'=>(int)$t_height,'width'=>(int)$t_width);


}





function Addcustomer_product_detail($memCartArr, $pay_amount, $couponid, $txnid) {





	if(!empty($_SESSION["cart_item"]) && !empty($_SESSION['ADDRESSTODELIVER'])) {





		$shipArr = db_fetch_assoc(db_query("SELECT * FROM member_shipping_address WHERE member_id = '".$memCartArr['member_id']."' && slno='".$_SESSION['ADDRESSTODELIVER']."' && status='Y' "));





		db_query("INSERT INTO payment_order SET member_id='".$memCartArr['member_id']."', total_amount='".$pay_amount."', coupon_code='".$couponid."', coupon_price='".$coupon_price."', ipaddress='".$_SERVER['REMOTE_ADDR']."', txnid='".$txnid."', payment_status='I', recv_date='".date("Y-m-d")."', recv_time='".date('g:i:s')."', shipping_price='".$pinArr['shipping_price']."', yname='".$shipArr['bname']."', email='".$shipArr['bemail']."',	mobile='".$shipArr['bmobile']."', mobile2='".$shipArr['bmobile2']."',	house_num='".$shipArr['house_num']."', address1='".$shipArr['baddress']."',	landmark='".$shipArr['landmark']."', city='".$shipArr['bcity']."',	state='".$shipArr['bstate']."', zip='".$shipArr['bzip']."', country='".$shipArr['bcountry']."', cod_status='".$_SESSION['COD_STATUS']."' ");





		$slno = db_insert_id($GLOBALS['con']);





		$orderID = "WONDERTOYSORD".$slno;


		//echo "UPDATE payment_order SET order_no = '".$orderID."' WHERE slno='".$slno."' <br><br>";


		db_query("UPDATE payment_order SET order_no = '".$orderID."' WHERE slno='".$slno."' ");





		if($slno>0) {


			$cartSalePrice =0; $totalDiscount=0;


			foreach ($_SESSION["cart_item"] as $key => $value) {


				$expld_cart_val = explode("_", $value);


				$prod_slno = $expld_cart_val[0];				


				$pquantity = $expld_cart_val[1];


				$storageSlno = $expld_cart_val[2];





				$cartProdArr = db_fetch_assoc(db_query("SELECT * from product_tbl WHERE slno='".$prod_slno."' "));





				if(!empty($_SESSION['WUSERTYPE']) && $_SESSION['WUSERTYPE']=='S') {


		


					$selling_price = $cartProdArr['selling_price_b2b'];


					if(empty($cartProdArr['b2b_qty'])) { //minimum qty 3 should be supplier


						$cartProdArr['b2b_qty']=3;


					}


					$pquantity = ($cartProdArr['b2b_qty']*$pquantity);





					//$b2b_unit_qty = ($cartProdArr['b2b_qty']*$pquantity);


					$cartSalePrice = ($cartProdArr['selling_price_b2b']*$pquantity);	


					$order_from="B2B";


					$b2b_qty = $cartProdArr['b2b_qty'];


				}


				else {


					$order_from="B2C";


					$selling_price = $cartProdArr['selling_price'];


					$cartSalePrice = ($cartProdArr['selling_price']*$pquantity);				


					$b2b_qty = 0;


					if(!empty($cartProdArr['product_mrp'])) {


			        	$Discount = $cartProdArr['product_mrp']-$cartProdArr['selling_price'];


			        	if($Discount!='') {


			        		$getPer = ($Discount/$cartProdArr['product_mrp'])*100;


			        		$totalDiscount = ($Discount*$pquantity);


			        	}


			        }


				}





				db_query("INSERT INTO product_order_detail SET product_storage_slno='".$storageSlno."', payment_order_slno = '".$slno."', order_no = '".$orderID."', member_id ='".$memCartArr['member_id']."', product_slno='".$prod_slno."', product_qty ='".$pquantity."', product_mrp='".$cartProdArr['product_mrp']."', selling_price='".$selling_price."', b2b_qty='".$b2b_qty."', order_from='".$order_from."', totalDiscount='".$totalDiscount."', discount_val='".$getPer."', final_amount='".$cartSalePrice."', recv_date='".date("Y-m-d")."', recv_time='".date("g:i:s")."' ");


			}


		}		


	}


	else {


		$slno = 0;


	}	


	return($slno);


}





function update_products_purchase_qrty($payment_order_slno) {


	//echo "SELECT * FROM product_order_detail WHERE payment_order_slno='".$payment_order_slno."'<br>";


	$order_qry = db_query("SELECT * FROM product_order_detail WHERE payment_order_slno='".$payment_order_slno."' ");


	if(db_num_rows($order_qry)>0) {


	 	while($oArr = db_fetch_assoc($order_qry)) {


	 		$saleQty = $oArr['product_qty'];


	 		//echo "UPDATE product_tbl SET used_qty=used_qty+$saleQty, stock_qty=stock_qty-$saleQty WHERE slno='".$oArr['product_slno']."'<br><br>";


	 		db_query("UPDATE product_tbl SET used_qty=used_qty+$saleQty, stock_qty=stock_qty-$saleQty WHERE slno='".$oArr['product_slno']."' ");


	 	}


	}


}





function payment_process_title($page) {


	?>


	<section class="mt-3">


		<div class="container"> 


		    <div class="row justify-content-center">


		        <div class="col-sm-12 pt-2 pb-3">


		            <ol class="list-unstyled step-indicator step-indicator-responsive">


		            	 <li class="step-1">


		                    <div class="step">1</div>


		                    <div class="caption"> Sign In </div>


		                </li>





		                <li class="step-1 <?php echo ($page=='2')?('active'):('')?>">


		                    <div class="step">2</div>


		                    <div class="caption"> Address Information </div>


		                </li>


		                <li class="step-2 <?php echo ($page=='3')?('active'):('')?>">


		                    <div class="step">3</div>


		                    <div class="caption">Order Summary & Payment</div>


		                </li>


		                <li class="step-3">


		                    <div class="step">4</div>


		                    <div class="caption">Complete Payment</div>


		                </li>


		            </ol>


		        </div>


		    </div>


		</div>


	</section> 


	<?php


}


function Display_Product_Discount($slno) {





	$prodQry = db_query("SELECT * from product_tbl WHERE status='Y' and slno='".$slno."' and selling_price!='' and product_mrp!='' "); 





	$getPerval='';


	if(db_num_rows($prodQry)>0) {


		$naArr = db_fetch_assoc($prodQry);


		$Discount = $naArr['product_mrp']-$naArr['selling_price'];


		if($Discount!='') {


    		$getPer = round(($Discount/$naArr['product_mrp'])*100);    		


    		$getPerval = " &nbsp; <span class='discounPrice text-success'>".$getPer."% off";


    	} 	


	} 


	return $getPerval;


}


function Get_Fetch_Data($attributeN, $dataV, $tableN) {


	//echo "SELECT * FROM $tableN WHERE $attributeN='".$dataV."' ";


	$getQry = db_query("SELECT * FROM $tableN WHERE $attributeN='".$dataV."' ");


	$getArr = db_fetch_assoc($getQry);


	return $getArr;


}


function authenticate_shipment() {


    $arr=[


      "email"=>"support@wondertoys.co.in", # Enter Registered Username in Shiprocket


      "password"=>"Aryand31!",


    ];


    $login_data=json_encode($arr);


    $curl = curl_init();


    curl_setopt_array($curl, array(


      CURLOPT_URL => "https://apiv2.shiprocket.in/v1/external/auth/login",


      CURLOPT_RETURNTRANSFER => true,


      CURLOPT_ENCODING => "",


      CURLOPT_MAXREDIRS => 10,


      CURLOPT_TIMEOUT => 0,


      CURLOPT_FOLLOWLOCATION => true,


      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,


      CURLOPT_CUSTOMREQUEST => "POST",


      CURLOPT_POSTFIELDS =>$login_data,


      CURLOPT_HTTPHEADER => array(


      "Content-Type: application/json"


      ),


    ));


    $response = curl_exec($curl);


    curl_close($curl);


    return($response);	


}


function Send_Shiprocket_Request($slno){


	$Rows=Get_Fetch_Data('slno',$slno,'payment_order');


	//$ShippingTot=$Rows['shipping']+$Rows['shipping_gst'];


	$shipmentAuth=authenticate_shipment();


	$Loginshipment=json_decode($shipmentAuth);	


	//echo "SELECT * from product_order_detail where payment_order_slno='".$Rows['slno']."' order by pid";


	$Psql=db_query("SELECT * from product_order_detail where payment_order_slno='".$Rows['slno']."' order by pid");


	while($Prow=db_fetch_array($Psql)) {


		$stateName = $GLOBALS['state_name_arr'][$Rows['state']];


		$prodArr=Get_Fetch_Data('slno',$Prow['product_slno'],'product_tbl');


		


		$sku_id = $prodArr['sku_id'];


		$Discount=$Prow['totalDiscount'];





		$productarry[]= array(


			'name' => "$prodArr[product_name]",


			'sku' => "$sku_id",


			'units' => "1",


			'selling_price' => "$Prow[selling_price]",


		    'discount' => "" ,


			'tax' => "",


			'hsn' => "" 


		);	


	}


	$PostFields = array(


		'order_id' => "$Rows[order_no]",


	    'order_date' => date('Y-m-d H:i'),


		'pickup_location' => "Primary",


		'channel_id'=> "CUSTOM",


		'comment'=> "Reseller: Wonder Toys",


		'billing_customer_name'=> "$Rows[yname]",


		'billing_last_name'=> " ",


		'billing_address'=> "$Rows[address1]",


		'billing_address_2'=> "$Rows[landmark]",


		'billing_city'=> "$Rows[city]",


		'billing_pincode'=> "$Rows[zip]",


		'billing_state'=> "$stateName",


		'billing_country'=> "India",


		'billing_email'=> "$Rows[email]",


		'billing_phone'=> "$Rows[mobile]",


		'shipping_is_billing'=> true,


		'shipping_customer_name'=> "",


		'shipping_last_name'=> "",


		'shipping_address'=> "",


		'shipping_address_2'=> "",


		'shipping_city'=> "",


		'shipping_pincode'=> "",


		'shipping_country'=> "",


		'shipping_state'=> "",


		'shipping_email'=> "",


		'shipping_phone'=> "",


		'order_items'=> $productarry,


		'payment_method'=> "Prepaid",


		'shipping_charges'=> "0",


		'giftwrap_charges'=> "0",


		'transaction_charges'=> "0",


		'total_discount'=> "0",


		'sub_total'=> "$Rows[total_amount]",


		'length'=> "7.99",


		'breadth'=> "76",


		'height'=> "170",


		'weight'=> "199",


	);


	$headers = array(


		'Content-Type: application/json',


		'Authorization: Bearer '.$Loginshipment->token


	);





	/*echo "<pre>";


	print_r($PostFields);


	echo "</pre>";


	echo "<pre>";


	print_r($headers);


	echo "</pre>";*/





	$ch = curl_init();


	curl_setopt( $ch,CURLOPT_URL, 'https://apiv2.shiprocket.in/v1/external/orders/create/adhoc');


	curl_setopt( $ch,CURLOPT_POST, true );


	curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );


	curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );


	curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );


	curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $PostFields ) );


	$result = curl_exec($ch );


	curl_close( $ch );


	$ResData=json_decode($result);


	$shipment_id=$ResData->shipment_id;	


	$ship_orderid=$ResData->order_id;


	//echo "UPDATE payment_order set shipment_id='".$shipment_id."', ship_order_id='".$ship_orderid."' where slno='".$Rows['slno']."' <br>";	


	db_query("UPDATE payment_order set shipment_id='".$shipment_id."', ship_order_id='".$ship_orderid."' where slno='".$Rows['slno']."' ");	


	return $result;	


}


?>


