Beispiel #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" }';
        }
    }
Beispiel #2
0
    public function locations_from_to()
    {
        $this->lodad->model('security/locationsservicevalidation');
        $this->load->model('security/usersservicevalidation');
        $emailvalidation = new UsersServiceValidation();
        $validation_from_to = new LocationsServiceValidation();
        $data = $this->input->post();
        if ($validation_from_to->validate_get_locations($data) && $emailvalidation->validate_email($data)) {
            $this->load->model('management/locationsmanagement');
            $this->load->model('management/usermanagement');
            $Locationmanagement = new Locationsmanagement();
            $usermanagement = new Usermanagement();
            $user = $usermanagement->get_user($email);
            $locations = $Locationmanagement->get_locations_from_to($user->id, $data['from'], $data['to']);
            echo '{
			"success" : "true",';
            echo '"locations_from_to : "';
            echo json_decode($locations);
            echo '}';
        } else {
            echo '{ "success" : "false" } ';
        }
    }