Sindbad~EG File Manager

Current Path : /home/numerotech/www/livemt2023.aios-scientificcommittee.org/app/controllers/
Upload File :
Current File : //home/numerotech/www/livemt2023.aios-scientificcommittee.org/app/controllers/BOFPController.php

<?php

class BOFPController extends BaseController {

    public function bo_path()
    {
        return "backoffice/abstracts/";
    }

    //IF id is null then create empty fp and redeirect to edit fp page
    //if id is not null then fp can edit 
    public function getFP($id = null){ 

    	$categories = array('' => '--select--') + Category::FP();    	
    	$pres_types = array('' => '--select--') + PresType::lists('type','presentation_type_id');

        $pres_auth_id = 0;

        try {
            if($id != null)
                $id = intval(urldecode(Helper::decrypt($id)));
        } catch (Exception $e) {
            return Redirect::to('bo/dashboard');
        }
        
		if($id>0)
		{
            $result    = Abstracts::usp_get_abstracts(null,null,null,null,$id,null,null,null,null,null,null,null);
            $fp        = $result['abstracts'][0];
            $authors   = $result['authors'];
            $ca = null;
            foreach ($authors as $key => $value) {
                if($value->role_id==CustomClass::$ChiefAuthor)
                {
                    $ca =$value;
                }
                if($value->role_id==CustomClass::$PresentingAuthor)
                {
                    $pres_auth_id =$value->user_id;
                }
            }	
		}        

        return View::make($this->bo_path() . 'fp.fp')
        			->with('fp',$fp) 
                    ->with('pres_auth_id',$pres_auth_id)                   
        			->with('categories',$categories)
        			->with('pres_types',$pres_types)
        			->with('ca',$ca);
    }

    //FP Search user for chief Author
    public function getSearchMembersCA(){
        try {
            $arr   = [];
            $data  = "";
            $msg   = "";            
            $code  = 0;

            $search = Helper::trimAndTruncate(Input::get('search'),250);
            
            $data   = Abstracts::usp_get_authors($search,CustomClass::$FP,CustomClass::$ChiefAuthor,null,null,null); 
           
            if(empty($data))
            {
                $data = "";
                $code = 0;
                $msg  = "record not found";
            }
            else
            {                
                $code = 1;
                $msg  = "";
            }


        } catch (Exception $e) {
            Log::error('BOFPController - getSearchMembersCA'.$e->getMessage());
            $msg =AppMessage::$GENERAL_ERROR;

        }
        $arr = ['data' => $data, 'code' => $code, 'msg' => $msg];

        return Response::json($arr); 
    }

    //FP Search user for Presenting Author
    public function getSearchMembersPA(){
        try {            $arr   = [];
            $data  = "";
            $msg   = "";            
            $code  = 0;

            $search = Helper::trimAndTruncate(Input::get('search'),250);

            $data   = Abstracts::usp_get_authors($search,CustomClass::$FP,CustomClass::$PresentingAuthor,null,null,null); 
           
            if(empty($data))
            {
                $data = "";
                $code = 0;
                $msg  = "record not found";
            }
            else
            {                
                $code = 1;
                $msg  = "";
            }


        } catch (Exception $e) {
            Log::error('BOFPController - getSearchMembersPA'.$e->getMessage());
            $msg =AppMessage::$GENERAL_ERROR;

        }
        $arr = ['data' => $data, 'code' => $code, 'msg' => $msg];

         return Response::json($arr); 
    }

     //FP Search user for COA
    public function getSearchMembers(){
        try {

            $arr   = [];
            $data  = "";
            $msg   = "";            
            $code  = 0;

            $search =  Helper::trimAndTruncate(Input::get('search'),250);

            //$data = DB::select("call usp_SearchMembers ('".$search."')");   
             $data   = Abstracts::usp_get_authors($search,CustomClass::$FP,CustomClass::$CoAuthor,null,null,null); 
           
            if(empty($data))
            {
                $data = "";
                $code = 0;
                $msg  = "record not found";
            }
            else
            {                
                $code = 1;
                $msg  = "";
            }


        } catch (Exception $e) {
            Log::error('BOFPController - getSearchMembers'.$e->getMessage());
            $msg =AppMessage::$GENERAL_ERROR;

        }
        $arr = ['data' => $data, 'code' => $code, 'msg' => $msg];

         return Response::json($arr); 
    }

