<?php
//////Authentication class Start///////////////
include("config.php");
class authentication
{
var $msg;
var $status;
var $obj;

	function login($username,$password,$table)
	{
	$msg="Invalid Username or Password !";
	$link = mysql_connect($dblocation, $dbusername, $dbpass);
	if (!$link) {
	die('Could not connect: ' . mysql_error());
	echo "<script>alert (\"LA CONNEXION ECHOUEE !\")</script>";
	}
	mysql_select_db($dbname, $link);
	
	$password=md5($password);
	
	$sql="SELECT * FROM $table WHERE `username`='".mysql_real_escape_string($username)."' and `password`='".mysql_real_escape_string($password)."' and `status`='1'";
	$result=mysql_query($sql);
	$rs=mysql_fetch_array($result);
	
	mysql_close($link);
	
	$num=mysql_num_rows($result);
	
	   if($rs['password'] == $password)
	   {
			$_SESSION['log']=$rs['username'];
			$_SESSION['name']=$rs['name'];
					
			$code=md5(uniqid(rand(), true));
			$_SESSION['code']=$code;
						
			header("location:dashboard.php");		
		}
		else
		{	
				
		$this->msg=$msg;
		}
	
	}


}
////////////Authontication class end/////////////////

////////////////////Admin Class Start////////////////
class Admin
{
var $msg;
var $status;
var $notice;
var $error;
var $del;
var $act;
var $inact;

   				  
					        function adminaction()
							{
							@extract($_GET);
							$chka=$_POST['chkid'];
							$temp="";
							if(is_array($chka))
							{
							foreach($chka as $val)
							{
							$temp.="'".$val."',";
							}
							$temp=substr($temp,0,strlen($temp)-1);
							}
							
							if($Action=="Delete")
		                    {
							$link = mysql_connect($dblocation, $dbusername, $dbpass);
							if (!$link) {
							die('Could not connect: ' . mysql_error());
							}
							mysql_select_db($dbname, $link);
							$sql="delete from `di_uac_adm_user` where `id` in ($temp)";
							$rs=mysql_query($sql);
							mysql_close($link);
							if($rs)
							{
							$this->del="true";
							$this->msg="Admin deleted successfully";
							}
								
							}
							

										if($Action=="Active")
										{
											$link = mysql_connect($dblocation, $dbusername, $dbpass);
											if (!$link) 
											{
											die('Could not connect: ' . mysql_error());
											}
										mysql_select_db($dbname, $link);
										$rs=mysql_query("UPDATE `di_uac_adm_user` SET `status`='1' WHERE `id` in ($temp)");
										mysql_close($link);
											if($rs)
											{
											$this->act="true";
											$this->msg="Admin Active successfully";
											}
											
                                        } 
							
							
								if($Action=="Inactive")
								{
									$link = mysql_connect($dblocation, $dbusername, $dbpass);
									if (!$link) 
									{
									die('Could not connect: ' . mysql_error());
									}
								mysql_select_db($dbname, $link);
								$rs=mysql_query("UPDATE `di_uac_adm_user` SET `status`='0' WHERE `id` in ($temp)");
								mysql_close($link);
								            if($rs)
											{
											$this->inact="true";
											$this->msg="Admin Inactive successfully";
											}
									
								}

							
							}

				  
					  
					    function addadmin()
						{
						@extract($_POST);
												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
						
$sqlN="SELECT * FROM `di_uac_adm_user` WHERE `mail`='".mysql_real_escape_string($email)."' or `username`='".mysql_real_escape_string($username)."'";
$resultN=mysql_query($sqlN);
$num=mysql_num_rows($resultN);

if($num=='0')
{
						
						$sql="INSERT INTO `di_uac_adm_user` (`id`, `username`, `password`, `mail`,`status`,`name`) VALUES ('', '$username', '".md5($password)."', '$email', '$status','$name')";
						$rs=mysql_query($sql) or die("Error in insering".mysql_error());
}						
						mysql_close($link);
						
						if($num=='0')
                        {
						$this->notice="sus";
						$this->msg="Admin added successfully";
						}
						else
						{
						$this->notice="sus";
						$this->msg="Email ID or Username already used, Please try again...";
						}
						}
						
						
						function editadmin()
						{
						@extract($_POST);
												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
						if($password!='')
						{						
						$sql="UPDATE `di_uac_adm_user` SET  `password` = '".md5($password)."', `status` = '$status',`name`='$name' WHERE `id` ='".mysql_real_escape_string($id)."'";
						$rs=mysql_query($sql) or die("Error in updating".mysql_error());
						}
						mysql_close($link);
						if($password!='')
						{
						$this->notice="sus";
						$this->msg="Admin Update successfully";
						}
						else
						{
						$this->notice="sus";
						$this->msg="Please enter your password.";
						}
						}
						
						
						
						
            function ShowAdmin($id)
			{
				$link = mysql_connect($dblocation, $dbusername, $dbpass);
				if (!$link) {
				die('Could not connect: ' . mysql_error());
				}
				mysql_select_db($dbname, $link);
				$sq="SELECT * FROM `di_uac_adm_user` where `id`='".mysql_real_escape_string($id)."'";
				$rs=mysql_query($sq);
				mysql_close($link);
				
				$Admin=array();
				while($row=mysql_fetch_assoc($rs))
				{
				$Admin[]=$row;
				}
		        return $Admin;
			}						
						
						
			function ShowAllAdmin()
			{
				$link = mysql_connect($dblocation, $dbusername, $dbpass);
				if (!$link) {
				die('Could not connect: ' . mysql_error());
				}
				mysql_select_db($dbname, $link);
				$sq="SELECT * FROM `di_uac_adm_user` order by id DESC";
				$rs=mysql_query($sq);
				mysql_close($link);
				
				$Admin=array();
				while($row=mysql_fetch_assoc($rs))
				{
				$Admin[]=$row;
				}
		        return $Admin;
			}				
						
									
						

}
////////////////////Admin Class End////////////////////////////////

////////////////////Menu Class Start////////////////////////////////
class menu
{
var $msg;
var $status;
var $notice;
var $error;
var $del;
var $act;
var $inact;

      				        function menuaction()
							{
							@extract($_GET);
							$chka=$_POST['chkid'];
							$temp="";
							if(is_array($chka))
							{
							foreach($chka as $val)
							{
							$temp.="'".$val."',";
							}
							$temp=substr($temp,0,strlen($temp)-1);
							}
							
							if($Action=="Delete")
		                    {
							$link = mysql_connect($dblocation, $dbusername, $dbpass);
							if (!$link) {
							die('Could not connect: ' . mysql_error());
							}
							mysql_select_db($dbname, $link);
							$sql="delete from `di_uac_nav` where `cat_id` in ($temp)";
							$rs=mysql_query($sql);
							mysql_close($link);
							if($rs)
							{
							$this->del="true";
							$this->msg="Menu deleted successfully";
							}
								
							}
							

										if($Action=="Active")
										{
											$link = mysql_connect($dblocation, $dbusername, $dbpass);
											if (!$link) 
											{
											die('Could not connect: ' . mysql_error());
											}
										mysql_select_db($dbname, $link);
										$rs=mysql_query("UPDATE `di_uac_nav` SET `cat_status`='yes' WHERE `cat_id` in ($temp)");
										mysql_close($link);
											if($rs)
											{
											$this->act="true";
											$this->msg="Menu Active successfully";
											}
											
                                        } 
							
							
								if($Action=="Inactive")
								{
									$link = mysql_connect($dblocation, $dbusername, $dbpass);
									if (!$link) 
									{
									die('Could not connect: ' . mysql_error());
									}
								mysql_select_db($dbname, $link);
								$rs=mysql_query("UPDATE `di_uac_nav` SET `cat_status`='no' WHERE `cat_id` in ($temp)");
								mysql_close($link);
								            if($rs)
											{
											$this->inact="true";
											$this->msg="Menu Inactive successfully";
											}
									
								}

							
							}

				  
					  
					    function addmenu()
						{
						@extract($_POST);
												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
						$sql="INSERT INTO `di_uac_nav` (`cat_id`, `cat_position`, `cat_name`, `cat_parent`,`cat_description`, `cat_prd_id`,`cat_banner_id`,`position`,`cat_status`,`menu_type`,`menu_page_type`) VALUES ('', '$cat_position', '".addslashes($title)."', '$parent', '".addslashes($cat_description)."'; '$artlink','$bannlink','$position', '$status','$pagetype','')";
						$rs=mysql_query($sql) or die("Error in insering".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Menu added successfully";
						}
						}
						
						
						
						
						function editmenu()
						{
						@extract($_POST);
												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
					    $sql="UPDATE `di_uac_nav` SET `cat_position`='$cat_position',`cat_name`='".addslashes($title)."',`cat_description`='".addslashes($cat_description)."', `cat_prd_id`='$artlink',`cat_banner_id`='$bannlink',`cat_status`='$status',`position`='$position',`menu_type`='$pagetype' WHERE `cat_id`='".mysql_real_escape_string($id)."'";
						$rs=mysql_query($sql) or die("Error in updating".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Menu Update successfully";
						}
						}
						
						
						
						
}
////////////////////Menu Class End////////////////////////////////




////////////////////cms Class Start////////////////////////////////
class cms
{
var $msg;
var $status;
var $notice;
var $error;
var $del;
var $act;
var $inact;
					  
