<?php
class classProductClosingReconcilation
{
	private $productID=NULL;
	private $locationID=NULL;
	
	private $closingReportID=NULL;
	private $closingReportClosingDate=NULL;
	private $closingReportCreatedBy=NULL;
	private $closingReportClosedBy=NULL;
	private $closingReportStatus=NULL;
	private $closingReportStartTime=NULL;
	private $closingReportEndTime=NULL;
	
	private $reconcileItemQuantity=NULL;
	private $reconcileItemID=NULL;
	private $reconcileStatus=NULL;
	private $reconcileTime=NULL;
	private $reconcileBy=NULL;
	
	private $closingItemID=NULL;
	private $closingItemDate=NULL;
	private $closingItemCount=NULL;
	private $closingItemPacking=NULL;
	
	private $unitPhysicalQuantityInStock=NULL;
	private $unitQuantityInStock=NULL;
	private $unitPrice=NULL;
	
	################################# SET FUNCTIONS ############################################
	
	function setProductID($productID)
	{
		if($productID!='')
		{
			$this->productID = $productID;
		}
		else
		{
			throw new MyException(112100);
		}
	}
	function setLocationID($locationID)
	{
		if($locationID!='')
		{
			$this->locationID = $locationID;
		}
		else
		{
			throw new MyException(112101);
		}
	}
	
	function setClosingReportID($closingReportID)
	{
		if($closingReportID!='')
		{
			$this->closingReportID = $closingReportID;
		}
		else
		{
			throw new MyException(112102);
		}
	}
	function setClosingReportClosingDate($closingReportClosingDate)
	{
		if($closingReportClosingDate!='')
		{
			$this->closingReportClosingDate = $closingReportClosingDate;
		}
		else
		{
			throw new MyException(112103);
		}
	}
	function setClosingReportCreatedBy($closingReportCreatedBy)
	{
		if($closingReportCreatedBy!='')
		{
			$this->closingReportCreatedBy = $closingReportCreatedBy;
		}
		else
		{
			throw new MyException(112104);
		}
	}
	function setClosingReportClosedBy($closingReportClosedBy)
	{
		if($closingReportClosedBy!='')
		{
			$this->closingReportClosedBy = $closingReportClosedBy;
		}
		else
		{
			throw new MyException(112105);
		}
	}
	function setClosingReportStatus($closingReportStatus)
	{
		if($closingReportStatus!='')
		{
			$this->closingReportStatus = $closingReportStatus;
		}
		else
		{
			throw new MyException(112106);
		}
	}
	function setClosingReportStartTime($closingReportStartTime)
	{
		if($closingReportStartTime!='')
		{
			$this->closingReportStartTime = $closingReportStartTime;
		}
		else
		{
			throw new MyException(112107);
		}
	}
	function setClosingReportEndTime($closingReportEndTime)
	{
		if($closingReportEndTime!='')
		{
			$this->closingReportEndTime = $closingReportEndTime;
		}
		else
		{
			throw new MyException(112108);
		}
	}
	
	function setReconcileItemID($reconcileItemID)
	{
		if($reconcileItemID!='')
		{
			$this->reconcileItemID = $reconcileItemID;
		}
		else
		{
			throw new MyException(112109);
		}
	}
	function setReconcileItemQuantity($reconcileItemQuantity)
	{
		if($reconcileItemQuantity!='')
		{
			$this->reconcileItemQuantity = $reconcileItemQuantity;
		}
		else
		{
			throw new MyException(112110);
		}
	}
	function setReconcileStatus($reconcileStatus)
	{
		if($reconcileStatus!='')
		{
			$this->reconcileStatus = $reconcileStatus;
		}
		else
		{
			throw new MyException(112111);
		}
	}
	function setReconcileTime($reconcileTime)
	{
		if($reconcileTime!='')
		{
			$this->reconcileTime = $reconcileTime;
		}
		else
		{
			throw new MyException(112112);
		}
	}
	function setReconcileBy($reconcileBy)
	{
		if($reconcileBy!='')
		{
			$this->reconcileBy = $reconcileBy;
		}
		else
		{
			throw new MyException(112113);
		}
	}
	
	function setClosingItemID($closingItemID)
	{
		if($closingItemID!='')
		{
			$this->closingItemID = $closingItemID;
		}
		else
		{
			throw new MyException(112114);
		}
	}
	function setClosingItemDate($closingItemDate)
	{
		if($closingItemDate!='')
		{
			$this->closingItemDate = $closingItemDate;
		}
		else
		{
			throw new MyException(112115);
		}
	}
	function setClosingItemCount($closingItemCount)
	{
		if($closingItemCount!='')
		{
			$this->closingItemCount = $closingItemCount;
		}
		else
		{
			throw new MyException(112116);
		}
	}
	function setClosingItemPacking($closingItemPacking)
	{
		if($closingItemPacking!='')
		{
			$this->closingItemPacking = $closingItemPacking;
		}
		else
		{
			throw new MyException(112117);
		}
	}
	
	function setUnitPhysicalQuantityInStock($unitPhysicalQuantityInStock)
	{
		if($unitPhysicalQuantityInStock!='')
		{
			$this->unitPhysicalQuantityInStock = $unitPhysicalQuantityInStock;
		}
		else
		{
			throw new MyException(112118);
		}
	}
	function setUnitQuantityInStock($unitQuantityInStock)
	{
		if($unitQuantityInStock!='')
		{
			$this->unitQuantityInStock = $unitQuantityInStock;
		}
		else
		{
			throw new MyException(112119);
		}
	}
	function setUnitPrice($unitPrice)
	{
		if($unitPrice!='')
		{
			$this->unitPrice = $unitPrice;
		}
		else
		{
			throw new MyException(112120);
		}
	}
	
	
	
	
	################################# GET FUNCTIONS ############################################
	
	function getProductID()
	{
		if($this->productID!='')
		{
			return $this->productID;
		}
		else
		{
			throw new MyException(112121);
		}
	}
	function getLocationID()
	{
		if($this->locationID!='')
		{
			return $this->locationID;
		}
		else
		{
			throw new MyException(112122);
		}
	}
	
	function getClosingReportID()
	{
		if($this->closingReportID!='')
		{
			return $this->closingReportID;
		}
		else
		{
			throw new MyException(112123);
		}
	}
	function getClosingReportClosingDate()
	{
		if($this->closingReportClosingDate!='')
		{
			return $this->closingReportClosingDate;
		}
		else
		{
			throw new MyException(112124);
		}
	}
	function getClosingReportCreatedBy()
	{
		if($this->closingReportCreatedBy!='')
		{
			return $this->closingReportCreatedBy;
		}
		else
		{
			throw new MyException(112125);
		}
	}
	function getClosingReportClosedBy()
	{
		if($this->closingReportClosedBy!='')
		{
			return $this->closingReportClosedBy;
		}
		else
		{
			throw new MyException(112126);
		}
	}
	function getClosingReportStatus()
	{
		if($this->closingReportStatus!='')
		{
			return $this->closingReportStatus;
		}
		else
		{
			throw new MyException(112127);
		}
	}
	function getClosingReportStartTime()
	{
		if($this->closingReportStartTime!='')
		{
			return $this->closingReportStartTime;
		}
		else
		{
			throw new MyException(112128);
		}
	}
	function getClosingReportEndTime()
	{
		if($this->closingReportEndTime!='')
		{
			return $this->closingReportEndTime;
		}
		else
		{
			throw new MyException(112129);
		}
	}
	
	function getReconcileItemID()
	{
		if($this->reconcileItemID!='')
		{
			return $this->reconcileItemID;
		}
		else
		{
			throw new MyException(112130);
		}
	}
	function getReconcileItemQuantity()
	{
		if($this->reconcileItemQuantity!='')
		{
			return $this->reconcileItemQuantity;
		}
		else
		{
			throw new MyException(112131);
		}
	}
	function getReconcileStatus()
	{
		if($this->reconcileStatus!='')
		{
			return $this->reconcileStatus;
		}
		else
		{
			throw new MyException(112132);
		}
	}
	function getReconcileTime()
	{
		if($this->reconcileTime!='')
		{
			return $this->reconcileTime;
		}
		else
		{
			throw new MyException(112133);
		}
	}
	function getReconcileBy()
	{
		if($this->reconcileBy!='')
		{
			return $this->reconcileBy;
		}
		else
		{
			throw new MyException(112134);
		}
	}
	
	function getClosingItemID()
	{
		if($this->closingItemID!='')
		{
			return $this->closingItemID;
		}
		else
		{
			throw new MyException(112135);
		}
	}
	function getClosingItemDate()
	{
		if($this->closingItemDate!='')
		{
			return $this->closingItemDate;
		}
		else
		{
			throw new MyException(112136);
		}
	}
	function getClosingItemCount()
	{
		if($this->closingItemCount!='')
		{
			return $this->closingItemCount;
		}
		else
		{
			throw new MyException(112137);
		}
	}
	function getClosingItemPacking()
	{
		if($this->closingItemPacking!='')
		{
			return $this->closingItemPacking;
		}
		else
		{
			throw new MyException(112138);
		}
	}

	function getUnitPhysicalQuantityInStock()
	{
		if($this->unitPhysicalQuantityInStock!='')
		{
			return $this->unitPhysicalQuantityInStock;
		}
		else
		{
			throw new MyException(112139);
		}
	}
	function getUnitQuantityInStock()
	{
		if($this->unitQuantityInStock!='')
		{
			return $this->unitQuantityInStock;
		}
		else
		{
			throw new MyException(112140);
		}
	}
	function getUnitPrice()
	{
		if($this->unitPrice!='')
		{
			return $this->unitPrice;
		}
		else
		{
			throw new MyException(112141);
		}
	}
	

	
	################################# MAIN CHECK FUNCTIONS ############################################
	
	function checkClosingReportAlreadyExistInThisMonth($closing_date,$location_id)
	{
		$startDateArray = explode(' ',$closing_date);
		
		$month = date('m', strtotime($startDateArray[0]));
		$year = $startDateArray[1];
		$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
		
		$startTime = mktime(0,0,0,$month,1,$year);
		$endTime = mktime(23,59,59,$month,$day,$year);
		
		$query = "SELECT productclosing_id FROM product_closing WHERE location_id = '$location_id'";
		
		if($startTime!="")
		{
			if(($endTime!="" && $endTime > $startTime) || $endTime="")
			{
				$query .= " AND closing_date >= $startTime";
			}
		}
		
		if($endTime!="")
		{
			if(($startTime!="" && $startTime < $endTime) || $startTime="")
			{
				$query .= " AND closing_date <= $endTime";
			}
		}
		
		$queryOb = new classQueryGlobal;
		$product_closing_array = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		if(isset($product_closing_array[0]['productclosing_id'])&&$product_closing_array[0]['productclosing_id']!='')
		{
			return 0;
		}
		else
		{
			return 1;
		}
		
	}
	
	function checkClosingReportAlreadyInProgress($status,$location_id)
	{
		$query = "SELECT productclosing_id FROM product_closing WHERE status = '$status' AND location_id = '$location_id'";
		$queryOb = new classQueryGlobal;
		$product_closing_array = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		if(isset($product_closing_array[0]['productclosing_id'])&&$product_closing_array[0]['productclosing_id']!='')
		{
			return 0;
		}
		else
		{
			return 1;
		}
		
	}
	
	function checkLastClosingReportReconciled($location_id)
	{
		$query = "SELECT productclosing_id FROM product_closing WHERE reconcile_status != 'reconciled' AND location_id = '$location_id' ORDER BY closing_date DESC LIMIT 1";
		$queryOb = new classQueryGlobal;
		$product_closing_array = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		//print_r($product_closing_array);
		
		if(isset($product_closing_array[0]['productclosing_id'])&&$product_closing_array[0]['productclosing_id']!='')
		{
			return 0;
		}
		else
		{
			return 1;
		}
		
	}
	
	function checkProductAlreadyClosed($product_id,$productclosing_id)
	{
		$query = "SELECT * FROM  product_closingitems WHERE product_id = '$product_id' AND productclosing_id = '$productclosing_id'";
		$queryOb = new classQueryGlobal;
		$closingitem_array = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		if(isset($closingitem_array[0]['closingitems_id'])&&$closingitem_array[0]['closingitems_id']!='')
		{
			return 0;
		}
		else
		{
			return 1;
		}
	}
	
	/*function checkClosingReportReconciled($productclosing_id)
	{
		$query = "SELECT reconcileitem_id FROM  product_reconcileitems WHERE productclosing_id = '$productclosing_id'";
		$queryOb = new classQueryGlobal;
		$reconcileitem_array = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		if(isset($reconcileitem_array[0]['reconcileitem_id'])&&$reconcileitem_array[0]['reconcileitem_id']!='')
		{
			return 0;
		}
		else
		{
			return 1;
		}
	}*/
	
	function checkClosingReportReconciled($productclosing_id)
	{
		$query = "SELECT productclosing_id FROM  product_closing WHERE productclosing_id = '$productclosing_id' AND reconcile_status = 'reconciled'";
		$queryOb = new classQueryGlobal;
		$reconcileitem_array = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		if(isset($reconcileitem_array[0]['productclosing_id'])&&$reconcileitem_array[0]['productclosing_id']!='')
		{
			return 0;
		}
		else
		{
			return 1;
		}
	}
	
	################################# MAIN INSERT FUNCTIONS ############################################
	
	function createClosingReport()
	{
		if($this->checkClosingReportAlreadyExistInThisMonth($this->getClosingReportClosingDate(),$this->getLocationID()))
		{
			if($this->checkClosingReportAlreadyInProgress('in_progress',$this->getLocationID()))
			{
				
				$closing_date = strtotime($this->getClosingReportClosingDate());
				$created_by = $this->getClosingReportCreatedBy();
				$location_id = $this->getLocationID();
				$status = $this->getClosingReportStatus();
				
				$closing_reports = $this->retrieveClosingReports();
				
				if(isset($closing_reports[0]['closing_end'])&&$closing_reports[0]['closing_end']!='')
				{
					$closing_start = $closing_reports[0]['closing_end'];
				}
				else
				{
					$closing_start = time();
				}
				/*echo '<pre>';
				print_r($closing_start);
				echo '</pre>';
				exit;*/
				$query = "INSERT INTO product_closing 
				(
					closing_date,
					created_by,
					location_id,
					status,
					closing_start
				) 
				VALUES 
				(
					'$closing_date',
					'$created_by',
					'$location_id',
					'$status',
					'$closing_start'
				)";
				$queryOb = new classQueryGlobal;
				$this->closingReportID = $queryOb->check_fetch_query($query,'insert',$server="",$debug_mode="off");
			}
			else
			{
				throw new MyException(112142);
			}
		}
		else
		{
			throw new MyException(112143);
		}
		
	}
	
	function insertItemClosing()
	{
		$product_id = $this->getProductID();
		$location_id = $this->getLocationID();
		$closing_date = $this->getClosingItemDate();
		$closing_count = $this->getClosingItemCount();
		$closing_packing = $this->getClosingItemPacking();
		$productclosing_id = $this->getClosingReportID();
		
		$singleProdOb = new classProduct;
		$prod_loc_relationship = $singleProdOb->retrieveProductLocationRelationship($product_id,$location_id);
		
		$unit_qtyinstock = $prod_loc_relationship[0]['unit_qtyinstock'];
		$unit_price = $prod_loc_relationship[0]['unit_retailprice'];
		
		######## retrieve product detail ########
		$singleProdOb->setProductID($product_id);
		$prod_detail = $singleProdOb->retrieveProductByProductID();
		
		if($closing_packing=='Unit/Tablets') 
		{
			$unit_phy_qtyinstock = $closing_count;
		} 
		elseif($closing_packing=='Leaf') 
		{
			$unit_phy_qtyinstock= $closing_count*($prod_detail[0]['unitperbox']/$prod_detail[0]['leafperbox']);
		} 
		elseif($closing_packing=='Box/Pack') 
		{
			$unit_phy_qtyinstock= $closing_count*$prod_detail[0]['unitperbox'];
			
		}
		
		if($this->checkProductAlreadyClosed($product_id,$productclosing_id))
		{
			$query = "INSERT INTO product_closingitems 
			(
				product_id,
				closing_date,
				closingcount,
				closing_packing,
				unit_phy_qtyinstock,
				unit_qtyinstock,
				unit_price,
				productclosing_id
			) 
			VALUES 
			(
				'$product_id',
				'$closing_date',
				'$closing_count',
				'$closing_packing',
				'$unit_phy_qtyinstock',
				'$unit_qtyinstock',
				'$unit_price',
				'$productclosing_id'
			)";
			$queryOb = new classQueryGlobal;
			$this->closingItemID = $queryOb->check_fetch_query($query,'insert',$server="",$debug_mode="off");
		}
		else
		{
			$query = "UPDATE product_closingitems SET closingcount = '$closing_count' , closing_packing = '$closing_packing' , unit_phy_qtyinstock = '$unit_phy_qtyinstock' WHERE productclosing_id = '$productclosing_id' AND product_id = '$product_id'";
			$queryOb = new classQueryGlobal;
			$queryOb->check_fetch_query($query,'update',$server="",$debug_mode="off");
		}
	
	}
	
