system: Linux mars.sprixweb.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
cmd: 

Direktori : /home/pfhr/public_html/admin/classes/Model/
Upload File :
Current File : /home/pfhr/public_html/admin/classes/Model/MMembersManager.php

<?PHP
class Model_MMembersManager
{
	
	function showMembersList()
	{
		// storing  request (ie, get/post) global array to a variable  
		$requestData= $_REQUEST;
		$columns = array( 
		// datatable column index  => database column name
			0 =>	'members_icard', 
			1 => 	'members_name',
			2 => 	'members_phone',
			3 => 	'members_city'
		);
		$obj=new Bin_Query();
		$select="SELECT * FROM members_table where members_id !=''";
		$obj->executeQuery($select);
		$totalData=count($obj->records);
		$totalFiltered = $totalData;
		
		
		$obj=new Bin_Query();
		$select="SELECT * FROM members_table WHERE 1=1 and members_id !=''";

		// getting records as per search parameters
		if( !empty($requestData['columns'][0]['search']['value']) ){   //name
			$select.=" AND members_icard LIKE '".$requestData['columns'][0]['search']['value']."%' ";
		}

		$obj->executeQuery($select);
		$totalFiltered = count($obj->records);
		$obj=new Bin_Query();
		$select.=" ORDER BY ". $columns[$requestData['order'][0]['column']]."   ".$requestData['order'][0]['dir']."  LIMIT ".$requestData['start']." ,".$requestData['length']."   ";
		
		$obj->executeQuery($select);
		 

		$data = array();
		for($i=0;$i<count($obj->records);$i++)
			{
			
			
			$row=$obj->records[$i];
			$nestedData=array(); 			
			$nestedData[] = $row["members_icard"];
			$nestedData[] = $row["members_name"];
			$nestedData[] = $row["members_phone"];
			$nestedData[] = $row["members_city"];
			$nestedData[] = $row["members_city"];
			$nestedData[] ='
			<a href="#" class="btn btn-success btn-xs"><span class="glyphicon glyphicon-search"></span></a>
			<a href="?do=members&action=editmember&id='.$row["members_id"].'" class="btn btn-info btn-xs"><span class="glyphicon glyphicon-edit"></span></a>
			<a href="#" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-trash"></span></a>
			
			';
			
			$data[] = $nestedData;		
			}
			

	$json_data = array(
				"draw"            => intval( $requestData['draw'] ),   // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw. 
				"recordsTotal"    => intval( $totalData ),  // total number of records
				"recordsFiltered" => intval( $totalFiltered ), // total number of records after searching, if there is no searching then totalFiltered = totalData
				"data"            => $data   // total data array
				);
	echo json_encode($json_data);  // send data as json format		
	}
	
	
	
	
	
	
	
	
	
	
	function showUserManager()
	{
		$sql1="select * from members_table  order by members_icard ASC";
		$obj2=new Bin_Query();
		$obj2->executeQuery($sql1);
		return Display_DUserManager::showUserManager($obj2->records);
	}
	
	function insertUser()
	{		
		$receipt_no=$_POST['txtrepno'];
		$receipt_pay_mode=$_POST['txtrepstatus'];
		$receipt_date=$_POST['txtrepdate'];
		$username=$_POST['txtusername'];
		$mem_sponser=$_POST['txtsponser'];
		$name=$_POST['txtname'];
		$of=$_POST['txtof'];
		$fname=$_POST['txtfname'];
		$dob=$_POST['txtdob'];
		$address=$_POST['txtaddress'];
		$city=$_POST['txtcity'];
		$block=$_POST['txtblock'];
		$tehsil=$_POST['txttehsil'];
		$district=$_POST['txtdistrict'];
		$state=$_POST['txtstate'];
		$country='India';
		$zipcode=$_POST['txtzipcode'];
		$phone=$_POST['txtphone'];
		$rank=$_POST['txtrank'];
		$rank1=$_POST['txtrank1'];
		$rank_date=$_POST['txtrankdate'];
		$membership=$_POST['txtmembership'];
		$membership_date=$_POST['txtmemdate'];
		$doj=$_POST['txtdoj'];
		$blood=$_POST['txtblood'];
		

		$uploaded_path = '../uploads/members';
		$saved_path = 'uploads/members';
		$saved_path1 = 'uploads/members_thumb';
		$uploaded_path1 = '../uploads/members_thumb';
		
		if($_FILES['image']['size']>0)
		{	
			$time=time();
			$headerimage = $uploaded_path."/".$time.'.jpg';
			$savedpath = $saved_path."/".$time.'.jpg';
			move_uploaded_file($_FILES['image']['tmp_name'],$headerimage);
			new Lib_ThumbImage('thumb',$headerimage,$uploaded_path1,40);
			$savedpath1 = $saved_path1."/".$time.'.jpg';
				
		}


		$obj = new Bin_Query();
		$insertmember="INSERT INTO members_table(`members_icard`, `members_under`, `members_name`, `members_of`, `members_fname`, `members_phone`, `members_doj`,`members_pos`, `members_address`, `members_city`, `members_block`, `members_tehsil`, `members_district`, `members_state`, `members_zip`, `members_country`, `members_rank`,`members_rank1`, `members_rank_date`, `members_blood`, `members_dob`, `members_membership`, `members_membership_date`, `members_rep_no`, `members_rep_status`, `members_rep_date`, `members_image`, `members_thumb_image`) VALUES('$username','$mem_sponser','$name','$of','$fname','$phone','$doj','$pos','$address','$city','$block','$tehsil','$district','$state','$zipcode','$country','$rank','$rank1','$rank_date','$blood','$dob','$membership','$membership_date','$receipt_no','$receipt_pay_mode','$receipt_date','$savedpath','$savedpath1')";
		 
		
		if($obj->updateQuery($insertmember))
		{
			$_SESSION['message']="User Added Sucessfully";
			header('Location:?do=usermanager&action=adduser');
		}
	else
		{
			$_SESSION['error_message']="Process Failed";
			header('Location:?do=usermanager&action=adduser');
			exit();
		}
	
	}
	
			
	function showEditDetail()
	{
		$userid=$_GET['id'];
		$obj1=new Bin_Query();
		$select="select * from members_table where members_id='$userid'";
		$obj1->executeQuery($select);
		return $obj1->records[0];
	}

	

	function UpdateMembers()
	{
		if(isset($_POST['update']))
		{
			$usrid=(int)$_GET['usrid'];
			$rep_no=$_POST['txtrepno'];
			$rep_pay_type=$_POST['txtrepstatus'];
			$rep_date=$_POST['txtrepdate'];
			$usernames=$_POST['txtusername'];
			$mem_sponser=$_POST['txtsponser'];
			$name=$_POST['txtname'];
			$of=$_POST['txtof'];
			$fname=$_POST['txtfname'];
			$dob=$_POST['txtdob'];
			$address=$_POST['txtaddress'];
			$city=$_POST['txtcity'];
			$block=$_POST['txtblock'];
			$tehsil=$_POST['txttehsil'];
			$district=$_POST['txtdistrict'];
			$state=$_POST['txtstate'];
			$zipcode=$_POST['txtzipcode'];
			$phone=$_POST['txtphone'];
			$rank=$_POST['txtrank'];
			$rank1=$_POST['txtrank1'];
			$rank_date=$_POST['txtrankdate'];
			$membership=$_POST['txtmembership'];
			$membership_date=$_POST['txtmemdate'];
			$doj=$_POST['txtdoj'];
			$blood=$_POST['txtblood'];
			$usrid=$_POST['user_id'];
															$uploaded_path = '../uploads/members';
			$uploaded_path1 = '../uploads/members_thumb';
			$saved_path = 'uploads/members';
			$saved_path1 = 'uploads/members_thumb';
			$image=$_FILES['image']['name'];
			if($_FILES['image']['size']>0)
			{	
				////////////New Modification////////////
				$select="select * from members_table where members_id='$usrid'";
				$obj1= new Bin_Query();
				$obj1->executeQuery($select);
				$mphotoM=$obj1->records[0]['members_image'];
				$mphotoTumb=$obj1->records[0]['members_thumb_image'];
				$mphoto='../'.$mphotoM.'';
				$mphoto1='../'.$mphotoTumb.'';
				unlink($mphoto);
				unlink($mphoto1);
				
				////////////New Modification////////////
                                $time=time();
				$headerimage = $uploaded_path."/".$time.'.jpg';
				$savedpath = $saved_path."/".$time.'.jpg';
				move_uploaded_file($_FILES['image']['tmp_name'],$headerimage);
				new Lib_ThumbImage('thumb',$headerimage,$uploaded_path1,40);
				$savedpath1 = $saved_path1."/".$time.'.jpg';
			
			}
			else
			{
				$select="select * from members_table where members_id='$usrid'";
				$obj1= new Bin_Query();
				$obj1->executeQuery($select);
				$savedpath=$obj1->records[0]['members_image'];
				$savedpath1=$obj1->records[0]['members_thumb_image'];
			}
			 $update="update members_table set members_rep_no='$rep_no',
			 members_rep_status='$rep_pay_type',
			 members_rep_date='$rep_date',
			 members_icard='$usernames',
			 members_under='$mem_sponser',
			 members_name='$name',
			 members_of='$of',
			 members_fname='$fname',
			 members_dob='$dob',
			 members_address='$address',
			 members_city='$city',
			 members_block='$block',
			 members_tehsil='$tehsil',
			 members_district='$district',
			 members_state='$state',
			 members_country='India',
			 members_zip='$zipcode',
			 members_phone='$phone',
			 members_rank='$rank',
			 members_rank1='$rank1',
			 members_rank_date='$rank_date',
			 members_membership='$membership',
			 members_membership_date='$membership_date',
			 members_doj='$doj',
			 members_blood='$blood',
			 members_image='$savedpath',
			 members_thumb_image='$savedpath1' where members_id='$usrid'";
			
			$obj=new Bin_Query();
			if($obj->updateQuery($update))
			{
				 $_SESSION['message']='User Updated Sucessfully';	
				header('Location:?do=members');
			}
			else
			{
				 $_SESSION['message']='User Updated Sucessfully';
				 header('Location:?do=members');
			}
		}
		
		
		if(isset($_POST['del']))
		{
			$usrid=$_POST['user_id'];
			$obj=new Bin_Query();
			$sql1="delete from members_table  WHERE members_id='".$usrid."' ";
			
			////////////New Modification////////////
			$select="select * from members_table where members_id='$usrid'";
			$obj1= new Bin_Query();
			$obj1->executeQuery($select);
			$mphotoM=$obj1->records[0]['members_image'];
			$mphotoTumb=$obj1->records[0]['members_thumb_image'];
			$mphoto='../'.$mphotoM.'';
			$mphoto1='../'.$mphotoTumb.'';
			unlink($mphoto);
			unlink($mphoto1);
			
			////////////New Modification////////////
				
			if($obj->updateQuery($sql1))
				{
					$_SESSION['message']='User Deleted Sucessfully';
					header('Location:?do=members');
				}					
			else
				{
					$_SESSION['error_message']='Please select the User(s) to be Deleted';
					header('Location:?do=members');
				}	

		}
		
		if(isset($_POST['delPIC']))
		{
			$usrid=$_POST['user_id'];
			$select="select * from members_table where members_id='$usrid' ";
			$obj1= new Bin_Query();
			if($obj1->updateQuery($select))
				{
					$mphotoM=$obj1->records[0]['members_image'];
					$mphotoTumb=$obj1->records[0]['members_thumb_image'];
					$mphoto='../'.$mphotoM.'';
					$mphoto1='../'.$mphotoTumb.'';
					unlink($mphoto);
					unlink($mphoto1);
					
					$obj12=new Bin_Query();
					$update="update members_table set members_image='', members_thumb_image='' where members_id='$usrid'";
					$obj12->executeQuery($update);
					
					$_SESSION['message']='Picture Deleted Sucessfully';
					header('Location:?do=members&action=editmember&id='.$usrid.'');
				}					
			else
				{
					$_SESSION['error_message']='Please select the User(s) to be Deleted';
					header('Location:?do=members&action=editmember&id=$usrid');
				}	

		}
		
		
		
	}
	function ChangeMembersDetails()
	{
		$OldID=$_POST['txtOldID'];
		$NewID=$_POST['txtNewID'];
		
			$obj=new Bin_Query();
			$select="select * from members_table where members_icard='$NewID'";
			if($obj->executeQuery($select))
			{

				$idno=$obj->records[0]['members_id'];
				$obj12=new Bin_Query();
				$update="update members_table set members_icard='M$NewID' where members_id='$idno'";
				if($obj12->updateQuery($update))
					{
							
					$obj5=new Bin_Query();
					$select5="select * from members_table where members_icard= '$OldID' ";
					if($obj5->executeQuery($select5))
						{
						$IDNO5=$obj5->records[0]['members_id'];
						$obj6=new Bin_Query();
						$update6="update members_table set members_icard='$NewID',members_membership='1' where members_id='$IDNO5'";
						if($obj6->updateQuery($update6))
							{
								header('Location:?do=members&action=editmember&id='.$IDNO5.'');
							}
						else
							{
								echo 'New ID Card Update Failed';
							}
							
						}
					else
						{
							echo 'ffNew ID Card Update Failed';
						}		
							
							
							
							
							
							
							
							
					}
				else
					{
							echo 'U';
					}
						
						
			}
			else
			{
				$obj5=new Bin_Query();
				$select5="select * from members_table where members_icard= '$OldID'";
				if($obj5->executeQuery($select5))
					{
					echo $IDNO5=$obj5->records[0]['members_id'];
					$obj6=new Bin_Query();
					$update6="update members_table set members_icard='$NewID',members_membership='1' where members_id='$IDNO5'";
					if($obj6->updateQuery($update6))
						{
							header('Location:?do=members&action=editmember&id='.$IDNO5.'');
						}
					else
						{
							echo 'New ID Card Update Failed';
						}
						
					}
				else
					{
						echo 'ffNew ID Card Update Failed';
					}
			}
		
		
	}
	
}
?>