// JavaScript Document
/////////////////////
$('body').on('keypress', '.add_bits_data', function (e) {
var self_obj = $(this).parent().parent();
book_mark_data(self_obj,0);
var key = e.which;
if (key == 13) {
///
var action = "insert";
var username = $("#janusername").val();
var password = $("#janpassword").val();
var jans_auction_date = $(".jans_auction_date").val();
var jans_auction_dates = jans_auction_date.split('-');
jans_auction_date = jans_auction_dates[2] + '-' + jans_auction_dates[0] + '-' + jans_auction_dates[1];
var jans_country = $('#jans_user_country').val();
var url = window.location.href;
if(url.indexOf("modelFull.aspx") >= 0) {
var obj = $('#MainContents_Exhibit_GridArea');
///
var jans_bid_price = [];
$('body').find("#bids_value").each(function () {
jans_bid_price.push($(this).val());
});
var jans_bid_marks = [];
$('body').find("#remarks").each(function () {
jans_bid_marks.push($(this).val());
});
var info = $(obj).find('td.bidNo').html();
if(info)
{
info = info.split("
");
}
var auction_company = [];
if(info && info[1])
auction_company.push("USS " + info[1]);
var lot_no = "";
if(info && info[0])
lot_no = info[0];
var lot_no1 = '';
var lot_no2 = lot_no;
var modelyear = [];
var grade = [];
var inspection = [];
var transactionstatus = [];
var cc = '';
var year = $(obj).find("td.mYear").text();
if(year)
modelyear.push(year);
var mileage = [];
var shifts = [];
var startprice = [];
var info1 = $(obj).find("td.shift").html();
if(info1)
{
info1 = info1.split("
");
shifts.push(info1[0]);
cc = info1[1];
}
var info1 = $(obj).find("td.mile").html();
if(info1)
{
info1 = info1.split("
");
mileage.push(info1[0]);
inspection.push(info1[1]);
}
var info1 = $(obj).find("td.color").text();
var color_name = info1;
var info1 = $(obj).find("td.cTypeDir").text();
var type = info1;
var info1 = $(obj).find("td.price").text();
if(info1)
{
info1 = info1.split("----");
transactionstatus.push(info1[0]);
var stp = info1[1];
if(stp)
stp = stp.replace(',','');
startprice.push(stp);
}
var info1 = $(obj).find("td.score").text();
grade.push(info1);
//////////////////////////////////////////////////////////////////////////////////////////////////////
$.ajax({
type: 'POST',
url: 'https://www.jjinventorysystem.com/new_ext/ajphp_v41.php',
crossDomain: true,
async: true,
data: {
action: action, username: username, password: password, jans_auction_date: jans_auction_date,
jans_country: jans_country,
auction_company: auction_company,
lot_no1: lot_no1,
lot_no2: lot_no2,
modelyear: modelyear,
grade: grade,
ctype: type,
cc: cc,
color: color_name,
'shift':shifts,
inspection: inspection,
mileage: mileage,
jans_bid_price: jans_bid_price,
remark: jans_bid_marks,
start_price: startprice,
},
success: function (data) {
/////////////////////////////////////////////////
if (data == "exist") {
alert("Lot No. is already added in System");
}
else{
var hr_name = get_country_class(jans_country);
var sh_cntry = $("#jans_user_country option:selected").text();
var add_bid = '
';
$(".show_already_existing_bids_full").parent().append(add_bid);
}
/////////////////////////////////////////////////
},
error: function (error) {
alert("Error");
// console.log(error);
}
});
}
else
{
///
var jans_bid_price = [];
$(self_obj).find("#bids_value").each(function () {
jans_bid_price.push($(this).val());
});
var jans_bid_marks = [];
$(self_obj).find("#remarks").each(function () {
jans_bid_marks.push($(this).val());
});
var info = $(self_obj).find('.bidNo').html();
if(info)
{
info = info.split("
");
}
var auction_company = [];
if(info && info[1])
auction_company.push("USS " + info[1]);
var lot_no = "";
if(info && info[0])
lot_no = info[0];
var lot_no1 = '';
var lot_no2 = lot_no;
var modelyear = [];
var grade = [];
var inspection = [];
var transactionstatus = [];
var cc = '';
var year = $(self_obj).find(".mYear").text();
if(year)
modelyear.push(year);
var mileage = [];
var shifts = [];
var startprice = [];
var info1 = $(self_obj).find(".shift").html();
if(info1)
{
info1 = info1.split("
");
shifts.push(info1[0]);
cc = info1[1];
}
var info1 = $(self_obj).find(".mile").html();
if(info1)
{
info1 = info1.split("
");
mileage.push(info1[0]);
inspection.push(info1[1]);
}
var info1 = $(self_obj).find(".color").text();
var color_name = info1;
var info1 = $(self_obj).find(".cTypeDir").text();
var type = info1;
var info1 = $(self_obj).find(".price").text();
if(info1)
{
info1 = info1.split("----");
transactionstatus.push(info1[0]);
var stp = info1[1];
if(stp)
stp = stp.replace(',','');
startprice.push(stp);
}
var info1 = $(self_obj).find(".score").text();
grade.push(info1);
//////////////////////////////////////////////////////////////////////////////////////////////////////
$.ajax({
type: 'POST',
url: 'https://www.jjinventorysystem.com/new_ext/ajphp_v41.php',
//url: 'http://localhost/new_extension/ajphp_v41.php',
crossDomain: true,
async: true,
data: {
action: action, username: username, password: password, jans_auction_date: jans_auction_date,
jans_country: jans_country,
auction_company: auction_company,
lot_no1: lot_no1,
lot_no2: lot_no2,
modelyear: modelyear,
//carname: carname,
grade: grade,
ctype: type,
cc: cc,
//crate: grade,
// ext: ext_color,
//inter:
color: color_name,
//color_no: color_no,
'shift':shifts,
//ac: ac,
//chassiscode: chassiscode,
inspection: inspection,
mileage: mileage,
jans_bid_price: jans_bid_price,
// car_detail_url: car_detail_url,
remark: jans_bid_marks,
start_price: startprice,
},
success: function (data) {
if (data == "exist") {
alert("Lot No. is already added in System");
}
else{
var hr_name = get_country_class(jans_country);
var sh_cntry = $("#jans_user_country option:selected").text();
var add_bid = '';
$(self_obj)
.find(".show_already_existing_bids")
.append(add_bid);
}
},
error: function (error) {
alert("Error");
// console.log(error);
}
});
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
}
});
////user login and get user assaign countries////////////////////
$('body').on('click', '#janlogin_user', function () {
///alert('logn again');
var action = "countries";
var username = $("#janusername").val();
var password = $("#janpassword").val();
///
$.ajax({
type: 'POST',
url: 'https://www.jjinventorysystem.com/new_ext/ajphp_v41.php',
crossDomain: true,
async: true,
data: { action: action, username: username, password: password },
success: function (data) {
$("#jans_user_country").html(data);
localStorage.setItem('janusername', username);
localStorage.setItem('janpassword', password);
localStorage.setItem('jancountrylist', data);
},
});
///
///////////
var action = "set_token";
$.ajax({
type: 'POST',
url: 'https://www.jjinventorysystem.com/new_ext/ajphp_v41.php',
crossDomain: true,
async: true,
data: { action: action, username: username, password: password },
success: function (data) {
var obj = jQuery.parseJSON(data);
localStorage.setItem('jans_user_login_id', obj.user_id);
localStorage.setItem('jans_user_login_token', obj.token);
},
});
//////////
});
///////////////submit bids/////////
$('body').on('keypress', '.item', function (e) {
book_mark_data(this,1);
var key = e.which;
if (key == 13) {
//alert("hello1");
///
if ($(this).find(".already_bid_value").is(':focus')) {
return false;
}
var my_this = $(this);
var action = "insert";
var username = $("#janusername").val();
var password = $("#janpassword").val();
var jans_auction_date = $(".jans_auction_date").val();
var jans_auction_dates = jans_auction_date.split('-');
jans_auction_date = jans_auction_dates[2] + '-' + jans_auction_dates[0] + '-' + jans_auction_dates[1];
var jans_country = $('#jans_user_country').val();
///
var jans_bid_price = [];
$(this).find("#bids_value").each(function () {
jans_bid_price.push($(this).val());
});
var jans_bid_marks = [];
$(this).find("#remarks").each(function () {
jans_bid_marks.push($(this).val());
});
var info = $(this).find('.info1 div').first().text();
info = info.split('No');
var company = info[0];
var auction_company = [];
auction_company.push("USS " + company);
var lot_no = info[1];
if(lot_no)
lot_no = lot_no.replace('.','');
var lot_no1 = '';
var lot_no2 = lot_no;
var modelyear = [];
var grade = [];
var inspection = [];
var transactionstatus = '';
var cnt = 1;
$(this).find(".info2 div ul li:nth-child(1)").each(function () {
var vl = $(this).text();
if(cnt == 1)
{
vl = vl.replace('[Year]','');
modelyear.push(vl);
}
if(cnt == 2)
{
vl = vl.replace('[Score]','');
grade.push(vl);
}
if(cnt == 3)
{
vl = vl.replace('[Inspect]','');
inspection.push(vl);
}
if(cnt == 4)
{
transactionstatus = vl;
}
cnt++;
});
var mileage = [];
var shifts = [];
var startprice = [];
cnt = 1;
$(this).find(".info2 div ul li:nth-child(2)").each(function () {
var vl = $(this).text();
if(cnt == 1)
{
vl = vl.replace('[Odo.]','');
mileage.push(vl);
}
if(cnt == 2)
{
vl = vl.replace('[T/M]','');
shifts.push(vl);
}
//if(cnt == 3)
//inspection.push(vl);
cnt++;
});
//////////////
cnt = 1;
$(this).find(".info2 div ul li:nth-child(3)").each(function () {
var vl = $(this).text();
if(cnt == 2)
{
vl = vl.replace(',','');
startprice.push(vl);
}
cnt++;
});
/////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
$.ajax({
type: 'POST',
url: 'https://www.jjinventorysystem.com/new_ext/ajphp_v41.php',
//url: 'http://localhost/new_extension/ajphp_v41.php',
crossDomain: true,
async: true,
data: {
action: action, username: username, password: password, jans_auction_date: jans_auction_date,
jans_country: jans_country,
auction_company: auction_company,
lot_no1: lot_no1,
lot_no2: lot_no2,
modelyear: modelyear,
//carname: carname,
grade: grade,
//ctype: type,
//cc: cc,
crate: grade,
// ext: ext_color,
//inter:
//color: color_name,
//color_no: color_no,
'shift':shifts,
//ac: ac,
//chassiscode: chassiscode,
inspection: inspection,
mileage: mileage,
jans_bid_price: jans_bid_price,
// car_detail_url: car_detail_url,
remark: jans_bid_marks,
start_price: startprice,
//aimage: aimage,
//fimage: fimage,
//rimage: rimage,
// ex_document: ex_document,
// ex_note: ex_note,
// ex_vehicle_history:ex_vehicle_history,
// ex_drive:ex_drive,
//ex_accessories:ex_accessories,
//ex_fuel: ex_fuel,
// ex_seats: ex_seats,
//ex_load_capacity: ex_load_capacity,
//ex_registeration_month: ex_registeration_month,
//ex_doors: ex_doors
},
success: function (data) {
if (data == "exist") {
alert("Lot No. is already added in System");
}
else{
var hr_name = get_country_class(jans_country);
var sh_cntry = $("#jans_user_country option:selected").text();
var add_bid = '';
$(my_this)
.append(add_bid);
}
},
error: function (error) {
alert("Error");
// console.log(error);
}
});
//////////////////////////////////////////////////////////////////////////////////////////////////////
}
});
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////
$('body').on('click', '.jans_ext_bid', function (e) {
var username = $("#janusername").val();
var password = $("#janpassword").val();
var action = "delete_existing_bids";
var pare_div = $(this).parent();
pre_bid_id = $(pare_div).find(".jans_pre_id").val();
var r = confirm("Are you sure you want to delete this bid?");
if (r == true)
{
$.ajax({
type: 'POST',
url: 'https://www.jjinventorysystem.com/new_ext/ajphp_v41.php',
//url: 'http://localhost/new_extension/ajphp_v41.php',
crossDomain: true,
async: true,
data: { action: action, id:pre_bid_id,
username:username,
password:password
},
success: function (data) {
var obj = jQuery.parseJSON(data);
if(obj.success == true)
{
$(pare_div).hide();
}
alert(obj.msg);
},
});
}
});
/////////////////////////////////////////
$('body').on('keypress', '.bid-header', function (e) {
var key = e.which;
if (key == 13) {
// event.preventDefault();
var pre_bid_price = $(this).find(".jans_pre_price").val();
var pre_bid_remarks = $(this).find(".jans_pre_ramarks").val();
var pre_bid_id = $(this).find(".jans_pre_id").val();
var username = $("#janusername").val();
var password = $("#janpassword").val();
var country = $("#jans_user_country").val();
var action = "update";
var this_obj = this;
/////////////
$.ajax({
type: 'POST',
url: 'https://www.jjinventorysystem.com/new_ext/ajphp_v41.php',
crossDomain: true,
async: true,
data: { action: action, jans_bid_price: pre_bid_price, remarks: pre_bid_remarks, id:pre_bid_id,
username:username,
password:password,
jans_country:country
},
success: function (data) {
//////////////////////
var hr_name = get_country_class(country);
var sh_cntry = $("#jans_user_country option:selected").text();
var add_bid =' '+sh_cntry+'';
$(this_obj).find(".jans_ext_bid_cntry").html(add_bid);
//////////////////////
// $(this_obj).parent('div').parent('div').parent('div').find(".bid-type").val(pre_bid_price);
//$(this_obj).parent('div').parent('div').parent('div').find(".remarks").val(pre_bid_remarks);
},
});
/////////////
}
});
//////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
/////////
$('body').on('click','#toggle', function() {
$(".main-user").toggleClass("tgl");
$("#slide").toggleClass("tgl");
});
////////
function get_country_class(country_id) {
var obj = {
10: 'flag tanzania',
12: 'flag zambia',
14: 'flag south-africa',
17: 'flag uae',
19: 'flag pakistan',
20: 'flag kenya',
21: 'flag uk',
23: 'flag japan',
209: 'flag south-africa',
212: 'flag namibia',
213: 'flag botswana',
214: 'flag mozambique',
267: 'flag japan',
279: 'flag uganda',
282: 'flag pakistan',
284: 'flag japan-online',
297: 'flag zimbabwe',
317: 'flag pakistan',
322: 'flag chili',
335: 'flag kenya',
353: 'flag lesotho',
359: 'flag swaziland',
363: 'flag Dominica',
387: 'flag south-africa',
391: 'flag dominican',
396: 'flag mongolia',
410: 'flag uganda',
419: 'flag uk',
462: 'flag philippines',
467: 'flag namibia',
480: 'flag botswana',
486: 'flag newzealand',
496: 'flag uae',
524: 'flag philippines',
534: 'flag uk'
}
return obj[country_id];
}
///////////
//$(document).ready(function(e) {
$("#janusername").val(localStorage.getItem('janusername'));
$("#janpassword").val(localStorage.getItem('janpassword'));
$("#jans_user_country").html(localStorage.getItem('jancountrylist'));
$("#jans_user_country").val(localStorage.getItem('jancountry'));
$("#janstotalbids").text(localStorage.getItem('jantotalbids'));
$(".jans_auction_date").val(localStorage.getItem('januserauctiondate'));
$('body').on('click','.change_date', function() {
localStorage.setItem('januserauctiondate', $(".jans_auction_date").val());
});
$('body').on('change','#jans_user_country', function() {
localStorage.setItem('jancountry', $(this).val());
});
$("#datepicker").datepicker({
autoclose: true,
todayHighlight: true
}).datepicker('update', localStorage.getItem('januserauctiondate'));
///////////
///////////
function getUrlVars(url) {
var vars = {};
var parts = url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) {
vars[key] = value;
});
return vars;
}
function book_mark_data(self_obj,type)
{
var href = "";
if(type == 0 )
{
href = $(self_obj).find(".carLink").parent().attr("href");
}
else
{
href = $(self_obj).find(".carImg").parent().attr("href");
}
var params={};
href = getUrlVars(href);
var key_list = "";
if(href && href.ExKey)
{
params['ExKey'] = href.ExKey;
key_list = href.ExKey;
}
var fav_id = $("#image_hidden_value").val();
if(href && href.RecordNo)
{
params['RecordNo'] = href.RecordNo;
}
params['__VIEWSTATE'] = $('#__VIEWSTATE').val();
params['__VIEWSTATEGENERATOR'] = $('#__VIEWSTATEGENERATOR').val();
params['AAResultOpen']= $('#AAResultOpen').val();
params['AAResultType']= $('#AAResultType').val();
params['AATermOpen']= $('#AATermOpen').val();
params['Aircon']= $('#Aircon').val();
params['AuctionTerm']= $('#AuctionTerm').val();
params['BrandCode']= $('#BrandCode').val();
params['BrandScrollTop']= $('#BrandScrollTop').val();
params['CarCategoryNo']= $('#CarCategoryNo').val();
params['CarType']= $('#CarType').val();
params['CarTypeMatch']= $('#CarTypeMatch').val();
params['CarTypeText']= $('#CarTypeText').val();
params['Color']= $('#Color').val();
params['CommercialType']= $('#CommercialType').val();
params['DisplacementFrom']= $('#DisplacementFrom').val();
params['DisplacementTo']= $('#DisplacementTo').val();
params['Drive']= $('#Drive').val();
params['ExInf']= $('#ExInf').val();
params['ExKeyList']= $('#ExKeyList').val();
params['FinalPriceFrom']= $('#FinalPriceFrom').val();
params['FinalPriceTo']= $('#FinalPriceTo').val();
params['Grade']= $('#Grade').val();
params['GradeMatch']= $('#GradeMatch').val();
params['GradeText']= $('#GradeText').val();
params['ImportedHandle']= $('#ImportedHandle').val();
params['ImportedModelYearFrom']= $('#ImportedModelYearFrom').val();
params['ImportedModelYearTo']= $('#ImportedModelYearTo').val();
params['ImportedType']= $('#ImportedType').val();
params['IsEquipAW']= $('#IsEquipAW').val();
params['IsEquipLeather']= $('#IsEquipLeather').val();
params['IsEquipNavi']= $('#IsEquipNavi').val();
params['IsEquipPS']= $('#IsEquipPS').val();
params['IsEquipPW']= $('#IsEquipPW').val();
params['IsEquipSR']= $('#IsEquipSR').val();
params['ListMode']= $('#ListMode').val();
params['MaxListRow']= $('#MaxListRow').val();
params['MaxRow']= $('#MaxRow').val();
params['MileageFrom']= $('#MileageFrom').val();
params['MileageTo']= $('#MileageTo').val();
params['MileageType']= $('#MileageType').val();
params['MileType']= $('#MileType').val();
params['ModelScrollTop']= $('#ModelScrollTop').val();
params['ModelYearFrom']= $('#ModelYearFrom').val();
params['ModelYearTo']= $('#ModelYearTo').val();
params['Mot']= $('#Mot').val();
params['OrderNo']= $('#OrderNo').val();
params['PageNo']= $('#PageNo').val();
params['RecordNo']= $('#RecordNo').val();
params['Score']= $('#Score').val();
params['ScrollTop']= $('#ScrollTop').val();
params['SearchFlow']= $('#SearchFlow').val();
params['SearchType']= $('#SearchType').val();
params['Shift']= $('#Shift').val();
params['SortNo']= $('#SortNo').val();
params['StartPriceFrom']= $('#StartPriceFrom').val();
params['StartPriceTo']= $('#StartPriceTo').val();
params['Tieup']= $('#Tieup').val();
params['TieupWeek']= $('#TieupWeek').val();
params['Uss']= $('#Uss').val();
params['UssWeek']= $('#UssWeek').val();
var url_arr = window.location.href;
url_arr = url_arr.split("/");
var replace_url = "";
if(url_arr && url_arr[4])
{
replace_url = url_arr[4];
}
var book_url = "http://www.cis6200.jp/cis/"+replace_url+"/en/etc/addBookmark.ashx?BookType=0";
$.ajax({
type: 'POST',
url: book_url,
crossDomain: true,
data : {ExKeyList: key_list},
success: function (data) {
$.ajax({
type: 'POST',
url: "http://www.cis6200.jp/cis/"+replace_url+"/en/etc/setFavoriteMark.ashx?MarkNoList="+fav_id+"&IsFavoriteMark=true",
crossDomain: true,
data : params,
success: function (data) {
var url_12 = "http://www.cis6200.jp/cis/"+replace_url+"/en/request/addBookmark.aspx?BookType=0&FavResultType=1&ExKeyList="+key_list+"&ListSelectCount=1";
$.ajax({
type: 'GET',
url: url_12,
crossDomain: true,
success: function (data) {
},
error:function(err){
console.log(err);
}
});
},
error:function(err){
console.log(err);
}
});
},
error:function(err){
console.log(err);
}
});
}
//});