Add "Manage Premiums" to AdminUI, toward dev/core#3912 .
authorAllen Shaw <allen@JoineryHQ.com>
Wed, 6 Dec 2023 14:59:38 +0000 (08:59 -0600)
committerAllen Shaw <allen@JoineryHQ.com>
Wed, 20 Dec 2023 20:24:11 +0000 (14:24 -0600)
CRM/Contribute/DAO/Product.php
ext/civicrm_admin_ui/ang/afsearchPremiumProducts.aff.html [new file with mode: 0644]
ext/civicrm_admin_ui/ang/afsearchPremiumProducts.aff.php [new file with mode: 0644]
ext/civicrm_admin_ui/managed/SavedSearch_Manage_Premiums.mgd.php [new file with mode: 0644]
xml/schema/Contribute/Product.xml

index 5cb1e55761d2923483ddf3d06674f491ff802bbb..3b431d02298e13b471ceabd6496e453d632ade84 100644 (file)
@@ -47,6 +47,7 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
     'add' => 'civicrm/admin/contribute/managePremiums/edit?action=add&reset=1',
     'update' => 'civicrm/admin/contribute/managePremiums/edit?action=update&id=[id]&reset=1',
     'delete' => 'civicrm/admin/contribute/managePremiums/edit?action=delete&id=[id]&reset=1',
+    'preview' => 'civicrm/admin/contribute/managePremiums/edit?action=preview&reset=1&id=[id]',
     'browse' => 'civicrm/admin/contribute/managePremiums/',
   ];
 
