backup stok audit
This commit is contained in:
Vendored
BIN
Binary file not shown.
@@ -0,0 +1,186 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Bank;
|
||||||
|
use App\Cawangan;
|
||||||
|
use App\Gadai;
|
||||||
|
use App\StokAudit1;
|
||||||
|
use App\StokAudit2;
|
||||||
|
use App\StokAudit3;
|
||||||
|
use App\StokAudit4;
|
||||||
|
use App\StokAudit5;
|
||||||
|
use App\StokAudit6;
|
||||||
|
use App\StokAudit7;
|
||||||
|
use App\StokAudit8;
|
||||||
|
use App\StokAudit9;
|
||||||
|
use App\StokAudit10;
|
||||||
|
use App\StokAudit11;
|
||||||
|
use App\StokAudit12;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class BackupStokAuditController extends Controller
|
||||||
|
{
|
||||||
|
public function backupStokAudit(Request $request){
|
||||||
|
if($request->zone == 'all'){
|
||||||
|
$cawangan = Cawangan::on('mysql7')->get();
|
||||||
|
}else{
|
||||||
|
$cawangan = Cawangan::on('mysql7')->where('zone',$request->zone)->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
$tarikh = Carbon::now();
|
||||||
|
$tarikh = $tarikh->subDay(1);
|
||||||
|
|
||||||
|
$month = $tarikh->month;
|
||||||
|
$year = $tarikh->year;
|
||||||
|
|
||||||
|
foreach($cawangan as $cawangan_mysql){
|
||||||
|
$all_gadai = Gadai::on($cawangan_mysql['mysql'])->whereNotIn('sttebus',['L','T'])->get();
|
||||||
|
$data = [];
|
||||||
|
foreach($all_gadai as $gadai){
|
||||||
|
$tarikh_gadai = Carbon::parse($gadai['t_gadai']. ' 00:00:00');
|
||||||
|
$current = Carbon::now();
|
||||||
|
$current = $current->subDay(1);
|
||||||
|
|
||||||
|
$tahun_gadai = $tarikh_gadai->year;
|
||||||
|
$bulan_gadai = $tarikh_gadai->month;
|
||||||
|
$hari_gadai = $tarikh_gadai->day;
|
||||||
|
|
||||||
|
$tahun_semasa = $current->year;
|
||||||
|
$bulan_semasa = $current->month;
|
||||||
|
$hari_semasa = $current->day;
|
||||||
|
|
||||||
|
if($hari_semasa >= $hari_gadai){
|
||||||
|
$beza_hari = $hari_semasa - $hari_gadai + 1;
|
||||||
|
}else if($hari_semasa < $hari_gadai){
|
||||||
|
$bulan_semasa = $bulan_semasa - 1;
|
||||||
|
$beza_hari = ($hari_semasa + 30) - $hari_gadai + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$extensivemonth_gadai = 0;
|
||||||
|
|
||||||
|
if($beza_hari >= 1 && $beza_hari <= 15){
|
||||||
|
$extensivemonth_gadai = 0.5;
|
||||||
|
}else if($beza_hari >= 16){
|
||||||
|
$extensivemonth_gadai = 1;
|
||||||
|
}else{
|
||||||
|
$extensivemonth_gadai = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$beza_tahun = $tahun_semasa - $tahun_gadai;
|
||||||
|
|
||||||
|
$beza_bulan = ($bulan_semasa + ($beza_tahun * 12)) - $bulan_gadai;
|
||||||
|
|
||||||
|
$tempoh_gadai = $beza_bulan + $extensivemonth_gadai;
|
||||||
|
|
||||||
|
$upah_semasa = $this->kiraupahTawarruqStokAudit($tempoh_gadai,$gadai['tempohbayar'],$gadai['kadarupah'],$gadai['bakipjm']);
|
||||||
|
|
||||||
|
Gadai::on($cawangan_mysql['mysql'])->where('norujukan','=',$gadai['norujukan'])->update(array(
|
||||||
|
'jbg' => $tempoh_gadai,
|
||||||
|
'tempoh' => $tempoh_gadai,
|
||||||
|
'tunggakan' => $upah_semasa
|
||||||
|
));
|
||||||
|
|
||||||
|
$data_gadai = [
|
||||||
|
'tahun' => $year,
|
||||||
|
'bulan' => $month,
|
||||||
|
'norujukan' => $gadai['norujukan'],
|
||||||
|
'tempoh' => $tempoh_gadai,
|
||||||
|
'nokp' => $gadai['nokp'],
|
||||||
|
'berat' => $gadai['berat'],
|
||||||
|
'nilaimarhun' => $gadai['nilaimarhun'],
|
||||||
|
'pinjaman' => $gadai['pinjaman'],
|
||||||
|
'bakipjm' => $gadai['bakipjm'],
|
||||||
|
'kadarupah' => $gadai['kadarupah'],
|
||||||
|
'tempohblmbyar' => $gadai['tempoh'] - $gadai['tempohbayar'],
|
||||||
|
'upahblmbyar' => $upah_semasa,
|
||||||
|
'lanjutan' => $gadai['lelong_tawarruq']
|
||||||
|
];
|
||||||
|
|
||||||
|
array_push($data,$data_gadai);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($month == 1){
|
||||||
|
foreach (array_chunk($data,1000) as $t)
|
||||||
|
{
|
||||||
|
StokAudit1::on($cawangan_mysql['mysql'])->insert($t);
|
||||||
|
}
|
||||||
|
}elseif($month == 2){
|
||||||
|
foreach (array_chunk($data,1000) as $t)
|
||||||
|
{
|
||||||
|
StokAudit2::on($cawangan_mysql['mysql'])->insert($t);
|
||||||
|
}
|
||||||
|
}elseif($month == 3){
|
||||||
|
foreach (array_chunk($data,1000) as $t)
|
||||||
|
{
|
||||||
|
StokAudit3::on($cawangan_mysql['mysql'])->insert($t);
|
||||||
|
}
|
||||||
|
}elseif($month == 4){
|
||||||
|
foreach (array_chunk($data,1000) as $t)
|
||||||
|
{
|
||||||
|
StokAudit4::on($cawangan_mysql['mysql'])->insert($t);
|
||||||
|
}
|
||||||
|
}elseif($month == 5){
|
||||||
|
foreach (array_chunk($data,1000) as $t)
|
||||||
|
{
|
||||||
|
StokAudit5::on($cawangan_mysql['mysql'])->insert($t);
|
||||||
|
}
|
||||||
|
}elseif($month == 6){
|
||||||
|
foreach (array_chunk($data,1000) as $t)
|
||||||
|
{
|
||||||
|
StokAudit6::on($cawangan_mysql['mysql'])->insert($t);
|
||||||
|
}
|
||||||
|
}elseif($month == 7){
|
||||||
|
foreach (array_chunk($data,1000) as $t)
|
||||||
|
{
|
||||||
|
StokAudit7::on($cawangan_mysql['mysql'])->insert($t);
|
||||||
|
}
|
||||||
|
}elseif($month == 8){
|
||||||
|
foreach (array_chunk($data,1000) as $t)
|
||||||
|
{
|
||||||
|
StokAudit8::on($cawangan_mysql['mysql'])->insert($t);
|
||||||
|
}
|
||||||
|
}elseif($month == 9){
|
||||||
|
foreach (array_chunk($data,1000) as $t)
|
||||||
|
{
|
||||||
|
StokAudit9::on($cawangan_mysql['mysql'])->insert($t);
|
||||||
|
}
|
||||||
|
}elseif($month == 10){
|
||||||
|
foreach (array_chunk($data,1000) as $t)
|
||||||
|
{
|
||||||
|
StokAudit10::on($cawangan_mysql['mysql'])->insert($t);
|
||||||
|
}
|
||||||
|
}elseif($month == 11){
|
||||||
|
foreach (array_chunk($data,1000) as $t)
|
||||||
|
{
|
||||||
|
StokAudit11::on($cawangan_mysql['mysql'])->insert($t);
|
||||||
|
}
|
||||||
|
}elseif($month == 12){
|
||||||
|
foreach (array_chunk($data,1000) as $t)
|
||||||
|
{
|
||||||
|
StokAudit12::on($cawangan_mysql['mysql'])->insert($t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'success';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function kiraupahTawarruqStokAudit($tempoh,$tempohbayar,$kadarupah,$bakipinjaman){
|
||||||
|
|
||||||
|
$bilang_bln = $tempoh - $tempohbayar;
|
||||||
|
|
||||||
|
$upahsemasa_raw = $bilang_bln * (($kadarupah/100 )* $bakipinjaman);
|
||||||
|
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
return $upah_semasa;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class StokAudit1 extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'stokaudit1';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = ['tahun','bulan','norujukan','tempoh','nokp','berat','nilaimarhun','pinjaman','bakipjm','kadarupdah','tempohblmbyar','upahblmbyar','lanjutan'];
|
||||||
|
|
||||||
|
public $timestamps = false;
|
||||||
|
/**
|
||||||
|
* The attributes excluded from the model's JSON form.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
// protected $hidden = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class StokAudit10 extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'stokaudit10';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = ['tahun','bulan','norujukan','tempoh','nokp','berat','nilaimarhun','pinjaman','bakipjm','kadarupdah','tempohblmbyar','upahblmbyar','lanjutan'];
|
||||||
|
|
||||||
|
public $timestamps = false;
|
||||||
|
/**
|
||||||
|
* The attributes excluded from the model's JSON form.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
// protected $hidden = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class StokAudit11 extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'stokaudit11';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = ['tahun','bulan','norujukan','tempoh','nokp','berat','nilaimarhun','pinjaman','bakipjm','kadarupdah','tempohblmbyar','upahblmbyar','lanjutan'];
|
||||||
|
|
||||||
|
public $timestamps = false;
|
||||||
|
/**
|
||||||
|
* The attributes excluded from the model's JSON form.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
// protected $hidden = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class StokAudit12 extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'stokaudit12';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = ['tahun','bulan','norujukan','tempoh','nokp','berat','nilaimarhun','pinjaman','bakipjm','kadarupdah','tempohblmbyar','upahblmbyar','lanjutan'];
|
||||||
|
|
||||||
|
public $timestamps = false;
|
||||||
|
/**
|
||||||
|
* The attributes excluded from the model's JSON form.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
// protected $hidden = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class StokAudit2 extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'stokaudit2';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = ['tahun','bulan','norujukan','tempoh','nokp','berat','nilaimarhun','pinjaman','bakipjm','kadarupdah','tempohblmbyar','upahblmbyar','lanjutan'];
|
||||||
|
|
||||||
|
public $timestamps = false;
|
||||||
|
/**
|
||||||
|
* The attributes excluded from the model's JSON form.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
// protected $hidden = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class StokAudit3 extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'stokaudit3';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = ['tahun','bulan','norujukan','tempoh','nokp','berat','nilaimarhun','pinjaman','bakipjm','kadarupdah','tempohblmbyar','upahblmbyar','lanjutan'];
|
||||||
|
|
||||||
|
public $timestamps = false;
|
||||||
|
/**
|
||||||
|
* The attributes excluded from the model's JSON form.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
// protected $hidden = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class StokAudit4 extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'stokaudit4';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = ['tahun','bulan','norujukan','tempoh','nokp','berat','nilaimarhun','pinjaman','bakipjm','kadarupdah','tempohblmbyar','upahblmbyar','lanjutan'];
|
||||||
|
|
||||||
|
public $timestamps = false;
|
||||||
|
/**
|
||||||
|
* The attributes excluded from the model's JSON form.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
// protected $hidden = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class StokAudit5 extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'stokaudit5';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = ['tahun','bulan','norujukan','tempoh','nokp','berat','nilaimarhun','pinjaman','bakipjm','kadarupdah','tempohblmbyar','upahblmbyar','lanjutan'];
|
||||||
|
|
||||||
|
public $timestamps = false;
|
||||||
|
/**
|
||||||
|
* The attributes excluded from the model's JSON form.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
// protected $hidden = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class StokAudit6 extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'stokaudit6';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = ['tahun','bulan','norujukan','tempoh','nokp','berat','nilaimarhun','pinjaman','bakipjm','kadarupdah','tempohblmbyar','upahblmbyar','lanjutan'];
|
||||||
|
|
||||||
|
public $timestamps = false;
|
||||||
|
/**
|
||||||
|
* The attributes excluded from the model's JSON form.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
// protected $hidden = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class StokAudit7 extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'stokaudit7';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = ['tahun','bulan','norujukan','tempoh','nokp','berat','nilaimarhun','pinjaman','bakipjm','kadarupdah','tempohblmbyar','upahblmbyar','lanjutan'];
|
||||||
|
|
||||||
|
public $timestamps = false;
|
||||||
|
/**
|
||||||
|
* The attributes excluded from the model's JSON form.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
// protected $hidden = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class StokAudit8 extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'stokaudit8';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = ['tahun','bulan','norujukan','tempoh','nokp','berat','nilaimarhun','pinjaman','bakipjm','kadarupdah','tempohblmbyar','upahblmbyar','lanjutan'];
|
||||||
|
|
||||||
|
public $timestamps = false;
|
||||||
|
/**
|
||||||
|
* The attributes excluded from the model's JSON form.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
// protected $hidden = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class StokAudit9 extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'stokaudit9';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = ['tahun','bulan','norujukan','tempoh','nokp','berat','nilaimarhun','pinjaman','bakipjm','kadarupdah','tempohblmbyar','upahblmbyar','lanjutan'];
|
||||||
|
|
||||||
|
public $timestamps = false;
|
||||||
|
/**
|
||||||
|
* The attributes excluded from the model's JSON form.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
// protected $hidden = [];
|
||||||
|
}
|
||||||
Generated
+1879
-738
File diff suppressed because it is too large
Load Diff
+3
-1
@@ -552,6 +552,8 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
|||||||
$router->get('calculate/akru/bycawangan',['uses'=>'GadaiController@calculateAkru']);
|
$router->get('calculate/akru/bycawangan',['uses'=>'GadaiController@calculateAkru']);
|
||||||
|
|
||||||
$router->get('keluar/lelong/tawarruq',['uses'=>'LelongController@keluarLelongTawarruq']);
|
$router->get('keluar/lelong/tawarruq',['uses'=>'LelongController@keluarLelongTawarruq']);
|
||||||
|
|
||||||
|
$router->get('backup/stok/audit',['uses'=>'BackupStokAuditController@backupStokAudit']);
|
||||||
});
|
});
|
||||||
|
|
||||||
$router->group(['prefix'=>'e-arrahn'], function () use ($router){
|
$router->group(['prefix'=>'e-arrahn'], function () use ($router){
|
||||||
@@ -700,7 +702,7 @@ $router->group(['prefix'=>'admin'], function () use ($router){
|
|||||||
$router->post('permohonan/tagcit',['uses'=>'AdminPageController@TagCit']);
|
$router->post('permohonan/tagcit',['uses'=>'AdminPageController@TagCit']);
|
||||||
$router->get('permohonan/viewfiles',['uses'=>'AdminPageController@downloadFile']);
|
$router->get('permohonan/viewfiles',['uses'=>'AdminPageController@downloadFile']);
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$router->group(['prefix'=>'kelantanpay'], function () use ($router){
|
$router->group(['prefix'=>'kelantanpay'], function () use ($router){
|
||||||
|
|||||||
Reference in New Issue
Block a user