Roberto Santini 3 years ago
parent
commit
f00c2a722c

+ 1
- 1
app/DataTables/IssueDataTable.php View File

36
       }
36
       }
37
     })
37
     })
38
     ->addColumn('action', function($entity){
38
     ->addColumn('action', function($entity){
39
-      $button = "<a class='btn btn-primary' href='".route('issue.show', ['id' => $entity->id])."'><i class='fas fa-chevron-right'></i></a>";
39
+      $button = "<a class='btn btn-primary' href='".route('issue.show', ['issue_id' => $entity->id])."'><i class='fas fa-chevron-right'></i></a>";
40
       return $button;
40
       return $button;
41
       return view('issue.menu', ['entity' => $entity]);
41
       return view('issue.menu', ['entity' => $entity]);
42
     });
42
     });

+ 27
- 23
app/Http/Controllers/ConfigController.php View File

30
 
30
 
31
     foreach($input['key'] as $key => $value){
31
     foreach($input['key'] as $key => $value){
32
       $config = Config::find($value);
32
       $config = Config::find($value);
33
-      switch ($config->type) {
34
-        case 'file':
35
-        $file = $request->file('value');
36
-        if($file != null && array_key_exists($key, $file)){
37
-          $filename = $file[$key]->storeAs('public', $file[$key]->getClientOriginalName());
38
-          $config->value = $filename;
39
-          $index_file++;
40
-        }
41
-        break;
33
+      try{
34
+        switch ($config->type) {
35
+          case 'file':
36
+          $file = $request->file('value');
37
+          if($file != null && array_key_exists($key, $file)){
38
+            $filename = $file[$key]->storeAs('public', $file[$key]->getClientOriginalName());
39
+            $config->value = $filename;
40
+            $index_file++;
41
+          }
42
+          break;
42
 
43
 
43
-        case 'array_status':
44
-        $config->value = json_encode($request->value[$key]);
45
-        break;
44
+          case 'array_status':
45
+          $config->value = json_encode($request->value[$key]);
46
+          break;
46
 
47
 
47
-        case 'users':
48
-        $config->value = json_encode($request->value[$key]);
49
-        break;
48
+          case 'users':
49
+          $config->value = json_encode($request->value[$key]);
50
+          break;
50
 
51
 
51
-        case 'password':
52
-        if($request->value[$key] != null && $request->value[$key] != ''){
52
+          case 'password':
53
+          if($request->value[$key] != null && $request->value[$key] != ''){
53
             $config->value = $request->value[$key];
54
             $config->value = $request->value[$key];
55
+          }
56
+          break;
57
+
58
+          default:
59
+          $config->value = $request->value[$key];
60
+          // $index++;
61
+          break;
54
         }
62
         }
55
-        break;
63
+        $config->save();
64
+      }catch(\Exception $e){
56
 
65
 
57
-        default:
58
-        $config->value = $request->value[$key];
59
-        // $index++;
60
-        break;
61
       }
66
       }
62
-      $config->save();
63
     }
67
     }
64
 
68
 
65
     Session::flash('flash_message', 'Configurazione aggiornata');
69
     Session::flash('flash_message', 'Configurazione aggiornata');

+ 4
- 4
app/Http/Controllers/IssueController.php View File

39
     return $dataTable->with(['issues' => $collection])->render('issue.index');
39
     return $dataTable->with(['issues' => $collection])->render('issue.index');
40
   }
40
   }
41
 
41
 
42
-  public function show($id = null, Request $request){
42
+  public function show(Request $request){
43
     $redmineUser = session('redmine_user');
43
     $redmineUser = session('redmine_user');
44
 
44
 
45
 
45
 
46
-    $response_issue = Http::get(config('redmine.url').'/issues/'.$id.'.json?include=attachments,relations,journals', [
46
+    $response_issue = Http::get(config('redmine.url').'/issues/'.$request->issue_id.'.json?include=attachments,relations,journals', [
47
       'key' => $redmineUser->api_key,
47
       'key' => $redmineUser->api_key,
48
       'include' => 'journals,attachments,relations'
48
       'include' => 'journals,attachments,relations'
49
     ]);
49
     ]);
50
 
50
 
51
 
51
 
52
-    $response_helpesk = Http::get(config('redmine.url').'/helpdesk_tickets/'.$id.'.json', [
52
+    $response_helpesk = Http::get(config('redmine.url').'/helpdesk_tickets/'.$request->issue_id.'.json', [
53
       'key' => $redmineUser->api_key,
53
       'key' => $redmineUser->api_key,
54
     ]);
54
     ]);
55
 
55
 
103
       'telefono' => 'required|string|max:255',
103
       'telefono' => 'required|string|max:255',
104
       'description' => 'required',
104
       'description' => 'required',
105
       'accetto_condizioni' =>'accepted',
105
       'accetto_condizioni' =>'accepted',
106
-      'allegato' => 'size:5000'
106
+      'allegato' => 'size:10000'
107
     ];
107
     ];