					        function cmsaction()
							{
							@extract($_GET);
							$chka=$_POST['chkid'];
							$temp="";
							if(is_array($chka))
							{
							foreach($chka as $val)
							{
							$temp.="'".$val."',";
							}
							$temp=substr($temp,0,strlen($temp)-1);
							}
							
							if($Action=="Delete")
		                    {
							$link = mysql_connect($dblocation, $dbusername, $dbpass);
							if (!$link) {
							die('Could not connect: ' . mysql_error());
							}
							mysql_select_db($dbname, $link);
							
							
							$sql="delete from `di_uac_cms` where `cms_id` in ($temp)";
							$rs=mysql_query($sql);
							
							
							mysql_query("UPDATE `di_uac_nav` SET `cat_prd_id`='' WHERE `cat_prd_id` in ($temp)");
							
							mysql_close($link);
							if($rs)
							{
							$this->del="true";
							$this->msg="Article deleted successfully";
							}
								
							}
							

										if($Action=="Active")
										{
											$link = mysql_connect($dblocation, $dbusername, $dbpass);
											if (!$link) 
											{
											die('Could not connect: ' . mysql_error());
											}
										mysql_select_db($dbname, $link);
										$rs=mysql_query("UPDATE `di_uac_cms` SET `cms_status`='1' WHERE `cms_id` in ($temp)");
										mysql_close($link);
											if($rs)
											{
											$this->act="true";
											$this->msg="Article Active successfully";
											}
											
                                        } 
							
							
								if($Action=="Inactive")
								{
									$link = mysql_connect($dblocation, $dbusername, $dbpass);
									if (!$link) 
									{
									die('Could not connect: ' . mysql_error());
									}
								mysql_select_db($dbname, $link);
								$rs=mysql_query("UPDATE `di_uac_cms` SET `cms_status`='0' WHERE `cms_id` in ($temp)");
								mysql_close($link);
								            if($rs)
											{
											$this->inact="true";
											$this->msg="Article Inactive successfully";
											}
									
								}

							
							}




					  
					  
					    function addcms()
						{
						@extract($_POST);
						$rid=rand();						
						if($_FILES['image']['name']!='')
						{						
						$dir = "../pic/"; 
						$file = $dir.$rid."_".$_FILES['image']['name']; 
						$imagename=$rid."_".$_FILES['image']['name']; 			
						move_uploaded_file($_FILES['image']['tmp_name'],$file);
						}
						else
						{
						$imagename='';
						}
						
				
												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
						$sql="INSERT INTO `di_uac_cms` (`cms_id`, `cms_pagetitle`, `cms_metakeyword`, `cms_metadescription`, `cms_shortdesc`,`cms_position`, `cms_cdate`, `cms_mdate`, `cms_status`,`cms_browser_title`,`cms_canonical`,`cms_image`,`cms_longdesc`,`cms_type`) VALUES ('', '".addslashes($title)."', '".addslashes($keywords)."', '".addslashes($description)."', '".addslashes($short)."', '', '$date', '$date', '$status','".addslashes($btitle)."','$canonical','$imagename', '".addslashes($long)."','')";
						
						$rs=mysql_query($sql) or die("Error in insering".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Article added successfully";
						}
						}
						
						
						
						
						function editcms()
						{
						@extract($_POST);
						
						
						
						$rid=rand();
						
						if($_FILES['image']['name']!='')
						{	
						unlink("../pic/$imagename");					
						$dir = "../pic/"; 
						$file = $dir.$rid."_".$_FILES['image']['name']; 
						$imagename=$rid."_".$_FILES['image']['name']; 			
						move_uploaded_file($_FILES['image']['tmp_name'],$file);
						}
						else
						{
						$imagename=$imagename;
						}
										
						
						
																		
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
$sql="UPDATE `di_uac_cms` SET `cms_pagetitle`='".addslashes($title)."', `cms_metakeyword`='".addslashes($keywords)."', `cms_metadescription`='".addslashes($description)."', `cms_shortdesc`='".addslashes($short)."',`cms_mdate`='$date',`cms_status`='$status',`cms_browser_title`='".addslashes($btitle)."',`cms_canonical`='$canonical',`cms_image`='$imagename',`cms_longdesc`='".addslashes($long)."' WHERE `cms_id`='".mysql_real_escape_string($id)."'";
$rs=mysql_query($sql) or die("Error in updating".mysql_error());
						
						
												
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Article Update successfully";
						}
						}
						
						
						
						
}
////////////////////cms Class End////////////////////////////////



////////////////////Banner Class Start////////////////
class ArtBnner
{
var $msg;
var $status;
var $notice;
var $error;
var $del;
var $act;
var $inact;

   				  
					        function ArtBnneraction()
							{
							@extract($_GET);
							$chka=$_POST['chkid'];
							$temp="";
							if(is_array($chka))
							{
							foreach($chka as $val)
							{
							$temp.="'".$val."',";
							}
							$temp=substr($temp,0,strlen($temp)-1);
							}
							
							if($Action=="Delete")
		                    {
							$link = mysql_connect($dblocation, $dbusername, $dbpass);
							if (!$link) {
							die('Could not connect: ' . mysql_error());
							}
							mysql_select_db($dbname, $link);
							$sql="delete from `di_uac_banner` where `bann_id` in ($temp)";
							$rs=mysql_query($sql);
							
							mysql_close($link);
							if($rs)
							{
							$this->del="true";
							$this->msg="Article Banner deleted successfully";
							}
								
							}
							

										if($Action=="Active")
										{
											$link = mysql_connect($dblocation, $dbusername, $dbpass);
											if (!$link) 
											{
											die('Could not connect: ' . mysql_error());
											}
										mysql_select_db($dbname, $link);
										$rs=mysql_query("UPDATE `di_uac_banner` SET `bann_status`='1' WHERE `bann_id` in ($temp)");
										mysql_close($link);
											if($rs)
											{
											$this->act="true";
											$this->msg="Article Banner Active successfully";
											}
											
                                        } 
							
							
								if($Action=="Inactive")
								{
									$link = mysql_connect($dblocation, $dbusername, $dbpass);
									if (!$link) 
									{
									die('Could not connect: ' . mysql_error());
									}
								mysql_select_db($dbname, $link);
								$rs=mysql_query("UPDATE `di_uac_banner` SET `bann_status`='0' WHERE `bann_id` in ($temp)");
								mysql_close($link);
								            if($rs)
											{
											$this->inact="true";
											$this->msg="Article Banner Inactive successfully";
											}
									
								}

							
							}

 					  
					  
					    function addArtBnner()
						{
						@extract($_POST);
						
						
						
if(!empty($_FILES['file']['name']))
{
$rid=rand();						
$smalldir = "../images/slider/"; 
$smallfile = $smalldir.$rid."_".$_FILES['file']['name']; 
$file_name=$rid."_".$_FILES['file']['name']; 			
move_uploaded_file($_FILES['file']['tmp_name'],$smallfile);
}

						
												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
				$sql="INSERT INTO `di_uac_banner` (`bann_id`, `bann_name`, `bann_file`, `bann_type`, `bann_status`, `bann_date`) VALUES ('', '$name', '$file_name', '$type','$status', '$date')";
						$rs=mysql_query($sql) or die("Error in insering".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Article Banner added successfully";
						}
						}
						
						
						
						
						function editArtBnner()
						{
						@extract($_POST);
						
if(!empty($_FILES['file']['name']))
{
unlink("../images/slider/$imgname");	

$rid=rand();						
$smalldir = "../images/slider/"; 
$smallfile = $smalldir.$rid."_".$_FILES['file']['name']; 
$file_name=$rid."_".$_FILES['file']['name']; 			
move_uploaded_file($_FILES['file']['tmp_name'],$smallfile);
}
else
{
$file_name=$imgname;
}

												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
						$sql="UPDATE `di_uac_banner` SET `bann_name` = '$name', `bann_file` = '$file_name', `bann_type` = '$type', `bann_status` = '$status' WHERE `bann_id` ='".mysql_real_escape_string($id)."'";
						$rs=mysql_query($sql) or die("Error in updating".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Article Banner Update successfully";
						}
						}
						
						
						
						
}
////////////////////Banner Class End////////////////////////////////