    //FP Get Chief Author only bo 
    public function getCADetails(){
        try {

            $arr   = [];
            $data  = "";
            $msg   = "";            
            $code  = 0;

            $ca_id  =  intval(Input::get('ca_id'));

            $data   = App::make('UserController')->getUserDetails($ca_id); 
           
            if(empty($data))
            {
                $data = "";
                $code = 0;                
            }
            else
            {                
                $code = 1;
                $msg  = "";
            }


        } catch (Exception $e) {
            Log::error('BOFPController - getCADetails '.$e->getMessage());
            $msg =AppMessage::$GENERAL_ERROR;

        }
        $arr = ['data' => $data, 'code' => $code, 'msg' => $msg];

         return Response::json($arr); 
    }



    //FP Get Presenting Author
    public function getPADetails(){
        try {

            $arr   = [];
            $data  = "";
            $msg   = "";            
            $code  = 0;

            $pa_id  =  intval(Input::get('pa_id'));

            $data   = App::make('UserController')->getUserDetails($pa_id); 
           
            if(empty($data))
            {
                $data = "";
                $code = 0;                
            }
            else
            {                
                $code = 1;
                $msg  = "";
            }


        } catch (Exception $e) {
            Log::error('BOFPController - getSearchMembersPA'.$e->getMessage());
            $msg =AppMessage::$GENERAL_ERROR;

        }
        $arr = ['data' => $data, 'code' => $code, 'msg' => $msg];

         return Response::json($arr); 
    }

    

