| 1 |
<?php |
| 2 |
namespace WeDevs\ERP; |
| 3 |
|
| 4 |
/** |
| 5 |
* Tracker class |
| 6 |
*/ |
| 7 |
class Tracker extends \WeDevs_Insights { |
| 8 |
|
| 9 |
public function __construct() { |
| 10 |
|
| 11 |
$notice = __( 'Want to help make <strong>WP ERP</strong> even more awesome? Allow weDevs to collect non-sensitive diagnostic data and usage information.', 'erp' ); |
| 12 |
|
| 13 |
parent::__construct( 'erp', 'WP ERP', WPERP_FILE, $notice ); |
| 14 |
} |
| 15 |
|
| 16 |
/** |
| 17 |
* Get the extra data |
| 18 |
* |
| 19 |
* @return array |
| 20 |
*/ |
| 21 |
protected function get_extra_data() { |
| 22 |
$data = array( |
| 23 |
'active_modules' => get_option( 'erp_modules', [] ), |
| 24 |
'contacts' => $this->get_people_count( 'contact' ), |
| 25 |
'customer' => $this->get_people_count( 'customer' ), |
| 26 |
'vendor' => $this->get_people_count( 'vendor' ), |
| 27 |
'sales' => $this->transaction_type_count( 'sales' ), |
| 28 |
'expense' => $this->transaction_type_count( 'expense' ), |
| 29 |
); |
| 30 |
|
| 31 |
return $data; |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Get people type count |
| 36 |
* |
| 37 |
* @param string $type |
| 38 |
* |
| 39 |
* @return integer |
| 40 |
*/ |
| 41 |
private function get_people_count( $type ) { |
| 42 |
return \WeDevs\ERP\Framework\Models\People::type( $type )->count(); |
| 43 |
} |
| 44 |
|
| 45 |
private function transaction_type_count( $type ) { |
| 46 |
if ( ! class_exists( '\WeDevs\ERP\Accounting\Model\Transaction' ) ) { |
| 47 |
require_once WPERP_MODULES . '/accounting/includes/models/transaction.php'; |
| 48 |
} |
| 49 |
|
| 50 |
return \WeDevs\ERP\Accounting\Model\Transaction::type( $type )->count(); |
| 51 |
} |
| 52 |
} |
| 53 |
|