<?php

namespace App\Controllers;

use App\Models\Md_student;
use App\Models\Md_sms;
use App\Models\Md_cms;
$session = \Config\Services::session();

class Cron extends BaseController
{
    
    
    public function __construct() {
         $this->Md_login = new Md_student();
         $this->Md_sms= new Md_sms();
         $this->Md_cms= new Md_cms();
    }
  

public function DraftStudentDelete() 
 {
     return true;
     
    $paymentHistory=$this->Md_login->GetAllDraft();
    
    // echo '<pre>';
    // print_r($paymentHistory);
    // die;
  
     if(!empty($paymentHistory))
      {
          foreach ($paymentHistory as $rows) {
  
            $dir_path  = '../../../home/mvpmo60o/public_html/hostel/upload/'.$rows['pk_id'];
            $del_path  = './../../../home/mvpmo60o/public_html/hostel/upload/'.$rows['pk_id'].'/';
    
              if(is_dir($dir_path))
              {
                   delete_files($del_path, true);
                   rmdir($del_path);
                   return true;
              }
      
  /*
            $dir_path='../public_html/hostel/upload/'.$rows['pk_id'].'/';     
                 
            return rmdir($dir_path);
              if(is_dir($dir_path))
              {
               echo "exist";   
              }else {
                  echo "not";
              }
                echo '<pre>';
            print_r($dir_path);
            die;
            if(!empty($rows['pk_id']))
               {
                @rmdir($folderlink);
               }
  echo '<pre>';
    print_r($folderlink);
    die;
    */
            //   if(!empty($rows['CurrentYEarCollegeAdmissionReceipt']))
            //   {
            //     unlink('https://www.mvpm.org/hostel/upload'.$rows['CurrentYEarCollegeAdmissionReceipt']);
            //   }
               
            //   if(!empty($rows['OtherTwo']))
            //   {
            //     unlink('https://www.mvpm.org/hostel/upload'.$rows['OtherTwo']);
            //   }
               
            //   if(!empty($rows['LastExamMarkSheetPhoto']))
            //   {
            //     unlink('https://www.mvpm.org/hostel/upload'.$rows['LastExamMarkSheetPhoto']);
            //   }
               
            //   if(!empty($rows['AdharCardPhoto']))
            //   {
            //     unlink('https://www.mvpm.org/hostel/upload'.$rows['AdharCardPhoto']);
            //   }
               
            //     if(!empty($rows['PassportColorPhoto']))
            //   {
            //     unlink('https://www.mvpm.org/hostel/upload'.$rows['PassportColorPhoto']);
            //   }
                
               
                $this->Md_login->DeleteAllDraft($rows['pk_id']);

          }
            
            $final = array('status' => 1, 'msg'=>"Draft record deleted.");
        } else {
            $final = array('status' => 2,'msg'=>"No new draft data found");
        }
    $final = array('status' => 1, 'msg'=>"Draft record deleted.");
        echo json_encode($final);
        exit();
    }
}