-
-
Save esmeromichael/265b7068cc61a2e28721f09f8d706376 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers\Booking; | |
use Illuminate\Http\Request; | |
use App\Http\Requests; | |
use App\Http\Controllers\Controller; | |
use App\BookingService; | |
use App\BookingServiceType; | |
use App\BookingTripType; | |
use App\BookingFclSize; | |
use App\BookingVanType; | |
use App\BookingOwnership; | |
use App\BookingPurpose; | |
use App\BookingHeader; | |
use App\BookingDetail; | |
use App\BookingSubDetail; | |
use App\BookingDispatchHeader; | |
use App\BookingDispatchDetail; | |
use App\BookingTruckType; | |
use App\BookingAssetClassification; | |
use App\BookingClassificationType; | |
use App\Route; | |
use Input; | |
use Session; | |
use Response; | |
use View; | |
use App\User; | |
use DB; | |
use Hash; | |
use App\CompanyBranch; | |
use App\PartnerBranch; | |
use App\UserTransactingBranch; | |
class BookingController extends Controller | |
{ | |
public function getIndex(){ | |
if(Session::has('user')){ | |
$user_id = Session::get('user'); | |
$module2 = User::where('partner_id', $user_id)->with('partner','m5b','m5sy')->first(); | |
$password = DB::table('users')->where('partner_id',$user_id)->first(); | |
if (Hash::check('admin', $password->password)) { | |
$pass = "admin"; | |
} | |
else{ | |
$pass = ""; | |
} | |
return view::make('booking/index',compact('module2','password','pass')); | |
} | |
else{ | |
return redirect()->action('Auth@checklogin'); | |
} | |
} | |
public function postIndex() { | |
if(Session::has('user')){ | |
$user_id = Input::get('user_id'); | |
$username = Input::get('user_name'); | |
$password1 = Input::get('password1'); | |
if (!$username) { | |
$updateuser = User::where('id',$user_id)->first(); | |
$updateuser->password = bcrypt($password1); | |
$updateuser->save(); | |
} | |
else{ | |
$updateuser = User::where('id',$user_id)->first(); | |
$updateuser->username = $username; | |
$updateuser->password = bcrypt($password1); | |
$updateuser->save(); | |
} | |
return redirect('booking/'); | |
} | |
else{ | |
return redirect()->action('Auth@checklogin'); | |
} | |
} | |
public function getBooking(){ | |
if(Session::has('user')){ | |
$service = BookingService::where('status','Active')->get(); | |
$triptype = BookingTripType::where('status','Active')->get(); | |
$fcl = BookingFclSize::where('status','Active')->get(); | |
$van = BookingVanType::where('status','Active')->get(); | |
$chassis = BookingOwnership::where('status','Active')->get(); | |
$purpose = BookingPurpose::where('status','Active')->get(); | |
$servicetype = BookingServiceType::where('status','Active')->get(); | |
$bookingheader = BookingHeader::all(); | |
$bookingdetail = BookingDetail::all(); | |
$bookingsubdetail = BookingSubDetail::all(); | |
$user_id = Session::get('user'); | |
$module2 = User::where('partner_id', $user_id)->with('partner','m5b','m5sy')->first(); | |
$password = DB::table('users')->where('partner_id',$user_id)->first(); | |
if ($module2->m5b->b_tab == "Yes") { | |
return view::make('booking/booking',compact('module2','service','triptype','fcl','van','chassis','purpose','servicetype','bookingsubdetail','bookingdetail','bookingheader','password')); | |
} | |
else { | |
return redirect()->action('Auth@checklogin'); | |
} | |
} | |
else{ | |
return redirect()->action('Auth@checklogin'); | |
} | |
} | |
public function postBooking(){ | |
if(Input::get('finalize')){ | |
$chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
$string = ''; | |
for ($i = 0; $i < 8; $i++){ | |
$string .= $chars[rand(0, strlen($chars) - 1)]; | |
} | |
$header = new BookingHeader; | |
$header->partner_id = Input::get('partner_id'); | |
$header->branch_id = Input::get('branch_id'); | |
$header->contact_id = Input::get('contact_id'); | |
$header->bill_to = Input::get('bill_to'); | |
$header->ship_fwdr = Input::get('ship_fwdr'); | |
$header->remarks = Input::get('remarks'); | |
$header->booking_date = Input::get('booking_date'); | |
$header->booking_time = Input::get('booking_time'); | |
$header->contact_no = Input::get('contact_no'); | |
$header->confirmation_no = $string; | |
$header->save(); | |
$countdetails = count(Input::get('details_service')); | |
if($countdetails > 0){ | |
for($i=0;$i<$countdetails;$i++){ | |
$details = new BookingDetail; | |
$details->booking_id = $header->id; | |
$details->booking_type = Input::get('details_service')[$i]; | |
$details->service_type = Input::get('details_servicetype')[$i]; | |
$details->trip_type = Input::get('details_triptype')[$i]; | |
$details->fcl_size = Input::get('details_fclsize')[$i]; | |
$details->van_type = Input::get('details_vantype')[$i]; | |
$details->booking_ref_no = Input::get('details_bokrefno')[$i]; | |
$details->empty_loaded = Input::get('details_emptyloaded')[$i]; | |
$details->chassis_owner = Input::get('details_chassis')[$i]; | |
$details->purpose = Input::get('details_purpose')[$i]; | |
$details->ref_no = Input::get('details_id')[$i]; | |
$details->detail_id = $header->id.Input::get('details_id')[$i]; | |
$details->ref_dtl_no = $details->id; | |
$details->save(); | |
} | |
} | |
$countsubdetails = count(Input::get('sub_detail_qty')); | |
if($countsubdetails > 0){ | |
for($i=0;$i<$countsubdetails;$i++){ | |
$subdetails = new BookingSubDetail; | |
$subdetails->booking_id = $header->id; | |
$subdetails->detail_id = $header->id.Input::get('detail_sub_id')[$i]; | |
$subdetails->classification = Input::get('sub_detail_classification')[$i]; | |
$subdetails->class_type = Input::get('sub_detail_type')[$i]; | |
$subdetails->ship_line = Input::get('sub_detail_shippingline')[$i]; | |
$subdetails->units = Input::get('sub_detail_qty')[$i]; | |
$subdetails->date_needed = Input::get('sub_detail_dateneeded')[$i]; | |
$subdetails->time_needed = Input::get('sub_detail_timeneeded')[$i]; | |
$subdetails->route_id = Input::get('sub_detail_route')[$i]; | |
$subdetails->remarks = Input::get('sub_detail_remarks')[$i]; | |
$subdetails->vessel_cy = Input::get('sub_detail_vessel_cy')[$i]; | |
$subdetails->cut_off_time = Input::get('sub_detail_cut_off_time')[$i]; | |
$subdetails->port_base = Input::get('sub_detail_port_base')[$i]; | |
$subdetails->port_id = Input::get('sub_detail_port_id')[$i]; | |
$subdetails->save(); | |
$dispatchHeader = new BookingDispatchHeader; | |
$dispatchHeader->booking_id = $header->id; | |
$dispatchHeader->detail_id = $subdetails->id; | |
$dispatchHeader->save(); | |
$dispatchDetail = new BookingDispatchDetail; | |
$dispatchDetail->dispatch_id = $dispatchHeader->id; | |
$dispatchDetail->dispatched_on = Input::get('sub_detail_dateneeded')[$i].' '.Input::get('sub_detail_timeneeded')[$i]; | |
$dispatchDetail->save(); | |
} | |
} | |
return redirect('booking/booking')->with('alert-success', 'New Booking Added.'); | |
} | |
else if(Input::get('modalcomplete')){ | |
$completebooking = BookingSubDetail::where('id',Input::get('bookingsubdetails_Modal'))->first(); | |
$completebooking->status = "Completed"; | |
$completebooking->save(); | |
$completedispatch = BookingDispatchDetail::where('id',Input::get('dispatchdetails_Modal'))->first(); | |
$completedispatch->truck = Input::get('dispatchdetails_Modal_pmno'); | |
$completedispatch->seal_no = Input::get('dispatchdetails_Modal_sealno'); | |
$completedispatch->van_no1 = Input::get('dispatchdetails_Modal_van1'); | |
$completedispatch->van_no2 = Input::get('dispatchdetails_Modal_van2'); | |
$completedispatch->weight_charge = Input::get('dispatchdetails_Modal_weighcharge'); | |
$completedispatch->cdr_no = Input::get('dispatchdetails_Modal_cdrno'); | |
$completedispatch->save(); | |
return redirect('booking/booking')->with('alerts-success', 'Dispatch Completed.'); | |
} | |
else if(Input::get('modalneeded')){ | |
$neededbooking = BookingSubDetail::where('id',Input::get('needed_sub_detail'))->first(); | |
$neededbooking->status = "Completed"; | |
$neededbooking->save(); | |
$neededdispatch = BookingDispatchDetail::where('id',Input::get('needed_dispatch_detail'))->first(); | |
$neededdispatch->asset_class = Input::get('needed_asset_classification'); | |
$neededdispatch->class_type = Input::get('needed_classififcation_type'); | |
$neededdispatch->trailer = Input::get('needed_trailler'); | |
$neededdispatch->truck = Input::get('needed_pmno'); | |
$neededdispatch->qty = Input::get('needed_qty'); | |
$neededdispatch->van_no1 = Input::get('needed_van1'); | |
$neededdispatch->van_no2 = Input::get('needed_van2'); | |
$neededdispatch->seal_no = Input::get('needed_seal_no'); | |
$neededdispatch->save(); | |
return redirect('booking/booking')->with('alerts-success', 'Dispatch Completed.'); | |
} | |
else if(Input::get('modalcomplete2')){ | |
$completebooking = BookingSubDetail::where('id',Input::get('bookingsubdetails_Modal'))->first(); | |
$completebooking->status = "Completed"; | |
$completebooking->save(); | |
$completedispatch = BookingDispatchDetail::where('id',Input::get('dispatchdetails_Modal'))->first(); | |
$completedispatch->truck = Input::get('dispatchdetails_Modal_pmno'); | |
$completedispatch->seal_no = Input::get('dispatchdetails_Modal_sealno'); | |
$completedispatch->van_no1 = Input::get('dispatchdetails_Modal_van1'); | |
$completedispatch->van_no2 = Input::get('dispatchdetails_Modal_van2'); | |
$completedispatch->weight_charge = Input::get('dispatchdetails_Modal_weighcharge'); | |
$completedispatch->cdr_no = Input::get('dispatchdetails_Modal_cdrno'); | |
$completedispatch->save(); | |
return redirect('booking/booking')->with('alerts2-success', 'Dispatch Completed.'); | |
} | |
else if(Input::get('modalneeded2')){ | |
$neededbooking = BookingSubDetail::where('id',Input::get('needed_sub_detail'))->first(); | |
$neededbooking->status = "Completed"; | |
$neededbooking->save(); | |
$neededdispatch = BookingDispatchDetail::where('id',Input::get('needed_dispatch_detail'))->first(); | |
$neededdispatch->asset_class = Input::get('needed_asset_classification'); | |
$neededdispatch->class_type = Input::get('needed_classififcation_type'); | |
$neededdispatch->trailer = Input::get('needed_trailler'); | |
$neededdispatch->truck = Input::get('needed_pmno'); | |
$neededdispatch->qty = Input::get('needed_qty'); | |
$neededdispatch->van_no1 = Input::get('needed_van1'); | |
$neededdispatch->van_no2 = Input::get('needed_van2'); | |
$neededdispatch->seal_no = Input::get('needed_seal_no'); | |
$neededdispatch->save(); | |
return redirect('booking/booking')->with('alerts2-success', 'Dispatch Completed.'); | |
} | |
else if(Input::get('modalchangedatetime')){ | |
$neededbooking = BookingSubDetail::where('id',Input::get('change_subdetailsid'))->first(); | |
$neededbooking->date_needed = Input::get('change_date'); | |
$neededbooking->time_needed = Input::get('change_time'); | |
$neededbooking->save(); | |
return redirect('booking/booking')->with('alerts-success', 'Date/Time Succesfully Changed.'); | |
} | |
else if(Input::get('modalchangedatetime_right')){ | |
$neededbooking = BookingSubDetail::where('id',Input::get('change_subdetailsid'))->first(); | |
$neededbooking->date_needed = Input::get('change_date'); | |
$neededbooking->time_needed = Input::get('change_time'); | |
$neededbooking->save(); | |
return redirect('booking/booking')->with('alerts2-success', 'Date/Time Succesfully Changed.'); | |
} | |
} | |
public function getUsermanagement(){ | |
if(Session::has('user')){ | |
$user = User::join('partners','users.partner_id','=','partners.id') | |
->where('users.module5','=','Yes') | |
->select('users.*','partners.name as partnername') | |
// ->with('m1p','m1s') | |
->get(); | |
$user_id = Session::get('user'); | |
$module2 = User::where('partner_id', $user_id)->with('partner','m5b','m5sy')->first(); | |
$partnerstab = User::where('partner_id',$user_id)->with('m5b','m5sy')->first(); | |
$password = DB::table('users')->where('partner_id',$user_id)->first(); | |
$cpb = CompanyBranch::where('id',1)->first(); | |
$p_branch = PartnerBranch::where('partner_id',$cpb->partner_id)->where('status','Active')->get(); | |
if ($module2->m5sy->s_tab == "Yes") { | |
return view::make('booking/systemproperties/user',compact('user','module2','partnerstab','password','p_branch')); | |
} | |
else { | |
return redirect()->action('Auth@checklogin'); | |
} | |
} | |
else{ | |
return redirect()->action('Auth@checklogin'); | |
} | |
} | |
public function getSystem(){ | |
if(Session::has('user')){ | |
$user_id = Session::get('user'); | |
$module2 = User::where('partner_id', $user_id)->with('partner','m5b','m5sy')->first(); | |
$password = DB::table('users')->where('partner_id',$user_id)->first(); | |
if ($module2->m5sy->sp_sub_tab == "Yes") { | |
return view::make('booking/systemproperties/systemproperties',compact('module2','password')); | |
} | |
else { | |
return redirect()->action('Auth@checklogin'); | |
} | |
} | |
else{ | |
return redirect()->action('Auth@checklogin'); | |
} | |
} | |
public function getService(){ | |
if(Session::has('user')){ | |
$service = BookingService::where('status','Active')->get(); | |
$user_id = Session::get('user'); | |
$module2 = User::where('partner_id', $user_id)->with('partner','m5b','m5sy')->first(); | |
$password = DB::table('users')->where('partner_id',$user_id)->first(); | |
return view::make('booking/systemproperties/service',compact('service','module2','password')); | |
} | |
else{ | |
return redirect()->action('Auth@checklogin'); | |
} | |
} | |
public function postService(){ | |
$service = new BookingService; | |
$service->name = Input::get('name'); | |
$service->status = Input::get('status'); | |
$service->save(); | |
return redirect('booking/service')->with('alert-success', 'Service Successfully Added.'); | |
} | |
public function getServicetype(){ | |
if(Session::has('user')){ | |
$service = BookingServiceType::where('status','Active')->get(); | |
$user_id = Session::get('user'); | |
$module2 = User::where('partner_id', $user_id)->with('partner','m5b','m5sy')->first(); | |
$password = DB::table('users')->where('partner_id',$user_id)->first(); | |
return view::make('booking/systemproperties/servicetype',compact('service','module2','password')); | |
} | |
else{ | |
return redirect()->action('Auth@checklogin'); | |
} | |
} | |
public function postServicetype(){ | |
$service = new BookingServiceType; | |
$service->name = Input::get('name'); | |
$service->status = Input::get('status'); | |
$service->save(); | |
return redirect('booking/servicetype')->with('alert-success', 'Service Type Successfully Added.'); | |
} | |
public function getTriptype(){ | |
if(Session::has('user')){ | |
$service = BookingTripType::where('status','Active')->get(); | |
$user_id = Session::get('user'); | |
$module2 = User::where('partner_id', $user_id)->with('partner','m5b','m5sy')->first(); | |
$password = DB::table('users')->where('partner_id',$user_id)->first(); | |
return view::make('booking/systemproperties/triptype',compact('service','module2','password')); | |
} | |
else{ | |
return redirect()->action('Auth@checklogin'); | |
} | |
} | |
public function postTriptype(){ | |
$service = new BookingTripType; | |
$service->name = Input::get('name'); | |
$service->status = Input::get('status'); | |
$service->save(); | |
return redirect('booking/triptype')->with('alert-success', 'Trip Type Successfully Added.'); | |
} | |
public function getFclsize(){ | |
if(Session::has('user')){ | |
$service = BookingFclSize::where('status','Active')->get(); | |
$user_id = Session::get('user'); | |
$module2 = User::where('partner_id', $user_id)->with('partner','m5b','m5sy')->first(); | |
$password = DB::table('users')->where('partner_id',$user_id)->first(); | |
return view::make('booking/systemproperties/fclsize',compact('service','module2','password')); | |
} | |
else{ | |
return redirect()->action('Auth@checklogin'); | |
} | |
} | |
public function postFclsize(){ | |
$service = new BookingFclSize; | |
$service->name = Input::get('name'); | |
$service->status = Input::get('status'); | |
$service->value = Input::get('value'); | |
$service->sizes = Input::get('size'); | |
$service->save(); | |
return redirect('booking/fclsize')->with('alert-success', 'FCL Size Successfully Added.'); | |
} | |
public function getVantypes(){ | |
if(Session::has('user')){ | |
$service = BookingVanType::where('status','Active')->get(); | |
$user_id = Session::get('user'); | |
$module2 = User::where('partner_id', $user_id)->with('partner','m5b','m5sy')->first(); | |
$password = DB::table('users')->where('partner_id',$user_id)->first(); | |
return view::make('booking/systemproperties/vantypes',compact('service','module2','password')); | |
} | |
else{ | |
return redirect()->action('Auth@checklogin'); | |
} | |
} | |
public function postVantypes(){ | |
$service = new BookingVanType; | |
$service->name = Input::get('name'); | |
$service->status = Input::get('status'); | |
$service->save(); | |
return redirect('booking/vantypes')->with('alert-success', 'Van Type Successfully Added.'); | |
} | |
public function getChassis(){ | |
if(Session::has('user')){ | |
$service = BookingOwnership::where('status','Active')->get(); | |
$user_id = Session::get('user'); | |
$module2 = User::where('partner_id', $user_id)->with('partner','m5b','m5sy')->first(); | |
$password = DB::table('users')->where('partner_id',$user_id)->first(); | |
return view::make('booking/systemproperties/chassis',compact('service','module2','password')); | |
} | |
else{ | |
return redirect()->action('Auth@checklogin'); | |
} | |
} | |
public function postChassis(){ | |
$service = new BookingOwnership; | |
$service->name = Input::get('name'); | |
$service->status = Input::get('status'); | |
$service->save(); | |
return redirect('booking/chassis')->with('alert-success', 'Chassis Ownership Successfully Added.'); | |
} | |
public function getPurpose(){ | |
if(Session::has('user')){ | |
$service = BookingPurpose::where('status','Active')->get(); | |
$user_id = Session::get('user'); | |
$module2 = User::where('partner_id', $user_id)->with('partner','m5b','m5sy')->first(); | |
$password = DB::table('users')->where('partner_id',$user_id)->first(); | |
return view::make('booking/systemproperties/purpose',compact('service','module2','password')); | |
} | |
else{ | |
return redirect()->action('Auth@checklogin'); | |
} | |
} | |
public function postPurpose(){ | |
$service = new BookingPurpose; | |
$service->name = Input::get('name'); | |
$service->status = Input::get('status'); | |
$service->save(); | |
return redirect('booking/purpose')->with('alert-success', 'Purpose Successfully Added.'); | |
} | |
public function getClassification(){ | |
if(Session::has('user')){ | |
$trucktype = BookingTruckType::where('status', 'Active')->get(); | |
$classification = DB::table('booking_classification_types') | |
->leftJoin('booking_truck_types', 'booking_classification_types.type', '=', 'booking_truck_types.id') | |
->select('booking_classification_types.name as name', 'booking_truck_types.name as type','booking_classification_types.status as status', | |
'booking_classification_types.id as id') | |
->get(); | |
$user_id = Session::get('user'); | |
$module2 = User::where('partner_id', $user_id)->with('partner','m5b','m5sy')->first(); | |
$password = DB::table('users')->where('partner_id',$user_id)->first(); | |
return view::make('booking/systemproperties/classification',compact('trucktype','classification','module2','password')); | |
} | |
else{ | |
return redirect()->action('Auth@checklogin'); | |
} | |
} | |
public function postClassification(){ | |
$classification = new BookingClassificationType; | |
$classification->name = Input::get('name'); | |
$classification->type = Input::get('type'); | |
$classification->status = Input::get('status'); | |
$classification->save(); | |
return redirect('booking/classification')->with('alert-success', 'Classification Type Successfully Added.'); | |
} | |
public function getAsset(){ | |
if(Session::has('user')){ | |
$trucktype = BookingTruckType::where('status', 'Active')->get(); | |
$asset = DB::table('booking_asset_classifications') | |
->leftJoin('booking_truck_types', 'booking_asset_classifications.type', '=', 'booking_truck_types.id') | |
->select('booking_asset_classifications.name as name', 'booking_truck_types.name as type','booking_asset_classifications.status as status', | |
'booking_asset_classifications.id as id') | |
->get(); | |
$user_id = Session::get('user'); | |
$module2 = User::where('partner_id', $user_id)->with('partner','m5b','m5sy')->first(); | |
$password = DB::table('users')->where('partner_id',$user_id)->first(); | |
return view::make('booking/systemproperties/asset',compact('asset','trucktype','module2','password')); | |
} | |
else{ | |
return redirect()->action('Auth@checklogin'); | |
} | |
} | |
public function postAsset(){ | |
$asset = new BookingAssetClassification; | |
$asset->name = Input::get('name'); | |
$asset->type = Input::get('type'); | |
$asset->status = Input::get('status'); | |
$asset->save(); | |
return redirect('booking/asset')->with('alert-success', 'Asset Successfully Added.'); | |
} | |
public function getTrucktype(){ | |
if(Session::has('user')){ | |
$truck = BookingTruckType::where('status','Active')->get(); | |
$user_id = Session::get('user'); | |
$module2 = User::where('partner_id', $user_id)->with('partner','m5b','m5sy')->first(); | |
$password = DB::table('users')->where('partner_id',$user_id)->first(); | |
return view::make('booking/systemproperties/trucktype',compact('truck','module2','password')); | |
} | |
else{ | |
return redirect()->action('Auth@checklogin'); | |
} | |
} | |
public function postTrucktype(){ | |
$trucktype = new BookingTruckType; | |
$trucktype->name = Input::get('name'); | |
$trucktype->status = Input::get('status'); | |
$trucktype->save(); | |
return redirect('booking/trucktype')->with('alert-success', 'Truck Type Successfully Added.'); | |
} | |
public function Routelist(){ | |
$id = Input::get('id'); | |
$route = Route::where('partner_id', $id)->get(); | |
return Response::json($route, 200, array(), JSON_PRETTY_PRINT); | |
} | |
public function DisplayService(){ | |
$from = Input::get('fromleft'); | |
$to = Input::get('toleft'); | |
$rental = BookingSubDetail::join('booking_details', 'booking_sub_details.detail_id', '=', 'booking_details.detail_id') | |
->leftjoin('booking_headers', 'booking_details.booking_id', '=', 'booking_headers.id') | |
->leftJoin('booking_van_types', 'booking_details.van_type', '=', 'booking_van_types.id') | |
->leftJoin('booking_fcl_sizes', 'booking_details.fcl_size', '=', 'booking_fcl_sizes.id') | |
->leftJoin('booking_partner_infos', 'booking_headers.ship_fwdr', '=', 'booking_partner_infos.id') | |
->leftJoin('booking_partner_contacts', 'booking_headers.contact_id', '=', 'booking_partner_contacts.id') | |
->leftJoin('booking_dispatch_headers', 'booking_sub_details.id', '=', 'booking_dispatch_headers.detail_id') | |
->join('booking_dispatch_details', 'booking_dispatch_headers.id', '=', 'booking_dispatch_details.dispatch_id') | |
->select('booking_sub_details.units as qty','booking_fcl_sizes.name as fcl_size','booking_details.empty_loaded as empty_loaded', | |
'booking_van_types.name as van_type','booking_partner_infos.name as shipper','booking_headers.id as booking_id','booking_headers.booking_date as booking_date', | |
'booking_sub_details.date_needed as date_needed','booking_sub_details.time_needed as time_needed','booking_partner_contacts.firstname as contact_name', | |
'booking_sub_details.remarks as remarks','booking_headers.status as status','booking_details.service_type as service_type','booking_details.booking_id as details_id', | |
'booking_dispatch_headers.id as dispatch_id','booking_sub_details.id as bookingsubdetails_id','booking_dispatch_details.id as bookingdispatchdetails_id','booking_headers.id as bookingheaders_id', | |
'booking_dispatch_details.dispatched_on as dispatch_time','booking_sub_details.status as bookingdetails_status','booking_sub_details.id as subdetails_id','booking_sub_details.ship_line as shippingline') | |
->where('booking_details.service_type', 'NOT LIKE', 'Pull/Out') | |
->where('booking_details.booking_type', 'LIKE', '2') | |
->where('booking_sub_details.status', 'NOT LIKE', 'Dispatch') | |
->whereBetween('booking_headers.booking_date', [$from, $to]) | |
->groupBy('booking_sub_details.id') | |
->orderBy('booking_sub_details.status', 'desc') | |
->orderBy('booking_headers.booking_date', 'desc')->with('shippinlines') | |
->get(); | |
return Response::json($rental, 200, array(), JSON_PRETTY_PRINT); | |
} | |
public function DisplayRental(){ | |
$from = Input::get('fromleft'); | |
$to = Input::get('toleft'); | |
$rental = BookingSubDetail::join('booking_details', 'booking_sub_details.detail_id', '=', 'booking_details.detail_id') | |
->leftjoin('booking_headers', 'booking_details.booking_id', '=', 'booking_headers.id') | |
->leftJoin('booking_van_types', 'booking_details.van_type', '=', 'booking_van_types.id') | |
->leftJoin('booking_fcl_sizes', 'booking_details.fcl_size', '=', 'booking_fcl_sizes.id') | |
->leftJoin('booking_partner_infos', 'booking_headers.ship_fwdr', '=', 'booking_partner_infos.id') | |
->leftJoin('booking_partner_contacts', 'booking_headers.contact_id', '=', 'booking_partner_contacts.id') | |
->leftJoin('booking_dispatch_headers', 'booking_headers.id', '=', 'booking_dispatch_headers.booking_id') | |
->leftjoin('booking_dispatch_details', 'booking_dispatch_headers.id', '=', 'booking_dispatch_details.dispatch_id') | |
->select('booking_sub_details.units as qty','booking_fcl_sizes.name as fcl_size','booking_details.empty_loaded as empty_loaded', | |
'booking_van_types.name as van_type','booking_partner_infos.name as shipper','booking_headers.id as booking_id','booking_headers.booking_date as booking_date', | |
'booking_sub_details.date_needed as date_needed','booking_sub_details.time_needed as time_needed','booking_partner_contacts.firstname as contact_name', | |
'booking_sub_details.remarks as remarks','booking_headers.status as status','booking_details.service_type as service_type','booking_details.booking_id as details_id', | |
'booking_dispatch_headers.id as dispatch_id','booking_sub_details.id as bookingsubdetails_id','booking_dispatch_details.id as bookingdispatchdetails_id','booking_headers.id as bookingheaders_id', | |
'booking_dispatch_details.dispatched_on as dispatch_time','booking_sub_details.status as bookingdetails_status','booking_sub_details.id as subdetails_id','booking_sub_details.ship_line as shippingline') | |
->where('booking_details.service_type', 'NOT LIKE', 'Pull/Out') | |
->where('booking_details.booking_type', 'LIKE', '1') | |
->where('booking_sub_details.status', 'NOT LIKE', 'Dispatch') | |
->whereBetween('booking_headers.booking_date', [$from, $to]) | |
->groupBy('booking_sub_details.id') | |
->orderBy('booking_sub_details.status', 'desc') | |
->orderBy('booking_headers.booking_date', 'desc')->with('shippinlines') | |
->get(); | |
return Response::json($rental, 200, array(), JSON_PRETTY_PRINT); | |
} | |
public function DisplayServicePullOut(){ | |
$from = Input::get('fromright'); | |
$to = Input::get('toright'); | |
$rental = BookingSubDetail::join('booking_details', 'booking_sub_details.detail_id', '=', 'booking_details.detail_id') | |
->leftjoin('booking_headers', 'booking_details.booking_id', '=', 'booking_headers.id') | |
->leftJoin('booking_van_types', 'booking_details.van_type', '=', 'booking_van_types.id') | |
->leftJoin('booking_fcl_sizes', 'booking_details.fcl_size', '=', 'booking_fcl_sizes.id') | |
->leftJoin('booking_partner_infos', 'booking_headers.ship_fwdr', '=', 'booking_partner_infos.id') | |
->leftJoin('booking_partner_contacts', 'booking_headers.contact_id', '=', 'booking_partner_contacts.id') | |
->leftJoin('booking_dispatch_headers', 'booking_headers.id', '=', 'booking_dispatch_headers.booking_id') | |
->leftjoin('booking_dispatch_details', 'booking_dispatch_headers.id', '=', 'booking_dispatch_details.dispatch_id') | |
->select('booking_sub_details.units as qty','booking_fcl_sizes.name as fcl_size','booking_details.empty_loaded as empty_loaded', | |
'booking_van_types.name as van_type','booking_partner_infos.name as shipper','booking_headers.id as booking_id','booking_headers.booking_date as booking_date', | |
'booking_sub_details.date_needed as date_needed','booking_sub_details.time_needed as time_needed','booking_partner_contacts.firstname as contact_name', | |
'booking_sub_details.remarks as remarks','booking_headers.status as status','booking_details.service_type as service_type','booking_details.booking_id as details_id', | |
'booking_dispatch_headers.id as dispatch_id','booking_sub_details.id as bookingsubdetails_id','booking_dispatch_details.id as bookingdispatchdetails_id','booking_headers.id as bookingheaders_id', | |
'booking_dispatch_details.dispatched_on as dispatch_time','booking_sub_details.status as bookingdetails_status','booking_sub_details.id as subdetails_id','booking_sub_details.ship_line as shippingline') | |
->where('booking_details.service_type', 'LIKE', 'Pull/Out') | |
->where('booking_details.booking_type', 'LIKE', '2') | |
->where('booking_sub_details.status', 'NOT LIKE', 'Dispatch') | |
->whereBetween('booking_headers.booking_date', [$from, $to]) | |
->groupBy('booking_sub_details.id') | |
->orderBy('booking_sub_details.status', 'desc') | |
->orderBy('booking_headers.booking_date', 'desc')->with('shippinlines') | |
->get(); | |
return Response::json($rental, 200, array(), JSON_PRETTY_PRINT); | |
} | |
public function DisplayRentalPullOut(){ | |
$from = Input::get('fromright'); | |
$to = Input::get('toright'); | |
$rental = BookingSubDetail::join('booking_details', 'booking_sub_details.detail_id', '=', 'booking_details.detail_id') | |
->leftjoin('booking_headers', 'booking_details.booking_id', '=', 'booking_headers.id') | |
->leftJoin('booking_van_types', 'booking_details.van_type', '=', 'booking_van_types.id') | |
->leftJoin('booking_fcl_sizes', 'booking_details.fcl_size', '=', 'booking_fcl_sizes.id') | |
->leftJoin('booking_partner_infos', 'booking_headers.ship_fwdr', '=', 'booking_partner_infos.id') | |
->leftJoin('booking_partner_contacts', 'booking_headers.contact_id', '=', 'booking_partner_contacts.id') | |
->leftJoin('booking_dispatch_headers', 'booking_headers.id', '=', 'booking_dispatch_headers.booking_id') | |
->leftjoin('booking_dispatch_details', 'booking_dispatch_headers.id', '=', 'booking_dispatch_details.dispatch_id') | |
->select('booking_sub_details.units as qty','booking_fcl_sizes.name as fcl_size','booking_details.empty_loaded as empty_loaded', | |
'booking_van_types.name as van_type','booking_partner_infos.name as shipper','booking_headers.id as booking_id','booking_headers.booking_date as booking_date', | |
'booking_sub_details.date_needed as date_needed','booking_sub_details.time_needed as time_needed','booking_partner_contacts.firstname as contact_name', | |
'booking_sub_details.remarks as remarks','booking_headers.status as status','booking_details.service_type as service_type','booking_details.booking_id as details_id', | |
'booking_dispatch_headers.id as dispatch_id','booking_sub_details.id as bookingsubdetails_id','booking_dispatch_details.id as bookingdispatchdetails_id','booking_headers.id as bookingheaders_id', | |
'booking_dispatch_details.dispatched_on as dispatch_time','booking_sub_details.status as bookingdetails_status','booking_sub_details.id as subdetails_id','booking_sub_details.ship_line as shippingline') | |
->where('booking_details.service_type', 'LIKE', 'Pull/Out') | |
->where('booking_details.booking_type', 'LIKE', '1') | |
->where('booking_sub_details.status', 'NOT LIKE', 'Dispatch') | |
->whereBetween('booking_headers.booking_date', [$from, $to]) | |
->groupBy('booking_sub_details.id') | |
->orderBy('booking_headers.status') | |
->orderBy('booking_sub_details.status', 'desc') | |
->orderBy('booking_headers.booking_date', 'desc')->with('shippinlines') | |
->get(); | |
return Response::json($rental, 200, array(), JSON_PRETTY_PRINT); | |
} | |
// public function postUsermanagement(){ | |
// $partner_name = Input::get('partnername'); | |
// $partner_id = Input::get('partner_id'); | |
// $username = Input::get('username'); | |
// $password = Input::get('password'); | |
// $user = User::where('partner_id', $partner_id)->first(); | |
// if(count($user) > 0){ | |
// Session::flash('alert-danger', 'Partner Name already Existed!!.'); | |
// return redirect('booking/usermanagement'); | |
// } | |
// else{ | |
// $newuser = new User; | |
// $newuser->name = $partner_name; | |
// $newuser->username = $username; | |
// $newuser->password = bcrypt($password); | |
// $newuser->partner_id = $partner_id; | |
// //$newuser->save(); | |
// if($newuser->save()){ | |
// Session::flash('alert-success', 'User Successfully Added.'); | |
// return redirect('booking/usermanagement'); | |
// } | |
// else{ | |
// Session::flash('alert-danger', 'Partner Name already Existed!!.'); | |
// return redirect('booking/usermanagement'); | |
// } | |
// } | |
// } | |
public function adduser5(){ | |
$partner_id = Input::get('partner_id'); | |
$username = Input::get('username'); | |
$status = Input::get('status'); | |
$result = User::where('partner_id',$partner_id)->count(); | |
$result1 = User::where('username',$username)->count(); | |
if ($result > 0 || $result1 > 0) { | |
$final = User::where('partner_id',$partner_id)->first(); | |
$final->module5 = "Yes"; | |
$final->status5 = $status; | |
$final->save(); | |
// $today = date("Y-m-d H:i:s", time()); | |
// $logs = new DeskpadUserLog; | |
// $logs->created_by_id = Session::get('user'); | |
// $logs->partner_id = $partner_id; | |
// $logs->action = "Save"; | |
// $logs->date_on = $today; | |
// $logs->save(); | |
return Response::json($final, 200, array(), JSON_PRETTY_PRINT); | |
} | |
else { | |
$final = new User; | |
$final->username = $username; | |
$final->partner_id = $partner_id; | |
$final->status5 = $status; | |
$final->module5 = 'Yes'; | |
$final->save(); | |
// $today = date("Y-m-d H:i:s", time()); | |
// $logs = new DeskpadUserLog; | |
// $logs->created_by_id = Session::get('user'); | |
// $logs->partner_id = $partner_id; | |
// $logs->action = "Save"; | |
// $logs->date_on = $today; | |
// $logs->save(); | |
return Response::json($final, 200, array(), JSON_PRETTY_PRINT); | |
} | |
} | |
public function postUsermanagement(){ | |
$partner_id = Input::get('partner_id'); | |
$username = Input::get('username'); | |
$password = Input::get('password'); | |
$status = Input::get('status'); | |
//return Response::json($password, 200, array(), JSON_PRETTY_PRINT); | |
$newuser = User::where('partner_id', $partner_id)->first(); | |
$newuser->username = $username; | |
if ($password == "") { | |
} | |
else { | |
$newuser->password = bcrypt($password); | |
} | |
$newuser->partner_id = $partner_id; | |
$newuser->status5 = $status; | |
$newuser->save(); | |
$check = UserTransactingBranch::where('user_id',$newuser->id)->count(); | |
$count1001 = count(Input::get('branchid1')); | |
//return Response::json($count1001, 200, array(), JSON_PRETTY_PRINT); | |
for ($i=0; $i < $count1001; $i++) { | |
$checking = UserTransactingBranch::where('user_id',$newuser->id)->where('trans_branch_id',Input::get('branchid1')[$i])->count(); | |
if ($checking == 0) { | |
$userbranch = new UserTransactingBranch; | |
$userbranch->user_id = $newuser->id; | |
$userbranch->trans_branch_id = Input::get('branchid1')[$i]; | |
$userbranch->checked = Input::get('status1')[$i]; | |
$userbranch->status = Input::get('status1')[$i]; | |
$userbranch->save(); | |
} | |
else { | |
$userbranch = $checking = UserTransactingBranch::where('user_id',$newuser->id)->where('trans_branch_id',Input::get('branchid1')[$i])->first(); | |
if (!$userbranch) { | |
$userbranch = new UserTransactingBranch; | |
$userbranch->user_id = $newuser->id; | |
$userbranch->trans_branch_id = Input::get('branchid1')[$i]; | |
$userbranch->checked = Input::get('status1')[$i]; | |
$userbranch->status = Input::get('status1')[$i]; | |
$userbranch->save(); | |
} | |
else { | |
$userbranch->user_id = $newuser->id; | |
$userbranch->trans_branch_id = Input::get('branchid1')[$i]; | |
$userbranch->checked = Input::get('status1')[$i]; | |
$userbranch->status = Input::get('status1')[$i]; | |
$userbranch->save(); | |
} | |
} | |
} | |
// $today = date("Y-m-d H:i:s", time()); | |
// $logs = new DeskpadUserLog; | |
// $logs->created_by_id = Session::get('user'); | |
// $logs->partner_id = $partner_id; | |
// $logs->action = "Update"; | |
// $logs->date_on = $today; | |
// $logs->save(); | |
Session::flash('alert-success', 'User Successfully Updated'); | |
return redirect('booking/usermanagement'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment