diff --git a/.env.example b/.env.example index 0b75a6079..79da23767 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,6 @@ APP_NAME=Bagisto APP_ENV=local -APP_VERSION=0.1.6 +APP_VERSION=0.1.7 APP_KEY= APP_DEBUG=true APP_URL=http://localhost diff --git a/CHANGELOG for v0.1.x.md b/CHANGELOG for v0.1.x.md index bbd67d15a..c58e370be 100755 --- a/CHANGELOG for v0.1.x.md +++ b/CHANGELOG for v0.1.x.md @@ -2,6 +2,114 @@ #### This changelog consists the bug & security fixes and new features being included in the releases listed below. +## **v0.1.7 (17th of September, 2019)** - *Release* + +* [feature] - Fiterable attributes according to category. + +* [feature] - New module CMS added for adding static pages. + +* [feature] - Dyanamic event firing in datagrid while adding columns, actions and mass actions as well. + +* [enhancement] - Customer gets an email after registration. + +* [enhancement] - Customer receives cancellation mail if his/her order is cancelled by admin. + +* [enhancement] - SEO is now available for home page. + +* [enhancement] - If account is created for customer by admin then customer should received an email that his/her account is created with create password link. + +* [enhancement] - product_flat will is now scalable according to choice of attributes to be used in it. + +* #1258 [fixed] - If payment is done through paypal then invoice should generate automatically and status of Order should be processing. + +* #1320 [fixed] - Catalog rule is not working according to selected attributes, if category is not selected. + +* #1260 [fixed] - Getting broken image link in email. + +* #1434 [fixed] - Incorrect discount amount in case of multicurrency. + +* #1288 [fixed] - Getting exception while creating cart rules if any of the dropdown field left blank. + +* #1381 [fixed] - Filter is not working properly for action type column in cart rule. + +* #1348 [fixed] - Showing incorrect grandtotal in invoice section of admin, if order is placed in currency other than base currency. + +* #1259 [fixed] - Getting exception if using same sku for variants.. + +* #1380 [fixed] - Getting error after refreshing the page. + +* #1256 [fixed] - Discounted amount is not displaying in invoice and invoice pdf at both customer end and admin end. + +* #1411 [fixed] - Getting exception on updating cart rule. + +* #1284 [fixed] - Updated price for variant is not reflected on store. + +* #1286 [fixed] - Incorrect discount is showing in cart. + +* #1382 [fixed] - In case of "Adjust whole cart to percent" discount amount is getting calculated according to price of one product. + +* #1415 [fixed] - Wrong discount applies if Action "Adjust whole cart to percent" is selected. + +* #1417 [fixed] - Discount amount is showing in "Quantity" column. + +* #973 [fixed] - Edit Slider, get wrong with: An invalid form control with name='image[image_0]' is not focusable. + +* #1263 [fixed] - For forgot password Submit button should get disabled if user has already clicked on submit button. + +* #1379 [fixed] - Cart rule not working in case of non-coupon if any condition is given. + +* #1239 [fixed] - Filterable attributes should not display in layered navigation if there are no product in that particular category. + +* #1351 [fixed] - Getting exception when assigning the root category to another category. + +* #1372 [fixed] - Getting exception if while updating cart rule , if any option is selected from "How to Choose Products?". + +* #1375 [fixed] - Wrong discount applied on cart in case of fixed discount. + +* #1226 [fixed] - Product variation that has been ordered should display in customer order section in case of configurable product. + +* #1391 [fixed] - By default attribute condition gets saved as 1 in db, because of which cart rule not getting applied. + +* #1277 [fixed] - Getting exception on creating cart rules. + +* #1334 [fixed] - On editing catalog rule data gets removed from Discount Amount field. + +* #778 [fixed] - Error when add item to cart. + +* #1253 [fixed] - Selected Channel for products get deselected after saving the product. + +* #1319 [fixed] - Getting exception when click on Apply rules if conditions are left empty while creating catalog rule. + +* #1295 [fixed] - Getting exception on changing the locale from cms page. + +* #1233 [fixed] - Got exception on front-end when first time changes the locale ,the changed locale have rtl direction. + +* #1235 [fixed] - Attributes are not visible in category page to select as filterable attribute if attributes name are not provided in particular locales. + +* #1177 [fixed] - Getting exception when trying to recover password. + +* #1228 [fixed] - Getting issue when entering direct url for customer account profile. + +* #1229 [fixed] - Issue with currency in customer order section, currency code doesn't get converted at orders page of customer. + +* #1234 [fixed] - After selecting direction to filter locale acc to direction no other field appears to select format. + +* #1015 [fixed] - Adjust Paginator Number of Elements. + +* #968 [fixed] - sorting is not working (price). + +* #1190 [fixed] - After printing invoice at customer end, price is not getting change according to currency in invoice. + +* #1209 [fixed] - There is an image issue while ordering any variant of configurable product. + +* #1217 [fixed] - Layered navigation for price is not working, when click on bar it shifts to rightmost end.Getting this issue in case of configurable product only. + +* #1216 [fixed] - Price filter of layered navigation not working properly in case of Multi Currency. + +* #1130 [fixed] - If "does not contain" is used in case of Shipping method, then discount amount get implemented before selecting any shipping method. + +* #1129 [fixed] - Discount not getting applied if "does not contain" condition is used from Actions for Payment Methods. + ## **v0.1.6(28th of June, 2019)** - *Release* * [feature] - Cart rules for providing discount with coupons and without coupons. diff --git a/app/Console/Commands/BagistoInstall.php b/app/Console/Commands/BagistoInstall.php deleted file mode 100644 index 14369cac6..000000000 --- a/app/Console/Commands/BagistoInstall.php +++ /dev/null @@ -1,186 +0,0 @@ -line('Hello and welcome to Bagisto command line installer.'); - - $APP_NAME = $this->ask('[KEY = "APP_NAME"] Please enter name of application instance?'); - $this->comment($APP_NAME ?? 'Bagisto'); - $this->changeEnvironmentVariable('APP_NAME', $APP_NAME); - - $APP_ENV = $this->choice('[KEY = "APP_ENV"] Choose environment for this instance of Bagisto?', ['development', 'production'], 0); - $this->comment($APP_ENV); - $this->changeEnvironmentVariable('APP_ENV', $APP_ENV); - - // $APP_DEBUG = $this->ask('Choose APP_DEBUG?', ['true', 'false'], 0); - // $this->comment($APP_DEBUG); - // $this->changeEnvironmentVariable('APP_DEBUG', $APP_DEBUG); - - $APP_URL = $this->ask('[KEY = "APP_URL"] Please enter application URL (Optional, default = localhost)?'); - $this->comment($APP_URL ?? 'localhost'); - $this->changeEnvironmentVariable('APP_URL', $APP_URL ?? 'http://localhost'); - - $DB_CONNECTION = $this->ask('[KEY = "DB_CONNECTION"] Enter database connection (Optional, default = mysql)?'); - $this->comment($DB_CONNECTION ?? 'mysql'); - $this->changeEnvironmentVariable('DB_CONNECTION', $DB_CONNECTION ?? 'mysql'); - - $DB_HOST = $this->ask('[KEY = "DB_HOST"] Enter database host (Optional, default = 127.0.0.1)?'); - $this->comment($DB_HOST ?? '127.0.0.1'); - $this->changeEnvironmentVariable('DB_HOST', $DB_HOST ?? '127.0.0.1'); - - $DB_PORT = $this->ask('[KEY = "DB_PORT"] Enter database port (Optional, default = 3306)?'); - $this->comment($DB_PORT ?? '3306'); - $this->changeEnvironmentVariable('DB_PORT', $DB_PORT ?? '3306'); - - $DB_DATABASE = null; - - while (!isset($DB_DATABASE)) { - $DB_DATABASE = $this->ask('[KEY = "DB_DATABASE"] Enter name of database?'); - $this->comment($DB_DATABASE ?? 'forge'); - } - - $this->changeEnvironmentVariable('DB_DATABASE', $DB_DATABASE ?? 'forge'); - - $DB_USERNAME = null; - - while (!isset($DB_USERNAME)) { - $DB_USERNAME = $this->ask('Enter database username?'); - $this->comment($DB_USERNAME ?? 'root'); - } - - $this->changeEnvironmentVariable('DB_USERNAME', $DB_USERNAME ?? root); - - $DB_PASSWORD = $this->ask('Please enter database password?'); - $this->comment($DB_PASSWORD); - $this->changeEnvironmentVariable('DB_PASSWORD', $DB_PASSWORD); - - $this->info('We are done with application and database params, good job!'); - - $this->info('Do you want me to be mail ready, i am loaded with notifications!'); - - $MAIL_DRIVER = $this->ask('[KEY = "MAIL_DRIVER"] Enter MAIL_DRIVER (Optional, default = smtp)?'); - $this->comment($MAIL_DRIVER ?? 'smtp'); - $this->changeEnvironmentVariable('MAIL_DRIVER', $MAIL_DRIVER ?? 'smtp'); - - $MAIL_HOST = $this->ask('[KEY = "MAIL_HOST"] Enter MAIL_HOST (Optional, default = smtp.mailtrap.io)?'); - $this->comment($MAIL_HOST ?? 'smtp.mailtrap.io'); - $this->changeEnvironmentVariable('MAIL_HOST', $MAIL_HOST ?? 'smtp.mailtrap.io'); - - $MAIL_PORT = $this->ask('[KEY = "MAIL_PORT"] Enter MAIL_PORT (Optional, default = 2525)?'); - $this->comment($MAIL_PORT ?? '2525'); - $this->changeEnvironmentVariable('MAIL_PORT', $MAIL_PORT ?? '2525'); - - $MAIL_USERNAME = $this->ask('[KEY = "MAIL_USERNAME"] Enter MAIL_USERNAME?'); - $this->comment($MAIL_USERNAME ?? null); - $this->changeEnvironmentVariable('MAIL_USERNAME', $MAIL_USERNAME ?? null); - - $MAIL_PASSWORD = $this->ask('[KEY = "MAIL_PASSWORD"] Enter MAIL_PASSWORD?'); - $this->comment($MAIL_PASSWORD ?? null); - $this->changeEnvironmentVariable('MAIL_PASSWORD', $MAIL_PASSWORD ?? null); - - $MAIL_ENCRYPTION = $this->ask('[KEY = "MAIL_ENCRYPTION"] Enter MAIL_ENCRYPTION (default = tls)?'); - $this->comment($MAIL_ENCRYPTION ?? 'tls'); - $this->changeEnvironmentVariable('MAIL_ENCRYPTION', $MAIL_ENCRYPTION ?? 'tls'); - - $SHOP_MAIL_FROM = $this->ask('[KEY = "SHOP_MAIL_FROM"] Enter SHOP_MAIL_FROM?'); - $this->comment($SHOP_MAIL_FROM ?? null); - $this->changeEnvironmentVariable('SHOP_MAIL_FROM', $SHOP_MAIL_FROM ?? null); - - $ADMIN_MAIL_TO = $this->ask('[KEY = "ADMIN_MAIL_TO"] Enter ADMIN_MAIL_TO?'); - $this->comment($ADMIN_MAIL_TO ?? null); - $this->changeEnvironmentVariable('ADMIN_MAIL_TO', $ADMIN_MAIL_TO ?? null); - - $this->line('We are done setting all the configuration in the env file, now we will proceed by running the commands necessary for Bagisto'); - - $this->info('Running migrations...'); - - \Artisan::call('key:generate'); - - \Artisan::call('migrate'); - - $this->info('Migration completed.'); - - $this->info('Running seeders...'); - - \Artisan::call('db:seed', ['--force' => true]); - - $this->info('Seeders finished.'); - - \Artisan::call('storage:link'); - - $this->info('Storage link created...'); - - \Artisan::call('vendor:publish', [0]); - - $this->info('All provider tags are published...'); - - $this->info('Installation completed.'); - - $this->Line('Please write us: SUPPORT@BAGISTO.COM'); - - $this->Line('Thank you!!!'); - } - - public static function changeEnvironmentVariable($key, $value) - { - - \Artisan::call('config:cache'); - - $path = base_path('.env'); - - if (file_exists($path)) { - - file_put_contents($path, str_replace( - $key . '=' . env($key), - $key . '=' . $value, - file_get_contents($path) - )); - } - - \Artisan::call('config:cache'); - } -} diff --git a/packages/Webkul/Admin/src/Config/menu.php b/packages/Webkul/Admin/src/Config/menu.php index 6435b5f41..c65fb65a9 100755 --- a/packages/Webkul/Admin/src/Config/menu.php +++ b/packages/Webkul/Admin/src/Config/menu.php @@ -31,8 +31,13 @@ return [ 'route' => 'admin.sales.invoices.index', 'sort' => 3, 'icon-class' => '' - ], - [ + ], [ + 'key' => 'sales.refunds', + 'name' => 'admin::app.layouts.refunds', + 'route' => 'admin.sales.refunds.index', + 'sort' => 4, + 'icon-class' => '' + ], [ 'key' => 'catalog', 'name' => 'admin::app.layouts.catalog', 'route' => 'admin.catalog.products.index', diff --git a/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php new file mode 100755 index 000000000..84c028308 --- /dev/null +++ b/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php @@ -0,0 +1,97 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ +class OrderRefundDataGrid extends DataGrid +{ + protected $index = 'id'; + + protected $sortOrder = 'desc'; //asc or desc + + public function prepareQueryBuilder() + { + $queryBuilder = DB::table('refunds') + ->select('refunds.id', 'refunds.order_id', 'refunds.state', 'refunds.base_grand_total', 'refunds.created_at') + ->leftJoin('orders', 'refunds.order_id', '=', 'orders.id') + ->leftJoin('order_address as order_address_billing', function($leftJoin) { + $leftJoin->on('order_address_billing.order_id', '=', 'orders.id') + ->where('order_address_billing.address_type', 'billing'); + }) + ->addSelect(DB::raw('CONCAT(order_address_billing.first_name, " ", order_address_billing.last_name) as billed_to')); + + $this->addFilter('billed_to', DB::raw('CONCAT(order_address_billing.first_name, " ", order_address_billing.last_name)')); + $this->addFilter('id', 'refunds.id'); + $this->addFilter('order_id', 'refunds.order_id'); + $this->addFilter('state', 'refunds.state'); + $this->addFilter('base_grand_total', 'refunds.base_grand_total'); + $this->addFilter('created_at', 'refunds.created_at'); + + $this->setQueryBuilder($queryBuilder); + } + + public function addColumns() + { + $this->addColumn([ + 'index' => 'id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', + 'searchable' => false, + 'sortable' => true, + 'filterable' => true + ]); + + $this->addColumn([ + 'index' => 'order_id', + 'label' => trans('admin::app.datagrid.order-id'), + 'type' => 'number', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true + ]); + + $this->addColumn([ + 'index' => 'base_grand_total', + 'label' => trans('admin::app.datagrid.refunded'), + 'type' => 'price', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true + ]); + + $this->addColumn([ + 'index' => 'billed_to', + 'label' => trans('admin::app.datagrid.billed-to'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true + ]); + + $this->addColumn([ + 'index' => 'created_at', + 'label' => trans('admin::app.datagrid.refund-date'), + 'type' => 'datetime', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true + ]); + } + + public function prepareActions() { + $this->addAction([ + 'title' => 'Order Refund View', + 'method' => 'GET', // use GET request only for redirect purposes + 'route' => 'admin.sales.refunds.view', + 'icon' => 'icon eye-icon' + ]); + } +} \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php b/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php index 3be5ad0c8..fc62d6247 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php @@ -286,7 +286,8 @@ class DashboardController extends Controller private function getOrdersBetweenDate($start, $end) { return $this->order->scopeQuery(function ($query) use ($start, $end) { - return $query->where('orders.created_at', '>=', $start)->where('orders.created_at', '<=', $end); + return $query->where('orders.created_at', '>=', $start)->where('orders.created_at', '<=', $end) + ->where('orders.status', '<>', 'canceled'); }); } diff --git a/packages/Webkul/Admin/src/Http/Controllers/Sales/RefundController.php b/packages/Webkul/Admin/src/Http/Controllers/Sales/RefundController.php new file mode 100755 index 000000000..669965513 --- /dev/null +++ b/packages/Webkul/Admin/src/Http/Controllers/Sales/RefundController.php @@ -0,0 +1,163 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ +class RefundController extends Controller +{ + /** + * Display a listing of the resource. + * + * @var array + */ + protected $_config; + + /** + * OrderRepository object + * + * @var Object + */ + protected $orderRepository; + + /** + * OrderItemRepository object + * + * @var Object + */ + protected $orderItemRepository; + + /** + * RefundRepository object + * + * @var Object + */ + protected $refundRepository; + + /** + * Create a new controller instance. + * + * @param \Webkul\Sales\Repositories\OrderRepository $orderRepository + * @param \Webkul\Sales\Repositories\OrderItemRepository $orderItemRepository + * @param \Webkul\Sales\Repositories\RefundRepository $refundRepository + * @return void + */ + public function __construct( + OrderRepository $orderRepository, + OrderItemRepository $orderItemRepository, + RefundRepository $refundRepository + ) + { + $this->middleware('admin'); + + $this->_config = request('_config'); + + $this->orderRepository = $orderRepository; + + $this->orderItemRepository = $orderItemRepository; + + $this->refundRepository = $refundRepository; + } + + /** + * Display a listing of the resource. + * + * @return \Illuminate\Http\View + */ + public function index() + { + return view($this->_config['view']); + } + + /** + * Show the form for creating a new resource. + * + * @param int $orderId + * @return \Illuminate\Http\View + */ + public function create($orderId) + { + $order = $this->orderRepository->findOrFail($orderId); + + return view($this->_config['view'], compact('order')); + } + + /** + * Store a newly created resource in storage. + * + * @param int $orderId + * @return \Illuminate\Http\Response + */ + public function store($orderId) + { + $order = $this->orderRepository->findOrFail($orderId); + + if (! $order->canRefund()) { + session()->flash('error', trans('admin::app.sales.refunds.creation-error')); + + return redirect()->back(); + } + + $this->validate(request(), [ + 'refund.items.*' => 'required|numeric|min:0' + ]); + + $data = request()->all(); + + $totals = $this->refundRepository->getOrderItemsRefundSummary($data['refund']['items'], $orderId); + + $maxRefundAmount = $totals['grand_total']['price'] - $order->refunds()->sum('base_adjustment_refund') + $order->refunds()->sum('base_adjustment_fee'); + + $refundAmount = $totals['grand_total']['price'] - $totals['shipping']['price'] + $data['refund']['shipping'] + $data['refund']['adjustment_refund'] - $data['refund']['adjustment_fee']; + + if ($refundAmount > $maxRefundAmount) { + session()->flash('error', trans('admin::app.sales.refunds.refund-limit-error', ['amount' => core()->formatBasePrice($maxRefundAmount)])); + + return redirect()->back(); + } + + $this->refundRepository->create(array_merge($data, ['order_id' => $orderId])); + + session()->flash('success', trans('admin::app.response.create-success', ['name' => 'Refund'])); + + return redirect()->route($this->_config['redirect'], $orderId); + } + + /** + * Store a newly created resource in storage. + * + * @param int $orderId + * @return \Illuminate\Http\JsonResponse + */ + public function updateQty($orderId) + { + $data = $this->refundRepository->getOrderItemsRefundSummary(request()->all(), $orderId); + + if (! $data) + return response(''); + + return response()->json($data); + } + + /** + * Show the view for the specified resource. + * + * @param int $id + * @return \Illuminate\Http\View + */ + public function view($id) + { + $refund = $this->refundRepository->findOrFail($id); + + return view($this->_config['view'], compact('refund')); + } +} diff --git a/packages/Webkul/Admin/src/Http/routes.php b/packages/Webkul/Admin/src/Http/routes.php index f7112a0f6..93a041ac3 100755 --- a/packages/Webkul/Admin/src/Http/routes.php +++ b/packages/Webkul/Admin/src/Http/routes.php @@ -196,6 +196,28 @@ Route::group(['middleware' => ['web']], function () { Route::get('/shipments/view/{id}', 'Webkul\Admin\Http\Controllers\Sales\ShipmentController@view')->defaults('_config', [ 'view' => 'admin::sales.shipments.view' ])->name('admin.sales.shipments.view'); + + + // Sales Redunds Routes + Route::get('/refunds', 'Webkul\Admin\Http\Controllers\Sales\RefundController@index')->defaults('_config', [ + 'view' => 'admin::sales.refunds.index' + ])->name('admin.sales.refunds.index'); + + Route::get('/refunds/create/{order_id}', 'Webkul\Admin\Http\Controllers\Sales\RefundController@create')->defaults('_config', [ + 'view' => 'admin::sales.refunds.create' + ])->name('admin.sales.refunds.create'); + + Route::post('/refunds/create/{order_id}', 'Webkul\Admin\Http\Controllers\Sales\RefundController@store')->defaults('_config', [ + 'redirect' => 'admin.sales.orders.view' + ])->name('admin.sales.refunds.store'); + + Route::post('/refunds/update-qty/{order_id}', 'Webkul\Admin\Http\Controllers\Sales\RefundController@updateQty')->defaults('_config', [ + 'redirect' => 'admin.sales.orders.view' + ])->name('admin.sales.refunds.update_qty'); + + Route::get('/refunds/view/{id}', 'Webkul\Admin\Http\Controllers\Sales\RefundController@view')->defaults('_config', [ + 'view' => 'admin::sales.refunds.view' + ])->name('admin.sales.refunds.view'); }); // Catalog Routes diff --git a/packages/Webkul/Admin/src/Mail/NewCustomerNotification.php b/packages/Webkul/Admin/src/Mail/NewCustomerNotification.php index b4e47718d..4af9308e6 100644 --- a/packages/Webkul/Admin/src/Mail/NewCustomerNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewCustomerNotification.php @@ -51,7 +51,7 @@ class NewCustomerNotification extends Mailable public function build() { return $this->to($this->customer->email) - ->subject(trans('shop::app.mail.customer.subject')) + ->subject(trans('shop::app.mail.customer.new.subject')) ->view('shop::emails.customer.new-customer')->with(['customer' => $this->customer, 'password' => $this->password]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Resources/assets/sass/app.scss b/packages/Webkul/Admin/src/Resources/assets/sass/app.scss index f6c0fbd6c..726d23090 100755 --- a/packages/Webkul/Admin/src/Resources/assets/sass/app.scss +++ b/packages/Webkul/Admin/src/Resources/assets/sass/app.scss @@ -556,6 +556,7 @@ body { tr { td { padding: 5px 8px; + vertical-align: text-bottom; } &.bold { diff --git a/packages/Webkul/Admin/src/Resources/lang/ar/app.php b/packages/Webkul/Admin/src/Resources/lang/ar/app.php index e1339a81f..a0bc2885f 100644 --- a/packages/Webkul/Admin/src/Resources/lang/ar/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/ar/app.php @@ -146,6 +146,7 @@ return [ 'role' => 'الدور', 'sub-total' => 'المجموع الفرعي', 'no-of-products' => 'عدد المنتجات', + 'refunded' => 'Refunded' ], 'account' => [ 'title' => 'حسابي', @@ -262,6 +263,7 @@ return [ 'item-invoice' => '3-الفواتير (:qty_invoiced)', 'item-shipped' => 'شحنت (:qty_shipped)', 'item-canceled' => 'ملغاة (:qty_canceled)', + 'item-refunded' => 'Refunded (:qty_refunded)', 'price' => 'Price', 'total' => 'المجموع', 'subtotal' => 'المجموع الفرعي', @@ -276,7 +278,9 @@ return [ 'total-paid' => 'المجموع المدفوع', 'total-refunded' => 'مجموع المبالغ المستردة', 'total-due' => 'المجموع المستحق', - 'cancel-confirm-msg' => 'هل أنت متأكد من أنك تريد إلغاء هذا الطلب ؟' + 'cancel-confirm-msg' => 'هل أنت متأكد من أنك تريد إلغاء هذا الطلب ؟', + 'refunds' => 'Refunds', + 'refunded' => 'Refunded' ], 'invoices' => [ 'title' => 'الفواتير', @@ -301,6 +305,7 @@ return [ 'creation-error' => 'لا يسمح بإنشاء الفواتير.', 'product-error' => 'ولا يمكن إعداد الفاتورة بدون منتجات.' ], + 'shipments' => [ 'title' => 'الشحنات', 'id' => 'Id', @@ -325,6 +330,27 @@ return [ 'creation-error' => 'لا يمكن إنشاء الشحنة لهذا الطلب.', 'order-error' => 'لا يسمح بإنشاء شحنة الطلب.', 'quantity-invalid' => 'الكمية المطلوبة غير صالحة أو غير متاحة.', + ], + + 'refunds' => [ + 'title' => 'Refunds', + 'id' => 'Id', + 'add-title' => 'Create Refund', + 'save-btn-title' => 'Refund', + 'order-id' => 'Order Id', + 'qty-ordered' => 'Qty Ordered', + 'qty-to-refund' => 'Qty To Refund', + 'refund-shipping' => 'Refund Shipping', + 'adjustment-refund' => 'Adjustment Refund', + 'adjustment-fee' => 'Adjustment Fee', + 'update-qty' => 'Update Quantities', + 'invalid-qty' => 'Found invalid quantity for return items.', + 'refund-limit-error' => 'The most money available to refund is :amount.', + 'refunded' => 'Refunded', + 'date' => 'Refund Date', + 'customer-name' => 'Customer Name', + 'status' => 'Status', + 'action' => 'Action' ] ], 'catalog' => [ diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php index 70435d640..9b8f5c95b 100755 --- a/packages/Webkul/Admin/src/Resources/lang/en/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php @@ -50,6 +50,7 @@ return [ 'orders' => 'Orders', 'shipments' => 'Shipments', 'invoices' => 'Invoices', + 'refunds' => 'Refunds', 'catalog' => 'Catalog', 'products' => 'Products', 'categories' => 'Categories', @@ -131,7 +132,7 @@ return [ 'order-count' => ':count Orders', 'revenue' => 'Revenue :total', 'stock-threshold' => 'Stock Threshold', - 'qty-left' => ':qty Left', + 'qty-left' => ':qty Left' ], 'datagrid' => [ @@ -198,7 +199,9 @@ return [ 'per-cust' => 'Per Customer', 'usage-throttle' => 'Usage Times', 'for-guest' => 'For Guest', - 'order_number' => 'Order Number' + 'order_number' => 'Order Number', + 'refund-date' => 'Refund Date', + 'refunded' => 'Refunded' ], 'account' => [ @@ -321,6 +324,7 @@ return [ 'item-invoice' => 'Invoiced (:qty_invoiced)', 'item-shipped' => 'shipped (:qty_shipped)', 'item-canceled' => 'Canceled (:qty_canceled)', + 'item-refunded' => 'Refunded (:qty_refunded)', 'price' => 'Price', 'total' => 'Total', 'subtotal' => 'Subtotal', @@ -335,7 +339,9 @@ return [ 'total-paid' => 'Total Paid', 'total-refunded' => 'Total Refunded', 'total-due' => 'Total Due', - 'cancel-confirm-msg' => 'Are you sure you want to cancel this order ?' + 'cancel-confirm-msg' => 'Are you sure you want to cancel this order ?', + 'refund-btn-title' => 'Refund', + 'refunds' => 'Refunds' ], 'invoices' => [ @@ -386,6 +392,28 @@ return [ 'creation-error' => 'Shipment can not be created for this order.', 'order-error' => 'Order shipment creation is not allowed.', 'quantity-invalid' => 'Requested quantity is invalid or not available.', + ], + + 'refunds' => [ + 'title' => 'Refunds', + 'id' => 'Id', + 'add-title' => 'Create Refund', + 'save-btn-title' => 'Refund', + 'order-id' => 'Order Id', + 'qty-ordered' => 'Qty Ordered', + 'qty-to-refund' => 'Qty To Refund', + 'refund-shipping' => 'Refund Shipping', + 'adjustment-refund' => 'Adjustment Refund', + 'adjustment-fee' => 'Adjustment Fee', + 'update-qty' => 'Update Quantities', + 'invalid-qty' => 'Found invalid quantity for return items.', + 'refund-limit-error' => 'The most money available to refund is :amount.', + 'refunded' => 'Refunded', + 'date' => 'Refund Date', + 'customer-name' => 'Customer Name', + 'status' => 'Status', + 'action' => 'Action', + 'view-title' => 'Refund #:refund_id', ] ], diff --git a/packages/Webkul/Admin/src/Resources/lang/fa/app.php b/packages/Webkul/Admin/src/Resources/lang/fa/app.php index 93a07cb11..efa6f4ecf 100644 --- a/packages/Webkul/Admin/src/Resources/lang/fa/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/fa/app.php @@ -166,7 +166,8 @@ return [ 'action_type' => 'نوع عملیات', 'disc_quantity' => 'مقدار استفاده نشده', 'disc_threshold' => 'آستانه استفاده نشده', - 'use_coupon' => 'استافده از کوپن' + 'use_coupon' => 'استافده از کوپن', + 'refunded' => 'Refunded' ], 'account' => [ @@ -289,6 +290,7 @@ return [ 'item-invoice' => 'صورت حساب (:qty_invoiced)', 'item-shipped' => 'حمل شده (:qty_shipped)', 'item-canceled' => 'لغو شده (:qty_canceled)', + 'item-refunded' => 'Refunded (:qty_refunded)', 'price' => 'قیمت', 'total' => 'کل', 'subtotal' => 'فرعی', @@ -302,7 +304,9 @@ return [ 'total-paid' => 'کل پرداخت شده', 'total-refunded' => 'بازپرداخت کل', 'total-due' => 'بدهی کل', - 'cancel-confirm-msg' => 'مطمئن هستید که می خواهید این سفارش را لغو کنید ؟' + 'cancel-confirm-msg' => 'مطمئن هستید که می خواهید این سفارش را لغو کنید ؟', + 'refunds' => 'Refunds', + 'refunded' => 'Refunded' ], 'invoices' => [ @@ -353,6 +357,27 @@ return [ 'creation-error' => 'حمل و نقل برای این سفارش ایجاد نمی شود.', 'order-error' => 'ایجاد محموله سفارش مجاز نیست.', 'quantity-invalid' => 'مقدار درخواستی نامعتبر است یا در دسترس نیست.', + ], + + 'refunds' => [ + 'title' => 'Refunds', + 'id' => 'Id', + 'add-title' => 'Create Refund', + 'save-btn-title' => 'Refund', + 'order-id' => 'Order Id', + 'qty-ordered' => 'Qty Ordered', + 'qty-to-refund' => 'Qty To Refund', + 'refund-shipping' => 'Refund Shipping', + 'adjustment-refund' => 'Adjustment Refund', + 'adjustment-fee' => 'Adjustment Fee', + 'update-qty' => 'Update Quantities', + 'invalid-qty' => 'Found invalid quantity for return items.', + 'refund-limit-error' => 'The most money available to refund is :amount.', + 'refunded' => 'Refunded', + 'date' => 'Refund Date', + 'customer-name' => 'Customer Name', + 'status' => 'Status', + 'action' => 'Action' ] ], diff --git a/packages/Webkul/Admin/src/Resources/lang/pt_BR/app.php b/packages/Webkul/Admin/src/Resources/lang/pt_BR/app.php index 9d3ef4265..547534691 100755 --- a/packages/Webkul/Admin/src/Resources/lang/pt_BR/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/pt_BR/app.php @@ -154,7 +154,8 @@ return [ 'ends-till' => 'Termina Até', 'per-cust' => 'Por cliente', 'usage-throttle' => 'Tempos de uso', - 'for-guest' => 'Para convidados' + 'for-guest' => 'Para convidados', + 'refunded' => 'Refunded' ], 'account' => [ 'title' => 'Minha Conta', @@ -270,6 +271,7 @@ return [ 'item-invoice' => 'Faturado(s) (:qty_invoiced)', 'item-shipped' => 'Enviado(s) (:qty_shipped)', 'item-canceled' => 'Cancelado(s) (:qty_canceled)', + 'item-refunded' => 'Refunded (:qty_refunded)', 'price' => 'Preço', 'total' => 'Total', 'subtotal' => 'Subtotal', @@ -284,7 +286,9 @@ return [ 'total-paid' => 'Total Pago', 'total-refunded' => 'Total Estornado', 'total-due' => 'Total Devido', - 'cancel-confirm-msg' => 'Tem certeza que deseja cancelar esse pedido ?' + 'cancel-confirm-msg' => 'Tem certeza que deseja cancelar esse pedido ?', + 'refunds' => 'Refunds', + 'refunded' => 'Refunded' ], 'invoices' => [ 'title' => 'Faturas', @@ -309,6 +313,7 @@ return [ 'creation-error' => 'A criação de fatura de pedido não é permitida.', 'product-error' => 'A fatura não pode ser criada sem produtos.' ], + 'shipments' => [ 'title' => 'Entregas', 'id' => 'Id', @@ -333,6 +338,27 @@ return [ 'creation-error' => 'A expedição não pode ser criada para este pedido.', 'order-error' => 'A criação de remessa de pedidos não é permitida.', 'quantity-invalid' => 'A quantidade solicitada é inválida ou não está disponível.' + ], + + 'refunds' => [ + 'title' => 'Refunds', + 'id' => 'Id', + 'add-title' => 'Create Refund', + 'save-btn-title' => 'Refund', + 'order-id' => 'Order Id', + 'qty-ordered' => 'Qty Ordered', + 'qty-to-refund' => 'Qty To Refund', + 'refund-shipping' => 'Refund Shipping', + 'adjustment-refund' => 'Adjustment Refund', + 'adjustment-fee' => 'Adjustment Fee', + 'update-qty' => 'Update Quantities', + 'invalid-qty' => 'Found invalid quantity for return items.', + 'refund-limit-error' => 'The most money available to refund is :amount.', + 'refunded' => 'Refunded', + 'date' => 'Refund Date', + 'customer-name' => 'Customer Name', + 'status' => 'Status', + 'action' => 'Action' ] ], 'catalog' => [ diff --git a/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php index 2837f847b..6ccde2120 100755 --- a/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php @@ -31,6 +31,12 @@ @endif + @if ($order->canRefund()) + + {{ __('admin::app.sales.orders.refund-btn-title') }} + + @endif + @if ($order->canShip()) {{ __('admin::app.sales.orders.shipment-btn-title') }} @@ -274,6 +280,10 @@ {{ $item->qty_shipped ? __('admin::app.sales.orders.item-shipped', ['qty_shipped' => $item->qty_shipped]) : '' }} + + {{ $item->qty_refunded ? __('admin::app.sales.orders.item-refunded', ['qty_refunded' => $item->qty_refunded]) : '' }} + + {{ $item->qty_canceled ? __('admin::app.sales.orders.item-canceled', ['qty_canceled' => $item->qty_canceled]) : '' }} @@ -440,6 +450,50 @@ + + + +
+ + + + + + + + + + + + + + + + @foreach ($order->refunds as $refund) + + + + + + + + + + @endforeach + + @if (! $order->refunds->count()) + + + + @endif +
{{ __('admin::app.sales.refunds.id') }}{{ __('admin::app.sales.refunds.date') }}{{ __('admin::app.sales.refunds.order-id') }}{{ __('admin::app.sales.refunds.customer-name') }}{{ __('admin::app.sales.refunds.status') }}{{ __('admin::app.sales.refunds.refunded') }}{{ __('admin::app.sales.refunds.action') }}
#{{ $refund->id }}{{ $refund->created_at }}#{{ $refund->order->id }}{{ $refund->order->customer_full_name }}{{ __('admin::app.sales.refunds.refunded') }}{{ core()->formatBasePrice($refund->base_grand_total) }} + + + +
{{ __('admin::app.common.no-result-found') }}
+
+ +
diff --git a/packages/Webkul/Admin/src/Resources/views/sales/refunds/create.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/refunds/create.blade.php new file mode 100755 index 000000000..216393cf7 --- /dev/null +++ b/packages/Webkul/Admin/src/Resources/views/sales/refunds/create.blade.php @@ -0,0 +1,404 @@ +@extends('admin::layouts.master') + +@section('page_title') + {{ __('admin::app.sales.refunds.add-title') }} +@stop + +@section('content-wrapper') +
+
+ @csrf() + + + +
+
+ + +
+ + + +
+
+ {{ __('admin::app.sales.orders.account-info') }} +
+ +
+
+ + {{ __('admin::app.sales.orders.customer-name') }} + + + + {{ $order->customer_full_name }} + +
+ +
+ + {{ __('admin::app.sales.orders.email') }} + + + + {{ $order->customer_email }} + +
+
+
+ +
+ + + +
+ +
+
+ {{ __('admin::app.sales.orders.billing-address') }} +
+ +
+ + @include ('admin::sales.address', ['address' => $order->billing_address]) + +
+
+ + @if ($order->shipping_address) +
+
+ {{ __('admin::app.sales.orders.shipping-address') }} +
+ +
+ + @include ('admin::sales.address', ['address' => $order->shipping_address]) + +
+
+ @endif + +
+
+ + +
+ +
+
+ {{ __('admin::app.sales.orders.payment-info') }} +
+ +
+
+ + {{ __('admin::app.sales.orders.payment-method') }} + + + + {{ core()->getConfigData('sales.paymentmethods.' . $order->payment->method . '.title') }} + +
+ +
+ + {{ __('admin::app.sales.orders.currency') }} + + + + {{ $order->order_currency_code }} + +
+
+
+ +
+
+ {{ __('admin::app.sales.orders.shipping-info') }} +
+ +
+
+ + {{ __('admin::app.sales.orders.shipping-method') }} + + + + {{ $order->shipping_title }} + +
+ +
+ + {{ __('admin::app.sales.orders.shipping-price') }} + + + + {{ core()->formatBasePrice($order->base_shipping_amount) }} + +
+
+
+
+
+ + +
+ + + +
+
+ +
+
+ +
+@stop + +@push('scripts') + + + +@endpush \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Resources/views/sales/refunds/index.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/refunds/index.blade.php new file mode 100755 index 000000000..ec85e3c88 --- /dev/null +++ b/packages/Webkul/Admin/src/Resources/views/sales/refunds/index.blade.php @@ -0,0 +1,42 @@ +@extends('admin::layouts.content') + +@section('page_title') + {{ __('admin::app.sales.refunds.title') }} +@stop + +@section('content') +
+ + +
+ @inject('refundGrid', 'Webkul\Admin\DataGrids\OrderRefundDataGrid') + + {!! $refundGrid->render() !!} +
+
+ + +