    //FP Store
    public function store()
    {
        try {

            //for Response
            $arr = [];
            $code = 0;
            $msg = "";
            $data = "";
            
            $fp_id      = intval(Input::get('hdnId'));
            $pa_id      = intval(Input::get('hdnPAId'));
            $is_next    = intval(Input::get('hdnIsNext'));
            $step       = intval(Input::get("hdnStep"));


            //for first step only 
            $categories = array('' => '--select--') + Category::FP();        
            $pres_types = array('' => '--select--') + PresType::lists('type','presentation_type_id');
            
            $is_edit = true;

            $pres_auth_id = 0;

            if($fp_id >0)
                $fp = Abstracts::find($fp_id);         
            else
                $fp = new Abstracts(); 

            if($fp != null)
            {
                $result    = Abstracts::usp_get_abstracts(null,null,null,null,$fp_id,null,null,null,null,null,null,null);
                //$fp        = $result['abstracts'][0];
                $authors   = $result['authors'];
                    foreach ($authors as $key => $value) {
                        if($value->role_id==CustomClass::$ChiefAuthor)
                        {
                            $ca =$value;
                        }
                        if($value->role_id==CustomClass::$PresentingAuthor)
                        {
                            $pres_auth_id =$value->user_id;
                        }
                }   
            }

            if($is_next == 1)
            {
                if($step ==1)
                {   
                    $fp->abs_type               = CustomClass::$FP;                        
                    $fp->category_id            = Input::get('ddlSection');                    
                    //$fp->original_category_id   = Input::get('ddlSection');
                    $fp->presentation_type_id   = Input::get('ddlType');       
                    $fp->user_id                = Input::get('hdnCAId');
                    $fp->save();

                    //check and save chief instructor in author table 
                    $author = Authors::where('abs_id',$fp->abs_id)->where('role_id',CustomClass::$ChiefAuthor)->first();
                    if($author == null)
                    {
                        $author = new Authors();
                        $author->user_id = Input::get('hdnCAId');   
                        $author->abs_id  = $fp->abs_id;
                        $author->role_id = CustomClass::$ChiefAuthor;
                        $author->consent_status_id = CustomClass::$Selected;
                        $author->save();
                    }                    
                    
                    $code = 1;
                    $data = View::make($this->bo_path() . 'fp.step2')->with('fp',$fp)->render();     
                    
                }                 

                if($step ==2)
                {   
               
                    $fp->title      = Helper::trimAndTruncate(Input::get('txtTitle'),200);  
                    $fp->synopsis   = Helper::trimAndTruncate(Input::get('txtSynopsis'),3000);                                       
                    $fp->save();

                    $arr    = $this->get_FPCOA_Count($fp_id);                            

                    $code   = 1;
                    $data   = View::make($this->bo_path() .'fp.step3')->with('fp',$fp)
                                ->with('coas',$arr["coas"])
                                ->with('isMaxCount',$arr["isMaxCount"])->render();
                    
                }      
                if($step ==3)
                {   
                   
                    if($this->IsRatifiedMembers($fp))
                    {                         
                        $code   = 1;
                        $data   = View::make($this->bo_path() .'fp.step4')->with('fp',$fp)->render();     
                    }
                    else
                    {
                        $code   = 0;
                        $msg    = AppMessage::$FP_RATIFIED_MEMBER;    
                        $data   = "";
                    }                

               }     
               if($step ==4)
                {   
                   
                    $fp->is_in_india             = Input::get('rbtnIndia'); 
                    $fp->is_already_published    = Input::get('rbtnIsAlreadyPublished');   
                    $fp->lab_research            = Input::get('rbtnlab_research');   
                    if($fp->presentation_type_id == CustomClass::$Paper_or_EPoster || $fp->presentation_type_id == CustomClass::$EPoster_only)
                    {
                        $fp->is_consider_hp     = Input::get('rbtnIsConsiderhP');  
                    }
                    $fp->save();

                    $arr    = $this->get_FPCOA_Count($fp_id);                    
                    $pa         = Abstracts::usp_get_authors(null,CustomClass::$FP,CustomClass::$PresentingAuthor,$fp_id,null,null); 
                    if(isset($pa[0]))
                    {
                        $pa =  $pa[0];
                    }
                    $code   = 1;
                    $data   = View::make($this->bo_path() .'fp.step5')->with('fp',$fp)
                                ->with('coas',$arr["coas"])
                                ->with('pa',$pa)
                                ->with('categories',$categories)
                                ->with('pres_types',$pres_types)
                                ->with('ca',$ca)
                                ->with('isMaxCount',$arr["isMaxCount"])->render();                       
                }                
               if($step == 5)
               {

                   // $count = $this->get_FPPA_Count($pres_auth_id);
                   
                    // if($count >= CustomClass::$FP_Count)
                    // {
                    //     $code   = 0;
                    //     $msg    = AppMessage::$FP_PA_Count;    
                    //     $data   = "";
                    // }
                    // else
                    // {
                        if(!($fp->abs_no >0))
                        {
                            $is_edit                    = false;                        
                            $fp->submitted_at           = date('Y-m-d H:i:s');
                            $fp->status_id      = CustomClass::$Submitted;                        
                            $result =    Abstracts::usp_generate_abs_no(CustomClass::$FP,$fp->abs_id);
                            $fp->abs_no = $result[0]->abs_no;
                        }
                        
                        $fp->save();

                        //FP mail    
                        $user = App::make('UserController')->getUserDetails($fp->user_id);
                        $pa         = Abstracts::usp_get_authors(null,CustomClass::$FP,CustomClass::$PresentingAuthor,$fp->abs_id,null,null); 
                        if(isset($pa[0]))
                        {
                            $pa =  $pa[0];
                        }

                        $arr = $this->get_FPCOA_Count($fp_id);

                        //  if($is_edit)
                        // {
                        //     $this->fp_mail_data($user,$pa,$fp,$arr['coas'],$categories,$pres_types);       
                        // }
                        // else
                        // {
                        //     $this->fp_mail($user,$pa,$fp,$arr['coas'],$categories);
                        // }

                        $code = 1;
                        $data = View::make($this->bo_path() .'fp.success')->with('fp',$fp)->with('coas',$arr["coas"])->render();                    
                  // }
                }
            }
            else 
            {
                if($step == 2)
                {   
                    $code = 1;
                    $data = View::make($this->bo_path() .'fp.step1')
                                ->with('fp',$fp)
                                ->with('pres_auth_id',$pres_auth_id)
                                ->with('categories',$categories)
                                ->with('pres_types',$pres_types)
                                ->with('ca',$ca)->render();
                }   
                if($step == 3)
                {   
                    $code = 1;
                    $data = View::make($this->bo_path() .'fp.step2')
                                ->with('fp',$fp)->render();
                }   
                if($step == 4)
                {   
                    $arr    = $this->get_FPCOA_Count($fp_id);                   

                    $code   = 1;
                    $data   = View::make($this->bo_path() .'fp.step3')->with('fp',$fp)
                                ->with('coas',$arr["coas"])
                                ->with('isMaxCount',$arr["isMaxCount"])->render();
                }  
                if($step == 5)
                {   
                    $code   = 1;
                    $data   = View::make($this->bo_path() .'fp.step4')->with('fp',$fp)->render();    
                }                
            }
            
        } catch (Exception $e) {
            Log::error('BOFPController - store :'.$e->getMessage());          
            $msg =AppMessage::$GENERAL_ERROR;
        }

        $arr = ['data' => $data, 'code' => $code, 'msg' => $msg];
        return Response::json($arr); 
    }


