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
28 changes: 15 additions & 13 deletions app/Helpers/Cetak.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ class Cetak
public static function cetak($jenis, $models)
{
$index = 0;
$mainXml ='';
$mainXml = '';
foreach ($models as $model) {
if ($index === 0) {
$mainTemplate = self::getTemplate($jenis, $model->id);
$mainXml = self::getMainXml($mainTemplate);
$data = call_user_func('App\Helpers\Cetak::'.$jenis, $model->id);
} else {
$innerTemplate = self::getTemplate($jenis, $model->id);
$innerXml = self::getModifiedInnerXml($innerTemplate);
$mainXml = preg_replace('/<\/w:body>/', '<w:p><w:r><w:br w:type="page" /><w:lastRenderedPageBreak/></w:r></w:p>' . $innerXml . '</w:body>', $mainXml);
}
$index++;
if ($index === 0) {
$mainTemplate = self::getTemplate($jenis, $model->id);
$mainXml = self::getMainXml($mainTemplate);
$data = call_user_func('App\Helpers\Cetak::'.$jenis, $model->id);
} else {
$innerTemplate = self::getTemplate($jenis, $model->id);
$innerXml = self::getModifiedInnerXml($innerTemplate);
$mainXml = preg_replace('/<\/w:body>/', '<w:p><w:r><w:br w:type="page" /><w:lastRenderedPageBreak/></w:r></w:p>'.$innerXml.'</w:body>', $mainXml);
}
$index++;
}
$mainTemplate->settempDocumentMainPart($mainXml);
($index === 1) ? $filename = $jenis.'_'.session('year').'_'.explode('/', $data['nomor'])[0].'.docx' : $filename = uniqid().'.docx';
Expand All @@ -57,6 +57,7 @@ public static function getTemplate($jenis, $id)
unset($data['anggaran'], $data['spesifikasi']);
}
$templateProcessor->setValues($data);

return $templateProcessor;
}

Expand All @@ -67,7 +68,7 @@ public static function getTemplate($jenis, $id)
* @return string
*/
public static function getMainXml($templateProcessor)
{
{
return $templateProcessor->gettempDocumentMainPart();
}

Expand All @@ -78,10 +79,11 @@ public static function getMainXml($templateProcessor)
* @return string
*/
public static function getModifiedInnerXml($templateProcessor)
{
{
$innerXml = $templateProcessor->gettempDocumentMainPart();
$innerXml = preg_replace('/^[\s\S]*<w:body>(.*)<\/w:body>.*/', '$1', $innerXml);
$innerXml = preg_replace('/<w:sectPr>.*<\/w:sectPr>/', '', $innerXml);

return $innerXml;
}

Expand Down
3 changes: 0 additions & 3 deletions app/Helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use App\Models\JenisKontrak;
use App\Models\JenisNaskah;
use App\Models\KamusAnggaran;
use App\Models\KerangkaAcuan;
use App\Models\KodeArsip;
use App\Models\KodeNaskah;
use App\Models\NaskahKeluar;
Expand All @@ -15,7 +14,6 @@
use App\Models\UnitKerja;
use App\Models\User;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;

Expand Down Expand Up @@ -781,5 +779,4 @@ public static function hapusTitikAkhirKalimat($kalimat)
{
return rtrim($kalimat, '.');
}

}
5 changes: 3 additions & 2 deletions app/Http/Controllers/DumpDownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

class DumpDownloadController extends Controller
{
public function show( $filename, Request $request )
public function show($filename, Request $request)
{
$path = Storage::path('public/'.$filename);
return response()->download( $path, $filename )->deleteFileAfterSend(true);

return response()->download($path, $filename)->deleteFileAfterSend(true);
}
}
10 changes: 3 additions & 7 deletions app/Nova/Actions/Download.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
namespace App\Nova\Actions;

use App\Helpers\Cetak;
use App\Helpers\TemplateProcessor;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Storage;
use Laravel\Nova\Actions\Action;
use Laravel\Nova\Actions\ActionResponse;
use Laravel\Nova\Fields\ActionFields;
use Laravel\Nova\Http\Requests\NovaRequest;

Expand Down Expand Up @@ -42,10 +39,9 @@ public function handle(ActionFields $fields, Collection $models)
{
$filename = Cetak::cetak($this->jenis, $models);

return Action::redirect( route('dump-download', [
'filename' => $filename, 'jenis'=>$this->jenis
] ) );

return Action::redirect(route('dump-download', [
'filename' => $filename, 'jenis' => $this->jenis,
]));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lang/en/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
declare(strict_types=1);

return [
'failed' => 'These credentials do not match our records.',
'failed' => 'These credentials do not match our records.',
'password' => 'The password is incorrect.',
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
];
2 changes: 1 addition & 1 deletion lang/en/pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
declare(strict_types=1);

return [
'next' => 'Next &raquo;',
'next' => 'Next &raquo;',
'previous' => '&laquo; Previous',
];
8 changes: 4 additions & 4 deletions lang/en/passwords.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

return [
'reset' => 'Your password has been reset.',
'sent' => 'We have emailed your password reset link.',
'reset' => 'Your password has been reset.',
'sent' => 'We have emailed your password reset link.',
'throttled' => 'Please wait before retrying.',
'token' => 'This password reset token is invalid.',
'user' => 'We can\'t find a user with that email address.',
'token' => 'This password reset token is invalid.',
'user' => 'We can\'t find a user with that email address.',
];
Loading