Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- 'use strict';
- angular.module("receiveGoodsModule")
- .controller("InputReceiveGoodsController", InputReceiveGoodsController);
- InputReceiveGoodsController.$inject = ['$scope' ,'RestService', '$filter', '$state', 'NotificationService', 'ReceiveGoodsApiConstant','LeafCommonConstant','SupplierApiConstant','$uibModal'];
- function InputReceiveGoodsController($scope, RestService, $filter, $state, NotificationService, ReceiveGoodsApiConstant, LeafCommonConstant, SupplierApiConstant, $uibModal) {
- onTop();
- document.title = $state.params.title;
- var ctrl = $scope;
- ctrl.doAction = doAction;
- ctrl.submitReceiveGoods = submitReceiveGoods;
- var id = getParams("detailReceiveGoods");
- ctrl.summary = {};
- ctrl.receiveGoodsItemList = [];
- ctrl.errors = [];
- ctrl.readOnly = false;
- ctrl.disabled = false;
- var date = new Date();
- if(id == -99)
- {
- ctrl.input = {
- "refId": -99,
- "refDocTypeId": -99,
- "docDate": date,
- "extDocNo" : "",
- "extDc": "",
- "remark": "",
- "supplierId": "",
- "dateConfirm" : ""
- }
- }
- else{
- ctrl.input = {};
- findReceiveGoodsById();
- }
- doReset();
- getSupplierList();
- function doReset()
- {
- ctrl.errors = [];
- }
- function getSupplierList() {
- var input = {};
- RestService.call(SupplierApiConstant.GET_SUPPLIER_LIST, input)
- .then(function (response) {
- var result = response.result;
- if(result.status == "OK") {
- ctrl.supplierList = result.supplierList;
- } else {
- onTop();
- NotificationService.errorData();
- ctrl.errors = result;
- }
- })
- }
- function findReceiveGoodsById(){
- RestService.call(ReceiveGoodsApiConstant.FIND_RECEIVE_GOODS_BY_ID,{"id" : id})
- .then(function (response){
- var result = response.result;
- console.log(" findReceiveGoodsById");
- console.log(result);
- if(result.status == 'OK')
- {
- ctrl.input = result;
- ctrl.input.DocDate = $filter("converterDate")(ctrl.input.docDate);
- ctrl.input.extDocDate = $filter("converterDate")(ctrl.input.extDocDate);
- if(ctrl.input.statusDoc = 'D')
- {
- ctrl.disabled = true;
- ctrl.readOnly = true;
- }
- getReceiveGoodsItemList();
- findSummaryReceiveGoodsById();
- }
- else
- {
- onTop();
- NotificationService.errorData();
- ctrl.errors = result;
- }
- })
- }
- function getReceiveGoodsItemList(){
- RestService.call(ReceiveGoodsApiConstant.GET_RECEIVE_GOODS_ITEM_LIST, {"receiveGoodsId" : id})
- .then(function(response) {
- var result = response.result;
- console.log(" getReceiveGoodsItemList ");
- console.log(result);
- if(result.satus == "OK")
- {
- ctrl.receiveGoodsItemList = result.receiveGoodsItemList;
- }
- else
- {
- onTop();
- NotificationService.errorData();
- ctrl.errors = result;
- }
- })
- }
- function findSummaryReceiveGoodsById() {
- RestService.call(ReceiveGoodsApiConstant.FIND_SUMMARY_RECEIVE_GOODS_BY_ID, {"receiveGoodsId" : id})
- .then(function(response){
- var result = response.result;
- if(result.status == "OK"){
- ctrl.summary = result;
- }
- else{
- onTop();
- NotificationService.errorData();
- ctrl.errors = result
- }
- })
- }
- function doAction(){
- doReset();
- doPrepareEditDocument();
- }
- function doPrepareEditDocument(){
- var input = angular.copy(ctrl.input);
- input.extDocDate = $filter("converterDateString")(ctrl.input.extDocDate);
- RestService.call(ReceiveGoodsApiConstant.EDIT_RECEIVE_GOODS, input)
- .then(function(response){
- var result = response.result;
- if(result.status == "OK")
- {
- NotificationService.editData();
- findReceiveGoodsById();
- }
- else
- {
- NotificationService.errorData();
- ctrl.errors = result
- }
- })
- }
- function submitReceiveGoods(){
- onTop();
- var input = {
- "receiveGoodsId" : id,
- "version" : ctrl.input.version,
- "statusDoc" : "R",
- "dateConfirm" : $filter("converterDateString")(ctrl.input.dateConfirm)
- };
- altertify.confirm('Apakah anda yakin submit dokumen'+ctrl.input.docNo+'?', function(){
- RestService.call(ReceiveGoodsApiConstant.SUBMIT_PURCHASE_ORDER, input)
- .then(function(){
- var result = response.result;
- if(result.response == "OK"){
- NotificationService.submitData();
- findReceiveGoodsById();
- }
- else{
- onTop();
- NotificationService.errorData();
- ctrl.errors = result;
- }
- })
- });
- }
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement