public function  CUST_customercalendercreation($fileDoc,$calPrimary,$custid,$startdate,$startdate_starttime,$startdate_endtime,$enddate,$enddate_starttime,$enddate_endtime,$firstname,$lastname,$mobile,$intmobile,$office,$customermailid,$unit,$roomtype,$unitrmtype)
 {
     try{
         $this->load->model('EILIB/Mdl_eilib_common_function');
         $attachments=[];
         for($j=0;$j<count($fileDoc)&&count($fileDoc)>0;$j++){
             $servicedoc= $this->Mdl_eilib_common_function->get_service_document();
             $file = $servicedoc->files->get($fileDoc[$j]);
             $attachments[]= array(
                 'fileUrl' => $file->alternateLink,
                 'mimeType' => $file->mimeType,
                 'title' => $file->title
             );}
         $calId=$this->GetEICalendarId();
         $initialsdate=$startdate;
         $initialedate=$enddate;
         $calendername= $firstname.' '.$lastname;
         $contactno="";
         $contactaddr="";
         if($mobile!=null)
         {$contactno=$mobile;}
         else if($intmobile!=null)
         {$contactno=$intmobile;}
         else if($office!=null)
         {$contactno=$office;}
         if($contactno!=null && $contactno!="")
         {
             $contactaddr=$custid." "."EMAIL :".$customermailid.",CONTACT NO :".$contactno;
         }
         else
         {
             $contactaddr=$custid." "."EMAIL :".$customermailid;
         }
         if($unitrmtype!="")
         {
             $details =$unit. " " . $calendername . " " .$unitrmtype." ". "CHECKIN";
         }
         else
         {
             $details =$unit. " " . $calendername . " " . "CHECKIN";
         }
         $details1 =$unit. " " .$roomtype ;
         if($initialsdate!="")
         {
             $event = new Google_Service_Calendar_Event();
             $startevents=$this->CalenderTime_Convertion($startdate, $startdate_starttime, $startdate_endtime);
             $event->setStart($startevents[0]);
             $event->setEnd($startevents[1]);
             $event->setDescription($contactaddr);
             $event->setLocation($details1);
             $event->setSummary($details);
             if(count($fileDoc)>0) {
                 $event->setAttachments($attachments);
                 $createdEvent = $calPrimary->events->insert($calId, $event, array('supportsAttachments' => TRUE));  // to create a event
             }else{
                 $createdEvent = $calPrimary->events->insert($calId, $event);
             }}
         $endevents=$this->CalenderTime_Convertion($enddate,$enddate_starttime,$enddate_endtime);
         $detailsend =$unit. " " . $calendername . " " . "CHECKOUT";
         $detailsend1 =$unit. " " .$roomtype ;
         if($initialedate!="")
         {
             $event = new Google_Service_Calendar_Event();
             $event->setStart($endevents[0]);
             $event->setEnd($endevents[1]);
             $event->setDescription($contactaddr);
             $event->setLocation($detailsend1);
             $event->setSummary($detailsend);
             if(count($fileDoc)>0) {
                 $event->setAttachments($attachments);
                 $createdEvent = $calPrimary->events->insert($calId, $event,array('supportsAttachments' => TRUE)); // to create a event
             }else{
                 $createdEvent = $calPrimary->events->insert($calId, $event);
             }
         }
         return 1;
     }
     catch(Exception $e){
         return $e->getMessage();
     }
 }
 public function  CUST_customercalendercreation_StartDate($servicedoc,$calId,$calPrimary,$calevents,$custid,$firstname,$lastname,$mobile,$intmobile,$office,$customermailid,$unit,$unitrmtype)
 {
     try{
         $folderIdCustomer=$this->Mdl_eilib_calender->getcustomerfileid($servicedoc,$custid);
         for($k=0;$k<count($calevents);$k++)
         {
             $attachments=[];
             $Events=explode(',',$calevents[$k]);
             if($Events[5]=="CHECKIN"){
                 for($j=0;$j<count($folderIdCustomer)&&count($folderIdCustomer)>0;$j++){
                     $servicedoc= $this->Mdl_eilib_common_function->get_service_document();
                     $file = $servicedoc->files->get($folderIdCustomer[$j]);
                     $attachments[]= array(
                         'fileUrl' => $file->alternateLink,
                         'mimeType' => $file->mimeType,
                         'title' => $file->title
                     );}}
             $initialsdate = $Events[2];
             $calendername = $firstname . ' ' . $lastname;
             $contactno = "";
             $contactaddr = "";
             if ($mobile != null) {
                 $contactno = $mobile;
             } else if ($intmobile != null) {
                 $contactno = $intmobile;
             } else if ($office != null) {
                 $contactno = $office;
             }
             if ($contactno != null && $contactno != "") {
                 $contactaddr = $custid . " " . "EMAIL :" . $customermailid . ",CONTACT NO :" . $contactno;
             } else {
                 $contactaddr = $custid . " " . "EMAIL :" . $customermailid;
             }
             if ($Events[1] != "") {
                 $details = $Events[0] . " " . $calendername . " " . $Events[1] . " " . $Events[5];
             } else {
                 $details = $Events[0] . " " . $calendername . " " . $Events[5];
             }
             $details1 = $Events[0] . " " . $Events[1];
             if ($initialsdate != "") {
                 $event = new Google_Service_Calendar_Event();
                 $startevents = $this->CalenderTime_Convertion($Events[2], $Events[3], $Events[4]);
                 $event->setStart($startevents[0]);
                 $event->setEnd($startevents[1]);
                 $event->setDescription($contactaddr);
                 $event->setLocation($details1);
                 $event->setSummary($details);
                 if(count($folderIdCustomer)>0 && $Events[5]=="CHECKIN") {
                     $event->setAttachments($attachments);
                     $createdEvent = $calPrimary->events->insert($calId, $event,array('supportsAttachments' => TRUE)); // to create a event
                 }else{
                     $createdEvent = $calPrimary->events->insert($calId, $event);
                 }
             }
         }
         return 1;
     }
     catch(Exception $e){
         return $e->getMessage();
     }
 }