diff --git a/.env b/.env index 0f0fba7..84e8fb8 100644 --- a/.env +++ b/.env @@ -25,7 +25,7 @@ LOG_DEPRECATIONS_CHANNEL=null LOG_LEVEL=debug DB_CONNECTION=mysql -DB_HOST=db.upsense.co.id +DB_HOST=mysql.upsense.co.id DB_PORT=3306 DB_DATABASE=xpendify DB_USERNAME=root diff --git a/app/Http/Controllers/Backend/ReportController.php b/app/Http/Controllers/Backend/ReportController.php index de78b11..ca8e854 100644 --- a/app/Http/Controllers/Backend/ReportController.php +++ b/app/Http/Controllers/Backend/ReportController.php @@ -17,6 +17,7 @@ use App\Models\Cabang; use App\Models\Region; use App\Helpers\FormHelper; use App\Helpers\BudgetHelper; +use App\Models\Admin; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Schema; use App\Models\Kategori; @@ -591,10 +592,51 @@ class ReportController extends Controller // Get the forms after all filters have been applied // Sort by 'tanggal' if it exists, otherwise by 'created_at' - $forms = $formsQuery->orderBy( - Schema::hasColumn('form_others', 'tanggal') ? 'tanggal' : 'created_at', - 'desc' - )->get(); + + $tables = [ + 'form_others', + 'form_up_country', + 'form_vehicle_running_cost', + 'form_meeting_seminar', + 'form_entertainment_presentation' + ]; + + $formsQuery = null; + + foreach ($tables as $table) { + $query = DB::table($table) + ->selectRaw(" + expense_number, + '$table' as type, + user_id, + total, + approved_total, + account_number, + status, + created_at + "); + + $formsQuery = $formsQuery + ? $formsQuery->unionAll($query) + : $query; + } + + $forms = DB::query() + ->fromSub($formsQuery, 'forms') + ->join('admins', 'admins.id', '=', 'forms.user_id') + ->select('forms.*', 'admins.id as admin_id') + ->orderBy('forms.created_at', 'desc') + ->paginate(100); + + + + // inject relasi Admin model ke setiap item + $forms->getCollection()->transform(function ($item) { + $item->user = \App\Models\Admin::with(['region', 'rayon.region'])->find($item->admin_id); + $item->type = ucwords(str_replace('_', ' ', str_replace('form_', '', $item->type))); + + return $item; + }); return view('backend.pages.report.all', [ diff --git a/app/Http/Controllers/Forms/FormUpCountryController.php b/app/Http/Controllers/Forms/FormUpCountryController.php index 0a74f1d..de86299 100644 --- a/app/Http/Controllers/Forms/FormUpCountryController.php +++ b/app/Http/Controllers/Forms/FormUpCountryController.php @@ -29,6 +29,7 @@ use App\Helpers\NotificationHelper; use Illuminate\Support\Facades\Log; use App\Services\BrevoService; use Carbon\Carbon; +use Illuminate\Container\Attributes\Auth; class FormUpCountryController extends Controller { @@ -372,7 +373,19 @@ class FormUpCountryController extends Controller $role = auth()->user()->getRoleNames()[0]; $cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang; + $regionId = Cabang::where('id', 1)->value('region_id'); + $rayonData = Rayon::where('cabang_id', $cabang->id)->get(); + if ($role = "Admin Region" || "Marketing Information System" || "Superadmin") { + $rayonData = DB::table('rayon') + ->join('cabang', 'rayon.cabang_id', '=', 'cabang.id') + ->join('region', 'cabang.region_id', '=', 'region.id') + ->where('region.id', $regionId) + ->select('rayon.*') + ->get(); + + } + $form = FormUpCountry::with('rayon')->findOrfail($id); if (($form->status != 'On Progress' && $form->status != 'Rejected') && $role == 'Medical Representatif') { session()->flash('error', 'You cannot edit this form because it has been approved or closed.'); @@ -380,7 +393,7 @@ class FormUpCountryController extends Controller } return view('backend.pages.forms.upcountry.edit', [ - 'rayons' => Rayon::where('cabang_id', $cabang->id)->get(), + 'rayons' => $rayonData, 'form' => $form ]); } diff --git a/app/Models/Admin.php b/app/Models/Admin.php index f100981..00c43dd 100644 --- a/app/Models/Admin.php +++ b/app/Models/Admin.php @@ -168,6 +168,11 @@ class Admin extends Authenticatable return $this->belongsTo(Rayon::class, 'rayon_id'); } + public function rayon() + { + return $this->belongsTo(Rayon::class, 'rayon_id'); + } + public function getRegion() { return $this->belongsTo(Region::class, 'region_id'); diff --git a/app/Models/Rayon.php b/app/Models/Rayon.php index 8a5436d..7aca1b9 100644 --- a/app/Models/Rayon.php +++ b/app/Models/Rayon.php @@ -16,4 +16,9 @@ class Rayon extends Model { return $this->belongsTo('App\Models\Cabang'); } + + public function region() +{ + return $this->belongsTo(\App\Models\Region::class, 'region_id', 'id'); +} } diff --git a/composer.json b/composer.json index a9a2156..0551ea9 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,6 @@ "yajra/laravel-datatables-oracle": "11.0" }, "require-dev": { - "barryvdh/laravel-debugbar": "^3.14", "fakerphp/faker": "^1.23", "laravel/pail": "^1.1", "laravel/pint": "^1.13", diff --git a/composer.lock b/composer.lock index be6d833..2460a4c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2576aa0bcffcd93e0f78de10eefa63c1", + "content-hash": "1ad355916564d86a9848db17b8afa298", "packages": [ { "name": "barryvdh/laravel-dompdf", @@ -8305,90 +8305,6 @@ } ], "packages-dev": [ - { - "name": "barryvdh/laravel-debugbar", - "version": "v3.14.10", - "source": { - "type": "git", - "url": "https://github.com/barryvdh/laravel-debugbar.git", - "reference": "56b9bd235e3fe62e250124804009ce5bab97cc63" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/56b9bd235e3fe62e250124804009ce5bab97cc63", - "reference": "56b9bd235e3fe62e250124804009ce5bab97cc63", - "shasum": "" - }, - "require": { - "illuminate/routing": "^9|^10|^11", - "illuminate/session": "^9|^10|^11", - "illuminate/support": "^9|^10|^11", - "maximebf/debugbar": "~1.23.0", - "php": "^8.0", - "symfony/finder": "^6|^7" - }, - "require-dev": { - "mockery/mockery": "^1.3.3", - "orchestra/testbench-dusk": "^5|^6|^7|^8|^9", - "phpunit/phpunit": "^9.6|^10.5", - "squizlabs/php_codesniffer": "^3.5" - }, - "type": "library", - "extra": { - "laravel": { - "aliases": { - "Debugbar": "Barryvdh\\Debugbar\\Facades\\Debugbar" - }, - "providers": [ - "Barryvdh\\Debugbar\\ServiceProvider" - ] - }, - "branch-alias": { - "dev-master": "3.14-dev" - } - }, - "autoload": { - "files": [ - "src/helpers.php" - ], - "psr-4": { - "Barryvdh\\Debugbar\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Barry vd. Heuvel", - "email": "barryvdh@gmail.com" - } - ], - "description": "PHP Debugbar integration for Laravel", - "keywords": [ - "debug", - "debugbar", - "laravel", - "profiler", - "webprofiler" - ], - "support": { - "issues": "https://github.com/barryvdh/laravel-debugbar/issues", - "source": "https://github.com/barryvdh/laravel-debugbar/tree/v3.14.10" - }, - "funding": [ - { - "url": "https://fruitcake.nl", - "type": "custom" - }, - { - "url": "https://github.com/barryvdh", - "type": "github" - } - ], - "time": "2024-12-23T10:10:42+00:00" - }, { "name": "fakerphp/faker", "version": "v1.24.1", @@ -8781,74 +8697,6 @@ }, "time": "2024-11-27T15:42:28+00:00" }, - { - "name": "maximebf/debugbar", - "version": "v1.23.5", - "source": { - "type": "git", - "url": "https://github.com/php-debugbar/php-debugbar.git", - "reference": "eeabd61a1f19ba5dcd5ac4585a477130ee03ce25" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-debugbar/php-debugbar/zipball/eeabd61a1f19ba5dcd5ac4585a477130ee03ce25", - "reference": "eeabd61a1f19ba5dcd5ac4585a477130ee03ce25", - "shasum": "" - }, - "require": { - "php": "^7.2|^8", - "psr/log": "^1|^2|^3", - "symfony/var-dumper": "^4|^5|^6|^7" - }, - "require-dev": { - "dbrekelmans/bdi": "^1", - "phpunit/phpunit": "^8|^9", - "symfony/panther": "^1|^2.1", - "twig/twig": "^1.38|^2.7|^3.0" - }, - "suggest": { - "kriswallsmith/assetic": "The best way to manage assets", - "monolog/monolog": "Log using Monolog", - "predis/predis": "Redis storage" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.23-dev" - } - }, - "autoload": { - "psr-4": { - "DebugBar\\": "src/DebugBar/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Maxime Bouroumeau-Fuseau", - "email": "maxime.bouroumeau@gmail.com", - "homepage": "http://maximebf.com" - }, - { - "name": "Barry vd. Heuvel", - "email": "barryvdh@gmail.com" - } - ], - "description": "Debug bar in the browser for php application", - "homepage": "https://github.com/maximebf/php-debugbar", - "keywords": [ - "debug", - "debugbar" - ], - "support": { - "issues": "https://github.com/php-debugbar/php-debugbar/issues", - "source": "https://github.com/php-debugbar/php-debugbar/tree/v1.23.5" - }, - "time": "2024-12-15T19:20:42+00:00" - }, { "name": "mockery/mockery", "version": "1.6.12", diff --git a/config/octane.php b/config/octane.php new file mode 100644 index 0000000..8cfba01 --- /dev/null +++ b/config/octane.php @@ -0,0 +1,224 @@ + env('OCTANE_SERVER', 'roadrunner'), + + /* + |-------------------------------------------------------------------------- + | Force HTTPS + |-------------------------------------------------------------------------- + | + | When this configuration value is set to "true", Octane will inform the + | framework that all absolute links must be generated using the HTTPS + | protocol. Otherwise your links may be generated using plain HTTP. + | + */ + + 'https' => env('OCTANE_HTTPS', false), + + /* + |-------------------------------------------------------------------------- + | Octane Listeners + |-------------------------------------------------------------------------- + | + | All of the event listeners for Octane's events are defined below. These + | listeners are responsible for resetting your application's state for + | the next request. You may even add your own listeners to the list. + | + */ + + 'listeners' => [ + WorkerStarting::class => [ + EnsureUploadedFilesAreValid::class, + EnsureUploadedFilesCanBeMoved::class, + ], + + RequestReceived::class => [ + ...Octane::prepareApplicationForNextOperation(), + ...Octane::prepareApplicationForNextRequest(), + // + ], + + RequestHandled::class => [ + // + ], + + RequestTerminated::class => [ + // FlushUploadedFiles::class, + ], + + TaskReceived::class => [ + ...Octane::prepareApplicationForNextOperation(), + // + ], + + TaskTerminated::class => [ + // + ], + + TickReceived::class => [ + ...Octane::prepareApplicationForNextOperation(), + // + ], + + TickTerminated::class => [ + // + ], + + OperationTerminated::class => [ + FlushOnce::class, + FlushTemporaryContainerInstances::class, + // DisconnectFromDatabases::class, + // CollectGarbage::class, + ], + + WorkerErrorOccurred::class => [ + ReportException::class, + StopWorkerIfNecessary::class, + ], + + WorkerStopping::class => [ + CloseMonologHandlers::class, + ], + ], + + /* + |-------------------------------------------------------------------------- + | Warm / Flush Bindings + |-------------------------------------------------------------------------- + | + | The bindings listed below will either be pre-warmed when a worker boots + | or they will be flushed before every new request. Flushing a binding + | will force the container to resolve that binding again when asked. + | + */ + + 'warm' => [ + ...Octane::defaultServicesToWarm(), + ], + + 'flush' => [ + // + ], + + /* + |-------------------------------------------------------------------------- + | Octane Swoole Tables + |-------------------------------------------------------------------------- + | + | While using Swoole, you may define additional tables as required by the + | application. These tables can be used to store data that needs to be + | quickly accessed by other workers on the particular Swoole server. + | + */ + + 'tables' => [ + 'example:1000' => [ + 'name' => 'string:1000', + 'votes' => 'int', + ], + ], + + /* + |-------------------------------------------------------------------------- + | Octane Swoole Cache Table + |-------------------------------------------------------------------------- + | + | While using Swoole, you may leverage the Octane cache, which is powered + | by a Swoole table. You may set the maximum number of rows as well as + | the number of bytes per row using the configuration options below. + | + */ + + 'cache' => [ + 'rows' => 1000, + 'bytes' => 10000, + ], + + /* + |-------------------------------------------------------------------------- + | File Watching + |-------------------------------------------------------------------------- + | + | The following list of files and directories will be watched when using + | the --watch option offered by Octane. If any of the directories and + | files are changed, Octane will automatically reload your workers. + | + */ + + 'watch' => [ + 'app', + 'bootstrap', + 'config/**/*.php', + 'database/**/*.php', + 'public/**/*.php', + 'resources/**/*.php', + 'routes', + 'composer.lock', + '.env', + ], + + /* + |-------------------------------------------------------------------------- + | Garbage Collection Threshold + |-------------------------------------------------------------------------- + | + | When executing long-lived PHP scripts such as Octane, memory can build + | up before being cleared by PHP. You can force Octane to run garbage + | collection if your application consumes this amount of megabytes. + | + */ + + 'garbage' => 50, + + /* + |-------------------------------------------------------------------------- + | Maximum Execution Time + |-------------------------------------------------------------------------- + | + | The following setting configures the maximum execution time for requests + | being handled by Octane. You may set this value to 0 to indicate that + | there isn't a specific time limit on Octane request execution time. + | + */ + + 'max_execution_time' => 30, + +]; diff --git a/frankenphp b/frankenphp new file mode 100644 index 0000000..6321c3d Binary files /dev/null and b/frankenphp differ diff --git a/public/.user.ini b/public/.user.ini new file mode 100644 index 0000000..0cbffa0 --- /dev/null +++ b/public/.user.ini @@ -0,0 +1,4 @@ +upload_max_filesize = 1024M +post_max_size = 1024M +memory_limit = 512M +max_execution_time = 300 \ No newline at end of file diff --git a/public/frankenphp-worker.php b/public/frankenphp-worker.php new file mode 100644 index 0000000..8608d9a --- /dev/null +++ b/public/frankenphp-worker.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/public/templates/login/images/bg-1.png b/public/templates/login/images/bg-1.png index 3f467a9..b97311c 100644 Binary files a/public/templates/login/images/bg-1.png and b/public/templates/login/images/bg-1.png differ diff --git a/public/templates/login/images/bg-1b.png b/public/templates/login/images/bg-1b.png new file mode 100644 index 0000000..f742c3a Binary files /dev/null and b/public/templates/login/images/bg-1b.png differ diff --git a/public/templates/login/images/bg-1c.png b/public/templates/login/images/bg-1c.png new file mode 100644 index 0000000..3f467a9 Binary files /dev/null and b/public/templates/login/images/bg-1c.png differ diff --git a/resources/views/backend/pages/admins/index.blade.php b/resources/views/backend/pages/admins/index.blade.php index dcd1ece..e6501c2 100644 --- a/resources/views/backend/pages/admins/index.blade.php +++ b/resources/views/backend/pages/admins/index.blade.php @@ -47,6 +47,7 @@