<?php
include_once __DIR__. '/helpers/admin-common.php';
require_once __DIR__. '/helpers/SessionManagementService.php';
require_once __DIR__. '/helpers/UserService.php';
require_once __DIR__. '/models/UserModel.php';
require_once __DIR__. '/../common.php';
require_once __DIR__. '/../my-optician-wsdl-service/MyOpticianWsdlService.php';
require_once __DIR__. '/../my-optician-wsdl-service/GlobalLoader.php';

global $service_url, $optician_id, $shops, $opticianService, $siteInfo, $siteId, $current_step, $isstepped_process;
$current_step = 1;
$isstepped_process = false;
$session_management_service = new SessionManagementService();
if(!isset($_SESSION['usermodel'])){
	include_once( __DIR__. '/../error.php');
	die;
}

$userModel = $session_management_service->getUserModel();
$siteInfo = $userModel->getSiteInfo();
$opticianService = new MyOpticianWsdlService($service_url, null);

$siteId = $siteInfo->getSite();
$password = $siteInfo->getPassword();

$shops = $opticianService->getShops($siteId, $password, $siteInfo);

if(count($shops) > 1){
    require_once __DIR__ . "/optician-panel-select-shop.php";
} else {
    $_GET['Shop'] = $shops[0]->getName();
    require_once __DIR__ . "/optician-panel-calendar.php";
}
?>