Allineamento devel con Master
This commit is contained in:
@@ -5,10 +5,76 @@ namespace App\Http\Controllers;
|
||||
use App\Models\anagrafica;
|
||||
use App\Models\contatto;
|
||||
use Illuminate\Http\Request;
|
||||
use Google\Client;
|
||||
Use Google\Service\PeopleService;
|
||||
|
||||
class AnagraficaController extends Controller
|
||||
{
|
||||
//
|
||||
// GOOGLE CONTACTS PART
|
||||
|
||||
// private $google_client;
|
||||
|
||||
/* public function getToken()
|
||||
{
|
||||
$client = new Client();
|
||||
$client->setApplicationName('gestionale.lavorain.cloud');
|
||||
if(!is_null($client->getAccessToken())){}
|
||||
elseif(!is_null(session('access_token'))) // is_null(Session::get('access_token', null))
|
||||
{
|
||||
$client->setAccessToken(session('access_token'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$scope = array();
|
||||
$scope[] = 'https://www.googleapis.com/auth/contacts';
|
||||
// $client->
|
||||
putenv('GOOGLE_APPLICATION_CREDENTIALS='.storage_path('app/google-calendar/service_key.json')); //this can be created with other ENV mode server side
|
||||
$client->useApplicationDefaultCredentials();
|
||||
$token = $client->getAccessToken();
|
||||
session(['access_token' => $token]);
|
||||
}
|
||||
return $client;
|
||||
}*/
|
||||
|
||||
public function getGoogleContacts()
|
||||
{
|
||||
$client = $this->getToken();
|
||||
$service = new PeopleService($client);
|
||||
$profile = $service->people_connections->listPeopleConnections('people/me', array('personFields' => 'names,emailAddresses,phoneNumbers'));
|
||||
}
|
||||
public function getToken()
|
||||
{
|
||||
$configJson =storage_path('app/google-calendar/service_key.json');
|
||||
// $configJson =storage_path('app/google-calendar/people.json');
|
||||
// define an application name
|
||||
$applicationName = 'gestionale-di-famiglia';
|
||||
|
||||
// create the client
|
||||
$client = new \Google_Client();
|
||||
$client->setApplicationName($applicationName);
|
||||
$client->setAuthConfig($configJson);
|
||||
$client->setAccessType('offline'); // necessary for getting the refresh token
|
||||
$client->setApprovalPrompt ('force'); // necessary for getting the refresh token
|
||||
// scopes determine what google endpoints we can access. keep it simple for now.
|
||||
|
||||
$client->setScopes(
|
||||
[
|
||||
/*
|
||||
\Google\Service\Oauth2::USERINFO_PROFILE,
|
||||
\Google\Service\Oauth2::USERINFO_EMAIL,
|
||||
\Google\Service\Oauth2::OPENID,
|
||||
*/
|
||||
\Google\Service\PeopleService::CONTACTS // allows reading of google drive metadata
|
||||
]
|
||||
);
|
||||
$client->setIncludeGrantedScopes(true);
|
||||
|
||||
return $client;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function newContact()
|
||||
{
|
||||
return view('anagrafica.form');
|
||||
|
||||
@@ -39,7 +39,7 @@ class CategorieController extends Controller
|
||||
|
||||
public function apiList()
|
||||
{
|
||||
$categorie=Categorie::list();
|
||||
$categorie=Categorie::listCategorieAPI();
|
||||
return json_encode($categorie);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,62 @@ namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Contratti;
|
||||
use App\Models\GenDoc;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ContrattiController extends Controller
|
||||
{
|
||||
//
|
||||
public function contratti()
|
||||
{
|
||||
return view('contratti.lista',['data'=>Contratti::all()]);
|
||||
return view('contratti.lista',['data'=>Contratti::getAllContratto()]);
|
||||
}
|
||||
|
||||
public function newContratto(Request $request)
|
||||
{
|
||||
// Contratti::storeContratto($request);
|
||||
//dd($request);
|
||||
if (isset($request['filename'])) {
|
||||
$filename = $request->file('filename')->store('Contratti');
|
||||
}else{
|
||||
$filename=null;
|
||||
}
|
||||
Contratti::create([
|
||||
'numero'=>$request['numero'],
|
||||
'nome'=>$request['nome'],
|
||||
'datainizio'=>date_format(date_create($request['datainizio']),'Y-m-d'),
|
||||
'datatermine'=>date_format(date_create($request['datatermine']),'Y-m-d'),
|
||||
'fornitore'=>$request['fornitore'],
|
||||
'tipo'=>$request['tipo'],
|
||||
'importo'=>$request['importo'],
|
||||
'scadenzapagamento'=>date_format(date_create($request['scadenzapagamento']),'Y-m-d'),
|
||||
'stato'=>$request['stato'],
|
||||
'note'=>$request['note'],
|
||||
'filename'=>$filename,
|
||||
]);
|
||||
return redirect()->back();
|
||||
}
|
||||
/* */
|
||||
|
||||
public function schedaContratto($id)
|
||||
{
|
||||
$contratto = Contratti::getContrattoById($id);
|
||||
return view('contratti.detail',[
|
||||
'contratto'=>$contratto,
|
||||
'docs' => \App\Models\GenDoc::listDocument(1,$id)
|
||||
]);
|
||||
}
|
||||
|
||||
public function documentDelete(Request $id)
|
||||
{
|
||||
// return dd($id);
|
||||
// $entity=1;
|
||||
$contratto=GenDoc::find($id['id']);
|
||||
if(file_exists('/storage/'.$contratto->filename))
|
||||
{
|
||||
unlink('storage/'.$contratto->filename);
|
||||
}
|
||||
GenDoc::find($id['id'])->delete();
|
||||
return redirect('/admin/contratti/'.$id['entity_id']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,27 +22,25 @@ class DocumentiController extends Controller
|
||||
}
|
||||
|
||||
public function fileForm(Request $request){
|
||||
$documenti = Documenti::getList($request->input('id'));
|
||||
return view('conti.documenti.insert', [
|
||||
'id'=>$request->input('id'),
|
||||
$documenti = Documenti::getList($request->input('entity_id'));
|
||||
|
||||
return view('conti.documenti.insert', [
|
||||
'id'=>$request->input('entity_id'),
|
||||
'documenti'=>$documenti
|
||||
]);
|
||||
}
|
||||
|
||||
/*
|
||||
// {issue #5} Proposta cambiamento per generalizzazione documenti
|
||||
// NB: cambiare anche in routes/admin.php il riferimento alla funzione da richiamare
|
||||
public function fileMovimentiForm(Request $request){
|
||||
$documenti = Documenti::getList($request->input('id'),'Movimenti');
|
||||
return view('conti.documenti.insert', [
|
||||
'id'=>$request['id']),
|
||||
'documenti'=>$documenti
|
||||
]);
|
||||
public function newFolder(Request $req)
|
||||
{
|
||||
// crea una nuova caregoria per i documenti
|
||||
Documenti::store($req);
|
||||
return redirect(route('folders'));
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
public function listaDocumenti()
|
||||
{
|
||||
return view('documenti.lista',['data'=>Documenti::all()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Event;
|
||||
use Illuminate\Http\Request;
|
||||
use Spatie\GoogleCalendar\Event as Events;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class FullCalenderController extends Controller
|
||||
{
|
||||
@@ -18,31 +20,14 @@ class FullCalenderController extends Controller
|
||||
*/
|
||||
|
||||
public function index(Request $request)
|
||||
|
||||
{
|
||||
|
||||
|
||||
|
||||
if($request->ajax()) {
|
||||
|
||||
|
||||
|
||||
$data = Event::whereDate('start', '>=', $request->start)
|
||||
|
||||
$data = Event::whereDate('start', '>=', $request->start)
|
||||
->whereDate('end', '<=', $request->end)
|
||||
|
||||
->get(['id', 'title', 'start', 'end']);
|
||||
|
||||
|
||||
|
||||
return response()->json($data);
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return view('fullcalendar');
|
||||
|
||||
return view('calendario.fullcalendar');
|
||||
}
|
||||
|
||||
|
||||
@@ -58,72 +43,53 @@ class FullCalenderController extends Controller
|
||||
*/
|
||||
|
||||
public function ajax(Request $request)
|
||||
|
||||
{
|
||||
|
||||
|
||||
|
||||
switch ($request->type) {
|
||||
|
||||
case 'add':
|
||||
|
||||
$event = Event::create([
|
||||
|
||||
'title' => $request->title,
|
||||
|
||||
'start' => $request->start,
|
||||
|
||||
'end' => $request->end,
|
||||
|
||||
]);
|
||||
|
||||
|
||||
|
||||
return response()->json($event);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case 'update':
|
||||
|
||||
$event = Event::find($request->id)->update([
|
||||
|
||||
'title' => $request->title,
|
||||
|
||||
'start' => $request->start,
|
||||
|
||||
'end' => $request->end,
|
||||
|
||||
]);
|
||||
|
||||
|
||||
|
||||
return response()->json($event);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case 'delete':
|
||||
|
||||
$event = Event::find($request->id)->delete();
|
||||
|
||||
|
||||
|
||||
return response()->json($event);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
# code...
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function showDemo()
|
||||
{
|
||||
return view('calendario.fullcalendar');
|
||||
}
|
||||
|
||||
public function saveEventToGoogle(Request $request){
|
||||
$event = new Events;
|
||||
$event->name = $request['title'];
|
||||
$event->description=$request['descrizione'];
|
||||
$tzStart = $request['DateStart'].'T'.$request['HourStart'].' +02:00';
|
||||
$tzEnd = $request['DateEnd'].'T'.$request['HourEnd'].' +02:00';
|
||||
$event->startDateTime = Carbon::parse($tzStart);
|
||||
$event->endDateTime = Carbon::parse($tzEnd);
|
||||
$event->save();
|
||||
return view('calendario.fullcalendar');
|
||||
}
|
||||
}
|
||||
|
||||
35
app/Http/Controllers/GenDocController.php
Normal file
35
app/Http/Controllers/GenDocController.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\GenDoc;
|
||||
|
||||
class GenDocController extends Controller
|
||||
{
|
||||
//
|
||||
public function fileForm(Request $request){
|
||||
$entity_id=$request->input('entity_id');
|
||||
$entity=$request->input('entity');
|
||||
|
||||
if(!$request->input('entity_id'))
|
||||
{
|
||||
$entity_id=0;
|
||||
}
|
||||
$documenti = GenDoc::listDocument($entity,$entity_id);
|
||||
return view('conti.documenti.gendoc', [
|
||||
'id'=>$entity_id,
|
||||
'entity'=>$entity,
|
||||
'documenti'=>$documenti,
|
||||
]);
|
||||
}
|
||||
|
||||
public function storeFile(Request $request){
|
||||
GenDoc::saveDocument($request);
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
24
app/Http/Controllers/HomeAssistantAPIController.php
Normal file
24
app/Http/Controllers/HomeAssistantAPIController.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\HomeAssistantAPI;
|
||||
|
||||
class HomeAssistantAPIController extends Controller
|
||||
{
|
||||
// Connessione RestAPI di HomeAssistant
|
||||
|
||||
public function getContatore()
|
||||
{
|
||||
$kwh = HomeAssistantAPI::getSensorState('sensor.contatore_casa');
|
||||
return $kwh->state;
|
||||
}
|
||||
|
||||
public function getStatoPompa()
|
||||
{
|
||||
$statoPompa = HomeAssistantAPI::getSensorState('switch.pompa_pozzo');
|
||||
return $statoPompa->state;
|
||||
//dd($statoPompa);
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,8 @@ class MovimentiController extends Controller
|
||||
$saldo=Movimenti::getSaldoTot();
|
||||
$mieiTasks=Task::getTaskAssignedToUser(Auth::id());
|
||||
// $TasksAssegnati=Task::getTaskAssignedByUser(Auth::id());
|
||||
$avvisi=Avviso::getAvvisi();
|
||||
// $avvisi=Avviso::getAvvisi();
|
||||
$avvisi=Avviso::getActualAvvisi();
|
||||
|
||||
return view('layouts.dashboard',[
|
||||
'entrate'=>$entrate,
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Models\Progetti;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\RigaProgetto;
|
||||
use App\Models\GenDoc;
|
||||
use function GuzzleHttp\json_encode;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
|
||||
@@ -75,4 +76,40 @@ class ProgettiController extends Controller
|
||||
return $pdf->stream();
|
||||
}
|
||||
|
||||
public function documentoProgetto(Request $request)
|
||||
{
|
||||
$documenti = GenDoc::listDocument(3,$request->input('entity_id'));
|
||||
|
||||
return view('conti.documenti.insert', [
|
||||
'id'=>$request->input('entity_id'),
|
||||
'entity'=>$request->input('entity'),
|
||||
'documenti'=>$documenti
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function modificaProgetto(Request $data)
|
||||
{
|
||||
// funzione di modifica del progetto (form inserimento modificato in js)
|
||||
Progetti::where('id', $data['id'])
|
||||
->update([
|
||||
'nome' => $data['nome'],
|
||||
'descrizione' => $data['descrizione'],
|
||||
//'data_creazione'=>$data['data_creazione'],
|
||||
'data_inizio'=>$data['data_inizio'],
|
||||
'data_fine'=>$data['data_fine'],
|
||||
'fk_user'=>$data['coordinatore'],
|
||||
'budget'=>$data['budget'],
|
||||
'stato'=>$data['stato'],
|
||||
'note' =>$data['note'],
|
||||
]);
|
||||
return redirect()->back();
|
||||
/* dd($data);*/
|
||||
}
|
||||
|
||||
public function getProgettobyId(Request $id)
|
||||
{
|
||||
return json_encode(Progetti::getProgettoById($id['id']));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class TagController extends Controller
|
||||
|
||||
public function apiList()
|
||||
{
|
||||
$tags=tag::getList();
|
||||
$tags=tag::getApiList();
|
||||
return json_encode($tags);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class TaskController extends Controller
|
||||
//
|
||||
public function listTask()
|
||||
{
|
||||
return Task::all();
|
||||
return Task::where('termine_il','>=', now())->get();
|
||||
// debug
|
||||
// return get_class_methods($this);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class Avviso extends Model
|
||||
{
|
||||
@@ -25,4 +26,30 @@ class Avviso extends Model
|
||||
{
|
||||
return self::all();
|
||||
}
|
||||
|
||||
public static function getActualAvvisi()
|
||||
{
|
||||
return self::where('creato_il','>=', now()->subMonth())->get();
|
||||
}
|
||||
|
||||
public static function getHAstatus()
|
||||
{
|
||||
/*$response = Http::withHeaders([
|
||||
'Authorization'=>' Bearer '.env('HA_TOKEN'),
|
||||
'Content-Type'=>' application/json',
|
||||
])->get('https://ha.lavorain.cloud/api/services',['domain']);
|
||||
return $response;
|
||||
// return dd($response);*/
|
||||
}
|
||||
|
||||
public static function getAnsaNews()
|
||||
{
|
||||
/*$xmlstring = Http::get('https://www.ansa.it/trentino/notizie/trentino_rss.xml');
|
||||
$xml_file = simplexml_load_string($xmlstring);
|
||||
$json = json_encode($xml_file );
|
||||
$array = json_decode($json,TRUE);
|
||||
dd($array); // return $array;*/
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,10 @@ class Categorie extends Model
|
||||
{
|
||||
return self::all();
|
||||
}
|
||||
|
||||
public static function listCategorieAPI()
|
||||
{
|
||||
return self::select('cat_name')->pluck('cat_name');
|
||||
}
|
||||
public static function listSpesa()
|
||||
{
|
||||
return DB::table('categories')->where('cat_uscita','=',1)->orderBy('cat_name')->get();
|
||||
|
||||
@@ -4,8 +4,40 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
|
||||
class Contratti extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable=[
|
||||
'numero',
|
||||
'nome',
|
||||
'datainizio',
|
||||
'datatermine',
|
||||
'fornitore',
|
||||
'tipo',
|
||||
'importo',
|
||||
'scadenzapagamento',
|
||||
'stato',
|
||||
'note',
|
||||
'filename'
|
||||
];
|
||||
|
||||
|
||||
public static function storeContratto(Request $req){
|
||||
/* dd($req); */
|
||||
|
||||
}
|
||||
|
||||
public static function getAllContratto(){
|
||||
return self::all();
|
||||
}
|
||||
|
||||
public static function getContrattoById($id){
|
||||
return DB::table('contrattis')->where('id','=',$id)->get();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,12 @@ use Illuminate\Support\Facades\DB;
|
||||
class Documenti extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
'descrizione',
|
||||
'path',
|
||||
];
|
||||
|
||||
public static function countDocument($id){
|
||||
$quanti=DB::table('documentis')
|
||||
@@ -26,13 +32,14 @@ class Documenti extends Model
|
||||
*/
|
||||
|
||||
public static function store($req) {
|
||||
$movimento_id=$req->input('id');
|
||||
$filename=$req->file('filename')->store('Documenti');
|
||||
// $movimento_id=$req->input('id');
|
||||
// $filename=$req->file('filename')->store('Documenti');
|
||||
DB::table('documentis')
|
||||
->insert([
|
||||
'movimenti_id'=>$movimento_id,
|
||||
// 'movimenti_id'=>$movimento_id,
|
||||
'descrizione'=>$req->input('descrizione'),
|
||||
'filename'=>$filename,
|
||||
'path'=>$req->input('path'),
|
||||
// 'filename'=>$filename,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -53,12 +60,12 @@ class Documenti extends Model
|
||||
public static function getList($id)
|
||||
{
|
||||
return DB::table('documentis')
|
||||
->where('movimenti_id','=',$id)
|
||||
->where('movimenti_id','=', $id)
|
||||
->get();
|
||||
}
|
||||
|
||||
// Proposta modifica issue {#5 gitea} (generalizzazione del documento)
|
||||
/*
|
||||
/*
|
||||
public static function getList($id,$entity)
|
||||
{
|
||||
self::where('entita','=',$entity)->where('entita_id','=',$id)->get();
|
||||
|
||||
51
app/Models/GenDoc.php
Normal file
51
app/Models/GenDoc.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Documenti;
|
||||
|
||||
class GenDoc extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
// DocumentiGenerali
|
||||
|
||||
public static function saveDocument($data){
|
||||
|
||||
$filename=$data->file('filename')->store(self::getEntityFolder($data['entity']));
|
||||
DB::table('gen_docs')
|
||||
->insert([
|
||||
'entity'=>$data['entity'],
|
||||
'entity_id'=>($data['entity_id'] ?? 0 ),
|
||||
'descrizione'=>$data['descrizione'],
|
||||
'filename'=>$filename,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function listDocument($entity,$entity_id = 0)
|
||||
{
|
||||
// Ritorna la lista dei documenti in base all'entità e al rispettivo id
|
||||
return DB::table('gen_docs')->where('entity','=',$entity)->where('entity_id','=',$entity_id)->get(); //nuova funzione
|
||||
// return DB::table('documentis')->where('movimenti_id','=', $entity_id)->get();
|
||||
}
|
||||
|
||||
public static function countDocument($entity,$entity_id = 0){
|
||||
// Conta i documenti inseriti per la determinata entità e id
|
||||
$quanti=DB::table('gen_docs')
|
||||
->where('entity','=',$entity)
|
||||
->andWhere('entity_id','=',$entity_id)
|
||||
->count();
|
||||
return $quanti;
|
||||
}
|
||||
|
||||
private static function getEntityFolder($id)
|
||||
{
|
||||
$entita = Documenti::where('id',$id)->pluck('path');
|
||||
|
||||
return $entita[0];
|
||||
//return $entita->path;
|
||||
}
|
||||
}
|
||||
26
app/Models/HomeAssistantAPI.php
Normal file
26
app/Models/HomeAssistantAPI.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class HomeAssistantAPI extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public static function getSensorState($sensor)
|
||||
{
|
||||
$result=Http::withHeaders(
|
||||
[
|
||||
'Authorization'=>'Bearer '.env('HA_TOKEN'),
|
||||
'Content-Type'=>'application/json',
|
||||
]
|
||||
)->get('https://ha.lavorain.cloud/api/states/'.$sensor);
|
||||
|
||||
return json_decode($result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,14 +13,34 @@ class Movimenti extends Model
|
||||
protected $dates = ['mov_data'];
|
||||
protected $casts = [ 'mov_data'=>'datetime'];
|
||||
|
||||
public static $query='SELECT
|
||||
a.id,
|
||||
a.mov_data,
|
||||
a.mov_importo,
|
||||
a.mov_descrizione,
|
||||
c.cat_name,
|
||||
t.tag_name,
|
||||
(SELECT Count(entity_id) as quanti FROM gen_docs WHERE entity=0 AND entity_id = a.id) as quanti
|
||||
FROM movimentis as a
|
||||
JOIN tags as t ON a.mov_fk_tags=t.id
|
||||
JOIN categories as c ON a.mov_fk_categoria=c.id';
|
||||
|
||||
public static function getList() {
|
||||
return DB::table('movimentis')
|
||||
->join('categories','movimentis.mov_fk_categoria','=','categories.id')
|
||||
->join('tags','movimentis.mov_fk_tags','=','tags.id')
|
||||
->leftJoin('documentis', 'movimenti_id','=','movimentis.id')
|
||||
->select('movimentis.id','mov_data','mov_descrizione','mov_importo','cat_name','tag_name', DB::raw('Count(movimenti_id) as quanti'))
|
||||
->groupBy('movimentis.id','mov_data','mov_descrizione','mov_importo','cat_name','tag_name')
|
||||
->get();
|
||||
|
||||
|
||||
return DB::select(DB::raw(
|
||||
'SELECT
|
||||
a.id,
|
||||
a.mov_data,
|
||||
a.mov_importo,
|
||||
a.mov_descrizione,
|
||||
c.cat_name,
|
||||
t.tag_name,
|
||||
(SELECT Count(entity_id) as quanti FROM gen_docs WHERE entity=0 AND entity_id = a.id) as quanti
|
||||
FROM movimentis as a
|
||||
JOIN tags as t ON a.mov_fk_tags=t.id
|
||||
JOIN categories as c ON a.mov_fk_categoria=c.id'
|
||||
));
|
||||
}
|
||||
|
||||
public static function getSaldo($date) {
|
||||
@@ -114,38 +134,51 @@ class Movimenti extends Model
|
||||
}
|
||||
|
||||
public static function listByCatMonth($month,$cat,$year) {
|
||||
return DB::table('movimentis')
|
||||
->join('categories','movimentis.mov_fk_categoria','=','categories.id')
|
||||
->join('tags','movimentis.mov_fk_tags','=','tags.id')
|
||||
->where('movimentis.mov_fk_categoria','=',$cat)
|
||||
->whereMonth('mov_data','=',$month)
|
||||
->whereYear('mov_data', '=' , $year)
|
||||
->leftJoin('documentis', 'movimenti_id','=','movimentis.id')
|
||||
->select('movimentis.id','mov_data','mov_descrizione','mov_importo','cat_name','tag_name', DB::raw('Count(movimenti_id) as quanti'))
|
||||
->groupBy('movimentis.id','mov_data','mov_descrizione','mov_importo','cat_name','tag_name')
|
||||
->get();
|
||||
return DB::select(DB::raw('SELECT
|
||||
a.id,
|
||||
a.mov_data,
|
||||
a.mov_importo,
|
||||
a.mov_descrizione,
|
||||
c.cat_name,
|
||||
t.tag_name,
|
||||
(SELECT Count(entity_id) as quanti FROM gen_docs WHERE entity=0 AND entity_id = a.id) as quanti
|
||||
FROM movimentis as a
|
||||
JOIN tags as t ON a.mov_fk_tags=t.id
|
||||
JOIN categories as c ON a.mov_fk_categoria=c.id
|
||||
WHERE Month(a.mov_data)='.$month.' AND Year(a.mov_data)='.$year.' AND a.mov_fk_categoria='.$cat
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
public static function listByCategory($cat) {
|
||||
return DB::table('movimentis')
|
||||
->join('categories','movimentis.mov_fk_categoria','=','categories.id')
|
||||
->join('tags','movimentis.mov_fk_tags','=','tags.id')
|
||||
->where('movimentis.mov_fk_categoria','=',$cat)
|
||||
->leftJoin('documentis', 'movimenti_id','=','movimentis.id')
|
||||
->select('movimentis.id','mov_data','mov_descrizione','mov_importo','cat_name','tag_name', DB::raw('Count(movimenti_id) as quanti'))
|
||||
->groupBy('movimentis.id','mov_data','mov_descrizione','mov_importo','cat_name','tag_name')
|
||||
->get();
|
||||
return DB::select(DB::raw('SELECT
|
||||
a.id,
|
||||
a.mov_data,
|
||||
a.mov_importo,
|
||||
a.mov_descrizione,
|
||||
c.cat_name,
|
||||
t.tag_name,
|
||||
(SELECT Count(entity_id) as quanti FROM gen_docs WHERE entity=0 AND entity_id = a.id) as quanti
|
||||
FROM movimentis as a
|
||||
JOIN tags as t ON a.mov_fk_tags=t.id
|
||||
JOIN categories as c ON a.mov_fk_categoria=c.id
|
||||
WHERE a.mov_fk_categoria = '.$cat ));
|
||||
|
||||
}
|
||||
|
||||
public static function getByTag($tag) {
|
||||
return DB::table('movimentis')
|
||||
->where('mov_fk_tags','=',$tag)
|
||||
->join('categories','movimentis.mov_fk_categoria','=','categories.id')
|
||||
->join('tags','movimentis.mov_fk_tags','=','tags.id')
|
||||
->leftJoin('documentis', 'movimenti_id','=','movimentis.id')
|
||||
->select('movimentis.id','mov_data','mov_descrizione','mov_importo','cat_name','tag_name', DB::raw('Count(movimenti_id) as quanti'))
|
||||
->groupBy('movimentis.id','mov_data','mov_descrizione','mov_importo','cat_name','tag_name')
|
||||
->get();
|
||||
return DB::select(DB::raw('SELECT
|
||||
a.id,
|
||||
a.mov_data,
|
||||
a.mov_importo,
|
||||
a.mov_descrizione,
|
||||
c.cat_name,
|
||||
t.tag_name,
|
||||
(SELECT Count(entity_id) as quanti FROM gen_docs WHERE entity=0 AND entity_id = a.id) as quanti
|
||||
FROM movimentis as a
|
||||
JOIN tags as t ON a.mov_fk_tags=t.id
|
||||
JOIN categories as c ON a.mov_fk_categoria=c.id
|
||||
WHERE a.mov_fk_tags = '.$tag ));
|
||||
}
|
||||
|
||||
public static function importEstrattoIng($filename)
|
||||
@@ -160,7 +193,11 @@ class Movimenti extends Model
|
||||
list($giorno,$mese,$anno) = explode('/',$line['Data valuta']);
|
||||
$data="$anno-$mese-$giorno";
|
||||
self::insEntrata([
|
||||
<<<<<<< HEAD
|
||||
'mov_data'=>$data,
|
||||
=======
|
||||
'mov_data'=>self::dateFormat(0,$line['Data valuta']),
|
||||
>>>>>>> devel
|
||||
'mov_fk_categoria'=>1,
|
||||
'mov_descrizione'=>$line['Descrizione operazione'],
|
||||
'mov_importo'=>trim(str_replace(',','.',(str_replace('.','',str_replace('€', '', $line['Importo']))))),
|
||||
@@ -183,7 +220,8 @@ class Movimenti extends Model
|
||||
if($line['DARE']<>'')
|
||||
{
|
||||
$dati=[
|
||||
'mov_data'=>self::dateFormat(0,$line['VALUTA']), // date_format(date_create($movimento->mov_data),'d/m/Y'
|
||||
'mov_data'=>self::dateFormat(0,$line['VALUTA']),
|
||||
// date_format(date_create($movimento->mov_data),'d/m/Y'
|
||||
// 'mov_data'=>date_format(date_create($line['VALUTA']),'Y-m-d'),
|
||||
'mov_fk_categoria'=>1,
|
||||
'mov_descrizione'=>$line['DESCRIZIONE OPERAZIONE'],
|
||||
|
||||
@@ -19,7 +19,7 @@ class Task extends Model
|
||||
//
|
||||
public static function getTaskAssignedToUser($userid)
|
||||
{
|
||||
return self::where('assegnato_a',$userid)->get();
|
||||
return self::where('assegnato_a',$userid)->where('termine_il','>=', now())->get();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -30,4 +30,5 @@ class contatto extends Model
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,11 @@ class tag extends Model
|
||||
return DB::table('tags')->orderBy('tag_name')->get();
|
||||
}
|
||||
|
||||
public static function getApiList()
|
||||
{
|
||||
return self::select('tag_name')->pluck('tag_name');
|
||||
}
|
||||
|
||||
public static function inserisci($param) {
|
||||
DB::table('tags')->insert(['tag_name'=> $param['tag_name']]);
|
||||
}
|
||||
|
||||
31
app/View/Components/Widget/Avvisi.php
Normal file
31
app/View/Components/Widget/Avvisi.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Widget;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class Avvisi extends Component
|
||||
{
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
// public $avvisi ="";
|
||||
|
||||
public function __construct(public array $avvisi)
|
||||
{
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Closure|string
|
||||
*/
|
||||
public function render():View
|
||||
{
|
||||
return view('components.widget.avvisi', ['avvisi'=>$this->avvisi]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user