public static function addVillage_climate($obj_Village_climate)
 {
     $db = config::dbconfig();
     $obj_retresult = new returnResult();
     $obj_Village_climate->ClimateId = DAL_manageVillage_climate::getLastVillage_climateId() + 1;
     $sql = "INSERT INTO tbl_village_climate (ClimateId,VillageId,ClimateReagion,RainFall,Temparature,Humidity) \n\t\tVALUES (" . common::noSqlInject($obj_Village_climate->ClimateId) . "," . common::noSqlInject($obj_Village_climate->VillageId) . "," . "'" . common::noSqlInject($obj_Village_climate->ClimateReagion) . "'" . "," . common::noSqlInject($obj_Village_climate->RainFall) . "," . common::noSqlInject($obj_Village_climate->Temparature) . "," . common::noSqlInject($obj_Village_climate->Humidity) . ");";
     $rs = mysql_query($sql);
     if (mysql_affected_rows() > 0) {
         $obj_retresult->type = 1;
         $obj_retresult->msg = "success";
         $obj_retresult->data = $obj_Village_climate;
     } else {
         $obj_retresult->type = 0;
         $obj_retresult->msg = "failed";
     }
     return $obj_retresult;
 }
function updateVillage_climate($sessionkey, $appcode, $Village_climatedata)
{
    $main_result = "<VPROFILERESULT>";
    $main_result .= "<AUTHSTATUS>0</AUTHSTATUS>";
    $userId = ValidateSession($sessionkey, $appcode);
    if ($userId > -1) {
        $main_result = "<AUTHSTATUS>1</AUTHSTATUS>";
        $obj_Village_climate = new Village_climate();
        foreach ($Userdata["[UPPERTEMPLATENAME"] as $key => $child) {
            switch ($key) {
                case "CLIMATEID":
                    $obj_Village_climate->ClimateId = $child;
                    break;
                case "VILLAGEID":
                    $obj_Village_climate->VillageId = $child;
                    break;
                case "CLIMATEREAGION":
                    $obj_Village_climate->ClimateReagion = $child;
                    break;
                case "RAINFALL":
                    $obj_Village_climate->RainFall = $child;
                    break;
                case "TEMPARATURE":
                    $obj_Village_climate->Temparature = $child;
                    break;
                case "HUMIDITY":
                    $obj_Village_climate->Humidity = $child;
                    break;
            }
        }
        $obj_retResult_Village_climate = DAL_manageVillage_climate::updateVillage_climate($obj_Village_climate);
        if ($obj_retResult_Village_climate->type == 1) {
            $main_result .= "<RESULTSTATUS>1</RESULTSTATUS>";
            $main_result .= getVillage_climateXml($obj_retResult_Village_climate->data);
        } else {
            $main_result .= "<RESULTSTATUS>0</RESULTSTATUS>";
        }
    }
    $main_result .= "</VPROFILERESULT>";
    return $main_result;
}
 public static function isChildVillage_climate($ClimateId, $ChildClimateId)
 {
     $ischild = false;
     $obj_retResult = DAL_manageVillage_climate::getVillage_climateListByClimateId($ChildClimateId);
     //get child node
     if ($obj_retResult->type == 1) {
         $arr_Village_climateList = $obj_retResult->data;
         $obj_Village_climate = $arr_Village_climateList[0];
         $arrParentIds = explode(",", $obj_Village_climate->Url);
         foreach ($arrParentIds as $Village_climateParentId) {
             if ($Village_climateParentId == $ClimateId) {
                 $ischild = true;
             }
         }
     }
     return $ischild;
 }