if(count($file_array)==0){
                    $file_flag=0;
                    $cal_flag=0;
                    URSRC_unshare_document($loggin,$fileId);
                    $con->rollback();

                }
            }

            if($ss_flag==0){

                $con->rollback();

            }
            if($cal_flag==0){
                URSRC_unshare_document($loggin,$fileId);
                for($i=0;$i<count($file_array);$i++){
                    delete_file($service,$file_array[$i]);
                }
                $con->rollback();
            }
//            echo $flag.$ss_flag.$cal_flag.$fileId.$file_flag.$folderid;
            if(($ss_flag==1)&&($cal_flag==1)){
                $email_body;
                $body_msg =explode("^", $body);
                $length=count($body_msg);
                for($i=0;$i<$length;$i++){
                    $email_body.=$body_msg[$i].'<br><br>';
                }
                $replace= array("[LOGINID]", "[LINK]","[SSLINK]", "[VLINK]","[DES]");
                $str_replaced  = array($URSRC_firstname,$site_link, $ss_link, $youtubelink,'<b>'.$URSRC_designation.'</b>');
             $authUrl = $drive->createAuthUrl();
             $access_token = $drive->getAccessToken();
             $refresh_token = $Refresh_Token;
             $drive->refreshToken($refresh_token);
             $service = new Google_Service_Drive($drive);
             $file_id_value = insertFile($service, $ufilename, 'PersonalDetails', $new_empfolderid, $ufiletype, $ufiletempname);
             if ($file_id_value != '') {
                 array_push($file_array, $file_id_value);
             }
         }
     }
 }
 if ($upload_flag == 1 && count($file_array) == 0) {
     $file_flag = 0;
     URSRC_unshare_document($loginid, $fileId);
     URSRC_unshare_document($loginid, $codeopti_fileId);
     $con->rollback();
     $login_empid = getEmpfolderName($loginid);
     renamefile($service, $login_empid, $new_empfolderid);
 }
 //UPDATE PART SENDING MAIL
 $select_template = "SELECT * FROM EMAIL_TEMPLATE_DETAILS WHERE ET_ID=16";
 $select_template_rs = mysqli_query($con, $select_template);
 if ($row = mysqli_fetch_array($select_template_rs)) {
     $mail_subject1 = $row["ETD_EMAIL_SUBJECT"];
     $body = $row["ETD_EMAIL_BODY"];
 }
 $select_template = "SELECT URC_DATA FROM USER_RIGHTS_CONFIGURATION WHERE URC_ID=26";
 $select_template_rs = mysqli_query($con, $select_template);
 if ($row = mysqli_fetch_array($select_template_rs)) {
     $mail_display1 = $row["URC_DATA"];