#!/usr/bin/perl
#
## SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
#
use lib "/var/www/copri-bike/shareeapp-primary/src";
use strict;
use warnings;
use POSIX;
use CGI ':standard';
use CGI::Carp qw(fatalsToBrowser);
use CGI::Cookie ();
use DBI;
use Lib::Config;
use Mod::DBtank;

my $q  = new CGI();
$q->import_names('R');
my $cf = new Config;
my $dbt = new DBtank;
my %varenv = $cf->envonline();

 my $coo = $q->cookie('domcookie') || $q->param('sessionid') || "";

 if($q->param('sessionid')  && $q->param('sessionid') ne $q->cookie('domcookie')){
        $coo = $q->param('sessionid');
        my $cookie = CGI::Cookie->new(-name  => 'domcookie',-value => $coo);
        print $q->header(-charset=>"utf-8", -cookie=>$cookie);
 }else{
        my $cookie = CGI::Cookie->new(-name  => 'domcookie',-value => $coo);
        print $q->header(-charset=>"utf-8", -cookie=>$cookie);
 }
 die "no configuration available" if(!$varenv{wwwhost});

  my $api_return = { authcookie => "$coo" };
  my $operator_key = $q->param('api_test');
  my $user_test = $q->param('user_test');
  my $bike = $q->param('bike');
  my $man_gps = $q->escapeHTML($R::man_gps) || "";
  #$bike = "FR4781";
  #$bike = "FR1002";

 my $lang = "de";
 my $dyn_js = "";

 #onLoad (testing) to get geo disabled because printing loaction accessor will be to late
 if(1==2){
 $dyn_js = " 
 function onLoad() {
   console.log('hallo');
   const status = document.querySelector('#status');
   const mapLink = document.querySelector('#map-link'); 
   mapLink.href = '';
   mapLink.textContent = '';

   function success(position) {
    	  const latitude = position.coords.latitude;
    	  const longitude = position.coords.longitude;
	console.log(latitude + ',' + longitude);
    	  status.textContent = '';
    	  mapLink.href = 'https://www.openstreetmap.org/#map=18/\${latitude}/\${longitude}';
    	  mapLink.textContent = 'Latitude: \${latitude} °, Longitude: \${longitude} °';
  }

  function error() {
    	  status.textContent = 'Unable to retrieve your location';
  }

   if ('geolocation' in navigator) {
 	console.log('geon');
	status.textContent = 'Locating…';
        navigator.geolocation.getCurrentPosition(success, error);

 	/* geolocation funktioniert */

    } else {
 	 console.log('geoff');
 	 /* geolocation funktioniert NICHT */
    }
 }
  \n";
 }

 my $dyn_css = "";
 my $local_style = "$varenv{metahost}/$dbt->{shareeapp_conf}->{local_style}";
 my $jquery = "$varenv{metahost}/$dbt->{shareeapp_conf}->{jquery}";
 my $js_bootstrap = "$varenv{metahost}/$dbt->{shareeapp_conf}->{js_bootstrap}";
 my $style_bootstrap = "$varenv{metahost}/$dbt->{shareeapp_conf}->{style_bootstrap}";
 if($varenv{wwwhost} =~ /shareedms/){
    $local_style = "$varenv{metahost}/$dbt->{shareedms_conf}->{local_style}";
    $jquery = "$varenv{metahost}/$dbt->{shareedms_conf}->{jquery}";
    $js_bootstrap = "$varenv{metahost}/$dbt->{shareedms_conf}->{js_bootstrap}";
    $style_bootstrap = "$varenv{metahost}/$dbt->{shareedms_conf}->{style_bootstrap}";
 }


 my $html5 = $q->start_html(
    -title    => "shareetest",
    -lang     => '',
    #-onload   => "onLoad();",
    -encoding => "utf-8",
    -base     => 'true',
    -head     => Link(
        {
            -rel  => 'shortcut icon',
            -type => 'image/x-icon',
            -href => "/css/favicon.ico"
        }
    ),
    -meta => {
	'viewport'=>"width=device-width,initial-scale=1,user-scalable=yes",
        'author'    => "rainer guempelein",
        'publisher' => "",
        'copyright' => "",
    },
                        -script=>[
                                {-language=>'JAVASCRIPT',
                                -code=>"$dyn_js"}
                                ],
                        -STYLE=>{
                                -code=>"$dyn_css",
                                -verbatim=>"\@import url(\"$local_style\");",
                                -media=>'screen'
                                }

);

 $html5 =~ s{<!DOCTYPE.*?>}{<!DOCTYPE html>}s;
 $html5 =~ s{<html.*?>}{<html lang='de'>}s;
 print $html5;
 print "<div style='text-align:left;'>\n";
