Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/Helpers/Cetak.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static function cetak($jenis, $id)
$templateProcessor->setValues($data);
$filename = $jenis.'_'.session('year').'_'.explode('/', $data['nomor'])[0].'.docx';
$templateProcessor->saveAs(Storage::path('public/'.$jenis.'/'.$filename));

return $filename;
}

Expand Down Expand Up @@ -62,7 +63,7 @@ public static function kak($id)
'tanggal_dipa' => Helper::terbilangTanggal(Helper::getDipa($data->tahun)->tanggal),
'tahun' => $data->tahun,
'jabatan' => $data->jabatan,
'waktu' => Helper::jangkaWaktuHariKalender($data->awal,$data->akhir),
'waktu' => Helper::jangkaWaktuHariKalender($data->awal, $data->akhir),
'awal' => Helper::terbilangTanggal($data->awal),
'akhir' => Helper::terbilangTanggal($data->akhir),
'ppk' => $data->ppk,
Expand Down
19 changes: 7 additions & 12 deletions app/Helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -748,19 +748,20 @@ public static function formatAnggaran($anggaran)
}

/**
* Mengambil Path Template
* Mengambil Path Template.
*
* @param string $jenis
* @return string
*/
public static function getTemplatePath($jenis)
{
$file = Template::cache()->get('all')->where('slug','template_'.$jenis)->first()->file;
$file = Template::cache()->get('all')->where('slug', 'template_'.$jenis)->first()->file;

return Storage::disk('templates')->path($file);
}

/**
* Mengambil Keterangan DIPA
* Mengambil Keterangan DIPA.
*
* @param string $tahun
* @return collection
Expand All @@ -771,7 +772,7 @@ public static function getDipa($tahun)
}

/**
* Menghapus titik di akhir kalimat
* Menghapus titik di akhir kalimat.
*
* @param string $kalimat
* @return string
Expand All @@ -782,7 +783,7 @@ public static function hapusTitikAkhirKalimat($kalimat)
}

/**
* Menghapus File dokumen
* Menghapus File dokumen.
*
* @param string $id
* @return void
Expand All @@ -792,14 +793,8 @@ public static function hapusFile($jenis, $id)
if ($jenis == 'kak') {
$naskah_id = KerangkaAcuan::find($id)->naskah_keluar_id;
$nomor = NaskahKeluar::find($naskah_id)->nomor;
}
}
$filename = $jenis.'_'.session('year').'_'.explode('/', $nomor)[0].'.docx';
File::delete(Storage::path('public/'.$jenis.'/'.$filename));

}





}
8 changes: 3 additions & 5 deletions app/Models/KerangkaAcuan.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Models;

use App\Helpers\Helper;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand Down Expand Up @@ -48,10 +47,10 @@ protected static function booted(): void
$naskahkeluar->save();
$kak->naskah_keluar_id = $naskahkeluar->id;

$user = User::cache()->get('all')->where('role', 'koordinator')->where('unit_kerja_id' , Auth::user()->unit_kerja_id)->first();
$user = User::cache()->get('all')->where('role', 'koordinator')->where('unit_kerja_id', Auth::user()->unit_kerja_id)->first();
$kak->nama = $user->nama;
$kak->nip = $user->nip;
$kak->jabatan = $user->jabatan == 'Kepala Subbagian Umum' ? 'Kepala Subbagian Umum': 'Penanggung Jawab Kegiatan';
$kak->jabatan = $user->jabatan == 'Kepala Subbagian Umum' ? 'Kepala Subbagian Umum' : 'Penanggung Jawab Kegiatan';
$kak->unit_kerja_id = Auth::user()->unit_kerja_id;
$kak->ppk = Helper::getPengelola('ppk')->nama;
$kak->nipppk = Helper::getPengelola('ppk')->nip;
Expand All @@ -64,10 +63,9 @@ protected static function booted(): void
$naskahkeluar->save();
});
static::deleting(function (KerangkaAcuan $kak) {
Helper::hapusFile('kak',$kak->id);
Helper::hapusFile('kak', $kak->id);
NaskahKeluar::where('id', $kak->naskah_keluar_id)->delete();
HonorSurvei::where('kerangka_acuan_id', $kak->id)->delete();

});
static::saving(function (KerangkaAcuan $kak) {
if ($kak->jenis !== 'Penyedia') {
Expand Down
6 changes: 3 additions & 3 deletions app/Nova/Actions/Download.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Helpers\Cetak;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Storage;
Expand All @@ -20,13 +19,13 @@ class Download extends Action
protected $jenis;
protected $title;

public function __construct($jenis , $title = 'Unduh')
public function __construct($jenis, $title = 'Unduh')
{
$this->jenis = $jenis;
$this->title = $title;
}

public function name ()
public function name()
{
return $this->title;
}
Expand All @@ -42,6 +41,7 @@ public function handle(ActionFields $fields, Collection $models)
{
$model = $models->first();
$filename = Cetak::cetak($this->jenis, $model->id);

return ActionResponse::download($filename, Storage::disk($this->jenis)->url($filename));
}

Expand Down
2 changes: 0 additions & 2 deletions app/Nova/KerangkaAcuan.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use App\Nova\Repeater\Anggaran;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\Boolean;
use Laravel\Nova\Fields\Currency;
Expand All @@ -20,7 +19,6 @@
use Laravel\Nova\Fields\Stack;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Textarea;
use Laravel\Nova\Fields\URL;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Panel;
use Outl1ne\NovaSimpleRepeatable\SimpleRepeatable;
Expand Down