////////////////////Research Class Start////////////////
class Research
{
var $msg;
var $status;
var $notice;
var $error;
var $del;
var $act;
var $inact;

   				  
					        function Researchaction()
							{
							@extract($_GET);
							$chka=$_POST['chkid'];
							$temp="";
							if(is_array($chka))
							{
							foreach($chka as $val)
							{
							$temp.="'".$val."',";
							}
							$temp=substr($temp,0,strlen($temp)-1);
							}
							
							if($Action=="Delete")
		                    {
							$link = mysql_connect($dblocation, $dbusername, $dbpass);
							if (!$link) {
							die('Could not connect: ' . mysql_error());
							}
							mysql_select_db($dbname, $link);
							
							
							$sqf=mysql_query("select * from `di_uac_research` where `res_id` in ($temp)");
							while($rr=mysql_fetch_array($sqf)){
							unlink("../research/".$rr['res_image']);	
	                        unlink("../research/".$rr['res_pdf_file']);
							}
							
							
							$sql="delete from `di_uac_research` where `res_id` in ($temp)";
							$rs=mysql_query($sql);
							mysql_close($link);
							if($rs)
							{
							$this->del="true";
							$this->msg="Research deleted successfully";
							}
								
							}
							

										if($Action=="Active")
										{
											$link = mysql_connect($dblocation, $dbusername, $dbpass);
											if (!$link) 
											{
											die('Could not connect: ' . mysql_error());
											}
										mysql_select_db($dbname, $link);
										$rs=mysql_query("UPDATE `di_uac_research` SET `res_status`='1' WHERE `res_id` in ($temp)");
										mysql_close($link);
											if($rs)
											{
											$this->act="true";
											$this->msg="Research Active successfully";
											}
											
                                        } 
							
							
								if($Action=="Inactive")
								{
									$link = mysql_connect($dblocation, $dbusername, $dbpass);
									if (!$link) 
									{
									die('Could not connect: ' . mysql_error());
									}
								mysql_select_db($dbname, $link);
								$rs=mysql_query("UPDATE `di_uac_research` SET `res_status`='0' WHERE `res_id` in ($temp)");
								mysql_close($link);
								            if($rs)
											{
											$this->inact="true";
											$this->msg="Research Inactive successfully";
											}
									
								}

							
							}




					  
				  
					  
					  
					  
					    function addResearch()
						{
						@extract($_POST);
						
						
						
if(!empty($_FILES['thamb']['name']))
{
$rid=rand();						
$thumbnaildir = "../research/"; 
$thumbnailfile = $thumbnaildir.$rid."_".$_FILES['thamb']['name']; 
$thumbnail_name=$rid."_".$_FILES['thamb']['name']; 			
move_uploaded_file($_FILES['thamb']['tmp_name'],$thumbnailfile);
}
else
{
$thumbnail_name='';
}
						
						
if(!empty($_FILES['file']['name']))
{
$rid=rand();						
$smalldir = "../research/"; 
$smallfile = $smalldir.$rid."_".$_FILES['file']['name']; 
$imagename=$rid."_".$_FILES['file']['name']; 			
move_uploaded_file($_FILES['file']['tmp_name'],$smallfile);
}
else
{
$imagename='';
}
	
										
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
				        $sql="INSERT INTO `di_uac_research` (`res_id`, `res_title`, `res_pdf_file`, `res_image`, `res_short_desc`, `res_status`,`res_order`, `res_date`) VALUES ('', '".addslashes($name)."', '$imagename', '$thumbnail_name', '".addslashes($short)."', '$status','$order', Now())";
						$rs=mysql_query($sql) or die("Error in insering".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Research added successfully";
						}
						}
						
						
						
						
						function editResearch()
						{
						@extract($_POST);
						
							
if(!empty($_FILES['thamb']['name']))
{
unlink("../research/$thumbnailname");	
$rid=rand();						
$thumbnaildir = "../research/"; 

$thumbnailfile = $thumbnaildir.$rid."_".$_FILES['thamb']['name']; 
$thumbnail_name=$rid."_".$_FILES['thamb']['name']; 			
move_uploaded_file($_FILES['thamb']['tmp_name'],$thumbnailfile);
}
else
{
$thumbnail_name=$thumbnailname;
}
						
if(!empty($_FILES['file']['name']))
{
unlink("../research/$fimg");	

$rid=rand();						
$smalldir = "../research/"; 
$smallfile = $smalldir.$rid."_".$_FILES['file']['name']; 
$imagename=$rid."_".$_FILES['file']['name']; 			
move_uploaded_file($_FILES['file']['tmp_name'],$smallfile);
}
else
{
$imagename=$fimg;
}

		
		
						
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
$sql="UPDATE `di_uac_research` SET `res_title` = '".addslashes($name)."', `res_pdf_file` = '$imagename', `res_image` = '$thumbnail_name', `res_short_desc` = '".addslashes($short)."', `res_status` = '$status',`res_order`='$order' WHERE `res_id` = '$id'";
						
					
						
						
						$rs=mysql_query($sql) or die("Error in updating".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Research Update successfully";
						}
						}
						
						
						
						
}
////////////////////Research Class End////////////////////////////////

////////////////////Client Logo Class Start////////////////
class Client
{
var $msg;
var $status;
var $notice;
var $error;
var $del;
var $act;
var $inact;

   				  
					        function Clientaction()
							{
							@extract($_GET);
							$chka=$_POST['chkid'];
							$temp="";
							if(is_array($chka))
							{
							foreach($chka as $val)
							{
							$temp.="'".$val."',";
							}
							$temp=substr($temp,0,strlen($temp)-1);
							}
							
							if($Action=="Delete")
		                    {
							$link = mysql_connect($dblocation, $dbusername, $dbpass);
							if (!$link) {
							die('Could not connect: ' . mysql_error());
							}
							mysql_select_db($dbname, $link);
							$sql="delete from `di_uac_clientele` where `client_id` in ($temp)";
							$rs=mysql_query($sql);
							
							mysql_close($link);
							if($rs)
							{
							$this->del="true";
							$this->msg="Client deleted successfully";
							}
								
							}
							

										if($Action=="Active")
										{
											$link = mysql_connect($dblocation, $dbusername, $dbpass);
											if (!$link) 
											{
											die('Could not connect: ' . mysql_error());
											}
										mysql_select_db($dbname, $link);
										$rs=mysql_query("UPDATE `di_uac_clientele` SET `client_status`='1' WHERE `client_id` in ($temp)");
										mysql_close($link);
											if($rs)
											{
											$this->act="true";
											$this->msg="Client Active successfully";
											}
											
                                        } 
							
							
								if($Action=="Inactive")
								{
									$link = mysql_connect($dblocation, $dbusername, $dbpass);
									if (!$link) 
									{
									die('Could not connect: ' . mysql_error());
									}
								mysql_select_db($dbname, $link);
								$rs=mysql_query("UPDATE `di_uac_clientele` SET `client_status`='0' WHERE `client_id` in ($temp)");
								mysql_close($link);
								            if($rs)
											{
											$this->inact="true";
											$this->msg="Client Inactive successfully";
											}
									
								}

							
							}

 					  
					  
					    function addClient()
						{
						@extract($_POST);
						
						
						
if(!empty($_FILES['file']['name']))
{
$rid=rand();						
$smalldir = "../images/clientele/"; 
$smallfile = $smalldir.$rid."_".$_FILES['file']['name']; 
$file_name=$rid."_".$_FILES['file']['name']; 			
move_uploaded_file($_FILES['file']['tmp_name'],$smallfile);
}

						
												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
				$sql="INSERT INTO `di_uac_clientele` (`client_id`, `client_name`, `client_file`, `client_status`, `client_date`) VALUES ('', '$name', '$file_name', '$status', '$date')";
						$rs=mysql_query($sql) or die("Error in insering".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Client added successfully";
						}
						}
						
						
						
						
						function editClient()
						{
						@extract($_POST);
						
if(!empty($_FILES['file']['name']))
{
unlink("../images/clientele/$imgname");	

$rid=rand();						
$smalldir = "../images/clientele/"; 
$smallfile = $smalldir.$rid."_".$_FILES['file']['name']; 
$file_name=$rid."_".$_FILES['file']['name']; 			
move_uploaded_file($_FILES['file']['tmp_name'],$smallfile);
}
else
{
$file_name=$imgname;
}

												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
						$sql="UPDATE `di_uac_clientele` SET `client_name` = '$name', `client_file` = '$file_name', `client_status` = '$status' WHERE `client_id` ='".mysql_real_escape_string($id)."'";
						$rs=mysql_query($sql) or die("Error in updating".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Client Update successfully";
						}
						}
						
						
						
						
}
////////////////////Client Logo Class End////////////////////////////////


////////////////////Testimonial Class Start////////////////
class Testimonial
{
var $msg;
var $status;
var $notice;
var $error;
var $del;
var $act;
var $inact;

   				  
					        function Testimonialaction()
							{
							@extract($_GET);
							$chka=$_POST['chkid'];
							$temp="";
							if(is_array($chka))
							{
							foreach($chka as $val)
							{
							$temp.="'".$val."',";
							}
							$temp=substr($temp,0,strlen($temp)-1);
							}
							
							if($Action=="Delete")
		                    {
							$link = mysql_connect($dblocation, $dbusername, $dbpass);
							if (!$link) {
							die('Could not connect: ' . mysql_error());
							}
							mysql_select_db($dbname, $link);
							$sql="delete from `di_uac_testimonial` where `testimonial_id` in ($temp)";
							$rs=mysql_query($sql);
							
							mysql_close($link);
							if($rs)
							{
							$this->del="true";
							$this->msg="Testimonial deleted successfully";
							}
								
							}
							

										if($Action=="Active")
										{
											$link = mysql_connect($dblocation, $dbusername, $dbpass);
											if (!$link) 
											{
											die('Could not connect: ' . mysql_error());
											}
										mysql_select_db($dbname, $link);
										$rs=mysql_query("UPDATE `di_uac_testimonial` SET `testimonial_status`='1' WHERE `testimonial_id` in ($temp)");
										mysql_close($link);
											if($rs)
											{
											$this->act="true";
											$this->msg="Testimonial Active successfully";
											}
											
                                        } 
							
							
								if($Action=="Inactive")
								{
									$link = mysql_connect($dblocation, $dbusername, $dbpass);
									if (!$link) 
									{
									die('Could not connect: ' . mysql_error());
									}
								mysql_select_db($dbname, $link);
								$rs=mysql_query("UPDATE `di_uac_testimonial` SET `testimonial_status`='0' WHERE `testimonial_id` in ($temp)");
								mysql_close($link);
								            if($rs)
											{
											$this->inact="true";
											$this->msg="Testimonial Inactive successfully";
											}
									
								}

							
							}

 					  
					  
					    function addTestimonial()
						{
						@extract($_POST);
						
						
						
if(!empty($_FILES['file']['name']))
{
$rid=rand();						
$smalldir = "../testimonial/"; 
$smallfile = $smalldir.$rid."_".$_FILES['file']['name']; 
$file_name=$rid."_".$_FILES['file']['name']; 			
move_uploaded_file($_FILES['file']['tmp_name'],$smallfile);
}

						
												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
				$sql="INSERT INTO `di_uac_testimonial` (`testimonial_id`, `testimonial_name`,`testimonial_company`, `testimonial_dis`,`testimonial_rating`,`testimonial_file`, `testimonial_status`, `testimonial_date`) VALUES ('', '$name','$company','".addslashes($description)."', '$rating', '$file_name', '$status', '$date')";
						$rs=mysql_query($sql) or die("Error in insering".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Testimonial added successfully";
						}
						}
						
						
						
						
						function editTestimonial()
						{
						@extract($_POST);
						
if(!empty($_FILES['file']['name']))
{
unlink("../testimonial/$imgname");	

$rid=rand();						
$smalldir = "../testimonial/"; 
$smallfile = $smalldir.$rid."_".$_FILES['file']['name']; 
$file_name=$rid."_".$_FILES['file']['name']; 			
move_uploaded_file($_FILES['file']['tmp_name'],$smallfile);
}
else
{
$file_name=$imgname;
}

												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
						$sql="UPDATE `di_uac_testimonial` SET `testimonial_name` = '$name', `testimonial_company` = '$company', `testimonial_dis` = '".addslashes($description)."', `testimonial_rating` = '$rating', `testimonial_file` = '$file_name', `testimonial_status` = '$status' WHERE `testimonial_id` ='".mysql_real_escape_string($id)."'";
						$rs=mysql_query($sql) or die("Error in updating".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Testimonial Update successfully";
						}
						}
						
						
						
						
}
////////////////////Testimonial Class End////////////////////////////////


