Roberto Santini 3 роки тому
джерело
коміт
88fd6b6b3f

+ 25
- 4
app/Http/Controllers/IssueController.php Переглянути файл

@@ -243,7 +243,28 @@ class IssueController extends Controller
243 243
   }
244 244
 
245 245
   public function show_user_report(){
246
-    return view('issue.componi_user_report');
246
+    $redmineUser = session('redmine_user');
247
+    $user = Auth::user();
248
+    $userProg = json_decode($user->progetti);
249
+    if($userProg == null){
250
+      $userProg = array();
251
+    }
252
+
253
+    $projectResponseUser = Http::get(config('redmine.url').'/projects.json', [
254
+      'key' => $redmineUser->api_key,
255
+      'id' => ($userProg!=null && count($userProg)>0)?implode('|', $userProg):'',
256
+      'limit' => 100
257
+    ]);
258
+
259
+    $progetti = new Collection;
260
+
261
+    foreach($projectResponseUser->object()->projects as $project){
262
+      if(in_array($project->id, $userProg)){
263
+        $progetti->push($project);
264
+      }
265
+    }
266
+
267
+    return view('issue.componi_user_report')->with(['progetti' => $progetti]);
247 268
   }
248 269
 
249 270
   public function user_report(Request $request){
@@ -256,15 +277,15 @@ class IssueController extends Controller
256 277
       'key' => $redmineUser->api_key,
257 278
       'from' => $from,
258 279
       'to' => $to,
259
-      'project_id' => implode('|', json_decode(Auth::user()->progetti)),
280
+      'project_id' => $request->project_id,
260 281
       'cf_'.Config::getValue(Config::CAMPO_FATTURARE) => 'Sì|Fatturato', // Custom fields "fatturare"
261 282
     ]);
262 283
 
263
-    // dd($timeEntries->object());
264 284
     if($timeEntries->object()->total_count > 0){
265 285
       $pdf = PDF::loadView('issue.user_report', [
266 286
         'from' => $from,
267
-        'to' => $to
287
+        'to' => $to,
288
+        'project_id' => $request->project_id
268 289
       ]);
269 290
       return $pdf->stream();
270 291
     }else{

+ 14
- 1
resources/views/issue/componi_user_report.blade.php Переглянути файл

@@ -47,11 +47,24 @@ use Illuminate\Support\Collection;
47 47
             </div>
48 48
           </div>
49 49
 
50
+          @if($progetti->count() == 1)
50 51
           <div class="form-row">
51 52
             <div class="form-group col-md">
52
-              <button type="submit" class="btn btn-primary">Genera</button>
53
+              {!! Form::hidden('project_id', $progetti->get(0)->id) !!}
54
+              <button type="submit" class="btn btn-primary"><i class="fas fa-sync-alt"></i> Genera</button>
53 55
             </div>
54 56
           </div>
57
+          @else
58
+
59
+          @foreach($progetti as $progetto)
60
+          <div class="form-row">
61
+            <div class="form-group col-md">
62
+              <button type="submit" class="btn btn-primary" name="project_id" value="{{ $progetto->id }}" style="margin-right: 10px;"><i class="fas fa-sync-alt"></i> Genera</button> {{ $progetto->name }}
63
+            </div>
64
+          </div>
65
+          @endforeach
66
+
67
+          @endif
55 68
 
56 69
 
57 70
           {!! Form::close() !!}

+ 8
- 14
resources/views/issue/user_report.blade.php Переглянути файл

@@ -16,7 +16,6 @@ $project_ids = json_decode(Auth::user()->progetti);
16 16
 @include('footer_pdf')
17 17
 <body>
18 18
 
19
-  @foreach($project_ids as $project_id)
20 19
   <?php
21 20
   $timeEntries = Http::get(config('redmine.url').'/time_entries.json', [
22 21
     'key' => $redmineUser->api_key,
@@ -60,17 +59,9 @@ $project_ids = json_decode(Auth::user()->progetti);
60 59
 
61 60
   ?>
62 61
 
63
-  @if($collectionIssue->count() == 0)
64
-  @continue
65
-  @endif
66
-
67 62
 
68 63
 
69 64
   <div style="width: 100%;">
70
-    @if($loop->iteration > 1)
71
-    <div class="page-break"></div>
72
-    @endif
73
-
74 65
     <div style="width: 100%; padding-top: 0px; height: 100px; margin-bottom: 15px;" >
75 66
       <div style="width: 25%; float: left;">
76 67
         <img src="{{ public_path('assets/logo_bgw.png') }}" style="height: 100%"/>
@@ -92,8 +83,7 @@ $project_ids = json_decode(Auth::user()->progetti);
92 83
       $sedeClienteCorrente = null;
93 84
       foreach($collectionIssue as $issue){
94 85
         $sedeCliente = $issue['sede_cliente'];
95
-
96
-        if($sedeClienteCorrente != $sedeCliente){
86
+        if($sedeClienteCorrente !== $sedeCliente){
97 87
           if($sedeClienteCorrente != null){
98 88
             echo "</table>";
99 89
           }
@@ -101,7 +91,12 @@ $project_ids = json_decode(Auth::user()->progetti);
101 91
           echo "<table class='table' style='width: 100%; margin-bottom: 40px;'>
102 92
           <thead>
103 93
           <tr>
104
-          <th style='width: 430px;'>Segnalazione - Sede: ".$sedeCliente."</th>
94
+          <th style='width: 430px;'>Segnalazione";
95
+          if($sedeCliente != '' && $sedeCliente != null){
96
+            echo "- Sede: ".$sedeCliente;
97
+          }
98
+
99
+          echo "</th>
105 100
           <th style='width: 60px;'>Data</th>
106 101
           <th style='width: 60px;'>On Site</th>
107 102
           <th style='width: 60px;'>Remota</th>
@@ -115,6 +110,7 @@ $project_ids = json_decode(Auth::user()->progetti);
115 110
 
116 111
         $index=0;
117 112
 
113
+        // dd($tempoImpiegatoOnSite);
118 114
         foreach($tempoImpiegatoOnSite as $tempo){
119 115
           echo "<tr>";
120 116
           if($index == 0){
@@ -139,7 +135,6 @@ $project_ids = json_decode(Auth::user()->progetti);
139 135
           echo "<td>".$tempo->hours."h</td>";
140 136
           echo "</tr>";
141 137
         }
142
-
143 138
       }
144 139
 
145 140
 
@@ -151,7 +146,6 @@ $project_ids = json_decode(Auth::user()->progetti);
151 146
 
152 147
 </div>
153 148
 
154
-@endforeach
155 149
 </table>
156 150
 
157 151
 

Завантаження…
Відмінити
Зберегти