add_filter(
GLM_MEMBERS_PACKAGING_PLUGIN_SLUG .'-dashboard-widget',
function ( $member = null ) {
- $packagingIndexPage = GLM_MEMBERS_PACKAGING_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-packaging-index&glm_action=index';
- $packagesTable = GLM_MEMBERS_PACKAGING_PLUGIN_DB_PREFIX . "packages";
- $packagingMemberEditPage = GLM_MEMBERS_PLUGIN_ADMIN_MENU_URL_BASE.'member&glm_action=packaging&option=edit';
- $packagingEditPage = GLM_MEMBERS_PLUGIN_ADMIN_MENU_URL_BASE.'member&glm_action=packaging&option=edit';
+ require_once GLM_MEMBERS_PACKAGING_PLUGIN_CLASS_PATH.'/data/dataPackages.php';
+ $Packages = new GlmDataPackages($this->wpdb, $this->config);
+
+ // Set default values for using getList() later, where the custom set of fields below will be used.
+ $where = '';
+ $order = '';
+ $fieldVals = true;
+ $idField = 'id';
+ $start = false;
+ $limit = false;
+
+ // Save the current fields array and make a copy
+ $fSave = $Packages->fields;
+
+ // Remove what we don't want from the copy and get the list
+ $Packages->fields = array(
+ 'id' => $fSave['id'],
+ 'title' => $fSave['title'],
+ 'status' => $fSave['status'],
+ 'ref_dest' => $fSave['ref_dest'],
+ 'ref_dest_name' => $fSave['ref_dest_name'],
+ 'ref_type' => $fSave['ref_type'],
+ 'expire_date' => $fSave['expire_date'],
+ );
+ $widgetResult = $Packages->getList("status=".$Packages->config['status_numb']['Pending'], $order, $fieldVals, $idField, $start, $limit);
+
+ // echo "<br><pre>" . var_dump($widgetResult) . "</pre><br>";
+
+ $packagingIndexPage = GLM_MEMBERS_PACKAGING_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-packaging-index&glm_action=index';
+ $packagesTable = GLM_MEMBERS_PACKAGING_PLUGIN_DB_PREFIX . "packages";
+ $packagingMemberEditPage = GLM_MEMBERS_PLUGIN_ADMIN_MENU_URL_BASE . 'member&glm_action=packaging&option=edit';
+ $packagingEditPage = GLM_MEMBERS_PLUGIN_ADMIN_MENU_URL_BASE . 'member&glm_action=packaging&option=edit';
+ $packagingRefLink = GLM_MEMBERS_PACKAGING_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-member&glm_action=index';
/*
* For list components: pass ref_type and ref_dest as part of the 'fields' string if you want to
'title' => 'Number of Packages',
'order' => 1,
'template' => 'entityAmount',
- 'table' => $packagesTable,
'url' => $packagingIndexPage . "&option=search",
+ 'result' => $Packages->getStats(),
],
[
'id' => 'textSearch',
'where' => 'title',
'resultUrl' => $packagingIndexPage . "&option=edit&packageID=",
],
- // [
- // 'id' => 'active',
- // 'title' => "Active Packages",
- // 'slug' => "active-packages",
- // 'order' => 3,
- // 'template' => 'list',
- // 'entityID' => 'packageID',
- // 'table' => $packagesTable,
- // 'fields' => "id, title, ref_type, ref_dest",
- // 'where' => 'status='.$this->config['status_numb']['Active'],
- // 'resultUrl' => $packagingEditPage,
- // ],
[
'id' => 'pending',
'title' => "Pending Packages",
'order' => 4,
'template' => 'list',
'entityID' => 'packageID',
- 'table' => $packagesTable,
- 'fields' => "id, title, ref_type, ref_dest",
- 'where' => 'status='.$this->config['status_numb']['Pending'],
- 'url' => $packagingEditPage,
+ 'refLink' => $packagingRefLink,
+ 'url' => $packagingIndexPage . "&option=search",
+ 'result' => $Packages->getList("status=".$Packages->config['status_numb']['Pending'], $order, $fieldVals, $idField, $start, $limit),
+ 'count' => $Packages->getStats("status=".$Packages->config['status_numb']['Pending'], $order, $fieldVals, $idField, $start, $limit),
+ 'fieldMap' => [
+ 'id' => 'id',
+ 'name' => 'title',
+ 'status' => 'status',
+ 'ref_dest_id' => 'ref_dest',
+ 'ref_dest_name' => 'ref_dest_name',
+ 'ref_type' => 'ref_type',
+ 'expire_date' => 'expire_date'
+ ],
],
[
'id' => 'expired',
'order' => 5,
'template' => 'list',
'entityID' => 'packageID',
- 'table' => $packagesTable,
- 'fields' => "id, title, ref_type, ref_dest, expire_date",
- 'where' => 'expire_date < NOW()',
- 'orderBy' => 'expire_date DESC',
- 'url' => $packagingEditPage,
+ 'refLink' => $packagingRefLink,
+ 'url' => $packagingIndexPage . "&option=search",
+ 'result' => $Packages->getList("expire_date < NOW()", "expire_date DESC", $fieldVals, $idField, $start, $limit),
+ 'count' => $Packages->getStats("expire_date < NOW()", "expire_date DESC", $fieldVals, $idField, $start, $limit),
+ 'fieldMap' => [
+ 'id' => 'id',
+ 'name' => 'title',
+ 'status' => 'status',
+ 'ref_dest_id' => 'ref_dest',
+ 'ref_dest_name' => 'ref_dest_name',
+ 'ref_type' => 'ref_type',
+ 'expire_date' => 'expire_date'
+ ],
],
]
];
+
+ // Restore the fields list
+ $Packages->fields = $fSave;
- return $content;
+ return $content;
},
13,
1