////////////////////General Settings Class Start////////////////
class Settings
{
var $msg;
var $status;
var $notice;
var $error;
var $del;
var $act;
var $inact;

   				  
					        function Settingsaction()
							{
							@extract($_GET);
							$chka=$_POST['chkid'];
							$temp="";
							if(is_array($chka))
							{
							foreach($chka as $val)
							{
							$temp.="'".$val."',";
							}
							$temp=substr($temp,0,strlen($temp)-1);
							}
							
							if($Action=="Delete")
		                    {}
							

										if($Action=="Active")
										{} 
							
							
								if($Action=="Inactive")
								{}

							
							}

 					  
					  
					    function addSettings()
						{}
						
						
						
						
						function editSettings()
						{
						@extract($_POST);
						
if(!empty($_FILES['file']['name']))
{
unlink("../images/logo/$imgname");	

$rid=rand();						
$smalldir = "../images/logo/"; 
$smallfile = $smalldir.$rid."_".$_FILES['file']['name']; 
$file_name=$rid."_".$_FILES['file']['name']; 			
move_uploaded_file($_FILES['file']['tmp_name'],$smallfile);
}
else
{
$file_name=$imgname;
}

												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
						$sql="UPDATE `di_uac_settings` SET `site_title` = '$site_title', `logo` = '$file_name', `contact` = '$contact',`facebook` = '$facebook',`twitter` = '$twitter',`google` = '$google',`youtube` = '$youtube',`linkedin` = '$linkedin',`pinterest` = '$pinterest',`instagram` = '$instagram', `skype` = '$skype', `copyright` = '".addslashes($copyright)."', `analytics_code` = '".addslashes($analytics_code)."' WHERE `id` ='".mysql_real_escape_string($id)."'";
						$rs=mysql_query($sql) or die("Error in updating".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Settings Saved successfully";
						}
						}
						
						
						
						
}
////////////////////General Settings Class End////////////////////////////////

////////////////////Division Class Start////////////////
class ArtDiv
{
var $msg;
var $status;
var $notice;
var $error;
var $del;
var $act;
var $inact;

   				  
					        function ArtDivaction()
							{
							@extract($_GET);
							$chka=$_POST['chkid'];
							$temp="";
							if(is_array($chka))
							{
							foreach($chka as $val)
							{
							$temp.="'".$val."',";
							}
							$temp=substr($temp,0,strlen($temp)-1);
							}
							
							if($Action=="Delete")
		                    {
							$link = mysql_connect($dblocation, $dbusername, $dbpass);
							if (!$link) {
							die('Could not connect: ' . mysql_error());
							}
							mysql_select_db($dbname, $link);
							$sql="delete from `di_uac_division` where `div_id` in ($temp)";
							$rs=mysql_query($sql);
							
							mysql_close($link);
							if($rs)
							{
							$this->del="true";
							$this->msg="Division deleted successfully";
							}
								
							}
							

										if($Action=="Active")
										{
											$link = mysql_connect($dblocation, $dbusername, $dbpass);
											if (!$link) 
											{
											die('Could not connect: ' . mysql_error());
											}
										mysql_select_db($dbname, $link);
										$rs=mysql_query("UPDATE `di_uac_division` SET `div_status`='1' WHERE `div_id` in ($temp)");
										mysql_close($link);
											if($rs)
											{
											$this->act="true";
											$this->msg="Division Active successfully";
											}
											
                                        } 
							
							
								if($Action=="Inactive")
								{
									$link = mysql_connect($dblocation, $dbusername, $dbpass);
									if (!$link) 
									{
									die('Could not connect: ' . mysql_error());
									}
								mysql_select_db($dbname, $link);
								$rs=mysql_query("UPDATE `di_uac_division` SET `div_status`='0' WHERE `div_id` in ($temp)");
								mysql_close($link);
								            if($rs)
											{
											$this->inact="true";
											$this->msg="Division Inactive successfully";
											}
									
								}

							
							}

 					  
					  
					    function addArtDiv()
						{
						@extract($_POST);
						
						
						
if(!empty($_FILES['file']['name']))
{
$rid=rand();						
$smalldir = "../images/div/"; 
$smallfile = $smalldir.$rid."_".$_FILES['file']['name']; 
$file_name=$rid."_".$_FILES['file']['name']; 			
move_uploaded_file($_FILES['file']['tmp_name'],$smallfile);
}

						
												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
				$sql="INSERT INTO `di_uac_division` (`div_id`, `div_title`, `div_img`, `div_desc`, `div_status`) VALUES ('', '$div_title', '$file_name', '".addslashes($div_desc)."','$status')";
						$rs=mysql_query($sql) or die("Error in insering".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Division added successfully";
						}
						}
						
						
						
						
						function editArtDiv()
						{
						@extract($_POST);
						
if(!empty($_FILES['file']['name']))
{
unlink("../images/div/$imgname");	

$rid=rand();						
$smalldir = "../images/div/"; 
$smallfile = $smalldir.$rid."_".$_FILES['file']['name']; 
$file_name=$rid."_".$_FILES['file']['name']; 			
move_uploaded_file($_FILES['file']['tmp_name'],$smallfile);
}
else
{
$file_name=$imgname;
}

												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
						$sql="UPDATE `di_uac_division` SET `div_title` = '$div_title', `div_img` = '$file_name', `div_desc` = '$div_desc', `div_status` = '$status' WHERE `div_id` ='".mysql_real_escape_string($id)."'";
						$rs=mysql_query($sql) or die("Error in updating".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Division Update successfully";
						}
						}
						
						
						
						
}
////////////////////Division Class End////////////////////////////////

////////////////////Milestone Class Start////////////////
class ArtMilestone
{
var $msg;
var $status;
var $notice;
var $error;
var $del;
var $act;
var $inact;

   				  
					        function ArtMilestoneaction()
							{
							@extract($_GET);
							$chka=$_POST['chkid'];
							$temp="";
							if(is_array($chka))
							{
							foreach($chka as $val)
							{
							$temp.="'".$val."',";
							}
							$temp=substr($temp,0,strlen($temp)-1);
							}
							
							if($Action=="Delete")
		                    {
							$link = mysql_connect($dblocation, $dbusername, $dbpass);
							if (!$link) {
							die('Could not connect: ' . mysql_error());
							}
							mysql_select_db($dbname, $link);
							$sql="delete from `di_tbl_milestone` where `milstn_id` in ($temp)";
							$rs=mysql_query($sql);
							
							mysql_close($link);
							if($rs)
							{
							$this->del="true";
							$this->msg="Milestone deleted successfully";
							}
								
							}
							

										if($Action=="Active")
										{
											$link = mysql_connect($dblocation, $dbusername, $dbpass);
											if (!$link) 
											{
											die('Could not connect: ' . mysql_error());
											}
										mysql_select_db($dbname, $link);
										$rs=mysql_query("UPDATE `di_tbl_milestone` SET `milstn_status`='1' WHERE `milstn_id` in ($temp)");
										mysql_close($link);
											if($rs)
											{
											$this->act="true";
											$this->msg="Milestone Active successfully";
											}
											
                                        } 
							
							
								if($Action=="Inactive")
								{
									$link = mysql_connect($dblocation, $dbusername, $dbpass);
									if (!$link) 
									{
									die('Could not connect: ' . mysql_error());
									}

								mysql_select_db($dbname, $link);
								$rs=mysql_query("UPDATE `di_tbl_milestone` SET `milstn_status`='0' WHERE `milstn_id` in ($temp)");
								mysql_close($link);
								            if($rs)
											{
											$this->inact="true";
											$this->msg="Milestone Inactive successfully";
											}
									
								}

							
							}

 					  
					  
					    function addArtMilestone()
						{
						@extract($_POST);
						
						
						
if(!empty($_FILES['file']['name']))
{
$rid=rand();						
$smalldir = "../images/milestone/"; 
$smallfile = $smalldir.$rid."_".$_FILES['file']['name']; 
$file_name=$rid."_".$_FILES['file']['name']; 			
move_uploaded_file($_FILES['file']['tmp_name'],$smallfile);
}

						
												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
				$sql="INSERT INTO `di_tbl_milestone` (`milstn_id`, `milstn_year`, `milstn_img`, `milstn_shortdesc`, `milstn_longdesc`, `milstn_status`) VALUES ('', '$milstn_year', '$file_name', '".addslashes($milstn_shortdesc)."', '".addslashes($milstn_longdesc)."','$status')";
						$rs=mysql_query($sql) or die("Error in insering".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Milestone added successfully";
						}
						}
						
						
						
						
						function editArtMilestone()
						{
						@extract($_POST);
						
if(!empty($_FILES['file']['name']))
{
unlink("../images/milestone/$imgname");	

$rid=rand();						
$smalldir = "../images/milestone/"; 
$smallfile = $smalldir.$rid."_".$_FILES['file']['name']; 
$file_name=$rid."_".$_FILES['file']['name']; 			
move_uploaded_file($_FILES['file']['tmp_name'],$smallfile);
}
else
{
$file_name=$imgname;
}

												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
						$sql="UPDATE `di_tbl_milestone` SET `milstn_year` = '$milstn_year', `milstn_img` = '$file_name', `milstn_shortdesc` = '".addslashes($milstn_shortdesc)."', `milstn_longdesc` = '".addslashes($milstn_longdesc)."', `milstn_status` = '$status' WHERE `milstn_id` ='".mysql_real_escape_string($id)."'";
						$rs=mysql_query($sql) or die("Error in updating".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Milestone Update successfully";
						}
						}
						
						
						
						
}
////////////////////Milestone Class End////////////////////////////////


