Parcourir la source

custom fields e grafica

Roberto Santini il y a 3 ans
Parent
révision
483aa2d425

+ 1
- 0
app/Console/Kernel.php Voir le fichier

@@ -16,6 +16,7 @@ class Kernel extends ConsoleKernel
16 16
     protected function schedule(Schedule $schedule)
17 17
     {
18 18
         // $schedule->command('inspire')->hourly();
19
+        $schedule->command('auth:clear-resets')->everyFifteenMinutes();
19 20
     }
20 21
 
21 22
     /**

+ 36
- 0
app/Http/Controllers/IssueController.php Voir le fichier

@@ -181,6 +181,12 @@ class IssueController extends Controller
181 181
     $descrizione .= "Descrizione problema: ".$request->description;
182 182
 
183 183
 
184
+    $customFields = [];
185
+    if($request->has('cf')){
186
+      foreach($request->cf as $key => $value){
187
+        $customFields[] = ['id' => $key, 'value' => $value];
188
+      }
189
+    }
184 190
     $response = Http::acceptJson()->post("https://".config('redmine.url').'/issues.xml', [
185 191
       'key' => $redmineUser->api_key,
186 192
       'customer_address' => $contact_id,
@@ -190,6 +196,7 @@ class IssueController extends Controller
190 196
         'subject' => $request->subject,
191 197
         'description' => $descrizione,
192 198
         'uploads' => $uploads,
199
+        'custom_fields' => $customFields
193 200
       ],
194 201
     ]);
195 202
 
@@ -201,4 +208,33 @@ class IssueController extends Controller
201 208
     Session::flash('flash_message', "Grazie, abbiamo ricevuto la tua segnalazione!");
202 209
     return redirect()->route('dashboard');
203 210
   }
211
+
212
+  public function load_custom_fields(Request $request){
213
+    $redmineUser = session('redmine_user');
214
+    $customCollection = new Collection();
215
+
216
+    $projectResponse = Http::get(config('redmine.url').'/projects.json', [
217
+      'key' => $redmineUser->api_key,
218
+      'id' => $request->project_id,
219
+      'include' => 'issue_custom_fields'
220
+    ]);
221
+
222
+
223
+    foreach($projectResponse->object()->projects as $project){
224
+      foreach($project->issue_custom_fields as $issue_custom_field){
225
+        $response = Http::get(config('redmine.url').'/custom_fields.json', [
226
+          'key' => $redmineUser->api_key,
227
+        ]);
228
+
229
+        foreach($response->object()->custom_fields as $custom_field){
230
+          if($custom_field->id == $issue_custom_field->id){
231
+            $customCollection->push($custom_field);
232
+          }
233
+        }
234
+
235
+      }
236
+    }
237
+
238
+    return view('issue.custom_field')->with(['customCollection' => $customCollection]);
239
+  }
204 240
 }

+ 17
- 1
app/Models/Issue.php Voir le fichier

@@ -61,9 +61,23 @@ class Issue{
61 61
 
62 62
     ]);
63 63
 
64
+    $last_date = null;
64 65
     try{
65 66
       foreach($issueResponse->object()->time_entries as $time){
66
-        $collection->push($time);
67
+        // $collection->push($time);
68
+        if($last_date == null){
69
+          $last_date = $time;
70
+        }else{
71
+          if($last_date->spent_on == $time->spent_on){
72
+            $last_date->hours += $time->hours;
73
+          }else{
74
+            $collection->push($last_date);
75
+            $last_date = $time;
76
+          }
77
+        }
78
+      }
79
+      if($last_date != null){
80
+        $collection->push($last_date);
67 81
       }
68 82
     }catch(\Exception $e){
69 83
     }
@@ -111,6 +125,8 @@ class Issue{
111 125
       'customized_type' => 'time_entry'
112 126
     ]);
113 127
 
128
+    // dd($response->object()->custom_fields);
129
+
114 130
     $custom = array();
115 131
     foreach($response->object()->custom_fields as $custom_field){
116 132
       $custom[$custom_field->id] = $custom_field->name;

+ 1
- 1
app/Notifications/ResetPasswordNotification.php Voir le fichier

@@ -45,7 +45,7 @@ class ResetPasswordNotification extends Notification
45 45
     ->subject('Reset password')
46 46
     ->line('Hai ricevuto questa email perché abbiamo ricevuto una richiesta di reimpostazione della password per il tuo account.')
47 47
     ->action('Reset Password', $this->url)
48
-    ->line('Questo link per la reimpostazione della password scadrà tra :count minuti.', ['count' => config('auth.passwords.'.config('auth.defaults.passwords').'.expire')])
48
+    ->line("Questo link per la reimpostazione della password scadrà tra ".config('auth.passwords.'.config('auth.defaults.passwords').'.expire')." minuti.")
49 49
     ->line('Se non hai richiesto la reimpostazione della password, non sono necessarie ulteriori azioni.');
50 50
   }
51 51
 

+ 1
- 1
resources/views/auth/confirm-password.blade.php Voir le fichier

@@ -2,7 +2,7 @@
2 2
     <x-auth-card>
3 3
         <x-slot name="logo">
4 4
             <a href="/">
5
-                <x-application-logo class="w-20 h-20 fill-current text-gray-500" />
5
+                <x-application-logo class="h-20 fill-current text-gray-500" />
6 6
             </a>
7 7
         </x-slot>
8 8
 

+ 2
- 2
resources/views/auth/forgot-password.blade.php Voir le fichier

@@ -2,7 +2,7 @@
2 2
     <x-auth-card>
3 3
         <x-slot name="logo">
4 4
             <a href="/">
5
-                <x-application-logo class="w-20 h-20 fill-current text-gray-500" />
5
+                <x-application-logo class="h-20 fill-current text-gray-500" />
6 6
             </a>
7 7
         </x-slot>
8 8
 
@@ -28,7 +28,7 @@
28 28
 
29 29
             <div class="flex items-center justify-end mt-4">
30 30
                 <x-button>
31
-                    {{ __('Invia lik di reset password') }}
31
+                    {{ __('Invia link di reset password') }}
32 32
                 </x-button>
33 33
             </div>
34 34
         </form>

+ 1
- 1
resources/views/auth/reset-password.blade.php Voir le fichier

@@ -2,7 +2,7 @@
2 2
     <x-auth-card>
3 3
         <x-slot name="logo">
4 4
             <a href="/">
5
-                <x-application-logo class="w-20 h-20 fill-current text-gray-500" />
5
+                <x-application-logo class="h-20 fill-current text-gray-500" />
6 6
             </a>
7 7
         </x-slot>
8 8
 

+ 1
- 1
resources/views/auth/verify-email.blade.php Voir le fichier

@@ -2,7 +2,7 @@
2 2
     <x-auth-card>
3 3
         <x-slot name="logo">
4 4
             <a href="/">
5
-                <x-application-logo class="w-20 h-20 fill-current text-gray-500" />
5
+                <x-application-logo class="h-20 fill-current text-gray-500" />
6 6
             </a>
7 7
         </x-slot>
8 8
 

+ 39
- 0
resources/views/issue/custom_field.blade.php Voir le fichier

@@ -0,0 +1,39 @@
1
+@foreach($customCollection as $custom)
2
+<div class="form-group col-md-6">
3
+  {!! Form::label('label_'.$custom->id, $custom->name) !!}
4
+  @switch($custom->field_format)
5
+
6
+  @case('string')
7
+  {!! Form::text('cf['.$custom->id.']', null, ['class' => 'form-control']) !!}
8
+  @break
9
+  @endcase
10
+
11
+  @case('sql')
12
+  <select class="form-control" name="cf[{{$custom->id}}]">
13
+    @foreach($custom->possible_values as $values)
14
+    <option id="{{ $values->value}}">{{ $values->label}}</option>
15
+    @endforeach
16
+  </select>
17
+  @break
18
+  @endcase
19
+
20
+  @case('list')
21
+  <select class="form-control" name="cf[{{$custom->id}}]">
22
+    @foreach($custom->possible_values as $values)
23
+    <option id="{{ $values->value}}">{{ $values->label}}</option>
24
+    @endforeach
25
+  </select>
26
+  @break
27
+  @endcase
28
+
29
+  @case('bool')
30
+  {!! Form::radio('cf['.$custom->id.']', 1, null, ['class' => '']) !!} SI
31
+  {!! Form::radio('cf['.$custom->id.']', 0, null, ['class' => '']) !!} NO
32
+  @break
33
+  @endcase
34
+
35
+  @endswitch
36
+
37
+
38
+</div>
39
+@endforeach

+ 43
- 16
resources/views/issue/nuovo.blade.php Voir le fichier

@@ -14,6 +14,8 @@ $projectResponse = Http::get(config('redmine.url').'/projects.json', [
14 14
   'id' => implode('|', $progettiUser)
15 15
 ]);
16 16
 
17
+// dd($projectResponse->object()->projects);
18
+
17 19
 foreach($projectResponse->object()->projects as $project){
18 20
   $progettiCollection->push($project);
19 21
 }
@@ -41,19 +43,20 @@ foreach($projectResponse->object()->projects as $project){
41 43
           {!! Form::open(['route' => 'issue.crea', 'files' => true]) !!}
42 44
 
43 45
           <div class="form-row">
44
-          @if($progettiCollection->count() > 1)
45
-            <div class="form-group col-md">
46
-              {!! Form::label('project_id', 'Progetto') !!}
47
-              {!! Form::select('project_id', $progettiCollection->pluck('name', 'id'), old('project_id'), ['class' => 'form-control']) !!}
48
-            </div>
49
-          @else
50
-          {!! Form::hidden('project_id', $progettiCollection->first()->id) !!}
51
-          @endif
52
-
53 46
           <div class="form-group col-md">
54 47
             {!! Form::label('tipo_richiesta', 'Tipologia di richiesta') !!}
55 48
             {!! Form::select('tipo_richiesta', Issue::tipologiaRichieste(), old('tipo_richiesta'), ['class' => 'form-control']) !!}
56 49
           </div>
50
+
51
+          <div class="form-group col-md">
52
+            {!! Form::label('referente', 'Referente per la problematica') !!}
53
+            {!! Form::text('referente', old('referente'), ['class' => 'form-control']) !!}
54
+          </div>
55
+
56
+          <div class="form-group col-md">
57
+            {!! Form::label('telefono', 'Numero di telefono') !!}
58
+            {!! Form::text('telefono', old('telefono'), ['class' => 'form-control']) !!}
59
+          </div>
57 60
         </div>
58 61
 
59 62
           <div class="form-row">
@@ -61,16 +64,23 @@ foreach($projectResponse->object()->projects as $project){
61 64
               {!! Form::label('subject', 'Oggetto') !!}
62 65
               {!! Form::text('subject', old('subject'), ['class' => 'form-control']) !!}
63 66
             </div>
67
+          </div>
64 68
 
65
-            <div class="form-group col-md">
66
-              {!! Form::label('referente', 'Referente per la problematica') !!}
67
-              {!! Form::text('referente', old('referente'), ['class' => 'form-control']) !!}
69
+          <div class="form-row">
70
+            @if($progettiCollection->count() > 1)
71
+              <div class="form-group col-md-4">
72
+                {!! Form::label('project_id', 'Progetto') !!}
73
+                {!! Form::select('project_id', $progettiCollection->pluck('name', 'id'), old('project_id'), ['class' => 'form-control', 'onchange' => 'load_custom_fields(this)']) !!}
74
+              </div>
75
+            @else
76
+            {!! Form::hidden('project_id', $progettiCollection->first()->id) !!}
77
+            @endif
78
+
79
+            <div class="form-group col-md-8">
80
+              <div class="form-row" id="custom_fields">
81
+              </div>
68 82
             </div>
69 83
 
70
-            <div class="form-group col-md">
71
-              {!! Form::label('telefono', 'Numero di telefono') !!}
72
-              {!! Form::text('telefono', old('telefono'), ['class' => 'form-control']) !!}
73
-            </div>
74 84
           </div>
75 85
 
76 86
           <div class="form-row">
@@ -110,3 +120,20 @@ foreach($projectResponse->object()->projects as $project){
110 120
 
111 121
 
112 122
 </x-app-layout>
123
+
124
+<script>
125
+$(document).ready(function(){
126
+  $.ajaxSetup({
127
+    headers: {
128
+      'X-CSRF-TOKEN': '{{csrf_token()}}'
129
+    }
130
+  });
131
+
132
+  load_custom_fields("[name='project_id']");
133
+});
134
+
135
+
136
+function load_custom_fields(select){
137
+  $('#custom_fields').load("{{ route('issue.load_custom_fields') }}?project_id="+$(select).val());
138
+}
139
+</script>

+ 34
- 18
resources/views/issue/show.blade.php Voir le fichier

@@ -8,6 +8,15 @@ $tempoImpiegatoRemota = Issue::getTempoImpiegato($issue->id, Config::getValue(Co
8 8
 ?>
9 9
 
10 10
 <style>
11
+.divData {
12
+  width: 100%;
13
+  font-weight: bold;
14
+  text-align: center;
15
+  background-color: #DCDCDC;
16
+  border-radius: 5px;
17
+  padding: 5px;
18
+  margin-bottom: 5px;
19
+}
11 20
 </style>
12 21
 
13 22
 <x-app-layout>
@@ -18,30 +27,30 @@ $tempoImpiegatoRemota = Issue::getTempoImpiegato($issue->id, Config::getValue(Co
18 27
   </x-slot>
19 28
 
20 29
   <div class="row justify-content-center mb-4">
21
-    <div class="col-xl-10 col-lg-12 col-md px-md-3 px-2">
30
+    <div class="col-xl-12 col-lg-12 col-md px-md-3 px-2">
22 31
       <div class="card">
23 32
         <div class="card-body">
24 33
 
25 34
           <div class="form-row">
26
-            <div class="form-group col-md">
35
+            <div class="form-group col-md border mr-2 p-2" >
27 36
               {!! Form::label('subject', 'Oggetto') !!}
28 37
               {!! $issue->subject !!}
29 38
             </div>
30 39
 
31
-            <div class="form-group col-md">
40
+            <div class="form-group col-md border mx-2 p-2">
32 41
               {!! Form::label('author', 'Autore') !!}
33 42
               {!! $author !!}
34 43
             </div>
35 44
 
36
-            <div class="form-group col-md">
45
+            <div class="form-group col-md border ml-2 p-2">
37 46
               {!! Form::label('created_on', 'Data') !!}
38 47
               {!! Carbon::parse($issue->created_on)->timezone(config('app.timezone'))->format('d/m/Y H:i') !!}
39 48
             </div>
40 49
           </div>
41 50
 
42 51
           <div class="form-row">
43
-            <div class="form-group col-md">
44
-              {!! Form::label('description', 'Descrizione') !!}
52
+            <div class="form-group col-md border p-2">
53
+              {!! Form::label('description', 'Descrizione della problematica') !!}
45 54
               {!! $issue->description !!}
46 55
             </div>
47 56
           </div>
@@ -54,12 +63,14 @@ $tempoImpiegatoRemota = Issue::getTempoImpiegato($issue->id, Config::getValue(Co
54 63
   <div class="row justify-content-center mb-4">
55 64
     <div class="col-xl-6 col-md px-md-3 px-2">
56 65
       <div class="card">
57
-        <div class="card-header">Cronologia</div>
66
+        <div class="card-header"><label>Interventi di assistenza</label></div>
58 67
         <div class="card-body">
59 68
           @foreach($issue->journals as $journal)
60 69
           @if($journal->notes != '' && !$journal->private_notes)
61 70
           <div class="mb-2">
62
-            <b>{{ Carbon::parse($journal->created_on)->timezone(config('app.timezone'))->format('d/m/Y H:i') }}</b><br>
71
+            <div class="divData">
72
+              <i class="fas fa-calendar-day"></i> {{ Carbon::parse($journal->created_on)->timezone(config('app.timezone'))->format('d/m/Y H:i') }}
73
+            </div>
63 74
             {!! $journal->notes !!}
64 75
           </div>
65 76
           @endif
@@ -70,12 +81,14 @@ $tempoImpiegatoRemota = Issue::getTempoImpiegato($issue->id, Config::getValue(Co
70 81
 
71 82
     <div class="col-xl-3 col-md px-md-3 px-2">
72 83
       <div class="card">
73
-        <div class="card-header">Tempo impiegato</div>
84
+        <div class="card-header"><label>Tempo impiegato</label></div>
74 85
         <div class="card-body">
75 86
           <?php
76 87
           $sum_ore_onsite = 0;
77 88
           ?>
78
-          <h4>On Site</h4>
89
+          <div class="divData">
90
+            On Site
91
+          </div>
79 92
           @if($tempoImpiegatoOnSite->count() == 0)
80 93
           <i>Nessun tempo registrato</i>
81 94
           @else
@@ -94,7 +107,10 @@ $tempoImpiegatoRemota = Issue::getTempoImpiegato($issue->id, Config::getValue(Co
94 107
           <b>Totale ore onsite: </b> {{ $sum_ore_onsite }}h
95 108
           @endif
96 109
 
97
-          <h4 class="mt-3">Remota</h4>
110
+          <div class="divData mt-3">
111
+            Remota
112
+          </div>
113
+
98 114
           <?php
99 115
           $sum_ore_remota = 0;
100 116
           ?>
@@ -122,15 +138,15 @@ $tempoImpiegatoRemota = Issue::getTempoImpiegato($issue->id, Config::getValue(Co
122 138
 
123 139
     <div class="col-xl-3 col-md px-md-3 px-2">
124 140
       <div class="card">
125
-        <div class="card-header">Allegati</div>
141
+        <div class="card-header"><label>Allegati</label></div>
126 142
         <div class="card-body">
127 143
           <ul>
128
-          @foreach($issue->attachments as $attachment)
129
-          <li>
130
-            <a href="{{ route('attachment.download', ['id' => $attachment->id]) }}?filename={{ $attachment->filename }}">{{ $attachment->filename }}</a>
131
-          </li>
132
-          @endforeach
133
-        </ul>
144
+            @foreach($issue->attachments as $attachment)
145
+            <li>
146
+              <a href="{{ route('attachment.download', ['id' => $attachment->id]) }}?filename={{ $attachment->filename }}">{{ $attachment->filename }}</a>
147
+            </li>
148
+            @endforeach
149
+          </ul>
134 150
         </div>
135 151
       </div>
136 152
     </div>

+ 1
- 0
routes/web.php Voir le fichier

@@ -36,6 +36,7 @@ Route::middleware(['auth', 'verified'])->group(function () {
36 36
 
37 37
   Route::get('issue', [IssueController::class, 'index'])->name('issue.index');
38 38
   Route::get('issue/show', [IssueController::class, 'show'])->name('issue.show');
39
+  Route::get('issue/load_custom_fields', [IssueController::class, 'load_custom_fields'])->name('issue.load_custom_fields');
39 40
   Route::get('issue/nuovo', [IssueController::class, 'nuovo'])->name('issue.nuovo');
40 41
   Route::post('issue/crea', [IssueController::class, 'crea'])->name('issue.crea');
41 42
   Route::get('attachment/{id?}/download', [IssueController::class, 'download'])->name('attachment.download');

Chargement…
Annuler
Enregistrer