| 1 |
<?php |
| 2 |
|
| 3 |
namespace WeDevs\ERP\Accounting\Includes\Classes; |
| 4 |
|
| 5 |
class Ledger_Map { |
| 6 |
private static $instance = null; |
| 7 |
|
| 8 |
public $ledgers; |
| 9 |
|
| 10 |
private function __construct() { |
| 11 |
global $wpdb; |
| 12 |
|
| 13 |
$this->ledgers = $wpdb->get_results( "SELECT slug, id, chart_id, category_id, name, code FROM {$wpdb->prefix}erp_acct_ledgers", OBJECT_K ); |
| 14 |
} |
| 15 |
|
| 16 |
public static function get_instance() { |
| 17 |
if ( null === static::$instance ) { |
| 18 |
static::$instance = new Ledger_Map(); |
| 19 |
} |
| 20 |
|
| 21 |
return static::$instance; |
| 22 |
} |
| 23 |
|
| 24 |
public function get_ledger_id_by_slug( $slug ) { |
| 25 |
if ( ! empty( $this->ledgers[ $slug ] ) ) { |
| 26 |
return $this->ledgers[ $slug ]->id; |
| 27 |
} |
| 28 |
|
| 29 |
return false; |
| 30 |
} |
| 31 |
|
| 32 |
public function get_ledger_details_by_slug( $slug ) { |
| 33 |
if ( ! empty( $this->ledgers[ $slug ] ) ) { |
| 34 |
return $this->ledgers[ $slug ]; |
| 35 |
} |
| 36 |
|
| 37 |
return false; |
| 38 |
} |
| 39 |
} |
| 40 |
|