////////////////////Footer Widget Class Start////////////////
class FooterWidget
{
var $msg;
var $status;
var $notice;
var $error;
var $del;
var $act;
var $inact;

   				  
					        function FooterWidgetaction()
							{
							@extract($_GET);
							$chka=$_POST['chkid'];
							$temp="";
							if(is_array($chka))
							{
							foreach($chka as $val)
							{
							$temp.="'".$val."',";
							}
							$temp=substr($temp,0,strlen($temp)-1);
							}
							
							if($Action=="Delete")
		                    {
							$link = mysql_connect($dblocation, $dbusername, $dbpass);
							if (!$link) {
							die('Could not connect: ' . mysql_error());
							}
							mysql_select_db($dbname, $link);
							$sql="delete from `di_uac_footer_widget` where `widget_id` in ($temp)";
							$rs=mysql_query($sql);
							
							mysql_close($link);
							if($rs)
							{
							$this->del="true";
							$this->msg="Footer Widget deleted successfully";
							}
								
							}
							

										if($Action=="Active")
										{
											$link = mysql_connect($dblocation, $dbusername, $dbpass);
											if (!$link) 
											{
											die('Could not connect: ' . mysql_error());
											}
										mysql_select_db($dbname, $link);
										$rs=mysql_query("UPDATE `di_uac_footer_widget` SET `widget_status`='1' WHERE `widget_id` in ($temp)");
										mysql_close($link);
											if($rs)
											{
											$this->act="true";
											$this->msg="Footer Widget Active successfully";
											}
											
                                        } 
							
							
								if($Action=="Inactive")
								{
									$link = mysql_connect($dblocation, $dbusername, $dbpass);
									if (!$link) 
									{
									die('Could not connect: ' . mysql_error());
									}
								mysql_select_db($dbname, $link);
								$rs=mysql_query("UPDATE `di_uac_footer_widget` SET `widget_status`='0' WHERE `widget_id` in ($temp)");
								mysql_close($link);
								            if($rs)
											{
											$this->inact="true";
											$this->msg="Footer Widget Inactive successfully";
											}
									
								}

							
							}

 					  
					  
					    function addFooterWidget()
						{
						@extract($_POST);
						
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
				$sql="INSERT INTO `di_uac_footer_widget` (`widget_id`, `widget_title`,`widget_content`, `widget_position`,`widget_status`) VALUES ('', '$widget_title','".addslashes($widget_content)."', '$widget_position', '$status')";
						$rs=mysql_query($sql) or die("Error in insering".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Footer Widget added successfully";
						}
						}
						
						
						
						
						function editFooterWidget()
						{
						@extract($_POST);
						
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
						$sql="UPDATE `di_uac_footer_widget` SET `widget_title` = '$widget_title', `widget_content` = '".addslashes($widget_content)."', `widget_position` = '$widget_position', `widget_status` = '$status' WHERE `widget_id` ='".mysql_real_escape_string($id)."'";
						$rs=mysql_query($sql) or die("Error in updating".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Footer Widget Update successfully";
						}
						}
						
						
						
						
}
////////////////////Footer Widget Class End////////////////////////////////

////////////////////Category Class Start////////////////////////////////
class Category
{
var $msg;
var $status;
var $notice;
var $error;
var $del;
var $act;
var $inact;

      				        function Categoryaction()
							{
							@extract($_GET);
							$chka=$_POST['chkid'];
							$temp="";
							if(is_array($chka))
							{
							foreach($chka as $val)
							{
							$temp.="'".$val."',";
							}
							$temp=substr($temp,0,strlen($temp)-1);
							}
							
							if($Action=="Delete")
		                    {
							$link = mysql_connect($dblocation, $dbusername, $dbpass);
							if (!$link) {
							die('Could not connect: ' . mysql_error());
							}
							mysql_select_db($dbname, $link);
							
							$ch_que = "select * from di_uac_cat where cat_parent in ($temp)";
							$ch_res = mysql_query($ch_que);
							$ch_num = mysql_num_rows($ch_res);
							if($ch_num > 0){
								while($ch_row = mysql_fetch_array($ch_res)){
									$ch_que_sub = "select * from di_uac_cat where cat_parent ='".$ch_row['cat_id']."'";
									$ch_res_sub = mysql_query($ch_que_sub);
									$ch_num_sub = mysql_num_rows($ch_res_sub);
									if($ch_num_sub > 0){
										while($ch_row_sub = mysql_fetch_array($ch_res_sub)){
											$ch_que_sub_sub = "select * from di_uac_cat where cat_parent ='".$ch_row_sub['cat_id']."'";
											$ch_res_sub_sub = mysql_query($ch_que_sub_sub);
											$ch_num_sub_sub = mysql_num_rows($ch_res_sub_sub);
											if($ch_num_sub_sub > 0){
												while($ch_row_sub_sub = mysql_fetch_array($ch_res_sub_sub)){
													$ch_que_sub_sub_sub = "select * from di_uac_cat where cat_parent ='".$ch_row_sub_sub['cat_id']."'";
													$ch_res_sub_sub_sub = mysql_query($ch_que_sub_sub_sub);
													$ch_num_sub_sub_sub = mysql_num_rows($ch_res_sub_sub_sub);
													if($ch_num_sub_sub_sub > 0){
														
														while($ch_row_sub_sub_sub = mysql_fetch_array($ch_res_sub_sub_sub)){
																
													
															$sql_sub_sub_sub_sub="delete from `di_uac_cat` where `cat_id` ='".$ch_row_sub_sub_sub['cat_id']."'";
															$rs_sub_sub_sub_sub=mysql_query($sql_sub_sub_sub_sub);
															
														}
												
											
														
													}
											
													$sql_sub_sub_sub="delete from `di_uac_cat` where `cat_id` ='".$ch_row_sub_sub['cat_id']."'";
													$rs_sub_sub_sub=mysql_query($sql_sub_sub_sub);
													
												}
												
											}
									
											$sql_sub_sub="delete from `di_uac_cat` where `cat_id` ='".$ch_row_sub['cat_id']."'";
											$rs_sub_sub=mysql_query($sql_sub_sub);
											
										}
									}	
							
									$sql_sub="delete from `di_uac_cat` where `cat_id` ='".$ch_row['cat_id']."'";
									$rs_sub=mysql_query($sql_sub);
									
								}
							}	
							
							$sql="delete from `di_uac_cat` where `cat_id` in ($temp)";
							$rs=mysql_query($sql);
							
							mysql_close($link);
							if($rs)
							{
							$this->del="true";
							$this->msg="Category deleted successfully";
							}
								
							}
							

										if($Action=="Active")
										{
											$link = mysql_connect($dblocation, $dbusername, $dbpass);
											if (!$link) 
											{
											die('Could not connect: ' . mysql_error());
											}
										mysql_select_db($dbname, $link);
							$ch_que = "select * from di_uac_cat where cat_parent in ($temp)";
							$ch_res = mysql_query($ch_que);
							$ch_num = mysql_num_rows($ch_res);
							if($ch_num > 0){
								while($ch_row = mysql_fetch_array($ch_res)){
									$ch_que_sub = "select * from di_uac_cat where cat_parent ='".$ch_row['cat_id']."'";
									$ch_res_sub = mysql_query($ch_que_sub);
									$ch_num_sub = mysql_num_rows($ch_res_sub);
									if($ch_num_sub > 0){
										while($ch_row_sub = mysql_fetch_array($ch_res_sub)){
											$ch_que_sub_sub = "select * from di_uac_cat where cat_parent ='".$ch_row_sub['cat_id']."'";
											$ch_res_sub_sub = mysql_query($ch_que_sub_sub);
											$ch_num_sub_sub = mysql_num_rows($ch_res_sub_sub);
											if($ch_num_sub_sub > 0){
												while($ch_row_sub_sub = mysql_fetch_array($ch_res_sub_sub)){
													$ch_que_sub_sub_sub = "select * from di_uac_cat where cat_parent ='".$ch_row_sub_sub['cat_id']."'";
													$ch_res_sub_sub_sub = mysql_query($ch_que_sub_sub_sub);
													$ch_num_sub_sub_sub = mysql_num_rows($ch_res_sub_sub_sub);
													if($ch_num_sub_sub_sub > 0){
														
														while($ch_row_sub_sub_sub = mysql_fetch_array($ch_res_sub_sub_sub)){
																
													
															$sql_sub_sub_sub_sub="UPDATE `di_uac_cat` SET `cat_status`='yes' WHERE `cat_id` ='".$ch_row_sub_sub_sub['cat_id']."'";
															$rs_sub_sub_sub_sub=mysql_query($sql_sub_sub_sub_sub);
															
														}
												
											
														
													}
											
													$sql_sub_sub_sub="UPDATE `di_uac_cat` SET `cat_status`='yes' WHERE `cat_id` ='".$ch_row_sub_sub['cat_id']."'";
													$rs_sub_sub_sub=mysql_query($sql_sub_sub_sub);
													
												}
												
											}
									
											$sql_sub_sub="UPDATE `di_uac_cat` SET `cat_status`='yes' WHERE `cat_id` ='".$ch_row_sub['cat_id']."'";
											$rs_sub_sub=mysql_query($sql_sub_sub);
											
										}
									}	
							
									$sql_sub="UPDATE `di_uac_cat` SET `cat_status`='yes' WHERE `cat_id` ='".$ch_row['cat_id']."'";
									$rs_sub=mysql_query($sql_sub);
									
								}
							}	
							
							$sql="UPDATE `di_uac_cat` SET `cat_status`='yes' WHERE `cat_id` in ($temp)";
							$rs=mysql_query($sql);
										
										
										//$rs=mysql_query("UPDATE `di_uac_cat` SET `cat_status`='yes' WHERE `cat_id` in ($temp)");
										mysql_close($link);
											if($rs)
											{
											$this->act="true";
											$this->msg="Category Active successfully";
											}
											
                                        } 
							
							
								if($Action=="Inactive")
								{
									$link = mysql_connect($dblocation, $dbusername, $dbpass);
									if (!$link) 
									{
									die('Could not connect: ' . mysql_error());
									}
								mysql_select_db($dbname, $link);
								$ch_que = "select * from di_uac_cat where cat_parent in ($temp)";
							$ch_res = mysql_query($ch_que);
							$ch_num = mysql_num_rows($ch_res);
							if($ch_num > 0){
								while($ch_row = mysql_fetch_array($ch_res)){
									$ch_que_sub = "select * from di_uac_cat where cat_parent ='".$ch_row['cat_id']."'";
									$ch_res_sub = mysql_query($ch_que_sub);
									$ch_num_sub = mysql_num_rows($ch_res_sub);
									if($ch_num_sub > 0){
										while($ch_row_sub = mysql_fetch_array($ch_res_sub)){
											$ch_que_sub_sub = "select * from di_uac_cat where cat_parent ='".$ch_row_sub['cat_id']."'";
											$ch_res_sub_sub = mysql_query($ch_que_sub_sub);
											$ch_num_sub_sub = mysql_num_rows($ch_res_sub_sub);
											if($ch_num_sub_sub > 0){
												while($ch_row_sub_sub = mysql_fetch_array($ch_res_sub_sub)){
													$ch_que_sub_sub_sub = "select * from di_uac_cat where cat_parent ='".$ch_row_sub_sub['cat_id']."'";
													$ch_res_sub_sub_sub = mysql_query($ch_que_sub_sub_sub);
													$ch_num_sub_sub_sub = mysql_num_rows($ch_res_sub_sub_sub);
													if($ch_num_sub_sub_sub > 0){
														
														while($ch_row_sub_sub_sub = mysql_fetch_array($ch_res_sub_sub_sub)){
																
													
															$sql_sub_sub_sub_sub="UPDATE `di_uac_cat` SET `cat_status`='no' WHERE `cat_id` ='".$ch_row_sub_sub_sub['cat_id']."'";
															$rs_sub_sub_sub_sub=mysql_query($sql_sub_sub_sub_sub);
															
														}
												
											
														
													}
											
													$sql_sub_sub_sub="UPDATE `di_uac_cat` SET `cat_status`='no' WHERE `cat_id` ='".$ch_row_sub_sub['cat_id']."'";
													$rs_sub_sub_sub=mysql_query($sql_sub_sub_sub);
													
												}
												
											}
									
											$sql_sub_sub="UPDATE `di_uac_cat` SET `cat_status`='no' WHERE `cat_id` ='".$ch_row_sub['cat_id']."'";
											$rs_sub_sub=mysql_query($sql_sub_sub);
											
										}
									}	
							
									$sql_sub="UPDATE `di_uac_cat` SET `cat_status`='no' WHERE `cat_id` ='".$ch_row['cat_id']."'";
									$rs_sub=mysql_query($sql_sub);
									
								}
							}	
							
							$sql="UPDATE `di_uac_cat` SET `cat_status`='no' WHERE `cat_id` in ($temp)";
							$rs=mysql_query($sql);
								//$rs=mysql_query("UPDATE `di_uac_cat` SET `cat_status`='no' WHERE `cat_id` in ($temp)");
								mysql_close($link);
								            if($rs)
											{
											$this->inact="true";
											$this->msg="Category Inactive successfully";
											}
									
								}

							
							}

				  
					  
