← All changes
|
backend/src/Services/Template/SoftwarePurchaseOrderFormTemplate.php
+37
-28
0.8.1
→
1.5
View file →
| @@ -1,26 +1,21 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace IvyForms\Services\Template; |
| 4 | 4 | |
| 5 | -// phpcs:disable PSR1.Files.SideEffects | |
| 6 | -if (!defined('ABSPATH')) { | |
| 7 | - exit; // Exit if accessed directly | |
| 8 | -} | |
| 9 | - | |
| 10 | 5 | use IvyForms\Services\Translations\BackendStrings; |
| 11 | 6 | |
| 7 | +class SoftwarePurchaseOrderFormTemplate | |
| 8 | +{ | |
| 12 | 9 | /** |
| 13 | 10 | * Software Purchase Order Form Template |
| 14 | 11 | */ |
| 15 | -class SoftwarePurchaseOrderFormTemplate | |
| 16 | -{ | |
| 17 | 12 | /** |
| 18 | - * Get the template configuration | |
| 13 | + * Get template metadata (without form_data) | |
| 19 | 14 | * |
| 20 | 15 | * @return array<string, mixed> |
| 21 | 16 | */ |
| 22 | - public static function getTemplate(): array | |
| 17 | + public static function getTemplateMeta(): array | |
| 23 | 18 | { |
| 24 | 19 | return [ |
| 25 | 20 | 'id' => 'software_purchase_order_form', |
| 26 | 21 | 'name' => BackendStrings::getTemplateStrings()['software_purchase_order_form'], |
| @@ -27,11 +22,24 @@ | ||
| 27 | 22 | 'description' => BackendStrings::getTemplateStrings()[ |
| 28 | 23 | 'software_purchase_order_form_description' |
| 29 | 24 | ], |
| 30 | 25 | 'category' => 'order-forms', |
| 31 | - 'subcategory' => 'general-product-order-form', | |
| 26 | + 'subcategory' => 'product-order-forms', | |
| 32 | 27 | 'is_pro' => false, |
| 33 | - 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'software-purchase-order-form.svg', | |
| 28 | + 'screenshot' => IVYFORMS_TEMPLATES_IMAGES_URL . 'software-purchase-order-form.svg' | |
| 29 | + ]; | |
| 30 | + } | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * Get the full template including form data | |
| 34 | + * | |
| 35 | + * @return array<string, mixed> | |
| 36 | + */ | |
| 37 | + public static function getTemplate(): array | |
| 38 | + { | |
| 39 | + return array_merge( | |
| 40 | + self::getTemplateMeta(), | |
| 41 | + [ | |
| 34 | 42 | 'form_data' => [ |
| 35 | 43 | 'name' => BackendStrings::getTemplateStrings()['software_purchase_order_form'], |
| 36 | 44 | 'published' => 1, |
| 37 | 45 | 'showTitle' => 1, |
| @@ -43,9 +51,10 @@ | ||
| 43 | 51 | self::getAdditionalInformationFields() |
| 44 | 52 | ), |
| 45 | 53 | 'settings' => [] |
| 46 | 54 | ] |
| 47 | - ]; | |
| 55 | + ] | |
| 56 | + ); | |
| 48 | 57 | } |
| 49 | 58 | |
| 50 | 59 | /** |
| 51 | 60 | * Requestor information fields (name, email, phone, department) |
| @@ -56,9 +65,9 @@ | ||
| 56 | 65 | { |
| 57 | 66 | return [ |
| 58 | 67 | // Requestor Name |
| 59 | 68 | [ |
| 60 | - 'id' => 0, | |
| 69 | + 'id' => 1, | |
| 61 | 70 | 'fieldIndex' => 1, |
| 62 | 71 | 'type' => 'name', |
| 63 | 72 | 'label' => BackendStrings::getTemplateStrings()['requestor_name'], |
| 64 | 73 | 'parentId' => null, |
| @@ -69,14 +78,14 @@ | ||
| 69 | 78 | 'position' => 1, |
| 70 | 79 | ], |
| 71 | 80 | // First Name - Child of Name Field |
| 72 | 81 | [ |
| 73 | - 'id' => 0, | |
| 82 | + 'id' => 2, | |
| 74 | 83 | 'type' => 'text', |
| 75 | 84 | 'label' => BackendStrings::getTemplateStrings()['first_name'], |
| 76 | 85 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_first_name'], |
| 77 | 86 | 'required' => true, |
| 78 | - 'parentId' => 0, | |
| 87 | + 'parentId' => 1, | |
| 79 | 88 | 'fieldIndex' => 1, |
| 80 | 89 | 'defaultValue' => '', |
| 81 | 90 | 'position' => 1, |
| 82 | 91 | 'optionHide' => false, |
| @@ -84,14 +93,14 @@ | ||
| 84 | 93 | 'settings' => json_encode(['nameFieldType' => 'nameField1']), |
| 85 | 94 | ], |
| 86 | 95 | // Last Name - Child of Name Field |
| 87 | 96 | [ |
| 88 | - 'id' => 0, | |
| 97 | + 'id' => 3, | |
| 89 | 98 | 'type' => 'text', |
| 90 | 99 | 'label' => BackendStrings::getTemplateStrings()['last_name'], |
| 91 | 100 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_your_last_name'], |
| 92 | 101 | 'required' => true, |
| 93 | - 'parentId' => 0, | |
| 102 | + 'parentId' => 1, | |
| 94 | 103 | 'fieldIndex' => 1, |
| 95 | 104 | 'defaultValue' => '', |
| 96 | 105 | 'position' => 2, |
| 97 | 106 | 'optionHide' => false, |
| @@ -99,9 +108,9 @@ | ||
| 99 | 108 | 'settings' => json_encode(['nameFieldType' => 'nameField2']), |
| 100 | 109 | ], |
| 101 | 110 | // Email Address |
| 102 | 111 | [ |
| 103 | - 'id' => 0, | |
| 112 | + 'id' => 4, | |
| 104 | 113 | 'fieldIndex' => 2, |
| 105 | 114 | 'type' => 'email', |
| 106 | 115 | 'label' => BackendStrings::getTemplateStrings()['email_address'], |
| 107 | 116 | 'placeholder' => BackendStrings::getTemplateStrings()['email_placeholder'], |
| @@ -111,9 +120,9 @@ | ||
| 111 | 120 | 'position' => 3, |
| 112 | 121 | ], |
| 113 | 122 | // Phone Number |
| 114 | 123 | [ |
| 115 | - 'id' => 0, | |
| 124 | + 'id' => 5, | |
| 116 | 125 | 'fieldIndex' => 3, |
| 117 | 126 | 'type' => 'phone', |
| 118 | 127 | 'label' => BackendStrings::getTemplateStrings()['phone_number'], |
| 119 | 128 | 'placeholder' => BackendStrings::getTemplateStrings()['phone_placeholder'], |
| @@ -123,9 +132,9 @@ | ||
| 123 | 132 | 'position' => 4, |
| 124 | 133 | ], |
| 125 | 134 | // Department |
| 126 | 135 | [ |
| 127 | - 'id' => 0, | |
| 136 | + 'id' => 6, | |
| 128 | 137 | 'fieldIndex' => 4, |
| 129 | 138 | 'type' => 'text', |
| 130 | 139 | 'label' => BackendStrings::getTemplateStrings()['department'], |
| 131 | 140 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_department'], |
| @@ -146,9 +155,9 @@ | ||
| 146 | 155 | { |
| 147 | 156 | return [ |
| 148 | 157 | // Software Name |
| 149 | 158 | [ |
| 150 | - 'id' => 0, | |
| 159 | + 'id' => 7, | |
| 151 | 160 | 'fieldIndex' => 5, |
| 152 | 161 | 'type' => 'text', |
| 153 | 162 | 'label' => BackendStrings::getTemplateStrings()['software_name'], |
| 154 | 163 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_software_name'], |
| @@ -158,9 +167,9 @@ | ||
| 158 | 167 | 'position' => 6, |
| 159 | 168 | ], |
| 160 | 169 | // Number of Licenses |
| 161 | 170 | [ |
| 162 | - 'id' => 0, | |
| 171 | + 'id' => 8, | |
| 163 | 172 | 'fieldIndex' => 6, |
| 164 | 173 | 'type' => 'number', |
| 165 | 174 | 'label' => BackendStrings::getTemplateStrings()['number_of_licenses'], |
| 166 | 175 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_number_of_licenses'], |
| @@ -171,9 +180,9 @@ | ||
| 171 | 180 | 'minValue' => 1, |
| 172 | 181 | ], |
| 173 | 182 | // License Type |
| 174 | 183 | [ |
| 175 | - 'id' => 0, | |
| 184 | + 'id' => 12, | |
| 176 | 185 | 'fieldIndex' => 7, |
| 177 | 186 | 'type' => 'select', |
| 178 | 187 | 'label' => BackendStrings::getTemplateStrings()['license_type'], |
| 179 | 188 | 'placeholder' => BackendStrings::getTemplateStrings()['select_license_type'], |
| @@ -182,9 +191,9 @@ | ||
| 182 | 191 | 'defaultValue' => '', |
| 183 | 192 | 'position' => 8, |
| 184 | 193 | 'fieldOptions' => [ |
| 185 | 194 | [ |
| 186 | - 'id' => 0, | |
| 195 | + 'id' => 9, | |
| 187 | 196 | 'label' => BackendStrings::getTemplateStrings()['single_user'], |
| 188 | 197 | 'value' => 'single_user', |
| 189 | 198 | 'isDefault' => false, |
| 190 | 199 | 'position' => 1 |
| @@ -189,9 +198,9 @@ | ||
| 189 | 198 | 'isDefault' => false, |
| 190 | 199 | 'position' => 1 |
| 191 | 200 | ], |
| 192 | 201 | [ |
| 193 | - 'id' => 0, | |
| 202 | + 'id' => 10, | |
| 194 | 203 | 'label' => BackendStrings::getTemplateStrings()['multi_user'], |
| 195 | 204 | 'value' => 'multi_user', |
| 196 | 205 | 'isDefault' => false, |
| 197 | 206 | 'position' => 2 |
| @@ -196,9 +205,9 @@ | ||
| 196 | 205 | 'isDefault' => false, |
| 197 | 206 | 'position' => 2 |
| 198 | 207 | ], |
| 199 | 208 | [ |
| 200 | - 'id' => 0, | |
| 209 | + 'id' => 11, | |
| 201 | 210 | 'label' => BackendStrings::getTemplateStrings()['enterprise'], |
| 202 | 211 | 'value' => 'enterprise', |
| 203 | 212 | 'isDefault' => false, |
| 204 | 213 | 'position' => 3 |
| @@ -217,9 +226,9 @@ | ||
| 217 | 226 | { |
| 218 | 227 | return [ |
| 219 | 228 | // Additional Notes or Requirements |
| 220 | 229 | [ |
| 221 | - 'id' => 0, | |
| 230 | + 'id' => 13, | |
| 222 | 231 | 'fieldIndex' => 8, |
| 223 | 232 | 'type' => 'textarea', |
| 224 | 233 | 'label' => BackendStrings::getTemplateStrings()['additional_notes_or_requirements'], |
| 225 | 234 | 'placeholder' => BackendStrings::getTemplateStrings()['enter_additional_notes_or_requirements'], |
| @@ -229,9 +238,9 @@ | ||
| 229 | 238 | 'position' => 9, |
| 230 | 239 | ], |
| 231 | 240 | // Required Activation Date |
| 232 | 241 | [ |
| 233 | - 'id' => 0, | |
| 242 | + 'id' => 14, | |
| 234 | 243 | 'fieldIndex' => 9, |
| 235 | 244 | 'type' => 'date', |
| 236 | 245 | 'label' => BackendStrings::getTemplateStrings()['required_activation_date'], |
| 237 | 246 | 'placeholder' => BackendStrings::getTemplateStrings()['select_required_activation_date'], |