##

my $initMap = $dbt->{website}->{$varenv{syshost}}->{initMap};
my $map_zoom = $dbt->{website}->{$varenv{syshost}}->{map_zoom} || "10";
my $project = "all";
my $uri_request = $dbt->{primary}->{sharee_primary}->{primaryApp};
my $uri = "$uri_request/APIjsonserver";

  if($dbt->{website}->{$varenv{syshost}}->{merchant_id}){
   $api_return->{authcookie} = $dbt->{website}->{$varenv{syshost}}->{merchant_id} if(!$api_return->{authcookie});
   $project = $dbt->{website}->{$varenv{syshost}}->{project} if($dbt->{website}->{$varenv{syshost}}->{project});
   $uri_request = $dbt->{website}->{$varenv{syshost}}->{operatorWeb};
   print $q->div({-class=>"content2_contact"},"Hier können Lastenfahrräder gemietet werden:"),"\n";
  }elsif($dbt->{operator}->{$varenv{dbname}}->{merchant_id}){
   $api_return->{authcookie} = $dbt->{operator}->{$varenv{dbname}}->{merchant_id} if(!$api_return->{authcookie});
   $initMap = $dbt->{operator}->{$varenv{dbname}}->{initMap} if($dbt->{operator}->{$varenv{dbname}}->{initMap});
   $map_zoom = $dbt->{operator}->{$varenv{dbname}}->{map_zoom} if($dbt->{operator}->{$varenv{dbname}}->{map_zoom});
   $project = $dbt->{operator}->{$varenv{dbname}}->{project} if($dbt->{operator}->{$varenv{dbname}}->{project});
   $uri_request = $dbt->{operator}->{$varenv{dbname}}->{operatorApp};
   print $q->div({-style=>'padding-top:25px;'},""),"\n";
  }elsif($dbt->{primary}->{$varenv{dbname}}->{merchant_id}){
   $api_return->{authcookie} = $dbt->{primary}->{$varenv{dbname}}->{merchant_id} if(!$api_return->{authcookie});
   $initMap = $dbt->{primary}->{$varenv{dbname}}->{initMap} if($dbt->{primary}->{$varenv{dbname}}->{initMap});
   $uri_request = $dbt->{primary}->{$varenv{dbname}}->{primaryApp};
   print $q->div({-style=>'padding-top:25px;'},""),"\n";
  }

  my $icon_green = "Open_Green.png";
  my $icon_red = "Open_Red.png";
  my $icon_blue = "Open_Blue.png";
  my $mapheight = "800px;";
  if($project eq "Bayern"){
   $icon_green = "LastenradBay_Standortpfeil_gruen_03a.png";
   $icon_red = "LastenradBay_Standortpfeil_rot_03a.png";
   $icon_blue = "LastenradBay_Standortpfeil_blau_03a.png";
   $mapheight = "800px;" if($varenv{syshost} !~ /shareedms-/);
  }
 $initMap =~ s/\s//g;
 my ($lat,$lng) = split(/,/,$initMap);


