last fixing

original
ajikamaludin 2 years ago
parent 02f5286ede
commit 5728be045a
Signed by: ajikamaludin
GPG Key ID: 476C9A2B4B794EBB

@ -30,6 +30,7 @@ class DocumentController extends Controller
$query->where('no_doc', 'like', '%'.$request->q.'%')
->orWhere('company_name', 'like', '%'.$request->q.'%')
->orWhere('pic_name', 'like', '%'.$request->q.'%')
->orWhere('name', 'like', '%'.$request->q.'%')
->orWhere('email', 'like', '%'.$request->q.'%');
});
}
@ -77,13 +78,15 @@ class DocumentController extends Controller
'document' => 'required|file',
'note' => 'nullable',
'status' => 'required|numeric',
'reminders' => 'nullable|array'
'reminders' => 'nullable|array',
'name' => 'required|string'
]);
$lastDocs = Document::orderBy('created_at', 'desc')->first();
$lastDocs = $lastDocs ? $lastDocs : Document::make(['no' => 0]);
$docs = Document::make([
'no' => $lastDocs->no + 1,
'name' => $request->name,
'no_doc' => $request->no_doc,
'company_name' => $request->company_name,
'first_person_name' => $request->first_person_name,
@ -141,12 +144,14 @@ class DocumentController extends Controller
'email' => 'required|email',
'document' => 'nullable|file',
'note' => 'nullable',
'name' => 'required|string',
'status' => 'required|numeric',
]);
$doc->fill([
'no_doc' => $request->no_doc,
'name' => $request->name,
'company_name' => $request->company_name,
'first_person_name' => $request->first_person_name,
'second_person_name' => $request->second_person_name,
@ -218,6 +223,7 @@ class DocumentController extends Controller
foreach ($query->get() as $document) {
$collections->add([
'no dokumen' => $document->no_doc,
'nama' => $document->name,
'jenis dokumen' => $document->type->name,
'nama perusahaan' => $document->company_name,
'nama pihak pertama' => $document->first_person_name,

@ -15,7 +15,7 @@ class GeneralController extends Controller
'count_update' => Document::where('status', Document::UPDATE)->count(),
'count_expired' => Document::where('status', Document::EXPIRED)->count(),
'count_total' => Document::count(),
'events' => DocumentReminder::with('document')->get(),
'events' => DocumentReminder::with('document.type')->get(),
]);
}
}

@ -9,8 +9,10 @@ use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Log\Logger;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
class DocumentReminder implements ShouldQueue
@ -36,13 +38,15 @@ class DocumentReminder implements ShouldQueue
{
$now = now();
$documentIds = ModelsDocumentReminder::whereDate('date', $now)->pluck('document_id');
Log::info("DocumentReminder:: Schedule Run $now , with $documentIds");
$documents = Document::whereIn('id', $documentIds)->get();
foreach ($documents as $doc) {
Mail::to($doc->email)->queue(new DocumentNotification($doc));
Mail::to($doc->email)->send(new DocumentNotification($doc));
if ($doc->shares()->count() > 0) {
foreach ($doc->shares as $share) {
Mail::to($share->share_to)->queue(new DocumentNotification($doc));
Mail::to($share->share_to)->send(new DocumentNotification($doc));
}
}
}

@ -30,9 +30,8 @@ class DocumentNotification extends Mailable
public function build()
{
return $this->markdown('emails.document.notification', [
'no_doc' => $this->doc->no_doc,
'end_date' => $this->doc->end_date->format('d-m-Y'),
'url' => route('docs.show', $this->doc)
'doc' => $this->doc->load(['type']),
'url' => route('docs.show', $this->doc->id)
]);
}
}

@ -25,6 +25,7 @@ class Document extends Model
'document',
'status',
'user_id',
'name',
];
protected $casts = [

@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
return new class extends Migration {
/**
* Run the migrations.
*
@ -16,6 +15,7 @@ return new class extends Migration
Schema::create('documents', function (Blueprint $table) {
$table->id();
$table->integer('no', false);
$table->string('name');
$table->string('no_doc');
$table->foreignId('type_doc_id')->constrained();
$table->string('company_name');

@ -13,7 +13,7 @@ export default function Dashboard(props) {
const calenderEvents = events.map(e => {
return {
title: `${e.document.no_doc} - ${e.document.pic_name}`,
title: `${e.document.type.name} - ${e.document.name}`,
date: e.date,
id : e.id,
url: route('docs.show', e.document)

@ -20,6 +20,7 @@ export default function FormDocument(props) {
const [reminders, setReminders] = useState([])
const { data, setData, post, processing, errors, reset } = useForm({
no_doc: '',
name: '',
email: '',
type_doc_id: '1',
department_id: '1',
@ -40,6 +41,7 @@ export default function FormDocument(props) {
if(doc !== undefined) {
setData({
no_doc: doc.no_doc,
name: doc.name,
email: doc.email,
type_doc_id: doc.type_doc_id,
department_id: doc.department_id,
@ -130,6 +132,19 @@ export default function FormDocument(props) {
</select>
<InputError message={errors.type_doc_id}/>
</div>
<div>
<InputLabel forInput="name" value="Nama Dokumen" />
<TextInput
type="text"
name="name"
value={data.name}
className="mt-1 block w-full"
autoComplete={"false"}
handleChange={onHandleChange}
isError={errors.name}
/>
<InputError message={errors.name}/>
</div>
<div className='mt-4'>
<InputLabel forInput="company_name" value="Nama Perusahaan" />
<TextInput

@ -112,6 +112,7 @@ export default function Document(props) {
<thead>
<tr>
<th className='hover:underline' onClick={() => sort('type_doc_id')}>Jenis</th>
<th>Nama Dokumen</th>
<th>Nama PIC</th>
<th className='hover:underline' onClick={() => sort('end_date')}>Tanggal Berakhir</th>
<th className='hover:underline' onClick={() => sort('status')}>Status</th>
@ -122,6 +123,7 @@ export default function Document(props) {
{docs?.map((doc) => (
<tr key={doc.id}>
<td>{doc.type.name}</td>
<td>{doc.name}</td>
<td>{doc.pic_name}</td>
<td>{formatDate(doc.end_date)}</td>
<td><DocStatusItem status={doc.status}/></td>

@ -1,7 +1,14 @@
@component('mail::message')
# Dokumen Notifikasi
Reminder, untuk dokument <b>{{ $no_doc }}</b> akan berakhir pada {{ $end_date }} mohon untuk segera melakukan tindakan
Reminder, untuk dokumen dengan detail :
No Dokumen : {{ $doc->no_doc }} <br/>
Jenis Dokumen : {{ $doc->type->name }} <br/>
Nama Dokumen : {{ $doc->name }} <br/>
Nama Perusahaan : {{ $doc->company_name }} <br/>
Akan berakhir pada <b>{{ $doc->end_date->format('d-m-Y') }}</b> mohon untuk segera melakukan tindakan
@component('mail::button', ['url' => $url])
Detail Dokumen

Loading…
Cancel
Save