diff --git a/ext/civicrm_admin_ui/ang/afsearchPremiumProducts.aff.html b/ext/civicrm_admin_ui/ang/afsearchPremiumProducts.aff.html
new file mode 100644 (file)
index 0000000..d98af53
--- /dev/null
@@ -0,0 +1,13 @@
+<div class="af-container">
+  <div class="af-markup">
+    <div class="help">
+    <p>{{:: ts(&#39;CiviContribute allows you to configure any number of Premiums which can be offered to contributors as incentives / thank-you gifts. Premiums may be tangible items (i.e. a coffee mug or t-shirt), or they may be a membership or subscription with a pre-determined duration.&#39;) }}</p>
+
+    <p>{{:: ts(&#39;Use this section to enter and update all premiums that you want to offer on any of your Online Contribution pages. Then you can assign one or more premiums to a specific Contribution page from Contributions &raquo; Manage Contribution Pages &raquo; Configure &raquo; Premiums.&#39;) }}</p>
+    </div>
+
+  </div>
+</div>
+<div af-fieldset="">
+  <crm-search-display-table search-name="Manage_Premiums" display-name="Manage_Premiums_Table_1"></crm-search-display-table>
+</div>
diff --git a/ext/civicrm_admin_ui/ang/afsearchPremiumProducts.aff.php b/ext/civicrm_admin_ui/ang/afsearchPremiumProducts.aff.php
new file mode 100644 (file)
index 0000000..dc9aa13
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+
+use CRM_CivicrmAdminUi_ExtensionUtil as E;
+
+return [
+  'type' => 'search',
+  'title' => E::ts('Premium Products'),
+  'placement' => [],
+  'icon' => 'fa-list-alt',
+  'server_route' => 'civicrm/admin/contribute/managePremiums',
+  'is_public' => FALSE,
+  'permission' => [
+    'access CiviCRM',
+  ],
+  'permission_operator' => 'AND',
+  'submit_enabled' => TRUE,
+  'create_submission' => FALSE,
+];
diff --git a/ext/civicrm_admin_ui/managed/SavedSearch_Manage_Premiums.mgd.php b/ext/civicrm_admin_ui/managed/SavedSearch_Manage_Premiums.mgd.php
new file mode 100644 (file)
index 0000000..0a79a61
--- /dev/null
@@ -0,0 +1,237 @@
+<?php
+use CRM_CivicrmAdminUi_ExtensionUtil as E;
+
+return [
+  [
+    'name' => 'SavedSearch_Manage_Premiums',
+    'entity' => 'SavedSearch',
+    'cleanup' => 'unused',
+    'update' => 'unmodified',
+    'params' => [
+      'version' => 4,
+      'values' => [
+        'name' => 'Manage_Premiums',
+        'label' => E::ts('Manage Premiums'),
+        'api_entity' => 'Product',
+        'api_params' => [
+          'version' => 4,
+          'select' => [
+            'name',
+            'sku',
+            'price',
+            'min_contribution',
+            'cost',
+            'financial_type_id:label',
+            'is_active',
+          ],
+          'orderBy' => [],
+          'where' => [],
+          'groupBy' => [],
+          'join' => [],
+          'having' => [],
+        ],
+      ],
+      'match' => [
+        'name',
+      ],
+    ],
+  ],
+  [
+    'name' => 'SavedSearch_Manage_Premiums_SearchDisplay_Manage_Premiums_Table_1',
+    'entity' => 'SearchDisplay',
+    'cleanup' => 'unused',
+    'update' => 'unmodified',
+    'params' => [
+      'version' => 4,
+      'values' => [
+        'name' => 'Manage_Premiums_Table_1',
+        'label' => E::ts('Manage Premium Products'),
+        'saved_search_id.name' => 'Manage_Premiums',
+        'type' => 'table',
+        'settings' => [
+          'description' => '',
+          'sort' => [
+            [
+              'name',
+              'ASC',
+            ],
+          ],
+          'limit' => 50,
+          'pager' => [
+            'expose_limit' => TRUE,
+            'show_count' => TRUE,
+            'hide_single' => TRUE,
+          ],
+          'placeholder' => 5,
+          'columns' => [
+            [
+              'type' => 'field',
+              'key' => 'name',
+              'dataType' => 'String',
+              'label' => E::ts('Product Name'),
+              'sortable' => TRUE,
+              'editable' => TRUE,
+            ],
+            [
+              'type' => 'field',
+              'key' => 'sku',
+              'dataType' => 'String',
+              'label' => E::ts('SKU'),
+              'sortable' => TRUE,
+              'editable' => TRUE,
+            ],
+            [
+              'type' => 'field',
+              'key' => 'price',
+              'dataType' => 'Money',
+              'label' => E::ts('Price'),
+              'sortable' => TRUE,
+              'editable' => TRUE,
+            ],
+            [
+              'type' => 'field',
+              'key' => 'min_contribution',
+              'dataType' => 'Money',
+              'label' => E::ts('Minimum Contribution'),
+              'sortable' => TRUE,
+              'editable' => TRUE,
+            ],
+            [
+              'type' => 'field',
+              'key' => 'cost',
+              'dataType' => 'Money',
+              'label' => E::ts('Cost'),
+              'sortable' => TRUE,
+              'editable' => TRUE,
+            ],
+            [
+              'type' => 'field',
+              'key' => 'financial_type_id:label',
+              'dataType' => 'Integer',
+              'label' => E::ts('Financial Type'),
+              'sortable' => TRUE,
+              'editable' => TRUE,
+            ],
+            [
+              'type' => 'field',
+              'key' => 'is_active',
+              'dataType' => 'Boolean',
+              'label' => E::ts('Enabled'),
+              'sortable' => TRUE,
+              'editable' => TRUE,
+            ],
+            [
+              'text' => '',
+              'style' => 'default',
+              'size' => 'btn-xs',
+              'icon' => 'fa-bars',
+              'links' => [
+                [
+                  'entity' => 'Product',
+                  'action' => 'preview',
+                  'join' => '',
+                  'target' => 'crm-popup',
+                  'icon' => 'fa-eye',
+                  'text' => E::ts('Preview'),
+                  'style' => 'default',
+                  'path' => '',
+                  'task' => '',
+                  'condition' => [],
+                ],
+                [
+                  'entity' => 'Product',
+                  'action' => 'update',
+                  'join' => '',
+                  'target' => 'crm-popup',
+                  'icon' => 'fa-pencil',
+                  'text' => E::ts('Edit'),
+                  'style' => 'default',
+                  'path' => '',
+                  'task' => '',
+                  'condition' => [],
+                ],
+                [
+                  'task' => 'enable',
+                  'entity' => 'Product',
+                  'join' => '',
+                  'target' => 'crm-popup',
+                  'icon' => 'fa-toggle-on',
+                  'text' => E::ts('Enable'),
+                  'style' => 'default',
+                  'path' => '',
+                  'action' => '',
+                  'condition' => [
+                    'is_active',
+                    '=',
+                    FALSE,
+                  ],
+                ],
+                [
+                  'task' => 'disable',
+                  'entity' => 'Product',
+                  'join' => '',
+                  'target' => 'crm-popup',
+                  'icon' => 'fa-toggle-off',
+                  'text' => E::ts('Disable'),
+                  'style' => 'default',
+                  'path' => '',
+                  'action' => '',
+                  'condition' => [
+                    'is_active',
+                    '=',
+                    TRUE,
+                  ],
+                ],
+                [
+                  'entity' => 'Product',
+                  'action' => 'delete',
+                  'join' => '',
+                  'target' => 'crm-popup',
+                  'icon' => 'fa-trash',
+                  'text' => E::ts('Delete'),
+                  'style' => 'danger',
+                  'path' => '',
+                  'task' => '',
+                  'condition' => [],
+                ],
+              ],
+              'type' => 'menu',
+              'alignment' => 'text-right',
+            ],
+          ],
+          'actions' => TRUE,
+          'classes' => [
+            'table',
+            'table-striped',
+          ],
+          'cssRules' => [
+            [
+              'disabled',
+              'is_active',
+              '=',
+              FALSE,
+            ],
+          ],
+          'toolbar' => [
+            [
+              'path' => '',
+              'icon' => 'fa-plus',
+              'text' => E::ts('Add Product'),
+              'style' => 'primary',
+              'condition' => [],
+              'task' => '',
+              'entity' => 'Product',
+              'action' => 'add',
+              'join' => '',
+              'target' => 'crm-popup',
+            ],
+          ],
+        ],
+      ],
+      'match' => [
+        'saved_search_id',
+        'name',
+      ],
+    ],
+  ],
+];
index 237453035ba16139cf08c39b5ca0a21217a8bfa3..3020d04d2456527ddc61b577e8049a053bb147d2 100644 (file)
@@ -6,6 +6,9 @@
   <comment>able - stores "product info" for premiums and can be used for non-incentive products </comment>
   <name>civicrm_product</name>
   <add>1.4</add>
+  <paths>
+    <preview>civicrm/admin/contribute/managePremiums?action=preview&amp;reset=1&amp;id=[id]</preview>
+  </paths>
   <log>true</log>
   <component>CiviContribute</component>
   <labelField>name</labelField>