#print $q->div({-style=>'margin:15px;'},$q->a({-href=>"/src/scripts/tests/index.pl"},"[ index ]")),"\n";
print $q->div({-style=>'margin:15px;'},"sharee API tests", $q->b("user: $user_test | operator_key: $operator_key | bike: $bike")),"\n";

print $q->start_multipart_form(-action=>"/src/scripts/tests/index.pl", -name=>'bikeform'),"\n";
#print $q->hidden(-name=>"sessionid",-override=>1,-value=>"$coo");
#print $q->hidden(-name=>"api_test",-override=>1,-value=>"$operator_key");

print $q->div({-style=>'margin:15px;'},$q->textfield(-name=>'api_test', -value=>"$operator_key", -override=>1, -placeholder=>'Operator'),$q->textfield(-name=>'bike', -value=>"$bike", -override=>1, -placeholder=>'bike', -autofocus=>1),$q->textfield(-name=>'sessionid', -value=>"$coo", -override=>1, -placeholder=>'sessionid',-size=>30),"<button type='submit' name='setbike' value='1' style=''>SET environment</button>"),"\n";

print $q->div({-style=>'margin:15px;'},$q->textfield(-name=>'man_gps', -value=>"$man_gps", -override=>1, -placeholder=>'latitude, longitude',-size=>30),"<button type='submit' name='set_gps' value='1' style=''>SET position</button>"),"\n";
print $q->end_form,"\n";

print $q->div({-id=>"geolocatestate"},""),"\n";

my $manlat = "";
my $manlng = "";
$manlat = $1 if($man_gps =~ /^(\d+\.\d+)/);
$manlng = $1 if($man_gps =~ /(\d+\.\d+)$/);

print<<EOF
<link rel="stylesheet" href="https://unpkg.com/leaflet\@1.8.0/dist/leaflet.css"
   integrity="sha512-hoalWLoI8r4UszCkZ5kL8vayOGVae1oxXe/2A4AO6J9+580uKHDO3JdHb7NzwwzK5xr/Fs0W40kiNHxM9vyTtQ=="
   crossorigin=""/>

<script src="https://unpkg.com/leaflet\@1.8.0/dist/leaflet.js"
   integrity="sha512-BB3hKbKWOc9Ez/TAwyWxNXeoV9c1v6FIeYiBieIWkpLjauysF18NzgR1MBNBXf8/KABdlkX68nAhlwcDFLGPCQ=="
   crossorigin=""></script>

<style>
  #map { 
   height: 500px; 
   width: 100vw;
  }
</style>

EOF
;

print "<div style='margin:15px;' id='map'></div>\n";

print<<EOF
 <script>

 var map = L.map('map', { scrollWheelZoom: false }).setView([$lat, $lng], $map_zoom);

  L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

var icon_green = L.icon({
    iconUrl: '$varenv{metahost}/img/$icon_green',
    iconSize: [37, 37],
    iconAnchor: [20, 37],
    popupAnchor: [-2, -36]
    //shadowUrl: 'marker-shadow.png',
    //shadowSize: [68, 95],
    //shadowAnchor: [22, 94]
});
var icon_red = L.icon({
    iconUrl: '$varenv{metahost}/img/$icon_red',
    iconSize: [37, 37],
    iconAnchor: [20, 37],
    popupAnchor: [-2, -36]
});

