<?php 
function getSelectBox_menulist($db, $SelName, $jrequired,$Attr,$selId=null) {		
	$StrQry="select MenuId AS Id,MenuName AS Name from a_menus where IsActive = '1' order by MenuName asc";		
	$resQry = $db->get_rsltset($StrQry);		
	$strSelHtml =  "<select class='form-control select2 ".$jrequired."' id='".$SelName."' name='".$SelName."'  ".$Attr." ><option value=''>Select</option>";
	
	if(!empty($resQry)) {
		foreach($resQry as $val) {
		$sel='';
			if($selId==$val['Id'])
				$sel=' selected="selected" ';
			$strSelHtml=$strSelHtml."<option value=".$val['Id']." ".$sel.">".$val['Name']."</option>";
		}
	}
	
	$strSelHtml=$strSelHtml."</select>";
	
	return $strSelHtml;	
}


function getSelectBox_rolelist($db, $SelName, $Attr,$selId=null) {
	$StrQry="select RoleId AS Id,RoleName AS Name from a_roles where IsActive = '1' and RoleId <> 1 order by RoleName asc";	
	$resQry = $db->get_rsltset($StrQry);		
	$strSelHtml =  "<select class='form-control select2 ".$Attr."' id='".$SelName."' name='".$SelName."' ><option value=''>Select</option>";
	
	if(!empty($resQry)) {
		foreach($resQry as $val) {
		$sel='';
			if($selId==$val['Id'])
				$sel=' selected="selected" ';
			$strSelHtml=$strSelHtml."<option value=".$val['Id']." ".$sel.">".$val['Name']."</option>";
		}
	}
	
	$strSelHtml=$strSelHtml."</select>";
	
	return $strSelHtml;	
}


function getSelectBox_companylist($db, $SelName, $Attr,$selId=null,$prop=null) {
	$StrQry="select company_id AS Id,company_name AS Name from m_company where IsActive = '1' order by company_name asc";
	
	$resQry = $db->get_rsltset($StrQry);		
	$strSelHtml =  "<select class='form-control select2 ".$Attr."' id='".$SelName."' name='".$SelName."' ".$prop." ><option value=''>Select Company</option>";
	
	if(!empty($resQry)) {
		foreach($resQry as $val) {
		$sel='';
			if($selId==$val['Id'])
				$sel=' selected="selected" ';
			$strSelHtml=$strSelHtml."<option value=".$val['Id']." ".$sel.">".$val['Name']."</option>";
		}
		
	}
	
	$strSelHtml=$strSelHtml."</select>";
	
	return $strSelHtml;	
}



function getSelectBoxFinancialYearlist($db, $SelName, $Attr, $selId = null, $prop = null)
{
    $StrQry = "SELECT financial_id AS Id, CONCAT(YEAR(f_start_date), ' - ', YEAR(f_end_date)) AS Name, f_start_date AS StartDate, f_end_date AS EndDate FROM m_financial_year ORDER BY IsActive DESC, f_end_date DESC";

    $resQry = $db->get_rsltset($StrQry);
    $strSelHtml = "<select class='form-control select2 " . $Attr . "' id='" . $SelName . "' name='" . $SelName . "' " . $prop . "><option value=''>Select Financial Year</option>";

    if (!empty($resQry)) {
        $ind = 0;
        foreach ($resQry as $val) {
            $sel = '';
            if ($selId == $val['Id']) {
                $sel = ' selected="selected" ';
            } elseif ($selId == null && $ind == 0) {
                $sel = ' selected="selected" ';
            }
            $strSelHtml = $strSelHtml . "<option value=" . $val['Id'] . " " . $sel . " data-start-date='" . $val['StartDate'] . "' data-end-date='" . $val['EndDate'] . "'>" . $val['Name'] . "</option>";
            $ind++;
        }
    }

    $strSelHtml = $strSelHtml . "</select>";

    return $strSelHtml;
}



