| 1 |
<?php |
| 2 |
namespace WeDevs\ERP\HRM; |
| 3 |
|
| 4 |
/** |
| 5 |
* The designation class |
| 6 |
*/ |
| 7 |
class Designation extends \WeDevs\ERP\Item { |
| 8 |
|
| 9 |
/** |
| 10 |
* Get a company by ID |
| 11 |
* |
| 12 |
* @param int company id |
| 13 |
* |
| 14 |
* @return object wpdb object |
| 15 |
*/ |
| 16 |
protected function get_by_id( $designation_id ) { |
| 17 |
global $wpdb; |
| 18 |
|
| 19 |
return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}erp_hr_designations WHERE id = %d", $designation_id ) ); |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Get number of employee belongs to this department |
| 24 |
* |
| 25 |
* @return int |
| 26 |
*/ |
| 27 |
public function num_of_employees() { |
| 28 |
return \WeDevs\ERP\HRM\Models\Employee::where( array( 'status' => 'active', 'designation' => $this->id ) )->count(); |
| 29 |
} |
| 30 |
} |