//Only stations with bike_count
Promise.all([
  fetch(
    "$uri_request/GBFSout?request=stations_available&calreserv=1&authcookie=$api_return->{authcookie}"
  )]).then(async ([response1]) => {
  const responseData1 = await response1.json();

  const data1 = responseData1.data.stations;

 const layerGroup = L.featureGroup().addTo(map);
  data1.forEach(({ lat, lon, name, bike_count, uri_operator, station_id: stationId }) => {
    console.log('Station: ' + stationId , name, bike_count);

    if(bike_count > 0){
     layerGroup.addLayer(
      L.marker([lat, lon], { icon:icon_green }).bindPopup(
        `<b>Mietradstation: \${name} \${stationId} </b><br/>
	Verfügbare Mieträder: \${bike_count}<br/><a href='\${uri_operator}/GBFSout?request=bikes_available&station=\${stationId}&authcookie=$api_return->{authcookie}' target='_blank'>Verfügbare Mieträder anzeigen</a>
        `
      )
     );
    }else{
     layerGroup.addLayer(
      L.marker([lat, lon], { icon:icon_red }).bindPopup(
        `<b>Mietradstation: \${name} \${stationId} </b><br/>
	Aktuell ist kein Mietrad verfügbar
        `
      )
     );

    }
  });

   if('$manlat' && '$manlng'){
     layerGroup.addLayer(
      L.marker([$manlat, $manlng]).bindPopup(
        '$manlat, $manlng'
      )
     );
    }

  //disabled to setView on current location
  //map.fitBounds(layerGroup.getBounds());
});

function onLocationFound(e) {
    console.log('onLocationFound');
    const geolocatestate = document.querySelector('#geolocatestate');
    var radius = e.accuracy;

    L.marker(e.latlng).addTo(map)
        .bindPopup("You are within " + radius + " meters from this point").openPopup();

    L.circle(e.latlng, radius).addTo(map);
    geolocatestate.textContent = 'You are within ' + radius + ' meters from blue point: ' + e.latlng;
}


function onLocationError(e) {
    alert(e.message);
}

map.on('locationfound', onLocationFound);
map.on('locationerror', onLocationError);
map.locate({setView: true, maxZoom: 16});


//stations and bikes at all
if(1==2){
Promise.all([
  fetch(
    "$uri_request/GBFSout?request=stations_available&authcookie=$api_return->{authcookie}"
  ),
  fetch("$uri_request/GBFSout?request=bikes_available&authcookie=$api_return->{authcookie}")
]).then(async ([response1, response2]) => {
  const responseData1 = await response1.json();
  const responseData2 = await response2.json();

  const data1 = responseData1.data.stations;
  const data2 = responseData2.data.vehicles;

 const layerGroup = L.featureGroup().addTo(map);
  data1.forEach(({ lat, lon, name, address, station_id: stationId }) => {
    let bikesonstation = '';
    console.log('Station: ' + stationId , name);

    data2.forEach(({ station_id, vehicle_name, vehicle_id }) => {
     if(typeof station_id !== 'undefined' && station_id == stationId){
        bikesonstation = bikesonstation.concat('&bull; Verfügbar: ' + vehicle_name + ' ' + vehicle_id + '<br/>');
     }
    });
    console.log(bikesonstation);

    //bike_array.forEach((bike, index) => {
        //console.log('xxxx ' + index + ':' + bike);
    //});

    if(bikesonstation){
     layerGroup.addLayer(
      L.marker([lat, lon], { icon:icon_green }).bindPopup(
        `<b>Mietradstation: \${name} \${stationId} </b><br/>
         \${bikesonstation}
        `
      )
     );
    }else{
     layerGroup.addLayer(
      L.marker([lat, lon], { icon:icon_red }).bindPopup(
        `<b>Mietradstation: \${name} \${stationId} </b><br/>
        `
      )
     );

    }
  });

   if('$manlat' && '$manlng'){
     layerGroup.addLayer(
      L.marker([$manlat, $manlng]).bindPopup(
        '$manlat, $manlng'
      )
     );
    }

  map.fitBounds(layerGroup.getBounds());
});
}//end stations and bikes at all


</script>
EOF
;



print $q->div({-style=>'margin:15px;'},"&nbsp;"),"\n";
print $q->div({-style=>'margin:15px;'},"-------------- $uri --------------------"),"\n";
my $authorization = "$uri?request=authorization&user_id=ragu\@sharee.bike&user_pw=xxxxxx&merchant_id=oiF2kahH&hw_id=g89g8o7goguzuzug\&lang=de";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$authorization"},"[ authorization ]---> $authorization")),"\n";