108
 
108
 
109
     $request->validate($rules, $this->messages);
109
     $request->validate($rules, $this->messages);

+ 21
- 4
app/Http/Controllers/UserController.php View File

106
 
106
 
107
   public function load_progetti(Request $request){
107
   public function load_progetti(Request $request){
108
     $redmineUser = session('redmine_user');
108
     $redmineUser = session('redmine_user');
109
-    $collection = new Collection();
109
+    $user = User::find($request->user_id);
110
+
111
+    $progettiUser = new Collection;
112
+    $progetti = new Collection;
113
+
114
+    // Lista di tutti i progetti
115
+    $projectResponseUser = Http::get(config('redmine.url').'/projects.json', [
116
+      'key' => $redmineUser->api_key
117
+    ]);
110
 
118
 
119
+    // Lista di 30 progetti filtrati per ricerca
111
     $projectResponse = Http::get(config('redmine.url').'/projects.json', [
120
     $projectResponse = Http::get(config('redmine.url').'/projects.json', [
112
       'key' => $redmineUser->api_key,
121
       'key' => $redmineUser->api_key,
113
       'name' => '~'.($request->has('filter')?$request->filter:''),
122
       'name' => '~'.($request->has('filter')?$request->filter:''),
114
-      'limit' => 20
123
+      'limit' => 30
115
     ]);
124
     ]);
116
 
125
 
126
+    foreach($projectResponseUser->object()->projects as $project){
127
+      if(in_array($project->id, json_decode($user->progetti))){
128
+        $progettiUser->push($project);
129
+      }
130
+    }
131
+
117
     foreach($projectResponse->object()->projects as $project){
132
     foreach($projectResponse->object()->projects as $project){
118
-      $collection->push($project);
133
+      if(!in_array($project->id, json_decode($user->progetti))){
134
+        $progetti->push($project);
135
+      }
119
     }
136
     }
120
 
137
 
121
-    return view('user.progetti')->with(['user' => User::find($request->user_id), 'progetti' => $collection]);
138
+    return view('user.progetti')->with(['user' => $user, 'progetti' => $progetti, 'progettiUser' => $progettiUser]);
122
   }
139
   }
123
 
140
 
