GIF89a php
Current File : /home/hencockfreshchic/public_html/app_old/libs.php
<?php
function discountCal($sale_price,$real_price)
{
	$diff=$real_price-$sale_price;
	$comm=round((100*$diff)/$sale_price);

	return $comm;
}

function profile($conn,$user_id,$field)
{
	$sql="SELECT * FROM `app_admin` WHERE `sr`='".$user_id."'";
	$rs=mysqli_query($conn,$sql);
	$row=mysqli_fetch_assoc($rs);
	$data=$row[$field];

	return $data;
}

function findDP($conn,$img,$gender)
{
	if($img<>"NA")
	{
		$data="admin.cpanel/".$img;
	}
	else
	{
		if($gender=="Male")
		{
			$data="icon/male.png";
		}
		else
		{
			$data="icon/woman.png";
		}
	}

	return $data;
}
function prodView($conn,$prod_id)
{
			  $sql="SELECT * FROM `prod_view` WHERE `prod_id`='".$prod_id."'";
              $rs=mysqli_query($conn,$sql);
              $chk=mysqli_num_rows($rs);
              $row=mysqli_fetch_assoc($rs);
              if($chk>0){
               $view=$row["total_view"]+1;            
               $sqlV3="UPDATE `prod_view` SET `total_view`='".$view."',`last_updated_date`='".date('Y-m-d')."' WHERE `prod_id`='".$prod_id."'";
               $rsV3=mysqli_query($conn,$sqlV3);
              }
              else 
              {
               $sqlV2="INSERT INTO `prod_view`(`prod_id`, `total_view`, `last_updated_date`) VALUES ('".$prod_id."','1','".date('Y-m-d')."')";
               $rsV2=mysqli_query($conn,$sqlV2);
              }
}

function totalPrice($prod_price,$qty)
{
	$price=$prod_price*$qty;

	return $price;
}

function totalCart_amount($conn,$user_id)
{
	$sql="SELECT * FROM `my_cart` WHERE `user_id`='".$user_id."'";
	$rs=mysqli_query($conn,$sql);
	$data=0;
	while($row=mysqli_fetch_array($rs))
	{
		$data=$data+($row['qty']*$row['prod_price']);
	}

	return $data;
}

function cartdeliveryCharge($conn,$user_id)
{
	$sql="SELECT * FROM `my_cart` WHERE `user_id`='".$user_id."'";
	$rs=mysqli_query($conn,$sql);
	$data=0;
	while($row=mysqli_fetch_array($rs))
	{
		$sqlP="SELECT * FROM `products` WHERE `sr`='".$row['prod_id']."'";
		$rsP=mysqli_query($conn,$sqlP);
		$rowP=mysqli_fetch_assoc($rsP);

		$data=$data+($rowP["ship_chrg"]);
	}

	return $data;
}

function findCoupon()
{
	$data=$_COOKIE["coupon_val"];
	if($data=="")
	{
		$data=0;
	}

	return $data;
}

function shipAddress($conn,$user_id)
{
	$sql="SELECT * FROM `shipping_address` WHERE `user_id`='".$user_id."' && `default_adds`='1'";
	$rs=mysqli_query($conn,$sql);
	$chk=mysqli_num_rows($rs);
	if($chk>0)
	{
		$row=mysqli_fetch_assoc($rs);
		$data=$row["user_name"].",".$row["address"]."-".$row["pincode"];
	}
	else
	{
		$data="NA";
	}
	

	return $data;
}

function findOrderStatus($order_status)
{
	if($order_status=="New")
	{
		$data="Under confirmation";
	}
	else if($order_status=="Confirm")
	{
		$data="Order confirmed";
	}
	else if($order_status=="Process")
	{
		$data="Under processing";
	}
	else if($order_status=="Return")
	{
		$data="Product Returned";
	}
	else if($order_status=="Delivered")
	{
		$data="Product Delivered";
	}
	else if($order_status=="Reject")
	{
		$data="Order Rejected";
	}
	else if($order_status=="Dispatch")
	{
		$data="Order Dispached";
	}
	else if($order_status=="On Way")
	{
		$data="Order On The Way";
	}
   else if($order_status=="Out")
   {
      $data="Out Of Delivery";
   }
	else if($order_status=="Refund")
	{
		$data="Refund initiated";
	}
	else if($order_status=="CompleteRefund")
	{
		$data="Product refunded";
	}

	return $data;
}

function dateFormates($date)
{
	$data=date("F, D-Y", strtotime($date));

	return $data;
}

function orderType($order_type)
{
	if($order_type=="1")
	{
		$data="Prepaid Order";
	}
	else
	{
		$data="Paid on Delivery";
	}

	return $data;
}


function companyDetails($ops)
{
	if($ops=="name")
	{
		$data="Hencock Fresh Chicken";
	}

	return $data;
}



?>