	function reconcileProducts()
	{
		$product_id = $this->getProductID();
		$productclosing_id = $this->getClosingReportID();
		$reconcile_qty = $this->getReconcileItemQuantity();
		$reconcile_date = $this->getReconcileTime();
		
		$unit_qtyinstock = $this->getClosingItemCount();
		$location_id = $this->getLocationID();
		
		$query = "INSERT INTO  product_reconcileitems (product_id,productclosing_id,reconcile_qty,reconcile_date) VALUES ('$product_id','$productclosing_id','$reconcile_qty','$reconcile_date')";
		$queryOb = new classQueryGlobal;
		$this->reconcileItemID = $queryOb->check_fetch_query($query,'insert',$server="",$debug_mode="off");
		
		$updateQtyOb = new classProduct;
		$updateQtyOb->setProductID($product_id);
		$updateQtyOb->setLocationID($location_id);
		$updateQtyOb->setProductUnitQtyInStock($unit_qtyinstock);
		$updateQtyOb->updateProductUnitQtyInStock();
	}
	
	################################# MAIN UPDATE FUNCTIONS #############################################
	
	function updateStatusAndClosingEndOfReport()
	{
		$closing_end = $this->getClosingReportEndTime();
		$status = $this->getClosingReportStatus();
		$productclosing_id = $this->getClosingReportID();
		$closed_by = $this->getClosingReportClosedBy();
		
		$query = "UPDATE product_closing SET status = '$status' , closing_end = '$closing_end' , closed_by = '$closed_by' WHERE productclosing_id = '$productclosing_id'";
		$queryOb = new classQueryGlobal;
		$queryOb->check_fetch_query($query,'update',$server="",$debug_mode="off");
		
	}
	
	function updateReconcileReport()
	{
		$reconcile_status = $this->getReconcileStatus();
		$reconcile_by = $this->getReconcileBy();
		$reconcile_time = $this->getReconcileTime();
		$productclosing_id = $this->getClosingReportID();
		$status = $this->getClosingReportStatus();
		
		$query = "UPDATE product_closing SET reconcile_status = '$reconcile_status' , reconcile_by = '$reconcile_by' , reconcile_time = '$reconcile_time' WHERE  productclosing_id = '$productclosing_id' AND status = '$status'";
		$queryOb = new classQueryGlobal;
		$queryOb->check_fetch_query($query,'update',$server="",$debug_mode="off");
		
	}
	
	################################# MAIN DELETE  FUNCTIONS #############################################
	
	function deleteClosingReport()
	{
		$productclosing_id = $this->getClosingReportID();
		
		$query = "DELETE FROM product_closing WHERE productclosing_id = '$productclosing_id'";
		$queryOb = new classQueryGlobal;
		$queryOb->check_fetch_query($query,'delete',$server="",$debug_mode="off");
		
		$query = "DELETE FROM product_closingitems WHERE productclosing_id = '$productclosing_id'";
		$queryOb = new classQueryGlobal;
		$queryOb->check_fetch_query($query,'delete',$server="",$debug_mode="off");
		
	}
	
