diff --git a/.gitignore b/.gitignore index 414589fc..9035d84d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ /.vscode /.vagrant /data +vendor/composer Homestead.json Homestead.yaml npm-debug.log diff --git a/app/Booking.php b/app/Booking.php index 33e6fe75..b03276d9 100644 --- a/app/Booking.php +++ b/app/Booking.php @@ -7,6 +7,22 @@ use Illuminate\Database\Eloquent\Model; class Booking extends Model { // protected $guarded = []; + protected $hidden = array('user_id', + "rate_id", + "rmb_book_amount", + "rmb_book_pay_method", + "rmb_book_account_name", + "rmb_book_bank_name", + "rmb_book_acc_no", + "rmb_book_bank_branch", + "usd_book_amount", + "usd_book_pay_method", + "usd_book_company_name", + "usd_book_company_address", + "usd_book_swift_code", + "usd_book_cnap", + "usd_book_bank_branch"); + protected $fillable = ['term', 'rate_id', 'user_id', 'amount', 'account_name', 'account_num', 'bank_name', 'bank_branch', 'company_name']; diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index ecfc4151..840ad692 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -4,6 +4,8 @@ namespace App\Http\Controllers\Auth; use App\User; use App\Role; +use App\Marking; +use Illuminate\Support\Facades\Auth; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Validator; @@ -56,8 +58,16 @@ class RegisterController extends Controller * @param array $data * @return User */ - protected function create(array $data) + protected function create(Request $data) { + $marking = Marking::Where('email',$data['email'])->first(); + if(!$marking){ + return response()->json('Access Denied', 401); + } + if($marking->marking != $data['marking']){ + return response()->json('Wrong Marking', 400); + } + $role = Role::where('name','=','member')->first(); $user = new User(); $user->name = $data['name']; @@ -66,7 +76,6 @@ class RegisterController extends Controller $user->save(); $user->attachRole($role); - return $user; - + return response()->json($user, 201); } } diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index 6f26a2f1..dade691e 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -9,6 +9,8 @@ use App\Booking; use App\Rate; use App\UserBankSlip; use App\User; +use App\Invoice; +use App\SettingCredit; use Auth; use Validator; use DateTime; @@ -16,32 +18,164 @@ use DateTime; class BookingController extends Controller { + public function index(){ + $user = Auth::user(); + $bookings = Booking::select('id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status') + ->where('user_id', $user->id) + ->get(); + + // reformat to fit frontend structure + foreach ($bookings as $booking) { + // set timeout + $date1 = new DateTime($booking->created_at); + $date2 = new DateTime(); + $time_in_seconds = SettingCredit::orderby('updated_at','desc')->first()->time_limit; + $difference_in_seconds = ($date1->format('U') + $time_in_seconds) - ($date2->format('U')); + $booking->timeout = $difference_in_seconds; + + // TODO : you can make it better + if($difference_in_seconds < 0 ){ + $booking->timeout = 0; + } + + // TODO : transfer_amount change name to bia + $booking->transfer_amount = $booking->bia; + + $booking->track_status = "(". $booking->status ."/6)"; + switch ($booking->status) { + case 1: + $status_desc = "Order in progress"; + break; + case 2: + $status_desc = "Waiting for payment"; + break; + case 3: + $status_desc = "Waiting verification"; + break; + case 4: + $status_desc = "Processing transfer"; + break; + case 5: + $status_desc = "Transfer Complete, please upload your PO"; + break; + case 6: + $status_desc = "Processing invoice"; + break; + default: + $status_desc = ""; + } + $booking->status_desc = $status_desc; + } + + return $bookings; + } + + public function adminIndex(){ + $user = Auth::user(); + $bookings = Booking::select('id', 'created_at', 'admin_status', 'rate', 'term', 'amount', 'bia', 'verification_status') + ->get(); + + // reformat to fit frontend structure + foreach ($bookings as $booking) { + // set timeout + $date1 = new DateTime($booking->created_at); + $date2 = new DateTime(); + $time_in_seconds = SettingCredit::orderby('updated_at','desc')->first()->time_limit; + $difference_in_seconds = ($date1->format('U') + $time_in_seconds) - ($date2->format('U')); + $booking->timeout = $difference_in_seconds; + + // TODO : you can make it better + if($difference_in_seconds < 0 ){ + $booking->timeout = 0; + } + + // TODO : transfer_amount change name to bia + $booking->transfer_amount = $booking->bia; + + $booking->track_status = "(". $booking->admin_status ."/6)"; + switch ($booking->admin_status) { + case 0: + $status_desc = "Waiting user to upload bankin slip"; + break; + case 1: + $status_desc = "Waiting for verification"; + break; + case 2: + $status_desc = "Bookg with supplier"; + break; + case 3: + $status_desc = "Supplier booking report. Please confirm with your booking."; + break; + case 4: + $status_desc = "Please update supplier booking status."; + break; + case 5: + $status_desc = "Customer has uploaded the invoice, please upload purchase order"; + break; + case 6: + $status_desc = "Booking completed"; + break; + default: + $status_desc = ""; + } + $booking->status_desc = $status_desc; + } + + return $bookings; + + } + public function show($id) { $booking = Booking::where('user_id',Auth::user()->id)->where('id', $id)->first(); + if($booking){ $date1 = new DateTime($booking->created_at); $date2 = new DateTime(); $difference_in_seconds = ($date1->format('U') + 600) - ($date2->format('U')); - - $booking->timeout = $difference_in_seconds; if (!$booking){ return response()->json(['success'=>false, 'message'=>'not found'], 404); } - return $booking; + return $booking; + } + } + + public function adminShow($id) + { + $booking = Booking::where('id', $id)->first(); + return $booking->userBankSlip()->get(); + + if($booking){ + $date1 = new DateTime($booking->created_at); + $date2 = new DateTime(); + $difference_in_seconds = ($date1->format('U') + 600) - ($date2->format('U')); + + $booking->timeout = $difference_in_seconds; + + if (!$booking){ + return response()->json(['success'=>false, 'message'=>'not found'], 404); + } + return $booking; + } } public function store(Request $request) { $rates = Rate::orderby('updated_at','desc')->first(); $term = $request->input('term'); - $amount = $request->input("amount"); + $amount = $request->input("amount"); // in RMB + $creditLimit = SettingCredit::orderby('updated_at','desc')->first(); + if($amount > $creditLimit->rmb_credit_limit){ + return response()->json("Exceed credit limit, need approved from admin", 401); + } + $user = Auth::user(); $rate = 1; // default rate to 1 + switch ($term) { case "x1_cash": $rate = $rates->x1_cash; @@ -100,7 +234,9 @@ class BookingController extends Controller $booking->amount = $request->input('amount'); $booking->term = $term; $booking->rate_id = $rates->id; + $booking->rate = $rate; $booking->rmb_book_amount = $request->input('amount'); + $booking->status = 2; $booking->bia = $bia; // $booking->user_id = $user->id; $booking->user()->associate($user); @@ -191,14 +327,14 @@ class BookingController extends Controller $input['file'] = $filename; $unique_name = 'bank_slip_' . md5($filename. time()); // probably not a good idea - $unique_image_url = $unique_name. '.' .$ext; + $unique_image_path = $unique_name. '.' .$ext; Storage::putFileAs( - 'user_bankslip', $bankslip_file, $unique_image_url + 'user_bankslip', $bankslip_file, $unique_image_path ); $user_bankslip = new UserBankSlip; $user_bankslip->booking_id = $booking->id; - $user_bankslip->bankslip_file = $unique_image_url; + $user_bankslip->bankslip_path = $unique_image_path; $user_bankslip->transfer_amount = $request->input('transfer_amount'); $user_bankslip->save(); @@ -248,19 +384,25 @@ class BookingController extends Controller $input['file'] = $filename; $unique_name = 'purchase_order_' . md5($filename. time()); - $unique_image_url = $unique_name. '.' .$ext; + $unique_image_path = $unique_name. '.' .$ext; Storage::putFileAs( - 'file',/*folder name*/ $user_input_file, $unique_image_url + 'purchase_order',/*folder name*/ $user_input_file, $unique_image_path ); $user_po = new PurchaseOrder; - $user_po->image_url = $unique_image_url; + $user_po->image_path = $unique_image_path; $user_po->book_id = $booking->id; - $user_po->amount = $request->input('amount'); $user_po->save(); return response()->json(['message'=>'Success'],200); } + + public function confirmPurchaseOrder($id){ + $booking = Booking::where('user_id',Auth::user()->id)->where('id',$id)->first(); + $booking->status = 5; + $booking->save(); + return response()->json(['message'=>'Success'],200); + } public function delete(Booking $book_id) { @@ -282,7 +424,8 @@ class BookingController extends Controller return response()->json(['message'=>'Success'],200); } - public function calculation(Request $request){ + public function calculation(Request $request) + { $amount = $request->input('amount'); $term = $request->input('term'); $china_beneficiary = $request->input('china_beneficiary'); @@ -342,7 +485,7 @@ class BookingController extends Controller 'bankin_amount' => $bankin_amount, 'china_beneficary' => $china_beneficiary ], 200); - } + } public function approveBankSlip(Request $request, $book_id) { @@ -351,7 +494,7 @@ class BookingController extends Controller return response()->json(['message'=>'Access denied'], 200); } - if(!$userBankSlip = UserBankSlip::where('book_id',$booking->id)->first()) + if(!$userBankSlip = UserBankSlip::where('booking_id',$booking->id)->first()) { return response()->json(['message'=>'Access denied'], 200); } @@ -363,6 +506,7 @@ class BookingController extends Controller } $userBankSlip->is_approve = 1; + $userBankSlip->estimated_arrival_time = $request->input('estimated_arrival_time'); $userBankSlip->save(); return response()->json(['message'=>'Success'],200); } @@ -374,7 +518,7 @@ class BookingController extends Controller return response()->json(['message'=>'Access denied'], 200); } - if(!$userBankSlip = UserBankSlip::where('book_id',$booking->id)->first()) + if(!$userBankSlip = UserBankSlip::where('booking_id',$booking->id)->first()) { return response()->json(['message'=>'Access denied'], 200); } @@ -392,4 +536,48 @@ class BookingController extends Controller return response()->json(['message'=>'Success'],200); } + public function uploadInvoice(Request $request, $id) + { + $booking = Booking::where('user_id',Auth::user()->id)->where('id',$id)->first(); + + /* Validation */ + if (!$booking) + { + return response()->json(['message'=>'Access denied'], 200); + } + + $validator = Validator::make($request->all(), [ + 'invoice_path' => 'mimes:jpg,jpeg,bmp,png,pdf,doc,docx' + ]); + + if($validator->fails()) + { + return response()->json(['message'=>'Incorrect format'],200); + } + + if(!$input_file = $request->file('invoice_path')) + { + return response()->json(['message'=>'No file detected'], 400); + } + /* End Validation */ + + $filename = $input_file->getClientOriginalName(); + $ext = $input_file->getClientOriginalExtension(); + + $input['invoice_path'] = $filename; + $unique_name = 'invoice' . md5($filename. time()); + $unique_file_url = $unique_name. '.' .$ext; + Storage::putFileAs( + 'invoice',/*folder name*/ $input_file, $unique_file_url + ); + + $invoice = new Invoice; + $invoice->invoice_path = $unique_file_url; + $invoice->amount = $request->input('amount'); + $invoice->booking_id = $booking->id; + $invoice->save(); + + return response()->json(['message'=>"Success"],200); + } + } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php new file mode 100644 index 00000000..a3af7dd8 --- /dev/null +++ b/app/Http/Controllers/HomeController.php @@ -0,0 +1,28 @@ +middleware('auth'); + } + + /** + * Show the application dashboard. + * + * @return \Illuminate\Http\Response + */ + public function index() + { + return view('home'); + } +} diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 58f9b8ab..392564cc 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use Auth; class UserController extends Controller { @@ -15,7 +16,9 @@ class UserController extends Controller * @return \Illuminate\Http\Response */ public function show(Request $request) - { - return $request->user(); + { + + $user = Auth::user(); + return $user; } } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index da7a7f5c..a95cd23b 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -61,5 +61,6 @@ class Kernel extends HttpKernel 'ability' => 'App\Http\Middleware\TokenEntrustAbility', 'role' => \Zizaco\Entrust\Middleware\EntrustRole::class, 'permission' => \Zizaco\Entrust\Middleware\EntrustPermission::class, + 'ability' => 'App\Http\Middleware\TokenEntrustAbility' ]; } diff --git a/app/Invoice.php b/app/Invoice.php new file mode 100644 index 00000000..570dc72b --- /dev/null +++ b/app/Invoice.php @@ -0,0 +1,10 @@ +roles->first()->name; + return $this->roles->first()->name; } /** diff --git a/app/UserBankSlip.php b/app/UserBankSlip.php index 3e3e6678..eb6ddc0e 100644 --- a/app/UserBankSlip.php +++ b/app/UserBankSlip.php @@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model; class UserBankSlip extends Model { - protected $fillable = ['bank_slip_type','bankslip_url','transfer_amount','booking_id','cust_marking']; + protected $fillable = ['bank_slip_type','bankslip_url','transfer_amount','booking_id','cust_marking','estimated_arrival_time']; public function booking() { diff --git a/composer.lock b/composer.lock index a060a284..674363c5 100644 --- a/composer.lock +++ b/composer.lock @@ -1063,16 +1063,16 @@ }, { "name": "laravel/framework", - "version": "v5.6.25", + "version": "v5.6.26", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "a15efe4fbcd6b38ea76edc5c8939ffde4f4c7b7f" + "reference": "7047df295e77cecb6a2f84736a732af66cc6789c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/a15efe4fbcd6b38ea76edc5c8939ffde4f4c7b7f", - "reference": "a15efe4fbcd6b38ea76edc5c8939ffde4f4c7b7f", + "url": "https://api.github.com/repos/laravel/framework/zipball/7047df295e77cecb6a2f84736a732af66cc6789c", + "reference": "7047df295e77cecb6a2f84736a732af66cc6789c", "shasum": "" }, "require": { @@ -1198,7 +1198,7 @@ "framework", "laravel" ], - "time": "2018-06-12T14:39:24+00:00" + "time": "2018-06-20T14:21:11+00:00" }, { "name": "laravel/socialite", @@ -1327,16 +1327,16 @@ }, { "name": "laravelcollective/html", - "version": "v5.6.9", + "version": "v5.6.10", "source": { "type": "git", "url": "https://github.com/LaravelCollective/html.git", - "reference": "fda9d3dad85ecea609ef9c6323d6923536cf5643" + "reference": "974605fcd22a7e4d19f0b2ef635a0d1d7400387d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/LaravelCollective/html/zipball/fda9d3dad85ecea609ef9c6323d6923536cf5643", - "reference": "fda9d3dad85ecea609ef9c6323d6923536cf5643", + "url": "https://api.github.com/repos/LaravelCollective/html/zipball/974605fcd22a7e4d19f0b2ef635a0d1d7400387d", + "reference": "974605fcd22a7e4d19f0b2ef635a0d1d7400387d", "shasum": "" }, "require": { @@ -1391,7 +1391,7 @@ ], "description": "HTML and Form Builders for the Laravel Framework", "homepage": "https://laravelcollective.com", - "time": "2018-05-30T16:09:07+00:00" + "time": "2018-06-18T15:04:16+00:00" }, { "name": "lcobucci/jwt", @@ -1441,7 +1441,7 @@ { "name": "Luís Otávio Cobucci Oblonczyk", "email": "lcobucci@gmail.com", - "role": "developer" + "role": "Developer" } ], "description": "A simple library to work with JSON Web Token and JSON Web Signature", @@ -2295,16 +2295,16 @@ }, { "name": "symfony/console", - "version": "v4.1.0", + "version": "v4.1.1", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "2d5d973bf9933d46802b01010bd25c800c87c242" + "reference": "70591cda56b4b47c55776ac78e157c4bb6c8b43f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/2d5d973bf9933d46802b01010bd25c800c87c242", - "reference": "2d5d973bf9933d46802b01010bd25c800c87c242", + "url": "https://api.github.com/repos/symfony/console/zipball/70591cda56b4b47c55776ac78e157c4bb6c8b43f", + "reference": "70591cda56b4b47c55776ac78e157c4bb6c8b43f", "shasum": "" }, "require": { @@ -2359,11 +2359,11 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2018-05-30T07:26:09+00:00" + "time": "2018-05-31T10:17:53+00:00" }, { "name": "symfony/css-selector", - "version": "v4.1.0", + "version": "v4.1.1", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", @@ -2416,16 +2416,16 @@ }, { "name": "symfony/debug", - "version": "v4.1.0", + "version": "v4.1.1", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "449f8b00b28ab6e6912c3e6b920406143b27193b" + "reference": "dbe0fad88046a755dcf9379f2964c61a02f5ae3d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/449f8b00b28ab6e6912c3e6b920406143b27193b", - "reference": "449f8b00b28ab6e6912c3e6b920406143b27193b", + "url": "https://api.github.com/repos/symfony/debug/zipball/dbe0fad88046a755dcf9379f2964c61a02f5ae3d", + "reference": "dbe0fad88046a755dcf9379f2964c61a02f5ae3d", "shasum": "" }, "require": { @@ -2468,11 +2468,11 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2018-05-16T14:33:22+00:00" + "time": "2018-06-08T09:39:36+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.1.0", + "version": "v4.1.1", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -2535,16 +2535,16 @@ }, { "name": "symfony/finder", - "version": "v4.1.0", + "version": "v4.1.1", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "087e2ee0d74464a4c6baac4e90417db7477dc238" + "reference": "84714b8417d19e4ba02ea78a41a975b3efaafddb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/087e2ee0d74464a4c6baac4e90417db7477dc238", - "reference": "087e2ee0d74464a4c6baac4e90417db7477dc238", + "url": "https://api.github.com/repos/symfony/finder/zipball/84714b8417d19e4ba02ea78a41a975b3efaafddb", + "reference": "84714b8417d19e4ba02ea78a41a975b3efaafddb", "shasum": "" }, "require": { @@ -2580,20 +2580,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2018-05-16T14:33:22+00:00" + "time": "2018-06-19T21:38:16+00:00" }, { "name": "symfony/http-foundation", - "version": "v4.1.0", + "version": "v4.1.1", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "a916c88390fb861ee21f12a92b107d51bb68af99" + "reference": "4f9c7cf962e635b0b26b14500ac046e07dbef7f3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/a916c88390fb861ee21f12a92b107d51bb68af99", - "reference": "a916c88390fb861ee21f12a92b107d51bb68af99", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/4f9c7cf962e635b0b26b14500ac046e07dbef7f3", + "reference": "4f9c7cf962e635b0b26b14500ac046e07dbef7f3", "shasum": "" }, "require": { @@ -2634,20 +2634,20 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2018-05-25T14:55:38+00:00" + "time": "2018-06-19T21:38:16+00:00" }, { "name": "symfony/http-kernel", - "version": "v4.1.0", + "version": "v4.1.1", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "b5ab9d4cdbfd369083744b6b5dfbf454e31e5f90" + "reference": "29c094a1c4f8209b7e033f612cbbd69029e38955" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/b5ab9d4cdbfd369083744b6b5dfbf454e31e5f90", - "reference": "b5ab9d4cdbfd369083744b6b5dfbf454e31e5f90", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/29c094a1c4f8209b7e033f612cbbd69029e38955", + "reference": "29c094a1c4f8209b7e033f612cbbd69029e38955", "shasum": "" }, "require": { @@ -2655,13 +2655,13 @@ "psr/log": "~1.0", "symfony/debug": "~3.4|~4.0", "symfony/event-dispatcher": "~4.1", - "symfony/http-foundation": "~4.1", + "symfony/http-foundation": "^4.1.1", "symfony/polyfill-ctype": "~1.8" }, "conflict": { "symfony/config": "<3.4", "symfony/dependency-injection": "<4.1", - "symfony/var-dumper": "<4.1", + "symfony/var-dumper": "<4.1.1", "twig/twig": "<1.34|<2.4,>=2" }, "provide": { @@ -2682,7 +2682,7 @@ "symfony/stopwatch": "~3.4|~4.0", "symfony/templating": "~3.4|~4.0", "symfony/translation": "~3.4|~4.0", - "symfony/var-dumper": "~4.1" + "symfony/var-dumper": "^4.1.1" }, "suggest": { "symfony/browser-kit": "", @@ -2721,7 +2721,7 @@ ], "description": "Symfony HttpKernel Component", "homepage": "https://symfony.com", - "time": "2018-05-30T12:52:34+00:00" + "time": "2018-06-25T13:06:45+00:00" }, { "name": "symfony/polyfill-ctype", @@ -3002,16 +3002,16 @@ }, { "name": "symfony/process", - "version": "v4.1.0", + "version": "v4.1.1", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "73445bd33b0d337c060eef9652b94df72b6b3434" + "reference": "1d1677391ecf00d1c5b9482d6050c0c27aa3ac3a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/73445bd33b0d337c060eef9652b94df72b6b3434", - "reference": "73445bd33b0d337c060eef9652b94df72b6b3434", + "url": "https://api.github.com/repos/symfony/process/zipball/1d1677391ecf00d1c5b9482d6050c0c27aa3ac3a", + "reference": "1d1677391ecf00d1c5b9482d6050c0c27aa3ac3a", "shasum": "" }, "require": { @@ -3047,20 +3047,20 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2018-05-30T07:26:09+00:00" + "time": "2018-05-31T10:17:53+00:00" }, { "name": "symfony/routing", - "version": "v4.1.0", + "version": "v4.1.1", "source": { "type": "git", "url": "https://github.com/symfony/routing.git", - "reference": "180b51c66d10f09e562c9ebc395b39aacb2cf8a2" + "reference": "b38b9797327b26ea2e4146a40e6e2dc9820a6932" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/routing/zipball/180b51c66d10f09e562c9ebc395b39aacb2cf8a2", - "reference": "180b51c66d10f09e562c9ebc395b39aacb2cf8a2", + "url": "https://api.github.com/repos/symfony/routing/zipball/b38b9797327b26ea2e4146a40e6e2dc9820a6932", + "reference": "b38b9797327b26ea2e4146a40e6e2dc9820a6932", "shasum": "" }, "require": { @@ -3073,7 +3073,6 @@ }, "require-dev": { "doctrine/annotations": "~1.0", - "doctrine/common": "~2.2", "psr/log": "~1.0", "symfony/config": "~3.4|~4.0", "symfony/dependency-injection": "~3.4|~4.0", @@ -3125,20 +3124,20 @@ "uri", "url" ], - "time": "2018-05-30T07:26:09+00:00" + "time": "2018-06-19T21:38:16+00:00" }, { "name": "symfony/translation", - "version": "v4.1.0", + "version": "v4.1.1", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "16328f5b217cebc8dd4adfe4aeeaa8c377581f5a" + "reference": "b6d8164085ee0b6debcd1b7a131fd6f63bb04854" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/16328f5b217cebc8dd4adfe4aeeaa8c377581f5a", - "reference": "16328f5b217cebc8dd4adfe4aeeaa8c377581f5a", + "url": "https://api.github.com/repos/symfony/translation/zipball/b6d8164085ee0b6debcd1b7a131fd6f63bb04854", + "reference": "b6d8164085ee0b6debcd1b7a131fd6f63bb04854", "shasum": "" }, "require": { @@ -3194,20 +3193,20 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2018-05-30T07:26:09+00:00" + "time": "2018-06-22T08:59:39+00:00" }, { "name": "symfony/var-dumper", - "version": "v4.1.0", + "version": "v4.1.1", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "bc88ad53e825ebacc7b190bbd360781fce381c64" + "reference": "b2eebaec085d1f2cafbad7644733d494a3bbbc9b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/bc88ad53e825ebacc7b190bbd360781fce381c64", - "reference": "bc88ad53e825ebacc7b190bbd360781fce381c64", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/b2eebaec085d1f2cafbad7644733d494a3bbbc9b", + "reference": "b2eebaec085d1f2cafbad7644733d494a3bbbc9b", "shasum": "" }, "require": { @@ -3269,7 +3268,7 @@ "debug", "dump" ], - "time": "2018-04-29T07:56:09+00:00" + "time": "2018-06-23T12:23:56+00:00" }, { "name": "tijsverkoyen/css-to-inline-styles", @@ -3798,20 +3797,20 @@ }, { "name": "laravel/dusk", - "version": "v3.0.8", + "version": "v3.0.9", "source": { "type": "git", "url": "https://github.com/laravel/dusk.git", - "reference": "c6201427e63b869b0c1ee83d91c1d1958b71968e" + "reference": "48215ab0028d759e5fd7cc8989f4b6c58050841d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/dusk/zipball/c6201427e63b869b0c1ee83d91c1d1958b71968e", - "reference": "c6201427e63b869b0c1ee83d91c1d1958b71968e", + "url": "https://api.github.com/repos/laravel/dusk/zipball/48215ab0028d759e5fd7cc8989f4b6c58050841d", + "reference": "48215ab0028d759e5fd7cc8989f4b6c58050841d", "shasum": "" }, "require": { - "facebook/webdriver": "~1.0", + "facebook/webdriver": "~1.3", "illuminate/console": "~5.6", "illuminate/support": "~5.6", "nesbot/carbon": "~1.20", @@ -3855,7 +3854,7 @@ "testing", "webdriver" ], - "time": "2018-04-29T19:15:23+00:00" + "time": "2018-06-20T13:47:27+00:00" }, { "name": "mockery/mockery", @@ -3973,16 +3972,16 @@ }, { "name": "nunomaduro/collision", - "version": "v2.0.2", + "version": "v2.0.3", "source": { "type": "git", "url": "https://github.com/nunomaduro/collision.git", - "reference": "245958b02c6a9edf24627380f368333ac5413a51" + "reference": "b1f606399ae77e9479b5597cd1aa3d8ea0078176" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/collision/zipball/245958b02c6a9edf24627380f368333ac5413a51", - "reference": "245958b02c6a9edf24627380f368333ac5413a51", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/b1f606399ae77e9479b5597cd1aa3d8ea0078176", + "reference": "b1f606399ae77e9479b5597cd1aa3d8ea0078176", "shasum": "" }, "require": { @@ -3993,7 +3992,8 @@ }, "require-dev": { "laravel/framework": "5.6.*", - "phpunit/phpunit": "~7.0" + "phpstan/phpstan": "^0.9.2", + "phpunit/phpunit": "~7.2" }, "type": "library", "extra": { @@ -4031,7 +4031,7 @@ "php", "symfony" ], - "time": "2018-03-21T20:11:24+00:00" + "time": "2018-06-16T22:05:52+00:00" }, { "name": "phar-io/manifest", @@ -4601,16 +4601,16 @@ }, { "name": "phpunit/phpunit", - "version": "7.2.4", + "version": "7.2.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "00bc0b93f0ff4f557e9ea766557fde96da9a03dd" + "reference": "400a3836ee549ae6f665323ac3f21e27eac7155f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/00bc0b93f0ff4f557e9ea766557fde96da9a03dd", - "reference": "00bc0b93f0ff4f557e9ea766557fde96da9a03dd", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/400a3836ee549ae6f665323ac3f21e27eac7155f", + "reference": "400a3836ee549ae6f665323ac3f21e27eac7155f", "shasum": "" }, "require": { @@ -4626,7 +4626,7 @@ "php": "^7.1", "phpspec/prophecy": "^1.7", "phpunit/php-code-coverage": "^6.0.7", - "phpunit/php-file-iterator": "^2.0", + "phpunit/php-file-iterator": "^2.0.1", "phpunit/php-text-template": "^1.2.1", "phpunit/php-timer": "^2.0", "sebastian/comparator": "^3.0", @@ -4681,7 +4681,7 @@ "testing", "xunit" ], - "time": "2018-06-05T03:40:05+00:00" + "time": "2018-06-21T13:13:39+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", diff --git a/database/factories/MarkingFactory.php b/database/factories/MarkingFactory.php new file mode 100644 index 00000000..989fcf07 --- /dev/null +++ b/database/factories/MarkingFactory.php @@ -0,0 +1,10 @@ +define(App\Marking::class, function (Faker $faker) { + return [ + 'email' => $faker->unique()->safeEmail, + 'marking' => str_random(10) + ]; +}); diff --git a/database/factories/SettingCreditFactory.php b/database/factories/SettingCreditFactory.php index 890b6be2..f1d4eeba 100644 --- a/database/factories/SettingCreditFactory.php +++ b/database/factories/SettingCreditFactory.php @@ -4,6 +4,8 @@ use Faker\Generator as Faker; $factory->define(App\SettingCredit::class, function (Faker $faker) { return [ - // + 'rmb_credit_limit' => $faker->randomDigit, + 'usd_credit_limit' => $faker->randomDigit, + 'time_limit' => $faker->randomDigit ]; }); diff --git a/database/factories/UserBankSlipFactory.php b/database/factories/UserBankSlipFactory.php index 7ab51f2d..e5406866 100644 --- a/database/factories/UserBankSlipFactory.php +++ b/database/factories/UserBankSlipFactory.php @@ -7,9 +7,10 @@ $factory->define(App\UserBankSlip::class, function (Faker $faker) { return [ 'bank_slip_type' => str_random(10), - 'bankslip_url' => str_random(10), + 'bankslip_path' => str_random(10), 'transfer_amount' => $faker->randomDigit, 'cust_marking' => str_random(10), 'booking_id' => $faker->randomElement($book_id), + 'estimated_arrival_time' => $faker->randomDigit ]; }); diff --git a/database/migrations/2018_06_20_145105_add_rate_to_booking.php b/database/migrations/2018_06_20_145105_add_rate_to_booking.php new file mode 100644 index 00000000..f74e2fb8 --- /dev/null +++ b/database/migrations/2018_06_20_145105_add_rate_to_booking.php @@ -0,0 +1,33 @@ +double('rate')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('bookings', function (Blueprint $table) { + $table->dropColumn('rate'); + // $table->dropColumn('reject_reason'); + }); + } +} \ No newline at end of file diff --git a/database/migrations/2018_06_21_024802_add_status_to_booking_table.php b/database/migrations/2018_06_21_024802_add_status_to_booking_table.php new file mode 100644 index 00000000..3c7daec7 --- /dev/null +++ b/database/migrations/2018_06_21_024802_add_status_to_booking_table.php @@ -0,0 +1,33 @@ +integer('status')->default(1); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('bookings', function (Blueprint $table) { + $table->dropColumn('status'); + // $table->dropColumn('reject_reason'); + }); + } +} diff --git a/database/migrations/2018_06_21_040652_create_invoice_table.php b/database/migrations/2018_06_21_040652_create_invoice_table.php new file mode 100644 index 00000000..ab3a8e48 --- /dev/null +++ b/database/migrations/2018_06_21_040652_create_invoice_table.php @@ -0,0 +1,35 @@ +increments('id'); + $table->string('invoice_path'); + $table->double('amount'); + $table->integer('booking_id')->unsigned(); + $table->foreign('booking_id')->references('id')->on('bookings'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('invoices'); + } +} diff --git a/database/migrations/2018_06_21_062637_rename_imageurl_to_imagepath_in_userbankslips_table.php b/database/migrations/2018_06_21_062637_rename_imageurl_to_imagepath_in_userbankslips_table.php new file mode 100644 index 00000000..e29ffc4d --- /dev/null +++ b/database/migrations/2018_06_21_062637_rename_imageurl_to_imagepath_in_userbankslips_table.php @@ -0,0 +1,31 @@ +renameColumn('bankslip_url', 'bankslip_path'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/database/migrations/2018_06_21_062700_rename_imageurl_to_imagepath_in_purchaseorders_table.php b/database/migrations/2018_06_21_062700_rename_imageurl_to_imagepath_in_purchaseorders_table.php new file mode 100644 index 00000000..cc1ea4df --- /dev/null +++ b/database/migrations/2018_06_21_062700_rename_imageurl_to_imagepath_in_purchaseorders_table.php @@ -0,0 +1,31 @@ +renameColumn('image_url', 'image_path'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/database/migrations/2018_06_21_072354_remove_amountcolumn_from_po_table.php b/database/migrations/2018_06_21_072354_remove_amountcolumn_from_po_table.php new file mode 100644 index 00000000..d350c3c1 --- /dev/null +++ b/database/migrations/2018_06_21_072354_remove_amountcolumn_from_po_table.php @@ -0,0 +1,34 @@ +dropColumn('amount'); + // $table->dropColumn('reject_reason'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('purchase_orders', function (Blueprint $table) { + $table->double('amount'); + // $table->dropColumn('reject_reason'); + }); + } +} diff --git a/database/migrations/2018_06_22_042127_add_adminstatus_to_booking_table.php b/database/migrations/2018_06_22_042127_add_adminstatus_to_booking_table.php new file mode 100644 index 00000000..4e7e93a9 --- /dev/null +++ b/database/migrations/2018_06_22_042127_add_adminstatus_to_booking_table.php @@ -0,0 +1,33 @@ +integer('admin_status')->default(1); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('bookings', function (Blueprint $table) { + $table->dropColumn('admin_status'); + // $table->dropColumn('reject_reason'); + }); + } +} diff --git a/database/migrations/2018_06_22_042911_change_adminstatus_default_booking_table.php b/database/migrations/2018_06_22_042911_change_adminstatus_default_booking_table.php new file mode 100644 index 00000000..5047f990 --- /dev/null +++ b/database/migrations/2018_06_22_042911_change_adminstatus_default_booking_table.php @@ -0,0 +1,29 @@ +integer('admin_status')->default(0)->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + } +} diff --git a/database/migrations/2018_06_25_075341_change_adminstatus_default_to1_on_booking_table.php b/database/migrations/2018_06_25_075341_change_adminstatus_default_to1_on_booking_table.php new file mode 100644 index 00000000..ef50d656 --- /dev/null +++ b/database/migrations/2018_06_25_075341_change_adminstatus_default_to1_on_booking_table.php @@ -0,0 +1,30 @@ +integer('admin_status')->default(1)->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/database/migrations/2018_06_25_101043_add_time_limit_setting_credit_table.php b/database/migrations/2018_06_25_101043_add_time_limit_setting_credit_table.php new file mode 100644 index 00000000..4e0aefef --- /dev/null +++ b/database/migrations/2018_06_25_101043_add_time_limit_setting_credit_table.php @@ -0,0 +1,32 @@ +integer('time_limit'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('setting_credits', function (Blueprint $table) { + // $table->dropColumn('time_limit'); + }); + } +} \ No newline at end of file diff --git a/database/migrations/2018_06_26_035802_add_eta_user_bank_slip_table.php b/database/migrations/2018_06_26_035802_add_eta_user_bank_slip_table.php new file mode 100644 index 00000000..acd53a08 --- /dev/null +++ b/database/migrations/2018_06_26_035802_add_eta_user_bank_slip_table.php @@ -0,0 +1,34 @@ +integer('estimated_arrival_time'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + if (Schema::hasColumn('user_bank_slips', 'estimated_arrival_time')) { + Schema::table('user_bank_slips', function (Blueprint $table) { + // $table->dropColumn('estimated_arrival_time'); + }); + } + } +} diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 098d40f3..bcf98f78 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -16,5 +16,6 @@ class DatabaseSeeder extends Seeder $this->call(UserRoleSeeder::class); $this->call(RateTableSeeder::class); $this->call(BookTableSeeder::class); + $this->call(SettingCreditSeeder::class); } } diff --git a/database/seeds/SettingCreditSeeder.php b/database/seeds/SettingCreditSeeder.php new file mode 100644 index 00000000..0087203e --- /dev/null +++ b/database/seeds/SettingCreditSeeder.php @@ -0,0 +1,21 @@ +insert([ + 'rmb_credit_limit' => '4000', + 'usd_credit_limit' => '5000', + 'time_limit' => '600' + ]); + } +} diff --git a/resources/assets/js/components/AdminProgressTrack.vue b/resources/assets/js/components/AdminProgressTrack.vue new file mode 100644 index 00000000..dfae9647 --- /dev/null +++ b/resources/assets/js/components/AdminProgressTrack.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/resources/assets/js/components/LocaleDropdown.vue b/resources/assets/js/components/LocaleDropdown.vue index b3d67fd4..f4b0d5c3 100644 --- a/resources/assets/js/components/LocaleDropdown.vue +++ b/resources/assets/js/components/LocaleDropdown.vue @@ -1,16 +1,24 @@ \ No newline at end of file + diff --git a/resources/assets/js/middleware/admin.js b/resources/assets/js/middleware/admin.js index 276ef3de..f2ccc855 100644 --- a/resources/assets/js/middleware/admin.js +++ b/resources/assets/js/middleware/admin.js @@ -1,7 +1,8 @@ import store from '~/store' export default (to, from, next) => { - if (store.getters['auth/user'].role !== 'admin') { + console.log(store.getters['auth/role']) + if (store.getters['auth/role'] !== 'admin') { next({ name: 'home' }) } else { next() diff --git a/resources/assets/js/middleware/auth.js b/resources/assets/js/middleware/auth.js index 138da317..00805252 100644 --- a/resources/assets/js/middleware/auth.js +++ b/resources/assets/js/middleware/auth.js @@ -3,7 +3,7 @@ import store from '~/store' export default async (to, from, next) => { if (!store.getters['auth/check']) { next({ name: 'login' }) - } else if (store.getters['auth/user'].role == 'admin') { + } else if (store.getters['auth/role'] === 'admin') { next({ name: 'admin.home' }) } else { next() diff --git a/resources/assets/js/pages/admin/booking/supplierBooking.vue b/resources/assets/js/pages/admin/booking/supplierBooking.vue new file mode 100644 index 00000000..37196cb3 --- /dev/null +++ b/resources/assets/js/pages/admin/booking/supplierBooking.vue @@ -0,0 +1,74 @@ + + + diff --git a/resources/assets/js/pages/admin/booking/supplierReport.vue b/resources/assets/js/pages/admin/booking/supplierReport.vue new file mode 100644 index 00000000..37196cb3 --- /dev/null +++ b/resources/assets/js/pages/admin/booking/supplierReport.vue @@ -0,0 +1,74 @@ + + + diff --git a/resources/assets/js/pages/admin/booking/uploadChinaBankslip.vue b/resources/assets/js/pages/admin/booking/uploadChinaBankslip.vue new file mode 100644 index 00000000..37196cb3 --- /dev/null +++ b/resources/assets/js/pages/admin/booking/uploadChinaBankslip.vue @@ -0,0 +1,74 @@ + + + diff --git a/resources/assets/js/pages/admin/booking/uploadInvoice.vue b/resources/assets/js/pages/admin/booking/uploadInvoice.vue new file mode 100644 index 00000000..37196cb3 --- /dev/null +++ b/resources/assets/js/pages/admin/booking/uploadInvoice.vue @@ -0,0 +1,74 @@ + + + diff --git a/resources/assets/js/pages/admin/booking/verification.vue b/resources/assets/js/pages/admin/booking/verification.vue new file mode 100644 index 00000000..20bac84b --- /dev/null +++ b/resources/assets/js/pages/admin/booking/verification.vue @@ -0,0 +1,280 @@ + + + \ No newline at end of file diff --git a/resources/assets/js/pages/admin/home.vue b/resources/assets/js/pages/admin/home.vue index f5f67c94..7fe842c0 100644 --- a/resources/assets/js/pages/admin/home.vue +++ b/resources/assets/js/pages/admin/home.vue @@ -1,15 +1,138 @@ diff --git a/resources/assets/js/pages/admin/index.vue b/resources/assets/js/pages/admin/index.vue index c60c3751..67871a7c 100644 --- a/resources/assets/js/pages/admin/index.vue +++ b/resources/assets/js/pages/admin/index.vue @@ -2,7 +2,7 @@