Merge branch 'afiqhamzah/feat/overall-report' into ujrah_master
Merge wip feature
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Cawangan;
|
||||
use App\Customer;
|
||||
use App\Gadai;
|
||||
|
||||
class ReportGadaiController extends Controller
|
||||
{
|
||||
public function getLaporanGadai($kodcaw, $tarikh)
|
||||
{
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw', '=', $kodcaw)->first();
|
||||
|
||||
$gadai_data = Gadai::on($cawangan['mysql'])->select('t_gadai', 'norujukan', 'nokp', 'semakbarcode', 'masa', 'berat', 'nilaimarhun', 'pinjaman', 'upah12', 'percentpinj', 'teller', 'nokp')
|
||||
->where('t_gadai', '=', $tarikh)
|
||||
->orderBy('teller')
|
||||
->orderBy('sirig')
|
||||
->get();
|
||||
|
||||
$gadai = [];
|
||||
|
||||
if ($gadai_data) {
|
||||
foreach ($gadai_data as $index => $gadaiData) {
|
||||
$customer_info = Customer::on('mysql7')->where('kplama', '=', $gadaiData['nokp'])->orWhere('kpbaru', '=', $gadaiData['nokp'])->first();
|
||||
array_push($gadai, [
|
||||
"t_gadai" => $gadaiData['t_gadai'],
|
||||
"norujukan" => $gadaiData['norujukan'],
|
||||
"nama" => $customer_info['nama'],
|
||||
"nokp" => $gadaiData['nokp'],
|
||||
"semakbarcode" => $gadaiData['semakbarcode'],
|
||||
"masa" => $gadaiData['masa'],
|
||||
"berat" => $gadaiData['berat'],
|
||||
"nilaimarhun" => $gadaiData['nilaimarhun'],
|
||||
"pinjaman" => $gadaiData['pinjaman'],
|
||||
"upah12" => $gadaiData['upah12'],
|
||||
"percentpinj" => $gadaiData['percentpinj'],
|
||||
"alamat1" => $customer_info['alamat1'],
|
||||
"teller" => $gadaiData['teller'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json($gadai);
|
||||
}
|
||||
public function getLaporanGadaiAll()
|
||||
{
|
||||
|
||||
$tarikh = '2023-11-01';
|
||||
|
||||
$active_cawangan_db_connection = getActiveCawanganDbConnection();
|
||||
|
||||
$active_cawangan_db = array_map(function ($connection) {
|
||||
return config('database.connections.' . $connection)['database'];
|
||||
}, $active_cawangan_db_connection);
|
||||
|
||||
$active_cawangan_name = Cawangan::whereIn('db_name', $active_cawangan_db)->pluck('details_caw')->toArray();
|
||||
|
||||
$gadai_data = array_map(function ($db_connection) use ($tarikh) {
|
||||
$gadai = Gadai::on($db_connection)->select('t_gadai', 'norujukan', 'nokp', 'semakbarcode', 'masa', 'berat', 'nilaimarhun', 'pinjaman', 'upah12', 'percentpinj', 'teller', 'nokp')
|
||||
->where('t_gadai', '=', $tarikh)
|
||||
->orderBy('teller')
|
||||
->orderBy('sirig')
|
||||
->get();
|
||||
|
||||
return $gadai->toArray();
|
||||
}, $active_cawangan_db_connection);
|
||||
|
||||
$gadai_data_with_key = array_combine($active_cawangan_name, $gadai_data);
|
||||
|
||||
$overall_data_gadai = array_map(function ($gadaian_cawangan) {
|
||||
return array_map(function ($gadai) {
|
||||
|
||||
$customer_info = Customer::on('mysql7')->where('kplama', '=', $gadai['nokp'])->orWhere('kpbaru', '=', $gadai['nokp'])->first()->toArray();
|
||||
|
||||
return [
|
||||
"t_gadai" => $gadai['t_gadai'],
|
||||
"norujukan" => $gadai['norujukan'],
|
||||
"nama" => $customer_info['nama'],
|
||||
"nokp" => $gadai['nokp'],
|
||||
"semakbarcode" => $gadai['semakbarcode'],
|
||||
"masa" => $gadai['masa'],
|
||||
"berat" => $gadai['berat'],
|
||||
"nilaimarhun" => $gadai['nilaimarhun'],
|
||||
"pinjaman" => $gadai['pinjaman'],
|
||||
"upah12" => $gadai['upah12'],
|
||||
"percentpinj" => $gadai['percentpinj'],
|
||||
"alamat1" => $customer_info['alamat1'],
|
||||
"teller" => $gadai['teller'],
|
||||
];
|
||||
|
||||
}, $gadaian_cawangan);
|
||||
|
||||
}, $gadai_data_with_key);
|
||||
|
||||
return response()->json($overall_data_gadai);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
if (!function_exists('getActiveCawanganDbConnection')) {
|
||||
|
||||
function getActiveCawanganDbConnection()
|
||||
{
|
||||
|
||||
$all_active_db_keys = array_filter(array_keys(config('database.connections')), function ($connection) {
|
||||
try {
|
||||
DB::connection($connection)->getPdo();
|
||||
return true;
|
||||
} catch (\Throwable $th) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$non_cawangan_database = ['lelong', 'online_arrahn', 'kaunterpkb'];
|
||||
|
||||
$all_cawangan_db = array_filter($all_active_db_keys, function ($db_key) use ($non_cawangan_database) {
|
||||
$isNotCawangan = in_array(config('database.connections.' . $db_key . '.database'), $non_cawangan_database);
|
||||
|
||||
if ($isNotCawangan) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return $all_cawangan_db;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+3
-1
@@ -60,6 +60,7 @@ $app->singleton(
|
||||
*/
|
||||
|
||||
$app->configure('app');
|
||||
$app->configure('tinker');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -110,6 +111,7 @@ $app->router->group([
|
||||
'namespace' => 'App\Http\Controllers',
|
||||
], function ($router) {
|
||||
require __DIR__.'/../routes/web.php';
|
||||
require __DIR__.'/../routes/report.php';
|
||||
});
|
||||
|
||||
$app->middleware([
|
||||
@@ -117,5 +119,5 @@ $app->middleware([
|
||||
]);
|
||||
|
||||
$app->register(\Rap2hpoutre\LaravelLogViewer\LaravelLogViewerServiceProvider::class);
|
||||
|
||||
$app->register(\Laravel\Tinker\TinkerServiceProvider::class);
|
||||
return $app;
|
||||
|
||||
+9
-1
@@ -1,13 +1,18 @@
|
||||
{
|
||||
"name": "laravel/lumen",
|
||||
"description": "The Laravel Lumen Framework.",
|
||||
"keywords": ["framework", "laravel", "lumen"],
|
||||
"keywords": [
|
||||
"framework",
|
||||
"laravel",
|
||||
"lumen"
|
||||
],
|
||||
"license": "MIT",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"php": "^7.2.5",
|
||||
"auth0/auth0-php": "^7.4",
|
||||
"laravel/lumen-framework": "^7.0",
|
||||
"laravel/tinker": "^2.8",
|
||||
"rap2hpoutre/laravel-log-viewer": "^1.7"
|
||||
},
|
||||
"require-dev": {
|
||||
@@ -16,6 +21,9 @@
|
||||
"phpunit/phpunit": "^8.5"
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"app/helpers.php"
|
||||
],
|
||||
"classmap": [
|
||||
"database/seeds",
|
||||
"database/factories"
|
||||
|
||||
Generated
+206
-1
@@ -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": "f3fc95d4bf94ca7763a98f60d5a6fd91",
|
||||
"content-hash": "9002d37085a4ef790b6e9f7269b8f058",
|
||||
"packages": [
|
||||
{
|
||||
"name": "auth0/auth0-php",
|
||||
@@ -2202,6 +2202,75 @@
|
||||
},
|
||||
"time": "2020-09-15T14:53:08+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/tinker",
|
||||
"version": "v2.8.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/tinker.git",
|
||||
"reference": "b936d415b252b499e8c3b1f795cd4fc20f57e1f3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/tinker/zipball/b936d415b252b499e8c3b1f795cd4fc20f57e1f3",
|
||||
"reference": "b936d415b252b499e8c3b1f795cd4fc20f57e1f3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/console": "^6.0|^7.0|^8.0|^9.0|^10.0",
|
||||
"illuminate/contracts": "^6.0|^7.0|^8.0|^9.0|^10.0",
|
||||
"illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0",
|
||||
"php": "^7.2.5|^8.0",
|
||||
"psy/psysh": "^0.10.4|^0.11.1",
|
||||
"symfony/var-dumper": "^4.3.4|^5.0|^6.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "~1.3.3|^1.4.2",
|
||||
"phpstan/phpstan": "^1.10",
|
||||
"phpunit/phpunit": "^8.5.8|^9.3.3"
|
||||
},
|
||||
"suggest": {
|
||||
"illuminate/database": "The Illuminate Database package (^6.0|^7.0|^8.0|^9.0|^10.0)."
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.x-dev"
|
||||
},
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Laravel\\Tinker\\TinkerServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Laravel\\Tinker\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylor@laravel.com"
|
||||
}
|
||||
],
|
||||
"description": "Powerful REPL for the Laravel framework.",
|
||||
"keywords": [
|
||||
"REPL",
|
||||
"Tinker",
|
||||
"laravel",
|
||||
"psysh"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel/tinker/issues",
|
||||
"source": "https://github.com/laravel/tinker/tree/v2.8.2"
|
||||
},
|
||||
"time": "2023-08-15T14:27:00+00:00"
|
||||
},
|
||||
{
|
||||
"name": "monolog/monolog",
|
||||
"version": "2.6.0",
|
||||
@@ -2453,6 +2522,62 @@
|
||||
},
|
||||
"time": "2018-02-13T20:26:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nikic/php-parser",
|
||||
"version": "v4.17.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nikic/PHP-Parser.git",
|
||||
"reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d",
|
||||
"reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-tokenizer": "*",
|
||||
"php": ">=7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ircmaxell/php-yacc": "^0.0.7",
|
||||
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0"
|
||||
},
|
||||
"bin": [
|
||||
"bin/php-parse"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.9-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PhpParser\\": "lib/PhpParser"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nikita Popov"
|
||||
}
|
||||
],
|
||||
"description": "A PHP parser written in PHP",
|
||||
"keywords": [
|
||||
"parser",
|
||||
"php"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/nikic/PHP-Parser/issues",
|
||||
"source": "https://github.com/nikic/PHP-Parser/tree/v4.17.1"
|
||||
},
|
||||
"time": "2023-08-13T19:53:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "opis/closure",
|
||||
"version": "3.6.3",
|
||||
@@ -2893,6 +3018,86 @@
|
||||
},
|
||||
"time": "2017-10-23T01:57:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psy/psysh",
|
||||
"version": "v0.11.22",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/bobthecow/psysh.git",
|
||||
"reference": "128fa1b608be651999ed9789c95e6e2a31b5802b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/128fa1b608be651999ed9789c95e6e2a31b5802b",
|
||||
"reference": "128fa1b608be651999ed9789c95e6e2a31b5802b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"ext-tokenizer": "*",
|
||||
"nikic/php-parser": "^4.0 || ^3.1",
|
||||
"php": "^8.0 || ^7.0.8",
|
||||
"symfony/console": "^6.0 || ^5.0 || ^4.0 || ^3.4",
|
||||
"symfony/var-dumper": "^6.0 || ^5.0 || ^4.0 || ^3.4"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/console": "4.4.37 || 5.3.14 || 5.3.15 || 5.4.3 || 5.4.4 || 6.0.3 || 6.0.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"bamarni/composer-bin-plugin": "^1.2"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-pcntl": "Enabling the PCNTL extension makes PsySH a lot happier :)",
|
||||
"ext-pdo-sqlite": "The doc command requires SQLite to work.",
|
||||
"ext-posix": "If you have PCNTL, you'll want the POSIX extension as well.",
|
||||
"ext-readline": "Enables support for arrow-key history navigation, and showing and manipulating command history."
|
||||
},
|
||||
"bin": [
|
||||
"bin/psysh"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-0.11": "0.11.x-dev"
|
||||
},
|
||||
"bamarni-bin": {
|
||||
"bin-links": false,
|
||||
"forward-command": false
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/functions.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Psy\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Justin Hileman",
|
||||
"email": "justin@justinhileman.info",
|
||||
"homepage": "http://justinhileman.com"
|
||||
}
|
||||
],
|
||||
"description": "An interactive shell for modern PHP.",
|
||||
"homepage": "http://psysh.org",
|
||||
"keywords": [
|
||||
"REPL",
|
||||
"console",
|
||||
"interactive",
|
||||
"shell"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/bobthecow/psysh/issues",
|
||||
"source": "https://github.com/bobthecow/psysh/tree/v0.11.22"
|
||||
},
|
||||
"time": "2023-10-14T21:56:36+00:00"
|
||||
},
|
||||
{
|
||||
"name": "ralouphie/getallheaders",
|
||||
"version": "3.0.3",
|
||||
|
||||
@@ -451,4 +451,3 @@ return [
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Console Commands
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to add additional Artisan commands that should
|
||||
| be available within the Tinker environment. Once the command is in
|
||||
| this array you may execute the command in Tinker using its name.
|
||||
|
|
||||
*/
|
||||
|
||||
'commands' => [
|
||||
// App\Console\Commands\ExampleCommand::class,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Auto Aliased Classes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Tinker will not automatically alias classes in your vendor namespaces
|
||||
| but you may explicitly allow a subset of classes to get aliased by
|
||||
| adding the names of each of those classes to the following list.
|
||||
|
|
||||
*/
|
||||
|
||||
'alias' => [
|
||||
//
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Classes That Should Not Be Aliased
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Typically, Tinker automatically aliases classes as you require them in
|
||||
| Tinker. However, you may wish to never alias certain classes, which
|
||||
| you may accomplish by listing the classes in the following array.
|
||||
|
|
||||
*/
|
||||
|
||||
'dont_alias' => [
|
||||
'App\Nova',
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddColumnsToKomuditiTransaksi extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
|
||||
public function up()
|
||||
{
|
||||
Schema::connection($this->getOnlineArrahnConnection())->table('komuditi_transaksi', function (Blueprint $table){
|
||||
$table->string('customer_id', 10, 2)->after('nosijil');
|
||||
$table->float('harga', 10, 2)->after('nosijil');
|
||||
$table->float('tan', 10, 2)->after('nosijil');
|
||||
$table->string('no_sijil_pelanggan')->after('nosijil')->comment('format: no sijil bursa + no siri PKB');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::connection($this->getOnlineArrahConnection())->table('komuditi_transaksi', function (Blueprint $table){
|
||||
$table->dropColumn('no_sijil_pelanggan');
|
||||
$table->dropColumn('tan');
|
||||
$table->dropColumn('harga');
|
||||
$table->dropColumn('customer_id');
|
||||
});
|
||||
}
|
||||
|
||||
private function getOnlineArrahnConnection()
|
||||
{
|
||||
$online_arrahn_connection_array = array_filter(config('database.connections'), function($connection) {
|
||||
|
||||
if($connection['database'] === 'online_arrahn'){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
|
||||
if(empty($online_arrahn_connection_array)){
|
||||
throw new Exception("online_arrahn doesn't exist in config.database.connections array");
|
||||
}
|
||||
|
||||
return array_keys($online_arrahn_connection_array)[0];
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user