Пример #1
0
    public function login()
    {
        $this->load->model('security/Usersservicevalidation');
        $validation = new UsersServiceValidation();
        $data = $this->input->post();
        if ($validation->validate_login($data)) {
            $this->load->model('management/usersmanagement');
            $this->load->model('entities/user');
            $this->load->model('entities/company');
            $this->load->model('entities/agence');
            $management = new usersmanagement();
            $user = new User();
            $user->user_email = $data['email'];
            $user->user_password = $data['password'];
            if ($management->login($user)) {
                $this->load->model('management/locationsmanagement');
                $this->load->model('management/countmanagement');
                $locations_management = new LocationsManagement();
                $count = new Countmanagement();
                $user = $management->get_user($user->user_email);
                $company = $management->get_user_company($user->id);
                $agence = $management->get_user_agence($user->id);
                $locations = $locations_management->get_company_locations($company->id, 0, 4);
                echo '{ 			
							"success" : "true",
							"statistics" : 
							 {' . '"clients_count" : "' . $count->count_client() . '",' . '"locations_count" : "' . $count->count_location() . '",' . '"cars_count" : "' . $count->count_car() . '",' . '"location_ongoing_count" : "' . $count->count_location_ongoing() . '",' . '},
							"company" : 
							 {' . '"id" : "' . $company->id . '",' . '"company_logo" : "' . $company->company_logo . '",' . '"company_name" : "' . $company->company_name . '",' . '"company_description" : "' . $company->company_description . '",' . '"company_createdAt" : "' . $company->company_createdAt . '",' . '"company_updatedAt" : "' . $company->company_updatedAt . '",' . '"subscription_id" : "' . $company->subscription_id . '",' . '},
							"agence" : 
							 {' . '"id" : "' . $agence->id . '",' . '"agence_name" : "' . $agence->agence_name . '",' . '"agence_adress" : "' . $agence->agence_adress . '",' . '"agence_city" : "' . $agence->agence_city . '",' . '"company_id" : "' . $agence->company_id . '",' . '"agence_createdAt" : "' . $agence->agence_createdAt . '",' . '"agence_updatedAt" : "' . $agence->agence_updatedAt . '",' . '},
							"user" : 
							 {' . '"id" : "' . $user->id . '",' . '"user_email" : "' . $user->user_email . '",' . '"user_first_name" : "' . $user->user_first_name . '",' . '"user_last_name" : "' . $user->user_last_name . '",' . '"user_role" : "' . $user->user_role . '",' . '"user_birth_date" : "' . $user->user_birth_date . '",' . '"user_avatar" : "' . $user->user_avatar . '",' . '"agence_id" : "' . $user->agence_id . '",' . '"user_createdAt" : "' . $user->user_createdAt . '",' . '"user_updatedAt" : "' . $user->user_updatedAt . '",' . '},
							"locations" : 
							 ';
                echo json_encode($locations);
                echo ',
					}';
            } else {
                echo '{ "success" : "false" }';
            }
        } else {
            echo '{ "success" : "false" }';
        }
    }
Пример #2
0
 public function index()
 {
     $this->load->model('management/LocationsManagement');
     $management = new LocationsManagement();
     $user = $management->get_company_locations(1, 0, 5);
     echo '<pre>' . var_export($user, true) . '</pre>';
     /*$user = new User();
     		$user->user_email='*****@*****.**';
     		$user->user_password='******';
     		if($management->login($user))
     			echo 'yohoo';
     		else
     			{
     				$this->load->model('management/ContratManagement');
     				$mng= new ContratManagement();
     				$msg = $mng->get_contrat(1);
     				var_dump($msg);
     			}*/
 }