diff --git a/CHANGELOG for v1.3.x.md b/CHANGELOG for v1.3.x.md deleted file mode 100755 index 217ae37..0000000 --- a/CHANGELOG for v1.3.x.md +++ /dev/null @@ -1,7 +0,0 @@ -# CHANGELOG for v1.x.x - -#### This changelog consists the bug & security fixes and new features being included in the releases listed below. - -## **v1.3.3(10th of Jan, 2022)** - *Release* - -* [compatible] compatible with bagisto v1.3.3 diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..f6a834c --- /dev/null +++ b/changelog.md @@ -0,0 +1,46 @@ +# CHANGELOG for v1.5.x + +#### This changelog consists the bug & security fixes and new features being included in the releases listed below. + +## **v1.5.1(8th of May, 2023)** - *Release* + +* [feature] compatible with bagisto v1.5.1 + +* [feature] Now admin can set time format for customers. + +* [feature] Mail should be send to the customer with delivery time slot details + +* [feature] Status - Enable/Disable column on delivery time slots + +* [feature] Status - Want to delete confirmation popup required Yes/No before delete + +* [bug] Colour should be same on all the radio buttons[blue colour] + +* [bug] Filter not working on Delivery Order Section + +* [bug] Display time format 12/24 hrs not working + +* [bug] Need to alert message that delivery time slot not available for virtual/downloadable/booking product + +* [bug] Unable to open the Invoice of Order in Admin Panel + +* [bug] Display time format not reflected in Order [Admin Panel] + +* [bug] Delivery time slots is not showing proper in mobile view [RTL Locale] + + +## **v1.4.5(14th of April, 2023)** - *Release* + +* [feature] compatible with bagisto v1.4.5 + +## **v1.4.3(19th of Jul, 2022)** - *Release* + +* [feature] compatible with bagisto v1.4.3 + +## **v1.3.3(1st of Nov, 2021)** - *Release* + +* [feature] compatible with bagisto v1.3.3 + +## **v1.3.2(7th of Oct, 2021)** - *Release* + +* [feature] compatible with bagisto v1.3.2 diff --git a/publishable/assets/css/delivery-time-slot-admin.css b/publishable/assets/css/delivery-time-slot-admin.css index 0106405..032ef11 100644 --- a/publishable/assets/css/delivery-time-slot-admin.css +++ b/publishable/assets/css/delivery-time-slot-admin.css @@ -1 +1 @@ -.time-slot-icon{width:48px;height:48px;display:inline-block;background-size:cover;background-image:url(../images/Icon-PWA.svg)}.active.time-slot-icon,.active .time-slot-icon{background-image:url(../images/Icon-PWA-Active.svg)}.navbar-left{width:100px}.navbar-left ul.menubar li.menu-item{padding:10px 7px}.content-container{padding-left:100px}@media (min-width:768px){.order-status{margin-top:6px;padding:5px 10px}}.order-status{border:3px solid #ccc;border-radius:3px;display:inline-block;margin:15px 0 0;padding:2px 10px;text-transform:uppercase;vertical-align:top} \ No newline at end of file +.time-slot-icon{width:48px;height:48px;display:inline-block;background-size:cover;background-image:url(../images/Icon-PWA.svg)}.active.time-slot-icon,.active .time-slot-icon{background-image:url(../images/Icon-PWA-Active.svg)}.content-container{padding-left:100px}@media (min-width:768px){.order-status{margin-top:6px;padding:5px 10px}}.order-status{border:3px solid #ccc;border-radius:3px;display:inline-block;margin:15px 0 0;padding:2px 10px;text-transform:uppercase;vertical-align:top} \ No newline at end of file diff --git a/publishable/assets/css/delivery-time-slot.css b/publishable/assets/css/delivery-time-slot.css index 3ba05de..afcdfad 100644 --- a/publishable/assets/css/delivery-time-slot.css +++ b/publishable/assets/css/delivery-time-slot.css @@ -1 +1 @@ -.time-slot-icon{width:48px;height:48px;display:inline-block;background-size:cover;background-image:url(../images/Icon-PWA.svg)}.active.time-slot-icon,.active .time-slot-icon{background-image:url(../images/Icon-PWA-Active.svg)}.radio-boxed label{display:inline-block;width:187px;background-color:#e6e6e6;padding:10px;border:2px solid #ccc;transition:all .3s;cursor:pointer}.radio-boxed input[type=radio]{display:none}.radio-boxed input[type=radio]:checked+label{border:2px solid grey;color:#fff;cursor:pointer;background-color:grey}.radio-boxed td:last-of-type{border-right:none;border-bottom:none}.radio-boxed td{border-right:1px solid #c7c7c7;vertical-align:middle!important}.radio-boxed table tbody td{padding:15px;color:#3a3a3a;vertical-align:middle;height:5pc;overflow-x:auto!important}.timeslot-td{display:grid;grid-template-columns:auto auto auto;float:left}.radio-boxed tr{border-bottom:1px solid #c7c7c7}.radio-boxed tr:last-of-type{border-bottom:none}.timeslot-td span{margin-right:3px;margin-top:5px}.seller-name{text-align:center;padding:2%;box-shadow:0 4px 8px 0 rgba(0,0,0,.2),0 6px 20px 0 transparent;-moz-box-shadow:0 4px 8px 0 rgba(0,0,0,.2),0 6px 20px 0 rgba(0,0,0,.19);font-weight:700;display:inline-block;text-transform:capitalize;margin:10px 0}@media (min-width:768px){.order-status{margin-top:6px;padding:5px 10px}}.order-status{border:3px solid #ccc;border-radius:3px;display:inline-block;margin:15px 0 0;padding:2px 10px;text-transform:uppercase;vertical-align:top}.message{border:2px solid red;text-align:center} \ No newline at end of file +.time-slot-icon{width:48px;height:48px;display:inline-block;background-size:cover;background-image:url(../images/Icon-PWA.svg)}.active.time-slot-icon,.active .time-slot-icon{background-image:url(../images/Icon-PWA-Active.svg)}.radio-boxed label{display:inline-block;width:187px;background-color:#e6e6e6;padding:10px;border:2px solid #ccc;transition:all .3s;cursor:pointer}.radio-boxed input[type=radio]{display:none}.radio-boxed input[type=radio]:checked+label{border:2px solid grey;color:#fff;cursor:pointer;background-color:grey}.radio-boxed td:last-of-type{border-right:none;border-bottom:none}.radio-boxed td{border-right:1px solid #c7c7c7;vertical-align:middle!important}.radio-boxed table tbody td{padding:15px;color:#3a3a3a;vertical-align:middle;height:5pc;overflow-x:auto!important}.timeslot-td{display:grid;grid-template-columns:auto auto auto;float:left;background-color:#0ff}.radio-boxed tr{border-bottom:1px solid #c7c7c7}.radio-boxed tr:last-of-type{border-bottom:none}.timeslot-td span{margin-right:3px;margin-top:5px}.seller-name{text-align:center;padding:2%;box-shadow:0 4px 8px 0 rgba(0,0,0,.2),0 6px 20px 0 transparent;-moz-box-shadow:0 4px 8px 0 rgba(0,0,0,.2),0 6px 20px 0 rgba(0,0,0,.19);font-weight:700;display:inline-block;text-transform:capitalize;margin:10px 0}@media (min-width:768px){.order-status{margin-top:6px;padding:5px 10px}}.order-status{border:3px solid #ccc;border-radius:3px;display:inline-block;margin:15px 0 0;padding:2px 10px;text-transform:uppercase;vertical-align:top}.message{border:2px solid red;text-align:center} \ No newline at end of file diff --git a/publishable/assets/js/delivery-time-slot.js b/publishable/assets/js/delivery-time-slot.js index cd54958..7911fae 100644 --- a/publishable/assets/js/delivery-time-slot.js +++ b/publishable/assets/js/delivery-time-slot.js @@ -1 +1 @@ -!function(t){var e={};function r(n){if(e[n])return e[n].exports;var a=e[n]={i:n,l:!1,exports:{}};return t[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)r.d(n,a,function(e){return t[e]}.bind(null,a));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="/",r(r.s=0)}({0:function(t,e,r){r("uPOf"),r("w/dW"),t.exports=r("y62a")},"9tPo":function(t,e){t.exports=function(t){var e="undefined"!=typeof window&&window.location;if(!e)throw new Error("fixUrls requires window.location");if(!t||"string"!=typeof t)return t;var r=e.protocol+"//"+e.host,n=r+e.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,(function(t,e){var a,i=e.trim().replace(/^"(.*)"$/,(function(t,e){return e})).replace(/^'(.*)'$/,(function(t,e){return e}));return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(i)?t:(a=0===i.indexOf("//")?i:0===i.indexOf("/")?r+i:n+i.replace(/^\.\//,""),"url("+JSON.stringify(a)+")")}))}},CVKz:function(t,e,r){var n=r("cybi");"string"==typeof n&&(n=[[t.i,n,""]]);var a={hmr:!0,transform:void 0,insertInto:void 0};r("aET+")(n,a);n.locals&&(t.exports=n.locals)},I1BE:function(t,e){t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var r=function(t,e){var r=t[1]||"",n=t[3];if(!n)return r;if(e&&"function"==typeof btoa){var a=(o=n,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */"),i=n.sources.map((function(t){return"/*# sourceURL="+n.sourceRoot+t+" */"}));return[r].concat(i).concat([a]).join("\n")}var o;return[r].join("\n")}(e,t);return e[2]?"@media "+e[2]+"{"+r+"}":r})).join("")},e.i=function(t,r){"string"==typeof t&&(t=[[null,t,""]]);for(var n={},a=0;a=0&&f.splice(e,1)}function m(t){var e=document.createElement("style");if(void 0===t.attrs.type&&(t.attrs.type="text/css"),void 0===t.attrs.nonce){var n=function(){0;return r.nc}();n&&(t.attrs.nonce=n)}return x(e,t.attrs),b(t,e),e}function x(t,e){Object.keys(e).forEach((function(r){t.setAttribute(r,e[r])}))}function g(t,e){var r,n,a,i;if(e.transform&&t.css){if(!(i="function"==typeof e.transform?e.transform(t.css):e.transform.default(t.css)))return function(){};t.css=i}if(e.singleton){var o=s++;r=c||(c=m(e)),n=v.bind(null,r,o,!1),a=v.bind(null,r,o,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(r=function(t){var e=document.createElement("link");return void 0===t.attrs.type&&(t.attrs.type="text/css"),t.attrs.rel="stylesheet",x(e,t.attrs),b(t,e),e}(e),n=I.bind(null,r,e),a=function(){k(r),r.href&&URL.revokeObjectURL(r.href)}):(r=m(e),n=R.bind(null,r),a=function(){k(r)});return n(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;n(t=e)}else a()}}t.exports=function(t,e){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(e=e||{}).attrs="object"==typeof e.attrs?e.attrs:{},e.singleton||"boolean"==typeof e.singleton||(e.singleton=o()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var r=h(t,e);return u(r,e),function(t){for(var n=[],a=0;a=0&&f.splice(e,1)}function m(t){var e=document.createElement("style");if(void 0===t.attrs.type&&(t.attrs.type="text/css"),void 0===t.attrs.nonce){var n=function(){0;return r.nc}();n&&(t.attrs.nonce=n)}return x(e,t.attrs),b(t,e),e}function x(t,e){Object.keys(e).forEach((function(r){t.setAttribute(r,e[r])}))}function g(t,e){var r,n,a,i;if(e.transform&&t.css){if(!(i="function"==typeof e.transform?e.transform(t.css):e.transform.default(t.css)))return function(){};t.css=i}if(e.singleton){var o=s++;r=c||(c=m(e)),n=v.bind(null,r,o,!1),a=v.bind(null,r,o,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(r=function(t){var e=document.createElement("link");return void 0===t.attrs.type&&(t.attrs.type="text/css"),t.attrs.rel="stylesheet",x(e,t.attrs),b(t,e),e}(e),n=I.bind(null,r,e),a=function(){k(r),r.href&&URL.revokeObjectURL(r.href)}):(r=m(e),n=R.bind(null,r),a=function(){k(r)});return n(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;n(t=e)}else a()}}t.exports=function(t,e){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(e=e||{}).attrs="object"==typeof e.attrs?e.attrs:{},e.singleton||"boolean"==typeof e.singleton||(e.singleton=o()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var r=h(t,e);return u(r,e),function(t){for(var n=[],a=0;a Press the number before DeliveryTimeSlotServiceProvider and then press enter to publish all assets and configurations. + +-> Press the number before "Webkul\DeliveryTimeSlot\Providers\DeliveryTimeSlotServiceProvider" and then press enter to publish all assets and configurations. +~~~ > That's it, now just execute the project on your specified domain. diff --git a/src/Config/system.php b/src/Config/system.php index 9050c87..7598fe5 100644 --- a/src/Config/system.php +++ b/src/Config/system.php @@ -1,6 +1,5 @@ 'delivery_time_slot', @@ -28,18 +27,41 @@ 'locale_based' => true, 'channel_based' => false, 'repository' => 'Webkul\DeliveryTimeSlot\Repositories\DeliveryTimeSlotsRepository@selectDays' - ], [ + ], [ 'name' => 'total_days', 'title' => 'delivery-time-slot::app.admin.system.display-total-days', 'type' => 'text', - 'validation' => 'numeric', + 'validation' => 'required|numeric|between:1,7', 'locale_based' => true, 'channel_based' => false, 'info' => 'Enter number of days, e.g: 7' - ],[ + ], [ + 'name' => 'display_time_format', + 'title' => 'delivery-time-slot::app.admin.system.display-time-format', + 'type' => 'select', + 'validation' => 'required|numeric|included:12,24', + 'locale_based' => true, + 'channel_based' => false, + 'options' => [ + [ + 'title' => '24 Hour', + 'value' => '24' + ], [ + 'title' => '12 Hour', + 'value' => '12' + ], + ] + ], [ + 'name' => 'show_message', + 'title' => 'delivery-time-slot::app.admin.system.show-message', + 'type' => 'boolean', + 'locale_based' => true, + 'channel_based' => false, + ], [ 'name' => 'time_slot_error_message', 'title' => 'delivery-time-slot::app.admin.system.error-message', 'type' => 'textarea', + 'validation' => 'max:150', 'channel_based' => true, 'locale_based' => true ] diff --git a/src/DataGrids/Admin/DeliveyOrdersDataGrid.php b/src/DataGrids/Admin/DeliveyOrdersDataGrid.php index 80f4303..5c6643e 100644 --- a/src/DataGrids/Admin/DeliveyOrdersDataGrid.php +++ b/src/DataGrids/Admin/DeliveyOrdersDataGrid.php @@ -3,7 +3,8 @@ namespace Webkul\DeliveryTimeSlot\DataGrids\Admin; use Webkul\Ui\DataGrid\DataGrid; -use DB; +use Webkul\Sales\Models\OrderAddress; +use Illuminate\Support\Facades\DB; class DeliveyOrdersDataGrid extends DataGrid { @@ -16,14 +17,25 @@ public function prepareQueryBuilder() $queryBuilder = DB::table('delivery_time_slots_orders') ->leftJoin('orders', 'orders.id', '=', 'delivery_time_slots_orders.order_id') ->leftJoin('delivery_time_slots', 'delivery_time_slots.id', '=', 'delivery_time_slots_orders.time_slot_id') - ->leftJoin('customers', 'delivery_time_slots_orders.customer_id', '=', 'customers.id') - - ->select(DB::raw('CONCAT(customers.first_name, " ", customers.last_name) as customer_name'), 'delivery_time_slots_orders.delivery_date', 'delivery_time_slots_orders.order_id as delivery_order_id', 'delivery_time_slots.start_time as delivery_time_from', 'delivery_time_slots.end_time as delivery_time_to', 'delivery_time_slots_orders.id' , 'delivery_time_slots_orders.customer_id'); + ->leftJoin('addresses as order_address_shipping', function ($leftJoin) { + $leftJoin->on('order_address_shipping.order_id', '=', 'orders.id') + ->where('order_address_shipping.address_type', OrderAddress::ADDRESS_TYPE_SHIPPING); + }) + ->leftJoin('addresses as order_address_billing', function ($leftJoin) { + $leftJoin->on('order_address_billing.order_id', '=', 'orders.id') + ->where('order_address_billing.address_type', OrderAddress::ADDRESS_TYPE_BILLING); + }) + + ->select(DB::raw('CONCAT(customers.first_name, " ", customers.last_name) as customer_name'), 'delivery_time_slots_orders.delivery_date', 'delivery_time_slots_orders.order_id as delivery_order_id', 'delivery_time_slots.start_time as delivery_time_from', 'delivery_time_slots.end_time as delivery_time_to', 'delivery_time_slots_orders.id' , 'delivery_time_slots_orders.customer_id') + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name) as billed_to')) + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_shipping.first_name, " ", ' . DB::getTablePrefix() . 'order_address_shipping.last_name) as shipped_to')); $this->addFilter('delivery_date', 'delivery_time_slots_orders.delivery_date'); $this->addFilter('delivery_order_id', 'delivery_time_slots_orders.order_id'); $this->addFilter('customer_name', DB::raw('CONCAT(customers.first_name, " ", customers.last_name)')); + $this->addFilter('billed_to', DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name)')); + $this->addFilter('shipped_to', DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_shipping.first_name, " ", ' . DB::getTablePrefix() . 'order_address_shipping.last_name)')); $this->setQueryBuilder($queryBuilder); } @@ -36,26 +48,43 @@ public function addColumns() 'type' => 'string', 'searchable' => true, 'sortable' => true, - 'filterable' => true, - 'wrapper' => function ($data) { - if ( is_null($data->customer_name)) + 'filterable' => false, + 'closure' => function ($data) { + if (is_null($data->customer_name)) { return 'Guest'; - else - echo '' . ucwords($data->customer_name) . ''; + } + + return '' . ucwords($data->customer_name) . ''; } ]); + $this->addColumn([ + 'index' => 'billed_to', + 'label' => trans('admin::app.datagrid.billed-to'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'shipped_to', + 'label' => trans('admin::app.datagrid.shipped-to'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + ]); + $this->addColumn([ 'index' => 'delivery_date', 'label' => trans('delivery-time-slot::app.admin.datagrid.delivery-date'), 'type' => 'datetime', - 'searchable' => false, + 'searchable' => true, 'sortable' => true, 'filterable' => true, 'wrapper' => function ($data) { - $string = \explode(',' ,$data->delivery_date); - - return "{$string[1]}, {$string[2]}"; + return date('d F Y', strtotime($data->delivery_date)); } ]); @@ -66,8 +95,8 @@ public function addColumns() 'searchable' => true, 'sortable' => true, 'filterable' => true, - 'wrapper' => function ($data) { - echo '' . '#'.$data->delivery_order_id . ''; + 'closure' => function ($data) { + return '' . '#'.$data->delivery_order_id . ''; } ]); @@ -78,9 +107,12 @@ public function addColumns() 'sortable' => true, 'searchable' => false, 'filterable' => false, - 'wrapper' => function($data) { - $deliveryTimeFrom = date("g:i a", strtotime("{$data->delivery_time_from}")); - return strtoupper($deliveryTimeFrom); + 'wrapper' => function ($data) { + if (core()->getConfigData('delivery_time_slot.settings.general.display_time_format') == 12) { + return date('h:i A', strtotime($data->delivery_time_from)); + } + + return $data->delivery_time_from; } ]); @@ -91,9 +123,12 @@ public function addColumns() 'sortable' => true, 'searchable' => false, 'filterable' => false, - 'wrapper' => function($data) { - $deliveryTimeTo = date("g:i a", strtotime("{$data->delivery_time_to}")); - return strtoupper($deliveryTimeTo); + 'wrapper' => function ($data) { + if (core()->getConfigData('delivery_time_slot.settings.general.display_time_format') == 12) { + return date('h:i A', strtotime($data->delivery_time_to)); + } + + return $data->delivery_time_to; } ]); } diff --git a/src/DataGrids/Admin/DeliveyTimeSlotsDataGrid.php b/src/DataGrids/Admin/DeliveyTimeSlotsDataGrid.php index 650be40..418ba84 100644 --- a/src/DataGrids/Admin/DeliveyTimeSlotsDataGrid.php +++ b/src/DataGrids/Admin/DeliveyTimeSlotsDataGrid.php @@ -3,7 +3,7 @@ namespace Webkul\DeliveryTimeSlot\DataGrids\Admin; use Webkul\Ui\DataGrid\DataGrid; -use DB; +use Illuminate\Support\Facades\DB; class DeliveyTimeSlotsDataGrid extends DataGrid { @@ -29,39 +29,47 @@ public function prepareQueryBuilder() public function addColumns() { - // $this->addColumn([ - // 'index' => 'customer_name', - // 'label' => trans('delivery-time-slot::app.admin.datagrid.seller-name'), - // 'type' => 'string', - // 'searchable' => true, - // 'sortable' => true, - // 'filterable' => true, - // // 'wrapper' => 'Admin' - // ]); + $this->addColumn([ + 'index' => 'delivery_day', + 'label' => trans('delivery-time-slot::app.admin.datagrid.delivery-day'), + 'type' => 'string', + 'sortable' => false, + 'searchable' => true, + 'filterable' => true, + 'wrapper' => function ($data) { + return ucwords($data->delivery_day); + } + ]); $this->addColumn([ - 'index' => 'end_time', - 'label' => trans('delivery-time-slot::app.admin.datagrid.end-time'), - 'type' => 'datetime', + 'index' => 'start_time', + 'label' => trans('delivery-time-slot::app.admin.datagrid.start-time'), + 'type' => 'string', 'searchable' => true, 'sortable' => true, 'filterable' => false, - 'wrapper' => function($data) { - $endTime = date("g:i a", strtotime("{$data->end_time}")); - return strtoupper($endTime); + 'wrapper' => function ($data) { + if (core()->getConfigData('delivery_time_slot.settings.general.display_time_format') == 12) { + return date('h:i A', strtotime($data->start_time)); + } + + return $data->start_time; } ]); $this->addColumn([ - 'index' => 'start_time', - 'label' => trans('delivery-time-slot::app.admin.datagrid.start-time'), - 'type' => 'integer', + 'index' => 'end_time', + 'label' => trans('delivery-time-slot::app.admin.datagrid.end-time'), + 'type' => 'string', 'searchable' => true, 'sortable' => true, 'filterable' => false, - 'wrapper' => function($data) { - $startTime = date("g:i a", strtotime("{$data->start_time}")); - return strtoupper($startTime); + 'wrapper' => function ($data) { + if (core()->getConfigData('delivery_time_slot.settings.general.display_time_format') == 12) { + return date('h:i A', strtotime($data->end_time)); + } + + return $data->end_time; } ]); @@ -73,30 +81,5 @@ public function addColumns() 'searchable' => false, 'filterable' => true ]); - - $this->addColumn([ - 'index' => 'delivery_day', - 'label' => trans('delivery-time-slot::app.admin.datagrid.delivery-day'), - 'type' => 'string', - 'sortable' => true, - 'searchable' => false, - 'filterable' => true, - 'wrapper' => function ($data) { - return ucwords($data->delivery_day); - } - ]); - - // $this->addColumn([ - // 'index' => 'transaction_agent_id', - // 'label' => trans('delivery-time-slot::app.admin.datagrid.action'), - // 'type' => 'string', - // 'searchable' => false, - // 'sortable' => false, - // 'closure' => true, - // 'wrapper' => function($row) { - // return '' .'Order'. ''; - // } - // ]); - } } \ No newline at end of file diff --git a/src/DataGrids/Shop/OrderDataGrid.php b/src/DataGrids/Shop/OrderDataGrid.php index 02569f8..9c73582 100644 --- a/src/DataGrids/Shop/OrderDataGrid.php +++ b/src/DataGrids/Shop/OrderDataGrid.php @@ -58,6 +58,13 @@ public function addColumns() 'searchable' => true, 'sortable' => true, 'filterable' => true, + 'wrapper' => function ($data) { + if (core()->getConfigData('delivery_time_slot.settings.general.display_time_format') == 12) { + return date('Y-m-d h:i:s A', strtotime($data->created_at)); + } + + return $data->created_at; + } ]); $this->addColumn([ @@ -91,7 +98,7 @@ public function addColumns() return '' . trans('shop::app.customer.account.order.index.pending') . ''; } elseif ($value->status == "pending_payment") { return '' . trans('shop::app.customer.account.order.index.pending-payment') . ''; - } elseif ($value->status == "fraud") { + } elseif ($value->status == "fraud") { return '' . trans('shop::app.customer.account.order.index.fraud') . ''; } }, diff --git a/src/Database/Migrations/2020_01_30_001255_create_delivery_time_slots_orders_table.php b/src/Database/Migrations/2020_01_30_001255_create_delivery_time_slots_orders_table.php index 5a42e4c..afe63f4 100644 --- a/src/Database/Migrations/2020_01_30_001255_create_delivery_time_slots_orders_table.php +++ b/src/Database/Migrations/2020_01_30_001255_create_delivery_time_slots_orders_table.php @@ -15,14 +15,11 @@ public function up() { Schema::create('delivery_time_slots_orders', function (Blueprint $table) { $table->increments('id'); - $table->integer('time_slot_id')->nullable()->unsigned(); $table->foreign('time_slot_id')->references('id')->on('delivery_time_slots')->onDelete('cascade'); - $table->string('delivery_date')->nullable(); - + $table->date('delivery_date')->nullable(); $table->integer('customer_id')->nullable()->unsigned(); $table->foreign('customer_id')->references('id')->on('customers')->onDelete('cascade'); - $table->integer('order_id')->nullable()->unsigned(); $table->foreign('order_id')->references('id')->on('orders')->onDelete('cascade'); $table->timestamps(); diff --git a/src/Database/Migrations/2023_05_31_120555_alter_delivery_time_slots_table.php b/src/Database/Migrations/2023_05_31_120555_alter_delivery_time_slots_table.php new file mode 100644 index 0000000..53b137a --- /dev/null +++ b/src/Database/Migrations/2023_05_31_120555_alter_delivery_time_slots_table.php @@ -0,0 +1,28 @@ +boolean('visibility')->after('status'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('delivery_time_slots', function (Blueprint $table) { + $table->dropColumn('visibility'); + }); + } +}; diff --git a/src/Http/Controllers/Admin/Sales/InvoiceController.php b/src/Http/Controllers/Admin/Sales/InvoiceController.php index b115ccd..a5f34d8 100644 --- a/src/Http/Controllers/Admin/Sales/InvoiceController.php +++ b/src/Http/Controllers/Admin/Sales/InvoiceController.php @@ -78,11 +78,11 @@ public function create($orderId) abort(404); } - if ( core()->getConfigData('delivery_time_slot.settings.general.status') ) { + if (core()->getConfigData('delivery_time_slot.settings.general.status')) { $deliveryTimeSlot = $this->deliveryTimeSlotsOrdersRepository->findOneByField('order_id', $orderId); $timeSlotData = []; - if ( $deliveryTimeSlot ) { + if ($deliveryTimeSlot) { foreach ($order->items as $key => $item) { if ($item->type == 'configurable') { $item = $item->child; @@ -93,7 +93,7 @@ public function create($orderId) 'customer_id' => $order->customer_id ]); - if ( $deliveryTimeSlot ) { + if ($deliveryTimeSlot) { $this->orderSlots->push([ 'items' => [$item], 'timeOrderSlot' => $deliveryTimeSlot @@ -122,11 +122,11 @@ public function view($id) $invoice = $this->invoiceRepository->findOrFail($id); $orderId = $invoice->order_id; - if ( core()->getConfigData('delivery_time_slot.settings.general.status') ) { + if (core()->getConfigData('delivery_time_slot.settings.general.status')) { $deliveryTimeSlot = $this->deliveryTimeSlotsOrdersRepository->findOneByField('order_id', $orderId); $timeSlotData = []; - if ( $deliveryTimeSlot ) { + if ($deliveryTimeSlot) { foreach ($invoice->items as $key => $item) { if ($item->type == 'configurable') { $item = $item->child; @@ -136,7 +136,7 @@ public function view($id) 'order_id' => $orderId ]); - if ( $deliveryTimeSlot ) { + if ($deliveryTimeSlot) { $this->orderSlots->push([ 'items' => [$item], 'timeOrderSlot' => $deliveryTimeSlot @@ -165,11 +165,11 @@ public function print($id) $invoice = $this->invoiceRepository->findOrFail($id); $orderId = $invoice->order_id; - if ( core()->getConfigData('delivery_time_slot.settings.general.status') ) { + if (core()->getConfigData('delivery_time_slot.settings.general.status')) { $deliveryTimeSlot = $this->deliveryTimeSlotsOrdersRepository->findOneByField('order_id', $orderId); $timeSlotData = []; - if ( $deliveryTimeSlot ) { + if ($deliveryTimeSlot) { foreach ($invoice->items as $key => $item) { if ($item->type == 'configurable') { $item = $item->child; @@ -179,7 +179,7 @@ public function print($id) 'order_id' => $orderId ]); - if ( $deliveryTimeSlot ) { + if ($deliveryTimeSlot) { $this->orderSlots->push([ 'items' => [$item], 'timeOrderSlot' => $deliveryTimeSlot diff --git a/src/Http/Controllers/Admin/Sales/OrderController.php b/src/Http/Controllers/Admin/Sales/OrderController.php index 1b20b9e..00f130a 100644 --- a/src/Http/Controllers/Admin/Sales/OrderController.php +++ b/src/Http/Controllers/Admin/Sales/OrderController.php @@ -62,11 +62,11 @@ public function view($id) { $order = $this->orderRepository->findOrFail($id); - if ( core()->getConfigData('delivery_time_slot.settings.general.status') ) { + if (core()->getConfigData('delivery_time_slot.settings.general.status')) { $deliveryTimeSlot = $this->deliveryTimeSlotsOrdersRepository->findOneByField('order_id', $id); $timeSlotData = []; - if ( $deliveryTimeSlot ) { + if ($deliveryTimeSlot) { foreach ($order->items as $key => $item) { if ($item->type == 'configurable') { $item = $item->child; @@ -77,7 +77,7 @@ public function view($id) 'customer_id' => $order->customer_id ]); - if ( $deliveryTimeSlot ) { + if ($deliveryTimeSlot) { $this->orderSlots->push([ 'items' => [$item], 'timeOrderSlot' => $deliveryTimeSlot diff --git a/src/Http/Controllers/Admin/Sales/RefundController.php b/src/Http/Controllers/Admin/Sales/RefundController.php index 85660c6..d4f3c37 100644 --- a/src/Http/Controllers/Admin/Sales/RefundController.php +++ b/src/Http/Controllers/Admin/Sales/RefundController.php @@ -86,11 +86,11 @@ public function create($orderId) { $order = $this->orderRepository->findOrFail($orderId); - if ( core()->getConfigData('delivery_time_slot.settings.general.status') ) { + if (core()->getConfigData('delivery_time_slot.settings.general.status')) { $deliveryTimeSlot = $this->deliveryTimeSlotsOrdersRepository->findOneByField('order_id', $orderId); $timeSlotData = []; - if ( $deliveryTimeSlot ) { + if ($deliveryTimeSlot) { foreach ($order->items as $key => $item) { if ($item->type == 'configurable') { $item = $item->child; @@ -101,7 +101,7 @@ public function create($orderId) 'customer_id' => $order->customer_id ]); - if ( $deliveryTimeSlot ) { + if ($deliveryTimeSlot) { $this->orderSlots->push([ 'items' => [$item], 'timeOrderSlot' => $deliveryTimeSlot @@ -130,11 +130,11 @@ public function view($id) $refund = $this->refundRepository->findOrFail($id); $orderId = $refund->order_id; - if ( core()->getConfigData('delivery_time_slot.settings.general.status') ) { + if (core()->getConfigData('delivery_time_slot.settings.general.status')) { $deliveryTimeSlot = $this->deliveryTimeSlotsOrdersRepository->findOneByField('order_id', $orderId); $timeSlotData = []; - if ( $deliveryTimeSlot ) { + if ($deliveryTimeSlot) { foreach ($refund->items as $key => $item) { if ($item->type == 'configurable') { $item = $item->child; @@ -144,7 +144,7 @@ public function view($id) 'order_id' => $orderId ]); - if ( $deliveryTimeSlot ) { + if ($deliveryTimeSlot) { $this->orderSlots->push([ 'items' => [$item], 'timeOrderSlot' => $deliveryTimeSlot diff --git a/src/Http/Controllers/Admin/Sales/ShipmentController.php b/src/Http/Controllers/Admin/Sales/ShipmentController.php index cc8d02a..062a370 100644 --- a/src/Http/Controllers/Admin/Sales/ShipmentController.php +++ b/src/Http/Controllers/Admin/Sales/ShipmentController.php @@ -86,17 +86,20 @@ public function create($orderId) { $order = $this->orderRepository->findOrFail($orderId); - if (! $order->channel || !$order->canShip()) { + if ( + ! $order->channel || + ! $order->canShip() + ) { session()->flash('error', trans('admin::app.sales.shipments.creation-error')); return redirect()->back(); } - if ( core()->getConfigData('delivery_time_slot.settings.general.status') ) { + if (core()->getConfigData('delivery_time_slot.settings.general.status')) { $deliveryTimeSlot = $this->deliveryTimeSlotsOrdersRepository->findOneByField('order_id', $orderId); $timeSlotData = []; - if ( $deliveryTimeSlot ) { + if ($deliveryTimeSlot) { foreach ($order->items as $key => $item) { if ($item->type == 'configurable') { $item = $item->child; @@ -107,7 +110,7 @@ public function create($orderId) 'customer_id' => $order->customer_id ]); - if ( $deliveryTimeSlot ) { + if ($deliveryTimeSlot) { $this->orderSlots->push([ 'items' => [$item], 'timeOrderSlot' => $deliveryTimeSlot @@ -136,11 +139,11 @@ public function view($id) $shipment = $this->shipmentRepository->findOrFail($id); $orderId = $shipment->order_id; - if ( core()->getConfigData('delivery_time_slot.settings.general.status') ) { + if (core()->getConfigData('delivery_time_slot.settings.general.status')) { $deliveryTimeSlot = $this->deliveryTimeSlotsOrdersRepository->findOneByField('order_id', $orderId); $timeSlotData = []; - if ( $deliveryTimeSlot ) { + if ($deliveryTimeSlot) { foreach ($shipment->items as $key => $item) { if ($item->type == 'configurable') { $item = $item->child; @@ -150,7 +153,7 @@ public function view($id) 'order_id' => $orderId ]); - if ( $deliveryTimeSlot ) { + if ($deliveryTimeSlot) { $this->orderSlots->push([ 'items' => [$item], 'timeOrderSlot' => $deliveryTimeSlot diff --git a/src/Http/Controllers/Admin/TimeSlotController.php b/src/Http/Controllers/Admin/TimeSlotController.php index 60ebaf1..8fa8a70 100644 --- a/src/Http/Controllers/Admin/TimeSlotController.php +++ b/src/Http/Controllers/Admin/TimeSlotController.php @@ -2,9 +2,13 @@ namespace Webkul\DeliveryTimeSlot\Http\Controllers\Admin; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Validator; use Webkul\Customer\Repositories\CustomerRepository; use Webkul\Sales\Repositories\OrderRepository as Order; use Webkul\DeliveryTimeSlot\Http\Controllers\Controller; +use Webkul\DeliveryTimeSlot\DataGrids\Admin\DeliveyOrdersDataGrid; +use Webkul\DeliveryTimeSlot\DataGrids\Admin\DeliveyTimeSlotsDataGrid; use Webkul\DeliveryTimeSlot\Repositories\DeliveryTimeSlotsRepository; use Webkul\DeliveryTimeSlot\Repositories\DeliveryTimeSlotsOrdersRepository; @@ -27,7 +31,7 @@ class TimeSlotController extends Controller /** * TimeSlotsRepository object * - * @var array + * @var object */ protected $timeSlotsRepository; @@ -97,8 +101,38 @@ public function index() * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ - public function store() + public function store(Request $request) { + $validator = Validator::make($request->all(), [ + 'delivery_day' => ['required', 'array'], + 'delivery_day.*' => ['required'], + 'start_time' => ['required', 'array'], + 'start_time.*' => ['required'], + 'end_time' => ['required', 'array'], + 'end_time.*' => ['required'], + 'time_delivery_quota' => ['required', 'array'], + 'time_delivery_quota.*' => ['required'], + 'visibility' => ['required', 'array'], + 'visibility.*' => ['required'], + ]); + + $validator->after(function ($validator) use ($request) { + $timeSlots = []; + foreach ($request->delivery_day as $index => $day) { + $slot = $day . $request->start_time[$index]; + if (in_array($slot, $timeSlots)) { + $validator->errors()->add('start_time.' . $index, trans('delivery-time-slot::app.admin.layouts.start-time-error')); + } + $timeSlots[] = $slot; + } + }); + + if ($validator->fails()) { + session()->flash('error', $validator->errors()->first()); + + return redirect()->back(); + } + $data = request()->except('_token'); $previousData = $this->timeSlotsRepository->findWhere([ @@ -137,20 +171,15 @@ public function store() foreach ($data['id'] as $exisitingValue => $id) { - $result = $this->timeSlotsRepository->findOneWhere( - ['id' => $id, - ]); + $result = $this->timeSlotsRepository->findOneWhere(['id' => $id]); if ($result) { - - // conver 24H to 12H - $startTime = date("g:i a", strtotime("{$data['start_time'][$exisitingValue]}")); - $endTime = date("g:i a", strtotime("{$data['end_time'][$exisitingValue]}")); $result->update([ 'delivery_day' => $data['delivery_day'][$exisitingValue], - 'start_time' => strtoupper($startTime), - 'end_time' => strtoupper($endTime), + 'start_time' => $data['start_time'][$exisitingValue], + 'end_time' => $data['end_time'][$exisitingValue], 'time_delivery_quota' => $data['time_delivery_quota'][$exisitingValue], + 'visibility' => $data['visibility'][$exisitingValue], 'is_seller' => 0, 'minimum_time_required' => $data['minimum_time_required'] ]); @@ -159,27 +188,28 @@ public function store() foreach ($data['delivery_day'] as $key => $value) { - if ( ! in_array($data['id'][$key], array_filter($data['id']))) { - - // convert 24H to 12H - $startTime = date("g:i a", strtotime("{$data['start_time'][$key]}")); - $endTime = date("g:i a", strtotime("{$data['end_time'][$key]}")); + if (! in_array($data['id'][$key], array_filter($data['id']))) { $insert = [ 'delivery_day' => $value, - 'start_time' => strtoupper($startTime), - 'end_time' => strtoupper($endTime), + 'start_time' => $data['start_time'][$key], + 'end_time' => $data['end_time'][$key], 'time_delivery_quota' => $data['time_delivery_quota'][$key], + 'visibility' => $data['visibility'][$key], 'is_seller' => 0, 'minimum_time_required' => (int)$data['minimum_time_required'] ]; - $this->timeSlotsRepository->create($insert); + $data = $this->timeSlotsRepository->findWhere($insert); + + if (! empty($data)) { + $this->timeSlotsRepository->create($insert); + } } } session()->flash('success', 'Delivery Time Slots Created.'); - return redirect()->route('admin.timeslot.index'); + return redirect()->back(); } /** @@ -190,6 +220,11 @@ public function store() */ public function deliveryOrders() { + if (request()->ajax()) { + + return app(DeliveyOrdersDataGrid::class)->toJson(); + } + return view($this->_config['view']); } @@ -201,6 +236,11 @@ public function deliveryOrders() */ public function deliverySlots() { + if (request()->ajax()) { + + return app(DeliveyTimeSlotsDataGrid::class)->toJson(); + } + return view($this->_config['view']); } diff --git a/src/Http/Controllers/Shop/Account/Customer/OrderController.php b/src/Http/Controllers/Shop/Account/Customer/OrderController.php index 8c8ea0b..9147393 100644 --- a/src/Http/Controllers/Shop/Account/Customer/OrderController.php +++ b/src/Http/Controllers/Shop/Account/Customer/OrderController.php @@ -49,10 +49,6 @@ public function __construct( DeliveryTimeSlotsOrdersRepository $deliveryTimeSlotsOrdersRepository ) { - $this->middleware('customer'); - - $this->currentCustomer = auth()->guard('customer')->user(); - $this->orderRepository = $orderRepository; $this->invoiceRepository = $invoiceRepository; @@ -72,44 +68,46 @@ public function __construct( */ public function view($id) { - $order = $this->orderRepository->findOneWhere([ - 'customer_id' => $this->currentCustomer->id, - 'id' => $id, - ]); - - if (! $order) { - abort(404); - } - - if ( core()->getConfigData('delivery_time_slot.settings.general.status') ) { - $deliveryTimeSlotsOrder = $this->deliveryTimeSlotsOrdersRepository->findOneByField('order_id', $id); - - $timeSlotData = []; - if ( $deliveryTimeSlotsOrder ) { - foreach ($order->items as $key => $item) { - if ($item->type == 'configurable') { - $item = $item->child; - } - - $deliveryTimeSlot = $this->deliveryTimeSlotsOrdersRepository->with('time_slot')->findOneWhere([ - 'order_id' => $id, - 'customer_id' => $order->customer_id - ]); - - if ( $deliveryTimeSlot ) { - $this->orderSlots->push([ - 'items' => [$item], - 'timeOrderSlot' => $deliveryTimeSlot + if (auth()->guard('customer')->user()) { + $order = $this->orderRepository->findOneWhere([ + 'customer_id' => auth()->guard('customer')->user()->id, + 'id' => $id, + ]); + + if (! $order) { + abort(404); + } + + if (core()->getConfigData('delivery_time_slot.settings.general.status')) { + $deliveryTimeSlotsOrder = $this->deliveryTimeSlotsOrdersRepository->findOneByField('order_id', $id); + + $timeSlotData = []; + if ($deliveryTimeSlotsOrder) { + foreach ($order->items as $key => $item) { + if ($item->type == 'configurable') { + $item = $item->child; + } + + $deliveryTimeSlot = $this->deliveryTimeSlotsOrdersRepository->with('time_slot')->findOneWhere([ + 'order_id' => $id, + 'customer_id' => $order->customer_id ]); + + if ($deliveryTimeSlot) { + $this->orderSlots->push([ + 'items' => [$item], + 'timeOrderSlot' => $deliveryTimeSlot + ]); + } } + + $timeSlotData = $this->orderSlots; } - - $timeSlotData = $this->orderSlots; + + return view($this->_config['view'], compact('order', 'timeSlotData')); + } else { + return view($this->_config['view'], compact('order')); } - - return view($this->_config['view'], compact('order', 'timeSlotData')); - } else { - return view($this->_config['view'], compact('order')); } } } \ No newline at end of file diff --git a/src/Http/Controllers/Shop/Account/Seller/SellerTimeSlotController.php b/src/Http/Controllers/Shop/Account/Seller/SellerTimeSlotController.php index d4967bd..f57edea 100644 --- a/src/Http/Controllers/Shop/Account/Seller/SellerTimeSlotController.php +++ b/src/Http/Controllers/Shop/Account/Seller/SellerTimeSlotController.php @@ -107,6 +107,7 @@ public function index() $data = $this->timeSlotsRepository->findWhere([ 'is_seller' => 1, 'status' => 1, + 'visibility' => 1, 'marketplace_seller_id' => $seller->id ]); @@ -117,6 +118,7 @@ public function index() $sellerData = $this->timeSlotsRepository->findWhere([ 'is_seller' => 1, 'status' => 1, + 'visibility' => 1, 'marketplace_seller_id' => $seller->id ])->last(); $minimuTimeRequired = $sellerData; diff --git a/src/Http/Controllers/Shop/OnepageController.php b/src/Http/Controllers/Shop/OnepageController.php index 8dead2e..8d43af4 100644 --- a/src/Http/Controllers/Shop/OnepageController.php +++ b/src/Http/Controllers/Shop/OnepageController.php @@ -2,7 +2,6 @@ namespace Webkul\DeliveryTimeSlot\Http\Controllers\Shop; -use Illuminate\Support\Facades\Event; use Webkul\Shop\Http\Controllers\Controller; use Webkul\Checkout\Facades\Cart; use Webkul\Shipping\Facades\Shipping; @@ -10,7 +9,6 @@ use Webkul\Checkout\Http\Requests\CustomerAddressForm; use Webkul\Sales\Repositories\OrderRepository; use Webkul\Customer\Repositories\CustomerRepository; - use Webkul\DeliveryTimeSlot\Repositories\DeliveryTimeSlotsRepository; use Webkul\DeliveryTimeSlot\Repositories\DeliveryTimeSlotsOrdersRepository; use Webkul\DeliveryTimeSlot\Repositories\OrderRepository as DeliveryTimeSlotOrderRepository; @@ -93,12 +91,12 @@ public function __construct( if ( core()->getConfigData('delivery_time_slot.settings.general.status') ) { $this->dtsConfigArray['status'] = core()->getConfigData('delivery_time_slot.settings.general.status'); - + $this->dtsConfigArray['message'] = core()->getConfigData('delivery_time_slot.settings.general.time_slot_error_message'); $this->dtsConfigArray['days'] = core()->getConfigData('delivery_time_slot.settings.general.allowed_days'); } - + parent::__construct(); } @@ -112,14 +110,20 @@ public function saveAddress(CustomerAddressForm $request) { $data = request()->all(); - if (! auth()->guard('customer')->check() && ! Cart::getCart()->hasGuestCheckoutItems()) { + if ( + ! auth()->guard('customer')->check() && + ! Cart::getCart()->hasGuestCheckoutItems() + ) { return response()->json(['redirect_url' => route('customer.session.index')], 403); } $data['billing']['address1'] = implode(PHP_EOL, array_filter($data['billing']['address1'])); $data['shipping']['address1'] = implode(PHP_EOL, array_filter($data['shipping']['address1'])); - if (Cart::hasError() || ! Cart::saveCustomerAddress($data)) { + if ( + Cart::hasError() || + ! Cart::saveCustomerAddress($data) + ) { return response()->json(['redirect_url' => route('shop.checkout.cart.index')], 403); } else { $cart = Cart::getCart(); @@ -134,7 +138,7 @@ public function saveAddress(CustomerAddressForm $request) if ( $this->dtsConfigArray['status'] ) { $rates['sellersTimeSlots'] = $this->deliveryTimeSlotsRepository->getShippingTimeSlots(); } // Delivery Time Slot End - + return response()->json($rates); } } else { @@ -152,7 +156,11 @@ public function savePayment() { $payment = request()->get('payment'); - if (Cart::hasError() || ! $payment || ! Cart::savePaymentMethod($payment)) { + if ( + Cart::hasError() || + ! $payment || + ! Cart::savePaymentMethod($payment) + ) { return response()->json(['redirect_url' => route('shop.checkout.cart.index')], 403); } @@ -161,27 +169,36 @@ public function savePayment() $cart = Cart::getCart(); // Delivery Time Slot Start - if ( $this->dtsConfigArray['status'] ) { + if ($this->dtsConfigArray['status']) { $selectedSlots = []; $selectedTimeSlot = request()->get('selected_delivery_slot'); - - if ( isset($selectedTimeSlot) && $selectedTimeSlot ) { + + if ( + isset($selectedTimeSlot) && + $selectedTimeSlot + ) { foreach ($selectedTimeSlot as $key => $slot) { - + $sellerId = NULL; - if (isset($slot[1]) && $slot[1]) { + if ( + isset($slot[1]) && + $slot[1] + ) { $sellerId = (int) $slot[1]; } - + $deliveryTimeSlot = $this->deliveryTimeSlotsRepository->find($slot[0]); - - if ( isset($deliveryTimeSlot->id) && $deliveryTimeSlot->id == $slot[0]) { + + if ( + isset($deliveryTimeSlot->id) && + $deliveryTimeSlot->id == $slot[0] + ) { $selectedSlots[0]['days'] = $deliveryTimeSlot; $selectedSlots[0]['delivery_date'] = $slot[2] . ',' . $slot['3'] . ',' . $slot[4]; } } } - + session()->put('selected_delivery_slot', request()->selected_delivery_slot); return response()->json([ @@ -222,7 +239,7 @@ public function saveOrder() } // Delivery Time Slot Start - if ( $this->dtsConfigArray['status'] ) { + if ($this->dtsConfigArray['status']) { $order = $this->deliveryTimeSlotOrderRepository->create(Cart::prepareDataForOrder()); } else { // Delivery Time Slot End $order = $this->orderRepository->create(Cart::prepareDataForOrder()); @@ -254,7 +271,10 @@ public function validateOrder() throw new \Exception(trans('shop::app.checkout.cart.minimum-order-message', ['amount' => core()->currency($minimumOrderAmount)])); } - if ($cart->haveStockableItems() && ! $cart->shipping_address) { + if ( + $cart->haveStockableItems() && + ! $cart->shipping_address + ) { throw new \Exception(trans('Please check shipping address.')); } @@ -262,7 +282,10 @@ public function validateOrder() throw new \Exception(trans('Please check billing address.')); } - if ($cart->haveStockableItems() && ! $cart->selected_shipping_rate) { + if ( + $cart->haveStockableItems() && + ! $cart->selected_shipping_rate + ) { throw new \Exception(trans('Please specify shipping method.')); } diff --git a/src/Http/Controllers/Shop/StandardController.php b/src/Http/Controllers/Shop/StandardController.php index 873e9cf..2fdb777 100755 --- a/src/Http/Controllers/Shop/StandardController.php +++ b/src/Http/Controllers/Shop/StandardController.php @@ -19,14 +19,14 @@ class StandardController extends Controller /** * TimeSlotOrderRepository object * - * @var array + * @var object */ protected $timeSlotOrderRepository; /** * Ipn object * - * @var array + * @var object */ protected $ipnHelper; diff --git a/src/Http/admin-routes.php b/src/Http/admin-routes.php index 98cf6a0..c925938 100644 --- a/src/Http/admin-routes.php +++ b/src/Http/admin-routes.php @@ -1,71 +1,84 @@ ['web']], function () { - - Route::prefix('admin')->group(function () { - - Route::group(['middleware' => ['admin']], function () { - - Route::prefix('delivery_time_slot')->group(function () { - //show index page - Route::get('/default-slot', 'Webkul\DeliveryTimeSlot\Http\Controllers\Admin\TimeSlotController@index')->defaults('_config', [ - 'view' => 'delivery-time-slot::admin.configuration.index' - ])->name('admin.timeslot.index'); - - Route::post('/default-slot', 'Webkul\DeliveryTimeSlot\Http\Controllers\Admin\TimeSlotController@store')->defaults('_config', [ - 'redirect' => 'marketplace.timeslot.admin.index' - ])->name('timeslot.admin.saveconfig'); - - //seller orders delivery - Route::get('/orders', 'Webkul\DeliveryTimeSlot\Http\Controllers\Admin\TimeSlotController@deliveryOrders')->defaults('_config', [ - 'view' => 'delivery-time-slot::admin.marketplace.timeslots.delivery-orders' - ])->name('admin.timeslot.delivery.orders'); - - //seller delivery timeslots - Route::get('/timeslots', 'Webkul\DeliveryTimeSlot\Http\Controllers\Admin\TimeSlotController@deliverySlots')->defaults('_config', [ - 'view' => 'delivery-time-slot::admin.marketplace.timeslots.delivery-time-slots' - ])->name('admin.timeslot.delivery.timeslots'); - }); +use Illuminate\Support\Facades\Route; +use Webkul\DeliveryTimeSlot\Http\Controllers\Admin\TimeSlotController; +use Webkul\DeliveryTimeSlot\Http\Controllers\Admin\Sales\OrderController; +use Webkul\DeliveryTimeSlot\Http\Controllers\Admin\Sales\RefundController; +use Webkul\DeliveryTimeSlot\Http\Controllers\Admin\Sales\InvoiceController; +use Webkul\DeliveryTimeSlot\Http\Controllers\Admin\Sales\ShipmentController; + +Route::group(['middleware' => ['web', 'admin'], 'prefix' => 'admin'], function () { + + Route::prefix('delivery_time_slot')->group(function () { + + Route::controller(TimeSlotController::class)->group(function () { + + Route::get('/default-slot', 'index')->defaults('_config', [ + 'view' => 'delivery-time-slot::admin.configuration.index' + ])->name('admin.timeslot.index'); + + Route::post('/default-slot', 'store')->defaults('_config', [ + 'redirect' => 'marketplace.timeslot.admin.index' + ])->name('timeslot.admin.saveconfig'); - // Sales Routes - Route::prefix('sales')->group(function () { - //admin order view - Route::get('/orders/view/{id}', 'Webkul\DeliveryTimeSlot\Http\Controllers\Admin\Sales\OrderController@view')->defaults('_config', [ - 'view' => 'admin::sales.orders.view' - ])->name('admin.sales.orders.view'); - - // Sales Invoices Routes - Route::get('/invoices/create/{order_id}', 'Webkul\DeliveryTimeSlot\Http\Controllers\Admin\Sales\InvoiceController@create')->defaults('_config', [ - 'view' => 'admin::sales.invoices.create' - ])->name('admin.sales.invoices.create'); - - Route::get('/invoices/view/{id}', 'Webkul\DeliveryTimeSlot\Http\Controllers\Admin\Sales\InvoiceController@view')->defaults('_config', [ - 'view' => 'admin::sales.invoices.view' - ])->name('admin.sales.invoices.view'); - - Route::get('/invoices/print/{id}', 'Webkul\DeliveryTimeSlot\Http\Controllers\Admin\Sales\InvoiceController@print')->defaults('_config', [ - 'view' => 'admin::sales.invoices.print', - ])->name('admin.sales.invoices.print'); - - // Sales Shipments Routes - Route::get('/shipments/create/{order_id}', 'Webkul\DeliveryTimeSlot\Http\Controllers\Admin\Sales\ShipmentController@create')->defaults('_config', [ - 'view' => 'admin::sales.shipments.create' - ])->name('admin.sales.shipments.create'); - - Route::get('/shipments/view/{id}', 'Webkul\DeliveryTimeSlot\Http\Controllers\Admin\Sales\ShipmentController@view')->defaults('_config', [ - 'view' => 'admin::sales.shipments.view' - ])->name('admin.sales.shipments.view'); - - // Sales Redunds Routes - Route::get('/refunds/create/{order_id}', 'Webkul\DeliveryTimeSlot\Http\Controllers\Admin\Sales\RefundController@create')->defaults('_config', [ - 'view' => 'admin::sales.refunds.create', - ])->name('admin.sales.refunds.create'); - - Route::get('/refunds/view/{id}', 'Webkul\DeliveryTimeSlot\Http\Controllers\Admin\Sales\RefundController@view')->defaults('_config', [ - 'view' => 'admin::sales.refunds.view', - ])->name('admin.sales.refunds.view'); - - }); + Route::get('/orders', 'deliveryOrders')->defaults('_config', [ + 'view' => 'delivery-time-slot::admin.marketplace.timeslots.delivery-orders' + ])->name('admin.timeslot.delivery.orders'); + + Route::get('/timeslots', 'deliverySlots')->defaults('_config', [ + 'view' => 'delivery-time-slot::admin.marketplace.timeslots.delivery-time-slots' + ])->name('admin.timeslot.delivery.timeslots'); + }); + }); + + Route::prefix('sales')->group(function () { + + Route::get('/orders/view/{id}', [OrderController::class, 'view'])->defaults('_config', [ + 'view' => 'admin::sales.orders.view' + ])->name('admin.sales.orders.view'); + + Route::controller(InvoiceController::class)->group(function () { + + Route::get('/invoices/create/{order_id}', 'create')->defaults('_config', [ + 'view' => 'admin::sales.invoices.create' + ])->name('admin.sales.invoices.create'); + + Route::get('/invoices/view/{id}', 'view')->defaults('_config', [ + 'view' => 'admin::sales.invoices.view' + ])->name('admin.sales.invoices.view'); + + Route::get('/invoices/print/{id}', 'print')->defaults('_config', [ + 'view' => 'admin::sales.invoices.print', + ])->name('admin.sales.invoices.print'); + + }); + + Route::controller(ShipmentController::class)->group(function () { + + Route::get('/shipments/create/{order_id}', 'create')->defaults('_config', [ + 'view' => 'admin::sales.shipments.create' + ])->name('admin.sales.shipments.create'); + + Route::get('/shipments/view/{id}', 'view')->defaults('_config', [ + 'view' => 'admin::sales.shipments.view' + ])->name('admin.sales.shipments.view'); + + }); + + Route::controller(RefundController::class)->group(function () { + + Route::get('/refunds/create/{order_id}', 'create')->defaults('_config', [ + 'view' => 'admin::sales.refunds.create', + ])->name('admin.sales.refunds.create'); + + Route::get('/refunds/view/{id}', 'view')->defaults('_config', [ + 'view' => 'admin::sales.refunds.view', + ])->name('admin.sales.refunds.view'); + + }); + + }); + }); diff --git a/src/Http/front-routes.php b/src/Http/front-routes.php index 6313f94..197ad3a 100644 --- a/src/Http/front-routes.php +++ b/src/Http/front-routes.php @@ -1,48 +1,52 @@ ['web', 'theme', 'locale', 'currency']], function () { - //Marketplace routes starts here Route::prefix('marketplace')->group(function () { - //mindex pages - Route::get('/account/timedelivery/configuration', 'Webkul\DeliveryTimeSlot\Http\Controllers\Shop\Account\Seller\SellerTimeSlotController@index')->defaults('_config', [ - 'view' => 'delivery-time-slot::shop.sellers.account.time-slot-configuration' - ])->name('marketplace.timeslot.seller.index'); + Route::controller(SellerTimeSlotController::class)->group(function () { + + Route::get('/account/timedelivery/configuration', 'index')->defaults('_config', [ + 'view' => 'delivery-time-slot::shop.sellers.account.time-slot-configuration' + ])->name('marketplace.timeslot.seller.index'); + + Route::post('/account/timedelivery/store', 'store')->defaults('_config', [ + 'redirect' => 'marketplace.timeslot.seller.index' + ])->name('marketplace.timeslot.seller.saveconfig'); + + Route::get('/account/timedelivery/orders', 'index')->defaults('_config', [ + 'view' => 'delivery-time-slot::shop.sellers.account.sales.orders.delivery-order-history' + ])->name('marketplace.timeslot.seller.orders'); + + }); - //store seller end time slots - Route::post('/account/timedelivery/store', 'Webkul\DeliveryTimeSlot\Http\Controllers\Shop\Account\Seller\SellerTimeSlotController@store')->defaults('_config', [ - 'redirect' => 'marketplace.timeslot.seller.index' - ])->name('marketplace.timeslot.seller.saveconfig'); + Route::controller(OnepageController::class)->group(function () { - //view the order of customer - Route::get('/account/timedelivery/orders', 'Webkul\DeliveryTimeSlot\Http\Controllers\Shop\Account\Seller\SellerTimeSlotController@index')->defaults('_config', [ - 'view' => 'delivery-time-slot::shop.sellers.account.sales.orders.delivery-order-history' - ])->name('marketplace.timeslot.seller.orders'); + Route::post('/checkout/save-address', 'saveAddress')->name('marketplace.timeslot.checkout.saveaddress'); - //checkout routes - //Checkout Save Address Form Store - Route::post('/checkout/save-address', 'Webkul\DeliveryTimeSlot\Http\Controllers\Shop\OnepageController@saveAddress')->name('marketplace.timeslot.checkout.saveaddress'); + Route::post('/checkout/save-order', 'saveOrder')->name('marketplace.timeslot.checkout.save-order'); - //save shipping - Route::post('/checkout/save-order', 'Webkul\DeliveryTimeSlot\Http\Controllers\Shop\OnepageController@saveOrder')->name('marketplace.timeslot.checkout.save-order'); + Route::post('/checkout/save-payment', 'savePayment')->name('marketplace.timeslot.checkout.save-payment'); - //save shipping - Route::post('/checkout/save-payment', 'Webkul\DeliveryTimeSlot\Http\Controllers\Shop\OnepageController@savePayment')->name('marketplace.timeslot.checkout.save-payment'); + }); - //seller order view - Route::get('orders/view/{id}', 'Webkul\DeliveryTimeSlot\Http\Controllers\Shop\Account\Seller\SellerTimeSlotController@view')->defaults('_config', [ + Route::get('orders/view/{id}', [SellerTimeSlotController::class, 'view'])->defaults('_config', [ 'view' => 'marketplace::shop.sellers.account.sales.orders.view' ])->name('marketplace.timeslot.seller.account.orders.view'); }); - Route::get('account/orders/view/{id}', 'Webkul\DeliveryTimeSlot\Http\Controllers\Shop\Account\Customer\OrderController@view')->defaults('_config', [ + Route::get('account/orders/view/{id}', [OrderController::class, 'view'])->defaults('_config', [ 'view' => 'shop::customers.account.orders.view' ])->name('timeslot.customer.orders.view'); Route::prefix('paypal/standard')->group(function () { - //paypal routes - Route::get('/success', 'Webkul\DeliveryTimeSlot\Http\Controllers\Shop\StandardController@success')->name('paypal.standard.success'); + Route::get('/success', [StandardController::class, 'success'])->name('paypal.standard.success'); }); }); \ No newline at end of file diff --git a/src/Models/DeliveryTimeSlots.php b/src/Models/DeliveryTimeSlots.php index 553712e..ce6d666 100644 --- a/src/Models/DeliveryTimeSlots.php +++ b/src/Models/DeliveryTimeSlots.php @@ -11,17 +11,29 @@ class DeliveryTimeSlots extends Model implements DeliveryTimeSlotsContract { protected $table = 'delivery_time_slots'; - protected $fillable = ['id', 'delivery_day', 'start_time', 'end_time', 'time_delivery_quota', 'is_seller','minimum_time_required', 'status', 'created_at', 'updated_at']; + protected $fillable = [ + 'id', + 'delivery_day', + 'start_time', + 'end_time', + 'time_delivery_quota', + 'is_seller', + 'minimum_time_required', + 'status', + 'visibility', + 'created_at', + 'updated_at' + ]; - //get time slots - public function time_slot_order() - { - return $this->hasOne(DeliveryTimeSlotsOrders::modelClass(), 'id', 'time_slot_id'); - } + //get time slots + public function time_slot_order() + { + return $this->hasOne(DeliveryTimeSlotsOrders::modelClass(), 'id', 'time_slot_id'); + } - //slot - public function slot() - { - return $this->hasOne(SlotsProxy::modelClass(), 'id'); - } -} \ No newline at end of file + //slot + public function slot() + { + return $this->hasOne(SlotsProxy::modelClass(), 'id'); + } +} diff --git a/src/Models/DeliveryTimeSlotsOrders.php b/src/Models/DeliveryTimeSlotsOrders.php index 3f0db39..83ba8a6 100644 --- a/src/Models/DeliveryTimeSlotsOrders.php +++ b/src/Models/DeliveryTimeSlotsOrders.php @@ -11,8 +11,13 @@ class DeliveryTimeSlotsOrders extends Model implements DeliveryTimeSlotsOrdersCo { protected $table = 'delivery_time_slots_orders'; - protected $fillable = ['id', 'time_slot_id', 'delivery_date', 'order_id','customer_id']; - + protected $fillable = [ + 'id', + 'time_slot_id', + 'delivery_date', + 'order_id', + 'customer_id' + ]; //get time slots public function time_slot() @@ -26,4 +31,9 @@ public function items() return $this->hasMany(OrderItemProxy::modelClass(), 'order_id')->whereNull('parent_id'); } -} \ No newline at end of file + public function setDeliveryDateAttribute($value) + { + $date = explode(',', $value); + $this->attributes['delivery_date'] = date('Y-m-d', strtotime($date[1] . ' ' . $date[2])); + } +} diff --git a/src/Providers/DeliveryTimeSlotServiceProvider.php b/src/Providers/DeliveryTimeSlotServiceProvider.php index 1c3b28f..e8d8a44 100644 --- a/src/Providers/DeliveryTimeSlotServiceProvider.php +++ b/src/Providers/DeliveryTimeSlotServiceProvider.php @@ -50,6 +50,10 @@ public function boot(Router $router) ]); /*** Velocity Theme page override ***/ + $this->publishes([ + __DIR__ . '/../Resources/views/shop/velocity/checkout/cart/index.blade.php' => resource_path('themes/velocity/views/checkout/cart/index.blade.php'), + ]); + $this->publishes([ __DIR__ . '/../Resources/views/shop/velocity/checkout/onepage.blade.php' => resource_path('themes/velocity/views/checkout/onepage.blade.php'), ]); @@ -76,17 +80,13 @@ public function boot(Router $router) ]); $this->publishes([ - __DIR__ . '/../Resources/views/emails/' => resource_path('views/vendor/emails/'), + __DIR__ . '/../Resources/views/admin/layouts/nav-left.blade.php' => resource_path('views/vendor/admin/layouts/nav-left.blade.php'), ]); /*** Assets of themes override ***/ - // $this->publishes([ - // __DIR__ . '/../../publishable/assets' => public_path('themes/default/assets'), - // ], 'public'); - - // $this->publishes([ - // __DIR__ . '/../../publishable/assets/' => public_path('themes/velocity/assets'), - // ], 'public'); + $this->publishes([ + __DIR__ . '/../../publishable/assets' => public_path('vendor/delivery-time-slot/assets'), + ], 'public'); $this->overrideModels(); diff --git a/src/Repositories/DeliveryTimeSlotsOrdersRepository.php b/src/Repositories/DeliveryTimeSlotsOrdersRepository.php index 9865226..793d4da 100644 --- a/src/Repositories/DeliveryTimeSlotsOrdersRepository.php +++ b/src/Repositories/DeliveryTimeSlotsOrdersRepository.php @@ -4,7 +4,6 @@ use Webkul\Core\Eloquent\Repository; - class DeliveryTimeSlotsOrdersRepository extends Repository { /** diff --git a/src/Repositories/DeliveryTimeSlotsRepository.php b/src/Repositories/DeliveryTimeSlotsRepository.php index ceb2b97..466d22f 100644 --- a/src/Repositories/DeliveryTimeSlotsRepository.php +++ b/src/Repositories/DeliveryTimeSlotsRepository.php @@ -48,7 +48,7 @@ public function selectDays() $timestamp = strtotime('next Sunday'); $days = array(); for ($i = 0; $i < 7; $i++) { - $days[] = strftime('%A', $timestamp); + $days[] = date('l', $timestamp); $timestamp = strtotime('+1 day', $timestamp); } @@ -63,39 +63,51 @@ public function getShippingTimeSlots() { $this->timeSlotsRepository = app('Webkul\DeliveryTimeSlot\Repositories\DeliveryTimeSlotsRepository'); $adminAllowesDays = explode(',', core()->getConfigData('delivery_time_slot.settings.general.allowed_days')); - + $adminSlots = $this->timeSlotsRepository->findWhere([ 'status' => 1, + 'visibility' => 1, 'is_seller' => 0, ['start_time', '<>', NULL], ['end_time', '<>', NULL], - ])->toArray(); + ]); + + if (core()->getConfigData('delivery_time_slot.settings.general.display_time_format') == 12) { + foreach ($adminSlots as &$slot) { + $slot['start_time'] = date('h:i A', strtotime($slot['start_time'])); + $slot['end_time'] = date('h:i A', strtotime($slot['end_time'])); + } + } // Defined days $dateAndDays = $this->getDateWithDays(); $timestamp = strtotime('next Monday'); - + $days = []; for ($i = 0; $i < 7; $i++) { - $days[] = strftime('%A', $timestamp); + $days[] = date('l', $timestamp); $timestamp = strtotime('+1 day', $timestamp); } $minimumRequiredTime = $this->timeSlotsRepository->findWhere([ 'is_seller' => 0, - 'status' => 1 + 'status' => 1, + 'visibility' => 1, ])->last(); - + $sellersTimeSlots = []; foreach ($adminSlots as $adminSlot) { $delivery_day = ucfirst($adminSlot['delivery_day']); - - if ( in_array($delivery_day, $days) && isset($dateAndDays[$delivery_day]) ) { + + if ( + in_array($delivery_day, $days) && + isset($dateAndDays[$delivery_day]) + ) { $oldDateTimestamp = strtotime($dateAndDays[$delivery_day]); $finalTimeStamp = date('j F, l, Y', $oldDateTimestamp); $addedDays = $minimumRequiredTime->minimum_time_required; - + $orderProcessDate = date('j F, l, Y', strtotime(date('Y-m-d') . '+' . $addedDays . 'days')); //Delivery quotas @@ -103,9 +115,9 @@ public function getShippingTimeSlots() 'time_slot_id' => $adminSlot['id'], ])->count(); - if ( strtotime($finalTimeStamp) >= strtotime($orderProcessDate) ) { + if (strtotime($finalTimeStamp) >= strtotime($orderProcessDate)) { $quotas[$adminSlot['id']] = $deliveryQuotasCount; - + $sellersTimeSlots[0]['seller'] = 'Admin'; $sellersTimeSlots[0]['message'] = core()->getConfigData('delivery_time_slot.settings.general.time_slot_error_message') ?: ' Warning: There are no slots avilable'; $sellersTimeSlots[0]['slotsNotAvilable'] = true; @@ -114,11 +126,14 @@ public function getShippingTimeSlots() } } } - + // Admin set days for delivery $timeSlots = []; foreach ($sellersTimeSlots as $key => $allTimeSlots) { - if ( isset($sellersTimeSlots[$key]['days']) && $sellersTimeSlots[$key]['days'] ) { + if ( + isset($sellersTimeSlots[$key]['days']) && + $sellersTimeSlots[$key]['days'] + ) { $timeSlots[$key] = [ 'seller' => $allTimeSlots['seller'], 'quotas' => $allTimeSlots['quotas'], @@ -130,7 +145,10 @@ public function getShippingTimeSlots() $daysArray = explode(',', $date); $slotOnlyDay = trim($daysArray[1]); - if (! empty($adminAllowesDays) && in_array(strtoLower($slotOnlyDay), $adminAllowesDays) ) { + if ( + ! empty($adminAllowesDays) && + in_array(strtoLower($slotOnlyDay), $adminAllowesDays) + ) { $timeSlots[$key]['days'][$date] = $filterDay; } } @@ -144,18 +162,41 @@ public function getShippingTimeSlots() $dateArray = []; foreach($timeSlots as $k => $timeSlot) { - if (! $timeSlot['slotsNotAvilable']) { + if ($timeSlot['slotsNotAvilable']) { foreach ($timeSlot['days'] as $key => $finalDays) { $dateArray[] = $key; } } - $filteredDates = array_reverse($dateArray); + $filteredDates = []; - if (! $timeSlot['slotsNotAvilable']) { - if ( count($timeSlot['days']) > $totalDaysCountByAdmin ) { + foreach($dateArray as $date) { + $filteredDates[] = strtotime($date); + } + + for($j = 0; $j < count($filteredDates); $j ++) { + for($i = 0; $i < count($filteredDates)-1; $i ++){ + + if($filteredDates[$i] > $filteredDates[$i+1]) { + $temp = $filteredDates[$i+1]; + $filteredDates[$i+1]=$filteredDates[$i]; + $filteredDates[$i]=$temp; + } + } + } + + $newFilteredDates = []; + + foreach($filteredDates as $filteredDate) { + $newFilteredDates[] = date('j F, l, Y', $filteredDate);; + } + + $filteredDates = array_reverse($newFilteredDates); + + if ($timeSlot['slotsNotAvilable']) { + if (count($timeSlot['days']) > $totalDaysCountByAdmin) { $noOfDays = count($timeSlot['days']) - $totalDaysCountByAdmin; - + for ($i = 0; $i < $noOfDays; $i++) { unset($filteredDates[$i]); } @@ -171,10 +212,10 @@ public function getShippingTimeSlots() //prepare Slots for user's end $finalTimeSlots = []; foreach ($timeSlots as $k => $filteredValue) { - if (! $filteredValue['slotsNotAvilable']) { - + if ($filteredValue['slotsNotAvilable']) { + foreach ($filteredValue['days'] as $days => $finaValue) { - if ( in_array($days, $filteredDays)) { + if (in_array($days, $filteredDays[$k])) { $finalTimeSlots[$k]['days'][$days] = $finaValue; $finalTimeSlots[$k]['seller'] = $filteredValue['seller']; $finalTimeSlots[$k]['quotas'] = $filteredValue['quotas']; @@ -185,11 +226,20 @@ public function getShippingTimeSlots() $finalTimeSlots[$k] = $filteredValue; } } - - if ( $finalTimeSlots == null ) { + + if ($finalTimeSlots == null) { + $finalTimeSlots[0]['seller'] = 'Admin'; $finalTimeSlots[0]['slotsNotAvilable'] = true; $finalTimeSlots[0]['message'] = core()->getConfigData('delivery_time_slot.settings.general.time_slot_error_message') ?: ' Warning: There are no slots avilable'; + + } elseif ( + isset($finalTimeSlots[0]['days']) && + count($finalTimeSlots[0]['days']) < 1 + ) { + $finalTimeSlots[0]['slotsNotAvilable'] = true; + } else { + $finalTimeSlots[0]['slotsNotAvilable'] = false; } return $finalTimeSlots; @@ -203,11 +253,11 @@ public function getDateWithDays() new \DateInterval('P1D'), // Define the intervals as Periods of 1 Day 6 // Apply the interval 6 times on top of the starting date ); - + foreach ($period as $day) { $dateAndDays[$day->format('l')] = $day->format('d F,Y'); } return $dateAndDays; } -} \ No newline at end of file +} diff --git a/src/Repositories/OrderRepository.php b/src/Repositories/OrderRepository.php index 44092e3..2ca5aaf 100644 --- a/src/Repositories/OrderRepository.php +++ b/src/Repositories/OrderRepository.php @@ -2,12 +2,12 @@ namespace Webkul\DeliveryTimeSlot\Repositories; -use Illuminate\Container\Container as App; use Illuminate\Support\Facades\DB; -use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Log; -use Webkul\Core\Eloquent\Repository; +use Illuminate\Support\Facades\Event; +use Illuminate\Container\Container as App; use Webkul\Sales\Contracts\Order; +use Webkul\Core\Eloquent\Repository; use Webkul\Sales\Generators\OrderSequencer; use Webkul\Sales\Repositories\OrderItemRepository; use Webkul\Sales\Repositories\DownloadableLinkPurchasedRepository; @@ -82,14 +82,20 @@ public function createOrderIfNotThenRetry(array $data) try { Event::dispatch('checkout.order.save.before', [$data]); - if (isset($data['customer']) && $data['customer']) { + if ( + isset($data['customer']) && + $data['customer'] + ) { $data['customer_id'] = $data['customer']->id; $data['customer_type'] = get_class($data['customer']); } else { unset($data['customer']); } - if (isset($data['channel']) && $data['channel']) { + if ( + isset($data['channel']) && + $data['channel'] + ) { $data['channel_id'] = $data['channel']->id; $data['channel_type'] = get_class($data['channel']); $data['channel_name'] = $data['channel']->name; @@ -102,7 +108,7 @@ public function createOrderIfNotThenRetry(array $data) $order = $this->model->create(array_merge($data, ['increment_id' => $this->generateIncrementId()])); // Delivery Time Slot Start - if ( core()->getConfigData('delivery_time_slot.settings.general.status') ) { + if (core()->getConfigData('delivery_time_slot.settings.general.status')) { $this->createDeliveryTimeSlotOrder($order); }// Delivery Time Slot End @@ -119,7 +125,10 @@ public function createOrderIfNotThenRetry(array $data) $orderItem = $this->orderItemRepository->create(array_merge($item, ['order_id' => $order->id])); - if (isset($item['children']) && $item['children']) { + if ( + isset($item['children']) && + $item['children'] + ) { foreach ($item['children'] as $child) { $this->orderItemRepository->create(array_merge($child, ['order_id' => $order->id, 'parent_id' => $orderItem->id])); } @@ -182,15 +191,21 @@ public function generateIncrementId() */ public function createDeliveryTimeSlotOrder($order) { - if (! isset($timeSlot['selected_delivery_slot']) ) { + if (! isset($timeSlot['selected_delivery_slot'])) { $timeSlot = session()->get('selected_delivery_slot'); } - if ( $order && isset($timeSlot) && $timeSlot ) { - + if ( + $order && + isset($timeSlot) && + $timeSlot + ) { foreach ($timeSlot as $key => $slot) { $sellerId = NULL; - if ( isset($slot[1]) && $slot[1]) { + if ( + isset($slot[1]) && + $slot[1] + ) { $sellerId = (int) $slot[1]; } diff --git a/src/Resources/assets/sass/admin.scss b/src/Resources/assets/sass/admin.scss index 013b923..f1fa20f 100644 --- a/src/Resources/assets/sass/admin.scss +++ b/src/Resources/assets/sass/admin.scss @@ -1,13 +1,5 @@ @import "icons"; -.navbar-left { - width: 100px; - - ul.menubar li.menu-item { - padding: 10px 7px; - } -} - .content-container { padding-left: 100px; } diff --git a/src/Resources/lang/ar/app.php b/src/Resources/lang/ar/app.php new file mode 100644 index 0000000..a6a8829 --- /dev/null +++ b/src/Resources/lang/ar/app.php @@ -0,0 +1,108 @@ + [ + 'tracking-number' => 'عدد تتبع', + 'layouts' => [ + 'delivery-time-slot' => 'فتحة وقت التسليم', + 'delivery-time-configuration' => 'تكوين وقت التسليم', + 'save-btn' => 'يحفظ' + ], + + 'email' => [ + 'customer' => [ + 'time-slots' => 'فتحات الوقت', + ], + ], + + 'seller' => [ + 'time-slot-configuration' => 'تكوين فترات زمنية', + 'delivery-order-history' => 'تاريخ أمر التسليم', + 'minimum-required-time' => 'الحد الأدنى من الوقت المطلوب في عملية الطلب:', + 'time-delivery-order' => 'أوامر التسليم في الوقت المحدد', + + 'datagrid' => [ + 'delivery-date' => 'تاريخ التسليم او الوصول', + 'orders' => 'طلب#', + 'selected-slot' => 'الفتحة المحددة', + 'purchased-on' => 'تم شراؤها على', + ], + ], + + 'checkout' => [ + 'time-slots' => 'فتحات الوقت', + 'seller' => 'تاجر', + 'time' => 'وقت', + 'date-day' => 'تاريخ اليوم', + 'admin' => 'مسؤل', + + 'cart' => [ + 'message' => 'فتحات وقت التسليم غير متوفرة لهذا المنتج.' + ] + ], + ], + + 'admin' => [ + 'layouts' => [ + 'delivery-time-slot' => 'فتحة وقت التسليم', + 'default-delivery-time' => 'خانات وقت التسليم الافتراضية', + 'save-btn' => 'حفظ التكوين', + 'select-day' => 'حدد اليوم', + 'start-time' => 'وقت البدء', + 'end-time' => 'وقت النهاية', + 'quotas' => 'الحصص', + 'delivery-orders' => 'أوامر التسليم', + 'delivery-time-slots' => 'فتحات وقت التسليم', + 'admin-delivery-time-slots' => 'فتحات وقت التسليم المسؤول', + 'delivery-slots' => 'فتحات التسليم', + 'delete-confirm' => 'هل أنت متأكد أنك تريد حذف هذا الفتحة؟', + 'start-time-error' => 'يجب أن يكون وقت البدء مختلفًا لنفس يوم التسليم.', + + 'btn' => [ + 'delete' => 'يمسح', + 'add-time-slot' => 'أضف فترة زمنية', + ], + + 'days' => [ + 'monday' => 'الاثنين', + 'tuesday' => 'يوم الثلاثاء', + 'wednesday' => 'الأربعاء', + 'thursday' => 'يوم الخميس', + 'friday' => 'جمعة', + 'saturday' => 'السبت', + 'sunday' => 'الأحد', + ], + ], + + 'datagrid' => [ + 'seller-name' => 'البائع اسم', + 'delivery-date' => 'تاريخ التسليم او الوصول', + 'order' => 'طلب#', + 'delivery-time-from' => 'وقت التسليم من', + 'delivery-time-to' => 'وقت التسليم إلى', + 'delivery-orders' => 'أوامر التسليم', + 'delivery-time-slots' => 'فتحات وقت التسليم', + 'end-time' => 'وقت النهاية', + 'start-time' => 'وقت البدء', + 'allowed-orders' => 'الطلبات المسموح بها', + 'delivery-day' => 'يوم التوصيل', + 'action' => 'أجراءات', + 'order-id' => 'رقم التعريف الخاص بالطلب', + 'customer-name' => 'اسم الزبون' + ], + + 'system' => [ + 'delivery-time-setting' => 'تحديد وقت التسليم', + 'enable' => 'يُمكَِن', + 'allowed-days' => 'الأيام المسموح بها', + 'display-total-days' => 'عرض إجمالي الأيام', + 'display-time-format' => 'تنسيق وقت العرض', + 'minimun-time' => 'الحد الأدنى من الوقت المطلوب في عملية الطلب', + 'error-message' => 'رسالة خطأ في حالة عدم توفر الفترات الزمنية.', + 'success-message' => ':name حفظ بنجاح.', + 'setting' => 'إعدادات', + 'delivery-time-slot' => 'فتحة وقت التسليم', + 'show-message' => 'عرض رسالة خطأ في المتجر إذا لم تكن الفتحات متاحة.' + ], + ], +]; \ No newline at end of file diff --git a/src/Resources/lang/en/app.php b/src/Resources/lang/en/app.php index 0189cdc..5a33923 100644 --- a/src/Resources/lang/en/app.php +++ b/src/Resources/lang/en/app.php @@ -34,7 +34,11 @@ 'seller' => 'Seller', 'time' => 'Time', 'date-day' => 'Date/Day', - 'admin' => 'Admin' + 'admin' => 'Admin', + + 'cart' => [ + 'message' => 'Delivery Time Slots are not available for this product.' + ] ], ], @@ -51,7 +55,8 @@ 'delivery-time-slots' => 'Delivery Time Slots', 'admin-delivery-time-slots' => 'Admin Delivery Time Slots', 'delivery-slots' => 'Delivery Slots', - + 'delete-confirm' => 'Are you sure you want to delete this slot?', + 'start-time-error' => 'Start time should be different for the same delivery day.', 'btn' => [ 'delete' => 'Delete', @@ -91,11 +96,13 @@ 'enable' => 'Enable', 'allowed-days' => 'Allowed Days', 'display-total-days' => 'Display Total Days', + 'display-time-format' => 'Display Time Format', 'minimun-time' => 'Minimum Required Time in Order Process', 'error-message' => 'Error Message if Time Slots not available.', 'success-message' => ':name Saved successfully.', 'setting' => 'Settings', - 'delivery-time-slot' => 'Delivery Time Slot' + 'delivery-time-slot' => 'Delivery Time Slot', + 'show-message' => 'Show error message at the shop if slots are not available.' ], ], ]; \ No newline at end of file diff --git a/src/Resources/lang/es/app.php b/src/Resources/lang/es/app.php new file mode 100644 index 0000000..0c75269 --- /dev/null +++ b/src/Resources/lang/es/app.php @@ -0,0 +1,108 @@ + [ + 'tracking-number' => 'El número de rastreo', + 'layouts' => [ + 'delivery-time-slot' => 'Horario de entrega', + 'delivery-time-configuration' => 'Configuración de tiempo de entrega', + 'save-btn' => 'Ahorrar' + ], + + 'email' => [ + 'customer' => [ + 'time-slots' => 'Ranuras de tiempo', + ], + ], + + 'seller' => [ + 'time-slot-configuration' => 'Configuración de franjas horarias', + 'delivery-order-history' => 'Historial de pedidos de entrega', + 'minimum-required-time' => 'Tiempo mínimo requerido en el proceso de pedido:', + 'time-delivery-order' => 'Órdenes de entrega a tiempo', + + 'datagrid' => [ + 'delivery-date' => 'Fecha de entrega', + 'orders' => 'Orden#', + 'selected-slot' => 'Ranura seleccionada', + 'purchased-on' => 'Comprado en', + ], + ], + + 'checkout' => [ + 'time-slots' => 'Ranuras de tiempo', + 'seller' => 'Vendedor', + 'time' => 'Tiempo', + 'date-day' => 'Dia de cita', + 'admin' => 'Administrador', + + 'cart' => [ + 'message' => 'No hay franjas horarias de entrega disponibles para este producto.' + ] + ], + ], + + 'admin' => [ + 'layouts' => [ + 'delivery-time-slot' => 'Horario de entrega', + 'default-delivery-time' => 'Intervalos de tiempo de entrega predeterminados', + 'save-btn' => 'Guardar configuración', + 'select-day' => 'Seleccionar día', + 'start-time' => 'Hora de inicio', + 'end-time' => 'Hora de finalización', + 'quotas' => 'cuotas', + 'delivery-orders' => 'Órdenes de entrega', + 'delivery-time-slots' => 'Franjas de tiempo de entrega', + 'admin-delivery-time-slots' => 'Intervalos de tiempo de entrega del administrador', + 'delivery-slots' => 'Ranuras de entrega', + 'delete-confirm' => 'Estás seguro de que deseas eliminar esta ranura?', + 'start-time-error' => 'El horario de inicio debe ser diferente para el mismo día de entrega.', + + 'btn' => [ + 'delete' => 'Borrar', + 'add-time-slot' => 'Agregar franja horaria', + ], + + 'days' => [ + 'monday' => 'Lunes', + 'tuesday' => 'Martes', + 'wednesday' => 'Miércoles', + 'thursday' => 'Jueves', + 'friday' => 'Viernes', + 'saturday' => 'Sábado', + 'sunday' => 'Domingo', + ], + ], + + 'datagrid' => [ + 'seller-name' => 'Nombre del vendedor', + 'delivery-date' => 'Fecha de entrega', + 'order' => 'Orden#', + 'delivery-time-from' => 'Plazo de entrega desde', + 'delivery-time-to' => 'Tiempo de entrega a', + 'delivery-orders' => 'Órdenes de entrega', + 'delivery-time-slots' => 'Franjas de tiempo de entrega', + 'end-time' => 'Hora de finalización', + 'start-time' => 'Hora de inicio', + 'allowed-orders' => 'Órdenes Permitidas', + 'delivery-day' => 'Dia de entrega', + 'action' => 'Comportamiento', + 'order-id' => 'Solicitar ID', + 'customer-name' => 'Nombre del cliente' + ], + + 'system' => [ + 'delivery-time-setting' => 'Configuración del tiempo de entrega', + 'enable' => 'Permitir', + 'allowed-days' => 'Días Permitidos', + 'display-total-days' => 'Mostrar días totales', + 'display-time-format' => 'Formato de tiempo de visualización', + 'minimun-time' => 'Tiempo mínimo requerido en el proceso de pedido', + 'error-message' => 'Mensaje de error si las franjas horarias no están disponibles.', + 'success-message' => ':name Guardado exitosamente.', + 'setting' => 'Ajustes', + 'delivery-time-slot' => 'Horario de entrega', + 'show-message' => 'Mostrar mensaje de error en la tienda si no hay espacios disponibles.' + ], + ], +]; \ No newline at end of file diff --git a/src/Resources/lang/fr/app.php b/src/Resources/lang/fr/app.php new file mode 100644 index 0000000..9d48fbc --- /dev/null +++ b/src/Resources/lang/fr/app.php @@ -0,0 +1,108 @@ + [ + 'tracking-number' => 'Numéro de suivi', + 'layouts' => [ + 'delivery-time-slot' => 'Plage horaire de livraison', + 'delivery-time-configuration' => "Configuration de l'heure de livraison", + 'save-btn' => 'Sauvegarder' + ], + + 'email' => [ + 'customer' => [ + 'time-slots' => 'Tranches de temps', + ], + ], + + 'seller' => [ + 'time-slot-configuration' => 'Configuration des créneaux horaires', + 'delivery-order-history' => 'Historique des commandes de livraison', + 'minimum-required-time' => 'Temps minimum requis dans le processus de commande:', + 'time-delivery-order' => 'Délai de livraison des commandes', + + 'datagrid' => [ + 'delivery-date' => 'La date de livraison', + 'orders' => 'Commande#', + 'selected-slot' => 'Emplacement sélectionné', + 'purchased-on' => 'Acheté le', + ], + ], + + 'checkout' => [ + 'time-slots' => 'Tranches de temps', + 'seller' => 'Vendeur', + 'time' => 'Temps', + 'date-day' => 'Date/Jour', + 'admin' => 'Administrateur', + + 'cart' => [ + 'message' => 'Les créneaux horaires de livraison ne sont pas disponibles pour ce produit.' + ] + ], + ], + + 'admin' => [ + 'layouts' => [ + 'delivery-time-slot' => 'Plage horaire de livraison', + 'default-delivery-time' => 'Plages horaires de livraison par défaut', + 'save-btn' => 'Enregistrer la configuration', + 'select-day' => 'Sélectionnez le jour', + 'start-time' => 'Heure de début', + 'end-time' => 'Heure de fin', + 'quotas' => 'Quotas', + 'delivery-orders' => 'Bons de livraison', + 'delivery-time-slots' => 'Plages horaires de livraison', + 'admin-delivery-time-slots' => 'Créneaux horaires de livraison pour les administrateurs', + 'delivery-slots' => 'Créneaux de livraison', + 'delete-confirm' => 'Êtes-vous sûr de vouloir supprimer cet emplacement ?', + 'start-time-error' => 'L\'heure de début doit être différente pour le même jour de livraison.', + + 'btn' => [ + 'delete' => 'Supprimer', + 'add-time-slot' => 'Ajouter un créneau horaire', + ], + + 'days' => [ + 'monday' => 'Lundi', + 'tuesday' => 'Mardi', + 'wednesday' => 'Mercredi', + 'thursday' => 'Jeudi', + 'friday' => 'Vendredi', + 'saturday' => 'Samedi', + 'sunday' => 'Dimanche', + ], + ], + + 'datagrid' => [ + 'seller-name' => 'Nom du Vendeur', + 'delivery-date' => 'La date de livraison', + 'order' => 'Commande#', + 'delivery-time-from' => 'Délai de livraison à partir de', + 'delivery-time-to' => "Délai de livraison jusqu'à", + 'delivery-orders' => 'Bons de livraison', + 'delivery-time-slots' => 'Plages horaires de livraison', + 'end-time' => 'Heure de fin', + 'start-time' => 'Heure de début', + 'allowed-orders' => 'Commandes autorisées', + 'delivery-day' => 'Jour de livraison', + 'action' => 'Actions', + 'order-id' => 'numéro de commande', + 'customer-name' => 'Nom du client' + ], + + 'system' => [ + 'delivery-time-setting' => 'Réglage du délai de livraison', + 'enable' => 'Activer', + 'allowed-days' => 'Jours autorisés', + 'display-total-days' => 'Afficher le nombre total de jours', + 'display-time-format' => 'Format de l\'heure d\'affichage', + 'minimun-time' => 'Temps minimum requis dans le processus de commande', + 'error-message' => "Message d'erreur si les créneaux horaires ne sont pas disponibles.", + 'success-message' => ':name Enregistré avec succès.', + 'setting' => 'Paramètres', + 'delivery-time-slot' => 'Plage horaire de livraison', + 'show-message' => "Afficher un message d'erreur à la boutique si les créneaux ne sont pas disponibles." + ], + ], +]; \ No newline at end of file diff --git a/src/Resources/lang/nl/app.php b/src/Resources/lang/nl/app.php new file mode 100644 index 0000000..5708898 --- /dev/null +++ b/src/Resources/lang/nl/app.php @@ -0,0 +1,108 @@ + [ + 'tracking-number' => 'Volg nummer', + 'layouts' => [ + 'delivery-time-slot' => 'Bezorgtijdslot', + 'delivery-time-configuration' => 'Configuratie van tijdlevering', + 'save-btn' => 'Redden' + ], + + 'email' => [ + 'customer' => [ + 'time-slots' => 'Tijdslots', + ], + ], + + 'seller' => [ + 'time-slot-configuration' => 'Configuratie van tijdslots', + 'delivery-order-history' => 'Geschiedenis van leveringsorders', + 'minimum-required-time' => 'Minimaal vereiste tijd in bestelproces:', + 'time-delivery-order' => 'Bestellingen voor tijdslevering', + + 'datagrid' => [ + 'delivery-date' => 'Bezorgdatum', + 'orders' => 'Volgorde#', + 'selected-slot' => 'Geselecteerde gokkast', + 'purchased-on' => 'Gekocht op', + ], + ], + + 'checkout' => [ + 'time-slots' => 'Tijdslots', + 'seller' => 'Verkoper', + 'time' => 'Tijd', + 'date-day' => 'Datum/Dag', + 'admin' => 'beheerder', + + 'cart' => [ + 'message' => 'Tijdvakken voor bezorging zijn niet beschikbaar voor dit product.' + ] + ], + ], + + 'admin' => [ + 'layouts' => [ + 'delivery-time-slot' => 'Bezorgtijdslot', + 'default-delivery-time' => 'Standaard levertijden', + 'save-btn' => 'Bewaar configuratie', + 'select-day' => 'Selecteer Dag', + 'start-time' => 'Starttijd', + 'end-time' => 'Eindtijd', + 'quotas' => 'quota', + 'delivery-orders' => 'Bezorg bestellingen', + 'delivery-time-slots' => 'Levertijd slots', + 'admin-delivery-time-slots' => 'Bezorgtijdslots voor beheerders', + 'delivery-slots' => 'Leveringsslots', + 'delete-confirm' => 'Weet je zeker dat je deze sleuf wilt verwijderen?', + 'start-time-error' => 'De starttijd moet verschillend zijn voor dezelfde bezorgdag.', + + 'btn' => [ + 'delete' => 'Delete', + 'add-time-slot' => 'Tijdslot toevoegen', + ], + + 'days' => [ + 'monday' => 'Maandag', + 'tuesday' => 'Dinsdag', + 'wednesday' => 'Woensdag', + 'thursday' => 'Donderdag', + 'friday' => 'Vrijdag', + 'saturday' => 'Zaterdag', + 'sunday' => 'Zondag', + ], + ], + + 'datagrid' => [ + 'seller-name' => 'Naam van de verkoper', + 'delivery-date' => 'Bezorgdatum', + 'order' => 'Volgorde#', + 'delivery-time-from' => 'Levertijd vanaf', + 'delivery-time-to' => 'Levertijd tot', + 'delivery-orders' => 'Bezorg bestellingen', + 'delivery-time-slots' => 'Levertijd slots', + 'end-time' => 'Eindtijd', + 'start-time' => 'Starttijd', + 'allowed-orders' => 'Toegestane bestellingen', + 'delivery-day' => 'Dag van bezorging', + 'action' => 'Acties', + 'order-id' => 'Order ID', + 'customer-name' => 'klantnaam' + ], + + 'system' => [ + 'delivery-time-setting' => 'Instelling bezorgtijd', + 'enable' => 'Inschakelen', + 'allowed-days' => 'Toegestane dagen', + 'display-total-days' => 'Totaal aantal dagen weergeven', + 'display-time-format' => 'Tijdformaat weergeven', + 'minimun-time' => 'Minimaal benodigde tijd in bestelproces', + 'error-message' => 'Foutmelding als tijdslots niet beschikbaar zijn.', + 'success-message' => ':name Met succes opgeslagen.', + 'setting' => 'Instellingen', + 'delivery-time-slot' => 'Bezorgtijdslot', + 'show-message' => 'Toon foutmelding in de winkel als slots niet beschikbaar zijn.' + ], + ], +]; \ No newline at end of file diff --git a/src/Resources/lang/tr/app.php b/src/Resources/lang/tr/app.php new file mode 100644 index 0000000..77c3456 --- /dev/null +++ b/src/Resources/lang/tr/app.php @@ -0,0 +1,108 @@ + [ + 'tracking-number' => 'Takip numarası', + 'layouts' => [ + 'delivery-time-slot' => 'Teslim Süresi Yuvası', + 'delivery-time-configuration' => 'Zamanında Teslimat Yapılandırması', + 'save-btn' => 'Kaydetmek' + ], + + 'email' => [ + 'customer' => [ + 'time-slots' => 'Zaman dilimleri', + ], + ], + + 'seller' => [ + 'time-slot-configuration' => 'Zaman Yuvaları Yapılandırması', + 'delivery-order-history' => 'Teslimat Siparişi Geçmişi', + 'minimum-required-time' => 'Sipariş Sürecinde Gerekli Minimum Süre:', + 'time-delivery-order' => 'Zamanında Teslimat Siparişleri', + + 'datagrid' => [ + 'delivery-date' => 'Teslim tarihi', + 'orders' => 'Emir#', + 'selected-slot' => 'Seçilen Yuva', + 'purchased-on' => 'Tarihinde satın alındı', + ], + ], + + 'checkout' => [ + 'time-slots' => 'Zaman dilimleri', + 'seller' => 'satıcı', + 'time' => 'Zaman', + 'date-day' => 'Randevu günü', + 'admin' => 'yönetici', + + 'cart' => [ + 'message' => 'Bu ürün için teslimat zaman aralıkları mevcut değil.' + ] + ], + ], + + 'admin' => [ + 'layouts' => [ + 'delivery-time-slot' => 'Teslim Süresi Yuvası', + 'default-delivery-time' => 'Varsayılan Teslim Süresi Aralıkları', + 'save-btn' => 'Yapılandırmayı Kaydet', + 'select-day' => 'Gün Seç', + 'start-time' => 'Başlangıç ​​saati', + 'end-time' => 'Bitiş zamanı', + 'quotas' => 'kotalar', + 'delivery-orders' => 'Teslimat Siparişleri', + 'delivery-time-slots' => 'Teslim Süresi Aralıkları', + 'admin-delivery-time-slots' => 'Yönetici Teslim Süresi Aralıkları', + 'delivery-slots' => 'Teslimat Yuvaları', + 'delete-confirm' => 'Bu yuvası silmek istediğinizden emin misiniz?', + 'start-time-error' => 'Aynı teslim günü için başlangıç ​​saati farklı olmalıdır.', + + 'btn' => [ + 'delete' => 'Silmek', + 'add-time-slot' => 'Zaman Aralığı Ekle', + ], + + 'days' => [ + 'monday' => 'Pazartesi', + 'tuesday' => 'Salı', + 'wednesday' => 'Çarşamba', + 'thursday' => 'Perşembe', + 'friday' => 'Cuma', + 'saturday' => 'Cumartesi', + 'sunday' => 'Pazar', + ], + ], + + 'datagrid' => [ + 'seller-name' => 'Satıcı Adı', + 'delivery-date' => 'Teslim tarihi', + 'order' => 'Emir#', + 'delivery-time-from' => 'Teslim Süresi', + 'delivery-time-to' => 'Teslim Süresi', + 'delivery-orders' => 'Teslimat Siparişleri', + 'delivery-time-slots' => 'Teslim Süresi Aralıkları', + 'end-time' => 'Bitiş zamanı', + 'start-time' => 'Başlangıç ​​saati', + 'allowed-orders' => 'İzin Verilen Siparişler', + 'delivery-day' => 'Teslim günü', + 'action' => 'Hareketler', + 'order-id' => 'Sipariş Kimliği', + 'customer-name' => 'müşteri adı' + ], + + 'system' => [ + 'delivery-time-setting' => 'Teslim Süresi Ayarı', + 'enable' => 'Olanak vermek', + 'allowed-days' => 'İzin Verilen Günler', + 'display-total-days' => 'Toplam Günleri Görüntüle', + 'display-time-format' => 'Görüntüleme Saati Formatı', + 'minimun-time' => 'Sipariş Sürecinde Gerekli Minimum Süre', + 'error-message' => 'Zaman Yuvaları yoksa Hata Mesajı.', + 'success-message' => ':name Başarıyla kaydedildi.', + 'setting' => 'Ayarlar', + 'delivery-time-slot' => 'Teslim Süresi Yuvası', + 'show-message' => 'Yuva yoksa mağazada hata mesajı göster.' + ], + ], +]; \ No newline at end of file diff --git a/src/Resources/views/admin/configuration/index.blade.php b/src/Resources/views/admin/configuration/index.blade.php index ddb95a6..6de27c7 100644 --- a/src/Resources/views/admin/configuration/index.blade.php +++ b/src/Resources/views/admin/configuration/index.blade.php @@ -5,12 +5,14 @@ @stop @section('content') - + +@push('css') + +@endpush
@@ -40,86 +42,95 @@
@csrf()
-
-
+
+
- + @{{ errors.first('minimum_time_required') }} Enter number of days, e.g: 5
- - - - - - - - - - - - - - - - - + + + + +
{{ __('delivery-time-slot::app.admin.layouts.select-day') }}{{ __('delivery-time-slot::app.admin.layouts.start-time') }}{{ __('delivery-time-slot::app.admin.layouts.end-time') }}{{ __('delivery-time-slot::app.admin.layouts.quotas') }}
-
- -
-
- -
- - - Start Time should be less Than End Time +
+ + + + + + + + + + + + + + + - End Time should be greater Than Start Time + + + - - - -
{{ __('delivery-time-slot::app.admin.layouts.select-day') }}{{ __('delivery-time-slot::app.admin.layouts.start-time') }}{{ __('delivery-time-slot::app.admin.layouts.end-time') }}{{ __('delivery-time-slot::app.admin.layouts.quotas') }}{{ __('admin::app.status') }}
+
+
- -
+ +
+ -
- -
- + Start Time should be less Than End Time +
+
+
+ +
+ + End Time should be greater Than Start Time + +
+
+ +
+
+ +
+
+
+
- - -
-
- -
-
- - {{ __('delivery-time-slot::app.admin.layouts.btn.delete') }} - -
+
+ + {{ __('delivery-time-slot::app.admin.layouts.btn.delete') }} + +
+
{{ __('delivery-time-slot::app.admin.layouts.btn.add-time-slot') }} @@ -152,6 +163,7 @@ start_time : "", end_time : "", time_delivery_quota : "", + visibility : "", is_seller : 0, }], } @@ -165,6 +177,7 @@ start_time : this.data[i].start_time, end_time : this.data[i].end_time, time_delivery_quota : this.data[i].time_delivery_quota, + visibility : this.data[i].visibility, is_seller: 0 }); } @@ -177,13 +190,14 @@ methods: { addInput() { - console.log(this.inputs); + this.inputs.push({ id: '', delivery_day : '', start_time: '', end_time: '', time_delivery_quota: '', + visibility: '', is_seller: 0, is_required: false, validate: { @@ -193,7 +207,9 @@ }, removeInput(index) { - this.$delete(this.inputs, index); + if (confirm(`{{ __('delivery-time-slot::app.admin.layouts.delete-confirm') }}`)) { + this.$delete(this.inputs, index); + } }, validateEndTime(start_time, event, index, endTime, setEndTime) { @@ -260,16 +276,22 @@ }, onSubmit: function (e) { - this.$validator.validateAll().then(result => { - for (var i = 0; i < this.inputs.length; i++) { - var startTime = this.inputs[i].start_time_execption; - var endTime = this.inputs[i].end_time_execption; - if (startTime === true || endTime === true) { - return e.preventDefault(); + this.$validator.validateAll().then(result => { + if (result) { + for (var i = 0; i < this.inputs.length; i++) { + + var startTime = this.inputs[i].start_time_execption; + var endTime = this.inputs[i].end_time_execption; + if (startTime === true || endTime === true) { + return e.preventDefault(); + } } + e.target.submit(); + } else { + alert('Field should not be empty.'); } - e.target.submit(); + }); }, }, diff --git a/src/Resources/views/admin/layouts/master.blade.php b/src/Resources/views/admin/layouts/master.blade.php index e486ea9..f393c77 100644 --- a/src/Resources/views/admin/layouts/master.blade.php +++ b/src/Resources/views/admin/layouts/master.blade.php @@ -2,25 +2,21 @@ @section('content-wrapper')
- - @include ('admin::layouts.nav-aside') -
@include ('admin::layouts.tabs') - + @yield('content')
-
@push('css') - + @endpush @push('scripts') - @endpush @stop diff --git a/src/Resources/views/admin/layouts/nav-left.blade.php b/src/Resources/views/admin/layouts/nav-left.blade.php new file mode 100755 index 0000000..cd24b2f --- /dev/null +++ b/src/Resources/views/admin/layouts/nav-left.blade.php @@ -0,0 +1,92 @@ +@php + $tree = \Webkul\Core\Tree::create(); + + foreach (config('core') as $item) { + $tree->add($item); + } + + $tree->items = core()->sortItems($tree->items); + + $config = $tree; + + $allLocales = core()->getAllLocales()->pluck('name', 'code'); +@endphp + +
+ +@push('scripts') + + + +@endpush \ No newline at end of file diff --git a/src/Resources/views/admin/layouts/style.blade.php b/src/Resources/views/admin/layouts/style.blade.php index 6ab4174..bf621fe 100644 --- a/src/Resources/views/admin/layouts/style.blade.php +++ b/src/Resources/views/admin/layouts/style.blade.php @@ -1 +1,2 @@ - \ No newline at end of file + + diff --git a/src/Resources/views/admin/marketplace/timeslots/delivery-orders.blade.php b/src/Resources/views/admin/marketplace/timeslots/delivery-orders.blade.php index 6c92f55..b96d4b0 100644 --- a/src/Resources/views/admin/marketplace/timeslots/delivery-orders.blade.php +++ b/src/Resources/views/admin/marketplace/timeslots/delivery-orders.blade.php @@ -13,8 +13,10 @@
- @inject('orderGrid', 'Webkul\DeliveryTimeSlot\DataGrids\Admin\DeliveyOrdersDataGrid') - {!! $orderGrid->render() !!} + +
@endsection \ No newline at end of file diff --git a/src/Resources/views/admin/marketplace/timeslots/delivery-time-slots.blade.php b/src/Resources/views/admin/marketplace/timeslots/delivery-time-slots.blade.php index fb2a1ac..fdd9636 100644 --- a/src/Resources/views/admin/marketplace/timeslots/delivery-time-slots.blade.php +++ b/src/Resources/views/admin/marketplace/timeslots/delivery-time-slots.blade.php @@ -13,8 +13,10 @@
- @inject('deliveryTimeSlots', 'Webkul\DeliveryTimeSlot\DataGrids\Admin\DeliveyTimeSlotsDataGrid') - {!! $deliveryTimeSlots->render() !!} + +
@endsection \ No newline at end of file diff --git a/src/Resources/views/admin/sales/invoices/create.blade.php b/src/Resources/views/admin/sales/invoices/create.blade.php index 5caaecb..f11771a 100755 --- a/src/Resources/views/admin/sales/invoices/create.blade.php +++ b/src/Resources/views/admin/sales/invoices/create.blade.php @@ -28,254 +28,259 @@
- +
-
-
- {{ __('admin::app.sales.orders.order-info') }} -
+
+
+
+ {{ __('admin::app.sales.orders.order-info') }} +
-
-
- - {{ __('admin::app.sales.invoices.order-id') }} - +
+
+ + {{ __('admin::app.sales.invoices.order-id') }} + - - #{{ $order->increment_id }} - -
+ + #{{ $order->increment_id }} + +
-
- - {{ __('admin::app.sales.orders.order-date') }} - +
+ + {{ __('admin::app.sales.orders.order-date') }} + - - {{ $order->created_at }} - -
+ + {{ $order->created_at }} + +
-
- - {{ __('admin::app.sales.orders.order-status') }} - +
+ + {{ __('admin::app.sales.orders.order-status') }} + - - {{ $order->status_label }} - -
+ + {{ $order->status_label }} + +
-
- - {{ __('admin::app.sales.orders.channel') }} - +
+ + {{ __('admin::app.sales.orders.channel') }} + - - {{ $order->channel_name }} - + + {{ $order->channel_name }} + +
-
-
-
- {{ __('admin::app.sales.orders.account-info') }} -
+
+
+ {{ __('admin::app.sales.orders.account-info') }} +
-
-
- - {{ __('admin::app.sales.orders.customer-name') }} - +
+
+ + {{ __('admin::app.sales.orders.customer-name') }} + - - {{ $order->customer_full_name }} - -
+ + {{ $order->customer_full_name }} + +
-
- - {{ __('admin::app.sales.orders.email') }} - +
+ + {{ __('admin::app.sales.orders.email') }} + - - {{ $order->customer_email }} - + + {{ $order->customer_email }} + +
-
- +
- +
- -
-
- {{ __('admin::app.sales.orders.billing-address') }} -
- -
- - @include ('admin::sales.address', ['address' => $order->billing_address]) - -
-
- - @if ($order->shipping_address) +
- {{ __('admin::app.sales.orders.shipping-address') }} + {{ __('admin::app.sales.orders.billing-address') }}
- @include ('admin::sales.address', ['address' => $order->shipping_address]) + @include ('admin::sales.address', ['address' => $order->billing_address])
- @endif - -
- - - -
- -
-
- {{ __('admin::app.sales.orders.payment-info') }} -
- -
-
- - {{ __('admin::app.sales.orders.payment-method') }} - - - - {{ core()->getConfigData('sales.paymentmethods.' . $order->payment->method . '.title') }} - -
- -
- - {{ __('admin::app.sales.orders.currency') }} - - - {{ $order->order_currency_code }} - -
+ @if ($order->shipping_address) +
+
+ {{ __('admin::app.sales.orders.shipping-address') }} +
- @php $additionalDetails = \Webkul\Payment\Payment::getAdditionalDetails($order->payment->method); @endphp +
- @if (! empty($additionalDetails)) -
- - {{ $additionalDetails['title'] }} - + @include ('admin::sales.address', ['address' => $order->shipping_address]) - - {{ $additionalDetails['value'] }} -
- @endif -
-
+
+ @endif +
+
+
- @if ($order->shipping_address) + +
+
- {{ __('admin::app.sales.orders.shipping-info') }} + {{ __('admin::app.sales.orders.payment-info') }}
- {{ __('admin::app.sales.orders.shipping-method') }} + {{ __('admin::app.sales.orders.payment-method') }} - {{ $order->shipping_title }} + {{ core()->getConfigData('sales.paymentmethods.' . $order->payment->method . '.title') }}
- {{ __('admin::app.sales.orders.shipping-price') }} + {{ __('admin::app.sales.orders.currency') }} - {{ core()->formatBasePrice($order->base_shipping_amount) }} + {{ $order->order_currency_code }}
+ + @php $additionalDetails = \Webkul\Payment\Payment::getAdditionalDetails($order->payment->method); @endphp + + @if (! empty($additionalDetails)) +
+ + {{ $additionalDetails['title'] }} + + + + {{ $additionalDetails['value'] }} + +
+ @endif
- @endif + + @if ($order->shipping_address) +
+
+ {{ __('admin::app.sales.orders.shipping-info') }} +
+ +
+
+ + {{ __('admin::app.sales.orders.shipping-method') }} + + + + {{ $order->shipping_title }} + +
+ +
+ + {{ __('admin::app.sales.orders.shipping-price') }} + + + + {{ core()->formatBasePrice($order->base_shipping_amount) }} + +
+
+
+ @endif +
- +
- - - - - - - - - - - - - @foreach ($order->items as $item) - @if ($item->qty_to_invoice > 0) - - - + + @endif + @endforeach + + +
{{ __('admin::app.sales.orders.SKU') }}{{ __('admin::app.sales.orders.product-name') }}{{ __('admin::app.sales.invoices.qty-ordered') }}{{ __('admin::app.sales.invoices.qty-to-invoice') }}
{{ $item->getTypeInstance()->getOrderedItem($item)->sku }} - {{ $item->name }} - - @if (isset($item->additional['attributes'])) -
- - @foreach ($item->additional['attributes'] as $attribute) - {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
- @endforeach - +
+ + + + + + + + + + + + + @foreach ($order->items as $item) + @if ($item->qty_to_invoice > 0) + + + + + + + - - - - @endif - @endforeach - - -
{{ __('admin::app.sales.orders.SKU') }}{{ __('admin::app.sales.orders.product-name') }}{{ __('admin::app.sales.invoices.qty-ordered') }}{{ __('admin::app.sales.invoices.qty-to-invoice') }}
{{ $item->getTypeInstance()->getOrderedItem($item)->sku }} + {{ $item->name }} + + @if (isset($item->additional['attributes'])) +
+ + @foreach ($item->additional['attributes'] as $attribute) + {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
+ @endforeach + +
+ @endif + + @if ( core()->getConfigData('delivery_time_slot.settings.general.status') && isset($timeSlotData) ) + @include('delivery-time-slot::admin.sales.orders.delivery-time-slot', ['item' => $item, 'timeSlotData' => $timeSlotData]) + @endif +
{{ $item->qty_ordered }} +
+ + + + @verbatim + {{ errors.first('invoice[items][id ?>]') }} + @endverbatim +
- @endif - - @if ( core()->getConfigData('delivery_time_slot.settings.general.status') && isset($timeSlotData) ) - @include('delivery-time-slot::admin.sales.orders.delivery-time-slot', ['item' => $item, 'timeSlotData' => $timeSlotData]) - @endif -
{{ $item->qty_ordered }} -
- - - - @verbatim - {{ errors.first('invoice[items][id ?>]') }} - @endverbatim - -
-
+
+
-
diff --git a/src/Resources/views/admin/sales/invoices/view.blade.php b/src/Resources/views/admin/sales/invoices/view.blade.php index 00d5d63..5db1924 100755 --- a/src/Resources/views/admin/sales/invoices/view.blade.php +++ b/src/Resources/views/admin/sales/invoices/view.blade.php @@ -5,8 +5,9 @@ @stop @section('content-wrapper') - - order; ?> + @php + $order = $invoice->order; + @endphp