Explorar el Código

custom fields e grafica

Roberto Santini hace 3 años
padre
commit
483aa2d425

+ 1
- 0
app/Console/Kernel.php Ver fichero

16
     protected function schedule(Schedule $schedule)
16
     protected function schedule(Schedule $schedule)
17
     {
17
     {
18
         // $schedule->command('inspire')->hourly();
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 Ver fichero

181
     $descrizione .= "Descrizione problema: ".$request->description;
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
     $response = Http::acceptJson()->post("https://".config('redmine.url').'/issues.xml', [
190
     $response = Http::acceptJson()->post("https://".config('redmine.url').'/issues.xml', [
185
       'key' => $redmineUser->api_key,
191
       'key' => $redmineUser->api_key,
186
       'customer_address' => $contact_id,
192
       'customer_address' => $contact_id,
190
         'subject' => $request->subject,
196
         'subject' => $request->subject,
191
         'description' => $descrizione,
197
         'description' => $descrizione,
192
         'uploads' => $uploads,
198
         'uploads' => $uploads,
199
+        'custom_fields' => $customFields
193
       ],
200
       ],
194
     ]);
201
     ]);
195
 
202
 
201
     Session::flash('flash_message', "Grazie, abbiamo ricevuto la tua segnalazione!");
208
     Session::flash('flash_message', "Grazie, abbiamo ricevuto la tua segnalazione!");
202
     return redirect()->route('dashboard');
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 Ver fichero

61
 
61
 
62
     ]);
62
     ]);
63
 
63
 
64
+    $last_date = null;
64
     try{
65
     try{
65
       foreach($issueResponse->object()->time_entries as $time){
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
     }catch(\Exception $e){
82
     }catch(\Exception $e){
69
     }
83
     }
111
       'customized_type' => 'time_entry'
125
       'customized_type' => 'time_entry'
112
     ]);
126
     ]);
113
 
127
 
128
+    // dd($response->object()->custom_fields);
129
+
114
     $custom = array();
130
     $custom = array();
115
     foreach($response->object()->custom_fields as $custom_field){
131
     foreach($response->object()->custom_fields as $custom_field){
116
       $custom[$custom_field->id] = $custom_field->name;
132
       $custom[$custom_field->id] = $custom_field->name;

+ 1
- 1
app/Notifications/ResetPasswordNotification.php Ver fichero

45
     ->subject('Reset password')
45
     ->subject('Reset password')
46
     ->line('Hai ricevuto questa email perché abbiamo ricevuto una richiesta di reimpostazione della password per il tuo account.')
46
     ->line('Hai ricevuto questa email perché abbiamo ricevuto una richiesta di reimpostazione della password per il tuo account.')
47
     ->action('Reset Password', $this->url)
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
     ->line('Se non hai richiesto la reimpostazione della password, non sono necessarie ulteriori azioni.');
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 Ver fichero

2
     <x-auth-card>
2
     <x-auth-card>
3
         <x-slot name="logo">
3
         <x-slot name="logo">
4
             <a href="/">
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
             </a>
6
             </a>
7
         </x-slot>
7
         </x-slot>
8
 
8
 

+ 2
- 2
resources/views/auth/forgot-password.blade.php Ver fichero

2
     <x-auth-card>
2
     <x-auth-card>
3
         <x-slot name="logo">
3
         <x-slot name="logo">
4
             <a href="/">
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
             </a>
6
             </a>
7
         </x-slot>
7
         </x-slot>
8
 
8
 
28
 
28
 
29
             <div class="flex items-center justify-end mt-4">
29
             <div class="flex items-center justify-end mt-4">
30
                 <x-button>
30
                 <x-button>
31
-                    {{ __('Invia lik di reset password') }}
31
+                    {{ __('Invia link di reset password') }}
32
                 </x-button>
32
                 </x-button>
33
             </div>
33
             </div>
34
         </form>
34
         </form>

+ 1
- 1
resources/views/auth/reset-password.blade.php Ver fichero

2
     <x-auth-card>
2
     <x-auth-card>
3
         <x-slot name="logo">
3
         <x-slot name="logo">
4
             <a href="/">
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
             </a>
6
             </a>
7
         </x-slot>
7
         </x-slot>
8
 
8
 

+ 1
- 1
resources/views/auth/verify-email.blade.php Ver fichero

2
     <x-auth-card>
2
     <x-auth-card>
3
         <x-slot name="logo">
3
         <x-slot name="logo">
4
             <a href="/">
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
             </a>
6
             </a>
7
         </x-slot>
7
         </x-slot>
8
 
8
 

+ 39
- 0
resources/views/issue/custom_field.blade.php Ver fichero

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 Ver fichero

14
   'id' => implode('|', $progettiUser)
14
   'id' => implode('|', $progettiUser)
15
 ]);
15
 ]);
16
 
16
 
17
+// dd($projectResponse->object()->projects);
18
+
17
 foreach($projectResponse->object()->projects as $project){
19
 foreach($projectResponse->object()->projects as $project){
18
   $progettiCollection->push($project);
20
   $progettiCollection->push($project);
19
 }
21
 }
41
           {!! Form::open(['route' => 'issue.crea', 'files' => true]) !!}
43
           {!! Form::open(['route' => 'issue.crea', 'files' => true]) !!}
42
 
44
 
43
           <div class="form-row">
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
           <div class="form-group col-md">
46
           <div class="form-group col-md">
54
             {!! Form::label('tipo_richiesta', 'Tipologia di richiesta') !!}
47
             {!! Form::label('tipo_richiesta', 'Tipologia di richiesta') !!}
55
             {!! Form::select('tipo_richiesta', Issue::tipologiaRichieste(), old('tipo_richiesta'), ['class' => 'form-control']) !!}
48
             {!! Form::select('tipo_richiesta', Issue::tipologiaRichieste(), old('tipo_richiesta'), ['class' => 'form-control']) !!}
56
           </div>
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
         </div>
60
         </div>
58
 
61
 
59
           <div class="form-row">
62
           <div class="form-row">
61
               {!! Form::label('subject', 'Oggetto') !!}
64
               {!! Form::label('subject', 'Oggetto') !!}
62
               {!! Form::text('subject', old('subject'), ['class' => 'form-control']) !!}
65
               {!! Form::text('subject', old('subject'), ['class' => 'form-control']) !!}
63
             </div>
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
             </div>
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
           </div>
84
           </div>
75
 
85
 
76
           <div class="form-row">
86
           <div class="form-row">
110
 
120
 
111
 
121
 
112
 </x-app-layout>
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 Ver fichero

8
 ?>
8
 ?>
9
 
9
 
10
 <style>
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
 </style>
20
 </style>
12
 
21
 
13
 <x-app-layout>
22
 <x-app-layout>
18
   </x-slot>
27
   </x-slot>
19
 
28
 
20
   <div class="row justify-content-center mb-4">
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
       <div class="card">
31
       <div class="card">
23
         <div class="card-body">
32
         <div class="card-body">
24
 
33
 
25
           <div class="form-row">
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
               {!! Form::label('subject', 'Oggetto') !!}
36
               {!! Form::label('subject', 'Oggetto') !!}
28
               {!! $issue->subject !!}
37
               {!! $issue->subject !!}
29
             </div>
38
             </div>
30
 
39
 
31
-            <div class="form-group col-md">
40
+            <div class="form-group col-md border mx-2 p-2">
32
               {!! Form::label('author', 'Autore') !!}
41
               {!! Form::label('author', 'Autore') !!}
33
               {!! $author !!}
42
               {!! $author !!}
34
             </div>
43
             </div>
35
 
44
 
36
-            <div class="form-group col-md">
45
+            <div class="form-group col-md border ml-2 p-2">
37
               {!! Form::label('created_on', 'Data') !!}
46
               {!! Form::label('created_on', 'Data') !!}
38
               {!! Carbon::parse($issue->created_on)->timezone(config('app.timezone'))->format('d/m/Y H:i') !!}