    //CA Store
    public function storeCA()
    {
        try {

            //for Response
            $arr = [];
            $code = 0;
            $msg = "";
            $data = "";
            
            $fp_id         = intval(Input::get('fp_id'));
            $ca_user_id    = intval(Input::get('ca_user_id')); 


            $abs =  Abstracts::find($fp_id);
            $abs->user_id =  $ca_user_id;
            $abs->save();


            $caauthor = Authors::where('abs_id',$fp_id)->where('role_id',CustomClass::$ChiefAuthor)->first();
            if($caauthor == null)
            {
                //presenting author            
                $ca_author = new Authors();
                $ca_author->user_id = $ca_user_id;   
                $ca_author->abs_id  = $fp_id;
                $ca_author->role_id = CustomClass::$ChiefAuthor;
                $ca_author->consent_status_id = CustomClass::$Selected;
                //$pa_author->save();            
                //$code = 1;

                //use for validation
               // $count = $this->get_FPPA_Count($pa_user_id);
                
                // if($count >= CustomClass::$FP_Count)
                // {
                //     $code = 0;
                //     $msg  = AppMessage::$FP_PA_Count;
                // }             
                // else 
                // {
                    $code = 1;
                    $ca_author->save();
                //}
            }
            else
            {
                 $code = 1; 
            }
            
        } catch (Exception $e) {
            Log::error('BOFPController - storeCA :'.$e->getMessage());          
            $msg =AppMessage::$GENERAL_ERROR;
        }

        $arr = ['data' => $data, 'code' => $code, 'msg' => $msg];
        return Response::json($arr);
    }

    //PA Store
    public function storePA()
    {
        try {

            //for Response
            $arr = [];
            $code = 0;
            $msg = "";
            $data = "";
            
            $fp_id         = intval(Input::get('fp_id'));
            $pa_user_id    = intval(Input::get('pa_user_id')); 

            $paauthor = Authors::where('abs_id',$fp_id)->where('role_id',CustomClass::$PresentingAuthor)->first();
            if($paauthor == null)
            {
                //presenting author            
                $pa_author = new Authors();
                $pa_author->user_id = $pa_user_id;   
                $pa_author->abs_id  = $fp_id;
                $pa_author->role_id = CustomClass::$PresentingAuthor;
                $pa_author->consent_status_id = CustomClass::$Selected;
                //$pa_author->save();            
                //$code = 1;

                //use for validation
                $count = $this->get_FPPA_Count($pa_user_id);
                
                // if($count >= CustomClass::$FP_Count)
                // {
                //     $code = 0;
                //     $msg  = AppMessage::$FP_PA_Count;
                // }             
                // else 
                // {
                    $code = 1;
                    $pa_author->save();
                //}
            }
            else
            {
                 $code = 1; 
            }
            
        } catch (Exception $e) {
            Log::error('BOFPController - storePA :'.$e->getMessage());          
            $msg =AppMessage::$GENERAL_ERROR;
        }

        $arr = ['data' => $data, 'code' => $code, 'msg' => $msg];
        return Response::json($arr);
    }

    //COA Store
    public function storeCOA()
    {
        try {

            //for Response
            $arr = [];
            $code = 0;
            $msg = "";
            $data = "";
            
            $fp_id          = intval(Input::get('fp_id'));
            $coa_user_id    = intval(Input::get('coa_user_id')); 


            $coa = new Authors();
            $coa->role_id       =     CustomClass::$CoAuthor;
            $coa->abs_id        =     $fp_id;
            $coa->user_id       =     $coa_user_id;   
            $coa->consent_status_id = CustomClass::$Selected;                     
            $coa->is_present    =     1;

            $fp = Abstracts::find($fp_id);   

            //use for validation
            $arr = $this->get_FPCOA_Count($fp_id,$coa_user_id);

            if($arr["isDuplicate"])
            {
                $code = 0;
                $msg  = AppMessage::$FP_COA_Duplicate;
            }
            else if($arr["isMaxCount"])
            {
                $code = 0;
                $msg  = AppMessage::$FP_COA_Count;
            }             
            else 
            {
                $code = 1;
                $coa->save();
            }
           

            //use for get coi list
            $arr = $this->get_FPCOA_Count($fp_id);
            
            $data = View::make($this->bo_path() .'fp.step3')
                                ->with('fp',$fp)
                                ->with('coas',$arr["coas"])
                                ->with('isMaxCount',$arr["isMaxCount"])->render();
            
        } catch (Exception $e) {
            Log::error('BOFPController - storeCOA :'.$e->getMessage());          
            $msg =AppMessage::$GENERAL_ERROR;
        }

        $arr = ['data' => $data, 'code' => $code, 'msg' => $msg];
        return Response::json($arr);
    }


    //FP Get Max FPNo Plus  one
    public function GetMaxFPNoPlusOne()
    {
         $fpno = FP::max('fp_no');
         return (intval($fpno) + 1); 
    }

    //CA Remove
    public function removeCA()
    {
        try {

            //for Response
            $arr    = [];
            $code   = 0;
            $msg    = "";
            $data   = "";

            $fp_id = intval(Input::get('fp_id'));
            $ca_id = intval(Input::get('ca_id'));
            
            $ca =  Authors::where('abs_id',$fp_id)->where('user_id',$ca_id)->where('role_id',CustomClass::$ChiefAuthor)->first();

            $ca->delete();
            $code = 1;            
                        
        } catch (Exception $e) {
            Log::error('BOFPController - removeCA :'.$e->getMessage());          
            $msg =AppMessage::$GENERAL_ERROR;            
        }

        $arr = ['data' => $data, 'code' => $code, 'msg' => $msg];
        return Response::json($arr); 

    }


    //PA Remove
    public function removePA()
    {
        try {

            //for Response
            $arr    = [];
            $code   = 0;
            $msg    = "";
            $data   = "";

            $fp_id = intval(Input::get('fp_id'));
            $pa_id = intval(Input::get('pa_id'));
            
            $pa =  Authors::where('abs_id',$fp_id)->where('user_id',$pa_id)->where('role_id',CustomClass::$PresentingAuthor)->first();

            $pa->delete();
            $code = 1;            

            // $fp = Abstracts::find($fp_id);         

            // $arr = $this->get_FPCOA_Count($fp_id);

            // $code = 1;
            // $data = View::make('fp.step3')
            //                     ->with('fp',$fp)
            //                     ->with('coas',$arr["coas"])
            //                     ->with('isMaxCount',$arr["isMaxCount"])->render();
            
            
        } catch (Exception $e) {
            Log::error('BOFPController - removeCOA :'.$e->getMessage());          
            $msg =AppMessage::$GENERAL_ERROR;            
        }

        $arr = ['data' => $data, 'code' => $code, 'msg' => $msg];
        return Response::json($arr); 

    }


