Advertisement
ahmadtri26

di order bang

Jan 5th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.44 KB | None | 0 0
  1. import { Component } from '@angular/core';
  2. import { ModalController, NavController, NavParams, ToastController, ActionSheetController, AlertController, ViewController } from 'ionic-angular';
  3. import { MyApp } from '../../app/app.component';
  4. import { ProductItemDetail } from '../product-item-detail/product-item-detail';
  5. import { ItemPopupAddress} from '../item-popup-address/item-popup-address';
  6. import { CartPage } from '../cart/cart';
  7.  
  8. import { OrderDbHelper } from '../../providers/order-db-helper';
  9. import { HttpService } from '../../providers/http-service';
  10. import { Session } from '../../providers/session';
  11. import { TranslateService } from '@ngx-translate/core';
  12. /**
  13. * Generated class for the ItemReviewOrderPage page.
  14. *
  15. * See https://ionicframework.com/docs/components/#navigation for more info on
  16. * Ionic pages and navigation.
  17. */
  18.  
  19. @Component({
  20. selector: 'page-item-review-order',
  21. templateUrl: 'item-review-order.html',
  22. })
  23. export class ItemReviewOrder {
  24. public nav;
  25. public navp;
  26. public buy;
  27. public pageTitle : string = "";
  28. public img : string = "";
  29. public itemId : string = "";
  30. public itemIdShop : string = "";
  31. public price : string = "";
  32. public seller : string = "";
  33. public sellerLocation : string = "";
  34. public category : string = "";
  35. public minimum : string = "";
  36. public stock = "";
  37. public description = "";
  38. public condition = "";
  39. public note;
  40. public total_price;
  41. public qty;
  42. public qty_zero = false;
  43. public example : string = "Example white Color/XL Size/2nd Edition";
  44. public jsonData;
  45. public chosenAddress;
  46. public chosenAgency;
  47.  
  48. public list_item;
  49. public itemBuy;
  50. public image : string;
  51. public name : string;
  52. public show_image : boolean = false;
  53. public itemBuy_final = [];
  54. public static chosenAddress;
  55. public static TAG : string = "Item Review Order";
  56. public static itemId = "";
  57. public static itemIdShop = "";
  58. public static img = "";
  59. public static pageTitle = "";
  60. public static price = "";
  61. public static seller = "";
  62. public static sellerLocation = "";
  63. public static category = "";
  64. public static minimum = "";
  65. public static stock = "";
  66. public static description = "";
  67. public static condition = "";
  68. public static totalPrice = "";
  69. public static qty = "";
  70. public static note = "";
  71.  
  72.  
  73. public estimatedPrice;
  74. public estimatedQty;
  75. public btnEstPrcTrigger;
  76.  
  77. public currentNumber = 0;
  78. public cart;
  79. public itemOrder;
  80. public itemProduct;
  81. public chooseAgency;
  82.  
  83. public setLang;
  84. public imglink;
  85. public translate;
  86.  
  87. public shippingAgency;
  88. public shippingAgencyFinal;
  89. public addressList;
  90. public addressListFinal;
  91. public isDataLoad: boolean = false;
  92. public showChosenAddress;
  93. constructor(
  94. public navCtrl: NavController,
  95. public navParams: NavParams,
  96. public toast: ToastController,
  97. public httpServ: HttpService,
  98. public session: Session,
  99. public modal: ModalController,
  100. public orderDB: OrderDbHelper,
  101. public alertCtrl: AlertController,
  102. public actionSheet: ActionSheetController,
  103. public translateSvc: TranslateService,
  104. public viewCtrl: ViewController
  105. )
  106. {
  107. try {
  108.  
  109. this.navp = navParams;
  110. this.nav = navCtrl;
  111. this.translate = translateSvc;
  112.  
  113. this.chooseAgency = {};
  114. this.itemOrder = {};
  115. this.shippingAgency = [];
  116. this.shippingAgencyFinal = [];
  117. this.addressList = [];
  118. this.addressListFinal = [];
  119. this.chosenAddress = [];
  120. this.chosenAgency = [];
  121. this.qty_zero = true;
  122. this.showChosenAddress = false;
  123.  
  124. this.chosenAddress = ItemReviewOrder.chosenAddress;
  125. this.pageTitle = ItemReviewOrder.pageTitle;
  126. this.img = ItemReviewOrder.img;
  127. this.itemId = ItemReviewOrder.itemId;
  128. this.itemIdShop = ItemReviewOrder.itemIdShop;
  129. this.price = ItemReviewOrder.price;
  130. this.seller = ItemReviewOrder.seller;
  131. this.sellerLocation = ItemReviewOrder.sellerLocation;
  132. this.stock = ItemReviewOrder.stock;
  133. this.description = ItemReviewOrder.description;
  134. this.condition = ItemReviewOrder.condition;
  135. this.category = ItemReviewOrder.category;
  136. this.qty = ItemReviewOrder.qty;
  137. this.note = ItemReviewOrder.note;
  138. this.total_price = ItemReviewOrder.totalPrice
  139.  
  140. this.itemBuy = {
  141. name: this.pageTitle,
  142. img: this.img,
  143. itemId: this.itemId,
  144. itemIdShop: this.itemIdShop,
  145. price: this.price,
  146. seller: this.seller,
  147. sellerLocation: this.sellerLocation,
  148. stock: this.stock,
  149. description: this.description,
  150. condition: this.condition,
  151. category: this.category,
  152. total_price: this.total_price,
  153. qty: this.qty,
  154. note: this.note
  155. }
  156.  
  157. this.itemBuy_final.push(this.itemBuy);
  158.  
  159. this.loadItem();
  160. this.totalEstPrice();
  161. this.loadShipping();
  162. this.loadShippingAgency();
  163. // this.loadAddress();
  164.  
  165. } catch (error) {
  166. MyApp.consoleLog("Some error happen", error);
  167. }
  168. }
  169.  
  170. ionViewDidLoad() {
  171. try {
  172. this.loadChooseAddress();
  173. this.showAddress();
  174. MyApp.consoleLog(ItemReviewOrder.TAG, "chosen Address", this.chosenAddress);
  175. MyApp.consoleLog(ItemReviewOrder.TAG, "flag choosen", this.showChosenAddress);
  176. MyApp.consoleLog(ItemReviewOrder.TAG, "loadshipping Item User", this.addressListFinal);
  177. } catch (error) {
  178. MyApp.consoleLog("Some error happen", error);
  179. }
  180. console.log('ionViewDidLoad ItemReviewOrderPage');
  181. MyApp.consoleLog(ItemReviewOrder.TAG, "item list: ", this.list_item);
  182. MyApp.consoleLog(ItemReviewOrder.TAG, "item buy: ", this.itemBuy_final);
  183.  
  184. }
  185.  
  186. ionViewWillLoad(){
  187.  
  188. }
  189.  
  190. ionViewWillUnload() {
  191. this.list_item = [];
  192. // this.addressListFinal = [];
  193. // this.shippingAgencyFinal = [];
  194. }
  195.  
  196. ionViewWillLeave(){
  197.  
  198. }
  199.  
  200. zeroQtyToast() {
  201. const toast = this.toast.create({
  202. message: 'Your item qty is 0',
  203. duration: 500,
  204. position: 'bottom'
  205. });
  206. toast.present();
  207. }
  208.  
  209. minus(mdata) {
  210. MyApp.consoleLog(ItemReviewOrder.TAG, "Minus button pressed!");
  211. if (mdata.qty == 0){
  212. MyApp.consoleLog(ItemReviewOrder.TAG, "Qty is 0");
  213. // this.zeroQtyToast();
  214. }
  215. else {
  216. mdata.qty--;
  217. mdata.total_price = mdata.qty * mdata.price;
  218. this.orderCart(mdata);
  219. MyApp.consoleLog(ItemReviewOrder.TAG, mdata);
  220. this.totalEstPrice();
  221. }
  222. }
  223.  
  224. plus(mdata) {
  225. MyApp.consoleLog(ItemReviewOrder.TAG, "Plus button pressed!");
  226. this.qty_zero = false;
  227. mdata.qty++;
  228. mdata.total_price = mdata.qty * mdata.price;
  229. this.orderCart(mdata);
  230. MyApp.consoleLog(ItemReviewOrder.TAG, mdata);
  231. this.totalEstPrice();
  232. }
  233.  
  234. deleteOrderCart(mdata, cartdata) {
  235. MyApp.consoleLog(ItemReviewOrder.TAG + "Delete mdata id " , mdata);
  236.  
  237. let temp = [];
  238. // let tempOrder2 = this.cart;
  239. for (let i in cartdata) {
  240. if (mdata.id != cartdata[i].id) {
  241. temp.push(cartdata[i]);
  242. }
  243. }
  244. // cart = tempOrder;
  245. return temp;
  246. }
  247.  
  248.  
  249. orderCart(mdata) {
  250. MyApp.consoleLog(ItemReviewOrder.TAG + "orderCart function ", mdata);
  251.  
  252. this.cart = ProductItemDetail.chosen_item;
  253. MyApp.consoleLog(ItemReviewOrder.TAG + "Data masuk ke Cart", this.cart);
  254.  
  255. // this.cart.push(mdata);
  256. let exist = false;
  257. let del = false;
  258. // let itemIndex = 0;
  259.  
  260. for (let i in this.cart) {
  261. MyApp.consoleLog(ItemReviewOrder.TAG + "Isi data i", i);
  262.  
  263. if (this.cart[i].id == mdata.id) {
  264. if (this.cart[i].qty == 0) {
  265. // delete this.cart[i];
  266. let tempOrder = this.deleteOrderCart(mdata, this.cart);
  267. MyApp.consoleLog(ItemReviewOrder.TAG + "TempOrder =", tempOrder);
  268. del = true;
  269.  
  270. this.cart = tempOrder;
  271. break;
  272. }
  273. else {
  274. exist = true;
  275. this.cart[i]=mdata;
  276. MyApp.consoleLog(ItemReviewOrder.TAG + "setIndex cart", this.cart);
  277.  
  278. // itemIndex++;
  279. }
  280. }
  281. }
  282.  
  283. if (exist === false && del === false) {
  284. MyApp.consoleLog(ItemReviewOrder.TAG + "add data", this.cart);
  285.  
  286. this.cart.push(mdata);
  287. }
  288.  
  289. let temp = [];
  290. for (let i in this.cart) {
  291. if (this.cart[i].qty != 0) {
  292. temp.push(this.cart[i]);
  293. }
  294. }
  295.  
  296. this.cart = temp;
  297. ProductItemDetail.chosen_item = this.cart;
  298.  
  299. MyApp.consoleLog(ItemReviewOrder.TAG + "Data masuk ke Cart 2", ProductItemDetail.chosen_item);
  300. }
  301.  
  302. loadItem() {
  303. MyApp.consoleLog(ItemReviewOrder.TAG, "XfoodChooseOrder Load Menu 2");
  304.  
  305. this.buildListItem(this.itemBuy_final);
  306.  
  307. MyApp.consoleLog(ItemReviewOrder.TAG, this.list_item);
  308. }
  309.  
  310. buildListItem(params){
  311. let list_item;
  312. list_item = params;
  313. for(let i = 0; i < params.length; i++){
  314. if(this.setLang == 'en'){
  315. list_item[i].itemId = params[i].itemId,
  316. list_item[i].itemIdShop = params[i].itemIdShop,
  317. list_item[i].img = params[i].img,
  318. list_item[i].note = params[i].note,
  319. list_item[i].price = params[i].price,
  320. list_item[i].shown_price = params[i].shown_price,
  321. list_item[i].total_price = params[i].total_price,
  322. list_item[i].qty = params[i].qty,
  323. list_item[i].name = params[i].name,
  324. list_item[i].description = params[i].description
  325. }
  326.  
  327. if(params[i].img == ""){
  328. list_item[i].imgLink = "assets/img/xfood_default_menu_image.jpg"
  329. } else {
  330. list_item[i].imgLink = this.imglink + params[i].img;
  331. }
  332. }
  333.  
  334. this.list_item = list_item;
  335. }
  336.  
  337. // loadAddress(){
  338. // this.buildListAddress(ItemReviewOrder.choosenAddress);
  339. // MyApp.consoleLog(ItemReviewOrder.TAG, "load choosen address", ItemReviewOrder.choosenAddress);
  340. // }
  341.  
  342. // buildListAddress(params){
  343. // let list_address;
  344. // list_address = params;
  345. // for(let i = 0; i < params.length; i++){
  346. // list_address[i].addressId = params[i].id,
  347. // list_address[i].id_user = params[i].id_user,
  348. // list_address[i].name = params[i].name,
  349. // list_address[i].address = params[i].address,
  350. // list_address[i].province = params[i].province,
  351. // list_address[i].postalCode = params[i].postalCode,
  352. // list_address[i].pickupLocation = params[i].pickupLocation
  353. // }
  354. // this.choosenAddress = list_address[i];
  355. // MyApp.consoleLog(ItemReviewOrder.TAG, "choosen Address data", this.choosenAddressFinal);
  356. // }
  357.  
  358. totalEstPrice(){
  359.  
  360. let sum_est = ProductItemDetail.chosen_item;
  361. MyApp.consoleLog(ItemReviewOrder.TAG + " isi sum_est ", sum_est);
  362.  
  363. let pricetotal = sum_est.map(i => i.total_price);
  364. let sums = pricetotal.reduce((a, b) => a + b, 0);
  365.  
  366. let qtytotal = sum_est.map(i => i.qty);
  367. let qtysums = qtytotal.reduce((a,b) => a + b, 0);
  368.  
  369. this.estimatedPrice = sums;
  370. this.estimatedQty = qtysums;
  371.  
  372. ProductItemDetail.estimatedPrice = sums;
  373. ProductItemDetail.estimatedQty = qtysums;
  374.  
  375. MyApp.consoleLog(ItemReviewOrder.TAG + " is estimated price ", this.estimatedPrice);
  376.  
  377. if ( this.estimatedPrice != 0) {
  378. this.btnEstPrcTrigger = true;
  379. }
  380. else {
  381. this.btnEstPrcTrigger = false;
  382.  
  383. MyApp.consoleLog(ItemReviewOrder.TAG + " status btn ", this.btnEstPrcTrigger);
  384. }
  385. }
  386.  
  387. gotoCart(){
  388. MyApp.consoleLog(ItemReviewOrder.TAG, "Go to Cart");
  389. //CartPage.list_order = this.cart;
  390. this.nav.push(CartPage);
  391. }
  392.  
  393. //load address user for shipping destination
  394. loadShipping(){
  395. let link = "http://192.168.0.111/phpscring/address_setting/load_address/";
  396. let user;
  397. user = {};
  398. user.id = this.session.getUserID();
  399. let postParams = {
  400. "link": link,
  401. "data": user
  402. }
  403.  
  404. this.httpServ.postService(postParams).then((data)=> {
  405. let response;
  406. response ={};
  407. response.data = data;
  408. MyApp.consoleLog(ItemReviewOrder.TAG, "data", data);
  409. MyApp.consoleLog(ItemReviewOrder.TAG, "response", response);
  410.  
  411. if(response.data != 0){
  412. for (let i = 0; i < response.data.length; i++) {
  413.  
  414. this.addressList[i] = {
  415. id: response.data[i].id,
  416. id_user: response.data[i].user_id,
  417. name: response.data[i].name,
  418. address: response.data[i].address,
  419. province: response.data[i].province,
  420. postalCode: response.data[i].postalCode,
  421. pickupLocation: response.data[i].pickupLocation
  422. };
  423. this.addressListFinal.push(this.addressList[i]);
  424. }
  425. MyApp.consoleLog(ItemReviewOrder.TAG, "address list", this.addressListFinal);
  426. }
  427. }, (error) => {
  428. MyApp.consoleError(ItemReviewOrder.TAG + "Couldn't connect to server", error);
  429. });
  430. }
  431.  
  432. //load Shipping Agency for service Delivery
  433. loadShippingAgency(){
  434. let link = "http://192.168.0.111/phpscring/open_shop/load_shipping_agency/";
  435. let shop;
  436. shop = {};
  437. shop.id = this.itemIdShop;
  438. let postParams = {
  439. "link": link,
  440. "data": shop
  441. }
  442.  
  443. MyApp.consoleLog(ItemReviewOrder.TAG, "shop id", shop);
  444.  
  445. this.httpServ.postService(postParams).then((data)=> {
  446. let response;
  447. response ={};
  448. response.data = data;
  449. MyApp.consoleLog(ItemReviewOrder.TAG, "data", data);
  450. MyApp.consoleLog(ItemReviewOrder.TAG, "response", response);
  451.  
  452. if(response.data != 0){
  453. for (let i = 0; i < response.data.length; i++) {
  454. this.shippingAgency[i] = {
  455. id: response.data[i].id,
  456. id_shop: response.data[i].id_shop,
  457. nameAgency: response.data[i].name_delivery
  458. };
  459. this.shippingAgencyFinal.push(this.shippingAgency[i]);
  460. }
  461. MyApp.consoleLog(ItemReviewOrder.TAG, "shippingAgency", this.shippingAgencyFinal);
  462. }
  463. }, (error) => {
  464. MyApp.consoleError(ItemReviewOrder.TAG + "Couldn't connect to server", error);
  465. });
  466. }
  467.  
  468. setItemNote() {
  469. MyApp.consoleLog(ItemReviewOrder.TAG + " Data Order untuk dijadikan Note ", this.cart);
  470.  
  471. // this.addNotes["notes"]
  472. this.itemProduct = this.cart;
  473. MyApp.consoleLog(ItemReviewOrder.TAG + " value xfoodNotes ", this.itemProduct);
  474.  
  475. this.itemOrder.list_order = this.itemProduct;
  476. this.itemOrder.total = this.estimatedPrice;
  477.  
  478. // this.XfoodOrder.total = XfoodReviewOrder.subtotalItem;
  479. // this.session.setXfoodNote(this.XfoodOrder);
  480.  
  481. let itemNote;
  482. let colSize = {
  483. name : 6,
  484. price : 7,
  485. qty : 5,
  486. total_price : 12
  487. };
  488.  
  489. let maxColSize = {
  490. name : 20,
  491. price : 20,
  492. qty : 20,
  493. total_price : 20
  494. };
  495.  
  496. for (let i = 0; i < this.itemProduct.length; i++) {
  497. let name: string = this.itemProduct[i].name;
  498. let price: string = this.itemProduct[i].price.toString();
  499. let qty: string = this.itemProduct[i].qty.toString();
  500. let total_price: string = this.itemProduct[i].total_price.toString();
  501.  
  502. if (name.length + 2 >= colSize.name) {
  503. if (name.length + 2>= maxColSize.name) {
  504. colSize.name = maxColSize.name;
  505. }
  506. else {
  507. colSize.name = name.length + 2;
  508. }
  509. }
  510.  
  511. if (price.length + 2 >= colSize.price) {
  512. if (price.length + 2 >= maxColSize.price) {
  513. colSize.price = maxColSize.price;
  514. }
  515. else {
  516. colSize.price = price.length + 2;
  517. }
  518. }
  519.  
  520. if (qty.length + 2 >= colSize.qty) {
  521. if (qty.length + 2 >= maxColSize.qty) {
  522. colSize.qty = maxColSize.qty;
  523. }
  524. else {
  525. colSize.qty = qty.length + 2;
  526. }
  527. }
  528.  
  529. if (total_price.length + 2 >= colSize.total_price) {
  530. if (total_price.length + 2 >= maxColSize.total_price) {
  531. colSize.total_price = maxColSize.total_price;
  532. }
  533. else {
  534. colSize.total_price = total_price.length + 2;
  535. }
  536. }
  537. }
  538.  
  539. itemNote = this.category;
  540. itemNote += "\n";
  541. itemNote += "\n";
  542. itemNote += "*****************************";
  543. itemNote += "\n";
  544. itemNote += this.getBeautyPrint("Qty", colSize.qty);
  545. itemNote += this.getBeautyPrint("Name", colSize.name);
  546. itemNote += this.getBeautyPrint("Price", colSize.price);
  547. itemNote += this.getBeautyPrint("Total Price", colSize.total_price);
  548.  
  549. for (let i = 0; i < this.itemProduct.length; i++) {
  550. let foodname: string = this.itemProduct[i].name;
  551. let price: string = this.itemProduct[i].price.toString();
  552. let qty: string = this.itemProduct[i].qty.toString();
  553. let total_price: string = this.itemProduct[i].total_price.toString();
  554. let note: string = this.itemProduct[i].note.toString();
  555. MyApp.consoleLog (ItemReviewOrder.TAG, " test beautyPrint " + "\n" + qty +" pcs" + " " + name + " " +"KHR "+ price + " " +"KHR "+ total_price);
  556. itemNote += "\n";
  557. itemNote += this.getBeautyPrint(qty, colSize.qty);
  558. itemNote += this.getBeautyPrint(foodname, colSize.name);
  559. itemNote += this.getBeautyPrint(price, colSize.price);
  560. itemNote += this.getBeautyPrint(total_price, colSize.total_price);
  561. if(note.length != 0 ){
  562. itemNote += "\n";
  563. itemNote += "*NB: " + note;
  564. itemNote += "\n";
  565. }
  566. }
  567.  
  568. itemNote += "\n";
  569. itemNote += "*****************************";
  570. if(ItemReviewOrder.note.length != 0 ){
  571. itemNote += "\n";
  572. itemNote += "\n";
  573. itemNote += "Notes :";
  574. itemNote += "\n";
  575. itemNote += ItemReviewOrder.note;
  576. }
  577. itemNote += "\n";
  578. itemNote += "\n";
  579. itemNote += "Estimate Price :" + "RP " + this.estimatedPrice;
  580.  
  581. MyApp.consoleLog(ItemReviewOrder.TAG, " isi itemNote " + "\n" + itemNote);
  582.  
  583. this.itemOrder.category = this.category;
  584. // this.XfoodOrder.restoaddress = this.restoaddress;
  585. // this.XfoodOrder.restoPhone = this.restophone;
  586. // this.XfoodOrder.restoPhone2 = this.restophone2;
  587. this.itemOrder.notes = ItemReviewOrder.note;
  588. // this.jsonStartLocation.Note = XfoodNote;
  589. // this.jsonStartLocation.XfoodNote = this.XfoodOrder;
  590. this.session.setStartNote(itemNote);
  591. }
  592.  
  593. getBeautyPrint(val, colSize){
  594. let beautyText = val;
  595. for (let i = val.length; i < colSize; i++) {
  596. beautyText += " ";
  597. }
  598. MyApp.consoleLog(ItemReviewOrder.TAG, beautyText + "INI Value ColSize " + colSize);
  599. return beautyText;
  600. }
  601.  
  602. loadChooseAddress(){
  603. this.EditAddress(this.addressListFinal);
  604. }
  605.  
  606. EditAddress(params){
  607. ItemPopupAddress.addressListFinal = params;
  608. // ItemPopupAddress.addressId = params.id;
  609. // ItemPopupAddress.addressUserId = params.id_user;
  610. // ItemPopupAddress.address = params.address;
  611. // ItemPopupAddress.addressName = params.name;
  612. // ItemPopupAddress.province = params.province;
  613. // ItemPopupAddress.postalCode = params.postalCode;
  614. // ItemPopupAddress.pickupLocation = params.pickupLocation;
  615. }
  616.  
  617. gotoEditAddress(params){
  618. this.nav.push(ItemPopupAddress).then(()=>{
  619. // let modalAddress = this.modal.create(ItemPopupAddress);
  620. // modalAddress.present();
  621. const index = this.viewCtrl.index;
  622. this.navCtrl.remove(index);
  623. });
  624. // this.nav.push(ItemPopupAddress);
  625. }
  626.  
  627. showImage(img, name){
  628. this.image = img;
  629. this.name = name;
  630. this.show_image = true;
  631. }
  632.  
  633. close(){
  634. this.show_image = false;
  635. }
  636.  
  637. confirmOrder(cart){
  638.  
  639. this.jsonData = {}
  640. this.jsonData.product = cart.itemId;
  641. this.jsonData.user = this.session.getUserID();
  642. this.jsonData.quantity = cart.qty;
  643. this.jsonData.timestamp = Math.round(new Date().getTime()/1000);
  644. this.jsonData.note = cart.note;
  645. this.jsonData.address = this.chosenAddress.id;
  646. this.jsonData.shippingAgency = this.chosenAgency.id;
  647.  
  648. MyApp.consoleLog(ItemReviewOrder.TAG, "cartOrder", this.cart);
  649. MyApp.consoleLog(ItemReviewOrder.TAG, "orderData", this.jsonData);
  650.  
  651.  
  652. let orders = {
  653. 'PRODUCT': this.jsonData.product,
  654. 'USER': this.jsonData.user,
  655. 'TIMESTAMP': this.jsonData.timestamp,
  656. 'QUANTITY': this.jsonData.quantity,
  657. 'NOTE': this.jsonData.note,
  658. 'ADDRESS': this.jsonData.address,
  659. 'AGENCY': this.jsonData.shippingAgency,
  660. }
  661. let lastID = this.session.getLastTx();
  662. lastID++;
  663. this.session.setLastTx(lastID);
  664. this.orderDB.saveOrdersMulti(lastID,orders).then((result) => {
  665. this.session.setXfoodNoteMulti(lastID,this.itemOrder);
  666. this.session.setLastTx(lastID);
  667. MyApp.consoleLog(ItemReviewOrder.TAG + " SAVE ORDER", result);
  668. MyApp.consoleLog(ItemReviewOrder.TAG + " SAVE ORDER", true);
  669. }, error => {
  670. MyApp.consoleError(ItemReviewOrder.TAG + " Save Order", error);
  671. });
  672.  
  673. this.popPage();
  674. }
  675.  
  676. popPage() {
  677. this.nav.remove().then(()=>{
  678. this.nav.pop(ProductItemDetail);
  679. });
  680. }
  681.  
  682. showAddress(){
  683. if (typeof this.chosenAddress == 'undefined') {
  684. this.showChosenAddress = false;
  685. }
  686. else {
  687. this.showChosenAddress = true;
  688. }
  689. }
  690.  
  691. agencyClicked(val){
  692. this.chooseAgency.selectedValue = val;
  693. this.chosenAgency = this.chooseAgency.selectedValue;
  694. MyApp.consoleLog(ItemReviewOrder.TAG, "selected value", this.chosenAgency)
  695. }
  696.  
  697. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement