Browse Source

report pdf e xls

Roberto Santini 3 years ago
parent
commit
88fd6b6b3f

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

243
   }
243
   }
244
 
244
 
245
   public function show_user_report(){
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
   public function user_report(Request $request){
270
   public function user_report(Request $request){
256
       'key' => $redmineUser->api_key,
277
       'key' => $redmineUser->api_key,
257
       'from' => $from,
278
       'from' => $from,
258
       'to' => $to,
279
       'to' => $to,
259
-      'project_id' => implode('|', json_decode(Auth::user()->progetti)),
280
+      'project_id' => $request->project_id,
260
       'cf_'.Config::getValue(Config::CAMPO_FATTURARE) => 'Sì|Fatturato', // Custom fields "fatturare"
281
       'cf_'.Config::getValue(Config::CAMPO_FATTURARE) => 'Sì|Fatturato', // Custom fields "fatturare"
261
     ]);
282
     ]);
262
 
283
 
263
-    // dd($timeEntries->object());
264
     if($timeEntries->object()->total_count > 0){
284
     if($timeEntries->object()->total_count > 0){
265
       $pdf = PDF::loadView('issue.user_report', [
285
       $pdf = PDF::loadView('issue.user_report', [
266
         'from' => $from,
286
         'from' => $from,
267
-        'to' => $to
287
+        'to' => $to,
288
+        'project_id' => $request->project_id
268
       ]);
289
       ]);
269
       return $pdf->stream();
290
       return $pdf->stream();
270
     }else{
291
     }else{

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

47
             </div>
47
             </div>
48
           </div>
48
           </div>
49
 
49
 
50
+          @if($progetti->count() == 1)
50
           <div class="form-row">
51
           <div class="form-row">
51
             <div class="form-group col-md">
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
             </div>
55
             </div>
54
           </div>
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
           {!! Form::close() !!}
70
           {!! Form::close() !!}

+ 8
- 14
resources/views/issue/user_report.blade.php View File

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

Loading…
Cancel
Save