Skip to content
This repository has been archived by the owner on Mar 24, 2019. It is now read-only.

Commit

Permalink
Continues the development.
Browse files Browse the repository at this point in the history
  • Loading branch information
alvachien committed Nov 3, 2015
1 parent 9b931e8 commit 5707b03
Show file tree
Hide file tree
Showing 17 changed files with 542 additions and 281 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Built with AngularJS, Angular UI, TinyMCE, etc. See more in Acknowledge menu.
- 2015.10.20, It's DECIDED that the stored procedure in DB layer only conver simple CREATE/UPDATE/DELETE operation no others. The reason we need stored procedure is that
- We need LAST_INSERT_ID() in Creation case; [?] <= However, via mysqli->insert_id can anyway get the new insert ID out!
- We need transaction in any case; [?] <= It can also achieve in PHP layer!
- 2015.11.3, It's DECIDED that the HIH using 'yyyy.MM.dd' as the default UI format for date for now. The customizing the date formatting waiting for next version. The ISO format 'yyyy-MM-dd' for database storage is no change.
- To be updated.

### HIH, version web 0.1 to web 0.3
Expand Down
3 changes: 2 additions & 1 deletion Sqls/DBPrepation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,8 @@ END;
====================================================== */

--Finance part
-- Account categoryINSERT INTO `t_fin_account_ctgy` (`ID`,`NAME`,`ASSETFLAG`,`COMMENT`) VALUES (1,'现金',1,NULL);
-- Account category
INSERT INTO `t_fin_account_ctgy` (`ID`,`NAME`,`ASSETFLAG`,`COMMENT`) VALUES (1,'现金',1,NULL);
INSERT INTO `t_fin_account_ctgy` (`ID`,`NAME`,`ASSETFLAG`,`COMMENT`) VALUES (2,'存储卡',1,NULL);
INSERT INTO `t_fin_account_ctgy` (`ID`,`NAME`,`ASSETFLAG`,`COMMENT`) VALUES (3,'信用卡',1,NULL);
INSERT INTO `t_fin_account_ctgy` (`ID`,`NAME`,`ASSETFLAG`,`COMMENT`) VALUES (4,'应付账款',0,'如贷款等');
Expand Down
79 changes: 38 additions & 41 deletions app/controllers/finance.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
// Grid options
$scope.selectedRows = [];
$scope.gridOptions = {};
$scope.gridOptions.data = 'myData';
$scope.gridOptions.data = 'arFinanceAccount';
$scope.gridOptions.enableSorting = true;
$scope.gridOptions.enableColumnResizing = true;
$scope.gridOptions.enableFiltering = true;
Expand Down Expand Up @@ -340,12 +340,7 @@
.then(function(response) {
utils.loadFinanceAccountsQ()
.then(function(response2) {
if (angular.isArray($rootScope.arFinanceAccount) && $rootScope.arFinanceAccount.length > 0) {
$scope.myData = [];
$.each($rootScope.arFinanceAccount, function(idx, obj) {
$scope.myData.push(angular.copy(obj));
});
}
// Do nothing...
}, function(reason2) {
// Error occurred
$rootScope.$broadcast("ShowMessage", "Error", reason2);
Expand Down Expand Up @@ -409,12 +404,7 @@
$scope.refreshList = function() {
utils.loadFinanceAccountsQ(true)
.then(function(response2) {
if (angular.isArray($rootScope.arFinanceAccount ) && $rootScope.arFinanceAccount.length > 0) {
$scope.myData = [];
$.each($rootScope.arFinanceAccount, function(idx, obj) {
$scope.myData.push(angular.copy(obj));
});
}
// Do nothing!
}, function(reason2) {
// Error occurred
$rootScope.$broadcast("ShowMessage", "Error", reason2);
Expand Down Expand Up @@ -518,11 +508,9 @@
.controller('FinanceAccountController', ['$scope', '$rootScope', '$state', '$stateParams', '$http', '$translate', '$q', 'utils',
function($scope, $rootScope, $state, $stateParams, $http, $translate, $q, utils) {
$scope.Activity = "";
$scope.isReadonly = false;
$scope.ActivityID = hih.Constants.UIMode_Create;

$scope.AccountObject = new hih.FinanceAccount();
$scope.AccountCategoryObject = {};
$scope.AllAccountCategories = $rootScope.arFinanceAccountCategory;

// Messages
$scope.ReportedMessages = [];
Expand All @@ -533,16 +521,16 @@
if (angular.isDefined($stateParams.accountid)) {
if ($state.current.name === "home.finance.account.maintain") {
$scope.Activity = "Common.Edit";
$scope.ActivityID = hih.Constants.UIMode_Change;
} else if ($state.current.name === "home.finance.account.display") {
$scope.Activity = "Common.Display";
$scope.isReadonly = true;
$scope.ActivityID = hih.Constants.UIMode_Display;
}

var nAcntID = parseInt($stateParams.accountid);
$.each($rootScope.arFinanceAccount, function (idx, obj) {
if (obj.ID === nAcntID) {
$scope.AccountObject = angular.copy(obj);
$scope.AccountCategoryObject.selected = obj.CategoryObject;
return false;
}
});
Expand All @@ -553,19 +541,13 @@
$scope.submit = function() {
$scope.cleanReportMessages();

// Update the category id
if ($scope.AccountCategoryObject.selected) {
if ($scope.AccountObject.CategoryID !== $scope.AccountCategoryObject.selected.ID) {
$scope.AccountObject.CategoryID = $scope.AccountCategoryObject.selected.ID;
}
} else {
$scope.AccountObject.CategoryID = -1;
}

var errMsgs = $scope.AccountObject.Verify();
// String => Integer
$scope.AccountObject.CategoryID = parseInt($scope.AccountObject.CategoryID);

var errMsgs = $scope.AccountObject.Verify($translate);
if (errMsgs && errMsgs.length > 0) {
$q.all(errMsgs).then(function (translations) {
Array.prototype.push.call($scope.cleanReportMessages, translations);
Array.prototype.push.call($scope.ReportedMessages, translations);
}, function(reason) {
$rootScope.$broadcast("ShowMessage", "Error", reason);
});
Expand All @@ -575,18 +557,33 @@
// Now submit to the server side
var strJSON = JSON && JSON.stringify($scope.AccountObject) || $.toJSON($scope.AccountObject);
if (strJSON) {
utils.createFinanceAccountQ(strJSON)
.then(function(response) {
// First of all, update the rootScope
if (response) {
$state.go("home.finance.account.display", { accountid : response });
} else {
$state.go("home.finance.account.list");
}
}, function(reason) {
// Failed, throw out error message
$rootScope.$broadcast("ShowMessage", "Error", reason);
});
if (this.ActivityID === hih.Constants.UIMode_Create) {
utils.createFinanceAccountQ(strJSON)
.then(function(response) {
// First of all, update the rootScope
if (response) {
$state.go("home.finance.account.display", { accountid : response });
} else {
$state.go("home.finance.account.list");
}
}, function(reason) {
// Failed, throw out error message
$rootScope.$broadcast("ShowMessage", "Error", reason);
});
} else if (this.ActivityID === hih.Constants.UIMode_Change) {
utils.changeFinanceAccountQ($scope.AccountObject)
.then(function(response) {
// First of all, update the rootScope
if (response) {
$state.go("home.finance.account.display", { accountid : response });
} else {
$state.go("home.finance.account.list");
}
}, function(reason) {
// Failed, throw out error message
$rootScope.$broadcast("ShowMessage", "Error", reason);
});
}
} else {
$rootScope.$broadcast("ShowMessage", "Error", "To-Do: reason");
}
Expand Down
Loading

0 comments on commit 5707b03

Please sign in to comment.