Pārlūkot izejas kodu

Generated sources (with reusable queries)

Vijayakrishnan Krishnan 5 gadi atpakaļ
vecāks
revīzija
56f83a4fe8

+ 4 - 2
app/Http/Controllers/my_teams_Controller.php

@@ -13,13 +13,15 @@ class my_teams_Controller extends Controller
 	// GET /my_teams
 	public function index(Request $request) {
 		$records = DB::table('team')->get();
-		return response()->view('pro/my_teams/index', compact('records'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
+		$result_pros = DB::select("select id, name_display from pro");
+		return response()->view('pro/my_teams/index', compact('records', 'result_pros'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
 	}
 
 	// GET /my_teams/add_new
 	public function add_new(Request $request) {
 		$records = DB::table('team')->get();
-		return response()->view('pro/my_teams/add_new', compact('records'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
+		$result_pros = DB::select("select uid, name_display from pro");
+		return response()->view('pro/my_teams/add_new', compact('records', 'result_pros'), session('message') ? 500 : 200)->header('Content-Type', 'text/html');
 	}
 
 	// GET /my_teams/view/{uid}

+ 2 - 4
resources/views/pro/my_teams/add_new.blade.php

@@ -29,8 +29,7 @@
 <label class='control-label'>Hcp Pro *</label>
 <select class='form-control' name='hcpProUid' value='{{ old('hcpProUid') ? old('hcpProUid') : '' }}' required>
 <option value=''>-- Select --</option>
-<?php $dbOptions = \Illuminate\Support\Facades\DB::table('pro')->get(); ?>
-<?php foreach($dbOptions as $o): ?>
+<?php foreach($result_pros as $o): ?>
 <option <?= $o->uid === (old('hcpProUid') ? old('hcpProUid') : '') ? 'selected' : '' ?> value='<?= $o->uid ?>'><?= $o->name_display ?> (<?= $o->uid ?>)</option>
 <?php endforeach; ?>
 </select>
@@ -39,8 +38,7 @@
 <label class='control-label'>Ally Pro *</label>
 <select class='form-control' name='allyProUid' value='{{ old('allyProUid') ? old('allyProUid') : '' }}' required>
 <option value=''>-- Select --</option>
-<?php $dbOptions = \Illuminate\Support\Facades\DB::table('pro')->get(); ?>
-<?php foreach($dbOptions as $o): ?>
+<?php foreach($result_pros as $o): ?>
 <option <?= $o->uid === (old('allyProUid') ? old('allyProUid') : '') ? 'selected' : '' ?> value='<?= $o->uid ?>'><?= $o->name_display ?> (<?= $o->uid ?>)</option>
 <?php endforeach; ?>
 </select>

+ 2 - 4
resources/views/pro/my_teams/index.blade.php

@@ -22,10 +22,8 @@
             @foreach($records as $record)
                 <tr>
 <td><a href="/my_teams/view/<?= $record->uid ?>"><?= $record->team_number ?></a></td>
-<td><a href="/foo/bar/<?= $record->hcp_pro_id ?>"><?php $_r = \Illuminate\Support\Facades\DB::select("select name_display as result from pro where id = " . ($record->hcp_pro_id ? $record->hcp_pro_id : -1) . " limit 1");
-echo ($_r && count($_r)) ? $_r[0]->result : '-'; ?></a></td>
-<td><?php $_r = \Illuminate\Support\Facades\DB::select("select name_display as result from pro where id = " . ($record->ally_pro_id ? $record->ally_pro_id : -1) . " limit 1");
-echo ($_r && count($_r)) ? $_r[0]->result : '-'; ?></td>
+<td><?= value_from_rs($result_pros, 'name_display', [['id', '=', $record->hcp_pro_id], ], 'all'); ?></td>
+<td><?= value_from_rs($result_pros, 'name_display', [['id', '=', $record->ally_pro_id], ], 'all'); ?></td>
 <td><?php $_r = \Illuminate\Support\Facades\DB::select("select COUNT(*) as result FROM client WHERE team_id = " . ($record->id ? $record->id : -1) . "");
 echo ($_r && count($_r)) ? $_r[0]->result : '-'; ?></td>
                 </tr>

+ 1 - 1
resources/views/pro/my_teams_SINGLE/SUB_dashboard.blade.php

@@ -35,7 +35,7 @@ echo ($_r && count($_r)) ? $_r[0]->result : '-'; ?>@if( $record->is_active) <a u
         </tr>
         </thead>
         <tbody>
-            <tr><td class="w-25 px-2 text-secondary border-right">HCP Pro</td><td class="w-75 px-2 font-weight-bold"><?= value_from_rs($result_pros, 'name_display', [['id', '=', $record->hcp_pro_id+1], ], 'all'); ?></td></tr>
+            <tr><td class="w-25 px-2 text-secondary border-right">HCP Pro</td><td class="w-75 px-2 font-weight-bold"><?= value_from_rs($result_pros, 'name_display', [['id', '=', $record->hcp_pro_id], ], 'all'); ?></td></tr>
 <tr><td class="w-25 px-2 text-secondary border-right">Ally Pro</td><td class="w-75 px-2 font-weight-bold"><?= value_from_rs($result_pros, 'name_display', [['id', '=', $record->ally_pro_id], ], 'all'); ?></td></tr>
         </tbody>
     </table>