Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 45 |
|
0.00% |
0 / 1 |
CRAP | n/a |
0 / 0 |
|
| zeroBS_dashboard_crm_list_growth | |
0.00% |
0 / 43 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | /* |
| 3 | * Jetpack CRM |
| 4 | * https://jetpackcrm.com |
| 5 | * V1.20 |
| 6 | * |
| 7 | * Copyright 2020 Automattic |
| 8 | * |
| 9 | * Date: 01/11/16 |
| 10 | */ |
| 11 | |
| 12 | defined( 'ZEROBSCRM_PATH' ) || exit( 0 ); |
| 13 | |
| 14 | /* |
| 15 | Add code in here for the dashboard boxes. Keeps it a bit tidier than ALL in the AdminPages.php file |
| 16 | |
| 17 | action hooks to use: |
| 18 | zbs_dashboard_pre_dashbox_post_totals: shows up on the first row AFTER the total boxes |
| 19 | zbs_dashboard_customiser_after_row_1: lets you add a on / off control (if desired after tht total boxes checkbox controls) |
| 20 | */ |
| 21 | |
| 22 | // example code to add a new box below the totals, but above the funnels. This one is NOT turn off-able (is off-able a word, lol). |
| 23 | add_action( 'zbs_dashboard_pre_dashbox_post_totals', 'zeroBS_dashboard_crm_list_growth', 1 ); |
| 24 | function zeroBS_dashboard_crm_list_growth() { |
| 25 | |
| 26 | global $zbs; |
| 27 | $contacts_added_in_last_year = (int) $zbs->DAL->contacts->getContacts( // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
| 28 | array( |
| 29 | 'newerThan' => strtotime( '-1 year', time() ), |
| 30 | 'count' => true, |
| 31 | ) |
| 32 | ); |
| 33 | ?> |
| 34 | <div class="jpcrm-dashcard" style="margin: 10px; padding: 10px;"> |
| 35 | <div class="jpcrm-dashcard-header"> |
| 36 | <h4><?php esc_html_e( 'CRM contacts', 'zero-bs-crm' ); ?></h4> |
| 37 | <?php |
| 38 | if ( $contacts_added_in_last_year !== 0 ) { |
| 39 | ?> |
| 40 | <div id="zbs-date-picker-background"> |
| 41 | <div class='month-selector'> |
| 42 | <div id="reportrange" class="jpcrm-date-range" style="cursor: pointer; width:240px; text-align: right;"> |
| 43 | <i class="fa fa-calendar"></i> |
| 44 | <span></span> <b class="caret"></b> |
| 45 | </div> |
| 46 | </div> |
| 47 | </div> |
| 48 | <div class="day-or-month"> |
| 49 | <div class="ui button small white" data-range="daily"><?php esc_html_e( 'Day', 'zero-bs-crm' ); ?></div> |
| 50 | <div class="ui button small white" data-range="weekly"><?php esc_html_e( 'Week', 'zero-bs-crm' ); ?></div> |
| 51 | <div class="ui button small black" data-range="monthly"><?php esc_html_e( 'Month', 'zero-bs-crm' ); ?></div> |
| 52 | <div class="ui button small white" data-range="yearly"><?php esc_html_e( 'Year', 'zero-bs-crm' ); ?></div> |
| 53 | </div> |
| 54 | <?php |
| 55 | } |
| 56 | ?> |
| 57 | </div> |
| 58 | <div class="jpcrm-listview-table-container"> |
| 59 | <?php |
| 60 | if ( $contacts_added_in_last_year !== 0 ) { |
| 61 | // Chart requires an empty div or else the height grows indefinitely |
| 62 | ?> |
| 63 | <div> |
| 64 | <canvas id="growth-chart" height="400"></canvas> |
| 65 | </div> |
| 66 | <?php |
| 67 | } else { |
| 68 | ?> |
| 69 | <div class="jpcrm-div-message-box"> |
| 70 | <div class="jpcrm-div-message"> |
| 71 | <?php esc_html_e( 'No contacts were added during the last 12 months. You need contacts for your growth chart to show.', 'zero-bs-crm' ); ?> |
| 72 | </div> |
| 73 | <div class="jpcrm-div-message"> |
| 74 | <?php ##WLREMOVE ?> |
| 75 | <a href="<?php echo esc_url( $zbs->urls['kbfirstcontact'] ); ?>" target="_blank" class="jpcrm-button white-bg"><?php echo esc_html__( 'Read guide', 'zero-bs-crm' ); ?></a> |
| 76 | <?php ##/WLREMOVE ?> |
| 77 | <a href="<?php echo jpcrm_esc_link( 'create', -1, 'zerobs_customer', false, false ); /* phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped */ ?>" class="jpcrm-button"><?php esc_html_e( 'Add a contact', 'zero-bs-crm' ); ?></a> |
| 78 | </div> |
| 79 | </div> |
| 80 | <?php |
| 81 | } |
| 82 | ?> |
| 83 | </div> |
| 84 | </div> |
| 85 | <?php |
| 86 | } |