{{ __('admin::app.export.download') }}

+
+ +
+
+ +@stop + +@push('scripts') + @include('admin::export.export', ['gridName' => $refundGrid]) +@endpush \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Resources/views/sales/refunds/view.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/refunds/view.blade.php new file mode 100755 index 000000000..c3e91847d --- /dev/null +++ b/packages/Webkul/Admin/src/Resources/views/sales/refunds/view.blade.php @@ -0,0 +1,314 @@ +@extends('admin::layouts.master') + +@section('page_title') + {{ __('admin::app.sales.refunds.view-title', ['refund_id' => $refund->id]) }} +@stop + +@section('content-wrapper') + + order; ?> + +
+ + +
+
+ + +
+ +
+
+ {{ __('admin::app.sales.orders.order-info') }} +
+ +
+ + +
+ + {{ __('admin::app.sales.orders.order-date') }} + + + + {{ $order->created_at }} + +
+ +
+ + {{ __('admin::app.sales.orders.order-status') }} + + + + {{ $order->status_label }} + +
+ +
+ + {{ __('admin::app.sales.orders.channel') }} + + + + {{ $order->channel_name }} + +
+
+
+ +
+
+ {{ __('admin::app.sales.orders.account-info') }} +
+ +
+
+ + {{ __('admin::app.sales.orders.customer-name') }} + + + + {{ $refund->order->customer_full_name }} + +
+ +
+ + {{ __('admin::app.sales.orders.email') }} + + + + {{ $refund->order->customer_email }} + +
+
+
+ +
+ + + +
+ +
+
+ {{ __('admin::app.sales.orders.billing-address') }} +
+ +
+ + @include ('admin::sales.address', ['address' => $order->billing_address]) + +
+
+ + @if ($order->shipping_address) +
+
+ {{ __('admin::app.sales.orders.shipping-address') }} +
+ +
+ + @include ('admin::sales.address', ['address' => $order->shipping_address]) + +
+
+ @endif + +
+
+ + +
+ +
+
+ {{ __('admin::app.sales.orders.payment-info') }} +
+ +
+
+ + {{ __('admin::app.sales.orders.payment-method') }} + + + + {{ core()->getConfigData('sales.paymentmethods.' . $order->payment->method . '.title') }} + +
+ +
+ + {{ __('admin::app.sales.orders.currency') }} + + + + {{ $order->order_currency_code }} + +
+
+
+ +
+
+ {{ __('admin::app.sales.orders.shipping-info') }} +
+ +
+
+ + {{ __('admin::app.sales.orders.shipping-method') }} + + + + {{ $order->shipping_title }} + +
+ +
+ + {{ __('admin::app.sales.orders.shipping-price') }} + + + + {{ core()->formatBasePrice($order->base_shipping_amount) }} + +
+
+
+
+
+ + +
+ +
+ + + + + + + + + + @if ($refund->base_discount_amount > 0) + + @endif + + + + + + + @foreach ($refund->items as $item) + + + + + + + + + + + + + + @if ($refund->base_discount_amount > 0) + + @endif + + + + @endforeach + + +
{{ __('admin::app.sales.orders.SKU') }}{{ __('admin::app.sales.orders.product-name') }}{{ __('admin::app.sales.orders.price') }}{{ __('admin::app.sales.orders.qty') }}{{ __('admin::app.sales.orders.subtotal') }}{{ __('admin::app.sales.orders.tax-amount') }}{{ __('admin::app.sales.orders.discount-amount') }}{{ __('admin::app.sales.orders.grand-total') }}
{{ $item->child ? $item->child->sku : $item->sku }} + {{ $item->name }} + + @if ($html = $item->getOptionDetailHtml()) +

