2013-04-14 22:42:40 +03:00
|
|
|
<?php
|
2013-04-20 20:20:16 +03:00
|
|
|
class Providers_Model extends CI_Model {
|
2013-04-17 00:37:36 +03:00
|
|
|
public function __construct() {
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This method returns the available providers and
|
|
|
|
* the services that can provide.
|
|
|
|
*
|
|
|
|
* @return array Returns an array with the providers
|
|
|
|
* data.
|
|
|
|
*/
|
|
|
|
public function getAvailableProviders() {
|
2013-04-20 20:20:16 +03:00
|
|
|
$this->db
|
|
|
|
->select('ea_users.*')
|
|
|
|
->from('ea_users')
|
|
|
|
->join('ea_roles', 'ea_roles.id = ea_users.id_roles', 'inner')
|
|
|
|
->where('ea_roles.slug', 'provider');
|
2013-04-17 00:37:36 +03:00
|
|
|
|
2013-04-20 20:20:16 +03:00
|
|
|
$providers = $this->db->get()->result_array();
|
2013-04-17 00:37:36 +03:00
|
|
|
|
|
|
|
foreach($providers as &$provider) {
|
2013-04-20 20:20:16 +03:00
|
|
|
$this->db
|
|
|
|
->select('id_services')
|
|
|
|
->from('ea_services_providers')
|
|
|
|
->where('id_users', $provider['id']);
|
2013-04-17 00:37:36 +03:00
|
|
|
|
2013-04-20 20:20:16 +03:00
|
|
|
$providerServices = $this->db->get()->result_array();
|
2013-04-17 00:37:36 +03:00
|
|
|
|
|
|
|
if (!isset($provider['services'])) {
|
|
|
|
$provider['services'] = array();
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach($providerServices as $providerService) {
|
|
|
|
$provider['services'][] = $providerService['id_services'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $providers;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|