my $authout = "$uri?request=authout&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$authout"},"[ authout ]---> $authout")),"\n";

my $bikes_all = "$uri?request=bikes_all&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$bikes_all"},"[ bikes_all ]---> $bikes_all")),"\n";

my $bikes_available = "$uri?request=bikes_available&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$bikes_available"},"[ bikes_available ]---> $bikes_available")),"\n";

my $stations_all = "$uri?request=stations_all&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$stations_all"},"[ stations_all ]---> $stations_all")),"\n";

my $stations_available = "$uri?request=stations_available&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$stations_available"},"[ stations_available ]---> $stations_available")),"\n";

my $user_bikes_occupied = "$uri?request=user_bikes_occupied&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$user_bikes_occupied"},"[ user_bikes_occupied ]---> $user_bikes_occupied")),"\n";

my $user_minianswer = "$uri?request=user_minianswer&q1=opt5&q2=opt4&q3=iuwehfiolbev&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$user_minianswer"},"[ user_minianswer ]---> $user_minianswer")),"\n";


###
#config 
my $uriop = "$dbt->{operator}->{$operator_key}->{operatorApp}/APIjsonserver";

#my $bike = "FR1003";
my $latitude = "47.927738";
my $longitude = "7.973855";
#not used
my $and_station_state_locking = "";
my $and_station_state_locked = "";
my $and_station_state_unlocked = "";

#system=sigo
if($operator_key eq "sharee_sx"){
  $latitude = "";
  $longitude = "";
  #$and_station_state_locking = "&station_state=locking";
  #$and_station_state_locked = "&station_state=locked";
  #$and_station_state_unlocked = "&station_state=unlocked";
}

if($operator_key eq "sharee_kn"){
  $latitude = "47.66267";
  $longitude = "9.17262";
}
if($operator_key eq "sharee_wue"){
  $latitude = "47.997930";
  $longitude = "7.785428";
}
if($operator_key eq "sharee_ren"){
  $latitude = "48.8975726";
  $longitude = "11.170959";
}
#Kronau
if($operator_key eq "sharee_tr"){
  $latitude = "49.21908";
  $longitude = "8.63415";
}

print $q->div({-style=>'margin:15px;'},"-------------- $uriop --------------------"),"\n";

my $bikes_available = "$uriop?request=bikes_available&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$bikes_available"},"[ bikes_available ]---> $bikes_available")),"\n";

my $booking_request = "$uriop?request=booking_request&bike=$bike&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_request"},"[ booking_request ]---> $booking_request")),"\n";

my $booking_update_cancel = "$uriop?request=booking_update&bike=$bike&state=canceled&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_cancel"},"[ booking_update_cancel ]---> $booking_update_cancel")),"\n";

my $booking_update_locking = "$uriop?request=booking_update&bike=$bike&lock_state=locking$and_station_state_locking&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_locking"},"[ booking_update_locking ]---> $booking_update_locking")),"\n";

my $booking_update_locked = "$uriop?request=booking_update&bike=$bike&lock_state=locked$and_station_state_locked&firmware=HW%203%3BFW%2031%3BLock%203&app_debug=testetstetst&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_locked"},"[ booking_update_locked ]---> $booking_update_locked")),"\n";

my $booking_update_occupied_unlocking = "$uriop?request=booking_update&bike=$bike&state=occupied&lock_state=unlocking$and_station_state_unlocked&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_occupied_unlocking"},"[ booking_update_occupied_unlocking ]---> $booking_update_occupied_unlocking")),"\n";

my $booking_update_unlocked = "$uriop?request=booking_update&bike=$bike&lock_state=unlocked$and_station_state_unlocked&voltage=39&firmware=HW%203%3BFW%2031%3BLock%203&app_debug=testetstetst&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_unlocked"},"[ booking_update_unlocked ]---> $booking_update_unlocked")),"\n";

