Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function(){
- 'use strict';
- angular
- .module('cmsOrderApp')
- .controller('CmsOrderCtrl', CmsOrderCtrl)
- .controller('CmsOrderDetailCtrl', CmsOrderDetailCtrl);
- CmsOrderCtrl.$inject = ['$scope','$state','$stateParams','$uibModal','$log','CmsOrderService', 'toastr'];
- CmsOrderDetailCtrl.$inject = ['$scope','$state','$stateParams','$uibModal','$log','CmsOrderService', 'toastr'];
- function CmsOrderCtrl($scope,$state,$stateParams,$uibModal,$log,CmsOrderService, toastr){
- $('#block').show();
- $scope.roleName = window.Laravel.suppType;
- $scope.roleGudang = window.Laravel.roleGudang;
- $scope.roleAdmin = window.Laravel.roleAdmin;
- $scope.roleManagement = window.Laravel.roleManagement;
- function defaultDate(){
- var date1 = new Date();
- var date2 = new Date();
- $scope.endDate = date1;
- date2.setDate(date2.getDate()-1);
- $scope.startDate = date2;
- }
- defaultDate();
- $scope.checkTask = function($task){
- var taskList = window.Laravel.taskList;
- taskList = taskList.split(",");
- var index = taskList.indexOf($task);
- if(index == -1){
- return false;
- }else{
- return true;
- }
- }
- $scope.limit = 10;
- $scope.offset = 1;
- $scope.sort = true; // true = ASC
- $scope.orderBy = ''
- $scope.orderType = '';
- $scope.back = function(){
- window.history.back();
- }
- $scope.filter = function(){
- $scope.startDateFilter = $scope.startDate;
- $scope.endDateFilter = $scope.endDate;
- $scope.getOrderList();
- }
- $scope.getOrderList = function(){
- $('#block').show();
- var input = {};
- input.orderNo = $scope.orderNo;
- // input.startDate = $scope.startDateFilter;
- // input.endDate = $scope.endDateFilter;
- input.startDate = $scope.startDate;
- input.endDate = $scope.endDate;
- if($scope.salesmanList != undefined && $scope.salesmanList.selected != undefined){
- input.salesmanUserId = $scope.salesmanList.selected.user_id;
- }else{
- input.salesmanUserId = '';
- }
- if($scope.tokoList != undefined && $scope.tokoList.selected != undefined){
- input.tokoUserId = $scope.tokoList.selected.user_id;
- }else{
- input.tokoUserId = '';
- }
- if($scope.cabangList != undefined && $scope.cabangList.selected != undefined){
- input.cabang = $scope.cabangList.selected.ou_id;
- }else{
- input.cabang = '';
- }
- input.limit = $scope.limit;
- input.offset = $scope.offset;
- input.status = $scope.status;
- input.orderBy = $scope.orderBy;
- input.orderType = $scope.orderType;
- CmsOrderService.getOrderList(input)
- .then(function(response){
- if(response.data.status == 'OK'){
- $scope.orderList = response.data.orderList;
- $scope.orderTotal = response.data.totalOrder;
- $('#block').hide();
- }else{
- $('#block').hide();
- swal("Error!", response.data.error, "error");
- }
- });
- }
- $scope.getOrderList();
- $scope.changeLimit = function(){
- if($scope.pageItem != ''){
- $scope.limit = $scope.pageItem;
- }else{
- $scope.limit = 10;
- }
- $scope.getOrderList();
- }
- $scope.setOrder = function(by,type){
- $scope.sort = type;
- if($scope.sort == true){
- $scope.orderType = 'ASC';
- $scope.orderIcon = 'fa fa-sort-amount-asc';
- }else{
- $scope.orderType = 'DESC';
- $scope.orderIcon = 'fa fa-sort-amount-desc';
- }
- $scope.orderBy = by;
- $scope.getOrderList();
- }
- $scope.getCabangList = function(){
- var defaultOu = {
- ou_id:"",
- ou_code:"",
- ou_name:"SEMUA CABANG"
- }
- CmsOrderService.getCabangList()
- .then(function(response){
- if(response.data.status == 'OK'){
- $scope.cabangList = response.data.cabangList;
- $scope.cabangList.unshift(defaultOu);
- $scope.cabangList.selected = defaultOu;
- }else{
- swal("Error!", response.data.error, "error");
- }
- });
- }
- $scope.getSalesmanList = function(){
- CmsOrderService.getSalesmanList()
- .then(function(response){
- if(response.data.status == 'OK'){
- $scope.salesmanList = response.data.salesmanList;
- console.log("DATA SALESMAN DARI ORDER");
- console.log($scope.salesmanList);
- }else{
- swal("Error!", response.data.error, "error");
- }
- });
- }
- $scope.getTokoList = function(){
- CmsOrderService.getTokoList()
- .then(function(response){
- if(response.data.status == 'OK'){
- $scope.tokoList = response.data.tokoList;
- }else{
- swal("Error!", response.data.error, "error");
- }
- });
- }
- $scope.getCabangList();
- $scope.getSalesmanList();
- $scope.getTokoList();
- }
- function CmsOrderDetailCtrl($scope,$state,$stateParams,$uibModal,$log,CmsOrderService, toastr){
- $('#block').show();
- $scope.roleName = window.Laravel.suppType;
- $scope.roleGudang = window.Laravel.roleGudang;
- $scope.roleAdmin = window.Laravel.roleAdmin;
- $scope.roleManagement = window.Laravel.roleManagement;
- $scope.flgAddBonus = false;
- $scope.flgUpdateStatusByAdminSales = false;
- $scope.flgUpdateStatusByAdminGudang = false;
- $scope.flgShowRemarkInternal = false;
- $scope.flgInputRemarkInternal = false;
- $scope.flgInputDiscountHeader = false;
- $scope.flgShowDiscount = false;
- $scope.flgInputDiscount = false;
- $scope.flgShowTotalOrderDiscount = false;
- $scope.flgShowTotalDeliveryDiscount = false;
- $scope.flgShowTotalReceivedDiscount = false;
- $scope.flgShowTotalOrderAmountAfterDisc = false;
- $scope.flgShowTotalDeliveryAmountAfterDisc = false;
- $scope.flgShowTotalReceivedAmountAfterDisc = false;
- $scope.flgShowQtyReceive = false;
- $scope.flgShowRemark = false;
- $scope.flgShowRowForAdminSales = false;
- $scope.flgShowRowForAdminGudang = false;
- $scope.flgEditUnitPrice = false;
- $scope.flgEditQtyOrderFreeProduct = false;
- $scope.statusD = 'D';
- $scope.statusR = 'R';
- $scope.statusC = 'C';
- $scope.statusS = 'S';
- $scope.statusF = 'F';
- $scope.externalList = [];
- $scope.expanded = [];
- $scope.soList = [];
- $scope.setFalse = function(){
- $scope.flgAddBonus = false;
- $scope.flgUpdateStatusByAdminSales = false;
- $scope.flgUpdateStatusByAdminGudang = false;
- $scope.flgShowRemarkInternal = false;
- $scope.flgInputRemarkInternal = false;
- $scope.flgInputDiscountHeader = false;
- $scope.flgShowDiscount = false;
- $scope.flgInputDiscount = false;
- $scope.flgShowTotalDeliveryDiscount = false;
- $scope.flgShowTotalOrderDiscount = false;
- $scope.flgShowTotalOrderAmountAfterDisc = false;
- $scope.flgShowTotalDeliveryAmountAfterDisc = false;
- $scope.flgShowTotalReceivedAmountAfterDisc = false;
- $scope.flgShowQtyReceive = false;
- $scope.flgShowRemark = false;
- $scope.flgShowRowForAdminSales = false;
- $scope.flgShowRowForAdminGudang = false;
- $scope.flgEditUnitPrice = false;
- $scope.flgEditQtyOrderFreeProduct = false;
- $scope.flgD = false;
- $scope.flgR = false;
- $scope.flgS = false;
- $scope.flgF = false;
- $scope.flgC = false;
- }
- $scope.setTrue = function(){
- $scope.setFalse();
- if(($scope.roleName == $scope.roleAdmin || $scope.roleName == $scope.roleManagement) && ($scope.orderDetail.status == $scope.statusR || $scope.orderDetail.status == $scope.statusS || $scope.orderDetail.status == $scope.statusD)){
- $scope.flgUpdateStatusByAdminSales = true;
- }
- if(($scope.roleName == $scope.roleAdmin || $scope.roleName == $scope.roleManagement) && ($scope.orderDetail.status == $scope.statusR || $scope.orderDetail.status == $scope.statusS)){
- $scope.flgShowTotalDeliveryDiscount = true;
- $scope.flgShowTotalDeliveryAmountAfterDisc = true;
- }
- if(($scope.roleName == $scope.roleAdmin || $scope.roleName == $scope.roleManagement) && $scope.orderDetail.status == $scope.statusF){
- $scope.flgShowTotalReceivedDiscount = true;
- $scope.flgShowTotalReceivedAmountAfterDisc = true;
- }
- if(($scope.roleName == $scope.roleGudang || $scope.roleName == $scope.roleManagement) && ($scope.orderDetail.status == $scope.statusR || $scope.orderDetail.status == $scope.statusS)){
- $scope.flgUpdateStatusByAdminGudang = true;
- }
- if(($scope.roleName == $scope.roleAdmin || $scope.roleName == $scope.roleManagement) ){
- $scope.flgShowRowForAdminSales = true;
- $scope.flgShowRemark = true;
- $scope.flgShowRemarkInternal = true;
- $scope.flgShowDiscount = true;
- }
- if(($scope.roleName == $scope.roleGudang || $scope.roleName == $scope.roleManagement) ){
- $scope.flgShowRowForAdminGudang = true;
- }
- if($scope.orderDetail.status == $scope.statusR || $scope.orderDetail.status == $scope.statusD){
- $scope.flgInputRemarkInternal = true;
- }
- if(($scope.roleName == $scope.roleAdmin || $scope.roleName == $scope.roleManagement) && $scope.orderDetail.status == $scope.statusD){
- $scope.flgInputDiscountHeader = true;
- }
- if($scope.orderDetail.status == $scope.statusD || $scope.orderDetail.status == $scope.statusC){
- $scope.flgShowTotalOrderAmountAfterDisc = true;
- }
- if($scope.orderDetail.status == $scope.statusD && ($scope.roleName == $scope.roleAdmin || $scope.roleName == $scope.roleManagement)){
- $scope.flgAddBonus = true;
- $scope.flgInputDiscount = true;
- $scope.flgEditUnitPrice = true;
- $scope.flgEditQtyOrderFreeProduct = true;
- }
- if($scope.orderDetail.status == $scope.statusD){
- $scope.flgD = false;
- $scope.flgR = true;
- $scope.flgS = false;
- $scope.flgF = false;
- $scope.flgC = true;
- }else if($scope.orderDetail.status == $scope.statusR){
- $scope.flgD = false;
- $scope.flgR = false;
- $scope.flgS = true;
- $scope.flgF = false;
- if(($scope.roleName == $scope.roleGudang || $scope.roleName == $scope.roleManagement))
- $scope.flgC = false;
- else
- $scope.flgC = true;
- }else if($scope.orderDetail.status == $scope.statusS){
- $scope.flgD = false;
- $scope.flgR = false;
- $scope.flgS = false;
- $scope.flgF = true;
- $scope.flgC = false;
- }else if($scope.orderDetail.status == $scope.statusF){
- $scope.flgD = false;
- $scope.flgR = false;
- $scope.flgS = false;
- $scope.flgF = false;
- $scope.flgC = false;
- $scope.flgShowQtyReceive = true;
- }else if($scope.orderDetail.status == $scope.statusC){
- $scope.flgD = false;
- $scope.flgR = false;
- $scope.flgS = false;
- $scope.flgF = false;
- $scope.flgC = false;
- }else{
- $scope.flgD = false;
- $scope.flgR = false;
- $scope.flgS = false;
- $scope.flgF = false;
- $scope.flgC = false;
- }
- }
- $scope.checkTask = function($task){
- var taskList = window.Laravel.taskList;
- taskList = taskList.split(",");
- var index = taskList.indexOf($task);
- if(index == -1){
- return false;
- }else{
- return true;
- }
- }
- $scope.getOrderDetail = function(){
- $('#block').show();
- var input = {};
- input.orderId = $stateParams.orderId;
- CmsOrderService.getOrderDetail(input)
- .then(function(response){
- if(response.data.status == 'OK'){
- $scope.orderDetail = response.data.detailOrder;
- $scope.discountHeader = $scope.orderDetail.header_discount;
- // $scope.remarkInternal = $scope.orderDetail.remark_internal;
- if($scope.orderDetail.status == 'D' || $scope.orderDetail.status == 'C' || $scope.orderDetail.status == 'R') {
- $scope.flgDelivered = false;
- }else if($scope.orderDetail.status == 'S' || $scope.orderDetail.status == 'F'){
- $scope.flgDelivered = true;
- }else{
- swal('Error','Terjadi Kesalahan Pada Sistem','error');
- }
- if($scope.orderDetail.status == 'D') {
- $scope.colspan = 4;
- }else{
- $scope.colspan = 3;
- }
- var i = 1;
- angular.forEach($scope.orderDetail.orderItem,function(row){
- row.number = i;
- i++;
- });
- $scope.setTrue();
- $('#block').hide();
- }else{
- $('#block').hide();
- swal('Error',response.data.error,'error');
- }
- });
- }
- $scope.getOrderDetail();
- $scope.getOrderSO = function(){
- $('#block').show();
- var input = {};
- input.orderId = $stateParams.orderId;
- CmsOrderService.getOrderSO(input)
- .then(function(response){
- if(response.data.status == 'OK'){
- $scope.soList = response.data.orderList.orderList;
- console.log("SOLIST", $scope.soList)
- $('#block').hide();
- }else{
- $('#block').hide();
- swal('Error',response.data.error,'error');
- }
- });
- }
- $scope.getItemList = function(order_external_id){
- $scope.expanded[order_external_id] = !$scope.expanded[order_external_id];
- var input = {
- orderExternalId : order_external_id
- };
- CmsOrderService.getOrderExternalItemList(input)
- .then(function(response){
- if(response.data.status == 'OK'){
- $scope.externalList[order_external_id] = response.data.orderExternalList.orderExternalList;
- $scope.orderExternal = order_external_id;
- $('#block').hide();
- }else{
- $('#block').hide();
- swal('Error',response.data.error,'error');
- }
- });
- }
- $scope.getOrderSO();
- $scope.getItemList();
- $scope.back = function(){
- window.history.back();
- }
- $scope.updateStatus = function(status){
- var message;
- if(status == 'R'){
- message = 'Apakah anda yakin akan mengubah status order ini menjadi Dalam Proses';
- }else if(status == 'S'){
- message = 'Apakah anda yakin akan mengubah status order ini menjadi Dalam Pengiriman Toko';
- }else if(status == 'F'){
- message = 'Apakah anda yakin akan mengubah status order ini menjadi Diterima Toko';
- }else if(status == 'C'){
- message = 'Apakah anda yakin akan mengubah status order ini menjadi Dibatalkan';
- }
- swal({
- title: "Update Status?",
- text: message,
- type: "warning",
- showCancelButton: true,
- confirmButtonText: "Yes"
- })
- .then((result)=>{
- if(result.value){
- $('#block').show();
- var input = {};
- input.orderId = $stateParams.orderId;
- input.status = status;
- CmsOrderService.updateStatusOrder(input)
- .then(function(response){
- if(response.data.status == 'OK'){
- if(status == 'R'){
- $scope.editDiscountHeader();
- }
- $scope.getOrderDetail();
- $scope.closeModalStatus();
- }else{
- $('#block').hide();
- swal('Error',response.data.error,'error');
- }
- });
- }
- })
- }
- $scope.closeModalStatus = function(){
- $('#statusModal').modal('hide');
- }
- $scope.calculateDiscountHeader = function(){
- console.log($scope.discountHeaderPercent);
- $scope.discountHeader = $scope.orderDetail.total_order_amount * ($scope.discountHeaderPercent / 100);
- }
- $scope.editDiscountHeader = function(){
- $('#block').show();
- var input = {};
- input.discountHeader = $scope.discountHeader;
- input.discountHeaderPercent = $scope.discountHeaderPercent;
- input.orderId = $stateParams.orderId;
- console.log(input);
- CmsOrderService.editDiscountHeader(input)
- .then(function(response){
- if(response.data.status == 'OK'){
- $scope.getOrderDetail();
- }else{
- $('#block').hide();
- swal('Error',response.data.error,'error');
- }
- });
- }
- $scope.editDiscountItem = function(id){
- $('#block').show();
- var input = {};
- input.orderId = $stateParams.orderId;
- input.orderItemId = id;
- if($scope.discountItemPercent == undefined){
- $scope.closeModalDiscountItem();
- $('#block').hide();
- return [];
- }else{
- input.discountItemPercent = $scope.discountItemPercent;
- }
- CmsOrderService.editDiscountItem(input)
- .then(function(response){
- if(response.data.status == 'OK'){
- $scope.getOrderDetail();
- $scope.closeModalDiscountItem();
- $scope.discountItemPercent = undefined;
- }else{
- $('#block').hide();
- swal('Error',response.data.error,'error');
- }
- });
- }
- $scope.openModalDiscountItem = function(item,id){
- $scope.oldDiscountItem = item;
- $scope.discountItemPercent = undefined;
- $('#discountModal').modal('show');
- $scope.selectedOrderItem = id;
- }
- $scope.closeModalDiscountItem = function(){
- $('#discountModal').modal('hide');
- }
- $scope.editQtyDeliveryItem = function(id){
- $('#block').show();
- var input = {};
- input.orderId = $stateParams.orderId;
- input.orderItemId = id;
- if($scope.qtyDelivery == undefined){
- $scope.closeModalQtyDeliveryItem();
- $('#block').hide();
- return [];
- }else{
- $('#block').hide();
- input.qtyDelivery = $scope.qtyDelivery;
- if(input.qtyDelivery < 0) {
- sweetAlert('Error', 'Qty Kirim harus lebih dari 0', 'error');
- return;
- }
- }
- CmsOrderService.editQtyDeliveryItem(input)
- .then(function(response){
- if(response.data.status == 'OK'){
- $scope.getOrderDetail();
- $scope.closeModalQtyDeliveryItem();
- $scope.qtyDelivery = undefined;
- }else{
- $('#block').hide();
- swal('Error',response.data.error,'error');
- }
- });
- }
- $scope.openModalQtyDeliveryItem = function(item,id){
- $scope.oldQtyDelivery = item;
- $('#qtyDevModal').modal('show');
- $scope.selectedOrderItem = id;
- $scope.qtyDelivery = item.qty_delivery;
- }
- $scope.closeModalQtyDeliveryItem = function(){
- $('#qtyDevModal').modal('hide');
- }
- // $scope.addFreeProduct = function(id){
- // $('#block').show();
- // var input = {};
- // input.orderId = $stateParams.orderId;
- // input.orderItemId = id;
- // CmsOrderService.addFreeProduct(input)
- // .then(function(response){
- // if(response.data.status == 'OK'){
- // $scope.getOrderDetail();
- // }else{
- // $('#block').hide();
- // swal('Error',response.data.error,'error');
- // }
- // });
- // }
- $scope.removeFreeProduct = function(id){
- $('#block').show();
- var input = {};
- input.orderId = $stateParams.orderId;
- input.orderItemId = id;
- CmsOrderService.removeFreeProduct(input)
- .then(function(response){
- if(response.data.status == 'OK'){
- $scope.getOrderDetail();
- }else{
- $('#block').hide();
- swal('Error',response.data.error,'error');
- }
- });
- }
- $scope.editQtyOrderFreeProduct = function(id){
- $('#block').show();
- var input = {};
- input.orderId = $stateParams.orderId;
- input.orderItemId = id;
- if($scope.qtyOrder == undefined){
- $scope.closeModalQtyOrderFreeProduct();
- $('#block').hide();
- return [];
- }else{
- input.qtyOrder = $scope.qtyOrder;
- }
- CmsOrderService.editQtyOrderFreeProduct(input)
- .then(function(response){
- if(response.data.status == 'OK'){
- $scope.getOrderDetail();
- $scope.closeModalQtyOrderFreeProduct();
- $scope.unitPrice = undefined;
- }else{
- $('#block').hide();
- swal('Error',response.data.error,'error');
- }
- });
- }
- $scope.openModalQtyOrderFreeProduct = function(item,id){
- $scope.qtyOrder = undefined;
- $scope.oldQtyOrderForFree = item;
- $('#qtyOrderModal').modal('show');
- $scope.selectedOrderItem = id;
- }
- $scope.closeModalQtyOrderFreeProduct = function(){
- $('#qtyOrderModal').modal('hide');
- }
- $scope.editUnitPriceOrderItem = function(id){
- $('#block').show();
- var input = {};
- input.orderId = $stateParams.orderId;
- input.orderItemId = id;
- if($scope.unitPrice == undefined){
- $scope.closeModalUnitPrice();
- $('#block').hide();
- return [];
- }else{
- $('#block').hide();
- input.unitPrice = $scope.unitPrice;
- if(input.unitPrice < 0){
- swal('Error','Unit price harus lebih dari 0','error');
- return;
- }
- }
- CmsOrderService.editUnitPriceOrderItem(input)
- .then(function(response){
- if(response.data.status == 'OK'){
- $scope.getOrderDetail();
- $scope.closeModalUnitPrice();
- $scope.unitPrice = undefined;
- }else{
- $('#block').hide();
- swal('Error',response.data.error,'error');
- }
- });
- }
- $scope.openModalUnitPrice = function(item,id){
- $scope.oldUnitPrice = item;
- $scope.unitPrice = undefined;
- $('#unitPriceModal').modal('show');
- $scope.selectedOrderItem = id;
- }
- $scope.closeModalUnitPrice = function(){
- $('#unitPriceModal').modal('hide');
- }
- $scope.openModalRemarkInternal = function(order){
- $scope.orderRemarkEdited = order;
- $scope.remarkInternal = order.remark_internal;
- $('#remarkInternalModal').modal('show');
- }
- $scope.closeModalRemarkInternal = function(){
- $('#remarkInternalModal').modal('hide');
- }
- $scope.addRemarkInternalOrder = function(order){
- $('#block').show();
- var input = {};
- input.orderId = $stateParams.orderId;
- input.remarkInternal = $scope.remarkInternal;
- CmsOrderService.addRemarkInternalOrder(input)
- .then(function(response){
- if(response.data.status == 'OK'){
- // $scope.getOrderDetail();
- order.remark_internal = $scope.remarkInternal;
- $scope.closeModalRemarkInternal();
- $('#block').hide();
- // swal('Success','Keterangan Telah Disimpan','success');
- }else{
- $('#block').hide();
- swal('Error',response.data.error,'error');
- }
- });
- }
- $scope.openModalQtyTerima = function(){
- $('#block').show();
- var input = {};
- input.orderId = $stateParams.orderId;
- CmsOrderService.getOrderItemByOrderId(input)
- .then(function(response){
- if(response.data.status == 'OK'){
- $scope.qtyTerimaList = response.data.orderItemList;
- angular.forEach($scope.qtyTerimaList,function(row){
- row.qty_received = row.qty_delivery;
- });
- $('#qtyTerimaModal').modal('show');
- $('#block').hide();
- }else{
- $('#block').hide();
- swal('Error',response.data.error,'error');
- }
- });
- }
- $scope.closeModalQtyTerima = function(){
- $('#qtyTerimaModal').modal('hide');
- }
- $scope.saveQtyTerima = function(){
- $('#block').show();
- var input = {};
- input.orderItem = $scope.qtyTerimaList;
- input.orderId = $stateParams.orderId;
- console.log(input);
- CmsOrderService.editQtyTerimaOrderItem(input)
- .then(function(response){
- if(response.data.status == 'OK'){
- $scope.getOrderDetail();
- $('#qtyTerimaModal').modal('hide');
- $('#statusModal').modal('hide');
- $('#block').hide();
- }else{
- $('#block').hide();
- swal('Error',response.data.error,'error');
- }
- });
- }
- $scope.openFreeProductModal = function(item){
- $('#block').show();
- $scope.qtyOrderFreeProduct = undefined;
- $('#freeProductModal').modal('show');
- var input = {};
- input.styleProduct = item.style_product;
- CmsOrderService.getProductListByStyleProduct(input)
- .then(function(response){
- if(response.data.status == 'OK'){
- $scope.productByStyle = response.data.productList;
- $scope.freeProduct = item;
- $('#block').hide();
- }else{
- $('#block').hide();
- swal('Error',response.data.error,'error');
- }
- });
- }
- $scope.closeFreeProductModal = function(item){
- $('#freeProductModal').modal('hide');
- }
- $scope.addFreeProduct = function(freeProduct){
- $('#block').show();
- var input = {};
- if(angular.isUndefined($scope.productByStyle.selected) || angular.isUndefined($scope.productByStyle.selected.product_id)){
- input.productId = freeProduct.product_id;
- input.productPrice = freeProduct.unit_price;
- }else{
- input.productId = $scope.productByStyle.selected.product_id;
- input.productPrice = $scope.productByStyle.selected.sell_price;
- }
- input.orderId = $stateParams.orderId;
- input.orderItemId = freeProduct.order_item_id;
- input.qtyOrder = $scope.qtyOrderFreeProduct;
- input.discPc = freeProduct.disc_pc;
- CmsOrderService.addFreeProduct(input)
- .then(function(response){
- if(response.data.status == 'OK'){
- $scope.getOrderDetail();
- $('#freeProductModal').modal('hide');
- }else{
- $('#block').hide();
- swal('Error',response.data.error,'error');
- }
- });
- }
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement