From 72fc36c8f53e49bc8524c84fcece0662f93111ff Mon Sep 17 00:00:00 2001 From: jekkos Date: Wed, 6 Jan 2016 19:29:33 +0100 Subject: [PATCH 1/8] Add (temp) fix for cur_page conuter in CI pagination libary (#284) Fix .htaccess file --- .htaccess | 4 ++-- system/libraries/Pagination.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.htaccess b/.htaccess index 255e6fa6c..44ee30c48 100755 --- a/.htaccess +++ b/.htaccess @@ -13,7 +13,7 @@ RewriteRule ^(.*)$ index.php?/$1 [L] # disable directory browsing # For security reasons, Option all cannot be overridden. #Options All -Indexes -Options ExecCGI Includes IncludesNOEXEC SymLinksIfOwnerMatch -Indexes +Options +ExecCGI +Includes +IncludesNOEXEC +SymLinksIfOwnerMatch -Indexes # prevent folder listing IndexIgnore * @@ -29,4 +29,4 @@ IndexIgnore * order allow,deny deny from all satisfy All - \ No newline at end of file + diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index cef98ebf4..e573d4285 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -497,7 +497,7 @@ class CI_Pagination { { $this->cur_page = $this->CI->input->get($this->query_string_segment); } - else + else if (!$this->cur_page) { // Default to the last segment number if one hasn't been defined. if ($this->uri_segment === 0) From 195c8a06013bb7552c79f95a2c76c9c7e4371a66 Mon Sep 17 00:00:00 2001 From: jekkos Date: Thu, 21 Jan 2016 16:23:54 +0100 Subject: [PATCH 2/8] Make docker work with 2.4 branch --- Dockerfile | 1 + system/libraries/Pagination.php | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 07aa6ddec..b1a667d67 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ RUN git clone https://github.com/jekkos/opensourcepos.git /app # RUN cd app && npm install RUN ln -fs /app/* /var/www +RUN rm /var/www/index.html ADD ./start_container.sh /start_container.sh RUN chmod 755 /start_container.sh EXPOSE 80 3306 diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index e573d4285..9a0db9664 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -512,14 +512,16 @@ class CI_Pagination { { $this->cur_page = str_replace(array($this->prefix, $this->suffix), '', $this->cur_page); } - } + } else { + $this->cur_page = (string) $this->cur_page; + } // If something isn't quite right, back to the default base page. if ( ! ctype_digit($this->cur_page) OR ($this->use_page_numbers && (int) $this->cur_page === 0)) { $this->cur_page = $base_page; } - else + elseif (empty($this->cur_page)) { // Make sure we're using integers for comparisons later. $this->cur_page = (int) $this->cur_page; From 8f9d80a80960590fb3b35eef0c0510d8e3d8823e Mon Sep 17 00:00:00 2001 From: jekkos Date: Fri, 29 Jan 2016 08:38:55 +0100 Subject: [PATCH 3/8] Wait for container before running integration tests (#305) Add integratoin test for quantity units (#305) --- .travis.yml | 10 ++++++---- Dockerfile | 2 +- test/make_sale_receiving.js | 27 ++++++++++++--------------- test/ospos.js | 22 ++++++++++++++++++---- test/receiving_quantity.js | 31 +++++++++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 24 deletions(-) create mode 100644 test/receiving_quantity.js diff --git a/.travis.yml b/.travis.yml index 6158f70ac..7c85fe0f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,16 @@ sudo: false - + language: node_js +node_js: + - "4.1" + services: - docker before_install: - docker build -t jekkos/opensourcepos . - - docker run -d -p 127.0.0.1:80:80 jekkos/opensourcepos - - sleep 4 + - docker run -d jekkos/opensourcepos script: - - docker exec -t -i $(docker ps | tail -n 1 | cut -d' ' -f1) /bin/sh -c "cd /app; grunt mochaWebdriver:test" + - docker exec -t -i $(docker ps | tail -n 1 | cut -d' ' -f1) /bin/sh -c "wget --retry-connrefused --tries=5 -q --waitretry=3 --spider http://localhost/index.php && cd /app && grunt mochaWebdriver:test" diff --git a/Dockerfile b/Dockerfile index 89e010c03..6e9517c6e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:trusty MAINTAINER jekkos RUN apt-get update RUN apt-get -y upgrade -RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-client mysql-server apache2 libapache2-mod-php5 pwgen python-setuptools vim-tiny php5-mysql php5-gd nodejs npm +RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-client mysql-server apache2 libapache2-mod-php5 pwgen python-setuptools vim-tiny php5-mysql php5-gd nodejs npm wget RUN easy_install supervisor ADD ./docker/foreground.sh /etc/apache2/foreground.sh ADD ./docker/supervisord.conf /etc/supervisord.conf diff --git a/test/make_sale_receiving.js b/test/make_sale_receiving.js index 1a3c4471b..ff4d0d59c 100644 --- a/test/make_sale_receiving.js +++ b/test/make_sale_receiving.js @@ -4,26 +4,23 @@ var ospos = require('./ospos'); describe("create item and make sale", function () { this.timeout(25000); + var def_timeout = 3000; + + var item = {name: "anItem", category: "aCategory", cost_price: 10, unit_price: 20}; + it("should be able to add item", function (done) { - return this.browser.get(ospos.url("/index.php/items")).elementByCssSelector("a[title='New Item']", 5000).click() - .waitForElementByName("name", 10000).type("anItem").elementById("category").type("aCategory") - .elementById('cost_price', 2000).clear().type("10").elementById("unit_price", 2000).type("20") - .elementById('tax_name_1', 2000).type('VAT').elementById("tax_percent_name_1", 2000).type("21") - .elementById("1_quantity", 2000).type("1").elementById("reorder_level", 2000).type("0").elementById("submit", 2000).click() - .waitForElementByXPath("//table/tbody/tr[td/text()='anItem']/td[3]").text().then(function (value) { - assert.equal(value, "anItem", "item could not be created!!"); - }).then(done, done); + return ospos.create_item(this.browser, item).then(done, done); }); it("should be able to make sale", function(done) { return this.browser.get(ospos.url("/index.php/sales")) - .elementById("item", 3000).type("1\r\n") - .waitForElementByName("quantity", 5000).clear().type("2").elementByName("discount", 1000).type("10").elementByName("edit_item").click() - .elementById("add_payment_button", 2000).click().elementByCssSelector("tbody#payment_contents tr td:last-child", 5000).text().then(function(value) { + .elementById("item", def_timeout).type("1\r\n") + .waitForElementByName("quantity", def_timeout).clear().type("2").elementByName("discount", def_timeout).type(item.cost_price).elementByName("edit_item").click() + .elementById("add_payment_button", def_timeout).click().elementByCssSelector("tbody#payment_contents tr td:last-child", def_timeout).text().then(function(value) { assert.equal(value, "$43.56", "price " + value + " in sale register is not correct!!"); - }).elementById("finish_sale_button", 3000).submit().elementByCssSelector("#receipt_items tbody tr:nth-child(7) td:last-child", 5000).text().then(function(value) { + }).elementById("finish_sale_button", def_timeout).submit().elementByCssSelector("#receipt_items tbody tr:nth-child(7) td:last-child", def_timeout).text().then(function(value) { assert.equal(value, "$43.56", "price " + value + " on sale receipt is not correct!!"); - }).elementByCssSelector("#receipt_items tbody tr:nth-child(9) td:last-child div.total-value", 5000).text().then(function(value) { + }).elementByCssSelector("#receipt_items tbody tr:nth-child(9) td:last-child div.total-value", def_timeout).text().then(function(value) { assert.equal(value, "-$43.56", "payment amount " + value + " on sale receipt is not correct!!") }).then(done, done); }); @@ -31,8 +28,8 @@ describe("create item and make sale", function () { it("should be able to make receiving", function(done) { return this.browser.get(ospos.url("/index.php/receivings")) - .elementById("item", 3000).type("1\r\n") - .waitForElementByName("quantity", 3000).clear().type("2").elementByName("edit_item").click() + .elementById("item", def_timeout).type("1\r\n") + .waitForElementByName("quantity", def_timeout).clear().type("2").elementByName("edit_item").click() .elementByCssSelector("td:nth-last-child(2)").text().then(function(value) { assert.equal(value, "$20.00", "price " + value + " in receiving register is not correct!!"); }).elementById("finish_receiving_button").submit().elementByCssSelector("#receipt_items tbody tr:nth-last-child(2) td:nth-child(2) div.total-value").text().then(function(value) { diff --git a/test/ospos.js b/test/ospos.js index 5d9d023ba..a361b6386 100644 --- a/test/ospos.js +++ b/test/ospos.js @@ -2,7 +2,7 @@ var assert = require('assert'); var ospos = function() { - var server = "http://localhost"; + var server = "http://localhost/index.php"; return { @@ -13,20 +13,34 @@ var ospos = function() { login : function(browser, done) { return browser.get(this.url("/index.php")) .elementByName('username').type("admin").getValue() - .then(function(value) { + .then(function (value) { assert.equal(value, "admin"); }) .elementByName('password').type("pointofsale").getValue() - .then(function(value) { + .then(function (value) { assert.ok(value, "pointofsale"); }) .elementByName('loginButton').click() - .elementById('home_module_list').then(function(value) { + .elementById('home_module_list').then(function (value) { assert.ok(value, "Login failed!!") }) .then(done, done); + }, + + create_item : function(browser, item) + { + return browser.get(this.url("/index.php/items")).elementByCssSelector("a[title='New Item']", 5000).click() + .waitForElementByName("name", 10000).type(item.name).elementById("category").type(item.category) + .elementById('cost_price', 2000).clear().type(item.cost_price).elementById("unit_price", 2000).type(item.unit_price) + .elementById('tax_name_1', 2000).type('VAT').elementById("tax_percent_name_1", 2000).type("21") + .elementById('receiving_quantity', 2000).type(item.receiving_quantity || 1) + .elementById("1_quantity", 2000).type("1").elementById("reorder_level", 2000).type("0").elementById("submit", 2000).click() + .waitForElementByXPath("//table/tbody/tr[td/text()='anItem']/td[3]").text().then(function (value) { + assert.equal(value, "anItem", "item " + item.name + " could not be created!!"); + }); } + } }; diff --git a/test/receiving_quantity.js b/test/receiving_quantity.js new file mode 100644 index 000000000..38a30e38e --- /dev/null +++ b/test/receiving_quantity.js @@ -0,0 +1,31 @@ +var assert = require('assert'); +var ospos = require('./ospos'); + +describe("test receiving quantity", function() { + + var def_timeout = 5000; + + var item = { + name: "recvQty", + category: "aCategory", + cost_price: 10, + unit_price: 20, + receiving_quantity: 2 + }; + + it("should be able to creaate item with receiving quantity", function(done) { + return ospos.create_item(this.browser, item).then(done, done); + }); + + it("should be able to receive quantities with multiplier", function(done) { + this.browser.get(ospos.url('/index.php/receivings')).elementById("item").type(item.name) + .waitForElementByCssSelector(".ac_even", def_timeout).click().waitForElementByName("quantity", def_timeout) + .elementByCssSelector("#cart_contents tr td:nth-child(5)").text().then(function(value) { + assert(value, "x " + item.receiving_quantity, "receiving quantity " + item.receiving_quantity + " is not displayed correctly in receivings module!"); + }).elementById("finish_receiving_button", def_timeout).submit() + .elementByCssSelector("#receipt_items tr:nth-child(2) td:nth-last-child(2)", def_timeout).text().then(function(value) { + assert(value, "1 x " + item.receiving_quantity, "receiving quantity " + item.receiving_quantity + " is not displayed correctly on receipt!!"); + }).then(done, done); + }); + +}); \ No newline at end of file From fa3d77299eeeda89d80e271a30e6b491adb7705a Mon Sep 17 00:00:00 2001 From: jekkos Date: Sun, 31 Jan 2016 15:24:42 +0100 Subject: [PATCH 4/8] Use curl to wait for apache start (#305) --- .travis.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7c85fe0f7..ff00e26be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,4 +13,4 @@ before_install: - docker run -d jekkos/opensourcepos script: - - docker exec -t -i $(docker ps | tail -n 1 | cut -d' ' -f1) /bin/sh -c "wget --retry-connrefused --tries=5 -q --waitretry=3 --spider http://localhost/index.php && cd /app && grunt mochaWebdriver:test" + - docker exec -t -i $(docker ps | tail -n 1 | cut -d' ' -f1) /bin/sh -c "while ! curl http://localhost/index.php; do sleep 1; done; cd app && grunt mochaWebdriver:test" diff --git a/Dockerfile b/Dockerfile index b739ecd69..23df9b96f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:trusty MAINTAINER jekkos RUN apt-get update RUN apt-get -y upgrade -RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-client mysql-server apache2 libapache2-mod-php5 pwgen python-setuptools vim-tiny php5-mysql php5-gd nodejs npm wget +RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-client mysql-server apache2 libapache2-mod-php5 pwgen python-setuptools vim-tiny php5-mysql php5-gd nodejs npm curl RUN easy_install supervisor ADD ./docker/foreground.sh /etc/apache2/foreground.sh ADD ./docker/supervisord.conf /etc/supervisord.conf From 35d53e2fae2e626f49dcfd769aaf8b76d08cfd22 Mon Sep 17 00:00:00 2001 From: jekkos Date: Wed, 3 Feb 2016 10:49:20 +0100 Subject: [PATCH 5/8] Fix base url for testcases (#305) Fix legacy ubuntu repository urls (#284) --- Dockerfile | 4 ++-- test/ospos.js | 60 +++++++++++++++++++++++++-------------------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Dockerfile b/Dockerfile index 23df9b96f..5578caddf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ -FROM ubuntu:trusty +FROM ubuntu:utopic MAINTAINER jekkos +RUN sed -i -e 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list RUN apt-get update RUN apt-get -y upgrade RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-client mysql-server apache2 libapache2-mod-php5 pwgen python-setuptools vim-tiny php5-mysql php5-gd nodejs npm curl @@ -20,7 +21,6 @@ RUN npm install -g grunt-cli RUn ln -s /usr/local/bin/grunt /usr/bin/grunt RUN ln -fs /app/* /var/www/html -RUN rm /var/www/index.html ADD ./docker/start_container.sh /start_container.sh RUN chmod 755 /start_container.sh EXPOSE 80 3306 diff --git a/test/ospos.js b/test/ospos.js index a361b6386..b26f5be6f 100644 --- a/test/ospos.js +++ b/test/ospos.js @@ -2,7 +2,7 @@ var assert = require('assert'); var ospos = function() { - var server = "http://localhost/index.php"; + var server = "http://localhost"; return { @@ -10,38 +10,38 @@ var ospos = function() { return server + suffix; } , - login : function(browser, done) { - return browser.get(this.url("/index.php")) - .elementByName('username').type("admin").getValue() - .then(function (value) { - assert.equal(value, "admin"); - }) - .elementByName('password').type("pointofsale").getValue() - .then(function (value) { - assert.ok(value, "pointofsale"); - }) - .elementByName('loginButton').click() - .elementById('home_module_list').then(function (value) { - assert.ok(value, "Login failed!!") - }) - .then(done, done); + login : function(browser, done) { + return browser.get(this.url("/index.php")) + .elementByName('username').type("admin").getValue() + .then(function (value) { + assert.equal(value, "admin"); + }) + .elementByName('password').type("pointofsale").getValue() + .then(function (value) { + assert.ok(value, "pointofsale"); + }) + .elementByName('loginButton').click() + .elementById('home_module_list').then(function (value) { + assert.ok(value, "Login failed!!") + }) + .then(done, done); - }, + }, - create_item : function(browser, item) - { - return browser.get(this.url("/index.php/items")).elementByCssSelector("a[title='New Item']", 5000).click() - .waitForElementByName("name", 10000).type(item.name).elementById("category").type(item.category) - .elementById('cost_price', 2000).clear().type(item.cost_price).elementById("unit_price", 2000).type(item.unit_price) - .elementById('tax_name_1', 2000).type('VAT').elementById("tax_percent_name_1", 2000).type("21") - .elementById('receiving_quantity', 2000).type(item.receiving_quantity || 1) - .elementById("1_quantity", 2000).type("1").elementById("reorder_level", 2000).type("0").elementById("submit", 2000).click() - .waitForElementByXPath("//table/tbody/tr[td/text()='anItem']/td[3]").text().then(function (value) { - assert.equal(value, "anItem", "item " + item.name + " could not be created!!"); - }); - } + create_item : function(browser, item) + { + return browser.get(this.url("/index.php/items")).elementByCssSelector("a[title='New Item']", 5000).click() + .waitForElementByName("name", 10000).type(item.name).elementById("category").type(item.category) + .elementById('cost_price', 2000).clear().type(item.cost_price).elementById("unit_price", 2000).type(item.unit_price) + .elementById('tax_name_1', 2000).type('VAT').elementById("tax_percent_name_1", 2000).type("21") + .elementById('receiving_quantity', 2000).type(item.receiving_quantity || 1) + .elementById("1_quantity", 2000).type("1").elementById("reorder_level", 2000).type("0").elementById("submit", 2000).click() + .waitForElementByXPath("//table/tbody/tr[td/text()='anItem']/td[3]").text().then(function (value) { + assert.equal(value, "anItem", "item " + item.name + " could not be created!!"); + }); + } } }; -module.exports = ospos(); \ No newline at end of file +module.exports = ospos(); From e598817287fe51cbf87a553bb1e6bd9403406d8b Mon Sep 17 00:00:00 2001 From: jekkos Date: Wed, 3 Feb 2016 17:18:28 +0100 Subject: [PATCH 6/8] Set correct version for npm package --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 31472a0f4..50c850e02 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opensourcepos", - "version": "2.3.3", + "version": "2.4.0", "description": "Open Source Point of Sale is a web based point of sale system written in the PHP language. It uses MySQL as the data storage back-end and has a simple user interface.", "main": "index.php", "scripts": { From 5c16c2a21ab1f4546d94d9b9dd235a3df22ada76 Mon Sep 17 00:00:00 2001 From: jekkos Date: Wed, 3 Feb 2016 10:49:20 +0100 Subject: [PATCH 7/8] Use grep and wait for mysql to come up properly (#305) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ff00e26be..94d0f227a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,4 +13,4 @@ before_install: - docker run -d jekkos/opensourcepos script: - - docker exec -t -i $(docker ps | tail -n 1 | cut -d' ' -f1) /bin/sh -c "while ! curl http://localhost/index.php; do sleep 1; done; cd app && grunt mochaWebdriver:test" + - docker exec -t -i $(docker ps | tail -n 1 | cut -d' ' -f1) /bin/sh -c "while ! curl http://localhost/index.php | grep username; do sleep 1; done; cd app && grunt mochaWebdriver:test" From 36cf19b1b998dee5578a17d031c8fd603b9ecb52 Mon Sep 17 00:00:00 2001 From: jekkos Date: Thu, 4 Feb 2016 23:09:03 +0100 Subject: [PATCH 8/8] Properly save company_name in customer form --- application/controllers/Customers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/Customers.php b/application/controllers/Customers.php index c1d155a76..201a1d3fd 100644 --- a/application/controllers/Customers.php +++ b/application/controllers/Customers.php @@ -73,7 +73,7 @@ class Customers extends Person_controller ); $customer_data=array( 'account_number'=>$this->input->post('account_number') == '' ? null : $this->input->post('account_number'), - 'company_name'=>$this->input->post('company_name') == '' ? null : $this->input->post('account_number'), + 'company_name'=>$this->input->post('company_name') == '' ? null : $this->input->post('company_name'), 'taxable'=>$this->input->post('taxable') != null ); if($this->Customer->save_customer($person_data,$customer_data,$customer_id))