I have a table which contain two buttons, one is for uploading a file and the other one is for giving score. What I want to do is to give a condition for the second button which is the scoring button, whereby it can't be clicked (disabled) if there is no file uploaded. How can I achieve this?
Here is what my table looks like:
And here is my AdminController for the table
public function showpekerjaanppk(){
if(Auth::user()->status=='super'){
$pekerjaan = Pekerjaan::with('penyedia','user')->paginate();
return view('admin.showpekerjaan', compact('pekerjaan'));
}else{
$pekerjaan = Auth::user()->pekerjaans;
return view('admin.showpekerjaan', compact('pekerjaan'));
}
//return view('admin.showpekerjaan', compact('penyedia','pekerjaan','totalAvg'));
}
And here is my blade file for the table
<section class="content">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
#if (Auth::user()->status=='super')
<h3 class="card-title"><b>{{$penyedia->nama}}</b></h3> <br>
<h3 class="card-title">Nilai Total: <b>{{$totalAvg}}</b></h3>
#else
<h3 class="card-title"><b></b></h3> <br>
<h3 class="card-title"></b></h3>
#endif
<!-- /.card-header -->
<div class="card-body table-responsive">
<table id="tabelpekerjaan" class="table table-bordered">
<thead>
<tr>
<th style="width: 10px" rowspan="2">No.</th>
<th rowspan="2">Tanggal</th>
<th rowspan="2">Paket Pekerjaan</th>
<th rowspan="2">Nama Perusahaan</th>
<th rowspan="2">Lokasi Pekerjaan</th>
<th rowspan="2">PPK</th>
<th rowspan="2">Nilai Kontrak</th>
<th rowspan="2">Nilai</th>
<th rowspan="2">BAHP</th>
<th colspan="2">Aksi</th>
</tr>
<tr>
<td>BAHP</td>
<td>Nilai</td>
</tr>
</thead>
<tbody>
#php $no = 1; /*$totalNilai = 0.0;*/ #endphp
#foreach ($pekerjaan as $pekerjaans)
<tr>
<td>{{$no++}}</td>
<td>{{$pekerjaans->tanggal}}</td>
<td>{{$pekerjaans->pekerjaan}}</td>
<td>{{$pekerjaans->penyedia->nama}}</td>
<td>{{$pekerjaans->lokasi}}</td>
<td>{{$pekerjaans->user->name}}</td>
<td>Rp. {{number_format($pekerjaans->nilai_kontrak,0,',',',')}}</td>
#php
$pekerjaans->nilai_total = $pekerjaans->nilai_1 + $pekerjaans->nilai_2 + $pekerjaans->nilai_3 + $pekerjaans->nilai_4;
#endphp
<td>{{$pekerjaans->nilai_total}}</td>
<td>{{$pekerjaans->bahp}}</td>
<td>
Upload
</td>
<td>
Penilaian //disabled untill file uploaded
</td>
</tr>
#endforeach
</tbody>
</table>
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
#if (Auth::user()->status=='super')
<div class="card-footer">
Kembali
</div>
#endif
</div>
</section>
Thank you in advance.
#if(isset($pekerjaans->yourFileCulmnName))
<td>
Penilaian //disabled untill file uploaded
</td>
#endif
Related
So I have a table called pekerjaan (work) and it is in an eloquent with another table called jeniskerja (type of work), jeniskerja hasMany pekerjaan, and pekerjaan belongsTo jeniskerja... I want to show the list of the work based on the type of the work which is the foreignId when the user click on the type shown below (if the type is A it will show list of works of type A), but the problem is I already shown the table based on another foreignId, in this case it is the penyedia (vendor)... So, at the moment the table in foreach section show all the list of works based on the penyedia_id (vendor_id)... How do I create another filter whereby when the user click on the type (in this case a card header) it will expand and show the list of works table based on the type they are clicking?
Here is what my code looks like:
AdminController
public function showpenyedia(Penyedia $penyedia){
$pekerjaan = $penyedia->pekerjaans; //show pekerjaan(work) based on penyedia(vendor)
$jeniskerja = Jeniskerja::all();
return view('admin.showpenyedia', compact('penyedia','pekerjaan','jeniskerja'));
}
detailpenyedia.php (this is where the table content is)
#foreach ($jeniskerja as $jeniskerjas)
<section class="content">
<div class="container-fluid">
<div class="card card-default collapsed-card">
<div class="card-header collapsed-card">
<h3 class="card-title">
<b>{{$jeniskerjas->nama_jenis}}</b> //show the name of the type
</h3>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse">
<i class="fas fa-plus"></i>
</button>
</div>
</div>
<div class="card-body table-responsive">
<table id="tabelpekerjaan" class="table table-bordered">
<thead>
<tr>
<th style="width: 10px" rowspan="2">Tahun Anggaran</th>
<th rowspan="2">Tanggal Kontrak</th>
<th rowspan="2">Paket Pekerjaan</th>
<th rowspan="2">Nama Perusahaan</th>
<th rowspan="2">Lokasi Pekerjaan</th>
<th rowspan="2">Jenis Pekerjaan</th>
<th rowspan="2">HPS</th>
<th rowspan="2">Nilai</th>
<th rowspan="2">Dokumen</th>
<th colspan="2">Tanggal</th>
</tr>
<tr>
<td>Tgl Buat</td>
<td>Tgl Update</td>
</tr>
</thead>
<tbody>
#php $no = 1; /*$totalNilai = 0.0;*/ #endphp
#foreach ($pekerjaan as $pekerjaans)
<tr>
<td>{{$pekerjaans->tanggal->format('Y')}}</td>
<td>{{$pekerjaans->tanggal->format('d/m/Y')}}</td>
<td>{{$pekerjaans->pekerjaan}}</td>
<td>{{$pekerjaans->penyedia->nama}}</td>
<td>{{$pekerjaans->lokasi}}</td>
<td>{{$pekerjaans->jeniskerja->nama_jenis}}</td>
<td>Rp. {{number_format($pekerjaans->hps,0,',',',')}}</td>
#php
$pekerjaans->nilai_total = $pekerjaans->nilai_1 + $pekerjaans->nilai_2 + $pekerjaans->nilai_3 + $pekerjaans->nilai_4;
#endphp
<td>{{$pekerjaans->nilai_total}}</td>
<td><u>{{$pekerjaans->status}}</u></td>
<td>
</td>
<td>
</td>
</tr>
#endforeach
</tbody>
</table>
</div>
</div>
</div>
</section>
#endforeach
Here is how my page look like atm:
I want Make Different on Table, Each table has a service name Dontt Need Loop Again Table same Group Name, Each group has the name of the service
Check : https://i.ibb.co/NTnynGq/639.png
View : Package.blade.php
<div class="pt-120 pb-120">
<div class="container">
<div class="row justify-content-center">
<div class="col-lg-12">
<div class="table-responsive--md">
<div class="services-table w-100">
<div class="service-group">
<div class="card">
#foreach($packages as $singlePackage)
<br>
<table class="table table-bordered style--two">
<thead>
<tr>
<th style="width:70%">
<span>Group Name : {{ $singlePackage->groups->name }}</span>
</th>
<th style="width:15%">
<span>#lang('Services Name')</span>
</th>
<th style="width:15%">
<span>#lang('Services Name')</span>
</th>
<th style="width:15%">
<span>#lang('Action')</span>
</th>
</tr>
</thead>
<tbody>
<tr class="block item">
<td class="word-break">{{ $singlePackage->name }}</td>
<td>
<span>{{ $singlePackage->delivery_time }}</span>
</td>
<td>
<span>{{ $singlePackage->price }}</span>
</td>
<td>
<span>{{ $singlePackage->price }}</span>
</td>
</tr>
</tbody>
</table>
#endforeach
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Package Model
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Package extends Model
{
protected $guarded = ['id'];
public function groups()
{
return $this->belongsTo(Group::class);
}
}
PackageController.php
public function packages()
{
$pageTitle = 'Packages';
$packages = Package::where('status', 1)->with('groups')->paginate(getPaginate());
return view('package',compact('pageTitle', 'packages'));
}
Want Separation each group has the name of the service
Option 1: You can add an ORDER BY group_id in the query
$packages = Package::where('status', 1)->with('groups')->orderBy('group_id')->paginate(getPaginate());
Option 2: You can sort by the group name in the foreach
#foreach($packages->sortBy(function ($item) { return $item->group->name; }) as $singlePackage)
or
#foreach($packages->sortBy(fn($item) => $item->group->name) as $singlePackage)
Option 3: Use the Collection's groupBy method.
<div class="card">
#foreach($packages->groupBy(function ($item) { return $item->groups->name; }) as $name => $group)
<br>
<table class="table table-bordered style--two">
<thead>
<tr>
<th style="width:70%">
<span>Group Name : {{ $name }}</span>
</th>
<th style="width:15%">
<span>#lang('Services Name')</span>
</th>
<th style="width:15%">
<span>#lang('Services Name')</span>
</th>
<th style="width:15%">
<span>#lang('Action')</span>
</th>
</tr>
</thead>
<tbody>
#foreach($group as $singlePackage)
<tr class="block item">
<td class="word-break">{{ $singlePackage->name }}</td>
<td>
<span>{{ $singlePackage->delivery_time }}</span>
</td>
<td>
<span>{{ $singlePackage->price }}</span>
</td>
<td>
<span>{{ $singlePackage->price }}</span>
</td>
</tr>
#endforeach
</tbody>
</table>
#endforeach
</div>
i want to generate pdf from the database for 1 row in a table , the table name is "listings"
i used that script for the controller :
class CreatePdfController extends Controller
{
public function pdfForm(Request $request,$id){
$listing = Listing::findOrFail($id);
view()->share('listing',$listing);
if($request->has('download')){
$pdf = PDF::loadView('pdf_download');
return $pdf->download('pdf_download.pdf');
}
return view('show_details')->with('listing', $listing);
}
}
and for the show_details its the view where can i fetch just the data for 1 line in the table :
<div class="col-sm-8 offset-sm-2">
Download PDF
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header col-xs-6">
<div class="col-xs-3">
<h2>Listing Ref n° :{{$listing->id}}</h2>
{{$listing->owner->owner_lastname}}</h4>
</div>
<div class="col-xs-3">
<img src="{{ asset('/assets/images/listings/'.$listing->listing_Fimage) }}" width="120px" height="100px" alt="image" >
</div>
</div>
<div class="card-body">
<div class="col-xs-7 well">
<table id="example1" class="table table-bordered">
<thead>
<tr>
<th scope="row">listing_title:</th>
<td>{{$listing->listing_title}}</td>
</tr>
<tr>
<th scope="row">listing_type:</th>
<td>{{$listing->listing_type}}</td>
</tr>
<tr>
<th scope="row">listing_purpose:</th>
<td>{{$listing->listing_purpose}}</td>
</tr>
<tr>
<th scope="row">listing_location:</th>
<td>{{$listing->listing_location}}</td>
</tr>
<tr>
the pdf_download is the view that i want to generated as pdf :
<table id="example1" class="table table-bordered">
<thead>
<tr>
<th scope="row">listing_title:</th>
<td>{{$listing->listing_title}}</td>
</tr>
<tr>
<th scope="row">listing_type:</th>
<td>{{$listing->listing_type}}</td>
</tr>
<tr>
<th scope="row">listing_purpose:</th>
<td>{{$listing->listing_purpose}}</td>
</tr>
<tr>
<th scope="row">listing_location:</th>
<td>{{$listing->listing_location}}</td>
</tr>
<tr>
<th scope="row">listing_emirate:</th>
<td>{{$listing->listing_emirate}}</td>
</tr>
<tr>
<th scope="row">listing_community:</th>
<td>{{$listing->listing_community}}</td>
</tr>
<tr>
<th scope="row">listing_price:</th>
<td>{{$listing->listing_price}}</td>
</tr>
</table>
and the route that i passed is :
Route::get('/show_details/{id}' ,array('as'=>'show_details',
'uses'=>'CreatePdfController#pdfForm'));
the problem is i get that error and i cannot download the pdf file :
**Symfony\Component\ErrorHandler\Error\FatalError
Maximum execution time of 60 seconds exceeded
http://127.0.0.1:8000/show_details/3?download=pdf**
How can I limit the impressions of the foreach ?.
I need only 7 rows horizontal to print. is there any way to do it with css or pagination?
Image the problem: https://i.imgur.com/LwhA42z.png
right now print infinity, the design is deformed
<div class="col-xl-6 col-lg-12 col-md-12 col-sm-12 col-12 layout-spacing">
<div class="widget widget-table-two">
<div class="widget-heading">
<h5 class="">Turnos Recientes</h5>
</div>
<div class="widget-content">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th><div class="th-content">Cliente</div></th>
<th><div class="th-content">Servicio</div></th>
<th><div class="th-content mr-3">Horario</div></th>
<th><div class="th-content ml-3">Asistencia</div></th>
<th><div class="th-content mr-3">Estado</div></th>
</tr>
</thead>
<tbody>
#foreach ($servicios as $servicio)
<tr>
<td><div class="td-content customer-name">{{$servicio->titulo}}</div></td>
<td><div class="td-content product-brand">{{$servicio->servicio->servicio}}</div></td>
<td><div class="td-content ml-2">{{$servicio->hora}}</div></td>
<td><div class="td-content">
#if($servicio->asistencia == 'on')
Sí
#elseif($servicio->asistencia == null)
No
#endif
</div></td>
<td><div class="td-content">
#if($servicio->c_confirma == 'on')
<span class="badge outline-badge-primary">Confirmado</span>
#elseif($servicio->c_confirma == null)
<span class="badge outline-badge-danger">Sin Confirmar</span>
#endif
</span></div></td>
</tr>
#endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
I think $servicios is of type Collection so you can just use this inside your foreach loop:
#foreach ($servicios->take(7) as $servicio)
...
#endforeach
I want to write a search function but I got the error when I click the search button (Undefined variable: requests)..
this is my form
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">
<form action="/member_search" methode="get">
<div class="input-group">
<input type="search" name="searchinput" class="form-control">
<span class="input-group-prepend">
<button type="submit" class="btn btn-primary">search</button>
</div>
</form>
</div>
<div class="card-body">
<table class="table">
<thead>
<tr>
<th scope="col">status</th>
<th scope="col">type</th>
<th scope="col">date</th>
<th scope="col"> request number</th>
</tr>
</thead>
<tbody>
#foreach ($requests as $request)
<tr>
<th scope="col">{{$request->status->name}}</th>
<th scope="col">{{$request->type->name}}</th>
<th scope="row">{{$request->created_at}}</th>
<th scope="row">{{$request->uniid}}</th>
</tr>
#endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
and this is my function in my controller and I got the error Undefined variable: requests with this function
public function searchmember(Request $request)
{
$searchinput= $request->get('searchinput');
$posts= DB::table('students')->where ( 'uniid', 'LIKE', '%' . $searchinput . '%' )->paginate(1);
return view('Committee.Request.index', ['posts' => $posts]);
}
and I this is my route I try to do it as (get) but it does not work
Route::any('/member_search','RequestController#searchmember');
You should use the variable in the loop which variable is passing to view:
#foreach ($posts as $post)
<tr>
<th scope="col">{{$post->status->name}}</th>
<th scope="col">{{$post->type->name}}</th>
<th scope="row">{{$post->created_at}}</th>
<th scope="row">{{$post->uniid}}</th>
</tr>
#endforeach