Add export data lelong
This commit is contained in:
@@ -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,66 @@ class LelongController extends Controller
|
||||
return response()->json($arraylelong);
|
||||
}
|
||||
|
||||
public function exportLelong(Request $request)
|
||||
{
|
||||
$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,
|
||||
]);
|
||||
|
||||
foreach ($request->lelongbid as $index) {
|
||||
$lelong_to_be_inserted = new Lelong();
|
||||
$lelong_to_be_inserted->kodcaw = $index['kodcaw'];
|
||||
$lelong_to_be_inserted->batchno = $newBatchNo;
|
||||
$lelong_to_be_inserted->t_lelong = $request->tarikh;
|
||||
$lelong_to_be_inserted->norujukan = $index['norujukan'];
|
||||
|
||||
$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->t_gadai = $data['t_gadai'];
|
||||
$lelmarhun_to_be_inserted->nota = $data['nota'];
|
||||
$lelmarhun_to_be_inserted->batch_no = $newBatchNo;
|
||||
|
||||
$lelmarhun_arr[] = $lelmarhun_to_be_inserted->attributesToArray();
|
||||
}
|
||||
|
||||
LelMarhun::on($cawangan['mysql'])->insert($lelmarhun_arr);
|
||||
|
||||
$tunai = Tunai::on($cawangan['mysql'])->create([
|
||||
'tarikh' => $request->tarikh,
|
||||
'kodlaluan' => "LELONG",
|
||||
'masuk' => $request->tunai,
|
||||
]);
|
||||
|
||||
$gldetail = GlDetail::on($cawangan['mysql'])->create([
|
||||
'tarikh' => $request->tarikh,
|
||||
'dtacct' => "1000/010",
|
||||
'ktacct' => "1000/020",
|
||||
'teller' => "LELONG ONLINE",
|
||||
'descpt' => "SERAHAN LELONG ONLINE",
|
||||
'amaun' => $request->gldetail
|
||||
]);
|
||||
|
||||
|
||||
return response()->json("success");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user