function getSelectStockAvailbilitylist($db, $SelName, $Attr,$selId=null,$prop=null) {
		
	$resQry = $db->get_rsltset($StrQry);		
	$strSelHtml =  "<select class='form-control select2 ".$Attr."' id='".$SelName."' name='".$SelName."' ".$prop." ><option value=''>All</option>";
	
	$strSelHtml=$strSelHtml."<option value='2'>Sold</option>";
	$strSelHtml=$strSelHtml."<option value='0'>Available</option>";
	
	$strSelHtml=$strSelHtml."</select>";
	
	return $strSelHtml;	
}


function getSelectBox_supplierlist($db, $SelName, $Attr,$selId=null,$prop=null) {
	$StrQry="select sup_id AS Id,sup_name AS Name from m_supplier where IsActive = '1' and sup_product = '2' order by sup_name asc";
	
	$resQry = $db->get_rsltset($StrQry);		
	$strSelHtml =  "<select class='form-control select2 ".$Attr."' id='".$SelName."' name='".$SelName."' ".$prop." ><option value=''>Select Supplier</option>";
	
	if(!empty($resQry)) {
		foreach($resQry as $val) {
		$sel='';
			if($selId==$val['Id'])
				$sel=' selected="selected" ';
			$strSelHtml=$strSelHtml."<option value=".$val['Id']." ".$sel.">".$val['Name']."</option>";
		}
		
	}
	
	$strSelHtml=$strSelHtml."</select>";
	
	return $strSelHtml;	
}
function getSelectBox_supplier_product_list($db, $SelName, $Attr,$selId=null,$prop=null) {
	$StrQry="select sup_id AS Id,sup_name AS Name from m_supplier where IsActive = '1' and sup_product = '1' order by sup_name asc";
	
	$resQry = $db->get_rsltset($StrQry);		
	$strSelHtml =  "<select class='form-control select2 ".$Attr."' id='".$SelName."' name='".$SelName."' ".$prop." ><option value=''>Select Supplier</option>";
	
	if(!empty($resQry)) {
		foreach($resQry as $val) {
		$sel='';
			if($selId==$val['Id'])
				$sel=' selected="selected" ';
			$strSelHtml=$strSelHtml."<option value=".$val['Id']." ".$sel.">".$val['Name']."</option>";
		}
		
	}
	
	$strSelHtml=$strSelHtml."</select>";
	
	return $strSelHtml;	
}
function getSelectBox_product_list($db, $SelName, $Attr,$selId=null,$prop=null) {
	$StrQry="select product_id AS Id, product_name AS Name from m_product where IsActive = '1' order by product_name asc";
	
	$resQry = $db->get_rsltset($StrQry);		
	$strSelHtml =  "<select class='form-control select2 ".$Attr."' id='".$SelName."' name='".$SelName."' ".$prop." ><option value=''>Select Product Type</option>";
	
	if(!empty($resQry)) {
		foreach($resQry as $val) {
		$sel='';
			if($selId==$val['Id'])
				$sel=' selected="selected" ';
			$strSelHtml=$strSelHtml."<option value=".$val['Id']." ".$sel.">".$val['Name']."</option>";
		}
		
	}
	
	$strSelHtml=$strSelHtml."</select>";
	
	return $strSelHtml;	
}

function getSelectBox_customerlist($db, $SelName, $Attr,$selId=null,$prop=null) {
	$StrQry="select cus_id AS Id,cus_name AS Name from m_customer where IsActive = '1' order by cus_name asc";
	
	$resQry = $db->get_rsltset($StrQry);		
	$strSelHtml =  "<select class='form-control select2 ".$Attr."' id='".$SelName."' name='".$SelName."' ".$prop." ><option value=''>Select Customer</option>";
	
	if(!empty($resQry)) {
		foreach($resQry as $val) {
		$sel='';
			if($selId==$val['Id'])
				$sel=' selected="selected" ';
			$strSelHtml=$strSelHtml."<option value=".$val['Id']." ".$sel.">".$val['Name']."</option>";
		}
		
	}
	
	$strSelHtml=$strSelHtml."</select>";
	
	return $strSelHtml;	
}

?>