<?php
/***************************************************************************
 *																		  *
 * Copyright (c) 2005 ISPG Technologies (I) Pvt Ltd. All rights reserved.   *
 *																		  *
 * This  is  commercial  software,  only  users  who have purchased a valid *
 * license  and  accept  to the terms of the  License Agreement can install *
 * and use this program.													*
 *																		  *
 ****************************************************************************
 * PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
 * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.			*
 ****************************************************************************/
//$Id: BusinessModel.php, v 1.0 2011/06/14 20:52:11
class BusinessTypeModel extends Model {
    public function getParentBusinessType($languageIDs, $busTypeID = "", $root_enable = "", $ajaxPage = "", $status = "", $languageXml = '') {
        $arr_businessType = array();
        $sql              = "					SELECT 
													busTyp.businessTypeID,
													busTypDet.businessTypeName 
												FROM 
													`" . DB_PREFIX . "business_types` AS busTyp
												 LEFT JOIN 
													`" . DB_PREFIX . "business_type_details` AS busTypDet 
														ON 
															(busTyp.businessTypeID = busTypDet.businessTypeID)
												 WHERE 
													busTyp.businessTypeStatus != 'Delete'
													AND
														busTypDet.languageID =" . (int) $languageIDs['Current'] . " 
													AND 
														busTyp.businessTypeParent = '0'";
        if ($busTypeID) {
            $sql .= "AND 
														busTyp.businessTypeID != '" . $busTypeID . "'";
        }
        if ($status) {
            $sql .= "	AND 
														busTyp.businessTypeStatus = '" . $status . "' 
													AND 
														busTyp.businessTypeID 
														IN
															(
																SELECT 
																	businessTypeId 
																FROM 
																	`" . DB_PREFIX . "business_types`
																WHERE 
																	businessTypeStatus = 'Active'
															)";
        }
        $sql .= " ORDER BY busTypDet.businessTypeName ASC ";
        $resParentBusinessType = $this->ObjDatabase->readValues($sql);
        if ($root_enable == 1) {
            $arr_businessType[0][0] = "0";
            $arr_businessType[0][1] = $languageXml['lblRootLevel'];
            for ($cnt = 0; $cnt < count($resParentBusinessType); $cnt++) {
                $arr_businessType[$cnt + 1][0] = $resParentBusinessType[$cnt]['businessTypeID'];
                $arr_businessType[$cnt + 1][1] = $resParentBusinessType[$cnt]['businessTypeName'];
            }
        } else {
            for ($cnt = 0; $cnt < count($resParentBusinessType); $cnt++) {
                $arr_businessType[$cnt][0] = $resParentBusinessType[$cnt]['businessTypeID'];
                $arr_businessType[$cnt][1] = $resParentBusinessType[$cnt]['businessTypeName'];
            }
        }
        if ($ajaxPage == 1) {
            return $resParentBusinessType;
        } else {
            return $arr_businessType;
        }
    }
    public function getSubBusinessType($languageIDs, $busTypeID = "", $root_enable = "", $status = "") {
        $defaultLanguageID    = $languageIDs['Default'];
        $currentLanguageID    = $languageIDs['Current'];
        $sql_subbusiness_type = "SELECT A.businessTypeID,B.businessTypeName FROM `" . DB_PREFIX . "business_types` AS A
											 LEFT JOIN `" . DB_PREFIX . "business_type_details` AS B ON (A.businessTypeID = B.businessTypeID)
							 				 WHERE A.businessTypeStatus != 'Delete' AND B.languageID = '" . $currentLanguageID . "' ";
        $sql_subbusiness_type .= " AND  A.businessTypeParent = '" . $busTypeID . "'";
        if ($status) {
            $sql_subbusiness_type .= " AND  A.businessTypeStatus = '" . $status . "'";
        }
        $sql_subbusiness_type .= " ORDER BY B.businessTypeName ASC ";
        $resParentBusinessType  = $this->ObjDatabase->readValues($sql_subbusiness_type);
        $arr_BusinessType[0][0] = "0";
        $arr_BusinessType[0][1] = "Root Level";
        if ($root_enable == 1) {
            $arr_businessType[0][0] = "0";
            $arr_businessType[0][1] = "Root Level";
            for ($cnt = 0; $cnt < count($resParentBusinessType); $cnt++) {
                $arr_businessType[$cnt + 1][0] = $resParentBusinessType[$cnt]['businessTypeID'];
                $arr_businessType[$cnt + 1][1] = $resParentBusinessType[$cnt]['businessTypeName'];
            }
        } else {
            for ($cnt = 0; $cnt < count($resParentBusinessType); $cnt++) {
                $arr_businessType[$cnt][0] = $resParentBusinessType[$cnt]['businessTypeID'];
                $arr_businessType[$cnt][1] = $resParentBusinessType[$cnt]['businessTypeName'];
            }
        }
        return $arr_businessType;
    }
    public function getBusinessTypeCount($languageIDs) {
        $defaultLanguageID     = $languageIDs['Default'];
        $currentLanguageID     = $languageIDs['Current'];
        $sqlSelectBusinessType = "SELECT ";
        $sqlSelectBusinessType .= " count(*) as bcount FROM `" . DB_PREFIX . "business_types` AS A 
												 LEFT JOIN `" . DB_PREFIX . "business_type_details` AS B ON (A.businessTypeID = B.businessTypeID)
				 								 WHERE A.businessTypeStatus != 'Delete' AND B.languageID = '" . $currentLanguageID . "' AND A.businessTypeParent='0' ";
        $res = $this->ObjDatabase->readValue($sqlSelectBusinessType);
        return $res['bcount'];
    }
    public function getBusSubTypeCount($languageIDs, $bustypeID = '', $mycheckboxes = '') {
        $existTypename     = array();
        $existTypename1    = array();
        $existTypename2    = array();
        //$existType = array();
        $existType         = "";
        $existTypenamear   = "";
        $defaultLanguageID = $languageIDs['Default'];
        $currentLanguageID = $languageIDs['Current'];
        if ($bustypeID != '') {
            $sql = "	SELECT 
									businessTypeID 
								FROM 
									`" . DB_PREFIX . "business_to_types` AS busToTyp  
								LEFT JOIN 
									" . DB_PREFIX . "business AS bus 
									ON (busToTyp.businessID = bus.businessID)
								WHERE  
									bus.businessStatus != 'Deleted' 
									AND 
										busToTyp.businessTypeID = '" . $bustypeID . "' ";
            $sql .= "		UNION
										
												SELECT 
													businessTypeID
												FROM 
													`" . DB_PREFIX . "business_types` 
												WHERE 
													businessTypeParent = '" . $bustypeID . "' 
												AND 
													businessTypeStatus !='Delete'
											";
            $btypecount = $this->ObjDatabase->numberOfRecords($sql);
            return $btypecount;
        }
    }
    public function listBusinessTypeLevels($languageIDs, $sub = "", $status = "", $page = NULL, $limitFrom = 0, $limitTo = "") {
        $defaultLanguageID = $languageIDs['Default'];
        $currentLanguageID = $languageIDs['Current'];
        $busTypes          = array();
        $where             = '';
        $ii                = 0;
        $sql               = "		SELECT ";
        if ($limitTo) {
            $sql .= "	SQL_CALC_FOUND_ROWS ";
        }
        $sql .= "	* 
							FROM 
								`" . DB_PREFIX . "business_types` AS busTyp 
							LEFT JOIN 
								`" . DB_PREFIX . "business_type_details` AS busTypDet 
									ON 
										(busTyp.businessTypeID = busTypDet.businessTypeID)	 
							WHERE 
								busTyp.businessTypeStatus != 'Delete' 
								AND 
									busTypDet.languageID = '" . $currentLanguageID . "' 
								AND
									busTyp.businessTypeParent='0' ";
        if (trim($sub) > 0) {
            $sql .= " AND  busTyp.businessTypeID  =  '" . $sub . "' ";
        }
        if ($status) {
            $sql .= " AND  busTyp.businessTypeStatus = '" . $status . "'";
        }
        $sql .= " ORDER BY busTypDet.businessTypeName ASC ";
        if ($limitTo) {
            $sql .= "LIMIT  " . $limitFrom . "," . $limitTo . " ";
        }
        $res            = $this->ObjDatabase->readValues($sql);
        $RecordMaxCount = $this->ObjDatabase->getRecordMaxCount();
        foreach ($res as $rows) {
            $busTypes[$ii]['businessTypeID']          = $rows["businessTypeID"];
            $busTypes[$ii]['businessTypeName']        = $rows["businessTypeName"];
            $busTypes[$ii]['businessTypeDescription'] = $rows["businessTypeDescription"];
            $busTypes[$ii]['businessTypeStatus']      = $rows["businessTypeStatus"];
            $parent                                   = $rows["businessTypeId"];
            $jj                                       = 0;
            $res                                      = $this->ObjDatabase->readValues("SELECT * FROM `" . DB_PREFIX . "business_types` AS busTyp 
	 												 LEFT JOIN `" . DB_PREFIX . "business_type_details` AS busTypDet ON (busTyp.businessTypeID = busTypDet.businessTypeID) 
													 WHERE  busTyp.businessTypeStatus != 'Delete' AND busTypDet.languageID = '" . $currentLanguageID . "' AND busTyp.businessTypeParent= '" . $parent . "' 	ORDER BY busTypDet.businessTypeName ASC ");
            foreach ($res as $rows) {
                $resBusiness               = $this->ObjDatabase->readValue("SELECT count(*) AS subBusinesscount FROM `" . DB_PREFIX . "business_to_types` AS busToTyp  
																LEFT JOIN " . DB_PREFIX . "business AS bus ON (busToTyp.businessID = bus.businessID)
																WHERE busToTyp.businessTypeID = '" . $rows["businessTypeID"] . "' AND bus.businessStatus != 'Deleted'");
                $busTypes[$ii]['sub'][$jj] = array(
                    "businessTypeID" => $rows["businessTypeID"],
                    "businessTypeName" => htmlspecialchars($rows["businessTypeName"]),
                    "businessTypeDescription" => htmlspecialchars($rows["businessTypeDescription"]),
                    "businessTypeStatus" => $rows["businessTypeStatus"],
                    "subBusinesscount" => $resBusiness["subBusinesscount"]
                );
                $jj++;
            }
            $ii++;
        }
        return array(
            $busTypes,
            $RecordMaxCount
        );
    }
    public function getBusinessTypeByID($languageIDs, $busTypeID = "", $status = "") {
        $languageID = $languageIDs['Current'];
        $sql        = "	SELECT 
									* 
								FROM 
									`" . DB_PREFIX . "business_types` AS busTyp 
								LEFT JOIN 
									`" . DB_PREFIX . "business_type_details` AS busTypDet 
										ON (busTyp.businessTypeID = busTypDet.businessTypeID
												AND busTypDet.languageID = '" . $languageID . "'
											) 
								WHERE busTyp.businessTypeID = '" . $busTypeID . "' ";
        if ($status) {
            $sql .= " AND  busTyp.businessTypeStatus = '" . $status . "'";
        }
        $resBusinessType = $this->ObjDatabase->readValue($sql);
        return $resBusinessType;
    }
    public function isBusinessTypeWithLangExists($businessTypeID, $languageID) {
        $sql    = "	SELECT 
										COUNT(*)
									FROM 
										" . DB_PREFIX . "business_type_details
									WHERE 
										businessTypeID = '" . $businessTypeID . "'
									AND
										languageID	= '" . $languageID . "'
								 ";
        $result = $this->ObjDatabase->readvalue($sql);
        if ($result[0] > 0) {
            return true;
        } else {
            return false;
        }
    }
    public function submitBusinessType($languageIDs, $POST, $busTypeID = "") {
        $defaultLanguageID       = $languageIDs['Default'];
        $currentLanguageID       = $languageIDs['Current'];
        $allLanguages            = $languageIDs['AllList'];
        $businessTypeParent      = $POST['businessTypeParent'];
        $businessTypeStatus      = $POST['businessTypeStatus'];
        $businessTypeName        = $this->escape($POST['businessTypeName']);
        $businessTypeDescription = $this->escape($POST['businessTypeDescription']);
        if ($busTypeID > 0) {
            $Qry1 = $this->ObjDatabase->setQuery("UPDATE  " . DB_PREFIX . "business_types SET 
											 		`businessTypeParent` = '" . $businessTypeParent . "',
											 		`businessTypeStatus` = '" . $businessTypeStatus . "'
		  									 		 WHERE `businessTypeId` ='" . $busTypeID . "'");
            if ($this->isBusinessTypeWithLangExists($busTypeID, $currentLanguageID)) {
                $Qry2 = $this->ObjDatabase->setQuery("UPDATE  " . DB_PREFIX . "business_type_details SET 
													`businessTypeName` = '" . $businessTypeName . "',
													`businessTypeDescription` = '" . $businessTypeDescription . "'
													 WHERE languageID = '" . $currentLanguageID . "' AND `businessTypeId` ='" . $busTypeID . "'");
            } else {
                $Qry2 = $this->ObjDatabase->setQuery("INSERT INTO " . DB_PREFIX . "business_type_details 
											(`businessTypeID`,`languageID`,`businessTypeName`, `businessTypeDescription`) 
											VALUES 
											('" . $businessTypeID . "','" . $defaultLanguageID . "','" . $businessTypeName . "', '" . $businessTypeDescription . "')");
            }
            if ($businessTypeParent > 0) {
                $Qry3 = $this->ObjDatabase->setQuery("UPDATE  " . DB_PREFIX . "business_types SET 
											 		`businessTypeParent` = '" . $businessTypeParent . "',
											 		`businessTypeStatus` = '" . $businessTypeStatus . "'
		  									 		 WHERE `businessTypeParent` ='" . $busTypeID . "'");
            }
        } else {
            $Qry1           = $this->ObjDatabase->setQuery("INSERT INTO " . DB_PREFIX . "business_types 
														(`businessTypeParent`,`businessTypeStatus`) 
														VALUES 
														('" . $businessTypeParent . "','" . $businessTypeStatus . "')");
            $businessTypeID = $this->ObjDatabase->getInsertId();
            foreach ($allLanguages as $language) {
                $Qry2 = $this->ObjDatabase->setQuery("INSERT INTO " . DB_PREFIX . "business_type_details 
											(`businessTypeID`,`languageID`,`businessTypeName`, `businessTypeDescription`) 
											VALUES 
											('" . $businessTypeID . "','" . $language . "','" . $businessTypeName . "', '" . $businessTypeDescription . "')");
            }
        }
    }
    public function updateBusinessTypeBulkStatus($POST, $languageIDs = '') {
        $existTypename = array();
        $changestatus  = $POST['changestatus'];
        $busTypeID     = $POST['busTypeID'];
        if ($changestatus != '') {
            if ($busTypeID != '') {
                $Qry1 = $this->ObjDatabase->setQuery("UPDATE  " . DB_PREFIX . "business_types SET 
													  `businessTypeStatus` = '" . $changestatus . "' 
													   WHERE `businessTypeID` ='" . $busTypeID . "'");
            }
        }
        return 1;
    }
    public function isBusinessTypeNameExists($languageIDs, $businessTypeParent, $businessTypeName, $businessTypeID) {
        $businessTypeName   = $this->escape($businessTypeName);
        $businessTypeParent = $this->escape($businessTypeParent);
        $defaultLanguageID  = $languageIDs['Default'];
        $currentLanguageID  = $languageIDs['Current'];
        $sql                = "	SELECT 
							COUNT(busTyp.businessTypeID) AS businessTypeCount 
						FROM 
							`" . DB_PREFIX . "business_types` AS busTyp 
						LEFT JOIN 
							`" . DB_PREFIX . "business_type_details` AS busTypDet 
								ON 
									(busTyp.businessTypeID = busTypDet.businessTypeID) ";
        $where              = "	WHERE 
							busTypDet.languageID='" . $currentLanguageID . "' 
							AND 
								busTypDet.businessTypeName='" . $businessTypeName . "' 
							AND 
								busTyp.businessTypeStatus != 'Delete' ";
        if ($businessTypeParent > 0) {
            $where .= " AND busTyp.businessTypeParent='" . $businessTypeParent . "' ";
        }
        if ($businessTypeID > 0) {
            $where .= " AND busTyp.businessTypeID != '" . $businessTypeID . "' ";
        }
        $businessTypeCount = $this->ObjDatabase->readValue($sql . $where);
        if ($businessTypeCount['businessTypeCount'] > 0) {
            echo "1";
        } else {
            echo "0";
        }
    }
    public function isBusinessExits($busTypeID) {
        $resBusiness = $this->ObjDatabase->readValue("SELECT * FROM `" . DB_PREFIX . "business_to_types` AS busToTyp  
																LEFT JOIN " . DB_PREFIX . "business AS bus ON (busToTyp.businessID = bus.businessID)
																WHERE  bus.businessStatus != 'Deleted' AND  busToTyp.businessTypeID = '" . $busTypeID . "' OR busToTyp.businessTypeID IN (SELECT businessTypeID FROM `" . DB_PREFIX . "business_types` WHERE businessTypeParent = '" . $busTypeID . "'  AND businessTypeStatus !='Delete')");
        if (count($resBusiness) > 0) {
            return "error";
        } else {
            return true;
        }
    }
    public function destroyBusinessType($busTypeID) {
        $sqlSelectBusinessType = $this->ObjDatabase->readValue("SELECT * FROM `" . DB_PREFIX . "business_types` WHERE businessTypeParent = '" . $busTypeID . "'  AND businessTypeStatus !='Delete'");
        $resBusiness           = $this->ObjDatabase->readValue("SELECT * FROM `" . DB_PREFIX . "business_to_types` AS busToTyp  
																LEFT JOIN " . DB_PREFIX . "business AS bus ON (busToTyp.businessID = bus.businessID)
																WHERE busToTyp.businessTypeID = '" . $busTypeID . "' AND bus.businessStatus != 'Deleted'");
        if (count($sqlSelectBusinessType) > 0 || count($resBusiness) > 0) {
            return "error";
        } else {
            $updateBusinessType = $this->ObjDatabase->setQuery("UPDATE  " . DB_PREFIX . "business_types SET 
											 		`businessTypeStatus` = 'Delete'
		 									 		 WHERE `businessTypeId` ='" . $busTypeID . "'");
        }
    }
    public function reassignAndDestroyBusinessType($businessTypeID1, $businessTypeID2) {
        $updateBusinessType1 = $this->ObjDatabase->setQuery("UPDATE  " . DB_PREFIX . "business_types SET 
											 		`businessTypeParent` = '" . $businessTypeID2 . "'
		 									 		 WHERE `businessTypeParent` ='" . $businessTypeID1 . "'");
        $updateBusinessType2 = $this->ObjDatabase->setQuery("UPDATE  " . DB_PREFIX . "business_types SET 
											 		`businessTypeStatus` = 'Delete'
		 									 		 WHERE `businessTypeId` ='" . $businessTypeID1 . "'");
        $updateBusinessType2 = $this->ObjDatabase->setQuery("UPDATE  " . DB_PREFIX . "business_to_types SET `businessTypeID` = '" . $businessTypeID2 . "' WHERE `businessTypeID` ='" . $businessTypeID1 . "'");
        return 1;
    }
    public function reassignInactivateBusType($businessTypeID1 = '', $businessTypeID2, $businessTypeIDar = '', $businessTypeIDar222 = '') {
        if ($businessTypeID1 != '') {
            $updateBusinessType1 = $this->ObjDatabase->setQuery("UPDATE  " . DB_PREFIX . "business_types SET 
														`businessTypeParent` = '" . $businessTypeID2 . "'
														 WHERE `businessTypeParent` ='" . $businessTypeID1 . "'");
            $updateBusinessType3 = $this->ObjDatabase->setQuery("UPDATE  " . DB_PREFIX . "business_types SET 
														`businessTypeStatus` = 'Inactive'
														 WHERE `businessTypeId` ='" . $businessTypeID1 . "'");
        } else if (count($businessTypeIDar) > 0) {
            for ($i = 0; $i < count($businessTypeIDar); $i++) {
                $businessTypeID1     = $businessTypeIDar[$i];
                $updateBusinessType1 = $this->ObjDatabase->setQuery("UPDATE  " . DB_PREFIX . "business_types SET 
														`businessTypeParent` = '" . $businessTypeID2 . "'
														 WHERE `businessTypeParent` ='" . $businessTypeID1 . "'");
                if ($businessTypeID1 != $businessTypeID2) {
                    $updateBusinessType3 = $this->ObjDatabase->setQuery("UPDATE  " . DB_PREFIX . "business_types SET 
														`businessTypeStatus` = 'Inactive'
														 WHERE `businessTypeId` ='" . $businessTypeID1 . "'");
                }
            }
        }
        return 1;
    }
    //get business by parent business ID	
    function getParentBySubID($busTypeID = "", $status = "") {
        $sql = "	SELECT 
													busTyp.*,
													busTypDet.businessTypeName 
												FROM 
													`" . DB_PREFIX . "business_types` AS busTyp,
													`" . DB_PREFIX . "business_type_details` AS busTypDet
												WHERE 
													busTyp.businessTypeID 
														IN 
															(
																SELECT 
																	businessTypeParent 
																FROM 
																	`" . DB_PREFIX . "business_types` 
																WHERE 
																	businessTypeID= '" . $busTypeID . "'
															)
															AND
																busTyp.businessTypeID=busTypDet.businessTypeID ";
        if ($status) {
            $sql .= " AND busTyp.businessTypeStatus = '" . $status . "'";
        }
        $resBusinessType = $this->ObjDatabase->readValue($sql);
        return $resBusinessType;
    }
    //FUNCTION TO GET BUSINESS TYPE OPTION
    public function getBusinessTypeOption($languageIDs, $businessTypeOthers = "", $defaultValue = "", $lan = 'others') {
        $defultLanguageID            = $languageIDs['Default'];
        //SET DEFAULT LANGUAGE ID	
        $currentLanguageID           = $languageIDs['Current'];
        //SET SELECTED/CUURENT LANGUAGE ID
        $sql                         = "	SELECT 
								" . DB_PREFIX . "business_type_details.businessTypeID,
								" . DB_PREFIX . "business_type_details.businessTypeName 
							FROM 
								" . DB_PREFIX . "business_type_details,
								" . DB_PREFIX . "business_types 
							WHERE 
								" . DB_PREFIX . "business_type_details.businessTypeID=" . DB_PREFIX . "business_types.businessTypeID 
								AND
									businessTypeStatus='Active' 
								AND 
									" . DB_PREFIX . "business_types.businessTypeParent='0'
								AND  
									" . DB_PREFIX . "business_type_details.languageID='" . $currentLanguageID . "' ORDER BY businessTypeName ASC";
        $resSelectBusinessTypeParent = $this->ObjDatabase->readValuesSlave($sql);
        $busParentCount              = 0;
        foreach ($resSelectBusinessTypeParent as $resBusinessTypeParent) {
            $businessTypeID                                          = $resBusinessTypeParent['businessTypeID'];
            //get businessSubtype details
            $sql                                                     = "	SELECT 
									" . DB_PREFIX . "business_type_details.businessTypeID,
									" . DB_PREFIX . "business_type_details.businessTypeName 
								FROM 
									" . DB_PREFIX . "business_type_details,
									" . DB_PREFIX . "business_types
								WHERE 
									" . DB_PREFIX . "business_type_details.businessTypeID=" . DB_PREFIX . "business_types.businessTypeID
									AND
										businessTypeStatus='Active'
									AND 
										" . DB_PREFIX . "business_types.businessTypeParent='" . $businessTypeID . "' 
									AND 
										" . DB_PREFIX . "business_types.businessTypeParent 
											IN
												(
													SELECT 
														busTyp.businessTypeID 
													FROM
														" . DB_PREFIX . "business_types busTyp
													LEFT JOIN
														" . DB_PREFIX . "business_type_details busTypDet 
														ON 
															busTyp.businessTypeID=busTypDet.businessTypeID 
													WHERE 
														busTyp.businessTypeStatus='Active' 
														AND 
															busTypDet.languageID='" . $currentLanguageID . "'
												) 
									AND
										" . DB_PREFIX . "business_type_details.languageID='" . $currentLanguageID . "' ORDER BY businessTypeName ASC";
            $resSelectBusinessTypeSub                                = $this->ObjDatabase->readValuesSlave($sql);
            $resSelectBusinessTypeParent[$busParentCount]['SubType'] = $resSelectBusinessTypeSub;
            $busParentCount++;
        }
        $resSelectBusinessTypeParentOpt = $resSelectBusinessTypeParent;
        $listContent                    = '';
        foreach ($resSelectBusinessTypeParentOpt as $listOptionGroup) {
            if ($defaultValue == $listOptionGroup['businessTypeID']) {
                $listContent .= '<option selected="selected" value="' . $listOptionGroup['businessTypeID'] . '">&raquo;&nbsp;' . $listOptionGroup['businessTypeName'] . '</option>';
            } else {
                $listContent .= '<option value="' . $listOptionGroup['businessTypeID'] . '">&raquo;&nbsp;' . $listOptionGroup['businessTypeName'] . '</option>';
            }
            foreach ($listOptionGroup['SubType'] as $SubType) {
                if ($defaultValue == $SubType['businessTypeID']) {
                    $sel = 'selected';
                } else {
                    $sel = '';
                }
                if ($defaultValue == $SubType['businessTypeID']) {
                    $listContent .= '<option selected="selected" value="' . $SubType['businessTypeID'] . '">&nbsp;&nbsp;&raquo;&nbsp;' . $SubType['businessTypeName'] . '</option>';
                } else {
                    $listContent .= '<option value="' . $SubType['businessTypeID'] . '">&nbsp;&nbsp;&raquo;&nbsp;' . $SubType['businessTypeName'] . '</option>';
                }
            }
        }
        if ($defaultValue == "0") {
            $sel = 'selected="selected"';
        } else {
            $sel = '';
        }
        if ($businessTypeOthers == "others") {
            $listContent .= '<option ' . $sel . ' value="0">' . $lan . '</option>';
        }
        return $listContent;
    }
    //END OF FUNCTION	
    public function getMaxcountForBusinesstype() {
        $sqlSelectBusinessType = "	SELECT 
														busTyp.businessTypeID 
													FROM
														`" . DB_PREFIX . "business_types` AS busTyp
													WHERE 
														busTyp.businessTypeStatus!= 'Delete'";
        $res                   = $this->ObjDatabase->readValues($sqlSelectBusinessType);
        return count($res);
    }
}