124
   public function update_progetti(Request $request){
141
   public function update_progetti(Request $request){

+ 7
- 3
app/Models/Config.php View File

5
 class Config extends \App\Models\AbstractModels\AbstractConfig
5
 class Config extends \App\Models\AbstractModels\AbstractConfig
6
 {
6
 {
7
   const STATI_SEGNALAZIONI_VALIDE = 'stati_segnalazioni_valide';
7
   const STATI_SEGNALAZIONI_VALIDE = 'stati_segnalazioni_valide';
8
-  const ATTIVITA_ON_SITE = 12;
9
-  const ATTIVITA_REMOTA = 11;
8
+  const ATTIVITA_ON_SITE = 'attivita_onsite';
9
+  const ATTIVITA_REMOTA = 'attivita_remota';
10
+  const CAMPO_FATTURARE = 'campo_fatturare';
10
 
11
 
11
   public static function getConfig(){
12
   public static function getConfig(){
12
     $config = [];
13
     $config = [];
13
     $config['Generale'] = [
14
     $config['Generale'] = [
14
-      ['key' => self::STATI_SEGNALAZIONI_VALIDE, 'value' => null, 'display_name' => 'Stati segnalazioni da mostrare al cliente', 'type' => 'array_status'],
15
+      ['key' => self::STATI_SEGNALAZIONI_VALIDE, 'value' => null, 'display_name' => 'Stati segnalazioni da mostrare al cliente', 'type' => 'array_status', 'order' => 10],
16
+      ['key' => self::ATTIVITA_ON_SITE, 'value' => null, 'display_name' => 'Tipo attività on site', 'type' => 'activity', 'order' => 20],
17
+      ['key' => self::ATTIVITA_REMOTA, 'value' => null, 'display_name' => 'Tipo attività remota', 'type' => 'activity', 'order' => 30],
18
+      ['key' => self::CAMPO_FATTURARE, 'value' => null, 'display_name' => 'Campo "Fatturare?" (impostato a "Si")', 'type' => 'custom_fields', 'order' => 30],
15
     ];
19
     ];
16
 
20
 
17
     return $config;
21
     return $config;

+ 33
- 1
app/Models/Issue.php View File

56
     $issueResponse = Http::get(config('redmine.url').'/time_entries.json', [
56
     $issueResponse = Http::get(config('redmine.url').'/time_entries.json', [
57
       'key' => $redmineUser->api_key,
57
       'key' => $redmineUser->api_key,
58
       'issue_id' => $issue_id,
58
       'issue_id' => $issue_id,
59
-      'cf_2' => 'Si', // Custom fields "fatturare"
59
+      'cf_'.Config::getValue(Config::CAMPO_FATTURARE) => 'Si', // Custom fields "fatturare"
60
       'activity_id' => $attivita
60
       'activity_id' => $attivita
61
 
61
 
62
     ]);
62
     ]);
87
     return $issueStatus;
87
     return $issueStatus;
88
   }
88
   }
89
 
89
 
90
+  public static function getAttivita(){
91
+    $redmineUser = session('redmine_user');
92
+
93
+    $response = Http::get(config('redmine.url').'/enumerations/time_entry_activities.json', [
94
+      'key' => $redmineUser->api_key,
95
+    ]);
96
+
97
+    $attivita = array();
98
+    foreach($response->object()->time_entry_activities as $time_entry_activities){
99
+      if(!$time_entry_activities->active) continue;
100
+      $attivita[$time_entry_activities->id] = $time_entry_activities->name;
101
+    }
102
+
103
+    return $attivita;
104
+  }
105
+
106
+  public static function getCustomFields(){
107
+    $redmineUser = session('redmine_user');
108
+
109
+    $response = Http::get(config('redmine.url').'/custom_fields.json', [
110
+      'key' => $redmineUser->api_key,
111
+      'customized_type' => 'time_entry'
112
+    ]);
113
+
114
+    $custom = array();
115
+    foreach($response->object()->custom_fields as $custom_field){
116
+      $custom[$custom_field->id] = $custom_field->name;
117
+    }
118
+
119
+    return $custom;
120
+  }
121
+
90
 }
122
 }

+ 1
- 1
database/seeders/ConfigSeeder.php View File

23
           $config->order = $order;
23
           $config->order = $order;
24
           $config->group = $key;
24
           $config->group = $key;
25
           $config->save();
25
           $config->save();
26
-          $order++;
27
         }
26
         }
27
+        $order++;
28
       }
28
       }
29
     }
29
     }
30
   }
30
   }

+ 6
- 8
resources/views/config/index.blade.php View File

68
               ?>
68
               ?>
69
               @break
69
               @break
70
 
70
 
71
-              @case('array_attivita')
72
-              <br>
73
-              <?php
74
-              $checked = json_decode($config->value);
75
-              foreach(Issue::getAttivita() as $attivita_id => $attivita_label){
76
-                echo Form::checkbox('value['.$config->key.'][]', $attivita_id, $checked!=null?in_array($attivita_id, $checked):false, [])." ".$attivita_label."<br>";
77
-              }
78
-              ?>
71
+              @case('activity')
72
+              {!! Form::select('value['.$config->key.']', Issue::getAttivita(), $config->value, ['class' => 'form-control']) !!}
73
+              @break
74
+
75
+              @case('custom_fields')
76
+              {!! Form::select('value['.$config->key.']', Issue::getCustomFields(), $config->value, ['class' => 'form-control']) !!}
79
               @break
77
               @break
80
 
78
 
81
               @case('file')
79
               @case('file')

+ 1
- 1
resources/views/issue/index.blade.php View File

