%PDF- %PDF-
| Direktori : /var/www/pjc/app/Http/Livewire/ |
| Current File : /var/www/pjc/app/Http/Livewire/LavoroRimanente.php |
<?php
namespace App\Http\Livewire;
use Livewire\Component;
use DB;
use Cknow\Money\Money;
class LavoroRimanente extends Component
{
public $settore;
public $carico_lavoro;
protected $listeners = ['rim' => 'rimanenza'];
public function mount($set)
{
$this->rimanenza($set);
}
public function rimanenza($set)
{
$this->settore = $set;
switch ($set) {
case 1:
$string = 'carico_s_old';
break;
case 2:
$string = 'carico_t_old';
break;
case 3:
$string = 'carico_e_old';
break;
case 4:
$string = 'carico_a_old';
break;
case 5:
$string = 'carico_f_old';
break;
}
$carico = DB::table('project')
->join('projects_accounts', 'projects_accounts.project_id', '=', 'project.id')
->join('project_cstm', 'project_cstm.id_c', '=', 'project.id')
->join('accounts', 'accounts.id', '=', 'projects_accounts.account_id')
->leftjoin('pianificazioneore', 'pianificazioneore.idCommessa', '=', 'project.id')
->leftjoin('pianificazionemese', 'pianificazionemese.idCommessa', '=', 'project.id')
->select('project.id as uid', 'project.name as nome', 'project.description as descrizione', 'project.estimated_start_date as data_inizio', 'project.status as stato', 'accounts.name as ragione_sociale', 'project_cstm.importo_c', 'project_cstm.npreventivo_c', 'pianificazioneore.*', 'project_cstm.settore_c', 'pianificazioneore.*')
->where('project.deleted', 0)
->where('projects_accounts.deleted', 0)
->whereIn('status', ['Draft', 'apertamafatturata'])
->where('project_cstm.settore_c', $set)
->orderby('project.date_entered', 'DESC')
->sum('project_cstm.importo_c') - DB::table('project')
->join('projects_accounts', 'projects_accounts.project_id', '=', 'project.id')
->join('project_cstm', 'project_cstm.id_c', '=', 'project.id')
->join('accounts', 'accounts.id', '=', 'projects_accounts.account_id')
->leftjoin('pianificazioneore', 'pianificazioneore.idCommessa', '=', 'project.id')
->leftjoin('pianificazionemese', 'pianificazionemese.idCommessa', '=', 'project.id')
->select('project.id as uid', 'project.name as nome', 'project.description as descrizione', 'project.estimated_start_date as data_inizio', 'project.status as stato', 'accounts.name as ragione_sociale', 'project_cstm.importo_c', 'project_cstm.npreventivo_c', 'pianificazioneore.*', 'project_cstm.settore_c', 'pianificazioneore.*')
->where('project.deleted', 0)
->where('projects_accounts.deleted', 0)
->whereIn('status', ['Draft', 'apertamafatturata'])
->where('project_cstm.settore_c', $set)
->orderby('project.date_entered', 'DESC')
->sum($string);
$utenti_t = [24, 5, 8, 31, 28, 12];
$utenti_e = [33, 34, 1, 2];
$utenti_a = [18, 6, 3];
$utenti_s = [13, 23, 21, 20, 19, 17, 14, 11, 30, 32, 35];
$utenti_f = [25, 26, 15];
switch ($set) {
case 1:
$this->carico_lavoro = $carico - \App\pianficazioneutente::wherein('idUtente', $utenti_s)->sum('ore');
break;
case 2:
$this->carico_lavoro = $carico - \App\pianficazioneutente::wherein('idUtente', $utenti_t)->sum('ore');
break;
case 3:
$this->carico_lavoro = $carico - \App\pianficazioneutente::wherein('idUtente', $utenti_e)->sum('ore');
break;
case 4:
$this->carico_lavoro = $carico - \App\pianficazioneutente::wherein('idUtente', $utenti_a)->sum('ore');
break;
case 5:
$this->carico_lavoro = Money::EUR($carico - \App\pianficazioneutente::wherein('idUtente', $utenti_f)->sum('ore'));
break;
}
}
public function render()
{
return view('livewire.lavoro-rimanente');
}
}