<?php
//DB Data
include '../../ASEngine/AS.php';
if(!$login->isLoggedIn())
    header("Location: ../../login.php");
$user = new ASUser(ASSession::get("user_id"));
$userInfo = $user->getInfo();

//basic include files
require_once("../../../db.php");

//variables
$ota_id = 0;
$inventory_id = $_POST['inventoryid'];
$inventory_name = $_POST['inventoryname'];
$element_id = $_POST['elementid'];
$element_name = $_POST['elementname'];
$ota_default = $_POST['otadefault'];
$element_type = $_POST['elementtype'];
$city_id = $_POST['cityid'];
$province = $_POST['province'];
$country_code = $_POST['countrycode'];
$microsite_code = $_POST['inventorycode'];
$top_destination = $_POST['topdestination'];
$imagecity = $_POST['imagecity'];

if($element_type == '1'){
   $imagepath = '/images/hotel.png';
   $tab = '3';  
   $ota_id = $element_id;
   $ota_priority = $ota_default;
   $imagecity = 'top-destination.jpg';
}elseif($element_type == '2'){
   $imagepath = '/images/city.jpg';
   $tab = '2';
   $ota_id = $city_id;
   $ota_priority = 'NA';   
}

mysqli_query($conn, "INSERT INTO approved_inventory (element_name,element_id,ota_id,ota_priority,element_type,top_destination,city_id,state_province_code,country_code,image_path,microsite_inventory_code,image_topdestination) VALUES('$element_name','$element_id','$ota_id','$ota_priority','$element_type','$top_destination','$city_id','$province','$country_code','$imagepath','$microsite_code','$imagecity')");

mysqli_close($conn);

header("Location: ../../manage-inventory.php?inventoryid=$inventory_id&inventoryname=$inventory_name&message=add$element_type&tab=$tab");
?>