					    function addCategory()
						{
						@extract($_POST);
						
						$rid=rand();						
						if($_FILES['image']['name']!='')
						{						
						$dir = "../images/product-category/"; 
						$file = $dir.$rid."_".$_FILES['image']['name']; 
						$imagename=$rid."_".$_FILES['image']['name']; 			
						move_uploaded_file($_FILES['image']['tmp_name'],$file);
						}
						else
						{
						$imagename='';
						}
												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
						$sql="INSERT INTO `di_uac_cat` (`cat_id`, `cat_name`, `cat_parent`,`cat_description`, `cat_position`,  `cat_prd_id`,`cat_banner_id`,`position`,`cat_status`,`cat_img`) VALUES ('','".addslashes($title)."', '$parent','".addslashes($cat_description)."', 'header', '$prdlink','$bannlink','$position', '$status','$imagename')";
						$rs=mysql_query($sql) or die("Error in insering".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Category added successfully";
						}
						}
						
						
						
						
						function editCategory()
						{
						@extract($_POST);
						
						$rid=rand();
						
						if(!empty($_FILES['image']['name']))
						{	
						unlink("../images/product-category/$imagename");					
						$dir = "../images/product-category/"; 
						$file = $dir.$rid."_".$_FILES['image']['name']; 
						$imagename=$rid."_".$_FILES['image']['name']; 			
						move_uploaded_file($_FILES['image']['tmp_name'],$file);
						}
						else
						{
						$imagename=$imagename;
						}
												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
					    $sql="UPDATE `di_uac_cat` SET `cat_name`='".addslashes($title)."', `cat_description`='".addslashes($cat_description)."',`cat_prd_id`='$prdlink',`cat_banner_id`='$bannlink',`cat_status`='$status',`position`='$position',`cat_img`='$imagename' WHERE `cat_id`='".mysql_real_escape_string($id)."'";
						$rs=mysql_query($sql) or die("Error in updating".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Category Update successfully";
						}
						}
						
						
						
						
}
////////////////////Category Class End////////////////////////////////

////////////////////Brand Class Start////////////////
class Brand
{
var $msg;
var $status;
var $notice;
var $error;
var $del;
var $act;
var $inact;

   				  
					        function Brandaction()
							{
							@extract($_GET);
							$chka=$_POST['chkid'];
							$temp="";
							if(is_array($chka))
							{
							foreach($chka as $val)
							{
							$temp.="'".$val."',";
							}
							$temp=substr($temp,0,strlen($temp)-1);
							}
							
							if($Action=="Delete")
		                    {
							$link = mysql_connect($dblocation, $dbusername, $dbpass);
							if (!$link) {
							die('Could not connect: ' . mysql_error());
							}
							mysql_select_db($dbname, $link);
							$sql="delete from `di_uac_brands` where `brnd_id` in ($temp)";
							$rs=mysql_query($sql);
							
							mysql_close($link);
							if($rs)
							{
							$this->del="true";
							$this->msg="Brand deleted successfully";
							}
								
							}
							

										if($Action=="Active")
										{
											$link = mysql_connect($dblocation, $dbusername, $dbpass);
											if (!$link) 
											{
											die('Could not connect: ' . mysql_error());
											}
										mysql_select_db($dbname, $link);
										$rs=mysql_query("UPDATE `di_uac_brands` SET `brnd_status`='1' WHERE `brnd_id` in ($temp)");
										mysql_close($link);
											if($rs)
											{
											$this->act="true";
											$this->msg="Brand Active successfully";
											}
											
                                        } 
							
							
								if($Action=="Inactive")
								{
									$link = mysql_connect($dblocation, $dbusername, $dbpass);
									if (!$link) 
									{
									die('Could not connect: ' . mysql_error());
									}
								mysql_select_db($dbname, $link);
								$rs=mysql_query("UPDATE `di_uac_brands` SET `brnd_status`='0' WHERE `brnd_id` in ($temp)");
								mysql_close($link);
								            if($rs)
											{
											$this->inact="true";
											$this->msg="Brand Inactive successfully";
											}
									
								}

							
							}

 					  
					  
					    function addBrand()
						{
						@extract($_POST);
						
						
						
if(!empty($_FILES['file']['name']))
{
$rid=rand();						
$smalldir = "../images/brand/"; 
$smallfile = $smalldir.$rid."_".$_FILES['file']['name']; 
$file_name=$rid."_".$_FILES['file']['name']; 			
move_uploaded_file($_FILES['file']['tmp_name'],$smallfile);
}

						
												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
				$sql="INSERT INTO `di_uac_brands` (`brnd_id`, `brnd_name`, `brnd_file`, `brnd_status`, `brnd_date`) VALUES ('', '$name', '$file_name', '$status', '$date')";
						$rs=mysql_query($sql) or die("Error in insering".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Brand added successfully";
						}
						}
						
						
						
						
						function editBrand()
						{
						@extract($_POST);
						
if(!empty($_FILES['file']['name']))
{
unlink("../images/brand/$imgname");	

$rid=rand();						
$smalldir = "../images/brand/"; 
$smallfile = $smalldir.$rid."_".$_FILES['file']['name']; 
$file_name=$rid."_".$_FILES['file']['name']; 			
move_uploaded_file($_FILES['file']['tmp_name'],$smallfile);
}
else
{
$file_name=$imgname;
}

												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
						$sql="UPDATE `di_uac_brands` SET `brnd_name` = '$name', `brnd_file` = '$file_name', `brnd_status` = '$status' WHERE `brnd_id` ='".mysql_real_escape_string($id)."'";
						$rs=mysql_query($sql) or die("Error in updating".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Brand Update successfully";
						}
						}
						
						
}
////////////////////Brand Class End////////////////////////////////


