1var myApp = new Framework7({ 2 modalTitle: 'Orderr', 3 // Enable Material theme 4 material: true, 5 fastClicks: false, 6}); 7 8var $$ = Dom7; 9var mySwiper = myApp.swiper('.swiper-container', { 10 pagination:'.swiper-pagination' 11 }); 12var mainView = myApp.addView('.view-main', { 13 // dynamicNavbar: true 14}); 15 16var cname = ''; 17$$('img.lazy').trigger('lazy'); 18$$(document).on('ajaxStart', function (e) { 19 //console.log("call ajax start"); 20}); 21 22$$(document).on('ajaxComplete', function () { 23 myApp.hideIndicator(); 24}); 25 26$$('div.lazy').trigger('lazy'); 27 28var userudid ='' ; 29var useremail ='' ; 30var uname = ''; 31var univUrl = ""; 32 33 function onBodyLoad(){ 34 univUrl = new Firebase("https://fiery-fire-6430.firebaseio.com/"); 35 console.log("On BodyLoad"); 36 var platform = myApp.device.os; 37 var url = window.location.href; 38 url = String(url); 39 console.log("Platform : " +platform+ ", URL : " +url); 40 var pos = url.search("bid="); 41 console.log("Position of Bid in URL : "+pos); 42 // if((platform === undefined || platform === "undefined") && (url === "https://orderr.in/")){ 43 // console.log("in if for redirection."); 44 // window.location.href = "https://orderr.in/aboutus"; 45 // } else 46 if(pos != -1){ 47 //console.log("With home launcher in web view."); 48 var res = url.split("bid="); 49 //console.log(res[0]); 50 //console.log(res[1]); 51 var bid = res[1]; 52 var check = res[0]; 53 setTimeout( function(){ 54 if(check === "https://orderr.in/app/?"){ 55 var userNum = window.localStorage.getItem('userudid'); 56 userNum = userNum; 57 var userName = window.localStorage.getItem('user_name'); 58 userName = userName; 59 console.log(userName+ " : " +userNum); 60 if((userNum) && (userName) && (bid)){ 61 mainView.router.loadPage('bprofile.html?bid='+bid); 62 } else{ 63 //myApp.alert("Go to login page."); 64 window.localStorage.setItem("homeLauncherUrl", url); 65 myApp.loginScreen(); 66 } 67 } 68 }, 2000); 69 } 70 71 branch.init('key_live_onhVkWYYW7vw2ZZKjimaWdoauucWyCJF', function(err, data) { 72 console.log(JSON.stringify(data)); 73 }); 74 internetCheck(); 75 }//End onBodyLoad function 76 77 function internetCheck(){ 78 myApp.showIndicator(); 79 // $.ajax({ 80 // url: "https://appsforbusiness.in/testing.php", 81 // error: function(){ 82 // mainView.router.loadPage('error.html'); 83 // myApp.alert('It seems your internet is sleeping, wake it up to enjoy the app.'); 84 // myApp.hideIndicator(); 85 // }, 86 // success: function(){ 87 myApp.hideIndicator(); 88 function loadjscssfile(filename, filetype){ 89 if (filetype=="js"){ //if filename is a external JavaScript file 90 var fileref=document.createElement('script'); 91 fileref.setAttribute("type","text/javascript"); 92 fileref.setAttribute("src", filename); 93 } else if (filetype=="css"){ //if filename is an external CSS file 94 var fileref=document.createElement("link"); 95 fileref.setAttribute("rel", "stylesheet"); 96 fileref.setAttribute("type", "text/css"); 97 fileref.setAttribute("href", filename); 98 } 99 if (typeof fileref!="undefined") 100 document.getElementsByTagName("head")[0].appendChild(fileref); 101 } 102 103 $("#usermobile").intlTelInput({ 104 defaultCountry: "in", 105 utilsScript: "js/utils.js" 106 }); 107 108 $("#usermobilereset").intlTelInput({ 109 defaultCountry: "in", 110 utilsScript: "js/utils.js" 111 }); 112 113 document.addEventListener("deviceready", onDeviceReady, false); 114 document.addEventListener("pause", onPaush, false); 115 document.addEventListener("resume", onResume, false); 116 document.addEventListener("backbutton", onBack, false); 117 118 var userid = window.localStorage.getItem("firebase:session::fiery-fire-6430"); 119 //console.log(userid); 120 if(userid != null){ 121 var parsjson = JSON.parse(userid); 122 useremail = parsjson.password.email; 123 var values = useremail.split("@"); 124 userudid = values[0]; 125 window.localStorage.setItem("userudid",userudid); 126 window.localStorage.setItem("useremail",useremail); 127 128 setTimeout(function(){ 129 userOnlineOfflineStatus(userudid); 130 //var firebaseBrand = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/username"); 131 univUrl.child("users/cc/"+userudid+"/username").on('value', function(snapshot){ 132 window.localStorage.setItem("user_name",snapshot.val()); 133 uname = snapshot.val(); 134 $$('#show-user-name').html(snapshot.val()); 135 }); 136 137 deviceData(userudid); 138 //var firebaseusername = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid); 139 univUrl.child("users/cc/"+userudid).once('value', function(snapshot){ 140 var cpage = mainView.activePage; 141 var useralldata = snapshot.val(); 142 uname = useralldata.username; 143 window.localStorage.setItem("user_name",useralldata.username); 144 $$('#show-user-name').html(useralldata.username); 145 if(useralldata.billing_address == '' ){ 146// myApp.alert("Please complete your profile."); 147// mainView.router.loadPage('firstprofile.html'); 148 } else{ 149 //console.log(cpage.name); 150 if(cpage.name == 'errorpage'){ 151 mainView.router.loadPage('index.html'); 152 } 153 } 154 }); 155 156 var cartbid; 157 //var firebaseBrands = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart"); 158 univUrl.child("users/cc/"+userudid+"/cart").once('value', function(snapshot){ 159 var b = snapshot.exists();
160 var a = snapshot.numChildren(); 161 if(b==true){ 162 snapshot.forEach(function(newdata) { 163 var cartkey = newdata.key(); 164 //var branddata = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"+cartkey+"/brand_id"); 165 univUrl.child("/users/cc/"+userudid+"/cart/"+cartkey+"/brand_id").once('value',function(snapshots){ 166 cartbid = snapshots.val(); 167 }); 168 }); 169 myApp.modal({ 170 title: 'Orderr', 171 text: 'You have products in your cart. Would you like to continue?', 172 buttons: [ 173 { 174 text: 'Discard', 175 onClick: function() { 176 //console.log(cartbid); 177 //var removecats = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"); 178 univUrl.child("/users/cc/"+userudid+"/cart/").remove(); 179 } 180 }, 181 { 182 text: 'Continue', 183 onClick: function() { 184 //console.log("brand id..."+cartbid); 185 mainView.router.loadPage('catalogues.html?bid='+cartbid); 186 } 187 } 188 189 ] 190 }); 191 192 } 193 }); 194 195 },1000); 196 197 }else{ 198 mainView.router.loadPage('welcome.html'); 199 } 200 // }, 201 // timeout: 15000 // sets timeout to 10 seconds remember you want it to be long to ensure that it isn't just a slow connection 202 // }); 203 }//End internetCheck() function 204 205function showsigninpopup(){ 206//console.log("call signup "); 207 myApp.loginScreen(); 208} 209 210function userOnlineOfflineStatus (firekey) { 211 var userid = firekey; 212 //var amOnline = univUrl.child(".info/connected"); //new Firebase('https://fiery-fire-6430.firebaseio.com/.info/connected'); 213 //var userRef = univUrl.child("presence/cloudcatalogue/"+userid); //new Firebase('https://fiery-fire-6430.firebaseio.com/presence/cloudcatalogue/'+userid); 214 setTimeout(function(){ 215 univUrl.child(".info/connected").on('value', function(snapshot) { 216 if(snapshot.val() == true){ 217 //console.log('Online - '+snapshot.val()); 218 univUrl.child("presence/cloudcatalogue/"+userid+"status").set('â online'); 219 univUrl.child("presence/cloudcatalogue/"+userid+"status").set(1); 220 221 myApp.hidePreloader(); 222 } else{ 223 //console.log('Offline - '+snapshot.val()); 224 univUrl.child("presence/cloudcatalogue/"+userid+"ended").onDisconnect().set(Firebase.
224ServerValue.TIMESTAMP); 225 univUrl.child("presence/cloudcatalogue/"+userid+"status").onDisconnect().set('â offline'); 226 univUrl.child("presence/cloudcatalogue/"+userid+"online").onDisconnect().set(0); 227 //console.log("waiting for internet"); 228 myApp.showPreloader('Waiting for internet connection...'); 229 230 } 231 }); 232 },5000); 233 234 document.onIdle = function () { 235 univUrl.child("presence/cloudcatalogue/"+userid+"status").set('â idle'); 236 univUrl.child("presence/cloudcatalogue/"+userid+"online").set(2); 237 } 238 document.onAway = function () { 239 univUrl.child("presence/cloudcatalogue/"+userid+"status").set('â away'); 240 univUrl.child("presence/cloudcatalogue/"+userid+"online").set(3); 241 } 242 document.onBack = function (isIdle, isAway) { 243 univUrl.child("presence/cloudcatalogue/"+userid+"status").set('â online'); 244 } 245 } //End userOnlineOfflineStatus 246 247 function sharebranch(bid,cid){ 248 //var getcatdatabr = univUrl.child("presence/cloudcatalogue/"+userid); //new Firebase("https://fiery-fire-6430.firebaseio.com/catalogues/"+bid+"/"+cid); 249 univUrl.child("presence/cloudcatalogue/"+userid).once("value", function(snapshotcat){ 250 var catdata = snapshotcat.val(); 251 branch.link({ 252 tags: [ 'tag1', 'tag2' ], 253 channel: 'ocp', 254 feature: 'Catalogue', 255 stage: 'ocp', 256 data: { 257 bid: bid, 258 cid:cid, 259 cwise:catdata.cat_orderstatus, 260 '$og_title': catdata.cat_name, 261 '$og_description': 'Your friend has suggested a product catalogue for you. Click on the link to check it out.', 262 '$og_image_url': catdata.cat_img 263 } 264 }, function(err, link) { 265 if(link){ 266 //console.log(JSON.stringify(link)); 267 window.plugins.socialsharing.share('Your friend has suggested a new catalogue. Click to check it out', null, catdata.cat_img, link); 268 } 269 }); 270 }); 271 }//End sharebranch() function 272 273 function callforbranch(){ 274 var userid = window.localStorage.getItem("firebase:session::fiery-fire-6430"); 275 if(userid != null){ 276 var parsjson = JSON.parse(userid); 277 useremail = parsjson.password.email; 278 var values = useremail.split("@"); 279 userudid = values[0]; 280 window.localStorage.setItem("userudid",userudid); 281 console.log("callforbranch....setidentity"+userudid); 282 branch.setIdentity( 283 userudid, 284 function (err, data){ 285 if(data){ 286 //console.log(data); 287 } 288 if(err){ 289 //console.log(err); 290 } 291 }); 292 293 branch.data(function(err, data) { 294 if (data.data && !(data.data === "null")) { 295 var currentUNo = window.localStorage.getItem('userudid'); 296 var striVar = JSON.stringify(data.data); 297 var stridata = JSON.parse(data.data); 298 299 if(stridata['+clicked_branch_link'] != false) { 300 var bid = stridata.bid; 301 var cid = stridata.cid; 302 var pid = stridata.pid; 303 var rd = stridata; 304 console.log("Bid :"+bid+ "\nCid :"+cid+ "\nPid :"+pid); 305 if(bid || cid || pid){ 306 var childNo = ""; 307 var username = window.localStorage.getItem("user_name"); 308 //var pstatus = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+rd.bid); 309 univUrl.child("brand/"+rd.bid+"currency").once('value', function(snapshot){ 310 window.localStorage.setItem("bcurrency",snapshot.val()); 311 }); 312 313 univUrl.child("brand/"+rd.bid+"min_order_price").once('value', function(snapshot){ 314 window.localStorage.setItem("bminordval",snapshot.val()); 315 }); 316 317 univUrl.child("brand/"+rd.bid+"brand_privacystatus").once('value', function(snapshot){ 318 var pstat = snapshot.val(); 319 // When public 320 if(pstat==0) { 321 if(rd.cid) { 322 //var cstatus = new Firebase("https://fiery-fire-6430.firebaseio.com/catalogues/"+rd.bid+"/"+rd.cid); 323 univUrl.child("catalogues/"+rd.bid+"/"+rd.cid).once('value', function(snapshot){ 324 var cstat = snapshot.val().cat_privacystatus; 325 var parentid = snapshot.val().parentid; 326 childNo = snapshot.val().no_of_child; 327 if(cstat==0) { 328 if(rd.pid) { 329 if(rd.catwise=="Product Wise") { 330 mainView.router.loadPage('productview.html?bid='+rd.bid+'&catid='+rd.cid+'&pid='+rd.pid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 331 } else { 332 mainView.router.loadPage('products.html?bid='+rd.bid+'&cid='+rd.cid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 333 } 334 } else { 335 if(childNo == 0){ 336 mainView.router.loadPage('products.html?bid='+rd.bid+'&cid='+rd.cid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 337 } else { 338 mainView.router.loadPage("subcatalogue.html?bid="+rd.bid+'&cid='+rd.cid+'&backinfo=callfromscan'); 339 } 340 } 341 } else{ 342 //var cataccbrand = new Firebase("https://fiery-fire-6430.firebaseio.com/caccess/"+rd.bid+"/"+rd.cid+"/"+userudid+"/status"); 343 univUrl.child("caccess/"+rd.bid+"/"+rd.cid+"/"+userudid+"/status").once('value', function(snapshotcat){ 344 var getcatsts = snapshotcat.val(); 345 if(getcatsts == 2) { 346 if(rd.pid) { 347 if(rd.catwise=="Product Wise") { 348 mainView.router.loadPage('productview.html?bid='+rd.bid+'&catid='+rd.cid+'&pid='+rd.pid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 349 } else { 350 mainView.router.loadPage('products.html?bid='+rd.bid+'&cid='+rd.cid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 351 } 352 } else{ 353 if(childNo == 0){ 354 mainView.router.loadPage('products.html?bid='+rd.bid+'&cid='+rd.cid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 355 } else{ 356 mainView.router.loadPage("subcatalogue.html?bid="+rd.bid+'&cid='+rd.cid+'&backinfo=callfromscan'); 357 } 358 } 359 } else{ 360 myApp.alert("Please ask the brand to provide you access for this catalogue"); 361 mainView.router.loadPage('catalogues.html?bid='+rd.bid); 362 } 363 }); 364 } 365 }); 366 } else{ 367 mainView.router.loadPage('bprofile.html?bid='+rd.bid); 368 } 369 } else{ 370 if(rd.bid){ 371 //var scanbrand = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"+rd.bid+"/"+userudid+"/status"); 372 univUrl.child("baccess/"+rd.bid+"/"+userudid+"/status").once('value', function(snapshot){ 373 var connstatus = snapshot.val(); 374 if(connstatus == 2) { 375 // Redirect to the Brand Profile Page 376 if(rd.cid) { 377 //var cstatus = new Firebase("https://fiery-fire-6430.firebaseio.com/catalogues/"+rd.bid+"/"+rd.cid); 378 univUrl.child("catalogues/"+rd.bid+"/"+rd.cid).once('value', function(snapshot){ 379 var cstat = snapshot.val().cat_privacystatus; 380 var parentid = snapshot.val().parentid; 381 childNo = snapshot.val().no_of_child; 382 //console.log("Parent Id"+parentid); 383 if(cstat==0){ 384 if(rd.pid){ 385 if(rd.catwise=="Product Wise"){ 386 mainView.router.loadPage('productview.html?bid='+rd.bid+'&catid='+rd.cid+'&pid='+rd.pid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 387 } else { 388 mainView.router.loadPage('products.html?bid='+rd.bid+'&cid='+rd.cid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 389 } 390 } else{ 391 if(childNo == 0){ 392 mainView.router.loadPage('products.html?bid='+rd.bid+'&cid='+rd.cid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 393 } else{ 394 mainView.router.loadPage("subcatalogue.html?bid="+rd.bid+'&cid='+rd.cid+'&backinfo=callfromscan'); 395 } 396 } 397 } else{ 398 //var cataccbrand = new Firebase("https://fiery-fire-6430.firebaseio.com/caccess/"+rd.bid+"/"+rd.cid+"/"+userudid+"/status"); 399 univUrl.child("caccess/"+rd.bid+"/"+rd.cid+"/"+userudid+"/status").once('value', function(snapshotcat){ 400 var getcatsts = snapshotcat.val(); 401 if(getcatsts == 2) { 402 if(rd.pid) { 403 if(rd.catwise=="Product Wise") { 404 mainView.router.loadPage('productview.html?bid='+rd.bid+'&catid='+rd.cid+'&pid='+rd.pid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 405 } else{ 406 mainView.router.loadPage('products.html?bid='+rd.bid+'&cid='+rd.cid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 407 } 408 } else{ 409 if(childNo == 0){ 410 mainView.router.loadPage('products.html?bid='+rd.bid+'&cid='+rd.cid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 411 } else{ 412 mainView.router.loadPage("subcatalogue.html?bid="+rd.bid+'&cid='+rd.cid+'&backinfo=callfromscan'); 413 } 414 } 415 } else{ 416 myApp.alert("Please ask the brand to provide you access for this catalogue"); 417 mainView.router.loadPage('catalogues.html?bid='+rd.bid); 418 } 419 }); 420 } 421 }); 422 } else{ 423 mainView.router.loadPage('bprofile.html?bid='+rd.bid); 424 } 425 } else{ 426 var uname = window.localStorage.getItem("user_name");
427 // Do not show product 428 //var chkbrand = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+rd.bid+"/brand_privacystatus"); 429 univUrl.child("brand/"+rd.bid+"/brand_privacystatus").once('value', function(snapshots){ 430 var opentatus = snapshots.val(); 431 //If brand is public/open 432 if(opentatus == 0) { 433 //var uaccessKey = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"+rd.bid+"/"+userudid); 434 univUrl.child("baccess/"+rd.bid+"/"+userudid).set({ 435 user_email: useremail, 436 status: 2, 437 invitename:username, 438 access_time: Firebase.ServerValue.TIMESTAMP, 439 }); 440 441 $$.post('https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/gcmsk1.php', 442 { msgtype:'crq', cname: uname, bid: rd.bid, mobile:userudid }, function (data) { 443 }); 444 mainView.router.loadPage('bprofile.html?bid='+rd.bid); 445 } else{ //if brand is private 446 //var uaccessKey = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"+rd.bid+"/"+userudid); 447 univUrl.child("baccess/"+rd.bid+"/"+userudid).set({ 448 user_email: useremail, 449 status: 1, 450 invitename:username, 451 access_time: Firebase.ServerValue.TIMESTAMP, 452 }); 453 454 var uname = window.localStorage.getItem("user_name"); 455 $$.post('https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/gcmsk1.php', 456 { msgtype:'crq', cname: uname, bid: rd.bid, mobile:userudid}, function (data) { 457 }); 458 myApp.alert("A connection request has been sent to the brand."); 459 } 460 }); 461 } 462 }); 463 } 464 } 465 }); 466 }else{ 467 468 } 469 } 470 } else{ 471 //console.log( JSON.stringify(err)); 472 } 473 }); 474 } else{ 475 } 476 }//End callforbranch() function 477 478function onDeviceReady(){ 479 navigator.splashscreen.hide(); 480 //console.log('call onDeviceReady'); 481 //OneSignal Notification 482 var notificationOpenedCallback = function(jsonData) { 483 //console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData)); 484 }; 485 486 // var deviceType = device.platform; 487 // console.log("Device OS :" +deviceType); 488 // if(deviceType == 'Android' || deviceType == 'android'){ 489 // var deviceInfo = cordova.require("cordova/plugin/DeviceInformation"); 490 // console.log(deviceInfo); 491 // deviceInfo.get(function(result) { 492 // console.log(result); 493 // console.log(result.length); 494 // var val = result.split(","); 495 // console.log("Length : "+val.length); 496 // console.log("Val : " +val); 497 // $.each( val, function(key, value){ 498 // console.log("Type : " +key+ " Name : " +value); 499 // }); 500 // // var i = 0; 501 // // while(result){ 502 // // console.log(result.('account'+i+'Name')); 503 // // console.log(result.('account'+i+'Type')); 504 // // i++; 505 // // if(result('account'+i+'Name') === undefined) break; 506 // // } 507 // console.log("result = " + JSON.stringify(result)); 508 // var devdata = JSON.parse(result); 509 510 // console.log(devdata); 511 // var j = 0; 512 // while(devdata){ 513 // console.log(devdata['account'+j+'Name']); 514 // console.log(devdata['account'+j+'Type']) 515 // j++; 516 // if((devdata['account'+j+'Name'] === 'undefined') || (devdata['account'+j+'Name'] === undefined)) 517 // break; 518 // //console.log(i); 519 // //if() 520 // } 521 // console.log(devdata['account1Name']); 522 // console.log(devdata['phoneNo']); 523 // if(devdata['account0Type']=="com.google"){ 524 // var email = devdata['account0Name']; 525 // }else if(devdata['account1Type']=="com.google"){ 526 // var email = devdata['account1Name']; 527 // }else if(devdata['account2Type']=="com.google"){ 528 // var email = devdata['account2Name']; 529 // } 530 // if(devdata['phoneNo']=="TM.ERROR"){ 531 // var mobno = "Not Available"; 532 // }else{ 533 // var mobno = devdata['phoneNo']; 534 // }
535 // window.localStorage.setItem("dmob", mobno); 536 // window.localStorage.setItem("demail", email); 537 538 // }, function() { 539 // console.log("error"); 540 // }); 541 // } 542 // window.plugins.OneSignal.init("ad3f0768-f248-4a52-b4da-1044568cb805", 543 // {googleProjectNumber: "794948118769"}, 544 // notificationOpenedCallback); 545 546 // // Show an alert box if a notification comes in when the user is in your app. 547 // window.plugins.OneSignal.enableInAppAlertNotification(true); 548 549 // window.plugins.OneSignal.getIds(function(ids) { 550 // //console.log('getIds: ' + JSON.stringify(ids)); 551 // window.localStorage.setItem("oneSignalPushToken", ids.pushToken); 552 // }); 553 554 nearby_user(); 555 branch.init('key_live_onhVkWYYW7vw2ZZKjimaWdoauucWyCJF', function(err, data) { 556 }); 557 initpush(); 558 initsms(); 559 setTimeout(function(){ 560 deviceData(userudid); 561 branch.data(function(err, data) { 562 if (data.data && !(data.data === "null")) { 563 var temp = JSON.stringify(data.data); 564 var stridata = JSON.parse(data.data); 565 var strings = temp.replace(/\+/g, ""); 566 567 var bDataStatus = JSON.parse(strings); 568 //console.log("clicked_branch_link..onDeviceReady."+stridata['+clicked_branch_link']); 569
570 if(stridata['+clicked_branch_link'] == false) { 571 572 } else{ 573 574 callforbranch(); 575 } 576 } 577 }); 578 579//callforbranch(); 580},1000); 581}//End onDeviceReady function 582 583function onPaush(){ 584 //console.log('call onPause'); 585} 586 587function onResume(){ 588 //console.log('call onResume'); 589 branch.init('key_live_onhVkWYYW7vw2ZZKjimaWdoauucWyCJF', function(err, data) { 590 if (data.data && !(data.data === "null")) { 591 var temp = JSON.stringify(data.data); 592 var stridata = JSON.parse(data.data); 593 var strings = temp.replace(/\+/g, ""); 594 595 var bDataStatus = JSON.parse(strings); 596 //console.log("clicked_branch_link..onDeviceReady."+stridata['+clicked_branch_link']); 597 if(stridata['+clicked_branch_link'] == false) { 598 599 } else{ 600 callforbranch(); 601 } 602 } 603 }); 604} 605 606function onBack(){ 607 //console.log('call onBack'); 608 var cpage = mainView.activePage; 609 if(cpage.name == 'index' || cpage.name =='login-screen' || cpage.name == 'mail-register-page' || cpage.name == 'registration' || cpage.name == 'welcome'){ 610 myApp.confirm('Are you sure you want to exit', function () { 611 var devicetype = window.localStorage.getItem('devicePlatform'); 612 if(devicetype === 'Android'){ 613 navigator.app.exitApp(); 614 } else{ 615 } 616 }); 617 } else{ 618 mainView.router.back(); 619 } 620 //return false; 621} 622 623/********************deviceData() function****************************/ 624 function deviceData(userid) { 625 OneSignal.push(["getUserId", function(ids) { 626 var deviceToken = ids; 627 var deviceModel = 'web'; 628 var userid = window.localStorage.getItem("firebase:session::fiery-fire-6430"); 629 var parsjson = JSON.parse(userid); 630 var useremail = parsjson.password.email; 631 var values = useremail.split("@"); 632 userid = values[0]; 633 var devicePlatform = ""; 634 var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor); 635 var isSafari = /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor); 636 var dtype = 5; 637 if(isChrome) { 638 devicePlatform = "Chrome"; 639 dtype = 5; 640 } else if(isSafari) { 641 devicePlatform = "Safari"; 642 dtype = 7; 643 } 644 var deviceUUID = devicePlatform+userid; 645 var deviceVersion = "1.0"; 646 //console.log("In Kitchen-sink.js, Device Model: "+deviceModel+", Platform: "+devicePlatform+", UUID: "+deviceUUID+", Version: "+deviceVersion); 647 var firebaseDevice = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userid+"/devices/"+deviceUUID); 648 firebaseDevice.set({ 649 deviceToken:deviceToken, 650 deviceModel:deviceModel, 651 deviceType:"cloudcatalogue", 652 devicePlatform:devicePlatform, 653 deviceUUID:deviceUUID, 654 deviceVersion:deviceVersion, 655 status:"1", 656 }); 657 window.localStorage.setItem("device_token", deviceToken); 658 window.localStorage.setItem("deviceModel", deviceModel); 659 window.localStorage.setItem("devicePlatform", devicePlatform); 660 window.localStorage.setItem("deviceUUID", deviceUUID); 661 window.localStorage.setItem("deviceVersion", deviceVersion); 662 branch.closeBanner(); 663 }]); 664 } 665 666/*function deviceData(userid){ 667 //console.log('call devicedata userid....'+userid); 668 var deviceToken = window.localStorage.getItem("device_token"); 669 //console.log("deviceToken: "+deviceToken); 670 var deviceModel = device.model; 671 var devicePlatform = device.platform; 672 var deviceUUID = device.uuid; 673 var deviceVersion = device.version; 674 window.localStorage.setItem("deviceModel", deviceModel); 675 window.localStorage.setItem("devicePlatform", devicePlatform); 676 window.localStorage.setItem("deviceUUID", deviceUUID); 677 window.localStorage.setItem("deviceVersion", deviceVersion); 678 // //console.log("Device Model: "+deviceModel+", Platform: "+devicePlatform+", UUID: "+deviceUUID+", Version: "+deviceVersion); 679 if(userid !== null || userid !== "null" || userid !== undefined || userid !== "") { 680 //var firebaseDevice = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userid+"/devices/"+deviceUUID); 681 univUrl.child("users/cc/"+userid+"/devices/"+deviceUUID).set({ 682 deviceToken:deviceToken, 683 deviceModel:deviceModel, 684 deviceType:"cloudcatalogue", 685 devicePlatform:devicePlatform, 686 deviceUUID:deviceUUID, 687 deviceVersion:deviceVersion, 688 status:"1", 689 });
690 } 691 }*/ 692 693function initpush(){ 694 push = PushNotification.init({ "android": {"senderID": "794948118769","icon": "icon", "iconColor": "orange"}, 695 "ios": {"alert": "true", "badge": "true", "sound": "true"}, "windows": {} } ); 696 697 push.on('registration', function(data) { 698 window.localStorage.setItem("device_token",data.registrationId); 699 }); 700 701 push.on('notification', function(data) { 702 var deviceType = window.localStorage.getItem("devicePlatform"); 703 //console.log(JSON.stringify(data)); 704 705 if(deviceType == 'iOS'){ 706 message = data.message; 707 data1 = data.additionalData; 708 data = data.additionalData.additionalData; 709 msgtype = data.msg_type; 710 msg_type = data.msgtype; 711 title = data.title; 712 brandid = data.b_id; 713 brandname = data.b_name; 714 orderid = data.o_id; 715 //console.log(message +' / '+msgtype +' / '+msg_type +' / '+title); 716 } else{ 717 message = data.message; 718 title = data.title; 719 data = data.additionalData; 720 msgtype = data.msg_type; 721 msg_type = data.msgtype; 722 brandid = data.b_id; 723 brandname = data.b_name; 724 orderid = data.o_id; 725 //console.log(message +' / '+msgtype +' / '+msg_type +' / '+title); 726 } 727 additionalData: Object 728 var cpage = mainView.activePage; 729 if(msgtype == "mr"){ 730 731 if(cpage.name !== 'chat_profile'){ 732 var modal = myApp.modal({ 733 title: title, 734 text: message, 735 buttons: [{ 736 text: data.actions[0].title, 737 onClick: function () { 738 739 if(data.actions[0].callback == "approve"){ 740 mainView.router.loadPage("chat.html?brandid="+brandid+"&bname="+brandname); 741 } 742 } 743 }, { 744 text: data.actions[1].title, 745 bold: true, 746 onClick: function () { 747 if(data.actions[1].callback == "reject"){ 748 749 } 750 } 751 },] 752 }) 753 } 754} else if(msgtype=="ordPA"){ 755 if(cpage.name !== 'viewaction'){ 756 var modal = myApp.modal({ 757 title: title, 758 text: message, 759 buttons: [ 760 { 761 text: data.actions[0].title, 762 onClick: function () { 763 if(data.actions[0].callback == "approve"){ 764 mainView.router.loadPage('viewaction.html?orderid='+orderid); 765 } 766 } 767 }, 768 { 769 text: data.actions[1].title, 770 bold: true, 771 onClick: function () { 772 if(data.actions[1].callback == "reject") 773 { 774 775 } 776 777 } 778 }, 779 ] 780 }) 781 } 782 783 } 784 else if(msgtype=="ordA") 785 { 786 if(cpage.name !== 'viewaction') 787 { 788 var modal = myApp.modal({ 789 title: title, 790 text: message, 791 buttons: [ 792 { 793 text: data.actions[0].title, 794 onClick: function () { 795 if(data.actions[0].callback == "approve") 796 { 797 mainView.router.loadPage('viewaction.html?orderid='+orderid); 798 } 799 800 801 } 802 }, 803 { 804 text: data.actions[1].title, 805 bold: true, 806 onClick: function () { 807 if(data.actions[1].callback == "reject") 808 { 809 810 } 811 812 } 813 }, 814 ] 815 }) 816 } 817 818 } 819 else if(msgtype=="ordR") 820 { 821 if(cpage.name !== 'viewaction') 822 { 823 var modal = myApp.modal({ 824 title: title, 825 text: message, 826 buttons: [ 827 { 828 text: data.actions[0].title, 829 onClick: function () { 830 if(data.actions[0].callback == "approve") 831 { 832 mainView.router.loadPage('viewaction.html?orderid='+orderid); 833 } 834 835 836 } 837 }, 838 { 839 text: data.actions[1].title, 840 bold: true, 841 onClick: function () { 842 if(data.actions[1].callback == "reject") 843 { 844 845 } 846 847 } 848 }, 849 ] 850 }) 851 } 852 853 } 854 else if(msgtype=="ordD") 855 { 856 if(cpage.name !== 'viewaction') 857 { 858 var modal = myApp.modal({ 859 title: title, 860 text: message, 861 buttons: [ 862 { 863 text: data.actions[0].title, 864 onClick: function () { 865 if(data.actions[0].callback == "approve") 866 { 867 //var oid = data.order_id; 868 mainView.router.loadPage('viewaction.html?orderid='+orderid); 869 } 870 871 872 } 873 }, 874 { 875 text: data.actions[1].title, 876 bold: true, 877 onClick: function () { 878 if(data.actions[1].callback == "reject") 879 { 880 881 } 882 883 } 884 }, 885 ] 886 }) 887 } 888 889 } 890 else if(msgtype=="ordPD") 891 { 892 if(cpage.name !== 'viewaction') 893 { 894 var modal = myApp.modal({ 895 title: title, 896 text: message, 897 buttons: [ 898 { 899 text: data.actions[0].title, 900 onClick: function () { 901 if(data.actions[0].callback == "approve") 902 { 903 904 mainView.router.loadPage('viewaction.html?orderid='+orderid); 905 } 906 907 908 } 909 }, 910 { 911 text: data.actions[1].title, 912 bold: true, 913 onClick: function () { 914 if(data.actions[1].callback == "reject") 915 { 916 917 } 918 919 } 920 }, 921 ] 922 }) 923 } 924 925 }else{ 926 var modal = myApp.modal({ 927 title: title, 928 text: message, 929 buttons: [ 930 { 931 text: data.actions[0].title, 932 onClick: function () { 933 934 if(msgtype=="devAct") 935 { 936 mainView.router.loadPage('settings.html'); 937 } 938 else if(msgtype=="ua") 939 { 940 if(devicePlatform == "Android") 941 { 942 window.open('https://play.google.com/store/apps/details?id=com.cloudcatalogue.scvpl&hl=en'); 943 }else if(devicePlatform == "iOS") { 944 //window.open('https://itunes.apple.com/in/app/cloud-catalogue/id989624737'); 945 //var ref = cordova.ThemeableBrowser.open('https://itunes.apple.com/in/app/cloud-catalogue/id989624737', '_blank', 'location=yes', 'toolbar=yes','presentationstyle=pagesheet','toolbarposition=top','closebuttoncaption=back'); 946 var url = 'https://itunes.apple.com/in/app/cloud-catalogue/id989624737'; 947 openBrowser(url, ""); 948 } 949 } 950 951 else if(msgtype=="brandR") 952 { 953 //call brand page profile 954 mainView.router.loadPage('bprofile.html?bid='+brandid); 955 }else if(msgtype=="brandA") 956 { 957 //call brand page cat 958 mainView.router.loadPage('catalogues.html?bid='+brandid); 959 }else if(msgtype=="brandRej") 960 { 961 //call brand page profile 962 963 }else if(msgtype=="catR") 964 { 965 //brand profile 966 mainView.router.loadPage('request_cat.html?bid='+brandid); 967 }else if(msgtype=="catAcc") 968 { 969 //brand cat page 970 mainView.router.loadPage('catalogues.html?bid='+brandid); 971 }else if(msgtype=="catRev") 972 { 973 // brand profile page 974 mainView.router.loadPage('catalogues.html?bid='+brandid); 975 }else if(msgtype=="payP") 976 { 977 //payment page 978 mainView.router.loadPage('viewaction.html?orderid='+orderid); 979 }else if(msgtype=="payS") 980 { 981 982 }else if(msgtype=="payE") 983 { 984 //payment page 985 mainView.router.loadPage('payment.html'); 986 } 987 988 else{ 989 990 } 991 } 992 }, 993 { 994 text: data.actions[1].title, 995 bold: true, 996 onClick: function () { 997 998 } 999 }, 1000 ] 1001 }) 1002 myApp.swiper($$(modal).find('.swiper-container'), {pagination: '.swiper-pagination'}); 1003} 1004 1005 });
1006 1007 1008 push.on('error', function(e) { 1009 }); 1010} 1011 1012function approve(data){ 1013 data = data.additionalData; 1014 msgtype = data.msg_type; 1015 brandid = data.b_id; 1016 brandname = data.b_name; 1017 orderid = data.o_id; 1018 //console.log(msgtype); 1019 //console.log(brandid); 1020 //console.log(orderid); 1021 //console.log(brandname); 1022 1023 if(msgtype=="devAct") 1024 { 1025 mainView.router.loadPage('settings.html'); 1026 } 1027 else if(msgtype=="ua") 1028 { 1029 if(devicePlatform == "Android") 1030 { 1031 window.open('https://play.google.com/store/apps/details?id=com.cloudcatalogue.scvpl&hl=en'); 1032 }else if(devicePlatform == "iOS") { 1033 //window.open('https://itunes.apple.com/in/app/cloud-catalogue/id989624737'); 1034 //var ref = cordova.ThemeableBrowser.open('https://itunes.apple.com/in/app/cloud-catalogue/id989624737', '_blank', 'location=yes', 'toolbar=yes','presentationstyle=pagesheet','toolbarposition=top','closebuttoncaption=back'); 1035 var url = 'https://itunes.apple.com/in/app/cloud-catalogue/id989624737'; 1036 openBrowser(url, ""); 1037 } 1038 1039 } 1040 else if(msgtype=="mr") 1041 { 1042 mainView.router.loadPage("chat.html?brandid="+brandid+"&bname="+brandname); 1043 } 1044 else if(msgtype=="brandR") 1045 { 1046 //call brand page profile 1047 mainView.router.loadPage('bprofile.html?bid='+brandid); 1048 }else if(msgtype=="brandA") 1049 { 1050 //call brand page cat 1051 mainView.router.loadPage('catalogues.html?bid='+brandid); 1052 }else if(msgtype=="brandRej") 1053 { 1054 //call brand page profile 1055 }else if(msgtype=="catR") 1056 { 1057 //brand profile 1058 mainView.router.loadPage('request_cat.html?bid='+brandid); 1059 }else if(msgtype=="catAcc") 1060 { 1061 //brand cat page 1062 mainView.router.loadPage('catalogues.html?bid='+brandid); 1063 }else if(msgtype=="catRev") 1064 { 1065 // brand profile page 1066 mainView.router.loadPage('catalogues.html?bid='+brandid); 1067 }else if(msgtype=="payP") 1068 { 1069 //payment page 1070 mainView.router.loadPage('viewaction.html?orderid='+orderid); 1071 }else if(msgtype=="payS") 1072 { 1073 1074 }else if(msgtype=="payE") 1075 { 1076 //payment page 1077 mainView.router.loadPage('payment.html'); 1078 }else if(msgtype=="ordPA") 1079 { 1080 //call order details page 1081 mainView.router.loadPage('viewaction.html?orderid='+orderid); 1082 }else if(msgtype=="ordA") 1083 { 1084 //call order details page 1085 mainView.router.loadPage('viewaction.html?orderid='+orderid); 1086 }else if(msgtype=="ordR") 1087 { 1088 //call order details page 1089 mainView.router.loadPage('viewaction.html?orderid='+orderid); 1090 }else if(msgtype=="ordD") 1091 { 1092 //call order details page 1093 mainView.router.loadPage('viewaction.html?orderid='+orderid); 1094 }else if(msgtype=="ordPD") 1095 { 1096 //call order details page 1097 mainView.router.loadPage('viewaction.html?orderid='+orderid); 1098 } 1099 else{ 1100 1101 } 1102} 1103 1104function reject(data){
1105 if(data.additionalData.actions[1].callback == 'reject'){ //Catalogue Access 1106 //console.log("click reject"); 1107 } 1108} 1109 1110myApp.onPageInit('index', function (page) { 1111//console.log("call index"); 1112 branch.closeBanner(); 1113 $$('.getnotification').on('click', function (page) { 1114 myApp.showIndicator(); 1115 function imgError(image) { 1116 image.onerror = ""; 1117 image.src = "img/logo.png"; 1118 return true; 1119 } 1120 var flagval=0; 1121 //var notificationKey = new Firebase("https://fiery-fire-6430.firebaseio.com/notification/cloudcatalogue/"+userudid); 1122 univUrl.child("notification/cloudcatalogue/"+userudid).limitToLast(30).once('value', function (snapshot){ 1123 var a = snapshot.exists(); 1124 $$('#notificationid').html(''); 1125 if(a==true){ 1126 snapshot.forEach(function(newdata) { 1127 var noti = newdata.key(); 1128 //var notiddata = new Firebase("https://fiery-fire-6430.firebaseio.com/notification/cloudcatalogue/"+userudid+"/"+noti); 1129 univUrl.child("notification/cloudcatalogue/"+userudid+"/"+noti).once('value',function(snapshot){ 1130 var msgf = snapshot.val().msg_time; 1131 var deviceType = window.localStorage.getItem("devicePlatform"); 1132 1133 msgf = msgf.replace(/-/g, '/'); 1134 var msgtime = $.timeago(new Date(msgf)); 1135 var html = '<li class="item-content">'+ 1136 '<div class="item-media"><img src="'+snapshot.val().picture+'" height="75" width="75" onError="imgError(this);"/></div>'+ 1137 '<div class="item-inner">'+ 1138 '<div class="item-title-row">'+ 1139 '<div class="item-title">'+snapshot.val().title+'</div>'+ 1140 '</div>'+ 1141 '<div class="item-subtitle">'+msgtime+'</div>'+ 1142 '<div class="inner-class">'+snapshot.val().message+'</div>'+ 1143 '</div>'+ 1144 '</li>'; 1145 $$('#notificationid').prepend(html); 1146 flagval++; 1147 }); 1148 setTimeout(function(){ 1149 if(flagval == 0){ 1150 var html = '<li class="item-content">No notification available.</li>'; 1151 $$('#notificationid').html(html); 1152 } 1153 myApp.hideIndicator(); 1154 },1000); 1155 }); 1156 }else{ 1157 myApp.hideIndicator(); 1158 var html = '<li class="item-content">No notification available.</li>'; 1159 $$('#notificationid').html(html); 1160 } 1161 }); 1162 }); 1163 1164 $$('.chat-brands').on('click',function(){ 1165 myApp.showIndicator(); 1166 function imgError(image){ 1167 image.onerror = ""; 1168 image.src = "img/logo.png"; 1169 return true; 1170 } 1171 //Orderr Chat 1172 $$('#user-chat-brand').html(''); 1173 //var orderrChatKey = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/b357"); 1174 univUrl.child("brand/b357").once('value',function(helpsnap){ 1175 var orderrChatData = helpsnap.val(); 1176 var orderrChat = '<a href="chat.html?brandid=b357&bname='+orderrChatData.brand_name+'" class="item-link item-content">'+ 1177 '<div class="item-media"><img src="'+orderrChatData.cover_image_url+'" width="80" onError="imgError(this);"></div>'+ 1178 '<div class="item-inner">'+ 1179 '<div class="item-title">'+orderrChatData.brand_name+'</div>'+ 1180 '</div>'+ 1181 '</a>'; 1182 $$('#user-chat-brand').append(orderrChat); 1183 flagval++; 1184 }); 1185 var flagval=0; 1186 //var bchatls = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"); 1187 univUrl.child("baccess/").orderByChild(userudid+"/status").equalTo(2).once('value', function(snapshot){ 1188 1189 var b = snapshot.exists();
1190 if(b==true){ 1191 snapshot.forEach(function(newdata) { 1192 var bid = newdata.key(); 1193 //console.log(bid); 1194 //var branddata = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+bid); 1195 univUrl.child('brand/'+bid).once('value',function(snapshots){ 1196 var chatbUserData = snapshots.val(); 1197 if(chatbUserData.enabled_status == 1 || chatbUserData.brand_privacystatus == 0 ) 1198 { 1199 var chathtmls1 = '<a href="chat.html?brandid='+chatbUserData.brand_id+'&bname='+chatbUserData.brand_name+'" class="item-link item-content">'+ 1200 '<div class="item-media"><img src="'+chatbUserData.cover_image_url+'" width="80" onError="imgError(this);"></div>'+ 1201 '<div class="item-inner">'+ 1202 '<div class="item-title">'+chatbUserData.brand_name+'</div>'+ 1203 '</div>'+ 1204 '</a>'; 1205 $$('#user-chat-brand').append(chathtmls1); 1206 flagval++; 1207 } 1208 }); 1209 }); 1210 setTimeout(function(){ 1211 $$('img.lazy').trigger('lazy'); 1212 if(flagval == 0) 1213 { 1214 var html2 = '<li class="item-content">Add your favorite brand for chat</li>'; 1215 $$('#user-chat-brand').html(html2); 1216 } 1217 myApp.hideIndicator(); 1218 },1000); 1219 }else{ 1220 myApp.hideIndicator(); 1221 var html2 = '<li class="item-content">Add your favorite brand for chat</li>'; 1222 $$('#user-chat-brand').html(html2); 1223 } 1224 }); 1225 }); 1226 1227 var uname = window.localStorage.getItem("user_name"); 1228 $$('#show-user-name').html(uname); 1229 function imgError(image) { 1230 image.onerror = ""; 1231 image.src = "img/logo.png"; 1232 return true; 1233 } 1234}).trigger(); 1235 1236function contactform() { 1237 //var firebaseCount = new Firebase("https://fiery-fire-6430.firebaseio.com/contact/"+userudid); 1238 var formData = myApp.formToJSON('#contact_section'); 1239 1240 var subject = formData.subject; 1241 var message = formData.message; 1242 if(message.length > 0){ 1243 //var firebaseUser = new Firebase("https://fiery-fire-6430.firebaseio.com/contact/"+userudid ); 1244 univUrl.child('contact/'+userudid).push({ 1245 subject: subject, 1246 message: message, 1247 status:0, 1248 time:Firebase.ServerValue.TIMESTAMP 1249 }); 1250 $$('#message').val(""); 1251 1252 myApp.addNotification({ 1253 message: 'Your message was sent successfully. Thank you for contacting us!', 1254 hold: 3000, 1255 closeOnClick: false 1256 }); 1257 } else { 1258 myApp.alert("Please enter message."); 1259 } 1260} 1261 1262 /* ===== Login screen page events ===== */ 1263 $$('.login-screen').find('.signin').on('click', function () { 1264 myApp.showIndicator(); 1265 $("#mobileno").intlTelInput({ 1266 defaultCountry: "in", 1267 utilsScript: "js/utils.js" 1268 }); 1269 1270 var usermobile = $("#usermobile").intlTelInput("getNumber"); 1271 var usermobileslice = usermobile.slice(1); 1272 userudid = usermobileslice; 1273 //console.log('userudid......'+userudid); 1274 var username = usermobileslice+"@cloudcatalogue.in"; 1275 var password = $$('.login-screen').find('input[name="userpass"]').val(); 1276 // alert(usermobileslice); 1277 1278 if(username.length === 0){ 1279 myApp.hideIndicator(); 1280 myApp.alert("Please fill in your username!"); 1281 } else if(password.length === 0){ 1282 myApp.hideIndicator(); 1283 myApp.alert("Please fill in your password!"); 1284 } else{ 1285 //var ref = new Firebase("https://fiery-fire-6430.firebaseio.com/"); 1286 univUrl.authWithPassword({ 1287 email : username, 1288 password : password 1289 }, function(error, authData) { 1290 if (error) { 1291 myApp.hideIndicator(); 1292 myApp.alert('Entered Username & Password is wrong!'); 1293 } else { 1294 mainView.router.loadPage('index.html'); 1295 myApp.closeModal('.login-screen'); 1296 //var firebaseBrand = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/username"); 1297 univUrl.child("users/cc/"+userudid+"/username").on('value', function(snapshot){ 1298 window.localStorage.setItem("user_name",snapshot.val()); 1299 uname = snapshot.val(); 1300 $$('#show-user-name').html(snapshot.val()); 1301 }); 1302 1303 deviceData(userudid); 1304 setTimeout(function(){ 1305 //console.log("user offline stat1"); 1306 userOnlineOfflineStatus(userudid); 1307 var deviceudids = window.localStorage.getItem("deviceUUID"); 1308 $$.post('https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/gcmcloud.php', {action:'device',msgtype:'devAct', uuid:deviceudids, mobile:userudid}, function (data) { 1309 //console.log('Notification was sent'); 1310 }); 1311 var url = window.localStorage.getItem("homeLauncherUrl"); 1312 url = url; 1313 if(url){ 1314 var bid = url.split("bid="); 1315 bid = bid[1]; 1316 console.log("Home Launcher Redirection, Bid : " +bid); 1317 mainView.router.loadPage('bprofile.html?bid='+bid); 1318 window.localStorage.removeItem("homeLauncherUrl"); 1319 } else{ 1320 console.log("Without HomeLaucher"); 1321 } 1322 1323 },3000); 1324 deviceData(userudid); 1325 callforbranch(); 1326 myApp.hideIndicator(); 1327 } 1328 }); 1329 } 1330 }); 1331 1332 1333/********************************* Reset Password ***********************************/ 1334 $$('.forgot-password').find('.sub').on('click', function () { 1335 myApp.showIndicator(); 1336 var mobileno = $("#usermobilereset").intlTelInput("getNumber"); 1337 var usermobile = mobileno.slice(1); 1338 var mobilenolast = mobileno.slice(-10); 1339 if(usermobile.length < 11) 1340 { 1341 myApp.hideIndicator();
1342 myApp.alert("Kindly enter a valid Mobile No.") 1343 } 1344 else 1345 { 1346 $.ajax({ 1347 url: 'https://appsforbusiness.in/cloudcatalogue/process/getjsonccmanager.php', 1348 type: 'POST', 1349 data: {mobileno:mobileno,action:'getUserPassword'}, 1350 success: function (data) 1351 { 1352 var obj = JSON.parse(data); 1353 if(obj.message == 'success') 1354 { 1355 myApp.hideIndicator(); 1356 genOTPForget(); 1357 } 1358 else 1359 { 1360 myApp.hideIndicator(); 1361 myApp.alert("It seems your account does not exist. Please enter the correct mobile no."); 1362 } 1363 } 1364 }); 1365 1366 function genOTPForget() 1367 { 1368 myApp.showPreloader('Please wait sending you an OTP, on entered mobile no.!'); 1369 1370 var settings = { 1371 "async": true, 1372 "crossDomain": true, 1373 "url": "https://appsforbusiness.in/cloudcatalogue/process/getjsonccmanager.php?action=otpForget&mobileno="+usermobile, 1374 "method": "GET", 1375 "headers": {} 1376 } 1377 1378 $.ajax(settings).done(function (response) { 1379 myApp.hidePreloader(); 1380 otpCheckForget(); 1381 }); 1382 } 1383 1384 function otpCheckForget() 1385 { 1386 myApp.modal({ 1387 title: 'Forget Password', 1388 text: 'Please enter the 6 digit OTP received as SMS (Indian No.) or Registered Email.', 1389 afterText: '<div class="input-field"><input type="tel" id="otpnumber" placeholder="Enter 6 digit OTP" class="modal-text-input"></div>', 1390 buttons: [ 1391 { 1392 text: 'Resend OTP', 1393 onClick: function() { 1394 1395 genOTPForget(); 1396 } 1397 }, 1398 { 1399 text: 'Submit', 1400 onClick: function() { 1401 var value = $$('#otpnumber').val(); 1402 //console.log('Your have entered "' + value + '" as OTP'); 1403 if(value.length < 1) 1404 { 1405 myApp.addNotification({ 1406 title: 'Orderr', 1407 message: 'Please enter an OTP!', 1408 hold: 3000, 1409 }); 1410 otpCheckForget(); 1411 } 1412 else if(value.length != 6) 1413 { 1414 myApp.addNotification({ 1415 title: 'Orderr', 1416 message: 'Please enter a correct OTP!', 1417 hold: 3000, 1418 }); 1419 otpCheckForget(); 1420 } 1421 else 1422 { 1423 var nsettings = { 1424 "async": true, 1425 "crossDomain": true, 1426 "url": "https://appsforbusiness.in/cloudcatalogue/process/getjsonccmanager.php?action=otpCCForgetVerify&mobileno="+usermobile+"&otp="+value, 1427 "method": "GET", 1428 "headers": {} 1429 } 1430 $.ajax(nsettings).done(function (data){ 1431 var ndata = JSON.parse(data); 1432 var message = ndata.message; 1433 var oldpassno = ndata.password; 1434 //console.log(data); 1435 if(message == "success") 1436 { 1437 myApp.hideIndicator(); 1438 document.getElementById("usermob").style.display = "none"; 1439 document.getElementById("subbutton").style.display = "none"; 1440 document.getElementById("newpass").style.display = "block"; 1441 document.getElementById("newpass1").style.display = "block"; 1442 document.getElementById("resetbutton").style.display = "block"; 1443 $('#userpassreset').val(oldpassno); 1444 myApp.alert("Please enter new password."); 1445 } 1446 else 1447 { 1448 myApp.addNotification({ 1449 title: 'Orderr', 1450 message: 'Please enter a correct OTP!', 1451 hold: 3000, 1452 }); 1453 otpCheckForget(); 1454 } 1455 }); 1456 } 1457 } 1458 }, 1459 { 1460 text: 'Cancel', 1461 onClick: function() { 1462 myApp.hideIndicator(); 1463 } 1464 }, 1465 ] 1466 }) 1467 } 1468 1469 } 1470 }); 1471 1472 $$('.forgot-password').find('.reset').on('click', function () { 1473 myApp.showIndicator(); 1474 var usermobile = $("#usermobilereset").intlTelInput("getNumber"); 1475 var mobileno = usermobile.slice(1); 1476 deviceData(mobileno); 1477 var mobilenolast = usermobile.slice(-10); 1478 var username = mobileno+"@cloudcatalogue.in"; 1479 //console.log("mob: "+usermobile+", mobno: "+mobileno+", moblast: "+mobilenolast+", mail: "+username); 1480 var password = $$('.forgot-password').find('input[name="userpassreset"]').val(); 1481 var password1 = $$('.forgot-password').find('input[name="userpassreset1"]').val(); 1482 var password2 = $$('.forgot-password').find('input[name="userpassreset2"]').val(); 1483 //console.log("mobile: "+usermobile+" pass: "+password+" pass1: "+password1); 1484 if(password.length < 6 && password1.length < 6) 1485 { 1486 myApp.hideIndicator();
1487 myApp.alert("Kindly input mininum 6 character password.") 1488 } 1489 else if(password1 !== password2) 1490 { 1491 myApp.hideIndicator(); 1492 myApp.alert("Password Mismatch"); 1493 } 1494 else 1495 { 1496 //var ref = new Firebase("https://fiery-fire-6430.firebaseio.com"); 1497 univUrl.changePassword({ 1498 email: username, 1499 oldPassword: password, 1500 newPassword: password1 1501 }, function (error) { 1502 if (error) { 1503 switch (error.code) { 1504 case "INVALID_PASSWORD": 1505 myApp.hideIndicator(); 1506 myApp.alert("The specified user account password is incorrect."); 1507 break; 1508 case "INVALID_USER": 1509 myApp.hideIndicator(); 1510 myApp.alert("The specified user account does not exist."); 1511 break; 1512 default: 1513 myApp.hideIndicator(); 1514 myApp.alert("Password could not be updated. Please try again!"); 1515 } 1516 } else { 1517 var devicetoken = window.localStorage.getItem("device_token"); 1518 var model = window.localStorage.getItem("deviceModel"); 1519 var platform = window.localStorage.getItem("devicePlatform"); 1520 var uuid = window.localStorage.getItem("deviceUUID"); 1521 var version = window.localStorage.getItem("deviceVersion"); 1522 $.ajax({
1523 url: 'https://appsforbusiness.in/cloudcatalogue/process/getjsonccmanager.php', 1524 type: 'POST', 1525 data: {mobileno:mobileno,pass:password1,platform:platform,devicetoken:devicetoken,uuid:uuid,model:model,version:version,action:'userupdate'}, 1526 success: function (data) 1527 { 1528 var obj = JSON.parse(data); 1529 if(obj.message == 'Profile updated') 1530 { 1531 //console.log('Password updated.'); 1532 myApp.closeModal('.popup-reset'); 1533 myApp.loginScreen(); 1534 } 1535 } 1536 }); 1537 myApp.hideIndicator(); 1538 myApp.alert('Password changed successfully! Please signin with your new password.'); 1539 1540 } 1541 }); 1542 } 1543 }); 1544 1545 $$('.login-screen').find('.signup').on('click', function () { 1546 myApp.closeModal(); 1547 mainView.loadPage('registeremail.html'); 1548 }); 1549 1550 function nearby_user() { 1551 if (navigator.geolocation) { 1552 navigator.geolocation.getCurrentPosition(showPositionlatlongusernear); 1553 } else { 1554 } 1555 } 1556 function showPositionlatlongusernear(position){ 1557 window.localStorage.setItem("latitude",position.coords.latitude); 1558 window.localStorage.setItem("longitude",position.coords.longitude); 1559 } 1560 1561 function resetSignin(){ 1562 myApp.closeModal('.popup-reset'); 1563 myApp.loginScreen(); 1564 } 1565 1566 function signinmodal(){ 1567 //console.log('signinmodal close;'); 1568 var cpage = mainView.activePage; 1569 //console.log(cpage); 1570 if(cpage.name == 'mail-register-page'){ 1571 mainView.router.back(); 1572 myApp.loginScreen(); 1573 } 1574 } 1575 1576//********************* Registration Authentication ***********************// 1577 function call_verify(usermobile){ 1578 var urltest = "https://www.cognalys.com/api/v1/otp/?app_id=9ab19c4e47824ee39cc946e&access_token=2bd3f9fa7d40ac52b8b999b751d009b27a6bd4a7&mobile="+usermobile; 1579 $$.get(urltest,function(data){ 1580 var result = $.parseJSON(data); 1581 var getkey = result.keymatch; 1582 var getmob = result.mobile; 1583 var getotp = result.otp_start; 1584 myApp.prompt('Enter the last five digit of the number (+177420) from which you got the missed call in this box below !', 1585 function (value) { 1586 var getotp = "https://www.cognalys.com/api/v1/otp/confirm/?app_id=9ab19c4e47824ee39cc946e&access_token=2bd3f9fa7d40ac52b8b999b751d009b27a6bd4a7&keymatch="+getkey+"&otp="+getotp; 1587 $$.get(getotp,function(data){ 1588 //console.log(data); 1589 var resultsts = $.parseJSON(data); 1590 //console.log(resultsts.status); 1591 if(resultsts.status == "success") 1592 { 1593 }else{ 1594 } 1595 }); 1596 }, 1597 function (value) { 1598 } 1599 ); 1600 }); 1601 } 1602 1603 // Register Option Page 1604 $$('.login-screen').find('.signup').on('click', function () { 1605 myApp.closeModal(); 1606 mainView.loadPage('registeremail.html'); 1607 }); 1608 1609//*********************** Registration Authentication ***********************// 1610 myApp.onPageInit('mail-register-page', function(page){ 1611 $("#mobileno").intlTelInput({ 1612 defaultCountry: "in", 1613 utilsScript: "js/utils.js" 1614 }); 1615 var userCount =0; 1616 //var firebaseUcount = new Firebase("https://fiery-fire-6430.firebaseio.com/counter/usercount"); 1617 univUrl.child("counter/usercount/").on("value", function(snap) { 1618 userCount = snap.val().counter; 1619 }); 1620 // var dmob = window.localStorage.getItem("dmob"); 1621 // if(dmob){ 1622 // if(dmob =="Not Available"){ 1623 1624 // }else{ 1625 // $$("#mobileno").val(dmob.substr(dmob.length - 10)); 1626 // } 1627 // } 1628 $$('.verify').on('click', function(){ 1629 /*var deviceType = device.platform; 1630 if(deviceType === 'Android' || deviceType === 'android'){ 1631 var userRegMob = $$("#mobileno").val(); 1632 userRegMob = userRegMob.replace(/\s/g, ""); 1633 var checkUserNum = window.localStorage.getItem("dmob"); 1634 checkUserNum = checkUserNum.substr(checkUserNum.length - 10); 1635 console.log("Number for registration : "+userRegMob+ " and length is :" +userRegMob.length+ " lS num :" +checkUserNum); 1636 if((userRegMob.length == 10) && (checkUserNum == userRegMob)){ 1637 myApp.alert("Do you want to register with " +userRegMob); 1638 var formData = myApp.formToJSON('#mobileregistration'); 1639 var adm_name = formData.admin_name; 1640 var usermobile = $("#mobileno").intlTelInput("getNumber"); 1641 var mobileno = usermobile.slice(1); 1642 var mobilenolast = usermobile.slice(-10); 1643 var email_id = mobileno+"@cloudcatalogue.in"; 1644 //var conv_mail = formData.conv_mail; 1645 var currentTime = getDateTime(); 1646 var pass = formData.login_pass; 1647 var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 1648 1649 if(adm_name.length < 1){
1650 myApp.alert("Kindly input Your Name."); 1651 } else if(usermobile.length< 12){ 1652 myApp.alert("Kindly input a valid Mobile No. to SignUp.") 1653 } 1654// else if(!filter.test(conv_mail)) 1655// { 1656// myApp.alert("Kindly provide a valid email address."); 1657// } 1658 else if(pass.length < 6){ 1659 myApp.alert("Kindly input minimum 6 character password."); 1660 } else{ 1661 window.localStorage.setItem("mobilenolast",mobilenolast); 1662 1663 1664 $$.ajax({ 1665 url: 'https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/getMobile.php', 1666 type: 'POST', 1667 data: {mobileno:mobileno,usertype:'cc'}, 1668 success: function (data){ 1669 var obj = JSON.parse(data); 1670 if(obj.status == 'success'){ 1671 myApp.alert('User already registered, please login.'); 1672 } else{ 1673 univUrl.createUser({ 1674 email : email_id, 1675 password : pass 1676 }, function(error, userData){ 1677 if (error) { 1678 //console.log("User already registered please login!", error); 1679 } else{ 1680 //var ref = new Firebase("https://fiery-fire-6430.firebaseio.com/"); 1681 univUrl.authWithPassword({ 1682 email : email_id, 1683 password : pass 1684 }, function(error, authData){ 1685 if(error){ 1686 myApp.alert(error); 1687 }else{ 1688 //var refMobile = new Firebase("https://fiery-fire-6430.firebaseio.com/missed/"+mobilenolast); 1689 univUrl.child('/missed/'+mobilenolast).set({ 1690 mobile: mobilenolast, 1691 time: currentTime, 1692 verified: "done", 1693 }); 1694 deviceData(mobileno); 1695 var ref = ""; 1696 branch.data(function(err, data){ 1697 if(!err){ 1698 var stridata = JSON.parse(data.data); 1699 var referalNo = stridata.referrer; 1700 if(referalNo){ 1701 ref = referalNo; 1702 //var friendKey = new Firebase("https://fiery-fire-6430.firebaseio.com/referredfriend/"+referalNo+"/"+mobileno); 1703 univUrl.child("/referredfriend/"+referalNo+"/"+mobileno).once("value", function(friendsnap){ 1704 var existance = friendsnap.exists();
1705 if(existance){ 1706 univUrl.child("referredfriend/"+referalNo+"/"+mobileno).update({ 1707 status: 1, 1708 time: Firebase.ServerValue.TIMESTAMP 1709 }); 1710 } else { 1711 univUrl.child("referredfriend/"+referalNo+"/"+mobileno).set({ 1712 status: 1, 1713 time: Firebase.ServerValue.TIMESTAMP 1714 }); 1715 } 1716 }); 1717 } 1718 } else{ 1719 //console.log('This is worng : '+err); 1720 } 1721 }); 1722 1723 var devicetoken = window.localStorage.getItem("device_token"); 1724 var model = window.localStorage.getItem("deviceModel"); 1725 var platform = window.localStorage.getItem("devicePlatform"); 1726 var uuid = window.localStorage.getItem("deviceUUID"); 1727 var version = window.localStorage.getItem("deviceVersion"); 1728 $.ajax({
1729 url: 'https://appsforbusiness.in/cloudcatalogue/process/getjsonccmanager.php', 1730 type: 'POST', 1731 data: {mobileno:mobileno,name:adm_name,pass:pass,platform:platform,devicetoken:devicetoken,uuid:uuid,model:model,version:version,uid:userData.uid,action:'userregister'}, 1732 success: function (data){ 1733 if(data.message == 'Profile updated'){ 1734 } else{ 1735 } 1736 } 1737 }); 1738 //var myUserRef = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+mobileno); 1739 univUrl.child("users/cc/"+mobileno).set({ 1740 email: email_id, 1741 role: "user", 1742 '.priority': email_id, 1743 mobile:mobileno, 1744 username: adm_name, 1745// conversation_mail: conv_mail, 1746 billing_address: "", 1747 autofill_address: "", 1748 city:"", 1749 state:"", 1750 pin:"", 1751 country:"", 1752 locality:"", 1753 referrer:ref, 1754 billing_name: adm_name, 1755 uid:userData.uid, 1756 gender: "", 1757 birth_date: "", 1758 time_created: Firebase.ServerValue.TIMESTAMP 1759 }); 1760 setTimeout(function(){ 1761 userudid = mobileno; 1762 useremail = email_id; 1763 window.localStorage.setItem("userudid",userudid); 1764 window.localStorage.setItem("useremail",useremail); 1765 //var firebaseBrand = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/username"); 1766 univUrl.child("users/cc/"+userudid+"/username").on('value', function(snapshot){ 1767 window.localStorage.setItem("user_name",snapshot.val()); 1768 uname = snapshot.val(); 1769 $$('#show-user-name').html(snapshot.val()); 1770 }); 1771 1772 //var userexistance = new Firebase("https://fiery-fire-6430.firebaseio.com/missed/"+mobilenolast); 1773 univUrl.child("missed/"+mobilenolast).on('value', function(snap){ 1774 var a = snap.exists();
1775 if(a == true) 1776 { 1777 univUrl.child("missed/"+mobilenolast).remove(); 1778 } 1779 }); 1780 //var userexistance1 = new Firebase("https://fiery-fire-6430.firebaseio.com/missedit/"+mobilenolast); 1781 univUrl.child("missedit/"+mobilenolast).on('value', function(snap1){ 1782 var b = snap1.exists(); 1783 if(b == true) 1784 { 1785 univUrl.child("missedit/"+mobilenolast).remove(); 1786 } 1787 }); 1788 deviceData(userudid); 1789 },200); 1790 1791 userCount++; 1792 //var firebaseCount = new Firebase("https://fiery-fire-6430.firebaseio.com/counter/usercount"); 1793 univUrl.child("counter/usercount").update({ 1794 counter:userCount, 1795 }); 1796 //var firebaseBrand = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/username"); 1797 univUrl.child("users/cc/"+userudid+"/username").on('value', function(snapshot){ 1798 window.localStorage.setItem("user_name",snapshot.val()); 1799 uname = snapshot.val(); 1800 $$('#show-user-name').html(snapshot.val()); 1801 }); 1802 1803 setTimeout(function(){ 1804 //var firebaseusername = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+mobileno+"/username"); 1805 univUrl.child("users/cc/"+mobileno+"/username").on('value', function(snapshot){ 1806 var uname = window.localStorage.setItem("user_name",snapshot.val()); 1807 $$('#show-user-name').html(snapshot.val()); 1808 }); 1809 },3000); 1810 deviceData(userudid); 1811 myApp.hidePreloader(); 1812 userudid = mobileno; 1813 //console.log("create user udid...."+userudid); 1814 // mainView.router.loadPage('firstprofile.html'); 1815 mainView.router.loadPage('index.html'); 1816 } 1817 }); 1818 } 1819 }); 1820 } 1821 } 1822 }); 1823 } 1824 } 1825 } else {*/ 1826 //$$("#mobileno").val(""); 1827 var mob_number = "+918000011822"; 1828 var formData = myApp.formToJSON('#mobileregistration'); 1829 var adm_name = formData.admin_name; 1830 var usermobile = $("#mobileno").intlTelInput("getNumber"); 1831 var mobileno = usermobile.slice(1); 1832 var mobilenolast = usermobile.slice(-10); 1833 var email_id = mobileno+"@cloudcatalogue.in"; 1834 //var conv_mail = formData.conv_mail; 1835 var currentTime = getDateTime(); 1836 var pass = formData.login_pass; 1837 var currentStatus = ''; 1838 var verifyStatus=''; var verifyStatus1=''; 1839 function call_verify() 1840 { 1841 myApp.confirm('Seems like your device is unable to make a call, should we try another alternate to give you a missed call to verify your mobile ?', 1842 function () { 1843 var urltest = "https://www.cognalys.com/api/v1/otp/?app_id=9ab19c4e47824ee39cc946e&access_token=2bd3f9fa7d40ac52b8b999b751d009b27a6bd4a7&mobile="+usermobile; 1844 $$.get(urltest,function(data) 1845 { 1846 var result = $.parseJSON(data); 1847 var status = result.status; 1848 var getkey = result.keymatch; 1849 var getmob = result.mobile; 1850 var getotp = result.otp_start; 1851 if(status=="success"){ 1852 myApp.prompt('Enter the last five digit of the number ('+getotp+') from which you got the missed call', 1853 function (value) { 1854 var getotpr = "https://www.cognalys.com/api/v1/otp/confirm/?app_id=9ab19c4e47824ee39cc946e&access_token=2bd3f9fa7d40ac52b8b999b751d009b27a6bd4a7&keymatch="+getkey+"&otp="+getotp+value; 1855 //console.log(getotpr); 1856 $$.get(getotpr,function(data) 1857 { 1858 //console.log(data); 1859 var resultsts = $.parseJSON(data); 1860 if(resultsts.status == "success") 1861 { 1862 setTimeout(function(){ 1863 createuser1(); 1864 },3000); 1865 myApp.alert("Congratulations you are verified! Now connect with brands by adding Brand Code, Explore Nearby Brands or Check Brand Invites."); 1866 }else{ 1867 } 1868 }); 1869 }, 1870 function (value) { 1871 }); 1872 } 1873 }); 1874 }, 1875 function () { 1876 myApp.alert('Please verify your mobile to register'); 1877 } 1878 ); 1879 myApp.hidePreloader(); 1880 } 1881 function createuser(){ 1882 //console.log("Trying to Create User"); 1883 //var refMobile = new Firebase("https://fiery-fire-6430.firebaseio.com/missed/"+mobilenolast); 1884 univUrl.child('missed/'+mobilenolast).on('value', function(snap){ 1885 var b = snap.exists();
1886 if(b==true){ 1887 //console.log("User log exists. Checking if user has given missed call"); 1888 var currentStatus = snap.val().verified; 1889 1890 if(currentStatus=="pending" || currentStatus == "done"){ 1891 //console.log("User has given missed call, trying to create the user now"); 1892 //console.log("create user email"+email_id); 1893 //var refAuth = new Firebase("https://fiery-fire-6430.firebaseio.com/"); 1894 univUrl.createUser({ 1895 email : email_id, 1896 password : pass 1897 }, function(error, userData){ 1898 if (error) { 1899 //console.log("User already registered please login!", error); 1900 } else{ 1901 //var ref = new Firebase("https://fiery-fire-6430.firebaseio.com/"); 1902 univUrl.authWithPassword({ 1903 email : email_id, 1904 password : pass 1905 }, function(error, authData){ 1906 if(error){ 1907 myApp.alert(error); 1908 }else{ 1909 //var refMobile = new Firebase("https://fiery-fire-6430.firebaseio.com/missed/"+mobilenolast); 1910 univUrl.child('missed/'+mobilenolast).set({ 1911 mobile: mobilenolast, 1912 time: currentTime, 1913 verified: "done", 1914 }); 1915 1916 deviceData(mobileno); 1917 1918 var ref = ""; 1919 branch.data(function(err, data){ 1920 if(!err){ 1921 //console.log(data); 1922 //console.log('This is done : '+JSON.stringify(data)); 1923 var stridata = JSON.parse(data.data); 1924 1925 var referalNo = stridata.referrer; 1926 //console.log(referalNo); 1927 if(referalNo){ 1928 ref = referalNo; 1929 //var friendKey = new Firebase("https://fiery-fire-6430.firebaseio.com/referredfriend/"+referalNo+"/"+mobileno); 1930 univUrl.child("referredfriend/"+referalNo+"/"+mobileno).once("value", function(friendsnap){ 1931 var existance = friendsnap.exists();
1932 if(existance){ 1933 univUrl.child("referredfriend/"+referalNo+"/"+mobileno).update({ 1934 status: 1, 1935 time: Firebase.ServerValue.TIMESTAMP 1936 }); 1937 } else { 1938 univUrl.child("referredfriend/"+referalNo+"/"+mobileno).set({ 1939 status: 1, 1940 time: Firebase.ServerValue.TIMESTAMP 1941 }); 1942 } 1943 }); 1944 } 1945 } else { 1946 //console.log('This is worng : '+err); 1947 } 1948 }); 1949 //console.log('call regisster mobileno...'+mobileno); 1950 var devicetoken = window.localStorage.getItem("device_token"); 1951 var model = window.localStorage.getItem("deviceModel"); 1952 var platform = window.localStorage.getItem("devicePlatform"); 1953 var uuid = window.localStorage.getItem("deviceUUID"); 1954 var version = window.localStorage.getItem("deviceVersion"); 1955 $.ajax({
1956 url: 'https://appsforbusiness.in/cloudcatalogue/process/getjsonccmanager.php', 1957 type: 'POST', 1958 data: {mobileno:mobileno,name:adm_name,pass:pass,platform:platform,devicetoken:devicetoken,uuid:uuid,model:model,version:version,uid:userData.uid,action:'userregister'}, 1959 success: function (data) 1960 { 1961 if(data.message == 'Profile updated') 1962 { 1963 //console.log("Php data saved."); 1964 }else{ 1965 //console.log("Php data could not be saved."); 1966 } 1967 } 1968 }); 1969 //console.log("conv_mail..."+conv_mail); 1970 //var myUserRef = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+mobileno); 1971 univUrl.child("users/cc/"+mobileno).set({ 1972 email: email_id, 1973 role: "user", 1974 '.priority': email_id, 1975 mobile:mobileno, 1976 username: adm_name, 1977// conversation_mail: conv_mail, 1978 billing_address: "", 1979 autofill_address: "", 1980 city:"", 1981 state:"", 1982 pin:"", 1983 country:"", 1984 locality:"", 1985 referrer:ref, 1986 billing_name: adm_name, 1987 uid:userData.uid, 1988 gender: "", 1989 birth_date: "", 1990 time_created: Firebase.ServerValue.TIMESTAMP 1991 }); 1992 setTimeout(function(){ 1993 userudid = mobileno; 1994 useremail = email_id; 1995 window.localStorage.setItem("userudid",userudid); 1996 window.localStorage.setItem("useremail",useremail); 1997 //var firebaseBrand = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/username"); 1998 univUrl.child("users/cc/"+userudid+"/username").on('value', function(snapshot){ 1999 window.localStorage.setItem("user_name",snapshot.val()); 2000 uname = snapshot.val(); 2001 $$('#show-user-name').html(snapshot.val()); 2002 }); 2003 2004 //var userexistance = new Firebase("https://fiery-fire-6430.firebaseio.com/missed/"+mobilenolast); 2005 univUrl.child("missed/"+mobilenolast).on('value', function(snap){ 2006 var a = snap.exists();
2007 if(a == true) 2008 { 2009 univUrl.child("missed/"+mobilenolast).remove(); 2010 } 2011 }); 2012 //var userexistance1 = new Firebase("https://fiery-fire-6430.firebaseio.com/missedit/"+mobilenolast); 2013 univUrl.child("missedit/"+mobilenolast).on('value', function(snap1){ 2014 var b = snap1.exists(); 2015 if(b == true) 2016 { 2017 univUrl.child("missedit/"+mobilenolast).remove(); 2018 } 2019 }); 2020 deviceData(userudid); 2021 },200); 2022 2023 userCount++; 2024 //var firebaseCount = new Firebase("https://fiery-fire-6430.firebaseio.com/counter/usercount"); 2025 univUrl.child("counter/usercount").update({ 2026 counter:userCount, 2027 }); 2028 //var firebaseBrand = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/username"); 2029 univUrl.child("users/cc/"+userudid+"/username").on('value', function(snapshot){ 2030 window.localStorage.setItem("user_name",snapshot.val()); 2031 uname = snapshot.val(); 2032 $$('#show-user-name').html(snapshot.val()); 2033 }); 2034 2035 setTimeout(function(){ 2036 //var firebaseusername = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+mobileno+"/username"); 2037 univUrl.child("users/cc/"+mobileno+"/username").on('value', function(snapshot){ 2038 var uname = window.localStorage.setItem("user_name",snapshot.val()); 2039 $$('#show-user-name').html(snapshot.val()); 2040 }); 2041 },3000); 2042 deviceData(userudid); 2043 myApp.hidePreloader(); 2044 userudid = mobileno; 2045 //console.log("create user udid...."+userudid); 2046 // mainView.router.loadPage('firstprofile.html'); 2047 mainView.router.loadPage('index.html'); 2048 } 2049 }); 2050 } 2051 }); 2052 } 2053 }else{ 2054 call_verify(); 2055 } 2056 }); 2057 } 2058 2059 //var userexistance = new Firebase("https://fiery-fire-6430.firebaseio.com/missed/"+mobilenolast); 2060 univUrl.child("missed/"+mobilenolast).on('value', function(snap){ 2061 var a = snap.exists();
2062 if(a == true) 2063 { 2064 verifyStatus = snap.val().verified; 2065 //console.log('verifyStatus..'+verifyStatus); 2066 if(verifyStatus == 'done' || verifyStatus1 == 'done') 2067 { 2068 createuser(); 2069 } 2070 } 2071 }); 2072 2073 //var userexistance1 = new Firebase("https://fiery-fire-6430.firebaseio.com/missedit/"+mobilenolast); 2074 univUrl.child("missedit/"+mobilenolast).once('value', function(snap1){ 2075 var b = snap1.exists(); 2076 if(b == true) 2077 { 2078 verifyStatus1 = snap1.val().verified; 2079 } 2080 }); 2081 2082 setTimeout(function(){ 2083 if(verifyStatus == 'done' || verifyStatus1 == 'done'){ 2084 createuser(); 2085 myApp.alert('Your number is already registered. Please SignIn.'); 2086 } else{ 2087 call_verify(); 2088 //Verify Call Function ends here 2089 2090 var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 2091 2092 if(adm_name.length < 1){ 2093 myApp.alert("Kindly input Your Name."); 2094 } else if(usermobile.length< 12){ 2095 myApp.alert("Kindly input a valid Mobile No. to SignUp.") 2096 } 2097// else if(!filter.test(conv_mail)) 2098// { 2099// myApp.alert("Kindly provide a valid email address."); 2100// } 2101 else if(pass.length < 6) 2102 { 2103 myApp.alert("Kindly input minimum 6 character password."); 2104 }else{ 2105 window.localStorage.setItem("mobilenolast",mobilenolast); 2106 2107 2108 $$.ajax({ 2109 url: 'https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/getMobile.php', 2110 type: 'POST', 2111 data: {mobileno:mobileno,usertype:'cc'}, 2112 success: function (data) 2113 { 2114 var obj = JSON.parse(data); 2115 console.log(obj); 2116 if(obj.status == 'success') 2117 { 2118 myApp.alert('User already registered, please login.'); 2119 }else{ 2120 2121 2122 genOTP(); 2123 function genOTP() 2124 { 2125 console.log("last"+mobilenolast); 2126 console.log("last"+dmob); 2127 if(mobilenolast==dmob){ 2128 2129 $$.ajax({ 2130 url: 'https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/otpVerify.php', 2131 type: 'POST', 2132 data: {mobile:mobilenolast}, 2133 success: function (data) 2134 { 2135 myApp.alert("Congratulations! You are auto verified."); 2136 }, 2137 error: function (data){ 2138 2139 } 2140 }); 2141 }else{ 2142 myApp.showPreloader('Please wait sending you an OTP, on entered mobile no.!'); 2143 startWatch(); 2144 var settings = { 2145 "async": true, 2146 "crossDomain": true, 2147 "url": "https://appsforbusiness.in/cloudcatalogue/process/getjsonccmanager.php?action=otpSave&mobileno="+mobilenolast, 2148 "method": "GET", 2149 "headers": {} 2150 } 2151 2152 $.ajax(settings).done(function (response) { 2153 myApp.hidePreloader(); 2154 otpCheck(); 2155 }); 2156 } 2157 } 2158 2159 2160 2161 function otpCheck() 2162 { 2163 myApp.modal({ 2164 title: 'Mobile Verification', 2165 text: 'Please enter the 4 digit OTP received as SMS on Indian Numbers. For International try Miss Call.', 2166 afterText: '<div class="input-field"><input type="tel" id="otpnumber" placeholder="Enter 4 digit OTP" class="modal-text-input"></div>', 2167 buttons: [ 2168 {
2169 text: 'Resend OTP', 2170 onClick: function() { 2171 myApp.alert('Resend OTP!'); 2172 genOTP(); 2173 } 2174 }, 2175 { 2176 text: 'Submit', 2177 onClick: function() { 2178 var value = $$('#otpnumber').val(); 2179 //console.log('Your have entered "' + value + '" as OTP'); 2180 if(value.length < 1) 2181 { 2182 myApp.addNotification({ 2183 title: 'Orderr', 2184 message: 'Please enter an OTP!', 2185 hold: 3000, 2186 }); 2187 otpCheck(); 2188 } 2189 else if(value.length != 4) 2190 { 2191 myApp.addNotification({ 2192 title: 'Orderr', 2193 message: 'Please enter a correct OTP!', 2194 hold: 3000, 2195 }); 2196 otpCheck(); 2197 } 2198 else 2199 { 2200 var nsettings = { 2201 "async": true, 2202 "crossDomain": true, 2203 "url": "https://appsforbusiness.in/cloudcatalogue/process/getjsonccmanager.php?action=otpVerify&mobileno="+mobilenolast+"&otp="+value, 2204 "method": "GET", 2205 "headers": {} 2206 } 2207 $.ajax(nsettings).done(function (data){ 2208 var ndata = JSON.parse(data); 2209 var message = ndata.message; 2210 //console.log(data); 2211 if(message == "success") 2212 { 2213 2214 } 2215 else 2216 { 2217 myApp.addNotification({ 2218 title: 'Orderr', 2219 message: 'Please enter a correct OTP!', 2220 hold: 3000, 2221 }); 2222 otpCheck(); 2223 } 2224 }); 2225 // Do second request 2226 } 2227 } 2228 }, 2229 { 2230 text: 'Miss Call', 2231 onClick: function() { 2232 myApp.alert('You need to verify your mobile. Try verify via missed call instead.'); 2233 trycall(); 2234 } 2235 }, 2236 ] 2237 }) 2238 } 2239 2240 2241 } 2242 2243 } 2244 2245 }); 2246 function trycall() 2247 { 2248 myApp.alert('Allow App to make an auto miss call to verify your mobile. In case your registered no. is in some other device, kindly make a call from registered no. at +918000011822 (Toll Free)'); 2249 myApp.showPreloader('Verifying !! May take upto 60 Seconds.'); 2250 window.plugins.CallNumber.callNumber(onMGSuccess, onMGError, mob_number); 2251 } 2252 2253 function onMGSuccess() 2254 { 2255 //console.log("Call success!!"); 2256 //var mver = new Firebase("https://fiery-fire-6430.firebaseio.com/missed/"+mobilenolast); 2257 univUrl.child("missed/"+mobilenolast).on('value', function(snap){ 2258 var a = snap.exists();
2259 //console.log(a); 2260 if(a == true) 2261 { 2262 var verifyStatus = snap.val().verified; 2263 //console.log(verifyStatus); 2264 if(verifyStatus=="done"){ 2265 //console.log("true"); 2266 createuser(); 2267 } 2268 2269 } 2270 }); 2271 setTimeout(function(){ 2272 createuser(); 2273 },60000); 2274 2275 } 2276 2277 function onMGError(){ 2278 myApp.hidePreloader(); 2279 myApp.alert('Seems like your device is unable to make a call, should we try another alternate to give you a missed call to verify your mobile ?'); 2280 call_verify(); 2281 } 2282 2283 function createuser1(){ 2284 //console.log("Trying to Create User"); 2285 //var refMobile = new Firebase("https://fiery-fire-6430.firebaseio.com/missedit/"+mobilenolast); 2286 univUrl.child("missedit/"+mobilenolast).on('value', function(snap){ 2287 var b = snap.exists();
2288 if(b==true){ 2289 //console.log("User log exists. Checking if user has given missed call"); 2290 var currentStatus = snap.val().verified; 2291 2292 if(currentStatus=="pending"){ 2293 //console.log("User has given missed call, trying to create the user now"); 2294 2295 //var refAuth = new Firebase("https://fiery-fire-6430.firebaseio.com/"); 2296 univUrl.createUser({ 2297 email : email_id, 2298 password : pass 2299 }, function(error, userData){ 2300 if (error) { 2301 //console.log("User already registered please login!", error); 2302 } else{ 2303 //var ref = new Firebase("https://fiery-fire-6430.firebaseio.com/"); 2304 univUrl.authWithPassword({ 2305 email : email_id, 2306 password : pass 2307 }, function(error, authData){ 2308 if(error){ 2309 //console.log(error); 2310 }else{ 2311 //var refMobile = new Firebase("https://fiery-fire-6430.firebaseio.com/missedit/"+mobilenolast); 2312 univUrl.child("missedit/"+mobilenolast).set({ 2313 mobile: mobilenolast, 2314 time: currentTime, 2315 verified: "done", 2316 }); 2317 2318 deviceData(mobileno); 2319 var ref = ""; 2320 branch.data(function(err, data){ 2321 if(!err){ 2322 //console.log(data); 2323 //console.log('This is done : '+JSON.stringify(data)); 2324 var stridata = JSON.parse(data.data); 2325 2326 var referalNo = stridata.referrer; 2327 //console.log(referalNo); 2328 2329 if(referalNo){ 2330 ref = referalNo; 2331 //var friendKey = new Firebase("https://fiery-fire-6430.firebaseio.com/referredfriend/"+referalNo+"/"+mobileno); 2332 univUrl.child("referredfriend/"+referalNo+"/"+mobileno).once("value", function(friendsnap){ 2333 var existance = friendsnap.exists();
2334 if(existance){ 2335 univUrl.child("referredfriend/"+referalNo+"/"+mobileno).update({ 2336 status: 1, 2337 time: Firebase.ServerValue.TIMESTAMP 2338 }); 2339 } else { 2340 univUrl.child("referredfriend/"+referalNo+"/"+mobileno).set({ 2341 status: 1, 2342 time: Firebase.ServerValue.TIMESTAMP 2343 }); 2344 } 2345 }); 2346 } 2347 } else { 2348 //console.log('This is worng : '+err); 2349 } 2350 }); 2351 //console.log('call createuse mobileno...'+mobileno); 2352 2353 var devicetoken = window.localStorage.getItem("device_token"); 2354 var model = window.localStorage.getItem("deviceModel"); 2355 var platform = window.localStorage.getItem("devicePlatform"); 2356 var uuid = window.localStorage.getItem("deviceUUID"); 2357 var version = window.localStorage.getItem("deviceVersion"); 2358 $.ajax({
2359 url: 'https://appsforbusiness.in/cloudcatalogue/process/getjsonccmanager.php', 2360 type: 'POST', 2361 data: {mobileno:mobileno,name:adm_name,username:conv_mail,pass:pass,platform:platform,devicetoken:devicetoken,uuid:uuid,model:model,version:version,uid:userData.uid,action:'userregister'}, 2362 success: function (data) 2363 { 2364 if(data.message == 'Profile updated') 2365 { 2366 //console.log("Php data saved."); 2367 }else{ 2368 //console.log("Php data could not be saved."); 2369 } 2370 } 2371 }); 2372 //console.log('conv_mail...'+conv_mail); 2373 //var myUserRef = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+mobileno); 2374 univUrl.child("users/cc/"+mobileno).set({ 2375 email: email_id, 2376 '.priority': email_id, 2377 role: "user", 2378 mobile:mobileno, 2379 username: adm_name, 2380 conversation_mail: conv_mail, 2381 billing_address: "", 2382 autofill_address: "", 2383 city:"", 2384 state:"", 2385 pin:"", 2386 country:"", 2387 locality:"", 2388 referrer:ref, 2389 billing_name: adm_name, 2390 uid:userData.uid, 2391 gender: "", 2392 birth_date: "", 2393 time_created: Firebase.ServerValue.TIMESTAMP 2394 }); 2395 setTimeout(function(){ 2396 userudid = mobileno; 2397 useremail = email_id; 2398 window.localStorage.setItem("userudid",userudid); 2399 window.localStorage.setItem("useremail",useremail); 2400 //var firebaseBrand = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/username"); 2401 univUrl.child("users/cc/"+userudid+"/username").on('value', function(snapshot){ 2402 window.localStorage.setItem("user_name",snapshot.val()); 2403 uname = snapshot.val(); 2404 $$('#show-user-name').html(snapshot.val()); 2405 }); 2406 2407 //var userexistance = new Firebase("https://fiery-fire-6430.firebaseio.com/missed/"+mobilenolast); 2408 univUrl.child("missed/"+mobilenolast).on('value', function(snap){ 2409 var a = snap.exists();
2410 if(a == true) 2411 { 2412 univUrl.child("missed/"+mobilenolast).remove(); 2413 } 2414 }); 2415 //var userexistance1 = new Firebase("https://fiery-fire-6430.firebaseio.com/missedit/"+mobilenolast); 2416 univUrl.child("missedit/"+mobilenolast).on('value', function(snap1){ 2417 var b = snap1.exists(); 2418 if(b == true) 2419 { 2420 univUrl.child("missedit/"+mobilenolast).remove(); 2421 } 2422 }); 2423 deviceData(userudid); 2424 },200); 2425 2426 userCount++; 2427 //var firebaseCount = new Firebase("https://fiery-fire-6430.firebaseio.com/counter/usercount"); 2428 univUrl.child("counter/usercount").update({ 2429 counter:userCount, 2430 }); 2431 setTimeout(function(){ 2432 //var firebaseusername = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+mobileno+"/username"); 2433 univUrl.child("users/cc/"+mobileno+"/username").on('value', function(snapshot){ 2434 var uname = window.localStorage.setItem("user_name",snapshot.val()); 2435 $$('#show-user-name').html(snapshot.val()); 2436 }); 2437 },3000); 2438 2439 deviceData(userudid); 2440 myApp.hidePreloader(); 2441// mainView.router.loadPage('firstprofile.html'); 2442 mainView.router.loadPage('index.html'); 2443 } 2444 }); 2445 2446 } 2447 2448 }); 2449 } 2450 }else{ 2451 } 2452 }); 2453 2454 } 2455 2456 } 2457 } 2458 },500); 2459 //} 2460 }); 2461 });//Page Init Ends here 2462 2463function getDateTime() { 2464 var now = new Date(); 2465 var year = now.getFullYear(); 2466 var month = now.getMonth()+1; 2467 var day = now.getDate(); 2468 var hour = now.getHours(); 2469 var minute = now.getMinutes(); 2470 var second = now.getSeconds(); 2471 if(month.toString().length == 1) { 2472 var month = '0'+month; 2473 } 2474 if(day.toString().length == 1) { 2475 var day = '0'+day; 2476 } 2477 if(hour.toString().length == 1) { 2478 var hour = '0'+hour; 2479 } 2480 if(minute.toString().length == 1) { 2481 var minute = '0'+minute; 2482 } 2483 if(second.toString().length == 1) { 2484 var second = '0'+second; 2485 } 2486 var dateTime = year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second; 2487 return dateTime; 2488} 2489 2490 2491function setgeo(){ 2492var firebaseRef = new Firebase("https://fiery-fire-6430.firebaseio.com/locations/"); 2493 2494var geoFire = new GeoFire(firebaseRef); 2495var geoQuery = geoFire.query({ 2496 center: [28.4907778, 77.0925637], 2497 radius: 1 //kilometers 2498}); 2499 2500geoQuery.on("key_entered", function(key, location, distance) { 2501 // //console.log("Brand" + key + " found at " + location + " (" + distance + " km away)"); 2502}); 2503 2504var geoFire = new GeoFire(firebaseRef); 2505 2506geoFire.set("30402", [28.654243, 77.22898299999997]).then(function() {
2507////console.log("Provided key has been added to GeoFire"); 2508}, function(error) { 2509////console.log("Error: " + error); 2510}); 2511} 2512 2513function initializeMap() { 2514 // Get the location as a Google Maps latitude-longitude object 2515 var center = [28.4906942,77.0924722]; 2516 var loc = new google.maps.LatLng(center[0], center[1]); 2517 2518 // Create the Google Map 2519 map = new google.maps.Map(document.getElementById("map-canvas"), { 2520 center: loc, 2521 zoom: 15, 2522 mapTypeId: google.maps.MapTypeId.ROADMAP 2523 }); 2524 2525 var circle = new google.maps.Circle({ 2526 strokeColor: "#6D3099", 2527 strokeOpacity: 0.7, 2528 strokeWeight: 1, 2529 fillColor: "#B650FF", 2530 fillOpacity: 0.35, 2531 map: map, 2532 center: loc, 2533 radius: ((1) * 1000), 2534 draggable: true 2535 }); 2536 var updateCriteria = _.debounce(function() { 2537 var latLng = circle.getCenter(); 2538 geoQuery.updateCriteria({ 2539 center: [latLng.lat(), latLng.lng()], 2540 radius: 1 2541 }); 2542 }, 10); 2543 google.maps.event.addListener(circle, "drag", updateCriteria); 2544} 2545 2546 function userreqbrand(){ 2547 myApp.closeModal('.popover-contacts'); 2548 var username = window.localStorage.getItem("user_name"); 2549 myApp.prompt("Please enter the 'Brand Code'", "Add Brand", 2550 function (value) { 2551 myApp.showIndicator(); 2552 var reqbrandid = ''; 2553 var b = false; 2554 var userFlag = 0; 2555 if(value == ''){ 2556 myApp.alert('Please enter the brand code !'); 2557 userFlag = 1; 2558 } else{ 2559 //var Brandcoderequest = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"); 2560 univUrl.child("brand/").orderByChild("brandcode").equalTo(value).once('child_added').then(function(snapshot){ 2561 reqbrandid = snapshot.key(); 2562 b = snapshot.exists(); 2563 var a = snapshot.numChildren(); 2564 2565 var bopensts = snapshot.val().brand_privacystatus; 2566 //var emailCheckKey = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"+reqbrandid+"/"+userudid+"/status"); 2567 univUrl.child("baccess/"+reqbrandid+"/"+userudid+"/status").once('value', function (snapshot) { 2568 var u_a_key = snapshot.key(); 2569 userFlag = 1; 2570 if(snapshot.val() == 2){ 2571 myApp.alert('You are already connected with this brand'); 2572 } else{ 2573 var uname = window.localStorage.getItem("user_name"); 2574 if(bopensts == 0){ 2575 //var uaccessKey = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"+reqbrandid+"/"+userudid); 2576 univUrl.child("baccess/"+reqbrandid+"/"+userudid).set({ 2577 user_email: useremail, 2578 status: 2, 2579 invitename:username, 2580 access_time: Firebase.ServerValue.TIMESTAMP, 2581 }, function(error){ 2582 if(!error){ 2583 b = true; 2584 } 2585 }); 2586 2587 $$.post('https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/gcmsk1.php', {msgtype:'crq', cname: uname, bid: reqbrandid,mobile:userudid}, function (data) { 2588 myApp.addNotification({ 2589 message: 'Thank you for your brand request!', 2590 hold: 3000, 2591 closeOnClick: false 2592 }); 2593 mainView.router.loadPage("bprofile.html?bid="+reqbrandid); 2594 }); 2595 } else{ 2596 //var uaccessKey = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"+reqbrandid+"/"+userudid); 2597 univUrl.child("baccess/"+reqbrandid+"/"+userudid).set({ 2598 user_email: useremail, 2599 status: 1, 2600 invitename:username, 2601 access_time: Firebase.ServerValue.TIMESTAMP, 2602 }, function(error){ 2603 if(!error){ 2604 b = true; 2605 } 2606 }); 2607 $$.post('https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/gcmsk1.php', {msgtype:'crq', cname: uname, bid: reqbrandid,mobile:userudid}, function (data) { 2608 myApp.addNotification({ 2609 message: 'Thank you for your brand request!', 2610 hold: 3000, 2611 closeOnClick: false 2612 }); 2613 mainView.router.loadPage("bprofile.html?bid="+reqbrandid); 2614 }); 2615 } 2616 } 2617 }); 2618 }); 2619 myApp.hideIndicator(); 2620 } 2621 setTimeout(function(){ 2622 if(b !== true && value !== ''){
2623 myApp.alert("Wrong brand code !"); 2624 } 2625 },500); 2626 myApp.hideIndicator(); 2627 }, 2628 function (value) { 2629 myApp.hideIndicator(); 2630 }); 2631 } 2632 2633function brandrequests(brandid){ 2634myApp.showIndicator(); 2635var userFlag = 0; 2636 var uname = window.localStorage.getItem("user_name"); 2637 2638 //var emailCheckKey = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"+brandid+"/"+userudid); 2639 univUrl.child("baccess/"+brandid+"/"+userudid).orderByChild('user_email').equalTo(useremail).on('child_added', function (snapshot) { 2640 var u_a_key = snapshot.key(); 2641 userFlag = 1; 2642 if(snapshot.val().user_email == useremail){ 2643 myApp.alert('You are already connected with this brand'); 2644 } 2645 }); 2646 if(userFlag == 0){ 2647 univUrl.child("baccess/"+brandid+"/"+userudid).off("child_added"); 2648 2649 //var uaccessKey = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"+brandid+"/"+userudid); 2650 univUrl.child("baccess/"+brandid+"/"+userudid).set({ 2651 user_email: useremail, 2652 status: 2, 2653 invitename:username, 2654 access_time: Firebase.ServerValue.TIMESTAMP, 2655 }); 2656 var uname = window.localStorage.getItem("user_name"); 2657 2658 $$.post('https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/gcmsk1.php', {msgtype:'crq', cname: uname, bid: brandid,mobile:userudid}, function (data) { 2659 2660 }); 2661 2662 myApp.alert("We have sent your request to the brand!"); 2663 mainView.router.refreshPage('brands.html'); 2664 } 2665 2666myApp.hideIndicator(); 2667} 2668 2669//Brand accept & reject 2670function brandaccept(bid){ 2671 myApp.showIndicator(); 2672 var uname = window.localStorage.getItem("user_name"); 2673 //var firebaseBrandacceptsts = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"+bid+"/"+userudid); 2674 univUrl.child("baccess/"+bid+"/"+userudid).update({ status:2}, onComplete); 2675 function onComplete(){ 2676 $$.post('https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/gcmsk1.php', {msgtype:'cau', cname: uname, bid: bid,mobile:userudid}, function (data) { 2677 myApp.addNotification({ 2678 message: 'Thank you for accepting brand request!', 2679 hold: 4000, 2680 closeOnClick: false 2681 }); 2682 }); 2683 } 2684 myApp.hideIndicator(); 2685 mainView.router.refreshPage('brands.html'); 2686 } 2687 2688function brandreject(bid){ 2689 myApp.showIndicator(); 2690 myApp.confirm('Are you sure, You want to disconnect yourself from this brand ?','Disconnect Brand', function () { 2691 //var firebaseBrandreject = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"+bid+"/"+userudid); 2692 univUrl.child("baccess/"+bid+"/"+userudid).update({ status:3 },onComplete); 2693 function onComplete(){ 2694 var uname = window.localStorage.getItem("user_name"); 2695 $$.post('https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/gcmsk1.php', {msgtype:'cru', cname: uname, bid: bid,mobile:userudid}, function (data) { 2696 myApp.hideIndicator(); 2697 2698 myApp.addNotification({ 2699 message: 'Brand Disconnected Successfully.', 2700 hold: 3000, 2701 closeOnClick: false 2702 }); 2703 }); 2704 } 2705 mainView.router.refreshPage('brands.html'); 2706 },function(){ 2707 myApp.hideIndicator(); 2708 }); 2709 2710 } 2711 2712 function brandcataccept(bid,catid){ 2713 myApp.showIndicator(); 2714 //var firebaseCatacceptsts = new Firebase("https://fiery-fire-6430.firebaseio.com/caccess/"+bid+"/"+catid+"/"+userudid); 2715 univUrl.child("caccess/"+bid+"/"+catid+"/"+userudid).update({status:2 },onComplete); 2716 function onComplete(){ 2717 var uname = window.localStorage.getItem("user_name"); 2718 $$.post('https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/gcmsk1.php', {msgtype:'cac', cname: uname, bid: bid,mobile:userudid}, function (data) { 2719 myApp.hideIndicator(); 2720 // //console.log('Notification was sent'); 2721 2722 }); 2723 myApp.addNotification({ 2724 message: 'Thank you for accepting catalogue request!', 2725 hold: 4000, 2726 closeOnClick: false 2727 }); 2728 } 2729 myApp.hideIndicator(); 2730 mainView.router.refreshPage('catalogues.html'); 2731 // }); 2732 } 2733 2734function brandcatreject(bid,catid){ 2735 var chatuname = window.localStorage.getItem("user_name"); 2736 myApp.confirm('Are you sure, this will remove your catalogue?', function () { 2737 //var firebaseCatacceptsts = new Firebase("https://fiery-fire-6430.firebaseio.com/caccess/"+bid+"/"+catid+"/"+userudid); 2738 univUrl.child("caccess/"+bid+"/"+catid+"/"+userudid).update({ status: 3 }); 2739 // firebaseCatacceptsts.remove(); 2740 $$.post('https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/gcmsk1.php', {msgtype:'crd',cname:chatuname, bid: bid ,mobile:userudid}, function (data) { 2741 }); 2742 myApp.addNotification({ 2743 message: 'Catalogue Disconnected Successfully.', 2744 hold: 3000, 2745 closeOnClick: false 2746 }); 2747 mainView.router.refreshPage('catalogues.html'); 2748 });
2749 } 2750 2751function reques_brand(){ 2752 myApp.showIndicator(); 2753 var reqconnbhtmls =''; 2754 var connbhtmls = ''; 2755 var bUserData = ''; 2756 var brandkey=''; 2757 //var firebaseBrandreqlist = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"); 2758 univUrl.child("baccess/").orderByChild(userudid+"/status").equalTo(0).on('value', function(snapshot){ 2759 $$('#brand-req').html(''); 2760 2761 if(snapshot.exists()==true && snapshot.numChildren() > 0){ 2762 snapshot.forEach(function (objs) 2763 { 2764 //var branddata = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+objs.key()); 2765 univUrl.child("brand/"+objs.key()).once('value',function(snapshots){ 2766 var req_bUserDatas = snapshots.val(); 2767 if(req_bUserDatas.enabled_status == 1){ 2768 connbhtmls += '<div class="demo-card-header-pic" style="padding: 5px 0px 5px 0;">' + 2769 '<a href="catalogues.html?bid='+req_bUserDatas.brand_id+'" >'+ 2770 '<div data-background="'+req_bUserDatas.cover_image_url+'" style="background-repeat: no-repeat !important; background-size: cover !important; background: #aaa;
2770 height:60vw;" valign="bottom" class="card-header lazy lazy-fadeIn color-white no-border">'+ 2771 '<div class="brand_heading">'+req_bUserDatas.brand_name+'<br><span style="font-size: small;font-weight: 200;">'+req_bUserDatas.brandcode+'</span></div>'+ 2772 '<div class="black_shad" style="margin-top:0;border-radius:0px;"></div>'+ 2773 '<div class="brand_social">'+ 2774 '<div class="brand_icons"><a href="#" onclick=brandaccept("'+req_bUserDatas.brand_id+'")><img src="img/ccimages/accept.png" style="height:40%;width:40%"></a></div>'+ 2775 '<div class="brand_icons"><a href="#" onclick=brandreject("'+req_bUserDatas.brand_id+'")><img src="img/ccimages/Delete_white.png" style="height:40%;width:40%"></a></div>'+ 2776 '<div class="brand_icons"><a href="bprofile.html?bid='+req_bUserDatas.brand_id+'"><img src="img/ccimages/Profile_white.png" style="height:40%;width:40%"></a></div>'+ 2777 '<div class="brand_icons"><a href="chat.html?username='+userudid+'&brandid='+req_bUserDatas.brand_id+'&bname='+bUserData.brand_name+'"><img src="img/ccimages/chat_white.png" style="height:40%;width:40%"></a></div>'+ 2778 '</div>'+ 2779 '</div></a></div>'; 2780 } 2781 setTimeout(function(){ 2782 $$('#brand-req').html(connbhtmls); 2783 myApp.hideIndicator(); 2784 $$('div.lazy').trigger('lazy'); 2785 },1000); 2786 2787 2788 }); 2789 }); 2790 }else{ 2791 var valhtml = '<ul><li>'+ 2792 '<div class="item-content">'+ 2793 '<div class="item-inner">'+ 2794 '<div class="item-title" style="text-align: center;">No Brand Invites available.</div>'+ 2795// '<div class="button"><a href="#" onClick="userreqbrand();" class="button button-fill">Add brand</a></div>'+ 2796 '</div>'+ 2797 '</div>'+ 2798 '</li></ul>'; 2799 $$('#brand-req').html(valhtml); 2800 myApp.hideIndicator(); 2801 } 2802 2803 }); 2804 }//End reques_brand function 2805 2806function calling(number){ 2807 var mob_number = "+'"+number+"'"; 2808 //console.log(mob_number); 2809 window.plugins.CallNumber.callNumber(onMSuccess, onMError, mob_number); 2810} 2811 2812function onMSuccess(){ 2813 //console.log("Call success!!"); 2814} 2815 2816function onMError(){ 2817 myApp.hidePreloader(); 2818 myApp.showPreloader('It seems your device does not support calling. Please give a missed call at +91 80 000 11822 with the registered number to verify.'); 2819} 2820 2821 function nearby_brand(){ 2822 myApp.showIndicator(); 2823 if (navigator.geolocation) { 2824 //console.log("call near by "); 2825 console.log("With near by function"); 2826 var options = {maximumAge: 0, timeout: 10000, enableHighAccuracy:true}; 2827 navigator.geolocation.getCurrentPosition(showPoslatlonnearby, onGError, options); 2828 } else { 2829 //console.log("not get current location lat lon"); 2830 myApp.hideIndicator(); 2831 } 2832 } 2833 2834 function onGError(error){ 2835 myApp.hideIndicator(); 2836 //console.log(error.message); 2837 if(error.message == 'Timeout expired'){ 2838 console.log("1 :"+error.message); 2839 myApp.alert("We were unable to fetch your location. Please confirm if GPS is enabled."); 2840 } 2841 if(error.message == 'POSITION_UNAVAILABLE'){ 2842 console.log("2 :"+error.message); 2843 myApp.alert("We were unable to fetch your location. Please confirm if GPS is enabled then try again."); 2844 } 2845 if(error.message == 'PERMISSION_DENIED'){ 2846 console.log("3 :"+error.message); 2847 myApp.alert("We were unable to fetch your location. Please confirm if GPS is enabled then try again."); 2848 } 2849 } 2850 2851 function showPoslatlonnearby(position){ 2852 myApp.showIndicator(); 2853 // $$.ajax({
2854 // url: "https://appsforbusiness.in/testing.php", 2855 // error: function(){ 2856 // // will fire when timeout is reached 2857 // mainView.router.loadPage('error.html'); 2858 // myApp.hideIndicator(); 2859 // myApp.alert('It seems your internet is sleeping, wake him up to enjoy the app.'); 2860 // }, 2861 // success: function(){ 2862 2863 //console.log("call showPositionlatlong"); 2864 var flagval = 0; 2865 var dist =0; 2866 var near_bUserData = ''; 2867 var radius = 5; 2868 var loadIndex = 20; 2869 $$('#brand-nearby').html(''); 2870 var nearby_blist =[]; 2871 window.localStorage.setItem("latitude",position.coords.latitude); 2872 window.localStorage.setItem("longitude",position.coords.longitude); 2873 var lat = position.coords.latitude; 2874 var lng = position.coords.longitude; 2875 2876 var $range = $("#rangeid"); 2877 $("#rangeid").ionRangeSlider({ 2878 type: "single", 2879 min: 5, 2880 max: 25, 2881 from: 5, 2882 step: 5, 2883 hide_min_max: true, 2884 postfix: "KM", 2885 //from_fixed: true, 2886 from_min: 5 2887 }); 2888 $range.on('change', function () { 2889 loadIndex += 20; 2890 console.log('Value : ' +this.value+ " No. Brand : " +loadIndex); 2891 radius = parseInt(this.value); 2892 if(radius == 5) { 2893 loadIndex = 20; 2894 } else if(radius == 10){ 2895 loadIndex = 40; 2896 } else if(radius == 15){ 2897 loadIndex = 60; 2898 } else if(radius == 20){ 2899 loadIndex = 80; 2900 } else { 2901 loadIndex = 100; 2902 } 2903 showNearBy(lat, lng, radius, loadIndex); 2904 }); 2905 2906 var firebaseRef = new Firebase("https://fiery-fire-6430.firebaseio.com/locations/"); 2907 var geoFire = new GeoFire(firebaseRef); 2908 var geoQuery = geoFire.query({ 2909 center: [position.coords.latitude, position.coords.longitude], 2910 radius: radius //kilometers 2911 }); 2912 2913 var openstatus =''; 2914 var baccessstatus =''; 2915 var carticon = ''; 2916 var length = 0; 2917 2918 var i = 0; 2919 //console.log("Radius : " +geoQuery.radius()); 2920 geoQuery.on("key_entered", function(key, location, distance) { 2921 //console.log("In radius 5 KM, Brands are : "+key); 2922 if(key){ 2923 var nearbyhtmls = ''; 2924 //console.log("I : " +i); 2925 i++; 2926 if((i % loadIndex) == 0){ 2927 //console.log("1st time geoQuery.cancel()"); 2928 geoQuery.cancel(); 2929 } 2930 2931 $$('#brand-nearby').html(''); 2932 univUrl.child("brand/"+key).once('value', function(snapshotacck){ 2933 var near_bUserData = snapshotacck.val(); 2934 if(near_bUserData){ 2935 //if brandPrivacyStatus is 0 then it's public, if 1 then it's private 2936 if((near_bUserData.brand_privacystatus == 0 || near_bUserData.brand_privacystatus == "0") && (near_bUserData.enabled_status == 1 || near_bUserData.enabled_status == "1")){ 2937 //console.log(near_bUserData.brand_privacystatus+ "\n" +key+ "\n" +i); 2938 nearbyhtmls = '<div class="demo-card-header-pic" style="padding: 5px 0px 5px 0;">' + 2939 '<a href="bprofile.html?bid='+near_bUserData.brand_id+'">'+ 2940 '<div data-background="'+near_bUserData.cover_image_url+'" style="background-repeat: no-repeat !important; background-size: cover !important; background: #aaa;
2940 height:60vw;" valign="bottom" class="card-header lazy lazy-fadeIn color-white no-border">'+ 2941 '<div class="brand_heading">'+near_bUserData.brand_name+'<br><span style="font-size: small;font-weight: 200;">'+near_bUserData.brandcode+'</span><br><span style="font-size: smaller;font-weight: 100;">'+distance.toFixed(2)+'   km away</span></div>'+ 2942 '<div class="black_shad" style="margin-top:0;border-radius:0px;"></div>'+ 2943 '</div>'+ 2944 '</div></a>'+ 2945 '</div>'; 2946 $$('#brand-nearby').append(nearbyhtmls); 2947 myApp.hideIndicator(); 2948 $$('div.lazy').trigger('lazy'); 2949 } 2950 } 2951 }); 2952 2953 } else{ 2954 var nonearbyhtmls = '<ul><li>'+ 2955 '<div class="item-content">'+ 2956 '<div class="item-inner">'+ 2957 '<div class="item-title" style="text-align: center;">No nearby brands Available.</div>'+ 2958 '</div>'+ 2959 '</div>'+ 2960 '</li></ul>'; 2961 $$('#brand-nearby').html(nonearbyhtmls); 2962 } 2963 }); 2964 // }, 2965 // timeout: 15000 // sets timeout to 30 seconds remember you want it to be long to ensure that it isn't just a slow connection 2966 // }); 2967}//End function showPoslatlonnearby(position) 2968 2969 //showNearBy(lat, lng, radius, loadIndex); 2970function showNearBy(lat, lng, radius, loadIndex){ 2971 myApp.showIndicator(); 2972 $$('#brand-nearby').html(''); 2973 //console.log("Latitude : " +lat+ "\nLongitude : " +lng+ "\n Radius : " +radius+ "\n Brand : " +loadIndex); 2974 var firebaseRef = new Firebase("https://fiery-fire-6430.firebaseio.com/locations/"); 2975 var geoFire = new GeoFire(firebaseRef); 2976 var geoQuery = geoFire.query({ 2977 center: [lat, lng], 2978 radius: radius //kilometers 2979 }); 2980 2981 var openstatus =''; 2982 var baccessstatus =''; 2983 var carticon = ''; 2984 var length = 0; 2985 var j = 0; 2986 var loadIndex = loadIndex; 2987 //var startIndex = 0; 2988 var i = 0; 2989 //console.log("Radius : " +geoQuery.radius()); 2990 geoQuery.on("key_entered", function(key, location, distance) { 2991 //console.log("Brands are : "+key); 2992 2993 if(key){ 2994 var nearbyhtmls = ''; 2995 //console.log("I : " +i); 2996 i++; 2997 if((i % loadIndex) == 0){ 2998 //console.log("Executing geoQuery.cancel()"); 2999 geoQuery.cancel(); 3000 } 3001 3002 $$('#brand-nearby').html(''); 3003 univUrl.child("brand/"+key).once('value', function(snapshotacck){ 3004 var near_bUserData = snapshotacck.val(); 3005 if(near_bUserData){ 3006 //if brandPrivacyStatus is 0 then it's public, if 1 then it's private 3007 if((near_bUserData.brand_privacystatus == 0 || near_bUserData.brand_privacystatus == "0") && (near_bUserData.enabled_status == 1 || near_bUserData.enabled_status == "1")){ 3008 //console.log(near_bUserData.brand_privacystatus+ "\n" +key+ "\n" +i); 3009 nearbyhtmls = '<div class="demo-card-header-pic" style="padding: 5px 0px 5px 0;">' + 3010 '<a href="bprofile.html?bid='+near_bUserData.brand_id+'">'+ 3011 '<div data-background="'+near_bUserData.cover_image_url+'" style="background-repeat: no-repeat !important; background-size: cover !important; background: #aaa;
3011 height:60vw;" valign="bottom" class="card-header lazy lazy-fadeIn color-white no-border">'+ 3012 '<div class="brand_heading">'+near_bUserData.brand_name+'<br><span style="font-size: small;font-weight: 200;">'+near_bUserData.brandcode+'</span><br><span style="font-size: smaller;font-weight: 100;">'+distance.toFixed(2)+'   km away</span></div>'+ 3013 '<div class="black_shad" style="margin-top:0;border-radius:0px;"></div>'+ 3014 '</div>'+ 3015 '</div></a>'+ 3016 '</div>'; 3017 $$('#brand-nearby').append(nearbyhtmls); 3018 myApp.hideIndicator(); 3019 $$('div.lazy').trigger('lazy'); 3020 } 3021 } 3022 }); 3023 3024 } else{ 3025 var nonearbyhtmls = '<ul><li>'+ 3026 '<div class="item-content">'+ 3027 '<div class="item-inner">'+ 3028 '<div class="item-title" style="text-align: center;">No nearby brands Available.</div>'+ 3029 '</div>'+ 3030 '</div>'+ 3031 '</li></ul>'; 3032 $$('#brand-nearby').html(nonearbyhtmls); 3033 } 3034 }); 3035} 3036 3037function cllachat(tabid){ 3038 if(tabid == 'tab2'){ 3039 myApp.showTab('#tab2'); 3040 } 3041} 3042 3043//myApp.onPageInit('firstprofile') 3044myApp.onPageInit('user-payment', function (page) { 3045 var paymentLi = ""; 3046 var bUserPayStatus = ""; 3047 var bSaltKey = ""; 3048 var bMerchantKey = ""; 3049 var flagsetpay = false; 3050 $$('#paymentliid').html(""); 3051 //console.log("page.query.orderId..."+page.query.orderId); 3052 //If order ID isn't availaible 3053 if(page.query.orderId == '' || page.query.orderId == 'undefined' || page.query.orderId == undefined){ 3054 myApp.showIndicator(); 3055 //var orderKey = new Firebase("https://fiery-fire-6430.firebaseio.com/orders"); 3056 univUrl.child("orders/").orderByChild('userid').equalTo(userudid).on('child_added', function (data) { 3057 var order_id = data.key(); 3058 var dataval = data.val(); 3059 3060 //console.log("Order ID :" +dataval); 3061 var user = data.val().userid; 3062 var brandId = data.val().brand_id; 3063 var totalPrice = data.val().total_ord_pri; 3064 var name = data.val().billing_name; 3065 var orderDate = data.val().ord_date; 3066 3067 //var brandKey = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+brandId); 3068 univUrl.child("brand/"+brandId).once('value', function (snap) { 3069 bUserPayStatus = snap.val().user_pay_status; 3070 bSaltKey = snap.val().salt; 3071 bMerchantKey = snap.val().merchant_key; 3072 3073 if((bUserPayStatus == 1 || bUserPayStatus == "1") && (bSaltKey) && (bMerchantKey)) { 3074 flagsetpay = snap.exists();
3075 var orderId = data.key(); 3076 orderId = "'"+orderId+"'"; 3077 var buttonOnOff = ""; 3078 var payRef = ""; 3079 //console.log(data.val().payment_status); 3080 var buttonOnOff = ""; 3081 if(data.val().payment_status == 0 || data.val().payment_status == "0"){ 3082 buttonOnOff = '<div class="card-footer"><p class="buttons-row">'+ 3083 '<a href="#" onClick="securePayment('+orderId+');" class="button button-fill color-deeporange" style="display:inline-table">Pay Now</a>'+ 3084 '<a href="index.html" class="button button-fill color-deeporange" style="display:inline-table">Later</a>'+ 3085 '</p></div>'; 3086 //console.log(buttonOnOff); 3087 } else if(data.val().payment_status == 2 || data.val().payment_status == "2"){ 3088 buttonOnOff = '<div class="card-footer"><p class="buttons-row">'+ 3089 '<a href="#" onClick="securePayment('+orderId+');" class="button button-fill color-deeporange" style="display:inline-table">Retry Payment</a>'+ 3090 '<a href="index.html" class="button button-fill color-deeporange" style="display:inline-table">Later</a>'+ 3091 '</p></div>'; 3092 } else { 3093 buttonOnOff = '<div class="card-footer"><p class="buttons-row"><a href="#" class="button button-fill color-deeporange">Paid</a></p></div>'; 3094 payRef = data.val().payment_ref; 3095 } 3096 //console.log(buttonOnOff); 3097 paymentLi +='<div class="card facebook-card" >'+ 3098 '<div class="card-header">'+ 3099 '<div class="name" style="text"><b>'+data.val().brand_name+'</b></div>'+ 3100 '<div class="order"><a href="viewaction.html?orderid='+order_id+'&brandid='+data.val().brand_id+'">Order ID :'+order_id+'</a></div>'+ 3101 '</div>'+ 3102 '<div class="card-content">'+ 3103 '<div class="card-content-inner">'+ 3104 '<div class="amount row"><div class="item-title">Total Amount :</div><div class="item-after">'+totalPrice+'</div>' + 3105 '</div><div class="order-date row"> <div class="item-title">Order Date :</div><div class="item-after">'+orderDate+'</div></div>'+ 3106 '<div class="row"><div class="item-title">Reference :</div><div class="item-after">'+payRef+'</div></div>'+ 3107 '</div>'+ 3108 '</div>'+ 3109 buttonOnOff+ 3110 '</div>'; 3111 3112 setTimeout(function(){ 3113 myApp.hideIndicator(); 3114 $$('#paymentliid').html(paymentLi); 3115 },300); 3116 // } 3117 } else { 3118 myApp.hideIndicator(); 3119 //console.log("Sorry, user payment option disabled by brand."); 3120 } 3121 }); //End brandKey.on 3122 }); //End orderKey.orderByChild 3123setTimeout(function(){ 3124if(flagsetpay == false) 3125{ 3126 var valhtml = '<ul><li>'+ 3127 '<div class="item-content">'+ 3128 '<div class="item-inner">'+ 3129 '<div class="item-title" style="text-align: center;">No payment Available.</div>'+ 3130 '</div>'+ 3131 '</div>'+ 3132 '</li></ul>'; 3133 $$('#paymentliid').html(valhtml); 3134 myApp.hideIndicator(); 3135} 3136}); 3137} else { 3138 3139 //console.log('page.query.orderId....'+page.query.orderId); 3140 //var orderKey = new Firebase("https://fiery-fire-6430.firebaseio.com/orders/"+page.query.orderId); 3141 univUrl.child("orders/"+page.query.orderId).once('value', function (data) { 3142 var order_id = data.key(); 3143 flagsetpay = data.exists(); 3144 var dataval = data.val(); 3145 //console.log("brand ID :" +data.val().brand_id); 3146 var user = data.val().userid; 3147 var brandId = data.val().brand_id; 3148 var totalPrice = data.val().total_ord_pri; 3149 var name = data.val().billing_name; 3150 var orderDate = data.val().ord_date; 3151 3152 var orderId = data.key(); 3153 orderId = "'"+orderId+"'"; 3154 var buttonOnOff = ""; 3155 var payRef = ""; 3156 //console.log(data.val().payment_status); 3157 if(data.val().payment_status == 0 || data.val().payment_status == "0") { 3158 buttonOnOff = '<div class="card-footer"><p class="buttons-row">'+ 3159 '<a href="#" onClick="securePayment('+orderId+');" class="button button-raised button-fill color-deeporange" style="display:inline-table">Pay Now</a>'+ 3160 '<a href="index.html" class="button button-raised button-fill color-deeporange" style="display:inline-table">Later</a>'+ 3161 '</p></div>'; 3162 //console.log(buttonOnOff); 3163 } 3164 else if(data.val().payment_status == 2 || data.val().payment_status == "2") { 3165 buttonOnOff = '<div class="card-footer"><p class="buttons-row">'+ 3166 '<a href="#" onClick="securePayment('+orderId+');" class="button button-raised button-fill color-deeporange" style="display:inline-table">Retry Payment</a>'+ 3167 '<a href="index.html" class="button button-raised button-fill color-deeporange" style="display:inline-table">Later</a>'+ 3168 '</p></div>'; 3169 } else { 3170 buttonOnOff = '<div class="card-footer"><p class="buttons-row"><a href="#" class="button button-raised button-fill color-deeporange">Paid</a></p></div>'; 3171 payRef = data.val().payment_ref; 3172 } 3173 3174 paymentLi +='<div class="card facebook-card" >'+ 3175 '<div class="card-header">'+ 3176 '<div class="name" style="text"><b>
3176'+data.val().brand_name+'</b></div>'+ 3177 '<div class="order"><a href="viewaction.html?orderid='+order_id+'&brandid='+data.val().brand_id+'">Order ID :'+order_id+'</a></div>'+ 3178 '</div>'+ 3179 '<div class="card-content">'+ 3180 '<div class="card-content-inner">'+ 3181 '<div class="amount row"><div class="item-title">Total Amount :</div><div class="item-after">'+totalPrice+'</div>' + 3182 '</div><div class="order-date row"> <div class="item-title">Order Date :</div><div class="item-after">'+orderDate+'</div></div>'+ 3183 '<div class="row"><div class="item-title">Reference :</div><div class="item-after">'+payRef+'</div></div>'+ 3184 '</div>'+ 3185 '</div>'+ 3186 buttonOnOff+ 3187 '</div>'; 3188 3189 setTimeout(function(){ 3190 myApp.hideIndicator(); 3191 $('#paymentliid').html(paymentLi); 3192 },300); 3193 }); 3194if(flagsetpay == false) 3195{ 3196 var valhtml = '<li>'+ 3197 '<div class="item-content">'+ 3198 '<div class="item-inner">'+ 3199 '<div class="item-title" align="center">No payment Available.</div>'+ 3200 '</div>'+ 3201 '</div>'+ 3202 '</li>'; 3203 $$('#paymentliid').html(valhtml); 3204 myApp.hideIndicator(); 3205} 3206 }//End else of check orderID 3207}); //End user-payment onPageInit 3208 3209/*function openURL(url){ 3210 var devicePlatform = device.platform; 3211 //var ref = ""; 3212 if(devicePaltform == "iOS"){ 3213 //ref = cordova.ThemeableBrowser.open(url, '_blank', 'location=yes', 'toolbar=yes','presentationstyle=pagesheet','toolbarposition=top','closebuttoncaption=back'); 3214 openBrowser(url, ""); 3215 } else{ 3216 window.open(url,'_system','location=yes'); 3217 } 3218}*/ 3219 3220function openURL(url){ 3221 window.open(url,'_system','location=yes'); 3222} 3223 3224function securePayment(orderId) { 3225 console.log("securePayment - "+ orderId); 3226 var finurl = 'https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/pay/index.php?order_id='+orderId; 3227 var surl = 'https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/pay/success.php'; 3228 var furl = 'https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/pay/failure.php'; 3229 3230 var ref = window.open(finurl, "_blank", "toolbar=yes, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400"); 3231 console.log(ref); 3232 ref.addEventListener('loadstart', function(event) { 3233 //console.log(event.type + ' - ' + event.url); 3234 }); 3235 3236 ref.addEventListener('exit', function(event) { console.log(event.url); }); 3237 ref.addEventListener('loadstop', function(event) { 3238 //console.log(event.type + ' - ' + event.url); 3239 var url = event.url; 3240 var urlAux = url.split('='); 3241 var suburl = urlAux[0].split('?'); 3242 var paymentref = urlAux[1]; 3243 console.log(url); 3244 console.log(suburl[0]); 3245 if(suburl[0]=='https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/pay/success.php'){ 3246 myApp.alert("Congratulations Payment was successful."); 3247 ref.close(); 3248 } 3249 3250 if(suburl[0]=='https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/pay/failure.php'){ 3251 myApp.alert("Sorry! Payment was unsuccessful. Please try again!"); 3252 ref.close(); 3253 } 3254 }); 3255} 3256 3257/*function securePayment(orderId) { 3258 //console.log("securePayment - "+ orderId); 3259 //window.open = cordova.ThemeableBrowser.open; 3260 var devicePlatform = device.platform; 3261 //console.log("devicePlatform - "+ devicePlatform); 3262 3263 var finurl = 'https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/pay/index.php?order_id='+orderId; 3264 var surl = 'https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/pay/success.php'; 3265 var furl = 'https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/pay/failure.php'; 3266 if(devicePlatform=='iOS'){ 3267 var ref = cordova.ThemeableBrowser.open(finurl, '_blank', 'location=yes', 'toolbar=yes','presentationstyle=pagesheet','toolbarposition=top','closebuttoncaption=back'); 3268 }else{ 3269 //var ref = cordova.ThemeableBrowser.open(finurl, '_self', 'location=yes'); 3270 var ref = cordova.ThemeableBrowser.open(finurl, '_blank', { 3271 statusbar: { 3272 color: '#ffffff' 3273 }, 3274 toolbar: { 3275 height: 44, 3276 color: '#ff5722' 3277 }, 3278 title: { 3279 color: '#ffffff', 3280 staticText : 'Payment', 3281 showPageTitle: true 3282 }, 3283 backButton: { 3284 wwwImage: 'image/back.png', 3285 wwwimagePressed: 'image/back_pressed.png', 3286 wwwImageDensity: 2, 3287 align: 'left', 3288 event: 'backPressed' 3289 }, 3290 forwardButton: { 3291 wwwImage: 'image/forward.png', 3292 wwwimagePressed: 'image/forward_pressed.png', 3293 wwwImageDensity: 2, 3294 align: 'left', 3295 event: 'forwardPressed' 3296 }, 3297 closeButton: { 3298 wwwImage: 'image/close.png',
3299 wwwimagePressed: 'image/close_pressed.png', 3300 wwwImageDensity: 2, 3301 align: 'left', 3302 event: 'closePressed' 3303 }, 3304 backButtonCanClose: true 3305 }); 3306 } 3307 ref.addEventListener('loadstart', function(event) { 3308 ////console.log(event.type + ' - ' + event.url); 3309 }); 3310 3311 ref.addEventListener('exit', function(event) { //console.log(event.url); }); 3312 ref.addEventListener('loadstop', function(event) { 3313 ////console.log(event.type + ' - ' + event.url); 3314 var url = event.url; 3315 var urlAux = url.split('='); 3316 var suburl = urlAux[0].split('?'); 3317 var paymentref = urlAux[1]; 3318 //console.log(url); 3319 //console.log(suburl[0]); 3320 if(suburl[0]=='https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/pay/success.php'){ 3321 myApp.alert("Congratulations Payment was successful."); 3322 ref.close(); 3323 } 3324 3325 if(suburl[0]=='https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/pay/failure.php'){ 3326 myApp.alert("Sorry! Payment was unsuccessful. Please try again!"); 3327 ref.close(); 3328 } 3329 }); 3330}); 3331}*/ 3332 3333/* ===== Infinite Scroll Page ===== */ 3334myApp.onPageInit('infinite-scroll', function (page) { 3335 // Loading trigger 3336 var loading = false; 3337 var bUserData =''; 3338 // Last loaded index, we need to pass it to script 3339 var lastLoadedIndex = $$('.infinite-scroll .list-block li').length; 3340 // create a Firebase reference 3341 var bUserData_as = ''; 3342 var fb = new Firebase('https://fiery-fire-6430.firebaseio.com/brand/'); 3343 scrollRef = new Firebase.util.Scroll(fb, 'indexno'); 3344 scrollRef.scroll.next(10); 3345 3346 scrollRef.on('child_added', function(snapshot) { 3347 // //console.log('loaded record ' + snapshot.key()); 3348 bUserData_as = snapshot.val(); 3349 var connbhtmlsk = '<div class="demo-card-header-pic" style="padding: 5px 0px 5px 0;">' + 3350 '<a href="catalogues.html?bid='+bUserData_as.brand_id+'" >'+ 3351 '<div data-background="'+bUserData_as.cover_image_url+'" style="background-repeat: no-repeat !important; background-size: cover !important; background: #aaa;
3351 height:60vw;" valign="bottom" class="card-header lazy lazy-fadeIn color-white no-border">'+ 3352 '<div class="brand_heading">'+bUserData_as.brand_name+'<br><span style="font-size: small;font-weight: 200;">'+bUserData_as.brandcode+'</span></div>'+ 3353 '<div class="black_shad" style="margin-top:0;border-radius:0px;"></div>'+ 3354 '<div class="brand_social">'+ 3355 '<div class="brand_icons"><a href="#" onclick=brandreject("'+bUserData_as.brand_id+'")><img src="img/ccimages/Delete_white.png" style="height:40%;width:40%"></div>'+ 3356 '<div class="brand_icons"><a href="chat.html?username='+userudid+'&brandid='+bUserData.brand_id+'&bname='+bUserData.brand_name+'"><img src="img/ccimages/chat_white.png" style="height:40%;width:40%"></a></div>'+ 3357 '<div class="brand_icons"><a href="bprofile.html?bid='+bUserData_as.brand_id+'"><img src="img/ccimages/Profile_white.png" style="height:40%;width:40%"></a></div>'+ 3358 '<div class="brand_icons"><a href="catalogues.html?bid='+bUserData_as.brand_id+'"><img src="img/ccimages/Shop_white.png" style="height:40%;width:40%"></a></div>'+ 3359 '</div>'+ 3360 '</div></a></div>'; 3361 $$('#conn-brand').append(connbhtmlsk); 3362 }); 3363}); 3364 3365function nearbyfloat(){ 3366 nearby_brand(); 3367 myApp.showTab('#tab2nearby'); 3368} 3369 3370 myApp.onPageInit('brands', function (page) { 3371 myApp.showIndicator(); 3372 var connbhtmls = ''; 3373 var flagval = 0; 3374 // $$.ajax({ 3375 // url: "https://appsforbusiness.in/testing.php", 3376 // error: function(){ 3377 // mainView.router.loadPage('error.html'); 3378 // myApp.hideIndicator(); 3379 // myApp.alert('It seems your internet is sleeping, wake him up to enjoy the app.'); 3380 // }, 3381 // success: function(){ 3382 //var firebaseBrandreqlist = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"); 3383 univUrl.child("baccess/").orderByChild(userudid+"/status").equalTo(2).once('value', function(snapshot){ 3384 //console.log(snapshot.numChildren()); 3385 $$('#conn-brand').html(''); 3386 if(snapshot.exists()==true){ 3387 var conBrandsArray = []; 3388 snapshot.forEach(function (objs){ 3389 conBrandsArray.push(objs.key()); 3390 }); 3391 var length = conBrandsArray.length; 3392 if(length <= 20){ 3393 for(var i = 0; i < length; i++){ 3394 univUrl.child("brand/"+conBrandsArray[i]).once('value',function(snapshots){ 3395 var bUserData = snapshots.val(); 3396 if(bUserData){ //for preventing null data 3397 if(bUserData.enabled_status == 1 || bUserData.enabled_status == "1"){ 3398 connbhtmls = '<div class="demo-card-header-pic" style="padding: 5px 0px 5px 0;">' + 3399 '<a href="catalogues.html?bid='+bUserData.brand_id+'" >'+ 3400 '<div data-background="'+bUserData.cover_image_url+'" style="background-repeat: no-repeat !important; background-size: cover !important; background: #aaa;
3400 height:60vw;" valign="bottom" class="card-header lazy lazy-fadeIn color-white no-border">'+ 3401 '<div class="brand_heading">'+bUserData.brand_name+'<br><span style="font-size: small;font-weight: 200;">'+bUserData.brandcode+'</span></div>'+ 3402 '<div class="black_shad" style="margin-top:0;border-radius:0px;"></div>'+ 3403 '<div class="brand_social">'+ 3404 '<div class="brand_icons"><a href="#" onclick=brandreject("'+bUserData.brand_id+'")><img src="img/ccimages/Delete_white.png" style="height:40%;width:40%"></div>'+ 3405 '<div class="brand_icons"><a href="chat.html?username='+userudid+'&brandid='+bUserData.brand_id+'&bname='+bUserData.brand_name+'"><img src="img/ccimages/chat_white.png" style="height:40%;width:40%"></a></div>'+ 3406 '<div class="brand_icons"><a href="bprofile.html?bid='+bUserData.brand_id+'"><img src="img/ccimages/Profile_white.png" style="height:40%;width:40%"></a></div>'+ 3407 '<div class="brand_icons"><a href="catalogues.html?bid='+bUserData.brand_id+'"><img src="img/ccimages/Shop_white.png" style="height:40%;width:40%"></a></div>'+ 3408 '</div>'+ 3409 '</div></a></div>'; 3410 $$('#conn-brand').append(connbhtmls); 3411 flagval++; 3412 } 3413 } 3414 }); 3415 } 3416 } else{ 3417 var i = 0; 3418 for( ;i < 20; i++){ 3419 console.log(conBrandsArray[i]+ "\t" +i+"\n"); 3420 univUrl.child("brand/"+conBrandsArray[i]).once('value',function(snapshots){ 3421 var bUserData = snapshots.val(); 3422 if(bUserData){ //for preventing null data 3423 3424 if(bUserData.enabled_status == 1 || bUserData.enabled_status == "1"){ 3425 connbhtmls = '<div class="demo-card-header-pic" style="padding: 5px 0px 5px 0;">' + 3426 '<a href="catalogues.html?bid='+bUserData.brand_id+'" >'+ 3427 '<div data-background="'+bUserData.cover_image_url+'" style="background-repeat: no-repeat !important; background-size: cover !important; background: #aaa;
3427 height:60vw;" valign="bottom" class="card-header lazy lazy-fadeIn color-white no-border">'+ 3428 '<div class="brand_heading">'+bUserData.brand_name+'<br><span style="font-size: small;font-weight: 200;">'+bUserData.brandcode+'</span></div>'+ 3429 '<div class="black_shad" style="margin-top:0;border-radius:0px;"></div>'+ 3430 '<div class="brand_social">'+ 3431 '<div class="brand_icons"><a href="#" onclick=brandreject("'+bUserData.brand_id+'")><img src="img/ccimages/Delete_white.png" style="height:40%;width:40%"></div>'+ 3432 '<div class="brand_icons"><a href="chat.html?username='+userudid+'&brandid='+bUserData.brand_id+'&bname='+bUserData.brand_name+'"><img src="img/ccimages/chat_white.png" style="height:40%;width:40%"></a></div>'+ 3433 '<div class="brand_icons"><a href="bprofile.html?bid='+bUserData.brand_id+'"><img src="img/ccimages/Profile_white.png" style="height:40%;width:40%"></a></div>'+ 3434 '<div class="brand_icons"><a href="catalogues.html?bid='+bUserData.brand_id+'"><img src="img/ccimages/Shop_white.png" style="height:40%;width:40%"></a></div>'+ 3435 '</div>'+ 3436 '</div></a></div>'; 3437 $$('#conn-brand').append(connbhtmls); 3438 flagval++; 3439 } 3440 } 3441 }); 3442 }//End for 3443 if(i >= 20 && i < length){ 3444 var ldBtn = '<p><a href="#" class="button button-fill color-deeporange ldmore">Load Brands</a></p>'; 3445 $$('#loadbrand').html(ldBtn); 3446 $$('.ldmore').on('click', function(){ 3447 //var checkLoad = i + 20; 3448 var j = i; 3449 i += 20; 3450 if(i >= length){ 3451 i = length; 3452 $$('#loadbrand').hide(); 3453 } 3454 for( ; j < i; j++){ 3455 console.log(conBrandsArray[j]+ "\t" +j+ "\n"); 3456 univUrl.child("brand/"+conBrandsArray[j]).once('value',function(snapshots){ 3457 var bUserData = snapshots.val(); 3458 if(bUserData){ //for preventing null data 3459 if(bUserData.enabled_status == 1 || bUserData.enabled_status == "1"){ 3460 connbhtmls = '<div class="demo-card-header-pic" style="padding: 5px 0px 5px 0;">' + 3461 '<a href="catalogues.html?bid='+bUserData.brand_id+'" >'+ 3462 '<div data-background="'+bUserData.cover_image_url+'" style="background-repeat: no-repeat !important; background-size: cover !important; background: #aaa;
3462 height:60vw;" valign="bottom" class="card-header lazy lazy-fadeIn color-white no-border">'+ 3463 '<div class="brand_heading">'+bUserData.brand_name+'<br><span style="font-size: small;font-weight: 200;">'+bUserData.brandcode+'</span></div>'+ 3464 '<div class="black_shad" style="margin-top:0;border-radius:0px;"></div>'+ 3465 '<div class="brand_social">'+ 3466 '<div class="brand_icons"><a href="#" onclick=brandreject("'+bUserData.brand_id+'")><img src="img/ccimages/Delete_white.png" style="height:40%;width:40%"></div>'+ 3467 '<div class="brand_icons"><a href="chat.html?username='+userudid+'&brandid='+bUserData.brand_id+'&bname='+bUserData.brand_name+'"><img src="img/ccimages/chat_white.png" style="height:40%;width:40%"></a></div>'+ 3468 '<div class="brand_icons"><a href="bprofile.html?bid='+bUserData.brand_id+'"><img src="img/ccimages/Profile_white.png" style="height:40%;width:40%"></a></div>'+ 3469 '<div class="brand_icons"><a href="catalogues.html?bid='+bUserData.brand_id+'"><img src="img/ccimages/Shop_white.png" style="height:40%;width:40%"></a></div>'+ 3470 '</div>'+ 3471 '</div></a></div>'; 3472 $$('#conn-brand').append(connbhtmls); 3473 flagval++; 3474 } 3475 } 3476 }); 3477 } 3478 }); 3479 } 3480 } 3481 //console.log("Brands are : " +conBrandsArray+ " and number of brands are : " +conBrandsArray.length); 3482 //var branddata = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+objs.key()); 3483 3484 //}); 3485 3486 setTimeout(function(){ 3487 myApp.hideIndicator(); 3488 $$('div.lazy').trigger('lazy'); 3489 if(flagval == 0) 3490 { 3491 var valhtml = '<ul><li>'+ 3492 '<div class="item-content">'+ 3493 '<div class="item-inner">'+ 3494 '<div class="item-title" style="text-align: center;">No Brands Available.</div>'+ 3495 '<div class="button" style="margin: 0 5%"> <a href="#" onClick="userreqbrand();" class="button button-fill">Add brand</a></div>'+ 3496 '</div>'+ 3497 '</div>'+ 3498 '</li></ul>'; 3499 $$('#conn-brand').html(valhtml); 3500 myApp.hideIndicator(); 3501 } 3502 },1000); 3503 } else{ 3504 var valhtml = '<ul><li>'+ 3505 '<div class="item-content">'+ 3506 '<div class="item-inner">'+ 3507 '<div class="item-title" style="text-align: center;">No Brands Available.</div>'+ 3508 '<div class="button" style="margin: 0 5%"> <a href="#" onClick="userreqbrand();" class="button button-fill">Add brand</a></div>'+ 3509 '</div>'+ 3510 '</div>'+ 3511 '</li></ul>'; 3512 $$('#conn-brand').html(valhtml); 3513 myApp.hideIndicator(); 3514 } 3515 }); 3516 // }, 3517 // timeout: 15000 // sets timeout to 30 seconds remember you want it to be long to ensure that it isn't just a slow connection 3518 // }); 3519 });
3520 3521myApp.onPageInit('brands-invited', function (page) { 3522 myApp.showIndicator(); 3523 // $$.ajax({ 3524 // url: "https://appsforbusiness.in/testing.php", 3525 // error: function(){ 3526 // mainView.router.loadPage('error.html'); 3527 // myApp.hideIndicator(); 3528 // myApp.alert('It seems your internet is sleeping, wake him up to enjoy the app.'); 3529 // }, 3530 // success: function(){ 3531 3532 var reqconnbhtmls =''; 3533 var connbhtmls = ''; 3534 var bUserData = ''; 3535 var brandkey=''; 3536 //var firebaseBrandreqlist = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"); 3537 univUrl.child("baccess/").orderByChild(userudid+"/status").equalTo(0).on('value', function(snapshot){ 3538 $$('#brand-req').html(''); 3539 if(snapshot.exists()==true && snapshot.numChildren() > 0){ 3540 snapshot.forEach(function (objs) 3541 { 3542 //var branddata = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+objs.key()); 3543 univUrl.child("brand/"+objs.key()).once('value',function(snapshots){ 3544 var req_bUserDatas = snapshots.val(); 3545 if(req_bUserDatas.enabled_status == 1 || req_bUserDatas.enabled_status == "1") 3546 { 3547 connbhtmls += '<div class="demo-card-header-pic" style="padding: 5px 0px 5px 0;">' + 3548 '<a href="catalogues.html?bid='+req_bUserDatas.brand_id+'" >'+ 3549 '<div data-background="'+req_bUserDatas.cover_image_url+'" style="background-repeat: no-repeat !important; background-size: cover !important; background: #aaa;
3549 height:60vw;" valign="bottom" class="card-header lazy lazy-fadeIn color-white no-border">'+ 3550 '<div class="brand_heading">'+req_bUserDatas.brand_name+'<br><span style="font-size: small;font-weight: 200;">'+req_bUserDatas.brandcode+'</span></div>'+ 3551 '<div class="black_shad" style="margin-top:0;border-radius:0px;"></div>'+ 3552 '<div class="brand_social">'+ 3553 '<div class="brand_icons"><a href="#" onclick=brandaccept("'+req_bUserDatas.brand_id+'")><img src="img/ccimages/accept.png" style="height:40%;width:40%"></a></div>'+ 3554 '<div class="brand_icons"><a href="#" onclick=brandreject("'+req_bUserDatas.brand_id+'")><img src="img/ccimages/Delete_white.png" style="height:40%;width:40%"></a></div>'+ 3555 '<div class="brand_icons"><a href="bprofile.html?bid='+req_bUserDatas.brand_id+'"><img src="img/ccimages/Profile_white.png" style="height:40%;width:40%"></a></div>'+ 3556 '<div class="brand_icons"><a href="chat.html?username='+userudid+'&brandid='+req_bUserDatas.brand_id+'&bname='+bUserData.brand_name+'"><img src="img/ccimages/chat_white.png" style="height:40%;width:40%"></a></div>'+ 3557 '</div>'+ 3558 '</div></a></div>'; 3559 } 3560 setTimeout(function(){ 3561 $$('#brand-req').html(connbhtmls); 3562 myApp.hideIndicator(); 3563 $$('div.lazy').trigger('lazy'); 3564 },1000); 3565 3566 3567 }); 3568 }); 3569 }else{ 3570 var valhtml = '<ul><li>'+ 3571 '<div class="item-content">'+ 3572 '<div class="item-inner">'+ 3573 '<div class="item-title" style="text-align: center;">No Brand Invites available.</div>'+ 3574 '</div>'+ 3575 '</div>'+ 3576 '</li></ul>'; 3577 $$('#brand-req').html(valhtml); 3578 myApp.hideIndicator(); 3579 } 3580 3581 }); 3582 // }, 3583 // timeout: 15000 // sets timeout to 30 seconds remember you want it to be long to ensure that it isn't just a slow connection 3584 // }); 3585}); 3586 3587 myApp.onPageInit('brands-nearby', function (page) { 3588 myApp.showIndicator(); 3589 // $$.ajax({ 3590 // url: "https://appsforbusiness.in/testing.php", 3591 // error: function(){ 3592 // // will fire when timeout is reached 3593 // mainView.router.loadPage('error.html'); 3594 // myApp.hideIndicator(); 3595 // myApp.alert('It seems your internet is sleeping, wake him up to enjoy the app.'); 3596 // }, 3597 // success: function(){ 3598 myApp.showIndicator(); 3599 var $range = $("#rangeid"); 3600 $("#rangeid").ionRangeSlider({ 3601 type: "single", 3602 min: 5, 3603 max: 25, 3604 from: 5, 3605 step: 5, 3606 hide_min_max: true, 3607 postfix: " KM", 3608 //from_fixed: true, 3609 from_min: 5 3610 }); 3611 if (navigator.geolocation) { 3612 //console.log("call near by "); 3613 console.log("On Near By PageInit"); 3614 var options = {maximumAge: 0, timeout: 10000, enableHighAccuracy:true}; 3615 navigator.geolocation.getCurrentPosition(showPoslatlonnearby, onGError, options); 3616 3617 } else { 3618 //console.log("not get current location lat lon"); 3619 myApp.hideIndicator(); 3620 } 3621 // }, 3622 // timeout: 15000 // sets timeout to 30 seconds remember you want it to be long to ensure that it isn't just a slow connection 3623 // }); 3624 });
3625 3626 // Search Brands 3627 function ucFirst(string) { 3628 return string.substring(0, 1).toUpperCase() + string.substring(1).toLowerCase(); 3629 } 3630 3631var searchTimeout; 3632myApp.searchLocation = function (search) { 3633 if (search.trim() === '') { 3634 $$('.popup .search-results').html(''); 3635 return; 3636 } 3637 var query = encodeURIComponent('select * from geo.places where text="' + search + '"'); 3638 3639 if (searchTimeout) clearTimeout(searchTimeout); 3640 $$('.popup .preloader').show(); 3641 searchTimeout = setTimeout(function () { 3642 var html = ''; 3643 $$('.popup .search-results').html(''); 3644 //var brandKey = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"); 3645 var searchs = ucFirst(search); 3646 univUrl.child("brand/").orderByChild('brand_name').startAt(searchs).endAt(""+searchs+"\uf8ff").on('child_added', function (data) { 3647 var brandValue = data.val(); 3648 $$('.popup .preloader').hide(); 3649 var brandName = brandValue.brand_name; 3650 var city = brandValue.city; 3651 var country = brandValue.country; 3652 html = '<li data-woeid="'+brandName+'" data-city="'+city+'" data-country="'+country+'" class="close-popup"><a href="bprofile.html?bid='+brandValue.brand_id+'" class="item-content item-link"><div class="item-inner"><div class="item-title">'+brandName+' <span>'+city+', '+country+'</span></div></div></a></li>'; 3653 $$('.popup .search-results').append(html); 3654 }); 3655 }, 300); 3656}; 3657 3658// Handle search results 3659var mySearchbar = myApp.searchbar('.searchbar', { 3660 customSearch: true, 3661 onDisable: function (s) { 3662 $$('.popup input[type="search"]')[0].blur(); 3663 myApp.closeModal('.popup'); 3664 }, 3665 onSearch: function (s, q) { 3666 myApp.searchLocation(s.query); 3667 }, 3668 onClear: function (s) { 3669 $$('.popup .search-results').html(''); 3670 } 3671}); 3672$$('.popup').on('open', function () { 3673 mySearchbar.enable(); 3674}); 3675$$('.popup').on('opened', function () { 3676 $$('.popup input[type="search"]')[0].focus(); 3677}); 3678 3679myApp.onPageInit('request_catalogue', function (page) { 3680 myApp.showIndicator(); 3681 var cat_conn_htmls = ''; 3682 var user_conn_catData = ''; 3683 var rechkbkey = ''; 3684 $$('#cat-req').html(''); 3685 var cat_conn_data = ''; 3686 var reqhtmls1 = ''; 3687 var reqhtmls2 = ''; 3688 var bid = page.query.bid; 3689 //console.log(bid); 3690 var userid = userudid; 3691 //var firebasecatreqlist = new Firebase("https://fiery-fire-6430.firebaseio.com/catalogues/"+bid); 3692 univUrl.child("catalogues/"+bid).once("value", function(snapshot){ 3693 $$('#cat-req').html(''); 3694 var as = snapshot.exists(); 3695 var bs = snapshot.numChildren(); 3696 if(as==true){ 3697 if(bs==1){ 3698 var reqcatdata=snapshot.val(); 3699 //console.log(reqcatdata); 3700 //console.log(reqcatdata.cat_name); 3701 3702 var result = Object.keys(snapshot.val()); 3703 var catid = result[0]; 3704 //console.log(catid); 3705 3706 //var fcatdata = new Firebase("https://fiery-fire-6430.firebaseio.com/caccess/"+bid+"/"+catid+"/"+userudid+"/status"); 3707 univUrl.child("caccess/"+bid+"/"+catid+"/"+userudid+"/status").once('value',function(snapshotsk){ 3708 var status = snapshotsk.val(); 3709 if(snapshotsk.exists() == false){ 3710 myApp.hideIndicator(); 3711 var valhtml = ''; 3712 valhtml = '<li>'+ 3713 '<div class="item-inner" style="display:inline-block;">'+ 3714 '<div class="item-title" style="text-align:center;">No New Catalogue Invite available.</div>'+ 3715 '</div>'+ 3716 '</li>'; 3717 $$('#cat-req').html(valhtml); 3718 } else{ 3719 univUrl.child("catalogues/"+bid+"/"+catid).once("value", function(snapshot){ 3720 var reqcatdata=snapshot.val(); 3721 //console.log(reqcatdata); 3722 //console.log(reqcatdata.cat_name); 3723 if(reqcatdata.cat_onoff==1 || reqcatdata.cat_onoff == "1"){ 3724 reqhtmls2 = '<li class="demo-card-header-pic" style="padding: 5px 0px 5px 0;">' + 3725 '<div data-background="'+reqcatdata.cat_img+'" style="background-repeat: no-repeat !important; background-size: cover !important; background: #aaa;
3725 height:60vw;" valign="bottom" class="card-header lazy lazy-fadeIn color-white no-border">'+ 3726 '<div class="brand_heading"><span style="font-size: larger;font-weight: bolder;"><div class="item-title">'+reqcatdata.cat_name+'</div></span><span style="font-size: small;font-weight: 600;">'+reqcatdata.cat_orderstatus+'</span></div>'+ 3727 '<div class="black_shad" style="margin-top:0;border-radius:0px;"></div>'+ 3728 '<div class="brand_social">'+ 3729 '<div class="brand_icons"><a href="#" onclick=brandcataccept("'+reqcatdata.brand_id+'","'+reqcatdata.cat_id+'")><img src="img/ccimages/accept.png" style="height:40%;width:40%"></a></div>'+ 3730 '<div class="brand_icons"><a href="#" onclick=brandcatreject("'+reqcatdata.brand_id+'","'+reqcatdata.cat_id+'")><img src="img/ccimages/Delete_white.png" style="height:40%;width:40%"></a></div>'+ 3731 '</div>'+ 3732 '</div></li>'; 3733 setTimeout(function(){ 3734 $$('#cat-req').html(reqhtmls2); 3735 myApp.hideIndicator(); 3736 $$('div.lazy').trigger('lazy'); 3737 },500) ; 3738 } 3739 }); 3740 } 3741 }); 3742 3743 }else{ 3744 //More then one catalogue 3745 snapshot.forEach(function(newdata){ 3746 var reqcatdata = newdata.val(); 3747 var cid = newdata.key(); 3748 // //console.log('cid..'+cid) ; 3749 //var fcatdata = new Firebase("https://fiery-fire-6430.firebaseio.com/caccess/"+bid+"/"+cid+"/"+userudid+"/status"); 3750 univUrl.child("caccess/"+bid+"/"+cid+"/"+userudid+"/status").once('value',function(snapshots){ 3751 var status = snapshots.val(); 3752 //console.log(cid +"..."+ status); 3753 if(status == 0){ 3754 if(reqcatdata.cat_onoff == 1 || reqcatdata.cat_onoff == "1") 3755 { 3756 reqhtmls1 += '<li class="demo-card-header-pic" style="padding: 5px 0px 5px 0;">' + 3757 '<div data-background="'+reqcatdata.cat_img+'" style="background-repeat: no-repeat !important; background-size: cover !important; background: #aaa;
3757 height:60vw;" valign="bottom" class="card-header lazy lazy-fadeIn color-white no-border">'+ 3758 '<div class=" brand_heading"><span style="font-size: larger;font-weight: bolder;"><div class="item-title">'+reqcatdata.cat_name+'</div></span><span style="font-size: small;font-weight: 600;">'+reqcatdata.cat_orderstatus+'</span></div>'+ 3759 '<div class="black_shad" style="margin-top:0;border-radius:0px;"></div>'+ 3760 '<div class="brand_social">'+ 3761 '<div class="brand_icons"><a href="#" onclick=brandcataccept("'+reqcatdata.brand_id+'","'+reqcatdata.cat_id+'")><img src="img/ccimages/accept.png" style="height:40%;width:40%"></a></div>'+ 3762 '<div class="brand_icons"><a href="#" onclick=brandcatreject("'+reqcatdata.brand_id+'","'+reqcatdata.cat_id+'")><img src="img/ccimages/Delete_white.png" style="height:40%;width:40%"></a></div>'+ 3763 '</div>'+ 3764 '</div></li>'; 3765 setTimeout(function(){ 3766 $$('#cat-req').html(reqhtmls1); 3767 myApp.hideIndicator(); 3768 $$('div.lazy').trigger('lazy'); 3769 },500) ; 3770 } 3771 }else{ 3772 var valhtml = ''; 3773 3774 valhtml = ' <ul> <li> <div class="item-content"> <div class="item-inner"> <div class="item-title" style="text-align: center;">No new Catalogue Invite available.</div></div></div></li></ul>'; 3775 $$('#cat-req').html(valhtml); 3776 myApp.hideIndicator(); 3777 3778 } 3779 }); 3780 3781 }); 3782 } 3783 }else{ 3784 //no cat avelable 3785 var valhtml = ''; 3786 valhtml = '<li>'+ 3787 '<div class="item-content">'+ 3788 '<div class="item-inner">'+ 3789 '<div class="item-title" style="text-align: center;">No new Catalogue Invite available.</div>'+ 3790 '</div>'+ 3791 '</div>'+ 3792 '</li>'; 3793 $$('#cat-req').html(valhtml); 3794 myApp.hideIndicator(); 3795 } 3796 }); 3797}); 3798//End Requested catalogue 3799 3800myApp.onPageInit('catalogue', function (page) { 3801 myApp.showIndicator(); 3802 3803//var firebaseBrands = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart"); 3804 univUrl.child("users/cc/"+userudid+"/cart").on('value', function(snapshot){ 3805 var b = snapshot.exists(); 3806 var val = snapshot.numChildren(); 3807 //console.log("number of cart..."+val); 3808 $counter = $('.notification-counter') 3809 $counter.text(val).css({top: '-4px'}).transition({top: '-2px', opacity: 1}); 3810 }); 3811 3812 var cat_conn_htmls = ''; 3813 var user_conn_catData = ''; 3814 var rechkbkey = ''; 3815 var cat_conn_data = ''; 3816 var flagvalcat = 'false'; 3817 //console.log(page.query.bid); 3818 window.localStorage.setItem("callbrandid",page.query.bid); 3819 var htmls1conn = ''; 3820 var bid = page.query.bid; 3821 3822 setTimeout(function(){ 3823 //var bcurrency = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+page.query.bid+"/currency"); 3824 univUrl.child("brand/"+page.query.bid+"/currency").once("value", function(snapshotcur) 3825 { 3826 window.localStorage.setItem("bcurrency",snapshotcur.val()); 3827 }); 3828 //var bcurrency = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+page.query.bid+"/min_order_price"); 3829 univUrl.child("brand/"+page.query.bid+"/min_order_price").once("value", function(snapshotcur) 3830 { 3831 window.localStorage.setItem("bminordval",snapshotcur.val()); 3832 }); 3833 },200); 3834 3835 //var firebasecatlistreq = new Firebase("https://fiery-fire-6430.firebaseio.com/catalogues/"+bid); 3836 univUrl.child("catalogues/"+bid).once("value", function (snapshot){ 3837 $$('#catConnectul').html(''); 3838 var noofcat = snapshot.numChildren(); 3839 if((snapshot.exists()==true) && (snapshot.numChildren() > 0)) { 3840 snapshot.forEach(function (objs) { 3841 univUrl.child("catalogues/"+bid+"/"+objs.key()).once("value", function (snapshotcat) { 3842 var catdata = snapshotcat.val(); 3843 //console.log(catdata); 3844 //console.log(snapshotcat.exists()); 3845 if(catdata.parentid=="root") { 3846 if(catdata.cat_onoff == 1 || catdata.cat_onoff == "1") { 3847 if(catdata.cat_privacystatus == 0 || catdata.cat_privacystatus == "0") { 3848 flagvalcat = 'true'; 3849 //console.log("catdata.cat_id.."+catdata.cat_id+"catdata.cat_privacystatus..."+catdata.cat_privacystatus); 3850 if(catdata.no_of_child > 0){ 3851 subcat = '<a href="subcatalogue.html?bid='+catdata.brand_id+'&cid='+catdata.cat_id+'">'; 3852 }else{ 3853 subcat = '<a href="products.html?bid='+catdata.brand_id+'&cid='+catdata.cat_id+'&pwise='+catdata.cat_orderstatus+'">'; 3854 } 3855 htmls1conn += '<li class="demo-card-header-pic" style="padding: 5px 0px 5px 0;">' + 3856 subcat+ 3857 '<div data-background="'+catdata.cat_img+'" style="background-repeat: no-repeat !important; background-size: cover !important; background: #aaa;
3857 height:60vw;" valign="bottom" class="card-header lazy lazy-fadeIn color-white no-border">'+ 3858 '<div class="brand_heading"><span style="font-size: larger;font-weight: bolder;">'+catdata.cat_name+'</span><br><span style="font-size: small;font-weight: 600;">'+catdata.cat_orderstatus+'</span></div>'+ 3859 '<div class="black_shad" style="margin-top:0;border-radius:0px;"></div>'+ 3860 '<div class="brand_social">'+ 3861 '<div class="brand_icons"><a href="#" onclick="catalogueinfo(\'' + catdata.brand_id + '\', \'' + catdata.cat_id + '\');"><img src="img/ccimages/info_icon.png" style="height:40%;width:40%"></a></div>'+ 3862 '</div>'+ 3863 '</div></a></li>'; 3864 //console.log(htmls1conn); 3865 $$('#catConnectul').html(htmls1conn); 3866 myApp.hideIndicator(); 3867 $$('div.lazy').trigger('lazy'); 3868 } else{ //privacy sts off 3869 //var scatdata = new Firebase("https://fiery-fire-6430.firebaseio.com/caccess/"+bid+"/"+catdata.cat_id+"/"+userudid+"/status"); 3870 univUrl.child("caccess/"+bid+"/"+catdata.cat_id+"/"+userudid+"/status").once('value',function(snapshots){ 3871 var status = snapshots.val(); 3872 if(status==2){ 3873 flagvalcat = 'true'; 3874 if(catdata.no_of_child > 0){ 3875 subcat = '<a href="subcatalogue.html?bid='+catdata.brand_id+'&cid='+catdata.cat_id+'">'; 3876 }else{ 3877 subcat = '<a href="products.html?bid='+catdata.brand_id+'&cid='+catdata.cat_id+'&pwise='+catdata.cat_orderstatus+'">'; 3878 } 3879 htmls1conn += '<li class="demo-card-header-pic" style="padding: 5px 0px 5px 0;">' + 3880 subcat+ 3881 '<div data-background="'+catdata.cat_img+'" style="background-repeat: no-repeat !important; background-size: cover !important; background: #aaa;
3881 height:60vw;" valign="bottom" class="card-header lazy lazy-fadeIn color-white no-border">'+ 3882 '<div class="brand_heading"><span style="font-size: large;font-weight: bolder;">'+catdata.cat_name+'</span><br><span style="font-size: small;font-weight: 600;">'+catdata.cat_orderstatus+'</span></div>'+ 3883 '<div class="black_shad" style="margin-top:0;border-radius:0px;"></div>'+ 3884 '<div class="brand_social">'+ 3885 '<div class="brand_icons"><a href="#" onclick=brandcatreject("'+catdata.brand_id+'","'+catdata.cat_id+'")><img src="img/ccimages/Delete_white.png" style="height:40%;width:40%"></div>'+ 3886 '<div class="brand_icons"><a href="#" onclick="catalogueinfo(\'' + catdata.brand_id + '\', \'' + catdata.cat_id + '\');"><img src="img/ccimages/info_icon.png" style="height:40%;width:40%"></a></div>'+ 3887 '</div>'+ 3888 '</div></a></li>'; 3889 $$('#catConnectul').html(htmls1conn); 3890 myApp.hideIndicator(); 3891 $$('div.lazy').trigger('lazy'); 3892 } 3893 }); 3894 } 3895 setTimeout(function(){ 3896 //console.log('flagvalcat... '+flagvalcat); 3897 if(flagvalcat != 'true') 3898 { 3899 var htmls1conn = ''; 3900 htmls1conn = ' <ul> <li> <div class="item-content"> <div class="item-inner"> <div class="item-title" style="text-align: center;">No Connected Catalogue Available.</div></div></div></li></ul>'; 3901 $$('#catConnectul').html(htmls1conn); 3902 myApp.hideIndicator(); 3903 } 3904 },400); 3905 3906 } else{ 3907 setTimeout(function(){ 3908 //console.log('flagvalcat... '+flagvalcat); 3909 if(flagvalcat != 'true') { 3910 var htmls1conn = ''; 3911 htmls1conn = ' <ul> <li> <div class="item-content"> <div class="item-inner"> <div class="item-title" style="text-align: center;">No Connected Catalogue Available.</div></div></div></li></ul>'; 3912 $$('#catConnectul').html(htmls1conn); 3913 myApp.hideIndicator(); 3914 } 3915 },400); 3916 } 3917 }//End catalogue if root id 3918 }); 3919 });//End snapshot.forEach 3920 } else{ 3921 var valhtml = ''; 3922 valhtml = ' <ul> <li> <div class="item-content"> <div class="item-inner"> <div class="item-title" style="text-align: center;">No Connected Catalogue Available.</div></div></div></li></ul>'; 3923 $$('#catConnectul').html(valhtml); 3924 myApp.hideIndicator(); 3925 } 3926 }); 3927 $$('.conn-cats').on('click', function (e) { 3928 mainView.router.refreshPage('catalogues.html'); 3929 //console.log("conn catalogues load page call"); 3930 }); 3931 3932$$('.req-cat').on('click', function (e) { 3933 mainView.router.loadPage('request_cat.html?bid='+page.query.bid); 3934}); 3935 }); 3936 3937 3938 myApp.onPageInit('subcatalogue', function (page) { 3939 myApp.showIndicator(); 3940 3941 //var firebaseBrands = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart"); 3942 univUrl.child("users/cc/"+userudid+"/cart").on('value', function(snapshot){ 3943 var b = snapshot.exists(); 3944 var val = snapshot.numChildren(); 3945 //console.log("number of cart..."+val); 3946 $counter = $('.notification-counter') 3947 $counter 3948 .text(val) 3949 .css({top: '1px'}) 3950 .transition({top: '-2px', opacity: 1}); 3951 }); 3952 var htmls1 = ''; 3953 var cat_conn_htmls = ''; 3954 var user_conn_catData = ''; 3955 var rechkbkey = ''; 3956 var cat_conn_data = ''; 3957 var flagvalsubcat = 'false'; 3958 var bid = page.query.bid; 3959 var cid = page.query.cid; 3960 var userid = userudid; 3961 var scanback = page.query.backinfo; 3962 //console.log('scanback..'+scanback); 3963 if(scanback == 'callfromscan') 3964 { 3965 $$('.subproscanback').attr('href','catalogues.html?bid='+page.query.bid); 3966 }else{ 3967 $$('.subproscanback').attr('href','catalogues.html?bid='+page.query.bid); 3968 } 3969 3970 if(cid){ 3971 //var firebasecatlistreq = new Firebase("https://fiery-fire-6430.firebaseio.com/catalogues/"+bid); 3972 univUrl.child("catalogues/"+bid).once("value", function(snapshot) 3973 { 3974 $$('#scatConnectul').html('');
3975 //console.log("snapshot.exists()..."+snapshot.exists()); 3976 if(snapshot.exists() == true){ 3977 snapshot.forEach(function (objs) 3978 { //console.log(objs.val().parentid+"=="+cid+""); 3979 if(objs.val().parentid==cid){ 3980 if(objs.val().cat_onoff==1){ 3981 if(objs.val().cat_privacystatus==0){ 3982 flagvalsubcat = 'true'; 3983 htmls1 = '<div class="demo-card-header-pic" style="padding: 5px 0px 5px 0;">' + 3984 '<a href="products.html?bid='+objs.val().brand_id+'&cid='+objs.val().cat_id+'&pwise='+objs.val().cat_orderstatus+'">'+ 3985 '<div data-background="'+objs.val().cat_img+'" style="background-repeat: no-repeat !important; background-size: cover !important; background: #aaa; height:60vw;" valign="bottom" class="card-header lazy lazy-fadeIn color-white no-border">'+ 3986 '<div class="brand_heading"><span style="font-size: larger;font-weight: bolder;">'+objs.val().cat_name+'</span><br><span style="font-size: small;font-weight: 600;">'+objs.val().cat_orderstatus+'</span></div>'+ 3987 '<div class="black_shad" style="margin-top:0;border-radius:0px;"></div>'+ 3988 '<div class="brand_social">'+ 3989 '<div class="brand_icons"><a href="#" onclick="catalogueinfo(\'' + objs.val().brand_id + '\', \'' + objs.val().cat_id + '\');"><img src="img/ccimages/info_icon.png" style="height:40%;width:40%"></a></div>'+ 3990 '</div>'+ 3991 '</div></a></div>'; 3992 //console.log(htmls1); 3993 $$('#scatConnectul').append(htmls1); 3994 myApp.hideIndicator(); 3995 $$('div.lazy').trigger('lazy'); 3996 3997 }else{ 3998 //var catdata = new Firebase("https://fiery-fire-6430.firebaseio.com/caccess/"+bid+"/"+cid+"/"+userudid+"/status"); 3999 univUrl.child("caccess/"+bid+"/"+cid+"/"+userudid+"/status").once('value',function(snapshots){ 4000 var status = snapshots.val(); 4001 if(status==2 || status == "2"){ 4002 flagvalsubcat = 'true'; 4003 htmls1 = '<div class="demo-card-header-pic" style="padding: 5px 0px 5px 0;">' + 4004 '<a href="products.html?bid='+objs.val().brand_id+'&cid='+objs.val().cat_id+'&pwise='+objs.val().cat_orderstatus+'">'+ 4005 '<div data-background="'+objs.val().cat_img+'" style="background-repeat: no-repeat !important; background-size: cover !important; background: #aaa;
4005 height:60vw;" valign="bottom" class="card-header lazy lazy-fadeIn color-white no-border">'+ 4006 '<div class="brand_heading"><span style="font-size: larger;font-weight: bolder;">'+objs.val().cat_name+'</span><br><span style="font-size: small;font-weight: 600;">'+objs.val().cat_orderstatus+'</span></div>'+ 4007 '<div class="black_shad" style="margin-top:0;border-radius:0px;"></div>'+ 4008 '<div class="brand_social">'+ 4009 '<div class="brand_icons"><a href="#" onclick="catalogueinfo(\'' + objs.val().brand_id + '\', \'' + objs.val().cat_id + '\');"><img src="img/ccimages/info_icon.png" style="height:40%;width:40%"></a></div>'+ 4010 '</div>'+ 4011 '</div></a></div>'; 4012 //console.log(htmls1); 4013 4014 $$('#scatConnectul').append(htmls1); 4015 myApp.hideIndicator(); 4016 $$('div.lazy').trigger('lazy'); 4017 } 4018 }); 4019 } 4020 }else{ 4021 var valhtml = ''; 4022 } 4023 } 4024 }); 4025 setTimeout(function(){ 4026 if(flagvalsubcat == 'false') 4027 { 4028 var valhtml = ''; 4029 valhtml = '<ul><li>'+ 4030 '<div class="item-content">'+ 4031 '<div class="item-inner">'+ 4032 '<div class="item-title" style="text-align: center;">No Connected Catalogue Available.</div>'+ 4033 '</div>'+ 4034 '</div>'+ 4035 '</li></ul>'; 4036 $$('#scatConnectul').html(valhtml); 4037 myApp.hideIndicator(); 4038 4039 } 4040 },200) 4041 4042 }else{ 4043 var valhtml = ''; 4044 valhtml = '<ul><li>'+ 4045 '<div class="item-content">'+ 4046 '<div class="item-inner">'+ 4047 '<div class="item-title" style="text-align: center;">No Connected Catalogue Available.</div>'+ 4048 '</div>'+ 4049 '</div>'+ 4050 '</li></ul>'; 4051 $$('#scatConnectul').html(valhtml); 4052 myApp.hideIndicator(); 4053 4054 } 4055 4056 }); 4057 } 4058 }); 4059 4060 function catalogueinfo(bid,cid){ 4061 //console.log('brand id--'+bid+' Cat id--'+cid); 4062 //var catalogue_info = new Firebase("https://fiery-fire-6430.firebaseio.com/catalogues/"+bid+'/'+cid); 4063 univUrl.child("catalogues/"+bid+"/"+cid).on('value', function(snap){ 4064 var snapval = snap.val();
4065 var catnote = snapval.notes; 4066 if(catnote.length < 1) 4067 { 4068 var catinfo = 'No extra info available.'; 4069 } 4070 else 4071 { 4072 var catinfo = catnote; 4073 } 4074 if ($$('.picker-modal.modal-in').length > 0) { 4075 myApp.closeModal('.picker-modal.modal-in'); 4076 } 4077 myApp.pickerModal( 4078 '<div class="picker-modal" style="height:350px;">' + 4079 '<div class="toolbar">' + 4080 '<div class="toolbar-inner" style="background-color: #ff5722;">' + 4081 '<div class="left"></div>' + 4082 '<div class="right"><a href="#" class="close-picker color-white" style="padding-right:10px">Close</a></div>' + 4083 '</div>' + 4084 '</div>' + 4085 '<div class="page-content" style="padding-top:0px !important;">'+ 4086 '<div class="picker-modal-inner">' + 4087 '<div class="list-block">' + 4088 '<ul>'+ 4089 '<li><div class="item-content"><div class="item-inner"><div class="item-title label">Catalogue Info</div></div></div></li>'+ 4090 '<li><div class="item-content"><div class="item-inner"><div class="item-sub-title" style="white-space: inherit;">'+catinfo+'</div></div></div></li>'+ 4091 '</ul>'+ 4092 '</div>' + 4093 '</div></div></div>' 4094 ) 4095 }); 4096 } 4097 4098 function delcartpro(cartid){ 4099 //var UserOrdercancle = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"+cartid); 4100 univUrl.child("users/cc/"+userudid+"/cart/"+cartid).remove(); 4101 mainView.router.refreshPage('cart.html'); 4102 } 4103 4104myApp.onPageInit('addcart', function (page) { 4105var objs =''; 4106var cartaddedbid = '' ; 4107 4108var catids= $.trim("'"+page.query.catid+"'"); 4109var pids= $.trim("'"+page.query.pid+"'"); 4110var bids = $.trim("'"+page.query.bid+"'"); 4111var pid = page.query.pid; 4112var brandidkeyat1name = ''; 4113var aux1opt = ''; 4114var brandidkeyat2name = ''; 4115var aux2opt = ''; 4116var extraprice1 = 0; 4117var extraprice2 = 0; 4118 var productprice = 0; 4119 var productname = ''; 4120 var productimg =''; 4121 var att11pvalchk = 0; 4122 var att12pvalchk = 0; 4123 var attr1val ; 4124 var attr2val ; 4125 //var firebaseprod = new Firebase("https://fiery-fire-6430.firebaseio.com/products/"+page.query.bid+"/"+page.query.catid+"/"+pid); 4126 univUrl.child("products/"+page.query.bid+"/"+page.query.catid+"/"+pid).on('value', function(snapshot) { 4127 $$('#productcart').html(''); 4128 var brandidkey = snapshot.val(); 4129 //console.log(brandidkey); 4130 productprice =brandidkey.product_price; 4131 productname =brandidkey.product_name; 4132 productimg = $.trim("'"+brandidkey.product_img+"'"); 4133 brandidkeyat1name = brandidkey.att1_name; 4134 brandidkeyat2name = brandidkey.att2_name; 4135 attr1val = brandidkey.att1; 4136 attr2val = brandidkey.att2; 4137 4138 var brandidkeyat1names = $.trim("'"+brandidkeyat1name+"'"); 4139 var brandidkeyat2names = $.trim("'"+brandidkeyat2name+"'"); 4140 4141univUrl.child("products/"+page.query.bid+"/"+page.query.catid+"/"+pid+"/att1").once('value', function(snapshot) { 4142 snapshot.forEach(function (objs){ 4143 //console.log(objs.key()); 4144 aux1opt += '<option value="'+objs.val().extra_price+'">'+objs.val().value+'</option>'; 4145 }); 4146}); 4147 4148 var datatypes = typeof(attr1val); 4149 //console.log("datatype..."+datatypes); 4150 if(datatypes === 'object'){ 4151 myApp.hideIndicator(); 4152 var aux1Field = '<li>'+ 4153 '<div class="item-media"></div>'+ 4154 '<div class="item-inner">'+ 4155 '<div class="item-title label">'+brandidkeyat1name+'</div>'+ 4156 '<div class="item-input">'+ 4157 '<select id="aux1id">'+ 4158 aux1opt+ 4159 ' </select>'+ 4160 ' </div>'+ 4161 ' </div>'+ 4162 '</li>'; 4163 }else{ 4164 var aux1Field = ''; 4165 } 4166 4167univUrl.child("products/"+page.query.bid+"/"+page.query.catid+"/"+pid+"/att2").once('value', function(snapshot) { 4168 snapshot.forEach(function (objs){ 4169 //console.log(objs.key()); 4170 aux2opt += '<option value="'+objs.val().extra_price+'">'+objs.val().value+'</option>'; 4171 }); 4172}); 4173 4174 var datatype = typeof(attr2val); 4175 //console.log("datatype..."+datatype); 4176 if(datatype === 'object'){ 4177 var aux2Field = '<li>'+ 4178 '<div class="item-media"></div>'+ 4179 '<div class="item-inner">'+ 4180 '<div class="item-title label">
4180'+brandidkeyat2name+'</div>'+ 4181 '<div class="item-input">'+ 4182 '<select id="aux2id">'+ 4183 aux2opt+ 4184 '</select>'+ 4185 '</div>'+ 4186 '</div>'+ 4187 '</li>'; 4188 } else{ 4189 var aux2Field = ''; 4190 } 4191 4192 var brandidkeyat2names = $.trim("'"+brandidkeyat2name+"'"); 4193 var productnames = $.trim("'"+productname+"'"); 4194 var qty=''; 4195 var qtyField=''; 4196 var z = 0; 4197 for(var i=0;i < 100 ;i++){ 4198 z = i+1; 4199 if(i == 0){ 4200 qty +='<option value="'+z+'" selected>'+z+'</option>'; 4201 } else{ 4202 qty +='<option value="'+z+'">'+z+'</option>'; 4203 } 4204 } 4205 qtyField += '<li>'+ 4206 '<div class="item-media"></div>'+ 4207 '<div class="item-inner">'+ 4208 '<div class="item-title label">Qty</div>'+ 4209 '<div class="item-input">'+ 4210 '<select id="catQty">'+ 4211 qty+ 4212 '</select>'+ 4213 '</div>'+ 4214 '</div>'+ 4215 '</li>'; 4216 4217 var popupHTML = '<div class="content-block">'+ 4218 '<form id="my-form" class="list-block">'+ 4219 '<div class="list-block" style="width:100%;">'+ 4220 '<ul>'+ 4221 aux1Field+ 4222 aux2Field+ 4223 qtyField+ 4224 '</ul>'+ 4225 '</form>'+ 4226 '<div class="content-block">'+ 4227 '<a href="#" onclick="adpdtToCart('+productprice+','+bids+','+catids+','+pids+','+brandidkeyat1names+','+brandidkeyat2names+','+productnames+','+productimg+');" class="button button-round button-fill active" style="top: -15px;">Add to cart</a>'+ 4228 '</div>'+ 4229 '</div>'+ 4230 '</div>'; 4231 $$('#productcart').html(popupHTML); 4232 }); 4233}); 4234 4235 4236$$(document).on('pageBack','.page[data-page="catalogue"]', function (e) { 4237 var page = e.detail.page; 4238 //var UserOrderdelchk = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"); 4239 univUrl.child("users/cc/"+userudid+"/cart/").once('value', function(snapshot){ 4240 var cartaddedbid = snapshot.val(); 4241 if(snapshot.numChildren() > 0){ 4242 myApp.confirm('You cart has products from another brand! Click OK to empty the cart then add product again', function () { 4243 //var UserOrdercancle = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart"); 4244 univUrl.child("users/cc/"+userudid+"/cart").remove(); 4245 },function(){ 4246 var getbid = window.localStorage.getItem("callbrandid"); 4247 mainView.router.loadPage("catalogues.html?bid="+getbid); 4248 }); 4249 } 4250 }); 4251}); 4252 4253$$(document).on('pageBack','.page[data-page="user-payment"]', function (e) { 4254 mainView.router.loadPage('cart.html'); 4255}); 4256 4257$$(document).on('pageBack','.page[data-page="thank_you"]', function (e) { 4258 mainView.router.loadPage('cart.html'); 4259}); 4260 4261function adpdtToCart(productprice,bid,catid,pid,brandidkeyat1name,brandidkeyat2name,proname,pdtimage,quantity){ 4262 //console.log("call add to cart"); 4263var att1name = ''; 4264var att2name = ''; 4265var cartarr =''; 4266var catnames = ''; 4267var val1 = 0; 4268var val2 = 0; 4269var val3 =0; 4270 var get_type = ''; 4271 var pro_names =''; 4272 var ordtimes = new Date(); 4273val1 = parseInt($$('#aux1id').val()); 4274val2 = parseInt($$('#aux2id').val()); 4275val3 = parseInt($$('#catQty').val()); 4276 4277if(quantity){ 4278 val3 = quantity; //parseInt($$('#prod'+pid+'').val()); 4279} else{ 4280 val3 = parseInt($$('#catQty').val()); 4281} 4282 4283if(isNaN(val1)){ 4284 val1 =0; 4285} 4286if(isNaN(val2)){ 4287 val2 =0; 4288} 4289if(isNaN(val3)){ 4290 val3 =1; 4291} 4292var plus_all_pdtpri = 0; 4293att1name = $("#aux1id option:selected").text(); 4294att2name = $("#aux2id option:selected").text(); 4295 4296 //var getprodtype = new Firebase("https://fiery-fire-6430.firebaseio.com/catalogues/"+bid+"/"+catid); 4297 univUrl.child("catalogues/"+bid+"/"+catid).on('value', function(snapshot){ 4298 get_type = snapshot.val().cat_orderstatus; 4299 var orddatetimes = ordtimes.getDate()+'/'+ordtimes.getMonth()+'/'+ordtimes.getFullYear()+' '+ordtimes.getHours()+':'+ordtimes.getMinutes(); 4300 var at1name = brandidkeyat1name; 4301 var at2name = brandidkeyat2name; 4302 catnames = snapshot.val().cat_name; 4303 4304 if(att1name != ''){ 4305 var cartid = catid+"-"+pid+'-'+att1name; 4306 } 4307 if(att2name != ''){ 4308 var cartid = catid+"-"+pid+'-'+att2name; 4309 } 4310 if((att1name != '') && (att2name != '')){ 4311 var cartid = catid+"-"+pid+'-'+att1name+'-'+att2name; 4312 } 4313 if((att1name == '') && (att2name == '')){ 4314 var cartid = catid+"-"+pid; 4315 } 4316 cartid = cartid.replace(/[^a-zA-Z0-9]/g,'-'); 4317 if(get_type == "Catalogue Wise"){ 4318 pro_names = snapshot.val().cat_name; 4319 //var getallprodtype = new Firebase("https://fiery-fire-6430.firebaseio.com/products/"+bid+"/"+catid); 4320 univUrl.child("products/"+bid+"/"+catid).on('child_added', function(snapshot){ 4321 if(snapshot.val().act_status == 1 || snapshot.val().act_status == "1"){ 4322 plus_all_pdtpri += parseInt(snapshot.val().product_price); 4323 } 4324 }); 4325 4326 setTimeout( function() { 4327 var localbrid = window.localStorage.getItem("callbrandid"); 4328 var totalpricess = parseInt(val1*val3)+parseInt(val2*val3)+parseInt(plus_all_pdtpri*val3); 4329 cartarr = {brand_id: bid,cat_id: catid,pid: pid,p_name: pro_names,quantity:val3,at1pri:val1,at2pri:val2, 4330 at1text:att1name,at2text:att2name, at1name:brandidkeyat1name, at2name:brandidkeyat2name,baseprice:plus_all_pdtpri, 4331 pdt_img:pdtimage,totalprice:totalpricess,ordertime:orddatetimes,catbypro:get_type,catname:catnames}; 4332 4333 //var UserOrderdelchk = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"); 4334 univUrl.child("users/cc/"+userudid+"/cart/").once('value', function(snapshot){ 4335 var cartaddedbid = snapshot.val(); 4336 if(snapshot.numChildren() > 0){
4337 //var brandschild = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"); 4338 univUrl.child("users/cc/"+userudid+"/cart/").limitToFirst(1).once("child_added", function(snapshot){ 4339 var cartkey = snapshot.key(); 4340 //var branddata = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"+cartkey+"/brand_id"); 4341 univUrl.child("users/cc/"+userudid+"/cart/"+cartkey+"/brand_id").once('value',function(snapshots){ 4342 cartbid = snapshots.val(); 4343 if(cartbid == bid){ 4344 //var UserOrder = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"+cartid); 4345 UserOrder.child("users/cc/"+userudid+"/cart/"+cartid).set(cartarr); 4346 } else{ 4347 myApp.confirm('You cart has products from another brand! Click OK to empty the cart then add product again', function () { 4348 //var UserOrdercancle = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart"); 4349 univUrl.child("users/cc/"+userudid+"/cart").remove(); 4350 4351 //var UserOrder = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"+cartid); 4352 univUrl.child("users/cc/"+userudid+"/cart/"+cartid).set(cartarr); 4353 },function() 4354 { 4355 mainView.router.loadPage("cart.html"); 4356 }); 4357 } 4358 }); 4359 }); 4360 4361 }else{ 4362 //var UserOrder = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"+cartid); 4363 univUrl.child("users/cc/"+userudid+"/cart/"+cartid).set(cartarr); 4364 } 4365 }); 4366 }, 1000); 4367 }else{ 4368 4369 pro_names = proname; 4370 var totalprices = 0; 4371 totalprices = parseInt(val1*val3)+parseInt(val2*val3)+parseInt(productprice*val3); 4372//var UserOrderdelchk = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"); 4373univUrl.child("users/cc/"+userudid+"/cart/").once('value', function(snapshot){ 4374var cartaddedbid = snapshot.val(); 4375if(snapshot.numChildren() > 0){ 4376 //var brandschild = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"); 4377 univUrl.child("users/cc/"+userudid+"/cart/").limitToFirst(1).once("child_added", function(snapshot){ 4378 var cartkey = snapshot.key(); 4379 //var branddata = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"+cartkey+"/brand_id"); 4380 univUrl.child("users/cc/"+userudid+"/cart/"+cartkey+"/brand_id").once('value',function(snapshots){ 4381 cartbid = snapshots.val(); 4382 //console.log(cartbid +"=="+ bid); 4383 if(cartbid == bid){ 4384 //var UserOrder = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"+cartid); 4385 univUrl.child("users/cc/"+userudid+"/cart/"+cartid).set({brand_id: bid,cat_id: catid,pid: pid,p_name: pro_names,quantity:val3,at1pri:val1,at2pri:val2, 4386 at1text:att1name,at2text:att2name, at1name:brandidkeyat1name, at2name:brandidkeyat2name,baseprice:productprice, 4387 pdt_img:pdtimage,totalprice:totalprices,ordertime:orddatetimes,catbypro:get_type,catname:catnames}); 4388 } else{ 4389 myApp.confirm('You cart has products from another brand! Click OK to empty the cart then add product again', function () { 4390 //var UserOrdercancle = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart"); 4391 univUrl.child("users/cc/"+userudid+"/cart").remove(); 4392 4393 //var UserOrder = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"+cartid); 4394 univUrl.child("users/cc/"+userudid+"/cart/"+cartid).set({brand_id: bid,cat_id: catid,pid: pid,p_name: pro_names,quantity:val3,at1pri:val1,at2pri:val2, 4395 at1text:att1name,at2text:att2name, at1name:brandidkeyat1name, at2name:brandidkeyat2name,baseprice:productprice, 4396 pdt_img:pdtimage,totalprice:totalprices,ordertime:orddatetimes,catbypro:get_type,catname:catnames}); 4397 4398 },function(){ 4399 mainView.router.loadPage("cart.html"); 4400 }); 4401 } 4402 }); 4403 }); 4404 4405}else{ 4406 4407 //var UserOrder = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"+cartid); 4408 univUrl.child("users/cc/"+userudid+"/cart/"+cartid).set({brand_id: bid,cat_id: catid,pid: pid,p_name: pro_names,quantity:val3,at1pri:val1,at2pri:val2, 4409 at1text:att1name,at2text:att2name, at1name:brandidkeyat1name, at2name:brandidkeyat2name,baseprice:productprice, 4410 pdt_img:pdtimage,totalprice:totalprices,ordertime:orddatetimes,catbypro:get_type,catname:catnames}); 4411} 4412}); 4413 } 4414 4415 }); 4416 4417if(quantity){ 4418 4419 } else{ 4420 mainView.router.back(); 4421 } 4422} 4423 4424function prodquantityplus(prodb,prodc,prodid){ 4425 var incval = 0; 4426 var value = parseInt($$('#prod'+prodid+'').val()); 4427 if (!isNaN(value)){ 4428 // Increment 4429 $$('#prod'+prodid+'').val(value + 1); 4430 incval = parseInt($('#prod'+prodid+'').val()); 4431 if(incval>0) 4432 { 4433 //var quantitydata = new Firebase("https://fiery-fire-6430.firebaseio.com/products/"+prodb+"/"+prodc+"/"+prodid); 4434 univUrl.child("products/"+prodb+"/"+prodc+"/"+prodid).once('value',function(snapshots){ 4435 var productlist = snapshots.val(); 4436 var datatype = typeof(productlist.att1); 4437 if(datatype !== 'object'){ 4438 //var productOrder = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"+prodc+'-'+prodid); 4439 univUrl.child("users/cc/"+userudid+"/cart/"+prodc+'-'+prodid).once('value', function(snapshot) { 4440 chkproincart = snapshot.exists();
4441 if(snapshot.exists()){ 4442 var calccproprice = incval * snapshot.val().baseprice; 4443 univUrl.child("users/cc/"+userudid+"/cart/"+prodc+'-'+prodid).update({ quantity: incval ,totalprice:calccproprice}); 4444 } else{ 4445 adpdtToCart(productlist.product_price,prodb,prodc,prodid,productlist.att1_name,productlist.att2_name,productlist.product_name,productlist.product_img,incval); 4446 } 4447 }); 4448 } else{ 4449 mainView.router.loadPage('addcart.html?bid='+prodb+'&catid='+prodc+'&pid='+prodid); 4450 } 4451 }); 4452 } else{ 4453 $$('#prod'+prodid+'').val(0); 4454 } 4455 } else{ 4456 $$('#prod'+prodid+'').val(0); 4457 } 4458} 4459 4460function prodquantityminus(prodb,prodc,prodid){ 4461 var incval = 0; 4462 var value = parseInt($$('#prod'+prodid+'').val()); 4463 if (!isNaN(value)){ 4464 // Increment 4465 $$('#prod'+prodid+'').val(value - 1); 4466 incval = parseInt($('#prod'+prodid+'').val()); 4467 if(incval < 1){ 4468 myApp.confirm('Are you sure delete product from cart?', 4469 function () { 4470 //var UserOrdercancle = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"+prodc+'-'+prodid); 4471 univUrl.child("users/cc/"+userudid+"/cart/"+prodc+'-'+prodid).once('value',function(snaps){ 4472 var urlexists = snaps.exists(); 4473 if(urlexists == true){ 4474 univUrl.child("users/cc/"+userudid+"/cart/"+prodc+'-'+prodid).remove(); 4475 } else{ 4476 myApp.alert("This product has various attributes, kindly remove it from cart."); 4477 } 4478 }); 4479 },function (){}); 4480 } 4481 if(incval>0){ 4482 //var quantitydata = new Firebase("https://fiery-fire-6430.firebaseio.com/products/"+prodb+"/"+prodc+"/"+prodid); 4483 univUrl.child("products/"+prodb+"/"+prodc+"/"+prodid).once('value',function(snapshots){ 4484 var productlist = snapshots.val(); 4485 var datatype = type(productlist.att1); 4486 if(datatype != 'object'){ 4487 4488 //var productOrder = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"+prodc+'-'+prodid); 4489 univUrl.child("users/cc/"+userudid+"/cart/"+prodc+'-'+prodid).once('value', function(snapshot) { 4490 chkproincart = snapshot.exists(); 4491 if(snapshot.exists()){ 4492 var calccproprice = incval * snapshot.val().baseprice; 4493 univUrl.child("users/cc/"+userudid+"/cart/"+prodc+'-'+prodid).update({ quantity: incval ,totalprice :calccproprice}); 4494 } else{ 4495 adpdtToCart(productlist.product_price,prodb,prodc,prodid,productlist.att1_name,productlist.att2_name,productlist.product_name,productlist.product_img,incval); 4496 } 4497 }); 4498 } else{ 4499 mainView.router.loadPage('addcart.html?bid='+prodb+'&catid='+prodc+'&pid='+prodid); 4500 } 4501 }); 4502 } else{ 4503 $$('#prod'+prodid+'').val(0); 4504 } 4505 } else{ 4506 $$('#prod'+prodid+'').val(0); 4507 } 4508} 4509 4510function selectcont(){ 4511 var successCallback = function(result){ 4512 var slicedmob = result.phoneNumber; 4513 var pname = result.name; 4514 $("#frmnumberid").intlTelInput("setNumber", slicedmob); 4515 $("#mername").val(pname); 4516 }; 4517 var failedCallback = function(result){ 4518 setTimeout(function(){myApp.alert(result);},0); 4519 } 4520 window.plugins.contactNumberPicker.pick(successCallback,failedCallback); 4521} 4522 4523function quantityplus(cartid){ 4524 var addtotalcartprice = 0; 4525 var totalcartcalc; 4526 var incval = 0; 4527 4528 var currentVal = parseInt($('#'+cartid).val()); 4529 if (!isNaN(currentVal)) { 4530 $$('#'+cartid).val(currentVal + 1); 4531 incval = parseInt($('#'+cartid).val()); 4532 //var UserOrderqtyupdates = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"+cartid); 4533 univUrl.child("users/cc/"+userudid+"/cart/"+cartid).on('value', function(snapshot) { 4534 varcartdetails = snapshot.val(); 4535 totalcartcalc = parseInt(varcartdetails.baseprice * incval + varcartdetails.at1pri * incval + varcartdetails.at2pri * incval); 4536 }); 4537 4538 univUrl.child("users/cc/"+userudid+"/cart/"+cartid).update({quantity:incval,totalprice:totalcartcalc}); 4539 $$('span.tpri'+cartid).html(totalcartcalc); 4540 4541 //var UserOrdercarttotalpri = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"); 4542 univUrl.child("users/cc/"+userudid+"/cart/").on('child_added', function(snapshot){ 4543 addtotalcartprice = snapshot.val().totalprice + addtotalcartprice; 4544 }); 4545 brandminord = window.localStorage.getItem("bminordval"); 4546 //console.log(brandminord); 4547 var calcminord = parseInt(addtotalcartprice) - parseInt(brandminord) ; 4548 //console.log(addtotalcartprice +">"+ brandminord); 4549 4550 if(addtotalcartprice > brandminord){ 4551 $$("#minorderval").hide(); 4552 } 4553 if(addtotalcartprice < brandminord){ 4554 var calcminords = parseInt(addtotalcartprice) - parseInt(brandminord); 4555 $$('#minorderval').text('You are Rs. '+calcminords +'* below minimum order amount.'); 4556 } 4557 4558 $$('#carttotalamount').html(addtotalcartprice); 4559 } else { 4560 $$('#'+cartid).val(1); 4561 } 4562} 4563 4564function quantityminus(cartid){ 4565var totalcartcalcmin = 0; 4566var totalcartcalc =0; 4567var addtotalcartprice = 0; 4568var incval = 0; 4569var currentVal = parseInt($('#'+cartid).val()); 4570 4571if(currentVal-1 < 1){ 4572 myApp.confirm('Are you sure delete product from cart?', 4573 function () { 4574 //var UserOrdercancle = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"+cartid); 4575 univUrl.child("users/cc/"+userudid+"/cart/"+cartid).remove(); 4576 mainView.router.refreshPage('cart.html'); 4577 },function () { 4578 }); 4579} else{ 4580 if (!isNaN(currentVal)) { 4581 // Increment 4582 $$('#'+cartid).val(currentVal - 1); 4583 incval = parseInt($('#'+cartid).val()); 4584 //var UserOrderqtyupdate = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"+cartid); 4585 univUrl.child("users/cc/"+userudid+"/cart/"+cartid).on('value', function(snapshot) { 4586 varcartdetails = snapshot.val(); 4587 totalcartcalc = parseInt(varcartdetails.baseprice * incval + varcartdetails.at1pri * incval + varcartdetails.at2pri * incval); 4588 }); 4589 univUrl.child("users/cc/"+userudid+"/cart/"+cartid).update({quantity:incval,totalprice:totalcartcalc}); 4590 $$('span.tpri'+cartid).html(totalcartcalc); 4591 //var UserOrdercarttotalpri = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"); 4592 univUrl.child("users/cc/"+userudid+"/cart/").on('child_added', function(snapshot){ 4593 addtotalcartprice = snapshot.val().totalprice + addtotalcartprice; 4594 }); 4595 brandminord = window.localStorage.getItem("bminordval"); 4596 //console.log(brandminord); 4597 var calcminord = parseInt(addtotalcartprice) - parseInt(brandminord); 4598 4599 if(addtotalcartprice < brandminord){ 4600 $$("#minorderval").show(); 4601 var calcminords = parseInt(addtotalcartprice) - parseInt(brandminord); 4602 $$('#minorderval').text('You are Rs. '+calcminords +'* below minimum order amount.'); 4603 } 4604 $$('#carttotalamount').html(addtotalcartprice); 4605 } else { 4606 $$('#'+cartid).val(1); 4607 } 4608 } 4609} 4610 4611myApp.onPageInit('cart', function (page) { 4612 $$('#order_list').html(""); 4613 var ordertotalpri =0; 4614 var minordcol = ''; 4615 var att1li = ''; 4616 var att2li = ''; 4617 var nocart = false; 4618 var totalcartval = 0; 4619 //var firebaseOrder = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart"); 4620 univUrl.child("users/cc/"+userudid+"/cart/").on('child_added', function(snapshot){ 4621 var objs = snapshot.val(); 4622 nocart = snapshot.exists();
4623 //console.log('nocart...'+nocart); 4624 var listid = $.trim("'"+snapshot.key()+"'"); 4625 if(objs == null || objs == 0){ 4626 var template = '<li><div style="text-align: center;"><img src="img/ccimages/shopping_cart_red.png" style="height:100px; width:100px; margin-top:6%">'+ 4627 '<div>There are no items in this cart</div><a href="brands.html"><div class="button button-fill color-blue" style="margin-left: 35%; margin-right:35%;">Order Now</div></a></div></li>'; 4628 $$('#cartulid').append(template); 4629 } else{ 4630 //console.log(objs.totalprice); 4631 ordertotalpri = parseInt(ordertotalpri) + parseInt(objs.totalprice); 4632 //console.log(ordertotalpri); 4633 var pdtpri = parseInt(objs.quantity); 4634 var pricl = 'tpri'+snapshot.key(); 4635 4636 nocart = snapshot.exists(); 4637 if(objs.at1text == '' || isNaN(objs.at1pri)){ 4638 att1li = ''; 4639 } else{ 4640 att1li = '<div class="item-subtitle">'+objs.at1name+': <b>'+objs.at1text+'</b>: +'+objs.at1pri+'</div>'; 4641 } 4642 if(objs.at2text == '' || isNaN(objs.at2pri)){ 4643 att2li = ''; 4644 } else{ 4645 att2li = '<div class="item-subtitle">'+objs.at2name+': <b>'+objs.at2text+'</b> :+'+objs.at2pri+'</div>'; 4646 } 4647 var brandminval; 4648 var template = '<li>'+ 4649 '<div class="item-link item-content">'+ 4650 '<div class="item-media"><img src="'+objs.pdt_img+'" width="80"></div>'+ 4651 '<div class="item-inner" style="background: none;">'+ 4652 '<div class="item-title-row">'+ 4653 '<div class="item-title">'+objs.p_name+'</div> '+ 4654 att1li+ 4655 att2li+ 4656 '<div class="item-subtitle">Unit Price:'+objs.baseprice+'</div>'+ 4657 '<div class="item-subtitle">Amount:<span class="'+pricl+'">'+objs.totalprice+'</div>'+ 4658 '<div class="item-subtitle" style="left:15px;overflow:visible;margin-top:20px;"><i class="fa fa-trash fa-2x" onClick="delcartpro('+listid+');" style="width: 25px;"></i></div> '+ 4659 '</div>'+ 4660 '</div>'+ 4661 '</div>'+ 4662 '</div>'+ 4663 '<div>'+ 4664 '<form class="myform">'+ 4665 '<input type="button" value="-" class="qtyminus" onClick="quantityminus('+listid+');" />'+ 4666 '<input name="quantity" value='+pdtpri+' class="qty" id='+listid+' style="background:none;border:none;" />'+ 4667 '<input type="button" value="+" class="qtyplus" onClick="quantityplus('+listid+');" />'+ 4668 '</form>'+ 4669 '</div>'+ 4670 '</li>'; 4671 4672 $$('#cartulid').append(template); 4673 } 4674 var minord = window.localStorage.getItem("bminordval");
4675 calcminord = parseInt(ordertotalpri) - parseInt(minord); 4676 //console.log('calcminord...'+calcminord); 4677 if(calcminord >= 0){ 4678 minordcol = ''; 4679 } else{ 4680 minordcol = '<div class="col-100" id="minorderval" align="right" style="font-size: small;margin-top: -32px; color: #ff5722;">You are Rs. '+calcminord * -1 +' below minimum order amount.</div>'; 4681 } 4682 4683 var totalamount = '<div class="content-block" id="totalamount">'+ 4684 '<div class="row">'+ 4685 minordcol+ 4686 '<div class="col-50">Total Amount</div>'+ 4687 '<div class="col-50" id="carttotalamount" align="right">'+ordertotalpri+'</div>'+ 4688 '</div>'+ 4689 '<div class="row">'+ 4690 '<div class="col-100" style="margin-left:10px;"><h3>Enter Shipping Address</h3><hr></div>'+ 4691 '<div class="col-100 item-input" id="current" style="display:none;background:#fff;margin-top:2px;"><textarea id="cur_address" value="" placeholder="Address" style="width:100%;overflow: hidden;border: #999 1px solid;height: 100%;padding: 5px;border-radius: 10px;min-height: 120px;background-image: url(https://developers.google.com/places/documentation/images/powered-by-google-on-white.png);background-repeat: no-repeat;background-position: 175px 97px;" class="resizable"></textarea></div>'+ 4692 '<div class="col-100 item-input" id="ship" style="display:none;background:#fff;margin-top:2px;"><textarea id="ship_address" value="" placeholder="Ship Address" style="width:100%;overflow: hidden;border: #999 1px solid;height: 100%;padding: 5px;border-radius: 10px;min-height: 120px;" class="resizable"></textarea></div>'+ 4693 '<div class="col-100" style="margin: -15px 0px 0px 2px;"><p class="buttons-row"><a href="#" class="button button-round" id="myradio1" onclick="currentship()" >Current Location<br><a href="#" class="button button-round" id="myradio2" onclick="savedship()">Saved Address</a></p></div>'+ 4694 '<div class="col-100">'+ 4695 '<ul><li class="accordion-item">'+ 4696 '<a href="#" class="item-content item-link">'+ 4697 '<div class="item-inner"><div class="item-title">Comments(optional)</div></div></a>'+ 4698 '<div class="accordion-item-content"><div class="content-block">'+ 4699 '<div class="col-100 item-input" id="ordernotes" style="background:#fff;margin-top:2px;"><textarea id="addordernote" value="" placeholder="Mention Preference (if any) : Delivery/Pickup/Appointment/Visit Time, Extra Note, Request Description, Packaging Details etc." style="width:100%;overflow: hidden;border: #999 1px solid;height: 100%;padding: 5px;border-radius: 10px;min-height: 120px;" class="resizable"></textarea></div>'+ 4700 '</div>'+ 4701 '</div>'+ 4702 '</li> '+ 4703 '</ul>'+ 4704'</div>'+ 4705'<div class="col-100" id="orderbutton" align="right" style="margin-top:2px;"><a href="#" class="button button-fill button-big color-deeporange demo-confirm" id="fordisable" onclick="orderplace('+ordertotalpri+');">Place Order</a></div>'+ 4706 '</div>'+ 4707 ' </div>'; 4708 $$("#placeorder").html(totalamount); 4709 }); 4710 4711setTimeout(function(){ 4712 if(nocart == false){ 4713 var template = '<li style="margin-top: 30%;"><div style="text-align: center;"><img src="img/ccimages/shopping_cart_red.png" style="height:100px; width:100px; margin-top:6%">'+ 4714 '<div>There are no items in this cart</div><a href="brands.html"><div class="button button-fill color-blue" style="margin-left: 35%; margin-right:35%;">Order Now</div></a></div></li>'; 4715 $$('#cartulid').append(template); 4716 } 4717 4718 },300); 4719 4720 }); 4721 4722 /*******************************CHAT PROFILE**************************************/ 4723 myApp.onPageInit('chat_profile', function (page) { 4724 var myMessagebar = $$('.messagebar')[0].f7Messagebar; 4725 var users = userudid; 4726 var brandid = page.query.brandid; 4727 var appendFlag = 0; 4728 var chatuname = window.localStorage.getItem('user_name'); 4729 $$('#chatpageid').html(""); 4730 $$('.brnames').append(page.query.bname); 4731 $$('#msgid').html(""); 4732 //var messageKey = new Firebase("https://fiery-fire-6430.firebaseio.com/messages/"+brandid+"/"+users+"/message"); 4733 univUrl.child("messages/"+brandid+"/"+users+"/message").once('value', function (data) { 4734 univUrl.child("messages/"+brandid+"/"+users+"/message").limitToLast(50).on('child_added', function (data) { 4735 var sender = data.val().sender; 4736 var msg = data.val().message; 4737 var time = data.val().time; 4738 var d = $.timeago(new Date(time)); 4739 var key = data.key(); 4740 var sentmsg = "";
4741 var receivedmsg = ""; 4742 setTimeout( function () { 4743 if(sender == users){ 4744 sentmsg = '<div class="messages-date">'+d+'</div>'+ 4745 '<div class="message message-sent message-with-avatar message-first message-last message-with-tail">'+ 4746 '<div class="message-text">'+msg+'</div>'+ 4747 '<div style="background-image:url(img/52_cc.png)" class="message-avatar"></div>'+ 4748 '</div>'; 4749 $$('#msgid').append(sentmsg); 4750 } else if(sender == brandid) { 4751 var check = msg.search(/doubletick.png/g); 4752 if(check < 0) { 4753 msg = msg + '<span style="float:right; bottom:5px;right:5px;position:absolute;"><img src="img/doubletick.png"></span>'; 4754 //var msgStatusUpdateKey = new Firebase("https://fiery-fire-6430.firebaseio.com/messages/"+brandid+"/"+users+"/message/"+key); 4755 univUrl.child("messages/"+brandid+"/"+users+"/message/"+key).update({ 4756 message: msg, 4757 }); 4758 } 4759 receivedmsg = '<div class="message message-received message-with-avatar message-first message-last message-with-tail">'+ 4760 '<div class="message-name">'+page.query.bname+'</div>'+ 4761 '<div class="message-text">'+msg+'</div>'+ 4762 '<div style="background-image:url(img/ccmlogo.png)" class="message-avatar"></div>'+ 4763 '</div>'; 4764 $$('#msgid').append(receivedmsg); 4765 }//End if-else 4766 4767 $('.messages-content').animate({ 4768 scrollTop: $('.messages-content')[0].scrollHeight}, 20); 4769 }, 100); //end setTimeout function 4770 }); 4771 }); 4772 univUrl.child("messages/"+brandid+"/"+users+"/message").off('child_added'); 4773 4774 //Code for new appendd message 4775 if(appendFlag != 0) { 4776 $$('#msgid').html(""); 4777 var messageAppendKey = ""; 4778 //messageAppendKey = new Firebase("https://fiery-fire-6430.firebaseio.com/messages/"+brandid+"/"+users+"/message"); 4779 univUrl.child("messages/"+brandid+"/"+users+"/message").once('child_added', function (datasnap) { 4780 var sender = datasnap.val().sender; 4781 var msg = datasnap.val().message; 4782 var time = datasnap.val().time; 4783 var d = $.timeago(new Date(time)); 4784 //var stat = datasnap.val().status; 4785 var key = datasnap.key(); 4786 var sentmsg = ""; 4787 var receivedmsg = ""; 4788 setTimeout( function () { 4789 if(sender == users){ 4790 sentmsg = '<div class="messages-date">'+d+'</div>'+ 4791 '<div class="message message-sent message-with-avatar message-first message-last message-with-tail">'+ 4792 '<div class="message-text">'+msg+'</div>'+ 4793 '<div style="background-image:url(img/52_cc.png)" class="message-avatar"></div>'+ 4794 '</div>'; 4795 $$('#msgid').append(sentmsg); 4796 } else if(sender == brandid) { 4797 var check = msg.search(/doubletick.png/g); 4798 if(check < 0) { 4799 msg = msg + '<span style="float:right; bottom:5px;right:5px;position:absolute;"><img src="img/doubletick.png"></span>'; 4800 //var msgStatusUpdateKey = new Firebase("https://fiery-fire-6430.firebaseio.com/messages/"+brandid+"/"+users+"/message/"+key); 4801 univUrl.child("messages/"+brandid+"/"+users+"/message/"+key).update({ 4802 message: msg, 4803 }); 4804 } 4805 receivedmsg = '<div class="message message-received message-with-avatar message-first message-last message-with-tail">'+ 4806 '<div class="message-name">'+page.query.bname+'</div>'+ 4807 '<div class="message-text">'+msg+'</div>'+ 4808 '<div style="background-image:url(img/ccmlogo.png)" class="message-avatar"></div>'+ 4809 '</div>';
4810 $$('#msgid').append(receivedmsg); 4811 }//End if-else 4812 4813 $('.messages-content').animate({ 4814 scrollTop: $('.messages-content')[0].scrollHeight}, 200); 4815 }, 200); //end setTimeout function 4816 }); 4817 } 4818 4819 $$(".getmsg").on('click', function() { 4820 var msgText = $$('#msgsendid').val(); 4821 if(msgText.length !== 0) { 4822 saveMessage(brandid, users, msgText,chatuname); 4823 myMessagebar.clear(); 4824 appendFlag = 1; 4825 } else { 4826 //console.log("Textarea shouldn't be empty. Please enter text."); 4827 } 4828 });//End send click 4829 });//End chat_profile 4830 4831 function saveMessage(brandid, users, msgText,chatuname) { 4832 if((brandid != null || brandid != undefined || brandid != "null") && (users != null || users != undefined || users != "null")) { 4833 setTimeout( function(){ 4834 //var nameKey = new Firebase("https://fiery-fire-6430.firebaseio.com/messages/"+brandid+"/"+users+"/name"); 4835 univUrl.child("messages/"+brandid+"/"+users+"/name").set({ 4836 username: chatuname 4837 }); 4838 4839 //var firebaseChat = new Firebase("https://fiery-fire-6430.firebaseio.com/messages/"+brandid+"/"+users+"/message"); 4840 var pushKey = univUrl.child("messages/"+brandid+"/"+users+"/message").push(); 4841 pushKey.set({ 4842 sender: users, 4843 message: msgText, 4844 time: Firebase.ServerValue.TIMESTAMP, 4845 }, function (error){ 4846 if (error) { 4847 } else { 4848 document.getElementById("msgsendid").value=''; 4849 $$.post('https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/gcmsk1.php', {action:'device',msgtype:'mr',cname:chatuname, mobile:users, bid: brandid, msgr: msgText}, function (data) { 4850 //console.log('Notification was sent'); 4851 }); 4852 } 4853 }); 4854 },500); 4855 } else { 4856 //console.log("Error : Either brand id or user id or both isn't available for necessary operation."); 4857 } 4858 }//End saveMessage function 4859 4860function currentship() { 4861 if (navigator.geolocation) { 4862 navigator.geolocation.getCurrentPosition(showPosition); 4863 // var options = {maximumAge: 0, timeout: 10000, enableHighAccuracy:true}; 4864 // navigator.geolocation.getCurrentPosition(showPoslatlonnearby, onGError, options); 4865 } else { 4866 // x.innerHTML = "Geolocation is not supported by this browser."; 4867 } 4868} 4869 4870function showPosition(position) { 4871 myApp.showPreloader(); 4872 window.localStorage.setItem("latitude",position.coords.latitude); 4873 window.localStorage.setItem("longitude",position.coords.longitude); 4874 var clatitude = position.coords.latitude;//window.localStorage.getItem("latitude"); 4875 var clongitude = position.coords.longitude;//window.localStorage.getItem("longitude"); 4876 window.localStorage.setItem("selectedadd",'current'); 4877 var posturlss = "https://maps.googleapis.com/maps/api/geocode/json?latlng="+clatitude+","+clongitude+"&sensor=false"; 4878 4879 $$.post( posturlss, function( data ){ 4880 myApp.hidePreloader(); 4881 var datass = JSON.parse(data);// ////console.log(JSON.stringify(objs)); 4882 4883 $$("#cur_address").val(datass.results[0].formatted_address); 4884 $$("#current").show(); 4885 $$("#ship").hide(); 4886 $$("#myradio1").addClass("active"); 4887 $$("#myradio2").removeClass("active"); 4888 myApp.alert("We have fetched your approximate address. Please edit and update as per your actual."); 4889 }); 4890} 4891 4892function savedship(){ 4893 window.localStorage.setItem("selectedadd",'saved'); 4894 //var userbillingadd = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid); 4895 univUrl.child("users/cc/"+userudid).once('value', function(snapshot){ 4896 var userdata = snapshot.val(); 4897 var b = snapshot.exists(); 4898 4899 if(userdata.billing_address == "" ){ 4900 myApp.alert("Please update your profile with billing name and address"); 4901 mainView.router.loadPage('profile.html'); 4902 var shipaddress = ''; 4903 } else if(userdata.billing_name == ""){ 4904 myApp.alert("Please update your profile with billing name and address"); 4905 mainView.router.loadPage('profile.html'); 4906 var shipaddress = ''; 4907 } else{ 4908 var shipaddress = userdata.billing_address+", "+userdata.locality+", "+userdata.city+", "+userdata.state+", "+userdata.country+", "+userdata.pin; 4909 $$("#ship_address").val(shipaddress); 4910 $$("#current").hide(); 4911 $$("#ship").show(); 4912 $$("#myradio2").addClass("active"); 4913 $$("#myradio1").removeClass("active"); 4914 } 4915 }); 4916} 4917 4918 function orderplace(ordertotalpri){ 4919 myApp.confirm('Please confirm to proceed with the order.', function () { 4920 myApp.showPreloader("Your orderr is on the way ..."); 4921 var brandids = ''; 4922 var getbrandid ; 4923 var shipaddress = $$("#cur_address").val(); 4924 var savedaddress = $$("#ship_address").val(); 4925 var getordernote = $$("#addordernote").val(); 4926 var fulladdress = ''; 4927 var selected = window.localStorage.getItem("selectedadd"); 4928 if(selected === 'current'){ 4929 fulladdress = $("#cur_address").val(); 4930 } 4931 if(selected === 'saved'){ 4932 fulladdress = $("#ship_address").val(); 4933 } 4934 4935 if(fulladdress.length == 0 || fulladdress == ''){ 4936 myApp.hidePreloader(); 4937 myApp.alert("Please enter or select shipping address"); 4938 } else{ 4939 var totalcartplus = 0; 4940 var brandids = ''; 4941 var cartcatid =''; 4942 var billingname = ''; 4943 var brandname = ''; 4944 var catname = ''; 4945 var genordid = ''; 4946 var onCompleteorder = function(error) { 4947 if (error) { 4948 myApp.hidePreloader(); 4949 } else { 4950 var bId = window.localStorage.getItem("callbrandid"); 4951 var uName = window.localStorage.getItem("user_name"); 4952 var uEmail = window.localStorage.getItem("useremail"); 4953 //var connectBrandKey = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"+bId+"/"+userudid); 4954 univUrl.child("baccess/"+bId+"/"+userudid).once("value", function (bacesssnap) { 4955 var existance = bacesssnap.exists();
4956 if(existance == true) { 4957 if(bacesssnap.val().status != 2) { 4958 univUrl.child("baccess/"+bId+"/"+userudid).update({ 4959 status : 2, 4960 }); 4961 } 4962 } else{ 4963 univUrl.child("baccess/"+bId+"/"+userudid).set({ 4964 invitename: uName, 4965 status : 2, 4966 access_time: Firebase.ServerValue.TIMESTAMP, 4967 user_email: uEmail, 4968 }); 4969 } 4970 }); 4971 4972 //var fredRankRef = new Firebase('https://fiery-fire-6430.firebaseio.com/counter/ordercount/ordercount'); 4973 univUrl.child("counter/ordercount/ordercount").transaction(function (currentRank) { 4974 return currentRank+1; 4975 }); 4976 4977 univUrl.child("brand/"+brandids+"/pending_orders").transaction(function (currentRank) { 4978 return currentRank+1; 4979 }); 4980 4981 univUrl.child("brand/"+brandids+"/total_orders").transaction(function (currentRank) { 4982 return currentRank+1; 4983 }); 4984 4985 // Check if the brand to which the order was placed has substore node (exists) 4986 // if it has a substore node, then the function should run 4987 // fetch the list of all the substores and there latitude longitude 4988 // fetch shipping addresss latitude longitude and compare with sub store's latitude longitude, calculate distance 4989 // grab the mobile number and brand id of the one with minimum distance 4990 // take basic order details and create a sub node under sub store for Order ID. 4991 // Send a notification to substore brand id, mobile number, in similar way, it was sent to the main store. 4992 4993 //Sub Store Function Starts 4994 var lati = ""; 4995 var longi = ""; 4996 var kms = new Array(); 4997 var kmsOrderId = new Array(); 4998 //var storeExist = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+brandids+"/substore"); 4999 univUrl.child("/brand/"+brandids+"/substore").once('value').then(function(subsnapshot) { 5000 if(subsnapshot.exists()){
5001 var storeVal = subsnapshot.val(); 5002 subsnapshot.forEach(function(objsub){ 5003 5004 if(objsub.val().substatus == true){ 5005 var origin1 = {lat: objsub.val().latitude, lng: objsub.val().longitude}; 5006 var destinationA = fulladdress; 5007 var geocoder = new google.maps.Geocoder; 5008 var service = new google.maps.DistanceMatrixService; 5009 service.getDistanceMatrix({ 5010 origins: [origin1], 5011 destinations: [destinationA], 5012 travelMode: google.maps.TravelMode.DRIVING, 5013 unitSystem: google.maps.UnitSystem.METRIC, 5014 avoidHighways: false, 5015 avoidTolls: false 5016 }, function(response, status) { 5017 if(status !== google.maps.DistanceMatrixStatus.OK) { 5018 myApp.alert('Error was: ' + status); 5019 } else{ 5020 var originList = response.originAddresses; 5021 var destinationList = response.destinationAddresses; 5022 var showGeocodedAddressOnMap = function(asDestination) { 5023 var icon = asDestination; 5024 return function(results, status) { 5025 if (status === google.maps.GeocoderStatus.OK) { 5026 ///console.log(results); 5027 } else { 5028 myApp.alert('Geocode was not successful due to: ' + status); 5029 } 5030 }; 5031 }; 5032 var outputDiv=''; 5033 for(var i = 0; i < originList.length; i++){ 5034 var results = response.rows[i].elements; 5035 geocoder.geocode({'address': originList[i]}, 5036 showGeocodedAddressOnMap(false)); 5037 for(var j = 0; j < results.length; j++){ 5038 geocoder.geocode({'address': destinationList[j]}, 5039 showGeocodedAddressOnMap(true)); 5040 outputDiv += originList[i] + ' to ' + destinationList[j] + 5041 ': ' + results[j].distance.text + ' in ' + 5042 results[j].duration.text + '<br>'; 5043 //console.log(outputDiv); 5044 console.log(results[j].distance.text); 5045 console.log(results[j].duration.text); 5046 kms.push(results[j].duration.value); 5047 kmsOrderId.push(objsub.key()); 5048 }//End Inner for loop 5049 }//End outer for loop 5050 } 5051 }); 5052 } 5053 }); 5054 } else{ 5055 console.log("Substore not exists."); 5056 } 5057 }); 5058 //Sub Store Function Starts 5059 var uname = window.localStorage.getItem("user_name"); 5060 5061 setTimeout(function(){ 5062 var kmsMin = Math.min.apply(Math,kms); 5063 var kmsPos = kms.indexOf(kmsMin); 5064 var kmsMobile = kmsOrderId[kmsPos]; 5065 var ordtime = new Date(); 5066 var month = (ordtime.getMonth() + 1); 5067 if(month < 10){ 5068 month = "0" + month; 5069 } 5070 5071 var date = ordtime.getDate(); 5072 if(date < 10){ 5073 date = "0" + date; 5074 } 5075 5076 var hour = ordtime.getHours(); 5077 if(hour < 10){ 5078 hour = "0" + hour; 5079 } 5080 5081 var minute = ordtime.getMinutes(); 5082 if(minute < 10){ 5083 minute = "0" + minute; 5084 } 5085 5086 var orddates = date +'/'+ month +'/'+ ordtime.getFullYear() +' '+ hour +':'+ minute; 5087 if(brandids && kmsMobile){ 5088 //var firebaseSubOrder = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+brandids+"/substore/"+kmsMobile+"/orders/"+genordid); 5089 univUrl.child("/brand/"+brandids+"/substore/"+kmsMobile+"/orders/"+genordid).transaction(function (storeData){ 5090 if(storeData === null) { 5091 return { 5092 billing_name : billingname, 5093 timestamp : Firebase.ServerValue.TIMESTAMP, 5094 '.priority':Firebase.ServerValue.TIMESTAMP, 5095 ord_no: genordid, 5096 '.priority' :genordid, 5097 ord_date: orddates, 5098 mobile: userudid, 5099 brand_name: brandname, 5100 ord_status: 0 5101 }; 5102 } else{ 5103 console.log("Order Id already exists, generate new id"); 5104 return; 5105 } 5106 }, function(error, committed, snapshot) { 5107 if (error) { 5108 } else if (!committed) { 5109 console.log('We aborted the transaction (because order id already exists).'); 5110 } else { 5111 console.log('Congratulations, your order has placed successfully.'); 5112 } 5113 console.log("Order Details are :", snapshot.val()); 5114 }); 5115 //var SubStore = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+brandids+"/substore/"+kmsMobile); 5116 univUrl.child("/brand/"+brandids+"/substore/"+kmsMobile).once('value', function(storeshot){ 5117 var subStoreId = storeshot.val().selfbid; 5118 console.log("Sub Store Id - "+subStoreId); 5119 $$.post('https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/gcmsk1.php', {msgtype:'ord', cname: uname, mainbid:brandids, bid: subStoreId, amt: totalcartplus,oid:genordid,mobile:userudid}, function (datastore) { 5120 console.log("Notification sent to substore."); 5121 }); 5122 }); 5123 } 5124 5125 $$.post('https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/gcmsk1.php', {msgtype:'ord', cname: uname, bid: brandids, amt: totalcartplus,oid:genordid,mobile:userudid}, function (data) { 5126 //var cartremove = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart");
5127 univUrl.child("/users/cc/"+userudid+"/cart").remove(); 5128 }); 5129 myApp.hidePreloader(); 5130 //var paysts = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+brandids+"/user_pay_status"); 5131 univUrl.child("/brand/"+brandids+"/user_pay_status").once('value', function(snapshota){ 5132 var userpaysts = snapshota.val(); 5133 if(userpaysts == 1){ 5134 mainView.router.loadPage("payment.html?orderId="+genordid); 5135 } else{ 5136 mainView.router.loadPage("thankyou.html?orderId="+genordid); 5137 } 5138 }); 5139 myApp.hidePreloader(); 5140 }, 2000); 5141 } 5142 };//End onComplete of firebase 5143 5144 var outterArray = new Array(); 5145 var localstrbr = window.localStorage.getItem("callbrandid"); 5146 //var UserOrder = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart/"); 5147 univUrl.child("users/cc/"+userudid+"/cart/").on('child_added', function(snapshot){ 5148 var cartdetails = snapshot.val(); 5149 brandids = cartdetails.brand_id; 5150 cartcatid = cartdetails.cat_id; 5151 totalcartplus = totalcartplus + cartdetails.totalprice ; 5152 if(localstrbr == brandids){ 5153 var data = {at1name:cartdetails.at1name,at1pri:cartdetails.at1pri,at2name: cartdetails.at2name,at2pri: cartdetails.at2pri,at1text:cartdetails.at1text,at2text:cartdetails.at2text,brand_id: cartdetails.brand_id,cat_id:cartdetails.cat_id,ordertime:cartdetails.ordertime,pid: cartdetails.pid,p_name:cartdetails.p_name,quantity:cartdetails.quantity,totalprice: cartdetails.totalprice,status: 0,catname:cartdetails.catname,catorpro:cartdetails.catbypro,probasepri:cartdetails.baseprice}; 5154 outterArray.push(data); 5155 } 5156 }); 5157 var getminordpri = window.localStorage.getItem("bminordval") ; 5158 5159 if(totalcartplus < getminordpri){ 5160 myApp.hidePreloader(); 5161 myApp.alert("Your order does not meet minimum order value of the brand i.e., "+getminordpri); 5162 } else{ 5163 //var firebasegetbillname = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/billing_name"); 5164 univUrl.child("users/cc/"+userudid+"/billing_name/").once('value', function(snapshotbill){ 5165 billingname = snapshotbill.val(); 5166 }); 5167 //var getbname = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+brandids+"/brand_name"); 5168 univUrl.child("brand/"+brandids+"/brand_name").once('value', function(bnamesnap){ 5169 brandname = bnamesnap.val(); 5170 }); 5171 //var getcatname = new Firebase("https://fiery-fire-6430.firebaseio.com/catalogues/"+brandids+"/"+cartcatid+"/cat_name"); 5172 univUrl.child("catalogues/"+brandids+"/"+cartcatid+"/cat_name").on('value', function(catnamesnap){ 5173 catname = catnamesnap.val(); 5174 }); 5175 5176 ordergen(); 5177 function ordergen(incid){ 5178 //var orderIdKey = new Firebase("https://fiery-fire-6430.firebaseio.com/orders"); 5179 univUrl.child("orders/").limitToLast(1).once('child_added', function (ordersnap) { 5180 var latestOrderId = ordersnap.key(); 5181 latestOrderId = parseInt(latestOrderId); 5182 var newOrderId = latestOrderId + 1; 5183 if(incid) { 5184 genordid = incid; 5185 } else { 5186 genordid = newOrderId; 5187 } 5188 if(genordid > 1986) { 5189 var ordtimes = new Date(); 5190 var month = (ordtimes.getMonth() + 1); 5191 if(month < 10){ 5192 month = "0" + month; 5193 } 5194 5195 var date = ordtimes.getDate(); 5196 if(date < 10){ 5197 date = "0" + date; 5198 } 5199 5200 var hour = ordtimes.getHours(); 5201 if(hour < 10){ 5202 hour = "0" + hour; 5203 } 5204 5205 var minute = ordtimes.getMinutes(); 5206 if(minute < 10){ 5207 minute = "0" + minute; 5208 } 5209 var orddatetss = date +'/'+ month +'/'+ ordtimes.getFullYear() +' '+ hour +':'+ minute; 5210 //var firebaseOrderplace = new Firebase("https://fiery-fire-6430.firebaseio.com/orders/"+genordid); 5211 univUrl.child("orders/"+genordid).transaction(function (currentData){ 5212 if(currentData === null) { 5213 return { 5214 userid: userudid, 5215 billing_name : billingname,
5216 timestamp : Firebase.ServerValue.TIMESTAMP, 5217 '.priority':Firebase.ServerValue.TIMESTAMP, 5218 ord_date : orddatetss, 5219 ord_no: genordid, 5220 '.priority' :genordid, 5221 brand_id: brandids, 5222 brand_name :brandname, 5223 cat_name:catname, 5224 ord_status: 0, 5225 payment_status:0, 5226 total_ord_pri:totalcartplus, 5227 products:outterArray, 5228 ship_add:fulladdress, 5229 order_note:"No dispatch note", 5230 ord_note:getordernote, 5231 }; 5232 } else{ 5233 return; 5234 } 5235 }, function(error, committed, snapshot) { 5236 if (error) { 5237 } else if (!committed) { 5238 ordergen(genordid + 1); 5239 } else { 5240 onCompleteorder(); 5241 } 5242 }); 5243 5244 } else { 5245 myApp.alert("Sorry for your inconvience, due to some technical glitch, right now, we can't place your order, please try again."); 5246 } 5247 myApp.hidePreloader(); 5248}); 5249} 5250 } 5251} 5252}); 5253} 5254 function reportOrderBug(bugreport) { 5255 if(bugreport) { 5256 //var bugReoprtKey = new Firebase("https://fiery-fire-6430.firebaseio.com/contact/"+userudid); 5257 univUrl.child("contact/"+userudid).push({ 5258 subject: "Report Bug", 5259 message: bugreport, 5260 status: 0, 5261 time: Firebase.ServerValue.TIMESTAMP 5262 }); 5263 myApp.alert("Thank you, we appreciate your feedback, we will rectify the problem as soon as possible."); 5264 } else { 5265 //console.log("Order bug report submission failure."); 5266 } 5267 } 5268 5269/************************Thank You***********************************/ 5270 myApp.onPageInit('thank_you', function (page) { 5271 var oId = page.query.orderId; 5272 var thankBrandId = ""; 5273 var thankOrderId = ""; 5274 var thankTemplate = ""; 5275 var attrtab2 =''; 5276 $$("#thankid").html(""); 5277 //var thankKey = new Firebase("https://fiery-fire-6430.firebaseio.com/orders/"+oId); 5278 univUrl.child("orders/"+oId).on('value', function (data) { 5279 thankBrandId = data.val().brand_id; 5280 thankBrandName = data.val().brand_name; 5281 //console.log(thankBrandId); 5282 thankTemplate = '<h2 style="color:red">Thank you for your order.</h2>'+ 5283 '<p style="font-size: larger;">Your Order ID is:'+ 5284 '<a style="font-size: 20px;" href="viewaction.html?orderid='+oId+'&brandid='+data.val().brand_id+'">'+oId+'.</a>'+ 5285 'Tap on order ID to check the live status for your order. Happy Ordering!!</p>'; 5286 $$("#thankid").html(thankTemplate); 5287 thankButton = '<a href="bprofile.html?bid='+data.val().brand_id+'" class="button button-fill color-green">Call/Rate the Brand</a>'; 5288 $$("#thank_brand").html(thankButton); 5289 });//End tnahkKey.on('child_added') 5290 });//End tnank_you onPageInit 5291 5292 function delpro(keyval){ 5293 myApp.prompt('You want to delete item from cart?', 5294 function (value) { 5295 myApp.alert(keyval); 5296 },function (value) { 5297 }); 5298 } 5299 5300function imgError(image) { 5301 image.onerror = ""; 5302 image.src = "img/logo.png"; 5303 return true; 5304} 5305 5306myApp.onPageInit('product-details', function (page) { 5307 var scanback = page.query.backinfo; 5308 //var firebaseBrands = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart"); 5309 univUrl.child("users/cc/"+userudid+"/cart").on('value', function(snapshot){ 5310 var b = snapshot.exists(); 5311 var val = snapshot.numChildren(); 5312 if(snapshot.exists()){ 5313 $$('.notification-counter').text(val).css({top: '-4px'}).transition({top: '-2px', opacity: 1}); 5314 } 5315 }); 5316 5317 function imgError(image) { 5318 image.onerror = ""; 5319 image.src = "img/logo.png"; 5320 return true; 5321 } 5322 attrtab1 = ''; 5323 myApp.showIndicator(); 5324 var brandpritype = window.localStorage.getItem("bcurrency"); 5325 //var firebaseproductvire = new Firebase("https://fiery-fire-6430.firebaseio.com/products/"+page.query.bid+"/"+page.query.catid+"/"+page.query.pid); 5326 univUrl.child("products/"+page.query.bid+"/"+page.query.catid+"/"+page.query.pid).on("value", function(snapshot) { 5327 var html = ''; 5328 var provalue = snapshot.val(); 5329 html = provalue.product_name; 5330 $$('#pdtdetails').append(html); 5331 var attrtab1 = ''; 5332 var datatypes1 = type(provalue.att1); 5333 if((provalue.att1_name == '') && (datatypes1 != 'object')){ 5334 var attr1name = ''; 5335 } else{ 5336 univUrl.child("products/"+page.query.bid+"/"+page.query.catid+"/"+page.query.pid).child('att1').once("value", function(snapshotaat) { 5337 if(snapshotaat.exists() == true){ 5338 snapshotaat.forEach(function(objs){ 5339 if(isNaN(objs.val().extra_price)){ 5340 var extval2 =0; 5341 } else{ 5342 var extval2 =objs.val().extra_price; 5343 } 5344 attrtab1 += '<tr><td style="padding:5px;border:#f2f2f2 1px solid;">'+objs.val().value+'</td><td style="padding:5px;border:#f2f2f2 1px solid;">'+brandpritype+' '+extval2+'+</td></tr>'; 5345 }); 5346 } 5347 }); 5348 var attr1name = '<tr><td colspan="2" style="padding:5px;border:#f2f2f2 1px solid;text-align:center;">'+provalue.att1_name+'(Extra price)</td>'+attrtab1+'</tr>'; 5349 } 5350 var attrtab2 =''; 5351 var datatypes = typeof(provalue.att2); 5352 if((provalue.att2_name == '') && (datatypes != 'object')){ 5353 var attr2name =''; 5354 } else{ 5355 univUrl.child("products/"+page.query.bid+"/"+page.query.catid+"/"+page.query.pid).child('att2').once("value", function(snapshotaat1) { 5356 if(snapshotaat1.exists() == true){
5357 snapshotaat1.forEach(function(objs){ 5358 if(isNaN(objs.val().extra_price)){ 5359 var extval =0; 5360 } else{ 5361 var extval = objs.val().extra_price; 5362 } 5363 attrtab2 += '<tr><td style="padding:5px;border:#f2f2f2 1px solid;">'+objs.val().value+'</td><td style="padding:5px;border:#f2f2f2 1px solid;">'+brandpritype+' '+extval+'+</td></tr>'; 5364 }); 5365 } 5366 }); 5367 var attr2name = '<tr><td colspan="2" style="padding:5px;border:#f2f2f2 1px solid;text-align:center;">'+provalue.att2_name+'(Extra price)</td>'+attrtab2+'</tr>'; 5368 } 5369 var pdetails = '<table border="0" cellpadding="0" cellspacing="0" width="100%">'+ 5370 '<tr><td style="padding:5px;border:#f2f2f2 1px solid;">OFFER Price</td>'+ 5371 '<td style="padding:5px;border:#f2f2f2 1px solid;">'+provalue.product_price+'</td></tr>'+ 5372 '<tr><td style="padding:5px;border:#f2f2f2 1px solid;">MRP Price</td>'+ 5373 '<td style="padding:5px;border:#f2f2f2 1px solid;">'+provalue.mrp_price+'</td></tr>'+ 5374 '<tr><td width="50%" style="padding:5px;border:#f2f2f2 1px solid;">SKU</td>'+ 5375 '<td style="padding:5px;border:#f2f2f2 1px solid;color:gray;">'+provalue.sku+'</td></tr>'+ 5376 attr1name+ 5377 attr2name+ 5378 '<tr><td colspan="2" style="padding:5px;border:#f2f2f2 1px solid;">'+provalue.product_desc+'</td></tr>'+ 5379 '</table>'; 5380 $$('#pdtdescription').append(pdetails); 5381 var image1 = "'"+provalue.product_img+"'"; 5382 var image2 = "'"+provalue.product_img1+"'"; 5383 var image3 = "'"+provalue.product_img2+"'"; 5384 var pdtimage = '<div class="swiper-wrapper">'+ 5385 '<div class="swiper-slide"><a onclick="productPhoto('+image1+','+image2+','+image3+');"><img src="'+provalue.product_img+'" width="100%" onError="imgError(this);"></a></div>'+ 5386 '<div class="swiper-slide"><a onclick="productPhoto('+image1+','+image2+','+image3+');"><img src="'+provalue.product_img1+'" width="100%" onError="imgError(this);"></a></div>'+ 5387 '<div class="swiper-slide"><a onclick="productPhoto('+image1+','+image2+','+image3+');"><img src="'+provalue.product_img2+'" width="100%" onError="imgError(this);"></a></div>'+ 5388 '</div>'; 5389 $$('#pdtimages').html(pdtimage); 5390 if(page.query.pwise == "Catalogue Wise"){ 5391 $$("#addtocart").html(''); 5392 } else{ 5393 $$("#addtocart").html('<a href="addcart.html?bid='+page.query.bid+'&catid='+page.query.catid+'&pid='+page.query.pid+'" class="button button-fill active">Add To Cart</a>'); 5394 } 5395 myApp.hideIndicator(); 5396 }); 5397 5398var mySwiper1 = myApp.swiper('.swiper-1', { 5399 pagination:'.swiper-1 .swiper-pagination', 5400 slidesPerView: 1, 5401 spaceBetween: 50 5402}); 5403}); 5404 5405function welcomesc(){ 5406 welcomescreen.open(); // Open the screen 5407 welcomescreen.close(); // Closes it 5408} 5409 5410function productPhoto(pic1,pic2,pic3){ 5411 var myPhotoBrowserPopupDark = myApp.photoBrowser({ 5412 photos : [ pic1, pic2, pic3, ], 5413 type: 'page', 5414 backLinkText: 'Back' 5415 }); 5416 //Open photo browser 5417 setTimeout(function(){ 5418 myPhotoBrowserPopupDark.open(); 5419 }, 500); 5420} 5421 5422 5423 function type(o) { 5424 var TYPES = { 5425 'undefined' : 'undefined', 5426 'number' : 'number', 5427 'boolean' : 'boolean', 5428 'string' : 'string', 5429 '[object Function]': 'function', 5430 '[object RegExp]' : 'regexp', 5431 '[object Array]' : 'array', 5432 '[object Date]' : 'date', 5433 '[object Error]' : 'error' 5434}, 5435 TOSTRING = Object.prototype.toString; 5436 return TYPES[typeof o] || TYPES[TOSTRING.call(o)] || (o ? 'object' : 'null'); 5437} 5438 5439myApp.onPageInit('products', function (page) { 5440 myApp.showIndicator(); 5441 var allpdthtml = ''; 5442 var catcartorder =''; 5443 var pdtcount = 0; 5444 var proflag = 'false'; 5445 var bid = page.query.bid; 5446 var cid = page.query.cid; 5447 var ordType = page.query.pwise; 5448 5449 var brandcurrencr = window.localStorage.getItem('bcurrency'); 5450 //var firebaseBrands = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/cart"); 5451 univUrl.child("users/cc/"+userudid+"/cart").on('value', function(snapshot){ 5452 var b = snapshot.exists();
5453 var val = snapshot.numChildren(); 5454 if(snapshot.exists()){ 5455 $$('.notification-counter').text(val).css({top: '-4px'}).transition({top: '-2px', opacity: 1}); 5456 } 5457 }); 5458 5459 var firstChild = 0; 5460 var lastChild = 0; 5461 var numChild = 0; 5462 //var firebaseBrandss = new Firebase("https://fiery-fire-6430.firebaseio.com/products/"+bid+"/"+cid); 5463 univUrl.child("products/"+bid+"/"+cid).orderByChild('act_status').equalTo(1).once('value', function (childsnap){ 5464 numChild = childsnap.numChildren(); 5465 5466 univUrl.child("products/"+bid+"/"+cid).orderByChild('act_status').equalTo(1).limitToFirst(1).once('child_added', function (firstsnap){ 5467 firstChild = firstsnap.key(); 5468 }); 5469 5470 univUrl.child("products/"+bid+"/"+cid).orderByChild('act_status').equalTo(1).limitToLast(1).once('child_added', function (lastsnap) { 5471 lastChild = lastsnap.key(); 5472 }); 5473 5474 var startIndexTemp = 1; 5475 var startIndex = String(startIndexTemp); 5476 var nextIndexTemp = 20; 5477 var nextIndex = String(nextIndexTemp); 5478 5479 var i = 0; 5480 showProduct(); 5481 function showProduct() { 5482 var b = childsnap.exists();
5483 var pcartVal = 0; 5484 if(b == true){ 5485 univUrl.child("products/"+bid+"/"+cid).orderByKey().startAt(startIndex).endAt(nextIndex).on('child_added', function (newdata) { 5486 var productlist = newdata.val(); 5487 var actStat = productlist.act_status; 5488 if(actStat == 1) { 5489 myApp.showIndicator(); 5490 i++ 5491 var pid = newdata.key(); 5492 var prodid = "'"+pid+"'"; 5493 var prodbrand = "'"+bid+"'"; 5494 var prodcat = "'"+cid+"'"; 5495 5496 var val1 = parseInt(Math.round(productlist.product_price))/ parseInt(Math.round(productlist.mrp_price)); 5497 var val2 = val1 * 100; 5498 val2 = val2 - 100; 5499 5500 if(isNaN(val2) || val2 == 0 ) { 5501 var offprice = '<span style="color:green;"></span><br>'; 5502 } else{ 5503 var offprice = '<span style="color:green;">'+val2.toFixed(2)+'% OFF</span><br>'; 5504 } 5505 5506 if(ordType == "Catalogue Wise"){ 5507 catcartorder = '<a href="addcart.html?bid='+bid+'&catid='+cid+'&pid='+pid+'" class="button button-fill active">Order Catalogue</a>'; 5508 $$("#cartcatbtn").html(catcartorder); 5509 var cart_btn = ''; 5510 allpdthtml = '<li class="element-item metal" style="width:50%;float:left;">'+ 5511 '<div><div class="prodgrid" style="width:100%">'+ 5512 '<div class="card demo-card-header-pic">'+ 5513 '<a href="productview.html?bid='+productlist.brand_id+'&catid='+productlist.cat_id+'&pid='+productlist.pid+'&pwise='+ordType+'" class="link"><div data-background="'+productlist.product_img+'" style="background-repeat: no-repeat !important; background-size: cover !important; background: #aaa;" valign="bottom" class="card-header lazy lazy-fadeIn color-white no-border"><p class="name" style="z-index: 12;margin-bottom: inherit;font-size: 15px;">'+productlist.product_name+ 5514 '</p><div class="black_tint3"></div></div></a>'+ 5515 '<div class="card-content">'+ 5516 '<div class="card-content-inner" style="text-align: initial;">'+ 5517 '<span class="number">OP: '+brandcurrencr+' '+productlist.product_price+'</span><br>'+ 5518 '<span>MRP <del style="color:red;">'+brandcurrencr+' '+productlist.mrp_price+'</del></span><br>'+ 5519 offprice+ 5520 '</div>'+ 5521 '</div>'+ 5522 '<div class="card-footer" style="padding:3px;">'+ 5523 cart_btn+ 5524 '</div>'+ 5525 '</div>'+ 5526 '</div></div>'+ 5527 '</li>'; 5528 $$('#productt').append(allpdthtml); 5529 myApp.hideIndicator(); 5530 $$('div.lazy').trigger('lazy'); 5531 } else{ 5532 pcartVal = 0; 5533 var datatype = typeof(productlist.att1); 5534 if(datatype !== 'object'){ 5535 var cart_btn = '<a href="addcart.html?bid='+productlist.brand_id+'&catid='+productlist.cat_id+'&pid='+productlist.pid+'" class="link" style="min-width:48px;"><i class="fa fa-cart-plus fa-lg"></i></a>'+ 5536 '<form class="myform" style="margin:0;">'+ 5537 '<input type="button" value="-" class="qtyminus" onClick="prodquantityminus('+prodbrand+','+prodcat+','+prodid+');" />'+ 5538 '<input type="text" name="quantity" min="0" value="'+pcartVal+'" class="qty" id="prod'+pid+'" style="background:none;border:none;width:30px;display:inline;" />'+ 5539 '<input type="button" value="+" class="qtyplus" onClick="prodquantityplus('+prodbrand+','+prodcat+','+prodid+');" />'+ 5540 '</form>'; 5541 }else{ 5542 var cart_btn = '<a href="addcart.html?bid='+productlist.brand_id+'&catid='+productlist.cat_id+'&pid='+productlist.pid+'" class="link" style="min-width:48px;"><i class="fa fa-cart-plus fa-lg"></i></a>'; 5543 } 5544 5545 allpdthtml = '<li class="element-item metal" style="width:50%;float:left;">'+ 5546 '<div><div class="prodgrid" style="width:100%">'+ 5547 '<div class="card demo-card-header-pic">'+ 5548 '<a href="productview.html?bid='+productlist.brand_id+'&catid='+productlist.cat_id+'&pid='+productlist.pid+'&pwise='+ordType+'" class="link"><div data-background="'+productlist.product_img+'" style="background-repeat: no-repeat !important; background-size: cover !important; background: #aaa;" valign="bottom" class="card-header lazy lazy-fadeIn color-white no-border"><p class="name" style="z-index: 12;margin-bottom: inherit;font-size: 15px;">'+productlist.product_name+ 5549 '</p><div class="black_tint3"></div></div></a>'+ 5550 '<div class="card-content">'+ 5551 '<div class="card-content-inner" style="text-align: initial;">'+ 5552 '<span class="number">OP: '+brandcurrencr+' '+productlist.product_price+'</span><br>'+ 5553 '<span>MRP <del style="color:red;">'+brandcurrencr+' '+productlist.mrp_price+'</del></span><br>'+ 5554 offprice+ 5555 '</div>'+ 5556 '</div>'+ 5557 '<div class="card-footer" style="padding:3px;">'+ 5558 cart_btn+ 5559 '</div>'+ 5560 '</div>'+ 5561 '</div></div>'+ 5562 '</li>'; 5563 $$('#productt').append(allpdthtml); 5564 myApp.hideIndicator(); 5565 $$('div.lazy').trigger('lazy'); 5566 } 5567 } 5568 }); 5569 } else{ 5570 var nopdthtml = '<li class="element-item transition metal" data-category="transition" style="width:50%;float:left;">'+ 5571 '<div class="row"><div class="prodgrid" style="width:100%">'+ 5572 '<div class="card demo-card-header-pic">'+ 5573 '<a href="#" class="link"><div data-background="img/logo.png" style="background-repeat: no-repeat !important; background-size: cover !important; background: #aaa;" valign="bottom" class="card-header lazy lazy-fadeIn color-white no-border"><p class="name">'+ 5574 '</p></div></a>'+ 5575 '<div class="card-content">'+ 5576 '<div class="card-content-inner" style="text-align: initial;">'+ 5577 '<span><span class="number">No Product in Catalogue</span></span><br>'+ 5578 '<span><del style="color:red;"><i class="fa fa-inr"></i></del></span><br>'+ 5579 '<span style="color:green;"></span><br>'+ 5580 '</div>'+ 5581 '</div>'+ 5582 '<div class="card-footer">'+ 5583 '</div>'+ 5584 '</div>'+ 5585 '</div></div>'+ 5586 '</li>'; 5587 myApp.hideIndicator(); 5588 $$('#productt').append(nopdthtml); 5589 } 5590 } 5591 5592 setTimeout( function() { 5593 if((numChild > nextIndexTemp) || (i < numChild && numChild != 0)) { 5594 myApp.hideIndicator(); 5595 var ldBtn = '<p><a href="#" class="button button-fill color-deeporange ldmore">Load Products</a></p>'; 5596 $$('#loadprdid').html(ldBtn); 5597 $$('.ldmore').on('click', function(){ 5598 startIndexTemp = nextIndexTemp + 1; 5599 nextIndexTemp += 20;
5600 if((nextIndexTemp < numChild) || (i < numChild)){ 5601 startIndex = String(startIndexTemp); 5602 nextIndex = String(nextIndexTemp); 5603 showProduct(); 5604 } else if((i == numChild) ||(nextIndexTemp >= numChild)){ 5605 startIndex = String(startIndexTemp); 5606 nextIndex = String(nextIndexTemp); 5607 showProduct(); 5608 $$('#loadprdid').hide(); 5609 myApp.hideIndicator(); 5610 }//End if condition 5611 });//End ldmore click 5612 } 5613 }, 2000); 5614 }); 5615 });//End product onPageInit 5616 5617//settings page 5618myApp.onPageInit('settings', function (page) { 5619 //var firebaseSettings = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid); 5620 univUrl.child("users/cc/"+userudid).on('value', function (snapshot) { 5621 var objs = snapshot.val(); 5622 $$("#login_email").val(objs.email); 5623 $$("#login_mobile").val(userudid); 5624 5625 }); 5626 5627 //var firebaseOrder = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid+"/devices/"); 5628 univUrl.child("users/cc/"+userudid+"/devices/").on('value', function (snapshot) { 5629 $("#notification").html(''); 5630 var objs = snapshot.val(); 5631 $$.each(objs, function(i, obj) { 5632 5633 if(obj.status==1) { 5634 obj.status = "checked='checked'" 5635 } 5636 if(obj.status==0) { 5637 obj.status = ""; 5638 } 5639 if(obj.deviceModel != undefined) { 5640 5641 var template = ""; 5642 var devId = "'"+obj.deviceUUID+"'"; 5643 template = '<ul><li> <div class="item-content"> <div class="item-media"><i class="fa fa-mobile"></i></div>' + 5644 ' <div class="item-inner"> <div class="item-title">' + obj.deviceModel + ' <label class="label-switch" style="float:right; padding-top:1%"> ' + 5645 '<input type="checkbox" class="checking" name="switch"' + obj.status + ' id="'+ obj.deviceUUID +'" /> <div class="checkbox" onclick="updateStatus('+devId+')"></div> </label> </div> </div> </div> </li> </ul>'; 5646 $("#notification").append(template); 5647 } 5648 5649 }); 5650 }); 5651}); 5652 5653function updateStatus(deviceId) { 5654 //var firebaseOrder = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/" + userudid + "/devices/"+deviceId); 5655 univUrl.child("users/cc/" + userudid + "/devices/"+deviceId).once('value', function (snapshot) { 5656 var objs = snapshot.val(); 5657 if(objs.status==1){ 5658 univUrl.child("users/cc/" + userudid + "/devices/"+deviceId).update({ status: 0}); 5659 } else{ 5660 univUrl.child("users/cc/" + userudid + "/devices/"+deviceId).update({ status: 1}); 5661 } 5662 }); 5663} 5664 5665//Change password and logout function 5666function change() { 5667 myApp.showIndicator(); 5668 var username = $$('.item-input').find('input[name="login_email"]').val(); 5669 var oldpassword = $$('.item-input').find('input[name="login_pass"]').val(); 5670 var newpassword = $$('.item-input').find('input[name="new_password"]').val(); 5671 if(oldpassword.length < 6){ 5672 myApp.hideIndicator(); 5673 myApp.alert("Old Password length must be minimum 6 character long."); 5674 } else if(newpassword.length < 6){ 5675 myApp.hideIndicator(); 5676 myApp.alert("New Password length must be minimum 6 character long."); 5677 } else{ 5678 //var ref = new Firebase("https://fiery-fire-6430.firebaseio.com"); 5679 univUrl.changePassword({ 5680 email: username, 5681 oldPassword: oldpassword, 5682 newPassword: newpassword 5683 }, function (error) { 5684 if (error) { 5685 switch (error.code) { 5686 case "INVALID_PASSWORD": 5687 myApp.hideIndicator(); 5688 myApp.alert("The specified user account password is incorrect."); 5689 break; 5690 case "INVALID_USER": 5691 myApp.hideIndicator(); 5692 myApp.alert("The specified user account does not exist."); 5693 break; 5694 default: 5695 myApp.hideIndicator(); 5696 myApp.alert("Password could not be updated. Please try again!"); 5697 } 5698 } else{ 5699 var devicetoken = window.localStorage.getItem("device_token"); 5700 var model = window.localStorage.getItem("deviceModel"); 5701 var platform = window.localStorage.getItem("devicePlatform"); 5702 var uuid = window.localStorage.getItem("deviceUUID"); 5703 var version = window.localStorage.getItem("deviceVersion"); 5704 $$.ajax({
5705 url: 'https://appsforbusiness.in/cloudcatalogue/process/getjsonccmanager.php', 5706 type: 'POST', 5707 data: {mobileno:userudid,pass:newpassword,platform:platform,devicetoken:devicetoken,uuid:uuid,model:model,version:version,action:'userupdate'}, 5708 success: function (data){ 5709 var obj = JSON.parse(data); 5710 if(obj.message == 'Profile updated'){ 5711 myApp.hideIndicator(); 5712 myApp.addNotification({ 5713 message: 'Password changed successfully!', 5714 hold: 3000, 5715 closeOnClick: false 5716 }); 5717 } 5718 } 5719 }); 5720 } 5721 }); 5722 } 5723 } 5724 5725 function logout() { 5726 myApp.confirm('Are you sure? You want to logout?', 'Orderr', 5727 function () { 5728 myApp.showIndicator(); 5729 var userid = window.localStorage.getItem("firebase:session::fiery-fire-6430"); 5730 var parsjson = JSON.parse(userid); 5731 var mob_mail = parsjson.password.email; 5732 var values = mob_mail.split("@"); 5733 var mobno = values[0]; 5734 var deviceUUID = window.localStorage.getItem('deviceUUID'); 5735 5736 //var firebaseDelUser = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+mobno+"/devices/"+deviceUUID); 5737 univUrl.child("users/cc/"+mobno+"/devices/"+deviceUUID).remove(); 5738 setTimeout(function(){ 5739 window.localStorage.clear(); 5740 window.location.href = window.location.href.replace(/#.*$/, 'login'); 5741 myApp.loginScreen(); 5742 5743 myApp.hideIndicator(); 5744 myApp.alert('You are Logged Out Successfully!'); 5745 myApp.addNotification({ 5746 message: 'You are Logged Out Successfully!', 5747 hold: 3000, 5748 closeOnClick: false 5749 }); 5750 }, 500); 5751 },function (){}); 5752 } 5753 5754 //Logout Web function 5755 function logoutweb() { 5756 //myApp.confirm('Are you sure? You want to logout?', 'Cloud Catalogue', 5757 myApp.showIndicator(); 5758 var userid = window.localStorage.getItem("firebase:session::fiery-fire-6430"); 5759 var parsjson = JSON.parse(userid); 5760 var mob_mail = parsjson.password.email; 5761 var values = mob_mail.split("@"); 5762 var mobno = values[0]; 5763 var deviceUUID = window.localStorage.getItem('deviceUUID'); 5764 //var firebaseDelUser = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+mobno+"/devices/"+deviceUUID); 5765 univUrl.child("/users/cc/"+mobno+"/devices/"+deviceUUID).remove(); 5766 setTimeout(function(){ 5767 window.localStorage.clear(); 5768 window.location.href = window.location.href.replace(/#.*$/, 'login'); 5769 myApp.loginScreen(); 5770 myApp.hideIndicator(); 5771 myApp.addNotification({ 5772 message: 'You are Logged Out Successfully!', 5773 hold: 3000, 5774 closeOnClick: false 5775 }); 5776 }, 500); 5777 } 5778 5779 5780function getgeolocation() { 5781 myApp.showIndicator(); 5782 if(navigator.geolocation) { 5783 navigator.geolocation.getCurrentPosition(getPositionlatlong); 5784 } else{ 5785 } 5786} 5787 5788function getPositionlatlong(position){ 5789function initialize(){ 5790 var longitude = position.coords.longitude; 5791 var latitude = position.coords.latitude; 5792 var latLong = new google.maps.LatLng(latitude, longitude); 5793 var mapProp = { center: latLong, zoom: 10, 5794 mapTypeId: google.maps.MapTypeId.ROADMAP 5795 }; 5796 var map = new google.maps.Map(document.getElementById('map-canvas'), mapProp); 5797 var locationmarker = { 5798 url: 'img/blue_dot.png', 5799 anchor: new google.maps.Point(16, 0) 5800 } 5801 var marker = new google.maps.Marker({ 5802 position: latLong, 5803 map: map, 5804 title: 'my location', 5805 icon: locationmarker
5806 }); 5807 setMarkers(map,latitude,longitude); 5808} 5809 initialize(); // run function 5810 function setMarkers(map,latitude,longitude) { 5811 var beachesarr =[]; var i=1; 5812 var marker; 5813 var farray = []; 5814 var firebaseRef = new Firebase("https://fiery-fire-6430.firebaseio.com/locations/"); 5815 var geoFire = new GeoFire(firebaseRef); 5816 var geoQuery = geoFire.query({ 5817 center: [latitude, longitude], 5818 radius: 25 //kilometers 5819 }); 5820 geoQuery.on("key_entered", function(key, location, distance) { 5821 var showtimes = [key, location[0], location[1], i]; 5822 var image = { 5823 url: 'images/grocery.png', size: new google.maps.Size(32, 37), origin: new google.maps.Point(0, 0), anchor: new google.maps.Point(0, 32) }; 5824 var shape = { coords: [1, 1, 1, 20, 18, 20, 18, 1], type: 'poly' }; 5825 var marker = new google.maps.Marker({ 5826 position: {lat: location[0], lng: location[1]}, 5827 map: map, 5828 icon: image, 5829 shape: shape, 5830 title: key, 5831 zIndex: i 5832 }); 5833 myApp.hideIndicator(); 5834 var brand_details=''; 5835 marker.addListener('click', function() { 5836 //var Brandcoderequests = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+key); 5837 univUrl.child("brand/"+key).once('value', function(snapshot){ 5838 brand_details = snapshot.val(); 5839 if ($$('.picker-modal.modal-in').length > 0){ 5840 myApp.closeModal('.picker-modal.modal-in'); 5841 } 5842 var trvicon = ''; 5843 if(brand_details.brand_privacystatus == 0 || brand_details.brand_privacystatus == "0"){ 5844 trvicon = '<div class="brand_icons"><a href="catalogues.html?bid='+brand_details.brand_id+'" class="close-picker"><img src="img/ccimages/Shop_white.png" style="height:40%;width:40%"></a></div>'; 5845 } else{ 5846 //var Brandconnsts = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"+brand_details.brand_id+"/"+userudid+"/status"); 5847 univUrl.child("baccess/"+brand_details.brand_id+"/"+userudid+"/status").on('value', function(snapshotsts){ 5848 if(snapshotsts.val() == 2 || snapshotsts.val() == "2"){ 5849 trvicon = '<div class="brand_icons"><a href="catalogues.html?bid='+brand_details.brand_id+'" class="close-picker"><img src="img/ccimages/Shop_white.png" style="height:40%;width:40%"></a></div>'; 5850 } else{ 5851 trvicon = '<div class="brand_icons"><a href="#" onclick="brandrequests('+brand_details.brand_id+')" class="close-picker"><img src="img/ccimages/request.png" style="height:40%;width:40%"></a></div>'; 5852 } 5853 }); 5854 } 5855 myApp.pickerModal( 5856 '<div class="picker-modal" style="height: 55%;">' + 5857 '<div class="toolbar">' + 5858 '<div class="toolbar-inner">' + 5859 '<div class="left"></div>' + 5860 '<div class="right"><a href="#" class="close-picker" style="right:20px;font-size:22px;"><i class="fa fa-close"></i></a><img data-src="img/52_cc.png" class="lazy" height="20px" /></div>' + 5861 '</div>' + 5862 '</div>' + 5863 '<div class="picker-modal-inner">' + 5864 ' <div class="card">' + 5865 '<div class="card-content">' + 5866 ' <div class="list-block media-list">' + 5867 '<div class="demo-card-header-pic">' + 5868 '<img src="'+brand_details.cover_image_url+'" style="background-repeat: no-repeat !important; background-size: cover !important; background: #aaa;
5868 height:60vw;width: 100%;" valign="bottom" class="lazy lazy-fadeIn color-white no-border">'+ 5869 '<div class="brand_heading">'+brand_details.brand_name+'<br><span style="font-size: small;font-weight: 200;">'+brand_details.brandcode+'</span></div>'+ 5870 '<div class="black_shad" style="margin-top:0;border-radius:0px;"></div>'+ 5871 '<div class="brand_social">'+ 5872 '<div class="brand_icons"><a href="#" onclick="brandMap('+brand_details.latitude+','+brand_details.longitude+')" class="close-picker"><img src="img/ccimages/locationping.png" style="height:40%;width:40%"></div>'+ 5873 '<div class="brand_icons"><a href="chat.html?username='+userudid+'&brandid='+brand_details.brand_id+'&bname='+brand_details.brand_name+'" class="close-picker"><img src="img/ccimages/chat_white.png" style="height:40%;width:40%"></a></div>'+ 5874 '<div class="brand_icons"><a href="bprofile.html?bid='+brand_details.brand_id+'" class="close-picker"><img src="img/ccimages/Profile_white.png" style="height:40%;width:40%"></a></div>'+ 5875 trvicon+ 5876 '</div>'+ 5877 '</div></div>'+ 5878 '</div>' + 5879 '</div>' 5880 ) 5881 }); 5882 }); 5883 }); 5884 } 5885 } 5886 5887myApp.onPageInit('map', function(page){ 5888 getgeolocation(); 5889}); 5890 5891function initiatebranch(){ 5892 branch.init("key_live_onhVkWYYW7vw2ZZKjimaWdoauucWyCJF", function(err, data) { 5893 if (!err) { 5894 var parsed_data = JSON.parse(data.data); 5895 if(userudid.length > 6){ 5896 branch.setIdentity( 5897 userudid, 5898 function (err, data){ 5899 }); 5900 branch.link({ 5901 tags: [ 'cc', 'app' ], 5902 channel: 'CC', 5903 feature: 'dashboard', 5904 stage: 'new user', 5905 data: { 5906 mydata: userudid, 5907 foo: 'bar', 5908 '$desktop_url': 'https://bnc.lt/ccfb', 5909 '$ios_url': 'https://bnc.lt/ccfb', 5910 '$ipad_url': 'https://bnc.lt/ccfb', 5911 '$android_url': 'https://bnc.lt/ccfb', 5912 '$og_app_id': '683264281795748', 5913 '$og_title': 'Order Anything Anytime Anywhere', 5914 '$og_description': 'Download the Orderr App and order anything, anytime, anywhere', 5915 '$og_image_url': 'http://www.cloudcatalogue.in/images/steps.png' 5916 } 5917 },function(err, link) { 5918 window.localStorage.setItem("refralLink", link); 5919 }); 5920 } 5921 5922 } 5923 }); 5924} 5925 5926 /************** help page init ****************/ 5927 myApp.onPageInit('help_inner', function (page) { 5928 var pageid = page.query.pageid; 5929 //var firebaseOrder = new Firebase("https://fiery-fire-6430.firebaseio.com/help/cc/"); 5930 var template = ""; 5931 if(pageid == 'add_scan_help'){ 5932 univUrl.child("help/cc/").child('add_scan_help').on('value', function (snap) { 5933 var datavalue = snap.val(); 5934 template = '<div class="videowrapper"> ' + 5935 '<iframe title="YouTube video player" class=" hs-responsive-embed-youtube" type="text/html" width="640" height="390" src="' + datavalue.url + '" frameborder="0" allowFullScreen></iframe> </div>' + 5936 ' <div class="content-block-title">' + datavalue.title + '</div> <div class="content-block">' + 5937 ' <p>' + datavalue.textdata + '</p>'; 5938 $("#help_inner").append(template); 5939 }); 5940 } else if(pageid == 'chat_help'){ 5941 univUrl.child("help/cc/").child('chat_help').on('value', function (snap) { 5942 var datavalue = snap.val(); 5943 template = '<div class="videowrapper"> ' + 5944 '<iframe title="YouTube video player" class=" hs-responsive-embed-youtube" type="text/html" width="640" height="390" src="' + datavalue.url + '" frameborder="0" allowFullScreen></iframe> </div>' + 5945 ' <div class="content-block-title">' + datavalue.title + '</div> <div class="content-block">' + 5946 ' <p>' + datavalue.textdata + '</p>'; 5947 $("#help_inner").append(template); 5948 }); 5949 } else if(pageid == 'order_help'){ 5950 univUrl.child("help/cc/").child('order_help').on('value', function (snap) { 5951 var datavalue = snap.val(); 5952 template = '<div class="videowrapper"> ' + 5953 '<iframe title="YouTube video player" class=" hs-responsive-embed-youtube" type="text/html" width="640" height="390" src="' + datavalue.url + '" frameborder="0" allowFullScreen></iframe> </div>' + 5954 ' <div class="content-block-title">' + datavalue.title + '</div> <div class="content-block">' + 5955 ' <p>' + datavalue.textdata + '</p>'; 5956 $("#help_inner").append(template); 5957 }); 5958 } else if(pageid == 'dashboard_help'){ 5959 univUrl.child("help/cc/").child('dashboard_help').on('value', function(snap){ 5960 var datavalue = snap.val(); 5961 template = '<div class="videowrapper"> ' + 5962 '<iframe title="YouTube video player" class=" hs-responsive-embed-youtube" type="text/html" width="640" height="390" src="'+datavalue.url+'" frameborder="0" allowFullScreen></iframe> </div>' + 5963 ' <div class="content-block-title">'+datavalue.title+'</div> <div class="content-block">' + 5964 ' <p>'+datavalue.textdata+'</p>'; 5965 $("#help_inner").append(template); 5966 }); 5967 } else if(pageid == 'brand_help'){ 5968 univUrl.child("help/cc/").child('brand_help').on('value', function(snap){ 5969 var datavalue = snap.val(); 5970 template = '<div class="videowrapper"> ' + 5971 '<iframe title="YouTube video player" class=" hs-responsive-embed-youtube" type="text/html" width="640" height="390" src="'+datavalue.url+'" frameborder="0" allowFullScreen></iframe> </div>' + 5972 ' <div class="content-block-title">'+datavalue.title+'</div> <div class="content-block">' + 5973 ' <p>'+datavalue.textdata+'</p>'; 5974 $("#help_inner").append(template); 5975 }); 5976 } else if(pageid == 'payment_help'){ 5977 univUrl.child("help/cc/").child('payment_help').on('value', function(snap){ 5978 var datavalue = snap.val(); 5979 template = '<div class="videowrapper"> ' + 5980 '<iframe title="YouTube video player" class=" hs-responsive-embed-youtube" type="text/html" width="640" height="390" src="'+datavalue.url+'" frameborder="0" allowFullScreen></iframe> </div>' + 5981 ' <div class="content-block-title">'+datavalue.title+'</div> <div class="content-block">' + 5982 ' <p>'+datavalue.textdata+'</p>'; 5983 $("#help_inner").append(template); 5984 }); 5985 } else if(pageid == 'profile_help'){ 5986 univUrl.child("help/cc/").child('profile_help').on('value', function(snap){ 5987 var datavalue = snap.val(); 5988 template = '<div class="videowrapper"> ' + 5989 '<iframe title="YouTube video player" class=" hs-responsive-embed-youtube" type="text/html" width="640" height="390" src="'+datavalue.url+'" frameborder="0" allowFullScreen></iframe> </div>' + 5990 ' <div class="content-block-title">'+datavalue.title+'</div> <div class="content-block">' + 5991 ' <p>'+datavalue.textdata+'</p>'; 5992 $("#help_inner").append(template); 5993 }); 5994 } else if(pageid == 'refer_help'){ 5995 univUrl.child("help/cc/").child('refer_help').on('value', function(snap){ 5996 var datavalue = snap.val(); 5997 template = '<div class="videowrapper"> ' + 5998 '<iframe title="YouTube video player" class=" hs-responsive-embed-youtube" type="text/html" width="640" height="390" src="'+datavalue.url+'" frameborder="0" allowFullScreen></iframe> </div>' + 5999 ' <div class="content-block-title">'+datavalue.title+'</div> <div class="content-block">' + 6000 ' <p>'+datavalue.textdata+'</p>'; 6001 $("#help_inner").append(template); 6002 }); 6003 } else if(pageid == 'setting_help'){ 6004 univUrl.child("help/cc/").child('setting_help').on('value', function(snap){ 6005 var datavalue = snap.val(); 6006 template = '<div class="videowrapper"> ' + 6007 '<iframe title="YouTube video player" class=" hs-responsive-embed-youtube" type="text/html" width="640" height="390" src="'+datavalue.url+'" frameborder="0" allowFullScreen></iframe> </div>' + 6008 ' <div class="content-block-title">'+datavalue.title+'</div> <div class="content-block">' + 6009 ' <p>'+datavalue.textdata+'</p>'; 6010 $("#help_inner").append(template); 6011 }); 6012 } 6013}); 6014 6015/*function market(){ 6016 var getappurl = window.localStorage.getItem("devicePlatform"); 6017 var devicePlatform = device.platform; 6018 if(devicePlatform === 'iOS') 6019 { 6020 var url = 'https://itunes.apple.com/in/app/cloud-catalogue/id989624737'; 6021 openBrowser(url, ""); 6022 }else{ 6023 var url = 'https://play.google.com/store/apps/details?id=com.cloudcatalogue.scvpl'; 6024 window.open(url,'_system','location=yes'); 6025 } 6026}
6026*/ 6027 6028function market(){ 6029 var getappurl = window.localStorage.getItem("devicePlatform"); 6030 if(getappurl === 'Android'){ 6031 var url = 'https://play.google.com/store/apps/details?id=com.cloudcatalogue.scvpl'; 6032 }else{ 6033 var url = 'https://itunes.apple.com/in/app/cloud-catalogue/id989624737'; 6034 } 6035 window.open(url,'_system','location=yes'); 6036} 6037 6038function sendinvitemar(){ 6039 var uName = window.localStorage.getItem('user_name'); 6040 $$.post('https://api.branch.io/v1/url', {branch_key:'key_live_ehiRA7OC6nASuCZL0DwmnmiprwmXCxTL', "data":"{\"referral\": "+userudid+"}"}, function (data) { 6041 var obj = JSON.parse(data); 6042 var orderUrl = obj.url; 6043 var shareMsg = uName+" wants to Orderr your products and services on mobile through Orderr App. You can start your shop here for free, just download Orderr Manager App Now. Happy Selling! " +orderUrl; 6044 //window.plugins.socialsharing.share(shareMsg, 'Happy Selling with Orderr Managerr'); 6045 document.getElementById("sharemsgmerchant").value = shareMsg; 6046 document.getElementById("shareblock").style.display = "block"; 6047 });//End post 6048} 6049 6050/*function sendinvitemar(){ 6051 var uName = window.localStorage.getItem("user_name"); 6052 $$.post('https://api.branch.io/v1/url', {branch_key:'key_live_ehiRA7OC6nASuCZL0DwmnmiprwmXCxTL', "data":"{\"referral\": "+userudid+"}"}, function (data) { 6053 //Use this url coming in response to open a share link 6054 //myApp.alert(JSON.stringify(data)); 6055 //console.log(data); 6056 var obj = JSON.parse(data); 6057 ////console.log(JSON.stringify(data)); 6058 //console.log(obj.url); 6059 var orderUrl = obj.url; 6060 var shareMsg = uName+" wants to Orderr your products and services on mobile through Orderr App. You can start your shop here for free, just download Orderr Manager App Now. Happy Selling! " +orderUrl; 6061 //console.log("Share Msg in:" +shareMsg); 6062 window.plugins.socialsharing.share(shareMsg, 'Happy Selling with Orderr Managerr'); 6063 6064 });//End post 6065}*/ 6066 6067/*************************Refer user list*********************************************/ 6068 myApp.onPageInit('refer_user_list', function (page) { 6069 var merchantAdd = ""; 6070 var friendAdd = ""; 6071 $$('#merchantid').html(""); 6072 //var refMerchantKey = new Firebase("https://fiery-fire-6430.firebaseio.com/referredmerchant/" + userudid); 6073 univUrl.child("referredmerchant/" + userudid).once('value', function (snap) { 6074 var c = snap.numChildren(); 6075 if (c == 0) { 6076 var temp = '<li class="item-content"> <div class="item-inner" style="display:inline-block;"><div class="item-title" style="text-align:center;"><b>No referred merchant yet.</b></div> </div> </li>'+ 6077 '<li class="item-content"> <div class="item-inner" style="display:inline-block;"><div class="item-title" style="text-align:center;"><div class="button" style="margin: 0 5%"><a href="refermerchant.html" class="button button-fill demo-refer-merchant">Refer Merchant</a></div</div> </div> </li>'; 6078 $$('#merchantid').append(temp); 6079 } 6080 }); 6081 univUrl.child("referredmerchant/" + userudid).on('child_added', function (snapshot) { 6082 var a = snapshot.numChildren() 6083 var mStatus = snapshot.val().status; 6084 var mNum = snapshot.key(); 6085 var mPApporve = ""; 6086 merchantAdd = ""; 6087 if (mStatus == 0) { 6088 mPApporve = "pending"; 6089 } else if (mStatus == 1) { 6090 mPApporve = "Accepted"; 6091 } 6092 merchantAdd += '<li class="item-content">' + 6093 '<div class="item-inner">' + 6094 '<div class="item-title-row">' + 6095 '<div class="item-title"><b>' + mNum + '</b></div>' + 6096 '<div class="item-text">' + mPApporve + '<br>'+// + mType + 6097 '</div>' + 6098 '</li>'; 6099 $$('#merchantid').append(merchantAdd); 6100 }); //End refMerchantKey .on 6101 6102 $$('.friends').on('click', function (page) { 6103 $$('#friendid').html(""); 6104 friendAdd = ""; 6105 //var refFriendKey = new Firebase("https://fiery-fire-6430.firebaseio.com/referredfriend/" + userudid); 6106 univUrl.child("referredfriend/" + userudid).on('value', function (snap) { 6107 var c = snap.numChildren(); 6108 if (c == 0) { 6109 var temp = '<li class="item-content"> <div class="item-inner" style="display:inline-block;"><div class="item-title" style="text-align:center;"><b>No referred friend yet.</b></div> </div> </li>'; 6110 $$('#friendid').append(temp); 6111 } 6112 }); 6113 6114 univUrl.child("referredfriend/" + userudid).on('child_added', function (datashot) { 6115 var fStatus = datashot.val().status; 6116 var fNum = datashot.key(); 6117 6118 var fPApporve = ""; 6119 if (fStatus == 0) { 6120 fPApporve = "pending"; 6121 } else if (fStatus == 1) { 6122 fPApporve = "Accepted"; 6123 } 6124 friendAdd += '<li class="item-content">' + 6125 '<div class="item-inner">' + 6126 '<div class="item-title-row">' + 6127 '<div class="item-title"><b>' + fNum + '</b></div>' + 6128 '<div class="item-text">
6128' + fPApporve + '<div>' + 6129 '</div>' + 6130 '</div>' + 6131 '</li>'; 6132 $$('#friendid').html(friendAdd); 6133 }); 6134 }); 6135 }); 6136 6137 function sendinvite() { 6138 var uName = window.localStorage.getItem("user_name"); 6139 branch.link( { 6140 tags: [ 'Orderr', 'app' ], 6141 channel: 'Orderr', 6142 feature: 'dashboard', 6143 stage: 'new user', 6144 data: { 6145 referrer: userudid, 6146 foo: 'bar', 6147 '$desktop_url': 'https://bnc.lt/ccfb', 6148 '$ios_url': 'https://bnc.lt/ccfb', 6149 '$ipad_url': 'https://bnc.lt/ccfb', 6150 '$android_url': 'https://bnc.lt/ccfb', 6151 '$og_app_id': '683264281795748', 6152 '$og_title': 'Order Anything Anytime Anywhere', 6153 '$og_description': 'Download the Orderr App and order anything, anytime, anywhere', 6154 '$og_image_url': 'http://www.cloudcatalogue.in/images/steps.png' 6155 } 6156 },function(err, link) { 6157 if (!err) { 6158 shareMsg = uName+" got one app to Orderr Anything, Anytime, Anywhere. Excited! Get yours at "+link; 6159 document.getElementById("sharemsgfriend").value = shareMsg; 6160 document.getElementById("shareblock").style.display = "block"; 6161 } 6162 }); 6163} 6164 6165/*function sendinvite() { 6166 var uName = window.localStorage.getItem("user_name"); 6167 //console.log(uName); 6168 branch.link( { 6169 tags: [ 'Orderr', 'app' ], 6170 channel: 'Orderr', 6171 feature: 'dashboard', 6172 stage: 'new user', 6173 data: { 6174 referrer: userudid, 6175 foo: 'bar', 6176 '$desktop_url': 'https://bnc.lt/ccfb', 6177 '$ios_url': 'https://bnc.lt/ccfb', 6178 '$ipad_url': 'https://bnc.lt/ccfb', 6179 '$android_url': 'https://bnc.lt/ccfb', 6180 '$og_app_id': '683264281795748', 6181 '$og_title': 'Order Anything Anytime Anywhere', 6182 '$og_description': 'Download the Orderr App and order anything, anytime, anywhere', 6183 '$og_image_url': 'http://www.cloudcatalogue.in/images/steps.png' 6184 } 6185 }, 6186 function(err, link) { 6187 if (!err) { 6188 //console.log("Ready to share my " + link); 6189 6190 shareMsg = uName+" got one app to Orderr Anything, Anytime, Anywhere. Excited! Get yours at "+link; 6191 //console.log("Share Msg in:" +shareMsg); 6192 window.plugins.socialsharing.share(shareMsg, 'Happy Ordering with Orderr'); 6193 } 6194 }); 6195}*/ 6196 6197function rateBrand(brandid) { 6198 var newcum = 0; 6199 var avg = 0; 6200 var cumulative = ""; 6201 var avgrating = ""; 6202 var totalvotes = ""; 6203 var starFlag = 0; 6204 var existRate = 0; 6205 6206 //var rateKey = new Firebase("https://fiery-fire-6430.firebaseio.com/bratings/"+brandid+"/"+userudid); 6207 univUrl.child("bratings/"+brandid+"/"+userudid).once('value', function (datashot) { 6208 var existance = datashot.exists(); 6209 if(existance == true) { 6210 existRate = datashot.val().rating; 6211 //console.log("If :" +existRate); 6212 } else { 6213 existRate = 0; 6214 //console.log("Else :" +existRate); 6215 } 6216 }); 6217 6218 $$("#group-2-0").on("click", function () { 6219 //console.log(this.value); 6220 var rate_value = parseInt(this.value); 6221 reRateBrand(rate_value, existRate, brandid); 6222 }); 6223 6224 $$("#group-2-1").on("click", function () { 6225 //console.log(this.value); 6226 var rate_value = parseInt(this.value); 6227 reRateBrand(rate_value, existRate, brandid); 6228 }); 6229 6230 $$("#group-2-2").on("click", function () { 6231 //console.log(this.value); 6232 var rate_value = parseInt(this.value); 6233 reRateBrand(rate_value, existRate, brandid); 6234 }); 6235 6236 $$("#group-2-3").on("click", function () { 6237 //console.log(this.value); 6238 var rate_value = parseInt(this.value); 6239 reRateBrand(rate_value, existRate, brandid); 6240 }); 6241 6242 $$("#group-2-4").on("click", function () { 6243 //console.log(this.value); 6244 var rate_value = parseInt(this.value); 6245 reRateBrand(rate_value, existRate, brandid); 6246 }); 6247 }; 6248 6249 function reRateBrand(rate_value, existRate, brandid) { 6250 var starFlag = 0; 6251 myApp.confirm('Do you want to rate brand with '+rate_value+' star. Please confirm !', 'Rating', 6252 function () { 6253 if(starFlag == 0) { 6254 setTimeout( function () { 6255 //var firebaseUBratings = new Firebase("https://fiery-fire-6430.firebaseio.com/bratings/"+brandid+"/"+userudid); 6256 univUrl.child("bratings/"+brandid+"/"+userudid).set({ 6257 rating:rate_value,
6258 time_created: Firebase.ServerValue.TIMESTAMP, 6259 }); 6260 }, 1000); 6261 //var firebaseBratings = new Firebase("https://fiery-fire-6430.firebaseio.com/bratings/"+brandid); 6262 univUrl.child("bratings/"+brandid).once("value", function (snapshot){ 6263 var existance = snapshot.exists(); 6264 var numChild = snapshot.numChildren(); 6265 if(existance == true){ 6266 if(numChild < 1){ 6267 //var firebaseBrating = new Firebase("https://fiery-fire-6430.firebaseio.com/bratings/"+brandid); 6268 univUrl.child("bratings/"+brandid).set({ 6269 cumulative_Rating: rate_value, 6270 average_Rating: rate_value, 6271 }); 6272 } else { 6273 cumulative = snapshot.val().cumulative_Rating; 6274 //console.log("Existing Rating :" +existRate); 6275 cumulative = parseInt(cumulative - existRate); 6276 //console.log("Cumulative Rating after deduction:" +cumulative); 6277 avgrating = snapshot.val().average_Rating; 6278 totalvotes = snapshot.numChildren(); 6279 if(existRate == 0){ 6280 totalvotes = parseInt(totalvotes - 1); 6281 ////console.log("0 :" +existRate); 6282 }else { 6283 totalvotes = parseInt(totalvotes - 2); 6284 } 6285 newcum = parseInt(cumulative + rate_value); 6286 avg = parseFloat(newcum / totalvotes).toFixed(2); 6287 //console.log("Average :" +avg); 6288 //console.log("Comulative :" +newcum); 6289 //console.log("Current Rating :" +rate_value); 6290 updateCounter(avg, newcum, brandid); 6291 } 6292 } else { 6293 //var firebaseBrating = new Firebase("https://fiery-fire-6430.firebaseio.com/bratings/"+brandid); 6294 univUrl.child("bratings/"+brandid).set({ 6295 cumulative_Rating: rate_value, 6296 average_Rating: rate_value, 6297 }); 6298 } 6299 }); 6300 starFlag = 1; 6301 } 6302 }, function() { 6303 //console.log(parseInt(this.value)); 6304 mainView.router.refreshPage('bprofile.html'); 6305 }); 6306 } 6307 function updateCounter(avg, newcum, brandid) { 6308 //var firebaseBrating = new Firebase("https://fiery-fire-6430.firebaseio.com/bratings/"+brandid); 6309 univUrl.child("bratings/"+brandid).update({ 6310 cumulative_Rating: newcum, 6311 average_Rating: avg, 6312 }); 6313 } 6314function reqbrandbyid(brandid) 6315{ 6316 //console.log(brandid); 6317 var username = window.localStorage.getItem("user_name"); 6318 //var connstss = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+brandid+"/brand_privacystatus"); 6319 univUrl.child("brand/"+brandid+"/brand_privacystatus").once('value', function(snapshotsts) {
6320 //console.log('snapshotsts.val()...'+snapshotsts.val()); 6321 if(snapshotsts.val() == 0) 6322 { 6323 //var uaccessKey = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"+brandid+"/"+userudid); 6324 univUrl.child("baccess/"+brandid+"/"+userudid).set({ 6325 user_email: useremail, 6326 status: 2, 6327 invitename:username, 6328 access_time: Firebase.ServerValue.TIMESTAMP, 6329 }); 6330 6331 $$.post('https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/gcmsk1.php', {msgtype:'crq', cname: username, bid: brandid,mobile:userudid}, function (data) { 6332 6333 myApp.addNotification({ 6334 message: 'We have sent your request to the brand!', 6335 hold: 4000, 6336 closeOnClick: false 6337 }); 6338 }); 6339 6340 }else{ 6341 //var uaccessKey = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"+brandid+"/"+userudid); 6342 univUrl.child("baccess/"+brandid+"/"+userudid).set({ 6343 user_email: useremail, 6344 status: 1, 6345 invitename:username, 6346 access_time: Firebase.ServerValue.TIMESTAMP, 6347 }); 6348 $$.post('https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/gcmsk1.php', {msgtype:'crq', cname: username, bid: brandid,mobile:userudid}, function (data) { 6349 6350 myApp.addNotification({ 6351 message: 'We have sent your request to the brand!', 6352 hold: 4000, 6353 closeOnClick: false 6354 }); 6355 }); 6356 6357 } 6358 }); 6359 } 6360 6361myApp.onPageInit('bprofile', function (page) { 6362 $$('.minordval').on('click', function () { 6363 //console.log("call minordval"); 6364 var clickedLink = this; 6365 var popoverHTML = '<div class="popover">'+ 6366 '<div class="popover-inner">'+ 6367 '<div class="content-block">'+ 6368 '<p style="text-align:justify;">Minimum Order Value</p>'+ 6369 '</div>'+ 6370 '</div>'+ 6371 '</div>' 6372 myApp.popover(popoverHTML, clickedLink); 6373 }); 6374 $$('.bsts').on('click', function () { 6375 //console.log("call bsts"); 6376 var clickedLink = this; 6377 var popoverHTML = '<div class="popover">'+ 6378 '<div class="popover-inner">'+ 6379 '<div class="content-block">'+ 6380 '<p style="text-align:justify;">Brand View Status</p>'+ 6381 '</div>'+ 6382 '</div>'+ 6383 '</div>' 6384 myApp.popover(popoverHTML, clickedLink); 6385 }); 6386 $$('.payopt').on('click', function () { 6387 //console.log("call payopt"); 6388 var clickedLink = this; 6389 var popoverHTML = '<div class="popover">'+ 6390 '<div class="popover-inner">'+ 6391 '<div class="content-block">'+ 6392 '<p style="text-align:justify;">Payment Options</p>'+ 6393 '</div>'+ 6394 '</div>'+ 6395 '</div>' 6396 myApp.popover(popoverHTML, clickedLink); 6397 }); 6398 $$('.deliverytime').on('click', function () { 6399 //console.log("call deliverytime"); 6400 var clickedLink = this; 6401 var popoverHTML = '<div class="popover">'+ 6402 '<div class="popover-inner">'+ 6403 '<div class="content-block">'+ 6404 '<p style="text-align:justify;">Delivery Time</p>'+ 6405 '</div>'+ 6406 '</div>'+ 6407 '</div>' 6408 myApp.popover(popoverHTML, clickedLink); 6409 }); 6410 var bid = page.query.bid; 6411 var brandId = "'"+bid+"'"; 6412 var brandsid = $.trim("'"+page.query.bid+"'"); 6413 //console.log(brandsid); 6414 var avgRate = ""; 6415 //var avgRateKey = new Firebase("https://fiery-fire-6430.firebaseio.com/bratings/"+bid); 6416 univUrl.child("bratings/"+bid).on('value', function (ratingsnap) { 6417 var brexists = ratingsnap.exists();
6418 if(brexists) 6419 { 6420 avgRate = ratingsnap.val().average_Rating; 6421 6422 //var rateKey = new Firebase("https://fiery-fire-6430.firebaseio.com/bratings/"+bid+"/"+userudid); 6423 univUrl.child("bratings/"+bid+"/"+userudid).once('value', function (datashot) { 6424 var existance = datashot.exists(); 6425 if(existance == true) { 6426 existRate = datashot.val().rating; 6427 if(existRate == 1 || existRate == "1") { 6428 //console.log(avgRate); 6429 var starInfo = 6430 '<input type="radio" name="group-2" id="group-2-0" value="5" /><label for="group-2-0"></label>'+ 6431 '<input type="radio" name="group-2" id="group-2-1" value="4" /><label for="group-2-1"></label>'+ 6432 '<input type="radio" name="group-2" id="group-2-2" value="3" /><label for="group-2-2"></label>'+ 6433 '<input type="radio" name="group-2" id="group-2-3" value="2" /><label for="group-2-3"></label>'+ 6434 '<input type="radio" name="group-2" id="group-2-4" value="1" checked="checked" /><label for="group-2-4"></label>'; 6435 6436 $$('#starForm').html(starInfo); 6437 } else if(existRate == 2 || existRate == "2") { 6438 //console.log(avgRate); 6439 var starInfo = 6440 '<input type="radio" name="group-2" id="group-2-0" value="5" /><label for="group-2-0"></label>'+ 6441 '<input type="radio" name="group-2" id="group-2-1" value="4" /><label for="group-2-1"></label>'+ 6442 '<input type="radio" name="group-2" id="group-2-2" value="3" /><label for="group-2-2"></label>'+ 6443 '<input type="radio" name="group-2" id="group-2-3" value="2" checked="checked" /><label for="group-2-3"></label>'+ 6444 '<input type="radio" name="group-2" id="group-2-4" value="1" /><label for="group-2-4"></label>'; 6445 6446 $$('#starForm').html(starInfo); 6447 } else if(existRate == 3 || existRate == "3") { 6448 //console.log(avgRate); 6449 var starInfo = 6450 '<input type="radio" name="group-2" id="group-2-0" value="5" /><label for="group-2-0"></label>'+ 6451 '<input type="radio" name="group-2" id="group-2-1" value="4" /><label for="group-2-1"></label>'+ 6452 '<input type="radio" name="group-2" id="group-2-2" value="3" checked="checked" /><label for="group-2-2"></label>'+ 6453 '<input type="radio" name="group-2" id="group-2-3" value="2" /><label for="group-2-3"></label>'+ 6454 '<input type="radio" name="group-2" id="group-2-4" value="1" /><label for="group-2-4"></label>'; 6455 6456 $$('#starForm').html(starInfo); 6457 } else if(existRate == 4 || existRate == "4") { 6458 //console.log(avgRate); 6459 var starInfo = 6460 '<input type="radio" name="group-2" id="group-2-0" value="5" /><label for="group-2-0"></label>'+ 6461 '<input type="radio" name="group-2" id="group-2-1" value="4" checked="checked" /><label for="group-2-1"></label>'+ 6462 '<input type="radio" name="group-2" id="group-2-2" value="3" /><label for="group-2-2"></label>'+ 6463 '<input type="radio" name="group-2" id="group-2-3" value="2" /><label for="group-2-3"></label>'+ 6464 '<input type="radio" name="group-2" id="group-2-4" value="1" /><label for="group-2-4"></label>'; 6465 6466 $$('#starForm').html(starInfo); 6467 } else { 6468 var starInfo = 6469 '<input type="radio" name="group-2" id="group-2-0" value="5" checked="checked" /><label for="group-2-0"></label>'+ 6470 '<input type="radio" name="group-2" id="group-2-1" value="4" /><label for="group-2-1"></label>'+ 6471 '<input type="radio" name="group-2" id="group-2-2" value="3" /><label for="group-2-2"></label>'+ 6472 '<input type="radio" name="group-2" id="group-2-3" value="2" /><label for="group-2-3"></label>'+ 6473 '<input type="radio" name="group-2" id="group-2-4" value="1" /><label for="group-2-4"></label>'; 6474 6475 $$('#starForm').html(starInfo); 6476 6477 } 6478 } else { 6479 6480 } 6481 }); 6482 } 6483$$('#avgid').html(avgRate); 6484 }); 6485 var carticons = ''; 6486 var plsbtn = ''; 6487 var catlink = ''; 6488 var adcatbuttono = ''; 6489 $$("#starForm").attr("onclick","rateBrand("+brandId+")"); 6490 //var firebaseOrder = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+page.query.bid); 6491 //console.log(page.query.bid); 6492 univUrl.child("brand/"+page.query.bid).on('value', function(snapshot) { 6493 var objs = snapshot.val(); 6494 var brand_name = objs.brand_name; 6495 var state = objs.state; 6496 var lats = "'"+objs.latitude+"'"; 6497 var longs = "'"+objs.longitude+"'"; 6498 var brandId = "'"+objs.brand_id+"'"; 6499 var chkbrandopen = objs.brand_privacystatus; 6500 var brandContactNo = objs.mobile; 6501 var altNum = objs.alternate_number; 6502 6503 if(!altNum){ //If alternate number isn't available 6504 altNum = brandContactNo; 6505 } 6506 6507 //var connstss = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"+page.query.bid+"/"+userudid+"/status"); 6508 univUrl.child("baccess/"+page.query.bid+"/"+userudid+"/status").on('value', function(snapshotsts) {
6509 //console.log('snapshotsts.val()...'+snapshotsts.val()); 6510 if(snapshotsts.exists() == true){ 6511 if(snapshotsts.val() == 2){ 6512 carticons = '<div class="brand_icons"><a href="catalogues.html?bid='+objs.brand_id+'"><img src="img/ccimages/Shop_white.png" width="28" height="28"></a></div>'; 6513 plsbtn = '<div class="brand_icons"><a href="#" onclick="brandreject('+brandsid+')"><img src="img/ccimages/Delete_white.png" width="28" height="28"></a></div>'; 6514 catlink = '<div class="row"><div class=".col-100.tablet-50">View Products <i class="fa fa-angle-double-right"></i></div></div><a href="catalogues.html?bid='+objs.brand_id+'"><i class="fa fa-cart-arrow-down" style="font-size:22px;float:right;"></i></a>'; 6515 } else if(snapshotsts.val() == 3){ 6516 if(chkbrandopen == 0){ 6517 carticons = '<div class="brand_icons"><a href="catalogues.html?bid='+objs.brand_id+'"><img src="img/ccimages/Shop_white.png" width="28" height="28"></a></div>'; 6518 plsbtn = '<div class="brand_icons"><a href="#" onclick="reqbrandbyid('+brandsid+')"><img src="img/ccimages/request.png" width="28" height="28"></a></div>'; 6519 catlink = '<div class="row"><div class=".col-100.tablet-50">View Products <i class="fa fa-angle-double-right"></i></div></div><a href="catalogues.html?bid='+objs.brand_id+'"><i class="fa fa-cart-arrow-down" style="font-size:22px;float:right;"></i></a>'; 6520 adcatbuttono = '<div class="row"><div class=".col-100.tablet-50">Add/Connect Brand <i class="fa fa-angle-double-right"></i></div></div><a href="#" onclick="reqbrandbyid('+brandsid+')"><i class="fa fa-plus" style="font-size:22px;float:right;"></i></a>' 6521 } else{ 6522 carticons = ''; 6523 catlink = ''; 6524 plsbtn = '<div class="brand_icons"><a href="#" onclick="reqbrandbyid('+brandsid+')"><img src="img/ccimages/request.png" width="28" height="28"></a></div>'; 6525 adcatbuttono = '<div class="row"><div class=".col-100.tablet-50">Add/Connect Brand <i class="fa fa-angle-double-right"></i></div></div><a href="#" onclick="reqbrandbyid('+brandsid+')"><i class="fa fa-plus" style="font-size:22px;float:right;"></i></a>' 6526 } 6527 6528 } else if(snapshotsts.val() == 1 || snapshotsts.val() == 0){ 6529 6530 if(chkbrandopen == 0) 6531 { 6532 carticons = '<div class="brand_icons"><a href="catalogues.html?bid='+objs.brand_id+'"><img src="img/ccimages/Shop_white.png" width="28" height="28"></a></div>'; 6533 plsbtn = ''; 6534 adcatbuttono = ''; 6535 catlink = '<div class="row"><div class=".col-100.tablet-50">View Products <i class="fa fa-angle-double-right"></i></div></div><a href="catalogues.html?bid='+objs.brand_id+'"><i class="fa fa-cart-arrow-down" style="font-size:22px;float:right;"></i></a>'; 6536 }else{ 6537 carticons = ''; 6538 catlink = ''; 6539 plsbtn = '<div class="brand_icons"><img src="img/ccimages/accept.png" width="28" height="28"></div>'; 6540 } 6541 }else{ 6542 if(chkbrandopen == 0) 6543 { 6544 carticons = '<div class="brand_icons"><a href="catalogues.html?bid='+objs.brand_id+'"><img src="img/ccimages/Shop_white.png" width="28" height="28"></a></div>'; 6545 plsbtn = '<div class="brand_icons"><a href="#" onclick="reqbrandbyid('+brandsid+')"><img src="img/ccimages/request.png" width="28" height="28"></a></div>'; 6546 catlink = '<div class="row"><div class=".col-100.tablet-50">View Products <i class="fa fa-angle-double-right"></i></div></div><a href="catalogues.html?bid='+objs.brand_id+'"><i class="fa fa-cart-arrow-down" style="font-size:22px;float:right;"></i></a>'; 6547 adcatbuttono = '<div class="row"><div class=".col-100.tablet-50">Add/Connect Brand <i class="fa fa-angle-double-right"></i></div></div><a href="#" onclick="reqbrandbyid('+brandsid+')"><i class="fa fa-plus" style="font-size:22px;float:right;"></i></a>' 6548 }else{ 6549 carticons = ''; 6550 catlink = ''; 6551 plsbtn = '<div class="brand_icons"><a href="#" onclick="reqbrandbyid('+brandsid+')"><img src="img/ccimages/request.png" width="28" height="28"></a></div>'; 6552 adcatbuttono = '<div class="row"><div class=".col-100.tablet-50">Add/Connect Brand <i class="fa fa-angle-double-right"></i></div></div><a href="#" onclick="reqbrandbyid('+brandsid+')"><i class="fa fa-plus" style="font-size:22px;float:right;"></i></a>' 6553 } 6554 } 6555 }else{ 6556 if(chkbrandopen == 0) 6557 { 6558 carticons = '<div class="brand_icons"><a href="catalogues.html?bid='+objs.brand_id+'"><img src="img/ccimages/Shop_white.png" width="28" height="28"></a></div>'; 6559 plsbtn = '<div class="brand_icons"><a href="#" onclick="reqbrandbyid('+brandsid+')"><img src="img/ccimages/request.png" width="28" height="28"></a></div>'; 6560 catlink = '<div class="row"><div class=".col-100.tablet-50">View Products <i class="fa fa-angle-double-right"></i></div></div><a href="catalogues.html?bid='+objs.brand_id+'"><i class="fa fa-cart-arrow-down" style="font-size:22px;float:right;"></i></a>'; 6561 adcatbuttono = '<div class="row"><div class=".col-100.tablet-50">Add/Connect Brand <i class="fa fa-angle-double-right"></i></div></div><a href="#" onclick="reqbrandbyid('+brandsid+')"><i class="fa fa-plus" style="font-size:22px;float:right;"></i></a>' 6562 }else{ 6563 carticons = ''; 6564 catlink = ''; 6565 plsbtn = '<div class="brand_icons"><a href="#" onclick="reqbrandbyid('+brandsid+')"><img src="img/ccimages/request.png" width="28" height="28"></a></div>'; 6566 adcatbuttono = '<div class="row"><div class=".col-100.tablet-50">Add/Connect Brand <i class="fa fa-angle-double-right"></i></div></div><a href="#" onclick="reqbrandbyid('+brandsid+')"><i class="fa fa-plus" style="font-size:22px;float:right;"></i></a>' 6567 } 6568 6569 } 6570 $$("#chattobrand").html('<div class="row"><div class=".col-100.tablet-50">Start Chat <i class="fa fa-angle-double-right"></i></div></div><a href="chat.html?username='+userudid+'&brandid='+page.query.bid+'&bname='+objs.brand_name+'"><i class="fa fa-comment" style="font-size:22px;float:right;"></i></a>'); 6571 $$("#connbrand").html(adcatbuttono); 6572 //console.log("plsbtn..."+plsbtn); 6573 $$("#chat_explore").html(catlink); 6574 var imgdata = '<div style="background-image:url('+objs.cover_image_url+');
6574height:60vw;" valign="bottom" class= "card-header color-white no-border">'+ 6575 '<div class="brand_heading">'+objs.brand_name+'<br><span style="font-size: small;font-weight: 200;">'+objs.brandcode+'</span></div>'+ 6576 '<div style="margin: 0 0 45% 0"></div>'+ 6577 '<div class="brand_social" style="z-index: 12;">'+ 6578 '<div class="brand_icons"><a href="#" onClick="calling('+altNum+');"><img src="img/ccimages/call.png" width="28" height="28"></a></div>'+ 6579 plsbtn+ 6580 '<div class="brand_icons"><a onclick="brandMap('+lats+','+longs+')"><img src="img/ccimages/locationping.png" width="28" height="28"></a></div>'+ 6581 carticons+ 6582 '</div>'+ 6583 '<div class="black_tint2"></div>'+ 6584 '</div>'; 6585 $$("#bimage").html(imgdata); 6586 }); 6587 $$("#minimum").html(objs.currency+" "+objs.min_order_price); 6588 6589 if(objs.brand_privacystatus == 0) 6590 { 6591 var privacy='<i class="fa fa-flag" style="font-size:22px;"></i><br> <span style="font-size:12px;margin-top:5px;">Public</span>'; 6592 } 6593 else 6594 { 6595 var privacy='<i class="fa fa-flag-checkered" style="font-size:22px;"></i><br><span style="font-size:12px;margin-top:5px;">Exclusive</span>'; 6596 } 6597 6598 $$("#privacy").html(privacy); 6599 if(objs.user_pay_status) 6600 { 6601 var payment='<i class="fa fa-credit-card" style="font-size:22px;"></i><br> <span style="font-size:12px;margin-top:5px;">Online + Cash</span>'; 6602 } 6603 else 6604 { 6605 var payment='<i class="fa fa-money" style="font-size:22px;"></i><br> <span style="font-size:12px;margin-top:5px;">Cash Only</span>'; 6606 } 6607 $$("#payment").html(payment); 6608 $$("#esttime").html(objs.est_delivery_time); 6609 var details = '<table border="0" width="100%" cellspacing="0" cellpadding="0">'+ 6610 '<tr><td width="45%">Currency :</td><td>'+objs.currency+'</td></tr>'+ 6611 '<tr><td>Contact Person :</td><td>'+objs.admin_name+'</td></tr>'+ 6612 '<tr><td>Phone :</td><td>'+objs.mobile+'</td></tr>'+ 6613 '<tr><td>Other Phone :</td><td>'+objs.alternate_number+'</td></tr>'+ 6614 '<tr><td>Email :</td><td>'+objs.conversation_mail+'</td></tr>'+ 6615 '<tr><td>Segment :</td><td>'+objs.industry+'</td></tr>'+ 6616 '<tr><td valign="top">Address :</td><td>'+objs.office+'</td></tr>'+ 6617 '<tr><td>City :</td><td>'+objs.city+'</td></tr>'+ 6618 '<tr><td>State :</td><td>'+objs.state+'</td></tr>'+ 6619 '<tr><td>Country :</td><td>'+objs.country+'</td></tr>'+ 6620 '<tr><td>PIN :</td><td>'+objs.pin+'</td></tr>'+ 6621 '</table>'; 6622 $$("#bdetails").html(details); 6623 6624 var social = ""; 6625 if(objs.gallery_url) 6626 { 6627 var gallery_url="'"+objs.gallery_url+"'"; 6628 social += '<a onClick="openBrowserURL('+gallery_url+')" class="social"><i class="fa fa-file-picture-o"></i></a>'; 6629 } 6630 if(objs.facebook_url) 6631 { 6632 var facebook_url="'"+objs.facebook_url+"'"; 6633 social += '<a onClick="openBrowserURL('+facebook_url+')" class="social"><i class="fa fa-facebook-square"></i></a>'; 6634 } 6635 if(objs.linkedin_url) 6636 { 6637 var linkedin_url="'"+objs.linkedin_url+"'"; 6638 social += '<a onClick="openBrowserURL('+linkedin_url+')" class="social"><i class="fa fa-linkedin-square"></i></a>'; 6639 } 6640 if(objs.twitter_url) 6641 { 6642 var twitter_url="'"+objs.twitter_url+"'"; 6643 social += '<a onClick="openBrowserURL('+twitter_url+')" class="social"><i class="fa fa-twitter-square"></i></a>'; 6644 } 6645 if(objs.website) 6646 { 6647 var website="'"+objs.website+"'"; 6648 social += '<a onClick="openBrowserURL('+website+')" class="social"><i class="fa fa-globe"></i></a>'; 6649 } 6650 if(objs.web_url) 6651 { 6652 var web_url="'"+objs.web_url+"'"; 6653 social += '<a onClick="openBrowserURL('+web_url+')" class="social"><i class="fa fa-internet-explorer"></i></a>'; 6654 } 6655 $$("#bsocial").html(social); 6656 6657 var delb2b = ["With in 3 Kms", "City", "National", "International",]; 6658 //myApp.alert(delb2b[0]); 6659 var deliverb2b = objs.service_areab2b; 6660 var deliveryb2b = deliverb2b.split(","); 6661 var areab2b=''; 6662 for(var i = 0; i < deliveryb2b.length; i++) 6663 { 6664 if(deliveryb2b[i] && deliveryb2b[i]==1) 6665 { 6666 areab2b+= delb2b[i]+","; 6667 } 6668 } 6669 6670 var delb2c = ["With in 3 Kms", "City", "National", "International",]; 6671 var deliverb2c = objs.service_areab2c; 6672 var deliveryb2c = deliverb2c.split(","); 6673 var areab2c=''; 6674 for(var j = 0; j < deliveryb2c.length; j++) 6675 { 6676 if(deliveryb2c[j] && deliveryb2c[j]==1) 6677 { 6678 areab2c+= delb2c[j]+","; 6679 } 6680 } 6681 6682 var delivery_area='<p>B2B : '+areab2b+'</p><p>B2C : '+areab2c+'</p>'; 6683 $$("#delivery_area").html(delivery_area); 6684 6685 var business_name = ["Manufacturer", "Stockist", "CNF Agent", "Distributor", "Wholeseller", "Indipendent Retailer", "Sub Retailer", "EBO", "MBO", "Online Seller", "Importer", "Exporter",]; 6686 var bus_type = objs.business_type; 6687 var business = bus_type.split(","); 6688 var business_type=''; 6689 for(var b = 0; b < business.length; b++) 6690 { 6691 if(business[b] && business[b]==1) 6692 { 6693 business_type+= business_name[b]+","; 6694 } 6695 } 6696 6697 $$("#pri_business").html(business_type); 6698 6699 var other = '<p>Annual Turnover : '+objs.annual_turnover+'</p><p>
6699No. of Employees : '+objs.no_employee+'</p><p>Year of Establishment : '+objs.establish_year+'</p><p>Awards : '+objs.awards+'</p><p>Ownership Type : '+objs.ownership_type+'</p>'; 6700 $$("#others").html(other); 6701 if(objs.account_name == undefined || objs.account_name == 'undefined') 6702 { 6703 var accname = ''; 6704 }else 6705 { 6706 var accname = objs.account_name; 6707 } 6708 var bank_detail = '<p>Account Name : '+accname+'</p><p>Account No : '+objs.account_no+'</p><p>Bank Name : '+objs.bank_name+'</p><p>Account Type : '+objs.account_type+'</p><p>Branch Name : '+objs.branch_name+'</p><p>Branch Address : '+objs.branch_address+'</p><p>IFSC Code : '+objs.ifsc_code+'</p>'; 6709 $$("#bank_detail").html(bank_detail); 6710 6711 var off_detail = '<p>PAN : '+objs.pan_no+'</p><p>TAN : '+objs.tan_no+'</p><p>CST : '+objs.cst_no+'</p><p>VAT : '+objs.vat_no+'</p><p>SERVICE TAX : '+objs.service_taxno+'</p>'; 6712 $$("#off_detail").html(off_detail); 6713 6714 }); 6715 6716 setTimeout( function(){ 6717 //var firebaseTc = new Firebase("https://fiery-fire-6430.firebaseio.com/tc/"+page.query.bid); 6718 univUrl.child("tc/"+page.query.bid).on('value', function(snapshot) { 6719 6720 var existance = snapshot.exists(); 6721 //console.log(existance); 6722 if(existance) { 6723 var obj = snapshot.val(); 6724 ////console.log('TC - '+JSON.stringify(obj)); 6725 $$("#terms").html(obj.tandc); 6726 $$("#return_pol").html(obj.return_pol); 6727 $$("#ship_pol").html(obj.ship_pol); 6728 } 6729 6730 }); 6731 }, 500); 6732 6733}); 6734 6735function openBrowserURL(url){ 6736 var deviceType=device.platform; 6737 if(deviceType=='Android'){ 6738 window.open(url,'_system','location=yes'); 6739 }else if(deviceType == 'iOS'){ 6740 openBrowser(url, ""); 6741 } else{ 6742 window.open(url,'_blank','location=yes'); 6743 } 6744} 6745 6746var currlatitude=''; 6747var currlongitude=''; 6748function callback(position){ 6749 currlatitude=position.coords.latitude; 6750 currlongitude=position.coords.latitude; 6751} 6752 6753function brandMap(lati,longit){ 6754 navigator.geolocation.getCurrentPosition(function showuserbloc(position) { 6755 var url = 'https://www.google.com/maps/dir/'+lati+','+longit+'/'+position.coords.latitude+','+position.coords.longitude+'/@'+position.coords.latitude+','+position.coords.longitude+',8z/data=!3m1!4b1'; 6756 var devicePlatform = device.platform; 6757 //var ref = ""; 6758 if(devicePlatform == 'iOS'){ 6759 //ref = cordova.ThemeableBrowser.open(url, '_blank', 'location=yes', 'toolbar=yes','presentationstyle=pagesheet','toolbarposition=top','closebuttoncaption=back'); 6760 openBrowser(url, ""); 6761 } else{ 6762 window.open(url,'_blank','location=yes'); 6763 } 6764 }); 6765} 6766 6767 myApp.onPageInit('order_all', function (page) { 6768 myApp.showIndicator(); 6769 var flagset = false; 6770 var templatess =''; 6771 //var firebaseOrder = new Firebase("https://fiery-fire-6430.firebaseio.com/orders/"); 6772 univUrl.child("orders/").orderByChild("userid").equalTo(userudid).limitToLast(100).on("value", function (snapshot){ 6773 $('#order_list').html(''); 6774 flagset = snapshot.exists(); 6775 var b = snapshot.exists(); 6776 var a = snapshot.numChildren(); 6777 if(b==true){ 6778 if(a==1){ 6779 var bdata = snapshot.val(); 6780 var result = Object.keys(snapshot.val()); 6781 var ordid = result[0]; 6782 6783 //var Orderdetail = new Firebase("https://fiery-fire-6430.firebaseio.com/orders/"+ordid); 6784 univUrl.child("orders/"+ordid).once('value', function(snapshot){ 6785 var obj = snapshot.val(); 6786 templatess = '<li>' + 6787 '<a href="viewaction.html?orderid=' + obj.ord_no + '&brandid=' + obj.brand_id + '" class="item-link item-content"><div class="item-media">' + 6788 '<i class="fa fa-shopping-cart fa-lg"></i></div><div class="item-inner">' + 6789 '<div class="item-title-row"><div class="item-title">Order id</div>' + 6790 '<div class="item-after">'+ obj.ord_no + '</div></div><div class="row">' + 6791 '<div class="item-title">Brand name</div><div class="item-after">' + obj.brand_name + '</div></div>' + 6792 '<div class="row"><div class="item-title">Order Date</div><div class="item">' + obj.ord_date + '</div></div>' + 6793 '</div></div></a>' + 6794 '</li>'; 6795 $('#order_list').html(templatess); 6796 myApp.hideIndicator(); 6797 }); 6798 6799 }else{ 6800 //more then one 6801 snapshot.forEach(function (newdata) { 6802 var orderid = newdata.key(); 6803 flagset = snapshot.exists();
6804 6805 //var Orderdetail = new Firebase("https://fiery-fire-6430.firebaseio.com/orders/"+orderid); 6806 univUrl.child("orders/"+orderid).once('value', function (snapshot){ 6807 var obj = snapshot.val(); 6808 templatess = '<li>'+ 6809 '<a href="viewaction.html?orderid=' + obj.ord_no + '&brandid=' + obj.brand_id + '" class="item-link item-content"><div class="item-media">' + 6810 '<i class="fa fa-shopping-cart fa-lg"></i></div><div class="item-inner">' + 6811 '<div class="item-title-row"><div class="item-title">Order id</div>' + 6812 '<div class="item-after">' + obj.ord_no + '</div></div><div class="row">' + 6813 '<div class="item-title">Brand name</div><div class="item-after">' + obj.brand_name + '</div></div>' + 6814 '<div class="row"><div class="item-title">Order Date</div><div class="item">' + obj.ord_date + '</div></div>' + 6815 '</div></div></a>' + 6816 '</li>'; 6817 }); 6818 $$('#order_list').prepend(templatess); 6819 myApp.hideIndicator(); 6820 }); 6821 } 6822 } else{ 6823 //no order avilable 6824 var valhtml = '<li>'+ 6825 '<div class="item-content">'+ 6826 '<div class="item-inner">'+ 6827 '<div class="item-title" style="text-align: center;">No Order Available.</div>'+ 6828 '</div>'+ 6829 '</div>'+ 6830 '</li>'; 6831 6832 $$('#order_list').html(valhtml); 6833 //console.log("IN ELSE"); 6834 myApp.hideIndicator(); 6835 } 6836 }); 6837}); 6838 6839// ordered-product Page : 6840 function cancelorder(orderid){ 6841 myApp.confirm('Are you sure, You want to cancel order ?','Cancel Order', function () { 6842 var brand_id; 6843 //var fredRankRef = new Firebase("https://fiery-fire-6430.firebaseio.com/orders/"+orderid+"/ord_status"); 6844 univUrl.child("orders/"+orderid+"/ord_status").transaction(function(currentRank) { 6845 var currentRank = 6; 6846 return currentRank; 6847 }); 6848 6849 //var allfredRankRef = new Firebase("https://fiery-fire-6430.firebaseio.com/orders/"+orderid+"/products"); 6850 univUrl.child("orders/"+orderid+"/products").on("child_added", function(snapshot){ 6851 brand_id = snapshot.val().brand_id; 6852 6853 //var allfredRankRefdel = new Firebase("https://fiery-fire-6430.firebaseio.com/orders/"+orderid+"/products/"+snapshot.key()+"/status"); 6854 univUrl.child("orders/"+orderid+"/products/"+snapshot.key()+"/status").transaction(function(currentRank) { 6855 var currentRank = 6; 6856 return currentRank; 6857 }); 6858 }); 6859 6860 //var brandcanordupdate = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+brand_id+"/cancelled_orders"); 6861 univUrl.child("brand/"+brand_id+"/cancelled_orders").transaction(function(currentRank) { 6862 return currentRank+1; 6863 }); 6864 //var Orderallamt = new Firebase("https://fiery-fire-6430.firebaseio.com/orders/"+orderid+"/total_ord_pri"); 6865 univUrl.child("orders/"+orderid+"/total_ord_pri").on("value", function(snapshot){ 6866 var totalamt = snapshot.val(); 6867 var uname = window.localStorage.getItem("user_name"); 6868 $$.post('https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/gcmsk1.php', {msgtype:'orc', cname: uname, bid: brand_id,oid:orderid,amt:totalamt,mobile:userudid}, function (data) { 6869 }); 6870 }); 6871 6872 univUrl.child('/orders/'+orderid).once('value',function(snaps){ 6873 var bid = snaps.val().brand_id; 6874 univUrl.child('/brand/'+bid+'/substore/').orderByChild('/orders/'+orderid).once('value',function(snap1){ 6875 snap1.forEach(function(eachsnap){ 6876 var nodekey = eachsnap.key(); 6877 univUrl.child('/brand/'+bid+'/substore/'+nodekey+'/orders/'+orderid).once('value').then(function(snap2){ 6878 if(snap2.exists()){ 6879 univUrl.child('/brand/'+bid+'/substore/'+nodekey+'/orders/'+orderid).update({ 6880 ord_status:6 6881 }); 6882 var uname = window.localStorage.getItem("user_name"); 6883 var SubStore = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+bid+"/substore/"+nodekey); 6884 SubStore.once('value', function(storeshot){ 6885 var subStoreId = storeshot.val().selfbid; 6886 console.log("Sub Store Id - "+subStoreId); 6887 $$.post('https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/gcmsk1.php', {msgtype:'orc', cname: uname, bid: subStoreId, amt: totalamt,oid:orderid,mobile:userudid}, function (datastore) { 6888 //console.log(datastore); 6889 console.log("Notification sent to substore."); 6890 }); 6891 }); 6892 } 6893 }) 6894 }); 6895 }); 6896 }); 6897 mainView.router.refreshPage('viewaction.html'); 6898 },function(){ 6899 });
6900 } 6901 6902 myApp.onPageInit('viewaction', function (page) { 6903 var template = ''; 6904 var orderId = page.query.orderid; 6905 var trackbtn = ''; 6906 var brcurrency = ''; 6907 //var firebaseOrder = new Firebase("https://fiery-fire-6430.firebaseio.com/orders/"+orderId); 6908 univUrl.child("orders/"+orderId).on("value", function(snapshot){ 6909 var obj = snapshot.val(); 6910 if(obj.ord_status==0){ 6911 obj.ord_status= "completed"; 6912 temp = '<li id="0" class="'+obj.ord_status+'"><span class="bubble"></span> Pending </li> ' + 6913 '<li id="1" > <span class="bubble"></span> Partial approved </li>' + 6914 ' <li id="2" > <span class="bubble"></span> Approved </li>' + 6915 ' <li id="3"> <span class="bubble"></span> Partial dispatch </li>' + 6916 ' <li id="4"> <span class="bubble"></span> Dispatched </li>'+ 6917 ' <li id="5"> <span class="bubble"></span> Rejected </li>'+ 6918 ' <li id="6"> <span class="bubble"></span> Cancel </li>'; 6919 $('#progress_bar').html(temp); 6920 var canorderId = $.trim("'"+orderId+"'"); 6921 $$("#ordcancle").html('<div class="button button-round active" style="float: right;margin-top: 20px;" onClick="cancelorder('+canorderId+');">Cancel</div>'); 6922 } 6923 if(obj.ord_status==1){ 6924 obj.ord_status= "completed"; 6925 temp = '<li id="0" class="'+obj.ord_status+'"><span class="bubble"></span> Pending </li> ' + 6926 '<li id="1" class="'+obj.ord_status+'"> <span class="bubble"></span> Partial approved </li>' + 6927 ' <li id="2" > <span class="bubble"></span> Approved </li>' + 6928 ' <li id="3"> <span class="bubble"></span> Partial dispatch </li>' + 6929 ' <li id="4"> <span class="bubble"></span> Dispatched </li>'+ 6930 ' <li id="5"> <span class="bubble"></span> Rejected </li>'+ 6931 ' <li id="6"> <span class="bubble"></span> Cancel </li>'; 6932 $('#progress_bar').html(temp); 6933 $$("#ordcancle").html(""); 6934 } 6935 if(obj.ord_status==2){ 6936 obj.ord_status= "completed"; 6937 temp = '<li id="0" class="'+obj.ord_status+'"><span class="bubble"></span> Pending </li> ' + 6938 '<li id="1" class="'+obj.ord_status+'"> <span class="bubble"></span> Partial approved </li>' + 6939 ' <li id="2" class="'+obj.ord_status+'" > <span class="bubble"></span> Approved </li>' + 6940 ' <li id="3"> <span class="bubble"></span> Partial dispatch </li>' + 6941 ' <li id="4"> <span class="bubble"></span> Dispatched </li>'+ 6942 ' <li id="5"> <span class="bubble"></span> Rejected </li>'+ 6943 ' <li id="6"> <span class="bubble"></span> Cancel </li>'; 6944 $('#progress_bar').html(temp); 6945 $$("#ordcancle").html(""); 6946 } 6947 if(obj.ord_status==3){ 6948 obj.ord_status= "partial"; 6949 temp = '<li id="0" class="'+obj.ord_status+'"><span class="bubble"></span> Pending </li> ' + 6950 '<li id="1" class="'+obj.ord_status+'"> <span class="bubble"></span> Partial approved </li>' + 6951 ' <li id="2" class="'+obj.ord_status+'"> <span class="bubble"></span> Approved </li>' + 6952 ' <li id="3" class="'+obj.ord_status+'"> <span class="bubble"></span> Partial dispatch </li>' + 6953 ' <li id="4"> <span class="bubble"></span> Dispatched </li>'+ 6954 ' <li id="5"> <span class="bubble"></span> Rejected </li>'+ 6955 ' <li id="6"> <span class="bubble"></span> Cancel </li>'; 6956 $('#progress_bar').html(temp); 6957 $$("#ordcancle").html(""); 6958 } 6959 if(obj.ord_status==4){ 6960 obj.ord_status= "dispatched"; 6961 temp = '<li id="0" class="'+obj.ord_status+'"><span class="bubble"></span> Pending </li> ' + 6962 '<li id="1" class="'+obj.ord_status+'"> <span class="bubble"></span> Partial approved </li>' + 6963 ' <li id="2" class="'+obj.ord_status+'"> <span class="bubble"></span> Approved </li>' + 6964 ' <li id="3" class="'+obj.ord_status+'"> <span class="bubble"></span> Partial dispatch </li>' + 6965 ' <li id="4" class="'+obj.ord_status+'"> <span class="bubble"></span> Dispatched </li>'+ 6966 ' <li id="5"> <span class="bubble"></span> Rejected </li>'+ 6967 ' <li id="6"> <span class="bubble"></span> Cancel </li>'; 6968 $('#progress_bar').html(temp); 6969 $$("#ordcancle").html(""); 6970 if(obj.courier_url){ 6971 trackbtn = '<div class="row" style="min-height:45px;"><div class="item-title"><b>Track Order :</b></div><div class="item-after"><a href="#" onClick=openBrowser("'+obj.courier_url+'","Track") target="_blank"><img src="img/track.png" style="margin-top:-15px;"></a></div></div>'; 6972 } else{ 6973 trackbtn = '<div style="padding:12px;"><div class="row"><div class="item-title">Delivery via : '+obj.courier_name+'</div></div><div class="row"><div class="item-title">Tracking/Mobile No. : '+obj.tracking_no+'</div></div></div>'; 6974 } 6975 } 6976 6977 if(obj.ord_status==5){ 6978 obj.ord_status= "completed"; 6979 temp = '<li id="0" class="'+obj.ord_status+'"><span class="bubble"></span> Pending </li> ' + 6980 '<li id="1" class="'+obj.ord_status+'"> <span class="bubble"></span> Partial approved </li>' + 6981 ' <li id="2" class="'+obj.ord_status+'"> <span class="bubble"></span> Approved </li>' + 6982 ' <li id="3" class="'+obj.ord_status+'"> <span class="bubble"></span> Partial dispatch </li>' + 6983 ' <li id="4" class="'+obj.ord_status+'"> <span class="bubble"></span> Dispatched </li>'+ 6984 ' <li id="5" class="'+obj.ord_status+'"> <span class="bubble"></span> Rejected </li>'+ 6985 ' <li id="6"> <span class="bubble"></span> Cancel </li>' 6986 $('#progress_bar').html(temp); 6987 $$("#ordcancle").html(""); 6988 } 6989 6990 if(obj.ord_status==6){ 6991 obj.ord_status= "rejected"; 6992 temp = '<li id="0" class="'+obj.ord_status+'"><span class="bubble"></span> Pending </li> ' + 6993 '<li id="1" class="'+obj.ord_status+'"> <span class="bubble"></span> Partial approved </li>' + 6994 ' <li id="2" class="'+obj.ord_status+'"> <span class="bubble"></span> Approved </li>' + 6995 ' <li id="3" class="'+obj.ord_status+'"> <span class="bubble"></span> Partial dispatch </li>' + 6996 ' <li id="4" class="'+obj.ord_status+'"> <span class="bubble"></span> Dispatched </li>'+ 6997 ' <li id="5" class="'+obj.ord_status+'"> <span class="bubble"></span> Rejected </li>'+ 6998 ' <li id="6" class="'+obj.ord_status+'"> <span class="bubble"></span> Cancel </li>'; 6999 $('#progress_bar').html(temp); 7000 $$("#ordcancle").html(""); 7001 } 7002 //var currencyicon = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+obj.brand_id+'/currency'); 7003 univUrl.child("brand/"+obj.brand_id+"/currency").once("value", function(snapshot12){ 7004 brcurrency = snapshot12.val(); 7005 }); 7006 template = '<li> <div>
7006<a href="#" class="item-link item-content"><div class="item-inner">' + 7007 '<div class="item-title"><b>Latest Dispatch Note :</b></div><div class="item-subtitle" style="white-space: inherit;">'+obj.order_note+'</div> <div class="row">'+ 7008 '<div class="item-title">Brand </div> <div class="item-after">'+obj.brand_name+'</div> </div> <div class="row"> ' + 7009 '<div class="item-title">Order Date</div> <div class="item-after">'+obj.ord_date+'</div> </div>' + 7010 '<div class="item-title">Address</div> <div class="item-subtitle-address" style="margin-bottom:2%;">' + obj.ship_add +'</div>' + 7011 '<div class="row"> <div class="item-title">Total</div> <div class="item-after">'+brcurrency+' '+obj.total_ord_pri+'</i></div> </div>'+ 7012 '</div>'+ 7013 '</a></div> </li>'; 7014 if(obj.tracking_no) { 7015 $$('#dispatch_details').html(template+trackbtn); 7016 } else{ 7017 $$('#dispatch_details').html(template); 7018 } 7019 }); 7020 myApp.hideIndicator(); 7021 var template = ''; 7022 //var firebaseOrder = new Firebase("https://fiery-fire-6430.firebaseio.com/orders/"+orderId+"/products/"); 7023 univUrl.child("orders/"+orderId+"/products/").once('value', function(snapshot){ 7024 $$('#ordered_product').html(""); 7025 var objs = snapshot.val(); 7026 $$.each(objs, function(i, obj) { 7027//console.log(trackbtn); 7028 if(obj.status === "0" || obj.status === 0){ 7029 var cstatus = '<div class="item-after" style="color:#4670A7;">Pending</div>'; 7030 } else if(obj.status === "2" || obj.status === 2){ 7031 var cstatus = '<div class="item-after" style="color:#2196F3;">Approved</div>'; 7032 } else if(obj.status === "4" || obj.status === 4){ 7033 var cstatus = '<div class="item-after" style="color:#009688;">Dispatched</div>'; 7034 } else if(obj.status === "5" || obj.status === 5){ 7035 var cstatus = '<div class="item-after" style="color:#03A9F4;">Rejected</div>'; 7036 } else if(obj.status === "6" || obj.status === 6){ 7037 var cstatus = '<div class="item-after" style="color:red;">Cancelled</div>'; 7038 } 7039 7040 if(obj.at1name=="") { 7041 var rowaatt1 = ''; 7042 } else{ 7043 if(obj.at1pri !== "" || obj.at1text !== ""){ 7044 var rowaatt1 = '<div class="row"> <div class="item-title">'+obj.at1name+'</div> <div class="item">'+obj.at1text+'+'+obj.at1pri+'</div> </div>'; 7045 } else{ 7046 var rowaatt1 = ''; 7047 } 7048 } 7049 if(obj.at2name=="") { 7050 var rowaatt2 = ''; 7051 } else{ 7052 if(obj.at2pri !== "" || obj.at2text !== ""){ 7053 var rowaatt2 = '<div class="row"> <div class="item-title">'+obj.at2name+'</div> <div class="item-after">'+obj.at2text+'+'+obj.at1pri+'</div> </div>' ; 7054 } else{ 7055 var rowaatt2 = ''; 7056 } 7057 } 7058 var unittpri = typeof(obj.probasepri); 7059 if(unittpri === "undefined") { 7060 var unipri = ''; 7061 } else{ 7062 var unipri = '<div class="row"><div class="item-title">Unit price</div> <div class="item-after">'+obj.probasepri+'</div> </div> '; 7063 } 7064 var catnames = typeof(obj.catname); 7065 if(catnames === "undefined") { 7066 var showcatname = ''; 7067 } else{ 7068 var showcatname = obj.catname; 7069 } 7070 if(obj.catorpro == "Catalogue Wise"){ 7071 template += '<div class="accordion-list inset"><ul> <li class="accordion-item"> <a href="#" class="item-link item-content"> <div class="item-inner"> <div class="item-title">'+obj.p_name+'(C)<i class="fa fa-angle-right" style="float:right;"></i> </div> </div></a> <div class="accordion-item-content button-block">'+ 7072 '<ul> <li style="margin-left:20px;"> <div class="item-inner"> <div class="item-title-row"> <div class="item-title">Product Name</div> <div class="item-after">
7072'+obj.p_name+'</div> </div>'+ 7073 showcatname+ 7074 rowaatt1+ 7075 rowaatt2+ 7076 unipri+ 7077 '<div class="row"> <div class="item-title">Quantity</div> <div class="item-after">'+obj.quantity+'</div> </div> '+ 7078 '<div class="row"> <div class="item-title">Total</div> <div class="item-after">'+brcurrency+' '+obj.totalprice+'</i></div> </div> </div> </li> </ul> </div> </li> </ul> </div>'; 7079 } else{ 7080 template += '<div class="accordion-list inset"><ul> <li class="accordion-item"> <a href="#" class="item-link item-content"> <div class="item-inner"> <div class="item-title">'+obj.p_name+'<i class="fa fa-angle-right" style="float:right;"></i> </div> </div></a> <div class="accordion-item-content button-block">'+ 7081 '<ul> <li style="margin-left:20px;"> <div class="item-inner"> <div class="item-title-row"> <div class="item-title">Product Name</div> <div class="item-after">'+obj.p_name+'</div> </div>'+ 7082 '<div class="row"> <div class="item-title">Catalogue Name</div> <div class="item-after">'+showcatname+'</div> </div> '+ 7083 rowaatt1+ 7084 rowaatt2+ 7085 unipri+ 7086 '<div class="row"><div class="item-title">Status</div>'+cstatus+'</div> '+ 7087 '<div class="row"> <div class="item-title">Quantity</div> <div class="item-after">'+obj.quantity+'</div> </div> '+ 7088 '<div class="row"> <div class="item-title">Total</div> <div class="item-after">'+brcurrency+' '+obj.totalprice+'</i></div> </div> </div> </li> </ul> </div> </li> </ul> </div>'; 7089 } 7090 $$('#ordered_product').html(template); 7091 }); 7092 usersLoaded = true; 7093 }); 7094}); 7095 7096function openBrowser(urls,title){ 7097 var ref = window.open(urls, title, "toolbar=yes, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400"); 7098 ref.addEventListener('exit', function(event) { 7099 console.log(event.url); 7100 ref.close(); 7101 }); 7102 /*cordova.ThemeableBrowser.open(urls, '_blank', { 7103 statusbar: { 7104 color: '#ffffff' 7105 }, 7106 toolbar: { 7107 height: 44, 7108 color: '#ff5722' 7109 }, 7110 title: { 7111 color: '#ffffff', 7112 staticText : title, 7113 showPageTitle: true 7114 }, 7115 backButton: { 7116 wwwImage: 'image/back.png', 7117 wwwimagePressed: 'image/back_pressed.png', 7118 wwwImageDensity: 2, 7119 align: 'left', 7120 event: 'backPressed' 7121 }, 7122 forwardButton: { 7123 wwwImage: 'image/forward.png', 7124 wwwimagePressed: 'image/forward_pressed.png', 7125 wwwImageDensity: 2, 7126 align: 'left', 7127 event: 'forwardPressed' 7128 }, 7129 closeButton: { 7130 wwwImage: 'image/close.png', 7131 wwwimagePressed: 'image/close_pressed.png', 7132 wwwImageDensity: 2, 7133 align: 'left', 7134 event: 'closePressed' 7135 }, 7136 backButtonCanClose: true 7137 });*/ 7138} 7139 7140/**********************************Profile page init*************************************/ 7141 myApp.onPageInit('profile', function (page) { 7142 //console.log(userudid); 7143 $("#autofill_address").geocomplete({ 7144 details: "#profile_page", 7145 types: ["geocode", "establishment"] 7146 }); 7147 var typingTimer; //timer identifier 7148 var doneTypingInterval = 2000; 7149 7150 var calendarDateFormat = myApp.calendar({ 7151 input: '#birth_date', 7152 dateFormat: 'MM dd, yyyy' 7153 }); 7154 $$("#tab2id").hide(); 7155 //var firebaseuserdata = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid); 7156 univUrl.child("users/cc/"+userudid).on("value", function(snapshot){ 7157 var objs = snapshot.val(); 7158 $$("#billing_name").val(objs.billing_name); 7159 $$("#full_name").val(objs.username); 7160 $$("#mobile").val(objs.mobile); 7161 $$("#conversation_mail").val(objs.conversation_mail); 7162 $$("#birth_date").val(objs.birth_date); 7163 $$("#billing_address").val(objs.billing_address); 7164 $$("#autofill_address").val(objs.autofill_address); 7165 $$("#locality").val(objs.city); 7166 $$("#area").val(objs.locality); 7167 $$("#administrative_area_level_1").val(objs.state); 7168 $$("#postal_code").val(objs.pin); 7169 $$("#country").val(objs.country); 7170 $$("#gender").val(objs.gender); 7171 usersLoaded = true; 7172 });
7173}); 7174 7175function checkdata() { 7176 //var ref = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid); 7177 var billing_name = $$('.item-input').find('input[name="billing_name"]').val(); 7178 var full_name = $$('.item-input').find('input[name="full_name"]').val(); 7179 var conversation_mail = $$('.item-input').find('input[name="conversation_mail"]').val(); 7180 var mobile = $$('.item-input').find('input[name="mobile"]').val(); 7181 var gender = $$('.item-input').find('input[name="gender"]').val(); 7182 var birth_date = $$('.item-input').find('input[name="birth_date"]').val(); 7183 var billing_address = $$('.item-input').find('input[name="billing_address"]').val(); 7184 var autofill_address = $$('.item-input').find('input[name="autofill_address"]').val(); 7185 var locality = $$('.item-input').find('input[name="locality"]').val(); 7186 var sublocality = $$('.item-input').find('input[name="area"]').val(); 7187 var administrative_area_level_1 = $$('.item-input').find('input[name="administrative_area_level_1"]').val(); 7188 var postal_code = $$('.item-input').find('input[name="postal_code"]').val(); 7189 var country = $$('.item-input').find('input[name="country"]').val(); 7190} 7191 7192 function submitform() { 7193 //var firebaseCount = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid); 7194 var formData = myApp.formToJSON('#profile_page'); 7195 7196 if(formData.billing_address==""){ 7197 myApp.alert("Please fill your Billing Address."); 7198 return false; 7199 } 7200 if(formData.locality==""){ 7201 myApp.alert("Please fill your City."); 7202 return false; 7203 } 7204 if(formData.administrative_area_level_1==""){ 7205 myApp.alert("Please fill your State."); 7206 return false; 7207 } 7208 if(formData.postal_code==""){ 7209 myApp.alert("Please fill your PIN Code."); 7210 return false; 7211 } 7212 if(formData.country==""){ 7213 myApp.alert("Please fill your Country."); 7214 return false; 7215 } 7216 7217 var billing_address = formData.billing_address; 7218 var autofill_address = formData.autofill_address; 7219 var city = formData.locality; 7220 var locality = formData.sublocality; 7221 var state = formData.administrative_area_level_1; 7222 var pin = formData.postal_code; 7223 var country = formData.country; 7224 7225 //var firebaseUser = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid); 7226 univUrl.child("users/cc/"+userudid).update({ 7227 billing_address: billing_address, 7228 autofill_address: autofill_address, 7229 city:city, 7230 state:state, 7231 locality:locality, 7232 pin:pin, 7233 country:country 7234 }); 7235 myApp.addNotification({ 7236 message: 'Profile updated Successfully.', 7237 hold: 4000, 7238 closeOnClick: false 7239 }); 7240 mainView.router.back(); 7241}; 7242 7243 function updateform(getuserudid) { 7244 $$("#idtab2").hide(); 7245 //$$("#tab2id").css("display","block");; 7246 // $$("#tab2id").css("display","none"); 7247 //var firebaseCount = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid); 7248 var formData = myApp.formToJSON('#profile_page'); 7249 if(formData.billing_name==""){ 7250 myApp.alert("Please fill your Billing name."); 7251 return false; 7252 } 7253 if(formData.full_name==""){ 7254 myApp.alert("Please fill Full Name."); 7255 return false; 7256 } 7257 if(formData.conversation_mail==""){ 7258 myApp.alert("Please fill your email."); 7259 return false; 7260 } 7261 if(formData.gender=="") { 7262 myApp.alert("Please select gender."); 7263 return false; 7264 } 7265 7266 var billing_name = formData.billing_name; 7267 var full_name = formData.full_name; 7268 var mobile = formData.mobile; 7269 var conversation_mail = formData.conversation_mail; 7270 var birth_date = formData.birth_date; 7271 var gender = formData.gender; 7272 $.ajax({
7273 url: 'https://appsforbusiness.in/cloudcatalogue/process/getjsonccmanager.php', 7274 type: 'POST', 7275 data: {mobileno:mobile,convemail:conversation_mail,username:full_name,action:'changeconvemail'}, 7276 success: function (data) 7277 { 7278 var obj = JSON.parse(data); 7279 if(obj.message == 'success') 7280 { 7281 myApp.addNotification({ 7282 message: 'Personal Profile updated, kindly complete your saved address.', 7283 hold: 4000, 7284 closeOnClick: false 7285 }); 7286 } 7287 else 7288 { 7289 myApp.hideIndicator(); 7290 7291 } 7292 } 7293 }); 7294 7295 //var firebaseUser = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid); 7296 univUrl.child("users/cc/"+userudid).update({ 7297 billing_name: billing_name, 7298 username: full_name, 7299 conversation_mail: conversation_mail, 7300 mobile: userudid, 7301 gender: gender, 7302 birth_date: birth_date 7303 }); 7304 myApp.showTab('#tab2'); 7305} 7306 7307function firstsubmitform() { 7308 //var firebaseCount = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid); 7309 var formData = myApp.formToJSON('#profile_page'); 7310 if(formData.billing_address==""){ 7311 myApp.alert("Please fill your Billing Address."); 7312 return false; 7313 } 7314 if(formData.locality==""){ 7315 myApp.alert("Please fill your City."); 7316 return false; 7317 } 7318 if(formData.administrative_area_level_1==""){ 7319 myApp.alert("Please fill your State."); 7320 return false; 7321 } 7322 if(formData.postal_code==""){ 7323 myApp.alert("Please fill your PIN Code."); 7324 return false; 7325 } 7326 if(formData.country==""){ 7327 myApp.alert("Please fill your Country."); 7328 return false; 7329 } 7330 7331 var billing_address = formData.billing_address; 7332 var autofill_address = formData.autofill_address; 7333 var locality = formData.sublocality; 7334 var city = formData.locality; 7335 var state = formData.administrative_area_level_1; 7336 var pin = formData.postal_code; 7337 var country = formData.country; 7338 7339 //var firebaseUser = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid); 7340 univUrl.child("users/cc/"+userudid).update({ 7341 billing_address: billing_address, 7342 autofill_address: autofill_address, 7343 city:city, 7344 state:state, 7345 locality:locality, 7346 pin:pin, 7347 country:country 7348 }); 7349 myApp.addNotification({ 7350 message: 'Profile updated Successfully.', 7351 hold: 4000, 7352 closeOnClick: false 7353 }); 7354 7355 mainView.router.loadPage('index.html'); 7356 myApp.alert("One app to connect with your selected merchants by simply adding/scanning their âBrand/QR Codesâ. Now place n track orders, chat realtime all on one single app. Happy Ordering!"); 7357 callforbranch(); 7358}; 7359 7360function firstupdateform() { 7361 //console.log('firstupdateform...'+userudid); 7362 //var firebaseCount = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid); 7363 var formData = myApp.formToJSON('#profile_page'); 7364 if(formData.billing_name==""){ 7365 myApp.alert("Please fill your Billing Name."); 7366 return false; 7367 } 7368 if(formData.full_name==""){ 7369 myApp.alert("Please fill your Full Name."); 7370 return false; 7371 } 7372 if(formData.conversation_mail==""){ 7373 myApp.alert("Please fill your email."); 7374 return false; 7375 } 7376 if(formData.gender=="") { 7377 myApp.alert("please select gender"); 7378 return false; 7379 } 7380 7381 var billing_name = formData.billing_name; 7382 var full_name = formData.full_name; 7383 var mobile = formData.mobile; 7384 var conversation_mail = formData.conversation_mail; 7385 var birth_date = formData.birth_date; 7386 var gender = formData.gender; 7387 7388 //var firebaseUser = new Firebase("https://fiery-fire-6430.firebaseio.com/users/cc/"+userudid); 7389 univUrl.child("users/cc/"+userudid).update({ 7390 billing_name: billing_name, 7391 username: full_name, 7392 conversation_mail: conversation_mail, 7393 mobile: userudid, 7394 gender: gender, 7395 birth_date: birth_date 7396 });
7397 myApp.alert("Personal Profile Updated."); 7398 myApp.showTab('#tab2'); 7399} 7400 7401myApp.onPageInit('first-profile', function (page) { 7402 //console.log(userudid); 7403 $("#autofill_address").geocomplete({ 7404 details: "#profile_page", 7405 types: ["geocode", "establishment"] 7406 }); 7407 7408 var monthnames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August' , 'September' , 'October', 'November', 'December']; 7409 var mshort = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; 7410 var calendarDefault = myApp.calendar({ 7411 input: '#birth_date', 7412 monthNames: monthnames, 7413 monthNamesShort: mshort, 7414 }); 7415 var typingTimer; //timer identifier 7416 var doneTypingInterval = 2000; 7417 var formData = myApp.formToJSON('#mobileregistration'); 7418 $$("#full_name").val(formData.admin_name); 7419 $$("#mobile").val(formData.mobileno); 7420 $$("#conversation_mail").val(formData.conv_mail); 7421 usersLoaded = true; 7422}); 7423 7424//This function will only apply on Website, not for app 7425function checkcamera() { 7426 MediaStreamTrack.getSources(gotSources); 7427 //navigator.mediaDevices.enumerateDevices(gotSources); 7428 function gotSources(sourceInfos){ 7429 var options = ''; 7430 for (var i = 0; i !== sourceInfos.length; ++i) { 7431 var sourceInfo = sourceInfos[i]; 7432 if (sourceInfo.kind === 'video') { 7433 var camId = "'"+sourceInfo.id+"'"; 7434 options += '<li><a href="#" onclick="cameraWeb('+camId+');">'+sourceInfo.label+'</a></li>'; 7435 $$("#camselect").append(options); 7436 } 7437 } 7438 setTimeout( function(){ 7439 myApp.modal({ 7440 title: 'Select Camera to Scan', 7441 text: options 7442 }); 7443 }, 500); 7444 /*var option = document.createElement('option'); 7445 option.value = sourceInfo.id; 7446 if (sourceInfo.kind === 'video') { 7447 var face = sourceInfo.facing == '' ? 'unknown' : sourceInfo.facing; 7448 option.text = sourceInfo.label || 'camera ' + (videoSelect.length + 1) + ' (facing: ' + face + ')'; 7449 videoSelect.appendChild(option); 7450 }*/ 7451 } 7452 } 7453 7454function cStop() 7455{ 7456 var MediaStream = window.MediaStream; 7457 7458 if (typeof MediaStream === 'undefined' && typeof webkitMediaStream !== 'undefined') { 7459 MediaStream = webkitMediaStream; 7460 } 7461 7462 /*global MediaStream:true */ 7463 if (typeof MediaStream !== 'undefined' && !('stop' in MediaStream.prototype)) { 7464 MediaStream.prototype.stop = function() { 7465 this.getAudioTracks().forEach(function(track) { 7466 track.stop(); 7467 }); 7468 7469 this.getVideoTracks().forEach(function(track) { 7470 track.stop(); 7471 }); 7472 }; 7473 } 7474} 7475 7476function cameraWeb(camId){ 7477 console.log("cameraWeb"); 7478 myApp.closeModal(); 7479 document.getElementById("camscanner").style.display = 'block'; 7480 //var urls = ""; 7481 //urls = "zxing://scan/?ret=https%3A%2F%2Fappsforbusiness.in%2Fccweb%2F%3Fcode%3D%7BCODE%7D"; 7482 //window.open(urls, "QR Scan"); 7483 /*var txt = "innerText" in HTMLElement.prototype ? "innerText" : "textContent"; 7484 var arg = { 7485 resultFunction: function(result) { 7486 console.log(result); 7487 var aChild = document.createElement('li'); 7488 aChild[txt] = result.format + ': ' + result.code; 7489 document.querySelector('body').appendChild(aChild); 7490 } 7491 }; 7492 new WebCodeCamJS("canvas").init(arg).play();*/ 7493 7494 $('#qr-canvas').WebCodeCam({ 7495 ReadQRCode: true, // false or true 7496 ReadBarecode: true, // false or true 7497 width: 320, 7498 height: 240, 7499 videoSource: { 7500 id: camId, //default Videosource 7501 maxWidth: 640, //max Videosource resolution width 7502 maxHeight: 480 //max Videosource resolution height 7503 }, 7504 flipVertical: false, // false or true 7505 flipHorizontal: false, // false or true 7506 zoom: -1, // if zoom = -1, auto zoom for optimal resolution else int 7507 beep: "js/beep.mp3", // string, audio file location 7508 autoBrightnessValue: false, // functional when value autoBrightnessValue is int 7509 brightness: 0, // int 7510 grayScale: false, // false or true 7511 contrast: 0, // int 7512 threshold: 0, // int 7513 sharpness: [], //or matrix, example for sharpness -> [0, -1, 0, -1, 5, -1, 0, -1, 0] 7514 resultFunction: function(resText, lastImageSrc) { 7515 console.log('resText - '+resText); 7516 document.getElementById("camscanner").style.display = 'none'; 7517 window.location.href = 'https://appsforbusiness.in/ccweb/index.html?code='+resText; 7518 //window.location('https://appsforbusiness.in/ccweb/index.html?code='+resText+''); 7519 //decoder.data().plugin_WebCodeCam.cameraStopAll(); 7520 //camerascan(resText); 7521 /* resText as decoded code, lastImageSrc as image source 7522 example: 7523 alert(resText); 7524 */ 7525 }, 7526 getUserMediaError: function() { 7527 /* callback funtion to getUserMediaError 7528 example: 7529 alert('Sorry, the browser you are using doesn\'t support getUserMedia'); 7530 */ 7531 }, 7532 cameraError: function(error) { 7533 /* callback funtion to cameraError, 7534 example: 7535 var p, message = 'Error detected with the following parameters:\n'; 7536 for (p in error) { 7537 message += p + ': ' + error[p] + '\n'; 7538 } 7539 alert(message); 7540 */ 7541 } 7542 }); 7543} 7544 7545 7546function camerascan(){ 7547myApp.closeModal('.popover-contacts');
7548 cordova.plugins.barcodeScanner.scan( 7549 function (result) { 7550 //var newresult = "https://bnc.lt/m/D6QHHLU2Tq/"; 7551 var newresult = result.text; 7552 var rd = ""; 7553 $.ajax({ 7554 type: 'GET', 7555 url: 'https://api.branch.io/v1/url?url='+newresult+'&branch_key=key_live_ehiRA7OC6nASuCZL0DwmnmiprwmXCxTL', 7556 data: { get_param: 'value'}, 7557 dataType: 'json', 7558 success: function(datas){ 7559 rd = datas.data; 7560 var childNo = ""; 7561 var username = window.localStorage.getItem("user_name"); 7562 var pstatus = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+rd.bid); 7563 pstatus.child('currency').once('value', function(snapshot){ 7564 window.localStorage.setItem("bcurrency",snapshot.val()); 7565 }); 7566 7567 pstatus.child('min_order_price').once('value', function(snapshot){ 7568 window.localStorage.setItem("bminordval",snapshot.val()); 7569 }); 7570 7571 pstatus.child('brand_privacystatus').once('value', function(snapshot){ 7572 var pstat = snapshot.val(); 7573 // When public 7574 if(pstat==0) { 7575 if(rd.cid) { 7576 var cstatus = new Firebase("https://fiery-fire-6430.firebaseio.com/catalogues/"+rd.bid+"/"+rd.cid); 7577 cstatus.once('value', function(snapshot){ 7578 var cstat = snapshot.val().cat_privacystatus; 7579 var parentid = snapshot.val().parentid; 7580 childNo = snapshot.val().no_of_child; 7581 if(cstat==0) { 7582 if(rd.pid) { 7583 if(rd.catwise=="Product Wise") { 7584 mainView.router.loadPage('productview.html?bid='+rd.bid+'&catid='+rd.cid+'&pid='+rd.pid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 7585 } else { 7586 mainView.router.loadPage('products.html?bid='+rd.bid+'&cid='+rd.cid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 7587 } 7588 } else { 7589 if(childNo == 0){ 7590 mainView.router.loadPage('products.html?bid='+rd.bid+'&cid='+rd.cid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 7591 } else { 7592 mainView.router.loadPage("subcatalogue.html?bid="+rd.bid+'&cid='+rd.cid+'&backinfo=callfromscan'); 7593 } 7594 } 7595 } else{ 7596 var cataccbrand = new Firebase("https://fiery-fire-6430.firebaseio.com/caccess/"+rd.bid+"/"+rd.cid+"/"+userudid+"/status"); 7597 cataccbrand.once('value', function(snapshotcat){ 7598 var getcatsts = snapshotcat.val(); 7599 if(getcatsts == 2) { 7600 if(rd.pid) { 7601 if(rd.catwise=="Product Wise") { 7602 mainView.router.loadPage('productview.html?bid='+rd.bid+'&catid='+rd.cid+'&pid='+rd.pid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 7603 } else { 7604 mainView.router.loadPage('products.html?bid='+rd.bid+'&cid='+rd.cid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 7605 } 7606 } else{ 7607 if(childNo == 0){ 7608 mainView.router.loadPage('products.html?bid='+rd.bid+'&cid='+rd.cid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 7609 } else{ 7610 mainView.router.loadPage("subcatalogue.html?bid="+rd.bid+'&cid='+rd.cid+'&backinfo=callfromscan'); 7611 } 7612 } 7613 } else{ 7614 myApp.alert("Please ask the brand to provide you access for this catalogue"); 7615 mainView.router.loadPage('catalogues.html?bid='+rd.bid); 7616 } 7617 }); 7618 } 7619 }); 7620 } else{ 7621 mainView.router.loadPage('bprofile.html?bid='+rd.bid); 7622 } 7623 } else{ 7624 if(rd.bid){ 7625 var scanbrand = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"+rd.bid+"/"+userudid+"/status"); 7626 scanbrand.once('value', function(snapshot){ 7627 var connstatus = snapshot.val(); 7628 if(connstatus == 2) { 7629 // Redirect to the Brand Profile Page 7630 if(rd.cid) { 7631 var cstatus = new Firebase("https://fiery-fire-6430.firebaseio.com/catalogues/"+rd.bid+"/"+rd.cid); 7632 cstatus.once('value', function(snapshot){ 7633 var cstat = snapshot.val().cat_privacystatus; 7634 var parentid = snapshot.val().parentid; 7635 childNo = snapshot.val().no_of_child; 7636 //console.log("Parent Id"+parentid); 7637 if(cstat==0){ 7638 if(rd.pid){ 7639 if(rd.catwise=="Product Wise"){ 7640 mainView.router.loadPage('productview.html?bid='+rd.bid+'&catid='+rd.cid+'&pid='+rd.pid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 7641 } else { 7642 mainView.router.loadPage('products.html?bid='+rd.bid+'&cid='+rd.cid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 7643 } 7644 } else{ 7645 if(childNo == 0){ 7646 mainView.router.loadPage('products.html?bid='+rd.bid+'&cid='+rd.cid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 7647 } else{ 7648 mainView.router.loadPage("subcatalogue.html?bid="+rd.bid+'&cid='+rd.cid+'&backinfo=callfromscan'); 7649 } 7650 } 7651 } else{ 7652 var cataccbrand = new Firebase("https://fiery-fire-6430.firebaseio.com/caccess/"+rd.bid+"/"+rd.cid+"/"+userudid+"/status"); 7653 cataccbrand.once('value', function(snapshotcat){ 7654 var getcatsts = snapshotcat.val(); 7655 if(getcatsts == 2) { 7656 if(rd.pid) { 7657 if(rd.catwise=="Product Wise") { 7658 mainView.router.loadPage('productview.html?bid='+rd.bid+'&catid='+rd.cid+'&pid='+rd.pid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 7659 } else{ 7660 mainView.router.loadPage('products.html?bid='+rd.bid+'&cid='+rd.cid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 7661 } 7662 } else{ 7663 if(childNo == 0){ 7664 mainView.router.loadPage('products.html?bid='+rd.bid+'&cid='+rd.cid+'&pwise='+rd.catwise+'&backinfo=callfromscan'); 7665 } else{ 7666 mainView.router.loadPage("subcatalogue.html?bid="+rd.bid+'&cid='+rd.cid+'&backinfo=callfromscan'); 7667 } 7668 } 7669 } else{ 7670 myApp.alert("Please ask the brand to provide you access for this catalogue"); 7671 mainView.router.loadPage('catalogues.html?bid='+rd.bid); 7672 } 7673 }); 7674 } 7675 }); 7676 } else{ 7677 mainView.router.loadPage('bprofile.html?bid='+rd.bid); 7678 } 7679 } else{ 7680 var uname = window.localStorage.getItem("user_name");
7681 // Do not show product 7682 var chkbrand = new Firebase("https://fiery-fire-6430.firebaseio.com/brand/"+rd.bid+"/brand_privacystatus"); 7683 chkbrand.once('value', function(snapshots){ 7684 var opentatus = snapshots.val(); 7685 //If brand is public/open 7686 if(opentatus == 0) { 7687 var uaccessKey = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"+rd.bid+"/"+userudid); 7688 uaccessKey.set({ 7689 user_email: useremail, 7690 status: 2, 7691 invitename:username, 7692 access_time: Firebase.ServerValue.TIMESTAMP, 7693 }); 7694 7695 $$.post('https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/gcmsk1.php', 7696 { msgtype:'crq', cname: uname, bid: rd.bid, mobile:userudid }, function (data) { 7697 }); 7698 mainView.router.loadPage('bprofile.html?bid='+rd.bid); 7699 } else{ //if brand is private 7700 var uaccessKey = new Firebase("https://fiery-fire-6430.firebaseio.com/baccess/"+rd.bid+"/"+userudid); 7701 uaccessKey.set({ 7702 user_email: useremail, 7703 status: 1, 7704 invitename:username, 7705 access_time: Firebase.ServerValue.TIMESTAMP, 7706 }); 7707 7708 var uname = window.localStorage.getItem("user_name"); 7709 $$.post('https://appsforbusiness.in/cloudcatalogue/process-copy/firebasesam/gcmsk1.php', 7710 { msgtype:'crq', cname: uname, bid: rd.bid, mobile:userudid}, function (data) { 7711 }); 7712 myApp.alert("A connection request has been sent to the brand."); 7713 } 7714 }); 7715 } 7716 }); 7717 } 7718 } 7719 }); 7720 }//End ajax success 7721 });//End ajax 7722 }, function (error) { 7723 myApp.alert("Scanning failed: " + error); 7724 }); 7725} 7726 7727 // Init App 7728 // we will restore the intercepted SMS here, for later restore 7729 var smsList = []; 7730 var interceptEnabled = false; 7731 function initsms() { 7732 if (! SMS ) { alert( 'SMS plugin not ready' ); return; } 7733 7734 document.addEventListener('onSMSArrive', function(e){ 7735 var mobilenolast = window.localStorage.getItem("mobilenolast"); 7736 var data = e.data; 7737 //console.log(data.address); 7738 //console.log(data.body); 7739 var addSplit = data.address 7740 addSplit = addSplit.split("-"); 7741 var compVal = addSplit[1]; 7742 //console.log("Compairable value : " +compVal); 7743 if(compVal === "CLOUDC" || compVal === "ORDERR" || compVal === "Orderr"){ 7744 var bodysms = data.body; 7745 bodysms = bodysms.split(/\r?\n/); 7746 var otp = bodysms[0].substr(bodysms[0].length - 4); 7747 //console.log(otp);
7748 //console.log(JSON.stringify(e)); 7749 smsList.push( data ); 7750 7751 updateStatus('SMS arrived, count: ' + smsList.length ); 7752 myApp.closeModal(); 7753 var nsettings = { 7754 "async": true, 7755 "crossDomain": true, 7756 "url": "https://appsforbusiness.in/cloudcatalogue/process/getjsonccmanager.php?action=otpVerify&mobileno="+mobilenolast+"&otp="+otp, 7757 "method": "GET", 7758 "headers": {} 7759 } 7760 $.ajax(nsettings).done(function (data){ 7761 var ndata = JSON.parse(data); 7762 var message = ndata.message; 7763 if(message="success"){ 7764 // myApp.alert("Congratulations You are verified with OTP "+otp); 7765 myApp.addNotification({ 7766 message: "Congratulations You are verified with OTP "+otp, 7767 hold: 3000, 7768 closeOnClick: false 7769 }); 7770 } 7771 //console.log(data); 7772 }); 7773 stopWatch(); 7774 }//end if of SMS read section 7775 }); 7776 } 7777 7778 function update( id, str ) { 7779 // $('div#' + id).html( str ); 7780 } 7781 function updateStatus( str ) { 7782 // $('div#status').html( str ); 7783 } 7784 function updateData( str ) { 7785 // $('div#data').html( str ); 7786 } 7787 7788 function sendSMS() { 7789 var sendto = $('input#sendto').val().trim(); 7790 var textmsg = $('textarea#textmsg').val(); 7791 if(sendto.indexOf(";") >=0) { 7792 sendto = sendto.split(";"); 7793 for(i in sendto) { 7794 sendto[i] = sendto[i].trim(); 7795 } 7796 } 7797 if(SMS) SMS.sendSMS(sendto, textmsg, function(){}, function(str){alert(str);}); 7798 } 7799 function listSMS() { 7800 updateData(''); 7801 7802 if(SMS) SMS.listSMS({}, function(data){ 7803 7804 var html = ""; 7805 if(Array.isArray(data)) { 7806 for(var i in data) { 7807 var sms = data[i]; 7808 html += sms.address + ": " + sms.body + "<br/>"; 7809 } 7810 } 7811 updateData( html ); 7812 7813 }, function(err){ 7814 updateStatus('error list sms: ' + err); 7815 }); 7816 } 7817 function deleteLastSMS() { 7818 updateData(''); 7819 if(smsList.length == 0) { 7820 updateStatus( 'no sms id to delete' ); 7821 return; 7822 } 7823 7824 var sms = smsList.pop(); 7825 7826 if(SMS) SMS.deleteSMS({ 7827 _id : sms["_id"] 7828 }, function( n ){ 7829 updateStatus( n + ' sms messages deleted' ); 7830 }, function(err){ 7831 updateStatus('error delete sms: ' + err); 7832 }); 7833 } 7834 function restoreAllSMS() { 7835 updateData(''); 7836 7837 if(SMS) SMS.restoreSMS(smsList, function( n ){ 7838 // clear the list if restore successfully 7839 smsList.length = 0; 7840 updateStatus(n + ' sms messages restored'); 7841 7842 }, function(err){ 7843 updateStatus('error restore sms: ' + err); 7844 }); 7845 } 7846 7847 /*function startWatch() { 7848 toggleIntercept(); 7849 if(SMS) SMS.startWatch(function(){ 7850 7851 console.log('watching started'); 7852 }, function(){ 7853 }); 7854 }*/ 7855 7856 function stopWatch() { 7857 if(SMS) SMS.stopWatch(function(){ 7858 toggleIntercept(); 7859 }, function(){ 7860 }); 7861 } 7862 7863 function toggleIntercept() { 7864 interceptEnabled = ! interceptEnabled; 7865 7866 if(interceptEnabled) { // clear the list before we start intercept 7867 smsList.length = 0; 7868 } 7869 7870 /* These lines will apply on app, not on web version*/ 7871 // if(SMS) SMS.enableIntercept(interceptEnabled, function(){ 7872 // }, function(){ 7873 // }); 7874 } 7875 7876 7877// function handleOpenURL(url) { 7878// // This function is triggered by the LaunchMyApp Plugin 7879// setTimeout(function() { 7880// myApp.alert(url); 7881// }, 400); 7882// } 7883 7884function handleOpenURL(url) { 7885 var res = url.split("bid="); 7886 console.log(res[0]); 7887 console.log(res[1]); 7888 var bid = res[1]; 7889 var check = res[0]; 7890 setTimeout( function(){ 7891 if(check === "https://orderr.in/app/"){ 7892 var userNum = window.localStorage.getItem('userudid'); 7893 userNum = userNum; 7894 var userName = window.localStorage.getItem('user_name'); 7895 userName = userName; 7896 console.log(userName+ " : " +userNum); 7897 if((userNum) && (userName) && (bid)){ 7898 mainView.router.loadPage('bprofile.html?bid='+bid); 7899 } else { 7900 //myApp.alert("Go to login page."); 7901 window.localStorage.setItem("homeLauncherUrl", url); 7902 myApp.loginScreen(); 7903 } 7904} 7905}, 2000); 7906 7907 // This function is triggered by the LaunchMyApp Plugin 7908 // setTimeout(function() { 7909 // alert(url); 7910 // }, 400); 7911} 7912 7913
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.