	################################# MAIN RETRIEVE FUNCTIONS ############################################
	
	function retrieveClosingReports()
	{
		$location_id = $this->getLocationID();
		
		$query = "SELECT * FROM product_closing WHERE location_id = '$location_id' ORDER BY closing_date DESC";
		$queryOb = new classQueryGlobal;
		$closing_report_array = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		if(isset($closing_report_array[0]['productclosing_id'])&&$closing_report_array[0]['productclosing_id']!='')
		{
			return $closing_report_array;
		}
	}
	
	function retrieveLastClosingReport()
	{
		$location_id = $this->getLocationID();
		
		$query = "SELECT * FROM product_closing WHERE location_id = '$location_id' ORDER BY closing_date DESC LIMIT 1";
		$queryOb = new classQueryGlobal;
		$closing_report_array = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		if(isset($closing_report_array[0]['productclosing_id'])&&$closing_report_array[0]['productclosing_id']!='')
		{
			return $closing_report_array;
		}
	}
	
	function retrieveSecondLastClosingReport()
	{
		$location_id = $this->getLocationID();
		
		$query = "SELECT * FROM product_closing WHERE location_id = '$location_id' ORDER BY closing_date DESC LIMIT 1,1";
		$queryOb = new classQueryGlobal;
		$closing_report_array = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		if(isset($closing_report_array[0]['productclosing_id'])&&$closing_report_array[0]['productclosing_id']!='')
		{
			return $closing_report_array;
		}
	}
	
	function retrieveLastClosingQtyOfProduct()
	{
		$product_id = $this->getProductID();
		
		$query = "SELECT * FROM product_closingitems WHERE product_id = '$product_id' ORDER BY closing_date DESC LIMIT 1";
		$queryOb = new classQueryGlobal;
		$closing_report_array = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		if(isset($closing_report_array[0]['closingitems_id'])&&$closing_report_array[0]['closingitems_id']!='')
		{
			return $closing_report_array;
		}
	}
	
	function retrieveClosingReportByReportID()
	{
		$productclosing_id = $this->getClosingReportID();
		$query = "SELECT * FROM product_closing WHERE productclosing_id = '$productclosing_id'";
		$queryOb = new classQueryGlobal;
		$closing_report_array = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		if(isset($closing_report_array[0]['productclosing_id'])&&$closing_report_array[0]['productclosing_id']!='')
		{
			return $closing_report_array;
		}
	}
	
	function retrieveClosingItemByItemID()
	{
		$closingitems_id = $this->getClosingItemID();
		$query = "SELECT * FROM  product_closingitems WHERE closingitems_id = '$closingitems_id'";
		$queryOb = new classQueryGlobal;
		$closingitem_array = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		if(isset($closingitem_array[0]['closingitems_id'])&&$closingitem_array[0]['closingitems_id']!='')
		{
			return $closingitem_array;
		}
	}
	
	function retrieveClosingItemByProductIDAndClosingReportID()
	{
		$product_id = $this->getProductID();
		$productclosing_id = $this->getClosingReportID();
		
		$query = "SELECT * FROM  product_closingitems WHERE product_id = '$product_id' AND productclosing_id = '$productclosing_id'";
		$queryOb = new classQueryGlobal;
		$closingitem_array = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		if(isset($closingitem_array[0]['closingitems_id'])&&$closingitem_array[0]['closingitems_id']!='')
		{
			return $closingitem_array;
		}
	}
	
	function retrieveClosingItemByClosingReportID()
	{
		$productclosing_id = $this->getClosingReportID();
		
		$query = "SELECT * FROM  product_closingitems JOIN products ON product_closingitems.product_id = products.product_id WHERE productclosing_id = '$productclosing_id' ORDER BY products.product_name ASC";
		$queryOb = new classQueryGlobal;
		$closingitem_array = $queryOb->check_fetch_query($query,'select',$server="",$debug_mode="off");
		
		if(isset($closingitem_array[0]['closingitems_id'])&&$closingitem_array[0]['closingitems_id']!='')
		{
			return $closingitem_array;
		}
	}
	
	

	
	
}
?>