37
   $("#dataTable_issues").attr('width', '100%');
37
   $("#dataTable_issues").attr('width', '100%');
38
 
38
 
39
   $("#dataTable_issues").on('dblclick', 'tbody td', function (e) {
39
   $("#dataTable_issues").on('dblclick', 'tbody td', function (e) {
40
-  window.location = "{{ route('issue.show') }}?issue_id="+$(this).attr('id');
40
+    window.location = "{{ route('issue.show') }}?issue_id="+$(this).closest('tr').attr('id');
41
   });
41
   });
42
 });
42
 });
43
 </script>
43
 </script>

+ 0
- 11
resources/views/issue/menu.blade.php View File

1
-<div class="dropdown">
2
-  <a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
3
-    <i class="fas fa-bars"></i>
4
-  </a>
5
-
6
-  <div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
7
-    <a class="dropdown-item" href="{{ route('issue.show', ['id' => $entity->id]) }}"><i class="far fa-eye"></i>Apri</a>
8
-    <a class="dropdown-item" href="#" onclick=""><i class="fas fa-signature"></i>Firma rapportino</a>
9
-
10
-  </div>
11
-</div>

+ 1
- 1
resources/views/issue/nuovo.blade.php View File

82
 
82
 
83
           <div class="form-row">
83
           <div class="form-row">
84
             <div class="form-group col-md">
84
             <div class="form-group col-md">
85
-              {!! Form::label('allegato', 'Allegato') !!}
85
+              {!! Form::label('allegato', 'Allegato (max. 10Mb)') !!}
86
               {!! Form::file('allegato', ['class' => 'form-control']) !!}
86
               {!! Form::file('allegato', ['class' => 'form-control']) !!}
87
             </div>
87
             </div>
88
           </div>
88
           </div>

+ 10
- 8
resources/views/issue/show.blade.php View File

3
 use App\Models\Config;
3
 use App\Models\Config;
4
 use Carbon\Carbon;
4
 use Carbon\Carbon;
5
 
5
 
6
-$tempoImpiegatoOnSite = Issue::getTempoImpiegato($issue->id, Config::ATTIVITA_ON_SITE);
7
-$tempoImpiegatoRemota = Issue::getTempoImpiegato($issue->id, Config::ATTIVITA_REMOTA);
6
+$tempoImpiegatoOnSite = Issue::getTempoImpiegato($issue->id, Config::getValue(Config::ATTIVITA_ON_SITE));
7
+$tempoImpiegatoRemota = Issue::getTempoImpiegato($issue->id, Config::getValue(Config::ATTIVITA_REMOTA));
8
 ?>
8
 ?>
9
 
9
 
10
 <style>
10
 <style>
72
       <div class="card">
72
       <div class="card">
73
         <div class="card-header">Tempo impiegato</div>
73
         <div class="card-header">Tempo impiegato</div>
74
         <div class="card-body">
74
         <div class="card-body">
75
+          <?php
76
+          $sum_ore_onsite = 0;
77
+          ?>
75
           <h4>On Site</h4>
78
           <h4>On Site</h4>
76
           @if($tempoImpiegatoOnSite->count() == 0)
79
           @if($tempoImpiegatoOnSite->count() == 0)
77
           <i>Nessun tempo registrato</i>
80
           <i>Nessun tempo registrato</i>
78
           @else
81
           @else
79
 
82
 
80
-          <?php
81
-          $sum_ore_onsite = 0;
82
-          ?>
83
+
83
           <ul>
84
           <ul>
84
             @foreach($tempoImpiegatoOnSite as $tempo)
85
             @foreach($tempoImpiegatoOnSite as $tempo)
85
             <li style="list-style-type: disc; margin: unset;">
86
             <li style="list-style-type: disc; margin: unset;">
94
           @endif
95
           @endif
95
 
96
 
96
           <h4 class="mt-3">Remota</h4>
97
           <h4 class="mt-3">Remota</h4>
98
+          <?php
99
+          $sum_ore_remota = 0;
100
+          ?>
97
           @if($tempoImpiegatoRemota->count() == 0)
101
           @if($tempoImpiegatoRemota->count() == 0)
98
           <i>Nessun tempo registrato</i>
102
           <i>Nessun tempo registrato</i>
99
           @else
103
           @else
100
 
