diff --git a/app/Http/Controllers/GadaiController.php b/app/Http/Controllers/GadaiController.php index 3e5aba2..07b422d 100644 --- a/app/Http/Controllers/GadaiController.php +++ b/app/Http/Controllers/GadaiController.php @@ -313,8 +313,11 @@ class GadaiController extends Controller $upahsemasa_raw = $bilang_bln * (($gadai_data['kadarupah']/100 )* $gadai_data['pinjaman']); $upah_semasa_round = number_format($upahsemasa_raw,2); - $upah_semasa = substr($upah_semasa_round, 0, -1); - $upah_semasa = floatval(preg_replace('/[^\d.]/', '', $upah_semasa)); + $upah_semasa = (float)substr($upah_semasa_round, 0, -1); + // $upah_semasa = floatval(preg_replace('/[^\d.]/', '', $upah_semasa)); + if(strpos($upah_semasa,',')){ + $upah_semasa = str_replace(',','',$upah_semasa); + } return $upah_semasa; } @@ -333,7 +336,10 @@ class GadaiController extends Controller $upah_rebet_round = number_format($upahrebet_raw,2); $upah_rebet = (float)substr($upah_rebet_round, 0, -1); - $upah_rebet = floatval(preg_replace('/[^\d.]/', '', $upah_rebet)); + if(strpos($upah_rebet,',')){ + $upah_rebet = str_replace(',','',$upah_rebet); + } + // $upah_rebet = floatval(preg_replace('/[^\d.]/', '', $upah_rebet)); return $upah_rebet; } diff --git a/app/Http/Controllers/MarhunController.php b/app/Http/Controllers/MarhunController.php index c780c63..140f89c 100644 --- a/app/Http/Controllers/MarhunController.php +++ b/app/Http/Controllers/MarhunController.php @@ -7,6 +7,7 @@ use App\Jemas; use App\Cawangan; use Illuminate\Http\Request; use App\Audit; +use App\HargaEmas; use Carbon\Carbon; @@ -49,6 +50,10 @@ class MarhunController extends Controller $current = Carbon::now(); $current = new Carbon(); + $harga = HargaEmas::on('mysql7')->where('karat',$request->karat)->first(); + + $nilai_marhun = $request->berat_emas * $harga['harga']; + $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); $marhun = Marhun::on($cawangan['mysql'])->create([ 'kodcaw'=> $kodcaw, @@ -59,8 +64,8 @@ class MarhunController extends Controller 'nota' => $request->nota, 'karat' => $request->karat, 'berat' => $request->berat_emas, - 'harga' => $request->harga, - 'n_marhun' => $request->nilai_marhun + 'harga' => $harga['harga'], + 'n_marhun' => $nilai_marhun ]); $audit = new Audit(); @@ -118,9 +123,12 @@ class MarhunController extends Controller public function editmarhun($kodcaw,$norujukan,Request $request) { - $current = Carbon::now(); + $current = Carbon::now(); $current = new Carbon(); + $harga = HargaEmas::on('mysql7')->where('karat',$request->karat)->first(); + $nilai_marhun = $request->berat_emas * $harga['harga']; + $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); $old_data = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->first(); @@ -131,8 +139,8 @@ class MarhunController extends Controller 'marhun' => $request->marhun, 'nota' => $request->nota, 'berat' => $request->berat, - 'harga' => $request->harga, - 'n_marhun' => $request->n_marhun + 'harga' => $harga['harga'], + 'n_marhun' => $nilai_marhun ]); $new_data = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->first(); diff --git a/app/Http/Controllers/TransactionOnlineController.php b/app/Http/Controllers/TransactionOnlineController.php index b1540d6..cc6e98e 100644 --- a/app/Http/Controllers/TransactionOnlineController.php +++ b/app/Http/Controllers/TransactionOnlineController.php @@ -107,7 +107,10 @@ class TransactionOnlineController extends Controller $upah_semasa_round = number_format($upahsemasa_raw,2); $upah_semasa = substr($upah_semasa_round, 0, -1); - $upah_semasa = floatval(preg_replace('/[^\d.]/', '', $upah_semasa)); + if(strpos($upah_semasa,',')){ + $upah_semasa = str_replace(',','',$upah_semasa); + } + // $upah_semasa = floatval(preg_replace('/[^\d.]/', '', $upah_semasa)); return $upah_semasa; } @@ -125,8 +128,11 @@ class TransactionOnlineController extends Controller $upahrebet_raw = $bilang_bln * (($gadai_data['kadarupah']/100 )* $gadai_data['bakipjm']); $upah_rebet_round = number_format($upahrebet_raw,2); - $upah_rebet = substr($upah_rebet_round, 0, -1); - $upah_rebet = floatval(preg_replace('/[^\d.]/', '', $upah_rebet)); + $upah_rebet = (float)substr($upah_rebet_round, 0, -1); + if(strpos($upah_rebet,',')){ + $upah_rebet = str_replace(',','',$upah_rebet); + } + // $upah_rebet = floatval(preg_replace('/[^\d.]/', '', $upah_rebet)); return $upah_rebet; }