From 19a27e0e9d8f72f6ba3884fa5d89648a6d893059 Mon Sep 17 00:00:00 2001 From: Jan Date: Thu, 1 Jun 2017 10:58:48 +0200 Subject: [PATCH] 3.0.0RC8 3.0.0RC8 --- config.xml | 50 +- controller.php | 4 +- .../phocacarteditproductpointgroup.php | 48 + .../phocacarteditproductpricegroup.php | 48 + .../phocacarteditproductpricehistory.php | 48 + controllers/phocacartexport.json.php | 2 +- controllers/phocacartformfields.php | 32 +- controllers/phocacartgroup.php | 12 + controllers/phocacartgroups.php | 18 + controllers/phocacartimport.json.php | 2 +- controllers/phocacartimport.php | 3 +- controllers/phocacartitem.php | 3 + controllers/phocacartpayments.php | 49 + controllers/phocacartreward.php | 12 + controllers/phocacartrewards.php | 18 + controllers/phocacartshipping.php | 3 +- controllers/phocacartshippings.php | 49 + controllers/phocacartuser.php | 3 + controllers/phocacartwizard.json.php | 2 +- helpers/phocacartgroups.php | 12 + helpers/phocacartrewards.php | 12 + install/script.php | 12 +- install/sql/mysql/install.utf8.sql | 428 +++-- install/sql/mysql/uninstall.utf8.sql | 8 + language/en-GB/en-GB.com_phocacart.ini | 154 +- language/en-GB/en-GB.com_phocacart.sys.ini | 6 + layouts/product_export.php | 224 +++ layouts/product_import.php | 237 ++- libraries/loader.php | 8 +- libraries/phocacart/captcha/captcha.php | 33 + libraries/phocacart/cart/calculation.php | 281 ++- libraries/phocacart/cart/cart.php | 113 +- libraries/phocacart/cart/db.php | 7 +- libraries/phocacart/cart/rendercart.php | 1 + libraries/phocacart/category/category.php | 6 + libraries/phocacart/category/multiple.php | 2 + libraries/phocacart/compare/compare.php | 16 +- libraries/phocacart/coupon/coupon.php | 31 +- libraries/phocacart/discount/cart.php | 105 +- libraries/phocacart/discount/product.php | 91 +- libraries/phocacart/download/download.php | 2 +- libraries/phocacart/email/email.php | 86 +- libraries/phocacart/form/items.php | 53 +- libraries/phocacart/form/user.php | 13 +- libraries/phocacart/group/group.php | 500 +++++ libraries/phocacart/group/index.html | 1 + libraries/phocacart/html/jgrid.php | 37 +- libraries/phocacart/image/magic.php | 2 +- libraries/phocacart/order/order.php | 102 +- libraries/phocacart/order/render.php | 69 +- libraries/phocacart/order/status.php | 193 +- libraries/phocacart/order/view.php | 45 +- libraries/phocacart/ordering/ordering.php | 2 +- libraries/phocacart/pagination/pagination.php | 2 +- libraries/phocacart/payment/payment.php | 54 +- libraries/phocacart/price/history.php | 252 +++ libraries/phocacart/price/price.php | 20 +- libraries/phocacart/product/product.php | 106 +- libraries/phocacart/region/region.php | 2 +- libraries/phocacart/related/related.php | 8 +- libraries/phocacart/render/adminview.php | 147 +- libraries/phocacart/render/adminviews.php | 37 +- libraries/phocacart/render/front.php | 30 +- libraries/phocacart/render/js.php | 1711 +++++++++-------- libraries/phocacart/render/media.php | 47 +- libraries/phocacart/reward/index.html | 1 + libraries/phocacart/reward/reward.php | 156 ++ libraries/phocacart/shipping/shipping.php | 84 +- libraries/phocacart/statistics/statistics.php | 106 + libraries/phocacart/user/user.php | 30 +- libraries/phocacart/utils/batchhelper.php | 19 +- libraries/phocacart/utils/utils.php | 25 + libraries/phocacart/wishlist/wishlist.php | 17 +- media/css/administrator/phocacart.css | 65 +- media/css/administrator/phocacartcustom.css | 12 +- media/css/administrator/phocacarttheme.css | 98 +- media/css/main.css | 56 +- media/js/chosen/chosen-bootstrap.css | 6 - media/js/chosen/chosen.required.js | 36 +- models/fields/phocacartgroups.php | 46 + models/fields/phocacartregions.php | 2 +- models/fields/phocapluginmethod.php | 3 +- models/fields/phocaselectitem.php | 33 +- models/fields/phocaselectitemcategory.php | 54 + models/forms/phocacartcategory.xml | 8 +- models/forms/phocacartcountry.xml | 2 +- models/forms/phocacartcoupon.xml | 8 +- models/forms/phocacartcurrency.xml | 2 +- models/forms/phocacartdiscount.xml | 10 +- models/forms/phocacartdownload.xml | 2 +- models/forms/phocacartfeed.xml | 2 +- models/forms/phocacartformfield.xml | 24 +- models/forms/phocacartgroup.xml | 51 + models/forms/phocacartitem.xml | 11 +- models/forms/phocacartmanufacturer.xml | 4 +- models/forms/phocacartorder.xml | 8 + models/forms/phocacartpayment.xml | 9 +- models/forms/phocacartquestion.xml | 4 +- models/forms/phocacartregion.xml | 2 +- models/forms/phocacartreview.xml | 4 +- models/forms/phocacartreward.xml | 55 + models/forms/phocacartshipping.xml | 48 +- models/forms/phocacartspecification.xml | 2 +- models/forms/phocacartstatus.xml | 25 +- models/forms/phocacartstockstatus.xml | 4 +- models/forms/phocacarttag.xml | 2 +- models/forms/phocacartuser.xml | 6 + models/forms/phocacartwishlist.xml | 4 +- models/forms/phocacartzone.xml | 2 +- models/phocacartcategory.php | 21 +- models/phocacartcoupon.php | 24 +- models/phocacartdiscount.php | 23 +- models/phocacartdiscounts.php | 2 +- models/phocacarteditproductpointgroup.php | 24 + models/phocacarteditproductpricegroup.php | 24 + models/phocacarteditproductpricehistory.php | 24 + models/phocacarteditstatus.php | 2 +- models/phocacarteditstockadvanced.php | 2 +- models/phocacartformfield.php | 166 +- models/phocacartformfields.php | 2 + models/phocacartgroup.php | 186 ++ models/phocacartgroups.php | 134 ++ models/phocacartitem.php | 36 +- models/phocacartpayment.php | 70 + models/phocacartreward.php | 78 + models/phocacartrewards.php | 147 ++ models/phocacartshipping.php | 71 + models/phocacartstatus.php | 66 + models/phocacartuser.php | 43 +- models/phocacartusers.php | 26 +- models/phocacartzones.php | 10 - other/index.html | 1 - other/install_xml.php | 129 -- phocacart.php | 56 +- phocacart.xml | 8 +- site/controller.php | 2 +- site/controllers/checkout.json.php | 10 +- site/controllers/checkout.php | 39 +- site/controllers/comparison.json.php | 4 +- site/controllers/wishlist.json.php | 6 +- site/helpers/route.php | 71 +- site/layouts/button_add_to_cart_list.php | 112 +- site/layouts/cart_cart.php | 10 + site/layouts/cart_checkout.php | 34 + site/layouts/form_filter_text.php | 2 +- site/layouts/popup_quickview.php | 3 +- site/models/categories.php | 7 +- site/models/category.php | 33 +- site/models/checkout.php | 3 +- site/models/fields/phocacaptcha.php | 2 + site/models/forms/question.xml | 4 +- site/models/item.php | 86 +- site/models/items.php | 23 +- site/models/orders.php | 4 +- site/models/question.php | 2 +- site/phocacart.php | 56 +- site/router.php | 34 +- site/views/account/view.html.php | 6 +- site/views/categories/tmpl/default.php | 3 +- site/views/categories/view.html.php | 18 +- site/views/category/tmpl/default.php | 42 +- site/views/category/tmpl/default_header.php | 3 + .../category/tmpl/default_pagination.php | 4 +- site/views/category/view.html.php | 40 +- site/views/category/view.raw.php | 28 +- site/views/checkout/tmpl/default.php | 8 +- site/views/checkout/tmpl/default_address.php | 34 +- site/views/checkout/tmpl/default_confirm.php | 17 + site/views/checkout/tmpl/default_payment.php | 23 +- site/views/checkout/tmpl/default_shipping.php | 3 +- site/views/checkout/view.html.php | 112 +- site/views/comparison/tmpl/default.php | 4 +- site/views/comparison/view.html.php | 10 +- site/views/download/view.html.php | 12 +- site/views/item/tmpl/default.php | 66 +- site/views/item/tmpl/default.xml | 20 +- site/views/item/tmpl/default_quickview.php | 207 ++ site/views/item/view.html.php | 56 +- site/views/item/view.json.php | 266 +-- site/views/items/tmpl/default.php | 39 +- site/views/items/tmpl/default_header.php | 2 + site/views/items/tmpl/default_pagination.php | 4 +- site/views/items/view.html.php | 34 +- site/views/items/view.raw.php | 25 +- site/views/orders/tmpl/default.php | 29 +- site/views/orders/view.html.php | 8 +- site/views/question/tmpl/default.php | 2 +- site/views/question/view.html.php | 7 +- site/views/terms/view.html.php | 4 +- site/views/wishlist/tmpl/default.php | 4 +- site/views/wishlist/view.html.php | 6 +- tables/phocacartgroup.php | 20 + tables/phocacartpayment.php | 12 + tables/phocacartproductpointgroup.php | 20 + tables/phocacartproductpricegroup.php | 20 + tables/phocacartproductpricehistory.php | 20 + tables/phocacartrewardpoint.php | 27 + tables/phocacartshipping.php | 12 + views/phocacartcategory/tmpl/edit.php | 2 +- views/phocacartcoupon/tmpl/edit.php | 2 +- views/phocacartcp/view.html.php | 4 +- views/phocacartdiscount/tmpl/edit.php | 2 +- .../phocacarteditproductpointgroup/index.html | 1 + .../tmpl/default.php | 101 + .../tmpl/index.html | 1 + .../view.html.php | 46 + .../phocacarteditproductpricegroup/index.html | 1 + .../tmpl/default.php | 106 + .../tmpl/index.html | 1 + .../view.html.php | 46 + .../index.html | 1 + .../tmpl/default.php | 87 + .../tmpl/index.html | 1 + .../view.html.php | 43 + views/phocacarteditstatus/tmpl/default.php | 17 + .../phocacarteditstockadvanced/view.html.php | 4 +- views/phocacartformfield/tmpl/edit.php | 2 +- views/phocacartformfield/view.html.php | 7 + views/phocacartformfields/tmpl/default.php | 12 +- views/phocacartformfields/view.html.php | 5 +- views/phocacartgroup/index.html | 1 + views/phocacartgroup/tmpl/edit.php | 79 + views/phocacartgroup/tmpl/index.html | 1 + views/phocacartgroup/view.html.php | 72 + views/phocacartgroups/index.html | 1 + views/phocacartgroups/tmpl/default.php | 136 ++ views/phocacartgroups/tmpl/index.html | 1 + views/phocacartgroups/view.html.php | 86 + views/phocacartitem/tmpl/edit.php | 55 +- views/phocacartitema/view.json.php | 8 +- views/phocacartmanager/view.html.php | 6 +- views/phocacartorder/tmpl/edit.php | 20 +- views/phocacartpayment/tmpl/edit.php | 4 +- views/phocacartpayments/tmpl/default.php | 11 +- views/phocacartpayments/view.html.php | 5 + views/phocacartreward/index.html | 1 + views/phocacartreward/tmpl/edit.php | 53 + views/phocacartreward/tmpl/index.html | 1 + views/phocacartreward/view.html.php | 64 + views/phocacartrewards/index.html | 1 + views/phocacartrewards/tmpl/default.php | 167 ++ views/phocacartrewards/tmpl/index.html | 1 + views/phocacartrewards/view.html.php | 86 + views/phocacartshipping/tmpl/edit.php | 21 +- views/phocacartshippings/tmpl/default.php | 14 +- views/phocacartshippings/view.html.php | 5 + views/phocacartstatus/tmpl/edit.php | 13 +- views/phocacartstatuses/tmpl/default.php | 3 +- views/phocacartuser/tmpl/edit.php | 12 +- views/phocacartuser/view.html.php | 30 +- views/phocacartusers/tmpl/default.php | 28 +- views/phocacartusers/view.html.php | 4 +- views/phocacartwizard/tmpl/default.php | 2 +- 253 files changed, 9228 insertions(+), 2317 deletions(-) create mode 100644 controllers/phocacarteditproductpointgroup.php create mode 100644 controllers/phocacarteditproductpricegroup.php create mode 100644 controllers/phocacarteditproductpricehistory.php create mode 100644 controllers/phocacartgroup.php create mode 100644 controllers/phocacartgroups.php create mode 100644 controllers/phocacartreward.php create mode 100644 controllers/phocacartrewards.php create mode 100644 helpers/phocacartgroups.php create mode 100644 helpers/phocacartrewards.php create mode 100644 libraries/phocacart/captcha/captcha.php create mode 100644 libraries/phocacart/group/group.php create mode 100644 libraries/phocacart/group/index.html create mode 100644 libraries/phocacart/price/history.php create mode 100644 libraries/phocacart/reward/index.html create mode 100644 libraries/phocacart/reward/reward.php create mode 100644 models/fields/phocacartgroups.php create mode 100644 models/fields/phocaselectitemcategory.php create mode 100644 models/forms/phocacartgroup.xml create mode 100644 models/forms/phocacartreward.xml create mode 100644 models/phocacarteditproductpointgroup.php create mode 100644 models/phocacarteditproductpricegroup.php create mode 100644 models/phocacarteditproductpricehistory.php create mode 100644 models/phocacartgroup.php create mode 100644 models/phocacartgroups.php create mode 100644 models/phocacartreward.php create mode 100644 models/phocacartrewards.php delete mode 100644 other/index.html delete mode 100644 other/install_xml.php create mode 100644 site/views/item/tmpl/default_quickview.php create mode 100644 tables/phocacartgroup.php create mode 100644 tables/phocacartproductpointgroup.php create mode 100644 tables/phocacartproductpricegroup.php create mode 100644 tables/phocacartproductpricehistory.php create mode 100644 tables/phocacartrewardpoint.php create mode 100644 views/phocacarteditproductpointgroup/index.html create mode 100644 views/phocacarteditproductpointgroup/tmpl/default.php create mode 100644 views/phocacarteditproductpointgroup/tmpl/index.html create mode 100644 views/phocacarteditproductpointgroup/view.html.php create mode 100644 views/phocacarteditproductpricegroup/index.html create mode 100644 views/phocacarteditproductpricegroup/tmpl/default.php create mode 100644 views/phocacarteditproductpricegroup/tmpl/index.html create mode 100644 views/phocacarteditproductpricegroup/view.html.php create mode 100644 views/phocacarteditproductpricehistory/index.html create mode 100644 views/phocacarteditproductpricehistory/tmpl/default.php create mode 100644 views/phocacarteditproductpricehistory/tmpl/index.html create mode 100644 views/phocacarteditproductpricehistory/view.html.php create mode 100644 views/phocacartgroup/index.html create mode 100644 views/phocacartgroup/tmpl/edit.php create mode 100644 views/phocacartgroup/tmpl/index.html create mode 100644 views/phocacartgroup/view.html.php create mode 100644 views/phocacartgroups/index.html create mode 100644 views/phocacartgroups/tmpl/default.php create mode 100644 views/phocacartgroups/tmpl/index.html create mode 100644 views/phocacartgroups/view.html.php create mode 100644 views/phocacartreward/index.html create mode 100644 views/phocacartreward/tmpl/edit.php create mode 100644 views/phocacartreward/tmpl/index.html create mode 100644 views/phocacartreward/view.html.php create mode 100644 views/phocacartrewards/index.html create mode 100644 views/phocacartrewards/tmpl/default.php create mode 100644 views/phocacartrewards/tmpl/index.html create mode 100644 views/phocacartrewards/view.html.php diff --git a/config.xml b/config.xml index a3351722..b2ea5365 100644 --- a/config.xml +++ b/config.xml @@ -3,12 +3,12 @@
- - + - + + @@ -243,6 +243,12 @@ + + + + + + @@ -275,6 +281,12 @@ + + + + + + @@ -296,6 +308,11 @@ + + + + + @@ -441,6 +458,16 @@ + + + + + + + + + + diff --git a/models/forms/phocacartcountry.xml b/models/forms/phocacartcountry.xml index 593a5307..2bd3d59d 100644 --- a/models/forms/phocacartcountry.xml +++ b/models/forms/phocacartcountry.xml @@ -39,7 +39,7 @@ diff --git a/models/forms/phocacartcoupon.xml b/models/forms/phocacartcoupon.xml index 9b9daf70..1fa8d925 100644 --- a/models/forms/phocacartcoupon.xml +++ b/models/forms/phocacartcoupon.xml @@ -44,8 +44,10 @@ + + - + @@ -53,9 +55,9 @@
- + - + diff --git a/models/forms/phocacartcurrency.xml b/models/forms/phocacartcurrency.xml index 03369c08..cdab12b3 100644 --- a/models/forms/phocacartcurrency.xml +++ b/models/forms/phocacartcurrency.xml @@ -50,7 +50,7 @@ diff --git a/models/forms/phocacartdiscount.xml b/models/forms/phocacartdiscount.xml index 2a49c8d0..a455e41c 100644 --- a/models/forms/phocacartdiscount.xml +++ b/models/forms/phocacartdiscount.xml @@ -46,8 +46,10 @@ - - + + + + @@ -55,9 +57,9 @@
- + - + diff --git a/models/forms/phocacartdownload.xml b/models/forms/phocacartdownload.xml index 072f5a82..41e2731b 100644 --- a/models/forms/phocacartdownload.xml +++ b/models/forms/phocacartdownload.xml @@ -14,7 +14,7 @@ - + diff --git a/models/forms/phocacartfeed.xml b/models/forms/phocacartfeed.xml index 5e7b7e6e..9eac42d5 100644 --- a/models/forms/phocacartfeed.xml +++ b/models/forms/phocacartfeed.xml @@ -20,7 +20,7 @@ - +
diff --git a/models/forms/phocacartformfield.xml b/models/forms/phocacartformfield.xml index 114addc5..6db833bc 100644 --- a/models/forms/phocacartformfield.xml +++ b/models/forms/phocacartformfield.xml @@ -5,7 +5,7 @@ - + @@ -15,7 +15,18 @@ - + + + + + + + + + + + + @@ -23,7 +34,12 @@ - + + + + + + @@ -44,6 +60,8 @@ + +
diff --git a/models/forms/phocacartgroup.xml b/models/forms/phocacartgroup.xml new file mode 100644 index 00000000..5e362d5d --- /dev/null +++ b/models/forms/phocacartgroup.xml @@ -0,0 +1,51 @@ + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + +
+ + +
diff --git a/models/forms/phocacartitem.xml b/models/forms/phocacartitem.xml index c6868322..b75d4291 100644 --- a/models/forms/phocacartitem.xml +++ b/models/forms/phocacartitem.xml @@ -47,7 +47,9 @@ - + + + @@ -105,6 +107,9 @@ + + + + + + + diff --git a/models/forms/phocacartmanufacturer.xml b/models/forms/phocacartmanufacturer.xml index 6d8df901..edda7585 100644 --- a/models/forms/phocacartmanufacturer.xml +++ b/models/forms/phocacartmanufacturer.xml @@ -11,7 +11,7 @@ - + @@ -37,7 +37,7 @@ diff --git a/models/forms/phocacartorder.xml b/models/forms/phocacartorder.xml index cc47ddd5..8a8a795d 100644 --- a/models/forms/phocacartorder.xml +++ b/models/forms/phocacartorder.xml @@ -12,6 +12,14 @@ + + + + + + + +
diff --git a/models/forms/phocacartpayment.xml b/models/forms/phocacartpayment.xml index aee20caf..ed759a55 100644 --- a/models/forms/phocacartpayment.xml +++ b/models/forms/phocacartpayment.xml @@ -17,6 +17,8 @@ + + @@ -26,6 +28,11 @@ + + + + + @@ -66,7 +73,7 @@ - +
diff --git a/models/forms/phocacartquestion.xml b/models/forms/phocacartquestion.xml index c1fb73cc..729aa707 100644 --- a/models/forms/phocacartquestion.xml +++ b/models/forms/phocacartquestion.xml @@ -9,7 +9,7 @@ - + @@ -39,7 +39,7 @@ - + diff --git a/models/forms/phocacartregion.xml b/models/forms/phocacartregion.xml index 1cbb37ac..f3077658 100644 --- a/models/forms/phocacartregion.xml +++ b/models/forms/phocacartregion.xml @@ -41,7 +41,7 @@ diff --git a/models/forms/phocacartreview.xml b/models/forms/phocacartreview.xml index 3f443d14..6d3a05c7 100644 --- a/models/forms/phocacartreview.xml +++ b/models/forms/phocacartreview.xml @@ -9,7 +9,7 @@ - + @@ -39,7 +39,7 @@ - + diff --git a/models/forms/phocacartreward.xml b/models/forms/phocacartreward.xml new file mode 100644 index 00000000..8bb8cff4 --- /dev/null +++ b/models/forms/phocacartreward.xml @@ -0,0 +1,55 @@ + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+ + +
diff --git a/models/forms/phocacartshipping.xml b/models/forms/phocacartshipping.xml index 0e92761b..fa054387 100644 --- a/models/forms/phocacartshipping.xml +++ b/models/forms/phocacartshipping.xml @@ -13,11 +13,13 @@ - + + + @@ -27,6 +29,15 @@ + + + + + + + + + @@ -35,6 +46,39 @@ + + + + + + + + + + + @@ -89,7 +133,7 @@ - + --> diff --git a/models/forms/phocacartspecification.xml b/models/forms/phocacartspecification.xml index 0acdcd8b..7c2060f6 100644 --- a/models/forms/phocacartspecification.xml +++ b/models/forms/phocacartspecification.xml @@ -24,7 +24,7 @@ - + diff --git a/models/forms/phocacartstatus.xml b/models/forms/phocacartstatus.xml index 64684dca..c3198f73 100644 --- a/models/forms/phocacartstatus.xml +++ b/models/forms/phocacartstatus.xml @@ -16,6 +16,23 @@ + + + + + + + + + + + + + + + + + @@ -25,12 +42,12 @@ - + - + @@ -41,7 +58,7 @@ - +
@@ -55,7 +72,7 @@ diff --git a/models/forms/phocacartstockstatus.xml b/models/forms/phocacartstockstatus.xml index 9afc1034..06e672c5 100644 --- a/models/forms/phocacartstockstatus.xml +++ b/models/forms/phocacartstockstatus.xml @@ -16,7 +16,7 @@ - +
@@ -30,7 +30,7 @@ diff --git a/models/forms/phocacarttag.xml b/models/forms/phocacarttag.xml index 7522c03a..aa8f1646 100644 --- a/models/forms/phocacarttag.xml +++ b/models/forms/phocacarttag.xml @@ -15,7 +15,7 @@ - +
diff --git a/models/forms/phocacartuser.xml b/models/forms/phocacartuser.xml index c7f63e9a..ca2a9e3e 100644 --- a/models/forms/phocacartuser.xml +++ b/models/forms/phocacartuser.xml @@ -1,4 +1,10 @@
+ +
+ + + +
\ No newline at end of file diff --git a/models/forms/phocacartwishlist.xml b/models/forms/phocacartwishlist.xml index 1a6d0a64..99e5af22 100644 --- a/models/forms/phocacartwishlist.xml +++ b/models/forms/phocacartwishlist.xml @@ -9,7 +9,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/models/forms/phocacartzone.xml b/models/forms/phocacartzone.xml index c2e4c965..fed0f4ce 100644 --- a/models/forms/phocacartzone.xml +++ b/models/forms/phocacartzone.xml @@ -46,7 +46,7 @@ diff --git a/models/phocacartcategory.php b/models/phocacartcategory.php index c5bbc3e2..c959b76a 100644 --- a/models/phocacartcategory.php +++ b/models/phocacartcategory.php @@ -115,7 +115,15 @@ public function save($data) { if(isset($data['image']) && $data['image'] != '') { $thumb = PhocacartFileThumbnail::getOrCreateThumbnail($data['image'], '', 1, 1, 1, 0, 'categoryimage'); } - return parent::save($data); + + $save = parent::save($data); + if ($save) { + $savedId = $this->getState($this->getName().'.id'); + if ((int)$savedId > 0) { + PhocacartGroup::storeGroupsById((int)$savedId, 2, $data['group']); + } + } + return $save; } public function delete(&$cid = array()) { @@ -219,6 +227,13 @@ public function delete(&$cid = array()) { $this->setError($this->_db->getErrorMsg()); return false; }*/ + + // 9. DELETE PRODUCT CUSTOMER GROUPS + $query = 'DELETE FROM #__phocacart_item_groups' + . ' WHERE item_id IN ( '.$cids.' )' + . ' AND type = 2'; + $this->_db->setQuery( $query ); + $this->_db->execute(); } } @@ -338,6 +353,10 @@ protected function batchCopy($value, $pks, $contexts) // Add the new ID to the array $newIds[$i] = $newId; + // Store other new information + PhocacartUtilsBatchhelper::storeCategoryItems($pk, (int)$newId); + + $i++; } diff --git a/models/phocacartcoupon.php b/models/phocacartcoupon.php index ce78606f..83863e40 100644 --- a/models/phocacartcoupon.php +++ b/models/phocacartcoupon.php @@ -45,7 +45,8 @@ protected function loadFormData() { public function getItem($pk = null) { if ($item = parent::getItem($pk)) { - $item->discount = PhocacartPrice::cleanPrice($item->discount); + $item->discount = PhocacartPrice::cleanPrice($item->discount); + $item->total_amount = PhocacartPrice::cleanPrice($item->total_amount); } return $item; } @@ -156,6 +157,9 @@ public function save($data) $data['cat_ids'] = array(); } PhocacartCoupon::storeCouponCatsById($data['cat_ids'], (int)$table->id); + + + PhocacartGroup::storeGroupsById((int)$table->id, 6, $data['group']); } // Clean the cache. @@ -181,5 +185,23 @@ public function save($data) return true; } + + public function delete(&$cid = array()) { + + if (count( $cid )) { + $delete = parent::delete($cid); + if ($delete) { + + JArrayHelper::toInteger($cid); + $cids = implode( ',', $cid ); + + $query = 'DELETE FROM #__phocacart_item_groups' + . ' WHERE item_id IN ( '.$cids.' )' + . ' AND type = 6'; + $this->_db->setQuery( $query ); + $this->_db->execute(); + } + } + } } ?> \ No newline at end of file diff --git a/models/phocacartdiscount.php b/models/phocacartdiscount.php index 624055bf..c9e1b0d8 100644 --- a/models/phocacartdiscount.php +++ b/models/phocacartdiscount.php @@ -178,8 +178,29 @@ public function save($data) $this->setState($this->getName() . '.id', $table->$pkName); } $this->setState($this->getName() . '.new', $isNew); - + + if ((int)$table->id > 0) { + PhocacartGroup::storeGroupsById((int)$table->id, 5, $data['group']); + } return true; } + + public function delete(&$cid = array()) { + + if (count( $cid )) { + $delete = parent::delete($cid); + if ($delete) { + + JArrayHelper::toInteger($cid); + $cids = implode( ',', $cid ); + + $query = 'DELETE FROM #__phocacart_item_groups' + . ' WHERE item_id IN ( '.$cids.' )' + . ' AND type = 5'; + $this->_db->setQuery( $query ); + $this->_db->execute(); + } + } + } } ?> \ No newline at end of file diff --git a/models/phocacartdiscounts.php b/models/phocacartdiscounts.php index 7943de56..1483480e 100644 --- a/models/phocacartdiscounts.php +++ b/models/phocacartdiscounts.php @@ -64,7 +64,7 @@ protected function getStoreId($id = '') $id .= ':'.$this->getState('filter.search'); //$id .= ':'.$this->getState('filter.access'); $id .= ':'.$this->getState('filter.state'); - $id .= ':'.$this->getState('filter.status_id'); + $id .= ':'.$this->getState('filter.discount_id'); return parent::getStoreId($id); } diff --git a/models/phocacarteditproductpointgroup.php b/models/phocacarteditproductpointgroup.php new file mode 100644 index 00000000..d9b9b2d7 --- /dev/null +++ b/models/phocacarteditproductpointgroup.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/models/phocacarteditproductpricegroup.php b/models/phocacarteditproductpricegroup.php new file mode 100644 index 00000000..e4dbb122 --- /dev/null +++ b/models/phocacarteditproductpricegroup.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/models/phocacarteditproductpricehistory.php b/models/phocacarteditproductpricehistory.php new file mode 100644 index 00000000..cdab6ed7 --- /dev/null +++ b/models/phocacarteditproductpricehistory.php @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/models/phocacarteditstatus.php b/models/phocacarteditstatus.php index 47e0c75e..e32d1b0c 100644 --- a/models/phocacarteditstatus.php +++ b/models/phocacarteditstatus.php @@ -105,7 +105,7 @@ public function editStatus($data) { - $notify = PhocacartOrderStatus::changeStatus((int)$data['id'], (int)$data['status_id'], '', $notifyUser, $notifyOther, (int)$data['email_send'], $data['stock_movements']); + $notify = PhocacartOrderStatus::changeStatus((int)$data['id'], (int)$data['status_id'], '', $notifyUser, $notifyOther, (int)$data['email_send'], $data['stock_movements'], $data['change_user_group'], $data['change_points_needed'], $data['change_points_received']); PhocacartOrderStatus::setHistory((int)$data['id'], (int)$data['status_id'], (int)$notify, $data['comment']); diff --git a/models/phocacarteditstockadvanced.php b/models/phocacarteditstockadvanced.php index 44cd0f49..3996dada 100644 --- a/models/phocacarteditstockadvanced.php +++ b/models/phocacarteditstockadvanced.php @@ -57,7 +57,7 @@ public function save($data, $productId) { .' AND id NOT IN ('.$notDeleteItemsString.')'; } else { $query = ' DELETE ' - .' FROM #__phocacart_attributes' + .' FROM #__phocacart_product_stock' .' WHERE product_id = '. (int)$productId; } diff --git a/models/phocacartformfield.php b/models/phocacartformfield.php index 0de661ac..63bf0786 100644 --- a/models/phocacartformfield.php +++ b/models/phocacartformfield.php @@ -60,6 +60,7 @@ protected function prepareTable($table) $user = JFactory::getUser(); $table->title = htmlspecialchars_decode($table->title, ENT_QUOTES); + $table->title = JApplication::stringURLSafe($table->title); $table->alias = JApplication::stringURLSafe($table->alias); if (empty($table->alias)) { @@ -109,8 +110,171 @@ function displayItem(&$pks, $value = 1, $column = 'display_billing') { return true; } + + public function save($data) { + + $save = parent::save($data); + if ($save) { + $savedId = $this->getState($this->getName().'.id'); + if ((int)$savedId > 0) { + + if (!isset($data['id']) || (isset($data['id']) && $data['id'] == 0)) { + + $type = PhocacartFormItems::getColumnType($data['type']); + $data['title'] = JApplication::stringURLSafe($data['title']); + $data['title'] = strip_tags($data['title']); + $db = JFactory::getDBO(); + $config = JFactory::getConfig(); + $dbName = $config->get('db', ''); + + + if ($dbName != '' && $data['title'] != '' && $type != '') { + /*$query = 'SELECT * FROM information_schema.COLUMNS' + .' WHERE TABLE_SCHEMA = '.$db->quote($dbName) + .' AND TABLE_NAME = '.$db->quote('#__phocacart_users') + .' AND COLUMN_NAME = '.$db->quote($data['title']);*/ + + $query10 = 'SHOW COLUMNS FROM #__phocacart_users LIKE '.$db->quote($data['title']); + $db->setQuery($query10); + $column1 = $db->loadResult(); + + if (empty($column1)) { + $query11 = 'ALTER TABLE #__phocacart_users ADD '.$db->quoteName($data['title']).' '.$type.';'; + $db->setQuery($query11); + + if (!$db->execute()){ + $this->setError($db->getErrorMsg()); + return false; + } + + } + + $query20 = 'SHOW COLUMNS FROM #__phocacart_order_users LIKE '.$db->quote($data['title']); + $db->setQuery($query20); + $column2 = $db->loadResult(); + + if (empty($column2)) { + $query21 = 'ALTER TABLE #__phocacart_order_users ADD '.$db->quoteName($data['title']).' '.$type.''; + $db->setQuery($query21); + if (!$db->execute()){ + $this->setError($db->getErrorMsg()); + return false; + } + } + } + } + + PhocacartGroup::storeGroupsById((int)$savedId, 9, $data['group']); + } + } + return $save; + } + + + public function delete(&$cid = array()) { - return false; + + $app = JFactory::getApplication(); + $db = JFactory::getDBO(); + + $result = false; + if (count( $cid )) { + JArrayHelper::toInteger($cid); + $cids = implode( ',', $cid ); + + $table = $this->getTable(); + if (!$this->canDelete($table)){ + $error = $this->getError(); + if ($error){ + JLog::add($error, JLog::WARNING); + return false; + } else { + JLog::add(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), JLog::WARNING); + return false; + } + } + + // Select id's from product table, if there are some items, don't delete it. + $query = 'SELECT a.id, a.title, a.type_default' + . ' FROM #__phocacart_form_fields AS a' + . ' WHERE a.id IN ( '.$cids.' )' + . ' GROUP BY a.id'; + + $db->setQuery( $query ); + + if (!($rows = $db->loadObjectList())) { + throw new Exception( $db->stderr('Load Data Problem'), 500 ); + return false; + } + + + $cidOK = array(); + $cidOKTitle = array(); + $cidError = array(); + foreach ($rows as $row) { + if ($row->type_default == 0) { + $cidOK[] = (int)$row->id; + $cidOKTitle[] = $row->title; + } else { + $cidError[] = $row->title; + } + } + + if (count( $cidOK )) { + $cidsOK = implode( ',', $cidOK ); + $query2 = 'DELETE FROM #__phocacart_form_fields' + . ' WHERE id IN ( '.$cidsOK.' )'; + $db->setQuery( $query2 ); + if (!$db->query()) { + $this->setError($this->_db->getErrorMsg()); + return false; + }; + + if (!empty($cidOKTitle)) { + foreach($cidOKTitle as $k => $v) { + $v = JApplication::stringURLSafe($v); + $v = strip_tags($v); + + $query10 = 'SHOW COLUMNS FROM #__phocacart_users LIKE '.$db->quote($v); + $db->setQuery($query10); + $column1 = $db->loadResult(); + + if (!empty($column1)) { + $query11 = 'ALTER TABLE #__phocacart_users DROP COLUMN '.$db->quoteName($v).';'; + $db->setQuery($query11); + $db->execute(); + } + + $query20 = 'SHOW COLUMNS FROM #__phocacart_order_users LIKE '.$db->quote($v); + $db->setQuery($query20); + $column2 = $db->loadResult(); + + if (!empty($column2)) { + $query21 = 'ALTER TABLE #__phocacart_order_users DROP COLUMN '.$db->quoteName($v).';'; + $db->setQuery($query21); + $db->execute(); + } + } + + } + } + + $msg = ''; + if (!empty($cidError)) { + $cidErrorString = implode( ", ", $cidError ); + $msg .= JText::plural( 'COM_PHOCACART_ERROR_DELETE_DEFAULT_FORM_FIELDS', $cidErrorString ); + } + if (!empty($cidOKTitle)) { + $cidOKTitleString = implode( ", ", $cidOKTitle ); + if ($msg != '') { $msg .= "
";} + $msg .= JText::plural( 'COM_PHOCACART_SUCCESS_FORM_FIELDS_DELETED', $cidOKTitleString ); + } + + $link = 'index.php?option=com_phocacart&view=phocacartformfields'; + $app->enqueueMessage($msg, 'error'); + $app->redirect($link); + } + return true; } } ?> \ No newline at end of file diff --git a/models/phocacartformfields.php b/models/phocacartformfields.php index c1b17d55..487eccb0 100644 --- a/models/phocacartformfields.php +++ b/models/phocacartformfields.php @@ -25,6 +25,8 @@ public function __construct($config = array()) 'display_account', 'a.display_account', 'description', 'a.description', 'label', 'a.label', + 'type', 'a.type', + 'type_default', 'a.type_default', 'checked_out', 'a.checked_out', 'checked_out_time', 'a.checked_out_time', 'access', 'a.access', 'access_level', diff --git a/models/phocacartgroup.php b/models/phocacartgroup.php new file mode 100644 index 00000000..dfe18e66 --- /dev/null +++ b/models/phocacartgroup.php @@ -0,0 +1,186 @@ +loadForm('com_phocacart.phocacartgroup', 'phocacartgroup', array('control' => 'jform', 'load_data' => $loadData)); + if (empty($form)) { + return false; + } + return $form; + } + + protected function loadFormData() { + $data = JFactory::getApplication()->getUserState('com_phocacart.edit.phocacartgroup.data', array()); + if (empty($data)) { + $data = $this->getItem(); + } + return $data; + } + + public function getItem($pk = null) { + if ($item = parent::getItem($pk)) { + $item->minimum_sum = PhocacartPrice::cleanPrice($item->minimum_sum); + } + return $item; + } + + protected function prepareTable($table) { + jimport('joomla.filter.output'); + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + $table->title = htmlspecialchars_decode($table->title, ENT_QUOTES); + $table->alias = JApplication::stringURLSafe($table->alias); + + if (empty($table->alias)) { + $table->alias = JApplication::stringURLSafe($table->title); + } + + if (empty($table->id)) { + // Set the values + //$table->created = $date->toSql(); + + // Set ordering to the last item if not set + if (empty($table->ordering)) { + $db = JFactory::getDbo(); + $db->setQuery('SELECT MAX(ordering) FROM #__phocacart_groups'); + $max = $db->loadResult(); + + $table->ordering = $max+1; + } + } + else { + // Set the values + //$table->modified = $date->toSql(); + //$table->modified_by = $user->get('id'); + } + + if (isset($table->type) && isset($table->published) && $table->type == 1 && $table->published == 0) { + $table->published = 1; + $app = JFactory::getApplication(); + $app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_DEFAULT_ITEMS_CANNOT_BE_UNPUBLISHED')); + } + } + + public function delete(&$cid = array()) { + + + if (count( $cid )) { + JArrayHelper::toInteger($cid); + //$cids = implode( ',', $cid ); + //$app = JFactory::getApplication(); + $error = 0; + if (!empty($cid)) { + foreach ($cid as $k => $v) { + $query = 'SELECT type FROM #__phocacart_groups WHERE id ='.(int)$v; + $this->_db->setQuery($query); + $type = $this->_db->loadRow(); + if (isset($type[0]) && $type[0] == 1) { + $error = 1; + } else { + $query = 'DELETE FROM #__phocacart_groups' + . ' WHERE id = '.(int)$v; + $this->_db->setQuery( $query ); + $this->_db->execute(); + } + + } + } + } + if ($error) { + $this->setError(JText::_('COM_PHOCACART_ERROR_DEFAULT_ITEMS_CANNOT_BE_DELETED')); + //$app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_DEFAULT_ITEMS_CANNOT_BE_DELETED')); + return false; + } else { + return true; + } + + } + + public function publish(&$pks, $value = 1) + { + + $user = JFactory::getUser(); + $table = $this->getTable(); + $pks = (array) $pks; + $app = JFactory::getApplication(); + + $error = 0; + foreach ($pks as $i => $pk){ + $table->reset(); + + if ($table->load($pk)) { + + + if (!$this->canEditState($table)){ + // Prune items that you can't change. + unset($pks[$i]); + JLog::add(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), JLog::WARNING, 'jerror'); + return false; + } + + // If the table is checked out by another user, drop it and report to the user trying to change its state. + if (property_exists($table, 'checked_out') && $table->checked_out && ($table->checked_out != $user->id)){ + JLog::add(JText::_('JLIB_APPLICATION_ERROR_CHECKIN_USER_MISMATCH'), JLog::WARNING, 'jerror'); + // Prune items that you can't change. + unset($pks[$i]); + return false; + } + + if (property_exists($table, 'type') && $table->type && ((int)$table->type == 1) && $value == 0){ + $error = 1; + unset($pks[$i]); + //return false; + } + } + } + + + // Attempt to change the state of the records. + if (!empty($pks)) { + if (!$table->publish($pks, $value, $user->get('id'))) { + $this->setError($table->getError()); + return false; + } + } + + + + if ($error) { + + //$this->setError(JText::_('COM_PHOCACART_ERROR_DEFAULT_ITEMS_CANNOT_BE_UNPUBLISHED')); + $app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_DEFAULT_ITEMS_CANNOT_BE_UNPUBLISHED')); + return true; + } else { + return true; + } + $this->cleanCache(); + } +} +?> \ No newline at end of file diff --git a/models/phocacartgroups.php b/models/phocacartgroups.php new file mode 100644 index 00000000..edc18329 --- /dev/null +++ b/models/phocacartgroups.php @@ -0,0 +1,134 @@ +getUserStateFromRequest($this->context.'.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + +/* $accessId = $app->getUserStateFromRequest($this->context.'.filter.access', 'filter_access', null, 'int'); + $this->setState('filter.access', $accessId);*/ + + + + $state = $app->getUserStateFromRequest($this->context.'.filter.state', 'filter_published', '', 'string'); + $this->setState('filter.state', $state); + + //$language = $app->getUserStateFromRequest($this->context.'.filter.language', 'filter_language', ''); + //$this->setState('filter.language', $language); + + // Load the parameters. + $params = JComponentHelper::getParams('com_phocacart'); + $this->setState('params', $params); + + // List state information. + parent::populateState('a.title', 'asc'); + } + + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':'.$this->getState('filter.search'); + //$id .= ':'.$this->getState('filter.access'); + $id .= ':'.$this->getState('filter.state'); + $id .= ':'.$this->getState('filter.group_id'); + return parent::getStoreId($id); + } + + protected function getListQuery() { + + $db = $this->getDbo(); + $query = $db->getQuery(true); + + // Select the required fields from the table. + $query->select( + $this->getState( + 'list.select', + 'a.*' + ) + ); + $query->from('`#__phocacart_groups` AS a'); + + // Join over the language + //$query->select('l.title AS language_title'); + //$query->join('LEFT', '`#__languages` AS l ON l.lang_code = a.language'); + + // Join over the users for the checked out user. + $query->select('uc.name AS editor'); + $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out'); + + + // Filter by access level. +/* if ($access = $this->getState('filter.access')) { + $query->where('a.access = '.(int) $access); + }*/ + + + + // Filter by published state. + $published = $this->getState('filter.state'); + if (is_numeric($published)) { + $query->where('a.published = '.(int) $published); + } + else if ($published === '') { + $query->where('(a.published IN (0, 1))'); + } + + + // Filter by search in title + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) { + $query->where('a.id = '.(int) substr($search, 3)); + } + else + { + $search = $db->Quote('%'.$db->escape($search, true).'%'); + $query->where('( a.title LIKE '.$search.' OR a.alias LIKE '.$search.')'); + } + } + + $orderCol = $this->state->get('list.ordering', 'title'); + $orderDirn = $this->state->get('list.direction', 'asc'); + $query->order($db->escape($orderCol.' '.$orderDirn)); + + //echo nl2br(str_replace('#__', 'jos_', $query->__toString())); + return $query; + } +} +?> \ No newline at end of file diff --git a/models/phocacartitem.php b/models/phocacartitem.php index e7dae2bc..8d3f5a99 100644 --- a/models/phocacartitem.php +++ b/models/phocacartitem.php @@ -131,6 +131,7 @@ function save($data) { } $app = JFactory::getApplication(); + // TO DO remove /*$pFormSpec = $app->input->post->get('pformspec', array(), 'array'); $pFormAttr = $app->input->post->get('pformattr', array(), 'array'); @@ -204,7 +205,7 @@ function save($data) { if ($table->image != '') { $thumb = PhocacartFileThumbnail::getOrCreateThumbnail($table->image, '', 1, 1, 1, 0, 'productimage'); } - + if ((int)$table->id > 0) { if (!isset($data['catid_multiple'])) { @@ -215,7 +216,7 @@ function save($data) { if (isset($data['featured'])) { $this->featured((int)$table->id, $data['featured']); } - + $dataRelated = ''; if (!isset($data['related'])) { $dataRelated = ''; @@ -232,7 +233,7 @@ function save($data) { $data['attributes'] = array(); } - + $pFormImg = $app->input->post->get('pformimg', array(), 'array'); PhocacartImageAdditional::storeImagesByProductId((int)$table->id, $pFormImg); $pFormAttr = $app->input->post->get('pformattr', array(), 'array'); @@ -242,11 +243,15 @@ function save($data) { $pFormDisc = $app->input->post->get('pformdisc', array(), 'array'); PhocacartDiscountProduct::storeDiscountsById((int)$table->id, $pFormDisc); + PhocacartGroup::storeGroupsById((int)$table->id, 3, $data['group']); + + PhocacartPriceHistory::storePriceHistoryById((int)$table->id, $data['price']); if (!isset($data['tags'])) { $data['tags'] = array(); } + PhocacartTag::storeTags($data['tags'], (int)$table->id); } @@ -363,6 +368,26 @@ public function delete(&$cid = array()) { $this->_db->setQuery( $query ); $this->_db->execute(); + // 9. DELETE PRODUCT CUSTOMER GROUPS + $query = 'DELETE FROM #__phocacart_item_groups' + . ' WHERE item_id IN ( '.$cids.' )' + . ' AND type = 3'; + $this->_db->setQuery( $query ); + $this->_db->execute(); + + // 10. DELETE PRODUCT PRICE CUSTOMER GROUPS + $query = 'DELETE FROM #__phocacart_product_price_groups' + . ' WHERE product_id IN ( '.$cids.' )'; + $this->_db->setQuery( $query ); + $this->_db->execute(); + + + // 11. DELETE PRODUCT POINT CUSTOMER GROUPS + $query = 'DELETE FROM #__phocacart_product_point_groups' + . ' WHERE product_id IN ( '.$cids.' )'; + $this->_db->setQuery( $query ); + $this->_db->execute(); + } return true; } @@ -904,6 +929,8 @@ public function copyattributes(&$cid = array(), $idSource = 0) { // Attributes $aA = PhocacartAttribute::getAttributesById($idSource, 1); + + if (!empty($aA)) { foreach ($aA as $k => $v) { if (isset($v['id']) && $v['id'] > 0) { @@ -923,7 +950,8 @@ public function copyattributes(&$cid = array(), $idSource = 0) { foreach($cid as $k => $v) { if ((int)$v != $idSource) { // Do not copy to itself - PhocacartAttribute::storeAttributesById((int)$v, $aA); + + PhocacartAttribute::storeAttributesById((int)$v, $aA, 1); $cA++; } } diff --git a/models/phocacartpayment.php b/models/phocacartpayment.php index bf8eaa48..1831bd0c 100644 --- a/models/phocacartpayment.php +++ b/models/phocacartpayment.php @@ -184,6 +184,8 @@ public function save($data) } PhocacartShipping::storeShippingMethods($data['shipping'], (int)$table->id, 'payment'); + + PhocacartGroup::storeGroupsById((int)$table->id, 8, $data['group']); } @@ -211,5 +213,73 @@ public function save($data) return true; } + + public function delete(&$cid = array()) { + + if (count( $cid )) { + $delete = parent::delete($cid); + if ($delete) { + + JArrayHelper::toInteger($cid); + $cids = implode( ',', $cid ); + + $query = 'DELETE FROM #__phocacart_item_groups' + . ' WHERE item_id IN ( '.$cids.' )' + . ' AND type = 8'; + $this->_db->setQuery( $query ); + $this->_db->execute(); + } + } + } + + public function setDefault($id = 0) { + + $user = JFactory::getUser(); + $db = $this->getDbo(); + + if (!$user->authorise('core.edit.state', 'com_phocacart')) { + throw new Exception(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); + } + + $table = $this->getTable(); + + if (!$table->load((int) $id)){ + throw new Exception(JText::_('COM_PHOCACART_ERROR_TABLE_NOT_FOUND')); + } + + $db->setQuery("UPDATE #__phocacart_payment_methods SET ".$db->quoteName('default')." = '0'"); + $db->execute(); + + $db->setQuery("UPDATE #__phocacart_payment_methods SET ".$db->quoteName('default')." = '1' WHERE id = " . (int) $id); + $db->execute(); + + $this->cleanCache(); + + return true; + } + + public function unsetDefault($id = 0) { + + $user = JFactory::getUser(); + $db = $this->getDbo(); + + if (!$user->authorise('core.edit.state', 'com_phocacart')) { + throw new Exception(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); + } + + $table = $this->getTable(); + + if (!$table->load((int) $id)){ + throw new Exception(JText::_('COM_PHOCACART_ERROR_TABLE_NOT_FOUND')); + } + + // It is possible that nothing will be set as default + $db->setQuery("UPDATE #__phocacart_payment_methods SET ".$db->quoteName('default')." = '0' WHERE id = " . (int)$id); + $db->execute(); + + $this->cleanCache(); + + return true; + } } ?> \ No newline at end of file diff --git a/models/phocacartreward.php b/models/phocacartreward.php new file mode 100644 index 00000000..daa77100 --- /dev/null +++ b/models/phocacartreward.php @@ -0,0 +1,78 @@ +loadForm('com_phocacart.phocacartreward', 'phocacartreward', array('control' => 'jform', 'load_data' => $loadData)); + if (empty($form)) { + return false; + } + return $form; + } + + protected function loadFormData() { + $data = JFactory::getApplication()->getUserState('com_phocacart.edit.phocacartreward.data', array()); + if (empty($data)) { + $data = $this->getItem(); + } + return $data; + } + + protected function prepareTable($table) { + jimport('joomla.filter.output'); + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + $table->title = htmlspecialchars_decode($table->title, ENT_QUOTES); + $table->alias = JApplication::stringURLSafe($table->alias); + + if (empty($table->alias)) { + $table->alias = JApplication::stringURLSafe($table->title); + } + + if (empty($table->id)) { + // Set the values + //$table->created = $date->toSql(); + + // Set ordering to the last item if not set + if (empty($table->ordering)) { + $db = JFactory::getDbo(); + $db->setQuery('SELECT MAX(ordering) FROM #__phocacart_reward_points'); + $max = $db->loadResult(); + + $table->ordering = $max+1; + } + } + else { + // Set the values + //$table->modified = $date->toSql(); + //$table->modified_by = $user->get('id'); + } + } +} +?> \ No newline at end of file diff --git a/models/phocacartrewards.php b/models/phocacartrewards.php new file mode 100644 index 00000000..084f82fd --- /dev/null +++ b/models/phocacartrewards.php @@ -0,0 +1,147 @@ +getUserStateFromRequest($this->context.'.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $user = $app->getUserStateFromRequest($this->context.'.filter.user', 'filter_user'); + $this->setState('filter.user', $user); + +/* $accessId = $app->getUserStateFromRequest($this->context.'.filter.access', 'filter_access', null, 'int'); + $this->setState('filter.access', $accessId);*/ + + + + $state = $app->getUserStateFromRequest($this->context.'.filter.state', 'filter_published', '', 'string'); + $this->setState('filter.state', $state); + + + //$language = $app->getUserStateFromRequest($this->context.'.filter.language', 'filter_language', ''); + //$this->setState('filter.language', $language); + + // Load the parameters. + $params = JComponentHelper::getParams('com_phocacart'); + $this->setState('params', $params); + + // List state information. + parent::populateState('a.date', 'desc'); + } + + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':'.$this->getState('filter.search'); + $id .= ':'.$this->getState('filter.user'); + //$id .= ':'.$this->getState('filter.access'); + $id .= ':'.$this->getState('filter.state'); + $id .= ':'.$this->getState('filter.reward_id'); + return parent::getStoreId($id); + } + + protected function getListQuery() { + + $db = $this->getDbo(); + $query = $db->getQuery(true); + + // Select the required fields from the table. + $query->select( + $this->getState( + 'list.select', + 'a.*' + ) + ); + $query->from('`#__phocacart_reward_points` AS a'); + + // Join over the language + //$query->select('l.title AS language_title'); + //$query->join('LEFT', '`#__languages` AS l ON l.lang_code = a.language'); + + // Join over the users for the checked out user. + $query->select('uc.name AS editor'); + $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out'); + + + $query->select('u.name AS user_name, u.username AS user_username'); + $query->join('LEFT', '#__users AS u ON u.id=a.user_id'); + + // Filter by access level. +/* if ($access = $this->getState('filter.access')) { + $query->where('a.access = '.(int) $access); + }*/ + + + + // Filter by published state. + $published = $this->getState('filter.state'); + if (is_numeric($published)) { + $query->where('a.published = '.(int) $published); + } + else if ($published === '') { + $query->where('(a.published IN (0, 1))'); + } + + + // Filter by search in title + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) { + $query->where('a.id = '.(int) substr($search, 3)); + } + else + { + $search = $db->Quote('%'.$db->escape($search, true).'%'); + $query->where('( a.title LIKE '.$search.' OR a.alias LIKE '.$search.' OR u.name LIKE '.$search.' OR u.username LIKE '.$search.')'); + } + } + + $user = $this->getState('filter.user'); + if (!empty($user)){ + $query->select('u2.name AS user_name_selected'); + $query->join('LEFT', '#__users AS u2 ON u2.id=a.user_id'); + $query->where('( u.id = '.(int)$user.')'); + } + + $orderCol = $this->state->get('list.ordering', 'title'); + $orderDirn = $this->state->get('list.direction', 'asc'); + $query->order($db->escape($orderCol.' '.$orderDirn)); + + //echo nl2br(str_replace('#__', 'jos_', $query->__toString())); + return $query; + } +} +?> \ No newline at end of file diff --git a/models/phocacartshipping.php b/models/phocacartshipping.php index 3c3ebe20..6a5cf0a1 100644 --- a/models/phocacartshipping.php +++ b/models/phocacartshipping.php @@ -173,6 +173,8 @@ public function save($data) PhocacartRegion::storeRegions($data['region'], (int)$table->id); + PhocacartGroup::storeGroupsById((int)$table->id, 7, $data['group']); + } @@ -199,5 +201,74 @@ public function save($data) return true; } + + public function delete(&$cid = array()) { + + if (count( $cid )) { + $delete = parent::delete($cid); + if ($delete) { + + JArrayHelper::toInteger($cid); + $cids = implode( ',', $cid ); + + $query = 'DELETE FROM #__phocacart_item_groups' + . ' WHERE item_id IN ( '.$cids.' )' + . ' AND type = 7'; + $this->_db->setQuery( $query ); + $this->_db->execute(); + } + } + } + + + public function setDefault($id = 0) { + + $user = JFactory::getUser(); + $db = $this->getDbo(); + + if (!$user->authorise('core.edit.state', 'com_phocacart')) { + throw new Exception(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); + } + + $table = $this->getTable(); + + if (!$table->load((int) $id)){ + throw new Exception(JText::_('COM_PHOCACART_ERROR_TABLE_NOT_FOUND')); + } + + $db->setQuery("UPDATE #__phocacart_shipping_methods SET ".$db->quoteName('default')." = '0'"); + $db->execute(); + + $db->setQuery("UPDATE #__phocacart_shipping_methods SET ".$db->quoteName('default')." = '1' WHERE id = " . (int) $id); + $db->execute(); + + $this->cleanCache(); + + return true; + } + + public function unsetDefault($id = 0) { + + $user = JFactory::getUser(); + $db = $this->getDbo(); + + if (!$user->authorise('core.edit.state', 'com_phocacart')) { + throw new Exception(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); + } + + $table = $this->getTable(); + + if (!$table->load((int) $id)){ + throw new Exception(JText::_('COM_PHOCACART_ERROR_TABLE_NOT_FOUND')); + } + + // It is possible that nothing will be set as default + $db->setQuery("UPDATE #__phocacart_shipping_methods SET ".$db->quoteName('default')." = '0' WHERE id = " . (int)$id); + $db->execute(); + + $this->cleanCache(); + + return true; + } } ?> \ No newline at end of file diff --git a/models/phocacartstatus.php b/models/phocacartstatus.php index c2607b96..73b979d0 100644 --- a/models/phocacartstatus.php +++ b/models/phocacartstatus.php @@ -73,6 +73,12 @@ protected function prepareTable($table) { //$table->modified = $date->toSql(); //$table->modified_by = $user->get('id'); } + + if (isset($table->type) && isset($table->published) && $table->type == 1 && $table->published == 0) { + $table->published = 1; + $app = JFactory::getApplication(); + $app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_DEFAULT_ITEMS_CANNOT_BE_UNPUBLISHED')); + } } public function delete(&$cid = array()) { @@ -109,5 +115,65 @@ public function delete(&$cid = array()) { } } + + public function publish(&$pks, $value = 1) + { + + $user = JFactory::getUser(); + $table = $this->getTable(); + $pks = (array) $pks; + $app = JFactory::getApplication(); + + $error = 0; + foreach ($pks as $i => $pk){ + $table->reset(); + + if ($table->load($pk)) { + + + if (!$this->canEditState($table)){ + // Prune items that you can't change. + unset($pks[$i]); + JLog::add(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), JLog::WARNING, 'jerror'); + return false; + } + + // If the table is checked out by another user, drop it and report to the user trying to change its state. + if (property_exists($table, 'checked_out') && $table->checked_out && ($table->checked_out != $user->id)){ + JLog::add(JText::_('JLIB_APPLICATION_ERROR_CHECKIN_USER_MISMATCH'), JLog::WARNING, 'jerror'); + // Prune items that you can't change. + unset($pks[$i]); + return false; + } + + if (property_exists($table, 'type') && $table->type && ((int)$table->type == 1) && $value == 0){ + $error = 1; + unset($pks[$i]); + //return false; + } + } + } + + + // Attempt to change the state of the records. + if (!empty($pks)) { + if (!$table->publish($pks, $value, $user->get('id'))) { + $this->setError($table->getError()); + return false; + } + } + + + + if ($error) { + + //$this->setError(JText::_('COM_PHOCACART_ERROR_DEFAULT_ITEMS_CANNOT_BE_UNPUBLISHED')); + $app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_DEFAULT_ITEMS_CANNOT_BE_UNPUBLISHED')); + return true; + } else { + return true; + } + $this->cleanCache(); + } } ?> \ No newline at end of file diff --git a/models/phocacartuser.php b/models/phocacartuser.php index 57abec34..33713b83 100644 --- a/models/phocacartuser.php +++ b/models/phocacartuser.php @@ -36,12 +36,22 @@ public function getTable($type = 'PhocacartUser', $prefix = 'Table', $config = a return JTable::getInstance($type, $prefix, $config); } - public function getForm($data = array(), $loadData = true) { + public function getFormSpecific($data = array(), $loadData = true) { if (empty($this->fields['xml'])) { $this->fields = $this->getFields(); } - $form = $this->loadForm('com_phocacart.user', (string)$this->fields['xml'], array('control' => 'jform', 'load_data' => $loadData)); + $form = $this->loadForm('com_phocacart.userspecific', (string)$this->fields['xml'], array('control' => 'jform', 'load_data' => $loadData)); + if (empty($form)) { + return false; + } + return $form; + } + + public function getForm($data = array(), $loadData = true) { + + $form = $this->loadForm('com_phocacart.user', 'phocacartuser', array('control' => 'jform', 'load_data' => $loadData)); + if (empty($form)) { return false; } @@ -60,13 +70,22 @@ protected function loadFormData() { public function getItem($pk = null) { $app = JFactory::getApplication(); - $user = $this->getUser(); + + if (empty($pk)) { + $pk = (int) $this->getState($this->getName() . '.id'); + } + + $user = $this->getUser($pk); + + $table = $this->getTable('PhocacartUser', 'Table'); - $tableS = $this->getTable('PhocacartUser', 'Table'); + $tableS = $this->getTable('PhocacartUser', 'Table'); // Billing if(isset($user->id) && (int)$user->id > 0) { + $return = $table->load(array('user_id' => (int)$user->id, 'type' => 0)); + if ($return === false && $table->getError()) { $this->setError($table->getError()); return false; @@ -106,7 +125,7 @@ public function getItem($pk = null) { $registry->loadString($item->params); $item->params = $registry->toArray(); }*/ - + return $item; } @@ -131,16 +150,19 @@ protected function getUser() { public function save($data, $type = 0) { $app = JFactory::getApplication(); - $data['type'] = (int)$type; $row = $this->getTable('PhocacartUser', 'Table'); if(isset($data['user_id']) && $data['user_id'] > 0) { if (!$row->load(array('user_id' => (int)$data['user_id'], 'type' => $type))) { // No data yet + + } else { + if (isset($row->id) && (int)$row->id > 0 && (!isset($data['id']) || (isset($data['id']) && $data['id'] == ''))) { + $data['id'] = (int)$row->id; + } } } - //$row->bind($data); if (!$row->bind($data)) { $this->setError($this->_db->getErrorMsg()); @@ -161,7 +183,12 @@ public function save($data, $type = 0) { return false; } - return $row->id; + // We save shipping and billing after each other - twice, so don't delete the group and run only once + if ($type == 0) { + PhocacartGroup::storeGroupsById((int)$row->user_id, 1, $data['group']); + } + + return $row->user_id; } public function delete(&$cid = array()) { diff --git a/models/phocacartusers.php b/models/phocacartusers.php index 4351b325..3aa81169 100644 --- a/models/phocacartusers.php +++ b/models/phocacartusers.php @@ -39,6 +39,9 @@ protected function populateState($ordering = null, $direction = null) { // Load the filter state. $search = $app->getUserStateFromRequest($this->context.'.filter.search', 'filter_search'); $this->setState('filter.search', $search); + + $user = $app->getUserStateFromRequest($this->context.'.filter.user', 'filter_user'); + $this->setState('filter.user', $user); /* $accessId = $app->getUserStateFromRequest($this->context.'.filter.access', 'filter_access', null, 'int'); $this->setState('filter.access', $accessId);*/ @@ -56,13 +59,14 @@ protected function populateState($ordering = null, $direction = null) { $this->setState('params', $params); // List state information. - parent::populateState('a.title', 'asc'); + parent::populateState('u.name', 'asc'); } protected function getStoreId($id = '') { // Compile the store id. $id .= ':'.$this->getState('filter.search'); + $id .= ':'.$this->getState('filter.user'); //$id .= ':'.$this->getState('filter.access'); $id .= ':'.$this->getState('filter.state'); $id .= ':'.$this->getState('filter.user_id'); @@ -103,6 +107,15 @@ protected function getListQuery() { $query->select('uc.name AS editor'); $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out'); + + + + $query->select('GROUP_CONCAT(DISTINCT g.title) AS groups'); + $query->join('LEFT', '#__phocacart_item_groups AS ug ON ug.item_id=u.id AND ug.type = 1'); + $query->join('LEFT', '#__phocacart_groups AS g ON g.id=ug.group_id'); + + + // Filter by access level. /* if ($access = $this->getState('filter.access')) { $query->where('a.access = '.(int) $access); @@ -137,10 +150,17 @@ protected function getListQuery() { // We have two rows for one customer - for billing and shipping address, but we need to list only one //$query->where('a.type = 0'); - $query->where('u.name <> '.$db->quote('Super User')); + //$query->where('u.name <> '.$db->quote('Super User')); $query->group('u.id'); + + $user = $this->getState('filter.user'); + if (!empty($user)){ + $query->select('u2.name AS user_name_selected'); + $query->join('LEFT', '#__users AS u2 ON u2.id=a.user_id'); + $query->where('( u.id = '.(int)$user.')'); + } - $orderCol = $this->state->get('list.ordering', 'title'); + $orderCol = $this->state->get('list.ordering', 'u.name'); $orderDirn = $this->state->get('list.direction', 'u.name'); $query->order($db->escape($orderCol.' '.$orderDirn)); diff --git a/models/phocacartzones.php b/models/phocacartzones.php index 3b1e6db8..bd9af434 100644 --- a/models/phocacartzones.php +++ b/models/phocacartzones.php @@ -39,8 +39,6 @@ protected function populateState($ordering = null, $direction = null) { $search = $app->getUserStateFromRequest($this->context.'.filter.search', 'filter_search'); $this->setState('filter.search', $search); -/* $accessId = $app->getUserStateFromRequest($this->context.'.filter.access', 'filter_access', null, 'int'); - $this->setState('filter.access', $accessId);*/ @@ -62,7 +60,6 @@ protected function getStoreId($id = '') { // Compile the store id. $id .= ':'.$this->getState('filter.search'); - //$id .= ':'.$this->getState('filter.access'); $id .= ':'.$this->getState('filter.state'); $id .= ':'.$this->getState('filter.zone_id'); @@ -92,14 +89,7 @@ protected function getListQuery() { $query->select('uc.name AS editor'); $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out'); - - - - // Filter by access level. -/* if ($access = $this->getState('filter.access')) { - $query->where('a.access = '.(int) $access); - }*/ diff --git a/other/index.html b/other/index.html deleted file mode 100644 index ea9e94c1..00000000 --- a/other/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/other/install_xml.php b/other/install_xml.php deleted file mode 100644 index a10556c8..00000000 --- a/other/install_xml.php +++ /dev/null @@ -1,129 +0,0 @@ - "COM_PHOCACART", 1 => "option=com_phocacart", 2 => "media/com_phocacart/images/administrator/images/icon-16-cart-menu.png"); - -$t = 'COM_PHOCACART_CONTROLPANEL'; -$xml_submenu[] = array (0 => $t, 1 => "option=com_phocacart", 2 => $iP.'icon-16-pc-menu-cp.png', 3 => $t, 4 => 'phocacartcp'); - -$t = 'COM_PHOCACART_PRODUCTS';$v = 'phocacartitems'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-item.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_CATEGORIES';$v = 'phocacartcategories'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-category.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_SPECIFICATIONS';$v = 'phocacartspecifications'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-specification.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_MANUFACTURERS';$v = 'phocacartmanufacturers'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-manufacturer.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_ORDERS';$v = 'phocacartorders'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-order.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_ORDER_STATUSES';$v = 'phocacartstatuses'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-orderstatus.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_STOCK_STATUSES';$v = 'phocacartstockstatuses'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-stockstatus.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_SHIPPING';$v = 'phocacartshippings'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-shipping.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_COUNTRIES';$v = 'phocacartcountries'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-country.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_REGIONS';$v = 'phocacartregions'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-region.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_ZONES';$v = 'phocacartzones'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-zone.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_PAYMENT';$v = 'phocacartpayments'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-payment.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_CURRENCIES';$v = 'phocacartcurrencies'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-currency.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_TAXES';$v = 'phocacarttaxes'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-tax.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_USERS';$v = 'phocacartusers'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-user.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_FORM_FIELDS';$v = 'phocacartformfields'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-user.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_REVIEWS';$v = 'phocacartreviews'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-review.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_COUPONS';$v = 'phocacartcoupons'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-coupon.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_DISCOUNTS';$v = 'phocacartdiscounts'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-discount.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_DOWNLOADS';$v = 'phocacartdownloads'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-download.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_TAGS';$v = 'phocacarttags'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-tag.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_XML_FEEDS';$v = 'phocacartfeeds'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-feeds.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_WISH_LISTS';$v = 'phocacartwishlists'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-wishlists.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_QUESTIONS';$v = 'phocacartquestions'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-questions.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_STATISTICS';$v = 'phocacartstatistics'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-statistics.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_HITS';$v = 'phocacarthits'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-hits.png', 3 => $t, 4 => $v); - - -$t = 'COM_PHOCACART_IMPORT';$v = 'phocacartimports'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-import.png', 3 => $t, 4 => $v); - - -$t = 'COM_PHOCACART_EXPORT';$v = 'phocacartexports'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-export.png', 3 => $t, 4 => $v); - - -$t = 'COM_PHOCACART_SYSTEM_LOG';$v = 'phocacartlogs'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-log.png', 3 => $t, 4 => $v); - -$t = 'COM_PHOCACART_INFO';$v = 'phocacartinfo'; -$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-info.png', 3 => $t, 4 => $v); - -$xml_install_file = ''; -$xml_uninstall_file = ''; -/*********** XML PARAMETERS AND VALUES ************/ -?> \ No newline at end of file diff --git a/phocacart.php b/phocacart.php index e2935a04..eec24a23 100644 --- a/phocacart.php +++ b/phocacart.php @@ -19,7 +19,7 @@ JLoader::registerPrefix('Phocacart', JPATH_ADMINISTRATOR . '/components/com_phocacart/libraries/phocacart'); /* -if (! class_exists('PhocaCartLoader')) { +if (! class_exists('PhocacartLoader')) { require_once( JPATH_ADMINISTRATOR.'/components/com_phocacart/libraries/loader.php'); } @@ -27,59 +27,7 @@ jimport('joomla.filesystem.file'); require_once( JPATH_COMPONENT.'/controller.php' ); phocacart import('phocacart.utils.utils'); -phocacart import('phocacart.utils.settings'); -phocacart import('phocacart.utils.exception'); -phocacart import('phocacart.utils.log'); -phocacart import('phocacart.utils.batchhelper'); -phocacart import('phocacart.utils.extension'); -phocacart import('phocacart.date.date'); -phocacart import('phocacart.path.path'); -phocacart import('phocacart.file.file'); -phocacart import('phocacart.access.access'); -phocacart import('phocacart.file.fileupload'); -phocacart import('phocacart.file.fileuploadmultiple'); -phocacart import('phocacart.file.fileuploadsingle'); -phocacart import('phocacart.file.filethumbnail'); -phocacart import('phocacart.image.image'); -phocacart import('phocacart.image.imageadditional'); -phocacart import('phocacart.attribute.attribute'); -phocacart import('phocacart.specification.specification'); -phocacart import('phocacart.region.region'); -phocacart import('phocacart.country.country'); -phocacart import('phocacart.zone.zone'); -phocacart import('phocacart.related.related'); -phocacart import('phocacart.coupon.coupon'); -phocacart import('phocacart.shipping.shipping'); -phocacart import('phocacart.payment.payment'); -phocacart import('phocacart.render.renderadmin'); -phocacart import('phocacart.render.renderadminview'); -phocacart import('phocacart.render.renderadminviews'); -phocacart import('phocacart.render.renderadminmedia'); -phocacart import('phocacart.render.renderjs'); -phocacart import('phocacart.html.category'); -phocacart import('phocacart.html.batch'); -phocacart import('phocacart.html.featured'); -phocacart import('phocacart.category.category'); -phocacart import('phocacart.category.categorymultiple'); -phocacart import('phocacart.tag.tag'); -phocacart import('phocacart.user.user'); -phocacart import('phocacart.user.guestuser'); -phocacart import('phocacart.form.formuser'); -phocacart import('phocacart.form.formitems'); -phocacart import('phocacart.country.country'); -phocacart import('phocacart.product.product'); -phocacart import('phocacart.html.jgrid'); -phocacart import('phocacart.order.order'); -phocacart import('phocacart.order.orderstatus'); -phocacart import('phocacart.order.orderview'); -phocacart import('phocacart.order.orderrender'); -phocacart import('phocacart.currency.currency'); -phocacart import('phocacart.price.price'); -phocacart import('phocacart.download.download'); -phocacart import('phocacart.email.email'); -phocacart import('phocacart.stock.stock'); -phocacart import('phocacart.statistics.statistics'); -phocacart import('phocacart.tax.tax');*/ +*/ jimport('joomla.application.component.controller'); diff --git a/phocacart.xml b/phocacart.xml index 4294e748..7fde61fa 100644 --- a/phocacart.xml +++ b/phocacart.xml @@ -2,12 +2,12 @@ Phoca Cart Jan Pavelka (www.phoca.cz) - 28/04/2017 + 01/06/2017 www.phoca.cz Jan Pavelka GNU/GPL - 3.0.0 RC6 + 3.0.0 RC8 Phoca Cart install/script.php @@ -71,7 +71,9 @@ COM_PHOCACART_PAYMENT COM_PHOCACART_CURRENCIES COM_PHOCACART_TAXES - COM_PHOCACART_USERS + COM_PHOCACART_CUSTOMERS + COM_PHOCACART_CUSTOMER_GROUPS + COM_PHOCACART_REWARD_POINTS COM_PHOCACART_FORM_FIELDS COM_PHOCACART_REVIEWS COM_PHOCACART_COUPONS diff --git a/site/controller.php b/site/controller.php index 2a99e44d..4639a0dc 100644 --- a/site/controller.php +++ b/site/controller.php @@ -20,7 +20,7 @@ public function display($cachable = false, $urlparams = false) } /*if (JFactory::getApplication()->input->get('view') && JFactory::getApplication()->input->get('view') == 'feed') { // Default view for Feed is XML - // Don't forget, this settings needs to have set router.php too - in method PhocaCartParseRoute() + // Don't forget, this settings needs to have set router.php too - in method PhocacartParseRoute() $this->getView('feed', 'xml'); }*/ diff --git a/site/controllers/checkout.json.php b/site/controllers/checkout.json.php index bf41240d..c2e8ad85 100644 --- a/site/controllers/checkout.json.php +++ b/site/controllers/checkout.json.php @@ -218,6 +218,14 @@ function add($tpl = null){ //$cart = new PhocacartCart(); $cart = new PhocacartCartRendercart(1);// is subclass of PhocacartCart, so we can use only subclass + + // Get Phoca Cart Cart Module Parameters + $module = JModuleHelper::getModule('mod_phocacart_cart'); + $paramsM = new JRegistry($module->params); + $cart->params['display_image'] = $paramsM->get( 'display_image', 0 ); + $cart->params['display_checkout_link'] = $paramsM->get( 'display_checkout_link', 1 ); + + $added = $cart->addItems((int)$item['id'], (int)$item['catid'], (int)$item['quantity'], $item['attribute']); if (!$added) { @@ -245,7 +253,7 @@ function add($tpl = null){ // Render the layout - $d = ''; + $d = array(); $layoutP = new JLayoutFile('popup_add_to_cart', null, array('component' => 'com_phocacart')); $d['link_checkout'] = JRoute::_(PhocacartRoute::getCheckoutRoute((int)$item['id'], (int)$item['catid'])); diff --git a/site/controllers/checkout.php b/site/controllers/checkout.php index fd6fbc5d..f510371e 100644 --- a/site/controllers/checkout.php +++ b/site/controllers/checkout.php @@ -26,6 +26,7 @@ public function add() { $cart = new PhocacartCart(); + $added = $cart->addItems((int)$item['id'], (int)$item['catid'], (int)$item['quantity'], $item['attribute']); if ($added) { @@ -247,14 +248,20 @@ public function savepayment() { $item['return'] = $this->input->get( 'return', '', 'string' ); $item['phpaymentopt'] = $this->input->get( 'phpaymentopt', array(), 'array' ); $item['phcoupon'] = $this->input->get( 'phcoupon', '', 'string' ); + $item['phreward'] = $this->input->get( 'phreward', '', 'int' ); $guest = PhocacartUserGuestuser::getGuestUser(); + $params = $app->getParams(); $msgSuffix = ''; + $this->t['enable_coupons'] = $params->get( 'enable_coupons', 1 ); + $this->t['enable_rewards'] = $params->get( 'enable_rewards', 1 ); + + if(!empty($item['phpaymentopt']) && isset($item['phpaymentopt'][0]) && (int)$item['phpaymentopt'][0] > 0) { // Coupon $couponId = 0; - if (isset($item['phcoupon']) && $item['phcoupon'] != '') { + if (isset($item['phcoupon']) && $item['phcoupon'] != '' && $this->t['enable_coupons']) { $coupon = new PhocacartCoupon(); $coupon->setCoupon(0, $item['phcoupon']); @@ -276,6 +283,25 @@ public function savepayment() { } } + $rewards = array(); + $rewards['used'] = 0; + if (isset($item['phreward']) && $item['phreward'] != '' && $this->t['enable_rewards']) { + + $reward = new PhocacartReward(); + $rewards['used'] = $reward->checkReward((int)$item['phreward'], 1); + + + if($rewards['used'] === false) { + $msg = JText::_('COM_PHOCACART_REWARD_POINTS_NOT_ADDED'); + $app->enqueueMessage($msg.$msgSuffix, 'error'); + } else { + $msg = JText::_('COM_PHOCACART_REWARD_POINTS_ADDED'); + $app->enqueueMessage($msg, 'message'); + } + + + } + $model = $this->getModel('checkout'); if ($guest) { @@ -287,7 +313,7 @@ public function savepayment() { $app->enqueueMessage($msg, 'message'); } } else { - if(!$model->savePaymentAndCoupon((int)$item['phpaymentopt'][0], $couponId)) { + if(!$model->savePaymentAndCouponAndReward((int)$item['phpaymentopt'][0], $couponId, $rewards['used'])) { $msg = JText::_('COM_PHOCACART_ERROR_DATA_NOT_STORED'); $app->enqueueMessage($msg.$msgSuffix, 'error'); } else { @@ -397,10 +423,13 @@ public function order() { $orderMade = $order->saveOrderMain($item['phcomment']); if(!$orderMade) { - $msg = JText::_('COM_PHOCACART_ORDER_ERROR_PROCESSING'); - $mO = PhocacartRenderFront::renderMessageQueue($msg); - $app->enqueueMessage($mO.$msgSuffix, 'error'); + $msg = ''; + if (!PhocacartUtils::issetMessage()){ + $msg = JText::_('COM_PHOCACART_ORDER_ERROR_PROCESSING'); + } + $app->enqueueMessage($msg.$msgSuffix, 'error'); $app->redirect(base64_decode($item['return'])); + return true; } else { $cart = new PhocacartCart(); diff --git a/site/controllers/comparison.json.php b/site/controllers/comparison.json.php index f9a46be4..e0354281 100644 --- a/site/controllers/comparison.json.php +++ b/site/controllers/comparison.json.php @@ -40,7 +40,7 @@ public function add() { ob_end_clean(); // Render the layout - $d = ''; + $d = array(); $layoutC = new JLayoutFile('popup_add_to_compare', null, array('component' => 'com_phocacart')); $d['link_comparison'] = JRoute::_(PhocacartRoute::getComparisonRoute((int)$item['id']), (int)$item['catid']); @@ -106,7 +106,7 @@ public function remove() { ob_end_clean(); // Render the layout - $d = ''; + $d = array(); $layoutC = new JLayoutFile('popup_remove_from_compare', null, array('component' => 'com_phocacart')); $d['link_comparison'] = JRoute::_(PhocacartRoute::getComparisonRoute((int)$item['id']), (int)$item['catid']); diff --git a/site/controllers/wishlist.json.php b/site/controllers/wishlist.json.php index f63bed4b..c7fbd0f8 100644 --- a/site/controllers/wishlist.json.php +++ b/site/controllers/wishlist.json.php @@ -41,7 +41,7 @@ public function add() { ob_end_clean(); // Render the layout - $d = ''; + $d = array(); $layoutW = new JLayoutFile('popup_add_to_wishlist', null, array('component' => 'com_phocacart')); $d['link_wishlist'] = JRoute::_(PhocacartRoute::getWishListRoute((int)$item['id']), (int)$item['catid']); @@ -95,7 +95,7 @@ public function remove() { $item['return'] = $this->input->get( 'return', '', 'string' ); $item['wishlistview'] = $this->input->get( 'wishlistview', 0, 'int' ); - $wishlist = new PhocaCartWishlist(); + $wishlist = new PhocacartWishlist(); $added = $wishlist->removeItem((int)$item['id']); //$catid = PhocacartProduct::getCategoryByProductId((int)$item['id']); @@ -107,7 +107,7 @@ public function remove() { ob_end_clean(); // Render the layout - $d = ''; + $d = array(); $layoutW = new JLayoutFile('popup_remove_from_wishlist', null, array('component' => 'com_phocacart')); $d['link_wishlist'] = JRoute::_(PhocacartRoute::getWishListRoute((int)$item['id']), (int)$item['catid']); diff --git a/site/helpers/route.php b/site/helpers/route.php index 9df50e52..2bec4ae0 100644 --- a/site/helpers/route.php +++ b/site/helpers/route.php @@ -9,78 +9,15 @@ defined('_JEXEC') or die; jimport('joomla.application.component.helper'); -class PhocaMapsHelperRoute +class PhocacartHelperRoute { function getOrderRoute($id, $idAlias = '') { - $needles = array( - 'order' => (int) $id - ); - - - if ($idAlias != '') { - $id = $id . ':' . $idAlias; - } - - //Create the link - $link = 'index.php?option=com_phocacart&view=order&id='. $id; - - if($item = PhocaMapsHelperRoute::_findItem($needles)) { - if(isset($item->id)) { - $link .= '&Itemid='.$item->id; - } - } - - return $link; + return true; } - - - - - function _findItem($needles, $notCheckId = 0) - { - $component = JComponentHelper::getComponent('com_phocacart'); - $app = JFactory::getApplication(); - //$menus = &JApplication::getMenu('site', array()); - //$items = $menus->getItems('componentid', $component->id); - //$menu = &J Site::getMenu(); - $app = JFactory::getApplication('site'); - $menu = $app->getMenu(); - $items = $menu->getItems('component', 'com_phocacart'); - - if(!$items) { - return $app->input->get('id', 0, 'int'); - //return null; - } - - $match = null; - - - foreach($needles as $needle => $id) - { - - if ($notCheckId == 0) { - foreach($items as $item) { - if ((@$item->query['view'] == $needle) && (@$item->query['id'] == $id)) { - $match = $item; - break; - } - } - } else { - foreach($items as $item) { - if (@$item->query['view'] == $needle) { - $match = $item; - break; - } - } - } - - if(isset($match)) { - break; - } - } - return $match; + function _findItem($needles, $notCheckId = 0) { + return true; } } ?> diff --git a/site/layouts/button_add_to_cart_list.php b/site/layouts/button_add_to_cart_list.php index 59abc83f..5c6ce05b 100644 --- a/site/layouts/button_add_to_cart_list.php +++ b/site/layouts/button_add_to_cart_list.php @@ -9,33 +9,101 @@ defined('_JEXEC') or die(); $d = $displayData; -// One of the attributes is required, cannot add to cart -if ($d['attrrequired'] == 1) { ?> -
'; + + if ($d['icon'] == 1) { + + // ICON - ATTRIBUTE REQUIRED + echo '
'; + echo ''; + echo ''; + echo ''; + echo '
'; + + } else { + // BUTTON - ATTRIBUTE REQUIRED if ($d['addtocart'] == 1) { - ?> '; + echo ' '; + echo JText::_('COM_PHOCACART_ADD_TO_CART'); + echo ''; + } else if ($d['addtocart'] == 4) { - ?> -
- -
- + + echo ''; + echo ''; + echo ''; + } + } + + echo ''; + +} else { + // ATTRIBUTE NOT REQUIRED + if ($d['icon'] == 1) { + // If icon then we need ID of form to run it per jquery + echo ''; + } else { + // If not icon then we don't need ID form and we don't display ID because of not conflict with icon + // On one page there can be BUTTON and ICON Add to Cart together so don't display ID for buttons to not conflict + // with the same ID of icon () + echo ''; + } + + ?> - -
-
-
- -
+ '; + + if ($d['icon'] == 1) { + // ICON ATTRIBUTE NOT REQUIRED + if ($d['method'] == 0) { + // STANDARD (add to cart method) + echo ''; + + } else { + // AJAX (add to cart method) + echo ''; + + } + + } else { + // BUTTON ATTRIBUTE NOT REQUIRED + if ($d['addtocart'] == 1) { + echo ''; + + } else if ($d['addtocart'] == 4) { + echo ''; + } + } - \ No newline at end of file + echo '';// pull right + echo '
'; + echo JHtml::_('form.token'); + echo ''; +} +?> \ No newline at end of file diff --git a/site/layouts/cart_cart.php b/site/layouts/cart_cart.php index 0d2e2d4b..07d48aeb 100644 --- a/site/layouts/cart_cart.php +++ b/site/layouts/cart_cart.php @@ -162,6 +162,14 @@ echo '';// end row } + // REWARD DISCOUNT + if ($d['total'][5]['dnetto']) { + echo '
'; + echo '
'.JText::_('COM_PHOCACART_REWARD_POINTS').$d['total'][5]['rewardproducttxtsuffix'].'
'; + echo '
'.$price->getPriceFormat($d['total'][5]['dnetto'], 1).'
'; + echo '
';// end row + } + // PRODUCT DISCOUNT if ($d['total'][2]['dnetto']) { echo '
'; @@ -312,8 +320,10 @@ if ($app->getName() != 'administrator') { + $linkCheckout = JRoute::_(PhocacartRoute::getCheckoutRoute()); $linkCheckoutHtml = ''; + if (isset($d['params']['display_checkout_link']) && $d['params']['display_checkout_link'] == 1) { echo $linkCheckoutHtml; } else if (isset($d['params']['display_checkout_link']) && $d['params']['display_checkout_link'] == 2 && !empty($d['fullitems'])) { diff --git a/site/layouts/cart_checkout.php b/site/layouts/cart_checkout.php index 7a4f17ee..b2688d07 100644 --- a/site/layouts/cart_checkout.php +++ b/site/layouts/cart_checkout.php @@ -168,6 +168,30 @@ // DISCOUNT price for each product if ($p['display_discount_product'] == 1) { + + + // REWARD DISCOUNT + if($d['fullitems'][5][$k]['rewardproduct']) { + + $discountTitle = JText::_('COM_PHOCACART_REWARD_POINTS_PRICE'); + if (isset($d['fullitems'][5][$k]['rewardproducttitle']) && $d['fullitems'][5][$k]['rewardproducttitle'] != '') { + $discountTitle = $d['fullitems'][5][$k]['rewardproducttitle']; + } + + echo '
'; + echo '
'; + echo '
'.$discountTitle.' '.$d['fullitems'][5][$k]['rewardproducttxtsuffix'].'
'; + if ((int)$p['tax_calculation'] > 0) { + echo '
'.$price->getPriceFormat($d['fullitems'][5][$k]['netto']).'
'; + } + echo '
'; + if ((int)$p['tax_calculation'] > 0) { + echo '
'.$price->getPriceFormat($d['fullitems'][5][$k]['tax'] * $v['quantity']).'
'; + } + echo '
'.$price->getPriceFormat($d['fullitems'][5][$k]['final']).'
'; + echo '
'. "\n"; // end row + } + // PRODUCT DISCOUNT if($d['fullitems'][2][$k]['discountproduct']) { @@ -284,6 +308,15 @@ echo '
';// end row } + // REWARD DISCOUNT + if ($d['total'][5]['dnetto']) { + echo '
'; + echo '
'; + echo '
'.JText::_('COM_PHOCACART_REWARD_POINTS').$d['total'][5]['rewardproducttxtsuffix'].'
'; + echo '
'.$price->getPriceFormat($d['total'][5]['dnetto'], 1).'
'; + echo '
';// end row + } + // PRODUCT DISCOUNT if ($d['total'][2]['dnetto']) { echo '
'; @@ -407,6 +440,7 @@ } // BRUTTO + if ($d['total'][0]['brutto'] !== 0) { echo '
'; echo '
'; diff --git a/site/layouts/form_filter_text.php b/site/layouts/form_filter_text.php index d2b6a01d..4e881ad2 100644 --- a/site/layouts/form_filter_text.php +++ b/site/layouts/form_filter_text.php @@ -58,7 +58,7 @@
- +
diff --git a/site/models/categories.php b/site/models/categories.php index 7581edb3..448877f7 100644 --- a/site/models/categories.php +++ b/site/models/categories.php @@ -69,6 +69,7 @@ public function getCategoriesListQuery($id, $categoriesOrdering) { $wheres = array(); $user = JFactory::getUser(); $userLevels = implode (',', $user->getAuthorisedViewLevels()); + $userGroups = implode (',', PhocacartGroup::getGroupsById($user->id, 1, 1)); $app = JFactory::getApplication(); $params = $app->getParams(); @@ -104,6 +105,7 @@ public function getCategoriesListQuery($id, $categoriesOrdering) { } $wheres[] = " c.access IN (".$userLevels.")"; + $wheres[] = " (gc.group_id IN (".$userGroups.") OR gc.group_id IS NULL)"; /*$query = " SELECT c.id, c.title, c.alias, c.image, c.description, c.image as image, c.parent_id as parentid, COUNT(c.id) AS numdoc" . " FROM #__phocacart_categories AS c" @@ -119,7 +121,7 @@ public function getCategoriesListQuery($id, $categoriesOrdering) { //. " LEFT JOIN #__phocacart_product_categories AS pc ON pc.category_id = c.id" //. " LEFT JOIN #__phocacart_products AS a ON a.id = pc.product_id AND a.published = 1" //. " LEFT JOIN #__phocacart_products AS a ON a.catid = c.id AND a.published = 1" - + . ' LEFT JOIN #__phocacart_item_groups AS gc ON c.id = gc.item_id AND gc.type = 2'// type 2 is category . " WHERE " . implode( " AND ", $wheres ) . " GROUP BY c.id" . " ORDER BY ".$categoriesOrdering; @@ -129,7 +131,8 @@ public function getCategoriesListQuery($id, $categoriesOrdering) { #__phocacart_categories as s on s.parent_id = c.id group by c.id";*/ - + + //echo nl2br(str_replace('#__', 'jos_', $query->__toString())); return $query; } diff --git a/site/models/category.php b/site/models/category.php index a90bb620..4c9871c3 100644 --- a/site/models/category.php +++ b/site/models/category.php @@ -103,6 +103,7 @@ protected function getItemListQuery($categoryId, $count = 0) { $app = JFactory::getApplication(); $user = JFactory::getUser(); $userLevels = implode (',', $user->getAuthorisedViewLevels()); + $userGroups = implode (',', PhocacartGroup::getGroupsById($user->id, 1, 1)); $params = $app->getParams(); $p['switch_image_category_items'] = $params->get( 'switch_image_category_items', 0 ); @@ -120,16 +121,27 @@ protected function getItemListQuery($categoryId, $count = 0) { } $wheres[] = ' a.published = 1'; $wheres[] = ' c.published = 1'; + + + if ($this->getState('filter.language')) { $wheres[] = ' a.language IN ('.$this->_db->Quote(JFactory::getLanguage()->getTag()).','.$this->_db->Quote('*').')'; $wheres[] = ' c.language IN ('.$this->_db->Quote(JFactory::getLanguage()->getTag()).','.$this->_db->Quote('*').')'; } $itemOrdering = $this->getItemOrdering(); + // BE AWARE + // g.item_id is in this case product_id: phocacart_item_groups table is used for more instances: user, product, category + // so item_id in case type = 3 is product_id, items_id in case type = 2 is category_id + // see types: administrator\components\com_phocacart\libraries\phocacart\group\group.php $wheres[] = " c.access IN (".$userLevels.")"; $wheres[] = " a.access IN (".$userLevels.")"; + $wheres[] = " (ga.group_id IN (".$userGroups.") OR ga.group_id IS NULL)"; + $wheres[] = " (gc.group_id IN (".$userGroups.") OR gc.group_id IS NULL)"; + + if ($count == 1) { $q = ' SELECT a.id' . ' FROM #__phocacart_products AS a' @@ -137,11 +149,13 @@ protected function getItemListQuery($categoryId, $count = 0) { . " LEFT JOIN #__phocacart_product_categories AS pc ON pc.product_id = a.id" . " LEFT JOIN #__phocacart_categories AS c ON c.id = pc.category_id" . ' LEFT JOIN #__phocacart_attributes AS at ON a.id = at.product_id AND at.id > 0 AND at.required = 1' + . ' LEFT JOIN #__phocacart_item_groups AS ga ON a.id = ga.item_id AND ga.type = 3'// type 3 is product + . ' LEFT JOIN #__phocacart_item_groups AS gc ON c.id = gc.item_id AND gc.type = 2'// type 2 is category . ' WHERE ' . implode( ' AND ', $wheres ) . ' GROUP BY a.id'; } else { - $q = ' SELECT a.id, a.title, a.image, a.alias, a.description, c.id AS catid, c.title AS cattitle, c.alias AS catalias, a.price, a.price_original, t.id as taxid, t.tax_rate as taxrate, t.calculation_type as taxcalculationtype, t.title as taxtitle, a.date, a.sales, a.featured, a.external_id, a.unit_amount, a.unit_unit, a.external_link, a.external_text,'. $selImages + $q = ' SELECT a.id, a.title, a.image, a.alias, a.description, c.id AS catid, c.title AS cattitle, c.alias AS catalias, a.price, min(ppg.price) as group_price, max(pptg.points_received) as group_points_received, a.points_received, a.price_original, t.id as taxid, t.tax_rate as taxrate, t.calculation_type as taxcalculationtype, t.title as taxtitle, a.date, a.sales, a.featured, a.external_id, a.unit_amount, a.unit_unit, a.external_link, a.external_text,'. $selImages . ' AVG(r.rating) AS rating,' . ' at.required AS attribute_required' . ' FROM #__phocacart_products AS a' @@ -151,6 +165,14 @@ protected function getItemListQuery($categoryId, $count = 0) { . ' LEFT JOIN #__phocacart_taxes AS t ON t.id = a.tax_id' . ' LEFT JOIN #__phocacart_reviews AS r ON a.id = r.product_id AND r.id > 0' . ' LEFT JOIN #__phocacart_attributes AS at ON a.id = at.product_id AND at.id > 0 AND at.required = 1' + . ' LEFT JOIN #__phocacart_item_groups AS ga ON a.id = ga.item_id AND ga.type = 3'// type 3 is product + . ' LEFT JOIN #__phocacart_item_groups AS gc ON c.id = gc.item_id AND gc.type = 2'// type 2 is category + + // user is in more groups, select lowest price by best group + . ' LEFT JOIN #__phocacart_product_price_groups AS ppg ON a.id = ppg.product_id AND ppg.group_id IN (SELECT group_id FROM #__phocacart_item_groups WHERE item_id = a.id AND group_id IN ('.$userGroups.') AND type = 3)' + // user is in more groups, select highest points by best group + . ' LEFT JOIN #__phocacart_product_point_groups AS pptg ON a.id = pptg.product_id AND pptg.group_id IN (SELECT group_id FROM #__phocacart_item_groups WHERE item_id = a.id AND group_id IN ('.$userGroups.') AND type = 3)' + . $leftImages . ' WHERE ' . implode( ' AND ', $wheres ) . ' GROUP BY a.id' @@ -169,6 +191,8 @@ protected function getCategoriesQuery($categoryId, $subcategories = FALSE) { $user = JFactory::getUser(); $userLevels = implode (',', $user->getAuthorisedViewLevels()); + $userGroups = implode (',', PhocacartGroup::getGroupsById($user->id, 1, 1)); + // Get the current category or get parent categories of the current category if ($subcategories) { $wheres[] = " c.parent_id = ".(int)$categoryId; @@ -177,8 +201,9 @@ protected function getCategoriesQuery($categoryId, $subcategories = FALSE) { $wheres[] = " c.id= ".(int)$categoryId; } - $wheres[] = " c.published = 1"; - $wheres[] = " c.access IN (".$userLevels.")"; + $wheres[] = " c.published = 1"; + $wheres[] = " c.access IN (".$userLevels.")"; + $wheres[] = " (gc.group_id IN (".$userGroups.") OR gc.group_id IS NULL)"; if ($this->getState('filter.language')) { $wheres[] = ' c.language IN ('.$this->_db->Quote(JFactory::getLanguage()->getTag()).','.$this->_db->Quote('*').')'; @@ -190,6 +215,7 @@ protected function getCategoriesQuery($categoryId, $subcategories = FALSE) { . " FROM #__phocacart_categories AS c" //. " LEFT JOIN #__phocacart_product_categories AS pc ON pc.category_id = c.id" //. " LEFT JOIN #__phocacart_products AS a ON a.id = pc.product_id AND a.published = 1 AND a.access IN (".$userLevels.")" + . ' LEFT JOIN #__phocacart_item_groups AS gc ON c.id = gc.item_id AND gc.type = 2'// type 2 is category . " WHERE " . implode( " AND ", $wheres ) . " GROUP BY c.id" . " ORDER BY ".$categoryOrdering; @@ -197,6 +223,7 @@ protected function getCategoriesQuery($categoryId, $subcategories = FALSE) { $query = " SELECT c.id, c.parent_id, c.title, c.alias, c.description, c.metakey, c.metadesc, cc.title as parenttitle, c.parent_id as parentid, cc.alias as parentalias" . " FROM #__phocacart_categories AS c" . " LEFT JOIN #__phocacart_categories AS cc ON cc.id = c.parent_id" + . ' LEFT JOIN #__phocacart_item_groups AS gc ON c.id = gc.item_id AND gc.type = 2'// type 2 is category . " WHERE " . implode( " AND ", $wheres ) . " ORDER BY c.ordering"; } diff --git a/site/models/checkout.php b/site/models/checkout.php index 01f7b4a8..bbf63472 100644 --- a/site/models/checkout.php +++ b/site/models/checkout.php @@ -218,7 +218,7 @@ public function saveShipping($shippingId) { } - public function savePaymentAndCoupon($paymentId, $couponId) { + public function savePaymentAndCouponAndReward($paymentId, $couponId, $reward) { $app = JFactory::getApplication(); $user = JFactory::getUser(); if ((int)$user->id < 1) { @@ -229,6 +229,7 @@ public function savePaymentAndCoupon($paymentId, $couponId) { $data['payment'] = (int)$paymentId; $data['coupon'] = (int)$couponId; $data['user_id'] = (int)$user->id; + $data['reward'] = (int)$reward; $row = $this->getTable('PhocacartCart', 'Table'); diff --git a/site/models/fields/phocacaptcha.php b/site/models/fields/phocacaptcha.php index d2bb9bc1..2a79da56 100644 --- a/site/models/fields/phocacaptcha.php +++ b/site/models/fields/phocacaptcha.php @@ -20,12 +20,14 @@ protected function getInput() { $namespace = 'pc'.$params->get('session_suffix', $string); $captchaCnt = $session->get('captcha_cnt', 0, $namespace) + 1; + // Possible extension of different captcha $id = $session->get('captcha_id', '', $namespace); switch ($id){ default: case 1: $retval = PhocacartCaptchaRecaptcha::render(); + //$session->set('captcha_cnt', $captchaCnt, $namespace); break; } diff --git a/site/models/forms/question.xml b/site/models/forms/question.xml index 7dadf0f1..a3a63cc3 100644 --- a/site/models/forms/question.xml +++ b/site/models/forms/question.xml @@ -18,7 +18,7 @@ - + JALL - + diff --git a/site/models/item.php b/site/models/item.php index f32e647d..adc5f0ae 100644 --- a/site/models/item.php +++ b/site/models/item.php @@ -60,10 +60,15 @@ function getItemPrev($ordering, $catid) { private function getItemQueryOrdering($ordering, $catid, $direction) { + + $user = JFactory::getUser(); + $userLevels = implode (',', $user->getAuthorisedViewLevels()); + $userGroups = implode (',', PhocacartGroup::getGroupsById($user->id, 1, 1)); + $wheres[] = " pc.category_id = ".(int) $catid; - //$wheres[] = " c.catid= cc.id"; + //$wheres[] = " c.catid= c.id"; + $wheres[] = " a.published = 1"; $wheres[] = " c.published = 1"; - $wheres[] = " cc.published = 1"; if ($direction == 1) { $wheres[] = " pc.ordering < " . (int) $ordering; @@ -73,15 +78,23 @@ private function getItemQueryOrdering($ordering, $catid, $direction) { $order = 'ASC'; } + $wheres[] = " c.access IN (".$userLevels.")"; + $wheres[] = " a.access IN (".$userLevels.")"; + + $wheres[] = " (ga.group_id IN (".$userGroups.") OR ga.group_id IS NULL)"; + $wheres[] = " (gc.group_id IN (".$userGroups.") OR gc.group_id IS NULL)"; + if ($this->getState('filter.language')) { + $wheres[] = ' a.language IN ('.$this->_db->Quote(JFactory::getLanguage()->getTag()).','.$this->_db->Quote('*').')'; $wheres[] = ' c.language IN ('.$this->_db->Quote(JFactory::getLanguage()->getTag()).','.$this->_db->Quote('*').')'; - $wheres[] = ' cc.language IN ('.$this->_db->Quote(JFactory::getLanguage()->getTag()).','.$this->_db->Quote('*').')'; } - $query = ' SELECT c.id, c.title, c.alias, c.catid, cc.id AS categoryid, cc.title AS categorytitle, cc.alias AS categoryalias' - .' FROM #__phocacart_products AS c' - .' LEFT JOIN #__phocacart_product_categories AS pc ON pc.product_id = c.id' - .' LEFT JOIN #__phocacart_categories AS cc ON cc.id = pc.category_id' + $query = ' SELECT a.id, a.title, a.alias, a.catid, c.id AS categoryid, c.title AS categorytitle, c.alias AS categoryalias' + .' FROM #__phocacart_products AS a' + .' LEFT JOIN #__phocacart_product_categories AS pc ON pc.product_id = a.id' + .' LEFT JOIN #__phocacart_categories AS c ON c.id = pc.category_id' + . ' LEFT JOIN #__phocacart_item_groups AS ga ON a.id = ga.item_id AND ga.type = 3'// type 3 is product + . ' LEFT JOIN #__phocacart_item_groups AS gc ON c.id = gc.item_id AND gc.type = 2'// type 2 is category .' WHERE ' . implode( ' AND ', $wheres ) .' ORDER BY pc.ordering '.$order; @@ -93,6 +106,10 @@ private function getItemQuery( $itemId, $catId ) { //$app = JFactory::getApplication(); //$params = $app->getParams(); + + $user = JFactory::getUser(); + $userLevels = implode (',', $user->getAuthorisedViewLevels()); + $userGroups = implode (',', PhocacartGroup::getGroupsById($user->id, 1, 1)); $categoryId = 0; $category = $this->getCategory($itemId, $catId); @@ -101,22 +118,36 @@ private function getItemQuery( $itemId, $catId ) { } $wheres[] = " pc.category_id= ".(int) $categoryId; - $wheres[] = " pc.category_id= cc.id"; + $wheres[] = " pc.category_id= c.id"; $wheres[] = " i.published = 1"; - $wheres[] = " cc.published = 1"; + $wheres[] = " c.published = 1"; $wheres[] = " i.id = " . (int) $itemId; + $wheres[] = " c.access IN (".$userLevels.")"; + $wheres[] = " i.access IN (".$userLevels.")"; + + $wheres[] = " (ga.group_id IN (".$userGroups.") OR ga.group_id IS NULL)"; + $wheres[] = " (gc.group_id IN (".$userGroups.") OR gc.group_id IS NULL)"; + if ($this->getState('filter.language')) { $wheres[] = ' i.language IN ('.$this->_db->Quote(JFactory::getLanguage()->getTag()).','.$this->_db->Quote('*').')'; - $wheres[] = ' cc.language IN ('.$this->_db->Quote(JFactory::getLanguage()->getTag()).','.$this->_db->Quote('*').')'; + $wheres[] = ' c.language IN ('.$this->_db->Quote(JFactory::getLanguage()->getTag()).','.$this->_db->Quote('*').')'; } - $query = ' SELECT i.id, i.title, i.alias, i.description, pc.ordering, i.metadesc, i.metakey, i.image, i.description, i.description_long, i.price, i.price_original, i.stockstatus_a_id, i.stockstatus_n_id, i.min_quantity, i.min_multiple_quantity, i.stock, i.date, i.sales, i.featured, i.external_id, i.unit_amount, i.unit_unit, i.video, i.external_link, i.external_text, i.public_download_file, i.public_download_text, i.sku AS sku, i.upc AS upc, i.ean AS ean, i.jan AS jan, i.isbn AS isbn, i.mpn AS mpn, i.serial_number, cc.id AS catid, cc.title AS cattitle, cc.alias AS catalias, t.id as taxid, t.tax_rate as taxrate, t.title as taxtitle, t.calculation_type as taxcalculationtype, m.id as manufacturerid, m.title as manufacturertitle' + $query = ' SELECT i.id, i.title, i.alias, i.description, pc.ordering, i.metadesc, i.metakey, i.image, i.description, i.description_long, i.price, i.price_original, i.stockstatus_a_id, i.stockstatus_n_id, i.min_quantity, i.min_multiple_quantity, i.stock, i.date, i.sales, i.featured, i.external_id, i.unit_amount, i.unit_unit, i.video, i.external_link, i.external_text, i.public_download_file, i.public_download_text, i.sku AS sku, i.upc AS upc, i.ean AS ean, i.jan AS jan, i.isbn AS isbn, i.mpn AS mpn, i.serial_number, i.points_needed, i.points_received, c.id AS catid, c.title AS cattitle, c.alias AS catalias, t.id as taxid, t.tax_rate as taxrate, t.title as taxtitle, t.calculation_type as taxcalculationtype, m.id as manufacturerid, m.title as manufacturertitle, min(ppg.price) as group_price, max(pptg.points_received) as group_points_received' .' FROM #__phocacart_products AS i' .' LEFT JOIN #__phocacart_product_categories AS pc ON pc.product_id = i.id' - .' LEFT JOIN #__phocacart_categories AS cc ON cc.id = pc.category_id' + .' LEFT JOIN #__phocacart_categories AS c ON c.id = pc.category_id' .' LEFT JOIN #__phocacart_taxes AS t ON t.id = i.tax_id' .' LEFT JOIN #__phocacart_manufacturers AS m ON m.id = i.manufacturer_id' + . ' LEFT JOIN #__phocacart_item_groups AS ga ON i.id = ga.item_id AND ga.type = 3'// type 3 is product + . ' LEFT JOIN #__phocacart_item_groups AS gc ON c.id = gc.item_id AND gc.type = 2'// type 2 is category + + // user is in more groups, select lowest price by best group + . ' LEFT JOIN #__phocacart_product_price_groups AS ppg ON i.id = ppg.product_id AND ppg.group_id IN (SELECT group_id FROM #__phocacart_item_groups WHERE item_id = i.id AND group_id IN ('.$userGroups.') AND type = 3)' + // user is in more groups, select highest points by best group + . ' LEFT JOIN #__phocacart_product_point_groups AS pptg ON i.id = pptg.product_id AND pptg.group_id IN (SELECT group_id FROM #__phocacart_item_groups WHERE item_id = i.id AND group_id IN ('.$userGroups.') AND type = 3)' + .' WHERE ' . implode( ' AND ', $wheres ) .' ORDER BY pc.ordering'; @@ -128,6 +159,7 @@ private function getItemQuery( $itemId, $catId ) { function getCategory($itemId, $catId) { if (empty($this->category)) { $query = $this->getCategoryQuery( $itemId, $catId ); + $this->category = $this->_getList( $query, 0, 1 ); } return $this->category; @@ -135,29 +167,41 @@ function getCategory($itemId, $catId) { function getCategoryQuery($itemId, $catId) { + $user = JFactory::getUser(); + $userLevels = implode (',', $user->getAuthorisedViewLevels()); + $userGroups = implode (',', PhocacartGroup::getGroupsById($user->id, 1, 1)); + $wheres = array(); //$app = JFactory::getApplication(); //$params = $app->getParams(); - $wheres[] = " cc.published = 1"; + $wheres[] = " c.published = 1"; if ($this->getState('filter.language')) { $wheres[] = ' c.language IN ('.$this->_db->Quote(JFactory::getLanguage()->getTag()).','.$this->_db->Quote('*').')'; - $wheres[] = ' cc.language IN ('.$this->_db->Quote(JFactory::getLanguage()->getTag()).','.$this->_db->Quote('*').')'; + $wheres[] = ' c.language IN ('.$this->_db->Quote(JFactory::getLanguage()->getTag()).','.$this->_db->Quote('*').')'; } if ((int)$catId > 0) { - $wheres[] = " cc.id= ".(int)$catId; + $wheres[] = " c.id= ".(int)$catId; } else { - $wheres[] = " c.id= ".(int)$itemId; + $wheres[] = " a.id= ".(int)$itemId; } + + $wheres[] = " c.access IN (".$userLevels.")"; + $wheres[] = " a.access IN (".$userLevels.")"; + + $wheres[] = " (ga.group_id IN (".$userGroups.") OR ga.group_id IS NULL)"; + $wheres[] = " (gc.group_id IN (".$userGroups.") OR gc.group_id IS NULL)"; - $query = " SELECT cc.id, cc.title, cc.alias, cc.description, cc.parent_id" - . " FROM #__phocacart_categories AS cc" - . ' LEFT JOIN #__phocacart_product_categories AS pc ON pc.category_id = cc.id' - . " LEFT JOIN #__phocacart_products AS c ON c.id = pc.product_id" + $query = " SELECT c.id, c.title, c.alias, c.description, c.parent_id" + . " FROM #__phocacart_categories AS c" + . ' LEFT JOIN #__phocacart_product_categories AS pc ON pc.category_id = c.id' + . " LEFT JOIN #__phocacart_products AS a ON a.id = pc.product_id" + . ' LEFT JOIN #__phocacart_item_groups AS ga ON a.id = ga.item_id AND ga.type = 3'// type 3 is product + . ' LEFT JOIN #__phocacart_item_groups AS gc ON c.id = gc.item_id AND gc.type = 2'// type 2 is category . " WHERE " . implode( " AND ", $wheres ) - . " ORDER BY cc.ordering"; + . " ORDER BY c.ordering"; return $query; } diff --git a/site/models/items.php b/site/models/items.php index e65f6641..26dfb1cf 100644 --- a/site/models/items.php +++ b/site/models/items.php @@ -115,6 +115,7 @@ protected function getItemListQuery($count = 0) { $app = JFactory::getApplication(); $user = JFactory::getUser(); $userLevels = implode (',', $user->getAuthorisedViewLevels()); + $userGroups = implode (',', PhocacartGroup::getGroupsById($user->id, 1, 1)); $params = $app->getParams(); $wheres = array(); $lefts = array(); @@ -133,6 +134,8 @@ protected function getItemListQuery($count = 0) { $wheres[] = " c.access IN (".$userLevels.")"; $wheres[] = " a.access IN (".$userLevels.")"; + $wheres[] = " (ga.group_id IN (".$userGroups.") OR ga.group_id IS NULL)"; + $wheres[] = " (gc.group_id IN (".$userGroups.") OR gc.group_id IS NULL)"; // =FILTER= // -TAG- @@ -214,6 +217,9 @@ protected function getItemListQuery($count = 0) { $lefts[] = ' LEFT JOIN #__phocacart_categories AS c ON c.id = pc.category_id'; $lefts[] = ' LEFT JOIN #__phocacart_attributes AS at ON a.id = at.product_id AND at.id > 0'; + $lefts[] = ' LEFT JOIN #__phocacart_item_groups AS ga ON a.id = ga.item_id AND ga.type = 3';// type 3 is product + $lefts[] = ' LEFT JOIN #__phocacart_item_groups AS gc ON c.id = gc.item_id AND gc.type = 2';// type 2 is category + //$query = ' SELECT COUNT(DISTINCT a.id) AS count'; // 2.85ms 0.12mb $q = ' SELECT a.id' // 2.42ms 0.12mb . ' FROM #__phocacart_products AS a' @@ -231,7 +237,15 @@ protected function getItemListQuery($count = 0) { //$lefts[] = ' LEFT JOIN #__phocacart_attributes AS at ON a.id = at.product_id AND at.id > 0 AND at.required = 1'; $lefts[] = ' LEFT JOIN #__phocacart_attributes AS at ON a.id = at.product_id AND at.id > 0'; - $q = ' SELECT a.id, a.title, a.image, a.alias, a.unit_amount, a.unit_unit, a.description, c.id AS catid, c.title AS cattitle, c.alias AS catalias, a.price, a.price_original, t.id as taxid, t.tax_rate as taxrate, t.calculation_type as taxcalculationtype, t.title as taxtitle, a.date, a.sales, a.featured, a.external_id, a.external_link, a.external_text,'. $selImages + $lefts[] = ' LEFT JOIN #__phocacart_item_groups AS ga ON a.id = ga.item_id AND ga.type = 3';// type 3 is product + $lefts[] = ' LEFT JOIN #__phocacart_item_groups AS gc ON c.id = gc.item_id AND gc.type = 2';// type 2 is category + + // user is in more groups, select lowest price by best group + $lefts[] = ' LEFT JOIN #__phocacart_product_price_groups AS ppg ON a.id = ppg.product_id AND ppg.group_id IN (SELECT group_id FROM #__phocacart_item_groups WHERE item_id = a.id AND group_id IN ('.$userGroups.') AND type = 3)'; + // user is in more groups, select highest points by best group + $lefts[] = ' LEFT JOIN #__phocacart_product_point_groups AS pptg ON a.id = pptg.product_id AND pptg.group_id IN (SELECT group_id FROM #__phocacart_item_groups WHERE item_id = a.id AND group_id IN ('.$userGroups.') AND type = 3)'; + + $q = ' SELECT a.id, a.title, a.image, a.alias, a.unit_amount, a.unit_unit, a.description, c.id AS catid, c.title AS cattitle, c.alias AS catalias, a.price, min(ppg.price) as group_price, max(pptg.points_received) as group_points_received, a.price_original, t.id as taxid, t.tax_rate as taxrate, t.calculation_type as taxcalculationtype, t.title as taxtitle, a.date, a.sales, a.featured, a.external_id, a.external_link, a.external_text,'. $selImages . ' AVG(r.rating) AS rating,' . ' at.required AS attribute_required' . ' FROM #__phocacart_products AS a' @@ -250,6 +264,9 @@ protected function getCategoriesQuery( $categoryId, $subcategories = FALSE ) { $wheres = array(); $app = JFactory::getApplication(); $params = $app->getParams(); + $user = JFactory::getUser(); + $userLevels = implode (',', $user->getAuthorisedViewLevels()); + $userGroups = implode (',', PhocacartGroup::getGroupsById($user->id, 1, 1)); // Get the current category or get parent categories of the current category if ($subcategories) { @@ -260,6 +277,8 @@ protected function getCategoriesQuery( $categoryId, $subcategories = FALSE ) { } $wheres[] = " c.published = 1"; + $wheres[] = " c.access IN (".$userLevels.")"; + $wheres[] = " (gc.group_id IN (".$userGroups.") OR gc.group_id IS NULL)"; if ($this->getState('filter.language')) { $wheres[] = ' c.language IN ('.$this->_db->Quote(JFactory::getLanguage()->getTag()).','.$this->_db->Quote('*').')'; @@ -269,6 +288,7 @@ protected function getCategoriesQuery( $categoryId, $subcategories = FALSE ) { $query = " SELECT c.id, c.title, c.alias, COUNT(c.id) AS numdoc" . " FROM #__phocacart_categories AS c" . " LEFT JOIN #__phocacart_products AS a ON a.catid = c.id AND a.published = 1" + . ' LEFT JOIN #__phocacart_item_groups AS gc ON c.id = gc.item_id AND gc.type = 2'// type 2 is category . " WHERE " . implode( " AND ", $wheres ) . " GROUP BY c.id" . " ORDER BY ".$categoryOrdering; @@ -276,6 +296,7 @@ protected function getCategoriesQuery( $categoryId, $subcategories = FALSE ) { $query = " SELECT c.id, c.title, c.alias, c.description, c.metakey, c.metadesc, cc.title as parenttitle, c.parent_id as parentid, cc.alias as parentalias" . " FROM #__phocacart_categories AS c" . " LEFT JOIN #__phocacart_categories AS cc ON cc.id = c.parent_id" + . ' LEFT JOIN #__phocacart_item_groups AS gc ON c.id = gc.item_id AND gc.type = 2'// type 2 is category . " WHERE " . implode( " AND ", $wheres ) . " ORDER BY c.ordering"; } diff --git a/site/models/orders.php b/site/models/orders.php index 3cc56e79..a51de62c 100644 --- a/site/models/orders.php +++ b/site/models/orders.php @@ -79,10 +79,12 @@ protected function getOrderListQuery() { $ordering = $this->getOrderOrdering(); $query = ' SELECT o.*,' .' os.title AS status_title,' - .' t.amount AS total_amount' + .' t.amount AS total_amount,' + .' s.title AS shippingtitle, s.tracking_link as shippingtrackinglink, s.tracking_description as shippingtrackingdescription' .' FROM #__phocacart_orders AS o' .' LEFT JOIN #__phocacart_order_statuses AS os ON os.id = o.status_id' .' LEFT JOIN #__phocacart_order_total AS t ON o.id = t.order_id' + .' LEFT JOIN #__phocacart_shipping_methods AS s ON s.id = o.shipping_id' .' WHERE ' . implode( ' AND ', $wheres ) .' ORDER BY '.$ordering; diff --git a/site/models/question.php b/site/models/question.php index 2706753e..57a2fcfa 100644 --- a/site/models/question.php +++ b/site/models/question.php @@ -128,7 +128,7 @@ function store(&$data) { } - $send = PhocaCartEmail::sendQuestionMail($params->get('send_email_question'), $data, JFactory::getURI()->toString(), $params); + $send = PhocacartEmail::sendQuestionMail($params->get('send_email_question'), $data, JFactory::getURI()->toString(), $params); if (!$send) { $user = JFactory::getUser(); diff --git a/site/phocacart.php b/site/phocacart.php index 2188110b..237beda7 100644 --- a/site/phocacart.php +++ b/site/phocacart.php @@ -15,65 +15,11 @@ JLoader::registerPrefix('Phocacart', JPATH_ADMINISTRATOR . '/components/com_phocacart/libraries/phocacart'); /* -if (! class_exists('PhocaCartLoader')) { +if (! class_exists('PhocacartLoader')) { require_once( JPATH_ADMINISTRATOR.'/components/com_phocacart/libraries/loader.php'); } phocacart import('phocacart.utils.settings'); -phocacart import('phocacart.utils.utils'); -phocacart import('phocacart.utils.log'); -phocacart import('phocacart.security.security'); -phocacart import('phocacart.utils.extension'); -phocacart import('phocacart.category.category'); -phocacart import('phocacart.category.categorymultiple'); -phocacart import('phocacart.date.date'); -phocacart import('phocacart.path.path'); -phocacart import('phocacart.path.route'); -phocacart import('phocacart.access.access'); -phocacart import('phocacart.ordering.ordering'); -phocacart import('phocacart.image.image'); -phocacart import('phocacart.pagination.pagination'); -phocacart import('phocacart.shipping.shipping'); -phocacart import('phocacart.payment.payment'); -phocacart import('phocacart.cart.cart'); -phocacart import('phocacart.cart.cartdb'); -phocacart import('phocacart.cart.rendercart'); -phocacart import('phocacart.cart.rendercheckout'); -phocacart import('phocacart.price.price'); -phocacart import('phocacart.related.related'); -phocacart import('phocacart.tag.tag'); -phocacart import('phocacart.stock.stock'); -phocacart import('phocacart.attribute.attribute'); -phocacart import('phocacart.specification.specification'); -phocacart import('phocacart.review.review'); -phocacart import('phocacart.file.filethumbnail'); -phocacart import('phocacart.currency.currency'); -phocacart import('phocacart.form.formuser'); -phocacart import('phocacart.form.formitems'); -phocacart import('phocacart.zone.zone'); -phocacart import('phocacart.country.country'); -phocacart import('phocacart.region.region'); -phocacart import('phocacart.user.user'); -phocacart import('phocacart.user.guestuser'); -phocacart import('phocacart.render.renderjs'); -phocacart import('phocacart.coupon.coupon'); -phocacart import('phocacart.product.product'); -phocacart import('phocacart.order.order'); -phocacart import('phocacart.order.orderstatus'); -phocacart import('phocacart.order.orderview'); -phocacart import('phocacart.order.orderrender'); -phocacart import('phocacart.compare.compare'); -phocacart import('phocacart.wishlist.wishlist'); -phocacart import('phocacart.download.download'); -phocacart import('phocacart.render.renderfront'); -phocacart import('phocacart.email.email'); -phocacart import('phocacart.search.search'); -phocacart import('phocacart.feed.feed'); -phocacart import('phocacart.render.rendermedia'); -phocacart import('phocacart.captcha.recaptcha'); -phocacart import('phocacart.statistics.hits'); -phocacart import('phocacart.tax.tax'); - */ $controller = JControllerLegacy::getInstance('PhocaCart'); diff --git a/site/router.php b/site/router.php index 1d5cd967..0fbc068c 100644 --- a/site/router.php +++ b/site/router.php @@ -9,7 +9,7 @@ defined('_JEXEC') or die; /* -if (! class_exists('PhocaCartLoader')) { +if (! class_exists('PhocacartLoader')) { require_once( JPATH_ADMINISTRATOR.'/components/com_phocacart/libraries/loader.php'); } phocacart import('phocacart.category.category'); @@ -384,6 +384,7 @@ public function build(&$query) { public function parse(&$segments) { + $viewsNoId = array('categories', 'checkout', 'comparison', 'download', 'terms', 'account', 'orders', 'payment', 'info', 'items', 'wishlist'); $viewsId = array('category', 'item', 'items', 'feed'); $viewsNotOwnId = array('question'); @@ -409,6 +410,7 @@ public function parse(&$segments) { // Count route segments $count = count($segments); + /* * Standard routing for items. If we don't pick up an Itemid then we get the view from the segments @@ -420,6 +422,7 @@ public function parse(&$segments) { // Called if no menu item created $vars['id'] = $segments[$count - 1]; + return $vars; } @@ -427,12 +430,14 @@ public function parse(&$segments) { if ($count == 1) { if(isset($segments[0]) && in_array($segments[0], $viewsNoId)) { $vars['view'] = $segments[0]; + return $vars; } // Question can include ID/CATID but can be without ID/CATID if(isset($segments[0]) && in_array($segments[0], $viewsNotOwnId)) { $vars['view'] = $segments[0]; + return $vars; } } @@ -474,9 +479,7 @@ public function parse(&$segments) { $vars['id'] = $id; return $vars; - } - else - { + } else { // TO DO specify catid - load from libraries $query = $db->getQuery(true) ->select($db->quoteName(array('alias', 'catid'))) @@ -486,13 +489,18 @@ public function parse(&$segments) { $item1 = $db->loadObject(); - if ($item1) - { - if ($item1->alias == $alias) - { - $vars['view'] = 'item'; - $vars['catid'] = (int) $item1->catid; - $vars['id'] = (int) $id; + if ($item1) { + if ($item1->alias == $alias) { + + $vars['view'] = 'item'; + $vars['id'] = (int) $id; + $vars['catid'] = (int) $item1->catid; + + // We have direct link to category view and item1->catid is null + if ((int) $vars['catid'] == 0 && isset($item->query['id']) && $item->query['id'] > 0) { + $vars['catid'] = (int)$item->query['id']; + } + return $vars; } @@ -571,7 +579,7 @@ public function parse(&$segments) { } } - + return $vars; } /* @@ -649,7 +657,7 @@ public function parse(&$segments) { $found = 0; }*/ - + return $vars; } diff --git a/site/views/account/view.html.php b/site/views/account/view.html.php index 67222542..30709a45 100644 --- a/site/views/account/view.html.php +++ b/site/views/account/view.html.php @@ -41,9 +41,7 @@ function display($tpl = null) $this->t['actionbase64'] = base64_encode($this->t['action']); $this->t['linkaccount'] = JRoute::_(PhocacartRoute::getAccountRoute()); $this->t['linkcheckout'] = JRoute::_(PhocacartRoute::getCheckoutRoute()); - $this->t['load_bootstrap'] = $this->p->get( 'load_bootstrap', 0 ); $this->t['display_edit_profile'] = $this->p->get( 'display_edit_profile', 1 ); - $this->t['load_chosen'] = $this->p->get( 'load_chosen', 1 ); $lang = JFactory::getLanguage(); @@ -86,8 +84,8 @@ function display($tpl = null) } $media = new PhocacartRenderMedia(); - $media->loadBootstrap($this->t['load_bootstrap']); - $media->loadChosen($this->t['load_chosen']); + $media->loadBootstrap(); + $media->loadChosen(); PhocacartRenderJs::renderBillingAndShippingSame(); $this->_prepareDocument(); diff --git a/site/views/categories/tmpl/default.php b/site/views/categories/tmpl/default.php index f60a11f3..bfbabe58 100644 --- a/site/views/categories/tmpl/default.php +++ b/site/views/categories/tmpl/default.php @@ -12,10 +12,11 @@ echo '
'; +echo $this->t['event']->onCategoriesBeforeHeader; echo PhocacartRenderFront::renderHeader(); if ( $this->t['main_description'] != '') { - echo '
'. JHTML::_('content.prepare', $this->t['main_description']). '
'; + echo '
'. $this->t['main_description']. '
'; } if (!empty($this->t['categories'])) { echo '
'; diff --git a/site/views/categories/view.html.php b/site/views/categories/view.html.php index bcf6abad..b8e9da0e 100644 --- a/site/views/categories/view.html.php +++ b/site/views/categories/view.html.php @@ -28,8 +28,7 @@ public function display($tpl = null) { $this->t['cart_metakey'] = $this->p->get( 'cart_metakey', '' ); $this->t['cart_metadesc'] = $this->p->get( 'cart_metadesc', '' ); $this->t['main_description'] = $this->p->get( 'main_description', '' ); - $this->t['load_bootstrap'] = $this->p->get( 'load_bootstrap', 1 ); - $this->t['equal_height'] = $this->p->get( 'equal_height', 1 ); + $this->t['main_description'] = PhocacartRenderFront::renderArticle($this->t['main_description']); $this->t['columns_cats'] = $this->p->get( 'columns_cats', 3 ); $this->t['image_width_cats'] = $this->p->get( 'image_width_cats', '' ); $this->t['image_height_cats'] = $this->p->get( 'image_height_cats', '' ); @@ -37,12 +36,21 @@ public function display($tpl = null) { $this->t['category_name_link'] = $this->p->get( 'category_name_link', 0 ); $media = new PhocacartRenderMedia(); - $media->loadBootstrap($this->t['load_bootstrap']); - //$media->loadChosen($this->t['load_chosen']); - $media->loadEqualHeights($this->t['equal_height']); + $media->loadBootstrap(); + //$media->loadChosen(); + $media->loadEqualHeights(); $this->t['path'] = PhocacartPath::getPath('categoryimage'); + // Plugins ------------------------------------------ + JPluginHelper::importPlugin('pcv'); + $this->t['dispatcher'] = JEventDispatcher::getInstance(); + $this->t['event'] = new stdClass; + + $results = $this->t['dispatcher']->trigger('onCategoriesBeforeHeader', array('com_phocacart.categories', &$this->t['categories'], &$this->p)); + $this->t['event']->onCategoriesBeforeHeader = trim(implode("\n", $results)); + // END Plugins -------------------------------------- + $this->_prepareDocument(); parent::display($tpl); diff --git a/site/views/category/tmpl/default.php b/site/views/category/tmpl/default.php index da579e1e..7ce68738 100644 --- a/site/views/category/tmpl/default.php +++ b/site/views/category/tmpl/default.php @@ -38,7 +38,7 @@ echo '
'; - echo '
'; + echo '
'; foreach ($this->items as $v) { @@ -110,7 +110,7 @@ // :L: PRICE $dP = array(); if ($this->t['hide_price'] != 1) { - $dP['priceitems'] = $price->getPriceItems($v->price, $v->taxid, $v->taxrate, $v->taxcalculationtype, $v->taxtitle, $v->unit_amount, $v->unit_unit, 1); + $dP['priceitems'] = $price->getPriceItems($v->price, $v->taxid, $v->taxrate, $v->taxcalculationtype, $v->taxtitle, $v->unit_amount, $v->unit_unit, 1, 1, $v->group_price); $dP['priceitemsorig']= array(); if ($v->price_original != '' && $v->price_original > 0) { $dP['priceitemsorig'] = $price->getPriceItems($v->price_original, $v->taxid, $v->taxrate, $v->taxcalculationtype); @@ -127,6 +127,8 @@ // :L: ADD TO CART $dA = $dA2 = $dA3 = array(); + $icon['addtocart'] = ''; + if ((int)$this->t['category_addtocart'] == 1 || (int)$this->t['category_addtocart'] == 4 ) { $dA['link'] = $link;// link to item (product) view e.g. when there are required attributes - we cannot add it to cart @@ -135,17 +137,27 @@ $dA['catid'] = $this->t['categoryid']; $dA['return'] = $this->t['actionbase64']; $dA['attrrequired'] = 0; - $dA['addtocart'] = $this->t['category_addtocart']; + $dA['addtocart'] = $this->t['category_addtocart']; + $dA['method'] = $this->t['add_cart_method']; if (isset($v->attribute_required) && $v->attribute_required == 1) { $dA['attrrequired'] = 1; } + // Add To Cart as Icon + if ($this->t['display_addtocart_icon'] == 1) { + $dA['icon'] = 1;// Display as Icon + $icon['addtocart'] = $layoutA->render($dA); + } + $dA['icon'] = 0;// Set back to display as button + } else if ((int)$this->t['category_addtocart'] == 2 && (int)$v->external_id != '') { // e.g. paddle $dA2['external_id'] = (int)$v->external_id; $dA2['return'] = $this->t['actionbase64']; + } else if ((int)$this->t['category_addtocart'] == 3 && $v->external_link != '') { + $dA3['external_link'] = $v->external_link; $dA3['external_text'] = $v->external_text; $dA3['return'] = $this->t['actionbase64']; @@ -191,9 +203,12 @@ echo '
';// end desc if ($this->t['fade_in_action_icons'] == 0) { + echo '
'; echo $icon['compare']; // if set in options, it will be displayed on other place, so this is why it is printed this way echo $icon['wishlist']; echo $icon['quickview']; + echo $icon['addtocart']; + echo '
'; } echo '
';// end caption @@ -210,6 +225,7 @@ echo $icon['compare']; echo $icon['wishlist']; echo $icon['quickview']; + echo $icon['addtocart']; echo '
'; } @@ -233,6 +249,10 @@ if (!empty($dA3)) { echo $layoutA3->render($dA3);} echo '
';// end add to cart box + + $results = $this->t['dispatcher']->trigger('onCategoryItemAfterAddToCart', array('com_phocacart.category', &$v, &$this->p)); + echo trim(implode("\n", $results)); + echo '
'; echo '
';// end row-item 3/3 @@ -268,9 +288,12 @@ echo '
';// end desc if ($this->t['fade_in_action_icons'] == 0) { + echo '
'; echo $icon['compare']; // if set in options, it will be displayed on other place, so this is why it is printed this way echo $icon['wishlist']; echo $icon['quickview']; + echo $icon['addtocart']; + echo '
'; } echo '';// end caption @@ -287,6 +310,7 @@ echo $icon['compare']; echo $icon['wishlist']; echo $icon['quickview']; + echo $icon['addtocart']; echo ''; } @@ -307,6 +331,10 @@ if (!empty($dA3)) { echo $layoutA3->render($dA3);} echo '';// end add to cart box + + $results = $this->t['dispatcher']->trigger('onCategoryItemAfterAddToCart', array('com_phocacart.category', &$v, &$this->p)); + echo trim(implode("\n", $results)); + echo '
'; echo '';// end row-item 3/3 @@ -326,9 +354,12 @@ if ($this->t['fade_in_action_icons'] == 0) { + echo '
'; echo $icon['compare']; // if set in options, it will be displayed on other place, so this is why it is printed this way echo $icon['wishlist']; echo $icon['quickview']; + echo $icon['addtocart']; + echo '
'; } echo '
'; @@ -368,6 +399,10 @@ if (!empty($dA3)) { echo $layoutA3->render($dA3);} echo '';// end add to cart box + + $results = $this->t['dispatcher']->trigger('onCategoryItemAfterAddToCart', array('com_phocacart.category', &$v, &$this->p)); + echo trim(implode("\n", $results)); + echo '
'; @@ -377,6 +412,7 @@ echo $icon['compare']; echo $icon['wishlist']; echo $icon['quickview']; + echo $icon['addtocart']; echo ''; echo '';// end action box } diff --git a/site/views/category/tmpl/default_header.php b/site/views/category/tmpl/default_header.php index ca48bb23..854026e1 100644 --- a/site/views/category/tmpl/default_header.php +++ b/site/views/category/tmpl/default_header.php @@ -29,10 +29,13 @@ } } +echo $this->t['event']->onCategoryBeforeHeader; + $title = ''; if (isset($this->category[0]->title) && $this->category[0]->title != '') { $title = $this->category[0]->title; } + echo PhocacartRenderFront::renderHeader(array($title)); if ( isset($this->category[0]->description) && $this->category[0]->description != '') { diff --git a/site/views/category/tmpl/default_pagination.php b/site/views/category/tmpl/default_pagination.php index bec33b88..0d377d8c 100644 --- a/site/views/category/tmpl/default_pagination.php +++ b/site/views/category/tmpl/default_pagination.php @@ -40,11 +40,11 @@ echo '
'; - echo '
'. str_replace( 'class="inputbox"', 'class="inputbox form-control chosen-select"', $this->t['pagination']->getPagesLinks()) . '
'; + echo ''; echo '
'; - echo '
'; + echo ''; diff --git a/site/views/category/view.html.php b/site/views/category/view.html.php index 60a15de1..0b1aef3c 100644 --- a/site/views/category/view.html.php +++ b/site/views/category/view.html.php @@ -35,8 +35,6 @@ function display($tpl = null) { $this->t['cart_metakey'] = $this->p->get( 'cart_metakey', '' ); $this->t['cart_metadesc'] = $this->p->get( 'cart_metadesc', '' ); //$this->t['description'] = $this->p->get( 'description', '' ); - $this->t['load_bootstrap'] = $this->p->get( 'load_bootstrap', 0 ); - $this->t['equal_height'] = $this->p->get( 'equal_height', 0 ); $this->t['image_width_cat'] = $this->p->get( 'image_width_cat', '' ); $this->t['image_height_cat'] = $this->p->get( 'image_height_cat', '' ); //$this->t['image_link'] = $this->p->get( 'image_link', 0 ); @@ -47,17 +45,20 @@ function display($tpl = null) { $this->t['display_compare'] = $this->p->get( 'display_compare', 0 ); $this->t['display_wishlist'] = $this->p->get( 'display_wishlist', 0 ); $this->t['display_quickview'] = $this->p->get( 'display_quickview', 0 ); + $this->t['display_addtocart_icon'] = $this->p->get( 'display_addtocart_icon', 0 ); $this->t['fade_in_action_icons'] = $this->p->get( 'fade_in_action_icons', 0 ); $this->t['dynamic_change_price'] = $this->p->get( 'dynamic_change_price', 0 ); $this->t['category_addtocart'] = $this->p->get( 'category_addtocart', 1 ); - $this->t['load_chosen'] = $this->p->get( 'load_chosen', 1 ); + $this->t['dynamic_change_image'] = $this->p->get( 'dynamic_change_image', 0); $this->t['dynamic_change_price'] = $this->p->get( 'dynamic_change_price', 0 ); $this->t['add_compare_method'] = $this->p->get( 'add_compare_method', 0 ); + $this->t['add_wishlist_method'] = $this->p->get( 'add_wishlist_method', 0 ); $this->t['hide_price'] = $this->p->get( 'hide_price', 0 ); $this->t['hide_addtocart'] = $this->p->get( 'hide_addtocart', 0 ); $this->t['display_star_rating'] = $this->p->get( 'display_star_rating', 0 ); + $this->t['add_cart_method'] = $this->p->get( 'add_cart_method', 0 ); if ($this->t['hide_addtocart'] == 1) { @@ -88,22 +89,21 @@ function display($tpl = null) { $this->t['linkcomparison'] = JRoute::_(PhocacartRoute::getComparisonRoute(0, (int)$this->t['categoryid'])); $this->t['linkwishlist'] = JRoute::_(PhocacartRoute::getWishListRoute(0, (int)$this->t['categoryid'])); $this->t['limitstarturl'] = $this->t['limitstart'] > 0 ? '&start='.$this->t['limitstart'] : ''; - $this->t['class_thumbnail'] = $this->t['fade_in_action_icons'] ? '' : 'thumbnail'; - $this->t['row-flex'] = $this->t['equal_height'] ? 'row-flex' : ''; + $media = new PhocacartRenderMedia(); - $media->loadBootstrap($this->t['load_bootstrap']); - $media->loadChosen($this->t['load_chosen']); - //$media->loadEqualHeights($this->t['equal_height']); - $media->loadProductHover($this->t['fade_in_action_icons']); - + $media->loadBootstrap(); + $media->loadChosen(); + $this->t['class-row-flex'] = $media->loadEqualHeights(); + $this->t['class_thumbnail'] = $media->loadProductHover(); + PhocacartRenderJs::renderAjaxAddToCart(); PhocacartRenderJs::renderAjaxAddToCompare(); PhocacartRenderJs::renderAjaxAddToWishList(); - PhocacartRenderJs::renderSubmitPaginationTopForm($this->t['action'], '#phItemsBox', $this->t['load_chosen'], $this->t['equal_height']); + PhocacartRenderJs::renderSubmitPaginationTopForm($this->t['action'], '#phItemsBox'); if ($this->t['display_quickview'] == 1) { PhocacartRenderJs::renderAjaxQuickViewBox(); @@ -119,12 +119,24 @@ function display($tpl = null) { $this->_prepareDocument(); $this->t['pathcat'] = PhocacartPath::getPath('categoryimage'); $this->t['pathitem'] = PhocacartPath::getPath('productimage'); + + $model->hit((int)$this->t['categoryid']); + + // Plugins ------------------------------------------ + JPluginHelper::importPlugin('pcv'); + $this->t['dispatcher'] = JEventDispatcher::getInstance(); + $this->t['event'] = new stdClass; + + $results = $this->t['dispatcher']->trigger('onCategoryBeforeHeader', array('com_phocacart.category', &$this->items, &$this->p)); + $this->t['event']->onCategoryBeforeHeader = trim(implode("\n", $results)); + + // Foreach values are rendered in default foreaches + // END Plugins -------------------------------------- + + parent::display($tpl); } - $model->hit((int)$this->t['categoryid']); - - parent::display($tpl); } diff --git a/site/views/category/view.raw.php b/site/views/category/view.raw.php index 22231802..8fe7b9f8 100644 --- a/site/views/category/view.raw.php +++ b/site/views/category/view.raw.php @@ -35,8 +35,6 @@ function display($tpl = null) { $this->t['cart_metakey'] = $this->p->get( 'cart_metakey', '' ); $this->t['cart_metadesc'] = $this->p->get( 'cart_metadesc', '' ); //$this->t['description'] = $this->p->get( 'description', '' ); - $this->t['load_bootstrap'] = $this->p->get( 'load_bootstrap', 0 ); - $this->t['equal_height'] = $this->p->get( 'equal_height', 0 ); $this->t['image_width_cat'] = $this->p->get( 'image_width_cat', '' ); $this->t['image_height_cat'] = $this->p->get( 'image_height_cat', '' ); //$this->t['image_link'] = $this->p->get( 'image_link', 0 ); @@ -50,7 +48,6 @@ function display($tpl = null) { $this->t['fade_in_action_icons'] = $this->p->get( 'fade_in_action_icons', 0 ); $this->t['dynamic_change_price'] = $this->p->get( 'dynamic_change_price', 0 ); $this->t['category_addtocart'] = $this->p->get( 'category_addtocart', 1 ); - $this->t['load_chosen'] = $this->p->get( 'load_chosen', 1 ); $this->t['dynamic_change_image'] = $this->p->get( 'dynamic_change_image', 0); $this->t['dynamic_change_price'] = $this->p->get( 'dynamic_change_price', 0 ); $this->t['add_compare_method'] = $this->p->get( 'add_compare_method', 0 ); @@ -58,7 +55,8 @@ function display($tpl = null) { $this->t['hide_price'] = $this->p->get( 'hide_price', 0 ); $this->t['hide_addtocart'] = $this->p->get( 'hide_addtocart', 0 ); $this->t['display_star_rating'] = $this->p->get( 'display_star_rating', 0 ); - + $this->t['add_cart_method'] = $this->p->get( 'add_cart_method', 0 ); + $this->t['display_addtocart_icon'] = $this->p->get( 'display_addtocart_icon', 0 ); if ($this->t['hide_addtocart'] == 1) { $this->t['category_addtocart'] = 0; @@ -89,15 +87,25 @@ function display($tpl = null) { $this->t['linkcomparison'] = JRoute::_(PhocacartRoute::getComparisonRoute(0, (int)$this->t['categoryid'])); $this->t['linkwishlist'] = JRoute::_(PhocacartRoute::getWishListRoute(0, (int)$this->t['categoryid'])); $this->t['limitstarturl'] = $this->t['limitstart'] > 0 ? '&start='.$this->t['limitstart'] : ''; - $this->t['class_thumbnail'] = $this->t['fade_in_action_icons'] ? '' : 'thumbnail'; - $this->t['row-flex'] = $this->t['equal_height'] ? 'row-flex' : ''; $this->t['pathcat'] = PhocacartPath::getPath('categoryimage'); $this->t['pathitem'] = PhocacartPath::getPath('productimage'); - } - - $model->hit((int)$this->t['categoryid']); + + $media = new PhocacartRenderMedia(); + $this->t['class-row-flex'] = $media->loadEqualHeights(); + $this->t['class_thumbnail'] = $media->loadProductHover(); + + $model->hit((int)$this->t['categoryid']); + + // Plugins ------------------------------------------ + JPluginHelper::importPlugin('pcv'); + $this->t['dispatcher'] = JEventDispatcher::getInstance(); + $this->t['event'] = new stdClass; + + // Foreach values are rendered in default foreaches + // END Plugins -------------------------------------- - parent::display($tpl); + parent::display($tpl); + } } } diff --git a/site/views/checkout/tmpl/default.php b/site/views/checkout/tmpl/default.php index 8c91ba1f..f1e71126 100644 --- a/site/views/checkout/tmpl/default.php +++ b/site/views/checkout/tmpl/default.php @@ -13,16 +13,22 @@ if ( isset($this->t['checkout_desc']) && $this->t['checkout_desc'] != '') { // Checkout description - echo '
'. JHTML::_('content.prepare', $this->t['checkout_desc']). '
'; + echo '
'. $this->t['checkout_desc']. '
'; } echo $this->loadTemplate('cart'); +echo $this->t['event']->onCheckoutAfterCart; echo $this->loadTemplate('login'); +echo $this->t['event']->onCheckoutAfterLogin; echo $this->loadTemplate('address'); +echo $this->t['event']->onCheckoutAfterAddress; echo $this->loadTemplate('shipping'); +echo $this->t['event']->onCheckoutAfterShipping; echo $this->loadTemplate('payment'); +echo $this->t['event']->onCheckoutAfterPayment; echo $this->loadTemplate('confirm'); +echo $this->t['event']->onCheckoutAfterConfirm; diff --git a/site/views/checkout/tmpl/default_address.php b/site/views/checkout/tmpl/default_address.php index d3a12e5b..bdbdb4be 100644 --- a/site/views/checkout/tmpl/default_address.php +++ b/site/views/checkout/tmpl/default_address.php @@ -67,15 +67,33 @@ echo '
'; echo ''; - echo '
'; - echo '
'.JText::_('COM_PHOCACART_BILLING_ADDRESS').'
'; - echo $this->t['dataaddressoutput']['b']; - echo '
';// end row - echo '
'; - echo '
'.JText::_('COM_PHOCACART_SHIPPING_ADDRESS').'
'; - echo $this->t['dataaddressoutput']['s']; - echo '
';// end row + + if (isset($this->t['dataaddressoutput']['bsch']) && $this->t['dataaddressoutput']['bsch'] == 1) { + + echo '
'; + echo '
'.JText::_('COM_PHOCACART_BILLING_AND_SHIPPING_ADDRESS').'
'; + echo $this->t['dataaddressoutput']['b']; + echo '
';// end row + + //echo '
'; + //echo '
'.JText::_('COM_PHOCACART_SHIPPING_ADDRESS').'
'; + //echo JText::_('COM_PHOCACART_BILLING_AND_SHIPPING_ADDRESS_IS_THE_SAME'); + //echo '
'; + + } else { + + echo '
'; + echo '
'.JText::_('COM_PHOCACART_BILLING_ADDRESS').'
'; + echo $this->t['dataaddressoutput']['b']; + echo '
';// end row + + echo '
'; + echo '
'.JText::_('COM_PHOCACART_SHIPPING_ADDRESS').'
'; + echo $this->t['dataaddressoutput']['s']; + echo '
'; + } + echo '
';// end row echo '
'; diff --git a/site/views/checkout/tmpl/default_confirm.php b/site/views/checkout/tmpl/default_confirm.php index 5d886b38..b207eeeb 100644 --- a/site/views/checkout/tmpl/default_confirm.php +++ b/site/views/checkout/tmpl/default_confirm.php @@ -51,6 +51,23 @@ echo '
 
'; + if ($this->t['enable_captcha_checkout']) { + echo '
'; + + echo '
'; + echo '
'; + echo ''; + echo '
'; + + echo '
'.PhocacartCaptchaRecaptcha::render().'
'; + + echo '
';// end group + + echo '
';// end col + + echo '
 
'; + } + echo '
'; diff --git a/site/views/checkout/tmpl/default_payment.php b/site/views/checkout/tmpl/default_payment.php index 5669b687..9285b6dd 100644 --- a/site/views/checkout/tmpl/default_payment.php +++ b/site/views/checkout/tmpl/default_payment.php @@ -82,8 +82,9 @@ foreach($this->t['paymentmethods'] as $k => $v) { + $checked = ''; - if (isset($this->t['cartitems']['payment']) && (int)$this->t['cartitems']['payment'] == (int)$v->id) { + if (isset($v->selected) && $v->selected == 1 ) { $checked = 'checked="checked"'; } @@ -137,17 +138,25 @@ echo '
 
'; - echo '
'; - //echo '
'; - echo ''; - //echo '
'; - echo '
'; + // COUPON CODE + if ($this->t['enable_coupons'] == 1) { + echo '
'; + echo ''; + echo '
'; + } + + // REWARD POINTS + if ($this->t['rewards']['apply']) { + echo '
'; + echo ''; + echo '
'; + } echo '
';// end payment cost box echo '
';// end payment row echo '
'; - echo '
'; + echo '
'; echo ''; echo '
'; diff --git a/site/views/checkout/tmpl/default_shipping.php b/site/views/checkout/tmpl/default_shipping.php index 2a254e7a..9007badc 100644 --- a/site/views/checkout/tmpl/default_shipping.php +++ b/site/views/checkout/tmpl/default_shipping.php @@ -119,8 +119,9 @@ foreach($this->t['shippingmethods'] as $k => $v) { + $checked = ''; - if (isset($this->t['cartitems']['shipping']) && (int)$this->t['cartitems']['shipping'] == (int)$v->id) { + if (isset($v->selected) && $v->selected == 1 ) { $checked = 'checked="checked"'; } diff --git a/site/views/checkout/view.html.php b/site/views/checkout/view.html.php index 04f65e73..58239044 100644 --- a/site/views/checkout/view.html.php +++ b/site/views/checkout/view.html.php @@ -31,24 +31,28 @@ function display($tpl = null) { $this->p = $app->getParams(); $this->a = new PhocacartAccess(); $guest = PhocacartUserGuestuser::getGuestUser(); + $reward = new PhocacartReward(); $this->t['action'] = $uri->toString(); $this->t['actionbase64'] = base64_encode($this->t['action']); $this->t['linkcheckout'] = JRoute::_(PhocacartRoute::getCheckoutRoute()); $this->t['checkout_desc'] = $this->p->get( 'checkout_desc', ''); + $this->t['checkout_desc'] = PhocacartRenderFront::renderArticle($this->t['checkout_desc']); $this->t['stock_checkout'] = $this->p->get( 'stock_checkout', 0 ); $this->t['stock_checking'] = $this->p->get( 'stock_checking', 0 ); $this->t['guest_checkout'] = $this->p->get( 'guest_checkout', 0 ); - $this->t['load_bootstrap'] = $this->p->get( 'load_bootstrap', 0 ); - $this->t['load_chosen'] = $this->p->get( 'load_chosen', 1 ); $this->t['icon_suffix'] = $this->p->get( 'icon_suffix', '-circle' ); $this->t['display_shipping_desc'] = $this->p->get( 'display_shipping_desc', 0 ); $this->t['display_payment_desc'] = $this->p->get( 'display_payment_desc', 0 ); - $this->t['load_chosen'] = $this->p->get( 'load_chosen', 1 ); $this->t['zero_shipping_price'] = $this->p->get( 'zero_shipping_price', 1 ); $this->t['zero_payment_price'] = $this->p->get( 'zero_payment_price', 1 ); + $this->t['enable_coupons'] = $this->p->get( 'enable_coupons', 1 ); + $this->t['enable_rewards'] = $this->p->get( 'enable_rewards', 1 ); + + $this->t['enable_captcha_checkout'] = PhocacartCaptcha::enableCaptchaCheckout(); + $scrollTo = ''; @@ -150,7 +154,6 @@ function display($tpl = null) { $this->cart->addShippingCosts($shippingId); $this->t['shippingmethod'] = $this->cart->getShippingCosts(); - } else { // Shipping cost is not stored in cart, display possible shipping methods // We ask for total of cart because of amount rule @@ -170,7 +173,9 @@ function display($tpl = null) { if(isset($this->t['dataaddressoutput']['bregion']) && (int)$this->t['dataaddressoutput']['bregion']) { $region = (int)$this->t['dataaddressoutput']['bregion']; } - $this->t['shippingmethods'] = $shipping->getPossibleShippingMethods($total[0]['netto'], $total[0]['brutto'], $country, $region, $total[0]['weight']); + + + $this->t['shippingmethods'] = $shipping->getPossibleShippingMethods($total[0]['netto'], $total[0]['brutto'], $country, $region, $total[0]['weight'], $total[0]['max_length'], $total[0]['max_width'], $total[0]['max_height'], 0, $shippingId); } } @@ -209,7 +214,33 @@ function display($tpl = null) { if(isset($this->t['dataaddressoutput']['bregion']) && (int)$this->t['dataaddressoutput']['bregion']) { $region = (int)$this->t['dataaddressoutput']['bregion']; } - $this->t['paymentmethods'] = $payment->getPossiblePaymentMethods($total[0]['netto'], $total[0]['brutto'], $country, $region, $shippingId); + + $this->t['paymentmethods'] = $payment->getPossiblePaymentMethods($total[0]['netto'], $total[0]['brutto'], $country, $region, $shippingId, 0, $this->t['paymentmethod']['id']); + + $this->t['couponcodevalue'] = ''; + if ($this->cart->getCouponCode() != '') { + $this->t['couponcodevalue'] = $this->cart->getCouponCode(); + } + + // REWARD POINTS + $this->t['rewards'] = array(); + $this->t['rewards']['apply'] = false; + if ($this->t['enable_rewards']) { + if ($this->u->id > 0) { + $this->t['rewards']['needed'] = $this->cart->getRewardPointsNeeded(); + $this->t['rewards']['usertotal'] = $reward->getTotalPointsByUserId($this->u->id); + + $this->t['rewards']['usedvalue'] = ''; + if ($this->cart->getRewardPointsUsed() != '' && (int)$this->cart->getRewardPointsUsed() > 0) { + $this->t['rewards']['usedvalue'] = $this->cart->getRewardPointsUsed(); + } + + if ($this->t['rewards']['usertotal'] > 0) { + $this->t['rewards']['text'] = '('.JText::_('COM_PHOCACART_AVAILABLE_REWARD_POINTS').': '.(int)$this->t['rewards']['usertotal'].', '.JText::_('COM_PHOCACART_MAXIMUM_REWARD_POINTS_TO_USE').': '.(int)$this->t['rewards']['needed'].')'; + $this->t['rewards']['apply'] = true; + } + } + } } } @@ -236,50 +267,20 @@ function display($tpl = null) { } $media = new PhocacartRenderMedia(); - $media->loadBootstrap($this->t['load_bootstrap']); - $media->loadChosen($this->t['load_chosen']); - //$media->loadEqualHeights($this->t['equal_height']); - $document->addScript(JURI::root(true).'/media/com_phocacart/js/windowpopup.js'); + $media->loadBootstrap(); + $media->loadChosen(); + $media->loadWindowPopup(); + //Scroll to if ($scrollTo == '') { } else if ($scrollTo == 'phcheckoutaddressedit' || $scrollTo == 'phcheckoutshippingedit' || $scrollTo == 'phcheckoutpaymentedit') { - $js = "\n" - . 'jQuery(function() { - if (jQuery("#ph-msg-ns").length > 0){ - jQuery(document).scrollTop( jQuery("#system-message").offset().top ); - //jQuery(\'html,body\').animate({scrollTop: jQuery("#system-message").offset().top}, 1500 ); - } else { - jQuery(document).scrollTop( jQuery("#'.$scrollTo.'").offset().top ); - //jQuery(\'html, body\').animate({scrollTop: jQuery("#'.$scrollTo.'").offset().top}, 1500 ); - } - });'; - $document->addScriptDeclaration($js); + PhocacartRenderJs::renderJsScrollTo($scrollTo, 0); } else if ($scrollTo == 'phcheckoutpaymentview') { // last view - in fact phcheckoutconfirmedit - $js = "\n" - . 'jQuery(function() { - if (jQuery("#ph-msg-ns").length > 0){ - jQuery(document).scrollTop( jQuery("#system-message").offset().top ); - //jQuery(\'html,body\').animate({scrollTop: jQuery("#system-message").offset().top}, 1500 ); - } else { - //jQuery(document).scrollTop( jQuery("#'.$scrollTo.'").offset().top ); - jQuery(\'html,body\').animate({scrollTop: jQuery("#'.$scrollTo.'").offset().top}, 1500 ); - } - });'; - $document->addScriptDeclaration($js); + PhocacartRenderJs::renderJsScrollTo($scrollTo, 1); } else { - /*$js = "\n". 'jQuery(function() { - jQuery(\'html, body\').animate({ scrollTop: jQuery("#'.$scrollTo.'").offset().top}, 1000); - });';*/ - $js = "\n" - . 'jQuery(function() { - if (jQuery("#ph-msg-ns").length > 0){ - jQuery(document).scrollTop( jQuery("#system-message").offset().top ); - //jQuery(\'html,body\').animate({scrollTop: jQuery("#system-message").offset().top}, 1500 ); - } - });'; - $document->addScriptDeclaration($js); + PhocacartRenderJs::renderJsScrollTo('', 0); } @@ -292,6 +293,31 @@ function display($tpl = null) { $this->t['minmultipleqtyvalid'] = $this->cart->getMinimumMultipleQuantityValid(); $this->_prepareDocument(); + + // Plugins ------------------------------------------ + JPluginHelper::importPlugin('pcv'); + $this->t['dispatcher'] = JEventDispatcher::getInstance(); + $this->t['event'] = new stdClass; + + $results = $this->t['dispatcher']->trigger('onCheckoutAfterCart', array('com_phocacart.checkout', $this->a, &$this->p)); + $this->t['event']->onCheckoutAfterCart = trim(implode("\n", $results)); + + $results = $this->t['dispatcher']->trigger('onCheckoutAfterLogin', array('com_phocacart.checkout', $this->a, &$this->p)); + $this->t['event']->onCheckoutAfterLogin = trim(implode("\n", $results)); + + $results = $this->t['dispatcher']->trigger('onCheckoutAfterAddress', array('com_phocacart.checkout', $this->a, &$this->p)); + $this->t['event']->onCheckoutAfterAddress = trim(implode("\n", $results)); + + $results = $this->t['dispatcher']->trigger('onCheckoutAfterShipping', array('com_phocacart.checkout', $this->a, &$this->p)); + $this->t['event']->onCheckoutAfterShipping = trim(implode("\n", $results)); + + $results = $this->t['dispatcher']->trigger('onCheckoutAfterPayment', array('com_phocacart.checkout', $this->a, &$this->p)); + $this->t['event']->onCheckoutAfterPayment = trim(implode("\n", $results)); + + $results = $this->t['dispatcher']->trigger('onCheckoutAfterConfirm', array('com_phocacart.checkout', $this->a, &$this->p)); + $this->t['event']->onCheckoutAfterConfirm = trim(implode("\n", $results)); + + // END Plugins -------------------------------------- parent::display($tpl); } diff --git a/site/views/comparison/tmpl/default.php b/site/views/comparison/tmpl/default.php index d9c00bb6..7f334201 100644 --- a/site/views/comparison/tmpl/default.php +++ b/site/views/comparison/tmpl/default.php @@ -67,7 +67,7 @@ $c['title'] .= ''; if ($this->t['hide_price'] != 1) { - $c['price'] .= ''.$price->getPriceFormat($v['price']).''; + $c['price'] .= ''.$price->getPriceItem($v['price'], $v['group_price']).''; } $c['remove'] .= ''; @@ -78,7 +78,7 @@ $c['remove'] .= ''; $c['remove'] .= ''; $c['remove'] .= '
'; - $c['remove'] .= ''; + $c['remove'] .= ''; $c['remove'] .= '
'; $c['remove'] .= JHtml::_('form.token'); $c['remove'] .= ''; diff --git a/site/views/comparison/view.html.php b/site/views/comparison/view.html.php index 49a7e305..846a4548 100644 --- a/site/views/comparison/view.html.php +++ b/site/views/comparison/view.html.php @@ -25,12 +25,6 @@ function display($tpl = null) $this->t['cart_metakey'] = $this->p->get( 'cart_metakey', '' ); $this->t['cart_metadesc'] = $this->p->get( 'cart_metadesc', '' ); - $this->t['load_bootstrap'] = $this->p->get( 'load_bootstrap', 0 ); - /*$this->t['main_description'] = $this->p->get( 'main_description', '' ); - $this->t['equal_height'] = $this->p->get( 'equal_height', 1 ); - $this->t['columns_cats'] = $this->p->get( 'columns_cats', 3 ); - $this->t['image_width_cat'] = $this->p->get( 'image_width_cat', '' ); - $this->t['image_height_cat'] = $this->p->get( 'image_height_cat', '' );*/ $this->t['unit_size'] = $this->p->get( 'unit_size', 0 ); $this->t['unit_weight'] = $this->p->get( 'unit_weight', 0 ); @@ -97,9 +91,7 @@ function display($tpl = null) } $media = new PhocacartRenderMedia(); - $media->loadBootstrap($this->t['load_bootstrap']); - //$media->loadChosen($this->t['load_chosen']); - //$media->loadEqualHeights($this->t['equal_height']); + $media->loadBootstrap(); $this->t['pathitem'] = PhocacartPath::getPath('productimage'); $this->_prepareDocument(); diff --git a/site/views/download/view.html.php b/site/views/download/view.html.php index 0a9e0bdc..19e8ceb3 100644 --- a/site/views/download/view.html.php +++ b/site/views/download/view.html.php @@ -33,14 +33,8 @@ function display($tpl = null) $this->t['cart_metakey'] = $this->p->get( 'cart_metakey', '' ); $this->t['cart_metadesc'] = $this->p->get( 'cart_metadesc', '' ); - $this->t['load_bootstrap'] = $this->p->get( 'load_bootstrap', 0 ); $this->t['download_days'] = $this->p->get( 'download_days', 0 ); $this->t['download_count'] = $this->p->get( 'download_count', 0 ); - /*$this->t['main_description'] = $this->p->get( 'main_description', '' ); - $this->t['equal_height'] = $this->p->get( 'equal_height', 1 ); - $this->t['columns_cats'] = $this->p->get( 'columns_cats', 3 ); - $this->t['image_width_cat'] = $this->p->get( 'image_width_cat', '' ); - $this->t['image_height_cat'] = $this->p->get( 'image_height_cat', '' );*/ $uri = JFactory::getURI(); $this->t['action'] = $uri->toString(); @@ -48,10 +42,8 @@ function display($tpl = null) $this->t['linkdownload'] = JRoute::_(PhocacartRoute::getDownloadRoute()); $media = new PhocacartRenderMedia(); - $media->loadBootstrap($this->t['load_bootstrap']); - //$media->loadChosen($this->t['load_chosen']); - //$media->loadEqualHeights($this->t['equal_height']); - + $media->loadBootstrap(); + $this->t['pathfile'] = PhocacartPath::getPath('productfile'); $this->_prepareDocument(); parent::display($tpl); diff --git a/site/views/item/tmpl/default.php b/site/views/item/tmpl/default.php index 04cd0256..711ecdb8 100644 --- a/site/views/item/tmpl/default.php +++ b/site/views/item/tmpl/default.php @@ -38,6 +38,8 @@ } } +echo $this->t['event']->onItemBeforeHeader; + $title = ''; if (isset($this->item[0]->title) && $this->item[0]->title != '') { $title = $this->item[0]->title; @@ -51,7 +53,7 @@ } $x = $this->item[0]; -if (!empty($x)) { +if (!empty($x) && isset($x->id) && (int)$x->id > 0) { echo '
'; // === IMAGE PANEL @@ -114,7 +116,7 @@ if ($this->t['hide_price'] != 1) { $d = array(); - $d['priceitems'] = $price->getPriceItems($x->price, $x->taxid, $x->taxrate, $x->taxcalculationtype, $x->taxtitle, $x->unit_amount, $x->unit_unit, 1); + $d['priceitems'] = $price->getPriceItems($x->price, $x->taxid, $x->taxrate, $x->taxcalculationtype, $x->taxtitle, $x->unit_amount, $x->unit_unit, 1, 1, $x->group_price); $d['priceitemsorig']= array(); if ($x->price_original != '' && $x->price_original > 0) { @@ -126,6 +128,28 @@ echo '
'; } + // REWARD POINTS - NEEDED + $pointsN = PhocacartReward::getPoints($x->points_needed, 'needed'); + if ($pointsN) { + echo '
'; + echo '
'.JText::_('COM_PHOCACART_PRICE_IN_REWARD_POINTS').'
'; + + echo '
'.$pointsN.'
'; + echo '
'; + echo '
'; + } + + // REWARD POINTS - RECEIVED + $pointsR = PhocacartReward::getPoints($x->points_received, 'received', $x->group_points_received); + if ($pointsR) { + echo '
'; + echo '
'.JText::_('COM_PHOCACART_REWARD_POINTS').'
'; + + echo '
'.$pointsR.'
'; + echo '
'; + echo '
'; + } + // STOCK if($this->t['stock_status']['stock_status'] || $this->t['stock_status']['stock_count']) { @@ -241,6 +265,8 @@ echo ''; echo '
'; + echo $this->t['event']->onItemAfterAddToCart; + echo '
'; if (isset($x->sku) && $x->sku != '') { @@ -386,7 +412,8 @@ echo $layoutEL->render($d); } - + echo $this->t['event']->onItemBeforeEndPricePanel; + echo '
';// end right side echo '
';// end row 1 @@ -598,6 +625,38 @@ $active = ''; } + // PRICE HISTORY + if ($this->t['enable_price_history'] && $this->t['price_history_data']) { + $tabLiO .= '
  • '.JText::_('COM_PHOCACART_PRICE_HISTORY').'
  • '; + + $tabO .= '
    '; + $tabO .= '
    '; + + $tabO .= '
    '; + $tabO .= '
    '; + $tabO .= ''; + $tabO .= '
    '; + $tabO .= '
    '; + + + $tabO .= '
    '; + $tabO .= '
    '; + + } + + // TABS PLUGIN + if (!empty($this->t['event']->onItemInsideTabPanel) && is_array($this->t['event']->onItemInsideTabPanel)) { + foreach($this->t['event']->onItemInsideTabPanel as $k => $v) { + if (isset($v['title']) && isset($v['alias']) && isset($v['content'])) { + $tabLiO .= '
  • '.$v['title'].'
  • '; + $tabO .= '
    '; + $tabO .= $v['content']; + $tabO .= '
    '; + $active = ''; + } + } + } + if ($tabLiO != '') { @@ -616,6 +675,7 @@ echo ''; // end row 2 (bottom) + echo $this->t['event']->onItemAfterTabs; } diff --git a/site/views/item/tmpl/default.xml b/site/views/item/tmpl/default.xml index a8b69610..a16f8dd2 100644 --- a/site/views/item/tmpl/default.xml +++ b/site/views/item/tmpl/default.xml @@ -11,7 +11,11 @@
    - + + +
    diff --git a/site/views/item/tmpl/default_quickview.php b/site/views/item/tmpl/default_quickview.php new file mode 100644 index 00000000..f8efa05e --- /dev/null +++ b/site/views/item/tmpl/default_quickview.php @@ -0,0 +1,207 @@ + 'com_phocacart')); +$layoutA = new JLayoutFile('button_add_to_cart_item', null, array('component' => 'com_phocacart')); +$layoutA2 = new JLayoutFile('button_buy_now_paddle', null, array('component' => 'com_phocacart')); +$layoutQV = new JLayoutFile('popup_quickview', null, array('component' => 'com_phocacart')); +$layoutAtOS = new JLayoutFile('attribute_options_select', null, array('component' => 'com_phocacart')); +$layoutAtOC = new JLayoutFile('attribute_options_checkbox', null, array('component' => 'com_phocacart')); + +$x = $this->item[0]; +?> + \ No newline at end of file diff --git a/site/views/item/view.html.php b/site/views/item/view.html.php index 1c1680b1..51ab720d 100644 --- a/site/views/item/view.html.php +++ b/site/views/item/view.html.php @@ -35,24 +35,27 @@ function display($tpl = null){ $document = JFactory::getDocument(); $id = $app->input->get('id', 0, 'int'); $catid = $app->input->get('catid', 0, 'int'); + $this->category = $model->getCategory($id, $catid); + $this->item = $model->getItem($id, $catid); $this->t['catid'] = 0; if (isset($this->category[0]->id)) { $this->t['catid'] = (int)$this->category[0]->id; } + + + // PARAMS $this->t['tax_calculation'] = $this->p->get( 'tax_calculation', 0 ); $this->t['cart_metakey'] = $this->p->get( 'cart_metakey', '' ); $this->t['cart_metadesc'] = $this->p->get( 'cart_metadesc', '' ); - $this->t['load_bootstrap'] = $this->p->get( 'load_bootstrap', 0 ); $this->t['display_back'] = $this->p->get( 'display_back', 3 ); //$this->t['enable_social'] = $this->p->get( 'enable_social', 0 ); $this->t['enable_item_navigation'] = $this->p->get( 'enable_item_navigation', 0 ); $this->t['item_addtocart'] = $this->p->get( 'item_addtocart', 1 ); $this->t['enable_review'] = $this->p->get( 'enable_review', 1 ); - $this->t['load_chosen'] = $this->p->get( 'load_chosen', 1 ); $this->t['dynamic_change_image'] = $this->p->get( 'dynamic_change_image', 0); $this->t['dynamic_change_price'] = $this->p->get( 'dynamic_change_price', 0 ); $this->t['image_popup_method'] = $this->p->get( 'image_popup_method', 1 ); @@ -68,15 +71,15 @@ function display($tpl = null){ $this->t['title_next_prev'] = $this->p->get( 'title_next_prev', 1 ); $this->t['display_public_download'] = $this->p->get( 'display_public_download', 1 ); $this->t['display_external_link'] = $this->p->get( 'display_external_link', 1 ); - - + $this->t['enable_rewards'] = $this->p->get( 'enable_rewards', 1 ); + $this->t['enable_price_history'] = $this->p->get( 'enable_price_history', 0 ); if ($this->t['hide_addtocart'] == 1) { $this->t['item_addtocart'] = 0; } - if (!$this->item) { + if (!isset($this->item[0]->id) || (isset($this->item[0]->id) && $this->item[0]->id < 1)) { echo '
    '.JText::_('COM_PHOCACART_NO_PRODUCT_FOUND').'
    '; @@ -90,7 +93,11 @@ function display($tpl = null){ $this->t['attr_options'] = PhocacartAttribute::getAttributesAndOptions((int)$id); $this->t['specifications'] = PhocacartSpecification::getSpecificationGroupsAndSpecifications((int)$id); $this->t['reviews'] = PhocacartReview::getReviewsByProduct((int)$id); - + + if ($this->t['enable_price_history']) { + $this->t['price_history_data'] = PhocacartPriceHistory::getPriceHistoryChartById((int)$id); + } + $this->t['action'] = $uri->toString(); //$this->t['actionbase64'] = base64_encode(htmlspecialchars($this->t['action'])); $this->t['actionbase64'] = base64_encode($this->t['action']); @@ -111,13 +118,14 @@ function display($tpl = null){ $media = new PhocacartRenderMedia(); - $media->loadBootstrap($this->t['load_bootstrap']); - $media->loadChosen($this->t['load_chosen']); - + $media->loadBootstrap(); + $media->loadChosen(); $media->loadRating(); - - $media->loadPhocaSwapImage($this->t['dynamic_change_image']); + $media->loadPhocaSwapImage(); $media->loadPhocaAttribute(1); + if ($this->t['popup_askquestion'] == 1) { + $media->loadWindowPopup(); + } if ($this->t['image_popup_method'] == 2) { PhocacartRenderJs::renderMagnific(); @@ -135,9 +143,7 @@ function display($tpl = null){ PhocacartRenderJs::renderAjaxAddToCompare(); PhocacartRenderJs::renderAjaxAddToWishList(); - if ($this->t['popup_askquestion'] == 1) { - $document->addScript(JURI::root(true).'/media/com_phocacart/js/windowpopup.js'); - } + if (isset($this->category[0]) && is_object($this->category[0]) && isset($this->item[0]) && is_object($this->item[0])){ @@ -149,6 +155,28 @@ function display($tpl = null){ } $model->hit((int)$id); PhocacartStatisticsHits::productHit((int)$id); + + // Plugins ------------------------------------------ + JPluginHelper::importPlugin('pcv'); + $this->t['dispatcher'] = JEventDispatcher::getInstance(); + $this->t['event'] = new stdClass; + + $results = $this->t['dispatcher']->trigger('onItemBeforeHeader', array('com_phocacart.item', &$this->item, &$this->p)); + $this->t['event']->onItemBeforeHeader = trim(implode("\n", $results)); + + $results = $this->t['dispatcher']->trigger('onItemAfterAddToCart', array('com_phocacart.item', &$this->item, &$this->p)); + $this->t['event']->onItemAfterAddToCart = trim(implode("\n", $results)); + + $results = $this->t['dispatcher']->trigger('onItemBeforeEndPricePanel', array('com_phocacart.item', &$this->item, &$this->p)); + $this->t['event']->onItemBeforeEndPricePanel = trim(implode("\n", $results)); + + $results = $this->t['dispatcher']->trigger('onItemInsideTabPanel', array('com_phocacart.item', &$this->item, &$this->p)); + $this->t['event']->onItemInsideTabPanel = $results; + + $results = $this->t['dispatcher']->trigger('onItemAfterTabs', array('com_phocacart.item', &$this->item, &$this->p)); + $this->t['event']->onItemAfterTabs = trim(implode("\n", $results)); + // END Plugins -------------------------------------- + parent::display($tpl); } diff --git a/site/views/item/view.json.php b/site/views/item/view.json.php index d16bbfb6..75ca0875 100644 --- a/site/views/item/view.json.php +++ b/site/views/item/view.json.php @@ -55,13 +55,11 @@ function display($tpl = null){ $this->t['tax_calculation'] = $this->p->get( 'tax_calculation', 0 ); $this->t['cart_metakey'] = $this->p->get( 'cart_metakey', '' ); $this->t['cart_metadesc'] = $this->p->get( 'cart_metadesc', '' ); - $this->t['load_bootstrap'] = $this->p->get( 'load_bootstrap', 0 ); $this->t['display_back'] = $this->p->get( 'display_back', 3 ); //$this->t['enable_social'] = $this->p->get( 'enable_social', 0 ); // $this->t['enable_item_navigation'] = $this->p->get( 'enable_item_navigation', 0 ); $this->t['item_addtocart'] = $this->p->get( 'item_addtocart', 1 ); // $this->t['enable_review'] = $this->p->get( 'enable_review', 1 ); - $this->t['load_chosen'] = $this->p->get( 'load_chosen', 1 ); $this->t['dynamic_change_image'] = $this->p->get( 'dynamic_change_image', 0); $this->t['dynamic_change_price'] = $this->p->get( 'dynamic_change_price', 0 ); /* $this->t['image_popup_method'] = $this->p->get( 'image_popup_method', 1 ); @@ -74,7 +72,7 @@ function display($tpl = null){ $this->t['hide_attributes'] = $this->p->get( 'hide_attributes', 0 );/* $this->t['item_askquestion'] = $this->p->get( 'item_askquestion', 0 ); $this->t['popup_askquestion'] = $this->p->get( 'popup_askquestion', 1 );*/ - + $this->t['enable_rewards'] = $this->p->get( 'enable_rewards', 1 ); if ($this->t['hide_addtocart'] == 1) { $this->t['item_addtocart'] = 0; @@ -112,257 +110,13 @@ function display($tpl = null){ $this->t['linkitem'] = JRoute::_(PhocacartRoute::getItemRoute((int)$this->item[0]->id, (int)$this->category[0]->id)); - - /* - $media = new PhocacartRenderMedia(); - $media->loadBootstrap($this->t['load_bootstrap']); - $media->loadChosen($this->t['load_chosen']); - - $media->loadRating(); - $media->loadPhocaSwapImage($this->t['dynamic_change_image']); - $media->loadPhocaAttribute(1); - - if ($this->t['image_popup_method'] == 2) { - PhocacartRenderJs::renderMagnific(); - $this->t['image_rel'] = 'rel="magnific" class="magnific"'; - } else { - PhocacartRenderJs::renderPrettyPhoto(); - $this->t['image_rel'] = 'rel="prettyPhoto[pc_gal1]"'; + $o2 = ''; + if (!empty($this->item[0])) { + $o2 = $this->loadTemplate('quickview'); + $model->hit((int)$id); + PhocacartStatisticsHits::productHit((int)$id); } - if ($this->t['dynamic_change_price'] == 1) { - PhocacartRenderJs::renderAjaxChangeProductPriceByOptions((int)$this->item[0]->id, 'ph-item-price-box'); - } - - PhocacartRenderJs::renderAjaxAddToCart(); - PhocacartRenderJs::renderAjaxAddToCompare(); - PhocacartRenderJs::renderAjaxAddToWishList(); - - if ($this->t['popup_askquestion'] == 1) { - $document->addScript(JURI::root(true).'/media/com_phocacart/js/windowpopup.js'); - } - - - if (isset($this->category[0]) && is_object($this->category[0]) && isset($this->item[0]) && is_object($this->item[0])){ - $this->_prepareDocument($this->category[0], $this->item[0]); - } - - $this->t['pathitem'] = PhocacartPath::getPath('productimage');*/ - - $layoutP = new JLayoutFile('product_price', null, array('component' => 'com_phocacart')); - $layoutA = new JLayoutFile('button_add_to_cart_item', null, array('component' => 'com_phocacart')); - $layoutA2 = new JLayoutFile('button_buy_now_paddle', null, array('component' => 'com_phocacart')); - $layoutQV = new JLayoutFile('popup_quickview', null, array('component' => 'com_phocacart')); - $layoutAtOS = new JLayoutFile('attribute_options_select', null, array('component' => 'com_phocacart')); - $layoutAtOC = new JLayoutFile('attribute_options_checkbox', null, array('component' => 'com_phocacart')); - - - - -$o = ''; -$x = $this->item[0]; -if (!empty($x)) { - - - $o[] = '

    '.$x->title.'

    '; - - $o[] = '
    '; - - // === IMAGE PANEL - $o[] = '';// end image panel - - - // === PRICE PANEL - $o[] = '
    '; - - - - // :L: PRICE - $price = new PhocacartPrice;// Can be used by options - if ($this->t['hide_price'] != 1) { - - $d = array(); - $d['priceitems'] = $price->getPriceItems($x->price, $x->taxid, $x->taxrate, $x->taxcalculationtype, $x->taxtitle, $x->unit_amount, $x->unit_unit, 1); - - $d['priceitemsorig']= array(); - if ($x->price_original != '' && $x->price_original > 0) { - $d['priceitemsorig'] = $price->getPriceItems($x->price_original, $x->taxid, $x->taxrate, $x->taxcalculationtype); - } - $d['class'] = 'ph-item-price-box'; - $o[] = '
    '; - $o[] = $layoutP->render($d); - $o[] = '
    '; - } - - // STOCK - if($this->t['stock_status']['stock_status'] || $this->t['stock_status']['stock_count']) { - - $o[] = '
    '; - $o[] = '
    '.JText::_('COM_PHOCACART_AVAILABILITY').'
    '; - - $o[] = '
    '.JText::_($this->t['stock_status_output']).'
    '; - $o[] = '
    '; - $o[] = '
    '; - } - - if($this->t['stock_status']['min_quantity']) { - - $o[] = '
    '; - $o[] = '
    '.JText::_('COM_PHOCACART_MINIMUM_ORDER_QUANTITY').'
    '; - $o[] = '
    '.$this->t['stock_status']['min_quantity'].'
    '; - $o[] = '
    '; - $o[] = '
    '; - - } - - if($this->t['stock_status']['min_multiple_quantity']) { - - $o[] = '
    '; - $o[] = '
    '.JText::_('COM_PHOCACART_MINIMUM_MULTIPLE_ORDER_QUANTITY').'
    '; - $o[] = '
    '.$this->t['stock_status']['min_multiple_quantity'].'
    '; - $o[] = '
    '; - $o[] = '
    '; - - } - - // This form can get two events: - // when option selected - price or image is changed id=phItemPriceBoxForm - // when ajax cart is active and submit button is clicked class=phItemCartBoxForm - // - - $o[] = '
    '; - - // data-id="'.(int)$x->id.'" - needed for dynamic change of price in quick view, we need to get the ID per javascript - // because Quick View = Items, Category View and there are more products listed, not like in item id - - // ATTRIBUTES, OPTIONS - if (!empty($this->t['attr_options']) && $this->t['hide_attributes'] != 1) { - - $o[] = PhocacartRenderJs::renderPhSwapImageInitialize(1, $this->t['dynamic_change_image'], 1); - - $o[] = '
    '; - $o[] = '

    '.JText::_('COM_PHOCACART_AVAILABLE_OPTIONS').'

    '; - - foreach ($this->t['attr_options'] as $k => $v) { - - - // SELECTBOX COLOR, SELECTBOX IMAGE - if ($v->type == 2 || $v->type == 3) { - $o[] = PhocacartRenderJs::renderPhAttributeSelectBoxInitialize((int)$v->id, (int)$v->type, 1); - } - - // If the attribute is required, return different required parts (attribute - html5, class - jquery, span - heading) - // Set jquery required validation, which should help to html 5 in case of checkboxes (see more info in the funtion) - // TYPES SET for JQUERY require control: 4 5 6 - $req = PhocacartRenderJs::renderRequiredParts((int)$v->id, (int)$v->required); - - // HTML5 does not know to check checkboxes - if some value is set - // CHECKBOX, CHECKBOX COLOR, CHECKBOX IMAGE - if($v->type == 4 || $v->type == 5 || $v->type == 6) { - $o[] = PhocacartRenderJs::renderCheckBoxRequired((int)$v->id, 1); - } - - $o[] = '
    '.$v->title.$req['span'].'
    '; - if(!empty($v->options)) { - - $d = array(); - $d['attribute'] = $v; - $d['required'] = $req; - $d['dynamic_change_image'] = $this->t['dynamic_change_image']; - $d['pathitem'] = $this->t['pathitem']; - $d['price'] = $price; - - if ($v->type == 1 || $v->type == 2 || $v->type == 3) { - $o[] = $layoutAtOS->render($d);// SELECTBOX, SELECTBOX COLOR, SELECTBOX IMAGE - } else if ($v->type == 4 || $v->type == 5 || $v->type == 6) { - $o[] = $layoutAtOC->render($d);// CHECKBOX, CHECKBOX COLOR, CHECKBOX COLOR - } - } - - } - $o[] = '
    '; - $o[] = '
    '; - } - - // :L: ADD TO CART - - if ((int)$this->t['item_addtocart'] == 1 || (int)$this->t['item_addtocart'] == 4) { - - $d = array(); - $d['id'] = (int)$x->id; - $d['catid'] = $this->t['catid']; - $d['return'] = $this->t['actionbase64']; - $d['addtocart'] = $this->t['item_addtocart']; - $o[] = $layoutA->render($d); - - } else if ((int)$this->t['item_addtocart'] == 2 && (int)$x->external_id != '') { - $d = array(); - $d['external_id'] = (int)$x->external_id; - $d['return'] = $this->t['actionbase64']; - - $o[] = $layoutA2->render($d); - } - - $o[] = '
    '; - $o[] = '
    '; - - - $o[] = '
    ';// end right side price panel - $o[] = '
    ';// end row - - - -} - - - $d = array(); - $d['content'] = implode("\n", $o); - // Popup with info - Continue,Proceed to Comparison list - //ob_start(); - $o2 = $layoutQV->render($d); - //$o2 = ob_get_contents(); - //ob_end_clean(); - - //echo implode("\n", $o); - - $model->hit((int)$id); - PhocacartStatisticsHits::productHit((int)$id); - $response = array( 'status' => '1', 'item' => '', @@ -370,15 +124,9 @@ function display($tpl = null){ echo json_encode($response); return; - - } } - - - - protected function _prepareDocument() { - } + protected function _prepareDocument() {} } ?> \ No newline at end of file diff --git a/site/views/items/tmpl/default.php b/site/views/items/tmpl/default.php index 82615ae7..7f8bde3f 100644 --- a/site/views/items/tmpl/default.php +++ b/site/views/items/tmpl/default.php @@ -38,7 +38,7 @@ echo '
    '; - echo '
    '; + echo '
    '; foreach ($this->items as $v) { @@ -113,7 +113,7 @@ // :L: PRICE $dP = array(); if ($this->t['hide_price'] != 1) { - $dP['priceitems'] = $price->getPriceItems($v->price, $v->taxid, $v->taxrate, $v->taxcalculationtype, $v->taxtitle, $v->unit_amount, $v->unit_unit, 1); + $dP['priceitems'] = $price->getPriceItems($v->price, $v->taxid, $v->taxrate, $v->taxcalculationtype, $v->taxtitle, $v->unit_amount, $v->unit_unit, 1, 1, $v->group_price); $dP['priceitemsorig']= array(); if ($v->price_original != '' && $v->price_original > 0) { $dP['priceitemsorig'] = $price->getPriceItems($v->price_original, $v->taxid, $v->taxrate, $v->taxcalculationtype); @@ -130,6 +130,7 @@ // :L: ADD TO CART $dA = $dA2 = $dA3 = array(); + $icon['addtocart'] = ''; if ((int)$this->t['category_addtocart'] == 1 || (int)$this->t['category_addtocart'] == 4 ) { $dA['link'] = $link;// link to item (product) view e.g. when there are required attributes - we cannot add it to cart @@ -139,10 +140,18 @@ $dA['return'] = $this->t['actionbase64']; $dA['attrrequired'] = 0; $dA['addtocart'] = $this->t['category_addtocart']; + $dA['method'] = $this->t['add_cart_method']; if (isset($v->attribute_required) && $v->attribute_required == 1) { $dA['attrrequired'] = 1; } + // Add To Cart as Icon + if ($this->t['display_addtocart_icon'] == 1) { + $dA['icon'] = 1;// Display as Icon + $icon['addtocart'] = $layoutA->render($dA); + } + $dA['icon'] = 0;// Set back to display as button + } else if ((int)$this->t['category_addtocart'] == 2 && (int)$v->external_id != '') { // e.g. paddle $dA2['external_id'] = (int)$v->external_id; @@ -194,9 +203,12 @@ echo '
    ';// end desc if ($this->t['fade_in_action_icons'] == 0) { + echo '
    '; echo $icon['compare']; // if set in options, it will be displayed on other place, so this is why it is printed this way echo $icon['wishlist']; echo $icon['quickview']; + echo $icon['addtocart']; + echo '
    '; } echo '
    ';// end caption @@ -213,6 +225,7 @@ echo $icon['compare']; echo $icon['wishlist']; echo $icon['quickview']; + echo $icon['addtocart']; echo '
    '; } @@ -236,6 +249,10 @@ if (!empty($dA3)) { echo $layoutA3->render($dA3);} echo '';// end add to cart box + + $results = $this->t['dispatcher']->trigger('onItemsItemAfterAddToCart', array('com_phocacart.items', &$v, &$this->p)); + echo trim(implode("\n", $results)); + echo '
    '; echo '';// end row-item 3/3 @@ -271,9 +288,12 @@ echo '';// end desc if ($this->t['fade_in_action_icons'] == 0) { + echo '
    '; echo $icon['compare']; // if set in options, it will be displayed on other place, so this is why it is printed this way echo $icon['wishlist']; echo $icon['quickview']; + echo $icon['addtocart']; + echo '
    '; } echo '';// end caption @@ -290,6 +310,7 @@ echo $icon['compare']; echo $icon['wishlist']; echo $icon['quickview']; + echo $icon['addtocart']; echo ''; } @@ -310,6 +331,10 @@ if (!empty($dA3)) { echo $layoutA3->render($dA3);} echo '';// end add to cart box + + $results = $this->t['dispatcher']->trigger('onItemsItemAfterAddToCart', array('com_phocacart.items', &$v, &$this->p)); + echo trim(implode("\n", $results)); + echo '
    '; echo '';// end row-item 3/3 @@ -329,15 +354,18 @@ if ($this->t['fade_in_action_icons'] == 0) { + echo '
    '; echo $icon['compare']; // if set in options, it will be displayed on other place, so this is why it is printed this way echo $icon['wishlist']; echo $icon['quickview']; + echo $icon['addtocart']; + echo '
    '; } echo '
    '; // CAPTION, DESCRIPTION BOX - echo '
    '; + echo '
    '; echo '

    '. PhocacartRenderFront::getLinkedTitle($this->t['product_name_link'], $v) . '

    '; echo '
    ';// end caption @@ -368,6 +396,10 @@ if (!empty($dA3)) { echo $layoutA3->render($dA3);} echo '
    ';// end add to cart box + + $results = $this->t['dispatcher']->trigger('onItemsItemAfterAddToCart', array('com_phocacart.items', &$v, &$this->p)); + echo trim(implode("\n", $results)); + echo '
    '; @@ -377,6 +409,7 @@ echo $icon['compare']; echo $icon['wishlist']; echo $icon['quickview']; + echo $icon['addtocart']; echo ''; echo '';// end action box } diff --git a/site/views/items/tmpl/default_header.php b/site/views/items/tmpl/default_header.php index 2b8eaff0..5ec24a00 100644 --- a/site/views/items/tmpl/default_header.php +++ b/site/views/items/tmpl/default_header.php @@ -31,6 +31,8 @@ } } +echo $this->t['event']->onItemsBeforeHeader; + $title = ''; if (isset($this->category[0]->title) && $this->category[0]->title != '') { $title = $this->category[0]->title; diff --git a/site/views/items/tmpl/default_pagination.php b/site/views/items/tmpl/default_pagination.php index bec33b88..0d377d8c 100644 --- a/site/views/items/tmpl/default_pagination.php +++ b/site/views/items/tmpl/default_pagination.php @@ -40,11 +40,11 @@ echo '
    '; - echo '
    '. str_replace( 'class="inputbox"', 'class="inputbox form-control chosen-select"', $this->t['pagination']->getPagesLinks()) . '
    '; + echo ''; echo '
    '; - echo '
    '; + echo ''; diff --git a/site/views/items/view.html.php b/site/views/items/view.html.php index fab53c64..6b39b7ce 100644 --- a/site/views/items/view.html.php +++ b/site/views/items/view.html.php @@ -38,8 +38,6 @@ function display($tpl = null) { $this->t['cart_metakey'] = $this->p->get( 'cart_metakey', '' ); $this->t['cart_metadesc'] = $this->p->get( 'cart_metadesc', '' ); //$this->t['description'] = $this->p->get( 'description', '' ); - $this->t['load_bootstrap'] = $this->p->get( 'load_bootstrap', 0 ); - $this->t['equal_height'] = $this->p->get( 'equal_height', 0 ); $this->t['image_width_cat'] = $this->p->get( 'image_width_cat', '' ); $this->t['image_height_cat'] = $this->p->get( 'image_height_cat', '' ); //$this->t['image_link'] = $this->p->get( 'image_link', 0 ); @@ -50,17 +48,19 @@ function display($tpl = null) { $this->t['display_compare'] = $this->p->get( 'display_compare', 0 ); $this->t['display_wishlist'] = $this->p->get( 'display_wishlist', 0 ); $this->t['display_quickview'] = $this->p->get( 'display_quickview', 0 ); + $this->t['display_addtocart_icon'] = $this->p->get( 'display_addtocart_icon', 0 ); $this->t['fade_in_action_icons'] = $this->p->get( 'fade_in_action_icons', 0 ); $this->t['dynamic_change_price'] = $this->p->get( 'dynamic_change_price', 0 ); $this->t['category_addtocart'] = $this->p->get( 'category_addtocart', 1 ); - $this->t['load_chosen'] = $this->p->get( 'load_chosen', 1 ); $this->t['dynamic_change_image'] = $this->p->get( 'dynamic_change_image', 0); $this->t['dynamic_change_price'] = $this->p->get( 'dynamic_change_price', 0 ); $this->t['add_compare_method'] = $this->p->get( 'add_compare_method', 0 ); $this->t['add_wishlist_method'] = $this->p->get( 'add_wishlist_method', 0 ); $this->t['hide_price'] = $this->p->get( 'hide_price', 0 ); $this->t['hide_addtocart'] = $this->p->get( 'hide_addtocart', 0 ); - $this->t['display_star_rating'] = $this->p->get( 'display_star_rating', 0 ); + $this->t['display_star_rating'] = $this->p->get( 'display_star_rating', 0 ); + $this->t['add_cart_method'] = $this->p->get( 'add_cart_method', 0 ); + if ($this->t['hide_addtocart'] == 1) { $this->t['category_addtocart'] = 0; } @@ -88,20 +88,19 @@ function display($tpl = null) { $this->t['linkcomparison'] = JRoute::_(PhocacartRoute::getComparisonRoute(0)); $this->t['linkwishlist'] = JRoute::_(PhocacartRoute::getWishListRoute(0)); $this->t['limitstarturl'] = $this->t['limitstart'] > 0 ? '&start='.$this->t['limitstart'] : ''; - $this->t['class_thumbnail'] = $this->t['fade_in_action_icons'] ? '' : 'thumbnail'; - $this->t['row-flex'] = $this->t['equal_height'] ? 'row-flex' : ''; - $media = new PhocacartRenderMedia(); - $media->loadBootstrap($this->t['load_bootstrap']); - $media->loadChosen($this->t['load_chosen']); - //$media->loadEqualHeights($this->t['equal_height']); - $media->loadProductHover($this->t['fade_in_action_icons']); + $media->loadBootstrap(); + $media->loadChosen(); + $this->t['class-row-flex'] = $media->loadEqualHeights(); + $this->t['class_thumbnail'] = $media->loadProductHover(); + + PhocacartRenderJs::renderAjaxAddToCart(); PhocacartRenderJs::renderAjaxAddToCompare(); PhocacartRenderJs::renderAjaxAddToWishList(); - PhocacartRenderJs::renderSubmitPaginationTopForm($this->t['action'], '#phItemsBox', $this->t['load_chosen'], $this->t['equal_height']); + PhocacartRenderJs::renderSubmitPaginationTopForm($this->t['action'], '#phItemsBox'); if ($this->t['display_quickview'] == 1) { PhocacartRenderJs::renderAjaxQuickViewBox(); @@ -119,6 +118,17 @@ function display($tpl = null) { $this->t['pathitem'] = PhocacartPath::getPath('productimage'); + // Plugins ------------------------------------------ + JPluginHelper::importPlugin('pcv'); + $this->t['dispatcher'] = JEventDispatcher::getInstance(); + $this->t['event'] = new stdClass; + + $results = $this->t['dispatcher']->trigger('onItemsBeforeHeader', array('com_phocacart.items', &$this->items, &$this->p)); + $this->t['event']->onItemsBeforeHeader = trim(implode("\n", $results)); + + // Foreach values are rendered in default foreaches + // END Plugins -------------------------------------- + parent::display($tpl); } diff --git a/site/views/items/view.raw.php b/site/views/items/view.raw.php index 2fd778c4..9ef33f8a 100644 --- a/site/views/items/view.raw.php +++ b/site/views/items/view.raw.php @@ -35,8 +35,6 @@ function display($tpl = null) { $this->t['cart_metakey'] = $this->p->get( 'cart_metakey', '' ); $this->t['cart_metadesc'] = $this->p->get( 'cart_metadesc', '' ); //$this->t['description'] = $this->p->get( 'description', '' ); - $this->t['load_bootstrap'] = $this->p->get( 'load_bootstrap', 0 ); - $this->t['equal_height'] = $this->p->get( 'equal_height', 0 ); $this->t['image_width_cat'] = $this->p->get( 'image_width_cat', '' ); $this->t['image_height_cat'] = $this->p->get( 'image_height_cat', '' ); //$this->t['image_link'] = $this->p->get( 'image_link', 0 ); @@ -50,7 +48,6 @@ function display($tpl = null) { $this->t['fade_in_action_icons'] = $this->p->get( 'fade_in_action_icons', 0 ); $this->t['dynamic_change_price'] = $this->p->get( 'dynamic_change_price', 0 ); $this->t['category_addtocart'] = $this->p->get( 'category_addtocart', 1 ); - $this->t['load_chosen'] = $this->p->get( 'load_chosen', 1 ); $this->t['dynamic_change_image'] = $this->p->get( 'dynamic_change_image', 0); $this->t['dynamic_change_price'] = $this->p->get( 'dynamic_change_price', 0 ); $this->t['add_compare_method'] = $this->p->get( 'add_compare_method', 0 ); @@ -58,7 +55,8 @@ function display($tpl = null) { $this->t['hide_price'] = $this->p->get( 'hide_price', 0 ); $this->t['hide_addtocart'] = $this->p->get( 'hide_addtocart', 0 ); $this->t['display_star_rating'] = $this->p->get( 'display_star_rating', 0 ); - + $this->t['add_cart_method'] = $this->p->get( 'add_cart_method', 0 ); + $this->t['display_addtocart_icon'] = $this->p->get( 'display_addtocart_icon', 0 ); if ($this->t['hide_addtocart'] == 1) { $this->t['category_addtocart'] = 0; @@ -84,15 +82,26 @@ function display($tpl = null) { $this->t['linkcomparison'] = JRoute::_(PhocacartRoute::getComparisonRoute(0)); $this->t['linkwishlist'] = JRoute::_(PhocacartRoute::getWishListRoute(0)); $this->t['limitstarturl'] = $this->t['limitstart'] > 0 ? '&start='.$this->t['limitstart'] : ''; - $this->t['class_thumbnail'] = $this->t['fade_in_action_icons'] ? '' : 'thumbnail'; - $this->t['row-flex'] = $this->t['equal_height'] ? 'row-flex' : ''; + $this->t['pathcat'] = PhocacartPath::getPath('categoryimage'); + $this->t['pathitem'] = PhocacartPath::getPath('productimage'); + + $media = new PhocacartRenderMedia(); + $this->t['class-row-flex'] = $media->loadEqualHeights(); + $this->t['class_thumbnail'] = $media->loadProductHover(); - $this->t['pathcat'] = PhocacartPath::getPath('categoryimage'); - $this->t['pathitem'] = PhocacartPath::getPath('productimage'); + //$model->hit((int)$this->t['categoryid']); + // Plugins ------------------------------------------ + JPluginHelper::importPlugin('pcv'); + $this->t['dispatcher'] = JEventDispatcher::getInstance(); + $this->t['event'] = new stdClass; + + // Foreach values are rendered in default foreaches + // END Plugins -------------------------------------- + parent::display($tpl); } diff --git a/site/views/orders/tmpl/default.php b/site/views/orders/tmpl/default.php index 98388d7c..becc2848 100644 --- a/site/views/orders/tmpl/default.php +++ b/site/views/orders/tmpl/default.php @@ -40,7 +40,7 @@ $status = ''.JText::_($v->status_title).''; echo '
    '.$status.'
    '; - echo '
    '.JHtml::date($v->date, 'd. m. Y. h:s').'
    '; + echo '
    '.PhocacartUtils::date($v->date).'
    '; $price->setCurrency($v->currency_id); $total = $price->getPriceFormat($v->total_amount); @@ -85,6 +85,33 @@ echo '
    '; + echo '
    '; + + $r = array(); + $r['trackinglink'] = PhocacartOrderView::getTrackingLink($v); + $r['trackingdescription'] = PhocacartOrderView::getTrackingDescription($v); + $r['shippingtitle'] = PhocacartOrderView::getShippingTitle($v); + $r['dateshipped'] = PhocacartOrderView::getDateShipped($v); + + if($r['shippingtitle'] != '' || $r['trackinglink'] != '') { + echo '
    '; + echo '
    '.JText::_('COM_PHOCACART_SHIPPING_INFORMATION').'
    '; + if ($r['shippingtitle'] != '') { + echo '
    '.$r['shippingtitle'].'
    '; + } + if ($r['trackingdescription'] != '') { + echo '
    '.$r['trackingdescription'].'
    '; + } + if ($r['trackinglink'] != '') { + echo ''; + } + if ($r['dateshipped'] != '') { + echo '
    '.JText::_('COM_PHOCACART_DATE_SHIPPED'). ': '.$r['dateshipped'].'
    '; + } + echo '
    '; + } + echo '
    '; + echo '
    '; echo ''; diff --git a/site/views/orders/view.html.php b/site/views/orders/view.html.php index 13deb33a..f65faf8a 100644 --- a/site/views/orders/view.html.php +++ b/site/views/orders/view.html.php @@ -25,7 +25,6 @@ function display($tpl = null) $this->t['orders'] = $model->getOrderList(); $this->t['token'] = $app->input->get('o', '', 'string'); - $this->t['load_bootstrap'] = $this->p->get( 'load_bootstrap', 0 ); $this->t['order_guest_access'] = $this->p->get( 'order_guest_access', 0 ); if ($this->t['order_guest_access'] == 0) { $this->t['token'] = ''; @@ -50,10 +49,9 @@ function display($tpl = null) $this->t['component-pdf'] = PhocacartUtilsExtension::getExtensionInfo('com_phocapdf'); $media = new PhocacartRenderMedia(); - $media->loadBootstrap($this->t['load_bootstrap']); - - $document->addScript(JURI::root(true).'/media/com_phocacart/js/windowpopup.js'); - + $media->loadBootstrap(); + $media->loadWindowPopup(); + //$this->t['path'] = PhocacartPath::getPath('categoryimage'); $this->_prepareDocument(); parent::display($tpl); diff --git a/site/views/question/tmpl/default.php b/site/views/question/tmpl/default.php index 9c08c0fc..943588bf 100644 --- a/site/views/question/tmpl/default.php +++ b/site/views/question/tmpl/default.php @@ -52,7 +52,7 @@ ' '; if ( isset($this->t['question_description']) && $this->t['question_description'] != '') { - echo '
    '. JHTML::_('content.prepare', $this->t['question_description']). '
    '; + echo '
    '. $this->t['question_description']. '
    '; } ?>
     
    diff --git a/site/views/question/view.html.php b/site/views/question/view.html.php index 878f2e3c..284d727f 100644 --- a/site/views/question/view.html.php +++ b/site/views/question/view.html.php @@ -30,9 +30,8 @@ public function display($tpl = null) { $this->u = JFactory::getUser(); $this->p = $app->getParams(); - $this->t['load_chosen'] = $this->p->get( 'load_chosen', 1 ); - $this->t['load_bootstrap'] = $this->p->get( 'load_bootstrap', 0 ); $this->t['question_description'] = $this->p->get( 'question_description', '' ); + $this->t['question_description'] = PhocacartRenderFront::renderArticle($this->t['question_description']); $this->t['enable_ask_question'] = $this->p->get('enable_ask_question', 0); if ($this->t['enable_ask_question'] == 0) { @@ -110,8 +109,8 @@ public function display($tpl = null) { $media = new PhocacartRenderMedia(); - $media->loadBootstrap($this->t['load_bootstrap']); - $media->loadChosen($this->t['load_chosen']); + $media->loadBootstrap(); + $media->loadChosen(); $this->_prepareDocument(); diff --git a/site/views/terms/view.html.php b/site/views/terms/view.html.php index 45f1218e..5d16575b 100644 --- a/site/views/terms/view.html.php +++ b/site/views/terms/view.html.php @@ -19,8 +19,10 @@ public function display($tpl = null) { $app = JFactory::getApplication(); $this->p = $app->getParams(); $this->t['terms_conditions']= $this->p->get( 'terms_conditions', '' ); - + $this->t['terms_conditions']= PhocacartRenderFront::renderArticle($this->t['terms_conditions']); + $media = new PhocacartRenderMedia(); + $media->loadBootstrap(); $this->_prepareDocument(); parent::display($tpl); diff --git a/site/views/wishlist/tmpl/default.php b/site/views/wishlist/tmpl/default.php index 05066abd..703fba21 100644 --- a/site/views/wishlist/tmpl/default.php +++ b/site/views/wishlist/tmpl/default.php @@ -75,7 +75,7 @@ } if ($this->t['hide_price'] != 1) { - echo '
    '.$price->getPriceFormat($v['price']).'
    '; + echo '
    '.$price->getPriceItem($v['price'], $v['group_price']).'
    '; } else { echo '
    '; } @@ -89,7 +89,7 @@ echo ''; echo ''; //echo '
    '; - echo ''; + echo ''; //echo '
    '; diff --git a/site/views/wishlist/view.html.php b/site/views/wishlist/view.html.php index 39f7a682..d1e82de5 100644 --- a/site/views/wishlist/view.html.php +++ b/site/views/wishlist/view.html.php @@ -27,7 +27,6 @@ function display($tpl = null) $this->t['cart_metakey'] = $this->p->get( 'cart_metakey', '' ); $this->t['cart_metadesc'] = $this->p->get( 'cart_metadesc', '' ); - $this->t['load_bootstrap'] = $this->p->get( 'load_bootstrap', 0 ); $this->t['hide_price'] = $this->p->get( 'hide_price', 0 ); //$this->t['hide_addtocart'] = $this->p->get( 'hide_addtocart', 0 ); //$this->t['category_addtocart'] = $this->p->get( 'category_addtocart', 1 ); @@ -77,9 +76,8 @@ function display($tpl = null) } $media = new PhocacartRenderMedia(); - $media->loadBootstrap($this->t['load_bootstrap']); - //$media->loadChosen($this->t['load_chosen']); - //$media->loadEqualHeights($this->t['equal_height']); + $media->loadBootstrap(); + $this->t['pathitem'] = PhocacartPath::getPath('productimage'); $this->_prepareDocument(); diff --git a/tables/phocacartgroup.php b/tables/phocacartgroup.php new file mode 100644 index 00000000..9b3f06b1 --- /dev/null +++ b/tables/phocacartgroup.php @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/tables/phocacartpayment.php b/tables/phocacartpayment.php index 1cb3633a..8de5b69c 100644 --- a/tables/phocacartpayment.php +++ b/tables/phocacartpayment.php @@ -23,5 +23,17 @@ function check() { return true; } + + public function store($updateNulls = false){ + if ($this->default != '0') { + $query = $this->_db->getQuery(true) + ->update('#__phocacart_payment_methods') + ->set($this->_db->quoteName('default').' = \'0\'') + ->where($this->_db->quoteName('default').' = ' . $this->_db->quote($this->default)); + $this->_db->setQuery($query); + $this->_db->execute(); + } + return parent::store($updateNulls); + } } ?> \ No newline at end of file diff --git a/tables/phocacartproductpointgroup.php b/tables/phocacartproductpointgroup.php new file mode 100644 index 00000000..ac197a8e --- /dev/null +++ b/tables/phocacartproductpointgroup.php @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/tables/phocacartproductpricegroup.php b/tables/phocacartproductpricegroup.php new file mode 100644 index 00000000..0ee63f70 --- /dev/null +++ b/tables/phocacartproductpricegroup.php @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/tables/phocacartproductpricehistory.php b/tables/phocacartproductpricehistory.php new file mode 100644 index 00000000..801f428c --- /dev/null +++ b/tables/phocacartproductpricehistory.php @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/tables/phocacartrewardpoint.php b/tables/phocacartrewardpoint.php new file mode 100644 index 00000000..5b09211e --- /dev/null +++ b/tables/phocacartrewardpoint.php @@ -0,0 +1,27 @@ +alias)) { + $this->alias = $this->title; + } + $this->alias = PhocacartUtils::getAliasName($this->alias); + + return true; + } +} +?> \ No newline at end of file diff --git a/tables/phocacartshipping.php b/tables/phocacartshipping.php index 4d9cf6a5..9ab1456c 100644 --- a/tables/phocacartshipping.php +++ b/tables/phocacartshipping.php @@ -23,5 +23,17 @@ function check() { return true; } + + public function store($updateNulls = false){ + if ($this->default != '0') { + $query = $this->_db->getQuery(true) + ->update('#__phocacart_shipping_methods') + ->set($this->_db->quoteName('default').' = \'0\'') + ->where($this->_db->quoteName('default').' = ' . $this->_db->quote($this->default)); + $this->_db->setQuery($query); + $this->_db->execute(); + } + return parent::store($updateNulls); + } } ?> \ No newline at end of file diff --git a/views/phocacartcategory/tmpl/edit.php b/views/phocacartcategory/tmpl/edit.php index 9776e18d..50aefc29 100644 --- a/views/phocacartcategory/tmpl/edit.php +++ b/views/phocacartcategory/tmpl/edit.php @@ -55,7 +55,7 @@ function phCheckRequestStatus(i, task) { echo '
    '. "\n"; echo '
    '."\n"; -$formArray = array ('title', 'alias', 'image', 'parent_id', 'ordering', 'access', 'title_feed'); +$formArray = array ('title', 'alias', 'image', 'parent_id', 'ordering', 'access', 'group', 'title_feed'); echo $r->group($this->form, $formArray); $formArray = array('description'); echo $r->group($this->form, $formArray, 1); diff --git a/views/phocacartcoupon/tmpl/edit.php b/views/phocacartcoupon/tmpl/edit.php index 891eb9ae..3239b585 100644 --- a/views/phocacartcoupon/tmpl/edit.php +++ b/views/phocacartcoupon/tmpl/edit.php @@ -39,7 +39,7 @@ echo '
    '. "\n"; echo '
    '."\n"; -$formArray = array ('title', 'code', 'discount', 'calculation_type', 'access'); +$formArray = array ('title', 'code', 'discount', 'calculation_type', 'access', 'group'); echo $r->group($this->form, $formArray); $formArray = array('description'); echo $r->group($this->form, $formArray, 1); diff --git a/views/phocacartcp/view.html.php b/views/phocacartcp/view.html.php index 6abe2d08..b4b89a8d 100644 --- a/views/phocacartcp/view.html.php +++ b/views/phocacartcp/view.html.php @@ -31,7 +31,9 @@ function display($tpl = null) { 'payments' => array($this->t['l'] . '_PAYMENT', 'credit-card', '#4f9ce2'), 'currencies' => array($this->t['l'] . '_CURRENCIES', 'eur', '#dca300'), 'taxes' => array($this->t['l'] . '_TAXES', 'calendar', '#dd5500'), - 'users' => array($this->t['l'] . '_USERS', 'user', '#7faa7f'), + 'users' => array($this->t['l'] . '_CUSTOMERS', 'user', '#7faa7f'), + 'groups' => array($this->t['l'] . '_CUSTOMER_GROUPS', 'user', '#aa7faa'), + 'rewards' => array($this->t['l'] . '_REWARD_POINTS', 'certificate', '#7faaaa'), 'formfields' => array($this->t['l'] . '_FORM_FIELDS', 'list-alt', '#ffde00'), 'reviews' => array($this->t['l'] . '_REVIEWS', 'comment', '#399ed0'), //'ratings' => array($this->t['l'] . '_RATINGS', 'xxx', '#ffde00'), diff --git a/views/phocacartdiscount/tmpl/edit.php b/views/phocacartdiscount/tmpl/edit.php index e17e2643..a488e7b0 100644 --- a/views/phocacartdiscount/tmpl/edit.php +++ b/views/phocacartdiscount/tmpl/edit.php @@ -39,7 +39,7 @@ echo '
    '. "\n"; echo '
    '."\n"; -$formArray = array ('title', 'discount', 'calculation_type', 'access'); +$formArray = array ('title', 'discount', 'calculation_type', 'access', 'group'); echo $r->group($this->form, $formArray); $formArray = array('description'); echo $r->group($this->form, $formArray, 1); diff --git a/views/phocacarteditproductpointgroup/index.html b/views/phocacarteditproductpointgroup/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/views/phocacarteditproductpointgroup/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/phocacarteditproductpointgroup/tmpl/default.php b/views/phocacarteditproductpointgroup/tmpl/default.php new file mode 100644 index 00000000..92bb7a13 --- /dev/null +++ b/views/phocacarteditproductpointgroup/tmpl/default.php @@ -0,0 +1,101 @@ +t['o'].'&view=phocacarteditproductpointgroup&tmpl=component&id='.(int)$this->id); + + +echo '
    '; + +echo '
    ' + . '
    • '.JText::_('COM_PHOCACART_TO_SEE_ALL_CUSTOMER_GROUPS_LISTED_CLOSE_WINDOW_SAVE_THE_PRODUCT_FIRST') . '
    • ' + . '
    • '. JText::_('COM_PHOCACART_CHECK_LIST_EVERY_TIME_CUSTOMER_GROUPS_CHANGE').'
    • ' + . '
    • '.JText::_('COM_PHOCACART_IF_YOU_SET_ZERO_AS_POINT_THEN_POINT_WILL_BE_ZERO').'
    • ' + .'
    '; + +if (!empty($this->t['product'])) { + + echo '
    '; + + echo '
    '; + + + if (!empty($this->t['groups'])) { + + echo ''; + + echo ''; + echo ''; + //echo ''; + echo ''; + echo ''; + + + // Default is the main price + echo ''; + echo ''; + echo ''; + echo ''; + + foreach($this->t['groups'] as $k => $v) { + + if ($v['type'] == 1) { + continue; + // Default + // Possible TO DO - disable price for default and let only the price in product + } + + echo ''; + echo ''; + + + // Set value from database + $points = ''; + if (isset($this->t['product_groups'][$v['id']]['points_received'])) { + $points = $this->t['product_groups'][$v['id']]['points_received']; + } + echo ''; + echo ''; + + } + + echo ''; + + echo ''; + echo ''; + + echo ''; + + echo '
    '.JText::_('COM_PHOCACART_CUSTOMER_GROUP').''.JText::_('COM_PHOCACART_PRODUCT_KEY').''.JText::_('COM_PHOCACART_POINTS_RECEIVED').'
    '.JText::_('COM_PHOCACART_DEFAULT').''; + echo '
    '.JText::_($v['title']).''; + echo ''; + echo ''; + //echo ''; + //echo ''; + echo '
    '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo JHtml::_('form.token'); + + + echo '
    '; + } +} + +?> diff --git a/views/phocacarteditproductpointgroup/tmpl/index.html b/views/phocacarteditproductpointgroup/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/views/phocacarteditproductpointgroup/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/phocacarteditproductpointgroup/view.html.php b/views/phocacarteditproductpointgroup/view.html.php new file mode 100644 index 00000000..c7e870ea --- /dev/null +++ b/views/phocacarteditproductpointgroup/view.html.php @@ -0,0 +1,46 @@ +id = $app->input->get('id', 0, 'int'); + + if ($this->id < 1) { + echo JText::_('COM_PHOCACART_NO_PRODUCT_FOUND'); + return; + } + + $this->t = PhocacartUtils::setVars('product'); + $this->t['product'] = PhocacartProduct::getProduct((int)$this->id); + $this->t['groups'] = PhocacartGroup::getGroupsById((int)$this->id, 3, 2); + $this->t['product_groups'] = PhocacartGroup::getProductPointGroupsById((int)$this->id, 3, 2); + + + + $media = new PhocacartRenderAdminmedia(); + + parent::display($tpl); + } +} +?> \ No newline at end of file diff --git a/views/phocacarteditproductpricegroup/index.html b/views/phocacarteditproductpricegroup/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/views/phocacarteditproductpricegroup/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/phocacarteditproductpricegroup/tmpl/default.php b/views/phocacarteditproductpricegroup/tmpl/default.php new file mode 100644 index 00000000..c882e39d --- /dev/null +++ b/views/phocacarteditproductpricegroup/tmpl/default.php @@ -0,0 +1,106 @@ +t['o'].'&view=phocacarteditproductpricegroup&tmpl=component&id='.(int)$this->id); + + +echo '
    '; + +echo '
    ' + . '
    • '.JText::_('COM_PHOCACART_TO_SEE_ALL_CUSTOMER_GROUPS_LISTED_CLOSE_WINDOW_SAVE_THE_PRODUCT_FIRST') . '
    • ' + . '
    • '. JText::_('COM_PHOCACART_CHECK_LIST_EVERY_TIME_CUSTOMER_GROUPS_CHANGE').'
    • ' + . '
    • '.JText::_('COM_PHOCACART_IF_YOU_SET_ZERO_AS_PRICE_THEN_PRICE_WILL_BE_ZERO').'
    • ' + .'
    '; + +if (!empty($this->t['product'])) { + + echo '
    '; + + echo ''; + + + if (!empty($this->t['groups'])) { + + echo ''; + + echo ''; + echo ''; + //echo ''; + echo ''; + echo ''; + + + // Default is the main price + echo ''; + echo ''; + echo ''; + echo ''; + + foreach($this->t['groups'] as $k => $v) { + + if ($v['type'] == 1) { + continue; + // Default + // Possible TO DO - disable price for default and let only the price in product + } + + echo ''; + echo ''; + + + + + // Set value from database + $price = ''; + if (isset($this->t['product_groups'][$v['id']]['price'])) { + $price = $this->t['product_groups'][$v['id']]['price']; + if ($price > 0 || $price == 0) { + $price = PhocacartPrice::cleanPrice($price); + } + } + echo ''; + echo ''; + + } + + echo ''; + + echo ''; + echo ''; + + echo ''; + + echo '
    '.JText::_('COM_PHOCACART_CUSTOMER_GROUP').''.JText::_('COM_PHOCACART_PRODUCT_KEY').''.JText::_('COM_PHOCACART_PRICE').'
    '.JText::_('COM_PHOCACART_DEFAULT').''; + echo '
    '.JText::_($v['title']).''; + echo ''; + echo ''; + //echo ''; + //echo ''; + echo '
    '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo JHtml::_('form.token'); + + + echo '
    '; + } +} + +?> diff --git a/views/phocacarteditproductpricegroup/tmpl/index.html b/views/phocacarteditproductpricegroup/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/views/phocacarteditproductpricegroup/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/phocacarteditproductpricegroup/view.html.php b/views/phocacarteditproductpricegroup/view.html.php new file mode 100644 index 00000000..4f056bf7 --- /dev/null +++ b/views/phocacarteditproductpricegroup/view.html.php @@ -0,0 +1,46 @@ +id = $app->input->get('id', 0, 'int'); + + if ($this->id < 1) { + echo JText::_('COM_PHOCACART_NO_PRODUCT_FOUND'); + return; + } + + $this->t = PhocacartUtils::setVars('product'); + $this->t['product'] = PhocacartProduct::getProduct((int)$this->id); + $this->t['groups'] = PhocacartGroup::getGroupsById((int)$this->id, 3, 2); + $this->t['product_groups'] = PhocacartGroup::getProductPriceGroupsById((int)$this->id, 3, 2); + + + + $media = new PhocacartRenderAdminmedia(); + + parent::display($tpl); + } +} +?> \ No newline at end of file diff --git a/views/phocacarteditproductpricehistory/index.html b/views/phocacarteditproductpricehistory/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/views/phocacarteditproductpricehistory/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/phocacarteditproductpricehistory/tmpl/default.php b/views/phocacarteditproductpricehistory/tmpl/default.php new file mode 100644 index 00000000..5198f0b4 --- /dev/null +++ b/views/phocacarteditproductpricehistory/tmpl/default.php @@ -0,0 +1,87 @@ +t['o'].'&view=phocacarteditproductpricehistory&tmpl=component&id='.(int)$this->id); + + +echo '
    '; + +/* +echo '
    ' + . '
    • '.JText::_('COM_PHOCACART_TO_SEE_ALL_CUSTOMER_GROUPS_LISTED_CLOSE_WINDOW_SAVE_THE_PRODUCT_FIRST') . '
    • ' + .'
    '; +*/ + + +echo '
    '; + +echo ''; + + + +echo '
    '; + +echo '
    '."\n"; +echo '
    '.JText::_('COM_PHOCACART_DATE').'
    '; +echo '
    '.JText::_('COM_PHOCACART_PRICE').'
    '; +echo '
    '; +echo '
    '; +echo '
    '; +echo '
    '."\n"; + + +$r = new PhocacartRenderAdminview(); + +if (!empty($this->t['history'])) { + $i = 0; + foreach($this->t['history'] as $k => $v) { + echo $r->additionalPricehistoryRow((int)$i, (int)$v['id'], $v['price'], $v['date'], $this->id, 0); + $i++; + } + + $newRow = $r->additionalPricehistoryRow('\' + phRowCountPricehistory + \'', '', '', '', $this->id, 1); + $newRow = preg_replace('/[\x00-\x1F\x80-\x9F]/u', '', $newRow); + PhocacartRenderJs::renderJsManageRowPricehistory($i, $newRow); +} else { + $newRow = $r->additionalPricehistoryRow('\' + phRowCountPricehistory + \'', '', '', '', $this->id, 1); + $newRow = preg_replace('/[\x00-\x1F\x80-\x9F]/u', '', $newRow); + PhocacartRenderJs::renderJsManageRowPricehistory(0, $newRow); + +} +echo $r->addRowButton(JText::_('COM_PHOCACART_ADD_PRICE'), 'pricehistory'); + //echo ''; + + + +echo '
    '; + +echo '
    '; +echo ''; +echo ''; +echo ''; +echo ''; +echo ''; +echo JHtml::_('form.token'); +echo '
    '; + +echo '
    '; +echo '
    '; + +echo '
    ';// end ph-product-price-history-box + + +?> diff --git a/views/phocacarteditproductpricehistory/tmpl/index.html b/views/phocacarteditproductpricehistory/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/views/phocacarteditproductpricehistory/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/phocacarteditproductpricehistory/view.html.php b/views/phocacarteditproductpricehistory/view.html.php new file mode 100644 index 00000000..57e428ff --- /dev/null +++ b/views/phocacarteditproductpricehistory/view.html.php @@ -0,0 +1,43 @@ +id = $app->input->get('id', 0, 'int'); + + if ($this->id < 1) { + echo JText::_('COM_PHOCACART_NO_PRODUCT_FOUND'); + return; + } + + $this->t = PhocacartUtils::setVars('product'); + $this->t['history'] = PhocacartPriceHistory::getPriceHistoryById((int)$this->id, 0, 1); + + + $media = new PhocacartRenderAdminmedia(); + + parent::display($tpl); + } +} +?> \ No newline at end of file diff --git a/views/phocacarteditstatus/tmpl/default.php b/views/phocacarteditstatus/tmpl/default.php index c71dea83..92854893 100644 --- a/views/phocacarteditstatus/tmpl/default.php +++ b/views/phocacarteditstatus/tmpl/default.php @@ -113,6 +113,23 @@ echo '
    '; echo '
    '; +echo '
    '; +echo '
    '.JText::_('COM_PHOCACART_FIELD_USER_GROUP_CHANGE_LABEL').'
    '; +echo '
    '.PhocacartOrderStatus::getChangeUserGroupSelectBox($this->item['change_user_group']).'
    '; +echo '
    '; +echo '
    '; + +echo '
    '; +echo '
    '.JText::_('COM_PHOCACART_FIELD_REWARD_POINTS_CHANGE_NEEDED_LABEL').'
    '; +echo '
    '.PhocacartOrderStatus::getChangeChangePointsNeededSelectBox($this->item['change_points_needed']).'
    '; +echo '
    '; +echo '
    '; + +echo '
    '; +echo '
    '.JText::_('COM_PHOCACART_FIELD_REWARD_POINTS_CHANGE_RECEIVED_LABEL').'
    '; +echo '
    '.PhocacartOrderStatus::getChangePointsReceivedSelectBox($this->item['change_points_received']).'
    '; +echo '
    '; +echo '
    '; echo '
    '; echo '
    '; diff --git a/views/phocacarteditstockadvanced/view.html.php b/views/phocacarteditstockadvanced/view.html.php index 4af0aa8d..43ec0d5d 100644 --- a/views/phocacarteditstockadvanced/view.html.php +++ b/views/phocacarteditstockadvanced/view.html.php @@ -37,9 +37,9 @@ function display($tpl = null) { $this->t['combinations'] = array(); $this->t['combinations_stock'] = array(); if (!empty($this->t['product'])) { - PhocaCartAttribute::getCombinations( $this->t['product']->id, $this->t['product']->title, $this->t['attr_options'], $this->t['combinations']); + PhocacartAttribute::getCombinations( $this->t['product']->id, $this->t['product']->title, $this->t['attr_options'], $this->t['combinations']); // Load data from database - $this->t['combinations_stock'] = PhocaCartAttribute::getCombinationsStockByProductId($this->t['product']->id); + $this->t['combinations_stock'] = PhocacartAttribute::getCombinationsStockByProductId($this->t['product']->id); } diff --git a/views/phocacartformfield/tmpl/edit.php b/views/phocacartformfield/tmpl/edit.php index b01d6dbd..963cf275 100644 --- a/views/phocacartformfield/tmpl/edit.php +++ b/views/phocacartformfield/tmpl/edit.php @@ -43,7 +43,7 @@ echo $r->item($this->form, 'description', '('.JText::_($this->form->getValue('description')).')', 1); -$formArray = array ('type', 'default', 'class', 'read_only', 'additional', 'validate', 'unique', 'ordering', 'access'); +$formArray = array ('type', 'default', 'class', 'required', 'read_only', 'additional', 'validate', 'unique', 'ordering', 'access', 'group'); echo $r->group($this->form, $formArray); echo '
    '; diff --git a/views/phocacartformfield/view.html.php b/views/phocacartformfield/view.html.php index a4033c88..75f67dcb 100644 --- a/views/phocacartformfield/view.html.php +++ b/views/phocacartformfield/view.html.php @@ -25,6 +25,13 @@ public function display($tpl = null) { $this->item = $this->get('Item'); $media = new PhocacartRenderAdminmedia(); + + if (isset($this->item->id) && (int)$this->item->id > 0) { + $this->form->setFieldAttribute( 'title', 'readonly', 'true' ); + $this->form->setFieldAttribute( 'type', 'readonly', 'true' ); + + } + $this->addToolbar(); parent::display($tpl); diff --git a/views/phocacartformfields/tmpl/default.php b/views/phocacartformfields/tmpl/default.php index 25145731..55b1b7f7 100644 --- a/views/phocacartformfields/tmpl/default.php +++ b/views/phocacartformfields/tmpl/default.php @@ -59,8 +59,10 @@ echo $r->thCheck('JGLOBAL_CHECK_ALL'); echo ''.JHTML::_('grid.sort', $this->t['l'].'_NAME', 'a.title', $listDirn, $listOrder ).''."\n"; echo ''.JHTML::_('grid.sort', $this->t['l'].'_PUBLISHED', 'a.published', $listDirn, $listOrder ).''."\n"; +echo ''.JHTML::_('grid.sort', $this->t['l'].'_REQUIRED', 'a.required', $listDirn, $listOrder ).''."\n"; echo ''.JHTML::_('grid.sort', $this->t['l'].'_LABEL', 'a.label', $listDirn, $listOrder ).''."\n"; echo ''.JHTML::_('grid.sort', $this->t['l'].'_TYPE', 'a.type', $listDirn, $listOrder ).''."\n"; +echo ''.JHTML::_('grid.sort', $this->t['l'].'_DEFAULT', 'a.type_default', $listDirn, $listOrder ).''."\n"; echo ''.JHTML::_('grid.sort', $this->t['l'].'_FORM_DISPLAY_BILLING', 'a.display_billing', $listDirn, $listOrder ).''."\n"; echo ''.JHTML::_('grid.sort', $this->t['l'].'_FORM_DISPLAY_SHIPPING', 'a.display_shipping', $listDirn, $listOrder ).''."\n"; echo ''.JHTML::_('grid.sort', $this->t['l'].'_FORM_DISPLAY_ACCOUNT', 'a.display_account', $listDirn, $listOrder ).''."\n"; @@ -113,10 +115,18 @@ echo $r->td(JHtml::_('jgrid.published', $item->published, $i, $this->t['tasks'].'.', $canChange), "small"); +echo $r->td(PhocacartHtmlJgrid::displayRequired( $item->required, $i, $this->t['tasks'].'.', $canChange), "small"); echo $r->td($item->label . '
    ('.JText::_($this->escape($item->label)).')', "small"); echo $r->td($item->type, "small"); +if ($item->type_default == 1) { + $default = ''; + echo $r->td($default, "small ph-center"); +} else { + echo $r->td('', "small"); +} + echo $r->td(PhocacartHtmlJgrid::displayBilling( $item->display_billing, $i, $this->t['tasks'].'.', $canChange), "small"); echo $r->td(PhocacartHtmlJgrid::displayShipping( $item->display_shipping, $i, $this->t['tasks'].'.', $canChange), "small"); @@ -133,7 +143,7 @@ } echo ''. "\n"; -echo $r->tblFoot($this->pagination->getListFooter(), 12); +echo $r->tblFoot($this->pagination->getListFooter(), 13); echo $r->endTable(); echo $r->formInputs($listOrder, $listDirn, $originalOrders); diff --git a/views/phocacartformfields/view.html.php b/views/phocacartformfields/view.html.php index 7f4d0567..e1939a73 100644 --- a/views/phocacartformfields/view.html.php +++ b/views/phocacartformfields/view.html.php @@ -50,7 +50,7 @@ function addToolbar() { JToolbarHelper::title( JText::_( $this->t['l'].'_FORM_FIELDS' ), 'list-alt' ); if ($canDo->get('core.create')) { - //JToolbarHelper::addNew($this->t['task'].'.add','JTOOLBAR_NEW'); + JToolbarHelper::addNew($this->t['task'].'.add','JTOOLBAR_NEW'); } if ($canDo->get('core.edit')) { @@ -64,7 +64,7 @@ function addToolbar() { } if ($canDo->get('core.delete')) { - //JToolbarHelper::deleteList( $this->t['l'].'_WARNING_DELETE_ITEMS', 'phocacartformfields.delete', $this->t['l'].'_DELETE'); + JToolbarHelper::deleteList( $this->t['l'].'_WARNING_DELETE_ITEMS_MAY_MEAN_DELETING_USER_DATA', 'phocacartformfields.delete', $this->t['l'].'_DELETE'); } @@ -82,6 +82,7 @@ protected function getSortFields() { 'a.display_shipping' => JText::_($this->t['l'] . '_FORM_DISPLAY_SHIPPING'), 'a.display_account' => JText::_($this->t['l'] . '_FORM_DISPLAY_ACCOUNT'), 'a.published' => JText::_($this->t['l'] . '_PUBLISHED'), + 'a.required' => JText::_($this->t['l'] . '_REQUIRED'), 'a.id' => JText::_('JGRID_HEADING_ID') ); } diff --git a/views/phocacartgroup/index.html b/views/phocacartgroup/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/views/phocacartgroup/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/phocacartgroup/tmpl/edit.php b/views/phocacartgroup/tmpl/edit.php new file mode 100644 index 00000000..4bc60cd8 --- /dev/null +++ b/views/phocacartgroup/tmpl/edit.php @@ -0,0 +1,79 @@ +t['n'] . 'RenderAdminview'; +$r = new $class(); +?> +startForm($this->t['o'], $this->t['task'], $this->item->id, 'adminForm', 'adminForm'); +// First Column +echo '
    '; +$tabs = array ( +'general' => JText::_($this->t['l'].'_GENERAL_OPTIONS'), +'rules' => JText::_($this->t['l'].'_RULES'), +'publishing' => JText::_($this->t['l'].'_PUBLISHING_OPTIONS')); +echo $r->navigation($tabs); + +echo '
    '. "\n"; + +echo '
    '."\n"; + +$translatedTitle = $this->form->getValue('title') ? '('.JText::_($this->form->getValue('title')).')' : ''; +echo $r->item($this->form, 'title', $translatedTitle, 1); +$formArray = array ('display_price'); +echo $r->group($this->form, $formArray); + +$formArray = array('description'); +echo $r->group($this->form, $formArray, 1); + + +echo '
    '; + +echo '
    '."\n"; +$formArray = array ('minimum_sum'); +echo $r->group($this->form, $formArray); +echo '
    '; + + +echo '
    '."\n"; +foreach($this->form->getFieldset('publish') as $field) { + echo '
    '; + if (!$field->hidden) { + echo '
    '.$field->label.'
    '; + } + echo '
    '; + echo $field->input; + echo '
    '; +} +echo '
    '; + +echo '
    ';//end tab content +echo '
    ';//end span10 +// Second Column +echo '
    '; +echo '
    ';//end span2 +echo $r->formInputs($this->t['task']); +echo $r->endForm(); +?> \ No newline at end of file diff --git a/views/phocacartgroup/tmpl/index.html b/views/phocacartgroup/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/views/phocacartgroup/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/phocacartgroup/view.html.php b/views/phocacartgroup/view.html.php new file mode 100644 index 00000000..42e94a85 --- /dev/null +++ b/views/phocacartgroup/view.html.php @@ -0,0 +1,72 @@ +t = PhocacartUtils::setVars('group'); + $this->state = $this->get('State'); + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + + if (isset($this->item->type) && (int)$this->item->type == 1) { + $this->form->setFieldAttribute( 'minimum_sum', 'readonly', 'true' ); + + + } + + $media = new PhocacartRenderAdminmedia(); + + $this->addToolbar(); + parent::display($tpl); + } + + protected function addToolbar() { + + require_once JPATH_COMPONENT.'/helpers/'.$this->t['tasks'].'.php'; + JFactory::getApplication()->input->set('hidemainmenu', true); + $bar = JToolBar::getInstance('toolbar'); + $user = JFactory::getUser(); + $isNew = ($this->item->id == 0); + $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); + $class = ucfirst($this->t['tasks']).'Helper'; + $canDo = $class::getActions($this->t, $this->state->get('filter.group_id')); + + $text = $isNew ? JText::_( $this->t['l'] . '_NEW' ) : JText::_($this->t['l'] . '_EDIT'); + JToolbarHelper::title( JText::_( $this->t['l'] . '_CUSTOMER_GROUP' ).': [ ' . $text.' ]' , 'credit-card'); + + // If not checked out, can save the item. + if (!$checkedOut && $canDo->get('core.edit')){ + JToolbarHelper::apply($this->t['task'].'.apply', 'JTOOLBAR_APPLY'); + JToolbarHelper::save($this->t['task'].'.save', 'JTOOLBAR_SAVE'); + JToolbarHelper::addNew($this->t['task'].'.save2new', 'JTOOLBAR_SAVE_AND_NEW'); + } + + if (empty($this->item->id)) { + JToolbarHelper::cancel($this->t['task'].'.cancel', 'JTOOLBAR_CANCEL'); + } + else { + JToolbarHelper::cancel($this->t['task'].'.cancel', 'JTOOLBAR_CLOSE'); + } + JToolbarHelper::divider(); + JToolbarHelper::help( 'screen.'.$this->t['c'], true ); + + PhocacartRenderAdminview::renderWizardButton('back'); + } +} +?> diff --git a/views/phocacartgroups/index.html b/views/phocacartgroups/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/views/phocacartgroups/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/phocacartgroups/tmpl/default.php b/views/phocacartgroups/tmpl/default.php new file mode 100644 index 00000000..e83a2864 --- /dev/null +++ b/views/phocacartgroups/tmpl/default.php @@ -0,0 +1,136 @@ +t['n'] . 'RenderAdminviews'; +$r = new $class(); +$user = JFactory::getUser(); +$userId = $user->get('id'); +$listOrder = $this->escape($this->state->get('list.ordering')); +$listDirn = $this->escape($this->state->get('list.direction')); +$canOrder = $user->authorise('core.edit.state', $this->t['o']); +$saveOrder = $listOrder == 'a.ordering'; +if ($saveOrder) { + $saveOrderingUrl = 'index.php?option='.$this->t['o'].'&task='.$this->t['tasks'].'.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', 'categoryList', 'adminForm', strtolower($listDirn), $saveOrderingUrl, false, true); +} +$sortFields = $this->getSortFields(); + +echo $r->jsJorderTable($listOrder); + + +echo $r->startForm($this->t['o'], $this->t['tasks'], 'adminForm'); +echo $r->startFilter(); +//echo $r->selectFilterPublished('JOPTION_SELECT_PUBLISHED', $this->state->get('filter.state')); +//echo $r->selectFilterLanguage('JOPTION_SELECT_LANGUAGE', $this->state->get('filter.language')); +//echo $r->selectFilterCategory(PhocaDownloadCategory::options($this->t['o']), 'JOPTION_SELECT_CATEGORY', $this->state->get('filter.category_id')); +echo $r->endFilter(); + +echo $r->startMainContainer(); +echo $r->startFilterBar(); +echo $r->inputFilterSearch($this->t['l'].'_FILTER_SEARCH_LABEL', $this->t['l'].'_FILTER_SEARCH_DESC', + $this->escape($this->state->get('filter.search'))); +echo $r->inputFilterSearchClear('JSEARCH_FILTER_SUBMIT', 'JSEARCH_FILTER_CLEAR'); +echo $r->inputFilterSearchLimit('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC', $this->pagination->getLimitBox()); +echo $r->selectFilterDirection('JFIELD_ORDERING_DESC', 'JGLOBAL_ORDER_ASCENDING', 'JGLOBAL_ORDER_DESCENDING', $listDirn); +echo $r->selectFilterSortBy('JGLOBAL_SORT_BY', $sortFields, $listOrder); + +echo $r->startFilterBar(2); +echo $r->selectFilterPublished('JOPTION_SELECT_PUBLISHED', $this->state->get('filter.state')); +echo $r->endFilterBar(); + +echo $r->endFilterBar(); + +echo $r->startTable('groupList'); + +echo $r->startTblHeader(); + +echo $r->thOrdering('JGRID_HEADING_ORDERING', $listDirn, $listOrder); +echo $r->thCheck('JGLOBAL_CHECK_ALL'); +echo ''.JHTML::_('grid.sort', $this->t['l'].'_TITLE', 'a.title', $listDirn, $listOrder ).''."\n"; +echo ''.JHTML::_('grid.sort', $this->t['l'].'_PUBLISHED', 'a.published', $listDirn, $listOrder ).''."\n"; +echo ''.JHTML::_('grid.sort', $this->t['l'].'_MINIMAL_SUM_OF_PURCHACHES', 'a.minimum_sum', $listDirn, $listOrder ).''."\n"; +echo ''.JHTML::_('grid.sort', $this->t['l'].'_DEFAULT', 'a.type', $listDirn, $listOrder ).''."\n"; +echo ''.JHTML::_('grid.sort', $this->t['l'].'_ID', 'a.id', $listDirn, $listOrder ).''."\n"; + +echo $r->endTblHeader(); + +echo ''. "\n"; + +$originalOrders = array(); +$parentsStr = ""; +$j = 0; + +if (is_array($this->items)) { + foreach ($this->items as $i => $item) { + //if ($i >= (int)$this->pagination->limitstart && $j < (int)$this->pagination->limit) { + $j++; + +$urlEdit = 'index.php?option='.$this->t['o'].'&task='.$this->t['task'].'.edit&id='; +$urlTask = 'index.php?option='.$this->t['o'].'&task='.$this->t['task']; +$orderkey = array_search($item->id, $this->ordering[0]); +$ordering = ($listOrder == 'a.ordering'); +$canCreate = $user->authorise('core.create', $this->t['o']); +$canEdit = $user->authorise('core.edit', $this->t['o']); +$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out==$user->get('id') || $item->checked_out==0; +$canChange = $user->authorise('core.edit.state', $this->t['o']) && $canCheckin; +$linkEdit = JRoute::_( $urlEdit. $item->id ); + + + +$iD = $i % 2; +echo "\n\n"; +//echo ''. "\n"; +echo ''. "\n"; +echo $r->tdOrder($canChange, $saveOrder, $orderkey); +echo $r->td(JHtml::_('grid.id', $i, $item->id), "small"); + +$checkO = ''; +if ($item->checked_out) { + $checkO .= JHtml::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, $this->t['tasks'].'.', $canCheckin); +} +if ($canCreate || $canEdit) { + $checkO .= ''. $this->escape(JText::_($item->title)).'' . ' ('.$this->escape($item->title).')'; +} else { + $checkO .= $this->escape(JText::_($item->title)) . ' ('.$this->escape($item->title).')'; +} +echo $r->td($checkO, "small"); + + +echo $r->td(JHtml::_('jgrid.published', $item->published, $i, $this->t['tasks'].'.', $canChange), "small"); + +echo $r->td(PhocacartPrice::cleanPrice($item->minimum_sum), "small"); + +if ($item->type == 1) { + $default = ''; + echo $r->td($default, "small ph-center"); +} else { + echo $r->td('', "small"); +} + +echo $r->td($item->id, "small"); + +echo ''. "\n"; + + //} + } +} +echo ''. "\n"; + +echo $r->tblFoot($this->pagination->getListFooter(), 7); +echo $r->endTable(); + +echo $r->formInputs($listOrder, $listDirn, $originalOrders); +echo $r->endMainContainer(); +echo $r->endForm(); +?> \ No newline at end of file diff --git a/views/phocacartgroups/tmpl/index.html b/views/phocacartgroups/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/views/phocacartgroups/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/phocacartgroups/view.html.php b/views/phocacartgroups/view.html.php new file mode 100644 index 00000000..70974d5d --- /dev/null +++ b/views/phocacartgroups/view.html.php @@ -0,0 +1,86 @@ +t = PhocacartUtils::setVars('group'); + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + + // Check for errors. + if (count($errors = $this->get('Errors'))) { + throw new Exception(implode("\n", $errors), 500); + return false; + } + + // Preprocess the list of items to find ordering divisions. + foreach ($this->items as &$item) { + $this->ordering[0][] = $item->id; + } + + $media = new PhocacartRenderAdminmedia(); + + $this->addToolbar(); + parent::display($tpl); + } + + function addToolbar() { + + require_once JPATH_COMPONENT.'/helpers/'.$this->t['tasks'].'.php'; + $state = $this->get('State'); + $class = ucfirst($this->t['tasks']).'Helper'; + $canDo = $class::getActions($this->t, $state->get('filter.group_id')); + + JToolbarHelper::title( JText::_( $this->t['l'].'_CUSTOMER_GROUPS' ), 'user' ); + + if ($canDo->get('core.create')) { + JToolbarHelper::addNew($this->t['task'].'.add','JTOOLBAR_NEW'); + } + + if ($canDo->get('core.edit')) { + JToolbarHelper::editList($this->t['task'].'.edit','JTOOLBAR_EDIT'); + } + if ($canDo->get('core.edit.state')) { + + JToolbarHelper::divider(); + JToolbarHelper::custom($this->t['tasks'].'.publish', 'publish.png', 'publish_f2.png','JTOOLBAR_PUBLISH', true); + JToolbarHelper::custom($this->t['tasks'].'.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true); + } + + if ($canDo->get('core.delete')) { + JToolbarHelper::deleteList( $this->t['l'].'_WARNING_DELETE_ITEMS', 'phocacartgroups.delete', $this->t['l'].'_DELETE'); + } + JToolbarHelper::divider(); + JToolbarHelper::help( 'screen.'.$this->t['c'], true ); + + PhocacartRenderAdminview::renderWizardButton('back'); + } + + protected function getSortFields() { + return array( + 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), + 'a.title' => JText::_($this->t['l'] . '_TITLE'), + 'a.published' => JText::_($this->t['l'] . '_PUBLISHED'), + 'a.minimum_sum' => JText::_($this->t['l']. '_MINIMAL_SUM_OF_PURCHACHES'), + 'a.type' => JText::_($this->t['l']. '_DEFAULT'), + 'a.id' => JText::_('JGRID_HEADING_ID') + ); + } +} +?> \ No newline at end of file diff --git a/views/phocacartitem/tmpl/edit.php b/views/phocacartitem/tmpl/edit.php index 155499f3..71bf73a4 100644 --- a/views/phocacartitem/tmpl/edit.php +++ b/views/phocacartitem/tmpl/edit.php @@ -61,6 +61,7 @@ function phCheckRequestStatus(i, task) { 'discount' => JText::_($this->t['l'].'_DISCOUNT_OPTIONS'), 'download' => JText::_($this->t['l'].'_DOWNLOAD_OPTIONS'), 'size' => JText::_($this->t['l'].'_SIZE_OPTIONS'), +'reward' => JText::_($this->t['l'].'_REWARD_POINTS'), 'publishing' => JText::_($this->t['l'].'_PUBLISHING_OPTIONS'), 'metadata' => JText::_($this->t['l'].'_METADATA_OPTIONS') ); @@ -70,9 +71,30 @@ function phCheckRequestStatus(i, task) { echo '
    '."\n"; +// Customer Group Price +$idMd = 'phEditProductPriceGroupModal'; +$textButton = 'COM_PHOCACART_CUSTOMER_GROUP_PRICES'; +$w = 500; +$h = 400; + +$linkStatus = JRoute::_( 'index.php?option='.$this->t['o'].'&view=phocacarteditproductpricegroup&tmpl=component&id='.(int)$this->item->id ); +echo '
    '. JText::_($textButton) . ''; +echo $r->modalWindowDynamic($idMd, $textButton, $w, $h, false); + +// Product Price History +$idMd = 'phEditProductPriceHistoryModal'; +$textButton = 'COM_PHOCACART_PRODUCT_PRICE_HISTORY'; +$w = 500; +$h = 400; + +$linkStatus = JRoute::_( 'index.php?option='.$this->t['o'].'&view=phocacarteditproductpricehistory&tmpl=component&id='.(int)$this->item->id ); +echo '
    '. JText::_($textButton) . '
    '; +echo $r->modalWindowDynamic($idMd, $textButton, $w, $h, false); + + // ORDERING cannot be used -$formArray = array ('title', 'alias', 'price', 'price_original', 'tax_id', 'catid_multiple', 'manufacturer_id', 'sku', 'upc', 'ean', 'jan', 'mpn', 'isbn', 'serial_number', 'registration_key', 'external_id', 'external_key', 'external_link', 'external_text', 'access', 'featured', 'video', 'public_download_file', 'public_download_text'); +$formArray = array ('title', 'alias', 'price', 'price_original', 'tax_id', 'catid_multiple', 'manufacturer_id', 'sku', 'upc', 'ean', 'jan', 'mpn', 'isbn', 'serial_number', 'registration_key', 'external_id', 'external_key', 'external_link', 'external_text', 'access', 'group', 'featured', 'video', 'public_download_file', 'public_download_text'); echo $r->group($this->form, $formArray); $formArray = array('description' ); echo $r->group($this->form, $formArray, 1); @@ -212,17 +234,28 @@ function phCheckRequestStatus(i, task) { echo '

    '.JText::_($this->t['l'].'_PRODUCT_DISCOUNT').'

    '; $i = 0; // if (!empty($this->discounts)) { + foreach ($this->discounts as $k => $v) { //if ($i == 0) { // echo $r->headerSpecification(); //} $v->discount = PhocacartPrice::cleanPrice($v->discount); - echo $r->additionalDiscountsRow((int)$i, (int)$v->id, $v->title, $v->alias, $v->access, $v->discount, $v->calculation_type, $v->quantity_from, /*$v->quantity_to*/ 0, $v->valid_from, $v->valid_to, 0); + + if ((int)$v->id > 0) { + $activeGroups = PhocacartGroup::getGroupsById((int)$v->id, 4, 1); + } + + if (empty($activeGroups)) { + $activeGroups = PhocacartGroup::getDefaultGroup(1); + } + + + echo $r->additionalDiscountsRow((int)$i, (int)$v->id, $v->title, $v->alias, $v->access, $activeGroups, $v->discount, $v->calculation_type, $v->quantity_from, /*$v->quantity_to*/ 0, $v->valid_from, $v->valid_to, 0); $i++; } } -$newRow = $r->additionalDiscountsRow('\' + phRowCountDiscount + \'', '', '', '', '', '', '', '', '', '', '', 1); +$newRow = $r->additionalDiscountsRow('\' + phRowCountDiscount + \'', '', '', '', '', PhocacartGroup::getDefaultGroup(1), '', '', '', '', '', '', 1); $newRow = preg_replace('/[\x00-\x1F\x80-\x9F]/u', '', $newRow); $newHeader = ''; @@ -309,6 +342,22 @@ function phCheckRequestStatus(i, task) { echo $r->group($this->form, $formArray); echo '
    '. "\n"; +// REWARD POINTS +echo '
    '. "\n"; + +$idMd = 'phEditProductPointGroupModal'; +$textButton = 'COM_PHOCACART_CUSTOMER_GROUP_RECEIVED_POINTS'; +$w = 500; +$h = 400; + +$linkStatus = JRoute::_( 'index.php?option='.$this->t['o'].'&view=phocacarteditproductpointgroup&tmpl=component&id='.(int)$this->item->id ); +echo ''; +echo $r->modalWindowDynamic($idMd, $textButton, $w, $h, false); + +$formArray = array ('points_needed', 'points_received'); +echo $r->group($this->form, $formArray); +echo '
    '. "\n"; + echo '
    '."\n"; foreach($this->form->getFieldset('publish') as $field) { diff --git a/views/phocacartitema/view.json.php b/views/phocacartitema/view.json.php index 671381f4..79d1e1da 100644 --- a/views/phocacartitema/view.json.php +++ b/views/phocacartitema/view.json.php @@ -35,6 +35,9 @@ function display($tpl = null){ //$query->select('c.title AS category_title, c.id AS category_id'); //$query->join('LEFT', '#__phocacart_categories AS c ON c.id = a.catid'); + + $query->select('group_concat(CONCAT_WS(":", c.id, c.title) SEPARATOR \',\') AS categories'); + $query->select('group_concat(c.id SEPARATOR \',\') AS categories_id'); $query->select('group_concat(c.title SEPARATOR \' \') AS categories_title'); $query->join('LEFT', '#__phocacart_product_categories AS pc ON pc.product_id = a.id'); $query->join('LEFT', '#__phocacart_categories AS c ON c.id = pc.category_id'); @@ -60,8 +63,9 @@ function display($tpl = null){ $itemsA = array(); if (!empty($items)) { foreach ($items as $k => $v) { - $itemsA[$k]['id'] = $v->id; - $itemsA[$k]['title'] = $v->title . ' ('.$v->categories_title.')'; + $itemsA[$k]['id'] = $v->id; + $itemsA[$k]['title'] = $v->title . ' ('.$v->categories_title.')'; + $itemsA[$k]['categories'] = $v->categories; if ($v->image != '') { $thumb = PhocacartFileThumbnail::getOrCreateThumbnail($v->image, '', 0, 0, 0, 0, 'productimage'); if ($thumb['thumb_name_s_no_rel'] != '') { diff --git a/views/phocacartmanager/view.html.php b/views/phocacartmanager/view.html.php index 13ae8827..368a29f7 100644 --- a/views/phocacartmanager/view.html.php +++ b/views/phocacartmanager/view.html.php @@ -44,7 +44,7 @@ public function display($tpl = null) { $this->t['uploadmaxsizeread'] = PhocacartFile::getFileSizeReadable($this->t['uploadmaxsize']); $this->t['enablemultiple'] = $params->get( 'enable_multiple', 0 ); $this->t['multipleuploadmethod'] = $params->get( 'multiple_upload_method', 4 ); - $media = new PhocacartRenderAdminmedia(); + /*if ($this->manager == 'filemultiple') { $this->form = $this->get('Form'); @@ -137,6 +137,10 @@ public function display($tpl = null) { $this->t['path'] = PhocacartPath::getPath($this->manager); $this->addToolbar(); + + $media = new PhocacartRenderAdminmedia(); + + parent::display($tpl); echo JHTML::_('behavior.keepalive'); } diff --git a/views/phocacartorder/tmpl/edit.php b/views/phocacartorder/tmpl/edit.php index 93ee86bf..5d92bd42 100644 --- a/views/phocacartorder/tmpl/edit.php +++ b/views/phocacartorder/tmpl/edit.php @@ -33,6 +33,7 @@ 'order' => JText::_($this->t['l'].'_ORDER_OPTIONS'), 'billing' => JText::_($this->t['l'].'_BILLING_OPTIONS'), 'shipping' => JText::_($this->t['l'].'_SHIPPING_OPTIONS'), +'tracking' => JText::_($this->t['l'].'_SHIPMENT_TRACKING_OPTIONS'), 'products' => JText::_($this->t['l'].'_ORDERED_PRODUCTS'), 'download' => JText::_($this->t['l'].'_DOWNLOAD_LINKS'), 'orderlink' => JText::_($this->t['l'].'_ORDER_LINK')); @@ -74,7 +75,7 @@ echo $r->itemText($this->itemcommon->paymenttitle, JText::_('COM_PHOCACART_PAYMENT_METHOD')); } -$formArray = array ('id', 'status_id', 'order_token'); +$formArray = array ('id', 'status_id', 'order_token', 'comment'); echo $r->group($this->form, $formArray); echo '
    '; @@ -88,6 +89,23 @@ echo $data['s']; echo '
    '; +echo '
    '."\n"; + +if ($this->itemcommon->shippingtrackinglink != '') { + PhocacartRenderJs::renderJsAddTrackingCode('jform_tracking_number', 'tracking-link'); + echo $r->itemText($this->itemcommon->shippingtrackinglink, JText::_('COM_PHOCACART_TRACKING_LINK'), 'tracking-link'); +} + +$formArray = array ('tracking_number', 'tracking_link_custom', 'tracking_date_shipped', 'tracking_description_custom'); +echo $r->group($this->form, $formArray); + +if ($this->itemcommon->shippingtrackingdescription != '') { + echo $r->itemText($this->itemcommon->shippingtrackingdescription, JText::_('COM_PHOCACART_TRACKING_DESCRIPTION')); +} + +echo '
    '; + + echo '
    '."\n"; diff --git a/views/phocacartpayment/tmpl/edit.php b/views/phocacartpayment/tmpl/edit.php index a5bb0a56..14895c79 100644 --- a/views/phocacartpayment/tmpl/edit.php +++ b/views/phocacartpayment/tmpl/edit.php @@ -44,14 +44,14 @@ echo '
    '. "\n"; echo '
    '."\n"; -$formArray = array ('title', 'cost', 'tax_id', 'calculation_type'); +$formArray = array ('title', 'cost', 'tax_id', 'calculation_type', 'default'); echo $r->group($this->form, $formArray); $formArray = array ('method'); echo $r->group($this->form, $formArray); echo '
    '; -$formArray = array ('image', 'ordering', 'access'); +$formArray = array ('image', 'ordering', 'access', 'group'); echo $r->group($this->form, $formArray); $formArray = array('description'); echo $r->group($this->form, $formArray, 1); diff --git a/views/phocacartpayments/tmpl/default.php b/views/phocacartpayments/tmpl/default.php index cbaf4e66..230c6cb9 100644 --- a/views/phocacartpayments/tmpl/default.php +++ b/views/phocacartpayments/tmpl/default.php @@ -59,6 +59,7 @@ echo $r->thCheck('JGLOBAL_CHECK_ALL'); echo ''.JHTML::_('grid.sort', $this->t['l'].'_TITLE', 'a.title', $listDirn, $listOrder ).''."\n"; echo ''.JHTML::_('grid.sort', $this->t['l'].'_PUBLISHED', 'a.published', $listDirn, $listOrder ).''."\n"; +echo ''.JHTML::_('grid.sort', $this->t['l'].'_DEFAULT', 'a.default', $listDirn, $listOrder ).''."\n"; echo ''.JHTML::_('grid.sort', $this->t['l'].'_PAYMENT_METHOD', 'a.method', $listDirn, $listOrder ).''."\n"; echo ''.JText::_( $this->t['l'].'_ACTIVE_RULE_S').''."\n"; echo ''.JTEXT::_($this->t['l'].'_ACCESS').''."\n"; @@ -110,6 +111,14 @@ echo $r->td(JHtml::_('jgrid.published', $item->published, $i, $this->t['tasks'].'.', $canChange), "small"); +if ($item->default == '0' || $item->default == '1') { + $default = JHtml::_('jgrid.isdefault', $item->default, $i, $this->t['tasks'].'.', $canChange); + +} else if ($canChange) { + $default = ''; +} +echo $r->td($default, "small"); + //$method = PhocacartUtilsSettings::getPaymentMethod($item->method); echo $r->td(JText::_($item->method), "small"); @@ -133,7 +142,7 @@ } echo ''. "\n"; -echo $r->tblFoot($this->pagination->getListFooter(), 8); +echo $r->tblFoot($this->pagination->getListFooter(), 9); echo $r->endTable(); echo $r->formInputs($listOrder, $listDirn, $originalOrders); diff --git a/views/phocacartpayments/view.html.php b/views/phocacartpayments/view.html.php index bdac7046..2e9685cf 100644 --- a/views/phocacartpayments/view.html.php +++ b/views/phocacartpayments/view.html.php @@ -66,6 +66,11 @@ function addToolbar() { if ($canDo->get('core.delete')) { JToolbarHelper::deleteList( $this->t['l'].'_WARNING_DELETE_ITEMS', 'phocacartpayments.delete', $this->t['l'].'_DELETE'); } + + if ($canDo->get('core.edit.state')){ + JToolbarHelper::makeDefault($this->t['tasks'].'.setDefault', 'COM_PHOCACART_DEFAULT'); + } + JToolbarHelper::divider(); JToolbarHelper::help( 'screen.'.$this->t['c'], true ); diff --git a/views/phocacartreward/index.html b/views/phocacartreward/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/views/phocacartreward/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/phocacartreward/tmpl/edit.php b/views/phocacartreward/tmpl/edit.php new file mode 100644 index 00000000..cb59ba7a --- /dev/null +++ b/views/phocacartreward/tmpl/edit.php @@ -0,0 +1,53 @@ +t['n'] . 'RenderAdminview'; +$r = new $class(); +?> +startForm($this->t['o'], $this->t['task'], $this->item->id, 'adminForm', 'adminForm'); +// First Column +echo '
    '; +$tabs = array ( +'general' => JText::_($this->t['l'].'_GENERAL_OPTIONS')); +echo $r->navigation($tabs); + +echo '
    '. "\n"; + +echo '
    '."\n"; +$formArray = array ('title', 'points', 'user_id', 'published'); +echo $r->group($this->form, $formArray); + +echo '
    '; + + + +echo '
    ';//end tab content +echo '
    ';//end span10 +// Second Column +echo '
    ';//end span2 +echo $r->formInputs(); +echo $r->endForm(); +echo PhocacartRenderJs::renderAjaxTopHtml(); +?> + diff --git a/views/phocacartreward/tmpl/index.html b/views/phocacartreward/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/views/phocacartreward/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/phocacartreward/view.html.php b/views/phocacartreward/view.html.php new file mode 100644 index 00000000..9d96a5c2 --- /dev/null +++ b/views/phocacartreward/view.html.php @@ -0,0 +1,64 @@ +t = PhocacartUtils::setVars('reward'); + $this->state = $this->get('State'); + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + + $media = new PhocacartRenderAdminmedia(); + + $this->addToolbar(); + parent::display($tpl); + } + + protected function addToolbar() { + + require_once JPATH_COMPONENT.'/helpers/'.$this->t['tasks'].'.php'; + JFactory::getApplication()->input->set('hidemainmenu', true); + $bar = JToolBar::getInstance('toolbar'); + $user = JFactory::getUser(); + $isNew = ($this->item->id == 0); + $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); + $class = ucfirst($this->t['tasks']).'Helper'; + $canDo = $class::getActions($this->t, $this->state->get('filter.reward_id')); + + $text = $isNew ? JText::_( $this->t['l'] . '_NEW' ) : JText::_($this->t['l'] . '_EDIT'); + JToolbarHelper::title( JText::_( $this->t['l'] . '_REWARD_POINTS' ).': [ ' . $text.' ]' , 'certificate'); + + // If not checked out, can save the item. + if (!$checkedOut && $canDo->get('core.edit')){ + JToolbarHelper::apply($this->t['task'].'.apply', 'JTOOLBAR_APPLY'); + JToolbarHelper::save($this->t['task'].'.save', 'JTOOLBAR_SAVE'); + JToolbarHelper::addNew($this->t['task'].'.save2new', 'JTOOLBAR_SAVE_AND_NEW'); + } + + if (empty($this->item->id)) { + JToolbarHelper::cancel($this->t['task'].'.cancel', 'JTOOLBAR_CANCEL'); + } + else { + JToolbarHelper::cancel($this->t['task'].'.cancel', 'JTOOLBAR_CLOSE'); + } + JToolbarHelper::divider(); + JToolbarHelper::help( 'screen.'.$this->t['c'], true ); + } +} +?> diff --git a/views/phocacartrewards/index.html b/views/phocacartrewards/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/views/phocacartrewards/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/phocacartrewards/tmpl/default.php b/views/phocacartrewards/tmpl/default.php new file mode 100644 index 00000000..da882cb0 --- /dev/null +++ b/views/phocacartrewards/tmpl/default.php @@ -0,0 +1,167 @@ +t['n'] . 'RenderAdminviews'; +$r = new $class(); +$user = JFactory::getUser(); +$userId = $user->get('id'); +$listOrder = $this->escape($this->state->get('list.ordering')); +$listDirn = $this->escape($this->state->get('list.direction')); +$canOrder = $user->authorise('core.edit.state', $this->t['o']); +$saveOrder = $listOrder == 'a.ordering'; +if ($saveOrder) { + $saveOrderingUrl = 'index.php?option='.$this->t['o'].'&task='.$this->t['tasks'].'.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', 'categoryList', 'adminForm', strtolower($listDirn), $saveOrderingUrl, false, true); +} +$sortFields = $this->getSortFields(); + +echo $r->jsJorderTable($listOrder); + + +echo $r->startForm($this->t['o'], $this->t['tasks'], 'adminForm'); +echo $r->startFilter(); +//echo $r->selectFilterPublished('JOPTION_SELECT_PUBLISHED', $this->state->get('filter.state')); +//echo $r->selectFilterLanguage('JOPTION_SELECT_LANGUAGE', $this->state->get('filter.language')); +//echo $r->selectFilterCategory(PhocaDownloadCategory::options($this->t['o']), 'JOPTION_SELECT_CATEGORY', $this->state->get('filter.category_id')); +echo $r->endFilter(); + +echo $r->startMainContainer(); +echo $r->startFilterBar(); + +echo $r->inputFilterSearch($this->t['l'].'_FILTER_SEARCH_LABEL', $this->t['l'].'_FILTER_SEARCH_DESC', + $this->escape($this->state->get('filter.search'))); + +$userNameSelected = isset($this->items[0]->user_name_selected) ? $this->items[0]->user_name_selected : ''; +echo $r->inputFilterUser($this->t['l'].'_FILTER_USER_LABEL', $this->t['l'].'_FILTER_USER_DESC', + $this->escape($this->state->get('filter.user')), $userNameSelected); +echo $r->inputFilterSearchClear('JSEARCH_FILTER_SUBMIT', 'JSEARCH_FILTER_CLEAR', array(0 => 'field-user-input')); +echo $r->inputFilterSearchLimit('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC', $this->pagination->getLimitBox()); +echo $r->selectFilterDirection('JFIELD_ORDERING_DESC', 'JGLOBAL_ORDER_ASCENDING', 'JGLOBAL_ORDER_DESCENDING', $listDirn); +echo $r->selectFilterSortBy('JGLOBAL_SORT_BY', $sortFields, $listOrder); + +echo $r->startFilterBar(2); +echo $r->selectFilterPublished('JOPTION_SELECT_PUBLISHED', $this->state->get('filter.state')); +echo $r->endFilterBar(); + +echo $r->endFilterBar(); + +echo $r->startTable('categoryList'); + +echo $r->startTblHeader(); + + +echo $r->thOrdering('JGRID_HEADING_ORDERING', $listDirn, $listOrder); +echo $r->thCheck('JGLOBAL_CHECK_ALL'); +echo ''.JHTML::_('grid.sort', $this->t['l'].'_TITLE', 'a.title', $listDirn, $listOrder ).''."\n"; +echo ''.JHTML::_('grid.sort', $this->t['l'].'_APPROVED', 'a.published', $listDirn, $listOrder ).''."\n"; +echo ''.JHTML::_('grid.sort', $this->t['l'].'_USER', 'u.name', $listDirn, $listOrder ).''."\n"; +echo ''.JHTML::_('grid.sort', $this->t['l'].'_REWARD_POINTS', 'a.points', $listDirn, $listOrder ).''."\n"; +echo ''.JText::_($this->t['l'].'_TOTAL_POINTS').''."\n"; +echo ''.JHTML::_('grid.sort', $this->t['l'].'_DATE', 'a.date', $listDirn, $listOrder ).''."\n"; +echo ''.JHTML::_('grid.sort', $this->t['l'].'_ID', 'a.id', $listDirn, $listOrder ).''."\n"; + +echo $r->endTblHeader(); + +echo ''. "\n"; + +$originalOrders = array(); +$parentsStr = ""; +$j = 0; + + +$reward = new PhocacartReward(); + +if (is_array($this->items)) { + foreach ($this->items as $i => $item) { + //if ($i >= (int)$this->pagination->limitstart && $j < (int)$this->pagination->limit) { + $j++; + +$urlEdit = 'index.php?option='.$this->t['o'].'&task='.$this->t['task'].'.edit&id='; +$urlTask = 'index.php?option='.$this->t['o'].'&task='.$this->t['task']; +$orderkey = array_search($item->id, $this->ordering[0]); +$ordering = ($listOrder == 'a.ordering'); +$canCreate = $user->authorise('core.create', $this->t['o']); +$canEdit = $user->authorise('core.edit', $this->t['o']); +$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out==$user->get('id') || $item->checked_out==0; +$canChange = $user->authorise('core.edit.state', $this->t['o']) && $canCheckin; +$linkEdit = JRoute::_( $urlEdit. $item->id ); + + + +$iD = $i % 2; +echo "\n\n"; +//echo ''. "\n"; + +echo $r->tdOrder($canChange, $saveOrder, $orderkey); +echo $r->td(JHtml::_('grid.id', $i, $item->id), "small"); + + +$checkO = ''; +if ($item->checked_out) { + $checkO .= JHtml::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, $this->t['tasks'].'.', $canCheckin); +} +if ($canCreate || $canEdit) { + $checkO .= '
    '. $this->escape($item->title).''; +} else { + $checkO .= $this->escape($item->title); +} +echo $r->td($checkO, "small"); + + +echo $r->td(PhocacartHtmlJgrid::approve($item->published, $i, $this->t['tasks'].'.', $canChange), "small"); + + +$userO = $this->escape($item->user_name); +if (isset($item->user_username)) { + $userO .= ' ('.$item->user_username.')'; +} +echo $r->td($userO, "small"); + + +$approvedClass = 'approved'; +if ($item->published == 0) { + $approvedClass = 'not-approved'; +} + +if ($item->type == 1) { + echo $r->td(''.$item->points.'', "small"); +} else if ($item->type == -1) { + echo $r->td(''.$item->points.'', "small"); +} else { + echo $r->td(''.$item->points.'', "small"); +} + + +$total = $reward->getTotalPointsByUserId($item->user_id); +echo $r->td($total, "small"); + + + +echo $r->td($item->date, "small"); +echo $r->td($item->id, "small"); + +echo ''. "\n"; + + //} + } +} +echo ''. "\n"; + +echo $r->tblFoot($this->pagination->getListFooter(), 9); +echo $r->endTable(); + +echo $r->formInputs($listOrder, $listDirn, $originalOrders); +echo $r->endMainContainer(); +echo $r->endForm(); +?> \ No newline at end of file diff --git a/views/phocacartrewards/tmpl/index.html b/views/phocacartrewards/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/views/phocacartrewards/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/phocacartrewards/view.html.php b/views/phocacartrewards/view.html.php new file mode 100644 index 00000000..de8f95b8 --- /dev/null +++ b/views/phocacartrewards/view.html.php @@ -0,0 +1,86 @@ +t = PhocacartUtils::setVars('reward'); + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + + + // Check for errors. + if (count($errors = $this->get('Errors'))) { + throw new Exception(implode("\n", $errors), 500); + return false; + } + + // Preprocess the list of items to find ordering divisions. + foreach ($this->items as &$item) { + $this->ordering[0][] = $item->id; + } + + $media = new PhocacartRenderAdminmedia(); + + $this->addToolbar(); + parent::display($tpl); + } + + function addToolbar() { + + require_once JPATH_COMPONENT.'/helpers/'.$this->t['tasks'].'.php'; + $state = $this->get('State'); + $class = ucfirst($this->t['tasks']).'Helper'; + $canDo = $class::getActions($this->t, $state->get('filter.reward_id')); + + JToolbarHelper::title( JText::_( $this->t['l'].'_REWARD_POINTS' ), 'certificate' ); + + if ($canDo->get('core.create')) { + JToolbarHelper::addNew($this->t['task'].'.add','JTOOLBAR_NEW'); + } + + if ($canDo->get('core.edit')) { + JToolbarHelper::editList($this->t['task'].'.edit','JTOOLBAR_EDIT'); + } + if ($canDo->get('core.edit.state')) { + + JToolbarHelper::divider(); + JToolbarHelper::custom($this->t['tasks'].'.publish', 'publish.png', 'publish_f2.png','COM_PHOCACART_APPROVE', true); + JToolbarHelper::custom($this->t['tasks'].'.unpublish', 'unpublish.png', 'unpublish_f2.png', 'COM_PHOCACART_DISAPPROVE', true); + } + + if ($canDo->get('core.delete')) { + JToolbarHelper::deleteList( $this->t['l'].'_WARNING_DELETE_ITEMS', 'phocacartrewards.delete', $this->t['l'].'_DELETE'); + } + JToolbarHelper::divider(); + JToolbarHelper::help( 'screen.'.$this->t['c'], true ); + } + + protected function getSortFields() { + return array( + //'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), + 'a.title' => JText::_($this->t['l'] . '_TITLE'), + 'u.username' => JText::_($this->t['l'] . '_USER'), + 'a.published' => JText::_($this->t['l'] . '_APPROVED'), + 'a.points' => JText::_($this->t['l'] . '_REWARD_POINTS'), + 'a.date' => JText::_($this->t['l'] . '_DATE'), + 'a.id' => JText::_('JGRID_HEADING_ID') + ); + } +} +?> \ No newline at end of file diff --git a/views/phocacartshipping/tmpl/edit.php b/views/phocacartshipping/tmpl/edit.php index b8bce598..ef143dad 100644 --- a/views/phocacartshipping/tmpl/edit.php +++ b/views/phocacartshipping/tmpl/edit.php @@ -28,7 +28,7 @@ startForm($this->t['o'], $this->t['task'], $this->item->id, 'adminForm', 'adminForm'); // First Column -echo '
    '; +echo '
    '; $tabs = array ( 'general' => JText::_($this->t['l'].'_GENERAL_OPTIONS'), 'amount' => JText::_($this->t['l'].'_AMOUNT_RULE'), @@ -36,21 +36,23 @@ 'country' => JText::_($this->t['l'].'_COUNTRY_RULE'), 'region' => JText::_($this->t['l'].'_REGION_RULE'), 'weight' => JText::_($this->t['l'].'_WEIGHT_RULE'), +'size' => JText::_($this->t['l'].'_SIZE_RULE'), 'method' => JText::_($this->t['l'].'_SHIPPING_METHOD_OPTIONS'), +'tracking' => JText::_($this->t['l'].'_SHIPMENT_TRACKING_OPTIONS'), 'publishing' => JText::_($this->t['l'].'_PUBLISHING_OPTIONS')); echo $r->navigation($tabs); echo '
    '. "\n"; echo '
    '."\n"; -$formArray = array ('title', 'cost', 'tax_id', 'calculation_type'); +$formArray = array ('title', 'cost', 'tax_id', 'calculation_type', 'default'); echo $r->group($this->form, $formArray); $formArray = array ('method'); echo $r->group($this->form, $formArray); echo '
    '; -$formArray = array ('image', 'ordering', 'access'); +$formArray = array ('image', 'ordering', 'access', 'group'); echo $r->group($this->form, $formArray); $formArray = array('description'); @@ -83,10 +85,21 @@ echo $r->group($this->form, $formArray); echo '
    '; +echo '
    '."\n"; +//$formArray = array ('shortest_length', 'longest_length', 'lowest_width', 'largest_width', 'lowest_height', 'highest_height', 'active_size'); +$formArray = array ('maximal_length', 'maximal_width', 'maximal_height', 'active_size'); +echo $r->group($this->form, $formArray); +echo '
    '; + echo '
    '."\n"; echo '
    '.JText::_('COM_PHOCACART_SELECT_SHIPPING_METHOD_TO_DISPLAY_PARAMETERS').'
    '; echo '
    '; +echo '
    '."\n"; +$formArray = array ('tracking_link', 'tracking_description'); +echo $r->group($this->form, $formArray); +echo '
    '; + echo '
    '."\n"; foreach($this->form->getFieldset('publish') as $field) { echo '
    '; @@ -102,7 +115,7 @@ echo '
    ';//end tab content echo '
    ';//end span10 // Second Column -echo '
    ';//end span2 +//echo '
    ';//end span2 echo $r->formInputs($this->t['task']); echo $r->endForm(); echo PhocacartRenderJs::renderAjaxTopHtml(); diff --git a/views/phocacartshippings/tmpl/default.php b/views/phocacartshippings/tmpl/default.php index dbb3c7b9..1d429de9 100644 --- a/views/phocacartshippings/tmpl/default.php +++ b/views/phocacartshippings/tmpl/default.php @@ -59,6 +59,7 @@ echo $r->thCheck('JGLOBAL_CHECK_ALL'); echo ''.JHTML::_('grid.sort', $this->t['l'].'_TITLE', 'a.title', $listDirn, $listOrder ).''."\n"; echo ''.JHTML::_('grid.sort', $this->t['l'].'_PUBLISHED', 'a.published', $listDirn, $listOrder ).''."\n"; +echo ''.JHTML::_('grid.sort', $this->t['l'].'_DEFAULT', 'a.default', $listDirn, $listOrder ).''."\n"; echo ''.JText::_( $this->t['l'].'_ACTIVE_RULE_S').''."\n"; echo ''.JTEXT::_($this->t['l'].'_ACCESS').''."\n"; echo ''.JHTML::_('grid.sort', $this->t['l'].'_ID', 'a.id', $listDirn, $listOrder ).''."\n"; @@ -109,6 +110,17 @@ echo $r->td(JHtml::_('jgrid.published', $item->published, $i, $this->t['tasks'].'.', $canChange), "small"); + +if ($item->default == '0' || $item->default == '1') { + $default = JHtml::_('jgrid.isdefault', $item->default, $i, $this->t['tasks'].'.', $canChange); + +} else if ($canChange) { + $default = ''; +} +echo $r->td($default, "small"); + + + $rules = array(); if($item->active_amount) {$rules[] = ''.JText::_('COM_PHOCACART_AMOUNT_RULE'). '';} if($item->active_country) {$rules[] = ''.JText::_('COM_PHOCACART_COUNTRY_RULE'). '';} @@ -129,7 +141,7 @@ } echo ''. "\n"; -echo $r->tblFoot($this->pagination->getListFooter(), 7); +echo $r->tblFoot($this->pagination->getListFooter(), 8); echo $r->endTable(); echo $r->formInputs($listOrder, $listDirn, $originalOrders); diff --git a/views/phocacartshippings/view.html.php b/views/phocacartshippings/view.html.php index 45eccc83..e4c90afd 100644 --- a/views/phocacartshippings/view.html.php +++ b/views/phocacartshippings/view.html.php @@ -66,6 +66,11 @@ function addToolbar() { if ($canDo->get('core.delete')) { JToolbarHelper::deleteList( $this->t['l'].'_WARNING_DELETE_ITEMS', 'phocacartshippings.delete', $this->t['l'].'_DELETE'); } + + if ($canDo->get('core.edit.state')){ + JToolbarHelper::makeDefault($this->t['tasks'].'.setDefault', 'COM_PHOCACART_DEFAULT'); + } + JToolbarHelper::divider(); JToolbarHelper::help( 'screen.'.$this->t['c'], true ); diff --git a/views/phocacartstatus/tmpl/edit.php b/views/phocacartstatus/tmpl/edit.php index ed19a753..1a137292 100644 --- a/views/phocacartstatus/tmpl/edit.php +++ b/views/phocacartstatus/tmpl/edit.php @@ -42,19 +42,22 @@ echo '
    '."\n"; -echo $r->item($this->form, 'title', '('.JText::_($this->form->getValue('title')).')', 1); +$translatedTitle = $this->form->getValue('title') ? '('.JText::_($this->form->getValue('title')).')' : ''; +echo $r->item($this->form, 'title', $translatedTitle, 1); -$formArray = array ( 'stock_movements', 'download', 'email_customer', 'email_others', 'email_subject', 'email_send'); +$formArray = array ( 'stock_movements', 'change_user_group', 'change_points_needed', 'change_points_received', 'download', 'email_customer', 'email_others', 'email_subject', 'email_send'); echo $r->group($this->form, $formArray); -$formArray = array('email_text'); -echo $r->group($this->form, $formArray, 1); - $formArray = array ('ordering'); echo $r->group($this->form, $formArray); +$formArray = array('email_text'); +echo $r->group($this->form, $formArray, 1); + $formArray = array('description'); echo $r->group($this->form, $formArray, 1); + + echo '
    '; echo '
    '."\n"; diff --git a/views/phocacartstatuses/tmpl/default.php b/views/phocacartstatuses/tmpl/default.php index df47fd95..3b26b0a5 100644 --- a/views/phocacartstatuses/tmpl/default.php +++ b/views/phocacartstatuses/tmpl/default.php @@ -123,8 +123,7 @@ if ($item->type == 1) { $default = ''; echo $r->td($default, "small ph-center"); -} -else { +} else { echo $r->td('', "small"); } echo $r->td($item->id, "small ph-center"); diff --git a/views/phocacartuser/tmpl/edit.php b/views/phocacartuser/tmpl/edit.php index ee9dac51..b016fd0b 100644 --- a/views/phocacartuser/tmpl/edit.php +++ b/views/phocacartuser/tmpl/edit.php @@ -34,10 +34,12 @@ echo '
    '; $tabs = array ( 'billing' => JText::_($this->t['l'].'_BILLING_OPTIONS'), -'shipping' => JText::_($this->t['l'].'_SHIPPING_OPTIONS')); +'shipping' => JText::_($this->t['l'].'_SHIPPING_OPTIONS'), +'groups' => JText::_($this->t['l'].'_GROUP_OPTIONS')); echo $r->navigation($tabs); -$data = PhocacartUser::getAddressDataForm($this->form, $this->fields['array'], $this->u); +$data = PhocacartUser::getAddressDataForm($this->formspecific, $this->fields['array'], $this->u); + echo '
    '. "\n"; echo '
    '."\n"; @@ -48,6 +50,12 @@ echo $data['s']; echo '
    '; +echo '
    '."\n"; + +$formArray = array ('group'); +echo $r->group($this->form, $formArray); +echo '
    '; + echo ''; /* diff --git a/views/phocacartuser/view.html.php b/views/phocacartuser/view.html.php index d9e9b232..c4e791c6 100644 --- a/views/phocacartuser/view.html.php +++ b/views/phocacartuser/view.html.php @@ -14,21 +14,35 @@ class PhocaCartCpViewPhocacartUser extends JViewLegacy protected $state; protected $item; protected $form; + protected $formspecific; protected $fields; protected $t; protected $u; public function display($tpl = null) { - $app = JFactory::getApplication(); - $this->t = PhocacartUtils::setVars('user'); - $this->state = $this->get('State'); - $this->form = $this->get('Form'); - $this->item = $this->get('Item'); - $this->fields = $this->get('Fields'); + $app = JFactory::getApplication(); + $this->t = PhocacartUtils::setVars('user'); + $this->state = $this->get('State'); + $this->form = $this->get('Form'); + $this->formspecific = $this->get('FormSpecific'); + $this->item = $this->get('Item'); + $this->fields = $this->get('Fields'); + + if (isset($this->item->user_id) && (int)$this->item->user_id > 0) { + $user_id = $this->item->user_id; + } else { + $user_id = $this->state->get($this->getName() . '.id'); + } + + $this->u = JFactory::getUser($user_id); + + // There are two forms + // 1) billing and shipping created by code + // 2) other info created by XML (user_id, group) + //$this->form->setValue('user_id', $user_id); // Add user_id to 2) so the field can get right Parameters - $this->u = JFactory::getUser($this->item->user_id); $media = new PhocacartRenderAdminmedia(); @@ -49,7 +63,7 @@ protected function addToolbar() { $canDo = $class::getActions($this->t, $this->state->get('filter.user_id')); $text = $isNew ? JText::_( $this->t['l'] . '_NEW' ) : JText::_($this->t['l'] . '_EDIT'); - JToolbarHelper::title( JText::_( $this->t['l'] . '_USER' ).': [ ' . $text.' ]' , 'user'); + JToolbarHelper::title( JText::_( $this->t['l'] . '_CUSTOMER' ).': [ ' . $text.' ]' , 'user'); // If not checked out, can save the item. if (!$checkedOut && $canDo->get('core.edit')){ diff --git a/views/phocacartusers/tmpl/default.php b/views/phocacartusers/tmpl/default.php index 5c8ef115..f26f3402 100644 --- a/views/phocacartusers/tmpl/default.php +++ b/views/phocacartusers/tmpl/default.php @@ -43,7 +43,11 @@ echo $r->startFilterBar(); echo $r->inputFilterSearch($this->t['l'].'_FILTER_SEARCH_LABEL', $this->t['l'].'_FILTER_SEARCH_DESC', $this->escape($this->state->get('filter.search'))); -echo $r->inputFilterSearchClear('JSEARCH_FILTER_SUBMIT', 'JSEARCH_FILTER_CLEAR'); + +$userNameSelected = isset($this->items[0]->user_name_selected) ? $this->items[0]->user_name_selected : ''; +echo $r->inputFilterUser($this->t['l'].'_FILTER_USER_LABEL', $this->t['l'].'_FILTER_USER_DESC', + $this->escape($this->state->get('filter.user')), $userNameSelected); +echo $r->inputFilterSearchClear('JSEARCH_FILTER_SUBMIT', 'JSEARCH_FILTER_CLEAR', array(0 => 'field-user-input')); echo $r->inputFilterSearchLimit('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC', $this->pagination->getLimitBox()); echo $r->selectFilterDirection('JFIELD_ORDERING_DESC', 'JGLOBAL_ORDER_ASCENDING', 'JGLOBAL_ORDER_DESCENDING', $listDirn); echo $r->selectFilterSortBy('JGLOBAL_SORT_BY', $sortFields, $listOrder); @@ -69,6 +73,7 @@ echo $r->thCheck('JGLOBAL_CHECK_ALL'); echo ''.JHTML::_('grid.sort', $this->t['l'].'_NAME', 'u.name', $listDirn, $listOrder ).''."\n"; echo ''.JText::_($this->t['l'].'_STATUS').''."\n"; +echo ''.JText::_($this->t['l'].'_GROUPS').''."\n"; echo ''.JHTML::_('grid.sort', $this->t['l'].'_FIRST_NAME_LABEL', 'a.name_first', $listDirn, $listOrder ).''."\n"; echo ''.JHTML::_('grid.sort', $this->t['l'].'_LAST_NAME_LABEL', 'a.name_last', $listDirn, $listOrder ).''."\n"; echo ''.JHTML::_('grid.sort', $this->t['l'].'_ADDRESS_1_LABEL', 'a.address_1', $listDirn, $listOrder ).''."\n"; @@ -116,7 +121,8 @@ if ($item->checked_out) { $checkO .= JHtml::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, $this->t['tasks'].'.', $canCheckin); } -if (($canCreate || $canEdit) && (int)$item->id > 0) { +//if (($canCreate || $canEdit) && (int)$item->id > 0) { +if ($canCreate || $canEdit) { $checkO .= ''. $this->escape($item->user_name).''; } else { $checkO .= $this->escape($item->user_name); @@ -180,6 +186,22 @@ else { echo $r->td('-', "small"); } + + +// GROUP +if (isset($item->groups) && $item->groups != '') { + $groupsA = explode(',', $item->groups); + asort($groupsA); + $groupsI = ''; + foreach($groupsA as $k => $v) { + $groupsI .= ' '.JText::_($v); + } + echo $r->td($groupsI, "small"); +} else { + echo $r->td('', "small"); +} + + echo $r->td($item->name_last, "small"); echo $r->td($item->name_first, "small"); echo $r->td($item->address_1, "small"); @@ -192,7 +214,7 @@ } echo ''. "\n"; -echo $r->tblFoot($this->pagination->getListFooter(), 8); +echo $r->tblFoot($this->pagination->getListFooter(), 9); echo $r->endTable(); echo '

    '.JText::_('COM_PHOCACART_NOTES').'

    '; diff --git a/views/phocacartusers/view.html.php b/views/phocacartusers/view.html.php index 7270ae51..d10b6e1f 100644 --- a/views/phocacartusers/view.html.php +++ b/views/phocacartusers/view.html.php @@ -49,7 +49,7 @@ function addToolbar() { $class = ucfirst($this->t['tasks']).'Helper'; $canDo = $class::getActions($this->t, $state->get('filter.user_id')); - JToolbarHelper::title( JText::_( $this->t['l'].'_USERS' ), 'user' ); + JToolbarHelper::title( JText::_( $this->t['l'].'_CUSTOMERS' ), 'user' ); if ($canDo->get('core.create')) { //JToolbarHelper::addNew($this->t['task'].'.add','JTOOLBAR_NEW'); @@ -66,7 +66,7 @@ function addToolbar() { } if ($canDo->get('core.delete')) { - //JToolbarHelper::deleteList( $this->t['l'].'_WARNING_DELETE_ITEMS', 'phocacarttags.delete', $this->t['l'].'_DELETE'); + //JToolbarHelper::deleteList( $this->t['l'].'_WARNING_DELETE_ITEMS', 'phocacartusers.delete', $this->t['l'].'_DELETE'); } JToolbarHelper::divider(); JToolbarHelper::help( 'screen.'.$this->t['c'], true ); diff --git a/views/phocacartwizard/tmpl/default.php b/views/phocacartwizard/tmpl/default.php index ea0d8b40..e927a09e 100644 --- a/views/phocacartwizard/tmpl/default.php +++ b/views/phocacartwizard/tmpl/default.php @@ -142,7 +142,7 @@
    -
    ()
    +
    ()