// JavaScript Document
/////////////////////
$('body').on('keypress', '.photo_detail', function (e) {
var self_obj = $(this).parent().parent();
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);
//////////////////////////////////////////////////////////////////////////////////////////////////////
$.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").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);
//////////////////////////////////////////////////////////////////////////////////////////////////////
$.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 () {
var action = "countries";
var username = $("#janusername").val();
var password = $("#janpassword").val();
///
$.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";
$.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) {
var key = e.which;
if (key == 13) {
//alert("hello1");
///
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++;
});
/////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
$.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','#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];
}