ok

Mini Shell

Direktori : /home2/selectio/public_html/subamangala/admin/apis/
Upload File :
Current File : /home2/selectio/public_html/subamangala/admin/apis/preferance-admin-create-update-api.php

<?php 
ob_start();
session_start();
include "../config/config.php";
$session_id = $_SESSION['subamangala_matrimony']['id'];
error_log('admin Preferance Page Api Is Working Well');

// City Details Create, Update Starts Here 

if(isset($_POST['type']) && $_POST['type']=='create_update_admin_preferance'){
     try{
         
         $profileid=$_POST['ids'];
         
         $insertstatus=$_POST['insertstatus'];
         
         $file_name ='';
         
         // Multi Select Implode Values Starts Here
         
         
                    // Caste implode
                    $caste_ids="";
                    if(isset($_POST['caste'])){
                    $caste_ids = implode(',', $_POST['caste']);
                    error_log($caste_ids);
                    
                    
                    }
                    
                    // Natchathiram implode
                    
                    $natchathiram_ids="";
                    if(isset($_POST['natchatram'])){
                    $natchatram_ids = implode(',', $_POST['natchatram']);
                    }
                    
                    
                    // Thosam implode 
                    
                    $thosam_ids="";
                    if(isset($_POST['thosam'])){
                    $thosam_ids = implode(',', $_POST['thosam']);
                    }
                    
                    
                    // Eduction implode edu
                    
                    $edu_ids="";
                    if(isset($_POST['edu'])){
                    $edu_ids = implode(',', $_POST['edu']);
                    }
                    
                    
                    // Marriage implode edu
                    
                    $marriage_ids="";
                    if(isset($_POST['marriage'])){
                    $marriage_ids = implode(',', $_POST['marriage']);
                    }
 
         
                    // Height implode edu
                    
                    $height_ids="";
                    if(isset($_POST['height_cat'])){
                    $height_ids = implode(',', $_POST['height_cat']);
                    }
         
         
                    $limit_sta=$_POST['limit_sta'];
                	$limit=$_POST['limit'];
         
         // Multi Select Implode Values Ends Here
         
         // Post Values Dates Starts Here
         
         
         	if(!empty($_POST['miny'])){
            		$miny=$_POST['miny'];
            		$maxy=$_POST['maxy'];
            		
            	}
            	else{
            		$miny='';$maxy='';
            	}
         
                 $servicedate=$_POST['date'];
        	     $servicedate=date('Y-m-d', strtotime($servicedate));
         
         
         
         	$days=$_POST['days'];
        	$login=$_POST['login'];
        	date_default_timezone_set('Asia/Kolkata'); 
        	
        	$cur=date('Y-m-d');
        	
        	if($days=='1')
        	{
        		$curdate=date('Y-m-d');
        	}
        	elseif($days=='0')
        	{
        		$curdate='';
        	}else{
        	    
        	    $statement = $pdo->prepare("select * from admin_preference where Profileid='$profileid' and Pref_Days='$days'");
                $statement->execute();
                $datas = $statement->fetchAll(PDO::FETCH_ASSOC);
                
                if($datas){
                    $curdate=$datas[0]['Entry_Date'];
                }else{
                    $dayss='+'.$days.' day';
		            $curdate=date('Y-m-d', strtotime($dayss, strtotime($cur)));
                }
        	}
         
         // Post Values Dates Ends Here
         
         
         // Preferance Table Update Query Starts Here   
         
         
         
         
         	if($insertstatus=='Updatevalue')
            	{
            	if($limit_sta=='Automatic')
            	{
            	    
            	    $statement1 = $pdo->prepare("select * from admin_preference where Profileid='$profileid' and Pref_Limit='$limit'");
                    $statement1->execute();
                    $datas1 = $statement1->fetchAll(PDO::FETCH_ASSOC);

            		if($datas1)
            		{
            			$Total_Count=$datas1[0]['Total_Count'];
            		}
            		else
            		{
            			$Total_Count=$limit;
            		}
            	}
	
	
	$statement = $pdo->prepare("UPDATE `admin_preference` SET `Pref_Caste`=?, `Pref_Star`=?, `Pref_Dhosam`=?, `Pref_Edu`=?, `Pref_Height`=?, `Pref_Marriage`=?, `From_Year`=?, `To_Year`=?, `Pref_Limit`=?, `Pref_Days`=?, `Entry_Date`=?, `Limit_Status`=?, `Service_Date`=?, `Total_Count`=? WHERE Profileid=?");
    $result = $statement->execute(array($caste_ids, $natchatram_ids, $thosam_ids, $edu_ids, $height_ids, $marriage_ids, $miny, $maxy, $limit, $days, $curdate, $limit_sta, $servicedate, $Total_Count,  $profileid));
	
	}else{
	
	if($limit_sta=='Automatic')
	{
		$Total_Count=$limit;
	}
	else{
		$Total_Count='';
	}
	
	
	 $statement6 = $pdo->prepare("INSERT INTO `admin_preference`(`Pref_Caste`,`Pref_Star`,`Pref_Dhosam`,`Pref_Edu`,`Pref_Height`,`Pref_Marriage`,`From_Year`,`To_Year`,`Profileid`,`Pref_Limit`,`Pref_Days`,`Entry_Date`,`Limit_Status`,`Service_Date`,`Total_Count`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
     $result6 = $statement6->execute(array($caste_ids,$natchatram_ids,$thosam_ids,$edu_ids,$height_ids,$marriage_ids,$miny,$maxy,$profileid,$limit,$days,$curdate,$limit_sta,$servicedate,$Total_Count));
	
	
	}
        
         // Preferance Table Update Ends Here
        
     if($result){
	
   
            $return_arr['message']='Preferance Details Added Successfully...';
           // $return_arr['last_id']=$last_id;
            $return_arr['status']=200;
   
       } else{
            $return_arr['message']='Something Went Wrong..';
            $return_arr['status']=400;
        }
         
    }catch(PDOException $e){
        $return_arr['message']="$e";
        $return_arr['status']=500;
        }   
    echo json_encode($return_arr);
}


function gettotalmatches($profileid,$pdo)
{
    $cont='0';
	

	//echo $query;
	
	$statement9 = $pdo->prepare("select 
count(*) as cont from 
profiles Ori,admin_preference pref,
profiles Mat left outer join rassi r on Mat.rasi=r.id
left OUTER join natchatram n on Mat.natchatram=n.id
left OUTER join caste c on c.id=Mat.caste
left OUTER join subcaste s on s.id=Mat.subcaste
WHERE
Ori.id='$profileid' and pref.Profileid=Ori.id
and Year(STR_TO_DATE(Mat.dob,'%d-%m-%Y')) BETWEEN if(pref.From_Year='',1900,From_Year) and if(pref.To_Year='',year(CURDATE()),To_Year)
and Mat.gender<>Ori.gender
and c.id like if(pref.Pref_Caste='','%',if(FIND_IN_SET(c.id,pref.Pref_Caste)<>0,c.id,0))
and n.id like if(pref.Pref_star='','%',if(FIND_IN_SET(n.id,pref.Pref_Star)<>0,n.id,0))
and Mat.edu_cat like if(pref.Pref_Edu='','%',FIND_IN_SET(Mat.edu_cat,pref.Pref_Edu))
and Mat.height_cat like if(pref.Pref_Height='','%',FIND_IN_SET(Mat.height_cat,pref.Pref_Height))
and Mat.marriage like if(pref.Pref_Marriage='','%',FIND_IN_SET(Mat.marriage,pref.Pref_Marriage))
and Mat.regnop like if(pref.Pref_Dhosam='','%',FIND_IN_SET(Mat.regnop,pref.Pref_Dhosam))
order by c.id");
    $statement9->execute();
    $datas9 = $statement9->fetchAll(PDO::FETCH_ASSOC);

	if($datas9)
	{
		$cont=$datas9[0]['cont'];
		
	}
	
	
	return $cont;
}
?>

Zerion Mini Shell 1.0