diff --git a/.env-example b/.env-example index 4271cefe..5c17b459 100644 --- a/.env-example +++ b/.env-example @@ -13,11 +13,6 @@ DB_DATABASE=default DB_USERNAME=default DB_PASSWORD=secret -BROADCAST_DRIVER=log -CACHE_DRIVER=file -SESSION_DRIVER=file -SESSION_LIFETIME=120 -QUEUE_DRIVER=sync REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null diff --git a/app/Events/RateUpdated.php b/app/Events/RateUpdated.php new file mode 100644 index 00000000..58f49817 --- /dev/null +++ b/app/Events/RateUpdated.php @@ -0,0 +1,47 @@ +rate = $rate; + } + + /** + * Get the channels the event should broadcast on. + * + * @return \Illuminate\Broadcasting\Channel|array + */ + public function broadcastOn() + { + return new Channel('rate-updated'); + //return new PrivateChannel('rate-updated'); + } + + public function broadcastWith() { + return [ + 'rate' => $this->rate, + ]; + } + +} diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index 89cf1dc8..d1bb15ac 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -25,7 +25,13 @@ class BookingController extends Controller $user = Auth::user(); $bookings = Booking::select('user_id', 'id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status') ->where('user_id', Auth::user()->id) - ->where('status', '<', '7') + ->where(function ($query) { + $query->where('status', '=', '6') + ->orwhere('status', '=', '4') + ->orwhere('status', '=', '3') + ->orwhere('status', '=', '2') + ->orwhere('status', '=', '1'); + }) ->orderby('updated_at','desc') ->paginate(10); @@ -88,7 +94,8 @@ class BookingController extends Controller $user = Auth::user(); $bookings = Booking::select('user_id', 'id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status') ->where('user_id', Auth::user()->id) - ->where('status', '=', '7') + ->where ( "status" ,'=','6') + ->orWhere( "status" ,'=','5') ->orderby('updated_at','desc') ->paginate(10); @@ -154,9 +161,13 @@ class BookingController extends Controller public function adminIndex(){ $user = Auth::user(); $bookings = Booking::select('user_id', 'id', 'created_at', 'admin_status', 'rate', 'term', 'amount', 'bia', 'verification_status') - ->where('status', '<', '7') - ->orderby('updated_at','desc') - ->paginate(10); + ->where('admin_status', '=', '5') + ->orwhere('admin_status', '=', '4') + ->orwhere('admin_status', '=', '3') + ->orwhere('admin_status', '=', '2') + ->orwhere('admin_status', '=', '1') + ->orderby('updated_at','desc') + ->paginate(10); // reformat to fit frontend structure foreach ($bookings as $booking) { @@ -221,60 +232,74 @@ class BookingController extends Controller } public function adminBookComplete(){ - $user = Auth::user(); - $bookings = Booking::select('user_id', 'id', 'created_at', 'status', 'rate', 'term', 'amount', 'bia', 'verification_status') - ->where('admin_status', '=', '7') - ->orderby('updated_at','desc') - ->paginate(10); + $user = Auth::user(); + $bookings = Booking::select('user_id', 'id', 'created_at', 'admin_status', 'rate', 'term', 'amount', 'bia', 'verification_status') + + ->where('admin_status', '=', '6') + ->orwhere('admin_status', '=', '7') + ->orderby('updated_at','desc') + ->paginate(10); - // 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; + // 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 : 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 ."/7)"; - 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; - case 7: - $status_desc = "Order Completed"; - break; - default: - $status_desc = ""; - } - $booking->status_desc = $status_desc; - $booking->marking = $booking->user->marking; - } - - return $bookings; + // TODO : transfer_amount change name to bia + $booking->transfer_amount = $booking->bia; + + $term = $booking->term; + if ($booking->term == "x2_cash" || $booking->term == "x2_cheque" || $booking->term == "x2_ba"){ + $booking->track_status = "(". $booking->admin_status ."/6)"; + } + else{ + $booking->track_status = "(". $booking->admin_status ."/7)"; + } + + switch ($booking->admin_status) { + case 1: + $status_desc = "Waiting customer upload bank slip"; + break; + case 2: + $status_desc = "Verify user bank slip"; + break; + case 3: + $status_desc = "Generate supplier booking report"; + break; + case 4: + $status_desc = "Supplier booking report. Please confirm with your booking."; + break; + case 5: + $status_desc = "Please, upload China Bankslip"; + break; + case 6: + $status_desc = "Waiting customer to upload purchase order"; + if ($booking->term == "x2_cash" || $booking->term == "x2_cheque" || $booking->term == "x2_ba"){ + $status_desc = "Order Completed"; + } + break; + case 7: + $status_desc = "Customer has uploaded purchase order, please upload invoice"; + break; + case 8: + $status_desc = "Booking Completed"; + break; + default: + $status_desc = ""; + } + $booking->marking = $booking->user->marking; + $booking->status_desc = $status_desc; + } + return $bookings; } public function show($id) { @@ -429,7 +454,8 @@ class BookingController extends Controller if ($amount >= 10000 && ($term == 'x2_cash' || $term == 'x2_cheque' || $term == 'x2_ba')) { $svcharge = 0; } else { - $svcharge = 20.00; + //$svcharge = 20.00; + $svcharge = 0; // UPDATE ON : 15-8-2018 from PM } $subtotal = round(($amount + $svcharge) / $rate, 2); @@ -598,16 +624,9 @@ class BookingController extends Controller $booking->admin_status = 2; $booking->save(); - // Add notification message to admin - $adminNotification = new Notification; - $adminNotification->detail = "A bankslip is uploaded for booking " . $booking->id; - $adminNotification->link = "/booking/" . $booking->id . "/verification"; - $adminNotification->user_id = User::withRole('admin')->first()->id; - $adminNotification->save(); - $user_bankslip->transfer_amount = $request->input('transfer_amount'); $user_bankslip->save(); - return response()->json($adminNotification,200); + return response()->json(["success"=>true],200); } public function uploadPurchaseOrder(Request $request, $id) @@ -756,7 +775,8 @@ class BookingController extends Controller if ($amount >= 10000 && ($term == 'x2_cash' || $term == 'x2_cheque' || $term == 'x2_ba')) { $svcharge = 0; } else { - $svcharge = 20.00; + //$svcharge = 20.00; + $svcharge = 0; // UPDATE ON : 15-8-2018 from PM } $subtotal = round(($amount + $svcharge) / $rate,2); @@ -828,21 +848,13 @@ class BookingController extends Controller $booking->status = 4; if($booking->term !== "x1_ba" || $booking->term !== "x2_cheque"){ $booking->admin_status = 3; - // Add notification message to user - $userNotification = new Notification; - $userNotification->detail = "Your bankslip for booking " . $booking->id . " is approved."; - $userNotification->link = "/booking/" . $booking->id . "/transfer"; - $userNotification->user_id = $booking->user_id; - $userNotification->save(); + // TODO : Add notification message to user + } else{ $booking->admin_status = 5; - // Add notification message to user - $userNotification = new Notification; - $userNotification->detail = "Your bankslip for booking " . $booking->id . " is approved."; - $userNotification->link = "/booking/" . $booking->id . "/supplier"; - $userNotification->user_id = $booking->user_id; - $userNotification->save(); + // TODO : Add notification message to user + } $booking->save(); @@ -962,12 +974,6 @@ class BookingController extends Controller $booking->admin_status = 6; // upload invoice $booking->save(); - $adminNotification = new Notification; - $adminNotification->detail = "Purchase Order for booking " . $booking->id . " is uploaded."; - $adminNotification->link = "/booking/" . $booking->id . "/upload-invoice"; - $adminNotification->user_id = User::withRole('admin')->first()->id; - $adminNotification->save(); - return response()->json($purchase_order,200); } @@ -985,11 +991,6 @@ class BookingController extends Controller $booking->admin_status = 7; // completed if($booking->save()){ - $adminNotification = new Notification; - $adminNotification->detail = "Invoice for booking " . $booking->id . " is uploaded."; - $adminNotification->link = "/booking/" . $booking->id . "/complete"; - $adminNotification->user_id = $booking->user_id; - $adminNotification->save(); return response()->json(['message'=>"Success"],200); } } diff --git a/app/Http/Controllers/ChinaBankSlipController.php b/app/Http/Controllers/ChinaBankSlipController.php index 0ed406ed..e4cc5742 100644 --- a/app/Http/Controllers/ChinaBankSlipController.php +++ b/app/Http/Controllers/ChinaBankSlipController.php @@ -5,7 +5,6 @@ namespace App\Http\Controllers; use App\ChinaBankSlip; use App\Booking; use App\User; -use App\Notification; use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; use Validator; @@ -82,13 +81,6 @@ class ChinaBankSlipController extends Controller $booking->admin_status = 6; $booking->save(); - $userNotification = new Notification; - $userNotification->detail = "Your china bankslip for booking " . $booking->id . " is uploaded."; - $userNotification->link = "/booking/" . $booking->id . "/upload-po"; - $userNotification->user_id = $booking->user_id; - $userNotification->save(); - - return response()->json(["message"=> "Success"],200); } diff --git a/app/Observers/RateObserver.php b/app/Observers/RateObserver.php new file mode 100644 index 00000000..14e55867 --- /dev/null +++ b/app/Observers/RateObserver.php @@ -0,0 +1,21 @@ + ["auth:api"]]); require base_path('routes/channels.php'); } diff --git a/caddy/Caddyfile b/caddy/Caddyfile index eaf1b056..e4f1b0d1 100644 --- a/caddy/Caddyfile +++ b/caddy/Caddyfile @@ -1,5 +1,4 @@ https://exchange-staging.izyim.com { - proxy /phpmyadmin 127.0.0.1:8090 root /var/www/public fastcgi / 127.0.0.1:9000 php { diff --git a/composer.json b/composer.json index 3ae12a1a..97b020e5 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ "laravel/socialite": "^3.0", "laravel/tinker": "~1.0", "laravelcollective/html": "^5.6", + "pusher/pusher-php-server": "~3.0", "tymon/jwt-auth": "^1.0.0-rc.2", "zizaco/entrust": "dev-master" }, diff --git a/config/app.php b/config/app.php index 3d40b81c..1c1d20d4 100644 --- a/config/app.php +++ b/config/app.php @@ -165,7 +165,7 @@ return [ */ App\Providers\AppServiceProvider::class, App\Providers\AuthServiceProvider::class, - // App\Providers\BroadcastServiceProvider::class, + App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, diff --git a/config/broadcasting.php b/config/broadcasting.php index 5eecd2b2..3ca45eaa 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -36,7 +36,8 @@ return [ 'secret' => env('PUSHER_APP_SECRET'), 'app_id' => env('PUSHER_APP_ID'), 'options' => [ - // + 'cluster' => env('PUSHER_APP_CLUSTER'), + 'encrypted' => true, ], ], diff --git a/database/migrations/2018_08_15_154652_remove_foreight_from_setting_active_banks_table.php b/database/migrations/2018_08_15_154652_remove_foreight_from_setting_active_banks_table.php new file mode 100644 index 00000000..d6ffe132 --- /dev/null +++ b/database/migrations/2018_08_15_154652_remove_foreight_from_setting_active_banks_table.php @@ -0,0 +1,32 @@ +dropForeign('setting_active_banks_beneficiary_id_foreign'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('setting_active_banks', function (Blueprint $table) { + // + }); + } +} diff --git a/database/migrations/2018_08_16_101635_drop_notifications_table.php b/database/migrations/2018_08_16_101635_drop_notifications_table.php new file mode 100644 index 00000000..d0b458c2 --- /dev/null +++ b/database/migrations/2018_08_16_101635_drop_notifications_table.php @@ -0,0 +1,28 @@ +uuid('id')->primary(); + $table->string('type'); + $table->morphs('notifiable'); + $table->text('data'); + $table->timestamp('read_at')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('notifications'); + } +} diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index e0ba98e9..ebc04e05 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -28,7 +28,6 @@ class DatabaseSeeder extends Seeder $this->call(SettingActiveBankSeeder::class); $this->call(SettingTaxRateSeeder::class); $this->call(SettingBillingChargeSeeder::class); - $this->call(NotificationSeeder::class); DB::statement('SET FOREIGN_KEY_CHECKS=1;'); } } diff --git a/database/seeds/NotificationSeeder.php b/database/seeds/NotificationSeeder.php deleted file mode 100644 index 316b11ad..00000000 --- a/database/seeds/NotificationSeeder.php +++ /dev/null @@ -1,35 +0,0 @@ -first(); - $admin = User::where("email", "admin@example.com")->first(); - - DB::table('notifications')->insert([ - 'detail' => 'This is an user seeder notification', - 'user_id' => $user->id, - 'link' => '/', - 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), - 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'), - ]); - - DB::table('notifications')->insert([ - 'detail' => 'This is an admin seeder notification', - 'user_id' => $admin->id, - 'link' => '/', - 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), - 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'), - ]); - } -} diff --git a/package.json b/package.json index 33534d51..1f7f1eff 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,10 @@ "element-ui": "^2.4.4", "jquery": "^3.3.1", "js-cookie": "^2.2.0", + "laravel-echo": "^1.4.0", "npm": "^6.0.1", "popper.js": "^1.14.1", + "pusher-js": "^4.3.0", "sweetalert2": "^7.15.1", "vform": "^1.0.0", "vue": "^2.5.16", diff --git a/resources/assets/js/components/LocaleDropdown.vue b/resources/assets/js/components/LocaleDropdown.vue index 7b490660..0e411ddf 100644 --- a/resources/assets/js/components/LocaleDropdown.vue +++ b/resources/assets/js/components/LocaleDropdown.vue @@ -210,6 +210,7 @@ export default { }) }, + } } diff --git a/resources/assets/js/components/Navbar.vue b/resources/assets/js/components/Navbar.vue index 7f32c3c2..46544951 100644 --- a/resources/assets/js/components/Navbar.vue +++ b/resources/assets/js/components/Navbar.vue @@ -6,7 +6,7 @@