Merge branch 'staging' into feature/senior-officer
This commit is contained in:
@@ -13,6 +13,7 @@ use Maatwebsite\Excel\Facades\Excel;
|
|||||||
use Modules\Lpj\Exports\KertasKerjaExport;
|
use Modules\Lpj\Exports\KertasKerjaExport;
|
||||||
use Modules\Lpj\Http\Controllers\SurveyorController;
|
use Modules\Lpj\Http\Controllers\SurveyorController;
|
||||||
use Modules\Location\Models\Province;
|
use Modules\Location\Models\Province;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class PenilaiController extends Controller
|
class PenilaiController extends Controller
|
||||||
{
|
{
|
||||||
@@ -243,10 +244,13 @@ class PenilaiController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(!Auth::user()->hasRole('administrator')) {
|
||||||
$query->whereHas('penilaian.userPenilai', function ($q) {
|
$query->whereHas('penilaian.userPenilai', function ($q) {
|
||||||
$q->where('role', 'penilai')
|
$q
|
||||||
|
->where('role', 'penilai')
|
||||||
->where('user_id', Auth::user()->id);
|
->where('user_id', Auth::user()->id);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Apply sorting if provided
|
// Apply sorting if provided
|
||||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
@@ -604,7 +608,7 @@ class PenilaiController extends Controller
|
|||||||
$lpjData = json_decode($lpj->lpj, true);
|
$lpjData = json_decode($lpj->lpj, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
$pdf = PDF::loadView('lpj::penilai.components.print-out', compact(
|
$pdf = PDF::loadView('lpj::penilai.components.print-out', compact(
|
||||||
'permohonan',
|
'permohonan',
|
||||||
'forminspeksi',
|
'forminspeksi',
|
||||||
@@ -618,6 +622,10 @@ class PenilaiController extends Controller
|
|||||||
$pdf->setPaper('A4', 'portrait');
|
$pdf->setPaper('A4', 'portrait');
|
||||||
|
|
||||||
return $pdf->download('laporan.pdf');
|
return $pdf->download('laporan.pdf');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Log::error('PDF generation failed: ' . $e->getMessage());
|
||||||
|
return response()->json(['error' => 'Failed to generate PDF. Please check the log for details.'], 500);
|
||||||
|
}
|
||||||
|
|
||||||
// return view('lpj::penilai.components.print-out', compact(
|
// return view('lpj::penilai.components.print-out', compact(
|
||||||
// 'permohonan',
|
// 'permohonan',
|
||||||
|
|||||||
@@ -536,7 +536,7 @@
|
|||||||
$filteredRecords = $query->count();
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
// Ambil data dengan relasi
|
// Ambil data dengan relasi
|
||||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'region.teams.teamsUsers'])->get();
|
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'approveSo'])->get();
|
||||||
|
|
||||||
|
|
||||||
// Hitung jumlah halaman
|
// Hitung jumlah halaman
|
||||||
|
|||||||
@@ -1412,10 +1412,12 @@ class SurveyorController extends Controller
|
|||||||
|
|
||||||
$query->whereRaw('LOWER(status) = ?', ['assign']);
|
$query->whereRaw('LOWER(status) = ?', ['assign']);
|
||||||
|
|
||||||
|
if(!Auth::user()->hasRole('administrator')) {
|
||||||
$query->whereHas('penilaian.userPenilai', function ($q) {
|
$query->whereHas('penilaian.userPenilai', function ($q) {
|
||||||
$q->where('user_id', Auth::user()->id);
|
$q->where('user_id', Auth::user()->id);
|
||||||
$q->where('role', 'surveyor');
|
$q->where('role', 'surveyor');
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||||
|
|||||||
@@ -193,4 +193,16 @@
|
|||||||
public function approveBayar(){
|
public function approveBayar(){
|
||||||
return $this->belongsTo(User::class, 'approve_bayar_by', 'id');
|
return $this->belongsTo(User::class, 'approve_bayar_by', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function approveEo(){
|
||||||
|
return $this->belongsTo(User::class, 'approval_eo', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function approveDd(){
|
||||||
|
return $this->belongsTo(User::class, 'approval_dd', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function approveSo(){
|
||||||
|
return $this->belongsTo(User::class, 'approval_so', 'id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,7 +245,9 @@
|
|||||||
"permission": "",
|
"permission": "",
|
||||||
"roles": [
|
"roles": [
|
||||||
"administrator",
|
"administrator",
|
||||||
"senior-officer"
|
"senior-officer",
|
||||||
|
"EO Appraisal",
|
||||||
|
"DD Appraisal"
|
||||||
],
|
],
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -454,7 +454,9 @@
|
|||||||
<table class="checkbox-table">
|
<table class="checkbox-table">
|
||||||
<tr>
|
<tr>
|
||||||
@foreach ($basicData['hubCadeb'] as $item)
|
@foreach ($basicData['hubCadeb'] as $item)
|
||||||
<td><input type="checkbox" {{ $item->name === $hubCadeb ? 'checked' : '' }} > {{ $item->name }}</td>
|
<td>
|
||||||
|
<input type="checkbox" {{ $item->name === $hubCadeb ? 'checked' : '' }} > {{ $item->name }}
|
||||||
|
</td>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -480,7 +482,9 @@
|
|||||||
<table class="checkbox-table">
|
<table class="checkbox-table">
|
||||||
<tr>
|
<tr>
|
||||||
@foreach ($basicData['hubPenghuni'] as $item)
|
@foreach ($basicData['hubPenghuni'] as $item)
|
||||||
<td><input type="checkbox" {{ $item->name === $hubCadeb ? 'checked' : '' }} > {{ $item->name }}</td>
|
<td>
|
||||||
|
<input type="checkbox" {{ $item->name === $hubCadeb ? 'checked' : '' }} > {{ $item->name }}
|
||||||
|
</td>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -920,7 +924,6 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@@ -1087,8 +1090,10 @@
|
|||||||
$imagePath = $forminspeksi[$type];
|
$imagePath = $forminspeksi[$type];
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
|
@if($imagePath && file_exists(storage_path('app/public/'. $imagePath)))
|
||||||
<img src="{{ storage_path('app/public/' . $imagePath) }}" alt="{{ $type }}"
|
<img src="{{ storage_path('app/public/' . $imagePath) }}" alt="{{ $type }}"
|
||||||
class="photo-image">
|
class="photo-image">
|
||||||
|
@endif
|
||||||
<p class="mt-2 text-sm">{{ Str::title(str_replace('_', ' ', $type)) }}</p>
|
<p class="mt-2 text-sm">{{ Str::title(str_replace('_', ' ', $type)) }}</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -1106,15 +1111,17 @@
|
|||||||
</h6>
|
</h6>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@if (isset($formFoto))
|
@if (isset($formFoto['rute_menuju_lokasi']))
|
||||||
@foreach ($formFoto['rute_menuju_lokasi'] as $item)
|
@foreach ($formFoto['rute_menuju_lokasi'] as $item)
|
||||||
<div class="border photo-item">
|
<div class="border photo-item">
|
||||||
<h2 class="text-gray-600 font-semibold text-xl">
|
<h2 class="text-gray-600 font-semibold text-xl">
|
||||||
{{ $item['name_rute'] . ' ' . $loop->index + 1 }}
|
{{ $item['name_rute'] . ' ' . $loop->index + 1 }}
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
|
@if(file_exists(storage_path('app/public/'. $item['foto_rute'])))
|
||||||
<img src="{{ storage_path('app/public/' . $item['foto_rute']) }}"
|
<img src="{{ storage_path('app/public/' . $item['foto_rute']) }}"
|
||||||
alt="{{ $item['foto_rute'] }}" class="photo-image">
|
alt="{{ $item['foto_rute'] }}" class="photo-image">
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
@endif
|
@endif
|
||||||
@@ -1126,8 +1133,10 @@
|
|||||||
{{ $item['name_objek'] }}
|
{{ $item['name_objek'] }}
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
|
@if(file_exists(storage_path('app/public/'. $item['foto_objek'])))
|
||||||
<img src="{{ storage_path('app/public/' . $item['foto_objek']) }}"
|
<img src="{{ storage_path('app/public/' . $item['foto_objek']) }}"
|
||||||
alt="{{ $item['foto_objek'] }}" class="photo-image">
|
alt="{{ $item['foto_objek'] }}" class="photo-image">
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
@endif
|
@endif
|
||||||
@@ -1138,8 +1147,10 @@
|
|||||||
Basement
|
Basement
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
|
@if(file_exists(storage_path('app/public/'. $formFoto['foto_basement'])))
|
||||||
<img src="{{ storage_path('app/public/' . $formFoto['foto_basement']) }}"
|
<img src="{{ storage_path('app/public/' . $formFoto['foto_basement']) }}"
|
||||||
alt="{{ $formFoto['foto_basement'] }}" class="photo-image">
|
alt="{{ $formFoto['foto_basement'] }}" class="photo-image">
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@@ -1149,8 +1160,10 @@
|
|||||||
Gerbang
|
Gerbang
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
|
@if(file_exists(storage_path('app/public/'. $formFoto['foto_gerbang'])))
|
||||||
<img src="{{ storage_path('app/public/' . $formFoto['foto_gerbang']) }}"
|
<img src="{{ storage_path('app/public/' . $formFoto['foto_gerbang']) }}"
|
||||||
alt="{{ $formFoto['foto_gerbang'] }}" class="photo-image">
|
alt="{{ $formFoto['foto_gerbang'] }}" class="photo-image">
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
@if (isset($formFoto['pendamping']))
|
@if (isset($formFoto['pendamping']))
|
||||||
@@ -1158,9 +1171,10 @@
|
|||||||
<h2 class="text-gray-600 font-semibold text-xl">
|
<h2 class="text-gray-600 font-semibold text-xl">
|
||||||
Pendamping
|
Pendamping
|
||||||
</h2>
|
</h2>
|
||||||
|
@if(file_exists(storage_path('app/public/'. $formFoto['pendamping'])))
|
||||||
<img src="{{ storage_path('app/public/' . $formFoto['pendamping']) }}"
|
<img src="{{ storage_path('app/public/' . $formFoto['pendamping']) }}"
|
||||||
alt="{{ $formFoto['pendamping'] }}" class="photo-image">
|
alt="{{ $formFoto['pendamping'] }}" class="photo-image">
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -61,12 +61,25 @@
|
|||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
|
|
||||||
@if ($header == 'Pembayaran')
|
|
||||||
<th class="min-w-[150px]" data-datatable-column="tujuan_penilaian_id">
|
<th class="min-w-[150px]" data-datatable-column="tujuan_penilaian_id">
|
||||||
<span class="sort"> <span class="sort-label"> Status Bayar </span>
|
<span class="sort"> <span class="sort-label"> Status Bayar </span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
@endif
|
|
||||||
|
<th class="min-w-[150px]" data-datatable-column="approval_so">
|
||||||
|
<span class="sort"> <span class="sort-label"> Approval SO </span>
|
||||||
|
<span class="sort-icon"> </span> </span>
|
||||||
|
</th>
|
||||||
|
|
||||||
|
<th class="min-w-[150px]" data-datatable-column="approval_eo">
|
||||||
|
<span class="sort"> <span class="sort-label"> Approval EO </span>
|
||||||
|
<span class="sort-icon"> </span> </span>
|
||||||
|
</th>
|
||||||
|
|
||||||
|
<th class="min-w-[150px]" data-datatable-column="approval_dd">
|
||||||
|
<span class="sort"> <span class="sort-label"> Approval DD </span>
|
||||||
|
<span class="sort-icon"> </span> </span>
|
||||||
|
</th>
|
||||||
|
|
||||||
<th class="min-w-[50px] text-center" data-datatable-column="actions">Action</th>
|
<th class="min-w-[50px] text-center" data-datatable-column="actions">Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -182,7 +195,6 @@
|
|||||||
return `${data.tujuan_penilaian.name}`;
|
return `${data.tujuan_penilaian.name}`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
...(dataHeader === 'Pembayaran' && {
|
|
||||||
status_bayar: {
|
status_bayar: {
|
||||||
title: 'Status Bayar',
|
title: 'Status Bayar',
|
||||||
render: (item, data) => {
|
render: (item, data) => {
|
||||||
@@ -195,21 +207,68 @@
|
|||||||
</span>`;
|
</span>`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
approval_so: {
|
||||||
|
title: 'Approval SO',
|
||||||
|
render: (item, data) => {
|
||||||
|
if(data.approve_so) {
|
||||||
|
return `${data.approve_so.name} | ${window.formatTanggalIndonesia(data.approval_so_at)}`;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
approval_eo: {
|
||||||
|
title: 'Approval EO',
|
||||||
|
render: (item, data) => {
|
||||||
|
if(data.approve_eo) {
|
||||||
|
return `${data.approve_eo.name} | ${window.formatTanggalIndonesia(data.approval_eo_at)}`;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
approval_dd: {
|
||||||
|
title: 'Approval DD',
|
||||||
|
render: (item, data) => {
|
||||||
|
if(data.approve_dd) {
|
||||||
|
return `${data.approve_dd.name} | ${window.formatTanggalIndonesia(data.approval_dd_at)}`;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
},
|
||||||
actions: {
|
actions: {
|
||||||
title: 'Status',
|
title: 'Status',
|
||||||
render: (item, data) => {
|
render: (item, data) => {
|
||||||
return `<div class="flex flex-nowrap justify-center">
|
const userRoles = @json(Auth::user()->getRoleNames());
|
||||||
|
const isAdmin = userRoles.includes('administrator');
|
||||||
|
|
||||||
|
let buttons = `
|
||||||
|
<div class="flex flex-nowrap justify-center">
|
||||||
<a class="btn btn-sm btn-icon btn-clear btn-warning" href="otorisator/show/${data.id}/${dataHeader}">
|
<a class="btn btn-sm btn-icon btn-clear btn-warning" href="otorisator/show/${data.id}/${dataHeader}">
|
||||||
<i class="ki-outline ki-eye"></i>
|
<i class="ki-outline ki-eye"></i>
|
||||||
</a>
|
</a>
|
||||||
|
`;
|
||||||
|
|
||||||
|
if ((isAdmin || userRoles.includes('senior-officer')) && !data.approval_so) {
|
||||||
|
buttons += `
|
||||||
<a class="btn btn-sm btn-icon btn-clear btn-primary" onclick="otorisatorData(${data.id})">
|
<a class="btn btn-sm btn-icon btn-clear btn-primary" onclick="otorisatorData(${data.id})">
|
||||||
<i class="ki-filled ki-double-check"></i>
|
<i class="ki-filled ki-double-check"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>`;
|
`;
|
||||||
|
} else if ((isAdmin || userRoles.includes('EO Appraisal')) && data.approval_so && !data.approval_eo) {
|
||||||
|
buttons += `
|
||||||
|
<a class="btn btn-sm btn-icon btn-clear btn-primary" onclick="otorisatorData(${data.id})">
|
||||||
|
<i class="ki-filled ki-double-check"></i>
|
||||||
|
</a>
|
||||||
|
`;
|
||||||
|
} else if ((isAdmin || userRoles.includes('DD Appraisal')) && data.approval_eo && !data.approval_dd) {
|
||||||
|
buttons += `
|
||||||
|
<a class="btn btn-sm btn-icon btn-clear btn-primary" onclick="otorisatorData(${data.id})">
|
||||||
|
<i class="ki-filled ki-double-check"></i>
|
||||||
|
</a>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
buttons += `</div>`;
|
||||||
|
return buttons;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -257,7 +316,7 @@
|
|||||||
message: userMessage // Kirim pesan sebagai bagian dari data
|
message: userMessage // Kirim pesan sebagai bagian dari data
|
||||||
},
|
},
|
||||||
success: (response) => {
|
success: (response) => {
|
||||||
Swal.fire('Berhasil!', 'Data berhasil diotorisasi.', 'success').then(() => {
|
Swal.fire('Berhasil!', 'Data berhasil diotorisasi. Menunggu Approval EO dan atau DD', 'success').then(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
console.log(response);
|
console.log(response);
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<div class="flex gap-2.5">
|
<div class="flex gap-2.5">
|
||||||
@php
|
@php
|
||||||
@@ -68,10 +69,26 @@
|
|||||||
</a>
|
</a>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if(Auth::user()->hasAnyRole(['administrator','senior-officer']) && $permohonan->approval_so==null)
|
||||||
<button onclick="otorisatorData({{ $permohonan->id }})" type="button" class="btn btn-primary">
|
<button onclick="otorisatorData({{ $permohonan->id }})" type="button" class="btn btn-primary">
|
||||||
<i class="ki-filled ki-double-check"></i>
|
<i class="ki-filled ki-double-check"></i>
|
||||||
Otorisator {{ $header ?? '' }}
|
Otorisator {{ $header ?? '' }}
|
||||||
</button>
|
</button>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if(Auth::user()->hasAnyRole(['administrator','EO Appraisal']) && $permohonan->approval_so && $permohonan->approval_eo==null)
|
||||||
|
<button onclick="otorisatorData({{ $permohonan->id }})" type="button" class="btn btn-primary">
|
||||||
|
<i class="ki-filled ki-double-check"></i>
|
||||||
|
Otorisator {{ $header ?? '' }}
|
||||||
|
</button>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if(Auth::user()->hasAnyRole(['administrator','DD Appraisal']) && $permohonan->approval_eo && $permohonan->approval_dd==null)
|
||||||
|
<button onclick="otorisatorData({{ $permohonan->id }})" type="button" class="btn btn-primary">
|
||||||
|
<i class="ki-filled ki-double-check"></i>
|
||||||
|
Otorisator {{ $header ?? '' }}
|
||||||
|
</button>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -111,7 +128,7 @@
|
|||||||
message: userMessage
|
message: userMessage
|
||||||
},
|
},
|
||||||
success: (response) => {
|
success: (response) => {
|
||||||
Swal.fire('Berhasil!', 'Data berhasil diotorisasi.', 'success').then(() => {
|
Swal.fire('Berhasil!', 'Data berhasil diotorisasi. Menunggu Approval EO dan atau DD', 'success').then(() => {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
console.log(response);
|
console.log(response);
|
||||||
|
|||||||
@@ -418,11 +418,6 @@
|
|||||||
<div class="input-group w-full flex gap-2">
|
<div class="input-group w-full flex gap-2">
|
||||||
<input type="hidden" name="name_lantai_unit[]" value="lantai">
|
<input type="hidden" name="name_lantai_unit[]" value="lantai">
|
||||||
<div class="preview-container">
|
<div class="preview-container">
|
||||||
<img id="foto_lantai-preview-{{ $loop->index }}"
|
|
||||||
src="{{ asset('storage/' . old('foto_lantai_unit', $item['foto_lantai_unit'])) }}"
|
|
||||||
alt="Foto Lantai" class="mt-2 h-auto"
|
|
||||||
style="{{ old('foto_lantai_unit', $item['foto_lantai_unit']) ? 'display: block;' : 'display: none;' }} width: 30rem;">
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<input id="inputLantai" type="file" name="foto_lantai_unit[]"
|
<input id="inputLantai" type="file" name="foto_lantai_unit[]"
|
||||||
class="file-input file-input-bordered w-full" accept="image/*"
|
class="file-input file-input-bordered w-full" accept="image/*"
|
||||||
|
|||||||
@@ -204,9 +204,9 @@
|
|||||||
setupCanvas() {
|
setupCanvas() {
|
||||||
// Set initial canvas size
|
// Set initial canvas size
|
||||||
this.canvas.width = 1280;
|
this.canvas.width = 1280;
|
||||||
this.canvas.height = 960;
|
this.canvas.height = (this.canvas.width * 3) / 4;
|
||||||
this.drawingCanvas.width = 1280;
|
this.drawingCanvas.width = this.canvas.width;
|
||||||
this.drawingCanvas.height = 960;
|
this.drawingCanvas.height = this.canvas.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
setupDrawingContext() {
|
setupDrawingContext() {
|
||||||
@@ -277,6 +277,43 @@
|
|||||||
this.saveDrawingState();
|
this.saveDrawingState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
takePhoto() {
|
||||||
|
const context = this.canvas.getContext('2d');
|
||||||
|
|
||||||
|
// Determine if the video is in portrait or landscape mode
|
||||||
|
const isPortrait = this.video.videoHeight > this.video.videoWidth;
|
||||||
|
|
||||||
|
if (isPortrait) {
|
||||||
|
// Portrait mode
|
||||||
|
this.canvas.width = this.video.videoWidth;
|
||||||
|
this.canvas.height = this.video.videoHeight;
|
||||||
|
context.drawImage(this.video, 0, 0, this.canvas.width, this.canvas.height);
|
||||||
|
} else {
|
||||||
|
// Landscape mode
|
||||||
|
this.canvas.width = 1280;
|
||||||
|
this.canvas.height = (this.canvas.width * this.video.videoHeight) / this.video.videoWidth;
|
||||||
|
context.drawImage(this.video, 0, 0, this.canvas.width, this.canvas.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adjust drawing canvas to match main canvas
|
||||||
|
this.drawingCanvas.width = this.canvas.width;
|
||||||
|
this.drawingCanvas.height = this.canvas.height;
|
||||||
|
|
||||||
|
// Hide video, show canvases
|
||||||
|
this.video.style.display = 'none';
|
||||||
|
this.canvas.style.display = 'block';
|
||||||
|
this.drawingCanvas.style.display = 'block';
|
||||||
|
|
||||||
|
// Show editor controls, hide camera controls
|
||||||
|
document.getElementById('editorControls').classList.remove('hidden');
|
||||||
|
document.getElementById('cameraControls').classList.add('hidden');
|
||||||
|
|
||||||
|
// Clear drawing history
|
||||||
|
this.drawingHistory = [];
|
||||||
|
this.historyIndex = -1;
|
||||||
|
this.saveDrawingState();
|
||||||
|
}
|
||||||
|
|
||||||
switchCamera() {
|
switchCamera() {
|
||||||
this.currentFacingMode = this.currentFacingMode === 'environment' ? 'user' : 'environment';
|
this.currentFacingMode = this.currentFacingMode === 'environment' ? 'user' : 'environment';
|
||||||
this.startCamera();
|
this.startCamera();
|
||||||
|
|||||||
Reference in New Issue
Block a user