////////////////////Product Class Start////////////////////////////////
class Product
{
var $msg;
var $status;
var $notice;
var $error;
var $del;
var $act;
var $inact;


      				        function Productaction()
							{
							@extract($_GET);
							$chka=$_POST['chkid'];
							$temp="";
							if(is_array($chka))
							{
							foreach($chka as $val)
							{
							$temp.="'".$val."',";
							}
							$temp=substr($temp,0,strlen($temp)-1);
							}
							
							if($Action=="Delete")
		                    {
							$link = mysql_connect($dblocation, $dbusername, $dbpass);
							if (!$link) {
							die('Could not connect: ' . mysql_error());
							}
							mysql_select_db($dbname, $link);
							
							$sqf=mysql_query("select * from `di_uac_prd_img` where `img_prd_id` in ($temp)");
							while($rr=mysql_fetch_array($sqf)){
							unlink("../images/products/".$rr['file_name']);	
	                        
							}
							$sql_dimg="delete from `di_uac_prd_img` where `img_prd_id` in ($temp)";
							$rs_dimg=mysql_query($sql_dimg);
							
							$sql="delete from `di_uac_product` where `prd_id` in ($temp)";
							$rs=mysql_query($sql);
							mysql_close($link);
							if($rs)
							{
							$this->del="true";
							$this->msg="Product deleted successfully";
							}
								
							}
							

										if($Action=="Active")
										{
											$link = mysql_connect($dblocation, $dbusername, $dbpass);
											if (!$link) 
											{
											die('Could not connect: ' . mysql_error());
											}
										mysql_select_db($dbname, $link);
										$rs=mysql_query("UPDATE `di_uac_product` SET `prd_status`='yes' WHERE `prd_id` in ($temp)");
										mysql_close($link);
											if($rs)
											{
											$this->act="true";
											$this->msg="Product Active successfully";
											}
											
                                        } 
							
							
								if($Action=="Inactive")
								{
									$link = mysql_connect($dblocation, $dbusername, $dbpass);
									if (!$link) 
									{
									die('Could not connect: ' . mysql_error());
									}
								mysql_select_db($dbname, $link);
								$rs=mysql_query("UPDATE `di_uac_product` SET `prd_status`='no' WHERE `prd_id` in ($temp)");
								mysql_close($link);
								            if($rs)
											{
											$this->inact="true";
											$this->msg="Product Inactive successfully";
											}
									
								}

							
							}

				  
					  
					    function addProduct()
						{
						@extract($_POST);
						
						//$rid=rand();						
						
												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
						$sql="INSERT INTO `di_uac_product` (`prd_id`, `prd_cat_id`, `prd_brnd_id`, `prd_name`, `prd_price`,`prd_price_status`, `prd_longdesc`, `new_prd`,`prd_position`,`prd_status`) VALUES ('', '$parent', '$prd_brnd_id', '".addslashes($prd_name)."', '$prd_price', 'prd_price_status,', '".addslashes($long)."', '$new_prd','$prd_position', '$prd_status' )";                                                                                                
						$rs=mysql_query($sql) or die("Error in insering".mysql_error());
						
						$dyn_prd_id = mysql_insert_id();
						
						//********* Start For Upload multiple Image File
						$error=array();
						$extension=array("jpeg","jpg","png","gif");
						foreach($_FILES["files"]["tmp_name"] as $key=>$tmp_name)
						{
							$rid=rand();
							$file_name=$rid.$_FILES["files"]["name"][$key];
							$file_path_name="../images/products/".$rid.$_FILES["files"]["name"][$key];
							$file_tmp=$_FILES["files"]["tmp_name"][$key];
							$ext=pathinfo($file_name,PATHINFO_EXTENSION);
							if(in_array($ext,$extension))
							{
								if(!file_exists("../images/products/".$file_name))
								{
									$sql="INSERT INTO `di_uac_prd_img` (`img_id`, `img_prd_id`, `file_name`) VALUES ('', '$dyn_prd_id', '".addslashes($file_name)."')";
						$rs=mysql_query($sql) or die("Error in insering".mysql_error());
						
									move_uploaded_file($file_tmp=$_FILES["files"]["tmp_name"][$key],$file_path_name);
								}
								
							}
							
						}
						//********* End Of Upload multiple Image File
						
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Product added successfully";
						}
						}
						
						
						
						
						function editProduct()
						{
						@extract($_POST);
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						//********* Start For Upload multiple Image File
						$error=array();
						$extension=array("jpeg","jpg","png","gif");
						foreach($_FILES["files"]["tmp_name"] as $key=>$tmp_name)
						{
							$rid=rand();
							$file_name=$rid.$_FILES["files"]["name"][$key];
							$file_path_name="../images/products/".$rid.$_FILES["files"]["name"][$key];
							$file_tmp=$_FILES["files"]["tmp_name"][$key];
							$ext=pathinfo($file_name,PATHINFO_EXTENSION);
							if(in_array($ext,$extension))
							{
								if(!file_exists("../images/products/".$file_name))
								{
									$sql="INSERT INTO `di_uac_prd_img` (`img_id`, `img_prd_id`, `file_name`) VALUES ('', '".$id."', '".addslashes($file_name)."')";
						$rs=mysql_query($sql) or die("Error in insering".mysql_error());
						
									move_uploaded_file($file_tmp=$_FILES["files"]["tmp_name"][$key],$file_path_name);
								}
								
							}
							
						}
						//********* End Of Upload multiple Image File
												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
												
					    $sql="UPDATE `di_uac_product` SET `prd_cat_id`='$parent' , `prd_name`='".addslashes($prd_name)."', `prd_brnd_id`='$prd_brnd_id' , `prd_price`='$prd_price' ,`prd_price_status`='$prd_price_status' , `prd_longdesc`='".addslashes($long)."' , `new_prd`='$new_prd',`prd_position`='$prd_position', `prd_status`='$prd_status' WHERE `prd_id`='".mysql_real_escape_string($id)."'";
						$rs=mysql_query($sql) or die("Error in updating".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Product Update successfully";
						}
						}
						
						
						
						
}
////////////////////Product Class End////////////////////////////////

////////////////////Product Image Class Start////////////////////////////////
class ProductImg
{
var $msg;
var $status;
var $notice;
var $error;
var $del;
var $act;
var $inact;


      				        function ProductImgaction()
							{
							@extract($_GET);
							$chka=$_POST['chkid'];
							$temp="";
							if(is_array($chka))
							{
							foreach($chka as $val)
							{
							$temp.="'".$val."',";
							}
							$temp=substr($temp,0,strlen($temp)-1);
							}
							
							if($Action=="Delete")
		                    {
							
							@extract($_GET);
							
							$link = mysql_connect($dblocation, $dbusername, $dbpass);
							if (!$link) {
							die('Could not connect: ' . mysql_error());
							}
							mysql_select_db($dbname, $link);
							
							
							$sqf=mysql_query("select * from `di_uac_prd_img` where `img_id`='".mysql_real_escape_string($img_id)."'");
							while($rr=mysql_fetch_array($sqf)){
							unlink("../images/products/".$rr['file_name']);	
	                        
							}
							
							$sql="delete from `di_uac_prd_img` where `img_id`='".mysql_real_escape_string($img_id)."'";
							$rs=mysql_query($sql);
							mysql_close($link);
							if($rs)
							{
							$this->del="true";
							$this->msg="Product Image deleted successfully";
							}
								
							}
							

										if($Action=="Active")
										{
											$link = mysql_connect($dblocation, $dbusername, $dbpass);
											if (!$link) 
											{
											die('Could not connect: ' . mysql_error());
											}
										mysql_select_db($dbname, $link);
										$rs=mysql_query("UPDATE `di_uac_product` SET `prd_status`='yes' WHERE `prd_id` in ($temp)");
										mysql_close($link);
											if($rs)
											{
											$this->act="true";
											$this->msg="Product Active successfully";
											}
											
                                        } 
							
							
								if($Action=="Inactive")
								{
									$link = mysql_connect($dblocation, $dbusername, $dbpass);
									if (!$link) 
									{
									die('Could not connect: ' . mysql_error());
									}
								mysql_select_db($dbname, $link);
								$rs=mysql_query("UPDATE `di_uac_product` SET `prd_status`='no' WHERE `prd_id` in ($temp)");
								mysql_close($link);
								            if($rs)
											{
											$this->inact="true";
											$this->msg="Product Inactive successfully";
											}
									
								}

							
							}

				  
					  
