Location: PHPKode > projects > Opensheet > opensheet/classes/groups.class.php
<?php 
#include ('../functions/base.functions.php');
#include ('drawPage.class.php');
#include ('../functions/base.functions.php');
#ini_set('display_errors',1);
#error_reporting(E_ALL);
#echo HI;

class Groups extends Base{
					
				
			  function getGroup($group_index){
			    #	db_connect();
				    $query = "SELECT `group_name`,`group_index`,`owner`,`note`,`status` FROM `groups` WHERE `group_index` = '$group_index'";
				#	$result = mysql_query($query) or die("Invalid query: " . mysql_error());
				#   	
			  }		
				  
			        #!!!!!!!!!!
 			function getGroupOwner($group_index){
			    #	db_connect();
				    $query = "Select real_name,user_index from users where user_index =any(SELECT owner FROM `groups` where `group_index` = '$group_index')";
					$result = mysql_query($query) or die("Invalid query: " . mysql_error());
				#   while($row = mysql_fetch_assoc($result)) {	
				#	$answer = array(user_index=>$row['user_index'],real_name=>$row['real_name']);
				 #  }
				    return $answer;
				    #print_r( $answer);
			        }	
			        
			function getOwnersGroup($user_index){
				    $query = "SELECT `id`,`group_name`,`owner_id`,`note`,`status` FROM `groups` WHERE `owner_id` = '$user_index'";
					foreach (parent::dbQuery($query) as $id=>$value){
				    	$result[$value['id']]=array('id'=>$value['id'],'group_name'=>$value['group_name'],'owner_id'=>$value['owner_id'],'note'=>$value['note'],'status'=>$value['status']);
				    }
				  	 return $result;
				   
					}
			        
			        
				function getGroupsArray($status){
			    	if($status == 'active'){
			    		$query = "SELECT `id`,`group_name`,`owner_id`,`note` FROM `groups` WHERE status='Y' ORDER BY `group_name`  DESC ";
			    		
			    	}else {
			    		$query = "SELECT `id`,`group_name`,`owner_id`,`note`,`status` FROM `groups` ORDER BY `group_name`  DESC ";
			    	}
				    foreach (parent::dbQuery($query) as $id=>$value){
				    	$result[$value['id']]=array('group_name'=>$value['group_name'],'owner_id'=>$value['owner_id'],'note'=>$value['note'],'status'=>$value['status']);
				    }
				  	 return $result;
						 
			        }   

			       function addGroup($gid_name,$owner_id,$status,$note){
			    		$query = "INSERT INTO  `timesheet`.`groups` ( `owner_id` ,`group_name` , `status` , `note`) VALUES ( '$owner_id','$gid_name','$status', '$note')";	
			    		parent::dbQuery($query);
				   }
					
					function updateGroup($gid,$gid_name,$owner_id,$status,$note){
			    		$query = "UPDATE `timesheet`.`groups` SET `group_name` = '$gid_name',`owner_id` = '$owner_id',`status`='$status',`note`='$note'  WHERE `groups`.`id` =$gid";	
			    		parent::dbQuery($query);
				   }
				   
				   
				   
			       function setGroupValue($group_index,$value_name,$value){
			    	#db_connect();
			    	$query = "UPDATE  `timesheet`.`groups` SET  `$value_name` = '".$value."' WHERE `groups`.`group_index` = '".$group_index."'";	
			    	#$result = mysql_query($query) or die("Invalid query: " . mysql_error());
					#return $answer;
				    
				 
			        }   
			        
			     function getGroupUsers($group_index){
			    	
				    $query = "SELECT id,real_name FROM `users` where `group_id` = '$group_index'";
					return parent::dbQuery($query);
				 
			        } 
			            
				function getGroupName($group_index){
			    	
				    $query = "SELECT group_name FROM `groups` where `id` = '$group_index'";
					return parent::dbQueryRow($query);
				 
			        }     
			        
				    
				    
			} 		
			        


?>
Return current item: Opensheet