%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/pjc/app/Http/Controllers/
Upload File :
Create Path :
Current File : /var/www/pjc/app/Http/Controllers/HomeController.php

<?php
use Illuminate\Support\Facades\Response;
namespace App\Http\Controllers;
use DB;
use App\Http\Controllers\Controller;
use App\Http\Middleware\Cors;
use App\Models\User;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Input;
use Illuminate\Http\Request;
use App\Exports\UsersExport;
use Maatwebsite\Excel\Facades\Excel;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\File;
use App\Exports\Exportc;
use Carbon\Carbon;
class HomeController extends Controller {

	/*
	|--------------------------------------------------------------------------
	| Default Home Controller
	|--------------------------------------------------------------------------
	|
	| You may wish to use controllers instead of, or in addition to, Closure
	| based routes. That's great! Here is an example controller method to
	| get you started. To route to this controller, just add the route:
	|
	|	Route::get('/', 'HomeController@showWelcome');
	|
	*/

  

	public function showWelcome()
	{
		return view('hello');
	}

        public function checkFail()
        {
            $accountFail = DB::table('accounts_cstm')
                    ->select('id_c')
                    ->where('stato_c',3)

                    ->get();

            foreach($accountFail as $item)
            {
                $rowScadenze = DB::table('tsi_scadenziario_accounts_c')
                        ->select('id_c','cliente_c')
                        ->join('tsi_scadenziario_cstm','id_c','=','tsi_scadenziario_accountstsi_scadenziario_idb')
                        ->where('tsi_scadenziario_accountsaccounts_ida',$item->id_c)
                        ->get();



                foreach($rowScadenze as $value)
                {
                    DB::table('tsi_scadenziario_cstm')
                            ->where('id_c',$value->id_c)
                            ->update(['statocliente_c' => 3]);
                    $ok[]=$value->id_c;
                }


            }

            $accountFail = DB::table('accounts_cstm')
                    ->select('id_c')
                    ->where('stato_c',2)

                    ->get();

            foreach($accountFail as $item)
            {
                $rowScadenze = DB::table('tsi_scadenziario_accounts_c')
                        ->select('id_c','cliente_c')
                        ->join('tsi_scadenziario_cstm','id_c','=','tsi_scadenziario_accountstsi_scadenziario_idb')
                        ->where('tsi_scadenziario_accountsaccounts_ida',$item->id_c)
                        ->get();



                foreach($rowScadenze as $value)
                {
                    DB::table('tsi_scadenziario_cstm')
                            ->where('id_c',$value->id_c)
                            ->update(['statocliente_c' => 2]);



                    $ok[]=$value->id_c;
                }


            }

              $accountFail = DB::table('accounts_cstm')
                    ->select('id_c')
                    ->where('stato_c',1)

                    ->get();

            foreach($accountFail as $item)
            {
                $rowScadenze = DB::table('tsi_scadenziario_accounts_c')
                        ->select('id_c','cliente_c')
                        ->join('tsi_scadenziario_cstm','id_c','=','tsi_scadenziario_accountstsi_scadenziario_idb')
                        ->where('tsi_scadenziario_accountsaccounts_ida',$item->id_c)
                        ->get();



                foreach($rowScadenze as $value)
                {
                    DB::table('tsi_scadenziario_cstm')
                            ->where('id_c',$value->id_c)
                            ->update(['statocliente_c' => 1]);

                    $ok[]=$value->id_c;
                }


            }

            return "righe modificate: ".count($ok)."\n";

        }



        public function exportScadenziario(Request $request)
        {

            if ($request->post())
            {

                if($request->inizio)
                {

                    return Excel::download(new UsersExport($request->inizio,$request->fine,$request->cliente), 'scadenziario.xlsx');
                }
                else
                {
                    return Excel::download(new UsersExport('0','0',$request->cliente), 'scadenziario.xlsx');
                }

            }
            else {
                $scad = \App\Scadenziario::select('cliente','idCliente')->distinct()->get();

                return view('export')->withScad($scad);
            }
        }

        public function reportCorsi()
        {
              
            //$directory =  Storage::Directories('public/learn/');

          
            $directory = Storage::disk('big')->directories('/');
           
            
       
            foreach ($directory as $item)
            {
    

                if( ( $item != "static") || ("learn"))
                {
                   
                 
                $subDirectory =  Storage::disk('big')->Directories($item);
                
               
                $dati = explode('/',$subDirectory[0]);
             

                $prova = Storage::disk('big')->files($subDirectory[0]);
            

             

             
              if(isset($prova[0]))
              {
                $time = Storage::disk('big')->lastModified($prova[0]);
          
               
                $dataFile = date('d/m/Y', $time);
      

               
               
                $file = json_decode(file_get_contents(storage_path()."/bigblue/".$prova[0]), true);

               
            

                $session = $item;
                $token = explode('/',$subDirectory[0])[1];

                //$session = $dati[2];
                //$token = $dati[3];
                $link = "https://virtualclass.tsisrl.net/learning-analytics-dashboard/?meeting=".$session."&report=".$token;
               
            
                
           
                $datiCorso[]=["data" => $dataFile, "link" => $link, "corso" => $file['name'], "session" => $session, "token" => $token];
              }
               
                }

           
            }

            return view('corsi')->withData($datiCorso);
        }

        public function getExtid($id)
        {
            $directory =  Storage::Directories('public/learn/'.$id);
           
           

            $prova = Storage::files($directory[0]);
            $file = json_decode(file_get_contents(storage_path()."/app/".$prova[0]), true);
            return $file['extId'];

        }

        public function exportCorsi($id,$token)
        {

       

      $file = json_decode(file_get_contents(storage_path()."/app/public/learn/learning-dashboard/".$id."/".$token."/learning_dashboard_data.json"), true);

   
      //$files = Storage::files("/app/public/learn/".$id."/".$token."/learning_dashboard_data.json");
      //return $files;
      //$time = Storage::lastModified($files);

     

      //$dataFile = date('d/m/Y', $time);
                
                //return dd($file);

      $subDirectory =  Storage::Directories("public/learn/".$id."/");
      $files = Storage::files($subDirectory[0]);
      $time = Storage::lastModified($files[0]);
    
      $dataFile = date('d/m/Y', $time);


      $endpoint = "https://www.tsisrlformazione.it/getcourse.php?id=".explode('-',$file['extId'])[0];
      
         
      $client = new \GuzzleHttp\Client();
      
      $response = $client->request('GET', $endpoint);
      
      
      
      $id = $response->getBody();




      $nomeCorso = $file['name'];

      foreach($file['users'] as $item)
      {
        $nome = $item['name'];
        foreach($item['intIds'] as $entrate)

        


        $dataP[]=[$nome,Carbon::createFromTimestamp(substr($entrate['registeredOn'],0, 10))->setTimezone('Europe/Rome')->toTimeString(), Carbon::createFromTimestamp(substr($entrate['leftOn'],0, 10))->setTimezone('Europe/Rome')->toTimeString(), $item['totalOfMessages'],$item['isModerator']];
        $nome = $nomeCorso;
        $dataTime = $dataFile;
      }


            return view('corsipdf')->withData($dataP)->withNome($nome)->withTime($dataFile)->withCodice($id);

            $export = new Exportc($dataP);
        
            //return Excel::download($export, $id.'.xlsx');

            return Excel::create( $id.'.xlsx', function($excel) {

                $excel->sheet('Corsi Export', function($sheet) {
            
                    $sheet->fromArray($export
                    );
            
                });
            
            })->export('xls');
        }

}

Zerion Mini Shell 1.0