ok

Mini Shell

Direktori : /home2/selectio/www/y1jobportal.in/admin/api/
Upload File :
Current File : //home2/selectio/www/y1jobportal.in/admin/api/bulk_updates.php

<?php 
ob_start();
session_start();
include "config/config.php";
include_once('config/custom-functions.php');
$session_id = $_SESSION['y1_jobs']['id'];
$date = date("Y-m-d");
$updated_at = date("Y-m-d H:i:s");
$fn = new custom_functions;

if($_POST['type']=="bulk_job_assign"){
    
    
    $assign_id = implode(',', $_POST['assign_id']);
    $interview_date = $_POST['interview_date'];
    $job_vacancy_id = $_POST['job_details'];
    
    
    
    

    
    
    
    
    // stephen logic ends
    
    
    
    
    
    
    
    
    
    
    
    
   
    
    for($i=0;$i<count($_POST['assign_id']);$i++){
        $employee_id = $_POST['assign_id'][$i];
        
        $statementss = $pdo->prepare("SELECT * FROM `tbl_job_assign` WHERE assign_date=? and requirement_id=? and employee_id=?");
        $statementss->execute(array($date,$job_vacancy_id, $employee_id));
        $datasss = $statementss->fetchAll(PDO::FETCH_ASSOC);
        $totalDatass = $statementss->rowCount();
        $job_assign_id = $datasss[0]['id'];
        
    /*Push Notification Start    */
        $statementss = $pdo->prepare("SELECT * FROM `customer` WHERE id=?");
        $statementss->execute(array($employee_id));
        $cus_res = $statementss->fetchAll(PDO::FETCH_ASSOC);
        if($cus_res){
            $id=0;$type='default';
            $title="Hi ".$cus_res[0]['cust_firstname'].", Your Interview Have Been Scheduled";
            $message="Kindly attend the interview,Date: ".$date;
            $fn->send_notification($cus_res[0]['fcm_id'], $title,$message,$type,$id);
        }
    /*Push Notification End   */    
        
        
        
        
        
        if($totalDatass>0){
            $statement = $pdo->prepare("UPDATE `tbl_job_assign` SET `requirement_id`=?, `employee_id`=?, `assign_date`=?, `interview_date`=?, `updated_by`=?, `updated_at`=? WHERE id=?");
            $result=$statement->execute(array($job_vacancy_id, $employee_id, $date, $interview_date, $session_id, $updated_at, $job_assign_id));
            
          /*  Subscription plans table conditions  by stephen for customer */
            $statement_subscr = $pdo->prepare("SELECT * FROM `tbl_subscription_details` WHERE type = 1 and customer_id=? ");
            $statement_subscr->execute(array( $employee_id));
            $subscr = $statement_subscr->fetchAll(PDO::FETCH_ASSOC);
            $no_of_interviews = $subscr[0]['no_of_interviews'];
            $status = $subscr[0]['status'];
            if($no_of_interviews!=1){
                $no_of_interviews-- ;
                 $statement_sub = $pdo->prepare("UPDATE `tbl_subscription_details` SET `no_of_interviews`=? WHERE type=1 and customer_id =?");
                 $result_sub=$statement_sub->execute(array($no_of_interviews, $employee_id));
             }else{
                 
                 
                 
                 $statement_sub = $pdo->prepare("UPDATE `tbl_subscription_details` SET `status`=?, `no_of_interviews`= 0 WHERE type=1 and customer_id =?");
                 $result_sub=$statement_sub->execute(array(2, $employee_id));
                 error_log('stephen'.'UPDATE `customer` SET `process`= 5 , status = 2 where  id ='.$employee_id);
                $statement_sub = $pdo->prepare("UPDATE `customer` SET `process`=? , status = 2 where  id =?");
                $result_sub=$statement_sub->execute(array(5, $employee_id));
                         
                 
             }
          /*  Subscription plans table conditions  by stephen for Client */
          
          
            $statement_client = $pdo->prepare("SELECT * FROM `tbl_subscription_details` WHERE customer_id=? and type=2 and status=1 ");
            $statement_client->execute(array( $assign_id));
            $client = $statement_client->fetchAll(PDO::FETCH_ASSOC);
            $no_of_interviews = $client[0]['no_of_interviews'];
            $id = $client[0]['id'];
            $status = $client[0]['status'];
            $countids = count($_POST['assign_id']); 
            // if($no_of_interviews!=0){
            if($no_of_interviews!=0){
                $no_of_interviews-- ;
                 $statement_sub = $pdo->prepare("UPDATE `tbl_subscription_details` SET `no_of_interviews`=? WHERE type=2 and id =?");
                 $result_sub=$statement_sub->execute(array($no_of_interviews, $id));
                    if($no_of_interviews == 0){
                        
                         $statement_sub = $pdo->prepare("UPDATE `tbl_subscription_details` SET `status`=? WHERE type=2 and id =?");
                         $result_sub=$statement_sub->execute(array(2, $id));
                         
                         
              
                         
                         
                     }
             }
             
             
            
          /*  Subscription plans table conditions  by stephen for Client */
            
            
            
               
            
            
        }else{
            $statement = $pdo->prepare("INSERT INTO `tbl_job_assign`(`requirement_id`, `employee_id`, `assign_date`, `interview_date`, `created_by`) VALUES (?,?,?,?,?)");
            $result=$statement->execute(array($job_vacancy_id, $employee_id, $date, $interview_date, $session_id));
            
            
            /*  Subscription plans table conditions  by stephen for customer */
            $statement_subscr = $pdo->prepare("SELECT * FROM `tbl_subscription_details` WHERE customer_id=? ");
            $statement_subscr->execute(array( $employee_id));
            $subscr = $statement_subscr->fetchAll(PDO::FETCH_ASSOC);
            $no_of_interviews = $subscr[0]['no_of_interviews'];
            $status = $subscr[0]['status'];
            error_log('$no_of_interviews'.$no_of_interviews);
            error_log('$status'.$status);
            if($no_of_interviews!=0){
                $no_of_interviews-- ;
                 $statement_sub = $pdo->prepare("UPDATE `tbl_subscription_details` SET `no_of_interviews`=? WHERE customer_id =?");
                 $result_sub=$statement_sub->execute(array($no_of_interviews, $employee_id));
             }else{
                 $statement_sub = $pdo->prepare("UPDATE `tbl_subscription_details` SET `status`=? WHERE customer_id =?");
                 $result_sub=$statement_sub->execute(array(2, $employee_id));
                 
             }
            
            
          /*  Subscription plans table conditions  by stephen for Client */
          
          
            $statement_client = $pdo->prepare("SELECT * FROM `tbl_subscription_details` WHERE customer_id=? and type=2 and status=1 ");
            $statement_client->execute(array( $assign_id));
            $client = $statement_client->fetchAll(PDO::FETCH_ASSOC);
            $no_of_interviews = $client[0]['no_of_interviews'];
            $id = $client[0]['id'];
            $status = $client[0]['status'];
            $countids = count($_POST['assign_id']); 
            if($no_of_interviews!=0){
                $no_of_interviews-- ;
                 $statement_sub = $pdo->prepare("UPDATE `tbl_subscription_details` SET `no_of_interviews`=? WHERE type=2 and id =?");
                 $result_sub=$statement_sub->execute(array($no_of_interviews, $id));
                    if($no_of_interviews == 0){
                         $statement_sub = $pdo->prepare("UPDATE `tbl_subscription_details` SET `status`=? WHERE type=2 and id =?");
                         $result_sub=$statement_sub->execute(array(2, $id));
                     }
             }
            
          /*  Subscription plans table conditions  by stephen for Client */
            
            
            
              
            
            
            
            
            
            
        }
        
    }
    
    if($result)
    	{
    	    $message='Success..';
    	    $error='1';
    	}
    	else
    	{
    	    $message='Failed..';
    	    $error='0';
    	}
    		$datas[] = array('message' => $message, 'error' => $error);                   
            echo $message;
    }

?>

Zerion Mini Shell 1.0