104
 
101
-          <?php
102
-          $sum_ore_remota = 0;
103
-          ?>
105
+
104
 
106
 
105
           <ul>
107
           <ul>
106
             @foreach($tempoImpiegatoRemota as $tempo)
108
             @foreach($tempoImpiegatoRemota as $tempo)

+ 11
- 1
resources/views/user/progetti.blade.php View File

14
     {!! Form::open(['method' => 'POST', 'route' => ['user.progetti']]) !!}
14
     {!! Form::open(['method' => 'POST', 'route' => ['user.progetti']]) !!}
15
     {!! Form::hidden('user_id', $user->id) !!}
15
     {!! Form::hidden('user_id', $user->id) !!}
16
 
16
 
17
+    <!-- Prima i progetti con flag -->
18
+
19
+    @foreach($progettiUser as $progetto)
20
+    <div class="form-row">
21
+      <div class="form-group col">
22
+        {!! Form::checkbox('progetto[]', $progetto->id, true, ['class' => '']) !!} {{ $progetto->name }}
23
+      </div>
24
+    </div>
25
+    @endforeach
26
+
17
     @foreach($progetti as $progetto)
27
     @foreach($progetti as $progetto)
18
     <div class="form-row">
28
     <div class="form-row">
19
       <div class="form-group col">
29
       <div class="form-group col">
20
-        {!! Form::checkbox('progetto[]', $progetto->id, $checked!=null?in_array($progetto->id, $checked):false, ['class' => '']) !!} {{ $progetto->name }}
30
+        {!! Form::checkbox('progetto[]', $progetto->id, false, ['class' => '']) !!} {{ $progetto->name }}
21
       </div>
31
       </div>
22
     </div>
32
     </div>
23
     @endforeach
33
     @endforeach

+ 0
- 12
resources/views/user/roles.blade.php View File

19
           @endforeach
19
           @endforeach
20
         </ul>
20
         </ul>
21
 
21
 
22
-        <!-- <h2 style="margin-top: 40px;">Permessi diretti assegnati all'utente</h2>
23
-        <hr>
24
-
25
-        @foreach(Permission::select('permissions.*')->groupBy('group')->orderBy('group', 'ASC')->get() as $group)
26
-        <h4>{{ $group->group }}</h4>
27
-        <ul style="list-style-type:none">
28
-          @foreach(Permission::where('group', $group->group)->orderBy('name', 'ASC')->get() as $permission)
29
-          <li>{!! Form::checkbox('permesso[]', $permission->id, $user->hasDirectPermission($permission->name), ['class' => '']) !!} {{ $permission->display_name }}</li>
30
-          @endforeach
31
-        </ul>
32
-        @endforeach -->
33
-
34
         {!! Form::submit('Salva', ['class' => 'btn btn-primary form-control']) !!}
22
         {!! Form::submit('Salva', ['class' => 'btn btn-primary form-control']) !!}
35
         {!! Form::close() !!}
23
         {!! Form::close() !!}
36
 
24
 

+ 1
- 1
routes/web.php View File

35
   Route::post('user/updateRole', [UserController::class, 'updateRole'])->name('user.updateRole');
35
   Route::post('user/updateRole', [UserController::class, 'updateRole'])->name('user.updateRole');
36
 
36
 
37
   Route::get('issue', [IssueController::class, 'index'])->name('issue.index');
37
   Route::get('issue', [IssueController::class, 'index'])->name('issue.index');
38
-  Route::get('issue/{id?}/show', [IssueController::class, 'show'])->name('issue.show');
38
+  Route::get('issue/show', [IssueController::class, 'show'])->name('issue.show');
39
   Route::get('issue/nuovo', [IssueController::class, 'nuovo'])->name('issue.nuovo');
39
   Route::get('issue/nuovo', [IssueController::class, 'nuovo'])->name('issue.nuovo');
40
   Route::post('issue/crea', [IssueController::class, 'crea'])->name('issue.crea');
40
   Route::post('issue/crea', [IssueController::class, 'crea'])->name('issue.crea');
41
   Route::get('attachment/{id?}/download', [IssueController::class, 'download'])->name('attachment.download');
41
   Route::get('attachment/{id?}/download', [IssueController::class, 'download'])->name('attachment.download');

Loading…
Cancel
Save