my $booking_update_occupied_unlocked = "$uriop?request=booking_update&bike=$bike&state=occupied&lock_state=unlocked$and_station_state_unlocked&app_debug=testetstetst&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_occupied_unlocked"},"[ booking_update_occupied_unlocked ]---> $booking_update_occupied_unlocked")),"\n";

my $booking_request_oc_uling = "$uriop?request=booking_request&bike=$bike&state=occupied&lock_state=unlocking$and_station_state_unlocked&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_request_oc_uling"},"[ booking_request_oc_unlocking ]---> $booking_request_oc_uling")),"\n";

my $booking_request_oc_ul = "$uriop?request=booking_request&bike=$bike&state=occupied&lock_state=unlocked$and_station_state_unlocked&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_request_oc_ul"},"[ booking_request_oc_unlocked ]---> $booking_request_oc_ul")),"\n";

my $booking_update_av_lo = "$uriop?request=booking_update&bike=$bike&state=available&lock_state=locked$and_station_state_locked&latitude=$latitude&longitude=$longitude&gps_age=300&voltage=37&user_device_manufaturer=samsung)&user_device_model=SM-G398FN&user_device_platform=Android&user_device_version=10&user_device_id=90af86831c10374d&app_debug=testetstetst&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_av_lo"},"[ booking_update_av_lo ]---> $booking_update_av_lo")),"\n";

my $booking_update_av_lo_nogps = "$uriop?request=booking_update&bike=$bike&state=available&lock_state=locked$and_station_state_locked&user_device_manufaturer=samsung)&user_device_model=SM-G398FN&user_device_platform=Android&user_device_version=10&user_device_id=90af86831c10374d&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_av_lo_nogps"},"[ booking_update_av_lo_nogps ]---> $booking_update_av_lo_nogps")),"\n";

my $user_feedback = "$uriop?request=user_feedback&bike=$bike&bike_broken=1&message=testnachricht äöü&charge_current_bars=4&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$user_feedback"},"[ user_feedback ]---> $user_feedback")),"\n";

#sig tests
print $q->div({-style=>'margin:15px;'},"&nbsp;"),"\n";
my $siguriop = "$dbt->{operator}->{$operator_key}->{operatorApp}/rentalservice";

print $q->div({-style=>'margin:15px;'},"-------------- sig $siguriop --------------------"),"\n";
my $apikey = "shujiequ0zeuqu0XulooChaex0feiquo";#in done by http header
my $bikeId = "9979e268-e19a-4c99-a39c-966f7d42c0eb";#txt22
my $rentalId = "replace-it-by-real-rentalId";#txt11
print $q->div({-style=>'margin:15px;'},"bikeId:$bikeId | rentalId:$rentalId "),"\n";
#HTTP_SHAREE_API_KEY=$apikey&
#
my $booking_request_sig_oc_uling = "$siguriop?request=booking_request&bike=$bike&state=occupied&lock_state=unlocking&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_request_sig_oc_uling"},"[ booking_request_sig_oc_uling ]---> $booking_request_sig_oc_uling")),"\n";

my $booking_update_sig_unlock = "$siguriop?request=booking_update&bike=$bike&lock_state=unlocking&authcookie=$coo";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_sig_unlock"},"[ booking_update_sig_unlock ]---> $booking_update_sig_unlock")),"\n";

my $sig_push = "$dbt->{operator}->{$operator_key}->{operatorApp}/APIshareeio";
print $q->div({-style=>'margin:15px;'},"-------------- sig $sig_push --------------------"),"\n";
my $sig_rental_end = "$sig_push?request=booking_update&state=available&lock_state=locked&rentalId=$rentalId&HTTP_SHAREE_API_KEY=$apikey";
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$sig_rental_end"},"[ sig_push ]---> $sig_rental_end")),"\n";



print $q->div({-style=>'margin:15px;'},"-------------- (-:-) --------------------"),"\n";
print "</div>\n";
print $q->end_html;
1;
