<?php
require_once("../api/class.restframework.php");
require_once("../api/class.saas.php");
session_start();
/////////////////////////////////////////
$restapi = new RestFrameWork();
// only allow get method
$restapi->allow("get");
$saas = new SaaS($restapi);
// $response = $saas->AuthToken("a0xNajFxWEZwWkR5RHY5a1FlZkZrN3JjYU55RXpCYzJTVnJxU2dYSkZtdz0");
//$restapi->IsTokenValid("WUNERU80RmFDWnU1OVJ6Rm00bURHOVp0S2RQLytBT2VmMG0xdHYrRGlwYz0=");
// $response = $saas->SeedDatabase("karibu_be_2oru1", 13, 12);
// $data = (object) [
//     'company' => (object) [
//         'id' => 1,
//         'company_no' => 570486,
//         'company_name' => 'Binarique Ltd',
//         'site_title' => 'Serena Hotel Ltd',
//         'db_name' => 'karibu_be_p34in',
//         'is_active' => 1,
//         'last_updated' => '2025-08-29 11:57:32',
//         'created' => '2025-08-29 11:57:32',
//     ],
//     'user' => (object) [
//         'id' => 1,
//         'company' => 1,
//         'user_no' => 684715,
//         'username' => 'walulyafrancis',
//         'first_name' => 'walulya',
//         'last_name' => 'francis',
//         'email' => 'walulyafrancis@gmail.com',
//         'password' => '25d55ad283aa400af464c76d713c07ad',
//         'verif_token' => 185187,
//         'is_verified' => 1,
//         'is_active' => 1,
//         'is_staff' => 1,
//         'is_super_user' => 1,
//         'last_login' => '2025-08-29 11:57:32',
//         'last_updated' => '2025-08-29 11:57:32',
//         'token' => (object) [
//             'id' => 1,
//             'user_id' => 1,
//             'token' => 'aFB0YU5Sa1BVcDdpZHBOVHNsL2dEaEpsekVaN3lWVWtJWWQwUHlFVkh0bz0=',
//             'token_generated' => '2025-08-29 08:57:32',
//             'expires' => 0,
//             'expiry_date' => '0000-00-00 00:00:00',
//             'is_active' => 1,
//             'created' => '2025-08-29 11:57:32',
//         ],
//     ],
// ];
// $info = array(
//     'country' => 'Uganda',
//     'first_name' => 'walulya',
//     'last_name' => 'francis',
//     'email' => 'walulyafrancis@gmail.com',
//     'username' => 'walulyafrancis',
//     'password' => '12345678',
//     'password2' => '12345678',
//     'company_name' => 'Binarique Ltd',
//     'site_title' => 'Serena Hotel Ltd',
//     'address' => '92b Ttula Rd, kawempe Ttula',
//     'postcode' => '110162',
//     'city' => 'Kampala',
//     'phone' => '0756743152',
//     'mobile' => '',
//     'create_company' => ''
// );

// $info = array(
//     'country' => 'Uganda',
//     'first_name' => 'walulya',
//     'last_name' => 'francis',
//     'email' => 'walulyafrancis@gmail.com',
//     'username' => 'walulyafrancis',
//     'password' => '12345678',
//     'password2' => '12345678',
//     'company_name' => 'Binarique Ltd',
//     'site_title' => 'Serena Hotel Ltd',
//     'address' => '92b Ttula Rd, kawempe Ttula',
//     'postcode' => '110162',
//     'city' => '',
//     'phone' => '',
//     'mobile' => '',
//     'create_company' => ''
// );
$info = array(
    'country' => '',
    'first_name' => 'binarique',
    'last_name' => 'binarique',
    'email' => '',
    'username' => 'binarique',
    'password' => '',
    'password2' => '',
    'company_name' => '',
    'site_title' => '',
    'address' => '',
    'postcode' => '',
    'city' => '',
    'phone' => '',
    'mobile' => '',
    'create_company' => ''
);
// print_r($data);
// $username = 'walulyafrancis';
// $password = '12345678';
// $response = $saas->loginUser('binarique', '12345678', 4);
// $saas->getUser(6);
// $mresponse = $saas->UpdateSaasUser($info, 345364, 1);
// $response = $saas->CreateUser($mresponse, $info);
// $saas->getAllCurrencies();
//$saas->CreateCompany(7);
//$saas->CreateDBDemo();
// $restapi->createToken(1, 1);
// echo $restapi->Response(array("message" => $saas->generateDBName(), "success" => true));
// // $response = $saas->CreateDatabase("karibu_booking_demo");
$company_id = isset($_SESSION['company']['id']) ? $_SESSION['company']['id'] : 0;
$response = $saas->Normallogin('binarique', "12345678", $company_id);
//$restapi->loginUser('binarique', "12345678", $company_id)
// $response = $restapi->authUpdate($info, 345364);
echo $restapi->Response($response);
