<?php

require_once __DIR__. '/../../my-optician-wsdl-service/MyOpticianWsdlService.php';
require_once __DIR__. '/../../my-optician-wsdl-service/GlobalLoader.php';
require_once __DIR__. '/../models/UserModel.php';

class UserService {

    public function __construct( ) {

    }

    public function validateLogin($username, $password) {
        global $service_url, $optician_id, $shops, $opticianService, $siteInfo, $siteId, $practitioners, $slots;
        if(!isset($opticianService)){
            $opticianService = new MyOpticianWsdlService($service_url, $optician_id);
        }
        $siteInfo = $opticianService->getSiteInfoByLogin($username, $password);
        $siteId = $siteInfo->getSite();
        $password = $siteInfo->getPassword();
        if($siteInfo != null && !empty($siteInfo->getSite()) ){
            $userModel = new UserModel($username, $password);
            $userModel->setSiteInfo($siteInfo);
            return $userModel;
        } else {
            return null;
        }
    }
}
?>
