last fix update forgoten

change-request
ajikamaludin 2 years ago
parent 47709eb529
commit c656d110ab
Signed by: ajikamaludin
GPG Key ID: 476C9A2B4B794EBB

@ -16,8 +16,8 @@ class CompanyController extends Controller
public function index()
{
return inertia('Company/Index', [
'companies' => Company::with(['region'])->paginate(),
'regions' => Region::all(),
'companies' => Company::with(['region.group'])->paginate(),
'regions' => Region::with(['group'])->get(),
]);
}

@ -18,7 +18,7 @@ class DocumentController extends Controller
{
public function index(Request $request)
{
$query = Document::with(['variety', 'category', 'company']);
$query = Document::with(['variety', 'category', 'company.region']);
if ($request->has('status')) {
if($request->status == 1) {
@ -79,11 +79,11 @@ class DocumentController extends Controller
"publisher" => "required|string",
"description" => "nullable",
"publish_date" => "nullable|date",
"due_date" => "required_if:type,0",
"due_date" => "nullable|date",
"status" => "required|in:0,1",
"type" => "required|in:0,1",
"company_id" => "required|exists:companies,id",
"document" => "required|file",
"document" => "nullable|file",
]);
if($request->type == Document::TYPE_TIDAK_TETAP) {
@ -115,9 +115,11 @@ class DocumentController extends Controller
"user_id" => auth()->user()->id,
]);
$file = $request->file('document');
$file->store('documents', 'public');
$doc->document = $file->hashName();
if ($request->hasFile('document')) {
$file = $request->file('document');
$file->store('documents', 'public');
$doc->document = $file->hashName();
}
$doc->save();
@ -152,14 +154,14 @@ class DocumentController extends Controller
"publisher" => "required|string",
"description" => "nullable",
"publish_date" => "nullable|date",
"due_date" => "required_if:type,1",
"due_date" => "nullable|date",
"status" => "required|in:0,1",
"type" => "required|in:0,1",
"company_id" => "required|exists:companies,id",
"document" => "nullable|file",
]);
if($request->type == Document::TYPE_TETAP) {
if($request->type == Document::TYPE_TIDAK_TETAP) {
$request->validate([
"due_date" => "date|after_or_equal:".$request->publish_date
]);

@ -39,14 +39,40 @@ class DocumentImport implements ToCollection, WithHeadingRow
}
$no += 1;
try {
$tanggal_terbit = Carbon::createFromFormat('d-m-Y',$row['tanggal_terbit']);
$tanggal_jatuh_tempo = Carbon::createFromFormat('d-m-Y',$row['tanggal_jatuh_tempo']);
} catch(\Exception $e) {
try {
$tanggal_terbit = Carbon::createFromFormat('d/m/Y',$row['tanggal_terbit']);
$tanggal_jatuh_tempo = Carbon::createFromFormat('d/m/Y',$row['tanggal_jatuh_tempo']);
} catch (\Exception $e) {
try {
$tanggal_terbit = Carbon::createFromFormat('m/d/Y',$row['tanggal_terbit']);
$tanggal_jatuh_tempo = Carbon::createFromFormat('m/d/Y',$row['tanggal_jatuh_tempo']);
} catch (\Exception $e) {
try {
$tanggal_terbit = Carbon::createFromFormat('m-d-Y',$row['tanggal_terbit']);
$tanggal_jatuh_tempo = Carbon::createFromFormat('m-d-Y',$row['tanggal_jatuh_tempo']);
} catch(\Exception $e) {
try {
$tanggal_terbit = Carbon::parse($row['tanggal_terbit']);
$tanggal_jatuh_tempo = Carbon::parse($row['tanggal_jatuh_tempo']);
} catch (\Exception $e) {}
}
}
}
}
$documents->add([
"no" => $no,
"no_doc" => $row['no'],
"name" => $row['nama'],
"publisher" => $row['penerbit'],
"description" => $row['keterangan'],
"publish_date" => Carbon::createFromFormat('d-m-Y',$row['tanggal_terbit']),
"due_date" => Carbon::createFromFormat('d-m-Y',$row['tanggal_jatuh_tempo']),
"publish_date" => $tanggal_terbit,
"due_date" => $tanggal_jatuh_tempo,
"status" => $row['status'] == 'Ya' ? Document::STATUS_YES : Document::STATUS_NO,
"type" => $row['tipe'] == 'Tetap' ? Document::TYPE_TETAP : Document::TYPE_TIDAK_TETAP,
"document" => '',

@ -30,7 +30,7 @@ class DocumentNotification extends Mailable
$docs = collect();
$categories = Category::all();
foreach($categories as $category) {
foreach($category->documents()->get() as $doc) {
foreach($category->documents()->with(['variety'])->get() as $doc) {
if ($doc->is_close_due != 0) {
$docs->add($doc);
}
@ -39,7 +39,7 @@ class DocumentNotification extends Mailable
return $this->markdown('emails.document.notification', [
'documents' => $docs,
'dueDocuments' => Document::whereDate('due_date', '<=', now()->toDateString())->get()
'dueDocuments' => Document::with(['variety'])->whereDate('due_date', '<=', now()->toDateString())->get()
]);
}
}

@ -127,7 +127,7 @@ export default function FormModal(props) {
>
<option disabled value=""></option>
{regions.map(region => (
<option key={region.id} value={region.id}>{region.name}</option>
<option key={region.id} value={region.id}>{region.name} ({region.group?.name})</option>
))}
</select>
<label className="label">

@ -74,7 +74,7 @@ export default function Types(props) {
{companies?.map((company) => (
<tr key={company.id}>
<th>{company.id}</th>
<td>{company.name}</td>
<td>{company.name} ({company.region.name})</td>
<td>{company.short}</td>
<td>{company.region.name}</td>
<td className="text-right">

@ -184,6 +184,7 @@ export default function FormDocument(props) {
<TextInput
type="date"
name="publish_date"
placeholder='dd-mm-yyyy'
value={data.publish_date}
className="mt-1 block w-full"
autoComplete={"false"}

@ -148,7 +148,7 @@ export default function Document(props) {
<tbody>
{docs?.map((doc) => (
<tr key={doc.id}>
<td>{doc.company.short}</td>
<td>{doc.company.short} ({doc.company.region.name})</td>
<td>{doc.variety.name}</td>
<td>{doc.category.name}</td>
<td>{doc.no_doc}</td>

@ -3,10 +3,10 @@
Reminder, untuk dokumen perlu diperhatikan :
@foreach($documents as $document)
{{ $document->no_doc }} {{ $document->name }} | {{ $document->due_status }}
{{ $document->no_doc }} {{ $document->name }} {{ $document->variety->name }} | {{ $document->due_status }}
@endforeach
@foreach($dueDocuments as $document)
{{ $document->no_doc }} {{ $document->name }} | {{ $document->due_status }}
{{ $document->no_doc }} {{ $document->name }} {{ $document->variety->name }} | {{ $document->due_status }}
@endforeach
Terima kasih , <br>

Loading…
Cancel
Save