{{ $html }}

+ @endif +
{{ core()->formatBasePrice($item->base_price) }}{{ $item->qty }}{{ core()->formatBasePrice($item->base_total) }}{{ core()->formatBasePrice($item->base_tax_amount) }}{{ core()->formatBasePrice($item->base_discount_amount) }}{{ core()->formatBasePrice($item->base_total + $item->base_tax_amount - $item->base_discount_amount) }}
+
+ + + + + + + + + @if ($refund->base_shipping_amount > 0) + + + + + + @endif + + @if ($refund->base_tax_amount > 0) + + + + + + @endif + + @if ($refund->base_discount_amount > 0) + + + + + + @endif + + + + + + + + + + + + + + + + + + +
{{ __('admin::app.sales.orders.subtotal') }}-{{ core()->formatBasePrice($refund->base_sub_total) }}
{{ __('admin::app.sales.orders.shipping-handling') }}-{{ core()->formatBasePrice($refund->base_shipping_amount) }}
{{ __('admin::app.sales.orders.tax') }}-{{ core()->formatBasePrice($refund->base_tax_amount) }}
{{ __('admin::app.sales.orders.discount') }}--{{ core()->formatBasePrice($refund->base_discount_amount) }}
{{ __('admin::app.sales.refunds.adjustment-refund') }}-{{ core()->formatBasePrice($refund->base_adjustment_refund) }}
{{ __('admin::app.sales.refunds.adjustment-fee') }}-{{ core()->formatBasePrice($refund->base_adjustment_fee) }}
{{ __('admin::app.sales.orders.grand-total') }}-{{ core()->formatBasePrice($refund->base_grand_total) }}
+ +
+
+ +
+
+ +
+@stop \ No newline at end of file diff --git a/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php b/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php index 14c36e819..30d407510 100755 --- a/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/CustomerController.php @@ -133,6 +133,32 @@ class CustomerController extends Controller } } + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id) + { + $id = auth()->guard('customer')->user()->id; + + $customer = $this->customer->findorFail($id); + + try { + $this->customer->delete($id); + + session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Customer'])); + + return redirect()->route($this->_config['redirect']); + } catch(\Exception $e) { + session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Customer'])); + + return redirect()->route($this->_config['redirect']); + } + } + + /** * Load the view for the customer account panel, showing approved reviews. * diff --git a/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php b/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php index 53c72926f..d0a0e195b 100755 --- a/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php @@ -6,6 +6,7 @@ use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Mail; +use Webkul\Customer\Mail\RegistrationEmail; use Webkul\Customer\Mail\VerificationEmail; use Illuminate\Routing\Controller; use Webkul\Customer\Repositories\CustomerRepository; @@ -97,6 +98,15 @@ class RegistrationController extends Controller session()->flash('info', trans('shop::app.customer.signup-form.success-verify-email-unsent')); } } else { + try { + Mail::queue(new RegistrationEmail(request()->all())); + + session()->flash('success', trans('shop::app.customer.signup-form.success-verify')); //customer registered successfully + } catch (\Exception $e) { + session()->flash('info', trans('shop::app.customer.signup-form.success-verify-email-unsent')); + } + + session()->flash('success', trans('shop::app.customer.signup-form.success')); } diff --git a/packages/Webkul/Customer/src/Mail/RegistrationEmail.php b/packages/Webkul/Customer/src/Mail/RegistrationEmail.php new file mode 100644 index 000000000..ffd045e90 --- /dev/null +++ b/packages/Webkul/Customer/src/Mail/RegistrationEmail.php @@ -0,0 +1,38 @@ +data = $data; + } + + /** + * Build the message. + * + * @return $this + */ + public function build() + { + return $this->to($this->data['email']) + ->from(env('SHOP_MAIL_FROM')) + ->subject(trans('shop::app.mail.customer.registration.customer-registration')) + ->view('shop::emails.customer.registration')->with('data', $this->data); + } +} \ No newline at end of file diff --git a/packages/Webkul/Customer/src/Mail/VerificationEmail.php b/packages/Webkul/Customer/src/Mail/VerificationEmail.php index 41fa0bc31..73c4b6f30 100755 --- a/packages/Webkul/Customer/src/Mail/VerificationEmail.php +++ b/packages/Webkul/Customer/src/Mail/VerificationEmail.php @@ -32,7 +32,7 @@ class VerificationEmail extends Mailable { return $this->to($this->verificationData['email']) ->from(env('SHOP_MAIL_FROM')) - ->subject('Verification email') + ->subject(trans('shop::app.mail.customer.verification.subject')) ->view('shop::emails.customer.verification-email')->with('data', ['email' => $this->verificationData['email'], 'token' => $this->verificationData['token']]); } } \ No newline at end of file diff --git a/packages/Webkul/Discount/src/Helpers/Cart/ConvertXToProductId.php b/packages/Webkul/Discount/src/Helpers/Cart/ConvertXToProductId.php index 7aec6ea26..5a1b6b8fc 100644 --- a/packages/Webkul/Discount/src/Helpers/Cart/ConvertXToProductId.php +++ b/packages/Webkul/Discount/src/Helpers/Cart/ConvertXToProductId.php @@ -182,7 +182,7 @@ class ConvertXToProductId ])->flatten()->all(); } else if ($testCondition == '=') { $foundProducts = $this->product->findWhere([ - ['sku', '=', '%'.$testValue.'%'], + ['sku', '=', $testValue], ['type', '!=', 'configurable'] ])->flatten()->all(); } diff --git a/packages/Webkul/Discount/src/Helpers/Catalog/ConvertXToProductId.php b/packages/Webkul/Discount/src/Helpers/Catalog/ConvertXToProductId.php index a930ebc53..c6e4cd79a 100644 --- a/packages/Webkul/Discount/src/Helpers/Catalog/ConvertXToProductId.php +++ b/packages/Webkul/Discount/src/Helpers/Catalog/ConvertXToProductId.php @@ -171,7 +171,7 @@ class ConvertXToProductId ])->flatten()->all(); } else if ($testCondition == '=') { $foundProducts = $this->product->findWhere([ - ['sku', '=', '%' . $testValue . '%'], + ['sku', '=', $testValue], ['type', '!=', 'configurable'] ])->flatten()->all(); } diff --git a/packages/Webkul/Payment/src/Config/paymentmethods.php b/packages/Webkul/Payment/src/Config/paymentmethods.php index ec7ec7e56..0d78373ed 100755 --- a/packages/Webkul/Payment/src/Config/paymentmethods.php +++ b/packages/Webkul/Payment/src/Config/paymentmethods.php @@ -7,7 +7,7 @@ return [ 'class' => 'Webkul\Payment\Payment\CashOnDelivery', 'active' => true, 'sort' => 1, - 'default' => 'no' + 'default' => 'yes' ], 'moneytransfer' => [ @@ -17,7 +17,7 @@ return [ 'class' => 'Webkul\Payment\Payment\MoneyTransfer', 'active' => true, 'sort' => 2, - 'default' => 'yes' + 'default' => 'no' ], 'paypal_standard' => [ diff --git a/packages/Webkul/Paypal/src/Helpers/Ipn.php b/packages/Webkul/Paypal/src/Helpers/Ipn.php index 215a82063..8a0f7257c 100755 --- a/packages/Webkul/Paypal/src/Helpers/Ipn.php +++ b/packages/Webkul/Paypal/src/Helpers/Ipn.php @@ -105,9 +105,9 @@ class Ipn */ protected function processOrder() { - if ($this->post['payment_status'] == 'completed') { + if ($this->post['payment_status'] == 'Completed') { if ($this->post['mc_gross'] != $this->order->grand_total) { - + } else { $this->orderRepository->update(['status' => 'processing'], $this->order->id); diff --git a/packages/Webkul/Paypal/src/Http/routes.php b/packages/Webkul/Paypal/src/Http/routes.php index 8c0a20b6a..819e96b3f 100755 --- a/packages/Webkul/Paypal/src/Http/routes.php +++ b/packages/Webkul/Paypal/src/Http/routes.php @@ -8,9 +8,9 @@ Route::group(['middleware' => ['web']], function () { Route::get('/success', 'Webkul\Paypal\Http\Controllers\StandardController@success')->name('paypal.standard.success'); Route::get('/cancel', 'Webkul\Paypal\Http\Controllers\StandardController@cancel')->name('paypal.standard.cancel'); - - Route::get('/ipn', 'Webkul\Paypal\Http\Controllers\StandardController@ipn')->name('paypal.standard.ipn'); - - Route::post('/ipn', 'Webkul\Paypal\Http\Controllers\StandardController@ipn')->name('paypal.standard.ipn'); }); }); + +Route::get('paypal/standard/ipn', 'Webkul\Paypal\Http\Controllers\StandardController@ipn')->name('paypal.standard.ipn'); + +Route::post('paypal/standard/ipn', 'Webkul\Paypal\Http\Controllers\StandardController@ipn')->name('paypal.standard.ipn'); diff --git a/packages/Webkul/Product/src/Http/Controllers/ProductController.php b/packages/Webkul/Product/src/Http/Controllers/ProductController.php index 4996e6074..a173e3cbb 100755 --- a/packages/Webkul/Product/src/Http/Controllers/ProductController.php +++ b/packages/Webkul/Product/src/Http/Controllers/ProductController.php @@ -129,7 +129,7 @@ class ProductController extends Controller */ public function store() { - if (!request()->get('family') && request()->input('type') == 'configurable' && request()->input('sku') != '') { + if (! request()->get('family') && request()->input('type') == 'configurable' && request()->input('sku') != '') { return redirect(url()->current() . '?family=' . request()->input('attribute_family_id') . '&sku=' . request()->input('sku')); } diff --git a/packages/Webkul/Sales/src/Contracts/Refund.php b/packages/Webkul/Sales/src/Contracts/Refund.php new file mode 100755 index 000000000..c8e2a7902 --- /dev/null +++ b/packages/Webkul/Sales/src/Contracts/Refund.php @@ -0,0 +1,7 @@ +increments('id'); + $table->string('increment_id')->nullable(); + $table->string('state')->nullable(); + $table->boolean('email_sent')->default(0); + + $table->integer('total_qty')->nullable(); + + $table->string('base_currency_code')->nullable(); + $table->string('channel_currency_code')->nullable(); + $table->string('order_currency_code')->nullable(); + + $table->decimal('adjustment_refund', 12, 4)->default(0)->nullable(); + $table->decimal('base_adjustment_refund', 12, 4)->default(0)->nullable(); + + $table->decimal('adjustment_fee', 12, 4)->default(0)->nullable(); + $table->decimal('base_adjustment_fee', 12, 4)->default(0)->nullable(); + + $table->decimal('sub_total', 12, 4)->default(0)->nullable(); + $table->decimal('base_sub_total', 12, 4)->default(0)->nullable(); + + $table->decimal('grand_total', 12, 4)->default(0)->nullable(); + $table->decimal('base_grand_total', 12, 4)->default(0)->nullable(); + + $table->decimal('shipping_amount', 12, 4)->default(0)->nullable(); + $table->decimal('base_shipping_amount', 12, 4)->default(0)->nullable(); + + $table->decimal('tax_amount', 12, 4)->default(0)->nullable(); + $table->decimal('base_tax_amount', 12, 4)->default(0)->nullable(); + + $table->decimal('discount_percent', 12, 4)->default(0)->nullable(); + $table->decimal('discount_amount', 12, 4)->default(0)->nullable(); + $table->decimal('base_discount_amount', 12, 4)->default(0)->nullable(); + + $table->integer('order_id')->unsigned()->nullable(); + $table->foreign('order_id')->references('id')->on('orders')->onDelete('cascade'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('refunds'); + } +} diff --git a/packages/Webkul/Sales/src/Database/Migrations/2019_09_11_184519_create_refund_items_table.php b/packages/Webkul/Sales/src/Database/Migrations/2019_09_11_184519_create_refund_items_table.php new file mode 100644 index 000000000..d522f9987 --- /dev/null +++ b/packages/Webkul/Sales/src/Database/Migrations/2019_09_11_184519_create_refund_items_table.php @@ -0,0 +1,62 @@ +increments('id'); + $table->string('name')->nullable(); + $table->string('description')->nullable(); + $table->string('sku')->nullable(); + $table->integer('qty')->nullable(); + + $table->decimal('price', 12,4)->default(0); + $table->decimal('base_price', 12,4)->default(0); + + $table->decimal('total', 12,4)->default(0); + $table->decimal('base_total', 12,4)->default(0); + + $table->decimal('tax_amount', 12,4)->default(0)->nullable(); + $table->decimal('base_tax_amount', 12,4)->default(0)->nullable(); + + $table->decimal('discount_percent', 12, 4)->default(0)->nullable(); + $table->decimal('discount_amount', 12, 4)->default(0)->nullable(); + $table->decimal('base_discount_amount', 12, 4)->default(0)->nullable(); + + $table->integer('product_id')->unsigned()->nullable(); + $table->string('product_type')->nullable(); + + $table->integer('order_item_id')->unsigned()->nullable(); + $table->foreign('order_item_id')->references('id')->on('order_items')->onDelete('cascade'); + + $table->integer('refund_id')->unsigned()->nullable(); + $table->foreign('refund_id')->references('id')->on('refunds')->onDelete('cascade'); + + $table->integer('parent_id')->unsigned()->nullable(); + $table->foreign('parent_id')->references('id')->on('refund_items')->onDelete('cascade'); + + $table->json('additional')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('refund_items'); + } +} diff --git a/packages/Webkul/Sales/src/Models/Order.php b/packages/Webkul/Sales/src/Models/Order.php index d43a5f4d5..98f882c6a 100755 --- a/packages/Webkul/Sales/src/Models/Order.php +++ b/packages/Webkul/Sales/src/Models/Order.php @@ -74,6 +74,14 @@ class Order extends Model implements OrderContract { return $this->hasMany(InvoiceProxy::modelClass()); } + + /** + * Get the order refunds record associated with the order. + */ + public function refunds() + { + return $this->hasMany(RefundProxy::modelClass()); + } /** * Get the customer record associated with the order. @@ -148,9 +156,8 @@ class Order extends Model implements OrderContract return false; foreach ($this->items as $item) { - if ($item->qty_to_ship > 0) { + if ($item->qty_to_ship > 0) return true; - } } return false; @@ -165,16 +172,15 @@ class Order extends Model implements OrderContract return false; foreach ($this->items as $item) { - if ($item->qty_to_invoice > 0) { + if ($item->qty_to_invoice > 0) return true; - } } return false; } /** - * Checks if order could can canceled on not + * Checks if order can be canceled or not */ public function canCancel() { @@ -182,11 +188,29 @@ class Order extends Model implements OrderContract return false; foreach ($this->items as $item) { - if ($item->qty_to_cancel > 0) { + if ($item->qty_to_cancel > 0) return true; - } } return false; } + + /** + * Checks if order can be refunded or not + */ + public function canRefund() + { + if ($this->status == 'fraud') + return false; + + foreach ($this->items as $item) { + if ($item->qty_to_refund > 0) + return true; + } + + if ($this->base_grand_total_invoiced - $this->base_grand_total_refunded > 0) + return true; + + return false; + } } \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Models/OrderItem.php b/packages/Webkul/Sales/src/Models/OrderItem.php index f585d97c5..757f1634a 100755 --- a/packages/Webkul/Sales/src/Models/OrderItem.php +++ b/packages/Webkul/Sales/src/Models/OrderItem.php @@ -38,6 +38,14 @@ class OrderItem extends Model implements OrderItemContract return $this->qty_ordered - $this->qty_canceled - $this->qty_invoiced; } + /** + * Get remaining qty for refund. + */ + public function getQtyToRefundAttribute() + { + return $this->qty_invoiced - $this->qty_refunded; + } + /** * Get the order record associated with the order item. */ @@ -78,6 +86,14 @@ class OrderItem extends Model implements OrderItemContract return $this->hasMany(ShipmentItemProxy::modelClass()); } + /** + * Get the refund items record associated with the order item. + */ + public function refund_items() + { + return $this->hasMany(RefundItemProxy::modelClass()); + } + /** * Returns configurable option html */ @@ -94,4 +110,22 @@ class OrderItem extends Model implements OrderItemContract return implode(', ', $labels); } } + + /** + * @return array + */ + public function toArray() + { + $array = parent::toArray(); + + $array['qty_to_ship'] = $this->qty_to_ship; + + $array['qty_to_invoice'] = $this->qty_to_invoice; + + $array['qty_to_cancel'] = $this->qty_to_cancel; + + $array['qty_to_refund'] = $this->qty_to_refund; + + return $array; + } } \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Models/Refund.php b/packages/Webkul/Sales/src/Models/Refund.php new file mode 100644 index 000000000..fa6806ae1 --- /dev/null +++ b/packages/Webkul/Sales/src/Models/Refund.php @@ -0,0 +1,61 @@ +statusLabel[$this->state]) ? $this->statusLabel[$this->state] : ''; + } + + /** + * Get the order that belongs to the Refund. + */ + public function order() + { + return $this->belongsTo(OrderProxy::modelClass()); + } + + /** + * Get the Refund items record associated with the Refund. + */ + public function items() { + return $this->hasMany(RefundItemProxy::modelClass())->whereNull('parent_id'); + } + + /** + * Get the customer record associated with the Refund. + */ + public function customer() + { + return $this->morphTo(); + } + + /** + * Get the channel record associated with the Refund. + */ + public function channel() + { + return $this->morphTo(); + } + + /** + * Get the addresses for the shipment. + */ + public function address() + { + return $this->belongsTo(OrderAddressProxy::modelClass(), 'order_address_id'); + } +} \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Models/RefundItem.php b/packages/Webkul/Sales/src/Models/RefundItem.php new file mode 100644 index 000000000..6285e2591 --- /dev/null +++ b/packages/Webkul/Sales/src/Models/RefundItem.php @@ -0,0 +1,64 @@ + 'array', + ]; + + /** + * Get the Refund record associated with the Refund item. + */ + public function refund() + { + return $this->belongsTo(RefundProxy::modelClass()); + } + + /** + * Get the order item record associated with the Refund item. + */ + public function order_item() + { + return $this->belongsTo(OrderItemProxy::modelClass()); + } + + /** + * Get the Refund record associated with the Refund item. + */ + public function product() + { + return $this->morphTo(); + } + + /** + * Get the child item record associated with the Refund item. + */ + public function child() + { + return $this->hasOne(RefundItemProxy::modelClass(), 'parent_id'); + } + + /** + * Returns configurable option html + */ + public function getOptionDetailHtml() + { + + if ($this->type == 'configurable' && isset($this->additional['attributes'])) { + $labels = []; + + foreach ($this->additional['attributes'] as $attribute) { + $labels[] = $attribute['attribute_name'] . ' : ' . $attribute['option_label']; + } + + return implode(', ', $labels); + } + } +} \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Models/RefundItemProxy.php b/packages/Webkul/Sales/src/Models/RefundItemProxy.php new file mode 100644 index 000000000..fcfdf495b --- /dev/null +++ b/packages/Webkul/Sales/src/Models/RefundItemProxy.php @@ -0,0 +1,10 @@ +order->shipping_amount) { foreach ($invoice->order->invoices as $prevInvoice) { - if ((float) $prevInvoice->shipping_amount) { - $shippingAmount = 0; - $baseShippingAmount = 0; - } + if ((float) $prevInvoice->shipping_amount) + $shippingAmount = $baseShippingAmount = 0; } } diff --git a/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php b/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php index f01c22201..0ccd5adb6 100755 --- a/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php +++ b/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php @@ -47,9 +47,13 @@ class OrderItemRepository extends Repository */ public function collectTotals($orderItem) { - $qtyShipped = $qtyInvoiced = 0; + $qtyShipped = $qtyInvoiced = $qtyRefunded = 0; + $totalInvoiced = $baseTotalInvoiced = 0; $taxInvoiced = $baseTaxInvoiced = 0; + + $totalRefunded = $baseTotalRefunded = 0; + $taxRefunded = $baseTaxRefunded = 0; foreach ($orderItem->invoice_items as $invoiceItem) { $qtyInvoiced += $invoiceItem->qty; @@ -65,8 +69,19 @@ class OrderItemRepository extends Repository $qtyShipped += $shipmentItem->qty; } + foreach ($orderItem->refund_items as $refundItem) { + $qtyRefunded += $refundItem->qty; + + $totalRefunded += $refundItem->total; + $baseTotalRefunded += $refundItem->base_total; + + $taxRefunded += $refundItem->tax_amount; + $baseTaxRefunded += $refundItem->base_tax_amount; + } + $orderItem->qty_shipped = $qtyShipped; $orderItem->qty_invoiced = $qtyInvoiced; + $orderItem->qty_refunded = $qtyRefunded; $orderItem->total_invoiced = $totalInvoiced; $orderItem->base_total_invoiced = $baseTotalInvoiced; @@ -74,6 +89,12 @@ class OrderItemRepository extends Repository $orderItem->tax_amount_invoiced = $taxInvoiced; $orderItem->base_tax_amount_invoiced = $baseTaxInvoiced; + $orderItem->amount_refunded = $totalRefunded; + $orderItem->base_amount_refunded = $baseTotalRefunded; + + $orderItem->tax_amount_refunded = $taxRefunded; + $orderItem->base_tax_amount_refunded = $baseTaxRefunded; + $orderItem->save(); return $orderItem; diff --git a/packages/Webkul/Sales/src/Repositories/OrderRepository.php b/packages/Webkul/Sales/src/Repositories/OrderRepository.php index e3941aa84..86c370d54 100755 --- a/packages/Webkul/Sales/src/Repositories/OrderRepository.php +++ b/packages/Webkul/Sales/src/Repositories/OrderRepository.php @@ -149,6 +149,7 @@ class OrderRepository extends Repository public function generateIncrementId() { $config = new CoreConfig(); + $invoiceNumberPrefix = $config->where('code','=',"sales.invoiceSettings.invoice_number.invoice_number_prefix")->first() ? $config->where('code','=',"sales.invoiceSettings.invoice_number.invoice_number_prefix")->first()->value : false; $invoiceNumberLength = $config->where('code','=',"sales.invoiceSettings.invoice_number.invoice_number_length")->first() @@ -159,11 +160,9 @@ class OrderRepository extends Repository $lastOrder = $this->model->orderBy('id', 'desc')->limit(1)->first(); $lastId = $lastOrder ? $lastOrder->id : 0; - if($invoiceNumberLength && ( $invoiceNumberPrefix || $invoiceNumberSuffix) ){ - - $invoiceNumber = $invoiceNumberPrefix . sprintf("%0{$invoiceNumberLength}d", $lastId + 1) . $invoiceNumberSuffix; - } - else{ + if ($invoiceNumberLength && ( $invoiceNumberPrefix || $invoiceNumberSuffix) ) { + $invoiceNumber = $invoiceNumberPrefix . sprintf("%0{$invoiceNumberLength}d", 0) . ($lastId + 1) . $invoiceNumberSuffix; + } else { $invoiceNumber = $lastId + 1; } @@ -287,6 +286,32 @@ class OrderRepository extends Repository $order->grand_total_invoiced = $order->sub_total_invoiced + $order->shipping_invoiced + $order->tax_amount_invoiced - $order->discount_invoiced; $order->base_grand_total_invoiced = $order->base_sub_total_invoiced + $order->base_shipping_invoiced + $order->base_tax_amount_invoiced - $order->base_discount_invoiced; + + $order->sub_total_refunded = $order->base_sub_total_refunded = 0; + $order->shipping_refunded = $order->base_shipping_refunded = 0; + $order->tax_amount_refunded = $order->base_tax_amount_refunded = 0; + $order->grand_total_refunded = $order->base_grand_total_refunded = 0; + + foreach ($order->refunds as $refund) { + $order->sub_total_refunded += $refund->sub_total; + $order->base_sub_total_refunded += $refund->base_sub_total; + + $order->shipping_refunded += $refund->shipping_amount; + $order->base_shipping_refunded += $refund->base_shipping_amount; + + $order->tax_amount_refunded += $refund->tax_amount; + $order->base_tax_amount_refunded += $refund->base_tax_amount; + + $order->discount_refunded += $refund->discount_amount; + $order->base_discount_refunded += $refund->base_discount_amount; + + $order->grand_total_refunded += $refund->adjustment_refund - $refund->adjustment_fee; + $order->base_grand_total_refunded += $refund->base_adjustment_refund - $refund->base_adjustment_fee; + } + + $order->grand_total_refunded += $order->sub_total_refunded + $order->shipping_refunded + $order->tax_amount_refunded - $order->discount_refunded; + $order->base_grand_total_refunded += $order->base_sub_total_refunded + $order->base_shipping_refunded + $order->base_tax_amount_refunded - $order->base_discount_refunded; + $order->save(); return $order; diff --git a/packages/Webkul/Sales/src/Repositories/RefundItemRepository.php b/packages/Webkul/Sales/src/Repositories/RefundItemRepository.php new file mode 100644 index 000000000..31eaa9405 --- /dev/null +++ b/packages/Webkul/Sales/src/Repositories/RefundItemRepository.php @@ -0,0 +1,28 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ + +class RefundItemRepository extends Repository +{ + /** + * Specify Model class name + * + * @return Mixed + */ + + function model() + { + return RefundItem::class; + } +} \ No newline at end of file diff --git a/packages/Webkul/Sales/src/Repositories/RefundRepository.php b/packages/Webkul/Sales/src/Repositories/RefundRepository.php new file mode 100644 index 000000000..505daf786 --- /dev/null +++ b/packages/Webkul/Sales/src/Repositories/RefundRepository.php @@ -0,0 +1,261 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ +class RefundRepository extends Repository +{ + /** + * OrderRepository object + * + * @var Object + */ + protected $orderRepository; + + /** + * OrderItemRepository object + * + * @var Object + */ + protected $orderItemRepository; + + /** + * RefundItemRepository object + * + * @var Object + */ + protected $refundItemRepository; + + /** + * Create a new repository instance. + * + * @param \Webkul\Sales\Repositories\OrderRepository $orderRepository + * @param \Webkul\Sales\Repositories\OrderItemRepository $orderItemRepository + * @param \Webkul\Sales\Repositories\RefundItemRepository $refundItemRepository + * @param \Illuminate\Container\Container $app + */ + public function __construct( + OrderRepository $orderRepository, + OrderItemRepository $orderItemRepository, + RefundItemRepository $refundItemRepository, + App $app + ) + { + $this->orderRepository = $orderRepository; + + $this->orderItemRepository = $orderItemRepository; + + $this->refundItemRepository = $refundItemRepository; + + parent::__construct($app); + } + + /** + * Specify Model class name + * + * @return Mixed + */ + function model() + { + return Refund::class; + } + + /** + * @param array $data + * @return mixed + */ + public function create(array $data) + { + DB::beginTransaction(); + + try { + Event::fire('sales.refund.save.before', $data); + + $order = $this->orderRepository->find($data['order_id']); + + $totalQty = array_sum($data['refund']['items']); + + $refund = parent::create([ + 'order_id' => $order->id, + 'total_qty' => $totalQty, + 'state' => 'refunded', + 'base_currency_code' => $order->base_currency_code, + 'channel_currency_code' => $order->channel_currency_code, + 'order_currency_code' => $order->order_currency_code, + 'adjustment_refund' => core()->convertPrice($data['refund']['adjustment_refund'], $order->order_currency_code), + 'base_adjustment_refund' => $data['refund']['adjustment_refund'], + 'adjustment_fee' => core()->convertPrice($data['refund']['adjustment_fee'], $order->order_currency_code), + 'base_adjustment_fee' => $data['refund']['adjustment_fee'], + 'shipping_amount' => core()->convertPrice($data['refund']['shipping'], $order->order_currency_code), + 'base_shipping_amount' => $data['refund']['shipping'] + ]); + + foreach ($data['refund']['items'] as $itemId => $qty) { + if (! $qty) + continue; + + $orderItem = $this->orderItemRepository->find($itemId); + + if ($qty > $orderItem->qty_to_refund) + $qty = $orderItem->qty_to_refund; + + $refundItem = $this->refundItemRepository->create([ + 'refund_id' => $refund->id, + 'order_item_id' => $orderItem->id, + 'name' => $orderItem->name, + 'sku' => $orderItem->sku, + 'qty' => $qty, + 'price' => $orderItem->price, + 'base_price' => $orderItem->base_price, + 'total' => $orderItem->price * $qty, + 'base_total' => $orderItem->base_price * $qty, + 'tax_amount' => ( ($orderItem->tax_amount / $orderItem->qty_ordered) * $qty ), + 'base_tax_amount' => ( ($orderItem->base_tax_amount / $orderItem->qty_ordered) * $qty ), + 'discount_amount' => ( ($orderItem->discount_amount / $orderItem->qty_ordered) * $qty ), + 'base_discount_amount' => ( ($orderItem->base_discount_amount / $orderItem->qty_ordered) * $qty ), + 'product_id' => $orderItem->product_id, + 'product_type' => $orderItem->product_type, + 'additional' => $orderItem->additional + ]); + + if ($orderItem->type == 'configurable' && $orderItem->child) { + $childOrderItem = $orderItem->child; + + $refundItem->child = $this->refundItemRepository->create([ + 'refund_id' => $refund->id, + 'order_item_id' => $childOrderItem->id, + 'parent_id' => $refundItem->id, + 'name' => $childOrderItem->name, + 'sku' => $childOrderItem->sku, + 'qty' => $qty, + 'price' => $childOrderItem->price, + 'base_price' => $childOrderItem->base_price, + 'total' => $childOrderItem->price * $qty, + 'base_total' => $childOrderItem->base_price * $qty, + 'tax_amount' => 0, + 'base_tax_amount' => 0, + 'discount_amount' => 0, + 'base_discount_amount' => 0, + 'product_id' => $childOrderItem->product_id, + 'product_type' => $childOrderItem->product_type, + 'additional' => $childOrderItem->additional + ]); + } + + $this->orderItemRepository->collectTotals($orderItem); + } + + $this->collectTotals($refund); + + $this->orderRepository->collectTotals($order); + + $this->orderRepository->updateOrderStatus($order); + + Event::fire('sales.refund.save.after', $refund); + } catch (\Exception $e) { + DB::rollBack(); + + throw $e; + } + + DB::commit(); + + return $refund; + } + + /** + * @param Refund $refund + * @return mixed + */ + public function collectTotals($refund) + { + $subTotal = $baseSubTotal = 0; + $taxAmount = $baseTaxAmount = 0; + $discountAmount = $baseDiscountAmount = 0; + + foreach ($refund->items as $refundItem) { + $subTotal += $refundItem->total; + $baseSubTotal += $refundItem->base_total; + + $taxAmount += $refundItem->tax_amount; + $baseTaxAmount += $refundItem->base_tax_amount; + + $discountAmount += $refundItem->discount_amount; + $baseDiscountAmount += $refundItem->base_discount_amount; + } + + $refund->sub_total = $subTotal; + $refund->base_sub_total = $baseSubTotal; + + $refund->tax_amount = $taxAmount; + $refund->base_tax_amount = $baseTaxAmount; + + $refund->grand_total = $subTotal + $taxAmount + $refund->shipping_amount + $refund->adjustment_refund - $refund->adjustment_fee - $discountAmount; + $refund->base_grand_total = $baseSubTotal + $baseTaxAmount + $refund->base_shipping_amount + $refund->base_adjustment_refund - $refund->adjustment_fee - $baseDiscountAmount; + + $refund->save(); + + return $refund; + } + + /** + * @param array $data + * @param integer $orderId + * @return array + */ + public function getOrderItemsRefundSummary($data, $orderId) + { + $order = $this->orderRepository->find($orderId); + + $summary = [ + 'subtotal' => ['price' => 0], + 'discount' => ['price' => 0], + 'tax' => ['price' => 0], + 'shipping' => ['price' => 0], + 'grand_total' => ['price' => 0] + ]; + + foreach ($data as $orderItemId => $qty) { + if (! $qty) + continue; + + $orderItem = $this->orderItemRepository->find($orderItemId); + + if ($qty > $orderItem->qty_to_refund) + return false; + + $summary['subtotal']['price'] += $orderItem->base_price * $qty; + + $summary['discount']['price'] += ($orderItem->base_discount_amount / $orderItem->qty_ordered) * $qty; + + $summary['tax']['price'] += ($orderItem->tax_amount / $orderItem->qty_ordered) * $qty; + } + + $summary['shipping']['price'] += $order->base_shipping_invoiced - $order->base_shipping_refunded; + + $summary['grand_total']['price'] += $summary['subtotal']['price'] + $summary['tax']['price'] + $summary['shipping']['price'] - $summary['discount']['price']; + + $summary['subtotal']['formated_price'] = core()->formatBasePrice($summary['subtotal']['price']); + + $summary['discount']['formated_price'] = core()->formatBasePrice($summary['discount']['price']); + + $summary['tax']['formated_price'] = core()->formatBasePrice($summary['tax']['price']); + + $summary['shipping']['formated_price'] = core()->formatBasePrice($summary['shipping']['price']); + + $summary['grand_total']['formated_price'] = core()->formatBasePrice($summary['grand_total']['price']); + + return $summary; + } +} \ No newline at end of file diff --git a/packages/Webkul/Shop/publishable/assets/js/shop.js b/packages/Webkul/Shop/publishable/assets/js/shop.js index 470e08dad..aff7a0b79 100755 --- a/packages/Webkul/Shop/publishable/assets/js/shop.js +++ b/packages/Webkul/Shop/publishable/assets/js/shop.js @@ -1 +1 @@ -!function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=0)}({0:function(e,t,n){n("J66Q"),e.exports=n("MT9B")},"162o":function(e,t,n){(function(e){var i=void 0!==e&&e||"undefined"!=typeof self&&self||window,r=Function.prototype.apply;function o(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new o(r.call(setTimeout,i,arguments),clearTimeout)},t.setInterval=function(){return new o(r.call(setInterval,i,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(i,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n("mypn"),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(t,n("DuR2"))},"21It":function(e,t,n){"use strict";var i=n("FtD3");e.exports=function(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(i("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},"4TI/":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={props:{slides:{type:Array,required:!0,default:function(){return[]}},public_path:{type:String,required:!0}},data:function(){return{images:[],currentIndex:-1,content:[],current:!1,images_loaded:!1}},mounted:function(){this.getProps()},methods:{getProps:function(){this.setProps()},setProps:function(){var e=this;this.slides.forEach(function(t){e.images.push(e.public_path+"/storage/"+t.path),e.content.push(t.content)}),this.currentIndex=0,0==this.images.length?this.images.push="vendor/webkul/shop/assets/images/banner.png":this.images_loaded=!0},changeIndexLeft:function(){this.currentIndex>0?this.currentIndex--:0==this.currentIndex&&(this.currentIndex=this.images.length-1)},changeIndexRight:function(){this.currentIndex0&&t-1 in e)}_.fn=_.prototype={jquery:"3.4.1",constructor:_,length:0,toArray:function(){return l.call(this)},get:function(e){return null==e?l.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=_.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return _.each(this,e)},map:function(e){return this.pushStack(_.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(l.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n+~]|"+j+")"+j+"*"),V=new RegExp(j+"|>"),U=new RegExp(H),Y=new RegExp("^"+F+"$"),Z={ID:new RegExp("^#("+F+")"),CLASS:new RegExp("^\\.("+F+")"),TAG:new RegExp("^("+F+"|[*])"),ATTR:new RegExp("^"+I),PSEUDO:new RegExp("^"+H),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+j+"*(even|odd|(([+-]|)(\\d*)n|)"+j+"*(?:([+-]|)"+j+"*(\\d+)|))"+j+"*\\)|)","i"),bool:new RegExp("^(?:"+N+")$","i"),needsContext:new RegExp("^"+j+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+j+"*((?:-\\d)?\\d*)"+j+"*\\)|)(?=[^-]|$)","i")},G=/HTML$/i,X=/^(?:input|select|textarea|button)$/i,K=/^h\d$/i,J=/^[^{]+\{\s*\[native \w/,Q=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\([\\da-f]{1,6}"+j+"?|("+j+")|.)","ig"),ne=function(e,t,n){var i="0x"+t-65536;return i!=i||n?t:i<0?String.fromCharCode(i+65536):String.fromCharCode(i>>10|55296,1023&i|56320)},ie=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,re=function(e,t){return t?"\0"===e?"�":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){f()},se=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{E.apply(D=W.call(x.childNodes),x.childNodes),D[x.childNodes.length].nodeType}catch(e){E={apply:D.length?function(e,t){L.apply(e,W.call(t))}:function(e,t){for(var n=e.length,i=0;e[n++]=t[i++];);e.length=n-1}}}function ae(e,t,i,r){var o,a,u,c,d,p,g,y=t&&t.ownerDocument,T=t?t.nodeType:9;if(i=i||[],"string"!=typeof e||!e||1!==T&&9!==T&&11!==T)return i;if(!r&&((t?t.ownerDocument||t:x)!==h&&f(t),t=t||h,v)){if(11!==T&&(d=Q.exec(e)))if(o=d[1]){if(9===T){if(!(u=t.getElementById(o)))return i;if(u.id===o)return i.push(u),i}else if(y&&(u=y.getElementById(o))&&w(t,u)&&u.id===o)return i.push(u),i}else{if(d[2])return E.apply(i,t.getElementsByTagName(e)),i;if((o=d[3])&&n.getElementsByClassName&&t.getElementsByClassName)return E.apply(i,t.getElementsByClassName(o)),i}if(n.qsa&&!$[e+" "]&&(!m||!m.test(e))&&(1!==T||"object"!==t.nodeName.toLowerCase())){if(g=e,y=t,1===T&&V.test(e)){for((c=t.getAttribute("id"))?c=c.replace(ie,re):t.setAttribute("id",c=b),a=(p=s(e)).length;a--;)p[a]="#"+c+" "+we(p[a]);g=p.join(","),y=ee.test(e)&&ge(t.parentNode)||t}try{return E.apply(i,y.querySelectorAll(g)),i}catch(t){$(e,!0)}finally{c===b&&t.removeAttribute("id")}}}return l(e.replace(P,"$1"),t,i,r)}function le(){var e=[];return function t(n,r){return e.push(n+" ")>i.cacheLength&&delete t[e.shift()],t[n+" "]=r}}function ue(e){return e[b]=!0,e}function ce(e){var t=h.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function de(e,t){for(var n=e.split("|"),r=n.length;r--;)i.attrHandle[n[r]]=t}function fe(e,t){var n=t&&e,i=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(i)return i;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function he(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}function pe(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function ve(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&se(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function me(e){return ue(function(t){return t=+t,ue(function(n,i){for(var r,o=e([],n.length,t),s=o.length;s--;)n[r=o[s]]&&(n[r]=!(i[r]=n[r]))})})}function ge(e){return e&&void 0!==e.getElementsByTagName&&e}for(t in n=ae.support={},o=ae.isXML=function(e){var t=e.namespaceURI,n=(e.ownerDocument||e).documentElement;return!G.test(t||n&&n.nodeName||"HTML")},f=ae.setDocument=function(e){var t,r,s=e?e.ownerDocument||e:x;return s!==h&&9===s.nodeType&&s.documentElement?(p=(h=s).documentElement,v=!o(h),x!==h&&(r=h.defaultView)&&r.top!==r&&(r.addEventListener?r.addEventListener("unload",oe,!1):r.attachEvent&&r.attachEvent("onunload",oe)),n.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),n.getElementsByTagName=ce(function(e){return e.appendChild(h.createComment("")),!e.getElementsByTagName("*").length}),n.getElementsByClassName=J.test(h.getElementsByClassName),n.getById=ce(function(e){return p.appendChild(e).id=b,!h.getElementsByName||!h.getElementsByName(b).length}),n.getById?(i.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},i.find.ID=function(e,t){if(void 0!==t.getElementById&&v){var n=t.getElementById(e);return n?[n]:[]}}):(i.filter.ID=function(e){var t=e.replace(te,ne);return function(e){var n=void 0!==e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}},i.find.ID=function(e,t){if(void 0!==t.getElementById&&v){var n,i,r,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];for(r=t.getElementsByName(e),i=0;o=r[i++];)if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),i.find.TAG=n.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):n.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,i=[],r=0,o=t.getElementsByTagName(e);if("*"===e){for(;n=o[r++];)1===n.nodeType&&i.push(n);return i}return o},i.find.CLASS=n.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&v)return t.getElementsByClassName(e)},g=[],m=[],(n.qsa=J.test(h.querySelectorAll))&&(ce(function(e){p.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&m.push("[*^$]="+j+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||m.push("\\["+j+"*(?:value|"+N+")"),e.querySelectorAll("[id~="+b+"-]").length||m.push("~="),e.querySelectorAll(":checked").length||m.push(":checked"),e.querySelectorAll("a#"+b+"+*").length||m.push(".#.+[+~]")}),ce(function(e){e.innerHTML="";var t=h.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&m.push("name"+j+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&m.push(":enabled",":disabled"),p.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&m.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),m.push(",.*:")})),(n.matchesSelector=J.test(y=p.matches||p.webkitMatchesSelector||p.mozMatchesSelector||p.oMatchesSelector||p.msMatchesSelector))&&ce(function(e){n.disconnectedMatch=y.call(e,"*"),y.call(e,"[s!='']:x"),g.push("!=",H)}),m=m.length&&new RegExp(m.join("|")),g=g.length&&new RegExp(g.join("|")),t=J.test(p.compareDocumentPosition),w=t||J.test(p.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,i=t&&t.parentNode;return e===i||!(!i||1!==i.nodeType||!(n.contains?n.contains(i):e.compareDocumentPosition&&16&e.compareDocumentPosition(i)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},A=t?function(e,t){if(e===t)return d=!0,0;var i=!e.compareDocumentPosition-!t.compareDocumentPosition;return i||(1&(i=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!n.sortDetached&&t.compareDocumentPosition(e)===i?e===h||e.ownerDocument===x&&w(x,e)?-1:t===h||t.ownerDocument===x&&w(x,t)?1:c?M(c,e)-M(c,t):0:4&i?-1:1)}:function(e,t){if(e===t)return d=!0,0;var n,i=0,r=e.parentNode,o=t.parentNode,s=[e],a=[t];if(!r||!o)return e===h?-1:t===h?1:r?-1:o?1:c?M(c,e)-M(c,t):0;if(r===o)return fe(e,t);for(n=e;n=n.parentNode;)s.unshift(n);for(n=t;n=n.parentNode;)a.unshift(n);for(;s[i]===a[i];)i++;return i?fe(s[i],a[i]):s[i]===x?-1:a[i]===x?1:0},h):h},ae.matches=function(e,t){return ae(e,null,null,t)},ae.matchesSelector=function(e,t){if((e.ownerDocument||e)!==h&&f(e),n.matchesSelector&&v&&!$[t+" "]&&(!g||!g.test(t))&&(!m||!m.test(t)))try{var i=y.call(e,t);if(i||n.disconnectedMatch||e.document&&11!==e.document.nodeType)return i}catch(e){$(t,!0)}return ae(t,h,null,[e]).length>0},ae.contains=function(e,t){return(e.ownerDocument||e)!==h&&f(e),w(e,t)},ae.attr=function(e,t){(e.ownerDocument||e)!==h&&f(e);var r=i.attrHandle[t.toLowerCase()],o=r&&k.call(i.attrHandle,t.toLowerCase())?r(e,t,!v):void 0;return void 0!==o?o:n.attributes||!v?e.getAttribute(t):(o=e.getAttributeNode(t))&&o.specified?o.value:null},ae.escape=function(e){return(e+"").replace(ie,re)},ae.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},ae.uniqueSort=function(e){var t,i=[],r=0,o=0;if(d=!n.detectDuplicates,c=!n.sortStable&&e.slice(0),e.sort(A),d){for(;t=e[o++];)t===e[o]&&(r=i.push(o));for(;r--;)e.splice(i[r],1)}return c=null,e},r=ae.getText=function(e){var t,n="",i=0,o=e.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=r(e)}else if(3===o||4===o)return e.nodeValue}else for(;t=e[i++];)n+=r(t);return n},(i=ae.selectors={cacheLength:50,createPseudo:ue,match:Z,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||ae.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&ae.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return Z.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&U.test(n)&&(t=s(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=S[e+" "];return t||(t=new RegExp("(^|"+j+")"+e+"("+j+"|$)"))&&S(e,function(e){return t.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(i){var r=ae.attr(i,e);return null==r?"!="===t:!t||(r+="","="===t?r===n:"!="===t?r!==n:"^="===t?n&&0===r.indexOf(n):"*="===t?n&&r.indexOf(n)>-1:"$="===t?n&&r.slice(-n.length)===n:"~="===t?(" "+r.replace(R," ")+" ").indexOf(n)>-1:"|="===t&&(r===n||r.slice(0,n.length+1)===n+"-"))}},CHILD:function(e,t,n,i,r){var o="nth"!==e.slice(0,3),s="last"!==e.slice(-4),a="of-type"===t;return 1===i&&0===r?function(e){return!!e.parentNode}:function(t,n,l){var u,c,d,f,h,p,v=o!==s?"nextSibling":"previousSibling",m=t.parentNode,g=a&&t.nodeName.toLowerCase(),y=!l&&!a,w=!1;if(m){if(o){for(;v;){for(f=t;f=f[v];)if(a?f.nodeName.toLowerCase()===g:1===f.nodeType)return!1;p=v="only"===e&&!p&&"nextSibling"}return!0}if(p=[s?m.firstChild:m.lastChild],s&&y){for(w=(h=(u=(c=(d=(f=m)[b]||(f[b]={}))[f.uniqueID]||(d[f.uniqueID]={}))[e]||[])[0]===T&&u[1])&&u[2],f=h&&m.childNodes[h];f=++h&&f&&f[v]||(w=h=0)||p.pop();)if(1===f.nodeType&&++w&&f===t){c[e]=[T,h,w];break}}else if(y&&(w=h=(u=(c=(d=(f=t)[b]||(f[b]={}))[f.uniqueID]||(d[f.uniqueID]={}))[e]||[])[0]===T&&u[1]),!1===w)for(;(f=++h&&f&&f[v]||(w=h=0)||p.pop())&&((a?f.nodeName.toLowerCase()!==g:1!==f.nodeType)||!++w||(y&&((c=(d=f[b]||(f[b]={}))[f.uniqueID]||(d[f.uniqueID]={}))[e]=[T,w]),f!==t)););return(w-=r)===i||w%i==0&&w/i>=0}}},PSEUDO:function(e,t){var n,r=i.pseudos[e]||i.setFilters[e.toLowerCase()]||ae.error("unsupported pseudo: "+e);return r[b]?r(t):r.length>1?(n=[e,e,"",t],i.setFilters.hasOwnProperty(e.toLowerCase())?ue(function(e,n){for(var i,o=r(e,t),s=o.length;s--;)e[i=M(e,o[s])]=!(n[i]=o[s])}):function(e){return r(e,0,n)}):r}},pseudos:{not:ue(function(e){var t=[],n=[],i=a(e.replace(P,"$1"));return i[b]?ue(function(e,t,n,r){for(var o,s=i(e,null,r,[]),a=e.length;a--;)(o=s[a])&&(e[a]=!(t[a]=o))}):function(e,r,o){return t[0]=e,i(t,null,o,n),t[0]=null,!n.pop()}}),has:ue(function(e){return function(t){return ae(e,t).length>0}}),contains:ue(function(e){return e=e.replace(te,ne),function(t){return(t.textContent||r(t)).indexOf(e)>-1}}),lang:ue(function(e){return Y.test(e||"")||ae.error("unsupported lang: "+e),e=e.replace(te,ne).toLowerCase(),function(t){var n;do{if(n=v?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(n=n.toLowerCase())===e||0===n.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===p},focus:function(e){return e===h.activeElement&&(!h.hasFocus||h.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:ve(!1),disabled:ve(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!i.pseudos.empty(e)},header:function(e){return K.test(e.nodeName)},input:function(e){return X.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:me(function(){return[0]}),last:me(function(e,t){return[t-1]}),eq:me(function(e,t,n){return[n<0?n+t:n]}),even:me(function(e,t){for(var n=0;nt?t:n;--i>=0;)e.push(i);return e}),gt:me(function(e,t,n){for(var i=n<0?n+t:n;++i1?function(t,n,i){for(var r=e.length;r--;)if(!e[r](t,n,i))return!1;return!0}:e[0]}function Te(e,t,n,i,r){for(var o,s=[],a=0,l=e.length,u=null!=t;a-1&&(o[u]=!(s[u]=d))}}else g=Te(g===s?g.splice(p,g.length):g),r?r(null,s,g,l):E.apply(s,g)})}function Se(e){for(var t,n,r,o=e.length,s=i.relative[e[0].type],a=s||i.relative[" "],l=s?1:0,c=be(function(e){return e===t},a,!0),d=be(function(e){return M(t,e)>-1},a,!0),f=[function(e,n,i){var r=!s&&(i||n!==u)||((t=n).nodeType?c(e,n,i):d(e,n,i));return t=null,r}];l1&&xe(f),l>1&&we(e.slice(0,l-1).concat({value:" "===e[l-2].type?"*":""})).replace(P,"$1"),n,l0,r=e.length>0,o=function(o,s,a,l,c){var d,p,m,g=0,y="0",w=o&&[],b=[],x=u,_=o||r&&i.find.TAG("*",c),S=T+=null==x?1:Math.random()||.1,C=_.length;for(c&&(u=s===h||s||c);y!==C&&null!=(d=_[y]);y++){if(r&&d){for(p=0,s||d.ownerDocument===h||(f(d),a=!v);m=e[p++];)if(m(d,s||h,a)){l.push(d);break}c&&(T=S)}n&&((d=!m&&d)&&g--,o&&w.push(d))}if(g+=y,n&&y!==g){for(p=0;m=t[p++];)m(w,b,s,a);if(o){if(g>0)for(;y--;)w[y]||b[y]||(b[y]=O.call(l));b=Te(b)}E.apply(l,b),c&&!o&&b.length>0&&g+t.length>1&&ae.uniqueSort(l)}return c&&(T=S,u=x),w};return n?ue(o):o}(o,r))).selector=e}return a},l=ae.select=function(e,t,n,r){var o,l,u,c,d,f="function"==typeof e&&e,h=!r&&s(e=f.selector||e);if(n=n||[],1===h.length){if((l=h[0]=h[0].slice(0)).length>2&&"ID"===(u=l[0]).type&&9===t.nodeType&&v&&i.relative[l[1].type]){if(!(t=(i.find.ID(u.matches[0].replace(te,ne),t)||[])[0]))return n;f&&(t=t.parentNode),e=e.slice(l.shift().value.length)}for(o=Z.needsContext.test(e)?0:l.length;o--&&(u=l[o],!i.relative[c=u.type]);)if((d=i.find[c])&&(r=d(u.matches[0].replace(te,ne),ee.test(l[0].type)&&ge(t.parentNode)||t))){if(l.splice(o,1),!(e=r.length&&we(l)))return E.apply(n,r),n;break}}return(f||a(e,h))(r,t,!v,n,!t||ee.test(e)&&ge(t.parentNode)||t),n},n.sortStable=b.split("").sort(A).join("")===b,n.detectDuplicates=!!d,f(),n.sortDetached=ce(function(e){return 1&e.compareDocumentPosition(h.createElement("fieldset"))}),ce(function(e){return e.innerHTML="","#"===e.firstChild.getAttribute("href")})||de("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),n.attributes&&ce(function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||de("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),ce(function(e){return null==e.getAttribute("disabled")})||de(N,function(e,t,n){var i;if(!n)return!0===e[t]?t.toLowerCase():(i=e.getAttributeNode(t))&&i.specified?i.value:null}),ae}(n);_.find=z,_.expr=z.selectors,_.expr[":"]=_.expr.pseudos,_.uniqueSort=_.unique=z.uniqueSort,_.text=z.getText,_.isXMLDoc=z.isXML,_.contains=z.contains,_.escapeSelector=z.escape;var $=function(e,t,n){for(var i=[],r=void 0!==n;(e=e[t])&&9!==e.nodeType;)if(1===e.nodeType){if(r&&_(e).is(n))break;i.push(e)}return i},A=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},k=_.expr.match.needsContext;function D(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var O=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function L(e,t,n){return y(t)?_.grep(e,function(e,i){return!!t.call(e,i,e)!==n}):t.nodeType?_.grep(e,function(e){return e===t!==n}):"string"!=typeof t?_.grep(e,function(e){return d.call(t,e)>-1!==n}):_.filter(t,e,n)}_.filter=function(e,t,n){var i=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===i.nodeType?_.find.matchesSelector(i,e)?[i]:[]:_.find.matches(e,_.grep(t,function(e){return 1===e.nodeType}))},_.fn.extend({find:function(e){var t,n,i=this.length,r=this;if("string"!=typeof e)return this.pushStack(_(e).filter(function(){for(t=0;t1?_.uniqueSort(n):n},filter:function(e){return this.pushStack(L(this,e||[],!1))},not:function(e){return this.pushStack(L(this,e||[],!0))},is:function(e){return!!L(this,"string"==typeof e&&k.test(e)?_(e):e||[],!1).length}});var E,W=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(_.fn.init=function(e,t,n){var i,r;if(!e)return this;if(n=n||E,"string"==typeof e){if(!(i="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:W.exec(e))||!i[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(i[1]){if(t=t instanceof _?t[0]:t,_.merge(this,_.parseHTML(i[1],t&&t.nodeType?t.ownerDocument||t:s,!0)),O.test(i[1])&&_.isPlainObject(t))for(i in t)y(this[i])?this[i](t[i]):this.attr(i,t[i]);return this}return(r=s.getElementById(i[2]))&&(this[0]=r,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):y(e)?void 0!==n.ready?n.ready(e):e(_):_.makeArray(e,this)}).prototype=_.fn,E=_(s);var M=/^(?:parents|prev(?:Until|All))/,N={children:!0,contents:!0,next:!0,prev:!0};function j(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}_.fn.extend({has:function(e){var t=_(e,this),n=t.length;return this.filter(function(){for(var e=0;e-1:1===n.nodeType&&_.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(o.length>1?_.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?d.call(_(e),this[0]):d.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(_.uniqueSort(_.merge(this.get(),_(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),_.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return $(e,"parentNode")},parentsUntil:function(e,t,n){return $(e,"parentNode",n)},next:function(e){return j(e,"nextSibling")},prev:function(e){return j(e,"previousSibling")},nextAll:function(e){return $(e,"nextSibling")},prevAll:function(e){return $(e,"previousSibling")},nextUntil:function(e,t,n){return $(e,"nextSibling",n)},prevUntil:function(e,t,n){return $(e,"previousSibling",n)},siblings:function(e){return A((e.parentNode||{}).firstChild,e)},children:function(e){return A(e.firstChild)},contents:function(e){return void 0!==e.contentDocument?e.contentDocument:(D(e,"template")&&(e=e.content||e),_.merge([],e.childNodes))}},function(e,t){_.fn[e]=function(n,i){var r=_.map(this,t,n);return"Until"!==e.slice(-5)&&(i=n),i&&"string"==typeof i&&(r=_.filter(i,r)),this.length>1&&(N[e]||_.uniqueSort(r),M.test(e)&&r.reverse()),this.pushStack(r)}});var F=/[^\x20\t\r\n\f]+/g;function I(e){return e}function H(e){throw e}function R(e,t,n,i){var r;try{e&&y(r=e.promise)?r.call(e).done(t).fail(n):e&&y(r=e.then)?r.call(e,t,n):t.apply(void 0,[e].slice(i))}catch(e){n.apply(void 0,[e])}}_.Callbacks=function(e){e="string"==typeof e?function(e){var t={};return _.each(e.match(F)||[],function(e,n){t[n]=!0}),t}(e):_.extend({},e);var t,n,i,r,o=[],s=[],a=-1,l=function(){for(r=r||e.once,i=t=!0;s.length;a=-1)for(n=s.shift();++a-1;)o.splice(n,1),n<=a&&a--}),this},has:function(e){return e?_.inArray(e,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return r=s=[],o=n="",this},disabled:function(){return!o},lock:function(){return r=s=[],n||t||(o=n=""),this},locked:function(){return!!r},fireWith:function(e,n){return r||(n=[e,(n=n||[]).slice?n.slice():n],s.push(n),t||l()),this},fire:function(){return u.fireWith(this,arguments),this},fired:function(){return!!i}};return u},_.extend({Deferred:function(e){var t=[["notify","progress",_.Callbacks("memory"),_.Callbacks("memory"),2],["resolve","done",_.Callbacks("once memory"),_.Callbacks("once memory"),0,"resolved"],["reject","fail",_.Callbacks("once memory"),_.Callbacks("once memory"),1,"rejected"]],i="pending",r={state:function(){return i},always:function(){return o.done(arguments).fail(arguments),this},catch:function(e){return r.then(null,e)},pipe:function(){var e=arguments;return _.Deferred(function(n){_.each(t,function(t,i){var r=y(e[i[4]])&&e[i[4]];o[i[1]](function(){var e=r&&r.apply(this,arguments);e&&y(e.promise)?e.promise().progress(n.notify).done(n.resolve).fail(n.reject):n[i[0]+"With"](this,r?[e]:arguments)})}),e=null}).promise()},then:function(e,i,r){var o=0;function s(e,t,i,r){return function(){var a=this,l=arguments,u=function(){var n,u;if(!(e=o&&(i!==H&&(a=void 0,l=[n]),t.rejectWith(a,l))}};e?c():(_.Deferred.getStackHook&&(c.stackTrace=_.Deferred.getStackHook()),n.setTimeout(c))}}return _.Deferred(function(n){t[0][3].add(s(0,n,y(r)?r:I,n.notifyWith)),t[1][3].add(s(0,n,y(e)?e:I)),t[2][3].add(s(0,n,y(i)?i:H))}).promise()},promise:function(e){return null!=e?_.extend(e,r):r}},o={};return _.each(t,function(e,n){var s=n[2],a=n[5];r[n[1]]=s.add,a&&s.add(function(){i=a},t[3-e][2].disable,t[3-e][3].disable,t[0][2].lock,t[0][3].lock),s.add(n[3].fire),o[n[0]]=function(){return o[n[0]+"With"](this===o?void 0:this,arguments),this},o[n[0]+"With"]=s.fireWith}),r.promise(o),e&&e.call(o,o),o},when:function(e){var t=arguments.length,n=t,i=Array(n),r=l.call(arguments),o=_.Deferred(),s=function(e){return function(n){i[e]=this,r[e]=arguments.length>1?l.call(arguments):n,--t||o.resolveWith(i,r)}};if(t<=1&&(R(e,o.done(s(n)).resolve,o.reject,!t),"pending"===o.state()||y(r[n]&&r[n].then)))return o.then();for(;n--;)R(r[n],s(n),o.reject);return o.promise()}});var P=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;_.Deferred.exceptionHook=function(e,t){n.console&&n.console.warn&&e&&P.test(e.name)&&n.console.warn("jQuery.Deferred exception: "+e.message,e.stack,t)},_.readyException=function(e){n.setTimeout(function(){throw e})};var B=_.Deferred();function q(){s.removeEventListener("DOMContentLoaded",q),n.removeEventListener("load",q),_.ready()}_.fn.ready=function(e){return B.then(e).catch(function(e){_.readyException(e)}),this},_.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--_.readyWait:_.isReady)||(_.isReady=!0,!0!==e&&--_.readyWait>0||B.resolveWith(s,[_]))}}),_.ready.then=B.then,"complete"===s.readyState||"loading"!==s.readyState&&!s.documentElement.doScroll?n.setTimeout(_.ready):(s.addEventListener("DOMContentLoaded",q),n.addEventListener("load",q));var V=function(e,t,n,i,r,o,s){var a=0,l=e.length,u=null==n;if("object"===T(n))for(a in r=!0,n)V(e,t,a,n[a],!0,o,s);else if(void 0!==i&&(r=!0,y(i)||(s=!0),u&&(s?(t.call(e,i),t=null):(u=t,t=function(e,t,n){return u.call(_(e),n)})),t))for(;a1,null,!0)},removeData:function(e){return this.each(function(){Q.remove(this,e)})}}),_.extend({queue:function(e,t,n){var i;if(e)return t=(t||"fx")+"queue",i=J.get(e,t),n&&(!i||Array.isArray(n)?i=J.access(e,t,_.makeArray(n)):i.push(n)),i||[]},dequeue:function(e,t){t=t||"fx";var n=_.queue(e,t),i=n.length,r=n.shift(),o=_._queueHooks(e,t);"inprogress"===r&&(r=n.shift(),i--),r&&("fx"===t&&n.unshift("inprogress"),delete o.stop,r.call(e,function(){_.dequeue(e,t)},o)),!i&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return J.get(e,n)||J.access(e,n,{empty:_.Callbacks("once memory").add(function(){J.remove(e,[t+"queue",n])})})}}),_.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length\x20\t\r\n\f]*)/i,ge=/^$|^module$|\/(?:java|ecma)script/i,ye={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function we(e,t){var n;return n=void 0!==e.getElementsByTagName?e.getElementsByTagName(t||"*"):void 0!==e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&D(e,t)?_.merge([e],n):n}function be(e,t){for(var n=0,i=e.length;n-1)r&&r.push(o);else if(u=ae(o),s=we(d.appendChild(o),"script"),u&&be(s),n)for(c=0;o=s[c++];)ge.test(o.type||"")&&n.push(o);return d}xe=s.createDocumentFragment().appendChild(s.createElement("div")),(Te=s.createElement("input")).setAttribute("type","radio"),Te.setAttribute("checked","checked"),Te.setAttribute("name","t"),xe.appendChild(Te),g.checkClone=xe.cloneNode(!0).cloneNode(!0).lastChild.checked,xe.innerHTML="",g.noCloneChecked=!!xe.cloneNode(!0).lastChild.defaultValue;var Ce=/^key/,ze=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,$e=/^([^.]*)(?:\.(.+)|)/;function Ae(){return!0}function ke(){return!1}function De(e,t){return e===function(){try{return s.activeElement}catch(e){}}()==("focus"===t)}function Oe(e,t,n,i,r,o){var s,a;if("object"==typeof t){for(a in"string"!=typeof n&&(i=i||n,n=void 0),t)Oe(e,a,n,i,t[a],o);return e}if(null==i&&null==r?(r=n,i=n=void 0):null==r&&("string"==typeof n?(r=i,i=void 0):(r=i,i=n,n=void 0)),!1===r)r=ke;else if(!r)return e;return 1===o&&(s=r,(r=function(e){return _().off(e),s.apply(this,arguments)}).guid=s.guid||(s.guid=_.guid++)),e.each(function(){_.event.add(this,t,r,i,n)})}function Le(e,t,n){n?(J.set(e,t,!1),_.event.add(e,t,{namespace:!1,handler:function(e){var i,r,o=J.get(this,t);if(1&e.isTrigger&&this[t]){if(o.length)(_.event.special[t]||{}).delegateType&&e.stopPropagation();else if(o=l.call(arguments),J.set(this,t,o),i=n(this,t),this[t](),o!==(r=J.get(this,t))||i?J.set(this,t,!1):r={},o!==r)return e.stopImmediatePropagation(),e.preventDefault(),r.value}else o.length&&(J.set(this,t,{value:_.event.trigger(_.extend(o[0],_.Event.prototype),o.slice(1),this)}),e.stopImmediatePropagation())}})):void 0===J.get(e,t)&&_.event.add(e,t,Ae)}_.event={global:{},add:function(e,t,n,i,r){var o,s,a,l,u,c,d,f,h,p,v,m=J.get(e);if(m)for(n.handler&&(n=(o=n).handler,r=o.selector),r&&_.find.matchesSelector(se,r),n.guid||(n.guid=_.guid++),(l=m.events)||(l=m.events={}),(s=m.handle)||(s=m.handle=function(t){return void 0!==_&&_.event.triggered!==t.type?_.event.dispatch.apply(e,arguments):void 0}),u=(t=(t||"").match(F)||[""]).length;u--;)h=v=(a=$e.exec(t[u])||[])[1],p=(a[2]||"").split(".").sort(),h&&(d=_.event.special[h]||{},h=(r?d.delegateType:d.bindType)||h,d=_.event.special[h]||{},c=_.extend({type:h,origType:v,data:i,handler:n,guid:n.guid,selector:r,needsContext:r&&_.expr.match.needsContext.test(r),namespace:p.join(".")},o),(f=l[h])||((f=l[h]=[]).delegateCount=0,d.setup&&!1!==d.setup.call(e,i,p,s)||e.addEventListener&&e.addEventListener(h,s)),d.add&&(d.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),r?f.splice(f.delegateCount++,0,c):f.push(c),_.event.global[h]=!0)},remove:function(e,t,n,i,r){var o,s,a,l,u,c,d,f,h,p,v,m=J.hasData(e)&&J.get(e);if(m&&(l=m.events)){for(u=(t=(t||"").match(F)||[""]).length;u--;)if(h=v=(a=$e.exec(t[u])||[])[1],p=(a[2]||"").split(".").sort(),h){for(d=_.event.special[h]||{},f=l[h=(i?d.delegateType:d.bindType)||h]||[],a=a[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),s=o=f.length;o--;)c=f[o],!r&&v!==c.origType||n&&n.guid!==c.guid||a&&!a.test(c.namespace)||i&&i!==c.selector&&("**"!==i||!c.selector)||(f.splice(o,1),c.selector&&f.delegateCount--,d.remove&&d.remove.call(e,c));s&&!f.length&&(d.teardown&&!1!==d.teardown.call(e,p,m.handle)||_.removeEvent(e,h,m.handle),delete l[h])}else for(h in l)_.event.remove(e,h+t[u],n,i,!0);_.isEmptyObject(l)&&J.remove(e,"handle events")}},dispatch:function(e){var t,n,i,r,o,s,a=_.event.fix(e),l=new Array(arguments.length),u=(J.get(this,"events")||{})[a.type]||[],c=_.event.special[a.type]||{};for(l[0]=a,t=1;t=1))for(;u!==this;u=u.parentNode||this)if(1===u.nodeType&&("click"!==e.type||!0!==u.disabled)){for(o=[],s={},n=0;n-1:_.find(r,this,null,[u]).length),s[r]&&o.push(i);o.length&&a.push({elem:u,handlers:o})}return u=this,l\x20\t\r\n\f]*)[^>]*)\/>/gi,We=/\s*$/g;function je(e,t){return D(e,"table")&&D(11!==t.nodeType?t:t.firstChild,"tr")&&_(e).children("tbody")[0]||e}function Fe(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Ie(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function He(e,t){var n,i,r,o,s,a,l,u;if(1===t.nodeType){if(J.hasData(e)&&(o=J.access(e),s=J.set(t,o),u=o.events))for(r in delete s.handle,s.events={},u)for(n=0,i=u[r].length;n1&&"string"==typeof p&&!g.checkClone&&Me.test(p))return e.each(function(r){var o=e.eq(r);v&&(t[0]=p.call(this,r,o.html())),Re(o,t,n,i)});if(f&&(o=(r=Se(t,e[0].ownerDocument,!1,e,i)).firstChild,1===r.childNodes.length&&(r=o),o||i)){for(a=(s=_.map(we(r,"script"),Fe)).length;d")},clone:function(e,t,n){var i,r,o,s,a,l,u,c=e.cloneNode(!0),d=ae(e);if(!(g.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||_.isXMLDoc(e)))for(s=we(c),i=0,r=(o=we(e)).length;i0&&be(s,!d&&we(e,"script")),c},cleanData:function(e){for(var t,n,i,r=_.event.special,o=0;void 0!==(n=e[o]);o++)if(X(n)){if(t=n[J.expando]){if(t.events)for(i in t.events)r[i]?_.event.remove(n,i):_.removeEvent(n,i,t.handle);n[J.expando]=void 0}n[Q.expando]&&(n[Q.expando]=void 0)}}}),_.fn.extend({detach:function(e){return Pe(this,e,!0)},remove:function(e){return Pe(this,e)},text:function(e){return V(this,function(e){return void 0===e?_.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return Re(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||je(this,e).appendChild(e)})},prepend:function(){return Re(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=je(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(_.cleanData(we(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return _.clone(this,e,t)})},html:function(e){return V(this,function(e){var t=this[0]||{},n=0,i=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!We.test(e)&&!ye[(me.exec(e)||["",""])[1].toLowerCase()]){e=_.htmlPrefilter(e);try{for(;n=0&&(l+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-l-a-.5))||0),l}function rt(e,t,n){var i=qe(e),r=(!g.boxSizingReliable()||n)&&"border-box"===_.css(e,"boxSizing",!1,i),o=r,s=Ue(e,t,i),a="offset"+t[0].toUpperCase()+t.slice(1);if(Be.test(s)){if(!n)return s;s="auto"}return(!g.boxSizingReliable()&&r||"auto"===s||!parseFloat(s)&&"inline"===_.css(e,"display",!1,i))&&e.getClientRects().length&&(r="border-box"===_.css(e,"boxSizing",!1,i),(o=a in e)&&(s=e[a])),(s=parseFloat(s)||0)+it(e,t,n||(r?"border":"content"),o,i,s)+"px"}function ot(e,t,n,i,r){return new ot.prototype.init(e,t,n,i,r)}_.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Ue(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,n,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var r,o,s,a=G(t),l=Qe.test(t),u=e.style;if(l||(t=Ke(a)),s=_.cssHooks[t]||_.cssHooks[a],void 0===n)return s&&"get"in s&&void 0!==(r=s.get(e,!1,i))?r:u[t];"string"===(o=typeof n)&&(r=re.exec(n))&&r[1]&&(n=de(e,t,r),o="number"),null!=n&&n==n&&("number"!==o||l||(n+=r&&r[3]||(_.cssNumber[a]?"":"px")),g.clearCloneStyle||""!==n||0!==t.indexOf("background")||(u[t]="inherit"),s&&"set"in s&&void 0===(n=s.set(e,n,i))||(l?u.setProperty(t,n):u[t]=n))}},css:function(e,t,n,i){var r,o,s,a=G(t);return Qe.test(t)||(t=Ke(a)),(s=_.cssHooks[t]||_.cssHooks[a])&&"get"in s&&(r=s.get(e,!0,n)),void 0===r&&(r=Ue(e,t,i)),"normal"===r&&t in tt&&(r=tt[t]),""===n||n?(o=parseFloat(r),!0===n||isFinite(o)?o||0:r):r}}),_.each(["height","width"],function(e,t){_.cssHooks[t]={get:function(e,n,i){if(n)return!Je.test(_.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?rt(e,t,i):ce(e,et,function(){return rt(e,t,i)})},set:function(e,n,i){var r,o=qe(e),s=!g.scrollboxSize()&&"absolute"===o.position,a=(s||i)&&"border-box"===_.css(e,"boxSizing",!1,o),l=i?it(e,t,i,a,o):0;return a&&s&&(l-=Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-parseFloat(o[t])-it(e,t,"border",!1,o)-.5)),l&&(r=re.exec(n))&&"px"!==(r[3]||"px")&&(e.style[t]=n,n=_.css(e,t)),nt(0,n,l)}}}),_.cssHooks.marginLeft=Ye(g.reliableMarginLeft,function(e,t){if(t)return(parseFloat(Ue(e,"marginLeft"))||e.getBoundingClientRect().left-ce(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),_.each({margin:"",padding:"",border:"Width"},function(e,t){_.cssHooks[e+t]={expand:function(n){for(var i=0,r={},o="string"==typeof n?n.split(" "):[n];i<4;i++)r[e+oe[i]+t]=o[i]||o[i-2]||o[0];return r}},"margin"!==e&&(_.cssHooks[e+t].set=nt)}),_.fn.extend({css:function(e,t){return V(this,function(e,t,n){var i,r,o={},s=0;if(Array.isArray(t)){for(i=qe(e),r=t.length;s1)}}),_.Tween=ot,ot.prototype={constructor:ot,init:function(e,t,n,i,r,o){this.elem=e,this.prop=n,this.easing=r||_.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=i,this.unit=o||(_.cssNumber[n]?"":"px")},cur:function(){var e=ot.propHooks[this.prop];return e&&e.get?e.get(this):ot.propHooks._default.get(this)},run:function(e){var t,n=ot.propHooks[this.prop];return this.options.duration?this.pos=t=_.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):ot.propHooks._default.set(this),this}},ot.prototype.init.prototype=ot.prototype,ot.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=_.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){_.fx.step[e.prop]?_.fx.step[e.prop](e):1!==e.elem.nodeType||!_.cssHooks[e.prop]&&null==e.elem.style[Ke(e.prop)]?e.elem[e.prop]=e.now:_.style(e.elem,e.prop,e.now+e.unit)}}},ot.propHooks.scrollTop=ot.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},_.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},_.fx=ot.prototype.init,_.fx.step={};var st,at,lt=/^(?:toggle|show|hide)$/,ut=/queueHooks$/;function ct(){at&&(!1===s.hidden&&n.requestAnimationFrame?n.requestAnimationFrame(ct):n.setTimeout(ct,_.fx.interval),_.fx.tick())}function dt(){return n.setTimeout(function(){st=void 0}),st=Date.now()}function ft(e,t){var n,i=0,r={height:e};for(t=t?1:0;i<4;i+=2-t)r["margin"+(n=oe[i])]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}function ht(e,t,n){for(var i,r=(pt.tweeners[t]||[]).concat(pt.tweeners["*"]),o=0,s=r.length;o1)},removeAttr:function(e){return this.each(function(){_.removeAttr(this,e)})}}),_.extend({attr:function(e,t,n){var i,r,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return void 0===e.getAttribute?_.prop(e,t,n):(1===o&&_.isXMLDoc(e)||(r=_.attrHooks[t.toLowerCase()]||(_.expr.match.bool.test(t)?vt:void 0)),void 0!==n?null===n?void _.removeAttr(e,t):r&&"set"in r&&void 0!==(i=r.set(e,n,t))?i:(e.setAttribute(t,n+""),n):r&&"get"in r&&null!==(i=r.get(e,t))?i:null==(i=_.find.attr(e,t))?void 0:i)},attrHooks:{type:{set:function(e,t){if(!g.radioValue&&"radio"===t&&D(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,i=0,r=t&&t.match(F);if(r&&1===e.nodeType)for(;n=r[i++];)e.removeAttribute(n)}}),vt={set:function(e,t,n){return!1===t?_.removeAttr(e,n):e.setAttribute(n,n),n}},_.each(_.expr.match.bool.source.match(/\w+/g),function(e,t){var n=mt[t]||_.find.attr;mt[t]=function(e,t,i){var r,o,s=t.toLowerCase();return i||(o=mt[s],mt[s]=r,r=null!=n(e,t,i)?s:null,mt[s]=o),r}});var gt=/^(?:input|select|textarea|button)$/i,yt=/^(?:a|area)$/i;function wt(e){return(e.match(F)||[]).join(" ")}function bt(e){return e.getAttribute&&e.getAttribute("class")||""}function xt(e){return Array.isArray(e)?e:"string"==typeof e&&e.match(F)||[]}_.fn.extend({prop:function(e,t){return V(this,_.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[_.propFix[e]||e]})}}),_.extend({prop:function(e,t,n){var i,r,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&_.isXMLDoc(e)||(t=_.propFix[t]||t,r=_.propHooks[t]),void 0!==n?r&&"set"in r&&void 0!==(i=r.set(e,n,t))?i:e[t]=n:r&&"get"in r&&null!==(i=r.get(e,t))?i:e[t]},propHooks:{tabIndex:{get:function(e){var t=_.find.attr(e,"tabindex");return t?parseInt(t,10):gt.test(e.nodeName)||yt.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),g.optSelected||(_.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),_.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){_.propFix[this.toLowerCase()]=this}),_.fn.extend({addClass:function(e){var t,n,i,r,o,s,a,l=0;if(y(e))return this.each(function(t){_(this).addClass(e.call(this,t,bt(this)))});if((t=xt(e)).length)for(;n=this[l++];)if(r=bt(n),i=1===n.nodeType&&" "+wt(r)+" "){for(s=0;o=t[s++];)i.indexOf(" "+o+" ")<0&&(i+=o+" ");r!==(a=wt(i))&&n.setAttribute("class",a)}return this},removeClass:function(e){var t,n,i,r,o,s,a,l=0;if(y(e))return this.each(function(t){_(this).removeClass(e.call(this,t,bt(this)))});if(!arguments.length)return this.attr("class","");if((t=xt(e)).length)for(;n=this[l++];)if(r=bt(n),i=1===n.nodeType&&" "+wt(r)+" "){for(s=0;o=t[s++];)for(;i.indexOf(" "+o+" ")>-1;)i=i.replace(" "+o+" "," ");r!==(a=wt(i))&&n.setAttribute("class",a)}return this},toggleClass:function(e,t){var n=typeof e,i="string"===n||Array.isArray(e);return"boolean"==typeof t&&i?t?this.addClass(e):this.removeClass(e):y(e)?this.each(function(n){_(this).toggleClass(e.call(this,n,bt(this),t),t)}):this.each(function(){var t,r,o,s;if(i)for(r=0,o=_(this),s=xt(e);t=s[r++];)o.hasClass(t)?o.removeClass(t):o.addClass(t);else void 0!==e&&"boolean"!==n||((t=bt(this))&&J.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":J.get(this,"__className__")||""))})},hasClass:function(e){var t,n,i=0;for(t=" "+e+" ";n=this[i++];)if(1===n.nodeType&&(" "+wt(bt(n))+" ").indexOf(t)>-1)return!0;return!1}});var Tt=/\r/g;_.fn.extend({val:function(e){var t,n,i,r=this[0];return arguments.length?(i=y(e),this.each(function(n){var r;1===this.nodeType&&(null==(r=i?e.call(this,n,_(this).val()):e)?r="":"number"==typeof r?r+="":Array.isArray(r)&&(r=_.map(r,function(e){return null==e?"":e+""})),(t=_.valHooks[this.type]||_.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,r,"value")||(this.value=r))})):r?(t=_.valHooks[r.type]||_.valHooks[r.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(r,"value"))?n:"string"==typeof(n=r.value)?n.replace(Tt,""):null==n?"":n:void 0}}),_.extend({valHooks:{option:{get:function(e){var t=_.find.attr(e,"value");return null!=t?t:wt(_.text(e))}},select:{get:function(e){var t,n,i,r=e.options,o=e.selectedIndex,s="select-one"===e.type,a=s?null:[],l=s?o+1:r.length;for(i=o<0?l:s?o:0;i-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),_.each(["radio","checkbox"],function(){_.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=_.inArray(_(e).val(),t)>-1}},g.checkOn||(_.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}),g.focusin="onfocusin"in n;var _t=/^(?:focusinfocus|focusoutblur)$/,St=function(e){e.stopPropagation()};_.extend(_.event,{trigger:function(e,t,i,r){var o,a,l,u,c,d,f,h,v=[i||s],m=p.call(e,"type")?e.type:e,g=p.call(e,"namespace")?e.namespace.split("."):[];if(a=h=l=i=i||s,3!==i.nodeType&&8!==i.nodeType&&!_t.test(m+_.event.triggered)&&(m.indexOf(".")>-1&&(m=(g=m.split(".")).shift(),g.sort()),c=m.indexOf(":")<0&&"on"+m,(e=e[_.expando]?e:new _.Event(m,"object"==typeof e&&e)).isTrigger=r?2:3,e.namespace=g.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+g.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=i),t=null==t?[e]:_.makeArray(t,[e]),f=_.event.special[m]||{},r||!f.trigger||!1!==f.trigger.apply(i,t))){if(!r&&!f.noBubble&&!w(i)){for(u=f.delegateType||m,_t.test(u+m)||(a=a.parentNode);a;a=a.parentNode)v.push(a),l=a;l===(i.ownerDocument||s)&&v.push(l.defaultView||l.parentWindow||n)}for(o=0;(a=v[o++])&&!e.isPropagationStopped();)h=a,e.type=o>1?u:f.bindType||m,(d=(J.get(a,"events")||{})[e.type]&&J.get(a,"handle"))&&d.apply(a,t),(d=c&&a[c])&&d.apply&&X(a)&&(e.result=d.apply(a,t),!1===e.result&&e.preventDefault());return e.type=m,r||e.isDefaultPrevented()||f._default&&!1!==f._default.apply(v.pop(),t)||!X(i)||c&&y(i[m])&&!w(i)&&((l=i[c])&&(i[c]=null),_.event.triggered=m,e.isPropagationStopped()&&h.addEventListener(m,St),i[m](),e.isPropagationStopped()&&h.removeEventListener(m,St),_.event.triggered=void 0,l&&(i[c]=l)),e.result}},simulate:function(e,t,n){var i=_.extend(new _.Event,n,{type:e,isSimulated:!0});_.event.trigger(i,null,t)}}),_.fn.extend({trigger:function(e,t){return this.each(function(){_.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return _.event.trigger(e,t,n,!0)}}),g.focusin||_.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){_.event.simulate(t,e.target,_.event.fix(e))};_.event.special[t]={setup:function(){var i=this.ownerDocument||this,r=J.access(i,t);r||i.addEventListener(e,n,!0),J.access(i,t,(r||0)+1)},teardown:function(){var i=this.ownerDocument||this,r=J.access(i,t)-1;r?J.access(i,t,r):(i.removeEventListener(e,n,!0),J.remove(i,t))}}});var Ct=n.location,zt=Date.now(),$t=/\?/;_.parseXML=function(e){var t;if(!e||"string"!=typeof e)return null;try{t=(new n.DOMParser).parseFromString(e,"text/xml")}catch(e){t=void 0}return t&&!t.getElementsByTagName("parsererror").length||_.error("Invalid XML: "+e),t};var At=/\[\]$/,kt=/\r?\n/g,Dt=/^(?:submit|button|image|reset|file)$/i,Ot=/^(?:input|select|textarea|keygen)/i;function Lt(e,t,n,i){var r;if(Array.isArray(t))_.each(t,function(t,r){n||At.test(e)?i(e,r):Lt(e+"["+("object"==typeof r&&null!=r?t:"")+"]",r,n,i)});else if(n||"object"!==T(t))i(e,t);else for(r in t)Lt(e+"["+r+"]",t[r],n,i)}_.param=function(e,t){var n,i=[],r=function(e,t){var n=y(t)?t():t;i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(null==e)return"";if(Array.isArray(e)||e.jquery&&!_.isPlainObject(e))_.each(e,function(){r(this.name,this.value)});else for(n in e)Lt(n,e[n],t,r);return i.join("&")},_.fn.extend({serialize:function(){return _.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=_.prop(this,"elements");return e?_.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!_(this).is(":disabled")&&Ot.test(this.nodeName)&&!Dt.test(e)&&(this.checked||!ve.test(e))}).map(function(e,t){var n=_(this).val();return null==n?null:Array.isArray(n)?_.map(n,function(e){return{name:t.name,value:e.replace(kt,"\r\n")}}):{name:t.name,value:n.replace(kt,"\r\n")}}).get()}});var Et=/%20/g,Wt=/#.*$/,Mt=/([?&])_=[^&]*/,Nt=/^(.*?):[ \t]*([^\r\n]*)$/gm,jt=/^(?:GET|HEAD)$/,Ft=/^\/\//,It={},Ht={},Rt="*/".concat("*"),Pt=s.createElement("a");function Bt(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var i,r=0,o=t.toLowerCase().match(F)||[];if(y(n))for(;i=o[r++];)"+"===i[0]?(i=i.slice(1)||"*",(e[i]=e[i]||[]).unshift(n)):(e[i]=e[i]||[]).push(n)}}function qt(e,t,n,i){var r={},o=e===Ht;function s(a){var l;return r[a]=!0,_.each(e[a]||[],function(e,a){var u=a(t,n,i);return"string"!=typeof u||o||r[u]?o?!(l=u):void 0:(t.dataTypes.unshift(u),s(u),!1)}),l}return s(t.dataTypes[0])||!r["*"]&&s("*")}function Vt(e,t){var n,i,r=_.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((r[n]?e:i||(i={}))[n]=t[n]);return i&&_.extend(!0,e,i),e}Pt.href=Ct.href,_.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Ct.href,type:"GET",isLocal:/^(?:about|app|app-storage|.+-extension|file|res|widget):$/.test(Ct.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Rt,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":_.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?Vt(Vt(e,_.ajaxSettings),t):Vt(_.ajaxSettings,e)},ajaxPrefilter:Bt(It),ajaxTransport:Bt(Ht),ajax:function(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var i,r,o,a,l,u,c,d,f,h,p=_.ajaxSetup({},t),v=p.context||p,m=p.context&&(v.nodeType||v.jquery)?_(v):_.event,g=_.Deferred(),y=_.Callbacks("once memory"),w=p.statusCode||{},b={},x={},T="canceled",S={readyState:0,getResponseHeader:function(e){var t;if(c){if(!a)for(a={};t=Nt.exec(o);)a[t[1].toLowerCase()+" "]=(a[t[1].toLowerCase()+" "]||[]).concat(t[2]);t=a[e.toLowerCase()+" "]}return null==t?null:t.join(", ")},getAllResponseHeaders:function(){return c?o:null},setRequestHeader:function(e,t){return null==c&&(e=x[e.toLowerCase()]=x[e.toLowerCase()]||e,b[e]=t),this},overrideMimeType:function(e){return null==c&&(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(c)S.always(e[S.status]);else for(t in e)w[t]=[w[t],e[t]];return this},abort:function(e){var t=e||T;return i&&i.abort(t),C(0,t),this}};if(g.promise(S),p.url=((e||p.url||Ct.href)+"").replace(Ft,Ct.protocol+"//"),p.type=t.method||t.type||p.method||p.type,p.dataTypes=(p.dataType||"*").toLowerCase().match(F)||[""],null==p.crossDomain){u=s.createElement("a");try{u.href=p.url,u.href=u.href,p.crossDomain=Pt.protocol+"//"+Pt.host!=u.protocol+"//"+u.host}catch(e){p.crossDomain=!0}}if(p.data&&p.processData&&"string"!=typeof p.data&&(p.data=_.param(p.data,p.traditional)),qt(It,p,t,S),c)return S;for(f in(d=_.event&&p.global)&&0==_.active++&&_.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!jt.test(p.type),r=p.url.replace(Wt,""),p.hasContent?p.data&&p.processData&&0===(p.contentType||"").indexOf("application/x-www-form-urlencoded")&&(p.data=p.data.replace(Et,"+")):(h=p.url.slice(r.length),p.data&&(p.processData||"string"==typeof p.data)&&(r+=($t.test(r)?"&":"?")+p.data,delete p.data),!1===p.cache&&(r=r.replace(Mt,"$1"),h=($t.test(r)?"&":"?")+"_="+zt+++h),p.url=r+h),p.ifModified&&(_.lastModified[r]&&S.setRequestHeader("If-Modified-Since",_.lastModified[r]),_.etag[r]&&S.setRequestHeader("If-None-Match",_.etag[r])),(p.data&&p.hasContent&&!1!==p.contentType||t.contentType)&&S.setRequestHeader("Content-Type",p.contentType),S.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+Rt+"; q=0.01":""):p.accepts["*"]),p.headers)S.setRequestHeader(f,p.headers[f]);if(p.beforeSend&&(!1===p.beforeSend.call(v,S,p)||c))return S.abort();if(T="abort",y.add(p.complete),S.done(p.success),S.fail(p.error),i=qt(Ht,p,t,S)){if(S.readyState=1,d&&m.trigger("ajaxSend",[S,p]),c)return S;p.async&&p.timeout>0&&(l=n.setTimeout(function(){S.abort("timeout")},p.timeout));try{c=!1,i.send(b,C)}catch(e){if(c)throw e;C(-1,e)}}else C(-1,"No Transport");function C(e,t,s,a){var u,f,h,b,x,T=t;c||(c=!0,l&&n.clearTimeout(l),i=void 0,o=a||"",S.readyState=e>0?4:0,u=e>=200&&e<300||304===e,s&&(b=function(e,t,n){for(var i,r,o,s,a=e.contents,l=e.dataTypes;"*"===l[0];)l.shift(),void 0===i&&(i=e.mimeType||t.getResponseHeader("Content-Type"));if(i)for(r in a)if(a[r]&&a[r].test(i)){l.unshift(r);break}if(l[0]in n)o=l[0];else{for(r in n){if(!l[0]||e.converters[r+" "+l[0]]){o=r;break}s||(s=r)}o=o||s}if(o)return o!==l[0]&&l.unshift(o),n[o]}(p,S,s)),b=function(e,t,n,i){var r,o,s,a,l,u={},c=e.dataTypes.slice();if(c[1])for(s in e.converters)u[s.toLowerCase()]=e.converters[s];for(o=c.shift();o;)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!l&&i&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),l=o,o=c.shift())if("*"===o)o=l;else if("*"!==l&&l!==o){if(!(s=u[l+" "+o]||u["* "+o]))for(r in u)if((a=r.split(" "))[1]===o&&(s=u[l+" "+a[0]]||u["* "+a[0]])){!0===s?s=u[r]:!0!==u[r]&&(o=a[0],c.unshift(a[1]));break}if(!0!==s)if(s&&e.throws)t=s(t);else try{t=s(t)}catch(e){return{state:"parsererror",error:s?e:"No conversion from "+l+" to "+o}}}return{state:"success",data:t}}(p,b,S,u),u?(p.ifModified&&((x=S.getResponseHeader("Last-Modified"))&&(_.lastModified[r]=x),(x=S.getResponseHeader("etag"))&&(_.etag[r]=x)),204===e||"HEAD"===p.type?T="nocontent":304===e?T="notmodified":(T=b.state,f=b.data,u=!(h=b.error))):(h=T,!e&&T||(T="error",e<0&&(e=0))),S.status=e,S.statusText=(t||T)+"",u?g.resolveWith(v,[f,T,S]):g.rejectWith(v,[S,T,h]),S.statusCode(w),w=void 0,d&&m.trigger(u?"ajaxSuccess":"ajaxError",[S,p,u?f:h]),y.fireWith(v,[S,T]),d&&(m.trigger("ajaxComplete",[S,p]),--_.active||_.event.trigger("ajaxStop")))}return S},getJSON:function(e,t,n){return _.get(e,t,n,"json")},getScript:function(e,t){return _.get(e,void 0,t,"script")}}),_.each(["get","post"],function(e,t){_[t]=function(e,n,i,r){return y(n)&&(r=r||i,i=n,n=void 0),_.ajax(_.extend({url:e,type:t,dataType:r,data:n,success:i},_.isPlainObject(e)&&e))}}),_._evalUrl=function(e,t){return _.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(e){_.globalEval(e,t)}})},_.fn.extend({wrapAll:function(e){var t;return this[0]&&(y(e)&&(e=e.call(this[0])),t=_(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){for(var e=this;e.firstElementChild;)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return y(e)?this.each(function(t){_(this).wrapInner(e.call(this,t))}):this.each(function(){var t=_(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=y(e);return this.each(function(n){_(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){_(this).replaceWith(this.childNodes)}),this}}),_.expr.pseudos.hidden=function(e){return!_.expr.pseudos.visible(e)},_.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},_.ajaxSettings.xhr=function(){try{return new n.XMLHttpRequest}catch(e){}};var Ut={0:200,1223:204},Yt=_.ajaxSettings.xhr();g.cors=!!Yt&&"withCredentials"in Yt,g.ajax=Yt=!!Yt,_.ajaxTransport(function(e){var t,i;if(g.cors||Yt&&!e.crossDomain)return{send:function(r,o){var s,a=e.xhr();if(a.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(s in e.xhrFields)a[s]=e.xhrFields[s];for(s in e.mimeType&&a.overrideMimeType&&a.overrideMimeType(e.mimeType),e.crossDomain||r["X-Requested-With"]||(r["X-Requested-With"]="XMLHttpRequest"),r)a.setRequestHeader(s,r[s]);t=function(e){return function(){t&&(t=i=a.onload=a.onerror=a.onabort=a.ontimeout=a.onreadystatechange=null,"abort"===e?a.abort():"error"===e?"number"!=typeof a.status?o(0,"error"):o(a.status,a.statusText):o(Ut[a.status]||a.status,a.statusText,"text"!==(a.responseType||"text")||"string"!=typeof a.responseText?{binary:a.response}:{text:a.responseText},a.getAllResponseHeaders()))}},a.onload=t(),i=a.onerror=a.ontimeout=t("error"),void 0!==a.onabort?a.onabort=i:a.onreadystatechange=function(){4===a.readyState&&n.setTimeout(function(){t&&i()})},t=t("abort");try{a.send(e.hasContent&&e.data||null)}catch(e){if(t)throw e}},abort:function(){t&&t()}}}),_.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),_.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return _.globalEval(e),e}}}),_.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),_.ajaxTransport("script",function(e){var t,n;if(e.crossDomain||e.scriptAttrs)return{send:function(i,r){t=_("