					    function addProductImg()
						{
						@extract($_POST);
						
						//$rid=rand();						
						
												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
						$sql="INSERT INTO `di_uac_product` (`prd_id`, `prd_cat_id`, `prd_brnd_id`, `prd_name`, `prd_price`, `prd_price_status`,`prd_longdesc`, `new_prd`,`prd_status`) VALUES ('', '$parent', '$prd_brnd_id', '".addslashes($prd_name)."', '$prd_price','$prd_price_status', '".addslashes($long)."', '$new_prd', '$prd_status' )";                                                                                                
						$rs=mysql_query($sql) or die("Error in insering".mysql_error());
						
						$dyn_prd_id = mysql_insert_id();
						
						//********* Start For Upload multiple Image File
						$error=array();
						$extension=array("jpeg","jpg","png","gif");
						foreach($_FILES["files"]["tmp_name"] as $key=>$tmp_name)
						{
							$rid=rand();
							$file_name=$rid.$_FILES["files"]["name"][$key];
							$file_path_name="../images/products/".$rid.$_FILES["files"]["name"][$key];
							$file_tmp=$_FILES["files"]["tmp_name"][$key];
							$ext=pathinfo($file_name,PATHINFO_EXTENSION);
							if(in_array($ext,$extension))
							{
								if(!file_exists("../images/products/".$file_name))
								{
									$sql="INSERT INTO `di_uac_prd_img` (`img_id`, `img_prd_id`, `file_name`) VALUES ('', '$dyn_prd_id', '".addslashes($file_name)."')";
						$rs=mysql_query($sql) or die("Error in insering".mysql_error());
						
									move_uploaded_file($file_tmp=$_FILES["files"]["tmp_name"][$key],$file_path_name);
								}
								
							}
							
						}
						//********* End Of Upload multiple Image File
						
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Product added successfully";
						}
						}
						
						
						
						
						function editProductImg()
						{
						@extract($_POST);
						
						$rid=rand();
						
						if($_FILES['image']['name']!='')
						{	
						unlink("../images/products/$imagename");					
						$dir = "../images/products/"; 
						$file = $dir.$rid."_".$_FILES['image']['name']; 
						$imagename=$rid."_".$_FILES['image']['name']; 			
						move_uploaded_file($_FILES['image']['tmp_name'],$file);
						}
						else
						{
						$imagename=$imagename;
						}
												
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
					    $sql="UPDATE `di_uac_prd_img` SET `file_name`='".addslashes($imagename)."' WHERE `img_id`='".mysql_real_escape_string($img_id)."'";
						$rs=mysql_query($sql) or die("Error in updating".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Image Update successfully";
						}
						}
						
						
						
						
}
////////////////////Product Image Class End////////////////////////////////


////////////////////City Class Start////////////////
class City
{
var $msg;
var $status;
var $notice;
var $error;
var $del;
var $act;
var $inact;

   				  
					        function Cityaction()
							{
							@extract($_GET);
							$chka=$_POST['chkid'];
							$temp="";
							if(is_array($chka))
							{
							foreach($chka as $val)
							{
							$temp.="'".$val."',";
							}
							$temp=substr($temp,0,strlen($temp)-1);
							}
							
							if($Action=="Delete")
		                    {
							$link = mysql_connect($dblocation, $dbusername, $dbpass);
							if (!$link) {
							die('Could not connect: ' . mysql_error());
							}
							mysql_select_db($dbname, $link);
							$sql="delete from `di_uac_city` where `city_id` in ($temp)";
							$rs=mysql_query($sql);
							
							mysql_close($link);
							if($rs)
							{
							$this->del="true";
							$this->msg="City deleted successfully";
							}
								
							}
							

										if($Action=="Active")
										{
											$link = mysql_connect($dblocation, $dbusername, $dbpass);
											if (!$link) 
											{
											die('Could not connect: ' . mysql_error());
											}
										mysql_select_db($dbname, $link);
										$rs=mysql_query("UPDATE `di_uac_city` SET `city_status`='1' WHERE `city_id` in ($temp)");
										mysql_close($link);
											if($rs)
											{
											$this->act="true";
											$this->msg="City Active successfully";
											}
											
                                        } 
							
							
								if($Action=="Inactive")
								{
									$link = mysql_connect($dblocation, $dbusername, $dbpass);
									if (!$link) 
									{
									die('Could not connect: ' . mysql_error());
									}
								mysql_select_db($dbname, $link);
								$rs=mysql_query("UPDATE `di_uac_city` SET `city_status`='0' WHERE `city_id` in ($temp)");
								mysql_close($link);
								            if($rs)
											{
											$this->inact="true";
											$this->msg="City Inactive successfully";
											}
									
								}

							
							}

 					  
					  
					    function addCity()
						{
						@extract($_POST);
						
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
				$sql="INSERT INTO `di_uac_city` (`city_id`, `city_name`, `city_status`) VALUES ('', '$name',  '$status')";
						$rs=mysql_query($sql) or die("Error in insering".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="City added successfully";
						}
						}
						
						
						
						
						function editCity()
						{
						@extract($_POST);
						
											
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
						$sql="UPDATE `di_uac_city` SET `city_name` = '$name', `city_status` = '$status' WHERE `city_id` ='".mysql_real_escape_string($id)."'";
						$rs=mysql_query($sql) or die("Error in updating".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="City Update successfully";
						}
						}
						
						
}
////////////////////City Class End////////////////////////////////

////////////////////Store Class Start////////////////
class Store
{
var $msg;
var $status;
var $notice;
var $error;
var $del;
var $act;
var $inact;

   				  
					        function Storeaction()
							{
							@extract($_GET);
							$chka=$_POST['chkid'];
							$temp="";
							if(is_array($chka))
							{
							foreach($chka as $val)
							{
							$temp.="'".$val."',";
							}
							$temp=substr($temp,0,strlen($temp)-1);
							}
							
							if($Action=="Delete")
		                    {
							$link = mysql_connect($dblocation, $dbusername, $dbpass);
							if (!$link) {
							die('Could not connect: ' . mysql_error());
							}
							mysql_select_db($dbname, $link);
							$sql="delete from `di_uac_store` where `store_id` in ($temp)";
							$rs=mysql_query($sql);
							
							mysql_close($link);
							if($rs)
							{
							$this->del="true";
							$this->msg="Store deleted successfully";
							}
								
							}
							

										if($Action=="Active")
										{
											$link = mysql_connect($dblocation, $dbusername, $dbpass);
											if (!$link) 
											{
											die('Could not connect: ' . mysql_error());
											}
										mysql_select_db($dbname, $link);
										$rs=mysql_query("UPDATE `di_uac_store` SET `store_status`='1' WHERE `store_id` in ($temp)");
										mysql_close($link);
											if($rs)
											{
											$this->act="true";
											$this->msg="Store Active successfully";
											}
											
                                        } 
							
							
								if($Action=="Inactive")
								{
									$link = mysql_connect($dblocation, $dbusername, $dbpass);
									if (!$link) 
									{
									die('Could not connect: ' . mysql_error());
									}
								mysql_select_db($dbname, $link);
								$rs=mysql_query("UPDATE `di_uac_store` SET `store_status`='0' WHERE `store_id` in ($temp)");
								mysql_close($link);
								            if($rs)
											{
											$this->inact="true";
											$this->msg="Store Inactive successfully";
											}
									
								}

							
							}

 					  
					  
					    function addStore()
						{
						@extract($_POST);
						
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
				$sql="INSERT INTO `di_uac_store` (`store_id` , `store_city_id` , `store_manager` , `store_contno` , `store_email` , `store_address` , `store_business` , `store_status`) VALUES ('', '$store_city_id' , '".addslashes($store_manager)."' , '$store_contno' , '".addslashes($store_email)."' , '".addslashes($long)."' , '".addslashes($store_business)."' , '$status')";
						$rs=mysql_query($sql) or die("Error in insering".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Store added successfully";
						}
						}
						
						
						
						
						function editStore()
						{
						@extract($_POST);
						
											
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
						$sql="UPDATE `di_uac_store` SET `store_city_id` = '$store_city_id', `store_manager` = '".addslashes($store_manager)."', `store_contno` = '$store_contno', `store_email` = '".addslashes($store_email)."', `store_address` = '".addslashes($long)."', `store_business` = '".addslashes($store_business)."', `store_status` = '$status' WHERE `store_id` ='".mysql_real_escape_string($id)."'";
						$rs=mysql_query($sql) or die("Error in updating".mysql_error());
						
						mysql_close($link);
						if($rs)
						{
						$this->notice="sus";
						$this->msg="Store Update successfully";
						}
						}
						
						
}
////////////////////Store Class End////////////////////////////////

////////////////////Excel Import Class Start////////////////
class ImportFile
{
var $msg;
var $status;
var $notice;
var $error;
var $del;
var $act;
var $inact;

					  
					    function addImportFile()
						{
						@extract($_POST);
						
						$date=date("y-m-d");
						$link = mysql_connect($dblocation, $dbusername, $dbpass);
						if (!$link) {
						die('Could not connect: ' . mysql_error());
						}
						mysql_select_db($dbname, $link);
						
			
	if($_FILES["file"]["size"] > 0)
	 {
		$file = $_FILES['file']['tmp_name'];
		$handle = fopen($file, "r");
		$c = 0;
		while(($filesop = fgetcsv($handle, 1000, ",")) !== false)
		{
			$sr_no = $filesop[0];
			$prd_cat_id = $filesop[1];
			$prd_brnd_id = $filesop[2];
			$prd_name= $filesop[3];
			$prd_price = $filesop[4];
			$prd_longdesc = $filesop[5];
			//$prd_grade = $filesop[8];
			
			$sql_cat = "select cat_id,cat_name from di_uac_cat where cat_name like '%$prd_cat_id%'";
			$exQue_cat = mysql_query($sql_cat);
			$row_cat = mysql_fetch_array($exQue_cat);
			$cat_id = $row_cat['cat_id'];
			
			$sql_brnd = "select brnd_id,brnd_name from di_uac_brands where brnd_name like '%$prd_brnd_id%'";
			$exQue_brnd = mysql_query($sql_brnd);
			$row_brnd = mysql_fetch_array($exQue_brnd);
			$brnd_id = $row_brnd['brnd_id'];
			
			$que_fi = "insert into di_uac_product SET prd_name='".addslashes($prd_name)."' , prd_cat_id='".$cat_id."' , prd_brnd_id='".addslashes($brnd_id)."' , prd_price='".addslashes($prd_price)."' , prd_longdesc='".addslashes($prd_longdesc)."' , prd_status='yes'";

$exQue_fi = mysql_query($que_fi);
			
			$c = $c + 1;
		}
		
	 }
						mysql_close($link);
						if($que_fi)
						{
						$this->notice="sus";
						$this->msg=$c." product added successfully";
						}
						}
						
						
						
}
////////////////////Excel Import Class End////////////////////////////////
?>
