From 50a0a7119650e17e8551fdfb7d25ce75f310fffc Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Fri, 18 Jan 2019 17:36:58 +0530 Subject: [PATCH 01/12] product flat column creation and deletion on the basis of attributes --- packages/Webkul/Admin/src/Http/routes.php | 2 + .../Http/Controllers/AttributeController.php | 3 +- .../Http/Controllers/ProductController.php | 17 +++++- .../Product/src/Listeners/ProductsFlat.php | 58 ++++++++++++++++--- .../Webkul/Ui/publishable/assets/css/ui.css | 2 +- .../Webkul/Ui/publishable/assets/js/ui.js | 2 +- .../Ui/publishable/assets/mix-manifest.json | 6 +- packages/Webkul/Ui/webpack.mix.js | 4 +- 8 files changed, 75 insertions(+), 19 deletions(-) diff --git a/packages/Webkul/Admin/src/Http/routes.php b/packages/Webkul/Admin/src/Http/routes.php index fb6330ce7..ed009680b 100755 --- a/packages/Webkul/Admin/src/Http/routes.php +++ b/packages/Webkul/Admin/src/Http/routes.php @@ -35,6 +35,8 @@ Route::group(['middleware' => ['web']], function () { // Admin Routes Route::group(['middleware' => ['admin']], function () { + Route::get('/testev', 'Webkul\Product\Http\Controllers\ProductController@testEvent'); + Route::get('/logout', 'Webkul\User\Http\Controllers\SessionController@destroy')->defaults('_config', [ 'redirect' => 'admin.session.create' ])->name('admin.session.destroy'); diff --git a/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php b/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php index 88afceba8..8af40c268 100755 --- a/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php +++ b/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php @@ -135,11 +135,12 @@ class AttributeController extends Controller session()->flash('error', trans('admin::app.response.user-define-error', ['name' => 'attribute'])); } else { try { + Event::fire('after.attribute.deleted', $attribute); + $this->attribute->delete($id); session()->flash('success', 'Attribute deleted successfully.'); - Event::fire(after.attribute.deleted, $attribute); } catch(\Exception $e) { session()->flash('error', trans('admin::app.response.attribute-error', ['name' => 'Attribute'])); } diff --git a/packages/Webkul/Product/src/Http/Controllers/ProductController.php b/packages/Webkul/Product/src/Http/Controllers/ProductController.php index fe902615b..577e9f8ed 100755 --- a/packages/Webkul/Product/src/Http/Controllers/ProductController.php +++ b/packages/Webkul/Product/src/Http/Controllers/ProductController.php @@ -9,10 +9,11 @@ use Webkul\Product\Http\Requests\ProductForm; use Webkul\Product\Repositories\ProductRepository as Product; use Webkul\Product\Repositories\ProductGridRepository as ProductGrid; use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily; +use Webkul\Attribute\Repositories\AttributeRepository as Attribute; use Webkul\Category\Repositories\CategoryRepository as Category; use Webkul\Inventory\Repositories\InventorySourceRepository as InventorySource; use Webkul\Admin\DataGrids\TestDataGrid; - +use Webkul\Product\Listeners\ProductsFlat as PF; /** * Product controller * @@ -62,6 +63,7 @@ class ProductController extends Controller * @var array */ protected $productGrid; + protected $attribute; /** * Create a new controller instance. @@ -77,7 +79,8 @@ class ProductController extends Controller Category $category, InventorySource $inventorySource, Product $product, - ProductGrid $productGrid) + ProductGrid $productGrid, + Attribute $attribute) { $this->attributeFamily = $attributeFamily; @@ -89,6 +92,8 @@ class ProductController extends Controller $this->productGrid = $productGrid; + $this->attribute = $attribute; + $this->_config = request('_config'); } @@ -127,7 +132,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')); } @@ -257,4 +262,10 @@ class ProductController extends Controller return redirect()->route('admin.catalog.products.index'); } + + public function testEvent() { + $productFlat = new PF(); + + $productFlat->afterAttributeCreated($this->attribute->find(27)); + } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Listeners/ProductsFlat.php b/packages/Webkul/Product/src/Listeners/ProductsFlat.php index 2ee64ecd3..c80a91fbe 100644 --- a/packages/Webkul/Product/src/Listeners/ProductsFlat.php +++ b/packages/Webkul/Product/src/Listeners/ProductsFlat.php @@ -20,8 +20,44 @@ class ProductsFlat */ public function afterAttributeCreated($attribute) { - return true; - dd('after attribute is created'); + if(!$attribute->is_user_defined) { + return false; + } + + $attributeType = $attribute->type; + $attributeCode = $attribute->code; + + if ($attributeType == 'text' || $attributeType == 'textarea') { + $columnType = 'text'; + } else if ($attributeType == 'price') { + $columnType = 'decimal'; + } else if ($attributeType == 'boolean') { + $columnType = 'boolean'; + } else if ($attributeType == 'select' || $attributeType == 'multiselect') { + if ($attributeType == 'multiselect') { + $columnType = 'text'; + } else { + $columnType = 'integer'; + } + } else if ($attributeType == 'datetime') { + $columnType = 'dateTime'; + } else if ($attributeType == 'date') { + $columnType = 'date'; + } else { + return false; + } + + if (Schema::hasTable('product_flat')) { + if (!Schema::hasColumn('product_flat', strtolower($attribute->code))) { + Schema::table('product_flat', function (Blueprint $table) use($columnType, $attributeCode) { + $table->{$columnType}(strtolower($attributeCode))->nullable(); + }); + + return true; + } else { + return false; + } + } } /** @@ -31,15 +67,21 @@ class ProductsFlat */ public function afterAttributeUpdated($attribute) { - return true; - - dd('after attribute is updated', $attribute); + dd($attribute); } - public function afterAttributeDeleted() + public function afterAttributeDeleted($attribute) { - return true; + if (Schema::hasTable('product_flat')) { + if (Schema::hasColumn('product_flat', strtolower($attribute->code))) { + Schema::table('product_flat', function (Blueprint $table) use($attribute){ + $table->dropColumn(strtolower($attribute->code)); + }); - dd('after attribute is deleted'); + return true; + } else { + return false; + } + } } } \ No newline at end of file diff --git a/packages/Webkul/Ui/publishable/assets/css/ui.css b/packages/Webkul/Ui/publishable/assets/css/ui.css index 9f1a0b1b1..cc8930dd2 100755 --- a/packages/Webkul/Ui/publishable/assets/css/ui.css +++ b/packages/Webkul/Ui/publishable/assets/css/ui.css @@ -1 +1 @@ -.active.configuration-icon,.catalog-icon,.configuration-icon,.customer-icon,.dashboard-icon,.sales-icon,.settings-icon{width:48px;height:48px;display:inline-block;background-size:cover}.icon{display:inline-block;background-size:cover}.dashboard-icon{background-image:url("../images/Icon-Dashboard.svg")}.sales-icon{background-image:url("../images/Icon-Sales.svg")}.catalog-icon{background-image:url("../images/Icon-Catalog.svg")}.customer-icon{background-image:url("../images/Icon-Customers.svg")}.configuration-icon{background-image:url("../images/Icon-Configure.svg")}.settings-icon{background-image:url("../images/Icon-Settings.svg")}.angle-right-icon{background-image:url("../images/Angle-Right.svg");width:17px;height:17px}.angle-left-icon{background-image:url("../images/Angle-Left.svg");width:17px;height:17px}.arrow-down-icon{background-image:url("../images/Arrow-Down-Light.svg");width:14px;height:8px}.arrow-right-icon{background-image:url("../images/Arrow-Right.svg");width:18px;height:18px}.white-cross-sm-icon{background-image:url("../images/Icon-Sm-Cross-White.svg");width:18px;height:18px}.accordian-up-icon{background-image:url("../images/Accordion-Arrow-Up.svg");width:24px;height:24px}.accordian-down-icon{background-image:url("../images/Accordion-Arrow-Down.svg");width:24px;height:24px}.cross-icon{background-image:url("../images/Icon-Crossed.svg");width:18px;height:18px}.trash-icon{background-image:url("../images/Icon-Trash.svg");width:24px;height:24px}.remove-icon{background-image:url("../images/Icon-remove.svg");width:24px;height:24px}.pencil-lg-icon{background-image:url("../images/Icon-Pencil-Large.svg");width:24px;height:24px}.eye-icon{background-image:url("../images/Icon-eye.svg");width:24px;height:24px}.search-icon{background-image:url("../images/icon-search.svg");width:24px;height:24px}.sortable-icon{background-image:url("../images/Icon-Sortable.svg");width:24px;height:24px}.sort-down-icon,.sort-up-icon{background-image:url("../images/Icon-Sort-Down.svg");width:18px;height:18px}.sort-up-icon{-webkit-transform:rotate(180deg);transform:rotate(180deg)}.primary-back-icon{background-image:url("../images/Icon-Back-Primary.svg");width:24px;height:24px}.checkbox-dash-icon{background-image:url("../images/Checkbox-Dash.svg");width:24px;height:24px}.account-icon{background-image:url("../images/icon-account.svg");width:24px;height:24px}.expand-icon{background-image:url("../images/Expand-Light.svg");width:18px;height:18px}.expand-on-icon{background-image:url("../images/Expand-Light-On.svg");width:18px;height:18px}.dark-left-icon{background-image:url("../images/arrow-left-dark.svg");width:18px;height:18px}.light-right-icon{background-image:url("../images/arrow-right-light.svg");width:18px;height:18px}.folder-icon{background-image:url("../images/Folder-Icon.svg");width:24px;height:24px}.star-icon{background-image:url("../images/Star-Icon.svg");width:24px;height:24px}.arrow-down-white-icon{background-image:url("../images/down-arrow-white.svg");width:17px;height:13px}.arrow-up-white-icon{background-image:url("../images/up-arrow-white.svg");width:17px;height:13px}.profile-pic-icon{background-image:url("../images/Profile-Pic.svg");width:60px;height:60px}.graph-up-icon{background-image:url("../images/Icon-Graph-Green.svg");width:24px;height:24px}.graph-down-icon{background-image:url("../images/Icon-Graph-Red.svg");width:24px;height:24px}.no-result-icon{background-image:url("../images/limited-icon.svg");width:52px;height:47px}.active .dashboard-icon{background-image:url("../images/Icon-Dashboard-Active.svg")}.active .sales-icon{background-image:url("../images/Icon-Sales-Active.svg")}.active .catalog-icon{background-image:url("../images/Icon-Catalog-Active.svg")}.active .customer-icon{background-image:url("../images/Icon-Customers-Active.svg")}.active .settings-icon{background-image:url("../images/Icon-Settings-Active.svg")}.active .configuration-icon{background-image:url("../images/Icon-Configure-Active.svg")}.active>.arrow-down-icon{background-image:url("../images/Arrow-Down.svg");width:14px;height:8px}.active>.expand-icon{background-image:url("../images/Expand-Light-On.svg")}.active.dashboard-icon{background-image:url("../images/Icon-Dashboard-Active.svg")}.active.customer-icon{background-image:url("../images/Icon-Customers-Active.svg")}.active.sales-icon{background-image:url("../images/Icon-Sales-Active.svg")}.active.settings-icon{background-image:url("../images/Icon-Settings-Active.svg")}.active.configuration-icon{background-image:url("../images/Icon-Configure-Active.svg")}.active.arrow-down-icon{background-image:url("../images/Arrow-Down.svg");width:14px;height:8px}.active.expand-icon{background-image:url("../images/Expand-Light-On.svg")}.icon-404{background-image:url("../images/404-image.svg");width:255px;height:255px}.export-icon{background-image:url("../images/Icon-Export.svg");width:32px;height:32px}.star-blue-icon{width:17px;height:17px;background-image:url("../images/Icon-star.svg")}.grid-container{display:block;width:100%;height:100%}.filter-row-one{-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.filter-row-one,.filter-row-two{display:-webkit-box;display:-ms-flexbox;display:flex;width:100%;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-webkit-box-align:center;-ms-flex-align:center;align-items:center;margin-bottom:10px}.filter-row-two,.search-filter{-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start}.search-filter{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.search-filter .control{background:#fff;border:2px solid #c7c7c7;border-right:none;border-top-right-radius:0;border-bottom-right-radius:0;border-radius:3px;height:36px;width:360px;padding-left:10px;font-size:15px;color:#8e8e8e}.search-filter .contorl:focus{border-color:#0041ff}.search-filter .icon-wrapper{border:2px solid #c7c7c7;border-radius:3px;border-top-left-radius:0;border-bottom-left-radius:0;height:36px;width:36px;margin-left:-1px}.search-filter .icon-wrapper .search-icon{margin-top:3px;margin-left:3px}.dropdown-header{display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:36px;width:202px;border:2px solid #c7c7c7;border-radius:3px;color:#8e8e8e;padding:0 5px}.dropdown-header .arrow-icon-down{float:right}.filter-tag{-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;border-radius:2px}.filter-tag,.filter-tag .wrapper{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-webkit-box-align:center;-ms-flex-align:center;align-items:center;font-size:14px;height:28px}.filter-tag .wrapper{margin-left:5px;padding:0 5px;background:#e7e7e7;color:#000311;letter-spacing:-.22px}.filter-tag:not(first-child) {margin-left:10px}@-webkit-keyframes jelly{0%{-webkit-transform:translateY(0) scale(.7);transform:translateY(0) scale(.7);opacity:0}70%{-webkit-transform:translateY(5px) scale(1.05);transform:translateY(5px) scale(1.05);opacity:1}to{-webkit-transform:translateY(0) scale(1);transform:translateY(0) scale(1);opacity:1}}@keyframes jelly{0%{-webkit-transform:translateY(0) scale(.7);transform:translateY(0) scale(.7);opacity:0}70%{-webkit-transform:translateY(5px) scale(1.05);transform:translateY(5px) scale(1.05);opacity:1}to{-webkit-transform:translateY(0) scale(1);transform:translateY(0) scale(1);opacity:1}}@-webkit-keyframes jelly-out{0%{-webkit-transform:translateY(0) scale(1);transform:translateY(0) scale(1);opacity:1}30%{-webkit-transform:translateY(-5px) scale(1.05);transform:translateY(-5px) scale(1.05);opacity:1}to{-webkit-transform:translateY(0) scale(.7);transform:translateY(0) scale(.7);opacity:0}}@keyframes jelly-out{0%{-webkit-transform:translateY(0) scale(1);transform:translateY(0) scale(1);opacity:1}30%{-webkit-transform:translateY(-5px) scale(1.05);transform:translateY(-5px) scale(1.05);opacity:1}to{-webkit-transform:translateY(0) scale(.7);transform:translateY(0) scale(.7);opacity:0}}*{-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}:focus{outline:none}a:active,a:focus,a:hover,a:link,a:visited{text-decoration:none;color:#0041ff}textarea{resize:none}ul{margin:0;padding:0;list-style:none}h1{font-size:28px;margin-top:0}h1,h2{color:#3a3a3a}h2{font-size:18px}.tooltip{position:relative;border-bottom:1px solid #000}.tooltip .tooltiptext{visibility:hidden;width:120px;background-color:#000;color:#fff;text-align:center;border-radius:6px;padding:5px 0;position:absolute;z-index:1}.tooltip:hover .tooltiptext{visibility:visible}.hide{display:none!important}.btn{-webkit-box-shadow:0 1px 4px 0 rgba(0,0,0,.2),0 0 8px 0 rgba(0,0,0,.1);box-shadow:0 1px 4px 0 rgba(0,0,0,.2),0 0 8px 0 rgba(0,0,0,.1);border-radius:3px;border:none;color:#fff;cursor:pointer;-webkit-transition:.2s cubic-bezier(.4,0,.2,1);transition:.2s cubic-bezier(.4,0,.2,1);font:inherit;display:inline-block}.btn:active,.btn:focus,.btn:hover{opacity:.75;border:none}.btn.btn-sm{padding:6px 12px}.btn.btn-md{padding:8px 16px}.btn.btn-lg{padding:10px 20px}.btn.btn-xl{padding:12px 24px;font-size:16px}.btn.btn-primary{background:#0041ff;color:#fff}.btn.btn-black{background:#000;color:#fff}.btn:disabled,.btn[disabled=disabled],.btn[disabled=disabled]:active,.btn[disabled=disabled]:hover{cursor:not-allowed;background:#b1b1ae;-webkit-box-shadow:none;box-shadow:none;opacity:1}.dropdown-open{position:relative}.dropdown-list{width:200px;margin-bottom:20px;-webkit-box-shadow:0 2px 4px 0 rgba(0,0,0,.16),0 0 9px 0 rgba(0,0,0,.16);box-shadow:0 2px 4px 0 rgba(0,0,0,.16),0 0 9px 0 rgba(0,0,0,.16);border-radius:3px;background-color:#fff;position:absolute;display:none;z-index:10;text-align:left}.dropdown-list.bottom-left{top:42px;left:0}.dropdown-list.bottom-right{top:42px;right:0}.dropdown-list.top-left{bottom:42px;left:0}.dropdown-list.top-right{bottom:42px;right:0}.dropdown-list .search-box{padding:20px;border-bottom:1px solid hsla(0,0%,64%,.2)}.dropdown-list .search-box .control{background:#fff;border:2px solid #c7c7c7;border-radius:3px;width:100%;height:36px;display:inline-block;vertical-align:middle;-webkit-transition:.2s cubic-bezier(.4,0,.2,1);transition:.2s cubic-bezier(.4,0,.2,1);padding:0 10px;font-size:15px}.dropdown-list .search-box .control:focus{border-color:#0041ff}.dropdown-list .dropdown-container{padding:20px;overflow-y:auto;max-height:280px}.dropdown-list .dropdown-container label{font-size:15px;display:inline-block;text-transform:uppercase;color:#9e9e9e;font-weight:700;padding-bottom:5px}.dropdown-list .dropdown-container ul{margin:0;list-style-type:none;padding:0}.dropdown-list .dropdown-container ul li{padding:5px 0}.dropdown-list .dropdown-container ul li a:active,.dropdown-list .dropdown-container ul li a:focus,.dropdown-list .dropdown-container ul li a:link,.dropdown-list .dropdown-container ul li a:visited{color:#333;display:block}.dropdown-list .dropdown-container ul li a:hover{color:#0041ff}.dropdown-list .dropdown-container ul li .checkbox{margin:0}.dropdown-list .dropdown-container ul li .control-group label{color:#3a3a3a;font-size:15px;font-weight:500;text-transform:capitalize;width:100%}.dropdown-list .dropdown-container .btn{width:100%;margin-top:10px}.table{width:100%;overflow-x:auto}.table table{width:100%;border-collapse:collapse;text-align:left}.table table thead th{font-weight:700;padding:12px 10px;background:#f8f9fa;color:#3a3a3a}.table table tbody td{padding:10px;border-bottom:1px solid #d3d3d3;color:#3a3a3a;vertical-align:top}.table table tbody td.actions{text-align:right}.table table tbody td.actions .icon{cursor:pointer;vertical-align:middle}.table table tbody td.empty{text-align:center}.table table tbody tr:last-child td{border-bottom:none}.table .control-group{width:100%;margin-bottom:0}.table .control-group .control{width:100%;margin:0}.dropdown-btn{min-width:150px;text-align:left;background:#fff;border:2px solid #c7c7c7;border-radius:3px;font-size:14px;padding:8px 35px 8px 10px;cursor:pointer;position:relative}.dropdown-btn:active,.dropdown-btn:focus,.dropdown-btn:hover{opacity:.75;border:2px solid #c7c7c7}.dropdown-btn .icon{position:absolute;right:10px;top:50%;margin-top:-4px}.pagination .page-item{background:#fff;border:2px solid #c7c7c7;border-radius:3px;padding:7px 14px;margin-right:5px;font-size:16px;display:inline-block;color:#8e8e8e;vertical-align:middle;text-decoration:none}.pagination .page-item.next,.pagination .page-item.previous{padding:6px 9px}.pagination .page-item.active{background:#0041ff;color:#fff;border-color:#0041ff}.pagination .page-item .icon{vertical-align:middle;margin-bottom:3px}.checkbox{position:relative;display:block}.checkbox input{left:0;opacity:0;position:absolute;top:0;height:24px;width:24px;z-index:100}.checkbox .checkbox-view{background-image:url("../images/Checkbox.svg");height:24px;width:24px;margin:0;display:inline-block!important;vertical-align:middle;margin-right:5px}.checkbox input:checked+.checkbox-view{background-image:url("../images/Checkbox-Checked.svg")}.checkbox input:disabled+.checkbox-view{opacity:.5;cursor:not-allowed}.radio{position:relative;display:block;margin:10px 5px 5px 0}.radio input{left:0;opacity:0;position:absolute;top:0;z-index:100}.radio .radio-view{background-image:url("../images/controls.svg");background-position:-21px 0;height:20px;width:20px;margin:0;display:inline-block!important;vertical-align:middle;margin-right:5px}.radio input:checked+.radio-view{background-position:-21px -21px}.radio input:disabled+.radio-view{opacity:.5;cursor:not-allowed}.control-group{display:block;margin-bottom:25px;font-size:15px;color:#333;width:750px;max-width:100%;position:relative}.control-group label{display:block;color:#3a3a3a}.control-group label.required:after{content:"*";color:#fc6868;font-weight:700;display:inline-block}.control-group textarea.control{height:100px;padding:10px}.control-group .control{background:#fff;border:2px solid #c7c7c7;border-radius:3px;width:70%;height:36px;display:inline-block;vertical-align:middle;-webkit-transition:.2s cubic-bezier(.4,0,.2,1);transition:.2s cubic-bezier(.4,0,.2,1);padding:0 10px;font-size:15px;margin-top:10px;margin-bottom:5px}.control-group .control:focus{border-color:#0041ff}.control-group .control[disabled=disabled]{border-color:#d3d3d3;background-color:#d3d3d3;cursor:not-allowed}.control-group .control[multiple]{height:100px}.control-group.date:after,.control-group.datetime:after{background-image:url("../images/Icon-Calendar.svg");width:24px;height:24px;content:"";display:inline-block;vertical-align:middle;margin-left:-34px;margin-top:2px;pointer-events:none}.control-group .control-info{display:block;font-style:italic;color:#6f6f6f}.control-group .control-error{display:none;color:#ff5656;margin-top:5px}.control-group.has-error .control{border-color:#fc6868}.control-group.has-error .control-error{display:block}.control-group.price .currency-code{vertical-align:middle;display:inline-block}.button-group{margin-top:20px;margin-bottom:20px}.alert-wrapper{width:300px;top:10px;right:10px;position:fixed;z-index:6;text-align:left}.alert-wrapper .alert{width:300px;padding:15px;border-radius:3px;display:inline-block;-webkit-box-shadow:0 4px 15.36px .64px rgba(0,0,0,.1),0 2px 6px 0 rgba(0,0,0,.12);box-shadow:0 4px 15.36px .64px rgba(0,0,0,.1),0 2px 6px 0 rgba(0,0,0,.12);position:relative;-webkit-animation:jelly .5s ease-in-out;animation:jelly .5s ease-in-out;-webkit-transform-origin:center top;transform-origin:center top;z-index:500;margin-bottom:10px}.alert-wrapper .alert.alert-error{background:#fc6868}.alert-wrapper .alert.alert-info{background:#204d74}.alert-wrapper .alert.alert-success{background:#4caf50}.alert-wrapper .alert.alert-warning{background:#ffc107}.alert-wrapper .alert .icon{position:absolute;right:10px;top:10px;cursor:pointer}.alert-wrapper .alert p{color:#fff;margin:0;padding:0;font-size:15px}.tabs ul{border-bottom:1px solid hsla(0,0%,64%,.2)}.tabs ul li{display:inline-block}.tabs ul li a{padding:15px 20px;cursor:pointer;margin:0 2px;text-align:center;color:#000311;display:block}.tabs ul li.active a{border-bottom:3px solid #0041ff}.accordian,accordian{display:inline-block;width:100%}.accordian .accordian-header,.accordian div[slot*=header],accordian .accordian-header,accordian div[slot*=header]{width:100%;display:inline-block;font-size:18px;color:#3a3a3a;border-bottom:1px solid hsla(0,0%,64%,.2);padding:20px 15px;cursor:pointer}.accordian .accordian-header .expand-icon,.accordian div[slot*=header] .expand-icon,accordian .accordian-header .expand-icon,accordian div[slot*=header] .expand-icon{background-image:url("../images/Expand-Light.svg");margin-right:10px;margin-top:3px}.accordian .accordian-header h1,.accordian div[slot*=header] h1,accordian .accordian-header h1,accordian div[slot*=header] h1{margin:0;font-size:20px;display:inline-block}.accordian .accordian-header .icon,.accordian div[slot*=header] .icon,accordian .accordian-header .icon,accordian div[slot*=header] .icon{float:right}.accordian .accordian-header .icon.left,.accordian div[slot*=header] .icon.left,accordian .accordian-header .icon.left,accordian div[slot*=header] .icon.left{float:left}.accordian .accordian-content,.accordian div[slot*=body],accordian .accordian-content,accordian div[slot*=body]{width:100%;padding:20px 15px;display:none;-webkit-transition:all .3s ease;transition:all .3s ease}.accordian.active>.accordian-content,accordian.active>.accordian-content{display:inline-block}.accordian.active>.accordian-header .expand-icon,accordian.active>.accordian-header .expand-icon{background-image:url("../images/Expand-Light-On.svg")}.tree-container .tree-item{padding-left:30px;display:inline-block;margin-top:10px;width:100%}.tree-container .tree-item>.tree-item{display:none}.tree-container .tree-item.active>.tree-item{display:inline-block}.tree-container .tree-item .checkbox,.tree-container .tree-item .radio{margin:0;display:inline-block}.tree-container .tree-item .expand-icon{display:inline-block;margin-right:10px;cursor:pointer;background-image:url("../images/Expand-Light.svg");width:18px;height:18px;vertical-align:middle}.tree-container .tree-item .folder-icon{vertical-align:middle;margin-right:10px}.tree-container .tree-item.active>.expand-icon{background-image:url("../images/Expand-Light-On.svg")}.tree-container>.tree-item{padding-left:0}.panel{-webkit-box-shadow:0 2px 25px 0 rgba(0,0,0,.15);box-shadow:0 2px 25px 0 rgba(0,0,0,.15);border-radius:5px;background:#fff}.panel .panel-content{padding:20px}modal{display:none}.modal-open{overflow:hidden}.modal-overlay{display:none;overflow-y:auto;z-index:10;top:0;right:0;bottom:0;left:0;position:fixed;background:#000;opacity:.75}.modal-open .modal-overlay{display:block}.modal-container{-webkit-animation:fade-in-white .3s ease-in-out;animation:fade-in-white .3s ease-in-out;z-index:11;margin-left:-350px;width:600px;max-width:80%;background:#fff;position:fixed;left:50%;top:100px;margin-bottom:100px;-webkit-box-shadow:0 15px 25px 0 rgba(0,0,0,.03),0 20px 45px 5px rgba(0,0,0,.2);box-shadow:0 15px 25px 0 rgba(0,0,0,.03),0 20px 45px 5px rgba(0,0,0,.2);-webkit-animation:jelly .5s ease-in-out;animation:jelly .5s ease-in-out;border-radius:5px}.modal-container .modal-header{padding:20px}.modal-container .modal-header h3{display:inline-block;font-size:20px;color:#3a3a3a;margin:0}.modal-container .modal-header .icon{float:right;cursor:pointer}.modal-container .modal-body{padding:20px}.modal-container .modal-body .control-group .control{width:100%}.label{background:#e7e7e7;border-radius:2px;padding:8px;color:#000311;display:inline-block}.label.label-sm{padding:5px}.label.label-md{padding:8px}.label.label-lg{padding:11px}.label.label-xl{padding:14px}.badge{border-radius:50px;color:#fff;padding:8px;white-space:nowrap}.badge.badge-sm{padding:5px}.badge.badge-md{padding:3px 10px}.badge.badge-lg{padding:11px}.badge.badge-xl{padding:14px}.badge.badge-success{background-color:#4caf50}.badge.badge-info{background-color:#0041ff}.badge.badge-danger{background-color:#fc6868}.badge.badge-warning{background-color:#ffc107}.image-wrapper{margin-bottom:20px;margin-top:10px;display:inline-block;width:100%}.image-wrapper .image-item{width:200px;height:200px;margin-right:20px;background:#f8f9fa;border-radius:3px;display:inline-block;position:relative;background-image:url("../images/placeholder-icon.svg");background-repeat:no-repeat;background-position:50%;margin-bottom:20px}.image-wrapper .image-item img.preview{width:100%;height:100%}.image-wrapper .image-item input{display:none}.image-wrapper .image-item .remove-image{background-image:-webkit-gradient(linear,left top,left bottom,from(rgba(0,0,0,.08)),to(rgba(0,0,0,.24)));background-image:linear-gradient(-180deg,rgba(0,0,0,.08),rgba(0,0,0,.24));border-radius:0 0 4px 4px;position:absolute;bottom:0;width:100%;padding:10px;text-align:center;color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.24);margin-right:20px;cursor:pointer}.image-wrapper .image-item:hover .remove-image{display:block}.image-wrapper .image-item.has-image{background-image:none}.cp-spinner{width:48px;height:48px;display:inline-block;-webkit-box-sizing:border-box;box-sizing:border-box}.cp-round:before{border-radius:50%;border:6px solid #bababa}.cp-round:after,.cp-round:before{content:" ";width:48px;height:48px;display:inline-block;-webkit-box-sizing:border-box;box-sizing:border-box;position:absolute;top:0;left:0}.cp-round:after{border-radius:50%;border-top:6px solid #0041ff;border-right:6px solid transparent;border-bottom:6px solid transparent;border-left:6px solid transparent;-webkit-animation:spin 1s ease-in-out infinite;animation:spin 1s ease-in-out infinite}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}} \ No newline at end of file +.active.configuration-icon,.catalog-icon,.configuration-icon,.customer-icon,.dashboard-icon,.sales-icon,.settings-icon{width:48px;height:48px;display:inline-block;background-size:cover}.icon{display:inline-block;background-size:cover}.dashboard-icon{background-image:url("../images/Icon-Dashboard.svg")}.sales-icon{background-image:url("../images/Icon-Sales.svg")}.catalog-icon{background-image:url("../images/Icon-Catalog.svg")}.customer-icon{background-image:url("../images/Icon-Customers.svg")}.configuration-icon{background-image:url("../images/Icon-Configure.svg")}.settings-icon{background-image:url("../images/Icon-Settings.svg")}.angle-right-icon{background-image:url("../images/Angle-Right.svg");width:17px;height:17px}.angle-left-icon{background-image:url("../images/Angle-Left.svg");width:17px;height:17px}.arrow-down-icon{background-image:url("../images/Arrow-Down-Light.svg");width:14px;height:8px}.arrow-right-icon{background-image:url("../images/Arrow-Right.svg");width:18px;height:18px}.white-cross-sm-icon{background-image:url("../images/Icon-Sm-Cross-White.svg");width:18px;height:18px}.accordian-up-icon{background-image:url("../images/Accordion-Arrow-Up.svg");width:24px;height:24px}.accordian-down-icon{background-image:url("../images/Accordion-Arrow-Down.svg");width:24px;height:24px}.cross-icon{background-image:url("../images/Icon-Crossed.svg");width:18px;height:18px}.trash-icon{background-image:url("../images/Icon-Trash.svg");width:24px;height:24px}.remove-icon{background-image:url("../images/Icon-remove.svg");width:24px;height:24px}.pencil-lg-icon{background-image:url("../images/Icon-Pencil-Large.svg");width:24px;height:24px}.eye-icon{background-image:url("../images/Icon-eye.svg");width:24px;height:24px}.search-icon{background-image:url("../images/icon-search.svg");width:24px;height:24px}.sortable-icon{background-image:url("../images/Icon-Sortable.svg");width:24px;height:24px}.sort-down-icon,.sort-up-icon{background-image:url("../images/Icon-Sort-Down.svg");width:18px;height:18px}.sort-up-icon{-webkit-transform:rotate(180deg);transform:rotate(180deg)}.primary-back-icon{background-image:url("../images/Icon-Back-Primary.svg");width:24px;height:24px}.checkbox-dash-icon{background-image:url("../images/Checkbox-Dash.svg");width:24px;height:24px}.account-icon{background-image:url("../images/icon-account.svg");width:24px;height:24px}.expand-icon{background-image:url("../images/Expand-Light.svg");width:18px;height:18px}.expand-on-icon{background-image:url("../images/Expand-Light-On.svg");width:18px;height:18px}.dark-left-icon{background-image:url("../images/arrow-left-dark.svg");width:18px;height:18px}.light-right-icon{background-image:url("../images/arrow-right-light.svg");width:18px;height:18px}.folder-icon{background-image:url("../images/Folder-Icon.svg");width:24px;height:24px}.star-icon{background-image:url("../images/Star-Icon.svg");width:24px;height:24px}.arrow-down-white-icon{background-image:url("../images/down-arrow-white.svg");width:17px;height:13px}.arrow-up-white-icon{background-image:url("../images/up-arrow-white.svg");width:17px;height:13px}.profile-pic-icon{background-image:url("../images/Profile-Pic.svg");width:60px;height:60px}.graph-up-icon{background-image:url("../images/Icon-Graph-Green.svg");width:24px;height:24px}.graph-down-icon{background-image:url("../images/Icon-Graph-Red.svg");width:24px;height:24px}.no-result-icon{background-image:url("../images/limited-icon.svg");width:52px;height:47px}.active .dashboard-icon{background-image:url("../images/Icon-Dashboard-Active.svg")}.active .sales-icon{background-image:url("../images/Icon-Sales-Active.svg")}.active .catalog-icon{background-image:url("../images/Icon-Catalog-Active.svg")}.active .customer-icon{background-image:url("../images/Icon-Customers-Active.svg")}.active .settings-icon{background-image:url("../images/Icon-Settings-Active.svg")}.active .configuration-icon{background-image:url("../images/Icon-Configure-Active.svg")}.active>.arrow-down-icon{background-image:url("../images/Arrow-Down.svg");width:14px;height:8px}.active>.expand-icon{background-image:url("../images/Expand-Light-On.svg")}.active.dashboard-icon{background-image:url("../images/Icon-Dashboard-Active.svg")}.active.customer-icon{background-image:url("../images/Icon-Customers-Active.svg")}.active.sales-icon{background-image:url("../images/Icon-Sales-Active.svg")}.active.settings-icon{background-image:url("../images/Icon-Settings-Active.svg")}.active.configuration-icon{background-image:url("../images/Icon-Configure-Active.svg")}.active.arrow-down-icon{background-image:url("../images/Arrow-Down.svg");width:14px;height:8px}.active.expand-icon{background-image:url("../images/Expand-Light-On.svg")}.icon-404{background-image:url("../images/404-image.svg");width:255px;height:255px}.export-icon{background-image:url("../images/Icon-Export.svg");width:32px;height:32px}.star-blue-icon{width:17px;height:17px;background-image:url("../images/Icon-star.svg")}.grid-container{display:block;width:100%;height:100%}.filter-row-one{-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.filter-row-one,.filter-row-two{display:-webkit-box;display:-ms-flexbox;display:flex;width:100%;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-webkit-box-align:center;-ms-flex-align:center;align-items:center;margin-bottom:10px}.filter-row-two,.search-filter{-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start}.search-filter{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.search-filter .control{background:#fff;border:2px solid #c7c7c7;border-right:none;border-top-right-radius:0;border-bottom-right-radius:0;border-radius:3px;height:36px;width:360px;padding-left:10px;font-size:15px;color:#8e8e8e}.search-filter .contorl:focus{border-color:#0041ff}.search-filter .icon-wrapper{border:2px solid #c7c7c7;border-radius:3px;border-top-left-radius:0;border-bottom-left-radius:0;height:36px;width:36px;margin-left:-1px}.search-filter .icon-wrapper .search-icon{margin-top:3px;margin-left:3px}.dropdown-header{display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:36px;width:202px;border:2px solid #c7c7c7;border-radius:3px;color:#8e8e8e;padding:0 5px}.dropdown-header .arrow-icon-down{float:right}.filter-tag{-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;border-radius:2px}.filter-tag,.filter-tag .wrapper{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-direction:row;flex-direction:row;-webkit-box-align:center;-ms-flex-align:center;align-items:center;font-size:14px;height:28px}.filter-tag .wrapper{margin-left:5px;padding:0 5px;background:#e7e7e7;color:#000311;letter-spacing:-.22px}.filter-tag:not(first-child){margin-left:10px}@-webkit-keyframes jelly{0%{-webkit-transform:translateY(0) scale(.7);transform:translateY(0) scale(.7);opacity:0}70%{-webkit-transform:translateY(5px) scale(1.05);transform:translateY(5px) scale(1.05);opacity:1}to{-webkit-transform:translateY(0) scale(1);transform:translateY(0) scale(1);opacity:1}}@keyframes jelly{0%{-webkit-transform:translateY(0) scale(.7);transform:translateY(0) scale(.7);opacity:0}70%{-webkit-transform:translateY(5px) scale(1.05);transform:translateY(5px) scale(1.05);opacity:1}to{-webkit-transform:translateY(0) scale(1);transform:translateY(0) scale(1);opacity:1}}@-webkit-keyframes jelly-out{0%{-webkit-transform:translateY(0) scale(1);transform:translateY(0) scale(1);opacity:1}30%{-webkit-transform:translateY(-5px) scale(1.05);transform:translateY(-5px) scale(1.05);opacity:1}to{-webkit-transform:translateY(0) scale(.7);transform:translateY(0) scale(.7);opacity:0}}@keyframes jelly-out{0%{-webkit-transform:translateY(0) scale(1);transform:translateY(0) scale(1);opacity:1}30%{-webkit-transform:translateY(-5px) scale(1.05);transform:translateY(-5px) scale(1.05);opacity:1}to{-webkit-transform:translateY(0) scale(.7);transform:translateY(0) scale(.7);opacity:0}}*{-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}:focus{outline:none}a:active,a:focus,a:hover,a:link,a:visited{text-decoration:none;color:#0041ff}textarea{resize:none}ul{margin:0;padding:0;list-style:none}h1{font-size:28px;margin-top:0}h1,h2{color:#3a3a3a}h2{font-size:18px}.tooltip{position:relative;border-bottom:1px solid #000}.tooltip .tooltiptext{visibility:hidden;width:120px;background-color:#000;color:#fff;text-align:center;border-radius:6px;padding:5px 0;position:absolute;z-index:1}.tooltip:hover .tooltiptext{visibility:visible}.hide{display:none!important}.btn{-webkit-box-shadow:0 1px 4px 0 rgba(0,0,0,.2),0 0 8px 0 rgba(0,0,0,.1);box-shadow:0 1px 4px 0 rgba(0,0,0,.2),0 0 8px 0 rgba(0,0,0,.1);border-radius:3px;border:none;color:#fff;cursor:pointer;-webkit-transition:.2s cubic-bezier(.4,0,.2,1);transition:.2s cubic-bezier(.4,0,.2,1);font:inherit;display:inline-block}.btn:active,.btn:focus,.btn:hover{opacity:.75;border:none}.btn.btn-sm{padding:6px 12px}.btn.btn-md{padding:8px 16px}.btn.btn-lg{padding:10px 20px}.btn.btn-xl{padding:12px 24px;font-size:16px}.btn.btn-primary{background:#0041ff;color:#fff}.btn.btn-black{background:#000;color:#fff}.btn:disabled,.btn[disabled=disabled],.btn[disabled=disabled]:active,.btn[disabled=disabled]:hover{cursor:not-allowed;background:#b1b1ae;-webkit-box-shadow:none;box-shadow:none;opacity:1}.dropdown-open{position:relative}.dropdown-list{width:200px;margin-bottom:20px;-webkit-box-shadow:0 2px 4px 0 rgba(0,0,0,.16),0 0 9px 0 rgba(0,0,0,.16);box-shadow:0 2px 4px 0 rgba(0,0,0,.16),0 0 9px 0 rgba(0,0,0,.16);border-radius:3px;background-color:#fff;position:absolute;display:none;z-index:10;text-align:left}.dropdown-list.bottom-left{top:42px;left:0}.dropdown-list.bottom-right{top:42px;right:0}.dropdown-list.top-left{bottom:42px;left:0}.dropdown-list.top-right{bottom:42px;right:0}.dropdown-list .search-box{padding:20px;border-bottom:1px solid hsla(0,0%,64%,.2)}.dropdown-list .search-box .control{background:#fff;border:2px solid #c7c7c7;border-radius:3px;width:100%;height:36px;display:inline-block;vertical-align:middle;-webkit-transition:.2s cubic-bezier(.4,0,.2,1);transition:.2s cubic-bezier(.4,0,.2,1);padding:0 10px;font-size:15px}.dropdown-list .search-box .control:focus{border-color:#0041ff}.dropdown-list .dropdown-container{padding:20px;overflow-y:auto;max-height:280px}.dropdown-list .dropdown-container label{font-size:15px;display:inline-block;text-transform:uppercase;color:#9e9e9e;font-weight:700;padding-bottom:5px}.dropdown-list .dropdown-container ul{margin:0;list-style-type:none;padding:0}.dropdown-list .dropdown-container ul li{padding:5px 0}.dropdown-list .dropdown-container ul li a:active,.dropdown-list .dropdown-container ul li a:focus,.dropdown-list .dropdown-container ul li a:link,.dropdown-list .dropdown-container ul li a:visited{color:#333;display:block}.dropdown-list .dropdown-container ul li a:hover{color:#0041ff}.dropdown-list .dropdown-container ul li .checkbox{margin:0}.dropdown-list .dropdown-container ul li .control-group label{color:#3a3a3a;font-size:15px;font-weight:500;text-transform:capitalize;width:100%}.dropdown-list .dropdown-container .btn{width:100%;margin-top:10px}.table{width:100%;overflow-x:auto}.table table{width:100%;border-collapse:collapse;text-align:left}.table table thead th{font-weight:700;padding:12px 10px;background:#f8f9fa;color:#3a3a3a}.table table tbody td{padding:10px;border-bottom:1px solid #d3d3d3;color:#3a3a3a;vertical-align:top}.table table tbody td.actions{text-align:right}.table table tbody td.actions .icon{cursor:pointer;vertical-align:middle}.table table tbody td.empty{text-align:center}.table table tbody td tr td{border:1px solid red}.table table tbody tr:last-child td{border-bottom:none}.table .control-group{width:100%;margin-bottom:0}.table .control-group .control{width:100%;margin:0}@media only screen and (max-width:770px){.table table thead{display:none}.table table tbody tr td:before{content:attr(data-value);font-size:15px;font-weight:600;margin-right:20px}.table table tbody td{border-bottom:none;display:block}.table table tbody tr{border:1px solid #c7c7c7}}.dropdown-btn{min-width:150px;text-align:left;background:#fff;border:2px solid #c7c7c7;border-radius:3px;font-size:14px;padding:8px 35px 8px 10px;cursor:pointer;position:relative}.dropdown-btn:active,.dropdown-btn:focus,.dropdown-btn:hover{opacity:.75;border:2px solid #c7c7c7}.dropdown-btn .icon{position:absolute;right:10px;top:50%;margin-top:-4px}.pagination .page-item{background:#fff;border:2px solid #c7c7c7;border-radius:3px;padding:7px 14px;margin-right:5px;font-size:16px;display:inline-block;color:#8e8e8e;vertical-align:middle;text-decoration:none}.pagination .page-item.next,.pagination .page-item.previous{padding:6px 9px}.pagination .page-item.active{background:#0041ff;color:#fff;border-color:#0041ff}.pagination .page-item .icon{vertical-align:middle;margin-bottom:3px}.checkbox{position:relative;display:block}.checkbox input{left:0;opacity:0;position:absolute;top:0;height:24px;width:24px;z-index:100}.checkbox .checkbox-view{background-image:url("../images/Checkbox.svg");height:24px;width:24px;margin:0;display:inline-block!important;vertical-align:middle;margin-right:5px}.checkbox input:checked+.checkbox-view{background-image:url("../images/Checkbox-Checked.svg")}.checkbox input:disabled+.checkbox-view{opacity:.5;cursor:not-allowed}.radio{position:relative;display:block;margin:10px 5px 5px 0}.radio input{left:0;opacity:0;position:absolute;top:0;z-index:100}.radio .radio-view{background-image:url("../images/controls.svg");background-position:-21px 0;height:20px;width:20px;margin:0;display:inline-block!important;vertical-align:middle;margin-right:5px}.radio input:checked+.radio-view{background-position:-21px -21px}.radio input:disabled+.radio-view{opacity:.5;cursor:not-allowed}.control-group{display:block;margin-bottom:25px;font-size:15px;color:#333;width:750px;max-width:100%;position:relative}.control-group label{display:block;color:#3a3a3a}.control-group label.required:after{content:"*";color:#fc6868;font-weight:700;display:inline-block}.control-group textarea.control{height:100px;padding:10px}.control-group .control{background:#fff;border:2px solid #c7c7c7;border-radius:3px;width:70%;height:36px;display:inline-block;vertical-align:middle;-webkit-transition:.2s cubic-bezier(.4,0,.2,1);transition:.2s cubic-bezier(.4,0,.2,1);padding:0 10px;font-size:15px;margin-top:10px;margin-bottom:5px}.control-group .control:focus{border-color:#0041ff}.control-group .control[disabled=disabled]{border-color:#d3d3d3;background-color:#d3d3d3;cursor:not-allowed}.control-group .control[multiple]{height:100px}.control-group.date:after,.control-group.datetime:after{background-image:url("../images/Icon-Calendar.svg");width:24px;height:24px;content:"";display:inline-block;vertical-align:middle;margin-left:-34px;margin-top:2px;pointer-events:none}.control-group .control-info{display:block;font-style:italic;color:#6f6f6f}.control-group .control-error{display:none;color:#ff5656;margin-top:5px}.control-group.has-error .control{border-color:#fc6868}.control-group.has-error .control-error{display:block}.control-group.price .currency-code{vertical-align:middle;display:inline-block}.button-group{margin-top:20px;margin-bottom:20px}.alert-wrapper{width:300px;top:10px;right:10px;position:fixed;z-index:6;text-align:left}.alert-wrapper .alert{width:300px;padding:15px;border-radius:3px;display:inline-block;-webkit-box-shadow:0 4px 15.36px .64px rgba(0,0,0,.1),0 2px 6px 0 rgba(0,0,0,.12);box-shadow:0 4px 15.36px .64px rgba(0,0,0,.1),0 2px 6px 0 rgba(0,0,0,.12);position:relative;-webkit-animation:jelly .5s ease-in-out;animation:jelly .5s ease-in-out;-webkit-transform-origin:center top;transform-origin:center top;z-index:500;margin-bottom:10px}.alert-wrapper .alert.alert-error{background:#fc6868}.alert-wrapper .alert.alert-info{background:#204d74}.alert-wrapper .alert.alert-success{background:#4caf50}.alert-wrapper .alert.alert-warning{background:#ffc107}.alert-wrapper .alert .icon{position:absolute;right:10px;top:10px;cursor:pointer}.alert-wrapper .alert p{color:#fff;margin:0;padding:0;font-size:15px}.tabs ul{border-bottom:1px solid hsla(0,0%,64%,.2)}.tabs ul li{display:inline-block}.tabs ul li a{padding:15px 20px;cursor:pointer;margin:0 2px;text-align:center;color:#000311;display:block}.tabs ul li.active a{border-bottom:3px solid #0041ff}.accordian,accordian{display:inline-block;width:100%}.accordian .accordian-header,.accordian div[slot*=header],accordian .accordian-header,accordian div[slot*=header]{width:100%;display:inline-block;font-size:18px;color:#3a3a3a;border-bottom:1px solid hsla(0,0%,64%,.2);padding:20px 15px;cursor:pointer}.accordian .accordian-header .expand-icon,.accordian div[slot*=header] .expand-icon,accordian .accordian-header .expand-icon,accordian div[slot*=header] .expand-icon{background-image:url("../images/Expand-Light.svg");margin-right:10px;margin-top:3px}.accordian .accordian-header h1,.accordian div[slot*=header] h1,accordian .accordian-header h1,accordian div[slot*=header] h1{margin:0;font-size:20px;display:inline-block}.accordian .accordian-header .icon,.accordian div[slot*=header] .icon,accordian .accordian-header .icon,accordian div[slot*=header] .icon{float:right}.accordian .accordian-header .icon.left,.accordian div[slot*=header] .icon.left,accordian .accordian-header .icon.left,accordian div[slot*=header] .icon.left{float:left}.accordian .accordian-content,.accordian div[slot*=body],accordian .accordian-content,accordian div[slot*=body]{width:100%;padding:20px 15px;display:none;-webkit-transition:all .3s ease;transition:all .3s ease}.accordian.active>.accordian-content,accordian.active>.accordian-content{display:inline-block}.accordian.active>.accordian-header .expand-icon,accordian.active>.accordian-header .expand-icon{background-image:url("../images/Expand-Light-On.svg")}.tree-container .tree-item{padding-left:30px;display:inline-block;margin-top:10px;width:100%}.tree-container .tree-item>.tree-item{display:none}.tree-container .tree-item.active>.tree-item{display:inline-block}.tree-container .tree-item .checkbox,.tree-container .tree-item .radio{margin:0;display:inline-block}.tree-container .tree-item .expand-icon{display:inline-block;margin-right:10px;cursor:pointer;background-image:url("../images/Expand-Light.svg");width:18px;height:18px;vertical-align:middle}.tree-container .tree-item .folder-icon{vertical-align:middle;margin-right:10px}.tree-container .tree-item.active>.expand-icon{background-image:url("../images/Expand-Light-On.svg")}.tree-container>.tree-item{padding-left:0}.panel{-webkit-box-shadow:0 2px 25px 0 rgba(0,0,0,.15);box-shadow:0 2px 25px 0 rgba(0,0,0,.15);border-radius:5px;background:#fff}.panel .panel-content{padding:20px}modal{display:none}.modal-open{overflow:hidden}.modal-overlay{display:none;overflow-y:auto;z-index:10;top:0;right:0;bottom:0;left:0;position:fixed;background:#000;opacity:.75}.modal-open .modal-overlay{display:block}.modal-container{-webkit-animation:fade-in-white .3s ease-in-out;animation:fade-in-white .3s ease-in-out;z-index:11;margin-left:-350px;width:600px;max-width:80%;background:#fff;position:fixed;left:50%;top:100px;margin-bottom:100px;-webkit-box-shadow:0 15px 25px 0 rgba(0,0,0,.03),0 20px 45px 5px rgba(0,0,0,.2);box-shadow:0 15px 25px 0 rgba(0,0,0,.03),0 20px 45px 5px rgba(0,0,0,.2);-webkit-animation:jelly .5s ease-in-out;animation:jelly .5s ease-in-out;border-radius:5px}.modal-container .modal-header{padding:20px}.modal-container .modal-header h3{display:inline-block;font-size:20px;color:#3a3a3a;margin:0}.modal-container .modal-header .icon{float:right;cursor:pointer}.modal-container .modal-body{padding:20px}.modal-container .modal-body .control-group .control{width:100%}.label{background:#e7e7e7;border-radius:2px;padding:8px;color:#000311;display:inline-block}.label.label-sm{padding:5px}.label.label-md{padding:8px}.label.label-lg{padding:11px}.label.label-xl{padding:14px}.badge{border-radius:50px;color:#fff;padding:8px;white-space:nowrap}.badge.badge-sm{padding:5px}.badge.badge-md{padding:3px 10px}.badge.badge-lg{padding:11px}.badge.badge-xl{padding:14px}.badge.badge-success{background-color:#4caf50}.badge.badge-info{background-color:#0041ff}.badge.badge-danger{background-color:#fc6868}.badge.badge-warning{background-color:#ffc107}.image-wrapper{margin-bottom:20px;margin-top:10px;display:inline-block;width:100%}.image-wrapper .image-item{width:200px;height:200px;margin-right:20px;background:#f8f9fa;border-radius:3px;display:inline-block;position:relative;background-image:url("../images/placeholder-icon.svg");background-repeat:no-repeat;background-position:50%;margin-bottom:20px}.image-wrapper .image-item img.preview{width:100%;height:100%}.image-wrapper .image-item input{display:none}.image-wrapper .image-item .remove-image{background-image:-webkit-gradient(linear,left top,left bottom,from(rgba(0,0,0,.08)),to(rgba(0,0,0,.24)));background-image:linear-gradient(-180deg,rgba(0,0,0,.08),rgba(0,0,0,.24));border-radius:0 0 4px 4px;position:absolute;bottom:0;width:100%;padding:10px;text-align:center;color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.24);margin-right:20px;cursor:pointer}.image-wrapper .image-item:hover .remove-image{display:block}.image-wrapper .image-item.has-image{background-image:none}.cp-spinner{width:48px;height:48px;display:inline-block;-webkit-box-sizing:border-box;box-sizing:border-box}.cp-round:before{border-radius:50%;border:6px solid #bababa}.cp-round:after,.cp-round:before{content:" ";width:48px;height:48px;display:inline-block;-webkit-box-sizing:border-box;box-sizing:border-box;position:absolute;top:0;left:0}.cp-round:after{border-radius:50%;border-top:6px solid #0041ff;border-right:6px solid transparent;border-bottom:6px solid transparent;border-left:6px solid transparent;-webkit-animation:spin 1s ease-in-out infinite;animation:spin 1s ease-in-out infinite}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}} \ No newline at end of file diff --git a/packages/Webkul/Ui/publishable/assets/js/ui.js b/packages/Webkul/Ui/publishable/assets/js/ui.js index d522d3ea5..f3fa85503 100755 --- a/packages/Webkul/Ui/publishable/assets/js/ui.js +++ b/packages/Webkul/Ui/publishable/assets/js/ui.js @@ -1 +1 @@ -!function(e){var t={};function n(i){if(t[i])return t[i].exports;var a=t[i]={i:i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,n),a.l=!0,a.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)}({"+wdr":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={data:function(){return{sample:"",image_file:"",file:null,newImage:""}},mounted:function(){this.sample="";var e=this.$el.getElementsByTagName("input")[0],t=this;e.onchange=function(){var n=new FileReader;n.readAsDataURL(e.files[0]),n.onload=function(e){this.img=document.getElementsByTagName("input")[0],this.img.src=e.target.result,t.newImage=this.img.src,t.changePreview()}}},methods:{removePreviewImage:function(){this.sample=""},changePreview:function(){this.sample=this.newImage}},computed:{getInputImage:function(){console.log(this.imageData)}}}},0:function(e,t,n){n("J66Q"),n("Oy72"),e.exports=n("MT9B")},"13ON":function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",[n("div",{staticClass:"tabs"},[n("ul",e._l(e.tabs,function(t){return n("li",{class:{active:t.isActive},on:{click:function(n){e.selectTab(t)}}},[n("a",[e._v(e._s(t.name))])])}))]),e._v(" "),n("div",{staticClass:"tabs-content"},[e._t("default")],2)])},staticRenderFns:[]}},"2JMG":function(e,t,n){var i=n("VU/8")(n("G3lE"),null,!1,null,null,null);e.exports=i.exports},"31/P":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.default={name:"tree-view",inheritAttrs:!1,props:{inputType:String,nameField:String,idField:String,captionField:String,childrenField:String,valueField:String,items:{type:[Array,String,Object],required:!1,default:null},value:{type:Array,required:!1,default:null},behavior:{type:String,required:!1,default:"reactive"},savedValues:{type:Array,required:!1,default:null}},created:function(){-1!==this.savedValues.indexOf(this.items[this.valueField])&&this.value.push(this.items)},computed:{caption:function(){return this.items[this.captionField]},allChildren:function(){var e=this,t=[];return function n(a){if(a[e.childrenField]&&e.getLength(a[e.childrenField])>0)if("object"==i(a[e.childrenField]))for(var r in a[e.childrenField])n(a[e.childrenField][r]);else a[e.childrenField].forEach(function(e){return n(e)});else t.push(a)}(this.items),t},hasChildren:function(){return!!this.items[this.childrenField]&&this.getLength(this.items[this.childrenField])>0},hasSelection:function(){return!!this.value&&this.value.length>0},isAllChildrenSelected:function(){var e=this;return this.hasChildren&&this.hasSelection&&this.allChildren.every(function(t){return e.value.some(function(n){return n[e.idField]===t[e.idField]})})},isSomeChildrenSelected:function(){var e=this;return this.hasChildren&&this.hasSelection&&this.allChildren.some(function(t){return e.value.some(function(n){return n[e.idField]===t[e.idField]})})}},methods:{getLength:function(e){if("object"==(void 0===e?"undefined":i(e))){var t=0;for(var n in e)t++;return t}return e.length},generateRoot:function(){var e=this;return"checkbox"==this.inputType?"reactive"==this.behavior?this.$createElement("tree-checkbox",{props:{id:this.items[this.idField],label:this.caption,nameField:this.nameField,modelValue:this.items[this.valueField],inputValue:this.hasChildren?this.isSomeChildrenSelected:this.value,value:this.hasChildren?this.isAllChildrenSelected:this.items},on:{change:function(t){e.hasChildren?(e.isAllChildrenSelected?e.allChildren.forEach(function(t){var n=e.value.indexOf(t);e.value.splice(n,1)}):e.allChildren.forEach(function(t){var n=!1;e.value.forEach(function(e){e.key==t.key&&(n=!0)}),n||e.value.push(t)}),e.$emit("input",e.value)):e.$emit("input",t)}}}):this.$createElement("tree-checkbox",{props:{id:this.items[this.idField],label:this.caption,nameField:this.nameField,modelValue:this.items[this.valueField],inputValue:this.value,value:this.items}}):"radio"==this.inputType?this.$createElement("tree-radio",{props:{id:this.items[this.idField],label:this.caption,nameField:this.nameField,modelValue:this.items[this.valueField],value:this.savedValues}}):void 0},generateChild:function(e){var t=this;return this.$createElement("tree-item",{on:{input:function(e){t.$emit("input",e)}},props:{items:e,value:this.value,savedValues:this.savedValues,nameField:this.nameField,inputType:this.inputType,captionField:this.captionField,childrenField:this.childrenField,valueField:this.valueField,idField:this.idField,behavior:this.behavior}})},generateChildren:function(){var e=this,t=[];if(this.items[this.childrenField])if("object"==i(this.items[this.childrenField]))for(var n in this.items[this.childrenField])t.push(this.generateChild(this.items[this.childrenField][n]));else this.items[this.childrenField].forEach(function(n){t.push(e.generateChild(n))});return t},generateIcon:function(){var e=this;return this.$createElement("i",{class:["expand-icon"],on:{click:function(t){e.$el.classList.toggle("active")}}})},generateFolderIcon:function(){return this.$createElement("i",{class:["icon","folder-icon"]})}},render:function(e){return e("div",{class:["tree-item","active",this.hasChildren?"has-children":""]},[this.generateIcon(),this.generateFolderIcon(),this.generateRoot()].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t0},attrs:{for:e._uid}},[n("input",{attrs:{type:"hidden",name:e.finalInputName}}),e._v(" "),n("input",{directives:[{name:"validate",rawName:"v-validate",value:"mimes:image/*",expression:"'mimes:image/*'"}],ref:"imageInput",attrs:{type:"file",accept:"image/*",name:e.finalInputName,id:e._uid},on:{change:function(t){e.addImageView(t)}}}),e._v(" "),e.imageData.length>0?n("img",{staticClass:"preview",attrs:{src:e.imageData}}):e._e(),e._v(" "),n("label",{staticClass:"remove-image",on:{click:function(t){e.removeImage()}}},[e._v(e._s(e.removeButtonLabel))])])},staticRenderFns:[]}},"44Sb":function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("span",{staticClass:"radio"},[n("input",{attrs:{type:"radio",id:e.id,name:e.nameField},domProps:{value:e.modelValue,checked:e.isActive}}),e._v(" "),n("label",{staticClass:"radio-view",attrs:{for:e.id}}),e._v(" "),n("span",{attrs:{for:e.id}},[e._v(e._s(e.label))])])},staticRenderFns:[]}},"6wXy":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={props:{title:String,id:String,className:String,active:Boolean},inject:["$validator"],data:function(){return{isActive:!1,imageData:""}},mounted:function(){this.isActive=this.active},methods:{toggleAccordion:function(){this.isActive=!this.isActive}},computed:{iconClass:function(){return{"accordian-down-icon":!this.isActive,"accordian-up-icon":this.isActive}}}}},"7aQn":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"tree-view",inheritAttrs:!1,props:{inputType:{type:String,required:!1,default:"checkbox"},nameField:{type:String,required:!1,default:"permissions"},idField:{type:String,required:!1,default:"id"},valueField:{type:String,required:!1,default:"value"},captionField:{type:String,required:!1,default:"name"},childrenField:{type:String,required:!1,default:"children"},items:{type:[Array,String,Object],required:!1,default:function(){return[]}},behavior:{type:String,required:!1,default:"reactive"},value:{type:[Array,String,Object],required:!1,default:function(){return[]}}},data:function(){return{finalValues:[]}},computed:{savedValues:function(){return this.value?"radio"==this.inputType?[this.value]:"string"==typeof this.value?JSON.parse(this.value):this.value:[]}},methods:{generateChildren:function(){var e=[],t="string"==typeof this.items?JSON.parse(this.items):this.items;for(var n in t)e.push(this.generateTreeItem(t[n]));return e},generateTreeItem:function(e){var t=this;return this.$createElement("tree-item",{props:{items:e,value:this.finalValues,savedValues:this.savedValues,nameField:this.nameField,inputType:this.inputType,captionField:this.captionField,childrenField:this.childrenField,valueField:this.valueField,idField:this.idField,behavior:this.behavior},on:{input:function(e){t.finalValues=e}}})}},render:function(e){return e("div",{class:["tree-container"]},[this.generateChildren()])}}},"7z1m":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={data:function(){return{uid:1,flashes:[]}},methods:{addFlash:function(e){e.uid=this.uid++,this.flashes.push(e)},removeFlash:function(e){var t=this.flashes.indexOf(e);this.flashes.splice(t,1)}}}},"8skS":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={props:{inputName:{type:String,required:!1,default:"attachments"},removeButtonLabel:{type:String},image:{type:Object,required:!1,default:null}},data:function(){return{imageData:""}},mounted:function(){this.image.id&&this.image.url&&(this.imageData=this.image.url)},computed:{finalInputName:function(){return this.inputName+"["+this.image.id+"]"}},methods:{addImageView:function(){var e=this,t=this.$refs.imageInput;if(t.files&&t.files[0])if(t.files[0].type.includes("image/")){var n=new FileReader;n.onload=function(t){e.imageData=t.target.result},n.readAsDataURL(t.files[0])}else t.value="",alert("Only images (.jpeg, .jpg, .png, ..) are allowed.")},removeImage:function(){this.$emit("onRemoveImage",this.image)}}}},"9yns":function(e,t,n){var i=n("VU/8")(n("EsN/"),n("wq5e"),!1,null,null,null);e.exports=i.exports},AOOz:function(e,t){e.exports={render:function(){var e=this.$createElement,t=this._self._c||e;return t("div",{staticClass:"alert",class:this.flash.type},[t("span",{staticClass:"icon white-cross-sm-icon",on:{click:this.remove}}),this._v(" "),t("p",[this._v(this._s(this.flash.message))])])},staticRenderFns:[]}},C2Px:function(e,t,n){var i=n("VU/8")(n("G8Iw"),n("rsIj"),!1,null,null,null);e.exports=i.exports},EZgW:function(e,t,n){var i=n("VU/8")(n("+wdr"),n("fXJ7"),!1,function(e){n("KJcg")},null,null);e.exports=i.exports},"EsN/":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n("GxBP"),a=n.n(i);t.default={props:{name:String,value:String},data:function(){return{datepicker:null}},mounted:function(){var e=this,t=this.$el.getElementsByTagName("input")[0];this.datepicker=new a.a(t,{allowInput:!0,altFormat:"Y-m-d H:i:s",dateFormat:"Y-m-d H:i:s",enableTime:!0,onChange:function(t,n,i){e.$emit("onChange",n)}})}}},"FZ+f":function(e,t){e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var n=function(e,t){var n=e[1]||"",i=e[3];if(!i)return n;if(t&&"function"==typeof btoa){var a=(o=i,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */"),r=i.sources.map(function(e){return"/*# sourceURL="+i.sourceRoot+e+" */"});return[n].concat(r).concat([a]).join("\n")}var o;return[n].join("\n")}(t,e);return t[2]?"@media "+t[2]+"{"+n+"}":n}).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var i={},a=0;a11)]},M:function(e,t){return r(e.getMonth(),!0,t)},S:function(t){return e(t.getSeconds())},U:function(e){return e.getTime()/1e3},W:function(e,t,n){return n.getWeek(e)},Y:function(e){return e.getFullYear()},d:function(t){return e(t.getDate())},h:function(e){return e.getHours()%12?e.getHours()%12:12},i:function(t){return e(t.getMinutes())},j:function(e){return e.getDate()},l:function(e,t){return t.weekdays.longhand[e.getDay()]},m:function(t){return e(t.getMonth()+1)},n:function(e){return e.getMonth()+1},s:function(e){return e.getSeconds()},w:function(e){return e.getDay()},y:function(e){return String(e.getFullYear()).substring(2)}},c={weekdays:{shorthand:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longhand:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},months:{shorthand:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longhand:["January","February","March","April","May","June","July","August","September","October","November","December"]},daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],firstDayOfWeek:0,ordinal:function(e){var t=e%100;if(t>3&&t<21)return"th";switch(t%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}},rangeSeparator:" to ",weekAbbreviation:"Wk",scrollTitle:"Scroll to increment",toggleTitle:"Click to toggle",amPM:["AM","PM"],yearAriaLabel:"Year"},d=function(e){var t=e.config,n=void 0===t?g:t,i=e.l10n,a=void 0===i?c:i;return function(e,t,i){var r=i||a;return void 0!==n.formatDate?n.formatDate(e,t,r):t.split("").map(function(t,i,a){return s[t]&&"\\"!==a[i-1]?s[t](e,r,n):"\\"!==t?t:""}).join("")}},u=function(e){var t=e.config,n=void 0===t?g:t,i=e.l10n,a=void 0===i?c:i;return function(e,t,i,r){if(0===e||e){var s,c=r||a,d=e;if(e instanceof Date)s=new Date(e.getTime());else if("string"!=typeof e&&void 0!==e.toFixed)s=new Date(e);else if("string"==typeof e){var u=t||(n||g).dateFormat,f=String(e).trim();if("today"===f)s=new Date,i=!0;else if(/Z$/.test(f)||/GMT$/.test(f))s=new Date(e);else if(n&&n.parseDate)s=n.parseDate(e,u);else{s=n&&n.noCalendar?new Date((new Date).setHours(0,0,0,0)):new Date((new Date).getFullYear(),0,1,0,0,0,0);for(var p,h=[],m=0,v=0,b="";mMath.min(t,n)&&e",noCalendar:!1,now:new Date,onChange:[],onClose:[],onDayCreate:[],onDestroy:[],onKeyDown:[],onMonthChange:[],onOpen:[],onParseConfig:[],onReady:[],onValueUpdate:[],onYearChange:[],onPreCalendarPosition:[],plugins:[],position:"auto",positionElement:void 0,prevArrow:"",shorthandCurrentMonth:!1,showMonths:1,static:!1,time_24hr:!1,weekNumbers:!1,wrap:!1};function v(e,t,n){if(!0===n)return e.classList.add(t);e.classList.remove(t)}function b(e,t,n){var i=window.document.createElement(e);return t=t||"",n=n||"",i.className=t,void 0!==n&&(i.textContent=n),i}function y(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function w(e,t){var n=b("div","numInputWrapper"),i=b("input","numInput "+e),a=b("span","arrowUp"),r=b("span","arrowDown");if(i.type="text",i.pattern="\\d*",void 0!==t)for(var o in t)i.setAttribute(o,t[o]);return n.appendChild(i),n.appendChild(a),n.appendChild(r),n}"function"!=typeof Object.assign&&(Object.assign=function(e){if(!e)throw TypeError("Cannot convert undefined or null to object");for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;io&&(u=a===s.hourElement?u-o-t(!s.amPM):r,p&&N(void 0,1,s.hourElement)),s.amPM&&f&&(1===l?u+c===23:Math.abs(u-c)>l)&&(s.amPM.textContent=s.l10n.amPM[t(s.amPM.textContent===s.l10n.amPM[0])]),a.value=e(u)}}(n);var i=s._input.value;M(),me(),s._input.value!==i&&s._debouncedChange()}}function M(){if(void 0!==s.hourElement&&void 0!==s.minuteElement){var e,n,i=(parseInt(s.hourElement.value.slice(-2),10)||0)%24,a=(parseInt(s.minuteElement.value,10)||0)%60,r=void 0!==s.secondElement?(parseInt(s.secondElement.value,10)||0)%60:0;void 0!==s.amPM&&(e=i,n=s.amPM.textContent,i=e%12+12*t(n===s.l10n.amPM[1]));var o=void 0!==s.config.minTime||s.config.minDate&&s.minDateHasTime&&s.latestSelectedDateObj&&0===f(s.latestSelectedDateObj,s.config.minDate,!0);if(void 0!==s.config.maxTime||s.config.maxDate&&s.maxDateHasTime&&s.latestSelectedDateObj&&0===f(s.latestSelectedDateObj,s.config.maxDate,!0)){var l=void 0!==s.config.maxTime?s.config.maxTime:s.config.maxDate;(i=Math.min(i,l.getHours()))===l.getHours()&&(a=Math.min(a,l.getMinutes())),a===l.getMinutes()&&(r=Math.min(r,l.getSeconds()))}if(o){var c=void 0!==s.config.minTime?s.config.minTime:s.config.minDate;(i=Math.max(i,c.getHours()))===c.getHours()&&(a=Math.max(a,c.getMinutes())),a===c.getMinutes()&&(r=Math.max(r,c.getSeconds()))}T(i,a,r)}}function _(e){var t=e||s.latestSelectedDateObj;t&&T(t.getHours(),t.getMinutes(),t.getSeconds())}function E(){var e=s.config.defaultHour,t=s.config.defaultMinute,n=s.config.defaultSeconds;if(void 0!==s.config.minDate){var i=s.config.minDate.getHours(),a=s.config.minDate.getMinutes();(e=Math.max(e,i))===i&&(t=Math.max(a,t)),e===i&&t===a&&(n=s.config.minDate.getSeconds())}if(void 0!==s.config.maxDate){var r=s.config.maxDate.getHours(),o=s.config.maxDate.getMinutes();(e=Math.min(e,r))===r&&(t=Math.min(o,t)),e===r&&t===o&&(n=s.config.maxDate.getSeconds())}T(e,t,n)}function T(n,i,a){void 0!==s.latestSelectedDateObj&&s.latestSelectedDateObj.setHours(n%24,i,a||0,0),s.hourElement&&s.minuteElement&&!s.isMobile&&(s.hourElement.value=e(s.config.time_24hr?n:(12+n)%12+12*t(n%12==0)),s.minuteElement.value=e(i),void 0!==s.amPM&&(s.amPM.textContent=s.l10n.amPM[t(n>=12)]),void 0!==s.secondElement&&(s.secondElement.value=e(a)))}function I(e){var t=parseInt(e.target.value)+(e.delta||0);(t/1e3>1||"Enter"===e.key&&!/[^\d]/.test(t.toString()))&&Z(t)}function F(e,t,n,i){return t instanceof Array?t.forEach(function(t){return F(e,t,n,i)}):e instanceof Array?e.forEach(function(e){return F(e,t,n,i)}):(e.addEventListener(t,n,i),void s._handlers.push({element:e,event:t,handler:n,options:i}))}function S(e){return function(t){1===t.which&&e(t)}}function O(){de("onChange")}function A(e){var t=void 0!==e?s.parseDate(e):s.latestSelectedDateObj||(s.config.minDate&&s.config.minDate>s.now?s.config.minDate:s.config.maxDate&&s.config.maxDate=0&&f(e,s.selectedDates[1])<=0}(t)&&!fe(t)&&r.classList.add("inRange"),s.weekNumbers&&1===s.config.showMonths&&"prevMonthDay"!==e&&n%7==1&&s.weekNumbers.insertAdjacentHTML("beforeend",""+s.config.getWeek(t)+""),de("onDayCreate",r),r}function P(e){e.focus(),"range"===s.config.mode&&Q(e)}function L(e){for(var t=e>0?0:s.config.showMonths-1,n=e>0?s.config.showMonths:-1,i=t;i!=n;i+=e)for(var a=s.daysContainer.children[i],r=e>0?0:a.children.length-1,o=e>0?a.children.length:-1,l=r;l!=o;l+=e){var c=a.children[l];if(-1===c.className.indexOf("hidden")&&K(c.dateObj))return c}}function Y(e,t){var n=G(document.activeElement||document.body),i=void 0!==e?e:n?document.activeElement:void 0!==s.selectedDateElem&&G(s.selectedDateElem)?s.selectedDateElem:void 0!==s.todayDateElem&&G(s.todayDateElem)?s.todayDateElem:L(t>0?1:-1);return void 0===i?s._input.focus():n?void function(e,t){for(var n=-1===e.className.indexOf("Month")?e.dateObj.getMonth():s.currentMonth,i=t>0?s.config.showMonths:-1,a=t>0?1:-1,r=n-s.currentMonth;r!=i;r+=a)for(var o=s.daysContainer.children[r],l=n-s.currentMonth===r?e.$i+t:t<0?o.children.length-1:0,c=o.children.length,d=l;d>=0&&d0?c:-1);d+=a){var u=o.children[d];if(-1===u.className.indexOf("hidden")&&K(u.dateObj)&&Math.abs(e.$i-d)>=Math.abs(t))return P(u)}s.changeMonth(a),Y(L(a),0)}(i,t):P(i)}function V(e,t){for(var n=(new Date(e,t,1).getDay()-s.l10n.firstDayOfWeek+7)%7,i=s.utils.getDaysInMonth((t-1+12)%12),a=s.utils.getDaysInMonth(t),r=window.document.createDocumentFragment(),o=s.config.showMonths>1,l=o?"prevMonthDay hidden":"prevMonthDay",c=o?"nextMonthDay hidden":"nextMonthDay",d=i+1-n,u=0;d<=i;d++,u++)r.appendChild(R(l,new Date(e,t-1,d),d,u));for(d=1;d<=a;d++,u++)r.appendChild(R("",new Date(e,t,d),d,u));for(var f=a+1;f<=42-n&&(1===s.config.showMonths||u%7!=0);f++,u++)r.appendChild(R(c,new Date(e,t+1,f%a),f,u));var p=b("div","dayContainer");return p.appendChild(r),p}function H(){if(void 0!==s.daysContainer){y(s.daysContainer),s.weekNumbers&&y(s.weekNumbers);for(var e=document.createDocumentFragment(),t=0;t0&&e\n "+t.join("")+"\n \n "}function q(e,t){void 0===t&&(t=!0);var n=t?e:e-s.currentMonth;n<0&&!0===s._hidePrevMonthArrow||n>0&&!0===s._hideNextMonthArrow||(s.currentMonth+=n,(s.currentMonth<0||s.currentMonth>11)&&(s.currentYear+=s.currentMonth>11?1:-1,s.currentMonth=(s.currentMonth+12)%12,de("onYearChange")),H(),de("onMonthChange"),pe())}function z(e){return!(!s.config.appendTo||!s.config.appendTo.contains(e))||s.calendarContainer.contains(e)}function J(e){if(s.isOpen&&!s.config.inline){var t=z(e.target),n=e.target===s.input||e.target===s.altInput||s.element.contains(e.target)||e.path&&e.path.indexOf&&(~e.path.indexOf(s.input)||~e.path.indexOf(s.altInput)),i="blur"===e.type?n&&e.relatedTarget&&!z(e.relatedTarget):!n&&!t,a=!s.config.ignoredFocusElements.some(function(t){return t.contains(e.target)});i&&a&&(s.close(),"range"===s.config.mode&&1===s.selectedDates.length&&(s.clear(!1),s.redraw()))}}function Z(e){if(!(!e||s.config.minDate&&es.config.maxDate.getFullYear())){var t=e,n=s.currentYear!==t;s.currentYear=t||s.currentYear,s.config.maxDate&&s.currentYear===s.config.maxDate.getFullYear()?s.currentMonth=Math.min(s.config.maxDate.getMonth(),s.currentMonth):s.config.minDate&&s.currentYear===s.config.minDate.getFullYear()&&(s.currentMonth=Math.max(s.config.minDate.getMonth(),s.currentMonth)),n&&(s.redraw(),de("onYearChange"))}}function K(e,t){void 0===t&&(t=!0);var n=s.parseDate(e,void 0,t);if(s.config.minDate&&n&&f(n,s.config.minDate,void 0!==t?t:!s.minDateHasTime)<0||s.config.maxDate&&n&&f(n,s.config.maxDate,void 0!==t?t:!s.maxDateHasTime)>0)return!1;if(0===s.config.enable.length&&0===s.config.disable.length)return!0;if(void 0===n)return!1;for(var i,a=s.config.enable.length>0,r=a?s.config.enable:s.config.disable,o=0;o=i.from.getTime()&&n.getTime()<=i.to.getTime())return a}return!a}function G(e){return void 0!==s.daysContainer&&(-1===e.className.indexOf("hidden")&&s.daysContainer.contains(e))}function X(e){var t=e.target===s._input,n=s.config.allowInput,i=s.isOpen&&(!n||!t),a=s.config.inline&&t&&!n;if(13===e.keyCode&&t){if(n)return s.setDate(s._input.value,!0,e.target===s.altInput?s.config.altFormat:s.config.dateFormat),e.target.blur();s.open()}else if(z(e.target)||i||a){var r=!!s.timeContainer&&s.timeContainer.contains(e.target);switch(e.keyCode){case 13:r?C():oe(e);break;case 27:e.preventDefault(),re();break;case 8:case 46:t&&!s.config.allowInput&&(e.preventDefault(),s.clear());break;case 37:case 39:if(r)s.hourElement&&s.hourElement.focus();else if(e.preventDefault(),void 0!==s.daysContainer&&(!1===n||G(document.activeElement))){var o=39===e.keyCode?1:-1;e.ctrlKey?(q(o),Y(L(1),0)):Y(void 0,o)}break;case 38:case 40:e.preventDefault();var l=40===e.keyCode?1:-1;s.daysContainer&&void 0!==e.target.$i?e.ctrlKey?(Z(s.currentYear-l),Y(L(1),0)):r||Y(void 0,7*l):s.config.enableTime&&(!r&&s.hourElement&&s.hourElement.focus(),C(e),s._debouncedChange());break;case 9:if(!r){s.element.focus();break}var c=[s.hourElement,s.minuteElement,s.secondElement,s.amPM].filter(function(e){return e}),d=c.indexOf(e.target);if(-1!==d){var u=c[d+(e.shiftKey?-1:1)];void 0!==u?(e.preventDefault(),u.focus()):s.element.focus()}}}if(void 0!==s.amPM&&e.target===s.amPM)switch(e.key){case s.l10n.amPM[0].charAt(0):case s.l10n.amPM[0].charAt(0).toLowerCase():s.amPM.textContent=s.l10n.amPM[0],M(),me();break;case s.l10n.amPM[1].charAt(0):case s.l10n.amPM[1].charAt(0).toLowerCase():s.amPM.textContent=s.l10n.amPM[1],M(),me()}de("onKeyDown",e)}function Q(e){if(1===s.selectedDates.length&&(!e||e.classList.contains("flatpickr-day")&&!e.classList.contains("disabled"))){for(var t=e?e.dateObj.getTime():s.days.firstElementChild.dateObj.getTime(),n=s.parseDate(s.selectedDates[0],void 0,!0).getTime(),i=Math.min(t,s.selectedDates[0].getTime()),a=Math.max(t,s.selectedDates[0].getTime()),r=s.daysContainer.lastChild.lastChild.dateObj.getTime(),o=!1,l=0,c=0,d=i;di&&dl)?l=d:d>n&&(!c||d0&&d0&&d>c;return h?(r.classList.add("notAllowed"),["inRange","startRange","endRange"].forEach(function(e){r.classList.remove(e)}),"continue"):o&&!h?"continue":(["startRange","inRange","endRange","notAllowed"].forEach(function(e){r.classList.remove(e)}),void(void 0!==e&&(e.classList.add(t0&&m&&m.lastChild.dateObj.getTime()>=d||(nt&&d===n&&r.classList.add("endRange"),d>=l&&(0===c||d<=c)&&p(d,n,t)&&r.classList.add("inRange")))))},v=0,b=f.children.length;v0||n.getMinutes()>0||n.getSeconds()>0),s.selectedDates&&(s.selectedDates=s.selectedDates.filter(function(e){return K(e)}),s.selectedDates.length||"min"!==e||_(n),me()),s.daysContainer&&(ae(),void 0!==n?s.currentYearElement[e]=n.getFullYear().toString():s.currentYearElement.removeAttribute(e),s.currentYearElement.disabled=!!i&&void 0!==n&&i.getFullYear()===n.getFullYear())}}function ne(){"object"!=typeof s.config.locale&&void 0===D.l10ns[s.config.locale]&&s.config.errorHandler(new Error("flatpickr: invalid locale "+s.config.locale)),s.l10n=Object.assign({},D.l10ns.default,"object"==typeof s.config.locale?s.config.locale:"default"!==s.config.locale?D.l10ns[s.config.locale]:void 0),l.K="("+s.l10n.amPM[0]+"|"+s.l10n.amPM[1]+"|"+s.l10n.amPM[0].toLowerCase()+"|"+s.l10n.amPM[1].toLowerCase()+")",s.formatDate=d(s),s.parseDate=u({config:s.config,l10n:s.l10n})}function ie(e){if(void 0!==s.calendarContainer){de("onPreCalendarPosition");var t=e||s._positionElement,n=Array.prototype.reduce.call(s.calendarContainer.children,function(e,t){return e+t.offsetHeight},0),i=s.calendarContainer.offsetWidth,a=s.config.position.split(" "),r=a[0],o=a.length>1?a[1]:null,l=t.getBoundingClientRect(),c=window.innerHeight-l.bottom,d="above"===r||"below"!==r&&cn,u=window.pageYOffset+l.top+(d?-n-2:t.offsetHeight+2);if(v(s.calendarContainer,"arrowTop",!d),v(s.calendarContainer,"arrowBottom",d),!s.config.inline){var f=window.pageXOffset+l.left-(null!=o&&"center"===o?(i-l.width)/2:0),p=window.document.body.offsetWidth-l.right,h=f+i>window.document.body.offsetWidth;v(s.calendarContainer,"rightMost",h),s.config.static||(s.calendarContainer.style.top=u+"px",h?(s.calendarContainer.style.left="auto",s.calendarContainer.style.right=p+"px"):(s.calendarContainer.style.left=f+"px",s.calendarContainer.style.right="auto"))}}}function ae(){s.config.noCalendar||s.isMobile||(pe(),H())}function re(){s._input.focus(),-1!==window.navigator.userAgent.indexOf("MSIE")||void 0!==navigator.msMaxTouchPoints?setTimeout(s.close,0):s.close()}function oe(e){e.preventDefault(),e.stopPropagation();var t=function e(t,n){return n(t)?t:t.parentNode?e(t.parentNode,n):void 0}(e.target,function(e){return e.classList&&e.classList.contains("flatpickr-day")&&!e.classList.contains("disabled")&&!e.classList.contains("notAllowed")});if(void 0!==t){var n=t,i=s.latestSelectedDateObj=new Date(n.dateObj.getTime()),a=(i.getMonth()s.currentMonth+s.config.showMonths-1)&&"range"!==s.config.mode;if(s.selectedDateElem=n,"single"===s.config.mode)s.selectedDates=[i];else if("multiple"===s.config.mode){var r=fe(i);r?s.selectedDates.splice(parseInt(r),1):s.selectedDates.push(i)}else"range"===s.config.mode&&(2===s.selectedDates.length&&s.clear(!1),s.selectedDates.push(i),0!==f(i,s.selectedDates[0],!0)&&s.selectedDates.sort(function(e,t){return e.getTime()-t.getTime()}));if(M(),a){var o=s.currentYear!==i.getFullYear();s.currentYear=i.getFullYear(),s.currentMonth=i.getMonth(),o&&de("onYearChange"),de("onMonthChange")}if(pe(),H(),me(),s.config.enableTime&&setTimeout(function(){return s.showTimeInput=!0},50),a||"range"===s.config.mode||1!==s.config.showMonths?s.selectedDateElem&&s.selectedDateElem.focus():P(n),void 0!==s.hourElement&&setTimeout(function(){return void 0!==s.hourElement&&s.hourElement.select()},451),s.config.closeOnSelect){var l="single"===s.config.mode&&!s.config.enableTime,c="range"===s.config.mode&&2===s.selectedDates.length&&!s.config.enableTime;(l||c)&&re()}O()}}s.parseDate=u({config:s.config,l10n:s.l10n}),s._handlers=[],s._bind=F,s._setHoursFromDate=_,s._positionCalendar=ie,s.changeMonth=q,s.changeYear=Z,s.clear=function(e){void 0===e&&(e=!0);s.input.value="",void 0!==s.altInput&&(s.altInput.value="");void 0!==s.mobileInput&&(s.mobileInput.value="");s.selectedDates=[],s.latestSelectedDateObj=void 0,s.showTimeInput=!1,!0===s.config.enableTime&&E();s.redraw(),e&&de("onChange")},s.close=function(){s.isOpen=!1,s.isMobile||(s.calendarContainer.classList.remove("open"),s._input.classList.remove("active"));de("onClose")},s._createElement=b,s.destroy=function(){void 0!==s.config&&de("onDestroy");for(var e=s._handlers.length;e--;){var t=s._handlers[e];t.element.removeEventListener(t.event,t.handler,t.options)}if(s._handlers=[],s.mobileInput)s.mobileInput.parentNode&&s.mobileInput.parentNode.removeChild(s.mobileInput),s.mobileInput=void 0;else if(s.calendarContainer&&s.calendarContainer.parentNode)if(s.config.static&&s.calendarContainer.parentNode){var n=s.calendarContainer.parentNode;if(n.lastChild&&n.removeChild(n.lastChild),n.parentNode){for(;n.firstChild;)n.parentNode.insertBefore(n.firstChild,n);n.parentNode.removeChild(n)}}else s.calendarContainer.parentNode.removeChild(s.calendarContainer);s.altInput&&(s.input.type="text",s.altInput.parentNode&&s.altInput.parentNode.removeChild(s.altInput),delete s.altInput);s.input&&(s.input.type=s.input._type,s.input.classList.remove("flatpickr-input"),s.input.removeAttribute("readonly"),s.input.value="");["_showTimeInput","latestSelectedDateObj","_hideNextMonthArrow","_hidePrevMonthArrow","__hideNextMonthArrow","__hidePrevMonthArrow","isMobile","isOpen","selectedDateElem","minDateHasTime","maxDateHasTime","days","daysContainer","_input","_positionElement","innerContainer","rContainer","monthNav","todayDateElem","calendarContainer","weekdayContainer","prevMonthNav","nextMonthNav","currentMonthElement","currentYearElement","navigationCurrentMonth","selectedDateElem","config"].forEach(function(e){try{delete s[e]}catch(e){}})},s.isEnabled=K,s.jumpToDate=A,s.open=function(e,t){void 0===t&&(t=s._positionElement);if(!0===s.isMobile)return e&&(e.preventDefault(),e.target&&e.target.blur()),void 0!==s.mobileInput&&(s.mobileInput.focus(),s.mobileInput.click()),void de("onOpen");if(s._input.disabled||s.config.inline)return;var n=s.isOpen;s.isOpen=!0,n||(s.calendarContainer.classList.add("open"),s._input.classList.add("active"),de("onOpen"),ie(t));!0===s.config.enableTime&&!0===s.config.noCalendar&&(0===s.selectedDates.length&&(s.setDate(void 0!==s.config.minDate?new Date(s.config.minDate.getTime()):new Date,!1),E(),me()),!1!==s.config.allowInput||void 0!==e&&s.timeContainer.contains(e.relatedTarget)||setTimeout(function(){return s.hourElement.select()},50))},s.redraw=ae,s.set=function(e,t){null!==e&&"object"==typeof e?Object.assign(s.config,e):(s.config[e]=t,void 0!==le[e]?le[e].forEach(function(e){return e()}):m.indexOf(e)>-1&&(s.config[e]=i(t)));s.redraw(),A(),me(!1)},s.setDate=function(e,t,n){void 0===t&&(t=!1);void 0===n&&(n=s.config.dateFormat);if(0!==e&&!e||e instanceof Array&&0===e.length)return s.clear(t);se(e,n),s.showTimeInput=s.selectedDates.length>0,s.latestSelectedDateObj=s.selectedDates[0],s.redraw(),A(),_(),me(t),t&&de("onChange")},s.toggle=function(e){if(!0===s.isOpen)return s.close();s.open(e)};var le={locale:[ne,B],showMonths:[U,k,W]};function se(e,t){var n=[];if(e instanceof Array)n=e.map(function(e){return s.parseDate(e,t)});else if(e instanceof Date||"number"==typeof e)n=[s.parseDate(e,t)];else if("string"==typeof e)switch(s.config.mode){case"single":case"time":n=[s.parseDate(e,t)];break;case"multiple":n=e.split(s.config.conjunction).map(function(e){return s.parseDate(e,t)});break;case"range":n=e.split(s.l10n.rangeSeparator).map(function(e){return s.parseDate(e,t)})}else s.config.errorHandler(new Error("Invalid date supplied: "+JSON.stringify(e)));s.selectedDates=n.filter(function(e){return e instanceof Date&&K(e,!1)}),"range"===s.config.mode&&s.selectedDates.sort(function(e,t){return e.getTime()-t.getTime()})}function ce(e){return e.slice().map(function(e){return"string"==typeof e||"number"==typeof e||e instanceof Date?s.parseDate(e,void 0,!0):e&&"object"==typeof e&&e.from&&e.to?{from:s.parseDate(e.from,void 0),to:s.parseDate(e.to,void 0)}:e}).filter(function(e){return e})}function de(e,t){if(void 0!==s.config){var n=s.config[e];if(void 0!==n&&n.length>0)for(var i=0;n[i]&&is.config.maxDate.getMonth():s.currentYear>s.config.maxDate.getFullYear()))}function he(e){return s.selectedDates.map(function(t){return s.formatDate(t,e)}).filter(function(e,t,n){return"range"!==s.config.mode||s.config.enableTime||n.indexOf(e)===t}).join("range"!==s.config.mode?s.config.conjunction:s.l10n.rangeSeparator)}function me(e){if(void 0===e&&(e=!0),0===s.selectedDates.length)return s.clear(e);void 0!==s.mobileInput&&s.mobileFormatStr&&(s.mobileInput.value=void 0!==s.latestSelectedDateObj?s.formatDate(s.latestSelectedDateObj,s.mobileFormatStr):""),s.input.value=he(s.config.dateFormat),void 0!==s.altInput&&(s.altInput.value=he(s.config.altFormat)),!1!==e&&de("onValueUpdate")}function ge(e){e.preventDefault();var t=s.prevMonthNav.contains(e.target),n=s.nextMonthNav.contains(e.target);t||n?q(t?-1:1):s.yearElements.indexOf(e.target)>=0?e.target.select():e.target.classList.contains("arrowUp")?s.changeYear(s.currentYear+1):e.target.classList.contains("arrowDown")&&s.changeYear(s.currentYear-1)}return function(){s.element=s.input=a,s.isOpen=!1,function(){var e=["wrap","weekNumbers","allowInput","clickOpens","time_24hr","enableTime","noCalendar","altInput","shorthandCurrentMonth","inline","static","enableSeconds","disableMobile"],t=Object.assign({},o,JSON.parse(JSON.stringify(a.dataset||{}))),n={};s.config.parseDate=t.parseDate,s.config.formatDate=t.formatDate,Object.defineProperty(s.config,"enable",{get:function(){return s.config._enable},set:function(e){s.config._enable=ce(e)}}),Object.defineProperty(s.config,"disable",{get:function(){return s.config._disable},set:function(e){s.config._disable=ce(e)}});var r="time"===t.mode;t.dateFormat||!t.enableTime&&!r||(n.dateFormat=t.noCalendar||r?"H:i"+(t.enableSeconds?":S":""):D.defaultConfig.dateFormat+" H:i"+(t.enableSeconds?":S":"")),t.altInput&&(t.enableTime||r)&&!t.altFormat&&(n.altFormat=t.noCalendar||r?"h:i"+(t.enableSeconds?":S K":" K"):D.defaultConfig.altFormat+" h:i"+(t.enableSeconds?":S":"")+" K"),Object.defineProperty(s.config,"minDate",{get:function(){return s.config._minDate},set:te("min")}),Object.defineProperty(s.config,"maxDate",{get:function(){return s.config._maxDate},set:te("max")});var l=function(e){return function(t){s.config["min"===e?"_minTime":"_maxTime"]=s.parseDate(t,"H:i")}};Object.defineProperty(s.config,"minTime",{get:function(){return s.config._minTime},set:l("min")}),Object.defineProperty(s.config,"maxTime",{get:function(){return s.config._maxTime},set:l("max")}),"time"===t.mode&&(s.config.noCalendar=!0,s.config.enableTime=!0),Object.assign(s.config,n,t);for(var c=0;c-1?s.config[f]=i(u[f]).map(g).concat(s.config[f]):void 0===t[f]&&(s.config[f]=u[f])}de("onParseConfig")}(),ne(),s.input=s.config.wrap?a.querySelector("[data-input]"):a,s.input?(s.input._type=s.input.type,s.input.type="text",s.input.classList.add("flatpickr-input"),s._input=s.input,s.config.altInput&&(s.altInput=b(s.input.nodeName,s.input.className+" "+s.config.altInputClass),s._input=s.altInput,s.altInput.placeholder=s.input.placeholder,s.altInput.disabled=s.input.disabled,s.altInput.required=s.input.required,s.altInput.tabIndex=s.input.tabIndex,s.altInput.type="text",s.input.setAttribute("type","hidden"),!s.config.static&&s.input.parentNode&&s.input.parentNode.insertBefore(s.altInput,s.input.nextSibling)),s.config.allowInput||s._input.setAttribute("readonly","readonly"),s._positionElement=s.config.positionElement||s._input):s.config.errorHandler(new Error("Invalid input element specified")),function(){s.selectedDates=[],s.now=s.parseDate(s.config.now)||new Date;var e=s.config.defaultDate||("INPUT"!==s.input.nodeName&&"TEXTAREA"!==s.input.nodeName||!s.input.placeholder||s.input.value!==s.input.placeholder?s.input.value:null);e&&se(e,s.config.dateFormat);var t=s.selectedDates.length>0?s.selectedDates[0]:s.config.minDate&&s.config.minDate.getTime()>s.now.getTime()?s.config.minDate:s.config.maxDate&&s.config.maxDate.getTime()0&&(s.latestSelectedDateObj=s.selectedDates[0]),void 0!==s.config.minTime&&(s.config.minTime=s.parseDate(s.config.minTime,"H:i")),void 0!==s.config.maxTime&&(s.config.maxTime=s.parseDate(s.config.maxTime,"H:i")),s.minDateHasTime=!!s.config.minDate&&(s.config.minDate.getHours()>0||s.config.minDate.getMinutes()>0||s.config.minDate.getSeconds()>0),s.maxDateHasTime=!!s.config.maxDate&&(s.config.maxDate.getHours()>0||s.config.maxDate.getMinutes()>0||s.config.maxDate.getSeconds()>0),Object.defineProperty(s,"showTimeInput",{get:function(){return s._showTimeInput},set:function(e){s._showTimeInput=e,s.calendarContainer&&v(s.calendarContainer,"showTimeInput",e),s.isOpen&&ie()}})}(),s.utils={getDaysInMonth:function(e,t){return void 0===e&&(e=s.currentMonth),void 0===t&&(t=s.currentYear),1===e&&(t%4==0&&t%100!=0||t%400==0)?29:s.l10n.daysInMonth[e]}},s.isMobile||function(){var n=window.document.createDocumentFragment();if(s.calendarContainer=b("div","flatpickr-calendar"),s.calendarContainer.tabIndex=-1,!s.config.noCalendar){if(n.appendChild((s.monthNav=b("div","flatpickr-months"),s.yearElements=[],s.monthElements=[],s.prevMonthNav=b("span","flatpickr-prev-month"),s.prevMonthNav.innerHTML=s.config.prevArrow,s.nextMonthNav=b("span","flatpickr-next-month"),s.nextMonthNav.innerHTML=s.config.nextArrow,U(),Object.defineProperty(s,"_hidePrevMonthArrow",{get:function(){return s.__hidePrevMonthArrow},set:function(e){s.__hidePrevMonthArrow!==e&&(v(s.prevMonthNav,"disabled",e),s.__hidePrevMonthArrow=e)}}),Object.defineProperty(s,"_hideNextMonthArrow",{get:function(){return s.__hideNextMonthArrow},set:function(e){s.__hideNextMonthArrow!==e&&(v(s.nextMonthNav,"disabled",e),s.__hideNextMonthArrow=e)}}),s.currentYearElement=s.yearElements[0],pe(),s.monthNav)),s.innerContainer=b("div","flatpickr-innerContainer"),s.config.weekNumbers){var i=function(){s.calendarContainer.classList.add("hasWeeks");var e=b("div","flatpickr-weekwrapper");e.appendChild(b("span","flatpickr-weekday",s.l10n.weekAbbreviation));var t=b("div","flatpickr-weeks");return e.appendChild(t),{weekWrapper:e,weekNumbers:t}}(),a=i.weekWrapper,r=i.weekNumbers;s.innerContainer.appendChild(a),s.weekNumbers=r,s.weekWrapper=a}s.rContainer=b("div","flatpickr-rContainer"),s.rContainer.appendChild(W()),s.daysContainer||(s.daysContainer=b("div","flatpickr-days"),s.daysContainer.tabIndex=-1),H(),s.rContainer.appendChild(s.daysContainer),s.innerContainer.appendChild(s.rContainer),n.appendChild(s.innerContainer)}s.config.enableTime&&n.appendChild(function(){s.calendarContainer.classList.add("hasTime"),s.config.noCalendar&&s.calendarContainer.classList.add("noCalendar"),s.timeContainer=b("div","flatpickr-time"),s.timeContainer.tabIndex=-1;var n=b("span","flatpickr-time-separator",":"),i=w("flatpickr-hour");s.hourElement=i.getElementsByTagName("input")[0];var a=w("flatpickr-minute");if(s.minuteElement=a.getElementsByTagName("input")[0],s.hourElement.tabIndex=s.minuteElement.tabIndex=-1,s.hourElement.value=e(s.latestSelectedDateObj?s.latestSelectedDateObj.getHours():s.config.time_24hr?s.config.defaultHour:function(e){switch(e%24){case 0:case 12:return 12;default:return e%12}}(s.config.defaultHour)),s.minuteElement.value=e(s.latestSelectedDateObj?s.latestSelectedDateObj.getMinutes():s.config.defaultMinute),s.hourElement.setAttribute("data-step",s.config.hourIncrement.toString()),s.minuteElement.setAttribute("data-step",s.config.minuteIncrement.toString()),s.hourElement.setAttribute("data-min",s.config.time_24hr?"0":"1"),s.hourElement.setAttribute("data-max",s.config.time_24hr?"23":"12"),s.minuteElement.setAttribute("data-min","0"),s.minuteElement.setAttribute("data-max","59"),s.timeContainer.appendChild(i),s.timeContainer.appendChild(n),s.timeContainer.appendChild(a),s.config.time_24hr&&s.timeContainer.classList.add("time24hr"),s.config.enableSeconds){s.timeContainer.classList.add("hasSeconds");var r=w("flatpickr-second");s.secondElement=r.getElementsByTagName("input")[0],s.secondElement.value=e(s.latestSelectedDateObj?s.latestSelectedDateObj.getSeconds():s.config.defaultSeconds),s.secondElement.setAttribute("data-step",s.minuteElement.getAttribute("data-step")),s.secondElement.setAttribute("data-min",s.minuteElement.getAttribute("data-min")),s.secondElement.setAttribute("data-max",s.minuteElement.getAttribute("data-max")),s.timeContainer.appendChild(b("span","flatpickr-time-separator",":")),s.timeContainer.appendChild(r)}return s.config.time_24hr||(s.amPM=b("span","flatpickr-am-pm",s.l10n.amPM[t((s.latestSelectedDateObj?s.hourElement.value:s.config.defaultHour)>11)]),s.amPM.title=s.l10n.toggleTitle,s.amPM.tabIndex=-1,s.timeContainer.appendChild(s.amPM)),s.timeContainer}()),v(s.calendarContainer,"rangeMode","range"===s.config.mode),v(s.calendarContainer,"animate",!0===s.config.animate),v(s.calendarContainer,"multiMonth",s.config.showMonths>1),s.calendarContainer.appendChild(n);var o=void 0!==s.config.appendTo&&void 0!==s.config.appendTo.nodeType;if((s.config.inline||s.config.static)&&(s.calendarContainer.classList.add(s.config.inline?"inline":"static"),s.config.inline&&(!o&&s.element.parentNode?s.element.parentNode.insertBefore(s.calendarContainer,s._input.nextSibling):void 0!==s.config.appendTo&&s.config.appendTo.appendChild(s.calendarContainer)),s.config.static)){var l=b("div","flatpickr-wrapper");s.element.parentNode&&s.element.parentNode.insertBefore(l,s.element),l.appendChild(s.element),s.altInput&&l.appendChild(s.altInput),l.appendChild(s.calendarContainer)}s.config.static||s.config.inline||(void 0!==s.config.appendTo?s.config.appendTo:window.document.body).appendChild(s.calendarContainer)}(),function(){if(s.config.wrap&&["open","close","toggle","clear"].forEach(function(e){Array.prototype.forEach.call(s.element.querySelectorAll("[data-"+e+"]"),function(t){return F(t,"click",s[e])})}),s.isMobile)!function(){var e=s.config.enableTime?s.config.noCalendar?"time":"datetime-local":"date";s.mobileInput=b("input",s.input.className+" flatpickr-mobile"),s.mobileInput.step=s.input.getAttribute("step")||"any",s.mobileInput.tabIndex=1,s.mobileInput.type=e,s.mobileInput.disabled=s.input.disabled,s.mobileInput.required=s.input.required,s.mobileInput.placeholder=s.input.placeholder,s.mobileFormatStr="datetime-local"===e?"Y-m-d\\TH:i:S":"date"===e?"Y-m-d":"H:i:S",s.selectedDates.length>0&&(s.mobileInput.defaultValue=s.mobileInput.value=s.formatDate(s.selectedDates[0],s.mobileFormatStr)),s.config.minDate&&(s.mobileInput.min=s.formatDate(s.config.minDate,"Y-m-d")),s.config.maxDate&&(s.mobileInput.max=s.formatDate(s.config.maxDate,"Y-m-d")),s.input.type="hidden",void 0!==s.altInput&&(s.altInput.type="hidden");try{s.input.parentNode&&s.input.parentNode.insertBefore(s.mobileInput,s.input.nextSibling)}catch(e){}F(s.mobileInput,"change",function(e){s.setDate(e.target.value,!1,s.mobileFormatStr),de("onChange"),de("onClose")})}();else{var e=n(ee,50);s._debouncedChange=n(O,x),s.daysContainer&&!/iPhone|iPad|iPod/i.test(navigator.userAgent)&&F(s.daysContainer,"mouseover",function(e){"range"===s.config.mode&&Q(e.target)}),F(window.document.body,"keydown",X),s.config.static||F(s._input,"keydown",X),s.config.inline||s.config.static||F(window,"resize",e),void 0!==window.ontouchstart?F(window.document,"click",J):F(window.document,"mousedown",S(J)),F(window.document,"focus",J,{capture:!0}),!0===s.config.clickOpens&&(F(s._input,"focus",s.open),F(s._input,"mousedown",S(s.open))),void 0!==s.daysContainer&&(F(s.monthNav,"mousedown",S(ge)),F(s.monthNav,["keyup","increment"],I),F(s.daysContainer,"mousedown",S(oe))),void 0!==s.timeContainer&&void 0!==s.minuteElement&&void 0!==s.hourElement&&(F(s.timeContainer,["increment"],C),F(s.timeContainer,"blur",C,{capture:!0}),F(s.timeContainer,"mousedown",S(j)),F([s.hourElement,s.minuteElement],["focus","click"],function(e){return e.target.select()}),void 0!==s.secondElement&&F(s.secondElement,"focus",function(){return s.secondElement&&s.secondElement.select()}),void 0!==s.amPM&&F(s.amPM,"mousedown",S(function(e){C(e),O()})))}}(),(s.selectedDates.length||s.config.noCalendar)&&(s.config.enableTime&&_(s.config.noCalendar?s.latestSelectedDateObj||s.config.minDate:void 0),me(!1)),k(),s.showTimeInput=s.selectedDates.length>0||s.config.noCalendar;var r=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);!s.isMobile&&r&&ie(),de("onReady")}(),s}function C(e,t){for(var n=Array.prototype.slice.call(e),i=[],a=0;a=0&&d.splice(t,1)}function g(e){var t=document.createElement("style");return e.attrs.type="text/css",v(t,e.attrs),h(e,t),t}function v(e,t){Object.keys(t).forEach(function(n){e.setAttribute(n,t[n])})}function b(e,t){var n,i,a,r;if(t.transform&&e.css){if(!(r=t.transform(e.css)))return function(){};e.css=r}if(t.singleton){var o=c++;n=s||(s=g(t)),i=x.bind(null,n,o,!1),a=x.bind(null,n,o,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(e){var t=document.createElement("link");return e.attrs.type="text/css",e.attrs.rel="stylesheet",v(t,e.attrs),h(e,t),t}(t),i=function(e,t,n){var i=n.css,a=n.sourceMap,r=void 0===t.convertToAbsoluteUrls&&a;(t.convertToAbsoluteUrls||r)&&(i=u(i));a&&(i+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(a))))+" */");var o=new Blob([i],{type:"text/css"}),l=e.href;e.href=URL.createObjectURL(o),l&&URL.revokeObjectURL(l)}.bind(null,n,t),a=function(){m(n),n.href&&URL.revokeObjectURL(n.href)}):(n=g(t),i=function(e,t){var n=t.css,i=t.media;i&&e.setAttribute("media",i);if(e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}.bind(null,n),a=function(){m(n)});return i(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;i(e=t)}else a()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||(t.singleton=o()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var n=p(e,t);return f(n,t),function(e){for(var i=[],a=0;ae||heightn.parts.length&&(i.parts.length=n.parts.length)}else{var o=[];for(a=0;a0)if("object"==i(a[e.childrenField]))for(var r in a[e.childrenField])n(a[e.childrenField][r]);else a[e.childrenField].forEach(function(e){return n(e)});else t.push(a)}(this.items),t},hasChildren:function(){return!!this.items[this.childrenField]&&this.getLength(this.items[this.childrenField])>0},hasSelection:function(){return!!this.value&&this.value.length>0},isAllChildrenSelected:function(){var e=this;return this.hasChildren&&this.hasSelection&&this.allChildren.every(function(t){return e.value.some(function(n){return n[e.idField]===t[e.idField]})})},isSomeChildrenSelected:function(){var e=this;return this.hasChildren&&this.hasSelection&&this.allChildren.some(function(t){return e.value.some(function(n){return n[e.idField]===t[e.idField]})})}},methods:{getLength:function(e){if("object"==(void 0===e?"undefined":i(e))){var t=0;for(var n in e)t++;return t}return e.length},generateRoot:function(){var e=this;return"checkbox"==this.inputType?"reactive"==this.behavior?this.$createElement("tree-checkbox",{props:{id:this.items[this.idField],label:this.caption,nameField:this.nameField,modelValue:this.items[this.valueField],inputValue:this.hasChildren?this.isSomeChildrenSelected:this.value,value:this.hasChildren?this.isAllChildrenSelected:this.items},on:{change:function(t){e.hasChildren?(e.isAllChildrenSelected?e.allChildren.forEach(function(t){var n=e.value.indexOf(t);e.value.splice(n,1)}):e.allChildren.forEach(function(t){var n=!1;e.value.forEach(function(e){e.key==t.key&&(n=!0)}),n||e.value.push(t)}),e.$emit("input",e.value)):e.$emit("input",t)}}}):this.$createElement("tree-checkbox",{props:{id:this.items[this.idField],label:this.caption,nameField:this.nameField,modelValue:this.items[this.valueField],inputValue:this.value,value:this.items}}):"radio"==this.inputType?this.$createElement("tree-radio",{props:{id:this.items[this.idField],label:this.caption,nameField:this.nameField,modelValue:this.items[this.valueField],value:this.savedValues}}):void 0},generateChild:function(e){var t=this;return this.$createElement("tree-item",{on:{input:function(e){t.$emit("input",e)}},props:{items:e,value:this.value,savedValues:this.savedValues,nameField:this.nameField,inputType:this.inputType,captionField:this.captionField,childrenField:this.childrenField,valueField:this.valueField,idField:this.idField,behavior:this.behavior}})},generateChildren:function(){var e=this,t=[];if(this.items[this.childrenField])if("object"==i(this.items[this.childrenField]))for(var n in this.items[this.childrenField])t.push(this.generateChild(this.items[this.childrenField][n]));else this.items[this.childrenField].forEach(function(n){t.push(e.generateChild(n))});return t},generateIcon:function(){var e=this;return this.$createElement("i",{class:["expand-icon"],on:{click:function(t){e.$el.classList.toggle("active")}}})},generateFolderIcon:function(){return this.$createElement("i",{class:["icon","folder-icon"]})}},render:function(e){return e("div",{class:["tree-item","active",this.hasChildren?"has-children":""]},[this.generateIcon(),this.generateFolderIcon(),this.generateRoot()].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t0},attrs:{for:e._uid}},[n("input",{attrs:{type:"hidden",name:e.finalInputName}}),e._v(" "),n("input",{directives:[{name:"validate",rawName:"v-validate",value:"mimes:image/*",expression:"'mimes:image/*'"}],ref:"imageInput",attrs:{type:"file",accept:"image/*",name:e.finalInputName,id:e._uid},on:{change:function(t){e.addImageView(t)}}}),e._v(" "),e.imageData.length>0?n("img",{staticClass:"preview",attrs:{src:e.imageData}}):e._e(),e._v(" "),n("label",{staticClass:"remove-image",on:{click:function(t){e.removeImage()}}},[e._v(e._s(e.removeButtonLabel))])])},staticRenderFns:[]}},"44Sb":function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("span",{staticClass:"radio"},[n("input",{attrs:{type:"radio",id:e.id,name:e.nameField},domProps:{value:e.modelValue,checked:e.isActive}}),e._v(" "),n("label",{staticClass:"radio-view",attrs:{for:e.id}}),e._v(" "),n("span",{attrs:{for:e.id}},[e._v(e._s(e.label))])])},staticRenderFns:[]}},"6wXy":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={props:{title:String,id:String,className:String,active:Boolean},inject:["$validator"],data:function(){return{isActive:!1,imageData:""}},mounted:function(){this.isActive=this.active},methods:{toggleAccordion:function(){this.isActive=!this.isActive}},computed:{iconClass:function(){return{"accordian-down-icon":!this.isActive,"accordian-up-icon":this.isActive}}}}},"7aQn":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"tree-view",inheritAttrs:!1,props:{inputType:{type:String,required:!1,default:"checkbox"},nameField:{type:String,required:!1,default:"permissions"},idField:{type:String,required:!1,default:"id"},valueField:{type:String,required:!1,default:"value"},captionField:{type:String,required:!1,default:"name"},childrenField:{type:String,required:!1,default:"children"},items:{type:[Array,String,Object],required:!1,default:function(){return[]}},behavior:{type:String,required:!1,default:"reactive"},value:{type:[Array,String,Object],required:!1,default:function(){return[]}}},data:function(){return{finalValues:[]}},computed:{savedValues:function(){return this.value?"radio"==this.inputType?[this.value]:"string"==typeof this.value?JSON.parse(this.value):this.value:[]}},methods:{generateChildren:function(){var e=[],t="string"==typeof this.items?JSON.parse(this.items):this.items;for(var n in t)e.push(this.generateTreeItem(t[n]));return e},generateTreeItem:function(e){var t=this;return this.$createElement("tree-item",{props:{items:e,value:this.finalValues,savedValues:this.savedValues,nameField:this.nameField,inputType:this.inputType,captionField:this.captionField,childrenField:this.childrenField,valueField:this.valueField,idField:this.idField,behavior:this.behavior},on:{input:function(e){t.finalValues=e}}})}},render:function(e){return e("div",{class:["tree-container"]},[this.generateChildren()])}}},"7z1m":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={data:function(){return{uid:1,flashes:[]}},methods:{addFlash:function(e){e.uid=this.uid++,this.flashes.push(e)},removeFlash:function(e){var t=this.flashes.indexOf(e);this.flashes.splice(t,1)}}}},"8skS":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={props:{inputName:{type:String,required:!1,default:"attachments"},removeButtonLabel:{type:String},image:{type:Object,required:!1,default:null}},data:function(){return{imageData:""}},mounted:function(){this.image.id&&this.image.url&&(this.imageData=this.image.url)},computed:{finalInputName:function(){return this.inputName+"["+this.image.id+"]"}},methods:{addImageView:function(){var e=this,t=this.$refs.imageInput;if(t.files&&t.files[0])if(t.files[0].type.includes("image/")){var n=new FileReader;n.onload=function(t){e.imageData=t.target.result},n.readAsDataURL(t.files[0])}else t.value="",alert("Only images (.jpeg, .jpg, .png, ..) are allowed.")},removeImage:function(){this.$emit("onRemoveImage",this.image)}}}},"9yns":function(e,t,n){var i=n("VU/8")(n("EsN/"),n("wq5e"),!1,null,null,null);e.exports=i.exports},AOOz:function(e,t){e.exports={render:function(){var e=this.$createElement,t=this._self._c||e;return t("div",{staticClass:"alert",class:this.flash.type},[t("span",{staticClass:"icon white-cross-sm-icon",on:{click:this.remove}}),this._v(" "),t("p",[this._v(this._s(this.flash.message))])])},staticRenderFns:[]}},C2Px:function(e,t,n){var i=n("VU/8")(n("G8Iw"),n("rsIj"),!1,null,null,null);e.exports=i.exports},EZgW:function(e,t,n){var i=n("VU/8")(n("+wdr"),n("fXJ7"),!1,function(e){n("KJcg")},null,null);e.exports=i.exports},"EsN/":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n("GxBP"),a=n.n(i);t.default={props:{name:String,value:String},data:function(){return{datepicker:null}},mounted:function(){var e=this,t=this.$el.getElementsByTagName("input")[0];this.datepicker=new a.a(t,{allowInput:!0,altFormat:"Y-m-d H:i:s",dateFormat:"Y-m-d H:i:s",enableTime:!0,onChange:function(t,n,i){e.$emit("onChange",n)}})}}},"FZ+f":function(e,t){e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var n=function(e,t){var n=e[1]||"",i=e[3];if(!i)return n;if(t&&"function"==typeof btoa){var a=(o=i,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */"),r=i.sources.map(function(e){return"/*# sourceURL="+i.sourceRoot+e+" */"});return[n].concat(r).concat([a]).join("\n")}var o;return[n].join("\n")}(t,e);return t[2]?"@media "+t[2]+"{"+n+"}":n}).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var i={},a=0;a11)]},M:function(e,t){return r(e.getMonth(),!0,t)},S:function(t){return e(t.getSeconds())},U:function(e){return e.getTime()/1e3},W:function(e,t,n){return n.getWeek(e)},Y:function(e){return e.getFullYear()},d:function(t){return e(t.getDate())},h:function(e){return e.getHours()%12?e.getHours()%12:12},i:function(t){return e(t.getMinutes())},j:function(e){return e.getDate()},l:function(e,t){return t.weekdays.longhand[e.getDay()]},m:function(t){return e(t.getMonth()+1)},n:function(e){return e.getMonth()+1},s:function(e){return e.getSeconds()},w:function(e){return e.getDay()},y:function(e){return String(e.getFullYear()).substring(2)}},c={weekdays:{shorthand:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],longhand:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},months:{shorthand:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],longhand:["January","February","March","April","May","June","July","August","September","October","November","December"]},daysInMonth:[31,28,31,30,31,30,31,31,30,31,30,31],firstDayOfWeek:0,ordinal:function(e){var t=e%100;if(t>3&&t<21)return"th";switch(t%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}},rangeSeparator:" to ",weekAbbreviation:"Wk",scrollTitle:"Scroll to increment",toggleTitle:"Click to toggle",amPM:["AM","PM"],yearAriaLabel:"Year"},d=function(e){var t=e.config,n=void 0===t?g:t,i=e.l10n,a=void 0===i?c:i;return function(e,t,i){var r=i||a;return void 0!==n.formatDate?n.formatDate(e,t,r):t.split("").map(function(t,i,a){return s[t]&&"\\"!==a[i-1]?s[t](e,r,n):"\\"!==t?t:""}).join("")}},u=function(e){var t=e.config,n=void 0===t?g:t,i=e.l10n,a=void 0===i?c:i;return function(e,t,i,r){if(0===e||e){var s,c=r||a,d=e;if(e instanceof Date)s=new Date(e.getTime());else if("string"!=typeof e&&void 0!==e.toFixed)s=new Date(e);else if("string"==typeof e){var u=t||(n||g).dateFormat,f=String(e).trim();if("today"===f)s=new Date,i=!0;else if(/Z$/.test(f)||/GMT$/.test(f))s=new Date(e);else if(n&&n.parseDate)s=n.parseDate(e,u);else{s=n&&n.noCalendar?new Date((new Date).setHours(0,0,0,0)):new Date((new Date).getFullYear(),0,1,0,0,0,0);for(var p,h=[],m=0,v=0,b="";mMath.min(t,n)&&e",noCalendar:!1,now:new Date,onChange:[],onClose:[],onDayCreate:[],onDestroy:[],onKeyDown:[],onMonthChange:[],onOpen:[],onParseConfig:[],onReady:[],onValueUpdate:[],onYearChange:[],onPreCalendarPosition:[],plugins:[],position:"auto",positionElement:void 0,prevArrow:"",shorthandCurrentMonth:!1,showMonths:1,static:!1,time_24hr:!1,weekNumbers:!1,wrap:!1};function v(e,t,n){if(!0===n)return e.classList.add(t);e.classList.remove(t)}function b(e,t,n){var i=window.document.createElement(e);return t=t||"",n=n||"",i.className=t,void 0!==n&&(i.textContent=n),i}function y(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function w(e,t){var n=b("div","numInputWrapper"),i=b("input","numInput "+e),a=b("span","arrowUp"),r=b("span","arrowDown");if(i.type="text",i.pattern="\\d*",void 0!==t)for(var o in t)i.setAttribute(o,t[o]);return n.appendChild(i),n.appendChild(a),n.appendChild(r),n}"function"!=typeof Object.assign&&(Object.assign=function(e){if(!e)throw TypeError("Cannot convert undefined or null to object");for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;io&&(u=a===s.hourElement?u-o-t(!s.amPM):r,p&&N(void 0,1,s.hourElement)),s.amPM&&f&&(1===l?u+c===23:Math.abs(u-c)>l)&&(s.amPM.textContent=s.l10n.amPM[t(s.amPM.textContent===s.l10n.amPM[0])]),a.value=e(u)}}(n);var i=s._input.value;M(),me(),s._input.value!==i&&s._debouncedChange()}}function M(){if(void 0!==s.hourElement&&void 0!==s.minuteElement){var e,n,i=(parseInt(s.hourElement.value.slice(-2),10)||0)%24,a=(parseInt(s.minuteElement.value,10)||0)%60,r=void 0!==s.secondElement?(parseInt(s.secondElement.value,10)||0)%60:0;void 0!==s.amPM&&(e=i,n=s.amPM.textContent,i=e%12+12*t(n===s.l10n.amPM[1]));var o=void 0!==s.config.minTime||s.config.minDate&&s.minDateHasTime&&s.latestSelectedDateObj&&0===f(s.latestSelectedDateObj,s.config.minDate,!0);if(void 0!==s.config.maxTime||s.config.maxDate&&s.maxDateHasTime&&s.latestSelectedDateObj&&0===f(s.latestSelectedDateObj,s.config.maxDate,!0)){var l=void 0!==s.config.maxTime?s.config.maxTime:s.config.maxDate;(i=Math.min(i,l.getHours()))===l.getHours()&&(a=Math.min(a,l.getMinutes())),a===l.getMinutes()&&(r=Math.min(r,l.getSeconds()))}if(o){var c=void 0!==s.config.minTime?s.config.minTime:s.config.minDate;(i=Math.max(i,c.getHours()))===c.getHours()&&(a=Math.max(a,c.getMinutes())),a===c.getMinutes()&&(r=Math.max(r,c.getSeconds()))}T(i,a,r)}}function _(e){var t=e||s.latestSelectedDateObj;t&&T(t.getHours(),t.getMinutes(),t.getSeconds())}function E(){var e=s.config.defaultHour,t=s.config.defaultMinute,n=s.config.defaultSeconds;if(void 0!==s.config.minDate){var i=s.config.minDate.getHours(),a=s.config.minDate.getMinutes();(e=Math.max(e,i))===i&&(t=Math.max(a,t)),e===i&&t===a&&(n=s.config.minDate.getSeconds())}if(void 0!==s.config.maxDate){var r=s.config.maxDate.getHours(),o=s.config.maxDate.getMinutes();(e=Math.min(e,r))===r&&(t=Math.min(o,t)),e===r&&t===o&&(n=s.config.maxDate.getSeconds())}T(e,t,n)}function T(n,i,a){void 0!==s.latestSelectedDateObj&&s.latestSelectedDateObj.setHours(n%24,i,a||0,0),s.hourElement&&s.minuteElement&&!s.isMobile&&(s.hourElement.value=e(s.config.time_24hr?n:(12+n)%12+12*t(n%12==0)),s.minuteElement.value=e(i),void 0!==s.amPM&&(s.amPM.textContent=s.l10n.amPM[t(n>=12)]),void 0!==s.secondElement&&(s.secondElement.value=e(a)))}function I(e){var t=parseInt(e.target.value)+(e.delta||0);(t/1e3>1||"Enter"===e.key&&!/[^\d]/.test(t.toString()))&&Z(t)}function F(e,t,n,i){return t instanceof Array?t.forEach(function(t){return F(e,t,n,i)}):e instanceof Array?e.forEach(function(e){return F(e,t,n,i)}):(e.addEventListener(t,n,i),void s._handlers.push({element:e,event:t,handler:n,options:i}))}function S(e){return function(t){1===t.which&&e(t)}}function O(){de("onChange")}function A(e){var t=void 0!==e?s.parseDate(e):s.latestSelectedDateObj||(s.config.minDate&&s.config.minDate>s.now?s.config.minDate:s.config.maxDate&&s.config.maxDate=0&&f(e,s.selectedDates[1])<=0}(t)&&!fe(t)&&r.classList.add("inRange"),s.weekNumbers&&1===s.config.showMonths&&"prevMonthDay"!==e&&n%7==1&&s.weekNumbers.insertAdjacentHTML("beforeend",""+s.config.getWeek(t)+""),de("onDayCreate",r),r}function P(e){e.focus(),"range"===s.config.mode&&Q(e)}function L(e){for(var t=e>0?0:s.config.showMonths-1,n=e>0?s.config.showMonths:-1,i=t;i!=n;i+=e)for(var a=s.daysContainer.children[i],r=e>0?0:a.children.length-1,o=e>0?a.children.length:-1,l=r;l!=o;l+=e){var c=a.children[l];if(-1===c.className.indexOf("hidden")&&K(c.dateObj))return c}}function Y(e,t){var n=G(document.activeElement||document.body),i=void 0!==e?e:n?document.activeElement:void 0!==s.selectedDateElem&&G(s.selectedDateElem)?s.selectedDateElem:void 0!==s.todayDateElem&&G(s.todayDateElem)?s.todayDateElem:L(t>0?1:-1);return void 0===i?s._input.focus():n?void function(e,t){for(var n=-1===e.className.indexOf("Month")?e.dateObj.getMonth():s.currentMonth,i=t>0?s.config.showMonths:-1,a=t>0?1:-1,r=n-s.currentMonth;r!=i;r+=a)for(var o=s.daysContainer.children[r],l=n-s.currentMonth===r?e.$i+t:t<0?o.children.length-1:0,c=o.children.length,d=l;d>=0&&d0?c:-1);d+=a){var u=o.children[d];if(-1===u.className.indexOf("hidden")&&K(u.dateObj)&&Math.abs(e.$i-d)>=Math.abs(t))return P(u)}s.changeMonth(a),Y(L(a),0)}(i,t):P(i)}function V(e,t){for(var n=(new Date(e,t,1).getDay()-s.l10n.firstDayOfWeek+7)%7,i=s.utils.getDaysInMonth((t-1+12)%12),a=s.utils.getDaysInMonth(t),r=window.document.createDocumentFragment(),o=s.config.showMonths>1,l=o?"prevMonthDay hidden":"prevMonthDay",c=o?"nextMonthDay hidden":"nextMonthDay",d=i+1-n,u=0;d<=i;d++,u++)r.appendChild(R(l,new Date(e,t-1,d),d,u));for(d=1;d<=a;d++,u++)r.appendChild(R("",new Date(e,t,d),d,u));for(var f=a+1;f<=42-n&&(1===s.config.showMonths||u%7!=0);f++,u++)r.appendChild(R(c,new Date(e,t+1,f%a),f,u));var p=b("div","dayContainer");return p.appendChild(r),p}function H(){if(void 0!==s.daysContainer){y(s.daysContainer),s.weekNumbers&&y(s.weekNumbers);for(var e=document.createDocumentFragment(),t=0;t0&&e\n "+t.join("")+"\n \n "}function q(e,t){void 0===t&&(t=!0);var n=t?e:e-s.currentMonth;n<0&&!0===s._hidePrevMonthArrow||n>0&&!0===s._hideNextMonthArrow||(s.currentMonth+=n,(s.currentMonth<0||s.currentMonth>11)&&(s.currentYear+=s.currentMonth>11?1:-1,s.currentMonth=(s.currentMonth+12)%12,de("onYearChange")),H(),de("onMonthChange"),pe())}function z(e){return!(!s.config.appendTo||!s.config.appendTo.contains(e))||s.calendarContainer.contains(e)}function J(e){if(s.isOpen&&!s.config.inline){var t=z(e.target),n=e.target===s.input||e.target===s.altInput||s.element.contains(e.target)||e.path&&e.path.indexOf&&(~e.path.indexOf(s.input)||~e.path.indexOf(s.altInput)),i="blur"===e.type?n&&e.relatedTarget&&!z(e.relatedTarget):!n&&!t,a=!s.config.ignoredFocusElements.some(function(t){return t.contains(e.target)});i&&a&&(s.close(),"range"===s.config.mode&&1===s.selectedDates.length&&(s.clear(!1),s.redraw()))}}function Z(e){if(!(!e||s.config.minDate&&es.config.maxDate.getFullYear())){var t=e,n=s.currentYear!==t;s.currentYear=t||s.currentYear,s.config.maxDate&&s.currentYear===s.config.maxDate.getFullYear()?s.currentMonth=Math.min(s.config.maxDate.getMonth(),s.currentMonth):s.config.minDate&&s.currentYear===s.config.minDate.getFullYear()&&(s.currentMonth=Math.max(s.config.minDate.getMonth(),s.currentMonth)),n&&(s.redraw(),de("onYearChange"))}}function K(e,t){void 0===t&&(t=!0);var n=s.parseDate(e,void 0,t);if(s.config.minDate&&n&&f(n,s.config.minDate,void 0!==t?t:!s.minDateHasTime)<0||s.config.maxDate&&n&&f(n,s.config.maxDate,void 0!==t?t:!s.maxDateHasTime)>0)return!1;if(0===s.config.enable.length&&0===s.config.disable.length)return!0;if(void 0===n)return!1;for(var i,a=s.config.enable.length>0,r=a?s.config.enable:s.config.disable,o=0;o=i.from.getTime()&&n.getTime()<=i.to.getTime())return a}return!a}function G(e){return void 0!==s.daysContainer&&(-1===e.className.indexOf("hidden")&&s.daysContainer.contains(e))}function X(e){var t=e.target===s._input,n=s.config.allowInput,i=s.isOpen&&(!n||!t),a=s.config.inline&&t&&!n;if(13===e.keyCode&&t){if(n)return s.setDate(s._input.value,!0,e.target===s.altInput?s.config.altFormat:s.config.dateFormat),e.target.blur();s.open()}else if(z(e.target)||i||a){var r=!!s.timeContainer&&s.timeContainer.contains(e.target);switch(e.keyCode){case 13:r?C():oe(e);break;case 27:e.preventDefault(),re();break;case 8:case 46:t&&!s.config.allowInput&&(e.preventDefault(),s.clear());break;case 37:case 39:if(r)s.hourElement&&s.hourElement.focus();else if(e.preventDefault(),void 0!==s.daysContainer&&(!1===n||G(document.activeElement))){var o=39===e.keyCode?1:-1;e.ctrlKey?(q(o),Y(L(1),0)):Y(void 0,o)}break;case 38:case 40:e.preventDefault();var l=40===e.keyCode?1:-1;s.daysContainer&&void 0!==e.target.$i?e.ctrlKey?(Z(s.currentYear-l),Y(L(1),0)):r||Y(void 0,7*l):s.config.enableTime&&(!r&&s.hourElement&&s.hourElement.focus(),C(e),s._debouncedChange());break;case 9:if(!r){s.element.focus();break}var c=[s.hourElement,s.minuteElement,s.secondElement,s.amPM].filter(function(e){return e}),d=c.indexOf(e.target);if(-1!==d){var u=c[d+(e.shiftKey?-1:1)];void 0!==u?(e.preventDefault(),u.focus()):s.element.focus()}}}if(void 0!==s.amPM&&e.target===s.amPM)switch(e.key){case s.l10n.amPM[0].charAt(0):case s.l10n.amPM[0].charAt(0).toLowerCase():s.amPM.textContent=s.l10n.amPM[0],M(),me();break;case s.l10n.amPM[1].charAt(0):case s.l10n.amPM[1].charAt(0).toLowerCase():s.amPM.textContent=s.l10n.amPM[1],M(),me()}de("onKeyDown",e)}function Q(e){if(1===s.selectedDates.length&&(!e||e.classList.contains("flatpickr-day")&&!e.classList.contains("disabled"))){for(var t=e?e.dateObj.getTime():s.days.firstElementChild.dateObj.getTime(),n=s.parseDate(s.selectedDates[0],void 0,!0).getTime(),i=Math.min(t,s.selectedDates[0].getTime()),a=Math.max(t,s.selectedDates[0].getTime()),r=s.daysContainer.lastChild.lastChild.dateObj.getTime(),o=!1,l=0,c=0,d=i;di&&dl)?l=d:d>n&&(!c||d0&&d0&&d>c;return h?(r.classList.add("notAllowed"),["inRange","startRange","endRange"].forEach(function(e){r.classList.remove(e)}),"continue"):o&&!h?"continue":(["startRange","inRange","endRange","notAllowed"].forEach(function(e){r.classList.remove(e)}),void(void 0!==e&&(e.classList.add(t0&&m&&m.lastChild.dateObj.getTime()>=d||(nt&&d===n&&r.classList.add("endRange"),d>=l&&(0===c||d<=c)&&p(d,n,t)&&r.classList.add("inRange")))))},v=0,b=f.children.length;v0||n.getMinutes()>0||n.getSeconds()>0),s.selectedDates&&(s.selectedDates=s.selectedDates.filter(function(e){return K(e)}),s.selectedDates.length||"min"!==e||_(n),me()),s.daysContainer&&(ae(),void 0!==n?s.currentYearElement[e]=n.getFullYear().toString():s.currentYearElement.removeAttribute(e),s.currentYearElement.disabled=!!i&&void 0!==n&&i.getFullYear()===n.getFullYear())}}function ne(){"object"!=typeof s.config.locale&&void 0===D.l10ns[s.config.locale]&&s.config.errorHandler(new Error("flatpickr: invalid locale "+s.config.locale)),s.l10n=Object.assign({},D.l10ns.default,"object"==typeof s.config.locale?s.config.locale:"default"!==s.config.locale?D.l10ns[s.config.locale]:void 0),l.K="("+s.l10n.amPM[0]+"|"+s.l10n.amPM[1]+"|"+s.l10n.amPM[0].toLowerCase()+"|"+s.l10n.amPM[1].toLowerCase()+")",s.formatDate=d(s),s.parseDate=u({config:s.config,l10n:s.l10n})}function ie(e){if(void 0!==s.calendarContainer){de("onPreCalendarPosition");var t=e||s._positionElement,n=Array.prototype.reduce.call(s.calendarContainer.children,function(e,t){return e+t.offsetHeight},0),i=s.calendarContainer.offsetWidth,a=s.config.position.split(" "),r=a[0],o=a.length>1?a[1]:null,l=t.getBoundingClientRect(),c=window.innerHeight-l.bottom,d="above"===r||"below"!==r&&cn,u=window.pageYOffset+l.top+(d?-n-2:t.offsetHeight+2);if(v(s.calendarContainer,"arrowTop",!d),v(s.calendarContainer,"arrowBottom",d),!s.config.inline){var f=window.pageXOffset+l.left-(null!=o&&"center"===o?(i-l.width)/2:0),p=window.document.body.offsetWidth-l.right,h=f+i>window.document.body.offsetWidth;v(s.calendarContainer,"rightMost",h),s.config.static||(s.calendarContainer.style.top=u+"px",h?(s.calendarContainer.style.left="auto",s.calendarContainer.style.right=p+"px"):(s.calendarContainer.style.left=f+"px",s.calendarContainer.style.right="auto"))}}}function ae(){s.config.noCalendar||s.isMobile||(pe(),H())}function re(){s._input.focus(),-1!==window.navigator.userAgent.indexOf("MSIE")||void 0!==navigator.msMaxTouchPoints?setTimeout(s.close,0):s.close()}function oe(e){e.preventDefault(),e.stopPropagation();var t=function e(t,n){return n(t)?t:t.parentNode?e(t.parentNode,n):void 0}(e.target,function(e){return e.classList&&e.classList.contains("flatpickr-day")&&!e.classList.contains("disabled")&&!e.classList.contains("notAllowed")});if(void 0!==t){var n=t,i=s.latestSelectedDateObj=new Date(n.dateObj.getTime()),a=(i.getMonth()s.currentMonth+s.config.showMonths-1)&&"range"!==s.config.mode;if(s.selectedDateElem=n,"single"===s.config.mode)s.selectedDates=[i];else if("multiple"===s.config.mode){var r=fe(i);r?s.selectedDates.splice(parseInt(r),1):s.selectedDates.push(i)}else"range"===s.config.mode&&(2===s.selectedDates.length&&s.clear(!1),s.selectedDates.push(i),0!==f(i,s.selectedDates[0],!0)&&s.selectedDates.sort(function(e,t){return e.getTime()-t.getTime()}));if(M(),a){var o=s.currentYear!==i.getFullYear();s.currentYear=i.getFullYear(),s.currentMonth=i.getMonth(),o&&de("onYearChange"),de("onMonthChange")}if(pe(),H(),me(),s.config.enableTime&&setTimeout(function(){return s.showTimeInput=!0},50),a||"range"===s.config.mode||1!==s.config.showMonths?s.selectedDateElem&&s.selectedDateElem.focus():P(n),void 0!==s.hourElement&&setTimeout(function(){return void 0!==s.hourElement&&s.hourElement.select()},451),s.config.closeOnSelect){var l="single"===s.config.mode&&!s.config.enableTime,c="range"===s.config.mode&&2===s.selectedDates.length&&!s.config.enableTime;(l||c)&&re()}O()}}s.parseDate=u({config:s.config,l10n:s.l10n}),s._handlers=[],s._bind=F,s._setHoursFromDate=_,s._positionCalendar=ie,s.changeMonth=q,s.changeYear=Z,s.clear=function(e){void 0===e&&(e=!0);s.input.value="",void 0!==s.altInput&&(s.altInput.value="");void 0!==s.mobileInput&&(s.mobileInput.value="");s.selectedDates=[],s.latestSelectedDateObj=void 0,s.showTimeInput=!1,!0===s.config.enableTime&&E();s.redraw(),e&&de("onChange")},s.close=function(){s.isOpen=!1,s.isMobile||(s.calendarContainer.classList.remove("open"),s._input.classList.remove("active"));de("onClose")},s._createElement=b,s.destroy=function(){void 0!==s.config&&de("onDestroy");for(var e=s._handlers.length;e--;){var t=s._handlers[e];t.element.removeEventListener(t.event,t.handler,t.options)}if(s._handlers=[],s.mobileInput)s.mobileInput.parentNode&&s.mobileInput.parentNode.removeChild(s.mobileInput),s.mobileInput=void 0;else if(s.calendarContainer&&s.calendarContainer.parentNode)if(s.config.static&&s.calendarContainer.parentNode){var n=s.calendarContainer.parentNode;if(n.lastChild&&n.removeChild(n.lastChild),n.parentNode){for(;n.firstChild;)n.parentNode.insertBefore(n.firstChild,n);n.parentNode.removeChild(n)}}else s.calendarContainer.parentNode.removeChild(s.calendarContainer);s.altInput&&(s.input.type="text",s.altInput.parentNode&&s.altInput.parentNode.removeChild(s.altInput),delete s.altInput);s.input&&(s.input.type=s.input._type,s.input.classList.remove("flatpickr-input"),s.input.removeAttribute("readonly"),s.input.value="");["_showTimeInput","latestSelectedDateObj","_hideNextMonthArrow","_hidePrevMonthArrow","__hideNextMonthArrow","__hidePrevMonthArrow","isMobile","isOpen","selectedDateElem","minDateHasTime","maxDateHasTime","days","daysContainer","_input","_positionElement","innerContainer","rContainer","monthNav","todayDateElem","calendarContainer","weekdayContainer","prevMonthNav","nextMonthNav","currentMonthElement","currentYearElement","navigationCurrentMonth","selectedDateElem","config"].forEach(function(e){try{delete s[e]}catch(e){}})},s.isEnabled=K,s.jumpToDate=A,s.open=function(e,t){void 0===t&&(t=s._positionElement);if(!0===s.isMobile)return e&&(e.preventDefault(),e.target&&e.target.blur()),void 0!==s.mobileInput&&(s.mobileInput.focus(),s.mobileInput.click()),void de("onOpen");if(s._input.disabled||s.config.inline)return;var n=s.isOpen;s.isOpen=!0,n||(s.calendarContainer.classList.add("open"),s._input.classList.add("active"),de("onOpen"),ie(t));!0===s.config.enableTime&&!0===s.config.noCalendar&&(0===s.selectedDates.length&&(s.setDate(void 0!==s.config.minDate?new Date(s.config.minDate.getTime()):new Date,!1),E(),me()),!1!==s.config.allowInput||void 0!==e&&s.timeContainer.contains(e.relatedTarget)||setTimeout(function(){return s.hourElement.select()},50))},s.redraw=ae,s.set=function(e,t){null!==e&&"object"==typeof e?Object.assign(s.config,e):(s.config[e]=t,void 0!==le[e]?le[e].forEach(function(e){return e()}):m.indexOf(e)>-1&&(s.config[e]=i(t)));s.redraw(),A(),me(!1)},s.setDate=function(e,t,n){void 0===t&&(t=!1);void 0===n&&(n=s.config.dateFormat);if(0!==e&&!e||e instanceof Array&&0===e.length)return s.clear(t);se(e,n),s.showTimeInput=s.selectedDates.length>0,s.latestSelectedDateObj=s.selectedDates[0],s.redraw(),A(),_(),me(t),t&&de("onChange")},s.toggle=function(e){if(!0===s.isOpen)return s.close();s.open(e)};var le={locale:[ne,B],showMonths:[U,k,W]};function se(e,t){var n=[];if(e instanceof Array)n=e.map(function(e){return s.parseDate(e,t)});else if(e instanceof Date||"number"==typeof e)n=[s.parseDate(e,t)];else if("string"==typeof e)switch(s.config.mode){case"single":case"time":n=[s.parseDate(e,t)];break;case"multiple":n=e.split(s.config.conjunction).map(function(e){return s.parseDate(e,t)});break;case"range":n=e.split(s.l10n.rangeSeparator).map(function(e){return s.parseDate(e,t)})}else s.config.errorHandler(new Error("Invalid date supplied: "+JSON.stringify(e)));s.selectedDates=n.filter(function(e){return e instanceof Date&&K(e,!1)}),"range"===s.config.mode&&s.selectedDates.sort(function(e,t){return e.getTime()-t.getTime()})}function ce(e){return e.slice().map(function(e){return"string"==typeof e||"number"==typeof e||e instanceof Date?s.parseDate(e,void 0,!0):e&&"object"==typeof e&&e.from&&e.to?{from:s.parseDate(e.from,void 0),to:s.parseDate(e.to,void 0)}:e}).filter(function(e){return e})}function de(e,t){if(void 0!==s.config){var n=s.config[e];if(void 0!==n&&n.length>0)for(var i=0;n[i]&&is.config.maxDate.getMonth():s.currentYear>s.config.maxDate.getFullYear()))}function he(e){return s.selectedDates.map(function(t){return s.formatDate(t,e)}).filter(function(e,t,n){return"range"!==s.config.mode||s.config.enableTime||n.indexOf(e)===t}).join("range"!==s.config.mode?s.config.conjunction:s.l10n.rangeSeparator)}function me(e){if(void 0===e&&(e=!0),0===s.selectedDates.length)return s.clear(e);void 0!==s.mobileInput&&s.mobileFormatStr&&(s.mobileInput.value=void 0!==s.latestSelectedDateObj?s.formatDate(s.latestSelectedDateObj,s.mobileFormatStr):""),s.input.value=he(s.config.dateFormat),void 0!==s.altInput&&(s.altInput.value=he(s.config.altFormat)),!1!==e&&de("onValueUpdate")}function ge(e){e.preventDefault();var t=s.prevMonthNav.contains(e.target),n=s.nextMonthNav.contains(e.target);t||n?q(t?-1:1):s.yearElements.indexOf(e.target)>=0?e.target.select():e.target.classList.contains("arrowUp")?s.changeYear(s.currentYear+1):e.target.classList.contains("arrowDown")&&s.changeYear(s.currentYear-1)}return function(){s.element=s.input=a,s.isOpen=!1,function(){var e=["wrap","weekNumbers","allowInput","clickOpens","time_24hr","enableTime","noCalendar","altInput","shorthandCurrentMonth","inline","static","enableSeconds","disableMobile"],t=Object.assign({},o,JSON.parse(JSON.stringify(a.dataset||{}))),n={};s.config.parseDate=t.parseDate,s.config.formatDate=t.formatDate,Object.defineProperty(s.config,"enable",{get:function(){return s.config._enable},set:function(e){s.config._enable=ce(e)}}),Object.defineProperty(s.config,"disable",{get:function(){return s.config._disable},set:function(e){s.config._disable=ce(e)}});var r="time"===t.mode;t.dateFormat||!t.enableTime&&!r||(n.dateFormat=t.noCalendar||r?"H:i"+(t.enableSeconds?":S":""):D.defaultConfig.dateFormat+" H:i"+(t.enableSeconds?":S":"")),t.altInput&&(t.enableTime||r)&&!t.altFormat&&(n.altFormat=t.noCalendar||r?"h:i"+(t.enableSeconds?":S K":" K"):D.defaultConfig.altFormat+" h:i"+(t.enableSeconds?":S":"")+" K"),Object.defineProperty(s.config,"minDate",{get:function(){return s.config._minDate},set:te("min")}),Object.defineProperty(s.config,"maxDate",{get:function(){return s.config._maxDate},set:te("max")});var l=function(e){return function(t){s.config["min"===e?"_minTime":"_maxTime"]=s.parseDate(t,"H:i")}};Object.defineProperty(s.config,"minTime",{get:function(){return s.config._minTime},set:l("min")}),Object.defineProperty(s.config,"maxTime",{get:function(){return s.config._maxTime},set:l("max")}),"time"===t.mode&&(s.config.noCalendar=!0,s.config.enableTime=!0),Object.assign(s.config,n,t);for(var c=0;c-1?s.config[f]=i(u[f]).map(g).concat(s.config[f]):void 0===t[f]&&(s.config[f]=u[f])}de("onParseConfig")}(),ne(),s.input=s.config.wrap?a.querySelector("[data-input]"):a,s.input?(s.input._type=s.input.type,s.input.type="text",s.input.classList.add("flatpickr-input"),s._input=s.input,s.config.altInput&&(s.altInput=b(s.input.nodeName,s.input.className+" "+s.config.altInputClass),s._input=s.altInput,s.altInput.placeholder=s.input.placeholder,s.altInput.disabled=s.input.disabled,s.altInput.required=s.input.required,s.altInput.tabIndex=s.input.tabIndex,s.altInput.type="text",s.input.setAttribute("type","hidden"),!s.config.static&&s.input.parentNode&&s.input.parentNode.insertBefore(s.altInput,s.input.nextSibling)),s.config.allowInput||s._input.setAttribute("readonly","readonly"),s._positionElement=s.config.positionElement||s._input):s.config.errorHandler(new Error("Invalid input element specified")),function(){s.selectedDates=[],s.now=s.parseDate(s.config.now)||new Date;var e=s.config.defaultDate||("INPUT"!==s.input.nodeName&&"TEXTAREA"!==s.input.nodeName||!s.input.placeholder||s.input.value!==s.input.placeholder?s.input.value:null);e&&se(e,s.config.dateFormat);var t=s.selectedDates.length>0?s.selectedDates[0]:s.config.minDate&&s.config.minDate.getTime()>s.now.getTime()?s.config.minDate:s.config.maxDate&&s.config.maxDate.getTime()0&&(s.latestSelectedDateObj=s.selectedDates[0]),void 0!==s.config.minTime&&(s.config.minTime=s.parseDate(s.config.minTime,"H:i")),void 0!==s.config.maxTime&&(s.config.maxTime=s.parseDate(s.config.maxTime,"H:i")),s.minDateHasTime=!!s.config.minDate&&(s.config.minDate.getHours()>0||s.config.minDate.getMinutes()>0||s.config.minDate.getSeconds()>0),s.maxDateHasTime=!!s.config.maxDate&&(s.config.maxDate.getHours()>0||s.config.maxDate.getMinutes()>0||s.config.maxDate.getSeconds()>0),Object.defineProperty(s,"showTimeInput",{get:function(){return s._showTimeInput},set:function(e){s._showTimeInput=e,s.calendarContainer&&v(s.calendarContainer,"showTimeInput",e),s.isOpen&&ie()}})}(),s.utils={getDaysInMonth:function(e,t){return void 0===e&&(e=s.currentMonth),void 0===t&&(t=s.currentYear),1===e&&(t%4==0&&t%100!=0||t%400==0)?29:s.l10n.daysInMonth[e]}},s.isMobile||function(){var n=window.document.createDocumentFragment();if(s.calendarContainer=b("div","flatpickr-calendar"),s.calendarContainer.tabIndex=-1,!s.config.noCalendar){if(n.appendChild((s.monthNav=b("div","flatpickr-months"),s.yearElements=[],s.monthElements=[],s.prevMonthNav=b("span","flatpickr-prev-month"),s.prevMonthNav.innerHTML=s.config.prevArrow,s.nextMonthNav=b("span","flatpickr-next-month"),s.nextMonthNav.innerHTML=s.config.nextArrow,U(),Object.defineProperty(s,"_hidePrevMonthArrow",{get:function(){return s.__hidePrevMonthArrow},set:function(e){s.__hidePrevMonthArrow!==e&&(v(s.prevMonthNav,"disabled",e),s.__hidePrevMonthArrow=e)}}),Object.defineProperty(s,"_hideNextMonthArrow",{get:function(){return s.__hideNextMonthArrow},set:function(e){s.__hideNextMonthArrow!==e&&(v(s.nextMonthNav,"disabled",e),s.__hideNextMonthArrow=e)}}),s.currentYearElement=s.yearElements[0],pe(),s.monthNav)),s.innerContainer=b("div","flatpickr-innerContainer"),s.config.weekNumbers){var i=function(){s.calendarContainer.classList.add("hasWeeks");var e=b("div","flatpickr-weekwrapper");e.appendChild(b("span","flatpickr-weekday",s.l10n.weekAbbreviation));var t=b("div","flatpickr-weeks");return e.appendChild(t),{weekWrapper:e,weekNumbers:t}}(),a=i.weekWrapper,r=i.weekNumbers;s.innerContainer.appendChild(a),s.weekNumbers=r,s.weekWrapper=a}s.rContainer=b("div","flatpickr-rContainer"),s.rContainer.appendChild(W()),s.daysContainer||(s.daysContainer=b("div","flatpickr-days"),s.daysContainer.tabIndex=-1),H(),s.rContainer.appendChild(s.daysContainer),s.innerContainer.appendChild(s.rContainer),n.appendChild(s.innerContainer)}s.config.enableTime&&n.appendChild(function(){s.calendarContainer.classList.add("hasTime"),s.config.noCalendar&&s.calendarContainer.classList.add("noCalendar"),s.timeContainer=b("div","flatpickr-time"),s.timeContainer.tabIndex=-1;var n=b("span","flatpickr-time-separator",":"),i=w("flatpickr-hour");s.hourElement=i.getElementsByTagName("input")[0];var a=w("flatpickr-minute");if(s.minuteElement=a.getElementsByTagName("input")[0],s.hourElement.tabIndex=s.minuteElement.tabIndex=-1,s.hourElement.value=e(s.latestSelectedDateObj?s.latestSelectedDateObj.getHours():s.config.time_24hr?s.config.defaultHour:function(e){switch(e%24){case 0:case 12:return 12;default:return e%12}}(s.config.defaultHour)),s.minuteElement.value=e(s.latestSelectedDateObj?s.latestSelectedDateObj.getMinutes():s.config.defaultMinute),s.hourElement.setAttribute("data-step",s.config.hourIncrement.toString()),s.minuteElement.setAttribute("data-step",s.config.minuteIncrement.toString()),s.hourElement.setAttribute("data-min",s.config.time_24hr?"0":"1"),s.hourElement.setAttribute("data-max",s.config.time_24hr?"23":"12"),s.minuteElement.setAttribute("data-min","0"),s.minuteElement.setAttribute("data-max","59"),s.timeContainer.appendChild(i),s.timeContainer.appendChild(n),s.timeContainer.appendChild(a),s.config.time_24hr&&s.timeContainer.classList.add("time24hr"),s.config.enableSeconds){s.timeContainer.classList.add("hasSeconds");var r=w("flatpickr-second");s.secondElement=r.getElementsByTagName("input")[0],s.secondElement.value=e(s.latestSelectedDateObj?s.latestSelectedDateObj.getSeconds():s.config.defaultSeconds),s.secondElement.setAttribute("data-step",s.minuteElement.getAttribute("data-step")),s.secondElement.setAttribute("data-min",s.minuteElement.getAttribute("data-min")),s.secondElement.setAttribute("data-max",s.minuteElement.getAttribute("data-max")),s.timeContainer.appendChild(b("span","flatpickr-time-separator",":")),s.timeContainer.appendChild(r)}return s.config.time_24hr||(s.amPM=b("span","flatpickr-am-pm",s.l10n.amPM[t((s.latestSelectedDateObj?s.hourElement.value:s.config.defaultHour)>11)]),s.amPM.title=s.l10n.toggleTitle,s.amPM.tabIndex=-1,s.timeContainer.appendChild(s.amPM)),s.timeContainer}()),v(s.calendarContainer,"rangeMode","range"===s.config.mode),v(s.calendarContainer,"animate",!0===s.config.animate),v(s.calendarContainer,"multiMonth",s.config.showMonths>1),s.calendarContainer.appendChild(n);var o=void 0!==s.config.appendTo&&void 0!==s.config.appendTo.nodeType;if((s.config.inline||s.config.static)&&(s.calendarContainer.classList.add(s.config.inline?"inline":"static"),s.config.inline&&(!o&&s.element.parentNode?s.element.parentNode.insertBefore(s.calendarContainer,s._input.nextSibling):void 0!==s.config.appendTo&&s.config.appendTo.appendChild(s.calendarContainer)),s.config.static)){var l=b("div","flatpickr-wrapper");s.element.parentNode&&s.element.parentNode.insertBefore(l,s.element),l.appendChild(s.element),s.altInput&&l.appendChild(s.altInput),l.appendChild(s.calendarContainer)}s.config.static||s.config.inline||(void 0!==s.config.appendTo?s.config.appendTo:window.document.body).appendChild(s.calendarContainer)}(),function(){if(s.config.wrap&&["open","close","toggle","clear"].forEach(function(e){Array.prototype.forEach.call(s.element.querySelectorAll("[data-"+e+"]"),function(t){return F(t,"click",s[e])})}),s.isMobile)!function(){var e=s.config.enableTime?s.config.noCalendar?"time":"datetime-local":"date";s.mobileInput=b("input",s.input.className+" flatpickr-mobile"),s.mobileInput.step=s.input.getAttribute("step")||"any",s.mobileInput.tabIndex=1,s.mobileInput.type=e,s.mobileInput.disabled=s.input.disabled,s.mobileInput.required=s.input.required,s.mobileInput.placeholder=s.input.placeholder,s.mobileFormatStr="datetime-local"===e?"Y-m-d\\TH:i:S":"date"===e?"Y-m-d":"H:i:S",s.selectedDates.length>0&&(s.mobileInput.defaultValue=s.mobileInput.value=s.formatDate(s.selectedDates[0],s.mobileFormatStr)),s.config.minDate&&(s.mobileInput.min=s.formatDate(s.config.minDate,"Y-m-d")),s.config.maxDate&&(s.mobileInput.max=s.formatDate(s.config.maxDate,"Y-m-d")),s.input.type="hidden",void 0!==s.altInput&&(s.altInput.type="hidden");try{s.input.parentNode&&s.input.parentNode.insertBefore(s.mobileInput,s.input.nextSibling)}catch(e){}F(s.mobileInput,"change",function(e){s.setDate(e.target.value,!1,s.mobileFormatStr),de("onChange"),de("onClose")})}();else{var e=n(ee,50);s._debouncedChange=n(O,x),s.daysContainer&&!/iPhone|iPad|iPod/i.test(navigator.userAgent)&&F(s.daysContainer,"mouseover",function(e){"range"===s.config.mode&&Q(e.target)}),F(window.document.body,"keydown",X),s.config.static||F(s._input,"keydown",X),s.config.inline||s.config.static||F(window,"resize",e),void 0!==window.ontouchstart?F(window.document,"click",J):F(window.document,"mousedown",S(J)),F(window.document,"focus",J,{capture:!0}),!0===s.config.clickOpens&&(F(s._input,"focus",s.open),F(s._input,"mousedown",S(s.open))),void 0!==s.daysContainer&&(F(s.monthNav,"mousedown",S(ge)),F(s.monthNav,["keyup","increment"],I),F(s.daysContainer,"mousedown",S(oe))),void 0!==s.timeContainer&&void 0!==s.minuteElement&&void 0!==s.hourElement&&(F(s.timeContainer,["increment"],C),F(s.timeContainer,"blur",C,{capture:!0}),F(s.timeContainer,"mousedown",S(j)),F([s.hourElement,s.minuteElement],["focus","click"],function(e){return e.target.select()}),void 0!==s.secondElement&&F(s.secondElement,"focus",function(){return s.secondElement&&s.secondElement.select()}),void 0!==s.amPM&&F(s.amPM,"mousedown",S(function(e){C(e),O()})))}}(),(s.selectedDates.length||s.config.noCalendar)&&(s.config.enableTime&&_(s.config.noCalendar?s.latestSelectedDateObj||s.config.minDate:void 0),me(!1)),k(),s.showTimeInput=s.selectedDates.length>0||s.config.noCalendar;var r=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);!s.isMobile&&r&&ie(),de("onReady")}(),s}function C(e,t){for(var n=Array.prototype.slice.call(e),i=[],a=0;a=0&&d.splice(t,1)}function g(e){var t=document.createElement("style");return e.attrs.type="text/css",v(t,e.attrs),h(e,t),t}function v(e,t){Object.keys(t).forEach(function(n){e.setAttribute(n,t[n])})}function b(e,t){var n,i,a,r;if(t.transform&&e.css){if(!(r=t.transform(e.css)))return function(){};e.css=r}if(t.singleton){var o=c++;n=s||(s=g(t)),i=x.bind(null,n,o,!1),a=x.bind(null,n,o,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(e){var t=document.createElement("link");return e.attrs.type="text/css",e.attrs.rel="stylesheet",v(t,e.attrs),h(e,t),t}(t),i=function(e,t,n){var i=n.css,a=n.sourceMap,r=void 0===t.convertToAbsoluteUrls&&a;(t.convertToAbsoluteUrls||r)&&(i=u(i));a&&(i+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(a))))+" */");var o=new Blob([i],{type:"text/css"}),l=e.href;e.href=URL.createObjectURL(o),l&&URL.revokeObjectURL(l)}.bind(null,n,t),a=function(){m(n),n.href&&URL.revokeObjectURL(n.href)}):(n=g(t),i=function(e,t){var n=t.css,i=t.media;i&&e.setAttribute("media",i);if(e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}.bind(null,n),a=function(){m(n)});return i(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;i(e=t)}else a()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||(t.singleton=o()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var n=p(e,t);return f(n,t),function(e){for(var i=[],a=0;ae||heightn.parts.length&&(i.parts.length=n.parts.length)}else{var o=[];for(a=0;a Date: Fri, 18 Jan 2019 18:49:51 +0530 Subject: [PATCH 02/12] attribute creation and deletion now syncing with columns of product_flat, label is now also creating when attribute type is select or multiselect --- .../src/Http/Controllers/AttributeController.php | 6 +++++- packages/Webkul/Product/src/Listeners/ProductsFlat.php | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php b/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php index 8af40c268..f4e94954e 100755 --- a/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php +++ b/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php @@ -75,7 +75,11 @@ class AttributeController extends Controller 'type' => 'required' ]); - $attribute = $this->attribute->create(request()->all()); + $data = request()->all(); + + $data['is_user_defined'] = 1; + + $attribute = $this->attribute->create($data); Event::fire('after.attribute.created', $attribute); diff --git a/packages/Webkul/Product/src/Listeners/ProductsFlat.php b/packages/Webkul/Product/src/Listeners/ProductsFlat.php index c80a91fbe..8f6c53370 100644 --- a/packages/Webkul/Product/src/Listeners/ProductsFlat.php +++ b/packages/Webkul/Product/src/Listeners/ProductsFlat.php @@ -49,8 +49,12 @@ class ProductsFlat if (Schema::hasTable('product_flat')) { if (!Schema::hasColumn('product_flat', strtolower($attribute->code))) { - Schema::table('product_flat', function (Blueprint $table) use($columnType, $attributeCode) { + Schema::table('product_flat', function (Blueprint $table) use($columnType, $attributeCode, $attributeType) { $table->{$columnType}(strtolower($attributeCode))->nullable(); + + if($attributeType == 'select' || $attributeType == 'multiselect') { + $table->string(strtolower($attributeCode).'_label')->nullable(); + } }); return true; @@ -76,6 +80,10 @@ class ProductsFlat if (Schema::hasColumn('product_flat', strtolower($attribute->code))) { Schema::table('product_flat', function (Blueprint $table) use($attribute){ $table->dropColumn(strtolower($attribute->code)); + + if ($attribute->type == 'select' || $attribute->type == 'multiselect') { + $table->dropColumn(strtolower($attribute->code).'_label'); + } }); return true; From 66c74af6ca890f6160014542b442ec80fbec5113 Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Fri, 18 Jan 2019 18:56:46 +0530 Subject: [PATCH 03/12] attribute update event for product flat is suppressed for now as code and type never gets changed when updating the attribute --- .../Attribute/src/Http/Controllers/AttributeController.php | 2 +- packages/Webkul/Product/src/Listeners/ProductsFlat.php | 2 +- packages/Webkul/Product/src/Providers/EventServiceProvider.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php b/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php index f4e94954e..978fe956f 100755 --- a/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php +++ b/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php @@ -118,7 +118,7 @@ class AttributeController extends Controller $attribute = $this->attribute->update(request()->all(), $id); - Event::fire('after.attribute.updated', $attribute); + // Event::fire('after.attribute.updated', $attribute); session()->flash('success', 'Attribute updated successfully.'); diff --git a/packages/Webkul/Product/src/Listeners/ProductsFlat.php b/packages/Webkul/Product/src/Listeners/ProductsFlat.php index 8f6c53370..d3ee2ed1f 100644 --- a/packages/Webkul/Product/src/Listeners/ProductsFlat.php +++ b/packages/Webkul/Product/src/Listeners/ProductsFlat.php @@ -71,7 +71,7 @@ class ProductsFlat */ public function afterAttributeUpdated($attribute) { - dd($attribute); + return true; } public function afterAttributeDeleted($attribute) diff --git a/packages/Webkul/Product/src/Providers/EventServiceProvider.php b/packages/Webkul/Product/src/Providers/EventServiceProvider.php index 832e7476d..ae1527f46 100644 --- a/packages/Webkul/Product/src/Providers/EventServiceProvider.php +++ b/packages/Webkul/Product/src/Providers/EventServiceProvider.php @@ -14,7 +14,7 @@ class EventServiceProvider extends ServiceProvider */ public function boot() { - Event::listen('after.attribute.updated', 'Webkul\Product\Listeners\ProductsFlat@afterAttributeUpdated'); + // Event::listen('after.attribute.updated', 'Webkul\Product\Listeners\ProductsFlat@afterAttributeUpdated'); Event::listen('after.attribute.created', 'Webkul\Product\Listeners\ProductsFlat@afterAttributeCreated'); From 9eeaee1c66a30389f0a606d60dd5f721cd7e44f1 Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Sat, 19 Jan 2019 15:35:12 +0530 Subject: [PATCH 04/12] migration changes in the product flat table --- packages/Webkul/Admin/src/Http/routes.php | 2 +- .../Webkul/Admin/src/Listeners/Product.php | 18 ++++++-- ...dd_new_from_to_columns_in_product_flat.php | 38 ++++++++++++++++ .../Http/Controllers/ProductController.php | 45 +++++++++++++++---- .../Webkul/Product/src/Models/ProductFlat.php | 20 +++++++++ .../ProductAttributeValueRepository.php | 6 +++ .../Repositories/ProductFlatRepository.php | 43 ++++++++++++++++++ 7 files changed, 159 insertions(+), 13 deletions(-) create mode 100644 packages/Webkul/Product/src/Database/Migrations/2019_01_19_144504_add_new_from_to_columns_in_product_flat.php create mode 100644 packages/Webkul/Product/src/Models/ProductFlat.php create mode 100644 packages/Webkul/Product/src/Repositories/ProductFlatRepository.php diff --git a/packages/Webkul/Admin/src/Http/routes.php b/packages/Webkul/Admin/src/Http/routes.php index ed009680b..da13e437d 100755 --- a/packages/Webkul/Admin/src/Http/routes.php +++ b/packages/Webkul/Admin/src/Http/routes.php @@ -35,7 +35,7 @@ Route::group(['middleware' => ['web']], function () { // Admin Routes Route::group(['middleware' => ['admin']], function () { - Route::get('/testev', 'Webkul\Product\Http\Controllers\ProductController@testEvent'); + Route::get('testev', 'Webkul\Product\Http\Controllers\ProductController@testProductFlat'); Route::get('/logout', 'Webkul\User\Http\Controllers\SessionController@destroy')->defaults('_config', [ 'redirect' => 'admin.session.create' diff --git a/packages/Webkul/Admin/src/Listeners/Product.php b/packages/Webkul/Admin/src/Listeners/Product.php index 19f4d0d63..6fad7284f 100755 --- a/packages/Webkul/Admin/src/Listeners/Product.php +++ b/packages/Webkul/Admin/src/Listeners/Product.php @@ -4,6 +4,7 @@ namespace Webkul\Admin\Listeners; use Webkul\Product\Repositories\ProductRepository; use Webkul\Product\Repositories\ProductGridRepository; +use Webkul\Product\Repositories\ProductFlatRepository; use Webkul\Product\Helpers\Price; /** @@ -23,19 +24,28 @@ class Product { * * @var array */ - Protected $price; + protected $price; + + /** + * Product Flat Object + * + * Repository Object + */ + protected $productFlat; /** * Product Grid Repository Object */ protected $productGrid; - public function __construct(ProductRepository $product, ProductGridRepository $productGrid, Price $price) + public function __construct(ProductRepository $product, ProductGridRepository $productGrid, ProductFlatRepository $productFlat, Price $price) { $this->product = $product; $this->productGrid = $productGrid; + $this->productFlat = $productFlat; + $this->price = $price; } @@ -91,7 +101,7 @@ class Product { 'name' => $variant->name, 'quantity' => 0, 'status' => $variant->status, - 'price' => $variant->price, + 'price' => $variant->price ]; $this->productGrid->create($variantObj); @@ -268,4 +278,6 @@ class Product { public function findRepeated() { //find if there is duplicacy in the products grid here } + + public function syncFlat() {} } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Database/Migrations/2019_01_19_144504_add_new_from_to_columns_in_product_flat.php b/packages/Webkul/Product/src/Database/Migrations/2019_01_19_144504_add_new_from_to_columns_in_product_flat.php new file mode 100644 index 000000000..e187229ae --- /dev/null +++ b/packages/Webkul/Product/src/Database/Migrations/2019_01_19_144504_add_new_from_to_columns_in_product_flat.php @@ -0,0 +1,38 @@ +date('new_to')->after('new'); + $table->date('new_from')->after('new'); + }); + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + if (Schema::hasTable('product_flat')) { + Schema::table('product_flat', function (Blueprint $table) { + $table->dropColumn('new_from'); + $table->dropColumn('new_to'); + }); + } + } +} diff --git a/packages/Webkul/Product/src/Http/Controllers/ProductController.php b/packages/Webkul/Product/src/Http/Controllers/ProductController.php index 577e9f8ed..b9d9ec2b7 100755 --- a/packages/Webkul/Product/src/Http/Controllers/ProductController.php +++ b/packages/Webkul/Product/src/Http/Controllers/ProductController.php @@ -8,12 +8,11 @@ use Illuminate\Support\Facades\Event; use Webkul\Product\Http\Requests\ProductForm; use Webkul\Product\Repositories\ProductRepository as Product; use Webkul\Product\Repositories\ProductGridRepository as ProductGrid; +use Webkul\Product\Repositories\ProductFlatRepository as ProductFlat; use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily; -use Webkul\Attribute\Repositories\AttributeRepository as Attribute; use Webkul\Category\Repositories\CategoryRepository as Category; use Webkul\Inventory\Repositories\InventorySourceRepository as InventorySource; -use Webkul\Admin\DataGrids\TestDataGrid; -use Webkul\Product\Listeners\ProductsFlat as PF; + /** * Product controller * @@ -63,7 +62,13 @@ class ProductController extends Controller * @var array */ protected $productGrid; - protected $attribute; + + /** + * ProductFlat Repository Object + * + * @vatr array + */ + protected $productFlat; /** * Create a new controller instance. @@ -80,7 +85,7 @@ class ProductController extends Controller InventorySource $inventorySource, Product $product, ProductGrid $productGrid, - Attribute $attribute) + ProductFlat $productFlat) { $this->attributeFamily = $attributeFamily; @@ -92,7 +97,7 @@ class ProductController extends Controller $this->productGrid = $productGrid; - $this->attribute = $attribute; + $this->productFlat = $productFlat; $this->_config = request('_config'); } @@ -263,9 +268,31 @@ class ProductController extends Controller return redirect()->route('admin.catalog.products.index'); } - public function testEvent() { - $productFlat = new PF(); + public function testProductFlat() { + $allChannels = []; + $allLocales = []; + $productFlatAtttributes = []; - $productFlat->afterAttributeCreated($this->attribute->find(27)); + $product = $this->product->find(4); + + foreach($product->attribute_values as $attributeValue) { + array_push($productFlatAtttributes, strtolower($attributeValue->attribute->code)); + } + + foreach(core()->getAllChannels() as $channel) { + array_push($allChannels, ['name' => $channel->name, 'code' => $channel->code]); + } + + foreach(core()->getAllLocales() as $locale) { + array_push($allLocales, ['name' => $locale->name, 'code' => $locale->code]); + } + + foreach($allChannels as $allChannel) { + foreach($allLocales as $allLocale) { + + } + } + + die; } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Models/ProductFlat.php b/packages/Webkul/Product/src/Models/ProductFlat.php new file mode 100644 index 000000000..9d357d7fd --- /dev/null +++ b/packages/Webkul/Product/src/Models/ProductFlat.php @@ -0,0 +1,20 @@ +count() ? false : true; } + + // public function getAttributesByChannelAndLocale($product, $channel = 0, $locale = null) { + // $productByChannelAndLocale = []; + + + // } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Repositories/ProductFlatRepository.php b/packages/Webkul/Product/src/Repositories/ProductFlatRepository.php new file mode 100644 index 000000000..db229e966 --- /dev/null +++ b/packages/Webkul/Product/src/Repositories/ProductFlatRepository.php @@ -0,0 +1,43 @@ + @prashant-webkul + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ +class ProductFlatRepository extends Repository +{ + protected $product; + + /** + * Price Object + * + * @var array + */ + protected $price; + + public function __construct( + Product $product, + Price $price, + App $app + ) { + $this->product = $product; + + $this->price = $price; + + parent::__construct($app); + } + + public function model() + { + return 'Webkul\Product\Models\ProductFlat'; + } +} \ No newline at end of file From b19f02f5c0dc976f116d69f2565eb44a46a93c1b Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Mon, 21 Jan 2019 10:56:50 +0530 Subject: [PATCH 05/12] UI issue fix in datagrid mass action master checkbox check and uncheck --- config/app.php | 2 +- .../Http/Controllers/ProductController.php | 48 +++++++++++++++---- .../ProductAttributeValueRepository.php | 6 --- .../src/Repositories/ProductRepository.php | 12 +---- .../Resources/views/datagrid/table.blade.php | 2 +- 5 files changed, 43 insertions(+), 27 deletions(-) diff --git a/config/app.php b/config/app.php index 9461ece41..d151dd0cf 100755 --- a/config/app.php +++ b/config/app.php @@ -147,7 +147,7 @@ return [ 'editor' =>'vscode', /** - * Debug blacklisting + * Blacklisting attributes while debugging */ 'debug_blacklist' => [ '_ENV' => [ diff --git a/packages/Webkul/Product/src/Http/Controllers/ProductController.php b/packages/Webkul/Product/src/Http/Controllers/ProductController.php index b9d9ec2b7..1ee130c75 100755 --- a/packages/Webkul/Product/src/Http/Controllers/ProductController.php +++ b/packages/Webkul/Product/src/Http/Controllers/ProductController.php @@ -9,6 +9,7 @@ use Webkul\Product\Http\Requests\ProductForm; use Webkul\Product\Repositories\ProductRepository as Product; use Webkul\Product\Repositories\ProductGridRepository as ProductGrid; use Webkul\Product\Repositories\ProductFlatRepository as ProductFlat; +use Webkul\Product\Repositories\ProductAttributeValueRepository as ProductAttributeValue; use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily; use Webkul\Category\Repositories\CategoryRepository as Category; use Webkul\Inventory\Repositories\InventorySourceRepository as InventorySource; @@ -69,6 +70,7 @@ class ProductController extends Controller * @vatr array */ protected $productFlat; + protected $productAttributeValue; /** * Create a new controller instance. @@ -85,7 +87,8 @@ class ProductController extends Controller InventorySource $inventorySource, Product $product, ProductGrid $productGrid, - ProductFlat $productFlat) + ProductFlat $productFlat, + ProductAttributeValue $productAttributeValue) { $this->attributeFamily = $attributeFamily; @@ -99,6 +102,8 @@ class ProductController extends Controller $this->productFlat = $productFlat; + $this->productAttributeValue = $productAttributeValue; + $this->_config = request('_config'); } @@ -268,31 +273,58 @@ class ProductController extends Controller return redirect()->route('admin.catalog.products.index'); } + /** + * Testing for the product flat sync method on product creation and updation + */ public function testProductFlat() { $allChannels = []; $allLocales = []; $productFlatAtttributes = []; + //hero variable to map the product and the attribute values on the basis of channels and locales + $productMapped = []; + $product = $this->product->find(4); - foreach($product->attribute_values as $attributeValue) { - array_push($productFlatAtttributes, strtolower($attributeValue->attribute->code)); - } - foreach(core()->getAllChannels() as $channel) { - array_push($allChannels, ['name' => $channel->name, 'code' => $channel->code]); + array_push($allChannels, ['id' => $channel->id, 'name' => $channel->name, 'code' => $channel->code]); } foreach(core()->getAllLocales() as $locale) { - array_push($allLocales, ['name' => $locale->name, 'code' => $locale->code]); + array_push($allLocales, ['id' => $locale->id,'name' => $locale->name, 'code' => $locale->code]); } + /** + * Setting up the hero variable for the direct use on the model itself to make entries in product flat. + */ foreach($allChannels as $allChannel) { foreach($allLocales as $allLocale) { - + $productMapped[$allChannel['code']][$allLocale['code']] = []; } } + /** + * 1. use null when the attribute value is empty string + * 2. make use of all the nullable columns present in the product flat table + */ + foreach($product->attribute_values as $attribute_value) { + // array_push($productFlatAtttributes, ['code' => $attribute_value->attribute->code, 'channel_based' => $attribute_value->attribute->value_per_channel, 'locale_based' => $attribute_value->attribute->value_per_locale]); + + if($attribute_value->attribute->value_per_locale) { + if($attribute_value->attribute->value_per_locale) { + + } else { + dd('this attributes value is only channel dependent'); + } + } else if($attribute_value->attribute->value_per_locale) { + dd('this attributes value is only locale dependent'); + } else { + //use this for non locale and non channel based values + } + } + + dd($productFlatAtttributes); + die; } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Repositories/ProductAttributeValueRepository.php b/packages/Webkul/Product/src/Repositories/ProductAttributeValueRepository.php index 8a3cb6c40..f237f0240 100755 --- a/packages/Webkul/Product/src/Repositories/ProductAttributeValueRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductAttributeValueRepository.php @@ -78,10 +78,4 @@ class ProductAttributeValueRepository extends Repository return $result->count() ? false : true; } - - // public function getAttributesByChannelAndLocale($product, $channel = 0, $locale = null) { - // $productByChannelAndLocale = []; - - - // } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Repositories/ProductRepository.php b/packages/Webkul/Product/src/Repositories/ProductRepository.php index 8ed181ad5..f9a0b5d94 100755 --- a/packages/Webkul/Product/src/Repositories/ProductRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductRepository.php @@ -243,7 +243,7 @@ class ProductRepository extends Repository public function delete($id) { Event::fire('catalog.product.delete.before', $id); - + parent::delete($id); Event::fire('catalog.product.delete.after', $id); @@ -512,14 +512,4 @@ class ProductRepository extends Repository return $query->distinct()->addSelect('products.*')->where('pav.text_value', 'like', '%'.$term.'%'); })->paginate(4); } - - /** - * break the search term into explode by using space and tell which exploded item is attribute - * , category, super attribute or combination of them. - */ - public function breakTheTerm($term) { - $explodedTerm = (explode(" ", $term)); - - dd($term); - } } \ No newline at end of file diff --git a/packages/Webkul/Ui/src/Resources/views/datagrid/table.blade.php b/packages/Webkul/Ui/src/Resources/views/datagrid/table.blade.php index 643b920be..1b1ee2ea5 100644 --- a/packages/Webkul/Ui/src/Resources/views/datagrid/table.blade.php +++ b/packages/Webkul/Ui/src/Resources/views/datagrid/table.blade.php @@ -155,7 +155,7 @@
- + From ffe0f246b4dc532170e3482c0ac682cc68656cf6 Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Mon, 21 Jan 2019 15:20:01 +0530 Subject: [PATCH 06/12] for alpha today --- .../Criteria/FilterByAttributesCriteria.php | 11 +- .../Http/Controllers/ProductController.php | 103 ++++++++++++------ 2 files changed, 75 insertions(+), 39 deletions(-) diff --git a/packages/Webkul/Product/src/Contracts/Criteria/FilterByAttributesCriteria.php b/packages/Webkul/Product/src/Contracts/Criteria/FilterByAttributesCriteria.php index ed65ba1ff..cba05e417 100755 --- a/packages/Webkul/Product/src/Contracts/Criteria/FilterByAttributesCriteria.php +++ b/packages/Webkul/Product/src/Contracts/Criteria/FilterByAttributesCriteria.php @@ -40,12 +40,12 @@ class FilterByAttributesCriteria extends AbstractProduct implements CriteriaInte public function apply($model, RepositoryInterface $repository) { $model = $model->leftJoin('products as variants', 'products.id', '=', 'variants.parent_id'); - + $model = $model->where(function($query1) use($model) { $aliases = [ - 'products' => 'filter_', - 'variants' => 'variant_filter_' - ]; + 'products' => 'filter_', + 'variants' => 'variant_filter_' + ]; foreach ($aliases as $table => $alias) { $query1 = $query1->orWhere(function($query2) use($model, $table, $alias) { @@ -58,8 +58,9 @@ class FilterByAttributesCriteria extends AbstractProduct implements CriteriaInte $query2 = $this->applyChannelLocaleFilter($attribute, $query2, $aliasTemp); $column = ProductAttributeValue::$attributeTypeFields[$attribute->type]; - + $temp = explode(',', request()->get($attribute->code)); + if ($attribute->type != 'price') { $query2 = $query2->where($aliasTemp . '.attribute_id', $attribute->id); diff --git a/packages/Webkul/Product/src/Http/Controllers/ProductController.php b/packages/Webkul/Product/src/Http/Controllers/ProductController.php index 1ee130c75..457c0a73c 100755 --- a/packages/Webkul/Product/src/Http/Controllers/ProductController.php +++ b/packages/Webkul/Product/src/Http/Controllers/ProductController.php @@ -10,6 +10,7 @@ use Webkul\Product\Repositories\ProductRepository as Product; use Webkul\Product\Repositories\ProductGridRepository as ProductGrid; use Webkul\Product\Repositories\ProductFlatRepository as ProductFlat; use Webkul\Product\Repositories\ProductAttributeValueRepository as ProductAttributeValue; +use Webkul\Attribute\Repositories\AttributeRepository as Attribute; use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily; use Webkul\Category\Repositories\CategoryRepository as Category; use Webkul\Inventory\Repositories\InventorySourceRepository as InventorySource; @@ -71,6 +72,7 @@ class ProductController extends Controller */ protected $productFlat; protected $productAttributeValue; + protected $attribute; /** * Create a new controller instance. @@ -88,7 +90,8 @@ class ProductController extends Controller Product $product, ProductGrid $productGrid, ProductFlat $productFlat, - ProductAttributeValue $productAttributeValue) + ProductAttributeValue $productAttributeValue, + Attribute $attribute) { $this->attributeFamily = $attributeFamily; @@ -102,7 +105,9 @@ class ProductController extends Controller $this->productFlat = $productFlat; - $this->productAttributeValue = $productAttributeValue; + $this->productAttributeValue = $productAttibuteValue; + + $this->attribute = $attribute; $this->_config = request('_config'); } @@ -277,54 +282,84 @@ class ProductController extends Controller * Testing for the product flat sync method on product creation and updation */ public function testProductFlat() { - $allChannels = []; - $allLocales = []; - $productFlatAtttributes = []; - - //hero variable to map the product and the attribute values on the basis of channels and locales - $productMapped = []; - $product = $this->product->find(4); + $allChannelAndLocales = []; + $productMapped = []; + $channelLocaleMap = []; foreach(core()->getAllChannels() as $channel) { - array_push($allChannels, ['id' => $channel->id, 'name' => $channel->name, 'code' => $channel->code]); - } + array_push($productMapped, [ + 'product_id' => $product->id, + 'type' => $product->type, + 'channel_code' => $channel->code, + 'locale_code' => 'null', + ]); - foreach(core()->getAllLocales() as $locale) { - array_push($allLocales, ['id' => $locale->id,'name' => $locale->name, 'code' => $locale->code]); - } + array_push($channelLocaleMap, [ + 'product_id' => $product->id, + 'type' => $product->type, + 'channel_code' => $channel->code, + 'locale_code' => 'null', + ]); - /** - * Setting up the hero variable for the direct use on the model itself to make entries in product flat. - */ - foreach($allChannels as $allChannel) { - foreach($allLocales as $allLocale) { - $productMapped[$allChannel['code']][$allLocale['code']] = []; + foreach($channel->locales as $locale) { + array_push($productMapped, [ + 'product_id' => $product->id, + 'type' => $product->type, + 'channel_code' => $channel->code, + 'locale_code' => $locale->code + ]); + + array_push($channelLocaleMap, [ + 'product_id' => $product->id, + 'type' => $product->type, + 'channel_code' => $channel->code, + 'locale_code' => $locale->code, + ]); + + array_push($productMapped, [ + 'product_id' => $product->id, + 'type' => $product->type, + 'channel_code' => 'null', + 'locale_code' => $locale->code, + ]); + + array_push($channelLocaleMap, [ + 'product_id' => $product->id, + 'type' => $product->type, + 'channel_code' => 'null', + 'locale_code' => $locale->code, + ]); } } - /** - * 1. use null when the attribute value is empty string - * 2. make use of all the nullable columns present in the product flat table - */ - foreach($product->attribute_values as $attribute_value) { - // array_push($productFlatAtttributes, ['code' => $attribute_value->attribute->code, 'channel_based' => $attribute_value->attribute->value_per_channel, 'locale_based' => $attribute_value->attribute->value_per_locale]); + $attributes = $product->attribute_family->custom_attributes; - if($attribute_value->attribute->value_per_locale) { - if($attribute_value->attribute->value_per_locale) { + foreach($attributes as $key => $attribute) { + dd($this->productAttributeValue->findWhere(['attribute_id' => $attribute->id, 'value_per_locale' => 1, 'value_per_channel' => 1])); + if($attribute->type == 'select') { + if($attribute->value_per_channel && $attribute->value_per_locale) { + dd($this->productAttributeValue->findWhere(['attribute_id' => $attribute->id, 'value_per_locale' => 1, 'value_per_channel' => 1])); + // $this->pushCorrect($attribute->channel); + } else if($attribute->value_per_channel && !$attribute->value_per_locale) { + // $this->pushCorrect(); + } else if($attribute->value_per_locale) { + // $this->pushCorrect(); } else { - dd('this attributes value is only channel dependent'); + // $this->pushCorrect(); } - } else if($attribute_value->attribute->value_per_locale) { - dd('this attributes value is only locale dependent'); + } else if($attribute->type == 'multiselect') { + // $this->pushCorrect(); } else { - //use this for non locale and non channel based values + // $this->pushCorrect(); } } - dd($productFlatAtttributes); + // dd($productMapped); + } - die; + public function pushCorrect($channelCode = null, $localeCode = null, $productMapped) { + dd($channelCode, $localeCode, $productMapped); } } \ No newline at end of file From 2172ac60ddf663d8022fb7683dbac25356c897aa Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Mon, 21 Jan 2019 16:29:20 +0530 Subject: [PATCH 07/12] fixed the issues with routes of actions in admin datagrids --- .../src/DataGrids/CustomerGroupDataGrid.php | 4 +- .../src/DataGrids/OrderShipmentsDataGrid.php | 2 +- .../Admin/src/DataGrids/TaxRateDataGrid.php | 4 +- .../Admin/src/DataGrids/UserDataGrid.php | 2 +- .../Http/Controllers/ProductController.php | 62 +++++++++++++------ 5 files changed, 48 insertions(+), 26 deletions(-) diff --git a/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php index c7960414c..79e700ca7 100755 --- a/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php @@ -48,13 +48,13 @@ class CustomerGroupDataGrid extends DataGrid public function prepareActions() { $this->addAction([ 'type' => 'Edit', - 'route' => 'admin.customer.edit', + 'route' => 'admin.groups.edit', 'icon' => 'icon pencil-lg-icon' ]); $this->addAction([ 'type' => 'Delete', - 'route' => 'admin.customer.delete', + 'route' => 'admin.groups.delete', 'icon' => 'icon trash-icon' ]); } diff --git a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php index 5cfd5cad8..e10c78f79 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php @@ -100,7 +100,7 @@ class OrderShipmentsDataGrid extends DataGrid public function prepareActions() { $this->addAction([ 'type' => 'View', - 'route' => 'admin.sales.orders.view', + 'route' => 'admin.sales.shipments.view', 'icon' => 'icon eye-icon' ]); } diff --git a/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php b/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php index 9a576f61f..5196bf813 100755 --- a/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php @@ -72,13 +72,13 @@ class TaxRateDataGrid extends DataGrid public function prepareActions() { $this->addAction([ 'type' => 'Edit', - 'route' => 'admin.tax-categories.edit', + 'route' => 'admin.tax-rates.store', 'icon' => 'icon pencil-lg-icon' ]); $this->addAction([ 'type' => 'Delete', - 'route' => 'admin.tax-categories.delete', + 'route' => 'admin.tax-rates.delete', 'icon' => 'icon trash-icon' ]); } diff --git a/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php b/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php index f594bfdbb..31fd8d7b3 100755 --- a/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php @@ -83,7 +83,7 @@ class UserDataGrid extends DataGrid public function prepareActions() { $this->addAction([ 'type' => 'Edit', - 'route' => 'admin.roles.edit', + 'route' => 'admin.users.edit', 'icon' => 'icon pencil-lg-icon' ]); } diff --git a/packages/Webkul/Product/src/Http/Controllers/ProductController.php b/packages/Webkul/Product/src/Http/Controllers/ProductController.php index 457c0a73c..7c6d4ef35 100755 --- a/packages/Webkul/Product/src/Http/Controllers/ProductController.php +++ b/packages/Webkul/Product/src/Http/Controllers/ProductController.php @@ -10,7 +10,6 @@ use Webkul\Product\Repositories\ProductRepository as Product; use Webkul\Product\Repositories\ProductGridRepository as ProductGrid; use Webkul\Product\Repositories\ProductFlatRepository as ProductFlat; use Webkul\Product\Repositories\ProductAttributeValueRepository as ProductAttributeValue; -use Webkul\Attribute\Repositories\AttributeRepository as Attribute; use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily; use Webkul\Category\Repositories\CategoryRepository as Category; use Webkul\Inventory\Repositories\InventorySourceRepository as InventorySource; @@ -90,8 +89,7 @@ class ProductController extends Controller Product $product, ProductGrid $productGrid, ProductFlat $productFlat, - ProductAttributeValue $productAttributeValue, - Attribute $attribute) + ProductAttributeValue $productAttributeValue) { $this->attributeFamily = $attributeFamily; @@ -105,9 +103,7 @@ class ProductController extends Controller $this->productFlat = $productFlat; - $this->productAttributeValue = $productAttibuteValue; - - $this->attribute = $attribute; + $this->productAttributeValue = $productAttributeValue; $this->_config = request('_config'); } @@ -336,27 +332,53 @@ class ProductController extends Controller $attributes = $product->attribute_family->custom_attributes; foreach($attributes as $key => $attribute) { - dd($this->productAttributeValue->findWhere(['attribute_id' => $attribute->id, 'value_per_locale' => 1, 'value_per_channel' => 1])); - if($attribute->type == 'select') { - if($attribute->value_per_channel && $attribute->value_per_locale) { - dd($this->productAttributeValue->findWhere(['attribute_id' => $attribute->id, 'value_per_locale' => 1, 'value_per_channel' => 1])); - - // $this->pushCorrect($attribute->channel); - } else if($attribute->value_per_channel && !$attribute->value_per_locale) { - // $this->pushCorrect(); - } else if($attribute->value_per_locale) { - // $this->pushCorrect(); - } else { - // $this->pushCorrect(); + if($attribute->value_per_channel && $attribute->value_per_locale) { + $values = $this->productAttributeValue->findWhere(['attribute_id' => $attribute->id, 'product_id' => $product->id]); + dd($values); + foreach($values as $key => $value) { + dd($value->channel, $value->locale); + // $this->pushCorrect($attribute->channel, ); } - } else if($attribute->type == 'multiselect') { + + + } else if($attribute->value_per_channel && !$attribute->value_per_locale) { + // $this->pushCorrect(); + } else if($attribute->value_per_locale) { // $this->pushCorrect(); } else { // $this->pushCorrect(); } + + // if($attribute->type == 'select') { + // if($attribute->value_per_channel && $attribute->value_per_locale) { + // dd($this->productAttributeValue->findWhere(['attribute_id' => $attribute->id])); + + // // $this->pushCorrect($attribute->channel); + // } else if($attribute->value_per_channel && !$attribute->value_per_locale) { + // // $this->pushCorrect(); + // } else if($attribute->value_per_locale) { + // // $this->pushCorrect(); + // } else { + // // $this->pushCorrect(); + // } + // } else if($attribute->type == 'multiselect') { + // // $this->pushCorrect(); + // } else { + // if($attribute->value_per_channel && $attribute->value_per_locale) { + // dd($this->productAttributeValue->findWhere(['attribute_id' => $attribute->id])); + + // // $this->pushCorrect($attribute->channel); + // } else if($attribute->value_per_channel && !$attribute->value_per_locale) { + // // $this->pushCorrect(); + // } else if($attribute->value_per_locale) { + // // $this->pushCorrect(); + // } else { + // // $this->pushCorrect(); + // } + // } } - // dd($productMapped); + dd($productMapped); } public function pushCorrect($channelCode = null, $localeCode = null, $productMapped) { From 810d5928c3e0673d3fe95f5e70d6c05cad75316a Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Tue, 22 Jan 2019 18:25:47 +0530 Subject: [PATCH 08/12] product flat all set with data structure with all the permutations of channels and locales now being recorded from the product attribute values --- README.md | 2 +- .../Http/Controllers/ProductController.php | 174 +++++++++--------- .../src/Models/ProductAttributeValue.php | 26 +-- 3 files changed, 105 insertions(+), 97 deletions(-) diff --git a/README.md b/README.md index 9a1651d96..ae51f948a 100755 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Bagisto is using power of both of these frameworks and making best out of it out * **OS**: Ubuntu 16.04 LTS or higher. * **SERVER**: Apache 2 or NGINX -* **RAM**: 2 GB or higer. +* **RAM**: 2 GB or higher. * **PHP**: 7.1.17 or higher. * **Processor**: Clock Cycle 1Ghz or higher. * **Mysql**: 5.7.23 or higher. diff --git a/packages/Webkul/Product/src/Http/Controllers/ProductController.php b/packages/Webkul/Product/src/Http/Controllers/ProductController.php index 2784051e1..8f0437eec 100755 --- a/packages/Webkul/Product/src/Http/Controllers/ProductController.php +++ b/packages/Webkul/Product/src/Http/Controllers/ProductController.php @@ -279,106 +279,114 @@ class ProductController extends Controller */ public function testProductFlat() { $product = $this->product->find(4); - $allChannelAndLocales = []; - $productMapped = []; - $channelLocaleMap = []; + $productAttributes = $product->attribute_family->custom_attributes; + $allLocales = core()->getAllLocales(); + $productsFlat = array(); + $attributeNames = array(); + $channelLocaleMap = array(); + $nonDependentAttributes = array(); + $localeDependentAttributes = array(); + $channelDependentAttributes = array(); + $channelLocaleDependentAttributes = array(); + + foreach($productAttributes as $key => $productAttribute) { + $attributeNames[$key] = [ + 'id' => $productAttribute->id, + 'code' => $productAttribute->code, + 'value_per_locale' => $productAttribute->value_per_locale, + 'value_per_channel' => $productAttribute->value_per_channel, + ]; + } + + foreach($productAttributes as $productAttribute) { + if($productAttribute->value_per_channel) { + if($productAttribute->value_per_locale) { + array_push($channelLocaleDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); + } else { + array_push($channelDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); + } + } else if($productAttribute->value_per_locale && !$productAttribute->value_per_channel) { + array_push($localeDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); + } else { + array_push($nonDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); + } + } foreach(core()->getAllChannels() as $channel) { - array_push($productMapped, [ + $dummy = [ 'product_id' => $product->id, - 'type' => $product->type, - 'channel_code' => $channel->code, - 'locale_code' => 'null', - ]); + 'channel' => $channel->code, + 'locale' => null, + 'data' => $channelDependentAttributes + ]; - array_push($channelLocaleMap, [ - 'product_id' => $product->id, - 'type' => $product->type, - 'channel_code' => $channel->code, - 'locale_code' => 'null', - ]); + array_push($channelLocaleMap, $dummy); + + $dummy = []; foreach($channel->locales as $locale) { - array_push($productMapped, [ + $dummy = [ 'product_id' => $product->id, - 'type' => $product->type, - 'channel_code' => $channel->code, - 'locale_code' => $locale->code - ]); + 'channel' => $channel->code, + 'locale' => $locale->code, + 'data' => $channelLocaleDependentAttributes + ]; - array_push($channelLocaleMap, [ - 'product_id' => $product->id, - 'type' => $product->type, - 'channel_code' => $channel->code, - 'locale_code' => $locale->code, - ]); + array_push($channelLocaleMap, $dummy); - array_push($productMapped, [ - 'product_id' => $product->id, - 'type' => $product->type, - 'channel_code' => 'null', - 'locale_code' => $locale->code, - ]); - - array_push($channelLocaleMap, [ - 'product_id' => $product->id, - 'type' => $product->type, - 'channel_code' => 'null', - 'locale_code' => $locale->code, - ]); + $dummy = []; } } - $attributes = $product->attribute_family->custom_attributes; + $dummy = [ + 'product_id' => $product->id, + 'channel' => null, + 'locale' => null, + 'data' => $nonDependentAttributes + ]; - foreach($attributes as $key => $attribute) { - if($attribute->value_per_channel && $attribute->value_per_locale) { - $values = $this->productAttributeValue->findWhere(['attribute_id' => $attribute->id, 'product_id' => $product->id]); + array_push($channelLocaleMap, $dummy); - foreach($values as $key => $value) { - $this->pushCorrect($value->channel, $value->locale, $productMapped); + $dummy = []; + + foreach($allLocales as $key => $allLocale) { + $dummy = [ + 'product_id' => $product->id, + 'channel' => null, + 'locale' => $allLocale->code, + 'data' => $localeDependentAttributes + ]; + + array_push($channelLocaleMap, $dummy); + + $dummy = []; + } + + $productFlatObjects = $channelLocaleMap; + + foreach($productAttributes as $productAttribute) { + foreach($productFlatObjects as $flatKey => $productFlatObject) { + foreach($productFlatObject['data'] as $key => $value) { + if($productAttribute->code == $value['code']) { + $valueOf = $this->productAttributeValue->findOneWhere([ + 'product_id' => $product->id, + 'channel' => $productFlatObject['channel'], + 'locale' => $productFlatObject['locale'], + 'attribute_id' => $productAttribute->id + ]); + + $productAttributeColumn = $this->productAttributeValue->model()::$attributeTypeFields[$productAttribute->type]; + + dump($productAttributeColumn); + + $valueOf = $valueOf->{$productAttributeColumn}; + + $productFlatObjects[$flatKey][$productAttribute->code] = $valueOf; + } } - } else if($attribute->value_per_channel && !$attribute->value_per_locale) { - $this->pushCorrect($value->channel, $value->locale, $productMapped); - } else if($attribute->value_per_locale) { - $this->pushCorrect($value->channel, $value->locale, $productMapped); - } else { - $this->pushCorrect($value->channel, $value->locale, $productMapped); } - - // if($attribute->type == 'select') { - // if($attribute->value_per_channel && $attribute->value_per_locale) { - // dd($this->productAttributeValue->findWhere(['attribute_id' => $attribute->id])); - - // // $this->pushCorrect($attribute->channel); - // } else if($attribute->value_per_channel && !$attribute->value_per_locale) { - // // $this->pushCorrect(); - // } else if($attribute->value_per_locale) { - // // $this->pushCorrect(); - // } else { - // // $this->pushCorrect(); - // } - // } else if($attribute->type == 'multiselect') { - // // $this->pushCorrect(); - // } else { - // if($attribute->value_per_channel && $attribute->value_per_locale) { - // dd($this->productAttributeValue->findWhere(['attribute_id' => $attribute->id])); - - // // $this->pushCorrect($attribute->channel); - // } else if($attribute->value_per_channel && !$attribute->value_per_locale) { - // // $this->pushCorrect(); - // } else if($attribute->value_per_locale) { - // // $this->pushCorrect(); - // } else { - // // $this->pushCorrect(); - // } - // } } - dd($productMapped); - } - - public function pushCorrect($channelCode = null, $localeCode = null, $productMapped) { - dd($channelCode, $localeCode, $productMapped); + dd($productFlatObjects); } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Models/ProductAttributeValue.php b/packages/Webkul/Product/src/Models/ProductAttributeValue.php index 6eb459ae3..eea93401d 100755 --- a/packages/Webkul/Product/src/Models/ProductAttributeValue.php +++ b/packages/Webkul/Product/src/Models/ProductAttributeValue.php @@ -28,19 +28,19 @@ class ProductAttributeValue extends Model ]; protected $fillable = [ - 'product_id', - 'attribute_id', - 'channel_id', - 'locale', - 'channel', - 'text_value', - 'boolean_value', - 'integer_value', - 'float_value', - 'datetime_value', - 'date_value', - 'json_value' - ]; + 'product_id', + 'attribute_id', + 'channel_id', + 'locale', + 'channel', + 'text_value', + 'boolean_value', + 'integer_value', + 'float_value', + 'datetime_value', + 'date_value', + 'json_value' + ]; /** * Get the attribute that owns the attribute value. From 07daf7d310f6298f22a8b8a536861aa133f4a284 Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Tue, 22 Jan 2019 18:53:17 +0530 Subject: [PATCH 09/12] product flat now showing up with relevant attributes data --- .../src/Http/Controllers/AttributeController.php | 4 ++-- .../src/Http/Controllers/ProductController.php | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php b/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php index c384500e5..978fe956f 100755 --- a/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php +++ b/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php @@ -81,7 +81,7 @@ class AttributeController extends Controller $attribute = $this->attribute->create($data); - // Event::fire('after.attribute.created', $attribute); + Event::fire('after.attribute.created', $attribute); session()->flash('success', 'Attribute created successfully.'); @@ -139,7 +139,7 @@ class AttributeController extends Controller session()->flash('error', trans('admin::app.response.user-define-error', ['name' => 'attribute'])); } else { try { - // Event::fire('after.attribute.deleted', $attribute); + Event::fire('after.attribute.deleted', $attribute); $this->attribute->delete($id); diff --git a/packages/Webkul/Product/src/Http/Controllers/ProductController.php b/packages/Webkul/Product/src/Http/Controllers/ProductController.php index 8f0437eec..52172d3d6 100755 --- a/packages/Webkul/Product/src/Http/Controllers/ProductController.php +++ b/packages/Webkul/Product/src/Http/Controllers/ProductController.php @@ -375,13 +375,16 @@ class ProductController extends Controller 'attribute_id' => $productAttribute->id ]); - $productAttributeColumn = $this->productAttributeValue->model()::$attributeTypeFields[$productAttribute->type]; + if($valueOf != null) { + $productAttributeColumn = $this->productAttributeValue->model()::$attributeTypeFields[$productAttribute->type]; - dump($productAttributeColumn); + $valueOf = $valueOf->{$productAttributeColumn}; - $valueOf = $valueOf->{$productAttributeColumn}; + $productFlatObjects[$flatKey][$productAttribute->code] = $valueOf; + } else { + $productFlatObjects[$flatKey][$productAttribute->code] = 'null'; + } - $productFlatObjects[$flatKey][$productAttribute->code] = $valueOf; } } } From 67dbce6fa8bf86a36f015c15f1d738554ca4e6af Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Wed, 23 Jan 2019 16:35:34 +0530 Subject: [PATCH 10/12] Product flat implementation working, now binding it with the product update evento to write the --- packages/Webkul/Core/src/Core.php | 12 +- ...dd_new_from_to_columns_in_product_flat.php | 4 + .../Http/Controllers/ProductController.php | 138 +------------- .../Product/src/Listeners/ProductsFlat.php | 173 ++++++++++++++++++ .../Webkul/Product/src/Models/ProductFlat.php | 2 + 5 files changed, 191 insertions(+), 138 deletions(-) diff --git a/packages/Webkul/Core/src/Core.php b/packages/Webkul/Core/src/Core.php index 67459a803..cd92ad92e 100755 --- a/packages/Webkul/Core/src/Core.php +++ b/packages/Webkul/Core/src/Core.php @@ -775,5 +775,15 @@ class Core } return $merged; - } + } + + public function convertEmptyStringsToNull($array) { + foreach($array as $key => $value) { + if($value == "" || $value == "null") { + $array[$key] = null; + } + } + + return $array; + } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Database/Migrations/2019_01_19_144504_add_new_from_to_columns_in_product_flat.php b/packages/Webkul/Product/src/Database/Migrations/2019_01_19_144504_add_new_from_to_columns_in_product_flat.php index e187229ae..f86b7d4e0 100644 --- a/packages/Webkul/Product/src/Database/Migrations/2019_01_19_144504_add_new_from_to_columns_in_product_flat.php +++ b/packages/Webkul/Product/src/Database/Migrations/2019_01_19_144504_add_new_from_to_columns_in_product_flat.php @@ -15,8 +15,10 @@ class AddNewFromToColumnsInProductFlat extends Migration { if (Schema::hasTable('product_flat')) { Schema::table('product_flat', function (Blueprint $table) { + $table->integer('tax_category_id')->unsigned()->nullable()->after('size_label'); $table->date('new_to')->after('new'); $table->date('new_from')->after('new'); + $table->unique(['product_id', 'channel', 'locale'], 'product_flat_unique_index'); }); } } @@ -30,8 +32,10 @@ class AddNewFromToColumnsInProductFlat extends Migration { if (Schema::hasTable('product_flat')) { Schema::table('product_flat', function (Blueprint $table) { + $table->dropColumn('tax_category_id')->unsigned(); $table->dropColumn('new_from'); $table->dropColumn('new_to'); + $table->dropIndex('product_flat_unique_index'); }); } } diff --git a/packages/Webkul/Product/src/Http/Controllers/ProductController.php b/packages/Webkul/Product/src/Http/Controllers/ProductController.php index 52172d3d6..dce62c5bc 100755 --- a/packages/Webkul/Product/src/Http/Controllers/ProductController.php +++ b/packages/Webkul/Product/src/Http/Controllers/ProductController.php @@ -8,8 +8,6 @@ use Illuminate\Support\Facades\Event; use Webkul\Product\Http\Requests\ProductForm; use Webkul\Product\Repositories\ProductRepository as Product; use Webkul\Product\Repositories\ProductGridRepository as ProductGrid; -use Webkul\Product\Repositories\ProductFlatRepository as ProductFlat; -use Webkul\Product\Repositories\ProductAttributeValueRepository as ProductAttributeValue; use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily; use Webkul\Category\Repositories\CategoryRepository as Category; use Webkul\Inventory\Repositories\InventorySourceRepository as InventorySource; @@ -64,15 +62,6 @@ class ProductController extends Controller */ protected $productGrid; - /** - * ProductFlat Repository Object - * - * @vatr array - */ - protected $productFlat; - protected $productAttributeValue; - protected $attribute; - /** * Create a new controller instance. * @@ -87,9 +76,7 @@ class ProductController extends Controller Category $category, InventorySource $inventorySource, Product $product, - ProductGrid $productGrid, - ProductFlat $productFlat, - ProductAttributeValue $productAttributeValue) + ProductGrid $productGrid) { $this->attributeFamily = $attributeFamily; @@ -101,10 +88,6 @@ class ProductController extends Controller $this->productGrid = $productGrid; - $this->productFlat = $productFlat; - - $this->productAttributeValue = $productAttributeValue; - $this->_config = request('_config'); } @@ -273,123 +256,4 @@ class ProductController extends Controller return redirect()->route('admin.catalog.products.index'); } - - /** - * Testing for the product flat sync method on product creation and updation - */ - public function testProductFlat() { - $product = $this->product->find(4); - $productAttributes = $product->attribute_family->custom_attributes; - $allLocales = core()->getAllLocales(); - $productsFlat = array(); - $attributeNames = array(); - $channelLocaleMap = array(); - $nonDependentAttributes = array(); - $localeDependentAttributes = array(); - $channelDependentAttributes = array(); - $channelLocaleDependentAttributes = array(); - - foreach($productAttributes as $key => $productAttribute) { - $attributeNames[$key] = [ - 'id' => $productAttribute->id, - 'code' => $productAttribute->code, - 'value_per_locale' => $productAttribute->value_per_locale, - 'value_per_channel' => $productAttribute->value_per_channel, - ]; - } - - foreach($productAttributes as $productAttribute) { - if($productAttribute->value_per_channel) { - if($productAttribute->value_per_locale) { - array_push($channelLocaleDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); - } else { - array_push($channelDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); - } - } else if($productAttribute->value_per_locale && !$productAttribute->value_per_channel) { - array_push($localeDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); - } else { - array_push($nonDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); - } - } - - foreach(core()->getAllChannels() as $channel) { - $dummy = [ - 'product_id' => $product->id, - 'channel' => $channel->code, - 'locale' => null, - 'data' => $channelDependentAttributes - ]; - - array_push($channelLocaleMap, $dummy); - - $dummy = []; - - foreach($channel->locales as $locale) { - $dummy = [ - 'product_id' => $product->id, - 'channel' => $channel->code, - 'locale' => $locale->code, - 'data' => $channelLocaleDependentAttributes - ]; - - array_push($channelLocaleMap, $dummy); - - $dummy = []; - } - } - - $dummy = [ - 'product_id' => $product->id, - 'channel' => null, - 'locale' => null, - 'data' => $nonDependentAttributes - ]; - - array_push($channelLocaleMap, $dummy); - - $dummy = []; - - foreach($allLocales as $key => $allLocale) { - $dummy = [ - 'product_id' => $product->id, - 'channel' => null, - 'locale' => $allLocale->code, - 'data' => $localeDependentAttributes - ]; - - array_push($channelLocaleMap, $dummy); - - $dummy = []; - } - - $productFlatObjects = $channelLocaleMap; - - foreach($productAttributes as $productAttribute) { - foreach($productFlatObjects as $flatKey => $productFlatObject) { - foreach($productFlatObject['data'] as $key => $value) { - if($productAttribute->code == $value['code']) { - $valueOf = $this->productAttributeValue->findOneWhere([ - 'product_id' => $product->id, - 'channel' => $productFlatObject['channel'], - 'locale' => $productFlatObject['locale'], - 'attribute_id' => $productAttribute->id - ]); - - if($valueOf != null) { - $productAttributeColumn = $this->productAttributeValue->model()::$attributeTypeFields[$productAttribute->type]; - - $valueOf = $valueOf->{$productAttributeColumn}; - - $productFlatObjects[$flatKey][$productAttribute->code] = $valueOf; - } else { - $productFlatObjects[$flatKey][$productAttribute->code] = 'null'; - } - - } - } - } - } - - dd($productFlatObjects); - } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Listeners/ProductsFlat.php b/packages/Webkul/Product/src/Listeners/ProductsFlat.php index d3ee2ed1f..21061904d 100644 --- a/packages/Webkul/Product/src/Listeners/ProductsFlat.php +++ b/packages/Webkul/Product/src/Listeners/ProductsFlat.php @@ -5,6 +5,8 @@ namespace Webkul\Product\Listeners; use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; +use Webkul\Product\Repositories\ProductFlatRepository as ProductFlat; +use Webkul\Product\Repositories\ProductAttributeValueRepository as ProductAttributeValue; /** * Products Flat Event handler * @@ -13,6 +15,23 @@ use Illuminate\Database\Schema\Blueprint; */ class ProductsFlat { + /** + * ProductFlat Repository Object + * + * @vatr array + */ + protected $productFlat; + + protected $productAttributeValue; + + protected $attribute; + + public function __construct(ProductFlat $productFlat, ProductAttributeValue $productAttributeValue) { + $this->productAttributeValue = $productAttributeValue; + + $this->productFlat = $productFlat; + } + /** * After the attribute is created * @@ -92,4 +111,158 @@ class ProductsFlat } } } + + public function afterProductCreated($Product) { + $product = $Product; + $productAttributes = $product->attribute_family->custom_attributes; + $allLocales = core()->getAllLocales(); + $productsFlat = array(); + $channelLocaleMap = array(); + $nonDependentAttributes = array(); + $localeDependentAttributes = array(); + $channelDependentAttributes = array(); + $channelLocaleDependentAttributes = array(); + + foreach($productAttributes as $key => $productAttribute) { + if($productAttribute->value_per_channel) { + if($productAttribute->value_per_locale) { + array_push($channelLocaleDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); + } else { + array_push($channelDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); + } + } else if($productAttribute->value_per_locale && !$productAttribute->value_per_channel) { + array_push($localeDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); + } else { + array_push($nonDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); + } + } + + foreach(core()->getAllChannels() as $channel) { + $dummy = [ + 'product_id' => $product->id, + 'channel' => $channel->code, + 'locale' => null, + 'data' => $channelDependentAttributes + ]; + + array_push($channelLocaleMap, $dummy); + + $dummy = []; + + foreach($channel->locales as $locale) { + $dummy = [ + 'product_id' => $product->id, + 'channel' => $channel->code, + 'locale' => $locale->code, + 'data' => $channelLocaleDependentAttributes + ]; + + array_push($channelLocaleMap, $dummy); + + $dummy = []; + } + } + + $dummy = [ + 'product_id' => $product->id, + 'channel' => null, + 'locale' => null, + 'data' => $nonDependentAttributes + ]; + + array_push($channelLocaleMap, $dummy); + + $dummy = []; + + foreach($allLocales as $key => $allLocale) { + $dummy = [ + 'product_id' => $product->id, + 'channel' => null, + 'locale' => $allLocale->code, + 'data' => $localeDependentAttributes + ]; + + array_push($channelLocaleMap, $dummy); + + $dummy = []; + } + + $productFlatObjects = $channelLocaleMap; + $keyOfNonDependentAttributes = null; + + foreach($productAttributes as $productAttribute) { + foreach($productFlatObjects as $flatKey => $productFlatObject) { + if($productFlatObject['channel'] == null && $productFlatObject['locale'] == null) { + $keyOfNonDependentAttributes = $flatKey; + } + + foreach($productFlatObject['data'] as $key => $value) { + if($productAttribute->code == $value['code']) { + $valueOf = $this->productAttributeValue->findOneWhere([ + 'product_id' => $product->id, + 'channel' => $productFlatObject['channel'], + 'locale' => $productFlatObject['locale'], + 'attribute_id' => $productAttribute->id + ]); + + if($valueOf != null) { + $productAttributeColumn = $this->productAttributeValue->model()::$attributeTypeFields[$productAttribute->type]; + + $valueOf = $valueOf->{$productAttributeColumn}; + + $productFlatObjects[$flatKey][$productAttribute->code] = $valueOf; + } else { + $productFlatObjects[$flatKey][$productAttribute->code] = 'null'; + } + } + } + } + } + + $nonDependentAttributes = $productFlatObjects[$keyOfNonDependentAttributes]; + + array_forget($nonDependentAttributes, ['product_id', 'channel', 'locale', 'data', 'visible_individually', 'width', 'height', 'depth']); + + unset($productFlatObjects[$keyOfNonDependentAttributes]); + + $productFlatEntryObject = array(); + + $tempFlatObject = array(); + + foreach($productFlatObjects as $flatKey => $productFlatObject) { + unset($productFlatObject['data']); + + if(isset($productFlatObject['short_description'])) { + $productFlatObject['description'] = $productFlatObject['short_description']; + + unset($productFlatObject['short_description']); + } + + if(isset($productFlatObject['meta_title'])) { + unset($productFlatObject['meta_title']); + unset($productFlatObject['meta_description']); + unset($productFlatObject['meta_keywords']); + } + + $tempFlatObject = array_merge($productFlatObject, $nonDependentAttributes); + + $tempFlatObject = core()->convertEmptyStringsToNull($tempFlatObject); + + $exists = $this->productFlat->findWhere([ + 'product_id' => $product->id, + 'channel' => $tempFlatObject['channel'], + 'locale' => $tempFlatObject['locale'] + ]); + + if($exists->count() == 0) { + $result = $this->productFlat->create($tempFlatObject); + } else { + //perform update + } + + unset($tempFlatObject); + } + + return true; + } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Models/ProductFlat.php b/packages/Webkul/Product/src/Models/ProductFlat.php index 9d357d7fd..84cd0de03 100644 --- a/packages/Webkul/Product/src/Models/ProductFlat.php +++ b/packages/Webkul/Product/src/Models/ProductFlat.php @@ -17,4 +17,6 @@ class ProductFlat extends Model protected $table = 'product_flat'; protected $guarded = ['id', 'created_at', 'updated_at']; + + public $timestamps = false; } \ No newline at end of file From 604f9d7da54f5791703aa681369bbace2829f8e9 Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Wed, 23 Jan 2019 17:08:17 +0530 Subject: [PATCH 11/12] Product flat create and update now both implemented --- .../Http/Controllers/ProductController.php | 168 +++++++++++++++++- .../Product/src/Listeners/ProductsFlat.php | 5 +- .../Repositories/ProductGridRepository.php | 2 +- 3 files changed, 172 insertions(+), 3 deletions(-) diff --git a/packages/Webkul/Product/src/Http/Controllers/ProductController.php b/packages/Webkul/Product/src/Http/Controllers/ProductController.php index dce62c5bc..d63e03662 100755 --- a/packages/Webkul/Product/src/Http/Controllers/ProductController.php +++ b/packages/Webkul/Product/src/Http/Controllers/ProductController.php @@ -8,6 +8,8 @@ use Illuminate\Support\Facades\Event; use Webkul\Product\Http\Requests\ProductForm; use Webkul\Product\Repositories\ProductRepository as Product; use Webkul\Product\Repositories\ProductGridRepository as ProductGrid; +use Webkul\Product\Repositories\ProductFlatRepository as ProductFlat; +use Webkul\Product\Repositories\ProductAttributeValueRepository as ProductAttributeValue; use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily; use Webkul\Category\Repositories\CategoryRepository as Category; use Webkul\Inventory\Repositories\InventorySourceRepository as InventorySource; @@ -61,6 +63,8 @@ class ProductController extends Controller * @var array */ protected $productGrid; + protected $productFlat; + protected $productAttributeValue; /** * Create a new controller instance. @@ -76,7 +80,9 @@ class ProductController extends Controller Category $category, InventorySource $inventorySource, Product $product, - ProductGrid $productGrid) + ProductGrid $productGrid, + ProductFlat $productFlat, + ProductAttributeValue $productAttributeValue) { $this->attributeFamily = $attributeFamily; @@ -88,6 +94,10 @@ class ProductController extends Controller $this->productGrid = $productGrid; + $this->productFlat = $productFlat; + + $this->productAttributeValue = $productAttributeValue; + $this->_config = request('_config'); } @@ -256,4 +266,160 @@ class ProductController extends Controller return redirect()->route('admin.catalog.products.index'); } + + public function testProductFlat() { + $product = $this->product->find(2); + $productAttributes = $product->attribute_family->custom_attributes; + $allLocales = core()->getAllLocales(); + $productsFlat = array(); + $channelLocaleMap = array(); + $nonDependentAttributes = array(); + $localeDependentAttributes = array(); + $channelDependentAttributes = array(); + $channelLocaleDependentAttributes = array(); + + foreach($productAttributes as $key => $productAttribute) { + if($productAttribute->value_per_channel) { + if($productAttribute->value_per_locale) { + array_push($channelLocaleDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); + } else { + array_push($channelDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); + } + } else if($productAttribute->value_per_locale && !$productAttribute->value_per_channel) { + array_push($localeDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); + } else { + array_push($nonDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); + } + } + + foreach(core()->getAllChannels() as $channel) { + $dummy = [ + 'product_id' => $product->id, + 'channel' => $channel->code, + 'locale' => null, + 'data' => $channelDependentAttributes + ]; + + array_push($channelLocaleMap, $dummy); + + $dummy = []; + + foreach($channel->locales as $locale) { + $dummy = [ + 'product_id' => $product->id, + 'channel' => $channel->code, + 'locale' => $locale->code, + 'data' => $channelLocaleDependentAttributes + ]; + + array_push($channelLocaleMap, $dummy); + + $dummy = []; + } + } + + $dummy = [ + 'product_id' => $product->id, + 'channel' => null, + 'locale' => null, + 'data' => $nonDependentAttributes + ]; + + array_push($channelLocaleMap, $dummy); + + $dummy = []; + + foreach($allLocales as $key => $allLocale) { + $dummy = [ + 'product_id' => $product->id, + 'channel' => null, + 'locale' => $allLocale->code, + 'data' => $localeDependentAttributes + ]; + + array_push($channelLocaleMap, $dummy); + + $dummy = []; + } + + $productFlatObjects = $channelLocaleMap; + $keyOfNonDependentAttributes = null; + + foreach($productAttributes as $productAttribute) { + foreach($productFlatObjects as $flatKey => $productFlatObject) { + if($productFlatObject['channel'] == null && $productFlatObject['locale'] == null) { + $keyOfNonDependentAttributes = $flatKey; + } + + foreach($productFlatObject['data'] as $key => $value) { + if($productAttribute->code == $value['code']) { + $valueOf = $this->productAttributeValue->findOneWhere([ + 'product_id' => $product->id, + 'channel' => $productFlatObject['channel'], + 'locale' => $productFlatObject['locale'], + 'attribute_id' => $productAttribute->id + ]); + + if($valueOf != null) { + $productAttributeColumn = $this->productAttributeValue->model()::$attributeTypeFields[$productAttribute->type]; + + $valueOf = $valueOf->{$productAttributeColumn}; + + $productFlatObjects[$flatKey][$productAttribute->code] = $valueOf; + } else { + $productFlatObjects[$flatKey][$productAttribute->code] = 'null'; + } + } + } + } + } + + $nonDependentAttributes = $productFlatObjects[$keyOfNonDependentAttributes]; + + array_forget($nonDependentAttributes, ['product_id', 'channel', 'locale', 'data', 'visible_individually', 'width', 'height', 'depth']); + + unset($productFlatObjects[$keyOfNonDependentAttributes]); + + $productFlatEntryObject = array(); + + $tempFlatObject = array(); + + foreach($productFlatObjects as $flatKey => $productFlatObject) { + unset($productFlatObject['data']); + + if(isset($productFlatObject['short_description'])) { + $productFlatObject['description'] = $productFlatObject['short_description']; + + unset($productFlatObject['short_description']); + } + + if(isset($productFlatObject['meta_title'])) { + unset($productFlatObject['meta_title']); + unset($productFlatObject['meta_description']); + unset($productFlatObject['meta_keywords']); + } + + $tempFlatObject = array_merge($productFlatObject, $nonDependentAttributes); + + $tempFlatObject = core()->convertEmptyStringsToNull($tempFlatObject); + + $exists = $this->productFlat->findWhere([ + 'product_id' => $product->id, + 'channel' => $tempFlatObject['channel'], + 'locale' => $tempFlatObject['locale'] + ]); + + if($exists->count() == 0) { + $result = $this->productFlat->create($tempFlatObject); + } else { + $result = $exists->first(); + + $result->update($tempFlatObject); + } + + unset($tempFlatObject); + } + + return true; + } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Listeners/ProductsFlat.php b/packages/Webkul/Product/src/Listeners/ProductsFlat.php index 21061904d..7aac31d12 100644 --- a/packages/Webkul/Product/src/Listeners/ProductsFlat.php +++ b/packages/Webkul/Product/src/Listeners/ProductsFlat.php @@ -255,11 +255,14 @@ class ProductsFlat ]); if($exists->count() == 0) { - $result = $this->productFlat->create($tempFlatObject); + dd('this does not exists'); + // $result = $this->productFlat->create($tempFlatObject); } else { //perform update + dd('product already exists'); } + dd($productFlatObjects); unset($tempFlatObject); } diff --git a/packages/Webkul/Product/src/Repositories/ProductGridRepository.php b/packages/Webkul/Product/src/Repositories/ProductGridRepository.php index c89e73371..9a17c80e7 100755 --- a/packages/Webkul/Product/src/Repositories/ProductGridRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductGridRepository.php @@ -108,7 +108,7 @@ class ProductGridRepository extends Repository return $this->getModel()->where('product_id', $variant->id)->update($gridObject); } } - + return false; } } \ No newline at end of file From 550f26f865c0aaf0576089c1f68a60d5e737dacb Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Thu, 24 Jan 2019 10:51:36 +0530 Subject: [PATCH 12/12] product flat implemented but needs some label attributes modifications and rigorous testing --- ...dd_new_from_to_columns_in_product_flat.php | 2 - .../Http/Controllers/ProductController.php | 240 +++++++++--------- .../Product/src/Listeners/ProductsFlat.php | 17 +- .../src/Providers/EventServiceProvider.php | 5 + .../src/Repositories/ProductRepository.php | 4 +- 5 files changed, 136 insertions(+), 132 deletions(-) diff --git a/packages/Webkul/Product/src/Database/Migrations/2019_01_19_144504_add_new_from_to_columns_in_product_flat.php b/packages/Webkul/Product/src/Database/Migrations/2019_01_19_144504_add_new_from_to_columns_in_product_flat.php index f86b7d4e0..2b4f1e27f 100644 --- a/packages/Webkul/Product/src/Database/Migrations/2019_01_19_144504_add_new_from_to_columns_in_product_flat.php +++ b/packages/Webkul/Product/src/Database/Migrations/2019_01_19_144504_add_new_from_to_columns_in_product_flat.php @@ -15,7 +15,6 @@ class AddNewFromToColumnsInProductFlat extends Migration { if (Schema::hasTable('product_flat')) { Schema::table('product_flat', function (Blueprint $table) { - $table->integer('tax_category_id')->unsigned()->nullable()->after('size_label'); $table->date('new_to')->after('new'); $table->date('new_from')->after('new'); $table->unique(['product_id', 'channel', 'locale'], 'product_flat_unique_index'); @@ -32,7 +31,6 @@ class AddNewFromToColumnsInProductFlat extends Migration { if (Schema::hasTable('product_flat')) { Schema::table('product_flat', function (Blueprint $table) { - $table->dropColumn('tax_category_id')->unsigned(); $table->dropColumn('new_from'); $table->dropColumn('new_to'); $table->dropIndex('product_flat_unique_index'); diff --git a/packages/Webkul/Product/src/Http/Controllers/ProductController.php b/packages/Webkul/Product/src/Http/Controllers/ProductController.php index d63e03662..ac8989707 100755 --- a/packages/Webkul/Product/src/Http/Controllers/ProductController.php +++ b/packages/Webkul/Product/src/Http/Controllers/ProductController.php @@ -267,159 +267,159 @@ class ProductController extends Controller return redirect()->route('admin.catalog.products.index'); } - public function testProductFlat() { - $product = $this->product->find(2); - $productAttributes = $product->attribute_family->custom_attributes; - $allLocales = core()->getAllLocales(); - $productsFlat = array(); - $channelLocaleMap = array(); - $nonDependentAttributes = array(); - $localeDependentAttributes = array(); - $channelDependentAttributes = array(); - $channelLocaleDependentAttributes = array(); + // public function testProductFlat() { + // $product = $this->product->find(2); + // $productAttributes = $product->attribute_family->custom_attributes; + // $allLocales = core()->getAllLocales(); + // $productsFlat = array(); + // $channelLocaleMap = array(); + // $nonDependentAttributes = array(); + // $localeDependentAttributes = array(); + // $channelDependentAttributes = array(); + // $channelLocaleDependentAttributes = array(); - foreach($productAttributes as $key => $productAttribute) { - if($productAttribute->value_per_channel) { - if($productAttribute->value_per_locale) { - array_push($channelLocaleDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); - } else { - array_push($channelDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); - } - } else if($productAttribute->value_per_locale && !$productAttribute->value_per_channel) { - array_push($localeDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); - } else { - array_push($nonDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); - } - } + // foreach($productAttributes as $key => $productAttribute) { + // if($productAttribute->value_per_channel) { + // if($productAttribute->value_per_locale) { + // array_push($channelLocaleDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); + // } else { + // array_push($channelDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); + // } + // } else if($productAttribute->value_per_locale && !$productAttribute->value_per_channel) { + // array_push($localeDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); + // } else { + // array_push($nonDependentAttributes, ['id' => $productAttribute->id, 'code' => $productAttribute->code]); + // } + // } - foreach(core()->getAllChannels() as $channel) { - $dummy = [ - 'product_id' => $product->id, - 'channel' => $channel->code, - 'locale' => null, - 'data' => $channelDependentAttributes - ]; + // foreach(core()->getAllChannels() as $channel) { + // $dummy = [ + // 'product_id' => $product->id, + // 'channel' => $channel->code, + // 'locale' => null, + // 'data' => $channelDependentAttributes + // ]; - array_push($channelLocaleMap, $dummy); + // array_push($channelLocaleMap, $dummy); - $dummy = []; + // $dummy = []; - foreach($channel->locales as $locale) { - $dummy = [ - 'product_id' => $product->id, - 'channel' => $channel->code, - 'locale' => $locale->code, - 'data' => $channelLocaleDependentAttributes - ]; + // foreach($channel->locales as $locale) { + // $dummy = [ + // 'product_id' => $product->id, + // 'channel' => $channel->code, + // 'locale' => $locale->code, + // 'data' => $channelLocaleDependentAttributes + // ]; - array_push($channelLocaleMap, $dummy); + // array_push($channelLocaleMap, $dummy); - $dummy = []; - } - } + // $dummy = []; + // } + // } - $dummy = [ - 'product_id' => $product->id, - 'channel' => null, - 'locale' => null, - 'data' => $nonDependentAttributes - ]; + // $dummy = [ + // 'product_id' => $product->id, + // 'channel' => null, + // 'locale' => null, + // 'data' => $nonDependentAttributes + // ]; - array_push($channelLocaleMap, $dummy); + // array_push($channelLocaleMap, $dummy); - $dummy = []; + // $dummy = []; - foreach($allLocales as $key => $allLocale) { - $dummy = [ - 'product_id' => $product->id, - 'channel' => null, - 'locale' => $allLocale->code, - 'data' => $localeDependentAttributes - ]; + // foreach($allLocales as $key => $allLocale) { + // $dummy = [ + // 'product_id' => $product->id, + // 'channel' => null, + // 'locale' => $allLocale->code, + // 'data' => $localeDependentAttributes + // ]; - array_push($channelLocaleMap, $dummy); + // array_push($channelLocaleMap, $dummy); - $dummy = []; - } + // $dummy = []; + // } - $productFlatObjects = $channelLocaleMap; - $keyOfNonDependentAttributes = null; + // $productFlatObjects = $channelLocaleMap; + // $keyOfNonDependentAttributes = null; - foreach($productAttributes as $productAttribute) { - foreach($productFlatObjects as $flatKey => $productFlatObject) { - if($productFlatObject['channel'] == null && $productFlatObject['locale'] == null) { - $keyOfNonDependentAttributes = $flatKey; - } + // foreach($productAttributes as $productAttribute) { + // foreach($productFlatObjects as $flatKey => $productFlatObject) { + // if($productFlatObject['channel'] == null && $productFlatObject['locale'] == null) { + // $keyOfNonDependentAttributes = $flatKey; + // } - foreach($productFlatObject['data'] as $key => $value) { - if($productAttribute->code == $value['code']) { - $valueOf = $this->productAttributeValue->findOneWhere([ - 'product_id' => $product->id, - 'channel' => $productFlatObject['channel'], - 'locale' => $productFlatObject['locale'], - 'attribute_id' => $productAttribute->id - ]); + // foreach($productFlatObject['data'] as $key => $value) { + // if($productAttribute->code == $value['code']) { + // $valueOf = $this->productAttributeValue->findOneWhere([ + // 'product_id' => $product->id, + // 'channel' => $productFlatObject['channel'], + // 'locale' => $productFlatObject['locale'], + // 'attribute_id' => $productAttribute->id + // ]); - if($valueOf != null) { - $productAttributeColumn = $this->productAttributeValue->model()::$attributeTypeFields[$productAttribute->type]; + // if($valueOf != null) { + // $productAttributeColumn = $this->productAttributeValue->model()::$attributeTypeFields[$productAttribute->type]; - $valueOf = $valueOf->{$productAttributeColumn}; + // $valueOf = $valueOf->{$productAttributeColumn}; - $productFlatObjects[$flatKey][$productAttribute->code] = $valueOf; - } else { - $productFlatObjects[$flatKey][$productAttribute->code] = 'null'; - } - } - } - } - } + // $productFlatObjects[$flatKey][$productAttribute->code] = $valueOf; + // } else { + // $productFlatObjects[$flatKey][$productAttribute->code] = 'null'; + // } + // } + // } + // } + // } - $nonDependentAttributes = $productFlatObjects[$keyOfNonDependentAttributes]; + // $nonDependentAttributes = $productFlatObjects[$keyOfNonDependentAttributes]; - array_forget($nonDependentAttributes, ['product_id', 'channel', 'locale', 'data', 'visible_individually', 'width', 'height', 'depth']); + // array_forget($nonDependentAttributes, ['product_id', 'channel', 'locale', 'data', 'visible_individually', 'width', 'height', 'depth']); - unset($productFlatObjects[$keyOfNonDependentAttributes]); + // unset($productFlatObjects[$keyOfNonDependentAttributes]); - $productFlatEntryObject = array(); + // $productFlatEntryObject = array(); - $tempFlatObject = array(); + // $tempFlatObject = array(); - foreach($productFlatObjects as $flatKey => $productFlatObject) { - unset($productFlatObject['data']); + // foreach($productFlatObjects as $flatKey => $productFlatObject) { + // unset($productFlatObject['data']); - if(isset($productFlatObject['short_description'])) { - $productFlatObject['description'] = $productFlatObject['short_description']; + // if(isset($productFlatObject['short_description'])) { + // $productFlatObject['description'] = $productFlatObject['short_description']; - unset($productFlatObject['short_description']); - } + // unset($productFlatObject['short_description']); + // } - if(isset($productFlatObject['meta_title'])) { - unset($productFlatObject['meta_title']); - unset($productFlatObject['meta_description']); - unset($productFlatObject['meta_keywords']); - } + // if(isset($productFlatObject['meta_title'])) { + // unset($productFlatObject['meta_title']); + // unset($productFlatObject['meta_description']); + // unset($productFlatObject['meta_keywords']); + // } - $tempFlatObject = array_merge($productFlatObject, $nonDependentAttributes); + // $tempFlatObject = array_merge($productFlatObject, $nonDependentAttributes); - $tempFlatObject = core()->convertEmptyStringsToNull($tempFlatObject); + // $tempFlatObject = core()->convertEmptyStringsToNull($tempFlatObject); - $exists = $this->productFlat->findWhere([ - 'product_id' => $product->id, - 'channel' => $tempFlatObject['channel'], - 'locale' => $tempFlatObject['locale'] - ]); + // $exists = $this->productFlat->findWhere([ + // 'product_id' => $product->id, + // 'channel' => $tempFlatObject['channel'], + // 'locale' => $tempFlatObject['locale'] + // ]); - if($exists->count() == 0) { - $result = $this->productFlat->create($tempFlatObject); - } else { - $result = $exists->first(); + // if($exists->count() == 0) { + // $result = $this->productFlat->create($tempFlatObject); + // } else { + // $result = $exists->first(); - $result->update($tempFlatObject); - } + // $result->update($tempFlatObject); + // } - unset($tempFlatObject); - } + // unset($tempFlatObject); + // } - return true; - } + // return 'true'; + // } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Listeners/ProductsFlat.php b/packages/Webkul/Product/src/Listeners/ProductsFlat.php index 7aac31d12..aa8e554cb 100644 --- a/packages/Webkul/Product/src/Listeners/ProductsFlat.php +++ b/packages/Webkul/Product/src/Listeners/ProductsFlat.php @@ -112,8 +112,8 @@ class ProductsFlat } } - public function afterProductCreated($Product) { - $product = $Product; + public function afterProductCreatedOrUpdated($ProductFlat) { + $product = $ProductFlat; $productAttributes = $product->attribute_family->custom_attributes; $allLocales = core()->getAllLocales(); $productsFlat = array(); @@ -221,7 +221,7 @@ class ProductsFlat $nonDependentAttributes = $productFlatObjects[$keyOfNonDependentAttributes]; - array_forget($nonDependentAttributes, ['product_id', 'channel', 'locale', 'data', 'visible_individually', 'width', 'height', 'depth']); + array_forget($nonDependentAttributes, ['product_id', 'channel', 'locale', 'data', 'visible_individually', 'width', 'height', 'depth', 'tax_category_id']); unset($productFlatObjects[$keyOfNonDependentAttributes]); @@ -255,17 +255,16 @@ class ProductsFlat ]); if($exists->count() == 0) { - dd('this does not exists'); - // $result = $this->productFlat->create($tempFlatObject); + $result = $this->productFlat->create($tempFlatObject); } else { - //perform update - dd('product already exists'); + $result = $exists->first(); + + $result->update($tempFlatObject); } - dd($productFlatObjects); unset($tempFlatObject); } - return true; + return 'true'; } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Providers/EventServiceProvider.php b/packages/Webkul/Product/src/Providers/EventServiceProvider.php index ae1527f46..c0eddc2b3 100644 --- a/packages/Webkul/Product/src/Providers/EventServiceProvider.php +++ b/packages/Webkul/Product/src/Providers/EventServiceProvider.php @@ -19,5 +19,10 @@ class EventServiceProvider extends ServiceProvider Event::listen('after.attribute.created', 'Webkul\Product\Listeners\ProductsFlat@afterAttributeCreated'); Event::listen('after.attribute.deleted', 'Webkul\Product\Listeners\ProductsFlat@afterAttributeDeleted'); + + Event::listen('after.product.created', 'Webkul\Product\Listeners\ProductsFlat@afterProductCreatedOrUpdated'); + + Event::listen('after.product.updated', 'Webkul\Product\Listeners\ProductsFlat@afterProductCreatedOrUpdated'); + } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Repositories/ProductRepository.php b/packages/Webkul/Product/src/Repositories/ProductRepository.php index f9a0b5d94..d386d7105 100755 --- a/packages/Webkul/Product/src/Repositories/ProductRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductRepository.php @@ -144,7 +144,6 @@ class ProductRepository extends Repository //after store of the product Event::fire('catalog.product.create.after', $product); - return $product; } @@ -233,6 +232,9 @@ class ProductRepository extends Repository Event::fire('catalog.product.update.after', $product); + //correct it after making sure which event to use. + Event::fire('after.product.updated', $product); + return $product; }