One Hat Cyber Team
Your IP :
3.135.224.139
Server IP :
104.21.80.1
Server :
Linux agrigation-prod 5.15.0-67-generic #74-Ubuntu SMP Wed Feb 22 14:14:39 UTC 2023 x86_64
Server Software :
nginx/1.24.0
PHP Version :
7.4.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
forge
/
app.gftag.com
/
app
/
Http
/
Controllers
/
Edit File:
AdjustmentController.php
<?php namespace App\Http\Controllers; use Carbon\Carbon; use App\Models\Item; use App\Models\Adjustment; use App\Models\Transaction; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use App\Services\TransactionService; use Illuminate\Support\Facades\View; use App\Services\OrganisationService; class AdjustmentController extends Controller { public function adjustmentView(){ $organisationService = new OrganisationService(); $org_id = $organisationService->getOrganisationByUser(); if (View::exists('adjustments.adjustmententries')) { $items = Item::where('organisation_id', $org_id)->get(); $adjustments = Adjustment::where('organisation_id', $org_id)->get(); return view('adjustments.adjustmententries', ['items' => $items, 'adjustments'=> $adjustments]); } } public function CreateAdjustment(){ $organisationService = new OrganisationService(); $org_id = $organisationService->getOrganisationByUser(); if (View::exists('adjustments.adjustment')) { $items = Item::where('organisation_id', $org_id)->get(); return view('adjustments.adjustment', ['items' => $items]); } } public function store(Request $request){ $this->validate($request,[ 'adjustment_date' => 'required', 'adjustment_type' => 'required', 'comment' => 'required' ]); $organisationService = new OrganisationService(); $org_id = $organisationService->getOrganisationByUser(); $arr_item_code = array(); $arr_item_qty = array(); $arr_item_code = $request->get('item'); $arr_item_qty = $request->get('stockadjusted'); $adjustment = new Adjustment(); $adjust_number = $adjustment->getLastAdjustmentNumber(); if(!empty($adjust_number)){ $adjust_no = !empty($adjust_number->adjustment_number) ? $adjust_number->adjustment_number : "ADJN10000000"; } else{ $adjust_no = "ADJN10000000"; } $adjust_no_prefix = "ADJN"; $new_adjust_no = ""; if($adjust_no != ""){ $adjust_no = (int)str_replace($adjust_no_prefix,"",$adjust_no); $new_adjust_no = $adjust_no_prefix.''.($adjust_no+1); } DB::beginTransaction(); try { for($i=0;$i<count($arr_item_code);$i++){ $adjustment = Adjustment::create([ "organisation_id" => $org_id, "adjustment_number" => $new_adjust_no, "item_id" => $arr_item_code[$i], "quantity" => $arr_item_qty[$i]==""?"0":$arr_item_qty[$i], "adjustment_date" => date('Y-m-d', strtotime($request->adjustment_date)), "adjustment_type" => $request->adjustment_type, "status" => 'confirmed', "comments" => $request->comment, ]); $transaction = new TransactionService(); $transaction->updateDailyTransaction( $org_id, $request->adjustment_type, $arr_item_code[$i], $arr_item_qty[$i]==""? 0 : $arr_item_qty[$i], date('Y-m-d', strtotime($request->adjustment_date)) ); $transaction_id = $transaction->createNewTransactionEntry( $org_id, $request->adjustment_type, $arr_item_code[$i], $arr_item_qty[$i]==""? 0 : $arr_item_qty[$i], uniqid(), 'organisation', 'organisation', date('Y-m-d', strtotime($request->adjustment_date)), get_class($adjustment), $adjustment->id ); if(!$transaction_id) { DB::rollback(); return redirect()->back()->with('message', 'Failed Creating Adjustment !'); } DB::commit(); } }catch(\Exception $e) { DB::rollback(); echo $e->getMessage(); die; return redirect()->back()->with('message', 'Failed Creating Adjustment !'); } return redirect()->back()->with('message', 'Adjustment Created successfully !'); } }
Simpan