Merge branch 'amir' into 'master'

Merge export lelong

See merge request online-sistem1/api_arrahn!162
This commit is contained in:
arrahn pkb
2022-12-01 02:24:51 +00:00
4 changed files with 146 additions and 3 deletions
+11 -3
View File
@@ -7,15 +7,23 @@ use Illuminate\Database\Eloquent\Model;
class BatchLel extends Model
{
protected $table = 'batchlel';
public $timestamps = false;
/**
* The attributes that are mass assignable.
*
* @var array
*/
// protected $fillable = [
// ];
protected $fillable = [
'tarikh',
'tarikh2',
'batchno',
'kodcaw',
't_daftar',
'masadari',
'masahingga'
];
/**
* The attributes excluded from the model's JSON form.
+119
View File
@@ -22,7 +22,9 @@ use App\Tebus;
use App\Advansur;
use App\LelTebus;
use App\LelMarhun;
use App\Tunai;
use App\Audit;
use App\GlDetail;
use Illuminate\Http\Request;
use DB;
@@ -963,4 +965,121 @@ class LelongController extends Controller
return response()->json($arraylelong);
}
public function exportLelong(Request $request)
{
$currentDate = Carbon::now();
$currentDate = $currentDate->toDateString();
$cawangan = Cawangan::on('mysql7')->where('kodcaw', $request->kodcaw)->first();
$batchlel = BatchLel::on($cawangan['mysql'])
->select('batchno')
->orderBy('batchno', 'desc')
->first();
$newBatchNo = $batchlel->batchno + 1;
$newBatchLel = BatchLel::on($cawangan['mysql'])->create([
'kodcaw' => $request->kodcaw,
'batchno' => $newBatchNo,
'tarikh' => $request->tarikh,
'tarikh2' => $request->tarikh,
't_daftar' => $currentDate,
'masadari' => $request->masadari,
'masahingga' => $request->masahingga
]);
$lelong = Lelong::on($cawangan['mysql'])
->select('sirilel')
->orderBy('batchno', 'desc')
->first();
foreach ($request->lelongbid as $index) {
$update_gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$index['norujukan'])->update(array(
'sttebus' => "L"
));
$lelong_to_be_inserted = new Lelong();
$lelong_to_be_inserted->batchno = $newBatchNo;
$lelong_to_be_inserted->sirilel = $lelong->sirilel + 1;
$lelong_to_be_inserted->kodcaw = $index['kodcaw'];
$lelong_to_be_inserted->norujukan = $index['norujukan'];
$lelong_to_be_inserted->t_lelong = $request->tarikh;
$lelong_to_be_inserted->hargaasas = $index['hargaasas'];
$lelong_to_be_inserted->hargajual = $index['hargajual'];
$lelong_to_be_inserted->glcode = "1000/010";
$lelong_to_be_inserted->t_jual = $index['t_lelong'];
// $lelong_to_be_inserted->nopembeli = $;
$lelong_to_be_inserted->jbg = $index['jbg'];
$lelong_to_be_inserted->kadarupah = $index['kadarupah'];
$lelong_to_be_inserted->upahsimpan = $index['upahsimpan'];
$lelong_to_be_inserted->ansuran = $index['ansuran'];
$lelong_to_be_inserted->nilaimarhun = $index['nilaimarhun'];
$lelong_to_be_inserted->nilaimarhuns = $index['nmarhuns'];
$lelong_to_be_inserted->pinjaman = $index['pinjaman'];
$lelong_to_be_inserted->bakiupah = $index['bakiupah'];
$lelong_to_be_inserted->cajlelong = $index['cajlelong'];
$lelong_to_be_inserted->baki = $index['baki'];
$lelong_to_be_inserted->teller = $index['teller'];
$lelong_to_be_inserted->prkod = "01";
$lelong_to_be_inserted->kodgl = "1000/013";
$lelong_to_be_inserted->berat = $index['berat'];
$lelong_to_be_inserted->marhun = $index['marhun'];
$lelong_to_be_inserted->fasa = $index['fasa'];
$lelong_arr[] = $lelong_to_be_inserted->attributesToArray();
}
Lelong::on($cawangan['mysql'])->insert($lelong_arr);
foreach ($request->lelongbidmarhun as $data) {
$lelmarhun_to_be_inserted = new LelMarhun();
$lelmarhun_to_be_inserted->kodcaw = $request->kodcaw;
$lelmarhun_to_be_inserted->norujukan = $data['norujukan'];
$lelmarhun_to_be_inserted->bil = $data['bil'];
$lelmarhun_to_be_inserted->marhun = $data['marhun'];
$lelmarhun_to_be_inserted->nota = $data['nota'];
$lelmarhun_to_be_inserted->karat = $data['karat'];
$lelmarhun_to_be_inserted->berat = $data['berat'];
$lelmarhun_to_be_inserted->harga = $data['harga'];
$lelmarhun_to_be_inserted->n_marhun = $data['n_marhun'];
$lelmarhun_to_be_inserted->hargaasas = $data['hargaasas'];
$lelmarhun_to_be_inserted->batch_no = $newBatchNo;
// $lelmarhun_to_be_inserted->beratasal = $;
$lelmarhun_arr[] = $lelmarhun_to_be_inserted->attributesToArray();
}
LelMarhun::on($cawangan['mysql'])->insert($lelmarhun_arr);
if ($request->tunai != null) {
$tunai = Tunai::on($cawangan['mysql'])->create([
'tarikh' => $request->tarikh,
'kodcaw' => $request->kodcaw,
'kodlaluan' => "LELONG",
'masuk' => $request->tunai,
'baki' => $request->tunai,
]);
}
if ($request->gldetail != null) {
$gldetail = GlDetail::on($cawangan['mysql'])->create([
'kodcaw' => $request->kodcaw,
'tarikh' => $request->tarikh,
'dtacct' => "1000/010",
'ktacct' => "1000/020",
'descpt' => "SERAHAN LELONG ONLINE, " . $request->tarikh,
'amaun' => $request->gldetail,
'teller' => "LELONG ONLINE",
'serahan' => $request->gldetail,
]);
}
//update table gadai
return response()->json("success");
}
}
+15
View File
@@ -15,6 +15,21 @@ class LelMarhun extends Model
* @var array
*/
protected $fillable = [
'kodcaw',
'norujukan',
'bil',
'marhun',
'nota',
'karat',
'berat',
'harga',
'n_marhun',
'hargaasas',
'batch_no',
'beratasal',
];
/**
* The attributes excluded from the model's JSON form.
*
+1
View File
@@ -745,6 +745,7 @@ $router->group(['prefix'=>'admin'], function () use ($router){
$router->group(['prefix'=>'lelong'], function () use ($router){
$router->post('taglel/update',['uses'=>'GadaiController@updateTagLelong']);
$router->post('taglel/revert',['uses'=>'GadaiController@revertTagLelong']);
$router->post('exportLelong',['uses'=>'LelongController@exportLelong']);
});
$router->group(['prefix'=>'kelantanpay'], function () use ($router){