| @@ -8,8 +8,13 @@ | ||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | namespace MainWP\Dashboard; |
| 11 | 11 | |
| 12 | +// Exit if accessed directly. | |
| 13 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 14 | + exit; | |
| 15 | +} | |
| 16 | + | |
| 12 | 17 | /** |
| 13 | 18 | * Class MainWP_Clients |
| 14 | 19 | * |
| 15 | 20 | * Displays the Site Actions. |
| @@ -42,9 +47,9 @@ | ||
| 42 | 47 | */ |
| 43 | 48 | private static function render_clients( $clients ) { // phpcs:ignore -- NOSONAR - complex. |
| 44 | 49 | ?> |
| 45 | 50 | <div class="mainwp-widget-header"> |
| 46 | - <h3 class="ui header handle-drag"> | |
| 51 | + <h2 class="ui header handle-drag"> | |
| 47 | 52 | <?php |
| 48 | 53 | /** |
| 49 | 54 | * Filter: mainwp_clients_widget_title |
| 50 | 55 | * |
| @@ -53,10 +58,10 @@ | ||
| 53 | 58 | * @since 4.4 |
| 54 | 59 | */ |
| 55 | 60 | echo esc_html( apply_filters( 'mainwp_clients_widget_title', esc_html__( 'Clients', 'mainwp' ) ) ); |
| 56 | 61 | ?> |
| 57 | - <div class="sub header"><?php esc_html_e( 'Clients information', 'mainwp' ); ?></div> | |
| 58 | - </h3> | |
| 62 | + <div class="sub header"><?php esc_html_e( 'View and manage all clients connected to your MainWP Dashboard.', 'mainwp' ); ?></div> | |
| 63 | + </h2> | |
| 59 | 64 | </div> |
| 60 | 65 | <div id="mainwp-clients-widget" class="mainwp-scrolly-overflow"> |
| 61 | 66 | <?php |
| 62 | 67 | /** |
| @@ -73,12 +78,11 @@ | ||
| 73 | 78 | <?php if ( $clients ) : ?> |
| 74 | 79 | <table class="ui table" id="mainwp-clients-widget-table"> |
| 75 | 80 | <thead> |
| 76 | 81 | <tr> |
| 77 | - <th scope="col" class="no-sort"></th> | |
| 78 | 82 | <th scope="col"><?php esc_html_e( 'Client', 'mainwp' ); ?></th> |
| 79 | - <th scope="col"><?php esc_html_e( 'Primary Contact', 'mainwp' ); ?></th> | |
| 80 | - <th scope="col" class="no-sort"></th> | |
| 83 | + <th scope="col" class="collapsing"><?php esc_html_e( 'Primary Contact', 'mainwp' ); ?></th> | |
| 84 | + <th scope="col" class="no-sort collapsing"></th> | |
| 81 | 85 | </tr> |
| 82 | 86 | </thead> |
| 83 | 87 | <tbody> |
| 84 | 88 | <?php foreach ( $clients as $client ) : ?> |
| @@ -85,21 +89,19 @@ | ||
| 85 | 89 | <?php $client_display_image = MainWP_Client_Handler::get_client_contact_image( $client ); ?> |
| 86 | 90 | <tr> |
| 87 | 91 | <td class="left aligned middle aligned"> |
| 88 | 92 | <a href="admin.php?page=ManageClients&client_id=<?php echo intval( $client['client_id'] ); ?>"> |
| 89 | - <?php echo $client_display_image; //phpcs:ignore -- ok. ?> | |
| 93 | + <?php echo $client_display_image; //phpcs:ignore -- ok. ?> <?php echo esc_html( $client['name'] ); ?> | |
| 90 | 94 | </a> |
| 95 | + <br/> | |
| 96 | + <?php if ( isset( $client['client_email'] ) && '' !== $client['client_email'] ) : ?> | |
| 97 | + <span class="ui small text"><a href="mailto:<?php echo esc_attr( $client['client_email'] ); ?>" class="ui grey text"><i class="envelope grey icon"></i> <?php echo esc_html( $client['client_email'] ); ?></a></span><br/> | |
| 98 | + <?php endif; ?> | |
| 99 | + <?php if ( isset( $client['client_phone'] ) && '' !== $client['client_phone'] ) : ?> | |
| 100 | + <span class="ui small text"><a href="tel:<?php echo esc_attr( $client['client_phone'] ); ?>" class="ui grey text"><i class="phone alternate grey icon"></i> <?php echo esc_html( $client['client_phone'] ); ?></a></span> | |
| 101 | + <?php endif; ?> | |
| 91 | 102 | </td> |
| 92 | 103 | <td class="left aligned middle aligned"> |
| 93 | - <span><a href="admin.php?page=ManageClients&client_id=<?php echo intval( $client['client_id'] ); ?>"><?php echo esc_html( $client['name'] ); ?></a></span><br/> | |
| 94 | - <?php if ( isset( $client['client_email'] ) && '' !== $client['client_email'] ) : ?> | |
| 95 | - <span class="ui small text"><a href="mailto:<?php echo esc_attr( $client['client_email'] ); ?>"><i class="envelope icon"></i> <?php echo esc_html( $client['client_email'] ); ?></a></span><br/> | |
| 96 | - <?php endif; ?> | |
| 97 | - <?php if ( isset( $client['client_phone'] ) && '' !== $client['client_phone'] ) : ?> | |
| 98 | - <span class="ui small text"><a href="tel:<?php echo esc_attr( $client['client_phone'] ); ?>"><i class="phone alternate icon"></i> <?php echo esc_html( $client['client_phone'] ); ?></a></span> | |
| 99 | - <?php endif; ?> | |
| 100 | - </td> | |
| 101 | - <td class="left aligned middle aligned"> | |
| 102 | 104 | <?php |
| 103 | 105 | $contact = false; |
| 104 | 106 | if ( isset( $client['primary_contact_id'] ) && '' !== $client['primary_contact_id'] ) { |
| 105 | 107 | $contact = MainWP_DB_Client::instance()->get_wp_client_contact_by( 'contact_id', $client['primary_contact_id'] ); |
| @@ -104,15 +106,15 @@ | ||
| 104 | 106 | if ( isset( $client['primary_contact_id'] ) && '' !== $client['primary_contact_id'] ) { |
| 105 | 107 | $contact = MainWP_DB_Client::instance()->get_wp_client_contact_by( 'contact_id', $client['primary_contact_id'] ); |
| 106 | 108 | if ( $contact ) { |
| 107 | 109 | ?> |
| 108 | - <span><?php echo esc_html( $contact->contact_name ); ?> <?php echo ( isset( $contact->contact_role ) && '' !== $contact->contact_role ) ? ' - ' . esc_html( $contact->contact_role ) : ''; ?></span><br/> | |
| 110 | + <?php echo esc_html( $contact->contact_name ); ?> <?php echo ( isset( $contact->contact_role ) && '' !== $contact->contact_role ) ? ' - ' . esc_html( $contact->contact_role ) : ''; ?><br/> | |
| 109 | 111 | <?php if ( isset( $contact->contact_email ) && '' !== $contact->contact_email ) : ?> |
| 110 | - <span class="ui small text"><a href="mailto:<?php echo esc_attr( $contact->contact_email ); ?>"><i class="envelope icon"></i> <?php echo esc_html( $contact->contact_email ); ?></a></span><br/> | |
| 111 | - <?php endif; ?> | |
| 112 | + <span class="ui small text"><a href="mailto:<?php echo esc_attr( $contact->contact_email ); ?>" class="ui grey text"><i class="envelope grey icon"></i> <?php echo esc_html( $contact->contact_email ); ?></a></span><br/> | |
| 113 | + <?php endif; ?> | |
| 112 | 114 | <?php if ( isset( $contact->contact_phone ) && '' !== $contact->contact_phone ) : ?> |
| 113 | - <span class="ui small text"><a href="tel:<?php echo esc_attr( $contact->contact_phone ); ?>"><i class="phone alternate icon"></i> <?php echo esc_html( $contact->contact_phone ); ?></a></span> | |
| 114 | - <?php endif; ?> | |
| 115 | + <span class="ui small text"><a href="tel:<?php echo esc_attr( $contact->contact_phone ); ?>" class="ui grey text"><i class="phone alternate grey icon"></i> <?php echo esc_html( $contact->contact_phone ); ?></a></span> | |
| 116 | + <?php endif; ?> | |
| 115 | 117 | <?php |
| 116 | 118 | } |
| 117 | 119 | } |
| 118 | 120 | if ( empty( $contact ) ) { |
| @@ -119,11 +121,11 @@ | ||
| 119 | 121 | echo esc_html__( 'No Contacts', 'mainwp' ); |
| 120 | 122 | } |
| 121 | 123 | ?> |
| 122 | 124 | </td> |
| 123 | - <td> | |
| 124 | - <div class="ui right pointing dropdown icon mini basic green button mainwp-768-hide" style="z-index:999"> | |
| 125 | - <i class="ellipsis horizontal icon"></i> | |
| 125 | + <td class="right aligned collapsing"> | |
| 126 | + <div class="ui right pointing dropdown mainwp-768-hide" style="z-index:999"> | |
| 127 | + <i class="ellipsis vertical icon"></i> | |
| 126 | 128 | <div class="menu"> |
| 127 | 129 | <a class="item" href="admin.php?page=ManageClients&client_id=<?php echo intval( $client['client_id'] ); ?>"><?php esc_html_e( 'View', 'mainwp' ); ?></a> |
| 128 | 130 | <a class="item" href="admin.php?page=ClientAddNew&client_id=<?php echo intval( $client['client_id'] ); ?>"><?php esc_html_e( 'Edit', 'mainwp' ); ?></a> |
| 129 | 131 | </div> |
| @@ -132,20 +134,19 @@ | ||
| 132 | 134 | </tr> |
| 133 | 135 | <?php endforeach; ?> |
| 134 | 136 | </tbody> |
| 135 | 137 | </table> |
| 136 | - <div class="ui two columns stackable grid mainwp-widget-footer"> | |
| 137 | - <div class="left aligned column"> | |
| 138 | - <a href="admin.php?page=ManageClients" class="ui button mini fluid green"><?php esc_html_e( 'Clients', 'mainwp' ); ?></a> | |
| 139 | - </div> | |
| 140 | - <div class="right aligned column"> | |
| 141 | - <a href="admin.php?page=ClientAddNew" class="ui button basic mini fluid green"><?php esc_html_e( 'New Client', 'mainwp' ); ?></a> | |
| 142 | - </div> | |
| 143 | - </div> | |
| 138 | + | |
| 144 | 139 | <script type="text/javascript"> |
| 145 | 140 | jQuery( document ).ready( function() { |
| 146 | 141 | jQuery.fn.DataTable.ext.pager.numbers_length = 4; |
| 147 | 142 | jQuery( '#mainwp-clients-widget-table' ).DataTable( { |
| 143 | + "info": false, | |
| 144 | + "layout": { | |
| 145 | + "bottom": 'paging', | |
| 146 | + "bottomStart": null, | |
| 147 | + "bottomEnd": null | |
| 148 | + }, | |
| 148 | 149 | "lengthMenu": [ [5, 10, 25, 50, 100, -1], [5, 10, 25, 50, 100, "All"] ], |
| 149 | 150 | "stateSave" : true, |
| 150 | 151 | "order" : [ [1, 'asc'] ], |
| 151 | 152 | "columnDefs": [ { |
| @@ -152,12 +153,15 @@ | ||
| 152 | 153 | "targets": 'no-sort', |
| 153 | 154 | "orderable": false |
| 154 | 155 | } ], |
| 155 | 156 | } ); |
| 157 | + setTimeout(() => { | |
| 158 | + mainwp_datatable_fix_menu_overflow('#mainwp-clients-widget-table', -50, 0 ); | |
| 159 | + }, 2000 ); | |
| 156 | 160 | } ); |
| 157 | 161 | </script> |
| 158 | 162 | <?php else : ?> |
| 159 | - <?php MainWP_UI::render_empty_element_placeholder(); ?> | |
| 163 | + <?php MainWP_UI::render_empty_element_placeholder( __( 'No Clients yet', 'mainwp' ), __( 'Create your first client to see them listed here.', 'mainwp' ), '<em data-emoji=":bust_in_silhouette:" class="medium"></em>' ); ?> | |
| 160 | 164 | <?php endif; ?> |
| 161 | 165 | <?php |
| 162 | 166 | /** |
| 163 | 167 | * Action: mainwp_clients_widget_bottom |
| @@ -170,7 +174,15 @@ | ||
| 170 | 174 | */ |
| 171 | 175 | do_action( 'mainwp_clients_widget_bottom', $clients ); |
| 172 | 176 | ?> |
| 173 | 177 | </div> |
| 174 | - <?php | |
| 178 | + <div class="ui two columns stackable grid mainwp-widget-footer"> | |
| 179 | + <div class="left aligned middle aligned column"> | |
| 180 | + | |
| 181 | + </div> | |
| 182 | + <div class="right aligned middle aligned column"> | |
| 183 | + | |
| 184 | + </div> | |
| 185 | + </div> | |
| 186 | + <?php | |
| 175 | 187 | } |
| 176 | 188 | } |