Skip to content

Commit

Permalink
Fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
meisyal committed Feb 2, 2016
1 parent eb46ec6 commit 99d2245
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
18 changes: 9 additions & 9 deletions www/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ MIM.controller('SalesController', function ($scope, $ionicPopup, Customer, Produ
$scope.products = products;
});

$scope.addSale = function(saleData) {
$scope.addSale = function (saleData) {
Sale.addTransaction(saleData).then(function (res) {
Sale.addBuying(res.insertId, saleData);
$scope.getRemainingAmount(saleData.products, saleData.amount);
Expand All @@ -58,14 +58,14 @@ MIM.controller('SalesController', function ($scope, $ionicPopup, Customer, Produ
});
};

$scope.getRemainingAmount = function(id, amount) {
$scope.getRemainingAmount = function (id, amount) {
Product.getAmount(id).then(function (productAmount) {
$scope.remaining_amount = productAmount.remaining_amount - amount;
$scope.updateProductAmount(id, $scope.remaining_amount);
});
};

$scope.updateProductAmount = function(id, remaining_amount) {
$scope.updateProductAmount = function (id, remaining_amount) {
Product.updateAmount(id, remaining_amount);
};

Expand Down Expand Up @@ -104,7 +104,7 @@ MIM.controller('SalesOrderController', function ($scope, $ionicModal, $ionicPopu
});
};

$scope.addOrder = function(ordersData) {
$scope.addOrder = function (ordersData) {
Order.addTransaction(ordersData).then(function (res) {
Order.addOrder(res.insertId, ordersData);
Customer.get(ordersData.customers).then(function (customers) {
Expand Down Expand Up @@ -163,7 +163,7 @@ MIM.controller('OrderDetailController', function ($scope, $stateParams, Order) {
});

MIM.controller('AddInventoryController', function ($scope, $ionicPopup, Product) {
$scope.addProduct = function(productData) {
$scope.addProduct = function (productData) {
Product.add(productData);
$scope.showAlert();
productData.newItem = '';
Expand Down Expand Up @@ -194,7 +194,7 @@ MIM.controller('InventoryItemsController', function ($scope, $ionicModal, $ionic
});
};

$scope.editItem = function(productData) {
$scope.editItem = function (productData) {
Product.update(productData);
$scope.populateProducts();
$scope.closeItemModal();
Expand Down Expand Up @@ -272,19 +272,19 @@ MIM.controller('CustomerController', function ($scope, $ionicModal, $ionicPopup,
});

$scope.populateCustomers = function () {
Customer.all().then(function(customers) {
Customer.all().then(function (customers) {
$scope.customers = customers;
});
};

$scope.addCustomer = function(customersData) {
$scope.addCustomer = function (customersData) {
Customer.add(customersData);
$scope.populateCustomers();
$scope.closeCustomerModal(1);
$scope.cleanForm();
};

$scope.editCustomer = function(customersData) {
$scope.editCustomer = function (customersData) {
Customer.update(customersData);
$scope.populateCustomers();
$scope.closeCustomerModal(2);
Expand Down
38 changes: 20 additions & 18 deletions www/js/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,31 @@ MIM.factory('DB', function ($q, $ionicPlatform, $cordovaSQLite) {

MIM.factory('Customer', function ($cordovaSQLite, DB) {
this.all = function () {
return DB.queryStatement("SELECT id, name FROM Customers").then(function (res) {
return DB.queryStatement('SELECT id, name FROM Customers').then(function (res) {
return DB.getAll(res);
});
};

this.get = function (customerId) {
var parameters = [customerId];
return DB.queryStatement("SELECT id, name, address, telephone_number, " +
"DATETIME(created_at, \'localtime\') AS joined_date, " +
"DATETIME(updated_at, \'localtime\') AS updated_date FROM Customers " +
"WHERE id = ?", parameters).then(function (res) {
return DB.getById(res);
return DB.queryStatement('SELECT id, name, address, telephone_number, ' +
'DATETIME(created_at, \'localtime\') AS joined_date, ' +
'DATETIME(updated_at, \'localtime\') AS updated_date FROM Customers ' +
'WHERE id = ?', parameters).then(function (res) {
return DB.getById(res);
});
};

this.add = function(customer) {
this.add = function (customer) {
var parameters = [customer.name, customer.address, customer.phone];
return DB.queryStatement("INSERT INTO Customers (name, address, telephone_number) " +
"VALUES (?, ?, ?)", parameters);
return DB.queryStatement('INSERT INTO Customers (name, address, telephone_number) ' +
'VALUES (?, ?, ?)', parameters);
};

this.update = function (customer) {
var parameters = [customer.name, customer.address, customer.phone, customer.id];
return DB.queryStatement('UPDATE Customers SET name = ?, address = ?, telephone_number = ?, ' +
'updated_at = DATETIME(\'now\') WHERE id = ?', parameters);
return DB.queryStatement('UPDATE Customers SET name = ?, address = ?, ' +
'telephone_number = ?, updated_at = DATETIME(\'now\') WHERE id = ?', parameters);
};

this.delete = function (customer) {
Expand All @@ -81,14 +81,15 @@ MIM.factory('Customer', function ($cordovaSQLite, DB) {

MIM.factory('Product', function ($cordovaSQLite, DB) {
this.all = function () {
return DB.queryStatement("SELECT id, name FROM Products").then(function (res) {
return DB.queryStatement('SELECT id, name FROM Products').then(function (res) {
return DB.getAll(res);
});
};

this.hasAmount = function () {
return DB.queryStatement('SELECT id, name FROM Products WHERE remaining_amount > 0').then(function (res) {
return DB.getAll(res);
return DB.queryStatement('SELECT id, name FROM Products WHERE remaining_amount > 0')
.then(function (res) {
return DB.getAll(res);
});
};

Expand All @@ -98,14 +99,15 @@ MIM.factory('Product', function ($cordovaSQLite, DB) {
'selling_price, purchase_price, DATETIME(created_at, \'localtime\') AS ' +
'created_date, DATETIME(updated_at, \'localtime\') AS updated_date ' +
'FROM Products WHERE id = ?', parameters).then(function (res) {
return DB.getById(res);
return DB.getById(res);
});
};

this.getAmount = function (productId) {
var parameters = [productId];
return DB.queryStatement('SELECT remaining_amount FROM Products WHERE id = ?', parameters).then(function (res) {
return DB.getById(res);
return DB.queryStatement('SELECT remaining_amount FROM Products WHERE id = ?', parameters)
.then(function (res) {
return DB.getById(res);
});
};

Expand Down Expand Up @@ -146,7 +148,7 @@ MIM.factory('Product', function ($cordovaSQLite, DB) {
this.orderByAmount = function () {
return DB.queryStatement('SELECT id, name, remaining_amount FROM Products ' +
'ORDER BY remaining_amount DESC').then(function (res) {
return DB.getAll(res);
return DB.getAll(res);
});
};

Expand Down

0 comments on commit 99d2245

Please sign in to comment.