| @@ -58,9 +58,11 @@ | ||
| 58 | 58 | public static function get_ticket_fields() { |
| 59 | 59 | |
| 60 | 60 | if ( ! WPSC_Functions::is_site_admin() ) { |
| 61 | 61 | wp_send_json_error( __( 'Unauthorized access!', 'supportcandy' ), 401 ); |
| 62 | - }?> | |
| 62 | + } | |
| 63 | + $custom_fields_types = array_merge( WPSC_Custom_Field::$cf_types, WPSC_Custom_Field::$default_cf_types ); | |
| 64 | + ?> | |
| 63 | 65 | |
| 64 | 66 | <div class="wpsc-setting-header"> |
| 65 | 67 | <h2><?php esc_attr_e( 'Ticket Fields', 'supportcandy' ); ?></h2> |
| 66 | 68 | </div> |
| @@ -77,10 +79,14 @@ | ||
| 77 | 79 | </div> |
| 78 | 80 | <table class="ticket-fields wpsc-setting-tbl"> |
| 79 | 81 | <thead> |
| 80 | 82 | <tr> |
| 83 | + <th style="width: 30px;"><?php esc_attr_e( 'Sort', 'supportcandy' ); ?></th> | |
| 81 | 84 | <th><?php esc_attr_e( 'Field', 'supportcandy' ); ?></th> |
| 82 | 85 | <th><?php esc_attr_e( 'Extra info', 'supportcandy' ); ?></th> |
| 86 | + <th><?php esc_attr_e( 'Type', 'supportcandy' ); ?></th> | |
| 87 | + <th><?php esc_attr_e( 'Auto Fill', 'supportcandy' ); ?></th> | |
| 88 | + <th><?php esc_attr_e( 'Personal Info', 'supportcandy' ); ?></th> | |
| 83 | 89 | <th><?php esc_attr_e( 'Actions', 'supportcandy' ); ?></th> |
| 84 | 90 | </tr> |
| 85 | 91 | </thead> |
| 86 | 92 | <tbody> |
| @@ -89,18 +95,22 @@ | ||
| 89 | 95 | if ( $cf->field != 'ticket' ) { |
| 90 | 96 | continue; |
| 91 | 97 | } |
| 92 | 98 | ?> |
| 93 | - <tr> | |
| 99 | + <tr data-id="<?php echo esc_attr( $cf->id ); ?>"> | |
| 100 | + <td class="sort-handle"><?php WPSC_Icons::get( 'sort' ); ?></td> | |
| 94 | 101 | <td><?php echo esc_attr( $cf->name ); ?></td> |
| 95 | 102 | <td><?php echo esc_attr( $cf->extra_info ); ?></td> |
| 103 | + <td><?php echo esc_attr( $custom_fields_types[ $cf->type::$slug ]['label'] ); ?></td> | |
| 104 | + <td><?php echo esc_attr( $cf->is_auto_fill ? __( 'Yes', 'supportcandy' ) : __( 'No', 'supportcandy' ) ); ?></td> | |
| 105 | + <td><?php echo esc_attr( $cf->is_personal_info ? __( 'Yes', 'supportcandy' ) : __( 'No', 'supportcandy' ) ); ?></td> | |
| 96 | 106 | <td> |
| 97 | - <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> | |
| 107 | + <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> | |
| 98 | 108 | <?php |
| 99 | 109 | if ( ! $cf->type::$is_default ) { |
| 100 | 110 | echo esc_attr( ' | ' ); |
| 101 | 111 | ?> |
| 102 | - <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> | |
| 112 | + <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> | |
| 103 | 113 | <?php |
| 104 | 114 | } |
| 105 | 115 | ?> |
| 106 | 116 | </td> |
| @@ -112,11 +122,13 @@ | ||
| 112 | 122 | </table> |
| 113 | 123 | <script> |
| 114 | 124 | jQuery('table.ticket-fields').DataTable({ |
| 115 | 125 | ordering: false, |
| 126 | + autoWidth: false, | |
| 116 | 127 | pageLength: 20, |
| 117 | 128 | bLengthChange: false, |
| 118 | - columnDefs: [ | |
| 129 | + columnDefs: [ | |
| 130 | + { targets: 0, width: '30px', searchable: false }, | |
| 119 | 131 | { targets: -1, searchable: false }, |
| 120 | 132 | { targets: '_all', className: 'dt-left' } |
| 121 | 133 | ], |
| 122 | 134 | layout: { |
| @@ -132,8 +144,37 @@ | ||
| 132 | 144 | ], |
| 133 | 145 | }, |
| 134 | 146 | }, |
| 135 | 147 | language: supportcandy.translations.datatables |
| 148 | + }); | |
| 149 | + | |
| 150 | + jQuery(function() { | |
| 151 | + // Enable sorting with jQuery UI. | |
| 152 | + jQuery('table.ticket-fields tbody').sortable({ | |
| 153 | + handle: '.sort-handle', | |
| 154 | + helper: function(e, tr) { | |
| 155 | + var $originals = tr.children(); | |
| 156 | + var $helper = tr.clone(); | |
| 157 | + $helper.children().each(function(index) { | |
| 158 | + jQuery(this).width($originals.eq(index).width()); | |
| 159 | + }); | |
| 160 | + return $helper; | |
| 161 | + }, | |
| 162 | + update: function(event, ui) { | |
| 163 | + var ids = jQuery(this).sortable('toArray', { attribute: 'data-id' }); | |
| 164 | + jQuery.post( | |
| 165 | + supportcandy.ajax_url, | |
| 166 | + { | |
| 167 | + action: 'wpsc_set_custom_field_load_order', | |
| 168 | + _ajax_nonce: '<?php echo esc_attr( wp_create_nonce( 'wpsc_set_custom_field_load_order' ) ); ?>', | |
| 169 | + ids: ids | |
| 170 | + }, | |
| 171 | + function(response) { | |
| 172 | + | |
| 173 | + } | |
| 174 | + ); | |
| 175 | + } | |
| 176 | + }); | |
| 136 | 177 | }); |
| 137 | 178 | </script> |
| 138 | 179 | </div> |
| 139 | 180 | <?php |