Roberto Santini 3 år sedan
förälder
incheckning
f00c2a722c

+ 1
- 1
app/DataTables/IssueDataTable.php Visa fil

@@ -36,7 +36,7 @@ class IssueDataTable extends DataTable
36 36
       }
37 37
     })
38 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 40
       return $button;
41 41
       return view('issue.menu', ['entity' => $entity]);
42 42
     });

+ 27
- 23
app/Http/Controllers/ConfigController.php Visa fil

@@ -30,36 +30,40 @@ class ConfigController extends Controller
30 30
 
31 31
     foreach($input['key'] as $key => $value){
32 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 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 69
     Session::flash('flash_message', 'Configurazione aggiornata');

+ 4
- 4
app/Http/Controllers/IssueController.php Visa fil

@@ -39,17 +39,17 @@ class IssueController extends Controller
39 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 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 47
       'key' => $redmineUser->api_key,
48 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 53
       'key' => $redmineUser->api_key,
54 54
     ]);
55 55
 
@@ -103,7 +103,7 @@ class IssueController extends Controller
103 103
       'telefono' => 'required|string|max:255',
104 104
       'description' => 'required',
105 105
       'accetto_condizioni' =>'accepted',
106
-      'allegato' => 'size:5000'
106
+      'allegato' => 'size:10000'
107 107
     ];
108 108
 
109 109
     $request->validate($rules, $this->messages);

+ 21
- 4
app/Http/Controllers/UserController.php Visa fil

@@ -106,19 +106,36 @@ class UserController extends Controller
106 106
 
107 107
   public function load_progetti(Request $request){
108 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 120
     $projectResponse = Http::get(config('redmine.url').'/projects.json', [
112 121
       'key' => $redmineUser->api_key,
113 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 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 141
   public function update_progetti(Request $request){

+ 7
- 3
app/Models/Config.php Visa fil

@@ -5,13 +5,17 @@ use Storage;
5 5
 class Config extends \App\Models\AbstractModels\AbstractConfig
6 6
 {
7 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 12
   public static function getConfig(){
12 13
     $config = [];
13 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 21
     return $config;

+ 33
- 1
app/Models/Issue.php Visa fil

@@ -56,7 +56,7 @@ class Issue{
56 56
     $issueResponse = Http::get(config('redmine.url').'/time_entries.json', [
57 57
       'key' => $redmineUser->api_key,
58 58
       'issue_id' => $issue_id,
59
-      'cf_2' => 'Si', // Custom fields "fatturare"
59
+      'cf_'.Config::getValue(Config::CAMPO_FATTURARE) => 'Si', // Custom fields "fatturare"
60 60
       'activity_id' => $attivita
61 61
 
62 62
     ]);
@@ -87,4 +87,36 @@ class Issue{
87 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 Visa fil

@@ -23,8 +23,8 @@ class ConfigSeeder extends Seeder
23 23
           $config->order = $order;
24 24
           $config->group = $key;
25 25
           $config->save();
26
-          $order++;
27 26
         }
27
+        $order++;
28 28
       }
29 29
     }
30 30
   }

+ 6
- 8
resources/views/config/index.blade.php Visa fil

@@ -68,14 +68,12 @@ thead select{
68 68
               ?>
69 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 77
               @break
80 78
 
81 79
               @case('file')

+ 1
- 1
resources/views/issue/index.blade.php Visa fil

@@ -37,7 +37,7 @@ $(document).ready(function(){
37 37
   $("#dataTable_issues").attr('width', '100%');
38 38
 
39 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 43
 </script>

+ 0
- 11
resources/views/issue/menu.blade.php Visa fil

@@ -1,11 +0,0 @@
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 Visa fil

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

+ 10
- 8
resources/views/issue/show.blade.php Visa fil

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

+ 11
- 1
resources/views/user/progetti.blade.php Visa fil

@@ -14,10 +14,20 @@ $checked = json_decode($user->progetti);
14 14
     {!! Form::open(['method' => 'POST', 'route' => ['user.progetti']]) !!}
15 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 27
     @foreach($progetti as $progetto)
18 28
     <div class="form-row">
19 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 31
       </div>
22 32
     </div>
23 33
     @endforeach

+ 0
- 12
resources/views/user/roles.blade.php Visa fil

@@ -19,18 +19,6 @@ use App\Models\Role;
19 19
           @endforeach
20 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 22
         {!! Form::submit('Salva', ['class' => 'btn btn-primary form-control']) !!}
35 23
         {!! Form::close() !!}
36 24
 

+ 1
- 1
routes/web.php Visa fil

@@ -35,7 +35,7 @@ Route::middleware(['auth', 'verified'])->group(function () {
35 35
   Route::post('user/updateRole', [UserController::class, 'updateRole'])->name('user.updateRole');
36 36
 
37 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 39
   Route::get('issue/nuovo', [IssueController::class, 'nuovo'])->name('issue.nuovo');
40 40
   Route::post('issue/crea', [IssueController::class, 'crea'])->name('issue.crea');
41 41
   Route::get('attachment/{id?}/download', [IssueController::class, 'download'])->name('attachment.download');

Laddar…
Avbryt
Spara