From 39d564615509a735d4427d9f6139f1163942c5b7 Mon Sep 17 00:00:00 2001 From: weiweitoo Date: Thu, 12 Jul 2018 00:52:46 +0800 Subject: [PATCH 1/8] dynamically show malaysia bank acc for booking step --- .../SettingBeneficiaryController.php | 12 +- app/SettingBeneficiaries.php | 10 + app/SettingBeneficiary.php | 10 - app/SettingMalaysiaBank.php | 2 +- .../factories/SettingBeneficiaryFactory.php | 2 +- ...pdate_accno_to_id_setting_active_table.php | 51 ++ database/seeds/SettingActiveBankSeeder.php | 12 +- .../js/pages/booking/uploadUserBankSlip.vue | 499 ++++++++++-------- routes/api.php | 10 +- 9 files changed, 360 insertions(+), 248 deletions(-) create mode 100644 app/SettingBeneficiaries.php delete mode 100644 app/SettingBeneficiary.php create mode 100644 database/migrations/2018_07_11_150423_update_accno_to_id_setting_active_table.php diff --git a/app/Http/Controllers/SettingBeneficiaryController.php b/app/Http/Controllers/SettingBeneficiaryController.php index fdec75f7..5b43d86b 100644 --- a/app/Http/Controllers/SettingBeneficiaryController.php +++ b/app/Http/Controllers/SettingBeneficiaryController.php @@ -2,36 +2,36 @@ namespace App\Http\Controllers; -use App\SettingBeneficiary; +use App\SettingBeneficiaries; use Illuminate\Http\Request; class SettingBeneficiaryController extends Controller { public function index() { - return SettingBeneficiary::all(); + return SettingBeneficiaries::all(); } - public function show(SettingBeneficiary $beneficiary) + public function show(SettingBeneficiaries $beneficiary) { return $beneficiary; } public function store(Request $request) { - $beneficiary = SettingBeneficiary::create($request->all()); + $beneficiary = SettingBeneficiaries::create($request->all()); return response()->json($beneficiary, 201); } - public function update(Request $request, SettingBeneficiary $beneficiary) + public function update(Request $request, SettingBeneficiaries $beneficiary) { $beneficiary->update($request->all()); return response()->json($beneficiary, 200); } - public function delete(SettingBeneficiary $beneficiary) + public function delete(SettingBeneficiaries $beneficiary) { $beneficiary->delete(); diff --git a/app/SettingBeneficiaries.php b/app/SettingBeneficiaries.php new file mode 100644 index 00000000..a37325fd --- /dev/null +++ b/app/SettingBeneficiaries.php @@ -0,0 +1,10 @@ +define(App\SettingBeneficiary::class, function (Faker $faker) { +$factory->define(App\SettingBeneficiaries::class, function (Faker $faker) { return [ // ]; diff --git a/database/migrations/2018_07_11_150423_update_accno_to_id_setting_active_table.php b/database/migrations/2018_07_11_150423_update_accno_to_id_setting_active_table.php new file mode 100644 index 00000000..148134b9 --- /dev/null +++ b/database/migrations/2018_07_11_150423_update_accno_to_id_setting_active_table.php @@ -0,0 +1,51 @@ +dropForeign('setting_active_banks_x1_bank_id_foreign'); + $table->dropForeign('setting_active_banks_x2_bank_id_foreign'); + $table->dropForeign('setting_active_banks_beneficiary_id_foreign'); + $table->dropColumn('x1_bank_id'); + $table->dropColumn('x2_bank_id'); + $table->dropColumn('beneficiary_id'); + }); + + Schema::table('setting_active_banks', function(Blueprint $table) + { + $table->unsignedInteger('x1_bank_id')->unique(); + $table->foreign('x1_bank_id') + ->references('id')->on('setting_malaysia_banks'); + + $table->unsignedInteger('x2_bank_id')->unique(); + $table->foreign('x2_bank_id') + ->references('id')->on('setting_malaysia_banks'); + + $table->unsignedInteger('beneficiary_id')->unique(); + $table->foreign('beneficiary_id') + ->references('id')->on('setting_beneficiaries'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/database/seeds/SettingActiveBankSeeder.php b/database/seeds/SettingActiveBankSeeder.php index feed9792..40560300 100644 --- a/database/seeds/SettingActiveBankSeeder.php +++ b/database/seeds/SettingActiveBankSeeder.php @@ -1,6 +1,8 @@ first(); + $bankx2 = SettingMalaysiaBank::where('acc_no', "=",'malaysiaacc02')->first(); + $chinabank = SettingBeneficiaries::where('acc_no', "=" ,'123456789')->first(); + DB::table('setting_active_banks')->truncate(); DB::table('setting_active_banks')->insert([ - 'x1_bank_id' => 'malaysiaacc01', - 'x2_bank_id' => 'malaysiaacc02', - 'beneficiary_id' => '123456789' + 'x1_bank_id' => $bankx1->id, + 'x2_bank_id' => $bankx2->id, + 'beneficiary_id' => $chinabank->id ]); } } diff --git a/resources/assets/js/pages/booking/uploadUserBankSlip.vue b/resources/assets/js/pages/booking/uploadUserBankSlip.vue index 5071cf96..705131cc 100644 --- a/resources/assets/js/pages/booking/uploadUserBankSlip.vue +++ b/resources/assets/js/pages/booking/uploadUserBankSlip.vue @@ -1,103 +1,103 @@ diff --git a/routes/api.php b/routes/api.php index ef3d2af0..b4f689ee 100644 --- a/routes/api.php +++ b/routes/api.php @@ -46,6 +46,10 @@ Route::group(['middleware' => 'auth:api'], function () { Route::get('user', 'UserController@show'); Route::patch('settings/profile', 'Settings\ProfileController@update'); Route::patch('settings/password', 'Settings\PasswordController@update'); + + // for both user and admin + Route::get('setting-active-bank', 'SettingActiveBankController@index'); + Route::get('setting-malaysia-bank/{malaysiaBank}', 'SettingMalaysiaBankController@show'); }); @@ -70,7 +74,6 @@ Route::group(['middleware' => ['role:admin']], function() { Route::get('setting-credit', 'SettingCreditController@index'); Route::put('setting-credit', 'SettingCreditController@update'); - Route::get('setting-active-bank', 'SettingActiveBankController@index'); Route::put('setting-active-bank', 'SettingActiveBankController@update'); Route::get('setting-supplier', 'SettingSupplierController@index'); @@ -86,7 +89,6 @@ Route::group(['middleware' => ['role:admin']], function() { Route::delete('setting-beneficiary/{beneficiary}', 'SettingBeneficiaryController@delete'); Route::get('setting-malaysia-bank', 'SettingMalaysiaBankController@index'); - Route::get('setting-malaysia-bank/{malaysiaBank}', 'SettingMalaysiaBankController@show'); Route::post('setting-malaysia-bank', 'SettingMalaysiaBankController@store'); Route::put('setting-malaysia-bank/{malaysiaBank}', 'SettingMalaysiaBankController@update'); Route::delete('setting-malaysia-bank/{malaysiaBank}', 'SettingMalaysiaBankController@delete'); @@ -108,5 +110,9 @@ Route::group(['middleware' => ['role:admin']], function() { Route::get('booking/{id}/po', 'BookingController@showPurchaseOrder'); Route::post('booking/{id}/upload-invoice', 'BookingController@uploadInvoice'); Route::post('booking/{id}/confirm-invoice', 'BookingController@confirmInvoice'); + + // for both user and admin + // Route::get('setting-active-bank', 'SettingActiveBankController@index'); + // Route::get('setting-malaysia-bank/{malaysiaBank}', 'SettingMalaysiaBankController@show'); }); \ No newline at end of file From 1535b54f04536aeb9f3add8e1c0bd831778ab696 Mon Sep 17 00:00:00 2001 From: weiweitoo Date: Thu, 12 Jul 2018 01:09:49 +0800 Subject: [PATCH 2/8] revert back changes during debug --- resources/assets/js/pages/booking/uploadUserBankSlip.vue | 6 +++--- routes/api.php | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/resources/assets/js/pages/booking/uploadUserBankSlip.vue b/resources/assets/js/pages/booking/uploadUserBankSlip.vue index 705131cc..593af081 100644 --- a/resources/assets/js/pages/booking/uploadUserBankSlip.vue +++ b/resources/assets/js/pages/booking/uploadUserBankSlip.vue @@ -257,7 +257,7 @@ export default { this.start = true; }, updateBankDetail(){ - axios.get('/api/setting-active-bank') + axios.get('/api/active-bank') .then((response) => { this.active_bank_setting = response.data; console.log(this.active_bank_setting.x1_bank_id); @@ -276,10 +276,10 @@ export default { getBankDetailWithTerm(){ var url = ''; if(this.booking.term === 'x1_cash' || this.booking.term === 'x1_cheque' ||this.booking.term === 'x1_ba'){ - url = '/api/setting-malaysia-bank/' + this.active_bank_setting.x1_bank_id; + url = '/api/malaysia-bank/' + this.active_bank_setting.x1_bank_id; } else if(this.booking.term === 'x2_cash' || this.booking.term === 'x2_cheque' ||this.booking.term === 'x2_ba'){ - url = '/api/setting-malaysia-bank/' + this.active_bank_setting.x2_bank_id; + url = '/api/malaysia-bank/' + this.active_bank_setting.x2_bank_id; } axios.get(url) diff --git a/routes/api.php b/routes/api.php index b4f689ee..75d54e38 100644 --- a/routes/api.php +++ b/routes/api.php @@ -48,8 +48,8 @@ Route::group(['middleware' => 'auth:api'], function () { Route::patch('settings/password', 'Settings\PasswordController@update'); // for both user and admin - Route::get('setting-active-bank', 'SettingActiveBankController@index'); - Route::get('setting-malaysia-bank/{malaysiaBank}', 'SettingMalaysiaBankController@show'); + Route::get('active-bank', 'SettingActiveBankController@index'); + Route::get('malaysia-bank/{malaysiaBank}', 'SettingMalaysiaBankController@show'); }); @@ -112,7 +112,7 @@ Route::group(['middleware' => ['role:admin']], function() { Route::post('booking/{id}/confirm-invoice', 'BookingController@confirmInvoice'); // for both user and admin - // Route::get('setting-active-bank', 'SettingActiveBankController@index'); - // Route::get('setting-malaysia-bank/{malaysiaBank}', 'SettingMalaysiaBankController@show'); + Route::get('setting-active-bank', 'SettingActiveBankController@index'); + Route::get('setting-malaysia-bank/{malaysiaBank}', 'SettingMalaysiaBankController@show'); }); \ No newline at end of file From ad5f8df8af952d4caf9ba530407e2e0ededec73c Mon Sep 17 00:00:00 2001 From: weiweitoo Date: Thu, 12 Jul 2018 01:12:26 +0800 Subject: [PATCH 3/8] revert back changes during debug --- app/SettingBeneficiaries.php | 2 +- app/SettingMalaysiaBank.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/SettingBeneficiaries.php b/app/SettingBeneficiaries.php index a37325fd..26c09e31 100644 --- a/app/SettingBeneficiaries.php +++ b/app/SettingBeneficiaries.php @@ -6,5 +6,5 @@ use Illuminate\Database\Eloquent\Model; class SettingBeneficiaries extends Model { - protected $fillable = ['id','company_name','bank_name','acc_no','bank_address','swift','cnap','bank_branch']; + protected $fillable = ['company_name','bank_name','acc_no','bank_address','swift','cnap','bank_branch']; } diff --git a/app/SettingMalaysiaBank.php b/app/SettingMalaysiaBank.php index a8153451..ccd71e62 100644 --- a/app/SettingMalaysiaBank.php +++ b/app/SettingMalaysiaBank.php @@ -6,5 +6,5 @@ use Illuminate\Database\Eloquent\Model; class SettingMalaysiaBank extends Model { - protected $fillable = ['id','company_name','bank_name','acc_no','bank_address','swift','cnap','bank_branch']; + protected $fillable = ['company_name','bank_name','acc_no','bank_address','swift','cnap','bank_branch']; } From 19ea22141e287706d91a38341f583d35ff7ac763 Mon Sep 17 00:00:00 2001 From: weiweitoo Date: Thu, 12 Jul 2018 22:42:16 +0800 Subject: [PATCH 4/8] dynamically show chinabank in supplier report --- .../js/pages/admin/booking/supplierReport.vue | 381 ++++++++++-------- routes/api.php | 2 - 2 files changed, 211 insertions(+), 172 deletions(-) diff --git a/resources/assets/js/pages/admin/booking/supplierReport.vue b/resources/assets/js/pages/admin/booking/supplierReport.vue index 41400042..ce6dca4b 100644 --- a/resources/assets/js/pages/admin/booking/supplierReport.vue +++ b/resources/assets/js/pages/admin/booking/supplierReport.vue @@ -270,13 +270,23 @@ }, supplier_booking:{ }, + active_bank_setting: { + x1_bank_id: null, + x2_bank_id: null, + beneficiary_id: null + }, + beneficiaryDetail:{ + company_name: '奕继椿', + bank_name: '民生银行 深川红荔支行', + acc_no: '123456789', + }, supplier: null, supplier_options: null, exampleContent: "This is TEXT" - } }, beforeCreate() { + const loading = this.$loading({ lock: true, text: 'Please wait..', @@ -297,8 +307,7 @@ }) }) - axios - .get('/api/supplier-booking/' + this.$route.params.id) + axios.get('/api/supplier-booking/' + this.$route.params.id) .then((response) => { loading.close() this.supplier_booking = response.data @@ -310,18 +319,45 @@ }) }) - - + axios.get('/api/active-bank') + .then((response) => { + axios.get('/api/setting-beneficiary/' + response.data.beneficiary_id) + .then((response) => { + this.supplier_booking.china_bank_name = response.data.bank_name; + this.supplier_booking.china_company_name = response.data.company_name; + this.supplier_booking.china_acc_no = response.data.acc_no; + console.log(this.supplier_booking); + }) + .catch((error) => { + console.log(error); + this.$message({ + showClose: true, + message: 'Fetch data fail', + type: 'error', + duration: 10000 + }); + }); + }) + .catch((error) => { + console.log(error); + this.$message({ + showClose: true, + message: 'Fetch data fail', + type: 'error', + duration: 10000 + }); + }); + }, methods: { downloadReport(){ let canvas = document.getElementById('myCanvas') - var dataString = canvas.toDataURL("image/png"); - console.log(dataString) - var link = document.createElement("a"); - link.download = 'image'; - link.href = dataString; - link.click(); + var dataString = canvas.toDataURL("image/png"); + console.log(dataString) + var link = document.createElement("a"); + link.download = 'image'; + link.href = dataString; + link.click(); }, goToSupplierBooking(){ this.$router.push({ @@ -330,7 +366,7 @@ }) }, completeReport() { - // TODO : send request to change status + // TODO : send request to change status this.loading_btn = true axios .post('/api/booking/' + this.$route.params.id + '/confirm-supplier') @@ -362,174 +398,179 @@ id: this.$route.params.id } }) - } - + }, }, directives: { insertMessage: function (canvasElement, binding) { - ////////////////// variable ////////////////////////// - var canvasWidth = 450; - var rowHeight = [20, 40, 60, 80, 100, 120, 140, 170, 190, 210, 230, 250, 270, 290, 310, 330, 350, 390, 410, - 470, 490, 510, 610, 630 - ] - const canvasHeight = rowHeight[rowHeight.length - 1]; + setTimeout(function (canvasElement, binding) { + ////////////////// variable ////////////////////////// + var canvasWidth = 450; + var rowHeight = [20, 40, 60, 80, 100, 120, 140, 170, 190, 210, 230, 250, 270, 290, 310, 330, 350, 390, 410, + 470, 490, 510, 610, 630 + ] + const canvasHeight = rowHeight[rowHeight.length - 1]; - var column1X = 220; - var column2X = 320; - var column3X = 420; + var column1X = 220; + var column2X = 320; + var column3X = 420; - ///////////////////Canvast Init//////////////////// - var canvas = document.getElementById("myCanvas"); - canvas.width = canvasWidth; - canvas.height = canvasHeight; - // Get canvas context - var ctx = canvasElement.getContext("2d"); - // Clear the canvas - ctx.clearRect(0, 0, 300, 150); + ///////////////////Canvast Init//////////////////// + var canvas = document.getElementById("myCanvas"); + canvas.width = canvasWidth; + canvas.height = canvasHeight; + // Get canvas context + var ctx = canvasElement.getContext("2d"); + // Clear the canvas + ctx.clearRect(0, 0, 300, 150); - ctx.fillStyle = "#FFFFFF"; - ctx.fillRect(0, 0, canvasWidth, rowHeight[0]); - for (var i = 1; i < rowHeight.length; i++) { - if (i % 2 == 1) - ctx.fillStyle = "#A9D08E"; - else ctx.fillStyle = "#FFFFFF"; - ctx.fillRect(0, rowHeight[i - 1], canvasWidth, rowHeight[i]); - } - ///////////// fillup with text//////////////// - //// config canvas - ctx.fillStyle = "#000000"; - ctx.font = "13px Arial"; - ctx.textAlign = "right"; - //// Row 1 - ctx.fillText("Payment Voucher :", column1X, rowHeight[1] - 5); - ctx.fillText(binding.value.id, column3X, rowHeight[1] - 5); - //// Row 2 - ctx.fillText("Date :", column1X, rowHeight[2] - 5); - ctx.fillText(binding.value.date, column3X, rowHeight[2] - 5); - //// Row 3 - ctx.fillText("Marking :", column1X, rowHeight[3] - 5); - ctx.font = "bold 14px Arial"; - ctx.fillStyle = "#0070D5"; - ctx.fillText("CIEF/605HOS", column3X, rowHeight[3] - 5); - ctx.fillStyle = "#000000"; - ctx.font = "13px Arial"; - //// Row 4 - ctx.fillText("Payment For(Order No.) :", column1X, rowHeight[4] - 5); - ctx.fillText(binding.value.id, column3X, rowHeight[4] - 5); - //// Row 4 - ctx.fillText("Payment For :", column1X, rowHeight[5] - 5); - ctx.fillText("Full Payment", column3X, rowHeight[5] - 5); - //// Row 5 - ctx.fillText("Payment Method :", column1X, rowHeight[6] - 5); - ctx.fillText(binding.value.payment_method, column3X, rowHeight[6] - 5); - //// Row 6 - ctx.fillText("Remark :", column1X, rowHeight[7] - 10); - //// Row 7 - // Empty - //// Row 8 - ctx.fillText("MYR/RM :", column1X, rowHeight[9] - 5); - ctx.fillText("MYR", column2X, rowHeight[9] - 5); - ctx.font = "bold 14px Arial"; - ctx.fillText(binding.value.transfer_amount, column3X, rowHeight[9] - 5); - ctx.font = "13px Arial"; - //// Row 8 - ctx.fillText("* RATE :", column1X, rowHeight[10] - 5); - ctx.fillText(binding.value.rate, column3X, rowHeight[10] - 5); - //// Row 9 - // Empty - //// Row 10 - ctx.font = "bold 14px Arial"; - ctx.fillText("CNY", column2X, rowHeight[12] - 5); - ctx.fillText(binding.value.amountInRMB, column3X, rowHeight[12] - 5); - ctx.font = "13px Arial"; - //line - ctx.beginPath(); - ctx.lineWidth = 1; - ctx.moveTo(column1X + 30, rowHeight[11]); - ctx.lineTo(column3X + 20, rowHeight[11]); - ctx.stroke(); - ctx.beginPath(); - ctx.lineWidth = 2; - ctx.moveTo(column1X + 30, rowHeight[12]); - ctx.lineTo(column3X + 20, rowHeight[12]); - ctx.stroke(); - //// Row 11 - ctx.fillText("MYR/RM :", column1X, rowHeight[14] - 5); - ctx.fillText("MYR", column2X, rowHeight[14] - 5); - ctx.fillText("4830.68", column3X, rowHeight[14] - 5); - //// Row 12 - ctx.fillText("Billing(1.0%) :", column1X, rowHeight[15] - 5); - ctx.fillText("MYR", column2X, rowHeight[15] - 5); - ctx.fillText(binding.value.billing_amount, column3X, rowHeight[15] - 5); - //// Row 13 - ctx.fillText("+ SALES TAX (10%) :", column1X, rowHeight[16] - 5); - ctx.fillText("MYR", column2X, rowHeight[16] - 5); - ctx.fillText(binding.value.salestax_amount, column3X, rowHeight[16] - 5); - //// Row 14 - ctx.fillText("+ GST 6% :", column1X, rowHeight[17] - 15); - ctx.fillText("MYR", column2X, rowHeight[17] - 15); - ctx.fillText("289.84", column3X, rowHeight[17] - 15); - //// Row 15 - ctx.font = "bold 14px Arial"; - ctx.fillText("Customer Bank In Amount :", column1X, rowHeight[18] - 5); - ctx.fillStyle = "#0070D5"; - ctx.fillText("MYR", column2X, rowHeight[18] - 5); - ctx.fillText(binding.value.amountInRMB, column3X, rowHeight[18] - 5); - ctx.fillStyle = "#000000"; - ctx.font = "13px Arial"; - //line - ctx.lineWidth = 1; - ctx.beginPath(); - ctx.moveTo(column1X + 30, rowHeight[17]); - ctx.lineTo(column3X + 20, rowHeight[17]); - ctx.stroke(); - ctx.beginPath(); - ctx.moveTo(column1X + 30, rowHeight[18] + 1); - ctx.lineTo(column3X + 20, rowHeight[18] + 1); - ctx.stroke(); - ctx.beginPath(); - ctx.moveTo(column1X + 30, rowHeight[18] - 2); - ctx.lineTo(column3X + 20, rowHeight[18] - 2); - ctx.stroke(); - //// Row 16 - ctx.fillText("Rebate :", column1X, rowHeight[19] - 25); - ctx.fillText("CNY", column2X, rowHeight[19] - 25); - ctx.fillText("224.68", column3X, rowHeight[19] - 25); - //// Row 16 - ctx.font = "bold 14px Arial"; - ctx.fillText("Bank In to Account Below :", column1X, rowHeight[20] - 5); - ctx.font = "bold italic 15px Arial"; - ctx.fillStyle = "#0070D5"; - ctx.fillText("CNY", column2X, rowHeight[20] - 5); - ctx.fillText("7692.17", column3X - 20, rowHeight[20] - 5); - ctx.fillStyle = "#000000"; - ctx.font = "13px Arial"; - //// Row 17 - //// Row 18 - //// Row 19 - var img = new Image(); - img.src = "/banklogo.png"; - img.crossOrigin = "anonymous"; - var maxwidth = 70; - var ratio = maxwidth / img.width; - var offset = ((rowHeight[22] - rowHeight[21]) / 2) - (img.height * ratio / 2); - var y = rowHeight[21] + offset; // to make it always center + ctx.fillRect(0, 0, canvasWidth, rowHeight[0]); + for (var i = 1; i < rowHeight.length; i++) { + if (i % 2 == 1) + ctx.fillStyle = "#A9D08E"; + else + ctx.fillStyle = "#FFFFFF"; + ctx.fillRect(0, rowHeight[i - 1], canvasWidth, rowHeight[i]); + } + ///////////// fillup with text//////////////// + //// config canvas + ctx.fillStyle = "#000000"; + ctx.font = "13px Arial"; + ctx.textAlign = "right"; + //// Row 1 + ctx.fillText("Payment Voucher :", column1X, rowHeight[1] - 5); + ctx.fillText(binding.value.id, column3X, rowHeight[1] - 5); + //// Row 2 + ctx.fillText("Date :", column1X, rowHeight[2] - 5); + ctx.fillText(binding.value.date, column3X, rowHeight[2] - 5); + //// Row 3 + ctx.fillText("Marking :", column1X, rowHeight[3] - 5); + ctx.font = "bold 14px Arial"; + ctx.fillStyle = "#0070D5"; + ctx.fillText("CIEF/605HOS", column3X, rowHeight[3] - 5); + ctx.fillStyle = "#000000"; + ctx.font = "13px Arial"; + //// Row 4 + ctx.fillText("Payment For(Order No.) :", column1X, rowHeight[4] - 5); + ctx.fillText(binding.value.id, column3X, rowHeight[4] - 5); + //// Row 4 + ctx.fillText("Payment For :", column1X, rowHeight[5] - 5); + ctx.fillText("Full Payment", column3X, rowHeight[5] - 5); + //// Row 5 + ctx.fillText("Payment Method :", column1X, rowHeight[6] - 5); + ctx.fillText(binding.value.payment_method, column3X, rowHeight[6] - 5); + //// Row 6 + ctx.fillText("Remark :", column1X, rowHeight[7] - 10); + //// Row 7 + // Empty + //// Row 8 + ctx.fillText("MYR/RM :", column1X, rowHeight[9] - 5); + ctx.fillText("MYR", column2X, rowHeight[9] - 5); + ctx.font = "bold 14px Arial"; + ctx.fillText(binding.value.transfer_amount, column3X, rowHeight[9] - 5); + ctx.font = "13px Arial"; + //// Row 8 + ctx.fillText("* RATE :", column1X, rowHeight[10] - 5); + ctx.fillText(binding.value.rate, column3X, rowHeight[10] - 5); + //// Row 9 + // Empty + //// Row 10 + ctx.font = "bold 14px Arial"; + ctx.fillText("CNY", column2X, rowHeight[12] - 5); + ctx.fillText(binding.value.amountInRMB, column3X, rowHeight[12] - 5); + ctx.font = "13px Arial"; + //line + ctx.beginPath(); + ctx.lineWidth = 1; + ctx.moveTo(column1X + 30, rowHeight[11]); + ctx.lineTo(column3X + 20, rowHeight[11]); + ctx.stroke(); + ctx.beginPath(); + ctx.lineWidth = 2; + ctx.moveTo(column1X + 30, rowHeight[12]); + ctx.lineTo(column3X + 20, rowHeight[12]); + ctx.stroke(); + //// Row 11 + ctx.fillText("MYR/RM :", column1X, rowHeight[14] - 5); + ctx.fillText("MYR", column2X, rowHeight[14] - 5); + ctx.fillText("4830.68", column3X, rowHeight[14] - 5); + //// Row 12 + ctx.fillText("Billing(1.0%) :", column1X, rowHeight[15] - 5); + ctx.fillText("MYR", column2X, rowHeight[15] - 5); + ctx.fillText(binding.value.billing_amount, column3X, rowHeight[15] - 5); + //// Row 13 + ctx.fillText("+ SALES TAX (10%) :", column1X, rowHeight[16] - 5); + ctx.fillText("MYR", column2X, rowHeight[16] - 5); + ctx.fillText(binding.value.salestax_amount, column3X, rowHeight[16] - 5); + //// Row 14 + ctx.fillText("+ GST 6% :", column1X, rowHeight[17] - 15); + ctx.fillText("MYR", column2X, rowHeight[17] - 15); + ctx.fillText("289.84", column3X, rowHeight[17] - 15); + //// Row 15 + ctx.font = "bold 14px Arial"; + ctx.fillText("Customer Bank In Amount :", column1X, rowHeight[18] - 5); + ctx.fillStyle = "#0070D5"; + ctx.fillText("MYR", column2X, rowHeight[18] - 5); + ctx.fillText(binding.value.amountInRMB, column3X, rowHeight[18] - 5); + ctx.fillStyle = "#000000"; + ctx.font = "13px Arial"; + //line + ctx.lineWidth = 1; + ctx.beginPath(); + ctx.moveTo(column1X + 30, rowHeight[17]); + ctx.lineTo(column3X + 20, rowHeight[17]); + ctx.stroke(); + ctx.beginPath(); + ctx.moveTo(column1X + 30, rowHeight[18] + 1); + ctx.lineTo(column3X + 20, rowHeight[18] + 1); + ctx.stroke(); + ctx.beginPath(); + ctx.moveTo(column1X + 30, rowHeight[18] - 2); + ctx.lineTo(column3X + 20, rowHeight[18] - 2); + ctx.stroke(); + //// Row 16 + ctx.fillText("Rebate :", column1X, rowHeight[19] - 25); + ctx.fillText("CNY", column2X, rowHeight[19] - 25); + ctx.fillText("224.68", column3X, rowHeight[19] - 25); + //// Row 16 + ctx.font = "bold 14px Arial"; + ctx.fillText("Bank In to Account Below :", column1X, rowHeight[20] - 5); + ctx.font = "bold italic 15px Arial"; + ctx.fillStyle = "#0070D5"; + ctx.fillText("CNY", column2X, rowHeight[20] - 5); + ctx.fillText("7692.17", column3X - 20, rowHeight[20] - 5); + ctx.fillStyle = "#000000"; + ctx.font = "13px Arial"; + //// Row 17 + //// Row 18 + //// Row 19 + var img = new Image(); + img.src = "/banklogo.png"; + img.crossOrigin = "anonymous"; + var maxwidth = 70; + var ratio = maxwidth / img.width; + var offset = ((rowHeight[22] - rowHeight[21]) / 2) - (img.height * ratio / 2); + var y = rowHeight[21] + offset; // to make it always center - img.onload=function(){ - ctx.drawImage(img, 50, 530, 80, 50); - }; - - // text - ctx.font = "bold 14px Arial"; - ctx.textAlign = "center"; - ctx.fillText("China beneficiary Account", column2X - 40, rowHeight[22] - 80); - ctx.fillText("户名 : 奕继椿", column2X - 40, rowHeight[22] - 60); - ctx.fillText("6226 1906 8014 3314", column2X - 40, rowHeight[22] - 40); - ctx.fillText("民生银行 深川红荔支行", column2X - 40, rowHeight[22] - 20); - ctx.font = "13px Arial"; + img.onload=function(){ + ctx.drawImage(img, 50, 530, 80, 50); + }; + // text + ctx.font = "bold 14px Arial"; + ctx.textAlign = "center"; + console.log(binding.value.amountInRMB); + console.log(binding.value); + ctx.fillText("China beneficiary Account", column2X - 40, rowHeight[22] - 80); + ctx.fillText("户名 : " + binding.value.china_company_name, column2X - 40, rowHeight[22] - 60); + ctx.fillText(binding.value.china_acc_no, column2X - 40, rowHeight[22] - 40); + ctx.fillText(binding.value.china_bank_name , column2X - 40, rowHeight[22] - 20); + + ctx.font = "13px Arial"; + }, 1000,canvasElement,binding); + } } + } \ No newline at end of file diff --git a/routes/api.php b/routes/api.php index 75d54e38..5e860f45 100644 --- a/routes/api.php +++ b/routes/api.php @@ -52,8 +52,6 @@ Route::group(['middleware' => 'auth:api'], function () { Route::get('malaysia-bank/{malaysiaBank}', 'SettingMalaysiaBankController@show'); }); - - Route::group(['middleware' => 'guest:api'], function () { Route::post('login', 'Auth\LoginController@login')->name('login'); Route::post('register', 'Auth\RegisterController@create'); From 62e8a9b9b6090a125e03f2aba753d4efdb71c86d Mon Sep 17 00:00:00 2001 From: weiweitoo Date: Thu, 12 Jul 2018 22:59:16 +0800 Subject: [PATCH 5/8] close loading only when all resource load finish --- .../assets/js/pages/admin/booking/supplierReport.vue | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/resources/assets/js/pages/admin/booking/supplierReport.vue b/resources/assets/js/pages/admin/booking/supplierReport.vue index ce6dca4b..33b1a5d2 100644 --- a/resources/assets/js/pages/admin/booking/supplierReport.vue +++ b/resources/assets/js/pages/admin/booking/supplierReport.vue @@ -297,11 +297,9 @@ axios .get('/api/admin/booking/' + this.$route.params.id) .then((response) => { - loading.close() this.booking_details = response.data }).catch((error) => { console.log(error) - loading.close() this.$router.push({ name: 'notfound' }) @@ -309,11 +307,9 @@ axios.get('/api/supplier-booking/' + this.$route.params.id) .then((response) => { - loading.close() this.supplier_booking = response.data }).catch((error) => { console.log(error) - loading.close() this.$router.push({ name: 'notfound' }) @@ -323,12 +319,13 @@ .then((response) => { axios.get('/api/setting-beneficiary/' + response.data.beneficiary_id) .then((response) => { + loading.close(); this.supplier_booking.china_bank_name = response.data.bank_name; this.supplier_booking.china_company_name = response.data.company_name; this.supplier_booking.china_acc_no = response.data.acc_no; - console.log(this.supplier_booking); }) .catch((error) => { + loading.close(); console.log(error); this.$message({ showClose: true, @@ -339,6 +336,7 @@ }); }) .catch((error) => { + loading.close(); console.log(error); this.$message({ showClose: true, @@ -347,7 +345,6 @@ duration: 10000 }); }); - }, methods: { downloadReport(){ From d9dfe84c2e0504fd08fa767651d5ab205ddc5cdf Mon Sep 17 00:00:00 2001 From: weiweitoo Date: Fri, 13 Jul 2018 09:58:32 +0800 Subject: [PATCH 6/8] rename beneficiaries tobeneficiary --- .../Controllers/SettingBeneficiaryController.php | 12 ++++++------ ...ttingBeneficiaries.php => SettingBeneficiary.php} | 2 +- database/factories/SettingBeneficiaryFactory.php | 2 +- database/seeds/DatabaseSeeder.php | 2 +- ...ciaresSeeder.php => SettingBeneficiarySeeder.php} | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) rename app/{SettingBeneficiaries.php => SettingBeneficiary.php} (81%) rename database/seeds/{SettingBeneficiaresSeeder.php => SettingBeneficiarySeeder.php} (94%) diff --git a/app/Http/Controllers/SettingBeneficiaryController.php b/app/Http/Controllers/SettingBeneficiaryController.php index 5b43d86b..fdec75f7 100644 --- a/app/Http/Controllers/SettingBeneficiaryController.php +++ b/app/Http/Controllers/SettingBeneficiaryController.php @@ -2,36 +2,36 @@ namespace App\Http\Controllers; -use App\SettingBeneficiaries; +use App\SettingBeneficiary; use Illuminate\Http\Request; class SettingBeneficiaryController extends Controller { public function index() { - return SettingBeneficiaries::all(); + return SettingBeneficiary::all(); } - public function show(SettingBeneficiaries $beneficiary) + public function show(SettingBeneficiary $beneficiary) { return $beneficiary; } public function store(Request $request) { - $beneficiary = SettingBeneficiaries::create($request->all()); + $beneficiary = SettingBeneficiary::create($request->all()); return response()->json($beneficiary, 201); } - public function update(Request $request, SettingBeneficiaries $beneficiary) + public function update(Request $request, SettingBeneficiary $beneficiary) { $beneficiary->update($request->all()); return response()->json($beneficiary, 200); } - public function delete(SettingBeneficiaries $beneficiary) + public function delete(SettingBeneficiary $beneficiary) { $beneficiary->delete(); diff --git a/app/SettingBeneficiaries.php b/app/SettingBeneficiary.php similarity index 81% rename from app/SettingBeneficiaries.php rename to app/SettingBeneficiary.php index 26c09e31..b6ea22e1 100644 --- a/app/SettingBeneficiaries.php +++ b/app/SettingBeneficiary.php @@ -4,7 +4,7 @@ namespace App; use Illuminate\Database\Eloquent\Model; -class SettingBeneficiaries extends Model +class SettingBeneficiary extends Model { protected $fillable = ['company_name','bank_name','acc_no','bank_address','swift','cnap','bank_branch']; } diff --git a/database/factories/SettingBeneficiaryFactory.php b/database/factories/SettingBeneficiaryFactory.php index f3d95095..79204254 100644 --- a/database/factories/SettingBeneficiaryFactory.php +++ b/database/factories/SettingBeneficiaryFactory.php @@ -2,7 +2,7 @@ use Faker\Generator as Faker; -$factory->define(App\SettingBeneficiaries::class, function (Faker $faker) { +$factory->define(App\SettingBeneficiary::class, function (Faker $faker) { return [ // ]; diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 32544630..2c2e3c17 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -24,7 +24,7 @@ class DatabaseSeeder extends Seeder $this->call(MarkingSeeder::class); DB::statement('SET FOREIGN_KEY_CHECKS=0;'); $this->call(SettingMalaysiaBankSeeder::class); - $this->call(SettingBeneficiaresSeeder::class); + $this->call(SettingBeneficiarySeeder::class); $this->call(SettingActiveBankSeeder::class); DB::statement('SET FOREIGN_KEY_CHECKS=1;'); } diff --git a/database/seeds/SettingBeneficiaresSeeder.php b/database/seeds/SettingBeneficiarySeeder.php similarity index 94% rename from database/seeds/SettingBeneficiaresSeeder.php rename to database/seeds/SettingBeneficiarySeeder.php index c7da261c..3cb2758b 100644 --- a/database/seeds/SettingBeneficiaresSeeder.php +++ b/database/seeds/SettingBeneficiarySeeder.php @@ -2,7 +2,7 @@ use Illuminate\Database\Seeder; -class SettingBeneficiaresSeeder extends Seeder +class SettingBeneficiarySeeder extends Seeder { /** * Run the database seeds. From 1c9a9aca208a5b46b3660851cdd4b07f53eef1a5 Mon Sep 17 00:00:00 2001 From: weiweitoo Date: Fri, 13 Jul 2018 18:31:29 +0800 Subject: [PATCH 7/8] missing change beneficiaries to beneficiary in seeder --- database/seeds/SettingActiveBankSeeder.php | 4 ++-- database/seeds/SettingBeneficiarySeeder.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/database/seeds/SettingActiveBankSeeder.php b/database/seeds/SettingActiveBankSeeder.php index 40560300..59ed5afd 100644 --- a/database/seeds/SettingActiveBankSeeder.php +++ b/database/seeds/SettingActiveBankSeeder.php @@ -2,7 +2,7 @@ use Illuminate\Database\Seeder; use App\SettingMalaysiaBank; -use App\SettingBeneficiaries; +use App\SettingBeneficiary; class SettingActiveBankSeeder extends Seeder { @@ -15,7 +15,7 @@ class SettingActiveBankSeeder extends Seeder { $bankx1 = SettingMalaysiaBank::where('acc_no', "=" ,'malaysiaacc01')->first(); $bankx2 = SettingMalaysiaBank::where('acc_no', "=",'malaysiaacc02')->first(); - $chinabank = SettingBeneficiaries::where('acc_no', "=" ,'123456789')->first(); + $chinabank = SettingBeneficiary::where('acc_no', "=" ,'123456789')->first(); DB::table('setting_active_banks')->truncate(); DB::table('setting_active_banks')->insert([ diff --git a/database/seeds/SettingBeneficiarySeeder.php b/database/seeds/SettingBeneficiarySeeder.php index 3cb2758b..ff34fbc4 100644 --- a/database/seeds/SettingBeneficiarySeeder.php +++ b/database/seeds/SettingBeneficiarySeeder.php @@ -1,6 +1,7 @@ Date: Sat, 14 Jul 2018 17:31:21 +0800 Subject: [PATCH 8/8] add new branch for booking flow for x2_chequeand x2_ba --- app/Http/Controllers/BookingController.php | 27 ++++++++++++++----- .../js/components/AdminProgressTrack.vue | 7 +++-- .../js/pages/admin/booking/completed.vue | 9 ++++--- .../pages/admin/booking/supplierBooking.vue | 8 ++++-- .../js/pages/admin/booking/supplierReport.vue | 8 ++++-- .../admin/booking/uploadChinaBankslip.vue | 10 ++++--- .../js/pages/admin/booking/uploadInvoice.vue | 9 ++++--- .../js/pages/admin/booking/verification.vue | 12 ++++++--- resources/assets/js/pages/admin/home.vue | 1 + 9 files changed, 64 insertions(+), 27 deletions(-) diff --git a/app/Http/Controllers/BookingController.php b/app/Http/Controllers/BookingController.php index ad63ff84..372e762f 100644 --- a/app/Http/Controllers/BookingController.php +++ b/app/Http/Controllers/BookingController.php @@ -97,7 +97,15 @@ class BookingController extends Controller // TODO : transfer_amount change name to bia $booking->transfer_amount = $booking->bia; - $booking->track_status = "(". $booking->admin_status ."/7)"; + $term = $booking->term; + if($term == "x1_ba" || $term == "x2_cheque"){ + $status = $booking->admin_status > 2 ? $booking->admin_status - 2 : $booking->admin_status; + $booking->track_status = "(". $status ."/5)"; + } + else{ + $booking->track_status = "(". $booking->admin_status ."/7)"; + } + switch ($booking->admin_status) { case 1: $status_desc = "Waiting customer upload bank slip"; @@ -106,11 +114,15 @@ class BookingController extends Controller $status_desc = "Verify user bank slip"; break; case 3: - $status_desc = "Generate supplier booking report"; - break; + if($term !== "x1_ba" || $term !== "x2_cheque"){ + $status_desc = "Generate supplier booking report"; + break; + } case 4: - $status_desc = "Supplier booking report. Please confirm with your booking."; - break; + if($term !== "x1_ba" || $term !== "x2_cheque"){ + $status_desc = "Supplier booking report. Please confirm with your booking."; + break; + } case 5: $status_desc = "Please, upload China Bankslip"; break; @@ -619,7 +631,10 @@ class BookingController extends Controller // update booking status $booking->status = 4; - $booking->admin_status = 3; + if($booking->term !== "x1_ba" || $booking->term !== "x2_cheque") + $booking->admin_status = 3; + else + $booking->admin_status = 5; $booking->save(); return response()->json(['message'=>'Success'],200); diff --git a/resources/assets/js/components/AdminProgressTrack.vue b/resources/assets/js/components/AdminProgressTrack.vue index bf3330c6..3a0a6507 100644 --- a/resources/assets/js/components/AdminProgressTrack.vue +++ b/resources/assets/js/components/AdminProgressTrack.vue @@ -1,10 +1,10 @@