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/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/SettingActiveBankSeeder.php b/database/seeds/SettingActiveBankSeeder.php index feed9792..59ed5afd 100644 --- a/database/seeds/SettingActiveBankSeeder.php +++ b/database/seeds/SettingActiveBankSeeder.php @@ -1,6 +1,8 @@ first(); + $bankx2 = SettingMalaysiaBank::where('acc_no', "=",'malaysiaacc02')->first(); + $chinabank = SettingBeneficiary::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/database/seeds/SettingBeneficiaresSeeder.php b/database/seeds/SettingBeneficiarySeeder.php similarity index 91% rename from database/seeds/SettingBeneficiaresSeeder.php rename to database/seeds/SettingBeneficiarySeeder.php index c7da261c..ff34fbc4 100644 --- a/database/seeds/SettingBeneficiaresSeeder.php +++ b/database/seeds/SettingBeneficiarySeeder.php @@ -1,8 +1,9 @@ { - loading.close() this.booking_details = response.data }).catch((error) => { console.log(error) - loading.close() this.$router.push({ name: 'notfound' }) }) - 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 }).catch((error) => { console.log(error) - loading.close() this.$router.push({ name: 'notfound' }) }) - - + axios.get('/api/active-bank') + .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; + }) + .catch((error) => { + loading.close(); + console.log(error); + this.$message({ + showClose: true, + message: 'Fetch data fail', + type: 'error', + duration: 10000 + }); + }); + }) + .catch((error) => { + loading.close(); + 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 +363,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 +395,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/resources/assets/js/pages/booking/uploadUserBankSlip.vue b/resources/assets/js/pages/booking/uploadUserBankSlip.vue index 5071cf96..593af081 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..5e860f45 100644 --- a/routes/api.php +++ b/routes/api.php @@ -46,10 +46,12 @@ 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('active-bank', 'SettingActiveBankController@index'); + 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'); @@ -70,7 +72,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 +87,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 +108,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