| @@ -63,9 +63,11 @@ | ||
| 63 | 63 | public static function get_customer_fields() { |
| 64 | 64 | |
| 65 | 65 | if ( ! WPSC_Functions::is_site_admin() ) { |
| 66 | 66 | wp_send_json_error( __( 'Unauthorized access!', 'supportcandy' ), 401 ); |
| 67 | - }?> | |
| 67 | + } | |
| 68 | + $custom_fields_types = array_merge( WPSC_Custom_Field::$cf_types, WPSC_Custom_Field::$default_cf_types ); | |
| 69 | + ?> | |
| 68 | 70 | |
| 69 | 71 | <div class="wpsc-setting-header"> |
| 70 | 72 | <h2><?php esc_attr_e( 'Customer Fields', 'supportcandy' ); ?></h2> |
| 71 | 73 | </div> |
| @@ -81,10 +83,16 @@ | ||
| 81 | 83 | </div> |
| 82 | 84 | <table class="ticket-fields wpsc-setting-tbl"> |
| 83 | 85 | <thead> |
| 84 | 86 | <tr> |
| 87 | + <th style="width: 30px;"><?php esc_attr_e( 'Sort', 'supportcandy' ); ?></th> | |
| 85 | 88 | <th><?php esc_attr_e( 'Field', 'supportcandy' ); ?></th> |
| 86 | 89 | <th><?php esc_attr_e( 'Extra info', 'supportcandy' ); ?></th> |
| 90 | + <th><?php esc_attr_e( 'Type', 'supportcandy' ); ?></th> | |
| 91 | + <th><?php esc_attr_e( 'Auto Fill', 'supportcandy' ); ?></th> | |
| 92 | + <th><?php esc_attr_e( 'Personal Info', 'supportcandy' ); ?></th> | |
| 93 | + <th><?php esc_attr_e( 'Allow in My Profile', 'supportcandy' ); ?></th> | |
| 94 | + <th><?php esc_attr_e( 'Allow in Ticket Form', 'supportcandy' ); ?></th> | |
| 87 | 95 | <th><?php esc_attr_e( 'Actions', 'supportcandy' ); ?></th> |
| 88 | 96 | </tr> |
| 89 | 97 | </thead> |
| 90 | 98 | <tbody> |
| @@ -93,18 +101,24 @@ | ||
| 93 | 101 | if ( $cf->field != 'customer' ) { |
| 94 | 102 | continue; |
| 95 | 103 | } |
| 96 | 104 | ?> |
| 97 | - <tr> | |
| 105 | + <tr data-id="<?php echo esc_attr( $cf->id ); ?>"> | |
| 106 | + <td class="sort-handle"><?php WPSC_Icons::get( 'sort' ); ?></td> | |
| 98 | 107 | <td><?php echo esc_attr( $cf->name ); ?></td> |
| 99 | 108 | <td><?php echo esc_attr( $cf->extra_info ); ?></td> |
| 109 | + <td><?php echo esc_attr( $custom_fields_types[ $cf->type::$slug ]['label'] ); ?></td> | |
| 110 | + <td><?php echo esc_attr( $cf->is_auto_fill ? __( 'Yes', 'supportcandy' ) : __( 'No', 'supportcandy' ) ); ?></td> | |
| 111 | + <td><?php echo esc_attr( $cf->is_personal_info ? __( 'Yes', 'supportcandy' ) : __( 'No', 'supportcandy' ) ); ?></td> | |
| 112 | + <td><?php echo esc_attr( $cf->allow_my_profile ? __( 'Yes', 'supportcandy' ) : __( 'No', 'supportcandy' ) ); ?></td> | |
| 113 | + <td><?php echo esc_attr( $cf->allow_ticket_form ? __( 'Yes', 'supportcandy' ) : __( 'No', 'supportcandy' ) ); ?></td> | |
| 100 | 114 | <td> |
| 101 | - <a href="javascript:wpsc_get_edit_custom_field(<?php echo esc_attr( $cf->id ); ?>, '<?php echo esc_attr( wp_create_nonce( 'wpsc_get_edit_custom_field' ) ); ?>');" class="wpsc-link"><?php esc_attr_e( 'Edit', 'supportcandy' ); ?></a> | |
| 115 | + <span class="wpsc-link" onclick="wpsc_get_edit_custom_field(<?php echo esc_attr( $cf->id ); ?>, '<?php echo esc_attr( wp_create_nonce( 'wpsc_get_edit_custom_field' ) ); ?>');"><?php esc_attr_e( 'Edit', 'supportcandy' ); ?></span> | |
| 102 | 116 | <?php |
| 103 | 117 | if ( ! $cf->type::$is_default ) { |
| 104 | 118 | echo esc_attr( ' | ' ); |
| 105 | 119 | ?> |
| 106 | - <a href="javascript:wpsc_delete_custom_field(<?php echo esc_attr( $cf->id ); ?>, '<?php echo esc_attr( wp_create_nonce( 'wpsc_delete_custom_field' ) ); ?>');" class="wpsc-link"><?php esc_attr_e( 'Delete', 'supportcandy' ); ?></a> | |
| 120 | + <span class="wpsc-link" onclick="wpsc_delete_custom_field(<?php echo esc_attr( $cf->id ); ?>, '<?php echo esc_attr( wp_create_nonce( 'wpsc_delete_custom_field' ) ); ?>');"><?php esc_attr_e( 'Delete', 'supportcandy' ); ?></span> | |
| 107 | 121 | <?php |
| 108 | 122 | } |
| 109 | 123 | ?> |
| 110 | 124 | </td> |
| @@ -116,11 +130,13 @@ | ||
| 116 | 130 | </table> |
| 117 | 131 | <script> |
| 118 | 132 | jQuery('table.ticket-fields').DataTable({ |
| 119 | 133 | ordering: false, |
| 134 | + autoWidth: false, | |
| 120 | 135 | pageLength: 20, |
| 121 | 136 | bLengthChange: false, |
| 122 | - columnDefs: [ | |
| 137 | + columnDefs: [ | |
| 138 | + { targets: 0, width: '30px', searchable: false }, | |
| 123 | 139 | { targets: -1, searchable: false }, |
| 124 | 140 | { targets: '_all', className: 'dt-left' } |
| 125 | 141 | ], |
| 126 | 142 | layout: { |
| @@ -136,8 +152,37 @@ | ||
| 136 | 152 | ], |
| 137 | 153 | }, |
| 138 | 154 | }, |
| 139 | 155 | language: supportcandy.translations.datatables |
| 156 | + }); | |
| 157 | + | |
| 158 | + jQuery(function() { | |
| 159 | + // Enable sorting with jQuery UI. | |
| 160 | + jQuery('table.ticket-fields tbody').sortable({ | |
| 161 | + handle: '.sort-handle', | |
| 162 | + helper: function(e, tr) { | |
| 163 | + var $originals = tr.children(); | |
| 164 | + var $helper = tr.clone(); | |
| 165 | + $helper.children().each(function(index) { | |
| 166 | + jQuery(this).width($originals.eq(index).width()); | |
| 167 | + }); | |
| 168 | + return $helper; | |
| 169 | + }, | |
| 170 | + update: function(event, ui) { | |
| 171 | + var ids = jQuery(this).sortable('toArray', { attribute: 'data-id' }); | |
| 172 | + jQuery.post( | |
| 173 | + supportcandy.ajax_url, | |
| 174 | + { | |
| 175 | + action: 'wpsc_set_custom_field_load_order', | |
| 176 | + _ajax_nonce: '<?php echo esc_attr( wp_create_nonce( 'wpsc_set_custom_field_load_order' ) ); ?>', | |
| 177 | + ids: ids | |
| 178 | + }, | |
| 179 | + function(response) { | |
| 180 | + | |
| 181 | + } | |
| 182 | + ); | |
| 183 | + } | |
| 184 | + }); | |
| 140 | 185 | }); |
| 141 | 186 | </script> |
| 142 | 187 | </div> |
| 143 | 188 | <?php |