diff --git a/framework/core/assets/less/tree.less b/framework/core/assets/less/tree.less
index 4ee5cec894..cb4a94cf8d 100644
--- a/framework/core/assets/less/tree.less
+++ b/framework/core/assets/less/tree.less
@@ -10,7 +10,7 @@
padding:0;
}
-.ygtvspacer { height: 10px; width: 18px; }
+.ygtvspacer { height: 13px!important; width: 13px!important; }
.ygtvcheck0 { background: url(../../../../external/yui/2in3/dist/2.9.0/build/assets/skins/sam/check0.gif) 0 0 no-repeat; width:16px; height:22px; cursor:pointer }
.ygtvcheck1 { background: url(../../../../external/yui/2in3/dist/2.9.0/build/assets/skins/sam/check1.gif) 0 0 no-repeat; width:16px; height:22px; cursor:pointer }
.ygtvcheck2 { background: url(../../../../external/yui/2in3/dist/2.9.0/build/assets/skins/sam/check2.gif) 0 0 no-repeat; width:16px; height:22px; cursor:pointer }
@@ -23,38 +23,38 @@
}
#dropindicator{
- width:18px;
+ width:18px;
height:15px;
float:left;
margin:1px 5px 0 1px;
}
#dropindicator.dropattop{
- background-image:url(../images/exp1icons.png);
+ background-image:url(../images/exp1icons.png);
background-repeat:no-repeat;
- background-position:0 -643px;
+ background-position:0 -643px;
}
#dropindicator.dropatbottom{
- background-image:url(../images/exp1icons.png);
+ background-image:url(../images/exp1icons.png);
background-repeat:no-repeat;
- background-position:0 -665px;
+ background-position:0 -665px;
}
#dropindicator.putinbetween{
- background-image:url(../images/exp1icons.png);
+ background-image:url(../images/exp1icons.png);
background-repeat:no-repeat;
- background-position:0 -685px;
+ background-position:0 -685px;
}
#dropindicator.addtome{
- background-image:url(../images/exp1icons.png);
+ background-image:url(../images/exp1icons.png);
background-repeat:no-repeat;
- background-position:0 -703px;
+ background-position:0 -703px;
}
#dropindicator.nodrop{
- background-image:url(../images/exp1icons.png);
+ background-image:url(../images/exp1icons.png);
background-repeat:no-repeat;
- background-position:0 -722px;
+ background-position:0 -722px;
}
.dragtable:hover {
@@ -92,9 +92,9 @@
font-family:"Trebuchet MS","Verdana";
margin:0px;
border-bottom:1px dotted #888;
- background-image:url(../images/exp1icons.png);
+ background-image:url(../images/exp1icons.png);
background-repeat:no-repeat;
- background-position: 0px -548px;
+ background-position: 0px -548px;
}
#treecontext.yuimenu.show-scrollbars {
@@ -275,15 +275,15 @@ version: 2.5.1
.ygtvblankdepthcell { width:18px; height:22px; }
/* the style of the div around each node */
-.ygtvitem { }
+.ygtvitem { }
/* the style of the div around each node's collection of children */
-.ygtvchildren {
+.ygtvchildren {
*zoom: 1;
-}
+}
/* the style of the text label in ygTextNode */
-.ygtvlabel, .ygtvlabel:link, .ygtvlabel:visited, .ygtvlabel:hover {
+.ygtvlabel, .ygtvlabel:link, .ygtvlabel:visited, .ygtvlabel:hover {
margin-left:2px;
text-decoration: none;
font-size:12px;
@@ -293,10 +293,10 @@ version: 2.5.1
margin-left: 0;
}
-.ygtvspacer {
- height: 22px;
- width: 12px;
-}
+//.ygtvspacer {
+// height: 22px;
+// width: 12px;
+//}
//#catModal .ygtvtable tr td {
// background:inherit;
diff --git a/framework/core/forms/controls/jquery/tagtreecontrol.php b/framework/core/forms/controls/jquery/tagtreecontrol.php
index 0b1ea23ce5..16b5f2690e 100644
--- a/framework/core/forms/controls/jquery/tagtreecontrol.php
+++ b/framework/core/forms/controls/jquery/tagtreecontrol.php
@@ -116,7 +116,7 @@ function toHTML($label, $name) {
foreach ($icon as $key=>$icn) {
$text = expTheme::buttonIcon($key, 'large');
$icon[$key] = $text->prefix . $text->class . ' ' . $text->size;
- if (bs3())
+ if (bs3() || bs4())
$icon[$key] .= ' fa-fw';
elseif (bs2())
$icon[$key] .= ' icon-fixed-width';
@@ -134,6 +134,13 @@ function toHTML($label, $name) {
$this->tags[$i]->value = false;
$this->tags[$i]->state->selected = false;
}
+ if ($this->checkable && isset($this->tags[$i]->subcount) && $this->tags[$i]->subcount) {
+ if (!$this->tags[$i]->value) {
+ $this->tags[$i]->state->disabled = true;
+ } else {
+ $this->tags[$i]->text = '' . $this->tags[$i]->text . ' (' . gt('Improper Category, please deselect') . ')';
+ }
+ }
$this->tags[$i]->draggable = $this->draggable;
$this->tags[$i]->checkable = $this->checkable;
}
@@ -224,7 +231,7 @@ function toHTML($label, $name) {
'keep_selected_style' : false,
'three_state' : false,
// 'whole_node' : false,
- 'cascade' : 'undetermined'
+ 'cascade' : 'false'
},
'plugins' : [" . ($this->draggable?"'dnd'":"") . "," . ($this->menu?"'contextmenu'":"") . "," . ($this->checkable?"'checkbox'":"") . "]
}).on('move_node.jstree', function (e, data) {
diff --git a/framework/core/forms/controls/tagtreecontrol.php b/framework/core/forms/controls/tagtreecontrol.php
index 925cab01bd..76ff6edf35 100644
--- a/framework/core/forms/controls/tagtreecontrol.php
+++ b/framework/core/forms/controls/tagtreecontrol.php
@@ -111,6 +111,9 @@ function toHTML($label, $name) {
foreach ($this->tags as $i=> $val) {
if (!empty($this->values) && in_array($val->id, $this->values)) {
$this->tags[$i]->value = true;
+ if ($this->checkable && isset($this->tags[$i]->subcount) && $this->tags[$i]->subcount) {
+ $this->tags[$i]->title = '' . $this->tags[$i]->text . ' (' . gt('Improper Category, please deselect') . ')';
+ }
} else {
$this->tags[$i]->value = false;
}
diff --git a/framework/modules/ecommerce/controllers/storeController.php b/framework/modules/ecommerce/controllers/storeController.php
index 7a7fce956e..fa81ba7866 100755
--- a/framework/modules/ecommerce/controllers/storeController.php
+++ b/framework/modules/ecommerce/controllers/storeController.php
@@ -590,10 +590,13 @@ function manage() {
));
}
+ /**
+ * Display those products assigned to a NON-end level category
+ * therefore they can't really be displayed
+ */
function showallImpropercategorized() {
expHistory::set('viewable', $this->params);
- //FIXME not sure this is the correct sql, not sure what we are trying to pull out
$sql = 'SELECT DISTINCT(p.id),p.product_type FROM ' . DB_TABLE_PREFIX . '_product p ';
$sql .= 'JOIN ' . DB_TABLE_PREFIX . '_product_storeCategories psc ON p.id = psc.product_id ';
$sql .= 'JOIN '.DB_TABLE_PREFIX.'_storeCategories sc ON psc.storecategories_id = sc.parent_id ';
diff --git a/framework/modules/ecommerce/models/storeCategory.php b/framework/modules/ecommerce/models/storeCategory.php
index 5e4f3d703d..9a2cc18362 100644
--- a/framework/modules/ecommerce/models/storeCategory.php
+++ b/framework/modules/ecommerce/models/storeCategory.php
@@ -42,6 +42,30 @@ public function __construct($params=null, $get_assoc=true, $get_attached=true) {
}
}
+ /**
+ * Get count of sub-categories in this category
+ *
+ * @param null $id
+ * @return int
+ */
+ public function getSubCatCount($id = null) {
+ global $db;
+
+ if ($id === null)
+ $id = $this->id;
+ if (empty($id)) {
+ return 0;
+ } else {
+// $children = $db->selectNestedNodeChildren($this->table, $id);
+ return $db->countObjects($this->table,'parent_id=' . $id);
+ }
+ }
+
+ /**
+ * Return all sub-categories in this category
+ *
+ * @return array
+ */
public function getEcomSubcategories() {
global $db;
@@ -64,6 +88,56 @@ public function getEcomSubcategories() {
return $children;
}
+ /**
+ * Return all products assigned to this category
+ *
+ * @param null $id
+ * @return array
+ */
+ public function getAllProductsInThisCategory($id = null) {
+ global $user, $db;
+
+ if ($id === null)
+ $id = $this->id;
+ //if(!empty($order)) $order = " ORDER BY " . $order;
+ $order = " ORDER BY p.title ASC";
+
+ $sql_start = 'SELECT DISTINCT p.* FROM ' . DB_TABLE_PREFIX . '_product p ';
+ $sql = 'JOIN ' . DB_TABLE_PREFIX . '_product_storeCategories sc ON p.id = sc.product_id ';
+ $sql .= 'WHERE ';
+ if (!($user->is_admin || $user->is_acting_admin))
+ $sql .= '(p.active_type=0 OR p.active_type=1) AND ';
+ $sql .= 'sc.storecategories_id = ' . $id;
+ $sql = $sql_start . $sql . $order;
+ //echo $sql;
+ return $db->selectObjectsBySql($sql);
+ }
+
+ /**
+ * Return number of products assigned to this category
+ *
+ * @param null $id
+ * @return int
+ */
+ public function countProductsInThisCategory($id = null) {
+ global $user, $db;
+
+ if ($id === null)
+ $id = $this->id;
+ //if(!empty($order)) $order = " ORDER BY " . $order;
+ $order = " ORDER BY p.title ASC";
+
+ $sql_start = 'SELECT count(DISTINCT p.id) as c FROM ' . DB_TABLE_PREFIX . '_product p ';
+ $sql = 'JOIN ' . DB_TABLE_PREFIX . '_product_storeCategories sc ON p.id = sc.product_id ';
+ $sql .= 'WHERE ';
+ if (!($user->is_admin || $user->is_acting_admin))
+ $sql .= '(p.active_type=0 OR p.active_type=1) AND ';
+ $sql .= 'sc.storecategories_id = ' . $id;
+ $sql = $sql_start . $sql . $order;
+ //echo $sql;
+ return $db->countObjectsBySql($sql);
+ }
+
/**
* Return an image object
*
@@ -123,12 +197,15 @@ public function getFullTree() {
$tree_copy[$key]->rgt = $node->rgt;
$tree_copy[$key]->lft = $node->lft;
+ $tree_copy[$key]->count = $this->countProductsInThisCategory($node->id); // number of products in category
+ $tree_copy[$key]->subcount = $this->getSubCatCount($node->id); // determine is this is a usable category
+
if (!empty($node->expFile[0]->id)) { // add thumbnail
- $tree_copy[$key]->text = ' ' . $node->title;
+ $tree_copy[$key]->text = ' ' . $node->title . ' (' . $tree_copy[$key]->count . ')';
$tree_copy[$key]->title = $tree_copy[$key]->text;
} else {
- $tree_copy[$key]->text = $node->title;
- $tree_copy[$key]->title = $node->title;
+ $tree_copy[$key]->text = $node->title . ' (' . $tree_copy[$key]->count . ')';
+ $tree_copy[$key]->title = $tree_copy[$key]->text;
}
}
return $tree_copy;