47
               {!! Carbon::parse($issue->created_on)->timezone(config('app.timezone'))->format('d/m/Y H:i') !!}
39
             </div>
48
             </div>
40
           </div>
49
           </div>
41
 
50
 
42
           <div class="form-row">
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
               {!! $issue->description !!}
54
               {!! $issue->description !!}
46
             </div>
55
             </div>
47
           </div>
56
           </div>
54
   <div class="row justify-content-center mb-4">
63
   <div class="row justify-content-center mb-4">
55
     <div class="col-xl-6 col-md px-md-3 px-2">
64
     <div class="col-xl-6 col-md px-md-3 px-2">
56
       <div class="card">
65
       <div class="card">
57
-        <div class="card-header">Cronologia</div>
66
+        <div class="card-header"><label>Interventi di assistenza</label></div>
58
         <div class="card-body">
67
         <div class="card-body">
59
           @foreach($issue->journals as $journal)
68
           @foreach($issue->journals as $journal)
60
           @if($journal->notes != '' && !$journal->private_notes)
69
           @if($journal->notes != '' && !$journal->private_notes)
61
           <div class="mb-2">
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
             {!! $journal->notes !!}
74
             {!! $journal->notes !!}
64
           </div>
75
           </div>
65
           @endif
76
           @endif
70
 
81
 
71
     <div class="col-xl-3 col-md px-md-3 px-2">
82
     <div class="col-xl-3 col-md px-md-3 px-2">
72
       <div class="card">
83
       <div class="card">
73
-        <div class="card-header">Tempo impiegato</div>
84
+        <div class="card-header"><label>Tempo impiegato</label></div>
74
         <div class="card-body">
85
         <div class="card-body">
75
           <?php
86
           <?php
76
           $sum_ore_onsite = 0;
87
           $sum_ore_onsite = 0;
77
           ?>
88
           ?>
78
-          <h4>On Site</h4>
89
+          <div class="divData">
90
+            On Site
91
+          </div>
79
           @if($tempoImpiegatoOnSite->count() == 0)
92
           @if($tempoImpiegatoOnSite->count() == 0)
80
           <i>Nessun tempo registrato</i>
93
           <i>Nessun tempo registrato</i>
81
           @else
94
           @else
94
           <b>Totale ore onsite: </b> {{ $sum_ore_onsite }}h
107
           <b>Totale ore onsite: </b> {{ $sum_ore_onsite }}h
95
           @endif
108
           @endif
96
 
109
 
97
-          <h4 class="mt-3">Remota</h4>
110
+          <div class="divData mt-3">
111
+            Remota
112
+          </div>
113
+
98
           <?php
114
           <?php
99
           $sum_ore_remota = 0;
115
           $sum_ore_remota = 0;
100
           ?>
116
           ?>
122
 
138
 
123
     <div class="col-xl-3 col-md px-md-3 px-2">
139
     <div class="col-xl-3 col-md px-md-3 px-2">
124
       <div class="card">
140
       <div class="card">
125
-        <div class="card-header">Allegati</div>
141
+        <div class="card-header"><label>Allegati</label></div>
126
         <div class="card-body">
142
         <div class="card-body">
127
           <ul>
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
         </div>
150
         </div>
135
       </div>
151
       </div>
136
     </div>
152
     </div>

+ 1
- 0
routes/web.php Ver fichero

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/show', [IssueController::class, 'show'])->name('issue.show');
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
   Route::get('issue/nuovo', [IssueController::class, 'nuovo'])->name('issue.nuovo');
40
   Route::get('issue/nuovo', [IssueController::class, 'nuovo'])->name('issue.nuovo');
40
   Route::post('issue/crea', [IssueController::class, 'crea'])->name('issue.crea');
41
   Route::post('issue/crea', [IssueController::class, 'crea'])->name('issue.crea');
41
   Route::get('attachment/{id?}/download', [IssueController::class, 'download'])->name('attachment.download');
42
   Route::get('attachment/{id?}/download', [IssueController::class, 'download'])->name('attachment.download');

Loading…
Cancelar
Guardar