From 99d2245f6a854b7751d6ba8ec8ca978b612e6afc Mon Sep 17 00:00:00 2001 From: Andrias Meisyal Date: Tue, 2 Feb 2016 17:07:22 +0700 Subject: [PATCH] Fix indentation --- www/js/controllers.js | 18 +++++++++--------- www/js/services.js | 38 ++++++++++++++++++++------------------ 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/www/js/controllers.js b/www/js/controllers.js index acbc0ad..efd0402 100644 --- a/www/js/controllers.js +++ b/www/js/controllers.js @@ -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); @@ -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); }; @@ -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) { @@ -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 = ''; @@ -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(); @@ -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); diff --git a/www/js/services.js b/www/js/services.js index b6b53c2..0fd598c 100644 --- a/www/js/services.js +++ b/www/js/services.js @@ -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) { @@ -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); }); }; @@ -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); }); }; @@ -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); }); };