    //COA Remove
    public function removeCOA()
    {
        try {

            //for Response
            $arr    = [];
            $code   = 0;
            $msg    = "";
            $data   = "";

            $fp_id = intval(Input::get('fp_id'));
            $coa_id = intval(Input::get('coa_id'));
            
            $coa =  Authors::find($coa_id);

            $coa->delete();
            
            $fp = Abstracts::find($fp_id);         

            $arr = $this->get_FPCOA_Count($fp_id);

            $code = 1;
            $data = View::make($this->bo_path(). 'fp.step3')
                                ->with('fp',$fp)
                                ->with('coas',$arr["coas"])
                                ->with('isMaxCount',$arr["isMaxCount"])->render();
            
            
        } catch (Exception $e) {
            Log::error('BOFPController - removeCOA :'.$e->getMessage());          
            $msg =AppMessage::$GENERAL_ERROR;
        }

        $arr = ['data' => $data, 'code' => $code, 'msg' => $msg];
        return Response::json($arr); 

    }

    
    //Get PA Count for validation 
    public function get_FPPA_Count($pa_uid)
    {           

        try {
                $isMaxCount     = false;

                $users   = null;
                $users   = Abstracts::usp_get_abstracts(null,null,null,null,null,null,null,$pa_uid,null,null,null,null); 
                $pa_count  = 0;
                foreach ($users["engaged"] as $key => $value) {
                    if($value->abs_type==CustomClass::$FP && $value->role_id==CustomClass::$PresentingAuthor && $value->status_id == CustomClass::$Submitted)
                    {
                        $pa_count++;
                    }
                }

        } catch (Exception $e) {
            Log::error('FPController - get_FPCOA_Count :'.$e->getMessage());    
        }
                     
        return $pa_count;
    }


    //Get COA and COA Count for validation 
    public function get_FPCOA_Count($fp_id,$coa_uid = null)
    {           

        try {
                $isMaxCount     = false;
                $isDuplicate    = false; 

                //ToDo: call sp from new version 
                //$coas           = DB::select('call usp_getCOAByFPId('.$fp_id.')');                            
                $coas = null;
                $coas   = Abstracts::usp_get_authors(null,CustomClass::$FP,CustomClass::$CoAuthor,$fp_id,null,null); 

                $coa_uids       = [];                

                if(isset($coas) &&  count($coas) >0)
                {
                    foreach ($coas as $key => $value) {  
                        if($coa_uid == $value->user_id)              
                        {
                            $isDuplicate =true;
                        }
                        
                        array_push($coa_uids, $value->user_id);    
                    }    
                }
                else
                {
                    $coas = [];                
                }

                if(count(array_unique($coa_uids)) >=  CustomClass::$FP_COA_Count)
                {
                  $isMaxCount = true;
                }    
        } catch (Exception $e) {
            Log::error('BOFPController - get_FPCOA_Count :'.$e->getMessage());    
        }
                     

            return ["isMaxCount" => $isMaxCount,"isDuplicate" => $isDuplicate ,"coas" => $coas];

    }

    //RATIFIED MEMBER Check for fp
    public function IsRatifiedMembers($fp)
    {
        $isretified = false;

        $ca  = App::make('UserController')->getUserDetails($fp->user_id);

        if($ca->user_type_id==CustomClass::$Ratified_Member)
        {
            $isretified = true;             
        }        

        // $pa  = App::make('UserController')->getUserDetails($fp->pres_auth_id); 
        // if(!empty($pa->membership_no))
        // {
        //     $isretified = true; 
        // }            

            $pa         = Abstracts::usp_get_authors(null,CustomClass::$FP,CustomClass::$PresentingAuthor,$fp->abs_id,null,null); 
            if(isset($pa[0]))
            {
                $pa =  $pa[0];
                if($pa->user_type_id==CustomClass::$Ratified_Member)
                {
                    $isretified = true;                     
                }            
            }


        $arr = $this->get_FPCOA_Count($fp->abs_id);
      //  var_dump($arr['coas']);
        foreach ($arr['coas'] as $key => $value) {
            if($value->user_type_id==CustomClass::$Ratified_Member)
            {
                $isretified = true;                 
            }
        }



        return $isretified;

    }


    //FP Mail Send add cc COA
    public function fp_mail($user,$pa,$fp,$coa,$categories)
    {
        if(empty($user->email))
        {
            return;
        }
        if(CustomClass::$IsEmailEnabled)
        {
             $isMailSend  =  Mail::send('emails.fp.chiefauthor', array('user' => $user,'fp' =>$fp,'coa' =>$coa,'pa'=>$pa,'categories'=>$categories), function($message) use ($coa,$fp,$user,$pa)
                                {       
                                    $message->subject(sprintf(Subject::$fp_ca,$fp->abs_no)); 
                                    if(CustomClass::$IsEmailTest)
                                    {
                                        $message->to(CustomClass::$TestMailId);   
                                    }
                                    else
                                    {

                                        $message->to($user->email, $user->first_name);                                             
                                        if(isset($coa) && count($coa)>0)                        
                                        {
                                            foreach ($coa as $value) {           
                                                if(!empty($value->email))                                     
                                                    $message->cc($value->email,$value->name);
                                            }    
                                        }                                    
                                        if(isset($pa) && !empty($pa))
                                        {
                                            if(!empty($pa->email))
                                                $message->cc($pa->email,$pa->name);
                                        }
                                        $message->cc(CustomClass::$BackupId);
                                    }
                                });  
        }
    }


    //FP Mail Send add cc COA
    public function fp_mail_data($user,$pa,$fp,$coa,$categories,$pres_types)
    {
        if(empty($user->email))
        {
            return;
        }
        if(CustomClass::$IsEmailEnabled)
        {
             $isMailSend  =  Mail::send('emails.fp.chiefauthor_data', array('user' => $user,'fp' =>$fp,'pa'=>$pa,'coas' =>$coa,'categories' => $categories ,'pres_types' =>$pres_types), function($message) use ($coa,$fp,$user,$pa)
                                {   

                                    $message->subject(sprintf(Subject::$fp_ca,$fp->abs_no)); 
                                    if(CustomClass::$IsEmailTest)
                                    {
                                        $message->to(CustomClass::$TestMailId);   
                                    }                          
                                    else
                                    {
                                        $message->to($user->email, $user->first_name);                                                                                 
                                        if(isset($coa) && count($coa)>0)                        
                                        {                                            
                                            foreach ($coa as $value) {
                                                if(!empty($value->email))
                                                    $message->cc($value->email,$value->name);
                                            }    
                                        }                                    
                                        if(isset($pa) && !empty($pa))
                                        {
                                            if(!empty($pa->email))
                                                $message->cc($pa->email,$pa->name);
                                        }
                                        $message->cc(CustomClass::$BackupId);
                                    }                                
                                    

                                });  
        }
    }



    //PA Awards 
    public function getPAAwards()
    {
        try {

            //for Response
            $arr    = [];
            $code   = 0;
            $msg    = "";
            $data   = "";

            $pa_id      = intval(Input::get('pa_id'));
            $cat_id     = intval(Input::get('cat_id'));
            $abs_type    = Input::get('abs_type');
            


            $awards     = Awards::usp_get_awards($pa_id,$cat_id,$abs_type);            


            //$awards     = DB::select('call usp_get_pa_awards('.$pa_id.','.$cat_id.','.$type_id.')'); 
            $str        = "";
            $isAwa      = false;
            if (Count($awards) > 0)
                {
                    $str = "<b>Please note :</b>  The presenting author you have chosen is already a winner of <br />";

                    foreach ($awards as $key => $value)
                    {
                        $flag = false;
                        if ($value->abs_type == "FP")
                        {                           
                            
                            if ($value->category_id == $cat_id)
                            {
                                $flag = true;
                            }
                        }
                        else
                        {
                            $flag = true;
                        }
                        if ($flag)
                        {
                            $isAwa = true;
                            $str .= "\"" . $value->award_name . "\" - ".CustomClass::$ConferenceInitial. " " . $value->year . ".<br />";
                        }

                    }

                    if ($isAwa)
                    {
                        $str .= "Hence your submission would not be eligible to contest for the above award(s)";
                        $str .= "<br /><br />You may either change the presenting author or click \"NEXT\" to proceed further with the selected presenting author.";
                        $msg = $str;
                        $code = 1;
                    }
                    else
                    {
                        $code = 0;
                        $msg  = "";
                    }
                }
                else
                {
                    $code = 0;
                    $msg  = "";
                }
            
            
        } catch (Exception $e) {
            Log::error('BOFPController - getPAAwards :'.$e->getMessage());          
            $msg =AppMessage::$GENERAL_ERROR;
            $code=0;
        }

        $arr = ['data' => $data, 'code' => $code, 'msg' => $msg];
        return Response::json($arr); 

    }

}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists